diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 00000000..4d49c113 Binary files /dev/null and b/.DS_Store differ diff --git a/20260226一场.zip b/20260226一场.zip new file mode 100644 index 00000000..12cff4f6 Binary files /dev/null and b/20260226一场.zip differ diff --git a/miniprogram/app.js b/miniprogram/app.js index 336ad0eb..1e92c013 100644 --- a/miniprogram/app.js +++ b/miniprogram/app.js @@ -431,6 +431,7 @@ App({ url: this.globalData.baseUrl + url, method: options.method || 'GET', data: options.data || {}, + timeout: options.timeout || 15000, header: { 'Content-Type': 'application/json', 'Authorization': token ? `Bearer ${token}` : '', diff --git a/miniprogram/app.json b/miniprogram/app.json index 2912c1ff..05b5bff2 100644 --- a/miniprogram/app.json +++ b/miniprogram/app.json @@ -57,7 +57,10 @@ ] }, "usingComponents": {}, - "navigateToMiniProgramAppIdList": [], + "navigateToMiniProgramAppIdList": [ + "wx6489c26045912fe1", + "wx3d15ed02e98b04e3" + ], "__usePrivacyCheck__": true, "lazyCodeLoading": "requiredComponents", "style": "v2", diff --git a/miniprogram/pages/index/index.js b/miniprogram/pages/index/index.js index 994bf21e..a2950732 100644 --- a/miniprogram/pages/index/index.js +++ b/miniprogram/pages/index/index.js @@ -108,13 +108,15 @@ Page({ this.updateUserStatus() }, - // 初始化数据:首次进页面并行异步加载,加快首屏展示 initData() { - this.setData({ loading: false }) - this.loadBookData() - this.loadFeaturedFromServer() - this.loadSuperMembers() - this.loadLatestChapters() + Promise.all([ + this.loadBookData(), + this.loadFeaturedFromServer(), + this.loadSuperMembers(), + this.loadLatestChapters() + ]).finally(() => { + this.setData({ loading: false }) + }) }, async loadSuperMembers() { diff --git a/miniprogram/pages/link-preview/link-preview.js b/miniprogram/pages/link-preview/link-preview.js index 60245778..72cda7b5 100644 --- a/miniprogram/pages/link-preview/link-preview.js +++ b/miniprogram/pages/link-preview/link-preview.js @@ -6,6 +6,7 @@ Page({ title: '链接预览', statusBarHeight: 44, navBarHeight: 88, + loadError: false, }, onLoad(options) { @@ -19,6 +20,26 @@ Page({ }) }, + onWebViewError() { + this.setData({ loadError: true }) + wx.showModal({ + title: '无法在小程序内打开', + content: '该链接无法在小程序内预览,是否复制链接到浏览器打开?', + confirmText: '复制链接', + cancelText: '返回', + success: (res) => { + if (res.confirm) { + wx.setClipboardData({ + data: this.data.url, + success: () => wx.showToast({ title: '链接已复制,请在浏览器打开', icon: 'none', duration: 2000 }), + }) + } else { + this.goBack() + } + }, + }) + }, + goBack() { const pages = getCurrentPages() if (pages.length > 1) { diff --git a/miniprogram/pages/link-preview/link-preview.wxml b/miniprogram/pages/link-preview/link-preview.wxml index 36696e10..5cc8bedf 100644 --- a/miniprogram/pages/link-preview/link-preview.wxml +++ b/miniprogram/pages/link-preview/link-preview.wxml @@ -18,8 +18,14 @@ - - + + + + + 该链接无法在小程序内预览 + + 复制链接到浏览器打开 + 暂无链接地址 diff --git a/miniprogram/pages/link-preview/link-preview.wxss b/miniprogram/pages/link-preview/link-preview.wxss index e47a2e2e..d01cb4ee 100644 --- a/miniprogram/pages/link-preview/link-preview.wxss +++ b/miniprogram/pages/link-preview/link-preview.wxss @@ -81,3 +81,27 @@ web-view { font-size: 26rpx; } +.error-wrap { + display: flex; + flex-direction: column; + align-items: center; + padding: 80rpx 40rpx; +} + +.error-text { + font-size: 28rpx; + color: #999; + margin-bottom: 40rpx; +} + +.error-btn { + padding: 16rpx 40rpx; + border-radius: 999rpx; + background: #38bdac; +} + +.error-btn-text { + font-size: 26rpx; + color: #fff; +} + diff --git a/miniprogram/pages/read/read.js b/miniprogram/pages/read/read.js index 9107782a..b5d02709 100644 --- a/miniprogram/pages/read/read.js +++ b/miniprogram/pages/read/read.js @@ -70,6 +70,9 @@ Page({ showPosterModal: false, isPaying: false, isGeneratingPoster: false, + showShareTip: false, + _shareTipShown: false, + _lastScrollTop: 0, // 章节 mid(扫码/海报分享用,便于分享 path 带 mid) sectionMid: null @@ -97,8 +100,6 @@ Page({ if (app.globalData.initialSectionMid) delete app.globalData.initialSectionMid if (app.globalData.initialSectionId) delete app.globalData.initialSectionId - console.log("页面:",mid); - // mid 有值但无 id 时,从 bookData 或 API 解析 id if (mid && !id) { const bookData = app.globalData.bookData || [] @@ -138,6 +139,11 @@ Page({ app.handleReferralCode({ query: { ref } }) } + const giftCode = options.gift || '' + if (giftCode) { + this._pendingGiftCode = giftCode + } + try { const config = await accessManager.fetchLatestConfig() this.setData({ @@ -160,6 +166,13 @@ Page({ // 加载内容(复用已拉取的章节数据,避免二次请求) await this.loadContent(id, accessState, chapterRes) + // 自动领取礼物码(代付解锁) + if (this._pendingGiftCode && !canAccess && app.globalData.isLoggedIn) { + await this._redeemGiftCode(this._pendingGiftCode) + this._pendingGiftCode = null + return + } + // 【标准流程】4. 如果有权限,初始化阅读追踪 if (canAccess) { readingTracker.init(id) @@ -184,6 +197,11 @@ Page({ return } + const currentScrollTop = e.scrollTop || 0 + const lastScrollTop = this.data._lastScrollTop || 0 + const isScrollingDown = currentScrollTop < lastScrollTop + this.setData({ _lastScrollTop: currentScrollTop }) + // 获取滚动信息并更新追踪器 const query = wx.createSelectorQuery() query.select('.page').boundingClientRect() @@ -202,6 +220,12 @@ Page({ ? Math.min((scrollInfo.scrollTop / totalScrollable) * 100, 100) : 0 this.setData({ readingProgress: progress }) + + // 阅读超过20%且向上滑动时,弹出一次分享提示 + if (progress >= 20 && isScrollingDown && !this.data._shareTipShown) { + this.setData({ showShareTip: true, _shareTipShown: true }) + setTimeout(() => { this.setData({ showShareTip: false }) }, 4000) + } // 更新阅读追踪器(记录最大进度、判断是否读完) readingTracker.updateProgress(scrollInfo) @@ -492,33 +516,38 @@ Page({ } } - // CKB 类型:复用 @mention 加好友流程,弹出留资表单 + // CKB 类型:走「链接卡若」留资流程(与首页 onLinkKaruo 一致) if (tagType === 'ckb') { - // 触发通用加好友(无特定 personId,使用全局 CKB Key) - this.onMentionTap({ currentTarget: { dataset: { userId: '', nickname: label } } }) + this._doCkbLead(label) return } - // 小程序类型:用密钥查 linkedMiniprograms 得 appId,再唤醒(需在 app.json 的 navigateToMiniProgramAppIdList 中配置) + // 小程序类型:先查 linkedMiniprograms 得 appId,降级直接用 mpKey/appId 字段 if (tagType === 'miniprogram') { + let appId = (e.currentTarget.dataset.appId || '').trim() if (!mpKey && label) { const cached = (app.globalData.linkTagsConfig || []).find(t => t.label === label) - if (cached) mpKey = cached.mpKey || '' + if (cached) { + mpKey = cached.mpKey || '' + if (!appId && cached.appId) appId = cached.appId + } } const linked = (app.globalData.linkedMiniprograms || []).find(m => m.key === mpKey) - if (linked && linked.appId) { + const targetAppId = (linked && linked.appId) ? linked.appId : (appId || mpKey || '') + if (targetAppId) { wx.navigateToMiniProgram({ - appId: linked.appId, - path: pagePath || linked.path || '', + appId: targetAppId, + path: pagePath || (linked && linked.path) || '', envVersion: 'release', success: () => {}, fail: (err) => { - wx.showToast({ title: err.errMsg || '跳转失败', icon: 'none' }) + console.warn('[LinkTag] 小程序跳转失败:', err) + wx.showToast({ title: '跳转失败,请检查小程序配置', icon: 'none' }) }, }) return } - if (mpKey) wx.showToast({ title: '未找到关联小程序配置', icon: 'none' }) + wx.showToast({ title: '未配置关联小程序', icon: 'none' }) } // 小程序内部路径(pagePath 或 url 以 /pages/ 开头) @@ -638,6 +667,76 @@ Page({ } }, + async _doCkbLead(label) { + const app = getApp() + if (!app.globalData.isLoggedIn || !app.globalData.userInfo) { + wx.showModal({ + title: '提示', + content: '请先登录后再链接', + confirmText: '去登录', + cancelText: '取消', + success: (res) => { + if (res.confirm) wx.switchTab({ url: '/pages/my/my' }) + } + }) + return + } + const userId = app.globalData.userInfo.id + const leadLastTs = wx.getStorageSync('lead_last_submit_ts') || 0 + if (Date.now() - leadLastTs < 2 * 60 * 1000) { + wx.showToast({ title: '操作太频繁,请2分钟后再试', icon: 'none' }) + return + } + let phone = (app.globalData.userInfo.phone || '').trim() + let wechatId = (app.globalData.userInfo.wechatId || app.globalData.userInfo.wechat_id || '').trim() + if (!phone && !wechatId) { + try { + const profileRes = await app.request({ url: `/api/miniprogram/user/profile?userId=${userId}`, silent: true }) + if (profileRes?.success && profileRes.data) { + phone = (profileRes.data.phone || '').trim() + wechatId = (profileRes.data.wechatId || profileRes.data.wechat_id || '').trim() + } + } catch (e) {} + } + if (!phone && !wechatId) { + wx.showModal({ + title: '完善资料', + content: '请先填写手机号或微信号,以便对方联系您', + confirmText: '去填写', + cancelText: '取消', + success: (res) => { + if (res.confirm) wx.navigateTo({ url: '/pages/profile-edit/profile-edit' }) + } + }) + return + } + wx.showLoading({ title: '提交中...', mask: true }) + try { + const res = await app.request({ + url: '/api/miniprogram/ckb/index-lead', + method: 'POST', + data: { + userId, + phone: phone || undefined, + wechatId: wechatId || undefined, + name: (app.globalData.userInfo.nickname || '').trim() || undefined, + source: 'article_ckb_tag', + tagLabel: label || undefined + } + }) + wx.hideLoading() + if (res && res.success) { + wx.setStorageSync('lead_last_submit_ts', Date.now()) + wx.showToast({ title: res.message || '提交成功', icon: 'success' }) + } else { + wx.showToast({ title: (res && res.message) || '提交失败', icon: 'none' }) + } + } catch (e) { + wx.hideLoading() + wx.showToast({ title: (e && e.message) || '提交失败', icon: 'none' }) + } + }, + // 分享弹窗 showShare() { this.setData({ showShareModal: true }) @@ -687,14 +786,19 @@ Page({ const { section, sectionId, sectionMid } = this.data const ref = app.getMyReferralCode() const q = sectionMid ? `mid=${sectionMid}` : `id=${sectionId}` - const shareTitle = section?.title + const giftCode = this._giftCodeToShare || '' + this._giftCodeToShare = null + + let shareTitle = section?.title ? `📚 ${section.title.length > 20 ? section.title.slice(0, 20) + '...' : section.title}` : '📚 Soul创业派对 - 真实商业故事' - return { - title: shareTitle, - path: ref ? `/pages/read/read?${q}&ref=${ref}` : `/pages/read/read?${q}` - // 不设置 imageUrl,使用当前阅读页截图作为分享卡片中间图片 - } + if (giftCode) shareTitle = `🎁 好友已为你解锁:${section?.title || '精选文章'}` + + let path = `/pages/read/read?${q}` + if (ref) path += `&ref=${ref}` + if (giftCode) path += `&gift=${giftCode}` + + return { title: shareTitle, path } }, // 分享到朋友圈:带文章标题,过长时截断(朋友圈卡片标题显示有限) @@ -1357,7 +1461,84 @@ Page({ closePosterModal() { this.setData({ showPosterModal: false }) }, - + + closeShareTip() { + this.setData({ showShareTip: false }) + }, + + // 代付分享:用余额帮好友解锁当前章节 + async handleGiftPay() { + if (!app.globalData.isLoggedIn || !app.globalData.userInfo) { + wx.showModal({ title: '提示', content: '请先登录', confirmText: '去登录', success: (r) => { if (r.confirm) this.showLoginModal() } }) + return + } + const sectionId = this.data.sectionId + const userId = app.globalData.userInfo.id + const price = (this.data.section && this.data.section.price != null) ? this.data.section.price : (this.data.sectionPrice || 1) + + const balRes = await app.request({ url: `/api/miniprogram/balance?userId=${userId}`, silent: true }).catch(() => null) + const balance = (balRes && balRes.data) ? balRes.data.balance : 0 + + wx.showModal({ + title: '代付分享', + content: `为好友代付本章 ¥${price}\n当前余额: ¥${balance.toFixed(2)}\n${balance < price ? '余额不足,请先充值' : '确认后将从余额扣除'}`, + confirmText: balance >= price ? '确认代付' : '去充值', + success: async (res) => { + if (!res.confirm) return + if (balance < price) { + wx.navigateTo({ url: '/pages/wallet/wallet' }) + return + } + wx.showLoading({ title: '处理中...' }) + try { + const giftRes = await app.request({ + url: '/api/miniprogram/balance/gift', + method: 'POST', + data: { giverId: userId, sectionId } + }) + wx.hideLoading() + if (giftRes && giftRes.data && giftRes.data.giftCode) { + const giftCode = giftRes.data.giftCode + wx.showModal({ + title: '代付成功!', + content: `已为好友代付 ¥${price},分享链接后好友可免费阅读`, + confirmText: '分享给好友', + success: (r) => { + if (r.confirm) { + this._giftCodeToShare = giftCode + wx.shareAppMessage() + } + } + }) + } else { + wx.showToast({ title: (giftRes && giftRes.error) || '代付失败', icon: 'none' }) + } + } catch (e) { + wx.hideLoading() + wx.showToast({ title: '代付失败', icon: 'none' }) + } + } + }) + }, + + // 领取礼物码解锁 + async _redeemGiftCode(giftCode) { + if (!app.globalData.isLoggedIn || !app.globalData.userInfo) return + try { + const res = await app.request({ + url: '/api/miniprogram/balance/gift/redeem', + method: 'POST', + data: { giftCode, receiverId: app.globalData.userInfo.id } + }) + if (res && res.data) { + wx.showToast({ title: '好友已为你解锁!', icon: 'success' }) + this.onLoad({ id: this.data.sectionId }) + } + } catch (e) { + console.warn('[Gift] 领取失败:', e) + } + }, + // 保存海报到相册 savePoster() { wx.canvasToTempFilePath({ diff --git a/miniprogram/pages/read/read.wxml b/miniprogram/pages/read/read.wxml index 031b9019..82d7cf5c 100644 --- a/miniprogram/pages/read/read.wxml +++ b/miniprogram/pages/read/read.wxml @@ -25,7 +25,7 @@ - + {{section.id}} 免费 @@ -85,15 +85,22 @@ - + + 🎁 + 代付分享 + 🖼️ 生成海报 + @@ -242,6 +249,14 @@ + + + diff --git a/miniprogram/pages/read/read.wxss b/miniprogram/pages/read/read.wxss index 0fbad963..1d5f5142 100644 --- a/miniprogram/pages/read/read.wxss +++ b/miniprogram/pages/read/read.wxss @@ -1003,3 +1003,77 @@ display: block; } +/* ===== 分享提示文字(底部导航上方) ===== */ +.share-tip-inline { + text-align: center; + margin-top: 16rpx; +} +.share-tip-text { + font-size: 24rpx; + color: rgba(255, 255, 255, 0.5); +} + +/* ===== 分享浮层提示(阅读20%触发) ===== */ +.share-float-tip { + position: fixed; + top: 180rpx; + left: 40rpx; + right: 40rpx; + background: linear-gradient(135deg, #1a3a4a 0%, #0d2533 100%); + border: 1rpx solid rgba(0, 206, 209, 0.3); + border-radius: 24rpx; + padding: 28rpx 32rpx; + display: flex; + align-items: center; + gap: 16rpx; + z-index: 10000; + box-shadow: 0 12rpx 48rpx rgba(0, 0, 0, 0.6); + opacity: 0; + transform: translateY(-40rpx); + transition: opacity 0.35s ease, transform 0.35s ease; +} +.share-float-tip.show { + opacity: 1; + transform: translateY(0); +} +.share-float-icon { + font-size: 40rpx; + flex-shrink: 0; +} +.share-float-text { + font-size: 26rpx; + color: rgba(255, 255, 255, 0.85); + flex: 1; +} +.share-float-btn { + background: linear-gradient(135deg, #00CED1, #20B2AA) !important; + color: #fff !important; + font-size: 24rpx; + padding: 10rpx 28rpx; + border-radius: 32rpx; + border: none; + flex-shrink: 0; + line-height: 1.5; +} +.share-float-btn::after { + border: none; +} +.share-float-close { + font-size: 28rpx; + color: rgba(255, 255, 255, 0.4); + padding: 8rpx; + flex-shrink: 0; +} + +/* ===== 代付分享按钮 ===== */ +.btn-gift-inline { + display: flex; + flex-direction: column; + align-items: center; + gap: 4rpx; + padding: 12rpx 24rpx; + border-radius: 16rpx; + background: rgba(255, 165, 0, 0.1); + border: 1rpx solid rgba(255, 165, 0, 0.3); +} + diff --git a/miniprogram/project.private.config.json b/miniprogram/project.private.config.json index a4caf5f6..bbd45212 100644 --- a/miniprogram/project.private.config.json +++ b/miniprogram/project.private.config.json @@ -27,8 +27,8 @@ "name": "唤醒", "pathName": "pages/read/read", "query": "mid=209", - "scene": null, - "launchMode": "default" + "launchMode": "default", + "scene": null }, { "name": "pages/my/my", diff --git a/miniprogram/utils/contentParser.js b/miniprogram/utils/contentParser.js index 6087237d..39492a2e 100644 --- a/miniprogram/utils/contentParser.js +++ b/miniprogram/utils/contentParser.js @@ -144,9 +144,29 @@ function parseHtmlToSegments(html) { return { lines, segments } } -/** 纯文本按行解析(无 HTML 标签) */ +/** 清理 Markdown 格式标记(**加粗** *斜体* __加粗__ _斜体_ ~~删除线~~ `代码` 等)*/ +function stripMarkdownFormatting(text) { + if (!text) return text + let s = text + s = s.replace(/^#{1,6}\s+/gm, '') + s = s.replace(/\*\*(.+?)\*\*/g, '$1') + s = s.replace(/__(.+?)__/g, '$1') + s = s.replace(/(?\s+/gm, '') + s = s.replace(/^---$/gm, '') + s = s.replace(/^\* /gm, '• ') + s = s.replace(/^- /gm, '• ') + s = s.replace(/^\d+\.\s/gm, '') + return s +} + +/** 纯文本/Markdown 按行解析 */ function parsePlainTextToSegments(text) { - const lines = text.split('\n').map(l => l.trim()).filter(l => l.length > 0) + const cleaned = stripMarkdownFormatting(text) + const lines = cleaned.split('\n').map(l => l.trim()).filter(l => l.length > 0) const segments = lines.map(line => [{ type: 'text', text: line }]) return { lines, segments } } diff --git a/scripts/.env.feishu b/scripts/.env.feishu new file mode 100644 index 00000000..4765e50c --- /dev/null +++ b/scripts/.env.feishu @@ -0,0 +1,4 @@ +# 飞书应用凭证(卡若私域)- 勿提交到公开仓库 +FEISHU_APP_ID=cli_a48818290ef8100d +FEISHU_APP_SECRET=dhjU0qWd5AzicGWTf4cTqhCWJOrnuCk4 +FEISHU_WIKI_NODE_TOKEN=FNP6wdvNKij7yMkb3xCce0CYnpd diff --git a/scripts/fix_duplicate_title_upload.py b/scripts/fix_duplicate_title_upload.py new file mode 100644 index 00000000..137c3e33 --- /dev/null +++ b/scripts/fix_duplicate_title_upload.py @@ -0,0 +1,75 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +"""批量去掉重复标题并重新上传到小程序。content_upload 已内置 strip 首行 # 标题。""" +import subprocess +import sys +from pathlib import Path + +PROJECT_ROOT = Path(__file__).resolve().parent.parent +BASE_2026 = Path("/Users/karuo/Documents/个人/2、我写的书/《一场soul的创业实验》/2026每日派对干货") +BASE_9 = Path("/Users/karuo/Documents/个人/2、我写的书/《一场soul的创业实验》/第四篇|真实的赚钱/第9章|我在Soul上亲访的赚钱案例") + +# (id, title, md_file_path relative to BASE_2026 or "9" for BASE_9) +CHAPTERS_2026 = [ + ("10.01", "第102场|今年第一个红包你发给谁", BASE_2026 / "第102场|今年第一个红包你发给谁.md"), + ("10.02", "第103场|号商、某客与炸房", BASE_2026 / "第103场|号商、某客与炸房.md"), + ("10.03", "第105场|创业社群、直播带货与程序员", BASE_2026 / "第105场|创业社群、直播带货与程序员.md"), + ("10.04", "第104场|婚恋、AI客服与一个微信", BASE_2026 / "第104场|婚恋、AI客服与一个微信.md"), + ("10.05", "第107场|性格、陪伴经济与本地AI", BASE_2026 / "第107场|性格、陪伴经济与本地AI.md"), + ("10.06", "第108场|Soul场观400等于抖音1万", BASE_2026 / "第108场|Soul场观400等于抖音1万.md"), + ("10.07", "第111场|平台规则变了怎么办", BASE_2026 / "第111场|平台规则变了怎么办.md"), + ("10.08", "第110场|Soul变现逻辑全程公开", BASE_2026 / "第110场|Soul变现逻辑全程公开.md"), + ("10.09", "第112场|一个人起头,维权挣了大半套房", BASE_2026 / "第112场|一个人起头,维权挣了大半套房.md"), + ("10.10", "第113场|不会选择怎么办?", BASE_2026 / "第113场|不会选择怎么办?.md"), + ("10.11", "第114场|人跟人差别,以前没 AI 差 100 倍,有 AI 差 1 万倍。", BASE_2026 / "第114场-人跟人差别,以前没 AI 差 100 倍,有 AI 差 1 万倍。.md"), + ("10.12", "第115场|一天改变,可控的事先做", BASE_2026 / "第115场|一天改变,可控的事先做.md"), + ("10.13", "第116场|钱是大风刮来的,怎么抓住?", BASE_2026 / "第116场|钱是大风刮来的,怎么抓住?.md"), + ("10.14", "第117场|流水百万挣八千,你还干不干?", BASE_2026 / "第117场|流水百万挣八千,你还干不干?.md"), + ("10.15", "第118场|运气是选出来的,不是等出来的", BASE_2026 / "第118场|运气是选出来的,不是等出来的.md"), + ("10.16", "第119场|开派对的初心是早上不影响老婆睡觉", BASE_2026 / "第119场|开派对的初心是早上不影响老婆睡觉.md"), + ("10.17", "第120场|发视频就有钱,这才是最低门槛的AI副业", BASE_2026 / "第120场|发视频就有钱,这才是最低门槛的AI副业.md"), +] + +CHAPTERS_9 = [ + ("9.15", "派对副业|做切片分发和副业分发的具体步骤与收益", BASE_9 / "9.15 派对副业.md"), + ("9.16", "如何开Soul派对|房主避坑、流量、变现与封号", BASE_9 / "9.16 如何开Soul派对|房主避坑、流量、变现与封号.md"), +] + + +def run_upload(section_id: str, title: str, content_file: Path, part: str, chapter: str) -> bool: + if not content_file.exists(): + print(f" 跳过 {section_id}: 文件不存在 {content_file}") + return False + cmd = [ + sys.executable, + str(PROJECT_ROOT / "content_upload.py"), + "--id", section_id, + "--title", title, + "--content-file", str(content_file), + "--part", part, + "--chapter", chapter, + "--price", "1.0", + ] + r = subprocess.run(cmd, cwd=str(PROJECT_ROOT)) + return r.returncode == 0 + + +def main(): + ok, fail = 0, 0 + for sid, title, fpath in CHAPTERS_2026: + print(f"上传 {sid} {title[:30]}...") + if run_upload(sid, title, fpath, "part-2026-daily", "chapter-2026-daily"): + ok += 1 + else: + fail += 1 + for sid, title, fpath in CHAPTERS_9: + print(f"上传 {sid} {title[:30]}...") + if run_upload(sid, title, fpath, "part-4", "chapter-9"): + ok += 1 + else: + fail += 1 + print(f"\n完成: 成功 {ok}, 失败 {fail}") + + +if __name__ == "__main__": + main() diff --git a/scripts/migrate_2026_sections.py b/scripts/migrate_2026_sections.py new file mode 100644 index 00000000..3a97b69b --- /dev/null +++ b/scripts/migrate_2026_sections.py @@ -0,0 +1,151 @@ +#!/usr/bin/env python3 +""" +将第102场及以后的派对场次迁移到「2026每日派对干货」目录 + +用法: + python3 scripts/migrate_2026_sections.py # 仅预览,不执行 + python3 scripts/migrate_2026_sections.py --execute # 执行迁移 + +迁移规则: +- 从章节中筛选 section_title 包含「第102场」「第103场」... 的条目 +- 按场次号排序,依次赋 id 10.01, 10.02, 10.03, ... +- 更新 part_id=part-2026-daily, part_title=2026每日派对干货 +- 更新 chapter_id=chapter-2026-daily, chapter_title=2026每日派对干货 + +依赖: pip install pymysql +""" + +import argparse +import re +import sys +from pathlib import Path + +# 项目根目录 +ROOT = Path(__file__).resolve().parent.parent +sys.path.insert(0, str(ROOT)) + +try: + import pymysql +except ImportError: + print("需要安装 pymysql: pip3 install pymysql") + sys.exit(1) + +DB_CONFIG = { + "host": "56b4c23f6853c.gz.cdb.myqcloud.com", + "port": 14413, + "user": "cdb_outerroot", + "password": "Zhiqun1984", + "database": "soul_miniprogram", + "charset": "utf8mb4", +} + +PART_2026 = "part-2026-daily" +CHAPTER_2026 = "chapter-2026-daily" +TITLE_2026 = "2026每日派对干货" + + +def extract_session_num(section_title: str) -> int | None: + """从 section_title 解析场次号,如 第102场 -> 102""" + m = re.search(r"第(\d+)场", section_title) + return int(m.group(1)) if m else None + + +def get_connection(): + return pymysql.connect(**DB_CONFIG) + + +def get_max_10_section(cur) -> int: + """获取当前 10.xx 最大序号""" + cur.execute( + "SELECT id FROM chapters WHERE id REGEXP '^10\\.[0-9]+$' ORDER BY CAST(SUBSTRING_INDEX(id, '.', -1) AS UNSIGNED) DESC LIMIT 1" + ) + row = cur.fetchone() + if row: + return int(row[0].split(".")[-1]) + return 0 + + +def find_sections_to_migrate(cur) -> list[tuple]: + """查找需要迁移的章节:第102场及以后,且不在 part-2026-daily 的""" + cur.execute(""" + SELECT id, section_title, part_id, chapter_id, sort_order + FROM chapters + WHERE section_title REGEXP '第[0-9]+场' + ORDER BY sort_order, id + """) + rows = cur.fetchall() + to_migrate = [] + for row in rows: + sid, title, part_id, ch_id, order = row + num = extract_session_num(title) + if num is not None and num >= 102 and part_id != PART_2026: + to_migrate.append((sid, title, part_id, ch_id, order, num)) + to_migrate.sort(key=lambda x: (x[5], x[4])) # 按场次号、sort_order + return to_migrate + + +def run(dry_run: bool): + conn = get_connection() + cur = conn.cursor() + rows = find_sections_to_migrate(cur) + max_10 = get_max_10_section(cur) + conn.close() + + if not rows: + print("未找到需要迁移的章节(第102场及以后、且不在 2026每日派对干货 中)") + return + + print(f"当前 10.xx 最大序号: {max_10}") + print(f"找到 {len(rows)} 节待迁移到「2026每日派对干货」:\n") + plan = [] + for i, (old_id, title, part_id, ch_id, order, num) in enumerate(rows, 1): + new_id = f"10.{max_10 + i:02d}" + plan.append((old_id, new_id, title, part_id)) + print(f" {old_id} -> {new_id} {title}") + + if dry_run: + print("\n[预览模式] 未执行写入,使用 --execute 执行迁移") + return + + print("\n执行迁移...") + conn = get_connection() + cur = conn.cursor() + + try: + # 先全部改为临时 id(避免与已有 10.xx 冲突) + for i, (old_id, new_id, title, part_id) in enumerate(plan, 1): + tmp_id = f"tmp-migrate-{old_id.replace('.', '-')}" + cur.execute( + "UPDATE chapters SET id = %s WHERE id = %s", + (tmp_id, old_id), + ) + conn.commit() + + # 再改为最终 id 并更新 part/chapter + for i, (old_id, new_id, title, part_id) in enumerate(plan, 1): + tmp_id = f"tmp-migrate-{old_id.replace('.', '-')}" + cur.execute(""" + UPDATE chapters SET + id = %s, part_id = %s, part_title = %s, + chapter_id = %s, chapter_title = %s + WHERE id = %s + """, (new_id, PART_2026, TITLE_2026, CHAPTER_2026, TITLE_2026, tmp_id)) + conn.commit() + print(f"已迁移 {len(plan)} 节到 part-2026-daily,id 为 10.01 ~ 10.{len(plan):02d}") + except Exception as e: + conn.rollback() + print(f"迁移失败: {e}") + raise + finally: + conn.close() + + +def main(): + parser = argparse.ArgumentParser(description="将第102场及以后的场次迁移到 2026每日派对干货") + parser.add_argument("--execute", action="store_true", help="执行迁移(默认仅预览)") + args = parser.parse_args() + run(dry_run=not args.execute) + + +if __name__ == "__main__": + main() diff --git a/scripts/post_to_feishu.py b/scripts/post_to_feishu.py index fff5cb01..af671d72 100644 --- a/scripts/post_to_feishu.py +++ b/scripts/post_to_feishu.py @@ -13,7 +13,7 @@ from urllib.request import Request, urlopen CONFIG_PATH = Path(__file__).resolve().parent / "feishu_publish_config.json" WEBHOOK_ENV = "FEISHU_KARUO_LOG_WEBHOOK" -DEFAULT_WEBHOOK = "https://open.feishu.cn/open-apis/bot/v2/hook/8b7f996e-2892-4075-989f-aa5593ea4fbc" +DEFAULT_WEBHOOK = "https://open.feishu.cn/open-apis/bot/v2/hook/34b762fc-5b9b-4abb-a05a-96c8fb9599f1" WIKI_URL = "https://cunkebao.feishu.cn/wiki/FNP6wdvNKij7yMkb3xCce0CYnpd" MINIPROGRAM_BASE = "https://soul.quwanzhi.com/read" MATERIAL_HINT = "材料找卡若AI拿" diff --git a/scripts/send_chapter_poster_to_feishu.py b/scripts/send_chapter_poster_to_feishu.py index 632cb245..5b9cc1dd 100644 --- a/scripts/send_chapter_poster_to_feishu.py +++ b/scripts/send_chapter_poster_to_feishu.py @@ -31,7 +31,7 @@ except ImportError: # 与 post_to_feishu 保持一致 SCRIPT_DIR = Path(__file__).resolve().parent # 默认发到 Soul 彩民团队飞书群 -WEBHOOK = "https://open.feishu.cn/open-apis/bot/v2/hook/14a7e0d3-864d-4709-ad40-0def6edba566" +WEBHOOK = "https://open.feishu.cn/open-apis/bot/v2/hook/34b762fc-5b9b-4abb-a05a-96c8fb9599f1" BACKEND_QRCODE_URL = "https://soul.quwanzhi.com/api/miniprogram/qrcode" MINIPROGRAM_READ_BASE = "https://soul.quwanzhi.com/read" diff --git a/soul-admin/dist/assets/index-Bd1cCYoa.css b/soul-admin/dist/assets/index-Bd1cCYoa.css deleted file mode 100644 index 1a125edc..00000000 --- a/soul-admin/dist/assets/index-Bd1cCYoa.css +++ /dev/null @@ -1 +0,0 @@ -.rich-editor-wrapper{border:1px solid #374151;border-radius:.5rem;background:#0a1628;overflow:hidden}.rich-editor-toolbar{display:flex;align-items:center;gap:2px;padding:6px 8px;border-bottom:1px solid #374151;background:#0f1d32;flex-wrap:wrap}.toolbar-group{display:flex;align-items:center;gap:1px}.toolbar-divider{width:1px;height:20px;background:#374151;margin:0 4px}.rich-editor-toolbar button{display:flex;align-items:center;justify-content:center;width:28px;height:28px;border-radius:4px;border:none;background:transparent;color:#9ca3af;cursor:pointer;transition:all .15s}.rich-editor-toolbar button:hover{background:#1f2937;color:#d1d5db}.rich-editor-toolbar button.is-active{background:#38bdac33;color:#38bdac}.rich-editor-toolbar button:disabled{opacity:.3;cursor:not-allowed}.link-tag-select{background:#0a1628;border:1px solid #374151;color:#d1d5db;font-size:12px;padding:2px 6px;border-radius:4px;cursor:pointer;max-width:160px}.link-input-bar{display:flex;align-items:center;gap:4px;padding:4px 8px;border-bottom:1px solid #374151;background:#0f1d32}.link-input{flex:1;background:#0a1628;border:1px solid #374151;color:#fff;padding:4px 8px;border-radius:4px;font-size:13px}.link-confirm,.link-remove{padding:4px 10px;border-radius:4px;border:none;font-size:12px;cursor:pointer}.link-confirm{background:#38bdac;color:#fff}.link-remove{background:#374151;color:#9ca3af}.rich-editor-content{min-height:300px;max-height:500px;overflow-y:auto;padding:12px 16px;color:#e5e7eb;font-size:14px;line-height:1.7}.rich-editor-content:focus{outline:none}.rich-editor-content h1{font-size:1.5em;font-weight:700;margin:.8em 0 .4em;color:#fff}.rich-editor-content h2{font-size:1.3em;font-weight:600;margin:.7em 0 .3em;color:#fff}.rich-editor-content h3{font-size:1.15em;font-weight:600;margin:.6em 0 .3em;color:#fff}.rich-editor-content p{margin:.4em 0}.rich-editor-content strong{color:#fff}.rich-editor-content code{background:#1f2937;padding:2px 6px;border-radius:3px;font-size:.9em;color:#38bdac}.rich-editor-content pre{background:#1f2937;padding:12px;border-radius:6px;overflow-x:auto;margin:.6em 0}.rich-editor-content blockquote{border-left:3px solid #38bdac;padding-left:12px;margin:.6em 0;color:#9ca3af}.rich-editor-content ul,.rich-editor-content ol{padding-left:1.5em;margin:.4em 0}.rich-editor-content li{margin:.2em 0}.rich-editor-content hr{border:none;border-top:1px solid #374151;margin:1em 0}.rich-editor-content img{max-width:100%;border-radius:6px;margin:.5em 0}.rich-editor-content a,.rich-link{color:#38bdac;text-decoration:underline;cursor:pointer}.rich-editor-content table{border-collapse:collapse;width:100%;margin:.5em 0}.rich-editor-content th,.rich-editor-content td{border:1px solid #374151;padding:6px 10px;text-align:left}.rich-editor-content th{background:#1f2937;font-weight:600}.rich-editor-content .ProseMirror-placeholder:before{content:attr(data-placeholder);color:#6b7280;float:left;height:0;pointer-events:none}.mention-tag{background:#38bdac26;color:#38bdac;border-radius:4px;padding:1px 4px;font-weight:500}.link-tag-node{background:#ffd7001f;color:gold;border-radius:4px;padding:1px 4px;font-weight:500;cursor:default;-webkit-user-select:all;user-select:all}.mention-popup{position:fixed;z-index:9999;background:#1a2638;border:1px solid #374151;border-radius:8px;padding:4px;min-width:180px;max-height:240px;overflow-y:auto;box-shadow:0 4px 20px #0006}.mention-item{display:flex;align-items:center;justify-content:space-between;padding:6px 10px;border-radius:4px;cursor:pointer;color:#d1d5db;font-size:13px}.mention-item:hover,.mention-item.is-selected{background:#38bdac26;color:#38bdac}.mention-name{font-weight:500}.mention-id{font-size:11px;color:#6b7280}.bubble-menu{display:flex;gap:2px;background:#1a2638;border:1px solid #374151;border-radius:6px;padding:4px;box-shadow:0 4px 12px #0000004d}.bubble-menu button{display:flex;align-items:center;justify-content:center;width:26px;height:26px;border-radius:4px;border:none;background:transparent;color:#9ca3af;cursor:pointer}.bubble-menu button:hover{background:#1f2937;color:#d1d5db}.bubble-menu button.is-active{color:#38bdac}/*! tailwindcss v4.1.18 | MIT License | https://tailwindcss.com */@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-translate-x:0;--tw-translate-y:0;--tw-translate-z:0;--tw-scale-x:1;--tw-scale-y:1;--tw-scale-z:1;--tw-rotate-x:initial;--tw-rotate-y:initial;--tw-rotate-z:initial;--tw-skew-x:initial;--tw-skew-y:initial;--tw-pan-x:initial;--tw-pan-y:initial;--tw-pinch-zoom:initial;--tw-space-y-reverse:0;--tw-space-x-reverse:0;--tw-divide-x-reverse:0;--tw-border-style:solid;--tw-divide-y-reverse:0;--tw-gradient-position:initial;--tw-gradient-from:#0000;--tw-gradient-via:#0000;--tw-gradient-to:#0000;--tw-gradient-stops:initial;--tw-gradient-via-stops:initial;--tw-gradient-from-position:0%;--tw-gradient-via-position:50%;--tw-gradient-to-position:100%;--tw-leading:initial;--tw-font-weight:initial;--tw-tracking:initial;--tw-ordinal:initial;--tw-slashed-zero:initial;--tw-numeric-figure:initial;--tw-numeric-spacing:initial;--tw-numeric-fraction:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-outline-style:solid;--tw-blur:initial;--tw-brightness:initial;--tw-contrast:initial;--tw-grayscale:initial;--tw-hue-rotate:initial;--tw-invert:initial;--tw-opacity:initial;--tw-saturate:initial;--tw-sepia:initial;--tw-drop-shadow:initial;--tw-drop-shadow-color:initial;--tw-drop-shadow-alpha:100%;--tw-drop-shadow-size:initial;--tw-backdrop-blur:initial;--tw-backdrop-brightness:initial;--tw-backdrop-contrast:initial;--tw-backdrop-grayscale:initial;--tw-backdrop-hue-rotate:initial;--tw-backdrop-invert:initial;--tw-backdrop-opacity:initial;--tw-backdrop-saturate:initial;--tw-backdrop-sepia:initial;--tw-duration:initial}}}@layer theme{:root,:host{--font-sans:-apple-system,BlinkMacSystemFont,"Segoe UI","PingFang SC","Microsoft YaHei",sans-serif;--font-mono:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;--color-red-300:oklch(80.8% .114 19.571);--color-red-400:oklch(70.4% .191 22.216);--color-red-500:oklch(63.7% .237 25.331);--color-orange-300:oklch(83.7% .128 66.29);--color-orange-400:oklch(75% .183 55.934);--color-orange-500:oklch(70.5% .213 47.604);--color-orange-600:oklch(64.6% .222 41.116);--color-amber-200:oklch(92.4% .12 95.746);--color-amber-300:oklch(87.9% .169 91.605);--color-amber-400:oklch(82.8% .189 84.429);--color-amber-500:oklch(76.9% .188 70.08);--color-amber-600:oklch(66.6% .179 58.318);--color-yellow-400:oklch(85.2% .199 91.936);--color-yellow-500:oklch(79.5% .184 86.047);--color-green-300:oklch(87.1% .15 154.449);--color-green-400:oklch(79.2% .209 151.711);--color-green-500:oklch(72.3% .219 149.579);--color-green-600:oklch(62.7% .194 149.214);--color-green-700:oklch(52.7% .154 150.069);--color-emerald-400:oklch(76.5% .177 163.223);--color-emerald-500:oklch(69.6% .17 162.48);--color-cyan-400:oklch(78.9% .154 211.53);--color-cyan-500:oklch(71.5% .143 215.221);--color-sky-200:oklch(90.1% .058 230.902);--color-sky-300:oklch(82.8% .111 230.318);--color-blue-300:oklch(80.9% .105 251.813);--color-blue-400:oklch(70.7% .165 254.624);--color-blue-500:oklch(62.3% .214 259.815);--color-purple-400:oklch(71.4% .203 305.504);--color-purple-500:oklch(62.7% .265 303.9);--color-gray-200:oklch(92.8% .006 264.531);--color-gray-300:oklch(87.2% .01 258.338);--color-gray-400:oklch(70.7% .022 261.325);--color-gray-500:oklch(55.1% .027 264.364);--color-gray-600:oklch(44.6% .03 256.802);--color-gray-700:oklch(37.3% .034 259.733);--color-gray-800:oklch(27.8% .033 256.848);--color-black:#000;--color-white:#fff;--spacing:.25rem;--container-xs:20rem;--container-sm:24rem;--container-md:28rem;--container-lg:32rem;--container-2xl:42rem;--container-3xl:48rem;--container-4xl:56rem;--text-xs:.75rem;--text-xs--line-height:calc(1/.75);--text-sm:.875rem;--text-sm--line-height:calc(1.25/.875);--text-base:1rem;--text-base--line-height: 1.5 ;--text-lg:1.125rem;--text-lg--line-height:calc(1.75/1.125);--text-xl:1.25rem;--text-xl--line-height:calc(1.75/1.25);--text-2xl:1.5rem;--text-2xl--line-height:calc(2/1.5);--text-3xl:1.875rem;--text-3xl--line-height: 1.2 ;--text-4xl:2.25rem;--text-4xl--line-height:calc(2.5/2.25);--font-weight-normal:400;--font-weight-medium:500;--font-weight-semibold:600;--font-weight-bold:700;--tracking-tight:-.025em;--tracking-wider:.05em;--leading-tight:1.25;--leading-relaxed:1.625;--radius-sm:.25rem;--radius-md:.375rem;--radius-lg:.5rem;--radius-xl:.75rem;--radius-2xl:1rem;--animate-spin:spin 1s linear infinite;--blur-xl:24px;--blur-3xl:64px;--default-transition-duration:.15s;--default-transition-timing-function:cubic-bezier(.4,0,.2,1);--default-font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","PingFang SC","Microsoft YaHei",sans-serif;--default-mono-font-family:var(--font-mono)}}@layer base{*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;-moz-tab-size:4;tab-size:4;line-height:1.5;font-family:var(--default-font-family,ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-variation-settings:var(--default-mono-font-variation-settings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring{outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab,red,red)){::placeholder{color:color-mix(in oklab,currentcolor 50%,transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit{padding-block:0}::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-month-field{padding-block:0}::-webkit-datetime-edit-day-field{padding-block:0}::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field{padding-block:0}::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-datetime-edit-meridiem-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){-webkit-appearance:button;-moz-appearance:button;appearance:button}::file-selector-button{-webkit-appearance:button;-moz-appearance:button;appearance:button}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}}@layer components;@layer utilities{.pointer-events-none{pointer-events:none}.collapse{visibility:collapse}.invisible{visibility:hidden}.visible{visibility:visible}.sr-only{clip-path:inset(50%);white-space:nowrap;border-width:0;width:1px;height:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}.not-sr-only{clip-path:none;white-space:normal;width:auto;height:auto;margin:0;padding:0;position:static;overflow:visible}.absolute{position:absolute}.fixed{position:fixed}.relative{position:relative}.static{position:static}.sticky{position:sticky}.inset-0{inset:calc(var(--spacing)*0)}.-top-2\.5{top:calc(var(--spacing)*-2.5)}.top-0{top:calc(var(--spacing)*0)}.top-1\/2{top:50%}.top-1\/4{top:25%}.top-4{top:calc(var(--spacing)*4)}.top-16{top:calc(var(--spacing)*16)}.top-\[50\%\]{top:50%}.top-full{top:100%}.right-0{right:calc(var(--spacing)*0)}.right-1{right:calc(var(--spacing)*1)}.right-1\/4{right:25%}.right-4{right:calc(var(--spacing)*4)}.bottom-1\/4{bottom:25%}.-left-2\.5{left:calc(var(--spacing)*-2.5)}.left-0{left:calc(var(--spacing)*0)}.left-1\/4{left:25%}.left-2{left:calc(var(--spacing)*2)}.left-3{left:calc(var(--spacing)*3)}.left-\[50\%\]{left:50%}.isolate{isolation:isolate}.isolation-auto{isolation:auto}.z-10{z-index:10}.z-50{z-index:50}.col-span-2{grid-column:span 2/span 2}.container{width:100%}@media(min-width:40rem){.container{max-width:40rem}}@media(min-width:48rem){.container{max-width:48rem}}@media(min-width:64rem){.container{max-width:64rem}}@media(min-width:80rem){.container{max-width:80rem}}@media(min-width:96rem){.container{max-width:96rem}}.-mx-2{margin-inline:calc(var(--spacing)*-2)}.-mx-8{margin-inline:calc(var(--spacing)*-8)}.mx-20{margin-inline:calc(var(--spacing)*20)}.mx-auto{margin-inline:auto}.-mt-6{margin-top:calc(var(--spacing)*-6)}.mt-0{margin-top:calc(var(--spacing)*0)}.mt-0\.5{margin-top:calc(var(--spacing)*.5)}.mt-1{margin-top:calc(var(--spacing)*1)}.mt-1\.5{margin-top:calc(var(--spacing)*1.5)}.mt-2{margin-top:calc(var(--spacing)*2)}.mt-3{margin-top:calc(var(--spacing)*3)}.mt-4{margin-top:calc(var(--spacing)*4)}.mt-6{margin-top:calc(var(--spacing)*6)}.mr-1{margin-right:calc(var(--spacing)*1)}.mr-2{margin-right:calc(var(--spacing)*2)}.mr-3{margin-right:calc(var(--spacing)*3)}.mr-auto{margin-right:auto}.mb-1{margin-bottom:calc(var(--spacing)*1)}.mb-1\.5{margin-bottom:calc(var(--spacing)*1.5)}.mb-2{margin-bottom:calc(var(--spacing)*2)}.mb-3{margin-bottom:calc(var(--spacing)*3)}.mb-4{margin-bottom:calc(var(--spacing)*4)}.mb-5{margin-bottom:calc(var(--spacing)*5)}.mb-6{margin-bottom:calc(var(--spacing)*6)}.mb-8{margin-bottom:calc(var(--spacing)*8)}.ml-1{margin-left:calc(var(--spacing)*1)}.ml-2{margin-left:calc(var(--spacing)*2)}.ml-4{margin-left:calc(var(--spacing)*4)}.ml-6{margin-left:calc(var(--spacing)*6)}.ml-auto{margin-left:auto}.line-clamp-2{-webkit-line-clamp:2;-webkit-box-orient:vertical;display:-webkit-box;overflow:hidden}.line-clamp-3{-webkit-line-clamp:3;-webkit-box-orient:vertical;display:-webkit-box;overflow:hidden}.block{display:block}.contents{display:contents}.flex{display:flex}.flow-root{display:flow-root}.grid{display:grid}.hidden{display:none}.inline{display:inline}.inline\!{display:inline!important}.inline-block{display:inline-block}.inline-flex{display:inline-flex}.inline-grid{display:inline-grid}.inline-table{display:inline-table}.list-item{display:list-item}.table{display:table}.table\!{display:table!important}.table-caption{display:table-caption}.table-cell{display:table-cell}.table-column{display:table-column}.table-column-group{display:table-column-group}.table-footer-group{display:table-footer-group}.table-header-group{display:table-header-group}.table-row{display:table-row}.table-row-group{display:table-row-group}.size-4{width:calc(var(--spacing)*4);height:calc(var(--spacing)*4)}.size-8{width:calc(var(--spacing)*8);height:calc(var(--spacing)*8)}.size-9{width:calc(var(--spacing)*9);height:calc(var(--spacing)*9)}.size-10{width:calc(var(--spacing)*10);height:calc(var(--spacing)*10)}.h-0\.5{height:calc(var(--spacing)*.5)}.h-1\.5{height:calc(var(--spacing)*1.5)}.h-2{height:calc(var(--spacing)*2)}.h-3{height:calc(var(--spacing)*3)}.h-3\.5{height:calc(var(--spacing)*3.5)}.h-4{height:calc(var(--spacing)*4)}.h-5{height:calc(var(--spacing)*5)}.h-6{height:calc(var(--spacing)*6)}.h-7{height:calc(var(--spacing)*7)}.h-8{height:calc(var(--spacing)*8)}.h-9{height:calc(var(--spacing)*9)}.h-10{height:calc(var(--spacing)*10)}.h-12{height:calc(var(--spacing)*12)}.h-16{height:calc(var(--spacing)*16)}.h-20{height:calc(var(--spacing)*20)}.h-24{height:calc(var(--spacing)*24)}.h-96{height:calc(var(--spacing)*96)}.h-\[75vh\]{height:75vh}.h-auto{height:auto}.h-full{height:100%}.max-h-48{max-height:calc(var(--spacing)*48)}.max-h-96{max-height:calc(var(--spacing)*96)}.max-h-\[80vh\]{max-height:80vh}.max-h-\[85vh\]{max-height:85vh}.max-h-\[90vh\]{max-height:90vh}.max-h-\[250px\]{max-height:250px}.max-h-\[300px\]{max-height:300px}.max-h-\[400px\]{max-height:400px}.min-h-0{min-height:calc(var(--spacing)*0)}.min-h-\[2rem\]{min-height:2rem}.min-h-\[32px\]{min-height:32px}.min-h-\[40px\]{min-height:40px}.min-h-\[60vh\]{min-height:60vh}.min-h-\[72px\]{min-height:72px}.min-h-\[80px\]{min-height:80px}.min-h-\[100px\]{min-height:100px}.min-h-\[120px\]{min-height:120px}.min-h-\[260px\]{min-height:260px}.min-h-\[400px\]{min-height:400px}.min-h-full{min-height:100%}.min-h-screen{min-height:100vh}.w-0\.5{width:calc(var(--spacing)*.5)}.w-2{width:calc(var(--spacing)*2)}.w-3{width:calc(var(--spacing)*3)}.w-3\.5{width:calc(var(--spacing)*3.5)}.w-4{width:calc(var(--spacing)*4)}.w-5{width:calc(var(--spacing)*5)}.w-6{width:calc(var(--spacing)*6)}.w-7{width:calc(var(--spacing)*7)}.w-8{width:calc(var(--spacing)*8)}.w-9{width:calc(var(--spacing)*9)}.w-10{width:calc(var(--spacing)*10)}.w-12{width:calc(var(--spacing)*12)}.w-16{width:calc(var(--spacing)*16)}.w-20{width:calc(var(--spacing)*20)}.w-24{width:calc(var(--spacing)*24)}.w-28{width:calc(var(--spacing)*28)}.w-32{width:calc(var(--spacing)*32)}.w-36{width:calc(var(--spacing)*36)}.w-40{width:calc(var(--spacing)*40)}.w-44{width:calc(var(--spacing)*44)}.w-48{width:calc(var(--spacing)*48)}.w-52{width:calc(var(--spacing)*52)}.w-56{width:calc(var(--spacing)*56)}.w-64{width:calc(var(--spacing)*64)}.w-96{width:calc(var(--spacing)*96)}.w-\[280px\]{width:280px}.w-fit{width:fit-content}.w-full{width:100%}.max-w-2xl{max-width:var(--container-2xl)}.max-w-3xl{max-width:var(--container-3xl)}.max-w-4xl{max-width:var(--container-4xl)}.max-w-\[100px\]{max-width:100px}.max-w-\[120px\]{max-width:120px}.max-w-\[140px\]{max-width:140px}.max-w-\[180px\]{max-width:180px}.max-w-\[200px\]{max-width:200px}.max-w-\[250px\]{max-width:250px}.max-w-\[calc\(100\%-2rem\)\]{max-width:calc(100% - 2rem)}.max-w-lg{max-width:var(--container-lg)}.max-w-md{max-width:var(--container-md)}.max-w-sm{max-width:var(--container-sm)}.max-w-xs{max-width:var(--container-xs)}.min-w-0{min-width:calc(var(--spacing)*0)}.min-w-48{min-width:calc(var(--spacing)*48)}.min-w-\[8rem\]{min-width:8rem}.min-w-\[60px\]{min-width:60px}.min-w-\[120px\]{min-width:120px}.min-w-\[1024px\]{min-width:1024px}.flex-1{flex:1}.flex-shrink-0{flex-shrink:0}.shrink{flex-shrink:1}.shrink-0{flex-shrink:0}.grow{flex-grow:1}.caption-bottom{caption-side:bottom}.border-collapse{border-collapse:collapse}.-translate-x-1\/2{--tw-translate-x: -50% ;translate:var(--tw-translate-x)var(--tw-translate-y)}.translate-x-1\/2{--tw-translate-x: 50% ;translate:var(--tw-translate-x)var(--tw-translate-y)}.-translate-y-1\/2{--tw-translate-y: -50% ;translate:var(--tw-translate-x)var(--tw-translate-y)}.translate-none{translate:none}.scale-3d{scale:var(--tw-scale-x)var(--tw-scale-y)var(--tw-scale-z)}.scale-\[0\.98\]{scale:.98}.transform{transform:var(--tw-rotate-x,)var(--tw-rotate-y,)var(--tw-rotate-z,)var(--tw-skew-x,)var(--tw-skew-y,)}.animate-spin{animation:var(--animate-spin)}.cursor-default{cursor:default}.cursor-grab{cursor:grab}.cursor-pointer{cursor:pointer}.touch-pinch-zoom{--tw-pinch-zoom:pinch-zoom;touch-action:var(--tw-pan-x,)var(--tw-pan-y,)var(--tw-pinch-zoom,)}.touch-none{touch-action:none}.resize{resize:both}.resize-none{resize:none}.resize-y{resize:vertical}.list-inside{list-style-position:inside}.list-decimal{list-style-type:decimal}.list-disc{list-style-type:disc}.grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.grid-cols-\[40px_40px_1fr_80px_80px_80px_60px\]{grid-template-columns:40px 40px 1fr 80px 80px 80px 60px}.flex-col{flex-direction:column}.flex-col-reverse{flex-direction:column-reverse}.flex-row{flex-direction:row}.flex-wrap{flex-wrap:wrap}.items-center{align-items:center}.items-end{align-items:flex-end}.items-start{align-items:flex-start}.justify-between{justify-content:space-between}.justify-center{justify-content:center}.justify-end{justify-content:flex-end}.gap-0{gap:calc(var(--spacing)*0)}.gap-0\.5{gap:calc(var(--spacing)*.5)}.gap-1{gap:calc(var(--spacing)*1)}.gap-1\.5{gap:calc(var(--spacing)*1.5)}.gap-2{gap:calc(var(--spacing)*2)}.gap-3{gap:calc(var(--spacing)*3)}.gap-4{gap:calc(var(--spacing)*4)}.gap-5{gap:calc(var(--spacing)*5)}.gap-6{gap:calc(var(--spacing)*6)}.gap-8{gap:calc(var(--spacing)*8)}:where(.space-y-0>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*0)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*0)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-1>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*1)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*1)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-1\.5>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*1.5)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*1.5)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-2>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*2)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*2)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-3>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*3)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*3)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-4>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*4)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*4)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-6>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*6)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*6)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-8>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*8)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*8)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-reverse>:not(:last-child)){--tw-space-y-reverse:1}.gap-x-8{column-gap:calc(var(--spacing)*8)}:where(.space-x-reverse>:not(:last-child)){--tw-space-x-reverse:1}.gap-y-4{row-gap:calc(var(--spacing)*4)}:where(.divide-x>:not(:last-child)){--tw-divide-x-reverse:0;border-inline-style:var(--tw-border-style);border-inline-start-width:calc(1px*var(--tw-divide-x-reverse));border-inline-end-width:calc(1px*calc(1 - var(--tw-divide-x-reverse)))}:where(.divide-y>:not(:last-child)){--tw-divide-y-reverse:0;border-bottom-style:var(--tw-border-style);border-top-style:var(--tw-border-style);border-top-width:calc(1px*var(--tw-divide-y-reverse));border-bottom-width:calc(1px*calc(1 - var(--tw-divide-y-reverse)))}:where(.divide-y-reverse>:not(:last-child)){--tw-divide-y-reverse:1}:where(.divide-gray-700\/50>:not(:last-child)){border-color:#36415380}@supports (color:color-mix(in lab,red,red)){:where(.divide-gray-700\/50>:not(:last-child)){border-color:color-mix(in oklab,var(--color-gray-700)50%,transparent)}}:where(.divide-white\/5>:not(:last-child)){border-color:#ffffff0d}@supports (color:color-mix(in lab,red,red)){:where(.divide-white\/5>:not(:last-child)){border-color:color-mix(in oklab,var(--color-white)5%,transparent)}}.truncate{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.overflow-auto{overflow:auto}.overflow-hidden{overflow:hidden}.overflow-x-auto{overflow-x:auto}.overflow-y-auto{overflow-y:auto}.rounded{border-radius:.25rem}.rounded-2xl{border-radius:var(--radius-2xl)}.rounded-full{border-radius:3.40282e38px}.rounded-lg{border-radius:var(--radius-lg)}.rounded-md{border-radius:var(--radius-md)}.rounded-sm{border-radius:var(--radius-sm)}.rounded-xl{border-radius:var(--radius-xl)}.rounded-s{border-start-start-radius:.25rem;border-end-start-radius:.25rem}.rounded-ss{border-start-start-radius:.25rem}.rounded-e{border-start-end-radius:.25rem;border-end-end-radius:.25rem}.rounded-se{border-start-end-radius:.25rem}.rounded-ee{border-end-end-radius:.25rem}.rounded-es{border-end-start-radius:.25rem}.rounded-t{border-top-left-radius:.25rem;border-top-right-radius:.25rem}.rounded-l{border-top-left-radius:.25rem;border-bottom-left-radius:.25rem}.rounded-tl{border-top-left-radius:.25rem}.rounded-r{border-top-right-radius:.25rem;border-bottom-right-radius:.25rem}.rounded-tr{border-top-right-radius:.25rem}.rounded-b{border-bottom-right-radius:.25rem;border-bottom-left-radius:.25rem}.rounded-br{border-bottom-right-radius:.25rem}.rounded-bl{border-bottom-left-radius:.25rem}.border{border-style:var(--tw-border-style);border-width:1px}.border-0{border-style:var(--tw-border-style);border-width:0}.border-2{border-style:var(--tw-border-style);border-width:2px}.border-x{border-inline-style:var(--tw-border-style);border-inline-width:1px}.border-y{border-block-style:var(--tw-border-style);border-block-width:1px}.border-s{border-inline-start-style:var(--tw-border-style);border-inline-start-width:1px}.border-e{border-inline-end-style:var(--tw-border-style);border-inline-end-width:1px}.border-t{border-top-style:var(--tw-border-style);border-top-width:1px}.border-r{border-right-style:var(--tw-border-style);border-right-width:1px}.border-b{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}.border-l{border-left-style:var(--tw-border-style);border-left-width:1px}.border-\[\#07C160\]{border-color:#07c160}.border-\[\#07C160\]\/20{border-color:#07c16033}.border-\[\#07C160\]\/30{border-color:#07c1604d}.border-\[\#38bdac\]{border-color:#38bdac}.border-\[\#38bdac\]\/20{border-color:#38bdac33}.border-\[\#38bdac\]\/30{border-color:#38bdac4d}.border-\[\#38bdac\]\/40{border-color:#38bdac66}.border-\[\#38bdac\]\/50{border-color:#38bdac80}.border-amber-400\/60{border-color:#fcbb0099}@supports (color:color-mix(in lab,red,red)){.border-amber-400\/60{border-color:color-mix(in oklab,var(--color-amber-400)60%,transparent)}}.border-amber-500\/20{border-color:#f99c0033}@supports (color:color-mix(in lab,red,red)){.border-amber-500\/20{border-color:color-mix(in oklab,var(--color-amber-500)20%,transparent)}}.border-amber-500\/30{border-color:#f99c004d}@supports (color:color-mix(in lab,red,red)){.border-amber-500\/30{border-color:color-mix(in oklab,var(--color-amber-500)30%,transparent)}}.border-amber-500\/40{border-color:#f99c0066}@supports (color:color-mix(in lab,red,red)){.border-amber-500\/40{border-color:color-mix(in oklab,var(--color-amber-500)40%,transparent)}}.border-amber-500\/50{border-color:#f99c0080}@supports (color:color-mix(in lab,red,red)){.border-amber-500\/50{border-color:color-mix(in oklab,var(--color-amber-500)50%,transparent)}}.border-blue-500\/30{border-color:#3080ff4d}@supports (color:color-mix(in lab,red,red)){.border-blue-500\/30{border-color:color-mix(in oklab,var(--color-blue-500)30%,transparent)}}.border-blue-500\/40{border-color:#3080ff66}@supports (color:color-mix(in lab,red,red)){.border-blue-500\/40{border-color:color-mix(in oklab,var(--color-blue-500)40%,transparent)}}.border-blue-500\/50{border-color:#3080ff80}@supports (color:color-mix(in lab,red,red)){.border-blue-500\/50{border-color:color-mix(in oklab,var(--color-blue-500)50%,transparent)}}.border-cyan-500\/30{border-color:#00b7d74d}@supports (color:color-mix(in lab,red,red)){.border-cyan-500\/30{border-color:color-mix(in oklab,var(--color-cyan-500)30%,transparent)}}.border-cyan-500\/40{border-color:#00b7d766}@supports (color:color-mix(in lab,red,red)){.border-cyan-500\/40{border-color:color-mix(in oklab,var(--color-cyan-500)40%,transparent)}}.border-gray-500{border-color:var(--color-gray-500)}.border-gray-600{border-color:var(--color-gray-600)}.border-gray-700{border-color:var(--color-gray-700)}.border-gray-700\/30{border-color:#3641534d}@supports (color:color-mix(in lab,red,red)){.border-gray-700\/30{border-color:color-mix(in oklab,var(--color-gray-700)30%,transparent)}}.border-gray-700\/40{border-color:#36415366}@supports (color:color-mix(in lab,red,red)){.border-gray-700\/40{border-color:color-mix(in oklab,var(--color-gray-700)40%,transparent)}}.border-gray-700\/50{border-color:#36415380}@supports (color:color-mix(in lab,red,red)){.border-gray-700\/50{border-color:color-mix(in oklab,var(--color-gray-700)50%,transparent)}}.border-gray-700\/60{border-color:#36415399}@supports (color:color-mix(in lab,red,red)){.border-gray-700\/60{border-color:color-mix(in oklab,var(--color-gray-700)60%,transparent)}}.border-green-500\/30{border-color:#00c7584d}@supports (color:color-mix(in lab,red,red)){.border-green-500\/30{border-color:color-mix(in oklab,var(--color-green-500)30%,transparent)}}.border-green-500\/40{border-color:#00c75866}@supports (color:color-mix(in lab,red,red)){.border-green-500\/40{border-color:color-mix(in oklab,var(--color-green-500)40%,transparent)}}.border-orange-500\/20{border-color:#fe6e0033}@supports (color:color-mix(in lab,red,red)){.border-orange-500\/20{border-color:color-mix(in oklab,var(--color-orange-500)20%,transparent)}}.border-orange-500\/30{border-color:#fe6e004d}@supports (color:color-mix(in lab,red,red)){.border-orange-500\/30{border-color:color-mix(in oklab,var(--color-orange-500)30%,transparent)}}.border-orange-500\/40{border-color:#fe6e0066}@supports (color:color-mix(in lab,red,red)){.border-orange-500\/40{border-color:color-mix(in oklab,var(--color-orange-500)40%,transparent)}}.border-orange-500\/50{border-color:#fe6e0080}@supports (color:color-mix(in lab,red,red)){.border-orange-500\/50{border-color:color-mix(in oklab,var(--color-orange-500)50%,transparent)}}.border-purple-500\/20{border-color:#ac4bff33}@supports (color:color-mix(in lab,red,red)){.border-purple-500\/20{border-color:color-mix(in oklab,var(--color-purple-500)20%,transparent)}}.border-purple-500\/30{border-color:#ac4bff4d}@supports (color:color-mix(in lab,red,red)){.border-purple-500\/30{border-color:color-mix(in oklab,var(--color-purple-500)30%,transparent)}}.border-purple-500\/40{border-color:#ac4bff66}@supports (color:color-mix(in lab,red,red)){.border-purple-500\/40{border-color:color-mix(in oklab,var(--color-purple-500)40%,transparent)}}.border-red-500\/20{border-color:#fb2c3633}@supports (color:color-mix(in lab,red,red)){.border-red-500\/20{border-color:color-mix(in oklab,var(--color-red-500)20%,transparent)}}.border-red-500\/30{border-color:#fb2c364d}@supports (color:color-mix(in lab,red,red)){.border-red-500\/30{border-color:color-mix(in oklab,var(--color-red-500)30%,transparent)}}.border-red-500\/50{border-color:#fb2c3680}@supports (color:color-mix(in lab,red,red)){.border-red-500\/50{border-color:color-mix(in oklab,var(--color-red-500)50%,transparent)}}.border-transparent{border-color:#0000}.border-white\/5{border-color:#ffffff0d}@supports (color:color-mix(in lab,red,red)){.border-white\/5{border-color:color-mix(in oklab,var(--color-white)5%,transparent)}}.border-white\/10{border-color:#ffffff1a}@supports (color:color-mix(in lab,red,red)){.border-white\/10{border-color:color-mix(in oklab,var(--color-white)10%,transparent)}}.border-white\/20{border-color:#fff3}@supports (color:color-mix(in lab,red,red)){.border-white\/20{border-color:color-mix(in oklab,var(--color-white)20%,transparent)}}.border-yellow-500\/30{border-color:#edb2004d}@supports (color:color-mix(in lab,red,red)){.border-yellow-500\/30{border-color:color-mix(in oklab,var(--color-yellow-500)30%,transparent)}}.border-yellow-500\/40{border-color:#edb20066}@supports (color:color-mix(in lab,red,red)){.border-yellow-500\/40{border-color:color-mix(in oklab,var(--color-yellow-500)40%,transparent)}}.bg-\[\#0a1628\]{background-color:#0a1628}.bg-\[\#0a1628\]\/50{background-color:#0a162880}.bg-\[\#0b1828\]{background-color:#0b1828}.bg-\[\#0f2137\]{background-color:#0f2137}.bg-\[\#00CED1\]{background-color:#00ced1}.bg-\[\#1C1C1E\]{background-color:#1c1c1e}.bg-\[\#07C160\]{background-color:#07c160}.bg-\[\#07C160\]\/5{background-color:#07c1600d}.bg-\[\#07C160\]\/10{background-color:#07c1601a}.bg-\[\#38bdac\]{background-color:#38bdac}.bg-\[\#38bdac\]\/5{background-color:#38bdac0d}.bg-\[\#38bdac\]\/10{background-color:#38bdac1a}.bg-\[\#38bdac\]\/15{background-color:#38bdac26}.bg-\[\#38bdac\]\/20{background-color:#38bdac33}.bg-\[\#38bdac\]\/30{background-color:#38bdac4d}.bg-\[\#38bdac\]\/60{background-color:#38bdac99}.bg-\[\#38bdac\]\/80{background-color:#38bdaccc}.bg-\[\#050c18\]{background-color:#050c18}.bg-\[\#162840\]{background-color:#162840}.bg-amber-500{background-color:var(--color-amber-500)}.bg-amber-500\/5{background-color:#f99c000d}@supports (color:color-mix(in lab,red,red)){.bg-amber-500\/5{background-color:color-mix(in oklab,var(--color-amber-500)5%,transparent)}}.bg-amber-500\/10{background-color:#f99c001a}@supports (color:color-mix(in lab,red,red)){.bg-amber-500\/10{background-color:color-mix(in oklab,var(--color-amber-500)10%,transparent)}}.bg-amber-500\/20{background-color:#f99c0033}@supports (color:color-mix(in lab,red,red)){.bg-amber-500\/20{background-color:color-mix(in oklab,var(--color-amber-500)20%,transparent)}}.bg-black{background-color:var(--color-black)}.bg-black\/50{background-color:#00000080}@supports (color:color-mix(in lab,red,red)){.bg-black\/50{background-color:color-mix(in oklab,var(--color-black)50%,transparent)}}.bg-black\/60{background-color:#0009}@supports (color:color-mix(in lab,red,red)){.bg-black\/60{background-color:color-mix(in oklab,var(--color-black)60%,transparent)}}.bg-black\/90{background-color:#000000e6}@supports (color:color-mix(in lab,red,red)){.bg-black\/90{background-color:color-mix(in oklab,var(--color-black)90%,transparent)}}.bg-blue-500\/5{background-color:#3080ff0d}@supports (color:color-mix(in lab,red,red)){.bg-blue-500\/5{background-color:color-mix(in oklab,var(--color-blue-500)5%,transparent)}}.bg-blue-500\/10{background-color:#3080ff1a}@supports (color:color-mix(in lab,red,red)){.bg-blue-500\/10{background-color:color-mix(in oklab,var(--color-blue-500)10%,transparent)}}.bg-blue-500\/20{background-color:#3080ff33}@supports (color:color-mix(in lab,red,red)){.bg-blue-500\/20{background-color:color-mix(in oklab,var(--color-blue-500)20%,transparent)}}.bg-cyan-500{background-color:var(--color-cyan-500)}.bg-cyan-500\/20{background-color:#00b7d733}@supports (color:color-mix(in lab,red,red)){.bg-cyan-500\/20{background-color:color-mix(in oklab,var(--color-cyan-500)20%,transparent)}}.bg-emerald-500\/20{background-color:#00bb7f33}@supports (color:color-mix(in lab,red,red)){.bg-emerald-500\/20{background-color:color-mix(in oklab,var(--color-emerald-500)20%,transparent)}}.bg-gray-500{background-color:var(--color-gray-500)}.bg-gray-500\/20{background-color:#6a728233}@supports (color:color-mix(in lab,red,red)){.bg-gray-500\/20{background-color:color-mix(in oklab,var(--color-gray-500)20%,transparent)}}.bg-gray-600{background-color:var(--color-gray-600)}.bg-gray-600\/20{background-color:#4a556533}@supports (color:color-mix(in lab,red,red)){.bg-gray-600\/20{background-color:color-mix(in oklab,var(--color-gray-600)20%,transparent)}}.bg-gray-600\/50{background-color:#4a556580}@supports (color:color-mix(in lab,red,red)){.bg-gray-600\/50{background-color:color-mix(in oklab,var(--color-gray-600)50%,transparent)}}.bg-gray-700{background-color:var(--color-gray-700)}.bg-gray-700\/50{background-color:#36415380}@supports (color:color-mix(in lab,red,red)){.bg-gray-700\/50{background-color:color-mix(in oklab,var(--color-gray-700)50%,transparent)}}.bg-green-500{background-color:var(--color-green-500)}.bg-green-500\/20{background-color:#00c75833}@supports (color:color-mix(in lab,red,red)){.bg-green-500\/20{background-color:color-mix(in oklab,var(--color-green-500)20%,transparent)}}.bg-green-600{background-color:var(--color-green-600)}.bg-orange-500{background-color:var(--color-orange-500)}.bg-orange-500\/10{background-color:#fe6e001a}@supports (color:color-mix(in lab,red,red)){.bg-orange-500\/10{background-color:color-mix(in oklab,var(--color-orange-500)10%,transparent)}}.bg-orange-500\/20{background-color:#fe6e0033}@supports (color:color-mix(in lab,red,red)){.bg-orange-500\/20{background-color:color-mix(in oklab,var(--color-orange-500)20%,transparent)}}.bg-purple-500\/20{background-color:#ac4bff33}@supports (color:color-mix(in lab,red,red)){.bg-purple-500\/20{background-color:color-mix(in oklab,var(--color-purple-500)20%,transparent)}}.bg-red-500\/10{background-color:#fb2c361a}@supports (color:color-mix(in lab,red,red)){.bg-red-500\/10{background-color:color-mix(in oklab,var(--color-red-500)10%,transparent)}}.bg-red-500\/20{background-color:#fb2c3633}@supports (color:color-mix(in lab,red,red)){.bg-red-500\/20{background-color:color-mix(in oklab,var(--color-red-500)20%,transparent)}}.bg-transparent{background-color:#0000}.bg-white{background-color:var(--color-white)}.bg-white\/5{background-color:#ffffff0d}@supports (color:color-mix(in lab,red,red)){.bg-white\/5{background-color:color-mix(in oklab,var(--color-white)5%,transparent)}}.bg-white\/10{background-color:#ffffff1a}@supports (color:color-mix(in lab,red,red)){.bg-white\/10{background-color:color-mix(in oklab,var(--color-white)10%,transparent)}}.bg-white\/20{background-color:#fff3}@supports (color:color-mix(in lab,red,red)){.bg-white\/20{background-color:color-mix(in oklab,var(--color-white)20%,transparent)}}.bg-yellow-500\/20{background-color:#edb20033}@supports (color:color-mix(in lab,red,red)){.bg-yellow-500\/20{background-color:color-mix(in oklab,var(--color-yellow-500)20%,transparent)}}.bg-gradient-to-br{--tw-gradient-position:to bottom right in oklab;background-image:linear-gradient(var(--tw-gradient-stops))}.bg-gradient-to-r{--tw-gradient-position:to right in oklab;background-image:linear-gradient(var(--tw-gradient-stops))}.from-\[\#0f2137\]{--tw-gradient-from:#0f2137;--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.from-\[\#00CED1\]{--tw-gradient-from:#00ced1;--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.from-\[\#38bdac\]\/10{--tw-gradient-from:oklab(72.378% -.11483 -.0053193/.1);--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.from-blue-500\/20{--tw-gradient-from:#3080ff33}@supports (color:color-mix(in lab,red,red)){.from-blue-500\/20{--tw-gradient-from:color-mix(in oklab,var(--color-blue-500)20%,transparent)}}.from-blue-500\/20{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.from-cyan-500\/20{--tw-gradient-from:#00b7d733}@supports (color:color-mix(in lab,red,red)){.from-cyan-500\/20{--tw-gradient-from:color-mix(in oklab,var(--color-cyan-500)20%,transparent)}}.from-cyan-500\/20{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.from-green-500\/20{--tw-gradient-from:#00c75833}@supports (color:color-mix(in lab,red,red)){.from-green-500\/20{--tw-gradient-from:color-mix(in oklab,var(--color-green-500)20%,transparent)}}.from-green-500\/20{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.from-purple-500\/20{--tw-gradient-from:#ac4bff33}@supports (color:color-mix(in lab,red,red)){.from-purple-500\/20{--tw-gradient-from:color-mix(in oklab,var(--color-purple-500)20%,transparent)}}.from-purple-500\/20{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.from-yellow-500\/20{--tw-gradient-from:#edb20033}@supports (color:color-mix(in lab,red,red)){.from-yellow-500\/20{--tw-gradient-from:color-mix(in oklab,var(--color-yellow-500)20%,transparent)}}.from-yellow-500\/20{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.via-\[\#38bdac\]\/30{--tw-gradient-via:oklab(72.378% -.11483 -.0053193/.3);--tw-gradient-via-stops:var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-via)var(--tw-gradient-via-position),var(--tw-gradient-to)var(--tw-gradient-to-position);--tw-gradient-stops:var(--tw-gradient-via-stops)}.to-\[\#0f2137\]{--tw-gradient-to:#0f2137;--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.to-\[\#20B2AA\]{--tw-gradient-to:#20b2aa;--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.to-\[\#162d4a\]{--tw-gradient-to:#162d4a;--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.to-amber-500\/20{--tw-gradient-to:#f99c0033}@supports (color:color-mix(in lab,red,red)){.to-amber-500\/20{--tw-gradient-to:color-mix(in oklab,var(--color-amber-500)20%,transparent)}}.to-amber-500\/20{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.to-cyan-500\/5{--tw-gradient-to:#00b7d70d}@supports (color:color-mix(in lab,red,red)){.to-cyan-500\/5{--tw-gradient-to:color-mix(in oklab,var(--color-cyan-500)5%,transparent)}}.to-cyan-500\/5{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.to-green-500\/5{--tw-gradient-to:#00c7580d}@supports (color:color-mix(in lab,red,red)){.to-green-500\/5{--tw-gradient-to:color-mix(in oklab,var(--color-green-500)5%,transparent)}}.to-green-500\/5{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.to-purple-500\/5{--tw-gradient-to:#ac4bff0d}@supports (color:color-mix(in lab,red,red)){.to-purple-500\/5{--tw-gradient-to:color-mix(in oklab,var(--color-purple-500)5%,transparent)}}.to-purple-500\/5{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.to-yellow-500\/5{--tw-gradient-to:#edb2000d}@supports (color:color-mix(in lab,red,red)){.to-yellow-500\/5{--tw-gradient-to:color-mix(in oklab,var(--color-yellow-500)5%,transparent)}}.to-yellow-500\/5{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.bg-repeat{background-repeat:repeat}.mask-no-clip{-webkit-mask-clip:no-clip;mask-clip:no-clip}.mask-repeat{-webkit-mask-repeat:repeat;mask-repeat:repeat}.fill-amber-400{fill:var(--color-amber-400)}.fill-current{fill:currentColor}.object-cover{object-fit:cover}.p-0{padding:calc(var(--spacing)*0)}.p-1{padding:calc(var(--spacing)*1)}.p-2{padding:calc(var(--spacing)*2)}.p-2\.5{padding:calc(var(--spacing)*2.5)}.p-3{padding:calc(var(--spacing)*3)}.p-4{padding:calc(var(--spacing)*4)}.p-5{padding:calc(var(--spacing)*5)}.p-6{padding:calc(var(--spacing)*6)}.p-8{padding:calc(var(--spacing)*8)}.px-0{padding-inline:calc(var(--spacing)*0)}.px-1{padding-inline:calc(var(--spacing)*1)}.px-1\.5{padding-inline:calc(var(--spacing)*1.5)}.px-2{padding-inline:calc(var(--spacing)*2)}.px-3{padding-inline:calc(var(--spacing)*3)}.px-4{padding-inline:calc(var(--spacing)*4)}.px-5{padding-inline:calc(var(--spacing)*5)}.px-6{padding-inline:calc(var(--spacing)*6)}.py-0\.5{padding-block:calc(var(--spacing)*.5)}.py-1{padding-block:calc(var(--spacing)*1)}.py-1\.5{padding-block:calc(var(--spacing)*1.5)}.py-2{padding-block:calc(var(--spacing)*2)}.py-2\.5{padding-block:calc(var(--spacing)*2.5)}.py-3{padding-block:calc(var(--spacing)*3)}.py-4{padding-block:calc(var(--spacing)*4)}.py-5{padding-block:calc(var(--spacing)*5)}.py-6{padding-block:calc(var(--spacing)*6)}.py-8{padding-block:calc(var(--spacing)*8)}.py-10{padding-block:calc(var(--spacing)*10)}.py-12{padding-block:calc(var(--spacing)*12)}.py-16{padding-block:calc(var(--spacing)*16)}.py-20{padding-block:calc(var(--spacing)*20)}.pt-0{padding-top:calc(var(--spacing)*0)}.pt-1{padding-top:calc(var(--spacing)*1)}.pt-2{padding-top:calc(var(--spacing)*2)}.pt-3{padding-top:calc(var(--spacing)*3)}.pt-4{padding-top:calc(var(--spacing)*4)}.pt-5{padding-top:calc(var(--spacing)*5)}.pt-6{padding-top:calc(var(--spacing)*6)}.pr-1{padding-right:calc(var(--spacing)*1)}.pr-2{padding-right:calc(var(--spacing)*2)}.pr-4{padding-right:calc(var(--spacing)*4)}.pb-1{padding-bottom:calc(var(--spacing)*1)}.pb-2{padding-bottom:calc(var(--spacing)*2)}.pb-3{padding-bottom:calc(var(--spacing)*3)}.pb-4{padding-bottom:calc(var(--spacing)*4)}.pl-2{padding-left:calc(var(--spacing)*2)}.pl-4{padding-left:calc(var(--spacing)*4)}.pl-8{padding-left:calc(var(--spacing)*8)}.pl-10{padding-left:calc(var(--spacing)*10)}.text-center{text-align:center}.text-left{text-align:left}.text-right{text-align:right}.align-middle{vertical-align:middle}.font-mono{font-family:var(--font-mono)}.text-2xl{font-size:var(--text-2xl);line-height:var(--tw-leading,var(--text-2xl--line-height))}.text-3xl{font-size:var(--text-3xl);line-height:var(--tw-leading,var(--text-3xl--line-height))}.text-4xl{font-size:var(--text-4xl);line-height:var(--tw-leading,var(--text-4xl--line-height))}.text-base{font-size:var(--text-base);line-height:var(--tw-leading,var(--text-base--line-height))}.text-lg{font-size:var(--text-lg);line-height:var(--tw-leading,var(--text-lg--line-height))}.text-sm{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.text-xl{font-size:var(--text-xl);line-height:var(--tw-leading,var(--text-xl--line-height))}.text-xs{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}.text-\[10px\]{font-size:10px}.text-\[11px\]{font-size:11px}.leading-6{--tw-leading:calc(var(--spacing)*6);line-height:calc(var(--spacing)*6)}.leading-none{--tw-leading:1;line-height:1}.leading-relaxed{--tw-leading:var(--leading-relaxed);line-height:var(--leading-relaxed)}.leading-tight{--tw-leading:var(--leading-tight);line-height:var(--leading-tight)}.font-bold{--tw-font-weight:var(--font-weight-bold);font-weight:var(--font-weight-bold)}.font-medium{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.font-normal{--tw-font-weight:var(--font-weight-normal);font-weight:var(--font-weight-normal)}.font-semibold{--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.tracking-tight{--tw-tracking:var(--tracking-tight);letter-spacing:var(--tracking-tight)}.tracking-wider{--tw-tracking:var(--tracking-wider);letter-spacing:var(--tracking-wider)}.text-wrap{text-wrap:wrap}.break-all{word-break:break-all}.text-clip{text-overflow:clip}.text-ellipsis{text-overflow:ellipsis}.whitespace-nowrap{white-space:nowrap}.whitespace-pre-wrap{white-space:pre-wrap}.text-\[\#00CED1\]{color:#00ced1}.text-\[\#07C160\]{color:#07c160}.text-\[\#07C160\]\/60{color:#07c16099}.text-\[\#07C160\]\/70{color:#07c160b3}.text-\[\#07C160\]\/80{color:#07c160cc}.text-\[\#26A17B\]{color:#26a17b}.text-\[\#38bdac\]{color:#38bdac}.text-\[\#38bdac\]\/30{color:#38bdac4d}.text-\[\#38bdac\]\/40{color:#38bdac66}.text-\[\#169BD7\]{color:#169bd7}.text-\[\#1677FF\]{color:#1677ff}.text-\[\#FFD700\]{color:gold}.text-amber-200{color:var(--color-amber-200)}.text-amber-300{color:var(--color-amber-300)}.text-amber-400{color:var(--color-amber-400)}.text-amber-400\/30{color:#fcbb004d}@supports (color:color-mix(in lab,red,red)){.text-amber-400\/30{color:color-mix(in oklab,var(--color-amber-400)30%,transparent)}}.text-amber-400\/90{color:#fcbb00e6}@supports (color:color-mix(in lab,red,red)){.text-amber-400\/90{color:color-mix(in oklab,var(--color-amber-400)90%,transparent)}}.text-black{color:var(--color-black)}.text-blue-300{color:var(--color-blue-300)}.text-blue-300\/60{color:#90c5ff99}@supports (color:color-mix(in lab,red,red)){.text-blue-300\/60{color:color-mix(in oklab,var(--color-blue-300)60%,transparent)}}.text-blue-400{color:var(--color-blue-400)}.text-blue-400\/60{color:#54a2ff99}@supports (color:color-mix(in lab,red,red)){.text-blue-400\/60{color:color-mix(in oklab,var(--color-blue-400)60%,transparent)}}.text-cyan-400{color:var(--color-cyan-400)}.text-emerald-400{color:var(--color-emerald-400)}.text-gray-200{color:var(--color-gray-200)}.text-gray-300{color:var(--color-gray-300)}.text-gray-400{color:var(--color-gray-400)}.text-gray-500{color:var(--color-gray-500)}.text-gray-600{color:var(--color-gray-600)}.text-gray-700{color:var(--color-gray-700)}.text-green-300{color:var(--color-green-300)}.text-green-400{color:var(--color-green-400)}.text-green-500{color:var(--color-green-500)}.text-orange-300{color:var(--color-orange-300)}.text-orange-300\/60{color:#ffb96d99}@supports (color:color-mix(in lab,red,red)){.text-orange-300\/60{color:color-mix(in oklab,var(--color-orange-300)60%,transparent)}}.text-orange-400{color:var(--color-orange-400)}.text-orange-400\/60{color:#ff8b1a99}@supports (color:color-mix(in lab,red,red)){.text-orange-400\/60{color:color-mix(in oklab,var(--color-orange-400)60%,transparent)}}.text-orange-400\/70{color:#ff8b1ab3}@supports (color:color-mix(in lab,red,red)){.text-orange-400\/70{color:color-mix(in oklab,var(--color-orange-400)70%,transparent)}}.text-orange-400\/80{color:#ff8b1acc}@supports (color:color-mix(in lab,red,red)){.text-orange-400\/80{color:color-mix(in oklab,var(--color-orange-400)80%,transparent)}}.text-purple-400{color:var(--color-purple-400)}.text-red-400{color:var(--color-red-400)}.text-sky-300{color:var(--color-sky-300)}.text-white{color:var(--color-white)}.text-white\/40{color:#fff6}@supports (color:color-mix(in lab,red,red)){.text-white\/40{color:color-mix(in oklab,var(--color-white)40%,transparent)}}.text-white\/60{color:#fff9}@supports (color:color-mix(in lab,red,red)){.text-white\/60{color:color-mix(in oklab,var(--color-white)60%,transparent)}}.text-white\/70{color:#ffffffb3}@supports (color:color-mix(in lab,red,red)){.text-white\/70{color:color-mix(in oklab,var(--color-white)70%,transparent)}}.text-white\/80{color:#fffc}@supports (color:color-mix(in lab,red,red)){.text-white\/80{color:color-mix(in oklab,var(--color-white)80%,transparent)}}.text-yellow-400{color:var(--color-yellow-400)}.text-yellow-400\/60{color:#fac80099}@supports (color:color-mix(in lab,red,red)){.text-yellow-400\/60{color:color-mix(in oklab,var(--color-yellow-400)60%,transparent)}}.text-yellow-500\/70{color:#edb200b3}@supports (color:color-mix(in lab,red,red)){.text-yellow-500\/70{color:color-mix(in oklab,var(--color-yellow-500)70%,transparent)}}.capitalize{text-transform:capitalize}.lowercase{text-transform:lowercase}.normal-case{text-transform:none}.uppercase{text-transform:uppercase}.italic{font-style:italic}.italic\!{font-style:italic!important}.not-italic{font-style:normal}.diagonal-fractions{--tw-numeric-fraction:diagonal-fractions;font-variant-numeric:var(--tw-ordinal,)var(--tw-slashed-zero,)var(--tw-numeric-figure,)var(--tw-numeric-spacing,)var(--tw-numeric-fraction,)}.lining-nums{--tw-numeric-figure:lining-nums;font-variant-numeric:var(--tw-ordinal,)var(--tw-slashed-zero,)var(--tw-numeric-figure,)var(--tw-numeric-spacing,)var(--tw-numeric-fraction,)}.oldstyle-nums{--tw-numeric-figure:oldstyle-nums;font-variant-numeric:var(--tw-ordinal,)var(--tw-slashed-zero,)var(--tw-numeric-figure,)var(--tw-numeric-spacing,)var(--tw-numeric-fraction,)}.ordinal{--tw-ordinal:ordinal;font-variant-numeric:var(--tw-ordinal,)var(--tw-slashed-zero,)var(--tw-numeric-figure,)var(--tw-numeric-spacing,)var(--tw-numeric-fraction,)}.proportional-nums{--tw-numeric-spacing:proportional-nums;font-variant-numeric:var(--tw-ordinal,)var(--tw-slashed-zero,)var(--tw-numeric-figure,)var(--tw-numeric-spacing,)var(--tw-numeric-fraction,)}.slashed-zero{--tw-slashed-zero:slashed-zero;font-variant-numeric:var(--tw-ordinal,)var(--tw-slashed-zero,)var(--tw-numeric-figure,)var(--tw-numeric-spacing,)var(--tw-numeric-fraction,)}.stacked-fractions{--tw-numeric-fraction:stacked-fractions;font-variant-numeric:var(--tw-ordinal,)var(--tw-slashed-zero,)var(--tw-numeric-figure,)var(--tw-numeric-spacing,)var(--tw-numeric-fraction,)}.tabular-nums{--tw-numeric-spacing:tabular-nums;font-variant-numeric:var(--tw-ordinal,)var(--tw-slashed-zero,)var(--tw-numeric-figure,)var(--tw-numeric-spacing,)var(--tw-numeric-fraction,)}.normal-nums{font-variant-numeric:normal}.line-through{text-decoration-line:line-through}.no-underline{text-decoration-line:none}.overline{text-decoration-line:overline}.underline{text-decoration-line:underline}.underline\!{text-decoration-line:underline!important}.underline-offset-4{text-underline-offset:4px}.antialiased{-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.subpixel-antialiased{-webkit-font-smoothing:auto;-moz-osx-font-smoothing:auto}.accent-\[\#38bdac\]{accent-color:#38bdac}.opacity-0{opacity:0}.opacity-50{opacity:.5}.opacity-55{opacity:.55}.opacity-60{opacity:.6}.opacity-70{opacity:.7}.shadow{--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a),0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-lg{--tw-shadow:0 10px 15px -3px var(--tw-shadow-color,#0000001a),0 4px 6px -4px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-md{--tw-shadow:0 4px 6px -1px var(--tw-shadow-color,#0000001a),0 2px 4px -2px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-sm{--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a),0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-xl{--tw-shadow:0 20px 25px -5px var(--tw-shadow-color,#0000001a),0 8px 10px -6px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-xs{--tw-shadow:0 1px 2px 0 var(--tw-shadow-color,#0000000d);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.ring-0{--tw-ring-shadow:var(--tw-ring-inset,)0 0 0 calc(0px + var(--tw-ring-offset-width))var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.ring-1{--tw-ring-shadow:var(--tw-ring-inset,)0 0 0 calc(1px + var(--tw-ring-offset-width))var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.ring-2{--tw-ring-shadow:var(--tw-ring-inset,)0 0 0 calc(2px + var(--tw-ring-offset-width))var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.inset-ring{--tw-inset-ring-shadow:inset 0 0 0 1px var(--tw-inset-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-\[\#38bdac\]\/20{--tw-shadow-color:#38bdac33}@supports (color:color-mix(in lab,red,red)){.shadow-\[\#38bdac\]\/20{--tw-shadow-color:color-mix(in oklab,oklab(72.378% -.11483 -.0053193/.2) var(--tw-shadow-alpha),transparent)}}.shadow-\[\#38bdac\]\/30{--tw-shadow-color:#38bdac4d}@supports (color:color-mix(in lab,red,red)){.shadow-\[\#38bdac\]\/30{--tw-shadow-color:color-mix(in oklab,oklab(72.378% -.11483 -.0053193/.3) var(--tw-shadow-alpha),transparent)}}.ring-\[\#38bdac\]{--tw-ring-color:#38bdac}.ring-\[\#38bdac\]\/40{--tw-ring-color:oklab(72.378% -.11483 -.0053193/.4)}.ring-\[\#38bdac\]\/50{--tw-ring-color:oklab(72.378% -.11483 -.0053193/.5)}.outline{outline-style:var(--tw-outline-style);outline-width:1px}.blur{--tw-blur:blur(8px);filter:var(--tw-blur,)var(--tw-brightness,)var(--tw-contrast,)var(--tw-grayscale,)var(--tw-hue-rotate,)var(--tw-invert,)var(--tw-saturate,)var(--tw-sepia,)var(--tw-drop-shadow,)}.blur-3xl{--tw-blur:blur(var(--blur-3xl));filter:var(--tw-blur,)var(--tw-brightness,)var(--tw-contrast,)var(--tw-grayscale,)var(--tw-hue-rotate,)var(--tw-invert,)var(--tw-saturate,)var(--tw-sepia,)var(--tw-drop-shadow,)}.drop-shadow{--tw-drop-shadow-size:drop-shadow(0 1px 2px var(--tw-drop-shadow-color,#0000001a))drop-shadow(0 1px 1px var(--tw-drop-shadow-color,#0000000f));--tw-drop-shadow:drop-shadow(0 1px 2px #0000001a)drop-shadow(0 1px 1px #0000000f);filter:var(--tw-blur,)var(--tw-brightness,)var(--tw-contrast,)var(--tw-grayscale,)var(--tw-hue-rotate,)var(--tw-invert,)var(--tw-saturate,)var(--tw-sepia,)var(--tw-drop-shadow,)}.filter{filter:var(--tw-blur,)var(--tw-brightness,)var(--tw-contrast,)var(--tw-grayscale,)var(--tw-hue-rotate,)var(--tw-invert,)var(--tw-saturate,)var(--tw-sepia,)var(--tw-drop-shadow,)}.filter\!{filter:var(--tw-blur,)var(--tw-brightness,)var(--tw-contrast,)var(--tw-grayscale,)var(--tw-hue-rotate,)var(--tw-invert,)var(--tw-saturate,)var(--tw-sepia,)var(--tw-drop-shadow,)!important}.backdrop-blur{--tw-backdrop-blur:blur(8px);-webkit-backdrop-filter:var(--tw-backdrop-blur,)var(--tw-backdrop-brightness,)var(--tw-backdrop-contrast,)var(--tw-backdrop-grayscale,)var(--tw-backdrop-hue-rotate,)var(--tw-backdrop-invert,)var(--tw-backdrop-opacity,)var(--tw-backdrop-saturate,)var(--tw-backdrop-sepia,);backdrop-filter:var(--tw-backdrop-blur,)var(--tw-backdrop-brightness,)var(--tw-backdrop-contrast,)var(--tw-backdrop-grayscale,)var(--tw-backdrop-hue-rotate,)var(--tw-backdrop-invert,)var(--tw-backdrop-opacity,)var(--tw-backdrop-saturate,)var(--tw-backdrop-sepia,)}.backdrop-blur-xl{--tw-backdrop-blur:blur(var(--blur-xl));-webkit-backdrop-filter:var(--tw-backdrop-blur,)var(--tw-backdrop-brightness,)var(--tw-backdrop-contrast,)var(--tw-backdrop-grayscale,)var(--tw-backdrop-hue-rotate,)var(--tw-backdrop-invert,)var(--tw-backdrop-opacity,)var(--tw-backdrop-saturate,)var(--tw-backdrop-sepia,);backdrop-filter:var(--tw-backdrop-blur,)var(--tw-backdrop-brightness,)var(--tw-backdrop-contrast,)var(--tw-backdrop-grayscale,)var(--tw-backdrop-hue-rotate,)var(--tw-backdrop-invert,)var(--tw-backdrop-opacity,)var(--tw-backdrop-saturate,)var(--tw-backdrop-sepia,)}.backdrop-grayscale{--tw-backdrop-grayscale:grayscale(100%);-webkit-backdrop-filter:var(--tw-backdrop-blur,)var(--tw-backdrop-brightness,)var(--tw-backdrop-contrast,)var(--tw-backdrop-grayscale,)var(--tw-backdrop-hue-rotate,)var(--tw-backdrop-invert,)var(--tw-backdrop-opacity,)var(--tw-backdrop-saturate,)var(--tw-backdrop-sepia,);backdrop-filter:var(--tw-backdrop-blur,)var(--tw-backdrop-brightness,)var(--tw-backdrop-contrast,)var(--tw-backdrop-grayscale,)var(--tw-backdrop-hue-rotate,)var(--tw-backdrop-invert,)var(--tw-backdrop-opacity,)var(--tw-backdrop-saturate,)var(--tw-backdrop-sepia,)}.backdrop-invert{--tw-backdrop-invert:invert(100%);-webkit-backdrop-filter:var(--tw-backdrop-blur,)var(--tw-backdrop-brightness,)var(--tw-backdrop-contrast,)var(--tw-backdrop-grayscale,)var(--tw-backdrop-hue-rotate,)var(--tw-backdrop-invert,)var(--tw-backdrop-opacity,)var(--tw-backdrop-saturate,)var(--tw-backdrop-sepia,);backdrop-filter:var(--tw-backdrop-blur,)var(--tw-backdrop-brightness,)var(--tw-backdrop-contrast,)var(--tw-backdrop-grayscale,)var(--tw-backdrop-hue-rotate,)var(--tw-backdrop-invert,)var(--tw-backdrop-opacity,)var(--tw-backdrop-saturate,)var(--tw-backdrop-sepia,)}.backdrop-sepia{--tw-backdrop-sepia:sepia(100%);-webkit-backdrop-filter:var(--tw-backdrop-blur,)var(--tw-backdrop-brightness,)var(--tw-backdrop-contrast,)var(--tw-backdrop-grayscale,)var(--tw-backdrop-hue-rotate,)var(--tw-backdrop-invert,)var(--tw-backdrop-opacity,)var(--tw-backdrop-saturate,)var(--tw-backdrop-sepia,);backdrop-filter:var(--tw-backdrop-blur,)var(--tw-backdrop-brightness,)var(--tw-backdrop-contrast,)var(--tw-backdrop-grayscale,)var(--tw-backdrop-hue-rotate,)var(--tw-backdrop-invert,)var(--tw-backdrop-opacity,)var(--tw-backdrop-saturate,)var(--tw-backdrop-sepia,)}.backdrop-filter{-webkit-backdrop-filter:var(--tw-backdrop-blur,)var(--tw-backdrop-brightness,)var(--tw-backdrop-contrast,)var(--tw-backdrop-grayscale,)var(--tw-backdrop-hue-rotate,)var(--tw-backdrop-invert,)var(--tw-backdrop-opacity,)var(--tw-backdrop-saturate,)var(--tw-backdrop-sepia,);backdrop-filter:var(--tw-backdrop-blur,)var(--tw-backdrop-brightness,)var(--tw-backdrop-contrast,)var(--tw-backdrop-grayscale,)var(--tw-backdrop-hue-rotate,)var(--tw-backdrop-invert,)var(--tw-backdrop-opacity,)var(--tw-backdrop-saturate,)var(--tw-backdrop-sepia,)}.transition{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to,opacity,box-shadow,transform,translate,scale,rotate,filter,-webkit-backdrop-filter,backdrop-filter,display,content-visibility,overlay,pointer-events;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition\!{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to,opacity,box-shadow,transform,translate,scale,rotate,filter,-webkit-backdrop-filter,backdrop-filter,display,content-visibility,overlay,pointer-events!important;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function))!important;transition-duration:var(--tw-duration,var(--default-transition-duration))!important}.transition-all{transition-property:all;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-colors{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-opacity{transition-property:opacity;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-transform{transition-property:transform,translate,scale,rotate;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.duration-200{--tw-duration:.2s;transition-duration:.2s}.outline-none{--tw-outline-style:none;outline-style:none}.select-none{-webkit-user-select:none;user-select:none}:where(.divide-x-reverse>:not(:last-child)){--tw-divide-x-reverse:1}.ring-inset{--tw-ring-inset:inset}@media(hover:hover){.group-hover\:text-\[\#38bdac\]:is(:where(.group):hover *){color:#38bdac}.group-hover\:text-gray-400:is(:where(.group):hover *){color:var(--color-gray-400)}.group-hover\:opacity-100:is(:where(.group):hover *){opacity:1}}.peer-disabled\:cursor-not-allowed:is(:where(.peer):disabled~*){cursor:not-allowed}.peer-disabled\:opacity-70:is(:where(.peer):disabled~*){opacity:.7}.placeholder\:text-gray-500::placeholder{color:var(--color-gray-500)}.last\:border-b-0:last-child{border-bottom-style:var(--tw-border-style);border-bottom-width:0}@media(hover:hover){.hover\:border-\[\#38bdac\]\/30:hover{border-color:#38bdac4d}.hover\:border-\[\#38bdac\]\/50:hover{border-color:#38bdac80}.hover\:border-\[\#38bdac\]\/60:hover{border-color:#38bdac99}.hover\:border-\[\#38bdac\]\/70:hover{border-color:#38bdacb3}.hover\:border-blue-500\/60:hover{border-color:#3080ff99}@supports (color:color-mix(in lab,red,red)){.hover\:border-blue-500\/60:hover{border-color:color-mix(in oklab,var(--color-blue-500)60%,transparent)}}.hover\:border-gray-500:hover{border-color:var(--color-gray-500)}.hover\:border-gray-600:hover{border-color:var(--color-gray-600)}.hover\:border-orange-500\/50:hover{border-color:#fe6e0080}@supports (color:color-mix(in lab,red,red)){.hover\:border-orange-500\/50:hover{border-color:color-mix(in oklab,var(--color-orange-500)50%,transparent)}}.hover\:border-yellow-500\/60:hover{border-color:#edb20099}@supports (color:color-mix(in lab,red,red)){.hover\:border-yellow-500\/60:hover{border-color:color-mix(in oklab,var(--color-yellow-500)60%,transparent)}}.hover\:bg-\[\#0a1628\]:hover{background-color:#0a1628}.hover\:bg-\[\#1a3050\]:hover{background-color:#1a3050}.hover\:bg-\[\#2da396\]:hover{background-color:#2da396}.hover\:bg-\[\#06AD51\]:hover{background-color:#06ad51}.hover\:bg-\[\#07C160\]\/10:hover{background-color:#07c1601a}.hover\:bg-\[\#20B2AA\]:hover{background-color:#20b2aa}.hover\:bg-\[\#38bdac\]\/10:hover{background-color:#38bdac1a}.hover\:bg-\[\#38bdac\]\/20:hover{background-color:#38bdac33}.hover\:bg-\[\#162840\]:hover{background-color:#162840}.hover\:bg-\[\#162840\]\/30:hover{background-color:#1628404d}.hover\:bg-\[\#162840\]\/50:hover{background-color:#16284080}.hover\:bg-amber-500\/10:hover{background-color:#f99c001a}@supports (color:color-mix(in lab,red,red)){.hover\:bg-amber-500\/10:hover{background-color:color-mix(in oklab,var(--color-amber-500)10%,transparent)}}.hover\:bg-amber-500\/20:hover{background-color:#f99c0033}@supports (color:color-mix(in lab,red,red)){.hover\:bg-amber-500\/20:hover{background-color:color-mix(in oklab,var(--color-amber-500)20%,transparent)}}.hover\:bg-amber-500\/30:hover{background-color:#f99c004d}@supports (color:color-mix(in lab,red,red)){.hover\:bg-amber-500\/30:hover{background-color:color-mix(in oklab,var(--color-amber-500)30%,transparent)}}.hover\:bg-amber-600:hover{background-color:var(--color-amber-600)}.hover\:bg-blue-400\/10:hover{background-color:#54a2ff1a}@supports (color:color-mix(in lab,red,red)){.hover\:bg-blue-400\/10:hover{background-color:color-mix(in oklab,var(--color-blue-400)10%,transparent)}}.hover\:bg-blue-500\/20:hover{background-color:#3080ff33}@supports (color:color-mix(in lab,red,red)){.hover\:bg-blue-500\/20:hover{background-color:color-mix(in oklab,var(--color-blue-500)20%,transparent)}}.hover\:bg-gray-500:hover{background-color:var(--color-gray-500)}.hover\:bg-gray-500\/20:hover{background-color:#6a728233}@supports (color:color-mix(in lab,red,red)){.hover\:bg-gray-500\/20:hover{background-color:color-mix(in oklab,var(--color-gray-500)20%,transparent)}}.hover\:bg-gray-700\/50:hover{background-color:#36415380}@supports (color:color-mix(in lab,red,red)){.hover\:bg-gray-700\/50:hover{background-color:color-mix(in oklab,var(--color-gray-700)50%,transparent)}}.hover\:bg-gray-800:hover{background-color:var(--color-gray-800)}.hover\:bg-green-500\/20:hover{background-color:#00c75833}@supports (color:color-mix(in lab,red,red)){.hover\:bg-green-500\/20:hover{background-color:color-mix(in oklab,var(--color-green-500)20%,transparent)}}.hover\:bg-green-700:hover{background-color:var(--color-green-700)}.hover\:bg-orange-500\/10:hover{background-color:#fe6e001a}@supports (color:color-mix(in lab,red,red)){.hover\:bg-orange-500\/10:hover{background-color:color-mix(in oklab,var(--color-orange-500)10%,transparent)}}.hover\:bg-orange-500\/20:hover{background-color:#fe6e0033}@supports (color:color-mix(in lab,red,red)){.hover\:bg-orange-500\/20:hover{background-color:color-mix(in oklab,var(--color-orange-500)20%,transparent)}}.hover\:bg-orange-600:hover{background-color:var(--color-orange-600)}.hover\:bg-purple-500\/10:hover{background-color:#ac4bff1a}@supports (color:color-mix(in lab,red,red)){.hover\:bg-purple-500\/10:hover{background-color:color-mix(in oklab,var(--color-purple-500)10%,transparent)}}.hover\:bg-purple-500\/20:hover{background-color:#ac4bff33}@supports (color:color-mix(in lab,red,red)){.hover\:bg-purple-500\/20:hover{background-color:color-mix(in oklab,var(--color-purple-500)20%,transparent)}}.hover\:bg-purple-500\/30:hover{background-color:#ac4bff4d}@supports (color:color-mix(in lab,red,red)){.hover\:bg-purple-500\/30:hover{background-color:color-mix(in oklab,var(--color-purple-500)30%,transparent)}}.hover\:bg-red-500\/10:hover{background-color:#fb2c361a}@supports (color:color-mix(in lab,red,red)){.hover\:bg-red-500\/10:hover{background-color:color-mix(in oklab,var(--color-red-500)10%,transparent)}}.hover\:bg-red-500\/20:hover{background-color:#fb2c3633}@supports (color:color-mix(in lab,red,red)){.hover\:bg-red-500\/20:hover{background-color:color-mix(in oklab,var(--color-red-500)20%,transparent)}}.hover\:bg-white\/5:hover{background-color:#ffffff0d}@supports (color:color-mix(in lab,red,red)){.hover\:bg-white\/5:hover{background-color:color-mix(in oklab,var(--color-white)5%,transparent)}}.hover\:bg-white\/20:hover{background-color:#fff3}@supports (color:color-mix(in lab,red,red)){.hover\:bg-white\/20:hover{background-color:color-mix(in oklab,var(--color-white)20%,transparent)}}.hover\:bg-yellow-500\/20:hover{background-color:#edb20033}@supports (color:color-mix(in lab,red,red)){.hover\:bg-yellow-500\/20:hover{background-color:color-mix(in oklab,var(--color-yellow-500)20%,transparent)}}.hover\:bg-yellow-500\/30:hover{background-color:#edb2004d}@supports (color:color-mix(in lab,red,red)){.hover\:bg-yellow-500\/30:hover{background-color:color-mix(in oklab,var(--color-yellow-500)30%,transparent)}}.hover\:text-\[\#2da396\]:hover{color:#2da396}.hover\:text-\[\#5fe0cd\]:hover{color:#5fe0cd}.hover\:text-\[\#38bdac\]:hover{color:#38bdac}.hover\:text-amber-200:hover{color:var(--color-amber-200)}.hover\:text-amber-300:hover{color:var(--color-amber-300)}.hover\:text-amber-400:hover{color:var(--color-amber-400)}.hover\:text-blue-300:hover{color:var(--color-blue-300)}.hover\:text-blue-400:hover{color:var(--color-blue-400)}.hover\:text-gray-300:hover{color:var(--color-gray-300)}.hover\:text-orange-400:hover{color:var(--color-orange-400)}.hover\:text-red-300:hover{color:var(--color-red-300)}.hover\:text-red-400:hover{color:var(--color-red-400)}.hover\:text-sky-200:hover{color:var(--color-sky-200)}.hover\:text-white:hover{color:var(--color-white)}.hover\:underline:hover{text-decoration-line:underline}.hover\:opacity-100:hover{opacity:1}}.focus\:border-\[\#38bdac\]:focus{border-color:#38bdac}.focus\:border-orange-500\/50:focus{border-color:#fe6e0080}@supports (color:color-mix(in lab,red,red)){.focus\:border-orange-500\/50:focus{border-color:color-mix(in oklab,var(--color-orange-500)50%,transparent)}}.focus\:bg-\[\#38bdac\]\/20:focus{background-color:#38bdac33}.focus\:ring-2:focus{--tw-ring-shadow:var(--tw-ring-inset,)0 0 0 calc(2px + var(--tw-ring-offset-width))var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.focus\:ring-\[\#38bdac\]:focus{--tw-ring-color:#38bdac}.focus\:ring-amber-400:focus{--tw-ring-color:var(--color-amber-400)}.focus\:ring-offset-2:focus{--tw-ring-offset-width:2px;--tw-ring-offset-shadow:var(--tw-ring-inset,)0 0 0 var(--tw-ring-offset-width)var(--tw-ring-offset-color)}.focus\:outline-none:focus{--tw-outline-style:none;outline-style:none}.focus-visible\:ring-2:focus-visible{--tw-ring-shadow:var(--tw-ring-inset,)0 0 0 calc(2px + var(--tw-ring-offset-width))var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.focus-visible\:ring-\[3px\]:focus-visible{--tw-ring-shadow:var(--tw-ring-inset,)0 0 0 calc(3px + var(--tw-ring-offset-width))var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.focus-visible\:ring-\[\#38bdac\]:focus-visible{--tw-ring-color:#38bdac}.focus-visible\:ring-offset-2:focus-visible{--tw-ring-offset-width:2px;--tw-ring-offset-shadow:var(--tw-ring-inset,)0 0 0 var(--tw-ring-offset-width)var(--tw-ring-offset-color)}.focus-visible\:ring-offset-\[\#0a1628\]:focus-visible{--tw-ring-offset-color:#0a1628}.focus-visible\:outline-none:focus-visible{--tw-outline-style:none;outline-style:none}.active\:cursor-grabbing:active{cursor:grabbing}.disabled\:pointer-events-none:disabled{pointer-events:none}.disabled\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\:opacity-40:disabled{opacity:.4}.disabled\:opacity-50:disabled{opacity:.5}.has-\[\>svg\]\:px-2\.5:has(>svg){padding-inline:calc(var(--spacing)*2.5)}.has-\[\>svg\]\:px-3:has(>svg){padding-inline:calc(var(--spacing)*3)}.has-\[\>svg\]\:px-4:has(>svg){padding-inline:calc(var(--spacing)*4)}.data-\[disabled\]\:pointer-events-none[data-disabled]{pointer-events:none}.data-\[disabled\]\:opacity-50[data-disabled]{opacity:.5}.data-\[side\=bottom\]\:translate-y-1[data-side=bottom]{--tw-translate-y:calc(var(--spacing)*1);translate:var(--tw-translate-x)var(--tw-translate-y)}.data-\[state\=active\]\:bg-\[\#07C160\]\/20[data-state=active]{background-color:#07c16033}.data-\[state\=active\]\:bg-\[\#26A17B\]\/20[data-state=active]{background-color:#26a17b33}.data-\[state\=active\]\:bg-\[\#38bdac\]\/20[data-state=active]{background-color:#38bdac33}.data-\[state\=active\]\:bg-\[\#1677FF\]\/20[data-state=active]{background-color:#1677ff33}.data-\[state\=active\]\:bg-\[\#003087\]\/20[data-state=active]{background-color:#00308733}.data-\[state\=active\]\:bg-amber-500\/20[data-state=active]{background-color:#f99c0033}@supports (color:color-mix(in lab,red,red)){.data-\[state\=active\]\:bg-amber-500\/20[data-state=active]{background-color:color-mix(in oklab,var(--color-amber-500)20%,transparent)}}.data-\[state\=active\]\:bg-purple-500\/20[data-state=active]{background-color:#ac4bff33}@supports (color:color-mix(in lab,red,red)){.data-\[state\=active\]\:bg-purple-500\/20[data-state=active]{background-color:color-mix(in oklab,var(--color-purple-500)20%,transparent)}}.data-\[state\=active\]\:font-medium[data-state=active]{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.data-\[state\=active\]\:text-\[\#07C160\][data-state=active]{color:#07c160}.data-\[state\=active\]\:text-\[\#26A17B\][data-state=active]{color:#26a17b}.data-\[state\=active\]\:text-\[\#38bdac\][data-state=active]{color:#38bdac}.data-\[state\=active\]\:text-\[\#169BD7\][data-state=active]{color:#169bd7}.data-\[state\=active\]\:text-\[\#1677FF\][data-state=active]{color:#1677ff}.data-\[state\=active\]\:text-amber-400[data-state=active]{color:var(--color-amber-400)}.data-\[state\=active\]\:text-purple-400[data-state=active]{color:var(--color-purple-400)}.data-\[state\=active\]\:shadow[data-state=active]{--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a),0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.data-\[state\=checked\]\:translate-x-4[data-state=checked]{--tw-translate-x:calc(var(--spacing)*4);translate:var(--tw-translate-x)var(--tw-translate-y)}.data-\[state\=checked\]\:bg-\[\#38bdac\][data-state=checked]{background-color:#38bdac}.data-\[state\=unchecked\]\:translate-x-0[data-state=unchecked]{--tw-translate-x:calc(var(--spacing)*0);translate:var(--tw-translate-x)var(--tw-translate-y)}.data-\[state\=unchecked\]\:bg-gray-600[data-state=unchecked]{background-color:var(--color-gray-600)}@media(min-width:40rem){.sm\:flex-row{flex-direction:row}.sm\:justify-end{justify-content:flex-end}.sm\:gap-0{gap:calc(var(--spacing)*0)}.sm\:text-left{text-align:left}}@media(min-width:48rem){.md\:col-span-2{grid-column:span 2/span 2}.md\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.md\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.md\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.md\:text-sm{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}}@media(min-width:64rem){.lg\:block{display:block}.lg\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.lg\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.lg\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.lg\:grid-cols-8{grid-template-columns:repeat(8,minmax(0,1fr))}}@media(min-width:80rem){.xl\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}}.\[\&_svg\]\:pointer-events-none svg{pointer-events:none}.\[\&_svg\]\:shrink-0 svg{flex-shrink:0}.\[\&_svg\:not\(\[class\*\=\'size-\'\]\)\]\:size-4 svg:not([class*=size-]){width:calc(var(--spacing)*4);height:calc(var(--spacing)*4)}.\[\&_tr\]\:border-b tr{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}.\[\&_tr\:last-child\]\:border-0 tr:last-child{border-style:var(--tw-border-style);border-width:0}.\[\&\:has\(\[role\=checkbox\]\)\]\:pr-0:has([role=checkbox]){padding-right:calc(var(--spacing)*0)}.\[\&\>span\]\:line-clamp-1>span{-webkit-line-clamp:1;-webkit-box-orient:vertical;display:-webkit-box;overflow:hidden}}:root{--background:oklch(14.5% 0 0);--foreground:oklch(98.5% 0 0);--card:oklch(20% .02 240);--card-foreground:oklch(98.5% 0 0);--popover:oklch(20% .02 240);--popover-foreground:oklch(98.5% 0 0);--primary:oklch(65% .15 180);--primary-foreground:oklch(20% 0 0);--secondary:oklch(27% 0 0);--secondary-foreground:oklch(98.5% 0 0);--muted:oklch(27% 0 0);--muted-foreground:oklch(65% 0 0);--accent:oklch(27% 0 0);--accent-foreground:oklch(98.5% 0 0);--destructive:oklch(55% .2 25);--destructive-foreground:oklch(98.5% 0 0);--border:oklch(35% 0 0);--input:oklch(35% 0 0);--ring:oklch(65% .15 180);--radius:.625rem}body{font-family:var(--font-sans);color:var(--foreground);background:#0a1628}@property --tw-translate-x{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-y{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-z{syntax:"*";inherits:false;initial-value:0}@property --tw-scale-x{syntax:"*";inherits:false;initial-value:1}@property --tw-scale-y{syntax:"*";inherits:false;initial-value:1}@property --tw-scale-z{syntax:"*";inherits:false;initial-value:1}@property --tw-rotate-x{syntax:"*";inherits:false}@property --tw-rotate-y{syntax:"*";inherits:false}@property --tw-rotate-z{syntax:"*";inherits:false}@property --tw-skew-x{syntax:"*";inherits:false}@property --tw-skew-y{syntax:"*";inherits:false}@property --tw-pan-x{syntax:"*";inherits:false}@property --tw-pan-y{syntax:"*";inherits:false}@property --tw-pinch-zoom{syntax:"*";inherits:false}@property --tw-space-y-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-space-x-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-divide-x-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-divide-y-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-gradient-position{syntax:"*";inherits:false}@property --tw-gradient-from{syntax:"";inherits:false;initial-value:#0000}@property --tw-gradient-via{syntax:"";inherits:false;initial-value:#0000}@property --tw-gradient-to{syntax:"";inherits:false;initial-value:#0000}@property --tw-gradient-stops{syntax:"*";inherits:false}@property --tw-gradient-via-stops{syntax:"*";inherits:false}@property --tw-gradient-from-position{syntax:"";inherits:false;initial-value:0%}@property --tw-gradient-via-position{syntax:"";inherits:false;initial-value:50%}@property --tw-gradient-to-position{syntax:"";inherits:false;initial-value:100%}@property --tw-leading{syntax:"*";inherits:false}@property --tw-font-weight{syntax:"*";inherits:false}@property --tw-tracking{syntax:"*";inherits:false}@property --tw-ordinal{syntax:"*";inherits:false}@property --tw-slashed-zero{syntax:"*";inherits:false}@property --tw-numeric-figure{syntax:"*";inherits:false}@property --tw-numeric-spacing{syntax:"*";inherits:false}@property --tw-numeric-fraction{syntax:"*";inherits:false}@property --tw-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:"*";inherits:false}@property --tw-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:"*";inherits:false}@property --tw-inset-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:"*";inherits:false}@property --tw-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:"*";inherits:false}@property --tw-inset-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:"*";inherits:false}@property --tw-ring-offset-width{syntax:"";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:"*";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-outline-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-blur{syntax:"*";inherits:false}@property --tw-brightness{syntax:"*";inherits:false}@property --tw-contrast{syntax:"*";inherits:false}@property --tw-grayscale{syntax:"*";inherits:false}@property --tw-hue-rotate{syntax:"*";inherits:false}@property --tw-invert{syntax:"*";inherits:false}@property --tw-opacity{syntax:"*";inherits:false}@property --tw-saturate{syntax:"*";inherits:false}@property --tw-sepia{syntax:"*";inherits:false}@property --tw-drop-shadow{syntax:"*";inherits:false}@property --tw-drop-shadow-color{syntax:"*";inherits:false}@property --tw-drop-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-drop-shadow-size{syntax:"*";inherits:false}@property --tw-backdrop-blur{syntax:"*";inherits:false}@property --tw-backdrop-brightness{syntax:"*";inherits:false}@property --tw-backdrop-contrast{syntax:"*";inherits:false}@property --tw-backdrop-grayscale{syntax:"*";inherits:false}@property --tw-backdrop-hue-rotate{syntax:"*";inherits:false}@property --tw-backdrop-invert{syntax:"*";inherits:false}@property --tw-backdrop-opacity{syntax:"*";inherits:false}@property --tw-backdrop-saturate{syntax:"*";inherits:false}@property --tw-backdrop-sepia{syntax:"*";inherits:false}@property --tw-duration{syntax:"*";inherits:false}@keyframes spin{to{transform:rotate(360deg)}} diff --git a/soul-admin/dist/assets/index-BlPUt9ll.css b/soul-admin/dist/assets/index-BlPUt9ll.css new file mode 100644 index 00000000..11fe830d --- /dev/null +++ b/soul-admin/dist/assets/index-BlPUt9ll.css @@ -0,0 +1 @@ +.rich-editor-wrapper{border:1px solid #374151;border-radius:.5rem;background:#0a1628;overflow:hidden}.rich-editor-toolbar{display:flex;align-items:center;gap:2px;padding:6px 8px;border-bottom:1px solid #374151;background:#0f1d32;flex-wrap:wrap}.toolbar-group{display:flex;align-items:center;gap:1px}.toolbar-divider{width:1px;height:20px;background:#374151;margin:0 4px}.rich-editor-toolbar button{display:flex;align-items:center;justify-content:center;width:28px;height:28px;border-radius:4px;border:none;background:transparent;color:#9ca3af;cursor:pointer;transition:all .15s}.rich-editor-toolbar button:hover{background:#1f2937;color:#d1d5db}.rich-editor-toolbar button.is-active{background:#38bdac33;color:#38bdac}.rich-editor-toolbar button:disabled{opacity:.3;cursor:not-allowed}.link-tag-select{background:#0a1628;border:1px solid #374151;color:#d1d5db;font-size:12px;padding:2px 6px;border-radius:4px;cursor:pointer;max-width:160px}.link-input-bar{display:flex;align-items:center;gap:4px;padding:4px 8px;border-bottom:1px solid #374151;background:#0f1d32}.link-input{flex:1;background:#0a1628;border:1px solid #374151;color:#fff;padding:4px 8px;border-radius:4px;font-size:13px}.link-confirm,.link-remove{padding:4px 10px;border-radius:4px;border:none;font-size:12px;cursor:pointer}.link-confirm{background:#38bdac;color:#fff}.link-remove{background:#374151;color:#9ca3af}.rich-editor-content{min-height:300px;max-height:500px;overflow-y:auto;padding:12px 16px;color:#e5e7eb;font-size:14px;line-height:1.7}.rich-editor-content:focus{outline:none}.rich-editor-content h1{font-size:1.5em;font-weight:700;margin:.8em 0 .4em;color:#fff}.rich-editor-content h2{font-size:1.3em;font-weight:600;margin:.7em 0 .3em;color:#fff}.rich-editor-content h3{font-size:1.15em;font-weight:600;margin:.6em 0 .3em;color:#fff}.rich-editor-content p{margin:.4em 0}.rich-editor-content strong{color:#fff}.rich-editor-content code{background:#1f2937;padding:2px 6px;border-radius:3px;font-size:.9em;color:#38bdac}.rich-editor-content pre{background:#1f2937;padding:12px;border-radius:6px;overflow-x:auto;margin:.6em 0}.rich-editor-content blockquote{border-left:3px solid #38bdac;padding-left:12px;margin:.6em 0;color:#9ca3af}.rich-editor-content ul,.rich-editor-content ol{padding-left:1.5em;margin:.4em 0}.rich-editor-content li{margin:.2em 0}.rich-editor-content hr{border:none;border-top:1px solid #374151;margin:1em 0}.rich-editor-content img{max-width:100%;border-radius:6px;margin:.5em 0}.rich-editor-content a,.rich-link{color:#38bdac;text-decoration:underline;cursor:pointer}.rich-editor-content table{border-collapse:collapse;width:100%;margin:.5em 0}.rich-editor-content th,.rich-editor-content td{border:1px solid #374151;padding:6px 10px;text-align:left}.rich-editor-content th{background:#1f2937;font-weight:600}.rich-editor-content .ProseMirror-placeholder:before{content:attr(data-placeholder);color:#6b7280;float:left;height:0;pointer-events:none}.mention-tag{background:#38bdac26;color:#38bdac;border-radius:4px;padding:1px 4px;font-weight:500}.link-tag-node{background:#ffd7001f;color:gold;border-radius:4px;padding:1px 4px;font-weight:500;cursor:default;-webkit-user-select:all;user-select:all}.mention-popup{position:fixed;z-index:9999;background:#1a2638;border:1px solid #374151;border-radius:8px;padding:4px;min-width:180px;max-height:240px;overflow-y:auto;box-shadow:0 4px 20px #0006}.mention-item{display:flex;align-items:center;justify-content:space-between;padding:6px 10px;border-radius:4px;cursor:pointer;color:#d1d5db;font-size:13px}.mention-item:hover,.mention-item.is-selected{background:#38bdac26;color:#38bdac}.mention-name{font-weight:500}.mention-id{font-size:11px;color:#6b7280}.bubble-menu{display:flex;gap:2px;background:#1a2638;border:1px solid #374151;border-radius:6px;padding:4px;box-shadow:0 4px 12px #0000004d}.bubble-menu button{display:flex;align-items:center;justify-content:center;width:26px;height:26px;border-radius:4px;border:none;background:transparent;color:#9ca3af;cursor:pointer}.bubble-menu button:hover{background:#1f2937;color:#d1d5db}.bubble-menu button.is-active{color:#38bdac}/*! tailwindcss v4.1.18 | MIT License | https://tailwindcss.com */@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-translate-x:0;--tw-translate-y:0;--tw-translate-z:0;--tw-scale-x:1;--tw-scale-y:1;--tw-scale-z:1;--tw-rotate-x:initial;--tw-rotate-y:initial;--tw-rotate-z:initial;--tw-skew-x:initial;--tw-skew-y:initial;--tw-pan-x:initial;--tw-pan-y:initial;--tw-pinch-zoom:initial;--tw-space-y-reverse:0;--tw-space-x-reverse:0;--tw-divide-x-reverse:0;--tw-border-style:solid;--tw-divide-y-reverse:0;--tw-gradient-position:initial;--tw-gradient-from:#0000;--tw-gradient-via:#0000;--tw-gradient-to:#0000;--tw-gradient-stops:initial;--tw-gradient-via-stops:initial;--tw-gradient-from-position:0%;--tw-gradient-via-position:50%;--tw-gradient-to-position:100%;--tw-leading:initial;--tw-font-weight:initial;--tw-tracking:initial;--tw-ordinal:initial;--tw-slashed-zero:initial;--tw-numeric-figure:initial;--tw-numeric-spacing:initial;--tw-numeric-fraction:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-outline-style:solid;--tw-blur:initial;--tw-brightness:initial;--tw-contrast:initial;--tw-grayscale:initial;--tw-hue-rotate:initial;--tw-invert:initial;--tw-opacity:initial;--tw-saturate:initial;--tw-sepia:initial;--tw-drop-shadow:initial;--tw-drop-shadow-color:initial;--tw-drop-shadow-alpha:100%;--tw-drop-shadow-size:initial;--tw-backdrop-blur:initial;--tw-backdrop-brightness:initial;--tw-backdrop-contrast:initial;--tw-backdrop-grayscale:initial;--tw-backdrop-hue-rotate:initial;--tw-backdrop-invert:initial;--tw-backdrop-opacity:initial;--tw-backdrop-saturate:initial;--tw-backdrop-sepia:initial;--tw-duration:initial}}}@layer theme{:root,:host{--font-sans:-apple-system,BlinkMacSystemFont,"Segoe UI","PingFang SC","Microsoft YaHei",sans-serif;--font-mono:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;--color-red-300:oklch(80.8% .114 19.571);--color-red-400:oklch(70.4% .191 22.216);--color-red-500:oklch(63.7% .237 25.331);--color-red-600:oklch(57.7% .245 27.325);--color-red-700:oklch(50.5% .213 27.518);--color-orange-300:oklch(83.7% .128 66.29);--color-orange-400:oklch(75% .183 55.934);--color-orange-500:oklch(70.5% .213 47.604);--color-orange-600:oklch(64.6% .222 41.116);--color-amber-200:oklch(92.4% .12 95.746);--color-amber-300:oklch(87.9% .169 91.605);--color-amber-400:oklch(82.8% .189 84.429);--color-amber-500:oklch(76.9% .188 70.08);--color-amber-600:oklch(66.6% .179 58.318);--color-yellow-400:oklch(85.2% .199 91.936);--color-yellow-500:oklch(79.5% .184 86.047);--color-green-300:oklch(87.1% .15 154.449);--color-green-400:oklch(79.2% .209 151.711);--color-green-500:oklch(72.3% .219 149.579);--color-green-600:oklch(62.7% .194 149.214);--color-green-700:oklch(52.7% .154 150.069);--color-emerald-400:oklch(76.5% .177 163.223);--color-emerald-500:oklch(69.6% .17 162.48);--color-cyan-400:oklch(78.9% .154 211.53);--color-cyan-500:oklch(71.5% .143 215.221);--color-sky-200:oklch(90.1% .058 230.902);--color-sky-300:oklch(82.8% .111 230.318);--color-blue-300:oklch(80.9% .105 251.813);--color-blue-400:oklch(70.7% .165 254.624);--color-blue-500:oklch(62.3% .214 259.815);--color-purple-400:oklch(71.4% .203 305.504);--color-purple-500:oklch(62.7% .265 303.9);--color-gray-200:oklch(92.8% .006 264.531);--color-gray-300:oklch(87.2% .01 258.338);--color-gray-400:oklch(70.7% .022 261.325);--color-gray-500:oklch(55.1% .027 264.364);--color-gray-600:oklch(44.6% .03 256.802);--color-gray-700:oklch(37.3% .034 259.733);--color-gray-800:oklch(27.8% .033 256.848);--color-black:#000;--color-white:#fff;--spacing:.25rem;--container-xs:20rem;--container-sm:24rem;--container-md:28rem;--container-lg:32rem;--container-2xl:42rem;--container-3xl:48rem;--container-4xl:56rem;--text-xs:.75rem;--text-xs--line-height:calc(1/.75);--text-sm:.875rem;--text-sm--line-height:calc(1.25/.875);--text-base:1rem;--text-base--line-height: 1.5 ;--text-lg:1.125rem;--text-lg--line-height:calc(1.75/1.125);--text-xl:1.25rem;--text-xl--line-height:calc(1.75/1.25);--text-2xl:1.5rem;--text-2xl--line-height:calc(2/1.5);--text-3xl:1.875rem;--text-3xl--line-height: 1.2 ;--text-4xl:2.25rem;--text-4xl--line-height:calc(2.5/2.25);--font-weight-normal:400;--font-weight-medium:500;--font-weight-semibold:600;--font-weight-bold:700;--tracking-tight:-.025em;--tracking-wider:.05em;--leading-tight:1.25;--leading-relaxed:1.625;--radius-sm:.25rem;--radius-md:.375rem;--radius-lg:.5rem;--radius-xl:.75rem;--radius-2xl:1rem;--animate-spin:spin 1s linear infinite;--blur-xl:24px;--blur-3xl:64px;--default-transition-duration:.15s;--default-transition-timing-function:cubic-bezier(.4,0,.2,1);--default-font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","PingFang SC","Microsoft YaHei",sans-serif;--default-mono-font-family:var(--font-mono)}}@layer base{*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;-moz-tab-size:4;tab-size:4;line-height:1.5;font-family:var(--default-font-family,ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-variation-settings:var(--default-mono-font-variation-settings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring{outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab,red,red)){::placeholder{color:color-mix(in oklab,currentcolor 50%,transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit{padding-block:0}::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-month-field{padding-block:0}::-webkit-datetime-edit-day-field{padding-block:0}::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field{padding-block:0}::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-datetime-edit-meridiem-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){-webkit-appearance:button;-moz-appearance:button;appearance:button}::file-selector-button{-webkit-appearance:button;-moz-appearance:button;appearance:button}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}}@layer components;@layer utilities{.pointer-events-none{pointer-events:none}.collapse{visibility:collapse}.invisible{visibility:hidden}.visible{visibility:visible}.sr-only{clip-path:inset(50%);white-space:nowrap;border-width:0;width:1px;height:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}.not-sr-only{clip-path:none;white-space:normal;width:auto;height:auto;margin:0;padding:0;position:static;overflow:visible}.absolute{position:absolute}.fixed{position:fixed}.relative{position:relative}.static{position:static}.sticky{position:sticky}.inset-0{inset:calc(var(--spacing)*0)}.-top-2\.5{top:calc(var(--spacing)*-2.5)}.top-0{top:calc(var(--spacing)*0)}.top-1\/2{top:50%}.top-1\/4{top:25%}.top-4{top:calc(var(--spacing)*4)}.top-16{top:calc(var(--spacing)*16)}.top-\[50\%\]{top:50%}.top-full{top:100%}.right-0{right:calc(var(--spacing)*0)}.right-1{right:calc(var(--spacing)*1)}.right-1\/4{right:25%}.right-4{right:calc(var(--spacing)*4)}.bottom-1\/4{bottom:25%}.-left-2\.5{left:calc(var(--spacing)*-2.5)}.left-0{left:calc(var(--spacing)*0)}.left-1\/4{left:25%}.left-2{left:calc(var(--spacing)*2)}.left-3{left:calc(var(--spacing)*3)}.left-\[50\%\]{left:50%}.isolate{isolation:isolate}.isolation-auto{isolation:auto}.z-10{z-index:10}.z-50{z-index:50}.col-span-2{grid-column:span 2/span 2}.container{width:100%}@media(min-width:40rem){.container{max-width:40rem}}@media(min-width:48rem){.container{max-width:48rem}}@media(min-width:64rem){.container{max-width:64rem}}@media(min-width:80rem){.container{max-width:80rem}}@media(min-width:96rem){.container{max-width:96rem}}.-mx-2{margin-inline:calc(var(--spacing)*-2)}.-mx-8{margin-inline:calc(var(--spacing)*-8)}.mx-20{margin-inline:calc(var(--spacing)*20)}.mx-auto{margin-inline:auto}.-mt-6{margin-top:calc(var(--spacing)*-6)}.mt-0{margin-top:calc(var(--spacing)*0)}.mt-0\.5{margin-top:calc(var(--spacing)*.5)}.mt-1{margin-top:calc(var(--spacing)*1)}.mt-1\.5{margin-top:calc(var(--spacing)*1.5)}.mt-2{margin-top:calc(var(--spacing)*2)}.mt-3{margin-top:calc(var(--spacing)*3)}.mt-4{margin-top:calc(var(--spacing)*4)}.mt-6{margin-top:calc(var(--spacing)*6)}.mr-1{margin-right:calc(var(--spacing)*1)}.mr-2{margin-right:calc(var(--spacing)*2)}.mr-3{margin-right:calc(var(--spacing)*3)}.mr-auto{margin-right:auto}.mb-1{margin-bottom:calc(var(--spacing)*1)}.mb-1\.5{margin-bottom:calc(var(--spacing)*1.5)}.mb-2{margin-bottom:calc(var(--spacing)*2)}.mb-3{margin-bottom:calc(var(--spacing)*3)}.mb-4{margin-bottom:calc(var(--spacing)*4)}.mb-5{margin-bottom:calc(var(--spacing)*5)}.mb-6{margin-bottom:calc(var(--spacing)*6)}.mb-8{margin-bottom:calc(var(--spacing)*8)}.ml-1{margin-left:calc(var(--spacing)*1)}.ml-2{margin-left:calc(var(--spacing)*2)}.ml-4{margin-left:calc(var(--spacing)*4)}.ml-6{margin-left:calc(var(--spacing)*6)}.ml-auto{margin-left:auto}.line-clamp-2{-webkit-line-clamp:2;-webkit-box-orient:vertical;display:-webkit-box;overflow:hidden}.line-clamp-3{-webkit-line-clamp:3;-webkit-box-orient:vertical;display:-webkit-box;overflow:hidden}.block{display:block}.contents{display:contents}.flex{display:flex}.flow-root{display:flow-root}.grid{display:grid}.hidden{display:none}.inline{display:inline}.inline\!{display:inline!important}.inline-block{display:inline-block}.inline-flex{display:inline-flex}.inline-grid{display:inline-grid}.inline-table{display:inline-table}.list-item{display:list-item}.table{display:table}.table\!{display:table!important}.table-caption{display:table-caption}.table-cell{display:table-cell}.table-column{display:table-column}.table-column-group{display:table-column-group}.table-footer-group{display:table-footer-group}.table-header-group{display:table-header-group}.table-row{display:table-row}.table-row-group{display:table-row-group}.size-4{width:calc(var(--spacing)*4);height:calc(var(--spacing)*4)}.size-8{width:calc(var(--spacing)*8);height:calc(var(--spacing)*8)}.size-9{width:calc(var(--spacing)*9);height:calc(var(--spacing)*9)}.size-10{width:calc(var(--spacing)*10);height:calc(var(--spacing)*10)}.h-0\.5{height:calc(var(--spacing)*.5)}.h-1\.5{height:calc(var(--spacing)*1.5)}.h-2{height:calc(var(--spacing)*2)}.h-3{height:calc(var(--spacing)*3)}.h-3\.5{height:calc(var(--spacing)*3.5)}.h-4{height:calc(var(--spacing)*4)}.h-5{height:calc(var(--spacing)*5)}.h-6{height:calc(var(--spacing)*6)}.h-7{height:calc(var(--spacing)*7)}.h-8{height:calc(var(--spacing)*8)}.h-9{height:calc(var(--spacing)*9)}.h-10{height:calc(var(--spacing)*10)}.h-12{height:calc(var(--spacing)*12)}.h-16{height:calc(var(--spacing)*16)}.h-20{height:calc(var(--spacing)*20)}.h-24{height:calc(var(--spacing)*24)}.h-96{height:calc(var(--spacing)*96)}.h-\[75vh\]{height:75vh}.h-auto{height:auto}.h-full{height:100%}.max-h-48{max-height:calc(var(--spacing)*48)}.max-h-96{max-height:calc(var(--spacing)*96)}.max-h-\[80vh\]{max-height:80vh}.max-h-\[85vh\]{max-height:85vh}.max-h-\[90vh\]{max-height:90vh}.max-h-\[250px\]{max-height:250px}.max-h-\[300px\]{max-height:300px}.max-h-\[400px\]{max-height:400px}.min-h-0{min-height:calc(var(--spacing)*0)}.min-h-\[2rem\]{min-height:2rem}.min-h-\[32px\]{min-height:32px}.min-h-\[40px\]{min-height:40px}.min-h-\[60vh\]{min-height:60vh}.min-h-\[72px\]{min-height:72px}.min-h-\[80px\]{min-height:80px}.min-h-\[100px\]{min-height:100px}.min-h-\[120px\]{min-height:120px}.min-h-\[260px\]{min-height:260px}.min-h-\[400px\]{min-height:400px}.min-h-full{min-height:100%}.min-h-screen{min-height:100vh}.w-0\.5{width:calc(var(--spacing)*.5)}.w-2{width:calc(var(--spacing)*2)}.w-3{width:calc(var(--spacing)*3)}.w-3\.5{width:calc(var(--spacing)*3.5)}.w-4{width:calc(var(--spacing)*4)}.w-5{width:calc(var(--spacing)*5)}.w-6{width:calc(var(--spacing)*6)}.w-7{width:calc(var(--spacing)*7)}.w-8{width:calc(var(--spacing)*8)}.w-9{width:calc(var(--spacing)*9)}.w-10{width:calc(var(--spacing)*10)}.w-12{width:calc(var(--spacing)*12)}.w-16{width:calc(var(--spacing)*16)}.w-20{width:calc(var(--spacing)*20)}.w-24{width:calc(var(--spacing)*24)}.w-28{width:calc(var(--spacing)*28)}.w-32{width:calc(var(--spacing)*32)}.w-36{width:calc(var(--spacing)*36)}.w-40{width:calc(var(--spacing)*40)}.w-44{width:calc(var(--spacing)*44)}.w-48{width:calc(var(--spacing)*48)}.w-52{width:calc(var(--spacing)*52)}.w-56{width:calc(var(--spacing)*56)}.w-64{width:calc(var(--spacing)*64)}.w-96{width:calc(var(--spacing)*96)}.w-\[280px\]{width:280px}.w-fit{width:fit-content}.w-full{width:100%}.max-w-2xl{max-width:var(--container-2xl)}.max-w-3xl{max-width:var(--container-3xl)}.max-w-4xl{max-width:var(--container-4xl)}.max-w-\[100px\]{max-width:100px}.max-w-\[120px\]{max-width:120px}.max-w-\[140px\]{max-width:140px}.max-w-\[180px\]{max-width:180px}.max-w-\[200px\]{max-width:200px}.max-w-\[250px\]{max-width:250px}.max-w-\[calc\(100\%-2rem\)\]{max-width:calc(100% - 2rem)}.max-w-lg{max-width:var(--container-lg)}.max-w-md{max-width:var(--container-md)}.max-w-sm{max-width:var(--container-sm)}.max-w-xs{max-width:var(--container-xs)}.min-w-0{min-width:calc(var(--spacing)*0)}.min-w-48{min-width:calc(var(--spacing)*48)}.min-w-\[8rem\]{min-width:8rem}.min-w-\[60px\]{min-width:60px}.min-w-\[120px\]{min-width:120px}.min-w-\[1024px\]{min-width:1024px}.flex-1{flex:1}.flex-shrink-0{flex-shrink:0}.shrink{flex-shrink:1}.shrink-0{flex-shrink:0}.grow{flex-grow:1}.caption-bottom{caption-side:bottom}.border-collapse{border-collapse:collapse}.-translate-x-1\/2{--tw-translate-x: -50% ;translate:var(--tw-translate-x)var(--tw-translate-y)}.translate-x-1\/2{--tw-translate-x: 50% ;translate:var(--tw-translate-x)var(--tw-translate-y)}.-translate-y-1\/2{--tw-translate-y: -50% ;translate:var(--tw-translate-x)var(--tw-translate-y)}.translate-none{translate:none}.scale-3d{scale:var(--tw-scale-x)var(--tw-scale-y)var(--tw-scale-z)}.scale-\[0\.98\]{scale:.98}.transform{transform:var(--tw-rotate-x,)var(--tw-rotate-y,)var(--tw-rotate-z,)var(--tw-skew-x,)var(--tw-skew-y,)}.animate-spin{animation:var(--animate-spin)}.cursor-default{cursor:default}.cursor-grab{cursor:grab}.cursor-pointer{cursor:pointer}.touch-pinch-zoom{--tw-pinch-zoom:pinch-zoom;touch-action:var(--tw-pan-x,)var(--tw-pan-y,)var(--tw-pinch-zoom,)}.touch-none{touch-action:none}.resize{resize:both}.resize-none{resize:none}.resize-y{resize:vertical}.list-inside{list-style-position:inside}.list-decimal{list-style-type:decimal}.list-disc{list-style-type:disc}.grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.grid-cols-\[40px_40px_1fr_80px_80px_80px_60px\]{grid-template-columns:40px 40px 1fr 80px 80px 80px 60px}.flex-col{flex-direction:column}.flex-col-reverse{flex-direction:column-reverse}.flex-row{flex-direction:row}.flex-wrap{flex-wrap:wrap}.items-center{align-items:center}.items-end{align-items:flex-end}.items-start{align-items:flex-start}.justify-between{justify-content:space-between}.justify-center{justify-content:center}.justify-end{justify-content:flex-end}.gap-0{gap:calc(var(--spacing)*0)}.gap-0\.5{gap:calc(var(--spacing)*.5)}.gap-1{gap:calc(var(--spacing)*1)}.gap-1\.5{gap:calc(var(--spacing)*1.5)}.gap-2{gap:calc(var(--spacing)*2)}.gap-3{gap:calc(var(--spacing)*3)}.gap-4{gap:calc(var(--spacing)*4)}.gap-5{gap:calc(var(--spacing)*5)}.gap-6{gap:calc(var(--spacing)*6)}.gap-8{gap:calc(var(--spacing)*8)}:where(.space-y-0>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*0)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*0)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-1>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*1)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*1)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-1\.5>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*1.5)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*1.5)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-2>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*2)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*2)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-3>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*3)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*3)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-4>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*4)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*4)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-6>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*6)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*6)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-8>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing)*8)*var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing)*8)*calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-reverse>:not(:last-child)){--tw-space-y-reverse:1}.gap-x-8{column-gap:calc(var(--spacing)*8)}:where(.space-x-reverse>:not(:last-child)){--tw-space-x-reverse:1}.gap-y-4{row-gap:calc(var(--spacing)*4)}:where(.divide-x>:not(:last-child)){--tw-divide-x-reverse:0;border-inline-style:var(--tw-border-style);border-inline-start-width:calc(1px*var(--tw-divide-x-reverse));border-inline-end-width:calc(1px*calc(1 - var(--tw-divide-x-reverse)))}:where(.divide-y>:not(:last-child)){--tw-divide-y-reverse:0;border-bottom-style:var(--tw-border-style);border-top-style:var(--tw-border-style);border-top-width:calc(1px*var(--tw-divide-y-reverse));border-bottom-width:calc(1px*calc(1 - var(--tw-divide-y-reverse)))}:where(.divide-y-reverse>:not(:last-child)){--tw-divide-y-reverse:1}:where(.divide-gray-700\/50>:not(:last-child)){border-color:#36415380}@supports (color:color-mix(in lab,red,red)){:where(.divide-gray-700\/50>:not(:last-child)){border-color:color-mix(in oklab,var(--color-gray-700)50%,transparent)}}:where(.divide-white\/5>:not(:last-child)){border-color:#ffffff0d}@supports (color:color-mix(in lab,red,red)){:where(.divide-white\/5>:not(:last-child)){border-color:color-mix(in oklab,var(--color-white)5%,transparent)}}.truncate{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.overflow-auto{overflow:auto}.overflow-hidden{overflow:hidden}.overflow-x-auto{overflow-x:auto}.overflow-y-auto{overflow-y:auto}.rounded{border-radius:.25rem}.rounded-2xl{border-radius:var(--radius-2xl)}.rounded-full{border-radius:3.40282e38px}.rounded-lg{border-radius:var(--radius-lg)}.rounded-md{border-radius:var(--radius-md)}.rounded-sm{border-radius:var(--radius-sm)}.rounded-xl{border-radius:var(--radius-xl)}.rounded-s{border-start-start-radius:.25rem;border-end-start-radius:.25rem}.rounded-ss{border-start-start-radius:.25rem}.rounded-e{border-start-end-radius:.25rem;border-end-end-radius:.25rem}.rounded-se{border-start-end-radius:.25rem}.rounded-ee{border-end-end-radius:.25rem}.rounded-es{border-end-start-radius:.25rem}.rounded-t{border-top-left-radius:.25rem;border-top-right-radius:.25rem}.rounded-l{border-top-left-radius:.25rem;border-bottom-left-radius:.25rem}.rounded-tl{border-top-left-radius:.25rem}.rounded-r{border-top-right-radius:.25rem;border-bottom-right-radius:.25rem}.rounded-r-md{border-top-right-radius:var(--radius-md);border-bottom-right-radius:var(--radius-md)}.rounded-tr{border-top-right-radius:.25rem}.rounded-b{border-bottom-right-radius:.25rem;border-bottom-left-radius:.25rem}.rounded-br{border-bottom-right-radius:.25rem}.rounded-bl{border-bottom-left-radius:.25rem}.border{border-style:var(--tw-border-style);border-width:1px}.border-0{border-style:var(--tw-border-style);border-width:0}.border-2{border-style:var(--tw-border-style);border-width:2px}.border-x{border-inline-style:var(--tw-border-style);border-inline-width:1px}.border-y{border-block-style:var(--tw-border-style);border-block-width:1px}.border-s{border-inline-start-style:var(--tw-border-style);border-inline-start-width:1px}.border-e{border-inline-end-style:var(--tw-border-style);border-inline-end-width:1px}.border-t{border-top-style:var(--tw-border-style);border-top-width:1px}.border-r{border-right-style:var(--tw-border-style);border-right-width:1px}.border-b{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}.border-l{border-left-style:var(--tw-border-style);border-left-width:1px}.border-\[\#07C160\]{border-color:#07c160}.border-\[\#07C160\]\/20{border-color:#07c16033}.border-\[\#07C160\]\/30{border-color:#07c1604d}.border-\[\#38bdac\]{border-color:#38bdac}.border-\[\#38bdac\]\/20{border-color:#38bdac33}.border-\[\#38bdac\]\/30{border-color:#38bdac4d}.border-\[\#38bdac\]\/40{border-color:#38bdac66}.border-\[\#38bdac\]\/50{border-color:#38bdac80}.border-amber-400\/60{border-color:#fcbb0099}@supports (color:color-mix(in lab,red,red)){.border-amber-400\/60{border-color:color-mix(in oklab,var(--color-amber-400)60%,transparent)}}.border-amber-500\/20{border-color:#f99c0033}@supports (color:color-mix(in lab,red,red)){.border-amber-500\/20{border-color:color-mix(in oklab,var(--color-amber-500)20%,transparent)}}.border-amber-500\/30{border-color:#f99c004d}@supports (color:color-mix(in lab,red,red)){.border-amber-500\/30{border-color:color-mix(in oklab,var(--color-amber-500)30%,transparent)}}.border-amber-500\/40{border-color:#f99c0066}@supports (color:color-mix(in lab,red,red)){.border-amber-500\/40{border-color:color-mix(in oklab,var(--color-amber-500)40%,transparent)}}.border-amber-500\/50{border-color:#f99c0080}@supports (color:color-mix(in lab,red,red)){.border-amber-500\/50{border-color:color-mix(in oklab,var(--color-amber-500)50%,transparent)}}.border-blue-500\/30{border-color:#3080ff4d}@supports (color:color-mix(in lab,red,red)){.border-blue-500\/30{border-color:color-mix(in oklab,var(--color-blue-500)30%,transparent)}}.border-blue-500\/40{border-color:#3080ff66}@supports (color:color-mix(in lab,red,red)){.border-blue-500\/40{border-color:color-mix(in oklab,var(--color-blue-500)40%,transparent)}}.border-blue-500\/50{border-color:#3080ff80}@supports (color:color-mix(in lab,red,red)){.border-blue-500\/50{border-color:color-mix(in oklab,var(--color-blue-500)50%,transparent)}}.border-cyan-500\/30{border-color:#00b7d74d}@supports (color:color-mix(in lab,red,red)){.border-cyan-500\/30{border-color:color-mix(in oklab,var(--color-cyan-500)30%,transparent)}}.border-cyan-500\/40{border-color:#00b7d766}@supports (color:color-mix(in lab,red,red)){.border-cyan-500\/40{border-color:color-mix(in oklab,var(--color-cyan-500)40%,transparent)}}.border-gray-500{border-color:var(--color-gray-500)}.border-gray-600{border-color:var(--color-gray-600)}.border-gray-700{border-color:var(--color-gray-700)}.border-gray-700\/30{border-color:#3641534d}@supports (color:color-mix(in lab,red,red)){.border-gray-700\/30{border-color:color-mix(in oklab,var(--color-gray-700)30%,transparent)}}.border-gray-700\/40{border-color:#36415366}@supports (color:color-mix(in lab,red,red)){.border-gray-700\/40{border-color:color-mix(in oklab,var(--color-gray-700)40%,transparent)}}.border-gray-700\/50{border-color:#36415380}@supports (color:color-mix(in lab,red,red)){.border-gray-700\/50{border-color:color-mix(in oklab,var(--color-gray-700)50%,transparent)}}.border-gray-700\/60{border-color:#36415399}@supports (color:color-mix(in lab,red,red)){.border-gray-700\/60{border-color:color-mix(in oklab,var(--color-gray-700)60%,transparent)}}.border-green-500\/30{border-color:#00c7584d}@supports (color:color-mix(in lab,red,red)){.border-green-500\/30{border-color:color-mix(in oklab,var(--color-green-500)30%,transparent)}}.border-green-500\/40{border-color:#00c75866}@supports (color:color-mix(in lab,red,red)){.border-green-500\/40{border-color:color-mix(in oklab,var(--color-green-500)40%,transparent)}}.border-inherit{border-color:inherit}.border-orange-500\/20{border-color:#fe6e0033}@supports (color:color-mix(in lab,red,red)){.border-orange-500\/20{border-color:color-mix(in oklab,var(--color-orange-500)20%,transparent)}}.border-orange-500\/30{border-color:#fe6e004d}@supports (color:color-mix(in lab,red,red)){.border-orange-500\/30{border-color:color-mix(in oklab,var(--color-orange-500)30%,transparent)}}.border-orange-500\/40{border-color:#fe6e0066}@supports (color:color-mix(in lab,red,red)){.border-orange-500\/40{border-color:color-mix(in oklab,var(--color-orange-500)40%,transparent)}}.border-orange-500\/50{border-color:#fe6e0080}@supports (color:color-mix(in lab,red,red)){.border-orange-500\/50{border-color:color-mix(in oklab,var(--color-orange-500)50%,transparent)}}.border-purple-500\/20{border-color:#ac4bff33}@supports (color:color-mix(in lab,red,red)){.border-purple-500\/20{border-color:color-mix(in oklab,var(--color-purple-500)20%,transparent)}}.border-purple-500\/30{border-color:#ac4bff4d}@supports (color:color-mix(in lab,red,red)){.border-purple-500\/30{border-color:color-mix(in oklab,var(--color-purple-500)30%,transparent)}}.border-purple-500\/40{border-color:#ac4bff66}@supports (color:color-mix(in lab,red,red)){.border-purple-500\/40{border-color:color-mix(in oklab,var(--color-purple-500)40%,transparent)}}.border-red-500{border-color:var(--color-red-500)}.border-red-500\/20{border-color:#fb2c3633}@supports (color:color-mix(in lab,red,red)){.border-red-500\/20{border-color:color-mix(in oklab,var(--color-red-500)20%,transparent)}}.border-red-500\/30{border-color:#fb2c364d}@supports (color:color-mix(in lab,red,red)){.border-red-500\/30{border-color:color-mix(in oklab,var(--color-red-500)30%,transparent)}}.border-red-500\/50{border-color:#fb2c3680}@supports (color:color-mix(in lab,red,red)){.border-red-500\/50{border-color:color-mix(in oklab,var(--color-red-500)50%,transparent)}}.border-transparent{border-color:#0000}.border-white\/5{border-color:#ffffff0d}@supports (color:color-mix(in lab,red,red)){.border-white\/5{border-color:color-mix(in oklab,var(--color-white)5%,transparent)}}.border-white\/10{border-color:#ffffff1a}@supports (color:color-mix(in lab,red,red)){.border-white\/10{border-color:color-mix(in oklab,var(--color-white)10%,transparent)}}.border-white\/20{border-color:#fff3}@supports (color:color-mix(in lab,red,red)){.border-white\/20{border-color:color-mix(in oklab,var(--color-white)20%,transparent)}}.border-yellow-500\/30{border-color:#edb2004d}@supports (color:color-mix(in lab,red,red)){.border-yellow-500\/30{border-color:color-mix(in oklab,var(--color-yellow-500)30%,transparent)}}.border-yellow-500\/40{border-color:#edb20066}@supports (color:color-mix(in lab,red,red)){.border-yellow-500\/40{border-color:color-mix(in oklab,var(--color-yellow-500)40%,transparent)}}.bg-\[\#0a1628\]{background-color:#0a1628}.bg-\[\#0a1628\]\/50{background-color:#0a162880}.bg-\[\#0b1828\]{background-color:#0b1828}.bg-\[\#0f2137\]{background-color:#0f2137}.bg-\[\#00CED1\]{background-color:#00ced1}.bg-\[\#1C1C1E\]{background-color:#1c1c1e}.bg-\[\#07C160\]{background-color:#07c160}.bg-\[\#07C160\]\/5{background-color:#07c1600d}.bg-\[\#07C160\]\/10{background-color:#07c1601a}.bg-\[\#38bdac\]{background-color:#38bdac}.bg-\[\#38bdac\]\/5{background-color:#38bdac0d}.bg-\[\#38bdac\]\/10{background-color:#38bdac1a}.bg-\[\#38bdac\]\/15{background-color:#38bdac26}.bg-\[\#38bdac\]\/20{background-color:#38bdac33}.bg-\[\#38bdac\]\/30{background-color:#38bdac4d}.bg-\[\#38bdac\]\/60{background-color:#38bdac99}.bg-\[\#38bdac\]\/80{background-color:#38bdaccc}.bg-\[\#050c18\]{background-color:#050c18}.bg-\[\#162840\]{background-color:#162840}.bg-amber-500{background-color:var(--color-amber-500)}.bg-amber-500\/5{background-color:#f99c000d}@supports (color:color-mix(in lab,red,red)){.bg-amber-500\/5{background-color:color-mix(in oklab,var(--color-amber-500)5%,transparent)}}.bg-amber-500\/10{background-color:#f99c001a}@supports (color:color-mix(in lab,red,red)){.bg-amber-500\/10{background-color:color-mix(in oklab,var(--color-amber-500)10%,transparent)}}.bg-amber-500\/20{background-color:#f99c0033}@supports (color:color-mix(in lab,red,red)){.bg-amber-500\/20{background-color:color-mix(in oklab,var(--color-amber-500)20%,transparent)}}.bg-black{background-color:var(--color-black)}.bg-black\/40{background-color:#0006}@supports (color:color-mix(in lab,red,red)){.bg-black\/40{background-color:color-mix(in oklab,var(--color-black)40%,transparent)}}.bg-black\/50{background-color:#00000080}@supports (color:color-mix(in lab,red,red)){.bg-black\/50{background-color:color-mix(in oklab,var(--color-black)50%,transparent)}}.bg-black\/60{background-color:#0009}@supports (color:color-mix(in lab,red,red)){.bg-black\/60{background-color:color-mix(in oklab,var(--color-black)60%,transparent)}}.bg-black\/90{background-color:#000000e6}@supports (color:color-mix(in lab,red,red)){.bg-black\/90{background-color:color-mix(in oklab,var(--color-black)90%,transparent)}}.bg-blue-500\/5{background-color:#3080ff0d}@supports (color:color-mix(in lab,red,red)){.bg-blue-500\/5{background-color:color-mix(in oklab,var(--color-blue-500)5%,transparent)}}.bg-blue-500\/10{background-color:#3080ff1a}@supports (color:color-mix(in lab,red,red)){.bg-blue-500\/10{background-color:color-mix(in oklab,var(--color-blue-500)10%,transparent)}}.bg-blue-500\/20{background-color:#3080ff33}@supports (color:color-mix(in lab,red,red)){.bg-blue-500\/20{background-color:color-mix(in oklab,var(--color-blue-500)20%,transparent)}}.bg-cyan-500{background-color:var(--color-cyan-500)}.bg-cyan-500\/20{background-color:#00b7d733}@supports (color:color-mix(in lab,red,red)){.bg-cyan-500\/20{background-color:color-mix(in oklab,var(--color-cyan-500)20%,transparent)}}.bg-emerald-500\/20{background-color:#00bb7f33}@supports (color:color-mix(in lab,red,red)){.bg-emerald-500\/20{background-color:color-mix(in oklab,var(--color-emerald-500)20%,transparent)}}.bg-gray-500{background-color:var(--color-gray-500)}.bg-gray-500\/20{background-color:#6a728233}@supports (color:color-mix(in lab,red,red)){.bg-gray-500\/20{background-color:color-mix(in oklab,var(--color-gray-500)20%,transparent)}}.bg-gray-600{background-color:var(--color-gray-600)}.bg-gray-600\/20{background-color:#4a556533}@supports (color:color-mix(in lab,red,red)){.bg-gray-600\/20{background-color:color-mix(in oklab,var(--color-gray-600)20%,transparent)}}.bg-gray-600\/50{background-color:#4a556580}@supports (color:color-mix(in lab,red,red)){.bg-gray-600\/50{background-color:color-mix(in oklab,var(--color-gray-600)50%,transparent)}}.bg-gray-700{background-color:var(--color-gray-700)}.bg-gray-700\/50{background-color:#36415380}@supports (color:color-mix(in lab,red,red)){.bg-gray-700\/50{background-color:color-mix(in oklab,var(--color-gray-700)50%,transparent)}}.bg-green-500{background-color:var(--color-green-500)}.bg-green-500\/20{background-color:#00c75833}@supports (color:color-mix(in lab,red,red)){.bg-green-500\/20{background-color:color-mix(in oklab,var(--color-green-500)20%,transparent)}}.bg-green-600{background-color:var(--color-green-600)}.bg-orange-500{background-color:var(--color-orange-500)}.bg-orange-500\/10{background-color:#fe6e001a}@supports (color:color-mix(in lab,red,red)){.bg-orange-500\/10{background-color:color-mix(in oklab,var(--color-orange-500)10%,transparent)}}.bg-orange-500\/20{background-color:#fe6e0033}@supports (color:color-mix(in lab,red,red)){.bg-orange-500\/20{background-color:color-mix(in oklab,var(--color-orange-500)20%,transparent)}}.bg-purple-500\/20{background-color:#ac4bff33}@supports (color:color-mix(in lab,red,red)){.bg-purple-500\/20{background-color:color-mix(in oklab,var(--color-purple-500)20%,transparent)}}.bg-red-500\/10{background-color:#fb2c361a}@supports (color:color-mix(in lab,red,red)){.bg-red-500\/10{background-color:color-mix(in oklab,var(--color-red-500)10%,transparent)}}.bg-red-500\/20{background-color:#fb2c3633}@supports (color:color-mix(in lab,red,red)){.bg-red-500\/20{background-color:color-mix(in oklab,var(--color-red-500)20%,transparent)}}.bg-red-600{background-color:var(--color-red-600)}.bg-transparent{background-color:#0000}.bg-white{background-color:var(--color-white)}.bg-white\/5{background-color:#ffffff0d}@supports (color:color-mix(in lab,red,red)){.bg-white\/5{background-color:color-mix(in oklab,var(--color-white)5%,transparent)}}.bg-white\/10{background-color:#ffffff1a}@supports (color:color-mix(in lab,red,red)){.bg-white\/10{background-color:color-mix(in oklab,var(--color-white)10%,transparent)}}.bg-white\/20{background-color:#fff3}@supports (color:color-mix(in lab,red,red)){.bg-white\/20{background-color:color-mix(in oklab,var(--color-white)20%,transparent)}}.bg-yellow-500\/20{background-color:#edb20033}@supports (color:color-mix(in lab,red,red)){.bg-yellow-500\/20{background-color:color-mix(in oklab,var(--color-yellow-500)20%,transparent)}}.bg-gradient-to-br{--tw-gradient-position:to bottom right in oklab;background-image:linear-gradient(var(--tw-gradient-stops))}.bg-gradient-to-r{--tw-gradient-position:to right in oklab;background-image:linear-gradient(var(--tw-gradient-stops))}.from-\[\#0f2137\]{--tw-gradient-from:#0f2137;--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.from-\[\#00CED1\]{--tw-gradient-from:#00ced1;--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.from-\[\#38bdac\]\/10{--tw-gradient-from:oklab(72.378% -.11483 -.0053193/.1);--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.from-blue-500\/20{--tw-gradient-from:#3080ff33}@supports (color:color-mix(in lab,red,red)){.from-blue-500\/20{--tw-gradient-from:color-mix(in oklab,var(--color-blue-500)20%,transparent)}}.from-blue-500\/20{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.from-cyan-500\/20{--tw-gradient-from:#00b7d733}@supports (color:color-mix(in lab,red,red)){.from-cyan-500\/20{--tw-gradient-from:color-mix(in oklab,var(--color-cyan-500)20%,transparent)}}.from-cyan-500\/20{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.from-green-500\/20{--tw-gradient-from:#00c75833}@supports (color:color-mix(in lab,red,red)){.from-green-500\/20{--tw-gradient-from:color-mix(in oklab,var(--color-green-500)20%,transparent)}}.from-green-500\/20{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.from-purple-500\/20{--tw-gradient-from:#ac4bff33}@supports (color:color-mix(in lab,red,red)){.from-purple-500\/20{--tw-gradient-from:color-mix(in oklab,var(--color-purple-500)20%,transparent)}}.from-purple-500\/20{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.from-yellow-500\/20{--tw-gradient-from:#edb20033}@supports (color:color-mix(in lab,red,red)){.from-yellow-500\/20{--tw-gradient-from:color-mix(in oklab,var(--color-yellow-500)20%,transparent)}}.from-yellow-500\/20{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.via-\[\#38bdac\]\/30{--tw-gradient-via:oklab(72.378% -.11483 -.0053193/.3);--tw-gradient-via-stops:var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-via)var(--tw-gradient-via-position),var(--tw-gradient-to)var(--tw-gradient-to-position);--tw-gradient-stops:var(--tw-gradient-via-stops)}.to-\[\#0f2137\]{--tw-gradient-to:#0f2137;--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.to-\[\#20B2AA\]{--tw-gradient-to:#20b2aa;--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.to-\[\#162d4a\]{--tw-gradient-to:#162d4a;--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.to-amber-500\/20{--tw-gradient-to:#f99c0033}@supports (color:color-mix(in lab,red,red)){.to-amber-500\/20{--tw-gradient-to:color-mix(in oklab,var(--color-amber-500)20%,transparent)}}.to-amber-500\/20{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.to-cyan-500\/5{--tw-gradient-to:#00b7d70d}@supports (color:color-mix(in lab,red,red)){.to-cyan-500\/5{--tw-gradient-to:color-mix(in oklab,var(--color-cyan-500)5%,transparent)}}.to-cyan-500\/5{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.to-green-500\/5{--tw-gradient-to:#00c7580d}@supports (color:color-mix(in lab,red,red)){.to-green-500\/5{--tw-gradient-to:color-mix(in oklab,var(--color-green-500)5%,transparent)}}.to-green-500\/5{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.to-purple-500\/5{--tw-gradient-to:#ac4bff0d}@supports (color:color-mix(in lab,red,red)){.to-purple-500\/5{--tw-gradient-to:color-mix(in oklab,var(--color-purple-500)5%,transparent)}}.to-purple-500\/5{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.to-yellow-500\/5{--tw-gradient-to:#edb2000d}@supports (color:color-mix(in lab,red,red)){.to-yellow-500\/5{--tw-gradient-to:color-mix(in oklab,var(--color-yellow-500)5%,transparent)}}.to-yellow-500\/5{--tw-gradient-stops:var(--tw-gradient-via-stops,var(--tw-gradient-position),var(--tw-gradient-from)var(--tw-gradient-from-position),var(--tw-gradient-to)var(--tw-gradient-to-position))}.bg-repeat{background-repeat:repeat}.mask-no-clip{-webkit-mask-clip:no-clip;mask-clip:no-clip}.mask-repeat{-webkit-mask-repeat:repeat;mask-repeat:repeat}.fill-amber-400{fill:var(--color-amber-400)}.fill-current{fill:currentColor}.object-cover{object-fit:cover}.p-0{padding:calc(var(--spacing)*0)}.p-1{padding:calc(var(--spacing)*1)}.p-2{padding:calc(var(--spacing)*2)}.p-2\.5{padding:calc(var(--spacing)*2.5)}.p-3{padding:calc(var(--spacing)*3)}.p-4{padding:calc(var(--spacing)*4)}.p-5{padding:calc(var(--spacing)*5)}.p-6{padding:calc(var(--spacing)*6)}.p-8{padding:calc(var(--spacing)*8)}.px-0{padding-inline:calc(var(--spacing)*0)}.px-1{padding-inline:calc(var(--spacing)*1)}.px-1\.5{padding-inline:calc(var(--spacing)*1.5)}.px-2{padding-inline:calc(var(--spacing)*2)}.px-3{padding-inline:calc(var(--spacing)*3)}.px-4{padding-inline:calc(var(--spacing)*4)}.px-5{padding-inline:calc(var(--spacing)*5)}.px-6{padding-inline:calc(var(--spacing)*6)}.py-0\.5{padding-block:calc(var(--spacing)*.5)}.py-1{padding-block:calc(var(--spacing)*1)}.py-1\.5{padding-block:calc(var(--spacing)*1.5)}.py-2{padding-block:calc(var(--spacing)*2)}.py-2\.5{padding-block:calc(var(--spacing)*2.5)}.py-3{padding-block:calc(var(--spacing)*3)}.py-4{padding-block:calc(var(--spacing)*4)}.py-5{padding-block:calc(var(--spacing)*5)}.py-6{padding-block:calc(var(--spacing)*6)}.py-8{padding-block:calc(var(--spacing)*8)}.py-10{padding-block:calc(var(--spacing)*10)}.py-12{padding-block:calc(var(--spacing)*12)}.py-16{padding-block:calc(var(--spacing)*16)}.py-20{padding-block:calc(var(--spacing)*20)}.pt-0{padding-top:calc(var(--spacing)*0)}.pt-1{padding-top:calc(var(--spacing)*1)}.pt-2{padding-top:calc(var(--spacing)*2)}.pt-3{padding-top:calc(var(--spacing)*3)}.pt-4{padding-top:calc(var(--spacing)*4)}.pt-5{padding-top:calc(var(--spacing)*5)}.pt-6{padding-top:calc(var(--spacing)*6)}.pr-1{padding-right:calc(var(--spacing)*1)}.pr-2{padding-right:calc(var(--spacing)*2)}.pr-4{padding-right:calc(var(--spacing)*4)}.pb-1{padding-bottom:calc(var(--spacing)*1)}.pb-2{padding-bottom:calc(var(--spacing)*2)}.pb-3{padding-bottom:calc(var(--spacing)*3)}.pb-4{padding-bottom:calc(var(--spacing)*4)}.pl-2{padding-left:calc(var(--spacing)*2)}.pl-4{padding-left:calc(var(--spacing)*4)}.pl-8{padding-left:calc(var(--spacing)*8)}.pl-10{padding-left:calc(var(--spacing)*10)}.text-center{text-align:center}.text-left{text-align:left}.text-right{text-align:right}.align-middle{vertical-align:middle}.font-mono{font-family:var(--font-mono)}.text-2xl{font-size:var(--text-2xl);line-height:var(--tw-leading,var(--text-2xl--line-height))}.text-3xl{font-size:var(--text-3xl);line-height:var(--tw-leading,var(--text-3xl--line-height))}.text-4xl{font-size:var(--text-4xl);line-height:var(--tw-leading,var(--text-4xl--line-height))}.text-base{font-size:var(--text-base);line-height:var(--tw-leading,var(--text-base--line-height))}.text-lg{font-size:var(--text-lg);line-height:var(--tw-leading,var(--text-lg--line-height))}.text-sm{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.text-xl{font-size:var(--text-xl);line-height:var(--tw-leading,var(--text-xl--line-height))}.text-xs{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}.text-\[10px\]{font-size:10px}.text-\[11px\]{font-size:11px}.leading-6{--tw-leading:calc(var(--spacing)*6);line-height:calc(var(--spacing)*6)}.leading-none{--tw-leading:1;line-height:1}.leading-relaxed{--tw-leading:var(--leading-relaxed);line-height:var(--leading-relaxed)}.leading-tight{--tw-leading:var(--leading-tight);line-height:var(--leading-tight)}.font-bold{--tw-font-weight:var(--font-weight-bold);font-weight:var(--font-weight-bold)}.font-medium{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.font-normal{--tw-font-weight:var(--font-weight-normal);font-weight:var(--font-weight-normal)}.font-semibold{--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.tracking-tight{--tw-tracking:var(--tracking-tight);letter-spacing:var(--tracking-tight)}.tracking-wider{--tw-tracking:var(--tracking-wider);letter-spacing:var(--tracking-wider)}.text-wrap{text-wrap:wrap}.break-all{word-break:break-all}.text-clip{text-overflow:clip}.text-ellipsis{text-overflow:ellipsis}.whitespace-nowrap{white-space:nowrap}.whitespace-pre-wrap{white-space:pre-wrap}.text-\[\#00CED1\]{color:#00ced1}.text-\[\#07C160\]{color:#07c160}.text-\[\#07C160\]\/60{color:#07c16099}.text-\[\#07C160\]\/70{color:#07c160b3}.text-\[\#07C160\]\/80{color:#07c160cc}.text-\[\#26A17B\]{color:#26a17b}.text-\[\#38bdac\]{color:#38bdac}.text-\[\#38bdac\]\/30{color:#38bdac4d}.text-\[\#38bdac\]\/40{color:#38bdac66}.text-\[\#169BD7\]{color:#169bd7}.text-\[\#1677FF\]{color:#1677ff}.text-\[\#FFD700\]{color:gold}.text-amber-200{color:var(--color-amber-200)}.text-amber-300{color:var(--color-amber-300)}.text-amber-400{color:var(--color-amber-400)}.text-amber-400\/30{color:#fcbb004d}@supports (color:color-mix(in lab,red,red)){.text-amber-400\/30{color:color-mix(in oklab,var(--color-amber-400)30%,transparent)}}.text-amber-400\/90{color:#fcbb00e6}@supports (color:color-mix(in lab,red,red)){.text-amber-400\/90{color:color-mix(in oklab,var(--color-amber-400)90%,transparent)}}.text-black{color:var(--color-black)}.text-blue-300{color:var(--color-blue-300)}.text-blue-300\/60{color:#90c5ff99}@supports (color:color-mix(in lab,red,red)){.text-blue-300\/60{color:color-mix(in oklab,var(--color-blue-300)60%,transparent)}}.text-blue-400{color:var(--color-blue-400)}.text-blue-400\/60{color:#54a2ff99}@supports (color:color-mix(in lab,red,red)){.text-blue-400\/60{color:color-mix(in oklab,var(--color-blue-400)60%,transparent)}}.text-cyan-400{color:var(--color-cyan-400)}.text-emerald-400{color:var(--color-emerald-400)}.text-gray-200{color:var(--color-gray-200)}.text-gray-300{color:var(--color-gray-300)}.text-gray-400{color:var(--color-gray-400)}.text-gray-500{color:var(--color-gray-500)}.text-gray-600{color:var(--color-gray-600)}.text-gray-700{color:var(--color-gray-700)}.text-green-300{color:var(--color-green-300)}.text-green-400{color:var(--color-green-400)}.text-green-500{color:var(--color-green-500)}.text-orange-300{color:var(--color-orange-300)}.text-orange-300\/60{color:#ffb96d99}@supports (color:color-mix(in lab,red,red)){.text-orange-300\/60{color:color-mix(in oklab,var(--color-orange-300)60%,transparent)}}.text-orange-400{color:var(--color-orange-400)}.text-orange-400\/60{color:#ff8b1a99}@supports (color:color-mix(in lab,red,red)){.text-orange-400\/60{color:color-mix(in oklab,var(--color-orange-400)60%,transparent)}}.text-orange-400\/70{color:#ff8b1ab3}@supports (color:color-mix(in lab,red,red)){.text-orange-400\/70{color:color-mix(in oklab,var(--color-orange-400)70%,transparent)}}.text-orange-400\/80{color:#ff8b1acc}@supports (color:color-mix(in lab,red,red)){.text-orange-400\/80{color:color-mix(in oklab,var(--color-orange-400)80%,transparent)}}.text-purple-400{color:var(--color-purple-400)}.text-red-400{color:var(--color-red-400)}.text-sky-300{color:var(--color-sky-300)}.text-white{color:var(--color-white)}.text-white\/40{color:#fff6}@supports (color:color-mix(in lab,red,red)){.text-white\/40{color:color-mix(in oklab,var(--color-white)40%,transparent)}}.text-white\/60{color:#fff9}@supports (color:color-mix(in lab,red,red)){.text-white\/60{color:color-mix(in oklab,var(--color-white)60%,transparent)}}.text-white\/70{color:#ffffffb3}@supports (color:color-mix(in lab,red,red)){.text-white\/70{color:color-mix(in oklab,var(--color-white)70%,transparent)}}.text-white\/80{color:#fffc}@supports (color:color-mix(in lab,red,red)){.text-white\/80{color:color-mix(in oklab,var(--color-white)80%,transparent)}}.text-yellow-400{color:var(--color-yellow-400)}.text-yellow-400\/60{color:#fac80099}@supports (color:color-mix(in lab,red,red)){.text-yellow-400\/60{color:color-mix(in oklab,var(--color-yellow-400)60%,transparent)}}.text-yellow-500\/70{color:#edb200b3}@supports (color:color-mix(in lab,red,red)){.text-yellow-500\/70{color:color-mix(in oklab,var(--color-yellow-500)70%,transparent)}}.capitalize{text-transform:capitalize}.lowercase{text-transform:lowercase}.normal-case{text-transform:none}.uppercase{text-transform:uppercase}.italic{font-style:italic}.italic\!{font-style:italic!important}.not-italic{font-style:normal}.diagonal-fractions{--tw-numeric-fraction:diagonal-fractions;font-variant-numeric:var(--tw-ordinal,)var(--tw-slashed-zero,)var(--tw-numeric-figure,)var(--tw-numeric-spacing,)var(--tw-numeric-fraction,)}.lining-nums{--tw-numeric-figure:lining-nums;font-variant-numeric:var(--tw-ordinal,)var(--tw-slashed-zero,)var(--tw-numeric-figure,)var(--tw-numeric-spacing,)var(--tw-numeric-fraction,)}.oldstyle-nums{--tw-numeric-figure:oldstyle-nums;font-variant-numeric:var(--tw-ordinal,)var(--tw-slashed-zero,)var(--tw-numeric-figure,)var(--tw-numeric-spacing,)var(--tw-numeric-fraction,)}.ordinal{--tw-ordinal:ordinal;font-variant-numeric:var(--tw-ordinal,)var(--tw-slashed-zero,)var(--tw-numeric-figure,)var(--tw-numeric-spacing,)var(--tw-numeric-fraction,)}.proportional-nums{--tw-numeric-spacing:proportional-nums;font-variant-numeric:var(--tw-ordinal,)var(--tw-slashed-zero,)var(--tw-numeric-figure,)var(--tw-numeric-spacing,)var(--tw-numeric-fraction,)}.slashed-zero{--tw-slashed-zero:slashed-zero;font-variant-numeric:var(--tw-ordinal,)var(--tw-slashed-zero,)var(--tw-numeric-figure,)var(--tw-numeric-spacing,)var(--tw-numeric-fraction,)}.stacked-fractions{--tw-numeric-fraction:stacked-fractions;font-variant-numeric:var(--tw-ordinal,)var(--tw-slashed-zero,)var(--tw-numeric-figure,)var(--tw-numeric-spacing,)var(--tw-numeric-fraction,)}.tabular-nums{--tw-numeric-spacing:tabular-nums;font-variant-numeric:var(--tw-ordinal,)var(--tw-slashed-zero,)var(--tw-numeric-figure,)var(--tw-numeric-spacing,)var(--tw-numeric-fraction,)}.normal-nums{font-variant-numeric:normal}.line-through{text-decoration-line:line-through}.no-underline{text-decoration-line:none}.overline{text-decoration-line:overline}.underline{text-decoration-line:underline}.underline\!{text-decoration-line:underline!important}.underline-offset-4{text-underline-offset:4px}.antialiased{-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.subpixel-antialiased{-webkit-font-smoothing:auto;-moz-osx-font-smoothing:auto}.accent-\[\#38bdac\]{accent-color:#38bdac}.opacity-0{opacity:0}.opacity-50{opacity:.5}.opacity-55{opacity:.55}.opacity-60{opacity:.6}.opacity-70{opacity:.7}.shadow{--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a),0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-lg{--tw-shadow:0 10px 15px -3px var(--tw-shadow-color,#0000001a),0 4px 6px -4px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-md{--tw-shadow:0 4px 6px -1px var(--tw-shadow-color,#0000001a),0 2px 4px -2px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-sm{--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a),0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-xl{--tw-shadow:0 20px 25px -5px var(--tw-shadow-color,#0000001a),0 8px 10px -6px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-xs{--tw-shadow:0 1px 2px 0 var(--tw-shadow-color,#0000000d);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.ring-0{--tw-ring-shadow:var(--tw-ring-inset,)0 0 0 calc(0px + var(--tw-ring-offset-width))var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.ring-1{--tw-ring-shadow:var(--tw-ring-inset,)0 0 0 calc(1px + var(--tw-ring-offset-width))var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.ring-2{--tw-ring-shadow:var(--tw-ring-inset,)0 0 0 calc(2px + var(--tw-ring-offset-width))var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.inset-ring{--tw-inset-ring-shadow:inset 0 0 0 1px var(--tw-inset-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-\[\#38bdac\]\/20{--tw-shadow-color:#38bdac33}@supports (color:color-mix(in lab,red,red)){.shadow-\[\#38bdac\]\/20{--tw-shadow-color:color-mix(in oklab,oklab(72.378% -.11483 -.0053193/.2) var(--tw-shadow-alpha),transparent)}}.shadow-\[\#38bdac\]\/30{--tw-shadow-color:#38bdac4d}@supports (color:color-mix(in lab,red,red)){.shadow-\[\#38bdac\]\/30{--tw-shadow-color:color-mix(in oklab,oklab(72.378% -.11483 -.0053193/.3) var(--tw-shadow-alpha),transparent)}}.ring-\[\#38bdac\]{--tw-ring-color:#38bdac}.ring-\[\#38bdac\]\/40{--tw-ring-color:oklab(72.378% -.11483 -.0053193/.4)}.ring-\[\#38bdac\]\/50{--tw-ring-color:oklab(72.378% -.11483 -.0053193/.5)}.outline{outline-style:var(--tw-outline-style);outline-width:1px}.blur{--tw-blur:blur(8px);filter:var(--tw-blur,)var(--tw-brightness,)var(--tw-contrast,)var(--tw-grayscale,)var(--tw-hue-rotate,)var(--tw-invert,)var(--tw-saturate,)var(--tw-sepia,)var(--tw-drop-shadow,)}.blur-3xl{--tw-blur:blur(var(--blur-3xl));filter:var(--tw-blur,)var(--tw-brightness,)var(--tw-contrast,)var(--tw-grayscale,)var(--tw-hue-rotate,)var(--tw-invert,)var(--tw-saturate,)var(--tw-sepia,)var(--tw-drop-shadow,)}.drop-shadow{--tw-drop-shadow-size:drop-shadow(0 1px 2px var(--tw-drop-shadow-color,#0000001a))drop-shadow(0 1px 1px var(--tw-drop-shadow-color,#0000000f));--tw-drop-shadow:drop-shadow(0 1px 2px #0000001a)drop-shadow(0 1px 1px #0000000f);filter:var(--tw-blur,)var(--tw-brightness,)var(--tw-contrast,)var(--tw-grayscale,)var(--tw-hue-rotate,)var(--tw-invert,)var(--tw-saturate,)var(--tw-sepia,)var(--tw-drop-shadow,)}.filter{filter:var(--tw-blur,)var(--tw-brightness,)var(--tw-contrast,)var(--tw-grayscale,)var(--tw-hue-rotate,)var(--tw-invert,)var(--tw-saturate,)var(--tw-sepia,)var(--tw-drop-shadow,)}.filter\!{filter:var(--tw-blur,)var(--tw-brightness,)var(--tw-contrast,)var(--tw-grayscale,)var(--tw-hue-rotate,)var(--tw-invert,)var(--tw-saturate,)var(--tw-sepia,)var(--tw-drop-shadow,)!important}.backdrop-blur{--tw-backdrop-blur:blur(8px);-webkit-backdrop-filter:var(--tw-backdrop-blur,)var(--tw-backdrop-brightness,)var(--tw-backdrop-contrast,)var(--tw-backdrop-grayscale,)var(--tw-backdrop-hue-rotate,)var(--tw-backdrop-invert,)var(--tw-backdrop-opacity,)var(--tw-backdrop-saturate,)var(--tw-backdrop-sepia,);backdrop-filter:var(--tw-backdrop-blur,)var(--tw-backdrop-brightness,)var(--tw-backdrop-contrast,)var(--tw-backdrop-grayscale,)var(--tw-backdrop-hue-rotate,)var(--tw-backdrop-invert,)var(--tw-backdrop-opacity,)var(--tw-backdrop-saturate,)var(--tw-backdrop-sepia,)}.backdrop-blur-xl{--tw-backdrop-blur:blur(var(--blur-xl));-webkit-backdrop-filter:var(--tw-backdrop-blur,)var(--tw-backdrop-brightness,)var(--tw-backdrop-contrast,)var(--tw-backdrop-grayscale,)var(--tw-backdrop-hue-rotate,)var(--tw-backdrop-invert,)var(--tw-backdrop-opacity,)var(--tw-backdrop-saturate,)var(--tw-backdrop-sepia,);backdrop-filter:var(--tw-backdrop-blur,)var(--tw-backdrop-brightness,)var(--tw-backdrop-contrast,)var(--tw-backdrop-grayscale,)var(--tw-backdrop-hue-rotate,)var(--tw-backdrop-invert,)var(--tw-backdrop-opacity,)var(--tw-backdrop-saturate,)var(--tw-backdrop-sepia,)}.backdrop-grayscale{--tw-backdrop-grayscale:grayscale(100%);-webkit-backdrop-filter:var(--tw-backdrop-blur,)var(--tw-backdrop-brightness,)var(--tw-backdrop-contrast,)var(--tw-backdrop-grayscale,)var(--tw-backdrop-hue-rotate,)var(--tw-backdrop-invert,)var(--tw-backdrop-opacity,)var(--tw-backdrop-saturate,)var(--tw-backdrop-sepia,);backdrop-filter:var(--tw-backdrop-blur,)var(--tw-backdrop-brightness,)var(--tw-backdrop-contrast,)var(--tw-backdrop-grayscale,)var(--tw-backdrop-hue-rotate,)var(--tw-backdrop-invert,)var(--tw-backdrop-opacity,)var(--tw-backdrop-saturate,)var(--tw-backdrop-sepia,)}.backdrop-invert{--tw-backdrop-invert:invert(100%);-webkit-backdrop-filter:var(--tw-backdrop-blur,)var(--tw-backdrop-brightness,)var(--tw-backdrop-contrast,)var(--tw-backdrop-grayscale,)var(--tw-backdrop-hue-rotate,)var(--tw-backdrop-invert,)var(--tw-backdrop-opacity,)var(--tw-backdrop-saturate,)var(--tw-backdrop-sepia,);backdrop-filter:var(--tw-backdrop-blur,)var(--tw-backdrop-brightness,)var(--tw-backdrop-contrast,)var(--tw-backdrop-grayscale,)var(--tw-backdrop-hue-rotate,)var(--tw-backdrop-invert,)var(--tw-backdrop-opacity,)var(--tw-backdrop-saturate,)var(--tw-backdrop-sepia,)}.backdrop-sepia{--tw-backdrop-sepia:sepia(100%);-webkit-backdrop-filter:var(--tw-backdrop-blur,)var(--tw-backdrop-brightness,)var(--tw-backdrop-contrast,)var(--tw-backdrop-grayscale,)var(--tw-backdrop-hue-rotate,)var(--tw-backdrop-invert,)var(--tw-backdrop-opacity,)var(--tw-backdrop-saturate,)var(--tw-backdrop-sepia,);backdrop-filter:var(--tw-backdrop-blur,)var(--tw-backdrop-brightness,)var(--tw-backdrop-contrast,)var(--tw-backdrop-grayscale,)var(--tw-backdrop-hue-rotate,)var(--tw-backdrop-invert,)var(--tw-backdrop-opacity,)var(--tw-backdrop-saturate,)var(--tw-backdrop-sepia,)}.backdrop-filter{-webkit-backdrop-filter:var(--tw-backdrop-blur,)var(--tw-backdrop-brightness,)var(--tw-backdrop-contrast,)var(--tw-backdrop-grayscale,)var(--tw-backdrop-hue-rotate,)var(--tw-backdrop-invert,)var(--tw-backdrop-opacity,)var(--tw-backdrop-saturate,)var(--tw-backdrop-sepia,);backdrop-filter:var(--tw-backdrop-blur,)var(--tw-backdrop-brightness,)var(--tw-backdrop-contrast,)var(--tw-backdrop-grayscale,)var(--tw-backdrop-hue-rotate,)var(--tw-backdrop-invert,)var(--tw-backdrop-opacity,)var(--tw-backdrop-saturate,)var(--tw-backdrop-sepia,)}.transition{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to,opacity,box-shadow,transform,translate,scale,rotate,filter,-webkit-backdrop-filter,backdrop-filter,display,content-visibility,overlay,pointer-events;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition\!{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to,opacity,box-shadow,transform,translate,scale,rotate,filter,-webkit-backdrop-filter,backdrop-filter,display,content-visibility,overlay,pointer-events!important;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function))!important;transition-duration:var(--tw-duration,var(--default-transition-duration))!important}.transition-all{transition-property:all;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-colors{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-opacity{transition-property:opacity;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-transform{transition-property:transform,translate,scale,rotate;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.duration-200{--tw-duration:.2s;transition-duration:.2s}.outline-none{--tw-outline-style:none;outline-style:none}.select-none{-webkit-user-select:none;user-select:none}:where(.divide-x-reverse>:not(:last-child)){--tw-divide-x-reverse:1}.ring-inset{--tw-ring-inset:inset}@media(hover:hover){.group-hover\:text-\[\#38bdac\]:is(:where(.group):hover *){color:#38bdac}.group-hover\:text-gray-400:is(:where(.group):hover *){color:var(--color-gray-400)}.group-hover\:opacity-100:is(:where(.group):hover *){opacity:1}}.peer-disabled\:cursor-not-allowed:is(:where(.peer):disabled~*){cursor:not-allowed}.peer-disabled\:opacity-70:is(:where(.peer):disabled~*){opacity:.7}.placeholder\:text-gray-500::placeholder{color:var(--color-gray-500)}.last\:border-b-0:last-child{border-bottom-style:var(--tw-border-style);border-bottom-width:0}@media(hover:hover){.hover\:border-\[\#38bdac\]\/30:hover{border-color:#38bdac4d}.hover\:border-\[\#38bdac\]\/50:hover{border-color:#38bdac80}.hover\:border-\[\#38bdac\]\/60:hover{border-color:#38bdac99}.hover\:border-\[\#38bdac\]\/70:hover{border-color:#38bdacb3}.hover\:border-blue-500\/60:hover{border-color:#3080ff99}@supports (color:color-mix(in lab,red,red)){.hover\:border-blue-500\/60:hover{border-color:color-mix(in oklab,var(--color-blue-500)60%,transparent)}}.hover\:border-gray-500:hover{border-color:var(--color-gray-500)}.hover\:border-gray-600:hover{border-color:var(--color-gray-600)}.hover\:border-orange-500\/50:hover{border-color:#fe6e0080}@supports (color:color-mix(in lab,red,red)){.hover\:border-orange-500\/50:hover{border-color:color-mix(in oklab,var(--color-orange-500)50%,transparent)}}.hover\:border-yellow-500\/60:hover{border-color:#edb20099}@supports (color:color-mix(in lab,red,red)){.hover\:border-yellow-500\/60:hover{border-color:color-mix(in oklab,var(--color-yellow-500)60%,transparent)}}.hover\:bg-\[\#0a1628\]:hover{background-color:#0a1628}.hover\:bg-\[\#1a3050\]:hover{background-color:#1a3050}.hover\:bg-\[\#2da396\]:hover{background-color:#2da396}.hover\:bg-\[\#06AD51\]:hover{background-color:#06ad51}.hover\:bg-\[\#07C160\]\/10:hover{background-color:#07c1601a}.hover\:bg-\[\#20B2AA\]:hover{background-color:#20b2aa}.hover\:bg-\[\#38bdac\]\/10:hover{background-color:#38bdac1a}.hover\:bg-\[\#38bdac\]\/20:hover{background-color:#38bdac33}.hover\:bg-\[\#162840\]:hover{background-color:#162840}.hover\:bg-\[\#162840\]\/30:hover{background-color:#1628404d}.hover\:bg-\[\#162840\]\/50:hover{background-color:#16284080}.hover\:bg-amber-500\/10:hover{background-color:#f99c001a}@supports (color:color-mix(in lab,red,red)){.hover\:bg-amber-500\/10:hover{background-color:color-mix(in oklab,var(--color-amber-500)10%,transparent)}}.hover\:bg-amber-500\/20:hover{background-color:#f99c0033}@supports (color:color-mix(in lab,red,red)){.hover\:bg-amber-500\/20:hover{background-color:color-mix(in oklab,var(--color-amber-500)20%,transparent)}}.hover\:bg-amber-500\/30:hover{background-color:#f99c004d}@supports (color:color-mix(in lab,red,red)){.hover\:bg-amber-500\/30:hover{background-color:color-mix(in oklab,var(--color-amber-500)30%,transparent)}}.hover\:bg-amber-600:hover{background-color:var(--color-amber-600)}.hover\:bg-blue-400\/10:hover{background-color:#54a2ff1a}@supports (color:color-mix(in lab,red,red)){.hover\:bg-blue-400\/10:hover{background-color:color-mix(in oklab,var(--color-blue-400)10%,transparent)}}.hover\:bg-blue-500\/20:hover{background-color:#3080ff33}@supports (color:color-mix(in lab,red,red)){.hover\:bg-blue-500\/20:hover{background-color:color-mix(in oklab,var(--color-blue-500)20%,transparent)}}.hover\:bg-gray-500:hover{background-color:var(--color-gray-500)}.hover\:bg-gray-500\/20:hover{background-color:#6a728233}@supports (color:color-mix(in lab,red,red)){.hover\:bg-gray-500\/20:hover{background-color:color-mix(in oklab,var(--color-gray-500)20%,transparent)}}.hover\:bg-gray-700\/50:hover{background-color:#36415380}@supports (color:color-mix(in lab,red,red)){.hover\:bg-gray-700\/50:hover{background-color:color-mix(in oklab,var(--color-gray-700)50%,transparent)}}.hover\:bg-gray-800:hover{background-color:var(--color-gray-800)}.hover\:bg-green-500\/20:hover{background-color:#00c75833}@supports (color:color-mix(in lab,red,red)){.hover\:bg-green-500\/20:hover{background-color:color-mix(in oklab,var(--color-green-500)20%,transparent)}}.hover\:bg-green-700:hover{background-color:var(--color-green-700)}.hover\:bg-orange-500\/10:hover{background-color:#fe6e001a}@supports (color:color-mix(in lab,red,red)){.hover\:bg-orange-500\/10:hover{background-color:color-mix(in oklab,var(--color-orange-500)10%,transparent)}}.hover\:bg-orange-500\/20:hover{background-color:#fe6e0033}@supports (color:color-mix(in lab,red,red)){.hover\:bg-orange-500\/20:hover{background-color:color-mix(in oklab,var(--color-orange-500)20%,transparent)}}.hover\:bg-orange-600:hover{background-color:var(--color-orange-600)}.hover\:bg-purple-500\/10:hover{background-color:#ac4bff1a}@supports (color:color-mix(in lab,red,red)){.hover\:bg-purple-500\/10:hover{background-color:color-mix(in oklab,var(--color-purple-500)10%,transparent)}}.hover\:bg-purple-500\/20:hover{background-color:#ac4bff33}@supports (color:color-mix(in lab,red,red)){.hover\:bg-purple-500\/20:hover{background-color:color-mix(in oklab,var(--color-purple-500)20%,transparent)}}.hover\:bg-purple-500\/30:hover{background-color:#ac4bff4d}@supports (color:color-mix(in lab,red,red)){.hover\:bg-purple-500\/30:hover{background-color:color-mix(in oklab,var(--color-purple-500)30%,transparent)}}.hover\:bg-red-500\/10:hover{background-color:#fb2c361a}@supports (color:color-mix(in lab,red,red)){.hover\:bg-red-500\/10:hover{background-color:color-mix(in oklab,var(--color-red-500)10%,transparent)}}.hover\:bg-red-500\/20:hover{background-color:#fb2c3633}@supports (color:color-mix(in lab,red,red)){.hover\:bg-red-500\/20:hover{background-color:color-mix(in oklab,var(--color-red-500)20%,transparent)}}.hover\:bg-red-700:hover{background-color:var(--color-red-700)}.hover\:bg-white\/5:hover{background-color:#ffffff0d}@supports (color:color-mix(in lab,red,red)){.hover\:bg-white\/5:hover{background-color:color-mix(in oklab,var(--color-white)5%,transparent)}}.hover\:bg-white\/20:hover{background-color:#fff3}@supports (color:color-mix(in lab,red,red)){.hover\:bg-white\/20:hover{background-color:color-mix(in oklab,var(--color-white)20%,transparent)}}.hover\:bg-yellow-500\/20:hover{background-color:#edb20033}@supports (color:color-mix(in lab,red,red)){.hover\:bg-yellow-500\/20:hover{background-color:color-mix(in oklab,var(--color-yellow-500)20%,transparent)}}.hover\:bg-yellow-500\/30:hover{background-color:#edb2004d}@supports (color:color-mix(in lab,red,red)){.hover\:bg-yellow-500\/30:hover{background-color:color-mix(in oklab,var(--color-yellow-500)30%,transparent)}}.hover\:text-\[\#2da396\]:hover{color:#2da396}.hover\:text-\[\#5fe0cd\]:hover{color:#5fe0cd}.hover\:text-\[\#38bdac\]:hover{color:#38bdac}.hover\:text-amber-200:hover{color:var(--color-amber-200)}.hover\:text-amber-300:hover{color:var(--color-amber-300)}.hover\:text-amber-400:hover{color:var(--color-amber-400)}.hover\:text-blue-300:hover{color:var(--color-blue-300)}.hover\:text-blue-400:hover{color:var(--color-blue-400)}.hover\:text-gray-300:hover{color:var(--color-gray-300)}.hover\:text-orange-400:hover{color:var(--color-orange-400)}.hover\:text-red-300:hover{color:var(--color-red-300)}.hover\:text-red-400:hover{color:var(--color-red-400)}.hover\:text-sky-200:hover{color:var(--color-sky-200)}.hover\:text-white:hover{color:var(--color-white)}.hover\:underline:hover{text-decoration-line:underline}.hover\:opacity-100:hover{opacity:1}}.focus\:border-\[\#38bdac\]:focus{border-color:#38bdac}.focus\:border-orange-500\/50:focus{border-color:#fe6e0080}@supports (color:color-mix(in lab,red,red)){.focus\:border-orange-500\/50:focus{border-color:color-mix(in oklab,var(--color-orange-500)50%,transparent)}}.focus\:bg-\[\#38bdac\]\/20:focus{background-color:#38bdac33}.focus\:ring-2:focus{--tw-ring-shadow:var(--tw-ring-inset,)0 0 0 calc(2px + var(--tw-ring-offset-width))var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.focus\:ring-\[\#38bdac\]:focus{--tw-ring-color:#38bdac}.focus\:ring-amber-400:focus{--tw-ring-color:var(--color-amber-400)}.focus\:ring-offset-2:focus{--tw-ring-offset-width:2px;--tw-ring-offset-shadow:var(--tw-ring-inset,)0 0 0 var(--tw-ring-offset-width)var(--tw-ring-offset-color)}.focus\:outline-none:focus{--tw-outline-style:none;outline-style:none}.focus-visible\:ring-0:focus-visible{--tw-ring-shadow:var(--tw-ring-inset,)0 0 0 calc(0px + var(--tw-ring-offset-width))var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.focus-visible\:ring-2:focus-visible{--tw-ring-shadow:var(--tw-ring-inset,)0 0 0 calc(2px + var(--tw-ring-offset-width))var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.focus-visible\:ring-\[3px\]:focus-visible{--tw-ring-shadow:var(--tw-ring-inset,)0 0 0 calc(3px + var(--tw-ring-offset-width))var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.focus-visible\:ring-\[\#38bdac\]:focus-visible{--tw-ring-color:#38bdac}.focus-visible\:ring-red-500:focus-visible{--tw-ring-color:var(--color-red-500)}.focus-visible\:ring-offset-0:focus-visible{--tw-ring-offset-width:0px;--tw-ring-offset-shadow:var(--tw-ring-inset,)0 0 0 var(--tw-ring-offset-width)var(--tw-ring-offset-color)}.focus-visible\:ring-offset-2:focus-visible{--tw-ring-offset-width:2px;--tw-ring-offset-shadow:var(--tw-ring-inset,)0 0 0 var(--tw-ring-offset-width)var(--tw-ring-offset-color)}.focus-visible\:ring-offset-\[\#0a1628\]:focus-visible{--tw-ring-offset-color:#0a1628}.focus-visible\:outline-none:focus-visible{--tw-outline-style:none;outline-style:none}.active\:cursor-grabbing:active{cursor:grabbing}.disabled\:pointer-events-none:disabled{pointer-events:none}.disabled\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\:opacity-40:disabled{opacity:.4}.disabled\:opacity-50:disabled{opacity:.5}.has-\[\>svg\]\:px-2\.5:has(>svg){padding-inline:calc(var(--spacing)*2.5)}.has-\[\>svg\]\:px-3:has(>svg){padding-inline:calc(var(--spacing)*3)}.has-\[\>svg\]\:px-4:has(>svg){padding-inline:calc(var(--spacing)*4)}.data-\[disabled\]\:pointer-events-none[data-disabled]{pointer-events:none}.data-\[disabled\]\:opacity-50[data-disabled]{opacity:.5}.data-\[side\=bottom\]\:translate-y-1[data-side=bottom]{--tw-translate-y:calc(var(--spacing)*1);translate:var(--tw-translate-x)var(--tw-translate-y)}.data-\[state\=active\]\:bg-\[\#07C160\]\/20[data-state=active]{background-color:#07c16033}.data-\[state\=active\]\:bg-\[\#26A17B\]\/20[data-state=active]{background-color:#26a17b33}.data-\[state\=active\]\:bg-\[\#38bdac\]\/20[data-state=active]{background-color:#38bdac33}.data-\[state\=active\]\:bg-\[\#1677FF\]\/20[data-state=active]{background-color:#1677ff33}.data-\[state\=active\]\:bg-\[\#003087\]\/20[data-state=active]{background-color:#00308733}.data-\[state\=active\]\:bg-amber-500\/20[data-state=active]{background-color:#f99c0033}@supports (color:color-mix(in lab,red,red)){.data-\[state\=active\]\:bg-amber-500\/20[data-state=active]{background-color:color-mix(in oklab,var(--color-amber-500)20%,transparent)}}.data-\[state\=active\]\:bg-purple-500\/20[data-state=active]{background-color:#ac4bff33}@supports (color:color-mix(in lab,red,red)){.data-\[state\=active\]\:bg-purple-500\/20[data-state=active]{background-color:color-mix(in oklab,var(--color-purple-500)20%,transparent)}}.data-\[state\=active\]\:font-medium[data-state=active]{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.data-\[state\=active\]\:text-\[\#07C160\][data-state=active]{color:#07c160}.data-\[state\=active\]\:text-\[\#26A17B\][data-state=active]{color:#26a17b}.data-\[state\=active\]\:text-\[\#38bdac\][data-state=active]{color:#38bdac}.data-\[state\=active\]\:text-\[\#169BD7\][data-state=active]{color:#169bd7}.data-\[state\=active\]\:text-\[\#1677FF\][data-state=active]{color:#1677ff}.data-\[state\=active\]\:text-amber-400[data-state=active]{color:var(--color-amber-400)}.data-\[state\=active\]\:text-purple-400[data-state=active]{color:var(--color-purple-400)}.data-\[state\=active\]\:shadow[data-state=active]{--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a),0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.data-\[state\=checked\]\:translate-x-4[data-state=checked]{--tw-translate-x:calc(var(--spacing)*4);translate:var(--tw-translate-x)var(--tw-translate-y)}.data-\[state\=checked\]\:bg-\[\#38bdac\][data-state=checked]{background-color:#38bdac}.data-\[state\=unchecked\]\:translate-x-0[data-state=unchecked]{--tw-translate-x:calc(var(--spacing)*0);translate:var(--tw-translate-x)var(--tw-translate-y)}.data-\[state\=unchecked\]\:bg-gray-600[data-state=unchecked]{background-color:var(--color-gray-600)}@media(min-width:40rem){.sm\:flex-row{flex-direction:row}.sm\:justify-end{justify-content:flex-end}.sm\:gap-0{gap:calc(var(--spacing)*0)}.sm\:text-left{text-align:left}}@media(min-width:48rem){.md\:col-span-2{grid-column:span 2/span 2}.md\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.md\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.md\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.md\:text-sm{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}}@media(min-width:64rem){.lg\:block{display:block}.lg\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.lg\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.lg\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.lg\:grid-cols-8{grid-template-columns:repeat(8,minmax(0,1fr))}}@media(min-width:80rem){.xl\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}}.\[\&_svg\]\:pointer-events-none svg{pointer-events:none}.\[\&_svg\]\:shrink-0 svg{flex-shrink:0}.\[\&_svg\:not\(\[class\*\=\'size-\'\]\)\]\:size-4 svg:not([class*=size-]){width:calc(var(--spacing)*4);height:calc(var(--spacing)*4)}.\[\&_tr\]\:border-b tr{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}.\[\&_tr\:last-child\]\:border-0 tr:last-child{border-style:var(--tw-border-style);border-width:0}.\[\&\:has\(\[role\=checkbox\]\)\]\:pr-0:has([role=checkbox]){padding-right:calc(var(--spacing)*0)}.\[\&\>span\]\:line-clamp-1>span{-webkit-line-clamp:1;-webkit-box-orient:vertical;display:-webkit-box;overflow:hidden}}:root{--background:oklch(14.5% 0 0);--foreground:oklch(98.5% 0 0);--card:oklch(20% .02 240);--card-foreground:oklch(98.5% 0 0);--popover:oklch(20% .02 240);--popover-foreground:oklch(98.5% 0 0);--primary:oklch(65% .15 180);--primary-foreground:oklch(20% 0 0);--secondary:oklch(27% 0 0);--secondary-foreground:oklch(98.5% 0 0);--muted:oklch(27% 0 0);--muted-foreground:oklch(65% 0 0);--accent:oklch(27% 0 0);--accent-foreground:oklch(98.5% 0 0);--destructive:oklch(55% .2 25);--destructive-foreground:oklch(98.5% 0 0);--border:oklch(35% 0 0);--input:oklch(35% 0 0);--ring:oklch(65% .15 180);--radius:.625rem}body{font-family:var(--font-sans);color:var(--foreground);background:#0a1628}@property --tw-translate-x{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-y{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-z{syntax:"*";inherits:false;initial-value:0}@property --tw-scale-x{syntax:"*";inherits:false;initial-value:1}@property --tw-scale-y{syntax:"*";inherits:false;initial-value:1}@property --tw-scale-z{syntax:"*";inherits:false;initial-value:1}@property --tw-rotate-x{syntax:"*";inherits:false}@property --tw-rotate-y{syntax:"*";inherits:false}@property --tw-rotate-z{syntax:"*";inherits:false}@property --tw-skew-x{syntax:"*";inherits:false}@property --tw-skew-y{syntax:"*";inherits:false}@property --tw-pan-x{syntax:"*";inherits:false}@property --tw-pan-y{syntax:"*";inherits:false}@property --tw-pinch-zoom{syntax:"*";inherits:false}@property --tw-space-y-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-space-x-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-divide-x-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-divide-y-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-gradient-position{syntax:"*";inherits:false}@property --tw-gradient-from{syntax:"";inherits:false;initial-value:#0000}@property --tw-gradient-via{syntax:"";inherits:false;initial-value:#0000}@property --tw-gradient-to{syntax:"";inherits:false;initial-value:#0000}@property --tw-gradient-stops{syntax:"*";inherits:false}@property --tw-gradient-via-stops{syntax:"*";inherits:false}@property --tw-gradient-from-position{syntax:"";inherits:false;initial-value:0%}@property --tw-gradient-via-position{syntax:"";inherits:false;initial-value:50%}@property --tw-gradient-to-position{syntax:"";inherits:false;initial-value:100%}@property --tw-leading{syntax:"*";inherits:false}@property --tw-font-weight{syntax:"*";inherits:false}@property --tw-tracking{syntax:"*";inherits:false}@property --tw-ordinal{syntax:"*";inherits:false}@property --tw-slashed-zero{syntax:"*";inherits:false}@property --tw-numeric-figure{syntax:"*";inherits:false}@property --tw-numeric-spacing{syntax:"*";inherits:false}@property --tw-numeric-fraction{syntax:"*";inherits:false}@property --tw-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:"*";inherits:false}@property --tw-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:"*";inherits:false}@property --tw-inset-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:"*";inherits:false}@property --tw-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:"*";inherits:false}@property --tw-inset-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:"*";inherits:false}@property --tw-ring-offset-width{syntax:"";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:"*";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-outline-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-blur{syntax:"*";inherits:false}@property --tw-brightness{syntax:"*";inherits:false}@property --tw-contrast{syntax:"*";inherits:false}@property --tw-grayscale{syntax:"*";inherits:false}@property --tw-hue-rotate{syntax:"*";inherits:false}@property --tw-invert{syntax:"*";inherits:false}@property --tw-opacity{syntax:"*";inherits:false}@property --tw-saturate{syntax:"*";inherits:false}@property --tw-sepia{syntax:"*";inherits:false}@property --tw-drop-shadow{syntax:"*";inherits:false}@property --tw-drop-shadow-color{syntax:"*";inherits:false}@property --tw-drop-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-drop-shadow-size{syntax:"*";inherits:false}@property --tw-backdrop-blur{syntax:"*";inherits:false}@property --tw-backdrop-brightness{syntax:"*";inherits:false}@property --tw-backdrop-contrast{syntax:"*";inherits:false}@property --tw-backdrop-grayscale{syntax:"*";inherits:false}@property --tw-backdrop-hue-rotate{syntax:"*";inherits:false}@property --tw-backdrop-invert{syntax:"*";inherits:false}@property --tw-backdrop-opacity{syntax:"*";inherits:false}@property --tw-backdrop-saturate{syntax:"*";inherits:false}@property --tw-backdrop-sepia{syntax:"*";inherits:false}@property --tw-duration{syntax:"*";inherits:false}@keyframes spin{to{transform:rotate(360deg)}} diff --git a/soul-admin/dist/assets/index-ChSYyP1O.js b/soul-admin/dist/assets/index-ChSYyP1O.js new file mode 100644 index 00000000..f99258fa --- /dev/null +++ b/soul-admin/dist/assets/index-ChSYyP1O.js @@ -0,0 +1,792 @@ +function uE(t,e){for(var n=0;nr[i]})}}}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 i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const a of i)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(i){const a={};return i.integrity&&(a.integrity=i.integrity),i.referrerPolicy&&(a.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?a.credentials="include":i.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function r(i){if(i.ep)return;i.ep=!0;const a=n(i);fetch(i.href,a)}})();function Cw(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var mm={exports:{}},Nc={},gm={exports:{}},ut={};/** + * @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 fb;function hE(){if(fb)return ut;fb=1;var t=Symbol.for("react.element"),e=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),i=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($){return $===null||typeof $!="object"?null:($=m&&$[m]||$["@@iterator"],typeof $=="function"?$:null)}var y={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},b=Object.assign,j={};function w($,H,ce){this.props=$,this.context=H,this.refs=j,this.updater=ce||y}w.prototype.isReactComponent={},w.prototype.setState=function($,H){if(typeof $!="object"&&typeof $!="function"&&$!=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,$,H,"setState")},w.prototype.forceUpdate=function($){this.updater.enqueueForceUpdate(this,$,"forceUpdate")};function N(){}N.prototype=w.prototype;function C($,H,ce){this.props=$,this.context=H,this.refs=j,this.updater=ce||y}var E=C.prototype=new N;E.constructor=C,b(E,w.prototype),E.isPureReactComponent=!0;var M=Array.isArray,I=Object.prototype.hasOwnProperty,O={current:null},D={key:!0,ref:!0,__self:!0,__source:!0};function P($,H,ce){var W,fe={},Q=null,de=null;if(H!=null)for(W in H.ref!==void 0&&(de=H.ref),H.key!==void 0&&(Q=""+H.key),H)I.call(H,W)&&!D.hasOwnProperty(W)&&(fe[W]=H[W]);var he=arguments.length-2;if(he===1)fe.children=ce;else if(1>>1,H=z[$];if(0>>1;$i(fe,G))Qi(de,fe)?(z[$]=de,z[Q]=G,$=Q):(z[$]=fe,z[W]=G,$=W);else if(Qi(de,G))z[$]=de,z[Q]=G,$=Q;else break e}}return ae}function i(z,ae){var G=z.sortIndex-ae.sortIndex;return G!==0?G:z.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,b=!1,j=!1,w=typeof setTimeout=="function"?setTimeout:null,N=typeof clearTimeout=="function"?clearTimeout:null,C=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function E(z){for(var ae=n(h);ae!==null;){if(ae.callback===null)r(h);else if(ae.startTime<=z)r(h),ae.sortIndex=ae.expirationTime,e(u,ae);else break;ae=n(h)}}function M(z){if(j=!1,E(z),!b)if(n(u)!==null)b=!0,F(I);else{var ae=n(h);ae!==null&&re(M,ae.startTime-z)}}function I(z,ae){b=!1,j&&(j=!1,N(P),P=-1),y=!0;var G=g;try{for(E(ae),m=n(u);m!==null&&(!(m.expirationTime>ae)||z&&!X());){var $=m.callback;if(typeof $=="function"){m.callback=null,g=m.priorityLevel;var H=$(m.expirationTime<=ae);ae=t.unstable_now(),typeof H=="function"?m.callback=H:m===n(u)&&r(u),E(ae)}else r(u);m=n(u)}if(m!==null)var ce=!0;else{var W=n(h);W!==null&&re(M,W.startTime-ae),ce=!1}return ce}finally{m=null,g=G,y=!1}}var O=!1,D=null,P=-1,L=5,_=-1;function X(){return!(t.unstable_now()-_z||125$?(z.sortIndex=G,e(h,z),n(u)===null&&z===n(h)&&(j?(N(P),P=-1):j=!0,re(M,G-$))):(z.sortIndex=H,e(u,z),b||y||(b=!0,F(I))),z},t.unstable_shouldYield=X,t.unstable_wrapCallback=function(z){var ae=g;return function(){var G=g;g=ae;try{return z.apply(this,arguments)}finally{g=G}}}})(vm)),vm}var yb;function gE(){return yb||(yb=1,ym.exports=mE()),ym.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 vb;function xE(){if(vb)return wr;vb=1;var t=cd(),e=gE();function n(l){for(var d="https://reactjs.org/docs/error-decoder.html?invariant="+l,p=1;p"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 b(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,k,S,T){this.acceptsBooleans=d===2||d===3||d===4,this.attributeName=x,this.attributeNamespace=k,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 N=/[\-:]([a-z])/g;function C(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(N,C);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(N,C);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(N,C);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 E(l,d,p,x){var k=w.hasOwnProperty(d)?w[d]:null;(k!==null?k.type!==0:x||!(2B||k[T]!==S[B]){var q=` +`+k[T].replace(" at new "," at ");return l.displayName&&q.includes("")&&(q=q.replace("",l.displayName)),q}while(1<=T&&0<=B);break}}}finally{ce=!1,Error.prepareStackTrace=p}return(l=l?l.displayName||l.name:"")?H(l):""}function fe(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=W(l.type,!1),l;case 11:return l=W(l.type.render,!1),l;case 1:return l=W(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 D:return"Fragment";case O:return"Portal";case L:return"Profiler";case P:return"StrictMode";case J:return"Suspense";case U:return"SuspenseList"}if(typeof l=="object")switch(l.$$typeof){case X:return(l.displayName||"Context")+".Consumer";case _:return(l._context.displayName||"Context")+".Provider";case ne:var d=l.render;return l=l.displayName,l||(l=d.displayName||d.name||"",l=l!==""?"ForwardRef("+l+")":"ForwardRef"),l;case R:return d=l.displayName||null,d!==null?d:Q(l.type)||"Memo";case F:d=l._payload,l=l._init;try{return Q(l(d))}catch{}}return null}function de(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===P?"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 he(l){switch(typeof l){case"boolean":case"number":case"string":case"undefined":return l;case"object":return l;default:return""}}function Ne(l){var d=l.type;return(l=l.nodeName)&&l.toLowerCase()==="input"&&(d==="checkbox"||d==="radio")}function Te(l){var d=Ne(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 k=p.get,S=p.set;return Object.defineProperty(l,d,{configurable:!0,get:function(){return k.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 Ve(l){l._valueTracker||(l._valueTracker=Te(l))}function He(l){if(!l)return!1;var d=l._valueTracker;if(!d)return!0;var p=d.getValue(),x="";return l&&(x=Ne(l)?l.checked?"true":"false":l.value),l=x,l!==p?(d.setValue(l),!0):!1}function gt(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 Pt(l,d){var p=d.checked;return G({},d,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:p??l._wrapperState.initialChecked})}function wn(l,d){var p=d.defaultValue==null?"":d.defaultValue,x=d.checked!=null?d.checked:d.defaultChecked;p=he(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 ht(l,d){d=d.checked,d!=null&&E(l,"checked",d,!1)}function At(l,d){ht(l,d);var p=he(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")?Pe(l,d.type,p):d.hasOwnProperty("defaultValue")&&Pe(l,d.type,he(d.defaultValue)),d.checked==null&&d.defaultChecked!=null&&(l.defaultChecked=!!d.defaultChecked)}function te(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 Pe(l,d,p){(d!=="number"||gt(l.ownerDocument)!==l)&&(p==null?l.defaultValue=""+l._wrapperState.initialValue:l.defaultValue!==""+p&&(l.defaultValue=""+p))}var Qe=Array.isArray;function xt(l,d,p,x){if(l=l.options,d){d={};for(var k=0;k"+d.valueOf().toString()+"",d=Dt.firstChild;l.firstChild;)l.removeChild(l.firstChild);for(;d.firstChild;)l.appendChild(d.firstChild)}});function Xr(l,d){if(d){var p=l.firstChild;if(p&&p===l.lastChild&&p.nodeType===3){p.nodeValue=d;return}}l.textContent=d}var ir={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},me=["Webkit","ms","Moz","O"];Object.keys(ir).forEach(function(l){me.forEach(function(d){d=d+l.charAt(0).toUpperCase()+l.substring(1),ir[d]=ir[l]})});function ve(l,d,p){return d==null||typeof d=="boolean"||d===""?"":p||typeof d!="number"||d===0||ir.hasOwnProperty(l)&&ir[l]?(""+d).trim():d+"px"}function ar(l,d){l=l.style;for(var p in d)if(d.hasOwnProperty(p)){var x=p.indexOf("--")===0,k=ve(p,d[p],x);p==="float"&&(p="cssFloat"),x?l.setProperty(p,k):l[p]=k}}var Hs=G({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 ki(l,d){if(d){if(Hs[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 Si(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 Sr=null;function Aa(l){return l=l.target||l.srcElement||window,l.correspondingUseElement&&(l=l.correspondingUseElement),l.nodeType===3?l.parentNode:l}var _r=null,Zr=null,or=null;function Ci(l){if(l=ac(l)){if(typeof _r!="function")throw Error(n(280));var d=l.stateNode;d&&(d=Od(d),_r(l.stateNode,l.type,d))}}function Ia(l){Zr?or?or.push(l):or=[l]:Zr=l}function Ws(){if(Zr){var l=Zr,d=or;if(or=Zr=null,Ci(l),d)for(l=0;l>>=0,l===0?32:31-(Mn(l)/lr|0)|0}var Jt=64,_n=4194304;function ns(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 Ss(l,d){var p=l.pendingLanes;if(p===0)return 0;var x=0,k=l.suspendedLanes,S=l.pingedLanes,T=p&268435455;if(T!==0){var B=T&~k;B!==0?x=ns(B):(S&=T,S!==0&&(x=ns(S)))}else T=p&~k,T!==0?x=ns(T):S!==0&&(x=ns(S));if(x===0)return 0;if(d!==0&&d!==x&&(d&k)===0&&(k=x&-x,S=d&-d,k>=S||k===16&&(S&4194240)!==0))return d;if((x&4)!==0&&(x|=p&16),d=l.entangledLanes,d!==0)for(l=l.entanglements,d&=x;0p;p++)d.push(l);return d}function Qs(l,d,p){l.pendingLanes|=d,d!==536870912&&(l.suspendedLanes=0,l.pingedLanes=0),l=l.eventTimes,d=31-et(d),l[d]=p}function vd(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=Ql),ay=" ",oy=!1;function ly(l,d){switch(l){case"keyup":return a3.indexOf(d.keyCode)!==-1;case"keydown":return d.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function cy(l){return l=l.detail,typeof l=="object"&&"data"in l?l.data:null}var Lo=!1;function l3(l,d){switch(l){case"compositionend":return cy(d);case"keypress":return d.which!==32?null:(oy=!0,ay);case"textInput":return l=d.data,l===ay&&oy?null:l;default:return null}}function c3(l,d){if(Lo)return l==="compositionend"||!Jf&&ly(l,d)?(l=ey(),jd=Hf=Ri=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)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=gy(p)}}function yy(l,d){return l&&d?l===d?!0:l&&l.nodeType===3?!1:d&&d.nodeType===3?yy(l,d.parentNode):"contains"in l?l.contains(d):l.compareDocumentPosition?!!(l.compareDocumentPosition(d)&16):!1:!1}function vy(){for(var l=window,d=gt();d instanceof l.HTMLIFrameElement;){try{var p=typeof d.contentWindow.location.href=="string"}catch{p=!1}if(p)l=d.contentWindow;else break;d=gt(l.document)}return d}function Xf(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 y3(l){var d=vy(),p=l.focusedElem,x=l.selectionRange;if(d!==p&&p&&p.ownerDocument&&yy(p.ownerDocument.documentElement,p)){if(x!==null&&Xf(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 k=p.textContent.length,S=Math.min(x.start,k);x=x.end===void 0?S:Math.min(x.end,k),!l.extend&&S>x&&(k=x,x=S,S=k),k=xy(p,S);var T=xy(p,x);k&&T&&(l.rangeCount!==1||l.anchorNode!==k.node||l.anchorOffset!==k.offset||l.focusNode!==T.node||l.focusOffset!==T.offset)&&(d=d.createRange(),d.setStart(k.node,k.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=document.documentMode,_o=null,Zf=null,tc=null,ep=!1;function by(l,d,p){var x=p.window===p?p.document:p.nodeType===9?p:p.ownerDocument;ep||_o==null||_o!==gt(x)||(x=_o,"selectionStart"in x&&Xf(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}),tc&&ec(tc,x)||(tc=x,x=Id(Zf,"onSelect"),0Vo||(l.current=hp[Vo],hp[Vo]=null,Vo--)}function Lt(l,d){Vo++,hp[Vo]=l.current,l.current=d}var Li={},qn=Di(Li),xr=Di(!1),za=Li;function Ho(l,d){var p=l.type.contextTypes;if(!p)return Li;var x=l.stateNode;if(x&&x.__reactInternalMemoizedUnmaskedChildContext===d)return x.__reactInternalMemoizedMaskedChildContext;var k={},S;for(S in p)k[S]=d[S];return x&&(l=l.stateNode,l.__reactInternalMemoizedUnmaskedChildContext=d,l.__reactInternalMemoizedMaskedChildContext=k),k}function yr(l){return l=l.childContextTypes,l!=null}function Dd(){Ht(xr),Ht(qn)}function Dy(l,d,p){if(qn.current!==Li)throw Error(n(168));Lt(qn,d),Lt(xr,p)}function Ly(l,d,p){var x=l.stateNode;if(d=d.childContextTypes,typeof x.getChildContext!="function")return p;x=x.getChildContext();for(var k in x)if(!(k in d))throw Error(n(108,de(l)||"Unknown",k));return G({},p,x)}function Ld(l){return l=(l=l.stateNode)&&l.__reactInternalMemoizedMergedChildContext||Li,za=qn.current,Lt(qn,l),Lt(xr,xr.current),!0}function _y(l,d,p){var x=l.stateNode;if(!x)throw Error(n(169));p?(l=Ly(l,d,za),x.__reactInternalMemoizedMergedChildContext=l,Ht(xr),Ht(qn),Lt(qn,l)):Ht(xr),Lt(xr,p)}var ei=null,_d=!1,fp=!1;function zy(l){ei===null?ei=[l]:ei.push(l)}function A3(l){_d=!0,zy(l)}function _i(){if(!fp&&ei!==null){fp=!0;var l=0,d=yt;try{var p=ei;for(yt=1;l>=T,k-=T,ti=1<<32-et(d)+k|p<tt?(Rn=Ye,Ye=null):Rn=Ye.sibling;var vt=be(se,Ye,le[tt],Ee);if(vt===null){Ye===null&&(Ye=Rn);break}l&&Ye&&vt.alternate===null&&d(se,Ye),Y=S(vt,Y,tt),Je===null?Be=vt:Je.sibling=vt,Je=vt,Ye=Rn}if(tt===le.length)return p(se,Ye),Yt&&Fa(se,tt),Be;if(Ye===null){for(;tttt?(Rn=Ye,Ye=null):Rn=Ye.sibling;var Ki=be(se,Ye,vt.value,Ee);if(Ki===null){Ye===null&&(Ye=Rn);break}l&&Ye&&Ki.alternate===null&&d(se,Ye),Y=S(Ki,Y,tt),Je===null?Be=Ki:Je.sibling=Ki,Je=Ki,Ye=Rn}if(vt.done)return p(se,Ye),Yt&&Fa(se,tt),Be;if(Ye===null){for(;!vt.done;tt++,vt=le.next())vt=ke(se,vt.value,Ee),vt!==null&&(Y=S(vt,Y,tt),Je===null?Be=vt:Je.sibling=vt,Je=vt);return Yt&&Fa(se,tt),Be}for(Ye=x(se,Ye);!vt.done;tt++,vt=le.next())vt=Oe(Ye,se,tt,vt.value,Ee),vt!==null&&(l&&vt.alternate!==null&&Ye.delete(vt.key===null?tt:vt.key),Y=S(vt,Y,tt),Je===null?Be=vt:Je.sibling=vt,Je=vt);return l&&Ye.forEach(function(dE){return d(se,dE)}),Yt&&Fa(se,tt),Be}function mn(se,Y,le,Ee){if(typeof le=="object"&&le!==null&&le.type===D&&le.key===null&&(le=le.props.children),typeof le=="object"&&le!==null){switch(le.$$typeof){case I:e:{for(var Be=le.key,Je=Y;Je!==null;){if(Je.key===Be){if(Be=le.type,Be===D){if(Je.tag===7){p(se,Je.sibling),Y=k(Je,le.props.children),Y.return=se,se=Y;break e}}else if(Je.elementType===Be||typeof Be=="object"&&Be!==null&&Be.$$typeof===F&&Wy(Be)===Je.type){p(se,Je.sibling),Y=k(Je,le.props),Y.ref=oc(se,Je,le),Y.return=se,se=Y;break e}p(se,Je);break}else d(se,Je);Je=Je.sibling}le.type===D?(Y=Ga(le.props.children,se.mode,Ee,le.key),Y.return=se,se=Y):(Ee=uu(le.type,le.key,le.props,null,se.mode,Ee),Ee.ref=oc(se,Y,le),Ee.return=se,se=Ee)}return T(se);case O:e:{for(Je=le.key;Y!==null;){if(Y.key===Je)if(Y.tag===4&&Y.stateNode.containerInfo===le.containerInfo&&Y.stateNode.implementation===le.implementation){p(se,Y.sibling),Y=k(Y,le.children||[]),Y.return=se,se=Y;break e}else{p(se,Y);break}else d(se,Y);Y=Y.sibling}Y=dm(le,se.mode,Ee),Y.return=se,se=Y}return T(se);case F:return Je=le._init,mn(se,Y,Je(le._payload),Ee)}if(Qe(le))return _e(se,Y,le,Ee);if(ae(le))return Fe(se,Y,le,Ee);Bd(se,le)}return typeof le=="string"&&le!==""||typeof le=="number"?(le=""+le,Y!==null&&Y.tag===6?(p(se,Y.sibling),Y=k(Y,le),Y.return=se,se=Y):(p(se,Y),Y=cm(le,se.mode,Ee),Y.return=se,se=Y),T(se)):p(se,Y)}return mn}var qo=Uy(!0),Ky=Uy(!1),Vd=Di(null),Hd=null,Go=null,vp=null;function bp(){vp=Go=Hd=null}function Np(l){var d=Vd.current;Ht(Vd),l._currentValue=d}function wp(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 Jo(l,d){Hd=l,vp=Go=null,l=l.dependencies,l!==null&&l.firstContext!==null&&((l.lanes&d)!==0&&(vr=!0),l.firstContext=null)}function Vr(l){var d=l._currentValue;if(vp!==l)if(l={context:l,memoizedValue:d,next:null},Go===null){if(Hd===null)throw Error(n(308));Go=l,Hd.dependencies={lanes:0,firstContext:l}}else Go=Go.next=l;return d}var Ba=null;function jp(l){Ba===null?Ba=[l]:Ba.push(l)}function qy(l,d,p,x){var k=d.interleaved;return k===null?(p.next=p,jp(d)):(p.next=k.next,k.next=p),d.interleaved=p,ri(l,x)}function ri(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 zi=!1;function kp(l){l.updateQueue={baseState:l.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Gy(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 si(l,d){return{eventTime:l,lane:d,tag:0,payload:null,callback:null,next:null}}function $i(l,d,p){var x=l.updateQueue;if(x===null)return null;if(x=x.shared,(mt&2)!==0){var k=x.pending;return k===null?d.next=d:(d.next=k.next,k.next=d),x.pending=d,ri(l,p)}return k=x.interleaved,k===null?(d.next=d,jp(x)):(d.next=k.next,k.next=d),x.interleaved=d,ri(l,p)}function Wd(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,Po(l,p)}}function Jy(l,d){var p=l.updateQueue,x=l.alternate;if(x!==null&&(x=x.updateQueue,p===x)){var k=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?k=S=T:S=S.next=T,p=p.next}while(p!==null);S===null?k=S=d:S=S.next=d}else k=S=d;p={baseState:x.baseState,firstBaseUpdate:k,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 Ud(l,d,p,x){var k=l.updateQueue;zi=!1;var S=k.firstBaseUpdate,T=k.lastBaseUpdate,B=k.shared.pending;if(B!==null){k.shared.pending=null;var q=B,ue=q.next;q.next=null,T===null?S=ue:T.next=ue,T=q;var we=l.alternate;we!==null&&(we=we.updateQueue,B=we.lastBaseUpdate,B!==T&&(B===null?we.firstBaseUpdate=ue:B.next=ue,we.lastBaseUpdate=q))}if(S!==null){var ke=k.baseState;T=0,we=ue=q=null,B=S;do{var be=B.lane,Oe=B.eventTime;if((x&be)===be){we!==null&&(we=we.next={eventTime:Oe,lane:0,tag:B.tag,payload:B.payload,callback:B.callback,next:null});e:{var _e=l,Fe=B;switch(be=d,Oe=p,Fe.tag){case 1:if(_e=Fe.payload,typeof _e=="function"){ke=_e.call(Oe,ke,be);break e}ke=_e;break e;case 3:_e.flags=_e.flags&-65537|128;case 0:if(_e=Fe.payload,be=typeof _e=="function"?_e.call(Oe,ke,be):_e,be==null)break e;ke=G({},ke,be);break e;case 2:zi=!0}}B.callback!==null&&B.lane!==0&&(l.flags|=64,be=k.effects,be===null?k.effects=[B]:be.push(B))}else Oe={eventTime:Oe,lane:be,tag:B.tag,payload:B.payload,callback:B.callback,next:null},we===null?(ue=we=Oe,q=ke):we=we.next=Oe,T|=be;if(B=B.next,B===null){if(B=k.shared.pending,B===null)break;be=B,B=be.next,be.next=null,k.lastBaseUpdate=be,k.shared.pending=null}}while(!0);if(we===null&&(q=ke),k.baseState=q,k.firstBaseUpdate=ue,k.lastBaseUpdate=we,d=k.shared.interleaved,d!==null){k=d;do T|=k.lane,k=k.next;while(k!==d)}else S===null&&(k.shared.lanes=0);Wa|=T,l.lanes=T,l.memoizedState=ke}}function Yy(l,d,p){if(l=d.effects,d.effects=null,l!==null)for(d=0;dp?p:4,l(!0);var x=Mp.transition;Mp.transition={};try{l(!1),d()}finally{yt=p,Mp.transition=x}}function mv(){return Hr().memoizedState}function O3(l,d,p){var x=Hi(l);if(p={lane:x,action:p,hasEagerState:!1,eagerState:null,next:null},gv(l))xv(d,p);else if(p=qy(l,d,p,x),p!==null){var k=dr();ds(p,l,x,k),yv(p,d,x)}}function D3(l,d,p){var x=Hi(l),k={lane:x,action:p,hasEagerState:!1,eagerState:null,next:null};if(gv(l))xv(d,k);else{var S=l.alternate;if(l.lanes===0&&(S===null||S.lanes===0)&&(S=d.lastRenderedReducer,S!==null))try{var T=d.lastRenderedState,B=S(T,p);if(k.hasEagerState=!0,k.eagerState=B,ss(B,T)){var q=d.interleaved;q===null?(k.next=k,jp(d)):(k.next=q.next,q.next=k),d.interleaved=k;return}}catch{}finally{}p=qy(l,d,k,x),p!==null&&(k=dr(),ds(p,l,x,k),yv(p,d,x))}}function gv(l){var d=l.alternate;return l===en||d!==null&&d===en}function xv(l,d){uc=Gd=!0;var p=l.pending;p===null?d.next=d:(d.next=p.next,p.next=d),l.pending=d}function yv(l,d,p){if((p&4194240)!==0){var x=d.lanes;x&=l.pendingLanes,p|=x,d.lanes=p,Po(l,p)}}var Qd={readContext:Vr,useCallback:Gn,useContext:Gn,useEffect:Gn,useImperativeHandle:Gn,useInsertionEffect:Gn,useLayoutEffect:Gn,useMemo:Gn,useReducer:Gn,useRef:Gn,useState:Gn,useDebugValue:Gn,useDeferredValue:Gn,useTransition:Gn,useMutableSource:Gn,useSyncExternalStore:Gn,useId:Gn,unstable_isNewReconciler:!1},L3={readContext:Vr,useCallback:function(l,d){return Ms().memoizedState=[l,d===void 0?null:d],l},useContext:Vr,useEffect:ov,useImperativeHandle:function(l,d,p){return p=p!=null?p.concat([l]):null,Jd(4194308,4,dv.bind(null,d,l),p)},useLayoutEffect:function(l,d){return Jd(4194308,4,l,d)},useInsertionEffect:function(l,d){return Jd(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=O3.bind(null,en,l),[x.memoizedState,l]},useRef:function(l){var d=Ms();return l={current:l},d.memoizedState=l},useState:iv,useDebugValue:Lp,useDeferredValue:function(l){return Ms().memoizedState=l},useTransition:function(){var l=iv(!1),d=l[0];return l=P3.bind(null,l[1]),Ms().memoizedState=l,[d,l]},useMutableSource:function(){},useSyncExternalStore:function(l,d,p){var x=en,k=Ms();if(Yt){if(p===void 0)throw Error(n(407));p=p()}else{if(p=d(),In===null)throw Error(n(349));(Ha&30)!==0||ev(x,d,p)}k.memoizedState=p;var S={value:p,getSnapshot:d};return k.queue=S,ov(nv.bind(null,x,S,l),[l]),x.flags|=2048,pc(9,tv.bind(null,x,S,p,d),void 0,null),p},useId:function(){var l=Ms(),d=In.identifierPrefix;if(Yt){var p=ni,x=ti;p=(x&~(1<<32-et(x)-1)).toString(32)+p,d=":"+d+"R"+p,p=hc++,0<\/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[Es]=d,l[ic]=x,zv(l,d,!1,!1),d.stateNode=l;e:{switch(T=Si(p,x),p){case"dialog":Vt("cancel",l),Vt("close",l),k=x;break;case"iframe":case"object":case"embed":Vt("load",l),k=x;break;case"video":case"audio":for(k=0;kel&&(d.flags|=128,x=!0,mc(S,!1),d.lanes=4194304)}else{if(!x)if(l=Kd(T),l!==null){if(d.flags|=128,x=!0,p=l.updateQueue,p!==null&&(d.updateQueue=p,d.flags|=4),mc(S,!0),S.tail===null&&S.tailMode==="hidden"&&!T.alternate&&!Yt)return Jn(d),null}else 2*Tt()-S.renderingStartTime>el&&p!==1073741824&&(d.flags|=128,x=!0,mc(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=Tt(),d.sibling=null,p=Zt.current,Lt(Zt,x?p&1|2:p&1),d):(Jn(d),null);case 22:case 23:return am(),x=d.memoizedState!==null,l!==null&&l.memoizedState!==null!==x&&(d.flags|=8192),x&&(d.mode&1)!==0?(Ar&1073741824)!==0&&(Jn(d),d.subtreeFlags&6&&(d.flags|=8192)):Jn(d),null;case 24:return null;case 25:return null}throw Error(n(156,d.tag))}function W3(l,d){switch(mp(d),d.tag){case 1:return yr(d.type)&&Dd(),l=d.flags,l&65536?(d.flags=l&-65537|128,d):null;case 3:return Yo(),Ht(xr),Ht(qn),Tp(),l=d.flags,(l&65536)!==0&&(l&128)===0?(d.flags=l&-65537|128,d):null;case 5:return Cp(d),null;case 13:if(Ht(Zt),l=d.memoizedState,l!==null&&l.dehydrated!==null){if(d.alternate===null)throw Error(n(340));Ko()}return l=d.flags,l&65536?(d.flags=l&-65537|128,d):null;case 19:return Ht(Zt),null;case 4:return Yo(),null;case 10:return Np(d.type._context),null;case 22:case 23:return am(),null;case 24:return null;default:return null}}var tu=!1,Yn=!1,U3=typeof WeakSet=="function"?WeakSet:Set,De=null;function Xo(l,d){var p=l.ref;if(p!==null)if(typeof p=="function")try{p(null)}catch(x){ln(l,d,x)}else p.current=null}function Gp(l,d,p){try{p()}catch(x){ln(l,d,x)}}var Bv=!1;function K3(l,d){if(ap=Nd,l=vy(),Xf(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 k=x.anchorOffset,S=x.focusNode;x=x.focusOffset;try{p.nodeType,S.nodeType}catch{p=null;break e}var T=0,B=-1,q=-1,ue=0,we=0,ke=l,be=null;t:for(;;){for(var Oe;ke!==p||k!==0&&ke.nodeType!==3||(B=T+k),ke!==S||x!==0&&ke.nodeType!==3||(q=T+x),ke.nodeType===3&&(T+=ke.nodeValue.length),(Oe=ke.firstChild)!==null;)be=ke,ke=Oe;for(;;){if(ke===l)break t;if(be===p&&++ue===k&&(B=T),be===S&&++we===x&&(q=T),(Oe=ke.nextSibling)!==null)break;ke=be,be=ke.parentNode}ke=Oe}p=B===-1||q===-1?null:{start:B,end:q}}else p=null}p=p||{start:0,end:0}}else p=null;for(op={focusedElem:l,selectionRange:p},Nd=!1,De=d;De!==null;)if(d=De,l=d.child,(d.subtreeFlags&1028)!==0&&l!==null)l.return=d,De=l;else for(;De!==null;){d=De;try{var _e=d.alternate;if((d.flags&1024)!==0)switch(d.tag){case 0:case 11:case 15:break;case 1:if(_e!==null){var Fe=_e.memoizedProps,mn=_e.memoizedState,se=d.stateNode,Y=se.getSnapshotBeforeUpdate(d.elementType===d.type?Fe:as(d.type,Fe),mn);se.__reactInternalSnapshotBeforeUpdate=Y}break;case 3:var le=d.stateNode.containerInfo;le.nodeType===1?le.textContent="":le.nodeType===9&&le.documentElement&&le.removeChild(le.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(n(163))}}catch(Ee){ln(d,d.return,Ee)}if(l=d.sibling,l!==null){l.return=d.return,De=l;break}De=d.return}return _e=Bv,Bv=!1,_e}function gc(l,d,p){var x=d.updateQueue;if(x=x!==null?x.lastEffect:null,x!==null){var k=x=x.next;do{if((k.tag&l)===l){var S=k.destroy;k.destroy=void 0,S!==void 0&&Gp(d,p,S)}k=k.next}while(k!==x)}}function nu(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 Jp(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 Vv(l){var d=l.alternate;d!==null&&(l.alternate=null,Vv(d)),l.child=null,l.deletions=null,l.sibling=null,l.tag===5&&(d=l.stateNode,d!==null&&(delete d[Es],delete d[ic],delete d[up],delete d[T3],delete d[M3])),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 Hv(l){return l.tag===5||l.tag===3||l.tag===4}function Wv(l){e:for(;;){for(;l.sibling===null;){if(l.return===null||Hv(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 Yp(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=Pd));else if(x!==4&&(l=l.child,l!==null))for(Yp(l,d,p),l=l.sibling;l!==null;)Yp(l,d,p),l=l.sibling}function Qp(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(Qp(l,d,p),l=l.sibling;l!==null;)Qp(l,d,p),l=l.sibling}var zn=null,ls=!1;function Fi(l,d,p){for(p=p.child;p!==null;)Uv(l,d,p),p=p.sibling}function Uv(l,d,p){if(Re&&typeof Re.onCommitFiberUnmount=="function")try{Re.onCommitFiberUnmount(V,p)}catch{}switch(p.tag){case 5:Yn||Xo(p,d);case 6:var x=zn,k=ls;zn=null,Fi(l,d,p),zn=x,ls=k,zn!==null&&(ls?(l=zn,p=p.stateNode,l.nodeType===8?l.parentNode.removeChild(p):l.removeChild(p)):zn.removeChild(p.stateNode));break;case 18:zn!==null&&(ls?(l=zn,p=p.stateNode,l.nodeType===8?dp(l.parentNode,p):l.nodeType===1&&dp(l,p),Gl(l)):dp(zn,p.stateNode));break;case 4:x=zn,k=ls,zn=p.stateNode.containerInfo,ls=!0,Fi(l,d,p),zn=x,ls=k;break;case 0:case 11:case 14:case 15:if(!Yn&&(x=p.updateQueue,x!==null&&(x=x.lastEffect,x!==null))){k=x=x.next;do{var S=k,T=S.destroy;S=S.tag,T!==void 0&&((S&2)!==0||(S&4)!==0)&&Gp(p,d,T),k=k.next}while(k!==x)}Fi(l,d,p);break;case 1:if(!Yn&&(Xo(p,d),x=p.stateNode,typeof x.componentWillUnmount=="function"))try{x.props=p.memoizedProps,x.state=p.memoizedState,x.componentWillUnmount()}catch(B){ln(p,d,B)}Fi(l,d,p);break;case 21:Fi(l,d,p);break;case 22:p.mode&1?(Yn=(x=Yn)||p.memoizedState!==null,Fi(l,d,p),Yn=x):Fi(l,d,p);break;default:Fi(l,d,p)}}function Kv(l){var d=l.updateQueue;if(d!==null){l.updateQueue=null;var p=l.stateNode;p===null&&(p=l.stateNode=new U3),d.forEach(function(x){var k=tE.bind(null,l,x);p.has(x)||(p.add(x),x.then(k,k))})}}function cs(l,d){var p=d.deletions;if(p!==null)for(var x=0;xk&&(k=T),x&=~S}if(x=k,x=Tt()-x,x=(120>x?120:480>x?480:1080>x?1080:1920>x?1920:3e3>x?3e3:4320>x?4320:1960*G3(x/1960))-x,10l?16:l,Vi===null)var x=!1;else{if(l=Vi,Vi=null,ou=0,(mt&6)!==0)throw Error(n(331));var k=mt;for(mt|=4,De=l.current;De!==null;){var S=De,T=S.child;if((De.flags&16)!==0){var B=S.deletions;if(B!==null){for(var q=0;qTt()-em?Ka(l,0):Zp|=p),Nr(l,d)}function ib(l,d){d===0&&((l.mode&1)===0?d=1:(d=_n,_n<<=1,(_n&130023424)===0&&(_n=4194304)));var p=dr();l=ri(l,d),l!==null&&(Qs(l,d,p),Nr(l,p))}function eE(l){var d=l.memoizedState,p=0;d!==null&&(p=d.retryLane),ib(l,p)}function tE(l,d){var p=0;switch(l.tag){case 13:var x=l.stateNode,k=l.memoizedState;k!==null&&(p=k.retryLane);break;case 19:x=l.stateNode;break;default:throw Error(n(314))}x!==null&&x.delete(d),ib(l,p)}var ab;ab=function(l,d,p){if(l!==null)if(l.memoizedProps!==d.pendingProps||xr.current)vr=!0;else{if((l.lanes&p)===0&&(d.flags&128)===0)return vr=!1,V3(l,d,p);vr=(l.flags&131072)!==0}else vr=!1,Yt&&(d.flags&1048576)!==0&&$y(d,$d,d.index);switch(d.lanes=0,d.tag){case 2:var x=d.type;eu(l,d),l=d.pendingProps;var k=Ho(d,qn.current);Jo(d,p),k=Ip(null,d,x,l,k,p);var S=Rp();return d.flags|=1,typeof k=="object"&&k!==null&&typeof k.render=="function"&&k.$$typeof===void 0?(d.tag=1,d.memoizedState=null,d.updateQueue=null,yr(x)?(S=!0,Ld(d)):S=!1,d.memoizedState=k.state!==null&&k.state!==void 0?k.state:null,kp(d),k.updater=Xd,d.stateNode=k,k._reactInternals=d,zp(d,x,l,p),d=Vp(null,d,x,!0,S,p)):(d.tag=0,Yt&&S&&pp(d),cr(null,d,k,p),d=d.child),d;case 16:x=d.elementType;e:{switch(eu(l,d),l=d.pendingProps,k=x._init,x=k(x._payload),d.type=x,k=d.tag=rE(x),l=as(x,l),k){case 0:d=Bp(null,d,x,l,p);break e;case 1:d=Rv(null,d,x,l,p);break e;case 11:d=Ev(null,d,x,l,p);break e;case 14:d=Tv(null,d,x,as(x.type,l),p);break e}throw Error(n(306,x,""))}return d;case 0:return x=d.type,k=d.pendingProps,k=d.elementType===x?k:as(x,k),Bp(l,d,x,k,p);case 1:return x=d.type,k=d.pendingProps,k=d.elementType===x?k:as(x,k),Rv(l,d,x,k,p);case 3:e:{if(Pv(d),l===null)throw Error(n(387));x=d.pendingProps,S=d.memoizedState,k=S.element,Gy(l,d),Ud(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){k=Qo(Error(n(423)),d),d=Ov(l,d,x,p,k);break e}else if(x!==k){k=Qo(Error(n(424)),d),d=Ov(l,d,x,p,k);break e}else for(Mr=Oi(d.stateNode.containerInfo.firstChild),Tr=d,Yt=!0,is=null,p=Ky(d,null,x,p),d.child=p;p;)p.flags=p.flags&-3|4096,p=p.sibling;else{if(Ko(),x===k){d=ii(l,d,p);break e}cr(l,d,x,p)}d=d.child}return d;case 5:return Qy(d),l===null&&xp(d),x=d.type,k=d.pendingProps,S=l!==null?l.memoizedProps:null,T=k.children,lp(x,k)?T=null:S!==null&&lp(x,S)&&(d.flags|=32),Iv(l,d),cr(l,d,T,p),d.child;case 6:return l===null&&xp(d),null;case 13:return Dv(l,d,p);case 4:return Sp(d,d.stateNode.containerInfo),x=d.pendingProps,l===null?d.child=qo(d,null,x,p):cr(l,d,x,p),d.child;case 11:return x=d.type,k=d.pendingProps,k=d.elementType===x?k:as(x,k),Ev(l,d,x,k,p);case 7:return cr(l,d,d.pendingProps,p),d.child;case 8:return cr(l,d,d.pendingProps.children,p),d.child;case 12:return cr(l,d,d.pendingProps.children,p),d.child;case 10:e:{if(x=d.type._context,k=d.pendingProps,S=d.memoizedProps,T=k.value,Lt(Vd,x._currentValue),x._currentValue=T,S!==null)if(ss(S.value,T)){if(S.children===k.children&&!xr.current){d=ii(l,d,p);break e}}else for(S=d.child,S!==null&&(S.return=d);S!==null;){var B=S.dependencies;if(B!==null){T=S.child;for(var q=B.firstContext;q!==null;){if(q.context===x){if(S.tag===1){q=si(-1,p&-p),q.tag=2;var ue=S.updateQueue;if(ue!==null){ue=ue.shared;var we=ue.pending;we===null?q.next=q:(q.next=we.next,we.next=q),ue.pending=q}}S.lanes|=p,q=S.alternate,q!==null&&(q.lanes|=p),wp(S.return,p,d),B.lanes|=p;break}q=q.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,B=T.alternate,B!==null&&(B.lanes|=p),wp(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}cr(l,d,k.children,p),d=d.child}return d;case 9:return k=d.type,x=d.pendingProps.children,Jo(d,p),k=Vr(k),x=x(k),d.flags|=1,cr(l,d,x,p),d.child;case 14:return x=d.type,k=as(x,d.pendingProps),k=as(x.type,k),Tv(l,d,x,k,p);case 15:return Mv(l,d,d.type,d.pendingProps,p);case 17:return x=d.type,k=d.pendingProps,k=d.elementType===x?k:as(x,k),eu(l,d),d.tag=1,yr(x)?(l=!0,Ld(d)):l=!1,Jo(d,p),bv(d,x,k),zp(d,x,k,p),Vp(null,d,x,!0,l,p);case 19:return _v(l,d,p);case 22:return Av(l,d,p)}throw Error(n(156,d.tag))};function ob(l,d){return To(l,d)}function nE(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 Ur(l,d,p,x){return new nE(l,d,p,x)}function lm(l){return l=l.prototype,!(!l||!l.isReactComponent)}function rE(l){if(typeof l=="function")return lm(l)?1:0;if(l!=null){if(l=l.$$typeof,l===ne)return 11;if(l===R)return 14}return 2}function Ui(l,d){var p=l.alternate;return p===null?(p=Ur(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 uu(l,d,p,x,k,S){var T=2;if(x=l,typeof l=="function")lm(l)&&(T=1);else if(typeof l=="string")T=5;else e:switch(l){case D:return Ga(p.children,k,S,d);case P:T=8,k|=8;break;case L:return l=Ur(12,p,d,k|2),l.elementType=L,l.lanes=S,l;case J:return l=Ur(13,p,d,k),l.elementType=J,l.lanes=S,l;case U:return l=Ur(19,p,d,k),l.elementType=U,l.lanes=S,l;case re:return hu(p,k,S,d);default:if(typeof l=="object"&&l!==null)switch(l.$$typeof){case _:T=10;break e;case X:T=9;break e;case ne:T=11;break e;case R:T=14;break e;case F:T=16,x=null;break e}throw Error(n(130,l==null?l:typeof l,""))}return d=Ur(T,p,d,k),d.elementType=l,d.type=x,d.lanes=S,d}function Ga(l,d,p,x){return l=Ur(7,l,x,d),l.lanes=p,l}function hu(l,d,p,x){return l=Ur(22,l,x,d),l.elementType=re,l.lanes=p,l.stateNode={isHidden:!1},l}function cm(l,d,p){return l=Ur(6,l,null,d),l.lanes=p,l}function dm(l,d,p){return d=Ur(4,l.children!==null?l.children:[],l.key,d),d.lanes=p,d.stateNode={containerInfo:l.containerInfo,pendingChildren:null,implementation:l.implementation},d}function sE(l,d,p,x,k){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=Ro(0),this.expirationTimes=Ro(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ro(0),this.identifierPrefix=x,this.onRecoverableError=k,this.mutableSourceEagerHydrationData=null}function um(l,d,p,x,k,S,T,B,q){return l=new sE(l,d,p,B,q),d===1?(d=1,S===!0&&(d|=8)):d=0,S=Ur(3,null,null,d),l.current=S,S.stateNode=l,S.memoizedState={element:x,isDehydrated:p,cache:null,transitions:null,pendingSuspenseBoundaries:null},kp(S),l}function iE(l,d,p){var x=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),xm.exports=xE(),xm.exports}var Nb;function yE(){if(Nb)return vu;Nb=1;var t=Ew();return vu.createRoot=t.createRoot,vu.hydrateRoot=t.hydrateRoot,vu}var vE=yE(),dd=Ew();const Tw=Cw(dd);/** + * @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 Kc(){return Kc=Object.assign?Object.assign.bind():function(t){for(var e=1;e"u")throw new Error(e)}function Ex(t,e){if(!t){typeof console<"u"&&console.warn(e);try{throw new Error(e)}catch{}}}function NE(){return Math.random().toString(36).substr(2,8)}function jb(t,e){return{usr:t.state,key:t.key,idx:e}}function xg(t,e,n,r){return n===void 0&&(n=null),Kc({pathname:typeof t=="string"?t:t.pathname,search:"",hash:""},typeof e=="string"?Rl(e):e,{state:n,key:e&&e.key||r||NE()})}function sh(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 Rl(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 wE(t,e,n,r){r===void 0&&(r={});let{window:i=document.defaultView,v5Compat:a=!1}=r,o=i.history,c=sa.Pop,u=null,h=f();h==null&&(h=0,o.replaceState(Kc({},o.state,{idx:h}),""));function f(){return(o.state||{idx:null}).idx}function m(){c=sa.Pop;let w=f(),N=w==null?null:w-h;h=w,u&&u({action:c,location:j.location,delta:N})}function g(w,N){c=sa.Push;let C=xg(j.location,w,N);h=f()+1;let E=jb(C,h),M=j.createHref(C);try{o.pushState(E,"",M)}catch(I){if(I instanceof DOMException&&I.name==="DataCloneError")throw I;i.location.assign(M)}a&&u&&u({action:c,location:j.location,delta:1})}function y(w,N){c=sa.Replace;let C=xg(j.location,w,N);h=f();let E=jb(C,h),M=j.createHref(C);o.replaceState(E,"",M),a&&u&&u({action:c,location:j.location,delta:0})}function b(w){let N=i.location.origin!=="null"?i.location.origin:i.location.href,C=typeof w=="string"?w:sh(w);return C=C.replace(/ $/,"%20"),xn(N,"No window.location.(origin|href) available to create URL for href: "+C),new URL(C,N)}let j={get action(){return c},get location(){return t(i,o)},listen(w){if(u)throw new Error("A history only accepts one active listener");return i.addEventListener(wb,m),u=w,()=>{i.removeEventListener(wb,m),u=null}},createHref(w){return e(i,w)},createURL:b,encodeLocation(w){let N=b(w);return{pathname:N.pathname,search:N.search,hash:N.hash}},push:g,replace:y,go(w){return o.go(w)}};return j}var kb;(function(t){t.data="data",t.deferred="deferred",t.redirect="redirect",t.error="error"})(kb||(kb={}));function jE(t,e,n){return n===void 0&&(n="/"),kE(t,e,n)}function kE(t,e,n,r){let i=typeof e=="string"?Rl(e):e,a=Tx(i.pathname||"/",n);if(a==null)return null;let o=Mw(t);SE(o);let c=null;for(let u=0;c==null&&u{let u={relativePath:c===void 0?a.path||"":c,caseSensitive:a.caseSensitive===!0,childrenIndex:o,route:a};u.relativePath.startsWith("/")&&(xn(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=ca([r,u.relativePath]),f=n.concat(u);a.children&&a.children.length>0&&(xn(a.index!==!0,"Index routes must not have child routes. Please remove "+('all child routes from route path "'+h+'".')),Mw(a.children,e,f,h)),!(a.path==null&&!a.index)&&e.push({path:h,score:RE(h,a.index),routesMeta:f})};return t.forEach((a,o)=>{var c;if(a.path===""||!((c=a.path)!=null&&c.includes("?")))i(a,o);else for(let u of Aw(a.path))i(a,o,u)}),e}function Aw(t){let e=t.split("/");if(e.length===0)return[];let[n,...r]=e,i=n.endsWith("?"),a=n.replace(/\?$/,"");if(r.length===0)return i?[a,""]:[a];let o=Aw(r.join("/")),c=[];return c.push(...o.map(u=>u===""?a:[a,u].join("/"))),i&&c.push(...o),c.map(u=>t.startsWith("/")&&u===""?"/":u)}function SE(t){t.sort((e,n)=>e.score!==n.score?n.score-e.score:PE(e.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}const CE=/^:[\w-]+$/,EE=3,TE=2,ME=1,AE=10,IE=-2,Sb=t=>t==="*";function RE(t,e){let n=t.split("/"),r=n.length;return n.some(Sb)&&(r+=IE),e&&(r+=TE),n.filter(i=>!Sb(i)).reduce((i,a)=>i+(CE.test(a)?EE:a===""?ME:AE),r)}function PE(t,e){return t.length===e.length&&t.slice(0,-1).every((r,i)=>r===e[i])?t[t.length-1]-e[e.length-1]:0}function OE(t,e,n){let{routesMeta:r}=t,i={},a="/",o=[];for(let c=0;c{let{paramName:g,isOptional:y}=f;if(g==="*"){let j=c[m]||"";o=a.slice(0,a.length-j.length).replace(/(.)\/+$/,"$1")}const b=c[m];return y&&!b?h[g]=void 0:h[g]=(b||"").replace(/%2F/g,"/"),h},{}),pathname:a,pathnameBase:o,pattern:t}}function LE(t,e,n){e===void 0&&(e=!1),n===void 0&&(n=!0),Ex(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=[],i="^"+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:"*"}),i+=t==="*"||t==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?i+="\\/*$":t!==""&&t!=="/"&&(i+="(?:(?=\\/|$))"),[new RegExp(i,e?void 0:"i"),r]}function _E(t){try{return t.split("/").map(e=>decodeURIComponent(e).replace(/\//g,"%2F")).join("/")}catch(e){return Ex(!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 Tx(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 zE=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,$E=t=>zE.test(t);function FE(t,e){e===void 0&&(e="/");let{pathname:n,search:r="",hash:i=""}=typeof t=="string"?Rl(t):t,a;if(n)if($E(n))a=n;else{if(n.includes("//")){let o=n;n=n.replace(/\/\/+/g,"/"),Ex(!1,"Pathnames cannot have embedded double slashes - normalizing "+(o+" -> "+n))}n.startsWith("/")?a=Cb(n.substring(1),"/"):a=Cb(n,e)}else a=e;return{pathname:a,search:HE(r),hash:WE(i)}}function Cb(t,e){let n=e.replace(/\/+$/,"").split("/");return t.split("/").forEach(i=>{i===".."?n.length>1&&n.pop():i!=="."&&n.push(i)}),n.length>1?n.join("/"):"/"}function bm(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 and the router will parse it for you.'}function BE(t){return t.filter((e,n)=>n===0||e.route.path&&e.route.path.length>0)}function Mx(t,e){let n=BE(t);return e?n.map((r,i)=>i===n.length-1?r.pathname:r.pathnameBase):n.map(r=>r.pathnameBase)}function Ax(t,e,n,r){r===void 0&&(r=!1);let i;typeof t=="string"?i=Rl(t):(i=Kc({},t),xn(!i.pathname||!i.pathname.includes("?"),bm("?","pathname","search",i)),xn(!i.pathname||!i.pathname.includes("#"),bm("#","pathname","hash",i)),xn(!i.search||!i.search.includes("#"),bm("#","search","hash",i)));let a=t===""||i.pathname==="",o=a?"/":i.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;i.pathname=g.join("/")}c=m>=0?e[m]:"/"}let u=FE(i,c),h=o&&o!=="/"&&o.endsWith("/"),f=(a||o===".")&&n.endsWith("/");return!u.pathname.endsWith("/")&&(h||f)&&(u.pathname+="/"),u}const ca=t=>t.join("/").replace(/\/\/+/g,"/"),VE=t=>t.replace(/\/+$/,"").replace(/^\/*/,"/"),HE=t=>!t||t==="?"?"":t.startsWith("?")?t:"?"+t,WE=t=>!t||t==="#"?"":t.startsWith("#")?t:"#"+t;function UE(t){return t!=null&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.internal=="boolean"&&"data"in t}const Iw=["post","put","patch","delete"];new Set(Iw);const KE=["get",...Iw];new Set(KE);/** + * 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 qc(){return qc=Object.assign?Object.assign.bind():function(t){for(var e=1;e{c.current=!0}),v.useCallback(function(h,f){if(f===void 0&&(f={}),!c.current)return;if(typeof h=="number"){r.go(h);return}let m=Ax(h,JSON.parse(o),a,f.relative==="path");t==null&&e!=="/"&&(m.pathname=m.pathname==="/"?e:ca([e,m.pathname])),(f.replace?r.replace:r.push)(m,f.state,f)},[e,r,o,a,t])}const YE=v.createContext(null);function QE(t){let e=v.useContext(wi).outlet;return e&&v.createElement(YE.Provider,{value:t},e)}function Ow(t,e){let{relative:n}=e===void 0?{}:e,{future:r}=v.useContext(Na),{matches:i}=v.useContext(wi),{pathname:a}=wa(),o=JSON.stringify(Mx(i,r.v7_relativeSplatPath));return v.useMemo(()=>Ax(t,JSON.parse(o),a,n==="path"),[t,o,a,n])}function XE(t,e){return ZE(t,e)}function ZE(t,e,n,r){Pl()||xn(!1);let{navigator:i}=v.useContext(Na),{matches:a}=v.useContext(wi),o=a[a.length-1],c=o?o.params:{};o&&o.pathname;let u=o?o.pathnameBase:"/";o&&o.route;let h=wa(),f;if(e){var m;let w=typeof e=="string"?Rl(e):e;u==="/"||(m=w.pathname)!=null&&m.startsWith(u)||xn(!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 b=jE(t,{pathname:y}),j=sT(b&&b.map(w=>Object.assign({},w,{params:Object.assign({},c,w.params),pathname:ca([u,i.encodeLocation?i.encodeLocation(w.pathname).pathname:w.pathname]),pathnameBase:w.pathnameBase==="/"?u:ca([u,i.encodeLocation?i.encodeLocation(w.pathnameBase).pathname:w.pathnameBase])})),a,n,r);return e&&j?v.createElement(cf.Provider,{value:{location:qc({pathname:"/",search:"",hash:"",state:null,key:"default"},f),navigationType:sa.Pop}},j):j}function eT(){let t=lT(),e=UE(t)?t.status+" "+t.statusText:t instanceof Error?t.message:JSON.stringify(t),n=t instanceof Error?t.stack:null,i={padding:"0.5rem",backgroundColor:"rgba(200,200,200, 0.5)"};return v.createElement(v.Fragment,null,v.createElement("h2",null,"Unexpected Application Error!"),v.createElement("h3",{style:{fontStyle:"italic"}},e),n?v.createElement("pre",{style:i},n):null,null)}const tT=v.createElement(eT,null);class nT extends v.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?v.createElement(wi.Provider,{value:this.props.routeContext},v.createElement(Rw.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function rT(t){let{routeContext:e,match:n,children:r}=t,i=v.useContext(Ix);return i&&i.static&&i.staticContext&&(n.route.errorElement||n.route.ErrorBoundary)&&(i.staticContext._deepestRenderedBoundaryId=n.route.id),v.createElement(wi.Provider,{value:e},r)}function sT(t,e,n,r){var i;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=(i=n)==null?void 0:i.errors;if(c!=null){let f=o.findIndex(m=>m.route.id&&(c==null?void 0:c[m.route.id])!==void 0);f>=0||xn(!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=0?o=o.slice(0,h+1):o=[o[0]];break}}}return o.reduceRight((f,m,g)=>{let y,b=!1,j=null,w=null;n&&(y=c&&m.route.id?c[m.route.id]:void 0,j=m.route.errorElement||tT,u&&(h<0&&g===0?(dT("route-fallback"),b=!0,w=null):h===g&&(b=!0,w=m.route.hydrateFallbackElement||null)));let N=e.concat(o.slice(0,g+1)),C=()=>{let E;return y?E=j:b?E=w:m.route.Component?E=v.createElement(m.route.Component,null):m.route.element?E=m.route.element:E=f,v.createElement(rT,{match:m,routeContext:{outlet:f,matches:N,isDataRoute:n!=null},children:E})};return n&&(m.route.ErrorBoundary||m.route.errorElement||g===0)?v.createElement(nT,{location:n.location,revalidation:n.revalidation,component:j,error:y,children:C(),routeContext:{outlet:null,matches:N,isDataRoute:!0}}):C()},null)}var Dw=(function(t){return t.UseBlocker="useBlocker",t.UseRevalidator="useRevalidator",t.UseNavigateStable="useNavigate",t})(Dw||{}),Lw=(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})(Lw||{});function iT(t){let e=v.useContext(Ix);return e||xn(!1),e}function aT(t){let e=v.useContext(qE);return e||xn(!1),e}function oT(t){let e=v.useContext(wi);return e||xn(!1),e}function _w(t){let e=oT(),n=e.matches[e.matches.length-1];return n.route.id||xn(!1),n.route.id}function lT(){var t;let e=v.useContext(Rw),n=aT(),r=_w();return e!==void 0?e:(t=n.errors)==null?void 0:t[r]}function cT(){let{router:t}=iT(Dw.UseNavigateStable),e=_w(Lw.UseNavigateStable),n=v.useRef(!1);return Pw(()=>{n.current=!0}),v.useCallback(function(i,a){a===void 0&&(a={}),n.current&&(typeof i=="number"?t.navigate(i):t.navigate(i,qc({fromRouteId:e},a)))},[t,e])}const Eb={};function dT(t,e,n){Eb[t]||(Eb[t]=!0)}function uT(t,e){t==null||t.v7_startTransition,t==null||t.v7_relativeSplatPath}function Nm(t){let{to:e,replace:n,state:r,relative:i}=t;Pl()||xn(!1);let{future:a,static:o}=v.useContext(Na),{matches:c}=v.useContext(wi),{pathname:u}=wa(),h=ja(),f=Ax(e,Mx(c,a.v7_relativeSplatPath),u,i==="path"),m=JSON.stringify(f);return v.useEffect(()=>h(JSON.parse(m),{replace:n,state:r,relative:i}),[h,m,i,n,r]),null}function hT(t){return QE(t.context)}function Wt(t){xn(!1)}function fT(t){let{basename:e="/",children:n=null,location:r,navigationType:i=sa.Pop,navigator:a,static:o=!1,future:c}=t;Pl()&&xn(!1);let u=e.replace(/^\/*/,"/"),h=v.useMemo(()=>({basename:u,navigator:a,static:o,future:qc({v7_relativeSplatPath:!1},c)}),[u,c,a,o]);typeof r=="string"&&(r=Rl(r));let{pathname:f="/",search:m="",hash:g="",state:y=null,key:b="default"}=r,j=v.useMemo(()=>{let w=Tx(f,u);return w==null?null:{location:{pathname:w,search:m,hash:g,state:y,key:b},navigationType:i}},[u,f,m,g,y,b,i]);return j==null?null:v.createElement(Na.Provider,{value:h},v.createElement(cf.Provider,{children:n,value:j}))}function pT(t){let{children:e,location:n}=t;return XE(yg(e),n)}new Promise(()=>{});function yg(t,e){e===void 0&&(e=[]);let n=[];return v.Children.forEach(t,(r,i)=>{if(!v.isValidElement(r))return;let a=[...e,i];if(r.type===v.Fragment){n.push.apply(n,yg(r.props.children,a));return}r.type!==Wt&&xn(!1),!r.props.index||!r.props.children||xn(!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=yg(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 vg(){return vg=Object.assign?Object.assign.bind():function(t){for(var e=1;e=0)&&(n[i]=t[i]);return n}function gT(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function xT(t,e){return t.button===0&&(!e||e==="_self")&&!gT(t)}function bg(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(i=>[n,i]):[[n,r]])},[]))}function yT(t,e){let n=bg(t);return e&&e.forEach((r,i)=>{n.has(i)||e.getAll(i).forEach(a=>{n.append(i,a)})}),n}const vT=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset","viewTransition"],bT="6";try{window.__reactRouterVersion=bT}catch{}const NT="startTransition",Tb=lf[NT];function wT(t){let{basename:e,children:n,future:r,window:i}=t,a=v.useRef();a.current==null&&(a.current=bE({window:i,v5Compat:!0}));let o=a.current,[c,u]=v.useState({action:o.action,location:o.location}),{v7_startTransition:h}=r||{},f=v.useCallback(m=>{h&&Tb?Tb(()=>u(m)):u(m)},[u,h]);return v.useLayoutEffect(()=>o.listen(f),[o,f]),v.useEffect(()=>uT(r),[r]),v.createElement(fT,{basename:e,children:n,location:c.location,navigationType:c.action,navigator:o,future:r})}const jT=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",kT=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Ng=v.forwardRef(function(e,n){let{onClick:r,relative:i,reloadDocument:a,replace:o,state:c,target:u,to:h,preventScrollReset:f,viewTransition:m}=e,g=mT(e,vT),{basename:y}=v.useContext(Na),b,j=!1;if(typeof h=="string"&&kT.test(h)&&(b=h,jT))try{let E=new URL(window.location.href),M=h.startsWith("//")?new URL(E.protocol+h):new URL(h),I=Tx(M.pathname,y);M.origin===E.origin&&I!=null?h=I+M.search+M.hash:j=!0}catch{}let w=GE(h,{relative:i}),N=ST(h,{replace:o,state:c,target:u,preventScrollReset:f,relative:i,viewTransition:m});function C(E){r&&r(E),E.defaultPrevented||N(E)}return v.createElement("a",vg({},g,{href:b||w,onClick:j||a?r:C,ref:n,target:u}))});var Mb;(function(t){t.UseScrollRestoration="useScrollRestoration",t.UseSubmit="useSubmit",t.UseSubmitFetcher="useSubmitFetcher",t.UseFetcher="useFetcher",t.useViewTransitionState="useViewTransitionState"})(Mb||(Mb={}));var Ab;(function(t){t.UseFetcher="useFetcher",t.UseFetchers="useFetchers",t.UseScrollRestoration="useScrollRestoration"})(Ab||(Ab={}));function ST(t,e){let{target:n,replace:r,state:i,preventScrollReset:a,relative:o,viewTransition:c}=e===void 0?{}:e,u=ja(),h=wa(),f=Ow(t,{relative:o});return v.useCallback(m=>{if(xT(m,n)){m.preventDefault();let g=r!==void 0?r:sh(h)===sh(f);u(t,{replace:g,state:i,preventScrollReset:a,relative:o,viewTransition:c})}},[h,u,f,r,i,n,t,a,o,c])}function zw(t){let e=v.useRef(bg(t)),n=v.useRef(!1),r=wa(),i=v.useMemo(()=>yT(r.search,n.current?null:e.current),[r.search]),a=ja(),o=v.useCallback((c,u)=>{const h=bg(typeof c=="function"?c(i):c);n.current=!0,a("?"+h,u)},[a,i]);return[i,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 CT=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),ET=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,r)=>r?r.toUpperCase():n.toLowerCase()),Ib=t=>{const e=ET(t);return e.charAt(0).toUpperCase()+e.slice(1)},$w=(...t)=>t.filter((e,n,r)=>!!e&&e.trim()!==""&&r.indexOf(e)===n).join(" ").trim(),TT=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 MT={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 AT=v.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:i="",children:a,iconNode:o,...c},u)=>v.createElement("svg",{ref:u,...MT,width:e,height:e,stroke:t,strokeWidth:r?Number(n)*24/Number(e):n,className:$w("lucide",i),...!a&&!TT(c)&&{"aria-hidden":"true"},...c},[...o.map(([h,f])=>v.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 Ce=(t,e)=>{const n=v.forwardRef(({className:r,...i},a)=>v.createElement(AT,{ref:a,iconNode:e,className:$w(`lucide-${CT(Ib(t))}`,`lucide-${t}`,r),...i}));return n.displayName=Ib(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 IT=[["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"}]],wm=Ce("arrow-up-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 RT=[["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"}]],Rb=Ce("bitcoin",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 PT=[["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"}]],OT=Ce("bold",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:"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"}]],ps=Ce("book-open",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:"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"}]],ih=Ce("calendar",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=[["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"}]],zT=Ce("chart-column",_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:"M20 6 9 17l-5-5",key:"1gmf2c"}]],df=Ce("check",$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=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Gc=Ce("chevron-down",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=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],VT=Ce("chevron-left",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 HT=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],fl=Ce("chevron-right",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:"m18 15-6-6-6 6",key:"153udz"}]],Fw=Ce("chevron-up",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=[["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"}]],KT=Ce("circle-alert",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=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],Pb=Ce("circle-check-big",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=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],wg=Ce("circle-check",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=[["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"}]],Bw=Ce("circle-question-mark",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=[["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"}]],jm=Ce("circle-user",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=[["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"}]],Vw=Ce("circle-x",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 XT=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],jg=Ce("clock",XT);/** + * @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:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]],eM=Ce("code",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 tM=[["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"}]],Hw=Ce("copy",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 nM=[["rect",{width:"20",height:"14",x:"2",y:"5",rx:"2",key:"ynyp8z"}],["line",{x1:"2",x2:"22",y1:"10",y2:"10",key:"1b3vmo"}]],Ob=Ce("credit-card",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 rM=[["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"}]],xl=Ce("crown",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=[["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"}]],ah=Ce("dollar-sign",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 iM=[["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"}]],aM=Ce("download",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 oM=[["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"}]],_s=Ce("external-link",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:"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"}]],oh=Ce("eye",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:"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"}]],dM=Ce("file-text",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=[["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"}]],Ww=Ce("funnel",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=[["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"}]],fM=Ce("gift",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=[["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"}]],mM=Ce("git-merge",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=[["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"}]],kg=Ce("globe",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 xM=[["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"}]],yM=Ce("graduation-cap",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 vM=[["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"}]],oi=Ce("grip-vertical",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 bM=[["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"}]],NM=Ce("handshake",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 wM=[["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"}]],Db=Ce("hash",wM);/** + * @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=[["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"}]],kM=Ce("heading-1",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 SM=[["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"}]],CM=Ce("heading-2",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 EM=[["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"}]],TM=Ce("heading-3",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 MM=[["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"}]],AM=Ce("house",MM);/** + * @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=[["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"}]],Uw=Ce("image",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 RM=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],bu=Ce("info",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 PM=[["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"}]],OM=Ce("italic",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 DM=[["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"}]],LM=Ce("key",DM);/** + * @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 _M=[["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"}]],zM=Ce("layout-dashboard",_M);/** + * @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 $M=[["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"}]],ms=Ce("link-2",$M);/** + * @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:"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"}]],Sg=Ce("link",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 BM=[["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"}]],VM=Ce("list-ordered",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 HM=[["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"}]],WM=Ce("list",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=[["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"}]],KM=Ce("lock",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:"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"}]],GM=Ce("log-out",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=[["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"}]],Kw=Ce("map-pin",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:"M4 5h16",key:"1tepv9"}],["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 19h16",key:"1djgab"}]],QM=Ce("menu",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:"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"}]],ZM=Ce("message-circle",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 eA=[["path",{d:"M5 12h14",key:"1ays0h"}]],tA=Ce("minus",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 nA=[["polygon",{points:"3 11 22 2 13 21 11 13 3 11",key:"1ltx0t"}]],pl=Ce("navigation",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 rA=[["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"}]],sA=Ce("palette",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:"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"}]],_t=Ce("pen-line",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=[["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"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]],qw=Ce("pencil",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=[["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"}]],lA=Ce("percent",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:"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"}]],dA=Ce("phone",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:"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"}]],hA=Ce("pin",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 fA=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],dn=Ce("plus",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=[["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"}]],Lb=Ce("qr-code",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 mA=[["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"}]],gA=Ce("quote",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 xA=[["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"}]],yA=Ce("redo",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 vA=[["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"}]],Ge=Ce("refresh-cw",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=[["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"}]],gn=Ce("save",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 NA=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],da=Ce("search",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 wA=[["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"}]],jA=Ce("send",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 kA=[["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"}]],so=Ce("settings",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 SA=[["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"}]],Nu=Ce("settings-2",SA);/** + * @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:"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"}]],Rx=Ce("shield-check",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:"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"}]],Cg=Ce("shopping-bag",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=[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]],uo=Ce("smartphone",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:"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"}]],ml=Ce("star",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:"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"}]],IA=Ce("strikethrough",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:"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"}]],PA=Ce("table",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 OA=[["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"}]],qu=Ce("tag",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:"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"}]],Bn=Ce("trash-2",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 7h6v6",key:"box55l"}],["path",{d:"m22 7-8.5 8.5-5-5L2 17",key:"1t1m79"}]],Oc=Ce("trending-up",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:"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"}]],_b=Ce("trophy",_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:"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"}]],Gw=Ce("undo-2",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:"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"}]],FA=Ce("undo",$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 BA=[["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"}]],lh=Ce("upload",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 VA=[["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"}]],Eg=Ce("user-plus",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 HA=[["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"}]],yl=Ce("user",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 WA=[["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"}]],Un=Ce("users",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 UA=[["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"}]],jl=Ce("wallet",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 KA=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],hr=Ce("x",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 qA=[["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"}]],ia=Ce("zap",qA),Px="admin_token";function Ox(){try{return localStorage.getItem(Px)}catch{return null}}function GA(t){try{localStorage.setItem(Px,t)}catch{}}function JA(){try{localStorage.removeItem(Px)}catch{}}const YA="https://soulapi.quwanzhi.com",QA=15e3,XA=()=>{const t="https://soulapi.quwanzhi.com";return t.length>0?t.replace(/\/$/,""):YA};function ho(t){const e=XA(),n=t.startsWith("/")?t:`/${t}`;return e?`${e}${n}`:n}async function uf(t,e={}){const{data:n,...r}=e,i=ho(t),a=new Headers(r.headers),o=Ox();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(),QA),f=await fetch(i,{...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 Le(t,e){return uf(t,{...e,method:"GET"})}function Nt(t,e,n){return uf(t,{...n,method:"POST",data:e})}function Mt(t,e,n){return uf(t,{...n,method:"PUT",data:e})}function Ps(t,e){return uf(t,{...e,method:"DELETE"})}const ZA=[{icon:zM,label:"数据概览",href:"/dashboard"},{icon:ps,label:"内容管理",href:"/content"},{icon:Un,label:"用户管理",href:"/users"},{icon:mM,label:"找伙伴",href:"/find-partner"},{icon:jl,label:"推广中心",href:"/distribution"}];function e5(){const t=wa(),e=ja(),[n,r]=v.useState(!1),[i,a]=v.useState(!1);v.useEffect(()=>{r(!0)},[]),v.useEffect(()=>{if(!n)return;a(!1);let c=!1;return Le("/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()=>{JA();try{await Nt("/api/admin/logout",{})}catch{}e("/login",{replace:!0})};return!n||!i?s.jsxs("div",{className:"flex min-h-screen bg-[#0a1628]",children:[s.jsx("div",{className:"w-64 bg-[#0f2137] border-r border-gray-700/50"}),s.jsx("div",{className:"flex-1 flex items-center justify-center",children:s.jsx("div",{className:"text-[#38bdac]",children:"加载中..."})})]}):s.jsxs("div",{className:"flex min-h-screen bg-[#0a1628]",children:[s.jsxs("div",{className:"w-64 bg-[#0f2137] flex flex-col border-r border-gray-700/50 shadow-xl",children:[s.jsxs("div",{className:"p-6 border-b border-gray-700/50",children:[s.jsx("h1",{className:"text-xl font-bold text-[#38bdac]",children:"管理后台"}),s.jsx("p",{className:"text-xs text-gray-400 mt-1",children:"Soul创业派对"})]}),s.jsxs("nav",{className:"flex-1 p-4 space-y-1 overflow-y-auto",children:[ZA.map(c=>{const u=t.pathname===c.href;return s.jsxs(Ng,{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:[s.jsx(c.icon,{className:"w-5 h-5 shrink-0"}),s.jsx("span",{className:"text-sm",children:c.label})]},c.href)}),s.jsx("div",{className:"pt-4 mt-4 border-t border-gray-700/50",children:s.jsxs(Ng,{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:[s.jsx(so,{className:"w-5 h-5 shrink-0"}),s.jsx("span",{className:"text-sm",children:"系统设置"})]})})]}),s.jsx("div",{className:"p-4 border-t border-gray-700/50 space-y-1",children:s.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:[s.jsx(GM,{className:"w-5 h-5"}),s.jsx("span",{className:"text-sm",children:"退出登录"})]})})]}),s.jsx("div",{className:"flex-1 overflow-auto bg-[#0a1628] min-w-0",children:s.jsx("div",{className:"w-full min-w-[1024px] min-h-full",children:s.jsx(hT,{})})})]})}function zb(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}function Dx(...t){return e=>{let n=!1;const r=t.map(i=>{const a=zb(i,e);return!n&&typeof a=="function"&&(n=!0),a});if(n)return()=>{for(let i=0;i{let{children:a,...o}=r;Jw(a)&&typeof ch=="function"&&(a=ch(a._payload));const c=v.Children.toArray(a),u=c.find(i5);if(u){const h=u.props.children,f=c.map(m=>m===u?v.Children.count(h)>1?v.Children.only(null):v.isValidElement(h)?h.props.children:null:m);return s.jsx(e,{...o,ref:i,children:v.isValidElement(h)?v.cloneElement(h,void 0,f):null})}return s.jsx(e,{...o,ref:i,children:a})});return n.displayName=`${t}.Slot`,n}var Qw=Yw("Slot");function r5(t){const e=v.forwardRef((n,r)=>{let{children:i,...a}=n;if(Jw(i)&&typeof ch=="function"&&(i=ch(i._payload)),v.isValidElement(i)){const o=o5(i),c=a5(a,i.props);return i.type!==v.Fragment&&(c.ref=r?Dx(r,o):o),v.cloneElement(i,c)}return v.Children.count(i)>1?v.Children.only(null):null});return e.displayName=`${t}.SlotClone`,e}var s5=Symbol("radix.slottable");function i5(t){return v.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===s5}function a5(t,e){const n={...e};for(const r in e){const i=t[r],a=e[r];/^on[A-Z]/.test(r)?i&&a?n[r]=(...c)=>{const u=a(...c);return i(...c),u}:i&&(n[r]=i):r==="style"?n[r]={...i,...a}:r==="className"&&(n[r]=[i,a].filter(Boolean).join(" "))}return{...t,...n}}function o5(t){var r,i;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=(i=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:i.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}function Xw(t){var e,n,r="";if(typeof t=="string"||typeof t=="number")r+=t;else if(typeof t=="object")if(Array.isArray(t)){var i=t.length;for(e=0;etypeof t=="boolean"?`${t}`:t===0?"0":t,Fb=Zw,ej=(t,e)=>n=>{var r;if((e==null?void 0:e.variants)==null)return Fb(t,n==null?void 0:n.class,n==null?void 0:n.className);const{variants:i,defaultVariants:a}=e,o=Object.keys(i).map(h=>{const f=n==null?void 0:n[h],m=a==null?void 0:a[h];if(f===null)return null;const g=$b(f)||$b(m);return i[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(b=>{let[j,w]=b;return Array.isArray(w)?w.includes({...a,...c}[j]):{...a,...c}[j]===w})?[...h,m,g]:h},[]);return Fb(t,o,u,n==null?void 0:n.class,n==null?void 0:n.className)},l5=(t,e)=>{const n=new Array(t.length+e.length);for(let r=0;r({classGroupId:t,validator:e}),tj=(t=new Map,e=null,n)=>({nextPart:t,validators:e,classGroupId:n}),dh="-",Bb=[],d5="arbitrary..",u5=t=>{const e=f5(t),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=t;return{getClassGroupId:o=>{if(o.startsWith("[")&&o.endsWith("]"))return h5(o);const c=o.split(dh),u=c[0]===""&&c.length>1?1:0;return nj(c,u,e)},getConflictingClassGroupIds:(o,c)=>{if(c){const u=r[o],h=n[o];return u?h?l5(h,u):u:h||Bb}return n[o]||Bb}}},nj=(t,e,n)=>{if(t.length-e===0)return n.classGroupId;const i=t[e],a=n.nextPart.get(i);if(a){const h=nj(t,e+1,a);if(h)return h}const o=n.validators;if(o===null)return;const c=e===0?t.join(dh):t.slice(e).join(dh),u=o.length;for(let h=0;ht.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const e=t.slice(1,-1),n=e.indexOf(":"),r=e.slice(0,n);return r?d5+r:void 0})(),f5=t=>{const{theme:e,classGroups:n}=t;return p5(n,e)},p5=(t,e)=>{const n=tj();for(const r in t){const i=t[r];Lx(i,n,r,e)}return n},Lx=(t,e,n,r)=>{const i=t.length;for(let a=0;a{if(typeof t=="string"){g5(t,e,n);return}if(typeof t=="function"){x5(t,e,n,r);return}y5(t,e,n,r)},g5=(t,e,n)=>{const r=t===""?e:rj(e,t);r.classGroupId=n},x5=(t,e,n,r)=>{if(v5(t)){Lx(t(r),e,n,r);return}e.validators===null&&(e.validators=[]),e.validators.push(c5(n,t))},y5=(t,e,n,r)=>{const i=Object.entries(t),a=i.length;for(let o=0;o{let n=t;const r=e.split(dh),i=r.length;for(let a=0;a"isThemeGetter"in t&&t.isThemeGetter===!0,b5=t=>{if(t<1)return{get:()=>{},set:()=>{}};let e=0,n=Object.create(null),r=Object.create(null);const i=(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 i(a,o),o},set(a,o){a in n?n[a]=o:i(a,o)}}},Tg="!",Vb=":",N5=[],Hb=(t,e,n,r,i)=>({modifiers:t,hasImportantModifier:e,baseClassName:n,maybePostfixModifierPosition:r,isExternal:i}),w5=t=>{const{prefix:e,experimentalParseClassName:n}=t;let r=i=>{const a=[];let o=0,c=0,u=0,h;const f=i.length;for(let j=0;ju?h-u:void 0;return Hb(a,y,g,b)};if(e){const i=e+Vb,a=r;r=o=>o.startsWith(i)?a(o.slice(i.length)):Hb(N5,!1,o,void 0,!0)}if(n){const i=r;r=a=>n({className:a,parseClassName:i})}return r},j5=t=>{const e=new Map;return t.orderSensitiveModifiers.forEach((n,r)=>{e.set(n,1e6+r)}),n=>{const r=[];let i=[];for(let a=0;a0&&(i.sort(),r.push(...i),i=[]),r.push(o)):i.push(o)}return i.length>0&&(i.sort(),r.push(...i)),r}},k5=t=>({cache:b5(t.cacheSize),parseClassName:w5(t),sortModifiers:j5(t),...u5(t)}),S5=/\s+/,C5=(t,e)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:i,sortModifiers:a}=e,o=[],c=t.trim().split(S5);let u="";for(let h=c.length-1;h>=0;h-=1){const f=c[h],{isExternal:m,modifiers:g,hasImportantModifier:y,baseClassName:b,maybePostfixModifierPosition:j}=n(f);if(m){u=f+(u.length>0?" "+u:u);continue}let w=!!j,N=r(w?b.substring(0,j):b);if(!N){if(!w){u=f+(u.length>0?" "+u:u);continue}if(N=r(b),!N){u=f+(u.length>0?" "+u:u);continue}w=!1}const C=g.length===0?"":g.length===1?g[0]:a(g).join(":"),E=y?C+Tg:C,M=E+N;if(o.indexOf(M)>-1)continue;o.push(M);const I=i(N,w);for(let O=0;O0?" "+u:u)}return u},E5=(...t)=>{let e=0,n,r,i="";for(;e{if(typeof t=="string")return t;let e,n="";for(let r=0;r{let n,r,i,a;const o=u=>{const h=e.reduce((f,m)=>m(f),t());return n=k5(h),r=n.cache.get,i=n.cache.set,a=c,c(u)},c=u=>{const h=r(u);if(h)return h;const f=C5(u,n);return i(u,f),f};return a=o,(...u)=>a(E5(...u))},M5=[],Cn=t=>{const e=n=>n[t]||M5;return e.isThemeGetter=!0,e},ij=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,aj=/^\((?:(\w[\w-]*):)?(.+)\)$/i,A5=/^\d+\/\d+$/,I5=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,R5=/\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$/,P5=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,O5=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,D5=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,nl=t=>A5.test(t),ct=t=>!!t&&!Number.isNaN(Number(t)),qi=t=>!!t&&Number.isInteger(Number(t)),km=t=>t.endsWith("%")&&ct(t.slice(0,-1)),li=t=>I5.test(t),L5=()=>!0,_5=t=>R5.test(t)&&!P5.test(t),oj=()=>!1,z5=t=>O5.test(t),$5=t=>D5.test(t),F5=t=>!ze(t)&&!$e(t),B5=t=>Ol(t,dj,oj),ze=t=>ij.test(t),Ja=t=>Ol(t,uj,_5),Sm=t=>Ol(t,K5,ct),Wb=t=>Ol(t,lj,oj),V5=t=>Ol(t,cj,$5),wu=t=>Ol(t,hj,z5),$e=t=>aj.test(t),wc=t=>Dl(t,uj),H5=t=>Dl(t,q5),Ub=t=>Dl(t,lj),W5=t=>Dl(t,dj),U5=t=>Dl(t,cj),ju=t=>Dl(t,hj,!0),Ol=(t,e,n)=>{const r=ij.exec(t);return r?r[1]?e(r[1]):n(r[2]):!1},Dl=(t,e,n=!1)=>{const r=aj.exec(t);return r?r[1]?e(r[1]):n:!1},lj=t=>t==="position"||t==="percentage",cj=t=>t==="image"||t==="url",dj=t=>t==="length"||t==="size"||t==="bg-size",uj=t=>t==="length",K5=t=>t==="number",q5=t=>t==="family-name",hj=t=>t==="shadow",G5=()=>{const t=Cn("color"),e=Cn("font"),n=Cn("text"),r=Cn("font-weight"),i=Cn("tracking"),a=Cn("leading"),o=Cn("breakpoint"),c=Cn("container"),u=Cn("spacing"),h=Cn("radius"),f=Cn("shadow"),m=Cn("inset-shadow"),g=Cn("text-shadow"),y=Cn("drop-shadow"),b=Cn("blur"),j=Cn("perspective"),w=Cn("aspect"),N=Cn("ease"),C=Cn("animate"),E=()=>["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"],I=()=>[...M(),$e,ze],O=()=>["auto","hidden","clip","visible","scroll"],D=()=>["auto","contain","none"],P=()=>[$e,ze,u],L=()=>[nl,"full","auto",...P()],_=()=>[qi,"none","subgrid",$e,ze],X=()=>["auto",{span:["full",qi,$e,ze]},qi,$e,ze],ne=()=>[qi,"auto",$e,ze],J=()=>["auto","min","max","fr",$e,ze],U=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],R=()=>["start","end","center","stretch","center-safe","end-safe"],F=()=>["auto",...P()],re=()=>[nl,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...P()],z=()=>[t,$e,ze],ae=()=>[...M(),Ub,Wb,{position:[$e,ze]}],G=()=>["no-repeat",{repeat:["","x","y","space","round"]}],$=()=>["auto","cover","contain",W5,B5,{size:[$e,ze]}],H=()=>[km,wc,Ja],ce=()=>["","none","full",h,$e,ze],W=()=>["",ct,wc,Ja],fe=()=>["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"],de=()=>[ct,km,Ub,Wb],he=()=>["","none",b,$e,ze],Ne=()=>["none",ct,$e,ze],Te=()=>["none",ct,$e,ze],Ve=()=>[ct,$e,ze],He=()=>[nl,"full",...P()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[li],breakpoint:[li],color:[L5],container:[li],"drop-shadow":[li],ease:["in","out","in-out"],font:[F5],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[li],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[li],shadow:[li],spacing:["px",ct],text:[li],"text-shadow":[li],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",nl,ze,$e,w]}],container:["container"],columns:[{columns:[ct,ze,$e,c]}],"break-after":[{"break-after":E()}],"break-before":[{"break-before":E()}],"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:I()}],overflow:[{overflow:O()}],"overflow-x":[{"overflow-x":O()}],"overflow-y":[{"overflow-y":O()}],overscroll:[{overscroll:D()}],"overscroll-x":[{"overscroll-x":D()}],"overscroll-y":[{"overscroll-y":D()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:L()}],"inset-x":[{"inset-x":L()}],"inset-y":[{"inset-y":L()}],start:[{start:L()}],end:[{end:L()}],top:[{top:L()}],right:[{right:L()}],bottom:[{bottom:L()}],left:[{left:L()}],visibility:["visible","invisible","collapse"],z:[{z:[qi,"auto",$e,ze]}],basis:[{basis:[nl,"full","auto",c,...P()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[ct,nl,"auto","initial","none",ze]}],grow:[{grow:["",ct,$e,ze]}],shrink:[{shrink:["",ct,$e,ze]}],order:[{order:[qi,"first","last","none",$e,ze]}],"grid-cols":[{"grid-cols":_()}],"col-start-end":[{col:X()}],"col-start":[{"col-start":ne()}],"col-end":[{"col-end":ne()}],"grid-rows":[{"grid-rows":_()}],"row-start-end":[{row:X()}],"row-start":[{"row-start":ne()}],"row-end":[{"row-end":ne()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":J()}],"auto-rows":[{"auto-rows":J()}],gap:[{gap:P()}],"gap-x":[{"gap-x":P()}],"gap-y":[{"gap-y":P()}],"justify-content":[{justify:[...U(),"normal"]}],"justify-items":[{"justify-items":[...R(),"normal"]}],"justify-self":[{"justify-self":["auto",...R()]}],"align-content":[{content:["normal",...U()]}],"align-items":[{items:[...R(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...R(),{baseline:["","last"]}]}],"place-content":[{"place-content":U()}],"place-items":[{"place-items":[...R(),"baseline"]}],"place-self":[{"place-self":["auto",...R()]}],p:[{p:P()}],px:[{px:P()}],py:[{py:P()}],ps:[{ps:P()}],pe:[{pe:P()}],pt:[{pt:P()}],pr:[{pr:P()}],pb:[{pb:P()}],pl:[{pl:P()}],m:[{m:F()}],mx:[{mx:F()}],my:[{my:F()}],ms:[{ms:F()}],me:[{me:F()}],mt:[{mt:F()}],mr:[{mr:F()}],mb:[{mb:F()}],ml:[{ml:F()}],"space-x":[{"space-x":P()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":P()}],"space-y-reverse":["space-y-reverse"],size:[{size:re()}],w:[{w:[c,"screen",...re()]}],"min-w":[{"min-w":[c,"screen","none",...re()]}],"max-w":[{"max-w":[c,"screen","none","prose",{screen:[o]},...re()]}],h:[{h:["screen","lh",...re()]}],"min-h":[{"min-h":["screen","lh","none",...re()]}],"max-h":[{"max-h":["screen","lh",...re()]}],"font-size":[{text:["base",n,wc,Ja]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[r,$e,Sm]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",km,ze]}],"font-family":[{font:[H5,ze,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:[i,$e,ze]}],"line-clamp":[{"line-clamp":[ct,"none",$e,Sm]}],leading:[{leading:[a,...P()]}],"list-image":[{"list-image":["none",$e,ze]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",$e,ze]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:z()}],"text-color":[{text:z()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...fe(),"wavy"]}],"text-decoration-thickness":[{decoration:[ct,"from-font","auto",$e,Ja]}],"text-decoration-color":[{decoration:z()}],"underline-offset":[{"underline-offset":[ct,"auto",$e,ze]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:P()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",$e,ze]}],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",$e,ze]}],"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:G()}],"bg-size":[{bg:$()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},qi,$e,ze],radial:["",$e,ze],conic:[qi,$e,ze]},U5,V5]}],"bg-color":[{bg:z()}],"gradient-from-pos":[{from:H()}],"gradient-via-pos":[{via:H()}],"gradient-to-pos":[{to:H()}],"gradient-from":[{from:z()}],"gradient-via":[{via:z()}],"gradient-to":[{to:z()}],rounded:[{rounded:ce()}],"rounded-s":[{"rounded-s":ce()}],"rounded-e":[{"rounded-e":ce()}],"rounded-t":[{"rounded-t":ce()}],"rounded-r":[{"rounded-r":ce()}],"rounded-b":[{"rounded-b":ce()}],"rounded-l":[{"rounded-l":ce()}],"rounded-ss":[{"rounded-ss":ce()}],"rounded-se":[{"rounded-se":ce()}],"rounded-ee":[{"rounded-ee":ce()}],"rounded-es":[{"rounded-es":ce()}],"rounded-tl":[{"rounded-tl":ce()}],"rounded-tr":[{"rounded-tr":ce()}],"rounded-br":[{"rounded-br":ce()}],"rounded-bl":[{"rounded-bl":ce()}],"border-w":[{border:W()}],"border-w-x":[{"border-x":W()}],"border-w-y":[{"border-y":W()}],"border-w-s":[{"border-s":W()}],"border-w-e":[{"border-e":W()}],"border-w-t":[{"border-t":W()}],"border-w-r":[{"border-r":W()}],"border-w-b":[{"border-b":W()}],"border-w-l":[{"border-l":W()}],"divide-x":[{"divide-x":W()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":W()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...fe(),"hidden","none"]}],"divide-style":[{divide:[...fe(),"hidden","none"]}],"border-color":[{border:z()}],"border-color-x":[{"border-x":z()}],"border-color-y":[{"border-y":z()}],"border-color-s":[{"border-s":z()}],"border-color-e":[{"border-e":z()}],"border-color-t":[{"border-t":z()}],"border-color-r":[{"border-r":z()}],"border-color-b":[{"border-b":z()}],"border-color-l":[{"border-l":z()}],"divide-color":[{divide:z()}],"outline-style":[{outline:[...fe(),"none","hidden"]}],"outline-offset":[{"outline-offset":[ct,$e,ze]}],"outline-w":[{outline:["",ct,wc,Ja]}],"outline-color":[{outline:z()}],shadow:[{shadow:["","none",f,ju,wu]}],"shadow-color":[{shadow:z()}],"inset-shadow":[{"inset-shadow":["none",m,ju,wu]}],"inset-shadow-color":[{"inset-shadow":z()}],"ring-w":[{ring:W()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:z()}],"ring-offset-w":[{"ring-offset":[ct,Ja]}],"ring-offset-color":[{"ring-offset":z()}],"inset-ring-w":[{"inset-ring":W()}],"inset-ring-color":[{"inset-ring":z()}],"text-shadow":[{"text-shadow":["none",g,ju,wu]}],"text-shadow-color":[{"text-shadow":z()}],opacity:[{opacity:[ct,$e,ze]}],"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":[ct]}],"mask-image-linear-from-pos":[{"mask-linear-from":de()}],"mask-image-linear-to-pos":[{"mask-linear-to":de()}],"mask-image-linear-from-color":[{"mask-linear-from":z()}],"mask-image-linear-to-color":[{"mask-linear-to":z()}],"mask-image-t-from-pos":[{"mask-t-from":de()}],"mask-image-t-to-pos":[{"mask-t-to":de()}],"mask-image-t-from-color":[{"mask-t-from":z()}],"mask-image-t-to-color":[{"mask-t-to":z()}],"mask-image-r-from-pos":[{"mask-r-from":de()}],"mask-image-r-to-pos":[{"mask-r-to":de()}],"mask-image-r-from-color":[{"mask-r-from":z()}],"mask-image-r-to-color":[{"mask-r-to":z()}],"mask-image-b-from-pos":[{"mask-b-from":de()}],"mask-image-b-to-pos":[{"mask-b-to":de()}],"mask-image-b-from-color":[{"mask-b-from":z()}],"mask-image-b-to-color":[{"mask-b-to":z()}],"mask-image-l-from-pos":[{"mask-l-from":de()}],"mask-image-l-to-pos":[{"mask-l-to":de()}],"mask-image-l-from-color":[{"mask-l-from":z()}],"mask-image-l-to-color":[{"mask-l-to":z()}],"mask-image-x-from-pos":[{"mask-x-from":de()}],"mask-image-x-to-pos":[{"mask-x-to":de()}],"mask-image-x-from-color":[{"mask-x-from":z()}],"mask-image-x-to-color":[{"mask-x-to":z()}],"mask-image-y-from-pos":[{"mask-y-from":de()}],"mask-image-y-to-pos":[{"mask-y-to":de()}],"mask-image-y-from-color":[{"mask-y-from":z()}],"mask-image-y-to-color":[{"mask-y-to":z()}],"mask-image-radial":[{"mask-radial":[$e,ze]}],"mask-image-radial-from-pos":[{"mask-radial-from":de()}],"mask-image-radial-to-pos":[{"mask-radial-to":de()}],"mask-image-radial-from-color":[{"mask-radial-from":z()}],"mask-image-radial-to-color":[{"mask-radial-to":z()}],"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":[ct]}],"mask-image-conic-from-pos":[{"mask-conic-from":de()}],"mask-image-conic-to-pos":[{"mask-conic-to":de()}],"mask-image-conic-from-color":[{"mask-conic-from":z()}],"mask-image-conic-to-color":[{"mask-conic-to":z()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:ae()}],"mask-repeat":[{mask:G()}],"mask-size":[{mask:$()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",$e,ze]}],filter:[{filter:["","none",$e,ze]}],blur:[{blur:he()}],brightness:[{brightness:[ct,$e,ze]}],contrast:[{contrast:[ct,$e,ze]}],"drop-shadow":[{"drop-shadow":["","none",y,ju,wu]}],"drop-shadow-color":[{"drop-shadow":z()}],grayscale:[{grayscale:["",ct,$e,ze]}],"hue-rotate":[{"hue-rotate":[ct,$e,ze]}],invert:[{invert:["",ct,$e,ze]}],saturate:[{saturate:[ct,$e,ze]}],sepia:[{sepia:["",ct,$e,ze]}],"backdrop-filter":[{"backdrop-filter":["","none",$e,ze]}],"backdrop-blur":[{"backdrop-blur":he()}],"backdrop-brightness":[{"backdrop-brightness":[ct,$e,ze]}],"backdrop-contrast":[{"backdrop-contrast":[ct,$e,ze]}],"backdrop-grayscale":[{"backdrop-grayscale":["",ct,$e,ze]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[ct,$e,ze]}],"backdrop-invert":[{"backdrop-invert":["",ct,$e,ze]}],"backdrop-opacity":[{"backdrop-opacity":[ct,$e,ze]}],"backdrop-saturate":[{"backdrop-saturate":[ct,$e,ze]}],"backdrop-sepia":[{"backdrop-sepia":["",ct,$e,ze]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":P()}],"border-spacing-x":[{"border-spacing-x":P()}],"border-spacing-y":[{"border-spacing-y":P()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",$e,ze]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[ct,"initial",$e,ze]}],ease:[{ease:["linear","initial",N,$e,ze]}],delay:[{delay:[ct,$e,ze]}],animate:[{animate:["none",C,$e,ze]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[j,$e,ze]}],"perspective-origin":[{"perspective-origin":I()}],rotate:[{rotate:Ne()}],"rotate-x":[{"rotate-x":Ne()}],"rotate-y":[{"rotate-y":Ne()}],"rotate-z":[{"rotate-z":Ne()}],scale:[{scale:Te()}],"scale-x":[{"scale-x":Te()}],"scale-y":[{"scale-y":Te()}],"scale-z":[{"scale-z":Te()}],"scale-3d":["scale-3d"],skew:[{skew:Ve()}],"skew-x":[{"skew-x":Ve()}],"skew-y":[{"skew-y":Ve()}],transform:[{transform:[$e,ze,"","none","gpu","cpu"]}],"transform-origin":[{origin:I()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:He()}],"translate-x":[{"translate-x":He()}],"translate-y":[{"translate-y":He()}],"translate-z":[{"translate-z":He()}],"translate-none":["translate-none"],accent:[{accent:z()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:z()}],"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",$e,ze]}],"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":P()}],"scroll-mx":[{"scroll-mx":P()}],"scroll-my":[{"scroll-my":P()}],"scroll-ms":[{"scroll-ms":P()}],"scroll-me":[{"scroll-me":P()}],"scroll-mt":[{"scroll-mt":P()}],"scroll-mr":[{"scroll-mr":P()}],"scroll-mb":[{"scroll-mb":P()}],"scroll-ml":[{"scroll-ml":P()}],"scroll-p":[{"scroll-p":P()}],"scroll-px":[{"scroll-px":P()}],"scroll-py":[{"scroll-py":P()}],"scroll-ps":[{"scroll-ps":P()}],"scroll-pe":[{"scroll-pe":P()}],"scroll-pt":[{"scroll-pt":P()}],"scroll-pr":[{"scroll-pr":P()}],"scroll-pb":[{"scroll-pb":P()}],"scroll-pl":[{"scroll-pl":P()}],"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",$e,ze]}],fill:[{fill:["none",...z()]}],"stroke-w":[{stroke:[ct,wc,Ja,Sm]}],stroke:[{stroke:["none",...z()]}],"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"]}},J5=T5(G5);function Ct(...t){return J5(Zw(t))}const Y5=ej("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 ee({className:t,variant:e,size:n,asChild:r=!1,...i}){const a=r?Qw:"button";return s.jsx(a,{"data-slot":"button",className:Ct(Y5({variant:e,size:n,className:t})),...i})}function oe({className:t,type:e,...n}){return s.jsx("input",{type:e,"data-slot":"input",className:Ct("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 Q5(){const t=ja(),[e,n]=v.useState(""),[r,i]=v.useState(""),[a,o]=v.useState(""),[c,u]=v.useState(!1),h=async()=>{o(""),u(!0);try{const f=await Nt("/api/admin",{username:e.trim(),password:r});if((f==null?void 0:f.success)!==!1&&(f!=null&&f.token)){GA(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 s.jsxs("div",{className:"min-h-screen bg-[#0a1628] flex items-center justify-center p-4",children:[s.jsxs("div",{className:"absolute inset-0 overflow-hidden",children:[s.jsx("div",{className:"absolute top-1/4 left-1/4 w-96 h-96 bg-[#38bdac]/5 rounded-full blur-3xl"}),s.jsx("div",{className:"absolute bottom-1/4 right-1/4 w-96 h-96 bg-blue-500/5 rounded-full blur-3xl"})]}),s.jsxs("div",{className:"w-full max-w-md relative z-10",children:[s.jsxs("div",{className:"text-center mb-8",children:[s.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:s.jsx(Rx,{className:"w-8 h-8 text-[#38bdac]"})}),s.jsx("h1",{className:"text-2xl font-bold text-white mb-2",children:"管理后台"}),s.jsx("p",{className:"text-gray-400",children:"一场SOUL的创业实验场"})]}),s.jsxs("div",{className:"bg-[#0f2137] rounded-2xl p-8 shadow-xl border border-gray-700/50 backdrop-blur-xl",children:[s.jsx("h2",{className:"text-xl font-semibold text-white mb-6 text-center",children:"管理员登录"}),s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-gray-400 text-sm mb-2",children:"用户名"}),s.jsxs("div",{className:"relative",children:[s.jsx(yl,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-5 h-5 text-gray-500"}),s.jsx(oe,{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]"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-gray-400 text-sm mb-2",children:"密码"}),s.jsxs("div",{className:"relative",children:[s.jsx(KM,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-5 h-5 text-gray-500"}),s.jsx(oe,{type:"password",value:r,onChange:f=>i(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&&s.jsx("div",{className:"bg-red-500/10 text-red-400 text-sm p-3 rounded-lg border border-red-500/20",children:a}),s.jsx(ee,{onClick:h,disabled:c,className:"w-full bg-[#38bdac] hover:bg-[#2da396] text-white py-5 disabled:opacity-50",children:c?"登录中...":"登录"})]})]}),s.jsx("p",{className:"text-center text-gray-500 text-xs mt-6",children:"Soul创业实验场 · 后台管理系统"})]})]})}const Me=v.forwardRef(({className:t,...e},n)=>s.jsx("div",{ref:n,className:Ct("rounded-xl border bg-card text-card-foreground shadow",t),...e}));Me.displayName="Card";const nt=v.forwardRef(({className:t,...e},n)=>s.jsx("div",{ref:n,className:Ct("flex flex-col space-y-1.5 p-6",t),...e}));nt.displayName="CardHeader";const rt=v.forwardRef(({className:t,...e},n)=>s.jsx("h3",{ref:n,className:Ct("font-semibold leading-none tracking-tight",t),...e}));rt.displayName="CardTitle";const $t=v.forwardRef(({className:t,...e},n)=>s.jsx("p",{ref:n,className:Ct("text-sm text-muted-foreground",t),...e}));$t.displayName="CardDescription";const Ae=v.forwardRef(({className:t,...e},n)=>s.jsx("div",{ref:n,className:Ct("p-6 pt-0",t),...e}));Ae.displayName="CardContent";const X5=v.forwardRef(({className:t,...e},n)=>s.jsx("div",{ref:n,className:Ct("flex items-center p-6 pt-0",t),...e}));X5.displayName="CardFooter";const Z5={success:{bg:"#f0fdf4",border:"#22c55e",icon:"✓"},error:{bg:"#fef2f2",border:"#ef4444",icon:"✕"},info:{bg:"#eff6ff",border:"#3b82f6",icon:"ℹ"}};function Cm(t,e="info",n=3e3){const r=`toast-${Date.now()}`,i=Z5[e],a=document.createElement("div");a.id=r,a.setAttribute("role","alert"),Object.assign(a.style,{position:"fixed",top:"24px",right:"24px",zIndex:"9999",display:"flex",alignItems:"center",gap:"10px",padding:"12px 18px",borderRadius:"10px",background:i.bg,border:`1.5px solid ${i.border}`,boxShadow:"0 4px 20px rgba(0,0,0,.12)",fontSize:"14px",color:"#1a1a1a",fontWeight:"500",maxWidth:"380px",lineHeight:"1.5",opacity:"0",transform:"translateY(-8px)",transition:"opacity .22s ease, transform .22s ease",pointerEvents:"none"});const o=document.createElement("span");Object.assign(o.style,{width:"20px",height:"20px",borderRadius:"50%",background:i.border,color:"#fff",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"12px",fontWeight:"700",flexShrink:"0"}),o.textContent=i.icon;const c=document.createElement("span");c.textContent=t,a.appendChild(o),a.appendChild(c),document.body.appendChild(a),requestAnimationFrame(()=>{a.style.opacity="1",a.style.transform="translateY(0)"});const u=setTimeout(()=>h(r),n);function h(f){clearTimeout(u);const m=document.getElementById(f);m&&(m.style.opacity="0",m.style.transform="translateY(-8px)",setTimeout(()=>{var g;return(g=m.parentNode)==null?void 0:g.removeChild(m)},250))}}const ie={success:(t,e)=>Cm(t,"success",e),error:(t,e)=>Cm(t,"error",e),info:(t,e)=>Cm(t,"info",e)};function at(t,e,{checkForDefaultPrevented:n=!0}={}){return function(i){if(t==null||t(i),n===!1||!i.defaultPrevented)return e==null?void 0:e(i)}}function eI(t,e){const n=v.createContext(e),r=a=>{const{children:o,...c}=a,u=v.useMemo(()=>c,Object.values(c));return s.jsx(n.Provider,{value:u,children:o})};r.displayName=t+"Provider";function i(a){const o=v.useContext(n);if(o)return o;if(e!==void 0)return e;throw new Error(`\`${a}\` must be used within \`${t}\``)}return[r,i]}function ka(t,e=[]){let n=[];function r(a,o){const c=v.createContext(o),u=n.length;n=[...n,o];const h=m=>{var N;const{scope:g,children:y,...b}=m,j=((N=g==null?void 0:g[t])==null?void 0:N[u])||c,w=v.useMemo(()=>b,Object.values(b));return s.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,b=v.useContext(y);if(b)return b;if(o!==void 0)return o;throw new Error(`\`${m}\` must be used within \`${a}\``)}return[h,f]}const i=()=>{const a=n.map(o=>v.createContext(o));return function(c){const u=(c==null?void 0:c[t])||a;return v.useMemo(()=>({[`__scope${t}`]:{...c,[t]:u}}),[c,u])}};return i.scopeName=t,[r,tI(i,...e)]}function tI(...t){const e=t[0];if(t.length===1)return e;const n=()=>{const r=t.map(i=>({useScope:i(),scopeName:i.scopeName}));return function(a){const o=r.reduce((c,{useScope:u,scopeName:h})=>{const m=u(a)[`__scope${h}`];return{...c,...m}},{});return v.useMemo(()=>({[`__scope${e.scopeName}`]:o}),[o])}};return n.scopeName=e.scopeName,n}var Xn=globalThis!=null&&globalThis.document?v.useLayoutEffect:()=>{},nI=lf[" useId ".trim().toString()]||(()=>{}),rI=0;function ua(t){const[e,n]=v.useState(nI());return Xn(()=>{n(r=>r??String(rI++))},[t]),e?`radix-${e}`:""}var sI=lf[" useInsertionEffect ".trim().toString()]||Xn;function fo({prop:t,defaultProp:e,onChange:n=()=>{},caller:r}){const[i,a,o]=iI({defaultProp:e,onChange:n}),c=t!==void 0,u=c?t:i;{const f=v.useRef(t!==void 0);v.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=v.useCallback(f=>{var m;if(c){const g=aI(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 iI({defaultProp:t,onChange:e}){const[n,r]=v.useState(t),i=v.useRef(n),a=v.useRef(e);return sI(()=>{a.current=e},[e]),v.useEffect(()=>{var o;i.current!==n&&((o=a.current)==null||o.call(a,n),i.current=n)},[n,i]),[n,r,a]}function aI(t){return typeof t=="function"}function Jc(t){const e=oI(t),n=v.forwardRef((r,i)=>{const{children:a,...o}=r,c=v.Children.toArray(a),u=c.find(cI);if(u){const h=u.props.children,f=c.map(m=>m===u?v.Children.count(h)>1?v.Children.only(null):v.isValidElement(h)?h.props.children:null:m);return s.jsx(e,{...o,ref:i,children:v.isValidElement(h)?v.cloneElement(h,void 0,f):null})}return s.jsx(e,{...o,ref:i,children:a})});return n.displayName=`${t}.Slot`,n}function oI(t){const e=v.forwardRef((n,r)=>{const{children:i,...a}=n;if(v.isValidElement(i)){const o=uI(i),c=dI(a,i.props);return i.type!==v.Fragment&&(c.ref=r?Dx(r,o):o),v.cloneElement(i,c)}return v.Children.count(i)>1?v.Children.only(null):null});return e.displayName=`${t}.SlotClone`,e}var lI=Symbol("radix.slottable");function cI(t){return v.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===lI}function dI(t,e){const n={...e};for(const r in e){const i=t[r],a=e[r];/^on[A-Z]/.test(r)?i&&a?n[r]=(...c)=>{const u=a(...c);return i(...c),u}:i&&(n[r]=i):r==="style"?n[r]={...i,...a}:r==="className"&&(n[r]=[i,a].filter(Boolean).join(" "))}return{...t,...n}}function uI(t){var r,i;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=(i=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:i.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}var hI=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],dt=hI.reduce((t,e)=>{const n=Jc(`Primitive.${e}`),r=v.forwardRef((i,a)=>{const{asChild:o,...c}=i,u=o?n:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),s.jsx(u,{...c,ref:a})});return r.displayName=`Primitive.${e}`,{...t,[e]:r}},{});function fI(t,e){t&&dd.flushSync(()=>t.dispatchEvent(e))}function ga(t){const e=v.useRef(t);return v.useEffect(()=>{e.current=t}),v.useMemo(()=>(...n)=>{var r;return(r=e.current)==null?void 0:r.call(e,...n)},[])}function pI(t,e=globalThis==null?void 0:globalThis.document){const n=ga(t);v.useEffect(()=>{const r=i=>{i.key==="Escape"&&n(i)};return e.addEventListener("keydown",r,{capture:!0}),()=>e.removeEventListener("keydown",r,{capture:!0})},[n,e])}var mI="DismissableLayer",Mg="dismissableLayer.update",gI="dismissableLayer.pointerDownOutside",xI="dismissableLayer.focusOutside",Kb,fj=v.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),_x=v.forwardRef((t,e)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:i,onFocusOutside:a,onInteractOutside:o,onDismiss:c,...u}=t,h=v.useContext(fj),[f,m]=v.useState(null),g=(f==null?void 0:f.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,y]=v.useState({}),b=St(e,D=>m(D)),j=Array.from(h.layers),[w]=[...h.layersWithOutsidePointerEventsDisabled].slice(-1),N=j.indexOf(w),C=f?j.indexOf(f):-1,E=h.layersWithOutsidePointerEventsDisabled.size>0,M=C>=N,I=bI(D=>{const P=D.target,L=[...h.branches].some(_=>_.contains(P));!M||L||(i==null||i(D),o==null||o(D),D.defaultPrevented||c==null||c())},g),O=NI(D=>{const P=D.target;[...h.branches].some(_=>_.contains(P))||(a==null||a(D),o==null||o(D),D.defaultPrevented||c==null||c())},g);return pI(D=>{C===h.layers.size-1&&(r==null||r(D),!D.defaultPrevented&&c&&(D.preventDefault(),c()))},g),v.useEffect(()=>{if(f)return n&&(h.layersWithOutsidePointerEventsDisabled.size===0&&(Kb=g.body.style.pointerEvents,g.body.style.pointerEvents="none"),h.layersWithOutsidePointerEventsDisabled.add(f)),h.layers.add(f),qb(),()=>{n&&h.layersWithOutsidePointerEventsDisabled.size===1&&(g.body.style.pointerEvents=Kb)}},[f,g,n,h]),v.useEffect(()=>()=>{f&&(h.layers.delete(f),h.layersWithOutsidePointerEventsDisabled.delete(f),qb())},[f,h]),v.useEffect(()=>{const D=()=>y({});return document.addEventListener(Mg,D),()=>document.removeEventListener(Mg,D)},[]),s.jsx(dt.div,{...u,ref:b,style:{pointerEvents:E?M?"auto":"none":void 0,...t.style},onFocusCapture:at(t.onFocusCapture,O.onFocusCapture),onBlurCapture:at(t.onBlurCapture,O.onBlurCapture),onPointerDownCapture:at(t.onPointerDownCapture,I.onPointerDownCapture)})});_x.displayName=mI;var yI="DismissableLayerBranch",vI=v.forwardRef((t,e)=>{const n=v.useContext(fj),r=v.useRef(null),i=St(e,r);return v.useEffect(()=>{const a=r.current;if(a)return n.branches.add(a),()=>{n.branches.delete(a)}},[n.branches]),s.jsx(dt.div,{...t,ref:i})});vI.displayName=yI;function bI(t,e=globalThis==null?void 0:globalThis.document){const n=ga(t),r=v.useRef(!1),i=v.useRef(()=>{});return v.useEffect(()=>{const a=c=>{if(c.target&&!r.current){let u=function(){pj(gI,n,h,{discrete:!0})};const h={originalEvent:c};c.pointerType==="touch"?(e.removeEventListener("click",i.current),i.current=u,e.addEventListener("click",i.current,{once:!0})):u()}else e.removeEventListener("click",i.current);r.current=!1},o=window.setTimeout(()=>{e.addEventListener("pointerdown",a)},0);return()=>{window.clearTimeout(o),e.removeEventListener("pointerdown",a),e.removeEventListener("click",i.current)}},[e,n]),{onPointerDownCapture:()=>r.current=!0}}function NI(t,e=globalThis==null?void 0:globalThis.document){const n=ga(t),r=v.useRef(!1);return v.useEffect(()=>{const i=a=>{a.target&&!r.current&&pj(xI,n,{originalEvent:a},{discrete:!1})};return e.addEventListener("focusin",i),()=>e.removeEventListener("focusin",i)},[e,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function qb(){const t=new CustomEvent(Mg);document.dispatchEvent(t)}function pj(t,e,n,{discrete:r}){const i=n.originalEvent.target,a=new CustomEvent(t,{bubbles:!1,cancelable:!0,detail:n});e&&i.addEventListener(t,e,{once:!0}),r?fI(i,a):i.dispatchEvent(a)}var Em="focusScope.autoFocusOnMount",Tm="focusScope.autoFocusOnUnmount",Gb={bubbles:!1,cancelable:!0},wI="FocusScope",zx=v.forwardRef((t,e)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:i,onUnmountAutoFocus:a,...o}=t,[c,u]=v.useState(null),h=ga(i),f=ga(a),m=v.useRef(null),g=St(e,j=>u(j)),y=v.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;v.useEffect(()=>{if(r){let j=function(E){if(y.paused||!c)return;const M=E.target;c.contains(M)?m.current=M:Yi(m.current,{select:!0})},w=function(E){if(y.paused||!c)return;const M=E.relatedTarget;M!==null&&(c.contains(M)||Yi(m.current,{select:!0}))},N=function(E){if(document.activeElement===document.body)for(const I of E)I.removedNodes.length>0&&Yi(c)};document.addEventListener("focusin",j),document.addEventListener("focusout",w);const C=new MutationObserver(N);return c&&C.observe(c,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",j),document.removeEventListener("focusout",w),C.disconnect()}}},[r,c,y.paused]),v.useEffect(()=>{if(c){Yb.add(y);const j=document.activeElement;if(!c.contains(j)){const N=new CustomEvent(Em,Gb);c.addEventListener(Em,h),c.dispatchEvent(N),N.defaultPrevented||(jI(TI(mj(c)),{select:!0}),document.activeElement===j&&Yi(c))}return()=>{c.removeEventListener(Em,h),setTimeout(()=>{const N=new CustomEvent(Tm,Gb);c.addEventListener(Tm,f),c.dispatchEvent(N),N.defaultPrevented||Yi(j??document.body,{select:!0}),c.removeEventListener(Tm,f),Yb.remove(y)},0)}}},[c,h,f,y]);const b=v.useCallback(j=>{if(!n&&!r||y.paused)return;const w=j.key==="Tab"&&!j.altKey&&!j.ctrlKey&&!j.metaKey,N=document.activeElement;if(w&&N){const C=j.currentTarget,[E,M]=kI(C);E&&M?!j.shiftKey&&N===M?(j.preventDefault(),n&&Yi(E,{select:!0})):j.shiftKey&&N===E&&(j.preventDefault(),n&&Yi(M,{select:!0})):N===C&&j.preventDefault()}},[n,r,y.paused]);return s.jsx(dt.div,{tabIndex:-1,...o,ref:g,onKeyDown:b})});zx.displayName=wI;function jI(t,{select:e=!1}={}){const n=document.activeElement;for(const r of t)if(Yi(r,{select:e}),document.activeElement!==n)return}function kI(t){const e=mj(t),n=Jb(e,t),r=Jb(e.reverse(),t);return[n,r]}function mj(t){const e=[],n=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const i=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||i?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)e.push(n.currentNode);return e}function Jb(t,e){for(const n of t)if(!SI(n,{upTo:e}))return n}function SI(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 CI(t){return t instanceof HTMLInputElement&&"select"in t}function Yi(t,{select:e=!1}={}){if(t&&t.focus){const n=document.activeElement;t.focus({preventScroll:!0}),t!==n&&CI(t)&&e&&t.select()}}var Yb=EI();function EI(){let t=[];return{add(e){const n=t[0];e!==n&&(n==null||n.pause()),t=Qb(t,e),t.unshift(e)},remove(e){var n;t=Qb(t,e),(n=t[0])==null||n.resume()}}}function Qb(t,e){const n=[...t],r=n.indexOf(e);return r!==-1&&n.splice(r,1),n}function TI(t){return t.filter(e=>e.tagName!=="A")}var MI="Portal",$x=v.forwardRef((t,e)=>{var c;const{container:n,...r}=t,[i,a]=v.useState(!1);Xn(()=>a(!0),[]);const o=n||i&&((c=globalThis==null?void 0:globalThis.document)==null?void 0:c.body);return o?Tw.createPortal(s.jsx(dt.div,{...r,ref:e}),o):null});$x.displayName=MI;function AI(t,e){return v.useReducer((n,r)=>e[n][r]??n,t)}var ud=t=>{const{present:e,children:n}=t,r=II(e),i=typeof n=="function"?n({present:r.isPresent}):v.Children.only(n),a=St(r.ref,RI(i));return typeof n=="function"||r.isPresent?v.cloneElement(i,{ref:a}):null};ud.displayName="Presence";function II(t){const[e,n]=v.useState(),r=v.useRef(null),i=v.useRef(t),a=v.useRef("none"),o=t?"mounted":"unmounted",[c,u]=AI(o,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return v.useEffect(()=>{const h=ku(r.current);a.current=c==="mounted"?h:"none"},[c]),Xn(()=>{const h=r.current,f=i.current;if(f!==t){const g=a.current,y=ku(h);t?u("MOUNT"):y==="none"||(h==null?void 0:h.display)==="none"?u("UNMOUNT"):u(f&&g!==y?"ANIMATION_OUT":"UNMOUNT"),i.current=t}},[t,u]),Xn(()=>{if(e){let h;const f=e.ownerDocument.defaultView??window,m=y=>{const j=ku(r.current).includes(CSS.escape(y.animationName));if(y.target===e&&j&&(u("ANIMATION_END"),!i.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=ku(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:v.useCallback(h=>{r.current=h?getComputedStyle(h):null,n(h)},[])}}function ku(t){return(t==null?void 0:t.animationName)||"none"}function RI(t){var r,i;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=(i=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:i.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}var Mm=0;function gj(){v.useEffect(()=>{const t=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",t[0]??Xb()),document.body.insertAdjacentElement("beforeend",t[1]??Xb()),Mm++,()=>{Mm===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(e=>e.remove()),Mm--}},[])}function Xb(){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 Os=function(){return Os=Object.assign||function(e){for(var n,r=1,i=arguments.length;r"u")return JI;var e=YI(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])}},XI=bj(),vl="data-scroll-locked",ZI=function(t,e,n,r){var i=t.left,a=t.top,o=t.right,c=t.gap;return n===void 0&&(n="margin"),` + .`.concat(OI,` { + overflow: hidden `).concat(r,`; + padding-right: `).concat(c,"px ").concat(r,`; + } + body[`).concat(vl,`] { + overflow: hidden `).concat(r,`; + overscroll-behavior: contain; + `).concat([e&&"position: relative ".concat(r,";"),n==="margin"&&` + padding-left: `.concat(i,`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(Gu,` { + right: `).concat(c,"px ").concat(r,`; + } + + .`).concat(Ju,` { + margin-right: `).concat(c,"px ").concat(r,`; + } + + .`).concat(Gu," .").concat(Gu,` { + right: 0 `).concat(r,`; + } + + .`).concat(Ju," .").concat(Ju,` { + margin-right: 0 `).concat(r,`; + } + + body[`).concat(vl,`] { + `).concat(DI,": ").concat(c,`px; + } +`)},e1=function(){var t=parseInt(document.body.getAttribute(vl)||"0",10);return isFinite(t)?t:0},eR=function(){v.useEffect(function(){return document.body.setAttribute(vl,(e1()+1).toString()),function(){var t=e1()-1;t<=0?document.body.removeAttribute(vl):document.body.setAttribute(vl,t.toString())}},[])},tR=function(t){var e=t.noRelative,n=t.noImportant,r=t.gapMode,i=r===void 0?"margin":r;eR();var a=v.useMemo(function(){return QI(i)},[i]);return v.createElement(XI,{styles:ZI(a,!e,i,n?"":"!important")})},Ag=!1;if(typeof window<"u")try{var Su=Object.defineProperty({},"passive",{get:function(){return Ag=!0,!0}});window.addEventListener("test",Su,Su),window.removeEventListener("test",Su,Su)}catch{Ag=!1}var rl=Ag?{passive:!1}:!1,nR=function(t){return t.tagName==="TEXTAREA"},Nj=function(t,e){if(!(t instanceof Element))return!1;var n=window.getComputedStyle(t);return n[e]!=="hidden"&&!(n.overflowY===n.overflowX&&!nR(t)&&n[e]==="visible")},rR=function(t){return Nj(t,"overflowY")},sR=function(t){return Nj(t,"overflowX")},t1=function(t,e){var n=e.ownerDocument,r=e;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var i=wj(t,r);if(i){var a=jj(t,r),o=a[1],c=a[2];if(o>c)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},iR=function(t){var e=t.scrollTop,n=t.scrollHeight,r=t.clientHeight;return[e,n,r]},aR=function(t){var e=t.scrollLeft,n=t.scrollWidth,r=t.clientWidth;return[e,n,r]},wj=function(t,e){return t==="v"?rR(e):sR(e)},jj=function(t,e){return t==="v"?iR(e):aR(e)},oR=function(t,e){return t==="h"&&e==="rtl"?-1:1},lR=function(t,e,n,r,i){var a=oR(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=jj(t,c),b=y[0],j=y[1],w=y[2],N=j-w-a*b;(b||N)&&wj(t,c)&&(m+=N,g+=b);var C=c.parentNode;c=C&&C.nodeType===Node.DOCUMENT_FRAGMENT_NODE?C.host:C}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]},n1=function(t){return[t.deltaX,t.deltaY]},r1=function(t){return t&&"current"in t?t.current:t},cR=function(t,e){return t[0]===e[0]&&t[1]===e[1]},dR=function(t){return` + .block-interactivity-`.concat(t,` {pointer-events: none;} + .allow-interactivity-`).concat(t,` {pointer-events: all;} +`)},uR=0,sl=[];function hR(t){var e=v.useRef([]),n=v.useRef([0,0]),r=v.useRef(),i=v.useState(uR++)[0],a=v.useState(bj)[0],o=v.useRef(t);v.useEffect(function(){o.current=t},[t]),v.useEffect(function(){if(t.inert){document.body.classList.add("block-interactivity-".concat(i));var j=PI([t.lockRef.current],(t.shards||[]).map(r1),!0).filter(Boolean);return j.forEach(function(w){return w.classList.add("allow-interactivity-".concat(i))}),function(){document.body.classList.remove("block-interactivity-".concat(i)),j.forEach(function(w){return w.classList.remove("allow-interactivity-".concat(i))})}}},[t.inert,t.lockRef.current,t.shards]);var c=v.useCallback(function(j,w){if("touches"in j&&j.touches.length===2||j.type==="wheel"&&j.ctrlKey)return!o.current.allowPinchZoom;var N=Cu(j),C=n.current,E="deltaX"in j?j.deltaX:C[0]-N[0],M="deltaY"in j?j.deltaY:C[1]-N[1],I,O=j.target,D=Math.abs(E)>Math.abs(M)?"h":"v";if("touches"in j&&D==="h"&&O.type==="range")return!1;var P=window.getSelection(),L=P&&P.anchorNode,_=L?L===O||L.contains(O):!1;if(_)return!1;var X=t1(D,O);if(!X)return!0;if(X?I=D:(I=D==="v"?"h":"v",X=t1(D,O)),!X)return!1;if(!r.current&&"changedTouches"in j&&(E||M)&&(r.current=I),!I)return!0;var ne=r.current||I;return lR(ne,w,j,ne==="h"?E:M)},[]),u=v.useCallback(function(j){var w=j;if(!(!sl.length||sl[sl.length-1]!==a)){var N="deltaY"in w?n1(w):Cu(w),C=e.current.filter(function(I){return I.name===w.type&&(I.target===w.target||w.target===I.shadowParent)&&cR(I.delta,N)})[0];if(C&&C.should){w.cancelable&&w.preventDefault();return}if(!C){var E=(o.current.shards||[]).map(r1).filter(Boolean).filter(function(I){return I.contains(w.target)}),M=E.length>0?c(w,E[0]):!o.current.noIsolation;M&&w.cancelable&&w.preventDefault()}}},[]),h=v.useCallback(function(j,w,N,C){var E={name:j,delta:w,target:N,should:C,shadowParent:fR(N)};e.current.push(E),setTimeout(function(){e.current=e.current.filter(function(M){return M!==E})},1)},[]),f=v.useCallback(function(j){n.current=Cu(j),r.current=void 0},[]),m=v.useCallback(function(j){h(j.type,n1(j),j.target,c(j,t.lockRef.current))},[]),g=v.useCallback(function(j){h(j.type,Cu(j),j.target,c(j,t.lockRef.current))},[]);v.useEffect(function(){return sl.push(a),t.setCallbacks({onScrollCapture:m,onWheelCapture:m,onTouchMoveCapture:g}),document.addEventListener("wheel",u,rl),document.addEventListener("touchmove",u,rl),document.addEventListener("touchstart",f,rl),function(){sl=sl.filter(function(j){return j!==a}),document.removeEventListener("wheel",u,rl),document.removeEventListener("touchmove",u,rl),document.removeEventListener("touchstart",f,rl)}},[]);var y=t.removeScrollBar,b=t.inert;return v.createElement(v.Fragment,null,b?v.createElement(a,{styles:dR(i)}):null,y?v.createElement(tR,{noRelative:t.noRelative,gapMode:t.gapMode}):null)}function fR(t){for(var e=null;t!==null;)t instanceof ShadowRoot&&(e=t.host,t=t.host),t=t.parentNode;return e}const pR=VI(vj,hR);var Fx=v.forwardRef(function(t,e){return v.createElement(hf,Os({},t,{ref:e,sideCar:pR}))});Fx.classNames=hf.classNames;var mR=function(t){if(typeof document>"u")return null;var e=Array.isArray(t)?t[0]:t;return e.ownerDocument.body},il=new WeakMap,Eu=new WeakMap,Tu={},Pm=0,kj=function(t){return t&&(t.host||kj(t.parentNode))},gR=function(t,e){return e.map(function(n){if(t.contains(n))return n;var r=kj(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})},xR=function(t,e,n,r){var i=gR(e,Array.isArray(t)?t:[t]);Tu[n]||(Tu[n]=new WeakMap);var a=Tu[n],o=[],c=new Set,u=new Set(i),h=function(m){!m||c.has(m)||(c.add(m),h(m.parentNode))};i.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),b=y!==null&&y!=="false",j=(il.get(g)||0)+1,w=(a.get(g)||0)+1;il.set(g,j),a.set(g,w),o.push(g),j===1&&b&&Eu.set(g,!0),w===1&&g.setAttribute(n,"true"),b||g.setAttribute(r,"true")}catch(N){console.error("aria-hidden: cannot operate on ",g,N)}})};return f(e),c.clear(),Pm++,function(){o.forEach(function(m){var g=il.get(m)-1,y=a.get(m)-1;il.set(m,g),a.set(m,y),g||(Eu.has(m)||m.removeAttribute(r),Eu.delete(m)),y||m.removeAttribute(n)}),Pm--,Pm||(il=new WeakMap,il=new WeakMap,Eu=new WeakMap,Tu={})}},Sj=function(t,e,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(t)?t:[t]),i=mR(t);return i?(r.push.apply(r,Array.from(i.querySelectorAll("[aria-live], script"))),xR(r,i,n,"aria-hidden")):function(){return null}},ff="Dialog",[Cj]=ka(ff),[yR,vs]=Cj(ff),Ej=t=>{const{__scopeDialog:e,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!0}=t,c=v.useRef(null),u=v.useRef(null),[h,f]=fo({prop:r,defaultProp:i??!1,onChange:a,caller:ff});return s.jsx(yR,{scope:e,triggerRef:c,contentRef:u,contentId:ua(),titleId:ua(),descriptionId:ua(),open:h,onOpenChange:f,onOpenToggle:v.useCallback(()=>f(m=>!m),[f]),modal:o,children:n})};Ej.displayName=ff;var Tj="DialogTrigger",vR=v.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,i=vs(Tj,n),a=St(e,i.triggerRef);return s.jsx(dt.button,{type:"button","aria-haspopup":"dialog","aria-expanded":i.open,"aria-controls":i.contentId,"data-state":Hx(i.open),...r,ref:a,onClick:at(t.onClick,i.onOpenToggle)})});vR.displayName=Tj;var Bx="DialogPortal",[bR,Mj]=Cj(Bx,{forceMount:void 0}),Aj=t=>{const{__scopeDialog:e,forceMount:n,children:r,container:i}=t,a=vs(Bx,e);return s.jsx(bR,{scope:e,forceMount:n,children:v.Children.map(r,o=>s.jsx(ud,{present:n||a.open,children:s.jsx($x,{asChild:!0,container:i,children:o})}))})};Aj.displayName=Bx;var uh="DialogOverlay",Ij=v.forwardRef((t,e)=>{const n=Mj(uh,t.__scopeDialog),{forceMount:r=n.forceMount,...i}=t,a=vs(uh,t.__scopeDialog);return a.modal?s.jsx(ud,{present:r||a.open,children:s.jsx(wR,{...i,ref:e})}):null});Ij.displayName=uh;var NR=Jc("DialogOverlay.RemoveScroll"),wR=v.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,i=vs(uh,n);return s.jsx(Fx,{as:NR,allowPinchZoom:!0,shards:[i.contentRef],children:s.jsx(dt.div,{"data-state":Hx(i.open),...r,ref:e,style:{pointerEvents:"auto",...r.style}})})}),po="DialogContent",Rj=v.forwardRef((t,e)=>{const n=Mj(po,t.__scopeDialog),{forceMount:r=n.forceMount,...i}=t,a=vs(po,t.__scopeDialog);return s.jsx(ud,{present:r||a.open,children:a.modal?s.jsx(jR,{...i,ref:e}):s.jsx(kR,{...i,ref:e})})});Rj.displayName=po;var jR=v.forwardRef((t,e)=>{const n=vs(po,t.__scopeDialog),r=v.useRef(null),i=St(e,n.contentRef,r);return v.useEffect(()=>{const a=r.current;if(a)return Sj(a)},[]),s.jsx(Pj,{...t,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:at(t.onCloseAutoFocus,a=>{var o;a.preventDefault(),(o=n.triggerRef.current)==null||o.focus()}),onPointerDownOutside:at(t.onPointerDownOutside,a=>{const o=a.detail.originalEvent,c=o.button===0&&o.ctrlKey===!0;(o.button===2||c)&&a.preventDefault()}),onFocusOutside:at(t.onFocusOutside,a=>a.preventDefault())})}),kR=v.forwardRef((t,e)=>{const n=vs(po,t.__scopeDialog),r=v.useRef(!1),i=v.useRef(!1);return s.jsx(Pj,{...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,i.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"&&(i.current=!0));const o=a.target;((h=n.triggerRef.current)==null?void 0:h.contains(o))&&a.preventDefault(),a.detail.originalEvent.type==="focusin"&&i.current&&a.preventDefault()}})}),Pj=v.forwardRef((t,e)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,...o}=t,c=vs(po,n),u=v.useRef(null),h=St(e,u);return gj(),s.jsxs(s.Fragment,{children:[s.jsx(zx,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:s.jsx(_x,{role:"dialog",id:c.contentId,"aria-describedby":c.descriptionId,"aria-labelledby":c.titleId,"data-state":Hx(c.open),...o,ref:h,onDismiss:()=>c.onOpenChange(!1)})}),s.jsxs(s.Fragment,{children:[s.jsx(SR,{titleId:c.titleId}),s.jsx(ER,{contentRef:u,descriptionId:c.descriptionId})]})]})}),Vx="DialogTitle",Oj=v.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,i=vs(Vx,n);return s.jsx(dt.h2,{id:i.titleId,...r,ref:e})});Oj.displayName=Vx;var Dj="DialogDescription",Lj=v.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,i=vs(Dj,n);return s.jsx(dt.p,{id:i.descriptionId,...r,ref:e})});Lj.displayName=Dj;var _j="DialogClose",zj=v.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,i=vs(_j,n);return s.jsx(dt.button,{type:"button",...r,ref:e,onClick:at(t.onClick,()=>i.onOpenChange(!1))})});zj.displayName=_j;function Hx(t){return t?"open":"closed"}var $j="DialogTitleWarning",[zV,Fj]=eI($j,{contentName:po,titleName:Vx,docsSlug:"dialog"}),SR=({titleId:t})=>{const e=Fj($j),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 v.useEffect(()=>{t&&(document.getElementById(t)||console.error(n))},[n,t]),null},CR="DialogDescriptionWarning",ER=({contentRef:t,descriptionId:e})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Fj(CR).contentName}}.`;return v.useEffect(()=>{var a;const i=(a=t.current)==null?void 0:a.getAttribute("aria-describedby");e&&i&&(document.getElementById(e)||console.warn(r))},[r,t,e]),null},TR=Ej,MR=Aj,AR=Ij,IR=Rj,RR=Oj,PR=Lj,OR=zj;function Kt(t){return s.jsx(TR,{"data-slot":"dialog",...t})}function DR(t){return s.jsx(MR,{...t})}const Bj=v.forwardRef(({className:t,...e},n)=>s.jsx(AR,{ref:n,className:Ct("fixed inset-0 z-50 bg-black/50",t),...e}));Bj.displayName="DialogOverlay";const zt=v.forwardRef(({className:t,children:e,showCloseButton:n=!0,...r},i)=>s.jsxs(DR,{children:[s.jsx(Bj,{}),s.jsxs(IR,{ref:i,"aria-describedby":void 0,className:Ct("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",t),...r,children:[e,n&&s.jsxs(OR,{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:[s.jsx(hr,{className:"h-4 w-4"}),s.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));zt.displayName="DialogContent";function qt({className:t,...e}){return s.jsx("div",{className:Ct("flex flex-col gap-2 text-center sm:text-left",t),...e})}function hn({className:t,...e}){return s.jsx("div",{className:Ct("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",t),...e})}function Gt(t){return s.jsx(RR,{className:"text-lg font-semibold leading-none",...t})}function Wx(t){return s.jsx(PR,{className:"text-sm text-muted-foreground",...t})}const LR=ej("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 Ue({className:t,variant:e,asChild:n=!1,...r}){const i=n?Qw:"span";return s.jsx(i,{className:Ct(LR({variant:e}),t),...r})}var _R=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],zR=_R.reduce((t,e)=>{const n=Yw(`Primitive.${e}`),r=v.forwardRef((i,a)=>{const{asChild:o,...c}=i,u=o?n:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),s.jsx(u,{...c,ref:a})});return r.displayName=`Primitive.${e}`,{...t,[e]:r}},{}),$R="Label",Vj=v.forwardRef((t,e)=>s.jsx(zR.label,{...t,ref:e,onMouseDown:n=>{var i;n.target.closest("button, input, select, textarea")||((i=t.onMouseDown)==null||i.call(t,n),!n.defaultPrevented&&n.detail>1&&n.preventDefault())}}));Vj.displayName=$R;var Hj=Vj;const Z=v.forwardRef(({className:t,...e},n)=>s.jsx(Hj,{ref:n,className:Ct("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",t),...e}));Z.displayName=Hj.displayName;function Ux(t){const e=t+"CollectionProvider",[n,r]=ka(e),[i,a]=n(e,{collectionRef:{current:null},itemMap:new Map}),o=j=>{const{scope:w,children:N}=j,C=ur.useRef(null),E=ur.useRef(new Map).current;return s.jsx(i,{scope:w,itemMap:E,collectionRef:C,children:N})};o.displayName=e;const c=t+"CollectionSlot",u=Jc(c),h=ur.forwardRef((j,w)=>{const{scope:N,children:C}=j,E=a(c,N),M=St(w,E.collectionRef);return s.jsx(u,{ref:M,children:C})});h.displayName=c;const f=t+"CollectionItemSlot",m="data-radix-collection-item",g=Jc(f),y=ur.forwardRef((j,w)=>{const{scope:N,children:C,...E}=j,M=ur.useRef(null),I=St(w,M),O=a(f,N);return ur.useEffect(()=>(O.itemMap.set(M,{ref:M,...E}),()=>void O.itemMap.delete(M))),s.jsx(g,{[m]:"",ref:I,children:C})});y.displayName=f;function b(j){const w=a(t+"CollectionConsumer",j);return ur.useCallback(()=>{const C=w.collectionRef.current;if(!C)return[];const E=Array.from(C.querySelectorAll(`[${m}]`));return Array.from(w.itemMap.values()).sort((O,D)=>E.indexOf(O.ref.current)-E.indexOf(D.ref.current))},[w.collectionRef,w.itemMap])}return[{Provider:o,Slot:h,ItemSlot:y},b,r]}var FR=v.createContext(void 0);function pf(t){const e=v.useContext(FR);return t||e||"ltr"}var Om="rovingFocusGroup.onEntryFocus",BR={bubbles:!1,cancelable:!0},hd="RovingFocusGroup",[Ig,Wj,VR]=Ux(hd),[HR,Uj]=ka(hd,[VR]),[WR,UR]=HR(hd),Kj=v.forwardRef((t,e)=>s.jsx(Ig.Provider,{scope:t.__scopeRovingFocusGroup,children:s.jsx(Ig.Slot,{scope:t.__scopeRovingFocusGroup,children:s.jsx(KR,{...t,ref:e})})}));Kj.displayName=hd;var KR=v.forwardRef((t,e)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:i=!1,dir:a,currentTabStopId:o,defaultCurrentTabStopId:c,onCurrentTabStopIdChange:u,onEntryFocus:h,preventScrollOnEntryFocus:f=!1,...m}=t,g=v.useRef(null),y=St(e,g),b=pf(a),[j,w]=fo({prop:o,defaultProp:c??null,onChange:u,caller:hd}),[N,C]=v.useState(!1),E=ga(h),M=Wj(n),I=v.useRef(!1),[O,D]=v.useState(0);return v.useEffect(()=>{const P=g.current;if(P)return P.addEventListener(Om,E),()=>P.removeEventListener(Om,E)},[E]),s.jsx(WR,{scope:n,orientation:r,dir:b,loop:i,currentTabStopId:j,onItemFocus:v.useCallback(P=>w(P),[w]),onItemShiftTab:v.useCallback(()=>C(!0),[]),onFocusableItemAdd:v.useCallback(()=>D(P=>P+1),[]),onFocusableItemRemove:v.useCallback(()=>D(P=>P-1),[]),children:s.jsx(dt.div,{tabIndex:N||O===0?-1:0,"data-orientation":r,...m,ref:y,style:{outline:"none",...t.style},onMouseDown:at(t.onMouseDown,()=>{I.current=!0}),onFocus:at(t.onFocus,P=>{const L=!I.current;if(P.target===P.currentTarget&&L&&!N){const _=new CustomEvent(Om,BR);if(P.currentTarget.dispatchEvent(_),!_.defaultPrevented){const X=M().filter(F=>F.focusable),ne=X.find(F=>F.active),J=X.find(F=>F.id===j),R=[ne,J,...X].filter(Boolean).map(F=>F.ref.current);Jj(R,f)}}I.current=!1}),onBlur:at(t.onBlur,()=>C(!1))})})}),qj="RovingFocusGroupItem",Gj=v.forwardRef((t,e)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:a,children:o,...c}=t,u=ua(),h=a||u,f=UR(qj,n),m=f.currentTabStopId===h,g=Wj(n),{onFocusableItemAdd:y,onFocusableItemRemove:b,currentTabStopId:j}=f;return v.useEffect(()=>{if(r)return y(),()=>b()},[r,y,b]),s.jsx(Ig.ItemSlot,{scope:n,id:h,focusable:r,active:i,children:s.jsx(dt.span,{tabIndex:m?0:-1,"data-orientation":f.orientation,...c,ref:e,onMouseDown:at(t.onMouseDown,w=>{r?f.onItemFocus(h):w.preventDefault()}),onFocus:at(t.onFocus,()=>f.onItemFocus(h)),onKeyDown:at(t.onKeyDown,w=>{if(w.key==="Tab"&&w.shiftKey){f.onItemShiftTab();return}if(w.target!==w.currentTarget)return;const N=JR(w,f.orientation,f.dir);if(N!==void 0){if(w.metaKey||w.ctrlKey||w.altKey||w.shiftKey)return;w.preventDefault();let E=g().filter(M=>M.focusable).map(M=>M.ref.current);if(N==="last")E.reverse();else if(N==="prev"||N==="next"){N==="prev"&&E.reverse();const M=E.indexOf(w.currentTarget);E=f.loop?YR(E,M+1):E.slice(M+1)}setTimeout(()=>Jj(E))}}),children:typeof o=="function"?o({isCurrentTabStop:m,hasTabStop:j!=null}):o})})});Gj.displayName=qj;var qR={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function GR(t,e){return e!=="rtl"?t:t==="ArrowLeft"?"ArrowRight":t==="ArrowRight"?"ArrowLeft":t}function JR(t,e,n){const r=GR(t.key,n);if(!(e==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(e==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return qR[r]}function Jj(t,e=!1){const n=document.activeElement;for(const r of t)if(r===n||(r.focus({preventScroll:e}),document.activeElement!==n))return}function YR(t,e){return t.map((n,r)=>t[(e+r)%t.length])}var QR=Kj,XR=Gj,mf="Tabs",[ZR]=ka(mf,[Uj]),Yj=Uj(),[eP,Kx]=ZR(mf),Qj=v.forwardRef((t,e)=>{const{__scopeTabs:n,value:r,onValueChange:i,defaultValue:a,orientation:o="horizontal",dir:c,activationMode:u="automatic",...h}=t,f=pf(c),[m,g]=fo({prop:r,onChange:i,defaultProp:a??"",caller:mf});return s.jsx(eP,{scope:n,baseId:ua(),value:m,onValueChange:g,orientation:o,dir:f,activationMode:u,children:s.jsx(dt.div,{dir:f,"data-orientation":o,...h,ref:e})})});Qj.displayName=mf;var Xj="TabsList",Zj=v.forwardRef((t,e)=>{const{__scopeTabs:n,loop:r=!0,...i}=t,a=Kx(Xj,n),o=Yj(n);return s.jsx(QR,{asChild:!0,...o,orientation:a.orientation,dir:a.dir,loop:r,children:s.jsx(dt.div,{role:"tablist","aria-orientation":a.orientation,...i,ref:e})})});Zj.displayName=Xj;var ek="TabsTrigger",tk=v.forwardRef((t,e)=>{const{__scopeTabs:n,value:r,disabled:i=!1,...a}=t,o=Kx(ek,n),c=Yj(n),u=sk(o.baseId,r),h=ik(o.baseId,r),f=r===o.value;return s.jsx(XR,{asChild:!0,...c,focusable:!i,active:f,children:s.jsx(dt.button,{type:"button",role:"tab","aria-selected":f,"aria-controls":h,"data-state":f?"active":"inactive","data-disabled":i?"":void 0,disabled:i,id:u,...a,ref:e,onMouseDown:at(t.onMouseDown,m=>{!i&&m.button===0&&m.ctrlKey===!1?o.onValueChange(r):m.preventDefault()}),onKeyDown:at(t.onKeyDown,m=>{[" ","Enter"].includes(m.key)&&o.onValueChange(r)}),onFocus:at(t.onFocus,()=>{const m=o.activationMode!=="manual";!f&&!i&&m&&o.onValueChange(r)})})})});tk.displayName=ek;var nk="TabsContent",rk=v.forwardRef((t,e)=>{const{__scopeTabs:n,value:r,forceMount:i,children:a,...o}=t,c=Kx(nk,n),u=sk(c.baseId,r),h=ik(c.baseId,r),f=r===c.value,m=v.useRef(f);return v.useEffect(()=>{const g=requestAnimationFrame(()=>m.current=!1);return()=>cancelAnimationFrame(g)},[]),s.jsx(ud,{present:i||f,children:({present:g})=>s.jsx(dt.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})})});rk.displayName=nk;function sk(t,e){return`${t}-trigger-${e}`}function ik(t,e){return`${t}-content-${e}`}var tP=Qj,ak=Zj,ok=tk,lk=rk;const fd=tP,Ll=v.forwardRef(({className:t,...e},n)=>s.jsx(ak,{ref:n,className:Ct("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",t),...e}));Ll.displayName=ak.displayName;const tn=v.forwardRef(({className:t,...e},n)=>s.jsx(ok,{ref:n,className:Ct("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}));tn.displayName=ok.displayName;const nn=v.forwardRef(({className:t,...e},n)=>s.jsx(lk,{ref:n,className:Ct("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",t),...e}));nn.displayName=lk.displayName;function qx(t){const e=v.useRef({value:t,previous:t});return v.useMemo(()=>(e.current.value!==t&&(e.current.previous=e.current.value,e.current.value=t),e.current.previous),[t])}function Gx(t){const[e,n]=v.useState(void 0);return Xn(()=>{if(t){n({width:t.offsetWidth,height:t.offsetHeight});const r=new ResizeObserver(i=>{if(!Array.isArray(i)||!i.length)return;const a=i[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 gf="Switch",[nP]=ka(gf),[rP,sP]=nP(gf),ck=v.forwardRef((t,e)=>{const{__scopeSwitch:n,name:r,checked:i,defaultChecked:a,required:o,disabled:c,value:u="on",onCheckedChange:h,form:f,...m}=t,[g,y]=v.useState(null),b=St(e,E=>y(E)),j=v.useRef(!1),w=g?f||!!g.closest("form"):!0,[N,C]=fo({prop:i,defaultProp:a??!1,onChange:h,caller:gf});return s.jsxs(rP,{scope:n,checked:N,disabled:c,children:[s.jsx(dt.button,{type:"button",role:"switch","aria-checked":N,"aria-required":o,"data-state":fk(N),"data-disabled":c?"":void 0,disabled:c,value:u,...m,ref:b,onClick:at(t.onClick,E=>{C(M=>!M),w&&(j.current=E.isPropagationStopped(),j.current||E.stopPropagation())})}),w&&s.jsx(hk,{control:g,bubbles:!j.current,name:r,value:u,checked:N,required:o,disabled:c,form:f,style:{transform:"translateX(-100%)"}})]})});ck.displayName=gf;var dk="SwitchThumb",uk=v.forwardRef((t,e)=>{const{__scopeSwitch:n,...r}=t,i=sP(dk,n);return s.jsx(dt.span,{"data-state":fk(i.checked),"data-disabled":i.disabled?"":void 0,...r,ref:e})});uk.displayName=dk;var iP="SwitchBubbleInput",hk=v.forwardRef(({__scopeSwitch:t,control:e,checked:n,bubbles:r=!0,...i},a)=>{const o=v.useRef(null),c=St(o,a),u=qx(n),h=Gx(e);return v.useEffect(()=>{const f=o.current;if(!f)return;const m=window.HTMLInputElement.prototype,y=Object.getOwnPropertyDescriptor(m,"checked").set;if(u!==n&&y){const b=new Event("click",{bubbles:r});y.call(f,n),f.dispatchEvent(b)}},[u,n,r]),s.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...i,tabIndex:-1,ref:c,style:{...i.style,...h,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});hk.displayName=iP;function fk(t){return t?"checked":"unchecked"}var pk=ck,aP=uk;const Et=v.forwardRef(({className:t,...e},n)=>s.jsx(pk,{className:Ct("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:s.jsx(aP,{className:Ct("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")})}));Et.displayName=pk.displayName;function Jx({open:t,onClose:e,userId:n,onUserUpdated:r}){var ir;const[i,a]=v.useState(null),[o,c]=v.useState([]),[u,h]=v.useState([]),[f,m]=v.useState(!1),[g,y]=v.useState(!1),[b,j]=v.useState(!1),[w,N]=v.useState("info"),[C,E]=v.useState(""),[M,I]=v.useState(""),[O,D]=v.useState([]),[P,L]=v.useState(""),[_,X]=v.useState(""),[ne,J]=v.useState(""),[U,R]=v.useState(!1),[F,re]=v.useState({isVip:!1,vipExpireDate:"",vipRole:"",vipName:"",vipProject:"",vipContact:"",vipBio:""}),[z,ae]=v.useState([]),[G,$]=v.useState(!1),[H,ce]=v.useState(!1),[W,fe]=v.useState(null),[Q,de]=v.useState(null),[he,Ne]=v.useState(""),[Te,Ve]=v.useState(""),[He,gt]=v.useState(""),[Pt,wn]=v.useState(!1),[ht,At]=v.useState(null),[te,Pe]=v.useState("");v.useEffect(()=>{t&&n&&(N("info"),fe(null),de(null),At(null),Pe(""),X(""),J(""),Qe(),Le("/api/db/vip-roles").then(me=>{me!=null&&me.success&&me.data&&ae(me.data)}).catch(()=>{}))},[t,n]);async function Qe(){if(n){m(!0);try{const me=await Le(`/api/db/users?id=${encodeURIComponent(n)}`);if(me!=null&&me.success&&me.user){const ve=me.user;a(ve),E(ve.phone||""),I(ve.nickname||""),Ne(ve.phone||""),Ve(ve.wechatId||""),gt(ve.openId||"");try{D(typeof ve.tags=="string"?JSON.parse(ve.tags||"[]"):[])}catch{D([])}re({isVip:!!(ve.isVip??!1),vipExpireDate:ve.vipExpireDate?String(ve.vipExpireDate).slice(0,10):"",vipRole:String(ve.vipRole??""),vipName:String(ve.vipName??""),vipProject:String(ve.vipProject??""),vipContact:String(ve.vipContact??""),vipBio:String(ve.vipBio??"")})}try{const ve=await Le(`/api/user/track?userId=${encodeURIComponent(n)}&limit=50`);ve!=null&&ve.success&&ve.tracks&&c(ve.tracks)}catch{c([])}try{const ve=await Le(`/api/db/users/referrals?userId=${encodeURIComponent(n)}`);ve!=null&&ve.success&&ve.referrals&&h(ve.referrals)}catch{h([])}}catch(me){console.error("Load user detail error:",me)}finally{m(!1)}}}async function xt(){if(!(i!=null&&i.phone)){ie.info("用户未绑定手机号,无法同步");return}y(!0);try{const me=await Nt("/api/ckb/sync",{action:"full_sync",phone:i.phone,userId:i.id});me!=null&&me.success?(ie.success("同步成功"),Qe()):ie.error("同步失败: "+(me==null?void 0:me.error))}catch(me){console.error("Sync CKB error:",me),ie.error("同步失败")}finally{y(!1)}}async function ft(){if(i){j(!0);try{const me={id:i.id,phone:C||void 0,nickname:M||void 0,tags:JSON.stringify(O)},ve=await Mt("/api/db/users",me);ve!=null&&ve.success?(ie.success("保存成功"),Qe(),r==null||r()):ie.error("保存失败: "+(ve==null?void 0:ve.error))}catch(me){console.error("Save user error:",me),ie.error("保存失败")}finally{j(!1)}}}const pt=()=>{P&&!O.includes(P)&&(D([...O,P]),L(""))},wt=me=>D(O.filter(ve=>ve!==me));async function Xt(){if(i){if(!_){ie.error("请输入新密码");return}if(_!==ne){ie.error("两次密码不一致");return}if(_.length<6){ie.error("密码至少 6 位");return}R(!0);try{const me=await Mt("/api/db/users",{id:i.id,password:_});me!=null&&me.success?(ie.success("修改成功"),X(""),J("")):ie.error("修改失败: "+((me==null?void 0:me.error)||""))}catch{ie.error("修改失败")}finally{R(!1)}}}async function Ot(){if(i){if(F.isVip&&!F.vipExpireDate.trim()){ie.error("开启 VIP 请填写有效到期日");return}$(!0);try{const me={id:i.id,isVip:F.isVip,vipExpireDate:F.isVip?F.vipExpireDate:void 0,vipRole:F.vipRole||void 0,vipName:F.vipName||void 0,vipProject:F.vipProject||void 0,vipContact:F.vipContact||void 0,vipBio:F.vipBio||void 0},ve=await Mt("/api/db/users",me);ve!=null&&ve.success?(ie.success("VIP 设置已保存"),Qe(),r==null||r()):ie.error("保存失败: "+((ve==null?void 0:ve.error)||""))}catch{ie.error("保存失败")}finally{$(!1)}}}async function Tn(){if(!he&&!He&&!Te){de("请至少输入手机号、微信号或 OpenID 中的一项");return}ce(!0),de(null),fe(null);try{const me=new URLSearchParams;he&&me.set("phone",he),He&&me.set("openId",He),Te&&me.set("wechatId",Te);const ve=await Le(`/api/admin/shensheshou/query?${me}`);ve!=null&&ve.success&&ve.data?(fe(ve.data),i&&await Dt(ve.data)):de((ve==null?void 0:ve.error)||"未查询到数据,该用户可能未在神射手收录")}catch(me){console.error("SSS query error:",me),de("请求失败,请检查神射手接口配置")}finally{ce(!1)}}async function Dt(me){if(i)try{await Nt("/api/admin/shensheshou/enrich",{userId:i.id,phone:he||i.phone||"",openId:He||i.openId||"",wechatId:Te||i.wechatId||""}),Qe()}catch(ve){console.error("SSS enrich error:",ve)}}async function Kn(){if(i){wn(!0),At(null);try{const me={users:[{phone:i.phone||"",name:i.nickname||"",openId:i.openId||"",tags:O}]},ve=await Nt("/api/admin/shensheshou/ingest",me);ve!=null&&ve.success&&ve.data?At(ve.data):At({error:(ve==null?void 0:ve.error)||"推送失败"})}catch(me){console.error("SSS ingest error:",me),At({error:"请求失败"})}finally{wn(!1)}}}const Xr=me=>{const ar={view_chapter:ps,purchase:Cg,match:Un,login:yl,register:yl,share:ms,bind_phone:dA,bind_wechat:ZM,fill_profile:qu,visit_page:pl}[me]||jg;return s.jsx(ar,{className:"w-4 h-4"})};return t?s.jsx(Kt,{open:t,onOpenChange:()=>e(),children:s.jsxs(zt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-4xl max-h-[90vh] overflow-hidden",children:[s.jsx(qt,{children:s.jsxs(Gt,{className:"text-white flex items-center gap-2",children:[s.jsx(yl,{className:"w-5 h-5 text-[#38bdac]"}),"用户详情",(i==null?void 0:i.phone)&&s.jsx(Ue,{className:"bg-green-500/20 text-green-400 border-0 ml-2",children:"已绑定手机"}),(i==null?void 0:i.isVip)&&s.jsx(Ue,{className:"bg-amber-500/20 text-amber-400 border-0",children:"VIP"})]})}),f?s.jsxs("div",{className:"flex items-center justify-center py-20",children:[s.jsx(Ge,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):i?s.jsxs("div",{className:"flex flex-col h-[75vh]",children:[s.jsxs("div",{className:"flex items-center gap-4 p-4 bg-[#0a1628] rounded-lg mb-3",children:[s.jsx("div",{className:"w-16 h-16 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-2xl text-[#38bdac] shrink-0",children:i.avatar?s.jsx("img",{src:i.avatar,className:"w-full h-full rounded-full object-cover",alt:""}):((ir=i.nickname)==null?void 0:ir.charAt(0))||"?"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.jsx("h3",{className:"text-lg font-bold text-white",children:i.nickname}),i.isAdmin&&s.jsx(Ue,{className:"bg-purple-500/20 text-purple-400 border-0",children:"管理员"}),i.hasFullBook&&s.jsx(Ue,{className:"bg-green-500/20 text-green-400 border-0",children:"全书已购"}),i.vipRole&&s.jsx(Ue,{className:"bg-amber-500/20 text-amber-400 border-0",children:i.vipRole})]}),s.jsxs("p",{className:"text-gray-400 text-sm mt-1",children:[i.phone?`📱 ${i.phone}`:"未绑定手机",i.wechatId&&` · 💬 ${i.wechatId}`,i.mbti&&` · ${i.mbti}`]}),s.jsxs("div",{className:"flex items-center gap-4 mt-1",children:[s.jsxs("p",{className:"text-gray-600 text-xs",children:["ID: ",i.id.slice(0,16),"…"]}),i.referralCode&&s.jsxs("p",{className:"text-xs",children:[s.jsx("span",{className:"text-gray-500",children:"推广码:"}),s.jsx("code",{className:"text-[#38bdac] bg-[#38bdac]/10 px-1.5 py-0.5 rounded",children:i.referralCode})]})]})]}),s.jsxs("div",{className:"text-right shrink-0",children:[s.jsxs("p",{className:"text-[#38bdac] font-bold text-lg",children:["¥",(i.earnings||0).toFixed(2)]}),s.jsx("p",{className:"text-gray-500 text-xs",children:"累计收益"})]})]}),s.jsxs(fd,{value:w,onValueChange:N,className:"flex-1 flex flex-col overflow-hidden",children:[s.jsxs(Ll,{className:"bg-[#0a1628] border border-gray-700/50 p-1 mb-3 flex-wrap h-auto gap-1",children:[s.jsx(tn,{value:"info",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-xs",children:"基础信息"}),s.jsx(tn,{value:"tags",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-xs",children:"标签体系"}),s.jsxs(tn,{value:"journey",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-xs",children:[s.jsx(pl,{className:"w-3 h-3 mr-1"}),"用户旅程"]}),s.jsx(tn,{value:"relations",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-xs",children:"关系链路"}),s.jsxs(tn,{value:"shensheshou",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-xs",children:[s.jsx(ia,{className:"w-3 h-3 mr-1"}),"用户资料完善"]})]}),s.jsxs(nn,{value:"info",className:"flex-1 overflow-auto space-y-4",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"手机号"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"输入手机号",value:C,onChange:me=>E(me.target.value)})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"昵称"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"输入昵称",value:M,onChange:me=>I(me.target.value)})]})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[i.openId&&s.jsxs("div",{className:"p-3 bg-[#0a1628] rounded-lg",children:[s.jsx("p",{className:"text-gray-500 text-xs mb-1",children:"微信 OpenID"}),s.jsx("p",{className:"text-gray-300 font-mono text-xs break-all",children:i.openId})]}),i.region&&s.jsxs("div",{className:"p-3 bg-[#0a1628] rounded-lg flex items-center gap-2",children:[s.jsx(Kw,{className:"w-4 h-4 text-gray-500"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-gray-500 text-xs",children:"地区"}),s.jsx("p",{className:"text-white",children:i.region})]})]}),i.industry&&s.jsxs("div",{className:"p-3 bg-[#0a1628] rounded-lg",children:[s.jsx("p",{className:"text-gray-500 text-xs mb-1",children:"行业"}),s.jsx("p",{className:"text-white",children:i.industry})]}),i.position&&s.jsxs("div",{className:"p-3 bg-[#0a1628] rounded-lg",children:[s.jsx("p",{className:"text-gray-500 text-xs mb-1",children:"职位"}),s.jsx("p",{className:"text-white",children:i.position})]})]}),s.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[s.jsxs("div",{className:"p-4 bg-[#0a1628] rounded-lg",children:[s.jsx("p",{className:"text-gray-400 text-sm",children:"推荐人数"}),s.jsx("p",{className:"text-2xl font-bold text-white",children:i.referralCount??0})]}),s.jsxs("div",{className:"p-4 bg-[#0a1628] rounded-lg",children:[s.jsx("p",{className:"text-gray-400 text-sm",children:"待提现"}),s.jsxs("p",{className:"text-2xl font-bold text-yellow-400",children:["¥",(i.pendingEarnings??0).toFixed(2)]})]}),s.jsxs("div",{className:"p-4 bg-[#0a1628] rounded-lg",children:[s.jsx("p",{className:"text-gray-400 text-sm",children:"创建时间"}),s.jsx("p",{className:"text-sm text-white",children:i.createdAt?new Date(i.createdAt).toLocaleDateString():"-"})]})]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[s.jsxs("div",{className:"p-4 bg-[#0a1628] rounded-lg border border-gray-700/50",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[s.jsx(LM,{className:"w-4 h-4 text-yellow-400"}),s.jsx("span",{className:"text-white font-medium",children:"修改密码"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(oe,{type:"password",className:"bg-[#162840] border-gray-700 text-white",placeholder:"新密码(至少6位)",value:_,onChange:me=>X(me.target.value)}),s.jsx(oe,{type:"password",className:"bg-[#162840] border-gray-700 text-white",placeholder:"确认密码",value:ne,onChange:me=>J(me.target.value)}),s.jsx(ee,{size:"sm",onClick:Xt,disabled:U||!_||!ne,className:"bg-yellow-500/20 hover:bg-yellow-500/30 text-yellow-400 border border-yellow-500/40",children:U?"保存中...":"确认修改"})]})]}),s.jsxs("div",{className:"p-4 bg-[#0a1628] rounded-lg border border-amber-500/20",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[s.jsx(xl,{className:"w-4 h-4 text-amber-400"}),s.jsx("span",{className:"text-white font-medium",children:"设成超级个体"})]}),s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx(Z,{className:"text-gray-400 text-sm",children:"VIP 会员"}),s.jsx(Et,{checked:F.isVip,onCheckedChange:me=>re(ve=>({...ve,isVip:me}))})]}),F.isVip&&s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-400 text-xs",children:"到期日"}),s.jsx(oe,{type:"date",className:"bg-[#162840] border-gray-700 text-white text-sm",value:F.vipExpireDate,onChange:me=>re(ve=>({...ve,vipExpireDate:me.target.value}))})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(Z,{className:"text-gray-400 text-xs",children:"角色"}),s.jsxs("select",{className:"w-full bg-[#162840] border border-gray-700 text-white rounded px-2 py-1.5 text-sm",value:F.vipRole,onChange:me=>re(ve=>({...ve,vipRole:me.target.value})),children:[s.jsx("option",{value:"",children:"请选择"}),z.map(me=>s.jsx("option",{value:me.name,children:me.name},me.id))]})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(Z,{className:"text-gray-400 text-xs",children:"展示名"}),s.jsx(oe,{className:"bg-[#162840] border-gray-700 text-white text-sm",placeholder:"创业老板排行展示名",value:F.vipName,onChange:me=>re(ve=>({...ve,vipName:me.target.value}))})]}),s.jsx(ee,{size:"sm",onClick:Ot,disabled:G,className:"bg-amber-500/20 hover:bg-amber-500/30 text-amber-400 border border-amber-500/40",children:G?"保存中...":"保存 VIP"})]})]})]}),i.isVip&&s.jsxs("div",{className:"p-4 bg-[#0a1628] rounded-lg border border-amber-500/20",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[s.jsx(xl,{className:"w-4 h-4 text-amber-400"}),s.jsx("span",{className:"text-white font-medium",children:"VIP 信息"}),s.jsx(Ue,{className:"bg-amber-500/20 text-amber-400 border-0 text-xs",children:i.vipRole||"VIP"})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[i.vipName&&s.jsxs("div",{children:[s.jsx("span",{className:"text-gray-500",children:"展示名:"}),s.jsx("span",{className:"text-white",children:i.vipName})]}),i.vipProject&&s.jsxs("div",{children:[s.jsx("span",{className:"text-gray-500",children:"项目:"}),s.jsx("span",{className:"text-white",children:i.vipProject})]}),i.vipContact&&s.jsxs("div",{children:[s.jsx("span",{className:"text-gray-500",children:"联系方式:"}),s.jsx("span",{className:"text-white",children:i.vipContact})]}),i.vipExpireDate&&s.jsxs("div",{children:[s.jsx("span",{className:"text-gray-500",children:"到期时间:"}),s.jsx("span",{className:"text-white",children:new Date(i.vipExpireDate).toLocaleDateString()})]})]}),i.vipBio&&s.jsx("p",{className:"text-gray-400 text-sm mt-2",children:i.vipBio})]}),s.jsxs("div",{className:"p-4 bg-[#0a1628] rounded-lg border border-purple-500/20",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[s.jsx(uo,{className:"w-4 h-4 text-purple-400"}),s.jsx("span",{className:"text-white font-medium",children:"微信归属"}),s.jsx("span",{className:"text-gray-500 text-xs",children:"该用户归属在哪个微信号下"})]}),s.jsxs("div",{className:"flex gap-2 items-center",children:[s.jsx(oe,{className:"bg-[#162840] border-gray-700 text-white flex-1",placeholder:"输入归属微信号(如 wxid_xxxx)",value:te,onChange:me=>Pe(me.target.value)}),s.jsxs(ee,{size:"sm",onClick:async()=>{if(!(!te||!i))try{await Mt("/api/db/users",{id:i.id,wechatId:te}),ie.success("已保存微信归属"),Qe()}catch{ie.error("保存失败")}},className:"bg-purple-500/20 hover:bg-purple-500/30 text-purple-400 border border-purple-500/30 shrink-0",children:[s.jsx(gn,{className:"w-4 h-4 mr-1"})," 保存"]})]}),i.wechatId&&s.jsxs("p",{className:"text-gray-500 text-xs mt-2",children:["当前归属:",s.jsx("span",{className:"text-purple-400",children:i.wechatId})]})]}),s.jsxs("div",{className:"p-4 bg-[#0a1628] rounded-lg",children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ms,{className:"w-4 h-4 text-[#38bdac]"}),s.jsx("span",{className:"text-white font-medium",children:"存客宝同步"})]}),s.jsx(ee,{size:"sm",onClick:xt,disabled:g||!i.phone,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:g?s.jsxs(s.Fragment,{children:[s.jsx(Ge,{className:"w-4 h-4 mr-1 animate-spin"})," 同步中..."]}):s.jsxs(s.Fragment,{children:[s.jsx(Ge,{className:"w-4 h-4 mr-1"})," 同步数据"]})})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[s.jsxs("div",{children:[s.jsx("span",{className:"text-gray-500",children:"同步状态:"}),i.ckbSyncedAt?s.jsx(Ue,{className:"bg-green-500/20 text-green-400 border-0 ml-1",children:"已同步"}):s.jsx(Ue,{className:"bg-gray-500/20 text-gray-400 border-0 ml-1",children:"未同步"})]}),s.jsxs("div",{children:[s.jsx("span",{className:"text-gray-500",children:"最后同步:"}),s.jsx("span",{className:"text-gray-300 ml-1",children:i.ckbSyncedAt?new Date(i.ckbSyncedAt).toLocaleString():"-"})]})]})]})]}),s.jsxs(nn,{value:"tags",className:"flex-1 overflow-auto space-y-4",children:[s.jsxs("div",{className:"p-4 bg-[#0a1628] rounded-lg",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[s.jsx(qu,{className:"w-4 h-4 text-[#38bdac]"}),s.jsx("span",{className:"text-white font-medium",children:"用户标签"}),s.jsx("span",{className:"text-gray-500 text-xs",children:"基于《一场 Soul 的创业实验》维度打标"})]}),s.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:[s.jsx(wg,{className:"w-3.5 h-3.5 text-[#38bdac] shrink-0"}),"命中的标签自动高亮 · 系统根据行为轨迹和填写资料自动打标 · 手动点击补充或取消"]}),s.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(me=>s.jsxs("div",{children:[s.jsx("p",{className:"text-gray-500 text-xs mb-1.5",children:me.category}),s.jsx("div",{className:"flex flex-wrap gap-1.5",children:me.tags.map(ve=>s.jsxs("button",{type:"button",onClick:()=>{O.includes(ve)?wt(ve):D([...O,ve])},className:`px-2 py-0.5 rounded text-xs border transition-all ${O.includes(ve)?"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:[O.includes(ve)?"✓ ":"",ve]},ve))})]},me.category))}),s.jsxs("div",{className:"border-t border-gray-700/50 pt-3",children:[s.jsx("p",{className:"text-gray-500 text-xs mb-2",children:"已选标签"}),s.jsxs("div",{className:"flex flex-wrap gap-2 mb-3 min-h-[32px]",children:[O.map((me,ve)=>s.jsxs(Ue,{className:"bg-[#38bdac]/20 text-[#38bdac] border-0 pr-1",children:[me,s.jsx("button",{type:"button",onClick:()=>wt(me),className:"ml-1 hover:text-red-400",children:s.jsx(hr,{className:"w-3 h-3"})})]},ve)),O.length===0&&s.jsx("span",{className:"text-gray-600 text-sm",children:"暂未选择标签"})]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(oe,{className:"bg-[#162840] border-gray-700 text-white flex-1",placeholder:"自定义标签(回车添加)",value:P,onChange:me=>L(me.target.value),onKeyDown:me=>me.key==="Enter"&&pt()}),s.jsx(ee,{onClick:pt,className:"bg-[#38bdac] hover:bg-[#2da396]",children:"添加"})]})]})]}),i.ckbTags&&s.jsxs("div",{className:"p-4 bg-[#0a1628] rounded-lg",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[s.jsx(qu,{className:"w-4 h-4 text-purple-400"}),s.jsx("span",{className:"text-white font-medium",children:"存客宝标签"})]}),s.jsx("div",{className:"flex flex-wrap gap-2",children:(typeof i.ckbTags=="string"?i.ckbTags.split(","):[]).map((me,ve)=>s.jsx(Ue,{className:"bg-purple-500/20 text-purple-400 border-0",children:me.trim()},ve))})]})]}),s.jsxs(nn,{value:"journey",className:"flex-1 overflow-auto",children:[s.jsxs("div",{className:"mb-3 p-3 bg-[#0a1628] rounded-lg flex items-center gap-2",children:[s.jsx(pl,{className:"w-4 h-4 text-[#38bdac]"}),s.jsxs("span",{className:"text-gray-400 text-sm",children:["记录用户从注册到付费的完整行动路径,共 ",o.length," 条记录"]})]}),s.jsx("div",{className:"space-y-2",children:o.length>0?o.map((me,ve)=>s.jsxs("div",{className:"flex items-start gap-3 p-3 bg-[#0a1628] rounded-lg",children:[s.jsxs("div",{className:"flex flex-col items-center",children:[s.jsx("div",{className:"w-8 h-8 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-[#38bdac]",children:Xr(me.action)}),ve0?u.map((me,ve)=>{var Hs;const ar=me;return s.jsxs("div",{className:"flex items-center justify-between p-2 bg-[#162840] rounded",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"w-6 h-6 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-xs text-[#38bdac]",children:((Hs=ar.nickname)==null?void 0:Hs.charAt(0))||"?"}),s.jsx("span",{className:"text-white text-sm",children:ar.nickname})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[ar.status==="vip"&&s.jsx(Ue,{className:"bg-green-500/20 text-green-400 border-0 text-xs",children:"已购"}),s.jsx("span",{className:"text-gray-500 text-xs",children:ar.createdAt?new Date(ar.createdAt).toLocaleDateString():""})]})]},ar.id||ve)}):s.jsx("p",{className:"text-gray-500 text-sm text-center py-4",children:"暂无推荐用户"})})]})}),s.jsxs(nn,{value:"shensheshou",className:"flex-1 overflow-auto space-y-4",children:[s.jsxs("div",{className:"p-4 bg-[#0a1628] rounded-lg",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[s.jsx(ia,{className:"w-5 h-5 text-[#38bdac]"}),s.jsx("span",{className:"text-white font-medium",children:"用户资料完善"}),s.jsx("span",{className:"text-gray-500 text-xs",children:"通过多维度查询神射手数据,自动回填用户基础信息"})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-2 mb-3",children:[s.jsxs("div",{children:[s.jsx(Z,{className:"text-gray-500 text-xs mb-1 block",children:"手机号"}),s.jsx(oe,{className:"bg-[#162840] border-gray-700 text-white",placeholder:"11位手机号",value:he,onChange:me=>Ne(me.target.value)})]}),s.jsxs("div",{children:[s.jsx(Z,{className:"text-gray-500 text-xs mb-1 block",children:"微信号"}),s.jsx(oe,{className:"bg-[#162840] border-gray-700 text-white",placeholder:"微信 ID",value:Te,onChange:me=>Ve(me.target.value)})]}),s.jsxs("div",{className:"col-span-2",children:[s.jsx(Z,{className:"text-gray-500 text-xs mb-1 block",children:"微信 OpenID"}),s.jsx(oe,{className:"bg-[#162840] border-gray-700 text-white",placeholder:"openid_xxxx(自动填入)",value:He,onChange:me=>gt(me.target.value)})]})]}),s.jsx(ee,{onClick:Tn,disabled:H,className:"w-full bg-[#38bdac] hover:bg-[#2da396] text-white",children:H?s.jsxs(s.Fragment,{children:[s.jsx(Ge,{className:"w-4 h-4 mr-1 animate-spin"})," 查询并自动回填中..."]}):s.jsxs(s.Fragment,{children:[s.jsx(da,{className:"w-4 h-4 mr-1"})," 查询并自动完善用户资料"]})}),s.jsx("p",{className:"text-gray-600 text-xs mt-2",children:"查询成功后,神射手返回的标签将自动同步到该用户"}),Q&&s.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}),W&&s.jsxs("div",{className:"mt-3 space-y-3",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{className:"p-3 bg-[#162840] rounded-lg",children:[s.jsx("p",{className:"text-gray-500 text-xs mb-1",children:"神射手 RFM 分"}),s.jsx("p",{className:"text-2xl font-bold text-[#38bdac]",children:W.rfm_score??"-"})]}),s.jsxs("div",{className:"p-3 bg-[#162840] rounded-lg",children:[s.jsx("p",{className:"text-gray-500 text-xs mb-1",children:"用户等级"}),s.jsx("p",{className:"text-2xl font-bold text-white",children:W.user_level??"-"})]})]}),W.tags&&W.tags.length>0&&s.jsxs("div",{className:"p-3 bg-[#162840] rounded-lg",children:[s.jsx("p",{className:"text-gray-500 text-xs mb-2",children:"神射手标签"}),s.jsx("div",{className:"flex flex-wrap gap-2",children:W.tags.map((me,ve)=>s.jsx(Ue,{className:"bg-[#38bdac]/10 text-[#38bdac] border border-[#38bdac]/20",children:me},ve))})]}),W.last_active&&s.jsxs("div",{className:"text-sm text-gray-500",children:["最近活跃:",W.last_active]})]})]}),s.jsxs("div",{className:"p-4 bg-[#0a1628] rounded-lg",children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[s.jsx(ia,{className:"w-4 h-4 text-purple-400"}),s.jsx("span",{className:"text-white font-medium",children:"推送用户数据到神射手"})]}),s.jsx("p",{className:"text-gray-500 text-xs",children:"将本用户信息(手机号、昵称、标签等)同步至神射手,自动完善用户画像"})]}),s.jsx(ee,{onClick:Kn,disabled:Pt||!i.phone,variant:"outline",className:"border-purple-500/40 text-purple-400 hover:bg-purple-500/10 bg-transparent shrink-0 ml-4",children:Pt?s.jsxs(s.Fragment,{children:[s.jsx(Ge,{className:"w-4 h-4 mr-1 animate-spin"})," 推送中"]}):s.jsxs(s.Fragment,{children:[s.jsx(ia,{className:"w-4 h-4 mr-1"})," 推送"]})})]}),!i.phone&&s.jsx("p",{className:"text-yellow-500/70 text-xs",children:"⚠ 用户未绑定手机号,无法推送"}),ht&&s.jsx("div",{className:"mt-3 p-3 bg-[#162840] rounded-lg text-sm",children:ht.error?s.jsx("p",{className:"text-red-400",children:String(ht.error)}):s.jsxs("div",{className:"space-y-1",children:[s.jsxs("p",{className:"text-green-400 flex items-center gap-1",children:[s.jsx(wg,{className:"w-4 h-4"})," 推送成功"]}),ht.enriched!==void 0&&s.jsxs("p",{className:"text-gray-400",children:["自动补全标签数:",String(ht.new_tags_added??0)]})]})})]})]})]}),s.jsxs("div",{className:"flex justify-end gap-2 pt-3 border-t border-gray-700 mt-3",children:[s.jsxs(ee,{variant:"outline",onClick:e,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(hr,{className:"w-4 h-4 mr-2"}),"关闭"]}),s.jsxs(ee,{onClick:ft,disabled:b,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(gn,{className:"w-4 h-4 mr-2"}),b?"保存中...":"保存修改"]})]})]}):s.jsx("div",{className:"text-center py-12 text-gray-500",children:"用户不存在"})]})}):null}function oP(){const t=ja(),[e,n]=v.useState(!0),[r,i]=v.useState(!0),[a,o]=v.useState(!0),[c,u]=v.useState([]),[h,f]=v.useState([]),[m,g]=v.useState(0),[y,b]=v.useState(0),[j,w]=v.useState(0),[N,C]=v.useState(0),[E,M]=v.useState(null),[I,O]=v.useState(null),[D,P]=v.useState(!1),L=U=>{const R=U;if((R==null?void 0:R.status)===401)M("登录已过期,请重新登录");else{if((R==null?void 0:R.name)==="AbortError")return;M("加载失败,请检查网络或联系管理员")}};async function _(U){const R=U?{signal:U}:void 0;n(!0),M(null);try{const z=await Le("/api/admin/dashboard/stats",R);z!=null&&z.success&&(g(z.totalUsers??0),b(z.paidOrderCount??0),w(z.totalRevenue??0))}catch(z){if((z==null?void 0:z.name)!=="AbortError"){console.error("stats 失败,尝试 overview 降级",z);try{const ae=await Le("/api/admin/dashboard/overview",R);ae!=null&&ae.success&&(g(ae.totalUsers??0),b(ae.paidOrderCount??0),w(ae.totalRevenue??0))}catch(ae){L(ae)}}}finally{n(!1)}try{const z=await Le("/api/admin/distribution/overview",R);z!=null&&z.success&&C(z.todayClicks??0)}catch{}i(!0),o(!0);const F=async()=>{try{const z=await Le("/api/admin/dashboard/recent-orders",R);if(z!=null&&z.success&&z.recentOrders)f(z.recentOrders);else throw new Error("no data")}catch(z){if((z==null?void 0:z.name)!=="AbortError")try{const ae=await Le("/api/admin/orders?page=1&pageSize=20&status=paid",R),$=((ae==null?void 0:ae.orders)??[]).filter(H=>["paid","completed","success"].includes(H.status||""));f($.slice(0,5))}catch{f([])}}finally{i(!1)}},re=async()=>{try{const z=await Le("/api/admin/dashboard/new-users",R);if(z!=null&&z.success&&z.newUsers)u(z.newUsers);else throw new Error("no data")}catch(z){if((z==null?void 0:z.name)!=="AbortError")try{const ae=await Le("/api/db/users?page=1&pageSize=10",R);u((ae==null?void 0:ae.users)??[])}catch{u([])}}finally{o(!1)}};await Promise.all([F(),re()])}v.useEffect(()=>{const U=new AbortController;_(U.signal);const R=setInterval(()=>_(),3e4);return()=>{U.abort(),clearInterval(R)}},[]);const X=m,ne=U=>{const R=U.productType||"",F=U.description||"";if(F){if(R==="section"&&F.includes("章节")){if(F.includes("-")){const re=F.split("-");if(re.length>=3)return{title:`第${re[1]}章 第${re[2]}节`,subtitle:"《一场Soul的创业实验》"}}return{title:F,subtitle:"章节购买"}}return R==="fullbook"||F.includes("全书")?{title:"《一场Soul的创业实验》",subtitle:"全书购买"}:R==="match"||F.includes("伙伴")?{title:"找伙伴匹配",subtitle:"功能服务"}:{title:F,subtitle:R==="section"?"单章":R==="fullbook"?"全书":"其他"}}return R==="section"?{title:`章节 ${U.productId||""}`,subtitle:"单章购买"}:R==="fullbook"?{title:"《一场Soul的创业实验》",subtitle:"全书购买"}:R==="match"?{title:"找伙伴匹配",subtitle:"功能服务"}:{title:"未知商品",subtitle:R||"其他"}},J=[{title:"总用户数",value:e?null:X,icon:Un,color:"text-blue-400",bg:"bg-blue-500/20",link:"/users"},{title:"总收入",value:e?null:`¥${(j??0).toFixed(2)}`,icon:Oc,color:"text-[#38bdac]",bg:"bg-[#38bdac]/20",link:"/orders"},{title:"订单数",value:e?null:y,icon:Cg,color:"text-purple-400",bg:"bg-purple-500/20",link:"/orders"},{title:"今日点击",value:e?null:N,icon:oh,color:"text-blue-400",bg:"bg-blue-500/20",link:"/distribution"}];return s.jsxs("div",{className:"p-8 w-full",children:[s.jsx("h1",{className:"text-2xl font-bold mb-8 text-white",children:"数据概览"}),E&&s.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:[s.jsx("span",{children:E}),s.jsx("button",{type:"button",onClick:()=>_(),className:"text-amber-400 hover:text-amber-300 underline",children:"重试"})]}),s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6 mb-8",children:J.map((U,R)=>s.jsxs(Me,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl cursor-pointer hover:border-[#38bdac]/50 transition-colors group",onClick:()=>U.link&&t(U.link),children:[s.jsxs(nt,{className:"flex flex-row items-center justify-between pb-2",children:[s.jsx(rt,{className:"text-sm font-medium text-gray-400",children:U.title}),s.jsx("div",{className:`p-2 rounded-lg ${U.bg}`,children:s.jsx(U.icon,{className:`w-4 h-4 ${U.color}`})})]}),s.jsx(Ae,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("div",{className:"text-2xl font-bold text-white min-h-[2rem] flex items-center",children:U.value!=null?U.value:s.jsxs("span",{className:"inline-flex items-center gap-2 text-gray-500",children:[s.jsx(Ge,{className:"w-4 h-4 animate-spin"}),"加载中"]})}),s.jsx(fl,{className:"w-5 h-5 text-gray-600 group-hover:text-[#38bdac] transition-colors"})]})})]},R))}),s.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8",children:[s.jsxs(Me,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(nt,{className:"flex flex-row items-center justify-between",children:[s.jsx(rt,{className:"text-white",children:"最近订单"}),s.jsxs("button",{type:"button",onClick:()=>_(),disabled:r||a,className:"text-xs text-gray-400 hover:text-[#38bdac] flex items-center gap-1 disabled:opacity-50",title:"刷新",children:[r||a?s.jsx(Ge,{className:"w-3.5 h-3.5 animate-spin"}):s.jsx(Ge,{className:"w-3.5 h-3.5"}),"刷新(每 30 秒自动更新)"]})]}),s.jsx(Ae,{children:s.jsx("div",{className:"space-y-3",children:r&&h.length===0?s.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-gray-500",children:[s.jsx(Ge,{className:"w-8 h-8 animate-spin mb-2"}),s.jsx("span",{className:"text-sm",children:"加载中..."})]}):s.jsxs(s.Fragment,{children:[h.slice(0,5).map(U=>{var ae;const R=U.referrerId?c.find(G=>G.id===U.referrerId):void 0,F=U.referralCode||(R==null?void 0:R.referralCode)||(R==null?void 0:R.nickname)||(U.referrerId?String(U.referrerId).slice(0,8):""),re=ne(U),z=U.userNickname||((ae=c.find(G=>G.id===U.userId))==null?void 0:ae.nickname)||"匿名用户";return s.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:[s.jsxs("div",{className:"flex items-start gap-3 flex-1",children:[U.userAvatar?s.jsx("img",{src:U.userAvatar,alt:z,className:"w-9 h-9 rounded-full object-cover flex-shrink-0 mt-0.5",onError:G=>{G.currentTarget.style.display="none";const $=G.currentTarget.nextElementSibling;$&&$.classList.remove("hidden")}}):null,s.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 ${U.userAvatar?"hidden":""}`,children:z.charAt(0)}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[s.jsx("button",{type:"button",onClick:()=>{U.userId&&(O(U.userId),P(!0))},className:"text-sm text-[#38bdac] hover:text-[#2da396] hover:underline text-left",children:z}),s.jsx("span",{className:"text-gray-600",children:"·"}),s.jsx("span",{className:"text-sm font-medium text-white truncate",children:re.title})]}),s.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500",children:[re.subtitle&&re.subtitle!=="章节购买"&&s.jsx("span",{className:"px-1.5 py-0.5 bg-gray-700/50 rounded",children:re.subtitle}),s.jsx("span",{children:new Date(U.createdAt||0).toLocaleString("zh-CN",{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"})})]}),F&&s.jsxs("p",{className:"text-xs text-gray-600 mt-1",children:["推荐: ",F]})]})]}),s.jsxs("div",{className:"text-right ml-4 flex-shrink-0",children:[s.jsxs("p",{className:"text-sm font-bold text-[#38bdac]",children:["+¥",Number(U.amount).toFixed(2)]}),s.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:U.paymentMethod||"微信"})]})]},U.id)}),h.length===0&&!r&&s.jsxs("div",{className:"text-center py-12",children:[s.jsx(Cg,{className:"w-12 h-12 text-gray-600 mx-auto mb-3"}),s.jsx("p",{className:"text-gray-500",children:"暂无订单数据"})]})]})})})]}),s.jsxs(Me,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsx(nt,{children:s.jsx(rt,{className:"text-white",children:"新注册用户"})}),s.jsx(Ae,{children:s.jsx("div",{className:"space-y-3",children:a&&c.length===0?s.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-gray-500",children:[s.jsx(Ge,{className:"w-8 h-8 animate-spin mb-2"}),s.jsx("span",{className:"text-sm",children:"加载中..."})]}):s.jsxs(s.Fragment,{children:[c.slice(0,5).map(U=>{var R;return s.jsxs("div",{className:"flex items-center justify-between p-4 bg-[#0a1628] rounded-lg border border-gray-700/30",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-10 h-10 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-sm font-medium text-[#38bdac]",children:((R=U.nickname)==null?void 0:R.charAt(0))||"?"}),s.jsxs("div",{children:[s.jsx("button",{type:"button",onClick:()=>{O(U.id),P(!0)},className:"text-sm font-medium text-[#38bdac] hover:text-[#2da396] hover:underline text-left",children:U.nickname||"匿名用户"}),s.jsx("p",{className:"text-xs text-gray-500",children:U.phone||"-"})]})]}),s.jsx("p",{className:"text-xs text-gray-400",children:U.createdAt?new Date(U.createdAt).toLocaleDateString():"-"})]},U.id)}),c.length===0&&!a&&s.jsx("p",{className:"text-gray-500 text-center py-8",children:"暂无用户数据"})]})})})]})]}),s.jsx(Jx,{open:D,onClose:()=>{P(!1),O(null)},userId:I,onUserUpdated:()=>_()})]})}const Zn=v.forwardRef(({className:t,...e},n)=>s.jsx("div",{className:"relative w-full overflow-auto",children:s.jsx("table",{ref:n,className:Ct("w-full caption-bottom text-sm",t),...e})}));Zn.displayName="Table";const er=v.forwardRef(({className:t,...e},n)=>s.jsx("thead",{ref:n,className:Ct("[&_tr]:border-b",t),...e}));er.displayName="TableHeader";const tr=v.forwardRef(({className:t,...e},n)=>s.jsx("tbody",{ref:n,className:Ct("[&_tr:last-child]:border-0",t),...e}));tr.displayName="TableBody";const st=v.forwardRef(({className:t,...e},n)=>s.jsx("tr",{ref:n,className:Ct("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",t),...e}));st.displayName="TableRow";const je=v.forwardRef(({className:t,...e},n)=>s.jsx("th",{ref:n,className:Ct("h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0",t),...e}));je.displayName="TableHead";const xe=v.forwardRef(({className:t,...e},n)=>s.jsx("td",{ref:n,className:Ct("p-4 align-middle [&:has([role=checkbox])]:pr-0",t),...e}));xe.displayName="TableCell";function Yx(t,e){const[n,r]=v.useState(t);return v.useEffect(()=>{const i=setTimeout(()=>r(t),e);return()=>clearTimeout(i)},[t,e]),n}function gs({page:t,totalPages:e,total:n,pageSize:r,onPageChange:i,onPageSizeChange:a,pageSizeOptions:o=[10,20,50,100]}){return e<=1&&!a?null:s.jsxs("div",{className:"flex items-center justify-between gap-4 py-4 px-5 border-t border-gray-700/50",children:[s.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-400",children:[s.jsxs("span",{children:["共 ",n," 条"]}),a&&s.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=>s.jsxs("option",{value:c,children:[c," 条/页"]},c))})]}),e>1&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{type:"button",onClick:()=>i(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:"首页"}),s.jsx("button",{type:"button",onClick:()=>i(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:"上一页"}),s.jsxs("span",{className:"px-3 py-1 text-gray-400 text-sm",children:[t," / ",e]}),s.jsx("button",{type:"button",onClick:()=>i(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:"下一页"}),s.jsx("button",{type:"button",onClick:()=>i(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 lP(){const[t,e]=v.useState([]),[n,r]=v.useState([]),[i,a]=v.useState(0),[o,c]=v.useState(0),[u,h]=v.useState(0),[f,m]=v.useState(1),[g,y]=v.useState(10),[b,j]=v.useState(""),w=Yx(b,300),[N,C]=v.useState("all"),[E,M]=v.useState(!0),[I,O]=v.useState(null),[D,P]=v.useState(null),[L,_]=v.useState(""),[X,ne]=v.useState(!1);async function J(){M(!0),O(null);try{const G=N==="all"?"":N==="completed"?"completed":N,$=new URLSearchParams({page:String(f),pageSize:String(g),...G&&{status:G},...w&&{search:w}}),[H,ce]=await Promise.all([Le(`/api/admin/orders?${$}`),Le("/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)),ce!=null&&ce.success&&ce.users&&r(ce.users)}catch(G){console.error("加载订单失败",G),O("加载订单失败,请检查网络后重试")}finally{M(!1)}}v.useEffect(()=>{m(1)},[w,N]),v.useEffect(()=>{J()},[f,g,w,N]);const U=G=>{var $;return G.userNickname||(($=n.find(H=>H.id===G.userId))==null?void 0:$.nickname)||"匿名用户"},R=G=>{var $;return(($=n.find(H=>H.id===G))==null?void 0:$.phone)||"-"},F=G=>{const $=G.productType||G.type||"",H=G.description||"";if(H){if($==="section"&&H.includes("章节")){if(H.includes("-")){const ce=H.split("-");if(ce.length>=3)return{name:`第${ce[1]}章 第${ce[2]}节`,type:"《一场Soul的创业实验》"}}return{name:H,type:"章节购买"}}return $==="fullbook"||H.includes("全书")?{name:"《一场Soul的创业实验》",type:"全书购买"}:$==="vip"||H.includes("VIP")?{name:"VIP年度会员",type:"VIP"}:$==="match"||H.includes("伙伴")?{name:"找伙伴匹配",type:"功能服务"}:{name:H,type:"其他"}}return $==="section"?{name:`章节 ${G.productId||G.sectionId||""}`,type:"单章"}:$==="fullbook"?{name:"《一场Soul的创业实验》",type:"全书"}:$==="vip"?{name:"VIP年度会员",type:"VIP"}:$==="match"?{name:"找伙伴匹配",type:"功能"}:{name:"未知商品",type:$||"其他"}},re=Math.ceil(i/g)||1;async function z(){var G;if(!(!(D!=null&&D.orderSn)&&!(D!=null&&D.id))){ne(!0),O(null);try{const $=await Mt("/api/admin/orders/refund",{orderSn:D.orderSn||D.id,reason:L||void 0});$!=null&&$.success?(P(null),_(""),J()):O(($==null?void 0:$.error)||"退款失败")}catch($){const H=$;O(((G=H==null?void 0:H.data)==null?void 0:G.error)||"退款失败,请检查网络后重试")}finally{ne(!1)}}}function ae(){if(t.length===0){ie.info("暂无数据可导出");return}const G=["订单号","用户","手机号","商品","金额","支付方式","状态","退款原因","分销佣金","下单时间"],$=t.map(Q=>{const de=F(Q);return[Q.orderSn||Q.id||"",U(Q),R(Q.userId),de.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"+[G.join(","),...$].join(` +`),ce=new Blob([H],{type:"text/csv;charset=utf-8"}),W=URL.createObjectURL(ce),fe=document.createElement("a");fe.href=W,fe.download=`订单列表_${new Date().toISOString().slice(0,10)}.csv`,fe.click(),URL.revokeObjectURL(W)}return s.jsxs("div",{className:"p-8 w-full",children:[I&&s.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:[s.jsx("span",{children:I}),s.jsx("button",{type:"button",onClick:()=>O(null),className:"hover:text-red-300",children:"×"})]}),s.jsxs("div",{className:"flex justify-between items-center mb-8",children:[s.jsxs("div",{children:[s.jsx("h2",{className:"text-2xl font-bold text-white",children:"订单管理"}),s.jsxs("p",{className:"text-gray-400 mt-1",children:["共 ",t.length," 笔订单"]})]}),s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsxs(ee,{variant:"outline",onClick:J,disabled:E,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Ge,{className:`w-4 h-4 mr-2 ${E?"animate-spin":""}`}),"刷新"]}),s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx("span",{className:"text-gray-400",children:"总收入:"}),s.jsxs("span",{className:"text-[#38bdac] font-bold",children:["¥",o.toFixed(2)]}),s.jsx("span",{className:"text-gray-600",children:"|"}),s.jsx("span",{className:"text-gray-400",children:"今日:"}),s.jsxs("span",{className:"text-[#FFD700] font-bold",children:["¥",u.toFixed(2)]})]})]})]}),s.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[s.jsxs("div",{className:"relative flex-1 max-w-md",children:[s.jsx(da,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-500"}),s.jsx(oe,{type:"text",placeholder:"搜索订单号/用户/章节...",className:"pl-10 bg-[#0f2137] border-gray-700 text-white placeholder:text-gray-500",value:b,onChange:G=>j(G.target.value)})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Ww,{className:"w-4 h-4 text-gray-400"}),s.jsxs("select",{value:N,onChange:G=>C(G.target.value),className:"bg-[#0f2137] border border-gray-700 text-white rounded-lg px-3 py-2 text-sm",children:[s.jsx("option",{value:"all",children:"全部状态"}),s.jsx("option",{value:"completed",children:"已完成"}),s.jsx("option",{value:"pending",children:"待支付"}),s.jsx("option",{value:"created",children:"已创建"}),s.jsx("option",{value:"failed",children:"已失败"}),s.jsx("option",{value:"refunded",children:"已退款"})]})]}),s.jsxs(ee,{variant:"outline",onClick:ae,disabled:t.length===0,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(aM,{className:"w-4 h-4 mr-2"}),"导出 CSV"]})]}),s.jsx(Me,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:s.jsx(Ae,{className:"p-0",children:E?s.jsxs("div",{className:"flex items-center justify-center py-12",children:[s.jsx(Ge,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):s.jsxs("div",{children:[s.jsxs(Zn,{children:[s.jsx(er,{children:s.jsxs(st,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[s.jsx(je,{className:"text-gray-400",children:"订单号"}),s.jsx(je,{className:"text-gray-400",children:"用户"}),s.jsx(je,{className:"text-gray-400",children:"商品"}),s.jsx(je,{className:"text-gray-400",children:"金额"}),s.jsx(je,{className:"text-gray-400",children:"支付方式"}),s.jsx(je,{className:"text-gray-400",children:"状态"}),s.jsx(je,{className:"text-gray-400",children:"退款原因"}),s.jsx(je,{className:"text-gray-400",children:"分销佣金"}),s.jsx(je,{className:"text-gray-400",children:"下单时间"}),s.jsx(je,{className:"text-gray-400",children:"操作"})]})}),s.jsxs(tr,{children:[t.map(G=>{const $=F(G);return s.jsxs(st,{className:"hover:bg-[#0a1628] border-gray-700/50",children:[s.jsxs(xe,{className:"font-mono text-xs text-gray-400",children:[(G.orderSn||G.id||"").slice(0,12),"..."]}),s.jsx(xe,{children:s.jsxs("div",{children:[s.jsx("p",{className:"text-white text-sm",children:U(G)}),s.jsx("p",{className:"text-gray-500 text-xs",children:R(G.userId)})]})}),s.jsx(xe,{children:s.jsxs("div",{children:[s.jsxs("p",{className:"text-white text-sm flex items-center gap-2",children:[$.name,(G.productType||G.type)==="vip"&&s.jsx(Ue,{className:"bg-amber-500/20 text-amber-400 hover:bg-amber-500/20 border-0 text-xs",children:"VIP"})]}),s.jsx("p",{className:"text-gray-500 text-xs",children:$.type})]})}),s.jsxs(xe,{className:"text-[#38bdac] font-bold",children:["¥",Number(G.amount||0).toFixed(2)]}),s.jsx(xe,{className:"text-gray-300",children:G.paymentMethod==="wechat"?"微信支付":G.paymentMethod==="alipay"?"支付宝":G.paymentMethod||"微信支付"}),s.jsx(xe,{children:G.status==="refunded"?s.jsx(Ue,{className:"bg-gray-500/20 text-gray-400 hover:bg-gray-500/20 border-0",children:"已退款"}):G.status==="paid"||G.status==="completed"?s.jsx(Ue,{className:"bg-green-500/20 text-green-400 hover:bg-green-500/20 border-0",children:"已完成"}):G.status==="pending"||G.status==="created"?s.jsx(Ue,{className:"bg-yellow-500/20 text-yellow-400 hover:bg-yellow-500/20 border-0",children:"待支付"}):s.jsx(Ue,{className:"bg-red-500/20 text-red-400 hover:bg-red-500/20 border-0",children:"已失败"})}),s.jsx(xe,{className:"text-gray-400 text-sm max-w-[120px] truncate",title:G.refundReason,children:G.status==="refunded"&&G.refundReason?G.refundReason:"-"}),s.jsx(xe,{className:"text-[#FFD700]",children:G.referrerEarnings?`¥${Number(G.referrerEarnings).toFixed(2)}`:"-"}),s.jsx(xe,{className:"text-gray-400 text-sm",children:new Date(G.createdAt).toLocaleString("zh-CN")}),s.jsx(xe,{children:(G.status==="paid"||G.status==="completed")&&s.jsxs(ee,{variant:"outline",size:"sm",className:"border-orange-500/50 text-orange-400 hover:bg-orange-500/20",onClick:()=>{P(G),_("")},children:[s.jsx(Gw,{className:"w-3 h-3 mr-1"}),"退款"]})})]},G.id)}),t.length===0&&s.jsx(st,{children:s.jsx(xe,{colSpan:10,className:"text-center py-12 text-gray-500",children:"暂无订单数据"})})]})]}),s.jsx(gs,{page:f,totalPages:re,total:i,pageSize:g,onPageChange:m,onPageSizeChange:G=>{y(G),m(1)}})]})})}),s.jsx(Kt,{open:!!D,onOpenChange:G=>!G&&P(null),children:s.jsxs(zt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",children:[s.jsx(qt,{children:s.jsx(Gt,{className:"text-white",children:"订单退款"})}),D&&s.jsxs("div",{className:"space-y-4",children:[s.jsxs("p",{className:"text-gray-400 text-sm",children:["订单号:",D.orderSn||D.id]}),s.jsxs("p",{className:"text-gray-400 text-sm",children:["退款金额:¥",Number(D.amount||0).toFixed(2)]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-sm text-gray-400 block mb-2",children:"退款原因(选填)"}),s.jsx("div",{className:"form-input",children:s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500",placeholder:"如:用户申请退款",value:L,onChange:G=>_(G.target.value)})})]}),s.jsx("p",{className:"text-orange-400/80 text-xs",children:"退款将原路退回至用户微信,且无法撤销,请确认后再操作。"})]}),s.jsxs(hn,{children:[s.jsx(ee,{variant:"outline",className:"border-gray-600 text-gray-300",onClick:()=>P(null),disabled:X,children:"取消"}),s.jsx(ee,{className:"bg-orange-500 hover:bg-orange-600 text-white",onClick:z,disabled:X,children:X?"退款中...":"确认退款"})]})]})})]})}const _l=v.forwardRef(({className:t,...e},n)=>s.jsx("textarea",{className:Ct("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}));_l.displayName="Textarea";const Mu=[{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 cP(){var Js,Ai,ks,Oa,Da;const[t,e]=zw(),n=t.get("pool"),[r,i]=v.useState([]),[a,o]=v.useState(0),[c,u]=v.useState(1),[h,f]=v.useState(10),[m,g]=v.useState(""),y=Yx(m,300),b=n==="vip"?"vip":n==="complete"?"complete":"all",[j,w]=v.useState(b),[N,C]=v.useState(!0),[E,M]=v.useState(!1),[I,O]=v.useState(null),[D,P]=v.useState(!1),[L,_]=v.useState("desc");v.useEffect(()=>{n==="vip"?w("vip"):n==="complete"?w("complete"):n==="all"&&w("all")},[n]);const[X,ne]=v.useState(!1),[J,U]=v.useState(null),[R,F]=v.useState(!1),[re,z]=v.useState(!1),[ae,G]=v.useState({referrals:[],stats:{}}),[$,H]=v.useState(!1),[ce,W]=v.useState(null),[fe,Q]=v.useState(!1),[de,he]=v.useState(null),[Ne,Te]=v.useState({phone:"",nickname:"",password:"",isAdmin:!1,hasFullBook:!1}),[Ve,He]=v.useState([]),[gt,Pt]=v.useState(!1),[wn,ht]=v.useState(!1),[At,te]=v.useState(null),[Pe,Qe]=v.useState({title:"",description:"",trigger:"",sort:0,enabled:!0}),[xt,ft]=v.useState([]),[pt,wt]=v.useState(!1),[Xt,Ot]=v.useState(null),[Tn,Dt]=v.useState(null),[Kn,Xr]=v.useState({}),[ir,me]=v.useState(!1);async function ve(V=!1){var Re;C(!0),V&&M(!0),O(null);try{if(D){const Xe=new URLSearchParams({search:y,limit:String(h*5)}),et=await Le(`/api/db/users/rfm?${Xe}`);if(et!=null&&et.success){let Mn=et.users||[];L==="asc"&&(Mn=[...Mn].reverse());const lr=(c-1)*h;i(Mn.slice(lr,lr+h)),o(((Re=et.users)==null?void 0:Re.length)??0),Mn.length===0&&(P(!1),O("暂无订单数据,RFM 排序需要用户有购买记录后才能生效"))}else P(!1),O((et==null?void 0:et.error)||"RFM 加载失败,已切回普通模式")}else{const Xe=new URLSearchParams({page:String(c),pageSize:String(h),search:y,...j==="vip"&&{vip:"true"},...j==="complete"&&{pool:"complete"}}),et=await Le(`/api/db/users?${Xe}`);et!=null&&et.success?(i(et.users||[]),o(et.total??0)):O((et==null?void 0:et.error)||"加载失败")}}catch(Xe){console.error("Load users error:",Xe),O("网络错误")}finally{C(!1),V&&M(!1)}}v.useEffect(()=>{u(1)},[y,j,D]),v.useEffect(()=>{ve()},[c,h,y,j,D,L]);const ar=Math.ceil(a/h)||1,Hs=()=>{D?L==="desc"?_("asc"):(P(!1),_("desc")):(P(!0),_("desc"))},ki=V=>({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"})[V||""]||"bg-gray-500/20 text-gray-400";async function Si(V){if(confirm("确定要删除这个用户吗?"))try{const Re=await Ps(`/api/db/users?id=${encodeURIComponent(V)}`);Re!=null&&Re.success?ve():ie.error("删除失败: "+((Re==null?void 0:Re.error)||""))}catch{ie.error("删除失败")}}const Sr=V=>{U(V),Te({phone:V.phone||"",nickname:V.nickname||"",password:"",isAdmin:!!(V.isAdmin??!1),hasFullBook:!!(V.hasFullBook??!1)}),ne(!0)},Aa=()=>{U(null),Te({phone:"",nickname:"",password:"",isAdmin:!1,hasFullBook:!1}),ne(!0)};async function _r(){if(!Ne.phone||!Ne.nickname){ie.error("请填写手机号和昵称");return}F(!0);try{if(J){const V=await Mt("/api/db/users",{id:J.id,nickname:Ne.nickname,isAdmin:Ne.isAdmin,hasFullBook:Ne.hasFullBook,...Ne.password&&{password:Ne.password}});if(!(V!=null&&V.success)){ie.error("更新失败: "+((V==null?void 0:V.error)||""));return}}else{const V=await Nt("/api/db/users",{phone:Ne.phone,nickname:Ne.nickname,password:Ne.password,isAdmin:Ne.isAdmin});if(!(V!=null&&V.success)){ie.error("创建失败: "+((V==null?void 0:V.error)||""));return}}ne(!1),ve()}catch{ie.error("保存失败")}finally{F(!1)}}async function Zr(V){W(V),z(!0),H(!0);try{const Re=await Le(`/api/db/users/referrals?userId=${encodeURIComponent(V.id)}`);Re!=null&&Re.success?G({referrals:Re.referrals||[],stats:Re.stats||{}}):G({referrals:[],stats:{}})}catch{G({referrals:[],stats:{}})}finally{H(!1)}}const or=v.useCallback(async()=>{Pt(!0);try{const V=await Le("/api/db/user-rules");V!=null&&V.success&&He(V.rules||[])}catch{}finally{Pt(!1)}},[]);async function Ci(){if(!Pe.title){ie.error("请填写规则标题");return}F(!0);try{if(At){const V=await Mt("/api/db/user-rules",{id:At.id,...Pe});if(!(V!=null&&V.success)){ie.error("更新失败: "+((V==null?void 0:V.error)||""));return}}else{const V=await Nt("/api/db/user-rules",Pe);if(!(V!=null&&V.success)){ie.error("创建失败: "+((V==null?void 0:V.error)||""));return}}ht(!1),or()}catch{ie.error("保存失败")}finally{F(!1)}}async function Ia(V){if(confirm("确定删除?"))try{const Re=await Ps(`/api/db/user-rules?id=${V}`);Re!=null&&Re.success&&or()}catch{}}async function Ws(V){try{await Mt("/api/db/user-rules",{id:V.id,enabled:!V.enabled}),or()}catch{}}const ot=v.useCallback(async()=>{wt(!0);try{const V=await Le("/api/db/vip-members?limit=500");if(V!=null&&V.success&&V.data){const Re=[...V.data].map((Xe,et)=>({...Xe,vipSort:typeof Xe.vipSort=="number"?Xe.vipSort:et+1}));Re.sort((Xe,et)=>(Xe.vipSort??999999)-(et.vipSort??999999)),ft(Re)}else V&&V.error&&ie.error(V.error)}catch{ie.error("加载超级个体列表失败")}finally{wt(!1)}},[]),[Ln,es]=v.useState(!1),[Cr,ts]=v.useState(null),[rn,zr]=v.useState(""),[Us,$r]=v.useState(!1),Ks=["创业者","资源整合者","技术达人","投资人","产品经理","流量操盘手"],jn=V=>{ts(V),zr(V.vipRole||""),es(!0)},Ns=async V=>{const Re=V.trim();if(Cr){if(!Re){ie.error("请选择或输入标签");return}$r(!0);try{const Xe=await Mt("/api/db/users",{id:Cr.id,vipRole:Re});if(!(Xe!=null&&Xe.success)){ie.error((Xe==null?void 0:Xe.error)||"更新超级个体标签失败");return}ie.success("已更新超级个体标签"),es(!1),ts(null),await ot()}catch{ie.error("更新超级个体标签失败")}finally{$r(!1)}}},[Hl,Ei]=v.useState(!1),[qs,mr]=v.useState(null),[Ra,Ti]=v.useState(""),[Gs,ws]=v.useState(!1),Mi=V=>{mr(V),Ti(V.vipSort!=null?String(V.vipSort):""),Ei(!0)},To=async()=>{if(!qs)return;const V=Number(Ra);if(!Number.isFinite(V)){ie.error("请输入有效的数字序号");return}ws(!0);try{const Re=await Mt("/api/db/users",{id:qs.id,vipSort:V});if(!(Re!=null&&Re.success)){ie.error((Re==null?void 0:Re.error)||"更新排序序号失败");return}ie.success("已更新排序序号"),Ei(!1),mr(null),await ot()}catch{ie.error("更新排序序号失败")}finally{ws(!1)}},js=(V,Re)=>{V.dataTransfer.effectAllowed="move",V.dataTransfer.setData("text/plain",Re),Ot(Re)},Pa=(V,Re)=>{V.preventDefault(),Tn!==Re&&Dt(Re)},Mo=()=>{Ot(null),Dt(null)},Tt=async(V,Re)=>{V.preventDefault();const Xe=V.dataTransfer.getData("text/plain")||Xt;if(Ot(null),Dt(null),!Xe||Xe===Re)return;const et=xt.find(Jt=>Jt.id===Xe),Mn=xt.find(Jt=>Jt.id===Re);if(!et||!Mn)return;const lr=et.vipSort??xt.findIndex(Jt=>Jt.id===Xe)+1,Io=Mn.vipSort??xt.findIndex(Jt=>Jt.id===Re)+1;ft(Jt=>{const _n=[...Jt],ns=_n.findIndex(Ii=>Ii.id===Xe),Ss=_n.findIndex(Ii=>Ii.id===Re);if(ns===-1||Ss===-1)return Jt;const Ys=[..._n],[Wl,La]=[Ys[ns],Ys[Ss]];return Ys[ns]={...La,vipSort:lr},Ys[Ss]={...Wl,vipSort:Io},Ys});try{const[Jt,_n]=await Promise.all([Mt("/api/db/users",{id:Xe,vipSort:Io}),Mt("/api/db/users",{id:Re,vipSort:lr})]);if(!(Jt!=null&&Jt.success)||!(_n!=null&&_n.success)){ie.error((Jt==null?void 0:Jt.error)||(_n==null?void 0:_n.error)||"更新排序失败"),await ot();return}ie.success("已更新排序"),await ot()}catch{ie.error("更新排序失败"),await ot()}},Ao=v.useCallback(async()=>{me(!0);try{const V=await Le("/api/db/users/journey-stats");V!=null&&V.success&&V.stats&&Xr(V.stats)}catch{}finally{me(!1)}},[]);return s.jsxs("div",{className:"p-8 w-full",children:[I&&s.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:[s.jsx("span",{children:I}),s.jsx("button",{type:"button",onClick:()=>O(null),children:"×"})]}),s.jsx("div",{className:"flex justify-between items-center mb-6",children:s.jsxs("div",{children:[s.jsx("h2",{className:"text-2xl font-bold text-white",children:"用户管理"}),s.jsxs("p",{className:"text-gray-400 mt-1 text-sm",children:["共 ",a," 位注册用户",D&&" · RFM 排序中"]})]})}),s.jsxs(fd,{defaultValue:"users",className:"w-full",children:[s.jsxs(Ll,{className:"bg-[#0a1628] border border-gray-700/50 p-1 mb-6 flex-wrap h-auto gap-1",children:[s.jsxs(tn,{value:"users",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] flex items-center gap-1.5",children:[s.jsx(Un,{className:"w-4 h-4"})," 用户列表"]}),s.jsxs(tn,{value:"journey",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] flex items-center gap-1.5",onClick:Ao,children:[s.jsx(pl,{className:"w-4 h-4"})," 用户旅程总览"]}),s.jsxs(tn,{value:"rules",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] flex items-center gap-1.5",onClick:or,children:[s.jsx(so,{className:"w-4 h-4"})," 规则配置"]}),s.jsxs(tn,{value:"vip-roles",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] flex items-center gap-1.5",onClick:ot,children:[s.jsx(xl,{className:"w-4 h-4"})," 超级个体列表"]})]}),s.jsxs(nn,{value:"users",children:[s.jsxs("div",{className:"flex items-center gap-3 mb-4 justify-end flex-wrap",children:[s.jsxs(ee,{variant:"outline",onClick:()=>ve(!0),disabled:E,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Ge,{className:`w-4 h-4 mr-2 ${E?"animate-spin":""}`})," 刷新"]}),s.jsxs("select",{value:j,onChange:V=>{const Re=V.target.value;w(Re),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:[s.jsx("option",{value:"all",children:"全部用户"}),s.jsx("option",{value:"vip",children:"VIP会员(超级个体)"}),s.jsx("option",{value:"complete",children:"完善资料用户"})]}),s.jsxs("div",{className:"relative",children:[s.jsx(da,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-500"}),s.jsx(oe,{type:"text",placeholder:"搜索用户...",className:"pl-10 bg-[#0f2137] border-gray-700 text-white placeholder:text-gray-500 w-56",value:m,onChange:V=>g(V.target.value)})]}),s.jsxs(ee,{onClick:Aa,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(Eg,{className:"w-4 h-4 mr-2"})," 添加用户"]})]}),s.jsx(Me,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:s.jsx(Ae,{className:"p-0",children:N?s.jsxs("div",{className:"flex items-center justify-center py-12",children:[s.jsx(Ge,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):s.jsxs("div",{children:[s.jsxs(Zn,{children:[s.jsx(er,{children:s.jsxs(st,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[s.jsx(je,{className:"text-gray-400",children:"用户信息"}),s.jsx(je,{className:"text-gray-400",children:"绑定信息"}),s.jsx(je,{className:"text-gray-400",children:"购买状态"}),s.jsx(je,{className:"text-gray-400",children:"分销收益"}),s.jsxs(je,{className:"text-gray-400 cursor-pointer select-none",onClick:Hs,children:[s.jsxs("div",{className:"flex items-center gap-1 group",children:[s.jsx(Oc,{className:"w-3.5 h-3.5"}),s.jsx("span",{children:"RFM分值"}),D?L==="desc"?s.jsx(Gc,{className:"w-3.5 h-3.5 text-[#38bdac]"}):s.jsx(Fw,{className:"w-3.5 h-3.5 text-[#38bdac]"}):s.jsx(wm,{className:"w-3.5 h-3.5 text-gray-600 group-hover:text-gray-400"})]}),D&&s.jsx("div",{className:"text-[10px] text-[#38bdac] font-normal mt-0.5",children:"点击切换方向/关闭"})]}),s.jsx(je,{className:"text-gray-400",children:"注册时间"}),s.jsx(je,{className:"text-right text-gray-400",children:"操作"})]})}),s.jsxs(tr,{children:[r.map(V=>{var Re,Xe,et;return s.jsxs(st,{className:"hover:bg-[#0a1628] border-gray-700/50",children:[s.jsx(xe,{children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-10 h-10 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-sm font-medium text-[#38bdac]",children:V.avatar?s.jsx("img",{src:V.avatar,className:"w-full h-full rounded-full object-cover",alt:""}):((Re=V.nickname)==null?void 0:Re.charAt(0))||"?"}),s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("button",{type:"button",onClick:()=>{he(V.id),Q(!0)},className:"font-medium text-[#38bdac] hover:text-[#2da396] hover:underline text-left",children:V.nickname}),V.isAdmin&&s.jsx(Ue,{className:"bg-purple-500/20 text-purple-400 hover:bg-purple-500/20 border-0 text-xs",children:"管理员"}),V.openId&&!((Xe=V.id)!=null&&Xe.startsWith("user_"))&&s.jsx(Ue,{className:"bg-green-500/20 text-green-400 hover:bg-green-500/20 border-0 text-xs",children:"微信"})]}),s.jsx("p",{className:"text-xs text-gray-500 font-mono",children:V.openId?V.openId.slice(0,12)+"...":(et=V.id)==null?void 0:et.slice(0,12)})]})]})}),s.jsx(xe,{children:s.jsxs("div",{className:"space-y-1",children:[V.phone&&s.jsxs("div",{className:"flex items-center gap-1 text-xs",children:[s.jsx("span",{className:"text-gray-500",children:"📱"}),s.jsx("span",{className:"text-gray-300",children:V.phone})]}),V.wechatId&&s.jsxs("div",{className:"flex items-center gap-1 text-xs",children:[s.jsx("span",{className:"text-gray-500",children:"💬"}),s.jsx("span",{className:"text-gray-300",children:V.wechatId})]}),V.openId&&s.jsxs("div",{className:"flex items-center gap-1 text-xs",children:[s.jsx("span",{className:"text-gray-500",children:"🔗"}),s.jsxs("span",{className:"text-gray-500 truncate max-w-[100px]",title:V.openId,children:[V.openId.slice(0,12),"..."]})]}),!V.phone&&!V.wechatId&&!V.openId&&s.jsx("span",{className:"text-gray-600 text-xs",children:"未绑定"})]})}),s.jsx(xe,{children:V.hasFullBook?s.jsx(Ue,{className:"bg-amber-500/20 text-amber-400 hover:bg-amber-500/20 border-0",children:"VIP"}):s.jsx(Ue,{variant:"outline",className:"text-gray-500 border-gray-600",children:"未购买"})}),s.jsx(xe,{children:s.jsxs("div",{className:"space-y-1",children:[s.jsxs("div",{className:"text-white font-medium",children:["¥",parseFloat(String(V.earnings||0)).toFixed(2)]}),parseFloat(String(V.pendingEarnings||0))>0&&s.jsxs("div",{className:"text-xs text-yellow-400",children:["待提现: ¥",parseFloat(String(V.pendingEarnings||0)).toFixed(2)]}),s.jsxs("div",{className:"text-xs text-[#38bdac] cursor-pointer hover:underline flex items-center gap-1",onClick:()=>Zr(V),role:"button",tabIndex:0,onKeyDown:Mn=>Mn.key==="Enter"&&Zr(V),children:[s.jsx(Un,{className:"w-3 h-3"})," 绑定",V.referralCount||0,"人"]})]})}),s.jsx(xe,{children:V.rfmScore!==void 0?s.jsx("div",{className:"flex flex-col gap-1",children:s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("span",{className:"text-white font-bold text-base",children:V.rfmScore}),s.jsx(Ue,{className:`border-0 text-xs ${ki(V.rfmLevel)}`,children:V.rfmLevel})]})}):s.jsxs("span",{className:"text-gray-600 text-sm",children:["— ",s.jsx("span",{className:"text-xs text-gray-700",children:"点列头排序"})]})}),s.jsx(xe,{className:"text-gray-400",children:V.createdAt?new Date(V.createdAt).toLocaleDateString():"-"}),s.jsx(xe,{className:"text-right",children:s.jsxs("div",{className:"flex items-center justify-end gap-1",children:[s.jsx(ee,{variant:"ghost",size:"sm",onClick:()=>{he(V.id),Q(!0)},className:"text-gray-400 hover:text-blue-400 hover:bg-blue-400/10",title:"用户详情",children:s.jsx(oh,{className:"w-4 h-4"})}),s.jsx(ee,{variant:"ghost",size:"sm",onClick:()=>Sr(V),className:"text-gray-400 hover:text-[#38bdac] hover:bg-[#38bdac]/10",title:"编辑用户",children:s.jsx(_t,{className:"w-4 h-4"})}),s.jsx(ee,{variant:"ghost",size:"sm",className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",onClick:()=>Si(V.id),title:"删除",children:s.jsx(Bn,{className:"w-4 h-4"})})]})})]},V.id)}),r.length===0&&s.jsx(st,{children:s.jsx(xe,{colSpan:7,className:"text-center py-12 text-gray-500",children:"暂无用户数据"})})]})]}),s.jsx(gs,{page:c,totalPages:ar,total:a,pageSize:h,onPageChange:u,onPageSizeChange:V=>{f(V),u(1)}})]})})})]}),s.jsxs(nn,{value:"journey",children:[s.jsxs("div",{className:"flex items-center justify-between mb-5",children:[s.jsx("p",{className:"text-gray-400 text-sm",children:"用户从注册到 VIP 的完整行动路径,点击各阶段查看用户动态"}),s.jsxs(ee,{variant:"outline",onClick:Ao,disabled:ir,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Ge,{className:`w-4 h-4 mr-2 ${ir?"animate-spin":""}`})," 刷新数据"]})]}),s.jsxs("div",{className:"relative mb-8",children:[s.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"}),s.jsx("div",{className:"grid grid-cols-4 gap-4 lg:grid-cols-8",children:Mu.map((V,Re)=>s.jsxs("div",{className:"relative flex flex-col items-center",children:[s.jsxs("div",{className:`relative w-full p-3 rounded-xl border ${V.color} text-center cursor-default`,children:[s.jsx("div",{className:"text-2xl mb-1",children:V.icon}),s.jsx("div",{className:`text-xs font-medium ${V.color.split(" ").find(Xe=>Xe.startsWith("text-"))}`,children:V.label}),Kn[V.id]!==void 0&&s.jsxs("div",{className:"mt-1.5 text-xs text-gray-400",children:[s.jsx("span",{className:"font-bold text-white",children:Kn[V.id]})," 人"]}),s.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:Re+1})]}),Res.jsxs("div",{className:"flex items-start gap-3 p-2 bg-[#0a1628] rounded",children:[s.jsx("span",{className:"text-[#38bdac] font-mono text-xs shrink-0 mt-0.5",children:V.step}),s.jsxs("div",{children:[s.jsx("p",{className:"text-gray-300",children:V.action}),s.jsxs("p",{className:"text-gray-600 text-xs",children:["→ ",V.next]})]})]},V.step))})]}),s.jsxs("div",{className:"bg-[#0f2137] border border-gray-700/50 rounded-lg p-4",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[s.jsx(ps,{className:"w-4 h-4 text-purple-400"}),s.jsx("span",{className:"text-white font-medium",children:"行为锚点统计"}),s.jsx("span",{className:"text-gray-500 text-xs ml-auto",children:"实时更新"})]}),ir?s.jsx("div",{className:"flex items-center justify-center py-8",children:s.jsx(Ge,{className:"w-5 h-5 text-[#38bdac] animate-spin"})}):Object.keys(Kn).length>0?s.jsx("div",{className:"space-y-2",children:Mu.map(V=>{const Re=Kn[V.id]||0,Xe=Math.max(...Mu.map(Mn=>Kn[Mn.id]||0),1),et=Math.round(Re/Xe*100);return s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("span",{className:"text-gray-500 text-xs w-20 shrink-0",children:[V.icon," ",V.label]}),s.jsx("div",{className:"flex-1 h-2 bg-[#0a1628] rounded-full overflow-hidden",children:s.jsx("div",{className:"h-full bg-[#38bdac]/60 rounded-full transition-all",style:{width:`${et}%`}})}),s.jsx("span",{className:"text-gray-400 text-xs w-10 text-right",children:Re})]},V.id)})}):s.jsx("div",{className:"text-center py-8",children:s.jsx("p",{className:"text-gray-500 text-sm",children:"点击「刷新数据」加载统计"})})]})]})]}),s.jsxs(nn,{value:"rules",children:[s.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[s.jsx("p",{className:"text-gray-400 text-sm",children:"用户旅程引导规则,定义各行为节点的触发条件与引导内容"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(ee,{variant:"outline",onClick:or,disabled:gt,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Ge,{className:`w-4 h-4 mr-2 ${gt?"animate-spin":""}`})," 刷新"]}),s.jsxs(ee,{onClick:()=>{te(null),Qe({title:"",description:"",trigger:"",sort:0,enabled:!0}),ht(!0)},className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(dn,{className:"w-4 h-4 mr-2"})," 添加规则"]})]})]}),gt?s.jsx("div",{className:"flex items-center justify-center py-12",children:s.jsx(Ge,{className:"w-6 h-6 text-[#38bdac] animate-spin"})}):Ve.length===0?s.jsxs("div",{className:"text-center py-16 bg-[#0f2137] rounded-lg border border-gray-700/50",children:[s.jsx(ps,{className:"w-12 h-12 text-[#38bdac]/30 mx-auto mb-4"}),s.jsx("p",{className:"text-gray-400 mb-4",children:"暂无规则(重启服务将自动写入10条默认规则)"}),s.jsxs(ee,{onClick:or,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(Ge,{className:"w-4 h-4 mr-2"})," 重新加载"]})]}):s.jsx("div",{className:"space-y-2",children:Ve.map(V=>s.jsx("div",{className:`p-4 rounded-lg border transition-all ${V.enabled?"bg-[#0f2137] border-gray-700/50":"bg-[#0a1628]/50 border-gray-700/30 opacity-55"}`,children:s.jsxs("div",{className:"flex items-start justify-between",children:[s.jsxs("div",{className:"flex-1",children:[s.jsxs("div",{className:"flex items-center gap-2 flex-wrap mb-1",children:[s.jsx(_t,{className:"w-4 h-4 text-[#38bdac] shrink-0"}),s.jsx("span",{className:"text-white font-medium",children:V.title}),V.trigger&&s.jsxs(Ue,{className:"bg-[#38bdac]/10 text-[#38bdac] border border-[#38bdac]/30 text-xs",children:["触发:",V.trigger]}),s.jsx(Ue,{className:`text-xs border-0 ${V.enabled?"bg-green-500/20 text-green-400":"bg-gray-500/20 text-gray-400"}`,children:V.enabled?"启用":"禁用"})]}),V.description&&s.jsx("p",{className:"text-gray-400 text-sm ml-6",children:V.description})]}),s.jsxs("div",{className:"flex items-center gap-2 ml-4 shrink-0",children:[s.jsx(Et,{checked:V.enabled,onCheckedChange:()=>Ws(V)}),s.jsx(ee,{variant:"ghost",size:"sm",onClick:()=>{te(V),Qe({title:V.title,description:V.description,trigger:V.trigger,sort:V.sort,enabled:V.enabled}),ht(!0)},className:"text-gray-400 hover:text-[#38bdac] hover:bg-[#38bdac]/10",children:s.jsx(_t,{className:"w-4 h-4"})}),s.jsx(ee,{variant:"ghost",size:"sm",onClick:()=>Ia(V.id),className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:s.jsx(Bn,{className:"w-4 h-4"})})]})]})},V.id))})]}),s.jsxs(nn,{value:"vip-roles",children:[s.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsx("p",{className:"text-gray-400 text-sm",children:"展示当前所有有效的超级个体(VIP 用户),用于检查会员信息与排序值。"}),s.jsx("p",{className:"text-xs text-[#38bdac]",children:"提示:按住任意一行即可拖拽排序,释放后将同步更新小程序展示顺序。"})]}),s.jsx("div",{className:"flex items-center gap-2",children:s.jsxs(ee,{variant:"outline",onClick:ot,disabled:pt,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Ge,{className:`w-4 h-4 mr-2 ${pt?"animate-spin":""}`})," ","刷新"]})})]}),pt?s.jsxs("div",{className:"flex items-center justify-center py-12",children:[s.jsx(Ge,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):xt.length===0?s.jsxs("div",{className:"text-center py-16 bg-[#0f2137] rounded-lg border border-gray-700/50",children:[s.jsx(xl,{className:"w-12 h-12 text-amber-400/30 mx-auto mb-4"}),s.jsx("p",{className:"text-gray-400 mb-4",children:"当前没有有效的超级个体用户。"})]}):s.jsx(Me,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:s.jsx(Ae,{className:"p-0",children:s.jsxs(Zn,{children:[s.jsx(er,{children:s.jsxs(st,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[s.jsx(je,{className:"text-gray-400 w-16",children:"序号"}),s.jsx(je,{className:"text-gray-400",children:"成员"}),s.jsx(je,{className:"text-gray-400 min-w-48",children:"超级个体标签"}),s.jsx(je,{className:"text-gray-400 w-24",children:"排序值"}),s.jsx(je,{className:"text-gray-400 w-40 text-right",children:"操作"})]})}),s.jsx(tr,{children:xt.map((V,Re)=>{var Mn;const Xe=Xt===V.id,et=Tn===V.id;return s.jsxs(st,{draggable:!0,onDragStart:lr=>js(lr,V.id),onDragOver:lr=>Pa(lr,V.id),onDrop:lr=>Tt(lr,V.id),onDragEnd:Mo,className:`border-gray-700/50 cursor-grab active:cursor-grabbing select-none ${Xe?"opacity-60":""} ${et?"bg-[#38bdac]/10":""}`,children:[s.jsx(xe,{className:"text-gray-300",children:Re+1}),s.jsx(xe,{children:s.jsxs("div",{className:"flex items-center gap-3",children:[V.avatar?s.jsx("img",{src:V.avatar,className:"w-8 h-8 rounded-full object-cover border border-amber-400/60"}):s.jsx("div",{className:"w-8 h-8 rounded-full bg-amber-500/20 border border-amber-400/60 flex items-center justify-center text-amber-300 text-sm",children:((Mn=V.name)==null?void 0:Mn[0])||"创"}),s.jsx("div",{className:"min-w-0",children:s.jsx("div",{className:"text-white text-sm truncate",children:V.name})})]})}),s.jsx(xe,{className:"text-gray-300 whitespace-nowrap",children:V.vipRole||s.jsx("span",{className:"text-gray-500",children:"(未设置超级个体标签)"})}),s.jsx(xe,{className:"text-gray-300",children:V.vipSort??Re+1}),s.jsx(xe,{className:"text-right text-xs text-gray-300",children:s.jsxs("div",{className:"inline-flex items-center gap-1.5",children:[s.jsx(ee,{variant:"ghost",size:"sm",className:"h-7 w-7 px-0 text-amber-300 hover:text-amber-200",onClick:()=>jn(V),title:"设置超级个体标签",children:s.jsx(qu,{className:"w-3.5 h-3.5"})}),s.jsx(ee,{variant:"ghost",size:"sm",className:"h-7 w-7 px-0 text-[#38bdac] hover:text-[#5fe0cd]",onClick:()=>{he(V.id),Q(!0)},title:"编辑资料",children:s.jsx(_t,{className:"w-3.5 h-3.5"})}),s.jsx(ee,{variant:"ghost",size:"sm",className:"h-7 w-7 px-0 text-sky-300 hover:text-sky-200",onClick:()=>Mi(V),title:"设置排序序号",children:s.jsx(wm,{className:"w-3.5 h-3.5"})})]})})]},V.id)})})]})})})]})]}),s.jsx(Kt,{open:Hl,onOpenChange:V=>{Ei(V),V||mr(null)},children:s.jsxs(zt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-sm",children:[s.jsx(qt,{children:s.jsxs(Gt,{className:"text-white flex items-center gap-2",children:[s.jsx(wm,{className:"w-5 h-5 text-[#38bdac]"}),"设置排序 — ",qs==null?void 0:qs.name]})}),s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsx(Z,{className:"text-gray-300 text-sm",children:"排序序号(数字越小越靠前)"}),s.jsx(oe,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如:1",value:Ra,onChange:V=>Ti(V.target.value)})]}),s.jsxs(hn,{children:[s.jsxs(ee,{variant:"outline",onClick:()=>Ei(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(hr,{className:"w-4 h-4 mr-2"}),"取消"]}),s.jsxs(ee,{onClick:To,disabled:Gs,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(gn,{className:"w-4 h-4 mr-2"}),Gs?"保存中...":"保存"]})]})]})}),s.jsx(Kt,{open:Ln,onOpenChange:V=>{es(V),V||ts(null)},children:s.jsxs(zt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",children:[s.jsx(qt,{children:s.jsxs(Gt,{className:"text-white flex items-center gap-2",children:[s.jsx(xl,{className:"w-5 h-5 text-amber-400"}),"设置超级个体标签 — ",Cr==null?void 0:Cr.name]})}),s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsx(Z,{className:"text-gray-300 text-sm",children:"选择或输入标签"}),s.jsx("div",{className:"flex flex-wrap gap-2",children:Ks.map(V=>s.jsx(ee,{variant:rn===V?"default":"outline",size:"sm",className:rn===V?"bg-[#38bdac] hover:bg-[#2da396] text-white":"border-gray-600 text-gray-300 hover:bg-gray-700/50",onClick:()=>zr(V),children:V},V))}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-400 text-xs",children:"或手动输入"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如:创业者、资源整合者等",value:rn,onChange:V=>zr(V.target.value)})]})]}),s.jsxs(hn,{children:[s.jsxs(ee,{variant:"outline",onClick:()=>es(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(hr,{className:"w-4 h-4 mr-2"}),"取消"]}),s.jsxs(ee,{onClick:()=>Ns(rn),disabled:Us,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(gn,{className:"w-4 h-4 mr-2"}),Us?"保存中...":"保存"]})]})]})}),s.jsx(Kt,{open:X,onOpenChange:ne,children:s.jsxs(zt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-lg",children:[s.jsx(qt,{children:s.jsxs(Gt,{className:"text-white flex items-center gap-2",children:[J?s.jsx(_t,{className:"w-5 h-5 text-[#38bdac]"}):s.jsx(Eg,{className:"w-5 h-5 text-[#38bdac]"}),J?"编辑用户":"添加用户"]})}),s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"手机号"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"请输入手机号",value:Ne.phone,onChange:V=>Te({...Ne,phone:V.target.value}),disabled:!!J})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"昵称"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"请输入昵称",value:Ne.nickname,onChange:V=>Te({...Ne,nickname:V.target.value})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:J?"新密码 (留空则不修改)":"密码"}),s.jsx(oe,{type:"password",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:J?"留空则不修改":"请输入密码",value:Ne.password,onChange:V=>Te({...Ne,password:V.target.value})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx(Z,{className:"text-gray-300",children:"管理员权限"}),s.jsx(Et,{checked:Ne.isAdmin,onCheckedChange:V=>Te({...Ne,isAdmin:V})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx(Z,{className:"text-gray-300",children:"已购全书"}),s.jsx(Et,{checked:Ne.hasFullBook,onCheckedChange:V=>Te({...Ne,hasFullBook:V})})]})]}),s.jsxs(hn,{children:[s.jsxs(ee,{variant:"outline",onClick:()=>ne(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(hr,{className:"w-4 h-4 mr-2"}),"取消"]}),s.jsxs(ee,{onClick:_r,disabled:R,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(gn,{className:"w-4 h-4 mr-2"}),R?"保存中...":"保存"]})]})]})}),s.jsx(Kt,{open:wn,onOpenChange:ht,children:s.jsxs(zt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-lg",children:[s.jsx(qt,{children:s.jsxs(Gt,{className:"text-white flex items-center gap-2",children:[s.jsx(_t,{className:"w-5 h-5 text-[#38bdac]"}),At?"编辑规则":"添加规则"]})}),s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"规则标题 *"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"例:匹配后填写头像、付款1980需填写信息",value:Pe.title,onChange:V=>Qe({...Pe,title:V.target.value})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"规则描述"}),s.jsx(_l,{className:"bg-[#0a1628] border-gray-700 text-white min-h-[80px] resize-none",placeholder:"详细说明规则内容...",value:Pe.description,onChange:V=>Qe({...Pe,description:V.target.value})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"触发条件"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"例:完成匹配、付款后、注册时",value:Pe.trigger,onChange:V=>Qe({...Pe,trigger:V.target.value})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("div",{children:s.jsx(Z,{className:"text-gray-300",children:"启用状态"})}),s.jsx(Et,{checked:Pe.enabled,onCheckedChange:V=>Qe({...Pe,enabled:V})})]})]}),s.jsxs(hn,{children:[s.jsxs(ee,{variant:"outline",onClick:()=>ht(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(hr,{className:"w-4 h-4 mr-2"}),"取消"]}),s.jsxs(ee,{onClick:Ci,disabled:R,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(gn,{className:"w-4 h-4 mr-2"}),R?"保存中...":"保存"]})]})]})}),s.jsx(Kt,{open:re,onOpenChange:z,children:s.jsxs(zt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-2xl max-h-[80vh] overflow-auto",children:[s.jsx(qt,{children:s.jsxs(Gt,{className:"text-white flex items-center gap-2",children:[s.jsx(Un,{className:"w-5 h-5 text-[#38bdac]"}),"绑定关系 - ",ce==null?void 0:ce.nickname]})}),s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsxs("div",{className:"grid grid-cols-4 gap-3",children:[s.jsxs("div",{className:"bg-[#0a1628] rounded-lg p-3 text-center",children:[s.jsx("div",{className:"text-2xl font-bold text-[#38bdac]",children:((Js=ae.stats)==null?void 0:Js.total)||0}),s.jsx("div",{className:"text-xs text-gray-400",children:"绑定总数"})]}),s.jsxs("div",{className:"bg-[#0a1628] rounded-lg p-3 text-center",children:[s.jsx("div",{className:"text-2xl font-bold text-green-400",children:((Ai=ae.stats)==null?void 0:Ai.purchased)||0}),s.jsx("div",{className:"text-xs text-gray-400",children:"已付费"})]}),s.jsxs("div",{className:"bg-[#0a1628] rounded-lg p-3 text-center",children:[s.jsxs("div",{className:"text-2xl font-bold text-yellow-400",children:["¥",(((ks=ae.stats)==null?void 0:ks.earnings)||0).toFixed(2)]}),s.jsx("div",{className:"text-xs text-gray-400",children:"累计收益"})]}),s.jsxs("div",{className:"bg-[#0a1628] rounded-lg p-3 text-center",children:[s.jsxs("div",{className:"text-2xl font-bold text-orange-400",children:["¥",(((Oa=ae.stats)==null?void 0:Oa.pendingEarnings)||0).toFixed(2)]}),s.jsx("div",{className:"text-xs text-gray-400",children:"待提现"})]})]}),$?s.jsxs("div",{className:"flex items-center justify-center py-8",children:[s.jsx(Ge,{className:"w-5 h-5 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):(((Da=ae.referrals)==null?void 0:Da.length)??0)>0?s.jsx("div",{className:"space-y-2 max-h-[300px] overflow-y-auto",children:(ae.referrals??[]).map((V,Re)=>{var et;const Xe=V;return s.jsxs("div",{className:"flex items-center justify-between bg-[#0a1628] rounded-lg p-3",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-8 h-8 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-sm text-[#38bdac]",children:((et=Xe.nickname)==null?void 0:et.charAt(0))||"?"}),s.jsxs("div",{children:[s.jsx("div",{className:"text-white text-sm",children:Xe.nickname}),s.jsx("div",{className:"text-xs text-gray-500",children:Xe.phone||(Xe.hasOpenId?"微信用户":"未绑定")})]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[Xe.status==="vip"&&s.jsx(Ue,{className:"bg-green-500/20 text-green-400 border-0 text-xs",children:"全书已购"}),Xe.status==="paid"&&s.jsxs(Ue,{className:"bg-blue-500/20 text-blue-400 border-0 text-xs",children:["已付费",Xe.purchasedSections,"章"]}),Xe.status==="free"&&s.jsx(Ue,{className:"bg-gray-500/20 text-gray-400 border-0 text-xs",children:"未付费"}),s.jsx("span",{className:"text-xs text-gray-500",children:Xe.createdAt?new Date(Xe.createdAt).toLocaleDateString():""})]})]},Xe.id||Re)})}):s.jsx("div",{className:"text-center py-8 text-gray-500",children:"暂无绑定用户"})]}),s.jsx(hn,{children:s.jsx(ee,{variant:"outline",onClick:()=>z(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"关闭"})})]})}),s.jsx(Jx,{open:fe,onClose:()=>Q(!1),userId:de,onUserUpdated:ve})]})}function hh(t,[e,n]){return Math.min(n,Math.max(e,t))}var mk=["PageUp","PageDown"],gk=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],xk={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},zl="Slider",[Rg,dP,uP]=Ux(zl),[yk]=ka(zl,[uP]),[hP,xf]=yk(zl),vk=v.forwardRef((t,e)=>{const{name:n,min:r=0,max:i=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:b,...j}=t,w=v.useRef(new Set),N=v.useRef(0),E=o==="horizontal"?fP:pP,[M=[],I]=fo({prop:f,defaultProp:h,onChange:X=>{var J;(J=[...w.current][N.current])==null||J.focus(),m(X)}}),O=v.useRef(M);function D(X){const ne=vP(M,X);_(X,ne)}function P(X){_(X,N.current)}function L(){const X=O.current[N.current];M[N.current]!==X&&g(M)}function _(X,ne,{commit:J}={commit:!1}){const U=jP(a),R=kP(Math.round((X-r)/a)*a+r,U),F=hh(R,[r,i]);I((re=[])=>{const z=xP(re,F,ne);if(wP(z,u*a)){N.current=z.indexOf(F);const ae=String(z)!==String(re);return ae&&J&&g(z),ae?z:re}else return re})}return s.jsx(hP,{scope:t.__scopeSlider,name:n,disabled:c,min:r,max:i,valueIndexToChangeRef:N,thumbs:w.current,values:M,orientation:o,form:b,children:s.jsx(Rg.Provider,{scope:t.__scopeSlider,children:s.jsx(Rg.Slot,{scope:t.__scopeSlider,children:s.jsx(E,{"aria-disabled":c,"data-disabled":c?"":void 0,...j,ref:e,onPointerDown:at(j.onPointerDown,()=>{c||(O.current=M)}),min:r,max:i,inverted:y,onSlideStart:c?void 0:D,onSlideMove:c?void 0:P,onSlideEnd:c?void 0:L,onHomeKeyDown:()=>!c&&_(r,0,{commit:!0}),onEndKeyDown:()=>!c&&_(i,M.length-1,{commit:!0}),onStepKeyDown:({event:X,direction:ne})=>{if(!c){const R=mk.includes(X.key)||X.shiftKey&&gk.includes(X.key)?10:1,F=N.current,re=M[F],z=a*R*ne;_(re+z,F,{commit:!0})}}})})})})});vk.displayName=zl;var[bk,Nk]=yk(zl,{startEdge:"left",endEdge:"right",size:"width",direction:1}),fP=v.forwardRef((t,e)=>{const{min:n,max:r,dir:i,inverted:a,onSlideStart:o,onSlideMove:c,onSlideEnd:u,onStepKeyDown:h,...f}=t,[m,g]=v.useState(null),y=St(e,E=>g(E)),b=v.useRef(void 0),j=pf(i),w=j==="ltr",N=w&&!a||!w&&a;function C(E){const M=b.current||m.getBoundingClientRect(),I=[0,M.width],D=Qx(I,N?[n,r]:[r,n]);return b.current=M,D(E-M.left)}return s.jsx(bk,{scope:t.__scopeSlider,startEdge:N?"left":"right",endEdge:N?"right":"left",direction:N?1:-1,size:"width",children:s.jsx(wk,{dir:j,"data-orientation":"horizontal",...f,ref:y,style:{...f.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:E=>{const M=C(E.clientX);o==null||o(M)},onSlideMove:E=>{const M=C(E.clientX);c==null||c(M)},onSlideEnd:()=>{b.current=void 0,u==null||u()},onStepKeyDown:E=>{const I=xk[N?"from-left":"from-right"].includes(E.key);h==null||h({event:E,direction:I?-1:1})}})})}),pP=v.forwardRef((t,e)=>{const{min:n,max:r,inverted:i,onSlideStart:a,onSlideMove:o,onSlideEnd:c,onStepKeyDown:u,...h}=t,f=v.useRef(null),m=St(e,f),g=v.useRef(void 0),y=!i;function b(j){const w=g.current||f.current.getBoundingClientRect(),N=[0,w.height],E=Qx(N,y?[r,n]:[n,r]);return g.current=w,E(j-w.top)}return s.jsx(bk,{scope:t.__scopeSlider,startEdge:y?"bottom":"top",endEdge:y?"top":"bottom",size:"height",direction:y?1:-1,children:s.jsx(wk,{"data-orientation":"vertical",...h,ref:m,style:{...h.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:j=>{const w=b(j.clientY);a==null||a(w)},onSlideMove:j=>{const w=b(j.clientY);o==null||o(w)},onSlideEnd:()=>{g.current=void 0,c==null||c()},onStepKeyDown:j=>{const N=xk[y?"from-bottom":"from-top"].includes(j.key);u==null||u({event:j,direction:N?-1:1})}})})}),wk=v.forwardRef((t,e)=>{const{__scopeSlider:n,onSlideStart:r,onSlideMove:i,onSlideEnd:a,onHomeKeyDown:o,onEndKeyDown:c,onStepKeyDown:u,...h}=t,f=xf(zl,n);return s.jsx(dt.span,{...h,ref:e,onKeyDown:at(t.onKeyDown,m=>{m.key==="Home"?(o(m),m.preventDefault()):m.key==="End"?(c(m),m.preventDefault()):mk.concat(gk).includes(m.key)&&(u(m),m.preventDefault())}),onPointerDown:at(t.onPointerDown,m=>{const g=m.target;g.setPointerCapture(m.pointerId),m.preventDefault(),f.thumbs.has(g)?g.focus():r(m)}),onPointerMove:at(t.onPointerMove,m=>{m.target.hasPointerCapture(m.pointerId)&&i(m)}),onPointerUp:at(t.onPointerUp,m=>{const g=m.target;g.hasPointerCapture(m.pointerId)&&(g.releasePointerCapture(m.pointerId),a(m))})})}),jk="SliderTrack",kk=v.forwardRef((t,e)=>{const{__scopeSlider:n,...r}=t,i=xf(jk,n);return s.jsx(dt.span,{"data-disabled":i.disabled?"":void 0,"data-orientation":i.orientation,...r,ref:e})});kk.displayName=jk;var Pg="SliderRange",Sk=v.forwardRef((t,e)=>{const{__scopeSlider:n,...r}=t,i=xf(Pg,n),a=Nk(Pg,n),o=v.useRef(null),c=St(e,o),u=i.values.length,h=i.values.map(g=>Tk(g,i.min,i.max)),f=u>1?Math.min(...h):0,m=100-Math.max(...h);return s.jsx(dt.span,{"data-orientation":i.orientation,"data-disabled":i.disabled?"":void 0,...r,ref:c,style:{...t.style,[a.startEdge]:f+"%",[a.endEdge]:m+"%"}})});Sk.displayName=Pg;var Og="SliderThumb",Ck=v.forwardRef((t,e)=>{const n=dP(t.__scopeSlider),[r,i]=v.useState(null),a=St(e,c=>i(c)),o=v.useMemo(()=>r?n().findIndex(c=>c.ref.current===r):-1,[n,r]);return s.jsx(mP,{...t,ref:a,index:o})}),mP=v.forwardRef((t,e)=>{const{__scopeSlider:n,index:r,name:i,...a}=t,o=xf(Og,n),c=Nk(Og,n),[u,h]=v.useState(null),f=St(e,C=>h(C)),m=u?o.form||!!u.closest("form"):!0,g=Gx(u),y=o.values[r],b=y===void 0?0:Tk(y,o.min,o.max),j=yP(r,o.values.length),w=g==null?void 0:g[c.size],N=w?bP(w,b,c.direction):0;return v.useEffect(()=>{if(u)return o.thumbs.add(u),()=>{o.thumbs.delete(u)}},[u,o.thumbs]),s.jsxs("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[c.startEdge]:`calc(${b}% + ${N}px)`},children:[s.jsx(Rg.ItemSlot,{scope:t.__scopeSlider,children:s.jsx(dt.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:at(t.onFocus,()=>{o.valueIndexToChangeRef.current=r})})}),m&&s.jsx(Ek,{name:i??(o.name?o.name+(o.values.length>1?"[]":""):void 0),form:o.form,value:y},r)]})});Ck.displayName=Og;var gP="RadioBubbleInput",Ek=v.forwardRef(({__scopeSlider:t,value:e,...n},r)=>{const i=v.useRef(null),a=St(i,r),o=qx(e);return v.useEffect(()=>{const c=i.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]),s.jsx(dt.input,{style:{display:"none"},...n,ref:a,defaultValue:e})});Ek.displayName=gP;function xP(t=[],e,n){const r=[...t];return r[n]=e,r.sort((i,a)=>i-a)}function Tk(t,e,n){const a=100/(n-e)*(t-e);return hh(a,[0,100])}function yP(t,e){return e>2?`Value ${t+1} of ${e}`:e===2?["Minimum","Maximum"][t]:void 0}function vP(t,e){if(t.length===1)return 0;const n=t.map(i=>Math.abs(i-e)),r=Math.min(...n);return n.indexOf(r)}function bP(t,e,n){const r=t/2,a=Qx([0,50],[0,r]);return(r-a(e)*n)*n}function NP(t){return t.slice(0,-1).map((e,n)=>t[n+1]-e)}function wP(t,e){if(e>0){const n=NP(t);return Math.min(...n)>=e}return!0}function Qx(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 jP(t){return(String(t).split(".")[1]||"").length}function kP(t,e){const n=Math.pow(10,e);return Math.round(t*n)/n}var SP=vk,CP=kk,EP=Sk,TP=Ck;function MP({className:t,defaultValue:e,value:n,min:r=0,max:i=100,...a}){const o=v.useMemo(()=>Array.isArray(n)?n:Array.isArray(e)?e:[r,i],[n,e,r,i]);return s.jsxs(SP,{defaultValue:e,value:n,min:r,max:i,className:Ct("relative flex w-full touch-none items-center select-none data-[disabled]:opacity-50",t),...a,children:[s.jsx(CP,{className:"bg-gray-600 relative grow overflow-hidden rounded-full h-1.5 w-full",children:s.jsx(EP,{className:"bg-[#38bdac] absolute h-full rounded-full"})}),Array.from({length:o.length},(c,u)=>s.jsx(TP,{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 AP={distributorShare:90,minWithdrawAmount:10,bindingDays:30,userDiscount:5,enableAutoWithdraw:!1,vipOrderShareVip:20,vipOrderShareNonVip:10};function Mk(t){const[e,n]=v.useState(AP),[r,i]=v.useState(!0),[a,o]=v.useState(!1);v.useEffect(()=>{Le("/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(()=>i(!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 Nt("/api/admin/referral-settings",h);if(!f||f.success===!1){ie.error("保存失败: "+(f&&typeof f=="object"&&"error"in f?f.error:""));return}ie.success(`✅ 分销配置已保存成功! + +• 小程序与网站的推广规则会一起生效 +• 绑定关系会使用新的天数配置 +• 佣金比例会立即应用到新订单 + +如有缓存,请刷新前台/小程序页面。`)}catch(h){console.error(h),ie.error("保存失败: "+(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?s.jsx("div",{className:"p-8 text-gray-500",children:"加载中..."}):s.jsxs("div",{className:"p-8 w-full",children:[s.jsxs("div",{className:"flex justify-between items-center mb-8",children:[s.jsxs("div",{children:[s.jsxs("h2",{className:"text-2xl font-bold text-white flex items-center gap-2",children:[s.jsx(jl,{className:"w-5 h-5 text-[#38bdac]"}),"推广 / 分销设置"]}),s.jsx("p",{className:"text-gray-400 mt-1",children:"统一管理「好友优惠」「你得 90% 收益」「绑定期 30 天」「提现门槛」等规则,小程序和 Web 共用这套配置。"})]}),s.jsxs(ee,{onClick:c,disabled:a||r,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(gn,{className:"w-4 h-4 mr-2"}),a?"保存中...":"保存配置"]})]}),s.jsxs("div",{className:"space-y-6",children:[s.jsxs(Me,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(nt,{children:[s.jsxs(rt,{className:"flex items-center gap-2 text-white",children:[s.jsx(lA,{className:"w-4 h-4 text-[#38bdac]"}),"推广规则"]}),s.jsx($t,{className:"text-gray-400",children:"这三项会直接体现在小程序「推广规则」卡片上,同时影响实收佣金计算。"})]}),s.jsx(Ae,{className:"space-y-6",children:s.jsxs("div",{className:"grid grid-cols-3 gap-6",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsxs(Z,{className:"text-gray-300 flex items-center gap-2",children:[s.jsx(bu,{className:"w-3 h-3 text-[#38bdac]"}),"好友优惠(%)"]}),s.jsx(oe,{type:"number",min:0,max:100,className:"bg-[#0a1628] border-gray-700 text-white",value:e.userDiscount,onChange:u("userDiscount")}),s.jsx("p",{className:"text-xs text-gray-500",children:"例如 5 表示好友立减 5%(在价格配置基础上生效)。"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs(Z,{className:"text-gray-300 flex items-center gap-2",children:[s.jsx(Un,{className:"w-3 h-3 text-[#38bdac]"}),"推广者分成(%)"]}),s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsx(MP,{className:"flex-1",min:10,max:100,step:1,value:[e.distributorShare],onValueChange:([h])=>n(f=>({...f,distributorShare:h}))}),s.jsx(oe,{type:"number",min:0,max:100,className:"w-20 bg-[#0a1628] border-gray-700 text-white text-center",value:e.distributorShare,onChange:u("distributorShare")})]}),s.jsxs("p",{className:"text-xs text-gray-500",children:["内容订单佣金 = 订单金额 ×"," ",s.jsxs("span",{className:"text-[#38bdac] font-mono",children:[e.distributorShare,"%"]}),";会员订单见下方。"]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs(Z,{className:"text-gray-300 flex items-center gap-2",children:[s.jsx(bu,{className:"w-3 h-3 text-[#38bdac]"}),"会员订单分润(推广者是会员 %)"]}),s.jsx(oe,{type:"number",min:0,max:100,className:"bg-[#0a1628] border-gray-700 text-white",value:e.vipOrderShareVip,onChange:u("vipOrderShareVip")}),s.jsx("p",{className:"text-xs text-gray-500",children:"推广者已是会员时,会员订单佣金比例,默认 20%。"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs(Z,{className:"text-gray-300 flex items-center gap-2",children:[s.jsx(bu,{className:"w-3 h-3 text-[#38bdac]"}),"会员订单分润(推广者非会员 %)"]}),s.jsx(oe,{type:"number",min:0,max:100,className:"bg-[#0a1628] border-gray-700 text-white",value:e.vipOrderShareNonVip,onChange:u("vipOrderShareNonVip")}),s.jsx("p",{className:"text-xs text-gray-500",children:"推广者非会员时,会员订单佣金比例,默认 10%。"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs(Z,{className:"text-gray-300 flex items-center gap-2",children:[s.jsx(Un,{className:"w-3 h-3 text-[#38bdac]"}),"绑定有效期(天)"]}),s.jsx(oe,{type:"number",min:1,max:365,className:"bg-[#0a1628] border-gray-700 text-white",value:e.bindingDays,onChange:u("bindingDays")}),s.jsx("p",{className:"text-xs text-gray-500",children:"好友通过你的链接进来并登录后,绑定在你名下的天数。"})]})]})})]}),s.jsxs(Me,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(nt,{children:[s.jsxs(rt,{className:"flex items-center gap-2 text-white",children:[s.jsx(jl,{className:"w-4 h-4 text-[#38bdac]"}),"提现规则"]}),s.jsx($t,{className:"text-gray-400",children:"与「提现中心」「自动提现」相关的参数,影响推广者看到的可提现金额和最低门槛。"})]}),s.jsx(Ae,{className:"space-y-6",children:s.jsxs("div",{className:"grid grid-cols-2 gap-6",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"最低提现金额(元)"}),s.jsx(oe,{type:"number",min:0,step:1,className:"bg-[#0a1628] border-gray-700 text-white",value:e.minWithdrawAmount,onChange:u("minWithdrawAmount")}),s.jsx("p",{className:"text-xs text-gray-500",children:"小程序「满 X 元可提现」展示的门槛,同时用于后端接口校验。"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs(Z,{className:"text-gray-300 flex items-center gap-2",children:["自动提现开关",s.jsx(Ue,{variant:"outline",className:"border-[#38bdac]/40 text-[#38bdac] text-[10px]",children:"预留"})]}),s.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[s.jsx(Et,{checked:e.enableAutoWithdraw,onCheckedChange:h=>n(f=>({...f,enableAutoWithdraw:h}))}),s.jsx("span",{className:"text-sm text-gray-400",children:"开启后,可结合定时任务实现「收益自动打款到微信零钱」。"})]})]})]})})]}),s.jsxs(Me,{className:"bg-[#0f2137] border-gray-700/50",children:[s.jsx(nt,{children:s.jsxs(rt,{className:"flex items-center gap-2 text-gray-200 text-sm",children:[s.jsx(bu,{className:"w-4 h-4 text-[#38bdac]"}),"使用说明"]})}),s.jsxs(Ae,{className:"space-y-2 text-xs text-gray-400 leading-relaxed",children:[s.jsxs("p",{children:["1. 以上配置会写入"," ",s.jsx("code",{className:"font-mono text-[11px] text-[#38bdac]",children:"system_config.referral_config"}),",小程序「推广中心」、Web 推广页以及支付回调都会读取同一份配置。"]}),s.jsx("p",{children:"2. 修改后新订单立即生效;旧订单的历史佣金不会自动重算,只影响之后产生的订单。"}),s.jsx("p",{children:"3. 如遇前端展示与实际结算不一致,优先以此处配置为准,再排查缓存和小程序版本。"})]})]})]})]})}function IP(){var At;const[t,e]=v.useState("overview"),[n,r]=v.useState([]),[i,a]=v.useState(null),[o,c]=v.useState([]),[u,h]=v.useState([]),[f,m]=v.useState([]),[g,y]=v.useState(!0),[b,j]=v.useState(null),[w,N]=v.useState(""),[C,E]=v.useState("all"),[M,I]=v.useState(1),[O,D]=v.useState(10),[P,L]=v.useState(0),[_,X]=v.useState(new Set),[ne,J]=v.useState(null),[U,R]=v.useState(""),[F,re]=v.useState(!1),[z,ae]=v.useState(null),[G,$]=v.useState(""),[H,ce]=v.useState(!1);v.useEffect(()=>{W()},[]),v.useEffect(()=>{I(1)},[t,C]),v.useEffect(()=>{fe(t)},[t]),v.useEffect(()=>{["orders","bindings","withdrawals"].includes(t)&&fe(t,!0)},[M,O,C,w]);async function W(){j(null);try{const te=await Le("/api/admin/distribution/overview");te!=null&&te.success&&te.overview&&a(te.overview)}catch(te){console.error("[Admin] 概览接口异常:",te),j("加载概览失败")}try{const te=await Le("/api/db/users");m((te==null?void 0:te.users)||[])}catch(te){console.error("[Admin] 用户数据加载失败:",te)}}async function fe(te,Pe=!1){var Qe;if(!(!Pe&&_.has(te))){y(!0);try{const xt=f;switch(te){case"overview":break;case"orders":{try{const ft=new URLSearchParams({page:String(M),pageSize:String(O),...C!=="all"&&{status:C},...w&&{search:w}}),pt=await Le(`/api/admin/orders?${ft}`);if(pt!=null&&pt.success&&pt.orders){const wt=pt.orders.map(Xt=>{const Ot=xt.find(Dt=>Dt.id===Xt.userId),Tn=Xt.referrerId?xt.find(Dt=>Dt.id===Xt.referrerId):null;return{...Xt,amount:parseFloat(String(Xt.amount))||0,userNickname:(Ot==null?void 0:Ot.nickname)||Xt.userNickname||"未知用户",userPhone:(Ot==null?void 0:Ot.phone)||Xt.userPhone||"-",referrerNickname:(Tn==null?void 0:Tn.nickname)||null,referrerCode:(Tn==null?void 0:Tn.referralCode)??null,type:Xt.productType||Xt.type}});r(wt),L(pt.total??wt.length)}else r([]),L(0)}catch(ft){console.error(ft),j("加载订单失败"),r([])}break}case"bindings":{try{const ft=new URLSearchParams({page:String(M),pageSize:String(O),...C!=="all"&&{status:C}}),pt=await Le(`/api/db/distribution?${ft}`);c((pt==null?void 0:pt.bindings)||[]),L((pt==null?void 0:pt.total)??((Qe=pt==null?void 0:pt.bindings)==null?void 0:Qe.length)??0)}catch(ft){console.error(ft),j("加载绑定数据失败"),c([])}break}case"withdrawals":{try{const ft=C==="completed"?"success":C==="rejected"?"failed":C,pt=new URLSearchParams({...ft&&ft!=="all"&&{status:ft},page:String(M),pageSize:String(O)}),wt=await Le(`/api/admin/withdrawals?${pt}`);if(wt!=null&&wt.success&&wt.withdrawals){const Xt=wt.withdrawals.map(Ot=>({...Ot,account:Ot.account??"未绑定微信号",status:Ot.status==="success"?"completed":Ot.status==="failed"?"rejected":Ot.status}));h(Xt),L((wt==null?void 0:wt.total)??Xt.length)}else wt!=null&&wt.success||j(`获取提现记录失败: ${(wt==null?void 0:wt.error)||"未知错误"}`),h([])}catch(ft){console.error(ft),j("加载提现数据失败"),h([])}break}}X(ft=>new Set(ft).add(te))}catch(xt){console.error(xt)}finally{y(!1)}}}async function Q(){j(null),X(te=>{const Pe=new Set(te);return Pe.delete(t),Pe}),t==="overview"&&W(),await fe(t,!0)}async function de(te){if(confirm("确认审核通过并打款?"))try{const Pe=await Mt("/api/admin/withdrawals",{id:te,action:"approve"});if(!(Pe!=null&&Pe.success)){const Qe=(Pe==null?void 0:Pe.message)||(Pe==null?void 0:Pe.error)||"操作失败";ie.error(Qe);return}await Q()}catch(Pe){console.error(Pe),ie.error("操作失败")}}function he(te){ae(te),$("")}async function Ne(){const te=z;if(!te)return;const Pe=G.trim();if(!Pe){ie.error("请填写拒绝原因");return}ce(!0);try{const Qe=await Mt("/api/admin/withdrawals",{id:te,action:"reject",errorMessage:Pe});if(!(Qe!=null&&Qe.success)){ie.error((Qe==null?void 0:Qe.error)||"操作失败");return}ie.success("已拒绝该提现申请"),ae(null),$(""),await Q()}catch(Qe){console.error(Qe),ie.error("操作失败")}finally{ce(!1)}}function Te(){z&&ie.info("已取消操作"),ae(null),$("")}async function Ve(){var te;if(!(!(ne!=null&&ne.orderSn)&&!(ne!=null&&ne.id))){re(!0),j(null);try{const Pe=await Mt("/api/admin/orders/refund",{orderSn:ne.orderSn||ne.id,reason:U||void 0});Pe!=null&&Pe.success?(J(null),R(""),await fe("orders",!0)):j((Pe==null?void 0:Pe.error)||"退款失败")}catch(Pe){const Qe=Pe;j(((te=Qe==null?void 0:Qe.data)==null?void 0:te.error)||"退款失败,请检查网络后重试")}finally{re(!1)}}}function He(te){const Pe={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"},Qe={active:"有效",converted:"已转化",expired:"已过期",cancelled:"已取消",pending:"待审核",pending_confirm:"待用户确认",processing:"处理中",completed:"已完成",rejected:"已拒绝"};return s.jsx(Ue,{className:`${Pe[te]||"bg-gray-500/20 text-gray-400"} border-0`,children:Qe[te]||te})}const gt=Math.ceil(P/O)||1,Pt=n,wn=o.filter(te=>{var Qe,xt,ft,pt;if(!w)return!0;const Pe=w.toLowerCase();return((Qe=te.refereeNickname)==null?void 0:Qe.toLowerCase().includes(Pe))||((xt=te.refereePhone)==null?void 0:xt.includes(Pe))||((ft=te.referrerName)==null?void 0:ft.toLowerCase().includes(Pe))||((pt=te.referrerCode)==null?void 0:pt.toLowerCase().includes(Pe))}),ht=u.filter(te=>{var Qe;if(!w)return!0;const Pe=w.toLowerCase();return((Qe=te.userName)==null?void 0:Qe.toLowerCase().includes(Pe))||te.account&&te.account.toLowerCase().includes(Pe)});return s.jsxs("div",{className:"p-8 w-full",children:[b&&s.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:[s.jsx("span",{children:b}),s.jsx("button",{type:"button",onClick:()=>j(null),className:"hover:text-red-300",children:"×"})]}),s.jsxs("div",{className:"flex items-center justify-between mb-8",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-bold text-white",children:"推广中心"}),s.jsx("p",{className:"text-gray-400 mt-1",children:"统一管理:订单、分销绑定、提现审核"})]}),s.jsxs(ee,{onClick:Q,disabled:g,variant:"outline",className:"border-gray-700 text-gray-300 hover:bg-gray-800",children:[s.jsx(Ge,{className:`w-4 h-4 mr-2 ${g?"animate-spin":""}`}),"刷新数据"]})]}),s.jsx("div",{className:"flex gap-2 mb-6 border-b border-gray-700 pb-4 flex-wrap",children:[{key:"overview",label:"数据概览",icon:Oc},{key:"orders",label:"订单管理",icon:ah},{key:"bindings",label:"绑定管理",icon:ms},{key:"withdrawals",label:"提现审核",icon:jl},{key:"settings",label:"推广设置",icon:so}].map(te=>s.jsxs("button",{type:"button",onClick:()=>{e(te.key),E("all"),N("")},className:`flex items-center gap-2 px-4 py-2 rounded-lg text-sm font-medium transition-colors ${t===te.key?"bg-[#38bdac] text-white":"text-gray-400 hover:text-white hover:bg-gray-800"}`,children:[s.jsx(te.icon,{className:"w-4 h-4"}),te.label]},te.key))}),g?s.jsxs("div",{className:"flex items-center justify-center py-20",children:[s.jsx(Ge,{className:"w-8 h-8 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):s.jsxs(s.Fragment,{children:[t==="overview"&&i&&s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"grid grid-cols-4 gap-4",children:[s.jsx(Me,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsx(Ae,{className:"p-6",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-gray-400 text-sm",children:"今日点击"}),s.jsx("p",{className:"text-2xl font-bold text-white mt-1",children:i.todayClicks}),s.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:"总点击次数(实时)"})]}),s.jsx("div",{className:"w-12 h-12 rounded-xl bg-blue-500/20 flex items-center justify-center",children:s.jsx(oh,{className:"w-6 h-6 text-blue-400"})})]})})}),s.jsx(Me,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsx(Ae,{className:"p-6",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-gray-400 text-sm",children:"今日独立用户"}),s.jsx("p",{className:"text-2xl font-bold text-white mt-1",children:i.todayUniqueVisitors??0}),s.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:"去重访客数(实时)"})]}),s.jsx("div",{className:"w-12 h-12 rounded-xl bg-cyan-500/20 flex items-center justify-center",children:s.jsx(Un,{className:"w-6 h-6 text-cyan-400"})})]})})}),s.jsx(Me,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsx(Ae,{className:"p-6",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-gray-400 text-sm",children:"今日总文章点击率"}),s.jsx("p",{className:"text-2xl font-bold text-white mt-1",children:(i.todayClickRate??0).toFixed(2)}),s.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:"人均点击(总点击/独立用户)"})]}),s.jsx("div",{className:"w-12 h-12 rounded-xl bg-amber-500/20 flex items-center justify-center",children:s.jsx(Oc,{className:"w-6 h-6 text-amber-400"})})]})})}),s.jsx(Me,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsx(Ae,{className:"p-6",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-gray-400 text-sm",children:"今日绑定"}),s.jsx("p",{className:"text-2xl font-bold text-white mt-1",children:i.todayBindings})]}),s.jsx("div",{className:"w-12 h-12 rounded-xl bg-green-500/20 flex items-center justify-center",children:s.jsx(ms,{className:"w-6 h-6 text-green-400"})})]})})}),s.jsx(Me,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsx(Ae,{className:"p-6",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-gray-400 text-sm",children:"今日转化"}),s.jsx("p",{className:"text-2xl font-bold text-white mt-1",children:i.todayConversions})]}),s.jsx("div",{className:"w-12 h-12 rounded-xl bg-purple-500/20 flex items-center justify-center",children:s.jsx(Pb,{className:"w-6 h-6 text-purple-400"})})]})})}),s.jsx(Me,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsx(Ae,{className:"p-6",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-gray-400 text-sm",children:"今日佣金"}),s.jsxs("p",{className:"text-2xl font-bold text-[#38bdac] mt-1",children:["¥",i.todayEarnings.toFixed(2)]})]}),s.jsx("div",{className:"w-12 h-12 rounded-xl bg-[#38bdac]/20 flex items-center justify-center",children:s.jsx(ah,{className:"w-6 h-6 text-[#38bdac]"})})]})})})]}),(((At=i.todayClicksByPage)==null?void 0:At.length)??0)>0&&s.jsxs(Me,{className:"bg-[#0f2137] border-gray-700/50",children:[s.jsxs(nt,{children:[s.jsxs(rt,{className:"text-white flex items-center gap-2",children:[s.jsx(oh,{className:"w-5 h-5 text-[#38bdac]"}),"每篇文章今日点击(按来源页/文章统计)"]}),s.jsx("p",{className:"text-gray-400 text-sm mt-1",children:"实际用户与实际文章的点击均计入;今日总点击与上表一致"})]}),s.jsx(Ae,{children:s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full text-sm",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"border-b border-gray-700 text-left text-gray-400",children:[s.jsx("th",{className:"pb-3 pr-4",children:"来源页/文章"}),s.jsx("th",{className:"pb-3 pr-4 text-right",children:"今日点击"}),s.jsx("th",{className:"pb-3 text-right",children:"占比"})]})}),s.jsx("tbody",{children:[...i.todayClicksByPage??[]].sort((te,Pe)=>Pe.clicks-te.clicks).map((te,Pe)=>s.jsxs("tr",{className:"border-b border-gray-700/50",children:[s.jsx("td",{className:"py-2 pr-4 text-white font-mono",children:te.page||"(未区分)"}),s.jsx("td",{className:"py-2 pr-4 text-right text-white",children:te.clicks}),s.jsxs("td",{className:"py-2 text-right text-gray-400",children:[i.todayClicks>0?(te.clicks/i.todayClicks*100).toFixed(1):0,"%"]})]},Pe))})]})})})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsx(Me,{className:"bg-orange-500/10 border-orange-500/30",children:s.jsx(Ae,{className:"p-6",children:s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsx("div",{className:"w-12 h-12 rounded-xl bg-orange-500/20 flex items-center justify-center",children:s.jsx(jg,{className:"w-6 h-6 text-orange-400"})}),s.jsxs("div",{className:"flex-1",children:[s.jsx("p",{className:"text-orange-300 font-medium",children:"即将过期绑定"}),s.jsxs("p",{className:"text-2xl font-bold text-white",children:[i.expiringBindings," 个"]}),s.jsx("p",{className:"text-orange-300/60 text-sm",children:"7天内到期,需关注转化"})]})]})})}),s.jsx(Me,{className:"bg-blue-500/10 border-blue-500/30",children:s.jsx(Ae,{className:"p-6",children:s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsx("div",{className:"w-12 h-12 rounded-xl bg-blue-500/20 flex items-center justify-center",children:s.jsx(jl,{className:"w-6 h-6 text-blue-400"})}),s.jsxs("div",{className:"flex-1",children:[s.jsx("p",{className:"text-blue-300 font-medium",children:"待审核提现"}),s.jsxs("p",{className:"text-2xl font-bold text-white",children:[i.pendingWithdrawals," 笔"]}),s.jsxs("p",{className:"text-blue-300/60 text-sm",children:["共 ¥",i.pendingWithdrawAmount.toFixed(2)]})]}),s.jsx(ee,{onClick:()=>e("withdrawals"),variant:"outline",className:"border-blue-500/50 text-blue-400 hover:bg-blue-500/20",children:"去审核"})]})})})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-6",children:[s.jsxs(Me,{className:"bg-[#0f2137] border-gray-700/50",children:[s.jsx(nt,{children:s.jsxs(rt,{className:"text-white flex items-center gap-2",children:[s.jsx(ih,{className:"w-5 h-5 text-[#38bdac]"}),"本月统计"]})}),s.jsx(Ae,{children:s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"p-4 bg-white/5 rounded-lg",children:[s.jsx("p",{className:"text-gray-400 text-sm",children:"点击量"}),s.jsx("p",{className:"text-xl font-bold text-white",children:i.monthClicks})]}),s.jsxs("div",{className:"p-4 bg-white/5 rounded-lg",children:[s.jsx("p",{className:"text-gray-400 text-sm",children:"绑定数"}),s.jsx("p",{className:"text-xl font-bold text-white",children:i.monthBindings})]}),s.jsxs("div",{className:"p-4 bg-white/5 rounded-lg",children:[s.jsx("p",{className:"text-gray-400 text-sm",children:"转化数"}),s.jsx("p",{className:"text-xl font-bold text-white",children:i.monthConversions})]}),s.jsxs("div",{className:"p-4 bg-white/5 rounded-lg",children:[s.jsx("p",{className:"text-gray-400 text-sm",children:"佣金"}),s.jsxs("p",{className:"text-xl font-bold text-[#38bdac]",children:["¥",i.monthEarnings.toFixed(2)]})]})]})})]}),s.jsxs(Me,{className:"bg-[#0f2137] border-gray-700/50",children:[s.jsx(nt,{children:s.jsxs(rt,{className:"text-white flex items-center gap-2",children:[s.jsx(Oc,{className:"w-5 h-5 text-[#38bdac]"}),"累计统计"]})}),s.jsxs(Ae,{children:[s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"p-4 bg-white/5 rounded-lg",children:[s.jsx("p",{className:"text-gray-400 text-sm",children:"总点击"}),s.jsx("p",{className:"text-xl font-bold text-white",children:i.totalClicks.toLocaleString()})]}),s.jsxs("div",{className:"p-4 bg-white/5 rounded-lg",children:[s.jsx("p",{className:"text-gray-400 text-sm",children:"总绑定"}),s.jsx("p",{className:"text-xl font-bold text-white",children:i.totalBindings.toLocaleString()})]}),s.jsxs("div",{className:"p-4 bg-white/5 rounded-lg",children:[s.jsx("p",{className:"text-gray-400 text-sm",children:"总转化"}),s.jsx("p",{className:"text-xl font-bold text-white",children:i.totalConversions})]}),s.jsxs("div",{className:"p-4 bg-white/5 rounded-lg",children:[s.jsx("p",{className:"text-gray-400 text-sm",children:"总佣金"}),s.jsxs("p",{className:"text-xl font-bold text-[#38bdac]",children:["¥",i.totalEarnings.toFixed(2)]})]})]}),s.jsxs("div",{className:"mt-4 p-4 bg-[#38bdac]/10 rounded-lg flex items-center justify-between",children:[s.jsx("span",{className:"text-gray-300",children:"点击转化率"}),s.jsxs("span",{className:"text-[#38bdac] font-bold text-xl",children:[i.conversionRate,"%"]})]})]})]})]}),s.jsxs(Me,{className:"bg-[#0f2137] border-gray-700/50",children:[s.jsx(nt,{children:s.jsxs(rt,{className:"text-white flex items-center gap-2",children:[s.jsx(Un,{className:"w-5 h-5 text-[#38bdac]"}),"推广统计"]})}),s.jsx(Ae,{children:s.jsxs("div",{className:"grid grid-cols-4 gap-4",children:[s.jsxs("div",{className:"p-4 bg-white/5 rounded-lg text-center",children:[s.jsx("p",{className:"text-3xl font-bold text-white",children:i.totalDistributors}),s.jsx("p",{className:"text-gray-400 text-sm mt-1",children:"推广用户数"})]}),s.jsxs("div",{className:"p-4 bg-white/5 rounded-lg text-center",children:[s.jsx("p",{className:"text-3xl font-bold text-green-400",children:i.activeDistributors}),s.jsx("p",{className:"text-gray-400 text-sm mt-1",children:"有收益用户"})]}),s.jsxs("div",{className:"p-4 bg-white/5 rounded-lg text-center",children:[s.jsx("p",{className:"text-3xl font-bold text-[#38bdac]",children:"90%"}),s.jsx("p",{className:"text-gray-400 text-sm mt-1",children:"佣金比例"})]}),s.jsxs("div",{className:"p-4 bg-white/5 rounded-lg text-center",children:[s.jsx("p",{className:"text-3xl font-bold text-orange-400",children:"30天"}),s.jsx("p",{className:"text-gray-400 text-sm mt-1",children:"绑定有效期"})]})]})})]})]}),t==="orders"&&s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex gap-4",children:[s.jsxs("div",{className:"relative flex-1",children:[s.jsx(da,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400"}),s.jsx(oe,{value:w,onChange:te=>N(te.target.value),placeholder:"搜索订单号、用户名、手机号...",className:"pl-10 bg-[#0f2137] border-gray-700 text-white"})]}),s.jsxs("select",{value:C,onChange:te=>E(te.target.value),className:"px-4 py-2 bg-[#0f2137] border border-gray-700 rounded-lg text-white",children:[s.jsx("option",{value:"all",children:"全部状态"}),s.jsx("option",{value:"completed",children:"已完成"}),s.jsx("option",{value:"pending",children:"待支付"}),s.jsx("option",{value:"failed",children:"已失败"}),s.jsx("option",{value:"refunded",children:"已退款"})]})]}),s.jsx(Me,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsxs(Ae,{className:"p-0",children:[n.length===0?s.jsx("div",{className:"py-12 text-center text-gray-500",children:"暂无订单数据"}):s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full text-sm",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"bg-[#0a1628] text-gray-400",children:[s.jsx("th",{className:"p-4 text-left font-medium",children:"订单号"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"用户"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"商品"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"金额"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"支付方式"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"状态"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"退款原因"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"推荐人/邀请码"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"分销佣金"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"下单时间"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"操作"})]})}),s.jsx("tbody",{className:"divide-y divide-gray-700/50",children:Pt.map(te=>{var Pe,Qe;return s.jsxs("tr",{className:"hover:bg-[#0a1628] transition-colors",children:[s.jsxs("td",{className:"p-4 font-mono text-xs text-gray-400",children:[(Pe=te.id)==null?void 0:Pe.slice(0,12),"..."]}),s.jsx("td",{className:"p-4",children:s.jsxs("div",{children:[s.jsx("p",{className:"text-white text-sm",children:te.userNickname}),s.jsx("p",{className:"text-gray-500 text-xs",children:te.userPhone})]})}),s.jsx("td",{className:"p-4",children:s.jsxs("div",{children:[s.jsx("p",{className:"text-white text-sm",children:(()=>{const xt=te.productType||te.type;return xt==="fullbook"?`${te.bookName||"《底层逻辑》"} - 全本`:xt==="match"?"匹配次数购买":`${te.bookName||"《底层逻辑》"} - ${te.sectionTitle||te.chapterTitle||`章节${te.productId||te.sectionId||""}`}`})()}),s.jsx("p",{className:"text-gray-500 text-xs",children:(()=>{const xt=te.productType||te.type;return xt==="fullbook"?"全书解锁":xt==="match"?"功能权益":te.chapterTitle||"单章购买"})()})]})}),s.jsxs("td",{className:"p-4 text-[#38bdac] font-bold",children:["¥",typeof te.amount=="number"?te.amount.toFixed(2):parseFloat(String(te.amount||"0")).toFixed(2)]}),s.jsx("td",{className:"p-4 text-gray-300",children:te.paymentMethod==="wechat"?"微信支付":te.paymentMethod==="alipay"?"支付宝":te.paymentMethod||"微信支付"}),s.jsx("td",{className:"p-4",children:te.status==="refunded"?s.jsx(Ue,{className:"bg-gray-500/20 text-gray-400 border-0",children:"已退款"}):te.status==="completed"||te.status==="paid"?s.jsx(Ue,{className:"bg-green-500/20 text-green-400 border-0",children:"已完成"}):te.status==="pending"||te.status==="created"?s.jsx(Ue,{className:"bg-yellow-500/20 text-yellow-400 border-0",children:"待支付"}):s.jsx(Ue,{className:"bg-red-500/20 text-red-400 border-0",children:"已失败"})}),s.jsx("td",{className:"p-4 text-gray-400 text-sm max-w-[120px]",title:te.refundReason,children:te.status==="refunded"&&te.refundReason?te.refundReason:"-"}),s.jsx("td",{className:"p-4 text-gray-300 text-sm",children:te.referrerId||te.referralCode?s.jsxs("span",{title:te.referralCode||te.referrerCode||te.referrerId||"",children:[te.referrerNickname||te.referralCode||te.referrerCode||((Qe=te.referrerId)==null?void 0:Qe.slice(0,8)),(te.referralCode||te.referrerCode)&&` (${te.referralCode||te.referrerCode})`]}):"-"}),s.jsx("td",{className:"p-4 text-[#FFD700]",children:te.referrerEarnings?`¥${(typeof te.referrerEarnings=="number"?te.referrerEarnings:parseFloat(String(te.referrerEarnings))).toFixed(2)}`:"-"}),s.jsx("td",{className:"p-4 text-gray-400 text-sm",children:te.createdAt?new Date(te.createdAt).toLocaleString("zh-CN"):"-"}),s.jsx("td",{className:"p-4",children:(te.status==="paid"||te.status==="completed")&&s.jsxs(ee,{variant:"outline",size:"sm",className:"border-orange-500/50 text-orange-400 hover:bg-orange-500/20",onClick:()=>{J(te),R("")},children:[s.jsx(Gw,{className:"w-3 h-3 mr-1"}),"退款"]})})]},te.id)})})]})}),t==="orders"&&s.jsx(gs,{page:M,totalPages:gt,total:P,pageSize:O,onPageChange:I,onPageSizeChange:te=>{D(te),I(1)}})]})})]}),t==="bindings"&&s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex gap-4",children:[s.jsxs("div",{className:"relative flex-1",children:[s.jsx(da,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400"}),s.jsx(oe,{value:w,onChange:te=>N(te.target.value),placeholder:"搜索用户昵称、手机号、推广码...",className:"pl-10 bg-[#0f2137] border-gray-700 text-white"})]}),s.jsxs("select",{value:C,onChange:te=>E(te.target.value),className:"px-4 py-2 bg-[#0f2137] border border-gray-700 rounded-lg text-white",children:[s.jsx("option",{value:"all",children:"全部状态"}),s.jsx("option",{value:"active",children:"有效"}),s.jsx("option",{value:"converted",children:"已转化"}),s.jsx("option",{value:"expired",children:"已过期"})]})]}),s.jsx(Me,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsxs(Ae,{className:"p-0",children:[wn.length===0?s.jsx("div",{className:"py-12 text-center text-gray-500",children:"暂无绑定数据"}):s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full text-sm",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"bg-[#0a1628] text-gray-400",children:[s.jsx("th",{className:"p-4 text-left font-medium",children:"访客"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"分销商"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"绑定时间"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"到期时间"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"状态"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"佣金"})]})}),s.jsx("tbody",{className:"divide-y divide-gray-700/50",children:wn.map(te=>s.jsxs("tr",{className:"hover:bg-[#0a1628] transition-colors",children:[s.jsx("td",{className:"p-4",children:s.jsxs("div",{children:[s.jsx("p",{className:"text-white font-medium",children:te.refereeNickname||"匿名用户"}),s.jsx("p",{className:"text-gray-500 text-xs",children:te.refereePhone})]})}),s.jsx("td",{className:"p-4",children:s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:te.referrerName||"-"}),s.jsx("p",{className:"text-gray-500 text-xs font-mono",children:te.referrerCode})]})}),s.jsx("td",{className:"p-4 text-gray-400",children:te.boundAt?new Date(te.boundAt).toLocaleDateString("zh-CN"):"-"}),s.jsx("td",{className:"p-4 text-gray-400",children:te.expiresAt?new Date(te.expiresAt).toLocaleDateString("zh-CN"):"-"}),s.jsx("td",{className:"p-4",children:He(te.status)}),s.jsx("td",{className:"p-4",children:te.commission?s.jsxs("span",{className:"text-[#38bdac] font-medium",children:["¥",te.commission.toFixed(2)]}):s.jsx("span",{className:"text-gray-500",children:"-"})})]},te.id))})]})}),t==="bindings"&&s.jsx(gs,{page:M,totalPages:gt,total:P,pageSize:O,onPageChange:I,onPageSizeChange:te=>{D(te),I(1)}})]})})]}),t==="withdrawals"&&s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex gap-4",children:[s.jsxs("div",{className:"relative flex-1",children:[s.jsx(da,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400"}),s.jsx(oe,{value:w,onChange:te=>N(te.target.value),placeholder:"搜索用户名称、账号...",className:"pl-10 bg-[#0f2137] border-gray-700 text-white"})]}),s.jsxs("select",{value:C,onChange:te=>E(te.target.value),className:"px-4 py-2 bg-[#0f2137] border border-gray-700 rounded-lg text-white",children:[s.jsx("option",{value:"all",children:"全部状态"}),s.jsx("option",{value:"pending",children:"待审核"}),s.jsx("option",{value:"completed",children:"已完成"}),s.jsx("option",{value:"rejected",children:"已拒绝"})]})]}),s.jsx(Me,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsxs(Ae,{className:"p-0",children:[ht.length===0?s.jsx("div",{className:"py-12 text-center text-gray-500",children:"暂无提现记录"}):s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full text-sm",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"bg-[#0a1628] text-gray-400",children:[s.jsx("th",{className:"p-4 text-left font-medium",children:"申请人"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"金额"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"收款方式"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"收款账号"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"申请时间"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"状态"}),s.jsx("th",{className:"p-4 text-right font-medium",children:"操作"})]})}),s.jsx("tbody",{className:"divide-y divide-gray-700/50",children:ht.map(te=>s.jsxs("tr",{className:"hover:bg-[#0a1628] transition-colors",children:[s.jsx("td",{className:"p-4",children:s.jsxs("div",{className:"flex items-center gap-2",children:[te.userAvatar?s.jsx("img",{src:te.userAvatar,alt:"",className:"w-8 h-8 rounded-full object-cover"}):s.jsx("div",{className:"w-8 h-8 rounded-full bg-gray-600 flex items-center justify-center text-white text-sm font-medium",children:(te.userName||te.name||"?").slice(0,1)}),s.jsx("p",{className:"text-white font-medium",children:te.userName||te.name})]})}),s.jsx("td",{className:"p-4",children:s.jsxs("span",{className:"text-[#38bdac] font-bold",children:["¥",te.amount.toFixed(2)]})}),s.jsx("td",{className:"p-4",children:s.jsx(Ue,{className:te.method==="wechat"?"bg-green-500/20 text-green-400 border-0":"bg-blue-500/20 text-blue-400 border-0",children:te.method==="wechat"?"微信":"支付宝"})}),s.jsx("td",{className:"p-4",children:s.jsxs("div",{children:[s.jsx("p",{className:"text-white font-mono text-xs",children:te.account}),s.jsx("p",{className:"text-gray-500 text-xs",children:te.name})]})}),s.jsx("td",{className:"p-4 text-gray-400",children:te.createdAt?new Date(te.createdAt).toLocaleString("zh-CN"):"-"}),s.jsx("td",{className:"p-4",children:He(te.status)}),s.jsx("td",{className:"p-4 text-right",children:te.status==="pending"&&s.jsxs("div",{className:"flex gap-2 justify-end",children:[s.jsxs(ee,{size:"sm",onClick:()=>de(te.id),className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(Pb,{className:"w-4 h-4 mr-1"}),"通过"]}),s.jsxs(ee,{size:"sm",variant:"outline",onClick:()=>he(te.id),className:"border-red-500/50 text-red-400 hover:bg-red-500/20",children:[s.jsx(Vw,{className:"w-4 h-4 mr-1"}),"拒绝"]})]})})]},te.id))})]})}),t==="withdrawals"&&s.jsx(gs,{page:M,totalPages:gt,total:P,pageSize:O,onPageChange:I,onPageSizeChange:te=>{D(te),I(1)}})]})})]})]}),s.jsx(Kt,{open:!!ne,onOpenChange:te=>!te&&J(null),children:s.jsxs(zt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",children:[s.jsx(qt,{children:s.jsx(Gt,{className:"text-white",children:"订单退款"})}),ne&&s.jsxs("div",{className:"space-y-4",children:[s.jsxs("p",{className:"text-gray-400 text-sm",children:["订单号:",ne.orderSn||ne.id]}),s.jsxs("p",{className:"text-gray-400 text-sm",children:["退款金额:¥",typeof ne.amount=="number"?ne.amount.toFixed(2):parseFloat(String(ne.amount||"0")).toFixed(2)]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-sm text-gray-400 block mb-2",children:"退款原因(选填)"}),s.jsx("div",{className:"form-input",children:s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500",placeholder:"如:用户申请退款",value:U,onChange:te=>R(te.target.value)})})]}),s.jsx("p",{className:"text-orange-400/80 text-xs",children:"退款将原路退回至用户微信,且无法撤销,请确认后再操作。"})]}),s.jsxs(hn,{children:[s.jsx(ee,{variant:"outline",className:"border-gray-600 text-gray-300",onClick:()=>J(null),disabled:F,children:"取消"}),s.jsx(ee,{className:"bg-orange-500 hover:bg-orange-600 text-white",onClick:Ve,disabled:F,children:F?"退款中...":"确认退款"})]})]})}),s.jsx(Kt,{open:!!z,onOpenChange:te=>!te&&Te(),children:s.jsxs(zt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",children:[s.jsx(qt,{children:s.jsx(Gt,{className:"text-white",children:"拒绝提现"})}),s.jsxs("div",{className:"space-y-4",children:[s.jsx("p",{className:"text-gray-400 text-sm",children:"拒绝后该笔提现金额将返还用户余额。"}),s.jsxs("div",{children:[s.jsx("label",{className:"text-sm text-gray-400 block mb-2",children:"拒绝原因(必填)"}),s.jsx("div",{className:"form-input",children:s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500",placeholder:"请输入拒绝原因",value:G,onChange:te=>$(te.target.value)})})]})]}),s.jsxs(hn,{children:[s.jsx(ee,{variant:"outline",className:"border-gray-600 text-gray-300",onClick:Te,disabled:H,children:"取消"}),s.jsx(ee,{className:"bg-red-600 hover:bg-red-700 text-white",onClick:Ne,disabled:H||!G.trim(),children:H?"提交中...":"确认拒绝"})]})]})}),t==="settings"&&s.jsx("div",{className:"-mx-8 -mt-6",children:s.jsx(Mk,{embedded:!0})})]})}function RP(){const[t,e]=v.useState([]),[n,r]=v.useState({total:0,pendingCount:0,pendingAmount:0,successCount:0,successAmount:0,failedCount:0}),[i,a]=v.useState(!0),[o,c]=v.useState(null),[u,h]=v.useState("all"),[f,m]=v.useState(1),[g,y]=v.useState(10),[b,j]=v.useState(0),[w,N]=v.useState(null),[C,E]=v.useState(null),[M,I]=v.useState(""),[O,D]=v.useState(!1);async function P(){var R,F,re,z,ae,G,$;a(!0),c(null);try{const H=new URLSearchParams({status:u,page:String(f),pageSize:String(g)}),ce=await Le(`/api/admin/withdrawals?${H}`);if(ce!=null&&ce.success){const W=ce.withdrawals||[];e(W),j(ce.total??((R=ce.stats)==null?void 0:R.total)??W.length),r({total:((F=ce.stats)==null?void 0:F.total)??ce.total??W.length,pendingCount:((re=ce.stats)==null?void 0:re.pendingCount)??0,pendingAmount:((z=ce.stats)==null?void 0:z.pendingAmount)??0,successCount:((ae=ce.stats)==null?void 0:ae.successCount)??0,successAmount:((G=ce.stats)==null?void 0:G.successAmount)??0,failedCount:(($=ce.stats)==null?void 0:$.failedCount)??0})}else c("加载提现记录失败")}catch(H){console.error("Load withdrawals error:",H),c("加载失败,请检查网络后重试")}finally{a(!1)}}v.useEffect(()=>{m(1)},[u]),v.useEffect(()=>{P()},[u,f,g]);const L=Math.ceil(b/g)||1;async function _(R){const F=t.find(re=>re.id===R);if(F!=null&&F.userCommissionInfo&&F.userCommissionInfo.availableAfterThis<0){if(!confirm(`⚠️ 风险警告:该用户审核后余额为负数(¥${F.userCommissionInfo.availableAfterThis.toFixed(2)}),可能存在超额提现。 + +确认已核实用户账户并完成打款?`))return}else if(!confirm("确认已完成打款?批准后将更新用户提现记录。"))return;N(R);try{const re=await Mt("/api/admin/withdrawals",{id:R,action:"approve"});re!=null&&re.success?P():ie.error("操作失败: "+((re==null?void 0:re.error)??""))}catch{ie.error("操作失败")}finally{N(null)}}function X(R){E(R),I("")}async function ne(){const R=C;if(!R)return;const F=M.trim();if(!F){ie.error("请填写拒绝原因");return}D(!0);try{const re=await Mt("/api/admin/withdrawals",{id:R,action:"reject",errorMessage:F});re!=null&&re.success?(ie.success("已拒绝该提现申请"),E(null),I(""),P()):ie.error("操作失败: "+((re==null?void 0:re.error)??""))}catch{ie.error("操作失败")}finally{D(!1)}}function J(){C&&ie.info("已取消操作"),E(null),I("")}function U(R){switch(R){case"pending":return s.jsx(Ue,{className:"bg-orange-500/20 text-orange-400 hover:bg-orange-500/20 border-0",children:"待处理"});case"pending_confirm":return s.jsx(Ue,{className:"bg-orange-500/20 text-orange-400 hover:bg-orange-500/20 border-0",children:"待用户确认"});case"processing":return s.jsx(Ue,{className:"bg-blue-500/20 text-blue-400 hover:bg-blue-500/20 border-0",children:"已审批等待打款"});case"success":case"completed":return s.jsx(Ue,{className:"bg-green-500/20 text-green-400 hover:bg-green-500/20 border-0",children:"已完成"});case"failed":case"rejected":return s.jsx(Ue,{className:"bg-red-500/20 text-red-400 hover:bg-red-500/20 border-0",children:"已拒绝"});default:return s.jsx(Ue,{className:"bg-gray-500/20 text-gray-400 border-0",children:R})}}return s.jsxs("div",{className:"p-8 w-full",children:[o&&s.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:[s.jsx("span",{children:o}),s.jsx("button",{type:"button",onClick:()=>c(null),className:"hover:text-red-300",children:"×"})]}),s.jsxs("div",{className:"flex justify-between items-start mb-8",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-bold text-white",children:"分账提现管理"}),s.jsx("p",{className:"text-gray-400 mt-1",children:"管理用户分销收益的提现申请"})]}),s.jsxs(ee,{variant:"outline",onClick:P,disabled:i,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Ge,{className:`w-4 h-4 mr-2 ${i?"animate-spin":""}`}),"刷新"]})]}),s.jsx(Me,{className:"bg-gradient-to-r from-[#38bdac]/10 to-[#0f2137] border-[#38bdac]/30 mb-6",children:s.jsx(Ae,{className:"p-4",children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx(ah,{className:"w-5 h-5 text-[#38bdac] mt-0.5"}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-white font-medium mb-2",children:"自动分账规则"}),s.jsxs("div",{className:"text-sm text-gray-400 space-y-1",children:[s.jsxs("p",{children:["• ",s.jsx("span",{className:"text-[#38bdac]",children:"分销比例"}),":推广者获得订单金额的"," ",s.jsx("span",{className:"text-white font-medium",children:"90%"})]}),s.jsxs("p",{children:["• ",s.jsx("span",{className:"text-[#38bdac]",children:"结算方式"}),":用户付款后,分销收益自动计入推广者账户"]}),s.jsxs("p",{children:["• ",s.jsx("span",{className:"text-[#38bdac]",children:"提现方式"}),":用户在小程序端点击提现,系统自动转账到微信零钱"]}),s.jsxs("p",{children:["• ",s.jsx("span",{className:"text-[#38bdac]",children:"审批流程"}),":待处理的提现需管理员手动确认打款后批准"]})]})]})]})})}),s.jsxs("div",{className:"grid grid-cols-4 gap-4 mb-6",children:[s.jsx(Me,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsxs(Ae,{className:"p-4 text-center",children:[s.jsx("div",{className:"text-3xl font-bold text-[#38bdac]",children:n.total}),s.jsx("div",{className:"text-sm text-gray-400",children:"总申请"})]})}),s.jsx(Me,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsxs(Ae,{className:"p-4 text-center",children:[s.jsx("div",{className:"text-3xl font-bold text-orange-400",children:n.pendingCount}),s.jsx("div",{className:"text-sm text-gray-400",children:"待处理"}),s.jsxs("div",{className:"text-xs text-orange-400 mt-1",children:["¥",n.pendingAmount.toFixed(2)]})]})}),s.jsx(Me,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsxs(Ae,{className:"p-4 text-center",children:[s.jsx("div",{className:"text-3xl font-bold text-green-400",children:n.successCount}),s.jsx("div",{className:"text-sm text-gray-400",children:"已完成"}),s.jsxs("div",{className:"text-xs text-green-400 mt-1",children:["¥",n.successAmount.toFixed(2)]})]})}),s.jsx(Me,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsxs(Ae,{className:"p-4 text-center",children:[s.jsx("div",{className:"text-3xl font-bold text-red-400",children:n.failedCount}),s.jsx("div",{className:"text-sm text-gray-400",children:"已拒绝"})]})})]}),s.jsx("div",{className:"flex gap-2 mb-4",children:["all","pending","success","failed"].map(R=>s.jsx(ee,{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))}),s.jsx(Me,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:s.jsx(Ae,{className:"p-0",children:i?s.jsxs("div",{className:"flex items-center justify-center py-12",children:[s.jsx(Ge,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):t.length===0?s.jsxs("div",{className:"text-center py-12",children:[s.jsx(jl,{className:"w-12 h-12 text-gray-600 mx-auto mb-3"}),s.jsx("p",{className:"text-gray-500",children:"暂无提现记录"})]}):s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full text-sm",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"bg-[#0a1628] text-gray-400",children:[s.jsx("th",{className:"p-4 text-left font-medium",children:"申请时间"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"用户"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"提现金额"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"用户佣金信息"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"状态"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"处理时间"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"确认收款"}),s.jsx("th",{className:"p-4 text-right font-medium",children:"操作"})]})}),s.jsx("tbody",{className:"divide-y divide-gray-700/50",children:t.map(R=>s.jsxs("tr",{className:"hover:bg-[#0a1628] transition-colors",children:[s.jsx("td",{className:"p-4 text-gray-400",children:new Date(R.createdAt??"").toLocaleString()}),s.jsx("td",{className:"p-4",children:s.jsxs("div",{className:"flex items-center gap-2",children:[R.userAvatar?s.jsx("img",{src:R.userAvatar,alt:R.userName??"",className:"w-8 h-8 rounded-full object-cover"}):s.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)}),s.jsxs("div",{children:[s.jsx("p",{className:"font-medium text-white",children:R.userName??"未知"}),s.jsx("p",{className:"text-xs text-gray-500",children:R.userPhone??R.referralCode??(R.userId??"").slice(0,10)})]})]})}),s.jsx("td",{className:"p-4",children:s.jsxs("span",{className:"font-bold text-orange-400",children:["¥",Number(R.amount).toFixed(2)]})}),s.jsx("td",{className:"p-4",children:R.userCommissionInfo?s.jsxs("div",{className:"text-xs space-y-1",children:[s.jsxs("div",{className:"flex justify-between gap-4",children:[s.jsx("span",{className:"text-gray-500",children:"累计佣金:"}),s.jsxs("span",{className:"text-[#38bdac] font-medium",children:["¥",R.userCommissionInfo.totalCommission.toFixed(2)]})]}),s.jsxs("div",{className:"flex justify-between gap-4",children:[s.jsx("span",{className:"text-gray-500",children:"已提现:"}),s.jsxs("span",{className:"text-gray-400",children:["¥",R.userCommissionInfo.withdrawnEarnings.toFixed(2)]})]}),s.jsxs("div",{className:"flex justify-between gap-4",children:[s.jsx("span",{className:"text-gray-500",children:"待审核:"}),s.jsxs("span",{className:"text-orange-400",children:["¥",R.userCommissionInfo.pendingWithdrawals.toFixed(2)]})]}),s.jsxs("div",{className:"flex justify-between gap-4 pt-1 border-t border-gray-700/30",children:[s.jsx("span",{className:"text-gray-500",children:"审核后余额:"}),s.jsxs("span",{className:R.userCommissionInfo.availableAfterThis>=0?"text-green-400 font-medium":"text-red-400 font-medium",children:["¥",R.userCommissionInfo.availableAfterThis.toFixed(2)]})]})]}):s.jsx("span",{className:"text-gray-500 text-xs",children:"暂无数据"})}),s.jsxs("td",{className:"p-4",children:[U(R.status),R.errorMessage&&s.jsx("p",{className:"text-xs text-red-400 mt-1",children:R.errorMessage})]}),s.jsx("td",{className:"p-4 text-gray-400",children:R.processedAt?new Date(R.processedAt).toLocaleString():"-"}),s.jsx("td",{className:"p-4 text-gray-400",children:R.userConfirmedAt?s.jsxs("span",{className:"text-green-400",title:R.userConfirmedAt,children:["已确认 ",new Date(R.userConfirmedAt).toLocaleString()]}):"-"}),s.jsxs("td",{className:"p-4 text-right",children:[(R.status==="pending"||R.status==="pending_confirm")&&s.jsxs("div",{className:"flex items-center justify-end gap-2",children:[s.jsxs(ee,{size:"sm",onClick:()=>_(R.id),disabled:w===R.id,className:"bg-green-600 hover:bg-green-700 text-white",children:[s.jsx(df,{className:"w-4 h-4 mr-1"}),"批准"]}),s.jsxs(ee,{size:"sm",variant:"outline",onClick:()=>X(R.id),disabled:w===R.id,className:"border-red-500/50 text-red-400 hover:bg-red-500/10 bg-transparent",children:[s.jsx(hr,{className:"w-4 h-4 mr-1"}),"拒绝"]})]}),(R.status==="success"||R.status==="completed")&&R.transactionId&&s.jsx("span",{className:"text-xs text-gray-500 font-mono",children:R.transactionId})]})]},R.id))})]})}),s.jsx(gs,{page:f,totalPages:L,total:b,pageSize:g,onPageChange:m,onPageSizeChange:R=>{y(R),m(1)}})]})})}),s.jsx(Kt,{open:!!C,onOpenChange:R=>!R&&J(),children:s.jsxs(zt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",children:[s.jsx(qt,{children:s.jsx(Gt,{className:"text-white",children:"拒绝提现"})}),s.jsxs("div",{className:"space-y-4",children:[s.jsx("p",{className:"text-gray-400 text-sm",children:"拒绝后该笔提现金额将返还用户余额。"}),s.jsxs("div",{children:[s.jsx("label",{className:"text-sm text-gray-400 block mb-2",children:"拒绝原因(必填)"}),s.jsx("div",{className:"form-input",children:s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500",placeholder:"请输入拒绝原因",value:M,onChange:R=>I(R.target.value)})})]})]}),s.jsxs(hn,{children:[s.jsx(ee,{variant:"outline",className:"border-gray-600 text-gray-300",onClick:J,disabled:O,children:"取消"}),s.jsx(ee,{className:"bg-red-600 hover:bg-red-700 text-white",onClick:ne,disabled:O||!M.trim(),children:O?"提交中...":"确认拒绝"})]})]})})]})}var Dm={exports:{}},Lm={};/** + * @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 s1;function PP(){if(s1)return Lm;s1=1;var t=cd();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,i=t.useEffect,a=t.useLayoutEffect,o=t.useDebugValue;function c(m,g){var y=g(),b=r({inst:{value:y,getSnapshot:g}}),j=b[0].inst,w=b[1];return a(function(){j.value=y,j.getSnapshot=g,u(j)&&w({inst:j})},[m,y,g]),i(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 Lm.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:f,Lm}var i1;function Ak(){return i1||(i1=1,Dm.exports=PP()),Dm.exports}var Ik=Ak();function Fn(t){this.content=t}Fn.prototype={constructor:Fn,find:function(t){for(var e=0;e>1}};Fn.from=function(t){if(t instanceof Fn)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new Fn(e)};function Rk(t,e,n){for(let r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:n;let i=t.child(r),a=e.child(r);if(i==a){n+=i.nodeSize;continue}if(!i.sameMarkup(a))return n;if(i.isText&&i.text!=a.text){for(let o=0;i.text[o]==a.text[o];o++)n++;return n}if(i.content.size||a.content.size){let o=Rk(i.content,a.content,n+1);if(o!=null)return o}n+=i.nodeSize}}function Pk(t,e,n,r){for(let i=t.childCount,a=e.childCount;;){if(i==0||a==0)return i==a?null:{a:n,b:r};let o=t.child(--i),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(;he&&r(u,i+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,i+f)}c=h}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,i){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?i?typeof i=="function"?i(c):i: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,i=this.content.slice(),a=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),a=1);ae)for(let a=0,o=0;oe&&((on)&&(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),i+=c.nodeSize),o=u}return new ge(r,i)}cutByIndex(e,n){return e==n?ge.empty:e==0&&n==this.content.length?this:new ge(this.content.slice(e,n))}replaceChild(e,n){let r=this.content[e];if(r==n)return this;let i=this.content.slice(),a=this.size+n.nodeSize-r.nodeSize;return i[e]=n,new ge(i,a)}addToStart(e){return new ge([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new ge(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let n=0;nthis.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let n=0,r=0;;n++){let i=this.child(n),a=r+i.nodeSize;if(a>=e)return a==e?Au(n+1,a):Au(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 ge.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new ge(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return ge.empty;let n,r=0;for(let i=0;ithis.type.rank&&(n||(n=e.slice(0,i)),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;nr.type.rank-i.type.rank),n}};Rt.none=[];class ph extends Error{}class Ie{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=Dk(this.content,e+this.openStart,n);return r&&new Ie(r,this.openStart,this.openEnd)}removeBetween(e,n){return new Ie(Ok(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 Ie.empty;let r=n.openStart||0,i=n.openEnd||0;if(typeof r!="number"||typeof i!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new Ie(ge.fromJSON(e,n.content),r,i)}static maxOpen(e,n=!0){let r=0,i=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)i++;return new Ie(e,r,i)}}Ie.empty=new Ie(ge.empty,0,0);function Ok(t,e,n){let{index:r,offset:i}=t.findIndex(e),a=t.maybeChild(r),{index:o,offset:c}=t.findIndex(n);if(i==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(Ok(a.content,e-i-1,n-i-1)))}function Dk(t,e,n,r){let{index:i,offset:a}=t.findIndex(e),o=t.maybeChild(i);if(a==e||o.isText)return r&&!r.canReplace(i,i,n)?null:t.cut(0,e).append(n).append(t.cut(e));let c=Dk(o.content,e-a-1,n,o);return c&&t.replaceChild(i,o.copy(c))}function OP(t,e,n){if(n.openStart>t.depth)throw new ph("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new ph("Inconsistent open depths");return Lk(t,e,n,0)}function Lk(t,e,n,r){let i=t.index(r),a=t.node(r);if(i==e.index(r)&&r=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 i=(e||t).node(n),a=0,o=e?e.index(n):i.childCount;t&&(a=t.index(n),t.depth>n?a++:t.textOffset&&(io(t.nodeAfter,r),a++));for(let c=a;ci&&Lg(t,e,i+1),o=r.depth>i&&Lg(n,r,i+1),c=[];return Dc(null,t,i,c),a&&o&&e.index(i)==n.index(i)?(_k(a,o),io(ao(a,zk(t,e,n,r,i+1)),c)):(a&&io(ao(a,mh(t,e,i+1)),c),Dc(e,n,i,c),o&&io(ao(o,mh(n,r,i+1)),c)),Dc(r,null,i,c),new ge(c)}function mh(t,e,n){let r=[];if(Dc(null,t,n,r),t.depth>n){let i=Lg(t,e,n+1);io(ao(i,mh(t,e,n+1)),r)}return Dc(e,null,n,r),new ge(r)}function DP(t,e){let n=e.depth-t.openStart,i=e.node(n).copy(t.content);for(let a=n-1;a>=0;a--)i=e.node(a).copy(ge.from(i));return{start:i.resolveNoCache(t.openStart+n),end:i.resolveNoCache(i.content.size-t.openEnd-n)}}class Yc{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],i=e.child(n);return r?e.child(n).cut(r):i}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],i=n==0?0:this.path[n*3-1]+1;for(let a=0;a0;n--)if(this.start(n)<=e&&this.end(n)>=e)return n;return 0}blockRange(e=this,n){if(e.pos=0;r--)if(e.pos<=this.end(r)&&(!n||n(this.node(r))))return new gh(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=0&&n<=e.content.size))throw new RangeError("Position "+n+" out of range");let r=[],i=0,a=n;for(let o=e;;){let{index:c,offset:u}=o.content.findIndex(a),h=a-u;if(r.push(o,c,i+u),!h||(o=o.child(c),o.isText))break;a=h-1,i+=u+1}return new Yc(n,r,a)}static resolveCached(e,n){let r=a1.get(e);if(r)for(let a=0;ae&&this.nodesBetween(e,n,a=>(r.isInSet(a.marks)&&(i=!0),!i)),i}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()+")"),$k(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=ge.empty,i=0,a=r.childCount){let o=this.contentMatchAt(e).matchFragment(r,i,a),c=o&&o.matchFragment(this.content,n);if(!c||!c.validEnd)return!1;for(let u=i;un.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 i=ge.fromJSON(e,n.content),a=e.nodeType(n.type).create(n.attrs,i,r);return a.type.checkAttrs(a.attrs),a}};xi.prototype.text=void 0;class xh extends xi{constructor(e,n,r,i){if(super(e,n,null,i),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):$k(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 xh(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new xh(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 $k(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class mo{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new $P(e,n);if(r.next==null)return mo.empty;let i=Fk(r);r.next&&r.err("Unexpected trailing text");let a=KP(UP(i));return qP(a,r),a}matchType(e){for(let n=0;nh.createAndFill()));for(let h=0;h=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 i=0;i{let a=i+(r.validEnd?"*":" ")+" ";for(let o=0;o"+e.indexOf(r.next[o].next);return a}).join(` +`)}}mo.empty=new mo(!0);class $P{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 Fk(t){let e=[];do e.push(FP(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function FP(t){let e=[];do e.push(BP(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function BP(t){let e=WP(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=VP(t,e);else break;return e}function o1(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function VP(t,e){let n=o1(t),r=n;return t.eat(",")&&(t.next!="}"?r=o1(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function HP(t,e){let n=t.nodeTypes,r=n[e];if(r)return[r];let i=[];for(let a in n){let o=n[a];o.isInGroup(e)&&i.push(o)}return i.length==0&&t.err("No node type or group '"+e+"' found"),i}function WP(t){if(t.eat("(")){let e=Fk(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=HP(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 UP(t){let e=[[]];return i(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 i(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;i(h,c=n())}else if(o.type=="star"){let u=n();return r(c,u),i(a(o.expr,u),u),[r(u)]}else if(o.type=="plus"){let u=n();return i(a(o.expr,c),u),i(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{t[o].forEach(({term:c,to:u})=>{if(!c)return;let h;for(let f=0;f{h||i.push([c,h=[]]),h.indexOf(f)==-1&&h.push(f)})})});let a=e[r.join(",")]=new mo(r.indexOf(t.length-1)>-1);for(let o=0;o-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:Hk(this.attrs,e)}create(e=null,n,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new xi(this,this.computeAttrs(e),ge.from(n),Rt.setFrom(r))}createChecked(e=null,n,r){return n=ge.from(n),this.checkContent(n),new xi(this,this.computeAttrs(e),n,Rt.setFrom(r))}createAndFill(e=null,n,r){if(e=this.computeAttrs(e),n=ge.from(n),n.size){let o=this.contentMatch.fillBefore(n);if(!o)return null;n=o.append(n)}let i=this.contentMatch.matchFragment(n),a=i&&i.fillBefore(ge.empty,!0);return a?new xi(this,e,n.append(a),Rt.setFrom(r)):null}validContent(e){let n=this.contentMatch.matchFragment(e);if(!n||!n.validEnd)return!1;for(let r=0;r-1}allowsMarks(e){if(this.markSet==null)return!0;for(let n=0;nr[a]=new Kk(a,n,o));let i=n.spec.topNode||"doc";if(!r[i])throw new RangeError("Schema is missing its top node type ('"+i+"')");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 GP(t,e,n){let r=n.split("|");return i=>{let a=i===null?"null":typeof i;if(r.indexOf(a)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${t}, got ${a}`)}}class JP{constructor(e,n,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?GP(e,n,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class yf{constructor(e,n,r,i){this.name=e,this.rank=n,this.schema=r,this.spec=i,this.attrs=Uk(e,i.attrs),this.excluded=null;let a=Vk(this.attrs);this.instance=a?new Rt(this,a):null}create(e=null){return!e&&this.instance?this.instance:new Rt(this,Hk(this.attrs,e))}static compile(e,n){let r=Object.create(null),i=0;return e.forEach((a,o)=>r[a]=new yf(a,i++,n,o)),r}removeFromSet(e){for(var n=0;n-1}}class qk{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let n=this.spec={};for(let i in e)n[i]=e[i];n.nodes=Fn.from(e.nodes),n.marks=Fn.from(e.marks||{}),this.nodes=c1.compile(this.spec.nodes,this),this.marks=yf.compile(this.spec.marks,this);let r=Object.create(null);for(let i in this.nodes){if(i in this.marks)throw new RangeError(i+" can not be both a node and a mark");let a=this.nodes[i],o=a.spec.content||"",c=a.spec.marks;if(a.contentMatch=r[o]||(r[o]=mo.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?d1(this,c.split(" ")):c==""||!a.inlineContent?[]:null}for(let i in this.marks){let a=this.marks[i],o=a.spec.excludes;a.excluded=o==null?[a]:o==""?[]:d1(this,o.split(" "))}this.nodeFromJSON=i=>xi.fromJSON(this,i),this.markFromJSON=i=>Rt.fromJSON(this,i),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,n=null,r,i){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof c1){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,i)}text(e,n){let r=this.nodes.text;return new xh(r,r.defaultAttrs,e,Rt.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 d1(t,e){let n=[];for(let r=0;r-1)&&n.push(o=u)}if(!o)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return n}function YP(t){return t.tag!=null}function QP(t){return t.style!=null}class ha{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(i=>{if(YP(i))this.tags.push(i);else if(QP(i)){let a=/[^=]*/.exec(i.style)[0];r.indexOf(a)<0&&r.push(a),this.styles.push(i)}}),this.normalizeLists=!this.tags.some(i=>{if(!/^(ul|ol)\b/.test(i.tag)||!i.node)return!1;let a=e.nodes[i.node];return a.contentMatch.matchType(a)})}parse(e,n={}){let r=new h1(this,n,!1);return r.addAll(e,Rt.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new h1(this,n,!0);return r.addAll(e,Rt.none,n.from,n.to),Ie.maxOpen(r.finish())}matchTag(e,n,r){for(let i=r?this.tags.indexOf(r)+1:0;ie.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(i){let a=i.priority==null?50:i.priority,o=0;for(;o{r(o=f1(o)),o.mark||o.ignore||o.clearMark||(o.mark=i)})}for(let i in e.nodes){let a=e.nodes[i].spec.parseDOM;a&&a.forEach(o=>{r(o=f1(o)),o.node||o.ignore||o.mark||(o.node=i)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new ha(e,ha.schemaRules(e)))}}const Gk={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},XP={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Jk={ol:!0,ul:!0},Qc=1,zg=2,Lc=4;function u1(t,e,n){return e!=null?(e?Qc:0)|(e==="full"?zg:0):t&&t.whitespace=="pre"?Qc|zg:n&~Lc}class Iu{constructor(e,n,r,i,a,o){this.type=e,this.attrs=n,this.marks=r,this.solid=i,this.options=o,this.content=[],this.activeMarks=Rt.none,this.match=a||(o&Lc?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(ge.from(e));if(n)this.match=this.type.contentMatch.matchFragment(n);else{let r=this.type.contentMatch,i;return(i=r.findWrapping(e.type))?(this.match=r,i):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&Qc)){let r=this.content[this.content.length-1],i;if(r&&r.isText&&(i=/[ \t\r\n\u000c]+$/.exec(r.text))){let a=r;r.text.length==i[0].length?this.content.pop():this.content[this.content.length-1]=a.withText(a.text.slice(0,a.text.length-i[0].length))}}let n=ge.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(ge.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&&!Gk.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class h1{constructor(e,n,r){this.parser=e,this.options=n,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let i=n.topNode,a,o=u1(null,n.preserveWhitespace,0)|(r?Lc:0);i?a=new Iu(i.type,i.attrs,Rt.none,!0,n.topMatch||i.type.contentMatch,o):r?a=new Iu(null,null,Rt.none,!0,null,o):a=new Iu(e.schema.topNodeType,null,Rt.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,i=this.top,a=i.options&zg?"full":this.localPreserveWS||(i.options&Qc)>0,{schema:o}=this.parser;if(a==="full"||i.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!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,i){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(i)this.addElement(e,r,i);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,i){let a=r||0;for(let o=r?e.childNodes[r]:e.firstChild,c=i==null?null:e.childNodes[i];o!=c;o=o.nextSibling,++a)this.findAtPoint(e,a),this.addDOM(o,n);this.findAtPoint(e,a)}findPlace(e,n,r){let i,a;for(let o=this.open,c=0;o>=0;o--){let u=this.nodes[o],h=u.findWrapping(e);if(h&&(!i||i.length>h.length+c)&&(i=h,a=u,!h.length))break;if(u.solid){if(r)break;c+=2}}if(!i)return null;this.sync(a);for(let o=0;o(o.type?o.type.allowsMarkType(h.type):p1(h.type,e))?(u=h.addToSet(u),!1):!0),this.nodes.push(new Iu(e,n,u,i,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|=Qc)}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 i=r.length-1;i>=0;i--)e+=r[i].nodeSize;n&&e++}return e}findAtPoint(e,n){if(this.find)for(let r=0;r-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let n=e.split("/"),r=this.options.context,i=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),a=-(r?r.depth+1:0)+(i?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&&i?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 ZP(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&Jk.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function eO(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function f1(t){let e={};for(let n in t)e[n]=t[n];return e}function p1(t,e){let n=e.schema.nodes;for(let r in n){let i=n[r];if(!i.allowsMarkType(t))continue;let a=[],o=c=>{a.push(c);for(let u=0;u{if(a.length||o.marks.length){let c=0,u=0;for(;c=0;i--){let a=this.serializeMark(e.marks[i],e.isInline,n);a&&((a.contentDOM||a.dom).appendChild(r),r=a.dom)}return r}serializeMark(e,n,r={}){let i=this.marks[e.type.name];return i&&Yu(zm(r),i(e,n),null,e.attrs)}static renderSpec(e,n,r=null,i){return Yu(e,n,r,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new So(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=m1(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return m1(e.marks)}}function m1(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function zm(t){return t.document||window.document}const g1=new WeakMap;function tO(t){let e=g1.get(t);return e===void 0&&g1.set(t,e=nO(t)),e}function nO(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 i=0;i-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=i.indexOf(" ");o>0&&(n=i.slice(0,o),i=i.slice(o+1));let c,u=n?t.createElementNS(n,i):t.createElement(i),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;mf)throw new RangeError("Content hole must be the only child of its parent node");return{dom:u,contentDOM:u}}else{let{dom:y,contentDOM:b}=Yu(t,g,n,r);if(u.appendChild(y),b){if(c)throw new RangeError("Multiple content holes");c=b}}}return{dom:u,contentDOM:c}}const Yk=65535,Qk=Math.pow(2,16);function rO(t,e){return t+e*Qk}function x1(t){return t&Yk}function sO(t){return(t-(t&Yk))/Qk}const Xk=1,Zk=2,Qu=4,eS=8;class $g{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&eS)>0}get deletedBefore(){return(this.delInfo&(Xk|Qu))>0}get deletedAfter(){return(this.delInfo&(Zk|Qu))>0}get deletedAcross(){return(this.delInfo&Qu)>0}}class Pr{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&Pr.empty)return Pr.empty}recover(e){let n=0,r=x1(e);if(!this.inverted)for(let i=0;ie)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+i+(g<0?0:f);if(r)return y;let b=e==(n<0?u:m)?null:rO(c/3,e-u),j=e==u?Zk:e==m?Xk:Qu;return(n<0?e!=u:e!=m)&&(j|=eS),new $g(y,j,b)}i+=f-h}return r?e+i:new $g(e+i,0,null)}touches(e,n){let r=0,i=x1(n),a=this.inverted?2:1,o=this.inverted?1:2;for(let c=0;ce)break;let h=this.ranges[c+a],f=u+h;if(e<=f&&c==i*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 i=0,a=0;i=0;n--){let i=e.getMirror(n);this.appendMap(e._maps[n].invert(),i!=null&&i>n?r-i-1:void 0)}}invert(){let e=new Xc;return e.appendMappingInverted(this),e}map(e,n=1){if(this.mirror)return this._map(e,n,!0);for(let r=this.from;ra&&u!o.isAtom||!c.type.allowsMarkType(this.mark.type)?o:o.mark(this.mark.addToSet(o.marks)),i),n.openStart,n.openEnd);return vn.fromReplace(e,this.from,this.to,a)}invert(){return new fs(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 aa(n.pos,r.pos,this.mark)}merge(e){return e instanceof aa&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new aa(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 aa(n.from,n.to,e.markFromJSON(n.mark))}}sr.jsonID("addMark",aa);class fs extends sr{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 Ie(Xx(n.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),n.openStart,n.openEnd);return vn.fromReplace(e,this.from,this.to,r)}invert(){return new aa(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 fs(n.pos,r.pos,this.mark)}merge(e){return e instanceof fs&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new fs(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 fs(n.from,n.to,e.markFromJSON(n.mark))}}sr.jsonID("removeMark",fs);class oa extends sr{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return vn.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return vn.fromReplace(e,this.pos,this.pos+1,new Ie(ge.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 i=0;ir.pos?null:new On(n.pos,r.pos,i,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 On(n.from,n.to,n.gapFrom,n.gapTo,Ie.fromJSON(e,n.slice),n.insert,!!n.structure)}}sr.jsonID("replaceAround",On);function Fg(t,e,n){let r=t.resolve(e),i=n-e,a=r.depth;for(;i>0&&a>0&&r.indexAfter(a)==r.node(a).childCount;)a--,i--;if(i>0){let o=r.node(a).maybeChild(r.indexAfter(a));for(;i>0;){if(!o||o.isLeaf)return!0;o=o.firstChild,i--}}return!1}function iO(t,e,n,r){let i=[],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),b=r.addToSet(m);for(let j=0;jt.step(u)),a.forEach(u=>t.step(u))}function aO(t,e,n,r){let i=[],a=0;t.doc.nodesBetween(e,n,(o,c)=>{if(!o.isInline)return;a++;let u=null;if(r instanceof yf){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;ft.step(new fs(o.from,o.to,o.style)))}function Zx(t,e,n,r=n.contentMatch,i=!0){let a=t.doc.nodeAt(e),o=[],c=e+1;for(let u=0;u=0;u--)t.step(o[u])}function oO(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function $l(t){let n=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let r=t.depth,i=0,a=0;;--r){let o=t.$from.node(r),c=t.$from.index(r)+i,u=t.$to.indexAfter(r)-a;if(rn;b--)j||r.index(b)>0?(j=!0,f=ge.from(r.node(b).copy(f)),m++):u--;let g=ge.empty,y=0;for(let b=a,j=!1;b>n;b--)j||i.after(b+1)=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=ge.from(n[o].type.create(n[o].attrs,r))}let i=e.start,a=e.end;t.step(new On(i,a,i,a,new Ie(r,0,0),n.length,!0))}function hO(t,e,n,r,i){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 i=="function"?i(o):i;if(o.isTextblock&&!o.hasMarkup(r,u)&&fO(t.doc,t.mapping.slice(a).map(c),r)){let h=null;if(r.schema.linebreakReplacement){let y=r.whitespace=="pre",b=!!r.contentMatch.matchType(r.schema.linebreakReplacement);y&&!b?h=!1:!y&&b&&(h=!0)}h===!1&&nS(t,o,c,a),Zx(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 On(m,g,m+1,g-1,new Ie(ge.from(r.create(u,null,o.marks)),0,0),1,!0)),h===!0&&tS(t,o,c,a),!1}})}function tS(t,e,n,r){e.forEach((i,a)=>{if(i.isText){let o,c=/\r?\n|\r/g;for(;o=c.exec(i.text);){let u=t.mapping.slice(r).map(n+1+a+o.index);t.replaceWith(u,u+1,e.type.schema.linebreakReplacement.create())}}})}function nS(t,e,n,r){e.forEach((i,a)=>{if(i.type==i.type.schema.linebreakReplacement){let o=t.mapping.slice(r).map(n+1+a);t.replaceWith(o,o+1,e.type.schema.text(` +`))}})}function fO(t,e,n){let r=t.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,n)}function pO(t,e,n,r,i){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,i||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 On(e,e+a.nodeSize,e+1,e+a.nodeSize-1,new Ie(ge.from(o),0,0),1,!0))}function yi(t,e,n=1,r){let i=t.resolve(e),a=i.depth-n,o=r&&r[r.length-1]||i.parent;if(a<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!o.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let h=i.depth-1,f=n-2;h>a;h--,f--){let m=i.node(h),g=i.index(h);if(m.type.spec.isolating)return!1;let y=m.content.cutByIndex(g,m.childCount),b=r&&r[f+1];b&&(y=y.replaceChild(0,b.type.create(b.attrs)));let j=r&&r[f]||m;if(!m.canReplace(g+1,m.childCount)||!j.type.validContent(y))return!1}let c=i.indexAfter(a),u=r&&r[0];return i.node(a).canReplaceWith(c,c,u?u.type:i.node(a+1).type)}function mO(t,e,n=1,r){let i=t.doc.resolve(e),a=ge.empty,o=ge.empty;for(let c=i.depth,u=i.depth-n,h=n-1;c>u;c--,h--){a=ge.from(i.node(c).copy(a));let f=r&&r[h];o=ge.from(f?f.type.create(f.attrs,o):i.node(c).copy(o))}t.step(new Pn(e,e,new Ie(a.append(o),n,n),!0))}function Sa(t,e){let n=t.resolve(e),r=n.index();return rS(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function gO(t,e){e.content.size||t.type.compatibleContent(e.type);let n=t.contentMatchAt(t.childCount),{linebreakReplacement:r}=t.type.schema;for(let i=0;i0?(a=r.node(i+1),c++,o=r.node(i).maybeChild(c)):(a=r.node(i).maybeChild(c-1),o=r.node(i+1)),a&&!a.isTextblock&&rS(a,o)&&r.node(i).canReplace(c,c+1))return e;if(i==0)break;e=n<0?r.before(i):r.after(i)}}function xO(t,e,n){let r=null,{linebreakReplacement:i}=t.doc.type.schema,a=t.doc.resolve(e-n),o=a.node().type;if(i&&o.inlineContent){let f=o.whitespace=="pre",m=!!o.contentMatch.matchType(i);f&&!m?r=!1:!f&&m&&(r=!0)}let c=t.steps.length;if(r===!1){let f=t.doc.resolve(e+n);nS(t,f.node(),f.before(),c)}o.inlineContent&&Zx(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 Pn(h,u.map(e+n,-1),Ie.empty,!0)),r===!0){let f=t.doc.resolve(h);tS(t,f.node(),f.before(),t.steps.length)}return t}function yO(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 i=r.depth-1;i>=0;i--){let a=r.index(i);if(r.node(i).canReplaceWith(a,a,n))return r.before(i+1);if(a>0)return null}if(r.parentOffset==r.parent.content.size)for(let i=r.depth-1;i>=0;i--){let a=r.indexAfter(i);if(r.node(i).canReplaceWith(a,a,n))return r.after(i+1);if(a=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,i);else{let m=h.contentMatchAt(u).findWrapping(i.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 bf(t,e,n=e,r=Ie.empty){if(e==n&&!r.size)return null;let i=t.resolve(e),a=t.resolve(n);return iS(i,a,r)?new Pn(e,n,r):new vO(i,a,r).fit()}function iS(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}class vO{constructor(e,n,r){this.$from=e,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=ge.empty;for(let i=0;i<=e.depth;i++){let a=e.node(i);this.frontier.push({type:a.type,match:a.contentMatchAt(e.indexAfter(i))})}for(let i=e.depth;i>0;i--)this.placed=ge.from(e.node(i).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,i=this.close(e<0?this.$to:r.doc.resolve(e));if(!i)return null;let a=this.placed,o=r.depth,c=i.depth;for(;o&&c&&a.childCount==1;)a=a.firstChild.content,o--,c--;let u=new Ie(a,o,c);return e>-1?new On(r.pos,e,this.$to.pos,this.$to.end(),u,n):u.size||r.pos!=this.$to.pos?new Pn(r.pos,i.pos,u):null}findFittable(){let e=this.unplaced.openStart;for(let n=this.unplaced.content,r=0,i=this.unplaced.openEnd;r1&&(i=0),a.type.spec.isolating&&i<=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 i,a=null;r?(a=Fm(this.unplaced.content,r-1).firstChild,i=a.content):i=this.unplaced.content;let o=i.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(ge.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,i=Fm(e,n);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new Ie(e,n+1,Math.max(r,i.size+n>=e.size-r?n+1:0)),!0)}dropNode(){let{content:e,openStart:n,openEnd:r}=this.unplaced,i=Fm(e,n);if(i.childCount<=1&&n>0){let a=e.size-n<=n+i.size;this.unplaced=new Ie(Ec(e,n-1,1),n-1,a?n-1:r)}else this.unplaced=new Ie(Ec(e,n,1),n,r)}placeNodes({sliceDepth:e,frontierDepth:n,parent:r,inject:i,wrap:a}){for(;this.depth>n;)this.closeFrontierNode();if(a)for(let j=0;j1||u==0||j.content.size)&&(m=w,f.push(aS(j.mark(g.allowedMarks(j.marks)),h==1?u:0,h==c.childCount?y:-1)))}let b=h==c.childCount;b||(y=-1),this.placed=Tc(this.placed,n,ge.from(f)),this.frontier[n].match=m,b&&y<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let j=0,w=c;j1&&i==this.$to.end(--r);)++i;return i}findCloseLevel(e){e:for(let n=Math.min(this.depth,e.depth);n>=0;n--){let{match:r,type:i}=this.frontier[n],a=n=0;c--){let{match:u,type:h}=this.frontier[c],f=Bm(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=Tc(this.placed,n.depth,n.fit)),e=n.move;for(let r=n.depth+1;r<=e.depth;r++){let i=e.node(r),a=i.type.contentMatch.fillBefore(i.content,!0,e.index(r));this.openFrontierNode(i.type,i.attrs,a)}return e}openFrontierNode(e,n=null,r){let i=this.frontier[this.depth];i.match=i.match.matchType(e),this.placed=Tc(this.placed,this.depth,ge.from(e.create(n,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(ge.empty,!0);n.childCount&&(this.placed=Tc(this.placed,this.frontier.length,n))}}function Ec(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(Ec(t.firstChild.content,e-1,n)))}function Tc(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(Tc(t.lastChild.content,e-1,n)))}function Fm(t,e){for(let n=0;n1&&(r=r.replaceChild(0,aS(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(ge.empty,!0)))),t.copy(r)}function Bm(t,e,n,r,i){let a=t.node(e),o=i?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&&!bO(n,a.content,o)?c:null}function bO(t,e,n){for(let r=n;r0;g--,y--){let b=i.node(g).type.spec;if(b.defining||b.definingAsContext||b.isolating)break;o.indexOf(g)>-1?c=g:i.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 b=g.firstChild;if(h.push(b),y==r.openStart)break;g=b.content}for(let g=f-1;g>=0;g--){let y=h[g],b=NO(y.type);if(b&&!y.sameMarkup(i.node(Math.abs(c)-1)))f=g;else if(b||!y.type.isTextblock)break}for(let g=r.openStart;g>=0;g--){let y=(g+f+1)%(r.openStart+1),b=h[y];if(b)for(let j=0;j=0&&(t.replace(e,n,r),!(t.steps.length>m));g--){let y=o[g];y<0||(e=i.before(y),n=a.after(y))}}function oS(t,e,n,r,i){if(er){let a=i.contentMatchAt(0),o=a.fillBefore(t).append(t);t=o.append(a.matchFragment(o).fillBefore(ge.empty,!0))}return t}function jO(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let i=yO(t.doc,e,r.type);i!=null&&(e=n=i)}t.replaceRange(e,n,new Ie(ge.from(r),0,0))}function kO(t,e,n){let r=t.doc.resolve(e),i=t.doc.resolve(n),a=lS(r,i);for(let o=0;o0&&(u||r.node(c-1).canReplace(r.index(c-1),i.indexAfter(c-1))))return t.delete(r.before(c),i.after(c))}for(let o=1;o<=r.depth&&o<=i.depth;o++)if(e-r.start(o)==r.depth-o&&n>r.end(o)&&i.end(o)-n!=i.depth-o&&r.start(o-1)==i.start(o-1)&&r.node(o-1).canReplace(r.index(o-1),i.index(o-1)))return t.delete(r.before(o),n);t.delete(e,n)}function lS(t,e){let n=[],r=Math.min(t.depth,e.depth);for(let i=r;i>=0;i--){let a=t.start(i);if(ae.pos+(e.depth-i)||t.node(i).type.spec.isolating||e.node(i).type.spec.isolating)break;(a==e.start(i)||i==t.depth&&i==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&i&&e.start(i-1)==a-1)&&n.push(i)}return n}class bl extends sr{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 vn.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 i=n.type.create(r,null,n.marks);return vn.fromReplace(e,this.pos,this.pos+1,new Ie(ge.from(i),0,n.isLeaf?0:1))}getMap(){return Pr.empty}invert(e){return new bl(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 bl(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 bl(n.pos,n.attr,n.value)}}sr.jsonID("attr",bl);class Zc extends sr{constructor(e,n){super(),this.attr=e,this.value=n}apply(e){let n=Object.create(null);for(let i in e.attrs)n[i]=e.attrs[i];n[this.attr]=this.value;let r=e.type.create(n,e.content,e.marks);return vn.ok(r)}getMap(){return Pr.empty}invert(e){return new Zc(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 Zc(n.attr,n.value)}}sr.jsonID("docAttr",Zc);let kl=class extends Error{};kl=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};kl.prototype=Object.create(Error.prototype);kl.prototype.constructor=kl;kl.prototype.name="TransformError";class t0{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Xc}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new kl(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{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=Ie.empty){let i=bf(this.doc,e,n,r);return i&&this.step(i),this}replaceWith(e,n,r){return this.replace(e,n,new Ie(ge.from(r),0,0))}delete(e,n){return this.replace(e,n,Ie.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return wO(this,e,n,r),this}replaceRangeWith(e,n,r){return jO(this,e,n,r),this}deleteRange(e,n){return kO(this,e,n),this}lift(e,n){return lO(this,e,n),this}join(e,n=1){return xO(this,e,n),this}wrap(e,n){return uO(this,e,n),this}setBlockType(e,n=e,r,i=null){return hO(this,e,n,r,i),this}setNodeMarkup(e,n,r=null,i){return pO(this,e,n,r,i),this}setNodeAttribute(e,n,r){return this.step(new bl(e,n,r)),this}setDocAttribute(e,n){return this.step(new Zc(e,n)),this}addNodeMark(e,n){return this.step(new oa(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 Rt)n.isInSet(r.marks)&&this.step(new go(e,n));else{let i=r.marks,a,o=[];for(;a=n.isInSet(i);)o.push(new go(e,a)),i=a.removeFromSet(i);for(let c=o.length-1;c>=0;c--)this.step(o[c])}return this}split(e,n=1,r){return mO(this,e,n,r),this}addMark(e,n,r){return iO(this,e,n,r),this}removeMark(e,n,r){return aO(this,e,n,r),this}clearIncompatible(e,n,r){return Zx(this,e,n,r),this}}const Vm=Object.create(null);class Ze{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new cS(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=0;a--){let o=n<0?ll(e.node(0),e.node(a),e.before(a+1),e.index(a),n,r):ll(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 Dr(e.node(0))}static atStart(e){return ll(e,e,0,0,1)||new Dr(e)}static atEnd(e){return ll(e,e,e.content.size,e.childCount,-1)||new Dr(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Vm[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 Vm)throw new RangeError("Duplicate use of selection JSON ID "+e);return Vm[e]=n,n.prototype.jsonID=e,n}getBookmark(){return qe.between(this.$anchor,this.$head).getBookmark()}}Ze.prototype.visible=!0;class cS{constructor(e,n){this.$from=e,this.$to=n}}let v1=!1;function b1(t){!v1&&!t.parent.inlineContent&&(v1=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class qe extends Ze{constructor(e,n=e){b1(e),b1(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 Ze.near(r);let i=e.resolve(n.map(this.anchor));return new qe(i.parent.inlineContent?i:r,r)}replace(e,n=Ie.empty){if(super.replace(e,n),n==Ie.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof qe&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Nf(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 qe(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){let i=e.resolve(n);return new this(i,r==n?i:e.resolve(r))}static between(e,n,r){let i=e.pos-n.pos;if((!r||i)&&(r=i>=0?1:-1),!n.parent.inlineContent){let a=Ze.findFrom(n,r,!0)||Ze.findFrom(n,-r,!0);if(a)n=a.$head;else return Ze.near(n,r)}return e.parent.inlineContent||(i==0?e=n:(e=(Ze.findFrom(e,-r,!0)||Ze.findFrom(e,r,!0)).$anchor,e.pos0?0:1);i>0?o=0;o+=i){let c=e.child(o);if(c.isAtom){if(!a&&Ke.isSelectable(c))return Ke.create(t,n-(i<0?c.nodeSize:0))}else{let u=ll(t,c,n+i,i<0?c.childCount:0,i,a);if(u)return u}n+=c.nodeSize*i}return null}function N1(t,e,n){let r=t.steps.length-1;if(r{o==null&&(o=f)}),t.setSelection(Ze.near(t.doc.resolve(o),n))}const w1=1,Ru=2,j1=4;class CO extends t0{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.curSelectionFor0}setStoredMarks(e){return this.storedMarks=e,this.updated|=Ru,this}ensureMarks(e){return Rt.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&Ru)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~Ru,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)||Rt.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,n,r){let i=this.doc.type.schema;if(n==null)return e?this.replaceSelectionWith(i.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,i.text(e,a)),!this.selection.empty&&this.selection.to==n+e.length&&this.setSelection(Ze.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|=j1,this}get scrolledIntoView(){return(this.updated&j1)>0}}function k1(t,e){return!e||!t?t:t.bind(e)}class Mc{constructor(e,n,r){this.name=e,this.init=k1(n.init,r),this.apply=k1(n.apply,r)}}const EO=[new Mc("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new Mc("selection",{init(t,e){return t.selection||Ze.atStart(e.doc)},apply(t){return t.selection}}),new Mc("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new Mc("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class Hm{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=EO.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 Mc(r.key,r.spec.state,r))})}}class gl{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;rr.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 i=e[r],a=i.spec.state;a&&a.toJSON&&(n[r]=a.toJSON.call(i,this[i.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 i=new Hm(e.schema,e.plugins),a=new gl(i);return i.fields.forEach(o=>{if(o.name=="doc")a.doc=xi.fromJSON(e.schema,n.doc);else if(o.name=="selection")a.selection=Ze.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 dS(t,e,n){for(let r in t){let i=t[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=dS(i,e,{})),n[r]=i}return n}class Bt{constructor(e){this.spec=e,this.props={},e.props&&dS(e.props,this,this.props),this.key=e.key?e.key.key:uS("plugin")}getState(e){return e[this.key]}}const Wm=Object.create(null);function uS(t){return t in Wm?t+"$"+ ++Wm[t]:(Wm[t]=0,t+"$")}class Qt{constructor(e="key"){this.key=uS(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const r0=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function hS(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const fS=(t,e,n)=>{let r=hS(t,n);if(!r)return!1;let i=s0(r);if(!i){let o=r.blockRange(),c=o&&$l(o);return c==null?!1:(e&&e(t.tr.lift(o,c).scrollIntoView()),!0)}let a=i.nodeBefore;if(wS(t,i,e,-1))return!0;if(r.parent.content.size==0&&(Sl(a,"end")||Ke.isSelectable(a)))for(let o=r.depth;;o--){let c=bf(t.doc,r.before(o),r.after(o),Ie.empty);if(c&&c.slice.size1)break}return a.isAtom&&i.depth==r.depth-1?(e&&e(t.tr.delete(i.pos-a.nodeSize,i.pos).scrollIntoView()),!0):!1},TO=(t,e,n)=>{let r=hS(t,n);if(!r)return!1;let i=s0(r);return i?pS(t,i,e):!1},MO=(t,e,n)=>{let r=gS(t,n);if(!r)return!1;let i=i0(r);return i?pS(t,i,e):!1};function pS(t,e,n){let r=e.nodeBefore,i=r,a=e.pos-1;for(;!i.isTextblock;a--){if(i.type.spec.isolating)return!1;let f=i.lastChild;if(!f)return!1;i=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=bf(t.doc,a,u,Ie.empty);if(!h||h.from!=a||h instanceof Pn&&h.slice.size>=u-a)return!1;if(n){let f=t.tr.step(h);f.setSelection(qe.create(f.doc,a)),n(f.scrollIntoView())}return!0}function Sl(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 mS=(t,e,n)=>{let{$head:r,empty:i}=t.selection,a=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",t):r.parentOffset>0)return!1;a=s0(r)}let o=a&&a.nodeBefore;return!o||!Ke.isSelectable(o)?!1:(e&&e(t.tr.setSelection(Ke.create(t.doc,a.pos-o.nodeSize)).scrollIntoView()),!0)};function s0(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 gS(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset{let r=gS(t,n);if(!r)return!1;let i=i0(r);if(!i)return!1;let a=i.nodeAfter;if(wS(t,i,e,1))return!0;if(r.parent.content.size==0&&(Sl(a,"start")||Ke.isSelectable(a))){let o=bf(t.doc,r.before(),r.after(),Ie.empty);if(o&&o.slice.size{let{$head:r,empty:i}=t.selection,a=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",t):r.parentOffset=0;e--){let n=t.node(e);if(t.index(e)+1{let n=t.selection,r=n instanceof Ke,i;if(r){if(n.node.isTextblock||!Sa(t.doc,n.from))return!1;i=n.from}else if(i=vf(t.doc,n.from,-1),i==null)return!1;if(e){let a=t.tr.join(i);r&&a.setSelection(Ke.create(a.doc,i-t.doc.resolve(i).nodeBefore.nodeSize)),e(a.scrollIntoView())}return!0},IO=(t,e)=>{let n=t.selection,r;if(n instanceof Ke){if(n.node.isTextblock||!Sa(t.doc,n.to))return!1;r=n.to}else if(r=vf(t.doc,n.to,1),r==null)return!1;return e&&e(t.tr.join(r).scrollIntoView()),!0},RO=(t,e)=>{let{$from:n,$to:r}=t.selection,i=n.blockRange(r),a=i&&$l(i);return a==null?!1:(e&&e(t.tr.lift(i,a).scrollIntoView()),!0)},vS=(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 a0(t){for(let e=0;e{let{$head:n,$anchor:r}=t.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let i=n.node(-1),a=n.indexAfter(-1),o=a0(i.contentMatchAt(a));if(!o||!i.canReplaceWith(a,a,o))return!1;if(e){let c=n.after(),u=t.tr.replaceWith(c,c,o.createAndFill());u.setSelection(Ze.near(u.doc.resolve(c),1)),e(u.scrollIntoView())}return!0},bS=(t,e)=>{let n=t.selection,{$from:r,$to:i}=n;if(n instanceof Dr||r.parent.inlineContent||i.parent.inlineContent)return!1;let a=a0(i.parent.contentMatchAt(i.indexAfter()));if(!a||!a.isTextblock)return!1;if(e){let o=(!r.parentOffset&&i.index(){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(yi(t.doc,a))return e&&e(t.tr.split(a).scrollIntoView()),!0}let r=n.blockRange(),i=r&&$l(r);return i==null?!1:(e&&e(t.tr.lift(r,i).scrollIntoView()),!0)};function OO(t){return(e,n)=>{let{$from:r,$to:i}=e.selection;if(e.selection instanceof Ke&&e.selection.node.isBlock)return!r.parentOffset||!yi(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=a0(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 qe||e.selection instanceof Dr)&&f.deleteSelection();let m=f.mapping.map(r.pos),g=yi(f.doc,m,a.length,a);if(g||(a[0]=c?{type:c}:null,g=yi(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)),b=f.doc.resolve(y);c&&r.node(o-1).canReplaceWith(b.index(),b.index()+1,c)&&f.setNodeMarkup(f.mapping.map(r.before(o)),c)}return n&&n(f.scrollIntoView()),!0}}const DO=OO(),LO=(t,e)=>{let{$from:n,to:r}=t.selection,i,a=n.sharedDepth(r);return a==0?!1:(i=n.before(a),e&&e(t.tr.setSelection(Ke.create(t.doc,i))),!0)};function _O(t,e,n){let r=e.nodeBefore,i=e.nodeAfter,a=e.index();return!r||!i||!r.type.compatibleContent(i.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)||!(i.isTextblock||Sa(t.doc,e.pos))?!1:(n&&n(t.tr.join(e.pos).scrollIntoView()),!0)}function wS(t,e,n,r){let i=e.nodeBefore,a=e.nodeAfter,o,c,u=i.type.spec.isolating||a.type.spec.isolating;if(!u&&_O(t,e,n))return!0;let h=!u&&e.parent.canReplace(e.index(),e.index()+1);if(h&&(o=(c=i.contentMatchAt(i.childCount)).findWrapping(a.type))&&c.matchType(o[0]||a.type).validEnd){if(n){let y=e.pos+a.nodeSize,b=ge.empty;for(let N=o.length-1;N>=0;N--)b=ge.from(o[N].create(null,b));b=ge.from(i.copy(b));let j=t.tr.step(new On(e.pos-1,y,e.pos,y,new Ie(b,1,0),o.length,!0)),w=j.doc.resolve(y+2*o.length);w.nodeAfter&&w.nodeAfter.type==i.type&&Sa(j.doc,w.pos)&&j.join(w.pos),n(j.scrollIntoView())}return!0}let f=a.type.spec.isolating||r>0&&u?null:Ze.findFrom(e,1),m=f&&f.$from.blockRange(f.$to),g=m&&$l(m);if(g!=null&&g>=e.depth)return n&&n(t.tr.lift(m,g).scrollIntoView()),!0;if(h&&Sl(a,"start",!0)&&Sl(i,"end")){let y=i,b=[];for(;b.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 N=ge.empty;for(let E=b.length-1;E>=0;E--)N=ge.from(b[E].copy(N));let C=t.tr.step(new On(e.pos-b.length,e.pos+a.nodeSize,e.pos+w,e.pos+a.nodeSize-w,new Ie(N,b.length,0),0,!0));n(C.scrollIntoView())}return!0}}return!1}function jS(t){return function(e,n){let r=e.selection,i=t<0?r.$from:r.$to,a=i.depth;for(;i.node(a).isInline;){if(!a)return!1;a--}return i.node(a).isTextblock?(n&&n(e.tr.setSelection(qe.create(e.doc,t<0?i.start(a):i.end(a)))),!0):!1}}const zO=jS(-1),$O=jS(1);function FO(t,e=null){return function(n,r){let{$from:i,$to:a}=n.selection,o=i.blockRange(a),c=o&&e0(o,t,e);return c?(r&&r(n.tr.wrap(o,c).scrollIntoView()),!0):!1}}function S1(t,e=null){return function(n,r){let i=!1;for(let a=0;a{if(i)return!1;if(!(!u.isTextblock||u.hasMarkup(t,e)))if(u.type==t)i=!0;else{let f=n.doc.resolve(h),m=f.index();i=f.parent.canReplaceWith(m,m+1,t)}})}if(!i)return!1;if(r){let a=n.tr;for(let o=0;o=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 gh(u,u,e.depth),e.endIndex=0;f--)a=ge.from(n[f].type.create(n[f].attrs,a));t.step(new On(e.start-(r?2:0),e.end,e.start,e.end,new Ie(a,0,0),n.length,!0));let o=0;for(let f=0;fo.childCount>0&&o.firstChild.type==t);return a?n?r.node(a.depth-1).type==t?UO(e,n,t,a):KO(e,n,a):!0:!1}}function UO(t,e,n,r){let i=t.tr,a=r.end,o=r.$to.end(r.depth);aj;b--)y-=i.child(b).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==i.childCount,h=a.node(-1),f=a.index(-1);if(!h.canReplace(f+(c?0:1),f+1,o.content.append(u?ge.empty:ge.from(i))))return!1;let m=a.pos,g=m+o.nodeSize;return r.step(new On(m-(c?1:0),g+(u?1:0),m+1,g-1,new Ie((c?ge.empty:ge.from(i.copy(ge.empty))).append(u?ge.empty:ge.from(i.copy(ge.empty))),c?0:1,u?0:1),c?0:1)),e(r.scrollIntoView()),!0}function qO(t){return function(e,n){let{$from:r,$to:i}=e.selection,a=r.blockRange(i,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=ge.from(h?t.create():null),m=new Ie(ge.from(t.create(null,ge.from(c.type.create(null,f)))),h?3:1,0),g=a.start,y=a.end;n(e.tr.step(new On(g-(h?3:1),y,g,y,m,1,!0)).scrollIntoView())}return!0}}const Vn=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},Cl=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let Bg=null;const pi=function(t,e,n){let r=Bg||(Bg=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},GO=function(){Bg=null},xo=function(t,e,n,r){return n&&(C1(t,e,n,r,-1)||C1(t,e,n,r,1))},JO=/^(img|br|input|textarea|hr)$/i;function C1(t,e,n,r,i){for(var a;;){if(t==n&&e==r)return!0;if(e==(i<0?0:Jr(t))){let o=t.parentNode;if(!o||o.nodeType!=1||pd(t)||JO.test(t.nodeName)||t.contentEditable=="false")return!1;e=Vn(t)+(i<0?0:1),t=o}else if(t.nodeType==1){let o=t.childNodes[e+(i<0?-1:0)];if(o.nodeType==1&&o.contentEditable=="false")if(!((a=o.pmViewDesc)===null||a===void 0)&&a.ignoreForSelection)e+=i;else return!1;else t=o,e=i<0?Jr(t):0}else return!1}}function Jr(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function YO(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=Jr(t)}else if(t.parentNode&&!pd(t))e=Vn(t),t=t.parentNode;else return null}}function QO(t,e){for(;;){if(t.nodeType==3&&e2),Gr=El||(zs?/Mac/.test(zs.platform):!1),CS=zs?/Win/.test(zs.platform):!1,gi=/Android \d/.test(Ca),md=!!E1&&"webkitFontSmoothing"in E1.documentElement.style,tD=md?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function nD(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 ci(t,e){return typeof t=="number"?t:t[e]}function rD(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 T1(t,e,n){let r=t.someProp("scrollThreshold")||0,i=t.someProp("scrollMargin")||5,a=t.dom.ownerDocument;for(let o=n||t.dom;o;){if(o.nodeType!=1){o=Cl(o);continue}let c=o,u=c==a.body,h=u?nD(a):rD(c),f=0,m=0;if(e.toph.bottom-ci(r,"bottom")&&(m=e.bottom-e.top>h.bottom-h.top?e.top+ci(i,"top")-h.top:e.bottom-h.bottom+ci(i,"bottom")),e.lefth.right-ci(r,"right")&&(f=e.right-h.right+ci(i,"right")),f||m)if(u)a.defaultView.scrollBy(f,m);else{let y=c.scrollLeft,b=c.scrollTop;m&&(c.scrollTop+=m),f&&(c.scrollLeft+=f);let j=c.scrollLeft-y,w=c.scrollTop-b;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:Cl(o)}}function sD(t){let e=t.dom.getBoundingClientRect(),n=Math.max(0,e.top),r,i;for(let a=(e.left+e.right)/2,o=n+1;o=n-20){r=c,i=u.top;break}}return{refDOM:r,refTop:i,stack:ES(t.dom)}}function ES(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=Cl(r));return e}function iD({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;TS(n,r==0?0:r-e)}function TS(t,e){for(let n=0;n=c){o=Math.max(b.bottom,o),c=Math.min(b.top,c);let j=b.left>e.left?b.left-e.left:b.right=(b.left+b.right)/2?1:0));continue}}else b.top>e.top&&!u&&b.left<=e.left&&b.right>=e.left&&(u=f,h={left:Math.max(b.left,Math.min(b.right,e.left)),top:b.top});!n&&(e.left>=b.right&&e.top>=b.top||e.left>=b.left&&e.top>=b.bottom)&&(a=m+1)}}return!n&&u&&(n=u,i=h,r=0),n&&n.nodeType==3?oD(n,i):!n||r&&n.nodeType==1?{node:t,offset:a}:MS(n,i)}function oD(t,e){let n=t.nodeValue.length,r=document.createRange(),i;for(let a=0;a=(o.left+o.right)/2?1:0)};break}}return r.detach(),i||{node:t,offset:0}}function l0(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function lD(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left(o.left+o.right)/2?1:-1}return t.docView.posFromDOM(r,i,a)}function dD(t,e,n,r){let i=-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?i=c.posBefore:(!o&&u.right-1?i:t.docView.posFromDOM(e,n,-1)}function AS(t,e,n){let r=t.childNodes.length;if(r&&n.tope.top&&i++}let h;md&&i&&r.nodeType==1&&(h=r.childNodes[i-1]).nodeType==1&&h.contentEditable=="false"&&h.getBoundingClientRect().top>=e.top&&i--,r==t.dom&&i==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?c=t.state.doc.content.size:(i==0||r.nodeType!=1||r.childNodes[i-1].nodeName!="BR")&&(c=dD(t,r,i,e))}c==null&&(c=cD(t,o,e));let u=t.docView.nearestDesc(o,!0);return{pos:c,inside:u?u.posAtStart-u.border:-1}}function M1(t){return t.top=0&&i==r.nodeValue.length?(u--,f=1):n<0?u--:h++,jc(Qi(pi(r,u,h),f),f<0)}if(!t.state.doc.resolve(e-(a||0)).parent.inlineContent){if(a==null&&i&&(n<0||i==Jr(r))){let u=r.childNodes[i-1];if(u.nodeType==1)return Um(u.getBoundingClientRect(),!1)}if(a==null&&i=0)}if(a==null&&i&&(n<0||i==Jr(r))){let u=r.childNodes[i-1],h=u.nodeType==3?pi(u,Jr(u)-(o?0:1)):u.nodeType==1&&(u.nodeName!="BR"||!u.nextSibling)?u:null;if(h)return jc(Qi(h,1),!1)}if(a==null&&i=0)}function jc(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 Um(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 RS(t,e,n){let r=t.state,i=t.root.activeElement;r!=e&&t.updateState(e),i!=t.dom&&t.focus();try{return n()}finally{r!=e&&t.updateState(r),i!=t.dom&&i&&i.focus()}}function fD(t,e,n){let r=e.selection,i=n=="up"?r.$from:r.$to;return RS(t,e,()=>{let{node:a}=t.docView.domFromPos(i.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=IS(t,i.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=pi(c,0,c.nodeValue.length).getClientRects();else continue;for(let h=0;hf.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 pD=/[\u0590-\u08ac]/;function mD(t,e,n){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,a=!i,o=i==r.parent.content.size,c=t.domSelection();return c?!pD.test(r.parent.textContent)||!c.modify?n=="left"||n=="backward"?a:o:RS(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:b,focusOffset:j}=t.domSelectionRange(),w=b&&!y.contains(b.nodeType==1?b:b.parentNode)||u==b&&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 A1=null,I1=null,R1=!1;function gD(t,e,n){return A1==e&&I1==n?R1:(A1=e,I1=n,R1=n=="up"||n=="down"?fD(t,e,n):mD(t,e,n))}const Qr=0,P1=1,eo=2,$s=3;class gd{constructor(e,n,r,i){this.parent=e,this.children=n,this.dom=r,this.contentDOM=i,this.dirty=Qr,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;nVn(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))i=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(n==0)for(let a=e;;a=a.parentNode){if(a==this.dom){i=!1;break}if(a.previousSibling)break}if(i==null&&n==e.childNodes.length)for(let a=e;;a=a.parentNode){if(a==this.dom){i=!0;break}if(a.nextSibling)break}}return i??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,n=!1){for(let r=!0,i=e;i;i=i.parentNode){let a=this.getDesc(i),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 i=e;i;i=i.parentNode){let a=this.getDesc(i);if(a)return a.localPosFromDOM(e,n,r)}return-1}descAt(e){for(let n=0,r=0;ne||o instanceof OS){i=e-a;break}a=c}if(i)return this.children[r].domFromPos(i-this.children[r].border,n);for(let a;r&&!(a=this.children[r-1]).size&&a instanceof PS&&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?Vn(a.dom)+1:0}}else{let a,o=!0;for(;a=r=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)){i=Vn(g.dom)+1;break}e-=g.size}i==-1&&(i=0)}if(i>-1&&(h>n||c==this.children.length-1)){n=h;for(let f=c+1;fb&&on){let b=c;c=u,u=b}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,i=0;i=r:er){let c=r+a.border,u=o-a.border;if(e>=c&&n<=u){this.dirty=e==r||n==o?eo:P1,e==c&&n==u&&(a.contentLost||a.dom.parentNode!=this.contentDOM)?a.dirty=$s:a.markDirty(e-c,n-c);return}else a.dirty=a.dom==a.contentDOM&&a.dom.parentNode==this.contentDOM&&!a.children.length?eo:$s}r=o}this.dirty=eo}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?eo:P1;n.dirty{if(!a)return i;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==Qr&&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 xD extends gd{constructor(e,n,r,i){super(e,[],n,null),this.textDOM=r,this.text=i}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 yo extends gd{constructor(e,n,r,i,a){super(e,[],r,i),this.mark=n,this.spec=a}static create(e,n,r,i){let a=i.nodeViews[n.type.name],o=a&&a(n,i,r);return(!o||!o.dom)&&(o=So.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new yo(e,n,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty&$s||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=$s&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=Qr){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty0&&(a=Kg(a,0,e,r));for(let c=0;c{if(!u)return o;if(u.parent)return u.parent.posBeforeChild(u)},r,i),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}=So.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=_S(f,r,n),h?u=new yD(e,n,r,i,f,m||null,g,h,a,o+1):n.isText?new jf(e,n,r,i,f,g,a):new pa(e,n,r,i,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=()=>ge.empty)}return e}matchesNode(e,n,r){return this.dirty==Qr&&e.eq(this.node)&&yh(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,i=n,a=e.composing?this.localCompositionInfo(e,n):null,o=a&&a.pos>-1?a:null,c=a&&a.pos<0,u=new bD(this,o&&o.node,e);jD(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?Rt.none:this.node.child(f).marks,r,e,f),u.placeWidget(h,e,i)},(h,f,m,g)=>{u.syncToMarks(h.marks,r,e,g);let y;u.findNodeMatch(h,f,m,g)||c&&e.state.selection.from>i&&e.state.selection.to-1&&u.updateNodeAt(h,f,m,y,e)||u.updateNextNode(h,f,m,e,g,i)||u.addNode(h,f,m,e,i),i+=h.nodeSize}),u.syncToMarks([],r,e,0),this.node.isTextblock&&u.addTextblockHacks(),u.destroyRest(),(u.changed||this.dirty==eo)&&(o&&this.protectLocalComposition(e,o),DS(this.contentDOM,this.children,e),El&&kD(this.dom))}localCompositionInfo(e,n){let{from:r,to:i}=e.state.selection;if(!(e.state.selection instanceof qe)||rn+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=SD(this.node.content,o,r-n,i-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:i}){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 xD(this,a,n,i);e.input.compositionNodes.push(o),this.children=Kg(this.children,r,r+i.length,e,o)}update(e,n,r,i){return this.dirty==$s||!e.sameMarkup(this.node)?!1:(this.updateInner(e,n,r,i),!0)}updateInner(e,n,r,i){this.updateOuterDeco(n),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(i,this.posAtStart),this.dirty=Qr}updateOuterDeco(e){if(yh(e,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=LS(this.dom,this.nodeDOM,Ug(this.outerDeco,this.node,n),Ug(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 O1(t,e,n,r,i){_S(r,e,t);let a=new pa(void 0,t,e,n,r,r,r,i,0);return a.contentDOM&&a.updateChildren(i,0),a}class jf extends pa{constructor(e,n,r,i,a,o,c){super(e,n,r,i,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,i){return this.dirty==$s||this.dirty!=Qr&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=Qr||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,i.trackWrites==this.nodeDOM&&(i.trackWrites=null)),this.node=e,this.dirty=Qr,!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 i=this.node.cut(e,n),a=document.createTextNode(i.text);return new jf(this.parent,i,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=$s)}get domAtom(){return!1}isText(e){return this.node.text==e}}class OS extends gd{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Qr&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class yD extends pa{constructor(e,n,r,i,a,o,c,u,h,f){super(e,n,r,i,a,o,c,h,f),this.spec=u}update(e,n,r,i){if(this.dirty==$s)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,i),a}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,n,r,i)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,n,r,i){this.spec.setSelection?this.spec.setSelection(e,n,r.root):super.setSelection(e,n,r,i)}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 DS(t,e,n){let r=t.firstChild,i=!1;for(let a=0;a>1,c=Math.min(o,e.length);for(;a-1)u>this.index&&(this.changed=!0,this.destroyBetween(this.index,u)),this.top=this.top.children[this.index];else{let f=yo.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,i){let a=-1,o;if(i>=this.preMatch.index&&(o=this.preMatch.matches[i-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);c0;){let c;for(;;)if(r){let h=n.children[r-1];if(h instanceof yo)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(i-1))break;--i,a.set(c,i),o.push(c)}}return{index:i,matched:a,matches:o.reverse()}}function wD(t,e){return t.type.side-e.type.side}function jD(t,e,n,r){let i=e.locals(t),a=0;if(i.length==0){for(let h=0;ha;)c.push(i[o++]);let b=a+g.nodeSize;if(g.isText){let w=b;o!w.inline):c.slice();r(g,j,e.forChild(a,g),y),a=b}}function kD(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 SD(t,e,n,r){for(let i=0,a=0;i=n){if(a>=r&&u.slice(r-e.length-c,r-c)==e)return r-e.length;let h=c=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 Kg(t,e,n,r,i){let a=[];for(let o=0,c=0;o=n||f<=e?a.push(u):(hn&&a.push(u.slice(n-h,u.size,r)))}return a}function c0(t,e=null){let n=t.domSelectionRange(),r=t.state.doc;if(!n.focusNode)return null;let i=t.docView.nearestDesc(n.focusNode),a=i&&i.size==0,o=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(o<0)return null;let c=r.resolve(o),u,h;if(wf(n)){for(u=o;i&&!i.node;)i=i.parent;let m=i.node;if(i&&m.isAtom&&Ke.isSelectable(m)&&i.parent&&!(m.isInline&&XO(n.focusNode,n.focusOffset,i.dom))){let g=i.posBefore;h=new Ke(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.anchorNode!=r||n.anchorOffset!=i)&&(e.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout(()=>{(!zS(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function ED(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,r=n.nodeName=="IMG";r?e.collapse(n.parentNode,Vn(n)+1):e.collapse(n,0),!r&&!t.state.selection.visible&&kr&&fa<=11&&(n.disabled=!0,n.disabled=!1)}function $S(t,e){if(e instanceof Ke){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&($1(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else $1(t)}function $1(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function d0(t,e,n,r){return t.someProp("createSelectionBetween",i=>i(t,e,n))||qe.between(e,n,r)}function F1(t){return t.editable&&!t.hasFocus()?!1:FS(t)}function FS(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 TD(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return xo(e.node,e.offset,n.anchorNode,n.anchorOffset)}function qg(t,e){let{$anchor:n,$head:r}=t.selection,i=e>0?n.max(r):n.min(r),a=i.parent.inlineContent?i.depth?t.doc.resolve(e>0?i.after():i.before()):null:i;return a&&Ze.findFrom(a,e)}function Xi(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function B1(t,e,n){let r=t.state.selection;if(r instanceof qe)if(n.indexOf("s")>-1){let{$head:i}=r,a=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter;if(!a||a.isText||!a.isLeaf)return!1;let o=t.state.doc.resolve(i.pos+a.nodeSize*(e<0?-1:1));return Xi(t,new qe(r.$anchor,o))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let i=qg(t.state,e);return i&&i instanceof Ke?Xi(t,i):!1}else if(!(Gr&&n.indexOf("m")>-1)){let i=r.$head,a=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter,o;if(!a||a.isText)return!1;let c=e<0?i.pos-a.nodeSize:i.pos;return a.isAtom||(o=t.docView.descAt(c))&&!o.contentDOM?Ke.isSelectable(a)?Xi(t,new Ke(e<0?t.state.doc.resolve(i.pos-a.nodeSize):i)):md?Xi(t,new qe(t.state.doc.resolve(e<0?c:c+a.nodeSize))):!1:!1}}else return!1;else{if(r instanceof Ke&&r.node.isInline)return Xi(t,new qe(e>0?r.$to:r.$from));{let i=qg(t.state,e);return i?Xi(t,i):!1}}}function vh(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function zc(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function ol(t,e){return e<0?MD(t):AD(t)}function MD(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i,a,o=!1;for(Yr&&n.nodeType==1&&r0){if(n.nodeType!=1)break;{let c=n.childNodes[r-1];if(zc(c,-1))i=n,a=--r;else if(c.nodeType==3)n=c,r=n.nodeValue.length;else break}}else{if(BS(n))break;{let c=n.previousSibling;for(;c&&zc(c,-1);)i=n.parentNode,a=Vn(c),c=c.previousSibling;if(c)n=c,r=vh(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}o?Gg(t,n,r):i&&Gg(t,i,a)}function AD(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i=vh(n),a,o;for(;;)if(r{t.state==i&&vi(t)},50)}function V1(t,e){let n=t.state.doc.resolve(e);if(!(Wn||CS)&&n.parent.inlineContent){let i=t.coordsAtPos(e);if(e>n.start()){let a=t.coordsAtPos(e-1),o=(a.top+a.bottom)/2;if(o>i.top&&o1)return a.lefti.top&&o1)return a.left>i.left?"ltr":"rtl"}}return getComputedStyle(t.dom).direction=="rtl"?"rtl":"ltr"}function H1(t,e,n){let r=t.state.selection;if(r instanceof qe&&!r.empty||n.indexOf("s")>-1||Gr&&n.indexOf("m")>-1)return!1;let{$from:i,$to:a}=r;if(!i.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let o=qg(t.state,e);if(o&&o instanceof Ke)return Xi(t,o)}if(!i.parent.inlineContent){let o=e<0?i:a,c=r instanceof Dr?Ze.near(o,e):Ze.findFrom(o,e);return c?Xi(t,c):!1}return!1}function W1(t,e){if(!(t.state.selection instanceof qe))return!0;let{$head:n,$anchor:r,empty:i}=t.state.selection;if(!n.sameParent(r))return!0;if(!i)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 U1(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function PD(t){if(!nr||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;U1(t,r,"true"),setTimeout(()=>U1(t,r,"false"),20)}return!1}function OD(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function DD(t,e){let n=e.keyCode,r=OD(e);if(n==8||Gr&&n==72&&r=="c")return W1(t,-1)||ol(t,-1);if(n==46&&!e.shiftKey||Gr&&n==68&&r=="c")return W1(t,1)||ol(t,1);if(n==13||n==27)return!0;if(n==37||Gr&&n==66&&r=="c"){let i=n==37?V1(t,t.state.selection.from)=="ltr"?-1:1:-1;return B1(t,i,r)||ol(t,i)}else if(n==39||Gr&&n==70&&r=="c"){let i=n==39?V1(t,t.state.selection.from)=="ltr"?1:-1:1;return B1(t,i,r)||ol(t,i)}else{if(n==38||Gr&&n==80&&r=="c")return H1(t,-1,r)||ol(t,-1);if(n==40||Gr&&n==78&&r=="c")return PD(t)||H1(t,1,r)||ol(t,1);if(r==(Gr?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function u0(t,e){t.someProp("transformCopied",y=>{e=y(e,t)});let n=[],{content:r,openStart:i,openEnd:a}=e;for(;i>1&&a>1&&r.childCount==1&&r.firstChild.childCount==1;){i--,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")||So.fromSchema(t.state.schema),c=qS(),u=c.createElement("div");u.appendChild(o.serializeFragment(r,{document:c}));let h=u.firstChild,f,m=0;for(;h&&h.nodeType==1&&(f=KS[h.nodeName.toLowerCase()]);){for(let y=f.length-1;y>=0;y--){let b=c.createElement(f[y]);for(;u.firstChild;)b.appendChild(u.firstChild);u.appendChild(b),m++}h=u.firstChild}h&&h.nodeType==1&&h.setAttribute("data-pm-slice",`${i} ${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 VS(t,e,n,r,i){let a=i.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 Ie(ge.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,i,r,t));if(m)c=m;else{let g=i.marks(),{schema:y}=t.state,b=So.fromSchema(y);o=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(j=>{let w=o.appendChild(document.createElement("p"));j&&w.appendChild(b.serializeNode(y.text(j,g)))})}}else t.someProp("transformPastedHTML",m=>{n=m(n,t)}),o=$D(n),md&&FD(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")||ha.fromSchema(t.state.schema)).parseSlice(o,{preserveWhitespace:!!(u||f),context:i,ruleFromNode(g){return g.nodeName=="BR"&&!g.nextSibling&&g.parentNode&&!LD.test(g.parentNode.nodeName)?{ignore:!0}:null}})),f)c=BD(K1(c,+f[1],+f[2]),f[4]);else if(c=Ie.maxOpen(_D(c.content,i),!0),c.openStart||c.openEnd){let m=0,g=0;for(let y=c.content.firstChild;m{c=m(c,t,u)}),c}const LD=/^(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 _D(t,e){if(t.childCount<2)return t;for(let n=e.depth;n>=0;n--){let i=e.node(n).contentMatchAt(e.index(n)),a,o=[];if(t.forEach(c=>{if(!o)return;let u=i.findWrapping(c.type),h;if(!u)return o=null;if(h=o.length&&a.length&&WS(u,a,c,o[o.length-1],0))o[o.length-1]=h;else{o.length&&(o[o.length-1]=US(o[o.length-1],a.length));let f=HS(c,u);o.push(f),i=i.matchType(f.type),a=u}}),o)return ge.from(o)}return t}function HS(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,ge.from(t));return t}function WS(t,e,n,r,i){if(i1&&(a=0),i=n&&(c=e<0?o.contentMatchAt(0).fillBefore(c,a<=i).append(c):c.append(o.contentMatchAt(o.childCount).fillBefore(ge.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,o.copy(c))}function K1(t,e,n){return en})),qm.createHTML(t)):t}function $D(t){let e=/^(\s*]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=qS().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(t),i;if((i=r&&KS[r[1].toLowerCase()])&&(t=i.map(a=>"<"+a+">").join("")+t+i.map(a=>"").reverse().join("")),n.innerHTML=zD(t),i)for(let a=0;a=0;c-=2){let u=n.nodes[r[c]];if(!u||u.hasRequiredAttrs())break;i=ge.from(u.create(r[c+1],i)),a++,o++}return new Ie(i,a,o)}const fr={},pr={},VD={touchstart:!0,touchmove:!0};class HD{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 WD(t){for(let e in fr){let n=fr[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{KD(t,r)&&!h0(t,r)&&(t.editable||!(r.type in pr))&&n(t,r)},VD[e]?{passive:!0}:void 0)}nr&&t.dom.addEventListener("input",()=>null),Yg(t)}function la(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function UD(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 Yg(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>h0(t,r))})}function h0(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function KD(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 qD(t,e){!h0(t,e)&&fr[e.type]&&(t.editable||!(e.type in pr))&&fr[e.type](t,e)}pr.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!JS(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(gi&&Wn&&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",i=>i(t,Qa(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||DD(t,n)?n.preventDefault():la(t,"key")};pr.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};pr.keypress=(t,e)=>{let n=e;if(JS(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||Gr&&n.metaKey)return;if(t.someProp("handleKeyPress",i=>i(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof qe)||!r.$from.sameParent(r.$to)){let i=String.fromCharCode(n.charCode),a=()=>t.state.tr.insertText(i).scrollIntoView();!/[\r\n]/.test(i)&&!t.someProp("handleTextInput",o=>o(t,r.$from.pos,r.$to.pos,i,a))&&t.dispatch(a()),n.preventDefault()}};function kf(t){return{left:t.clientX,top:t.clientY}}function GD(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function f0(t,e,n,r,i){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),i,!0):c(t,n,a.node(o),a.before(o),i,!1)))return!0;return!1}function Nl(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 JD(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&Ke.isSelectable(r)?(Nl(t,new Ke(n)),!0):!1}function YD(t,e){if(e==-1)return!1;let n=t.state.selection,r,i;n instanceof Ke&&(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(Ke.isSelectable(c)){r&&n.$from.depth>0&&o>=n.$from.depth&&a.before(n.$from.depth+1)==n.$from.pos?i=a.before(n.$from.depth):i=a.before(o);break}}return i!=null?(Nl(t,Ke.create(t.state.doc,i)),!0):!1}function QD(t,e,n,r,i){return f0(t,"handleClickOn",e,n,r)||t.someProp("handleClick",a=>a(t,e,r))||(i?YD(t,n):JD(t,n))}function XD(t,e,n,r){return f0(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",i=>i(t,e,r))}function ZD(t,e,n,r){return f0(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",i=>i(t,e,r))||eL(t,n,r)}function eL(t,e,n){if(n.button!=0)return!1;let r=t.state.doc;if(e==-1)return r.inlineContent?(Nl(t,qe.create(r,0,r.content.size)),!0):!1;let i=r.resolve(e);for(let a=i.depth+1;a>0;a--){let o=a>i.depth?i.nodeAfter:i.node(a),c=i.before(a);if(o.inlineContent)Nl(t,qe.create(r,c+1,c+1+o.content.size));else if(Ke.isSelectable(o))Nl(t,Ke.create(r,c));else continue;return!0}}function p0(t){return bh(t)}const GS=Gr?"metaKey":"ctrlKey";fr.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=p0(t),i=Date.now(),a="singleClick";i-t.input.lastClick.time<500&&GD(n,t.input.lastClick)&&!n[GS]&&t.input.lastClick.button==n.button&&(t.input.lastClick.type=="singleClick"?a="doubleClick":t.input.lastClick.type=="doubleClick"&&(a="tripleClick")),t.input.lastClick={time:i,x:n.clientX,y:n.clientY,type:a,button:n.button};let o=t.posAtCoords(kf(n));o&&(a=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new tL(t,o,n,!!r)):(a=="doubleClick"?XD:ZD)(t,o.pos,o.inside,n)?n.preventDefault():la(t,"pointer"))};class tL{constructor(e,n,r,i){this.view=e,this.pos=n,this.event=r,this.flushed=i,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[GS],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=i?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 Ke&&h.from<=o&&h.to>o)&&(this.mightDrag={node:a,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Yr&&!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)),la(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(()=>vi(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(kf(e))),this.updateAllowDefault(e),this.allowDefault||!n?la(this.view,"pointer"):QD(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||nr&&this.mightDrag&&!this.mightDrag.node.isAtom||Wn&&!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)?(Nl(this.view,Ze.near(this.view.state.doc.resolve(n.pos))),e.preventDefault()):la(this.view,"pointer")}move(e){this.updateAllowDefault(e),la(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)}}fr.touchstart=t=>{t.input.lastTouch=Date.now(),p0(t),la(t,"pointer")};fr.touchmove=t=>{t.input.lastTouch=Date.now(),la(t,"pointer")};fr.contextmenu=t=>p0(t);function JS(t,e){return t.composing?!0:nr&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const nL=gi?5e3:-1;pr.compositionstart=pr.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof qe&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||Wn&&CS&&rL(t)))t.markCursor=t.state.storedMarks||n.marks(),bh(t,!0),t.markCursor=null;else if(bh(t,!e.selection.empty),Yr&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let r=t.domSelectionRange();for(let i=r.focusNode,a=r.focusOffset;i&&i.nodeType==1&&a!=0;){let o=a<0?i.lastChild:i.childNodes[a-1];if(!o)break;if(o.nodeType==3){let c=t.domSelection();c&&c.collapse(o,o.nodeValue.length);break}else i=o,a=-1}}t.input.composing=!0}YS(t,nL)};function rL(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"}pr.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++,YS(t,20))};function YS(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>bh(t),e))}function QS(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=iL());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function sL(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=YO(e.focusNode,e.focusOffset),r=QO(e.focusNode,e.focusOffset);if(n&&r&&n!=r){let i=r.pmViewDesc,a=t.domObserver.lastChangedTextNode;if(n==a||r==a)return a;if(!i||!i.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 iL(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function bh(t,e=!1){if(!(gi&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),QS(t),e||t.docView&&t.docView.dirty){let n=c0(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 aL(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(),i=document.createRange();i.selectNodeContents(e),t.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),t.focus()},50)}const ed=kr&&fa<15||El&&tD<604;fr.copy=pr.cut=(t,e)=>{let n=e,r=t.state.selection,i=n.type=="cut";if(r.empty)return;let a=ed?null:n.clipboardData,o=r.content(),{dom:c,text:u}=u0(t,o);a?(n.preventDefault(),a.clearData(),a.setData("text/html",c.innerHTML),a.setData("text/plain",u)):aL(t,c),i&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function oL(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function lL(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 i=t.input.shiftKey&&t.input.lastKeyCode!=45;setTimeout(()=>{t.focus(),r.parentNode&&r.parentNode.removeChild(r),n?td(t,r.value,null,i,e):td(t,r.textContent,r.innerHTML,i,e)},50)}function td(t,e,n,r,i){let a=VS(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",u=>u(t,i,a||Ie.empty)))return!0;if(!a)return!1;let o=oL(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 XS(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," "):""}pr.paste=(t,e)=>{let n=e;if(t.composing&&!gi)return;let r=ed?null:n.clipboardData,i=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&td(t,XS(r),r.getData("text/html"),i,n)?n.preventDefault():lL(t,n)};class ZS{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}}const cL=Gr?"altKey":"ctrlKey";function e2(t,e){let n=t.someProp("dragCopies",r=>!r(e));return n??!e[cL]}fr.dragstart=(t,e)=>{let n=e,r=t.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let i=t.state.selection,a=i.empty?null:t.posAtCoords(kf(n)),o;if(!(a&&a.pos>=i.from&&a.pos<=(i instanceof Ke?i.to-1:i.to))){if(r&&r.mightDrag)o=Ke.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=Ke.create(t.state.doc,m.posBefore))}}let c=(o||t.state.selection).content(),{dom:u,text:h,slice:f}=u0(t,c);(!n.dataTransfer.files.length||!Wn||SS>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(ed?"Text":"text/html",u.innerHTML),n.dataTransfer.effectAllowed="copyMove",ed||n.dataTransfer.setData("text/plain",h),t.dragging=new ZS(f,e2(t,n),o)};fr.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};pr.dragover=pr.dragenter=(t,e)=>e.preventDefault();pr.drop=(t,e)=>{try{dL(t,e,t.dragging)}finally{t.dragging=null}};function dL(t,e,n){if(!e.dataTransfer)return;let r=t.posAtCoords(kf(e));if(!r)return;let i=t.state.doc.resolve(r.pos),a=n&&n.slice;a?t.someProp("transformPasted",y=>{a=y(a,t,!1)}):a=VS(t,XS(e.dataTransfer),ed?null:e.dataTransfer.getData("text/html"),!1,i);let o=!!(n&&e2(t,e));if(t.someProp("handleDrop",y=>y(t,e,a||Ie.empty,o))){e.preventDefault();return}if(!a)return;e.preventDefault();let c=a?sS(t.state.doc,i.pos,a):i.pos;c==null&&(c=i.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&&Ke.isSelectable(a.content.firstChild)&&g.nodeAfter&&g.nodeAfter.sameMarkup(a.content.firstChild))u.setSelection(new Ke(g));else{let y=u.mapping.map(c);u.mapping.maps[u.mapping.maps.length-1].forEach((b,j,w,N)=>y=N),u.setSelection(d0(t,g,u.doc.resolve(y)))}t.focus(),t.dispatch(u.setMeta("uiEvent","drop"))}fr.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())&&vi(t)},20))};fr.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)};fr.beforeinput=(t,e)=>{if(Wn&&gi&&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,Qa(8,"Backspace")))))return;let{$cursor:i}=t.state.selection;i&&i.pos>0&&t.dispatch(t.state.tr.delete(i.pos-1,i.pos).scrollIntoView())},50)}};for(let t in pr)fr[t]=pr[t];function nd(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||oo,this.side=this.spec.side||0}map(e,n,r,i){let{pos:a,deleted:o}=e.mapResult(n.from+i,this.side<0?-1:1);return o?null:new En(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&&nd(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class ma{constructor(e,n){this.attrs=e,this.spec=n||oo}map(e,n,r,i){let a=e.map(n.from+i,this.spec.inclusiveStart?-1:1)-r,o=e.map(n.to+i,this.spec.inclusiveEnd?1:-1)-r;return a>=o?null:new En(a,o,this)}valid(e,n){return n.from=e&&(!a||a(c.spec))&&r.push(c.copy(c.from+i,c.to+i))}for(let o=0;oe){let c=this.children[o]+1;this.children[o+2].findInner(e-c,n-c,r,i+c,a)}}map(e,n,r){return this==Qn||e.maps.length==0?this:this.mapInner(e,n,0,0,r||oo)}mapInner(e,n,r,i,a){let o;for(let c=0;c{let h=u+r,f;if(f=n2(n,c,h)){for(i||(i=this.children.slice());ac&&m.to=e){this.children[c]==e&&(r=this.children[c+2]);break}let a=e+1,o=a+n.content.size;for(let c=0;ca&&u.type instanceof ma){let h=Math.max(a,u.from)-a,f=Math.min(o,u.to)-a;hi.map(e,n,oo));return ta.from(r)}forChild(e,n){if(n.isLeaf)return It.empty;let r=[];for(let i=0;in instanceof It)?e:e.reduce((n,r)=>n.concat(r instanceof It?r:r.members),[]))}}forEachSet(e){for(let n=0;n{let w=j-b-(y-g);for(let N=0;NC+f-m)continue;let E=c[N]+f-m;y>=E?c[N+1]=g<=E?-2:-1:g>=f&&w&&(c[N]+=w,c[N+1]+=w)}m+=w}),f=n.maps[h].map(f,-1)}let u=!1;for(let h=0;h=r.content.size){u=!0;continue}let g=n.map(t[h+1]+a,-1),y=g-i,{index:b,offset:j}=r.content.findIndex(m),w=r.maybeChild(b);if(w&&j==m&&j+w.nodeSize==y){let N=c[h+2].mapInner(n,w,f+1,t[h]+a+1,o);N!=Qn?(c[h]=m,c[h+1]=y,c[h+2]=N):(c[h+1]=-2,u=!0)}else u=!0}if(u){let h=hL(c,t,e,n,i,a,o),f=wh(h,r,0,o);e=f.local;for(let m=0;mn&&o.to{let h=n2(t,c,u+n);if(h){a=!0;let f=wh(h,c,n+u+1,r);f!=Qn&&i.push(u,u+c.nodeSize,f)}});let o=t2(a?r2(t):t,-n).sort(lo);for(let c=0;c0;)e++;t.splice(e,0,n)}function Gm(t){let e=[];return t.someProp("decorations",n=>{let r=n(t.state);r&&r!=Qn&&e.push(r)}),t.cursorWrapper&&e.push(It.create(t.state.doc,[t.cursorWrapper.deco])),ta.from(e)}const fL={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},pL=kr&&fa<=11;class mL{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 gL{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new mL,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let i=0;ii.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():nr&&e.composing&&r.some(i=>i.type=="childList"&&i.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),pL&&(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,fL)),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;nthis.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(F1(this.view)){if(this.suppressingSelectionUpdates)return vi(this.view);if(kr&&fa<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&xo(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=Cl(a))n.add(a);for(let a=e.anchorNode;a;a=Cl(a))if(n.has(a)){r=a;break}let i=r&&this.view.docView.nearestDesc(r);if(i&&i.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(),i=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&F1(e)&&!this.ignoreSelectionChange(r),a=-1,o=-1,c=!1,u=[];if(e.editable)for(let f=0;ff.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(Yr&&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||vL(e,m)!=y)&&g.remove()}}}let h=null;a<0&&i&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)-1||i)&&(a>-1&&(e.docView.markDirty(a,o),xL(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,bL(e,u)),this.handleDOMChange(a,o,c,u),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||vi(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;fi;w--){let N=r.childNodes[w-1],C=N.pmViewDesc;if(N.nodeName=="BR"&&!C){a=w;break}if(!C||C.size)break}let m=t.state.doc,g=t.someProp("domParser")||ha.fromSchema(t.state.schema),y=m.resolve(o),b=null,j=g.parse(r,{topNode:y.parent,topMatch:y.parent.contentMatchAt(y.index()),topOpen:!0,from:i,to:a,preserveWhitespace:y.parent.type.whitespace=="pre"?"full":!0,findPositions:h,ruleFromNode:wL,context:y});if(h&&h[0].pos!=null){let w=h[0].pos,N=h[1]&&h[1].pos;N==null&&(N=w),b={anchor:w+o,head:N+o}}return{doc:j,sel:b,from:o,to:c}}function wL(t){let e=t.pmViewDesc;if(e)return e.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(nr&&/^(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||nr&&/^(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 jL=/^(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 kL(t,e,n,r,i){let a=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let D=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,P=c0(t,D);if(P&&!t.state.selection.eq(P)){if(Wn&&gi&&t.input.lastKeyCode===13&&Date.now()-100_(t,Qa(13,"Enter"))))return;let L=t.state.tr.setSelection(P);D=="pointer"?L.setMeta("pointer",!0):D=="key"&&L.scrollIntoView(),a&&L.setMeta("composition",a),t.dispatch(L)}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=NL(t,e,n),f=t.state.doc,m=f.slice(h.from,h.to),g,y;t.input.lastKeyCode===8&&Date.now()-100Date.now()-225||gi)&&i.some(D=>D.nodeType==1&&!jL.test(D.nodeName))&&(!b||b.endA>=b.endB)&&t.someProp("handleKeyDown",D=>D(t,Qa(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!b)if(r&&u instanceof qe&&!u.empty&&u.$head.sameParent(u.$anchor)&&!t.composing&&!(h.sel&&h.sel.anchor!=h.sel.head))b={start:u.from,endA:u.to,endB:u.to};else{if(h.sel){let D=X1(t,t.state.doc,h.sel);if(D&&!D.eq(t.state.selection)){let P=t.state.tr.setSelection(D);a&&P.setMeta("composition",a),t.dispatch(P)}}return}t.state.selection.fromt.state.selection.from&&b.start<=t.state.selection.from+2&&t.state.selection.from>=h.from?b.start=t.state.selection.from:b.endA=t.state.selection.to-2&&t.state.selection.to<=h.to&&(b.endB+=t.state.selection.to-b.endA,b.endA=t.state.selection.to)),kr&&fa<=11&&b.endB==b.start+1&&b.endA==b.start&&b.start>h.from&&h.doc.textBetween(b.start-h.from-1,b.start-h.from+1)=="  "&&(b.start--,b.endA--,b.endB--);let j=h.doc.resolveNoCache(b.start-h.from),w=h.doc.resolveNoCache(b.endB-h.from),N=f.resolve(b.start),C=j.sameParent(w)&&j.parent.inlineContent&&N.end()>=b.endA;if((El&&t.input.lastIOSEnter>Date.now()-225&&(!C||i.some(D=>D.nodeName=="DIV"||D.nodeName=="P"))||!C&&j.posD(t,Qa(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>b.start&&CL(f,b.start,b.endA,j,w)&&t.someProp("handleKeyDown",D=>D(t,Qa(8,"Backspace")))){gi&&Wn&&t.domObserver.suppressSelectionUpdates();return}Wn&&b.endB==b.start&&(t.input.lastChromeDelete=Date.now()),gi&&!C&&j.start()!=w.start()&&w.parentOffset==0&&j.depth==w.depth&&h.sel&&h.sel.anchor==h.sel.head&&h.sel.head==b.endA&&(b.endB-=2,w=h.doc.resolveNoCache(b.endB-h.from),setTimeout(()=>{t.someProp("handleKeyDown",function(D){return D(t,Qa(13,"Enter"))})},20));let E=b.start,M=b.endA,I=D=>{let P=D||t.state.tr.replace(E,M,h.doc.slice(b.start-h.from,b.endB-h.from));if(h.sel){let L=X1(t,P.doc,h.sel);L&&!(Wn&&t.composing&&L.empty&&(b.start!=b.endB||t.input.lastChromeDeletevi(t),20));let D=I(t.state.tr.delete(E,M)),P=f.resolve(b.start).marksAcross(f.resolve(b.endA));P&&D.ensureMarks(P),t.dispatch(D)}else if(b.endA==b.endB&&(O=SL(j.parent.content.cut(j.parentOffset,w.parentOffset),N.parent.content.cut(N.parentOffset,b.endA-N.start())))){let D=I(t.state.tr);O.type=="add"?D.addMark(E,M,O.mark):D.removeMark(E,M,O.mark),t.dispatch(D)}else if(j.parent.child(j.index()).isText&&j.index()==w.index()-(w.textOffset?0:1)){let D=j.parent.textBetween(j.parentOffset,w.parentOffset),P=()=>I(t.state.tr.insertText(D,E,M));t.someProp("handleTextInput",L=>L(t,E,M,D,P))||t.dispatch(P())}else t.dispatch(I());else t.dispatch(I())}function X1(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:d0(t,e.resolve(n.anchor),e.resolve(n.head))}function SL(t,e){let n=t.firstChild.marks,r=e.firstChild.marks,i=n,a=r,o,c,u;for(let f=0;ff.mark(c.addToSet(f.marks));else if(i.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;fn||Jm(o,!0,!1)0&&(e||t.indexAfter(r)==t.node(r).childCount);)r--,i++,e=!1;if(n){let a=t.node(r).maybeChild(t.indexAfter(r));for(;a&&!a.isLeaf;)a=a.firstChild,i++}return i}function EL(t,e,n,r,i){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(i=="end"){let u=Math.max(0,a-Math.min(o,c));r-=o+u-a}if(o=o?a-r:0;a-=u,a&&a=c?a-r:0;a-=u,a&&a=56320&&e<=57343&&n>=55296&&n<=56319}class s2{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 HD,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(sN),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=nN(this),tN(this),this.nodeViews=rN(this),this.docView=O1(this.state.doc,eN(this),Gm(this),this.dom,this),this.domObserver=new gL(this,(r,i,a,o)=>kL(this,r,i,a,o)),this.domObserver.start(),WD(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&&Yg(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(sN),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 i=this.state,a=!1,o=!1;e.storedMarks&&this.composing&&(QS(this),o=!0),this.state=e;let c=i.plugins!=e.plugins||this._props.plugins!=n.plugins;if(c||this._props.plugins!=n.plugins||this._props.nodeViews!=n.nodeViews){let y=rN(this);ML(y,this.nodeViews)&&(this.nodeViews=y,a=!0)}(c||n.handleDOMEvents!=this._props.handleDOMEvents)&&Yg(this),this.editable=nN(this),tN(this);let u=Gm(this),h=eN(this),f=i.plugins!=e.plugins&&!i.doc.eq(e.doc)?"reset":e.scrollToSelection>i.scrollToSelection?"to selection":"preserve",m=a||!this.docView.matchesNode(e.doc,h,u);(m||!e.selection.eq(i.selection))&&(o=!0);let g=f=="preserve"&&o&&this.dom.style.overflowAnchor==null&&sD(this);if(o){this.domObserver.stop();let y=m&&(kr||Wn)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&TL(i.selection,e.selection);if(m){let b=Wn?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=sL(this)),(a||!this.docView.update(e.doc,h,u,this))&&(this.docView.updateOuterDeco(h),this.docView.destroy(),this.docView=O1(e.doc,h,u,this.dom,this)),b&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(y=!0)}y||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&TD(this))?vi(this,y):($S(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(i),!((r=this.dragging)===null||r===void 0)&&r.node&&!i.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,i),f=="reset"?this.dom.scrollTop=0:f=="to selection"?this.scrollToSelection():g&&iD(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 Ke){let n=this.docView.domAfterPos(this.state.selection.from);n.nodeType==1&&T1(this,n.getBoundingClientRect(),e)}else T1(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;n0&&this.state.doc.nodeAt(a))==r.node&&(i=a)}this.dragging=new ZS(e.slice,e.move,i<0?void 0:Ke.create(this.state.doc,i))}someProp(e,n){let r=this._props&&this._props[e],i;if(r!=null&&(i=n?n(r):r))return i;for(let o=0;on.ownerDocument.getSelection()),this._root=n}return e||document}updateRoot(){this._root=null}posAtCoords(e){return uD(this,e)}coordsAtPos(e,n=1){return IS(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 i=this.docView.posFromDOM(e,n,r);if(i==null)throw new RangeError("DOM position not inside the editor");return i}endOfTextblock(e,n){return gD(this,n||this.state,e)}pasteHTML(e,n){return td(this,"",e,!1,n||new ClipboardEvent("paste"))}pasteText(e,n){return td(this,e,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(e){return u0(this,e)}destroy(){this.docView&&(UD(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Gm(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,GO())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return qD(this,e)}domSelectionRange(){let e=this.domSelection();return e?nr&&this.root.nodeType===11&&ZO(this.dom.ownerDocument)==this.dom&&yL(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}s2.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function eN(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"),[En.node(0,t.state.doc.content.size,e)]}function tN(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:En.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function nN(t){return!t.someProp("editable",e=>e(t.state)===!1)}function TL(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 rN(t){let e=Object.create(null);function n(r){for(let i in r)Object.prototype.hasOwnProperty.call(e,i)||(e[i]=r[i])}return t.someProp("nodeViews",n),t.someProp("markViews",n),e}function ML(t,e){let n=0,r=0;for(let i in t){if(t[i]!=e[i])return!0;n++}for(let i in e)r++;return n!=r}function sN(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 xa={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:"'"},jh={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},AL=typeof navigator<"u"&&/Mac/.test(navigator.platform),IL=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var Hn=0;Hn<10;Hn++)xa[48+Hn]=xa[96+Hn]=String(Hn);for(var Hn=1;Hn<=24;Hn++)xa[Hn+111]="F"+Hn;for(var Hn=65;Hn<=90;Hn++)xa[Hn]=String.fromCharCode(Hn+32),jh[Hn]=String.fromCharCode(Hn);for(var Ym in xa)jh.hasOwnProperty(Ym)||(jh[Ym]=xa[Ym]);function RL(t){var e=AL&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||IL&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?jh:xa)[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 PL=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),OL=typeof navigator<"u"&&/Win/.test(navigator.platform);function DL(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n=="Space"&&(n=" ");let r,i,a,o;for(let c=0;c{for(var n in e)zL(t,n,{get:e[n],enumerable:!0})};function Sf(t){const{state:e,transaction:n}=t;let{selection:r}=n,{doc:i}=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 i},get tr(){return r=n.selection,i=n.doc,a=n.storedMarks,n}}}var Cf=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:i}=n,a=this.buildProps(i);return Object.fromEntries(Object.entries(t).map(([o,c])=>[o,(...h)=>{const f=c(...h)(a);return!i.getMeta("preventDispatch")&&!this.hasCustomState&&r.dispatch(i),f}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(t,e=!0){const{rawCommands:n,editor:r,state:i}=this,{view:a}=r,o=[],c=!!t,u=t||i.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,(...b)=>{const j=this.buildProps(u,e),w=g(...b)(j);return o.push(w),f}])),run:h};return f}createCan(t){const{rawCommands:e,state:n}=this,r=!1,i=t||n.tr,a=this.buildProps(i,r);return{...Object.fromEntries(Object.entries(e).map(([c,u])=>[c,(...h)=>u(...h)({...a,dispatch:void 0})])),chain:()=>this.createChain(i,r)}}buildProps(t,e=!0){const{rawCommands:n,editor:r,state:i}=this,{view:a}=r,o={tr:t,editor:r,view:a,state:Sf({state:i,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}},i2={};y0(i2,{blur:()=>$L,clearContent:()=>FL,clearNodes:()=>BL,command:()=>VL,createParagraphNear:()=>HL,cut:()=>WL,deleteCurrentNode:()=>UL,deleteNode:()=>KL,deleteRange:()=>qL,deleteSelection:()=>GL,enter:()=>JL,exitCode:()=>YL,extendMarkRange:()=>QL,first:()=>XL,focus:()=>e8,forEach:()=>t8,insertContent:()=>n8,insertContentAt:()=>i8,joinBackward:()=>l8,joinDown:()=>o8,joinForward:()=>c8,joinItemBackward:()=>d8,joinItemForward:()=>u8,joinTextblockBackward:()=>h8,joinTextblockForward:()=>f8,joinUp:()=>a8,keyboardShortcut:()=>m8,lift:()=>g8,liftEmptyBlock:()=>x8,liftListItem:()=>y8,newlineInCode:()=>v8,resetAttributes:()=>b8,scrollIntoView:()=>N8,selectAll:()=>w8,selectNodeBackward:()=>j8,selectNodeForward:()=>k8,selectParentNode:()=>S8,selectTextblockEnd:()=>C8,selectTextblockStart:()=>E8,setContent:()=>T8,setMark:()=>G8,setMeta:()=>J8,setNode:()=>Y8,setNodeSelection:()=>Q8,setTextDirection:()=>X8,setTextSelection:()=>Z8,sinkListItem:()=>e6,splitBlock:()=>t6,splitListItem:()=>n6,toggleList:()=>r6,toggleMark:()=>s6,toggleNode:()=>i6,toggleWrap:()=>a6,undoInputRule:()=>o6,unsetAllMarks:()=>l6,unsetMark:()=>c6,unsetTextDirection:()=>d6,updateAttributes:()=>u6,wrapIn:()=>h6,wrapInList:()=>f6});var $L=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{var n;t.isDestroyed||(e.dom.blur(),(n=window==null?void 0:window.getSelection())==null||n.removeAllRanges())}),!0),FL=(t=!0)=>({commands:e})=>e.setContent("",{emitUpdate:t}),BL=()=>({state:t,tr:e,dispatch:n})=>{const{selection:r}=e,{ranges:i}=r;return n&&i.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 b=$l(y);if(c.type.isTextblock){const{defaultType:j}=m.parent.contentMatchAt(m.index());e.setNodeMarkup(y.start,j)}(b||b===0)&&e.lift(y,b)})}),!0},VL=t=>e=>t(e),HL=()=>({state:t,dispatch:e})=>bS(t,e),WL=(t,e)=>({editor:n,tr:r})=>{const{state:i}=n,a=i.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 qe(r.doc.resolve(Math.max(o-1,0)))),!0},UL=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,r=n.$anchor.node();if(r.content.size>0)return!1;const i=t.selection.$anchor;for(let a=i.depth;a>0;a-=1)if(i.node(a).type===r.type){if(e){const c=i.before(a),u=i.after(a);t.delete(c,u).scrollIntoView()}return!0}return!1};function bn(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 KL=t=>({tr:e,state:n,dispatch:r})=>{const i=bn(t,n.schema),a=e.selection.$anchor;for(let o=a.depth;o>0;o-=1)if(a.node(o).type===i){if(r){const u=a.before(o),h=a.after(o);e.delete(u,h).scrollIntoView()}return!0}return!1},qL=t=>({tr:e,dispatch:n})=>{const{from:r,to:i}=t;return n&&e.delete(r,i),!0},GL=()=>({state:t,dispatch:e})=>r0(t,e),JL=()=>({commands:t})=>t.keyboardShortcut("Enter"),YL=()=>({state:t,dispatch:e})=>PO(t,e);function v0(t){return Object.prototype.toString.call(t)==="[object RegExp]"}function kh(t,e,n={strict:!0}){const r=Object.keys(e);return r.length?r.every(i=>n.strict?e[i]===t[i]:v0(e[i])?e[i].test(t[i]):e[i]===t[i]):!0}function a2(t,e,n={}){return t.find(r=>r.type===e&&kh(Object.fromEntries(Object.keys(n).map(i=>[i,r.attrs[i]])),n))}function iN(t,e,n={}){return!!a2(t,e,n)}function b0(t,e,n){var r;if(!t||!e)return;let i=t.parent.childAfter(t.parentOffset);if((!i.node||!i.node.marks.some(f=>f.type===e))&&(i=t.parent.childBefore(t.parentOffset)),!i.node||!i.node.marks.some(f=>f.type===e)||(n=n||((r=i.node.marks[0])==null?void 0:r.attrs),!a2([...i.node.marks],e,n)))return;let o=i.index,c=t.start()+i.offset,u=o+1,h=c+i.node.nodeSize;for(;o>0&&iN([...t.parent.child(o-1).marks],e,n);)o-=1,c-=t.parent.child(o).nodeSize;for(;u({tr:n,state:r,dispatch:i})=>{const a=ji(t,r.schema),{doc:o,selection:c}=n,{$from:u,from:h,to:f}=c;if(i){const m=b0(u,a,e);if(m&&m.from<=h&&m.to>=f){const g=qe.create(o,m.from,m.to);n.setSelection(g)}}return!0},XL=t=>e=>{const n=typeof t=="function"?t(e):t;for(let r=0;r({editor:n,view:r,tr:i,dispatch:a})=>{e={scrollIntoView:!0,...e};const o=()=>{(Sh()||aN())&&r.dom.focus(),ZL()&&!Sh()&&!aN()&&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&&!o2(n.state.selection))return o(),!0;const c=l2(i.doc,t)||n.state.selection,u=n.state.selection.eq(c);return a&&(u||i.setSelection(c),u&&i.storedMarks&&i.setStoredMarks(i.storedMarks),o()),!0},t8=(t,e)=>n=>t.every((r,i)=>e(r,{...n,index:i})),n8=(t,e)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),c2=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&&c2(r)}return t};function Pu(t){if(typeof window>"u")throw new Error("[tiptap error]: there is no window object available, so this function cannot be used");const e=`${t}`,n=new window.DOMParser().parseFromString(e,"text/html").body;return c2(n)}function rd(t,e,n){if(t instanceof xi||t instanceof ge)return t;n={slice:!0,parseOptions:{},...n};const r=typeof t=="object"&&t!==null,i=typeof t=="string";if(r)try{if(Array.isArray(t)&&t.length>0)return ge.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),rd("",e,n)}if(i){if(n.errorOnInvalidContent){let o=!1,c="";const u=new qk({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?ha.fromSchema(u).parseSlice(Pu(t),n.parseOptions):ha.fromSchema(u).parse(Pu(t),n.parseOptions),n.errorOnInvalidContent&&o)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${c}`)})}const a=ha.fromSchema(e);return n.slice?a.parseSlice(Pu(t),n.parseOptions).content:a.parse(Pu(t),n.parseOptions)}return rd("",e,n)}function r8(t,e,n){const r=t.steps.length-1;if(r{o===0&&(o=f)}),t.setSelection(Ze.near(t.doc.resolve(o),n))}var s8=t=>!("type"in t),i8=(t,e,n)=>({tr:r,dispatch:i,editor:a})=>{var o;if(i){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{rd(e,a.schema,{parseOptions:h,errorOnInvalidContent:!0})}catch(w){u(w)}try{c=rd(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((s8(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 ge){let w="";e.forEach(N=>{N.text&&(w+=N.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),N=w.node(),C=w.parentOffset===0,E=N.isText||N.isTextblock,M=N.content.size>0;C&&E&&M&&(f=Math.max(0,f-1)),r.replaceWith(f,m,j)}n.updateSelection&&r8(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},a8=()=>({state:t,dispatch:e})=>AO(t,e),o8=()=>({state:t,dispatch:e})=>IO(t,e),l8=()=>({state:t,dispatch:e})=>fS(t,e),c8=()=>({state:t,dispatch:e})=>xS(t,e),d8=()=>({state:t,dispatch:e,tr:n})=>{try{const r=vf(t.doc,t.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},u8=()=>({state:t,dispatch:e,tr:n})=>{try{const r=vf(t.doc,t.selection.$from.pos,1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},h8=()=>({state:t,dispatch:e})=>TO(t,e),f8=()=>({state:t,dispatch:e})=>MO(t,e);function d2(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function p8(t){const e=t.split(/-(?!$)/);let n=e[e.length-1];n==="Space"&&(n=" ");let r,i,a,o;for(let c=0;c({editor:e,view:n,tr:r,dispatch:i})=>{const a=p8(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&&i&&r.maybeStep(f)}),!0};function ya(t,e,n={}){const{from:r,to:i,empty:a}=t.selection,o=e?bn(e,t.schema):null,c=[];t.doc.nodesBetween(r,i,(m,g)=>{if(m.isText)return;const y=Math.max(r,g),b=Math.min(i,g+m.nodeSize);c.push({node:m,from:y,to:b})});const u=i-r,h=c.filter(m=>o?o.name===m.node.type.name:!0).filter(m=>kh(m.node.attrs,n,{strict:!1}));return a?!!h.length:h.reduce((m,g)=>m+g.to-g.from,0)>=u}var g8=(t,e={})=>({state:n,dispatch:r})=>{const i=bn(t,n.schema);return ya(n,i,e)?RO(n,r):!1},x8=()=>({state:t,dispatch:e})=>NS(t,e),y8=t=>({state:e,dispatch:n})=>{const r=bn(t,e.schema);return WO(r)(e,n)},v8=()=>({state:t,dispatch:e})=>vS(t,e);function Ef(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function oN(t,e){const n=typeof e=="string"?[e]:e;return Object.keys(t).reduce((r,i)=>(n.includes(i)||(r[i]=t[i]),r),{})}var b8=(t,e)=>({tr:n,state:r,dispatch:i})=>{let a=null,o=null;const c=Ef(typeof t=="string"?t:t.name,r.schema);if(!c)return!1;c==="node"&&(a=bn(t,r.schema)),c==="mark"&&(o=ji(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,i&&n.setNodeMarkup(m,void 0,oN(f.attrs,e))),o&&f.marks.length&&f.marks.forEach(g=>{o===g.type&&(u=!0,i&&n.addMark(m,m+f.nodeSize,o.create(oN(g.attrs,e))))})})}),u},N8=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),w8=()=>({tr:t,dispatch:e})=>{if(e){const n=new Dr(t.doc);t.setSelection(n)}return!0},j8=()=>({state:t,dispatch:e})=>mS(t,e),k8=()=>({state:t,dispatch:e})=>yS(t,e),S8=()=>({state:t,dispatch:e})=>LO(t,e),C8=()=>({state:t,dispatch:e})=>$O(t,e),E8=()=>({state:t,dispatch:e})=>zO(t,e);function Qg(t,e,n={},r={}){return rd(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var T8=(t,{errorOnInvalidContent:e,emitUpdate:n=!0,parseOptions:r={}}={})=>({editor:i,tr:a,dispatch:o,commands:c})=>{const{doc:u}=a;if(r.preserveWhitespace!=="full"){const h=Qg(t,i.schema,r,{errorOnInvalidContent:e??i.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??i.options.enableContentCheck})};function u2(t,e){const n=ji(e,t.schema),{from:r,to:i,empty:a}=t.selection,o=[];a?(t.storedMarks&&o.push(...t.storedMarks),o.push(...t.selection.$head.marks())):t.doc.nodesBetween(r,i,u=>{o.push(...u.marks)});const c=o.find(u=>u.type.name===n.name);return c?{...c.attrs}:{}}function h2(t,e){const n=new t0(t);return e.forEach(r=>{r.steps.forEach(i=>{n.step(i)})}),n}function M8(t){for(let e=0;e{n(i)&&r.push({node:i,pos:a})}),r}function f2(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 Tf(t){return e=>f2(e.$from,t)}function We(t,e,n){return t.config[e]===void 0&&t.parent?We(t.parent,e,n):typeof t.config[e]=="function"?t.config[e].bind({...n,parent:t.parent?We(t.parent,e,n):null}):t.config[e]}function N0(t){return t.map(e=>{const n={name:e.name,options:e.options,storage:e.storage},r=We(e,"addExtensions",n);return r?[e,...N0(r())]:e}).flat(10)}function w0(t,e){const n=So.fromSchema(e).serializeFragment(t),i=document.implementation.createHTMLDocument().createElement("div");return i.appendChild(n),i.innerHTML}function p2(t){return typeof t=="function"}function jt(t,e=void 0,...n){return p2(t)?e?t.bind(e)(...n):t(...n):t}function I8(t={}){return Object.keys(t).length===0&&t.constructor===Object}function Tl(t){const e=t.filter(i=>i.type==="extension"),n=t.filter(i=>i.type==="node"),r=t.filter(i=>i.type==="mark");return{baseExtensions:e,nodeExtensions:n,markExtensions:r}}function m2(t){const e=[],{nodeExtensions:n,markExtensions:r}=Tl(t),i=[...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:i},m=We(h,"addGlobalAttributes",f);if(!m)return;m().forEach(y=>{let b;Array.isArray(y.types)?b=y.types:y.types==="*"?b=u:y.types==="nodes"?b=o:y.types==="marks"?b=c:b=[],b.forEach(j=>{Object.entries(y.attributes).forEach(([w,N])=>{e.push({type:j,name:w,attribute:{...a,...N}})})})})}),i.forEach(h=>{const f={name:h.name,options:h.options,storage:h.storage},m=We(h,"addAttributes",f);if(!m)return;const g=m();Object.entries(g).forEach(([y,b])=>{const j={...a,...b};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 R8(t){const e=[];let n="",r=!1,i=!1,a=0;const o=t.length;for(let c=0;c0){a-=1,n+=u;continue}if(u===";"&&a===0){e.push(n),n="";continue}}n+=u}return n&&e.push(n),e}function lN(t){const e=[],n=R8(t||""),r=n.length;for(let i=0;i!!e).reduce((e,n)=>{const r={...e};return Object.entries(n).forEach(([i,a])=>{if(!r[i]){r[i]=a;return}if(i==="class"){const c=a?String(a).split(" "):[],u=r[i]?r[i].split(" "):[],h=c.filter(f=>!u.includes(f));r[i]=[...u,...h].join(" ")}else if(i==="style"){const c=new Map([...lN(r[i]),...lN(a)]);r[i]=Array.from(c.entries()).map(([u,h])=>`${u}: ${h}`).join("; ")}else r[i]=a}),r},{})}function sd(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)=>kt(n,r),{})}function P8(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function cN(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 i=e.reduce((a,o)=>{const c=o.attribute.parseHTML?o.attribute.parseHTML(n):P8(n.getAttribute(o.name));return c==null?a:{...a,[o.name]:c}},{});return{...r,...i}}}}function dN(t){return Object.fromEntries(Object.entries(t).filter(([e,n])=>e==="attrs"&&I8(n)?!1:n!=null))}function uN(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 O8(t,e){var n;const r=m2(t),{nodeExtensions:i,markExtensions:a}=Tl(t),o=(n=i.find(h=>We(h,"topNode")))==null?void 0:n.name,c=Object.fromEntries(i.map(h=>{const f=r.filter(N=>N.type===h.name),m={name:h.name,options:h.options,storage:h.storage,editor:e},g=t.reduce((N,C)=>{const E=We(C,"extendNodeSchema",m);return{...N,...E?E(h):{}}},{}),y=dN({...g,content:jt(We(h,"content",m)),marks:jt(We(h,"marks",m)),group:jt(We(h,"group",m)),inline:jt(We(h,"inline",m)),atom:jt(We(h,"atom",m)),selectable:jt(We(h,"selectable",m)),draggable:jt(We(h,"draggable",m)),code:jt(We(h,"code",m)),whitespace:jt(We(h,"whitespace",m)),linebreakReplacement:jt(We(h,"linebreakReplacement",m)),defining:jt(We(h,"defining",m)),isolating:jt(We(h,"isolating",m)),attrs:Object.fromEntries(f.map(uN))}),b=jt(We(h,"parseHTML",m));b&&(y.parseDOM=b.map(N=>cN(N,f)));const j=We(h,"renderHTML",m);j&&(y.toDOM=N=>j({node:N,HTMLAttributes:sd(N,f)}));const w=We(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,N)=>{const C=We(N,"extendMarkSchema",m);return{...w,...C?C(h):{}}},{}),y=dN({...g,inclusive:jt(We(h,"inclusive",m)),excludes:jt(We(h,"excludes",m)),group:jt(We(h,"group",m)),spanning:jt(We(h,"spanning",m)),code:jt(We(h,"code",m)),attrs:Object.fromEntries(f.map(uN))}),b=jt(We(h,"parseHTML",m));b&&(y.parseDOM=b.map(w=>cN(w,f)));const j=We(h,"renderHTML",m);return j&&(y.toDOM=w=>j({mark:w,HTMLAttributes:sd(w,f)})),[h.name,y]}));return new qk({topNode:o,nodes:c,marks:u})}function D8(t){const e=t.filter((n,r)=>t.indexOf(n)!==r);return Array.from(new Set(e))}function $c(t){return t.sort((n,r)=>{const i=We(n,"priority")||100,a=We(r,"priority")||100;return i>a?-1:ir.name));return n.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${n.map(r=>`'${r}'`).join(", ")}]. This can lead to issues.`),e}function x2(t,e,n){const{from:r,to:i}=e,{blockSeparator:a=` + +`,textSerializers:o={}}=n||{};let c="";return t.nodesBetween(r,i,(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,i-h))}),c}function L8(t,e){const n={from:0,to:t.content.size};return x2(t,n,e)}function y2(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,n])=>[e,n.spec.toText]))}function _8(t,e){const n=bn(e,t.schema),{from:r,to:i}=t.selection,a=[];t.doc.nodesBetween(r,i,c=>{a.push(c)});const o=a.reverse().find(c=>c.type.name===n.name);return o?{...o.attrs}:{}}function v2(t,e){const n=Ef(typeof e=="string"?e:e.name,t.schema);return n==="node"?_8(t,e):n==="mark"?u2(t,e):{}}function z8(t,e=JSON.stringify){const n={};return t.filter(r=>{const i=e(r);return Object.prototype.hasOwnProperty.call(n,i)?!1:n[i]=!0})}function $8(t){const e=z8(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 b2(t){const{mapping:e,steps:n}=t,r=[];return e.maps.forEach((i,a)=>{const o=[];if(i.ranges.length)i.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}})})}),$8(r)}function j0(t,e,n){const r=[];return t===e?n.resolve(t).marks().forEach(i=>{const a=n.resolve(t),o=b0(a,i.type);o&&r.push({mark:i,...o})}):n.nodesBetween(t,e,(i,a)=>{!i||(i==null?void 0:i.nodeSize)===void 0||r.push(...i.marks.map(o=>({from:a,to:a+i.nodeSize,mark:o})))}),r}var F8=(t,e,n,r=20)=>{const i=t.doc.resolve(n);let a=r,o=null;for(;a>0&&o===null;){const c=i.node(a);(c==null?void 0:c.type.name)===e?o=c:a-=1}return[o,a]};function kc(t,e){return e.nodes[t]||e.marks[t]||null}function Xu(t,e,n){return Object.fromEntries(Object.entries(n).filter(([r])=>{const i=t.find(a=>a.type===e&&a.name===r);return i?i.attribute.keepOnSplit:!1}))}var B8=(t,e=500)=>{let n="";const r=t.parentOffset;return t.parent.nodesBetween(Math.max(0,r-e),r,(i,a,o,c)=>{var u,h;const f=((h=(u=i.type.spec).toText)==null?void 0:h.call(u,{node:i,pos:a,parent:o,index:c}))||i.textContent||"%leaf%";n+=i.isAtom&&!i.isText?f:f.slice(0,Math.max(0,r-a))}),n};function Xg(t,e,n={}){const{empty:r,ranges:i}=t.selection,a=e?ji(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter(m=>a?a.name===m.type.name:!0).find(m=>kh(m.attrs,n,{strict:!1}));let o=0;const c=[];if(i.forEach(({$from:m,$to:g})=>{const y=m.pos,b=g.pos;t.doc.nodesBetween(y,b,(j,w)=>{if(a&&j.inlineContent&&!j.type.allowsMarkType(a))return!1;if(!j.isText&&!j.marks.length)return;const N=Math.max(y,w),C=Math.min(b,w+j.nodeSize),E=C-N;o+=E,c.push(...j.marks.map(M=>({mark:M,from:N,to:C})))})}),o===0)return!1;const u=c.filter(m=>a?a.name===m.mark.type.name:!0).filter(m=>kh(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 V8(t,e,n={}){if(!e)return ya(t,null,n)||Xg(t,null,n);const r=Ef(e,t.schema);return r==="node"?ya(t,e,n):r==="mark"?Xg(t,e,n):!1}var H8=(t,e)=>{const{$from:n,$to:r,$anchor:i}=t.selection;if(e){const a=Tf(c=>c.type.name===e)(t.selection);if(!a)return!1;const o=t.doc.resolve(a.pos+1);return i.pos+1===o.end()}return!(r.parentOffset{const{$from:e,$to:n}=t.selection;return!(e.parentOffset>0||e.pos!==n.pos)};function hN(t,e){return Array.isArray(e)?e.some(n=>(typeof n=="string"?n:n.name)===t.name):e}function fN(t,e){const{nodeExtensions:n}=Tl(e),r=n.find(o=>o.name===t);if(!r)return!1;const i={name:r.name,options:r.options,storage:r.storage},a=jt(We(r,"group",i));return typeof a!="string"?!1:a.split(" ").includes("list")}function Mf(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 i=!0;return t.content.forEach(a=>{i!==!1&&(Mf(a,{ignoreWhitespace:n,checkChildren:e})||(i=!1))}),i}return!1}function N2(t){return t instanceof Ke}var w2=class j2{constructor(e){this.position=e}static fromJSON(e){return new j2(e.position)}toJSON(){return{position:this.position}}};function U8(t,e){const n=e.mapping.mapResult(t.position);return{position:new w2(n.pos),mapResult:n}}function K8(t){return new w2(t)}function q8(t,e,n){var r;const{selection:i}=e;let a=null;if(o2(i)&&(a=i.$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}=i;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),b=!!n.isInSet(f.marks)||!f.marks.some(j=>j.type.excludes(n));h=y&&b}return!h}),h})}var G8=(t,e={})=>({tr:n,state:r,dispatch:i})=>{const{selection:a}=n,{empty:o,ranges:c}=a,u=ji(t,r.schema);if(i)if(o){const h=u2(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 b=Math.max(y,f),j=Math.min(y+g.nodeSize,m);g.marks.find(N=>N.type===u)?g.marks.forEach(N=>{u===N.type&&n.addMark(b,j,u.create({...N.attrs,...e}))}):n.addMark(b,j,u.create(e))})});return q8(r,n,u)},J8=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),Y8=(t,e={})=>({state:n,dispatch:r,chain:i})=>{const a=bn(t,n.schema);let o;return n.selection.$anchor.sameParent(n.selection.$head)&&(o=n.selection.$anchor.parent.attrs),a.isTextblock?i().command(({commands:c})=>S1(a,{...o,...e})(n)?!0:c.clearNodes()).command(({state:c})=>S1(a,{...o,...e})(c,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},Q8=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,i=no(t,0,r.content.size),a=Ke.create(r,i);e.setSelection(a)}return!0},X8=(t,e)=>({tr:n,state:r,dispatch:i})=>{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),i&&n.doc.nodesBetween(o,c,(u,h)=>{u.isText||n.setNodeMarkup(h,void 0,{...u.attrs,dir:t})}),!0},Z8=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,{from:i,to:a}=typeof t=="number"?{from:t,to:t}:t,o=qe.atStart(r).from,c=qe.atEnd(r).to,u=no(i,o,c),h=no(a,o,c),f=qe.create(r,u,h);e.setSelection(f)}return!0},e6=t=>({state:e,dispatch:n})=>{const r=bn(t,e.schema);return qO(r)(e,n)};function pN(t,e){const n=t.storedMarks||t.selection.$to.parentOffset&&t.selection.$from.marks();if(n){const r=n.filter(i=>e==null?void 0:e.includes(i.type.name));t.tr.ensureMarks(r)}}var t6=({keepMarks:t=!0}={})=>({tr:e,state:n,dispatch:r,editor:i})=>{const{selection:a,doc:o}=e,{$from:c,$to:u}=a,h=i.extensionManager.attributes,f=Xu(h,c.node().type.name,c.node().attrs);if(a instanceof Ke&&a.node.isBlock)return!c.parentOffset||!yi(o,c.pos)?!1:(r&&(t&&pN(n,i.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:M8(c.node(-1).contentMatchAt(c.indexAfter(-1)));let y=m&&g?[{type:g,attrs:f}]:void 0,b=yi(e.doc,e.mapping.map(c.pos),1,y);if(!y&&!b&&yi(e.doc,e.mapping.map(c.pos),1,g?[{type:g}]:void 0)&&(b=!0,y=g?[{type:g,attrs:f}]:void 0),r){if(b&&(a instanceof qe&&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&&pN(n,i.extensionManager.splittableMarks),e.scrollIntoView()}return b},n6=(t,e={})=>({tr:n,state:r,dispatch:i,editor:a})=>{var o;const c=bn(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(i){let N=ge.empty;const C=u.index(-1)?1:u.index(-2)?2:3;for(let P=u.depth-C;P>=u.depth-3;P-=1)N=ge.from(u.node(P).copy(N));const E=u.indexAfter(-1){if(D>-1)return!1;P.isTextblock&&P.content.size===0&&(D=L+1)}),D>-1&&n.setSelection(qe.near(n.doc.resolve(D))),n.scrollIntoView()}return!0}const y=h.pos===u.end()?m.contentMatchAt(0).defaultType:null,b={...Xu(g,m.type.name,m.attrs),...e},j={...Xu(g,u.node().type.name,u.node().attrs),...e};n.delete(u.pos,h.pos);const w=y?[{type:c,attrs:b},{type:y,attrs:j}]:[{type:c,attrs:b}];if(!yi(n.doc,u.pos,2))return!1;if(i){const{selection:N,storedMarks:C}=r,{splittableMarks:E}=a.extensionManager,M=C||N.$to.parentOffset&&N.$from.marks();if(n.split(u.pos,2,w).scrollIntoView(),!M||!i)return!0;const I=M.filter(O=>E.includes(O.type.name));n.ensureMarks(I)}return!0},Xm=(t,e)=>{const n=Tf(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 i=t.doc.nodeAt(r);return n.node.type===(i==null?void 0:i.type)&&Sa(t.doc,n.pos)&&t.join(n.pos),!0},Zm=(t,e)=>{const n=Tf(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 i=t.doc.nodeAt(r);return n.node.type===(i==null?void 0:i.type)&&Sa(t.doc,r)&&t.join(r),!0},r6=(t,e,n,r={})=>({editor:i,tr:a,state:o,dispatch:c,chain:u,commands:h,can:f})=>{const{extensions:m,splittableMarks:g}=i.extensionManager,y=bn(t,o.schema),b=bn(e,o.schema),{selection:j,storedMarks:w}=o,{$from:N,$to:C}=j,E=N.blockRange(C),M=w||j.$to.parentOffset&&j.$from.marks();if(!E)return!1;const I=Tf(O=>fN(O.type.name,m))(j);if(E.depth>=1&&I&&E.depth-I.depth<=1){if(I.node.type===y)return h.liftListItem(b);if(fN(I.node.type.name,m)&&y.validContent(I.node.content)&&c)return u().command(()=>(a.setNodeMarkup(I.pos,y),!0)).command(()=>Xm(a,y)).command(()=>Zm(a,y)).run()}return!n||!M||!c?u().command(()=>f().wrapInList(y,r)?!0:h.clearNodes()).wrapInList(y,r).command(()=>Xm(a,y)).command(()=>Zm(a,y)).run():u().command(()=>{const O=f().wrapInList(y,r),D=M.filter(P=>g.includes(P.type.name));return a.ensureMarks(D),O?!0:h.clearNodes()}).wrapInList(y,r).command(()=>Xm(a,y)).command(()=>Zm(a,y)).run()},s6=(t,e={},n={})=>({state:r,commands:i})=>{const{extendEmptyMarkRange:a=!1}=n,o=ji(t,r.schema);return Xg(r,o,e)?i.unsetMark(o,{extendEmptyMarkRange:a}):i.setMark(o,e)},i6=(t,e,n={})=>({state:r,commands:i})=>{const a=bn(t,r.schema),o=bn(e,r.schema),c=ya(r,a,n);let u;return r.selection.$anchor.sameParent(r.selection.$head)&&(u=r.selection.$anchor.parent.attrs),c?i.setNode(o,u):i.setNode(a,{...u,...n})},a6=(t,e={})=>({state:n,commands:r})=>{const i=bn(t,n.schema);return ya(n,i,e)?r.lift(i):r.wrapIn(i,e)},o6=()=>({state:t,dispatch:e})=>{const n=t.plugins;for(let r=0;r=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},l6=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,{empty:r,ranges:i}=n;return r||e&&i.forEach(a=>{t.removeMark(a.$from.pos,a.$to.pos)}),!0},c6=(t,e={})=>({tr:n,state:r,dispatch:i})=>{var a;const{extendEmptyMarkRange:o=!1}=e,{selection:c}=n,u=ji(t,r.schema),{$from:h,empty:f,ranges:m}=c;if(!i)return!0;if(f&&o){let{from:g,to:y}=c;const b=(a=h.marks().find(w=>w.type===u))==null?void 0:a.attrs,j=b0(h,u,b);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},d6=t=>({tr:e,state:n,dispatch:r})=>{const{selection:i}=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=i.from,o=i.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},u6=(t,e={})=>({tr:n,state:r,dispatch:i})=>{let a=null,o=null;const c=Ef(typeof t=="string"?t:t.name,r.schema);if(!c)return!1;c==="node"&&(a=bn(t,r.schema)),c==="mark"&&(o=ji(t,r.schema));let u=!1;return n.selection.ranges.forEach(h=>{const f=h.$from.pos,m=h.$to.pos;let g,y,b,j;n.selection.empty?r.doc.nodesBetween(f,m,(w,N)=>{a&&a===w.type&&(u=!0,b=Math.max(N,f),j=Math.min(N+w.nodeSize,m),g=N,y=w)}):r.doc.nodesBetween(f,m,(w,N)=>{N=f&&N<=m&&(a&&a===w.type&&(u=!0,i&&n.setNodeMarkup(N,void 0,{...w.attrs,...e})),o&&w.marks.length&&w.marks.forEach(C=>{if(o===C.type&&(u=!0,i)){const E=Math.max(N,f),M=Math.min(N+w.nodeSize,m);n.addMark(E,M,o.create({...C.attrs,...e}))}}))}),y&&(g!==void 0&&i&&n.setNodeMarkup(g,void 0,{...y.attrs,...e}),o&&y.marks.length&&y.marks.forEach(w=>{o===w.type&&i&&n.addMark(b,j,o.create({...w.attrs,...e}))}))}),u},h6=(t,e={})=>({state:n,dispatch:r})=>{const i=bn(t,n.schema);return FO(i,e)(n,r)},f6=(t,e={})=>({state:n,dispatch:r})=>{const i=bn(t,n.schema);return BO(i,e)(n,r)},p6=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={}}},Af=class{constructor(t){var e;this.find=t.find,this.handler=t.handler,this.undoable=(e=t.undoable)!=null?e:!0}},m6=(t,e)=>{if(v0(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 Ou(t){var e;const{editor:n,from:r,to:i,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=B8(h)+a;return o.forEach(g=>{if(f)return;const y=m6(m,g.find);if(!y)return;const b=u.state.tr,j=Sf({state:u.state,transaction:b}),w={from:r-(y[0].length-a.length),to:i},{commands:N,chain:C,can:E}=new Cf({editor:n,state:j});g.handler({state:j,range:w,match:y,commands:N,chain:C,can:E})===null||!b.steps.length||(g.undoable&&b.setMeta(c,{transform:b,from:r,to:i,text:a}),u.dispatch(b),f=!0)}),f}function g6(t){const{editor:e,rules:n}=t,r=new Bt({state:{init(){return null},apply(i,a,o){const c=i.getMeta(r);if(c)return c;const u=i.getMeta("applyInputRules");return!!u&&setTimeout(()=>{let{text:f}=u;typeof f=="string"?f=f:f=w0(ge.from(f),o.schema);const{from:m}=u,g=m+f.length;Ou({editor:e,from:m,to:g,text:f,rules:n,plugin:r})}),i.selectionSet||i.docChanged?null:a}},props:{handleTextInput(i,a,o,c){return Ou({editor:e,from:a,to:o,text:c,rules:n,plugin:r})},handleDOMEvents:{compositionend:i=>(setTimeout(()=>{const{$cursor:a}=i.state.selection;a&&Ou({editor:e,from:a.pos,to:a.pos,text:"",rules:n,plugin:r})}),!1)},handleKeyDown(i,a){if(a.key!=="Enter")return!1;const{$cursor:o}=i.state.selection;return o?Ou({editor:e,from:o.pos,to:o.pos,text:` +`,rules:n,plugin:r}):!1}},isInputRules:!0});return r}function x6(t){return Object.prototype.toString.call(t).slice(8,-1)}function Du(t){return x6(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function k2(t,e){const n={...t};return Du(t)&&Du(e)&&Object.keys(e).forEach(r=>{Du(e[r])&&Du(t[r])?n[r]=k2(t[r],e[r]):n[r]=e[r]}),n}var k0=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{...jt(We(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...jt(We(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(t={}){const e=this.extend({...this.config,addOptions:()=>k2(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}},Co=class S2 extends k0{constructor(){super(...arguments),this.type="mark"}static create(e={}){const n=typeof e=="function"?e():e;return new S2(n)}static handleExit({editor:e,mark:n}){const{tr:r}=e.state,i=e.state.selection.$from;if(i.pos===i.end()){const o=i.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(" ",i.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 y6(t){return typeof t=="number"}var v6=class{constructor(t){this.find=t.find,this.handler=t.handler}},b6=(t,e,n)=>{if(v0(e))return[...t.matchAll(e)];const r=e(t,n);return r?r.map(i=>{const a=[i.text];return a.index=i.index,a.input=t,a.data=i.data,i.replaceWith&&(i.text.includes(i.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),a.push(i.replaceWith)),a}):[]};function N6(t){const{editor:e,state:n,from:r,to:i,rule:a,pasteEvent:o,dropEvent:c}=t,{commands:u,chain:h,can:f}=new Cf({editor:e,state:n}),m=[];return n.doc.nodesBetween(r,i,(y,b)=>{var j,w,N,C,E;if((w=(j=y.type)==null?void 0:j.spec)!=null&&w.code||!(y.isText||y.isTextblock||y.isInline))return;const M=(E=(C=(N=y.content)==null?void 0:N.size)!=null?C:y.nodeSize)!=null?E:0,I=Math.max(r,b),O=Math.min(i,b+M);if(I>=O)return;const D=y.isText?y.text||"":y.textBetween(I-b,O-b,void 0,"");b6(D,a.find,o).forEach(L=>{if(L.index===void 0)return;const _=I+L.index+1,X=_+L[0].length,ne={from:n.tr.mapping.map(_),to:n.tr.mapping.map(X)},J=a.handler({state:n,range:ne,match:L,commands:u,chain:h,can:f,pasteEvent:o,dropEvent:c});m.push(J)})}),m.every(y=>y!==null)}var Lu=null,w6=t=>{var e;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=n.clipboardData)==null||e.setData("text/html",t),n};function j6(t){const{editor:e,rules:n}=t;let r=null,i=!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:b})=>{const j=f.tr,w=Sf({state:f,transaction:j});if(!(!N6({editor:e,state:w,from:Math.max(m-1,0),to:g.b-1,rule:y,pasteEvent:b,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 Bt({view(m){const g=b=>{var j;r=(j=m.dom.parentElement)!=null&&j.contains(b.target)?m.dom.parentElement:null,r&&(Lu=e)},y=()=>{Lu&&(Lu=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=Lu;y!=null&&y.isEditable&&setTimeout(()=>{const b=y.state.selection;b&&y.commands.deleteRange({from:b.from,to:b.to})},10)}return!1},paste:(m,g)=>{var y;const b=(y=g.clipboardData)==null?void 0:y.getData("text/html");return o=g,i=!!(b!=null&&b.includes("data-pm-slice")),!1}}},appendTransaction:(m,g,y)=>{const b=m[0],j=b.getMeta("uiEvent")==="paste"&&!i,w=b.getMeta("uiEvent")==="drop"&&!a,N=b.getMeta("applyPasteRules"),C=!!N;if(!j&&!w&&!C)return;if(C){let{text:I}=N;typeof I=="string"?I=I:I=w0(ge.from(I),y.schema);const{from:O}=N,D=O+I.length,P=w6(I);return u({rule:f,state:y,from:O,to:{b:D},pasteEvt:P})}const E=g.doc.content.findDiffStart(y.doc.content),M=g.doc.content.findDiffEnd(y.doc.content);if(!(!y6(E)||!M||E===M.b))return u({rule:f,state:y,from:E,to:M,pasteEvt:o})}}))}var If=class{constructor(t,e){this.splittableMarks=[],this.editor=e,this.baseExtensions=t,this.extensions=g2(t),this.schema=O8(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:kc(e.name,this.schema)},r=We(e,"addCommands",n);return r?{...t,...r()}:t},{})}get plugins(){const{editor:t}=this;return $c([...this.extensions].reverse()).flatMap(r=>{const i={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:t,type:kc(r.name,this.schema)},a=[],o=We(r,"addKeyboardShortcuts",i);let c={};if(r.type==="mark"&&We(r,"exitable",i)&&(c.ArrowRight=()=>Co.handleExit({editor:t,mark:r})),o){const g=Object.fromEntries(Object.entries(o()).map(([y,b])=>[y,()=>b({editor:t})]));c={...c,...g}}const u=_L(c);a.push(u);const h=We(r,"addInputRules",i);if(hN(r,t.options.enableInputRules)&&h){const g=h();if(g&&g.length){const y=g6({editor:t,rules:g}),b=Array.isArray(y)?y:[y];a.push(...b)}}const f=We(r,"addPasteRules",i);if(hN(r,t.options.enablePasteRules)&&f){const g=f();if(g&&g.length){const y=j6({editor:t,rules:g});a.push(...y)}}const m=We(r,"addProseMirrorPlugins",i);if(m){const g=m();a.push(...g)}return a})}get attributes(){return m2(this.extensions)}get nodeViews(){const{editor:t}=this,{nodeExtensions:e}=Tl(this.extensions);return Object.fromEntries(e.filter(n=>!!We(n,"addNodeView")).map(n=>{const r=this.attributes.filter(u=>u.type===n.name),i={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:bn(n.name,this.schema)},a=We(n,"addNodeView",i);if(!a)return[];const o=a();if(!o)return[];const c=(u,h,f,m,g)=>{const y=sd(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 $c([...this.extensions].reverse()).reduceRight((r,i)=>{const a={name:i.name,options:i.options,storage:this.editor.extensionStorage[i.name],editor:e,type:kc(i.name,this.schema)},o=We(i,"dispatchTransaction",a);return o?c=>{o.call(a,{transaction:c,next:r})}:r},t)}transformPastedHTML(t){const{editor:e}=this;return $c([...this.extensions]).reduce((r,i)=>{const a={name:i.name,options:i.options,storage:this.editor.extensionStorage[i.name],editor:e,type:kc(i.name,this.schema)},o=We(i,"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=>!!We(n,"addMarkView")).map(n=>{const r=this.attributes.filter(c=>c.type===n.name),i={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:ji(n.name,this.schema)},a=We(n,"addMarkView",i);if(!a)return[];const o=(c,u,h)=>{const f=sd(c,r);return a()({mark:c,view:u,inline:h,editor:t,extension:n,HTMLAttributes:f,updateAttributes:m=>{z6(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:kc(e.name,this.schema)};e.type==="mark"&&((n=jt(We(e,"keepOnSplit",r)))==null||n)&&this.splittableMarks.push(e.name);const i=We(e,"onBeforeCreate",r),a=We(e,"onCreate",r),o=We(e,"onUpdate",r),c=We(e,"onSelectionUpdate",r),u=We(e,"onTransaction",r),h=We(e,"onFocus",r),f=We(e,"onBlur",r),m=We(e,"onDestroy",r);i&&this.editor.on("beforeCreate",i),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)})}};If.resolve=g2;If.sort=$c;If.flatten=N0;var k6={};y0(k6,{ClipboardTextSerializer:()=>E2,Commands:()=>T2,Delete:()=>M2,Drop:()=>A2,Editable:()=>I2,FocusEvents:()=>P2,Keymap:()=>O2,Paste:()=>D2,Tabindex:()=>L2,TextDirection:()=>_2,focusEventsPluginKey:()=>R2});var pn=class C2 extends k0{constructor(){super(...arguments),this.type="extension"}static create(e={}){const n=typeof e=="function"?e():e;return new C2(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}},E2=pn.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new Bt({key:new Qt("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:t}=this,{state:e,schema:n}=t,{doc:r,selection:i}=e,{ranges:a}=i,o=Math.min(...a.map(f=>f.$from.pos)),c=Math.max(...a.map(f=>f.$to.pos)),u=y2(n);return x2(r,{from:o,to:c},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:u})}}})]}}),T2=pn.create({name:"commands",addCommands(){return{...i2}}}),M2=pn.create({name:"delete",onUpdate({transaction:t,appendedTransactions:e}){var n,r,i;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=h2(t.before,[t,...e]);b2(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,(b,j)=>{const w=j+b.nodeSize-2,N=y.oldRange.from<=j&&w<=y.oldRange.to;this.editor.emit("delete",{type:"node",node:b,from:j,to:w,newFrom:f.mapping.map(j),newTo:f.mapping.map(w),deletedRange:y.oldRange,newRange:y.newRange,partial:!N,editor:this.editor,transaction:t,combinedTransform:f})})});const g=f.mapping;f.steps.forEach((y,b)=>{var j,w;if(y instanceof fs){const N=g.slice(b).map(y.from,-1),C=g.slice(b).map(y.to),E=g.invert().map(N,-1),M=g.invert().map(C),I=(j=f.doc.nodeAt(N-1))==null?void 0:j.marks.some(D=>D.eq(y.mark)),O=(w=f.doc.nodeAt(C))==null?void 0:w.marks.some(D=>D.eq(y.mark));this.editor.emit("delete",{type:"mark",mark:y.mark,from:y.from,to:y.to,deletedRange:{from:E,to:M},newRange:{from:N,to:C},partial:!!(O||I),editor:this.editor,transaction:t,combinedTransform:f})}})};(i=(r=(n=this.editor.options.coreExtensionOptions)==null?void 0:n.delete)==null?void 0:r.async)==null||i?setTimeout(a,0):a()}}),A2=pn.create({name:"drop",addProseMirrorPlugins(){return[new Bt({key:new Qt("tiptapDrop"),props:{handleDrop:(t,e,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:r})}}})]}}),I2=pn.create({name:"editable",addProseMirrorPlugins(){return[new Bt({key:new Qt("editable"),props:{editable:()=>this.editor.options.editable}})]}}),R2=new Qt("focusEvents"),P2=pn.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new Bt({key:R2,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}}}})]}}),O2=pn.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,b=m.parent.isTextblock&&g>0?c.doc.resolve(g-1):m,j=b.parent.type.spec.isolating,w=m.pos-m.parentOffset,N=j&&b.parent.childCount===1?w===m.pos:Ze.atStart(h).from===g;return!f||!y.type.isTextblock||y.textContent.length||!N||N&&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()},i={...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 Sh()||d2()?a:i},addProseMirrorPlugins(){return[new Bt({key:new Qt("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),i=t.some(j=>j.getMeta("preventClearDocument"));if(!r||i)return;const{empty:a,from:o,to:c}=e.selection,u=Ze.atStart(e.doc).from,h=Ze.atEnd(e.doc).to;if(a||!(o===u&&c===h)||!Mf(n.doc))return;const g=n.tr,y=Sf({state:n,transaction:g}),{commands:b}=new Cf({editor:this.editor,state:y});if(b.clearNodes(),!!g.steps.length)return g}})]}}),D2=pn.create({name:"paste",addProseMirrorPlugins(){return[new Bt({key:new Qt("tiptapPaste"),props:{handlePaste:(t,e,n)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:n})}}})]}}),L2=pn.create({name:"tabindex",addProseMirrorPlugins(){return[new Bt({key:new Qt("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),_2=pn.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 Bt({key:new Qt("textDirection"),props:{attributes:()=>{const t=this.options.direction;return t?{dir:t}:{}}}})]}}),S6=class Ac{constructor(e,n,r=!1,i=null){this.currentNode=null,this.actualDepth=null,this.isBlock=r,this.resolvedPos=e,this.editor=n,this.currentNode=i}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 can’t 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 Ac(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 Ac(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 Ac(e,this.editor)}get children(){const e=[];return this.node.content.forEach((n,r)=>{const i=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(!i&&!o&&u.depth<=this.depth)return;const h=new Ac(u,this.editor,i,i||o?n:null);i&&(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,i=this.parent;for(;i&&!r;){if(i.node.type.name===e)if(Object.keys(n).length>0){const a=i.node.attrs,o=Object.keys(n);for(let c=0;c{r&&i.length>0||(o.node.type.name===e&&a.every(u=>n[u]===o.node.attrs[u])&&i.push(o),!(r&&i.length>0)&&(i=i.concat(o.querySelectorAll(e,n,r))))}),i}setAttribute(e){const{tr:n}=this.editor.state;n.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(n)}},C6=`.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 E6(t,e,n){const r=document.querySelector("style[data-tiptap-style]");if(r!==null)return r;const i=document.createElement("style");return e&&i.setAttribute("nonce",e),i.setAttribute("data-tiptap-style",""),i.innerHTML=t,document.getElementsByTagName("head")[0].appendChild(i),i}var T6=class extends p6{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:U8,createMappablePosition:K8},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:i,moved:a})=>this.options.onDrop(r,i,a)),this.on("paste",({event:r,slice:i})=>this.options.onPaste(r,i)),this.on("delete",this.options.onDelete);const e=this.createDoc(),n=l2(e,this.options.autofocus);this.editorState=gl.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=E6(C6,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=p2(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(i=>{const a=typeof i=="string"?`${i}$`:i.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?[I2,E2.configure({blockSeparator:(e=(t=this.options.coreExtensionOptions)==null?void 0:t.clipboardTextSerializer)==null?void 0:e.blockSeparator}),T2,P2,O2,L2,A2,D2,M2,_2.configure({direction:this.options.textDirection})].filter(i=>typeof this.options.enableCoreExtensions=="object"?this.options.enableCoreExtensions[i.name]!==!1:!0):[],...this.options.extensions].filter(i=>["extension","node","mark"].includes(i==null?void 0:i.type));this.extensionManager=new If(r,this)}createCommandManager(){this.commandManager=new Cf({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let t;try{t=Qg(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=Qg(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),i=n?this.extensionManager.dispatchTransaction(r):r,a=e.transformPastedHTML,o=this.extensionManager.transformPastedHTML(a);this.editorView=new s2(t,{...e,attributes:{role:"textbox",...e==null?void 0:e.attributes},dispatchTransaction:i,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),i=n.includes(t),a=this.state;if(this.emit("beforeTransaction",{editor:this,transaction:t,nextState:e}),!i)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 v2(this.state,t)}isActive(t,e){const n=typeof t=="string"?t:null,r=typeof t=="string"?e:t;return V8(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return w0(this.state.doc.content,this.schema)}getText(t){const{blockSeparator:e=` + +`,textSerializers:n={}}=t||{};return L8(this.state.doc,{blockSeparator:e,textSerializers:{...y2(this.schema),...n}})}get isEmpty(){return Mf(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 S6(e,this)}get $doc(){return this.$pos(0)}};function Ml(t){return new Af({find:t.find,handler:({state:e,range:n,match:r})=>{const i=jt(t.getAttributes,void 0,r);if(i===!1||i===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(j0(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;fn.from&&a.delete(n.from+u,h);const g=n.from+u+o.length;a.addMark(n.from+u,g,t.type.create(i||{})),a.removeStoredMark(t.type)}},undoable:t.undoable})}function z2(t){return new Af({find:t.find,handler:({state:e,range:n,match:r})=>{const i=jt(t.getAttributes,void 0,r)||{},{tr:a}=e,o=n.from;let c=n.to;const u=t.type.create(i);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(i)).delete(a.mapping.map(o),a.mapping.map(c))}a.scrollIntoView()},undoable:t.undoable})}function Zg(t){return new Af({find:t.find,handler:({state:e,range:n,match:r})=>{const i=e.doc.resolve(n.from),a=jt(t.getAttributes,void 0,r)||{};if(!i.node(-1).canReplaceWith(i.index(-1),i.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 Al(t){return new Af({find:t.find,handler:({state:e,range:n,match:r,chain:i})=>{const a=jt(t.getAttributes,void 0,r)||{},o=e.tr.delete(n.from,n.to),u=o.doc.resolve(n.from).blockRange(),h=u&&e0(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,b=g||m.$to.parentOffset&&m.$from.marks();if(b){const j=b.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";i().updateAttributes(m,a).run()}const f=o.doc.resolve(n.from-1).nodeBefore;f&&f.type===t.type&&Sa(o.doc,n.from-1)&&(!t.joinPredicate||t.joinPredicate(r,f))&&o.join(n.from-1)},undoable:t.undoable})}var M6=t=>"touches"in t,A6=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,i,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),(i=t.options)!=null&&i.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"),i=e.includes("left"),a=e.includes("right");n&&(t.style.top="0"),r&&(t.style.bottom="0"),i&&(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,M6(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:i}=this.calculateNewDimensions(this.activeHandle,t,e),a=this.applyConstraints(r,i,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,i=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?i=this.startHeight+n:u&&(i=this.startHeight-n),(t==="right"||t==="left")&&(r=this.startWidth+(a?e:-e)),(t==="top"||t==="bottom")&&(i=this.startHeight+(c?n:-n)),this.preserveAspectRatio||this.isShiftKeyPressed?this.applyAspectRatio(r,i,t):{width:r,height:i}}applyConstraints(t,e,n){var r,i,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)),(i=this.maxSize)!=null&&i.height&&(f=Math.min(this.maxSize.height,f)),{width:h,height:f}}let c=t,u=e;return cthis.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",i=n==="top"||n==="bottom";return r?{width:t,height:t/this.aspectRatio}:i?{width:e*this.aspectRatio,height:e}:{width:t,height:t/this.aspectRatio}}};function I6(t,e){const{selection:n}=t,{$from:r}=n;if(n instanceof Ke){const a=r.index();return r.parent.canReplaceWith(a,a+1,e)}let i=r.depth;for(;i>=0;){const a=r.index(i);if(r.node(i).contentMatchAt(a).matchType(e))return!0;i-=1}return!1}function R6(t){return t.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}var P6={};y0(P6,{createAtomBlockMarkdownSpec:()=>O6,createBlockMarkdownSpec:()=>D6,createInlineMarkdownSpec:()=>$2,parseAttributes:()=>S0,parseIndentedBlocks:()=>ex,renderNestedMarkdownContent:()=>E0,serializeAttributes:()=>C0});function S0(t){if(!(t!=null&&t.trim()))return{};const e={},n=[],r=t.replace(/["']([^"']*)["']/g,h=>(n.push(h),`__QUOTED_${n.length-1}__`)),i=r.match(/(?:^|\s)\.([a-zA-Z][\w-]*)/g);if(i){const h=i.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 C0(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 O6(t){const{nodeName:e,name:n,parseAttributes:r=S0,serializeAttributes:i=C0,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|$)`),b=f.match(y);if(!b)return;const j=b[1]||"",w=r(j);if(!o.find(C=>!(C in w)))return{type:e,raw:b[0],attributes:w}}},renderMarkdown:f=>{const m=h(f.attrs||{}),g=i(m),y=g?` {${g}}`:"";return`:::${u}${y} :::`}}}function D6(t){const{nodeName:e,name:n,getContent:r,parseAttributes:i=S0,serializeAttributes:a=C0,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 b={...o,...m.attributes};return g.createNode(e,b,y)},markdownTokenizer:{name:e,level:"block",start(m){var g;const y=new RegExp(`^:::${h}`,"m"),b=(g=m.match(y))==null?void 0:g.index;return b!==void 0?b:-1},tokenize(m,g,y){var b;const j=new RegExp(`^:::${h}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),w=m.match(j);if(!w)return;const[N,C=""]=w,E=i(C);let M=1;const I=N.length;let O="";const D=/^:::([\w-]*)(\s.*)?/gm,P=m.slice(I);for(D.lastIndex=0;;){const L=D.exec(P);if(L===null)break;const _=L.index,X=L[1];if(!((b=L[2])!=null&&b.endsWith(":::"))){if(X)M+=1;else if(M-=1,M===0){const ne=P.slice(0,_);O=ne.trim();const J=m.slice(0,I+_+L[0].length);let U=[];if(O)if(c==="block")for(U=y.blockTokens(ne),U.forEach(R=>{R.text&&(!R.tokens||R.tokens.length===0)&&(R.tokens=y.inlineTokens(R.text))});U.length>0;){const R=U[U.length-1];if(R.type==="paragraph"&&(!R.text||R.text.trim()===""))U.pop();else break}else U=y.inlineTokens(O);return{type:e,raw:J,attributes:E,content:O,tokens:U}}}}}},renderMarkdown:(m,g)=>{const y=f(m.attrs||{}),b=a(y),j=b?` {${b}}`:"",w=g.renderChildren(m.content||[],` + +`);return`:::${h}${j} + +${w} + +:::`}}}function L6(t){if(!t.trim())return{};const e={},n=/(\w+)=(?:"([^"]*)"|'([^']*)')/g;let r=n.exec(t);for(;r!==null;){const[,i,a,o]=r;e[i]=a||o,r=n.exec(t)}return e}function _6(t){return Object.entries(t).filter(([,e])=>e!=null).map(([e,n])=>`${e}="${n}"`).join(" ")}function $2(t){const{nodeName:e,name:n,getContent:r,parseAttributes:i=L6,serializeAttributes:a=_6,defaultAttributes:o={},selfClosing:c=!1,allowedAttributes:u}=t,h=n||e,f=g=>{if(!u)return g;const y={};return u.forEach(b=>{const j=typeof b=="string"?b:b.name,w=typeof b=="string"?void 0:b.skipIfDefault;if(j in g){const N=g[j];if(w!==void 0&&N===w)return;y[j]=N}}),y},m=h.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return{parseMarkdown:(g,y)=>{const b={...o,...g.attributes};if(c)return y.createNode(e,b);const j=r?r(g):g.content||"";return j?y.createNode(e,b,[y.createTextNode(j)]):y.createNode(e,b,[])},markdownTokenizer:{name:e,level:"inline",start(g){const y=c?new RegExp(`\\[${m}\\s*[^\\]]*\\]`):new RegExp(`\\[${m}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${m}\\]`),b=g.match(y),j=b==null?void 0:b.index;return j!==void 0?j:-1},tokenize(g,y,b){const j=c?new RegExp(`^\\[${m}\\s*([^\\]]*)\\]`):new RegExp(`^\\[${m}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${m}\\]`),w=g.match(j);if(!w)return;let N="",C="";if(c){const[,M]=w;C=M}else{const[,M,I]=w;C=M,N=I||""}const E=i(C.trim());return{type:e,raw:w[0],content:N.trim(),attributes:E}}},renderMarkdown:g=>{let y="";r?y=r(g):g.content&&g.content.length>0&&(y=g.content.filter(N=>N.type==="text").map(N=>N.text).join(""));const b=f(g.attrs||{}),j=a(b),w=j?` ${j}`:"";return c?`[${h}${w}]`:`[${h}${w}]${y}[/${h}]`}}}function ex(t,e,n){var r,i,a,o;const c=t.split(` +`),u=[];let h="",f=0;const m=e.baseIndentSize||2;for(;f0)break;if(g.trim()===""){f+=1,h=`${h}${g} +`;continue}else return}const b=e.extractItemData(y),{indentLevel:j,mainContent:w}=b;h=`${h}${g} +`;const N=[w];for(f+=1;f_.trim()!=="");if(D===-1)break;if((((i=(r=c[f+1+D].match(/^(\s*)/))==null?void 0:r[1])==null?void 0:i.length)||0)>j){N.push(I),h=`${h}${I} +`,f+=1;continue}else break}if((((o=(a=I.match(/^(\s*)/))==null?void 0:a[1])==null?void 0:o.length)||0)>j)N.push(I),h=`${h}${I} +`,f+=1;else break}let C;const E=N.slice(1);if(E.length>0){const I=E.map(O=>O.slice(j+m)).join(` +`);I.trim()&&(e.customNestedParser?C=e.customNestedParser(I):C=n.blockTokens(I))}const M=e.createToken(b,C);u.push(M)}if(u.length!==0)return{items:u,raw:h}}function E0(t,e,n,r){if(!t||!Array.isArray(t.content))return"";const i=typeof n=="function"?n(r):n,[a,...o]=t.content,c=e.renderChildren([a]),u=[`${i}${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 z6(t,e,n={}){const{state:r}=e,{doc:i,tr:a}=r,o=t;i.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 Nn=class F2 extends k0{constructor(){super(...arguments),this.type="node"}static create(e={}){const n=typeof e=="function"?e():e;return new F2(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}};function vo(t){return new v6({find:t.find,handler:({state:e,range:n,match:r,pasteEvent:i})=>{const a=jt(t.getAttributes,void 0,r,i);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(j0(n.from,n.to,e.doc).filter(b=>b.mark.type.excluded.find(w=>w===t.type&&w!==b.mark.type)).filter(b=>b.to>m).length)return null;gn.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:$6,getOwnPropertySymbols:F6}=Object,{hasOwnProperty:B6}=Object.prototype;function eg(t,e){return function(r,i,a){return t(r,i,a)&&e(r,i,a)}}function _u(t){return function(n,r,i){if(!n||!r||typeof n!="object"||typeof r!="object")return t(n,r,i);const{cache:a}=i,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,i);return a.delete(n),a.delete(r),u}}function V6(t){return t!=null?t[Symbol.toStringTag]:void 0}function mN(t){return $6(t).concat(F6(t))}const H6=Object.hasOwn||((t,e)=>B6.call(t,e));function Eo(t,e){return t===e||!t&&!e&&t!==t&&e!==e}const W6="__v",U6="__o",K6="_owner",{getOwnPropertyDescriptor:gN,keys:xN}=Object;function q6(t,e){return t.byteLength===e.byteLength&&Ch(new Uint8Array(t),new Uint8Array(e))}function G6(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 J6(t,e){return t.byteLength===e.byteLength&&Ch(new Uint8Array(t.buffer,t.byteOffset,t.byteLength),new Uint8Array(e.buffer,e.byteOffset,e.byteLength))}function Y6(t,e){return Eo(t.getTime(),e.getTime())}function Q6(t,e){return t.name===e.name&&t.message===e.message&&t.cause===e.cause&&t.stack===e.stack}function X6(t,e){return t===e}function yN(t,e,n){const r=t.size;if(r!==e.size)return!1;if(!r)return!0;const i=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(i[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=i[m]=!0;break}m++}if(!f)return!1;u++}return!0}const Z6=Eo;function e_(t,e,n){const r=xN(t);let i=r.length;if(xN(e).length!==i)return!1;for(;i-- >0;)if(!B2(t,e,n,r[i]))return!1;return!0}function Sc(t,e,n){const r=mN(t);let i=r.length;if(mN(e).length!==i)return!1;let a,o,c;for(;i-- >0;)if(a=r[i],!B2(t,e,n,a)||(o=gN(t,a),c=gN(e,a),(o||c)&&(!o||!c||o.configurable!==c.configurable||o.enumerable!==c.enumerable||o.writable!==c.writable)))return!1;return!0}function t_(t,e){return Eo(t.valueOf(),e.valueOf())}function n_(t,e){return t.source===e.source&&t.flags===e.flags}function vN(t,e,n){const r=t.size;if(r!==e.size)return!1;if(!r)return!0;const i=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(!i[f]&&n.equals(o.value,c.value,o.value,c.value,t,e,n)){h=i[f]=!0;break}f++}if(!h)return!1}return!0}function Ch(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 r_(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 B2(t,e,n,r){return(r===K6||r===U6||r===W6)&&(t.$$typeof||e.$$typeof)?!0:H6(e,r)&&n.equals(t[r],e[r],r,r,t,e,n)}const s_="[object ArrayBuffer]",i_="[object Arguments]",a_="[object Boolean]",o_="[object DataView]",l_="[object Date]",c_="[object Error]",d_="[object Map]",u_="[object Number]",h_="[object Object]",f_="[object RegExp]",p_="[object Set]",m_="[object String]",g_={"[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},x_="[object URL]",y_=Object.prototype.toString;function v_({areArrayBuffersEqual:t,areArraysEqual:e,areDataViewsEqual:n,areDatesEqual:r,areErrorsEqual:i,areFunctionsEqual:a,areMapsEqual:o,areNumbersEqual:c,areObjectsEqual:u,arePrimitiveWrappersEqual:h,areRegExpsEqual:f,areSetsEqual:m,areTypedArraysEqual:g,areUrlsEqual:y,unknownTagComparators:b}){return function(w,N,C){if(w===N)return!0;if(w==null||N==null)return!1;const E=typeof w;if(E!==typeof N)return!1;if(E!=="object")return E==="number"?c(w,N,C):E==="function"?a(w,N,C):!1;const M=w.constructor;if(M!==N.constructor)return!1;if(M===Object)return u(w,N,C);if(Array.isArray(w))return e(w,N,C);if(M===Date)return r(w,N,C);if(M===RegExp)return f(w,N,C);if(M===Map)return o(w,N,C);if(M===Set)return m(w,N,C);const I=y_.call(w);if(I===l_)return r(w,N,C);if(I===f_)return f(w,N,C);if(I===d_)return o(w,N,C);if(I===p_)return m(w,N,C);if(I===h_)return typeof w.then!="function"&&typeof N.then!="function"&&u(w,N,C);if(I===x_)return y(w,N,C);if(I===c_)return i(w,N,C);if(I===i_)return u(w,N,C);if(g_[I])return g(w,N,C);if(I===s_)return t(w,N,C);if(I===o_)return n(w,N,C);if(I===a_||I===u_||I===m_)return h(w,N,C);if(b){let O=b[I];if(!O){const D=V6(w);D&&(O=b[D])}if(O)return O(w,N,C)}return!1}}function b_({circular:t,createCustomConfig:e,strict:n}){let r={areArrayBuffersEqual:q6,areArraysEqual:n?Sc:G6,areDataViewsEqual:J6,areDatesEqual:Y6,areErrorsEqual:Q6,areFunctionsEqual:X6,areMapsEqual:n?eg(yN,Sc):yN,areNumbersEqual:Z6,areObjectsEqual:n?Sc:e_,arePrimitiveWrappersEqual:t_,areRegExpsEqual:n_,areSetsEqual:n?eg(vN,Sc):vN,areTypedArraysEqual:n?eg(Ch,Sc):Ch,areUrlsEqual:r_,unknownTagComparators:void 0};if(e&&(r=Object.assign({},r,e(r))),t){const i=_u(r.areArraysEqual),a=_u(r.areMapsEqual),o=_u(r.areObjectsEqual),c=_u(r.areSetsEqual);r=Object.assign({},r,{areArraysEqual:i,areMapsEqual:a,areObjectsEqual:o,areSetsEqual:c})}return r}function N_(t){return function(e,n,r,i,a,o,c){return t(e,n,c)}}function w_({circular:t,comparator:e,createState:n,equals:r,strict:i}){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:i})};if(t)return function(c,u){return e(c,u,{cache:new WeakMap,equals:r,meta:void 0,strict:i})};const a={cache:void 0,equals:r,meta:void 0,strict:i};return function(c,u){return e(c,u,a)}}const j_=Ea();Ea({strict:!0});Ea({circular:!0});Ea({circular:!0,strict:!0});Ea({createInternalComparator:()=>Eo});Ea({strict:!0,createInternalComparator:()=>Eo});Ea({circular:!0,createInternalComparator:()=>Eo});Ea({circular:!0,createInternalComparator:()=>Eo,strict:!0});function Ea(t={}){const{circular:e=!1,createInternalComparator:n,createState:r,strict:i=!1}=t,a=b_(t),o=v_(a),c=n?n(o):N_(o);return w_({circular:e,comparator:o,createState:r,equals:c,strict:i})}var tg={exports:{}},ng={};/** + * @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 bN;function k_(){if(bN)return ng;bN=1;var t=cd(),e=Ak();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,i=e.useSyncExternalStore,a=t.useRef,o=t.useEffect,c=t.useMemo,u=t.useDebugValue;return ng.useSyncExternalStoreWithSelector=function(h,f,m,g,y){var b=a(null);if(b.current===null){var j={hasValue:!1,value:null};b.current=j}else j=b.current;b=c(function(){function N(O){if(!C){if(C=!0,E=O,O=g(O),y!==void 0&&j.hasValue){var D=j.value;if(y(D,O))return M=D}return M=O}if(D=M,r(E,O))return D;var P=g(O);return y!==void 0&&y(D,P)?(E=O,D):(E=O,M=P)}var C=!1,E,M,I=m===void 0?null:m;return[function(){return N(f())},I===null?void 0:function(){return N(I())}]},[f,m,g,y]);var w=i(h,b[0],b[1]);return o(function(){j.hasValue=!0,j.value=w},[w]),u(w),w},ng}var NN;function S_(){return NN||(NN=1,tg.exports=k_()),tg.exports}var C_=S_(),E_=(...t)=>e=>{t.forEach(n=>{typeof n=="function"?n(e):n&&(n.current=e)})},T_=({contentComponent:t})=>{const e=Ik.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getServerSnapshot);return s.jsx(s.Fragment,{children:Object.values(e)})};function M_(){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]:Tw.createPortal(r.reactElement,r.element,n)},t.forEach(i=>i())},removeRenderer(n){const r={...e};delete r[n],e=r,t.forEach(i=>i())}}}var A_=class extends ur.Component{constructor(t){var e;super(t),this.editorContentRef=ur.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=M_(),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 s.jsxs(s.Fragment,{children:[s.jsx("div",{ref:E_(e,this.editorContentRef),...n}),(t==null?void 0:t.contentComponent)&&s.jsx(T_,{contentComponent:t.contentComponent})]})}},I_=v.forwardRef((t,e)=>{const n=ur.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[t.editor]);return ur.createElement(A_,{key:n,innerRef:e,...t})}),V2=ur.memo(I_),R_=typeof window<"u"?v.useLayoutEffect:v.useEffect,P_=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 O_(t){var e;const[n]=v.useState(()=>new P_(t.editor)),r=C_.useSyncExternalStoreWithSelector(n.subscribe,n.getSnapshot,n.getServerSnapshot,t.selector,(e=t.equalityFn)!=null?e:j_);return R_(()=>n.watch(t.editor),[t.editor,n]),v.useDebugValue(r),r}var D_=!1,tx=typeof window>"u",L_=tx||!!(typeof window<"u"&&window.next),__=class H2{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?tx||L_?null:this.createEditor():(this.options.current.immediatelyRender,this.options.current.immediatelyRender?this.createEditor():null)}createEditor(){const e={...this.options.current,onBeforeCreate:(...r)=>{var i,a;return(a=(i=this.options.current).onBeforeCreate)==null?void 0:a.call(i,...r)},onBlur:(...r)=>{var i,a;return(a=(i=this.options.current).onBlur)==null?void 0:a.call(i,...r)},onCreate:(...r)=>{var i,a;return(a=(i=this.options.current).onCreate)==null?void 0:a.call(i,...r)},onDestroy:(...r)=>{var i,a;return(a=(i=this.options.current).onDestroy)==null?void 0:a.call(i,...r)},onFocus:(...r)=>{var i,a;return(a=(i=this.options.current).onFocus)==null?void 0:a.call(i,...r)},onSelectionUpdate:(...r)=>{var i,a;return(a=(i=this.options.current).onSelectionUpdate)==null?void 0:a.call(i,...r)},onTransaction:(...r)=>{var i,a;return(a=(i=this.options.current).onTransaction)==null?void 0:a.call(i,...r)},onUpdate:(...r)=>{var i,a;return(a=(i=this.options.current).onUpdate)==null?void 0:a.call(i,...r)},onContentError:(...r)=>{var i,a;return(a=(i=this.options.current).onContentError)==null?void 0:a.call(i,...r)},onDrop:(...r)=>{var i,a;return(a=(i=this.options.current).onDrop)==null?void 0:a.call(i,...r)},onPaste:(...r)=>{var i,a;return(a=(i=this.options.current).onPaste)==null?void 0:a.call(i,...r)},onDelete:(...r)=>{var i,a;return(a=(i=this.options.current).onDelete)==null?void 0:a.call(i,...r)}};return new T6(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((i,a)=>{var o;return i===((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?H2.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,i)=>r===e[i]))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 z_(t={},e=[]){const n=v.useRef(t);n.current=t;const[r]=v.useState(()=>new __(n)),i=Ik.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return v.useDebugValue(i),v.useEffect(r.onRender(e)),O_({editor:i,selector:({transactionNumber:a})=>t.shouldRerenderOnTransaction===!1||t.shouldRerenderOnTransaction===void 0?null:t.immediatelyRender&&a===0?0:a+1}),i}var W2=v.createContext({editor:null});W2.Consumer;var $_=v.createContext({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),F_=()=>v.useContext($_);ur.forwardRef((t,e)=>{const{onDragStart:n}=F_(),r=t.as||"div";return s.jsx(r,{...t,ref:e,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...t.style}})});ur.createContext({markViewContentRef:()=>{}});var T0=v.createContext({get editor(){throw new Error("useTiptap must be used within a provider")}});T0.displayName="TiptapContext";var B_=()=>v.useContext(T0);function U2({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 i=v.useMemo(()=>({editor:r}),[r]),a=v.useMemo(()=>({editor:r}),[r]);return s.jsx(W2.Provider,{value:a,children:s.jsx(T0.Provider,{value:i,children:n})})}U2.displayName="Tiptap";function K2({...t}){const{editor:e}=B_();return s.jsx(V2,{editor:e,...t})}K2.displayName="Tiptap.Content";Object.assign(U2,{Content:K2});var Eh=(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]},V_=/^\s*>\s$/,H_=Nn.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return Eh("blockquote",{...kt(this.options.HTMLAttributes,t),children:Eh("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(i=>{const c=e.renderChildren([i]).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[Al({find:V_,type:this.type})]}}),W_=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,U_=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,K_=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,q_=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,G_=Co.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 Eh("strong",{...kt(this.options.HTMLAttributes,t),children:Eh("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[Ml({find:W_,type:this.type}),Ml({find:K_,type:this.type})]},addPasteRules(){return[vo({find:U_,type:this.type}),vo({find:q_,type:this.type})]}}),J_=/(^|[^`])`([^`]+)`(?!`)$/,Y_=/(^|[^`])`([^`]+)`(?!`)/g,Q_=Co.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",kt(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[Ml({find:J_,type:this.type})]},addPasteRules(){return[vo({find:Y_,type:this.type})]}}),rg=4,X_=/^```([a-z]+)?[\s\n]$/,Z_=/^~~~([a-z]+)?[\s\n]$/,e7=Nn.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:rg,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",kt(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 i=((n=t.attrs)==null?void 0:n.language)||"";return t.content?r=[`\`\`\`${i}`,e.renderChildren(t.content),"```"].join(` +`):r=`\`\`\`${i} + +\`\`\``,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:rg,{state:r}=t,{selection:i}=r,{$from:a,empty:o}=i;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}=i,y=r.doc.textBetween(h,f,` +`,` +`).split(` +`).map(b=>c+b).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:rg,{state:r}=t,{selection:i}=r,{$from:a,empty:o}=i;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 b=0,j=0;const w=h-f;for(let O=0;O=w){b=O;break}j+=y[O].length+1}const C=((u=y[b].match(/^ */))==null?void 0:u[0])||"",E=Math.min(C.length,n);if(E===0)return!0;let M=f;for(let O=0;O{const{from:u,to:h}=i,g=r.doc.textBetween(u,h,` +`,` +`).split(` +`).map(y=>{var b;const j=((b=y.match(/^ */))==null?void 0:b[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:i}=n;if(!i||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:i,empty:a}=n;if(!a||i.parent.type!==this.type||!(i.parentOffset===i.parent.nodeSize-2))return!1;const c=i.after();return c===void 0?!1:r.nodeAt(c)?t.commands.command(({tr:h})=>(h.setSelection(Ze.near(r.resolve(c))),!0)):t.commands.exitCode()}}},addInputRules(){return[Zg({find:X_,type:this.type,getAttributes:t=>({language:t[1]})}),Zg({find:Z_,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new Bt({key:new Qt("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"),i=r?JSON.parse(r):void 0,a=i==null?void 0:i.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(qe.near(o.doc.resolve(Math.max(0,o.selection.from-2)))),o.setMeta("paste",!0),t.dispatch(o),!0}}})]}}),t7=Nn.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,` + +`):""}),n7=Nn.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",kt(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:i,storedMarks:a}=n;if(i.$from.parent.type.spec.isolating)return!1;const{keepMarks:o}=this.options,{splittableMarks:c}=r.extensionManager,u=a||i.$to.parentOffset&&i.$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()}}}),r7=Nn.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]}`,kt(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,i="#".repeat(r);return t.content?`${i} ${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=>Zg({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}}),s7=Nn.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",kt(this.options.HTMLAttributes,t)]},markdownTokenName:"hr",parseMarkdown:(t,e)=>e.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{if(!I6(e,e.schema.nodes[this.name]))return!1;const{selection:n}=e,{$to:r}=n,i=t();return N2(n)?i.insertContentAt(r.pos,{type:this.name}):i.insertContent({type:this.name}),i.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(qe.create(o.doc,u.pos+1)):u.nodeAfter.isBlock?o.setSelection(Ke.create(o.doc,u.pos)):o.setSelection(qe.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(qe.create(o.doc,h+1)))}o.scrollIntoView()}return!0}).run()}}},addInputRules(){return[z2({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),i7=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,a7=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,o7=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,l7=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,c7=Co.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",kt(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[Ml({find:i7,type:this.type}),Ml({find:o7,type:this.type})]},addPasteRules(){return[vo({find:a7,type:this.type}),vo({find:l7,type:this.type})]}});const d7="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",u7="ελ1υ2бг1ел3дети4ею2католик6ом3мкд2он1сква6онлайн5рг3рус2ф2сайт3рб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همراه5پاکستان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",nx="numeric",rx="ascii",sx="alpha",Fc="asciinumeric",Ic="alphanumeric",ix="domain",q2="emoji",h7="scheme",f7="slashscheme",sg="whitespace";function p7(t,e){return t in e||(e[t]=[]),e[t]}function ro(t,e,n){e[nx]&&(e[Fc]=!0,e[Ic]=!0),e[rx]&&(e[Fc]=!0,e[sx]=!0),e[Fc]&&(e[Ic]=!0),e[sx]&&(e[Ic]=!0),e[Ic]&&(e[ix]=!0),e[q2]&&(e[ix]=!0);for(const r in e){const i=p7(r,n);i.indexOf(t)<0&&i.push(t)}}function m7(t,e){const n={};for(const r in e)e[r].indexOf(t)>=0&&(n[r]=!0);return n}function jr(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}jr.groups={};jr.prototype={accepts(){return!!this.t},go(t){const e=this,n=e.j[t];if(n)return n;for(let r=0;rt.ta(e,n,r,i),cn=(t,e,n,r,i)=>t.tr(e,n,r,i),wN=(t,e,n,r,i)=>t.ts(e,n,r,i),Se=(t,e,n,r,i)=>t.tt(e,n,r,i),hi="WORD",ax="UWORD",G2="ASCIINUMERICAL",J2="ALPHANUMERICAL",id="LOCALHOST",ox="TLD",lx="UTLD",Zu="SCHEME",dl="SLASH_SCHEME",M0="NUM",cx="WS",A0="NL",Bc="OPENBRACE",Vc="CLOSEBRACE",Th="OPENBRACKET",Mh="CLOSEBRACKET",Ah="OPENPAREN",Ih="CLOSEPAREN",Rh="OPENANGLEBRACKET",Ph="CLOSEANGLEBRACKET",Oh="FULLWIDTHLEFTPAREN",Dh="FULLWIDTHRIGHTPAREN",Lh="LEFTCORNERBRACKET",_h="RIGHTCORNERBRACKET",zh="LEFTWHITECORNERBRACKET",$h="RIGHTWHITECORNERBRACKET",Fh="FULLWIDTHLESSTHAN",Bh="FULLWIDTHGREATERTHAN",Vh="AMPERSAND",Hh="APOSTROPHE",Wh="ASTERISK",Zi="AT",Uh="BACKSLASH",Kh="BACKTICK",qh="CARET",na="COLON",I0="COMMA",Gh="DOLLAR",Is="DOT",Jh="EQUALS",R0="EXCLAMATION",qr="HYPHEN",Hc="PERCENT",Yh="PIPE",Qh="PLUS",Xh="POUND",Wc="QUERY",P0="QUOTE",Y2="FULLWIDTHMIDDLEDOT",O0="SEMI",Rs="SLASH",Uc="TILDE",Zh="UNDERSCORE",Q2="EMOJI",ef="SYM";var X2=Object.freeze({__proto__:null,ALPHANUMERICAL:J2,AMPERSAND:Vh,APOSTROPHE:Hh,ASCIINUMERICAL:G2,ASTERISK:Wh,AT:Zi,BACKSLASH:Uh,BACKTICK:Kh,CARET:qh,CLOSEANGLEBRACKET:Ph,CLOSEBRACE:Vc,CLOSEBRACKET:Mh,CLOSEPAREN:Ih,COLON:na,COMMA:I0,DOLLAR:Gh,DOT:Is,EMOJI:Q2,EQUALS:Jh,EXCLAMATION:R0,FULLWIDTHGREATERTHAN:Bh,FULLWIDTHLEFTPAREN:Oh,FULLWIDTHLESSTHAN:Fh,FULLWIDTHMIDDLEDOT:Y2,FULLWIDTHRIGHTPAREN:Dh,HYPHEN:qr,LEFTCORNERBRACKET:Lh,LEFTWHITECORNERBRACKET:zh,LOCALHOST:id,NL:A0,NUM:M0,OPENANGLEBRACKET:Rh,OPENBRACE:Bc,OPENBRACKET:Th,OPENPAREN:Ah,PERCENT:Hc,PIPE:Yh,PLUS:Qh,POUND:Xh,QUERY:Wc,QUOTE:P0,RIGHTCORNERBRACKET:_h,RIGHTWHITECORNERBRACKET:$h,SCHEME:Zu,SEMI:O0,SLASH:Rs,SLASH_SCHEME:dl,SYM:ef,TILDE:Uc,TLD:ox,UNDERSCORE:Zh,UTLD:lx,UWORD:ax,WORD:hi,WS:cx});const di=/[a-z]/,Cc=new RegExp("\\p{L}","u"),ig=new RegExp("\\p{Emoji}","u"),ui=/\d/,ag=/\s/,jN="\r",og=` +`,g7="️",x7="‍",lg="";let zu=null,$u=null;function y7(t=[]){const e={};jr.groups=e;const n=new jr;zu==null&&(zu=kN(d7)),$u==null&&($u=kN(u7)),Se(n,"'",Hh),Se(n,"{",Bc),Se(n,"}",Vc),Se(n,"[",Th),Se(n,"]",Mh),Se(n,"(",Ah),Se(n,")",Ih),Se(n,"<",Rh),Se(n,">",Ph),Se(n,"(",Oh),Se(n,")",Dh),Se(n,"「",Lh),Se(n,"」",_h),Se(n,"『",zh),Se(n,"』",$h),Se(n,"<",Fh),Se(n,">",Bh),Se(n,"&",Vh),Se(n,"*",Wh),Se(n,"@",Zi),Se(n,"`",Kh),Se(n,"^",qh),Se(n,":",na),Se(n,",",I0),Se(n,"$",Gh),Se(n,".",Is),Se(n,"=",Jh),Se(n,"!",R0),Se(n,"-",qr),Se(n,"%",Hc),Se(n,"|",Yh),Se(n,"+",Qh),Se(n,"#",Xh),Se(n,"?",Wc),Se(n,'"',P0),Se(n,"/",Rs),Se(n,";",O0),Se(n,"~",Uc),Se(n,"_",Zh),Se(n,"\\",Uh),Se(n,"・",Y2);const r=cn(n,ui,M0,{[nx]:!0});cn(r,ui,r);const i=cn(r,di,G2,{[Fc]:!0}),a=cn(r,Cc,J2,{[Ic]:!0}),o=cn(n,di,hi,{[rx]:!0});cn(o,ui,i),cn(o,di,o),cn(i,ui,i),cn(i,di,i);const c=cn(n,Cc,ax,{[sx]:!0});cn(c,di),cn(c,ui,a),cn(c,Cc,c),cn(a,ui,a),cn(a,di),cn(a,Cc,a);const u=Se(n,og,A0,{[sg]:!0}),h=Se(n,jN,cx,{[sg]:!0}),f=cn(n,ag,cx,{[sg]:!0});Se(n,lg,f),Se(h,og,u),Se(h,lg,f),cn(h,ag,f),Se(f,jN),Se(f,og),cn(f,ag,f),Se(f,lg,f);const m=cn(n,ig,Q2,{[q2]:!0});Se(m,"#"),cn(m,ig,m),Se(m,g7,m);const g=Se(m,x7);Se(g,"#"),cn(g,ig,m);const y=[[di,o],[ui,i]],b=[[di,null],[Cc,c],[ui,a]];for(let j=0;jj[0]>w[0]?1:-1);for(let j=0;j=0?C[ix]=!0:di.test(w)?ui.test(w)?C[Fc]=!0:C[rx]=!0:C[nx]=!0,wN(n,w,w,C)}return wN(n,"localhost",id,{ascii:!0}),n.jd=new jr(ef),{start:n,tokens:Object.assign({groups:e},X2)}}function Z2(t,e){const n=v7(e.replace(/[A-Z]/g,c=>c.toLowerCase())),r=n.length,i=[];let a=0,o=0;for(;o=0&&(m+=n[o].length,g++),h+=n[o].length,a+=n[o].length,o++;a-=m,o-=g,h-=m,i.push({t:f.t,v:e.slice(a-h,a),s:a-h,e:a})}return i}function v7(t){const e=[],n=t.length;let r=0;for(;r56319||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 Gi(t,e,n,r,i){let a;const o=e.length;for(let c=0;c=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 ad={defaultProtocol:"http",events:null,format:SN,formatHref:SN,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function D0(t,e=null){let n=Object.assign({},ad);t&&(n=Object.assign(n,t instanceof D0?t.o:t));const r=n.ignoreTags,i=[];for(let a=0;an?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=ad.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),i=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:i,attributes:o,content:a,eventListeners:m}}};function Rf(t,e){class n extends eC{constructor(i,a){super(i,a),this.t=t}}for(const r in e)n.prototype[r]=e[r];return n.t=t,n}const CN=Rf("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),EN=Rf("text"),b7=Rf("nl"),Fu=Rf("url",{isLink:!0,toHref(t=ad.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==id&&t[1].t===na}}),Kr=t=>new jr(t);function N7({groups:t}){const e=t.domain.concat([Vh,Wh,Zi,Uh,Kh,qh,Gh,Jh,qr,M0,Hc,Yh,Qh,Xh,Rs,ef,Uc,Zh]),n=[Hh,na,I0,Is,R0,Hc,Wc,P0,O0,Rh,Ph,Bc,Vc,Mh,Th,Ah,Ih,Oh,Dh,Lh,_h,zh,$h,Fh,Bh],r=[Vh,Hh,Wh,Uh,Kh,qh,Gh,Jh,qr,Bc,Vc,Hc,Yh,Qh,Xh,Wc,Rs,ef,Uc,Zh],i=Kr(),a=Se(i,Uc);lt(a,r,a),lt(a,t.domain,a);const o=Kr(),c=Kr(),u=Kr();lt(i,t.domain,o),lt(i,t.scheme,c),lt(i,t.slashscheme,u),lt(o,r,a),lt(o,t.domain,o);const h=Se(o,Zi);Se(a,Zi,h),Se(c,Zi,h),Se(u,Zi,h);const f=Se(a,Is);lt(f,r,a),lt(f,t.domain,a);const m=Kr();lt(h,t.domain,m),lt(m,t.domain,m);const g=Se(m,Is);lt(g,t.domain,m);const y=Kr(CN);lt(g,t.tld,y),lt(g,t.utld,y),Se(h,id,y);const b=Se(m,qr);Se(b,qr,b),lt(b,t.domain,m),lt(y,t.domain,m),Se(y,Is,g),Se(y,qr,b);const j=Se(y,na);lt(j,t.numeric,CN);const w=Se(o,qr),N=Se(o,Is);Se(w,qr,w),lt(w,t.domain,o),lt(N,r,a),lt(N,t.domain,o);const C=Kr(Fu);lt(N,t.tld,C),lt(N,t.utld,C),lt(C,t.domain,o),lt(C,r,a),Se(C,Is,N),Se(C,qr,w),Se(C,Zi,h);const E=Se(C,na),M=Kr(Fu);lt(E,t.numeric,M);const I=Kr(Fu),O=Kr();lt(I,e,I),lt(I,n,O),lt(O,e,I),lt(O,n,O),Se(C,Rs,I),Se(M,Rs,I);const D=Se(c,na),P=Se(u,na),L=Se(P,Rs),_=Se(L,Rs);lt(c,t.domain,o),Se(c,Is,N),Se(c,qr,w),lt(u,t.domain,o),Se(u,Is,N),Se(u,qr,w),lt(D,t.domain,I),Se(D,Rs,I),Se(D,Wc,I),lt(_,t.domain,I),lt(_,e,I),Se(_,Rs,I);const X=[[Bc,Vc],[Th,Mh],[Ah,Ih],[Rh,Ph],[Oh,Dh],[Lh,_h],[zh,$h],[Fh,Bh]];for(let ne=0;ne=0&&g++,i++,f++;if(g<0)i-=f,i0&&(a.push(cg(EN,e,o)),o=[]),i-=g,f-=g;const y=m.t,b=n.slice(i-f,i);a.push(cg(y,e,b))}}return o.length>0&&a.push(cg(EN,e,o)),a}function cg(t,e,n){const r=n[0].s,i=n[n.length-1].e,a=e.slice(r,i);return new t(a,n)}const j7=typeof console<"u"&&console&&console.warn||(()=>{}),k7="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",Ut={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function S7(){return jr.groups={},Ut.scanner=null,Ut.parser=null,Ut.tokenQueue=[],Ut.pluginQueue=[],Ut.customSchemes=[],Ut.initialized=!1,Ut}function TN(t,e=!1){if(Ut.initialized&&j7(`linkifyjs: already initialized - will not register custom scheme "${t}" ${k7}`),!/^[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`);Ut.customSchemes.push([t,e])}function C7(){Ut.scanner=y7(Ut.customSchemes);for(let t=0;t{const i=e.some(h=>h.docChanged)&&!n.doc.eq(r.doc),a=e.some(h=>h.getMeta("preventAutolink"));if(!i||a)return;const{tr:o}=r,c=h2(n.doc,[...e]);if(b2(c).forEach(({newRange:h})=>{const f=A8(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(!T7.test(y))return;m=f[0],g=r.doc.textBetween(m.pos,h.to,void 0," ")}if(m&&g){const y=g.split(E7).filter(Boolean);if(y.length<=0)return!1;const b=y[y.length-1],j=m.pos+g.lastIndexOf(b);if(!b)return!1;const w=L0(b).map(N=>N.toObject(t.defaultProtocol));if(!A7(w))return!1;w.filter(N=>N.isLink).map(N=>({...N,from:j+N.start+1,to:j+N.end+1})).filter(N=>r.schema.marks.code?!r.doc.rangeHasMark(N.from,N.to,r.schema.marks.code):!0).filter(N=>t.validate(N.value)).filter(N=>t.shouldAutoLink(N.value)).forEach(N=>{j0(N.from,N.to,r.doc).some(C=>C.mark.type===t.type)||o.addMark(N.from,N.to,t.type.create({href:N.href}))})}}),!!o.steps.length)return o}})}function R7(t){return new Bt({key:new Qt("handleClickLink"),props:{handleClick:(e,n,r)=>{var i,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=v2(e.state,t.type.name),h=(i=o.href)!=null?i:u.href,f=(a=o.target)!=null?a:u.target;h&&(window.open(h,f),c=!0)}return c}}})}function P7(t){return new Bt({key:new Qt("handlePasteLink"),props:{handlePaste:(e,n,r)=>{const{shouldAutoLink:i}=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=tC(u,{defaultProtocol:t.defaultProtocol}).find(f=>f.isLink&&f.value===u);return!u||!h||i!==void 0&&!i(h.value)?!1:t.editor.commands.setMark(t.type,{href:h.href})}}})}function Ya(t,e){const n=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return e&&e.forEach(r=>{const i=typeof r=="string"?r:r.scheme;i&&n.push(i)}),!t||t.replace(M7,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var nC=Co.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"){TN(t);return}TN(t.scheme,t.optionalSlashes)})},onDestroy(){S7()},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)=>!!Ya(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 i=(t.includes("@")?t.split("@").pop():t).split(/[/?#:]/)[0];return!(/^\d{1,3}(\.\d{1,3}){3}$/.test(i)||!/\./.test(i))}}},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=>!!Ya(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=>!!Ya(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",kt(this.options.HTMLAttributes,t),0]:["a",kt(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,i,a;const o=(r=(n=t.attrs)==null?void 0:n.href)!=null?r:"",c=(a=(i=t.attrs)==null?void 0:i.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=>!!Ya(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=>!!Ya(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[vo({find:t=>{const e=[];if(t){const{protocols:n,defaultProtocol:r}=this.options,i=tC(t).filter(a=>a.isLink&&this.options.isAllowedUri(a.value,{defaultValidate:o=>!!Ya(o,n),protocols:n,defaultProtocol:r}));i.length&&i.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(I7({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:i=>!!Ya(i,e),protocols:e,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),t.push(R7({type:this.type,editor:this.editor,openOnClick:this.options.openOnClick==="whenNotEditable"?!0:this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&t.push(P7({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),t}}),O7=nC,D7=Object.defineProperty,L7=(t,e)=>{for(var n in e)D7(t,n,{get:e[n],enumerable:!0})},_7="listItem",MN="textStyle",AN=/^\s*([-+*])\s$/,rC=Nn.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",kt(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(_7,this.editor.getAttributes(MN)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=Al({find:AN,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=Al({find:AN,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(MN),editor:this.editor})),[t]}}),sC=Nn.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",kt(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(i=>i.type==="paragraph"))n=e.parseChildren(t.tokens);else{const i=t.tokens[0];if(i&&i.type==="text"&&i.tokens&&i.tokens.length>0){if(n=[{type:"paragraph",content:e.parseInline(i.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)=>E0(t,e,r=>{var i,a;return r.parentType==="bulletList"?"- ":r.parentType==="orderedList"?`${(((a=(i=r.meta)==null?void 0:i.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)}}}),z7={};L7(z7,{findListItemPos:()=>xd,getNextListDepth:()=>z0,handleBackspace:()=>dx,handleDelete:()=>ux,hasListBefore:()=>iC,hasListItemAfter:()=>$7,hasListItemBefore:()=>aC,listItemHasSubList:()=>oC,nextListIsDeeper:()=>lC,nextListIsHigher:()=>cC});var xd=(t,e)=>{const{$from:n}=e.selection,r=bn(t,e.schema);let i=null,a=n.depth,o=n.pos,c=null;for(;a>0&&c===null;)i=n.node(a),i.type===r?c=a:(a-=1,o-=1);return c===null?null:{$pos:e.doc.resolve(o),depth:c}},z0=(t,e)=>{const n=xd(t,e);if(!n)return!1;const[,r]=F8(e,t,n.$pos.pos+4);return r},iC=(t,e,n)=>{const{$anchor:r}=t.selection,i=Math.max(0,r.pos-2),a=t.doc.resolve(i).node();return!(!a||!n.includes(a.type.name))},aC=(t,e)=>{var n;const{$anchor:r}=e.selection,i=e.doc.resolve(r.pos-2);return!(i.index()===0||((n=i.nodeBefore)==null?void 0:n.type.name)!==t)},oC=(t,e,n)=>{if(!n)return!1;const r=bn(t,e.schema);let i=!1;return n.descendants(a=>{a.type===r&&(i=!0)}),i},dx=(t,e,n)=>{if(t.commands.undoInputRule())return!0;if(t.state.selection.from!==t.state.selection.to)return!1;if(!ya(t.state,e)&&iC(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(!ya(t.state,e)||!W8(t.state))return!1;const r=xd(e,t.state);if(!r)return!1;const a=t.state.doc.resolve(r.$pos.pos-2).node(r.depth),o=oC(e,t.state,a);return aC(e,t.state)&&!o?t.commands.joinItemBackward():t.chain().liftListItem(e).run()},lC=(t,e)=>{const n=z0(t,e),r=xd(t,e);return!r||!n?!1:n>r.depth},cC=(t,e)=>{const n=z0(t,e),r=xd(t,e);return!r||!n?!1:n{if(!ya(t.state,e)||!H8(t.state,e))return!1;const{selection:n}=t.state,{$from:r,$to:i}=n;return!n.empty&&r.sameParent(i)?!1:lC(e,t.state)?t.chain().focus(t.state.selection.from+4).lift(e).joinBackward().run():cC(e,t.state)?t.chain().joinForward().joinBackward().run():t.commands.joinItemForward()},$7=(t,e)=>{var n;const{$anchor:r}=e.selection,i=e.doc.resolve(r.pos-r.parentOffset-2);return!(i.index()===i.parent.childCount-1||((n=i.nodeAfter)==null?void 0:n.type.name)!==t)},dC=pn.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&&ux(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&&ux(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&&dx(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&&dx(t,n,r)&&(e=!0)}),e}}}}),IN=/^(\s*)(\d+)\.\s+(.*)$/,F7=/^\s/;function B7(t){const e=[];let n=0,r=0;for(;ne;)g.push(t[m]),m+=1;if(g.length>0){const y=Math.min(...g.map(j=>j.indent)),b=uC(g,y,n);h.push({type:"list",ordered:!0,start:g[0].number,items:b,raw:g.map(j=>j.raw).join(` +`)})}i.push({type:"list_item",raw:o.raw,tokens:h}),a=m}else a+=1}return i}function V7(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(i=>{if(i.type==="paragraph"||i.type==="list"||i.type==="blockquote"||i.type==="code")r.push(...e.parseChildren([i]));else if(i.type==="text"&&i.tokens){const a=e.parseChildren([i]);r.push({type:"paragraph",content:a})}else{const a=e.parseChildren([i]);a.length>0&&r.push(...a)}}),{type:"listItem",content:r}})}var H7="listItem",RN="textStyle",PN=/^(\d+)\.\s$/,hC=Nn.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",kt(this.options.HTMLAttributes,n),0]:["ol",kt(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?V7(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 i=t.split(` +`),[a,o]=B7(i);if(a.length===0)return;const c=uC(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:i.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(H7,this.editor.getAttributes(RN)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=Al({find:PN,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=Al({find:PN,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(RN)}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1],editor:this.editor})),[t]}}),W7=/^\s*(\[([( |x])?\])\s$/,U7=Nn.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",kt(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 i=`- [${(n=t.attrs)!=null&&n.checked?"x":" "}] `;return E0(t,e,i)},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 i=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 b=n();if(typeof b!="number")return!1;const j=y.doc.nodeAt(b);return y.setNodeMarkup(b,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])=>{i.setAttribute(m,g)}),i.dataset.checked=t.attrs.checked,c.checked=t.attrs.checked,a.append(c,o),i.append(a,u),Object.entries(e).forEach(([m,g])=>{i.setAttribute(m,g)});let f=new Set(Object.keys(e));return{dom:i,contentDOM:u,update:m=>{if(m.type!==this.type)return!1;i.dataset.checked=m.attrs.checked,c.checked=m.attrs.checked,h(m);const g=r.extensionManager.attributes,y=sd(m,g),b=new Set(Object.keys(y)),j=this.options.HTMLAttributes;return f.forEach(w=>{b.has(w)||(w in j?i.setAttribute(w,j[w]):i.removeAttribute(w))}),Object.entries(y).forEach(([w,N])=>{N==null?w in j?i.setAttribute(w,j[w]):i.removeAttribute(w):i.setAttribute(w,N)}),f=b,!0}}}},addInputRules(){return[Al({find:W7,type:this.type,getAttributes:t=>({checked:t[t.length-1]==="x"})})]}}),K7=Nn.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",kt(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=ex(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)},i=ex(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(i)return{type:"taskList",raw:i.raw,items:i.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()}}});pn.create({name:"listKit",addExtensions(){const t=[];return this.options.bulletList!==!1&&t.push(rC.configure(this.options.bulletList)),this.options.listItem!==!1&&t.push(sC.configure(this.options.listItem)),this.options.listKeymap!==!1&&t.push(dC.configure(this.options.listKeymap)),this.options.orderedList!==!1&&t.push(hC.configure(this.options.orderedList)),this.options.taskItem!==!1&&t.push(U7.configure(this.options.taskItem)),this.options.taskList!==!1&&t.push(K7.configure(this.options.taskList)),t}});var ON=" ",q7=" ",G7=Nn.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",kt(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===ON||r[0].text===q7)?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?ON:e.renderChildren(n)},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),J7=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,Y7=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,Q7=Co.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",kt(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[Ml({find:J7,type:this.type})]},addPasteRules(){return[vo({find:Y7,type:this.type})]}}),X7=Nn.create({name:"text",group:"inline",parseMarkdown:t=>({type:"text",text:t.text||""}),renderMarkdown:t=>t.text||""}),Z7=Co.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",kt(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 i=/^(\+\+)([\s\S]+?)(\+\+)/.exec(t);if(!i)return;const a=i[2].trim();return{type:"underline",raw:i[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 ez(t={}){return new Bt({view(e){return new tz(e,t)}})}class tz{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(i=>{let a=o=>{this[i](o)};return e.dom.addEventListener(i,a),{name:i,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,i=this.editorView.dom,a=i.getBoundingClientRect(),o=a.width/i.offsetWidth,c=a.height/i.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 b=y.getBoundingClientRect(),j=m?b.bottom:b.top;m&&g&&(j=(j+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let w=this.width/2*c;r={left:b.left,right:b.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),i=r&&r.type.spec.disableDropCursor,a=typeof i=="function"?i(this.editorView,n,e):i;if(n&&!a){let o=n.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let c=sS(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 un extends Ze{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return un.valid(r)?new un(r):Ze.near(r)}content(){return Ie.empty}eq(e){return e instanceof un&&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 un(e.resolve(n.pos))}getBookmark(){return new $0(this.anchor)}static valid(e){let n=e.parent;if(n.isTextblock||!nz(e)||!rz(e))return!1;let r=n.type.spec.allowGapCursor;if(r!=null)return r;let i=n.contentMatchAt(e.index()).defaultType;return i&&i.isTextblock}static findGapCursorFrom(e,n,r=!1){e:for(;;){if(!r&&un.valid(e))return e;let i=e.pos,a=null;for(let o=e.depth;;o--){let c=e.node(o);if(n>0?e.indexAfter(o)0){a=c.child(n>0?e.indexAfter(o):e.index(o)-1);break}else if(o==0)return null;i+=n;let u=e.doc.resolve(i);if(un.valid(u))return u}for(;;){let o=n>0?a.firstChild:a.lastChild;if(!o){if(a.isAtom&&!a.isText&&!Ke.isSelectable(a)){e=e.doc.resolve(i+a.nodeSize*n),r=!1;continue e}break}a=o,i+=n;let c=e.doc.resolve(i);if(un.valid(c))return c}return null}}}un.prototype.visible=!1;un.findFrom=un.findGapCursorFrom;Ze.jsonID("gapcursor",un);class $0{constructor(e){this.pos=e}map(e){return new $0(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return un.valid(n)?new un(n):Ze.near(n)}}function fC(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function nz(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 i=r.child(n-1);;i=i.lastChild){if(i.childCount==0&&!i.inlineContent||fC(i.type))return!0;if(i.inlineContent)return!1}}return!0}function rz(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 i=r.child(n);;i=i.firstChild){if(i.childCount==0&&!i.inlineContent||fC(i.type))return!0;if(i.inlineContent)return!1}}return!0}function sz(){return new Bt({props:{decorations:lz,createSelectionBetween(t,e,n){return e.pos==n.pos&&un.valid(n)?new un(n):null},handleClick:az,handleKeyDown:iz,handleDOMEvents:{beforeinput:oz}}})}const iz=x0({ArrowLeft:Bu("horiz",-1),ArrowRight:Bu("horiz",1),ArrowUp:Bu("vert",-1),ArrowDown:Bu("vert",1)});function Bu(t,e){const n=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,i,a){let o=r.selection,c=e>0?o.$to:o.$from,u=o.empty;if(o instanceof qe){if(!a.endOfTextblock(n)||c.depth==0)return!1;u=!1,c=r.doc.resolve(e>0?c.after():c.before())}let h=un.findGapCursorFrom(c,e,u);return h?(i&&i(r.tr.setSelection(new un(h))),!0):!1}}function az(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!un.valid(r))return!1;let i=t.posAtCoords({left:n.clientX,top:n.clientY});return i&&i.inside>-1&&Ke.isSelectable(t.state.doc.nodeAt(i.inside))?!1:(t.dispatch(t.state.tr.setSelection(new un(r))),!0)}function oz(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof un))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 i=ge.empty;for(let o=r.length-1;o>=0;o--)i=ge.from(r[o].createAndFill(null,i));let a=t.state.tr.replace(n.pos,n.pos,new Ie(i,0,0));return a.setSelection(qe.near(a.doc.resolve(n.pos+1))),t.dispatch(a),!1}function lz(t){if(!(t.selection instanceof un))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",It.create(t.doc,[En.widget(t.selection.head,e,{key:"gapcursor"})])}var tf=200,Dn=function(){};Dn.prototype.append=function(e){return e.length?(e=Dn.from(e),!this.length&&e||e.length=n?Dn.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};Dn.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};Dn.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)};Dn.prototype.map=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length);var i=[];return this.forEach(function(a,o){return i.push(e(a,o))},n,r),i};Dn.from=function(e){return e instanceof Dn?e:e&&e.length?new pC(e):Dn.empty};var pC=(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(i,a){return i==0&&a==this.length?this:new e(this.values.slice(i,a))},e.prototype.getInner=function(i){return this.values[i]},e.prototype.forEachInner=function(i,a,o,c){for(var u=a;u=o;u--)if(i(this.values[u],c+u)===!1)return!1},e.prototype.leafAppend=function(i){if(this.length+i.length<=tf)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=tf)return new e(i.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(e.prototype,n),e})(Dn);Dn.empty=new pC([]);var cz=(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 rc&&this.right.forEachInner(r,Math.max(i-c,0),Math.min(this.length,a)-c,o+c)===!1)return!1},e.prototype.forEachInvertedInner=function(r,i,a,o){var c=this.left.length;if(i>c&&this.right.forEachInvertedInner(r,i-c,Math.max(a,c)-c,o+c)===!1||a=a?this.right.slice(r-a,i-a):this.left.slice(r,a).append(this.right.slice(0,i-a))},e.prototype.leafAppend=function(r){var i=this.right.leafAppend(r);if(i)return new e(this.left,i)},e.prototype.leafPrepend=function(r){var i=this.left.leafPrepend(r);if(i)return new e(i,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})(Dn);const dz=500;class hs{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 i,a;n&&(i=this.remapping(r,this.items.length),a=i.maps.length);let o=e.tr,c,u,h=[],f=[];return this.items.forEach((m,g)=>{if(!m.step){i||(i=this.remapping(r,g+1),a=i.maps.length),a--,f.push(m);return}if(i){f.push(new Ji(m.map));let y=m.step.map(i.slice(a)),b;y&&o.maybeStep(y).doc&&(b=o.mapping.maps[o.mapping.maps.length-1],h.push(new Ji(b,void 0,void 0,h.length+f.length))),a--,b&&i.appendMap(b,a)}else o.maybeStep(m.step);if(m.selection)return c=i?m.selection.map(i.slice(a)):m.selection,u=new hs(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,i){let a=[],o=this.eventCount,c=this.items,u=!i&&c.length?c.get(c.length-1):null;for(let f=0;fhz&&(c=uz(c,h),o-=h),new hs(c.append(a),o)}remapping(e,n){let r=new Xc;return this.items.forEach((i,a)=>{let o=i.mirrorOffset!=null&&a-i.mirrorOffset>=e?r.maps.length-i.mirrorOffset:void 0;r.appendMap(i.map,o)},e,n),r}addMaps(e){return this.eventCount==0?this:new hs(this.items.append(e.map(n=>new Ji(n))),this.eventCount)}rebased(e,n){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-n),a=e.mapping,o=e.steps.length,c=this.eventCount;this.items.forEach(g=>{g.selection&&c--},i);let u=n;this.items.forEach(g=>{let y=a.getMirror(--u);if(y==null)return;o=Math.min(o,y);let b=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 Ji(b,j,w))}else r.push(new Ji(b))},i);let h=[];for(let g=n;gdz&&(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,i=[],a=0;return this.items.forEach((o,c)=>{if(c>=e)i.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 Ji(h.invert(),u,f),g,y=i.length-1;(g=i.length&&i[y].merge(m))?i[y]=g:i.push(m)}}else o.map&&r--},this.items.length,0),new hs(Dn.from(i.reverse()),a)}}hs.empty=new hs(Dn.empty,0);function uz(t,e){let n;return t.forEach((r,i)=>{if(r.selection&&e--==0)return n=i,!1}),t.slice(n)}let Ji=class mC{constructor(e,n,r,i){this.map=e,this.step=n,this.selection=r,this.mirrorOffset=i}merge(e){if(this.step&&e.step&&!e.selection){let n=e.step.merge(this.step);if(n)return new mC(n.getMap().invert(),n,this.selection)}}};class ea{constructor(e,n,r,i,a){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=i,this.prevComposition=a}}const hz=20;function fz(t,e,n,r){let i=n.getMeta(co),a;if(i)return i.historyState;n.getMeta(gz)&&(t=new ea(t.done,t.undone,null,0,-1));let o=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(o&&o.getMeta(co))return o.getMeta(co).redo?new ea(t.done.addTransform(n,void 0,r,eh(e)),t.undone,DN(n.mapping.maps),t.prevTime,t.prevComposition):new ea(t.done,t.undone.addTransform(n,void 0,r,eh(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||!pz(n,t.prevRanges)),h=o?dg(t.prevRanges,n.mapping):DN(n.mapping.maps);return new ea(t.done.addTransform(n,u?e.selection.getBookmark():void 0,r,eh(e)),hs.empty,h,n.time,c??t.prevComposition)}else return(a=n.getMeta("rebased"))?new ea(t.done.rebased(n,a),t.undone.rebased(n,a),dg(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new ea(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),dg(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function pz(t,e){if(!e)return!1;if(!t.docChanged)return!0;let n=!1;return t.mapping.maps[0].forEach((r,i)=>{for(let a=0;a=e[a]&&(n=!0)}),n}function DN(t){let e=[];for(let n=t.length-1;n>=0&&e.length==0;n--)t[n].forEach((r,i,a,o)=>e.push(a,o));return e}function dg(t,e){if(!t)return null;let n=[];for(let r=0;r{let i=co.getState(n);if(!i||(t?i.undone:i.done).eventCount==0)return!1;if(r){let a=mz(i,n,t);a&&r(e?a.scrollIntoView():a)}return!0}}const xC=gC(!1,!0),yC=gC(!0,!0);pn.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 Bt({key:new Qt("characterCount"),appendTransaction:(e,n,r)=>{if(t)return;const i=this.options.limit;if(i==null||i===0){t=!0;return}const a=this.storage.characters({node:r.doc});if(a>i){const o=a-i,c=0,u=o;console.warn(`[CharacterCount] Initial content exceeded limit of ${i} 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 i=this.storage.characters({node:n.doc}),a=this.storage.characters({node:e.doc});if(a<=r||i>r&&a>r&&a<=i)return!0;if(i>r&&a>r&&a>i||!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 yz=pn.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[ez(this.options)]}});pn.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new Bt({key:new Qt("focus"),props:{decorations:({doc:t,selection:e})=>{const{isEditable:n,isFocused:r}=this.editor,{anchor:i}=e,a=[];if(!n||!r)return It.create(t,[]);let o=0;this.options.mode==="deepest"&&t.descendants((u,h)=>{if(u.isText)return;if(!(i>=h&&i<=h+u.nodeSize-1))return!1;o+=1});let c=0;return t.descendants((u,h)=>{if(u.isText||!(i>=h&&i<=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(En.node(h,h+u.nodeSize,{class:this.options.className}))}),It.create(t,a)}}})]}});var vz=pn.create({name:"gapCursor",addProseMirrorPlugins(){return[sz()]},extendNodeSchema(t){var e;const n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=jt(We(t,"allowGapCursor",n)))!=null?e:null}}}),_N="placeholder";function bz(t){return t.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-]/g,"").replace(/^[0-9-]+/,"").replace(/^-+/,"").toLowerCase()}var Nz=pn.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",dataAttribute:_N,placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){const t=this.options.dataAttribute?`data-${bz(this.options.dataAttribute)}`:`data-${_N}`;return[new Bt({key:new Qt("placeholder"),props:{decorations:({doc:e,selection:n})=>{const r=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:i}=n,a=[];if(!r)return null;const o=this.editor.isEmpty;return e.descendants((c,u)=>{const h=i>=u&&i<=u+c.nodeSize,f=!c.isLeaf&&Mf(c);if((h||!this.options.showOnlyCurrent)&&f){const m=[this.options.emptyNodeClass];o&&m.push(this.options.emptyEditorClass);const g=En.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}),It.create(e,a)}}})]}});pn.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:t,options:e}=this;return[new Bt({key:new Qt("selection"),props:{decorations(n){return n.selection.empty||t.isFocused||!t.isEditable||N2(n.selection)||t.view.dragging?null:It.create(n.doc,[En.inline(n.selection.from,n.selection.to,{class:e.className})])}}})]}});function zN({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||(e==null?void 0:e.type)===t}var wz=pn.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var t;const e=new Qt(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(([,i])=>i).filter(i=>(this.options.notAfter||[]).concat(n).includes(i.name));return[new Bt({key:e,appendTransaction:(i,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:(i,a)=>{const o=a.tr.doc.lastChild;return!zN({node:o,types:r})},apply:(i,a)=>{if(!i.docChanged||i.getMeta("__uniqueIDTransaction"))return a;const o=i.doc.lastChild;return!zN({node:o,types:r})}}})]}}),jz=pn.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>xC(t,e),redo:()=>({state:t,dispatch:e})=>yC(t,e)}},addProseMirrorPlugins(){return[xz(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()}}}),kz=pn.create({name:"starterKit",addExtensions(){var t,e,n,r;const i=[];return this.options.bold!==!1&&i.push(G_.configure(this.options.bold)),this.options.blockquote!==!1&&i.push(H_.configure(this.options.blockquote)),this.options.bulletList!==!1&&i.push(rC.configure(this.options.bulletList)),this.options.code!==!1&&i.push(Q_.configure(this.options.code)),this.options.codeBlock!==!1&&i.push(e7.configure(this.options.codeBlock)),this.options.document!==!1&&i.push(t7.configure(this.options.document)),this.options.dropcursor!==!1&&i.push(yz.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&i.push(vz.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&i.push(n7.configure(this.options.hardBreak)),this.options.heading!==!1&&i.push(r7.configure(this.options.heading)),this.options.undoRedo!==!1&&i.push(jz.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&i.push(s7.configure(this.options.horizontalRule)),this.options.italic!==!1&&i.push(c7.configure(this.options.italic)),this.options.listItem!==!1&&i.push(sC.configure(this.options.listItem)),this.options.listKeymap!==!1&&i.push(dC.configure((t=this.options)==null?void 0:t.listKeymap)),this.options.link!==!1&&i.push(nC.configure((e=this.options)==null?void 0:e.link)),this.options.orderedList!==!1&&i.push(hC.configure(this.options.orderedList)),this.options.paragraph!==!1&&i.push(G7.configure(this.options.paragraph)),this.options.strike!==!1&&i.push(Q7.configure(this.options.strike)),this.options.text!==!1&&i.push(X7.configure(this.options.text)),this.options.underline!==!1&&i.push(Z7.configure((n=this.options)==null?void 0:n.underline)),this.options.trailingNode!==!1&&i.push(wz.configure((r=this.options)==null?void 0:r.trailingNode)),i}}),Sz=kz,Cz=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,Ez=Nn.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",kt(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,i,a,o;const c=(n=(e=t.attrs)==null?void 0:e.src)!=null?n:"",u=(i=(r=t.attrs)==null?void 0:r.alt)!=null?i:"",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:i,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 A6({element:u,editor:c,node:i,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===i.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[z2({find:Cz,type:this.type,getAttributes:t=>{const[,,e,n,r]=t;return{src:n,alt:e,title:r}}})]}}),Tz=Ez;function Mz(t){var e;const{char:n,allowSpaces:r,allowToIncludeChar:i,allowedPrefixes:a,startOfLine:o,$position:c}=t,u=r&&!i,h=R6(n),f=new RegExp(`\\s${h}$`),m=o?"^":"",g=i?"":h,y=u?new RegExp(`${m}${h}.*?(?=\\s${g}|$)`,"gm"):new RegExp(`${m}(?:^)?${h}[^\\s${g}]*`,"gm"),b=((e=c.nodeBefore)==null?void 0:e.isText)&&c.nodeBefore.text;if(!b)return null;const j=c.pos-b.length,w=Array.from(b.matchAll(y)).pop();if(!w||w.input===void 0||w.index===void 0)return null;const N=w.input.slice(Math.max(0,w.index-1),w.index),C=new RegExp(`^[${a==null?void 0:a.join("")}\0]?$`).test(N);if(a!==null&&!C)return null;const E=j+w.index;let M=E+w[0].length;return u&&f.test(b.slice(M-1,M+1))&&(w[0]+=" ",M+=1),E=c.pos?{range:{from:E,to:M},query:w[0].slice(n.length),text:w[0]}:null}var Az=new Qt("suggestion");function Iz({pluginKey:t=Az,editor:e,char:n="@",allowSpaces:r=!1,allowToIncludeChar:i=!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:b=()=>!0,findSuggestionMatch:j=Mz,shouldShow:w}){let N;const C=y==null?void 0:y(),E=()=>{const D=e.state.selection.$anchor.pos,P=e.view.coordsAtPos(D),{top:L,right:_,bottom:X,left:ne}=P;try{return new DOMRect(ne,L,_-ne,X-L)}catch{return null}},M=(D,P)=>P?()=>{const L=t.getState(e.state),_=L==null?void 0:L.decorationId,X=D.dom.querySelector(`[data-decoration-id="${_}"]`);return(X==null?void 0:X.getBoundingClientRect())||null}:E;function I(D,P){var L;try{const X=t.getState(D.state),ne=X!=null&&X.decorationId?D.dom.querySelector(`[data-decoration-id="${X.decorationId}"]`):null,J={editor:e,range:(X==null?void 0:X.range)||{from:0,to:0},query:(X==null?void 0:X.query)||null,text:(X==null?void 0:X.text)||null,items:[],command:U=>m({editor:e,range:(X==null?void 0:X.range)||{from:0,to:0},props:U}),decorationNode:ne,clientRect:M(D,ne)};(L=C==null?void 0:C.onExit)==null||L.call(C,J)}catch{}const _=D.state.tr.setMeta(P,{exit:!0});D.dispatch(_)}const O=new Bt({key:t,view(){return{update:async(D,P)=>{var L,_,X,ne,J,U,R;const F=(L=this.key)==null?void 0:L.getState(P),re=(_=this.key)==null?void 0:_.getState(D.state),z=F.active&&re.active&&F.range.from!==re.range.from,ae=!F.active&&re.active,G=F.active&&!re.active,$=!ae&&!G&&F.query!==re.query,H=ae||z&&$,ce=$||z,W=G||z&&$;if(!H&&!ce&&!W)return;const fe=W&&!H?F:re,Q=D.dom.querySelector(`[data-decoration-id="${fe.decorationId}"]`);N={editor:e,range:fe.range,query:fe.query,text:fe.text,items:[],command:de=>m({editor:e,range:fe.range,props:de}),decorationNode:Q,clientRect:M(D,Q)},H&&((X=C==null?void 0:C.onBeforeStart)==null||X.call(C,N)),ce&&((ne=C==null?void 0:C.onBeforeUpdate)==null||ne.call(C,N)),(ce||H)&&(N.items=await g({editor:e,query:fe.query})),W&&((J=C==null?void 0:C.onExit)==null||J.call(C,N)),ce&&((U=C==null?void 0:C.onUpdate)==null||U.call(C,N)),H&&((R=C==null?void 0:C.onStart)==null||R.call(C,N))},destroy:()=>{var D;N&&((D=C==null?void 0:C.onExit)==null||D.call(C,N))}}},state:{init(){return{active:!1,range:{from:0,to:0},query:null,text:null,composing:!1}},apply(D,P,L,_){const{isEditable:X}=e,{composing:ne}=e.view,{selection:J}=D,{empty:U,from:R}=J,F={...P},re=D.getMeta(t);if(re&&re.exit)return F.active=!1,F.decorationId=null,F.range={from:0,to:0},F.query=null,F.text=null,F;if(F.composing=ne,X&&(U||e.view.composing)){(RP.range.to)&&!ne&&!P.composing&&(F.active=!1);const z=j({char:n,allowSpaces:r,allowToIncludeChar:i,allowedPrefixes:a,startOfLine:o,$position:J.$from}),ae=`id_${Math.floor(Math.random()*4294967295)}`;z&&b({editor:e,state:_,range:z.range,isActive:P.active})&&(!w||w({editor:e,range:z.range,query:z.query,text:z.text,transaction:D}))?(F.active=!0,F.decorationId=P.decorationId?P.decorationId:ae,F.range=z.range,F.query=z.query,F.text=z.text):F.active=!1}else F.active=!1;return F.active||(F.decorationId=null,F.range={from:0,to:0},F.query=null,F.text=null),F}},props:{handleKeyDown(D,P){var L,_,X,ne;const{active:J,range:U}=O.getState(D.state);if(!J)return!1;if(P.key==="Escape"||P.key==="Esc"){const F=O.getState(D.state),re=(L=N==null?void 0:N.decorationNode)!=null?L:null,z=re??(F!=null&&F.decorationId?D.dom.querySelector(`[data-decoration-id="${F.decorationId}"]`):null);if(((_=C==null?void 0:C.onKeyDown)==null?void 0:_.call(C,{view:D,event:P,range:F.range}))||!1)return!0;const G={editor:e,range:F.range,query:F.query,text:F.text,items:[],command:$=>m({editor:e,range:F.range,props:$}),decorationNode:z,clientRect:z?()=>z.getBoundingClientRect()||null:null};return(X=C==null?void 0:C.onExit)==null||X.call(C,G),I(D,t),!0}return((ne=C==null?void 0:C.onKeyDown)==null?void 0:ne.call(C,{view:D,event:P,range:U}))||!1},decorations(D){const{active:P,range:L,decorationId:_,query:X}=O.getState(D);if(!P)return null;const ne=!(X!=null&&X.length),J=[u];return ne&&J.push(f),It.create(D.doc,[En.inline(L.from,L.to,{nodeName:c,class:J.join(" "),"data-decoration-id":_,"data-decoration-content":h})])}}});return O}function Rz({editor:t,overrideSuggestionOptions:e,extensionName:n,char:r="@"}){const i=new Qt;return{editor:t,char:r,pluginKey:i,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 vC(t){return(t.options.suggestions.length?t.options.suggestions:[t.options.suggestion]).map(e=>Rz({editor:t.editor,overrideSuggestionOptions:e,extensionName:t.name,char:e.char}))}function $N(t,e){const n=vC(t),r=n.find(i=>i.char===e);return r||(n.length?n[0]:null)}var Pz=Nn.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,i;return["span",kt(this.HTMLAttributes,t.HTMLAttributes),`${(r=n==null?void 0:n.char)!=null?r:"@"}${(i=e.attrs.label)!=null?i: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=$N(this,t.attrs.mentionSuggestionChar);if(this.options.renderLabel!==void 0)return console.warn("renderLabel is deprecated use renderText and renderHTML instead"),["span",kt({"data-type":this.name},this.options.HTMLAttributes,e),this.options.renderLabel({options:this.options,node:t,suggestion:n})];const r={...this.options};r.HTMLAttributes=kt({"data-type":this.name},this.options.HTMLAttributes,e);const i=this.options.renderHTML({options:r,node:t,suggestion:n});return typeof i=="string"?["span",kt({"data-type":this.name},this.options.HTMLAttributes,e),i]:i},...$2({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[,i,a,o]=r,c=a??o;e[i==="char"?"mentionSuggestionChar":i]=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:$N(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:i,anchor:a}=r;if(!i)return!1;let o=new xi,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 vC(this).map(Iz)}}),Oz=Pz,Dz=Nz;let hx,fx;if(typeof WeakMap<"u"){let t=new WeakMap;hx=e=>t.get(e),fx=(e,n)=>(t.set(e,n),n)}else{const t=[];let n=0;hx=r=>{for(let i=0;i(n==10&&(n=0),t[n++]=r,t[n++]=i)}var fn=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=n){(a||(a=[])).push({type:"overlong_rowspan",pos:f,n:N-E});break}const M=i+E*e;for(let I=0;Ir&&(a+=h.attrs.colspan)}}for(let o=0;o1&&(n=!0)}e==-1?e=a:e!=a&&(e=Math.max(e,a))}return e}function zz(t,e,n){t.problems||(t.problems=[]);const r={};for(let i=0;i0;e--)if(t.node(e).type.spec.tableRole=="row")return t.node(0).resolve(t.before(e+1));return null}function Fz(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 bs(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=bo(e.$head)||Bz(e.$head);if(n)return n;throw new RangeError(`No cell found around position ${e.head}`)}function Bz(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 px(t){return t.parent.type.spec.tableRole=="row"&&!!t.nodeAfter}function Vz(t){return t.node(0).resolve(t.pos+t.nodeAfter.nodeSize)}function F0(t,e){return t.depth==e.depth&&t.pos>=e.start(-1)&&t.pos<=e.end(-1)}function bC(t,e,n){const r=t.node(-1),i=fn.get(r),a=t.start(-1),o=i.nextCell(t.pos-a,e,n);return o==null?null:t.node(0).resolve(a+o)}function No(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(i=>i>0)||(r.colwidth=null)),r}function NC(t,e,n=1){const r={...t,colspan:t.colspan+n};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let i=0;if!=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 cS(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)),i=e.resolve(n.map(this.$headCell.pos));if(px(r)&&px(i)&&F0(r,i)){const a=this.$anchorCell.node(-1)!=r.node(-1);return a&&this.isRowSelection()?fi.rowSelection(r,i):a&&this.isColSelection()?fi.colSelection(r,i):new fi(r,i)}return qe.between(r,i)}content(){const e=this.$anchorCell.node(-1),n=fn.get(e),r=this.$anchorCell.start(-1),i=n.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),a={},o=[];for(let u=i.top;u0||w>0){let N=b.attrs;if(j>0&&(N=No(N,0,j)),w>0&&(N=No(N,N.colspan-w,w)),y.lefti.bottom){const N={...b.attrs,rowspan:Math.min(y.bottom,i.bottom)-Math.max(y.top,i.top)};y.top0)return!1;const r=e+this.$anchorCell.nodeAfter.attrs.rowspan,i=n+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,i)==this.$headCell.node(-1).childCount}static colSelection(e,n=e){const r=e.node(-1),i=fn.get(r),a=e.start(-1),o=i.findCell(e.pos-a),c=i.findCell(n.pos-a),u=e.node(0);return o.top<=c.top?(o.top>0&&(e=u.resolve(a+i.map[o.left])),c.bottom0&&(n=u.resolve(a+i.map[c.left])),o.bottom0)return!1;const o=i+this.$anchorCell.nodeAfter.attrs.colspan,c=a+this.$headCell.nodeAfter.attrs.colspan;return Math.max(o,c)==n.width}eq(e){return e instanceof fi&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,n=e){const r=e.node(-1),i=fn.get(r),a=e.start(-1),o=i.findCell(e.pos-a),c=i.findCell(n.pos-a),u=e.node(0);return o.left<=c.left?(o.left>0&&(e=u.resolve(a+i.map[o.top*i.width])),c.right0&&(n=u.resolve(a+i.map[c.top*i.width])),o.right{e.push(En.node(r,r+n.nodeSize,{class:"selectedCell"}))}),It.create(t.doc,e)}function Kz({$from:t,$to:e}){if(t.pos==e.pos||t.pos=0&&!(t.after(i+1)=0&&!(e.before(a+1)>e.start(a));a--,r--);return n==r&&/row|table/.test(t.node(i).type.spec.tableRole)}function qz({$from:t,$to:e}){let n,r;for(let i=t.depth;i>0;i--){const a=t.node(i);if(a.type.spec.tableRole==="cell"||a.type.spec.tableRole==="header_cell"){n=a;break}}for(let i=e.depth;i>0;i--){const a=e.node(i);if(a.type.spec.tableRole==="cell"||a.type.spec.tableRole==="header_cell"){r=a;break}}return n!==r&&e.parentOffset===0}function Gz(t,e,n){const r=(e||t).selection,i=(e||t).doc;let a,o;if(r instanceof Ke&&(o=r.node.type.spec.tableRole)){if(o=="cell"||o=="header_cell")a=Ft.create(i,r.from);else if(o=="row"){const c=i.resolve(r.from+1);a=Ft.rowSelection(c,c)}else if(!n){const c=fn.get(r.node),u=r.from+1,h=u+c.map[c.width*c.height-1];a=Ft.create(i,u+1,h)}}else r instanceof qe&&Kz(r)?a=qe.create(i,r.from):r instanceof qe&&qz(r)&&(a=qe.create(i,r.$from.start(),r.$from.end()));return a&&(e||(e=t.tr)).setSelection(a),e}const Jz=new Qt("fix-tables");function jC(t,e,n,r){const i=t.childCount,a=e.childCount;e:for(let o=0,c=0;o{i.type.spec.tableRole=="table"&&(n=Yz(t,i,a,n))};return e?e.doc!=t.doc&&jC(e.doc,t.doc,0,r):t.doc.descendants(r),n}function Yz(t,e,n,r){const i=fn.get(e);if(!i.problems)return r;r||(r=t.tr);const a=[];for(let u=0;u0){let y="cell";f.firstChild&&(y=f.firstChild.type.spec.tableRole);const b=[];for(let w=0;w0?-1:0;Hz(e,r,i+a)&&(a=i==0||i==e.width?null:0);for(let o=0;o0&&i0&&e.map[c-1]==u||i0?-1:0;t$(e,r,i+c)&&(c=i==0||i==e.height?null:0);for(let h=0,f=e.width*i;h0&&i0&&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(i0&&n[a]==n[a-1]||r.right0&&n[i]==n[i-t]||r.bottom0){const f=u+1+h.content.size,m=FN(h)?u+1:f;a.replaceWith(m+r.tableStart,f+r.tableStart,c)}a.setSelection(new Ft(a.doc.resolve(u+r.tableStart))),e(a)}return!0}function VN(t,e){const n=rr(t.schema);return o$(({node:r})=>n[r.type.spec.tableRole])(t,e)}function o$(t){return(e,n)=>{const r=e.selection;let i,a;if(r instanceof Ft){if(r.$anchorCell.pos!=r.$headCell.pos)return!1;i=r.$anchorCell.nodeAfter,a=r.$anchorCell.pos}else{var o;if(i=Fz(r.$from),!i)return!1;a=(o=bo(r.$from))===null||o===void 0?void 0:o.pos}if(i==null||a==null||i.attrs.colspan==1&&i.attrs.rowspan==1)return!1;if(n){let c=i.attrs;const u=[],h=c.colwidth;c.rowspan>1&&(c={...c,rowspan:1}),c.colspan>1&&(c={...c,colspan:1});const f=Bs(e),m=e.tr;for(let y=0;y{o.attrs[t]!==e&&a.setNodeMarkup(c,null,{...o.attrs,[t]:e})}):a.setNodeMarkup(i.pos,null,{...i.nodeAfter.attrs,[t]:e}),r(a)}return!0}}function c$(t){return function(e,n){if(!bs(e))return!1;if(n){const r=rr(e.schema),i=Bs(e),a=e.tr,o=i.map.cellsInRect(t=="column"?{left:i.left,top:0,right:i.right,bottom:i.map.height}:t=="row"?{left:0,top:i.top,right:i.map.width,bottom:i.bottom}:i),c=o.map(u=>i.table.nodeAt(u));for(let u=0;u{const y=g+a.tableStart,b=o.doc.nodeAt(y);b&&o.setNodeMarkup(y,m,b.attrs)}),r(o)}return!0}}od("row",{useDeprecatedLogic:!0});od("column",{useDeprecatedLogic:!0});const d$=od("cell",{useDeprecatedLogic:!0});function u$(t,e){if(e<0){const n=t.nodeBefore;if(n)return t.pos-n.nodeSize;for(let r=t.index(-1)-1,i=t.before();r>=0;r--){const a=t.node(-1).child(r),o=a.lastChild;if(o)return i-1-o.nodeSize;i-=a.nodeSize}}else{if(t.index()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 Vu(t,e){const n=t.selection;if(!(n instanceof Ft))return!1;if(e){const r=t.tr,i=rr(t.schema).cell.createAndFill().content;n.forEachCell((a,o)=>{a.content.eq(i)||r.replace(r.mapping.map(o+1),r.mapping.map(o+a.nodeSize-1),new Ie(i,0,0))}),r.docChanged&&e(r)}return!0}function f$(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 i=e.child(0),a=i.type.spec.tableRole,o=i.type.schema,c=[];if(a=="row")for(let u=0;u=0;o--){const{rowspan:c,colspan:u}=a.child(o).attrs;for(let h=i;h=e.length&&e.push(ge.empty),n[i]r&&(g=g.type.createChecked(No(g.attrs,g.attrs.colspan,f+g.attrs.colspan-r),g.content)),h.push(g),f+=g.attrs.colspan;for(let y=1;yi&&(m=m.type.create({...m.attrs,rowspan:Math.max(1,i-m.attrs.rowspan)},m.content)),u.push(m)}a.push(ge.from(u))}n=a,e=i}return{width:t,height:e,rows:n}}function g$(t,e,n,r,i,a,o){const c=t.doc.type.schema,u=rr(c);let h,f;if(i>e.width)for(let m=0,g=0;me.height){const m=[];for(let b=0,j=(e.height-1)*e.width;b=e.width?!1:n.nodeAt(e.map[j+b]).type==u.header_cell;m.push(w?f||(f=u.header_cell.createAndFill()):h||(h=u.cell.createAndFill()))}const g=u.row.create(null,ge.from(m)),y=[];for(let b=e.height;b{if(!i)return!1;const a=n.selection;if(a instanceof Ft)return th(n,r,Ze.near(a.$headCell,e));if(t!="horiz"&&!a.empty)return!1;const o=EC(i,t,e);if(o==null)return!1;if(t=="horiz")return th(n,r,Ze.near(n.doc.resolve(a.head+e),e));{const c=n.doc.resolve(o),u=bC(c,t,e);let h;return u?h=Ze.near(u,1):e<0?h=Ze.near(n.doc.resolve(c.before(-1)),-1):h=Ze.near(n.doc.resolve(c.after(-1)),1),th(n,r,h)}}}function Wu(t,e){return(n,r,i)=>{if(!i)return!1;const a=n.selection;let o;if(a instanceof Ft)o=a;else{const u=EC(i,t,e);if(u==null)return!1;o=new Ft(n.doc.resolve(u))}const c=bC(o.$headCell,t,e);return c?th(n,r,new Ft(o.$anchorCell,c)):!1}}function y$(t,e){const n=t.state.doc,r=bo(n.resolve(e));return r?(t.dispatch(t.state.tr.setSelection(new Ft(r))),!0):!1}function v$(t,e,n){if(!bs(t.state))return!1;let r=f$(n);const i=t.state.selection;if(i instanceof Ft){r||(r={width:1,height:1,rows:[ge.from(mx(rr(t.state.schema).cell,n))]});const a=i.$anchorCell.node(-1),o=i.$anchorCell.start(-1),c=fn.get(a).rectBetween(i.$anchorCell.pos-o,i.$headCell.pos-o);return r=m$(r,c.right-c.left,c.bottom-c.top),qN(t.state,t.dispatch,o,c,r),!0}else if(r){const a=Pf(t.state),o=a.start(-1);return qN(t.state,t.dispatch,o,fn.get(a.node(-1)).findCell(a.pos-o),r),!0}else return!1}function b$(t,e){var n;if(e.button!=0||e.ctrlKey||e.metaKey)return;const r=GN(t,e.target);let i;if(e.shiftKey&&t.state.selection instanceof Ft)a(t.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&r&&(i=bo(t.state.selection.$anchor))!=null&&((n=hg(t,e))===null||n===void 0?void 0:n.pos)!=i.pos)a(i,e),e.preventDefault();else if(!r)return;function a(u,h){let f=hg(t,h);const m=ra.getState(t.state)==null;if(!f||!F0(u,f))if(m)f=u;else return;const g=new Ft(u,f);if(m||!t.state.selection.eq(g)){const y=t.state.tr.setSelection(g);m&&y.setMeta(ra,u.pos),t.dispatch(y)}}function o(){t.root.removeEventListener("mouseup",o),t.root.removeEventListener("dragstart",o),t.root.removeEventListener("mousemove",c),ra.getState(t.state)!=null&&t.dispatch(t.state.tr.setMeta(ra,-1))}function c(u){const h=u,f=ra.getState(t.state);let m;if(f!=null)m=t.state.doc.resolve(f);else if(GN(t,h.target)!=r&&(m=hg(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 EC(t,e,n){if(!(t.state.selection instanceof qe))return null;const{$head:r}=t.state.selection;for(let i=r.depth-1;i>=0;i--){const a=r.node(i);if((n<0?r.index(i):r.indexAfter(i))!=(n<0?0:a.childCount))return null;if(a.type.spec.tableRole=="cell"||a.type.spec.tableRole=="header_cell"){const o=r.before(i),c=e=="vert"?n>0?"down":"up":n>0?"right":"left";return t.endOfTextblock(c)?o:null}}return null}function GN(t,e){for(;e&&e!=t.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function hg(t,e){const n=t.posAtCoords({left:e.clientX,top:e.clientY});if(!n)return null;let{inside:r,pos:i}=n;return r>=0&&bo(t.state.doc.resolve(r))||bo(t.state.doc.resolve(i))}var N$=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")),gx(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,gx(e,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(e){return e.type=="attributes"&&(e.target==this.table||this.colgroup.contains(e.target))}};function gx(t,e,n,r,i,a){let o=0,c=!0,u=e.firstChild;const h=t.firstChild;if(h){for(let m=0,g=0;mnew r(m,n,g)),new j$(-1,!1)},apply(o,c){return c.apply(o)}},props:{attributes:o=>{const c=Or.getState(o);return c&&c.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(o,c)=>{k$(o,c,t,i)},mouseleave:o=>{S$(o)},mousedown:(o,c)=>{C$(o,c,e,n)}},decorations:o=>{const c=Or.getState(o);if(c&&c.activeHandle>-1)return I$(o,c.activeHandle)},nodeViews:{}}});return a}var j$=class nh{constructor(e,n){this.activeHandle=e,this.dragging=n}apply(e){const n=this,r=e.getMeta(Or);if(r&&r.setHandle!=null)return new nh(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new nh(n.activeHandle,r.setDragging);if(n.activeHandle>-1&&e.docChanged){let i=e.mapping.map(n.activeHandle,-1);return px(e.doc.resolve(i))||(i=-1),new nh(i,n.dragging)}return n}};function k$(t,e,n,r){if(!t.editable)return;const i=Or.getState(t.state);if(i&&!i.dragging){const a=T$(e.target);let o=-1;if(a){const{left:c,right:u}=a.getBoundingClientRect();e.clientX-c<=n?o=JN(t,e,"left",n):u-e.clientX<=n&&(o=JN(t,e,"right",n))}if(o!=i.activeHandle){if(!r&&o!==-1){const c=t.state.doc.resolve(o),u=c.node(-1),h=fn.get(u),f=c.start(-1);if(h.colCount(c.pos-f)+c.nodeAfter.attrs.colspan-1==h.width-1)return}TC(t,o)}}}function S$(t){if(!t.editable)return;const e=Or.getState(t.state);e&&e.activeHandle>-1&&!e.dragging&&TC(t,-1)}function C$(t,e,n,r){var i;if(!t.editable)return!1;const a=(i=t.dom.ownerDocument.defaultView)!==null&&i!==void 0?i:window,o=Or.getState(t.state);if(!o||o.activeHandle==-1||o.dragging)return!1;const c=t.state.doc.nodeAt(o.activeHandle),u=E$(t,o.activeHandle,c.attrs);t.dispatch(t.state.tr.setMeta(Or,{setDragging:{startX:e.clientX,startWidth:u}}));function h(m){a.removeEventListener("mouseup",h),a.removeEventListener("mousemove",f);const g=Or.getState(t.state);g!=null&&g.dragging&&(M$(t,g.activeHandle,YN(g.dragging,m,n)),t.dispatch(t.state.tr.setMeta(Or,{setDragging:null})))}function f(m){if(!m.which)return h(m);const g=Or.getState(t.state);if(g&&g.dragging){const y=YN(g.dragging,m,n);QN(t,g.activeHandle,y,r)}}return QN(t,o.activeHandle,u,r),a.addEventListener("mouseup",h),a.addEventListener("mousemove",f),e.preventDefault(),!0}function E$(t,e,{colspan:n,colwidth:r}){const i=r&&r[r.length-1];if(i)return i;const a=t.domAtPos(e);let o=a.node.childNodes[a.offset].offsetWidth,c=n;if(r)for(let u=0;u{var e,n;const r=t.getAttribute("colwidth"),i=r?r.split(",").map(a=>parseInt(a,10)):null;if(!i){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 i}}}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td"}]},renderHTML({HTMLAttributes:t}){return["td",kt(this.options.HTMLAttributes,t),0]}}),AC=Nn.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",kt(this.options.HTMLAttributes,t),0]}}),IC=Nn.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:t}){return["tr",kt(this.options.HTMLAttributes,t),0]}});function xx(t,e){return e?["width",`${Math.max(e,t)}px`]:["min-width",`${t}px`]}function XN(t,e,n,r,i,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{const r=t.nodes[n];r.spec.tableRole&&(e[r.spec.tableRole]=r)}),t.cached.tableNodeTypes=e,e}function L$(t,e,n,r,i){const a=D$(t),o=[],c=[];for(let h=0;h{const{selection:e}=t.state;if(!_$(e))return!1;let n=0;const r=f2(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},z$="";function $$(t){return(t||"").replace(/\s+/g," ").trim()}function F$(t,e,n={}){var r;const i=(r=n.cellLineSeparator)!=null?r:z$;if(!t||!t.content||t.content.length===0)return"";const a=[];t.content.forEach(b=>{const j=[];b.content&&b.content.forEach(w=>{let N="";w.content&&Array.isArray(w.content)&&w.content.length>1?N=w.content.map(I=>e.renderChildren(I)).join(i):N=w.content?e.renderChildren(w.content):"";const C=$$(N),E=w.type==="tableHeader";j.push({text:C,isHeader:E})}),a.push(j)});const o=a.reduce((b,j)=>Math.max(b,j.length),0);if(o===0)return"";const c=new Array(o).fill(0);a.forEach(b=>{var j;for(let w=0;wc[w]&&(c[w]=C),c[w]<3&&(c[w]=3)}});const u=(b,j)=>b+" ".repeat(Math.max(0,j-b.length)),h=a[0],f=h.some(b=>b.isHeader);let m=` +`;const g=new Array(o).fill(0).map((b,j)=>f&&h[j]&&h[j].text||"");return m+=`| ${g.map((b,j)=>u(b,c[j])).join(" | ")} | +`,m+=`| ${c.map(b=>"-".repeat(Math.max(3,b))).join(" | ")} | +`,(f?a.slice(1):a).forEach(b=>{m+=`| ${new Array(o).fill(0).map((j,w)=>u(b[w]&&b[w].text||"",c[w])).join(" | ")} | +`}),m}var B$=F$,RC=Nn.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,renderWrapper:!1,handleWidth:5,cellMinWidth:25,View:P$,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:i}=O$(t,this.options.cellMinWidth),a=e.style;function o(){return a||(r?`width: ${r}`:`min-width: ${i}`)}const c=["table",kt(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(i=>{r.push(e.createNode("tableHeader",{},[{type:"paragraph",content:e.parseInline(i.tokens)}]))}),n.push(e.createNode("tableRow",{},r))}return t.rows&&t.rows.forEach(r=>{const i=[];r.forEach(a=>{i.push(e.createNode("tableCell",{},[{type:"paragraph",content:e.parseInline(a.tokens)}]))}),n.push(e.createNode("tableRow",{},i))}),e.createNode("table",void 0,n)},renderMarkdown:(t,e)=>B$(t,e),addCommands(){return{insertTable:({rows:t=3,cols:e=3,withHeaderRow:n=!0}={})=>({tr:r,dispatch:i,editor:a})=>{const o=L$(a.schema,t,e,n);if(i){const c=r.selection.from+1;r.replaceSelectionWith(o).scrollIntoView().setSelection(qe.near(r.doc.resolve(c)))}return!0},addColumnBefore:()=>({state:t,dispatch:e})=>Qz(t,e),addColumnAfter:()=>({state:t,dispatch:e})=>Xz(t,e),deleteColumn:()=>({state:t,dispatch:e})=>e$(t,e),addRowBefore:()=>({state:t,dispatch:e})=>n$(t,e),addRowAfter:()=>({state:t,dispatch:e})=>r$(t,e),deleteRow:()=>({state:t,dispatch:e})=>i$(t,e),deleteTable:()=>({state:t,dispatch:e})=>h$(t,e),mergeCells:()=>({state:t,dispatch:e})=>BN(t,e),splitCell:()=>({state:t,dispatch:e})=>VN(t,e),toggleHeaderColumn:()=>({state:t,dispatch:e})=>od("column")(t,e),toggleHeaderRow:()=>({state:t,dispatch:e})=>od("row")(t,e),toggleHeaderCell:()=>({state:t,dispatch:e})=>d$(t,e),mergeOrSplit:()=>({state:t,dispatch:e})=>BN(t,e)?!0:VN(t,e),setCellAttribute:(t,e)=>({state:n,dispatch:r})=>l$(t,e)(n,r),goToNextCell:()=>({state:t,dispatch:e})=>WN(1)(t,e),goToPreviousCell:()=>({state:t,dispatch:e})=>WN(-1)(t,e),fixTables:()=>({state:t,dispatch:e})=>(e&&kC(t),!0),setCellSelection:t=>({tr:e,dispatch:n})=>{if(n){const r=Ft.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:Uu,"Mod-Backspace":Uu,Delete:Uu,"Mod-Delete":Uu}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[w$({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],R$({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema(t){const e={name:t.name,options:t.options,storage:t.storage};return{tableRole:jt(We(t,"tableRole",e))}}});pn.create({name:"tableKit",addExtensions(){const t=[];return this.options.table!==!1&&t.push(RC.configure(this.options.table)),this.options.tableCell!==!1&&t.push(MC.configure(this.options.tableCell)),this.options.tableHeader!==!1&&t.push(AC.configure(this.options.tableHeader)),this.options.tableRow!==!1&&t.push(IC.configure(this.options.tableRow)),t}});function V$(t){if(!t)return"";let e=t;return e=e.replace(/]*>(.*?)<\/h1>/gi,`# $1 + +`),e=e.replace(/]*>(.*?)<\/h2>/gi,`## $1 + +`),e=e.replace(/]*>(.*?)<\/h3>/gi,`### $1 + +`),e=e.replace(/]*>(.*?)<\/strong>/gi,"**$1**"),e=e.replace(/]*>(.*?)<\/b>/gi,"**$1**"),e=e.replace(/]*>(.*?)<\/em>/gi,"*$1*"),e=e.replace(/]*>(.*?)<\/i>/gi,"*$1*"),e=e.replace(/]*>(.*?)<\/s>/gi,"~~$1~~"),e=e.replace(/]*>(.*?)<\/del>/gi,"~~$1~~"),e=e.replace(/]*>(.*?)<\/code>/gi,"`$1`"),e=e.replace(/]*>(.*?)<\/blockquote>/gi,`> $1 + +`),e=e.replace(/]*src="([^"]*)"[^>]*alt="([^"]*)"[^>]*>/gi,"![$2]($1)"),e=e.replace(/]*src="([^"]*)"[^>]*>/gi,"![]($1)"),e=e.replace(/]*href="([^"]*)"[^>]*>(.*?)<\/a>/gi,"[$2]($1)"),e=e.replace(/]*>(.*?)<\/li>/gi,`- $1 +`),e=e.replace(/<\/?[uo]l[^>]*>/gi,` +`),e=e.replace(//gi,` +`),e=e.replace(/]*>(.*?)<\/p>/gi,`$1 + +`),e=e.replace(//gi,`--- + +`),e=e.replace(/]*data-type="mention"[^>]*data-id="([^"]*)"[^>]*>@([^<]*)<\/span>/gi,"@$2"),e=e.replace(/]*data-type="linkTag"[^>]*data-url="([^"]*)"[^>]*>#([^<]*)<\/span>/gi,"#[$2]($1)"),e=e.replace(/<[^>]+>/g,""),e=e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'"),e=e.replace(/\n{3,}/g,` + +`),e.trim()}function ew(t){if(!t)return"";if(t.startsWith("<")&&t.includes("$1"),e=e.replace(/^## (.+)$/gm,"

$1

"),e=e.replace(/^# (.+)$/gm,"

$1

"),e=e.replace(/\*\*(.+?)\*\*/g,"$1"),e=e.replace(/__(.+?)__/g,"$1"),e=e.replace(new RegExp("(?$1"),e=e.replace(new RegExp("(?$1"),e=e.replace(/~~(.+?)~~/g,"$1"),e=e.replace(/`([^`]+)`/g,"$1"),e=e.replace(/!\[([^\]]*)\]\(([^)]+)\)/g,'$1'),e=e.replace(/\[([^\]]+)\]\(([^)]+)\)/g,'$1'),e=e.replace(/^> (.+)$/gm,"

$1

"),e=e.replace(/^---$/gm,"
"),e=e.replace(/^- (.+)$/gm,"
  • $1
  • ");const n=e.split(` +`),r=[];for(const i of n){const a=i.trim();a&&(/^<(?:h[1-6]|blockquote|hr|li|ul|ol|table|img)/.test(a)?r.push(a):r.push(`

    ${a}

    `))}return r.join("")}const H$=Nn.create({name:"linkTag",group:"inline",inline:!0,selectable:!0,atom:!0,addAttributes(){return{label:{default:""},url:{default:""},tagType:{default:"url",parseHTML:t=>t.getAttribute("data-tag-type")||"url"},tagId:{default:"",parseHTML:t=>t.getAttribute("data-tag-id")||""},pagePath:{default:"",parseHTML:t=>t.getAttribute("data-page-path")||""},appId:{default:"",parseHTML:t=>t.getAttribute("data-app-id")||""},mpKey:{default:"",parseHTML:t=>t.getAttribute("data-mp-key")||""}}},parseHTML(){return[{tag:'span[data-type="linkTag"]',getAttrs:t=>{var e;return{label:((e=t.textContent)==null?void 0:e.replace(/^#/,"").trim())||"",url:t.getAttribute("data-url")||"",tagType:t.getAttribute("data-tag-type")||"url",tagId:t.getAttribute("data-tag-id")||"",pagePath:t.getAttribute("data-page-path")||"",appId:t.getAttribute("data-app-id")||"",mpKey:t.getAttribute("data-mp-key")||""}}}]},renderHTML({node:t,HTMLAttributes:e}){return["span",kt(e,{"data-type":"linkTag","data-url":t.attrs.url,"data-tag-type":t.attrs.tagType,"data-tag-id":t.attrs.tagId,"data-page-path":t.attrs.pagePath,"data-app-id":t.attrs.appId||"","data-mp-key":t.attrs.mpKey||t.attrs.appId||"",class:"link-tag-node"}),`#${t.attrs.label}`]}}),W$=t=>({items:({query:e})=>(t.current||[]).filter(r=>r.name.toLowerCase().includes(e.toLowerCase())||r.id.includes(e)).slice(0,8),render:()=>{let e=null,n=0,r=[],i=null;const a=()=>{e&&(e.innerHTML=r.map((o,c)=>`
    + @${o.name} + ${o.label||o.id} +
    `).join(""),e.querySelectorAll(".mention-item").forEach(o=>{o.addEventListener("click",()=>{const c=parseInt(o.getAttribute("data-index")||"0");i&&r[c]&&i({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,i=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,i=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"?(i&&r[n]&&i({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}}}}),yx=v.forwardRef(({content:t,onChange:e,onImageUpload:n,persons:r=[],linkTags:i=[],placeholder:a="开始编辑内容...",className:o},c)=>{const u=v.useRef(null),[h,f]=v.useState(""),[m,g]=v.useState(!1),y=v.useRef(ew(t)),b=v.useRef(e);b.current=e;const j=v.useRef(r);j.current=r;const w=v.useRef(),N=z_({extensions:[Sz,Tz.configure({inline:!0,allowBase64:!0}),O7.configure({openOnClick:!1,HTMLAttributes:{class:"rich-link"}}),Oz.configure({HTMLAttributes:{class:"mention-tag"},suggestion:W$(j)}),H$,Dz.configure({placeholder:a}),RC.configure({resizable:!0}),IC,MC,AC],content:y.current,onUpdate:({editor:I})=>{w.current&&clearTimeout(w.current),w.current=setTimeout(()=>{b.current(I.getHTML())},300)},editorProps:{attributes:{class:"rich-editor-content"}}});v.useImperativeHandle(c,()=>({getHTML:()=>(N==null?void 0:N.getHTML())||"",getMarkdown:()=>V$((N==null?void 0:N.getHTML())||"")})),v.useEffect(()=>{if(N&&t!==N.getHTML()){const I=ew(t);I!==N.getHTML()&&N.commands.setContent(I)}},[t]);const C=v.useCallback(async I=>{var D;const O=(D=I.target.files)==null?void 0:D[0];if(!(!O||!N)){if(n){const P=await n(O);P&&N.chain().focus().setImage({src:P}).run()}else{const P=new FileReader;P.onload=()=>{typeof P.result=="string"&&N.chain().focus().setImage({src:P.result}).run()},P.readAsDataURL(O)}I.target.value=""}},[N,n]),E=v.useCallback(I=>{N&&N.chain().focus().insertContent({type:"linkTag",attrs:{label:I.label,url:I.url||"",tagType:I.type||"url",tagId:I.id||"",pagePath:I.pagePath||"",appId:I.appId||"",mpKey:I.type==="miniprogram"&&I.appId||""}}).run()},[N]),M=v.useCallback(()=>{!N||!h||(N.chain().focus().setLink({href:h}).run(),f(""),g(!1))},[N,h]);return N?s.jsxs("div",{className:`rich-editor-wrapper ${o||""}`,children:[s.jsxs("div",{className:"rich-editor-toolbar",children:[s.jsxs("div",{className:"toolbar-group",children:[s.jsx("button",{onClick:()=>N.chain().focus().toggleBold().run(),className:N.isActive("bold")?"is-active":"",type:"button",children:s.jsx(OT,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>N.chain().focus().toggleItalic().run(),className:N.isActive("italic")?"is-active":"",type:"button",children:s.jsx(OM,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>N.chain().focus().toggleStrike().run(),className:N.isActive("strike")?"is-active":"",type:"button",children:s.jsx(IA,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>N.chain().focus().toggleCode().run(),className:N.isActive("code")?"is-active":"",type:"button",children:s.jsx(eM,{className:"w-4 h-4"})})]}),s.jsx("div",{className:"toolbar-divider"}),s.jsxs("div",{className:"toolbar-group",children:[s.jsx("button",{onClick:()=>N.chain().focus().toggleHeading({level:1}).run(),className:N.isActive("heading",{level:1})?"is-active":"",type:"button",children:s.jsx(kM,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>N.chain().focus().toggleHeading({level:2}).run(),className:N.isActive("heading",{level:2})?"is-active":"",type:"button",children:s.jsx(CM,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>N.chain().focus().toggleHeading({level:3}).run(),className:N.isActive("heading",{level:3})?"is-active":"",type:"button",children:s.jsx(TM,{className:"w-4 h-4"})})]}),s.jsx("div",{className:"toolbar-divider"}),s.jsxs("div",{className:"toolbar-group",children:[s.jsx("button",{onClick:()=>N.chain().focus().toggleBulletList().run(),className:N.isActive("bulletList")?"is-active":"",type:"button",children:s.jsx(WM,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>N.chain().focus().toggleOrderedList().run(),className:N.isActive("orderedList")?"is-active":"",type:"button",children:s.jsx(VM,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>N.chain().focus().toggleBlockquote().run(),className:N.isActive("blockquote")?"is-active":"",type:"button",children:s.jsx(gA,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>N.chain().focus().setHorizontalRule().run(),type:"button",children:s.jsx(tA,{className:"w-4 h-4"})})]}),s.jsx("div",{className:"toolbar-divider"}),s.jsxs("div",{className:"toolbar-group",children:[s.jsx("input",{ref:u,type:"file",accept:"image/*",onChange:C,className:"hidden"}),s.jsx("button",{onClick:()=>{var I;return(I=u.current)==null?void 0:I.click()},type:"button",children:s.jsx(Uw,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>g(!m),className:N.isActive("link")?"is-active":"",type:"button",children:s.jsx(Sg,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>N.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run(),type:"button",children:s.jsx(PA,{className:"w-4 h-4"})})]}),s.jsx("div",{className:"toolbar-divider"}),s.jsxs("div",{className:"toolbar-group",children:[s.jsx("button",{onClick:()=>N.chain().focus().undo().run(),disabled:!N.can().undo(),type:"button",children:s.jsx(FA,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>N.chain().focus().redo().run(),disabled:!N.can().redo(),type:"button",children:s.jsx(yA,{className:"w-4 h-4"})})]}),i.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"toolbar-divider"}),s.jsx("div",{className:"toolbar-group",children:s.jsxs("select",{className:"link-tag-select",onChange:I=>{const O=i.find(D=>D.id===I.target.value);O&&E(O),I.target.value=""},defaultValue:"",children:[s.jsx("option",{value:"",disabled:!0,children:"# 插入链接标签"}),i.map(I=>s.jsx("option",{value:I.id,children:I.label},I.id))]})})]})]}),m&&s.jsxs("div",{className:"link-input-bar",children:[s.jsx("input",{type:"url",placeholder:"输入链接地址...",value:h,onChange:I=>f(I.target.value),onKeyDown:I=>I.key==="Enter"&&M(),className:"link-input"}),s.jsx("button",{onClick:M,className:"link-confirm",type:"button",children:"确定"}),s.jsx("button",{onClick:()=>{N.chain().focus().unsetLink().run(),g(!1)},className:"link-remove",type:"button",children:"移除"})]}),s.jsx(V2,{editor:N})]}):null});yx.displayName="RichEditor";const U$=["top","right","bottom","left"],va=Math.min,Rr=Math.max,nf=Math.round,Ku=Math.floor,Ls=t=>({x:t,y:t}),K$={left:"right",right:"left",bottom:"top",top:"bottom"},q$={start:"end",end:"start"};function vx(t,e,n){return Rr(t,va(e,n))}function bi(t,e){return typeof t=="function"?t(e):t}function Ni(t){return t.split("-")[0]}function Fl(t){return t.split("-")[1]}function B0(t){return t==="x"?"y":"x"}function V0(t){return t==="y"?"height":"width"}const G$=new Set(["top","bottom"]);function Ds(t){return G$.has(Ni(t))?"y":"x"}function H0(t){return B0(Ds(t))}function J$(t,e,n){n===void 0&&(n=!1);const r=Fl(t),i=H0(t),a=V0(i);let o=i==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return e.reference[a]>e.floating[a]&&(o=rf(o)),[o,rf(o)]}function Y$(t){const e=rf(t);return[bx(t),e,bx(e)]}function bx(t){return t.replace(/start|end/g,e=>q$[e])}const tw=["left","right"],nw=["right","left"],Q$=["top","bottom"],X$=["bottom","top"];function Z$(t,e,n){switch(t){case"top":case"bottom":return n?e?nw:tw:e?tw:nw;case"left":case"right":return e?Q$:X$;default:return[]}}function eF(t,e,n,r){const i=Fl(t);let a=Z$(Ni(t),n==="start",r);return i&&(a=a.map(o=>o+"-"+i),e&&(a=a.concat(a.map(bx)))),a}function rf(t){return t.replace(/left|right|bottom|top/g,e=>K$[e])}function tF(t){return{top:0,right:0,bottom:0,left:0,...t}}function PC(t){return typeof t!="number"?tF(t):{top:t,right:t,bottom:t,left:t}}function sf(t){const{x:e,y:n,width:r,height:i}=t;return{width:r,height:i,top:n,left:e,right:e+r,bottom:n+i,x:e,y:n}}function rw(t,e,n){let{reference:r,floating:i}=t;const a=Ds(e),o=H0(e),c=V0(o),u=Ni(e),h=a==="y",f=r.x+r.width/2-i.width/2,m=r.y+r.height/2-i.height/2,g=r[c]/2-i[c]/2;let y;switch(u){case"top":y={x:f,y:r.y-i.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-i.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 nF(t,e){var n;e===void 0&&(e={});const{x:r,y:i,platform:a,rects:o,elements:c,strategy:u}=t,{boundary:h="clippingAncestors",rootBoundary:f="viewport",elementContext:m="floating",altBoundary:g=!1,padding:y=0}=bi(e,t),b=PC(y),w=c[g?m==="floating"?"reference":"floating":m],N=sf(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})),C=m==="floating"?{x:r,y:i,width:o.floating.width,height:o.floating.height}:o.reference,E=await(a.getOffsetParent==null?void 0:a.getOffsetParent(c.floating)),M=await(a.isElement==null?void 0:a.isElement(E))?await(a.getScale==null?void 0:a.getScale(E))||{x:1,y:1}:{x:1,y:1},I=sf(a.convertOffsetParentRelativeRectToViewportRelativeRect?await a.convertOffsetParentRelativeRectToViewportRelativeRect({elements:c,rect:C,offsetParent:E,strategy:u}):C);return{top:(N.top-I.top+b.top)/M.y,bottom:(I.bottom-N.bottom+b.bottom)/M.y,left:(N.left-I.left+b.left)/M.x,right:(I.right-N.right+b.right)/M.x}}const rF=async(t,e,n)=>{const{placement:r="bottom",strategy:i="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:i}),{x:f,y:m}=rw(h,r,u),g=r,y={},b=0;for(let w=0;w({name:"arrow",options:t,async fn(e){const{x:n,y:r,placement:i,rects:a,platform:o,elements:c,middlewareData:u}=e,{element:h,padding:f=0}=bi(t,e)||{};if(h==null)return{};const m=PC(f),g={x:n,y:r},y=H0(i),b=V0(y),j=await o.getDimensions(h),w=y==="y",N=w?"top":"left",C=w?"bottom":"right",E=w?"clientHeight":"clientWidth",M=a.reference[b]+a.reference[y]-g[y]-a.floating[b],I=g[y]-a.reference[y],O=await(o.getOffsetParent==null?void 0:o.getOffsetParent(h));let D=O?O[E]:0;(!D||!await(o.isElement==null?void 0:o.isElement(O)))&&(D=c.floating[E]||a.floating[b]);const P=M/2-I/2,L=D/2-j[b]/2-1,_=va(m[N],L),X=va(m[C],L),ne=_,J=D-j[b]-X,U=D/2-j[b]/2+P,R=vx(ne,U,J),F=!u.arrow&&Fl(i)!=null&&U!==R&&a.reference[b]/2-(UU<=0)){var X,ne;const U=(((X=a.flip)==null?void 0:X.index)||0)+1,R=D[U];if(R&&(!(m==="alignment"?C!==Ds(R):!1)||_.every(z=>Ds(z.placement)===C?z.overflows[0]>0:!0)))return{data:{index:U,overflows:_},reset:{placement:R}};let F=(ne=_.filter(re=>re.overflows[0]<=0).sort((re,z)=>re.overflows[1]-z.overflows[1])[0])==null?void 0:ne.placement;if(!F)switch(y){case"bestFit":{var J;const re=(J=_.filter(z=>{if(O){const ae=Ds(z.placement);return ae===C||ae==="y"}return!0}).map(z=>[z.placement,z.overflows.filter(ae=>ae>0).reduce((ae,G)=>ae+G,0)]).sort((z,ae)=>z[1]-ae[1])[0])==null?void 0:J[0];re&&(F=re);break}case"initialPlacement":F=c;break}if(i!==F)return{reset:{placement:F}}}return{}}}};function sw(t,e){return{top:t.top-e.height,right:t.right-e.width,bottom:t.bottom-e.height,left:t.left-e.width}}function iw(t){return U$.some(e=>t[e]>=0)}const aF=function(t){return t===void 0&&(t={}),{name:"hide",options:t,async fn(e){const{rects:n,platform:r}=e,{strategy:i="referenceHidden",...a}=bi(t,e);switch(i){case"referenceHidden":{const o=await r.detectOverflow(e,{...a,elementContext:"reference"}),c=sw(o,n.reference);return{data:{referenceHiddenOffsets:c,referenceHidden:iw(c)}}}case"escaped":{const o=await r.detectOverflow(e,{...a,altBoundary:!0}),c=sw(o,n.floating);return{data:{escapedOffsets:c,escaped:iw(c)}}}default:return{}}}}},OC=new Set(["left","top"]);async function oF(t,e){const{placement:n,platform:r,elements:i}=t,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=Ni(n),c=Fl(n),u=Ds(n)==="y",h=OC.has(o)?-1:1,f=a&&u?-1:1,m=bi(e,t);let{mainAxis:g,crossAxis:y,alignmentAxis:b}=typeof m=="number"?{mainAxis:m,crossAxis:0,alignmentAxis:null}:{mainAxis:m.mainAxis||0,crossAxis:m.crossAxis||0,alignmentAxis:m.alignmentAxis};return c&&typeof b=="number"&&(y=c==="end"?b*-1:b),u?{x:y*f,y:g*h}:{x:g*h,y:y*f}}const lF=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){var n,r;const{x:i,y:a,placement:o,middlewareData:c}=e,u=await oF(e,t);return o===((n=c.offset)==null?void 0:n.placement)&&(r=c.arrow)!=null&&r.alignmentOffset?{}:{x:i+u.x,y:a+u.y,data:{...u,placement:o}}}}},cF=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){const{x:n,y:r,placement:i,platform:a}=e,{mainAxis:o=!0,crossAxis:c=!1,limiter:u={fn:N=>{let{x:C,y:E}=N;return{x:C,y:E}}},...h}=bi(t,e),f={x:n,y:r},m=await a.detectOverflow(e,h),g=Ds(Ni(i)),y=B0(g);let b=f[y],j=f[g];if(o){const N=y==="y"?"top":"left",C=y==="y"?"bottom":"right",E=b+m[N],M=b-m[C];b=vx(E,b,M)}if(c){const N=g==="y"?"top":"left",C=g==="y"?"bottom":"right",E=j+m[N],M=j-m[C];j=vx(E,j,M)}const w=u.fn({...e,[y]:b,[g]:j});return{...w,data:{x:w.x-n,y:w.y-r,enabled:{[y]:o,[g]:c}}}}}},dF=function(t){return t===void 0&&(t={}),{options:t,fn(e){const{x:n,y:r,placement:i,rects:a,middlewareData:o}=e,{offset:c=0,mainAxis:u=!0,crossAxis:h=!0}=bi(t,e),f={x:n,y:r},m=Ds(i),g=B0(m);let y=f[g],b=f[m];const j=bi(c,e),w=typeof j=="number"?{mainAxis:j,crossAxis:0}:{mainAxis:0,crossAxis:0,...j};if(u){const E=g==="y"?"height":"width",M=a.reference[g]-a.floating[E]+w.mainAxis,I=a.reference[g]+a.reference[E]-w.mainAxis;yI&&(y=I)}if(h){var N,C;const E=g==="y"?"width":"height",M=OC.has(Ni(i)),I=a.reference[m]-a.floating[E]+(M&&((N=o.offset)==null?void 0:N[m])||0)+(M?0:w.crossAxis),O=a.reference[m]+a.reference[E]+(M?0:((C=o.offset)==null?void 0:C[m])||0)-(M?w.crossAxis:0);bO&&(b=O)}return{[g]:y,[m]:b}}}},uF=function(t){return t===void 0&&(t={}),{name:"size",options:t,async fn(e){var n,r;const{placement:i,rects:a,platform:o,elements:c}=e,{apply:u=()=>{},...h}=bi(t,e),f=await o.detectOverflow(e,h),m=Ni(i),g=Fl(i),y=Ds(i)==="y",{width:b,height:j}=a.floating;let w,N;m==="top"||m==="bottom"?(w=m,N=g===(await(o.isRTL==null?void 0:o.isRTL(c.floating))?"start":"end")?"left":"right"):(N=m,w=g==="end"?"top":"bottom");const C=j-f.top-f.bottom,E=b-f.left-f.right,M=va(j-f[w],C),I=va(b-f[N],E),O=!e.middlewareData.shift;let D=M,P=I;if((n=e.middlewareData.shift)!=null&&n.enabled.x&&(P=E),(r=e.middlewareData.shift)!=null&&r.enabled.y&&(D=C),O&&!g){const _=Rr(f.left,0),X=Rr(f.right,0),ne=Rr(f.top,0),J=Rr(f.bottom,0);y?P=b-2*(_!==0||X!==0?_+X:Rr(f.left,f.right)):D=j-2*(ne!==0||J!==0?ne+J:Rr(f.top,f.bottom))}await u({...e,availableWidth:P,availableHeight:D});const L=await o.getDimensions(c.floating);return b!==L.width||j!==L.height?{reset:{rects:!0}}:{}}}};function Of(){return typeof window<"u"}function Bl(t){return DC(t)?(t.nodeName||"").toLowerCase():"#document"}function Lr(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function Vs(t){var e;return(e=(DC(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function DC(t){return Of()?t instanceof Node||t instanceof Lr(t).Node:!1}function xs(t){return Of()?t instanceof Element||t instanceof Lr(t).Element:!1}function Fs(t){return Of()?t instanceof HTMLElement||t instanceof Lr(t).HTMLElement:!1}function aw(t){return!Of()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof Lr(t).ShadowRoot}const hF=new Set(["inline","contents"]);function yd(t){const{overflow:e,overflowX:n,overflowY:r,display:i}=ys(t);return/auto|scroll|overlay|hidden|clip/.test(e+r+n)&&!hF.has(i)}const fF=new Set(["table","td","th"]);function pF(t){return fF.has(Bl(t))}const mF=[":popover-open",":modal"];function Df(t){return mF.some(e=>{try{return t.matches(e)}catch{return!1}})}const gF=["transform","translate","scale","rotate","perspective"],xF=["transform","translate","scale","rotate","perspective","filter"],yF=["paint","layout","strict","content"];function W0(t){const e=U0(),n=xs(t)?ys(t):t;return gF.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)||xF.some(r=>(n.willChange||"").includes(r))||yF.some(r=>(n.contain||"").includes(r))}function vF(t){let e=ba(t);for(;Fs(e)&&!Il(e);){if(W0(e))return e;if(Df(e))return null;e=ba(e)}return null}function U0(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const bF=new Set(["html","body","#document"]);function Il(t){return bF.has(Bl(t))}function ys(t){return Lr(t).getComputedStyle(t)}function Lf(t){return xs(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function ba(t){if(Bl(t)==="html")return t;const e=t.assignedSlot||t.parentNode||aw(t)&&t.host||Vs(t);return aw(e)?e.host:e}function LC(t){const e=ba(t);return Il(e)?t.ownerDocument?t.ownerDocument.body:t.body:Fs(e)&&yd(e)?e:LC(e)}function ld(t,e,n){var r;e===void 0&&(e=[]),n===void 0&&(n=!0);const i=LC(t),a=i===((r=t.ownerDocument)==null?void 0:r.body),o=Lr(i);if(a){const c=Nx(o);return e.concat(o,o.visualViewport||[],yd(i)?i:[],c&&n?ld(c):[])}return e.concat(i,ld(i,[],n))}function Nx(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function _C(t){const e=ys(t);let n=parseFloat(e.width)||0,r=parseFloat(e.height)||0;const i=Fs(t),a=i?t.offsetWidth:n,o=i?t.offsetHeight:r,c=nf(n)!==a||nf(r)!==o;return c&&(n=a,r=o),{width:n,height:r,$:c}}function K0(t){return xs(t)?t:t.contextElement}function wl(t){const e=K0(t);if(!Fs(e))return Ls(1);const n=e.getBoundingClientRect(),{width:r,height:i,$:a}=_C(e);let o=(a?nf(n.width):n.width)/r,c=(a?nf(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!c||!Number.isFinite(c))&&(c=1),{x:o,y:c}}const NF=Ls(0);function zC(t){const e=Lr(t);return!U0()||!e.visualViewport?NF:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function wF(t,e,n){return e===void 0&&(e=!1),!n||e&&n!==Lr(t)?!1:e}function wo(t,e,n,r){e===void 0&&(e=!1),n===void 0&&(n=!1);const i=t.getBoundingClientRect(),a=K0(t);let o=Ls(1);e&&(r?xs(r)&&(o=wl(r)):o=wl(t));const c=wF(a,n,r)?zC(a):Ls(0);let u=(i.left+c.x)/o.x,h=(i.top+c.y)/o.y,f=i.width/o.x,m=i.height/o.y;if(a){const g=Lr(a),y=r&&xs(r)?Lr(r):r;let b=g,j=Nx(b);for(;j&&r&&y!==b;){const w=wl(j),N=j.getBoundingClientRect(),C=ys(j),E=N.left+(j.clientLeft+parseFloat(C.paddingLeft))*w.x,M=N.top+(j.clientTop+parseFloat(C.paddingTop))*w.y;u*=w.x,h*=w.y,f*=w.x,m*=w.y,u+=E,h+=M,b=Lr(j),j=Nx(b)}}return sf({width:f,height:m,x:u,y:h})}function _f(t,e){const n=Lf(t).scrollLeft;return e?e.left+n:wo(Vs(t)).left+n}function $C(t,e){const n=t.getBoundingClientRect(),r=n.left+e.scrollLeft-_f(t,n),i=n.top+e.scrollTop;return{x:r,y:i}}function jF(t){let{elements:e,rect:n,offsetParent:r,strategy:i}=t;const a=i==="fixed",o=Vs(r),c=e?Df(e.floating):!1;if(r===o||c&&a)return n;let u={scrollLeft:0,scrollTop:0},h=Ls(1);const f=Ls(0),m=Fs(r);if((m||!m&&!a)&&((Bl(r)!=="body"||yd(o))&&(u=Lf(r)),Fs(r))){const y=wo(r);h=wl(r),f.x=y.x+r.clientLeft,f.y=y.y+r.clientTop}const g=o&&!m&&!a?$C(o,u):Ls(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 kF(t){return Array.from(t.getClientRects())}function SF(t){const e=Vs(t),n=Lf(t),r=t.ownerDocument.body,i=Rr(e.scrollWidth,e.clientWidth,r.scrollWidth,r.clientWidth),a=Rr(e.scrollHeight,e.clientHeight,r.scrollHeight,r.clientHeight);let o=-n.scrollLeft+_f(t);const c=-n.scrollTop;return ys(r).direction==="rtl"&&(o+=Rr(e.clientWidth,r.clientWidth)-i),{width:i,height:a,x:o,y:c}}const ow=25;function CF(t,e){const n=Lr(t),r=Vs(t),i=n.visualViewport;let a=r.clientWidth,o=r.clientHeight,c=0,u=0;if(i){a=i.width,o=i.height;const f=U0();(!f||f&&e==="fixed")&&(c=i.offsetLeft,u=i.offsetTop)}const h=_f(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,b=Math.abs(r.clientWidth-m.clientWidth-y);b<=ow&&(a-=b)}else h<=ow&&(a+=h);return{width:a,height:o,x:c,y:u}}const EF=new Set(["absolute","fixed"]);function TF(t,e){const n=wo(t,!0,e==="fixed"),r=n.top+t.clientTop,i=n.left+t.clientLeft,a=Fs(t)?wl(t):Ls(1),o=t.clientWidth*a.x,c=t.clientHeight*a.y,u=i*a.x,h=r*a.y;return{width:o,height:c,x:u,y:h}}function lw(t,e,n){let r;if(e==="viewport")r=CF(t,n);else if(e==="document")r=SF(Vs(t));else if(xs(e))r=TF(e,n);else{const i=zC(t);r={x:e.x-i.x,y:e.y-i.y,width:e.width,height:e.height}}return sf(r)}function FC(t,e){const n=ba(t);return n===e||!xs(n)||Il(n)?!1:ys(n).position==="fixed"||FC(n,e)}function MF(t,e){const n=e.get(t);if(n)return n;let r=ld(t,[],!1).filter(c=>xs(c)&&Bl(c)!=="body"),i=null;const a=ys(t).position==="fixed";let o=a?ba(t):t;for(;xs(o)&&!Il(o);){const c=ys(o),u=W0(o);!u&&c.position==="fixed"&&(i=null),(a?!u&&!i:!u&&c.position==="static"&&!!i&&EF.has(i.position)||yd(o)&&!u&&FC(t,o))?r=r.filter(f=>f!==o):i=c,o=ba(o)}return e.set(t,r),r}function AF(t){let{element:e,boundary:n,rootBoundary:r,strategy:i}=t;const o=[...n==="clippingAncestors"?Df(e)?[]:MF(e,this._c):[].concat(n),r],c=o[0],u=o.reduce((h,f)=>{const m=lw(e,f,i);return h.top=Rr(m.top,h.top),h.right=va(m.right,h.right),h.bottom=va(m.bottom,h.bottom),h.left=Rr(m.left,h.left),h},lw(e,c,i));return{width:u.right-u.left,height:u.bottom-u.top,x:u.left,y:u.top}}function IF(t){const{width:e,height:n}=_C(t);return{width:e,height:n}}function RF(t,e,n){const r=Fs(e),i=Vs(e),a=n==="fixed",o=wo(t,!0,a,e);let c={scrollLeft:0,scrollTop:0};const u=Ls(0);function h(){u.x=_f(i)}if(r||!r&&!a)if((Bl(e)!=="body"||yd(i))&&(c=Lf(e)),r){const y=wo(e,!0,a,e);u.x=y.x+e.clientLeft,u.y=y.y+e.clientTop}else i&&h();a&&!r&&i&&h();const f=i&&!r&&!a?$C(i,c):Ls(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 fg(t){return ys(t).position==="static"}function cw(t,e){if(!Fs(t)||ys(t).position==="fixed")return null;if(e)return e(t);let n=t.offsetParent;return Vs(t)===n&&(n=n.ownerDocument.body),n}function BC(t,e){const n=Lr(t);if(Df(t))return n;if(!Fs(t)){let i=ba(t);for(;i&&!Il(i);){if(xs(i)&&!fg(i))return i;i=ba(i)}return n}let r=cw(t,e);for(;r&&pF(r)&&fg(r);)r=cw(r,e);return r&&Il(r)&&fg(r)&&!W0(r)?n:r||vF(t)||n}const PF=async function(t){const e=this.getOffsetParent||BC,n=this.getDimensions,r=await n(t.floating);return{reference:RF(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function OF(t){return ys(t).direction==="rtl"}const DF={convertOffsetParentRelativeRectToViewportRelativeRect:jF,getDocumentElement:Vs,getClippingRect:AF,getOffsetParent:BC,getElementRects:PF,getClientRects:kF,getDimensions:IF,getScale:wl,isElement:xs,isRTL:OF};function VC(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}function LF(t,e){let n=null,r;const i=Vs(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 b=Ku(m),j=Ku(i.clientWidth-(f+g)),w=Ku(i.clientHeight-(m+y)),N=Ku(f),E={rootMargin:-b+"px "+-j+"px "+-w+"px "+-N+"px",threshold:Rr(0,va(1,u))||1};let M=!0;function I(O){const D=O[0].intersectionRatio;if(D!==u){if(!M)return o();D?o(!1,D):r=setTimeout(()=>{o(!1,1e-7)},1e3)}D===1&&!VC(h,t.getBoundingClientRect())&&o(),M=!1}try{n=new IntersectionObserver(I,{...E,root:i.ownerDocument})}catch{n=new IntersectionObserver(I,E)}n.observe(t)}return o(!0),a}function _F(t,e,n,r){r===void 0&&(r={});const{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:o=typeof ResizeObserver=="function",layoutShift:c=typeof IntersectionObserver=="function",animationFrame:u=!1}=r,h=K0(t),f=i||a?[...h?ld(h):[],...ld(e)]:[];f.forEach(N=>{i&&N.addEventListener("scroll",n,{passive:!0}),a&&N.addEventListener("resize",n)});const m=h&&c?LF(h,n):null;let g=-1,y=null;o&&(y=new ResizeObserver(N=>{let[C]=N;C&&C.target===h&&y&&(y.unobserve(e),cancelAnimationFrame(g),g=requestAnimationFrame(()=>{var E;(E=y)==null||E.observe(e)})),n()}),h&&!u&&y.observe(h),y.observe(e));let b,j=u?wo(t):null;u&&w();function w(){const N=wo(t);j&&!VC(j,N)&&n(),j=N,b=requestAnimationFrame(w)}return n(),()=>{var N;f.forEach(C=>{i&&C.removeEventListener("scroll",n),a&&C.removeEventListener("resize",n)}),m==null||m(),(N=y)==null||N.disconnect(),y=null,u&&cancelAnimationFrame(b)}}const zF=lF,$F=cF,FF=iF,BF=uF,VF=aF,dw=sF,HF=dF,WF=(t,e,n)=>{const r=new Map,i={platform:DF,...n},a={...i.platform,_c:r};return rF(t,e,{...i,platform:a})};var UF=typeof document<"u",KF=function(){},rh=UF?v.useLayoutEffect:KF;function af(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,i;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(!af(t[r],e[r]))return!1;return!0}if(i=Object.keys(t),n=i.length,n!==Object.keys(e).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(e,i[r]))return!1;for(r=n;r--!==0;){const a=i[r];if(!(a==="_owner"&&t.$$typeof)&&!af(t[a],e[a]))return!1}return!0}return t!==t&&e!==e}function HC(t){return typeof window>"u"?1:(t.ownerDocument.defaultView||window).devicePixelRatio||1}function uw(t,e){const n=HC(t);return Math.round(e*n)/n}function pg(t){const e=v.useRef(t);return rh(()=>{e.current=t}),e}function qF(t){t===void 0&&(t={});const{placement:e="bottom",strategy:n="absolute",middleware:r=[],platform:i,elements:{reference:a,floating:o}={},transform:c=!0,whileElementsMounted:u,open:h}=t,[f,m]=v.useState({x:0,y:0,strategy:n,placement:e,middlewareData:{},isPositioned:!1}),[g,y]=v.useState(r);af(g,r)||y(r);const[b,j]=v.useState(null),[w,N]=v.useState(null),C=v.useCallback(z=>{z!==O.current&&(O.current=z,j(z))},[]),E=v.useCallback(z=>{z!==D.current&&(D.current=z,N(z))},[]),M=a||b,I=o||w,O=v.useRef(null),D=v.useRef(null),P=v.useRef(f),L=u!=null,_=pg(u),X=pg(i),ne=pg(h),J=v.useCallback(()=>{if(!O.current||!D.current)return;const z={placement:e,strategy:n,middleware:g};X.current&&(z.platform=X.current),WF(O.current,D.current,z).then(ae=>{const G={...ae,isPositioned:ne.current!==!1};U.current&&!af(P.current,G)&&(P.current=G,dd.flushSync(()=>{m(G)}))})},[g,e,n,X,ne]);rh(()=>{h===!1&&P.current.isPositioned&&(P.current.isPositioned=!1,m(z=>({...z,isPositioned:!1})))},[h]);const U=v.useRef(!1);rh(()=>(U.current=!0,()=>{U.current=!1}),[]),rh(()=>{if(M&&(O.current=M),I&&(D.current=I),M&&I){if(_.current)return _.current(M,I,J);J()}},[M,I,J,_,L]);const R=v.useMemo(()=>({reference:O,floating:D,setReference:C,setFloating:E}),[C,E]),F=v.useMemo(()=>({reference:M,floating:I}),[M,I]),re=v.useMemo(()=>{const z={position:n,left:0,top:0};if(!F.floating)return z;const ae=uw(F.floating,f.x),G=uw(F.floating,f.y);return c?{...z,transform:"translate("+ae+"px, "+G+"px)",...HC(F.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:ae,top:G}},[n,c,F.floating,f.x,f.y]);return v.useMemo(()=>({...f,update:J,refs:R,elements:F,floatingStyles:re}),[f,J,R,F,re])}const GF=t=>{function e(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:t,fn(n){const{element:r,padding:i}=typeof t=="function"?t(n):t;return r&&e(r)?r.current!=null?dw({element:r.current,padding:i}).fn(n):{}:r?dw({element:r,padding:i}).fn(n):{}}}},JF=(t,e)=>({...zF(t),options:[t,e]}),YF=(t,e)=>({...$F(t),options:[t,e]}),QF=(t,e)=>({...HF(t),options:[t,e]}),XF=(t,e)=>({...FF(t),options:[t,e]}),ZF=(t,e)=>({...BF(t),options:[t,e]}),eB=(t,e)=>({...VF(t),options:[t,e]}),tB=(t,e)=>({...GF(t),options:[t,e]});var nB="Arrow",WC=v.forwardRef((t,e)=>{const{children:n,width:r=10,height:i=5,...a}=t;return s.jsx(dt.svg,{...a,ref:e,width:r,height:i,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:t.asChild?n:s.jsx("polygon",{points:"0,0 30,0 15,10"})})});WC.displayName=nB;var rB=WC,q0="Popper",[UC,KC]=ka(q0),[sB,qC]=UC(q0),GC=t=>{const{__scopePopper:e,children:n}=t,[r,i]=v.useState(null);return s.jsx(sB,{scope:e,anchor:r,onAnchorChange:i,children:n})};GC.displayName=q0;var JC="PopperAnchor",YC=v.forwardRef((t,e)=>{const{__scopePopper:n,virtualRef:r,...i}=t,a=qC(JC,n),o=v.useRef(null),c=St(e,o),u=v.useRef(null);return v.useEffect(()=>{const h=u.current;u.current=(r==null?void 0:r.current)||o.current,h!==u.current&&a.onAnchorChange(u.current)}),r?null:s.jsx(dt.div,{...i,ref:c})});YC.displayName=JC;var G0="PopperContent",[iB,aB]=UC(G0),QC=v.forwardRef((t,e)=>{var de,he,Ne,Te,Ve,He;const{__scopePopper:n,side:r="bottom",sideOffset:i=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:b,...j}=t,w=qC(G0,n),[N,C]=v.useState(null),E=St(e,gt=>C(gt)),[M,I]=v.useState(null),O=Gx(M),D=(O==null?void 0:O.width)??0,P=(O==null?void 0:O.height)??0,L=r+(a!=="center"?"-"+a:""),_=typeof f=="number"?f:{top:0,right:0,bottom:0,left:0,...f},X=Array.isArray(h)?h:[h],ne=X.length>0,J={padding:_,boundary:X.filter(lB),altBoundary:ne},{refs:U,floatingStyles:R,placement:F,isPositioned:re,middlewareData:z}=qF({strategy:"fixed",placement:L,whileElementsMounted:(...gt)=>_F(...gt,{animationFrame:y==="always"}),elements:{reference:w.anchor},middleware:[JF({mainAxis:i+P,alignmentAxis:o}),u&&YF({mainAxis:!0,crossAxis:!1,limiter:m==="partial"?QF():void 0,...J}),u&&XF({...J}),ZF({...J,apply:({elements:gt,rects:Pt,availableWidth:wn,availableHeight:ht})=>{const{width:At,height:te}=Pt.reference,Pe=gt.floating.style;Pe.setProperty("--radix-popper-available-width",`${wn}px`),Pe.setProperty("--radix-popper-available-height",`${ht}px`),Pe.setProperty("--radix-popper-anchor-width",`${At}px`),Pe.setProperty("--radix-popper-anchor-height",`${te}px`)}}),M&&tB({element:M,padding:c}),cB({arrowWidth:D,arrowHeight:P}),g&&eB({strategy:"referenceHidden",...J})]}),[ae,G]=e4(F),$=ga(b);Xn(()=>{re&&($==null||$())},[re,$]);const H=(de=z.arrow)==null?void 0:de.x,ce=(he=z.arrow)==null?void 0:he.y,W=((Ne=z.arrow)==null?void 0:Ne.centerOffset)!==0,[fe,Q]=v.useState();return Xn(()=>{N&&Q(window.getComputedStyle(N).zIndex)},[N]),s.jsx("div",{ref:U.setFloating,"data-radix-popper-content-wrapper":"",style:{...R,transform:re?R.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:fe,"--radix-popper-transform-origin":[(Te=z.transformOrigin)==null?void 0:Te.x,(Ve=z.transformOrigin)==null?void 0:Ve.y].join(" "),...((He=z.hide)==null?void 0:He.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:s.jsx(iB,{scope:n,placedSide:ae,onArrowChange:I,arrowX:H,arrowY:ce,shouldHideArrow:W,children:s.jsx(dt.div,{"data-side":ae,"data-align":G,...j,ref:E,style:{...j.style,animation:re?void 0:"none"}})})})});QC.displayName=G0;var XC="PopperArrow",oB={top:"bottom",right:"left",bottom:"top",left:"right"},ZC=v.forwardRef(function(e,n){const{__scopePopper:r,...i}=e,a=aB(XC,r),o=oB[a.placedSide];return s.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:s.jsx(rB,{...i,ref:n,style:{...i.style,display:"block"}})})});ZC.displayName=XC;function lB(t){return t!==null}var cB=t=>({name:"transformOrigin",options:t,fn(e){var w,N,C;const{placement:n,rects:r,middlewareData:i}=e,o=((w=i.arrow)==null?void 0:w.centerOffset)!==0,c=o?0:t.arrowWidth,u=o?0:t.arrowHeight,[h,f]=e4(n),m={start:"0%",center:"50%",end:"100%"}[f],g=(((N=i.arrow)==null?void 0:N.x)??0)+c/2,y=(((C=i.arrow)==null?void 0:C.y)??0)+u/2;let b="",j="";return h==="bottom"?(b=o?m:`${g}px`,j=`${-u}px`):h==="top"?(b=o?m:`${g}px`,j=`${r.floating.height+u}px`):h==="right"?(b=`${-u}px`,j=o?m:`${y}px`):h==="left"&&(b=`${r.floating.width+u}px`,j=o?m:`${y}px`),{data:{x:b,y:j}}}});function e4(t){const[e,n="center"]=t.split("-");return[e,n]}var dB=GC,uB=YC,hB=QC,fB=ZC,t4=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"}),pB="VisuallyHidden",mB=v.forwardRef((t,e)=>s.jsx(dt.span,{...t,ref:e,style:{...t4,...t.style}}));mB.displayName=pB;var gB=[" ","Enter","ArrowUp","ArrowDown"],xB=[" ","Enter"],jo="Select",[zf,$f,yB]=Ux(jo),[Vl]=ka(jo,[yB,KC]),Ff=KC(),[vB,Ta]=Vl(jo),[bB,NB]=Vl(jo),n4=t=>{const{__scopeSelect:e,children:n,open:r,defaultOpen:i,onOpenChange:a,value:o,defaultValue:c,onValueChange:u,dir:h,name:f,autoComplete:m,disabled:g,required:y,form:b}=t,j=Ff(e),[w,N]=v.useState(null),[C,E]=v.useState(null),[M,I]=v.useState(!1),O=pf(h),[D,P]=fo({prop:r,defaultProp:i??!1,onChange:a,caller:jo}),[L,_]=fo({prop:o,defaultProp:c,onChange:u,caller:jo}),X=v.useRef(null),ne=w?b||!!w.closest("form"):!0,[J,U]=v.useState(new Set),R=Array.from(J).map(F=>F.props.value).join(";");return s.jsx(dB,{...j,children:s.jsxs(vB,{required:y,scope:e,trigger:w,onTriggerChange:N,valueNode:C,onValueNodeChange:E,valueNodeHasChildren:M,onValueNodeHasChildrenChange:I,contentId:ua(),value:L,onValueChange:_,open:D,onOpenChange:P,dir:O,triggerPointerDownPosRef:X,disabled:g,children:[s.jsx(zf.Provider,{scope:e,children:s.jsx(bB,{scope:t.__scopeSelect,onNativeOptionAdd:v.useCallback(F=>{U(re=>new Set(re).add(F))},[]),onNativeOptionRemove:v.useCallback(F=>{U(re=>{const z=new Set(re);return z.delete(F),z})},[]),children:n})}),ne?s.jsxs(k4,{"aria-hidden":!0,required:y,tabIndex:-1,name:f,autoComplete:m,value:L,onChange:F=>_(F.target.value),disabled:g,form:b,children:[L===void 0?s.jsx("option",{value:""}):null,Array.from(J)]},R):null]})})};n4.displayName=jo;var r4="SelectTrigger",s4=v.forwardRef((t,e)=>{const{__scopeSelect:n,disabled:r=!1,...i}=t,a=Ff(n),o=Ta(r4,n),c=o.disabled||r,u=St(e,o.onTriggerChange),h=$f(n),f=v.useRef("touch"),[m,g,y]=C4(j=>{const w=h().filter(E=>!E.disabled),N=w.find(E=>E.value===o.value),C=E4(w,j,N);C!==void 0&&o.onValueChange(C.value)}),b=j=>{c||(o.onOpenChange(!0),y()),j&&(o.triggerPointerDownPosRef.current={x:Math.round(j.pageX),y:Math.round(j.pageY)})};return s.jsx(uB,{asChild:!0,...a,children:s.jsx(dt.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":S4(o.value)?"":void 0,...i,ref:u,onClick:at(i.onClick,j=>{j.currentTarget.focus(),f.current!=="mouse"&&b(j)}),onPointerDown:at(i.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"&&(b(j),j.preventDefault())}),onKeyDown:at(i.onKeyDown,j=>{const w=m.current!=="";!(j.ctrlKey||j.altKey||j.metaKey)&&j.key.length===1&&g(j.key),!(w&&j.key===" ")&&gB.includes(j.key)&&(b(),j.preventDefault())})})})});s4.displayName=r4;var i4="SelectValue",a4=v.forwardRef((t,e)=>{const{__scopeSelect:n,className:r,style:i,children:a,placeholder:o="",...c}=t,u=Ta(i4,n),{onValueNodeHasChildrenChange:h}=u,f=a!==void 0,m=St(e,u.onValueNodeChange);return Xn(()=>{h(f)},[h,f]),s.jsx(dt.span,{...c,ref:m,style:{pointerEvents:"none"},children:S4(u.value)?s.jsx(s.Fragment,{children:o}):a})});a4.displayName=i4;var wB="SelectIcon",o4=v.forwardRef((t,e)=>{const{__scopeSelect:n,children:r,...i}=t;return s.jsx(dt.span,{"aria-hidden":!0,...i,ref:e,children:r||"▼"})});o4.displayName=wB;var jB="SelectPortal",l4=t=>s.jsx($x,{asChild:!0,...t});l4.displayName=jB;var ko="SelectContent",c4=v.forwardRef((t,e)=>{const n=Ta(ko,t.__scopeSelect),[r,i]=v.useState();if(Xn(()=>{i(new DocumentFragment)},[]),!n.open){const a=r;return a?dd.createPortal(s.jsx(d4,{scope:t.__scopeSelect,children:s.jsx(zf.Slot,{scope:t.__scopeSelect,children:s.jsx("div",{children:t.children})})}),a):null}return s.jsx(u4,{...t,ref:e})});c4.displayName=ko;var us=10,[d4,Ma]=Vl(ko),kB="SelectContentImpl",SB=Jc("SelectContent.RemoveScroll"),u4=v.forwardRef((t,e)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:i,onEscapeKeyDown:a,onPointerDownOutside:o,side:c,sideOffset:u,align:h,alignOffset:f,arrowPadding:m,collisionBoundary:g,collisionPadding:y,sticky:b,hideWhenDetached:j,avoidCollisions:w,...N}=t,C=Ta(ko,n),[E,M]=v.useState(null),[I,O]=v.useState(null),D=St(e,de=>M(de)),[P,L]=v.useState(null),[_,X]=v.useState(null),ne=$f(n),[J,U]=v.useState(!1),R=v.useRef(!1);v.useEffect(()=>{if(E)return Sj(E)},[E]),gj();const F=v.useCallback(de=>{const[he,...Ne]=ne().map(He=>He.ref.current),[Te]=Ne.slice(-1),Ve=document.activeElement;for(const He of de)if(He===Ve||(He==null||He.scrollIntoView({block:"nearest"}),He===he&&I&&(I.scrollTop=0),He===Te&&I&&(I.scrollTop=I.scrollHeight),He==null||He.focus(),document.activeElement!==Ve))return},[ne,I]),re=v.useCallback(()=>F([P,E]),[F,P,E]);v.useEffect(()=>{J&&re()},[J,re]);const{onOpenChange:z,triggerPointerDownPosRef:ae}=C;v.useEffect(()=>{if(E){let de={x:0,y:0};const he=Te=>{var Ve,He;de={x:Math.abs(Math.round(Te.pageX)-(((Ve=ae.current)==null?void 0:Ve.x)??0)),y:Math.abs(Math.round(Te.pageY)-(((He=ae.current)==null?void 0:He.y)??0))}},Ne=Te=>{de.x<=10&&de.y<=10?Te.preventDefault():E.contains(Te.target)||z(!1),document.removeEventListener("pointermove",he),ae.current=null};return ae.current!==null&&(document.addEventListener("pointermove",he),document.addEventListener("pointerup",Ne,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",he),document.removeEventListener("pointerup",Ne,{capture:!0})}}},[E,z,ae]),v.useEffect(()=>{const de=()=>z(!1);return window.addEventListener("blur",de),window.addEventListener("resize",de),()=>{window.removeEventListener("blur",de),window.removeEventListener("resize",de)}},[z]);const[G,$]=C4(de=>{const he=ne().filter(Ve=>!Ve.disabled),Ne=he.find(Ve=>Ve.ref.current===document.activeElement),Te=E4(he,de,Ne);Te&&setTimeout(()=>Te.ref.current.focus())}),H=v.useCallback((de,he,Ne)=>{const Te=!R.current&&!Ne;(C.value!==void 0&&C.value===he||Te)&&(L(de),Te&&(R.current=!0))},[C.value]),ce=v.useCallback(()=>E==null?void 0:E.focus(),[E]),W=v.useCallback((de,he,Ne)=>{const Te=!R.current&&!Ne;(C.value!==void 0&&C.value===he||Te)&&X(de)},[C.value]),fe=r==="popper"?wx:h4,Q=fe===wx?{side:c,sideOffset:u,align:h,alignOffset:f,arrowPadding:m,collisionBoundary:g,collisionPadding:y,sticky:b,hideWhenDetached:j,avoidCollisions:w}:{};return s.jsx(d4,{scope:n,content:E,viewport:I,onViewportChange:O,itemRefCallback:H,selectedItem:P,onItemLeave:ce,itemTextRefCallback:W,focusSelectedItem:re,selectedItemText:_,position:r,isPositioned:J,searchRef:G,children:s.jsx(Fx,{as:SB,allowPinchZoom:!0,children:s.jsx(zx,{asChild:!0,trapped:C.open,onMountAutoFocus:de=>{de.preventDefault()},onUnmountAutoFocus:at(i,de=>{var he;(he=C.trigger)==null||he.focus({preventScroll:!0}),de.preventDefault()}),children:s.jsx(_x,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:de=>de.preventDefault(),onDismiss:()=>C.onOpenChange(!1),children:s.jsx(fe,{role:"listbox",id:C.contentId,"data-state":C.open?"open":"closed",dir:C.dir,onContextMenu:de=>de.preventDefault(),...N,...Q,onPlaced:()=>U(!0),ref:D,style:{display:"flex",flexDirection:"column",outline:"none",...N.style},onKeyDown:at(N.onKeyDown,de=>{const he=de.ctrlKey||de.altKey||de.metaKey;if(de.key==="Tab"&&de.preventDefault(),!he&&de.key.length===1&&$(de.key),["ArrowUp","ArrowDown","Home","End"].includes(de.key)){let Te=ne().filter(Ve=>!Ve.disabled).map(Ve=>Ve.ref.current);if(["ArrowUp","End"].includes(de.key)&&(Te=Te.slice().reverse()),["ArrowUp","ArrowDown"].includes(de.key)){const Ve=de.target,He=Te.indexOf(Ve);Te=Te.slice(He+1)}setTimeout(()=>F(Te)),de.preventDefault()}})})})})})})});u4.displayName=kB;var CB="SelectItemAlignedPosition",h4=v.forwardRef((t,e)=>{const{__scopeSelect:n,onPlaced:r,...i}=t,a=Ta(ko,n),o=Ma(ko,n),[c,u]=v.useState(null),[h,f]=v.useState(null),m=St(e,D=>f(D)),g=$f(n),y=v.useRef(!1),b=v.useRef(!0),{viewport:j,selectedItem:w,selectedItemText:N,focusSelectedItem:C}=o,E=v.useCallback(()=>{if(a.trigger&&a.valueNode&&c&&h&&j&&w&&N){const D=a.trigger.getBoundingClientRect(),P=h.getBoundingClientRect(),L=a.valueNode.getBoundingClientRect(),_=N.getBoundingClientRect();if(a.dir!=="rtl"){const Ve=_.left-P.left,He=L.left-Ve,gt=D.left-He,Pt=D.width+gt,wn=Math.max(Pt,P.width),ht=window.innerWidth-us,At=hh(He,[us,Math.max(us,ht-wn)]);c.style.minWidth=Pt+"px",c.style.left=At+"px"}else{const Ve=P.right-_.right,He=window.innerWidth-L.right-Ve,gt=window.innerWidth-D.right-He,Pt=D.width+gt,wn=Math.max(Pt,P.width),ht=window.innerWidth-us,At=hh(He,[us,Math.max(us,ht-wn)]);c.style.minWidth=Pt+"px",c.style.right=At+"px"}const X=g(),ne=window.innerHeight-us*2,J=j.scrollHeight,U=window.getComputedStyle(h),R=parseInt(U.borderTopWidth,10),F=parseInt(U.paddingTop,10),re=parseInt(U.borderBottomWidth,10),z=parseInt(U.paddingBottom,10),ae=R+F+J+z+re,G=Math.min(w.offsetHeight*5,ae),$=window.getComputedStyle(j),H=parseInt($.paddingTop,10),ce=parseInt($.paddingBottom,10),W=D.top+D.height/2-us,fe=ne-W,Q=w.offsetHeight/2,de=w.offsetTop+Q,he=R+F+de,Ne=ae-he;if(he<=W){const Ve=X.length>0&&w===X[X.length-1].ref.current;c.style.bottom="0px";const He=h.clientHeight-j.offsetTop-j.offsetHeight,gt=Math.max(fe,Q+(Ve?ce:0)+He+re),Pt=he+gt;c.style.height=Pt+"px"}else{const Ve=X.length>0&&w===X[0].ref.current;c.style.top="0px";const gt=Math.max(W,R+j.offsetTop+(Ve?H:0)+Q)+Ne;c.style.height=gt+"px",j.scrollTop=he-W+j.offsetTop}c.style.margin=`${us}px 0`,c.style.minHeight=G+"px",c.style.maxHeight=ne+"px",r==null||r(),requestAnimationFrame(()=>y.current=!0)}},[g,a.trigger,a.valueNode,c,h,j,w,N,a.dir,r]);Xn(()=>E(),[E]);const[M,I]=v.useState();Xn(()=>{h&&I(window.getComputedStyle(h).zIndex)},[h]);const O=v.useCallback(D=>{D&&b.current===!0&&(E(),C==null||C(),b.current=!1)},[E,C]);return s.jsx(TB,{scope:n,contentWrapper:c,shouldExpandOnScrollRef:y,onScrollButtonChange:O,children:s.jsx("div",{ref:u,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:M},children:s.jsx(dt.div,{...i,ref:m,style:{boxSizing:"border-box",maxHeight:"100%",...i.style}})})})});h4.displayName=CB;var EB="SelectPopperPosition",wx=v.forwardRef((t,e)=>{const{__scopeSelect:n,align:r="start",collisionPadding:i=us,...a}=t,o=Ff(n);return s.jsx(hB,{...o,...a,ref:e,align:r,collisionPadding:i,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)"}})});wx.displayName=EB;var[TB,J0]=Vl(ko,{}),jx="SelectViewport",f4=v.forwardRef((t,e)=>{const{__scopeSelect:n,nonce:r,...i}=t,a=Ma(jx,n),o=J0(jx,n),c=St(e,a.onViewportChange),u=v.useRef(0);return s.jsxs(s.Fragment,{children:[s.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}),s.jsx(zf.Slot,{scope:n,children:s.jsx(dt.div,{"data-radix-select-viewport":"",role:"presentation",...i,ref:c,style:{position:"relative",flex:1,overflow:"hidden auto",...i.style},onScroll:at(i.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 b=window.innerHeight-us*2,j=parseFloat(m.style.minHeight),w=parseFloat(m.style.height),N=Math.max(j,w);if(N0?M:0,m.style.justifyContent="flex-end")}}}u.current=f.scrollTop})})})]})});f4.displayName=jx;var p4="SelectGroup",[MB,AB]=Vl(p4),IB=v.forwardRef((t,e)=>{const{__scopeSelect:n,...r}=t,i=ua();return s.jsx(MB,{scope:n,id:i,children:s.jsx(dt.div,{role:"group","aria-labelledby":i,...r,ref:e})})});IB.displayName=p4;var m4="SelectLabel",RB=v.forwardRef((t,e)=>{const{__scopeSelect:n,...r}=t,i=AB(m4,n);return s.jsx(dt.div,{id:i.id,...r,ref:e})});RB.displayName=m4;var of="SelectItem",[PB,g4]=Vl(of),x4=v.forwardRef((t,e)=>{const{__scopeSelect:n,value:r,disabled:i=!1,textValue:a,...o}=t,c=Ta(of,n),u=Ma(of,n),h=c.value===r,[f,m]=v.useState(a??""),[g,y]=v.useState(!1),b=St(e,C=>{var E;return(E=u.itemRefCallback)==null?void 0:E.call(u,C,r,i)}),j=ua(),w=v.useRef("touch"),N=()=>{i||(c.onValueChange(r),c.onOpenChange(!1))};if(r==="")throw new Error("A 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 s.jsx(PB,{scope:n,value:r,disabled:i,textId:j,isSelected:h,onItemTextChange:v.useCallback(C=>{m(E=>E||((C==null?void 0:C.textContent)??"").trim())},[]),children:s.jsx(zf.ItemSlot,{scope:n,value:r,disabled:i,textValue:f,children:s.jsx(dt.div,{role:"option","aria-labelledby":j,"data-highlighted":g?"":void 0,"aria-selected":h&&g,"data-state":h?"checked":"unchecked","aria-disabled":i||void 0,"data-disabled":i?"":void 0,tabIndex:i?void 0:-1,...o,ref:b,onFocus:at(o.onFocus,()=>y(!0)),onBlur:at(o.onBlur,()=>y(!1)),onClick:at(o.onClick,()=>{w.current!=="mouse"&&N()}),onPointerUp:at(o.onPointerUp,()=>{w.current==="mouse"&&N()}),onPointerDown:at(o.onPointerDown,C=>{w.current=C.pointerType}),onPointerMove:at(o.onPointerMove,C=>{var E;w.current=C.pointerType,i?(E=u.onItemLeave)==null||E.call(u):w.current==="mouse"&&C.currentTarget.focus({preventScroll:!0})}),onPointerLeave:at(o.onPointerLeave,C=>{var E;C.currentTarget===document.activeElement&&((E=u.onItemLeave)==null||E.call(u))}),onKeyDown:at(o.onKeyDown,C=>{var M;((M=u.searchRef)==null?void 0:M.current)!==""&&C.key===" "||(xB.includes(C.key)&&N(),C.key===" "&&C.preventDefault())})})})})});x4.displayName=of;var Rc="SelectItemText",y4=v.forwardRef((t,e)=>{const{__scopeSelect:n,className:r,style:i,...a}=t,o=Ta(Rc,n),c=Ma(Rc,n),u=g4(Rc,n),h=NB(Rc,n),[f,m]=v.useState(null),g=St(e,N=>m(N),u.onItemTextChange,N=>{var C;return(C=c.itemTextRefCallback)==null?void 0:C.call(c,N,u.value,u.disabled)}),y=f==null?void 0:f.textContent,b=v.useMemo(()=>s.jsx("option",{value:u.value,disabled:u.disabled,children:y},u.value),[u.disabled,u.value,y]),{onNativeOptionAdd:j,onNativeOptionRemove:w}=h;return Xn(()=>(j(b),()=>w(b)),[j,w,b]),s.jsxs(s.Fragment,{children:[s.jsx(dt.span,{id:u.textId,...a,ref:g}),u.isSelected&&o.valueNode&&!o.valueNodeHasChildren?dd.createPortal(a.children,o.valueNode):null]})});y4.displayName=Rc;var v4="SelectItemIndicator",b4=v.forwardRef((t,e)=>{const{__scopeSelect:n,...r}=t;return g4(v4,n).isSelected?s.jsx(dt.span,{"aria-hidden":!0,...r,ref:e}):null});b4.displayName=v4;var kx="SelectScrollUpButton",N4=v.forwardRef((t,e)=>{const n=Ma(kx,t.__scopeSelect),r=J0(kx,t.__scopeSelect),[i,a]=v.useState(!1),o=St(e,r.onScrollButtonChange);return Xn(()=>{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]),i?s.jsx(j4,{...t,ref:o,onAutoScroll:()=>{const{viewport:c,selectedItem:u}=n;c&&u&&(c.scrollTop=c.scrollTop-u.offsetHeight)}}):null});N4.displayName=kx;var Sx="SelectScrollDownButton",w4=v.forwardRef((t,e)=>{const n=Ma(Sx,t.__scopeSelect),r=J0(Sx,t.__scopeSelect),[i,a]=v.useState(!1),o=St(e,r.onScrollButtonChange);return Xn(()=>{if(n.viewport&&n.isPositioned){let c=function(){const h=u.scrollHeight-u.clientHeight,f=Math.ceil(u.scrollTop)u.removeEventListener("scroll",c)}},[n.viewport,n.isPositioned]),i?s.jsx(j4,{...t,ref:o,onAutoScroll:()=>{const{viewport:c,selectedItem:u}=n;c&&u&&(c.scrollTop=c.scrollTop+u.offsetHeight)}}):null});w4.displayName=Sx;var j4=v.forwardRef((t,e)=>{const{__scopeSelect:n,onAutoScroll:r,...i}=t,a=Ma("SelectScrollButton",n),o=v.useRef(null),c=$f(n),u=v.useCallback(()=>{o.current!==null&&(window.clearInterval(o.current),o.current=null)},[]);return v.useEffect(()=>()=>u(),[u]),Xn(()=>{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]),s.jsx(dt.div,{"aria-hidden":!0,...i,ref:e,style:{flexShrink:0,...i.style},onPointerDown:at(i.onPointerDown,()=>{o.current===null&&(o.current=window.setInterval(r,50))}),onPointerMove:at(i.onPointerMove,()=>{var h;(h=a.onItemLeave)==null||h.call(a),o.current===null&&(o.current=window.setInterval(r,50))}),onPointerLeave:at(i.onPointerLeave,()=>{u()})})}),OB="SelectSeparator",DB=v.forwardRef((t,e)=>{const{__scopeSelect:n,...r}=t;return s.jsx(dt.div,{"aria-hidden":!0,...r,ref:e})});DB.displayName=OB;var Cx="SelectArrow",LB=v.forwardRef((t,e)=>{const{__scopeSelect:n,...r}=t,i=Ff(n),a=Ta(Cx,n),o=Ma(Cx,n);return a.open&&o.position==="popper"?s.jsx(fB,{...i,...r,ref:e}):null});LB.displayName=Cx;var _B="SelectBubbleInput",k4=v.forwardRef(({__scopeSelect:t,value:e,...n},r)=>{const i=v.useRef(null),a=St(r,i),o=qx(e);return v.useEffect(()=>{const c=i.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]),s.jsx(dt.select,{...n,style:{...t4,...n.style},ref:a,defaultValue:e})});k4.displayName=_B;function S4(t){return t===""||t===void 0}function C4(t){const e=ga(t),n=v.useRef(""),r=v.useRef(0),i=v.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=v.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return v.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,i,a]}function E4(t,e,n){const i=e.length>1&&Array.from(e).every(h=>h===e[0])?e[0]:e,a=n?t.indexOf(n):-1;let o=zB(t,Math.max(a,0));i.length===1&&(o=o.filter(h=>h!==n));const u=o.find(h=>h.textValue.toLowerCase().startsWith(i.toLowerCase()));return u!==n?u:void 0}function zB(t,e){return t.map((n,r)=>t[(e+r)%t.length])}var $B=n4,T4=s4,FB=a4,BB=o4,VB=l4,M4=c4,HB=f4,A4=x4,WB=y4,UB=b4,KB=N4,qB=w4;const ul=$B,hl=FB,Xa=v.forwardRef(({className:t,children:e,...n},r)=>s.jsxs(T4,{ref:r,className:Ct("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,s.jsx(BB,{asChild:!0,children:s.jsx(Gc,{className:"h-4 w-4 opacity-50"})})]}));Xa.displayName=T4.displayName;const Za=v.forwardRef(({className:t,children:e,position:n="popper",...r},i)=>s.jsx(VB,{children:s.jsxs(M4,{ref:i,className:Ct("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:[s.jsx(KB,{className:"flex cursor-default items-center justify-center py-1",children:s.jsx(Fw,{className:"h-4 w-4"})}),s.jsx(HB,{className:"p-1",children:e}),s.jsx(qB,{className:"flex cursor-default items-center justify-center py-1",children:s.jsx(Gc,{className:"h-4 w-4"})})]})}));Za.displayName=M4.displayName;const Ir=v.forwardRef(({className:t,children:e,...n},r)=>s.jsxs(A4,{ref:r,className:Ct("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:[s.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:s.jsx(UB,{children:s.jsx(df,{className:"h-4 w-4"})})}),s.jsx(WB,{children:e})]}));Ir.displayName=A4.displayName;function GB(){const[t,e]=v.useState([]),[n,r]=v.useState(!0),[i,a]=v.useState(!1),[o,c]=v.useState(null),[u,h]=v.useState({name:"",appId:"",path:"",sort:0}),[f,m]=v.useState(!1);async function g(){r(!0);try{const N=await Le("/api/admin/linked-miniprograms");if(N!=null&&N.success&&Array.isArray(N.data)){const C=[...N.data].sort((E,M)=>(E.sort??0)-(M.sort??0));e(C)}}catch(N){console.error("Load linked miniprograms error:",N),ie.error("加载失败")}finally{r(!1)}}v.useEffect(()=>{g()},[]);function y(){c(null),h({name:"",appId:"",path:"",sort:t.length}),a(!0)}function b(N){c(N),h({name:N.name,appId:N.appId,path:N.path??"",sort:N.sort??0}),a(!0)}async function j(){const N=u.name.trim(),C=u.appId.trim();if(!N||!C){ie.error("请填写小程序名称和 AppID");return}m(!0);try{if(o){const E=await Mt("/api/admin/linked-miniprograms",{key:o.key,name:N,appId:C,path:u.path.trim(),sort:u.sort});E!=null&&E.success?(ie.success("已更新"),a(!1),g()):ie.error((E==null?void 0:E.error)??"更新失败")}else{const E=await Nt("/api/admin/linked-miniprograms",{name:N,appId:C,path:u.path.trim(),sort:u.sort});E!=null&&E.success?(ie.success("已添加"),a(!1),g()):ie.error((E==null?void 0:E.error)??"添加失败")}}catch{ie.error("操作失败")}finally{m(!1)}}async function w(N){if(confirm(`确定要删除「${N.name}」吗?`))try{const C=await Ps(`/api/admin/linked-miniprograms/${N.key}`);C!=null&&C.success?(ie.success("已删除"),g()):ie.error((C==null?void 0:C.error)??"删除失败")}catch{ie.error("删除失败")}}return s.jsxs("div",{className:"space-y-6",children:[s.jsxs(Me,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(nt,{children:[s.jsxs(rt,{className:"text-white flex items-center gap-2",children:[s.jsx(uo,{className:"w-5 h-5 text-[#38bdac]"}),"关联小程序管理"]}),s.jsx($t,{className:"text-gray-400",children:"添加后生成 32 位密钥,链接标签选择小程序时存密钥;小程序端点击 #标签 时用密钥查 appId 再跳转。需在 app.json 的 navigateToMiniProgramAppIdList 中配置目标 AppID。"})]}),s.jsxs(Ae,{children:[s.jsx("div",{className:"flex justify-end mb-4",children:s.jsxs(ee,{onClick:y,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(dn,{className:"w-4 h-4 mr-2"}),"添加关联小程序"]})}),n?s.jsx("div",{className:"py-12 text-center text-gray-400",children:"加载中..."}):s.jsxs(Zn,{children:[s.jsx(er,{children:s.jsxs(st,{className:"bg-[#0a1628] border-gray-700",children:[s.jsx(je,{className:"text-gray-400",children:"名称"}),s.jsx(je,{className:"text-gray-400",children:"密钥"}),s.jsx(je,{className:"text-gray-400",children:"AppID"}),s.jsx(je,{className:"text-gray-400",children:"路径"}),s.jsx(je,{className:"text-gray-400 w-24",children:"排序"}),s.jsx(je,{className:"text-gray-400 w-32",children:"操作"})]})}),s.jsxs(tr,{children:[t.map(N=>s.jsxs(st,{className:"border-gray-700/50",children:[s.jsx(xe,{className:"text-white",children:N.name}),s.jsx(xe,{className:"text-gray-300 font-mono text-xs",children:N.key}),s.jsx(xe,{className:"text-gray-300 font-mono text-sm",children:N.appId}),s.jsx(xe,{className:"text-gray-400 text-sm",children:N.path||"—"}),s.jsx(xe,{className:"text-gray-300",children:N.sort??0}),s.jsx(xe,{children:s.jsxs("div",{className:"flex gap-2",children:[s.jsx(ee,{variant:"ghost",size:"sm",className:"text-[#38bdac] hover:bg-[#38bdac]/20",onClick:()=>b(N),children:s.jsx(qw,{className:"w-4 h-4"})}),s.jsx(ee,{variant:"ghost",size:"sm",className:"text-red-400 hover:bg-red-500/20",onClick:()=>w(N),children:s.jsx(Bn,{className:"w-4 h-4"})})]})})]},N.key)),t.length===0&&s.jsx(st,{children:s.jsx(xe,{colSpan:6,className:"text-center py-12 text-gray-500",children:"暂无关联小程序,点击「添加关联小程序」开始配置"})})]})]})]})]}),s.jsx(Kt,{open:i,onOpenChange:a,children:s.jsxs(zt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md p-4 gap-3",children:[s.jsxs(qt,{className:"gap-1",children:[s.jsx(Gt,{className:"text-base",children:o?"编辑关联小程序":"添加关联小程序"}),s.jsx(Wx,{className:"text-gray-400 text-xs",children:"填写目标小程序的名称和 AppID,路径可选(为空则打开首页)"})]}),s.jsxs("div",{className:"space-y-3 py-2",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsx(Z,{className:"text-gray-300 text-sm",children:"小程序名称"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white h-8 text-sm",placeholder:"例如:Soul 创业派对",value:u.name,onChange:N=>h(C=>({...C,name:N.target.value}))})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(Z,{className:"text-gray-300 text-sm",children:"AppID"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white font-mono h-8 text-sm",placeholder:"例如:wxb8bbb2b10dec74aa",value:u.appId,onChange:N=>h(C=>({...C,appId:N.target.value}))})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(Z,{className:"text-gray-300 text-sm",children:"路径(可选)"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white h-8 text-sm",placeholder:"例如:pages/index/index",value:u.path,onChange:N=>h(C=>({...C,path:N.target.value}))})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(Z,{className:"text-gray-300 text-sm",children:"排序"}),s.jsx(oe,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white h-8 text-sm w-20",value:u.sort,onChange:N=>h(C=>({...C,sort:parseInt(N.target.value,10)||0}))})]})]}),s.jsxs(hn,{className:"gap-2 pt-1",children:[s.jsx(ee,{variant:"outline",onClick:()=>a(!1),className:"border-gray-600",children:"取消"}),s.jsx(ee,{onClick:j,disabled:f,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:f?"保存中...":"保存"})]})]})})]})}const JB=["一","二","三","四","五","六","七","八","九","十"];function mg(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 YB({parts:t,expandedParts:e,onTogglePart:n,onReorder:r,onReadSection:i,onDeleteSection:a,onAddSectionInPart:o,onAddChapterInPart:c,onDeleteChapter:u,onEditPart:h,onDeletePart:f,onEditChapter:m,selectedSectionIds:g=[],onToggleSectionSelect:y,onShowSectionOrders:b,pinnedSectionIds:j=[]}){const[w,N]=v.useState(null),[C,E]=v.useState(null),M=(_,X)=>(w==null?void 0:w.type)===_&&(w==null?void 0:w.id)===X,I=(_,X)=>(C==null?void 0:C.type)===_&&(C==null?void 0:C.id)===X,O=v.useCallback(()=>{const _=[];for(const X of t)for(const ne of X.chapters)for(const J of ne.sections)_.push({id:J.id,partId:X.id,partTitle:X.title,chapterId:ne.id,chapterTitle:ne.title});return _},[t]),D=v.useCallback(async(_,X,ne,J)=>{var z;_.preventDefault(),_.stopPropagation();const U=_.dataTransfer.getData("text/plain"),R=mg(U);if(!R||R.type===X&&R.id===ne)return;const F=O(),re=new Map(F.map(ae=>[ae.id,ae]));if(R.type==="part"&&X==="part"){const ae=t.map(W=>W.id),G=ae.indexOf(R.id),$=ae.indexOf(ne);if(G===-1||$===-1)return;const H=[...ae];H.splice(G,1),H.splice(G<$?$-1:$,0,R.id);const ce=[];for(const W of H){const fe=t.find(Q=>Q.id===W);if(fe)for(const Q of fe.chapters)for(const de of Q.sections){const he=re.get(de.id);he&&ce.push(he)}}await r(ce);return}if(R.type==="chapter"&&(X==="chapter"||X==="section"||X==="part")){const ae=t.find(he=>he.chapters.some(Ne=>Ne.id===R.id)),G=ae==null?void 0:ae.chapters.find(he=>he.id===R.id);if(!ae||!G)return;let $,H,ce=null;if(X==="section"){const he=re.get(ne);if(!he)return;$=he.partId,H=he.partTitle,ce=ne}else if(X==="chapter"){const he=t.find(Ve=>Ve.chapters.some(He=>He.id===ne)),Ne=he==null?void 0:he.chapters.find(Ve=>Ve.id===ne);if(!he||!Ne)return;$=he.id,H=he.title;const Te=F.filter(Ve=>Ve.chapterId===ne).pop();ce=(Te==null?void 0:Te.id)??null}else{const he=t.find(Te=>Te.id===ne);if(!he||!he.chapters[0])return;$=he.id,H=he.title;const Ne=F.filter(Te=>Te.partId===he.id&&Te.chapterId===he.chapters[0].id);ce=((z=Ne[Ne.length-1])==null?void 0:z.id)??null}const W=G.sections.map(he=>he.id),fe=F.filter(he=>!W.includes(he.id));let Q=fe.length;if(ce){const he=fe.findIndex(Ne=>Ne.id===ce);he>=0&&(Q=he+1)}const de=W.map(he=>({...re.get(he),partId:$,partTitle:H,chapterId:G.id,chapterTitle:G.title}));await r([...fe.slice(0,Q),...de,...fe.slice(Q)]);return}if(R.type==="section"&&(X==="section"||X==="chapter"||X==="part")){if(!J)return;const{partId:ae,partTitle:G,chapterId:$,chapterTitle:H}=J;let ce;if(X==="section")ce=F.findIndex(Ne=>Ne.id===ne);else if(X==="chapter"){const Ne=F.filter(Te=>Te.chapterId===ne).pop();ce=Ne?F.findIndex(Te=>Te.id===Ne.id)+1:F.length}else{const Ne=t.find(He=>He.id===ne);if(!(Ne!=null&&Ne.chapters[0]))return;const Te=F.filter(He=>He.partId===Ne.id&&He.chapterId===Ne.chapters[0].id),Ve=Te[Te.length-1];ce=Ve?F.findIndex(He=>He.id===Ve.id)+1:0}const W=F.findIndex(Ne=>Ne.id===R.id);if(W===-1)return;const fe=F.filter(Ne=>Ne.id!==R.id),Q=W({onDragEnter:J=>{J.preventDefault(),J.stopPropagation(),J.dataTransfer.dropEffect="move",E({type:_,id:X})},onDragOver:J=>{J.preventDefault(),J.stopPropagation(),J.dataTransfer.dropEffect="move",E({type:_,id:X})},onDragLeave:()=>E(null),onDrop:J=>{E(null);const U=mg(J.dataTransfer.getData("text/plain"));if(U&&!(_==="section"&&U.type==="section"&&U.id===X))if(_==="part")if(U.type==="part")D(J,"part",X);else{const R=t.find(re=>re.id===X);(R==null?void 0:R.chapters[0])&&ne&&D(J,"part",X,ne)}else _==="chapter"&&ne?(U.type==="section"||U.type==="chapter")&&D(J,"chapter",X,ne):_==="section"&&ne&&D(J,"section",X,ne)}}),L=_=>JB[_]??String(_+1);return s.jsx("div",{className:"space-y-3",children:t.map((_,X)=>{var G,$,H,ce;const ne=_.title==="序言"||_.title.includes("序言"),J=_.title==="尾声"||_.title.includes("尾声"),U=_.title==="附录"||_.title.includes("附录"),R=I("part",_.id),F=e.includes(_.id),re=_.chapters.length,z=_.chapters.reduce((W,fe)=>W+fe.sections.length,0);if(ne&&_.chapters.length===1&&_.chapters[0].sections.length===1){const W=_.chapters[0].sections[0],fe=I("section",W.id),Q={partId:_.id,partTitle:_.title,chapterId:_.chapters[0].id,chapterTitle:_.chapters[0].title};return s.jsxs("div",{draggable:!0,onDragStart:de=>{de.stopPropagation(),de.dataTransfer.setData("text/plain","section:"+W.id),de.dataTransfer.effectAllowed="move",N({type:"section",id:W.id})},onDragEnd:()=>{N(null),E(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] ${fe?"bg-[#38bdac]/15 ring-2 ring-[#38bdac]/50":""} ${M("section",W.id)?"opacity-60 scale-[0.98] ring-2 ring-[#38bdac]":""}`,...P("section",W.id,Q),children:[s.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0 select-none",children:[s.jsx(oi,{className:"w-5 h-5 text-gray-500 shrink-0 opacity-60"}),y&&s.jsx("label",{className:"shrink-0 flex items-center",onClick:de=>de.stopPropagation(),children:s.jsx("input",{type:"checkbox",checked:g.includes(W.id),onChange:()=>y(W.id),className:"w-4 h-4 rounded border-gray-600 bg-[#0a1628] text-[#38bdac] focus:ring-[#38bdac]"})}),s.jsx("div",{className:"w-8 h-8 rounded-lg bg-gray-600/50 flex items-center justify-center shrink-0",children:s.jsx(ps,{className:"w-4 h-4 text-gray-400"})}),s.jsxs("span",{className:"font-medium text-gray-200 truncate",children:[_.chapters[0].title," | ",W.title]}),j.includes(W.id)&&s.jsx("span",{title:"已置顶",children:s.jsx(ml,{className:"w-3.5 h-3.5 text-amber-400 fill-amber-400 shrink-0"})})]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",onMouseDown:de=>de.stopPropagation(),onClick:de=>de.stopPropagation(),children:[W.price===0||W.isFree?s.jsx("span",{className:"px-2 py-1 bg-[#38bdac]/20 text-[#38bdac] text-[10px] font-medium rounded",children:"免费"}):s.jsxs("span",{className:"text-xs text-gray-500",children:["¥",W.price]}),s.jsxs("span",{className:"text-[10px] text-gray-500",children:["点击 ",W.clickCount??0," · 付款 ",W.payCount??0]}),s.jsxs("span",{className:"text-[10px] text-amber-400/90",title:"热度积分与排名",children:["热度 ",(W.hotScore??0).toFixed(1)," · 第",W.hotRank&&W.hotRank>0?W.hotRank:"-","名"]}),b&&s.jsx(ee,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>b(W),className:"text-[10px] text-gray-500 hover:text-[#38bdac] h-7 px-1.5",children:"付款记录"}),s.jsxs("div",{className:"flex gap-1",children:[s.jsx(ee,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>i(W),className:"text-gray-500 hover:text-[#38bdac] h-7 px-2",title:"编辑",children:s.jsx(_t,{className:"w-3.5 h-3.5"})}),s.jsx(ee,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>a(W),className:"text-gray-500 hover:text-red-400 h-7 px-2",children:s.jsx(Bn,{className:"w-3.5 h-3.5"})})]})]})]},_.id)}if(_.title==="2026每日派对干货"||_.title.includes("2026每日派对干货")){const W=I("part",_.id);return s.jsxs("div",{className:`rounded-xl border overflow-hidden transition-all duration-200 ${W?"border-[#38bdac] ring-2 ring-[#38bdac]/40 bg-[#38bdac]/5":"border-gray-700/50 bg-[#1C1C1E]"}`,...P("part",_.id,{partId:_.id,partTitle:_.title,chapterId:((G=_.chapters[0])==null?void 0:G.id)??"",chapterTitle:(($=_.chapters[0])==null?void 0:$.title)??""}),children:[s.jsxs("div",{draggable:!0,onDragStart:fe=>{fe.stopPropagation(),fe.dataTransfer.setData("text/plain","part:"+_.id),fe.dataTransfer.effectAllowed="move",N({type:"part",id:_.id})},onDragEnd:()=>{N(null),E(null)},className:`flex items-center justify-between p-4 cursor-grab active:cursor-grabbing select-none transition-all duration-200 ${M("part",_.id)?"opacity-60 scale-[0.98] ring-2 ring-[#38bdac]":"hover:bg-[#162840]/50"}`,onClick:()=>n(_.id),children:[s.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[s.jsx(oi,{className:"w-5 h-5 text-gray-500 shrink-0 opacity-60"}),s.jsx("div",{className:"w-10 h-10 rounded-xl bg-[#38bdac]/80 flex items-center justify-center text-white font-bold shrink-0",children:"派"}),s.jsxs("div",{children:[s.jsx("h3",{className:"font-bold text-white text-base",children:_.title}),s.jsxs("p",{className:"text-xs text-gray-500 mt-0.5",children:["共 ",z," 节"]})]})]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",onMouseDown:fe=>fe.stopPropagation(),onClick:fe=>fe.stopPropagation(),children:[o&&s.jsx(ee,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>o(_),className:"text-gray-500 hover:text-[#38bdac] h-7 px-2",title:"在本篇下新增章节",children:s.jsx(dn,{className:"w-3.5 h-3.5"})}),h&&s.jsx(ee,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>h(_),className:"text-gray-500 hover:text-[#38bdac] h-7 px-2",title:"编辑篇名",children:s.jsx(_t,{className:"w-3.5 h-3.5"})}),f&&s.jsx(ee,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>f(_),className:"text-gray-500 hover:text-red-400 h-7 px-2",title:"删除本篇",children:s.jsx(Bn,{className:"w-3.5 h-3.5"})}),s.jsxs("span",{className:"text-xs text-gray-500",children:[re,"章"]}),F?s.jsx(Gc,{className:"w-5 h-5 text-gray-500"}):s.jsx(fl,{className:"w-5 h-5 text-gray-500"})]})]}),F&&_.chapters.length>0&&s.jsx("div",{className:"border-t border-gray-700/50 pl-4 pr-4 pb-4 pt-3 space-y-4",children:_.chapters.map(fe=>s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center gap-2 w-full",children:[s.jsx("p",{className:"text-xs text-gray-500 pb-1 flex-1",children:fe.title}),s.jsxs("div",{className:"flex gap-0.5 shrink-0",onClick:Q=>Q.stopPropagation(),children:[m&&s.jsx(ee,{variant:"ghost",size:"sm",onClick:()=>m(_,fe),className:"text-gray-500 hover:text-[#38bdac] h-7 px-1.5",title:"编辑章节名称",children:s.jsx(_t,{className:"w-3.5 h-3.5"})}),c&&s.jsx(ee,{variant:"ghost",size:"sm",onClick:()=>c(_),className:"text-gray-500 hover:text-[#38bdac] h-7 px-1.5",title:"新增第X章",children:s.jsx(dn,{className:"w-3.5 h-3.5"})}),u&&s.jsx(ee,{variant:"ghost",size:"sm",onClick:()=>u(_,fe),className:"text-gray-500 hover:text-red-400 h-7 px-1.5",title:"删除本章",children:s.jsx(Bn,{className:"w-3.5 h-3.5"})})]})]}),s.jsx("div",{className:"space-y-1 pl-2",children:fe.sections.map(Q=>{const de=I("section",Q.id);return s.jsxs("div",{draggable:!0,onDragStart:he=>{he.stopPropagation(),he.dataTransfer.setData("text/plain","section:"+Q.id),he.dataTransfer.effectAllowed="move",N({type:"section",id:Q.id})},onDragEnd:()=>{N(null),E(null)},onClick:()=>i(Q),className:`flex items-center justify-between py-2 px-3 rounded-lg min-h-[40px] cursor-pointer select-none transition-all duration-200 ${de?"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]":""}`,...P("section",Q.id,{partId:_.id,partTitle:_.title,chapterId:fe.id,chapterTitle:fe.title}),children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[s.jsx(oi,{className:"w-4 h-4 text-gray-500 shrink-0 opacity-50"}),y&&s.jsx("label",{className:"shrink-0 flex items-center",onClick:he=>he.stopPropagation(),children:s.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]"})}),s.jsxs("span",{className:"text-sm text-gray-200 truncate",children:[Q.id," ",Q.title]}),j.includes(Q.id)&&s.jsx("span",{title:"已置顶",children:s.jsx(ml,{className:"w-3 h-3 text-amber-400 fill-amber-400 shrink-0"})})]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",onClick:he=>he.stopPropagation(),children:[s.jsxs("span",{className:"text-[10px] text-gray-500",children:["点击 ",Q.clickCount??0," · 付款 ",Q.payCount??0]}),s.jsxs("span",{className:"text-[10px] text-amber-400/90",title:"热度积分与排名",children:["热度 ",(Q.hotScore??0).toFixed(1)," · 第",Q.hotRank&&Q.hotRank>0?Q.hotRank:"-","名"]}),b&&s.jsx(ee,{variant:"ghost",size:"sm",onClick:()=>b(Q),className:"text-[10px] text-gray-500 hover:text-[#38bdac] h-7 px-1.5",children:"付款记录"}),s.jsx(ee,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>i(Q),className:"text-gray-500 hover:text-[#38bdac] h-7 px-1.5",title:"编辑",children:s.jsx(_t,{className:"w-3.5 h-3.5"})}),s.jsx(ee,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>a(Q),className:"text-gray-500 hover:text-red-400 h-7 px-1.5",children:s.jsx(Bn,{className:"w-3.5 h-3.5"})})]})]},Q.id)})})]},fe.id))})]},_.id)}if(U)return s.jsxs("div",{className:"rounded-xl border border-gray-700/50 bg-[#1C1C1E] p-5",children:[s.jsx("h3",{className:"text-sm font-medium text-gray-400 mb-4",children:"附录"}),s.jsx("div",{className:"space-y-3",children:_.chapters.map((W,fe)=>W.sections.length>0?W.sections.map(Q=>{const de=I("section",Q.id);return s.jsxs("div",{draggable:!0,onDragStart:he=>{he.stopPropagation(),he.dataTransfer.setData("text/plain","section:"+Q.id),he.dataTransfer.effectAllowed="move",N({type:"section",id:Q.id})},onDragEnd:()=>{N(null),E(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 ${de?"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]":""}`,...P("section",Q.id,{partId:_.id,partTitle:_.title,chapterId:W.id,chapterTitle:W.title}),children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[s.jsx(oi,{className:"w-4 h-4 text-gray-500 shrink-0 opacity-50"}),y&&s.jsx("label",{className:"shrink-0 flex items-center",onClick:he=>he.stopPropagation(),children:s.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]"})}),s.jsxs("span",{className:"text-sm text-gray-300 truncate",children:["附录",fe+1," | ",W.title," | ",Q.title]}),j.includes(Q.id)&&s.jsx("span",{title:"已置顶",children:s.jsx(ml,{className:"w-3 h-3 text-amber-400 fill-amber-400 shrink-0"})})]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[s.jsxs("span",{className:"text-[10px] text-gray-500",children:["点击 ",Q.clickCount??0," · 付款 ",Q.payCount??0]}),s.jsxs("span",{className:"text-[10px] text-amber-400/90",title:"热度积分与排名",children:["热度 ",(Q.hotScore??0).toFixed(1)," · 第",Q.hotRank&&Q.hotRank>0?Q.hotRank:"-","名"]}),b&&s.jsx(ee,{variant:"ghost",size:"sm",onClick:()=>b(Q),className:"text-[10px] text-gray-500 hover:text-[#38bdac] h-7 px-1.5",children:"付款记录"}),s.jsxs("div",{className:"flex gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[s.jsx(ee,{variant:"ghost",size:"sm",onClick:()=>i(Q),className:"text-gray-500 hover:text-[#38bdac] h-7 px-1.5",title:"编辑",children:s.jsx(_t,{className:"w-3.5 h-3.5"})}),s.jsx(ee,{variant:"ghost",size:"sm",onClick:()=>a(Q),className:"text-gray-500 hover:text-red-400 h-7 px-1.5",children:s.jsx(Bn,{className:"w-3.5 h-3.5"})})]})]}),s.jsx(fl,{className:"w-4 h-4 text-gray-500 shrink-0"})]},Q.id)}):s.jsxs("div",{className:"flex justify-between items-center py-2 select-none hover:bg-[#162840]/50 rounded px-2 -mx-2",children:[s.jsxs("span",{className:"text-sm text-gray-500",children:["附录",fe+1," | ",W.title,"(空)"]}),s.jsx(fl,{className:"w-4 h-4 text-gray-500 shrink-0"})]},W.id))})]},_.id);if(J&&_.chapters.length===1&&_.chapters[0].sections.length===1){const W=_.chapters[0].sections[0],fe=I("section",W.id),Q={partId:_.id,partTitle:_.title,chapterId:_.chapters[0].id,chapterTitle:_.chapters[0].title};return s.jsxs("div",{draggable:!0,onDragStart:de=>{de.stopPropagation(),de.dataTransfer.setData("text/plain","section:"+W.id),de.dataTransfer.effectAllowed="move",N({type:"section",id:W.id})},onDragEnd:()=>{N(null),E(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] ${fe?"bg-[#38bdac]/15 ring-2 ring-[#38bdac]/50":""} ${M("section",W.id)?"opacity-60 scale-[0.98] ring-2 ring-[#38bdac]":""}`,...P("section",W.id,Q),children:[s.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0 select-none",children:[s.jsx(oi,{className:"w-5 h-5 text-gray-500 shrink-0 opacity-60"}),y&&s.jsx("label",{className:"shrink-0 flex items-center",onClick:de=>de.stopPropagation(),children:s.jsx("input",{type:"checkbox",checked:g.includes(W.id),onChange:()=>y(W.id),className:"w-4 h-4 rounded border-gray-600 bg-[#0a1628] text-[#38bdac] focus:ring-[#38bdac]"})}),s.jsx("div",{className:"w-8 h-8 rounded-lg bg-gray-600/50 flex items-center justify-center shrink-0",children:s.jsx(ps,{className:"w-4 h-4 text-gray-400"})}),s.jsxs("span",{className:"font-medium text-gray-200 truncate",children:[_.chapters[0].title," | ",W.title]})]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",onMouseDown:de=>de.stopPropagation(),onClick:de=>de.stopPropagation(),children:[W.price===0||W.isFree?s.jsx("span",{className:"px-2 py-1 bg-[#38bdac]/20 text-[#38bdac] text-[10px] font-medium rounded",children:"免费"}):s.jsxs("span",{className:"text-xs text-gray-500",children:["¥",W.price]}),s.jsxs("span",{className:"text-[10px] text-gray-500",children:["点击 ",W.clickCount??0," · 付款 ",W.payCount??0]}),s.jsxs("span",{className:"text-[10px] text-amber-400/90",title:"热度积分与排名",children:["热度 ",(W.hotScore??0).toFixed(1)," · 第",W.hotRank&&W.hotRank>0?W.hotRank:"-","名"]}),b&&s.jsx(ee,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>b(W),className:"text-[10px] text-gray-500 hover:text-[#38bdac] h-7 px-1.5",children:"付款记录"}),s.jsxs("div",{className:"flex gap-1",children:[s.jsx(ee,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>i(W),className:"text-gray-500 hover:text-[#38bdac] h-7 px-2",title:"编辑",children:s.jsx(_t,{className:"w-3.5 h-3.5"})}),s.jsx(ee,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>a(W),className:"text-gray-500 hover:text-red-400 h-7 px-2",children:s.jsx(Bn,{className:"w-3.5 h-3.5"})})]})]})]},_.id)}return J?s.jsxs("div",{className:"rounded-xl border border-gray-700/50 bg-[#1C1C1E] p-5",children:[s.jsx("h3",{className:"text-sm font-medium text-gray-400 mb-4",children:"尾声"}),s.jsx("div",{className:"space-y-3",children:_.chapters.map(W=>W.sections.map(fe=>{const Q=I("section",fe.id);return s.jsxs("div",{draggable:!0,onDragStart:de=>{de.stopPropagation(),de.dataTransfer.setData("text/plain","section:"+fe.id),de.dataTransfer.effectAllowed="move",N({type:"section",id:fe.id})},onDragEnd:()=>{N(null),E(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",fe.id)?"opacity-60 scale-[0.98] ring-2 ring-[#38bdac]":""}`,...P("section",fe.id,{partId:_.id,partTitle:_.title,chapterId:W.id,chapterTitle:W.title}),children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[s.jsx(oi,{className:"w-4 h-4 text-gray-500 shrink-0 opacity-50"}),y&&s.jsx("label",{className:"shrink-0 flex items-center",onClick:de=>de.stopPropagation(),children:s.jsx("input",{type:"checkbox",checked:g.includes(fe.id),onChange:()=>y(fe.id),className:"w-4 h-4 rounded border-gray-600 bg-[#0a1628] text-[#38bdac] focus:ring-[#38bdac]"})}),s.jsxs("span",{className:"text-sm text-gray-300",children:[W.title," | ",fe.title]})]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[s.jsxs("span",{className:"text-[10px] text-gray-500",children:["点击 ",fe.clickCount??0," · 付款 ",fe.payCount??0]}),s.jsxs("span",{className:"text-[10px] text-amber-400/90",title:"热度积分与排名",children:["热度 ",(fe.hotScore??0).toFixed(1)," · 第",fe.hotRank&&fe.hotRank>0?fe.hotRank:"-","名"]}),b&&s.jsx(ee,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>b(fe),className:"text-[10px] text-gray-500 hover:text-[#38bdac] h-7 px-1.5",children:"付款记录"}),s.jsxs("div",{className:"flex gap-1",children:[s.jsx(ee,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>i(fe),className:"text-gray-500 hover:text-[#38bdac] h-7 px-2",title:"编辑",children:s.jsx(_t,{className:"w-3.5 h-3.5"})}),s.jsx(ee,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>a(fe),className:"text-gray-500 hover:text-red-400 h-7 px-2",children:s.jsx(Bn,{className:"w-3.5 h-3.5"})})]})]})]},fe.id)}))})]},_.id):s.jsxs("div",{className:`rounded-xl border bg-[#1C1C1E] overflow-hidden transition-all duration-200 ${R?"border-[#38bdac] ring-2 ring-[#38bdac]/40 bg-[#38bdac]/5":"border-gray-700/50"}`,...P("part",_.id,{partId:_.id,partTitle:_.title,chapterId:((H=_.chapters[0])==null?void 0:H.id)??"",chapterTitle:((ce=_.chapters[0])==null?void 0:ce.title)??""}),children:[s.jsxs("div",{draggable:!0,onDragStart:W=>{W.stopPropagation(),W.dataTransfer.setData("text/plain","part:"+_.id),W.dataTransfer.effectAllowed="move",N({type:"part",id:_.id})},onDragEnd:()=>{N(null),E(null)},className:`flex items-center justify-between p-4 cursor-grab active:cursor-grabbing select-none transition-all duration-200 ${M("part",_.id)?"opacity-60 scale-[0.98] ring-2 ring-[#38bdac] rounded-xl shadow-xl shadow-[#38bdac]/20":"hover:bg-[#162840]/50"}`,onClick:()=>n(_.id),children:[s.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[s.jsx(oi,{className:"w-5 h-5 text-gray-500 shrink-0 opacity-60"}),s.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:L(X)}),s.jsxs("div",{children:[s.jsx("h3",{className:"font-bold text-white text-base",children:_.title}),s.jsxs("p",{className:"text-xs text-gray-500 mt-0.5",children:["共 ",z," 节"]})]})]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",onMouseDown:W=>W.stopPropagation(),onClick:W=>W.stopPropagation(),children:[o&&s.jsx(ee,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>o(_),className:"text-gray-500 hover:text-[#38bdac] h-7 px-2",title:"在本篇下新增章节",children:s.jsx(dn,{className:"w-3.5 h-3.5"})}),h&&s.jsx(ee,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>h(_),className:"text-gray-500 hover:text-[#38bdac] h-7 px-2",title:"编辑篇名",children:s.jsx(_t,{className:"w-3.5 h-3.5"})}),f&&s.jsx(ee,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>f(_),className:"text-gray-500 hover:text-red-400 h-7 px-2",title:"删除本篇",children:s.jsx(Bn,{className:"w-3.5 h-3.5"})}),s.jsxs("span",{className:"text-xs text-gray-500",children:[re,"章"]}),F?s.jsx(Gc,{className:"w-5 h-5 text-gray-500"}):s.jsx(fl,{className:"w-5 h-5 text-gray-500"})]})]}),F&&s.jsx("div",{className:"border-t border-gray-700/50 pl-4 pr-4 pb-4 pt-3 space-y-4",children:_.chapters.map(W=>{const fe=I("chapter",W.id);return s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center gap-2 w-full",children:[s.jsxs("div",{draggable:!0,onDragStart:Q=>{Q.stopPropagation(),Q.dataTransfer.setData("text/plain","chapter:"+W.id),Q.dataTransfer.effectAllowed="move",N({type:"chapter",id:W.id})},onDragEnd:()=>{N(null),E(null)},onDragEnter:Q=>{Q.preventDefault(),Q.stopPropagation(),Q.dataTransfer.dropEffect="move",E({type:"chapter",id:W.id})},onDragOver:Q=>{Q.preventDefault(),Q.stopPropagation(),Q.dataTransfer.dropEffect="move",E({type:"chapter",id:W.id})},onDragLeave:()=>E(null),onDrop:Q=>{E(null);const de=mg(Q.dataTransfer.getData("text/plain"));if(!de)return;const he={partId:_.id,partTitle:_.title,chapterId:W.id,chapterTitle:W.title};(de.type==="section"||de.type==="chapter")&&D(Q,"chapter",W.id,he)},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 ${fe?"bg-[#38bdac]/15 ring-1 ring-[#38bdac]/50":""} ${M("chapter",W.id)?"opacity-60 scale-[0.98] ring-2 ring-[#38bdac]":"hover:bg-[#162840]/30"}`,children:[s.jsx(oi,{className:"w-4 h-4 text-gray-500 shrink-0 opacity-50"}),s.jsx("p",{className:"text-xs text-gray-500 pb-1 flex-1",children:W.title})]}),s.jsxs("div",{className:"flex gap-0.5 shrink-0",onClick:Q=>Q.stopPropagation(),children:[m&&s.jsx(ee,{variant:"ghost",size:"sm",onClick:()=>m(_,W),className:"text-gray-500 hover:text-[#38bdac] h-7 px-1.5",title:"编辑章节名称",children:s.jsx(_t,{className:"w-3.5 h-3.5"})}),c&&s.jsx(ee,{variant:"ghost",size:"sm",onClick:()=>c(_),className:"text-gray-500 hover:text-[#38bdac] h-7 px-1.5",title:"新增第X章",children:s.jsx(dn,{className:"w-3.5 h-3.5"})}),u&&s.jsx(ee,{variant:"ghost",size:"sm",onClick:()=>u(_,W),className:"text-gray-500 hover:text-red-400 h-7 px-1.5",title:"删除本章",children:s.jsx(Bn,{className:"w-3.5 h-3.5"})})]})]}),s.jsx("div",{className:"space-y-1 pl-2",children:W.sections.map(Q=>{const de=I("section",Q.id);return s.jsxs("div",{draggable:!0,onDragStart:he=>{he.stopPropagation(),he.dataTransfer.setData("text/plain","section:"+Q.id),he.dataTransfer.effectAllowed="move",N({type:"section",id:Q.id})},onDragEnd:()=>{N(null),E(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 ${de?"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"}`,...P("section",Q.id,{partId:_.id,partTitle:_.title,chapterId:W.id,chapterTitle:W.title}),children:[s.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[y&&s.jsx("label",{className:"shrink-0 flex items-center",onClick:he=>he.stopPropagation(),children:s.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]"})}),s.jsx(oi,{className:"w-4 h-4 text-gray-500 shrink-0 opacity-50"}),s.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"}`}),s.jsxs("span",{className:"text-sm text-gray-200 truncate",children:[Q.id," ",Q.title]}),j.includes(Q.id)&&s.jsx("span",{title:"已置顶",children:s.jsx(ml,{className:"w-3 h-3 text-amber-400 fill-amber-400 shrink-0"})})]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",onMouseDown:he=>he.stopPropagation(),onClick:he=>he.stopPropagation(),children:[Q.isNew&&s.jsx("span",{className:"px-2 py-1 bg-[#38bdac]/20 text-[#38bdac] text-[10px] font-medium rounded",children:"NEW"}),Q.price===0||Q.isFree?s.jsx("span",{className:"px-2 py-1 bg-[#38bdac]/20 text-[#38bdac] text-[10px] font-medium rounded",children:"免费"}):s.jsxs("span",{className:"text-xs text-gray-500",children:["¥",Q.price]}),s.jsxs("span",{className:"text-[10px] text-gray-500",title:"点击次数 · 付款笔数",children:["点击 ",Q.clickCount??0," · 付款 ",Q.payCount??0]}),s.jsxs("span",{className:"text-[10px] text-amber-400/90",title:"热度积分与排名",children:["热度 ",(Q.hotScore??0).toFixed(1)," · 第",Q.hotRank&&Q.hotRank>0?Q.hotRank:"-","名"]}),b&&s.jsx(ee,{variant:"ghost",size:"sm",onClick:()=>b(Q),className:"text-[10px] text-gray-500 hover:text-[#38bdac] h-7 px-1.5 shrink-0",children:"付款记录"}),s.jsxs("div",{className:"flex gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[s.jsx(ee,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>i(Q),className:"text-gray-500 hover:text-[#38bdac] h-7 px-1.5",title:"编辑",children:s.jsx(_t,{className:"w-3.5 h-3.5"})}),s.jsx(ee,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>a(Q),className:"text-gray-500 hover:text-red-400 h-7 px-1.5",children:s.jsx(Bn,{className:"w-3.5 h-3.5"})})]})]})]},Q.id)})})]},W.id)})})]},_.id)})})}function QB(t){var i;const e=new URLSearchParams;e.set("page",String(t.page)),e.set("limit",String(t.limit)),(i=t==null?void 0:t.keyword)!=null&&i.trim()&&e.set("keyword",t.keyword.trim());const n=e.toString(),r=n?`/api/admin/ckb/devices?${n}`:"/api/admin/ckb/devices";return Le(r)}function XB(t){return Le(`/api/db/person?personId=${encodeURIComponent(t)}`)}const I4=11,hw={personId:"",name:"",label:"",sceneId:I4,ckbApiKey:"",greeting:"你好,请通过",tips:"请注意消息,稍后加你微信",remarkType:"phone",remarkFormat:"",addFriendInterval:1,startTime:"09:00",endTime:"18:00",deviceGroups:""};function ZB({open:t,onOpenChange:e,editingPerson:n,onSubmit:r}){const i=!!n,[a,o]=v.useState(hw),[c,u]=v.useState(!1),[h,f]=v.useState(!1),[m,g]=v.useState([]),[y,b]=v.useState(!1),[j,w]=v.useState(""),[N,C]=v.useState({});v.useEffect(()=>{t&&(w(""),o(n?{personId:n.personId??n.name??"",name:n.name??"",label:n.label??"",sceneId:I4,ckbApiKey:n.ckbApiKey??"",greeting:"你好,请通过",tips:"请注意消息,稍后加你微信",remarkType:n.remarkType??"phone",remarkFormat:n.remarkFormat??"",addFriendInterval:n.addFriendInterval??1,startTime:n.startTime??"09:00",endTime:n.endTime??"18:00",deviceGroups:n.deviceGroups??""}:{...hw}),C({}),m.length===0&&E(""))},[t,n]);const E=async I=>{b(!0);try{const O=await QB({page:1,limit:50,keyword:I});O!=null&&O.success&&Array.isArray(O.devices)?g(O.devices):O!=null&&O.error&&ie.error(O.error)}catch(O){ie.error(O instanceof Error?O.message:"加载设备列表失败")}finally{b(!1)}},M=async()=>{var P;const I={};(!a.name||!String(a.name).trim())&&(I.name="请填写名称");const O=a.addFriendInterval;if((typeof O!="number"||O<1)&&(I.addFriendInterval="添加间隔至少为 1 分钟"),(((P=a.deviceGroups)==null?void 0:P.split(",").map(L=>L.trim()).filter(Boolean))??[]).length===0&&(I.deviceGroups="请至少选择 1 台设备"),C(I),Object.keys(I).length>0){ie.error(I.name||I.addFriendInterval||I.deviceGroups||"请完善必填项");return}u(!0);try{await r(a),e(!1)}catch(L){ie.error(L instanceof Error?L.message:"保存失败")}finally{u(!1)}};return s.jsx(Kt,{open:t,onOpenChange:e,children:s.jsxs(zt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-4xl max-h-[90vh] overflow-y-auto",children:[s.jsxs(qt,{children:[s.jsx(Gt,{className:"text-[#38bdac]",children:i?"编辑人物":"添加人物 — 存客宝 API 获客"}),s.jsx(Wx,{className:"text-gray-400 text-sm",children:i?"修改后同步到存客宝计划":"添加时自动生成 token,并同步创建存客宝场景获客计划"})]}),s.jsxs("div",{className:"space-y-6 py-2",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-xs font-medium text-gray-400 uppercase tracking-wider mb-3",children:"基础信息"}),s.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs(Z,{className:"text-gray-400 text-xs",children:["名称 ",s.jsx("span",{className:"text-red-400",children:"*"})]}),s.jsx(oe,{className:`bg-[#0a1628] text-white ${N.name?"border-red-500 focus-visible:ring-red-500":"border-gray-700"}`,placeholder:"如 卡若",value:a.name,onChange:I=>{o(O=>({...O,name:I.target.value})),N.name&&C(O=>({...O,name:void 0}))}}),N.name&&s.jsx("p",{className:"text-xs text-red-400",children:N.name})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Z,{className:"text-gray-400 text-xs",children:"人物ID(可选)"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"自动生成",value:a.personId,onChange:I=>o(O=>({...O,personId:I.target.value})),disabled:i})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Z,{className:"text-gray-400 text-xs",children:"标签(身份/角色)"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如 超级个体",value:a.label,onChange:I=>o(O=>({...O,label:I.target.value}))})]})]})]}),s.jsxs("div",{className:"border-t border-gray-700/50 pt-5",children:[s.jsx("p",{className:"text-xs font-medium text-gray-400 uppercase tracking-wider mb-4",children:"存客宝 API 获客配置"}),s.jsxs("div",{className:"grid grid-cols-2 gap-x-8 gap-y-4",children:[s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Z,{className:"text-gray-400 text-xs",children:"存客宝密钥(计划 apiKey)"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"创建计划成功后自动回填,不可手动修改",value:a.ckbApiKey,readOnly:!0}),s.jsx("p",{className:"text-xs text-gray-500",children:"由存客宝计划详情接口返回的 apiKey,用于小程序 @人物 时推送到对应获客计划。"})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs(Z,{className:"text-gray-400 text-xs",children:["选择设备 ",s.jsx("span",{className:"text-red-400",children:"*"})]}),s.jsxs("div",{className:`flex gap-2 rounded-md border ${N.deviceGroups?"border-red-500":"border-gray-700"}`,children:[s.jsx(oe,{className:"bg-[#0a1628] border-0 text-white focus-visible:ring-0 focus-visible:ring-offset-0",placeholder:"未选择设备",readOnly:!0,value:a.deviceGroups?`已选择 ${a.deviceGroups.split(",").filter(Boolean).length} 个设备`:"",onClick:()=>f(!0)}),s.jsx(ee,{type:"button",variant:"outline",className:"border-0 border-l border-inherit rounded-r-md text-gray-200",onClick:()=>f(!0),children:"选择"})]}),N.deviceGroups?s.jsx("p",{className:"text-xs text-red-400",children:N.deviceGroups}):s.jsx("p",{className:"text-xs text-gray-500",children:"从存客宝设备列表中选择,至少选择 1 台设备参与获客计划。"})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Z,{className:"text-gray-400 text-xs",children:"好友备注"}),s.jsxs(ul,{value:a.remarkType,onValueChange:I=>o(O=>({...O,remarkType:I})),children:[s.jsx(Xa,{className:"bg-[#0a1628] border-gray-700 text-white",children:s.jsx(hl,{placeholder:"选择备注类型"})}),s.jsxs(Za,{children:[s.jsx(Ir,{value:"phone",children:"手机号"}),s.jsx(Ir,{value:"nickname",children:"昵称"}),s.jsx(Ir,{value:"source",children:"来源"})]})]})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Z,{className:"text-gray-400 text-xs",children:"备注格式"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如 手机号+SOUL链接人与事-{名称},留空用默认",value:a.remarkFormat,onChange:I=>o(O=>({...O,remarkFormat:I.target.value}))})]})]}),s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Z,{className:"text-gray-400 text-xs",children:"打招呼语"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"你好,请通过",value:a.greeting,onChange:I=>o(O=>({...O,greeting:I.target.value}))})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Z,{className:"text-gray-400 text-xs",children:"添加间隔(分钟)"}),s.jsx(oe,{type:"number",min:1,className:`bg-[#0a1628] text-white ${N.addFriendInterval?"border-red-500 focus-visible:ring-red-500":"border-gray-700"}`,value:a.addFriendInterval,onChange:I=>{o(O=>({...O,addFriendInterval:Number(I.target.value)||1})),N.addFriendInterval&&C(O=>({...O,addFriendInterval:void 0}))}}),N.addFriendInterval&&s.jsx("p",{className:"text-xs text-red-400",children:N.addFriendInterval})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Z,{className:"text-gray-400 text-xs",children:"允许加人时间段"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(oe,{type:"time",className:"bg-[#0a1628] border-gray-700 text-white w-24",value:a.startTime,onChange:I=>o(O=>({...O,startTime:I.target.value}))}),s.jsx("span",{className:"text-gray-500 text-sm shrink-0",children:"至"}),s.jsx(oe,{type:"time",className:"bg-[#0a1628] border-gray-700 text-white w-24",value:a.endTime,onChange:I=>o(O=>({...O,endTime:I.target.value}))})]})]})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Z,{className:"text-gray-400 text-xs",children:"获客成功提示"}),s.jsx(_l,{className:"bg-[#0a1628] border-gray-700 text-white min-h-[72px] resize-none",placeholder:"请注意消息,稍后加你微信",value:a.tips,onChange:I=>o(O=>({...O,tips:I.target.value}))})]})]})]})]})]}),s.jsxs(hn,{className:"gap-3 pt-2",children:[s.jsx(ee,{variant:"outline",onClick:()=>e(!1),className:"border-gray-600 text-gray-300",children:"取消"}),s.jsx(ee,{onClick:M,disabled:c,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:c?"保存中...":i?"保存":"添加"})]}),h&&s.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60",children:s.jsxs("div",{className:"w-full max-w-3xl max-h-[80vh] bg-[#0b1828] border border-gray-700 rounded-xl shadow-xl flex flex-col",children:[s.jsxs("div",{className:"flex items-center justify-between px-5 py-3 border-b border-gray-700/60",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"text-sm font-medium text-white",children:"选择设备"}),s.jsx("p",{className:"text-xs text-gray-400 mt-0.5",children:"勾选需要参与本计划的设备,可多选"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(oe,{className:"bg-[#050c18] border-gray-700 text-white h-8 w-52",placeholder:"搜索备注/微信号/IMEI",value:j,onChange:I=>w(I.target.value),onKeyDown:I=>{I.key==="Enter"&&E(j)}}),s.jsx(ee,{type:"button",size:"sm",variant:"outline",className:"border-gray-600 text-gray-200 h-8",onClick:()=>E(j),disabled:y,children:"刷新"}),s.jsx(ee,{type:"button",size:"icon",variant:"outline",className:"border-gray-600 text-gray-300 h-8 w-8",onClick:()=>f(!1),children:"✕"})]})]}),s.jsx("div",{className:"flex-1 overflow-y-auto",children:y?s.jsx("div",{className:"flex h-full items-center justify-center text-gray-400 text-sm",children:"正在加载设备列表…"}):m.length===0?s.jsx("div",{className:"flex h-full items-center justify-center text-gray-500 text-sm",children:"暂无设备数据,请检查存客宝账号与开放 API 配置"}):s.jsx("div",{className:"p-4 space-y-2",children:m.map(I=>{const O=String(I.id??""),D=a.deviceGroups?a.deviceGroups.split(",").map(_=>_.trim()).filter(Boolean):[],P=D.includes(O),L=()=>{let _;P?_=D.filter(X=>X!==O):_=[...D,O],o(X=>({...X,deviceGroups:_.join(",")})),_.length>0&&C(X=>({...X,deviceGroups:void 0}))};return s.jsxs("label",{className:"flex items-center gap-3 rounded-lg border border-gray-700/60 bg-[#050c18] px-3 py-2 cursor-pointer hover:border-[#38bdac]/70",children:[s.jsx("input",{type:"checkbox",className:"h-4 w-4 accent-[#38bdac]",checked:P,onChange:L}),s.jsxs("div",{className:"flex flex-col min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-sm text-white truncate max-w-xs",children:I.memo||I.wechatId||`设备 ${O}`}),I.status==="online"&&s.jsx("span",{className:"rounded-full bg-emerald-500/20 text-emerald-400 text-[11px] px-2 py-0.5",children:"在线"}),I.status==="offline"&&s.jsx("span",{className:"rounded-full bg-gray-600/20 text-gray-400 text-[11px] px-2 py-0.5",children:"离线"})]}),s.jsxs("div",{className:"text-[11px] text-gray-400 mt-0.5",children:[s.jsxs("span",{className:"mr-3",children:["ID: ",O]}),I.wechatId&&s.jsxs("span",{className:"mr-3",children:["微信号: ",I.wechatId]}),typeof I.totalFriend=="number"&&s.jsxs("span",{children:["好友数: ",I.totalFriend]})]})]})]},O)})})}),s.jsxs("div",{className:"flex justify-between items-center px-5 py-3 border-t border-gray-700/60",children:[s.jsxs("span",{className:"text-xs text-gray-400",children:["已选择"," ",a.deviceGroups?a.deviceGroups.split(",").filter(Boolean).length:0," ","台设备"]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(ee,{type:"button",variant:"outline",className:"border-gray-600 text-gray-200 h-8 px-4",onClick:()=>f(!1),children:"取消"}),s.jsx(ee,{type:"button",className:"bg-[#38bdac] hover:bg-[#2da396] text-white h-8 px-4",onClick:()=>f(!1),children:"确定"})]})]})]})})]})})}function fw(t,e,n){if(!t||!t.includes("@")&&!t.includes("#")||typeof document>"u")return t;const r=document.createElement("div");r.innerHTML=t;const i=u=>e.find(h=>h.name===u),a=u=>n.find(h=>h.label===u),o=u=>{const h=u.textContent||"";if(!h||!h.includes("@")&&!h.includes("#"))return;const f=u.parentNode;if(!f)return;const m=document.createDocumentFragment(),g=/(@[^\s@#]+|#[^\s@#]+)/g;let y=0,b;for(;b=g.exec(h);){const[j]=b,w=b.index;if(w>y&&m.appendChild(document.createTextNode(h.slice(y,w))),j.startsWith("@")){const N=j.slice(1),C=i(N);if(C){const E=document.createElement("span");E.setAttribute("data-type","mention"),E.setAttribute("data-id",C.id),E.className="mention-tag",E.textContent=`@${C.name}`,m.appendChild(E)}else m.appendChild(document.createTextNode(j))}else if(j.startsWith("#")){const N=j.slice(1),C=a(N);if(C){const E=document.createElement("span");E.setAttribute("data-type","linkTag"),E.setAttribute("data-url",C.url||""),E.setAttribute("data-tag-type",C.type||"url"),E.setAttribute("data-tag-id",C.id||""),E.setAttribute("data-page-path",C.pagePath||""),E.setAttribute("data-app-id",C.appId||""),C.type==="miniprogram"&&C.appId&&E.setAttribute("data-mp-key",C.appId),E.className="link-tag-node",E.textContent=`#${C.label}`,m.appendChild(E)}else m.appendChild(document.createTextNode(j))}else m.appendChild(document.createTextNode(j));y=w+j.length}y{if(u.nodeType===Node.ELEMENT_NODE){const f=u.getAttribute("data-type");if(f==="mention"||f==="linkTag")return;u.childNodes.forEach(m=>c(m));return}u.nodeType===Node.TEXT_NODE&&o(u)};return r.childNodes.forEach(u=>c(u)),r.innerHTML}function eV(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 tV(){var Po,yt,Ul;const[t,e]=v.useState([]),[n,r]=v.useState(!0),[i,a]=v.useState([]),[o,c]=v.useState(null),[u,h]=v.useState(!1),[f,m]=v.useState(!1),[g,y]=v.useState(!1),[b,j]=v.useState(""),[w,N]=v.useState([]),[C,E]=v.useState(!1),[M,I]=v.useState({id:"",title:"",price:1,partId:"part-1",chapterId:"chapter-1",content:"",editionStandard:!0,editionPremium:!1,isFree:!1,isNew:!1,isPinned:!1,hotScore:0}),[O,D]=v.useState(null),[P,L]=v.useState(!1),[_,X]=v.useState(!1),[ne,J]=v.useState(null),[U,R]=v.useState(!1),[F,re]=v.useState([]),[z,ae]=v.useState(!1),[G,$]=v.useState(""),[H,ce]=v.useState(""),[W,fe]=v.useState(!1),[Q,de]=v.useState(""),[he,Ne]=v.useState(!1),[Te,Ve]=v.useState(null),[He,gt]=v.useState(!1),[Pt,wn]=v.useState(!1),[ht,At]=v.useState({readWeight:.5,recencyWeight:.3,payWeight:.2}),[te,Pe]=v.useState(!1),[Qe,xt]=v.useState(!1),[ft,pt]=v.useState(1),[wt,Xt]=v.useState([]),[Ot,Tn]=v.useState(!1),[Dt,Kn]=v.useState([]),[Xr,ir]=v.useState(!1),[me,ve]=v.useState(20),[ar,Hs]=v.useState(!1),[ki,Si]=v.useState(!1),[Sr,Aa]=v.useState([]),[_r,Zr]=v.useState([]),[or,Ci]=v.useState(!1),[Ia,Ws]=v.useState(null),[ot,Ln]=v.useState({tagId:"",label:"",url:"",type:"url",appId:"",pagePath:""}),[es,Cr]=v.useState(null),ts=v.useRef(null),rn=eV(t),zr=t.length,Us=10,$r=Math.max(1,Math.ceil(wt.length/Us)),Ks=wt.slice((ft-1)*Us,ft*Us),jn=async()=>{r(!0);try{const A=await Le("/api/db/book?action=list",{cache:"no-store"});e(Array.isArray(A==null?void 0:A.sections)?A.sections:[])}catch(A){console.error(A),e([])}finally{r(!1)}},Ns=async()=>{Tn(!0);try{const A=await Le("/api/db/book?action=ranking",{cache:"no-store"}),K=Array.isArray(A==null?void 0:A.sections)?A.sections:[];Xt(K);const pe=K.filter(ye=>ye.isPinned).map(ye=>ye.id);Kn(pe)}catch(A){console.error(A),Xt([])}finally{Tn(!1)}};v.useEffect(()=>{jn(),Ns()},[]);const Hl=A=>{a(K=>K.includes(A)?K.filter(pe=>pe!==A):[...K,A])},Ei=v.useCallback(A=>{const K=t,pe=A.flatMap(ye=>{const it=K.find(bt=>bt.id===ye.id);return it?[{...it,partId:ye.partId,partTitle:ye.partTitle,chapterId:ye.chapterId,chapterTitle:ye.chapterTitle}]:[]});return e(pe),Mt("/api/db/book",{action:"reorder",items:A}).then(ye=>{ye&&ye.success===!1&&(e(K),ie.error("排序失败: "+(ye&&typeof ye=="object"&&"error"in ye?ye.error:"未知错误")))}).catch(ye=>{e(K),console.error("排序失败:",ye),ie.error("排序失败: "+(ye instanceof Error?ye.message:"网络或服务异常"))}),Promise.resolve()},[t]),qs=async A=>{if(confirm(`确定要删除章节「${A.title}」吗?此操作不可恢复。`))try{const K=await Ps(`/api/db/book?id=${encodeURIComponent(A.id)}`);K&&K.success!==!1?(ie.success("已删除"),jn(),Ns()):ie.error("删除失败: "+(K&&typeof K=="object"&&"error"in K?K.error:"未知错误"))}catch(K){console.error(K),ie.error("删除失败")}},mr=v.useCallback(async()=>{Pe(!0);try{const A=await Le("/api/db/config/full?key=article_ranking_weights",{cache:"no-store"}),K=A&&A.data;K&&typeof K.readWeight=="number"&&typeof K.recencyWeight=="number"&&typeof K.payWeight=="number"&&At({readWeight:Math.max(0,Math.min(1,K.readWeight)),recencyWeight:Math.max(0,Math.min(1,K.recencyWeight)),payWeight:Math.max(0,Math.min(1,K.payWeight))})}catch{}finally{Pe(!1)}},[]);v.useEffect(()=>{Pt&&mr()},[Pt,mr]);const Ra=async()=>{const{readWeight:A,recencyWeight:K,payWeight:pe}=ht,ye=A+K+pe;if(Math.abs(ye-1)>.001){ie.error("三个权重之和必须等于 1");return}xt(!0);try{const it=await Nt("/api/db/config",{key:"article_ranking_weights",value:{readWeight:A,recencyWeight:K,payWeight:pe},description:"文章排名算法权重"});it&&it.success!==!1?(ie.success("排名权重已保存"),jn()):ie.error("保存失败: "+(it&&typeof it=="object"&&"error"in it?it.error:""))}catch(it){console.error(it),ie.error("保存失败")}finally{xt(!1)}},Ti=v.useCallback(async()=>{ir(!0);try{const A=await Le("/api/db/config/full?key=pinned_section_ids",{cache:"no-store"}),K=A&&A.data;Array.isArray(K)&&Kn(K)}catch{}finally{ir(!1)}},[]),Gs=v.useCallback(async()=>{try{const A=await Le("/api/db/persons");A!=null&&A.success&&A.persons&&Aa(A.persons.map(K=>{const pe=K.deviceGroups,ye=Array.isArray(pe)?pe.join(","):pe??"";return{id:K.token??K.personId??"",personId:K.personId,name:K.name,label:K.label??"",ckbApiKey:K.ckbApiKey??"",ckbPlanId:K.ckbPlanId,remarkType:K.remarkType,remarkFormat:K.remarkFormat,addFriendInterval:K.addFriendInterval,startTime:K.startTime,endTime:K.endTime,deviceGroups:ye}}))}catch{}},[]),ws=v.useCallback(async()=>{try{const A=await Le("/api/db/link-tags");A!=null&&A.success&&A.linkTags&&Zr(A.linkTags.map(K=>({id:K.tagId,label:K.label,url:K.url,type:K.type||"url",appId:K.appId||"",pagePath:K.pagePath||""})))}catch{}},[]),[Mi,To]=v.useState([]),[js,Pa]=v.useState(""),[Mo,Tt]=v.useState(!1),Ao=v.useRef(null),Js=v.useCallback(async()=>{try{const A=await Le("/api/admin/linked-miniprograms");A!=null&&A.success&&Array.isArray(A.data)&&To(A.data.map(K=>({...K,key:K.key})))}catch{}},[]),Ai=Mi.filter(A=>!js.trim()||A.name.toLowerCase().includes(js.toLowerCase())||A.key&&A.key.toLowerCase().includes(js.toLowerCase())||A.appId.toLowerCase().includes(js.toLowerCase())),ks=async A=>{const K=Dt.includes(A)?Dt.filter(pe=>pe!==A):[...Dt,A];Kn(K);try{await Nt("/api/db/config",{key:"pinned_section_ids",value:K,description:"强制置顶章节ID列表(精选推荐/首页最新更新)"}),Ns()}catch{Kn(Dt)}},Oa=v.useCallback(async()=>{Hs(!0);try{const A=await Le("/api/db/config/full?key=unpaid_preview_percent",{cache:"no-store"}),K=A&&A.data;typeof K=="number"&&K>0&&K<=100&&ve(K)}catch{}finally{Hs(!1)}},[]),Da=async()=>{if(me<1||me>100){ie.error("预览比例需在 1~100 之间");return}Si(!0);try{const A=await Nt("/api/db/config",{key:"unpaid_preview_percent",value:me,description:"小程序未付费内容默认预览比例(%)"});A&&A.success!==!1?ie.success("预览比例已保存"):ie.error("保存失败: "+(A.error||""))}catch{ie.error("保存失败")}finally{Si(!1)}};v.useEffect(()=>{Ti(),Oa(),Gs(),ws(),Js()},[Ti,Oa,Gs,ws,Js]);const V=async A=>{Ve({section:A,orders:[]}),gt(!0);try{const K=await Le(`/api/db/book?action=section-orders&id=${encodeURIComponent(A.id)}`),pe=K!=null&&K.success&&Array.isArray(K.orders)?K.orders:[];Ve(ye=>ye?{...ye,orders:pe}:null)}catch(K){console.error(K),Ve(pe=>pe?{...pe,orders:[]}:null)}finally{gt(!1)}},Re=async A=>{m(!0);try{const K=await Le(`/api/db/book?action=read&id=${encodeURIComponent(A.id)}`);if(K!=null&&K.success&&K.section){const pe=K.section,ye=pe.editionPremium===!0;c({id:A.id,originalId:A.id,title:K.section.title??A.title,price:K.section.price??A.price,content:K.section.content??"",filePath:A.filePath,isFree:A.isFree||A.price===0,isNew:pe.isNew??A.isNew,isPinned:Dt.includes(A.id),hotScore:A.hotScore??0,editionStandard:ye?!1:pe.editionStandard??!0,editionPremium:ye})}else c({id:A.id,originalId:A.id,title:A.title,price:A.price,content:"",filePath:A.filePath,isFree:A.isFree,isNew:A.isNew,isPinned:Dt.includes(A.id),hotScore:A.hotScore??0,editionStandard:!0,editionPremium:!1}),K&&!K.success&&ie.error("无法读取文件内容: "+(K.error||"未知错误"))}catch(K){console.error(K),c({id:A.id,title:A.title,price:A.price,content:"",filePath:A.filePath,isFree:A.isFree})}finally{m(!1)}},Xe=async()=>{var A;if(o){y(!0);try{let K=o.content||"";K=fw(K,Sr,_r);const pe=[new RegExp(`^#+\\s*${o.id.replace(".","\\.")}\\s+.*$`,"gm"),new RegExp(`^#+\\s*${o.id.replace(".","\\.")}[::].*$`,"gm"),new RegExp(`^#\\s+.*${(A=o.title)==null?void 0:A.slice(0,10).replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}.*$`,"gm")];for(const an of pe)K=K.replace(an,"");K=K.replace(/^\s*\n+/,"").trim();const ye=o.originalId||o.id,it=o.id!==ye,bt=await Mt("/api/db/book",{id:ye,...it?{newId:o.id}:{},title:o.title,price:o.isFree?0:o.price,content:K,isFree:o.isFree||o.price===0,isNew:o.isNew,hotScore:o.hotScore,editionStandard:o.editionPremium?!1:o.editionStandard??!0,editionPremium:o.editionPremium??!1,saveToFile:!0}),sn=it?o.id:ye;o.isPinned!==Dt.includes(sn)&&await ks(sn),bt&&bt.success!==!1?(ie.success(`已保存:${o.title}`),c(null),jn()):ie.error("保存失败: "+(bt&&typeof bt=="object"&&"error"in bt?bt.error:"未知错误"))}catch(K){console.error(K),ie.error("保存失败")}finally{y(!1)}}},et=async()=>{if(!M.id||!M.title){ie.error("请填写章节ID和标题");return}y(!0);try{const A=rn.find(ye=>ye.id===M.partId),K=A==null?void 0:A.chapters.find(ye=>ye.id===M.chapterId),pe=await Mt("/api/db/book",{id:M.id,title:M.title,price:M.isFree?0:M.price,content:fw(M.content||"",Sr,_r),partId:M.partId,partTitle:(A==null?void 0:A.title)??"",chapterId:M.chapterId,chapterTitle:(K==null?void 0:K.title)??"",isFree:M.isFree,isNew:M.isNew,editionStandard:M.editionPremium?!1:M.editionStandard??!0,editionPremium:M.editionPremium??!1,hotScore:M.hotScore??0,saveToFile:!1});if(pe&&pe.success!==!1){if(M.isPinned){const ye=[...Dt,M.id];Kn(ye);try{await Nt("/api/db/config",{key:"pinned_section_ids",value:ye,description:"强制置顶章节ID列表(精选推荐/首页最新更新)"})}catch{}}ie.success(`章节创建成功:${M.title}`),h(!1),I({id:"",title:"",price:1,partId:"part-1",chapterId:"chapter-1",content:"",editionStandard:!0,editionPremium:!1,isFree:!1,isNew:!1,isPinned:!1,hotScore:0}),jn()}else ie.error("创建失败: "+(pe&&typeof pe=="object"&&"error"in pe?pe.error:"未知错误"))}catch(A){console.error(A),ie.error("创建失败")}finally{y(!1)}},Mn=A=>{I(K=>{var pe;return{...K,partId:A.id,chapterId:((pe=A.chapters[0])==null?void 0:pe.id)??"chapter-1"}}),h(!0)},lr=A=>{D({id:A.id,title:A.title})},Io=async()=>{var A;if((A=O==null?void 0:O.title)!=null&&A.trim()){L(!0);try{const K=t.map(ye=>({id:ye.id,partId:ye.partId||"part-1",partTitle:ye.partId===O.id?O.title.trim():ye.partTitle||"",chapterId:ye.chapterId||"chapter-1",chapterTitle:ye.chapterTitle||""})),pe=await Mt("/api/db/book",{action:"reorder",items:K});if(pe&&pe.success!==!1){const ye=O.title.trim();e(it=>it.map(bt=>bt.partId===O.id?{...bt,partTitle:ye}:bt)),D(null),jn()}else ie.error("更新篇名失败: "+(pe&&typeof pe=="object"&&"error"in pe?pe.error:"未知错误"))}catch(K){console.error(K),ie.error("更新篇名失败")}finally{L(!1)}}},Jt=A=>{const K=A.chapters.length+1,pe=`chapter-${A.id}-${K}-${Date.now()}`;I({id:`${K}.1`,title:"新章节",price:1,partId:A.id,chapterId:pe,content:"",editionStandard:!0,editionPremium:!1,isFree:!1,isNew:!1,isPinned:!1,hotScore:0}),h(!0)},_n=(A,K)=>{J({part:A,chapter:K,title:K.title})},ns=async()=>{var A;if((A=ne==null?void 0:ne.title)!=null&&A.trim()){R(!0);try{const K=t.map(ye=>({id:ye.id,partId:ye.partId||ne.part.id,partTitle:ye.partId===ne.part.id?ne.part.title:ye.partTitle||"",chapterId:ye.chapterId||ne.chapter.id,chapterTitle:ye.partId===ne.part.id&&ye.chapterId===ne.chapter.id?ne.title.trim():ye.chapterTitle||""})),pe=await Mt("/api/db/book",{action:"reorder",items:K});if(pe&&pe.success!==!1){const ye=ne.title.trim(),it=ne.part.id,bt=ne.chapter.id;e(sn=>sn.map(an=>an.partId===it&&an.chapterId===bt?{...an,chapterTitle:ye}:an)),J(null),jn()}else ie.error("保存失败: "+(pe&&typeof pe=="object"&&"error"in pe?pe.error:"未知错误"))}catch(K){console.error(K),ie.error("保存失败")}finally{R(!1)}}},Ss=async(A,K)=>{const pe=K.sections.map(ye=>ye.id);if(pe.length===0){ie.info("该章下无小节,无需删除");return}if(confirm(`确定要删除「第${A.chapters.indexOf(K)+1}章 | ${K.title}」吗?将删除共 ${pe.length} 节,此操作不可恢复。`))try{for(const ye of pe)await Ps(`/api/db/book?id=${encodeURIComponent(ye)}`);jn()}catch(ye){console.error(ye),ie.error("删除失败")}},Ys=async()=>{if(!Q.trim()){ie.error("请输入篇名");return}Ne(!0);try{const A=`part-new-${Date.now()}`,K="chapter-1",pe=`part-placeholder-${Date.now()}`,ye=await Mt("/api/db/book",{id:pe,title:"占位节(可编辑)",price:0,content:"",partId:A,partTitle:Q.trim(),chapterId:K,chapterTitle:"第1章 | 待编辑",saveToFile:!1});ye&&ye.success!==!1?(ie.success(`篇「${Q}」创建成功`),X(!1),de(""),jn()):ie.error("创建失败: "+(ye&&typeof ye=="object"&&"error"in ye?ye.error:"未知错误"))}catch(A){console.error(A),ie.error("创建失败")}finally{Ne(!1)}},Wl=async()=>{if(F.length===0){ie.error("请先勾选要移动的章节");return}const A=rn.find(pe=>pe.id===G),K=A==null?void 0:A.chapters.find(pe=>pe.id===H);if(!A||!K||!G||!H){ie.error("请选择目标篇和章");return}fe(!0);try{const pe=()=>{const sn=new Set(F),an=t.map(on=>({id:on.id,partId:on.partId||"",partTitle:on.partTitle||"",chapterId:on.chapterId||"",chapterTitle:on.chapterTitle||""})),Cs=an.filter(on=>sn.has(on.id)).map(on=>({...on,partId:G,partTitle:A.title||G,chapterId:H,chapterTitle:K.title||H})),gr=an.filter(on=>!sn.has(on.id));let Xs=gr.length;for(let on=gr.length-1;on>=0;on-=1){const rs=gr[on];if(rs.partId===G&&rs.chapterId===H){Xs=on+1;break}}return[...gr.slice(0,Xs),...Cs,...gr.slice(Xs)]},ye=async()=>{const sn=pe(),an=await Mt("/api/db/book",{action:"reorder",items:sn});return an&&an.success!==!1?(ie.success(`已移动 ${F.length} 节到「${A.title}」-「${K.title}」`),ae(!1),re([]),await jn(),!0):!1},it={action:"move-sections",sectionIds:F,targetPartId:G,targetChapterId:H,targetPartTitle:A.title||G,targetChapterTitle:K.title||H},bt=await Mt("/api/db/book",it);if(bt&&bt.success!==!1)ie.success(`已移动 ${bt.count??F.length} 节到「${A.title}」-「${K.title}」`),ae(!1),re([]),await jn();else{const sn=bt&&typeof bt=="object"&&"error"in bt?bt.error||"":"未知错误";if((sn.includes("缺少 id")||sn.includes("无效的 action"))&&await ye())return;ie.error("移动失败: "+sn)}}catch(pe){console.error(pe),ie.error("移动失败: "+(pe instanceof Error?pe.message:"网络或服务异常"))}finally{fe(!1)}},La=A=>{re(K=>K.includes(A)?K.filter(pe=>pe!==A):[...K,A])},Ii=async A=>{const K=t.filter(pe=>pe.partId===A.id).map(pe=>pe.id);if(K.length===0){ie.info("该篇下暂无小节可删除");return}if(confirm(`确定要删除「${A.title}」整篇吗?将删除共 ${K.length} 节内容,此操作不可恢复。`))try{for(const pe of K)await Ps(`/api/db/book?id=${encodeURIComponent(pe)}`);jn()}catch(pe){console.error(pe),ie.error("删除失败")}},Ro=async()=>{var A;if(b.trim()){E(!0);try{const K=await Le(`/api/search?q=${encodeURIComponent(b)}`);K!=null&&K.success&&((A=K.data)!=null&&A.results)?N(K.data.results):(N([]),K&&!K.success&&ie.error("搜索失败: "+K.error))}catch(K){console.error(K),N([]),ie.error("搜索失败")}finally{E(!1)}}},Qs=rn.find(A=>A.id===M.partId),vd=(Qs==null?void 0:Qs.chapters)??[];return s.jsxs("div",{className:"p-8 w-full",children:[s.jsxs("div",{className:"flex justify-between items-center mb-8",children:[s.jsxs("div",{children:[s.jsx("h2",{className:"text-2xl font-bold text-white",children:"内容管理"}),s.jsxs("p",{className:"text-gray-400 mt-1",children:["共 ",rn.length," 篇 · ",zr," 节内容"]})]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs(ee,{onClick:()=>wn(!0),variant:"outline",className:"border-amber-500/50 text-amber-400 hover:bg-amber-500/10 bg-transparent",children:[s.jsx(Nu,{className:"w-4 h-4 mr-2"}),"排名算法"]}),s.jsxs(ee,{onClick:()=>{const A=typeof window<"u"?`${window.location.origin}/api-doc`:"";A&&window.open(A,"_blank","noopener,noreferrer")},variant:"outline",className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(ms,{className:"w-4 h-4 mr-2"}),"API 接口"]})]})]}),s.jsx(Kt,{open:u,onOpenChange:h,children:s.jsxs(zt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-4xl max-h-[90vh] flex flex-col p-0 gap-0",showCloseButton:!0,children:[s.jsx(qt,{className:"shrink-0 px-6 pt-6 pb-2",children:s.jsxs(Gt,{className:"text-white flex items-center gap-2",children:[s.jsx(dn,{className:"w-5 h-5 text-[#38bdac]"}),"新建章节"]})}),s.jsxs("div",{className:"flex-1 overflow-y-auto min-h-0 px-6 space-y-4 py-4",children:[s.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"章节ID *"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如: 9.15",value:M.id,onChange:A=>I({...M,id:A.target.value})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"价格 (元)"}),s.jsx(oe,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:M.isFree?0:M.price,onChange:A=>I({...M,price:Number(A.target.value),isFree:Number(A.target.value)===0}),disabled:M.isFree})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"免费"}),s.jsx("div",{className:"flex items-center h-10",children:s.jsxs("label",{className:"flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:M.isFree,onChange:A=>I({...M,isFree:A.target.checked,price:A.target.checked?0:1}),className:"w-5 h-5 rounded border-gray-600 bg-[#0a1628] text-[#38bdac] focus:ring-[#38bdac]"}),s.jsx("span",{className:"ml-2 text-gray-400 text-sm",children:"设为免费"})]})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"最新新增"}),s.jsx("div",{className:"flex items-center h-10",children:s.jsxs("label",{className:"flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:M.isNew,onChange:A=>I({...M,isNew:A.target.checked}),className:"w-5 h-5 rounded border-gray-600 bg-[#0a1628] text-[#38bdac] focus:ring-[#38bdac]"}),s.jsx("span",{className:"ml-2 text-gray-400 text-sm",children:"标记 NEW"})]})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"小程序直推"}),s.jsx("div",{className:"flex items-center h-10",children:s.jsxs("label",{className:"flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:M.isPinned,onChange:A=>I({...M,isPinned:A.target.checked}),className:"w-5 h-5 rounded border-gray-600 bg-[#0a1628] text-amber-400 focus:ring-amber-400"}),s.jsx("span",{className:"ml-2 text-gray-400 text-sm",children:"强制置顶到小程序首页"})]})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"文章类型"}),s.jsxs("div",{className:"flex items-center gap-4 h-10",children:[s.jsxs("label",{className:"flex items-center cursor-pointer",children:[s.jsx("input",{type:"radio",name:"new-edition-type",checked:M.editionPremium!==!0,onChange:()=>I({...M,editionStandard:!0,editionPremium:!1}),className:"w-4 h-4 border-gray-600 bg-[#0a1628] text-[#38bdac] focus:ring-[#38bdac]"}),s.jsx("span",{className:"ml-2 text-gray-400 text-sm",children:"普通版"})]}),s.jsxs("label",{className:"flex items-center cursor-pointer",children:[s.jsx("input",{type:"radio",name:"new-edition-type",checked:M.editionPremium===!0,onChange:()=>I({...M,editionStandard:!1,editionPremium:!0}),className:"w-4 h-4 border-gray-600 bg-[#0a1628] text-[#38bdac] focus:ring-[#38bdac]"}),s.jsx("span",{className:"ml-2 text-gray-400 text-sm",children:"增值版"})]})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"热度分"}),s.jsx(oe,{type:"number",step:"0.1",min:"0",className:"bg-[#0a1628] border-gray-700 text-white",value:M.hotScore??0,onChange:A=>I({...M,hotScore:Math.max(0,parseFloat(A.target.value)||0)})})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"章节标题 *"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"输入章节标题",value:M.title,onChange:A=>I({...M,title:A.target.value})})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"所属篇"}),s.jsxs(ul,{value:M.partId,onValueChange:A=>{var pe;const K=rn.find(ye=>ye.id===A);I({...M,partId:A,chapterId:((pe=K==null?void 0:K.chapters[0])==null?void 0:pe.id)??"chapter-1"})},children:[s.jsx(Xa,{className:"bg-[#0a1628] border-gray-700 text-white",children:s.jsx(hl,{})}),s.jsxs(Za,{className:"bg-[#0f2137] border-gray-700",children:[rn.map(A=>s.jsx(Ir,{value:A.id,className:"text-white hover:bg-[#38bdac]/20 focus:bg-[#38bdac]/20",children:A.title},A.id)),rn.length===0&&s.jsx(Ir,{value:"part-1",className:"text-white hover:bg-[#38bdac]/20 focus:bg-[#38bdac]/20",children:"默认篇"})]})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"所属章"}),s.jsxs(ul,{value:M.chapterId,onValueChange:A=>I({...M,chapterId:A}),children:[s.jsx(Xa,{className:"bg-[#0a1628] border-gray-700 text-white",children:s.jsx(hl,{})}),s.jsxs(Za,{className:"bg-[#0f2137] border-gray-700",children:[vd.map(A=>s.jsx(Ir,{value:A.id,className:"text-white hover:bg-[#38bdac]/20 focus:bg-[#38bdac]/20",children:A.title},A.id)),vd.length===0&&s.jsx(Ir,{value:"chapter-1",className:"text-white hover:bg-[#38bdac]/20 focus:bg-[#38bdac]/20",children:"默认章"})]})]})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"内容(富文本编辑器,支持 @链接AI人物 和 #链接标签)"}),s.jsx(yx,{content:M.content||"",onChange:A=>I({...M,content:A}),onImageUpload:async A=>{var it;const K=new FormData;K.append("file",A),K.append("folder","book-images");const ye=await(await fetch(ho("/api/upload"),{method:"POST",body:K,headers:{Authorization:`Bearer ${localStorage.getItem("admin_token")||""}`}})).json();return((it=ye==null?void 0:ye.data)==null?void 0:it.url)||(ye==null?void 0:ye.url)||""},persons:Sr,linkTags:_r,placeholder:"开始编辑内容... 输入 @ 可链接AI人物,工具栏可插入 #链接标签"})]})]}),s.jsxs(hn,{className:"shrink-0 px-6 py-4 border-t border-gray-700/50",children:[s.jsx(ee,{variant:"outline",onClick:()=>h(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"取消"}),s.jsx(ee,{onClick:et,disabled:g||!M.id||!M.title,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:g?s.jsxs(s.Fragment,{children:[s.jsx(Ge,{className:"w-4 h-4 mr-2 animate-spin"}),"创建中..."]}):s.jsxs(s.Fragment,{children:[s.jsx(dn,{className:"w-4 h-4 mr-2"}),"创建章节"]})})]})]})}),s.jsx(Kt,{open:!!O,onOpenChange:A=>!A&&D(null),children:s.jsxs(zt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",showCloseButton:!0,children:[s.jsx(qt,{children:s.jsxs(Gt,{className:"text-white flex items-center gap-2",children:[s.jsx(_t,{className:"w-5 h-5 text-[#38bdac]"}),"编辑篇名"]})}),O&&s.jsx("div",{className:"space-y-4 py-4",children:s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"篇名"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",value:O.title,onChange:A=>D({...O,title:A.target.value}),placeholder:"输入篇名"})]})}),s.jsxs(hn,{children:[s.jsx(ee,{variant:"outline",onClick:()=>D(null),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"取消"}),s.jsx(ee,{onClick:Io,disabled:P||!((Po=O==null?void 0:O.title)!=null&&Po.trim()),className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:P?s.jsxs(s.Fragment,{children:[s.jsx(Ge,{className:"w-4 h-4 mr-2 animate-spin"}),"保存中..."]}):s.jsxs(s.Fragment,{children:[s.jsx(gn,{className:"w-4 h-4 mr-2"}),"保存"]})})]})]})}),s.jsx(Kt,{open:!!ne,onOpenChange:A=>!A&&J(null),children:s.jsxs(zt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",showCloseButton:!0,children:[s.jsx(qt,{children:s.jsxs(Gt,{className:"text-white flex items-center gap-2",children:[s.jsx(_t,{className:"w-5 h-5 text-[#38bdac]"}),"编辑章节名称"]})}),ne&&s.jsx("div",{className:"space-y-4 py-4",children:s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"章节名称(如:第8章|底层结构)"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",value:ne.title,onChange:A=>J({...ne,title:A.target.value}),placeholder:"输入章节名称"})]})}),s.jsxs(hn,{children:[s.jsx(ee,{variant:"outline",onClick:()=>J(null),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"取消"}),s.jsx(ee,{onClick:ns,disabled:U||!((yt=ne==null?void 0:ne.title)!=null&&yt.trim()),className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:U?s.jsxs(s.Fragment,{children:[s.jsx(Ge,{className:"w-4 h-4 mr-2 animate-spin"}),"保存中..."]}):s.jsxs(s.Fragment,{children:[s.jsx(gn,{className:"w-4 h-4 mr-2"}),"保存"]})})]})]})}),s.jsx(Kt,{open:z,onOpenChange:A=>{var K;if(ae(A),A&&rn.length>0){const pe=rn[0];$(pe.id),ce(((K=pe.chapters[0])==null?void 0:K.id)??"")}},children:s.jsxs(zt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",showCloseButton:!0,children:[s.jsx(qt,{children:s.jsx(Gt,{className:"text-white",children:"批量移动至指定目录"})}),s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsxs("p",{className:"text-gray-400 text-sm",children:["已选 ",s.jsx("span",{className:"text-[#38bdac] font-medium",children:F.length})," 节,请选择目标篇与章。"]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"目标篇"}),s.jsxs(ul,{value:G,onValueChange:A=>{var pe;$(A);const K=rn.find(ye=>ye.id===A);ce(((pe=K==null?void 0:K.chapters[0])==null?void 0:pe.id)??"")},children:[s.jsx(Xa,{className:"bg-[#0a1628] border-gray-700 text-white",children:s.jsx(hl,{placeholder:"选择篇"})}),s.jsx(Za,{className:"bg-[#0f2137] border-gray-700",children:rn.map(A=>s.jsx(Ir,{value:A.id,className:"text-white hover:bg-[#38bdac]/20 focus:bg-[#38bdac]/20",children:A.title},A.id))})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"目标章"}),s.jsxs(ul,{value:H,onValueChange:ce,children:[s.jsx(Xa,{className:"bg-[#0a1628] border-gray-700 text-white",children:s.jsx(hl,{placeholder:"选择章"})}),s.jsx(Za,{className:"bg-[#0f2137] border-gray-700",children:(((Ul=rn.find(A=>A.id===G))==null?void 0:Ul.chapters)??[]).map(A=>s.jsx(Ir,{value:A.id,className:"text-white hover:bg-[#38bdac]/20 focus:bg-[#38bdac]/20",children:A.title},A.id))})]})]})]}),s.jsxs(hn,{children:[s.jsx(ee,{variant:"outline",onClick:()=>ae(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"取消"}),s.jsx(ee,{onClick:Wl,disabled:W||F.length===0,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:W?s.jsxs(s.Fragment,{children:[s.jsx(Ge,{className:"w-4 h-4 mr-2 animate-spin"}),"移动中..."]}):"确认移动"})]})]})}),s.jsx(Kt,{open:!!Te,onOpenChange:A=>!A&&Ve(null),children:s.jsxs(zt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-3xl max-h-[85vh] overflow-hidden flex flex-col",showCloseButton:!0,children:[s.jsx(qt,{children:s.jsxs(Gt,{className:"text-white",children:["付款记录 — ",(Te==null?void 0:Te.section.title)??""]})}),s.jsx("div",{className:"flex-1 overflow-y-auto py-2",children:He?s.jsxs("div",{className:"flex items-center justify-center py-8",children:[s.jsx(Ge,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):Te&&Te.orders.length===0?s.jsx("p",{className:"text-gray-500 text-center py-6",children:"暂无付款记录"}):Te?s.jsxs("table",{className:"w-full text-sm border-collapse",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"border-b border-gray-700 text-left text-gray-400",children:[s.jsx("th",{className:"py-2 pr-2",children:"订单号"}),s.jsx("th",{className:"py-2 pr-2",children:"用户ID"}),s.jsx("th",{className:"py-2 pr-2",children:"金额"}),s.jsx("th",{className:"py-2 pr-2",children:"状态"}),s.jsx("th",{className:"py-2 pr-2",children:"支付时间"})]})}),s.jsx("tbody",{children:Te.orders.map(A=>s.jsxs("tr",{className:"border-b border-gray-700/50",children:[s.jsx("td",{className:"py-2 pr-2",children:s.jsx("button",{className:"text-blue-400 hover:text-blue-300 hover:underline text-left truncate max-w-[180px] block",title:`查看订单 ${A.orderSn}`,onClick:()=>window.open(`/orders?search=${A.orderSn??A.id??""}`,"_blank"),children:A.orderSn?A.orderSn.length>16?A.orderSn.slice(0,8)+"..."+A.orderSn.slice(-6):A.orderSn:"-"})}),s.jsx("td",{className:"py-2 pr-2",children:s.jsx("button",{className:"text-[#38bdac] hover:text-[#2da396] hover:underline text-left truncate max-w-[140px] block",title:`查看用户 ${A.userId??A.openId??""}`,onClick:()=>window.open(`/users?search=${A.userId??A.openId??""}`,"_blank"),children:(()=>{const K=A.userId??A.openId??"-";return K.length>12?K.slice(0,6)+"..."+K.slice(-4):K})()})}),s.jsxs("td",{className:"py-2 pr-2 text-gray-300",children:["¥",A.amount??0]}),s.jsx("td",{className:"py-2 pr-2 text-gray-300",children:A.status??"-"}),s.jsx("td",{className:"py-2 pr-2 text-gray-500",children:A.payTime??A.createdAt??"-"})]},A.id??A.orderSn??""))})]}):null})]})}),s.jsx(Kt,{open:Pt,onOpenChange:wn,children:s.jsxs(zt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",showCloseButton:!0,children:[s.jsx(qt,{children:s.jsxs(Gt,{className:"text-white flex items-center gap-2",children:[s.jsx(Nu,{className:"w-5 h-5 text-amber-400"}),"文章排名算法"]})}),s.jsxs("div",{className:"space-y-4 py-2",children:[s.jsx("p",{className:"text-sm text-gray-400",children:"热度积分 = 阅读权重×阅读排名分 + 新度权重×新度排名分 + 付款权重×付款排名分(三权重之和须为 1)"}),te?s.jsx("p",{className:"text-gray-500",children:"加载中..."}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsx(Z,{className:"text-gray-400 text-xs",children:"阅读权重"}),s.jsx(oe,{type:"number",step:"0.1",min:"0",max:"1",className:"bg-[#0a1628] border-gray-700 text-white",value:ht.readWeight,onChange:A=>At(K=>({...K,readWeight:Math.max(0,Math.min(1,parseFloat(A.target.value)||0))}))})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(Z,{className:"text-gray-400 text-xs",children:"新度权重"}),s.jsx(oe,{type:"number",step:"0.1",min:"0",max:"1",className:"bg-[#0a1628] border-gray-700 text-white",value:ht.recencyWeight,onChange:A=>At(K=>({...K,recencyWeight:Math.max(0,Math.min(1,parseFloat(A.target.value)||0))}))})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(Z,{className:"text-gray-400 text-xs",children:"付款权重"}),s.jsx(oe,{type:"number",step:"0.1",min:"0",max:"1",className:"bg-[#0a1628] border-gray-700 text-white",value:ht.payWeight,onChange:A=>At(K=>({...K,payWeight:Math.max(0,Math.min(1,parseFloat(A.target.value)||0))}))})]})]}),s.jsxs("p",{className:"text-xs text-gray-500",children:["当前之和: ",(ht.readWeight+ht.recencyWeight+ht.payWeight).toFixed(1)]}),s.jsxs("ul",{className:"list-disc list-inside space-y-1 text-xs text-gray-400",children:[s.jsx("li",{children:"阅读量前 20 名:第1名=20分、第2名=19分...第20名=1分"}),s.jsx("li",{children:"最近更新前 30 篇:第1名=30分、第2名=29分...第30名=1分"}),s.jsx("li",{children:"付款数前 20 名:第1名=20分、第2名=19分...第20名=1分"}),s.jsx("li",{children:"热度分可在编辑章节中手动覆盖"})]}),s.jsx(ee,{onClick:Ra,disabled:Qe||Math.abs(ht.readWeight+ht.recencyWeight+ht.payWeight-1)>.001,className:"w-full bg-amber-500 hover:bg-amber-600 text-white",children:Qe?"保存中...":"保存权重"})]})]})]})}),s.jsx(Kt,{open:_,onOpenChange:X,children:s.jsxs(zt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",showCloseButton:!0,children:[s.jsx(qt,{children:s.jsxs(Gt,{className:"text-white flex items-center gap-2",children:[s.jsx(dn,{className:"w-5 h-5 text-amber-400"}),"新建篇"]})}),s.jsx("div",{className:"space-y-4 py-4",children:s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"篇名(如:第六篇|真实的社会)"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",value:Q,onChange:A=>de(A.target.value),placeholder:"输入篇名"})]})}),s.jsxs(hn,{children:[s.jsx(ee,{variant:"outline",onClick:()=>{X(!1),de("")},className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"取消"}),s.jsx(ee,{onClick:Ys,disabled:he||!Q.trim(),className:"bg-amber-500 hover:bg-amber-600 text-white",children:he?s.jsxs(s.Fragment,{children:[s.jsx(Ge,{className:"w-4 h-4 mr-2 animate-spin"}),"创建中..."]}):s.jsxs(s.Fragment,{children:[s.jsx(dn,{className:"w-4 h-4 mr-2"}),"创建篇"]})})]})]})}),s.jsx(Kt,{open:!!o,onOpenChange:()=>c(null),children:s.jsxs(zt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-4xl max-h-[90vh] flex flex-col p-0 gap-0",showCloseButton:!0,children:[s.jsx(qt,{className:"shrink-0 px-6 pt-6 pb-2",children:s.jsxs(Gt,{className:"text-white flex items-center gap-2",children:[s.jsx(_t,{className:"w-5 h-5 text-[#38bdac]"}),"编辑章节"]})}),o&&s.jsxs("div",{className:"flex-1 overflow-y-auto min-h-0 px-6 space-y-4 py-4",children:[s.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"章节ID"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",value:o.id,onChange:A=>c({...o,id:A.target.value}),placeholder:"如: 9.15"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"价格 (元)"}),s.jsx(oe,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:o.isFree?0:o.price,onChange:A=>c({...o,price:Number(A.target.value),isFree:Number(A.target.value)===0}),disabled:o.isFree})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"免费"}),s.jsx("div",{className:"flex items-center h-10",children:s.jsxs("label",{className:"flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:o.isFree||o.price===0,onChange:A=>c({...o,isFree:A.target.checked,price:A.target.checked?0:1}),className:"w-5 h-5 rounded border-gray-600 bg-[#0a1628] text-[#38bdac] focus:ring-[#38bdac]"}),s.jsx("span",{className:"ml-2 text-gray-400 text-sm",children:"设为免费"})]})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"最新新增"}),s.jsx("div",{className:"flex items-center h-10",children:s.jsxs("label",{className:"flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:o.isNew??!1,onChange:A=>c({...o,isNew:A.target.checked}),className:"w-5 h-5 rounded border-gray-600 bg-[#0a1628] text-[#38bdac] focus:ring-[#38bdac]"}),s.jsx("span",{className:"ml-2 text-gray-400 text-sm",children:"标记 NEW"})]})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"小程序直推"}),s.jsx("div",{className:"flex items-center h-10",children:s.jsxs("label",{className:"flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:o.isPinned??!1,onChange:A=>c({...o,isPinned:A.target.checked}),className:"w-5 h-5 rounded border-gray-600 bg-[#0a1628] text-amber-400 focus:ring-amber-400"}),s.jsx("span",{className:"ml-2 text-gray-400 text-sm",children:"强制置顶到小程序首页"})]})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"文章类型"}),s.jsxs("div",{className:"flex items-center gap-4 h-10",children:[s.jsxs("label",{className:"flex items-center cursor-pointer",children:[s.jsx("input",{type:"radio",name:"edition-type",checked:o.editionPremium!==!0,onChange:()=>c({...o,editionStandard:!0,editionPremium:!1}),className:"w-4 h-4 border-gray-600 bg-[#0a1628] text-[#38bdac] focus:ring-[#38bdac]"}),s.jsx("span",{className:"ml-2 text-gray-400 text-sm",children:"普通版"})]}),s.jsxs("label",{className:"flex items-center cursor-pointer",children:[s.jsx("input",{type:"radio",name:"edition-type",checked:o.editionPremium===!0,onChange:()=>c({...o,editionStandard:!1,editionPremium:!0}),className:"w-4 h-4 border-gray-600 bg-[#0a1628] text-[#38bdac] focus:ring-[#38bdac]"}),s.jsx("span",{className:"ml-2 text-gray-400 text-sm",children:"增值版"})]})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"热度分"}),s.jsx(oe,{type:"number",step:"0.1",min:"0",className:"bg-[#0a1628] border-gray-700 text-white",value:o.hotScore??0,onChange:A=>c({...o,hotScore:Math.max(0,parseFloat(A.target.value)||0)})})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"章节标题"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",value:o.title,onChange:A=>c({...o,title:A.target.value})})]}),o.filePath&&s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"文件路径"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-gray-400 text-sm",value:o.filePath,disabled:!0})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"内容(富文本编辑器,支持 @链接AI人物 和 #链接标签)"}),f?s.jsxs("div",{className:"bg-[#0a1628] border border-gray-700 rounded-md min-h-[400px] flex items-center justify-center",children:[s.jsx(Ge,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):s.jsx(yx,{ref:ts,content:o.content||"",onChange:A=>c({...o,content:A}),onImageUpload:async A=>{var it;const K=new FormData;K.append("file",A),K.append("folder","book-images");const ye=await(await fetch(ho("/api/upload"),{method:"POST",body:K,headers:{Authorization:`Bearer ${localStorage.getItem("admin_token")||""}`}})).json();return((it=ye==null?void 0:ye.data)==null?void 0:it.url)||(ye==null?void 0:ye.url)||""},persons:Sr,linkTags:_r,placeholder:"开始编辑内容... 输入 @ 可链接AI人物,工具栏可插入 #链接标签"})]})]}),s.jsxs(hn,{className:"shrink-0 px-6 py-4 border-t border-gray-700/50",children:[o&&s.jsxs(ee,{variant:"outline",onClick:()=>V({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:[s.jsx(ps,{className:"w-4 h-4 mr-2"}),"付款记录"]}),s.jsxs(ee,{variant:"outline",onClick:()=>c(null),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(hr,{className:"w-4 h-4 mr-2"}),"取消"]}),s.jsx(ee,{onClick:Xe,disabled:g,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:g?s.jsxs(s.Fragment,{children:[s.jsx(Ge,{className:"w-4 h-4 mr-2 animate-spin"}),"保存中..."]}):s.jsxs(s.Fragment,{children:[s.jsx(gn,{className:"w-4 h-4 mr-2"}),"保存修改"]})})]})]})}),s.jsxs(fd,{defaultValue:"chapters",className:"space-y-6",children:[s.jsxs(Ll,{className:"bg-[#0f2137] border border-gray-700/50 p-1",children:[s.jsxs(tn,{value:"chapters",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-gray-400",children:[s.jsx(ps,{className:"w-4 h-4 mr-2"}),"章节管理"]}),s.jsxs(tn,{value:"ranking",className:"data-[state=active]:bg-amber-500/20 data-[state=active]:text-amber-400 text-gray-400",children:[s.jsx(_b,{className:"w-4 h-4 mr-2"}),"内容排行榜"]}),s.jsxs(tn,{value:"search",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-gray-400",children:[s.jsx(da,{className:"w-4 h-4 mr-2"}),"内容搜索"]}),s.jsxs(tn,{value:"link-person",className:"data-[state=active]:bg-purple-500/20 data-[state=active]:text-purple-400 text-gray-400",children:[s.jsx(ms,{className:"w-4 h-4 mr-2"}),"链接人与事"]}),s.jsxs(tn,{value:"link-tag",className:"data-[state=active]:bg-amber-500/20 data-[state=active]:text-amber-400 text-gray-400",children:[s.jsx(Db,{className:"w-4 h-4 mr-2"}),"链接标签"]}),s.jsxs(tn,{value:"linkedmp",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-gray-400",children:[s.jsx(uo,{className:"w-4 h-4 mr-2"}),"关联小程序"]})]}),s.jsxs(nn,{value:"chapters",className:"space-y-4",children:[s.jsxs("div",{className:"rounded-2xl border border-gray-700/50 bg-[#1C1C1E] p-4 flex items-center justify-between shadow-sm",children:[s.jsxs("div",{className:"flex items-center gap-4",children:[s.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:s.jsx(ps,{className:"w-6 h-6"})}),s.jsxs("div",{children:[s.jsx("h2",{className:"font-bold text-base text-white leading-tight mb-1",children:"一场SOUL的创业实验场"}),s.jsx("p",{className:"text-xs text-gray-500",children:"来自Soul派对房的真实商业故事"})]})]}),s.jsxs("div",{className:"text-center shrink-0",children:[s.jsx("span",{className:"block text-2xl font-bold text-[#38bdac]",children:zr}),s.jsx("span",{className:"text-xs text-gray-500",children:"章节"})]})]}),s.jsxs("div",{className:"flex flex-wrap gap-2",children:[s.jsxs(ee,{onClick:()=>h(!0),className:"flex-1 min-w-[120px] bg-[#38bdac]/10 hover:bg-[#38bdac]/20 text-[#38bdac] border border-[#38bdac]/30",children:[s.jsx(dn,{className:"w-4 h-4 mr-2"}),"新建章节"]}),s.jsxs(ee,{onClick:()=>X(!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:[s.jsx(dn,{className:"w-4 h-4 mr-2"}),"新建篇"]}),s.jsxs(ee,{variant:"outline",onClick:()=>ae(!0),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:["批量移动(已选 ",F.length," 节)"]})]}),n?s.jsxs("div",{className:"flex items-center justify-center py-12",children:[s.jsx(Ge,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):s.jsx(YB,{parts:rn,expandedParts:i,onTogglePart:Hl,onReorder:Ei,onReadSection:Re,onDeleteSection:qs,onAddSectionInPart:Mn,onAddChapterInPart:Jt,onDeleteChapter:Ss,onEditPart:lr,onDeletePart:Ii,onEditChapter:_n,selectedSectionIds:F,onToggleSectionSelect:La,onShowSectionOrders:V,pinnedSectionIds:Dt})]}),s.jsx(nn,{value:"search",className:"space-y-4",children:s.jsxs(Me,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsx(nt,{children:s.jsx(rt,{className:"text-white",children:"内容搜索"})}),s.jsxs(Ae,{className:"space-y-4",children:[s.jsxs("div",{className:"flex gap-2",children:[s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500 flex-1",placeholder:"搜索标题或内容...",value:b,onChange:A=>j(A.target.value),onKeyDown:A=>A.key==="Enter"&&Ro()}),s.jsx(ee,{onClick:Ro,disabled:C||!b.trim(),className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:C?s.jsx(Ge,{className:"w-4 h-4 animate-spin"}):s.jsx(da,{className:"w-4 h-4"})})]}),w.length>0&&s.jsxs("div",{className:"space-y-2 mt-4",children:[s.jsxs("p",{className:"text-gray-400 text-sm",children:["找到 ",w.length," 个结果"]}),w.map(A=>s.jsxs("div",{className:"p-3 rounded-lg bg-[#162840] hover:bg-[#1a3050] cursor-pointer transition-colors",onClick:()=>Re({id:A.id,title:A.title,price:A.price??1,filePath:""}),children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-[#38bdac] font-mono text-xs",children:A.id}),s.jsx("span",{className:"text-white",children:A.title}),Dt.includes(A.id)&&s.jsx(ml,{className:"w-3 h-3 text-amber-400 fill-amber-400 shrink-0"})]}),s.jsx(Ue,{variant:"outline",className:"text-gray-400 border-gray-600 text-xs",children:A.matchType==="title"?"标题匹配":"内容匹配"})]}),A.snippet&&s.jsx("p",{className:"text-gray-500 text-xs mt-2 line-clamp-2",children:A.snippet}),(A.partTitle||A.chapterTitle)&&s.jsxs("p",{className:"text-gray-600 text-xs mt-1",children:[A.partTitle," · ",A.chapterTitle]})]},A.id))]})]})]})}),s.jsxs(nn,{value:"ranking",className:"space-y-4",children:[s.jsxs(Me,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsx(nt,{className:"pb-3",children:s.jsxs(rt,{className:"text-white text-base flex items-center gap-2",children:[s.jsx(Nu,{className:"w-4 h-4 text-[#38bdac]"}),"内容显示规则"]})}),s.jsx(Ae,{children:s.jsxs("div",{className:"flex items-center gap-4 flex-wrap",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Z,{className:"text-gray-400 text-sm whitespace-nowrap",children:"未付费预览比例"}),s.jsx(oe,{type:"number",min:"1",max:"100",className:"bg-[#0a1628] border-gray-700 text-white w-20",value:me,onChange:A=>ve(Math.max(1,Math.min(100,Number(A.target.value)||20))),disabled:ar}),s.jsx("span",{className:"text-gray-500 text-sm",children:"%"})]}),s.jsx(ee,{size:"sm",onClick:Da,disabled:ki,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:ki?"保存中...":"保存"}),s.jsxs("span",{className:"text-xs text-gray-500",children:["小程序未付费用户默认显示文章前 ",me,"% 内容"]})]})})]}),s.jsxs(Me,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsx(nt,{className:"pb-3",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs(rt,{className:"text-white text-base flex items-center gap-2",children:[s.jsx(_b,{className:"w-4 h-4 text-amber-400"}),"内容排行榜",s.jsxs("span",{className:"text-xs text-gray-500 font-normal ml-2",children:["按热度排行 · 共 ",wt.length," 节"]})]}),s.jsxs("div",{className:"flex items-center gap-1 text-sm",children:[s.jsx(ee,{variant:"ghost",size:"sm",onClick:()=>Ns(),disabled:Ot,className:"text-gray-400 hover:text-white h-7 w-7 p-0",title:"刷新排行榜",children:s.jsx(Ge,{className:`w-4 h-4 ${Ot?"animate-spin":""}`})}),s.jsx(ee,{variant:"ghost",size:"sm",disabled:ft<=1||Ot,onClick:()=>pt(A=>Math.max(1,A-1)),className:"text-gray-400 hover:text-white h-7 w-7 p-0",children:s.jsx(VT,{className:"w-4 h-4"})}),s.jsxs("span",{className:"text-gray-400 min-w-[60px] text-center",children:[ft," / ",$r]}),s.jsx(ee,{variant:"ghost",size:"sm",disabled:ft>=$r||Ot,onClick:()=>pt(A=>Math.min($r,A+1)),className:"text-gray-400 hover:text-white h-7 w-7 p-0",children:s.jsx(fl,{className:"w-4 h-4"})})]})]})}),s.jsx(Ae,{children:s.jsxs("div",{className:"space-y-0",children:[s.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:[s.jsx("span",{children:"排名"}),s.jsx("span",{children:"置顶"}),s.jsx("span",{children:"标题"}),s.jsx("span",{className:"text-right",children:"点击量"}),s.jsx("span",{className:"text-right",children:"付款数"}),s.jsx("span",{className:"text-right",children:"热度"}),s.jsx("span",{className:"text-right",children:"编辑"})]}),Ks.map((A,K)=>{const pe=(ft-1)*Us+K+1,ye=A.isPinned??Dt.includes(A.id);return s.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 ${ye?"bg-amber-500/5":""}`,children:[s.jsx("span",{className:`text-sm font-bold ${pe<=3?"text-amber-400":"text-gray-500"}`,children:pe<=3?["🥇","🥈","🥉"][pe-1]:`#${pe}`}),s.jsx(ee,{variant:"ghost",size:"sm",className:`h-6 w-6 p-0 ${ye?"text-amber-400":"text-gray-600 hover:text-amber-400"}`,onClick:()=>ks(A.id),disabled:Xr,title:ye?"取消置顶":"强制置顶(精选推荐/首页最新更新)",children:ye?s.jsx(ml,{className:"w-3.5 h-3.5 fill-current"}):s.jsx(hA,{className:"w-3.5 h-3.5"})}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("span",{className:"text-white text-sm truncate block",children:A.title}),s.jsxs("span",{className:"text-gray-600 text-xs",children:[A.partTitle," · ",A.chapterTitle]})]}),s.jsx("span",{className:"text-right text-sm text-blue-400 font-mono",children:A.clickCount??0}),s.jsx("span",{className:"text-right text-sm text-green-400 font-mono",children:A.payCount??0}),s.jsx("span",{className:"text-right text-sm text-amber-400 font-mono",children:(A.hotScore??0).toFixed(1)}),s.jsx("div",{className:"text-right",children:s.jsx(ee,{variant:"ghost",size:"sm",className:"text-gray-500 hover:text-[#38bdac] h-6 px-1",onClick:()=>Re({id:A.id,title:A.title,price:A.price,filePath:""}),title:"编辑文章",children:s.jsx(_t,{className:"w-3 h-3"})})})]},A.id)}),Ks.length===0&&s.jsx("div",{className:"py-8 text-center text-gray-500",children:"暂无数据"})]})})]})]}),s.jsxs(nn,{value:"link-person",className:"space-y-4",children:[s.jsxs(Me,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(nt,{className:"pb-3",children:[s.jsxs(rt,{className:"text-white text-base flex items-center gap-2",children:[s.jsx("span",{className:"text-[#38bdac] text-lg font-bold",children:"@"}),"AI列表 — 链接人与事(编辑器内输入 @ 可链接)"]}),s.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"添加时自动生成 32 位 token,文章 @ 时存 token;小程序点击 @ 时用 token 兑换真实密钥后加好友"})]}),s.jsxs(Ae,{className:"space-y-3",children:[s.jsxs("div",{className:"flex justify-between items-center",children:[s.jsx("p",{className:"text-xs text-gray-500",children:"添加人物时同步创建存客宝场景获客计划,配置与存客宝 API 获客一致"}),s.jsxs(ee,{size:"sm",className:"bg-[#38bdac] hover:bg-[#2da396] text-white",onClick:()=>{Ws(null),Ci(!0)},children:[s.jsx(dn,{className:"w-4 h-4 mr-2"}),"添加"]})]}),s.jsxs("div",{className:"space-y-1 max-h-[400px] overflow-y-auto",children:[Sr.length>0&&s.jsxs("div",{className:"flex items-center gap-4 px-3 py-1.5 text-xs text-gray-500 border-b border-gray-700/50",children:[s.jsx("span",{className:"w-[280px] shrink-0",children:"token"}),s.jsx("span",{className:"w-24 shrink-0",children:"@的人"}),s.jsx("span",{children:"获客计划活动名"})]}),Sr.map(A=>s.jsxs("div",{className:"bg-[#0a1628] rounded px-3 py-2 flex items-center justify-between gap-3",children:[s.jsxs("div",{className:"flex items-center gap-4 text-sm min-w-0",children:[s.jsx("span",{className:"text-gray-400 text-xs font-mono shrink-0 w-[280px]",title:"32位token",children:A.id}),s.jsx("span",{className:"text-amber-400 shrink-0 w-24 truncate",title:"@的人",children:A.name}),s.jsxs("span",{className:"text-white truncate",title:"获客计划活动名",children:["SOUL链接人与事-",A.name]})]}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx(ee,{variant:"ghost",size:"sm",className:"text-gray-400 hover:text-[#38bdac] h-6 px-2",title:"编辑",onClick:async()=>{try{const K=await XB(A.personId||"");if(K!=null&&K.success&&K.person){const pe=K.person;Ws({id:pe.token??pe.personId,personId:pe.personId,name:pe.name,label:pe.label??"",ckbApiKey:pe.ckbApiKey??"",remarkType:pe.remarkType,remarkFormat:pe.remarkFormat,addFriendInterval:pe.addFriendInterval,startTime:pe.startTime,endTime:pe.endTime,deviceGroups:pe.deviceGroups})}else Ws(A),K!=null&&K.error&&ie.error(K.error)}catch(K){console.error(K),Ws(A),ie.error(K instanceof Error?K.message:"加载人物详情失败")}Ci(!0)},children:s.jsx(qw,{className:"w-3 h-3"})}),s.jsx(ee,{variant:"ghost",size:"sm",className:"text-gray-400 hover:text-amber-400 h-6 px-2",title:"编辑计划(跳转存客宝)",onClick:()=>{const K=A.ckbPlanId;K?window.open(`https://h5.ckb.quwanzhi.com/#/scenarios/edit/${K}`,"_blank"):ie.info("该人物尚未同步存客宝计划,请先保存后等待同步完成")},children:s.jsx(_s,{className:"w-3 h-3"})}),s.jsx(ee,{variant:"ghost",size:"sm",className:"text-red-400 hover:text-red-300 h-6 px-2",title:"删除(同时删除存客宝对应获客计划)",onClick:async()=>{confirm(`确定删除「SOUL链接人与事-${A.name}」?将同时删除存客宝对应获客计划。`)&&(await Ps(`/api/db/persons?personId=${A.personId}`),Gs())},children:s.jsx(hr,{className:"w-3 h-3"})})]})]},A.id)),Sr.length===0&&s.jsx("div",{className:"text-gray-500 text-sm py-4 text-center",children:"暂无AI人物,添加后可在编辑器中 @链接"})]})]})]}),s.jsxs(Me,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(nt,{className:"pb-3",children:[s.jsxs(rt,{className:"text-white text-base flex items-center gap-2",children:[s.jsx(Nu,{className:"w-4 h-4 text-green-400"}),"存客宝绑定"]}),s.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"配置存客宝 API 后,文章中 @人物 或 #标签 点击可自动进入存客宝流量池"})]}),s.jsxs(Ae,{className:"space-y-3",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-400 text-xs",children:"存客宝 API 地址"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white h-8",placeholder:"https://ckbapi.quwanzhi.com",defaultValue:"https://ckbapi.quwanzhi.com",readOnly:!0})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-400 text-xs",children:"绑定计划"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white h-8",placeholder:"创业实验-内容引流",defaultValue:"创业实验-内容引流",readOnly:!0})]})]}),s.jsxs("p",{className:"text-xs text-gray-500",children:["具体存客宝场景配置与接口测试请前往"," ",s.jsx("button",{className:"text-[#38bdac] hover:underline",onClick:()=>window.open("/match","_blank"),children:"找伙伴 → 存客宝工作台"})]})]})]})]}),s.jsx(nn,{value:"link-tag",className:"space-y-4",children:s.jsxs(Me,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(nt,{className:"pb-3",children:[s.jsxs(rt,{className:"text-white text-base flex items-center gap-2",children:[s.jsx(Db,{className:"w-4 h-4 text-amber-400"}),"链接标签 — 链接事与物(编辑器内 #标签 可跳转链接/小程序/存客宝)"]}),s.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"小程序端点击 #标签 可直接跳转对应链接,进入流量池"})]}),s.jsxs(Ae,{className:"space-y-3",children:[s.jsxs("div",{className:"flex gap-2 items-end flex-wrap",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-400 text-xs",children:"标签ID"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white h-8 w-24",placeholder:"如 team01",value:ot.tagId,onChange:A=>Ln({...ot,tagId:A.target.value})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-400 text-xs",children:"显示文字"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white h-8 w-28",placeholder:"如 神仙团队",value:ot.label,onChange:A=>Ln({...ot,label:A.target.value})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-400 text-xs",children:"类型"}),s.jsxs(ul,{value:ot.type,onValueChange:A=>Ln({...ot,type:A}),children:[s.jsx(Xa,{className:"bg-[#0a1628] border-gray-700 text-white h-8 w-24",children:s.jsx(hl,{})}),s.jsxs(Za,{children:[s.jsx(Ir,{value:"url",children:"网页链接"}),s.jsx(Ir,{value:"miniprogram",children:"小程序"}),s.jsx(Ir,{value:"ckb",children:"存客宝"})]})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-400 text-xs",children:ot.type==="url"?"URL地址":ot.type==="ckb"?"存客宝计划URL":"小程序(选密钥)"}),ot.type==="miniprogram"&&Mi.length>0?s.jsxs("div",{ref:Ao,className:"relative w-44",children:[s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white h-8 w-44",placeholder:"搜索名称或密钥",value:Mo?js:ot.appId,onChange:A=>{const K=A.target.value;Pa(K),Tt(!0),Mi.some(pe=>pe.key===K)||Ln({...ot,appId:K})},onFocus:()=>{Pa(ot.appId),Tt(!0)},onBlur:()=>setTimeout(()=>Tt(!1),150)}),Mo&&s.jsx("div",{className:"absolute top-full left-0 right-0 mt-1 max-h-48 overflow-y-auto rounded-md border border-gray-700 bg-[#0a1628] shadow-lg z-50",children:Ai.length===0?s.jsx("div",{className:"px-3 py-2 text-gray-500 text-xs",children:"无匹配,可手动输入密钥"}):Ai.map(A=>s.jsxs("button",{type:"button",className:"w-full px-3 py-2 text-left text-sm text-white hover:bg-[#38bdac]/20 flex flex-col gap-0.5",onMouseDown:K=>{K.preventDefault(),Ln({...ot,appId:A.key,pagePath:A.path||""}),Pa(""),Tt(!1)},children:[s.jsx("span",{children:A.name}),s.jsx("span",{className:"text-xs text-gray-400 font-mono",children:A.key})]},A.key))})]}):s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white h-8 w-44",placeholder:ot.type==="url"?"https://...":ot.type==="ckb"?"https://ckbapi.quwanzhi.com/...":"关联小程序的32位密钥",value:ot.type==="url"||ot.type==="ckb"?ot.url:ot.appId,onChange:A=>{ot.type==="url"||ot.type==="ckb"?Ln({...ot,url:A.target.value}):Ln({...ot,appId:A.target.value})}})]}),ot.type==="miniprogram"&&s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-400 text-xs",children:"页面路径"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white h-8 w-36",placeholder:"pages/index/index",value:ot.pagePath,onChange:A=>Ln({...ot,pagePath:A.target.value})})]}),s.jsxs(ee,{size:"sm",className:"bg-amber-500 hover:bg-amber-600 text-white h-8",onClick:async()=>{if(!ot.tagId||!ot.label){ie.error("标签ID和显示文字必填");return}const A={...ot};A.type==="miniprogram"&&(A.url=""),await Nt("/api/db/link-tags",A),Ln({tagId:"",label:"",url:"",type:"url",appId:"",pagePath:""}),Cr(null),ws()},children:[s.jsx(dn,{className:"w-3 h-3 mr-1"}),es?"保存":"添加"]})]}),s.jsxs("div",{className:"space-y-1 max-h-[400px] overflow-y-auto",children:[_r.map(A=>s.jsxs("div",{className:"flex items-center justify-between bg-[#0a1628] rounded px-3 py-2",children:[s.jsxs("div",{className:"flex items-center gap-3 text-sm",children:[s.jsxs("button",{type:"button",className:"text-amber-400 font-bold text-base hover:underline",onClick:()=>{Ln({tagId:A.id,label:A.label,url:A.url,type:A.type,appId:A.appId??"",pagePath:A.pagePath??""}),Cr(A.id)},children:["#",A.label]}),s.jsx(Ue,{variant:"secondary",className:`text-[10px] ${A.type==="ckb"?"bg-green-500/20 text-green-300 border-green-500/30":"bg-gray-700 text-gray-300"}`,children:A.type==="url"?"网页":A.type==="ckb"?"存客宝":"小程序"}),A.type==="miniprogram"?s.jsxs("span",{className:"text-gray-400 text-xs font-mono",children:[A.appId," ",A.pagePath?`· ${A.pagePath}`:""]}):A.url?s.jsxs("a",{href:A.url,target:"_blank",rel:"noreferrer",className:"text-blue-400 text-xs truncate max-w-[250px] hover:underline flex items-center gap-1",children:[A.url," ",s.jsx(_s,{className:"w-3 h-3 shrink-0"})]}):null]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ee,{variant:"ghost",size:"sm",className:"text-gray-300 hover:text-white h-6 px-2",onClick:()=>{Ln({tagId:A.id,label:A.label,url:A.url,type:A.type,appId:A.appId??"",pagePath:A.pagePath??""}),Cr(A.id)},children:"编辑"}),s.jsx(ee,{variant:"ghost",size:"sm",className:"text-red-400 hover:text-red-300 h-6 px-2",onClick:async()=>{await Ps(`/api/db/link-tags?tagId=${A.id}`),es===A.id&&(Cr(null),Ln({tagId:"",label:"",url:"",type:"url",appId:"",pagePath:""})),ws()},children:s.jsx(hr,{className:"w-3 h-3"})})]})]},A.id)),_r.length===0&&s.jsx("div",{className:"text-gray-500 text-sm py-4 text-center",children:"暂无链接标签,添加后可在编辑器中使用 #标签 跳转"})]})]})]})}),s.jsx(nn,{value:"linkedmp",className:"space-y-4",children:s.jsx(GB,{})})]}),s.jsx(ZB,{open:or,onOpenChange:Ci,editingPerson:Ia,onSubmit:async A=>{var ye;const K={personId:A.personId||A.name.toLowerCase().replace(/\s+/g,"_")+"_"+Date.now().toString(36),name:A.name,label:A.label,ckbApiKey:A.ckbApiKey||void 0,greeting:A.greeting||void 0,tips:A.tips||void 0,remarkType:A.remarkType||void 0,remarkFormat:A.remarkFormat||void 0,addFriendInterval:A.addFriendInterval,startTime:A.startTime||void 0,endTime:A.endTime||void 0,deviceGroups:(ye=A.deviceGroups)!=null&&ye.trim()?A.deviceGroups.split(",").map(it=>parseInt(it.trim(),10)).filter(it=>!Number.isNaN(it)):void 0},pe=await Nt("/api/db/persons",K);if(pe&&pe.success===!1){const it=pe;it.ckbResponse&&console.log("存客宝返回",it.ckbResponse);const bt=it.error||"操作失败";throw new Error(bt)}if(Gs(),ie.success(Ia?"已保存":"已添加"),pe!=null&&pe.ckbCreateResult&&Object.keys(pe.ckbCreateResult).length>0){const it=pe.ckbCreateResult;console.log("存客宝创建结果",it);const bt=it.planId??it.id,sn=bt!=null?[`planId: ${bt}`]:[];it.apiKey!=null&&sn.push("apiKey: ***"),ie.info(sn.length?`存客宝创建结果:${sn.join(",")}`:"存客宝创建结果见控制台")}}})]})}const mi={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 pw(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):mi.stats}function mw(t){return Array.isArray(t)?t.map(e=>typeof e=="string"?e:String(e??"")).filter(Boolean):mi.highlights}function nV(){const[t,e]=v.useState(mi),[n,r]=v.useState(!0),[i,a]=v.useState(!1),[o,c]=v.useState(!1),u=v.useRef(null);v.useEffect(()=>{Le("/api/admin/author-settings").then(N=>{const C=N==null?void 0:N.data;C&&typeof C=="object"&&e({name:String(C.name??mi.name),avatar:String(C.avatar??mi.avatar),avatarImg:String(C.avatarImg??""),title:String(C.title??mi.title),bio:String(C.bio??mi.bio),stats:pw(C.stats).length?pw(C.stats):mi.stats,highlights:mw(C.highlights).length?mw(C.highlights):mi.highlights})}).catch(console.error).finally(()=>r(!1))},[]);const h=async()=>{a(!0);try{const N={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)},C=await Nt("/api/admin/author-settings",N);if(!C||C.success===!1){ie.error("保存失败: "+(C&&typeof C=="object"&&"error"in C?C.error:""));return}a(!1);const E=document.createElement("div");E.className="fixed top-4 right-4 z-50 px-4 py-2 rounded-lg bg-[#38bdac] text-white text-sm shadow-lg",E.textContent="作者设置已保存",document.body.appendChild(E),setTimeout(()=>E.remove(),2e3)}catch(N){console.error(N),ie.error("保存失败: "+(N instanceof Error?N.message:String(N)))}finally{a(!1)}},f=async N=>{var E;const C=(E=N.target.files)==null?void 0:E[0];if(C){c(!0);try{const M=new FormData;M.append("file",C),M.append("folder","avatars");const I=Ox(),O={};I&&(O.Authorization=`Bearer ${I}`);const P=await(await fetch(ho("/api/upload"),{method:"POST",body:M,credentials:"include",headers:O})).json();P!=null&&P.success&&(P!=null&&P.url)?e(L=>({...L,avatarImg:P.url})):ie.error("上传失败: "+((P==null?void 0:P.error)||"未知错误"))}catch(M){console.error(M),ie.error("上传失败")}finally{c(!1),u.current&&(u.current.value="")}}},m=()=>e(N=>({...N,stats:[...N.stats,{label:"",value:""}]})),g=N=>e(C=>({...C,stats:C.stats.filter((E,M)=>M!==N)})),y=(N,C,E)=>e(M=>({...M,stats:M.stats.map((I,O)=>O===N?{...I,[C]:E}:I)})),b=()=>e(N=>({...N,highlights:[...N.highlights,""]})),j=N=>e(C=>({...C,highlights:C.highlights.filter((E,M)=>M!==N)})),w=(N,C)=>e(E=>({...E,highlights:E.highlights.map((M,I)=>I===N?C:M)}));return n?s.jsx("div",{className:"p-8 text-gray-500",children:"加载中..."}):s.jsxs("div",{className:"p-8 w-full",children:[s.jsxs("div",{className:"flex justify-between items-center mb-8",children:[s.jsxs("div",{children:[s.jsxs("h2",{className:"text-2xl font-bold text-white flex items-center gap-2",children:[s.jsx(yl,{className:"w-5 h-5 text-[#38bdac]"}),"作者详情"]}),s.jsx("p",{className:"text-gray-400 mt-1",children:"配置小程序「关于作者」页展示的作者信息,包括头像、简介、统计数据与亮点标签。"})]}),s.jsxs(ee,{onClick:h,disabled:i||n,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(gn,{className:"w-4 h-4 mr-2"}),i?"保存中...":"保存"]})]}),s.jsxs("div",{className:"space-y-6",children:[s.jsxs(Me,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(nt,{children:[s.jsxs(rt,{className:"flex items-center gap-2 text-white",children:[s.jsx(yl,{className:"w-4 h-4 text-[#38bdac]"}),"基本信息"]}),s.jsx($t,{className:"text-gray-400",children:"作者姓名、头像、头衔与个人简介,将展示在「关于作者」页顶部。"})]}),s.jsxs(Ae,{className:"space-y-4",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"姓名"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",value:t.name,onChange:N=>e(C=>({...C,name:N.target.value})),placeholder:"卡若"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"首字母占位(无头像时显示)"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white w-20",value:t.avatar,onChange:N=>e(C=>({...C,avatar:N.target.value.slice(0,1)||"K"})),placeholder:"K"})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs(Z,{className:"text-gray-300 flex items-center gap-2",children:[s.jsx(Uw,{className:"w-3 h-3 text-[#38bdac]"}),"头像图片"]}),s.jsxs("div",{className:"flex gap-3 items-center",children:[s.jsx(oe,{className:"flex-1 bg-[#0a1628] border-gray-700 text-white",value:t.avatarImg,onChange:N=>e(C=>({...C,avatarImg:N.target.value})),placeholder:"上传或粘贴 URL,如 /uploads/avatars/xxx.png"}),s.jsx("input",{ref:u,type:"file",accept:"image/*",className:"hidden",onChange:f}),s.jsxs(ee,{type:"button",variant:"outline",size:"sm",className:"border-gray-600 text-gray-400 shrink-0",disabled:o,onClick:()=>{var N;return(N=u.current)==null?void 0:N.click()},children:[s.jsx(lh,{className:"w-4 h-4 mr-2"}),o?"上传中...":"上传"]})]}),t.avatarImg&&s.jsx("div",{className:"mt-2",children:s.jsx("img",{src:t.avatarImg.startsWith("http")?t.avatarImg:ho(t.avatarImg),alt:"头像预览",className:"w-20 h-20 rounded-full object-cover border border-gray-600"})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"头衔"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",value:t.title,onChange:N=>e(C=>({...C,title:N.target.value})),placeholder:"Soul派对房主理人 · 私域运营专家"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"个人简介"}),s.jsx(_l,{className:"bg-[#0a1628] border-gray-700 text-white min-h-[120px]",value:t.bio,onChange:N=>e(C=>({...C,bio:N.target.value})),placeholder:"每天早上6点到9点..."})]})]})]}),s.jsxs(Me,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(nt,{children:[s.jsx(rt,{className:"text-white",children:"统计数据"}),s.jsx($t,{className:"text-gray-400",children:"展示在作者卡片中的数字指标,如「商业案例 62」「连续直播 365天」。第一个「商业案例」的值可由书籍统计自动更新。"})]}),s.jsxs(Ae,{className:"space-y-3",children:[t.stats.map((N,C)=>s.jsxs("div",{className:"flex gap-3 items-center",children:[s.jsx(oe,{className:"flex-1 bg-[#0a1628] border-gray-700 text-white",value:N.label,onChange:E=>y(C,"label",E.target.value),placeholder:"标签"}),s.jsx(oe,{className:"flex-1 bg-[#0a1628] border-gray-700 text-white",value:N.value,onChange:E=>y(C,"value",E.target.value),placeholder:"数值"}),s.jsx(ee,{variant:"ghost",size:"icon",className:"text-gray-400 hover:text-red-400",onClick:()=>g(C),children:s.jsx(hr,{className:"w-4 h-4"})})]},C)),s.jsxs(ee,{variant:"outline",size:"sm",onClick:m,className:"border-gray-600 text-gray-400",children:[s.jsx(dn,{className:"w-4 h-4 mr-2"}),"添加统计项"]})]})]}),s.jsxs(Me,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(nt,{children:[s.jsx(rt,{className:"text-white",children:"亮点标签"}),s.jsx($t,{className:"text-gray-400",children:"作者优势或成就的简短描述,以标签形式展示。"})]}),s.jsxs(Ae,{className:"space-y-3",children:[t.highlights.map((N,C)=>s.jsxs("div",{className:"flex gap-3 items-center",children:[s.jsx(oe,{className:"flex-1 bg-[#0a1628] border-gray-700 text-white",value:N,onChange:E=>w(C,E.target.value),placeholder:"5年私域运营经验"}),s.jsx(ee,{variant:"ghost",size:"icon",className:"text-gray-400 hover:text-red-400",onClick:()=>j(C),children:s.jsx(hr,{className:"w-4 h-4"})})]},C)),s.jsxs(ee,{variant:"outline",size:"sm",onClick:b,className:"border-gray-600 text-gray-400",children:[s.jsx(dn,{className:"w-4 h-4 mr-2"}),"添加亮点"]})]})]})]})]})}function rV(){const[t,e]=v.useState([]),[n,r]=v.useState(0),[i,a]=v.useState(1),[o]=v.useState(10),[c,u]=v.useState(0),[h,f]=v.useState(""),m=Yx(h,300),[g,y]=v.useState(!0),[b,j]=v.useState(null),[w,N]=v.useState(!1),[C,E]=v.useState(null),[M,I]=v.useState(""),[O,D]=v.useState(""),[P,L]=v.useState(""),[_,X]=v.useState("admin"),[ne,J]=v.useState("active"),[U,R]=v.useState(!1);async function F(){var H;y(!0),j(null);try{const ce=new URLSearchParams({page:String(i),pageSize:String(o)});m.trim()&&ce.set("search",m.trim());const W=await Le(`/api/admin/users?${ce}`);W!=null&&W.success?(e(W.records||[]),r(W.total??0),u(W.totalPages??0)):j(W.error||"加载失败")}catch(ce){const W=ce;j(W.status===403?"无权限访问":((H=W==null?void 0:W.data)==null?void 0:H.error)||"加载失败"),e([])}finally{y(!1)}}v.useEffect(()=>{F()},[i,o,m]);const re=()=>{E(null),I(""),D(""),L(""),X("admin"),J("active"),N(!0)},z=H=>{E(H),I(H.username),D(""),L(H.name||""),X(H.role==="super_admin"?"super_admin":"admin"),J(H.status==="disabled"?"disabled":"active"),N(!0)},ae=async()=>{var H;if(!M.trim()){j("用户名不能为空");return}if(!C&&!O){j("新建时密码必填,至少 6 位");return}if(O&&O.length<6){j("密码至少 6 位");return}j(null),R(!0);try{if(C){const ce=await Mt("/api/admin/users",{id:C.id,password:O||void 0,name:P.trim(),role:_,status:ne});ce!=null&&ce.success?(N(!1),F()):j((ce==null?void 0:ce.error)||"保存失败")}else{const ce=await Nt("/api/admin/users",{username:M.trim(),password:O,name:P.trim(),role:_});ce!=null&&ce.success?(N(!1),F()):j((ce==null?void 0:ce.error)||"保存失败")}}catch(ce){const W=ce;j(((H=W==null?void 0:W.data)==null?void 0:H.error)||"保存失败")}finally{R(!1)}},G=async H=>{var ce;if(confirm("确定删除该管理员?"))try{const W=await Ps(`/api/admin/users?id=${H}`);W!=null&&W.success?F():j((W==null?void 0:W.error)||"删除失败")}catch(W){const fe=W;j(((ce=fe==null?void 0:fe.data)==null?void 0:ce.error)||"删除失败")}},$=H=>{if(!H)return"-";try{const ce=new Date(H);return isNaN(ce.getTime())?H:ce.toLocaleString("zh-CN")}catch{return H}};return s.jsxs("div",{className:"p-8 w-full",children:[s.jsxs("div",{className:"flex justify-between items-center mb-6",children:[s.jsxs("div",{children:[s.jsxs("h2",{className:"text-2xl font-bold text-white flex items-center gap-2",children:[s.jsx(Rx,{className:"w-5 h-5 text-[#38bdac]"}),"管理员用户"]}),s.jsx("p",{className:"text-gray-400 mt-1",children:"后台登录账号管理,仅超级管理员可操作"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(oe,{placeholder:"搜索用户名/昵称",value:h,onChange:H=>f(H.target.value),className:"w-48 bg-[#0f2137] border-gray-700 text-white placeholder:text-gray-500"}),s.jsx(ee,{variant:"outline",size:"sm",onClick:F,disabled:g,className:"border-gray-600 text-gray-300",children:s.jsx(Ge,{className:`w-4 h-4 ${g?"animate-spin":""}`})}),s.jsxs(ee,{onClick:re,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(dn,{className:"w-4 h-4 mr-2"}),"新增管理员"]})]})]}),b&&s.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:[s.jsx("span",{children:b}),s.jsx("button",{type:"button",onClick:()=>j(null),className:"text-red-400 hover:text-red-300",children:"×"})]}),s.jsx(Me,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsx(Ae,{className:"p-0",children:g?s.jsx("div",{className:"py-12 text-center text-gray-400",children:"加载中..."}):s.jsxs(s.Fragment,{children:[s.jsxs(Zn,{children:[s.jsx(er,{children:s.jsxs(st,{className:"bg-[#0a1628] border-gray-700",children:[s.jsx(je,{className:"text-gray-400",children:"ID"}),s.jsx(je,{className:"text-gray-400",children:"用户名"}),s.jsx(je,{className:"text-gray-400",children:"昵称"}),s.jsx(je,{className:"text-gray-400",children:"角色"}),s.jsx(je,{className:"text-gray-400",children:"状态"}),s.jsx(je,{className:"text-gray-400",children:"创建时间"}),s.jsx(je,{className:"text-right text-gray-400",children:"操作"})]})}),s.jsxs(tr,{children:[t.map(H=>s.jsxs(st,{className:"border-gray-700/50",children:[s.jsx(xe,{className:"text-gray-300",children:H.id}),s.jsx(xe,{className:"text-white font-medium",children:H.username}),s.jsx(xe,{className:"text-gray-400",children:H.name||"-"}),s.jsx(xe,{children:s.jsx(Ue,{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"?"超级管理员":"管理员"})}),s.jsx(xe,{children:s.jsx(Ue,{variant:"outline",className:H.status==="active"?"border-[#38bdac]/50 text-[#38bdac]":"border-gray-500 text-gray-500",children:H.status==="active"?"正常":"已禁用"})}),s.jsx(xe,{className:"text-gray-500 text-sm",children:$(H.createdAt)}),s.jsxs(xe,{className:"text-right",children:[s.jsx(ee,{variant:"ghost",size:"sm",onClick:()=>z(H),className:"text-gray-400 hover:text-[#38bdac]",children:s.jsx(_t,{className:"w-4 h-4"})}),s.jsx(ee,{variant:"ghost",size:"sm",onClick:()=>G(H.id),className:"text-gray-400 hover:text-red-400",children:s.jsx(Bn,{className:"w-4 h-4"})})]})]},H.id)),t.length===0&&!g&&s.jsx(st,{children:s.jsx(xe,{colSpan:7,className:"text-center py-12 text-gray-500",children:b==="无权限访问"?"仅超级管理员可查看":"暂无管理员"})})]})]}),c>1&&s.jsx("div",{className:"p-4 border-t border-gray-700/50",children:s.jsx(gs,{page:i,pageSize:o,total:n,totalPages:c,onPageChange:a})})]})})}),s.jsx(Kt,{open:w,onOpenChange:N,children:s.jsxs(zt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-sm",children:[s.jsx(qt,{children:s.jsx(Gt,{className:"text-white",children:C?"编辑管理员":"新增管理员"})}),s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"用户名"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"登录用户名",value:M,onChange:H=>I(H.target.value),disabled:!!C}),C&&s.jsx("p",{className:"text-xs text-gray-500",children:"用户名不可修改"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:C?"新密码(留空不改)":"密码"}),s.jsx(oe,{type:"password",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:C?"留空表示不修改":"至少 6 位",value:O,onChange:H=>D(H.target.value)})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"昵称"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"显示名称",value:P,onChange:H=>L(H.target.value)})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"角色"}),s.jsxs("select",{value:_,onChange:H=>X(H.target.value),className:"w-full h-10 px-3 rounded-md bg-[#0a1628] border border-gray-700 text-white",children:[s.jsx("option",{value:"admin",children:"管理员"}),s.jsx("option",{value:"super_admin",children:"超级管理员"})]})]}),C&&s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"状态"}),s.jsxs("select",{value:ne,onChange:H=>J(H.target.value),className:"w-full h-10 px-3 rounded-md bg-[#0a1628] border border-gray-700 text-white",children:[s.jsx("option",{value:"active",children:"正常"}),s.jsx("option",{value:"disabled",children:"禁用"})]})]})]}),s.jsxs(hn,{children:[s.jsxs(ee,{variant:"outline",onClick:()=>N(!1),className:"border-gray-600 text-gray-300",children:[s.jsx(hr,{className:"w-4 h-4 mr-2"}),"取消"]}),s.jsxs(ee,{onClick:ae,disabled:U,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(gn,{className:"w-4 h-4 mr-2"}),U?"保存中...":"保存"]})]})]})})]})}const sV={appId:"wxb8bbb2b10dec74aa",withdrawSubscribeTmplId:"u3MbZGPRkrZIk-I7QdpwzFxnO_CeQPaCWF2FkiIablE",mchId:"1318592501",minWithdraw:10},iV={name:"卡若",startDate:"2025年10月15日",bio:"连续创业者,私域运营专家,每天早上6-9点在Soul派对房分享真实商业故事",liveTime:"06:00-09:00",platform:"Soul派对房",description:"连续创业者,私域运营专家"},aV={sectionPrice:1,baseBookPrice:9.9,distributorShare:90,authorInfo:{...iV},ckbLeadApiKey:""},oV={matchEnabled:!0,referralEnabled:!0,searchEnabled:!0,aboutEnabled:!0},lV=["system","author","admin"];function cV(){const[t,e]=zw(),n=t.get("tab")??"system",r=lV.includes(n)?n:"system",[i,a]=v.useState(aV),[o,c]=v.useState(oV),[u,h]=v.useState(sV),[f,m]=v.useState(!1),[g,y]=v.useState(!0),[b,j]=v.useState(!1),[w,N]=v.useState(""),[C,E]=v.useState(""),[M,I]=v.useState(!1),[O,D]=v.useState(!1),P=(J,U,R=!1)=>{N(J),E(U),I(R),j(!0)};v.useEffect(()=>{(async()=>{try{const U=await Le("/api/admin/settings");if(!U||U.success===!1)return;if(U.featureConfig&&Object.keys(U.featureConfig).length&&c(R=>({...R,...U.featureConfig})),U.mpConfig&&typeof U.mpConfig=="object"&&h(R=>({...R,...U.mpConfig})),U.siteSettings&&typeof U.siteSettings=="object"){const R=U.siteSettings;a(F=>({...F,...typeof R.sectionPrice=="number"&&{sectionPrice:R.sectionPrice},...typeof R.baseBookPrice=="number"&&{baseBookPrice:R.baseBookPrice},...typeof R.distributorShare=="number"&&{distributorShare:R.distributorShare},...R.authorInfo&&typeof R.authorInfo=="object"&&{authorInfo:{...F.authorInfo,...R.authorInfo}},...typeof R.ckbLeadApiKey=="string"&&{ckbLeadApiKey:R.ckbLeadApiKey}}))}}catch(U){console.error("Load settings error:",U)}finally{y(!1)}})()},[]);const L=async(J,U)=>{D(!0);try{const R=await Nt("/api/admin/settings",{featureConfig:J});if(!R||R.success===!1){U(),P("保存失败",(R==null?void 0:R.error)??"未知错误",!0);return}P("已保存","功能开关已更新,相关入口将随之显示或隐藏。")}catch(R){console.error("Save feature config error:",R),U(),P("保存失败",R instanceof Error?R.message:String(R),!0)}finally{D(!1)}},_=(J,U)=>{const R=o,F={...R,[J]:U};c(F),L(F,()=>c(R))},X=async()=>{m(!0);try{const J=await Nt("/api/admin/settings",{featureConfig:o,siteSettings:{sectionPrice:i.sectionPrice,baseBookPrice:i.baseBookPrice,distributorShare:i.distributorShare,authorInfo:i.authorInfo,ckbLeadApiKey:i.ckbLeadApiKey||void 0},mpConfig:{...u,appId:u.appId||"",withdrawSubscribeTmplId:u.withdrawSubscribeTmplId||"",mchId:u.mchId||"",minWithdraw:typeof u.minWithdraw=="number"?u.minWithdraw:10}});if(!J||J.success===!1){P("保存失败",(J==null?void 0:J.error)??"未知错误",!0);return}P("已保存","设置已保存成功。")}catch(J){console.error("Save settings error:",J),P("保存失败",J instanceof Error?J.message:String(J),!0)}finally{m(!1)}},ne=J=>{e(J==="system"?{}:{tab:J})};return g?s.jsx("div",{className:"p-8 text-gray-500",children:"加载中..."}):s.jsxs("div",{className:"p-8 w-full",children:[s.jsxs("div",{className:"flex justify-between items-center mb-6",children:[s.jsxs("div",{children:[s.jsx("h2",{className:"text-2xl font-bold text-white",children:"系统设置"}),s.jsx("p",{className:"text-gray-400 mt-1",children:"配置全站基础参数与开关"})]}),r==="system"&&s.jsxs(ee,{onClick:X,disabled:f,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(gn,{className:"w-4 h-4 mr-2"}),f?"保存中...":"保存设置"]})]}),s.jsxs(fd,{value:r,onValueChange:ne,className:"w-full",children:[s.jsxs(Ll,{className:"mb-6 bg-[#0f2137] border border-gray-700/50 p-1",children:[s.jsxs(tn,{value:"system",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-gray-400 data-[state=active]:font-medium",children:[s.jsx(so,{className:"w-4 h-4 mr-2"}),"系统设置"]}),s.jsxs(tn,{value:"author",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-gray-400 data-[state=active]:font-medium",children:[s.jsx(jm,{className:"w-4 h-4 mr-2"}),"作者详情"]}),s.jsxs(tn,{value:"admin",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-gray-400 data-[state=active]:font-medium",children:[s.jsx(Rx,{className:"w-4 h-4 mr-2"}),"管理员"]})]}),s.jsx(nn,{value:"system",className:"mt-0",children:s.jsxs("div",{className:"space-y-6",children:[s.jsxs(Me,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(nt,{children:[s.jsxs(rt,{className:"text-white flex items-center gap-2",children:[s.jsx(jm,{className:"w-5 h-5 text-[#38bdac]"}),"关于作者"]}),s.jsx($t,{className:"text-gray-400",children:'配置作者信息,将在"关于作者"页面显示'})]}),s.jsxs(Ae,{className:"space-y-4",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsxs(Z,{htmlFor:"author-name",className:"text-gray-300 flex items-center gap-1",children:[s.jsx(jm,{className:"w-3 h-3"}),"主理人名称"]}),s.jsx(oe,{id:"author-name",className:"bg-[#0a1628] border-gray-700 text-white",value:i.authorInfo.name??"",onChange:J=>a(U=>({...U,authorInfo:{...U.authorInfo,name:J.target.value}}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs(Z,{htmlFor:"start-date",className:"text-gray-300 flex items-center gap-1",children:[s.jsx(ih,{className:"w-3 h-3"}),"开播日期"]}),s.jsx(oe,{id:"start-date",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"例如: 2025年10月15日",value:i.authorInfo.startDate??"",onChange:J=>a(U=>({...U,authorInfo:{...U.authorInfo,startDate:J.target.value}}))})]})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsxs(Z,{htmlFor:"live-time",className:"text-gray-300 flex items-center gap-1",children:[s.jsx(ih,{className:"w-3 h-3"}),"直播时间"]}),s.jsx(oe,{id:"live-time",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"例如: 06:00-09:00",value:i.authorInfo.liveTime??"",onChange:J=>a(U=>({...U,authorInfo:{...U.authorInfo,liveTime:J.target.value}}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs(Z,{htmlFor:"platform",className:"text-gray-300 flex items-center gap-1",children:[s.jsx(Kw,{className:"w-3 h-3"}),"直播平台"]}),s.jsx(oe,{id:"platform",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"例如: Soul派对房",value:i.authorInfo.platform??"",onChange:J=>a(U=>({...U,authorInfo:{...U.authorInfo,platform:J.target.value}}))})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs(Z,{htmlFor:"description",className:"text-gray-300 flex items-center gap-1",children:[s.jsx(ps,{className:"w-3 h-3"}),"简介描述"]}),s.jsx(oe,{id:"description",className:"bg-[#0a1628] border-gray-700 text-white",value:i.authorInfo.description??"",onChange:J=>a(U=>({...U,authorInfo:{...U.authorInfo,description:J.target.value}}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{htmlFor:"bio",className:"text-gray-300",children:"详细介绍"}),s.jsx(_l,{id:"bio",className:"bg-[#0a1628] border-gray-700 text-white min-h-[100px]",placeholder:"输入作者详细介绍...",value:i.authorInfo.bio??"",onChange:J=>a(U=>({...U,authorInfo:{...U.authorInfo,bio:J.target.value}}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs(Z,{htmlFor:"ckb-lead-api-key",className:"text-gray-300 flex items-center gap-1",children:[s.jsx(ms,{className:"w-3 h-3"}),"链接卡若存客宝密钥"]}),s.jsx(oe,{id:"ckb-lead-api-key",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如 xxxxx-xxxxx-xxxxx-xxxxx(留空则用 .env 默认)",value:i.ckbLeadApiKey??"",onChange:J=>a(U=>({...U,ckbLeadApiKey:J.target.value}))}),s.jsx("p",{className:"text-xs text-gray-500",children:"小程序首页「链接卡若」留资接口使用的存客宝 API Key,优先于 .env 配置"})]}),s.jsxs("div",{className:"mt-4 p-4 rounded-xl bg-[#0a1628] border border-[#38bdac]/30",children:[s.jsx("p",{className:"text-xs text-gray-500 mb-2",children:"预览效果"}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.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:(i.authorInfo.name??"K").charAt(0)}),s.jsxs("div",{children:[s.jsx("p",{className:"text-white font-semibold",children:i.authorInfo.name}),s.jsx("p",{className:"text-gray-400 text-xs",children:i.authorInfo.description}),s.jsxs("p",{className:"text-[#38bdac] text-xs mt-1",children:["每日 ",i.authorInfo.liveTime," · ",i.authorInfo.platform]})]})]})]})]})]}),s.jsxs(Me,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(nt,{children:[s.jsxs(rt,{className:"text-white flex items-center gap-2",children:[s.jsx(ah,{className:"w-5 h-5 text-[#38bdac]"}),"价格设置"]}),s.jsx($t,{className:"text-gray-400",children:"配置书籍和章节的定价"})]}),s.jsx(Ae,{className:"space-y-4",children:s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"单节价格 (元)"}),s.jsx(oe,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:i.sectionPrice,onChange:J=>a(U=>({...U,sectionPrice:Number.parseFloat(J.target.value)||1}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"整本价格 (元)"}),s.jsx(oe,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:i.baseBookPrice,onChange:J=>a(U=>({...U,baseBookPrice:Number.parseFloat(J.target.value)||9.9}))})]})]})})]}),s.jsxs(Me,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(nt,{children:[s.jsxs(rt,{className:"text-white flex items-center gap-2",children:[s.jsx(uo,{className:"w-5 h-5 text-[#38bdac]"}),"小程序配置"]}),s.jsx($t,{className:"text-gray-400",children:"订阅消息模板、支付商户号等,小程序从 /api/miniprogram/config 读取(API 地址由 app.js baseUrl 控制)"})]}),s.jsx(Ae,{className:"space-y-4",children:s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"小程序 AppID"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"wxb8bbb2b10dec74aa",value:u.appId??"",onChange:J=>h(U=>({...U,appId:J.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"提现订阅模板 ID"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"用户申请提现时需授权",value:u.withdrawSubscribeTmplId??"",onChange:J=>h(U=>({...U,withdrawSubscribeTmplId:J.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"微信支付商户号"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"1318592501",value:u.mchId??"",onChange:J=>h(U=>({...U,mchId:J.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"最低提现金额 (元)"}),s.jsx(oe,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:u.minWithdraw??10,onChange:J=>h(U=>({...U,minWithdraw:Number.parseFloat(J.target.value)||10}))})]})]})})]}),s.jsxs(Me,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(nt,{children:[s.jsxs(rt,{className:"text-white flex items-center gap-2",children:[s.jsx(so,{className:"w-5 h-5 text-[#38bdac]"}),"功能开关"]}),s.jsx($t,{className:"text-gray-400",children:"控制各个功能模块的显示/隐藏"})]}),s.jsxs(Ae,{className:"space-y-4",children:[s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 rounded-lg bg-[#0a1628] border border-gray-700/50",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Un,{className:"w-4 h-4 text-[#38bdac]"}),s.jsx(Z,{htmlFor:"match-enabled",className:"text-white font-medium cursor-pointer",children:"找伙伴功能"})]}),s.jsx("p",{className:"text-xs text-gray-400 ml-6",children:"控制小程序和Web端的找伙伴功能显示"})]}),s.jsx(Et,{id:"match-enabled",checked:o.matchEnabled,disabled:O,onCheckedChange:J=>_("matchEnabled",J)})]}),s.jsxs("div",{className:"flex items-center justify-between p-4 rounded-lg bg-[#0a1628] border border-gray-700/50",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(fM,{className:"w-4 h-4 text-[#38bdac]"}),s.jsx(Z,{htmlFor:"referral-enabled",className:"text-white font-medium cursor-pointer",children:"推广功能"})]}),s.jsx("p",{className:"text-xs text-gray-400 ml-6",children:"控制推广中心的显示(我的页面入口)"})]}),s.jsx(Et,{id:"referral-enabled",checked:o.referralEnabled,disabled:O,onCheckedChange:J=>_("referralEnabled",J)})]}),s.jsxs("div",{className:"flex items-center justify-between p-4 rounded-lg bg-[#0a1628] border border-gray-700/50",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ps,{className:"w-4 h-4 text-[#38bdac]"}),s.jsx(Z,{htmlFor:"search-enabled",className:"text-white font-medium cursor-pointer",children:"搜索功能"})]}),s.jsx("p",{className:"text-xs text-gray-400 ml-6",children:"控制首页搜索栏的显示"})]}),s.jsx(Et,{id:"search-enabled",checked:o.searchEnabled,disabled:O,onCheckedChange:J=>_("searchEnabled",J)})]}),s.jsxs("div",{className:"flex items-center justify-between p-4 rounded-lg bg-[#0a1628] border border-gray-700/50",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(so,{className:"w-4 h-4 text-[#38bdac]"}),s.jsx(Z,{htmlFor:"about-enabled",className:"text-white font-medium cursor-pointer",children:"关于页面"})]}),s.jsx("p",{className:"text-xs text-gray-400 ml-6",children:"控制关于页面的访问"})]}),s.jsx(Et,{id:"about-enabled",checked:o.aboutEnabled,disabled:O,onCheckedChange:J=>_("aboutEnabled",J)})]})]}),s.jsx("div",{className:"p-3 rounded-lg bg-blue-500/10 border border-blue-500/30",children:s.jsx("p",{className:"text-xs text-blue-300",children:"💡 关闭功能后,相关入口会自动隐藏。建议在功能开发完成后再开启。"})})]})]})]})}),s.jsx(nn,{value:"author",className:"mt-0",children:s.jsx(nV,{})}),s.jsx(nn,{value:"admin",className:"mt-0",children:s.jsx(rV,{})})]}),s.jsx(Kt,{open:b,onOpenChange:j,children:s.jsxs(zt,{className:"bg-[#0f2137] border-gray-700 text-white",showCloseButton:!0,children:[s.jsxs(qt,{children:[s.jsx(Gt,{className:M?"text-red-400":"text-[#38bdac]",children:w}),s.jsx(Wx,{className:"text-gray-400 whitespace-pre-wrap pt-2",children:C})]}),s.jsx(hn,{className:"mt-4",children:s.jsx(ee,{onClick:()=>j(!1),className:M?"bg-gray-600 hover:bg-gray-500":"bg-[#38bdac] hover:bg-[#2da396]",children:"确定"})})]})})]})}const gw={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 dV(){const[t,e]=v.useState(!1),[n,r]=v.useState(gw),[i,a]=v.useState(""),o=async()=>{e(!0);try{const N=await Le("/api/config");N!=null&&N.paymentMethods&&r({...gw,...N.paymentMethods})}catch(N){console.error(N)}finally{e(!1)}};v.useEffect(()=>{o()},[]);const c=async()=>{e(!0);try{await Nt("/api/db/config",{key:"payment_methods",value:n,description:"支付方式配置"}),ie.success("配置已保存!")}catch(N){console.error("保存失败:",N),ie.error("保存失败: "+(N instanceof Error?N.message:String(N)))}finally{e(!1)}},u=(N,C)=>{navigator.clipboard.writeText(N),a(C),setTimeout(()=>a(""),2e3)},h=(N,C)=>{r(E=>({...E,wechat:{...E.wechat,[N]:C}}))},f=(N,C)=>{r(E=>({...E,alipay:{...E.alipay,[N]:C}}))},m=(N,C)=>{r(E=>({...E,usdt:{...E.usdt,[N]:C}}))},g=(N,C)=>{r(E=>({...E,paypal:{...E.paypal,[N]:C}}))},y=n.wechat,b=n.alipay,j=n.usdt,w=n.paypal;return s.jsxs("div",{className:"p-8 w-full",children:[s.jsxs("div",{className:"flex justify-between items-center mb-8",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-bold mb-2 text-white",children:"支付配置"}),s.jsx("p",{className:"text-gray-400",children:"配置微信、支付宝、USDT、PayPal等支付参数"})]}),s.jsxs("div",{className:"flex gap-3",children:[s.jsxs(ee,{variant:"outline",onClick:o,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Ge,{className:`w-4 h-4 mr-2 ${t?"animate-spin":""}`}),"同步配置"]}),s.jsxs(ee,{onClick:c,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(gn,{className:"w-4 h-4 mr-2"}),"保存配置"]})]})]}),s.jsx("div",{className:"mb-6 bg-[#07C160]/10 border border-[#07C160]/30 rounded-xl p-4",children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx(Bw,{className:"w-5 h-5 text-[#07C160] flex-shrink-0 mt-0.5"}),s.jsxs("div",{className:"text-sm",children:[s.jsx("p",{className:"font-medium mb-2 text-[#07C160]",children:"如何获取微信群跳转链接?"}),s.jsxs("ol",{className:"text-[#07C160]/80 space-y-1 list-decimal list-inside",children:[s.jsx("li",{children:"打开微信,进入目标微信群"}),s.jsx("li",{children:'点击右上角"..." → "群二维码"'}),s.jsx("li",{children:'点击右上角"..." → "发送到电脑"'}),s.jsx("li",{children:"在电脑上保存二维码图片,上传到图床获取URL"}),s.jsx("li",{children:"或使用草料二维码等工具解析二维码获取链接"})]}),s.jsx("p",{className:"text-[#07C160]/60 mt-2",children:"提示:微信群二维码7天后失效,建议使用活码工具"})]})]})}),s.jsxs(fd,{defaultValue:"wechat",className:"space-y-6",children:[s.jsxs(Ll,{className:"bg-[#0f2137] border border-gray-700/50 p-1 grid grid-cols-4 w-full",children:[s.jsxs(tn,{value:"wechat",className:"data-[state=active]:bg-[#07C160]/20 data-[state=active]:text-[#07C160] text-gray-400",children:[s.jsx(uo,{className:"w-4 h-4 mr-2"}),"微信"]}),s.jsxs(tn,{value:"alipay",className:"data-[state=active]:bg-[#1677FF]/20 data-[state=active]:text-[#1677FF] text-gray-400",children:[s.jsx(Ob,{className:"w-4 h-4 mr-2"}),"支付宝"]}),s.jsxs(tn,{value:"usdt",className:"data-[state=active]:bg-[#26A17B]/20 data-[state=active]:text-[#26A17B] text-gray-400",children:[s.jsx(Rb,{className:"w-4 h-4 mr-2"}),"USDT"]}),s.jsxs(tn,{value:"paypal",className:"data-[state=active]:bg-[#003087]/20 data-[state=active]:text-[#169BD7] text-gray-400",children:[s.jsx(kg,{className:"w-4 h-4 mr-2"}),"PayPal"]})]}),s.jsx(nn,{value:"wechat",className:"space-y-4",children:s.jsxs(Me,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(nt,{className:"flex flex-row items-center justify-between pb-2",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsxs(rt,{className:"text-[#07C160] flex items-center gap-2",children:[s.jsx(uo,{className:"w-5 h-5"}),"微信支付配置"]}),s.jsx($t,{className:"text-gray-400",children:"配置微信支付参数和跳转链接"})]}),s.jsx(Et,{checked:!!y.enabled,onCheckedChange:N=>h("enabled",N)})]}),s.jsxs(Ae,{className:"space-y-4",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"网站AppID"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white font-mono text-sm",value:String(y.websiteAppId??""),onChange:N=>h("websiteAppId",N.target.value)})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"商户号"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white font-mono text-sm",value:String(y.merchantId??""),onChange:N=>h("merchantId",N.target.value)})]})]}),s.jsxs("div",{className:"border-t border-gray-700/50 pt-4 space-y-4",children:[s.jsxs("h4",{className:"text-white font-medium flex items-center gap-2",children:[s.jsx(_s,{className:"w-4 h-4 text-[#38bdac]"}),"跳转链接配置(核心功能)"]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"微信收款码/支付链接"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500",placeholder:"https://收款码图片URL 或 weixin://支付链接",value:String(y.qrCode??""),onChange:N=>h("qrCode",N.target.value)}),s.jsx("p",{className:"text-xs text-gray-500",children:"用户点击微信支付后显示的二维码图片URL"})]}),s.jsxs("div",{className:"space-y-2 bg-[#07C160]/5 p-4 rounded-xl border border-[#07C160]/20",children:[s.jsx(Z,{className:"text-[#07C160] font-medium",children:"微信群跳转链接(支付成功后跳转)"}),s.jsx(oe,{className:"bg-[#0a1628] border-[#07C160]/30 text-white placeholder:text-gray-500",placeholder:"https://weixin.qq.com/g/... 或微信群二维码图片URL",value:String(y.groupQrCode??""),onChange:N=>h("groupQrCode",N.target.value)}),s.jsx("p",{className:"text-xs text-[#07C160]/70",children:"用户支付成功后将自动跳转到此链接,进入指定微信群"})]})]})]})]})}),s.jsx(nn,{value:"alipay",className:"space-y-4",children:s.jsxs(Me,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(nt,{className:"flex flex-row items-center justify-between pb-2",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsxs(rt,{className:"text-[#1677FF] flex items-center gap-2",children:[s.jsx(Ob,{className:"w-5 h-5"}),"支付宝配置"]}),s.jsx($t,{className:"text-gray-400",children:"已加载真实支付宝参数"})]}),s.jsx(Et,{checked:!!b.enabled,onCheckedChange:N=>f("enabled",N)})]}),s.jsxs(Ae,{className:"space-y-4",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"合作者身份 (PID)"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white font-mono text-sm",value:String(b.partnerId??""),onChange:N=>f("partnerId",N.target.value)}),s.jsx(ee,{size:"icon",variant:"outline",className:"border-gray-700 bg-transparent",onClick:()=>u(String(b.partnerId??""),"pid"),children:i==="pid"?s.jsx(df,{className:"w-4 h-4 text-green-500"}):s.jsx(Hw,{className:"w-4 h-4 text-gray-400"})})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"安全校验码 (Key)"}),s.jsx(oe,{type:"password",className:"bg-[#0a1628] border-gray-700 text-white font-mono text-sm",value:String(b.securityKey??""),onChange:N=>f("securityKey",N.target.value)})]})]}),s.jsxs("div",{className:"border-t border-gray-700/50 pt-4 space-y-4",children:[s.jsxs("h4",{className:"text-white font-medium flex items-center gap-2",children:[s.jsx(_s,{className:"w-4 h-4 text-[#38bdac]"}),"跳转链接配置"]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"支付宝收款码/跳转链接"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500",placeholder:"https://qr.alipay.com/... 或收款码图片URL",value:String(b.qrCode??""),onChange:N=>f("qrCode",N.target.value)}),s.jsx("p",{className:"text-xs text-gray-500",children:"用户点击支付宝支付后显示的二维码"})]})]})]})]})}),s.jsx(nn,{value:"usdt",className:"space-y-4",children:s.jsxs(Me,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(nt,{className:"flex flex-row items-center justify-between pb-2",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsxs(rt,{className:"text-[#26A17B] flex items-center gap-2",children:[s.jsx(Rb,{className:"w-5 h-5"}),"USDT配置"]}),s.jsx($t,{className:"text-gray-400",children:"配置加密货币收款地址"})]}),s.jsx(Et,{checked:!!j.enabled,onCheckedChange:N=>m("enabled",N)})]}),s.jsxs(Ae,{className:"space-y-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"网络类型"}),s.jsxs("select",{className:"w-full bg-[#0a1628] border border-gray-700 text-white rounded-md p-2",value:String(j.network??"TRC20"),onChange:N=>m("network",N.target.value),children:[s.jsx("option",{value:"TRC20",children:"TRC20 (波场)"}),s.jsx("option",{value:"ERC20",children:"ERC20 (以太坊)"}),s.jsx("option",{value:"BEP20",children:"BEP20 (币安链)"})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"收款地址"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white font-mono text-sm",placeholder:"T... (TRC20地址)",value:String(j.address??""),onChange:N=>m("address",N.target.value)})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"汇率 (1 USD = ? CNY)"}),s.jsx(oe,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:Number(j.exchangeRate)??7.2,onChange:N=>m("exchangeRate",Number.parseFloat(N.target.value)||7.2)})]})]})]})}),s.jsx(nn,{value:"paypal",className:"space-y-4",children:s.jsxs(Me,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(nt,{className:"flex flex-row items-center justify-between pb-2",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsxs(rt,{className:"text-[#169BD7] flex items-center gap-2",children:[s.jsx(kg,{className:"w-5 h-5"}),"PayPal配置"]}),s.jsx($t,{className:"text-gray-400",children:"配置PayPal收款账户"})]}),s.jsx(Et,{checked:!!w.enabled,onCheckedChange:N=>g("enabled",N)})]}),s.jsxs(Ae,{className:"space-y-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"PayPal邮箱"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"your@email.com",value:String(w.email??""),onChange:N=>g("email",N.target.value)})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"汇率 (1 USD = ? CNY)"}),s.jsx(oe,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:Number(w.exchangeRate)??7.2,onChange:N=>g("exchangeRate",Number(N.target.value)||7.2)})]})]})]})})]})]})}const uV={siteName:"卡若日记",siteTitle:"一场SOUL的创业实验场",siteDescription:"来自Soul派对房的真实商业故事",logo:"/logo.png",favicon:"/favicon.ico",primaryColor:"#00CED1"},hV={home:{enabled:!0,label:"首页"},chapters:{enabled:!0,label:"目录"},match:{enabled:!0,label:"匹配"},my:{enabled:!0,label:"我的"}},fV={homeTitle:"一场SOUL的创业实验场",homeSubtitle:"来自Soul派对房的真实商业故事",chaptersTitle:"我要看",matchTitle:"语音匹配",myTitle:"我的",aboutTitle:"关于作者"};function pV(){const[t,e]=v.useState({siteConfig:{...uV},menuConfig:{...hV},pageConfig:{...fV}}),[n,r]=v.useState(!1),[i,a]=v.useState(!1);v.useEffect(()=>{Le("/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 Nt("/api/db/config",{key:"site_config",value:t.siteConfig,description:"网站基础配置"}),await Nt("/api/db/config",{key:"menu_config",value:t.menuConfig,description:"底部菜单配置"}),await Nt("/api/db/config",{key:"page_config",value:t.pageConfig,description:"页面标题配置"}),r(!0),setTimeout(()=>r(!1),2e3),ie.success("配置已保存")}catch(f){console.error(f),ie.error("保存失败: "+(f instanceof Error?f.message:String(f)))}finally{a(!1)}},c=t.siteConfig,u=t.menuConfig,h=t.pageConfig;return s.jsxs("div",{className:"p-8 w-full",children:[s.jsxs("div",{className:"flex justify-between items-center mb-8",children:[s.jsxs("div",{children:[s.jsx("h2",{className:"text-2xl font-bold text-white",children:"网站配置"}),s.jsx("p",{className:"text-gray-400 mt-1",children:"配置网站名称、图标、菜单和页面标题"})]}),s.jsxs(ee,{onClick:o,disabled:i,className:`${n?"bg-green-500":"bg-[#00CED1]"} hover:bg-[#20B2AA] text-white transition-colors`,children:[s.jsx(gn,{className:"w-4 h-4 mr-2"}),i?"保存中...":n?"已保存":"保存设置"]})]}),s.jsxs("div",{className:"space-y-6",children:[s.jsxs(Me,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(nt,{children:[s.jsxs(rt,{className:"text-white flex items-center gap-2",children:[s.jsx(kg,{className:"w-5 h-5 text-[#00CED1]"}),"网站基础信息"]}),s.jsx($t,{className:"text-gray-400",children:"配置网站名称、标题和描述"})]}),s.jsxs(Ae,{className:"space-y-4",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{htmlFor:"site-name",className:"text-gray-300",children:"网站名称"}),s.jsx(oe,{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}}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{htmlFor:"site-title",className:"text-gray-300",children:"网站标题"}),s.jsx(oe,{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}}))})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{htmlFor:"site-desc",className:"text-gray-300",children:"网站描述"}),s.jsx(oe,{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}}))})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{htmlFor:"logo",className:"text-gray-300",children:"Logo地址"}),s.jsx(oe,{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}}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{htmlFor:"favicon",className:"text-gray-300",children:"Favicon地址"}),s.jsx(oe,{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}}))})]})]})]})]}),s.jsxs(Me,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(nt,{children:[s.jsxs(rt,{className:"text-white flex items-center gap-2",children:[s.jsx(sA,{className:"w-5 h-5 text-[#00CED1]"}),"主题颜色"]}),s.jsx($t,{className:"text-gray-400",children:"配置网站主题色"})]}),s.jsx(Ae,{children:s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsxs("div",{className:"space-y-2 flex-1",children:[s.jsx(Z,{htmlFor:"primary-color",className:"text-gray-300",children:"主色调"}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(oe,{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}}))}),s.jsx(oe,{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}}))})]})]}),s.jsx("div",{className:"w-24 h-24 rounded-xl flex items-center justify-center text-white font-bold",style:{backgroundColor:c.primaryColor??"#00CED1"},children:"预览"})]})})]}),s.jsxs(Me,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(nt,{children:[s.jsxs(rt,{className:"text-white flex items-center gap-2",children:[s.jsx(QM,{className:"w-5 h-5 text-[#00CED1]"}),"底部菜单配置"]}),s.jsx($t,{className:"text-gray-400",children:"控制底部导航栏菜单的显示和名称"})]}),s.jsx(Ae,{className:"space-y-4",children:Object.entries(u).map(([f,m])=>s.jsxs("div",{className:"flex items-center justify-between p-4 bg-[#0a1628] rounded-lg",children:[s.jsxs("div",{className:"flex items-center gap-4 flex-1",children:[s.jsx(Et,{checked:(m==null?void 0:m.enabled)??!0,onCheckedChange:g=>e(y=>({...y,menuConfig:{...y.menuConfig,[f]:{...m,enabled:g}}}))}),s.jsx("span",{className:"text-gray-300 w-16 capitalize",children:f}),s.jsx(oe,{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}}}))})]}),s.jsx("span",{className:`text-sm ${m!=null&&m.enabled?"text-green-400":"text-gray-500"}`,children:m!=null&&m.enabled?"显示":"隐藏"})]},f))})]}),s.jsxs(Me,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(nt,{children:[s.jsxs(rt,{className:"text-white flex items-center gap-2",children:[s.jsx(dM,{className:"w-5 h-5 text-[#00CED1]"}),"页面标题配置"]}),s.jsx($t,{className:"text-gray-400",children:"配置各个页面的标题和副标题"})]}),s.jsxs(Ae,{className:"space-y-4",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"首页标题"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",value:h.homeTitle??"",onChange:f=>e(m=>({...m,pageConfig:{...m.pageConfig,homeTitle:f.target.value}}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"首页副标题"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",value:h.homeSubtitle??"",onChange:f=>e(m=>({...m,pageConfig:{...m.pageConfig,homeSubtitle:f.target.value}}))})]})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"目录页标题"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",value:h.chaptersTitle??"",onChange:f=>e(m=>({...m,pageConfig:{...m.pageConfig,chaptersTitle:f.target.value}}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"匹配页标题"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",value:h.matchTitle??"",onChange:f=>e(m=>({...m,pageConfig:{...m.pageConfig,matchTitle:f.target.value}}))})]})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"我的页标题"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",value:h.myTitle??"",onChange:f=>e(m=>({...m,pageConfig:{...m.pageConfig,myTitle:f.target.value}}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"关于作者标题"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",value:h.aboutTitle??"",onChange:f=>e(m=>({...m,pageConfig:{...m.pageConfig,aboutTitle:f.target.value}}))})]})]})]})]})]})]})}function mV(){const[t,e]=v.useState(""),[n,r]=v.useState(""),[i,a]=v.useState(""),[o,c]=v.useState({}),u=async()=>{var y,b,j,w;try{const N=await Le("/api/config"),C=(b=(y=N==null?void 0:N.liveQRCodes)==null?void 0:y[0])==null?void 0:b.urls;Array.isArray(C)&&e(C.join(` +`));const E=(w=(j=N==null?void 0:N.paymentMethods)==null?void 0:j.wechat)==null?void 0:w.groupQrCode;E&&r(E),c({paymentMethods:N==null?void 0:N.paymentMethods,liveQRCodes:N==null?void 0:N.liveQRCodes})}catch(N){console.error(N)}};v.useEffect(()=>{u()},[]);const h=(y,b)=>{navigator.clipboard.writeText(y),a(b),setTimeout(()=>a(""),2e3)},f=async()=>{try{const y=t.split(` +`).map(j=>j.trim()).filter(Boolean),b=[...o.liveQRCodes||[]];b[0]?b[0].urls=y:b.push({id:"live-1",name:"微信群活码",urls:y,clickCount:0}),await Nt("/api/db/config",{key:"live_qr_codes",value:b,description:"群活码配置"}),ie.success("群活码配置已保存!"),await u()}catch(y){console.error(y),ie.error("保存失败: "+(y instanceof Error?y.message:String(y)))}},m=async()=>{var y;try{await Nt("/api/db/config",{key:"payment_methods",value:{...o.paymentMethods||{},wechat:{...((y=o.paymentMethods)==null?void 0:y.wechat)||{},groupQrCode:n}},description:"支付方式配置"}),ie.success("微信群链接已保存!用户支付成功后将自动跳转"),await u()}catch(b){console.error(b),ie.error("保存失败: "+(b instanceof Error?b.message:String(b)))}},g=()=>{n?window.open(n,"_blank"):ie.error("请先配置微信群链接")};return s.jsxs("div",{className:"p-8 w-full",children:[s.jsxs("div",{className:"mb-8",children:[s.jsx("h2",{className:"text-2xl font-bold text-white",children:"微信群活码管理"}),s.jsx("p",{className:"text-gray-400 mt-1",children:"配置微信群跳转链接,用户支付后自动跳转加群"})]}),s.jsx("div",{className:"mb-6 bg-[#07C160]/10 border border-[#07C160]/30 rounded-xl p-4",children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx(Bw,{className:"w-5 h-5 text-[#07C160] flex-shrink-0 mt-0.5"}),s.jsxs("div",{className:"text-sm",children:[s.jsx("p",{className:"font-medium mb-2 text-[#07C160]",children:"微信群活码配置指南"}),s.jsxs("div",{className:"text-[#07C160]/80 space-y-2",children:[s.jsx("p",{className:"font-medium",children:"方法一:使用草料活码(推荐)"}),s.jsxs("ol",{className:"list-decimal list-inside space-y-1 pl-2",children:[s.jsx("li",{children:"访问草料二维码创建活码"}),s.jsx("li",{children:"上传微信群二维码图片,生成永久链接"}),s.jsx("li",{children:"复制生成的短链接填入下方配置"}),s.jsx("li",{children:"群满后可直接在草料后台更换新群码,链接不变"})]}),s.jsx("p",{className:"font-medium mt-3",children:"方法二:直接使用微信群链接"}),s.jsxs("ol",{className:"list-decimal list-inside space-y-1 pl-2",children:[s.jsx("li",{children:'微信打开目标群 → 右上角"..." → 群二维码'}),s.jsx("li",{children:"长按二维码 → 识别二维码 → 复制链接"})]}),s.jsx("p",{className:"text-[#07C160]/60 mt-2",children:"注意:微信原生群二维码7天后失效,建议使用草料活码"})]})]})]})}),s.jsxs("div",{className:"grid gap-6 md:grid-cols-2",children:[s.jsxs(Me,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl md:col-span-2",children:[s.jsxs(nt,{children:[s.jsxs(rt,{className:"text-[#07C160] flex items-center gap-2",children:[s.jsx(Lb,{className:"w-5 h-5"}),"支付成功跳转链接(核心配置)"]}),s.jsx($t,{className:"text-gray-400",children:"用户支付完成后自动跳转到此链接,进入指定微信群"})]}),s.jsxs(Ae,{className:"space-y-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsxs(Z,{className:"text-gray-300 flex items-center gap-2",children:[s.jsx(Sg,{className:"w-4 h-4"}),"微信群链接 / 活码链接"]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(oe,{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)}),s.jsx(ee,{variant:"outline",size:"icon",className:"border-gray-700 bg-transparent hover:bg-gray-700/50",onClick:()=>h(n,"group"),children:i==="group"?s.jsx(df,{className:"w-4 h-4 text-green-500"}):s.jsx(Hw,{className:"w-4 h-4 text-gray-400"})})]}),s.jsxs("p",{className:"text-xs text-gray-500 flex items-center gap-1",children:[s.jsx(_s,{className:"w-3 h-3"}),"支持格式:草料短链、微信群链接(https://weixin.qq.com/g/...)、企业微信链接等"]})]}),s.jsxs("div",{className:"flex gap-3",children:[s.jsxs(ee,{onClick:m,className:"flex-1 bg-[#07C160] hover:bg-[#06AD51] text-white",children:[s.jsx(lh,{className:"w-4 h-4 mr-2"}),"保存配置"]}),s.jsxs(ee,{onClick:g,variant:"outline",className:"border-[#07C160] text-[#07C160] hover:bg-[#07C160]/10 bg-transparent",children:[s.jsx(_s,{className:"w-4 h-4 mr-2"}),"测试跳转"]})]})]})]}),s.jsxs(Me,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl md:col-span-2",children:[s.jsxs(nt,{children:[s.jsxs(rt,{className:"text-white flex items-center gap-2",children:[s.jsx(Lb,{className:"w-5 h-5 text-[#38bdac]"}),"多群轮换(高级配置)"]}),s.jsx($t,{className:"text-gray-400",children:"配置多个群链接,系统自动轮换分配,避免单群满员"})]}),s.jsxs(Ae,{className:"space-y-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsxs(Z,{className:"text-gray-300 flex items-center gap-2",children:[s.jsx(Sg,{className:"w-4 h-4"}),"多个群链接(每行一个)"]}),s.jsx(_l,{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)}),s.jsx("p",{className:"text-xs text-gray-500",children:"每行填写一个群链接,系统将按顺序或随机分配"})]}),s.jsxs("div",{className:"flex items-center justify-between p-3 bg-[#0a1628] rounded-lg border border-gray-700/50",children:[s.jsx("span",{className:"text-sm text-gray-400",children:"已配置群数量"}),s.jsxs("span",{className:"font-bold text-[#38bdac]",children:[t.split(` +`).filter(Boolean).length," 个"]})]}),s.jsxs(ee,{onClick:f,className:"w-full bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(lh,{className:"w-4 h-4 mr-2"}),"保存多群配置"]})]})]})]}),s.jsxs("div",{className:"mt-6 bg-[#0f2137] rounded-xl p-4 border border-gray-700/50",children:[s.jsx("h4",{className:"text-white font-medium mb-3",children:"常见问题"}),s.jsxs("div",{className:"space-y-3 text-sm",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-[#38bdac]",children:"Q: 为什么推荐使用草料活码?"}),s.jsx("p",{className:"text-gray-400",children:"A: 草料活码是永久链接,群满后可直接在后台更换新群码,无需修改网站配置。微信原生群码7天失效。"})]}),s.jsxs("div",{children:[s.jsx("p",{className:"text-[#38bdac]",children:"Q: 支付后没有跳转怎么办?"}),s.jsx("p",{className:"text-gray-400",children:"A: 1) 检查链接是否正确填写 2) 部分浏览器可能拦截弹窗,用户需手动允许 3) 建议使用https开头的链接"})]})]})]})]})}const xw={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}},gV=["⭐","👥","❤️","🎮","💼","🚀","💡","🎯","🔥","✨"];function xV(){const[t,e]=v.useState(xw),[n,r]=v.useState(!0),[i,a]=v.useState(!1),[o,c]=v.useState(!1),[u,h]=v.useState(null),[f,m]=v.useState({id:"",label:"",matchLabel:"",icon:"⭐",matchFromDB:!1,showJoinAfterMatch:!0,price:1,enabled:!0}),g=async()=>{r(!0);try{const E=await Le("/api/db/config/full?key=match_config"),M=(E==null?void 0:E.data)??(E==null?void 0:E.config);M&&e({...xw,...M})}catch(E){console.error("加载匹配配置失败:",E)}finally{r(!1)}};v.useEffect(()=>{g()},[]);const y=async()=>{a(!0);try{const E=await Nt("/api/db/config",{key:"match_config",value:t,description:"匹配功能配置"});E&&E.success!==!1?ie.success("配置保存成功!"):ie.error("保存失败: "+(E&&typeof E=="object"&&"error"in E?E.error:"未知错误"))}catch(E){console.error("保存配置失败:",E),ie.error("保存失败")}finally{a(!1)}},b=E=>{h(E),m({id:E.id,label:E.label,matchLabel:E.matchLabel,icon:E.icon,matchFromDB:E.matchFromDB,showJoinAfterMatch:E.showJoinAfterMatch,price:E.price,enabled:E.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){ie.error("请填写类型ID和名称");return}const E=[...t.matchTypes];if(u){const M=E.findIndex(I=>I.id===u.id);M!==-1&&(E[M]={...f})}else{if(E.some(M=>M.id===f.id)){ie.error("类型ID已存在");return}E.push({...f})}e({...t,matchTypes:E}),c(!1)},N=E=>{confirm("确定要删除这个匹配类型吗?")&&e({...t,matchTypes:t.matchTypes.filter(M=>M.id!==E)})},C=E=>{e({...t,matchTypes:t.matchTypes.map(M=>M.id===E?{...M,enabled:!M.enabled}:M)})};return s.jsxs("div",{className:"p-8 w-full space-y-6",children:[s.jsxs("div",{className:"flex justify-between items-center",children:[s.jsxs("div",{children:[s.jsxs("h2",{className:"text-2xl font-bold text-white flex items-center gap-2",children:[s.jsx(so,{className:"w-6 h-6 text-[#38bdac]"}),"匹配功能配置"]}),s.jsx("p",{className:"text-gray-400 mt-1",children:"管理找伙伴功能的匹配类型和价格"})]}),s.jsxs("div",{className:"flex gap-3",children:[s.jsxs(ee,{variant:"outline",onClick:g,disabled:n,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Ge,{className:`w-4 h-4 mr-2 ${n?"animate-spin":""}`}),"刷新"]}),s.jsxs(ee,{onClick:y,disabled:i,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(gn,{className:"w-4 h-4 mr-2"}),i?"保存中...":"保存配置"]})]})]}),s.jsxs(Me,{className:"bg-[#0f2137] border-gray-700/50",children:[s.jsxs(nt,{children:[s.jsxs(rt,{className:"text-white flex items-center gap-2",children:[s.jsx(ia,{className:"w-5 h-5 text-yellow-400"}),"基础设置"]}),s.jsx($t,{className:"text-gray-400",children:"配置免费匹配次数和付费规则"})]}),s.jsxs(Ae,{className:"space-y-6",children:[s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"每日免费匹配次数"}),s.jsx(oe,{type:"number",min:0,max:100,className:"bg-[#0a1628] border-gray-700 text-white",value:t.freeMatchLimit,onChange:E=>e({...t,freeMatchLimit:parseInt(E.target.value,10)||0})}),s.jsx("p",{className:"text-xs text-gray-500",children:"用户每天可免费匹配的次数"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"付费匹配价格(元)"}),s.jsx(oe,{type:"number",min:.01,step:.01,className:"bg-[#0a1628] border-gray-700 text-white",value:t.matchPrice,onChange:E=>e({...t,matchPrice:parseFloat(E.target.value)||1})}),s.jsx("p",{className:"text-xs text-gray-500",children:"免费次数用完后的单次匹配价格"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"每日最大匹配次数"}),s.jsx(oe,{type:"number",min:1,max:100,className:"bg-[#0a1628] border-gray-700 text-white",value:t.settings.maxMatchesPerDay,onChange:E=>e({...t,settings:{...t.settings,maxMatchesPerDay:parseInt(E.target.value,10)||10}})}),s.jsx("p",{className:"text-xs text-gray-500",children:"包含免费和付费的总次数"})]})]}),s.jsxs("div",{className:"flex gap-8 pt-4 border-t border-gray-700/50",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Et,{checked:t.settings.enableFreeMatches,onCheckedChange:E=>e({...t,settings:{...t.settings,enableFreeMatches:E}})}),s.jsx(Z,{className:"text-gray-300",children:"启用免费匹配"})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Et,{checked:t.settings.enablePaidMatches,onCheckedChange:E=>e({...t,settings:{...t.settings,enablePaidMatches:E}})}),s.jsx(Z,{className:"text-gray-300",children:"启用付费匹配"})]})]})]})]}),s.jsxs(Me,{className:"bg-[#0f2137] border-gray-700/50",children:[s.jsxs(nt,{className:"flex flex-row items-center justify-between",children:[s.jsxs("div",{children:[s.jsxs(rt,{className:"text-white flex items-center gap-2",children:[s.jsx(Un,{className:"w-5 h-5 text-[#38bdac]"}),"匹配类型管理"]}),s.jsx($t,{className:"text-gray-400",children:"配置不同的匹配类型及其价格"})]}),s.jsxs(ee,{onClick:j,size:"sm",className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(dn,{className:"w-4 h-4 mr-1"}),"添加类型"]})]}),s.jsx(Ae,{children:s.jsxs(Zn,{children:[s.jsx(er,{children:s.jsxs(st,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[s.jsx(je,{className:"text-gray-400",children:"图标"}),s.jsx(je,{className:"text-gray-400",children:"类型ID"}),s.jsx(je,{className:"text-gray-400",children:"显示名称"}),s.jsx(je,{className:"text-gray-400",children:"匹配标签"}),s.jsx(je,{className:"text-gray-400",children:"价格"}),s.jsx(je,{className:"text-gray-400",children:"数据库匹配"}),s.jsx(je,{className:"text-gray-400",children:"状态"}),s.jsx(je,{className:"text-right text-gray-400",children:"操作"})]})}),s.jsx(tr,{children:t.matchTypes.map(E=>s.jsxs(st,{className:"hover:bg-[#0a1628] border-gray-700/50",children:[s.jsx(xe,{children:s.jsx("span",{className:"text-2xl",children:E.icon})}),s.jsx(xe,{className:"font-mono text-gray-300",children:E.id}),s.jsx(xe,{className:"text-white font-medium",children:E.label}),s.jsx(xe,{className:"text-gray-300",children:E.matchLabel}),s.jsx(xe,{children:s.jsxs(Ue,{className:"bg-yellow-500/20 text-yellow-400 hover:bg-yellow-500/20 border-0",children:["¥",E.price]})}),s.jsx(xe,{children:E.matchFromDB?s.jsx(Ue,{className:"bg-green-500/20 text-green-400 hover:bg-green-500/20 border-0",children:"是"}):s.jsx(Ue,{variant:"outline",className:"text-gray-500 border-gray-600",children:"否"})}),s.jsx(xe,{children:s.jsx(Et,{checked:E.enabled,onCheckedChange:()=>C(E.id)})}),s.jsx(xe,{className:"text-right",children:s.jsxs("div",{className:"flex items-center justify-end gap-1",children:[s.jsx(ee,{variant:"ghost",size:"sm",onClick:()=>b(E),className:"text-gray-400 hover:text-[#38bdac] hover:bg-[#38bdac]/10",children:s.jsx(_t,{className:"w-4 h-4"})}),s.jsx(ee,{variant:"ghost",size:"sm",onClick:()=>N(E.id),className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:s.jsx(Bn,{className:"w-4 h-4"})})]})})]},E.id))})]})})]}),s.jsx(Kt,{open:o,onOpenChange:c,children:s.jsxs(zt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-lg",showCloseButton:!0,children:[s.jsx(qt,{children:s.jsxs(Gt,{className:"text-white flex items-center gap-2",children:[u?s.jsx(_t,{className:"w-5 h-5 text-[#38bdac]"}):s.jsx(dn,{className:"w-5 h-5 text-[#38bdac]"}),u?"编辑匹配类型":"添加匹配类型"]})}),s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"类型ID(英文)"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如: partner",value:f.id,onChange:E=>m({...f,id:E.target.value}),disabled:!!u})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"图标"}),s.jsx("div",{className:"flex gap-1 flex-wrap",children:gV.map(E=>s.jsx("button",{type:"button",className:`w-8 h-8 text-lg rounded ${f.icon===E?"bg-[#38bdac]/30 ring-1 ring-[#38bdac]":"bg-[#0a1628]"}`,onClick:()=>m({...f,icon:E}),children:E},E))})]})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"显示名称"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如: 创业合伙",value:f.label,onChange:E=>m({...f,label:E.target.value})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"匹配标签"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如: 创业伙伴",value:f.matchLabel,onChange:E=>m({...f,matchLabel:E.target.value})})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"单次匹配价格(元)"}),s.jsx(oe,{type:"number",min:.01,step:.01,className:"bg-[#0a1628] border-gray-700 text-white",value:f.price,onChange:E=>m({...f,price:parseFloat(E.target.value)||1})})]}),s.jsxs("div",{className:"flex gap-6 pt-2",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Et,{checked:f.matchFromDB,onCheckedChange:E=>m({...f,matchFromDB:E})}),s.jsx(Z,{className:"text-gray-300 text-sm",children:"从数据库匹配"})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Et,{checked:f.showJoinAfterMatch,onCheckedChange:E=>m({...f,showJoinAfterMatch:E})}),s.jsx(Z,{className:"text-gray-300 text-sm",children:"匹配后显示加入"})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Et,{checked:f.enabled,onCheckedChange:E=>m({...f,enabled:E})}),s.jsx(Z,{className:"text-gray-300 text-sm",children:"启用"})]})]})]}),s.jsxs(hn,{children:[s.jsx(ee,{variant:"outline",onClick:()=>c(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"取消"}),s.jsxs(ee,{onClick:w,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(gn,{className:"w-4 h-4 mr-2"}),"保存"]})]})]})})]})}const yw={partner:"找伙伴",investor:"资源对接",mentor:"导师顾问",team:"团队招募"};function yV(){const[t,e]=v.useState([]),[n,r]=v.useState(0),[i,a]=v.useState(1),[o,c]=v.useState(10),[u,h]=v.useState(""),[f,m]=v.useState(!0),[g,y]=v.useState(null);async function b(){m(!0),y(null);try{const w=new URLSearchParams({page:String(i),pageSize:String(o)});u&&w.set("matchType",u);const N=await Le(`/api/db/match-records?${w}`);N!=null&&N.success?(e(N.records||[]),r(N.total??0)):y("加载匹配记录失败")}catch(w){console.error("加载匹配记录失败",w),y("加载失败,请检查网络后重试")}finally{m(!1)}}v.useEffect(()=>{b()},[i,u]);const j=Math.ceil(n/o)||1;return s.jsxs("div",{className:"p-8 w-full",children:[g&&s.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:[s.jsx("span",{children:g}),s.jsx("button",{type:"button",onClick:()=>y(null),className:"hover:text-red-300",children:"×"})]}),s.jsxs("div",{className:"flex justify-between items-center mb-8",children:[s.jsxs("div",{children:[s.jsx("h2",{className:"text-2xl font-bold text-white",children:"匹配记录"}),s.jsxs("p",{className:"text-gray-400 mt-1",children:["找伙伴匹配统计,共 ",n," 条记录"]})]}),s.jsxs("div",{className:"flex items-center gap-4",children:[s.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:[s.jsx("option",{value:"",children:"全部类型"}),Object.entries(yw).map(([w,N])=>s.jsx("option",{value:w,children:N},w))]}),s.jsxs("button",{type:"button",onClick:b,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:[s.jsx(Ge,{className:`w-4 h-4 ${f?"animate-spin":""}`}),"刷新"]})]})]}),s.jsx(Me,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:s.jsx(Ae,{className:"p-0",children:f?s.jsxs("div",{className:"flex justify-center py-12",children:[s.jsx(Ge,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):s.jsxs(s.Fragment,{children:[s.jsxs(Zn,{children:[s.jsx(er,{children:s.jsxs(st,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[s.jsx(je,{className:"text-gray-400",children:"发起人"}),s.jsx(je,{className:"text-gray-400",children:"匹配到"}),s.jsx(je,{className:"text-gray-400",children:"类型"}),s.jsx(je,{className:"text-gray-400",children:"联系方式"}),s.jsx(je,{className:"text-gray-400",children:"匹配时间"})]})}),s.jsxs(tr,{children:[t.map(w=>s.jsxs(st,{className:"hover:bg-[#0a1628] border-gray-700/50",children:[s.jsx(xe,{children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.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?s.jsx("img",{src:w.userAvatar,alt:"",className:"w-full h-full object-cover",onError:N=>{N.currentTarget.style.display="none";const C=N.currentTarget.nextElementSibling;C&&C.classList.remove("hidden")}}):null,s.jsx("span",{className:w.userAvatar?"hidden":"",children:(w.userNickname||w.userId||"?").charAt(0)})]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-white",children:w.userNickname||w.userId}),s.jsxs("div",{className:"text-xs text-gray-500 font-mono",children:[w.userId.slice(0,16),"..."]})]})]})}),s.jsx(xe,{children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.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?s.jsx("img",{src:w.matchedUserAvatar,alt:"",className:"w-full h-full object-cover",onError:N=>{N.currentTarget.style.display="none";const C=N.currentTarget.nextElementSibling;C&&C.classList.remove("hidden")}}):null,s.jsx("span",{className:w.matchedUserAvatar?"hidden":"",children:(w.matchedNickname||w.matchedUserId||"?").charAt(0)})]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-white",children:w.matchedNickname||w.matchedUserId}),s.jsxs("div",{className:"text-xs text-gray-500 font-mono",children:[w.matchedUserId.slice(0,16),"..."]})]})]})}),s.jsx(xe,{children:s.jsx(Ue,{className:"bg-[#38bdac]/20 text-[#38bdac] border-0",children:yw[w.matchType]||w.matchType})}),s.jsxs(xe,{className:"text-gray-400 text-sm",children:[w.phone&&s.jsxs("div",{children:["📱 ",w.phone]}),w.wechatId&&s.jsxs("div",{children:["💬 ",w.wechatId]}),!w.phone&&!w.wechatId&&"-"]}),s.jsx(xe,{className:"text-gray-400",children:w.createdAt?new Date(w.createdAt).toLocaleString():"-"})]},w.id)),t.length===0&&s.jsx(st,{children:s.jsx(xe,{colSpan:5,className:"text-center py-12 text-gray-500",children:"暂无匹配记录"})})]})]}),s.jsx(gs,{page:i,totalPages:j,total:n,pageSize:o,onPageChange:a,onPageSizeChange:w=>{c(w),a(1)}})]})})})]})}function vV(){const[t,e]=v.useState([]),[n,r]=v.useState(!0);async function i(){r(!0);try{const a=await Le("/api/db/vip-members?limit=100");if(a!=null&&a.success&&a.data){const o=[...a.data].map((c,u)=>({...c,vipSort:typeof c.vipSort=="number"?c.vipSort:u+1}));o.sort((c,u)=>(c.vipSort??999999)-(u.vipSort??999999)),e(o)}}catch(a){console.error("Load VIP members error:",a),ie.error("加载 VIP 成员失败")}finally{r(!1)}}return v.useEffect(()=>{i()},[]),s.jsxs("div",{className:"p-8 w-full",children:[s.jsx("div",{className:"flex justify-between items-center mb-8",children:s.jsxs("div",{children:[s.jsxs("h2",{className:"text-2xl font-bold text-white flex items-center gap-2",children:[s.jsx(xl,{className:"w-5 h-5 text-amber-400"}),"用户管理 / 超级个体列表"]}),s.jsx("p",{className:"text-gray-400 mt-1",children:"这里展示所有有效超级个体用户,仅用于查看其基本信息与排序值。"})]})}),s.jsx(Me,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsx(Ae,{className:"p-0",children:n?s.jsx("div",{className:"py-12 text-center text-gray-400",children:"加载中..."}):s.jsxs(Zn,{children:[s.jsx(er,{children:s.jsxs(st,{className:"bg-[#0a1628] border-gray-700",children:[s.jsx(je,{className:"text-gray-400 w-20",children:"序号"}),s.jsx(je,{className:"text-gray-400",children:"成员"}),s.jsx(je,{className:"text-gray-400 w-40",children:"超级个体"}),s.jsx(je,{className:"text-gray-400 w-28",children:"排序值"})]})}),s.jsxs(tr,{children:[t.map((a,o)=>{var c;return s.jsxs(st,{className:"border-gray-700/50",children:[s.jsx(xe,{className:"text-gray-300",children:o+1}),s.jsx(xe,{children:s.jsxs("div",{className:"flex items-center gap-3",children:[a.avatar?s.jsx("img",{src:a.avatar,className:"w-8 h-8 rounded-full object-cover border border-amber-400/60"}):s.jsx("div",{className:"w-8 h-8 rounded-full bg-amber-500/20 border border-amber-400/60 flex items-center justify-center text-amber-300 text-sm",children:((c=a.name)==null?void 0:c[0])||"创"}),s.jsx("div",{className:"min-w-0",children:s.jsx("div",{className:"text-white text-sm truncate",children:a.name})})]})}),s.jsx(xe,{className:"text-gray-300",children:a.vipRole||s.jsx("span",{className:"text-gray-500",children:"(未设置超级个体)"})}),s.jsx(xe,{className:"text-gray-300",children:a.vipSort??o+1})]},a.id)}),t.length===0&&s.jsx(st,{children:s.jsx(xe,{colSpan:5,className:"text-center py-12 text-gray-500",children:"当前没有有效的超级个体用户。"})})]})]})})})]})}function R4(t){const[e,n]=v.useState([]),[r,i]=v.useState(!0),[a,o]=v.useState(!1),[c,u]=v.useState(null),[h,f]=v.useState({name:"",avatar:"",intro:"",tags:"",priceSingle:"",priceHalfYear:"",priceYear:"",quote:"",whyFind:"",offering:"",judgmentStyle:"",sort:0,enabled:!0}),[m,g]=v.useState(!1),[y,b]=v.useState(!1),j=v.useRef(null),w=async P=>{var _;const L=(_=P.target.files)==null?void 0:_[0];if(L){b(!0);try{const X=new FormData;X.append("file",L),X.append("folder","mentors");const ne=Ox(),J={};ne&&(J.Authorization=`Bearer ${ne}`);const R=await(await fetch(ho("/api/upload"),{method:"POST",body:X,credentials:"include",headers:J})).json();R!=null&&R.success&&(R!=null&&R.url)?f(F=>({...F,avatar:R.url})):ie.error("上传失败: "+((R==null?void 0:R.error)||"未知错误"))}catch(X){console.error(X),ie.error("上传失败")}finally{b(!1),j.current&&(j.current.value="")}}};async function N(){i(!0);try{const P=await Le("/api/db/mentors");P!=null&&P.success&&P.data&&n(P.data)}catch(P){console.error("Load mentors error:",P)}finally{i(!1)}}v.useEffect(()=>{N()},[]);const C=()=>{f({name:"",avatar:"",intro:"",tags:"",priceSingle:"",priceHalfYear:"",priceYear:"",quote:"",whyFind:"",offering:"",judgmentStyle:"",sort:e.length>0?Math.max(...e.map(P=>P.sort))+1:0,enabled:!0})},E=()=>{u(null),C(),o(!0)},M=P=>{u(P),f({name:P.name,avatar:P.avatar||"",intro:P.intro||"",tags:P.tags||"",priceSingle:P.priceSingle!=null?String(P.priceSingle):"",priceHalfYear:P.priceHalfYear!=null?String(P.priceHalfYear):"",priceYear:P.priceYear!=null?String(P.priceYear):"",quote:P.quote||"",whyFind:P.whyFind||"",offering:P.offering||"",judgmentStyle:P.judgmentStyle||"",sort:P.sort,enabled:P.enabled??!0}),o(!0)},I=async()=>{if(!h.name.trim()){ie.error("导师姓名不能为空");return}g(!0);try{const P=_=>_===""?void 0:parseFloat(_),L={name:h.name.trim(),avatar:h.avatar.trim()||void 0,intro:h.intro.trim()||void 0,tags:h.tags.trim()||void 0,priceSingle:P(h.priceSingle),priceHalfYear:P(h.priceHalfYear),priceYear:P(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 _=await Mt("/api/db/mentors",{id:c.id,...L});_!=null&&_.success?(o(!1),N()):ie.error("更新失败: "+(_==null?void 0:_.error))}else{const _=await Nt("/api/db/mentors",L);_!=null&&_.success?(o(!1),N()):ie.error("新增失败: "+(_==null?void 0:_.error))}}catch(P){console.error("Save error:",P),ie.error("保存失败")}finally{g(!1)}},O=async P=>{if(confirm("确定删除该导师?"))try{const L=await Ps(`/api/db/mentors?id=${P}`);L!=null&&L.success?N():ie.error("删除失败: "+(L==null?void 0:L.error))}catch(L){console.error("Delete error:",L),ie.error("删除失败")}},D=P=>P!=null?`¥${P}`:"-";return s.jsxs("div",{className:"p-8 w-full",children:[s.jsxs("div",{className:"flex justify-between items-center mb-8",children:[s.jsxs("div",{children:[s.jsxs("h2",{className:"text-2xl font-bold text-white flex items-center gap-2",children:[s.jsx(Un,{className:"w-5 h-5 text-[#38bdac]"}),"导师管理"]}),s.jsx("p",{className:"text-gray-400 mt-1",children:"stitch_soul 导师列表,支持每个导师独立配置单次/半年/年度价格"})]}),s.jsxs(ee,{onClick:E,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(dn,{className:"w-4 h-4 mr-2"}),"新增导师"]})]}),s.jsx(Me,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsx(Ae,{className:"p-0",children:r?s.jsx("div",{className:"py-12 text-center text-gray-400",children:"加载中..."}):s.jsxs(Zn,{children:[s.jsx(er,{children:s.jsxs(st,{className:"bg-[#0a1628] border-gray-700",children:[s.jsx(je,{className:"text-gray-400",children:"ID"}),s.jsx(je,{className:"text-gray-400",children:"姓名"}),s.jsx(je,{className:"text-gray-400",children:"简介"}),s.jsx(je,{className:"text-gray-400",children:"单次"}),s.jsx(je,{className:"text-gray-400",children:"半年"}),s.jsx(je,{className:"text-gray-400",children:"年度"}),s.jsx(je,{className:"text-gray-400",children:"排序"}),s.jsx(je,{className:"text-right text-gray-400",children:"操作"})]})}),s.jsxs(tr,{children:[e.map(P=>s.jsxs(st,{className:"border-gray-700/50",children:[s.jsx(xe,{className:"text-gray-300",children:P.id}),s.jsx(xe,{className:"text-white",children:P.name}),s.jsx(xe,{className:"text-gray-400 max-w-[200px] truncate",children:P.intro||"-"}),s.jsx(xe,{className:"text-gray-400",children:D(P.priceSingle)}),s.jsx(xe,{className:"text-gray-400",children:D(P.priceHalfYear)}),s.jsx(xe,{className:"text-gray-400",children:D(P.priceYear)}),s.jsx(xe,{className:"text-gray-400",children:P.sort}),s.jsxs(xe,{className:"text-right",children:[s.jsx(ee,{variant:"ghost",size:"sm",onClick:()=>M(P),className:"text-gray-400 hover:text-[#38bdac]",children:s.jsx(_t,{className:"w-4 h-4"})}),s.jsx(ee,{variant:"ghost",size:"sm",onClick:()=>O(P.id),className:"text-gray-400 hover:text-red-400",children:s.jsx(Bn,{className:"w-4 h-4"})})]})]},P.id)),e.length===0&&s.jsx(st,{children:s.jsx(xe,{colSpan:8,className:"text-center py-12 text-gray-500",children:"暂无导师,点击「新增导师」添加"})})]})]})})}),s.jsx(Kt,{open:a,onOpenChange:o,children:s.jsxs(zt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-lg max-h-[90vh] overflow-y-auto",children:[s.jsx(qt,{children:s.jsx(Gt,{className:"text-white",children:c?"编辑导师":"新增导师"})}),s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"姓名 *"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如:卡若",value:h.name,onChange:P=>f(L=>({...L,name:P.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"排序"}),s.jsx(oe,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:h.sort,onChange:P=>f(L=>({...L,sort:parseInt(P.target.value,10)||0}))})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"头像"}),s.jsxs("div",{className:"flex gap-3 items-center",children:[s.jsx(oe,{className:"flex-1 bg-[#0a1628] border-gray-700 text-white",value:h.avatar,onChange:P=>f(L=>({...L,avatar:P.target.value})),placeholder:"点击上传或粘贴图片地址"}),s.jsx("input",{ref:j,type:"file",accept:"image/*",className:"hidden",onChange:w}),s.jsxs(ee,{type:"button",variant:"outline",size:"sm",className:"border-gray-600 text-gray-400 shrink-0",disabled:y,onClick:()=>{var P;return(P=j.current)==null?void 0:P.click()},children:[s.jsx(lh,{className:"w-4 h-4 mr-2"}),y?"上传中...":"上传"]})]}),h.avatar&&s.jsx("div",{className:"mt-2",children:s.jsx("img",{src:h.avatar.startsWith("http")?h.avatar:ho(h.avatar),alt:"头像预览",className:"w-20 h-20 rounded-full object-cover border border-gray-600"})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"简介"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如:结构判断型咨询 · Decision > Execution",value:h.intro,onChange:P=>f(L=>({...L,intro:P.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"技能标签(逗号分隔)"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如:项目结构判断、风险止损、人×项目匹配",value:h.tags,onChange:P=>f(L=>({...L,tags:P.target.value}))})]}),s.jsxs("div",{className:"border-t border-gray-700 pt-4",children:[s.jsx(Z,{className:"text-gray-300 block mb-2",children:"价格配置(每个导师独立)"}),s.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-500 text-xs",children:"单次咨询 ¥"}),s.jsx(oe,{type:"number",step:"0.01",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"980",value:h.priceSingle,onChange:P=>f(L=>({...L,priceSingle:P.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-500 text-xs",children:"半年咨询 ¥"}),s.jsx(oe,{type:"number",step:"0.01",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"19800",value:h.priceHalfYear,onChange:P=>f(L=>({...L,priceHalfYear:P.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-500 text-xs",children:"年度咨询 ¥"}),s.jsx(oe,{type:"number",step:"0.01",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"29800",value:h.priceYear,onChange:P=>f(L=>({...L,priceYear:P.target.value}))})]})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"引言"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如:大多数人失败,不是因为不努力...",value:h.quote,onChange:P=>f(L=>({...L,quote:P.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"为什么找(文本)"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"",value:h.whyFind,onChange:P=>f(L=>({...L,whyFind:P.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"提供什么(文本)"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"",value:h.offering,onChange:P=>f(L=>({...L,offering:P.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"判断风格(逗号分隔)"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如:冷静、克制、偏风险视角",value:h.judgmentStyle,onChange:P=>f(L=>({...L,judgmentStyle:P.target.value}))})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"checkbox",id:"enabled",checked:h.enabled,onChange:P=>f(L=>({...L,enabled:P.target.checked})),className:"rounded border-gray-600 bg-[#0a1628]"}),s.jsx(Z,{htmlFor:"enabled",className:"text-gray-300 cursor-pointer",children:"上架(小程序可见)"})]})]}),s.jsxs(hn,{children:[s.jsxs(ee,{variant:"outline",onClick:()=>o(!1),className:"border-gray-600 text-gray-300",children:[s.jsx(hr,{className:"w-4 h-4 mr-2"}),"取消"]}),s.jsxs(ee,{onClick:I,disabled:m,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(gn,{className:"w-4 h-4 mr-2"}),m?"保存中...":"保存"]})]})]})})]})}function bV(){const[t,e]=v.useState([]),[n,r]=v.useState(!0),[i,a]=v.useState("");async function o(){r(!0);try{const h=i?`/api/db/mentor-consultations?status=${i}`:"/api/db/mentor-consultations",f=await Le(h);f!=null&&f.success&&f.data&&e(f.data)}catch(h){console.error("Load consultations error:",h)}finally{r(!1)}}v.useEffect(()=>{o()},[i]);const c={created:"已创建",pending_pay:"待支付",paid:"已支付",completed:"已完成",cancelled:"已取消"},u={single:"单次",half_year:"半年",year:"年度"};return s.jsxs("div",{className:"p-8 w-full",children:[s.jsxs("div",{className:"flex justify-between items-center mb-8",children:[s.jsxs("div",{children:[s.jsxs("h2",{className:"text-2xl font-bold text-white flex items-center gap-2",children:[s.jsx(ih,{className:"w-5 h-5 text-[#38bdac]"}),"导师预约列表"]}),s.jsx("p",{className:"text-gray-400 mt-1",children:"stitch_soul 导师咨询预约记录"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("select",{value:i,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:[s.jsx("option",{value:"",children:"全部状态"}),Object.entries(c).map(([h,f])=>s.jsx("option",{value:h,children:f},h))]}),s.jsxs(ee,{onClick:o,disabled:n,variant:"outline",className:"border-gray-600 text-gray-300",children:[s.jsx(Ge,{className:`w-4 h-4 mr-2 ${n?"animate-spin":""}`}),"刷新"]})]})]}),s.jsx(Me,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsx(Ae,{className:"p-0",children:n?s.jsx("div",{className:"py-12 text-center text-gray-400",children:"加载中..."}):s.jsxs(Zn,{children:[s.jsx(er,{children:s.jsxs(st,{className:"bg-[#0a1628] border-gray-700",children:[s.jsx(je,{className:"text-gray-400",children:"ID"}),s.jsx(je,{className:"text-gray-400",children:"用户ID"}),s.jsx(je,{className:"text-gray-400",children:"导师ID"}),s.jsx(je,{className:"text-gray-400",children:"类型"}),s.jsx(je,{className:"text-gray-400",children:"金额"}),s.jsx(je,{className:"text-gray-400",children:"状态"}),s.jsx(je,{className:"text-gray-400",children:"创建时间"})]})}),s.jsxs(tr,{children:[t.map(h=>s.jsxs(st,{className:"border-gray-700/50",children:[s.jsx(xe,{className:"text-gray-300",children:h.id}),s.jsx(xe,{className:"text-gray-400",children:h.userId}),s.jsx(xe,{className:"text-gray-400",children:h.mentorId}),s.jsx(xe,{className:"text-gray-400",children:u[h.consultationType]||h.consultationType}),s.jsxs(xe,{className:"text-white",children:["¥",h.amount]}),s.jsx(xe,{className:"text-gray-400",children:c[h.status]||h.status}),s.jsx(xe,{className:"text-gray-500 text-sm",children:h.createdAt})]},h.id)),t.length===0&&s.jsx(st,{children:s.jsx(xe,{colSpan:7,className:"text-center py-12 text-gray-500",children:"暂无预约记录"})})]})]})})})]})}const Pc={poolSource:["vip"],requirePhone:!0,requireNickname:!0,requireAvatar:!1,requireBusiness:!1},vw={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:Pc},NV=["⭐","👥","❤️","🎮","💼","🚀","💡","🎯","🔥","✨"];function wV(){const t=ja(),[e,n]=v.useState(vw),[r,i]=v.useState(!0),[a,o]=v.useState(!1),[c,u]=v.useState(!1),[h,f]=v.useState(null),[m,g]=v.useState({id:"",label:"",matchLabel:"",icon:"⭐",matchFromDB:!1,showJoinAfterMatch:!0,price:1,enabled:!0}),[y,b]=v.useState(null),[j,w]=v.useState(!1),N=async()=>{w(!0);try{const L=await Le("/api/db/match-pool-counts");L!=null&&L.success&&L.data&&b(L.data)}catch(L){console.error("加载池子人数失败:",L)}finally{w(!1)}},C=async()=>{i(!0);try{const L=await Le("/api/db/config/full?key=match_config"),_=(L==null?void 0:L.data)??(L==null?void 0:L.config);if(_){let X=_.poolSettings??Pc;X.poolSource&&!Array.isArray(X.poolSource)&&(X={...X,poolSource:[X.poolSource]}),n({...vw,..._,poolSettings:X})}}catch(L){console.error("加载匹配配置失败:",L)}finally{i(!1)}};v.useEffect(()=>{C(),N()},[]);const E=async()=>{o(!0);try{const L=await Nt("/api/db/config",{key:"match_config",value:e,description:"匹配功能配置"});ie.error((L==null?void 0:L.success)!==!1?"配置保存成功!":"保存失败: "+((L==null?void 0:L.error)||"未知错误"))}catch(L){console.error(L),ie.error("保存失败")}finally{o(!1)}},M=L=>{f(L),g({...L}),u(!0)},I=()=>{f(null),g({id:"",label:"",matchLabel:"",icon:"⭐",matchFromDB:!1,showJoinAfterMatch:!0,price:1,enabled:!0}),u(!0)},O=()=>{if(!m.id||!m.label){ie.error("请填写类型ID和名称");return}const L=[...e.matchTypes];if(h){const _=L.findIndex(X=>X.id===h.id);_!==-1&&(L[_]={...m})}else{if(L.some(_=>_.id===m.id)){ie.error("类型ID已存在");return}L.push({...m})}n({...e,matchTypes:L}),u(!1)},D=L=>{confirm("确定要删除这个匹配类型吗?")&&n({...e,matchTypes:e.matchTypes.filter(_=>_.id!==L)})},P=L=>{n({...e,matchTypes:e.matchTypes.map(_=>_.id===L?{..._,enabled:!_.enabled}:_)})};return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"flex justify-end gap-3",children:[s.jsxs(ee,{variant:"outline",onClick:C,disabled:r,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Ge,{className:`w-4 h-4 mr-2 ${r?"animate-spin":""}`})," 刷新"]}),s.jsxs(ee,{onClick:E,disabled:a,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(gn,{className:"w-4 h-4 mr-2"})," ",a?"保存中...":"保存配置"]})]}),s.jsxs(Me,{className:"bg-[#0f2137] border-gray-700/50",children:[s.jsxs(nt,{children:[s.jsxs(rt,{className:"text-white flex items-center gap-2",children:[s.jsx(Ww,{className:"w-5 h-5 text-blue-400"})," 匹配池选择"]}),s.jsx($t,{className:"text-gray-400",children:"选择匹配的用户池和完善程度要求,只有满足条件的用户才可被匹配到"})]}),s.jsxs(Ae,{className:"space-y-6",children:[s.jsxs("div",{className:"space-y-3",children:[s.jsx(Z,{className:"text-gray-300",children:"匹配来源池"}),s.jsx("p",{className:"text-gray-500 text-xs",children:"可同时勾选多个池子(取并集匹配)"}),s.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(L=>{const _=e.poolSettings??Pc,ne=(Array.isArray(_.poolSource)?_.poolSource:[_.poolSource]).includes(L.value),J=y==null?void 0:y[L.countKey],U=()=>{const R=Array.isArray(_.poolSource)?[..._.poolSource]:[_.poolSource],F=ne?R.filter(re=>re!==L.value):[...R,L.value];F.length===0&&F.push(L.value),n({...e,poolSettings:{..._,poolSource:F}})};return s.jsxs("button",{type:"button",onClick:U,className:`p-4 rounded-lg border text-left transition-all ${ne?"border-[#38bdac] bg-[#38bdac]/10":"border-gray-700 bg-[#0a1628] hover:border-gray-600"}`,children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:`w-5 h-5 rounded border-2 flex items-center justify-center text-xs ${ne?"border-[#38bdac] bg-[#38bdac] text-white":"border-gray-600"}`,children:ne&&"✓"}),s.jsx("span",{className:"text-xl",children:L.icon}),s.jsx("span",{className:`text-sm font-medium ${ne?"text-[#38bdac]":"text-gray-300"}`,children:L.label})]}),s.jsxs("span",{className:"text-lg font-bold text-white",children:[j?"...":J??"-",s.jsx("span",{className:"text-xs text-gray-500 font-normal ml-1",children:"人"})]})]}),s.jsx("p",{className:"text-gray-500 text-xs mt-2",children:L.desc}),s.jsx("span",{role:"link",tabIndex:0,onClick:R=>{R.stopPropagation(),t(`/users?pool=${L.value}`)},onKeyDown:R=>{R.key==="Enter"&&(R.stopPropagation(),t(`/users?pool=${L.value}`))},className:"text-[#38bdac] text-xs mt-2 inline-block hover:underline cursor-pointer",children:"查看用户列表 →"})]},L.value)})})]}),s.jsxs("div",{className:"space-y-3 pt-4 border-t border-gray-700/50",children:[s.jsx(Z,{className:"text-gray-300",children:"用户资料完善要求(被匹配用户必须满足以下条件)"}),s.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(L=>{const X=(e.poolSettings??Pc)[L.key];return s.jsxs("div",{className:"flex items-center gap-3 bg-[#0a1628] rounded-lg p-3",children:[s.jsx(Et,{checked:X,onCheckedChange:ne=>n({...e,poolSettings:{...e.poolSettings??Pc,[L.key]:ne}})}),s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("span",{children:L.icon}),s.jsx(Z,{className:"text-gray-300 text-sm",children:L.label})]})]},L.key)})})]})]})]}),s.jsxs(Me,{className:"bg-[#0f2137] border-gray-700/50",children:[s.jsxs(nt,{children:[s.jsxs(rt,{className:"text-white flex items-center gap-2",children:[s.jsx(ia,{className:"w-5 h-5 text-yellow-400"})," 基础设置"]}),s.jsx($t,{className:"text-gray-400",children:"配置免费匹配次数和付费规则"})]}),s.jsxs(Ae,{className:"space-y-6",children:[s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"每日免费匹配次数"}),s.jsx(oe,{type:"number",min:0,max:100,className:"bg-[#0a1628] border-gray-700 text-white",value:e.freeMatchLimit,onChange:L=>n({...e,freeMatchLimit:parseInt(L.target.value,10)||0})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"付费匹配价格(元)"}),s.jsx(oe,{type:"number",min:.01,step:.01,className:"bg-[#0a1628] border-gray-700 text-white",value:e.matchPrice,onChange:L=>n({...e,matchPrice:parseFloat(L.target.value)||1})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"每日最大匹配次数"}),s.jsx(oe,{type:"number",min:1,max:100,className:"bg-[#0a1628] border-gray-700 text-white",value:e.settings.maxMatchesPerDay,onChange:L=>n({...e,settings:{...e.settings,maxMatchesPerDay:parseInt(L.target.value,10)||10}})})]})]}),s.jsxs("div",{className:"flex gap-8 pt-4 border-t border-gray-700/50",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Et,{checked:e.settings.enableFreeMatches,onCheckedChange:L=>n({...e,settings:{...e.settings,enableFreeMatches:L}})}),s.jsx(Z,{className:"text-gray-300",children:"启用免费匹配"})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Et,{checked:e.settings.enablePaidMatches,onCheckedChange:L=>n({...e,settings:{...e.settings,enablePaidMatches:L}})}),s.jsx(Z,{className:"text-gray-300",children:"启用付费匹配"})]})]})]})]}),s.jsxs(Me,{className:"bg-[#0f2137] border-gray-700/50",children:[s.jsxs(nt,{className:"flex flex-row items-center justify-between",children:[s.jsxs("div",{children:[s.jsxs(rt,{className:"text-white flex items-center gap-2",children:[s.jsx(Un,{className:"w-5 h-5 text-[#38bdac]"})," 匹配类型管理"]}),s.jsx($t,{className:"text-gray-400",children:"配置不同的匹配类型及其价格"})]}),s.jsxs(ee,{onClick:I,size:"sm",className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(dn,{className:"w-4 h-4 mr-1"})," 添加类型"]})]}),s.jsx(Ae,{children:s.jsxs(Zn,{children:[s.jsx(er,{children:s.jsxs(st,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[s.jsx(je,{className:"text-gray-400",children:"图标"}),s.jsx(je,{className:"text-gray-400",children:"类型ID"}),s.jsx(je,{className:"text-gray-400",children:"显示名称"}),s.jsx(je,{className:"text-gray-400",children:"匹配标签"}),s.jsx(je,{className:"text-gray-400",children:"价格"}),s.jsx(je,{className:"text-gray-400",children:"数据库匹配"}),s.jsx(je,{className:"text-gray-400",children:"状态"}),s.jsx(je,{className:"text-right text-gray-400",children:"操作"})]})}),s.jsx(tr,{children:e.matchTypes.map(L=>s.jsxs(st,{className:"hover:bg-[#0a1628] border-gray-700/50",children:[s.jsx(xe,{children:s.jsx("span",{className:"text-2xl",children:L.icon})}),s.jsx(xe,{className:"font-mono text-gray-300",children:L.id}),s.jsx(xe,{className:"text-white font-medium",children:L.label}),s.jsx(xe,{className:"text-gray-300",children:L.matchLabel}),s.jsx(xe,{children:s.jsxs(Ue,{className:"bg-yellow-500/20 text-yellow-400 hover:bg-yellow-500/20 border-0",children:["¥",L.price]})}),s.jsx(xe,{children:L.matchFromDB?s.jsx(Ue,{className:"bg-green-500/20 text-green-400 hover:bg-green-500/20 border-0",children:"是"}):s.jsx(Ue,{variant:"outline",className:"text-gray-500 border-gray-600",children:"否"})}),s.jsx(xe,{children:s.jsx(Et,{checked:L.enabled,onCheckedChange:()=>P(L.id)})}),s.jsx(xe,{className:"text-right",children:s.jsxs("div",{className:"flex items-center justify-end gap-1",children:[s.jsx(ee,{variant:"ghost",size:"sm",onClick:()=>M(L),className:"text-gray-400 hover:text-[#38bdac] hover:bg-[#38bdac]/10",children:s.jsx(_t,{className:"w-4 h-4"})}),s.jsx(ee,{variant:"ghost",size:"sm",onClick:()=>D(L.id),className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:s.jsx(Bn,{className:"w-4 h-4"})})]})})]},L.id))})]})})]}),s.jsx(Kt,{open:c,onOpenChange:u,children:s.jsxs(zt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-lg",showCloseButton:!0,children:[s.jsx(qt,{children:s.jsxs(Gt,{className:"text-white flex items-center gap-2",children:[h?s.jsx(_t,{className:"w-5 h-5 text-[#38bdac]"}):s.jsx(dn,{className:"w-5 h-5 text-[#38bdac]"}),h?"编辑匹配类型":"添加匹配类型"]})}),s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"类型ID(英文)"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如: partner",value:m.id,onChange:L=>g({...m,id:L.target.value}),disabled:!!h})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"图标"}),s.jsx("div",{className:"flex gap-1 flex-wrap",children:NV.map(L=>s.jsx("button",{type:"button",className:`w-8 h-8 text-lg rounded ${m.icon===L?"bg-[#38bdac]/30 ring-1 ring-[#38bdac]":"bg-[#0a1628]"}`,onClick:()=>g({...m,icon:L}),children:L},L))})]})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"显示名称"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如: 超级个体",value:m.label,onChange:L=>g({...m,label:L.target.value})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"匹配标签"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如: 超级个体",value:m.matchLabel,onChange:L=>g({...m,matchLabel:L.target.value})})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"单次匹配价格(元)"}),s.jsx(oe,{type:"number",min:.01,step:.01,className:"bg-[#0a1628] border-gray-700 text-white",value:m.price,onChange:L=>g({...m,price:parseFloat(L.target.value)||1})})]}),s.jsxs("div",{className:"flex gap-6 pt-2",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Et,{checked:m.matchFromDB,onCheckedChange:L=>g({...m,matchFromDB:L})}),s.jsx(Z,{className:"text-gray-300 text-sm",children:"从数据库匹配"})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Et,{checked:m.showJoinAfterMatch,onCheckedChange:L=>g({...m,showJoinAfterMatch:L})}),s.jsx(Z,{className:"text-gray-300 text-sm",children:"匹配后显示加入"})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Et,{checked:m.enabled,onCheckedChange:L=>g({...m,enabled:L})}),s.jsx(Z,{className:"text-gray-300 text-sm",children:"启用"})]})]})]}),s.jsxs(hn,{children:[s.jsx(ee,{variant:"outline",onClick:()=>u(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"取消"}),s.jsxs(ee,{onClick:O,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(gn,{className:"w-4 h-4 mr-2"})," 保存"]})]})]})})]})}const bw={partner:"找伙伴",investor:"资源对接",mentor:"导师顾问",team:"团队招募"};function jV(){const[t,e]=v.useState([]),[n,r]=v.useState(0),[i,a]=v.useState(1),[o,c]=v.useState(10),[u,h]=v.useState(""),[f,m]=v.useState(!0),[g,y]=v.useState(null),[b,j]=v.useState(null);async function w(){m(!0),y(null);try{const E=new URLSearchParams({page:String(i),pageSize:String(o)});u&&E.set("matchType",u);const M=await Le(`/api/db/match-records?${E}`);M!=null&&M.success?(e(M.records||[]),r(M.total??0)):y("加载匹配记录失败")}catch{y("加载失败,请检查网络后重试")}finally{m(!1)}}v.useEffect(()=>{w()},[i,u]);const N=Math.ceil(n/o)||1,C=({userId:E,nickname:M,avatar:I})=>s.jsxs("div",{className:"flex items-center gap-3 cursor-pointer group",onClick:()=>j(E),children:[s.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:[I?s.jsx("img",{src:I,alt:"",className:"w-full h-full object-cover",onError:O=>{O.currentTarget.style.display="none"}}):null,s.jsx("span",{className:I?"hidden":"",children:(M||E||"?").charAt(0)})]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-white group-hover:text-[#38bdac] transition-colors",children:M||E}),s.jsxs("div",{className:"text-xs text-gray-500 font-mono",children:[E==null?void 0:E.slice(0,16),(E==null?void 0:E.length)>16?"...":""]})]})]});return s.jsxs("div",{children:[g&&s.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:[s.jsx("span",{children:g}),s.jsx("button",{type:"button",onClick:()=>y(null),className:"hover:text-red-300",children:"×"})]}),s.jsxs("div",{className:"flex justify-between items-center mb-4",children:[s.jsxs("p",{className:"text-gray-400",children:["共 ",n," 条匹配记录 · 点击用户名查看详情"]}),s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsxs("select",{value:u,onChange:E=>{h(E.target.value),a(1)},className:"bg-[#0f2137] border border-gray-700 text-white rounded-lg px-3 py-2 text-sm",children:[s.jsx("option",{value:"",children:"全部类型"}),Object.entries(bw).map(([E,M])=>s.jsx("option",{value:E,children:M},E))]}),s.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:[s.jsx(Ge,{className:`w-4 h-4 ${f?"animate-spin":""}`})," 刷新"]})]})]}),s.jsx(Me,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:s.jsx(Ae,{className:"p-0",children:f?s.jsxs("div",{className:"flex justify-center py-12",children:[s.jsx(Ge,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):s.jsxs(s.Fragment,{children:[s.jsxs(Zn,{children:[s.jsx(er,{children:s.jsxs(st,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[s.jsx(je,{className:"text-gray-400",children:"发起人"}),s.jsx(je,{className:"text-gray-400",children:"匹配到"}),s.jsx(je,{className:"text-gray-400",children:"类型"}),s.jsx(je,{className:"text-gray-400",children:"联系方式"}),s.jsx(je,{className:"text-gray-400",children:"匹配时间"})]})}),s.jsxs(tr,{children:[t.map(E=>s.jsxs(st,{className:"hover:bg-[#0a1628] border-gray-700/50",children:[s.jsx(xe,{children:s.jsx(C,{userId:E.userId,nickname:E.userNickname,avatar:E.userAvatar})}),s.jsx(xe,{children:E.matchedUserId?s.jsx(C,{userId:E.matchedUserId,nickname:E.matchedNickname,avatar:E.matchedUserAvatar}):s.jsx("span",{className:"text-gray-500",children:"—"})}),s.jsx(xe,{children:s.jsx(Ue,{className:"bg-[#38bdac]/20 text-[#38bdac] border-0",children:bw[E.matchType]||E.matchType})}),s.jsxs(xe,{className:"text-sm",children:[E.phone&&s.jsxs("div",{className:"text-green-400",children:["📱 ",E.phone]}),E.wechatId&&s.jsxs("div",{className:"text-blue-400",children:["💬 ",E.wechatId]}),!E.phone&&!E.wechatId&&s.jsx("span",{className:"text-gray-600",children:"-"})]}),s.jsx(xe,{className:"text-gray-400",children:E.createdAt?new Date(E.createdAt).toLocaleString():"-"})]},E.id)),t.length===0&&s.jsx(st,{children:s.jsx(xe,{colSpan:5,className:"text-center py-12 text-gray-500",children:"暂无匹配记录"})})]})]}),s.jsx(gs,{page:i,totalPages:N,total:n,pageSize:o,onPageChange:a,onPageSizeChange:E=>{c(E),a(1)}})]})})}),s.jsx(Jx,{open:!!b,onClose:()=>j(null),userId:b,onUserUpdated:w})]})}function kV(){const[t,e]=v.useState("records");return s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex gap-2",children:[s.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:"匹配记录"}),s.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"&&s.jsx(jV,{}),t==="pool"&&s.jsx(wV,{})]})}const Nw={investor:"资源对接",mentor:"导师顾问",team:"团队招募"};function SV(){const[t,e]=v.useState([]),[n,r]=v.useState(0),[i,a]=v.useState(1),[o,c]=v.useState(10),[u,h]=v.useState(!0),[f,m]=v.useState("investor"),[g,y]=v.useState(null);async function b(){h(!0);try{const C=new URLSearchParams({page:String(i),pageSize:String(o),matchType:f}),E=await Le(`/api/db/match-records?${C}`);E!=null&&E.success&&(e(E.records||[]),r(E.total??0))}catch(C){console.error(C)}finally{h(!1)}}v.useEffect(()=>{b()},[i,f]);const j=async C=>{if(!C.phone&&!C.wechatId){ie.info("该记录无联系方式,无法推送到存客宝");return}y(C.id);try{const E=await Nt("/api/ckb/join",{type:C.matchType||"investor",phone:C.phone||"",wechat:C.wechatId||"",userId:C.userId,name:C.userNickname||""});ie.error((E==null?void 0:E.message)||(E!=null&&E.success?"推送成功":"推送失败"))}catch(E){ie.error("推送失败: "+(E instanceof Error?E.message:"网络错误"))}finally{y(null)}},w=Math.ceil(n/o)||1,N=C=>!!(C.phone||C.wechatId);return s.jsxs("div",{children:[s.jsxs("div",{className:"flex justify-between items-center mb-4",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-gray-400",children:"点击获客:有人填写手机号/微信号的直接显示,可一键推送到存客宝"}),s.jsxs("p",{className:"text-gray-500 text-xs mt-1",children:["共 ",n," 条记录 — 有联系方式的可触发存客宝添加好友"]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("select",{value:f,onChange:C=>{m(C.target.value),a(1)},className:"bg-[#0f2137] border border-gray-700 text-white rounded-lg px-3 py-2 text-sm",children:Object.entries(Nw).map(([C,E])=>s.jsx("option",{value:C,children:E},C))}),s.jsxs(ee,{onClick:b,disabled:u,variant:"outline",className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Ge,{className:`w-4 h-4 mr-2 ${u?"animate-spin":""}`})," 刷新"]})]})]}),s.jsx(Me,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:s.jsx(Ae,{className:"p-0",children:u?s.jsxs("div",{className:"flex justify-center py-12",children:[s.jsx(Ge,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):s.jsxs(s.Fragment,{children:[s.jsxs(Zn,{children:[s.jsx(er,{children:s.jsxs(st,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[s.jsx(je,{className:"text-gray-400",children:"发起人"}),s.jsx(je,{className:"text-gray-400",children:"匹配到"}),s.jsx(je,{className:"text-gray-400",children:"类型"}),s.jsx(je,{className:"text-gray-400",children:"联系方式"}),s.jsx(je,{className:"text-gray-400",children:"时间"}),s.jsx(je,{className:"text-gray-400 text-right",children:"操作"})]})}),s.jsxs(tr,{children:[t.map(C=>{var E,M;return s.jsxs(st,{className:`border-gray-700/50 ${N(C)?"hover:bg-[#0a1628]":"opacity-60"}`,children:[s.jsx(xe,{className:"text-white",children:C.userNickname||((E=C.userId)==null?void 0:E.slice(0,12))}),s.jsx(xe,{className:"text-white",children:C.matchedNickname||((M=C.matchedUserId)==null?void 0:M.slice(0,12))}),s.jsx(xe,{children:s.jsx(Ue,{className:"bg-[#38bdac]/20 text-[#38bdac] border-0",children:Nw[C.matchType]||C.matchType})}),s.jsxs(xe,{className:"text-sm",children:[C.phone&&s.jsxs("div",{className:"text-green-400",children:["📱 ",C.phone]}),C.wechatId&&s.jsxs("div",{className:"text-blue-400",children:["💬 ",C.wechatId]}),!C.phone&&!C.wechatId&&s.jsx("span",{className:"text-gray-600",children:"无联系方式"})]}),s.jsx(xe,{className:"text-gray-400 text-sm",children:C.createdAt?new Date(C.createdAt).toLocaleString():"-"}),s.jsx(xe,{className:"text-right",children:N(C)?s.jsxs(ee,{size:"sm",onClick:()=>j(C),disabled:g===C.id,className:"bg-[#38bdac] hover:bg-[#2da396] text-white text-xs h-7 px-3",children:[s.jsx(jA,{className:"w-3 h-3 mr-1"}),g===C.id?"推送中...":"推送CKB"]}):s.jsx("span",{className:"text-gray-600 text-xs",children:"—"})})]},C.id)}),t.length===0&&s.jsx(st,{children:s.jsx(xe,{colSpan:6,className:"text-center py-12 text-gray-500",children:"暂无记录"})})]})]}),s.jsx(gs,{page:i,totalPages:w,total:n,pageSize:o,onPageChange:a,onPageSizeChange:C=>{c(C),a(1)}})]})})})]})}const ww={created:"已创建",pending_pay:"待支付",paid:"已支付",completed:"已完成",cancelled:"已取消"},CV={single:"单次",half_year:"半年",year:"年度"};function EV(){const[t,e]=v.useState([]),[n,r]=v.useState(!0),[i,a]=v.useState("");async function o(){r(!0);try{const c=i?`/api/db/mentor-consultations?status=${i}`:"/api/db/mentor-consultations",u=await Le(c);u!=null&&u.success&&u.data&&e(u.data)}catch(c){console.error(c)}finally{r(!1)}}return v.useEffect(()=>{o()},[i]),s.jsxs("div",{children:[s.jsxs("div",{className:"flex justify-between items-center mb-4",children:[s.jsx("p",{className:"text-gray-400",children:"导师咨询预约记录"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("select",{value:i,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:[s.jsx("option",{value:"",children:"全部状态"}),Object.entries(ww).map(([c,u])=>s.jsx("option",{value:c,children:u},c))]}),s.jsxs(ee,{onClick:o,disabled:n,variant:"outline",className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Ge,{className:`w-4 h-4 mr-2 ${n?"animate-spin":""}`})," 刷新"]})]})]}),s.jsx(Me,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsx(Ae,{className:"p-0",children:n?s.jsx("div",{className:"py-12 text-center text-gray-400",children:"加载中..."}):s.jsxs(Zn,{children:[s.jsx(er,{children:s.jsxs(st,{className:"bg-[#0a1628] border-gray-700",children:[s.jsx(je,{className:"text-gray-400",children:"ID"}),s.jsx(je,{className:"text-gray-400",children:"用户ID"}),s.jsx(je,{className:"text-gray-400",children:"导师ID"}),s.jsx(je,{className:"text-gray-400",children:"类型"}),s.jsx(je,{className:"text-gray-400",children:"金额"}),s.jsx(je,{className:"text-gray-400",children:"状态"}),s.jsx(je,{className:"text-gray-400",children:"创建时间"})]})}),s.jsxs(tr,{children:[t.map(c=>s.jsxs(st,{className:"border-gray-700/50",children:[s.jsx(xe,{className:"text-gray-300",children:c.id}),s.jsx(xe,{className:"text-gray-400",children:c.userId}),s.jsx(xe,{className:"text-gray-400",children:c.mentorId}),s.jsx(xe,{className:"text-gray-400",children:CV[c.consultationType]||c.consultationType}),s.jsxs(xe,{className:"text-white",children:["¥",c.amount]}),s.jsx(xe,{className:"text-gray-400",children:ww[c.status]||c.status}),s.jsx(xe,{className:"text-gray-500 text-sm",children:c.createdAt?new Date(c.createdAt).toLocaleString():"-"})]},c.id)),t.length===0&&s.jsx(st,{children:s.jsx(xe,{colSpan:7,className:"text-center py-12 text-gray-500",children:"暂无预约记录"})})]})]})})})]})}function TV(){const[t,e]=v.useState("booking");return s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex gap-2",children:[s.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:"预约记录"}),s.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"&&s.jsx(EV,{}),t==="manage"&&s.jsx("div",{className:"-mx-8",children:s.jsx(R4,{embedded:!0})})]})}function MV(){const[t,e]=v.useState([]),[n,r]=v.useState(0),[i,a]=v.useState(1),[o,c]=v.useState(10),[u,h]=v.useState(!0);async function f(){h(!0);try{const g=new URLSearchParams({page:String(i),pageSize:String(o),matchType:"team"}),y=await Le(`/api/db/match-records?${g}`);y!=null&&y.success&&(e(y.records||[]),r(y.total??0))}catch(g){console.error(g)}finally{h(!1)}}v.useEffect(()=>{f()},[i]);const m=Math.ceil(n/o)||1;return s.jsxs("div",{children:[s.jsxs("div",{className:"flex justify-between items-center mb-4",children:[s.jsxs("div",{children:[s.jsxs("p",{className:"text-gray-400",children:["团队招募匹配记录,共 ",n," 条"]}),s.jsx("p",{className:"text-gray-500 text-xs mt-1",children:"用户通过「团队招募」提交联系方式到存客宝"})]}),s.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:[s.jsx(Ge,{className:`w-4 h-4 ${u?"animate-spin":""}`})," 刷新"]})]}),s.jsx(Me,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:s.jsx(Ae,{className:"p-0",children:u?s.jsxs("div",{className:"flex justify-center py-12",children:[s.jsx(Ge,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):s.jsxs(s.Fragment,{children:[s.jsxs(Zn,{children:[s.jsx(er,{children:s.jsxs(st,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[s.jsx(je,{className:"text-gray-400",children:"发起人"}),s.jsx(je,{className:"text-gray-400",children:"匹配到"}),s.jsx(je,{className:"text-gray-400",children:"联系方式"}),s.jsx(je,{className:"text-gray-400",children:"时间"})]})}),s.jsxs(tr,{children:[t.map(g=>s.jsxs(st,{className:"hover:bg-[#0a1628] border-gray-700/50",children:[s.jsx(xe,{className:"text-white",children:g.userNickname||g.userId}),s.jsx(xe,{className:"text-white",children:g.matchedNickname||g.matchedUserId}),s.jsxs(xe,{className:"text-gray-400 text-sm",children:[g.phone&&s.jsxs("div",{children:["📱 ",g.phone]}),g.wechatId&&s.jsxs("div",{children:["💬 ",g.wechatId]}),!g.phone&&!g.wechatId&&"-"]}),s.jsx(xe,{className:"text-gray-400",children:g.createdAt?new Date(g.createdAt).toLocaleString():"-"})]},g.id)),t.length===0&&s.jsx(st,{children:s.jsx(xe,{colSpan:4,className:"text-center py-12 text-gray-500",children:"暂无团队招募记录"})})]})]}),s.jsx(gs,{page:i,totalPages:m,total:n,pageSize:o,onPageChange:a,onPageSizeChange:g=>{c(g),a(1)}})]})})})]})}const jw={partner:"找伙伴",investor:"资源对接",mentor:"导师顾问",team:"团队招募"},kw={partner:"⭐",investor:"👥",mentor:"❤️",team:"🎮"};function AV({onSwitchTab:t,onOpenCKB:e}={}){const n=ja(),[r,i]=v.useState(null),[a,o]=v.useState(null),[c,u]=v.useState(!0),h=v.useCallback(async()=>{var m,g;u(!0);try{const[y,b]=await Promise.allSettled([Le("/api/db/match-records?stats=true"),Le("/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 Le("/api/db/match-records?page=1&pageSize=200");if(w!=null&&w.success&&w.records){const N=new Set(w.records.map(C=>C.userId).filter(Boolean));j={...j,uniqueUsers:N.size}}}catch{}i(j)}b.status==="fulfilled"&&((g=b.value)!=null&&g.success)&&b.value.data&&o(b.value.data)}catch(y){console.error("加载统计失败:",y)}finally{u(!1)}},[]);v.useEffect(()=>{h()},[h]);const f=m=>c?"—":String(m??0);return s.jsxs("div",{className:"space-y-8",children:[s.jsxs("div",{children:[s.jsxs("h3",{className:"text-lg font-semibold text-white mb-4 flex items-center gap-2",children:[s.jsx(Un,{className:"w-5 h-5 text-[#38bdac]"})," 找伙伴数据"]}),s.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-3 gap-5",children:[s.jsx(Me,{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:s.jsxs(Ae,{className:"p-6",children:[s.jsx("p",{className:"text-gray-400 text-sm mb-2",children:"总匹配次数"}),s.jsx("p",{className:"text-4xl font-bold text-white",children:f(r==null?void 0:r.totalMatches)}),s.jsxs("p",{className:"text-[#38bdac] text-xs mt-3 flex items-center gap-1",children:[s.jsx(_s,{className:"w-3 h-3"})," 查看匹配记录"]})]})}),s.jsx(Me,{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:s.jsxs(Ae,{className:"p-6",children:[s.jsx("p",{className:"text-gray-400 text-sm mb-2",children:"今日匹配"}),s.jsx("p",{className:"text-4xl font-bold text-white",children:f(r==null?void 0:r.todayMatches)}),s.jsxs("p",{className:"text-yellow-400/60 text-xs mt-3 flex items-center gap-1",children:[s.jsx(ia,{className:"w-3 h-3"})," 今日实时"]})]})}),s.jsx(Me,{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:s.jsxs(Ae,{className:"p-6",children:[s.jsx("p",{className:"text-gray-400 text-sm mb-2",children:"匹配用户数"}),s.jsx("p",{className:"text-4xl font-bold text-white",children:f(r==null?void 0:r.uniqueUsers)}),s.jsxs("p",{className:"text-blue-400/60 text-xs mt-3 flex items-center gap-1",children:[s.jsx(_s,{className:"w-3 h-3"})," 查看用户管理"]})]})}),s.jsx(Me,{className:"bg-[#0f2137] border-gray-700/40",children:s.jsxs(Ae,{className:"p-6",children:[s.jsx("p",{className:"text-gray-400 text-sm mb-2",children:"人均匹配"}),s.jsx("p",{className:"text-3xl font-bold text-white",children:c?"—":r!=null&&r.uniqueUsers?(r.totalMatches/r.uniqueUsers).toFixed(1):"0"})]})}),s.jsx(Me,{className:"bg-[#0f2137] border-gray-700/40",children:s.jsxs(Ae,{className:"p-6",children:[s.jsx("p",{className:"text-gray-400 text-sm mb-2",children:"付费匹配次数"}),s.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&&s.jsxs("div",{children:[s.jsx("h3",{className:"text-lg font-semibold text-white mb-4",children:"各类型匹配分布"}),s.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 s.jsxs("div",{className:"bg-[#0f2137] border border-gray-700/40 rounded-xl p-5",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[s.jsx("span",{className:"text-2xl",children:kw[m.matchType]||"📊"}),s.jsx("span",{className:"text-gray-300 font-medium",children:jw[m.matchType]||m.matchType})]}),s.jsx("p",{className:"text-3xl font-bold text-white mb-2",children:m.count}),s.jsx("div",{className:"w-full h-2 bg-gray-700/50 rounded-full overflow-hidden",children:s.jsx("div",{className:"h-full bg-[#38bdac] rounded-full transition-all",style:{width:`${Math.min(g,100)}%`}})}),s.jsxs("p",{className:"text-gray-500 text-xs mt-1.5",children:[g.toFixed(1),"%"]})]},m.matchType)})})]}),s.jsxs("div",{children:[s.jsxs("h3",{className:"text-lg font-semibold text-white mb-4 flex items-center gap-2",children:[s.jsx(ms,{className:"w-5 h-5 text-orange-400"})," AI 获客数据"]}),s.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-3 gap-5 mb-6",children:[s.jsx(Me,{className:"bg-[#0f2137] border-orange-500/20 cursor-pointer hover:border-orange-500/50 transition-colors",onClick:()=>e==null?void 0:e("submitted"),children:s.jsxs(Ae,{className:"p-6",children:[s.jsx("p",{className:"text-gray-400 text-sm mb-2",children:"已提交线索"}),s.jsx("p",{className:"text-3xl font-bold text-white",children:c?"—":(a==null?void 0:a.ckbTotal)??0}),s.jsx("p",{className:"text-orange-400/60 text-xs mt-2",children:"点击查看明细 →"})]})}),s.jsx(Me,{className:"bg-[#0f2137] border-orange-500/20 cursor-pointer hover:border-orange-500/50 transition-colors",onClick:()=>e==null?void 0:e("contact"),children:s.jsxs(Ae,{className:"p-6",children:[s.jsx("p",{className:"text-gray-400 text-sm mb-2",children:"有联系方式"}),s.jsx("p",{className:"text-3xl font-bold text-white",children:c?"—":(a==null?void 0:a.withContact)??0}),s.jsx("p",{className:"text-orange-400/60 text-xs mt-2",children:"点击查看明细 →"})]})}),s.jsx(Me,{className:"bg-[#0f2137] border-orange-500/20 cursor-pointer hover:border-orange-500/50 transition-colors",onClick:()=>e==null?void 0:e("test"),children:s.jsxs(Ae,{className:"p-6",children:[s.jsx("p",{className:"text-gray-400 text-sm mb-2",children:"AI 添加进度"}),s.jsx("p",{className:"text-xl font-bold text-orange-400",children:"查看详情 →"}),s.jsx("p",{className:"text-gray-500 text-xs mt-2",children:"添加成功率 · 回复率 · API 文档"})]})})]}),(a==null?void 0:a.byType)&&a.byType.length>0&&s.jsx("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-3 mb-6",children:a.byType.map(m=>s.jsxs("div",{className:"bg-[#0a1628] border border-gray-700/30 rounded-lg p-4 flex items-center gap-3",children:[s.jsx("span",{className:"text-xl",children:kw[m.matchType]||"📋"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-gray-400 text-xs",children:jw[m.matchType]||m.matchType}),s.jsx("p",{className:"text-xl font-bold text-white",children:m.total})]})]},m.matchType))})]})]})}const IV=["partner","investor","mentor","team"],gg=[{key:"join_partner",label:"找伙伴场景"},{key:"join_investor",label:"资源对接场景"},{key:"join_mentor",label:"导师顾问场景"},{key:"join_team",label:"团队招募场景"},{key:"match",label:"匹配上报"},{key:"lead",label:"链接卡若"}],Sw=`# 场景获客接口摘要 +- 地址:POST /v1/api/scenarios +- 必填:apiKey、sign、timestamp +- 主标识:phone 或 wechatId 至少一项 +- 可选:name、source、remark、tags、siteTags、portrait +- 签名:排除 sign/apiKey/portrait,键名升序拼接值后双重 MD5 +- 成功:code=200,message=新增成功 或 已存在`;function RV({initialTab:t="overview"}){const[e,n]=v.useState(t),[r,i]=v.useState("13800000000"),[a,o]=v.useState(""),[c,u]=v.useState(""),[h,f]=v.useState(Sw),[m,g]=v.useState(!1),[y,b]=v.useState(!1),[j,w]=v.useState([]),[N,C]=v.useState([]),[E,M]=v.useState({}),[I,O]=v.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"}]),D=v.useMemo(()=>{const R={};return gg.forEach(F=>{R[F.key]=E[F.key]||{apiUrl:"https://ckbapi.quwanzhi.com/v1/api/scenarios",apiKey:"fyngh-ecy9h-qkdae-epwd5-rz6kd",source:"",tags:"",siteTags:"创业实验APP",notes:""}}),R},[E]),P=R=>{const F=r.trim(),re=a.trim();return R<=3?{type:IV[R],phone:F||void 0,wechat:re||void 0,userId:"admin_test",name:"后台测试"}:R===4?{matchType:"partner",phone:F||void 0,wechat:re||void 0,userId:"admin_test",nickname:"后台测试",matchedUser:{id:"test",nickname:"测试",matchScore:88}}:R===5?{phone:F||void 0,wechatId:re||void 0,userId:"admin_test",name:"后台测试"}:{}};async function L(){b(!0);try{const[R,F,re]=await Promise.all([Le("/api/db/config/full?key=ckb_config"),Le("/api/db/ckb-leads?mode=submitted&page=1&pageSize=50"),Le("/api/db/ckb-leads?mode=contact&page=1&pageSize=50")]),z=R==null?void 0:R.data;z!=null&&z.routes&&M(z.routes),z!=null&&z.docNotes&&u(z.docNotes),z!=null&&z.docContent&&f(z.docContent),F!=null&&F.success&&w(F.records||[]),re!=null&&re.success&&C(re.records||[])}finally{b(!1)}}v.useEffect(()=>{n(t)},[t]),v.useEffect(()=>{L()},[]);async function _(){g(!0);try{const R=await Nt("/api/db/config",{key:"ckb_config",value:{routes:D,docNotes:c,docContent:h},description:"存客宝接口配置"});ie.error((R==null?void 0:R.success)!==!1?"存客宝配置已保存":`保存失败: ${(R==null?void 0:R.error)||"未知错误"}`)}catch(R){ie.error(`保存失败: ${R instanceof Error?R.message:"网络错误"}`)}finally{g(!1)}}const X=(R,F)=>{M(re=>({...re,[R]:{...D[R],...F}}))},ne=async R=>{const F=I[R];if(F.method==="POST"&&!r.trim()&&!a.trim()){ie.error("请填写测试手机号");return}const re=[...I];re[R]={...F,status:"testing",message:void 0,responseTime:void 0},O(re);const z=performance.now();try{const ae=F.method==="GET"?await Le(F.endpoint):await Nt(F.endpoint,P(R)),G=Math.round(performance.now()-z),$=(ae==null?void 0:ae.message)||"",H=(ae==null?void 0:ae.success)===!0||$.includes("已存在")||$.includes("已加入")||$.includes("已提交"),ce=[...I];ce[R]={...F,status:H?"success":"error",message:$||(H?"正常":"异常"),responseTime:G},O(ce),await L()}catch(ae){const G=Math.round(performance.now()-z),$=[...I];$[R]={...F,status:"error",message:ae instanceof Error?ae.message:"失败",responseTime:G},O($)}},J=async()=>{if(!r.trim()&&!a.trim()){ie.error("请填写测试手机号");return}for(let R=0;Rs.jsx("div",{className:"overflow-auto rounded-lg border border-gray-700/30",children:s.jsxs("table",{className:"w-full text-sm",children:[s.jsx("thead",{className:"bg-[#0a1628] text-gray-400",children:s.jsxs("tr",{children:[s.jsx("th",{className:"text-left px-4 py-3",children:"发起人"}),s.jsx("th",{className:"text-left px-4 py-3",children:"类型"}),s.jsx("th",{className:"text-left px-4 py-3",children:"手机号"}),s.jsx("th",{className:"text-left px-4 py-3",children:"微信号"}),s.jsx("th",{className:"text-left px-4 py-3",children:"时间"})]})}),s.jsx("tbody",{children:R.length===0?s.jsx("tr",{children:s.jsx("td",{colSpan:5,className:"text-center py-10 text-gray-500",children:F})}):R.map(re=>s.jsxs("tr",{className:"border-t border-gray-700/30",children:[s.jsx("td",{className:"px-4 py-3 text-white",children:re.userNickname||re.userId}),s.jsx("td",{className:"px-4 py-3 text-gray-300",children:re.matchType}),s.jsx("td",{className:"px-4 py-3 text-green-400",children:re.phone||"—"}),s.jsx("td",{className:"px-4 py-3 text-blue-400",children:re.wechatId||"—"}),s.jsx("td",{className:"px-4 py-3 text-gray-400",children:re.createdAt?new Date(re.createdAt).toLocaleString():"—"})]},re.id))})]})});return s.jsx(Me,{className:"bg-[#0f2137] border-orange-500/30 mb-6",children:s.jsxs(Ae,{className:"p-5",children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("h3",{className:"text-white font-semibold",children:"存客宝工作台"}),s.jsx(Ue,{className:"bg-orange-500/20 text-orange-400 border-0 text-xs",children:"CKB"}),s.jsxs("button",{type:"button",onClick:()=>n("doc"),className:"text-orange-400/60 text-xs hover:text-orange-400 flex items-center gap-1",children:[s.jsx(_s,{className:"w-3 h-3"})," API 文档"]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(ee,{onClick:()=>L(),variant:"outline",size:"sm",className:"border-gray-700 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Ge,{className:`w-3.5 h-3.5 mr-1 ${y?"animate-spin":""}`})," 刷新"]}),s.jsxs(ee,{onClick:_,disabled:m,size:"sm",className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(gn,{className:"w-3.5 h-3.5 mr-1"})," ",m?"保存中...":"保存配置"]})]})]}),s.jsx("div",{className:"flex flex-wrap gap-2 mb-5",children:[["overview","概览"],["submitted","已提交线索"],["contact","有联系方式"],["config","场景配置"],["test","接口测试"],["doc","API 文档"]].map(([R,F])=>s.jsx("button",{type:"button",onClick:()=>n(R),className:`px-4 py-2 rounded-lg text-sm transition-colors ${e===R?"bg-orange-500 text-white":"bg-[#0a1628] text-gray-400 hover:text-white"}`,children:F},R))}),e==="overview"&&s.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-4",children:[s.jsxs("div",{className:"bg-[#0a1628] border border-gray-700/30 rounded-xl p-5",children:[s.jsx("p",{className:"text-gray-400 text-xs mb-2",children:"已提交线索"}),s.jsx("p",{className:"text-3xl font-bold text-white",children:j.length})]}),s.jsxs("div",{className:"bg-[#0a1628] border border-gray-700/30 rounded-xl p-5",children:[s.jsx("p",{className:"text-gray-400 text-xs mb-2",children:"有联系方式"}),s.jsx("p",{className:"text-3xl font-bold text-white",children:N.length})]}),s.jsxs("div",{className:"bg-[#0a1628] border border-gray-700/30 rounded-xl p-5",children:[s.jsx("p",{className:"text-gray-400 text-xs mb-2",children:"场景配置数"}),s.jsx("p",{className:"text-3xl font-bold text-white",children:gg.length})]}),s.jsxs("div",{className:"bg-[#0a1628] border border-gray-700/30 rounded-xl p-5",children:[s.jsx("p",{className:"text-gray-400 text-xs mb-2",children:"文档备注"}),s.jsx("p",{className:"text-sm text-gray-300 line-clamp-3",children:c||"未填写"})]})]}),e==="submitted"&&U(j,"暂无已提交线索"),e==="contact"&&U(N,"暂无有联系方式线索"),e==="config"&&s.jsx("div",{className:"space-y-4",children:gg.map(R=>s.jsxs("div",{className:"bg-[#0a1628] border border-gray-700/30 rounded-xl p-4",children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsx("h4",{className:"text-white font-medium",children:R.label}),s.jsx(Ue,{className:"bg-orange-500/20 text-orange-300 border-0 text-xs",children:R.key})]}),s.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsx(Z,{className:"text-gray-500 text-xs",children:"API 地址"}),s.jsx(oe,{className:"bg-[#0f2137] border-gray-700 text-white h-9 text-sm",value:D[R.key].apiUrl,onChange:F=>X(R.key,{apiUrl:F.target.value})})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(Z,{className:"text-gray-500 text-xs",children:"API Key"}),s.jsx(oe,{className:"bg-[#0f2137] border-gray-700 text-white h-9 text-sm",value:D[R.key].apiKey,onChange:F=>X(R.key,{apiKey:F.target.value})})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(Z,{className:"text-gray-500 text-xs",children:"Source"}),s.jsx(oe,{className:"bg-[#0f2137] border-gray-700 text-white h-9 text-sm",value:D[R.key].source,onChange:F=>X(R.key,{source:F.target.value})})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(Z,{className:"text-gray-500 text-xs",children:"Tags"}),s.jsx(oe,{className:"bg-[#0f2137] border-gray-700 text-white h-9 text-sm",value:D[R.key].tags,onChange:F=>X(R.key,{tags:F.target.value})})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(Z,{className:"text-gray-500 text-xs",children:"SiteTags"}),s.jsx(oe,{className:"bg-[#0f2137] border-gray-700 text-white h-9 text-sm",value:D[R.key].siteTags,onChange:F=>X(R.key,{siteTags:F.target.value})})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(Z,{className:"text-gray-500 text-xs",children:"说明备注"}),s.jsx(oe,{className:"bg-[#0f2137] border-gray-700 text-white h-9 text-sm",value:D[R.key].notes,onChange:F=>X(R.key,{notes:F.target.value})})]})]})]},R.key))}),e==="test"&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex gap-3 mb-4",children:[s.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[s.jsx(uo,{className:"w-4 h-4 text-gray-500 shrink-0"}),s.jsxs("div",{className:"flex-1",children:[s.jsx(Z,{className:"text-gray-500 text-xs",children:"测试手机号"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white h-8 text-sm mt-0.5",value:r,onChange:R=>i(R.target.value)})]})]}),s.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[s.jsx("span",{className:"text-gray-500 text-sm shrink-0",children:"💬"}),s.jsxs("div",{className:"flex-1",children:[s.jsx(Z,{className:"text-gray-500 text-xs",children:"微信号(可选)"}),s.jsx(oe,{className:"bg-[#0a1628] border-gray-700 text-white h-8 text-sm mt-0.5",value:a,onChange:R=>o(R.target.value)})]})]}),s.jsx("div",{className:"flex items-end",children:s.jsxs(ee,{onClick:J,className:"bg-orange-500 hover:bg-orange-600 text-white",children:[s.jsx(ia,{className:"w-3.5 h-3.5 mr-1"})," 全部测试"]})})]}),s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-2",children:I.map((R,F)=>s.jsxs("div",{className:"flex items-center justify-between bg-[#0a1628] rounded-lg px-3 py-2 border border-gray-700/30",children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[R.status==="idle"&&s.jsx("div",{className:"w-2 h-2 rounded-full bg-gray-600 shrink-0"}),R.status==="testing"&&s.jsx(Ge,{className:"w-3 h-3 text-yellow-400 animate-spin shrink-0"}),R.status==="success"&&s.jsx(wg,{className:"w-3 h-3 text-green-400 shrink-0"}),R.status==="error"&&s.jsx(Vw,{className:"w-3 h-3 text-red-400 shrink-0"}),s.jsx("span",{className:"text-white text-xs truncate",children:R.label})]}),s.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[R.responseTime!==void 0&&s.jsxs("span",{className:"text-gray-600 text-[10px]",children:[R.responseTime,"ms"]}),s.jsx("button",{type:"button",onClick:()=>ne(F),disabled:R.status==="testing",className:"text-orange-400/60 hover:text-orange-400 text-[10px] disabled:opacity-50",children:"测试"})]})]},`${R.endpoint}-${F}`))})]}),e==="doc"&&s.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-2 gap-4",children:[s.jsxs("div",{className:"bg-[#0a1628] rounded-lg border border-gray-700/30 p-4",children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsx("h4",{className:"text-white text-sm font-medium",children:"场景获客 API 摘要"}),s.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:[s.jsx(_s,{className:"w-3 h-3"})," 打开外链"]})]}),s.jsx("pre",{className:"whitespace-pre-wrap text-xs text-gray-400 leading-6",children:h||Sw})]}),s.jsxs("div",{className:"bg-[#0a1628] rounded-lg border border-gray-700/30 p-4",children:[s.jsx("h4",{className:"text-white text-sm font-medium mb-3",children:"说明备注(可编辑)"}),s.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:R=>u(R.target.value),placeholder:"记录 Token、入口差异、回复率统计规则、对接约定等。"})]})]})]})})}const PV=[{id:"stats",label:"数据统计",icon:zT},{id:"partner",label:"找伙伴",icon:Un},{id:"resource",label:"资源对接",icon:NM},{id:"mentor",label:"导师预约",icon:yM},{id:"team",label:"团队招募",icon:Eg}];function OV(){const[t,e]=v.useState("stats"),[n,r]=v.useState(!1),[i,a]=v.useState("overview");return s.jsxs("div",{className:"p-8 w-full",children:[s.jsxs("div",{className:"mb-6 flex items-start justify-between gap-4",children:[s.jsxs("div",{children:[s.jsxs("h2",{className:"text-2xl font-bold text-white flex items-center gap-2",children:[s.jsx(Un,{className:"w-6 h-6 text-[#38bdac]"}),"找伙伴"]}),s.jsx("p",{className:"text-gray-400 mt-1",children:"数据统计、匹配池与记录、资源对接、导师预约、团队招募"})]}),s.jsxs(ee,{type:"button",variant:"outline",onClick:()=>r(o=>!o),className:"border-orange-500/40 text-orange-300 hover:bg-orange-500/10 bg-transparent",children:[s.jsx(ms,{className:"w-4 h-4 mr-2"}),"存客宝"]})]}),n&&s.jsx(RV,{initialTab:i}),s.jsx("div",{className:"flex flex-wrap gap-1 mb-6 bg-[#0f2137] rounded-lg p-1 border border-gray-700/50",children:PV.map(o=>{const c=t===o.id;return s.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:[s.jsx(o.icon,{className:"w-4 h-4"}),o.label]},o.id)})}),t==="stats"&&s.jsx(AV,{onSwitchTab:o=>e(o),onOpenCKB:o=>{a(o||"overview"),r(!0)}}),t==="partner"&&s.jsx(kV,{}),t==="resource"&&s.jsx(SV,{}),t==="mentor"&&s.jsx(TV,{}),t==="team"&&s.jsx(MV,{})]})}function DV(){return s.jsxs("div",{className:"p-8 w-full",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-8",children:[s.jsx(ms,{className:"w-8 h-8 text-[#38bdac]"}),s.jsx("h1",{className:"text-2xl font-bold text-white",children:"API 接口文档"})]}),s.jsx("p",{className:"text-gray-400 mb-6",children:"API 风格:RESTful · 版本 v1.0 · 基础路径 /api · 简单、清晰、易用。"}),s.jsxs(Me,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl mb-6",children:[s.jsx(nt,{children:s.jsx(rt,{className:"text-white",children:"1. 接口总览"})}),s.jsxs(Ae,{className:"space-y-4 text-sm",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-gray-400 mb-2",children:"接口分类"}),s.jsxs("ul",{className:"space-y-1 text-gray-300 font-mono",children:[s.jsx("li",{children:"/api/book — 书籍内容(章节列表、内容获取、同步)"}),s.jsx("li",{children:"/api/miniprogram/upload — 小程序上传(图片/视频、图片压缩)"}),s.jsx("li",{children:"/api/admin/content/upload — 管理端内容导入"}),s.jsx("li",{children:"/api/payment — 支付系统(订单创建、回调、状态查询)"}),s.jsx("li",{children:"/api/referral — 分销系统(邀请码、收益、提现)"}),s.jsx("li",{children:"/api/user — 用户系统(登录、注册、信息更新)"}),s.jsx("li",{children:"/api/match — 匹配系统(寻找匹配、匹配历史)"}),s.jsx("li",{children:"/api/admin — 管理后台(内容/订单/用户/分销管理)"}),s.jsx("li",{children:"/api/config — 配置系统"})]})]}),s.jsxs("div",{children:[s.jsx("p",{className:"text-gray-400 mb-2",children:"认证方式"}),s.jsx("p",{className:"text-gray-300",children:"用户:Cookie session_id(可选)"}),s.jsx("p",{className:"text-gray-300",children:"管理端:Authorization: Bearer admin-token-secret"})]})]})]}),s.jsxs(Me,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl mb-6",children:[s.jsx(nt,{children:s.jsx(rt,{className:"text-white",children:"2. 书籍内容"})}),s.jsxs(Ae,{className:"space-y-2 text-sm text-gray-300 font-mono",children:[s.jsx("p",{children:"GET /api/book/all-chapters — 获取所有章节"}),s.jsx("p",{children:"GET /api/book/chapter/:id — 获取单章内容"}),s.jsx("p",{children:"POST /api/book/sync — 同步章节(需管理员认证)"})]})]}),s.jsxs(Me,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl mb-6",children:[s.jsx(nt,{children:s.jsx(rt,{className:"text-white",children:"2.1 小程序上传接口"})}),s.jsxs(Ae,{className:"space-y-4 text-sm",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-gray-400 mb-1",children:"POST /api/miniprogram/upload/image — 图片上传(支持压缩)"}),s.jsx("p",{className:"text-gray-500 text-xs mb-1",children:"表单:file(必填)、folder(可选,默认 images)、quality(可选 1-100,默认 85)"}),s.jsx("p",{className:"text-gray-500 text-xs",children:"支持 jpeg/png/gif,单张最大 5MB。JPEG 按 quality 压缩。"}),s.jsx("pre",{className:"mt-2 p-2 rounded bg-black/40 text-green-400 text-xs overflow-x-auto",children:'响应示例: { "success": true, "url": "/uploads/images/xxx.jpg", "data": { "url", "fileName", "size", "type", "quality" } }'})]}),s.jsxs("div",{children:[s.jsx("p",{className:"text-gray-400 mb-1",children:"POST /api/miniprogram/upload/video — 视频上传"}),s.jsx("p",{className:"text-gray-500 text-xs mb-1",children:"表单:file(必填)、folder(可选,默认 videos)"}),s.jsx("p",{className:"text-gray-500 text-xs",children:"支持 mp4/mov/avi,单个最大 100MB。"}),s.jsx("pre",{className:"mt-2 p-2 rounded bg-black/40 text-green-400 text-xs overflow-x-auto",children:'响应示例: { "success": true, "url": "/uploads/videos/xxx.mp4", "data": { "url", "fileName", "size", "type", "folder" } }'})]})]})]}),s.jsxs(Me,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl mb-6",children:[s.jsx(nt,{children:s.jsx(rt,{className:"text-white",children:"2.2 管理端内容上传"})}),s.jsxs(Ae,{className:"space-y-3 text-sm",children:[s.jsx("p",{className:"text-gray-400",children:"POST /api/admin/content/upload — 内容导入(需 AdminAuth)"}),s.jsx("p",{className:"text-gray-500 text-xs",children:"通过 API 批量导入章节到内容管理,不直接操作数据库。"}),s.jsx("pre",{className:"p-2 rounded bg-black/40 text-green-400 text-xs overflow-x-auto",children:`请求体: { + "action": "import", + "data": [{ + "id": "ch-001", + "title": "章节标题", + "content": "正文内容", + "price": 1.0, + "isFree": false, + "partId": "part-1", + "partTitle": "第一篇", + "chapterId": "chapter-1", + "chapterTitle": "第1章" + }] +}`}),s.jsxs("p",{className:"text-gray-500 text-xs",children:["响应:",'{ "success": true, "message": "导入完成", "imported": N, "failed": M }']})]})]}),s.jsxs(Me,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl mb-6",children:[s.jsx(nt,{children:s.jsx(rt,{className:"text-white",children:"3. 支付"})}),s.jsxs(Ae,{className:"space-y-2 text-sm text-gray-300 font-mono",children:[s.jsx("p",{children:"POST /api/payment/create-order — 创建订单"}),s.jsx("p",{children:"POST /api/payment/alipay/notify — 支付宝回调"}),s.jsx("p",{children:"POST /api/payment/wechat/notify — 微信回调"})]})]}),s.jsxs(Me,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl mb-6",children:[s.jsx(nt,{children:s.jsx(rt,{className:"text-white",children:"4. 分销与用户"})}),s.jsxs(Ae,{className:"space-y-2 text-sm text-gray-300 font-mono",children:[s.jsx("p",{children:"/api/referral/* — 邀请码、收益查询、提现"}),s.jsx("p",{children:"/api/user/* — 登录、注册、信息更新"}),s.jsx("p",{children:"/api/match/* — 匹配、匹配历史"})]})]}),s.jsxs(Me,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl mb-6",children:[s.jsx(nt,{children:s.jsx(rt,{className:"text-white",children:"5. 管理后台"})}),s.jsxs(Ae,{className:"space-y-2 text-sm text-gray-300 font-mono",children:[s.jsx("p",{children:"GET/POST /api/admin/referral-settings — 推广/分销设置(含 VIP 配置)"}),s.jsx("p",{children:"GET /api/db/users、/api/db/book — 用户与章节数据"}),s.jsx("p",{children:"GET /api/admin/orders — 订单列表"})]})]}),s.jsx("p",{className:"text-gray-500 text-xs",children:"完整说明见项目内 开发文档/5、接口/API接口完整文档.md"})]})}function LV(){const t=wa();return s.jsx("div",{className:"min-h-screen bg-[#0a1628] flex items-center justify-center p-8",children:s.jsxs("div",{className:"text-center max-w-md",children:[s.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:s.jsx(KT,{className:"w-10 h-10"})}),s.jsx("h1",{className:"text-4xl font-bold text-white mb-2",children:"404"}),s.jsx("p",{className:"text-gray-400 mb-1",children:"页面不存在"}),s.jsx("p",{className:"text-sm text-gray-500 font-mono mb-8 break-all",children:t.pathname}),s.jsx(ee,{asChild:!0,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:s.jsxs(Ng,{to:"/",children:[s.jsx(AM,{className:"w-4 h-4 mr-2"}),"返回首页"]})})]})})}function _V(){return s.jsxs(pT,{children:[s.jsx(Wt,{path:"/login",element:s.jsx(Q5,{})}),s.jsxs(Wt,{path:"/",element:s.jsx(e5,{}),children:[s.jsx(Wt,{index:!0,element:s.jsx(Nm,{to:"/dashboard",replace:!0})}),s.jsx(Wt,{path:"dashboard",element:s.jsx(oP,{})}),s.jsx(Wt,{path:"orders",element:s.jsx(lP,{})}),s.jsx(Wt,{path:"users",element:s.jsx(cP,{})}),s.jsx(Wt,{path:"distribution",element:s.jsx(IP,{})}),s.jsx(Wt,{path:"withdrawals",element:s.jsx(RP,{})}),s.jsx(Wt,{path:"content",element:s.jsx(tV,{})}),s.jsx(Wt,{path:"referral-settings",element:s.jsx(Mk,{})}),s.jsx(Wt,{path:"author-settings",element:s.jsx(Nm,{to:"/settings?tab=author",replace:!0})}),s.jsx(Wt,{path:"vip-roles",element:s.jsx(vV,{})}),s.jsx(Wt,{path:"mentors",element:s.jsx(R4,{})}),s.jsx(Wt,{path:"mentor-consultations",element:s.jsx(bV,{})}),s.jsx(Wt,{path:"admin-users",element:s.jsx(Nm,{to:"/settings?tab=admin",replace:!0})}),s.jsx(Wt,{path:"settings",element:s.jsx(cV,{})}),s.jsx(Wt,{path:"payment",element:s.jsx(dV,{})}),s.jsx(Wt,{path:"site",element:s.jsx(pV,{})}),s.jsx(Wt,{path:"qrcodes",element:s.jsx(mV,{})}),s.jsx(Wt,{path:"find-partner",element:s.jsx(OV,{})}),s.jsx(Wt,{path:"match",element:s.jsx(xV,{})}),s.jsx(Wt,{path:"match-records",element:s.jsx(yV,{})}),s.jsx(Wt,{path:"api-doc",element:s.jsx(DV,{})})]}),s.jsx(Wt,{path:"*",element:s.jsx(LV,{})})]})}vE.createRoot(document.getElementById("root")).render(s.jsx(v.StrictMode,{children:s.jsx(wT,{future:{v7_startTransition:!0,v7_relativeSplatPath:!0},children:s.jsx(_V,{})})})); diff --git a/soul-admin/dist/assets/index-DJPaWrh0.js b/soul-admin/dist/assets/index-DJPaWrh0.js deleted file mode 100644 index 7b5c194e..00000000 --- a/soul-admin/dist/assets/index-DJPaWrh0.js +++ /dev/null @@ -1,779 +0,0 @@ -function u3(t,e){for(var n=0;nr[i]})}}}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 i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const a of i)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(i){const a={};return i.integrity&&(a.integrity=i.integrity),i.referrerPolicy&&(a.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?a.credentials="include":i.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function r(i){if(i.ep)return;i.ep=!0;const a=n(i);fetch(i.href,a)}})();function Cw(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var pm={exports:{}},Nc={},mm={exports:{}},ut={};/** - * @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 fb;function h3(){if(fb)return ut;fb=1;var t=Symbol.for("react.element"),e=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),i=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(z){return z===null||typeof z!="object"?null:(z=m&&z[m]||z["@@iterator"],typeof z=="function"?z:null)}var y={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},v=Object.assign,w={};function N(z,W,ue){this.props=z,this.context=W,this.refs=w,this.updater=ue||y}N.prototype.isReactComponent={},N.prototype.setState=function(z,W){if(typeof z!="object"&&typeof z!="function"&&z!=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,z,W,"setState")},N.prototype.forceUpdate=function(z){this.updater.enqueueForceUpdate(this,z,"forceUpdate")};function k(){}k.prototype=N.prototype;function E(z,W,ue){this.props=z,this.context=W,this.refs=w,this.updater=ue||y}var C=E.prototype=new k;C.constructor=E,v(C,N.prototype),C.isPureReactComponent=!0;var T=Array.isArray,O=Object.prototype.hasOwnProperty,F={current:null},I={key:!0,ref:!0,__self:!0,__source:!0};function R(z,W,ue){var G,fe={},X=null,ce=null;if(W!=null)for(G in W.ref!==void 0&&(ce=W.ref),W.key!==void 0&&(X=""+W.key),W)O.call(W,G)&&!I.hasOwnProperty(G)&&(fe[G]=W[G]);var he=arguments.length-2;if(he===1)fe.children=ue;else if(1>>1,W=_[z];if(0>>1;zi(fe,J))Xi(ce,fe)?(_[z]=ce,_[X]=J,z=X):(_[z]=fe,_[G]=J,z=G);else if(Xi(ce,J))_[z]=ce,_[X]=J,z=X;else break e}}return se}function i(_,se){var J=_.sortIndex-se.sortIndex;return J!==0?J:_.id-se.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,w=!1,N=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(_){for(var se=n(h);se!==null;){if(se.callback===null)r(h);else if(se.startTime<=_)r(h),se.sortIndex=se.expirationTime,e(u,se);else break;se=n(h)}}function T(_){if(w=!1,C(_),!v)if(n(u)!==null)v=!0,$(O);else{var se=n(h);se!==null&&le(T,se.startTime-_)}}function O(_,se){v=!1,w&&(w=!1,k(R),R=-1),y=!0;var J=g;try{for(C(se),m=n(u);m!==null&&(!(m.expirationTime>se)||_&&!ee());){var z=m.callback;if(typeof z=="function"){m.callback=null,g=m.priorityLevel;var W=z(m.expirationTime<=se);se=t.unstable_now(),typeof W=="function"?m.callback=W:m===n(u)&&r(u),C(se)}else r(u);m=n(u)}if(m!==null)var ue=!0;else{var G=n(h);G!==null&&le(T,G.startTime-se),ue=!1}return ue}finally{m=null,g=J,y=!1}}var F=!1,I=null,R=-1,P=5,L=-1;function ee(){return!(t.unstable_now()-L_||125<_?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):P=0<_?Math.floor(1e3/_):5},t.unstable_getCurrentPriorityLevel=function(){return g},t.unstable_getFirstCallbackNode=function(){return n(u)},t.unstable_next=function(_){switch(g){case 1:case 2:case 3:var se=3;break;default:se=g}var J=g;g=se;try{return _()}finally{g=J}},t.unstable_pauseExecution=function(){},t.unstable_requestPaint=function(){},t.unstable_runWithPriority=function(_,se){switch(_){case 1:case 2:case 3:case 4:case 5:break;default:_=3}var J=g;g=_;try{return se()}finally{g=J}},t.unstable_scheduleCallback=function(_,se,J){var z=t.unstable_now();switch(typeof J=="object"&&J!==null?(J=J.delay,J=typeof J=="number"&&0z?(_.sortIndex=J,e(h,_),n(u)===null&&_===n(h)&&(w?(k(R),R=-1):w=!0,le(T,J-z))):(_.sortIndex=W,e(u,_),v||y||(v=!0,$(O))),_},t.unstable_shouldYield=ee,t.unstable_wrapCallback=function(_){var se=g;return function(){var J=g;g=se;try{return _.apply(this,arguments)}finally{g=J}}}})(ym)),ym}var yb;function g3(){return yb||(yb=1,xm.exports=m3()),xm.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 vb;function x3(){if(vb)return xr;vb=1;var t=cd(),e=g3();function n(l){for(var d="https://reactjs.org/docs/error-decoder.html?invariant="+l,p=1;p"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 w(l,d,p,x,j,S,M){this.acceptsBooleans=d===2||d===3||d===4,this.attributeName=x,this.attributeNamespace=j,this.mustUseProperty=p,this.propertyName=l,this.type=d,this.sanitizeURL=S,this.removeEmptyString=M}var N={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(l){N[l]=new w(l,0,!1,l,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(l){var d=l[0];N[d]=new w(d,1,!1,l[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(l){N[l]=new w(l,2,!1,l.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(l){N[l]=new w(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){N[l]=new w(l,3,!1,l.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(l){N[l]=new w(l,3,!0,l,null,!1,!1)}),["capture","download"].forEach(function(l){N[l]=new w(l,4,!1,l,null,!1,!1)}),["cols","rows","size","span"].forEach(function(l){N[l]=new w(l,6,!1,l,null,!1,!1)}),["rowSpan","start"].forEach(function(l){N[l]=new w(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);N[d]=new w(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);N[d]=new w(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);N[d]=new w(d,1,!1,l,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(l){N[l]=new w(l,1,!1,l.toLowerCase(),null,!1,!1)}),N.xlinkHref=new w("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(l){N[l]=new w(l,1,!1,l.toLowerCase(),null,!0,!0)});function C(l,d,p,x){var j=N.hasOwnProperty(d)?N[d]:null;(j!==null?j.type!==0:x||!(2B||j[M]!==S[B]){var q=` -`+j[M].replace(" at new "," at ");return l.displayName&&q.includes("")&&(q=q.replace("",l.displayName)),q}while(1<=M&&0<=B);break}}}finally{ue=!1,Error.prepareStackTrace=p}return(l=l?l.displayName||l.name:"")?W(l):""}function fe(l){switch(l.tag){case 5:return W(l.type);case 16:return W("Lazy");case 13:return W("Suspense");case 19:return W("SuspenseList");case 0:case 2:case 15:return l=G(l.type,!1),l;case 11:return l=G(l.type.render,!1),l;case 1:return l=G(l.type,!0),l;default:return""}}function X(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 I:return"Fragment";case F:return"Portal";case P:return"Profiler";case R:return"StrictMode";case Y:return"Suspense";case U:return"SuspenseList"}if(typeof l=="object")switch(l.$$typeof){case ee:return(l.displayName||"Context")+".Consumer";case L:return(l._context.displayName||"Context")+".Provider";case te:var d=l.render;return l=l.displayName,l||(l=d.displayName||d.name||"",l=l!==""?"ForwardRef("+l+")":"ForwardRef"),l;case D:return d=l.displayName||null,d!==null?d:X(l.type)||"Memo";case $:d=l._payload,l=l._init;try{return X(l(d))}catch{}}return null}function ce(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 X(d);case 8:return d===R?"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 he(l){switch(typeof l){case"boolean":case"number":case"string":case"undefined":return l;case"object":return l;default:return""}}function we(l){var d=l.type;return(l=l.nodeName)&&l.toLowerCase()==="input"&&(d==="checkbox"||d==="radio")}function V(l){var d=we(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 j=p.get,S=p.set;return Object.defineProperty(l,d,{configurable:!0,get:function(){return j.call(this)},set:function(M){x=""+M,S.call(this,M)}}),Object.defineProperty(l,d,{enumerable:p.enumerable}),{getValue:function(){return x},setValue:function(M){x=""+M},stopTracking:function(){l._valueTracker=null,delete l[d]}}}}function be(l){l._valueTracker||(l._valueTracker=V(l))}function Me(l){if(!l)return!1;var d=l._valueTracker;if(!d)return!0;var p=d.getValue(),x="";return l&&(x=we(l)?l.checked?"true":"false":l.value),l=x,l!==p?(d.setValue(l),!0):!1}function st(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 nt(l,d){var p=d.checked;return J({},d,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:p??l._wrapperState.initialChecked})}function dt(l,d){var p=d.defaultValue==null?"":d.defaultValue,x=d.checked!=null?d.checked:d.defaultChecked;p=he(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 Ye(l,d){d=d.checked,d!=null&&C(l,"checked",d,!1)}function ht(l,d){Ye(l,d);var p=he(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")?ft(l,d.type,p):d.hasOwnProperty("defaultValue")&&ft(l,d.type,he(d.defaultValue)),d.checked==null&&d.defaultChecked!=null&&(l.defaultChecked=!!d.defaultChecked)}function Tt(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 ft(l,d,p){(d!=="number"||st(l.ownerDocument)!==l)&&(p==null?l.defaultValue=""+l._wrapperState.initialValue:l.defaultValue!==""+p&&(l.defaultValue=""+p))}var Mt=Array.isArray;function Nn(l,d,p,x){if(l=l.options,d){d={};for(var j=0;j"+d.valueOf().toString()+"",d=Qt.firstChild;l.firstChild;)l.removeChild(l.firstChild);for(;d.firstChild;)l.appendChild(d.firstChild)}});function Xr(l,d){if(d){var p=l.firstChild;if(p&&p===l.lastChild&&p.nodeType===3){p.nodeValue=d;return}}l.textContent=d}var er={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},pe=["Webkit","ms","Moz","O"];Object.keys(er).forEach(function(l){pe.forEach(function(d){d=d+l.charAt(0).toUpperCase()+l.substring(1),er[d]=er[l]})});function ve(l,d,p){return d==null||typeof d=="boolean"||d===""?"":p||typeof d!="number"||d===0||er.hasOwnProperty(l)&&er[l]?(""+d).trim():d+"px"}function tr(l,d){l=l.style;for(var p in d)if(d.hasOwnProperty(p)){var x=p.indexOf("--")===0,j=ve(p,d[p],x);p==="float"&&(p="cssFloat"),x?l.setProperty(p,j):l[p]=j}}var Hs=J({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 ki(l,d){if(d){if(Hs[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 Si(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 Nr=null;function Aa(l){return l=l.target||l.srcElement||window,l.correspondingUseElement&&(l=l.correspondingUseElement),l.nodeType===3?l.parentNode:l}var Dr=null,Zr=null,nr=null;function Ci(l){if(l=ac(l)){if(typeof Dr!="function")throw Error(n(280));var d=l.stateNode;d&&(d=Od(d),Dr(l.stateNode,l.type,d))}}function Ia(l){Zr?nr?nr.push(l):nr=[l]:Zr=l}function Ws(){if(Zr){var l=Zr,d=nr;if(nr=Zr=null,Ci(l),d)for(l=0;l>>=0,l===0?32:31-(wn(l)/rr|0)|0}var Ft=64,In=4194304;function ns(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 Ss(l,d){var p=l.pendingLanes;if(p===0)return 0;var x=0,j=l.suspendedLanes,S=l.pingedLanes,M=p&268435455;if(M!==0){var B=M&~j;B!==0?x=ns(B):(S&=M,S!==0&&(x=ns(S)))}else M=p&~j,M!==0?x=ns(M):S!==0&&(x=ns(S));if(x===0)return 0;if(d!==0&&d!==x&&(d&j)===0&&(j=x&-x,S=d&-d,j>=S||j===16&&(S&4194240)!==0))return d;if((x&4)!==0&&(x|=p&16),d=l.entangledLanes,d!==0)for(l=l.entanglements,d&=x;0p;p++)d.push(l);return d}function Qs(l,d,p){l.pendingLanes|=d,d!==536870912&&(l.suspendedLanes=0,l.pingedLanes=0),l=l.eventTimes,d=31-Xe(d),l[d]=p}function vd(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=Ql),ay=" ",oy=!1;function ly(l,d){switch(l){case"keyup":return aE.indexOf(d.keyCode)!==-1;case"keydown":return d.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function cy(l){return l=l.detail,typeof l=="object"&&"data"in l?l.data:null}var Lo=!1;function lE(l,d){switch(l){case"compositionend":return cy(d);case"keypress":return d.which!==32?null:(oy=!0,ay);case"textInput":return l=d.data,l===ay&&oy?null:l;default:return null}}function cE(l,d){if(Lo)return l==="compositionend"||!Gf&&ly(l,d)?(l=ey(),jd=Vf=Ri=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)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=gy(p)}}function yy(l,d){return l&&d?l===d?!0:l&&l.nodeType===3?!1:d&&d.nodeType===3?yy(l,d.parentNode):"contains"in l?l.contains(d):l.compareDocumentPosition?!!(l.compareDocumentPosition(d)&16):!1:!1}function vy(){for(var l=window,d=st();d instanceof l.HTMLIFrameElement;){try{var p=typeof d.contentWindow.location.href=="string"}catch{p=!1}if(p)l=d.contentWindow;else break;d=st(l.document)}return d}function Qf(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 yE(l){var d=vy(),p=l.focusedElem,x=l.selectionRange;if(d!==p&&p&&p.ownerDocument&&yy(p.ownerDocument.documentElement,p)){if(x!==null&&Qf(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 j=p.textContent.length,S=Math.min(x.start,j);x=x.end===void 0?S:Math.min(x.end,j),!l.extend&&S>x&&(j=x,x=S,S=j),j=xy(p,S);var M=xy(p,x);j&&M&&(l.rangeCount!==1||l.anchorNode!==j.node||l.anchorOffset!==j.offset||l.focusNode!==M.node||l.focusOffset!==M.offset)&&(d=d.createRange(),d.setStart(j.node,j.offset),l.removeAllRanges(),S>x?(l.addRange(d),l.extend(M.node,M.offset)):(d.setEnd(M.node,M.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=document.documentMode,_o=null,Xf=null,tc=null,Zf=!1;function by(l,d,p){var x=p.window===p?p.document:p.nodeType===9?p:p.ownerDocument;Zf||_o==null||_o!==st(x)||(x=_o,"selectionStart"in x&&Qf(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}),tc&&ec(tc,x)||(tc=x,x=Id(Xf,"onSelect"),0Vo||(l.current=up[Vo],up[Vo]=null,Vo--)}function It(l,d){Vo++,up[Vo]=l.current,l.current=d}var Li={},Bn=Di(Li),hr=Di(!1),za=Li;function Ho(l,d){var p=l.type.contextTypes;if(!p)return Li;var x=l.stateNode;if(x&&x.__reactInternalMemoizedUnmaskedChildContext===d)return x.__reactInternalMemoizedMaskedChildContext;var j={},S;for(S in p)j[S]=d[S];return x&&(l=l.stateNode,l.__reactInternalMemoizedUnmaskedChildContext=d,l.__reactInternalMemoizedMaskedChildContext=j),j}function fr(l){return l=l.childContextTypes,l!=null}function Dd(){_t(hr),_t(Bn)}function Dy(l,d,p){if(Bn.current!==Li)throw Error(n(168));It(Bn,d),It(hr,p)}function Ly(l,d,p){var x=l.stateNode;if(d=d.childContextTypes,typeof x.getChildContext!="function")return p;x=x.getChildContext();for(var j in x)if(!(j in d))throw Error(n(108,ce(l)||"Unknown",j));return J({},p,x)}function Ld(l){return l=(l=l.stateNode)&&l.__reactInternalMemoizedMergedChildContext||Li,za=Bn.current,It(Bn,l),It(hr,hr.current),!0}function _y(l,d,p){var x=l.stateNode;if(!x)throw Error(n(169));p?(l=Ly(l,d,za),x.__reactInternalMemoizedMergedChildContext=l,_t(hr),_t(Bn),It(Bn,l)):_t(hr),It(hr,p)}var ei=null,_d=!1,hp=!1;function zy(l){ei===null?ei=[l]:ei.push(l)}function AE(l){_d=!0,zy(l)}function _i(){if(!hp&&ei!==null){hp=!0;var l=0,d=mt;try{var p=ei;for(mt=1;l>=M,j-=M,ti=1<<32-Xe(d)+j|p<Ze?(Cn=Ge,Ge=null):Cn=Ge.sibling;var gt=Ne(re,Ge,ie[Ze],Te);if(gt===null){Ge===null&&(Ge=Cn);break}l&&Ge&>.alternate===null&&d(re,Ge),Q=S(gt,Q,Ze),qe===null?Be=gt:qe.sibling=gt,qe=gt,Ge=Cn}if(Ze===ie.length)return p(re,Ge),Bt&&Fa(re,Ze),Be;if(Ge===null){for(;ZeZe?(Cn=Ge,Ge=null):Cn=Ge.sibling;var Ki=Ne(re,Ge,gt.value,Te);if(Ki===null){Ge===null&&(Ge=Cn);break}l&&Ge&&Ki.alternate===null&&d(re,Ge),Q=S(Ki,Q,Ze),qe===null?Be=Ki:qe.sibling=Ki,qe=Ki,Ge=Cn}if(gt.done)return p(re,Ge),Bt&&Fa(re,Ze),Be;if(Ge===null){for(;!gt.done;Ze++,gt=ie.next())gt=Se(re,gt.value,Te),gt!==null&&(Q=S(gt,Q,Ze),qe===null?Be=gt:qe.sibling=gt,qe=gt);return Bt&&Fa(re,Ze),Be}for(Ge=x(re,Ge);!gt.done;Ze++,gt=ie.next())gt=Oe(Ge,re,Ze,gt.value,Te),gt!==null&&(l&>.alternate!==null&&Ge.delete(gt.key===null?Ze:gt.key),Q=S(gt,Q,Ze),qe===null?Be=gt:qe.sibling=gt,qe=gt);return l&&Ge.forEach(function(d3){return d(re,d3)}),Bt&&Fa(re,Ze),Be}function ln(re,Q,ie,Te){if(typeof ie=="object"&&ie!==null&&ie.type===I&&ie.key===null&&(ie=ie.props.children),typeof ie=="object"&&ie!==null){switch(ie.$$typeof){case O:e:{for(var Be=ie.key,qe=Q;qe!==null;){if(qe.key===Be){if(Be=ie.type,Be===I){if(qe.tag===7){p(re,qe.sibling),Q=j(qe,ie.props.children),Q.return=re,re=Q;break e}}else if(qe.elementType===Be||typeof Be=="object"&&Be!==null&&Be.$$typeof===$&&Wy(Be)===qe.type){p(re,qe.sibling),Q=j(qe,ie.props),Q.ref=oc(re,qe,ie),Q.return=re,re=Q;break e}p(re,qe);break}else d(re,qe);qe=qe.sibling}ie.type===I?(Q=Ga(ie.props.children,re.mode,Te,ie.key),Q.return=re,re=Q):(Te=uu(ie.type,ie.key,ie.props,null,re.mode,Te),Te.ref=oc(re,Q,ie),Te.return=re,re=Te)}return M(re);case F:e:{for(qe=ie.key;Q!==null;){if(Q.key===qe)if(Q.tag===4&&Q.stateNode.containerInfo===ie.containerInfo&&Q.stateNode.implementation===ie.implementation){p(re,Q.sibling),Q=j(Q,ie.children||[]),Q.return=re,re=Q;break e}else{p(re,Q);break}else d(re,Q);Q=Q.sibling}Q=cm(ie,re.mode,Te),Q.return=re,re=Q}return M(re);case $:return qe=ie._init,ln(re,Q,qe(ie._payload),Te)}if(Mt(ie))return _e(re,Q,ie,Te);if(se(ie))return Fe(re,Q,ie,Te);Bd(re,ie)}return typeof ie=="string"&&ie!==""||typeof ie=="number"?(ie=""+ie,Q!==null&&Q.tag===6?(p(re,Q.sibling),Q=j(Q,ie),Q.return=re,re=Q):(p(re,Q),Q=lm(ie,re.mode,Te),Q.return=re,re=Q),M(re)):p(re,Q)}return ln}var qo=Uy(!0),Ky=Uy(!1),Vd=Di(null),Hd=null,Go=null,yp=null;function vp(){yp=Go=Hd=null}function bp(l){var d=Vd.current;_t(Vd),l._currentValue=d}function Np(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 Jo(l,d){Hd=l,yp=Go=null,l=l.dependencies,l!==null&&l.firstContext!==null&&((l.lanes&d)!==0&&(pr=!0),l.firstContext=null)}function Fr(l){var d=l._currentValue;if(yp!==l)if(l={context:l,memoizedValue:d,next:null},Go===null){if(Hd===null)throw Error(n(308));Go=l,Hd.dependencies={lanes:0,firstContext:l}}else Go=Go.next=l;return d}var Ba=null;function wp(l){Ba===null?Ba=[l]:Ba.push(l)}function qy(l,d,p,x){var j=d.interleaved;return j===null?(p.next=p,wp(d)):(p.next=j.next,j.next=p),d.interleaved=p,ri(l,x)}function ri(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 zi=!1;function jp(l){l.updateQueue={baseState:l.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Gy(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 si(l,d){return{eventTime:l,lane:d,tag:0,payload:null,callback:null,next:null}}function $i(l,d,p){var x=l.updateQueue;if(x===null)return null;if(x=x.shared,(pt&2)!==0){var j=x.pending;return j===null?d.next=d:(d.next=j.next,j.next=d),x.pending=d,ri(l,p)}return j=x.interleaved,j===null?(d.next=d,wp(x)):(d.next=j.next,j.next=d),x.interleaved=d,ri(l,p)}function Wd(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,Po(l,p)}}function Jy(l,d){var p=l.updateQueue,x=l.alternate;if(x!==null&&(x=x.updateQueue,p===x)){var j=null,S=null;if(p=p.firstBaseUpdate,p!==null){do{var M={eventTime:p.eventTime,lane:p.lane,tag:p.tag,payload:p.payload,callback:p.callback,next:null};S===null?j=S=M:S=S.next=M,p=p.next}while(p!==null);S===null?j=S=d:S=S.next=d}else j=S=d;p={baseState:x.baseState,firstBaseUpdate:j,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 Ud(l,d,p,x){var j=l.updateQueue;zi=!1;var S=j.firstBaseUpdate,M=j.lastBaseUpdate,B=j.shared.pending;if(B!==null){j.shared.pending=null;var q=B,de=q.next;q.next=null,M===null?S=de:M.next=de,M=q;var je=l.alternate;je!==null&&(je=je.updateQueue,B=je.lastBaseUpdate,B!==M&&(B===null?je.firstBaseUpdate=de:B.next=de,je.lastBaseUpdate=q))}if(S!==null){var Se=j.baseState;M=0,je=de=q=null,B=S;do{var Ne=B.lane,Oe=B.eventTime;if((x&Ne)===Ne){je!==null&&(je=je.next={eventTime:Oe,lane:0,tag:B.tag,payload:B.payload,callback:B.callback,next:null});e:{var _e=l,Fe=B;switch(Ne=d,Oe=p,Fe.tag){case 1:if(_e=Fe.payload,typeof _e=="function"){Se=_e.call(Oe,Se,Ne);break e}Se=_e;break e;case 3:_e.flags=_e.flags&-65537|128;case 0:if(_e=Fe.payload,Ne=typeof _e=="function"?_e.call(Oe,Se,Ne):_e,Ne==null)break e;Se=J({},Se,Ne);break e;case 2:zi=!0}}B.callback!==null&&B.lane!==0&&(l.flags|=64,Ne=j.effects,Ne===null?j.effects=[B]:Ne.push(B))}else Oe={eventTime:Oe,lane:Ne,tag:B.tag,payload:B.payload,callback:B.callback,next:null},je===null?(de=je=Oe,q=Se):je=je.next=Oe,M|=Ne;if(B=B.next,B===null){if(B=j.shared.pending,B===null)break;Ne=B,B=Ne.next,Ne.next=null,j.lastBaseUpdate=Ne,j.shared.pending=null}}while(!0);if(je===null&&(q=Se),j.baseState=q,j.firstBaseUpdate=de,j.lastBaseUpdate=je,d=j.shared.interleaved,d!==null){j=d;do M|=j.lane,j=j.next;while(j!==d)}else S===null&&(j.shared.lanes=0);Wa|=M,l.lanes=M,l.memoizedState=Se}}function Yy(l,d,p){if(l=d.effects,d.effects=null,l!==null)for(d=0;dp?p:4,l(!0);var x=Tp.transition;Tp.transition={};try{l(!1),d()}finally{mt=p,Tp.transition=x}}function mv(){return Br().memoizedState}function OE(l,d,p){var x=Hi(l);if(p={lane:x,action:p,hasEagerState:!1,eagerState:null,next:null},gv(l))xv(d,p);else if(p=qy(l,d,p,x),p!==null){var j=ir();ds(p,l,x,j),yv(p,d,x)}}function DE(l,d,p){var x=Hi(l),j={lane:x,action:p,hasEagerState:!1,eagerState:null,next:null};if(gv(l))xv(d,j);else{var S=l.alternate;if(l.lanes===0&&(S===null||S.lanes===0)&&(S=d.lastRenderedReducer,S!==null))try{var M=d.lastRenderedState,B=S(M,p);if(j.hasEagerState=!0,j.eagerState=B,ss(B,M)){var q=d.interleaved;q===null?(j.next=j,wp(d)):(j.next=q.next,q.next=j),d.interleaved=j;return}}catch{}finally{}p=qy(l,d,j,x),p!==null&&(j=ir(),ds(p,l,x,j),yv(p,d,x))}}function gv(l){var d=l.alternate;return l===Ut||d!==null&&d===Ut}function xv(l,d){uc=Gd=!0;var p=l.pending;p===null?d.next=d:(d.next=p.next,p.next=d),l.pending=d}function yv(l,d,p){if((p&4194240)!==0){var x=d.lanes;x&=l.pendingLanes,p|=x,d.lanes=p,Po(l,p)}}var Qd={readContext:Fr,useCallback:Vn,useContext:Vn,useEffect:Vn,useImperativeHandle:Vn,useInsertionEffect:Vn,useLayoutEffect:Vn,useMemo:Vn,useReducer:Vn,useRef:Vn,useState:Vn,useDebugValue:Vn,useDeferredValue:Vn,useTransition:Vn,useMutableSource:Vn,useSyncExternalStore:Vn,useId:Vn,unstable_isNewReconciler:!1},LE={readContext:Fr,useCallback:function(l,d){return Ms().memoizedState=[l,d===void 0?null:d],l},useContext:Fr,useEffect:ov,useImperativeHandle:function(l,d,p){return p=p!=null?p.concat([l]):null,Jd(4194308,4,dv.bind(null,d,l),p)},useLayoutEffect:function(l,d){return Jd(4194308,4,l,d)},useInsertionEffect:function(l,d){return Jd(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=OE.bind(null,Ut,l),[x.memoizedState,l]},useRef:function(l){var d=Ms();return l={current:l},d.memoizedState=l},useState:iv,useDebugValue:Dp,useDeferredValue:function(l){return Ms().memoizedState=l},useTransition:function(){var l=iv(!1),d=l[0];return l=PE.bind(null,l[1]),Ms().memoizedState=l,[d,l]},useMutableSource:function(){},useSyncExternalStore:function(l,d,p){var x=Ut,j=Ms();if(Bt){if(p===void 0)throw Error(n(407));p=p()}else{if(p=d(),Sn===null)throw Error(n(349));(Ha&30)!==0||ev(x,d,p)}j.memoizedState=p;var S={value:p,getSnapshot:d};return j.queue=S,ov(nv.bind(null,x,S,l),[l]),x.flags|=2048,pc(9,tv.bind(null,x,S,p,d),void 0,null),p},useId:function(){var l=Ms(),d=Sn.identifierPrefix;if(Bt){var p=ni,x=ti;p=(x&~(1<<32-Xe(x)-1)).toString(32)+p,d=":"+d+"R"+p,p=hc++,0<\/script>",l=l.removeChild(l.firstChild)):typeof x.is=="string"?l=M.createElement(p,{is:x.is}):(l=M.createElement(p),p==="select"&&(M=l,x.multiple?M.multiple=!0:x.size&&(M.size=x.size))):l=M.createElementNS(l,p),l[Es]=d,l[ic]=x,zv(l,d,!1,!1),d.stateNode=l;e:{switch(M=Si(p,x),p){case"dialog":Lt("cancel",l),Lt("close",l),j=x;break;case"iframe":case"object":case"embed":Lt("load",l),j=x;break;case"video":case"audio":for(j=0;jel&&(d.flags|=128,x=!0,mc(S,!1),d.lanes=4194304)}else{if(!x)if(l=Kd(M),l!==null){if(d.flags|=128,x=!0,p=l.updateQueue,p!==null&&(d.updateQueue=p,d.flags|=4),mc(S,!0),S.tail===null&&S.tailMode==="hidden"&&!M.alternate&&!Bt)return Hn(d),null}else 2*kt()-S.renderingStartTime>el&&p!==1073741824&&(d.flags|=128,x=!0,mc(S,!1),d.lanes=4194304);S.isBackwards?(M.sibling=d.child,d.child=M):(p=S.last,p!==null?p.sibling=M:d.child=M,S.last=M)}return S.tail!==null?(d=S.tail,S.rendering=d,S.tail=d.sibling,S.renderingStartTime=kt(),d.sibling=null,p=Wt.current,It(Wt,x?p&1|2:p&1),d):(Hn(d),null);case 22:case 23:return im(),x=d.memoizedState!==null,l!==null&&l.memoizedState!==null!==x&&(d.flags|=8192),x&&(d.mode&1)!==0?(Cr&1073741824)!==0&&(Hn(d),d.subtreeFlags&6&&(d.flags|=8192)):Hn(d),null;case 24:return null;case 25:return null}throw Error(n(156,d.tag))}function WE(l,d){switch(pp(d),d.tag){case 1:return fr(d.type)&&Dd(),l=d.flags,l&65536?(d.flags=l&-65537|128,d):null;case 3:return Yo(),_t(hr),_t(Bn),Ep(),l=d.flags,(l&65536)!==0&&(l&128)===0?(d.flags=l&-65537|128,d):null;case 5:return Sp(d),null;case 13:if(_t(Wt),l=d.memoizedState,l!==null&&l.dehydrated!==null){if(d.alternate===null)throw Error(n(340));Ko()}return l=d.flags,l&65536?(d.flags=l&-65537|128,d):null;case 19:return _t(Wt),null;case 4:return Yo(),null;case 10:return bp(d.type._context),null;case 22:case 23:return im(),null;case 24:return null;default:return null}}var tu=!1,Wn=!1,UE=typeof WeakSet=="function"?WeakSet:Set,De=null;function Xo(l,d){var p=l.ref;if(p!==null)if(typeof p=="function")try{p(null)}catch(x){tn(l,d,x)}else p.current=null}function qp(l,d,p){try{p()}catch(x){tn(l,d,x)}}var Bv=!1;function KE(l,d){if(ip=Nd,l=vy(),Qf(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 j=x.anchorOffset,S=x.focusNode;x=x.focusOffset;try{p.nodeType,S.nodeType}catch{p=null;break e}var M=0,B=-1,q=-1,de=0,je=0,Se=l,Ne=null;t:for(;;){for(var Oe;Se!==p||j!==0&&Se.nodeType!==3||(B=M+j),Se!==S||x!==0&&Se.nodeType!==3||(q=M+x),Se.nodeType===3&&(M+=Se.nodeValue.length),(Oe=Se.firstChild)!==null;)Ne=Se,Se=Oe;for(;;){if(Se===l)break t;if(Ne===p&&++de===j&&(B=M),Ne===S&&++je===x&&(q=M),(Oe=Se.nextSibling)!==null)break;Se=Ne,Ne=Se.parentNode}Se=Oe}p=B===-1||q===-1?null:{start:B,end:q}}else p=null}p=p||{start:0,end:0}}else p=null;for(ap={focusedElem:l,selectionRange:p},Nd=!1,De=d;De!==null;)if(d=De,l=d.child,(d.subtreeFlags&1028)!==0&&l!==null)l.return=d,De=l;else for(;De!==null;){d=De;try{var _e=d.alternate;if((d.flags&1024)!==0)switch(d.tag){case 0:case 11:case 15:break;case 1:if(_e!==null){var Fe=_e.memoizedProps,ln=_e.memoizedState,re=d.stateNode,Q=re.getSnapshotBeforeUpdate(d.elementType===d.type?Fe:as(d.type,Fe),ln);re.__reactInternalSnapshotBeforeUpdate=Q}break;case 3:var ie=d.stateNode.containerInfo;ie.nodeType===1?ie.textContent="":ie.nodeType===9&&ie.documentElement&&ie.removeChild(ie.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(n(163))}}catch(Te){tn(d,d.return,Te)}if(l=d.sibling,l!==null){l.return=d.return,De=l;break}De=d.return}return _e=Bv,Bv=!1,_e}function gc(l,d,p){var x=d.updateQueue;if(x=x!==null?x.lastEffect:null,x!==null){var j=x=x.next;do{if((j.tag&l)===l){var S=j.destroy;j.destroy=void 0,S!==void 0&&qp(d,p,S)}j=j.next}while(j!==x)}}function nu(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 Gp(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 Vv(l){var d=l.alternate;d!==null&&(l.alternate=null,Vv(d)),l.child=null,l.deletions=null,l.sibling=null,l.tag===5&&(d=l.stateNode,d!==null&&(delete d[Es],delete d[ic],delete d[dp],delete d[TE],delete d[ME])),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 Hv(l){return l.tag===5||l.tag===3||l.tag===4}function Wv(l){e:for(;;){for(;l.sibling===null;){if(l.return===null||Hv(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 Jp(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=Pd));else if(x!==4&&(l=l.child,l!==null))for(Jp(l,d,p),l=l.sibling;l!==null;)Jp(l,d,p),l=l.sibling}function Yp(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(Yp(l,d,p),l=l.sibling;l!==null;)Yp(l,d,p),l=l.sibling}var Rn=null,ls=!1;function Fi(l,d,p){for(p=p.child;p!==null;)Uv(l,d,p),p=p.sibling}function Uv(l,d,p){if(Pe&&typeof Pe.onCommitFiberUnmount=="function")try{Pe.onCommitFiberUnmount(H,p)}catch{}switch(p.tag){case 5:Wn||Xo(p,d);case 6:var x=Rn,j=ls;Rn=null,Fi(l,d,p),Rn=x,ls=j,Rn!==null&&(ls?(l=Rn,p=p.stateNode,l.nodeType===8?l.parentNode.removeChild(p):l.removeChild(p)):Rn.removeChild(p.stateNode));break;case 18:Rn!==null&&(ls?(l=Rn,p=p.stateNode,l.nodeType===8?cp(l.parentNode,p):l.nodeType===1&&cp(l,p),Gl(l)):cp(Rn,p.stateNode));break;case 4:x=Rn,j=ls,Rn=p.stateNode.containerInfo,ls=!0,Fi(l,d,p),Rn=x,ls=j;break;case 0:case 11:case 14:case 15:if(!Wn&&(x=p.updateQueue,x!==null&&(x=x.lastEffect,x!==null))){j=x=x.next;do{var S=j,M=S.destroy;S=S.tag,M!==void 0&&((S&2)!==0||(S&4)!==0)&&qp(p,d,M),j=j.next}while(j!==x)}Fi(l,d,p);break;case 1:if(!Wn&&(Xo(p,d),x=p.stateNode,typeof x.componentWillUnmount=="function"))try{x.props=p.memoizedProps,x.state=p.memoizedState,x.componentWillUnmount()}catch(B){tn(p,d,B)}Fi(l,d,p);break;case 21:Fi(l,d,p);break;case 22:p.mode&1?(Wn=(x=Wn)||p.memoizedState!==null,Fi(l,d,p),Wn=x):Fi(l,d,p);break;default:Fi(l,d,p)}}function Kv(l){var d=l.updateQueue;if(d!==null){l.updateQueue=null;var p=l.stateNode;p===null&&(p=l.stateNode=new UE),d.forEach(function(x){var j=t3.bind(null,l,x);p.has(x)||(p.add(x),x.then(j,j))})}}function cs(l,d){var p=d.deletions;if(p!==null)for(var x=0;xj&&(j=M),x&=~S}if(x=j,x=kt()-x,x=(120>x?120:480>x?480:1080>x?1080:1920>x?1920:3e3>x?3e3:4320>x?4320:1960*GE(x/1960))-x,10l?16:l,Vi===null)var x=!1;else{if(l=Vi,Vi=null,ou=0,(pt&6)!==0)throw Error(n(331));var j=pt;for(pt|=4,De=l.current;De!==null;){var S=De,M=S.child;if((De.flags&16)!==0){var B=S.deletions;if(B!==null){for(var q=0;qkt()-Zp?Ka(l,0):Xp|=p),gr(l,d)}function ib(l,d){d===0&&((l.mode&1)===0?d=1:(d=In,In<<=1,(In&130023424)===0&&(In=4194304)));var p=ir();l=ri(l,d),l!==null&&(Qs(l,d,p),gr(l,p))}function e3(l){var d=l.memoizedState,p=0;d!==null&&(p=d.retryLane),ib(l,p)}function t3(l,d){var p=0;switch(l.tag){case 13:var x=l.stateNode,j=l.memoizedState;j!==null&&(p=j.retryLane);break;case 19:x=l.stateNode;break;default:throw Error(n(314))}x!==null&&x.delete(d),ib(l,p)}var ab;ab=function(l,d,p){if(l!==null)if(l.memoizedProps!==d.pendingProps||hr.current)pr=!0;else{if((l.lanes&p)===0&&(d.flags&128)===0)return pr=!1,VE(l,d,p);pr=(l.flags&131072)!==0}else pr=!1,Bt&&(d.flags&1048576)!==0&&$y(d,$d,d.index);switch(d.lanes=0,d.tag){case 2:var x=d.type;eu(l,d),l=d.pendingProps;var j=Ho(d,Bn.current);Jo(d,p),j=Ap(null,d,x,l,j,p);var S=Ip();return d.flags|=1,typeof j=="object"&&j!==null&&typeof j.render=="function"&&j.$$typeof===void 0?(d.tag=1,d.memoizedState=null,d.updateQueue=null,fr(x)?(S=!0,Ld(d)):S=!1,d.memoizedState=j.state!==null&&j.state!==void 0?j.state:null,jp(d),j.updater=Xd,d.stateNode=j,j._reactInternals=d,_p(d,x,l,p),d=Bp(null,d,x,!0,S,p)):(d.tag=0,Bt&&S&&fp(d),sr(null,d,j,p),d=d.child),d;case 16:x=d.elementType;e:{switch(eu(l,d),l=d.pendingProps,j=x._init,x=j(x._payload),d.type=x,j=d.tag=r3(x),l=as(x,l),j){case 0:d=Fp(null,d,x,l,p);break e;case 1:d=Rv(null,d,x,l,p);break e;case 11:d=Ev(null,d,x,l,p);break e;case 14:d=Tv(null,d,x,as(x.type,l),p);break e}throw Error(n(306,x,""))}return d;case 0:return x=d.type,j=d.pendingProps,j=d.elementType===x?j:as(x,j),Fp(l,d,x,j,p);case 1:return x=d.type,j=d.pendingProps,j=d.elementType===x?j:as(x,j),Rv(l,d,x,j,p);case 3:e:{if(Pv(d),l===null)throw Error(n(387));x=d.pendingProps,S=d.memoizedState,j=S.element,Gy(l,d),Ud(d,x,null,p);var M=d.memoizedState;if(x=M.element,S.isDehydrated)if(S={element:x,isDehydrated:!1,cache:M.cache,pendingSuspenseBoundaries:M.pendingSuspenseBoundaries,transitions:M.transitions},d.updateQueue.baseState=S,d.memoizedState=S,d.flags&256){j=Qo(Error(n(423)),d),d=Ov(l,d,x,p,j);break e}else if(x!==j){j=Qo(Error(n(424)),d),d=Ov(l,d,x,p,j);break e}else for(Sr=Oi(d.stateNode.containerInfo.firstChild),kr=d,Bt=!0,is=null,p=Ky(d,null,x,p),d.child=p;p;)p.flags=p.flags&-3|4096,p=p.sibling;else{if(Ko(),x===j){d=ii(l,d,p);break e}sr(l,d,x,p)}d=d.child}return d;case 5:return Qy(d),l===null&&gp(d),x=d.type,j=d.pendingProps,S=l!==null?l.memoizedProps:null,M=j.children,op(x,j)?M=null:S!==null&&op(x,S)&&(d.flags|=32),Iv(l,d),sr(l,d,M,p),d.child;case 6:return l===null&&gp(d),null;case 13:return Dv(l,d,p);case 4:return kp(d,d.stateNode.containerInfo),x=d.pendingProps,l===null?d.child=qo(d,null,x,p):sr(l,d,x,p),d.child;case 11:return x=d.type,j=d.pendingProps,j=d.elementType===x?j:as(x,j),Ev(l,d,x,j,p);case 7:return sr(l,d,d.pendingProps,p),d.child;case 8:return sr(l,d,d.pendingProps.children,p),d.child;case 12:return sr(l,d,d.pendingProps.children,p),d.child;case 10:e:{if(x=d.type._context,j=d.pendingProps,S=d.memoizedProps,M=j.value,It(Vd,x._currentValue),x._currentValue=M,S!==null)if(ss(S.value,M)){if(S.children===j.children&&!hr.current){d=ii(l,d,p);break e}}else for(S=d.child,S!==null&&(S.return=d);S!==null;){var B=S.dependencies;if(B!==null){M=S.child;for(var q=B.firstContext;q!==null;){if(q.context===x){if(S.tag===1){q=si(-1,p&-p),q.tag=2;var de=S.updateQueue;if(de!==null){de=de.shared;var je=de.pending;je===null?q.next=q:(q.next=je.next,je.next=q),de.pending=q}}S.lanes|=p,q=S.alternate,q!==null&&(q.lanes|=p),Np(S.return,p,d),B.lanes|=p;break}q=q.next}}else if(S.tag===10)M=S.type===d.type?null:S.child;else if(S.tag===18){if(M=S.return,M===null)throw Error(n(341));M.lanes|=p,B=M.alternate,B!==null&&(B.lanes|=p),Np(M,p,d),M=S.sibling}else M=S.child;if(M!==null)M.return=S;else for(M=S;M!==null;){if(M===d){M=null;break}if(S=M.sibling,S!==null){S.return=M.return,M=S;break}M=M.return}S=M}sr(l,d,j.children,p),d=d.child}return d;case 9:return j=d.type,x=d.pendingProps.children,Jo(d,p),j=Fr(j),x=x(j),d.flags|=1,sr(l,d,x,p),d.child;case 14:return x=d.type,j=as(x,d.pendingProps),j=as(x.type,j),Tv(l,d,x,j,p);case 15:return Mv(l,d,d.type,d.pendingProps,p);case 17:return x=d.type,j=d.pendingProps,j=d.elementType===x?j:as(x,j),eu(l,d),d.tag=1,fr(x)?(l=!0,Ld(d)):l=!1,Jo(d,p),bv(d,x,j),_p(d,x,j,p),Bp(null,d,x,!0,l,p);case 19:return _v(l,d,p);case 22:return Av(l,d,p)}throw Error(n(156,d.tag))};function ob(l,d){return To(l,d)}function n3(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 Hr(l,d,p,x){return new n3(l,d,p,x)}function om(l){return l=l.prototype,!(!l||!l.isReactComponent)}function r3(l){if(typeof l=="function")return om(l)?1:0;if(l!=null){if(l=l.$$typeof,l===te)return 11;if(l===D)return 14}return 2}function Ui(l,d){var p=l.alternate;return p===null?(p=Hr(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 uu(l,d,p,x,j,S){var M=2;if(x=l,typeof l=="function")om(l)&&(M=1);else if(typeof l=="string")M=5;else e:switch(l){case I:return Ga(p.children,j,S,d);case R:M=8,j|=8;break;case P:return l=Hr(12,p,d,j|2),l.elementType=P,l.lanes=S,l;case Y:return l=Hr(13,p,d,j),l.elementType=Y,l.lanes=S,l;case U:return l=Hr(19,p,d,j),l.elementType=U,l.lanes=S,l;case le:return hu(p,j,S,d);default:if(typeof l=="object"&&l!==null)switch(l.$$typeof){case L:M=10;break e;case ee:M=9;break e;case te:M=11;break e;case D:M=14;break e;case $:M=16,x=null;break e}throw Error(n(130,l==null?l:typeof l,""))}return d=Hr(M,p,d,j),d.elementType=l,d.type=x,d.lanes=S,d}function Ga(l,d,p,x){return l=Hr(7,l,x,d),l.lanes=p,l}function hu(l,d,p,x){return l=Hr(22,l,x,d),l.elementType=le,l.lanes=p,l.stateNode={isHidden:!1},l}function lm(l,d,p){return l=Hr(6,l,null,d),l.lanes=p,l}function cm(l,d,p){return d=Hr(4,l.children!==null?l.children:[],l.key,d),d.lanes=p,d.stateNode={containerInfo:l.containerInfo,pendingChildren:null,implementation:l.implementation},d}function s3(l,d,p,x,j){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=Ro(0),this.expirationTimes=Ro(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ro(0),this.identifierPrefix=x,this.onRecoverableError=j,this.mutableSourceEagerHydrationData=null}function dm(l,d,p,x,j,S,M,B,q){return l=new s3(l,d,p,B,q),d===1?(d=1,S===!0&&(d|=8)):d=0,S=Hr(3,null,null,d),l.current=S,S.stateNode=l,S.memoizedState={element:x,isDehydrated:p,cache:null,transitions:null,pendingSuspenseBoundaries:null},jp(S),l}function i3(l,d,p){var x=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),gm.exports=x3(),gm.exports}var Nb;function y3(){if(Nb)return vu;Nb=1;var t=Ew();return vu.createRoot=t.createRoot,vu.hydrateRoot=t.hydrateRoot,vu}var v3=y3(),dd=Ew();const Tw=Cw(dd);/** - * @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 Kc(){return Kc=Object.assign?Object.assign.bind():function(t){for(var e=1;e"u")throw new Error(e)}function Ex(t,e){if(!t){typeof console<"u"&&console.warn(e);try{throw new Error(e)}catch{}}}function N3(){return Math.random().toString(36).substr(2,8)}function jb(t,e){return{usr:t.state,key:t.key,idx:e}}function gg(t,e,n,r){return n===void 0&&(n=null),Kc({pathname:typeof t=="string"?t:t.pathname,search:"",hash:""},typeof e=="string"?Rl(e):e,{state:n,key:e&&e.key||r||N3()})}function sh(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 Rl(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 w3(t,e,n,r){r===void 0&&(r={});let{window:i=document.defaultView,v5Compat:a=!1}=r,o=i.history,c=sa.Pop,u=null,h=f();h==null&&(h=0,o.replaceState(Kc({},o.state,{idx:h}),""));function f(){return(o.state||{idx:null}).idx}function m(){c=sa.Pop;let N=f(),k=N==null?null:N-h;h=N,u&&u({action:c,location:w.location,delta:k})}function g(N,k){c=sa.Push;let E=gg(w.location,N,k);h=f()+1;let C=jb(E,h),T=w.createHref(E);try{o.pushState(C,"",T)}catch(O){if(O instanceof DOMException&&O.name==="DataCloneError")throw O;i.location.assign(T)}a&&u&&u({action:c,location:w.location,delta:1})}function y(N,k){c=sa.Replace;let E=gg(w.location,N,k);h=f();let C=jb(E,h),T=w.createHref(E);o.replaceState(C,"",T),a&&u&&u({action:c,location:w.location,delta:0})}function v(N){let k=i.location.origin!=="null"?i.location.origin:i.location.href,E=typeof N=="string"?N:sh(N);return E=E.replace(/ $/,"%20"),dn(k,"No window.location.(origin|href) available to create URL for href: "+E),new URL(E,k)}let w={get action(){return c},get location(){return t(i,o)},listen(N){if(u)throw new Error("A history only accepts one active listener");return i.addEventListener(wb,m),u=N,()=>{i.removeEventListener(wb,m),u=null}},createHref(N){return e(i,N)},createURL:v,encodeLocation(N){let k=v(N);return{pathname:k.pathname,search:k.search,hash:k.hash}},push:g,replace:y,go(N){return o.go(N)}};return w}var kb;(function(t){t.data="data",t.deferred="deferred",t.redirect="redirect",t.error="error"})(kb||(kb={}));function j3(t,e,n){return n===void 0&&(n="/"),k3(t,e,n)}function k3(t,e,n,r){let i=typeof e=="string"?Rl(e):e,a=Tx(i.pathname||"/",n);if(a==null)return null;let o=Mw(t);S3(o);let c=null;for(let u=0;c==null&&u{let u={relativePath:c===void 0?a.path||"":c,caseSensitive:a.caseSensitive===!0,childrenIndex:o,route:a};u.relativePath.startsWith("/")&&(dn(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=ca([r,u.relativePath]),f=n.concat(u);a.children&&a.children.length>0&&(dn(a.index!==!0,"Index routes must not have child routes. Please remove "+('all child routes from route path "'+h+'".')),Mw(a.children,e,f,h)),!(a.path==null&&!a.index)&&e.push({path:h,score:R3(h,a.index),routesMeta:f})};return t.forEach((a,o)=>{var c;if(a.path===""||!((c=a.path)!=null&&c.includes("?")))i(a,o);else for(let u of Aw(a.path))i(a,o,u)}),e}function Aw(t){let e=t.split("/");if(e.length===0)return[];let[n,...r]=e,i=n.endsWith("?"),a=n.replace(/\?$/,"");if(r.length===0)return i?[a,""]:[a];let o=Aw(r.join("/")),c=[];return c.push(...o.map(u=>u===""?a:[a,u].join("/"))),i&&c.push(...o),c.map(u=>t.startsWith("/")&&u===""?"/":u)}function S3(t){t.sort((e,n)=>e.score!==n.score?n.score-e.score:P3(e.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}const C3=/^:[\w-]+$/,E3=3,T3=2,M3=1,A3=10,I3=-2,Sb=t=>t==="*";function R3(t,e){let n=t.split("/"),r=n.length;return n.some(Sb)&&(r+=I3),e&&(r+=T3),n.filter(i=>!Sb(i)).reduce((i,a)=>i+(C3.test(a)?E3:a===""?M3:A3),r)}function P3(t,e){return t.length===e.length&&t.slice(0,-1).every((r,i)=>r===e[i])?t[t.length-1]-e[e.length-1]:0}function O3(t,e,n){let{routesMeta:r}=t,i={},a="/",o=[];for(let c=0;c{let{paramName:g,isOptional:y}=f;if(g==="*"){let w=c[m]||"";o=a.slice(0,a.length-w.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 L3(t,e,n){e===void 0&&(e=!1),n===void 0&&(n=!0),Ex(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=[],i="^"+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:"*"}),i+=t==="*"||t==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?i+="\\/*$":t!==""&&t!=="/"&&(i+="(?:(?=\\/|$))"),[new RegExp(i,e?void 0:"i"),r]}function _3(t){try{return t.split("/").map(e=>decodeURIComponent(e).replace(/\//g,"%2F")).join("/")}catch(e){return Ex(!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 Tx(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 z3=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,$3=t=>z3.test(t);function F3(t,e){e===void 0&&(e="/");let{pathname:n,search:r="",hash:i=""}=typeof t=="string"?Rl(t):t,a;if(n)if($3(n))a=n;else{if(n.includes("//")){let o=n;n=n.replace(/\/\/+/g,"/"),Ex(!1,"Pathnames cannot have embedded double slashes - normalizing "+(o+" -> "+n))}n.startsWith("/")?a=Cb(n.substring(1),"/"):a=Cb(n,e)}else a=e;return{pathname:a,search:H3(r),hash:W3(i)}}function Cb(t,e){let n=e.replace(/\/+$/,"").split("/");return t.split("/").forEach(i=>{i===".."?n.length>1&&n.pop():i!=="."&&n.push(i)}),n.length>1?n.join("/"):"/"}function vm(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 and the router will parse it for you.'}function B3(t){return t.filter((e,n)=>n===0||e.route.path&&e.route.path.length>0)}function Mx(t,e){let n=B3(t);return e?n.map((r,i)=>i===n.length-1?r.pathname:r.pathnameBase):n.map(r=>r.pathnameBase)}function Ax(t,e,n,r){r===void 0&&(r=!1);let i;typeof t=="string"?i=Rl(t):(i=Kc({},t),dn(!i.pathname||!i.pathname.includes("?"),vm("?","pathname","search",i)),dn(!i.pathname||!i.pathname.includes("#"),vm("#","pathname","hash",i)),dn(!i.search||!i.search.includes("#"),vm("#","search","hash",i)));let a=t===""||i.pathname==="",o=a?"/":i.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;i.pathname=g.join("/")}c=m>=0?e[m]:"/"}let u=F3(i,c),h=o&&o!=="/"&&o.endsWith("/"),f=(a||o===".")&&n.endsWith("/");return!u.pathname.endsWith("/")&&(h||f)&&(u.pathname+="/"),u}const ca=t=>t.join("/").replace(/\/\/+/g,"/"),V3=t=>t.replace(/\/+$/,"").replace(/^\/*/,"/"),H3=t=>!t||t==="?"?"":t.startsWith("?")?t:"?"+t,W3=t=>!t||t==="#"?"":t.startsWith("#")?t:"#"+t;function U3(t){return t!=null&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.internal=="boolean"&&"data"in t}const Iw=["post","put","patch","delete"];new Set(Iw);const K3=["get",...Iw];new Set(K3);/** - * 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 qc(){return qc=Object.assign?Object.assign.bind():function(t){for(var e=1;e{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=Ax(h,JSON.parse(o),a,f.relative==="path");t==null&&e!=="/"&&(m.pathname=m.pathname==="/"?e:ca([e,m.pathname])),(f.replace?r.replace:r.push)(m,f.state,f)},[e,r,o,a,t])}const Y3=b.createContext(null);function Q3(t){let e=b.useContext(wi).outlet;return e&&b.createElement(Y3.Provider,{value:t},e)}function Ow(t,e){let{relative:n}=e===void 0?{}:e,{future:r}=b.useContext(Na),{matches:i}=b.useContext(wi),{pathname:a}=wa(),o=JSON.stringify(Mx(i,r.v7_relativeSplatPath));return b.useMemo(()=>Ax(t,JSON.parse(o),a,n==="path"),[t,o,a,n])}function X3(t,e){return Z3(t,e)}function Z3(t,e,n,r){Pl()||dn(!1);let{navigator:i}=b.useContext(Na),{matches:a}=b.useContext(wi),o=a[a.length-1],c=o?o.params:{};o&&o.pathname;let u=o?o.pathnameBase:"/";o&&o.route;let h=wa(),f;if(e){var m;let N=typeof e=="string"?Rl(e):e;u==="/"||(m=N.pathname)!=null&&m.startsWith(u)||dn(!1),f=N}else f=h;let g=f.pathname||"/",y=g;if(u!=="/"){let N=u.replace(/^\//,"").split("/");y="/"+g.replace(/^\//,"").split("/").slice(N.length).join("/")}let v=j3(t,{pathname:y}),w=sT(v&&v.map(N=>Object.assign({},N,{params:Object.assign({},c,N.params),pathname:ca([u,i.encodeLocation?i.encodeLocation(N.pathname).pathname:N.pathname]),pathnameBase:N.pathnameBase==="/"?u:ca([u,i.encodeLocation?i.encodeLocation(N.pathnameBase).pathname:N.pathnameBase])})),a,n,r);return e&&w?b.createElement(lf.Provider,{value:{location:qc({pathname:"/",search:"",hash:"",state:null,key:"default"},f),navigationType:sa.Pop}},w):w}function eT(){let t=lT(),e=U3(t)?t.status+" "+t.statusText:t instanceof Error?t.message:JSON.stringify(t),n=t instanceof Error?t.stack:null,i={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:i},n):null,null)}const tT=b.createElement(eT,null);class nT 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(wi.Provider,{value:this.props.routeContext},b.createElement(Rw.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function rT(t){let{routeContext:e,match:n,children:r}=t,i=b.useContext(Ix);return i&&i.static&&i.staticContext&&(n.route.errorElement||n.route.ErrorBoundary)&&(i.staticContext._deepestRenderedBoundaryId=n.route.id),b.createElement(wi.Provider,{value:e},r)}function sT(t,e,n,r){var i;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=(i=n)==null?void 0:i.errors;if(c!=null){let f=o.findIndex(m=>m.route.id&&(c==null?void 0:c[m.route.id])!==void 0);f>=0||dn(!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=0?o=o.slice(0,h+1):o=[o[0]];break}}}return o.reduceRight((f,m,g)=>{let y,v=!1,w=null,N=null;n&&(y=c&&m.route.id?c[m.route.id]:void 0,w=m.route.errorElement||tT,u&&(h<0&&g===0?(dT("route-fallback"),v=!0,N=null):h===g&&(v=!0,N=m.route.hydrateFallbackElement||null)));let k=e.concat(o.slice(0,g+1)),E=()=>{let C;return y?C=w:v?C=N:m.route.Component?C=b.createElement(m.route.Component,null):m.route.element?C=m.route.element:C=f,b.createElement(rT,{match:m,routeContext:{outlet:f,matches:k,isDataRoute:n!=null},children:C})};return n&&(m.route.ErrorBoundary||m.route.errorElement||g===0)?b.createElement(nT,{location:n.location,revalidation:n.revalidation,component:w,error:y,children:E(),routeContext:{outlet:null,matches:k,isDataRoute:!0}}):E()},null)}var Dw=(function(t){return t.UseBlocker="useBlocker",t.UseRevalidator="useRevalidator",t.UseNavigateStable="useNavigate",t})(Dw||{}),Lw=(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})(Lw||{});function iT(t){let e=b.useContext(Ix);return e||dn(!1),e}function aT(t){let e=b.useContext(q3);return e||dn(!1),e}function oT(t){let e=b.useContext(wi);return e||dn(!1),e}function _w(t){let e=oT(),n=e.matches[e.matches.length-1];return n.route.id||dn(!1),n.route.id}function lT(){var t;let e=b.useContext(Rw),n=aT(),r=_w();return e!==void 0?e:(t=n.errors)==null?void 0:t[r]}function cT(){let{router:t}=iT(Dw.UseNavigateStable),e=_w(Lw.UseNavigateStable),n=b.useRef(!1);return Pw(()=>{n.current=!0}),b.useCallback(function(i,a){a===void 0&&(a={}),n.current&&(typeof i=="number"?t.navigate(i):t.navigate(i,qc({fromRouteId:e},a)))},[t,e])}const Eb={};function dT(t,e,n){Eb[t]||(Eb[t]=!0)}function uT(t,e){t==null||t.v7_startTransition,t==null||t.v7_relativeSplatPath}function bm(t){let{to:e,replace:n,state:r,relative:i}=t;Pl()||dn(!1);let{future:a,static:o}=b.useContext(Na),{matches:c}=b.useContext(wi),{pathname:u}=wa(),h=ja(),f=Ax(e,Mx(c,a.v7_relativeSplatPath),u,i==="path"),m=JSON.stringify(f);return b.useEffect(()=>h(JSON.parse(m),{replace:n,state:r,relative:i}),[h,m,i,n,r]),null}function hT(t){return Q3(t.context)}function zt(t){dn(!1)}function fT(t){let{basename:e="/",children:n=null,location:r,navigationType:i=sa.Pop,navigator:a,static:o=!1,future:c}=t;Pl()&&dn(!1);let u=e.replace(/^\/*/,"/"),h=b.useMemo(()=>({basename:u,navigator:a,static:o,future:qc({v7_relativeSplatPath:!1},c)}),[u,c,a,o]);typeof r=="string"&&(r=Rl(r));let{pathname:f="/",search:m="",hash:g="",state:y=null,key:v="default"}=r,w=b.useMemo(()=>{let N=Tx(f,u);return N==null?null:{location:{pathname:N,search:m,hash:g,state:y,key:v},navigationType:i}},[u,f,m,g,y,v,i]);return w==null?null:b.createElement(Na.Provider,{value:h},b.createElement(lf.Provider,{children:n,value:w}))}function pT(t){let{children:e,location:n}=t;return X3(xg(e),n)}new Promise(()=>{});function xg(t,e){e===void 0&&(e=[]);let n=[];return b.Children.forEach(t,(r,i)=>{if(!b.isValidElement(r))return;let a=[...e,i];if(r.type===b.Fragment){n.push.apply(n,xg(r.props.children,a));return}r.type!==zt&&dn(!1),!r.props.index||!r.props.children||dn(!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=xg(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 yg(){return yg=Object.assign?Object.assign.bind():function(t){for(var e=1;e=0)&&(n[i]=t[i]);return n}function gT(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function xT(t,e){return t.button===0&&(!e||e==="_self")&&!gT(t)}function vg(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(i=>[n,i]):[[n,r]])},[]))}function yT(t,e){let n=vg(t);return e&&e.forEach((r,i)=>{n.has(i)||e.getAll(i).forEach(a=>{n.append(i,a)})}),n}const vT=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset","viewTransition"],bT="6";try{window.__reactRouterVersion=bT}catch{}const NT="startTransition",Tb=of[NT];function wT(t){let{basename:e,children:n,future:r,window:i}=t,a=b.useRef();a.current==null&&(a.current=b3({window:i,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&&Tb?Tb(()=>u(m)):u(m)},[u,h]);return b.useLayoutEffect(()=>o.listen(f),[o,f]),b.useEffect(()=>uT(r),[r]),b.createElement(fT,{basename:e,children:n,location:c.location,navigationType:c.action,navigator:o,future:r})}const jT=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",kT=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,bg=b.forwardRef(function(e,n){let{onClick:r,relative:i,reloadDocument:a,replace:o,state:c,target:u,to:h,preventScrollReset:f,viewTransition:m}=e,g=mT(e,vT),{basename:y}=b.useContext(Na),v,w=!1;if(typeof h=="string"&&kT.test(h)&&(v=h,jT))try{let C=new URL(window.location.href),T=h.startsWith("//")?new URL(C.protocol+h):new URL(h),O=Tx(T.pathname,y);T.origin===C.origin&&O!=null?h=O+T.search+T.hash:w=!0}catch{}let N=G3(h,{relative:i}),k=ST(h,{replace:o,state:c,target:u,preventScrollReset:f,relative:i,viewTransition:m});function E(C){r&&r(C),C.defaultPrevented||k(C)}return b.createElement("a",yg({},g,{href:v||N,onClick:w||a?r:E,ref:n,target:u}))});var Mb;(function(t){t.UseScrollRestoration="useScrollRestoration",t.UseSubmit="useSubmit",t.UseSubmitFetcher="useSubmitFetcher",t.UseFetcher="useFetcher",t.useViewTransitionState="useViewTransitionState"})(Mb||(Mb={}));var Ab;(function(t){t.UseFetcher="useFetcher",t.UseFetchers="useFetchers",t.UseScrollRestoration="useScrollRestoration"})(Ab||(Ab={}));function ST(t,e){let{target:n,replace:r,state:i,preventScrollReset:a,relative:o,viewTransition:c}=e===void 0?{}:e,u=ja(),h=wa(),f=Ow(t,{relative:o});return b.useCallback(m=>{if(xT(m,n)){m.preventDefault();let g=r!==void 0?r:sh(h)===sh(f);u(t,{replace:g,state:i,preventScrollReset:a,relative:o,viewTransition:c})}},[h,u,f,r,i,n,t,a,o,c])}function zw(t){let e=b.useRef(vg(t)),n=b.useRef(!1),r=wa(),i=b.useMemo(()=>yT(r.search,n.current?null:e.current),[r.search]),a=ja(),o=b.useCallback((c,u)=>{const h=vg(typeof c=="function"?c(i):c);n.current=!0,a("?"+h,u)},[a,i]);return[i,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 CT=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),ET=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,r)=>r?r.toUpperCase():n.toLowerCase()),Ib=t=>{const e=ET(t);return e.charAt(0).toUpperCase()+e.slice(1)},$w=(...t)=>t.filter((e,n,r)=>!!e&&e.trim()!==""&&r.indexOf(e)===n).join(" ").trim(),TT=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 MT={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 AT=b.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:i="",children:a,iconNode:o,...c},u)=>b.createElement("svg",{ref:u,...MT,width:e,height:e,stroke:t,strokeWidth:r?Number(n)*24/Number(e):n,className:$w("lucide",i),...!a&&!TT(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 Ee=(t,e)=>{const n=b.forwardRef(({className:r,...i},a)=>b.createElement(AT,{ref:a,iconNode:e,className:$w(`lucide-${CT(Ib(t))}`,`lucide-${t}`,r),...i}));return n.displayName=Ib(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 IT=[["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"}]],Nm=Ee("arrow-up-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 RT=[["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"}]],Rb=Ee("bitcoin",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 PT=[["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"}]],OT=Ee("bold",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:"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"}]],Gr=Ee("book-open",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:"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"}]],ih=Ee("calendar",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=[["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"}]],zT=Ee("chart-column",_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:"M20 6 9 17l-5-5",key:"1gmf2c"}]],cf=Ee("check",$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=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Gc=Ee("chevron-down",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=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],VT=Ee("chevron-left",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 HT=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],fl=Ee("chevron-right",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:"m18 15-6-6-6 6",key:"153udz"}]],Fw=Ee("chevron-up",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=[["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"}]],KT=Ee("circle-alert",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=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],Pb=Ee("circle-check-big",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=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],Ng=Ee("circle-check",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=[["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"}]],Bw=Ee("circle-question-mark",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=[["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"}]],wm=Ee("circle-user",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=[["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"}]],Vw=Ee("circle-x",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 XT=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],wg=Ee("clock",XT);/** - * @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:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]],eM=Ee("code",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 tM=[["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"}]],Hw=Ee("copy",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 nM=[["rect",{width:"20",height:"14",x:"2",y:"5",rx:"2",key:"ynyp8z"}],["line",{x1:"2",x2:"22",y1:"10",y2:"10",key:"1b3vmo"}]],Ob=Ee("credit-card",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 rM=[["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"}]],xl=Ee("crown",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=[["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"}]],ah=Ee("dollar-sign",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 iM=[["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"}]],aM=Ee("download",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 oM=[["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"}]],_s=Ee("external-link",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:"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"}]],jg=Ee("eye",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:"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"}]],dM=Ee("file-text",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=[["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"}]],Ww=Ee("funnel",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=[["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"}]],fM=Ee("gift",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=[["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"}]],mM=Ee("git-merge",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=[["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"}]],kg=Ee("globe",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 xM=[["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"}]],yM=Ee("graduation-cap",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 vM=[["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"}]],oi=Ee("grip-vertical",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 bM=[["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"}]],NM=Ee("handshake",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 wM=[["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"}]],Db=Ee("hash",wM);/** - * @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=[["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"}]],kM=Ee("heading-1",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 SM=[["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"}]],CM=Ee("heading-2",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 EM=[["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"}]],TM=Ee("heading-3",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 MM=[["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"}]],AM=Ee("house",MM);/** - * @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=[["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"}]],Uw=Ee("image",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 RM=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],bu=Ee("info",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 PM=[["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"}]],OM=Ee("italic",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 DM=[["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"}]],LM=Ee("key",DM);/** - * @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 _M=[["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"}]],zM=Ee("layout-dashboard",_M);/** - * @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 $M=[["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"}]],ps=Ee("link-2",$M);/** - * @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:"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"}]],Sg=Ee("link",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 BM=[["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"}]],VM=Ee("list-ordered",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 HM=[["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"}]],WM=Ee("list",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=[["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"}]],KM=Ee("lock",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:"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"}]],GM=Ee("log-out",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=[["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"}]],Kw=Ee("map-pin",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:"M4 5h16",key:"1tepv9"}],["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 19h16",key:"1djgab"}]],QM=Ee("menu",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:"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"}]],ZM=Ee("message-circle",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 eA=[["path",{d:"M5 12h14",key:"1ays0h"}]],tA=Ee("minus",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 nA=[["polygon",{points:"3 11 22 2 13 21 11 13 3 11",key:"1ltx0t"}]],pl=Ee("navigation",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 rA=[["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"}]],sA=Ee("palette",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:"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"}]],Rt=Ee("pen-line",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=[["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"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]],qw=Ee("pencil",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=[["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"}]],lA=Ee("percent",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:"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"}]],dA=Ee("phone",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:"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"}]],hA=Ee("pin",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 fA=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],rn=Ee("plus",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=[["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"}]],Lb=Ee("qr-code",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 mA=[["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"}]],gA=Ee("quote",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 xA=[["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"}]],yA=Ee("redo",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 vA=[["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"}]],Ke=Ee("refresh-cw",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=[["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"}]],cn=Ee("save",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 NA=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],da=Ee("search",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 wA=[["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"}]],jA=Ee("send",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 kA=[["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"}]],so=Ee("settings",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 SA=[["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"}]],Nu=Ee("settings-2",SA);/** - * @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:"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"}]],Rx=Ee("shield-check",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:"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"}]],Cg=Ee("shopping-bag",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=[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]],uo=Ee("smartphone",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:"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"}]],ml=Ee("star",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:"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"}]],IA=Ee("strikethrough",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:"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"}]],PA=Ee("table",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 OA=[["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"}]],qu=Ee("tag",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:"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"}]],Dn=Ee("trash-2",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 7h6v6",key:"box55l"}],["path",{d:"m22 7-8.5 8.5-5-5L2 17",key:"1t1m79"}]],Oc=Ee("trending-up",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:"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"}]],_b=Ee("trophy",_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:"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"}]],Gw=Ee("undo-2",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:"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"}]],FA=Ee("undo",$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 BA=[["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"}]],oh=Ee("upload",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 VA=[["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"}]],Eg=Ee("user-plus",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 HA=[["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"}]],yl=Ee("user",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 WA=[["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"}]],$n=Ee("users",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 UA=[["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"}]],jl=Ee("wallet",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 KA=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],or=Ee("x",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 qA=[["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"}]],ia=Ee("zap",qA),Px="admin_token";function Ox(){try{return localStorage.getItem(Px)}catch{return null}}function GA(t){try{localStorage.setItem(Px,t)}catch{}}function JA(){try{localStorage.removeItem(Px)}catch{}}const YA="https://soulapi.quwanzhi.com",QA=15e3,XA=()=>{const t="https://soulapi.quwanzhi.com";return t.length>0?t.replace(/\/$/,""):YA};function ho(t){const e=XA(),n=t.startsWith("/")?t:`/${t}`;return e?`${e}${n}`:n}async function df(t,e={}){const{data:n,...r}=e,i=ho(t),a=new Headers(r.headers),o=Ox();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(),QA),f=await fetch(i,{...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 Le(t,e){return df(t,{...e,method:"GET"})}function xt(t,e,n){return df(t,{...n,method:"POST",data:e})}function St(t,e,n){return df(t,{...n,method:"PUT",data:e})}function Ps(t,e){return df(t,{...e,method:"DELETE"})}const ZA=[{icon:zM,label:"数据概览",href:"/dashboard"},{icon:Gr,label:"内容管理",href:"/content"},{icon:$n,label:"用户管理",href:"/users"},{icon:mM,label:"找伙伴",href:"/find-partner"},{icon:jl,label:"推广中心",href:"/distribution"}];function e5(){const t=wa(),e=ja(),[n,r]=b.useState(!1),[i,a]=b.useState(!1);b.useEffect(()=>{r(!0)},[]),b.useEffect(()=>{if(!n)return;a(!1);let c=!1;return Le("/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()=>{JA();try{await xt("/api/admin/logout",{})}catch{}e("/login",{replace:!0})};return!n||!i?s.jsxs("div",{className:"flex min-h-screen bg-[#0a1628]",children:[s.jsx("div",{className:"w-64 bg-[#0f2137] border-r border-gray-700/50"}),s.jsx("div",{className:"flex-1 flex items-center justify-center",children:s.jsx("div",{className:"text-[#38bdac]",children:"加载中..."})})]}):s.jsxs("div",{className:"flex min-h-screen bg-[#0a1628]",children:[s.jsxs("div",{className:"w-64 bg-[#0f2137] flex flex-col border-r border-gray-700/50 shadow-xl",children:[s.jsxs("div",{className:"p-6 border-b border-gray-700/50",children:[s.jsx("h1",{className:"text-xl font-bold text-[#38bdac]",children:"管理后台"}),s.jsx("p",{className:"text-xs text-gray-400 mt-1",children:"Soul创业派对"})]}),s.jsxs("nav",{className:"flex-1 p-4 space-y-1 overflow-y-auto",children:[ZA.map(c=>{const u=t.pathname===c.href;return s.jsxs(bg,{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:[s.jsx(c.icon,{className:"w-5 h-5 shrink-0"}),s.jsx("span",{className:"text-sm",children:c.label})]},c.href)}),s.jsx("div",{className:"pt-4 mt-4 border-t border-gray-700/50",children:s.jsxs(bg,{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:[s.jsx(so,{className:"w-5 h-5 shrink-0"}),s.jsx("span",{className:"text-sm",children:"系统设置"})]})})]}),s.jsx("div",{className:"p-4 border-t border-gray-700/50 space-y-1",children:s.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:[s.jsx(GM,{className:"w-5 h-5"}),s.jsx("span",{className:"text-sm",children:"退出登录"})]})})]}),s.jsx("div",{className:"flex-1 overflow-auto bg-[#0a1628] min-w-0",children:s.jsx("div",{className:"w-full min-w-[1024px] min-h-full",children:s.jsx(hT,{})})})]})}function zb(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}function Dx(...t){return e=>{let n=!1;const r=t.map(i=>{const a=zb(i,e);return!n&&typeof a=="function"&&(n=!0),a});if(n)return()=>{for(let i=0;i{let{children:a,...o}=r;Jw(a)&&typeof lh=="function"&&(a=lh(a._payload));const c=b.Children.toArray(a),u=c.find(i5);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 s.jsx(e,{...o,ref:i,children:b.isValidElement(h)?b.cloneElement(h,void 0,f):null})}return s.jsx(e,{...o,ref:i,children:a})});return n.displayName=`${t}.Slot`,n}var Qw=Yw("Slot");function r5(t){const e=b.forwardRef((n,r)=>{let{children:i,...a}=n;if(Jw(i)&&typeof lh=="function"&&(i=lh(i._payload)),b.isValidElement(i)){const o=o5(i),c=a5(a,i.props);return i.type!==b.Fragment&&(c.ref=r?Dx(r,o):o),b.cloneElement(i,c)}return b.Children.count(i)>1?b.Children.only(null):null});return e.displayName=`${t}.SlotClone`,e}var s5=Symbol("radix.slottable");function i5(t){return b.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===s5}function a5(t,e){const n={...e};for(const r in e){const i=t[r],a=e[r];/^on[A-Z]/.test(r)?i&&a?n[r]=(...c)=>{const u=a(...c);return i(...c),u}:i&&(n[r]=i):r==="style"?n[r]={...i,...a}:r==="className"&&(n[r]=[i,a].filter(Boolean).join(" "))}return{...t,...n}}function o5(t){var r,i;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=(i=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:i.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}function Xw(t){var e,n,r="";if(typeof t=="string"||typeof t=="number")r+=t;else if(typeof t=="object")if(Array.isArray(t)){var i=t.length;for(e=0;etypeof t=="boolean"?`${t}`:t===0?"0":t,Fb=Zw,ej=(t,e)=>n=>{var r;if((e==null?void 0:e.variants)==null)return Fb(t,n==null?void 0:n.class,n==null?void 0:n.className);const{variants:i,defaultVariants:a}=e,o=Object.keys(i).map(h=>{const f=n==null?void 0:n[h],m=a==null?void 0:a[h];if(f===null)return null;const g=$b(f)||$b(m);return i[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[w,N]=v;return Array.isArray(N)?N.includes({...a,...c}[w]):{...a,...c}[w]===N})?[...h,m,g]:h},[]);return Fb(t,o,u,n==null?void 0:n.class,n==null?void 0:n.className)},l5=(t,e)=>{const n=new Array(t.length+e.length);for(let r=0;r({classGroupId:t,validator:e}),tj=(t=new Map,e=null,n)=>({nextPart:t,validators:e,classGroupId:n}),ch="-",Bb=[],d5="arbitrary..",u5=t=>{const e=f5(t),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=t;return{getClassGroupId:o=>{if(o.startsWith("[")&&o.endsWith("]"))return h5(o);const c=o.split(ch),u=c[0]===""&&c.length>1?1:0;return nj(c,u,e)},getConflictingClassGroupIds:(o,c)=>{if(c){const u=r[o],h=n[o];return u?h?l5(h,u):u:h||Bb}return n[o]||Bb}}},nj=(t,e,n)=>{if(t.length-e===0)return n.classGroupId;const i=t[e],a=n.nextPart.get(i);if(a){const h=nj(t,e+1,a);if(h)return h}const o=n.validators;if(o===null)return;const c=e===0?t.join(ch):t.slice(e).join(ch),u=o.length;for(let h=0;ht.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const e=t.slice(1,-1),n=e.indexOf(":"),r=e.slice(0,n);return r?d5+r:void 0})(),f5=t=>{const{theme:e,classGroups:n}=t;return p5(n,e)},p5=(t,e)=>{const n=tj();for(const r in t){const i=t[r];Lx(i,n,r,e)}return n},Lx=(t,e,n,r)=>{const i=t.length;for(let a=0;a{if(typeof t=="string"){g5(t,e,n);return}if(typeof t=="function"){x5(t,e,n,r);return}y5(t,e,n,r)},g5=(t,e,n)=>{const r=t===""?e:rj(e,t);r.classGroupId=n},x5=(t,e,n,r)=>{if(v5(t)){Lx(t(r),e,n,r);return}e.validators===null&&(e.validators=[]),e.validators.push(c5(n,t))},y5=(t,e,n,r)=>{const i=Object.entries(t),a=i.length;for(let o=0;o{let n=t;const r=e.split(ch),i=r.length;for(let a=0;a"isThemeGetter"in t&&t.isThemeGetter===!0,b5=t=>{if(t<1)return{get:()=>{},set:()=>{}};let e=0,n=Object.create(null),r=Object.create(null);const i=(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 i(a,o),o},set(a,o){a in n?n[a]=o:i(a,o)}}},Tg="!",Vb=":",N5=[],Hb=(t,e,n,r,i)=>({modifiers:t,hasImportantModifier:e,baseClassName:n,maybePostfixModifierPosition:r,isExternal:i}),w5=t=>{const{prefix:e,experimentalParseClassName:n}=t;let r=i=>{const a=[];let o=0,c=0,u=0,h;const f=i.length;for(let w=0;wu?h-u:void 0;return Hb(a,y,g,v)};if(e){const i=e+Vb,a=r;r=o=>o.startsWith(i)?a(o.slice(i.length)):Hb(N5,!1,o,void 0,!0)}if(n){const i=r;r=a=>n({className:a,parseClassName:i})}return r},j5=t=>{const e=new Map;return t.orderSensitiveModifiers.forEach((n,r)=>{e.set(n,1e6+r)}),n=>{const r=[];let i=[];for(let a=0;a0&&(i.sort(),r.push(...i),i=[]),r.push(o)):i.push(o)}return i.length>0&&(i.sort(),r.push(...i)),r}},k5=t=>({cache:b5(t.cacheSize),parseClassName:w5(t),sortModifiers:j5(t),...u5(t)}),S5=/\s+/,C5=(t,e)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:i,sortModifiers:a}=e,o=[],c=t.trim().split(S5);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:w}=n(f);if(m){u=f+(u.length>0?" "+u:u);continue}let N=!!w,k=r(N?v.substring(0,w):v);if(!k){if(!N){u=f+(u.length>0?" "+u:u);continue}if(k=r(v),!k){u=f+(u.length>0?" "+u:u);continue}N=!1}const E=g.length===0?"":g.length===1?g[0]:a(g).join(":"),C=y?E+Tg:E,T=C+k;if(o.indexOf(T)>-1)continue;o.push(T);const O=i(k,N);for(let F=0;F0?" "+u:u)}return u},E5=(...t)=>{let e=0,n,r,i="";for(;e{if(typeof t=="string")return t;let e,n="";for(let r=0;r{let n,r,i,a;const o=u=>{const h=e.reduce((f,m)=>m(f),t());return n=k5(h),r=n.cache.get,i=n.cache.set,a=c,c(u)},c=u=>{const h=r(u);if(h)return h;const f=C5(u,n);return i(u,f),f};return a=o,(...u)=>a(E5(...u))},M5=[],vn=t=>{const e=n=>n[t]||M5;return e.isThemeGetter=!0,e},ij=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,aj=/^\((?:(\w[\w-]*):)?(.+)\)$/i,A5=/^\d+\/\d+$/,I5=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,R5=/\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$/,P5=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,O5=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,D5=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,nl=t=>A5.test(t),lt=t=>!!t&&!Number.isNaN(Number(t)),qi=t=>!!t&&Number.isInteger(Number(t)),jm=t=>t.endsWith("%")&<(t.slice(0,-1)),li=t=>I5.test(t),L5=()=>!0,_5=t=>R5.test(t)&&!P5.test(t),oj=()=>!1,z5=t=>O5.test(t),$5=t=>D5.test(t),F5=t=>!ze(t)&&!$e(t),B5=t=>Ol(t,dj,oj),ze=t=>ij.test(t),Ja=t=>Ol(t,uj,_5),km=t=>Ol(t,K5,lt),Wb=t=>Ol(t,lj,oj),V5=t=>Ol(t,cj,$5),wu=t=>Ol(t,hj,z5),$e=t=>aj.test(t),wc=t=>Dl(t,uj),H5=t=>Dl(t,q5),Ub=t=>Dl(t,lj),W5=t=>Dl(t,dj),U5=t=>Dl(t,cj),ju=t=>Dl(t,hj,!0),Ol=(t,e,n)=>{const r=ij.exec(t);return r?r[1]?e(r[1]):n(r[2]):!1},Dl=(t,e,n=!1)=>{const r=aj.exec(t);return r?r[1]?e(r[1]):n:!1},lj=t=>t==="position"||t==="percentage",cj=t=>t==="image"||t==="url",dj=t=>t==="length"||t==="size"||t==="bg-size",uj=t=>t==="length",K5=t=>t==="number",q5=t=>t==="family-name",hj=t=>t==="shadow",G5=()=>{const t=vn("color"),e=vn("font"),n=vn("text"),r=vn("font-weight"),i=vn("tracking"),a=vn("leading"),o=vn("breakpoint"),c=vn("container"),u=vn("spacing"),h=vn("radius"),f=vn("shadow"),m=vn("inset-shadow"),g=vn("text-shadow"),y=vn("drop-shadow"),v=vn("blur"),w=vn("perspective"),N=vn("aspect"),k=vn("ease"),E=vn("animate"),C=()=>["auto","avoid","all","avoid-page","page","left","right","column"],T=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],O=()=>[...T(),$e,ze],F=()=>["auto","hidden","clip","visible","scroll"],I=()=>["auto","contain","none"],R=()=>[$e,ze,u],P=()=>[nl,"full","auto",...R()],L=()=>[qi,"none","subgrid",$e,ze],ee=()=>["auto",{span:["full",qi,$e,ze]},qi,$e,ze],te=()=>[qi,"auto",$e,ze],Y=()=>["auto","min","max","fr",$e,ze],U=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],D=()=>["start","end","center","stretch","center-safe","end-safe"],$=()=>["auto",...R()],le=()=>[nl,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...R()],_=()=>[t,$e,ze],se=()=>[...T(),Ub,Wb,{position:[$e,ze]}],J=()=>["no-repeat",{repeat:["","x","y","space","round"]}],z=()=>["auto","cover","contain",W5,B5,{size:[$e,ze]}],W=()=>[jm,wc,Ja],ue=()=>["","none","full",h,$e,ze],G=()=>["",lt,wc,Ja],fe=()=>["solid","dashed","dotted","double"],X=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],ce=()=>[lt,jm,Ub,Wb],he=()=>["","none",v,$e,ze],we=()=>["none",lt,$e,ze],V=()=>["none",lt,$e,ze],be=()=>[lt,$e,ze],Me=()=>[nl,"full",...R()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[li],breakpoint:[li],color:[L5],container:[li],"drop-shadow":[li],ease:["in","out","in-out"],font:[F5],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[li],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[li],shadow:[li],spacing:["px",lt],text:[li],"text-shadow":[li],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",nl,ze,$e,N]}],container:["container"],columns:[{columns:[lt,ze,$e,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:O()}],overflow:[{overflow:F()}],"overflow-x":[{"overflow-x":F()}],"overflow-y":[{"overflow-y":F()}],overscroll:[{overscroll:I()}],"overscroll-x":[{"overscroll-x":I()}],"overscroll-y":[{"overscroll-y":I()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:P()}],"inset-x":[{"inset-x":P()}],"inset-y":[{"inset-y":P()}],start:[{start:P()}],end:[{end:P()}],top:[{top:P()}],right:[{right:P()}],bottom:[{bottom:P()}],left:[{left:P()}],visibility:["visible","invisible","collapse"],z:[{z:[qi,"auto",$e,ze]}],basis:[{basis:[nl,"full","auto",c,...R()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[lt,nl,"auto","initial","none",ze]}],grow:[{grow:["",lt,$e,ze]}],shrink:[{shrink:["",lt,$e,ze]}],order:[{order:[qi,"first","last","none",$e,ze]}],"grid-cols":[{"grid-cols":L()}],"col-start-end":[{col:ee()}],"col-start":[{"col-start":te()}],"col-end":[{"col-end":te()}],"grid-rows":[{"grid-rows":L()}],"row-start-end":[{row:ee()}],"row-start":[{"row-start":te()}],"row-end":[{"row-end":te()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":Y()}],"auto-rows":[{"auto-rows":Y()}],gap:[{gap:R()}],"gap-x":[{"gap-x":R()}],"gap-y":[{"gap-y":R()}],"justify-content":[{justify:[...U(),"normal"]}],"justify-items":[{"justify-items":[...D(),"normal"]}],"justify-self":[{"justify-self":["auto",...D()]}],"align-content":[{content:["normal",...U()]}],"align-items":[{items:[...D(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...D(),{baseline:["","last"]}]}],"place-content":[{"place-content":U()}],"place-items":[{"place-items":[...D(),"baseline"]}],"place-self":[{"place-self":["auto",...D()]}],p:[{p:R()}],px:[{px:R()}],py:[{py:R()}],ps:[{ps:R()}],pe:[{pe:R()}],pt:[{pt:R()}],pr:[{pr:R()}],pb:[{pb:R()}],pl:[{pl:R()}],m:[{m:$()}],mx:[{mx:$()}],my:[{my:$()}],ms:[{ms:$()}],me:[{me:$()}],mt:[{mt:$()}],mr:[{mr:$()}],mb:[{mb:$()}],ml:[{ml:$()}],"space-x":[{"space-x":R()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":R()}],"space-y-reverse":["space-y-reverse"],size:[{size:le()}],w:[{w:[c,"screen",...le()]}],"min-w":[{"min-w":[c,"screen","none",...le()]}],"max-w":[{"max-w":[c,"screen","none","prose",{screen:[o]},...le()]}],h:[{h:["screen","lh",...le()]}],"min-h":[{"min-h":["screen","lh","none",...le()]}],"max-h":[{"max-h":["screen","lh",...le()]}],"font-size":[{text:["base",n,wc,Ja]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[r,$e,km]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",jm,ze]}],"font-family":[{font:[H5,ze,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:[i,$e,ze]}],"line-clamp":[{"line-clamp":[lt,"none",$e,km]}],leading:[{leading:[a,...R()]}],"list-image":[{"list-image":["none",$e,ze]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",$e,ze]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:_()}],"text-color":[{text:_()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...fe(),"wavy"]}],"text-decoration-thickness":[{decoration:[lt,"from-font","auto",$e,Ja]}],"text-decoration-color":[{decoration:_()}],"underline-offset":[{"underline-offset":[lt,"auto",$e,ze]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:R()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",$e,ze]}],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",$e,ze]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:se()}],"bg-repeat":[{bg:J()}],"bg-size":[{bg:z()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},qi,$e,ze],radial:["",$e,ze],conic:[qi,$e,ze]},U5,V5]}],"bg-color":[{bg:_()}],"gradient-from-pos":[{from:W()}],"gradient-via-pos":[{via:W()}],"gradient-to-pos":[{to:W()}],"gradient-from":[{from:_()}],"gradient-via":[{via:_()}],"gradient-to":[{to:_()}],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:G()}],"border-w-x":[{"border-x":G()}],"border-w-y":[{"border-y":G()}],"border-w-s":[{"border-s":G()}],"border-w-e":[{"border-e":G()}],"border-w-t":[{"border-t":G()}],"border-w-r":[{"border-r":G()}],"border-w-b":[{"border-b":G()}],"border-w-l":[{"border-l":G()}],"divide-x":[{"divide-x":G()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":G()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...fe(),"hidden","none"]}],"divide-style":[{divide:[...fe(),"hidden","none"]}],"border-color":[{border:_()}],"border-color-x":[{"border-x":_()}],"border-color-y":[{"border-y":_()}],"border-color-s":[{"border-s":_()}],"border-color-e":[{"border-e":_()}],"border-color-t":[{"border-t":_()}],"border-color-r":[{"border-r":_()}],"border-color-b":[{"border-b":_()}],"border-color-l":[{"border-l":_()}],"divide-color":[{divide:_()}],"outline-style":[{outline:[...fe(),"none","hidden"]}],"outline-offset":[{"outline-offset":[lt,$e,ze]}],"outline-w":[{outline:["",lt,wc,Ja]}],"outline-color":[{outline:_()}],shadow:[{shadow:["","none",f,ju,wu]}],"shadow-color":[{shadow:_()}],"inset-shadow":[{"inset-shadow":["none",m,ju,wu]}],"inset-shadow-color":[{"inset-shadow":_()}],"ring-w":[{ring:G()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:_()}],"ring-offset-w":[{"ring-offset":[lt,Ja]}],"ring-offset-color":[{"ring-offset":_()}],"inset-ring-w":[{"inset-ring":G()}],"inset-ring-color":[{"inset-ring":_()}],"text-shadow":[{"text-shadow":["none",g,ju,wu]}],"text-shadow-color":[{"text-shadow":_()}],opacity:[{opacity:[lt,$e,ze]}],"mix-blend":[{"mix-blend":[...X(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":X()}],"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":[lt]}],"mask-image-linear-from-pos":[{"mask-linear-from":ce()}],"mask-image-linear-to-pos":[{"mask-linear-to":ce()}],"mask-image-linear-from-color":[{"mask-linear-from":_()}],"mask-image-linear-to-color":[{"mask-linear-to":_()}],"mask-image-t-from-pos":[{"mask-t-from":ce()}],"mask-image-t-to-pos":[{"mask-t-to":ce()}],"mask-image-t-from-color":[{"mask-t-from":_()}],"mask-image-t-to-color":[{"mask-t-to":_()}],"mask-image-r-from-pos":[{"mask-r-from":ce()}],"mask-image-r-to-pos":[{"mask-r-to":ce()}],"mask-image-r-from-color":[{"mask-r-from":_()}],"mask-image-r-to-color":[{"mask-r-to":_()}],"mask-image-b-from-pos":[{"mask-b-from":ce()}],"mask-image-b-to-pos":[{"mask-b-to":ce()}],"mask-image-b-from-color":[{"mask-b-from":_()}],"mask-image-b-to-color":[{"mask-b-to":_()}],"mask-image-l-from-pos":[{"mask-l-from":ce()}],"mask-image-l-to-pos":[{"mask-l-to":ce()}],"mask-image-l-from-color":[{"mask-l-from":_()}],"mask-image-l-to-color":[{"mask-l-to":_()}],"mask-image-x-from-pos":[{"mask-x-from":ce()}],"mask-image-x-to-pos":[{"mask-x-to":ce()}],"mask-image-x-from-color":[{"mask-x-from":_()}],"mask-image-x-to-color":[{"mask-x-to":_()}],"mask-image-y-from-pos":[{"mask-y-from":ce()}],"mask-image-y-to-pos":[{"mask-y-to":ce()}],"mask-image-y-from-color":[{"mask-y-from":_()}],"mask-image-y-to-color":[{"mask-y-to":_()}],"mask-image-radial":[{"mask-radial":[$e,ze]}],"mask-image-radial-from-pos":[{"mask-radial-from":ce()}],"mask-image-radial-to-pos":[{"mask-radial-to":ce()}],"mask-image-radial-from-color":[{"mask-radial-from":_()}],"mask-image-radial-to-color":[{"mask-radial-to":_()}],"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":T()}],"mask-image-conic-pos":[{"mask-conic":[lt]}],"mask-image-conic-from-pos":[{"mask-conic-from":ce()}],"mask-image-conic-to-pos":[{"mask-conic-to":ce()}],"mask-image-conic-from-color":[{"mask-conic-from":_()}],"mask-image-conic-to-color":[{"mask-conic-to":_()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:se()}],"mask-repeat":[{mask:J()}],"mask-size":[{mask:z()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",$e,ze]}],filter:[{filter:["","none",$e,ze]}],blur:[{blur:he()}],brightness:[{brightness:[lt,$e,ze]}],contrast:[{contrast:[lt,$e,ze]}],"drop-shadow":[{"drop-shadow":["","none",y,ju,wu]}],"drop-shadow-color":[{"drop-shadow":_()}],grayscale:[{grayscale:["",lt,$e,ze]}],"hue-rotate":[{"hue-rotate":[lt,$e,ze]}],invert:[{invert:["",lt,$e,ze]}],saturate:[{saturate:[lt,$e,ze]}],sepia:[{sepia:["",lt,$e,ze]}],"backdrop-filter":[{"backdrop-filter":["","none",$e,ze]}],"backdrop-blur":[{"backdrop-blur":he()}],"backdrop-brightness":[{"backdrop-brightness":[lt,$e,ze]}],"backdrop-contrast":[{"backdrop-contrast":[lt,$e,ze]}],"backdrop-grayscale":[{"backdrop-grayscale":["",lt,$e,ze]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[lt,$e,ze]}],"backdrop-invert":[{"backdrop-invert":["",lt,$e,ze]}],"backdrop-opacity":[{"backdrop-opacity":[lt,$e,ze]}],"backdrop-saturate":[{"backdrop-saturate":[lt,$e,ze]}],"backdrop-sepia":[{"backdrop-sepia":["",lt,$e,ze]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":R()}],"border-spacing-x":[{"border-spacing-x":R()}],"border-spacing-y":[{"border-spacing-y":R()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",$e,ze]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[lt,"initial",$e,ze]}],ease:[{ease:["linear","initial",k,$e,ze]}],delay:[{delay:[lt,$e,ze]}],animate:[{animate:["none",E,$e,ze]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[w,$e,ze]}],"perspective-origin":[{"perspective-origin":O()}],rotate:[{rotate:we()}],"rotate-x":[{"rotate-x":we()}],"rotate-y":[{"rotate-y":we()}],"rotate-z":[{"rotate-z":we()}],scale:[{scale:V()}],"scale-x":[{"scale-x":V()}],"scale-y":[{"scale-y":V()}],"scale-z":[{"scale-z":V()}],"scale-3d":["scale-3d"],skew:[{skew:be()}],"skew-x":[{"skew-x":be()}],"skew-y":[{"skew-y":be()}],transform:[{transform:[$e,ze,"","none","gpu","cpu"]}],"transform-origin":[{origin:O()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:Me()}],"translate-x":[{"translate-x":Me()}],"translate-y":[{"translate-y":Me()}],"translate-z":[{"translate-z":Me()}],"translate-none":["translate-none"],accent:[{accent:_()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:_()}],"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",$e,ze]}],"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":R()}],"scroll-mx":[{"scroll-mx":R()}],"scroll-my":[{"scroll-my":R()}],"scroll-ms":[{"scroll-ms":R()}],"scroll-me":[{"scroll-me":R()}],"scroll-mt":[{"scroll-mt":R()}],"scroll-mr":[{"scroll-mr":R()}],"scroll-mb":[{"scroll-mb":R()}],"scroll-ml":[{"scroll-ml":R()}],"scroll-p":[{"scroll-p":R()}],"scroll-px":[{"scroll-px":R()}],"scroll-py":[{"scroll-py":R()}],"scroll-ps":[{"scroll-ps":R()}],"scroll-pe":[{"scroll-pe":R()}],"scroll-pt":[{"scroll-pt":R()}],"scroll-pr":[{"scroll-pr":R()}],"scroll-pb":[{"scroll-pb":R()}],"scroll-pl":[{"scroll-pl":R()}],"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",$e,ze]}],fill:[{fill:["none",..._()]}],"stroke-w":[{stroke:[lt,wc,Ja,km]}],stroke:[{stroke:["none",..._()]}],"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"]}},J5=T5(G5);function Nt(...t){return J5(Zw(t))}const Y5=ej("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 ne({className:t,variant:e,size:n,asChild:r=!1,...i}){const a=r?Qw:"button";return s.jsx(a,{"data-slot":"button",className:Nt(Y5({variant:e,size:n,className:t})),...i})}function ae({className:t,type:e,...n}){return s.jsx("input",{type:e,"data-slot":"input",className:Nt("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 Q5(){const t=ja(),[e,n]=b.useState(""),[r,i]=b.useState(""),[a,o]=b.useState(""),[c,u]=b.useState(!1),h=async()=>{o(""),u(!0);try{const f=await xt("/api/admin",{username:e.trim(),password:r});if((f==null?void 0:f.success)!==!1&&(f!=null&&f.token)){GA(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 s.jsxs("div",{className:"min-h-screen bg-[#0a1628] flex items-center justify-center p-4",children:[s.jsxs("div",{className:"absolute inset-0 overflow-hidden",children:[s.jsx("div",{className:"absolute top-1/4 left-1/4 w-96 h-96 bg-[#38bdac]/5 rounded-full blur-3xl"}),s.jsx("div",{className:"absolute bottom-1/4 right-1/4 w-96 h-96 bg-blue-500/5 rounded-full blur-3xl"})]}),s.jsxs("div",{className:"w-full max-w-md relative z-10",children:[s.jsxs("div",{className:"text-center mb-8",children:[s.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:s.jsx(Rx,{className:"w-8 h-8 text-[#38bdac]"})}),s.jsx("h1",{className:"text-2xl font-bold text-white mb-2",children:"管理后台"}),s.jsx("p",{className:"text-gray-400",children:"一场SOUL的创业实验场"})]}),s.jsxs("div",{className:"bg-[#0f2137] rounded-2xl p-8 shadow-xl border border-gray-700/50 backdrop-blur-xl",children:[s.jsx("h2",{className:"text-xl font-semibold text-white mb-6 text-center",children:"管理员登录"}),s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-gray-400 text-sm mb-2",children:"用户名"}),s.jsxs("div",{className:"relative",children:[s.jsx(yl,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-5 h-5 text-gray-500"}),s.jsx(ae,{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]"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-gray-400 text-sm mb-2",children:"密码"}),s.jsxs("div",{className:"relative",children:[s.jsx(KM,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-5 h-5 text-gray-500"}),s.jsx(ae,{type:"password",value:r,onChange:f=>i(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&&s.jsx("div",{className:"bg-red-500/10 text-red-400 text-sm p-3 rounded-lg border border-red-500/20",children:a}),s.jsx(ne,{onClick:h,disabled:c,className:"w-full bg-[#38bdac] hover:bg-[#2da396] text-white py-5 disabled:opacity-50",children:c?"登录中...":"登录"})]})]}),s.jsx("p",{className:"text-center text-gray-500 text-xs mt-6",children:"Soul创业实验场 · 后台管理系统"})]})]})}const Ae=b.forwardRef(({className:t,...e},n)=>s.jsx("div",{ref:n,className:Nt("rounded-xl border bg-card text-card-foreground shadow",t),...e}));Ae.displayName="Card";const et=b.forwardRef(({className:t,...e},n)=>s.jsx("div",{ref:n,className:Nt("flex flex-col space-y-1.5 p-6",t),...e}));et.displayName="CardHeader";const tt=b.forwardRef(({className:t,...e},n)=>s.jsx("h3",{ref:n,className:Nt("font-semibold leading-none tracking-tight",t),...e}));tt.displayName="CardTitle";const Pt=b.forwardRef(({className:t,...e},n)=>s.jsx("p",{ref:n,className:Nt("text-sm text-muted-foreground",t),...e}));Pt.displayName="CardDescription";const Ie=b.forwardRef(({className:t,...e},n)=>s.jsx("div",{ref:n,className:Nt("p-6 pt-0",t),...e}));Ie.displayName="CardContent";const X5=b.forwardRef(({className:t,...e},n)=>s.jsx("div",{ref:n,className:Nt("flex items-center p-6 pt-0",t),...e}));X5.displayName="CardFooter";const Z5={success:{bg:"#f0fdf4",border:"#22c55e",icon:"✓"},error:{bg:"#fef2f2",border:"#ef4444",icon:"✕"},info:{bg:"#eff6ff",border:"#3b82f6",icon:"ℹ"}};function Sm(t,e="info",n=3e3){const r=`toast-${Date.now()}`,i=Z5[e],a=document.createElement("div");a.id=r,a.setAttribute("role","alert"),Object.assign(a.style,{position:"fixed",top:"24px",right:"24px",zIndex:"9999",display:"flex",alignItems:"center",gap:"10px",padding:"12px 18px",borderRadius:"10px",background:i.bg,border:`1.5px solid ${i.border}`,boxShadow:"0 4px 20px rgba(0,0,0,.12)",fontSize:"14px",color:"#1a1a1a",fontWeight:"500",maxWidth:"380px",lineHeight:"1.5",opacity:"0",transform:"translateY(-8px)",transition:"opacity .22s ease, transform .22s ease",pointerEvents:"none"});const o=document.createElement("span");Object.assign(o.style,{width:"20px",height:"20px",borderRadius:"50%",background:i.border,color:"#fff",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"12px",fontWeight:"700",flexShrink:"0"}),o.textContent=i.icon;const c=document.createElement("span");c.textContent=t,a.appendChild(o),a.appendChild(c),document.body.appendChild(a),requestAnimationFrame(()=>{a.style.opacity="1",a.style.transform="translateY(0)"});const u=setTimeout(()=>h(r),n);function h(f){clearTimeout(u);const m=document.getElementById(f);m&&(m.style.opacity="0",m.style.transform="translateY(-8px)",setTimeout(()=>{var g;return(g=m.parentNode)==null?void 0:g.removeChild(m)},250))}}const oe={success:(t,e)=>Sm(t,"success",e),error:(t,e)=>Sm(t,"error",e),info:(t,e)=>Sm(t,"info",e)};function it(t,e,{checkForDefaultPrevented:n=!0}={}){return function(i){if(t==null||t(i),n===!1||!i.defaultPrevented)return e==null?void 0:e(i)}}function eI(t,e){const n=b.createContext(e),r=a=>{const{children:o,...c}=a,u=b.useMemo(()=>c,Object.values(c));return s.jsx(n.Provider,{value:u,children:o})};r.displayName=t+"Provider";function i(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,i]}function ka(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,w=((k=g==null?void 0:g[t])==null?void 0:k[u])||c,N=b.useMemo(()=>v,Object.values(v));return s.jsx(w.Provider,{value:N,children:y})};h.displayName=a+"Provider";function f(m,g){var w;const y=((w=g==null?void 0:g[t])==null?void 0:w[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 i=()=>{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 i.scopeName=t,[r,tI(i,...e)]}function tI(...t){const e=t[0];if(t.length===1)return e;const n=()=>{const r=t.map(i=>({useScope:i(),scopeName:i.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 Kn=globalThis!=null&&globalThis.document?b.useLayoutEffect:()=>{},nI=of[" useId ".trim().toString()]||(()=>{}),rI=0;function ua(t){const[e,n]=b.useState(nI());return Kn(()=>{n(r=>r??String(rI++))},[t]),e?`radix-${e}`:""}var sI=of[" useInsertionEffect ".trim().toString()]||Kn;function fo({prop:t,defaultProp:e,onChange:n=()=>{},caller:r}){const[i,a,o]=iI({defaultProp:e,onChange:n}),c=t!==void 0,u=c?t:i;{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=aI(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 iI({defaultProp:t,onChange:e}){const[n,r]=b.useState(t),i=b.useRef(n),a=b.useRef(e);return sI(()=>{a.current=e},[e]),b.useEffect(()=>{var o;i.current!==n&&((o=a.current)==null||o.call(a,n),i.current=n)},[n,i]),[n,r,a]}function aI(t){return typeof t=="function"}function Jc(t){const e=oI(t),n=b.forwardRef((r,i)=>{const{children:a,...o}=r,c=b.Children.toArray(a),u=c.find(cI);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 s.jsx(e,{...o,ref:i,children:b.isValidElement(h)?b.cloneElement(h,void 0,f):null})}return s.jsx(e,{...o,ref:i,children:a})});return n.displayName=`${t}.Slot`,n}function oI(t){const e=b.forwardRef((n,r)=>{const{children:i,...a}=n;if(b.isValidElement(i)){const o=uI(i),c=dI(a,i.props);return i.type!==b.Fragment&&(c.ref=r?Dx(r,o):o),b.cloneElement(i,c)}return b.Children.count(i)>1?b.Children.only(null):null});return e.displayName=`${t}.SlotClone`,e}var lI=Symbol("radix.slottable");function cI(t){return b.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===lI}function dI(t,e){const n={...e};for(const r in e){const i=t[r],a=e[r];/^on[A-Z]/.test(r)?i&&a?n[r]=(...c)=>{const u=a(...c);return i(...c),u}:i&&(n[r]=i):r==="style"?n[r]={...i,...a}:r==="className"&&(n[r]=[i,a].filter(Boolean).join(" "))}return{...t,...n}}function uI(t){var r,i;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=(i=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:i.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}var hI=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],ct=hI.reduce((t,e)=>{const n=Jc(`Primitive.${e}`),r=b.forwardRef((i,a)=>{const{asChild:o,...c}=i,u=o?n:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),s.jsx(u,{...c,ref:a})});return r.displayName=`Primitive.${e}`,{...t,[e]:r}},{});function fI(t,e){t&&dd.flushSync(()=>t.dispatchEvent(e))}function ga(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 pI(t,e=globalThis==null?void 0:globalThis.document){const n=ga(t);b.useEffect(()=>{const r=i=>{i.key==="Escape"&&n(i)};return e.addEventListener("keydown",r,{capture:!0}),()=>e.removeEventListener("keydown",r,{capture:!0})},[n,e])}var mI="DismissableLayer",Mg="dismissableLayer.update",gI="dismissableLayer.pointerDownOutside",xI="dismissableLayer.focusOutside",Kb,fj=b.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),_x=b.forwardRef((t,e)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:i,onFocusOutside:a,onInteractOutside:o,onDismiss:c,...u}=t,h=b.useContext(fj),[f,m]=b.useState(null),g=(f==null?void 0:f.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,y]=b.useState({}),v=bt(e,I=>m(I)),w=Array.from(h.layers),[N]=[...h.layersWithOutsidePointerEventsDisabled].slice(-1),k=w.indexOf(N),E=f?w.indexOf(f):-1,C=h.layersWithOutsidePointerEventsDisabled.size>0,T=E>=k,O=bI(I=>{const R=I.target,P=[...h.branches].some(L=>L.contains(R));!T||P||(i==null||i(I),o==null||o(I),I.defaultPrevented||c==null||c())},g),F=NI(I=>{const R=I.target;[...h.branches].some(L=>L.contains(R))||(a==null||a(I),o==null||o(I),I.defaultPrevented||c==null||c())},g);return pI(I=>{E===h.layers.size-1&&(r==null||r(I),!I.defaultPrevented&&c&&(I.preventDefault(),c()))},g),b.useEffect(()=>{if(f)return n&&(h.layersWithOutsidePointerEventsDisabled.size===0&&(Kb=g.body.style.pointerEvents,g.body.style.pointerEvents="none"),h.layersWithOutsidePointerEventsDisabled.add(f)),h.layers.add(f),qb(),()=>{n&&h.layersWithOutsidePointerEventsDisabled.size===1&&(g.body.style.pointerEvents=Kb)}},[f,g,n,h]),b.useEffect(()=>()=>{f&&(h.layers.delete(f),h.layersWithOutsidePointerEventsDisabled.delete(f),qb())},[f,h]),b.useEffect(()=>{const I=()=>y({});return document.addEventListener(Mg,I),()=>document.removeEventListener(Mg,I)},[]),s.jsx(ct.div,{...u,ref:v,style:{pointerEvents:C?T?"auto":"none":void 0,...t.style},onFocusCapture:it(t.onFocusCapture,F.onFocusCapture),onBlurCapture:it(t.onBlurCapture,F.onBlurCapture),onPointerDownCapture:it(t.onPointerDownCapture,O.onPointerDownCapture)})});_x.displayName=mI;var yI="DismissableLayerBranch",vI=b.forwardRef((t,e)=>{const n=b.useContext(fj),r=b.useRef(null),i=bt(e,r);return b.useEffect(()=>{const a=r.current;if(a)return n.branches.add(a),()=>{n.branches.delete(a)}},[n.branches]),s.jsx(ct.div,{...t,ref:i})});vI.displayName=yI;function bI(t,e=globalThis==null?void 0:globalThis.document){const n=ga(t),r=b.useRef(!1),i=b.useRef(()=>{});return b.useEffect(()=>{const a=c=>{if(c.target&&!r.current){let u=function(){pj(gI,n,h,{discrete:!0})};const h={originalEvent:c};c.pointerType==="touch"?(e.removeEventListener("click",i.current),i.current=u,e.addEventListener("click",i.current,{once:!0})):u()}else e.removeEventListener("click",i.current);r.current=!1},o=window.setTimeout(()=>{e.addEventListener("pointerdown",a)},0);return()=>{window.clearTimeout(o),e.removeEventListener("pointerdown",a),e.removeEventListener("click",i.current)}},[e,n]),{onPointerDownCapture:()=>r.current=!0}}function NI(t,e=globalThis==null?void 0:globalThis.document){const n=ga(t),r=b.useRef(!1);return b.useEffect(()=>{const i=a=>{a.target&&!r.current&&pj(xI,n,{originalEvent:a},{discrete:!1})};return e.addEventListener("focusin",i),()=>e.removeEventListener("focusin",i)},[e,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function qb(){const t=new CustomEvent(Mg);document.dispatchEvent(t)}function pj(t,e,n,{discrete:r}){const i=n.originalEvent.target,a=new CustomEvent(t,{bubbles:!1,cancelable:!0,detail:n});e&&i.addEventListener(t,e,{once:!0}),r?fI(i,a):i.dispatchEvent(a)}var Cm="focusScope.autoFocusOnMount",Em="focusScope.autoFocusOnUnmount",Gb={bubbles:!1,cancelable:!0},wI="FocusScope",zx=b.forwardRef((t,e)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:i,onUnmountAutoFocus:a,...o}=t,[c,u]=b.useState(null),h=ga(i),f=ga(a),m=b.useRef(null),g=bt(e,w=>u(w)),y=b.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;b.useEffect(()=>{if(r){let w=function(C){if(y.paused||!c)return;const T=C.target;c.contains(T)?m.current=T:Yi(m.current,{select:!0})},N=function(C){if(y.paused||!c)return;const T=C.relatedTarget;T!==null&&(c.contains(T)||Yi(m.current,{select:!0}))},k=function(C){if(document.activeElement===document.body)for(const O of C)O.removedNodes.length>0&&Yi(c)};document.addEventListener("focusin",w),document.addEventListener("focusout",N);const E=new MutationObserver(k);return c&&E.observe(c,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",w),document.removeEventListener("focusout",N),E.disconnect()}}},[r,c,y.paused]),b.useEffect(()=>{if(c){Yb.add(y);const w=document.activeElement;if(!c.contains(w)){const k=new CustomEvent(Cm,Gb);c.addEventListener(Cm,h),c.dispatchEvent(k),k.defaultPrevented||(jI(TI(mj(c)),{select:!0}),document.activeElement===w&&Yi(c))}return()=>{c.removeEventListener(Cm,h),setTimeout(()=>{const k=new CustomEvent(Em,Gb);c.addEventListener(Em,f),c.dispatchEvent(k),k.defaultPrevented||Yi(w??document.body,{select:!0}),c.removeEventListener(Em,f),Yb.remove(y)},0)}}},[c,h,f,y]);const v=b.useCallback(w=>{if(!n&&!r||y.paused)return;const N=w.key==="Tab"&&!w.altKey&&!w.ctrlKey&&!w.metaKey,k=document.activeElement;if(N&&k){const E=w.currentTarget,[C,T]=kI(E);C&&T?!w.shiftKey&&k===T?(w.preventDefault(),n&&Yi(C,{select:!0})):w.shiftKey&&k===C&&(w.preventDefault(),n&&Yi(T,{select:!0})):k===E&&w.preventDefault()}},[n,r,y.paused]);return s.jsx(ct.div,{tabIndex:-1,...o,ref:g,onKeyDown:v})});zx.displayName=wI;function jI(t,{select:e=!1}={}){const n=document.activeElement;for(const r of t)if(Yi(r,{select:e}),document.activeElement!==n)return}function kI(t){const e=mj(t),n=Jb(e,t),r=Jb(e.reverse(),t);return[n,r]}function mj(t){const e=[],n=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const i=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||i?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)e.push(n.currentNode);return e}function Jb(t,e){for(const n of t)if(!SI(n,{upTo:e}))return n}function SI(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 CI(t){return t instanceof HTMLInputElement&&"select"in t}function Yi(t,{select:e=!1}={}){if(t&&t.focus){const n=document.activeElement;t.focus({preventScroll:!0}),t!==n&&CI(t)&&e&&t.select()}}var Yb=EI();function EI(){let t=[];return{add(e){const n=t[0];e!==n&&(n==null||n.pause()),t=Qb(t,e),t.unshift(e)},remove(e){var n;t=Qb(t,e),(n=t[0])==null||n.resume()}}}function Qb(t,e){const n=[...t],r=n.indexOf(e);return r!==-1&&n.splice(r,1),n}function TI(t){return t.filter(e=>e.tagName!=="A")}var MI="Portal",$x=b.forwardRef((t,e)=>{var c;const{container:n,...r}=t,[i,a]=b.useState(!1);Kn(()=>a(!0),[]);const o=n||i&&((c=globalThis==null?void 0:globalThis.document)==null?void 0:c.body);return o?Tw.createPortal(s.jsx(ct.div,{...r,ref:e}),o):null});$x.displayName=MI;function AI(t,e){return b.useReducer((n,r)=>e[n][r]??n,t)}var ud=t=>{const{present:e,children:n}=t,r=II(e),i=typeof n=="function"?n({present:r.isPresent}):b.Children.only(n),a=bt(r.ref,RI(i));return typeof n=="function"||r.isPresent?b.cloneElement(i,{ref:a}):null};ud.displayName="Presence";function II(t){const[e,n]=b.useState(),r=b.useRef(null),i=b.useRef(t),a=b.useRef("none"),o=t?"mounted":"unmounted",[c,u]=AI(o,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return b.useEffect(()=>{const h=ku(r.current);a.current=c==="mounted"?h:"none"},[c]),Kn(()=>{const h=r.current,f=i.current;if(f!==t){const g=a.current,y=ku(h);t?u("MOUNT"):y==="none"||(h==null?void 0:h.display)==="none"?u("UNMOUNT"):u(f&&g!==y?"ANIMATION_OUT":"UNMOUNT"),i.current=t}},[t,u]),Kn(()=>{if(e){let h;const f=e.ownerDocument.defaultView??window,m=y=>{const w=ku(r.current).includes(CSS.escape(y.animationName));if(y.target===e&&w&&(u("ANIMATION_END"),!i.current)){const N=e.style.animationFillMode;e.style.animationFillMode="forwards",h=f.setTimeout(()=>{e.style.animationFillMode==="forwards"&&(e.style.animationFillMode=N)})}},g=y=>{y.target===e&&(a.current=ku(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 ku(t){return(t==null?void 0:t.animationName)||"none"}function RI(t){var r,i;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=(i=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:i.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}var Tm=0;function gj(){b.useEffect(()=>{const t=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",t[0]??Xb()),document.body.insertAdjacentElement("beforeend",t[1]??Xb()),Tm++,()=>{Tm===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(e=>e.remove()),Tm--}},[])}function Xb(){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 Os=function(){return Os=Object.assign||function(e){for(var n,r=1,i=arguments.length;r"u")return JI;var e=YI(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])}},XI=bj(),vl="data-scroll-locked",ZI=function(t,e,n,r){var i=t.left,a=t.top,o=t.right,c=t.gap;return n===void 0&&(n="margin"),` - .`.concat(OI,` { - overflow: hidden `).concat(r,`; - padding-right: `).concat(c,"px ").concat(r,`; - } - body[`).concat(vl,`] { - overflow: hidden `).concat(r,`; - overscroll-behavior: contain; - `).concat([e&&"position: relative ".concat(r,";"),n==="margin"&&` - padding-left: `.concat(i,`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(Gu,` { - right: `).concat(c,"px ").concat(r,`; - } - - .`).concat(Ju,` { - margin-right: `).concat(c,"px ").concat(r,`; - } - - .`).concat(Gu," .").concat(Gu,` { - right: 0 `).concat(r,`; - } - - .`).concat(Ju," .").concat(Ju,` { - margin-right: 0 `).concat(r,`; - } - - body[`).concat(vl,`] { - `).concat(DI,": ").concat(c,`px; - } -`)},e1=function(){var t=parseInt(document.body.getAttribute(vl)||"0",10);return isFinite(t)?t:0},eR=function(){b.useEffect(function(){return document.body.setAttribute(vl,(e1()+1).toString()),function(){var t=e1()-1;t<=0?document.body.removeAttribute(vl):document.body.setAttribute(vl,t.toString())}},[])},tR=function(t){var e=t.noRelative,n=t.noImportant,r=t.gapMode,i=r===void 0?"margin":r;eR();var a=b.useMemo(function(){return QI(i)},[i]);return b.createElement(XI,{styles:ZI(a,!e,i,n?"":"!important")})},Ag=!1;if(typeof window<"u")try{var Su=Object.defineProperty({},"passive",{get:function(){return Ag=!0,!0}});window.addEventListener("test",Su,Su),window.removeEventListener("test",Su,Su)}catch{Ag=!1}var rl=Ag?{passive:!1}:!1,nR=function(t){return t.tagName==="TEXTAREA"},Nj=function(t,e){if(!(t instanceof Element))return!1;var n=window.getComputedStyle(t);return n[e]!=="hidden"&&!(n.overflowY===n.overflowX&&!nR(t)&&n[e]==="visible")},rR=function(t){return Nj(t,"overflowY")},sR=function(t){return Nj(t,"overflowX")},t1=function(t,e){var n=e.ownerDocument,r=e;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var i=wj(t,r);if(i){var a=jj(t,r),o=a[1],c=a[2];if(o>c)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},iR=function(t){var e=t.scrollTop,n=t.scrollHeight,r=t.clientHeight;return[e,n,r]},aR=function(t){var e=t.scrollLeft,n=t.scrollWidth,r=t.clientWidth;return[e,n,r]},wj=function(t,e){return t==="v"?rR(e):sR(e)},jj=function(t,e){return t==="v"?iR(e):aR(e)},oR=function(t,e){return t==="h"&&e==="rtl"?-1:1},lR=function(t,e,n,r,i){var a=oR(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=jj(t,c),v=y[0],w=y[1],N=y[2],k=w-N-a*v;(v||k)&&wj(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]},n1=function(t){return[t.deltaX,t.deltaY]},r1=function(t){return t&&"current"in t?t.current:t},cR=function(t,e){return t[0]===e[0]&&t[1]===e[1]},dR=function(t){return` - .block-interactivity-`.concat(t,` {pointer-events: none;} - .allow-interactivity-`).concat(t,` {pointer-events: all;} -`)},uR=0,sl=[];function hR(t){var e=b.useRef([]),n=b.useRef([0,0]),r=b.useRef(),i=b.useState(uR++)[0],a=b.useState(bj)[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(i));var w=PI([t.lockRef.current],(t.shards||[]).map(r1),!0).filter(Boolean);return w.forEach(function(N){return N.classList.add("allow-interactivity-".concat(i))}),function(){document.body.classList.remove("block-interactivity-".concat(i)),w.forEach(function(N){return N.classList.remove("allow-interactivity-".concat(i))})}}},[t.inert,t.lockRef.current,t.shards]);var c=b.useCallback(function(w,N){if("touches"in w&&w.touches.length===2||w.type==="wheel"&&w.ctrlKey)return!o.current.allowPinchZoom;var k=Cu(w),E=n.current,C="deltaX"in w?w.deltaX:E[0]-k[0],T="deltaY"in w?w.deltaY:E[1]-k[1],O,F=w.target,I=Math.abs(C)>Math.abs(T)?"h":"v";if("touches"in w&&I==="h"&&F.type==="range")return!1;var R=window.getSelection(),P=R&&R.anchorNode,L=P?P===F||P.contains(F):!1;if(L)return!1;var ee=t1(I,F);if(!ee)return!0;if(ee?O=I:(O=I==="v"?"h":"v",ee=t1(I,F)),!ee)return!1;if(!r.current&&"changedTouches"in w&&(C||T)&&(r.current=O),!O)return!0;var te=r.current||O;return lR(te,N,w,te==="h"?C:T)},[]),u=b.useCallback(function(w){var N=w;if(!(!sl.length||sl[sl.length-1]!==a)){var k="deltaY"in N?n1(N):Cu(N),E=e.current.filter(function(O){return O.name===N.type&&(O.target===N.target||N.target===O.shadowParent)&&cR(O.delta,k)})[0];if(E&&E.should){N.cancelable&&N.preventDefault();return}if(!E){var C=(o.current.shards||[]).map(r1).filter(Boolean).filter(function(O){return O.contains(N.target)}),T=C.length>0?c(N,C[0]):!o.current.noIsolation;T&&N.cancelable&&N.preventDefault()}}},[]),h=b.useCallback(function(w,N,k,E){var C={name:w,delta:N,target:k,should:E,shadowParent:fR(k)};e.current.push(C),setTimeout(function(){e.current=e.current.filter(function(T){return T!==C})},1)},[]),f=b.useCallback(function(w){n.current=Cu(w),r.current=void 0},[]),m=b.useCallback(function(w){h(w.type,n1(w),w.target,c(w,t.lockRef.current))},[]),g=b.useCallback(function(w){h(w.type,Cu(w),w.target,c(w,t.lockRef.current))},[]);b.useEffect(function(){return sl.push(a),t.setCallbacks({onScrollCapture:m,onWheelCapture:m,onTouchMoveCapture:g}),document.addEventListener("wheel",u,rl),document.addEventListener("touchmove",u,rl),document.addEventListener("touchstart",f,rl),function(){sl=sl.filter(function(w){return w!==a}),document.removeEventListener("wheel",u,rl),document.removeEventListener("touchmove",u,rl),document.removeEventListener("touchstart",f,rl)}},[]);var y=t.removeScrollBar,v=t.inert;return b.createElement(b.Fragment,null,v?b.createElement(a,{styles:dR(i)}):null,y?b.createElement(tR,{noRelative:t.noRelative,gapMode:t.gapMode}):null)}function fR(t){for(var e=null;t!==null;)t instanceof ShadowRoot&&(e=t.host,t=t.host),t=t.parentNode;return e}const pR=VI(vj,hR);var Fx=b.forwardRef(function(t,e){return b.createElement(uf,Os({},t,{ref:e,sideCar:pR}))});Fx.classNames=uf.classNames;var mR=function(t){if(typeof document>"u")return null;var e=Array.isArray(t)?t[0]:t;return e.ownerDocument.body},il=new WeakMap,Eu=new WeakMap,Tu={},Rm=0,kj=function(t){return t&&(t.host||kj(t.parentNode))},gR=function(t,e){return e.map(function(n){if(t.contains(n))return n;var r=kj(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})},xR=function(t,e,n,r){var i=gR(e,Array.isArray(t)?t:[t]);Tu[n]||(Tu[n]=new WeakMap);var a=Tu[n],o=[],c=new Set,u=new Set(i),h=function(m){!m||c.has(m)||(c.add(m),h(m.parentNode))};i.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",w=(il.get(g)||0)+1,N=(a.get(g)||0)+1;il.set(g,w),a.set(g,N),o.push(g),w===1&&v&&Eu.set(g,!0),N===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(),Rm++,function(){o.forEach(function(m){var g=il.get(m)-1,y=a.get(m)-1;il.set(m,g),a.set(m,y),g||(Eu.has(m)||m.removeAttribute(r),Eu.delete(m)),y||m.removeAttribute(n)}),Rm--,Rm||(il=new WeakMap,il=new WeakMap,Eu=new WeakMap,Tu={})}},Sj=function(t,e,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(t)?t:[t]),i=mR(t);return i?(r.push.apply(r,Array.from(i.querySelectorAll("[aria-live], script"))),xR(r,i,n,"aria-hidden")):function(){return null}},hf="Dialog",[Cj]=ka(hf),[yR,ys]=Cj(hf),Ej=t=>{const{__scopeDialog:e,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!0}=t,c=b.useRef(null),u=b.useRef(null),[h,f]=fo({prop:r,defaultProp:i??!1,onChange:a,caller:hf});return s.jsx(yR,{scope:e,triggerRef:c,contentRef:u,contentId:ua(),titleId:ua(),descriptionId:ua(),open:h,onOpenChange:f,onOpenToggle:b.useCallback(()=>f(m=>!m),[f]),modal:o,children:n})};Ej.displayName=hf;var Tj="DialogTrigger",vR=b.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,i=ys(Tj,n),a=bt(e,i.triggerRef);return s.jsx(ct.button,{type:"button","aria-haspopup":"dialog","aria-expanded":i.open,"aria-controls":i.contentId,"data-state":Hx(i.open),...r,ref:a,onClick:it(t.onClick,i.onOpenToggle)})});vR.displayName=Tj;var Bx="DialogPortal",[bR,Mj]=Cj(Bx,{forceMount:void 0}),Aj=t=>{const{__scopeDialog:e,forceMount:n,children:r,container:i}=t,a=ys(Bx,e);return s.jsx(bR,{scope:e,forceMount:n,children:b.Children.map(r,o=>s.jsx(ud,{present:n||a.open,children:s.jsx($x,{asChild:!0,container:i,children:o})}))})};Aj.displayName=Bx;var dh="DialogOverlay",Ij=b.forwardRef((t,e)=>{const n=Mj(dh,t.__scopeDialog),{forceMount:r=n.forceMount,...i}=t,a=ys(dh,t.__scopeDialog);return a.modal?s.jsx(ud,{present:r||a.open,children:s.jsx(wR,{...i,ref:e})}):null});Ij.displayName=dh;var NR=Jc("DialogOverlay.RemoveScroll"),wR=b.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,i=ys(dh,n);return s.jsx(Fx,{as:NR,allowPinchZoom:!0,shards:[i.contentRef],children:s.jsx(ct.div,{"data-state":Hx(i.open),...r,ref:e,style:{pointerEvents:"auto",...r.style}})})}),po="DialogContent",Rj=b.forwardRef((t,e)=>{const n=Mj(po,t.__scopeDialog),{forceMount:r=n.forceMount,...i}=t,a=ys(po,t.__scopeDialog);return s.jsx(ud,{present:r||a.open,children:a.modal?s.jsx(jR,{...i,ref:e}):s.jsx(kR,{...i,ref:e})})});Rj.displayName=po;var jR=b.forwardRef((t,e)=>{const n=ys(po,t.__scopeDialog),r=b.useRef(null),i=bt(e,n.contentRef,r);return b.useEffect(()=>{const a=r.current;if(a)return Sj(a)},[]),s.jsx(Pj,{...t,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:it(t.onCloseAutoFocus,a=>{var o;a.preventDefault(),(o=n.triggerRef.current)==null||o.focus()}),onPointerDownOutside:it(t.onPointerDownOutside,a=>{const o=a.detail.originalEvent,c=o.button===0&&o.ctrlKey===!0;(o.button===2||c)&&a.preventDefault()}),onFocusOutside:it(t.onFocusOutside,a=>a.preventDefault())})}),kR=b.forwardRef((t,e)=>{const n=ys(po,t.__scopeDialog),r=b.useRef(!1),i=b.useRef(!1);return s.jsx(Pj,{...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,i.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"&&(i.current=!0));const o=a.target;((h=n.triggerRef.current)==null?void 0:h.contains(o))&&a.preventDefault(),a.detail.originalEvent.type==="focusin"&&i.current&&a.preventDefault()}})}),Pj=b.forwardRef((t,e)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,...o}=t,c=ys(po,n),u=b.useRef(null),h=bt(e,u);return gj(),s.jsxs(s.Fragment,{children:[s.jsx(zx,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:s.jsx(_x,{role:"dialog",id:c.contentId,"aria-describedby":c.descriptionId,"aria-labelledby":c.titleId,"data-state":Hx(c.open),...o,ref:h,onDismiss:()=>c.onOpenChange(!1)})}),s.jsxs(s.Fragment,{children:[s.jsx(SR,{titleId:c.titleId}),s.jsx(ER,{contentRef:u,descriptionId:c.descriptionId})]})]})}),Vx="DialogTitle",Oj=b.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,i=ys(Vx,n);return s.jsx(ct.h2,{id:i.titleId,...r,ref:e})});Oj.displayName=Vx;var Dj="DialogDescription",Lj=b.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,i=ys(Dj,n);return s.jsx(ct.p,{id:i.descriptionId,...r,ref:e})});Lj.displayName=Dj;var _j="DialogClose",zj=b.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,i=ys(_j,n);return s.jsx(ct.button,{type:"button",...r,ref:e,onClick:it(t.onClick,()=>i.onOpenChange(!1))})});zj.displayName=_j;function Hx(t){return t?"open":"closed"}var $j="DialogTitleWarning",[zV,Fj]=eI($j,{contentName:po,titleName:Vx,docsSlug:"dialog"}),SR=({titleId:t})=>{const e=Fj($j),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},CR="DialogDescriptionWarning",ER=({contentRef:t,descriptionId:e})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Fj(CR).contentName}}.`;return b.useEffect(()=>{var a;const i=(a=t.current)==null?void 0:a.getAttribute("aria-describedby");e&&i&&(document.getElementById(e)||console.warn(r))},[r,t,e]),null},TR=Ej,MR=Aj,AR=Ij,IR=Rj,RR=Oj,PR=Lj,OR=zj;function Kt(t){return s.jsx(TR,{"data-slot":"dialog",...t})}function DR(t){return s.jsx(MR,{...t})}const Bj=b.forwardRef(({className:t,...e},n)=>s.jsx(AR,{ref:n,className:Nt("fixed inset-0 z-50 bg-black/50",t),...e}));Bj.displayName="DialogOverlay";const Vt=b.forwardRef(({className:t,children:e,showCloseButton:n=!0,...r},i)=>s.jsxs(DR,{children:[s.jsx(Bj,{}),s.jsxs(IR,{ref:i,"aria-describedby":void 0,className:Nt("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",t),...r,children:[e,n&&s.jsxs(OR,{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:[s.jsx(or,{className:"h-4 w-4"}),s.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Vt.displayName="DialogContent";function qt({className:t,...e}){return s.jsx("div",{className:Nt("flex flex-col gap-2 text-center sm:text-left",t),...e})}function hn({className:t,...e}){return s.jsx("div",{className:Nt("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",t),...e})}function Gt(t){return s.jsx(RR,{className:"text-lg font-semibold leading-none",...t})}function Wx(t){return s.jsx(PR,{className:"text-sm text-muted-foreground",...t})}const LR=ej("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 He({className:t,variant:e,asChild:n=!1,...r}){const i=n?Qw:"span";return s.jsx(i,{className:Nt(LR({variant:e}),t),...r})}var _R=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],zR=_R.reduce((t,e)=>{const n=Yw(`Primitive.${e}`),r=b.forwardRef((i,a)=>{const{asChild:o,...c}=i,u=o?n:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),s.jsx(u,{...c,ref:a})});return r.displayName=`Primitive.${e}`,{...t,[e]:r}},{}),$R="Label",Vj=b.forwardRef((t,e)=>s.jsx(zR.label,{...t,ref:e,onMouseDown:n=>{var i;n.target.closest("button, input, select, textarea")||((i=t.onMouseDown)==null||i.call(t,n),!n.defaultPrevented&&n.detail>1&&n.preventDefault())}}));Vj.displayName=$R;var Hj=Vj;const Z=b.forwardRef(({className:t,...e},n)=>s.jsx(Hj,{ref:n,className:Nt("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",t),...e}));Z.displayName=Hj.displayName;function Ux(t){const e=t+"CollectionProvider",[n,r]=ka(e),[i,a]=n(e,{collectionRef:{current:null},itemMap:new Map}),o=w=>{const{scope:N,children:k}=w,E=ar.useRef(null),C=ar.useRef(new Map).current;return s.jsx(i,{scope:N,itemMap:C,collectionRef:E,children:k})};o.displayName=e;const c=t+"CollectionSlot",u=Jc(c),h=ar.forwardRef((w,N)=>{const{scope:k,children:E}=w,C=a(c,k),T=bt(N,C.collectionRef);return s.jsx(u,{ref:T,children:E})});h.displayName=c;const f=t+"CollectionItemSlot",m="data-radix-collection-item",g=Jc(f),y=ar.forwardRef((w,N)=>{const{scope:k,children:E,...C}=w,T=ar.useRef(null),O=bt(N,T),F=a(f,k);return ar.useEffect(()=>(F.itemMap.set(T,{ref:T,...C}),()=>void F.itemMap.delete(T))),s.jsx(g,{[m]:"",ref:O,children:E})});y.displayName=f;function v(w){const N=a(t+"CollectionConsumer",w);return ar.useCallback(()=>{const E=N.collectionRef.current;if(!E)return[];const C=Array.from(E.querySelectorAll(`[${m}]`));return Array.from(N.itemMap.values()).sort((F,I)=>C.indexOf(F.ref.current)-C.indexOf(I.ref.current))},[N.collectionRef,N.itemMap])}return[{Provider:o,Slot:h,ItemSlot:y},v,r]}var FR=b.createContext(void 0);function ff(t){const e=b.useContext(FR);return t||e||"ltr"}var Pm="rovingFocusGroup.onEntryFocus",BR={bubbles:!1,cancelable:!0},hd="RovingFocusGroup",[Ig,Wj,VR]=Ux(hd),[HR,Uj]=ka(hd,[VR]),[WR,UR]=HR(hd),Kj=b.forwardRef((t,e)=>s.jsx(Ig.Provider,{scope:t.__scopeRovingFocusGroup,children:s.jsx(Ig.Slot,{scope:t.__scopeRovingFocusGroup,children:s.jsx(KR,{...t,ref:e})})}));Kj.displayName=hd;var KR=b.forwardRef((t,e)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:i=!1,dir:a,currentTabStopId:o,defaultCurrentTabStopId:c,onCurrentTabStopIdChange:u,onEntryFocus:h,preventScrollOnEntryFocus:f=!1,...m}=t,g=b.useRef(null),y=bt(e,g),v=ff(a),[w,N]=fo({prop:o,defaultProp:c??null,onChange:u,caller:hd}),[k,E]=b.useState(!1),C=ga(h),T=Wj(n),O=b.useRef(!1),[F,I]=b.useState(0);return b.useEffect(()=>{const R=g.current;if(R)return R.addEventListener(Pm,C),()=>R.removeEventListener(Pm,C)},[C]),s.jsx(WR,{scope:n,orientation:r,dir:v,loop:i,currentTabStopId:w,onItemFocus:b.useCallback(R=>N(R),[N]),onItemShiftTab:b.useCallback(()=>E(!0),[]),onFocusableItemAdd:b.useCallback(()=>I(R=>R+1),[]),onFocusableItemRemove:b.useCallback(()=>I(R=>R-1),[]),children:s.jsx(ct.div,{tabIndex:k||F===0?-1:0,"data-orientation":r,...m,ref:y,style:{outline:"none",...t.style},onMouseDown:it(t.onMouseDown,()=>{O.current=!0}),onFocus:it(t.onFocus,R=>{const P=!O.current;if(R.target===R.currentTarget&&P&&!k){const L=new CustomEvent(Pm,BR);if(R.currentTarget.dispatchEvent(L),!L.defaultPrevented){const ee=T().filter($=>$.focusable),te=ee.find($=>$.active),Y=ee.find($=>$.id===w),D=[te,Y,...ee].filter(Boolean).map($=>$.ref.current);Jj(D,f)}}O.current=!1}),onBlur:it(t.onBlur,()=>E(!1))})})}),qj="RovingFocusGroupItem",Gj=b.forwardRef((t,e)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:a,children:o,...c}=t,u=ua(),h=a||u,f=UR(qj,n),m=f.currentTabStopId===h,g=Wj(n),{onFocusableItemAdd:y,onFocusableItemRemove:v,currentTabStopId:w}=f;return b.useEffect(()=>{if(r)return y(),()=>v()},[r,y,v]),s.jsx(Ig.ItemSlot,{scope:n,id:h,focusable:r,active:i,children:s.jsx(ct.span,{tabIndex:m?0:-1,"data-orientation":f.orientation,...c,ref:e,onMouseDown:it(t.onMouseDown,N=>{r?f.onItemFocus(h):N.preventDefault()}),onFocus:it(t.onFocus,()=>f.onItemFocus(h)),onKeyDown:it(t.onKeyDown,N=>{if(N.key==="Tab"&&N.shiftKey){f.onItemShiftTab();return}if(N.target!==N.currentTarget)return;const k=JR(N,f.orientation,f.dir);if(k!==void 0){if(N.metaKey||N.ctrlKey||N.altKey||N.shiftKey)return;N.preventDefault();let C=g().filter(T=>T.focusable).map(T=>T.ref.current);if(k==="last")C.reverse();else if(k==="prev"||k==="next"){k==="prev"&&C.reverse();const T=C.indexOf(N.currentTarget);C=f.loop?YR(C,T+1):C.slice(T+1)}setTimeout(()=>Jj(C))}}),children:typeof o=="function"?o({isCurrentTabStop:m,hasTabStop:w!=null}):o})})});Gj.displayName=qj;var qR={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function GR(t,e){return e!=="rtl"?t:t==="ArrowLeft"?"ArrowRight":t==="ArrowRight"?"ArrowLeft":t}function JR(t,e,n){const r=GR(t.key,n);if(!(e==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(e==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return qR[r]}function Jj(t,e=!1){const n=document.activeElement;for(const r of t)if(r===n||(r.focus({preventScroll:e}),document.activeElement!==n))return}function YR(t,e){return t.map((n,r)=>t[(e+r)%t.length])}var QR=Kj,XR=Gj,pf="Tabs",[ZR]=ka(pf,[Uj]),Yj=Uj(),[eP,Kx]=ZR(pf),Qj=b.forwardRef((t,e)=>{const{__scopeTabs:n,value:r,onValueChange:i,defaultValue:a,orientation:o="horizontal",dir:c,activationMode:u="automatic",...h}=t,f=ff(c),[m,g]=fo({prop:r,onChange:i,defaultProp:a??"",caller:pf});return s.jsx(eP,{scope:n,baseId:ua(),value:m,onValueChange:g,orientation:o,dir:f,activationMode:u,children:s.jsx(ct.div,{dir:f,"data-orientation":o,...h,ref:e})})});Qj.displayName=pf;var Xj="TabsList",Zj=b.forwardRef((t,e)=>{const{__scopeTabs:n,loop:r=!0,...i}=t,a=Kx(Xj,n),o=Yj(n);return s.jsx(QR,{asChild:!0,...o,orientation:a.orientation,dir:a.dir,loop:r,children:s.jsx(ct.div,{role:"tablist","aria-orientation":a.orientation,...i,ref:e})})});Zj.displayName=Xj;var ek="TabsTrigger",tk=b.forwardRef((t,e)=>{const{__scopeTabs:n,value:r,disabled:i=!1,...a}=t,o=Kx(ek,n),c=Yj(n),u=sk(o.baseId,r),h=ik(o.baseId,r),f=r===o.value;return s.jsx(XR,{asChild:!0,...c,focusable:!i,active:f,children:s.jsx(ct.button,{type:"button",role:"tab","aria-selected":f,"aria-controls":h,"data-state":f?"active":"inactive","data-disabled":i?"":void 0,disabled:i,id:u,...a,ref:e,onMouseDown:it(t.onMouseDown,m=>{!i&&m.button===0&&m.ctrlKey===!1?o.onValueChange(r):m.preventDefault()}),onKeyDown:it(t.onKeyDown,m=>{[" ","Enter"].includes(m.key)&&o.onValueChange(r)}),onFocus:it(t.onFocus,()=>{const m=o.activationMode!=="manual";!f&&!i&&m&&o.onValueChange(r)})})})});tk.displayName=ek;var nk="TabsContent",rk=b.forwardRef((t,e)=>{const{__scopeTabs:n,value:r,forceMount:i,children:a,...o}=t,c=Kx(nk,n),u=sk(c.baseId,r),h=ik(c.baseId,r),f=r===c.value,m=b.useRef(f);return b.useEffect(()=>{const g=requestAnimationFrame(()=>m.current=!1);return()=>cancelAnimationFrame(g)},[]),s.jsx(ud,{present:i||f,children:({present:g})=>s.jsx(ct.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})})});rk.displayName=nk;function sk(t,e){return`${t}-trigger-${e}`}function ik(t,e){return`${t}-content-${e}`}var tP=Qj,ak=Zj,ok=tk,lk=rk;const fd=tP,Ll=b.forwardRef(({className:t,...e},n)=>s.jsx(ak,{ref:n,className:Nt("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",t),...e}));Ll.displayName=ak.displayName;const Jt=b.forwardRef(({className:t,...e},n)=>s.jsx(ok,{ref:n,className:Nt("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}));Jt.displayName=ok.displayName;const Yt=b.forwardRef(({className:t,...e},n)=>s.jsx(lk,{ref:n,className:Nt("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",t),...e}));Yt.displayName=lk.displayName;function qx(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 Gx(t){const[e,n]=b.useState(void 0);return Kn(()=>{if(t){n({width:t.offsetWidth,height:t.offsetHeight});const r=new ResizeObserver(i=>{if(!Array.isArray(i)||!i.length)return;const a=i[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 mf="Switch",[nP]=ka(mf),[rP,sP]=nP(mf),ck=b.forwardRef((t,e)=>{const{__scopeSwitch:n,name:r,checked:i,defaultChecked:a,required:o,disabled:c,value:u="on",onCheckedChange:h,form:f,...m}=t,[g,y]=b.useState(null),v=bt(e,C=>y(C)),w=b.useRef(!1),N=g?f||!!g.closest("form"):!0,[k,E]=fo({prop:i,defaultProp:a??!1,onChange:h,caller:mf});return s.jsxs(rP,{scope:n,checked:k,disabled:c,children:[s.jsx(ct.button,{type:"button",role:"switch","aria-checked":k,"aria-required":o,"data-state":fk(k),"data-disabled":c?"":void 0,disabled:c,value:u,...m,ref:v,onClick:it(t.onClick,C=>{E(T=>!T),N&&(w.current=C.isPropagationStopped(),w.current||C.stopPropagation())})}),N&&s.jsx(hk,{control:g,bubbles:!w.current,name:r,value:u,checked:k,required:o,disabled:c,form:f,style:{transform:"translateX(-100%)"}})]})});ck.displayName=mf;var dk="SwitchThumb",uk=b.forwardRef((t,e)=>{const{__scopeSwitch:n,...r}=t,i=sP(dk,n);return s.jsx(ct.span,{"data-state":fk(i.checked),"data-disabled":i.disabled?"":void 0,...r,ref:e})});uk.displayName=dk;var iP="SwitchBubbleInput",hk=b.forwardRef(({__scopeSwitch:t,control:e,checked:n,bubbles:r=!0,...i},a)=>{const o=b.useRef(null),c=bt(o,a),u=qx(n),h=Gx(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]),s.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...i,tabIndex:-1,ref:c,style:{...i.style,...h,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});hk.displayName=iP;function fk(t){return t?"checked":"unchecked"}var pk=ck,aP=uk;const jt=b.forwardRef(({className:t,...e},n)=>s.jsx(pk,{className:Nt("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:s.jsx(aP,{className:Nt("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")})}));jt.displayName=pk.displayName;function Jx({open:t,onClose:e,userId:n,onUserUpdated:r}){var er;const[i,a]=b.useState(null),[o,c]=b.useState([]),[u,h]=b.useState([]),[f,m]=b.useState(!1),[g,y]=b.useState(!1),[v,w]=b.useState(!1),[N,k]=b.useState("info"),[E,C]=b.useState(""),[T,O]=b.useState(""),[F,I]=b.useState([]),[R,P]=b.useState(""),[L,ee]=b.useState(""),[te,Y]=b.useState(""),[U,D]=b.useState(!1),[$,le]=b.useState({isVip:!1,vipExpireDate:"",vipRole:"",vipName:"",vipProject:"",vipContact:"",vipBio:""}),[_,se]=b.useState([]),[J,z]=b.useState(!1),[W,ue]=b.useState(!1),[G,fe]=b.useState(null),[X,ce]=b.useState(null),[he,we]=b.useState(""),[V,be]=b.useState(""),[Me,st]=b.useState(""),[nt,dt]=b.useState(!1),[Ye,ht]=b.useState(null),[Tt,ft]=b.useState("");b.useEffect(()=>{t&&n&&(k("info"),fe(null),ce(null),ht(null),ft(""),ee(""),Y(""),Mt(),Le("/api/db/vip-roles").then(pe=>{pe!=null&&pe.success&&pe.data&&se(pe.data)}).catch(()=>{}))},[t,n]);async function Mt(){if(n){m(!0);try{const pe=await Le(`/api/db/users?id=${encodeURIComponent(n)}`);if(pe!=null&&pe.success&&pe.user){const ve=pe.user;a(ve),C(ve.phone||""),O(ve.nickname||""),we(ve.phone||""),be(ve.wechatId||""),st(ve.openId||"");try{I(typeof ve.tags=="string"?JSON.parse(ve.tags||"[]"):[])}catch{I([])}le({isVip:!!(ve.isVip??!1),vipExpireDate:ve.vipExpireDate?String(ve.vipExpireDate).slice(0,10):"",vipRole:String(ve.vipRole??""),vipName:String(ve.vipName??""),vipProject:String(ve.vipProject??""),vipContact:String(ve.vipContact??""),vipBio:String(ve.vipBio??"")})}try{const ve=await Le(`/api/user/track?userId=${encodeURIComponent(n)}&limit=50`);ve!=null&&ve.success&&ve.tracks&&c(ve.tracks)}catch{c([])}try{const ve=await Le(`/api/db/users/referrals?userId=${encodeURIComponent(n)}`);ve!=null&&ve.success&&ve.referrals&&h(ve.referrals)}catch{h([])}}catch(pe){console.error("Load user detail error:",pe)}finally{m(!1)}}}async function Nn(){if(!(i!=null&&i.phone)){oe.info("用户未绑定手机号,无法同步");return}y(!0);try{const pe=await xt("/api/ckb/sync",{action:"full_sync",phone:i.phone,userId:i.id});pe!=null&&pe.success?(oe.success("同步成功"),Mt()):oe.error("同步失败: "+(pe==null?void 0:pe.error))}catch(pe){console.error("Sync CKB error:",pe),oe.error("同步失败")}finally{y(!1)}}async function Zn(){if(i){w(!0);try{const pe={id:i.id,phone:E||void 0,nickname:T||void 0,tags:JSON.stringify(F)},ve=await St("/api/db/users",pe);ve!=null&&ve.success?(oe.success("保存成功"),Mt(),r==null||r()):oe.error("保存失败: "+(ve==null?void 0:ve.error))}catch(pe){console.error("Save user error:",pe),oe.error("保存失败")}finally{w(!1)}}}const Pr=()=>{R&&!F.includes(R)&&(I([...F,R]),P(""))},Or=pe=>I(F.filter(ve=>ve!==pe));async function bs(){if(i){if(!L){oe.error("请输入新密码");return}if(L!==te){oe.error("两次密码不一致");return}if(L.length<6){oe.error("密码至少 6 位");return}D(!0);try{const pe=await St("/api/db/users",{id:i.id,password:L});pe!=null&&pe.success?(oe.success("修改成功"),ee(""),Y("")):oe.error("修改失败: "+((pe==null?void 0:pe.error)||""))}catch{oe.error("修改失败")}finally{D(!1)}}}async function br(){if(i){if($.isVip&&!$.vipExpireDate.trim()){oe.error("开启 VIP 请填写有效到期日");return}z(!0);try{const pe={id:i.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},ve=await St("/api/db/users",pe);ve!=null&&ve.success?(oe.success("VIP 设置已保存"),Mt(),r==null||r()):oe.error("保存失败: "+((ve==null?void 0:ve.error)||""))}catch{oe.error("保存失败")}finally{z(!1)}}}async function Qr(){if(!he&&!Me&&!V){ce("请至少输入手机号、微信号或 OpenID 中的一项");return}ue(!0),ce(null),fe(null);try{const pe=new URLSearchParams;he&&pe.set("phone",he),Me&&pe.set("openId",Me),V&&pe.set("wechatId",V);const ve=await Le(`/api/admin/shensheshou/query?${pe}`);ve!=null&&ve.success&&ve.data?(fe(ve.data),i&&await Qt(ve.data)):ce((ve==null?void 0:ve.error)||"未查询到数据,该用户可能未在神射手收录")}catch(pe){console.error("SSS query error:",pe),ce("请求失败,请检查神射手接口配置")}finally{ue(!1)}}async function Qt(pe){if(i)try{await xt("/api/admin/shensheshou/enrich",{userId:i.id,phone:he||i.phone||"",openId:Me||i.openId||"",wechatId:V||i.wechatId||""}),Mt()}catch(ve){console.error("SSS enrich error:",ve)}}async function Fn(){if(i){dt(!0),ht(null);try{const pe={users:[{phone:i.phone||"",name:i.nickname||"",openId:i.openId||"",tags:F}]},ve=await xt("/api/admin/shensheshou/ingest",pe);ve!=null&&ve.success&&ve.data?ht(ve.data):ht({error:(ve==null?void 0:ve.error)||"推送失败"})}catch(pe){console.error("SSS ingest error:",pe),ht({error:"请求失败"})}finally{dt(!1)}}}const Xr=pe=>{const tr={view_chapter:Gr,purchase:Cg,match:$n,login:yl,register:yl,share:ps,bind_phone:dA,bind_wechat:ZM,fill_profile:qu,visit_page:pl}[pe]||wg;return s.jsx(tr,{className:"w-4 h-4"})};return t?s.jsx(Kt,{open:t,onOpenChange:()=>e(),children:s.jsxs(Vt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-4xl max-h-[90vh] overflow-hidden",children:[s.jsx(qt,{children:s.jsxs(Gt,{className:"text-white flex items-center gap-2",children:[s.jsx(yl,{className:"w-5 h-5 text-[#38bdac]"}),"用户详情",(i==null?void 0:i.phone)&&s.jsx(He,{className:"bg-green-500/20 text-green-400 border-0 ml-2",children:"已绑定手机"}),(i==null?void 0:i.isVip)&&s.jsx(He,{className:"bg-amber-500/20 text-amber-400 border-0",children:"VIP"})]})}),f?s.jsxs("div",{className:"flex items-center justify-center py-20",children:[s.jsx(Ke,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):i?s.jsxs("div",{className:"flex flex-col h-[75vh]",children:[s.jsxs("div",{className:"flex items-center gap-4 p-4 bg-[#0a1628] rounded-lg mb-3",children:[s.jsx("div",{className:"w-16 h-16 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-2xl text-[#38bdac] shrink-0",children:i.avatar?s.jsx("img",{src:i.avatar,className:"w-full h-full rounded-full object-cover",alt:""}):((er=i.nickname)==null?void 0:er.charAt(0))||"?"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.jsx("h3",{className:"text-lg font-bold text-white",children:i.nickname}),i.isAdmin&&s.jsx(He,{className:"bg-purple-500/20 text-purple-400 border-0",children:"管理员"}),i.hasFullBook&&s.jsx(He,{className:"bg-green-500/20 text-green-400 border-0",children:"全书已购"}),i.vipRole&&s.jsx(He,{className:"bg-amber-500/20 text-amber-400 border-0",children:i.vipRole})]}),s.jsxs("p",{className:"text-gray-400 text-sm mt-1",children:[i.phone?`📱 ${i.phone}`:"未绑定手机",i.wechatId&&` · 💬 ${i.wechatId}`,i.mbti&&` · ${i.mbti}`]}),s.jsxs("div",{className:"flex items-center gap-4 mt-1",children:[s.jsxs("p",{className:"text-gray-600 text-xs",children:["ID: ",i.id.slice(0,16),"…"]}),i.referralCode&&s.jsxs("p",{className:"text-xs",children:[s.jsx("span",{className:"text-gray-500",children:"推广码:"}),s.jsx("code",{className:"text-[#38bdac] bg-[#38bdac]/10 px-1.5 py-0.5 rounded",children:i.referralCode})]})]})]}),s.jsxs("div",{className:"text-right shrink-0",children:[s.jsxs("p",{className:"text-[#38bdac] font-bold text-lg",children:["¥",(i.earnings||0).toFixed(2)]}),s.jsx("p",{className:"text-gray-500 text-xs",children:"累计收益"})]})]}),s.jsxs(fd,{value:N,onValueChange:k,className:"flex-1 flex flex-col overflow-hidden",children:[s.jsxs(Ll,{className:"bg-[#0a1628] border border-gray-700/50 p-1 mb-3 flex-wrap h-auto gap-1",children:[s.jsx(Jt,{value:"info",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-xs",children:"基础信息"}),s.jsx(Jt,{value:"tags",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-xs",children:"标签体系"}),s.jsxs(Jt,{value:"journey",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-xs",children:[s.jsx(pl,{className:"w-3 h-3 mr-1"}),"用户旅程"]}),s.jsx(Jt,{value:"relations",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-xs",children:"关系链路"}),s.jsxs(Jt,{value:"shensheshou",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-xs",children:[s.jsx(ia,{className:"w-3 h-3 mr-1"}),"用户资料完善"]})]}),s.jsxs(Yt,{value:"info",className:"flex-1 overflow-auto space-y-4",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"手机号"}),s.jsx(ae,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"输入手机号",value:E,onChange:pe=>C(pe.target.value)})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"昵称"}),s.jsx(ae,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"输入昵称",value:T,onChange:pe=>O(pe.target.value)})]})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[i.openId&&s.jsxs("div",{className:"p-3 bg-[#0a1628] rounded-lg",children:[s.jsx("p",{className:"text-gray-500 text-xs mb-1",children:"微信 OpenID"}),s.jsx("p",{className:"text-gray-300 font-mono text-xs break-all",children:i.openId})]}),i.region&&s.jsxs("div",{className:"p-3 bg-[#0a1628] rounded-lg flex items-center gap-2",children:[s.jsx(Kw,{className:"w-4 h-4 text-gray-500"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-gray-500 text-xs",children:"地区"}),s.jsx("p",{className:"text-white",children:i.region})]})]}),i.industry&&s.jsxs("div",{className:"p-3 bg-[#0a1628] rounded-lg",children:[s.jsx("p",{className:"text-gray-500 text-xs mb-1",children:"行业"}),s.jsx("p",{className:"text-white",children:i.industry})]}),i.position&&s.jsxs("div",{className:"p-3 bg-[#0a1628] rounded-lg",children:[s.jsx("p",{className:"text-gray-500 text-xs mb-1",children:"职位"}),s.jsx("p",{className:"text-white",children:i.position})]})]}),s.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[s.jsxs("div",{className:"p-4 bg-[#0a1628] rounded-lg",children:[s.jsx("p",{className:"text-gray-400 text-sm",children:"推荐人数"}),s.jsx("p",{className:"text-2xl font-bold text-white",children:i.referralCount??0})]}),s.jsxs("div",{className:"p-4 bg-[#0a1628] rounded-lg",children:[s.jsx("p",{className:"text-gray-400 text-sm",children:"待提现"}),s.jsxs("p",{className:"text-2xl font-bold text-yellow-400",children:["¥",(i.pendingEarnings??0).toFixed(2)]})]}),s.jsxs("div",{className:"p-4 bg-[#0a1628] rounded-lg",children:[s.jsx("p",{className:"text-gray-400 text-sm",children:"创建时间"}),s.jsx("p",{className:"text-sm text-white",children:i.createdAt?new Date(i.createdAt).toLocaleDateString():"-"})]})]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[s.jsxs("div",{className:"p-4 bg-[#0a1628] rounded-lg border border-gray-700/50",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[s.jsx(LM,{className:"w-4 h-4 text-yellow-400"}),s.jsx("span",{className:"text-white font-medium",children:"修改密码"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ae,{type:"password",className:"bg-[#162840] border-gray-700 text-white",placeholder:"新密码(至少6位)",value:L,onChange:pe=>ee(pe.target.value)}),s.jsx(ae,{type:"password",className:"bg-[#162840] border-gray-700 text-white",placeholder:"确认密码",value:te,onChange:pe=>Y(pe.target.value)}),s.jsx(ne,{size:"sm",onClick:bs,disabled:U||!L||!te,className:"bg-yellow-500/20 hover:bg-yellow-500/30 text-yellow-400 border border-yellow-500/40",children:U?"保存中...":"确认修改"})]})]}),s.jsxs("div",{className:"p-4 bg-[#0a1628] rounded-lg border border-amber-500/20",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[s.jsx(xl,{className:"w-4 h-4 text-amber-400"}),s.jsx("span",{className:"text-white font-medium",children:"设成超级个体"})]}),s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx(Z,{className:"text-gray-400 text-sm",children:"VIP 会员"}),s.jsx(jt,{checked:$.isVip,onCheckedChange:pe=>le(ve=>({...ve,isVip:pe}))})]}),$.isVip&&s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-400 text-xs",children:"到期日"}),s.jsx(ae,{type:"date",className:"bg-[#162840] border-gray-700 text-white text-sm",value:$.vipExpireDate,onChange:pe=>le(ve=>({...ve,vipExpireDate:pe.target.value}))})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(Z,{className:"text-gray-400 text-xs",children:"角色"}),s.jsxs("select",{className:"w-full bg-[#162840] border border-gray-700 text-white rounded px-2 py-1.5 text-sm",value:$.vipRole,onChange:pe=>le(ve=>({...ve,vipRole:pe.target.value})),children:[s.jsx("option",{value:"",children:"请选择"}),_.map(pe=>s.jsx("option",{value:pe.name,children:pe.name},pe.id))]})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(Z,{className:"text-gray-400 text-xs",children:"展示名"}),s.jsx(ae,{className:"bg-[#162840] border-gray-700 text-white text-sm",placeholder:"创业老板排行展示名",value:$.vipName,onChange:pe=>le(ve=>({...ve,vipName:pe.target.value}))})]}),s.jsx(ne,{size:"sm",onClick:br,disabled:J,className:"bg-amber-500/20 hover:bg-amber-500/30 text-amber-400 border border-amber-500/40",children:J?"保存中...":"保存 VIP"})]})]})]}),i.isVip&&s.jsxs("div",{className:"p-4 bg-[#0a1628] rounded-lg border border-amber-500/20",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[s.jsx(xl,{className:"w-4 h-4 text-amber-400"}),s.jsx("span",{className:"text-white font-medium",children:"VIP 信息"}),s.jsx(He,{className:"bg-amber-500/20 text-amber-400 border-0 text-xs",children:i.vipRole||"VIP"})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[i.vipName&&s.jsxs("div",{children:[s.jsx("span",{className:"text-gray-500",children:"展示名:"}),s.jsx("span",{className:"text-white",children:i.vipName})]}),i.vipProject&&s.jsxs("div",{children:[s.jsx("span",{className:"text-gray-500",children:"项目:"}),s.jsx("span",{className:"text-white",children:i.vipProject})]}),i.vipContact&&s.jsxs("div",{children:[s.jsx("span",{className:"text-gray-500",children:"联系方式:"}),s.jsx("span",{className:"text-white",children:i.vipContact})]}),i.vipExpireDate&&s.jsxs("div",{children:[s.jsx("span",{className:"text-gray-500",children:"到期时间:"}),s.jsx("span",{className:"text-white",children:new Date(i.vipExpireDate).toLocaleDateString()})]})]}),i.vipBio&&s.jsx("p",{className:"text-gray-400 text-sm mt-2",children:i.vipBio})]}),s.jsxs("div",{className:"p-4 bg-[#0a1628] rounded-lg border border-purple-500/20",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[s.jsx(uo,{className:"w-4 h-4 text-purple-400"}),s.jsx("span",{className:"text-white font-medium",children:"微信归属"}),s.jsx("span",{className:"text-gray-500 text-xs",children:"该用户归属在哪个微信号下"})]}),s.jsxs("div",{className:"flex gap-2 items-center",children:[s.jsx(ae,{className:"bg-[#162840] border-gray-700 text-white flex-1",placeholder:"输入归属微信号(如 wxid_xxxx)",value:Tt,onChange:pe=>ft(pe.target.value)}),s.jsxs(ne,{size:"sm",onClick:async()=>{if(!(!Tt||!i))try{await St("/api/db/users",{id:i.id,wechatId:Tt}),oe.success("已保存微信归属"),Mt()}catch{oe.error("保存失败")}},className:"bg-purple-500/20 hover:bg-purple-500/30 text-purple-400 border border-purple-500/30 shrink-0",children:[s.jsx(cn,{className:"w-4 h-4 mr-1"})," 保存"]})]}),i.wechatId&&s.jsxs("p",{className:"text-gray-500 text-xs mt-2",children:["当前归属:",s.jsx("span",{className:"text-purple-400",children:i.wechatId})]})]}),s.jsxs("div",{className:"p-4 bg-[#0a1628] rounded-lg",children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ps,{className:"w-4 h-4 text-[#38bdac]"}),s.jsx("span",{className:"text-white font-medium",children:"存客宝同步"})]}),s.jsx(ne,{size:"sm",onClick:Nn,disabled:g||!i.phone,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:g?s.jsxs(s.Fragment,{children:[s.jsx(Ke,{className:"w-4 h-4 mr-1 animate-spin"})," 同步中..."]}):s.jsxs(s.Fragment,{children:[s.jsx(Ke,{className:"w-4 h-4 mr-1"})," 同步数据"]})})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[s.jsxs("div",{children:[s.jsx("span",{className:"text-gray-500",children:"同步状态:"}),i.ckbSyncedAt?s.jsx(He,{className:"bg-green-500/20 text-green-400 border-0 ml-1",children:"已同步"}):s.jsx(He,{className:"bg-gray-500/20 text-gray-400 border-0 ml-1",children:"未同步"})]}),s.jsxs("div",{children:[s.jsx("span",{className:"text-gray-500",children:"最后同步:"}),s.jsx("span",{className:"text-gray-300 ml-1",children:i.ckbSyncedAt?new Date(i.ckbSyncedAt).toLocaleString():"-"})]})]})]})]}),s.jsxs(Yt,{value:"tags",className:"flex-1 overflow-auto space-y-4",children:[s.jsxs("div",{className:"p-4 bg-[#0a1628] rounded-lg",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[s.jsx(qu,{className:"w-4 h-4 text-[#38bdac]"}),s.jsx("span",{className:"text-white font-medium",children:"用户标签"}),s.jsx("span",{className:"text-gray-500 text-xs",children:"基于《一场 Soul 的创业实验》维度打标"})]}),s.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:[s.jsx(Ng,{className:"w-3.5 h-3.5 text-[#38bdac] shrink-0"}),"命中的标签自动高亮 · 系统根据行为轨迹和填写资料自动打标 · 手动点击补充或取消"]}),s.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(pe=>s.jsxs("div",{children:[s.jsx("p",{className:"text-gray-500 text-xs mb-1.5",children:pe.category}),s.jsx("div",{className:"flex flex-wrap gap-1.5",children:pe.tags.map(ve=>s.jsxs("button",{type:"button",onClick:()=>{F.includes(ve)?Or(ve):I([...F,ve])},className:`px-2 py-0.5 rounded text-xs border transition-all ${F.includes(ve)?"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(ve)?"✓ ":"",ve]},ve))})]},pe.category))}),s.jsxs("div",{className:"border-t border-gray-700/50 pt-3",children:[s.jsx("p",{className:"text-gray-500 text-xs mb-2",children:"已选标签"}),s.jsxs("div",{className:"flex flex-wrap gap-2 mb-3 min-h-[32px]",children:[F.map((pe,ve)=>s.jsxs(He,{className:"bg-[#38bdac]/20 text-[#38bdac] border-0 pr-1",children:[pe,s.jsx("button",{type:"button",onClick:()=>Or(pe),className:"ml-1 hover:text-red-400",children:s.jsx(or,{className:"w-3 h-3"})})]},ve)),F.length===0&&s.jsx("span",{className:"text-gray-600 text-sm",children:"暂未选择标签"})]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(ae,{className:"bg-[#162840] border-gray-700 text-white flex-1",placeholder:"自定义标签(回车添加)",value:R,onChange:pe=>P(pe.target.value),onKeyDown:pe=>pe.key==="Enter"&&Pr()}),s.jsx(ne,{onClick:Pr,className:"bg-[#38bdac] hover:bg-[#2da396]",children:"添加"})]})]})]}),i.ckbTags&&s.jsxs("div",{className:"p-4 bg-[#0a1628] rounded-lg",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[s.jsx(qu,{className:"w-4 h-4 text-purple-400"}),s.jsx("span",{className:"text-white font-medium",children:"存客宝标签"})]}),s.jsx("div",{className:"flex flex-wrap gap-2",children:(typeof i.ckbTags=="string"?i.ckbTags.split(","):[]).map((pe,ve)=>s.jsx(He,{className:"bg-purple-500/20 text-purple-400 border-0",children:pe.trim()},ve))})]})]}),s.jsxs(Yt,{value:"journey",className:"flex-1 overflow-auto",children:[s.jsxs("div",{className:"mb-3 p-3 bg-[#0a1628] rounded-lg flex items-center gap-2",children:[s.jsx(pl,{className:"w-4 h-4 text-[#38bdac]"}),s.jsxs("span",{className:"text-gray-400 text-sm",children:["记录用户从注册到付费的完整行动路径,共 ",o.length," 条记录"]})]}),s.jsx("div",{className:"space-y-2",children:o.length>0?o.map((pe,ve)=>s.jsxs("div",{className:"flex items-start gap-3 p-3 bg-[#0a1628] rounded-lg",children:[s.jsxs("div",{className:"flex flex-col items-center",children:[s.jsx("div",{className:"w-8 h-8 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-[#38bdac]",children:Xr(pe.action)}),ve0?u.map((pe,ve)=>{var Hs;const tr=pe;return s.jsxs("div",{className:"flex items-center justify-between p-2 bg-[#162840] rounded",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"w-6 h-6 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-xs text-[#38bdac]",children:((Hs=tr.nickname)==null?void 0:Hs.charAt(0))||"?"}),s.jsx("span",{className:"text-white text-sm",children:tr.nickname})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[tr.status==="vip"&&s.jsx(He,{className:"bg-green-500/20 text-green-400 border-0 text-xs",children:"已购"}),s.jsx("span",{className:"text-gray-500 text-xs",children:tr.createdAt?new Date(tr.createdAt).toLocaleDateString():""})]})]},tr.id||ve)}):s.jsx("p",{className:"text-gray-500 text-sm text-center py-4",children:"暂无推荐用户"})})]})}),s.jsxs(Yt,{value:"shensheshou",className:"flex-1 overflow-auto space-y-4",children:[s.jsxs("div",{className:"p-4 bg-[#0a1628] rounded-lg",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[s.jsx(ia,{className:"w-5 h-5 text-[#38bdac]"}),s.jsx("span",{className:"text-white font-medium",children:"用户资料完善"}),s.jsx("span",{className:"text-gray-500 text-xs",children:"通过多维度查询神射手数据,自动回填用户基础信息"})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-2 mb-3",children:[s.jsxs("div",{children:[s.jsx(Z,{className:"text-gray-500 text-xs mb-1 block",children:"手机号"}),s.jsx(ae,{className:"bg-[#162840] border-gray-700 text-white",placeholder:"11位手机号",value:he,onChange:pe=>we(pe.target.value)})]}),s.jsxs("div",{children:[s.jsx(Z,{className:"text-gray-500 text-xs mb-1 block",children:"微信号"}),s.jsx(ae,{className:"bg-[#162840] border-gray-700 text-white",placeholder:"微信 ID",value:V,onChange:pe=>be(pe.target.value)})]}),s.jsxs("div",{className:"col-span-2",children:[s.jsx(Z,{className:"text-gray-500 text-xs mb-1 block",children:"微信 OpenID"}),s.jsx(ae,{className:"bg-[#162840] border-gray-700 text-white",placeholder:"openid_xxxx(自动填入)",value:Me,onChange:pe=>st(pe.target.value)})]})]}),s.jsx(ne,{onClick:Qr,disabled:W,className:"w-full bg-[#38bdac] hover:bg-[#2da396] text-white",children:W?s.jsxs(s.Fragment,{children:[s.jsx(Ke,{className:"w-4 h-4 mr-1 animate-spin"})," 查询并自动回填中..."]}):s.jsxs(s.Fragment,{children:[s.jsx(da,{className:"w-4 h-4 mr-1"})," 查询并自动完善用户资料"]})}),s.jsx("p",{className:"text-gray-600 text-xs mt-2",children:"查询成功后,神射手返回的标签将自动同步到该用户"}),X&&s.jsx("div",{className:"mt-3 p-3 bg-red-500/10 border border-red-500/30 rounded-lg text-red-400 text-sm",children:X}),G&&s.jsxs("div",{className:"mt-3 space-y-3",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{className:"p-3 bg-[#162840] rounded-lg",children:[s.jsx("p",{className:"text-gray-500 text-xs mb-1",children:"神射手 RFM 分"}),s.jsx("p",{className:"text-2xl font-bold text-[#38bdac]",children:G.rfm_score??"-"})]}),s.jsxs("div",{className:"p-3 bg-[#162840] rounded-lg",children:[s.jsx("p",{className:"text-gray-500 text-xs mb-1",children:"用户等级"}),s.jsx("p",{className:"text-2xl font-bold text-white",children:G.user_level??"-"})]})]}),G.tags&&G.tags.length>0&&s.jsxs("div",{className:"p-3 bg-[#162840] rounded-lg",children:[s.jsx("p",{className:"text-gray-500 text-xs mb-2",children:"神射手标签"}),s.jsx("div",{className:"flex flex-wrap gap-2",children:G.tags.map((pe,ve)=>s.jsx(He,{className:"bg-[#38bdac]/10 text-[#38bdac] border border-[#38bdac]/20",children:pe},ve))})]}),G.last_active&&s.jsxs("div",{className:"text-sm text-gray-500",children:["最近活跃:",G.last_active]})]})]}),s.jsxs("div",{className:"p-4 bg-[#0a1628] rounded-lg",children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[s.jsx(ia,{className:"w-4 h-4 text-purple-400"}),s.jsx("span",{className:"text-white font-medium",children:"推送用户数据到神射手"})]}),s.jsx("p",{className:"text-gray-500 text-xs",children:"将本用户信息(手机号、昵称、标签等)同步至神射手,自动完善用户画像"})]}),s.jsx(ne,{onClick:Fn,disabled:nt||!i.phone,variant:"outline",className:"border-purple-500/40 text-purple-400 hover:bg-purple-500/10 bg-transparent shrink-0 ml-4",children:nt?s.jsxs(s.Fragment,{children:[s.jsx(Ke,{className:"w-4 h-4 mr-1 animate-spin"})," 推送中"]}):s.jsxs(s.Fragment,{children:[s.jsx(ia,{className:"w-4 h-4 mr-1"})," 推送"]})})]}),!i.phone&&s.jsx("p",{className:"text-yellow-500/70 text-xs",children:"⚠ 用户未绑定手机号,无法推送"}),Ye&&s.jsx("div",{className:"mt-3 p-3 bg-[#162840] rounded-lg text-sm",children:Ye.error?s.jsx("p",{className:"text-red-400",children:String(Ye.error)}):s.jsxs("div",{className:"space-y-1",children:[s.jsxs("p",{className:"text-green-400 flex items-center gap-1",children:[s.jsx(Ng,{className:"w-4 h-4"})," 推送成功"]}),Ye.enriched!==void 0&&s.jsxs("p",{className:"text-gray-400",children:["自动补全标签数:",String(Ye.new_tags_added??0)]})]})})]})]})]}),s.jsxs("div",{className:"flex justify-end gap-2 pt-3 border-t border-gray-700 mt-3",children:[s.jsxs(ne,{variant:"outline",onClick:e,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(or,{className:"w-4 h-4 mr-2"}),"关闭"]}),s.jsxs(ne,{onClick:Zn,disabled:v,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(cn,{className:"w-4 h-4 mr-2"}),v?"保存中...":"保存修改"]})]})]}):s.jsx("div",{className:"text-center py-12 text-gray-500",children:"用户不存在"})]})}):null}function oP(){const t=ja(),[e,n]=b.useState(!0),[r,i]=b.useState(!0),[a,o]=b.useState(!0),[c,u]=b.useState([]),[h,f]=b.useState([]),[m,g]=b.useState(0),[y,v]=b.useState(0),[w,N]=b.useState(0),[k,E]=b.useState(0),[C,T]=b.useState(null),[O,F]=b.useState(null),[I,R]=b.useState(!1),P=U=>{const D=U;if((D==null?void 0:D.status)===401)T("登录已过期,请重新登录");else{if((D==null?void 0:D.name)==="AbortError")return;T("加载失败,请检查网络或联系管理员")}};async function L(U){const D=U?{signal:U}:void 0;n(!0),T(null);try{const _=await Le("/api/admin/dashboard/stats",D);_!=null&&_.success&&(g(_.totalUsers??0),v(_.paidOrderCount??0),N(_.totalRevenue??0),E(_.conversionRate??0))}catch(_){if((_==null?void 0:_.name)!=="AbortError"){console.error("stats 失败,尝试 overview 降级",_);try{const se=await Le("/api/admin/dashboard/overview",D);se!=null&&se.success&&(g(se.totalUsers??0),v(se.paidOrderCount??0),N(se.totalRevenue??0),E(se.conversionRate??0))}catch(se){P(se)}}}finally{n(!1)}i(!0),o(!0);const $=async()=>{try{const _=await Le("/api/admin/dashboard/recent-orders",D);if(_!=null&&_.success&&_.recentOrders)f(_.recentOrders);else throw new Error("no data")}catch(_){if((_==null?void 0:_.name)!=="AbortError")try{const se=await Le("/api/admin/orders?page=1&pageSize=20&status=paid",D),z=((se==null?void 0:se.orders)??[]).filter(W=>["paid","completed","success"].includes(W.status||""));f(z.slice(0,5))}catch{f([])}}finally{i(!1)}},le=async()=>{try{const _=await Le("/api/admin/dashboard/new-users",D);if(_!=null&&_.success&&_.newUsers)u(_.newUsers);else throw new Error("no data")}catch(_){if((_==null?void 0:_.name)!=="AbortError")try{const se=await Le("/api/db/users?page=1&pageSize=10",D);u((se==null?void 0:se.users)??[])}catch{u([])}}finally{o(!1)}};await Promise.all([$(),le()])}b.useEffect(()=>{const U=new AbortController;L(U.signal);const D=setInterval(()=>L(),3e4);return()=>{U.abort(),clearInterval(D)}},[]);const ee=m,te=U=>{const D=U.productType||"",$=U.description||"";if($){if(D==="section"&&$.includes("章节")){if($.includes("-")){const le=$.split("-");if(le.length>=3)return{title:`第${le[1]}章 第${le[2]}节`,subtitle:"《一场Soul的创业实验》"}}return{title:$,subtitle:"章节购买"}}return D==="fullbook"||$.includes("全书")?{title:"《一场Soul的创业实验》",subtitle:"全书购买"}:D==="match"||$.includes("伙伴")?{title:"找伙伴匹配",subtitle:"功能服务"}:{title:$,subtitle:D==="section"?"单章":D==="fullbook"?"全书":"其他"}}return D==="section"?{title:`章节 ${U.productId||""}`,subtitle:"单章购买"}:D==="fullbook"?{title:"《一场Soul的创业实验》",subtitle:"全书购买"}:D==="match"?{title:"找伙伴匹配",subtitle:"功能服务"}:{title:"未知商品",subtitle:D||"其他"}},Y=[{title:"总用户数",value:e?null:ee,icon:$n,color:"text-blue-400",bg:"bg-blue-500/20",link:"/users"},{title:"总收入",value:e?null:`¥${(w??0).toFixed(2)}`,icon:Oc,color:"text-[#38bdac]",bg:"bg-[#38bdac]/20",link:"/orders"},{title:"订单数",value:e?null:y,icon:Cg,color:"text-purple-400",bg:"bg-purple-500/20",link:"/orders"},{title:"转化率",value:e?null:`${typeof k=="number"?k.toFixed(1):0}%`,icon:Gr,color:"text-orange-400",bg:"bg-orange-500/20",link:"/distribution"}];return s.jsxs("div",{className:"p-8 w-full",children:[s.jsx("h1",{className:"text-2xl font-bold mb-8 text-white",children:"数据概览"}),C&&s.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:[s.jsx("span",{children:C}),s.jsx("button",{type:"button",onClick:()=>L(),className:"text-amber-400 hover:text-amber-300 underline",children:"重试"})]}),s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6 mb-8",children:Y.map((U,D)=>s.jsxs(Ae,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl cursor-pointer hover:border-[#38bdac]/50 transition-colors group",onClick:()=>U.link&&t(U.link),children:[s.jsxs(et,{className:"flex flex-row items-center justify-between pb-2",children:[s.jsx(tt,{className:"text-sm font-medium text-gray-400",children:U.title}),s.jsx("div",{className:`p-2 rounded-lg ${U.bg}`,children:s.jsx(U.icon,{className:`w-4 h-4 ${U.color}`})})]}),s.jsx(Ie,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("div",{className:"text-2xl font-bold text-white min-h-[2rem] flex items-center",children:U.value!=null?U.value:s.jsxs("span",{className:"inline-flex items-center gap-2 text-gray-500",children:[s.jsx(Ke,{className:"w-4 h-4 animate-spin"}),"加载中"]})}),s.jsx(fl,{className:"w-5 h-5 text-gray-600 group-hover:text-[#38bdac] transition-colors"})]})})]},D))}),s.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8",children:[s.jsxs(Ae,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(et,{className:"flex flex-row items-center justify-between",children:[s.jsx(tt,{className:"text-white",children:"最近订单"}),s.jsxs("button",{type:"button",onClick:()=>L(),disabled:r||a,className:"text-xs text-gray-400 hover:text-[#38bdac] flex items-center gap-1 disabled:opacity-50",title:"刷新",children:[r||a?s.jsx(Ke,{className:"w-3.5 h-3.5 animate-spin"}):s.jsx(Ke,{className:"w-3.5 h-3.5"}),"刷新(每 30 秒自动更新)"]})]}),s.jsx(Ie,{children:s.jsx("div",{className:"space-y-3",children:r&&h.length===0?s.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-gray-500",children:[s.jsx(Ke,{className:"w-8 h-8 animate-spin mb-2"}),s.jsx("span",{className:"text-sm",children:"加载中..."})]}):s.jsxs(s.Fragment,{children:[h.slice(0,5).map(U=>{var se;const D=U.referrerId?c.find(J=>J.id===U.referrerId):void 0,$=U.referralCode||(D==null?void 0:D.referralCode)||(D==null?void 0:D.nickname)||(U.referrerId?String(U.referrerId).slice(0,8):""),le=te(U),_=U.userNickname||((se=c.find(J=>J.id===U.userId))==null?void 0:se.nickname)||"匿名用户";return s.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:[s.jsxs("div",{className:"flex items-start gap-3 flex-1",children:[U.userAvatar?s.jsx("img",{src:U.userAvatar,alt:_,className:"w-9 h-9 rounded-full object-cover flex-shrink-0 mt-0.5",onError:J=>{J.currentTarget.style.display="none";const z=J.currentTarget.nextElementSibling;z&&z.classList.remove("hidden")}}):null,s.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 ${U.userAvatar?"hidden":""}`,children:_.charAt(0)}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[s.jsx("button",{type:"button",onClick:()=>{U.userId&&(F(U.userId),R(!0))},className:"text-sm text-[#38bdac] hover:text-[#2da396] hover:underline text-left",children:_}),s.jsx("span",{className:"text-gray-600",children:"·"}),s.jsx("span",{className:"text-sm font-medium text-white truncate",children:le.title})]}),s.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500",children:[le.subtitle&&le.subtitle!=="章节购买"&&s.jsx("span",{className:"px-1.5 py-0.5 bg-gray-700/50 rounded",children:le.subtitle}),s.jsx("span",{children:new Date(U.createdAt||0).toLocaleString("zh-CN",{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"})})]}),$&&s.jsxs("p",{className:"text-xs text-gray-600 mt-1",children:["推荐: ",$]})]})]}),s.jsxs("div",{className:"text-right ml-4 flex-shrink-0",children:[s.jsxs("p",{className:"text-sm font-bold text-[#38bdac]",children:["+¥",Number(U.amount).toFixed(2)]}),s.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:U.paymentMethod||"微信"})]})]},U.id)}),h.length===0&&!r&&s.jsxs("div",{className:"text-center py-12",children:[s.jsx(Cg,{className:"w-12 h-12 text-gray-600 mx-auto mb-3"}),s.jsx("p",{className:"text-gray-500",children:"暂无订单数据"})]})]})})})]}),s.jsxs(Ae,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsx(et,{children:s.jsx(tt,{className:"text-white",children:"新注册用户"})}),s.jsx(Ie,{children:s.jsx("div",{className:"space-y-3",children:a&&c.length===0?s.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-gray-500",children:[s.jsx(Ke,{className:"w-8 h-8 animate-spin mb-2"}),s.jsx("span",{className:"text-sm",children:"加载中..."})]}):s.jsxs(s.Fragment,{children:[c.slice(0,5).map(U=>{var D;return s.jsxs("div",{className:"flex items-center justify-between p-4 bg-[#0a1628] rounded-lg border border-gray-700/30",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-10 h-10 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-sm font-medium text-[#38bdac]",children:((D=U.nickname)==null?void 0:D.charAt(0))||"?"}),s.jsxs("div",{children:[s.jsx("button",{type:"button",onClick:()=>{F(U.id),R(!0)},className:"text-sm font-medium text-[#38bdac] hover:text-[#2da396] hover:underline text-left",children:U.nickname||"匿名用户"}),s.jsx("p",{className:"text-xs text-gray-500",children:U.phone||"-"})]})]}),s.jsx("p",{className:"text-xs text-gray-400",children:U.createdAt?new Date(U.createdAt).toLocaleDateString():"-"})]},U.id)}),c.length===0&&!a&&s.jsx("p",{className:"text-gray-500 text-center py-8",children:"暂无用户数据"})]})})})]})]}),s.jsx(Jx,{open:I,onClose:()=>{R(!1),F(null)},userId:O,onUserUpdated:()=>L()})]})}const qn=b.forwardRef(({className:t,...e},n)=>s.jsx("div",{className:"relative w-full overflow-auto",children:s.jsx("table",{ref:n,className:Nt("w-full caption-bottom text-sm",t),...e})}));qn.displayName="Table";const Gn=b.forwardRef(({className:t,...e},n)=>s.jsx("thead",{ref:n,className:Nt("[&_tr]:border-b",t),...e}));Gn.displayName="TableHeader";const Jn=b.forwardRef(({className:t,...e},n)=>s.jsx("tbody",{ref:n,className:Nt("[&_tr:last-child]:border-0",t),...e}));Jn.displayName="TableBody";const rt=b.forwardRef(({className:t,...e},n)=>s.jsx("tr",{ref:n,className:Nt("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",t),...e}));rt.displayName="TableRow";const ke=b.forwardRef(({className:t,...e},n)=>s.jsx("th",{ref:n,className:Nt("h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0",t),...e}));ke.displayName="TableHead";const xe=b.forwardRef(({className:t,...e},n)=>s.jsx("td",{ref:n,className:Nt("p-4 align-middle [&:has([role=checkbox])]:pr-0",t),...e}));xe.displayName="TableCell";function Yx(t,e){const[n,r]=b.useState(t);return b.useEffect(()=>{const i=setTimeout(()=>r(t),e);return()=>clearTimeout(i)},[t,e]),n}function ms({page:t,totalPages:e,total:n,pageSize:r,onPageChange:i,onPageSizeChange:a,pageSizeOptions:o=[10,20,50,100]}){return e<=1&&!a?null:s.jsxs("div",{className:"flex items-center justify-between gap-4 py-4 px-5 border-t border-gray-700/50",children:[s.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-400",children:[s.jsxs("span",{children:["共 ",n," 条"]}),a&&s.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=>s.jsxs("option",{value:c,children:[c," 条/页"]},c))})]}),e>1&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{type:"button",onClick:()=>i(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:"首页"}),s.jsx("button",{type:"button",onClick:()=>i(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:"上一页"}),s.jsxs("span",{className:"px-3 py-1 text-gray-400 text-sm",children:[t," / ",e]}),s.jsx("button",{type:"button",onClick:()=>i(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:"下一页"}),s.jsx("button",{type:"button",onClick:()=>i(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 lP(){const[t,e]=b.useState([]),[n,r]=b.useState([]),[i,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,w]=b.useState(""),N=Yx(v,300),[k,E]=b.useState("all"),[C,T]=b.useState(!0),[O,F]=b.useState(null),[I,R]=b.useState(null),[P,L]=b.useState(""),[ee,te]=b.useState(!1);async function Y(){T(!0),F(null);try{const J=k==="all"?"":k==="completed"?"completed":k,z=new URLSearchParams({page:String(f),pageSize:String(g),...J&&{status:J},...N&&{search:N}}),[W,ue]=await Promise.all([Le(`/api/admin/orders?${z}`),Le("/api/db/users?page=1&pageSize=500")]);W!=null&&W.success&&(e(W.orders||[]),a(W.total??0),c(W.totalRevenue??0),h(W.todayRevenue??0)),ue!=null&&ue.success&&ue.users&&r(ue.users)}catch(J){console.error("加载订单失败",J),F("加载订单失败,请检查网络后重试")}finally{T(!1)}}b.useEffect(()=>{m(1)},[N,k]),b.useEffect(()=>{Y()},[f,g,N,k]);const U=J=>{var z;return J.userNickname||((z=n.find(W=>W.id===J.userId))==null?void 0:z.nickname)||"匿名用户"},D=J=>{var z;return((z=n.find(W=>W.id===J))==null?void 0:z.phone)||"-"},$=J=>{const z=J.productType||J.type||"",W=J.description||"";if(W){if(z==="section"&&W.includes("章节")){if(W.includes("-")){const ue=W.split("-");if(ue.length>=3)return{name:`第${ue[1]}章 第${ue[2]}节`,type:"《一场Soul的创业实验》"}}return{name:W,type:"章节购买"}}return z==="fullbook"||W.includes("全书")?{name:"《一场Soul的创业实验》",type:"全书购买"}:z==="vip"||W.includes("VIP")?{name:"VIP年度会员",type:"VIP"}:z==="match"||W.includes("伙伴")?{name:"找伙伴匹配",type:"功能服务"}:{name:W,type:"其他"}}return z==="section"?{name:`章节 ${J.productId||J.sectionId||""}`,type:"单章"}:z==="fullbook"?{name:"《一场Soul的创业实验》",type:"全书"}:z==="vip"?{name:"VIP年度会员",type:"VIP"}:z==="match"?{name:"找伙伴匹配",type:"功能"}:{name:"未知商品",type:z||"其他"}},le=Math.ceil(i/g)||1;async function _(){var J;if(!(!(I!=null&&I.orderSn)&&!(I!=null&&I.id))){te(!0),F(null);try{const z=await St("/api/admin/orders/refund",{orderSn:I.orderSn||I.id,reason:P||void 0});z!=null&&z.success?(R(null),L(""),Y()):F((z==null?void 0:z.error)||"退款失败")}catch(z){const W=z;F(((J=W==null?void 0:W.data)==null?void 0:J.error)||"退款失败,请检查网络后重试")}finally{te(!1)}}}function se(){if(t.length===0){oe.info("暂无数据可导出");return}const J=["订单号","用户","手机号","商品","金额","支付方式","状态","退款原因","分销佣金","下单时间"],z=t.map(X=>{const ce=$(X);return[X.orderSn||X.id||"",U(X),D(X.userId),ce.name,Number(X.amount||0).toFixed(2),X.paymentMethod==="wechat"?"微信支付":X.paymentMethod==="alipay"?"支付宝":X.paymentMethod||"微信支付",X.status==="refunded"?"已退款":X.status==="paid"||X.status==="completed"?"已完成":X.status==="pending"||X.status==="created"?"待支付":"已失败",X.status==="refunded"&&X.refundReason?X.refundReason:"-",X.referrerEarnings?Number(X.referrerEarnings).toFixed(2):"-",X.createdAt?new Date(X.createdAt).toLocaleString("zh-CN"):""].join(",")}),W="\uFEFF"+[J.join(","),...z].join(` -`),ue=new Blob([W],{type:"text/csv;charset=utf-8"}),G=URL.createObjectURL(ue),fe=document.createElement("a");fe.href=G,fe.download=`订单列表_${new Date().toISOString().slice(0,10)}.csv`,fe.click(),URL.revokeObjectURL(G)}return s.jsxs("div",{className:"p-8 w-full",children:[O&&s.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:[s.jsx("span",{children:O}),s.jsx("button",{type:"button",onClick:()=>F(null),className:"hover:text-red-300",children:"×"})]}),s.jsxs("div",{className:"flex justify-between items-center mb-8",children:[s.jsxs("div",{children:[s.jsx("h2",{className:"text-2xl font-bold text-white",children:"订单管理"}),s.jsxs("p",{className:"text-gray-400 mt-1",children:["共 ",t.length," 笔订单"]})]}),s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsxs(ne,{variant:"outline",onClick:Y,disabled:C,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Ke,{className:`w-4 h-4 mr-2 ${C?"animate-spin":""}`}),"刷新"]}),s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx("span",{className:"text-gray-400",children:"总收入:"}),s.jsxs("span",{className:"text-[#38bdac] font-bold",children:["¥",o.toFixed(2)]}),s.jsx("span",{className:"text-gray-600",children:"|"}),s.jsx("span",{className:"text-gray-400",children:"今日:"}),s.jsxs("span",{className:"text-[#FFD700] font-bold",children:["¥",u.toFixed(2)]})]})]})]}),s.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[s.jsxs("div",{className:"relative flex-1 max-w-md",children:[s.jsx(da,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-500"}),s.jsx(ae,{type:"text",placeholder:"搜索订单号/用户/章节...",className:"pl-10 bg-[#0f2137] border-gray-700 text-white placeholder:text-gray-500",value:v,onChange:J=>w(J.target.value)})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Ww,{className:"w-4 h-4 text-gray-400"}),s.jsxs("select",{value:k,onChange:J=>E(J.target.value),className:"bg-[#0f2137] border border-gray-700 text-white rounded-lg px-3 py-2 text-sm",children:[s.jsx("option",{value:"all",children:"全部状态"}),s.jsx("option",{value:"completed",children:"已完成"}),s.jsx("option",{value:"pending",children:"待支付"}),s.jsx("option",{value:"created",children:"已创建"}),s.jsx("option",{value:"failed",children:"已失败"}),s.jsx("option",{value:"refunded",children:"已退款"})]})]}),s.jsxs(ne,{variant:"outline",onClick:se,disabled:t.length===0,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(aM,{className:"w-4 h-4 mr-2"}),"导出 CSV"]})]}),s.jsx(Ae,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:s.jsx(Ie,{className:"p-0",children:C?s.jsxs("div",{className:"flex items-center justify-center py-12",children:[s.jsx(Ke,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):s.jsxs("div",{children:[s.jsxs(qn,{children:[s.jsx(Gn,{children:s.jsxs(rt,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[s.jsx(ke,{className:"text-gray-400",children:"订单号"}),s.jsx(ke,{className:"text-gray-400",children:"用户"}),s.jsx(ke,{className:"text-gray-400",children:"商品"}),s.jsx(ke,{className:"text-gray-400",children:"金额"}),s.jsx(ke,{className:"text-gray-400",children:"支付方式"}),s.jsx(ke,{className:"text-gray-400",children:"状态"}),s.jsx(ke,{className:"text-gray-400",children:"退款原因"}),s.jsx(ke,{className:"text-gray-400",children:"分销佣金"}),s.jsx(ke,{className:"text-gray-400",children:"下单时间"}),s.jsx(ke,{className:"text-gray-400",children:"操作"})]})}),s.jsxs(Jn,{children:[t.map(J=>{const z=$(J);return s.jsxs(rt,{className:"hover:bg-[#0a1628] border-gray-700/50",children:[s.jsxs(xe,{className:"font-mono text-xs text-gray-400",children:[(J.orderSn||J.id||"").slice(0,12),"..."]}),s.jsx(xe,{children:s.jsxs("div",{children:[s.jsx("p",{className:"text-white text-sm",children:U(J)}),s.jsx("p",{className:"text-gray-500 text-xs",children:D(J.userId)})]})}),s.jsx(xe,{children:s.jsxs("div",{children:[s.jsxs("p",{className:"text-white text-sm flex items-center gap-2",children:[z.name,(J.productType||J.type)==="vip"&&s.jsx(He,{className:"bg-amber-500/20 text-amber-400 hover:bg-amber-500/20 border-0 text-xs",children:"VIP"})]}),s.jsx("p",{className:"text-gray-500 text-xs",children:z.type})]})}),s.jsxs(xe,{className:"text-[#38bdac] font-bold",children:["¥",Number(J.amount||0).toFixed(2)]}),s.jsx(xe,{className:"text-gray-300",children:J.paymentMethod==="wechat"?"微信支付":J.paymentMethod==="alipay"?"支付宝":J.paymentMethod||"微信支付"}),s.jsx(xe,{children:J.status==="refunded"?s.jsx(He,{className:"bg-gray-500/20 text-gray-400 hover:bg-gray-500/20 border-0",children:"已退款"}):J.status==="paid"||J.status==="completed"?s.jsx(He,{className:"bg-green-500/20 text-green-400 hover:bg-green-500/20 border-0",children:"已完成"}):J.status==="pending"||J.status==="created"?s.jsx(He,{className:"bg-yellow-500/20 text-yellow-400 hover:bg-yellow-500/20 border-0",children:"待支付"}):s.jsx(He,{className:"bg-red-500/20 text-red-400 hover:bg-red-500/20 border-0",children:"已失败"})}),s.jsx(xe,{className:"text-gray-400 text-sm max-w-[120px] truncate",title:J.refundReason,children:J.status==="refunded"&&J.refundReason?J.refundReason:"-"}),s.jsx(xe,{className:"text-[#FFD700]",children:J.referrerEarnings?`¥${Number(J.referrerEarnings).toFixed(2)}`:"-"}),s.jsx(xe,{className:"text-gray-400 text-sm",children:new Date(J.createdAt).toLocaleString("zh-CN")}),s.jsx(xe,{children:(J.status==="paid"||J.status==="completed")&&s.jsxs(ne,{variant:"outline",size:"sm",className:"border-orange-500/50 text-orange-400 hover:bg-orange-500/20",onClick:()=>{R(J),L("")},children:[s.jsx(Gw,{className:"w-3 h-3 mr-1"}),"退款"]})})]},J.id)}),t.length===0&&s.jsx(rt,{children:s.jsx(xe,{colSpan:10,className:"text-center py-12 text-gray-500",children:"暂无订单数据"})})]})]}),s.jsx(ms,{page:f,totalPages:le,total:i,pageSize:g,onPageChange:m,onPageSizeChange:J=>{y(J),m(1)}})]})})}),s.jsx(Kt,{open:!!I,onOpenChange:J=>!J&&R(null),children:s.jsxs(Vt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",children:[s.jsx(qt,{children:s.jsx(Gt,{className:"text-white",children:"订单退款"})}),I&&s.jsxs("div",{className:"space-y-4",children:[s.jsxs("p",{className:"text-gray-400 text-sm",children:["订单号:",I.orderSn||I.id]}),s.jsxs("p",{className:"text-gray-400 text-sm",children:["退款金额:¥",Number(I.amount||0).toFixed(2)]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-sm text-gray-400 block mb-2",children:"退款原因(选填)"}),s.jsx("div",{className:"form-input",children:s.jsx(ae,{className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500",placeholder:"如:用户申请退款",value:P,onChange:J=>L(J.target.value)})})]}),s.jsx("p",{className:"text-orange-400/80 text-xs",children:"退款将原路退回至用户微信,且无法撤销,请确认后再操作。"})]}),s.jsxs(hn,{children:[s.jsx(ne,{variant:"outline",className:"border-gray-600 text-gray-300",onClick:()=>R(null),disabled:ee,children:"取消"}),s.jsx(ne,{className:"bg-orange-500 hover:bg-orange-600 text-white",onClick:_,disabled:ee,children:ee?"退款中...":"确认退款"})]})]})})]})}const _l=b.forwardRef(({className:t,...e},n)=>s.jsx("textarea",{className:Nt("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}));_l.displayName="Textarea";const Mu=[{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 cP(){var Js,Ai,ks,Oa,Da;const[t,e]=zw(),n=t.get("pool"),[r,i]=b.useState([]),[a,o]=b.useState(0),[c,u]=b.useState(1),[h,f]=b.useState(10),[m,g]=b.useState(""),y=Yx(m,300),v=n==="vip"?"vip":n==="complete"?"complete":"all",[w,N]=b.useState(v),[k,E]=b.useState(!0),[C,T]=b.useState(!1),[O,F]=b.useState(null),[I,R]=b.useState(!1),[P,L]=b.useState("desc");b.useEffect(()=>{n==="vip"?N("vip"):n==="complete"?N("complete"):n==="all"&&N("all")},[n]);const[ee,te]=b.useState(!1),[Y,U]=b.useState(null),[D,$]=b.useState(!1),[le,_]=b.useState(!1),[se,J]=b.useState({referrals:[],stats:{}}),[z,W]=b.useState(!1),[ue,G]=b.useState(null),[fe,X]=b.useState(!1),[ce,he]=b.useState(null),[we,V]=b.useState({phone:"",nickname:"",password:"",isAdmin:!1,hasFullBook:!1}),[be,Me]=b.useState([]),[st,nt]=b.useState(!1),[dt,Ye]=b.useState(!1),[ht,Tt]=b.useState(null),[ft,Mt]=b.useState({title:"",description:"",trigger:"",sort:0,enabled:!0}),[Nn,Zn]=b.useState([]),[Pr,Or]=b.useState(!1),[bs,br]=b.useState(null),[Qr,Qt]=b.useState(null),[Fn,Xr]=b.useState({}),[er,pe]=b.useState(!1);async function ve(H=!1){var Pe;E(!0),H&&T(!0),F(null);try{if(I){const Je=new URLSearchParams({search:y,limit:String(h*5)}),Xe=await Le(`/api/db/users/rfm?${Je}`);if(Xe!=null&&Xe.success){let wn=Xe.users||[];P==="asc"&&(wn=[...wn].reverse());const rr=(c-1)*h;i(wn.slice(rr,rr+h)),o(((Pe=Xe.users)==null?void 0:Pe.length)??0),wn.length===0&&(R(!1),F("暂无订单数据,RFM 排序需要用户有购买记录后才能生效"))}else R(!1),F((Xe==null?void 0:Xe.error)||"RFM 加载失败,已切回普通模式")}else{const Je=new URLSearchParams({page:String(c),pageSize:String(h),search:y,...w==="vip"&&{vip:"true"},...w==="complete"&&{pool:"complete"}}),Xe=await Le(`/api/db/users?${Je}`);Xe!=null&&Xe.success?(i(Xe.users||[]),o(Xe.total??0)):F((Xe==null?void 0:Xe.error)||"加载失败")}}catch(Je){console.error("Load users error:",Je),F("网络错误")}finally{E(!1),H&&T(!1)}}b.useEffect(()=>{u(1)},[y,w,I]),b.useEffect(()=>{ve()},[c,h,y,w,I,P]);const tr=Math.ceil(a/h)||1,Hs=()=>{I?P==="desc"?L("asc"):(R(!1),L("desc")):(R(!0),L("desc"))},ki=H=>({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"})[H||""]||"bg-gray-500/20 text-gray-400";async function Si(H){if(confirm("确定要删除这个用户吗?"))try{const Pe=await Ps(`/api/db/users?id=${encodeURIComponent(H)}`);Pe!=null&&Pe.success?ve():oe.error("删除失败: "+((Pe==null?void 0:Pe.error)||""))}catch{oe.error("删除失败")}}const Nr=H=>{U(H),V({phone:H.phone||"",nickname:H.nickname||"",password:"",isAdmin:!!(H.isAdmin??!1),hasFullBook:!!(H.hasFullBook??!1)}),te(!0)},Aa=()=>{U(null),V({phone:"",nickname:"",password:"",isAdmin:!1,hasFullBook:!1}),te(!0)};async function Dr(){if(!we.phone||!we.nickname){oe.error("请填写手机号和昵称");return}$(!0);try{if(Y){const H=await St("/api/db/users",{id:Y.id,nickname:we.nickname,isAdmin:we.isAdmin,hasFullBook:we.hasFullBook,...we.password&&{password:we.password}});if(!(H!=null&&H.success)){oe.error("更新失败: "+((H==null?void 0:H.error)||""));return}}else{const H=await xt("/api/db/users",{phone:we.phone,nickname:we.nickname,password:we.password,isAdmin:we.isAdmin});if(!(H!=null&&H.success)){oe.error("创建失败: "+((H==null?void 0:H.error)||""));return}}te(!1),ve()}catch{oe.error("保存失败")}finally{$(!1)}}async function Zr(H){G(H),_(!0),W(!0);try{const Pe=await Le(`/api/db/users/referrals?userId=${encodeURIComponent(H.id)}`);Pe!=null&&Pe.success?J({referrals:Pe.referrals||[],stats:Pe.stats||{}}):J({referrals:[],stats:{}})}catch{J({referrals:[],stats:{}})}finally{W(!1)}}const nr=b.useCallback(async()=>{nt(!0);try{const H=await Le("/api/db/user-rules");H!=null&&H.success&&Me(H.rules||[])}catch{}finally{nt(!1)}},[]);async function Ci(){if(!ft.title){oe.error("请填写规则标题");return}$(!0);try{if(ht){const H=await St("/api/db/user-rules",{id:ht.id,...ft});if(!(H!=null&&H.success)){oe.error("更新失败: "+((H==null?void 0:H.error)||""));return}}else{const H=await xt("/api/db/user-rules",ft);if(!(H!=null&&H.success)){oe.error("创建失败: "+((H==null?void 0:H.error)||""));return}}Ye(!1),nr()}catch{oe.error("保存失败")}finally{$(!1)}}async function Ia(H){if(confirm("确定删除?"))try{const Pe=await Ps(`/api/db/user-rules?id=${H}`);Pe!=null&&Pe.success&&nr()}catch{}}async function Ws(H){try{await St("/api/db/user-rules",{id:H.id,enabled:!H.enabled}),nr()}catch{}}const at=b.useCallback(async()=>{Or(!0);try{const H=await Le("/api/db/vip-members?limit=500");if(H!=null&&H.success&&H.data){const Pe=[...H.data].map((Je,Xe)=>({...Je,vipSort:typeof Je.vipSort=="number"?Je.vipSort:Xe+1}));Pe.sort((Je,Xe)=>(Je.vipSort??999999)-(Xe.vipSort??999999)),Zn(Pe)}else H&&H.error&&oe.error(H.error)}catch{oe.error("加载超级个体列表失败")}finally{Or(!1)}},[]),[An,es]=b.useState(!1),[wr,ts]=b.useState(null),[Xt,Lr]=b.useState(""),[Us,_r]=b.useState(!1),Ks=["创业者","资源整合者","技术达人","投资人","产品经理","流量操盘手"],gn=H=>{ts(H),Lr(H.vipRole||""),es(!0)},Ns=async H=>{const Pe=H.trim();if(wr){if(!Pe){oe.error("请选择或输入标签");return}_r(!0);try{const Je=await St("/api/db/users",{id:wr.id,vipRole:Pe});if(!(Je!=null&&Je.success)){oe.error((Je==null?void 0:Je.error)||"更新超级个体标签失败");return}oe.success("已更新超级个体标签"),es(!1),ts(null),await at()}catch{oe.error("更新超级个体标签失败")}finally{_r(!1)}}},[Hl,Ei]=b.useState(!1),[qs,dr]=b.useState(null),[Ra,Ti]=b.useState(""),[Gs,ws]=b.useState(!1),Mi=H=>{dr(H),Ti(H.vipSort!=null?String(H.vipSort):""),Ei(!0)},To=async()=>{if(!qs)return;const H=Number(Ra);if(!Number.isFinite(H)){oe.error("请输入有效的数字序号");return}ws(!0);try{const Pe=await St("/api/db/users",{id:qs.id,vipSort:H});if(!(Pe!=null&&Pe.success)){oe.error((Pe==null?void 0:Pe.error)||"更新排序序号失败");return}oe.success("已更新排序序号"),Ei(!1),dr(null),await at()}catch{oe.error("更新排序序号失败")}finally{ws(!1)}},js=(H,Pe)=>{H.dataTransfer.effectAllowed="move",H.dataTransfer.setData("text/plain",Pe),br(Pe)},Pa=(H,Pe)=>{H.preventDefault(),Qr!==Pe&&Qt(Pe)},Mo=()=>{br(null),Qt(null)},kt=async(H,Pe)=>{H.preventDefault();const Je=H.dataTransfer.getData("text/plain")||bs;if(br(null),Qt(null),!Je||Je===Pe)return;const Xe=Nn.find(Ft=>Ft.id===Je),wn=Nn.find(Ft=>Ft.id===Pe);if(!Xe||!wn)return;const rr=Xe.vipSort??Nn.findIndex(Ft=>Ft.id===Je)+1,Io=wn.vipSort??Nn.findIndex(Ft=>Ft.id===Pe)+1;Zn(Ft=>{const In=[...Ft],ns=In.findIndex(Ii=>Ii.id===Je),Ss=In.findIndex(Ii=>Ii.id===Pe);if(ns===-1||Ss===-1)return Ft;const Ys=[...In],[Wl,La]=[Ys[ns],Ys[Ss]];return Ys[ns]={...La,vipSort:rr},Ys[Ss]={...Wl,vipSort:Io},Ys});try{const[Ft,In]=await Promise.all([St("/api/db/users",{id:Je,vipSort:Io}),St("/api/db/users",{id:Pe,vipSort:rr})]);if(!(Ft!=null&&Ft.success)||!(In!=null&&In.success)){oe.error((Ft==null?void 0:Ft.error)||(In==null?void 0:In.error)||"更新排序失败"),await at();return}oe.success("已更新排序"),await at()}catch{oe.error("更新排序失败"),await at()}},Ao=b.useCallback(async()=>{pe(!0);try{const H=await Le("/api/db/users/journey-stats");H!=null&&H.success&&H.stats&&Xr(H.stats)}catch{}finally{pe(!1)}},[]);return s.jsxs("div",{className:"p-8 w-full",children:[O&&s.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:[s.jsx("span",{children:O}),s.jsx("button",{type:"button",onClick:()=>F(null),children:"×"})]}),s.jsx("div",{className:"flex justify-between items-center mb-6",children:s.jsxs("div",{children:[s.jsx("h2",{className:"text-2xl font-bold text-white",children:"用户管理"}),s.jsxs("p",{className:"text-gray-400 mt-1 text-sm",children:["共 ",a," 位注册用户",I&&" · RFM 排序中"]})]})}),s.jsxs(fd,{defaultValue:"users",className:"w-full",children:[s.jsxs(Ll,{className:"bg-[#0a1628] border border-gray-700/50 p-1 mb-6 flex-wrap h-auto gap-1",children:[s.jsxs(Jt,{value:"users",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] flex items-center gap-1.5",children:[s.jsx($n,{className:"w-4 h-4"})," 用户列表"]}),s.jsxs(Jt,{value:"journey",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] flex items-center gap-1.5",onClick:Ao,children:[s.jsx(pl,{className:"w-4 h-4"})," 用户旅程总览"]}),s.jsxs(Jt,{value:"rules",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] flex items-center gap-1.5",onClick:nr,children:[s.jsx(so,{className:"w-4 h-4"})," 规则配置"]}),s.jsxs(Jt,{value:"vip-roles",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] flex items-center gap-1.5",onClick:at,children:[s.jsx(xl,{className:"w-4 h-4"})," 超级个体列表"]})]}),s.jsxs(Yt,{value:"users",children:[s.jsxs("div",{className:"flex items-center gap-3 mb-4 justify-end flex-wrap",children:[s.jsxs(ne,{variant:"outline",onClick:()=>ve(!0),disabled:C,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Ke,{className:`w-4 h-4 mr-2 ${C?"animate-spin":""}`})," 刷新"]}),s.jsxs("select",{value:w,onChange:H=>{const Pe=H.target.value;N(Pe),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:I,children:[s.jsx("option",{value:"all",children:"全部用户"}),s.jsx("option",{value:"vip",children:"VIP会员(超级个体)"}),s.jsx("option",{value:"complete",children:"完善资料用户"})]}),s.jsxs("div",{className:"relative",children:[s.jsx(da,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-500"}),s.jsx(ae,{type:"text",placeholder:"搜索用户...",className:"pl-10 bg-[#0f2137] border-gray-700 text-white placeholder:text-gray-500 w-56",value:m,onChange:H=>g(H.target.value)})]}),s.jsxs(ne,{onClick:Aa,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(Eg,{className:"w-4 h-4 mr-2"})," 添加用户"]})]}),s.jsx(Ae,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:s.jsx(Ie,{className:"p-0",children:k?s.jsxs("div",{className:"flex items-center justify-center py-12",children:[s.jsx(Ke,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):s.jsxs("div",{children:[s.jsxs(qn,{children:[s.jsx(Gn,{children:s.jsxs(rt,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[s.jsx(ke,{className:"text-gray-400",children:"用户信息"}),s.jsx(ke,{className:"text-gray-400",children:"绑定信息"}),s.jsx(ke,{className:"text-gray-400",children:"购买状态"}),s.jsx(ke,{className:"text-gray-400",children:"分销收益"}),s.jsxs(ke,{className:"text-gray-400 cursor-pointer select-none",onClick:Hs,children:[s.jsxs("div",{className:"flex items-center gap-1 group",children:[s.jsx(Oc,{className:"w-3.5 h-3.5"}),s.jsx("span",{children:"RFM分值"}),I?P==="desc"?s.jsx(Gc,{className:"w-3.5 h-3.5 text-[#38bdac]"}):s.jsx(Fw,{className:"w-3.5 h-3.5 text-[#38bdac]"}):s.jsx(Nm,{className:"w-3.5 h-3.5 text-gray-600 group-hover:text-gray-400"})]}),I&&s.jsx("div",{className:"text-[10px] text-[#38bdac] font-normal mt-0.5",children:"点击切换方向/关闭"})]}),s.jsx(ke,{className:"text-gray-400",children:"注册时间"}),s.jsx(ke,{className:"text-right text-gray-400",children:"操作"})]})}),s.jsxs(Jn,{children:[r.map(H=>{var Pe,Je,Xe;return s.jsxs(rt,{className:"hover:bg-[#0a1628] border-gray-700/50",children:[s.jsx(xe,{children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-10 h-10 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-sm font-medium text-[#38bdac]",children:H.avatar?s.jsx("img",{src:H.avatar,className:"w-full h-full rounded-full object-cover",alt:""}):((Pe=H.nickname)==null?void 0:Pe.charAt(0))||"?"}),s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("button",{type:"button",onClick:()=>{he(H.id),X(!0)},className:"font-medium text-[#38bdac] hover:text-[#2da396] hover:underline text-left",children:H.nickname}),H.isAdmin&&s.jsx(He,{className:"bg-purple-500/20 text-purple-400 hover:bg-purple-500/20 border-0 text-xs",children:"管理员"}),H.openId&&!((Je=H.id)!=null&&Je.startsWith("user_"))&&s.jsx(He,{className:"bg-green-500/20 text-green-400 hover:bg-green-500/20 border-0 text-xs",children:"微信"})]}),s.jsx("p",{className:"text-xs text-gray-500 font-mono",children:H.openId?H.openId.slice(0,12)+"...":(Xe=H.id)==null?void 0:Xe.slice(0,12)})]})]})}),s.jsx(xe,{children:s.jsxs("div",{className:"space-y-1",children:[H.phone&&s.jsxs("div",{className:"flex items-center gap-1 text-xs",children:[s.jsx("span",{className:"text-gray-500",children:"📱"}),s.jsx("span",{className:"text-gray-300",children:H.phone})]}),H.wechatId&&s.jsxs("div",{className:"flex items-center gap-1 text-xs",children:[s.jsx("span",{className:"text-gray-500",children:"💬"}),s.jsx("span",{className:"text-gray-300",children:H.wechatId})]}),H.openId&&s.jsxs("div",{className:"flex items-center gap-1 text-xs",children:[s.jsx("span",{className:"text-gray-500",children:"🔗"}),s.jsxs("span",{className:"text-gray-500 truncate max-w-[100px]",title:H.openId,children:[H.openId.slice(0,12),"..."]})]}),!H.phone&&!H.wechatId&&!H.openId&&s.jsx("span",{className:"text-gray-600 text-xs",children:"未绑定"})]})}),s.jsx(xe,{children:H.hasFullBook?s.jsx(He,{className:"bg-amber-500/20 text-amber-400 hover:bg-amber-500/20 border-0",children:"VIP"}):s.jsx(He,{variant:"outline",className:"text-gray-500 border-gray-600",children:"未购买"})}),s.jsx(xe,{children:s.jsxs("div",{className:"space-y-1",children:[s.jsxs("div",{className:"text-white font-medium",children:["¥",parseFloat(String(H.earnings||0)).toFixed(2)]}),parseFloat(String(H.pendingEarnings||0))>0&&s.jsxs("div",{className:"text-xs text-yellow-400",children:["待提现: ¥",parseFloat(String(H.pendingEarnings||0)).toFixed(2)]}),s.jsxs("div",{className:"text-xs text-[#38bdac] cursor-pointer hover:underline flex items-center gap-1",onClick:()=>Zr(H),role:"button",tabIndex:0,onKeyDown:wn=>wn.key==="Enter"&&Zr(H),children:[s.jsx($n,{className:"w-3 h-3"})," 绑定",H.referralCount||0,"人"]})]})}),s.jsx(xe,{children:H.rfmScore!==void 0?s.jsx("div",{className:"flex flex-col gap-1",children:s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("span",{className:"text-white font-bold text-base",children:H.rfmScore}),s.jsx(He,{className:`border-0 text-xs ${ki(H.rfmLevel)}`,children:H.rfmLevel})]})}):s.jsxs("span",{className:"text-gray-600 text-sm",children:["— ",s.jsx("span",{className:"text-xs text-gray-700",children:"点列头排序"})]})}),s.jsx(xe,{className:"text-gray-400",children:H.createdAt?new Date(H.createdAt).toLocaleDateString():"-"}),s.jsx(xe,{className:"text-right",children:s.jsxs("div",{className:"flex items-center justify-end gap-1",children:[s.jsx(ne,{variant:"ghost",size:"sm",onClick:()=>{he(H.id),X(!0)},className:"text-gray-400 hover:text-blue-400 hover:bg-blue-400/10",title:"用户详情",children:s.jsx(jg,{className:"w-4 h-4"})}),s.jsx(ne,{variant:"ghost",size:"sm",onClick:()=>Nr(H),className:"text-gray-400 hover:text-[#38bdac] hover:bg-[#38bdac]/10",title:"编辑用户",children:s.jsx(Rt,{className:"w-4 h-4"})}),s.jsx(ne,{variant:"ghost",size:"sm",className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",onClick:()=>Si(H.id),title:"删除",children:s.jsx(Dn,{className:"w-4 h-4"})})]})})]},H.id)}),r.length===0&&s.jsx(rt,{children:s.jsx(xe,{colSpan:7,className:"text-center py-12 text-gray-500",children:"暂无用户数据"})})]})]}),s.jsx(ms,{page:c,totalPages:tr,total:a,pageSize:h,onPageChange:u,onPageSizeChange:H=>{f(H),u(1)}})]})})})]}),s.jsxs(Yt,{value:"journey",children:[s.jsxs("div",{className:"flex items-center justify-between mb-5",children:[s.jsx("p",{className:"text-gray-400 text-sm",children:"用户从注册到 VIP 的完整行动路径,点击各阶段查看用户动态"}),s.jsxs(ne,{variant:"outline",onClick:Ao,disabled:er,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Ke,{className:`w-4 h-4 mr-2 ${er?"animate-spin":""}`})," 刷新数据"]})]}),s.jsxs("div",{className:"relative mb-8",children:[s.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"}),s.jsx("div",{className:"grid grid-cols-4 gap-4 lg:grid-cols-8",children:Mu.map((H,Pe)=>s.jsxs("div",{className:"relative flex flex-col items-center",children:[s.jsxs("div",{className:`relative w-full p-3 rounded-xl border ${H.color} text-center cursor-default`,children:[s.jsx("div",{className:"text-2xl mb-1",children:H.icon}),s.jsx("div",{className:`text-xs font-medium ${H.color.split(" ").find(Je=>Je.startsWith("text-"))}`,children:H.label}),Fn[H.id]!==void 0&&s.jsxs("div",{className:"mt-1.5 text-xs text-gray-400",children:[s.jsx("span",{className:"font-bold text-white",children:Fn[H.id]})," 人"]}),s.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:Pe+1})]}),Pes.jsxs("div",{className:"flex items-start gap-3 p-2 bg-[#0a1628] rounded",children:[s.jsx("span",{className:"text-[#38bdac] font-mono text-xs shrink-0 mt-0.5",children:H.step}),s.jsxs("div",{children:[s.jsx("p",{className:"text-gray-300",children:H.action}),s.jsxs("p",{className:"text-gray-600 text-xs",children:["→ ",H.next]})]})]},H.step))})]}),s.jsxs("div",{className:"bg-[#0f2137] border border-gray-700/50 rounded-lg p-4",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[s.jsx(Gr,{className:"w-4 h-4 text-purple-400"}),s.jsx("span",{className:"text-white font-medium",children:"行为锚点统计"}),s.jsx("span",{className:"text-gray-500 text-xs ml-auto",children:"实时更新"})]}),er?s.jsx("div",{className:"flex items-center justify-center py-8",children:s.jsx(Ke,{className:"w-5 h-5 text-[#38bdac] animate-spin"})}):Object.keys(Fn).length>0?s.jsx("div",{className:"space-y-2",children:Mu.map(H=>{const Pe=Fn[H.id]||0,Je=Math.max(...Mu.map(wn=>Fn[wn.id]||0),1),Xe=Math.round(Pe/Je*100);return s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("span",{className:"text-gray-500 text-xs w-20 shrink-0",children:[H.icon," ",H.label]}),s.jsx("div",{className:"flex-1 h-2 bg-[#0a1628] rounded-full overflow-hidden",children:s.jsx("div",{className:"h-full bg-[#38bdac]/60 rounded-full transition-all",style:{width:`${Xe}%`}})}),s.jsx("span",{className:"text-gray-400 text-xs w-10 text-right",children:Pe})]},H.id)})}):s.jsx("div",{className:"text-center py-8",children:s.jsx("p",{className:"text-gray-500 text-sm",children:"点击「刷新数据」加载统计"})})]})]})]}),s.jsxs(Yt,{value:"rules",children:[s.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[s.jsx("p",{className:"text-gray-400 text-sm",children:"用户旅程引导规则,定义各行为节点的触发条件与引导内容"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(ne,{variant:"outline",onClick:nr,disabled:st,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Ke,{className:`w-4 h-4 mr-2 ${st?"animate-spin":""}`})," 刷新"]}),s.jsxs(ne,{onClick:()=>{Tt(null),Mt({title:"",description:"",trigger:"",sort:0,enabled:!0}),Ye(!0)},className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(rn,{className:"w-4 h-4 mr-2"})," 添加规则"]})]})]}),st?s.jsx("div",{className:"flex items-center justify-center py-12",children:s.jsx(Ke,{className:"w-6 h-6 text-[#38bdac] animate-spin"})}):be.length===0?s.jsxs("div",{className:"text-center py-16 bg-[#0f2137] rounded-lg border border-gray-700/50",children:[s.jsx(Gr,{className:"w-12 h-12 text-[#38bdac]/30 mx-auto mb-4"}),s.jsx("p",{className:"text-gray-400 mb-4",children:"暂无规则(重启服务将自动写入10条默认规则)"}),s.jsxs(ne,{onClick:nr,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(Ke,{className:"w-4 h-4 mr-2"})," 重新加载"]})]}):s.jsx("div",{className:"space-y-2",children:be.map(H=>s.jsx("div",{className:`p-4 rounded-lg border transition-all ${H.enabled?"bg-[#0f2137] border-gray-700/50":"bg-[#0a1628]/50 border-gray-700/30 opacity-55"}`,children:s.jsxs("div",{className:"flex items-start justify-between",children:[s.jsxs("div",{className:"flex-1",children:[s.jsxs("div",{className:"flex items-center gap-2 flex-wrap mb-1",children:[s.jsx(Rt,{className:"w-4 h-4 text-[#38bdac] shrink-0"}),s.jsx("span",{className:"text-white font-medium",children:H.title}),H.trigger&&s.jsxs(He,{className:"bg-[#38bdac]/10 text-[#38bdac] border border-[#38bdac]/30 text-xs",children:["触发:",H.trigger]}),s.jsx(He,{className:`text-xs border-0 ${H.enabled?"bg-green-500/20 text-green-400":"bg-gray-500/20 text-gray-400"}`,children:H.enabled?"启用":"禁用"})]}),H.description&&s.jsx("p",{className:"text-gray-400 text-sm ml-6",children:H.description})]}),s.jsxs("div",{className:"flex items-center gap-2 ml-4 shrink-0",children:[s.jsx(jt,{checked:H.enabled,onCheckedChange:()=>Ws(H)}),s.jsx(ne,{variant:"ghost",size:"sm",onClick:()=>{Tt(H),Mt({title:H.title,description:H.description,trigger:H.trigger,sort:H.sort,enabled:H.enabled}),Ye(!0)},className:"text-gray-400 hover:text-[#38bdac] hover:bg-[#38bdac]/10",children:s.jsx(Rt,{className:"w-4 h-4"})}),s.jsx(ne,{variant:"ghost",size:"sm",onClick:()=>Ia(H.id),className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:s.jsx(Dn,{className:"w-4 h-4"})})]})]})},H.id))})]}),s.jsxs(Yt,{value:"vip-roles",children:[s.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsx("p",{className:"text-gray-400 text-sm",children:"展示当前所有有效的超级个体(VIP 用户),用于检查会员信息与排序值。"}),s.jsx("p",{className:"text-xs text-[#38bdac]",children:"提示:按住任意一行即可拖拽排序,释放后将同步更新小程序展示顺序。"})]}),s.jsx("div",{className:"flex items-center gap-2",children:s.jsxs(ne,{variant:"outline",onClick:at,disabled:Pr,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Ke,{className:`w-4 h-4 mr-2 ${Pr?"animate-spin":""}`})," ","刷新"]})})]}),Pr?s.jsxs("div",{className:"flex items-center justify-center py-12",children:[s.jsx(Ke,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):Nn.length===0?s.jsxs("div",{className:"text-center py-16 bg-[#0f2137] rounded-lg border border-gray-700/50",children:[s.jsx(xl,{className:"w-12 h-12 text-amber-400/30 mx-auto mb-4"}),s.jsx("p",{className:"text-gray-400 mb-4",children:"当前没有有效的超级个体用户。"})]}):s.jsx(Ae,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:s.jsx(Ie,{className:"p-0",children:s.jsxs(qn,{children:[s.jsx(Gn,{children:s.jsxs(rt,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[s.jsx(ke,{className:"text-gray-400 w-16",children:"序号"}),s.jsx(ke,{className:"text-gray-400",children:"成员"}),s.jsx(ke,{className:"text-gray-400 min-w-48",children:"超级个体标签"}),s.jsx(ke,{className:"text-gray-400 w-24",children:"排序值"}),s.jsx(ke,{className:"text-gray-400 w-40 text-right",children:"操作"})]})}),s.jsx(Jn,{children:Nn.map((H,Pe)=>{var wn;const Je=bs===H.id,Xe=Qr===H.id;return s.jsxs(rt,{draggable:!0,onDragStart:rr=>js(rr,H.id),onDragOver:rr=>Pa(rr,H.id),onDrop:rr=>kt(rr,H.id),onDragEnd:Mo,className:`border-gray-700/50 cursor-grab active:cursor-grabbing select-none ${Je?"opacity-60":""} ${Xe?"bg-[#38bdac]/10":""}`,children:[s.jsx(xe,{className:"text-gray-300",children:Pe+1}),s.jsx(xe,{children:s.jsxs("div",{className:"flex items-center gap-3",children:[H.avatar?s.jsx("img",{src:H.avatar,className:"w-8 h-8 rounded-full object-cover border border-amber-400/60"}):s.jsx("div",{className:"w-8 h-8 rounded-full bg-amber-500/20 border border-amber-400/60 flex items-center justify-center text-amber-300 text-sm",children:((wn=H.name)==null?void 0:wn[0])||"创"}),s.jsx("div",{className:"min-w-0",children:s.jsx("div",{className:"text-white text-sm truncate",children:H.name})})]})}),s.jsx(xe,{className:"text-gray-300 whitespace-nowrap",children:H.vipRole||s.jsx("span",{className:"text-gray-500",children:"(未设置超级个体标签)"})}),s.jsx(xe,{className:"text-gray-300",children:H.vipSort??Pe+1}),s.jsx(xe,{className:"text-right text-xs text-gray-300",children:s.jsxs("div",{className:"inline-flex items-center gap-1.5",children:[s.jsx(ne,{variant:"ghost",size:"sm",className:"h-7 w-7 px-0 text-amber-300 hover:text-amber-200",onClick:()=>gn(H),title:"设置超级个体标签",children:s.jsx(qu,{className:"w-3.5 h-3.5"})}),s.jsx(ne,{variant:"ghost",size:"sm",className:"h-7 w-7 px-0 text-[#38bdac] hover:text-[#5fe0cd]",onClick:()=>{he(H.id),X(!0)},title:"编辑资料",children:s.jsx(Rt,{className:"w-3.5 h-3.5"})}),s.jsx(ne,{variant:"ghost",size:"sm",className:"h-7 w-7 px-0 text-sky-300 hover:text-sky-200",onClick:()=>Mi(H),title:"设置排序序号",children:s.jsx(Nm,{className:"w-3.5 h-3.5"})})]})})]},H.id)})})]})})})]})]}),s.jsx(Kt,{open:Hl,onOpenChange:H=>{Ei(H),H||dr(null)},children:s.jsxs(Vt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-sm",children:[s.jsx(qt,{children:s.jsxs(Gt,{className:"text-white flex items-center gap-2",children:[s.jsx(Nm,{className:"w-5 h-5 text-[#38bdac]"}),"设置排序 — ",qs==null?void 0:qs.name]})}),s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsx(Z,{className:"text-gray-300 text-sm",children:"排序序号(数字越小越靠前)"}),s.jsx(ae,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如:1",value:Ra,onChange:H=>Ti(H.target.value)})]}),s.jsxs(hn,{children:[s.jsxs(ne,{variant:"outline",onClick:()=>Ei(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(or,{className:"w-4 h-4 mr-2"}),"取消"]}),s.jsxs(ne,{onClick:To,disabled:Gs,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(cn,{className:"w-4 h-4 mr-2"}),Gs?"保存中...":"保存"]})]})]})}),s.jsx(Kt,{open:An,onOpenChange:H=>{es(H),H||ts(null)},children:s.jsxs(Vt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",children:[s.jsx(qt,{children:s.jsxs(Gt,{className:"text-white flex items-center gap-2",children:[s.jsx(xl,{className:"w-5 h-5 text-amber-400"}),"设置超级个体标签 — ",wr==null?void 0:wr.name]})}),s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsx(Z,{className:"text-gray-300 text-sm",children:"选择或输入标签"}),s.jsx("div",{className:"flex flex-wrap gap-2",children:Ks.map(H=>s.jsx(ne,{variant:Xt===H?"default":"outline",size:"sm",className:Xt===H?"bg-[#38bdac] hover:bg-[#2da396] text-white":"border-gray-600 text-gray-300 hover:bg-gray-700/50",onClick:()=>Lr(H),children:H},H))}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-400 text-xs",children:"或手动输入"}),s.jsx(ae,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如:创业者、资源整合者等",value:Xt,onChange:H=>Lr(H.target.value)})]})]}),s.jsxs(hn,{children:[s.jsxs(ne,{variant:"outline",onClick:()=>es(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(or,{className:"w-4 h-4 mr-2"}),"取消"]}),s.jsxs(ne,{onClick:()=>Ns(Xt),disabled:Us,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(cn,{className:"w-4 h-4 mr-2"}),Us?"保存中...":"保存"]})]})]})}),s.jsx(Kt,{open:ee,onOpenChange:te,children:s.jsxs(Vt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-lg",children:[s.jsx(qt,{children:s.jsxs(Gt,{className:"text-white flex items-center gap-2",children:[Y?s.jsx(Rt,{className:"w-5 h-5 text-[#38bdac]"}):s.jsx(Eg,{className:"w-5 h-5 text-[#38bdac]"}),Y?"编辑用户":"添加用户"]})}),s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"手机号"}),s.jsx(ae,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"请输入手机号",value:we.phone,onChange:H=>V({...we,phone:H.target.value}),disabled:!!Y})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"昵称"}),s.jsx(ae,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"请输入昵称",value:we.nickname,onChange:H=>V({...we,nickname:H.target.value})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:Y?"新密码 (留空则不修改)":"密码"}),s.jsx(ae,{type:"password",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:Y?"留空则不修改":"请输入密码",value:we.password,onChange:H=>V({...we,password:H.target.value})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx(Z,{className:"text-gray-300",children:"管理员权限"}),s.jsx(jt,{checked:we.isAdmin,onCheckedChange:H=>V({...we,isAdmin:H})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx(Z,{className:"text-gray-300",children:"已购全书"}),s.jsx(jt,{checked:we.hasFullBook,onCheckedChange:H=>V({...we,hasFullBook:H})})]})]}),s.jsxs(hn,{children:[s.jsxs(ne,{variant:"outline",onClick:()=>te(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(or,{className:"w-4 h-4 mr-2"}),"取消"]}),s.jsxs(ne,{onClick:Dr,disabled:D,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(cn,{className:"w-4 h-4 mr-2"}),D?"保存中...":"保存"]})]})]})}),s.jsx(Kt,{open:dt,onOpenChange:Ye,children:s.jsxs(Vt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-lg",children:[s.jsx(qt,{children:s.jsxs(Gt,{className:"text-white flex items-center gap-2",children:[s.jsx(Rt,{className:"w-5 h-5 text-[#38bdac]"}),ht?"编辑规则":"添加规则"]})}),s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"规则标题 *"}),s.jsx(ae,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"例:匹配后填写头像、付款1980需填写信息",value:ft.title,onChange:H=>Mt({...ft,title:H.target.value})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"规则描述"}),s.jsx(_l,{className:"bg-[#0a1628] border-gray-700 text-white min-h-[80px] resize-none",placeholder:"详细说明规则内容...",value:ft.description,onChange:H=>Mt({...ft,description:H.target.value})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"触发条件"}),s.jsx(ae,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"例:完成匹配、付款后、注册时",value:ft.trigger,onChange:H=>Mt({...ft,trigger:H.target.value})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("div",{children:s.jsx(Z,{className:"text-gray-300",children:"启用状态"})}),s.jsx(jt,{checked:ft.enabled,onCheckedChange:H=>Mt({...ft,enabled:H})})]})]}),s.jsxs(hn,{children:[s.jsxs(ne,{variant:"outline",onClick:()=>Ye(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(or,{className:"w-4 h-4 mr-2"}),"取消"]}),s.jsxs(ne,{onClick:Ci,disabled:D,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(cn,{className:"w-4 h-4 mr-2"}),D?"保存中...":"保存"]})]})]})}),s.jsx(Kt,{open:le,onOpenChange:_,children:s.jsxs(Vt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-2xl max-h-[80vh] overflow-auto",children:[s.jsx(qt,{children:s.jsxs(Gt,{className:"text-white flex items-center gap-2",children:[s.jsx($n,{className:"w-5 h-5 text-[#38bdac]"}),"绑定关系 - ",ue==null?void 0:ue.nickname]})}),s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsxs("div",{className:"grid grid-cols-4 gap-3",children:[s.jsxs("div",{className:"bg-[#0a1628] rounded-lg p-3 text-center",children:[s.jsx("div",{className:"text-2xl font-bold text-[#38bdac]",children:((Js=se.stats)==null?void 0:Js.total)||0}),s.jsx("div",{className:"text-xs text-gray-400",children:"绑定总数"})]}),s.jsxs("div",{className:"bg-[#0a1628] rounded-lg p-3 text-center",children:[s.jsx("div",{className:"text-2xl font-bold text-green-400",children:((Ai=se.stats)==null?void 0:Ai.purchased)||0}),s.jsx("div",{className:"text-xs text-gray-400",children:"已付费"})]}),s.jsxs("div",{className:"bg-[#0a1628] rounded-lg p-3 text-center",children:[s.jsxs("div",{className:"text-2xl font-bold text-yellow-400",children:["¥",(((ks=se.stats)==null?void 0:ks.earnings)||0).toFixed(2)]}),s.jsx("div",{className:"text-xs text-gray-400",children:"累计收益"})]}),s.jsxs("div",{className:"bg-[#0a1628] rounded-lg p-3 text-center",children:[s.jsxs("div",{className:"text-2xl font-bold text-orange-400",children:["¥",(((Oa=se.stats)==null?void 0:Oa.pendingEarnings)||0).toFixed(2)]}),s.jsx("div",{className:"text-xs text-gray-400",children:"待提现"})]})]}),z?s.jsxs("div",{className:"flex items-center justify-center py-8",children:[s.jsx(Ke,{className:"w-5 h-5 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):(((Da=se.referrals)==null?void 0:Da.length)??0)>0?s.jsx("div",{className:"space-y-2 max-h-[300px] overflow-y-auto",children:(se.referrals??[]).map((H,Pe)=>{var Xe;const Je=H;return s.jsxs("div",{className:"flex items-center justify-between bg-[#0a1628] rounded-lg p-3",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-8 h-8 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-sm text-[#38bdac]",children:((Xe=Je.nickname)==null?void 0:Xe.charAt(0))||"?"}),s.jsxs("div",{children:[s.jsx("div",{className:"text-white text-sm",children:Je.nickname}),s.jsx("div",{className:"text-xs text-gray-500",children:Je.phone||(Je.hasOpenId?"微信用户":"未绑定")})]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[Je.status==="vip"&&s.jsx(He,{className:"bg-green-500/20 text-green-400 border-0 text-xs",children:"全书已购"}),Je.status==="paid"&&s.jsxs(He,{className:"bg-blue-500/20 text-blue-400 border-0 text-xs",children:["已付费",Je.purchasedSections,"章"]}),Je.status==="free"&&s.jsx(He,{className:"bg-gray-500/20 text-gray-400 border-0 text-xs",children:"未付费"}),s.jsx("span",{className:"text-xs text-gray-500",children:Je.createdAt?new Date(Je.createdAt).toLocaleDateString():""})]})]},Je.id||Pe)})}):s.jsx("div",{className:"text-center py-8 text-gray-500",children:"暂无绑定用户"})]}),s.jsx(hn,{children:s.jsx(ne,{variant:"outline",onClick:()=>_(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"关闭"})})]})}),s.jsx(Jx,{open:fe,onClose:()=>X(!1),userId:ce,onUserUpdated:ve})]})}function uh(t,[e,n]){return Math.min(n,Math.max(e,t))}var mk=["PageUp","PageDown"],gk=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],xk={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},zl="Slider",[Rg,dP,uP]=Ux(zl),[yk]=ka(zl,[uP]),[hP,gf]=yk(zl),vk=b.forwardRef((t,e)=>{const{name:n,min:r=0,max:i=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,...w}=t,N=b.useRef(new Set),k=b.useRef(0),C=o==="horizontal"?fP:pP,[T=[],O]=fo({prop:f,defaultProp:h,onChange:ee=>{var Y;(Y=[...N.current][k.current])==null||Y.focus(),m(ee)}}),F=b.useRef(T);function I(ee){const te=vP(T,ee);L(ee,te)}function R(ee){L(ee,k.current)}function P(){const ee=F.current[k.current];T[k.current]!==ee&&g(T)}function L(ee,te,{commit:Y}={commit:!1}){const U=jP(a),D=kP(Math.round((ee-r)/a)*a+r,U),$=uh(D,[r,i]);O((le=[])=>{const _=xP(le,$,te);if(wP(_,u*a)){k.current=_.indexOf($);const se=String(_)!==String(le);return se&&Y&&g(_),se?_:le}else return le})}return s.jsx(hP,{scope:t.__scopeSlider,name:n,disabled:c,min:r,max:i,valueIndexToChangeRef:k,thumbs:N.current,values:T,orientation:o,form:v,children:s.jsx(Rg.Provider,{scope:t.__scopeSlider,children:s.jsx(Rg.Slot,{scope:t.__scopeSlider,children:s.jsx(C,{"aria-disabled":c,"data-disabled":c?"":void 0,...w,ref:e,onPointerDown:it(w.onPointerDown,()=>{c||(F.current=T)}),min:r,max:i,inverted:y,onSlideStart:c?void 0:I,onSlideMove:c?void 0:R,onSlideEnd:c?void 0:P,onHomeKeyDown:()=>!c&&L(r,0,{commit:!0}),onEndKeyDown:()=>!c&&L(i,T.length-1,{commit:!0}),onStepKeyDown:({event:ee,direction:te})=>{if(!c){const D=mk.includes(ee.key)||ee.shiftKey&&gk.includes(ee.key)?10:1,$=k.current,le=T[$],_=a*D*te;L(le+_,$,{commit:!0})}}})})})})});vk.displayName=zl;var[bk,Nk]=yk(zl,{startEdge:"left",endEdge:"right",size:"width",direction:1}),fP=b.forwardRef((t,e)=>{const{min:n,max:r,dir:i,inverted:a,onSlideStart:o,onSlideMove:c,onSlideEnd:u,onStepKeyDown:h,...f}=t,[m,g]=b.useState(null),y=bt(e,C=>g(C)),v=b.useRef(void 0),w=ff(i),N=w==="ltr",k=N&&!a||!N&&a;function E(C){const T=v.current||m.getBoundingClientRect(),O=[0,T.width],I=Qx(O,k?[n,r]:[r,n]);return v.current=T,I(C-T.left)}return s.jsx(bk,{scope:t.__scopeSlider,startEdge:k?"left":"right",endEdge:k?"right":"left",direction:k?1:-1,size:"width",children:s.jsx(wk,{dir:w,"data-orientation":"horizontal",...f,ref:y,style:{...f.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:C=>{const T=E(C.clientX);o==null||o(T)},onSlideMove:C=>{const T=E(C.clientX);c==null||c(T)},onSlideEnd:()=>{v.current=void 0,u==null||u()},onStepKeyDown:C=>{const O=xk[k?"from-left":"from-right"].includes(C.key);h==null||h({event:C,direction:O?-1:1})}})})}),pP=b.forwardRef((t,e)=>{const{min:n,max:r,inverted:i,onSlideStart:a,onSlideMove:o,onSlideEnd:c,onStepKeyDown:u,...h}=t,f=b.useRef(null),m=bt(e,f),g=b.useRef(void 0),y=!i;function v(w){const N=g.current||f.current.getBoundingClientRect(),k=[0,N.height],C=Qx(k,y?[r,n]:[n,r]);return g.current=N,C(w-N.top)}return s.jsx(bk,{scope:t.__scopeSlider,startEdge:y?"bottom":"top",endEdge:y?"top":"bottom",size:"height",direction:y?1:-1,children:s.jsx(wk,{"data-orientation":"vertical",...h,ref:m,style:{...h.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:w=>{const N=v(w.clientY);a==null||a(N)},onSlideMove:w=>{const N=v(w.clientY);o==null||o(N)},onSlideEnd:()=>{g.current=void 0,c==null||c()},onStepKeyDown:w=>{const k=xk[y?"from-bottom":"from-top"].includes(w.key);u==null||u({event:w,direction:k?-1:1})}})})}),wk=b.forwardRef((t,e)=>{const{__scopeSlider:n,onSlideStart:r,onSlideMove:i,onSlideEnd:a,onHomeKeyDown:o,onEndKeyDown:c,onStepKeyDown:u,...h}=t,f=gf(zl,n);return s.jsx(ct.span,{...h,ref:e,onKeyDown:it(t.onKeyDown,m=>{m.key==="Home"?(o(m),m.preventDefault()):m.key==="End"?(c(m),m.preventDefault()):mk.concat(gk).includes(m.key)&&(u(m),m.preventDefault())}),onPointerDown:it(t.onPointerDown,m=>{const g=m.target;g.setPointerCapture(m.pointerId),m.preventDefault(),f.thumbs.has(g)?g.focus():r(m)}),onPointerMove:it(t.onPointerMove,m=>{m.target.hasPointerCapture(m.pointerId)&&i(m)}),onPointerUp:it(t.onPointerUp,m=>{const g=m.target;g.hasPointerCapture(m.pointerId)&&(g.releasePointerCapture(m.pointerId),a(m))})})}),jk="SliderTrack",kk=b.forwardRef((t,e)=>{const{__scopeSlider:n,...r}=t,i=gf(jk,n);return s.jsx(ct.span,{"data-disabled":i.disabled?"":void 0,"data-orientation":i.orientation,...r,ref:e})});kk.displayName=jk;var Pg="SliderRange",Sk=b.forwardRef((t,e)=>{const{__scopeSlider:n,...r}=t,i=gf(Pg,n),a=Nk(Pg,n),o=b.useRef(null),c=bt(e,o),u=i.values.length,h=i.values.map(g=>Tk(g,i.min,i.max)),f=u>1?Math.min(...h):0,m=100-Math.max(...h);return s.jsx(ct.span,{"data-orientation":i.orientation,"data-disabled":i.disabled?"":void 0,...r,ref:c,style:{...t.style,[a.startEdge]:f+"%",[a.endEdge]:m+"%"}})});Sk.displayName=Pg;var Og="SliderThumb",Ck=b.forwardRef((t,e)=>{const n=dP(t.__scopeSlider),[r,i]=b.useState(null),a=bt(e,c=>i(c)),o=b.useMemo(()=>r?n().findIndex(c=>c.ref.current===r):-1,[n,r]);return s.jsx(mP,{...t,ref:a,index:o})}),mP=b.forwardRef((t,e)=>{const{__scopeSlider:n,index:r,name:i,...a}=t,o=gf(Og,n),c=Nk(Og,n),[u,h]=b.useState(null),f=bt(e,E=>h(E)),m=u?o.form||!!u.closest("form"):!0,g=Gx(u),y=o.values[r],v=y===void 0?0:Tk(y,o.min,o.max),w=yP(r,o.values.length),N=g==null?void 0:g[c.size],k=N?bP(N,v,c.direction):0;return b.useEffect(()=>{if(u)return o.thumbs.add(u),()=>{o.thumbs.delete(u)}},[u,o.thumbs]),s.jsxs("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[c.startEdge]:`calc(${v}% + ${k}px)`},children:[s.jsx(Rg.ItemSlot,{scope:t.__scopeSlider,children:s.jsx(ct.span,{role:"slider","aria-label":t["aria-label"]||w,"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:it(t.onFocus,()=>{o.valueIndexToChangeRef.current=r})})}),m&&s.jsx(Ek,{name:i??(o.name?o.name+(o.values.length>1?"[]":""):void 0),form:o.form,value:y},r)]})});Ck.displayName=Og;var gP="RadioBubbleInput",Ek=b.forwardRef(({__scopeSlider:t,value:e,...n},r)=>{const i=b.useRef(null),a=bt(i,r),o=qx(e);return b.useEffect(()=>{const c=i.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]),s.jsx(ct.input,{style:{display:"none"},...n,ref:a,defaultValue:e})});Ek.displayName=gP;function xP(t=[],e,n){const r=[...t];return r[n]=e,r.sort((i,a)=>i-a)}function Tk(t,e,n){const a=100/(n-e)*(t-e);return uh(a,[0,100])}function yP(t,e){return e>2?`Value ${t+1} of ${e}`:e===2?["Minimum","Maximum"][t]:void 0}function vP(t,e){if(t.length===1)return 0;const n=t.map(i=>Math.abs(i-e)),r=Math.min(...n);return n.indexOf(r)}function bP(t,e,n){const r=t/2,a=Qx([0,50],[0,r]);return(r-a(e)*n)*n}function NP(t){return t.slice(0,-1).map((e,n)=>t[n+1]-e)}function wP(t,e){if(e>0){const n=NP(t);return Math.min(...n)>=e}return!0}function Qx(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 jP(t){return(String(t).split(".")[1]||"").length}function kP(t,e){const n=Math.pow(10,e);return Math.round(t*n)/n}var SP=vk,CP=kk,EP=Sk,TP=Ck;function MP({className:t,defaultValue:e,value:n,min:r=0,max:i=100,...a}){const o=b.useMemo(()=>Array.isArray(n)?n:Array.isArray(e)?e:[r,i],[n,e,r,i]);return s.jsxs(SP,{defaultValue:e,value:n,min:r,max:i,className:Nt("relative flex w-full touch-none items-center select-none data-[disabled]:opacity-50",t),...a,children:[s.jsx(CP,{className:"bg-gray-600 relative grow overflow-hidden rounded-full h-1.5 w-full",children:s.jsx(EP,{className:"bg-[#38bdac] absolute h-full rounded-full"})}),Array.from({length:o.length},(c,u)=>s.jsx(TP,{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 AP={distributorShare:90,minWithdrawAmount:10,bindingDays:30,userDiscount:5,enableAutoWithdraw:!1,vipOrderShareVip:20,vipOrderShareNonVip:10};function Mk(t){const[e,n]=b.useState(AP),[r,i]=b.useState(!0),[a,o]=b.useState(!1);b.useEffect(()=>{Le("/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(()=>i(!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 xt("/api/admin/referral-settings",h);if(!f||f.success===!1){oe.error("保存失败: "+(f&&typeof f=="object"&&"error"in f?f.error:""));return}oe.success(`✅ 分销配置已保存成功! - -• 小程序与网站的推广规则会一起生效 -• 绑定关系会使用新的天数配置 -• 佣金比例会立即应用到新订单 - -如有缓存,请刷新前台/小程序页面。`)}catch(h){console.error(h),oe.error("保存失败: "+(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?s.jsx("div",{className:"p-8 text-gray-500",children:"加载中..."}):s.jsxs("div",{className:"p-8 w-full",children:[s.jsxs("div",{className:"flex justify-between items-center mb-8",children:[s.jsxs("div",{children:[s.jsxs("h2",{className:"text-2xl font-bold text-white flex items-center gap-2",children:[s.jsx(jl,{className:"w-5 h-5 text-[#38bdac]"}),"推广 / 分销设置"]}),s.jsx("p",{className:"text-gray-400 mt-1",children:"统一管理「好友优惠」「你得 90% 收益」「绑定期 30 天」「提现门槛」等规则,小程序和 Web 共用这套配置。"})]}),s.jsxs(ne,{onClick:c,disabled:a||r,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(cn,{className:"w-4 h-4 mr-2"}),a?"保存中...":"保存配置"]})]}),s.jsxs("div",{className:"space-y-6",children:[s.jsxs(Ae,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(et,{children:[s.jsxs(tt,{className:"flex items-center gap-2 text-white",children:[s.jsx(lA,{className:"w-4 h-4 text-[#38bdac]"}),"推广规则"]}),s.jsx(Pt,{className:"text-gray-400",children:"这三项会直接体现在小程序「推广规则」卡片上,同时影响实收佣金计算。"})]}),s.jsx(Ie,{className:"space-y-6",children:s.jsxs("div",{className:"grid grid-cols-3 gap-6",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsxs(Z,{className:"text-gray-300 flex items-center gap-2",children:[s.jsx(bu,{className:"w-3 h-3 text-[#38bdac]"}),"好友优惠(%)"]}),s.jsx(ae,{type:"number",min:0,max:100,className:"bg-[#0a1628] border-gray-700 text-white",value:e.userDiscount,onChange:u("userDiscount")}),s.jsx("p",{className:"text-xs text-gray-500",children:"例如 5 表示好友立减 5%(在价格配置基础上生效)。"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs(Z,{className:"text-gray-300 flex items-center gap-2",children:[s.jsx($n,{className:"w-3 h-3 text-[#38bdac]"}),"推广者分成(%)"]}),s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsx(MP,{className:"flex-1",min:10,max:100,step:1,value:[e.distributorShare],onValueChange:([h])=>n(f=>({...f,distributorShare:h}))}),s.jsx(ae,{type:"number",min:0,max:100,className:"w-20 bg-[#0a1628] border-gray-700 text-white text-center",value:e.distributorShare,onChange:u("distributorShare")})]}),s.jsxs("p",{className:"text-xs text-gray-500",children:["内容订单佣金 = 订单金额 ×"," ",s.jsxs("span",{className:"text-[#38bdac] font-mono",children:[e.distributorShare,"%"]}),";会员订单见下方。"]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs(Z,{className:"text-gray-300 flex items-center gap-2",children:[s.jsx(bu,{className:"w-3 h-3 text-[#38bdac]"}),"会员订单分润(推广者是会员 %)"]}),s.jsx(ae,{type:"number",min:0,max:100,className:"bg-[#0a1628] border-gray-700 text-white",value:e.vipOrderShareVip,onChange:u("vipOrderShareVip")}),s.jsx("p",{className:"text-xs text-gray-500",children:"推广者已是会员时,会员订单佣金比例,默认 20%。"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs(Z,{className:"text-gray-300 flex items-center gap-2",children:[s.jsx(bu,{className:"w-3 h-3 text-[#38bdac]"}),"会员订单分润(推广者非会员 %)"]}),s.jsx(ae,{type:"number",min:0,max:100,className:"bg-[#0a1628] border-gray-700 text-white",value:e.vipOrderShareNonVip,onChange:u("vipOrderShareNonVip")}),s.jsx("p",{className:"text-xs text-gray-500",children:"推广者非会员时,会员订单佣金比例,默认 10%。"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs(Z,{className:"text-gray-300 flex items-center gap-2",children:[s.jsx($n,{className:"w-3 h-3 text-[#38bdac]"}),"绑定有效期(天)"]}),s.jsx(ae,{type:"number",min:1,max:365,className:"bg-[#0a1628] border-gray-700 text-white",value:e.bindingDays,onChange:u("bindingDays")}),s.jsx("p",{className:"text-xs text-gray-500",children:"好友通过你的链接进来并登录后,绑定在你名下的天数。"})]})]})})]}),s.jsxs(Ae,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(et,{children:[s.jsxs(tt,{className:"flex items-center gap-2 text-white",children:[s.jsx(jl,{className:"w-4 h-4 text-[#38bdac]"}),"提现规则"]}),s.jsx(Pt,{className:"text-gray-400",children:"与「提现中心」「自动提现」相关的参数,影响推广者看到的可提现金额和最低门槛。"})]}),s.jsx(Ie,{className:"space-y-6",children:s.jsxs("div",{className:"grid grid-cols-2 gap-6",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"最低提现金额(元)"}),s.jsx(ae,{type:"number",min:0,step:1,className:"bg-[#0a1628] border-gray-700 text-white",value:e.minWithdrawAmount,onChange:u("minWithdrawAmount")}),s.jsx("p",{className:"text-xs text-gray-500",children:"小程序「满 X 元可提现」展示的门槛,同时用于后端接口校验。"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs(Z,{className:"text-gray-300 flex items-center gap-2",children:["自动提现开关",s.jsx(He,{variant:"outline",className:"border-[#38bdac]/40 text-[#38bdac] text-[10px]",children:"预留"})]}),s.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[s.jsx(jt,{checked:e.enableAutoWithdraw,onCheckedChange:h=>n(f=>({...f,enableAutoWithdraw:h}))}),s.jsx("span",{className:"text-sm text-gray-400",children:"开启后,可结合定时任务实现「收益自动打款到微信零钱」。"})]})]})]})})]}),s.jsxs(Ae,{className:"bg-[#0f2137] border-gray-700/50",children:[s.jsx(et,{children:s.jsxs(tt,{className:"flex items-center gap-2 text-gray-200 text-sm",children:[s.jsx(bu,{className:"w-4 h-4 text-[#38bdac]"}),"使用说明"]})}),s.jsxs(Ie,{className:"space-y-2 text-xs text-gray-400 leading-relaxed",children:[s.jsxs("p",{children:["1. 以上配置会写入"," ",s.jsx("code",{className:"font-mono text-[11px] text-[#38bdac]",children:"system_config.referral_config"}),",小程序「推广中心」、Web 推广页以及支付回调都会读取同一份配置。"]}),s.jsx("p",{children:"2. 修改后新订单立即生效;旧订单的历史佣金不会自动重算,只影响之后产生的订单。"}),s.jsx("p",{children:"3. 如遇前端展示与实际结算不一致,优先以此处配置为准,再排查缓存和小程序版本。"})]})]})]})]})}function IP(){var we;const[t,e]=b.useState("overview"),[n,r]=b.useState([]),[i,a]=b.useState(null),[o,c]=b.useState([]),[u,h]=b.useState([]),[f,m]=b.useState([]),[g,y]=b.useState(!0),[v,w]=b.useState(null),[N,k]=b.useState(""),[E,C]=b.useState("all"),[T,O]=b.useState(1),[F,I]=b.useState(10),[R,P]=b.useState(0),[L,ee]=b.useState(new Set),[te,Y]=b.useState(null),[U,D]=b.useState(""),[$,le]=b.useState(!1);b.useEffect(()=>{_()},[]),b.useEffect(()=>{O(1)},[t,E]),b.useEffect(()=>{se(t)},[t]),b.useEffect(()=>{["orders","bindings","withdrawals"].includes(t)&&se(t,!0)},[T,F,E,N]);async function _(){w(null);try{const V=await Le("/api/admin/distribution/overview");V!=null&&V.success&&V.overview&&a(V.overview)}catch(V){console.error("[Admin] 概览接口异常:",V),w("加载概览失败")}try{const V=await Le("/api/db/users");m((V==null?void 0:V.users)||[])}catch(V){console.error("[Admin] 用户数据加载失败:",V)}}async function se(V,be=!1){var Me;if(!(!be&&L.has(V))){y(!0);try{const st=f;switch(V){case"overview":break;case"orders":{try{const nt=new URLSearchParams({page:String(T),pageSize:String(F),...E!=="all"&&{status:E},...N&&{search:N}}),dt=await Le(`/api/admin/orders?${nt}`);if(dt!=null&&dt.success&&dt.orders){const Ye=dt.orders.map(ht=>{const Tt=st.find(Mt=>Mt.id===ht.userId),ft=ht.referrerId?st.find(Mt=>Mt.id===ht.referrerId):null;return{...ht,amount:parseFloat(String(ht.amount))||0,userNickname:(Tt==null?void 0:Tt.nickname)||ht.userNickname||"未知用户",userPhone:(Tt==null?void 0:Tt.phone)||ht.userPhone||"-",referrerNickname:(ft==null?void 0:ft.nickname)||null,referrerCode:(ft==null?void 0:ft.referralCode)??null,type:ht.productType||ht.type}});r(Ye),P(dt.total??Ye.length)}else r([]),P(0)}catch(nt){console.error(nt),w("加载订单失败"),r([])}break}case"bindings":{try{const nt=new URLSearchParams({page:String(T),pageSize:String(F),...E!=="all"&&{status:E}}),dt=await Le(`/api/db/distribution?${nt}`);c((dt==null?void 0:dt.bindings)||[]),P((dt==null?void 0:dt.total)??((Me=dt==null?void 0:dt.bindings)==null?void 0:Me.length)??0)}catch(nt){console.error(nt),w("加载绑定数据失败"),c([])}break}case"withdrawals":{try{const nt=E==="completed"?"success":E==="rejected"?"failed":E,dt=new URLSearchParams({...nt&&nt!=="all"&&{status:nt},page:String(T),pageSize:String(F)}),Ye=await Le(`/api/admin/withdrawals?${dt}`);if(Ye!=null&&Ye.success&&Ye.withdrawals){const ht=Ye.withdrawals.map(Tt=>({...Tt,account:Tt.account??"未绑定微信号",status:Tt.status==="success"?"completed":Tt.status==="failed"?"rejected":Tt.status}));h(ht),P((Ye==null?void 0:Ye.total)??ht.length)}else Ye!=null&&Ye.success||w(`获取提现记录失败: ${(Ye==null?void 0:Ye.error)||"未知错误"}`),h([])}catch(nt){console.error(nt),w("加载提现数据失败"),h([])}break}}ee(nt=>new Set(nt).add(V))}catch(st){console.error(st)}finally{y(!1)}}}async function J(){w(null),ee(V=>{const be=new Set(V);return be.delete(t),be}),t==="overview"&&_(),await se(t,!0)}async function z(V){if(confirm("确认审核通过并打款?"))try{const be=await St("/api/admin/withdrawals",{id:V,action:"approve"});if(!(be!=null&&be.success)){const Me=(be==null?void 0:be.message)||(be==null?void 0:be.error)||"操作失败";oe.error(Me);return}await J()}catch(be){console.error(be),oe.error("操作失败")}}async function W(V){const be=prompt("请输入拒绝原因:");if(be)try{const Me=await St("/api/admin/withdrawals",{id:V,action:"reject",errorMessage:be});if(!(Me!=null&&Me.success)){oe.error((Me==null?void 0:Me.error)||"操作失败");return}await J()}catch(Me){console.error(Me),oe.error("操作失败")}}async function ue(){var V;if(!(!(te!=null&&te.orderSn)&&!(te!=null&&te.id))){le(!0),w(null);try{const be=await St("/api/admin/orders/refund",{orderSn:te.orderSn||te.id,reason:U||void 0});be!=null&&be.success?(Y(null),D(""),await se("orders",!0)):w((be==null?void 0:be.error)||"退款失败")}catch(be){const Me=be;w(((V=Me==null?void 0:Me.data)==null?void 0:V.error)||"退款失败,请检查网络后重试")}finally{le(!1)}}}function G(V){const be={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"},Me={active:"有效",converted:"已转化",expired:"已过期",cancelled:"已取消",pending:"待审核",pending_confirm:"待用户确认",processing:"处理中",completed:"已完成",rejected:"已拒绝"};return s.jsx(He,{className:`${be[V]||"bg-gray-500/20 text-gray-400"} border-0`,children:Me[V]||V})}const fe=Math.ceil(R/F)||1,X=n,ce=o.filter(V=>{var Me,st,nt,dt;if(!N)return!0;const be=N.toLowerCase();return((Me=V.refereeNickname)==null?void 0:Me.toLowerCase().includes(be))||((st=V.refereePhone)==null?void 0:st.includes(be))||((nt=V.referrerName)==null?void 0:nt.toLowerCase().includes(be))||((dt=V.referrerCode)==null?void 0:dt.toLowerCase().includes(be))}),he=u.filter(V=>{var Me;if(!N)return!0;const be=N.toLowerCase();return((Me=V.userName)==null?void 0:Me.toLowerCase().includes(be))||V.account&&V.account.toLowerCase().includes(be)});return s.jsxs("div",{className:"p-8 w-full",children:[v&&s.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:[s.jsx("span",{children:v}),s.jsx("button",{type:"button",onClick:()=>w(null),className:"hover:text-red-300",children:"×"})]}),s.jsxs("div",{className:"flex items-center justify-between mb-8",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-bold text-white",children:"推广中心"}),s.jsx("p",{className:"text-gray-400 mt-1",children:"统一管理:订单、分销绑定、提现审核"})]}),s.jsxs(ne,{onClick:J,disabled:g,variant:"outline",className:"border-gray-700 text-gray-300 hover:bg-gray-800",children:[s.jsx(Ke,{className:`w-4 h-4 mr-2 ${g?"animate-spin":""}`}),"刷新数据"]})]}),s.jsx("div",{className:"flex gap-2 mb-6 border-b border-gray-700 pb-4 flex-wrap",children:[{key:"overview",label:"数据概览",icon:Oc},{key:"orders",label:"订单管理",icon:ah},{key:"bindings",label:"绑定管理",icon:ps},{key:"withdrawals",label:"提现审核",icon:jl},{key:"settings",label:"推广设置",icon:so}].map(V=>s.jsxs("button",{type:"button",onClick:()=>{e(V.key),C("all"),k("")},className:`flex items-center gap-2 px-4 py-2 rounded-lg text-sm font-medium transition-colors ${t===V.key?"bg-[#38bdac] text-white":"text-gray-400 hover:text-white hover:bg-gray-800"}`,children:[s.jsx(V.icon,{className:"w-4 h-4"}),V.label]},V.key))}),g?s.jsxs("div",{className:"flex items-center justify-center py-20",children:[s.jsx(Ke,{className:"w-8 h-8 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):s.jsxs(s.Fragment,{children:[t==="overview"&&i&&s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"grid grid-cols-4 gap-4",children:[s.jsx(Ae,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsx(Ie,{className:"p-6",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-gray-400 text-sm",children:"今日点击"}),s.jsx("p",{className:"text-2xl font-bold text-white mt-1",children:i.todayClicks}),s.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:"总点击次数(实时)"})]}),s.jsx("div",{className:"w-12 h-12 rounded-xl bg-blue-500/20 flex items-center justify-center",children:s.jsx(jg,{className:"w-6 h-6 text-blue-400"})})]})})}),s.jsx(Ae,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsx(Ie,{className:"p-6",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-gray-400 text-sm",children:"今日独立用户"}),s.jsx("p",{className:"text-2xl font-bold text-white mt-1",children:i.todayUniqueVisitors??0}),s.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:"去重访客数(实时)"})]}),s.jsx("div",{className:"w-12 h-12 rounded-xl bg-cyan-500/20 flex items-center justify-center",children:s.jsx($n,{className:"w-6 h-6 text-cyan-400"})})]})})}),s.jsx(Ae,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsx(Ie,{className:"p-6",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-gray-400 text-sm",children:"今日总文章点击率"}),s.jsx("p",{className:"text-2xl font-bold text-white mt-1",children:(i.todayClickRate??0).toFixed(2)}),s.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:"人均点击(总点击/独立用户)"})]}),s.jsx("div",{className:"w-12 h-12 rounded-xl bg-amber-500/20 flex items-center justify-center",children:s.jsx(Oc,{className:"w-6 h-6 text-amber-400"})})]})})}),s.jsx(Ae,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsx(Ie,{className:"p-6",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-gray-400 text-sm",children:"今日绑定"}),s.jsx("p",{className:"text-2xl font-bold text-white mt-1",children:i.todayBindings})]}),s.jsx("div",{className:"w-12 h-12 rounded-xl bg-green-500/20 flex items-center justify-center",children:s.jsx(ps,{className:"w-6 h-6 text-green-400"})})]})})}),s.jsx(Ae,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsx(Ie,{className:"p-6",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-gray-400 text-sm",children:"今日转化"}),s.jsx("p",{className:"text-2xl font-bold text-white mt-1",children:i.todayConversions})]}),s.jsx("div",{className:"w-12 h-12 rounded-xl bg-purple-500/20 flex items-center justify-center",children:s.jsx(Pb,{className:"w-6 h-6 text-purple-400"})})]})})}),s.jsx(Ae,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsx(Ie,{className:"p-6",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-gray-400 text-sm",children:"今日佣金"}),s.jsxs("p",{className:"text-2xl font-bold text-[#38bdac] mt-1",children:["¥",i.todayEarnings.toFixed(2)]})]}),s.jsx("div",{className:"w-12 h-12 rounded-xl bg-[#38bdac]/20 flex items-center justify-center",children:s.jsx(ah,{className:"w-6 h-6 text-[#38bdac]"})})]})})})]}),(((we=i.todayClicksByPage)==null?void 0:we.length)??0)>0&&s.jsxs(Ae,{className:"bg-[#0f2137] border-gray-700/50",children:[s.jsxs(et,{children:[s.jsxs(tt,{className:"text-white flex items-center gap-2",children:[s.jsx(jg,{className:"w-5 h-5 text-[#38bdac]"}),"每篇文章今日点击(按来源页/文章统计)"]}),s.jsx("p",{className:"text-gray-400 text-sm mt-1",children:"实际用户与实际文章的点击均计入;今日总点击与上表一致"})]}),s.jsx(Ie,{children:s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full text-sm",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"border-b border-gray-700 text-left text-gray-400",children:[s.jsx("th",{className:"pb-3 pr-4",children:"来源页/文章"}),s.jsx("th",{className:"pb-3 pr-4 text-right",children:"今日点击"}),s.jsx("th",{className:"pb-3 text-right",children:"占比"})]})}),s.jsx("tbody",{children:[...i.todayClicksByPage??[]].sort((V,be)=>be.clicks-V.clicks).map((V,be)=>s.jsxs("tr",{className:"border-b border-gray-700/50",children:[s.jsx("td",{className:"py-2 pr-4 text-white font-mono",children:V.page||"(未区分)"}),s.jsx("td",{className:"py-2 pr-4 text-right text-white",children:V.clicks}),s.jsxs("td",{className:"py-2 text-right text-gray-400",children:[i.todayClicks>0?(V.clicks/i.todayClicks*100).toFixed(1):0,"%"]})]},be))})]})})})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsx(Ae,{className:"bg-orange-500/10 border-orange-500/30",children:s.jsx(Ie,{className:"p-6",children:s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsx("div",{className:"w-12 h-12 rounded-xl bg-orange-500/20 flex items-center justify-center",children:s.jsx(wg,{className:"w-6 h-6 text-orange-400"})}),s.jsxs("div",{className:"flex-1",children:[s.jsx("p",{className:"text-orange-300 font-medium",children:"即将过期绑定"}),s.jsxs("p",{className:"text-2xl font-bold text-white",children:[i.expiringBindings," 个"]}),s.jsx("p",{className:"text-orange-300/60 text-sm",children:"7天内到期,需关注转化"})]})]})})}),s.jsx(Ae,{className:"bg-blue-500/10 border-blue-500/30",children:s.jsx(Ie,{className:"p-6",children:s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsx("div",{className:"w-12 h-12 rounded-xl bg-blue-500/20 flex items-center justify-center",children:s.jsx(jl,{className:"w-6 h-6 text-blue-400"})}),s.jsxs("div",{className:"flex-1",children:[s.jsx("p",{className:"text-blue-300 font-medium",children:"待审核提现"}),s.jsxs("p",{className:"text-2xl font-bold text-white",children:[i.pendingWithdrawals," 笔"]}),s.jsxs("p",{className:"text-blue-300/60 text-sm",children:["共 ¥",i.pendingWithdrawAmount.toFixed(2)]})]}),s.jsx(ne,{onClick:()=>e("withdrawals"),variant:"outline",className:"border-blue-500/50 text-blue-400 hover:bg-blue-500/20",children:"去审核"})]})})})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-6",children:[s.jsxs(Ae,{className:"bg-[#0f2137] border-gray-700/50",children:[s.jsx(et,{children:s.jsxs(tt,{className:"text-white flex items-center gap-2",children:[s.jsx(ih,{className:"w-5 h-5 text-[#38bdac]"}),"本月统计"]})}),s.jsx(Ie,{children:s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"p-4 bg-white/5 rounded-lg",children:[s.jsx("p",{className:"text-gray-400 text-sm",children:"点击量"}),s.jsx("p",{className:"text-xl font-bold text-white",children:i.monthClicks})]}),s.jsxs("div",{className:"p-4 bg-white/5 rounded-lg",children:[s.jsx("p",{className:"text-gray-400 text-sm",children:"绑定数"}),s.jsx("p",{className:"text-xl font-bold text-white",children:i.monthBindings})]}),s.jsxs("div",{className:"p-4 bg-white/5 rounded-lg",children:[s.jsx("p",{className:"text-gray-400 text-sm",children:"转化数"}),s.jsx("p",{className:"text-xl font-bold text-white",children:i.monthConversions})]}),s.jsxs("div",{className:"p-4 bg-white/5 rounded-lg",children:[s.jsx("p",{className:"text-gray-400 text-sm",children:"佣金"}),s.jsxs("p",{className:"text-xl font-bold text-[#38bdac]",children:["¥",i.monthEarnings.toFixed(2)]})]})]})})]}),s.jsxs(Ae,{className:"bg-[#0f2137] border-gray-700/50",children:[s.jsx(et,{children:s.jsxs(tt,{className:"text-white flex items-center gap-2",children:[s.jsx(Oc,{className:"w-5 h-5 text-[#38bdac]"}),"累计统计"]})}),s.jsxs(Ie,{children:[s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"p-4 bg-white/5 rounded-lg",children:[s.jsx("p",{className:"text-gray-400 text-sm",children:"总点击"}),s.jsx("p",{className:"text-xl font-bold text-white",children:i.totalClicks.toLocaleString()})]}),s.jsxs("div",{className:"p-4 bg-white/5 rounded-lg",children:[s.jsx("p",{className:"text-gray-400 text-sm",children:"总绑定"}),s.jsx("p",{className:"text-xl font-bold text-white",children:i.totalBindings.toLocaleString()})]}),s.jsxs("div",{className:"p-4 bg-white/5 rounded-lg",children:[s.jsx("p",{className:"text-gray-400 text-sm",children:"总转化"}),s.jsx("p",{className:"text-xl font-bold text-white",children:i.totalConversions})]}),s.jsxs("div",{className:"p-4 bg-white/5 rounded-lg",children:[s.jsx("p",{className:"text-gray-400 text-sm",children:"总佣金"}),s.jsxs("p",{className:"text-xl font-bold text-[#38bdac]",children:["¥",i.totalEarnings.toFixed(2)]})]})]}),s.jsxs("div",{className:"mt-4 p-4 bg-[#38bdac]/10 rounded-lg flex items-center justify-between",children:[s.jsx("span",{className:"text-gray-300",children:"点击转化率"}),s.jsxs("span",{className:"text-[#38bdac] font-bold text-xl",children:[i.conversionRate,"%"]})]})]})]})]}),s.jsxs(Ae,{className:"bg-[#0f2137] border-gray-700/50",children:[s.jsx(et,{children:s.jsxs(tt,{className:"text-white flex items-center gap-2",children:[s.jsx($n,{className:"w-5 h-5 text-[#38bdac]"}),"推广统计"]})}),s.jsx(Ie,{children:s.jsxs("div",{className:"grid grid-cols-4 gap-4",children:[s.jsxs("div",{className:"p-4 bg-white/5 rounded-lg text-center",children:[s.jsx("p",{className:"text-3xl font-bold text-white",children:i.totalDistributors}),s.jsx("p",{className:"text-gray-400 text-sm mt-1",children:"推广用户数"})]}),s.jsxs("div",{className:"p-4 bg-white/5 rounded-lg text-center",children:[s.jsx("p",{className:"text-3xl font-bold text-green-400",children:i.activeDistributors}),s.jsx("p",{className:"text-gray-400 text-sm mt-1",children:"有收益用户"})]}),s.jsxs("div",{className:"p-4 bg-white/5 rounded-lg text-center",children:[s.jsx("p",{className:"text-3xl font-bold text-[#38bdac]",children:"90%"}),s.jsx("p",{className:"text-gray-400 text-sm mt-1",children:"佣金比例"})]}),s.jsxs("div",{className:"p-4 bg-white/5 rounded-lg text-center",children:[s.jsx("p",{className:"text-3xl font-bold text-orange-400",children:"30天"}),s.jsx("p",{className:"text-gray-400 text-sm mt-1",children:"绑定有效期"})]})]})})]})]}),t==="orders"&&s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex gap-4",children:[s.jsxs("div",{className:"relative flex-1",children:[s.jsx(da,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400"}),s.jsx(ae,{value:N,onChange:V=>k(V.target.value),placeholder:"搜索订单号、用户名、手机号...",className:"pl-10 bg-[#0f2137] border-gray-700 text-white"})]}),s.jsxs("select",{value:E,onChange:V=>C(V.target.value),className:"px-4 py-2 bg-[#0f2137] border border-gray-700 rounded-lg text-white",children:[s.jsx("option",{value:"all",children:"全部状态"}),s.jsx("option",{value:"completed",children:"已完成"}),s.jsx("option",{value:"pending",children:"待支付"}),s.jsx("option",{value:"failed",children:"已失败"}),s.jsx("option",{value:"refunded",children:"已退款"})]})]}),s.jsx(Ae,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsxs(Ie,{className:"p-0",children:[n.length===0?s.jsx("div",{className:"py-12 text-center text-gray-500",children:"暂无订单数据"}):s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full text-sm",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"bg-[#0a1628] text-gray-400",children:[s.jsx("th",{className:"p-4 text-left font-medium",children:"订单号"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"用户"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"商品"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"金额"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"支付方式"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"状态"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"退款原因"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"推荐人/邀请码"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"分销佣金"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"下单时间"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"操作"})]})}),s.jsx("tbody",{className:"divide-y divide-gray-700/50",children:X.map(V=>{var be,Me;return s.jsxs("tr",{className:"hover:bg-[#0a1628] transition-colors",children:[s.jsxs("td",{className:"p-4 font-mono text-xs text-gray-400",children:[(be=V.id)==null?void 0:be.slice(0,12),"..."]}),s.jsx("td",{className:"p-4",children:s.jsxs("div",{children:[s.jsx("p",{className:"text-white text-sm",children:V.userNickname}),s.jsx("p",{className:"text-gray-500 text-xs",children:V.userPhone})]})}),s.jsx("td",{className:"p-4",children:s.jsxs("div",{children:[s.jsx("p",{className:"text-white text-sm",children:(()=>{const st=V.productType||V.type;return st==="fullbook"?`${V.bookName||"《底层逻辑》"} - 全本`:st==="match"?"匹配次数购买":`${V.bookName||"《底层逻辑》"} - ${V.sectionTitle||V.chapterTitle||`章节${V.productId||V.sectionId||""}`}`})()}),s.jsx("p",{className:"text-gray-500 text-xs",children:(()=>{const st=V.productType||V.type;return st==="fullbook"?"全书解锁":st==="match"?"功能权益":V.chapterTitle||"单章购买"})()})]})}),s.jsxs("td",{className:"p-4 text-[#38bdac] font-bold",children:["¥",typeof V.amount=="number"?V.amount.toFixed(2):parseFloat(String(V.amount||"0")).toFixed(2)]}),s.jsx("td",{className:"p-4 text-gray-300",children:V.paymentMethod==="wechat"?"微信支付":V.paymentMethod==="alipay"?"支付宝":V.paymentMethod||"微信支付"}),s.jsx("td",{className:"p-4",children:V.status==="refunded"?s.jsx(He,{className:"bg-gray-500/20 text-gray-400 border-0",children:"已退款"}):V.status==="completed"||V.status==="paid"?s.jsx(He,{className:"bg-green-500/20 text-green-400 border-0",children:"已完成"}):V.status==="pending"||V.status==="created"?s.jsx(He,{className:"bg-yellow-500/20 text-yellow-400 border-0",children:"待支付"}):s.jsx(He,{className:"bg-red-500/20 text-red-400 border-0",children:"已失败"})}),s.jsx("td",{className:"p-4 text-gray-400 text-sm max-w-[120px]",title:V.refundReason,children:V.status==="refunded"&&V.refundReason?V.refundReason:"-"}),s.jsx("td",{className:"p-4 text-gray-300 text-sm",children:V.referrerId||V.referralCode?s.jsxs("span",{title:V.referralCode||V.referrerCode||V.referrerId||"",children:[V.referrerNickname||V.referralCode||V.referrerCode||((Me=V.referrerId)==null?void 0:Me.slice(0,8)),(V.referralCode||V.referrerCode)&&` (${V.referralCode||V.referrerCode})`]}):"-"}),s.jsx("td",{className:"p-4 text-[#FFD700]",children:V.referrerEarnings?`¥${(typeof V.referrerEarnings=="number"?V.referrerEarnings:parseFloat(String(V.referrerEarnings))).toFixed(2)}`:"-"}),s.jsx("td",{className:"p-4 text-gray-400 text-sm",children:V.createdAt?new Date(V.createdAt).toLocaleString("zh-CN"):"-"}),s.jsx("td",{className:"p-4",children:(V.status==="paid"||V.status==="completed")&&s.jsxs(ne,{variant:"outline",size:"sm",className:"border-orange-500/50 text-orange-400 hover:bg-orange-500/20",onClick:()=>{Y(V),D("")},children:[s.jsx(Gw,{className:"w-3 h-3 mr-1"}),"退款"]})})]},V.id)})})]})}),t==="orders"&&s.jsx(ms,{page:T,totalPages:fe,total:R,pageSize:F,onPageChange:O,onPageSizeChange:V=>{I(V),O(1)}})]})})]}),t==="bindings"&&s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex gap-4",children:[s.jsxs("div",{className:"relative flex-1",children:[s.jsx(da,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400"}),s.jsx(ae,{value:N,onChange:V=>k(V.target.value),placeholder:"搜索用户昵称、手机号、推广码...",className:"pl-10 bg-[#0f2137] border-gray-700 text-white"})]}),s.jsxs("select",{value:E,onChange:V=>C(V.target.value),className:"px-4 py-2 bg-[#0f2137] border border-gray-700 rounded-lg text-white",children:[s.jsx("option",{value:"all",children:"全部状态"}),s.jsx("option",{value:"active",children:"有效"}),s.jsx("option",{value:"converted",children:"已转化"}),s.jsx("option",{value:"expired",children:"已过期"})]})]}),s.jsx(Ae,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsxs(Ie,{className:"p-0",children:[ce.length===0?s.jsx("div",{className:"py-12 text-center text-gray-500",children:"暂无绑定数据"}):s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full text-sm",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"bg-[#0a1628] text-gray-400",children:[s.jsx("th",{className:"p-4 text-left font-medium",children:"访客"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"分销商"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"绑定时间"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"到期时间"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"状态"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"佣金"})]})}),s.jsx("tbody",{className:"divide-y divide-gray-700/50",children:ce.map(V=>s.jsxs("tr",{className:"hover:bg-[#0a1628] transition-colors",children:[s.jsx("td",{className:"p-4",children:s.jsxs("div",{children:[s.jsx("p",{className:"text-white font-medium",children:V.refereeNickname||"匿名用户"}),s.jsx("p",{className:"text-gray-500 text-xs",children:V.refereePhone})]})}),s.jsx("td",{className:"p-4",children:s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:V.referrerName||"-"}),s.jsx("p",{className:"text-gray-500 text-xs font-mono",children:V.referrerCode})]})}),s.jsx("td",{className:"p-4 text-gray-400",children:V.boundAt?new Date(V.boundAt).toLocaleDateString("zh-CN"):"-"}),s.jsx("td",{className:"p-4 text-gray-400",children:V.expiresAt?new Date(V.expiresAt).toLocaleDateString("zh-CN"):"-"}),s.jsx("td",{className:"p-4",children:G(V.status)}),s.jsx("td",{className:"p-4",children:V.commission?s.jsxs("span",{className:"text-[#38bdac] font-medium",children:["¥",V.commission.toFixed(2)]}):s.jsx("span",{className:"text-gray-500",children:"-"})})]},V.id))})]})}),t==="bindings"&&s.jsx(ms,{page:T,totalPages:fe,total:R,pageSize:F,onPageChange:O,onPageSizeChange:V=>{I(V),O(1)}})]})})]}),t==="withdrawals"&&s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex gap-4",children:[s.jsxs("div",{className:"relative flex-1",children:[s.jsx(da,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400"}),s.jsx(ae,{value:N,onChange:V=>k(V.target.value),placeholder:"搜索用户名称、账号...",className:"pl-10 bg-[#0f2137] border-gray-700 text-white"})]}),s.jsxs("select",{value:E,onChange:V=>C(V.target.value),className:"px-4 py-2 bg-[#0f2137] border border-gray-700 rounded-lg text-white",children:[s.jsx("option",{value:"all",children:"全部状态"}),s.jsx("option",{value:"pending",children:"待审核"}),s.jsx("option",{value:"completed",children:"已完成"}),s.jsx("option",{value:"rejected",children:"已拒绝"})]})]}),s.jsx(Ae,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsxs(Ie,{className:"p-0",children:[he.length===0?s.jsx("div",{className:"py-12 text-center text-gray-500",children:"暂无提现记录"}):s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full text-sm",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"bg-[#0a1628] text-gray-400",children:[s.jsx("th",{className:"p-4 text-left font-medium",children:"申请人"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"金额"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"收款方式"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"收款账号"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"申请时间"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"状态"}),s.jsx("th",{className:"p-4 text-right font-medium",children:"操作"})]})}),s.jsx("tbody",{className:"divide-y divide-gray-700/50",children:he.map(V=>s.jsxs("tr",{className:"hover:bg-[#0a1628] transition-colors",children:[s.jsx("td",{className:"p-4",children:s.jsxs("div",{className:"flex items-center gap-2",children:[V.userAvatar?s.jsx("img",{src:V.userAvatar,alt:"",className:"w-8 h-8 rounded-full object-cover"}):s.jsx("div",{className:"w-8 h-8 rounded-full bg-gray-600 flex items-center justify-center text-white text-sm font-medium",children:(V.userName||V.name||"?").slice(0,1)}),s.jsx("p",{className:"text-white font-medium",children:V.userName||V.name})]})}),s.jsx("td",{className:"p-4",children:s.jsxs("span",{className:"text-[#38bdac] font-bold",children:["¥",V.amount.toFixed(2)]})}),s.jsx("td",{className:"p-4",children:s.jsx(He,{className:V.method==="wechat"?"bg-green-500/20 text-green-400 border-0":"bg-blue-500/20 text-blue-400 border-0",children:V.method==="wechat"?"微信":"支付宝"})}),s.jsx("td",{className:"p-4",children:s.jsxs("div",{children:[s.jsx("p",{className:"text-white font-mono text-xs",children:V.account}),s.jsx("p",{className:"text-gray-500 text-xs",children:V.name})]})}),s.jsx("td",{className:"p-4 text-gray-400",children:V.createdAt?new Date(V.createdAt).toLocaleString("zh-CN"):"-"}),s.jsx("td",{className:"p-4",children:G(V.status)}),s.jsx("td",{className:"p-4 text-right",children:V.status==="pending"&&s.jsxs("div",{className:"flex gap-2 justify-end",children:[s.jsxs(ne,{size:"sm",onClick:()=>z(V.id),className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(Pb,{className:"w-4 h-4 mr-1"}),"通过"]}),s.jsxs(ne,{size:"sm",variant:"outline",onClick:()=>W(V.id),className:"border-red-500/50 text-red-400 hover:bg-red-500/20",children:[s.jsx(Vw,{className:"w-4 h-4 mr-1"}),"拒绝"]})]})})]},V.id))})]})}),t==="withdrawals"&&s.jsx(ms,{page:T,totalPages:fe,total:R,pageSize:F,onPageChange:O,onPageSizeChange:V=>{I(V),O(1)}})]})})]})]}),s.jsx(Kt,{open:!!te,onOpenChange:V=>!V&&Y(null),children:s.jsxs(Vt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",children:[s.jsx(qt,{children:s.jsx(Gt,{className:"text-white",children:"订单退款"})}),te&&s.jsxs("div",{className:"space-y-4",children:[s.jsxs("p",{className:"text-gray-400 text-sm",children:["订单号:",te.orderSn||te.id]}),s.jsxs("p",{className:"text-gray-400 text-sm",children:["退款金额:¥",typeof te.amount=="number"?te.amount.toFixed(2):parseFloat(String(te.amount||"0")).toFixed(2)]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-sm text-gray-400 block mb-2",children:"退款原因(选填)"}),s.jsx("div",{className:"form-input",children:s.jsx(ae,{className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500",placeholder:"如:用户申请退款",value:U,onChange:V=>D(V.target.value)})})]}),s.jsx("p",{className:"text-orange-400/80 text-xs",children:"退款将原路退回至用户微信,且无法撤销,请确认后再操作。"})]}),s.jsxs(hn,{children:[s.jsx(ne,{variant:"outline",className:"border-gray-600 text-gray-300",onClick:()=>Y(null),disabled:$,children:"取消"}),s.jsx(ne,{className:"bg-orange-500 hover:bg-orange-600 text-white",onClick:ue,disabled:$,children:$?"退款中...":"确认退款"})]})]})}),t==="settings"&&s.jsx("div",{className:"-mx-8 -mt-6",children:s.jsx(Mk,{embedded:!0})})]})}function RP(){const[t,e]=b.useState([]),[n,r]=b.useState({total:0,pendingCount:0,pendingAmount:0,successCount:0,successAmount:0,failedCount:0}),[i,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,w]=b.useState(0),[N,k]=b.useState(null);async function E(){var I,R,P,L,ee,te,Y;a(!0),c(null);try{const U=new URLSearchParams({status:u,page:String(f),pageSize:String(g)}),D=await Le(`/api/admin/withdrawals?${U}`);if(D!=null&&D.success){const $=D.withdrawals||[];e($),w(D.total??((I=D.stats)==null?void 0:I.total)??$.length),r({total:((R=D.stats)==null?void 0:R.total)??D.total??$.length,pendingCount:((P=D.stats)==null?void 0:P.pendingCount)??0,pendingAmount:((L=D.stats)==null?void 0:L.pendingAmount)??0,successCount:((ee=D.stats)==null?void 0:ee.successCount)??0,successAmount:((te=D.stats)==null?void 0:te.successAmount)??0,failedCount:((Y=D.stats)==null?void 0:Y.failedCount)??0})}else c("加载提现记录失败")}catch(U){console.error("Load withdrawals error:",U),c("加载失败,请检查网络后重试")}finally{a(!1)}}b.useEffect(()=>{m(1)},[u]),b.useEffect(()=>{E()},[u,f,g]);const C=Math.ceil(v/g)||1;async function T(I){const R=t.find(P=>P.id===I);if(R!=null&&R.userCommissionInfo&&R.userCommissionInfo.availableAfterThis<0){if(!confirm(`⚠️ 风险警告:该用户审核后余额为负数(¥${R.userCommissionInfo.availableAfterThis.toFixed(2)}),可能存在超额提现。 - -确认已核实用户账户并完成打款?`))return}else if(!confirm("确认已完成打款?批准后将更新用户提现记录。"))return;k(I);try{const P=await St("/api/admin/withdrawals",{id:I,action:"approve"});P!=null&&P.success?E():oe.error("操作失败: "+((P==null?void 0:P.error)??""))}catch{oe.error("操作失败")}finally{k(null)}}async function O(I){const R=prompt("请输入拒绝原因(将返还用户余额):");if(R){k(I);try{const P=await St("/api/admin/withdrawals",{id:I,action:"reject",errorMessage:R});P!=null&&P.success?E():oe.error("操作失败: "+((P==null?void 0:P.error)??""))}catch{oe.error("操作失败")}finally{k(null)}}}function F(I){switch(I){case"pending":return s.jsx(He,{className:"bg-orange-500/20 text-orange-400 hover:bg-orange-500/20 border-0",children:"待处理"});case"pending_confirm":return s.jsx(He,{className:"bg-orange-500/20 text-orange-400 hover:bg-orange-500/20 border-0",children:"待用户确认"});case"processing":return s.jsx(He,{className:"bg-blue-500/20 text-blue-400 hover:bg-blue-500/20 border-0",children:"已审批等待打款"});case"success":case"completed":return s.jsx(He,{className:"bg-green-500/20 text-green-400 hover:bg-green-500/20 border-0",children:"已完成"});case"failed":case"rejected":return s.jsx(He,{className:"bg-red-500/20 text-red-400 hover:bg-red-500/20 border-0",children:"已拒绝"});default:return s.jsx(He,{className:"bg-gray-500/20 text-gray-400 border-0",children:I})}}return s.jsxs("div",{className:"p-8 w-full",children:[o&&s.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:[s.jsx("span",{children:o}),s.jsx("button",{type:"button",onClick:()=>c(null),className:"hover:text-red-300",children:"×"})]}),s.jsxs("div",{className:"flex justify-between items-start mb-8",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-bold text-white",children:"分账提现管理"}),s.jsx("p",{className:"text-gray-400 mt-1",children:"管理用户分销收益的提现申请"})]}),s.jsxs(ne,{variant:"outline",onClick:E,disabled:i,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Ke,{className:`w-4 h-4 mr-2 ${i?"animate-spin":""}`}),"刷新"]})]}),s.jsx(Ae,{className:"bg-gradient-to-r from-[#38bdac]/10 to-[#0f2137] border-[#38bdac]/30 mb-6",children:s.jsx(Ie,{className:"p-4",children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx(ah,{className:"w-5 h-5 text-[#38bdac] mt-0.5"}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-white font-medium mb-2",children:"自动分账规则"}),s.jsxs("div",{className:"text-sm text-gray-400 space-y-1",children:[s.jsxs("p",{children:["• ",s.jsx("span",{className:"text-[#38bdac]",children:"分销比例"}),":推广者获得订单金额的"," ",s.jsx("span",{className:"text-white font-medium",children:"90%"})]}),s.jsxs("p",{children:["• ",s.jsx("span",{className:"text-[#38bdac]",children:"结算方式"}),":用户付款后,分销收益自动计入推广者账户"]}),s.jsxs("p",{children:["• ",s.jsx("span",{className:"text-[#38bdac]",children:"提现方式"}),":用户在小程序端点击提现,系统自动转账到微信零钱"]}),s.jsxs("p",{children:["• ",s.jsx("span",{className:"text-[#38bdac]",children:"审批流程"}),":待处理的提现需管理员手动确认打款后批准"]})]})]})]})})}),s.jsxs("div",{className:"grid grid-cols-4 gap-4 mb-6",children:[s.jsx(Ae,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsxs(Ie,{className:"p-4 text-center",children:[s.jsx("div",{className:"text-3xl font-bold text-[#38bdac]",children:n.total}),s.jsx("div",{className:"text-sm text-gray-400",children:"总申请"})]})}),s.jsx(Ae,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsxs(Ie,{className:"p-4 text-center",children:[s.jsx("div",{className:"text-3xl font-bold text-orange-400",children:n.pendingCount}),s.jsx("div",{className:"text-sm text-gray-400",children:"待处理"}),s.jsxs("div",{className:"text-xs text-orange-400 mt-1",children:["¥",n.pendingAmount.toFixed(2)]})]})}),s.jsx(Ae,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsxs(Ie,{className:"p-4 text-center",children:[s.jsx("div",{className:"text-3xl font-bold text-green-400",children:n.successCount}),s.jsx("div",{className:"text-sm text-gray-400",children:"已完成"}),s.jsxs("div",{className:"text-xs text-green-400 mt-1",children:["¥",n.successAmount.toFixed(2)]})]})}),s.jsx(Ae,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsxs(Ie,{className:"p-4 text-center",children:[s.jsx("div",{className:"text-3xl font-bold text-red-400",children:n.failedCount}),s.jsx("div",{className:"text-sm text-gray-400",children:"已拒绝"})]})})]}),s.jsx("div",{className:"flex gap-2 mb-4",children:["all","pending","success","failed"].map(I=>s.jsx(ne,{variant:u===I?"default":"outline",size:"sm",onClick:()=>h(I),className:u===I?"bg-[#38bdac] hover:bg-[#2da396] text-white":"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:I==="all"?"全部":I==="pending"?"待处理":I==="success"?"已完成":"已拒绝"},I))}),s.jsx(Ae,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:s.jsx(Ie,{className:"p-0",children:i?s.jsxs("div",{className:"flex items-center justify-center py-12",children:[s.jsx(Ke,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):t.length===0?s.jsxs("div",{className:"text-center py-12",children:[s.jsx(jl,{className:"w-12 h-12 text-gray-600 mx-auto mb-3"}),s.jsx("p",{className:"text-gray-500",children:"暂无提现记录"})]}):s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full text-sm",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"bg-[#0a1628] text-gray-400",children:[s.jsx("th",{className:"p-4 text-left font-medium",children:"申请时间"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"用户"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"提现金额"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"用户佣金信息"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"状态"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"处理时间"}),s.jsx("th",{className:"p-4 text-left font-medium",children:"确认收款"}),s.jsx("th",{className:"p-4 text-right font-medium",children:"操作"})]})}),s.jsx("tbody",{className:"divide-y divide-gray-700/50",children:t.map(I=>s.jsxs("tr",{className:"hover:bg-[#0a1628] transition-colors",children:[s.jsx("td",{className:"p-4 text-gray-400",children:new Date(I.createdAt??"").toLocaleString()}),s.jsx("td",{className:"p-4",children:s.jsxs("div",{className:"flex items-center gap-2",children:[I.userAvatar?s.jsx("img",{src:I.userAvatar,alt:I.userName??"",className:"w-8 h-8 rounded-full object-cover"}):s.jsx("div",{className:"w-8 h-8 rounded-full bg-[#38bdac]/20 flex items-center justify-center text-sm text-[#38bdac]",children:(I.userName??"?").charAt(0)}),s.jsxs("div",{children:[s.jsx("p",{className:"font-medium text-white",children:I.userName??"未知"}),s.jsx("p",{className:"text-xs text-gray-500",children:I.userPhone??I.referralCode??(I.userId??"").slice(0,10)})]})]})}),s.jsx("td",{className:"p-4",children:s.jsxs("span",{className:"font-bold text-orange-400",children:["¥",Number(I.amount).toFixed(2)]})}),s.jsx("td",{className:"p-4",children:I.userCommissionInfo?s.jsxs("div",{className:"text-xs space-y-1",children:[s.jsxs("div",{className:"flex justify-between gap-4",children:[s.jsx("span",{className:"text-gray-500",children:"累计佣金:"}),s.jsxs("span",{className:"text-[#38bdac] font-medium",children:["¥",I.userCommissionInfo.totalCommission.toFixed(2)]})]}),s.jsxs("div",{className:"flex justify-between gap-4",children:[s.jsx("span",{className:"text-gray-500",children:"已提现:"}),s.jsxs("span",{className:"text-gray-400",children:["¥",I.userCommissionInfo.withdrawnEarnings.toFixed(2)]})]}),s.jsxs("div",{className:"flex justify-between gap-4",children:[s.jsx("span",{className:"text-gray-500",children:"待审核:"}),s.jsxs("span",{className:"text-orange-400",children:["¥",I.userCommissionInfo.pendingWithdrawals.toFixed(2)]})]}),s.jsxs("div",{className:"flex justify-between gap-4 pt-1 border-t border-gray-700/30",children:[s.jsx("span",{className:"text-gray-500",children:"审核后余额:"}),s.jsxs("span",{className:I.userCommissionInfo.availableAfterThis>=0?"text-green-400 font-medium":"text-red-400 font-medium",children:["¥",I.userCommissionInfo.availableAfterThis.toFixed(2)]})]})]}):s.jsx("span",{className:"text-gray-500 text-xs",children:"暂无数据"})}),s.jsxs("td",{className:"p-4",children:[F(I.status),I.errorMessage&&s.jsx("p",{className:"text-xs text-red-400 mt-1",children:I.errorMessage})]}),s.jsx("td",{className:"p-4 text-gray-400",children:I.processedAt?new Date(I.processedAt).toLocaleString():"-"}),s.jsx("td",{className:"p-4 text-gray-400",children:I.userConfirmedAt?s.jsxs("span",{className:"text-green-400",title:I.userConfirmedAt,children:["已确认 ",new Date(I.userConfirmedAt).toLocaleString()]}):"-"}),s.jsxs("td",{className:"p-4 text-right",children:[(I.status==="pending"||I.status==="pending_confirm")&&s.jsxs("div",{className:"flex items-center justify-end gap-2",children:[s.jsxs(ne,{size:"sm",onClick:()=>T(I.id),disabled:N===I.id,className:"bg-green-600 hover:bg-green-700 text-white",children:[s.jsx(cf,{className:"w-4 h-4 mr-1"}),"批准"]}),s.jsxs(ne,{size:"sm",variant:"outline",onClick:()=>O(I.id),disabled:N===I.id,className:"border-red-500/50 text-red-400 hover:bg-red-500/10 bg-transparent",children:[s.jsx(or,{className:"w-4 h-4 mr-1"}),"拒绝"]})]}),(I.status==="success"||I.status==="completed")&&I.transactionId&&s.jsx("span",{className:"text-xs text-gray-500 font-mono",children:I.transactionId})]})]},I.id))})]})}),s.jsx(ms,{page:f,totalPages:C,total:v,pageSize:g,onPageChange:m,onPageSizeChange:I=>{y(I),m(1)}})]})})})]})}var Om={exports:{}},Dm={};/** - * @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 s1;function PP(){if(s1)return Dm;s1=1;var t=cd();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,i=t.useEffect,a=t.useLayoutEffect,o=t.useDebugValue;function c(m,g){var y=g(),v=r({inst:{value:y,getSnapshot:g}}),w=v[0].inst,N=v[1];return a(function(){w.value=y,w.getSnapshot=g,u(w)&&N({inst:w})},[m,y,g]),i(function(){return u(w)&&N({inst:w}),m(function(){u(w)&&N({inst:w})})},[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 Dm.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:f,Dm}var i1;function Ak(){return i1||(i1=1,Om.exports=PP()),Om.exports}var Ik=Ak();function On(t){this.content=t}On.prototype={constructor:On,find:function(t){for(var e=0;e>1}};On.from=function(t){if(t instanceof On)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new On(e)};function Rk(t,e,n){for(let r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:n;let i=t.child(r),a=e.child(r);if(i==a){n+=i.nodeSize;continue}if(!i.sameMarkup(a))return n;if(i.isText&&i.text!=a.text){for(let o=0;i.text[o]==a.text[o];o++)n++;return n}if(i.content.size||a.content.size){let o=Rk(i.content,a.content,n+1);if(o!=null)return o}n+=i.nodeSize}}function Pk(t,e,n,r){for(let i=t.childCount,a=e.childCount;;){if(i==0||a==0)return i==a?null:{a:n,b:r};let o=t.child(--i),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(;he&&r(u,i+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,i+f)}c=h}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,i){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?i?typeof i=="function"?i(c):i: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,i=this.content.slice(),a=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),a=1);ae)for(let a=0,o=0;oe&&((on)&&(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),i+=c.nodeSize),o=u}return new ge(r,i)}cutByIndex(e,n){return e==n?ge.empty:e==0&&n==this.content.length?this:new ge(this.content.slice(e,n))}replaceChild(e,n){let r=this.content[e];if(r==n)return this;let i=this.content.slice(),a=this.size+n.nodeSize-r.nodeSize;return i[e]=n,new ge(i,a)}addToStart(e){return new ge([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new ge(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let n=0;nthis.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let n=0,r=0;;n++){let i=this.child(n),a=r+i.nodeSize;if(a>=e)return a==e?Au(n+1,a):Au(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 ge.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new ge(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return ge.empty;let n,r=0;for(let i=0;ithis.type.rank&&(n||(n=e.slice(0,i)),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;nr.type.rank-i.type.rank),n}};Et.none=[];class fh extends Error{}class Re{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=Dk(this.content,e+this.openStart,n);return r&&new Re(r,this.openStart,this.openEnd)}removeBetween(e,n){return new Re(Ok(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 Re.empty;let r=n.openStart||0,i=n.openEnd||0;if(typeof r!="number"||typeof i!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new Re(ge.fromJSON(e,n.content),r,i)}static maxOpen(e,n=!0){let r=0,i=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)i++;return new Re(e,r,i)}}Re.empty=new Re(ge.empty,0,0);function Ok(t,e,n){let{index:r,offset:i}=t.findIndex(e),a=t.maybeChild(r),{index:o,offset:c}=t.findIndex(n);if(i==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(Ok(a.content,e-i-1,n-i-1)))}function Dk(t,e,n,r){let{index:i,offset:a}=t.findIndex(e),o=t.maybeChild(i);if(a==e||o.isText)return r&&!r.canReplace(i,i,n)?null:t.cut(0,e).append(n).append(t.cut(e));let c=Dk(o.content,e-a-1,n,o);return c&&t.replaceChild(i,o.copy(c))}function OP(t,e,n){if(n.openStart>t.depth)throw new fh("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new fh("Inconsistent open depths");return Lk(t,e,n,0)}function Lk(t,e,n,r){let i=t.index(r),a=t.node(r);if(i==e.index(r)&&r=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 i=(e||t).node(n),a=0,o=e?e.index(n):i.childCount;t&&(a=t.index(n),t.depth>n?a++:t.textOffset&&(io(t.nodeAfter,r),a++));for(let c=a;ci&&Lg(t,e,i+1),o=r.depth>i&&Lg(n,r,i+1),c=[];return Dc(null,t,i,c),a&&o&&e.index(i)==n.index(i)?(_k(a,o),io(ao(a,zk(t,e,n,r,i+1)),c)):(a&&io(ao(a,ph(t,e,i+1)),c),Dc(e,n,i,c),o&&io(ao(o,ph(n,r,i+1)),c)),Dc(r,null,i,c),new ge(c)}function ph(t,e,n){let r=[];if(Dc(null,t,n,r),t.depth>n){let i=Lg(t,e,n+1);io(ao(i,ph(t,e,n+1)),r)}return Dc(e,null,n,r),new ge(r)}function DP(t,e){let n=e.depth-t.openStart,i=e.node(n).copy(t.content);for(let a=n-1;a>=0;a--)i=e.node(a).copy(ge.from(i));return{start:i.resolveNoCache(t.openStart+n),end:i.resolveNoCache(i.content.size-t.openEnd-n)}}class Yc{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],i=e.child(n);return r?e.child(n).cut(r):i}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],i=n==0?0:this.path[n*3-1]+1;for(let a=0;a0;n--)if(this.start(n)<=e&&this.end(n)>=e)return n;return 0}blockRange(e=this,n){if(e.pos=0;r--)if(e.pos<=this.end(r)&&(!n||n(this.node(r))))return new mh(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=0&&n<=e.content.size))throw new RangeError("Position "+n+" out of range");let r=[],i=0,a=n;for(let o=e;;){let{index:c,offset:u}=o.content.findIndex(a),h=a-u;if(r.push(o,c,i+u),!h||(o=o.child(c),o.isText))break;a=h-1,i+=u+1}return new Yc(n,r,a)}static resolveCached(e,n){let r=a1.get(e);if(r)for(let a=0;ae&&this.nodesBetween(e,n,a=>(r.isInSet(a.marks)&&(i=!0),!i)),i}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()+")"),$k(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=ge.empty,i=0,a=r.childCount){let o=this.contentMatchAt(e).matchFragment(r,i,a),c=o&&o.matchFragment(this.content,n);if(!c||!c.validEnd)return!1;for(let u=i;un.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 i=ge.fromJSON(e,n.content),a=e.nodeType(n.type).create(n.attrs,i,r);return a.type.checkAttrs(a.attrs),a}};xi.prototype.text=void 0;class gh extends xi{constructor(e,n,r,i){if(super(e,n,null,i),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):$k(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 gh(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new gh(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 $k(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class mo{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new $P(e,n);if(r.next==null)return mo.empty;let i=Fk(r);r.next&&r.err("Unexpected trailing text");let a=KP(UP(i));return qP(a,r),a}matchType(e){for(let n=0;nh.createAndFill()));for(let h=0;h=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 i=0;i{let a=i+(r.validEnd?"*":" ")+" ";for(let o=0;o"+e.indexOf(r.next[o].next);return a}).join(` -`)}}mo.empty=new mo(!0);class $P{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 Fk(t){let e=[];do e.push(FP(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function FP(t){let e=[];do e.push(BP(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function BP(t){let e=WP(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=VP(t,e);else break;return e}function o1(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function VP(t,e){let n=o1(t),r=n;return t.eat(",")&&(t.next!="}"?r=o1(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function HP(t,e){let n=t.nodeTypes,r=n[e];if(r)return[r];let i=[];for(let a in n){let o=n[a];o.isInGroup(e)&&i.push(o)}return i.length==0&&t.err("No node type or group '"+e+"' found"),i}function WP(t){if(t.eat("(")){let e=Fk(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=HP(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 UP(t){let e=[[]];return i(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 i(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;i(h,c=n())}else if(o.type=="star"){let u=n();return r(c,u),i(a(o.expr,u),u),[r(u)]}else if(o.type=="plus"){let u=n();return i(a(o.expr,c),u),i(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{t[o].forEach(({term:c,to:u})=>{if(!c)return;let h;for(let f=0;f{h||i.push([c,h=[]]),h.indexOf(f)==-1&&h.push(f)})})});let a=e[r.join(",")]=new mo(r.indexOf(t.length-1)>-1);for(let o=0;o-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:Hk(this.attrs,e)}create(e=null,n,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new xi(this,this.computeAttrs(e),ge.from(n),Et.setFrom(r))}createChecked(e=null,n,r){return n=ge.from(n),this.checkContent(n),new xi(this,this.computeAttrs(e),n,Et.setFrom(r))}createAndFill(e=null,n,r){if(e=this.computeAttrs(e),n=ge.from(n),n.size){let o=this.contentMatch.fillBefore(n);if(!o)return null;n=o.append(n)}let i=this.contentMatch.matchFragment(n),a=i&&i.fillBefore(ge.empty,!0);return a?new xi(this,e,n.append(a),Et.setFrom(r)):null}validContent(e){let n=this.contentMatch.matchFragment(e);if(!n||!n.validEnd)return!1;for(let r=0;r-1}allowsMarks(e){if(this.markSet==null)return!0;for(let n=0;nr[a]=new Kk(a,n,o));let i=n.spec.topNode||"doc";if(!r[i])throw new RangeError("Schema is missing its top node type ('"+i+"')");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 GP(t,e,n){let r=n.split("|");return i=>{let a=i===null?"null":typeof i;if(r.indexOf(a)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${t}, got ${a}`)}}class JP{constructor(e,n,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?GP(e,n,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class xf{constructor(e,n,r,i){this.name=e,this.rank=n,this.schema=r,this.spec=i,this.attrs=Uk(e,i.attrs),this.excluded=null;let a=Vk(this.attrs);this.instance=a?new Et(this,a):null}create(e=null){return!e&&this.instance?this.instance:new Et(this,Hk(this.attrs,e))}static compile(e,n){let r=Object.create(null),i=0;return e.forEach((a,o)=>r[a]=new xf(a,i++,n,o)),r}removeFromSet(e){for(var n=0;n-1}}class qk{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let n=this.spec={};for(let i in e)n[i]=e[i];n.nodes=On.from(e.nodes),n.marks=On.from(e.marks||{}),this.nodes=c1.compile(this.spec.nodes,this),this.marks=xf.compile(this.spec.marks,this);let r=Object.create(null);for(let i in this.nodes){if(i in this.marks)throw new RangeError(i+" can not be both a node and a mark");let a=this.nodes[i],o=a.spec.content||"",c=a.spec.marks;if(a.contentMatch=r[o]||(r[o]=mo.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?d1(this,c.split(" ")):c==""||!a.inlineContent?[]:null}for(let i in this.marks){let a=this.marks[i],o=a.spec.excludes;a.excluded=o==null?[a]:o==""?[]:d1(this,o.split(" "))}this.nodeFromJSON=i=>xi.fromJSON(this,i),this.markFromJSON=i=>Et.fromJSON(this,i),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,n=null,r,i){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof c1){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,i)}text(e,n){let r=this.nodes.text;return new gh(r,r.defaultAttrs,e,Et.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 d1(t,e){let n=[];for(let r=0;r-1)&&n.push(o=u)}if(!o)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return n}function YP(t){return t.tag!=null}function QP(t){return t.style!=null}class ha{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(i=>{if(YP(i))this.tags.push(i);else if(QP(i)){let a=/[^=]*/.exec(i.style)[0];r.indexOf(a)<0&&r.push(a),this.styles.push(i)}}),this.normalizeLists=!this.tags.some(i=>{if(!/^(ul|ol)\b/.test(i.tag)||!i.node)return!1;let a=e.nodes[i.node];return a.contentMatch.matchType(a)})}parse(e,n={}){let r=new h1(this,n,!1);return r.addAll(e,Et.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new h1(this,n,!0);return r.addAll(e,Et.none,n.from,n.to),Re.maxOpen(r.finish())}matchTag(e,n,r){for(let i=r?this.tags.indexOf(r)+1:0;ie.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(i){let a=i.priority==null?50:i.priority,o=0;for(;o{r(o=f1(o)),o.mark||o.ignore||o.clearMark||(o.mark=i)})}for(let i in e.nodes){let a=e.nodes[i].spec.parseDOM;a&&a.forEach(o=>{r(o=f1(o)),o.node||o.ignore||o.mark||(o.node=i)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new ha(e,ha.schemaRules(e)))}}const Gk={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},XP={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Jk={ol:!0,ul:!0},Qc=1,zg=2,Lc=4;function u1(t,e,n){return e!=null?(e?Qc:0)|(e==="full"?zg:0):t&&t.whitespace=="pre"?Qc|zg:n&~Lc}class Iu{constructor(e,n,r,i,a,o){this.type=e,this.attrs=n,this.marks=r,this.solid=i,this.options=o,this.content=[],this.activeMarks=Et.none,this.match=a||(o&Lc?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(ge.from(e));if(n)this.match=this.type.contentMatch.matchFragment(n);else{let r=this.type.contentMatch,i;return(i=r.findWrapping(e.type))?(this.match=r,i):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&Qc)){let r=this.content[this.content.length-1],i;if(r&&r.isText&&(i=/[ \t\r\n\u000c]+$/.exec(r.text))){let a=r;r.text.length==i[0].length?this.content.pop():this.content[this.content.length-1]=a.withText(a.text.slice(0,a.text.length-i[0].length))}}let n=ge.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(ge.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&&!Gk.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class h1{constructor(e,n,r){this.parser=e,this.options=n,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let i=n.topNode,a,o=u1(null,n.preserveWhitespace,0)|(r?Lc:0);i?a=new Iu(i.type,i.attrs,Et.none,!0,n.topMatch||i.type.contentMatch,o):r?a=new Iu(null,null,Et.none,!0,null,o):a=new Iu(e.schema.topNodeType,null,Et.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,i=this.top,a=i.options&zg?"full":this.localPreserveWS||(i.options&Qc)>0,{schema:o}=this.parser;if(a==="full"||i.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!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,i){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(i)this.addElement(e,r,i);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,i){let a=r||0;for(let o=r?e.childNodes[r]:e.firstChild,c=i==null?null:e.childNodes[i];o!=c;o=o.nextSibling,++a)this.findAtPoint(e,a),this.addDOM(o,n);this.findAtPoint(e,a)}findPlace(e,n,r){let i,a;for(let o=this.open,c=0;o>=0;o--){let u=this.nodes[o],h=u.findWrapping(e);if(h&&(!i||i.length>h.length+c)&&(i=h,a=u,!h.length))break;if(u.solid){if(r)break;c+=2}}if(!i)return null;this.sync(a);for(let o=0;o(o.type?o.type.allowsMarkType(h.type):p1(h.type,e))?(u=h.addToSet(u),!1):!0),this.nodes.push(new Iu(e,n,u,i,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|=Qc)}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 i=r.length-1;i>=0;i--)e+=r[i].nodeSize;n&&e++}return e}findAtPoint(e,n){if(this.find)for(let r=0;r-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let n=e.split("/"),r=this.options.context,i=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),a=-(r?r.depth+1:0)+(i?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&&i?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 ZP(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&Jk.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function eO(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function f1(t){let e={};for(let n in t)e[n]=t[n];return e}function p1(t,e){let n=e.schema.nodes;for(let r in n){let i=n[r];if(!i.allowsMarkType(t))continue;let a=[],o=c=>{a.push(c);for(let u=0;u{if(a.length||o.marks.length){let c=0,u=0;for(;c=0;i--){let a=this.serializeMark(e.marks[i],e.isInline,n);a&&((a.contentDOM||a.dom).appendChild(r),r=a.dom)}return r}serializeMark(e,n,r={}){let i=this.marks[e.type.name];return i&&Yu(_m(r),i(e,n),null,e.attrs)}static renderSpec(e,n,r=null,i){return Yu(e,n,r,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new So(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=m1(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return m1(e.marks)}}function m1(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function _m(t){return t.document||window.document}const g1=new WeakMap;function tO(t){let e=g1.get(t);return e===void 0&&g1.set(t,e=nO(t)),e}function nO(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 i=0;i-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=i.indexOf(" ");o>0&&(n=i.slice(0,o),i=i.slice(o+1));let c,u=n?t.createElementNS(n,i):t.createElement(i),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;mf)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}=Yu(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 Yk=65535,Qk=Math.pow(2,16);function rO(t,e){return t+e*Qk}function x1(t){return t&Yk}function sO(t){return(t-(t&Yk))/Qk}const Xk=1,Zk=2,Qu=4,eS=8;class $g{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&eS)>0}get deletedBefore(){return(this.delInfo&(Xk|Qu))>0}get deletedAfter(){return(this.delInfo&(Zk|Qu))>0}get deletedAcross(){return(this.delInfo&Qu)>0}}class Mr{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&Mr.empty)return Mr.empty}recover(e){let n=0,r=x1(e);if(!this.inverted)for(let i=0;ie)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+i+(g<0?0:f);if(r)return y;let v=e==(n<0?u:m)?null:rO(c/3,e-u),w=e==u?Zk:e==m?Xk:Qu;return(n<0?e!=u:e!=m)&&(w|=eS),new $g(y,w,v)}i+=f-h}return r?e+i:new $g(e+i,0,null)}touches(e,n){let r=0,i=x1(n),a=this.inverted?2:1,o=this.inverted?1:2;for(let c=0;ce)break;let h=this.ranges[c+a],f=u+h;if(e<=f&&c==i*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 i=0,a=0;i=0;n--){let i=e.getMirror(n);this.appendMap(e._maps[n].invert(),i!=null&&i>n?r-i-1:void 0)}}invert(){let e=new Xc;return e.appendMappingInverted(this),e}map(e,n=1){if(this.mirror)return this._map(e,n,!0);for(let r=this.from;ra&&u!o.isAtom||!c.type.allowsMarkType(this.mark.type)?o:o.mark(this.mark.addToSet(o.marks)),i),n.openStart,n.openEnd);return fn.fromReplace(e,this.from,this.to,a)}invert(){return new fs(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 aa(n.pos,r.pos,this.mark)}merge(e){return e instanceof aa&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new aa(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 aa(n.from,n.to,e.markFromJSON(n.mark))}}Xn.jsonID("addMark",aa);class fs extends Xn{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 Re(Xx(n.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),n.openStart,n.openEnd);return fn.fromReplace(e,this.from,this.to,r)}invert(){return new aa(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 fs(n.pos,r.pos,this.mark)}merge(e){return e instanceof fs&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new fs(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 fs(n.from,n.to,e.markFromJSON(n.mark))}}Xn.jsonID("removeMark",fs);class oa extends Xn{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return fn.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return fn.fromReplace(e,this.pos,this.pos+1,new Re(ge.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 i=0;ir.pos?null:new Tn(n.pos,r.pos,i,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 Tn(n.from,n.to,n.gapFrom,n.gapTo,Re.fromJSON(e,n.slice),n.insert,!!n.structure)}}Xn.jsonID("replaceAround",Tn);function Fg(t,e,n){let r=t.resolve(e),i=n-e,a=r.depth;for(;i>0&&a>0&&r.indexAfter(a)==r.node(a).childCount;)a--,i--;if(i>0){let o=r.node(a).maybeChild(r.indexAfter(a));for(;i>0;){if(!o||o.isLeaf)return!0;o=o.firstChild,i--}}return!1}function iO(t,e,n,r){let i=[],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 w=0;wt.step(u)),a.forEach(u=>t.step(u))}function aO(t,e,n,r){let i=[],a=0;t.doc.nodesBetween(e,n,(o,c)=>{if(!o.isInline)return;a++;let u=null;if(r instanceof xf){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;ft.step(new fs(o.from,o.to,o.style)))}function Zx(t,e,n,r=n.contentMatch,i=!0){let a=t.doc.nodeAt(e),o=[],c=e+1;for(let u=0;u=0;u--)t.step(o[u])}function oO(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function $l(t){let n=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let r=t.depth,i=0,a=0;;--r){let o=t.$from.node(r),c=t.$from.index(r)+i,u=t.$to.indexAfter(r)-a;if(rn;v--)w||r.index(v)>0?(w=!0,f=ge.from(r.node(v).copy(f)),m++):u--;let g=ge.empty,y=0;for(let v=a,w=!1;v>n;v--)w||i.after(v+1)=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=ge.from(n[o].type.create(n[o].attrs,r))}let i=e.start,a=e.end;t.step(new Tn(i,a,i,a,new Re(r,0,0),n.length,!0))}function hO(t,e,n,r,i){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 i=="function"?i(o):i;if(o.isTextblock&&!o.hasMarkup(r,u)&&fO(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&&nS(t,o,c,a),Zx(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 Tn(m,g,m+1,g-1,new Re(ge.from(r.create(u,null,o.marks)),0,0),1,!0)),h===!0&&tS(t,o,c,a),!1}})}function tS(t,e,n,r){e.forEach((i,a)=>{if(i.isText){let o,c=/\r?\n|\r/g;for(;o=c.exec(i.text);){let u=t.mapping.slice(r).map(n+1+a+o.index);t.replaceWith(u,u+1,e.type.schema.linebreakReplacement.create())}}})}function nS(t,e,n,r){e.forEach((i,a)=>{if(i.type==i.type.schema.linebreakReplacement){let o=t.mapping.slice(r).map(n+1+a);t.replaceWith(o,o+1,e.type.schema.text(` -`))}})}function fO(t,e,n){let r=t.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,n)}function pO(t,e,n,r,i){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,i||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 Tn(e,e+a.nodeSize,e+1,e+a.nodeSize-1,new Re(ge.from(o),0,0),1,!0))}function yi(t,e,n=1,r){let i=t.resolve(e),a=i.depth-n,o=r&&r[r.length-1]||i.parent;if(a<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!o.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let h=i.depth-1,f=n-2;h>a;h--,f--){let m=i.node(h),g=i.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 w=r&&r[f]||m;if(!m.canReplace(g+1,m.childCount)||!w.type.validContent(y))return!1}let c=i.indexAfter(a),u=r&&r[0];return i.node(a).canReplaceWith(c,c,u?u.type:i.node(a+1).type)}function mO(t,e,n=1,r){let i=t.doc.resolve(e),a=ge.empty,o=ge.empty;for(let c=i.depth,u=i.depth-n,h=n-1;c>u;c--,h--){a=ge.from(i.node(c).copy(a));let f=r&&r[h];o=ge.from(f?f.type.create(f.attrs,o):i.node(c).copy(o))}t.step(new En(e,e,new Re(a.append(o),n,n),!0))}function Sa(t,e){let n=t.resolve(e),r=n.index();return rS(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function gO(t,e){e.content.size||t.type.compatibleContent(e.type);let n=t.contentMatchAt(t.childCount),{linebreakReplacement:r}=t.type.schema;for(let i=0;i0?(a=r.node(i+1),c++,o=r.node(i).maybeChild(c)):(a=r.node(i).maybeChild(c-1),o=r.node(i+1)),a&&!a.isTextblock&&rS(a,o)&&r.node(i).canReplace(c,c+1))return e;if(i==0)break;e=n<0?r.before(i):r.after(i)}}function xO(t,e,n){let r=null,{linebreakReplacement:i}=t.doc.type.schema,a=t.doc.resolve(e-n),o=a.node().type;if(i&&o.inlineContent){let f=o.whitespace=="pre",m=!!o.contentMatch.matchType(i);f&&!m?r=!1:!f&&m&&(r=!0)}let c=t.steps.length;if(r===!1){let f=t.doc.resolve(e+n);nS(t,f.node(),f.before(),c)}o.inlineContent&&Zx(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 En(h,u.map(e+n,-1),Re.empty,!0)),r===!0){let f=t.doc.resolve(h);tS(t,f.node(),f.before(),t.steps.length)}return t}function yO(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 i=r.depth-1;i>=0;i--){let a=r.index(i);if(r.node(i).canReplaceWith(a,a,n))return r.before(i+1);if(a>0)return null}if(r.parentOffset==r.parent.content.size)for(let i=r.depth-1;i>=0;i--){let a=r.indexAfter(i);if(r.node(i).canReplaceWith(a,a,n))return r.after(i+1);if(a=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,i);else{let m=h.contentMatchAt(u).findWrapping(i.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 vf(t,e,n=e,r=Re.empty){if(e==n&&!r.size)return null;let i=t.resolve(e),a=t.resolve(n);return iS(i,a,r)?new En(e,n,r):new vO(i,a,r).fit()}function iS(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}class vO{constructor(e,n,r){this.$from=e,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=ge.empty;for(let i=0;i<=e.depth;i++){let a=e.node(i);this.frontier.push({type:a.type,match:a.contentMatchAt(e.indexAfter(i))})}for(let i=e.depth;i>0;i--)this.placed=ge.from(e.node(i).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,i=this.close(e<0?this.$to:r.doc.resolve(e));if(!i)return null;let a=this.placed,o=r.depth,c=i.depth;for(;o&&c&&a.childCount==1;)a=a.firstChild.content,o--,c--;let u=new Re(a,o,c);return e>-1?new Tn(r.pos,e,this.$to.pos,this.$to.end(),u,n):u.size||r.pos!=this.$to.pos?new En(r.pos,i.pos,u):null}findFittable(){let e=this.unplaced.openStart;for(let n=this.unplaced.content,r=0,i=this.unplaced.openEnd;r1&&(i=0),a.type.spec.isolating&&i<=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 i,a=null;r?(a=$m(this.unplaced.content,r-1).firstChild,i=a.content):i=this.unplaced.content;let o=i.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(ge.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,i=$m(e,n);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new Re(e,n+1,Math.max(r,i.size+n>=e.size-r?n+1:0)),!0)}dropNode(){let{content:e,openStart:n,openEnd:r}=this.unplaced,i=$m(e,n);if(i.childCount<=1&&n>0){let a=e.size-n<=n+i.size;this.unplaced=new Re(Ec(e,n-1,1),n-1,a?n-1:r)}else this.unplaced=new Re(Ec(e,n,1),n,r)}placeNodes({sliceDepth:e,frontierDepth:n,parent:r,inject:i,wrap:a}){for(;this.depth>n;)this.closeFrontierNode();if(a)for(let w=0;w1||u==0||w.content.size)&&(m=N,f.push(aS(w.mark(g.allowedMarks(w.marks)),h==1?u:0,h==c.childCount?y:-1)))}let v=h==c.childCount;v||(y=-1),this.placed=Tc(this.placed,n,ge.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 w=0,N=c;w1&&i==this.$to.end(--r);)++i;return i}findCloseLevel(e){e:for(let n=Math.min(this.depth,e.depth);n>=0;n--){let{match:r,type:i}=this.frontier[n],a=n=0;c--){let{match:u,type:h}=this.frontier[c],f=Fm(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=Tc(this.placed,n.depth,n.fit)),e=n.move;for(let r=n.depth+1;r<=e.depth;r++){let i=e.node(r),a=i.type.contentMatch.fillBefore(i.content,!0,e.index(r));this.openFrontierNode(i.type,i.attrs,a)}return e}openFrontierNode(e,n=null,r){let i=this.frontier[this.depth];i.match=i.match.matchType(e),this.placed=Tc(this.placed,this.depth,ge.from(e.create(n,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(ge.empty,!0);n.childCount&&(this.placed=Tc(this.placed,this.frontier.length,n))}}function Ec(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(Ec(t.firstChild.content,e-1,n)))}function Tc(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(Tc(t.lastChild.content,e-1,n)))}function $m(t,e){for(let n=0;n1&&(r=r.replaceChild(0,aS(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(ge.empty,!0)))),t.copy(r)}function Fm(t,e,n,r,i){let a=t.node(e),o=i?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&&!bO(n,a.content,o)?c:null}function bO(t,e,n){for(let r=n;r0;g--,y--){let v=i.node(g).type.spec;if(v.defining||v.definingAsContext||v.isolating)break;o.indexOf(g)>-1?c=g:i.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=NO(y.type);if(v&&!y.sameMarkup(i.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 w=0;w=0&&(t.replace(e,n,r),!(t.steps.length>m));g--){let y=o[g];y<0||(e=i.before(y),n=a.after(y))}}function oS(t,e,n,r,i){if(er){let a=i.contentMatchAt(0),o=a.fillBefore(t).append(t);t=o.append(a.matchFragment(o).fillBefore(ge.empty,!0))}return t}function jO(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let i=yO(t.doc,e,r.type);i!=null&&(e=n=i)}t.replaceRange(e,n,new Re(ge.from(r),0,0))}function kO(t,e,n){let r=t.doc.resolve(e),i=t.doc.resolve(n),a=lS(r,i);for(let o=0;o0&&(u||r.node(c-1).canReplace(r.index(c-1),i.indexAfter(c-1))))return t.delete(r.before(c),i.after(c))}for(let o=1;o<=r.depth&&o<=i.depth;o++)if(e-r.start(o)==r.depth-o&&n>r.end(o)&&i.end(o)-n!=i.depth-o&&r.start(o-1)==i.start(o-1)&&r.node(o-1).canReplace(r.index(o-1),i.index(o-1)))return t.delete(r.before(o),n);t.delete(e,n)}function lS(t,e){let n=[],r=Math.min(t.depth,e.depth);for(let i=r;i>=0;i--){let a=t.start(i);if(ae.pos+(e.depth-i)||t.node(i).type.spec.isolating||e.node(i).type.spec.isolating)break;(a==e.start(i)||i==t.depth&&i==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&i&&e.start(i-1)==a-1)&&n.push(i)}return n}class bl extends Xn{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 fn.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 i=n.type.create(r,null,n.marks);return fn.fromReplace(e,this.pos,this.pos+1,new Re(ge.from(i),0,n.isLeaf?0:1))}getMap(){return Mr.empty}invert(e){return new bl(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 bl(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 bl(n.pos,n.attr,n.value)}}Xn.jsonID("attr",bl);class Zc extends Xn{constructor(e,n){super(),this.attr=e,this.value=n}apply(e){let n=Object.create(null);for(let i in e.attrs)n[i]=e.attrs[i];n[this.attr]=this.value;let r=e.type.create(n,e.content,e.marks);return fn.ok(r)}getMap(){return Mr.empty}invert(e){return new Zc(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 Zc(n.attr,n.value)}}Xn.jsonID("docAttr",Zc);let kl=class extends Error{};kl=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};kl.prototype=Object.create(Error.prototype);kl.prototype.constructor=kl;kl.prototype.name="TransformError";class t0{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Xc}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new kl(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{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=Re.empty){let i=vf(this.doc,e,n,r);return i&&this.step(i),this}replaceWith(e,n,r){return this.replace(e,n,new Re(ge.from(r),0,0))}delete(e,n){return this.replace(e,n,Re.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return wO(this,e,n,r),this}replaceRangeWith(e,n,r){return jO(this,e,n,r),this}deleteRange(e,n){return kO(this,e,n),this}lift(e,n){return lO(this,e,n),this}join(e,n=1){return xO(this,e,n),this}wrap(e,n){return uO(this,e,n),this}setBlockType(e,n=e,r,i=null){return hO(this,e,n,r,i),this}setNodeMarkup(e,n,r=null,i){return pO(this,e,n,r,i),this}setNodeAttribute(e,n,r){return this.step(new bl(e,n,r)),this}setDocAttribute(e,n){return this.step(new Zc(e,n)),this}addNodeMark(e,n){return this.step(new oa(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 Et)n.isInSet(r.marks)&&this.step(new go(e,n));else{let i=r.marks,a,o=[];for(;a=n.isInSet(i);)o.push(new go(e,a)),i=a.removeFromSet(i);for(let c=o.length-1;c>=0;c--)this.step(o[c])}return this}split(e,n=1,r){return mO(this,e,n,r),this}addMark(e,n,r){return iO(this,e,n,r),this}removeMark(e,n,r){return aO(this,e,n,r),this}clearIncompatible(e,n,r){return Zx(this,e,n,r),this}}const Bm=Object.create(null);class Qe{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new cS(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=0;a--){let o=n<0?ll(e.node(0),e.node(a),e.before(a+1),e.index(a),n,r):ll(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 Ir(e.node(0))}static atStart(e){return ll(e,e,0,0,1)||new Ir(e)}static atEnd(e){return ll(e,e,e.content.size,e.childCount,-1)||new Ir(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Bm[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 Bm)throw new RangeError("Duplicate use of selection JSON ID "+e);return Bm[e]=n,n.prototype.jsonID=e,n}getBookmark(){return Ue.between(this.$anchor,this.$head).getBookmark()}}Qe.prototype.visible=!0;class cS{constructor(e,n){this.$from=e,this.$to=n}}let v1=!1;function b1(t){!v1&&!t.parent.inlineContent&&(v1=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class Ue extends Qe{constructor(e,n=e){b1(e),b1(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 Qe.near(r);let i=e.resolve(n.map(this.anchor));return new Ue(i.parent.inlineContent?i:r,r)}replace(e,n=Re.empty){if(super.replace(e,n),n==Re.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof Ue&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new bf(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 Ue(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){let i=e.resolve(n);return new this(i,r==n?i:e.resolve(r))}static between(e,n,r){let i=e.pos-n.pos;if((!r||i)&&(r=i>=0?1:-1),!n.parent.inlineContent){let a=Qe.findFrom(n,r,!0)||Qe.findFrom(n,-r,!0);if(a)n=a.$head;else return Qe.near(n,r)}return e.parent.inlineContent||(i==0?e=n:(e=(Qe.findFrom(e,-r,!0)||Qe.findFrom(e,r,!0)).$anchor,e.pos0?0:1);i>0?o=0;o+=i){let c=e.child(o);if(c.isAtom){if(!a&&We.isSelectable(c))return We.create(t,n-(i<0?c.nodeSize:0))}else{let u=ll(t,c,n+i,i<0?c.childCount:0,i,a);if(u)return u}n+=c.nodeSize*i}return null}function N1(t,e,n){let r=t.steps.length-1;if(r{o==null&&(o=f)}),t.setSelection(Qe.near(t.doc.resolve(o),n))}const w1=1,Ru=2,j1=4;class CO extends t0{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.curSelectionFor0}setStoredMarks(e){return this.storedMarks=e,this.updated|=Ru,this}ensureMarks(e){return Et.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&Ru)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~Ru,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)||Et.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,n,r){let i=this.doc.type.schema;if(n==null)return e?this.replaceSelectionWith(i.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,i.text(e,a)),!this.selection.empty&&this.selection.to==n+e.length&&this.setSelection(Qe.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|=j1,this}get scrolledIntoView(){return(this.updated&j1)>0}}function k1(t,e){return!e||!t?t:t.bind(e)}class Mc{constructor(e,n,r){this.name=e,this.init=k1(n.init,r),this.apply=k1(n.apply,r)}}const EO=[new Mc("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new Mc("selection",{init(t,e){return t.selection||Qe.atStart(e.doc)},apply(t){return t.selection}}),new Mc("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new Mc("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class Vm{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=EO.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 Mc(r.key,r.spec.state,r))})}}class gl{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;rr.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 i=e[r],a=i.spec.state;a&&a.toJSON&&(n[r]=a.toJSON.call(i,this[i.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 i=new Vm(e.schema,e.plugins),a=new gl(i);return i.fields.forEach(o=>{if(o.name=="doc")a.doc=xi.fromJSON(e.schema,n.doc);else if(o.name=="selection")a.selection=Qe.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 dS(t,e,n){for(let r in t){let i=t[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=dS(i,e,{})),n[r]=i}return n}class Dt{constructor(e){this.spec=e,this.props={},e.props&&dS(e.props,this,this.props),this.key=e.key?e.key.key:uS("plugin")}getState(e){return e[this.key]}}const Hm=Object.create(null);function uS(t){return t in Hm?t+"$"+ ++Hm[t]:(Hm[t]=0,t+"$")}class Ht{constructor(e="key"){this.key=uS(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const r0=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function hS(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const fS=(t,e,n)=>{let r=hS(t,n);if(!r)return!1;let i=s0(r);if(!i){let o=r.blockRange(),c=o&&$l(o);return c==null?!1:(e&&e(t.tr.lift(o,c).scrollIntoView()),!0)}let a=i.nodeBefore;if(wS(t,i,e,-1))return!0;if(r.parent.content.size==0&&(Sl(a,"end")||We.isSelectable(a)))for(let o=r.depth;;o--){let c=vf(t.doc,r.before(o),r.after(o),Re.empty);if(c&&c.slice.size1)break}return a.isAtom&&i.depth==r.depth-1?(e&&e(t.tr.delete(i.pos-a.nodeSize,i.pos).scrollIntoView()),!0):!1},TO=(t,e,n)=>{let r=hS(t,n);if(!r)return!1;let i=s0(r);return i?pS(t,i,e):!1},MO=(t,e,n)=>{let r=gS(t,n);if(!r)return!1;let i=i0(r);return i?pS(t,i,e):!1};function pS(t,e,n){let r=e.nodeBefore,i=r,a=e.pos-1;for(;!i.isTextblock;a--){if(i.type.spec.isolating)return!1;let f=i.lastChild;if(!f)return!1;i=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=vf(t.doc,a,u,Re.empty);if(!h||h.from!=a||h instanceof En&&h.slice.size>=u-a)return!1;if(n){let f=t.tr.step(h);f.setSelection(Ue.create(f.doc,a)),n(f.scrollIntoView())}return!0}function Sl(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 mS=(t,e,n)=>{let{$head:r,empty:i}=t.selection,a=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",t):r.parentOffset>0)return!1;a=s0(r)}let o=a&&a.nodeBefore;return!o||!We.isSelectable(o)?!1:(e&&e(t.tr.setSelection(We.create(t.doc,a.pos-o.nodeSize)).scrollIntoView()),!0)};function s0(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 gS(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset{let r=gS(t,n);if(!r)return!1;let i=i0(r);if(!i)return!1;let a=i.nodeAfter;if(wS(t,i,e,1))return!0;if(r.parent.content.size==0&&(Sl(a,"start")||We.isSelectable(a))){let o=vf(t.doc,r.before(),r.after(),Re.empty);if(o&&o.slice.size{let{$head:r,empty:i}=t.selection,a=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",t):r.parentOffset=0;e--){let n=t.node(e);if(t.index(e)+1{let n=t.selection,r=n instanceof We,i;if(r){if(n.node.isTextblock||!Sa(t.doc,n.from))return!1;i=n.from}else if(i=yf(t.doc,n.from,-1),i==null)return!1;if(e){let a=t.tr.join(i);r&&a.setSelection(We.create(a.doc,i-t.doc.resolve(i).nodeBefore.nodeSize)),e(a.scrollIntoView())}return!0},IO=(t,e)=>{let n=t.selection,r;if(n instanceof We){if(n.node.isTextblock||!Sa(t.doc,n.to))return!1;r=n.to}else if(r=yf(t.doc,n.to,1),r==null)return!1;return e&&e(t.tr.join(r).scrollIntoView()),!0},RO=(t,e)=>{let{$from:n,$to:r}=t.selection,i=n.blockRange(r),a=i&&$l(i);return a==null?!1:(e&&e(t.tr.lift(i,a).scrollIntoView()),!0)},vS=(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 a0(t){for(let e=0;e{let{$head:n,$anchor:r}=t.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let i=n.node(-1),a=n.indexAfter(-1),o=a0(i.contentMatchAt(a));if(!o||!i.canReplaceWith(a,a,o))return!1;if(e){let c=n.after(),u=t.tr.replaceWith(c,c,o.createAndFill());u.setSelection(Qe.near(u.doc.resolve(c),1)),e(u.scrollIntoView())}return!0},bS=(t,e)=>{let n=t.selection,{$from:r,$to:i}=n;if(n instanceof Ir||r.parent.inlineContent||i.parent.inlineContent)return!1;let a=a0(i.parent.contentMatchAt(i.indexAfter()));if(!a||!a.isTextblock)return!1;if(e){let o=(!r.parentOffset&&i.index(){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(yi(t.doc,a))return e&&e(t.tr.split(a).scrollIntoView()),!0}let r=n.blockRange(),i=r&&$l(r);return i==null?!1:(e&&e(t.tr.lift(r,i).scrollIntoView()),!0)};function OO(t){return(e,n)=>{let{$from:r,$to:i}=e.selection;if(e.selection instanceof We&&e.selection.node.isBlock)return!r.parentOffset||!yi(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=a0(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 Ue||e.selection instanceof Ir)&&f.deleteSelection();let m=f.mapping.map(r.pos),g=yi(f.doc,m,a.length,a);if(g||(a[0]=c?{type:c}:null,g=yi(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 DO=OO(),LO=(t,e)=>{let{$from:n,to:r}=t.selection,i,a=n.sharedDepth(r);return a==0?!1:(i=n.before(a),e&&e(t.tr.setSelection(We.create(t.doc,i))),!0)};function _O(t,e,n){let r=e.nodeBefore,i=e.nodeAfter,a=e.index();return!r||!i||!r.type.compatibleContent(i.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)||!(i.isTextblock||Sa(t.doc,e.pos))?!1:(n&&n(t.tr.join(e.pos).scrollIntoView()),!0)}function wS(t,e,n,r){let i=e.nodeBefore,a=e.nodeAfter,o,c,u=i.type.spec.isolating||a.type.spec.isolating;if(!u&&_O(t,e,n))return!0;let h=!u&&e.parent.canReplace(e.index(),e.index()+1);if(h&&(o=(c=i.contentMatchAt(i.childCount)).findWrapping(a.type))&&c.matchType(o[0]||a.type).validEnd){if(n){let y=e.pos+a.nodeSize,v=ge.empty;for(let k=o.length-1;k>=0;k--)v=ge.from(o[k].create(null,v));v=ge.from(i.copy(v));let w=t.tr.step(new Tn(e.pos-1,y,e.pos,y,new Re(v,1,0),o.length,!0)),N=w.doc.resolve(y+2*o.length);N.nodeAfter&&N.nodeAfter.type==i.type&&Sa(w.doc,N.pos)&&w.join(N.pos),n(w.scrollIntoView())}return!0}let f=a.type.spec.isolating||r>0&&u?null:Qe.findFrom(e,1),m=f&&f.$from.blockRange(f.$to),g=m&&$l(m);if(g!=null&&g>=e.depth)return n&&n(t.tr.lift(m,g).scrollIntoView()),!0;if(h&&Sl(a,"start",!0)&&Sl(i,"end")){let y=i,v=[];for(;v.push(y),!y.isTextblock;)y=y.lastChild;let w=a,N=1;for(;!w.isTextblock;w=w.firstChild)N++;if(y.canReplace(y.childCount,y.childCount,w.content)){if(n){let k=ge.empty;for(let C=v.length-1;C>=0;C--)k=ge.from(v[C].copy(k));let E=t.tr.step(new Tn(e.pos-v.length,e.pos+a.nodeSize,e.pos+N,e.pos+a.nodeSize-N,new Re(k,v.length,0),0,!0));n(E.scrollIntoView())}return!0}}return!1}function jS(t){return function(e,n){let r=e.selection,i=t<0?r.$from:r.$to,a=i.depth;for(;i.node(a).isInline;){if(!a)return!1;a--}return i.node(a).isTextblock?(n&&n(e.tr.setSelection(Ue.create(e.doc,t<0?i.start(a):i.end(a)))),!0):!1}}const zO=jS(-1),$O=jS(1);function FO(t,e=null){return function(n,r){let{$from:i,$to:a}=n.selection,o=i.blockRange(a),c=o&&e0(o,t,e);return c?(r&&r(n.tr.wrap(o,c).scrollIntoView()),!0):!1}}function S1(t,e=null){return function(n,r){let i=!1;for(let a=0;a{if(i)return!1;if(!(!u.isTextblock||u.hasMarkup(t,e)))if(u.type==t)i=!0;else{let f=n.doc.resolve(h),m=f.index();i=f.parent.canReplaceWith(m,m+1,t)}})}if(!i)return!1;if(r){let a=n.tr;for(let o=0;o=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 mh(u,u,e.depth),e.endIndex=0;f--)a=ge.from(n[f].type.create(n[f].attrs,a));t.step(new Tn(e.start-(r?2:0),e.end,e.start,e.end,new Re(a,0,0),n.length,!0));let o=0;for(let f=0;fo.childCount>0&&o.firstChild.type==t);return a?n?r.node(a.depth-1).type==t?UO(e,n,t,a):KO(e,n,a):!0:!1}}function UO(t,e,n,r){let i=t.tr,a=r.end,o=r.$to.end(r.depth);aw;v--)y-=i.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==i.childCount,h=a.node(-1),f=a.index(-1);if(!h.canReplace(f+(c?0:1),f+1,o.content.append(u?ge.empty:ge.from(i))))return!1;let m=a.pos,g=m+o.nodeSize;return r.step(new Tn(m-(c?1:0),g+(u?1:0),m+1,g-1,new Re((c?ge.empty:ge.from(i.copy(ge.empty))).append(u?ge.empty:ge.from(i.copy(ge.empty))),c?0:1,u?0:1),c?0:1)),e(r.scrollIntoView()),!0}function qO(t){return function(e,n){let{$from:r,$to:i}=e.selection,a=r.blockRange(i,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=ge.from(h?t.create():null),m=new Re(ge.from(t.create(null,ge.from(c.type.create(null,f)))),h?3:1,0),g=a.start,y=a.end;n(e.tr.step(new Tn(g-(h?3:1),y,g,y,m,1,!0)).scrollIntoView())}return!0}}const Ln=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},Cl=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let Bg=null;const pi=function(t,e,n){let r=Bg||(Bg=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},GO=function(){Bg=null},xo=function(t,e,n,r){return n&&(C1(t,e,n,r,-1)||C1(t,e,n,r,1))},JO=/^(img|br|input|textarea|hr)$/i;function C1(t,e,n,r,i){for(var a;;){if(t==n&&e==r)return!0;if(e==(i<0?0:qr(t))){let o=t.parentNode;if(!o||o.nodeType!=1||pd(t)||JO.test(t.nodeName)||t.contentEditable=="false")return!1;e=Ln(t)+(i<0?0:1),t=o}else if(t.nodeType==1){let o=t.childNodes[e+(i<0?-1:0)];if(o.nodeType==1&&o.contentEditable=="false")if(!((a=o.pmViewDesc)===null||a===void 0)&&a.ignoreForSelection)e+=i;else return!1;else t=o,e=i<0?qr(t):0}else return!1}}function qr(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function YO(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=qr(t)}else if(t.parentNode&&!pd(t))e=Ln(t),t=t.parentNode;else return null}}function QO(t,e){for(;;){if(t.nodeType==3&&e2),Kr=El||(zs?/Mac/.test(zs.platform):!1),CS=zs?/Win/.test(zs.platform):!1,gi=/Android \d/.test(Ca),md=!!E1&&"webkitFontSmoothing"in E1.documentElement.style,tD=md?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function nD(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 ci(t,e){return typeof t=="number"?t:t[e]}function rD(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 T1(t,e,n){let r=t.someProp("scrollThreshold")||0,i=t.someProp("scrollMargin")||5,a=t.dom.ownerDocument;for(let o=n||t.dom;o;){if(o.nodeType!=1){o=Cl(o);continue}let c=o,u=c==a.body,h=u?nD(a):rD(c),f=0,m=0;if(e.toph.bottom-ci(r,"bottom")&&(m=e.bottom-e.top>h.bottom-h.top?e.top+ci(i,"top")-h.top:e.bottom-h.bottom+ci(i,"bottom")),e.lefth.right-ci(r,"right")&&(f=e.right-h.right+ci(i,"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 w=c.scrollLeft-y,N=c.scrollTop-v;e={left:e.left-w,top:e.top-N,right:e.right-w,bottom:e.bottom-N}}let g=u?"fixed":getComputedStyle(o).position;if(/^(fixed|sticky)$/.test(g))break;o=g=="absolute"?o.offsetParent:Cl(o)}}function sD(t){let e=t.dom.getBoundingClientRect(),n=Math.max(0,e.top),r,i;for(let a=(e.left+e.right)/2,o=n+1;o=n-20){r=c,i=u.top;break}}return{refDOM:r,refTop:i,stack:ES(t.dom)}}function ES(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=Cl(r));return e}function iD({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;TS(n,r==0?0:r-e)}function TS(t,e){for(let n=0;n=c){o=Math.max(v.bottom,o),c=Math.min(v.top,c);let w=v.left>e.left?v.left-e.left:v.right=(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,i=h,r=0),n&&n.nodeType==3?oD(n,i):!n||r&&n.nodeType==1?{node:t,offset:a}:MS(n,i)}function oD(t,e){let n=t.nodeValue.length,r=document.createRange(),i;for(let a=0;a=(o.left+o.right)/2?1:0)};break}}return r.detach(),i||{node:t,offset:0}}function l0(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function lD(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left(o.left+o.right)/2?1:-1}return t.docView.posFromDOM(r,i,a)}function dD(t,e,n,r){let i=-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?i=c.posBefore:(!o&&u.right-1?i:t.docView.posFromDOM(e,n,-1)}function AS(t,e,n){let r=t.childNodes.length;if(r&&n.tope.top&&i++}let h;md&&i&&r.nodeType==1&&(h=r.childNodes[i-1]).nodeType==1&&h.contentEditable=="false"&&h.getBoundingClientRect().top>=e.top&&i--,r==t.dom&&i==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?c=t.state.doc.content.size:(i==0||r.nodeType!=1||r.childNodes[i-1].nodeName!="BR")&&(c=dD(t,r,i,e))}c==null&&(c=cD(t,o,e));let u=t.docView.nearestDesc(o,!0);return{pos:c,inside:u?u.posAtStart-u.border:-1}}function M1(t){return t.top=0&&i==r.nodeValue.length?(u--,f=1):n<0?u--:h++,jc(Qi(pi(r,u,h),f),f<0)}if(!t.state.doc.resolve(e-(a||0)).parent.inlineContent){if(a==null&&i&&(n<0||i==qr(r))){let u=r.childNodes[i-1];if(u.nodeType==1)return Wm(u.getBoundingClientRect(),!1)}if(a==null&&i=0)}if(a==null&&i&&(n<0||i==qr(r))){let u=r.childNodes[i-1],h=u.nodeType==3?pi(u,qr(u)-(o?0:1)):u.nodeType==1&&(u.nodeName!="BR"||!u.nextSibling)?u:null;if(h)return jc(Qi(h,1),!1)}if(a==null&&i=0)}function jc(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 Wm(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 RS(t,e,n){let r=t.state,i=t.root.activeElement;r!=e&&t.updateState(e),i!=t.dom&&t.focus();try{return n()}finally{r!=e&&t.updateState(r),i!=t.dom&&i&&i.focus()}}function fD(t,e,n){let r=e.selection,i=n=="up"?r.$from:r.$to;return RS(t,e,()=>{let{node:a}=t.docView.domFromPos(i.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=IS(t,i.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=pi(c,0,c.nodeValue.length).getClientRects();else continue;for(let h=0;hf.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 pD=/[\u0590-\u08ac]/;function mD(t,e,n){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,a=!i,o=i==r.parent.content.size,c=t.domSelection();return c?!pD.test(r.parent.textContent)||!c.modify?n=="left"||n=="backward"?a:o:RS(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:w}=t.domSelectionRange(),N=v&&!y.contains(v.nodeType==1?v:v.parentNode)||u==v&&h==w;try{c.collapse(f,m),u&&(u!=f||h!=m)&&c.extend&&c.extend(u,h)}catch{}return g!=null&&(c.caretBidiLevel=g),N}):r.pos==r.start()||r.pos==r.end()}let A1=null,I1=null,R1=!1;function gD(t,e,n){return A1==e&&I1==n?R1:(A1=e,I1=n,R1=n=="up"||n=="down"?fD(t,e,n):mD(t,e,n))}const Yr=0,P1=1,eo=2,$s=3;class gd{constructor(e,n,r,i){this.parent=e,this.children=n,this.dom=r,this.contentDOM=i,this.dirty=Yr,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;nLn(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))i=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(n==0)for(let a=e;;a=a.parentNode){if(a==this.dom){i=!1;break}if(a.previousSibling)break}if(i==null&&n==e.childNodes.length)for(let a=e;;a=a.parentNode){if(a==this.dom){i=!0;break}if(a.nextSibling)break}}return i??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,n=!1){for(let r=!0,i=e;i;i=i.parentNode){let a=this.getDesc(i),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 i=e;i;i=i.parentNode){let a=this.getDesc(i);if(a)return a.localPosFromDOM(e,n,r)}return-1}descAt(e){for(let n=0,r=0;ne||o instanceof OS){i=e-a;break}a=c}if(i)return this.children[r].domFromPos(i-this.children[r].border,n);for(let a;r&&!(a=this.children[r-1]).size&&a instanceof PS&&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?Ln(a.dom)+1:0}}else{let a,o=!0;for(;a=r=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)){i=Ln(g.dom)+1;break}e-=g.size}i==-1&&(i=0)}if(i>-1&&(h>n||c==this.children.length-1)){n=h;for(let f=c+1;fv&&on){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,i=0;i=r:er){let c=r+a.border,u=o-a.border;if(e>=c&&n<=u){this.dirty=e==r||n==o?eo:P1,e==c&&n==u&&(a.contentLost||a.dom.parentNode!=this.contentDOM)?a.dirty=$s:a.markDirty(e-c,n-c);return}else a.dirty=a.dom==a.contentDOM&&a.dom.parentNode==this.contentDOM&&!a.children.length?eo:$s}r=o}this.dirty=eo}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?eo:P1;n.dirty{if(!a)return i;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==Yr&&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 xD extends gd{constructor(e,n,r,i){super(e,[],n,null),this.textDOM=r,this.text=i}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 yo extends gd{constructor(e,n,r,i,a){super(e,[],r,i),this.mark=n,this.spec=a}static create(e,n,r,i){let a=i.nodeViews[n.type.name],o=a&&a(n,i,r);return(!o||!o.dom)&&(o=So.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new yo(e,n,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty&$s||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=$s&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=Yr){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty0&&(a=Kg(a,0,e,r));for(let c=0;c{if(!u)return o;if(u.parent)return u.parent.posBeforeChild(u)},r,i),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}=So.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=_S(f,r,n),h?u=new yD(e,n,r,i,f,m||null,g,h,a,o+1):n.isText?new wf(e,n,r,i,f,g,a):new pa(e,n,r,i,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=()=>ge.empty)}return e}matchesNode(e,n,r){return this.dirty==Yr&&e.eq(this.node)&&xh(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,i=n,a=e.composing?this.localCompositionInfo(e,n):null,o=a&&a.pos>-1?a:null,c=a&&a.pos<0,u=new bD(this,o&&o.node,e);jD(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?Et.none:this.node.child(f).marks,r,e,f),u.placeWidget(h,e,i)},(h,f,m,g)=>{u.syncToMarks(h.marks,r,e,g);let y;u.findNodeMatch(h,f,m,g)||c&&e.state.selection.from>i&&e.state.selection.to-1&&u.updateNodeAt(h,f,m,y,e)||u.updateNextNode(h,f,m,e,g,i)||u.addNode(h,f,m,e,i),i+=h.nodeSize}),u.syncToMarks([],r,e,0),this.node.isTextblock&&u.addTextblockHacks(),u.destroyRest(),(u.changed||this.dirty==eo)&&(o&&this.protectLocalComposition(e,o),DS(this.contentDOM,this.children,e),El&&kD(this.dom))}localCompositionInfo(e,n){let{from:r,to:i}=e.state.selection;if(!(e.state.selection instanceof Ue)||rn+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=SD(this.node.content,o,r-n,i-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:i}){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 xD(this,a,n,i);e.input.compositionNodes.push(o),this.children=Kg(this.children,r,r+i.length,e,o)}update(e,n,r,i){return this.dirty==$s||!e.sameMarkup(this.node)?!1:(this.updateInner(e,n,r,i),!0)}updateInner(e,n,r,i){this.updateOuterDeco(n),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(i,this.posAtStart),this.dirty=Yr}updateOuterDeco(e){if(xh(e,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=LS(this.dom,this.nodeDOM,Ug(this.outerDeco,this.node,n),Ug(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 O1(t,e,n,r,i){_S(r,e,t);let a=new pa(void 0,t,e,n,r,r,r,i,0);return a.contentDOM&&a.updateChildren(i,0),a}class wf extends pa{constructor(e,n,r,i,a,o,c){super(e,n,r,i,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,i){return this.dirty==$s||this.dirty!=Yr&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=Yr||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,i.trackWrites==this.nodeDOM&&(i.trackWrites=null)),this.node=e,this.dirty=Yr,!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 i=this.node.cut(e,n),a=document.createTextNode(i.text);return new wf(this.parent,i,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=$s)}get domAtom(){return!1}isText(e){return this.node.text==e}}class OS extends gd{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Yr&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class yD extends pa{constructor(e,n,r,i,a,o,c,u,h,f){super(e,n,r,i,a,o,c,h,f),this.spec=u}update(e,n,r,i){if(this.dirty==$s)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,i),a}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,n,r,i)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,n,r,i){this.spec.setSelection?this.spec.setSelection(e,n,r.root):super.setSelection(e,n,r,i)}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 DS(t,e,n){let r=t.firstChild,i=!1;for(let a=0;a>1,c=Math.min(o,e.length);for(;a-1)u>this.index&&(this.changed=!0,this.destroyBetween(this.index,u)),this.top=this.top.children[this.index];else{let f=yo.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,i){let a=-1,o;if(i>=this.preMatch.index&&(o=this.preMatch.matches[i-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);c0;){let c;for(;;)if(r){let h=n.children[r-1];if(h instanceof yo)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(i-1))break;--i,a.set(c,i),o.push(c)}}return{index:i,matched:a,matches:o.reverse()}}function wD(t,e){return t.type.side-e.type.side}function jD(t,e,n,r){let i=e.locals(t),a=0;if(i.length==0){for(let h=0;ha;)c.push(i[o++]);let v=a+g.nodeSize;if(g.isText){let N=v;o!N.inline):c.slice();r(g,w,e.forChild(a,g),y),a=v}}function kD(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 SD(t,e,n,r){for(let i=0,a=0;i=n){if(a>=r&&u.slice(r-e.length-c,r-c)==e)return r-e.length;let h=c=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 Kg(t,e,n,r,i){let a=[];for(let o=0,c=0;o=n||f<=e?a.push(u):(hn&&a.push(u.slice(n-h,u.size,r)))}return a}function c0(t,e=null){let n=t.domSelectionRange(),r=t.state.doc;if(!n.focusNode)return null;let i=t.docView.nearestDesc(n.focusNode),a=i&&i.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;i&&!i.node;)i=i.parent;let m=i.node;if(i&&m.isAtom&&We.isSelectable(m)&&i.parent&&!(m.isInline&&XO(n.focusNode,n.focusOffset,i.dom))){let g=i.posBefore;h=new We(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.anchorNode!=r||n.anchorOffset!=i)&&(e.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout(()=>{(!zS(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function ED(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,r=n.nodeName=="IMG";r?e.collapse(n.parentNode,Ln(n)+1):e.collapse(n,0),!r&&!t.state.selection.visible&&vr&&fa<=11&&(n.disabled=!0,n.disabled=!1)}function $S(t,e){if(e instanceof We){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&($1(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else $1(t)}function $1(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function d0(t,e,n,r){return t.someProp("createSelectionBetween",i=>i(t,e,n))||Ue.between(e,n,r)}function F1(t){return t.editable&&!t.hasFocus()?!1:FS(t)}function FS(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 TD(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return xo(e.node,e.offset,n.anchorNode,n.anchorOffset)}function qg(t,e){let{$anchor:n,$head:r}=t.selection,i=e>0?n.max(r):n.min(r),a=i.parent.inlineContent?i.depth?t.doc.resolve(e>0?i.after():i.before()):null:i;return a&&Qe.findFrom(a,e)}function Xi(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function B1(t,e,n){let r=t.state.selection;if(r instanceof Ue)if(n.indexOf("s")>-1){let{$head:i}=r,a=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter;if(!a||a.isText||!a.isLeaf)return!1;let o=t.state.doc.resolve(i.pos+a.nodeSize*(e<0?-1:1));return Xi(t,new Ue(r.$anchor,o))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let i=qg(t.state,e);return i&&i instanceof We?Xi(t,i):!1}else if(!(Kr&&n.indexOf("m")>-1)){let i=r.$head,a=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter,o;if(!a||a.isText)return!1;let c=e<0?i.pos-a.nodeSize:i.pos;return a.isAtom||(o=t.docView.descAt(c))&&!o.contentDOM?We.isSelectable(a)?Xi(t,new We(e<0?t.state.doc.resolve(i.pos-a.nodeSize):i)):md?Xi(t,new Ue(t.state.doc.resolve(e<0?c:c+a.nodeSize))):!1:!1}}else return!1;else{if(r instanceof We&&r.node.isInline)return Xi(t,new Ue(e>0?r.$to:r.$from));{let i=qg(t.state,e);return i?Xi(t,i):!1}}}function yh(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function zc(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function ol(t,e){return e<0?MD(t):AD(t)}function MD(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i,a,o=!1;for(Jr&&n.nodeType==1&&r0){if(n.nodeType!=1)break;{let c=n.childNodes[r-1];if(zc(c,-1))i=n,a=--r;else if(c.nodeType==3)n=c,r=n.nodeValue.length;else break}}else{if(BS(n))break;{let c=n.previousSibling;for(;c&&zc(c,-1);)i=n.parentNode,a=Ln(c),c=c.previousSibling;if(c)n=c,r=yh(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}o?Gg(t,n,r):i&&Gg(t,i,a)}function AD(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i=yh(n),a,o;for(;;)if(r{t.state==i&&vi(t)},50)}function V1(t,e){let n=t.state.doc.resolve(e);if(!(zn||CS)&&n.parent.inlineContent){let i=t.coordsAtPos(e);if(e>n.start()){let a=t.coordsAtPos(e-1),o=(a.top+a.bottom)/2;if(o>i.top&&o1)return a.lefti.top&&o1)return a.left>i.left?"ltr":"rtl"}}return getComputedStyle(t.dom).direction=="rtl"?"rtl":"ltr"}function H1(t,e,n){let r=t.state.selection;if(r instanceof Ue&&!r.empty||n.indexOf("s")>-1||Kr&&n.indexOf("m")>-1)return!1;let{$from:i,$to:a}=r;if(!i.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let o=qg(t.state,e);if(o&&o instanceof We)return Xi(t,o)}if(!i.parent.inlineContent){let o=e<0?i:a,c=r instanceof Ir?Qe.near(o,e):Qe.findFrom(o,e);return c?Xi(t,c):!1}return!1}function W1(t,e){if(!(t.state.selection instanceof Ue))return!0;let{$head:n,$anchor:r,empty:i}=t.state.selection;if(!n.sameParent(r))return!0;if(!i)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 U1(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function PD(t){if(!Yn||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;U1(t,r,"true"),setTimeout(()=>U1(t,r,"false"),20)}return!1}function OD(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function DD(t,e){let n=e.keyCode,r=OD(e);if(n==8||Kr&&n==72&&r=="c")return W1(t,-1)||ol(t,-1);if(n==46&&!e.shiftKey||Kr&&n==68&&r=="c")return W1(t,1)||ol(t,1);if(n==13||n==27)return!0;if(n==37||Kr&&n==66&&r=="c"){let i=n==37?V1(t,t.state.selection.from)=="ltr"?-1:1:-1;return B1(t,i,r)||ol(t,i)}else if(n==39||Kr&&n==70&&r=="c"){let i=n==39?V1(t,t.state.selection.from)=="ltr"?1:-1:1;return B1(t,i,r)||ol(t,i)}else{if(n==38||Kr&&n==80&&r=="c")return H1(t,-1,r)||ol(t,-1);if(n==40||Kr&&n==78&&r=="c")return PD(t)||H1(t,1,r)||ol(t,1);if(r==(Kr?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function u0(t,e){t.someProp("transformCopied",y=>{e=y(e,t)});let n=[],{content:r,openStart:i,openEnd:a}=e;for(;i>1&&a>1&&r.childCount==1&&r.firstChild.childCount==1;){i--,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")||So.fromSchema(t.state.schema),c=qS(),u=c.createElement("div");u.appendChild(o.serializeFragment(r,{document:c}));let h=u.firstChild,f,m=0;for(;h&&h.nodeType==1&&(f=KS[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",`${i} ${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 VS(t,e,n,r,i){let a=i.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 Re(ge.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,i,r,t));if(m)c=m;else{let g=i.marks(),{schema:y}=t.state,v=So.fromSchema(y);o=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(w=>{let N=o.appendChild(document.createElement("p"));w&&N.appendChild(v.serializeNode(y.text(w,g)))})}}else t.someProp("transformPastedHTML",m=>{n=m(n,t)}),o=$D(n),md&&FD(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")||ha.fromSchema(t.state.schema)).parseSlice(o,{preserveWhitespace:!!(u||f),context:i,ruleFromNode(g){return g.nodeName=="BR"&&!g.nextSibling&&g.parentNode&&!LD.test(g.parentNode.nodeName)?{ignore:!0}:null}})),f)c=BD(K1(c,+f[1],+f[2]),f[4]);else if(c=Re.maxOpen(_D(c.content,i),!0),c.openStart||c.openEnd){let m=0,g=0;for(let y=c.content.firstChild;m{c=m(c,t,u)}),c}const LD=/^(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 _D(t,e){if(t.childCount<2)return t;for(let n=e.depth;n>=0;n--){let i=e.node(n).contentMatchAt(e.index(n)),a,o=[];if(t.forEach(c=>{if(!o)return;let u=i.findWrapping(c.type),h;if(!u)return o=null;if(h=o.length&&a.length&&WS(u,a,c,o[o.length-1],0))o[o.length-1]=h;else{o.length&&(o[o.length-1]=US(o[o.length-1],a.length));let f=HS(c,u);o.push(f),i=i.matchType(f.type),a=u}}),o)return ge.from(o)}return t}function HS(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,ge.from(t));return t}function WS(t,e,n,r,i){if(i1&&(a=0),i=n&&(c=e<0?o.contentMatchAt(0).fillBefore(c,a<=i).append(c):c.append(o.contentMatchAt(o.childCount).fillBefore(ge.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,o.copy(c))}function K1(t,e,n){return en})),Km.createHTML(t)):t}function $D(t){let e=/^(\s*]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=qS().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(t),i;if((i=r&&KS[r[1].toLowerCase()])&&(t=i.map(a=>"<"+a+">").join("")+t+i.map(a=>"").reverse().join("")),n.innerHTML=zD(t),i)for(let a=0;a=0;c-=2){let u=n.nodes[r[c]];if(!u||u.hasRequiredAttrs())break;i=ge.from(u.create(r[c+1],i)),a++,o++}return new Re(i,a,o)}const lr={},cr={},VD={touchstart:!0,touchmove:!0};class HD{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 WD(t){for(let e in lr){let n=lr[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{KD(t,r)&&!h0(t,r)&&(t.editable||!(r.type in cr))&&n(t,r)},VD[e]?{passive:!0}:void 0)}Yn&&t.dom.addEventListener("input",()=>null),Yg(t)}function la(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function UD(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 Yg(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>h0(t,r))})}function h0(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function KD(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 qD(t,e){!h0(t,e)&&lr[e.type]&&(t.editable||!(e.type in cr))&&lr[e.type](t,e)}cr.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!JS(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(gi&&zn&&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",i=>i(t,Qa(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||DD(t,n)?n.preventDefault():la(t,"key")};cr.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};cr.keypress=(t,e)=>{let n=e;if(JS(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||Kr&&n.metaKey)return;if(t.someProp("handleKeyPress",i=>i(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof Ue)||!r.$from.sameParent(r.$to)){let i=String.fromCharCode(n.charCode),a=()=>t.state.tr.insertText(i).scrollIntoView();!/[\r\n]/.test(i)&&!t.someProp("handleTextInput",o=>o(t,r.$from.pos,r.$to.pos,i,a))&&t.dispatch(a()),n.preventDefault()}};function jf(t){return{left:t.clientX,top:t.clientY}}function GD(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function f0(t,e,n,r,i){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),i,!0):c(t,n,a.node(o),a.before(o),i,!1)))return!0;return!1}function Nl(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 JD(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&We.isSelectable(r)?(Nl(t,new We(n)),!0):!1}function YD(t,e){if(e==-1)return!1;let n=t.state.selection,r,i;n instanceof We&&(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(We.isSelectable(c)){r&&n.$from.depth>0&&o>=n.$from.depth&&a.before(n.$from.depth+1)==n.$from.pos?i=a.before(n.$from.depth):i=a.before(o);break}}return i!=null?(Nl(t,We.create(t.state.doc,i)),!0):!1}function QD(t,e,n,r,i){return f0(t,"handleClickOn",e,n,r)||t.someProp("handleClick",a=>a(t,e,r))||(i?YD(t,n):JD(t,n))}function XD(t,e,n,r){return f0(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",i=>i(t,e,r))}function ZD(t,e,n,r){return f0(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",i=>i(t,e,r))||eL(t,n,r)}function eL(t,e,n){if(n.button!=0)return!1;let r=t.state.doc;if(e==-1)return r.inlineContent?(Nl(t,Ue.create(r,0,r.content.size)),!0):!1;let i=r.resolve(e);for(let a=i.depth+1;a>0;a--){let o=a>i.depth?i.nodeAfter:i.node(a),c=i.before(a);if(o.inlineContent)Nl(t,Ue.create(r,c+1,c+1+o.content.size));else if(We.isSelectable(o))Nl(t,We.create(r,c));else continue;return!0}}function p0(t){return vh(t)}const GS=Kr?"metaKey":"ctrlKey";lr.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=p0(t),i=Date.now(),a="singleClick";i-t.input.lastClick.time<500&&GD(n,t.input.lastClick)&&!n[GS]&&t.input.lastClick.button==n.button&&(t.input.lastClick.type=="singleClick"?a="doubleClick":t.input.lastClick.type=="doubleClick"&&(a="tripleClick")),t.input.lastClick={time:i,x:n.clientX,y:n.clientY,type:a,button:n.button};let o=t.posAtCoords(jf(n));o&&(a=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new tL(t,o,n,!!r)):(a=="doubleClick"?XD:ZD)(t,o.pos,o.inside,n)?n.preventDefault():la(t,"pointer"))};class tL{constructor(e,n,r,i){this.view=e,this.pos=n,this.event=r,this.flushed=i,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[GS],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=i?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 We&&h.from<=o&&h.to>o)&&(this.mightDrag={node:a,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Jr&&!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)),la(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(()=>vi(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(jf(e))),this.updateAllowDefault(e),this.allowDefault||!n?la(this.view,"pointer"):QD(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||Yn&&this.mightDrag&&!this.mightDrag.node.isAtom||zn&&!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)?(Nl(this.view,Qe.near(this.view.state.doc.resolve(n.pos))),e.preventDefault()):la(this.view,"pointer")}move(e){this.updateAllowDefault(e),la(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)}}lr.touchstart=t=>{t.input.lastTouch=Date.now(),p0(t),la(t,"pointer")};lr.touchmove=t=>{t.input.lastTouch=Date.now(),la(t,"pointer")};lr.contextmenu=t=>p0(t);function JS(t,e){return t.composing?!0:Yn&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const nL=gi?5e3:-1;cr.compositionstart=cr.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof Ue&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||zn&&CS&&rL(t)))t.markCursor=t.state.storedMarks||n.marks(),vh(t,!0),t.markCursor=null;else if(vh(t,!e.selection.empty),Jr&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let r=t.domSelectionRange();for(let i=r.focusNode,a=r.focusOffset;i&&i.nodeType==1&&a!=0;){let o=a<0?i.lastChild:i.childNodes[a-1];if(!o)break;if(o.nodeType==3){let c=t.domSelection();c&&c.collapse(o,o.nodeValue.length);break}else i=o,a=-1}}t.input.composing=!0}YS(t,nL)};function rL(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"}cr.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++,YS(t,20))};function YS(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>vh(t),e))}function QS(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=iL());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function sL(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=YO(e.focusNode,e.focusOffset),r=QO(e.focusNode,e.focusOffset);if(n&&r&&n!=r){let i=r.pmViewDesc,a=t.domObserver.lastChangedTextNode;if(n==a||r==a)return a;if(!i||!i.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 iL(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function vh(t,e=!1){if(!(gi&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),QS(t),e||t.docView&&t.docView.dirty){let n=c0(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 aL(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(),i=document.createRange();i.selectNodeContents(e),t.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),t.focus()},50)}const ed=vr&&fa<15||El&&tD<604;lr.copy=cr.cut=(t,e)=>{let n=e,r=t.state.selection,i=n.type=="cut";if(r.empty)return;let a=ed?null:n.clipboardData,o=r.content(),{dom:c,text:u}=u0(t,o);a?(n.preventDefault(),a.clearData(),a.setData("text/html",c.innerHTML),a.setData("text/plain",u)):aL(t,c),i&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function oL(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function lL(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 i=t.input.shiftKey&&t.input.lastKeyCode!=45;setTimeout(()=>{t.focus(),r.parentNode&&r.parentNode.removeChild(r),n?td(t,r.value,null,i,e):td(t,r.textContent,r.innerHTML,i,e)},50)}function td(t,e,n,r,i){let a=VS(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",u=>u(t,i,a||Re.empty)))return!0;if(!a)return!1;let o=oL(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 XS(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," "):""}cr.paste=(t,e)=>{let n=e;if(t.composing&&!gi)return;let r=ed?null:n.clipboardData,i=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&td(t,XS(r),r.getData("text/html"),i,n)?n.preventDefault():lL(t,n)};class ZS{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}}const cL=Kr?"altKey":"ctrlKey";function e2(t,e){let n=t.someProp("dragCopies",r=>!r(e));return n??!e[cL]}lr.dragstart=(t,e)=>{let n=e,r=t.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let i=t.state.selection,a=i.empty?null:t.posAtCoords(jf(n)),o;if(!(a&&a.pos>=i.from&&a.pos<=(i instanceof We?i.to-1:i.to))){if(r&&r.mightDrag)o=We.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=We.create(t.state.doc,m.posBefore))}}let c=(o||t.state.selection).content(),{dom:u,text:h,slice:f}=u0(t,c);(!n.dataTransfer.files.length||!zn||SS>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(ed?"Text":"text/html",u.innerHTML),n.dataTransfer.effectAllowed="copyMove",ed||n.dataTransfer.setData("text/plain",h),t.dragging=new ZS(f,e2(t,n),o)};lr.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};cr.dragover=cr.dragenter=(t,e)=>e.preventDefault();cr.drop=(t,e)=>{try{dL(t,e,t.dragging)}finally{t.dragging=null}};function dL(t,e,n){if(!e.dataTransfer)return;let r=t.posAtCoords(jf(e));if(!r)return;let i=t.state.doc.resolve(r.pos),a=n&&n.slice;a?t.someProp("transformPasted",y=>{a=y(a,t,!1)}):a=VS(t,XS(e.dataTransfer),ed?null:e.dataTransfer.getData("text/html"),!1,i);let o=!!(n&&e2(t,e));if(t.someProp("handleDrop",y=>y(t,e,a||Re.empty,o))){e.preventDefault();return}if(!a)return;e.preventDefault();let c=a?sS(t.state.doc,i.pos,a):i.pos;c==null&&(c=i.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&&We.isSelectable(a.content.firstChild)&&g.nodeAfter&&g.nodeAfter.sameMarkup(a.content.firstChild))u.setSelection(new We(g));else{let y=u.mapping.map(c);u.mapping.maps[u.mapping.maps.length-1].forEach((v,w,N,k)=>y=k),u.setSelection(d0(t,g,u.doc.resolve(y)))}t.focus(),t.dispatch(u.setMeta("uiEvent","drop"))}lr.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())&&vi(t)},20))};lr.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)};lr.beforeinput=(t,e)=>{if(zn&&gi&&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,Qa(8,"Backspace")))))return;let{$cursor:i}=t.state.selection;i&&i.pos>0&&t.dispatch(t.state.tr.delete(i.pos-1,i.pos).scrollIntoView())},50)}};for(let t in cr)lr[t]=cr[t];function nd(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 bh{constructor(e,n){this.toDOM=e,this.spec=n||oo,this.side=this.spec.side||0}map(e,n,r,i){let{pos:a,deleted:o}=e.mapResult(n.from+i,this.side<0?-1:1);return o?null:new bn(a-r,a-r,this)}valid(){return!0}eq(e){return this==e||e instanceof bh&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&nd(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class ma{constructor(e,n){this.attrs=e,this.spec=n||oo}map(e,n,r,i){let a=e.map(n.from+i,this.spec.inclusiveStart?-1:1)-r,o=e.map(n.to+i,this.spec.inclusiveEnd?1:-1)-r;return a>=o?null:new bn(a,o,this)}valid(e,n){return n.from=e&&(!a||a(c.spec))&&r.push(c.copy(c.from+i,c.to+i))}for(let o=0;oe){let c=this.children[o]+1;this.children[o+2].findInner(e-c,n-c,r,i+c,a)}}map(e,n,r){return this==Un||e.maps.length==0?this:this.mapInner(e,n,0,0,r||oo)}mapInner(e,n,r,i,a){let o;for(let c=0;c{let h=u+r,f;if(f=n2(n,c,h)){for(i||(i=this.children.slice());ac&&m.to=e){this.children[c]==e&&(r=this.children[c+2]);break}let a=e+1,o=a+n.content.size;for(let c=0;ca&&u.type instanceof ma){let h=Math.max(a,u.from)-a,f=Math.min(o,u.to)-a;hi.map(e,n,oo));return ta.from(r)}forChild(e,n){if(n.isLeaf)return Ct.empty;let r=[];for(let i=0;in instanceof Ct)?e:e.reduce((n,r)=>n.concat(r instanceof Ct?r:r.members),[]))}}forEachSet(e){for(let n=0;n{let N=w-v-(y-g);for(let k=0;kE+f-m)continue;let C=c[k]+f-m;y>=C?c[k+1]=g<=C?-2:-1:g>=f&&N&&(c[k]+=N,c[k+1]+=N)}m+=N}),f=n.maps[h].map(f,-1)}let u=!1;for(let h=0;h=r.content.size){u=!0;continue}let g=n.map(t[h+1]+a,-1),y=g-i,{index:v,offset:w}=r.content.findIndex(m),N=r.maybeChild(v);if(N&&w==m&&w+N.nodeSize==y){let k=c[h+2].mapInner(n,N,f+1,t[h]+a+1,o);k!=Un?(c[h]=m,c[h+1]=y,c[h+2]=k):(c[h+1]=-2,u=!0)}else u=!0}if(u){let h=hL(c,t,e,n,i,a,o),f=Nh(h,r,0,o);e=f.local;for(let m=0;mn&&o.to{let h=n2(t,c,u+n);if(h){a=!0;let f=Nh(h,c,n+u+1,r);f!=Un&&i.push(u,u+c.nodeSize,f)}});let o=t2(a?r2(t):t,-n).sort(lo);for(let c=0;c0;)e++;t.splice(e,0,n)}function qm(t){let e=[];return t.someProp("decorations",n=>{let r=n(t.state);r&&r!=Un&&e.push(r)}),t.cursorWrapper&&e.push(Ct.create(t.state.doc,[t.cursorWrapper.deco])),ta.from(e)}const fL={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},pL=vr&&fa<=11;class mL{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 gL{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new mL,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let i=0;ii.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():Yn&&e.composing&&r.some(i=>i.type=="childList"&&i.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),pL&&(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,fL)),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;nthis.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(F1(this.view)){if(this.suppressingSelectionUpdates)return vi(this.view);if(vr&&fa<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&xo(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=Cl(a))n.add(a);for(let a=e.anchorNode;a;a=Cl(a))if(n.has(a)){r=a;break}let i=r&&this.view.docView.nearestDesc(r);if(i&&i.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(),i=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&F1(e)&&!this.ignoreSelectionChange(r),a=-1,o=-1,c=!1,u=[];if(e.editable)for(let f=0;ff.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(Jr&&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||vL(e,m)!=y)&&g.remove()}}}let h=null;a<0&&i&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)-1||i)&&(a>-1&&(e.docView.markDirty(a,o),xL(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,bL(e,u)),this.handleDOMChange(a,o,c,u),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||vi(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;fi;N--){let k=r.childNodes[N-1],E=k.pmViewDesc;if(k.nodeName=="BR"&&!E){a=N;break}if(!E||E.size)break}let m=t.state.doc,g=t.someProp("domParser")||ha.fromSchema(t.state.schema),y=m.resolve(o),v=null,w=g.parse(r,{topNode:y.parent,topMatch:y.parent.contentMatchAt(y.index()),topOpen:!0,from:i,to:a,preserveWhitespace:y.parent.type.whitespace=="pre"?"full":!0,findPositions:h,ruleFromNode:wL,context:y});if(h&&h[0].pos!=null){let N=h[0].pos,k=h[1]&&h[1].pos;k==null&&(k=N),v={anchor:N+o,head:k+o}}return{doc:w,sel:v,from:o,to:c}}function wL(t){let e=t.pmViewDesc;if(e)return e.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(Yn&&/^(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||Yn&&/^(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 jL=/^(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 kL(t,e,n,r,i){let a=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let I=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,R=c0(t,I);if(R&&!t.state.selection.eq(R)){if(zn&&gi&&t.input.lastKeyCode===13&&Date.now()-100L(t,Qa(13,"Enter"))))return;let P=t.state.tr.setSelection(R);I=="pointer"?P.setMeta("pointer",!0):I=="key"&&P.scrollIntoView(),a&&P.setMeta("composition",a),t.dispatch(P)}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=NL(t,e,n),f=t.state.doc,m=f.slice(h.from,h.to),g,y;t.input.lastKeyCode===8&&Date.now()-100Date.now()-225||gi)&&i.some(I=>I.nodeType==1&&!jL.test(I.nodeName))&&(!v||v.endA>=v.endB)&&t.someProp("handleKeyDown",I=>I(t,Qa(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!v)if(r&&u instanceof Ue&&!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 I=X1(t,t.state.doc,h.sel);if(I&&!I.eq(t.state.selection)){let R=t.state.tr.setSelection(I);a&&R.setMeta("composition",a),t.dispatch(R)}}return}t.state.selection.fromt.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-2&&t.state.selection.to<=h.to&&(v.endB+=t.state.selection.to-v.endA,v.endA=t.state.selection.to)),vr&&fa<=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 w=h.doc.resolveNoCache(v.start-h.from),N=h.doc.resolveNoCache(v.endB-h.from),k=f.resolve(v.start),E=w.sameParent(N)&&w.parent.inlineContent&&k.end()>=v.endA;if((El&&t.input.lastIOSEnter>Date.now()-225&&(!E||i.some(I=>I.nodeName=="DIV"||I.nodeName=="P"))||!E&&w.posI(t,Qa(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>v.start&&CL(f,v.start,v.endA,w,N)&&t.someProp("handleKeyDown",I=>I(t,Qa(8,"Backspace")))){gi&&zn&&t.domObserver.suppressSelectionUpdates();return}zn&&v.endB==v.start&&(t.input.lastChromeDelete=Date.now()),gi&&!E&&w.start()!=N.start()&&N.parentOffset==0&&w.depth==N.depth&&h.sel&&h.sel.anchor==h.sel.head&&h.sel.head==v.endA&&(v.endB-=2,N=h.doc.resolveNoCache(v.endB-h.from),setTimeout(()=>{t.someProp("handleKeyDown",function(I){return I(t,Qa(13,"Enter"))})},20));let C=v.start,T=v.endA,O=I=>{let R=I||t.state.tr.replace(C,T,h.doc.slice(v.start-h.from,v.endB-h.from));if(h.sel){let P=X1(t,R.doc,h.sel);P&&!(zn&&t.composing&&P.empty&&(v.start!=v.endB||t.input.lastChromeDeletevi(t),20));let I=O(t.state.tr.delete(C,T)),R=f.resolve(v.start).marksAcross(f.resolve(v.endA));R&&I.ensureMarks(R),t.dispatch(I)}else if(v.endA==v.endB&&(F=SL(w.parent.content.cut(w.parentOffset,N.parentOffset),k.parent.content.cut(k.parentOffset,v.endA-k.start())))){let I=O(t.state.tr);F.type=="add"?I.addMark(C,T,F.mark):I.removeMark(C,T,F.mark),t.dispatch(I)}else if(w.parent.child(w.index()).isText&&w.index()==N.index()-(N.textOffset?0:1)){let I=w.parent.textBetween(w.parentOffset,N.parentOffset),R=()=>O(t.state.tr.insertText(I,C,T));t.someProp("handleTextInput",P=>P(t,C,T,I,R))||t.dispatch(R())}else t.dispatch(O());else t.dispatch(O())}function X1(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:d0(t,e.resolve(n.anchor),e.resolve(n.head))}function SL(t,e){let n=t.firstChild.marks,r=e.firstChild.marks,i=n,a=r,o,c,u;for(let f=0;ff.mark(c.addToSet(f.marks));else if(i.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;fn||Gm(o,!0,!1)0&&(e||t.indexAfter(r)==t.node(r).childCount);)r--,i++,e=!1;if(n){let a=t.node(r).maybeChild(t.indexAfter(r));for(;a&&!a.isLeaf;)a=a.firstChild,i++}return i}function EL(t,e,n,r,i){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(i=="end"){let u=Math.max(0,a-Math.min(o,c));r-=o+u-a}if(o=o?a-r:0;a-=u,a&&a=c?a-r:0;a-=u,a&&a=56320&&e<=57343&&n>=55296&&n<=56319}class s2{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 HD,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(sN),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=nN(this),tN(this),this.nodeViews=rN(this),this.docView=O1(this.state.doc,eN(this),qm(this),this.dom,this),this.domObserver=new gL(this,(r,i,a,o)=>kL(this,r,i,a,o)),this.domObserver.start(),WD(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&&Yg(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(sN),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 i=this.state,a=!1,o=!1;e.storedMarks&&this.composing&&(QS(this),o=!0),this.state=e;let c=i.plugins!=e.plugins||this._props.plugins!=n.plugins;if(c||this._props.plugins!=n.plugins||this._props.nodeViews!=n.nodeViews){let y=rN(this);ML(y,this.nodeViews)&&(this.nodeViews=y,a=!0)}(c||n.handleDOMEvents!=this._props.handleDOMEvents)&&Yg(this),this.editable=nN(this),tN(this);let u=qm(this),h=eN(this),f=i.plugins!=e.plugins&&!i.doc.eq(e.doc)?"reset":e.scrollToSelection>i.scrollToSelection?"to selection":"preserve",m=a||!this.docView.matchesNode(e.doc,h,u);(m||!e.selection.eq(i.selection))&&(o=!0);let g=f=="preserve"&&o&&this.dom.style.overflowAnchor==null&&sD(this);if(o){this.domObserver.stop();let y=m&&(vr||zn)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&TL(i.selection,e.selection);if(m){let v=zn?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=sL(this)),(a||!this.docView.update(e.doc,h,u,this))&&(this.docView.updateOuterDeco(h),this.docView.destroy(),this.docView=O1(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())&&TD(this))?vi(this,y):($S(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(i),!((r=this.dragging)===null||r===void 0)&&r.node&&!i.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,i),f=="reset"?this.dom.scrollTop=0:f=="to selection"?this.scrollToSelection():g&&iD(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 We){let n=this.docView.domAfterPos(this.state.selection.from);n.nodeType==1&&T1(this,n.getBoundingClientRect(),e)}else T1(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;n0&&this.state.doc.nodeAt(a))==r.node&&(i=a)}this.dragging=new ZS(e.slice,e.move,i<0?void 0:We.create(this.state.doc,i))}someProp(e,n){let r=this._props&&this._props[e],i;if(r!=null&&(i=n?n(r):r))return i;for(let o=0;on.ownerDocument.getSelection()),this._root=n}return e||document}updateRoot(){this._root=null}posAtCoords(e){return uD(this,e)}coordsAtPos(e,n=1){return IS(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 i=this.docView.posFromDOM(e,n,r);if(i==null)throw new RangeError("DOM position not inside the editor");return i}endOfTextblock(e,n){return gD(this,n||this.state,e)}pasteHTML(e,n){return td(this,"",e,!1,n||new ClipboardEvent("paste"))}pasteText(e,n){return td(this,e,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(e){return u0(this,e)}destroy(){this.docView&&(UD(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],qm(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,GO())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return qD(this,e)}domSelectionRange(){let e=this.domSelection();return e?Yn&&this.root.nodeType===11&&ZO(this.dom.ownerDocument)==this.dom&&yL(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}s2.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function eN(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"),[bn.node(0,t.state.doc.content.size,e)]}function tN(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:bn.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function nN(t){return!t.someProp("editable",e=>e(t.state)===!1)}function TL(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 rN(t){let e=Object.create(null);function n(r){for(let i in r)Object.prototype.hasOwnProperty.call(e,i)||(e[i]=r[i])}return t.someProp("nodeViews",n),t.someProp("markViews",n),e}function ML(t,e){let n=0,r=0;for(let i in t){if(t[i]!=e[i])return!0;n++}for(let i in e)r++;return n!=r}function sN(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 xa={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:"'"},wh={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},AL=typeof navigator<"u"&&/Mac/.test(navigator.platform),IL=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var _n=0;_n<10;_n++)xa[48+_n]=xa[96+_n]=String(_n);for(var _n=1;_n<=24;_n++)xa[_n+111]="F"+_n;for(var _n=65;_n<=90;_n++)xa[_n]=String.fromCharCode(_n+32),wh[_n]=String.fromCharCode(_n);for(var Jm in xa)wh.hasOwnProperty(Jm)||(wh[Jm]=xa[Jm]);function RL(t){var e=AL&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||IL&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?wh:xa)[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 PL=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),OL=typeof navigator<"u"&&/Win/.test(navigator.platform);function DL(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n=="Space"&&(n=" ");let r,i,a,o;for(let c=0;c{for(var n in e)zL(t,n,{get:e[n],enumerable:!0})};function kf(t){const{state:e,transaction:n}=t;let{selection:r}=n,{doc:i}=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 i},get tr(){return r=n.selection,i=n.doc,a=n.storedMarks,n}}}var Sf=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:i}=n,a=this.buildProps(i);return Object.fromEntries(Object.entries(t).map(([o,c])=>[o,(...h)=>{const f=c(...h)(a);return!i.getMeta("preventDispatch")&&!this.hasCustomState&&r.dispatch(i),f}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(t,e=!0){const{rawCommands:n,editor:r,state:i}=this,{view:a}=r,o=[],c=!!t,u=t||i.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 w=this.buildProps(u,e),N=g(...v)(w);return o.push(N),f}])),run:h};return f}createCan(t){const{rawCommands:e,state:n}=this,r=!1,i=t||n.tr,a=this.buildProps(i,r);return{...Object.fromEntries(Object.entries(e).map(([c,u])=>[c,(...h)=>u(...h)({...a,dispatch:void 0})])),chain:()=>this.createChain(i,r)}}buildProps(t,e=!0){const{rawCommands:n,editor:r,state:i}=this,{view:a}=r,o={tr:t,editor:r,view:a,state:kf({state:i,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}},i2={};y0(i2,{blur:()=>$L,clearContent:()=>FL,clearNodes:()=>BL,command:()=>VL,createParagraphNear:()=>HL,cut:()=>WL,deleteCurrentNode:()=>UL,deleteNode:()=>KL,deleteRange:()=>qL,deleteSelection:()=>GL,enter:()=>JL,exitCode:()=>YL,extendMarkRange:()=>QL,first:()=>XL,focus:()=>e8,forEach:()=>t8,insertContent:()=>n8,insertContentAt:()=>i8,joinBackward:()=>l8,joinDown:()=>o8,joinForward:()=>c8,joinItemBackward:()=>d8,joinItemForward:()=>u8,joinTextblockBackward:()=>h8,joinTextblockForward:()=>f8,joinUp:()=>a8,keyboardShortcut:()=>m8,lift:()=>g8,liftEmptyBlock:()=>x8,liftListItem:()=>y8,newlineInCode:()=>v8,resetAttributes:()=>b8,scrollIntoView:()=>N8,selectAll:()=>w8,selectNodeBackward:()=>j8,selectNodeForward:()=>k8,selectParentNode:()=>S8,selectTextblockEnd:()=>C8,selectTextblockStart:()=>E8,setContent:()=>T8,setMark:()=>G8,setMeta:()=>J8,setNode:()=>Y8,setNodeSelection:()=>Q8,setTextDirection:()=>X8,setTextSelection:()=>Z8,sinkListItem:()=>e6,splitBlock:()=>t6,splitListItem:()=>n6,toggleList:()=>r6,toggleMark:()=>s6,toggleNode:()=>i6,toggleWrap:()=>a6,undoInputRule:()=>o6,unsetAllMarks:()=>l6,unsetMark:()=>c6,unsetTextDirection:()=>d6,updateAttributes:()=>u6,wrapIn:()=>h6,wrapInList:()=>f6});var $L=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{var n;t.isDestroyed||(e.dom.blur(),(n=window==null?void 0:window.getSelection())==null||n.removeAllRanges())}),!0),FL=(t=!0)=>({commands:e})=>e.setContent("",{emitUpdate:t}),BL=()=>({state:t,tr:e,dispatch:n})=>{const{selection:r}=e,{ranges:i}=r;return n&&i.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=$l(y);if(c.type.isTextblock){const{defaultType:w}=m.parent.contentMatchAt(m.index());e.setNodeMarkup(y.start,w)}(v||v===0)&&e.lift(y,v)})}),!0},VL=t=>e=>t(e),HL=()=>({state:t,dispatch:e})=>bS(t,e),WL=(t,e)=>({editor:n,tr:r})=>{const{state:i}=n,a=i.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 Ue(r.doc.resolve(Math.max(o-1,0)))),!0},UL=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,r=n.$anchor.node();if(r.content.size>0)return!1;const i=t.selection.$anchor;for(let a=i.depth;a>0;a-=1)if(i.node(a).type===r.type){if(e){const c=i.before(a),u=i.after(a);t.delete(c,u).scrollIntoView()}return!0}return!1};function pn(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 KL=t=>({tr:e,state:n,dispatch:r})=>{const i=pn(t,n.schema),a=e.selection.$anchor;for(let o=a.depth;o>0;o-=1)if(a.node(o).type===i){if(r){const u=a.before(o),h=a.after(o);e.delete(u,h).scrollIntoView()}return!0}return!1},qL=t=>({tr:e,dispatch:n})=>{const{from:r,to:i}=t;return n&&e.delete(r,i),!0},GL=()=>({state:t,dispatch:e})=>r0(t,e),JL=()=>({commands:t})=>t.keyboardShortcut("Enter"),YL=()=>({state:t,dispatch:e})=>PO(t,e);function v0(t){return Object.prototype.toString.call(t)==="[object RegExp]"}function jh(t,e,n={strict:!0}){const r=Object.keys(e);return r.length?r.every(i=>n.strict?e[i]===t[i]:v0(e[i])?e[i].test(t[i]):e[i]===t[i]):!0}function a2(t,e,n={}){return t.find(r=>r.type===e&&jh(Object.fromEntries(Object.keys(n).map(i=>[i,r.attrs[i]])),n))}function iN(t,e,n={}){return!!a2(t,e,n)}function b0(t,e,n){var r;if(!t||!e)return;let i=t.parent.childAfter(t.parentOffset);if((!i.node||!i.node.marks.some(f=>f.type===e))&&(i=t.parent.childBefore(t.parentOffset)),!i.node||!i.node.marks.some(f=>f.type===e)||(n=n||((r=i.node.marks[0])==null?void 0:r.attrs),!a2([...i.node.marks],e,n)))return;let o=i.index,c=t.start()+i.offset,u=o+1,h=c+i.node.nodeSize;for(;o>0&&iN([...t.parent.child(o-1).marks],e,n);)o-=1,c-=t.parent.child(o).nodeSize;for(;u({tr:n,state:r,dispatch:i})=>{const a=ji(t,r.schema),{doc:o,selection:c}=n,{$from:u,from:h,to:f}=c;if(i){const m=b0(u,a,e);if(m&&m.from<=h&&m.to>=f){const g=Ue.create(o,m.from,m.to);n.setSelection(g)}}return!0},XL=t=>e=>{const n=typeof t=="function"?t(e):t;for(let r=0;r({editor:n,view:r,tr:i,dispatch:a})=>{e={scrollIntoView:!0,...e};const o=()=>{(kh()||aN())&&r.dom.focus(),ZL()&&!kh()&&!aN()&&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&&!o2(n.state.selection))return o(),!0;const c=l2(i.doc,t)||n.state.selection,u=n.state.selection.eq(c);return a&&(u||i.setSelection(c),u&&i.storedMarks&&i.setStoredMarks(i.storedMarks),o()),!0},t8=(t,e)=>n=>t.every((r,i)=>e(r,{...n,index:i})),n8=(t,e)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),c2=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&&c2(r)}return t};function Pu(t){if(typeof window>"u")throw new Error("[tiptap error]: there is no window object available, so this function cannot be used");const e=`${t}`,n=new window.DOMParser().parseFromString(e,"text/html").body;return c2(n)}function rd(t,e,n){if(t instanceof xi||t instanceof ge)return t;n={slice:!0,parseOptions:{},...n};const r=typeof t=="object"&&t!==null,i=typeof t=="string";if(r)try{if(Array.isArray(t)&&t.length>0)return ge.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),rd("",e,n)}if(i){if(n.errorOnInvalidContent){let o=!1,c="";const u=new qk({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?ha.fromSchema(u).parseSlice(Pu(t),n.parseOptions):ha.fromSchema(u).parse(Pu(t),n.parseOptions),n.errorOnInvalidContent&&o)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${c}`)})}const a=ha.fromSchema(e);return n.slice?a.parseSlice(Pu(t),n.parseOptions).content:a.parse(Pu(t),n.parseOptions)}return rd("",e,n)}function r8(t,e,n){const r=t.steps.length-1;if(r{o===0&&(o=f)}),t.setSelection(Qe.near(t.doc.resolve(o),n))}var s8=t=>!("type"in t),i8=(t,e,n)=>({tr:r,dispatch:i,editor:a})=>{var o;if(i){n={parseOptions:a.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};let c;const u=N=>{a.emit("contentError",{editor:a,error:N,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{rd(e,a.schema,{parseOptions:h,errorOnInvalidContent:!0})}catch(N){u(N)}try{c=rd(e,a.schema,{parseOptions:h,errorOnInvalidContent:(o=n.errorOnInvalidContent)!=null?o:a.options.enableContentCheck})}catch(N){return u(N),!1}let{from:f,to:m}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},g=!0,y=!0;if((s8(c)?c:[c]).forEach(N=>{N.check(),g=g?N.isText&&N.marks.length===0:!1,y=y?N.isBlock:!1}),f===m&&y){const{parent:N}=r.doc.resolve(f);N.isTextblock&&!N.type.spec.code&&!N.childCount&&(f-=1,m+=1)}let w;if(g){if(Array.isArray(e))w=e.map(N=>N.text||"").join("");else if(e instanceof ge){let N="";e.forEach(k=>{k.text&&(N+=k.text)}),w=N}else typeof e=="object"&&e&&e.text?w=e.text:w=e;r.insertText(w,f,m)}else{w=c;const N=r.doc.resolve(f),k=N.node(),E=N.parentOffset===0,C=k.isText||k.isTextblock,T=k.content.size>0;E&&C&&T&&(f=Math.max(0,f-1)),r.replaceWith(f,m,w)}n.updateSelection&&r8(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta("applyInputRules",{from:f,text:w}),n.applyPasteRules&&r.setMeta("applyPasteRules",{from:f,text:w})}return!0},a8=()=>({state:t,dispatch:e})=>AO(t,e),o8=()=>({state:t,dispatch:e})=>IO(t,e),l8=()=>({state:t,dispatch:e})=>fS(t,e),c8=()=>({state:t,dispatch:e})=>xS(t,e),d8=()=>({state:t,dispatch:e,tr:n})=>{try{const r=yf(t.doc,t.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},u8=()=>({state:t,dispatch:e,tr:n})=>{try{const r=yf(t.doc,t.selection.$from.pos,1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},h8=()=>({state:t,dispatch:e})=>TO(t,e),f8=()=>({state:t,dispatch:e})=>MO(t,e);function d2(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function p8(t){const e=t.split(/-(?!$)/);let n=e[e.length-1];n==="Space"&&(n=" ");let r,i,a,o;for(let c=0;c({editor:e,view:n,tr:r,dispatch:i})=>{const a=p8(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&&i&&r.maybeStep(f)}),!0};function ya(t,e,n={}){const{from:r,to:i,empty:a}=t.selection,o=e?pn(e,t.schema):null,c=[];t.doc.nodesBetween(r,i,(m,g)=>{if(m.isText)return;const y=Math.max(r,g),v=Math.min(i,g+m.nodeSize);c.push({node:m,from:y,to:v})});const u=i-r,h=c.filter(m=>o?o.name===m.node.type.name:!0).filter(m=>jh(m.node.attrs,n,{strict:!1}));return a?!!h.length:h.reduce((m,g)=>m+g.to-g.from,0)>=u}var g8=(t,e={})=>({state:n,dispatch:r})=>{const i=pn(t,n.schema);return ya(n,i,e)?RO(n,r):!1},x8=()=>({state:t,dispatch:e})=>NS(t,e),y8=t=>({state:e,dispatch:n})=>{const r=pn(t,e.schema);return WO(r)(e,n)},v8=()=>({state:t,dispatch:e})=>vS(t,e);function Cf(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function oN(t,e){const n=typeof e=="string"?[e]:e;return Object.keys(t).reduce((r,i)=>(n.includes(i)||(r[i]=t[i]),r),{})}var b8=(t,e)=>({tr:n,state:r,dispatch:i})=>{let a=null,o=null;const c=Cf(typeof t=="string"?t:t.name,r.schema);if(!c)return!1;c==="node"&&(a=pn(t,r.schema)),c==="mark"&&(o=ji(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,i&&n.setNodeMarkup(m,void 0,oN(f.attrs,e))),o&&f.marks.length&&f.marks.forEach(g=>{o===g.type&&(u=!0,i&&n.addMark(m,m+f.nodeSize,o.create(oN(g.attrs,e))))})})}),u},N8=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),w8=()=>({tr:t,dispatch:e})=>{if(e){const n=new Ir(t.doc);t.setSelection(n)}return!0},j8=()=>({state:t,dispatch:e})=>mS(t,e),k8=()=>({state:t,dispatch:e})=>yS(t,e),S8=()=>({state:t,dispatch:e})=>LO(t,e),C8=()=>({state:t,dispatch:e})=>$O(t,e),E8=()=>({state:t,dispatch:e})=>zO(t,e);function Qg(t,e,n={},r={}){return rd(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var T8=(t,{errorOnInvalidContent:e,emitUpdate:n=!0,parseOptions:r={}}={})=>({editor:i,tr:a,dispatch:o,commands:c})=>{const{doc:u}=a;if(r.preserveWhitespace!=="full"){const h=Qg(t,i.schema,r,{errorOnInvalidContent:e??i.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??i.options.enableContentCheck})};function u2(t,e){const n=ji(e,t.schema),{from:r,to:i,empty:a}=t.selection,o=[];a?(t.storedMarks&&o.push(...t.storedMarks),o.push(...t.selection.$head.marks())):t.doc.nodesBetween(r,i,u=>{o.push(...u.marks)});const c=o.find(u=>u.type.name===n.name);return c?{...c.attrs}:{}}function h2(t,e){const n=new t0(t);return e.forEach(r=>{r.steps.forEach(i=>{n.step(i)})}),n}function M8(t){for(let e=0;e{n(i)&&r.push({node:i,pos:a})}),r}function f2(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 Ef(t){return e=>f2(e.$from,t)}function Ve(t,e,n){return t.config[e]===void 0&&t.parent?Ve(t.parent,e,n):typeof t.config[e]=="function"?t.config[e].bind({...n,parent:t.parent?Ve(t.parent,e,n):null}):t.config[e]}function N0(t){return t.map(e=>{const n={name:e.name,options:e.options,storage:e.storage},r=Ve(e,"addExtensions",n);return r?[e,...N0(r())]:e}).flat(10)}function w0(t,e){const n=So.fromSchema(e).serializeFragment(t),i=document.implementation.createHTMLDocument().createElement("div");return i.appendChild(n),i.innerHTML}function p2(t){return typeof t=="function"}function yt(t,e=void 0,...n){return p2(t)?e?t.bind(e)(...n):t(...n):t}function I8(t={}){return Object.keys(t).length===0&&t.constructor===Object}function Tl(t){const e=t.filter(i=>i.type==="extension"),n=t.filter(i=>i.type==="node"),r=t.filter(i=>i.type==="mark");return{baseExtensions:e,nodeExtensions:n,markExtensions:r}}function m2(t){const e=[],{nodeExtensions:n,markExtensions:r}=Tl(t),i=[...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:i},m=Ve(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(w=>{Object.entries(y.attributes).forEach(([N,k])=>{e.push({type:w,name:N,attribute:{...a,...k}})})})})}),i.forEach(h=>{const f={name:h.name,options:h.options,storage:h.storage},m=Ve(h,"addAttributes",f);if(!m)return;const g=m();Object.entries(g).forEach(([y,v])=>{const w={...a,...v};typeof(w==null?void 0:w.default)=="function"&&(w.default=w.default()),w!=null&&w.isRequired&&(w==null?void 0:w.default)===void 0&&delete w.default,e.push({type:h.name,name:y,attribute:w})})}),e}function R8(t){const e=[];let n="",r=!1,i=!1,a=0;const o=t.length;for(let c=0;c0){a-=1,n+=u;continue}if(u===";"&&a===0){e.push(n),n="";continue}}n+=u}return n&&e.push(n),e}function lN(t){const e=[],n=R8(t||""),r=n.length;for(let i=0;i!!e).reduce((e,n)=>{const r={...e};return Object.entries(n).forEach(([i,a])=>{if(!r[i]){r[i]=a;return}if(i==="class"){const c=a?String(a).split(" "):[],u=r[i]?r[i].split(" "):[],h=c.filter(f=>!u.includes(f));r[i]=[...u,...h].join(" ")}else if(i==="style"){const c=new Map([...lN(r[i]),...lN(a)]);r[i]=Array.from(c.entries()).map(([u,h])=>`${u}: ${h}`).join("; ")}else r[i]=a}),r},{})}function sd(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 P8(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function cN(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 i=e.reduce((a,o)=>{const c=o.attribute.parseHTML?o.attribute.parseHTML(n):P8(n.getAttribute(o.name));return c==null?a:{...a,[o.name]:c}},{});return{...r,...i}}}}function dN(t){return Object.fromEntries(Object.entries(t).filter(([e,n])=>e==="attrs"&&I8(n)?!1:n!=null))}function uN(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 O8(t,e){var n;const r=m2(t),{nodeExtensions:i,markExtensions:a}=Tl(t),o=(n=i.find(h=>Ve(h,"topNode")))==null?void 0:n.name,c=Object.fromEntries(i.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=Ve(E,"extendNodeSchema",m);return{...k,...C?C(h):{}}},{}),y=dN({...g,content:yt(Ve(h,"content",m)),marks:yt(Ve(h,"marks",m)),group:yt(Ve(h,"group",m)),inline:yt(Ve(h,"inline",m)),atom:yt(Ve(h,"atom",m)),selectable:yt(Ve(h,"selectable",m)),draggable:yt(Ve(h,"draggable",m)),code:yt(Ve(h,"code",m)),whitespace:yt(Ve(h,"whitespace",m)),linebreakReplacement:yt(Ve(h,"linebreakReplacement",m)),defining:yt(Ve(h,"defining",m)),isolating:yt(Ve(h,"isolating",m)),attrs:Object.fromEntries(f.map(uN))}),v=yt(Ve(h,"parseHTML",m));v&&(y.parseDOM=v.map(k=>cN(k,f)));const w=Ve(h,"renderHTML",m);w&&(y.toDOM=k=>w({node:k,HTMLAttributes:sd(k,f)}));const N=Ve(h,"renderText",m);return N&&(y.toText=N),[h.name,y]})),u=Object.fromEntries(a.map(h=>{const f=r.filter(N=>N.type===h.name),m={name:h.name,options:h.options,storage:h.storage,editor:e},g=t.reduce((N,k)=>{const E=Ve(k,"extendMarkSchema",m);return{...N,...E?E(h):{}}},{}),y=dN({...g,inclusive:yt(Ve(h,"inclusive",m)),excludes:yt(Ve(h,"excludes",m)),group:yt(Ve(h,"group",m)),spanning:yt(Ve(h,"spanning",m)),code:yt(Ve(h,"code",m)),attrs:Object.fromEntries(f.map(uN))}),v=yt(Ve(h,"parseHTML",m));v&&(y.parseDOM=v.map(N=>cN(N,f)));const w=Ve(h,"renderHTML",m);return w&&(y.toDOM=N=>w({mark:N,HTMLAttributes:sd(N,f)})),[h.name,y]}));return new qk({topNode:o,nodes:c,marks:u})}function D8(t){const e=t.filter((n,r)=>t.indexOf(n)!==r);return Array.from(new Set(e))}function $c(t){return t.sort((n,r)=>{const i=Ve(n,"priority")||100,a=Ve(r,"priority")||100;return i>a?-1:ir.name));return n.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${n.map(r=>`'${r}'`).join(", ")}]. This can lead to issues.`),e}function x2(t,e,n){const{from:r,to:i}=e,{blockSeparator:a=` - -`,textSerializers:o={}}=n||{};let c="";return t.nodesBetween(r,i,(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,i-h))}),c}function L8(t,e){const n={from:0,to:t.content.size};return x2(t,n,e)}function y2(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,n])=>[e,n.spec.toText]))}function _8(t,e){const n=pn(e,t.schema),{from:r,to:i}=t.selection,a=[];t.doc.nodesBetween(r,i,c=>{a.push(c)});const o=a.reverse().find(c=>c.type.name===n.name);return o?{...o.attrs}:{}}function v2(t,e){const n=Cf(typeof e=="string"?e:e.name,t.schema);return n==="node"?_8(t,e):n==="mark"?u2(t,e):{}}function z8(t,e=JSON.stringify){const n={};return t.filter(r=>{const i=e(r);return Object.prototype.hasOwnProperty.call(n,i)?!1:n[i]=!0})}function $8(t){const e=z8(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 b2(t){const{mapping:e,steps:n}=t,r=[];return e.maps.forEach((i,a)=>{const o=[];if(i.ranges.length)i.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}})})}),$8(r)}function j0(t,e,n){const r=[];return t===e?n.resolve(t).marks().forEach(i=>{const a=n.resolve(t),o=b0(a,i.type);o&&r.push({mark:i,...o})}):n.nodesBetween(t,e,(i,a)=>{!i||(i==null?void 0:i.nodeSize)===void 0||r.push(...i.marks.map(o=>({from:a,to:a+i.nodeSize,mark:o})))}),r}var F8=(t,e,n,r=20)=>{const i=t.doc.resolve(n);let a=r,o=null;for(;a>0&&o===null;){const c=i.node(a);(c==null?void 0:c.type.name)===e?o=c:a-=1}return[o,a]};function kc(t,e){return e.nodes[t]||e.marks[t]||null}function Xu(t,e,n){return Object.fromEntries(Object.entries(n).filter(([r])=>{const i=t.find(a=>a.type===e&&a.name===r);return i?i.attribute.keepOnSplit:!1}))}var B8=(t,e=500)=>{let n="";const r=t.parentOffset;return t.parent.nodesBetween(Math.max(0,r-e),r,(i,a,o,c)=>{var u,h;const f=((h=(u=i.type.spec).toText)==null?void 0:h.call(u,{node:i,pos:a,parent:o,index:c}))||i.textContent||"%leaf%";n+=i.isAtom&&!i.isText?f:f.slice(0,Math.max(0,r-a))}),n};function Xg(t,e,n={}){const{empty:r,ranges:i}=t.selection,a=e?ji(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter(m=>a?a.name===m.type.name:!0).find(m=>jh(m.attrs,n,{strict:!1}));let o=0;const c=[];if(i.forEach(({$from:m,$to:g})=>{const y=m.pos,v=g.pos;t.doc.nodesBetween(y,v,(w,N)=>{if(a&&w.inlineContent&&!w.type.allowsMarkType(a))return!1;if(!w.isText&&!w.marks.length)return;const k=Math.max(y,N),E=Math.min(v,N+w.nodeSize),C=E-k;o+=C,c.push(...w.marks.map(T=>({mark:T,from:k,to:E})))})}),o===0)return!1;const u=c.filter(m=>a?a.name===m.mark.type.name:!0).filter(m=>jh(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 V8(t,e,n={}){if(!e)return ya(t,null,n)||Xg(t,null,n);const r=Cf(e,t.schema);return r==="node"?ya(t,e,n):r==="mark"?Xg(t,e,n):!1}var H8=(t,e)=>{const{$from:n,$to:r,$anchor:i}=t.selection;if(e){const a=Ef(c=>c.type.name===e)(t.selection);if(!a)return!1;const o=t.doc.resolve(a.pos+1);return i.pos+1===o.end()}return!(r.parentOffset{const{$from:e,$to:n}=t.selection;return!(e.parentOffset>0||e.pos!==n.pos)};function hN(t,e){return Array.isArray(e)?e.some(n=>(typeof n=="string"?n:n.name)===t.name):e}function fN(t,e){const{nodeExtensions:n}=Tl(e),r=n.find(o=>o.name===t);if(!r)return!1;const i={name:r.name,options:r.options,storage:r.storage},a=yt(Ve(r,"group",i));return typeof a!="string"?!1:a.split(" ").includes("list")}function Tf(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 i=!0;return t.content.forEach(a=>{i!==!1&&(Tf(a,{ignoreWhitespace:n,checkChildren:e})||(i=!1))}),i}return!1}function N2(t){return t instanceof We}var w2=class j2{constructor(e){this.position=e}static fromJSON(e){return new j2(e.position)}toJSON(){return{position:this.position}}};function U8(t,e){const n=e.mapping.mapResult(t.position);return{position:new w2(n.pos),mapResult:n}}function K8(t){return new w2(t)}function q8(t,e,n){var r;const{selection:i}=e;let a=null;if(o2(i)&&(a=i.$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}=i;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(w=>w.type.excludes(n));h=y&&v}return!h}),h})}var G8=(t,e={})=>({tr:n,state:r,dispatch:i})=>{const{selection:a}=n,{empty:o,ranges:c}=a,u=ji(t,r.schema);if(i)if(o){const h=u2(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),w=Math.min(y+g.nodeSize,m);g.marks.find(k=>k.type===u)?g.marks.forEach(k=>{u===k.type&&n.addMark(v,w,u.create({...k.attrs,...e}))}):n.addMark(v,w,u.create(e))})});return q8(r,n,u)},J8=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),Y8=(t,e={})=>({state:n,dispatch:r,chain:i})=>{const a=pn(t,n.schema);let o;return n.selection.$anchor.sameParent(n.selection.$head)&&(o=n.selection.$anchor.parent.attrs),a.isTextblock?i().command(({commands:c})=>S1(a,{...o,...e})(n)?!0:c.clearNodes()).command(({state:c})=>S1(a,{...o,...e})(c,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},Q8=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,i=no(t,0,r.content.size),a=We.create(r,i);e.setSelection(a)}return!0},X8=(t,e)=>({tr:n,state:r,dispatch:i})=>{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),i&&n.doc.nodesBetween(o,c,(u,h)=>{u.isText||n.setNodeMarkup(h,void 0,{...u.attrs,dir:t})}),!0},Z8=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,{from:i,to:a}=typeof t=="number"?{from:t,to:t}:t,o=Ue.atStart(r).from,c=Ue.atEnd(r).to,u=no(i,o,c),h=no(a,o,c),f=Ue.create(r,u,h);e.setSelection(f)}return!0},e6=t=>({state:e,dispatch:n})=>{const r=pn(t,e.schema);return qO(r)(e,n)};function pN(t,e){const n=t.storedMarks||t.selection.$to.parentOffset&&t.selection.$from.marks();if(n){const r=n.filter(i=>e==null?void 0:e.includes(i.type.name));t.tr.ensureMarks(r)}}var t6=({keepMarks:t=!0}={})=>({tr:e,state:n,dispatch:r,editor:i})=>{const{selection:a,doc:o}=e,{$from:c,$to:u}=a,h=i.extensionManager.attributes,f=Xu(h,c.node().type.name,c.node().attrs);if(a instanceof We&&a.node.isBlock)return!c.parentOffset||!yi(o,c.pos)?!1:(r&&(t&&pN(n,i.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:M8(c.node(-1).contentMatchAt(c.indexAfter(-1)));let y=m&&g?[{type:g,attrs:f}]:void 0,v=yi(e.doc,e.mapping.map(c.pos),1,y);if(!y&&!v&&yi(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 Ue&&e.deleteSelection(),e.split(e.mapping.map(c.pos),1,y),g&&!m&&!c.parentOffset&&c.parent.type!==g)){const w=e.mapping.map(c.before()),N=e.doc.resolve(w);c.node(-1).canReplaceWith(N.index(),N.index()+1,g)&&e.setNodeMarkup(e.mapping.map(c.before()),g)}t&&pN(n,i.extensionManager.splittableMarks),e.scrollIntoView()}return v},n6=(t,e={})=>({tr:n,state:r,dispatch:i,editor:a})=>{var o;const c=pn(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(i){let k=ge.empty;const E=u.index(-1)?1:u.index(-2)?2:3;for(let R=u.depth-E;R>=u.depth-3;R-=1)k=ge.from(u.node(R).copy(k));const C=u.indexAfter(-1){if(I>-1)return!1;R.isTextblock&&R.content.size===0&&(I=P+1)}),I>-1&&n.setSelection(Ue.near(n.doc.resolve(I))),n.scrollIntoView()}return!0}const y=h.pos===u.end()?m.contentMatchAt(0).defaultType:null,v={...Xu(g,m.type.name,m.attrs),...e},w={...Xu(g,u.node().type.name,u.node().attrs),...e};n.delete(u.pos,h.pos);const N=y?[{type:c,attrs:v},{type:y,attrs:w}]:[{type:c,attrs:v}];if(!yi(n.doc,u.pos,2))return!1;if(i){const{selection:k,storedMarks:E}=r,{splittableMarks:C}=a.extensionManager,T=E||k.$to.parentOffset&&k.$from.marks();if(n.split(u.pos,2,N).scrollIntoView(),!T||!i)return!0;const O=T.filter(F=>C.includes(F.type.name));n.ensureMarks(O)}return!0},Qm=(t,e)=>{const n=Ef(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 i=t.doc.nodeAt(r);return n.node.type===(i==null?void 0:i.type)&&Sa(t.doc,n.pos)&&t.join(n.pos),!0},Xm=(t,e)=>{const n=Ef(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 i=t.doc.nodeAt(r);return n.node.type===(i==null?void 0:i.type)&&Sa(t.doc,r)&&t.join(r),!0},r6=(t,e,n,r={})=>({editor:i,tr:a,state:o,dispatch:c,chain:u,commands:h,can:f})=>{const{extensions:m,splittableMarks:g}=i.extensionManager,y=pn(t,o.schema),v=pn(e,o.schema),{selection:w,storedMarks:N}=o,{$from:k,$to:E}=w,C=k.blockRange(E),T=N||w.$to.parentOffset&&w.$from.marks();if(!C)return!1;const O=Ef(F=>fN(F.type.name,m))(w);if(C.depth>=1&&O&&C.depth-O.depth<=1){if(O.node.type===y)return h.liftListItem(v);if(fN(O.node.type.name,m)&&y.validContent(O.node.content)&&c)return u().command(()=>(a.setNodeMarkup(O.pos,y),!0)).command(()=>Qm(a,y)).command(()=>Xm(a,y)).run()}return!n||!T||!c?u().command(()=>f().wrapInList(y,r)?!0:h.clearNodes()).wrapInList(y,r).command(()=>Qm(a,y)).command(()=>Xm(a,y)).run():u().command(()=>{const F=f().wrapInList(y,r),I=T.filter(R=>g.includes(R.type.name));return a.ensureMarks(I),F?!0:h.clearNodes()}).wrapInList(y,r).command(()=>Qm(a,y)).command(()=>Xm(a,y)).run()},s6=(t,e={},n={})=>({state:r,commands:i})=>{const{extendEmptyMarkRange:a=!1}=n,o=ji(t,r.schema);return Xg(r,o,e)?i.unsetMark(o,{extendEmptyMarkRange:a}):i.setMark(o,e)},i6=(t,e,n={})=>({state:r,commands:i})=>{const a=pn(t,r.schema),o=pn(e,r.schema),c=ya(r,a,n);let u;return r.selection.$anchor.sameParent(r.selection.$head)&&(u=r.selection.$anchor.parent.attrs),c?i.setNode(o,u):i.setNode(a,{...u,...n})},a6=(t,e={})=>({state:n,commands:r})=>{const i=pn(t,n.schema);return ya(n,i,e)?r.lift(i):r.wrapIn(i,e)},o6=()=>({state:t,dispatch:e})=>{const n=t.plugins;for(let r=0;r=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},l6=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,{empty:r,ranges:i}=n;return r||e&&i.forEach(a=>{t.removeMark(a.$from.pos,a.$to.pos)}),!0},c6=(t,e={})=>({tr:n,state:r,dispatch:i})=>{var a;const{extendEmptyMarkRange:o=!1}=e,{selection:c}=n,u=ji(t,r.schema),{$from:h,empty:f,ranges:m}=c;if(!i)return!0;if(f&&o){let{from:g,to:y}=c;const v=(a=h.marks().find(N=>N.type===u))==null?void 0:a.attrs,w=b0(h,u,v);w&&(g=w.from,y=w.to),n.removeMark(g,y,u)}else m.forEach(g=>{n.removeMark(g.$from.pos,g.$to.pos,u)});return n.removeStoredMark(u),!0},d6=t=>({tr:e,state:n,dispatch:r})=>{const{selection:i}=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=i.from,o=i.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},u6=(t,e={})=>({tr:n,state:r,dispatch:i})=>{let a=null,o=null;const c=Cf(typeof t=="string"?t:t.name,r.schema);if(!c)return!1;c==="node"&&(a=pn(t,r.schema)),c==="mark"&&(o=ji(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,w;n.selection.empty?r.doc.nodesBetween(f,m,(N,k)=>{a&&a===N.type&&(u=!0,v=Math.max(k,f),w=Math.min(k+N.nodeSize,m),g=k,y=N)}):r.doc.nodesBetween(f,m,(N,k)=>{k=f&&k<=m&&(a&&a===N.type&&(u=!0,i&&n.setNodeMarkup(k,void 0,{...N.attrs,...e})),o&&N.marks.length&&N.marks.forEach(E=>{if(o===E.type&&(u=!0,i)){const C=Math.max(k,f),T=Math.min(k+N.nodeSize,m);n.addMark(C,T,o.create({...E.attrs,...e}))}}))}),y&&(g!==void 0&&i&&n.setNodeMarkup(g,void 0,{...y.attrs,...e}),o&&y.marks.length&&y.marks.forEach(N=>{o===N.type&&i&&n.addMark(v,w,o.create({...N.attrs,...e}))}))}),u},h6=(t,e={})=>({state:n,dispatch:r})=>{const i=pn(t,n.schema);return FO(i,e)(n,r)},f6=(t,e={})=>({state:n,dispatch:r})=>{const i=pn(t,n.schema);return BO(i,e)(n,r)},p6=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={}}},Mf=class{constructor(t){var e;this.find=t.find,this.handler=t.handler,this.undoable=(e=t.undoable)!=null?e:!0}},m6=(t,e)=>{if(v0(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 Ou(t){var e;const{editor:n,from:r,to:i,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=B8(h)+a;return o.forEach(g=>{if(f)return;const y=m6(m,g.find);if(!y)return;const v=u.state.tr,w=kf({state:u.state,transaction:v}),N={from:r-(y[0].length-a.length),to:i},{commands:k,chain:E,can:C}=new Sf({editor:n,state:w});g.handler({state:w,range:N,match:y,commands:k,chain:E,can:C})===null||!v.steps.length||(g.undoable&&v.setMeta(c,{transform:v,from:r,to:i,text:a}),u.dispatch(v),f=!0)}),f}function g6(t){const{editor:e,rules:n}=t,r=new Dt({state:{init(){return null},apply(i,a,o){const c=i.getMeta(r);if(c)return c;const u=i.getMeta("applyInputRules");return!!u&&setTimeout(()=>{let{text:f}=u;typeof f=="string"?f=f:f=w0(ge.from(f),o.schema);const{from:m}=u,g=m+f.length;Ou({editor:e,from:m,to:g,text:f,rules:n,plugin:r})}),i.selectionSet||i.docChanged?null:a}},props:{handleTextInput(i,a,o,c){return Ou({editor:e,from:a,to:o,text:c,rules:n,plugin:r})},handleDOMEvents:{compositionend:i=>(setTimeout(()=>{const{$cursor:a}=i.state.selection;a&&Ou({editor:e,from:a.pos,to:a.pos,text:"",rules:n,plugin:r})}),!1)},handleKeyDown(i,a){if(a.key!=="Enter")return!1;const{$cursor:o}=i.state.selection;return o?Ou({editor:e,from:o.pos,to:o.pos,text:` -`,rules:n,plugin:r}):!1}},isInputRules:!0});return r}function x6(t){return Object.prototype.toString.call(t).slice(8,-1)}function Du(t){return x6(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function k2(t,e){const n={...t};return Du(t)&&Du(e)&&Object.keys(e).forEach(r=>{Du(e[r])&&Du(t[r])?n[r]=k2(t[r],e[r]):n[r]=e[r]}),n}var k0=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{...yt(Ve(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...yt(Ve(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(t={}){const e=this.extend({...this.config,addOptions:()=>k2(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}},Co=class S2 extends k0{constructor(){super(...arguments),this.type="mark"}static create(e={}){const n=typeof e=="function"?e():e;return new S2(n)}static handleExit({editor:e,mark:n}){const{tr:r}=e.state,i=e.state.selection.$from;if(i.pos===i.end()){const o=i.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(" ",i.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 y6(t){return typeof t=="number"}var v6=class{constructor(t){this.find=t.find,this.handler=t.handler}},b6=(t,e,n)=>{if(v0(e))return[...t.matchAll(e)];const r=e(t,n);return r?r.map(i=>{const a=[i.text];return a.index=i.index,a.input=t,a.data=i.data,i.replaceWith&&(i.text.includes(i.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),a.push(i.replaceWith)),a}):[]};function N6(t){const{editor:e,state:n,from:r,to:i,rule:a,pasteEvent:o,dropEvent:c}=t,{commands:u,chain:h,can:f}=new Sf({editor:e,state:n}),m=[];return n.doc.nodesBetween(r,i,(y,v)=>{var w,N,k,E,C;if((N=(w=y.type)==null?void 0:w.spec)!=null&&N.code||!(y.isText||y.isTextblock||y.isInline))return;const T=(C=(E=(k=y.content)==null?void 0:k.size)!=null?E:y.nodeSize)!=null?C:0,O=Math.max(r,v),F=Math.min(i,v+T);if(O>=F)return;const I=y.isText?y.text||"":y.textBetween(O-v,F-v,void 0,"");b6(I,a.find,o).forEach(P=>{if(P.index===void 0)return;const L=O+P.index+1,ee=L+P[0].length,te={from:n.tr.mapping.map(L),to:n.tr.mapping.map(ee)},Y=a.handler({state:n,range:te,match:P,commands:u,chain:h,can:f,pasteEvent:o,dropEvent:c});m.push(Y)})}),m.every(y=>y!==null)}var Lu=null,w6=t=>{var e;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=n.clipboardData)==null||e.setData("text/html",t),n};function j6(t){const{editor:e,rules:n}=t;let r=null,i=!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 w=f.tr,N=kf({state:f,transaction:w});if(!(!N6({editor:e,state:N,from:Math.max(m-1,0),to:g.b-1,rule:y,pasteEvent:v,dropEvent:c})||!w.steps.length)){try{c=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{c=null}return o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,w}};return n.map(f=>new Dt({view(m){const g=v=>{var w;r=(w=m.dom.parentElement)!=null&&w.contains(v.target)?m.dom.parentElement:null,r&&(Lu=e)},y=()=>{Lu&&(Lu=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=Lu;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,i=!!(v!=null&&v.includes("data-pm-slice")),!1}}},appendTransaction:(m,g,y)=>{const v=m[0],w=v.getMeta("uiEvent")==="paste"&&!i,N=v.getMeta("uiEvent")==="drop"&&!a,k=v.getMeta("applyPasteRules"),E=!!k;if(!w&&!N&&!E)return;if(E){let{text:O}=k;typeof O=="string"?O=O:O=w0(ge.from(O),y.schema);const{from:F}=k,I=F+O.length,R=w6(O);return u({rule:f,state:y,from:F,to:{b:I},pasteEvt:R})}const C=g.doc.content.findDiffStart(y.doc.content),T=g.doc.content.findDiffEnd(y.doc.content);if(!(!y6(C)||!T||C===T.b))return u({rule:f,state:y,from:C,to:T,pasteEvt:o})}}))}var Af=class{constructor(t,e){this.splittableMarks=[],this.editor=e,this.baseExtensions=t,this.extensions=g2(t),this.schema=O8(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:kc(e.name,this.schema)},r=Ve(e,"addCommands",n);return r?{...t,...r()}:t},{})}get plugins(){const{editor:t}=this;return $c([...this.extensions].reverse()).flatMap(r=>{const i={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:t,type:kc(r.name,this.schema)},a=[],o=Ve(r,"addKeyboardShortcuts",i);let c={};if(r.type==="mark"&&Ve(r,"exitable",i)&&(c.ArrowRight=()=>Co.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=_L(c);a.push(u);const h=Ve(r,"addInputRules",i);if(hN(r,t.options.enableInputRules)&&h){const g=h();if(g&&g.length){const y=g6({editor:t,rules:g}),v=Array.isArray(y)?y:[y];a.push(...v)}}const f=Ve(r,"addPasteRules",i);if(hN(r,t.options.enablePasteRules)&&f){const g=f();if(g&&g.length){const y=j6({editor:t,rules:g});a.push(...y)}}const m=Ve(r,"addProseMirrorPlugins",i);if(m){const g=m();a.push(...g)}return a})}get attributes(){return m2(this.extensions)}get nodeViews(){const{editor:t}=this,{nodeExtensions:e}=Tl(this.extensions);return Object.fromEntries(e.filter(n=>!!Ve(n,"addNodeView")).map(n=>{const r=this.attributes.filter(u=>u.type===n.name),i={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:pn(n.name,this.schema)},a=Ve(n,"addNodeView",i);if(!a)return[];const o=a();if(!o)return[];const c=(u,h,f,m,g)=>{const y=sd(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 $c([...this.extensions].reverse()).reduceRight((r,i)=>{const a={name:i.name,options:i.options,storage:this.editor.extensionStorage[i.name],editor:e,type:kc(i.name,this.schema)},o=Ve(i,"dispatchTransaction",a);return o?c=>{o.call(a,{transaction:c,next:r})}:r},t)}transformPastedHTML(t){const{editor:e}=this;return $c([...this.extensions]).reduce((r,i)=>{const a={name:i.name,options:i.options,storage:this.editor.extensionStorage[i.name],editor:e,type:kc(i.name,this.schema)},o=Ve(i,"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=>!!Ve(n,"addMarkView")).map(n=>{const r=this.attributes.filter(c=>c.type===n.name),i={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:ji(n.name,this.schema)},a=Ve(n,"addMarkView",i);if(!a)return[];const o=(c,u,h)=>{const f=sd(c,r);return a()({mark:c,view:u,inline:h,editor:t,extension:n,HTMLAttributes:f,updateAttributes:m=>{z6(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:kc(e.name,this.schema)};e.type==="mark"&&((n=yt(Ve(e,"keepOnSplit",r)))==null||n)&&this.splittableMarks.push(e.name);const i=Ve(e,"onBeforeCreate",r),a=Ve(e,"onCreate",r),o=Ve(e,"onUpdate",r),c=Ve(e,"onSelectionUpdate",r),u=Ve(e,"onTransaction",r),h=Ve(e,"onFocus",r),f=Ve(e,"onBlur",r),m=Ve(e,"onDestroy",r);i&&this.editor.on("beforeCreate",i),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)})}};Af.resolve=g2;Af.sort=$c;Af.flatten=N0;var k6={};y0(k6,{ClipboardTextSerializer:()=>E2,Commands:()=>T2,Delete:()=>M2,Drop:()=>A2,Editable:()=>I2,FocusEvents:()=>P2,Keymap:()=>O2,Paste:()=>D2,Tabindex:()=>L2,TextDirection:()=>_2,focusEventsPluginKey:()=>R2});var on=class C2 extends k0{constructor(){super(...arguments),this.type="extension"}static create(e={}){const n=typeof e=="function"?e():e;return new C2(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}},E2=on.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new Dt({key:new Ht("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:t}=this,{state:e,schema:n}=t,{doc:r,selection:i}=e,{ranges:a}=i,o=Math.min(...a.map(f=>f.$from.pos)),c=Math.max(...a.map(f=>f.$to.pos)),u=y2(n);return x2(r,{from:o,to:c},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:u})}}})]}}),T2=on.create({name:"commands",addCommands(){return{...i2}}}),M2=on.create({name:"delete",onUpdate({transaction:t,appendedTransactions:e}){var n,r,i;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=h2(t.before,[t,...e]);b2(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,w)=>{const N=w+v.nodeSize-2,k=y.oldRange.from<=w&&N<=y.oldRange.to;this.editor.emit("delete",{type:"node",node:v,from:w,to:N,newFrom:f.mapping.map(w),newTo:f.mapping.map(N),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 w,N;if(y instanceof fs){const k=g.slice(v).map(y.from,-1),E=g.slice(v).map(y.to),C=g.invert().map(k,-1),T=g.invert().map(E),O=(w=f.doc.nodeAt(k-1))==null?void 0:w.marks.some(I=>I.eq(y.mark)),F=(N=f.doc.nodeAt(E))==null?void 0:N.marks.some(I=>I.eq(y.mark));this.editor.emit("delete",{type:"mark",mark:y.mark,from:y.from,to:y.to,deletedRange:{from:C,to:T},newRange:{from:k,to:E},partial:!!(F||O),editor:this.editor,transaction:t,combinedTransform:f})}})};(i=(r=(n=this.editor.options.coreExtensionOptions)==null?void 0:n.delete)==null?void 0:r.async)==null||i?setTimeout(a,0):a()}}),A2=on.create({name:"drop",addProseMirrorPlugins(){return[new Dt({key:new Ht("tiptapDrop"),props:{handleDrop:(t,e,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:r})}}})]}}),I2=on.create({name:"editable",addProseMirrorPlugins(){return[new Dt({key:new Ht("editable"),props:{editable:()=>this.editor.options.editable}})]}}),R2=new Ht("focusEvents"),P2=on.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new Dt({key:R2,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}}}})]}}),O2=on.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,w=v.parent.type.spec.isolating,N=m.pos-m.parentOffset,k=w&&v.parent.childCount===1?N===m.pos:Qe.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()},i={...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 kh()||d2()?a:i},addProseMirrorPlugins(){return[new Dt({key:new Ht("clearDocument"),appendTransaction:(t,e,n)=>{if(t.some(w=>w.getMeta("composition")))return;const r=t.some(w=>w.docChanged)&&!e.doc.eq(n.doc),i=t.some(w=>w.getMeta("preventClearDocument"));if(!r||i)return;const{empty:a,from:o,to:c}=e.selection,u=Qe.atStart(e.doc).from,h=Qe.atEnd(e.doc).to;if(a||!(o===u&&c===h)||!Tf(n.doc))return;const g=n.tr,y=kf({state:n,transaction:g}),{commands:v}=new Sf({editor:this.editor,state:y});if(v.clearNodes(),!!g.steps.length)return g}})]}}),D2=on.create({name:"paste",addProseMirrorPlugins(){return[new Dt({key:new Ht("tiptapPaste"),props:{handlePaste:(t,e,n)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:n})}}})]}}),L2=on.create({name:"tabindex",addProseMirrorPlugins(){return[new Dt({key:new Ht("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),_2=on.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 Dt({key:new Ht("textDirection"),props:{attributes:()=>{const t=this.options.direction;return t?{dir:t}:{}}}})]}}),S6=class Ac{constructor(e,n,r=!1,i=null){this.currentNode=null,this.actualDepth=null,this.isBlock=r,this.resolvedPos=e,this.editor=n,this.currentNode=i}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 can’t 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 Ac(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 Ac(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 Ac(e,this.editor)}get children(){const e=[];return this.node.content.forEach((n,r)=>{const i=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(!i&&!o&&u.depth<=this.depth)return;const h=new Ac(u,this.editor,i,i||o?n:null);i&&(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,i=this.parent;for(;i&&!r;){if(i.node.type.name===e)if(Object.keys(n).length>0){const a=i.node.attrs,o=Object.keys(n);for(let c=0;c{r&&i.length>0||(o.node.type.name===e&&a.every(u=>n[u]===o.node.attrs[u])&&i.push(o),!(r&&i.length>0)&&(i=i.concat(o.querySelectorAll(e,n,r))))}),i}setAttribute(e){const{tr:n}=this.editor.state;n.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(n)}},C6=`.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 E6(t,e,n){const r=document.querySelector("style[data-tiptap-style]");if(r!==null)return r;const i=document.createElement("style");return e&&i.setAttribute("nonce",e),i.setAttribute("data-tiptap-style",""),i.innerHTML=t,document.getElementsByTagName("head")[0].appendChild(i),i}var T6=class extends p6{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:U8,createMappablePosition:K8},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:i,moved:a})=>this.options.onDrop(r,i,a)),this.on("paste",({event:r,slice:i})=>this.options.onPaste(r,i)),this.on("delete",this.options.onDelete);const e=this.createDoc(),n=l2(e,this.options.autofocus);this.editorState=gl.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=E6(C6,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=p2(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(i=>{const a=typeof i=="string"?`${i}$`:i.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?[I2,E2.configure({blockSeparator:(e=(t=this.options.coreExtensionOptions)==null?void 0:t.clipboardTextSerializer)==null?void 0:e.blockSeparator}),T2,P2,O2,L2,A2,D2,M2,_2.configure({direction:this.options.textDirection})].filter(i=>typeof this.options.enableCoreExtensions=="object"?this.options.enableCoreExtensions[i.name]!==!1:!0):[],...this.options.extensions].filter(i=>["extension","node","mark"].includes(i==null?void 0:i.type));this.extensionManager=new Af(r,this)}createCommandManager(){this.commandManager=new Sf({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let t;try{t=Qg(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=Qg(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),i=n?this.extensionManager.dispatchTransaction(r):r,a=e.transformPastedHTML,o=this.extensionManager.transformPastedHTML(a);this.editorView=new s2(t,{...e,attributes:{role:"textbox",...e==null?void 0:e.attributes},dispatchTransaction:i,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),i=n.includes(t),a=this.state;if(this.emit("beforeTransaction",{editor:this,transaction:t,nextState:e}),!i)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 v2(this.state,t)}isActive(t,e){const n=typeof t=="string"?t:null,r=typeof t=="string"?e:t;return V8(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return w0(this.state.doc.content,this.schema)}getText(t){const{blockSeparator:e=` - -`,textSerializers:n={}}=t||{};return L8(this.state.doc,{blockSeparator:e,textSerializers:{...y2(this.schema),...n}})}get isEmpty(){return Tf(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 S6(e,this)}get $doc(){return this.$pos(0)}};function Ml(t){return new Mf({find:t.find,handler:({state:e,range:n,match:r})=>{const i=yt(t.getAttributes,void 0,r);if(i===!1||i===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(j0(n.from,n.to,e.doc).filter(y=>y.mark.type.excluded.find(w=>w===t.type&&w!==y.mark.type)).filter(y=>y.to>h).length)return null;fn.from&&a.delete(n.from+u,h);const g=n.from+u+o.length;a.addMark(n.from+u,g,t.type.create(i||{})),a.removeStoredMark(t.type)}},undoable:t.undoable})}function z2(t){return new Mf({find:t.find,handler:({state:e,range:n,match:r})=>{const i=yt(t.getAttributes,void 0,r)||{},{tr:a}=e,o=n.from;let c=n.to;const u=t.type.create(i);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(i)).delete(a.mapping.map(o),a.mapping.map(c))}a.scrollIntoView()},undoable:t.undoable})}function Zg(t){return new Mf({find:t.find,handler:({state:e,range:n,match:r})=>{const i=e.doc.resolve(n.from),a=yt(t.getAttributes,void 0,r)||{};if(!i.node(-1).canReplaceWith(i.index(-1),i.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 Al(t){return new Mf({find:t.find,handler:({state:e,range:n,match:r,chain:i})=>{const a=yt(t.getAttributes,void 0,r)||{},o=e.tr.delete(n.from,n.to),u=o.doc.resolve(n.from).blockRange(),h=u&&e0(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 w=v.filter(N=>y.includes(N.type.name));o.ensureMarks(w)}}if(t.keepAttributes){const m=t.type.name==="bulletList"||t.type.name==="orderedList"?"listItem":"taskList";i().updateAttributes(m,a).run()}const f=o.doc.resolve(n.from-1).nodeBefore;f&&f.type===t.type&&Sa(o.doc,n.from-1)&&(!t.joinPredicate||t.joinPredicate(r,f))&&o.join(n.from-1)},undoable:t.undoable})}var M6=t=>"touches"in t,A6=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,i,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),(i=t.options)!=null&&i.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"),i=e.includes("left"),a=e.includes("right");n&&(t.style.top="0"),r&&(t.style.bottom="0"),i&&(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,M6(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:i}=this.calculateNewDimensions(this.activeHandle,t,e),a=this.applyConstraints(r,i,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,i=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?i=this.startHeight+n:u&&(i=this.startHeight-n),(t==="right"||t==="left")&&(r=this.startWidth+(a?e:-e)),(t==="top"||t==="bottom")&&(i=this.startHeight+(c?n:-n)),this.preserveAspectRatio||this.isShiftKeyPressed?this.applyAspectRatio(r,i,t):{width:r,height:i}}applyConstraints(t,e,n){var r,i,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)),(i=this.maxSize)!=null&&i.height&&(f=Math.min(this.maxSize.height,f)),{width:h,height:f}}let c=t,u=e;return cthis.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",i=n==="top"||n==="bottom";return r?{width:t,height:t/this.aspectRatio}:i?{width:e*this.aspectRatio,height:e}:{width:t,height:t/this.aspectRatio}}};function I6(t,e){const{selection:n}=t,{$from:r}=n;if(n instanceof We){const a=r.index();return r.parent.canReplaceWith(a,a+1,e)}let i=r.depth;for(;i>=0;){const a=r.index(i);if(r.node(i).contentMatchAt(a).matchType(e))return!0;i-=1}return!1}function R6(t){return t.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}var P6={};y0(P6,{createAtomBlockMarkdownSpec:()=>O6,createBlockMarkdownSpec:()=>D6,createInlineMarkdownSpec:()=>$2,parseAttributes:()=>S0,parseIndentedBlocks:()=>ex,renderNestedMarkdownContent:()=>E0,serializeAttributes:()=>C0});function S0(t){if(!(t!=null&&t.trim()))return{};const e={},n=[],r=t.replace(/["']([^"']*)["']/g,h=>(n.push(h),`__QUOTED_${n.length-1}__`)),i=r.match(/(?:^|\s)\.([a-zA-Z][\w-]*)/g);if(i){const h=i.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 C0(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 O6(t){const{nodeName:e,name:n,parseAttributes:r=S0,serializeAttributes:i=C0,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 w=v[1]||"",N=r(w);if(!o.find(E=>!(E in N)))return{type:e,raw:v[0],attributes:N}}},renderMarkdown:f=>{const m=h(f.attrs||{}),g=i(m),y=g?` {${g}}`:"";return`:::${u}${y} :::`}}}function D6(t){const{nodeName:e,name:n,getContent:r,parseAttributes:i=S0,serializeAttributes:a=C0,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 w=r(m);y=typeof w=="string"?[{type:"text",text:w}]:w}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 w=new RegExp(`^:::${h}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),N=m.match(w);if(!N)return;const[k,E=""]=N,C=i(E);let T=1;const O=k.length;let F="";const I=/^:::([\w-]*)(\s.*)?/gm,R=m.slice(O);for(I.lastIndex=0;;){const P=I.exec(R);if(P===null)break;const L=P.index,ee=P[1];if(!((v=P[2])!=null&&v.endsWith(":::"))){if(ee)T+=1;else if(T-=1,T===0){const te=R.slice(0,L);F=te.trim();const Y=m.slice(0,O+L+P[0].length);let U=[];if(F)if(c==="block")for(U=y.blockTokens(te),U.forEach(D=>{D.text&&(!D.tokens||D.tokens.length===0)&&(D.tokens=y.inlineTokens(D.text))});U.length>0;){const D=U[U.length-1];if(D.type==="paragraph"&&(!D.text||D.text.trim()===""))U.pop();else break}else U=y.inlineTokens(F);return{type:e,raw:Y,attributes:C,content:F,tokens:U}}}}}},renderMarkdown:(m,g)=>{const y=f(m.attrs||{}),v=a(y),w=v?` {${v}}`:"",N=g.renderChildren(m.content||[],` - -`);return`:::${h}${w} - -${N} - -:::`}}}function L6(t){if(!t.trim())return{};const e={},n=/(\w+)=(?:"([^"]*)"|'([^']*)')/g;let r=n.exec(t);for(;r!==null;){const[,i,a,o]=r;e[i]=a||o,r=n.exec(t)}return e}function _6(t){return Object.entries(t).filter(([,e])=>e!=null).map(([e,n])=>`${e}="${n}"`).join(" ")}function $2(t){const{nodeName:e,name:n,getContent:r,parseAttributes:i=L6,serializeAttributes:a=_6,defaultAttributes:o={},selfClosing:c=!1,allowedAttributes:u}=t,h=n||e,f=g=>{if(!u)return g;const y={};return u.forEach(v=>{const w=typeof v=="string"?v:v.name,N=typeof v=="string"?void 0:v.skipIfDefault;if(w in g){const k=g[w];if(N!==void 0&&k===N)return;y[w]=k}}),y},m=h.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return{parseMarkdown:(g,y)=>{const v={...o,...g.attributes};if(c)return y.createNode(e,v);const w=r?r(g):g.content||"";return w?y.createNode(e,v,[y.createTextNode(w)]):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),w=v==null?void 0:v.index;return w!==void 0?w:-1},tokenize(g,y,v){const w=c?new RegExp(`^\\[${m}\\s*([^\\]]*)\\]`):new RegExp(`^\\[${m}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${m}\\]`),N=g.match(w);if(!N)return;let k="",E="";if(c){const[,T]=N;E=T}else{const[,T,O]=N;E=T,k=O||""}const C=i(E.trim());return{type:e,raw:N[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||{}),w=a(v),N=w?` ${w}`:"";return c?`[${h}${N}]`:`[${h}${N}]${y}[/${h}]`}}}function ex(t,e,n){var r,i,a,o;const c=t.split(` -`),u=[];let h="",f=0;const m=e.baseIndentSize||2;for(;f0)break;if(g.trim()===""){f+=1,h=`${h}${g} -`;continue}else return}const v=e.extractItemData(y),{indentLevel:w,mainContent:N}=v;h=`${h}${g} -`;const k=[N];for(f+=1;fL.trim()!=="");if(I===-1)break;if((((i=(r=c[f+1+I].match(/^(\s*)/))==null?void 0:r[1])==null?void 0:i.length)||0)>w){k.push(O),h=`${h}${O} -`,f+=1;continue}else break}if((((o=(a=O.match(/^(\s*)/))==null?void 0:a[1])==null?void 0:o.length)||0)>w)k.push(O),h=`${h}${O} -`,f+=1;else break}let E;const C=k.slice(1);if(C.length>0){const O=C.map(F=>F.slice(w+m)).join(` -`);O.trim()&&(e.customNestedParser?E=e.customNestedParser(O):E=n.blockTokens(O))}const T=e.createToken(v,E);u.push(T)}if(u.length!==0)return{items:u,raw:h}}function E0(t,e,n,r){if(!t||!Array.isArray(t.content))return"";const i=typeof n=="function"?n(r):n,[a,...o]=t.content,c=e.renderChildren([a]),u=[`${i}${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 z6(t,e,n={}){const{state:r}=e,{doc:i,tr:a}=r,o=t;i.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 mn=class F2 extends k0{constructor(){super(...arguments),this.type="node"}static create(e={}){const n=typeof e=="function"?e():e;return new F2(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}};function vo(t){return new v6({find:t.find,handler:({state:e,range:n,match:r,pasteEvent:i})=>{const a=yt(t.getAttributes,void 0,r,i);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(j0(n.from,n.to,e.doc).filter(v=>v.mark.type.excluded.find(N=>N===t.type&&N!==v.mark.type)).filter(v=>v.to>m).length)return null;gn.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:$6,getOwnPropertySymbols:F6}=Object,{hasOwnProperty:B6}=Object.prototype;function Zm(t,e){return function(r,i,a){return t(r,i,a)&&e(r,i,a)}}function _u(t){return function(n,r,i){if(!n||!r||typeof n!="object"||typeof r!="object")return t(n,r,i);const{cache:a}=i,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,i);return a.delete(n),a.delete(r),u}}function V6(t){return t!=null?t[Symbol.toStringTag]:void 0}function mN(t){return $6(t).concat(F6(t))}const H6=Object.hasOwn||((t,e)=>B6.call(t,e));function Eo(t,e){return t===e||!t&&!e&&t!==t&&e!==e}const W6="__v",U6="__o",K6="_owner",{getOwnPropertyDescriptor:gN,keys:xN}=Object;function q6(t,e){return t.byteLength===e.byteLength&&Sh(new Uint8Array(t),new Uint8Array(e))}function G6(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 J6(t,e){return t.byteLength===e.byteLength&&Sh(new Uint8Array(t.buffer,t.byteOffset,t.byteLength),new Uint8Array(e.buffer,e.byteOffset,e.byteLength))}function Y6(t,e){return Eo(t.getTime(),e.getTime())}function Q6(t,e){return t.name===e.name&&t.message===e.message&&t.cause===e.cause&&t.stack===e.stack}function X6(t,e){return t===e}function yN(t,e,n){const r=t.size;if(r!==e.size)return!1;if(!r)return!0;const i=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(i[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=i[m]=!0;break}m++}if(!f)return!1;u++}return!0}const Z6=Eo;function e_(t,e,n){const r=xN(t);let i=r.length;if(xN(e).length!==i)return!1;for(;i-- >0;)if(!B2(t,e,n,r[i]))return!1;return!0}function Sc(t,e,n){const r=mN(t);let i=r.length;if(mN(e).length!==i)return!1;let a,o,c;for(;i-- >0;)if(a=r[i],!B2(t,e,n,a)||(o=gN(t,a),c=gN(e,a),(o||c)&&(!o||!c||o.configurable!==c.configurable||o.enumerable!==c.enumerable||o.writable!==c.writable)))return!1;return!0}function t_(t,e){return Eo(t.valueOf(),e.valueOf())}function n_(t,e){return t.source===e.source&&t.flags===e.flags}function vN(t,e,n){const r=t.size;if(r!==e.size)return!1;if(!r)return!0;const i=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(!i[f]&&n.equals(o.value,c.value,o.value,c.value,t,e,n)){h=i[f]=!0;break}f++}if(!h)return!1}return!0}function Sh(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 r_(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 B2(t,e,n,r){return(r===K6||r===U6||r===W6)&&(t.$$typeof||e.$$typeof)?!0:H6(e,r)&&n.equals(t[r],e[r],r,r,t,e,n)}const s_="[object ArrayBuffer]",i_="[object Arguments]",a_="[object Boolean]",o_="[object DataView]",l_="[object Date]",c_="[object Error]",d_="[object Map]",u_="[object Number]",h_="[object Object]",f_="[object RegExp]",p_="[object Set]",m_="[object String]",g_={"[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},x_="[object URL]",y_=Object.prototype.toString;function v_({areArrayBuffersEqual:t,areArraysEqual:e,areDataViewsEqual:n,areDatesEqual:r,areErrorsEqual:i,areFunctionsEqual:a,areMapsEqual:o,areNumbersEqual:c,areObjectsEqual:u,arePrimitiveWrappersEqual:h,areRegExpsEqual:f,areSetsEqual:m,areTypedArraysEqual:g,areUrlsEqual:y,unknownTagComparators:v}){return function(N,k,E){if(N===k)return!0;if(N==null||k==null)return!1;const C=typeof N;if(C!==typeof k)return!1;if(C!=="object")return C==="number"?c(N,k,E):C==="function"?a(N,k,E):!1;const T=N.constructor;if(T!==k.constructor)return!1;if(T===Object)return u(N,k,E);if(Array.isArray(N))return e(N,k,E);if(T===Date)return r(N,k,E);if(T===RegExp)return f(N,k,E);if(T===Map)return o(N,k,E);if(T===Set)return m(N,k,E);const O=y_.call(N);if(O===l_)return r(N,k,E);if(O===f_)return f(N,k,E);if(O===d_)return o(N,k,E);if(O===p_)return m(N,k,E);if(O===h_)return typeof N.then!="function"&&typeof k.then!="function"&&u(N,k,E);if(O===x_)return y(N,k,E);if(O===c_)return i(N,k,E);if(O===i_)return u(N,k,E);if(g_[O])return g(N,k,E);if(O===s_)return t(N,k,E);if(O===o_)return n(N,k,E);if(O===a_||O===u_||O===m_)return h(N,k,E);if(v){let F=v[O];if(!F){const I=V6(N);I&&(F=v[I])}if(F)return F(N,k,E)}return!1}}function b_({circular:t,createCustomConfig:e,strict:n}){let r={areArrayBuffersEqual:q6,areArraysEqual:n?Sc:G6,areDataViewsEqual:J6,areDatesEqual:Y6,areErrorsEqual:Q6,areFunctionsEqual:X6,areMapsEqual:n?Zm(yN,Sc):yN,areNumbersEqual:Z6,areObjectsEqual:n?Sc:e_,arePrimitiveWrappersEqual:t_,areRegExpsEqual:n_,areSetsEqual:n?Zm(vN,Sc):vN,areTypedArraysEqual:n?Zm(Sh,Sc):Sh,areUrlsEqual:r_,unknownTagComparators:void 0};if(e&&(r=Object.assign({},r,e(r))),t){const i=_u(r.areArraysEqual),a=_u(r.areMapsEqual),o=_u(r.areObjectsEqual),c=_u(r.areSetsEqual);r=Object.assign({},r,{areArraysEqual:i,areMapsEqual:a,areObjectsEqual:o,areSetsEqual:c})}return r}function N_(t){return function(e,n,r,i,a,o,c){return t(e,n,c)}}function w_({circular:t,comparator:e,createState:n,equals:r,strict:i}){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:i})};if(t)return function(c,u){return e(c,u,{cache:new WeakMap,equals:r,meta:void 0,strict:i})};const a={cache:void 0,equals:r,meta:void 0,strict:i};return function(c,u){return e(c,u,a)}}const j_=Ea();Ea({strict:!0});Ea({circular:!0});Ea({circular:!0,strict:!0});Ea({createInternalComparator:()=>Eo});Ea({strict:!0,createInternalComparator:()=>Eo});Ea({circular:!0,createInternalComparator:()=>Eo});Ea({circular:!0,createInternalComparator:()=>Eo,strict:!0});function Ea(t={}){const{circular:e=!1,createInternalComparator:n,createState:r,strict:i=!1}=t,a=b_(t),o=v_(a),c=n?n(o):N_(o);return w_({circular:e,comparator:o,createState:r,equals:c,strict:i})}var eg={exports:{}},tg={};/** - * @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 bN;function k_(){if(bN)return tg;bN=1;var t=cd(),e=Ak();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,i=e.useSyncExternalStore,a=t.useRef,o=t.useEffect,c=t.useMemo,u=t.useDebugValue;return tg.useSyncExternalStoreWithSelector=function(h,f,m,g,y){var v=a(null);if(v.current===null){var w={hasValue:!1,value:null};v.current=w}else w=v.current;v=c(function(){function k(F){if(!E){if(E=!0,C=F,F=g(F),y!==void 0&&w.hasValue){var I=w.value;if(y(I,F))return T=I}return T=F}if(I=T,r(C,F))return I;var R=g(F);return y!==void 0&&y(I,R)?(C=F,I):(C=F,T=R)}var E=!1,C,T,O=m===void 0?null:m;return[function(){return k(f())},O===null?void 0:function(){return k(O())}]},[f,m,g,y]);var N=i(h,v[0],v[1]);return o(function(){w.hasValue=!0,w.value=N},[N]),u(N),N},tg}var NN;function S_(){return NN||(NN=1,eg.exports=k_()),eg.exports}var C_=S_(),E_=(...t)=>e=>{t.forEach(n=>{typeof n=="function"?n(e):n&&(n.current=e)})},T_=({contentComponent:t})=>{const e=Ik.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getServerSnapshot);return s.jsx(s.Fragment,{children:Object.values(e)})};function M_(){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]:Tw.createPortal(r.reactElement,r.element,n)},t.forEach(i=>i())},removeRenderer(n){const r={...e};delete r[n],e=r,t.forEach(i=>i())}}}var A_=class extends ar.Component{constructor(t){var e;super(t),this.editorContentRef=ar.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=M_(),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 s.jsxs(s.Fragment,{children:[s.jsx("div",{ref:E_(e,this.editorContentRef),...n}),(t==null?void 0:t.contentComponent)&&s.jsx(T_,{contentComponent:t.contentComponent})]})}},I_=b.forwardRef((t,e)=>{const n=ar.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[t.editor]);return ar.createElement(A_,{key:n,innerRef:e,...t})}),V2=ar.memo(I_),R_=typeof window<"u"?b.useLayoutEffect:b.useEffect,P_=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 O_(t){var e;const[n]=b.useState(()=>new P_(t.editor)),r=C_.useSyncExternalStoreWithSelector(n.subscribe,n.getSnapshot,n.getServerSnapshot,t.selector,(e=t.equalityFn)!=null?e:j_);return R_(()=>n.watch(t.editor),[t.editor,n]),b.useDebugValue(r),r}var D_=!1,tx=typeof window>"u",L_=tx||!!(typeof window<"u"&&window.next),__=class H2{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?tx||L_?null:this.createEditor():(this.options.current.immediatelyRender,this.options.current.immediatelyRender?this.createEditor():null)}createEditor(){const e={...this.options.current,onBeforeCreate:(...r)=>{var i,a;return(a=(i=this.options.current).onBeforeCreate)==null?void 0:a.call(i,...r)},onBlur:(...r)=>{var i,a;return(a=(i=this.options.current).onBlur)==null?void 0:a.call(i,...r)},onCreate:(...r)=>{var i,a;return(a=(i=this.options.current).onCreate)==null?void 0:a.call(i,...r)},onDestroy:(...r)=>{var i,a;return(a=(i=this.options.current).onDestroy)==null?void 0:a.call(i,...r)},onFocus:(...r)=>{var i,a;return(a=(i=this.options.current).onFocus)==null?void 0:a.call(i,...r)},onSelectionUpdate:(...r)=>{var i,a;return(a=(i=this.options.current).onSelectionUpdate)==null?void 0:a.call(i,...r)},onTransaction:(...r)=>{var i,a;return(a=(i=this.options.current).onTransaction)==null?void 0:a.call(i,...r)},onUpdate:(...r)=>{var i,a;return(a=(i=this.options.current).onUpdate)==null?void 0:a.call(i,...r)},onContentError:(...r)=>{var i,a;return(a=(i=this.options.current).onContentError)==null?void 0:a.call(i,...r)},onDrop:(...r)=>{var i,a;return(a=(i=this.options.current).onDrop)==null?void 0:a.call(i,...r)},onPaste:(...r)=>{var i,a;return(a=(i=this.options.current).onPaste)==null?void 0:a.call(i,...r)},onDelete:(...r)=>{var i,a;return(a=(i=this.options.current).onDelete)==null?void 0:a.call(i,...r)}};return new T6(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((i,a)=>{var o;return i===((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?H2.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,i)=>r===e[i]))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 z_(t={},e=[]){const n=b.useRef(t);n.current=t;const[r]=b.useState(()=>new __(n)),i=Ik.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return b.useDebugValue(i),b.useEffect(r.onRender(e)),O_({editor:i,selector:({transactionNumber:a})=>t.shouldRerenderOnTransaction===!1||t.shouldRerenderOnTransaction===void 0?null:t.immediatelyRender&&a===0?0:a+1}),i}var W2=b.createContext({editor:null});W2.Consumer;var $_=b.createContext({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),F_=()=>b.useContext($_);ar.forwardRef((t,e)=>{const{onDragStart:n}=F_(),r=t.as||"div";return s.jsx(r,{...t,ref:e,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...t.style}})});ar.createContext({markViewContentRef:()=>{}});var T0=b.createContext({get editor(){throw new Error("useTiptap must be used within a provider")}});T0.displayName="TiptapContext";var B_=()=>b.useContext(T0);function U2({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 i=b.useMemo(()=>({editor:r}),[r]),a=b.useMemo(()=>({editor:r}),[r]);return s.jsx(W2.Provider,{value:a,children:s.jsx(T0.Provider,{value:i,children:n})})}U2.displayName="Tiptap";function K2({...t}){const{editor:e}=B_();return s.jsx(V2,{editor:e,...t})}K2.displayName="Tiptap.Content";Object.assign(U2,{Content:K2});var Ch=(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]},V_=/^\s*>\s$/,H_=mn.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return Ch("blockquote",{...vt(this.options.HTMLAttributes,t),children:Ch("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(i=>{const c=e.renderChildren([i]).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[Al({find:V_,type:this.type})]}}),W_=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,U_=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,K_=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,q_=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,G_=Co.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 Ch("strong",{...vt(this.options.HTMLAttributes,t),children:Ch("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[Ml({find:W_,type:this.type}),Ml({find:K_,type:this.type})]},addPasteRules(){return[vo({find:U_,type:this.type}),vo({find:q_,type:this.type})]}}),J_=/(^|[^`])`([^`]+)`(?!`)$/,Y_=/(^|[^`])`([^`]+)`(?!`)/g,Q_=Co.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[Ml({find:J_,type:this.type})]},addPasteRules(){return[vo({find:Y_,type:this.type})]}}),ng=4,X_=/^```([a-z]+)?[\s\n]$/,Z_=/^~~~([a-z]+)?[\s\n]$/,e7=mn.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:ng,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 i=((n=t.attrs)==null?void 0:n.language)||"";return t.content?r=[`\`\`\`${i}`,e.renderChildren(t.content),"```"].join(` -`):r=`\`\`\`${i} - -\`\`\``,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:ng,{state:r}=t,{selection:i}=r,{$from:a,empty:o}=i;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}=i,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:ng,{state:r}=t,{selection:i}=r,{$from:a,empty:o}=i;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,w=0;const N=h-f;for(let F=0;F=N){v=F;break}w+=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 T=f;for(let F=0;F{const{from:u,to:h}=i,g=r.doc.textBetween(u,h,` -`,` -`).split(` -`).map(y=>{var v;const w=((v=y.match(/^ */))==null?void 0:v[0])||"",N=Math.min(w.length,n);return y.slice(N)}).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:i}=n;if(!i||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:i,empty:a}=n;if(!a||i.parent.type!==this.type||!(i.parentOffset===i.parent.nodeSize-2))return!1;const c=i.after();return c===void 0?!1:r.nodeAt(c)?t.commands.command(({tr:h})=>(h.setSelection(Qe.near(r.resolve(c))),!0)):t.commands.exitCode()}}},addInputRules(){return[Zg({find:X_,type:this.type,getAttributes:t=>({language:t[1]})}),Zg({find:Z_,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new Dt({key:new Ht("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"),i=r?JSON.parse(r):void 0,a=i==null?void 0:i.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(Ue.near(o.doc.resolve(Math.max(0,o.selection.from-2)))),o.setMeta("paste",!0),t.dispatch(o),!0}}})]}}),t7=mn.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,` - -`):""}),n7=mn.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:i,storedMarks:a}=n;if(i.$from.parent.type.spec.isolating)return!1;const{keepMarks:o}=this.options,{splittableMarks:c}=r.extensionManager,u=a||i.$to.parentOffset&&i.$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()}}}),r7=mn.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,i="#".repeat(r);return t.content?`${i} ${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=>Zg({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}}),s7=mn.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(!I6(e,e.schema.nodes[this.name]))return!1;const{selection:n}=e,{$to:r}=n,i=t();return N2(n)?i.insertContentAt(r.pos,{type:this.name}):i.insertContent({type:this.name}),i.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(Ue.create(o.doc,u.pos+1)):u.nodeAfter.isBlock?o.setSelection(We.create(o.doc,u.pos)):o.setSelection(Ue.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(Ue.create(o.doc,h+1)))}o.scrollIntoView()}return!0}).run()}}},addInputRules(){return[z2({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),i7=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,a7=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,o7=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,l7=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,c7=Co.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[Ml({find:i7,type:this.type}),Ml({find:o7,type:this.type})]},addPasteRules(){return[vo({find:a7,type:this.type}),vo({find:l7,type:this.type})]}});const d7="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",u7="ελ1υ2бг1ел3дети4ею2католик6ом3мкд2он1сква6онлайн5рг3рус2ф2сайт3рб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همراه5پاکستان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",nx="numeric",rx="ascii",sx="alpha",Fc="asciinumeric",Ic="alphanumeric",ix="domain",q2="emoji",h7="scheme",f7="slashscheme",rg="whitespace";function p7(t,e){return t in e||(e[t]=[]),e[t]}function ro(t,e,n){e[nx]&&(e[Fc]=!0,e[Ic]=!0),e[rx]&&(e[Fc]=!0,e[sx]=!0),e[Fc]&&(e[Ic]=!0),e[sx]&&(e[Ic]=!0),e[Ic]&&(e[ix]=!0),e[q2]&&(e[ix]=!0);for(const r in e){const i=p7(r,n);i.indexOf(t)<0&&i.push(t)}}function m7(t,e){const n={};for(const r in e)e[r].indexOf(t)>=0&&(n[r]=!0);return n}function yr(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}yr.groups={};yr.prototype={accepts(){return!!this.t},go(t){const e=this,n=e.j[t];if(n)return n;for(let r=0;rt.ta(e,n,r,i),nn=(t,e,n,r,i)=>t.tr(e,n,r,i),wN=(t,e,n,r,i)=>t.ts(e,n,r,i),Ce=(t,e,n,r,i)=>t.tt(e,n,r,i),hi="WORD",ax="UWORD",G2="ASCIINUMERICAL",J2="ALPHANUMERICAL",id="LOCALHOST",ox="TLD",lx="UTLD",Zu="SCHEME",dl="SLASH_SCHEME",M0="NUM",cx="WS",A0="NL",Bc="OPENBRACE",Vc="CLOSEBRACE",Eh="OPENBRACKET",Th="CLOSEBRACKET",Mh="OPENPAREN",Ah="CLOSEPAREN",Ih="OPENANGLEBRACKET",Rh="CLOSEANGLEBRACKET",Ph="FULLWIDTHLEFTPAREN",Oh="FULLWIDTHRIGHTPAREN",Dh="LEFTCORNERBRACKET",Lh="RIGHTCORNERBRACKET",_h="LEFTWHITECORNERBRACKET",zh="RIGHTWHITECORNERBRACKET",$h="FULLWIDTHLESSTHAN",Fh="FULLWIDTHGREATERTHAN",Bh="AMPERSAND",Vh="APOSTROPHE",Hh="ASTERISK",Zi="AT",Wh="BACKSLASH",Uh="BACKTICK",Kh="CARET",na="COLON",I0="COMMA",qh="DOLLAR",Is="DOT",Gh="EQUALS",R0="EXCLAMATION",Ur="HYPHEN",Hc="PERCENT",Jh="PIPE",Yh="PLUS",Qh="POUND",Wc="QUERY",P0="QUOTE",Y2="FULLWIDTHMIDDLEDOT",O0="SEMI",Rs="SLASH",Uc="TILDE",Xh="UNDERSCORE",Q2="EMOJI",Zh="SYM";var X2=Object.freeze({__proto__:null,ALPHANUMERICAL:J2,AMPERSAND:Bh,APOSTROPHE:Vh,ASCIINUMERICAL:G2,ASTERISK:Hh,AT:Zi,BACKSLASH:Wh,BACKTICK:Uh,CARET:Kh,CLOSEANGLEBRACKET:Rh,CLOSEBRACE:Vc,CLOSEBRACKET:Th,CLOSEPAREN:Ah,COLON:na,COMMA:I0,DOLLAR:qh,DOT:Is,EMOJI:Q2,EQUALS:Gh,EXCLAMATION:R0,FULLWIDTHGREATERTHAN:Fh,FULLWIDTHLEFTPAREN:Ph,FULLWIDTHLESSTHAN:$h,FULLWIDTHMIDDLEDOT:Y2,FULLWIDTHRIGHTPAREN:Oh,HYPHEN:Ur,LEFTCORNERBRACKET:Dh,LEFTWHITECORNERBRACKET:_h,LOCALHOST:id,NL:A0,NUM:M0,OPENANGLEBRACKET:Ih,OPENBRACE:Bc,OPENBRACKET:Eh,OPENPAREN:Mh,PERCENT:Hc,PIPE:Jh,PLUS:Yh,POUND:Qh,QUERY:Wc,QUOTE:P0,RIGHTCORNERBRACKET:Lh,RIGHTWHITECORNERBRACKET:zh,SCHEME:Zu,SEMI:O0,SLASH:Rs,SLASH_SCHEME:dl,SYM:Zh,TILDE:Uc,TLD:ox,UNDERSCORE:Xh,UTLD:lx,UWORD:ax,WORD:hi,WS:cx});const di=/[a-z]/,Cc=new RegExp("\\p{L}","u"),sg=new RegExp("\\p{Emoji}","u"),ui=/\d/,ig=/\s/,jN="\r",ag=` -`,g7="️",x7="‍",og="";let zu=null,$u=null;function y7(t=[]){const e={};yr.groups=e;const n=new yr;zu==null&&(zu=kN(d7)),$u==null&&($u=kN(u7)),Ce(n,"'",Vh),Ce(n,"{",Bc),Ce(n,"}",Vc),Ce(n,"[",Eh),Ce(n,"]",Th),Ce(n,"(",Mh),Ce(n,")",Ah),Ce(n,"<",Ih),Ce(n,">",Rh),Ce(n,"(",Ph),Ce(n,")",Oh),Ce(n,"「",Dh),Ce(n,"」",Lh),Ce(n,"『",_h),Ce(n,"』",zh),Ce(n,"<",$h),Ce(n,">",Fh),Ce(n,"&",Bh),Ce(n,"*",Hh),Ce(n,"@",Zi),Ce(n,"`",Uh),Ce(n,"^",Kh),Ce(n,":",na),Ce(n,",",I0),Ce(n,"$",qh),Ce(n,".",Is),Ce(n,"=",Gh),Ce(n,"!",R0),Ce(n,"-",Ur),Ce(n,"%",Hc),Ce(n,"|",Jh),Ce(n,"+",Yh),Ce(n,"#",Qh),Ce(n,"?",Wc),Ce(n,'"',P0),Ce(n,"/",Rs),Ce(n,";",O0),Ce(n,"~",Uc),Ce(n,"_",Xh),Ce(n,"\\",Wh),Ce(n,"・",Y2);const r=nn(n,ui,M0,{[nx]:!0});nn(r,ui,r);const i=nn(r,di,G2,{[Fc]:!0}),a=nn(r,Cc,J2,{[Ic]:!0}),o=nn(n,di,hi,{[rx]:!0});nn(o,ui,i),nn(o,di,o),nn(i,ui,i),nn(i,di,i);const c=nn(n,Cc,ax,{[sx]:!0});nn(c,di),nn(c,ui,a),nn(c,Cc,c),nn(a,ui,a),nn(a,di),nn(a,Cc,a);const u=Ce(n,ag,A0,{[rg]:!0}),h=Ce(n,jN,cx,{[rg]:!0}),f=nn(n,ig,cx,{[rg]:!0});Ce(n,og,f),Ce(h,ag,u),Ce(h,og,f),nn(h,ig,f),Ce(f,jN),Ce(f,ag),nn(f,ig,f),Ce(f,og,f);const m=nn(n,sg,Q2,{[q2]:!0});Ce(m,"#"),nn(m,sg,m),Ce(m,g7,m);const g=Ce(m,x7);Ce(g,"#"),nn(g,sg,m);const y=[[di,o],[ui,i]],v=[[di,null],[Cc,c],[ui,a]];for(let w=0;ww[0]>N[0]?1:-1);for(let w=0;w=0?E[ix]=!0:di.test(N)?ui.test(N)?E[Fc]=!0:E[rx]=!0:E[nx]=!0,wN(n,N,N,E)}return wN(n,"localhost",id,{ascii:!0}),n.jd=new yr(Zh),{start:n,tokens:Object.assign({groups:e},X2)}}function Z2(t,e){const n=v7(e.replace(/[A-Z]/g,c=>c.toLowerCase())),r=n.length,i=[];let a=0,o=0;for(;o=0&&(m+=n[o].length,g++),h+=n[o].length,a+=n[o].length,o++;a-=m,o-=g,h-=m,i.push({t:f.t,v:e.slice(a-h,a),s:a-h,e:a})}return i}function v7(t){const e=[],n=t.length;let r=0;for(;r56319||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 Gi(t,e,n,r,i){let a;const o=e.length;for(let c=0;c=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 ad={defaultProtocol:"http",events:null,format:SN,formatHref:SN,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function D0(t,e=null){let n=Object.assign({},ad);t&&(n=Object.assign(n,t instanceof D0?t.o:t));const r=n.ignoreTags,i=[];for(let a=0;an?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=ad.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),i=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:i,attributes:o,content:a,eventListeners:m}}};function If(t,e){class n extends eC{constructor(i,a){super(i,a),this.t=t}}for(const r in e)n.prototype[r]=e[r];return n.t=t,n}const CN=If("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),EN=If("text"),b7=If("nl"),Fu=If("url",{isLink:!0,toHref(t=ad.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==id&&t[1].t===na}}),Wr=t=>new yr(t);function N7({groups:t}){const e=t.domain.concat([Bh,Hh,Zi,Wh,Uh,Kh,qh,Gh,Ur,M0,Hc,Jh,Yh,Qh,Rs,Zh,Uc,Xh]),n=[Vh,na,I0,Is,R0,Hc,Wc,P0,O0,Ih,Rh,Bc,Vc,Th,Eh,Mh,Ah,Ph,Oh,Dh,Lh,_h,zh,$h,Fh],r=[Bh,Vh,Hh,Wh,Uh,Kh,qh,Gh,Ur,Bc,Vc,Hc,Jh,Yh,Qh,Wc,Rs,Zh,Uc,Xh],i=Wr(),a=Ce(i,Uc);ot(a,r,a),ot(a,t.domain,a);const o=Wr(),c=Wr(),u=Wr();ot(i,t.domain,o),ot(i,t.scheme,c),ot(i,t.slashscheme,u),ot(o,r,a),ot(o,t.domain,o);const h=Ce(o,Zi);Ce(a,Zi,h),Ce(c,Zi,h),Ce(u,Zi,h);const f=Ce(a,Is);ot(f,r,a),ot(f,t.domain,a);const m=Wr();ot(h,t.domain,m),ot(m,t.domain,m);const g=Ce(m,Is);ot(g,t.domain,m);const y=Wr(CN);ot(g,t.tld,y),ot(g,t.utld,y),Ce(h,id,y);const v=Ce(m,Ur);Ce(v,Ur,v),ot(v,t.domain,m),ot(y,t.domain,m),Ce(y,Is,g),Ce(y,Ur,v);const w=Ce(y,na);ot(w,t.numeric,CN);const N=Ce(o,Ur),k=Ce(o,Is);Ce(N,Ur,N),ot(N,t.domain,o),ot(k,r,a),ot(k,t.domain,o);const E=Wr(Fu);ot(k,t.tld,E),ot(k,t.utld,E),ot(E,t.domain,o),ot(E,r,a),Ce(E,Is,k),Ce(E,Ur,N),Ce(E,Zi,h);const C=Ce(E,na),T=Wr(Fu);ot(C,t.numeric,T);const O=Wr(Fu),F=Wr();ot(O,e,O),ot(O,n,F),ot(F,e,O),ot(F,n,F),Ce(E,Rs,O),Ce(T,Rs,O);const I=Ce(c,na),R=Ce(u,na),P=Ce(R,Rs),L=Ce(P,Rs);ot(c,t.domain,o),Ce(c,Is,k),Ce(c,Ur,N),ot(u,t.domain,o),Ce(u,Is,k),Ce(u,Ur,N),ot(I,t.domain,O),Ce(I,Rs,O),Ce(I,Wc,O),ot(L,t.domain,O),ot(L,e,O),Ce(L,Rs,O);const ee=[[Bc,Vc],[Eh,Th],[Mh,Ah],[Ih,Rh],[Ph,Oh],[Dh,Lh],[_h,zh],[$h,Fh]];for(let te=0;te=0&&g++,i++,f++;if(g<0)i-=f,i0&&(a.push(lg(EN,e,o)),o=[]),i-=g,f-=g;const y=m.t,v=n.slice(i-f,i);a.push(lg(y,e,v))}}return o.length>0&&a.push(lg(EN,e,o)),a}function lg(t,e,n){const r=n[0].s,i=n[n.length-1].e,a=e.slice(r,i);return new t(a,n)}const j7=typeof console<"u"&&console&&console.warn||(()=>{}),k7="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",$t={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function S7(){return yr.groups={},$t.scanner=null,$t.parser=null,$t.tokenQueue=[],$t.pluginQueue=[],$t.customSchemes=[],$t.initialized=!1,$t}function TN(t,e=!1){if($t.initialized&&j7(`linkifyjs: already initialized - will not register custom scheme "${t}" ${k7}`),!/^[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`);$t.customSchemes.push([t,e])}function C7(){$t.scanner=y7($t.customSchemes);for(let t=0;t<$t.tokenQueue.length;t++)$t.tokenQueue[t][1]({scanner:$t.scanner});$t.parser=N7($t.scanner.tokens);for(let t=0;t<$t.pluginQueue.length;t++)$t.pluginQueue[t][1]({scanner:$t.scanner,parser:$t.parser});return $t.initialized=!0,$t}function L0(t){return $t.initialized||C7(),w7($t.parser.start,t,Z2($t.scanner.start,t))}L0.scan=Z2;function tC(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 D0(n),i=L0(t),a=[];for(let o=0;o{const i=e.some(h=>h.docChanged)&&!n.doc.eq(r.doc),a=e.some(h=>h.getMeta("preventAutolink"));if(!i||a)return;const{tr:o}=r,c=h2(n.doc,[...e]);if(b2(c).forEach(({newRange:h})=>{const f=A8(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(!T7.test(y))return;m=f[0],g=r.doc.textBetween(m.pos,h.to,void 0," ")}if(m&&g){const y=g.split(E7).filter(Boolean);if(y.length<=0)return!1;const v=y[y.length-1],w=m.pos+g.lastIndexOf(v);if(!v)return!1;const N=L0(v).map(k=>k.toObject(t.defaultProtocol));if(!A7(N))return!1;N.filter(k=>k.isLink).map(k=>({...k,from:w+k.start+1,to:w+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=>{j0(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 R7(t){return new Dt({key:new Ht("handleClickLink"),props:{handleClick:(e,n,r)=>{var i,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=v2(e.state,t.type.name),h=(i=o.href)!=null?i:u.href,f=(a=o.target)!=null?a:u.target;h&&(window.open(h,f),c=!0)}return c}}})}function P7(t){return new Dt({key:new Ht("handlePasteLink"),props:{handlePaste:(e,n,r)=>{const{shouldAutoLink:i}=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=tC(u,{defaultProtocol:t.defaultProtocol}).find(f=>f.isLink&&f.value===u);return!u||!h||i!==void 0&&!i(h.value)?!1:t.editor.commands.setMark(t.type,{href:h.href})}}})}function Ya(t,e){const n=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return e&&e.forEach(r=>{const i=typeof r=="string"?r:r.scheme;i&&n.push(i)}),!t||t.replace(M7,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var nC=Co.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"){TN(t);return}TN(t.scheme,t.optionalSlashes)})},onDestroy(){S7()},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)=>!!Ya(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 i=(t.includes("@")?t.split("@").pop():t).split(/[/?#:]/)[0];return!(/^\d{1,3}(\.\d{1,3}){3}$/.test(i)||!/\./.test(i))}}},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=>!!Ya(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=>!!Ya(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,i,a;const o=(r=(n=t.attrs)==null?void 0:n.href)!=null?r:"",c=(a=(i=t.attrs)==null?void 0:i.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=>!!Ya(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=>!!Ya(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[vo({find:t=>{const e=[];if(t){const{protocols:n,defaultProtocol:r}=this.options,i=tC(t).filter(a=>a.isLink&&this.options.isAllowedUri(a.value,{defaultValidate:o=>!!Ya(o,n),protocols:n,defaultProtocol:r}));i.length&&i.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(I7({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:i=>!!Ya(i,e),protocols:e,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),t.push(R7({type:this.type,editor:this.editor,openOnClick:this.options.openOnClick==="whenNotEditable"?!0:this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&t.push(P7({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),t}}),O7=nC,D7=Object.defineProperty,L7=(t,e)=>{for(var n in e)D7(t,n,{get:e[n],enumerable:!0})},_7="listItem",MN="textStyle",AN=/^\s*([-+*])\s$/,rC=mn.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(_7,this.editor.getAttributes(MN)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=Al({find:AN,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=Al({find:AN,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(MN),editor:this.editor})),[t]}}),sC=mn.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(i=>i.type==="paragraph"))n=e.parseChildren(t.tokens);else{const i=t.tokens[0];if(i&&i.type==="text"&&i.tokens&&i.tokens.length>0){if(n=[{type:"paragraph",content:e.parseInline(i.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)=>E0(t,e,r=>{var i,a;return r.parentType==="bulletList"?"- ":r.parentType==="orderedList"?`${(((a=(i=r.meta)==null?void 0:i.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)}}}),z7={};L7(z7,{findListItemPos:()=>xd,getNextListDepth:()=>z0,handleBackspace:()=>dx,handleDelete:()=>ux,hasListBefore:()=>iC,hasListItemAfter:()=>$7,hasListItemBefore:()=>aC,listItemHasSubList:()=>oC,nextListIsDeeper:()=>lC,nextListIsHigher:()=>cC});var xd=(t,e)=>{const{$from:n}=e.selection,r=pn(t,e.schema);let i=null,a=n.depth,o=n.pos,c=null;for(;a>0&&c===null;)i=n.node(a),i.type===r?c=a:(a-=1,o-=1);return c===null?null:{$pos:e.doc.resolve(o),depth:c}},z0=(t,e)=>{const n=xd(t,e);if(!n)return!1;const[,r]=F8(e,t,n.$pos.pos+4);return r},iC=(t,e,n)=>{const{$anchor:r}=t.selection,i=Math.max(0,r.pos-2),a=t.doc.resolve(i).node();return!(!a||!n.includes(a.type.name))},aC=(t,e)=>{var n;const{$anchor:r}=e.selection,i=e.doc.resolve(r.pos-2);return!(i.index()===0||((n=i.nodeBefore)==null?void 0:n.type.name)!==t)},oC=(t,e,n)=>{if(!n)return!1;const r=pn(t,e.schema);let i=!1;return n.descendants(a=>{a.type===r&&(i=!0)}),i},dx=(t,e,n)=>{if(t.commands.undoInputRule())return!0;if(t.state.selection.from!==t.state.selection.to)return!1;if(!ya(t.state,e)&&iC(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(!ya(t.state,e)||!W8(t.state))return!1;const r=xd(e,t.state);if(!r)return!1;const a=t.state.doc.resolve(r.$pos.pos-2).node(r.depth),o=oC(e,t.state,a);return aC(e,t.state)&&!o?t.commands.joinItemBackward():t.chain().liftListItem(e).run()},lC=(t,e)=>{const n=z0(t,e),r=xd(t,e);return!r||!n?!1:n>r.depth},cC=(t,e)=>{const n=z0(t,e),r=xd(t,e);return!r||!n?!1:n{if(!ya(t.state,e)||!H8(t.state,e))return!1;const{selection:n}=t.state,{$from:r,$to:i}=n;return!n.empty&&r.sameParent(i)?!1:lC(e,t.state)?t.chain().focus(t.state.selection.from+4).lift(e).joinBackward().run():cC(e,t.state)?t.chain().joinForward().joinBackward().run():t.commands.joinItemForward()},$7=(t,e)=>{var n;const{$anchor:r}=e.selection,i=e.doc.resolve(r.pos-r.parentOffset-2);return!(i.index()===i.parent.childCount-1||((n=i.nodeAfter)==null?void 0:n.type.name)!==t)},dC=on.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&&ux(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&&ux(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&&dx(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&&dx(t,n,r)&&(e=!0)}),e}}}}),IN=/^(\s*)(\d+)\.\s+(.*)$/,F7=/^\s/;function B7(t){const e=[];let n=0,r=0;for(;ne;)g.push(t[m]),m+=1;if(g.length>0){const y=Math.min(...g.map(w=>w.indent)),v=uC(g,y,n);h.push({type:"list",ordered:!0,start:g[0].number,items:v,raw:g.map(w=>w.raw).join(` -`)})}i.push({type:"list_item",raw:o.raw,tokens:h}),a=m}else a+=1}return i}function V7(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(i=>{if(i.type==="paragraph"||i.type==="list"||i.type==="blockquote"||i.type==="code")r.push(...e.parseChildren([i]));else if(i.type==="text"&&i.tokens){const a=e.parseChildren([i]);r.push({type:"paragraph",content:a})}else{const a=e.parseChildren([i]);a.length>0&&r.push(...a)}}),{type:"listItem",content:r}})}var H7="listItem",RN="textStyle",PN=/^(\d+)\.\s$/,hC=mn.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?V7(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 i=t.split(` -`),[a,o]=B7(i);if(a.length===0)return;const c=uC(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:i.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(H7,this.editor.getAttributes(RN)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=Al({find:PN,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=Al({find:PN,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(RN)}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1],editor:this.editor})),[t]}}),W7=/^\s*(\[([( |x])?\])\s$/,U7=mn.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 i=`- [${(n=t.attrs)!=null&&n.checked?"x":" "}] `;return E0(t,e,i)},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 i=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 w=y.doc.nodeAt(v);return y.setNodeMarkup(v,void 0,{...w==null?void 0:w.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])=>{i.setAttribute(m,g)}),i.dataset.checked=t.attrs.checked,c.checked=t.attrs.checked,a.append(c,o),i.append(a,u),Object.entries(e).forEach(([m,g])=>{i.setAttribute(m,g)});let f=new Set(Object.keys(e));return{dom:i,contentDOM:u,update:m=>{if(m.type!==this.type)return!1;i.dataset.checked=m.attrs.checked,c.checked=m.attrs.checked,h(m);const g=r.extensionManager.attributes,y=sd(m,g),v=new Set(Object.keys(y)),w=this.options.HTMLAttributes;return f.forEach(N=>{v.has(N)||(N in w?i.setAttribute(N,w[N]):i.removeAttribute(N))}),Object.entries(y).forEach(([N,k])=>{k==null?N in w?i.setAttribute(N,w[N]):i.removeAttribute(N):i.setAttribute(N,k)}),f=v,!0}}}},addInputRules(){return[Al({find:W7,type:this.type,getAttributes:t=>({checked:t[t.length-1]==="x"})})]}}),K7=mn.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=ex(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)},i=ex(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(i)return{type:"taskList",raw:i.raw,items:i.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()}}});on.create({name:"listKit",addExtensions(){const t=[];return this.options.bulletList!==!1&&t.push(rC.configure(this.options.bulletList)),this.options.listItem!==!1&&t.push(sC.configure(this.options.listItem)),this.options.listKeymap!==!1&&t.push(dC.configure(this.options.listKeymap)),this.options.orderedList!==!1&&t.push(hC.configure(this.options.orderedList)),this.options.taskItem!==!1&&t.push(U7.configure(this.options.taskItem)),this.options.taskList!==!1&&t.push(K7.configure(this.options.taskList)),t}});var ON=" ",q7=" ",G7=mn.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===ON||r[0].text===q7)?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?ON:e.renderChildren(n)},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),J7=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,Y7=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,Q7=Co.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[Ml({find:J7,type:this.type})]},addPasteRules(){return[vo({find:Y7,type:this.type})]}}),X7=mn.create({name:"text",group:"inline",parseMarkdown:t=>({type:"text",text:t.text||""}),renderMarkdown:t=>t.text||""}),Z7=Co.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 i=/^(\+\+)([\s\S]+?)(\+\+)/.exec(t);if(!i)return;const a=i[2].trim();return{type:"underline",raw:i[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 ez(t={}){return new Dt({view(e){return new tz(e,t)}})}class tz{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(i=>{let a=o=>{this[i](o)};return e.dom.addEventListener(i,a),{name:i,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,i=this.editorView.dom,a=i.getBoundingClientRect(),o=a.width/i.offsetWidth,c=a.height/i.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(),w=m?v.bottom:v.top;m&&g&&(w=(w+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let N=this.width/2*c;r={left:v.left,right:v.right,top:w-N,bottom:w+N}}}}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),i=r&&r.type.spec.disableDropCursor,a=typeof i=="function"?i(this.editorView,n,e):i;if(n&&!a){let o=n.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let c=sS(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 sn extends Qe{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return sn.valid(r)?new sn(r):Qe.near(r)}content(){return Re.empty}eq(e){return e instanceof sn&&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 sn(e.resolve(n.pos))}getBookmark(){return new $0(this.anchor)}static valid(e){let n=e.parent;if(n.isTextblock||!nz(e)||!rz(e))return!1;let r=n.type.spec.allowGapCursor;if(r!=null)return r;let i=n.contentMatchAt(e.index()).defaultType;return i&&i.isTextblock}static findGapCursorFrom(e,n,r=!1){e:for(;;){if(!r&&sn.valid(e))return e;let i=e.pos,a=null;for(let o=e.depth;;o--){let c=e.node(o);if(n>0?e.indexAfter(o)0){a=c.child(n>0?e.indexAfter(o):e.index(o)-1);break}else if(o==0)return null;i+=n;let u=e.doc.resolve(i);if(sn.valid(u))return u}for(;;){let o=n>0?a.firstChild:a.lastChild;if(!o){if(a.isAtom&&!a.isText&&!We.isSelectable(a)){e=e.doc.resolve(i+a.nodeSize*n),r=!1;continue e}break}a=o,i+=n;let c=e.doc.resolve(i);if(sn.valid(c))return c}return null}}}sn.prototype.visible=!1;sn.findFrom=sn.findGapCursorFrom;Qe.jsonID("gapcursor",sn);class $0{constructor(e){this.pos=e}map(e){return new $0(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return sn.valid(n)?new sn(n):Qe.near(n)}}function fC(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function nz(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 i=r.child(n-1);;i=i.lastChild){if(i.childCount==0&&!i.inlineContent||fC(i.type))return!0;if(i.inlineContent)return!1}}return!0}function rz(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 i=r.child(n);;i=i.firstChild){if(i.childCount==0&&!i.inlineContent||fC(i.type))return!0;if(i.inlineContent)return!1}}return!0}function sz(){return new Dt({props:{decorations:lz,createSelectionBetween(t,e,n){return e.pos==n.pos&&sn.valid(n)?new sn(n):null},handleClick:az,handleKeyDown:iz,handleDOMEvents:{beforeinput:oz}}})}const iz=x0({ArrowLeft:Bu("horiz",-1),ArrowRight:Bu("horiz",1),ArrowUp:Bu("vert",-1),ArrowDown:Bu("vert",1)});function Bu(t,e){const n=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,i,a){let o=r.selection,c=e>0?o.$to:o.$from,u=o.empty;if(o instanceof Ue){if(!a.endOfTextblock(n)||c.depth==0)return!1;u=!1,c=r.doc.resolve(e>0?c.after():c.before())}let h=sn.findGapCursorFrom(c,e,u);return h?(i&&i(r.tr.setSelection(new sn(h))),!0):!1}}function az(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!sn.valid(r))return!1;let i=t.posAtCoords({left:n.clientX,top:n.clientY});return i&&i.inside>-1&&We.isSelectable(t.state.doc.nodeAt(i.inside))?!1:(t.dispatch(t.state.tr.setSelection(new sn(r))),!0)}function oz(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof sn))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 i=ge.empty;for(let o=r.length-1;o>=0;o--)i=ge.from(r[o].createAndFill(null,i));let a=t.state.tr.replace(n.pos,n.pos,new Re(i,0,0));return a.setSelection(Ue.near(a.doc.resolve(n.pos+1))),t.dispatch(a),!1}function lz(t){if(!(t.selection instanceof sn))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",Ct.create(t.doc,[bn.widget(t.selection.head,e,{key:"gapcursor"})])}var ef=200,Mn=function(){};Mn.prototype.append=function(e){return e.length?(e=Mn.from(e),!this.length&&e||e.length=n?Mn.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};Mn.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};Mn.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)};Mn.prototype.map=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length);var i=[];return this.forEach(function(a,o){return i.push(e(a,o))},n,r),i};Mn.from=function(e){return e instanceof Mn?e:e&&e.length?new pC(e):Mn.empty};var pC=(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(i,a){return i==0&&a==this.length?this:new e(this.values.slice(i,a))},e.prototype.getInner=function(i){return this.values[i]},e.prototype.forEachInner=function(i,a,o,c){for(var u=a;u=o;u--)if(i(this.values[u],c+u)===!1)return!1},e.prototype.leafAppend=function(i){if(this.length+i.length<=ef)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=ef)return new e(i.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(e.prototype,n),e})(Mn);Mn.empty=new pC([]);var cz=(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 rc&&this.right.forEachInner(r,Math.max(i-c,0),Math.min(this.length,a)-c,o+c)===!1)return!1},e.prototype.forEachInvertedInner=function(r,i,a,o){var c=this.left.length;if(i>c&&this.right.forEachInvertedInner(r,i-c,Math.max(a,c)-c,o+c)===!1||a=a?this.right.slice(r-a,i-a):this.left.slice(r,a).append(this.right.slice(0,i-a))},e.prototype.leafAppend=function(r){var i=this.right.leafAppend(r);if(i)return new e(this.left,i)},e.prototype.leafPrepend=function(r){var i=this.left.leafPrepend(r);if(i)return new e(i,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})(Mn);const dz=500;class hs{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 i,a;n&&(i=this.remapping(r,this.items.length),a=i.maps.length);let o=e.tr,c,u,h=[],f=[];return this.items.forEach((m,g)=>{if(!m.step){i||(i=this.remapping(r,g+1),a=i.maps.length),a--,f.push(m);return}if(i){f.push(new Ji(m.map));let y=m.step.map(i.slice(a)),v;y&&o.maybeStep(y).doc&&(v=o.mapping.maps[o.mapping.maps.length-1],h.push(new Ji(v,void 0,void 0,h.length+f.length))),a--,v&&i.appendMap(v,a)}else o.maybeStep(m.step);if(m.selection)return c=i?m.selection.map(i.slice(a)):m.selection,u=new hs(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,i){let a=[],o=this.eventCount,c=this.items,u=!i&&c.length?c.get(c.length-1):null;for(let f=0;fhz&&(c=uz(c,h),o-=h),new hs(c.append(a),o)}remapping(e,n){let r=new Xc;return this.items.forEach((i,a)=>{let o=i.mirrorOffset!=null&&a-i.mirrorOffset>=e?r.maps.length-i.mirrorOffset:void 0;r.appendMap(i.map,o)},e,n),r}addMaps(e){return this.eventCount==0?this:new hs(this.items.append(e.map(n=>new Ji(n))),this.eventCount)}rebased(e,n){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-n),a=e.mapping,o=e.steps.length,c=this.eventCount;this.items.forEach(g=>{g.selection&&c--},i);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 w=e.steps[y].invert(e.docs[y]),N=g.selection&&g.selection.map(a.slice(u+1,y));N&&c++,r.push(new Ji(v,w,N))}else r.push(new Ji(v))},i);let h=[];for(let g=n;gdz&&(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,i=[],a=0;return this.items.forEach((o,c)=>{if(c>=e)i.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 Ji(h.invert(),u,f),g,y=i.length-1;(g=i.length&&i[y].merge(m))?i[y]=g:i.push(m)}}else o.map&&r--},this.items.length,0),new hs(Mn.from(i.reverse()),a)}}hs.empty=new hs(Mn.empty,0);function uz(t,e){let n;return t.forEach((r,i)=>{if(r.selection&&e--==0)return n=i,!1}),t.slice(n)}let Ji=class mC{constructor(e,n,r,i){this.map=e,this.step=n,this.selection=r,this.mirrorOffset=i}merge(e){if(this.step&&e.step&&!e.selection){let n=e.step.merge(this.step);if(n)return new mC(n.getMap().invert(),n,this.selection)}}};class ea{constructor(e,n,r,i,a){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=i,this.prevComposition=a}}const hz=20;function fz(t,e,n,r){let i=n.getMeta(co),a;if(i)return i.historyState;n.getMeta(gz)&&(t=new ea(t.done,t.undone,null,0,-1));let o=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(o&&o.getMeta(co))return o.getMeta(co).redo?new ea(t.done.addTransform(n,void 0,r,eh(e)),t.undone,DN(n.mapping.maps),t.prevTime,t.prevComposition):new ea(t.done,t.undone.addTransform(n,void 0,r,eh(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||!pz(n,t.prevRanges)),h=o?cg(t.prevRanges,n.mapping):DN(n.mapping.maps);return new ea(t.done.addTransform(n,u?e.selection.getBookmark():void 0,r,eh(e)),hs.empty,h,n.time,c??t.prevComposition)}else return(a=n.getMeta("rebased"))?new ea(t.done.rebased(n,a),t.undone.rebased(n,a),cg(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new ea(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),cg(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function pz(t,e){if(!e)return!1;if(!t.docChanged)return!0;let n=!1;return t.mapping.maps[0].forEach((r,i)=>{for(let a=0;a=e[a]&&(n=!0)}),n}function DN(t){let e=[];for(let n=t.length-1;n>=0&&e.length==0;n--)t[n].forEach((r,i,a,o)=>e.push(a,o));return e}function cg(t,e){if(!t)return null;let n=[];for(let r=0;r{let i=co.getState(n);if(!i||(t?i.undone:i.done).eventCount==0)return!1;if(r){let a=mz(i,n,t);a&&r(e?a.scrollIntoView():a)}return!0}}const xC=gC(!1,!0),yC=gC(!0,!0);on.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 Dt({key:new Ht("characterCount"),appendTransaction:(e,n,r)=>{if(t)return;const i=this.options.limit;if(i==null||i===0){t=!0;return}const a=this.storage.characters({node:r.doc});if(a>i){const o=a-i,c=0,u=o;console.warn(`[CharacterCount] Initial content exceeded limit of ${i} 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 i=this.storage.characters({node:n.doc}),a=this.storage.characters({node:e.doc});if(a<=r||i>r&&a>r&&a<=i)return!0;if(i>r&&a>r&&a>i||!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 yz=on.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[ez(this.options)]}});on.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new Dt({key:new Ht("focus"),props:{decorations:({doc:t,selection:e})=>{const{isEditable:n,isFocused:r}=this.editor,{anchor:i}=e,a=[];if(!n||!r)return Ct.create(t,[]);let o=0;this.options.mode==="deepest"&&t.descendants((u,h)=>{if(u.isText)return;if(!(i>=h&&i<=h+u.nodeSize-1))return!1;o+=1});let c=0;return t.descendants((u,h)=>{if(u.isText||!(i>=h&&i<=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(bn.node(h,h+u.nodeSize,{class:this.options.className}))}),Ct.create(t,a)}}})]}});var vz=on.create({name:"gapCursor",addProseMirrorPlugins(){return[sz()]},extendNodeSchema(t){var e;const n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=yt(Ve(t,"allowGapCursor",n)))!=null?e:null}}}),_N="placeholder";function bz(t){return t.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-]/g,"").replace(/^[0-9-]+/,"").replace(/^-+/,"").toLowerCase()}var Nz=on.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",dataAttribute:_N,placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){const t=this.options.dataAttribute?`data-${bz(this.options.dataAttribute)}`:`data-${_N}`;return[new Dt({key:new Ht("placeholder"),props:{decorations:({doc:e,selection:n})=>{const r=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:i}=n,a=[];if(!r)return null;const o=this.editor.isEmpty;return e.descendants((c,u)=>{const h=i>=u&&i<=u+c.nodeSize,f=!c.isLeaf&&Tf(c);if((h||!this.options.showOnlyCurrent)&&f){const m=[this.options.emptyNodeClass];o&&m.push(this.options.emptyEditorClass);const g=bn.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}),Ct.create(e,a)}}})]}});on.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:t,options:e}=this;return[new Dt({key:new Ht("selection"),props:{decorations(n){return n.selection.empty||t.isFocused||!t.isEditable||N2(n.selection)||t.view.dragging?null:Ct.create(n.doc,[bn.inline(n.selection.from,n.selection.to,{class:e.className})])}}})]}});function zN({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||(e==null?void 0:e.type)===t}var wz=on.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var t;const e=new Ht(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(([,i])=>i).filter(i=>(this.options.notAfter||[]).concat(n).includes(i.name));return[new Dt({key:e,appendTransaction:(i,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:(i,a)=>{const o=a.tr.doc.lastChild;return!zN({node:o,types:r})},apply:(i,a)=>{if(!i.docChanged||i.getMeta("__uniqueIDTransaction"))return a;const o=i.doc.lastChild;return!zN({node:o,types:r})}}})]}}),jz=on.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>xC(t,e),redo:()=>({state:t,dispatch:e})=>yC(t,e)}},addProseMirrorPlugins(){return[xz(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()}}}),kz=on.create({name:"starterKit",addExtensions(){var t,e,n,r;const i=[];return this.options.bold!==!1&&i.push(G_.configure(this.options.bold)),this.options.blockquote!==!1&&i.push(H_.configure(this.options.blockquote)),this.options.bulletList!==!1&&i.push(rC.configure(this.options.bulletList)),this.options.code!==!1&&i.push(Q_.configure(this.options.code)),this.options.codeBlock!==!1&&i.push(e7.configure(this.options.codeBlock)),this.options.document!==!1&&i.push(t7.configure(this.options.document)),this.options.dropcursor!==!1&&i.push(yz.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&i.push(vz.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&i.push(n7.configure(this.options.hardBreak)),this.options.heading!==!1&&i.push(r7.configure(this.options.heading)),this.options.undoRedo!==!1&&i.push(jz.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&i.push(s7.configure(this.options.horizontalRule)),this.options.italic!==!1&&i.push(c7.configure(this.options.italic)),this.options.listItem!==!1&&i.push(sC.configure(this.options.listItem)),this.options.listKeymap!==!1&&i.push(dC.configure((t=this.options)==null?void 0:t.listKeymap)),this.options.link!==!1&&i.push(nC.configure((e=this.options)==null?void 0:e.link)),this.options.orderedList!==!1&&i.push(hC.configure(this.options.orderedList)),this.options.paragraph!==!1&&i.push(G7.configure(this.options.paragraph)),this.options.strike!==!1&&i.push(Q7.configure(this.options.strike)),this.options.text!==!1&&i.push(X7.configure(this.options.text)),this.options.underline!==!1&&i.push(Z7.configure((n=this.options)==null?void 0:n.underline)),this.options.trailingNode!==!1&&i.push(wz.configure((r=this.options)==null?void 0:r.trailingNode)),i}}),Sz=kz,Cz=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,Ez=mn.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,i,a,o;const c=(n=(e=t.attrs)==null?void 0:e.src)!=null?n:"",u=(i=(r=t.attrs)==null?void 0:r.alt)!=null?i:"",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:i,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 A6({element:u,editor:c,node:i,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===i.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[z2({find:Cz,type:this.type,getAttributes:t=>{const[,,e,n,r]=t;return{src:n,alt:e,title:r}}})]}}),Tz=Ez;function Mz(t){var e;const{char:n,allowSpaces:r,allowToIncludeChar:i,allowedPrefixes:a,startOfLine:o,$position:c}=t,u=r&&!i,h=R6(n),f=new RegExp(`\\s${h}$`),m=o?"^":"",g=i?"":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 w=c.pos-v.length,N=Array.from(v.matchAll(y)).pop();if(!N||N.input===void 0||N.index===void 0)return null;const k=N.input.slice(Math.max(0,N.index-1),N.index),E=new RegExp(`^[${a==null?void 0:a.join("")}\0]?$`).test(k);if(a!==null&&!E)return null;const C=w+N.index;let T=C+N[0].length;return u&&f.test(v.slice(T-1,T+1))&&(N[0]+=" ",T+=1),C=c.pos?{range:{from:C,to:T},query:N[0].slice(n.length),text:N[0]}:null}var Az=new Ht("suggestion");function Iz({pluginKey:t=Az,editor:e,char:n="@",allowSpaces:r=!1,allowToIncludeChar:i=!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:w=Mz,shouldShow:N}){let k;const E=y==null?void 0:y(),C=()=>{const I=e.state.selection.$anchor.pos,R=e.view.coordsAtPos(I),{top:P,right:L,bottom:ee,left:te}=R;try{return new DOMRect(te,P,L-te,ee-P)}catch{return null}},T=(I,R)=>R?()=>{const P=t.getState(e.state),L=P==null?void 0:P.decorationId,ee=I.dom.querySelector(`[data-decoration-id="${L}"]`);return(ee==null?void 0:ee.getBoundingClientRect())||null}:C;function O(I,R){var P;try{const ee=t.getState(I.state),te=ee!=null&&ee.decorationId?I.dom.querySelector(`[data-decoration-id="${ee.decorationId}"]`):null,Y={editor:e,range:(ee==null?void 0:ee.range)||{from:0,to:0},query:(ee==null?void 0:ee.query)||null,text:(ee==null?void 0:ee.text)||null,items:[],command:U=>m({editor:e,range:(ee==null?void 0:ee.range)||{from:0,to:0},props:U}),decorationNode:te,clientRect:T(I,te)};(P=E==null?void 0:E.onExit)==null||P.call(E,Y)}catch{}const L=I.state.tr.setMeta(R,{exit:!0});I.dispatch(L)}const F=new Dt({key:t,view(){return{update:async(I,R)=>{var P,L,ee,te,Y,U,D;const $=(P=this.key)==null?void 0:P.getState(R),le=(L=this.key)==null?void 0:L.getState(I.state),_=$.active&&le.active&&$.range.from!==le.range.from,se=!$.active&&le.active,J=$.active&&!le.active,z=!se&&!J&&$.query!==le.query,W=se||_&&z,ue=z||_,G=J||_&&z;if(!W&&!ue&&!G)return;const fe=G&&!W?$:le,X=I.dom.querySelector(`[data-decoration-id="${fe.decorationId}"]`);k={editor:e,range:fe.range,query:fe.query,text:fe.text,items:[],command:ce=>m({editor:e,range:fe.range,props:ce}),decorationNode:X,clientRect:T(I,X)},W&&((ee=E==null?void 0:E.onBeforeStart)==null||ee.call(E,k)),ue&&((te=E==null?void 0:E.onBeforeUpdate)==null||te.call(E,k)),(ue||W)&&(k.items=await g({editor:e,query:fe.query})),G&&((Y=E==null?void 0:E.onExit)==null||Y.call(E,k)),ue&&((U=E==null?void 0:E.onUpdate)==null||U.call(E,k)),W&&((D=E==null?void 0:E.onStart)==null||D.call(E,k))},destroy:()=>{var I;k&&((I=E==null?void 0:E.onExit)==null||I.call(E,k))}}},state:{init(){return{active:!1,range:{from:0,to:0},query:null,text:null,composing:!1}},apply(I,R,P,L){const{isEditable:ee}=e,{composing:te}=e.view,{selection:Y}=I,{empty:U,from:D}=Y,$={...R},le=I.getMeta(t);if(le&&le.exit)return $.active=!1,$.decorationId=null,$.range={from:0,to:0},$.query=null,$.text=null,$;if($.composing=te,ee&&(U||e.view.composing)){(DR.range.to)&&!te&&!R.composing&&($.active=!1);const _=w({char:n,allowSpaces:r,allowToIncludeChar:i,allowedPrefixes:a,startOfLine:o,$position:Y.$from}),se=`id_${Math.floor(Math.random()*4294967295)}`;_&&v({editor:e,state:L,range:_.range,isActive:R.active})&&(!N||N({editor:e,range:_.range,query:_.query,text:_.text,transaction:I}))?($.active=!0,$.decorationId=R.decorationId?R.decorationId:se,$.range=_.range,$.query=_.query,$.text=_.text):$.active=!1}else $.active=!1;return $.active||($.decorationId=null,$.range={from:0,to:0},$.query=null,$.text=null),$}},props:{handleKeyDown(I,R){var P,L,ee,te;const{active:Y,range:U}=F.getState(I.state);if(!Y)return!1;if(R.key==="Escape"||R.key==="Esc"){const $=F.getState(I.state),le=(P=k==null?void 0:k.decorationNode)!=null?P:null,_=le??($!=null&&$.decorationId?I.dom.querySelector(`[data-decoration-id="${$.decorationId}"]`):null);if(((L=E==null?void 0:E.onKeyDown)==null?void 0:L.call(E,{view:I,event:R,range:$.range}))||!1)return!0;const J={editor:e,range:$.range,query:$.query,text:$.text,items:[],command:z=>m({editor:e,range:$.range,props:z}),decorationNode:_,clientRect:_?()=>_.getBoundingClientRect()||null:null};return(ee=E==null?void 0:E.onExit)==null||ee.call(E,J),O(I,t),!0}return((te=E==null?void 0:E.onKeyDown)==null?void 0:te.call(E,{view:I,event:R,range:U}))||!1},decorations(I){const{active:R,range:P,decorationId:L,query:ee}=F.getState(I);if(!R)return null;const te=!(ee!=null&&ee.length),Y=[u];return te&&Y.push(f),Ct.create(I.doc,[bn.inline(P.from,P.to,{nodeName:c,class:Y.join(" "),"data-decoration-id":L,"data-decoration-content":h})])}}});return F}function Rz({editor:t,overrideSuggestionOptions:e,extensionName:n,char:r="@"}){const i=new Ht;return{editor:t,char:r,pluginKey:i,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 vC(t){return(t.options.suggestions.length?t.options.suggestions:[t.options.suggestion]).map(e=>Rz({editor:t.editor,overrideSuggestionOptions:e,extensionName:t.name,char:e.char}))}function $N(t,e){const n=vC(t),r=n.find(i=>i.char===e);return r||(n.length?n[0]:null)}var Pz=mn.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,i;return["span",vt(this.HTMLAttributes,t.HTMLAttributes),`${(r=n==null?void 0:n.char)!=null?r:"@"}${(i=e.attrs.label)!=null?i: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=$N(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 i=this.options.renderHTML({options:r,node:t,suggestion:n});return typeof i=="string"?["span",vt({"data-type":this.name},this.options.HTMLAttributes,e),i]:i},...$2({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[,i,a,o]=r,c=a??o;e[i==="char"?"mentionSuggestionChar":i]=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:$N(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:i,anchor:a}=r;if(!i)return!1;let o=new xi,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 vC(this).map(Iz)}}),Oz=Pz,Dz=Nz;let hx,fx;if(typeof WeakMap<"u"){let t=new WeakMap;hx=e=>t.get(e),fx=(e,n)=>(t.set(e,n),n)}else{const t=[];let n=0;hx=r=>{for(let i=0;i(n==10&&(n=0),t[n++]=r,t[n++]=i)}var an=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=n){(a||(a=[])).push({type:"overlong_rowspan",pos:f,n:k-C});break}const T=i+C*e;for(let O=0;Or&&(a+=h.attrs.colspan)}}for(let o=0;o1&&(n=!0)}e==-1?e=a:e!=a&&(e=Math.max(e,a))}return e}function zz(t,e,n){t.problems||(t.problems=[]);const r={};for(let i=0;i0;e--)if(t.node(e).type.spec.tableRole=="row")return t.node(0).resolve(t.before(e+1));return null}function Fz(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 vs(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 Rf(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=bo(e.$head)||Bz(e.$head);if(n)return n;throw new RangeError(`No cell found around position ${e.head}`)}function Bz(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 px(t){return t.parent.type.spec.tableRole=="row"&&!!t.nodeAfter}function Vz(t){return t.node(0).resolve(t.pos+t.nodeAfter.nodeSize)}function F0(t,e){return t.depth==e.depth&&t.pos>=e.start(-1)&&t.pos<=e.end(-1)}function bC(t,e,n){const r=t.node(-1),i=an.get(r),a=t.start(-1),o=i.nextCell(t.pos-a,e,n);return o==null?null:t.node(0).resolve(a+o)}function No(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(i=>i>0)||(r.colwidth=null)),r}function NC(t,e,n=1){const r={...t,colspan:t.colspan+n};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let i=0;if!=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 cS(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)),i=e.resolve(n.map(this.$headCell.pos));if(px(r)&&px(i)&&F0(r,i)){const a=this.$anchorCell.node(-1)!=r.node(-1);return a&&this.isRowSelection()?fi.rowSelection(r,i):a&&this.isColSelection()?fi.colSelection(r,i):new fi(r,i)}return Ue.between(r,i)}content(){const e=this.$anchorCell.node(-1),n=an.get(e),r=this.$anchorCell.start(-1),i=n.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),a={},o=[];for(let u=i.top;u0||N>0){let k=v.attrs;if(w>0&&(k=No(k,0,w)),N>0&&(k=No(k,k.colspan-N,N)),y.lefti.bottom){const k={...v.attrs,rowspan:Math.min(y.bottom,i.bottom)-Math.max(y.top,i.top)};y.top0)return!1;const r=e+this.$anchorCell.nodeAfter.attrs.rowspan,i=n+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,i)==this.$headCell.node(-1).childCount}static colSelection(e,n=e){const r=e.node(-1),i=an.get(r),a=e.start(-1),o=i.findCell(e.pos-a),c=i.findCell(n.pos-a),u=e.node(0);return o.top<=c.top?(o.top>0&&(e=u.resolve(a+i.map[o.left])),c.bottom0&&(n=u.resolve(a+i.map[c.left])),o.bottom0)return!1;const o=i+this.$anchorCell.nodeAfter.attrs.colspan,c=a+this.$headCell.nodeAfter.attrs.colspan;return Math.max(o,c)==n.width}eq(e){return e instanceof fi&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,n=e){const r=e.node(-1),i=an.get(r),a=e.start(-1),o=i.findCell(e.pos-a),c=i.findCell(n.pos-a),u=e.node(0);return o.left<=c.left?(o.left>0&&(e=u.resolve(a+i.map[o.top*i.width])),c.right0&&(n=u.resolve(a+i.map[c.top*i.width])),o.right{e.push(bn.node(r,r+n.nodeSize,{class:"selectedCell"}))}),Ct.create(t.doc,e)}function Kz({$from:t,$to:e}){if(t.pos==e.pos||t.pos=0&&!(t.after(i+1)=0&&!(e.before(a+1)>e.start(a));a--,r--);return n==r&&/row|table/.test(t.node(i).type.spec.tableRole)}function qz({$from:t,$to:e}){let n,r;for(let i=t.depth;i>0;i--){const a=t.node(i);if(a.type.spec.tableRole==="cell"||a.type.spec.tableRole==="header_cell"){n=a;break}}for(let i=e.depth;i>0;i--){const a=e.node(i);if(a.type.spec.tableRole==="cell"||a.type.spec.tableRole==="header_cell"){r=a;break}}return n!==r&&e.parentOffset===0}function Gz(t,e,n){const r=(e||t).selection,i=(e||t).doc;let a,o;if(r instanceof We&&(o=r.node.type.spec.tableRole)){if(o=="cell"||o=="header_cell")a=Ot.create(i,r.from);else if(o=="row"){const c=i.resolve(r.from+1);a=Ot.rowSelection(c,c)}else if(!n){const c=an.get(r.node),u=r.from+1,h=u+c.map[c.width*c.height-1];a=Ot.create(i,u+1,h)}}else r instanceof Ue&&Kz(r)?a=Ue.create(i,r.from):r instanceof Ue&&qz(r)&&(a=Ue.create(i,r.$from.start(),r.$from.end()));return a&&(e||(e=t.tr)).setSelection(a),e}const Jz=new Ht("fix-tables");function jC(t,e,n,r){const i=t.childCount,a=e.childCount;e:for(let o=0,c=0;o{i.type.spec.tableRole=="table"&&(n=Yz(t,i,a,n))};return e?e.doc!=t.doc&&jC(e.doc,t.doc,0,r):t.doc.descendants(r),n}function Yz(t,e,n,r){const i=an.get(e);if(!i.problems)return r;r||(r=t.tr);const a=[];for(let u=0;u0){let y="cell";f.firstChild&&(y=f.firstChild.type.spec.tableRole);const v=[];for(let N=0;N0?-1:0;Hz(e,r,i+a)&&(a=i==0||i==e.width?null:0);for(let o=0;o0&&i0&&e.map[c-1]==u||i0?-1:0;t$(e,r,i+c)&&(c=i==0||i==e.height?null:0);for(let h=0,f=e.width*i;h0&&i0&&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(i0&&n[a]==n[a-1]||r.right0&&n[i]==n[i-t]||r.bottom0){const f=u+1+h.content.size,m=FN(h)?u+1:f;a.replaceWith(m+r.tableStart,f+r.tableStart,c)}a.setSelection(new Ot(a.doc.resolve(u+r.tableStart))),e(a)}return!0}function VN(t,e){const n=Qn(t.schema);return o$(({node:r})=>n[r.type.spec.tableRole])(t,e)}function o$(t){return(e,n)=>{const r=e.selection;let i,a;if(r instanceof Ot){if(r.$anchorCell.pos!=r.$headCell.pos)return!1;i=r.$anchorCell.nodeAfter,a=r.$anchorCell.pos}else{var o;if(i=Fz(r.$from),!i)return!1;a=(o=bo(r.$from))===null||o===void 0?void 0:o.pos}if(i==null||a==null||i.attrs.colspan==1&&i.attrs.rowspan==1)return!1;if(n){let c=i.attrs;const u=[],h=c.colwidth;c.rowspan>1&&(c={...c,rowspan:1}),c.colspan>1&&(c={...c,colspan:1});const f=Bs(e),m=e.tr;for(let y=0;y{o.attrs[t]!==e&&a.setNodeMarkup(c,null,{...o.attrs,[t]:e})}):a.setNodeMarkup(i.pos,null,{...i.nodeAfter.attrs,[t]:e}),r(a)}return!0}}function c$(t){return function(e,n){if(!vs(e))return!1;if(n){const r=Qn(e.schema),i=Bs(e),a=e.tr,o=i.map.cellsInRect(t=="column"?{left:i.left,top:0,right:i.right,bottom:i.map.height}:t=="row"?{left:0,top:i.top,right:i.map.width,bottom:i.bottom}:i),c=o.map(u=>i.table.nodeAt(u));for(let u=0;u{const y=g+a.tableStart,v=o.doc.nodeAt(y);v&&o.setNodeMarkup(y,m,v.attrs)}),r(o)}return!0}}od("row",{useDeprecatedLogic:!0});od("column",{useDeprecatedLogic:!0});const d$=od("cell",{useDeprecatedLogic:!0});function u$(t,e){if(e<0){const n=t.nodeBefore;if(n)return t.pos-n.nodeSize;for(let r=t.index(-1)-1,i=t.before();r>=0;r--){const a=t.node(-1).child(r),o=a.lastChild;if(o)return i-1-o.nodeSize;i-=a.nodeSize}}else{if(t.index()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 Vu(t,e){const n=t.selection;if(!(n instanceof Ot))return!1;if(e){const r=t.tr,i=Qn(t.schema).cell.createAndFill().content;n.forEachCell((a,o)=>{a.content.eq(i)||r.replace(r.mapping.map(o+1),r.mapping.map(o+a.nodeSize-1),new Re(i,0,0))}),r.docChanged&&e(r)}return!0}function f$(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 i=e.child(0),a=i.type.spec.tableRole,o=i.type.schema,c=[];if(a=="row")for(let u=0;u=0;o--){const{rowspan:c,colspan:u}=a.child(o).attrs;for(let h=i;h=e.length&&e.push(ge.empty),n[i]r&&(g=g.type.createChecked(No(g.attrs,g.attrs.colspan,f+g.attrs.colspan-r),g.content)),h.push(g),f+=g.attrs.colspan;for(let y=1;yi&&(m=m.type.create({...m.attrs,rowspan:Math.max(1,i-m.attrs.rowspan)},m.content)),u.push(m)}a.push(ge.from(u))}n=a,e=i}return{width:t,height:e,rows:n}}function g$(t,e,n,r,i,a,o){const c=t.doc.type.schema,u=Qn(c);let h,f;if(i>e.width)for(let m=0,g=0;me.height){const m=[];for(let v=0,w=(e.height-1)*e.width;v=e.width?!1:n.nodeAt(e.map[w+v]).type==u.header_cell;m.push(N?f||(f=u.header_cell.createAndFill()):h||(h=u.cell.createAndFill()))}const g=u.row.create(null,ge.from(m)),y=[];for(let v=e.height;v{if(!i)return!1;const a=n.selection;if(a instanceof Ot)return th(n,r,Qe.near(a.$headCell,e));if(t!="horiz"&&!a.empty)return!1;const o=EC(i,t,e);if(o==null)return!1;if(t=="horiz")return th(n,r,Qe.near(n.doc.resolve(a.head+e),e));{const c=n.doc.resolve(o),u=bC(c,t,e);let h;return u?h=Qe.near(u,1):e<0?h=Qe.near(n.doc.resolve(c.before(-1)),-1):h=Qe.near(n.doc.resolve(c.after(-1)),1),th(n,r,h)}}}function Wu(t,e){return(n,r,i)=>{if(!i)return!1;const a=n.selection;let o;if(a instanceof Ot)o=a;else{const u=EC(i,t,e);if(u==null)return!1;o=new Ot(n.doc.resolve(u))}const c=bC(o.$headCell,t,e);return c?th(n,r,new Ot(o.$anchorCell,c)):!1}}function y$(t,e){const n=t.state.doc,r=bo(n.resolve(e));return r?(t.dispatch(t.state.tr.setSelection(new Ot(r))),!0):!1}function v$(t,e,n){if(!vs(t.state))return!1;let r=f$(n);const i=t.state.selection;if(i instanceof Ot){r||(r={width:1,height:1,rows:[ge.from(mx(Qn(t.state.schema).cell,n))]});const a=i.$anchorCell.node(-1),o=i.$anchorCell.start(-1),c=an.get(a).rectBetween(i.$anchorCell.pos-o,i.$headCell.pos-o);return r=m$(r,c.right-c.left,c.bottom-c.top),qN(t.state,t.dispatch,o,c,r),!0}else if(r){const a=Rf(t.state),o=a.start(-1);return qN(t.state,t.dispatch,o,an.get(a.node(-1)).findCell(a.pos-o),r),!0}else return!1}function b$(t,e){var n;if(e.button!=0||e.ctrlKey||e.metaKey)return;const r=GN(t,e.target);let i;if(e.shiftKey&&t.state.selection instanceof Ot)a(t.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&r&&(i=bo(t.state.selection.$anchor))!=null&&((n=ug(t,e))===null||n===void 0?void 0:n.pos)!=i.pos)a(i,e),e.preventDefault();else if(!r)return;function a(u,h){let f=ug(t,h);const m=ra.getState(t.state)==null;if(!f||!F0(u,f))if(m)f=u;else return;const g=new Ot(u,f);if(m||!t.state.selection.eq(g)){const y=t.state.tr.setSelection(g);m&&y.setMeta(ra,u.pos),t.dispatch(y)}}function o(){t.root.removeEventListener("mouseup",o),t.root.removeEventListener("dragstart",o),t.root.removeEventListener("mousemove",c),ra.getState(t.state)!=null&&t.dispatch(t.state.tr.setMeta(ra,-1))}function c(u){const h=u,f=ra.getState(t.state);let m;if(f!=null)m=t.state.doc.resolve(f);else if(GN(t,h.target)!=r&&(m=ug(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 EC(t,e,n){if(!(t.state.selection instanceof Ue))return null;const{$head:r}=t.state.selection;for(let i=r.depth-1;i>=0;i--){const a=r.node(i);if((n<0?r.index(i):r.indexAfter(i))!=(n<0?0:a.childCount))return null;if(a.type.spec.tableRole=="cell"||a.type.spec.tableRole=="header_cell"){const o=r.before(i),c=e=="vert"?n>0?"down":"up":n>0?"right":"left";return t.endOfTextblock(c)?o:null}}return null}function GN(t,e){for(;e&&e!=t.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function ug(t,e){const n=t.posAtCoords({left:e.clientX,top:e.clientY});if(!n)return null;let{inside:r,pos:i}=n;return r>=0&&bo(t.state.doc.resolve(r))||bo(t.state.doc.resolve(i))}var N$=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")),gx(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,gx(e,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(e){return e.type=="attributes"&&(e.target==this.table||this.colgroup.contains(e.target))}};function gx(t,e,n,r,i,a){let o=0,c=!0,u=e.firstChild;const h=t.firstChild;if(h){for(let m=0,g=0;mnew r(m,n,g)),new j$(-1,!1)},apply(o,c){return c.apply(o)}},props:{attributes:o=>{const c=Ar.getState(o);return c&&c.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(o,c)=>{k$(o,c,t,i)},mouseleave:o=>{S$(o)},mousedown:(o,c)=>{C$(o,c,e,n)}},decorations:o=>{const c=Ar.getState(o);if(c&&c.activeHandle>-1)return I$(o,c.activeHandle)},nodeViews:{}}});return a}var j$=class nh{constructor(e,n){this.activeHandle=e,this.dragging=n}apply(e){const n=this,r=e.getMeta(Ar);if(r&&r.setHandle!=null)return new nh(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new nh(n.activeHandle,r.setDragging);if(n.activeHandle>-1&&e.docChanged){let i=e.mapping.map(n.activeHandle,-1);return px(e.doc.resolve(i))||(i=-1),new nh(i,n.dragging)}return n}};function k$(t,e,n,r){if(!t.editable)return;const i=Ar.getState(t.state);if(i&&!i.dragging){const a=T$(e.target);let o=-1;if(a){const{left:c,right:u}=a.getBoundingClientRect();e.clientX-c<=n?o=JN(t,e,"left",n):u-e.clientX<=n&&(o=JN(t,e,"right",n))}if(o!=i.activeHandle){if(!r&&o!==-1){const c=t.state.doc.resolve(o),u=c.node(-1),h=an.get(u),f=c.start(-1);if(h.colCount(c.pos-f)+c.nodeAfter.attrs.colspan-1==h.width-1)return}TC(t,o)}}}function S$(t){if(!t.editable)return;const e=Ar.getState(t.state);e&&e.activeHandle>-1&&!e.dragging&&TC(t,-1)}function C$(t,e,n,r){var i;if(!t.editable)return!1;const a=(i=t.dom.ownerDocument.defaultView)!==null&&i!==void 0?i:window,o=Ar.getState(t.state);if(!o||o.activeHandle==-1||o.dragging)return!1;const c=t.state.doc.nodeAt(o.activeHandle),u=E$(t,o.activeHandle,c.attrs);t.dispatch(t.state.tr.setMeta(Ar,{setDragging:{startX:e.clientX,startWidth:u}}));function h(m){a.removeEventListener("mouseup",h),a.removeEventListener("mousemove",f);const g=Ar.getState(t.state);g!=null&&g.dragging&&(M$(t,g.activeHandle,YN(g.dragging,m,n)),t.dispatch(t.state.tr.setMeta(Ar,{setDragging:null})))}function f(m){if(!m.which)return h(m);const g=Ar.getState(t.state);if(g&&g.dragging){const y=YN(g.dragging,m,n);QN(t,g.activeHandle,y,r)}}return QN(t,o.activeHandle,u,r),a.addEventListener("mouseup",h),a.addEventListener("mousemove",f),e.preventDefault(),!0}function E$(t,e,{colspan:n,colwidth:r}){const i=r&&r[r.length-1];if(i)return i;const a=t.domAtPos(e);let o=a.node.childNodes[a.offset].offsetWidth,c=n;if(r)for(let u=0;u{var e,n;const r=t.getAttribute("colwidth"),i=r?r.split(",").map(a=>parseInt(a,10)):null;if(!i){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 i}}}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td"}]},renderHTML({HTMLAttributes:t}){return["td",vt(this.options.HTMLAttributes,t),0]}}),AC=mn.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]}}),IC=mn.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 xx(t,e){return e?["width",`${Math.max(e,t)}px`]:["min-width",`${t}px`]}function XN(t,e,n,r,i,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{const r=t.nodes[n];r.spec.tableRole&&(e[r.spec.tableRole]=r)}),t.cached.tableNodeTypes=e,e}function L$(t,e,n,r,i){const a=D$(t),o=[],c=[];for(let h=0;h{const{selection:e}=t.state;if(!_$(e))return!1;let n=0;const r=f2(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},z$="";function $$(t){return(t||"").replace(/\s+/g," ").trim()}function F$(t,e,n={}){var r;const i=(r=n.cellLineSeparator)!=null?r:z$;if(!t||!t.content||t.content.length===0)return"";const a=[];t.content.forEach(v=>{const w=[];v.content&&v.content.forEach(N=>{let k="";N.content&&Array.isArray(N.content)&&N.content.length>1?k=N.content.map(O=>e.renderChildren(O)).join(i):k=N.content?e.renderChildren(N.content):"";const E=$$(k),C=N.type==="tableHeader";w.push({text:E,isHeader:C})}),a.push(w)});const o=a.reduce((v,w)=>Math.max(v,w.length),0);if(o===0)return"";const c=new Array(o).fill(0);a.forEach(v=>{var w;for(let N=0;Nc[N]&&(c[N]=E),c[N]<3&&(c[N]=3)}});const u=(v,w)=>v+" ".repeat(Math.max(0,w-v.length)),h=a[0],f=h.some(v=>v.isHeader);let m=` -`;const g=new Array(o).fill(0).map((v,w)=>f&&h[w]&&h[w].text||"");return m+=`| ${g.map((v,w)=>u(v,c[w])).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((w,N)=>u(v[N]&&v[N].text||"",c[N])).join(" | ")} | -`}),m}var B$=F$,RC=mn.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,renderWrapper:!1,handleWidth:5,cellMinWidth:25,View:P$,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:i}=O$(t,this.options.cellMinWidth),a=e.style;function o(){return a||(r?`width: ${r}`:`min-width: ${i}`)}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(i=>{r.push(e.createNode("tableHeader",{},[{type:"paragraph",content:e.parseInline(i.tokens)}]))}),n.push(e.createNode("tableRow",{},r))}return t.rows&&t.rows.forEach(r=>{const i=[];r.forEach(a=>{i.push(e.createNode("tableCell",{},[{type:"paragraph",content:e.parseInline(a.tokens)}]))}),n.push(e.createNode("tableRow",{},i))}),e.createNode("table",void 0,n)},renderMarkdown:(t,e)=>B$(t,e),addCommands(){return{insertTable:({rows:t=3,cols:e=3,withHeaderRow:n=!0}={})=>({tr:r,dispatch:i,editor:a})=>{const o=L$(a.schema,t,e,n);if(i){const c=r.selection.from+1;r.replaceSelectionWith(o).scrollIntoView().setSelection(Ue.near(r.doc.resolve(c)))}return!0},addColumnBefore:()=>({state:t,dispatch:e})=>Qz(t,e),addColumnAfter:()=>({state:t,dispatch:e})=>Xz(t,e),deleteColumn:()=>({state:t,dispatch:e})=>e$(t,e),addRowBefore:()=>({state:t,dispatch:e})=>n$(t,e),addRowAfter:()=>({state:t,dispatch:e})=>r$(t,e),deleteRow:()=>({state:t,dispatch:e})=>i$(t,e),deleteTable:()=>({state:t,dispatch:e})=>h$(t,e),mergeCells:()=>({state:t,dispatch:e})=>BN(t,e),splitCell:()=>({state:t,dispatch:e})=>VN(t,e),toggleHeaderColumn:()=>({state:t,dispatch:e})=>od("column")(t,e),toggleHeaderRow:()=>({state:t,dispatch:e})=>od("row")(t,e),toggleHeaderCell:()=>({state:t,dispatch:e})=>d$(t,e),mergeOrSplit:()=>({state:t,dispatch:e})=>BN(t,e)?!0:VN(t,e),setCellAttribute:(t,e)=>({state:n,dispatch:r})=>l$(t,e)(n,r),goToNextCell:()=>({state:t,dispatch:e})=>WN(1)(t,e),goToPreviousCell:()=>({state:t,dispatch:e})=>WN(-1)(t,e),fixTables:()=>({state:t,dispatch:e})=>(e&&kC(t),!0),setCellSelection:t=>({tr:e,dispatch:n})=>{if(n){const r=Ot.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:Uu,"Mod-Backspace":Uu,Delete:Uu,"Mod-Delete":Uu}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[w$({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],R$({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema(t){const e={name:t.name,options:t.options,storage:t.storage};return{tableRole:yt(Ve(t,"tableRole",e))}}});on.create({name:"tableKit",addExtensions(){const t=[];return this.options.table!==!1&&t.push(RC.configure(this.options.table)),this.options.tableCell!==!1&&t.push(MC.configure(this.options.tableCell)),this.options.tableHeader!==!1&&t.push(AC.configure(this.options.tableHeader)),this.options.tableRow!==!1&&t.push(IC.configure(this.options.tableRow)),t}});function V$(t){if(!t)return"";let e=t;return e=e.replace(/]*>(.*?)<\/h1>/gi,`# $1 - -`),e=e.replace(/]*>(.*?)<\/h2>/gi,`## $1 - -`),e=e.replace(/]*>(.*?)<\/h3>/gi,`### $1 - -`),e=e.replace(/]*>(.*?)<\/strong>/gi,"**$1**"),e=e.replace(/]*>(.*?)<\/b>/gi,"**$1**"),e=e.replace(/]*>(.*?)<\/em>/gi,"*$1*"),e=e.replace(/]*>(.*?)<\/i>/gi,"*$1*"),e=e.replace(/]*>(.*?)<\/s>/gi,"~~$1~~"),e=e.replace(/]*>(.*?)<\/del>/gi,"~~$1~~"),e=e.replace(/]*>(.*?)<\/code>/gi,"`$1`"),e=e.replace(/]*>(.*?)<\/blockquote>/gi,`> $1 - -`),e=e.replace(/]*src="([^"]*)"[^>]*alt="([^"]*)"[^>]*>/gi,"![$2]($1)"),e=e.replace(/]*src="([^"]*)"[^>]*>/gi,"![]($1)"),e=e.replace(/]*href="([^"]*)"[^>]*>(.*?)<\/a>/gi,"[$2]($1)"),e=e.replace(/]*>(.*?)<\/li>/gi,`- $1 -`),e=e.replace(/<\/?[uo]l[^>]*>/gi,` -`),e=e.replace(//gi,` -`),e=e.replace(/]*>(.*?)<\/p>/gi,`$1 - -`),e=e.replace(//gi,`--- - -`),e=e.replace(/]*data-type="mention"[^>]*data-id="([^"]*)"[^>]*>@([^<]*)<\/span>/gi,"@$2"),e=e.replace(/]*data-type="linkTag"[^>]*data-url="([^"]*)"[^>]*>#([^<]*)<\/span>/gi,"#[$2]($1)"),e=e.replace(/<[^>]+>/g,""),e=e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'"),e=e.replace(/\n{3,}/g,` - -`),e.trim()}function ew(t){if(!t)return"";if(t.startsWith("<")&&t.includes("$1"),e=e.replace(/^## (.+)$/gm,"

    $1

    "),e=e.replace(/^# (.+)$/gm,"

    $1

    "),e=e.replace(/\*\*(.+?)\*\*/g,"$1"),e=e.replace(/\*(.+?)\*/g,"$1"),e=e.replace(/~~(.+?)~~/g,"$1"),e=e.replace(/`([^`]+)`/g,"$1"),e=e.replace(/!\[([^\]]*)\]\(([^)]+)\)/g,'$1'),e=e.replace(/\[([^\]]+)\]\(([^)]+)\)/g,'$1'),e=e.replace(/^> (.+)$/gm,"

    $1

    "),e=e.replace(/^---$/gm,"
    "),e=e.replace(/^- (.+)$/gm,"
  • $1
  • ");const n=e.split(` -`),r=[];for(const i of n){const a=i.trim();a&&(/^<(?:h[1-6]|blockquote|hr|li|ul|ol|table|img)/.test(a)?r.push(a):r.push(`

    ${a}

    `))}return r.join("")}const H$=mn.create({name:"linkTag",group:"inline",inline:!0,selectable:!0,atom:!0,addAttributes(){return{label:{default:""},url:{default:""},tagType:{default:"url",parseHTML:t=>t.getAttribute("data-tag-type")||"url"},tagId:{default:"",parseHTML:t=>t.getAttribute("data-tag-id")||""},pagePath:{default:"",parseHTML:t=>t.getAttribute("data-page-path")||""},appId:{default:"",parseHTML:t=>t.getAttribute("data-app-id")||""},mpKey:{default:"",parseHTML:t=>t.getAttribute("data-mp-key")||""}}},parseHTML(){return[{tag:'span[data-type="linkTag"]',getAttrs:t=>{var e;return{label:((e=t.textContent)==null?void 0:e.replace(/^#/,"").trim())||"",url:t.getAttribute("data-url")||"",tagType:t.getAttribute("data-tag-type")||"url",tagId:t.getAttribute("data-tag-id")||"",pagePath:t.getAttribute("data-page-path")||"",appId:t.getAttribute("data-app-id")||"",mpKey:t.getAttribute("data-mp-key")||""}}}]},renderHTML({node:t,HTMLAttributes:e}){return["span",vt(e,{"data-type":"linkTag","data-url":t.attrs.url,"data-tag-type":t.attrs.tagType,"data-tag-id":t.attrs.tagId,"data-page-path":t.attrs.pagePath,"data-app-id":t.attrs.appId||"","data-mp-key":t.attrs.mpKey||t.attrs.appId||"",class:"link-tag-node"}),`#${t.attrs.label}`]}}),W$=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=[],i=null;const a=()=>{e&&(e.innerHTML=r.map((o,c)=>`
    - @${o.name} - ${o.label||o.id} -
    `).join(""),e.querySelectorAll(".mention-item").forEach(o=>{o.addEventListener("click",()=>{const c=parseInt(o.getAttribute("data-index")||"0");i&&r[c]&&i({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,i=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,i=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"?(i&&r[n]&&i({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}}}}),yx=b.forwardRef(({content:t,onChange:e,onImageUpload:n,persons:r=[],linkTags:i=[],placeholder:a="开始编辑内容...",className:o},c)=>{const u=b.useRef(null),[h,f]=b.useState(""),[m,g]=b.useState(!1),y=b.useRef(ew(t)),v=z_({extensions:[Sz,Tz.configure({inline:!0,allowBase64:!0}),O7.configure({openOnClick:!1,HTMLAttributes:{class:"rich-link"}}),Oz.configure({HTMLAttributes:{class:"mention-tag"},suggestion:W$(r)}),H$,Dz.configure({placeholder:a}),RC.configure({resizable:!0}),IC,MC,AC],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:()=>V$((v==null?void 0:v.getHTML())||"")})),b.useEffect(()=>{if(v&&t!==v.getHTML()){const E=ew(t);E!==v.getHTML()&&v.commands.setContent(E)}},[t]);const w=b.useCallback(async E=>{var T;const C=(T=E.target.files)==null?void 0:T[0];if(!(!C||!v)){if(n){const O=await n(C);O&&v.chain().focus().setImage({src:O}).run()}else{const O=new FileReader;O.onload=()=>{typeof O.result=="string"&&v.chain().focus().setImage({src:O.result}).run()},O.readAsDataURL(C)}E.target.value=""}},[v,n]),N=b.useCallback(E=>{v&&v.chain().focus().insertContent({type:"linkTag",attrs:{label:E.label,url:E.url||"",tagType:E.type||"url",tagId:E.id||"",pagePath:E.pagePath||"",appId:E.appId||"",mpKey:E.type==="miniprogram"&&E.appId||""}}).run()},[v]),k=b.useCallback(()=>{!v||!h||(v.chain().focus().setLink({href:h}).run(),f(""),g(!1))},[v,h]);return v?s.jsxs("div",{className:`rich-editor-wrapper ${o||""}`,children:[s.jsxs("div",{className:"rich-editor-toolbar",children:[s.jsxs("div",{className:"toolbar-group",children:[s.jsx("button",{onClick:()=>v.chain().focus().toggleBold().run(),className:v.isActive("bold")?"is-active":"",type:"button",children:s.jsx(OT,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>v.chain().focus().toggleItalic().run(),className:v.isActive("italic")?"is-active":"",type:"button",children:s.jsx(OM,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>v.chain().focus().toggleStrike().run(),className:v.isActive("strike")?"is-active":"",type:"button",children:s.jsx(IA,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>v.chain().focus().toggleCode().run(),className:v.isActive("code")?"is-active":"",type:"button",children:s.jsx(eM,{className:"w-4 h-4"})})]}),s.jsx("div",{className:"toolbar-divider"}),s.jsxs("div",{className:"toolbar-group",children:[s.jsx("button",{onClick:()=>v.chain().focus().toggleHeading({level:1}).run(),className:v.isActive("heading",{level:1})?"is-active":"",type:"button",children:s.jsx(kM,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>v.chain().focus().toggleHeading({level:2}).run(),className:v.isActive("heading",{level:2})?"is-active":"",type:"button",children:s.jsx(CM,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>v.chain().focus().toggleHeading({level:3}).run(),className:v.isActive("heading",{level:3})?"is-active":"",type:"button",children:s.jsx(TM,{className:"w-4 h-4"})})]}),s.jsx("div",{className:"toolbar-divider"}),s.jsxs("div",{className:"toolbar-group",children:[s.jsx("button",{onClick:()=>v.chain().focus().toggleBulletList().run(),className:v.isActive("bulletList")?"is-active":"",type:"button",children:s.jsx(WM,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>v.chain().focus().toggleOrderedList().run(),className:v.isActive("orderedList")?"is-active":"",type:"button",children:s.jsx(VM,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>v.chain().focus().toggleBlockquote().run(),className:v.isActive("blockquote")?"is-active":"",type:"button",children:s.jsx(gA,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>v.chain().focus().setHorizontalRule().run(),type:"button",children:s.jsx(tA,{className:"w-4 h-4"})})]}),s.jsx("div",{className:"toolbar-divider"}),s.jsxs("div",{className:"toolbar-group",children:[s.jsx("input",{ref:u,type:"file",accept:"image/*",onChange:w,className:"hidden"}),s.jsx("button",{onClick:()=>{var E;return(E=u.current)==null?void 0:E.click()},type:"button",children:s.jsx(Uw,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>g(!m),className:v.isActive("link")?"is-active":"",type:"button",children:s.jsx(Sg,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>v.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run(),type:"button",children:s.jsx(PA,{className:"w-4 h-4"})})]}),s.jsx("div",{className:"toolbar-divider"}),s.jsxs("div",{className:"toolbar-group",children:[s.jsx("button",{onClick:()=>v.chain().focus().undo().run(),disabled:!v.can().undo(),type:"button",children:s.jsx(FA,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>v.chain().focus().redo().run(),disabled:!v.can().redo(),type:"button",children:s.jsx(yA,{className:"w-4 h-4"})})]}),i.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"toolbar-divider"}),s.jsx("div",{className:"toolbar-group",children:s.jsxs("select",{className:"link-tag-select",onChange:E=>{const C=i.find(T=>T.id===E.target.value);C&&N(C),E.target.value=""},defaultValue:"",children:[s.jsx("option",{value:"",disabled:!0,children:"# 插入链接标签"}),i.map(E=>s.jsx("option",{value:E.id,children:E.label},E.id))]})})]})]}),m&&s.jsxs("div",{className:"link-input-bar",children:[s.jsx("input",{type:"url",placeholder:"输入链接地址...",value:h,onChange:E=>f(E.target.value),onKeyDown:E=>E.key==="Enter"&&k(),className:"link-input"}),s.jsx("button",{onClick:k,className:"link-confirm",type:"button",children:"确定"}),s.jsx("button",{onClick:()=>{v.chain().focus().unsetLink().run(),g(!1)},className:"link-remove",type:"button",children:"移除"})]}),s.jsx(V2,{editor:v})]}):null});yx.displayName="RichEditor";const U$=["top","right","bottom","left"],va=Math.min,Tr=Math.max,tf=Math.round,Ku=Math.floor,Ls=t=>({x:t,y:t}),K$={left:"right",right:"left",bottom:"top",top:"bottom"},q$={start:"end",end:"start"};function vx(t,e,n){return Tr(t,va(e,n))}function bi(t,e){return typeof t=="function"?t(e):t}function Ni(t){return t.split("-")[0]}function Fl(t){return t.split("-")[1]}function B0(t){return t==="x"?"y":"x"}function V0(t){return t==="y"?"height":"width"}const G$=new Set(["top","bottom"]);function Ds(t){return G$.has(Ni(t))?"y":"x"}function H0(t){return B0(Ds(t))}function J$(t,e,n){n===void 0&&(n=!1);const r=Fl(t),i=H0(t),a=V0(i);let o=i==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return e.reference[a]>e.floating[a]&&(o=nf(o)),[o,nf(o)]}function Y$(t){const e=nf(t);return[bx(t),e,bx(e)]}function bx(t){return t.replace(/start|end/g,e=>q$[e])}const tw=["left","right"],nw=["right","left"],Q$=["top","bottom"],X$=["bottom","top"];function Z$(t,e,n){switch(t){case"top":case"bottom":return n?e?nw:tw:e?tw:nw;case"left":case"right":return e?Q$:X$;default:return[]}}function eF(t,e,n,r){const i=Fl(t);let a=Z$(Ni(t),n==="start",r);return i&&(a=a.map(o=>o+"-"+i),e&&(a=a.concat(a.map(bx)))),a}function nf(t){return t.replace(/left|right|bottom|top/g,e=>K$[e])}function tF(t){return{top:0,right:0,bottom:0,left:0,...t}}function PC(t){return typeof t!="number"?tF(t):{top:t,right:t,bottom:t,left:t}}function rf(t){const{x:e,y:n,width:r,height:i}=t;return{width:r,height:i,top:n,left:e,right:e+r,bottom:n+i,x:e,y:n}}function rw(t,e,n){let{reference:r,floating:i}=t;const a=Ds(e),o=H0(e),c=V0(o),u=Ni(e),h=a==="y",f=r.x+r.width/2-i.width/2,m=r.y+r.height/2-i.height/2,g=r[c]/2-i[c]/2;let y;switch(u){case"top":y={x:f,y:r.y-i.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-i.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 nF(t,e){var n;e===void 0&&(e={});const{x:r,y:i,platform:a,rects:o,elements:c,strategy:u}=t,{boundary:h="clippingAncestors",rootBoundary:f="viewport",elementContext:m="floating",altBoundary:g=!1,padding:y=0}=bi(e,t),v=PC(y),N=c[g?m==="floating"?"reference":"floating":m],k=rf(await a.getClippingRect({element:(n=await(a.isElement==null?void 0:a.isElement(N)))==null||n?N:N.contextElement||await(a.getDocumentElement==null?void 0:a.getDocumentElement(c.floating)),boundary:h,rootBoundary:f,strategy:u})),E=m==="floating"?{x:r,y:i,width:o.floating.width,height:o.floating.height}:o.reference,C=await(a.getOffsetParent==null?void 0:a.getOffsetParent(c.floating)),T=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},O=rf(a.convertOffsetParentRelativeRectToViewportRelativeRect?await a.convertOffsetParentRelativeRectToViewportRelativeRect({elements:c,rect:E,offsetParent:C,strategy:u}):E);return{top:(k.top-O.top+v.top)/T.y,bottom:(O.bottom-k.bottom+v.bottom)/T.y,left:(k.left-O.left+v.left)/T.x,right:(O.right-k.right+v.right)/T.x}}const rF=async(t,e,n)=>{const{placement:r="bottom",strategy:i="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:i}),{x:f,y:m}=rw(h,r,u),g=r,y={},v=0;for(let N=0;N({name:"arrow",options:t,async fn(e){const{x:n,y:r,placement:i,rects:a,platform:o,elements:c,middlewareData:u}=e,{element:h,padding:f=0}=bi(t,e)||{};if(h==null)return{};const m=PC(f),g={x:n,y:r},y=H0(i),v=V0(y),w=await o.getDimensions(h),N=y==="y",k=N?"top":"left",E=N?"bottom":"right",C=N?"clientHeight":"clientWidth",T=a.reference[v]+a.reference[y]-g[y]-a.floating[v],O=g[y]-a.reference[y],F=await(o.getOffsetParent==null?void 0:o.getOffsetParent(h));let I=F?F[C]:0;(!I||!await(o.isElement==null?void 0:o.isElement(F)))&&(I=c.floating[C]||a.floating[v]);const R=T/2-O/2,P=I/2-w[v]/2-1,L=va(m[k],P),ee=va(m[E],P),te=L,Y=I-w[v]-ee,U=I/2-w[v]/2+R,D=vx(te,U,Y),$=!u.arrow&&Fl(i)!=null&&U!==D&&a.reference[v]/2-(UU<=0)){var ee,te;const U=(((ee=a.flip)==null?void 0:ee.index)||0)+1,D=I[U];if(D&&(!(m==="alignment"?E!==Ds(D):!1)||L.every(_=>Ds(_.placement)===E?_.overflows[0]>0:!0)))return{data:{index:U,overflows:L},reset:{placement:D}};let $=(te=L.filter(le=>le.overflows[0]<=0).sort((le,_)=>le.overflows[1]-_.overflows[1])[0])==null?void 0:te.placement;if(!$)switch(y){case"bestFit":{var Y;const le=(Y=L.filter(_=>{if(F){const se=Ds(_.placement);return se===E||se==="y"}return!0}).map(_=>[_.placement,_.overflows.filter(se=>se>0).reduce((se,J)=>se+J,0)]).sort((_,se)=>_[1]-se[1])[0])==null?void 0:Y[0];le&&($=le);break}case"initialPlacement":$=c;break}if(i!==$)return{reset:{placement:$}}}return{}}}};function sw(t,e){return{top:t.top-e.height,right:t.right-e.width,bottom:t.bottom-e.height,left:t.left-e.width}}function iw(t){return U$.some(e=>t[e]>=0)}const aF=function(t){return t===void 0&&(t={}),{name:"hide",options:t,async fn(e){const{rects:n,platform:r}=e,{strategy:i="referenceHidden",...a}=bi(t,e);switch(i){case"referenceHidden":{const o=await r.detectOverflow(e,{...a,elementContext:"reference"}),c=sw(o,n.reference);return{data:{referenceHiddenOffsets:c,referenceHidden:iw(c)}}}case"escaped":{const o=await r.detectOverflow(e,{...a,altBoundary:!0}),c=sw(o,n.floating);return{data:{escapedOffsets:c,escaped:iw(c)}}}default:return{}}}}},OC=new Set(["left","top"]);async function oF(t,e){const{placement:n,platform:r,elements:i}=t,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=Ni(n),c=Fl(n),u=Ds(n)==="y",h=OC.has(o)?-1:1,f=a&&u?-1:1,m=bi(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 lF=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){var n,r;const{x:i,y:a,placement:o,middlewareData:c}=e,u=await oF(e,t);return o===((n=c.offset)==null?void 0:n.placement)&&(r=c.arrow)!=null&&r.alignmentOffset?{}:{x:i+u.x,y:a+u.y,data:{...u,placement:o}}}}},cF=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){const{x:n,y:r,placement:i,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}=bi(t,e),f={x:n,y:r},m=await a.detectOverflow(e,h),g=Ds(Ni(i)),y=B0(g);let v=f[y],w=f[g];if(o){const k=y==="y"?"top":"left",E=y==="y"?"bottom":"right",C=v+m[k],T=v-m[E];v=vx(C,v,T)}if(c){const k=g==="y"?"top":"left",E=g==="y"?"bottom":"right",C=w+m[k],T=w-m[E];w=vx(C,w,T)}const N=u.fn({...e,[y]:v,[g]:w});return{...N,data:{x:N.x-n,y:N.y-r,enabled:{[y]:o,[g]:c}}}}}},dF=function(t){return t===void 0&&(t={}),{options:t,fn(e){const{x:n,y:r,placement:i,rects:a,middlewareData:o}=e,{offset:c=0,mainAxis:u=!0,crossAxis:h=!0}=bi(t,e),f={x:n,y:r},m=Ds(i),g=B0(m);let y=f[g],v=f[m];const w=bi(c,e),N=typeof w=="number"?{mainAxis:w,crossAxis:0}:{mainAxis:0,crossAxis:0,...w};if(u){const C=g==="y"?"height":"width",T=a.reference[g]-a.floating[C]+N.mainAxis,O=a.reference[g]+a.reference[C]-N.mainAxis;yO&&(y=O)}if(h){var k,E;const C=g==="y"?"width":"height",T=OC.has(Ni(i)),O=a.reference[m]-a.floating[C]+(T&&((k=o.offset)==null?void 0:k[m])||0)+(T?0:N.crossAxis),F=a.reference[m]+a.reference[C]+(T?0:((E=o.offset)==null?void 0:E[m])||0)-(T?N.crossAxis:0);vF&&(v=F)}return{[g]:y,[m]:v}}}},uF=function(t){return t===void 0&&(t={}),{name:"size",options:t,async fn(e){var n,r;const{placement:i,rects:a,platform:o,elements:c}=e,{apply:u=()=>{},...h}=bi(t,e),f=await o.detectOverflow(e,h),m=Ni(i),g=Fl(i),y=Ds(i)==="y",{width:v,height:w}=a.floating;let N,k;m==="top"||m==="bottom"?(N=m,k=g===(await(o.isRTL==null?void 0:o.isRTL(c.floating))?"start":"end")?"left":"right"):(k=m,N=g==="end"?"top":"bottom");const E=w-f.top-f.bottom,C=v-f.left-f.right,T=va(w-f[N],E),O=va(v-f[k],C),F=!e.middlewareData.shift;let I=T,R=O;if((n=e.middlewareData.shift)!=null&&n.enabled.x&&(R=C),(r=e.middlewareData.shift)!=null&&r.enabled.y&&(I=E),F&&!g){const L=Tr(f.left,0),ee=Tr(f.right,0),te=Tr(f.top,0),Y=Tr(f.bottom,0);y?R=v-2*(L!==0||ee!==0?L+ee:Tr(f.left,f.right)):I=w-2*(te!==0||Y!==0?te+Y:Tr(f.top,f.bottom))}await u({...e,availableWidth:R,availableHeight:I});const P=await o.getDimensions(c.floating);return v!==P.width||w!==P.height?{reset:{rects:!0}}:{}}}};function Pf(){return typeof window<"u"}function Bl(t){return DC(t)?(t.nodeName||"").toLowerCase():"#document"}function Rr(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function Vs(t){var e;return(e=(DC(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function DC(t){return Pf()?t instanceof Node||t instanceof Rr(t).Node:!1}function gs(t){return Pf()?t instanceof Element||t instanceof Rr(t).Element:!1}function Fs(t){return Pf()?t instanceof HTMLElement||t instanceof Rr(t).HTMLElement:!1}function aw(t){return!Pf()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof Rr(t).ShadowRoot}const hF=new Set(["inline","contents"]);function yd(t){const{overflow:e,overflowX:n,overflowY:r,display:i}=xs(t);return/auto|scroll|overlay|hidden|clip/.test(e+r+n)&&!hF.has(i)}const fF=new Set(["table","td","th"]);function pF(t){return fF.has(Bl(t))}const mF=[":popover-open",":modal"];function Of(t){return mF.some(e=>{try{return t.matches(e)}catch{return!1}})}const gF=["transform","translate","scale","rotate","perspective"],xF=["transform","translate","scale","rotate","perspective","filter"],yF=["paint","layout","strict","content"];function W0(t){const e=U0(),n=gs(t)?xs(t):t;return gF.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)||xF.some(r=>(n.willChange||"").includes(r))||yF.some(r=>(n.contain||"").includes(r))}function vF(t){let e=ba(t);for(;Fs(e)&&!Il(e);){if(W0(e))return e;if(Of(e))return null;e=ba(e)}return null}function U0(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const bF=new Set(["html","body","#document"]);function Il(t){return bF.has(Bl(t))}function xs(t){return Rr(t).getComputedStyle(t)}function Df(t){return gs(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function ba(t){if(Bl(t)==="html")return t;const e=t.assignedSlot||t.parentNode||aw(t)&&t.host||Vs(t);return aw(e)?e.host:e}function LC(t){const e=ba(t);return Il(e)?t.ownerDocument?t.ownerDocument.body:t.body:Fs(e)&&yd(e)?e:LC(e)}function ld(t,e,n){var r;e===void 0&&(e=[]),n===void 0&&(n=!0);const i=LC(t),a=i===((r=t.ownerDocument)==null?void 0:r.body),o=Rr(i);if(a){const c=Nx(o);return e.concat(o,o.visualViewport||[],yd(i)?i:[],c&&n?ld(c):[])}return e.concat(i,ld(i,[],n))}function Nx(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function _C(t){const e=xs(t);let n=parseFloat(e.width)||0,r=parseFloat(e.height)||0;const i=Fs(t),a=i?t.offsetWidth:n,o=i?t.offsetHeight:r,c=tf(n)!==a||tf(r)!==o;return c&&(n=a,r=o),{width:n,height:r,$:c}}function K0(t){return gs(t)?t:t.contextElement}function wl(t){const e=K0(t);if(!Fs(e))return Ls(1);const n=e.getBoundingClientRect(),{width:r,height:i,$:a}=_C(e);let o=(a?tf(n.width):n.width)/r,c=(a?tf(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!c||!Number.isFinite(c))&&(c=1),{x:o,y:c}}const NF=Ls(0);function zC(t){const e=Rr(t);return!U0()||!e.visualViewport?NF:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function wF(t,e,n){return e===void 0&&(e=!1),!n||e&&n!==Rr(t)?!1:e}function wo(t,e,n,r){e===void 0&&(e=!1),n===void 0&&(n=!1);const i=t.getBoundingClientRect(),a=K0(t);let o=Ls(1);e&&(r?gs(r)&&(o=wl(r)):o=wl(t));const c=wF(a,n,r)?zC(a):Ls(0);let u=(i.left+c.x)/o.x,h=(i.top+c.y)/o.y,f=i.width/o.x,m=i.height/o.y;if(a){const g=Rr(a),y=r&&gs(r)?Rr(r):r;let v=g,w=Nx(v);for(;w&&r&&y!==v;){const N=wl(w),k=w.getBoundingClientRect(),E=xs(w),C=k.left+(w.clientLeft+parseFloat(E.paddingLeft))*N.x,T=k.top+(w.clientTop+parseFloat(E.paddingTop))*N.y;u*=N.x,h*=N.y,f*=N.x,m*=N.y,u+=C,h+=T,v=Rr(w),w=Nx(v)}}return rf({width:f,height:m,x:u,y:h})}function Lf(t,e){const n=Df(t).scrollLeft;return e?e.left+n:wo(Vs(t)).left+n}function $C(t,e){const n=t.getBoundingClientRect(),r=n.left+e.scrollLeft-Lf(t,n),i=n.top+e.scrollTop;return{x:r,y:i}}function jF(t){let{elements:e,rect:n,offsetParent:r,strategy:i}=t;const a=i==="fixed",o=Vs(r),c=e?Of(e.floating):!1;if(r===o||c&&a)return n;let u={scrollLeft:0,scrollTop:0},h=Ls(1);const f=Ls(0),m=Fs(r);if((m||!m&&!a)&&((Bl(r)!=="body"||yd(o))&&(u=Df(r)),Fs(r))){const y=wo(r);h=wl(r),f.x=y.x+r.clientLeft,f.y=y.y+r.clientTop}const g=o&&!m&&!a?$C(o,u):Ls(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 kF(t){return Array.from(t.getClientRects())}function SF(t){const e=Vs(t),n=Df(t),r=t.ownerDocument.body,i=Tr(e.scrollWidth,e.clientWidth,r.scrollWidth,r.clientWidth),a=Tr(e.scrollHeight,e.clientHeight,r.scrollHeight,r.clientHeight);let o=-n.scrollLeft+Lf(t);const c=-n.scrollTop;return xs(r).direction==="rtl"&&(o+=Tr(e.clientWidth,r.clientWidth)-i),{width:i,height:a,x:o,y:c}}const ow=25;function CF(t,e){const n=Rr(t),r=Vs(t),i=n.visualViewport;let a=r.clientWidth,o=r.clientHeight,c=0,u=0;if(i){a=i.width,o=i.height;const f=U0();(!f||f&&e==="fixed")&&(c=i.offsetLeft,u=i.offsetTop)}const h=Lf(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<=ow&&(a-=v)}else h<=ow&&(a+=h);return{width:a,height:o,x:c,y:u}}const EF=new Set(["absolute","fixed"]);function TF(t,e){const n=wo(t,!0,e==="fixed"),r=n.top+t.clientTop,i=n.left+t.clientLeft,a=Fs(t)?wl(t):Ls(1),o=t.clientWidth*a.x,c=t.clientHeight*a.y,u=i*a.x,h=r*a.y;return{width:o,height:c,x:u,y:h}}function lw(t,e,n){let r;if(e==="viewport")r=CF(t,n);else if(e==="document")r=SF(Vs(t));else if(gs(e))r=TF(e,n);else{const i=zC(t);r={x:e.x-i.x,y:e.y-i.y,width:e.width,height:e.height}}return rf(r)}function FC(t,e){const n=ba(t);return n===e||!gs(n)||Il(n)?!1:xs(n).position==="fixed"||FC(n,e)}function MF(t,e){const n=e.get(t);if(n)return n;let r=ld(t,[],!1).filter(c=>gs(c)&&Bl(c)!=="body"),i=null;const a=xs(t).position==="fixed";let o=a?ba(t):t;for(;gs(o)&&!Il(o);){const c=xs(o),u=W0(o);!u&&c.position==="fixed"&&(i=null),(a?!u&&!i:!u&&c.position==="static"&&!!i&&EF.has(i.position)||yd(o)&&!u&&FC(t,o))?r=r.filter(f=>f!==o):i=c,o=ba(o)}return e.set(t,r),r}function AF(t){let{element:e,boundary:n,rootBoundary:r,strategy:i}=t;const o=[...n==="clippingAncestors"?Of(e)?[]:MF(e,this._c):[].concat(n),r],c=o[0],u=o.reduce((h,f)=>{const m=lw(e,f,i);return h.top=Tr(m.top,h.top),h.right=va(m.right,h.right),h.bottom=va(m.bottom,h.bottom),h.left=Tr(m.left,h.left),h},lw(e,c,i));return{width:u.right-u.left,height:u.bottom-u.top,x:u.left,y:u.top}}function IF(t){const{width:e,height:n}=_C(t);return{width:e,height:n}}function RF(t,e,n){const r=Fs(e),i=Vs(e),a=n==="fixed",o=wo(t,!0,a,e);let c={scrollLeft:0,scrollTop:0};const u=Ls(0);function h(){u.x=Lf(i)}if(r||!r&&!a)if((Bl(e)!=="body"||yd(i))&&(c=Df(e)),r){const y=wo(e,!0,a,e);u.x=y.x+e.clientLeft,u.y=y.y+e.clientTop}else i&&h();a&&!r&&i&&h();const f=i&&!r&&!a?$C(i,c):Ls(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 hg(t){return xs(t).position==="static"}function cw(t,e){if(!Fs(t)||xs(t).position==="fixed")return null;if(e)return e(t);let n=t.offsetParent;return Vs(t)===n&&(n=n.ownerDocument.body),n}function BC(t,e){const n=Rr(t);if(Of(t))return n;if(!Fs(t)){let i=ba(t);for(;i&&!Il(i);){if(gs(i)&&!hg(i))return i;i=ba(i)}return n}let r=cw(t,e);for(;r&&pF(r)&&hg(r);)r=cw(r,e);return r&&Il(r)&&hg(r)&&!W0(r)?n:r||vF(t)||n}const PF=async function(t){const e=this.getOffsetParent||BC,n=this.getDimensions,r=await n(t.floating);return{reference:RF(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function OF(t){return xs(t).direction==="rtl"}const DF={convertOffsetParentRelativeRectToViewportRelativeRect:jF,getDocumentElement:Vs,getClippingRect:AF,getOffsetParent:BC,getElementRects:PF,getClientRects:kF,getDimensions:IF,getScale:wl,isElement:gs,isRTL:OF};function VC(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}function LF(t,e){let n=null,r;const i=Vs(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=Ku(m),w=Ku(i.clientWidth-(f+g)),N=Ku(i.clientHeight-(m+y)),k=Ku(f),C={rootMargin:-v+"px "+-w+"px "+-N+"px "+-k+"px",threshold:Tr(0,va(1,u))||1};let T=!0;function O(F){const I=F[0].intersectionRatio;if(I!==u){if(!T)return o();I?o(!1,I):r=setTimeout(()=>{o(!1,1e-7)},1e3)}I===1&&!VC(h,t.getBoundingClientRect())&&o(),T=!1}try{n=new IntersectionObserver(O,{...C,root:i.ownerDocument})}catch{n=new IntersectionObserver(O,C)}n.observe(t)}return o(!0),a}function _F(t,e,n,r){r===void 0&&(r={});const{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:o=typeof ResizeObserver=="function",layoutShift:c=typeof IntersectionObserver=="function",animationFrame:u=!1}=r,h=K0(t),f=i||a?[...h?ld(h):[],...ld(e)]:[];f.forEach(k=>{i&&k.addEventListener("scroll",n,{passive:!0}),a&&k.addEventListener("resize",n)});const m=h&&c?LF(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,w=u?wo(t):null;u&&N();function N(){const k=wo(t);w&&!VC(w,k)&&n(),w=k,v=requestAnimationFrame(N)}return n(),()=>{var k;f.forEach(E=>{i&&E.removeEventListener("scroll",n),a&&E.removeEventListener("resize",n)}),m==null||m(),(k=y)==null||k.disconnect(),y=null,u&&cancelAnimationFrame(v)}}const zF=lF,$F=cF,FF=iF,BF=uF,VF=aF,dw=sF,HF=dF,WF=(t,e,n)=>{const r=new Map,i={platform:DF,...n},a={...i.platform,_c:r};return rF(t,e,{...i,platform:a})};var UF=typeof document<"u",KF=function(){},rh=UF?b.useLayoutEffect:KF;function sf(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,i;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(!sf(t[r],e[r]))return!1;return!0}if(i=Object.keys(t),n=i.length,n!==Object.keys(e).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(e,i[r]))return!1;for(r=n;r--!==0;){const a=i[r];if(!(a==="_owner"&&t.$$typeof)&&!sf(t[a],e[a]))return!1}return!0}return t!==t&&e!==e}function HC(t){return typeof window>"u"?1:(t.ownerDocument.defaultView||window).devicePixelRatio||1}function uw(t,e){const n=HC(t);return Math.round(e*n)/n}function fg(t){const e=b.useRef(t);return rh(()=>{e.current=t}),e}function qF(t){t===void 0&&(t={});const{placement:e="bottom",strategy:n="absolute",middleware:r=[],platform:i,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);sf(g,r)||y(r);const[v,w]=b.useState(null),[N,k]=b.useState(null),E=b.useCallback(_=>{_!==F.current&&(F.current=_,w(_))},[]),C=b.useCallback(_=>{_!==I.current&&(I.current=_,k(_))},[]),T=a||v,O=o||N,F=b.useRef(null),I=b.useRef(null),R=b.useRef(f),P=u!=null,L=fg(u),ee=fg(i),te=fg(h),Y=b.useCallback(()=>{if(!F.current||!I.current)return;const _={placement:e,strategy:n,middleware:g};ee.current&&(_.platform=ee.current),WF(F.current,I.current,_).then(se=>{const J={...se,isPositioned:te.current!==!1};U.current&&!sf(R.current,J)&&(R.current=J,dd.flushSync(()=>{m(J)}))})},[g,e,n,ee,te]);rh(()=>{h===!1&&R.current.isPositioned&&(R.current.isPositioned=!1,m(_=>({..._,isPositioned:!1})))},[h]);const U=b.useRef(!1);rh(()=>(U.current=!0,()=>{U.current=!1}),[]),rh(()=>{if(T&&(F.current=T),O&&(I.current=O),T&&O){if(L.current)return L.current(T,O,Y);Y()}},[T,O,Y,L,P]);const D=b.useMemo(()=>({reference:F,floating:I,setReference:E,setFloating:C}),[E,C]),$=b.useMemo(()=>({reference:T,floating:O}),[T,O]),le=b.useMemo(()=>{const _={position:n,left:0,top:0};if(!$.floating)return _;const se=uw($.floating,f.x),J=uw($.floating,f.y);return c?{..._,transform:"translate("+se+"px, "+J+"px)",...HC($.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:se,top:J}},[n,c,$.floating,f.x,f.y]);return b.useMemo(()=>({...f,update:Y,refs:D,elements:$,floatingStyles:le}),[f,Y,D,$,le])}const GF=t=>{function e(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:t,fn(n){const{element:r,padding:i}=typeof t=="function"?t(n):t;return r&&e(r)?r.current!=null?dw({element:r.current,padding:i}).fn(n):{}:r?dw({element:r,padding:i}).fn(n):{}}}},JF=(t,e)=>({...zF(t),options:[t,e]}),YF=(t,e)=>({...$F(t),options:[t,e]}),QF=(t,e)=>({...HF(t),options:[t,e]}),XF=(t,e)=>({...FF(t),options:[t,e]}),ZF=(t,e)=>({...BF(t),options:[t,e]}),eB=(t,e)=>({...VF(t),options:[t,e]}),tB=(t,e)=>({...GF(t),options:[t,e]});var nB="Arrow",WC=b.forwardRef((t,e)=>{const{children:n,width:r=10,height:i=5,...a}=t;return s.jsx(ct.svg,{...a,ref:e,width:r,height:i,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:t.asChild?n:s.jsx("polygon",{points:"0,0 30,0 15,10"})})});WC.displayName=nB;var rB=WC,q0="Popper",[UC,KC]=ka(q0),[sB,qC]=UC(q0),GC=t=>{const{__scopePopper:e,children:n}=t,[r,i]=b.useState(null);return s.jsx(sB,{scope:e,anchor:r,onAnchorChange:i,children:n})};GC.displayName=q0;var JC="PopperAnchor",YC=b.forwardRef((t,e)=>{const{__scopePopper:n,virtualRef:r,...i}=t,a=qC(JC,n),o=b.useRef(null),c=bt(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:s.jsx(ct.div,{...i,ref:c})});YC.displayName=JC;var G0="PopperContent",[iB,aB]=UC(G0),QC=b.forwardRef((t,e)=>{var ce,he,we,V,be,Me;const{__scopePopper:n,side:r="bottom",sideOffset:i=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,...w}=t,N=qC(G0,n),[k,E]=b.useState(null),C=bt(e,st=>E(st)),[T,O]=b.useState(null),F=Gx(T),I=(F==null?void 0:F.width)??0,R=(F==null?void 0:F.height)??0,P=r+(a!=="center"?"-"+a:""),L=typeof f=="number"?f:{top:0,right:0,bottom:0,left:0,...f},ee=Array.isArray(h)?h:[h],te=ee.length>0,Y={padding:L,boundary:ee.filter(lB),altBoundary:te},{refs:U,floatingStyles:D,placement:$,isPositioned:le,middlewareData:_}=qF({strategy:"fixed",placement:P,whileElementsMounted:(...st)=>_F(...st,{animationFrame:y==="always"}),elements:{reference:N.anchor},middleware:[JF({mainAxis:i+R,alignmentAxis:o}),u&&YF({mainAxis:!0,crossAxis:!1,limiter:m==="partial"?QF():void 0,...Y}),u&&XF({...Y}),ZF({...Y,apply:({elements:st,rects:nt,availableWidth:dt,availableHeight:Ye})=>{const{width:ht,height:Tt}=nt.reference,ft=st.floating.style;ft.setProperty("--radix-popper-available-width",`${dt}px`),ft.setProperty("--radix-popper-available-height",`${Ye}px`),ft.setProperty("--radix-popper-anchor-width",`${ht}px`),ft.setProperty("--radix-popper-anchor-height",`${Tt}px`)}}),T&&tB({element:T,padding:c}),cB({arrowWidth:I,arrowHeight:R}),g&&eB({strategy:"referenceHidden",...Y})]}),[se,J]=e4($),z=ga(v);Kn(()=>{le&&(z==null||z())},[le,z]);const W=(ce=_.arrow)==null?void 0:ce.x,ue=(he=_.arrow)==null?void 0:he.y,G=((we=_.arrow)==null?void 0:we.centerOffset)!==0,[fe,X]=b.useState();return Kn(()=>{k&&X(window.getComputedStyle(k).zIndex)},[k]),s.jsx("div",{ref:U.setFloating,"data-radix-popper-content-wrapper":"",style:{...D,transform:le?D.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:fe,"--radix-popper-transform-origin":[(V=_.transformOrigin)==null?void 0:V.x,(be=_.transformOrigin)==null?void 0:be.y].join(" "),...((Me=_.hide)==null?void 0:Me.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:s.jsx(iB,{scope:n,placedSide:se,onArrowChange:O,arrowX:W,arrowY:ue,shouldHideArrow:G,children:s.jsx(ct.div,{"data-side":se,"data-align":J,...w,ref:C,style:{...w.style,animation:le?void 0:"none"}})})})});QC.displayName=G0;var XC="PopperArrow",oB={top:"bottom",right:"left",bottom:"top",left:"right"},ZC=b.forwardRef(function(e,n){const{__scopePopper:r,...i}=e,a=aB(XC,r),o=oB[a.placedSide];return s.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:s.jsx(rB,{...i,ref:n,style:{...i.style,display:"block"}})})});ZC.displayName=XC;function lB(t){return t!==null}var cB=t=>({name:"transformOrigin",options:t,fn(e){var N,k,E;const{placement:n,rects:r,middlewareData:i}=e,o=((N=i.arrow)==null?void 0:N.centerOffset)!==0,c=o?0:t.arrowWidth,u=o?0:t.arrowHeight,[h,f]=e4(n),m={start:"0%",center:"50%",end:"100%"}[f],g=(((k=i.arrow)==null?void 0:k.x)??0)+c/2,y=(((E=i.arrow)==null?void 0:E.y)??0)+u/2;let v="",w="";return h==="bottom"?(v=o?m:`${g}px`,w=`${-u}px`):h==="top"?(v=o?m:`${g}px`,w=`${r.floating.height+u}px`):h==="right"?(v=`${-u}px`,w=o?m:`${y}px`):h==="left"&&(v=`${r.floating.width+u}px`,w=o?m:`${y}px`),{data:{x:v,y:w}}}});function e4(t){const[e,n="center"]=t.split("-");return[e,n]}var dB=GC,uB=YC,hB=QC,fB=ZC,t4=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"}),pB="VisuallyHidden",mB=b.forwardRef((t,e)=>s.jsx(ct.span,{...t,ref:e,style:{...t4,...t.style}}));mB.displayName=pB;var gB=[" ","Enter","ArrowUp","ArrowDown"],xB=[" ","Enter"],jo="Select",[_f,zf,yB]=Ux(jo),[Vl]=ka(jo,[yB,KC]),$f=KC(),[vB,Ta]=Vl(jo),[bB,NB]=Vl(jo),n4=t=>{const{__scopeSelect:e,children:n,open:r,defaultOpen:i,onOpenChange:a,value:o,defaultValue:c,onValueChange:u,dir:h,name:f,autoComplete:m,disabled:g,required:y,form:v}=t,w=$f(e),[N,k]=b.useState(null),[E,C]=b.useState(null),[T,O]=b.useState(!1),F=ff(h),[I,R]=fo({prop:r,defaultProp:i??!1,onChange:a,caller:jo}),[P,L]=fo({prop:o,defaultProp:c,onChange:u,caller:jo}),ee=b.useRef(null),te=N?v||!!N.closest("form"):!0,[Y,U]=b.useState(new Set),D=Array.from(Y).map($=>$.props.value).join(";");return s.jsx(dB,{...w,children:s.jsxs(vB,{required:y,scope:e,trigger:N,onTriggerChange:k,valueNode:E,onValueNodeChange:C,valueNodeHasChildren:T,onValueNodeHasChildrenChange:O,contentId:ua(),value:P,onValueChange:L,open:I,onOpenChange:R,dir:F,triggerPointerDownPosRef:ee,disabled:g,children:[s.jsx(_f.Provider,{scope:e,children:s.jsx(bB,{scope:t.__scopeSelect,onNativeOptionAdd:b.useCallback($=>{U(le=>new Set(le).add($))},[]),onNativeOptionRemove:b.useCallback($=>{U(le=>{const _=new Set(le);return _.delete($),_})},[]),children:n})}),te?s.jsxs(k4,{"aria-hidden":!0,required:y,tabIndex:-1,name:f,autoComplete:m,value:P,onChange:$=>L($.target.value),disabled:g,form:v,children:[P===void 0?s.jsx("option",{value:""}):null,Array.from(Y)]},D):null]})})};n4.displayName=jo;var r4="SelectTrigger",s4=b.forwardRef((t,e)=>{const{__scopeSelect:n,disabled:r=!1,...i}=t,a=$f(n),o=Ta(r4,n),c=o.disabled||r,u=bt(e,o.onTriggerChange),h=zf(n),f=b.useRef("touch"),[m,g,y]=C4(w=>{const N=h().filter(C=>!C.disabled),k=N.find(C=>C.value===o.value),E=E4(N,w,k);E!==void 0&&o.onValueChange(E.value)}),v=w=>{c||(o.onOpenChange(!0),y()),w&&(o.triggerPointerDownPosRef.current={x:Math.round(w.pageX),y:Math.round(w.pageY)})};return s.jsx(uB,{asChild:!0,...a,children:s.jsx(ct.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":S4(o.value)?"":void 0,...i,ref:u,onClick:it(i.onClick,w=>{w.currentTarget.focus(),f.current!=="mouse"&&v(w)}),onPointerDown:it(i.onPointerDown,w=>{f.current=w.pointerType;const N=w.target;N.hasPointerCapture(w.pointerId)&&N.releasePointerCapture(w.pointerId),w.button===0&&w.ctrlKey===!1&&w.pointerType==="mouse"&&(v(w),w.preventDefault())}),onKeyDown:it(i.onKeyDown,w=>{const N=m.current!=="";!(w.ctrlKey||w.altKey||w.metaKey)&&w.key.length===1&&g(w.key),!(N&&w.key===" ")&&gB.includes(w.key)&&(v(),w.preventDefault())})})})});s4.displayName=r4;var i4="SelectValue",a4=b.forwardRef((t,e)=>{const{__scopeSelect:n,className:r,style:i,children:a,placeholder:o="",...c}=t,u=Ta(i4,n),{onValueNodeHasChildrenChange:h}=u,f=a!==void 0,m=bt(e,u.onValueNodeChange);return Kn(()=>{h(f)},[h,f]),s.jsx(ct.span,{...c,ref:m,style:{pointerEvents:"none"},children:S4(u.value)?s.jsx(s.Fragment,{children:o}):a})});a4.displayName=i4;var wB="SelectIcon",o4=b.forwardRef((t,e)=>{const{__scopeSelect:n,children:r,...i}=t;return s.jsx(ct.span,{"aria-hidden":!0,...i,ref:e,children:r||"▼"})});o4.displayName=wB;var jB="SelectPortal",l4=t=>s.jsx($x,{asChild:!0,...t});l4.displayName=jB;var ko="SelectContent",c4=b.forwardRef((t,e)=>{const n=Ta(ko,t.__scopeSelect),[r,i]=b.useState();if(Kn(()=>{i(new DocumentFragment)},[]),!n.open){const a=r;return a?dd.createPortal(s.jsx(d4,{scope:t.__scopeSelect,children:s.jsx(_f.Slot,{scope:t.__scopeSelect,children:s.jsx("div",{children:t.children})})}),a):null}return s.jsx(u4,{...t,ref:e})});c4.displayName=ko;var us=10,[d4,Ma]=Vl(ko),kB="SelectContentImpl",SB=Jc("SelectContent.RemoveScroll"),u4=b.forwardRef((t,e)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:i,onEscapeKeyDown:a,onPointerDownOutside:o,side:c,sideOffset:u,align:h,alignOffset:f,arrowPadding:m,collisionBoundary:g,collisionPadding:y,sticky:v,hideWhenDetached:w,avoidCollisions:N,...k}=t,E=Ta(ko,n),[C,T]=b.useState(null),[O,F]=b.useState(null),I=bt(e,ce=>T(ce)),[R,P]=b.useState(null),[L,ee]=b.useState(null),te=zf(n),[Y,U]=b.useState(!1),D=b.useRef(!1);b.useEffect(()=>{if(C)return Sj(C)},[C]),gj();const $=b.useCallback(ce=>{const[he,...we]=te().map(Me=>Me.ref.current),[V]=we.slice(-1),be=document.activeElement;for(const Me of ce)if(Me===be||(Me==null||Me.scrollIntoView({block:"nearest"}),Me===he&&O&&(O.scrollTop=0),Me===V&&O&&(O.scrollTop=O.scrollHeight),Me==null||Me.focus(),document.activeElement!==be))return},[te,O]),le=b.useCallback(()=>$([R,C]),[$,R,C]);b.useEffect(()=>{Y&&le()},[Y,le]);const{onOpenChange:_,triggerPointerDownPosRef:se}=E;b.useEffect(()=>{if(C){let ce={x:0,y:0};const he=V=>{var be,Me;ce={x:Math.abs(Math.round(V.pageX)-(((be=se.current)==null?void 0:be.x)??0)),y:Math.abs(Math.round(V.pageY)-(((Me=se.current)==null?void 0:Me.y)??0))}},we=V=>{ce.x<=10&&ce.y<=10?V.preventDefault():C.contains(V.target)||_(!1),document.removeEventListener("pointermove",he),se.current=null};return se.current!==null&&(document.addEventListener("pointermove",he),document.addEventListener("pointerup",we,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",he),document.removeEventListener("pointerup",we,{capture:!0})}}},[C,_,se]),b.useEffect(()=>{const ce=()=>_(!1);return window.addEventListener("blur",ce),window.addEventListener("resize",ce),()=>{window.removeEventListener("blur",ce),window.removeEventListener("resize",ce)}},[_]);const[J,z]=C4(ce=>{const he=te().filter(be=>!be.disabled),we=he.find(be=>be.ref.current===document.activeElement),V=E4(he,ce,we);V&&setTimeout(()=>V.ref.current.focus())}),W=b.useCallback((ce,he,we)=>{const V=!D.current&&!we;(E.value!==void 0&&E.value===he||V)&&(P(ce),V&&(D.current=!0))},[E.value]),ue=b.useCallback(()=>C==null?void 0:C.focus(),[C]),G=b.useCallback((ce,he,we)=>{const V=!D.current&&!we;(E.value!==void 0&&E.value===he||V)&&ee(ce)},[E.value]),fe=r==="popper"?wx:h4,X=fe===wx?{side:c,sideOffset:u,align:h,alignOffset:f,arrowPadding:m,collisionBoundary:g,collisionPadding:y,sticky:v,hideWhenDetached:w,avoidCollisions:N}:{};return s.jsx(d4,{scope:n,content:C,viewport:O,onViewportChange:F,itemRefCallback:W,selectedItem:R,onItemLeave:ue,itemTextRefCallback:G,focusSelectedItem:le,selectedItemText:L,position:r,isPositioned:Y,searchRef:J,children:s.jsx(Fx,{as:SB,allowPinchZoom:!0,children:s.jsx(zx,{asChild:!0,trapped:E.open,onMountAutoFocus:ce=>{ce.preventDefault()},onUnmountAutoFocus:it(i,ce=>{var he;(he=E.trigger)==null||he.focus({preventScroll:!0}),ce.preventDefault()}),children:s.jsx(_x,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:ce=>ce.preventDefault(),onDismiss:()=>E.onOpenChange(!1),children:s.jsx(fe,{role:"listbox",id:E.contentId,"data-state":E.open?"open":"closed",dir:E.dir,onContextMenu:ce=>ce.preventDefault(),...k,...X,onPlaced:()=>U(!0),ref:I,style:{display:"flex",flexDirection:"column",outline:"none",...k.style},onKeyDown:it(k.onKeyDown,ce=>{const he=ce.ctrlKey||ce.altKey||ce.metaKey;if(ce.key==="Tab"&&ce.preventDefault(),!he&&ce.key.length===1&&z(ce.key),["ArrowUp","ArrowDown","Home","End"].includes(ce.key)){let V=te().filter(be=>!be.disabled).map(be=>be.ref.current);if(["ArrowUp","End"].includes(ce.key)&&(V=V.slice().reverse()),["ArrowUp","ArrowDown"].includes(ce.key)){const be=ce.target,Me=V.indexOf(be);V=V.slice(Me+1)}setTimeout(()=>$(V)),ce.preventDefault()}})})})})})})});u4.displayName=kB;var CB="SelectItemAlignedPosition",h4=b.forwardRef((t,e)=>{const{__scopeSelect:n,onPlaced:r,...i}=t,a=Ta(ko,n),o=Ma(ko,n),[c,u]=b.useState(null),[h,f]=b.useState(null),m=bt(e,I=>f(I)),g=zf(n),y=b.useRef(!1),v=b.useRef(!0),{viewport:w,selectedItem:N,selectedItemText:k,focusSelectedItem:E}=o,C=b.useCallback(()=>{if(a.trigger&&a.valueNode&&c&&h&&w&&N&&k){const I=a.trigger.getBoundingClientRect(),R=h.getBoundingClientRect(),P=a.valueNode.getBoundingClientRect(),L=k.getBoundingClientRect();if(a.dir!=="rtl"){const be=L.left-R.left,Me=P.left-be,st=I.left-Me,nt=I.width+st,dt=Math.max(nt,R.width),Ye=window.innerWidth-us,ht=uh(Me,[us,Math.max(us,Ye-dt)]);c.style.minWidth=nt+"px",c.style.left=ht+"px"}else{const be=R.right-L.right,Me=window.innerWidth-P.right-be,st=window.innerWidth-I.right-Me,nt=I.width+st,dt=Math.max(nt,R.width),Ye=window.innerWidth-us,ht=uh(Me,[us,Math.max(us,Ye-dt)]);c.style.minWidth=nt+"px",c.style.right=ht+"px"}const ee=g(),te=window.innerHeight-us*2,Y=w.scrollHeight,U=window.getComputedStyle(h),D=parseInt(U.borderTopWidth,10),$=parseInt(U.paddingTop,10),le=parseInt(U.borderBottomWidth,10),_=parseInt(U.paddingBottom,10),se=D+$+Y+_+le,J=Math.min(N.offsetHeight*5,se),z=window.getComputedStyle(w),W=parseInt(z.paddingTop,10),ue=parseInt(z.paddingBottom,10),G=I.top+I.height/2-us,fe=te-G,X=N.offsetHeight/2,ce=N.offsetTop+X,he=D+$+ce,we=se-he;if(he<=G){const be=ee.length>0&&N===ee[ee.length-1].ref.current;c.style.bottom="0px";const Me=h.clientHeight-w.offsetTop-w.offsetHeight,st=Math.max(fe,X+(be?ue:0)+Me+le),nt=he+st;c.style.height=nt+"px"}else{const be=ee.length>0&&N===ee[0].ref.current;c.style.top="0px";const st=Math.max(G,D+w.offsetTop+(be?W:0)+X)+we;c.style.height=st+"px",w.scrollTop=he-G+w.offsetTop}c.style.margin=`${us}px 0`,c.style.minHeight=J+"px",c.style.maxHeight=te+"px",r==null||r(),requestAnimationFrame(()=>y.current=!0)}},[g,a.trigger,a.valueNode,c,h,w,N,k,a.dir,r]);Kn(()=>C(),[C]);const[T,O]=b.useState();Kn(()=>{h&&O(window.getComputedStyle(h).zIndex)},[h]);const F=b.useCallback(I=>{I&&v.current===!0&&(C(),E==null||E(),v.current=!1)},[C,E]);return s.jsx(TB,{scope:n,contentWrapper:c,shouldExpandOnScrollRef:y,onScrollButtonChange:F,children:s.jsx("div",{ref:u,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:T},children:s.jsx(ct.div,{...i,ref:m,style:{boxSizing:"border-box",maxHeight:"100%",...i.style}})})})});h4.displayName=CB;var EB="SelectPopperPosition",wx=b.forwardRef((t,e)=>{const{__scopeSelect:n,align:r="start",collisionPadding:i=us,...a}=t,o=$f(n);return s.jsx(hB,{...o,...a,ref:e,align:r,collisionPadding:i,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)"}})});wx.displayName=EB;var[TB,J0]=Vl(ko,{}),jx="SelectViewport",f4=b.forwardRef((t,e)=>{const{__scopeSelect:n,nonce:r,...i}=t,a=Ma(jx,n),o=J0(jx,n),c=bt(e,a.onViewportChange),u=b.useRef(0);return s.jsxs(s.Fragment,{children:[s.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}),s.jsx(_f.Slot,{scope:n,children:s.jsx(ct.div,{"data-radix-select-viewport":"",role:"presentation",...i,ref:c,style:{position:"relative",flex:1,overflow:"hidden auto",...i.style},onScroll:it(i.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-us*2,w=parseFloat(m.style.minHeight),N=parseFloat(m.style.height),k=Math.max(w,N);if(k0?T:0,m.style.justifyContent="flex-end")}}}u.current=f.scrollTop})})})]})});f4.displayName=jx;var p4="SelectGroup",[MB,AB]=Vl(p4),IB=b.forwardRef((t,e)=>{const{__scopeSelect:n,...r}=t,i=ua();return s.jsx(MB,{scope:n,id:i,children:s.jsx(ct.div,{role:"group","aria-labelledby":i,...r,ref:e})})});IB.displayName=p4;var m4="SelectLabel",RB=b.forwardRef((t,e)=>{const{__scopeSelect:n,...r}=t,i=AB(m4,n);return s.jsx(ct.div,{id:i.id,...r,ref:e})});RB.displayName=m4;var af="SelectItem",[PB,g4]=Vl(af),x4=b.forwardRef((t,e)=>{const{__scopeSelect:n,value:r,disabled:i=!1,textValue:a,...o}=t,c=Ta(af,n),u=Ma(af,n),h=c.value===r,[f,m]=b.useState(a??""),[g,y]=b.useState(!1),v=bt(e,E=>{var C;return(C=u.itemRefCallback)==null?void 0:C.call(u,E,r,i)}),w=ua(),N=b.useRef("touch"),k=()=>{i||(c.onValueChange(r),c.onOpenChange(!1))};if(r==="")throw new Error("A 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 s.jsx(PB,{scope:n,value:r,disabled:i,textId:w,isSelected:h,onItemTextChange:b.useCallback(E=>{m(C=>C||((E==null?void 0:E.textContent)??"").trim())},[]),children:s.jsx(_f.ItemSlot,{scope:n,value:r,disabled:i,textValue:f,children:s.jsx(ct.div,{role:"option","aria-labelledby":w,"data-highlighted":g?"":void 0,"aria-selected":h&&g,"data-state":h?"checked":"unchecked","aria-disabled":i||void 0,"data-disabled":i?"":void 0,tabIndex:i?void 0:-1,...o,ref:v,onFocus:it(o.onFocus,()=>y(!0)),onBlur:it(o.onBlur,()=>y(!1)),onClick:it(o.onClick,()=>{N.current!=="mouse"&&k()}),onPointerUp:it(o.onPointerUp,()=>{N.current==="mouse"&&k()}),onPointerDown:it(o.onPointerDown,E=>{N.current=E.pointerType}),onPointerMove:it(o.onPointerMove,E=>{var C;N.current=E.pointerType,i?(C=u.onItemLeave)==null||C.call(u):N.current==="mouse"&&E.currentTarget.focus({preventScroll:!0})}),onPointerLeave:it(o.onPointerLeave,E=>{var C;E.currentTarget===document.activeElement&&((C=u.onItemLeave)==null||C.call(u))}),onKeyDown:it(o.onKeyDown,E=>{var T;((T=u.searchRef)==null?void 0:T.current)!==""&&E.key===" "||(xB.includes(E.key)&&k(),E.key===" "&&E.preventDefault())})})})})});x4.displayName=af;var Rc="SelectItemText",y4=b.forwardRef((t,e)=>{const{__scopeSelect:n,className:r,style:i,...a}=t,o=Ta(Rc,n),c=Ma(Rc,n),u=g4(Rc,n),h=NB(Rc,n),[f,m]=b.useState(null),g=bt(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(()=>s.jsx("option",{value:u.value,disabled:u.disabled,children:y},u.value),[u.disabled,u.value,y]),{onNativeOptionAdd:w,onNativeOptionRemove:N}=h;return Kn(()=>(w(v),()=>N(v)),[w,N,v]),s.jsxs(s.Fragment,{children:[s.jsx(ct.span,{id:u.textId,...a,ref:g}),u.isSelected&&o.valueNode&&!o.valueNodeHasChildren?dd.createPortal(a.children,o.valueNode):null]})});y4.displayName=Rc;var v4="SelectItemIndicator",b4=b.forwardRef((t,e)=>{const{__scopeSelect:n,...r}=t;return g4(v4,n).isSelected?s.jsx(ct.span,{"aria-hidden":!0,...r,ref:e}):null});b4.displayName=v4;var kx="SelectScrollUpButton",N4=b.forwardRef((t,e)=>{const n=Ma(kx,t.__scopeSelect),r=J0(kx,t.__scopeSelect),[i,a]=b.useState(!1),o=bt(e,r.onScrollButtonChange);return Kn(()=>{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]),i?s.jsx(j4,{...t,ref:o,onAutoScroll:()=>{const{viewport:c,selectedItem:u}=n;c&&u&&(c.scrollTop=c.scrollTop-u.offsetHeight)}}):null});N4.displayName=kx;var Sx="SelectScrollDownButton",w4=b.forwardRef((t,e)=>{const n=Ma(Sx,t.__scopeSelect),r=J0(Sx,t.__scopeSelect),[i,a]=b.useState(!1),o=bt(e,r.onScrollButtonChange);return Kn(()=>{if(n.viewport&&n.isPositioned){let c=function(){const h=u.scrollHeight-u.clientHeight,f=Math.ceil(u.scrollTop)u.removeEventListener("scroll",c)}},[n.viewport,n.isPositioned]),i?s.jsx(j4,{...t,ref:o,onAutoScroll:()=>{const{viewport:c,selectedItem:u}=n;c&&u&&(c.scrollTop=c.scrollTop+u.offsetHeight)}}):null});w4.displayName=Sx;var j4=b.forwardRef((t,e)=>{const{__scopeSelect:n,onAutoScroll:r,...i}=t,a=Ma("SelectScrollButton",n),o=b.useRef(null),c=zf(n),u=b.useCallback(()=>{o.current!==null&&(window.clearInterval(o.current),o.current=null)},[]);return b.useEffect(()=>()=>u(),[u]),Kn(()=>{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]),s.jsx(ct.div,{"aria-hidden":!0,...i,ref:e,style:{flexShrink:0,...i.style},onPointerDown:it(i.onPointerDown,()=>{o.current===null&&(o.current=window.setInterval(r,50))}),onPointerMove:it(i.onPointerMove,()=>{var h;(h=a.onItemLeave)==null||h.call(a),o.current===null&&(o.current=window.setInterval(r,50))}),onPointerLeave:it(i.onPointerLeave,()=>{u()})})}),OB="SelectSeparator",DB=b.forwardRef((t,e)=>{const{__scopeSelect:n,...r}=t;return s.jsx(ct.div,{"aria-hidden":!0,...r,ref:e})});DB.displayName=OB;var Cx="SelectArrow",LB=b.forwardRef((t,e)=>{const{__scopeSelect:n,...r}=t,i=$f(n),a=Ta(Cx,n),o=Ma(Cx,n);return a.open&&o.position==="popper"?s.jsx(fB,{...i,...r,ref:e}):null});LB.displayName=Cx;var _B="SelectBubbleInput",k4=b.forwardRef(({__scopeSelect:t,value:e,...n},r)=>{const i=b.useRef(null),a=bt(r,i),o=qx(e);return b.useEffect(()=>{const c=i.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]),s.jsx(ct.select,{...n,style:{...t4,...n.style},ref:a,defaultValue:e})});k4.displayName=_B;function S4(t){return t===""||t===void 0}function C4(t){const e=ga(t),n=b.useRef(""),r=b.useRef(0),i=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,i,a]}function E4(t,e,n){const i=e.length>1&&Array.from(e).every(h=>h===e[0])?e[0]:e,a=n?t.indexOf(n):-1;let o=zB(t,Math.max(a,0));i.length===1&&(o=o.filter(h=>h!==n));const u=o.find(h=>h.textValue.toLowerCase().startsWith(i.toLowerCase()));return u!==n?u:void 0}function zB(t,e){return t.map((n,r)=>t[(e+r)%t.length])}var $B=n4,T4=s4,FB=a4,BB=o4,VB=l4,M4=c4,HB=f4,A4=x4,WB=y4,UB=b4,KB=N4,qB=w4;const ul=$B,hl=FB,Xa=b.forwardRef(({className:t,children:e,...n},r)=>s.jsxs(T4,{ref:r,className:Nt("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,s.jsx(BB,{asChild:!0,children:s.jsx(Gc,{className:"h-4 w-4 opacity-50"})})]}));Xa.displayName=T4.displayName;const Za=b.forwardRef(({className:t,children:e,position:n="popper",...r},i)=>s.jsx(VB,{children:s.jsxs(M4,{ref:i,className:Nt("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:[s.jsx(KB,{className:"flex cursor-default items-center justify-center py-1",children:s.jsx(Fw,{className:"h-4 w-4"})}),s.jsx(HB,{className:"p-1",children:e}),s.jsx(qB,{className:"flex cursor-default items-center justify-center py-1",children:s.jsx(Gc,{className:"h-4 w-4"})})]})}));Za.displayName=M4.displayName;const Er=b.forwardRef(({className:t,children:e,...n},r)=>s.jsxs(A4,{ref:r,className:Nt("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:[s.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:s.jsx(UB,{children:s.jsx(cf,{className:"h-4 w-4"})})}),s.jsx(WB,{children:e})]}));Er.displayName=A4.displayName;function GB(){const[t,e]=b.useState([]),[n,r]=b.useState(!0),[i,a]=b.useState(!1),[o,c]=b.useState(null),[u,h]=b.useState({name:"",appId:"",path:"",sort:0}),[f,m]=b.useState(!1);async function g(){r(!0);try{const k=await Le("/api/admin/linked-miniprograms");if(k!=null&&k.success&&Array.isArray(k.data)){const E=[...k.data].sort((C,T)=>(C.sort??0)-(T.sort??0));e(E)}}catch(k){console.error("Load linked miniprograms error:",k),oe.error("加载失败")}finally{r(!1)}}b.useEffect(()=>{g()},[]);function y(){c(null),h({name:"",appId:"",path:"",sort:t.length}),a(!0)}function v(k){c(k),h({name:k.name,appId:k.appId,path:k.path??"",sort:k.sort??0}),a(!0)}async function w(){const k=u.name.trim(),E=u.appId.trim();if(!k||!E){oe.error("请填写小程序名称和 AppID");return}m(!0);try{if(o){const C=await St("/api/admin/linked-miniprograms",{key:o.key,name:k,appId:E,path:u.path.trim(),sort:u.sort});C!=null&&C.success?(oe.success("已更新"),a(!1),g()):oe.error((C==null?void 0:C.error)??"更新失败")}else{const C=await xt("/api/admin/linked-miniprograms",{name:k,appId:E,path:u.path.trim(),sort:u.sort});C!=null&&C.success?(oe.success("已添加"),a(!1),g()):oe.error((C==null?void 0:C.error)??"添加失败")}}catch{oe.error("操作失败")}finally{m(!1)}}async function N(k){if(confirm(`确定要删除「${k.name}」吗?`))try{const E=await Ps(`/api/admin/linked-miniprograms/${k.key}`);E!=null&&E.success?(oe.success("已删除"),g()):oe.error((E==null?void 0:E.error)??"删除失败")}catch{oe.error("删除失败")}}return s.jsxs("div",{className:"space-y-6",children:[s.jsxs(Ae,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(et,{children:[s.jsxs(tt,{className:"text-white flex items-center gap-2",children:[s.jsx(uo,{className:"w-5 h-5 text-[#38bdac]"}),"关联小程序管理"]}),s.jsx(Pt,{className:"text-gray-400",children:"添加后生成 32 位密钥,链接标签选择小程序时存密钥;小程序端点击 #标签 时用密钥查 appId 再跳转。需在 app.json 的 navigateToMiniProgramAppIdList 中配置目标 AppID。"})]}),s.jsxs(Ie,{children:[s.jsx("div",{className:"flex justify-end mb-4",children:s.jsxs(ne,{onClick:y,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(rn,{className:"w-4 h-4 mr-2"}),"添加关联小程序"]})}),n?s.jsx("div",{className:"py-12 text-center text-gray-400",children:"加载中..."}):s.jsxs(qn,{children:[s.jsx(Gn,{children:s.jsxs(rt,{className:"bg-[#0a1628] border-gray-700",children:[s.jsx(ke,{className:"text-gray-400",children:"名称"}),s.jsx(ke,{className:"text-gray-400",children:"密钥"}),s.jsx(ke,{className:"text-gray-400",children:"AppID"}),s.jsx(ke,{className:"text-gray-400",children:"路径"}),s.jsx(ke,{className:"text-gray-400 w-24",children:"排序"}),s.jsx(ke,{className:"text-gray-400 w-32",children:"操作"})]})}),s.jsxs(Jn,{children:[t.map(k=>s.jsxs(rt,{className:"border-gray-700/50",children:[s.jsx(xe,{className:"text-white",children:k.name}),s.jsx(xe,{className:"text-gray-300 font-mono text-xs",children:k.key}),s.jsx(xe,{className:"text-gray-300 font-mono text-sm",children:k.appId}),s.jsx(xe,{className:"text-gray-400 text-sm",children:k.path||"—"}),s.jsx(xe,{className:"text-gray-300",children:k.sort??0}),s.jsx(xe,{children:s.jsxs("div",{className:"flex gap-2",children:[s.jsx(ne,{variant:"ghost",size:"sm",className:"text-[#38bdac] hover:bg-[#38bdac]/20",onClick:()=>v(k),children:s.jsx(qw,{className:"w-4 h-4"})}),s.jsx(ne,{variant:"ghost",size:"sm",className:"text-red-400 hover:bg-red-500/20",onClick:()=>N(k),children:s.jsx(Dn,{className:"w-4 h-4"})})]})})]},k.key)),t.length===0&&s.jsx(rt,{children:s.jsx(xe,{colSpan:6,className:"text-center py-12 text-gray-500",children:"暂无关联小程序,点击「添加关联小程序」开始配置"})})]})]})]})]}),s.jsx(Kt,{open:i,onOpenChange:a,children:s.jsxs(Vt,{className:"bg-[#0f2137] border-gray-700 text-white",children:[s.jsxs(qt,{children:[s.jsx(Gt,{children:o?"编辑关联小程序":"添加关联小程序"}),s.jsx(Wx,{className:"text-gray-400",children:"填写目标小程序的名称和 AppID,路径可选(为空则打开首页)"})]}),s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"小程序名称"}),s.jsx(ae,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"例如:Soul 创业派对",value:u.name,onChange:k=>h(E=>({...E,name:k.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"AppID"}),s.jsx(ae,{className:"bg-[#0a1628] border-gray-700 text-white font-mono",placeholder:"例如:wxb8bbb2b10dec74aa",value:u.appId,onChange:k=>h(E=>({...E,appId:k.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"路径(可选)"}),s.jsx(ae,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"例如:pages/index/index",value:u.path,onChange:k=>h(E=>({...E,path:k.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"排序"}),s.jsx(ae,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:u.sort,onChange:k=>h(E=>({...E,sort:parseInt(k.target.value,10)||0}))})]})]}),s.jsxs(hn,{children:[s.jsx(ne,{variant:"outline",onClick:()=>a(!1),className:"border-gray-600",children:"取消"}),s.jsx(ne,{onClick:w,disabled:f,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:f?"保存中...":"保存"})]})]})})]})}const JB=["一","二","三","四","五","六","七","八","九","十"];function pg(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 YB({parts:t,expandedParts:e,onTogglePart:n,onReorder:r,onReadSection:i,onDeleteSection:a,onAddSectionInPart:o,onAddChapterInPart:c,onDeleteChapter:u,onEditPart:h,onDeletePart:f,onEditChapter:m,selectedSectionIds:g=[],onToggleSectionSelect:y,onShowSectionOrders:v,pinnedSectionIds:w=[]}){const[N,k]=b.useState(null),[E,C]=b.useState(null),T=(L,ee)=>(N==null?void 0:N.type)===L&&(N==null?void 0:N.id)===ee,O=(L,ee)=>(E==null?void 0:E.type)===L&&(E==null?void 0:E.id)===ee,F=b.useCallback(()=>{const L=[];for(const ee of t)for(const te of ee.chapters)for(const Y of te.sections)L.push({id:Y.id,partId:ee.id,partTitle:ee.title,chapterId:te.id,chapterTitle:te.title});return L},[t]),I=b.useCallback(async(L,ee,te,Y)=>{var _;L.preventDefault(),L.stopPropagation();const U=L.dataTransfer.getData("text/plain"),D=pg(U);if(!D||D.type===ee&&D.id===te)return;const $=F(),le=new Map($.map(se=>[se.id,se]));if(D.type==="part"&&ee==="part"){const se=t.map(G=>G.id),J=se.indexOf(D.id),z=se.indexOf(te);if(J===-1||z===-1)return;const W=[...se];W.splice(J,1),W.splice(JX.id===G);if(fe)for(const X of fe.chapters)for(const ce of X.sections){const he=le.get(ce.id);he&&ue.push(he)}}await r(ue);return}if(D.type==="chapter"&&(ee==="chapter"||ee==="section"||ee==="part")){const se=t.find(he=>he.chapters.some(we=>we.id===D.id)),J=se==null?void 0:se.chapters.find(he=>he.id===D.id);if(!se||!J)return;let z,W,ue=null;if(ee==="section"){const he=le.get(te);if(!he)return;z=he.partId,W=he.partTitle,ue=te}else if(ee==="chapter"){const he=t.find(be=>be.chapters.some(Me=>Me.id===te)),we=he==null?void 0:he.chapters.find(be=>be.id===te);if(!he||!we)return;z=he.id,W=he.title;const V=$.filter(be=>be.chapterId===te).pop();ue=(V==null?void 0:V.id)??null}else{const he=t.find(V=>V.id===te);if(!he||!he.chapters[0])return;z=he.id,W=he.title;const we=$.filter(V=>V.partId===he.id&&V.chapterId===he.chapters[0].id);ue=((_=we[we.length-1])==null?void 0:_.id)??null}const G=J.sections.map(he=>he.id),fe=$.filter(he=>!G.includes(he.id));let X=fe.length;if(ue){const he=fe.findIndex(we=>we.id===ue);he>=0&&(X=he+1)}const ce=G.map(he=>({...le.get(he),partId:z,partTitle:W,chapterId:J.id,chapterTitle:J.title}));await r([...fe.slice(0,X),...ce,...fe.slice(X)]);return}if(D.type==="section"&&(ee==="section"||ee==="chapter"||ee==="part")){if(!Y)return;const{partId:se,partTitle:J,chapterId:z,chapterTitle:W}=Y;let ue;if(ee==="section")ue=$.findIndex(we=>we.id===te);else if(ee==="chapter"){const we=$.filter(V=>V.chapterId===te).pop();ue=we?$.findIndex(V=>V.id===we.id)+1:$.length}else{const we=t.find(Me=>Me.id===te);if(!(we!=null&&we.chapters[0]))return;const V=$.filter(Me=>Me.partId===we.id&&Me.chapterId===we.chapters[0].id),be=V[V.length-1];ue=be?$.findIndex(Me=>Me.id===be.id)+1:0}const G=$.findIndex(we=>we.id===D.id);if(G===-1)return;const fe=$.filter(we=>we.id!==D.id),X=G({onDragEnter:Y=>{Y.preventDefault(),Y.stopPropagation(),Y.dataTransfer.dropEffect="move",C({type:L,id:ee})},onDragOver:Y=>{Y.preventDefault(),Y.stopPropagation(),Y.dataTransfer.dropEffect="move",C({type:L,id:ee})},onDragLeave:()=>C(null),onDrop:Y=>{C(null);const U=pg(Y.dataTransfer.getData("text/plain"));if(U&&!(L==="section"&&U.type==="section"&&U.id===ee))if(L==="part")if(U.type==="part")I(Y,"part",ee);else{const D=t.find(le=>le.id===ee);(D==null?void 0:D.chapters[0])&&te&&I(Y,"part",ee,te)}else L==="chapter"&&te?(U.type==="section"||U.type==="chapter")&&I(Y,"chapter",ee,te):L==="section"&&te&&I(Y,"section",ee,te)}}),P=L=>JB[L]??String(L+1);return s.jsx("div",{className:"space-y-3",children:t.map((L,ee)=>{var J,z,W,ue;const te=L.title==="序言"||L.title.includes("序言"),Y=L.title==="尾声"||L.title.includes("尾声"),U=L.title==="附录"||L.title.includes("附录"),D=O("part",L.id),$=e.includes(L.id),le=L.chapters.length,_=L.chapters.reduce((G,fe)=>G+fe.sections.length,0);if(te&&L.chapters.length===1&&L.chapters[0].sections.length===1){const G=L.chapters[0].sections[0],fe=O("section",G.id),X={partId:L.id,partTitle:L.title,chapterId:L.chapters[0].id,chapterTitle:L.chapters[0].title};return s.jsxs("div",{draggable:!0,onDragStart:ce=>{ce.stopPropagation(),ce.dataTransfer.setData("text/plain","section:"+G.id),ce.dataTransfer.effectAllowed="move",k({type:"section",id:G.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] ${fe?"bg-[#38bdac]/15 ring-2 ring-[#38bdac]/50":""} ${T("section",G.id)?"opacity-60 scale-[0.98] ring-2 ring-[#38bdac]":""}`,...R("section",G.id,X),children:[s.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0 select-none",children:[s.jsx(oi,{className:"w-5 h-5 text-gray-500 shrink-0 opacity-60"}),y&&s.jsx("label",{className:"shrink-0 flex items-center",onClick:ce=>ce.stopPropagation(),children:s.jsx("input",{type:"checkbox",checked:g.includes(G.id),onChange:()=>y(G.id),className:"w-4 h-4 rounded border-gray-600 bg-[#0a1628] text-[#38bdac] focus:ring-[#38bdac]"})}),s.jsx("div",{className:"w-8 h-8 rounded-lg bg-gray-600/50 flex items-center justify-center shrink-0",children:s.jsx(Gr,{className:"w-4 h-4 text-gray-400"})}),s.jsxs("span",{className:"font-medium text-gray-200 truncate",children:[L.chapters[0].title," | ",G.title]}),w.includes(G.id)&&s.jsx("span",{title:"已置顶",children:s.jsx(ml,{className:"w-3.5 h-3.5 text-amber-400 fill-amber-400 shrink-0"})})]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",onMouseDown:ce=>ce.stopPropagation(),onClick:ce=>ce.stopPropagation(),children:[G.price===0||G.isFree?s.jsx("span",{className:"px-2 py-1 bg-[#38bdac]/20 text-[#38bdac] text-[10px] font-medium rounded",children:"免费"}):s.jsxs("span",{className:"text-xs text-gray-500",children:["¥",G.price]}),s.jsxs("span",{className:"text-[10px] text-gray-500",children:["点击 ",G.clickCount??0," · 付款 ",G.payCount??0]}),s.jsxs("span",{className:"text-[10px] text-amber-400/90",title:"热度积分与排名",children:["热度 ",(G.hotScore??0).toFixed(1)," · 第",G.hotRank&&G.hotRank>0?G.hotRank:"-","名"]}),v&&s.jsx(ne,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>v(G),className:"text-[10px] text-gray-500 hover:text-[#38bdac] h-7 px-1.5",children:"付款记录"}),s.jsxs("div",{className:"flex gap-1",children:[s.jsx(ne,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>i(G),className:"text-gray-500 hover:text-[#38bdac] h-7 px-2",title:"编辑",children:s.jsx(Rt,{className:"w-3.5 h-3.5"})}),s.jsx(ne,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>a(G),className:"text-gray-500 hover:text-red-400 h-7 px-2",children:s.jsx(Dn,{className:"w-3.5 h-3.5"})})]})]})]},L.id)}if(L.title==="2026每日派对干货"||L.title.includes("2026每日派对干货")){const G=O("part",L.id);return s.jsxs("div",{className:`rounded-xl border overflow-hidden transition-all duration-200 ${G?"border-[#38bdac] ring-2 ring-[#38bdac]/40 bg-[#38bdac]/5":"border-gray-700/50 bg-[#1C1C1E]"}`,...R("part",L.id,{partId:L.id,partTitle:L.title,chapterId:((J=L.chapters[0])==null?void 0:J.id)??"",chapterTitle:((z=L.chapters[0])==null?void 0:z.title)??""}),children:[s.jsxs("div",{draggable:!0,onDragStart:fe=>{fe.stopPropagation(),fe.dataTransfer.setData("text/plain","part:"+L.id),fe.dataTransfer.effectAllowed="move",k({type:"part",id:L.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 ${T("part",L.id)?"opacity-60 scale-[0.98] ring-2 ring-[#38bdac]":"hover:bg-[#162840]/50"}`,onClick:()=>n(L.id),children:[s.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[s.jsx(oi,{className:"w-5 h-5 text-gray-500 shrink-0 opacity-60"}),s.jsx("div",{className:"w-10 h-10 rounded-xl bg-[#38bdac]/80 flex items-center justify-center text-white font-bold shrink-0",children:"派"}),s.jsxs("div",{children:[s.jsx("h3",{className:"font-bold text-white text-base",children:L.title}),s.jsxs("p",{className:"text-xs text-gray-500 mt-0.5",children:["共 ",_," 节"]})]})]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",onMouseDown:fe=>fe.stopPropagation(),onClick:fe=>fe.stopPropagation(),children:[o&&s.jsx(ne,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>o(L),className:"text-gray-500 hover:text-[#38bdac] h-7 px-2",title:"在本篇下新增章节",children:s.jsx(rn,{className:"w-3.5 h-3.5"})}),h&&s.jsx(ne,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>h(L),className:"text-gray-500 hover:text-[#38bdac] h-7 px-2",title:"编辑篇名",children:s.jsx(Rt,{className:"w-3.5 h-3.5"})}),f&&s.jsx(ne,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>f(L),className:"text-gray-500 hover:text-red-400 h-7 px-2",title:"删除本篇",children:s.jsx(Dn,{className:"w-3.5 h-3.5"})}),s.jsxs("span",{className:"text-xs text-gray-500",children:[le,"章"]}),$?s.jsx(Gc,{className:"w-5 h-5 text-gray-500"}):s.jsx(fl,{className:"w-5 h-5 text-gray-500"})]})]}),$&&L.chapters.length>0&&s.jsx("div",{className:"border-t border-gray-700/50 pl-4 pr-4 pb-4 pt-3 space-y-4",children:L.chapters.map(fe=>s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center gap-2 w-full",children:[s.jsx("p",{className:"text-xs text-gray-500 pb-1 flex-1",children:fe.title}),s.jsxs("div",{className:"flex gap-0.5 shrink-0",onClick:X=>X.stopPropagation(),children:[m&&s.jsx(ne,{variant:"ghost",size:"sm",onClick:()=>m(L,fe),className:"text-gray-500 hover:text-[#38bdac] h-7 px-1.5",title:"编辑章节名称",children:s.jsx(Rt,{className:"w-3.5 h-3.5"})}),c&&s.jsx(ne,{variant:"ghost",size:"sm",onClick:()=>c(L),className:"text-gray-500 hover:text-[#38bdac] h-7 px-1.5",title:"新增第X章",children:s.jsx(rn,{className:"w-3.5 h-3.5"})}),u&&s.jsx(ne,{variant:"ghost",size:"sm",onClick:()=>u(L,fe),className:"text-gray-500 hover:text-red-400 h-7 px-1.5",title:"删除本章",children:s.jsx(Dn,{className:"w-3.5 h-3.5"})})]})]}),s.jsx("div",{className:"space-y-1 pl-2",children:fe.sections.map(X=>{const ce=O("section",X.id);return s.jsxs("div",{draggable:!0,onDragStart:he=>{he.stopPropagation(),he.dataTransfer.setData("text/plain","section:"+X.id),he.dataTransfer.effectAllowed="move",k({type:"section",id:X.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 ${ce?"bg-[#38bdac]/15 ring-2 ring-[#38bdac]/50":"hover:bg-[#162840]/50"} ${T("section",X.id)?"opacity-60 scale-[0.98] ring-2 ring-[#38bdac]":""}`,...R("section",X.id,{partId:L.id,partTitle:L.title,chapterId:fe.id,chapterTitle:fe.title}),children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[s.jsx(oi,{className:"w-4 h-4 text-gray-500 shrink-0 opacity-50"}),y&&s.jsx("label",{className:"shrink-0 flex items-center",onClick:he=>he.stopPropagation(),children:s.jsx("input",{type:"checkbox",checked:g.includes(X.id),onChange:()=>y(X.id),className:"w-4 h-4 rounded border-gray-600 bg-[#0a1628] text-[#38bdac] focus:ring-[#38bdac]"})}),s.jsxs("span",{className:"text-sm text-gray-200 truncate",children:[X.id," ",X.title]}),w.includes(X.id)&&s.jsx("span",{title:"已置顶",children:s.jsx(ml,{className:"w-3 h-3 text-amber-400 fill-amber-400 shrink-0"})})]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[s.jsxs("span",{className:"text-[10px] text-gray-500",children:["点击 ",X.clickCount??0," · 付款 ",X.payCount??0]}),s.jsxs("span",{className:"text-[10px] text-amber-400/90",title:"热度积分与排名",children:["热度 ",(X.hotScore??0).toFixed(1)," · 第",X.hotRank&&X.hotRank>0?X.hotRank:"-","名"]}),v&&s.jsx(ne,{variant:"ghost",size:"sm",onClick:()=>v(X),className:"text-[10px] text-gray-500 hover:text-[#38bdac] h-7 px-1.5",children:"付款记录"}),s.jsx(ne,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>i(X),className:"text-gray-500 hover:text-[#38bdac] h-7 px-1.5",title:"编辑",children:s.jsx(Rt,{className:"w-3.5 h-3.5"})}),s.jsx(ne,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>a(X),className:"text-gray-500 hover:text-red-400 h-7 px-1.5",children:s.jsx(Dn,{className:"w-3.5 h-3.5"})})]})]},X.id)})})]},fe.id))})]},L.id)}if(U)return s.jsxs("div",{className:"rounded-xl border border-gray-700/50 bg-[#1C1C1E] p-5",children:[s.jsx("h3",{className:"text-sm font-medium text-gray-400 mb-4",children:"附录"}),s.jsx("div",{className:"space-y-3",children:L.chapters.map((G,fe)=>G.sections.length>0?G.sections.map(X=>{const ce=O("section",X.id);return s.jsxs("div",{draggable:!0,onDragStart:he=>{he.stopPropagation(),he.dataTransfer.setData("text/plain","section:"+X.id),he.dataTransfer.effectAllowed="move",k({type:"section",id:X.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 ${ce?"bg-[#38bdac]/15 ring-2 ring-[#38bdac]/50":"hover:bg-[#162840]/50"} ${T("section",X.id)?"opacity-60 scale-[0.98] ring-2 ring-[#38bdac]":""}`,...R("section",X.id,{partId:L.id,partTitle:L.title,chapterId:G.id,chapterTitle:G.title}),children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[s.jsx(oi,{className:"w-4 h-4 text-gray-500 shrink-0 opacity-50"}),y&&s.jsx("label",{className:"shrink-0 flex items-center",onClick:he=>he.stopPropagation(),children:s.jsx("input",{type:"checkbox",checked:g.includes(X.id),onChange:()=>y(X.id),className:"w-4 h-4 rounded border-gray-600 bg-[#0a1628] text-[#38bdac] focus:ring-[#38bdac]"})}),s.jsxs("span",{className:"text-sm text-gray-300 truncate",children:["附录",fe+1," | ",G.title," | ",X.title]}),w.includes(X.id)&&s.jsx("span",{title:"已置顶",children:s.jsx(ml,{className:"w-3 h-3 text-amber-400 fill-amber-400 shrink-0"})})]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[s.jsxs("span",{className:"text-[10px] text-gray-500",children:["点击 ",X.clickCount??0," · 付款 ",X.payCount??0]}),s.jsxs("span",{className:"text-[10px] text-amber-400/90",title:"热度积分与排名",children:["热度 ",(X.hotScore??0).toFixed(1)," · 第",X.hotRank&&X.hotRank>0?X.hotRank:"-","名"]}),v&&s.jsx(ne,{variant:"ghost",size:"sm",onClick:()=>v(X),className:"text-[10px] text-gray-500 hover:text-[#38bdac] h-7 px-1.5",children:"付款记录"}),s.jsxs("div",{className:"flex gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[s.jsx(ne,{variant:"ghost",size:"sm",onClick:()=>i(X),className:"text-gray-500 hover:text-[#38bdac] h-7 px-1.5",title:"编辑",children:s.jsx(Rt,{className:"w-3.5 h-3.5"})}),s.jsx(ne,{variant:"ghost",size:"sm",onClick:()=>a(X),className:"text-gray-500 hover:text-red-400 h-7 px-1.5",children:s.jsx(Dn,{className:"w-3.5 h-3.5"})})]})]}),s.jsx(fl,{className:"w-4 h-4 text-gray-500 shrink-0"})]},X.id)}):s.jsxs("div",{className:"flex justify-between items-center py-2 select-none hover:bg-[#162840]/50 rounded px-2 -mx-2",children:[s.jsxs("span",{className:"text-sm text-gray-500",children:["附录",fe+1," | ",G.title,"(空)"]}),s.jsx(fl,{className:"w-4 h-4 text-gray-500 shrink-0"})]},G.id))})]},L.id);if(Y&&L.chapters.length===1&&L.chapters[0].sections.length===1){const G=L.chapters[0].sections[0],fe=O("section",G.id),X={partId:L.id,partTitle:L.title,chapterId:L.chapters[0].id,chapterTitle:L.chapters[0].title};return s.jsxs("div",{draggable:!0,onDragStart:ce=>{ce.stopPropagation(),ce.dataTransfer.setData("text/plain","section:"+G.id),ce.dataTransfer.effectAllowed="move",k({type:"section",id:G.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] ${fe?"bg-[#38bdac]/15 ring-2 ring-[#38bdac]/50":""} ${T("section",G.id)?"opacity-60 scale-[0.98] ring-2 ring-[#38bdac]":""}`,...R("section",G.id,X),children:[s.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0 select-none",children:[s.jsx(oi,{className:"w-5 h-5 text-gray-500 shrink-0 opacity-60"}),y&&s.jsx("label",{className:"shrink-0 flex items-center",onClick:ce=>ce.stopPropagation(),children:s.jsx("input",{type:"checkbox",checked:g.includes(G.id),onChange:()=>y(G.id),className:"w-4 h-4 rounded border-gray-600 bg-[#0a1628] text-[#38bdac] focus:ring-[#38bdac]"})}),s.jsx("div",{className:"w-8 h-8 rounded-lg bg-gray-600/50 flex items-center justify-center shrink-0",children:s.jsx(Gr,{className:"w-4 h-4 text-gray-400"})}),s.jsxs("span",{className:"font-medium text-gray-200 truncate",children:[L.chapters[0].title," | ",G.title]})]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",onMouseDown:ce=>ce.stopPropagation(),onClick:ce=>ce.stopPropagation(),children:[G.price===0||G.isFree?s.jsx("span",{className:"px-2 py-1 bg-[#38bdac]/20 text-[#38bdac] text-[10px] font-medium rounded",children:"免费"}):s.jsxs("span",{className:"text-xs text-gray-500",children:["¥",G.price]}),s.jsxs("span",{className:"text-[10px] text-gray-500",children:["点击 ",G.clickCount??0," · 付款 ",G.payCount??0]}),s.jsxs("span",{className:"text-[10px] text-amber-400/90",title:"热度积分与排名",children:["热度 ",(G.hotScore??0).toFixed(1)," · 第",G.hotRank&&G.hotRank>0?G.hotRank:"-","名"]}),v&&s.jsx(ne,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>v(G),className:"text-[10px] text-gray-500 hover:text-[#38bdac] h-7 px-1.5",children:"付款记录"}),s.jsxs("div",{className:"flex gap-1",children:[s.jsx(ne,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>i(G),className:"text-gray-500 hover:text-[#38bdac] h-7 px-2",title:"编辑",children:s.jsx(Rt,{className:"w-3.5 h-3.5"})}),s.jsx(ne,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>a(G),className:"text-gray-500 hover:text-red-400 h-7 px-2",children:s.jsx(Dn,{className:"w-3.5 h-3.5"})})]})]})]},L.id)}return Y?s.jsxs("div",{className:"rounded-xl border border-gray-700/50 bg-[#1C1C1E] p-5",children:[s.jsx("h3",{className:"text-sm font-medium text-gray-400 mb-4",children:"尾声"}),s.jsx("div",{className:"space-y-3",children:L.chapters.map(G=>G.sections.map(fe=>{const X=O("section",fe.id);return s.jsxs("div",{draggable:!0,onDragStart:ce=>{ce.stopPropagation(),ce.dataTransfer.setData("text/plain","section:"+fe.id),ce.dataTransfer.effectAllowed="move",k({type:"section",id:fe.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 ${X?"bg-[#38bdac]/15 ring-2 ring-[#38bdac]/50":"hover:bg-[#162840]/50"} ${T("section",fe.id)?"opacity-60 scale-[0.98] ring-2 ring-[#38bdac]":""}`,...R("section",fe.id,{partId:L.id,partTitle:L.title,chapterId:G.id,chapterTitle:G.title}),children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[s.jsx(oi,{className:"w-4 h-4 text-gray-500 shrink-0 opacity-50"}),y&&s.jsx("label",{className:"shrink-0 flex items-center",onClick:ce=>ce.stopPropagation(),children:s.jsx("input",{type:"checkbox",checked:g.includes(fe.id),onChange:()=>y(fe.id),className:"w-4 h-4 rounded border-gray-600 bg-[#0a1628] text-[#38bdac] focus:ring-[#38bdac]"})}),s.jsxs("span",{className:"text-sm text-gray-300",children:[G.title," | ",fe.title]})]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[s.jsxs("span",{className:"text-[10px] text-gray-500",children:["点击 ",fe.clickCount??0," · 付款 ",fe.payCount??0]}),s.jsxs("span",{className:"text-[10px] text-amber-400/90",title:"热度积分与排名",children:["热度 ",(fe.hotScore??0).toFixed(1)," · 第",fe.hotRank&&fe.hotRank>0?fe.hotRank:"-","名"]}),v&&s.jsx(ne,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>v(fe),className:"text-[10px] text-gray-500 hover:text-[#38bdac] h-7 px-1.5",children:"付款记录"}),s.jsxs("div",{className:"flex gap-1",children:[s.jsx(ne,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>i(fe),className:"text-gray-500 hover:text-[#38bdac] h-7 px-2",title:"编辑",children:s.jsx(Rt,{className:"w-3.5 h-3.5"})}),s.jsx(ne,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>a(fe),className:"text-gray-500 hover:text-red-400 h-7 px-2",children:s.jsx(Dn,{className:"w-3.5 h-3.5"})})]})]})]},fe.id)}))})]},L.id):s.jsxs("div",{className:`rounded-xl border bg-[#1C1C1E] overflow-hidden transition-all duration-200 ${D?"border-[#38bdac] ring-2 ring-[#38bdac]/40 bg-[#38bdac]/5":"border-gray-700/50"}`,...R("part",L.id,{partId:L.id,partTitle:L.title,chapterId:((W=L.chapters[0])==null?void 0:W.id)??"",chapterTitle:((ue=L.chapters[0])==null?void 0:ue.title)??""}),children:[s.jsxs("div",{draggable:!0,onDragStart:G=>{G.stopPropagation(),G.dataTransfer.setData("text/plain","part:"+L.id),G.dataTransfer.effectAllowed="move",k({type:"part",id:L.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 ${T("part",L.id)?"opacity-60 scale-[0.98] ring-2 ring-[#38bdac] rounded-xl shadow-xl shadow-[#38bdac]/20":"hover:bg-[#162840]/50"}`,onClick:()=>n(L.id),children:[s.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[s.jsx(oi,{className:"w-5 h-5 text-gray-500 shrink-0 opacity-60"}),s.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:P(ee)}),s.jsxs("div",{children:[s.jsx("h3",{className:"font-bold text-white text-base",children:L.title}),s.jsxs("p",{className:"text-xs text-gray-500 mt-0.5",children:["共 ",_," 节"]})]})]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",onMouseDown:G=>G.stopPropagation(),onClick:G=>G.stopPropagation(),children:[o&&s.jsx(ne,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>o(L),className:"text-gray-500 hover:text-[#38bdac] h-7 px-2",title:"在本篇下新增章节",children:s.jsx(rn,{className:"w-3.5 h-3.5"})}),h&&s.jsx(ne,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>h(L),className:"text-gray-500 hover:text-[#38bdac] h-7 px-2",title:"编辑篇名",children:s.jsx(Rt,{className:"w-3.5 h-3.5"})}),f&&s.jsx(ne,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>f(L),className:"text-gray-500 hover:text-red-400 h-7 px-2",title:"删除本篇",children:s.jsx(Dn,{className:"w-3.5 h-3.5"})}),s.jsxs("span",{className:"text-xs text-gray-500",children:[le,"章"]}),$?s.jsx(Gc,{className:"w-5 h-5 text-gray-500"}):s.jsx(fl,{className:"w-5 h-5 text-gray-500"})]})]}),$&&s.jsx("div",{className:"border-t border-gray-700/50 pl-4 pr-4 pb-4 pt-3 space-y-4",children:L.chapters.map(G=>{const fe=O("chapter",G.id);return s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center gap-2 w-full",children:[s.jsxs("div",{draggable:!0,onDragStart:X=>{X.stopPropagation(),X.dataTransfer.setData("text/plain","chapter:"+G.id),X.dataTransfer.effectAllowed="move",k({type:"chapter",id:G.id})},onDragEnd:()=>{k(null),C(null)},onDragEnter:X=>{X.preventDefault(),X.stopPropagation(),X.dataTransfer.dropEffect="move",C({type:"chapter",id:G.id})},onDragOver:X=>{X.preventDefault(),X.stopPropagation(),X.dataTransfer.dropEffect="move",C({type:"chapter",id:G.id})},onDragLeave:()=>C(null),onDrop:X=>{C(null);const ce=pg(X.dataTransfer.getData("text/plain"));if(!ce)return;const he={partId:L.id,partTitle:L.title,chapterId:G.id,chapterTitle:G.title};(ce.type==="section"||ce.type==="chapter")&&I(X,"chapter",G.id,he)},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 ${fe?"bg-[#38bdac]/15 ring-1 ring-[#38bdac]/50":""} ${T("chapter",G.id)?"opacity-60 scale-[0.98] ring-2 ring-[#38bdac]":"hover:bg-[#162840]/30"}`,children:[s.jsx(oi,{className:"w-4 h-4 text-gray-500 shrink-0 opacity-50"}),s.jsx("p",{className:"text-xs text-gray-500 pb-1 flex-1",children:G.title})]}),s.jsxs("div",{className:"flex gap-0.5 shrink-0",onClick:X=>X.stopPropagation(),children:[m&&s.jsx(ne,{variant:"ghost",size:"sm",onClick:()=>m(L,G),className:"text-gray-500 hover:text-[#38bdac] h-7 px-1.5",title:"编辑章节名称",children:s.jsx(Rt,{className:"w-3.5 h-3.5"})}),c&&s.jsx(ne,{variant:"ghost",size:"sm",onClick:()=>c(L),className:"text-gray-500 hover:text-[#38bdac] h-7 px-1.5",title:"新增第X章",children:s.jsx(rn,{className:"w-3.5 h-3.5"})}),u&&s.jsx(ne,{variant:"ghost",size:"sm",onClick:()=>u(L,G),className:"text-gray-500 hover:text-red-400 h-7 px-1.5",title:"删除本章",children:s.jsx(Dn,{className:"w-3.5 h-3.5"})})]})]}),s.jsx("div",{className:"space-y-1 pl-2",children:G.sections.map(X=>{const ce=O("section",X.id);return s.jsxs("div",{draggable:!0,onDragStart:he=>{he.stopPropagation(),he.dataTransfer.setData("text/plain","section:"+X.id),he.dataTransfer.effectAllowed="move",k({type:"section",id:X.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 ${ce?"bg-[#38bdac]/15 ring-2 ring-[#38bdac]/50":""} ${T("section",X.id)?"opacity-60 scale-[0.98] ring-2 ring-[#38bdac] shadow-lg":"hover:bg-[#162840]/50"}`,...R("section",X.id,{partId:L.id,partTitle:L.title,chapterId:G.id,chapterTitle:G.title}),children:[s.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[y&&s.jsx("label",{className:"shrink-0 flex items-center",onClick:he=>he.stopPropagation(),children:s.jsx("input",{type:"checkbox",checked:g.includes(X.id),onChange:()=>y(X.id),className:"w-4 h-4 rounded border-gray-600 bg-[#0a1628] text-[#38bdac] focus:ring-[#38bdac]"})}),s.jsx(oi,{className:"w-4 h-4 text-gray-500 shrink-0 opacity-50"}),s.jsx("div",{className:`w-2 h-2 rounded-full shrink-0 ${X.price===0||X.isFree?"border-2 border-[#38bdac] bg-transparent":"bg-gray-500"}`}),s.jsxs("span",{className:"text-sm text-gray-200 truncate",children:[X.id," ",X.title]}),w.includes(X.id)&&s.jsx("span",{title:"已置顶",children:s.jsx(ml,{className:"w-3 h-3 text-amber-400 fill-amber-400 shrink-0"})})]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",onMouseDown:he=>he.stopPropagation(),onClick:he=>he.stopPropagation(),children:[X.isNew&&s.jsx("span",{className:"px-2 py-1 bg-[#38bdac]/20 text-[#38bdac] text-[10px] font-medium rounded",children:"NEW"}),X.price===0||X.isFree?s.jsx("span",{className:"px-2 py-1 bg-[#38bdac]/20 text-[#38bdac] text-[10px] font-medium rounded",children:"免费"}):s.jsxs("span",{className:"text-xs text-gray-500",children:["¥",X.price]}),s.jsxs("span",{className:"text-[10px] text-gray-500",title:"点击次数 · 付款笔数",children:["点击 ",X.clickCount??0," · 付款 ",X.payCount??0]}),s.jsxs("span",{className:"text-[10px] text-amber-400/90",title:"热度积分与排名",children:["热度 ",(X.hotScore??0).toFixed(1)," · 第",X.hotRank&&X.hotRank>0?X.hotRank:"-","名"]}),v&&s.jsx(ne,{variant:"ghost",size:"sm",onClick:()=>v(X),className:"text-[10px] text-gray-500 hover:text-[#38bdac] h-7 px-1.5 shrink-0",children:"付款记录"}),s.jsxs("div",{className:"flex gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[s.jsx(ne,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>i(X),className:"text-gray-500 hover:text-[#38bdac] h-7 px-1.5",title:"编辑",children:s.jsx(Rt,{className:"w-3.5 h-3.5"})}),s.jsx(ne,{draggable:!1,variant:"ghost",size:"sm",onClick:()=>a(X),className:"text-gray-500 hover:text-red-400 h-7 px-1.5",children:s.jsx(Dn,{className:"w-3.5 h-3.5"})})]})]})]},X.id)})})]},G.id)})})]},L.id)})})}function QB(t){var i;const e=new URLSearchParams;e.set("page",String(t.page)),e.set("limit",String(t.limit)),(i=t==null?void 0:t.keyword)!=null&&i.trim()&&e.set("keyword",t.keyword.trim());const n=e.toString(),r=n?`/api/admin/ckb/devices?${n}`:"/api/admin/ckb/devices";return Le(r)}function XB(t){return Le(`/api/db/person?personId=${encodeURIComponent(t)}`)}const I4=11,hw={personId:"",name:"",label:"",sceneId:I4,ckbApiKey:"",greeting:"你好,请通过",tips:"请注意消息,稍后加你微信",remarkType:"phone",remarkFormat:"",addFriendInterval:1,startTime:"09:00",endTime:"18:00",deviceGroups:""};function ZB({open:t,onOpenChange:e,editingPerson:n,onSubmit:r}){const i=!!n,[a,o]=b.useState(hw),[c,u]=b.useState(!1),[h,f]=b.useState(!1),[m,g]=b.useState([]),[y,v]=b.useState(!1),[w,N]=b.useState("");b.useEffect(()=>{t&&(N(""),o(n?{personId:n.personId??n.name??"",name:n.name??"",label:n.label??"",sceneId:I4,ckbApiKey:n.ckbApiKey??"",greeting:"你好,请通过",tips:"请注意消息,稍后加你微信",remarkType:n.remarkType??"phone",remarkFormat:n.remarkFormat??"",addFriendInterval:n.addFriendInterval??1,startTime:n.startTime??"09:00",endTime:n.endTime??"18:00",deviceGroups:n.deviceGroups??""}:{...hw}),m.length===0&&k(""))},[t,n]);const k=async C=>{v(!0);try{const T=await QB({page:1,limit:50,keyword:C});T!=null&&T.success&&Array.isArray(T.devices)?g(T.devices):T!=null&&T.error&&oe.error(T.error)}catch(T){oe.error(T instanceof Error?T.message:"加载设备列表失败")}finally{v(!1)}},E=async()=>{if(!a.name.trim()){oe.error("名称必填");return}u(!0);try{await r(a),e(!1)}catch(C){oe.error(C instanceof Error?C.message:"保存失败")}finally{u(!1)}};return s.jsx(Kt,{open:t,onOpenChange:e,children:s.jsxs(Vt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-4xl max-h-[90vh] overflow-y-auto",children:[s.jsxs(qt,{children:[s.jsx(Gt,{className:"text-[#38bdac]",children:i?"编辑人物":"添加人物 — 存客宝 API 获客"}),s.jsx(Wx,{className:"text-gray-400 text-sm",children:i?"修改后同步到存客宝计划":"添加时自动生成 token,并同步创建存客宝场景获客计划"})]}),s.jsxs("div",{className:"space-y-6 py-2",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-xs font-medium text-gray-400 uppercase tracking-wider mb-3",children:"基础信息"}),s.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Z,{className:"text-gray-400 text-xs",children:"名称 *"}),s.jsx(ae,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如 卡若",value:a.name,onChange:C=>o(T=>({...T,name:C.target.value}))})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Z,{className:"text-gray-400 text-xs",children:"人物ID(可选)"}),s.jsx(ae,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"自动生成",value:a.personId,onChange:C=>o(T=>({...T,personId:C.target.value})),disabled:i})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Z,{className:"text-gray-400 text-xs",children:"标签(身份/角色)"}),s.jsx(ae,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如 超级个体",value:a.label,onChange:C=>o(T=>({...T,label:C.target.value}))})]})]})]}),s.jsxs("div",{className:"border-t border-gray-700/50 pt-5",children:[s.jsx("p",{className:"text-xs font-medium text-gray-400 uppercase tracking-wider mb-4",children:"存客宝 API 获客配置"}),s.jsxs("div",{className:"grid grid-cols-2 gap-x-8 gap-y-4",children:[s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Z,{className:"text-gray-400 text-xs",children:"存客宝密钥(计划 apiKey)"}),s.jsx(ae,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"创建计划成功后自动回填,不可手动修改",value:a.ckbApiKey,readOnly:!0}),s.jsx("p",{className:"text-xs text-gray-500",children:"由存客宝计划详情接口返回的 apiKey,用于小程序 @人物 时推送到对应获客计划。"})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Z,{className:"text-gray-400 text-xs",children:"选择设备"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(ae,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"未选择设备",readOnly:!0,value:a.deviceGroups?`已选择 ${a.deviceGroups.split(",").filter(Boolean).length} 个设备`:"",onClick:()=>f(!0)}),s.jsx(ne,{type:"button",variant:"outline",className:"border-gray-600 text-gray-200",onClick:()=>f(!0),children:"选择"})]}),s.jsx("p",{className:"text-xs text-gray-500",children:"从存客宝设备列表中选择,建议至少选择 1 台在线设备;不选则由存客宝自行分配。"})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Z,{className:"text-gray-400 text-xs",children:"好友备注"}),s.jsxs(ul,{value:a.remarkType,onValueChange:C=>o(T=>({...T,remarkType:C})),children:[s.jsx(Xa,{className:"bg-[#0a1628] border-gray-700 text-white",children:s.jsx(hl,{placeholder:"选择备注类型"})}),s.jsxs(Za,{children:[s.jsx(Er,{value:"phone",children:"手机号"}),s.jsx(Er,{value:"nickname",children:"昵称"}),s.jsx(Er,{value:"source",children:"来源"})]})]})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Z,{className:"text-gray-400 text-xs",children:"备注格式"}),s.jsx(ae,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如 手机号+SOUL链接人与事-{名称},留空用默认",value:a.remarkFormat,onChange:C=>o(T=>({...T,remarkFormat:C.target.value}))})]})]}),s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Z,{className:"text-gray-400 text-xs",children:"打招呼语"}),s.jsx(ae,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"你好,请通过",value:a.greeting,onChange:C=>o(T=>({...T,greeting:C.target.value}))})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Z,{className:"text-gray-400 text-xs",children:"添加间隔(分钟)"}),s.jsx(ae,{type:"number",min:1,className:"bg-[#0a1628] border-gray-700 text-white",value:a.addFriendInterval,onChange:C=>o(T=>({...T,addFriendInterval:Number(C.target.value)||1}))})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Z,{className:"text-gray-400 text-xs",children:"允许加人时间段"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ae,{type:"time",className:"bg-[#0a1628] border-gray-700 text-white w-24",value:a.startTime,onChange:C=>o(T=>({...T,startTime:C.target.value}))}),s.jsx("span",{className:"text-gray-500 text-sm shrink-0",children:"至"}),s.jsx(ae,{type:"time",className:"bg-[#0a1628] border-gray-700 text-white w-24",value:a.endTime,onChange:C=>o(T=>({...T,endTime:C.target.value}))})]})]})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Z,{className:"text-gray-400 text-xs",children:"获客成功提示"}),s.jsx(_l,{className:"bg-[#0a1628] border-gray-700 text-white min-h-[72px] resize-none",placeholder:"请注意消息,稍后加你微信",value:a.tips,onChange:C=>o(T=>({...T,tips:C.target.value}))})]})]})]})]})]}),s.jsxs(hn,{className:"gap-2 sm:gap-0 pt-2",children:[s.jsx(ne,{variant:"outline",onClick:()=>e(!1),className:"border-gray-600 text-gray-300",children:"取消"}),s.jsx(ne,{onClick:E,disabled:c,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:c?"保存中...":i?"保存":"添加"})]}),h&&s.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60",children:s.jsxs("div",{className:"w-full max-w-3xl max-h-[80vh] bg-[#0b1828] border border-gray-700 rounded-xl shadow-xl flex flex-col",children:[s.jsxs("div",{className:"flex items-center justify-between px-5 py-3 border-b border-gray-700/60",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"text-sm font-medium text-white",children:"选择设备"}),s.jsx("p",{className:"text-xs text-gray-400 mt-0.5",children:"勾选需要参与本计划的设备,可多选"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ae,{className:"bg-[#050c18] border-gray-700 text-white h-8 w-52",placeholder:"搜索备注/微信号/IMEI",value:w,onChange:C=>N(C.target.value),onKeyDown:C=>{C.key==="Enter"&&k(w)}}),s.jsx(ne,{type:"button",size:"sm",variant:"outline",className:"border-gray-600 text-gray-200 h-8",onClick:()=>k(w),disabled:y,children:"刷新"}),s.jsx(ne,{type:"button",size:"icon",variant:"outline",className:"border-gray-600 text-gray-300 h-8 w-8",onClick:()=>f(!1),children:"✕"})]})]}),s.jsx("div",{className:"flex-1 overflow-y-auto",children:y?s.jsx("div",{className:"flex h-full items-center justify-center text-gray-400 text-sm",children:"正在加载设备列表…"}):m.length===0?s.jsx("div",{className:"flex h-full items-center justify-center text-gray-500 text-sm",children:"暂无设备数据,请检查存客宝账号与开放 API 配置"}):s.jsx("div",{className:"p-4 space-y-2",children:m.map(C=>{const T=String(C.id??""),O=a.deviceGroups?a.deviceGroups.split(",").map(R=>R.trim()).filter(Boolean):[],F=O.includes(T),I=()=>{let R;F?R=O.filter(P=>P!==T):R=[...O,T],o(P=>({...P,deviceGroups:R.join(",")}))};return s.jsxs("label",{className:"flex items-center gap-3 rounded-lg border border-gray-700/60 bg-[#050c18] px-3 py-2 cursor-pointer hover:border-[#38bdac]/70",children:[s.jsx("input",{type:"checkbox",className:"h-4 w-4 accent-[#38bdac]",checked:F,onChange:I}),s.jsxs("div",{className:"flex flex-col min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-sm text-white truncate max-w-xs",children:C.memo||C.wechatId||`设备 ${T}`}),C.status==="online"&&s.jsx("span",{className:"rounded-full bg-emerald-500/20 text-emerald-400 text-[11px] px-2 py-0.5",children:"在线"}),C.status==="offline"&&s.jsx("span",{className:"rounded-full bg-gray-600/20 text-gray-400 text-[11px] px-2 py-0.5",children:"离线"})]}),s.jsxs("div",{className:"text-[11px] text-gray-400 mt-0.5",children:[s.jsxs("span",{className:"mr-3",children:["ID: ",T]}),C.wechatId&&s.jsxs("span",{className:"mr-3",children:["微信号: ",C.wechatId]}),typeof C.totalFriend=="number"&&s.jsxs("span",{children:["好友数: ",C.totalFriend]})]})]})]},T)})})}),s.jsxs("div",{className:"flex justify-between items-center px-5 py-3 border-t border-gray-700/60",children:[s.jsxs("span",{className:"text-xs text-gray-400",children:["已选择"," ",a.deviceGroups?a.deviceGroups.split(",").filter(Boolean).length:0," ","台设备"]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(ne,{type:"button",variant:"outline",className:"border-gray-600 text-gray-200 h-8 px-4",onClick:()=>f(!1),children:"取消"}),s.jsx(ne,{type:"button",className:"bg-[#38bdac] hover:bg-[#2da396] text-white h-8 px-4",onClick:()=>f(!1),children:"确定"})]})]})]})})]})})}function fw(t,e,n){if(!t||!t.includes("@")&&!t.includes("#")||typeof document>"u")return t;const r=document.createElement("div");r.innerHTML=t;const i=u=>e.find(h=>h.name===u),a=u=>n.find(h=>h.label===u),o=u=>{const h=u.textContent||"";if(!h||!h.includes("@")&&!h.includes("#"))return;const f=u.parentNode;if(!f)return;const m=document.createDocumentFragment(),g=/(@[^\s@#]+|#[^\s@#]+)/g;let y=0,v;for(;v=g.exec(h);){const[w]=v,N=v.index;if(N>y&&m.appendChild(document.createTextNode(h.slice(y,N))),w.startsWith("@")){const k=w.slice(1),E=i(k);if(E){const C=document.createElement("span");C.setAttribute("data-type","mention"),C.setAttribute("data-id",E.id),C.className="mention-tag",C.textContent=`@${E.name}`,m.appendChild(C)}else m.appendChild(document.createTextNode(w))}else if(w.startsWith("#")){const k=w.slice(1),E=a(k);if(E){const C=document.createElement("span");C.setAttribute("data-type","linkTag"),C.setAttribute("data-url",E.url||""),C.setAttribute("data-tag-type",E.type||"url"),C.setAttribute("data-tag-id",E.id||""),C.setAttribute("data-page-path",E.pagePath||""),C.setAttribute("data-app-id",E.appId||""),E.type==="miniprogram"&&E.appId&&C.setAttribute("data-mp-key",E.appId),C.className="link-tag-node",C.textContent=`#${E.label}`,m.appendChild(C)}else m.appendChild(document.createTextNode(w))}else m.appendChild(document.createTextNode(w));y=N+w.length}y{if(u.nodeType===Node.ELEMENT_NODE){const f=u.getAttribute("data-type");if(f==="mention"||f==="linkTag")return;u.childNodes.forEach(m=>c(m));return}u.nodeType===Node.TEXT_NODE&&o(u)};return r.childNodes.forEach(u=>c(u)),r.innerHTML}function eV(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 tV(){var Po,mt,Ul;const[t,e]=b.useState([]),[n,r]=b.useState(!0),[i,a]=b.useState([]),[o,c]=b.useState(null),[u,h]=b.useState(!1),[f,m]=b.useState(!1),[g,y]=b.useState(!1),[v,w]=b.useState(""),[N,k]=b.useState([]),[E,C]=b.useState(!1),[T,O]=b.useState({id:"",title:"",price:1,partId:"part-1",chapterId:"chapter-1",content:"",editionStandard:!0,editionPremium:!1,isFree:!1,isNew:!1,isPinned:!1,hotScore:0}),[F,I]=b.useState(null),[R,P]=b.useState(!1),[L,ee]=b.useState(!1),[te,Y]=b.useState(null),[U,D]=b.useState(!1),[$,le]=b.useState([]),[_,se]=b.useState(!1),[J,z]=b.useState(""),[W,ue]=b.useState(""),[G,fe]=b.useState(!1),[X,ce]=b.useState(""),[he,we]=b.useState(!1),[V,be]=b.useState(null),[Me,st]=b.useState(!1),[nt,dt]=b.useState(!1),[Ye,ht]=b.useState({readWeight:.5,recencyWeight:.3,payWeight:.2}),[Tt,ft]=b.useState(!1),[Mt,Nn]=b.useState(!1),[Zn,Pr]=b.useState(1),[Or,bs]=b.useState([]),[br,Qr]=b.useState(!1),[Qt,Fn]=b.useState([]),[Xr,er]=b.useState(!1),[pe,ve]=b.useState(20),[tr,Hs]=b.useState(!1),[ki,Si]=b.useState(!1),[Nr,Aa]=b.useState([]),[Dr,Zr]=b.useState([]),[nr,Ci]=b.useState(!1),[Ia,Ws]=b.useState(null),[at,An]=b.useState({tagId:"",label:"",url:"",type:"url",appId:"",pagePath:""}),[es,wr]=b.useState(null),ts=b.useRef(null),Xt=eV(t),Lr=t.length,Us=10,_r=Math.max(1,Math.ceil(Or.length/Us)),Ks=Or.slice((Zn-1)*Us,Zn*Us),gn=async()=>{r(!0);try{const A=await Le("/api/db/book?action=list",{cache:"no-store"});e(Array.isArray(A==null?void 0:A.sections)?A.sections:[])}catch(A){console.error(A),e([])}finally{r(!1)}},Ns=async()=>{Qr(!0);try{const A=await Le("/api/db/book?action=ranking",{cache:"no-store"}),K=Array.isArray(A==null?void 0:A.sections)?A.sections:[];bs(K);const me=K.filter(ye=>ye.isPinned).map(ye=>ye.id);Fn(me)}catch(A){console.error(A),bs([])}finally{Qr(!1)}};b.useEffect(()=>{gn(),Ns()},[]);const Hl=A=>{a(K=>K.includes(A)?K.filter(me=>me!==A):[...K,A])},Ei=b.useCallback(A=>{const K=t,me=A.flatMap(ye=>{const wt=K.find(At=>At.id===ye.id);return wt?[{...wt,partId:ye.partId,partTitle:ye.partTitle,chapterId:ye.chapterId,chapterTitle:ye.chapterTitle}]:[]});return e(me),St("/api/db/book",{action:"reorder",items:A}).then(ye=>{ye&&ye.success===!1&&(e(K),oe.error("排序失败: "+(ye&&typeof ye=="object"&&"error"in ye?ye.error:"未知错误")))}).catch(ye=>{e(K),console.error("排序失败:",ye),oe.error("排序失败: "+(ye instanceof Error?ye.message:"网络或服务异常"))}),Promise.resolve()},[t]),qs=async A=>{if(confirm(`确定要删除章节「${A.title}」吗?此操作不可恢复。`))try{const K=await Ps(`/api/db/book?id=${encodeURIComponent(A.id)}`);K&&K.success!==!1?(oe.success("已删除"),gn(),Ns()):oe.error("删除失败: "+(K&&typeof K=="object"&&"error"in K?K.error:"未知错误"))}catch(K){console.error(K),oe.error("删除失败")}},dr=b.useCallback(async()=>{ft(!0);try{const A=await Le("/api/db/config/full?key=article_ranking_weights",{cache:"no-store"}),K=A&&A.data;K&&typeof K.readWeight=="number"&&typeof K.recencyWeight=="number"&&typeof K.payWeight=="number"&&ht({readWeight:Math.max(0,Math.min(1,K.readWeight)),recencyWeight:Math.max(0,Math.min(1,K.recencyWeight)),payWeight:Math.max(0,Math.min(1,K.payWeight))})}catch{}finally{ft(!1)}},[]);b.useEffect(()=>{nt&&dr()},[nt,dr]);const Ra=async()=>{const{readWeight:A,recencyWeight:K,payWeight:me}=Ye,ye=A+K+me;if(Math.abs(ye-1)>.001){oe.error("三个权重之和必须等于 1");return}Nn(!0);try{const wt=await xt("/api/db/config",{key:"article_ranking_weights",value:{readWeight:A,recencyWeight:K,payWeight:me},description:"文章排名算法权重"});wt&&wt.success!==!1?(oe.success("排名权重已保存"),gn()):oe.error("保存失败: "+(wt&&typeof wt=="object"&&"error"in wt?wt.error:""))}catch(wt){console.error(wt),oe.error("保存失败")}finally{Nn(!1)}},Ti=b.useCallback(async()=>{er(!0);try{const A=await Le("/api/db/config/full?key=pinned_section_ids",{cache:"no-store"}),K=A&&A.data;Array.isArray(K)&&Fn(K)}catch{}finally{er(!1)}},[]),Gs=b.useCallback(async()=>{try{const A=await Le("/api/db/persons");A!=null&&A.success&&A.persons&&Aa(A.persons.map(K=>{const me=K.deviceGroups,ye=Array.isArray(me)?me.join(","):me??"";return{id:K.token??K.personId??"",personId:K.personId,name:K.name,label:K.label??"",ckbApiKey:K.ckbApiKey??"",ckbPlanId:K.ckbPlanId,remarkType:K.remarkType,remarkFormat:K.remarkFormat,addFriendInterval:K.addFriendInterval,startTime:K.startTime,endTime:K.endTime,deviceGroups:ye}}))}catch{}},[]),ws=b.useCallback(async()=>{try{const A=await Le("/api/db/link-tags");A!=null&&A.success&&A.linkTags&&Zr(A.linkTags.map(K=>({id:K.tagId,label:K.label,url:K.url,type:K.type||"url",appId:K.appId||"",pagePath:K.pagePath||""})))}catch{}},[]),[Mi,To]=b.useState([]),[js,Pa]=b.useState(""),[Mo,kt]=b.useState(!1),Ao=b.useRef(null),Js=b.useCallback(async()=>{try{const A=await Le("/api/admin/linked-miniprograms");A!=null&&A.success&&Array.isArray(A.data)&&To(A.data.map(K=>({...K,key:K.key})))}catch{}},[]),Ai=Mi.filter(A=>!js.trim()||A.name.toLowerCase().includes(js.toLowerCase())||A.key&&A.key.toLowerCase().includes(js.toLowerCase())||A.appId.toLowerCase().includes(js.toLowerCase())),ks=async A=>{const K=Qt.includes(A)?Qt.filter(me=>me!==A):[...Qt,A];Fn(K);try{await xt("/api/db/config",{key:"pinned_section_ids",value:K,description:"强制置顶章节ID列表(精选推荐/首页最新更新)"}),Ns()}catch{Fn(Qt)}},Oa=b.useCallback(async()=>{Hs(!0);try{const A=await Le("/api/db/config/full?key=unpaid_preview_percent",{cache:"no-store"}),K=A&&A.data;typeof K=="number"&&K>0&&K<=100&&ve(K)}catch{}finally{Hs(!1)}},[]),Da=async()=>{if(pe<1||pe>100){oe.error("预览比例需在 1~100 之间");return}Si(!0);try{const A=await xt("/api/db/config",{key:"unpaid_preview_percent",value:pe,description:"小程序未付费内容默认预览比例(%)"});A&&A.success!==!1?oe.success("预览比例已保存"):oe.error("保存失败: "+(A.error||""))}catch{oe.error("保存失败")}finally{Si(!1)}};b.useEffect(()=>{Ti(),Oa(),Gs(),ws(),Js()},[Ti,Oa,Gs,ws,Js]);const H=async A=>{be({section:A,orders:[]}),st(!0);try{const K=await Le(`/api/db/book?action=section-orders&id=${encodeURIComponent(A.id)}`),me=K!=null&&K.success&&Array.isArray(K.orders)?K.orders:[];be(ye=>ye?{...ye,orders:me}:null)}catch(K){console.error(K),be(me=>me?{...me,orders:[]}:null)}finally{st(!1)}},Pe=async A=>{m(!0);try{const K=await Le(`/api/db/book?action=read&id=${encodeURIComponent(A.id)}`);if(K!=null&&K.success&&K.section){const me=K.section,ye=me.editionPremium===!0;c({id:A.id,originalId:A.id,title:K.section.title??A.title,price:K.section.price??A.price,content:K.section.content??"",filePath:A.filePath,isFree:A.isFree||A.price===0,isNew:me.isNew??A.isNew,isPinned:Qt.includes(A.id),hotScore:A.hotScore??0,editionStandard:ye?!1:me.editionStandard??!0,editionPremium:ye})}else c({id:A.id,originalId:A.id,title:A.title,price:A.price,content:"",filePath:A.filePath,isFree:A.isFree,isNew:A.isNew,isPinned:Qt.includes(A.id),hotScore:A.hotScore??0,editionStandard:!0,editionPremium:!1}),K&&!K.success&&oe.error("无法读取文件内容: "+(K.error||"未知错误"))}catch(K){console.error(K),c({id:A.id,title:A.title,price:A.price,content:"",filePath:A.filePath,isFree:A.isFree})}finally{m(!1)}},Je=async()=>{var A;if(o){y(!0);try{let K=o.content||"";K=fw(K,Nr,Dr);const me=[new RegExp(`^#+\\s*${o.id.replace(".","\\.")}\\s+.*$`,"gm"),new RegExp(`^#+\\s*${o.id.replace(".","\\.")}[::].*$`,"gm"),new RegExp(`^#\\s+.*${(A=o.title)==null?void 0:A.slice(0,10).replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}.*$`,"gm")];for(const Zt of me)K=K.replace(Zt,"");K=K.replace(/^\s*\n+/,"").trim();const ye=o.originalId||o.id,wt=o.id!==ye,At=await St("/api/db/book",{id:ye,...wt?{newId:o.id}:{},title:o.title,price:o.isFree?0:o.price,content:K,isFree:o.isFree||o.price===0,isNew:o.isNew,hotScore:o.hotScore,editionStandard:o.editionPremium?!1:o.editionStandard??!0,editionPremium:o.editionPremium??!1,saveToFile:!0}),jn=wt?o.id:ye;o.isPinned!==Qt.includes(jn)&&await ks(jn),At&&At.success!==!1?(oe.success(`已保存:${o.title}`),c(null),gn()):oe.error("保存失败: "+(At&&typeof At=="object"&&"error"in At?At.error:"未知错误"))}catch(K){console.error(K),oe.error("保存失败")}finally{y(!1)}}},Xe=async()=>{if(!T.id||!T.title){oe.error("请填写章节ID和标题");return}y(!0);try{const A=Xt.find(ye=>ye.id===T.partId),K=A==null?void 0:A.chapters.find(ye=>ye.id===T.chapterId),me=await St("/api/db/book",{id:T.id,title:T.title,price:T.isFree?0:T.price,content:fw(T.content||"",Nr,Dr),partId:T.partId,partTitle:(A==null?void 0:A.title)??"",chapterId:T.chapterId,chapterTitle:(K==null?void 0:K.title)??"",isFree:T.isFree,isNew:T.isNew,editionStandard:T.editionPremium?!1:T.editionStandard??!0,editionPremium:T.editionPremium??!1,hotScore:T.hotScore??0,saveToFile:!1});if(me&&me.success!==!1){if(T.isPinned){const ye=[...Qt,T.id];Fn(ye);try{await xt("/api/db/config",{key:"pinned_section_ids",value:ye,description:"强制置顶章节ID列表(精选推荐/首页最新更新)"})}catch{}}oe.success(`章节创建成功:${T.title}`),h(!1),O({id:"",title:"",price:1,partId:"part-1",chapterId:"chapter-1",content:"",editionStandard:!0,editionPremium:!1,isFree:!1,isNew:!1,isPinned:!1,hotScore:0}),gn()}else oe.error("创建失败: "+(me&&typeof me=="object"&&"error"in me?me.error:"未知错误"))}catch(A){console.error(A),oe.error("创建失败")}finally{y(!1)}},wn=A=>{O(K=>{var me;return{...K,partId:A.id,chapterId:((me=A.chapters[0])==null?void 0:me.id)??"chapter-1"}}),h(!0)},rr=A=>{I({id:A.id,title:A.title})},Io=async()=>{var A;if((A=F==null?void 0:F.title)!=null&&A.trim()){P(!0);try{const K=t.map(ye=>({id:ye.id,partId:ye.partId||"part-1",partTitle:ye.partId===F.id?F.title.trim():ye.partTitle||"",chapterId:ye.chapterId||"chapter-1",chapterTitle:ye.chapterTitle||""})),me=await St("/api/db/book",{action:"reorder",items:K});if(me&&me.success!==!1){const ye=F.title.trim();e(wt=>wt.map(At=>At.partId===F.id?{...At,partTitle:ye}:At)),I(null),gn()}else oe.error("更新篇名失败: "+(me&&typeof me=="object"&&"error"in me?me.error:"未知错误"))}catch(K){console.error(K),oe.error("更新篇名失败")}finally{P(!1)}}},Ft=A=>{const K=A.chapters.length+1,me=`chapter-${A.id}-${K}-${Date.now()}`;O({id:`${K}.1`,title:"新章节",price:1,partId:A.id,chapterId:me,content:"",editionStandard:!0,editionPremium:!1,isFree:!1,isNew:!1,isPinned:!1,hotScore:0}),h(!0)},In=(A,K)=>{Y({part:A,chapter:K,title:K.title})},ns=async()=>{var A;if((A=te==null?void 0:te.title)!=null&&A.trim()){D(!0);try{const K=t.map(ye=>({id:ye.id,partId:ye.partId||te.part.id,partTitle:ye.partId===te.part.id?te.part.title:ye.partTitle||"",chapterId:ye.chapterId||te.chapter.id,chapterTitle:ye.partId===te.part.id&&ye.chapterId===te.chapter.id?te.title.trim():ye.chapterTitle||""})),me=await St("/api/db/book",{action:"reorder",items:K});if(me&&me.success!==!1){const ye=te.title.trim(),wt=te.part.id,At=te.chapter.id;e(jn=>jn.map(Zt=>Zt.partId===wt&&Zt.chapterId===At?{...Zt,chapterTitle:ye}:Zt)),Y(null),gn()}else oe.error("保存失败: "+(me&&typeof me=="object"&&"error"in me?me.error:"未知错误"))}catch(K){console.error(K),oe.error("保存失败")}finally{D(!1)}}},Ss=async(A,K)=>{const me=K.sections.map(ye=>ye.id);if(me.length===0){oe.info("该章下无小节,无需删除");return}if(confirm(`确定要删除「第${A.chapters.indexOf(K)+1}章 | ${K.title}」吗?将删除共 ${me.length} 节,此操作不可恢复。`))try{for(const ye of me)await Ps(`/api/db/book?id=${encodeURIComponent(ye)}`);gn()}catch(ye){console.error(ye),oe.error("删除失败")}},Ys=async()=>{if(!X.trim()){oe.error("请输入篇名");return}we(!0);try{const A=`part-new-${Date.now()}`,K="chapter-1",me=`part-placeholder-${Date.now()}`,ye=await St("/api/db/book",{id:me,title:"占位节(可编辑)",price:0,content:"",partId:A,partTitle:X.trim(),chapterId:K,chapterTitle:"第1章 | 待编辑",saveToFile:!1});ye&&ye.success!==!1?(oe.success(`篇「${X}」创建成功`),ee(!1),ce(""),gn()):oe.error("创建失败: "+(ye&&typeof ye=="object"&&"error"in ye?ye.error:"未知错误"))}catch(A){console.error(A),oe.error("创建失败")}finally{we(!1)}},Wl=async()=>{if($.length===0){oe.error("请先勾选要移动的章节");return}const A=Xt.find(me=>me.id===J),K=A==null?void 0:A.chapters.find(me=>me.id===W);if(!A||!K||!J||!W){oe.error("请选择目标篇和章");return}fe(!0);try{const me=()=>{const jn=new Set($),Zt=t.map(en=>({id:en.id,partId:en.partId||"",partTitle:en.partTitle||"",chapterId:en.chapterId||"",chapterTitle:en.chapterTitle||""})),Cs=Zt.filter(en=>jn.has(en.id)).map(en=>({...en,partId:J,partTitle:A.title||J,chapterId:W,chapterTitle:K.title||W})),ur=Zt.filter(en=>!jn.has(en.id));let Xs=ur.length;for(let en=ur.length-1;en>=0;en-=1){const rs=ur[en];if(rs.partId===J&&rs.chapterId===W){Xs=en+1;break}}return[...ur.slice(0,Xs),...Cs,...ur.slice(Xs)]},ye=async()=>{const jn=me(),Zt=await St("/api/db/book",{action:"reorder",items:jn});return Zt&&Zt.success!==!1?(oe.success(`已移动 ${$.length} 节到「${A.title}」-「${K.title}」`),se(!1),le([]),await gn(),!0):!1},wt={action:"move-sections",sectionIds:$,targetPartId:J,targetChapterId:W,targetPartTitle:A.title||J,targetChapterTitle:K.title||W},At=await St("/api/db/book",wt);if(At&&At.success!==!1)oe.success(`已移动 ${At.count??$.length} 节到「${A.title}」-「${K.title}」`),se(!1),le([]),await gn();else{const jn=At&&typeof At=="object"&&"error"in At?At.error||"":"未知错误";if((jn.includes("缺少 id")||jn.includes("无效的 action"))&&await ye())return;oe.error("移动失败: "+jn)}}catch(me){console.error(me),oe.error("移动失败: "+(me instanceof Error?me.message:"网络或服务异常"))}finally{fe(!1)}},La=A=>{le(K=>K.includes(A)?K.filter(me=>me!==A):[...K,A])},Ii=async A=>{const K=t.filter(me=>me.partId===A.id).map(me=>me.id);if(K.length===0){oe.info("该篇下暂无小节可删除");return}if(confirm(`确定要删除「${A.title}」整篇吗?将删除共 ${K.length} 节内容,此操作不可恢复。`))try{for(const me of K)await Ps(`/api/db/book?id=${encodeURIComponent(me)}`);gn()}catch(me){console.error(me),oe.error("删除失败")}},Ro=async()=>{var A;if(v.trim()){C(!0);try{const K=await Le(`/api/search?q=${encodeURIComponent(v)}`);K!=null&&K.success&&((A=K.data)!=null&&A.results)?k(K.data.results):(k([]),K&&!K.success&&oe.error("搜索失败: "+K.error))}catch(K){console.error(K),k([]),oe.error("搜索失败")}finally{C(!1)}}},Qs=Xt.find(A=>A.id===T.partId),vd=(Qs==null?void 0:Qs.chapters)??[];return s.jsxs("div",{className:"p-8 w-full",children:[s.jsxs("div",{className:"flex justify-between items-center mb-8",children:[s.jsxs("div",{children:[s.jsx("h2",{className:"text-2xl font-bold text-white",children:"内容管理"}),s.jsxs("p",{className:"text-gray-400 mt-1",children:["共 ",Xt.length," 篇 · ",Lr," 节内容"]})]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs(ne,{onClick:()=>dt(!0),variant:"outline",className:"border-amber-500/50 text-amber-400 hover:bg-amber-500/10 bg-transparent",children:[s.jsx(Nu,{className:"w-4 h-4 mr-2"}),"排名算法"]}),s.jsxs(ne,{onClick:()=>{const A=typeof window<"u"?`${window.location.origin}/api-doc`:"";A&&window.open(A,"_blank","noopener,noreferrer")},variant:"outline",className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(ps,{className:"w-4 h-4 mr-2"}),"API 接口"]})]})]}),s.jsx(Kt,{open:u,onOpenChange:h,children:s.jsxs(Vt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-4xl max-h-[90vh] flex flex-col p-0 gap-0",showCloseButton:!0,children:[s.jsx(qt,{className:"shrink-0 px-6 pt-6 pb-2",children:s.jsxs(Gt,{className:"text-white flex items-center gap-2",children:[s.jsx(rn,{className:"w-5 h-5 text-[#38bdac]"}),"新建章节"]})}),s.jsxs("div",{className:"flex-1 overflow-y-auto min-h-0 px-6 space-y-4 py-4",children:[s.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"章节ID *"}),s.jsx(ae,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如: 9.15",value:T.id,onChange:A=>O({...T,id:A.target.value})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"价格 (元)"}),s.jsx(ae,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:T.isFree?0:T.price,onChange:A=>O({...T,price:Number(A.target.value),isFree:Number(A.target.value)===0}),disabled:T.isFree})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"免费"}),s.jsx("div",{className:"flex items-center h-10",children:s.jsxs("label",{className:"flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:T.isFree,onChange:A=>O({...T,isFree:A.target.checked,price:A.target.checked?0:1}),className:"w-5 h-5 rounded border-gray-600 bg-[#0a1628] text-[#38bdac] focus:ring-[#38bdac]"}),s.jsx("span",{className:"ml-2 text-gray-400 text-sm",children:"设为免费"})]})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"最新新增"}),s.jsx("div",{className:"flex items-center h-10",children:s.jsxs("label",{className:"flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:T.isNew,onChange:A=>O({...T,isNew:A.target.checked}),className:"w-5 h-5 rounded border-gray-600 bg-[#0a1628] text-[#38bdac] focus:ring-[#38bdac]"}),s.jsx("span",{className:"ml-2 text-gray-400 text-sm",children:"标记 NEW"})]})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"小程序直推"}),s.jsx("div",{className:"flex items-center h-10",children:s.jsxs("label",{className:"flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:T.isPinned,onChange:A=>O({...T,isPinned:A.target.checked}),className:"w-5 h-5 rounded border-gray-600 bg-[#0a1628] text-amber-400 focus:ring-amber-400"}),s.jsx("span",{className:"ml-2 text-gray-400 text-sm",children:"强制置顶到小程序首页"})]})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"文章类型"}),s.jsxs("div",{className:"flex items-center gap-4 h-10",children:[s.jsxs("label",{className:"flex items-center cursor-pointer",children:[s.jsx("input",{type:"radio",name:"new-edition-type",checked:T.editionPremium!==!0,onChange:()=>O({...T,editionStandard:!0,editionPremium:!1}),className:"w-4 h-4 border-gray-600 bg-[#0a1628] text-[#38bdac] focus:ring-[#38bdac]"}),s.jsx("span",{className:"ml-2 text-gray-400 text-sm",children:"普通版"})]}),s.jsxs("label",{className:"flex items-center cursor-pointer",children:[s.jsx("input",{type:"radio",name:"new-edition-type",checked:T.editionPremium===!0,onChange:()=>O({...T,editionStandard:!1,editionPremium:!0}),className:"w-4 h-4 border-gray-600 bg-[#0a1628] text-[#38bdac] focus:ring-[#38bdac]"}),s.jsx("span",{className:"ml-2 text-gray-400 text-sm",children:"增值版"})]})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"热度分"}),s.jsx(ae,{type:"number",step:"0.1",min:"0",className:"bg-[#0a1628] border-gray-700 text-white",value:T.hotScore??0,onChange:A=>O({...T,hotScore:Math.max(0,parseFloat(A.target.value)||0)})})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"章节标题 *"}),s.jsx(ae,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"输入章节标题",value:T.title,onChange:A=>O({...T,title:A.target.value})})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"所属篇"}),s.jsxs(ul,{value:T.partId,onValueChange:A=>{var me;const K=Xt.find(ye=>ye.id===A);O({...T,partId:A,chapterId:((me=K==null?void 0:K.chapters[0])==null?void 0:me.id)??"chapter-1"})},children:[s.jsx(Xa,{className:"bg-[#0a1628] border-gray-700 text-white",children:s.jsx(hl,{})}),s.jsxs(Za,{className:"bg-[#0f2137] border-gray-700",children:[Xt.map(A=>s.jsx(Er,{value:A.id,className:"text-white hover:bg-[#38bdac]/20 focus:bg-[#38bdac]/20",children:A.title},A.id)),Xt.length===0&&s.jsx(Er,{value:"part-1",className:"text-white hover:bg-[#38bdac]/20 focus:bg-[#38bdac]/20",children:"默认篇"})]})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"所属章"}),s.jsxs(ul,{value:T.chapterId,onValueChange:A=>O({...T,chapterId:A}),children:[s.jsx(Xa,{className:"bg-[#0a1628] border-gray-700 text-white",children:s.jsx(hl,{})}),s.jsxs(Za,{className:"bg-[#0f2137] border-gray-700",children:[vd.map(A=>s.jsx(Er,{value:A.id,className:"text-white hover:bg-[#38bdac]/20 focus:bg-[#38bdac]/20",children:A.title},A.id)),vd.length===0&&s.jsx(Er,{value:"chapter-1",className:"text-white hover:bg-[#38bdac]/20 focus:bg-[#38bdac]/20",children:"默认章"})]})]})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"内容(富文本编辑器,支持 @链接AI人物 和 #链接标签)"}),s.jsx(yx,{content:T.content||"",onChange:A=>O({...T,content:A}),onImageUpload:async A=>{var wt;const K=new FormData;K.append("file",A),K.append("folder","book-images");const ye=await(await fetch(ho("/api/upload"),{method:"POST",body:K,headers:{Authorization:`Bearer ${localStorage.getItem("admin_token")||""}`}})).json();return((wt=ye==null?void 0:ye.data)==null?void 0:wt.url)||(ye==null?void 0:ye.url)||""},persons:Nr,linkTags:Dr,placeholder:"开始编辑内容... 输入 @ 可链接AI人物,工具栏可插入 #链接标签"})]})]}),s.jsxs(hn,{className:"shrink-0 px-6 py-4 border-t border-gray-700/50",children:[s.jsx(ne,{variant:"outline",onClick:()=>h(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"取消"}),s.jsx(ne,{onClick:Xe,disabled:g||!T.id||!T.title,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:g?s.jsxs(s.Fragment,{children:[s.jsx(Ke,{className:"w-4 h-4 mr-2 animate-spin"}),"创建中..."]}):s.jsxs(s.Fragment,{children:[s.jsx(rn,{className:"w-4 h-4 mr-2"}),"创建章节"]})})]})]})}),s.jsx(Kt,{open:!!F,onOpenChange:A=>!A&&I(null),children:s.jsxs(Vt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",showCloseButton:!0,children:[s.jsx(qt,{children:s.jsxs(Gt,{className:"text-white flex items-center gap-2",children:[s.jsx(Rt,{className:"w-5 h-5 text-[#38bdac]"}),"编辑篇名"]})}),F&&s.jsx("div",{className:"space-y-4 py-4",children:s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"篇名"}),s.jsx(ae,{className:"bg-[#0a1628] border-gray-700 text-white",value:F.title,onChange:A=>I({...F,title:A.target.value}),placeholder:"输入篇名"})]})}),s.jsxs(hn,{children:[s.jsx(ne,{variant:"outline",onClick:()=>I(null),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"取消"}),s.jsx(ne,{onClick:Io,disabled:R||!((Po=F==null?void 0:F.title)!=null&&Po.trim()),className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:R?s.jsxs(s.Fragment,{children:[s.jsx(Ke,{className:"w-4 h-4 mr-2 animate-spin"}),"保存中..."]}):s.jsxs(s.Fragment,{children:[s.jsx(cn,{className:"w-4 h-4 mr-2"}),"保存"]})})]})]})}),s.jsx(Kt,{open:!!te,onOpenChange:A=>!A&&Y(null),children:s.jsxs(Vt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",showCloseButton:!0,children:[s.jsx(qt,{children:s.jsxs(Gt,{className:"text-white flex items-center gap-2",children:[s.jsx(Rt,{className:"w-5 h-5 text-[#38bdac]"}),"编辑章节名称"]})}),te&&s.jsx("div",{className:"space-y-4 py-4",children:s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"章节名称(如:第8章|底层结构)"}),s.jsx(ae,{className:"bg-[#0a1628] border-gray-700 text-white",value:te.title,onChange:A=>Y({...te,title:A.target.value}),placeholder:"输入章节名称"})]})}),s.jsxs(hn,{children:[s.jsx(ne,{variant:"outline",onClick:()=>Y(null),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"取消"}),s.jsx(ne,{onClick:ns,disabled:U||!((mt=te==null?void 0:te.title)!=null&&mt.trim()),className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:U?s.jsxs(s.Fragment,{children:[s.jsx(Ke,{className:"w-4 h-4 mr-2 animate-spin"}),"保存中..."]}):s.jsxs(s.Fragment,{children:[s.jsx(cn,{className:"w-4 h-4 mr-2"}),"保存"]})})]})]})}),s.jsx(Kt,{open:_,onOpenChange:A=>{var K;if(se(A),A&&Xt.length>0){const me=Xt[0];z(me.id),ue(((K=me.chapters[0])==null?void 0:K.id)??"")}},children:s.jsxs(Vt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",showCloseButton:!0,children:[s.jsx(qt,{children:s.jsx(Gt,{className:"text-white",children:"批量移动至指定目录"})}),s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsxs("p",{className:"text-gray-400 text-sm",children:["已选 ",s.jsx("span",{className:"text-[#38bdac] font-medium",children:$.length})," 节,请选择目标篇与章。"]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"目标篇"}),s.jsxs(ul,{value:J,onValueChange:A=>{var me;z(A);const K=Xt.find(ye=>ye.id===A);ue(((me=K==null?void 0:K.chapters[0])==null?void 0:me.id)??"")},children:[s.jsx(Xa,{className:"bg-[#0a1628] border-gray-700 text-white",children:s.jsx(hl,{placeholder:"选择篇"})}),s.jsx(Za,{className:"bg-[#0f2137] border-gray-700",children:Xt.map(A=>s.jsx(Er,{value:A.id,className:"text-white hover:bg-[#38bdac]/20 focus:bg-[#38bdac]/20",children:A.title},A.id))})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"目标章"}),s.jsxs(ul,{value:W,onValueChange:ue,children:[s.jsx(Xa,{className:"bg-[#0a1628] border-gray-700 text-white",children:s.jsx(hl,{placeholder:"选择章"})}),s.jsx(Za,{className:"bg-[#0f2137] border-gray-700",children:(((Ul=Xt.find(A=>A.id===J))==null?void 0:Ul.chapters)??[]).map(A=>s.jsx(Er,{value:A.id,className:"text-white hover:bg-[#38bdac]/20 focus:bg-[#38bdac]/20",children:A.title},A.id))})]})]})]}),s.jsxs(hn,{children:[s.jsx(ne,{variant:"outline",onClick:()=>se(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"取消"}),s.jsx(ne,{onClick:Wl,disabled:G||$.length===0,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:G?s.jsxs(s.Fragment,{children:[s.jsx(Ke,{className:"w-4 h-4 mr-2 animate-spin"}),"移动中..."]}):"确认移动"})]})]})}),s.jsx(Kt,{open:!!V,onOpenChange:A=>!A&&be(null),children:s.jsxs(Vt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-3xl max-h-[85vh] overflow-hidden flex flex-col",showCloseButton:!0,children:[s.jsx(qt,{children:s.jsxs(Gt,{className:"text-white",children:["付款记录 — ",(V==null?void 0:V.section.title)??""]})}),s.jsx("div",{className:"flex-1 overflow-y-auto py-2",children:Me?s.jsxs("div",{className:"flex items-center justify-center py-8",children:[s.jsx(Ke,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):V&&V.orders.length===0?s.jsx("p",{className:"text-gray-500 text-center py-6",children:"暂无付款记录"}):V?s.jsxs("table",{className:"w-full text-sm border-collapse",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"border-b border-gray-700 text-left text-gray-400",children:[s.jsx("th",{className:"py-2 pr-2",children:"订单号"}),s.jsx("th",{className:"py-2 pr-2",children:"用户ID"}),s.jsx("th",{className:"py-2 pr-2",children:"金额"}),s.jsx("th",{className:"py-2 pr-2",children:"状态"}),s.jsx("th",{className:"py-2 pr-2",children:"支付时间"})]})}),s.jsx("tbody",{children:V.orders.map(A=>s.jsxs("tr",{className:"border-b border-gray-700/50",children:[s.jsx("td",{className:"py-2 pr-2",children:s.jsx("button",{className:"text-blue-400 hover:text-blue-300 hover:underline text-left truncate max-w-[180px] block",title:`查看订单 ${A.orderSn}`,onClick:()=>window.open(`/orders?search=${A.orderSn??A.id??""}`,"_blank"),children:A.orderSn?A.orderSn.length>16?A.orderSn.slice(0,8)+"..."+A.orderSn.slice(-6):A.orderSn:"-"})}),s.jsx("td",{className:"py-2 pr-2",children:s.jsx("button",{className:"text-[#38bdac] hover:text-[#2da396] hover:underline text-left truncate max-w-[140px] block",title:`查看用户 ${A.userId??A.openId??""}`,onClick:()=>window.open(`/users?search=${A.userId??A.openId??""}`,"_blank"),children:(()=>{const K=A.userId??A.openId??"-";return K.length>12?K.slice(0,6)+"..."+K.slice(-4):K})()})}),s.jsxs("td",{className:"py-2 pr-2 text-gray-300",children:["¥",A.amount??0]}),s.jsx("td",{className:"py-2 pr-2 text-gray-300",children:A.status??"-"}),s.jsx("td",{className:"py-2 pr-2 text-gray-500",children:A.payTime??A.createdAt??"-"})]},A.id??A.orderSn??""))})]}):null})]})}),s.jsx(Kt,{open:nt,onOpenChange:dt,children:s.jsxs(Vt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",showCloseButton:!0,children:[s.jsx(qt,{children:s.jsxs(Gt,{className:"text-white flex items-center gap-2",children:[s.jsx(Nu,{className:"w-5 h-5 text-amber-400"}),"文章排名算法"]})}),s.jsxs("div",{className:"space-y-4 py-2",children:[s.jsx("p",{className:"text-sm text-gray-400",children:"热度积分 = 阅读权重×阅读排名分 + 新度权重×新度排名分 + 付款权重×付款排名分(三权重之和须为 1)"}),Tt?s.jsx("p",{className:"text-gray-500",children:"加载中..."}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsx(Z,{className:"text-gray-400 text-xs",children:"阅读权重"}),s.jsx(ae,{type:"number",step:"0.1",min:"0",max:"1",className:"bg-[#0a1628] border-gray-700 text-white",value:Ye.readWeight,onChange:A=>ht(K=>({...K,readWeight:Math.max(0,Math.min(1,parseFloat(A.target.value)||0))}))})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(Z,{className:"text-gray-400 text-xs",children:"新度权重"}),s.jsx(ae,{type:"number",step:"0.1",min:"0",max:"1",className:"bg-[#0a1628] border-gray-700 text-white",value:Ye.recencyWeight,onChange:A=>ht(K=>({...K,recencyWeight:Math.max(0,Math.min(1,parseFloat(A.target.value)||0))}))})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(Z,{className:"text-gray-400 text-xs",children:"付款权重"}),s.jsx(ae,{type:"number",step:"0.1",min:"0",max:"1",className:"bg-[#0a1628] border-gray-700 text-white",value:Ye.payWeight,onChange:A=>ht(K=>({...K,payWeight:Math.max(0,Math.min(1,parseFloat(A.target.value)||0))}))})]})]}),s.jsxs("p",{className:"text-xs text-gray-500",children:["当前之和: ",(Ye.readWeight+Ye.recencyWeight+Ye.payWeight).toFixed(1)]}),s.jsxs("ul",{className:"list-disc list-inside space-y-1 text-xs text-gray-400",children:[s.jsx("li",{children:"阅读量前 20 名:第1名=20分、第2名=19分...第20名=1分"}),s.jsx("li",{children:"最近更新前 30 篇:第1名=30分、第2名=29分...第30名=1分"}),s.jsx("li",{children:"付款数前 20 名:第1名=20分、第2名=19分...第20名=1分"}),s.jsx("li",{children:"热度分可在编辑章节中手动覆盖"})]}),s.jsx(ne,{onClick:Ra,disabled:Mt||Math.abs(Ye.readWeight+Ye.recencyWeight+Ye.payWeight-1)>.001,className:"w-full bg-amber-500 hover:bg-amber-600 text-white",children:Mt?"保存中...":"保存权重"})]})]})]})}),s.jsx(Kt,{open:L,onOpenChange:ee,children:s.jsxs(Vt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-md",showCloseButton:!0,children:[s.jsx(qt,{children:s.jsxs(Gt,{className:"text-white flex items-center gap-2",children:[s.jsx(rn,{className:"w-5 h-5 text-amber-400"}),"新建篇"]})}),s.jsx("div",{className:"space-y-4 py-4",children:s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"篇名(如:第六篇|真实的社会)"}),s.jsx(ae,{className:"bg-[#0a1628] border-gray-700 text-white",value:X,onChange:A=>ce(A.target.value),placeholder:"输入篇名"})]})}),s.jsxs(hn,{children:[s.jsx(ne,{variant:"outline",onClick:()=>{ee(!1),ce("")},className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"取消"}),s.jsx(ne,{onClick:Ys,disabled:he||!X.trim(),className:"bg-amber-500 hover:bg-amber-600 text-white",children:he?s.jsxs(s.Fragment,{children:[s.jsx(Ke,{className:"w-4 h-4 mr-2 animate-spin"}),"创建中..."]}):s.jsxs(s.Fragment,{children:[s.jsx(rn,{className:"w-4 h-4 mr-2"}),"创建篇"]})})]})]})}),s.jsx(Kt,{open:!!o,onOpenChange:()=>c(null),children:s.jsxs(Vt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-4xl max-h-[90vh] flex flex-col p-0 gap-0",showCloseButton:!0,children:[s.jsx(qt,{className:"shrink-0 px-6 pt-6 pb-2",children:s.jsxs(Gt,{className:"text-white flex items-center gap-2",children:[s.jsx(Rt,{className:"w-5 h-5 text-[#38bdac]"}),"编辑章节"]})}),o&&s.jsxs("div",{className:"flex-1 overflow-y-auto min-h-0 px-6 space-y-4 py-4",children:[s.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"章节ID"}),s.jsx(ae,{className:"bg-[#0a1628] border-gray-700 text-white",value:o.id,onChange:A=>c({...o,id:A.target.value}),placeholder:"如: 9.15"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"价格 (元)"}),s.jsx(ae,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:o.isFree?0:o.price,onChange:A=>c({...o,price:Number(A.target.value),isFree:Number(A.target.value)===0}),disabled:o.isFree})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"免费"}),s.jsx("div",{className:"flex items-center h-10",children:s.jsxs("label",{className:"flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:o.isFree||o.price===0,onChange:A=>c({...o,isFree:A.target.checked,price:A.target.checked?0:1}),className:"w-5 h-5 rounded border-gray-600 bg-[#0a1628] text-[#38bdac] focus:ring-[#38bdac]"}),s.jsx("span",{className:"ml-2 text-gray-400 text-sm",children:"设为免费"})]})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"最新新增"}),s.jsx("div",{className:"flex items-center h-10",children:s.jsxs("label",{className:"flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:o.isNew??!1,onChange:A=>c({...o,isNew:A.target.checked}),className:"w-5 h-5 rounded border-gray-600 bg-[#0a1628] text-[#38bdac] focus:ring-[#38bdac]"}),s.jsx("span",{className:"ml-2 text-gray-400 text-sm",children:"标记 NEW"})]})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"小程序直推"}),s.jsx("div",{className:"flex items-center h-10",children:s.jsxs("label",{className:"flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:o.isPinned??!1,onChange:A=>c({...o,isPinned:A.target.checked}),className:"w-5 h-5 rounded border-gray-600 bg-[#0a1628] text-amber-400 focus:ring-amber-400"}),s.jsx("span",{className:"ml-2 text-gray-400 text-sm",children:"强制置顶到小程序首页"})]})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"文章类型"}),s.jsxs("div",{className:"flex items-center gap-4 h-10",children:[s.jsxs("label",{className:"flex items-center cursor-pointer",children:[s.jsx("input",{type:"radio",name:"edition-type",checked:o.editionPremium!==!0,onChange:()=>c({...o,editionStandard:!0,editionPremium:!1}),className:"w-4 h-4 border-gray-600 bg-[#0a1628] text-[#38bdac] focus:ring-[#38bdac]"}),s.jsx("span",{className:"ml-2 text-gray-400 text-sm",children:"普通版"})]}),s.jsxs("label",{className:"flex items-center cursor-pointer",children:[s.jsx("input",{type:"radio",name:"edition-type",checked:o.editionPremium===!0,onChange:()=>c({...o,editionStandard:!1,editionPremium:!0}),className:"w-4 h-4 border-gray-600 bg-[#0a1628] text-[#38bdac] focus:ring-[#38bdac]"}),s.jsx("span",{className:"ml-2 text-gray-400 text-sm",children:"增值版"})]})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"热度分"}),s.jsx(ae,{type:"number",step:"0.1",min:"0",className:"bg-[#0a1628] border-gray-700 text-white",value:o.hotScore??0,onChange:A=>c({...o,hotScore:Math.max(0,parseFloat(A.target.value)||0)})})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"章节标题"}),s.jsx(ae,{className:"bg-[#0a1628] border-gray-700 text-white",value:o.title,onChange:A=>c({...o,title:A.target.value})})]}),o.filePath&&s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"文件路径"}),s.jsx(ae,{className:"bg-[#0a1628] border-gray-700 text-gray-400 text-sm",value:o.filePath,disabled:!0})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"内容(富文本编辑器,支持 @链接AI人物 和 #链接标签)"}),f?s.jsxs("div",{className:"bg-[#0a1628] border border-gray-700 rounded-md min-h-[400px] flex items-center justify-center",children:[s.jsx(Ke,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):s.jsx(yx,{ref:ts,content:o.content||"",onChange:A=>c({...o,content:A}),onImageUpload:async A=>{var wt;const K=new FormData;K.append("file",A),K.append("folder","book-images");const ye=await(await fetch(ho("/api/upload"),{method:"POST",body:K,headers:{Authorization:`Bearer ${localStorage.getItem("admin_token")||""}`}})).json();return((wt=ye==null?void 0:ye.data)==null?void 0:wt.url)||(ye==null?void 0:ye.url)||""},persons:Nr,linkTags:Dr,placeholder:"开始编辑内容... 输入 @ 可链接AI人物,工具栏可插入 #链接标签"})]})]}),s.jsxs(hn,{className:"shrink-0 px-6 py-4 border-t border-gray-700/50",children:[o&&s.jsxs(ne,{variant:"outline",onClick:()=>H({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:[s.jsx(Gr,{className:"w-4 h-4 mr-2"}),"付款记录"]}),s.jsxs(ne,{variant:"outline",onClick:()=>c(null),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(or,{className:"w-4 h-4 mr-2"}),"取消"]}),s.jsx(ne,{onClick:Je,disabled:g,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:g?s.jsxs(s.Fragment,{children:[s.jsx(Ke,{className:"w-4 h-4 mr-2 animate-spin"}),"保存中..."]}):s.jsxs(s.Fragment,{children:[s.jsx(cn,{className:"w-4 h-4 mr-2"}),"保存修改"]})})]})]})}),s.jsxs(fd,{defaultValue:"chapters",className:"space-y-6",children:[s.jsxs(Ll,{className:"bg-[#0f2137] border border-gray-700/50 p-1",children:[s.jsxs(Jt,{value:"chapters",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-gray-400",children:[s.jsx(Gr,{className:"w-4 h-4 mr-2"}),"章节管理"]}),s.jsxs(Jt,{value:"ranking",className:"data-[state=active]:bg-amber-500/20 data-[state=active]:text-amber-400 text-gray-400",children:[s.jsx(_b,{className:"w-4 h-4 mr-2"}),"内容排行榜"]}),s.jsxs(Jt,{value:"search",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-gray-400",children:[s.jsx(da,{className:"w-4 h-4 mr-2"}),"内容搜索"]}),s.jsxs(Jt,{value:"link-person",className:"data-[state=active]:bg-purple-500/20 data-[state=active]:text-purple-400 text-gray-400",children:[s.jsx(ps,{className:"w-4 h-4 mr-2"}),"链接人与事"]}),s.jsxs(Jt,{value:"link-tag",className:"data-[state=active]:bg-amber-500/20 data-[state=active]:text-amber-400 text-gray-400",children:[s.jsx(Db,{className:"w-4 h-4 mr-2"}),"链接标签"]}),s.jsxs(Jt,{value:"linkedmp",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-gray-400",children:[s.jsx(uo,{className:"w-4 h-4 mr-2"}),"关联小程序"]})]}),s.jsxs(Yt,{value:"chapters",className:"space-y-4",children:[s.jsxs("div",{className:"rounded-2xl border border-gray-700/50 bg-[#1C1C1E] p-4 flex items-center justify-between shadow-sm",children:[s.jsxs("div",{className:"flex items-center gap-4",children:[s.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:s.jsx(Gr,{className:"w-6 h-6"})}),s.jsxs("div",{children:[s.jsx("h2",{className:"font-bold text-base text-white leading-tight mb-1",children:"一场SOUL的创业实验场"}),s.jsx("p",{className:"text-xs text-gray-500",children:"来自Soul派对房的真实商业故事"})]})]}),s.jsxs("div",{className:"text-center shrink-0",children:[s.jsx("span",{className:"block text-2xl font-bold text-[#38bdac]",children:Lr}),s.jsx("span",{className:"text-xs text-gray-500",children:"章节"})]})]}),s.jsxs("div",{className:"flex flex-wrap gap-2",children:[s.jsxs(ne,{onClick:()=>h(!0),className:"flex-1 min-w-[120px] bg-[#38bdac]/10 hover:bg-[#38bdac]/20 text-[#38bdac] border border-[#38bdac]/30",children:[s.jsx(rn,{className:"w-4 h-4 mr-2"}),"新建章节"]}),s.jsxs(ne,{onClick:()=>ee(!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:[s.jsx(rn,{className:"w-4 h-4 mr-2"}),"新建篇"]}),s.jsxs(ne,{variant:"outline",onClick:()=>se(!0),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:["批量移动(已选 ",$.length," 节)"]})]}),n?s.jsxs("div",{className:"flex items-center justify-center py-12",children:[s.jsx(Ke,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):s.jsx(YB,{parts:Xt,expandedParts:i,onTogglePart:Hl,onReorder:Ei,onReadSection:Pe,onDeleteSection:qs,onAddSectionInPart:wn,onAddChapterInPart:Ft,onDeleteChapter:Ss,onEditPart:rr,onDeletePart:Ii,onEditChapter:In,selectedSectionIds:$,onToggleSectionSelect:La,onShowSectionOrders:H,pinnedSectionIds:Qt})]}),s.jsx(Yt,{value:"search",className:"space-y-4",children:s.jsxs(Ae,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsx(et,{children:s.jsx(tt,{className:"text-white",children:"内容搜索"})}),s.jsxs(Ie,{className:"space-y-4",children:[s.jsxs("div",{className:"flex gap-2",children:[s.jsx(ae,{className:"bg-[#0a1628] border-gray-700 text-white placeholder:text-gray-500 flex-1",placeholder:"搜索标题或内容...",value:v,onChange:A=>w(A.target.value),onKeyDown:A=>A.key==="Enter"&&Ro()}),s.jsx(ne,{onClick:Ro,disabled:E||!v.trim(),className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:E?s.jsx(Ke,{className:"w-4 h-4 animate-spin"}):s.jsx(da,{className:"w-4 h-4"})})]}),N.length>0&&s.jsxs("div",{className:"space-y-2 mt-4",children:[s.jsxs("p",{className:"text-gray-400 text-sm",children:["找到 ",N.length," 个结果"]}),N.map(A=>s.jsxs("div",{className:"p-3 rounded-lg bg-[#162840] hover:bg-[#1a3050] cursor-pointer transition-colors",onClick:()=>Pe({id:A.id,title:A.title,price:A.price??1,filePath:""}),children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-[#38bdac] font-mono text-xs",children:A.id}),s.jsx("span",{className:"text-white",children:A.title}),Qt.includes(A.id)&&s.jsx(ml,{className:"w-3 h-3 text-amber-400 fill-amber-400 shrink-0"})]}),s.jsx(He,{variant:"outline",className:"text-gray-400 border-gray-600 text-xs",children:A.matchType==="title"?"标题匹配":"内容匹配"})]}),A.snippet&&s.jsx("p",{className:"text-gray-500 text-xs mt-2 line-clamp-2",children:A.snippet}),(A.partTitle||A.chapterTitle)&&s.jsxs("p",{className:"text-gray-600 text-xs mt-1",children:[A.partTitle," · ",A.chapterTitle]})]},A.id))]})]})]})}),s.jsxs(Yt,{value:"ranking",className:"space-y-4",children:[s.jsxs(Ae,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsx(et,{className:"pb-3",children:s.jsxs(tt,{className:"text-white text-base flex items-center gap-2",children:[s.jsx(Nu,{className:"w-4 h-4 text-[#38bdac]"}),"内容显示规则"]})}),s.jsx(Ie,{children:s.jsxs("div",{className:"flex items-center gap-4 flex-wrap",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Z,{className:"text-gray-400 text-sm whitespace-nowrap",children:"未付费预览比例"}),s.jsx(ae,{type:"number",min:"1",max:"100",className:"bg-[#0a1628] border-gray-700 text-white w-20",value:pe,onChange:A=>ve(Math.max(1,Math.min(100,Number(A.target.value)||20))),disabled:tr}),s.jsx("span",{className:"text-gray-500 text-sm",children:"%"})]}),s.jsx(ne,{size:"sm",onClick:Da,disabled:ki,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:ki?"保存中...":"保存"}),s.jsxs("span",{className:"text-xs text-gray-500",children:["小程序未付费用户默认显示文章前 ",pe,"% 内容"]})]})})]}),s.jsxs(Ae,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsx(et,{className:"pb-3",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs(tt,{className:"text-white text-base flex items-center gap-2",children:[s.jsx(_b,{className:"w-4 h-4 text-amber-400"}),"内容排行榜",s.jsxs("span",{className:"text-xs text-gray-500 font-normal ml-2",children:["按热度排行 · 共 ",Or.length," 节"]})]}),s.jsxs("div",{className:"flex items-center gap-1 text-sm",children:[s.jsx(ne,{variant:"ghost",size:"sm",onClick:()=>Ns(),disabled:br,className:"text-gray-400 hover:text-white h-7 w-7 p-0",title:"刷新排行榜",children:s.jsx(Ke,{className:`w-4 h-4 ${br?"animate-spin":""}`})}),s.jsx(ne,{variant:"ghost",size:"sm",disabled:Zn<=1||br,onClick:()=>Pr(A=>Math.max(1,A-1)),className:"text-gray-400 hover:text-white h-7 w-7 p-0",children:s.jsx(VT,{className:"w-4 h-4"})}),s.jsxs("span",{className:"text-gray-400 min-w-[60px] text-center",children:[Zn," / ",_r]}),s.jsx(ne,{variant:"ghost",size:"sm",disabled:Zn>=_r||br,onClick:()=>Pr(A=>Math.min(_r,A+1)),className:"text-gray-400 hover:text-white h-7 w-7 p-0",children:s.jsx(fl,{className:"w-4 h-4"})})]})]})}),s.jsx(Ie,{children:s.jsxs("div",{className:"space-y-0",children:[s.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:[s.jsx("span",{children:"排名"}),s.jsx("span",{children:"置顶"}),s.jsx("span",{children:"标题"}),s.jsx("span",{className:"text-right",children:"点击量"}),s.jsx("span",{className:"text-right",children:"付款数"}),s.jsx("span",{className:"text-right",children:"热度"}),s.jsx("span",{className:"text-right",children:"编辑"})]}),Ks.map((A,K)=>{const me=(Zn-1)*Us+K+1,ye=A.isPinned??Qt.includes(A.id);return s.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 ${ye?"bg-amber-500/5":""}`,children:[s.jsx("span",{className:`text-sm font-bold ${me<=3?"text-amber-400":"text-gray-500"}`,children:me<=3?["🥇","🥈","🥉"][me-1]:`#${me}`}),s.jsx(ne,{variant:"ghost",size:"sm",className:`h-6 w-6 p-0 ${ye?"text-amber-400":"text-gray-600 hover:text-amber-400"}`,onClick:()=>ks(A.id),disabled:Xr,title:ye?"取消置顶":"强制置顶(精选推荐/首页最新更新)",children:ye?s.jsx(ml,{className:"w-3.5 h-3.5 fill-current"}):s.jsx(hA,{className:"w-3.5 h-3.5"})}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("span",{className:"text-white text-sm truncate block",children:A.title}),s.jsxs("span",{className:"text-gray-600 text-xs",children:[A.partTitle," · ",A.chapterTitle]})]}),s.jsx("span",{className:"text-right text-sm text-blue-400 font-mono",children:A.clickCount??0}),s.jsx("span",{className:"text-right text-sm text-green-400 font-mono",children:A.payCount??0}),s.jsx("span",{className:"text-right text-sm text-amber-400 font-mono",children:(A.hotScore??0).toFixed(1)}),s.jsx("div",{className:"text-right",children:s.jsx(ne,{variant:"ghost",size:"sm",className:"text-gray-500 hover:text-[#38bdac] h-6 px-1",onClick:()=>Pe({id:A.id,title:A.title,price:A.price,filePath:""}),title:"编辑文章",children:s.jsx(Rt,{className:"w-3 h-3"})})})]},A.id)}),Ks.length===0&&s.jsx("div",{className:"py-8 text-center text-gray-500",children:"暂无数据"})]})})]})]}),s.jsxs(Yt,{value:"link-person",className:"space-y-4",children:[s.jsxs(Ae,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(et,{className:"pb-3",children:[s.jsxs(tt,{className:"text-white text-base flex items-center gap-2",children:[s.jsx("span",{className:"text-[#38bdac] text-lg font-bold",children:"@"}),"AI列表 — 链接人与事(编辑器内输入 @ 可链接)"]}),s.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"添加时自动生成 32 位 token,文章 @ 时存 token;小程序点击 @ 时用 token 兑换真实密钥后加好友"})]}),s.jsxs(Ie,{className:"space-y-3",children:[s.jsxs("div",{className:"flex justify-between items-center",children:[s.jsx("p",{className:"text-xs text-gray-500",children:"添加人物时同步创建存客宝场景获客计划,配置与存客宝 API 获客一致"}),s.jsxs(ne,{size:"sm",className:"bg-[#38bdac] hover:bg-[#2da396] text-white",onClick:()=>{Ws(null),Ci(!0)},children:[s.jsx(rn,{className:"w-4 h-4 mr-2"}),"添加"]})]}),s.jsxs("div",{className:"space-y-1 max-h-[400px] overflow-y-auto",children:[Nr.length>0&&s.jsxs("div",{className:"flex items-center gap-4 px-3 py-1.5 text-xs text-gray-500 border-b border-gray-700/50",children:[s.jsx("span",{className:"w-[280px] shrink-0",children:"token"}),s.jsx("span",{className:"w-24 shrink-0",children:"@的人"}),s.jsx("span",{children:"获客计划活动名"})]}),Nr.map(A=>s.jsxs("div",{className:"bg-[#0a1628] rounded px-3 py-2 flex items-center justify-between gap-3",children:[s.jsxs("div",{className:"flex items-center gap-4 text-sm min-w-0",children:[s.jsx("span",{className:"text-gray-400 text-xs font-mono shrink-0 w-[280px]",title:"32位token",children:A.id}),s.jsx("span",{className:"text-amber-400 shrink-0 w-24 truncate",title:"@的人",children:A.name}),s.jsxs("span",{className:"text-white truncate",title:"获客计划活动名",children:["SOUL链接人与事-",A.name]})]}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx(ne,{variant:"ghost",size:"sm",className:"text-gray-400 hover:text-[#38bdac] h-6 px-2",title:"编辑",onClick:async()=>{try{const K=await XB(A.personId||"");if(K!=null&&K.success&&K.person){const me=K.person;Ws({id:me.token??me.personId,personId:me.personId,name:me.name,label:me.label??"",ckbApiKey:me.ckbApiKey??"",remarkType:me.remarkType,remarkFormat:me.remarkFormat,addFriendInterval:me.addFriendInterval,startTime:me.startTime,endTime:me.endTime,deviceGroups:me.deviceGroups})}else Ws(A),K!=null&&K.error&&oe.error(K.error)}catch(K){console.error(K),Ws(A),oe.error(K instanceof Error?K.message:"加载人物详情失败")}Ci(!0)},children:s.jsx(qw,{className:"w-3 h-3"})}),s.jsx(ne,{variant:"ghost",size:"sm",className:"text-gray-400 hover:text-amber-400 h-6 px-2",title:"编辑计划(跳转存客宝)",onClick:()=>{const K=A.ckbPlanId;K?window.open(`https://h5.ckb.quwanzhi.com/#/scenarios/edit/${K}`,"_blank"):oe.info("该人物尚未同步存客宝计划,请先保存后等待同步完成")},children:s.jsx(_s,{className:"w-3 h-3"})}),s.jsx(ne,{variant:"ghost",size:"sm",className:"text-red-400 hover:text-red-300 h-6 px-2",title:"删除(同时删除存客宝对应获客计划)",onClick:async()=>{confirm(`确定删除「SOUL链接人与事-${A.name}」?将同时删除存客宝对应获客计划。`)&&(await Ps(`/api/db/persons?personId=${A.personId}`),Gs())},children:s.jsx(or,{className:"w-3 h-3"})})]})]},A.id)),Nr.length===0&&s.jsx("div",{className:"text-gray-500 text-sm py-4 text-center",children:"暂无AI人物,添加后可在编辑器中 @链接"})]})]})]}),s.jsxs(Ae,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(et,{className:"pb-3",children:[s.jsxs(tt,{className:"text-white text-base flex items-center gap-2",children:[s.jsx(Nu,{className:"w-4 h-4 text-green-400"}),"存客宝绑定"]}),s.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"配置存客宝 API 后,文章中 @人物 或 #标签 点击可自动进入存客宝流量池"})]}),s.jsxs(Ie,{className:"space-y-3",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-400 text-xs",children:"存客宝 API 地址"}),s.jsx(ae,{className:"bg-[#0a1628] border-gray-700 text-white h-8",placeholder:"https://ckbapi.quwanzhi.com",defaultValue:"https://ckbapi.quwanzhi.com",readOnly:!0})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-400 text-xs",children:"绑定计划"}),s.jsx(ae,{className:"bg-[#0a1628] border-gray-700 text-white h-8",placeholder:"创业实验-内容引流",defaultValue:"创业实验-内容引流",readOnly:!0})]})]}),s.jsxs("p",{className:"text-xs text-gray-500",children:["具体存客宝场景配置与接口测试请前往"," ",s.jsx("button",{className:"text-[#38bdac] hover:underline",onClick:()=>window.open("/match","_blank"),children:"找伙伴 → 存客宝工作台"})]})]})]})]}),s.jsx(Yt,{value:"link-tag",className:"space-y-4",children:s.jsxs(Ae,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(et,{className:"pb-3",children:[s.jsxs(tt,{className:"text-white text-base flex items-center gap-2",children:[s.jsx(Db,{className:"w-4 h-4 text-amber-400"}),"链接标签 — 链接事与物(编辑器内 #标签 可跳转链接/小程序/存客宝)"]}),s.jsx("p",{className:"text-xs text-gray-500 mt-1",children:"小程序端点击 #标签 可直接跳转对应链接,进入流量池"})]}),s.jsxs(Ie,{className:"space-y-3",children:[s.jsxs("div",{className:"flex gap-2 items-end flex-wrap",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-400 text-xs",children:"标签ID"}),s.jsx(ae,{className:"bg-[#0a1628] border-gray-700 text-white h-8 w-24",placeholder:"如 team01",value:at.tagId,onChange:A=>An({...at,tagId:A.target.value})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-400 text-xs",children:"显示文字"}),s.jsx(ae,{className:"bg-[#0a1628] border-gray-700 text-white h-8 w-28",placeholder:"如 神仙团队",value:at.label,onChange:A=>An({...at,label:A.target.value})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-400 text-xs",children:"类型"}),s.jsxs(ul,{value:at.type,onValueChange:A=>An({...at,type:A}),children:[s.jsx(Xa,{className:"bg-[#0a1628] border-gray-700 text-white h-8 w-24",children:s.jsx(hl,{})}),s.jsxs(Za,{children:[s.jsx(Er,{value:"url",children:"网页链接"}),s.jsx(Er,{value:"miniprogram",children:"小程序"}),s.jsx(Er,{value:"ckb",children:"存客宝"})]})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-400 text-xs",children:at.type==="url"?"URL地址":at.type==="ckb"?"存客宝计划URL":"小程序(选密钥)"}),at.type==="miniprogram"&&Mi.length>0?s.jsxs("div",{ref:Ao,className:"relative w-44",children:[s.jsx(ae,{className:"bg-[#0a1628] border-gray-700 text-white h-8 w-44",placeholder:"搜索名称或密钥",value:Mo?js:at.appId,onChange:A=>{const K=A.target.value;Pa(K),kt(!0),Mi.some(me=>me.key===K)||An({...at,appId:K})},onFocus:()=>{Pa(at.appId),kt(!0)},onBlur:()=>setTimeout(()=>kt(!1),150)}),Mo&&s.jsx("div",{className:"absolute top-full left-0 right-0 mt-1 max-h-48 overflow-y-auto rounded-md border border-gray-700 bg-[#0a1628] shadow-lg z-50",children:Ai.length===0?s.jsx("div",{className:"px-3 py-2 text-gray-500 text-xs",children:"无匹配,可手动输入密钥"}):Ai.map(A=>s.jsxs("button",{type:"button",className:"w-full px-3 py-2 text-left text-sm text-white hover:bg-[#38bdac]/20 flex flex-col gap-0.5",onMouseDown:K=>{K.preventDefault(),An({...at,appId:A.key,pagePath:A.path||""}),Pa(""),kt(!1)},children:[s.jsx("span",{children:A.name}),s.jsx("span",{className:"text-xs text-gray-400 font-mono",children:A.key})]},A.key))})]}):s.jsx(ae,{className:"bg-[#0a1628] border-gray-700 text-white h-8 w-44",placeholder:at.type==="url"?"https://...":at.type==="ckb"?"https://ckbapi.quwanzhi.com/...":"关联小程序的32位密钥",value:at.type==="url"||at.type==="ckb"?at.url:at.appId,onChange:A=>{at.type==="url"||at.type==="ckb"?An({...at,url:A.target.value}):An({...at,appId:A.target.value})}})]}),at.type==="miniprogram"&&s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-400 text-xs",children:"页面路径"}),s.jsx(ae,{className:"bg-[#0a1628] border-gray-700 text-white h-8 w-36",placeholder:"pages/index/index",value:at.pagePath,onChange:A=>An({...at,pagePath:A.target.value})})]}),s.jsxs(ne,{size:"sm",className:"bg-amber-500 hover:bg-amber-600 text-white h-8",onClick:async()=>{if(!at.tagId||!at.label){oe.error("标签ID和显示文字必填");return}const A={...at};A.type==="miniprogram"&&(A.url=""),await xt("/api/db/link-tags",A),An({tagId:"",label:"",url:"",type:"url",appId:"",pagePath:""}),wr(null),ws()},children:[s.jsx(rn,{className:"w-3 h-3 mr-1"}),es?"保存":"添加"]})]}),s.jsxs("div",{className:"space-y-1 max-h-[400px] overflow-y-auto",children:[Dr.map(A=>s.jsxs("div",{className:"flex items-center justify-between bg-[#0a1628] rounded px-3 py-2",children:[s.jsxs("div",{className:"flex items-center gap-3 text-sm",children:[s.jsxs("button",{type:"button",className:"text-amber-400 font-bold text-base hover:underline",onClick:()=>{An({tagId:A.id,label:A.label,url:A.url,type:A.type,appId:A.appId??"",pagePath:A.pagePath??""}),wr(A.id)},children:["#",A.label]}),s.jsx(He,{variant:"secondary",className:`text-[10px] ${A.type==="ckb"?"bg-green-500/20 text-green-300 border-green-500/30":"bg-gray-700 text-gray-300"}`,children:A.type==="url"?"网页":A.type==="ckb"?"存客宝":"小程序"}),A.type==="miniprogram"?s.jsxs("span",{className:"text-gray-400 text-xs font-mono",children:[A.appId," ",A.pagePath?`· ${A.pagePath}`:""]}):A.url?s.jsxs("a",{href:A.url,target:"_blank",rel:"noreferrer",className:"text-blue-400 text-xs truncate max-w-[250px] hover:underline flex items-center gap-1",children:[A.url," ",s.jsx(_s,{className:"w-3 h-3 shrink-0"})]}):null]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ne,{variant:"ghost",size:"sm",className:"text-gray-300 hover:text-white h-6 px-2",onClick:()=>{An({tagId:A.id,label:A.label,url:A.url,type:A.type,appId:A.appId??"",pagePath:A.pagePath??""}),wr(A.id)},children:"编辑"}),s.jsx(ne,{variant:"ghost",size:"sm",className:"text-red-400 hover:text-red-300 h-6 px-2",onClick:async()=>{await Ps(`/api/db/link-tags?tagId=${A.id}`),es===A.id&&(wr(null),An({tagId:"",label:"",url:"",type:"url",appId:"",pagePath:""})),ws()},children:s.jsx(or,{className:"w-3 h-3"})})]})]},A.id)),Dr.length===0&&s.jsx("div",{className:"text-gray-500 text-sm py-4 text-center",children:"暂无链接标签,添加后可在编辑器中使用 #标签 跳转"})]})]})]})}),s.jsx(Yt,{value:"linkedmp",className:"space-y-4",children:s.jsx(GB,{})})]}),s.jsx(ZB,{open:nr,onOpenChange:Ci,editingPerson:Ia,onSubmit:async A=>{var me;const K={personId:A.personId||A.name.toLowerCase().replace(/\s+/g,"_")+"_"+Date.now().toString(36),name:A.name,label:A.label,ckbApiKey:A.ckbApiKey||void 0,greeting:A.greeting||void 0,tips:A.tips||void 0,remarkType:A.remarkType||void 0,remarkFormat:A.remarkFormat||void 0,addFriendInterval:A.addFriendInterval,startTime:A.startTime||void 0,endTime:A.endTime||void 0,deviceGroups:(me=A.deviceGroups)!=null&&me.trim()?A.deviceGroups.split(",").map(ye=>parseInt(ye.trim(),10)).filter(ye=>!Number.isNaN(ye)):void 0};await xt("/api/db/persons",K),Gs(),oe.success(Ia?"已保存":"已添加")}})]})}const mi={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 pw(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):mi.stats}function mw(t){return Array.isArray(t)?t.map(e=>typeof e=="string"?e:String(e??"")).filter(Boolean):mi.highlights}function nV(){const[t,e]=b.useState(mi),[n,r]=b.useState(!0),[i,a]=b.useState(!1),[o,c]=b.useState(!1),u=b.useRef(null);b.useEffect(()=>{Le("/api/admin/author-settings").then(k=>{const E=k==null?void 0:k.data;E&&typeof E=="object"&&e({name:String(E.name??mi.name),avatar:String(E.avatar??mi.avatar),avatarImg:String(E.avatarImg??""),title:String(E.title??mi.title),bio:String(E.bio??mi.bio),stats:pw(E.stats).length?pw(E.stats):mi.stats,highlights:mw(E.highlights).length?mw(E.highlights):mi.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(T=>T.label||T.value),highlights:t.highlights.filter(Boolean)},E=await xt("/api/admin/author-settings",k);if(!E||E.success===!1){oe.error("保存失败: "+(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),oe.error("保存失败: "+(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 T=new FormData;T.append("file",E),T.append("folder","avatars");const O=Ox(),F={};O&&(F.Authorization=`Bearer ${O}`);const R=await(await fetch(ho("/api/upload"),{method:"POST",body:T,credentials:"include",headers:F})).json();R!=null&&R.success&&(R!=null&&R.url)?e(P=>({...P,avatarImg:R.url})):oe.error("上传失败: "+((R==null?void 0:R.error)||"未知错误"))}catch(T){console.error(T),oe.error("上传失败")}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,T)=>T!==k)})),y=(k,E,C)=>e(T=>({...T,stats:T.stats.map((O,F)=>F===k?{...O,[E]:C}:O)})),v=()=>e(k=>({...k,highlights:[...k.highlights,""]})),w=k=>e(E=>({...E,highlights:E.highlights.filter((C,T)=>T!==k)})),N=(k,E)=>e(C=>({...C,highlights:C.highlights.map((T,O)=>O===k?E:T)}));return n?s.jsx("div",{className:"p-8 text-gray-500",children:"加载中..."}):s.jsxs("div",{className:"p-8 w-full",children:[s.jsxs("div",{className:"flex justify-between items-center mb-8",children:[s.jsxs("div",{children:[s.jsxs("h2",{className:"text-2xl font-bold text-white flex items-center gap-2",children:[s.jsx(yl,{className:"w-5 h-5 text-[#38bdac]"}),"作者详情"]}),s.jsx("p",{className:"text-gray-400 mt-1",children:"配置小程序「关于作者」页展示的作者信息,包括头像、简介、统计数据与亮点标签。"})]}),s.jsxs(ne,{onClick:h,disabled:i||n,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(cn,{className:"w-4 h-4 mr-2"}),i?"保存中...":"保存"]})]}),s.jsxs("div",{className:"space-y-6",children:[s.jsxs(Ae,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(et,{children:[s.jsxs(tt,{className:"flex items-center gap-2 text-white",children:[s.jsx(yl,{className:"w-4 h-4 text-[#38bdac]"}),"基本信息"]}),s.jsx(Pt,{className:"text-gray-400",children:"作者姓名、头像、头衔与个人简介,将展示在「关于作者」页顶部。"})]}),s.jsxs(Ie,{className:"space-y-4",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"姓名"}),s.jsx(ae,{className:"bg-[#0a1628] border-gray-700 text-white",value:t.name,onChange:k=>e(E=>({...E,name:k.target.value})),placeholder:"卡若"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"首字母占位(无头像时显示)"}),s.jsx(ae,{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"})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs(Z,{className:"text-gray-300 flex items-center gap-2",children:[s.jsx(Uw,{className:"w-3 h-3 text-[#38bdac]"}),"头像图片"]}),s.jsxs("div",{className:"flex gap-3 items-center",children:[s.jsx(ae,{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"}),s.jsx("input",{ref:u,type:"file",accept:"image/*",className:"hidden",onChange:f}),s.jsxs(ne,{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:[s.jsx(oh,{className:"w-4 h-4 mr-2"}),o?"上传中...":"上传"]})]}),t.avatarImg&&s.jsx("div",{className:"mt-2",children:s.jsx("img",{src:t.avatarImg.startsWith("http")?t.avatarImg:ho(t.avatarImg),alt:"头像预览",className:"w-20 h-20 rounded-full object-cover border border-gray-600"})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"头衔"}),s.jsx(ae,{className:"bg-[#0a1628] border-gray-700 text-white",value:t.title,onChange:k=>e(E=>({...E,title:k.target.value})),placeholder:"Soul派对房主理人 · 私域运营专家"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"个人简介"}),s.jsx(_l,{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点..."})]})]})]}),s.jsxs(Ae,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(et,{children:[s.jsx(tt,{className:"text-white",children:"统计数据"}),s.jsx(Pt,{className:"text-gray-400",children:"展示在作者卡片中的数字指标,如「商业案例 62」「连续直播 365天」。第一个「商业案例」的值可由书籍统计自动更新。"})]}),s.jsxs(Ie,{className:"space-y-3",children:[t.stats.map((k,E)=>s.jsxs("div",{className:"flex gap-3 items-center",children:[s.jsx(ae,{className:"flex-1 bg-[#0a1628] border-gray-700 text-white",value:k.label,onChange:C=>y(E,"label",C.target.value),placeholder:"标签"}),s.jsx(ae,{className:"flex-1 bg-[#0a1628] border-gray-700 text-white",value:k.value,onChange:C=>y(E,"value",C.target.value),placeholder:"数值"}),s.jsx(ne,{variant:"ghost",size:"icon",className:"text-gray-400 hover:text-red-400",onClick:()=>g(E),children:s.jsx(or,{className:"w-4 h-4"})})]},E)),s.jsxs(ne,{variant:"outline",size:"sm",onClick:m,className:"border-gray-600 text-gray-400",children:[s.jsx(rn,{className:"w-4 h-4 mr-2"}),"添加统计项"]})]})]}),s.jsxs(Ae,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(et,{children:[s.jsx(tt,{className:"text-white",children:"亮点标签"}),s.jsx(Pt,{className:"text-gray-400",children:"作者优势或成就的简短描述,以标签形式展示。"})]}),s.jsxs(Ie,{className:"space-y-3",children:[t.highlights.map((k,E)=>s.jsxs("div",{className:"flex gap-3 items-center",children:[s.jsx(ae,{className:"flex-1 bg-[#0a1628] border-gray-700 text-white",value:k,onChange:C=>N(E,C.target.value),placeholder:"5年私域运营经验"}),s.jsx(ne,{variant:"ghost",size:"icon",className:"text-gray-400 hover:text-red-400",onClick:()=>w(E),children:s.jsx(or,{className:"w-4 h-4"})})]},E)),s.jsxs(ne,{variant:"outline",size:"sm",onClick:v,className:"border-gray-600 text-gray-400",children:[s.jsx(rn,{className:"w-4 h-4 mr-2"}),"添加亮点"]})]})]})]})]})}function rV(){const[t,e]=b.useState([]),[n,r]=b.useState(0),[i,a]=b.useState(1),[o]=b.useState(10),[c,u]=b.useState(0),[h,f]=b.useState(""),m=Yx(h,300),[g,y]=b.useState(!0),[v,w]=b.useState(null),[N,k]=b.useState(!1),[E,C]=b.useState(null),[T,O]=b.useState(""),[F,I]=b.useState(""),[R,P]=b.useState(""),[L,ee]=b.useState("admin"),[te,Y]=b.useState("active"),[U,D]=b.useState(!1);async function $(){var W;y(!0),w(null);try{const ue=new URLSearchParams({page:String(i),pageSize:String(o)});m.trim()&&ue.set("search",m.trim());const G=await Le(`/api/admin/users?${ue}`);G!=null&&G.success?(e(G.records||[]),r(G.total??0),u(G.totalPages??0)):w(G.error||"加载失败")}catch(ue){const G=ue;w(G.status===403?"无权限访问":((W=G==null?void 0:G.data)==null?void 0:W.error)||"加载失败"),e([])}finally{y(!1)}}b.useEffect(()=>{$()},[i,o,m]);const le=()=>{C(null),O(""),I(""),P(""),ee("admin"),Y("active"),k(!0)},_=W=>{C(W),O(W.username),I(""),P(W.name||""),ee(W.role==="super_admin"?"super_admin":"admin"),Y(W.status==="disabled"?"disabled":"active"),k(!0)},se=async()=>{var W;if(!T.trim()){w("用户名不能为空");return}if(!E&&!F){w("新建时密码必填,至少 6 位");return}if(F&&F.length<6){w("密码至少 6 位");return}w(null),D(!0);try{if(E){const ue=await St("/api/admin/users",{id:E.id,password:F||void 0,name:R.trim(),role:L,status:te});ue!=null&&ue.success?(k(!1),$()):w((ue==null?void 0:ue.error)||"保存失败")}else{const ue=await xt("/api/admin/users",{username:T.trim(),password:F,name:R.trim(),role:L});ue!=null&&ue.success?(k(!1),$()):w((ue==null?void 0:ue.error)||"保存失败")}}catch(ue){const G=ue;w(((W=G==null?void 0:G.data)==null?void 0:W.error)||"保存失败")}finally{D(!1)}},J=async W=>{var ue;if(confirm("确定删除该管理员?"))try{const G=await Ps(`/api/admin/users?id=${W}`);G!=null&&G.success?$():w((G==null?void 0:G.error)||"删除失败")}catch(G){const fe=G;w(((ue=fe==null?void 0:fe.data)==null?void 0:ue.error)||"删除失败")}},z=W=>{if(!W)return"-";try{const ue=new Date(W);return isNaN(ue.getTime())?W:ue.toLocaleString("zh-CN")}catch{return W}};return s.jsxs("div",{className:"p-8 w-full",children:[s.jsxs("div",{className:"flex justify-between items-center mb-6",children:[s.jsxs("div",{children:[s.jsxs("h2",{className:"text-2xl font-bold text-white flex items-center gap-2",children:[s.jsx(Rx,{className:"w-5 h-5 text-[#38bdac]"}),"管理员用户"]}),s.jsx("p",{className:"text-gray-400 mt-1",children:"后台登录账号管理,仅超级管理员可操作"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ae,{placeholder:"搜索用户名/昵称",value:h,onChange:W=>f(W.target.value),className:"w-48 bg-[#0f2137] border-gray-700 text-white placeholder:text-gray-500"}),s.jsx(ne,{variant:"outline",size:"sm",onClick:$,disabled:g,className:"border-gray-600 text-gray-300",children:s.jsx(Ke,{className:`w-4 h-4 ${g?"animate-spin":""}`})}),s.jsxs(ne,{onClick:le,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(rn,{className:"w-4 h-4 mr-2"}),"新增管理员"]})]})]}),v&&s.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:[s.jsx("span",{children:v}),s.jsx("button",{type:"button",onClick:()=>w(null),className:"text-red-400 hover:text-red-300",children:"×"})]}),s.jsx(Ae,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsx(Ie,{className:"p-0",children:g?s.jsx("div",{className:"py-12 text-center text-gray-400",children:"加载中..."}):s.jsxs(s.Fragment,{children:[s.jsxs(qn,{children:[s.jsx(Gn,{children:s.jsxs(rt,{className:"bg-[#0a1628] border-gray-700",children:[s.jsx(ke,{className:"text-gray-400",children:"ID"}),s.jsx(ke,{className:"text-gray-400",children:"用户名"}),s.jsx(ke,{className:"text-gray-400",children:"昵称"}),s.jsx(ke,{className:"text-gray-400",children:"角色"}),s.jsx(ke,{className:"text-gray-400",children:"状态"}),s.jsx(ke,{className:"text-gray-400",children:"创建时间"}),s.jsx(ke,{className:"text-right text-gray-400",children:"操作"})]})}),s.jsxs(Jn,{children:[t.map(W=>s.jsxs(rt,{className:"border-gray-700/50",children:[s.jsx(xe,{className:"text-gray-300",children:W.id}),s.jsx(xe,{className:"text-white font-medium",children:W.username}),s.jsx(xe,{className:"text-gray-400",children:W.name||"-"}),s.jsx(xe,{children:s.jsx(He,{variant:"outline",className:W.role==="super_admin"?"border-amber-500/50 text-amber-400":"border-gray-600 text-gray-400",children:W.role==="super_admin"?"超级管理员":"管理员"})}),s.jsx(xe,{children:s.jsx(He,{variant:"outline",className:W.status==="active"?"border-[#38bdac]/50 text-[#38bdac]":"border-gray-500 text-gray-500",children:W.status==="active"?"正常":"已禁用"})}),s.jsx(xe,{className:"text-gray-500 text-sm",children:z(W.createdAt)}),s.jsxs(xe,{className:"text-right",children:[s.jsx(ne,{variant:"ghost",size:"sm",onClick:()=>_(W),className:"text-gray-400 hover:text-[#38bdac]",children:s.jsx(Rt,{className:"w-4 h-4"})}),s.jsx(ne,{variant:"ghost",size:"sm",onClick:()=>J(W.id),className:"text-gray-400 hover:text-red-400",children:s.jsx(Dn,{className:"w-4 h-4"})})]})]},W.id)),t.length===0&&!g&&s.jsx(rt,{children:s.jsx(xe,{colSpan:7,className:"text-center py-12 text-gray-500",children:v==="无权限访问"?"仅超级管理员可查看":"暂无管理员"})})]})]}),c>1&&s.jsx("div",{className:"p-4 border-t border-gray-700/50",children:s.jsx(ms,{page:i,pageSize:o,total:n,totalPages:c,onPageChange:a})})]})})}),s.jsx(Kt,{open:N,onOpenChange:k,children:s.jsxs(Vt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-sm",children:[s.jsx(qt,{children:s.jsx(Gt,{className:"text-white",children:E?"编辑管理员":"新增管理员"})}),s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"用户名"}),s.jsx(ae,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"登录用户名",value:T,onChange:W=>O(W.target.value),disabled:!!E}),E&&s.jsx("p",{className:"text-xs text-gray-500",children:"用户名不可修改"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:E?"新密码(留空不改)":"密码"}),s.jsx(ae,{type:"password",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:E?"留空表示不修改":"至少 6 位",value:F,onChange:W=>I(W.target.value)})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"昵称"}),s.jsx(ae,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"显示名称",value:R,onChange:W=>P(W.target.value)})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"角色"}),s.jsxs("select",{value:L,onChange:W=>ee(W.target.value),className:"w-full h-10 px-3 rounded-md bg-[#0a1628] border border-gray-700 text-white",children:[s.jsx("option",{value:"admin",children:"管理员"}),s.jsx("option",{value:"super_admin",children:"超级管理员"})]})]}),E&&s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"状态"}),s.jsxs("select",{value:te,onChange:W=>Y(W.target.value),className:"w-full h-10 px-3 rounded-md bg-[#0a1628] border border-gray-700 text-white",children:[s.jsx("option",{value:"active",children:"正常"}),s.jsx("option",{value:"disabled",children:"禁用"})]})]})]}),s.jsxs(hn,{children:[s.jsxs(ne,{variant:"outline",onClick:()=>k(!1),className:"border-gray-600 text-gray-300",children:[s.jsx(or,{className:"w-4 h-4 mr-2"}),"取消"]}),s.jsxs(ne,{onClick:se,disabled:U,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(cn,{className:"w-4 h-4 mr-2"}),U?"保存中...":"保存"]})]})]})})]})}const sV={appId:"wxb8bbb2b10dec74aa",withdrawSubscribeTmplId:"u3MbZGPRkrZIk-I7QdpwzFxnO_CeQPaCWF2FkiIablE",mchId:"1318592501",minWithdraw:10},iV={name:"卡若",startDate:"2025年10月15日",bio:"连续创业者,私域运营专家,每天早上6-9点在Soul派对房分享真实商业故事",liveTime:"06:00-09:00",platform:"Soul派对房",description:"连续创业者,私域运营专家"},aV={sectionPrice:1,baseBookPrice:9.9,distributorShare:90,authorInfo:{...iV},ckbLeadApiKey:""},oV={matchEnabled:!0,referralEnabled:!0,searchEnabled:!0,aboutEnabled:!0},lV=["system","author","admin"];function cV(){const[t,e]=zw(),n=t.get("tab")??"system",r=lV.includes(n)?n:"system",[i,a]=b.useState(aV),[o,c]=b.useState(oV),[u,h]=b.useState(sV),[f,m]=b.useState(!1),[g,y]=b.useState(!0),[v,w]=b.useState(!1),[N,k]=b.useState(""),[E,C]=b.useState(""),[T,O]=b.useState(!1),[F,I]=b.useState(!1),R=(Y,U,D=!1)=>{k(Y),C(U),O(D),w(!0)};b.useEffect(()=>{(async()=>{try{const U=await Le("/api/admin/settings");if(!U||U.success===!1)return;if(U.featureConfig&&Object.keys(U.featureConfig).length&&c(D=>({...D,...U.featureConfig})),U.mpConfig&&typeof U.mpConfig=="object"&&h(D=>({...D,...U.mpConfig})),U.siteSettings&&typeof U.siteSettings=="object"){const D=U.siteSettings;a($=>({...$,...typeof D.sectionPrice=="number"&&{sectionPrice:D.sectionPrice},...typeof D.baseBookPrice=="number"&&{baseBookPrice:D.baseBookPrice},...typeof D.distributorShare=="number"&&{distributorShare:D.distributorShare},...D.authorInfo&&typeof D.authorInfo=="object"&&{authorInfo:{...$.authorInfo,...D.authorInfo}},...typeof D.ckbLeadApiKey=="string"&&{ckbLeadApiKey:D.ckbLeadApiKey}}))}}catch(U){console.error("Load settings error:",U)}finally{y(!1)}})()},[]);const P=async(Y,U)=>{I(!0);try{const D=await xt("/api/admin/settings",{featureConfig:Y});if(!D||D.success===!1){U(),R("保存失败",(D==null?void 0:D.error)??"未知错误",!0);return}R("已保存","功能开关已更新,相关入口将随之显示或隐藏。")}catch(D){console.error("Save feature config error:",D),U(),R("保存失败",D instanceof Error?D.message:String(D),!0)}finally{I(!1)}},L=(Y,U)=>{const D=o,$={...D,[Y]:U};c($),P($,()=>c(D))},ee=async()=>{m(!0);try{const Y=await xt("/api/admin/settings",{featureConfig:o,siteSettings:{sectionPrice:i.sectionPrice,baseBookPrice:i.baseBookPrice,distributorShare:i.distributorShare,authorInfo:i.authorInfo,ckbLeadApiKey:i.ckbLeadApiKey||void 0},mpConfig:{...u,appId:u.appId||"",withdrawSubscribeTmplId:u.withdrawSubscribeTmplId||"",mchId:u.mchId||"",minWithdraw:typeof u.minWithdraw=="number"?u.minWithdraw:10}});if(!Y||Y.success===!1){R("保存失败",(Y==null?void 0:Y.error)??"未知错误",!0);return}R("已保存","设置已保存成功。")}catch(Y){console.error("Save settings error:",Y),R("保存失败",Y instanceof Error?Y.message:String(Y),!0)}finally{m(!1)}},te=Y=>{e(Y==="system"?{}:{tab:Y})};return g?s.jsx("div",{className:"p-8 text-gray-500",children:"加载中..."}):s.jsxs("div",{className:"p-8 w-full",children:[s.jsxs("div",{className:"flex justify-between items-center mb-6",children:[s.jsxs("div",{children:[s.jsx("h2",{className:"text-2xl font-bold text-white",children:"系统设置"}),s.jsx("p",{className:"text-gray-400 mt-1",children:"配置全站基础参数与开关"})]}),r==="system"&&s.jsxs(ne,{onClick:ee,disabled:f,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(cn,{className:"w-4 h-4 mr-2"}),f?"保存中...":"保存设置"]})]}),s.jsxs(fd,{value:r,onValueChange:te,className:"w-full",children:[s.jsxs(Ll,{className:"mb-6 bg-[#0f2137] border border-gray-700/50 p-1",children:[s.jsxs(Jt,{value:"system",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-gray-400 data-[state=active]:font-medium",children:[s.jsx(so,{className:"w-4 h-4 mr-2"}),"系统设置"]}),s.jsxs(Jt,{value:"author",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-gray-400 data-[state=active]:font-medium",children:[s.jsx(wm,{className:"w-4 h-4 mr-2"}),"作者详情"]}),s.jsxs(Jt,{value:"admin",className:"data-[state=active]:bg-[#38bdac]/20 data-[state=active]:text-[#38bdac] text-gray-400 data-[state=active]:font-medium",children:[s.jsx(Rx,{className:"w-4 h-4 mr-2"}),"管理员"]})]}),s.jsx(Yt,{value:"system",className:"mt-0",children:s.jsxs("div",{className:"space-y-6",children:[s.jsxs(Ae,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(et,{children:[s.jsxs(tt,{className:"text-white flex items-center gap-2",children:[s.jsx(wm,{className:"w-5 h-5 text-[#38bdac]"}),"关于作者"]}),s.jsx(Pt,{className:"text-gray-400",children:'配置作者信息,将在"关于作者"页面显示'})]}),s.jsxs(Ie,{className:"space-y-4",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsxs(Z,{htmlFor:"author-name",className:"text-gray-300 flex items-center gap-1",children:[s.jsx(wm,{className:"w-3 h-3"}),"主理人名称"]}),s.jsx(ae,{id:"author-name",className:"bg-[#0a1628] border-gray-700 text-white",value:i.authorInfo.name??"",onChange:Y=>a(U=>({...U,authorInfo:{...U.authorInfo,name:Y.target.value}}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs(Z,{htmlFor:"start-date",className:"text-gray-300 flex items-center gap-1",children:[s.jsx(ih,{className:"w-3 h-3"}),"开播日期"]}),s.jsx(ae,{id:"start-date",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"例如: 2025年10月15日",value:i.authorInfo.startDate??"",onChange:Y=>a(U=>({...U,authorInfo:{...U.authorInfo,startDate:Y.target.value}}))})]})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsxs(Z,{htmlFor:"live-time",className:"text-gray-300 flex items-center gap-1",children:[s.jsx(ih,{className:"w-3 h-3"}),"直播时间"]}),s.jsx(ae,{id:"live-time",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"例如: 06:00-09:00",value:i.authorInfo.liveTime??"",onChange:Y=>a(U=>({...U,authorInfo:{...U.authorInfo,liveTime:Y.target.value}}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs(Z,{htmlFor:"platform",className:"text-gray-300 flex items-center gap-1",children:[s.jsx(Kw,{className:"w-3 h-3"}),"直播平台"]}),s.jsx(ae,{id:"platform",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"例如: Soul派对房",value:i.authorInfo.platform??"",onChange:Y=>a(U=>({...U,authorInfo:{...U.authorInfo,platform:Y.target.value}}))})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs(Z,{htmlFor:"description",className:"text-gray-300 flex items-center gap-1",children:[s.jsx(Gr,{className:"w-3 h-3"}),"简介描述"]}),s.jsx(ae,{id:"description",className:"bg-[#0a1628] border-gray-700 text-white",value:i.authorInfo.description??"",onChange:Y=>a(U=>({...U,authorInfo:{...U.authorInfo,description:Y.target.value}}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{htmlFor:"bio",className:"text-gray-300",children:"详细介绍"}),s.jsx(_l,{id:"bio",className:"bg-[#0a1628] border-gray-700 text-white min-h-[100px]",placeholder:"输入作者详细介绍...",value:i.authorInfo.bio??"",onChange:Y=>a(U=>({...U,authorInfo:{...U.authorInfo,bio:Y.target.value}}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs(Z,{htmlFor:"ckb-lead-api-key",className:"text-gray-300 flex items-center gap-1",children:[s.jsx(ps,{className:"w-3 h-3"}),"链接卡若存客宝密钥"]}),s.jsx(ae,{id:"ckb-lead-api-key",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如 xxxxx-xxxxx-xxxxx-xxxxx(留空则用 .env 默认)",value:i.ckbLeadApiKey??"",onChange:Y=>a(U=>({...U,ckbLeadApiKey:Y.target.value}))}),s.jsx("p",{className:"text-xs text-gray-500",children:"小程序首页「链接卡若」留资接口使用的存客宝 API Key,优先于 .env 配置"})]}),s.jsxs("div",{className:"mt-4 p-4 rounded-xl bg-[#0a1628] border border-[#38bdac]/30",children:[s.jsx("p",{className:"text-xs text-gray-500 mb-2",children:"预览效果"}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.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:(i.authorInfo.name??"K").charAt(0)}),s.jsxs("div",{children:[s.jsx("p",{className:"text-white font-semibold",children:i.authorInfo.name}),s.jsx("p",{className:"text-gray-400 text-xs",children:i.authorInfo.description}),s.jsxs("p",{className:"text-[#38bdac] text-xs mt-1",children:["每日 ",i.authorInfo.liveTime," · ",i.authorInfo.platform]})]})]})]})]})]}),s.jsxs(Ae,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(et,{children:[s.jsxs(tt,{className:"text-white flex items-center gap-2",children:[s.jsx(ah,{className:"w-5 h-5 text-[#38bdac]"}),"价格设置"]}),s.jsx(Pt,{className:"text-gray-400",children:"配置书籍和章节的定价"})]}),s.jsx(Ie,{className:"space-y-4",children:s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"单节价格 (元)"}),s.jsx(ae,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:i.sectionPrice,onChange:Y=>a(U=>({...U,sectionPrice:Number.parseFloat(Y.target.value)||1}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"整本价格 (元)"}),s.jsx(ae,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:i.baseBookPrice,onChange:Y=>a(U=>({...U,baseBookPrice:Number.parseFloat(Y.target.value)||9.9}))})]})]})})]}),s.jsxs(Ae,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(et,{children:[s.jsxs(tt,{className:"text-white flex items-center gap-2",children:[s.jsx(uo,{className:"w-5 h-5 text-[#38bdac]"}),"小程序配置"]}),s.jsx(Pt,{className:"text-gray-400",children:"订阅消息模板、支付商户号等,小程序从 /api/miniprogram/config 读取(API 地址由 app.js baseUrl 控制)"})]}),s.jsx(Ie,{className:"space-y-4",children:s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"小程序 AppID"}),s.jsx(ae,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"wxb8bbb2b10dec74aa",value:u.appId??"",onChange:Y=>h(U=>({...U,appId:Y.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"提现订阅模板 ID"}),s.jsx(ae,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"用户申请提现时需授权",value:u.withdrawSubscribeTmplId??"",onChange:Y=>h(U=>({...U,withdrawSubscribeTmplId:Y.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"微信支付商户号"}),s.jsx(ae,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"1318592501",value:u.mchId??"",onChange:Y=>h(U=>({...U,mchId:Y.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"最低提现金额 (元)"}),s.jsx(ae,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:u.minWithdraw??10,onChange:Y=>h(U=>({...U,minWithdraw:Number.parseFloat(Y.target.value)||10}))})]})]})})]}),s.jsxs(Ae,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(et,{children:[s.jsxs(tt,{className:"text-white flex items-center gap-2",children:[s.jsx(so,{className:"w-5 h-5 text-[#38bdac]"}),"功能开关"]}),s.jsx(Pt,{className:"text-gray-400",children:"控制各个功能模块的显示/隐藏"})]}),s.jsxs(Ie,{className:"space-y-4",children:[s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 rounded-lg bg-[#0a1628] border border-gray-700/50",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx($n,{className:"w-4 h-4 text-[#38bdac]"}),s.jsx(Z,{htmlFor:"match-enabled",className:"text-white font-medium cursor-pointer",children:"找伙伴功能"})]}),s.jsx("p",{className:"text-xs text-gray-400 ml-6",children:"控制小程序和Web端的找伙伴功能显示"})]}),s.jsx(jt,{id:"match-enabled",checked:o.matchEnabled,disabled:F,onCheckedChange:Y=>L("matchEnabled",Y)})]}),s.jsxs("div",{className:"flex items-center justify-between p-4 rounded-lg bg-[#0a1628] border border-gray-700/50",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(fM,{className:"w-4 h-4 text-[#38bdac]"}),s.jsx(Z,{htmlFor:"referral-enabled",className:"text-white font-medium cursor-pointer",children:"推广功能"})]}),s.jsx("p",{className:"text-xs text-gray-400 ml-6",children:"控制推广中心的显示(我的页面入口)"})]}),s.jsx(jt,{id:"referral-enabled",checked:o.referralEnabled,disabled:F,onCheckedChange:Y=>L("referralEnabled",Y)})]}),s.jsxs("div",{className:"flex items-center justify-between p-4 rounded-lg bg-[#0a1628] border border-gray-700/50",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Gr,{className:"w-4 h-4 text-[#38bdac]"}),s.jsx(Z,{htmlFor:"search-enabled",className:"text-white font-medium cursor-pointer",children:"搜索功能"})]}),s.jsx("p",{className:"text-xs text-gray-400 ml-6",children:"控制首页搜索栏的显示"})]}),s.jsx(jt,{id:"search-enabled",checked:o.searchEnabled,disabled:F,onCheckedChange:Y=>L("searchEnabled",Y)})]}),s.jsxs("div",{className:"flex items-center justify-between p-4 rounded-lg bg-[#0a1628] border border-gray-700/50",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(so,{className:"w-4 h-4 text-[#38bdac]"}),s.jsx(Z,{htmlFor:"about-enabled",className:"text-white font-medium cursor-pointer",children:"关于页面"})]}),s.jsx("p",{className:"text-xs text-gray-400 ml-6",children:"控制关于页面的访问"})]}),s.jsx(jt,{id:"about-enabled",checked:o.aboutEnabled,disabled:F,onCheckedChange:Y=>L("aboutEnabled",Y)})]})]}),s.jsx("div",{className:"p-3 rounded-lg bg-blue-500/10 border border-blue-500/30",children:s.jsx("p",{className:"text-xs text-blue-300",children:"💡 关闭功能后,相关入口会自动隐藏。建议在功能开发完成后再开启。"})})]})]})]})}),s.jsx(Yt,{value:"author",className:"mt-0",children:s.jsx(nV,{})}),s.jsx(Yt,{value:"admin",className:"mt-0",children:s.jsx(rV,{})})]}),s.jsx(Kt,{open:v,onOpenChange:w,children:s.jsxs(Vt,{className:"bg-[#0f2137] border-gray-700 text-white",showCloseButton:!0,children:[s.jsxs(qt,{children:[s.jsx(Gt,{className:T?"text-red-400":"text-[#38bdac]",children:N}),s.jsx(Wx,{className:"text-gray-400 whitespace-pre-wrap pt-2",children:E})]}),s.jsx(hn,{className:"mt-4",children:s.jsx(ne,{onClick:()=>w(!1),className:T?"bg-gray-600 hover:bg-gray-500":"bg-[#38bdac] hover:bg-[#2da396]",children:"确定"})})]})})]})}const gw={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 dV(){const[t,e]=b.useState(!1),[n,r]=b.useState(gw),[i,a]=b.useState(""),o=async()=>{e(!0);try{const k=await Le("/api/config");k!=null&&k.paymentMethods&&r({...gw,...k.paymentMethods})}catch(k){console.error(k)}finally{e(!1)}};b.useEffect(()=>{o()},[]);const c=async()=>{e(!0);try{await xt("/api/db/config",{key:"payment_methods",value:n,description:"支付方式配置"}),oe.success("配置已保存!")}catch(k){console.error("保存失败:",k),oe.error("保存失败: "+(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,w=n.usdt,N=n.paypal;return s.jsxs("div",{className:"p-8 w-full",children:[s.jsxs("div",{className:"flex justify-between items-center mb-8",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-bold mb-2 text-white",children:"支付配置"}),s.jsx("p",{className:"text-gray-400",children:"配置微信、支付宝、USDT、PayPal等支付参数"})]}),s.jsxs("div",{className:"flex gap-3",children:[s.jsxs(ne,{variant:"outline",onClick:o,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Ke,{className:`w-4 h-4 mr-2 ${t?"animate-spin":""}`}),"同步配置"]}),s.jsxs(ne,{onClick:c,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(cn,{className:"w-4 h-4 mr-2"}),"保存配置"]})]})]}),s.jsx("div",{className:"mb-6 bg-[#07C160]/10 border border-[#07C160]/30 rounded-xl p-4",children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx(Bw,{className:"w-5 h-5 text-[#07C160] flex-shrink-0 mt-0.5"}),s.jsxs("div",{className:"text-sm",children:[s.jsx("p",{className:"font-medium mb-2 text-[#07C160]",children:"如何获取微信群跳转链接?"}),s.jsxs("ol",{className:"text-[#07C160]/80 space-y-1 list-decimal list-inside",children:[s.jsx("li",{children:"打开微信,进入目标微信群"}),s.jsx("li",{children:'点击右上角"..." → "群二维码"'}),s.jsx("li",{children:'点击右上角"..." → "发送到电脑"'}),s.jsx("li",{children:"在电脑上保存二维码图片,上传到图床获取URL"}),s.jsx("li",{children:"或使用草料二维码等工具解析二维码获取链接"})]}),s.jsx("p",{className:"text-[#07C160]/60 mt-2",children:"提示:微信群二维码7天后失效,建议使用活码工具"})]})]})}),s.jsxs(fd,{defaultValue:"wechat",className:"space-y-6",children:[s.jsxs(Ll,{className:"bg-[#0f2137] border border-gray-700/50 p-1 grid grid-cols-4 w-full",children:[s.jsxs(Jt,{value:"wechat",className:"data-[state=active]:bg-[#07C160]/20 data-[state=active]:text-[#07C160] text-gray-400",children:[s.jsx(uo,{className:"w-4 h-4 mr-2"}),"微信"]}),s.jsxs(Jt,{value:"alipay",className:"data-[state=active]:bg-[#1677FF]/20 data-[state=active]:text-[#1677FF] text-gray-400",children:[s.jsx(Ob,{className:"w-4 h-4 mr-2"}),"支付宝"]}),s.jsxs(Jt,{value:"usdt",className:"data-[state=active]:bg-[#26A17B]/20 data-[state=active]:text-[#26A17B] text-gray-400",children:[s.jsx(Rb,{className:"w-4 h-4 mr-2"}),"USDT"]}),s.jsxs(Jt,{value:"paypal",className:"data-[state=active]:bg-[#003087]/20 data-[state=active]:text-[#169BD7] text-gray-400",children:[s.jsx(kg,{className:"w-4 h-4 mr-2"}),"PayPal"]})]}),s.jsx(Yt,{value:"wechat",className:"space-y-4",children:s.jsxs(Ae,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(et,{className:"flex flex-row items-center justify-between pb-2",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsxs(tt,{className:"text-[#07C160] flex items-center gap-2",children:[s.jsx(uo,{className:"w-5 h-5"}),"微信支付配置"]}),s.jsx(Pt,{className:"text-gray-400",children:"配置微信支付参数和跳转链接"})]}),s.jsx(jt,{checked:!!y.enabled,onCheckedChange:k=>h("enabled",k)})]}),s.jsxs(Ie,{className:"space-y-4",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"网站AppID"}),s.jsx(ae,{className:"bg-[#0a1628] border-gray-700 text-white font-mono text-sm",value:String(y.websiteAppId??""),onChange:k=>h("websiteAppId",k.target.value)})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"商户号"}),s.jsx(ae,{className:"bg-[#0a1628] border-gray-700 text-white font-mono text-sm",value:String(y.merchantId??""),onChange:k=>h("merchantId",k.target.value)})]})]}),s.jsxs("div",{className:"border-t border-gray-700/50 pt-4 space-y-4",children:[s.jsxs("h4",{className:"text-white font-medium flex items-center gap-2",children:[s.jsx(_s,{className:"w-4 h-4 text-[#38bdac]"}),"跳转链接配置(核心功能)"]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"微信收款码/支付链接"}),s.jsx(ae,{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)}),s.jsx("p",{className:"text-xs text-gray-500",children:"用户点击微信支付后显示的二维码图片URL"})]}),s.jsxs("div",{className:"space-y-2 bg-[#07C160]/5 p-4 rounded-xl border border-[#07C160]/20",children:[s.jsx(Z,{className:"text-[#07C160] font-medium",children:"微信群跳转链接(支付成功后跳转)"}),s.jsx(ae,{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)}),s.jsx("p",{className:"text-xs text-[#07C160]/70",children:"用户支付成功后将自动跳转到此链接,进入指定微信群"})]})]})]})]})}),s.jsx(Yt,{value:"alipay",className:"space-y-4",children:s.jsxs(Ae,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(et,{className:"flex flex-row items-center justify-between pb-2",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsxs(tt,{className:"text-[#1677FF] flex items-center gap-2",children:[s.jsx(Ob,{className:"w-5 h-5"}),"支付宝配置"]}),s.jsx(Pt,{className:"text-gray-400",children:"已加载真实支付宝参数"})]}),s.jsx(jt,{checked:!!v.enabled,onCheckedChange:k=>f("enabled",k)})]}),s.jsxs(Ie,{className:"space-y-4",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"合作者身份 (PID)"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(ae,{className:"bg-[#0a1628] border-gray-700 text-white font-mono text-sm",value:String(v.partnerId??""),onChange:k=>f("partnerId",k.target.value)}),s.jsx(ne,{size:"icon",variant:"outline",className:"border-gray-700 bg-transparent",onClick:()=>u(String(v.partnerId??""),"pid"),children:i==="pid"?s.jsx(cf,{className:"w-4 h-4 text-green-500"}):s.jsx(Hw,{className:"w-4 h-4 text-gray-400"})})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"安全校验码 (Key)"}),s.jsx(ae,{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)})]})]}),s.jsxs("div",{className:"border-t border-gray-700/50 pt-4 space-y-4",children:[s.jsxs("h4",{className:"text-white font-medium flex items-center gap-2",children:[s.jsx(_s,{className:"w-4 h-4 text-[#38bdac]"}),"跳转链接配置"]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"支付宝收款码/跳转链接"}),s.jsx(ae,{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)}),s.jsx("p",{className:"text-xs text-gray-500",children:"用户点击支付宝支付后显示的二维码"})]})]})]})]})}),s.jsx(Yt,{value:"usdt",className:"space-y-4",children:s.jsxs(Ae,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(et,{className:"flex flex-row items-center justify-between pb-2",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsxs(tt,{className:"text-[#26A17B] flex items-center gap-2",children:[s.jsx(Rb,{className:"w-5 h-5"}),"USDT配置"]}),s.jsx(Pt,{className:"text-gray-400",children:"配置加密货币收款地址"})]}),s.jsx(jt,{checked:!!w.enabled,onCheckedChange:k=>m("enabled",k)})]}),s.jsxs(Ie,{className:"space-y-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"网络类型"}),s.jsxs("select",{className:"w-full bg-[#0a1628] border border-gray-700 text-white rounded-md p-2",value:String(w.network??"TRC20"),onChange:k=>m("network",k.target.value),children:[s.jsx("option",{value:"TRC20",children:"TRC20 (波场)"}),s.jsx("option",{value:"ERC20",children:"ERC20 (以太坊)"}),s.jsx("option",{value:"BEP20",children:"BEP20 (币安链)"})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"收款地址"}),s.jsx(ae,{className:"bg-[#0a1628] border-gray-700 text-white font-mono text-sm",placeholder:"T... (TRC20地址)",value:String(w.address??""),onChange:k=>m("address",k.target.value)})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"汇率 (1 USD = ? CNY)"}),s.jsx(ae,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:Number(w.exchangeRate)??7.2,onChange:k=>m("exchangeRate",Number.parseFloat(k.target.value)||7.2)})]})]})]})}),s.jsx(Yt,{value:"paypal",className:"space-y-4",children:s.jsxs(Ae,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(et,{className:"flex flex-row items-center justify-between pb-2",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsxs(tt,{className:"text-[#169BD7] flex items-center gap-2",children:[s.jsx(kg,{className:"w-5 h-5"}),"PayPal配置"]}),s.jsx(Pt,{className:"text-gray-400",children:"配置PayPal收款账户"})]}),s.jsx(jt,{checked:!!N.enabled,onCheckedChange:k=>g("enabled",k)})]}),s.jsxs(Ie,{className:"space-y-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"PayPal邮箱"}),s.jsx(ae,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"your@email.com",value:String(N.email??""),onChange:k=>g("email",k.target.value)})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"汇率 (1 USD = ? CNY)"}),s.jsx(ae,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:Number(N.exchangeRate)??7.2,onChange:k=>g("exchangeRate",Number(k.target.value)||7.2)})]})]})]})})]})]})}const uV={siteName:"卡若日记",siteTitle:"一场SOUL的创业实验场",siteDescription:"来自Soul派对房的真实商业故事",logo:"/logo.png",favicon:"/favicon.ico",primaryColor:"#00CED1"},hV={home:{enabled:!0,label:"首页"},chapters:{enabled:!0,label:"目录"},match:{enabled:!0,label:"匹配"},my:{enabled:!0,label:"我的"}},fV={homeTitle:"一场SOUL的创业实验场",homeSubtitle:"来自Soul派对房的真实商业故事",chaptersTitle:"我要看",matchTitle:"语音匹配",myTitle:"我的",aboutTitle:"关于作者"};function pV(){const[t,e]=b.useState({siteConfig:{...uV},menuConfig:{...hV},pageConfig:{...fV}}),[n,r]=b.useState(!1),[i,a]=b.useState(!1);b.useEffect(()=>{Le("/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 xt("/api/db/config",{key:"site_config",value:t.siteConfig,description:"网站基础配置"}),await xt("/api/db/config",{key:"menu_config",value:t.menuConfig,description:"底部菜单配置"}),await xt("/api/db/config",{key:"page_config",value:t.pageConfig,description:"页面标题配置"}),r(!0),setTimeout(()=>r(!1),2e3),oe.success("配置已保存")}catch(f){console.error(f),oe.error("保存失败: "+(f instanceof Error?f.message:String(f)))}finally{a(!1)}},c=t.siteConfig,u=t.menuConfig,h=t.pageConfig;return s.jsxs("div",{className:"p-8 w-full",children:[s.jsxs("div",{className:"flex justify-between items-center mb-8",children:[s.jsxs("div",{children:[s.jsx("h2",{className:"text-2xl font-bold text-white",children:"网站配置"}),s.jsx("p",{className:"text-gray-400 mt-1",children:"配置网站名称、图标、菜单和页面标题"})]}),s.jsxs(ne,{onClick:o,disabled:i,className:`${n?"bg-green-500":"bg-[#00CED1]"} hover:bg-[#20B2AA] text-white transition-colors`,children:[s.jsx(cn,{className:"w-4 h-4 mr-2"}),i?"保存中...":n?"已保存":"保存设置"]})]}),s.jsxs("div",{className:"space-y-6",children:[s.jsxs(Ae,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(et,{children:[s.jsxs(tt,{className:"text-white flex items-center gap-2",children:[s.jsx(kg,{className:"w-5 h-5 text-[#00CED1]"}),"网站基础信息"]}),s.jsx(Pt,{className:"text-gray-400",children:"配置网站名称、标题和描述"})]}),s.jsxs(Ie,{className:"space-y-4",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{htmlFor:"site-name",className:"text-gray-300",children:"网站名称"}),s.jsx(ae,{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}}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{htmlFor:"site-title",className:"text-gray-300",children:"网站标题"}),s.jsx(ae,{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}}))})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{htmlFor:"site-desc",className:"text-gray-300",children:"网站描述"}),s.jsx(ae,{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}}))})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{htmlFor:"logo",className:"text-gray-300",children:"Logo地址"}),s.jsx(ae,{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}}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{htmlFor:"favicon",className:"text-gray-300",children:"Favicon地址"}),s.jsx(ae,{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}}))})]})]})]})]}),s.jsxs(Ae,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(et,{children:[s.jsxs(tt,{className:"text-white flex items-center gap-2",children:[s.jsx(sA,{className:"w-5 h-5 text-[#00CED1]"}),"主题颜色"]}),s.jsx(Pt,{className:"text-gray-400",children:"配置网站主题色"})]}),s.jsx(Ie,{children:s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsxs("div",{className:"space-y-2 flex-1",children:[s.jsx(Z,{htmlFor:"primary-color",className:"text-gray-300",children:"主色调"}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(ae,{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}}))}),s.jsx(ae,{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}}))})]})]}),s.jsx("div",{className:"w-24 h-24 rounded-xl flex items-center justify-center text-white font-bold",style:{backgroundColor:c.primaryColor??"#00CED1"},children:"预览"})]})})]}),s.jsxs(Ae,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(et,{children:[s.jsxs(tt,{className:"text-white flex items-center gap-2",children:[s.jsx(QM,{className:"w-5 h-5 text-[#00CED1]"}),"底部菜单配置"]}),s.jsx(Pt,{className:"text-gray-400",children:"控制底部导航栏菜单的显示和名称"})]}),s.jsx(Ie,{className:"space-y-4",children:Object.entries(u).map(([f,m])=>s.jsxs("div",{className:"flex items-center justify-between p-4 bg-[#0a1628] rounded-lg",children:[s.jsxs("div",{className:"flex items-center gap-4 flex-1",children:[s.jsx(jt,{checked:(m==null?void 0:m.enabled)??!0,onCheckedChange:g=>e(y=>({...y,menuConfig:{...y.menuConfig,[f]:{...m,enabled:g}}}))}),s.jsx("span",{className:"text-gray-300 w-16 capitalize",children:f}),s.jsx(ae,{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}}}))})]}),s.jsx("span",{className:`text-sm ${m!=null&&m.enabled?"text-green-400":"text-gray-500"}`,children:m!=null&&m.enabled?"显示":"隐藏"})]},f))})]}),s.jsxs(Ae,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:[s.jsxs(et,{children:[s.jsxs(tt,{className:"text-white flex items-center gap-2",children:[s.jsx(dM,{className:"w-5 h-5 text-[#00CED1]"}),"页面标题配置"]}),s.jsx(Pt,{className:"text-gray-400",children:"配置各个页面的标题和副标题"})]}),s.jsxs(Ie,{className:"space-y-4",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"首页标题"}),s.jsx(ae,{className:"bg-[#0a1628] border-gray-700 text-white",value:h.homeTitle??"",onChange:f=>e(m=>({...m,pageConfig:{...m.pageConfig,homeTitle:f.target.value}}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"首页副标题"}),s.jsx(ae,{className:"bg-[#0a1628] border-gray-700 text-white",value:h.homeSubtitle??"",onChange:f=>e(m=>({...m,pageConfig:{...m.pageConfig,homeSubtitle:f.target.value}}))})]})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"目录页标题"}),s.jsx(ae,{className:"bg-[#0a1628] border-gray-700 text-white",value:h.chaptersTitle??"",onChange:f=>e(m=>({...m,pageConfig:{...m.pageConfig,chaptersTitle:f.target.value}}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"匹配页标题"}),s.jsx(ae,{className:"bg-[#0a1628] border-gray-700 text-white",value:h.matchTitle??"",onChange:f=>e(m=>({...m,pageConfig:{...m.pageConfig,matchTitle:f.target.value}}))})]})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"我的页标题"}),s.jsx(ae,{className:"bg-[#0a1628] border-gray-700 text-white",value:h.myTitle??"",onChange:f=>e(m=>({...m,pageConfig:{...m.pageConfig,myTitle:f.target.value}}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"关于作者标题"}),s.jsx(ae,{className:"bg-[#0a1628] border-gray-700 text-white",value:h.aboutTitle??"",onChange:f=>e(m=>({...m,pageConfig:{...m.pageConfig,aboutTitle:f.target.value}}))})]})]})]})]})]})]})}function mV(){const[t,e]=b.useState(""),[n,r]=b.useState(""),[i,a]=b.useState(""),[o,c]=b.useState({}),u=async()=>{var y,v,w,N;try{const k=await Le("/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=(N=(w=k==null?void 0:k.paymentMethods)==null?void 0:w.wechat)==null?void 0:N.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(w=>w.trim()).filter(Boolean),v=[...o.liveQRCodes||[]];v[0]?v[0].urls=y:v.push({id:"live-1",name:"微信群活码",urls:y,clickCount:0}),await xt("/api/db/config",{key:"live_qr_codes",value:v,description:"群活码配置"}),oe.success("群活码配置已保存!"),await u()}catch(y){console.error(y),oe.error("保存失败: "+(y instanceof Error?y.message:String(y)))}},m=async()=>{var y;try{await xt("/api/db/config",{key:"payment_methods",value:{...o.paymentMethods||{},wechat:{...((y=o.paymentMethods)==null?void 0:y.wechat)||{},groupQrCode:n}},description:"支付方式配置"}),oe.success("微信群链接已保存!用户支付成功后将自动跳转"),await u()}catch(v){console.error(v),oe.error("保存失败: "+(v instanceof Error?v.message:String(v)))}},g=()=>{n?window.open(n,"_blank"):oe.error("请先配置微信群链接")};return s.jsxs("div",{className:"p-8 w-full",children:[s.jsxs("div",{className:"mb-8",children:[s.jsx("h2",{className:"text-2xl font-bold text-white",children:"微信群活码管理"}),s.jsx("p",{className:"text-gray-400 mt-1",children:"配置微信群跳转链接,用户支付后自动跳转加群"})]}),s.jsx("div",{className:"mb-6 bg-[#07C160]/10 border border-[#07C160]/30 rounded-xl p-4",children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx(Bw,{className:"w-5 h-5 text-[#07C160] flex-shrink-0 mt-0.5"}),s.jsxs("div",{className:"text-sm",children:[s.jsx("p",{className:"font-medium mb-2 text-[#07C160]",children:"微信群活码配置指南"}),s.jsxs("div",{className:"text-[#07C160]/80 space-y-2",children:[s.jsx("p",{className:"font-medium",children:"方法一:使用草料活码(推荐)"}),s.jsxs("ol",{className:"list-decimal list-inside space-y-1 pl-2",children:[s.jsx("li",{children:"访问草料二维码创建活码"}),s.jsx("li",{children:"上传微信群二维码图片,生成永久链接"}),s.jsx("li",{children:"复制生成的短链接填入下方配置"}),s.jsx("li",{children:"群满后可直接在草料后台更换新群码,链接不变"})]}),s.jsx("p",{className:"font-medium mt-3",children:"方法二:直接使用微信群链接"}),s.jsxs("ol",{className:"list-decimal list-inside space-y-1 pl-2",children:[s.jsx("li",{children:'微信打开目标群 → 右上角"..." → 群二维码'}),s.jsx("li",{children:"长按二维码 → 识别二维码 → 复制链接"})]}),s.jsx("p",{className:"text-[#07C160]/60 mt-2",children:"注意:微信原生群二维码7天后失效,建议使用草料活码"})]})]})]})}),s.jsxs("div",{className:"grid gap-6 md:grid-cols-2",children:[s.jsxs(Ae,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl md:col-span-2",children:[s.jsxs(et,{children:[s.jsxs(tt,{className:"text-[#07C160] flex items-center gap-2",children:[s.jsx(Lb,{className:"w-5 h-5"}),"支付成功跳转链接(核心配置)"]}),s.jsx(Pt,{className:"text-gray-400",children:"用户支付完成后自动跳转到此链接,进入指定微信群"})]}),s.jsxs(Ie,{className:"space-y-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsxs(Z,{className:"text-gray-300 flex items-center gap-2",children:[s.jsx(Sg,{className:"w-4 h-4"}),"微信群链接 / 活码链接"]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(ae,{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)}),s.jsx(ne,{variant:"outline",size:"icon",className:"border-gray-700 bg-transparent hover:bg-gray-700/50",onClick:()=>h(n,"group"),children:i==="group"?s.jsx(cf,{className:"w-4 h-4 text-green-500"}):s.jsx(Hw,{className:"w-4 h-4 text-gray-400"})})]}),s.jsxs("p",{className:"text-xs text-gray-500 flex items-center gap-1",children:[s.jsx(_s,{className:"w-3 h-3"}),"支持格式:草料短链、微信群链接(https://weixin.qq.com/g/...)、企业微信链接等"]})]}),s.jsxs("div",{className:"flex gap-3",children:[s.jsxs(ne,{onClick:m,className:"flex-1 bg-[#07C160] hover:bg-[#06AD51] text-white",children:[s.jsx(oh,{className:"w-4 h-4 mr-2"}),"保存配置"]}),s.jsxs(ne,{onClick:g,variant:"outline",className:"border-[#07C160] text-[#07C160] hover:bg-[#07C160]/10 bg-transparent",children:[s.jsx(_s,{className:"w-4 h-4 mr-2"}),"测试跳转"]})]})]})]}),s.jsxs(Ae,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl md:col-span-2",children:[s.jsxs(et,{children:[s.jsxs(tt,{className:"text-white flex items-center gap-2",children:[s.jsx(Lb,{className:"w-5 h-5 text-[#38bdac]"}),"多群轮换(高级配置)"]}),s.jsx(Pt,{className:"text-gray-400",children:"配置多个群链接,系统自动轮换分配,避免单群满员"})]}),s.jsxs(Ie,{className:"space-y-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsxs(Z,{className:"text-gray-300 flex items-center gap-2",children:[s.jsx(Sg,{className:"w-4 h-4"}),"多个群链接(每行一个)"]}),s.jsx(_l,{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)}),s.jsx("p",{className:"text-xs text-gray-500",children:"每行填写一个群链接,系统将按顺序或随机分配"})]}),s.jsxs("div",{className:"flex items-center justify-between p-3 bg-[#0a1628] rounded-lg border border-gray-700/50",children:[s.jsx("span",{className:"text-sm text-gray-400",children:"已配置群数量"}),s.jsxs("span",{className:"font-bold text-[#38bdac]",children:[t.split(` -`).filter(Boolean).length," 个"]})]}),s.jsxs(ne,{onClick:f,className:"w-full bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(oh,{className:"w-4 h-4 mr-2"}),"保存多群配置"]})]})]})]}),s.jsxs("div",{className:"mt-6 bg-[#0f2137] rounded-xl p-4 border border-gray-700/50",children:[s.jsx("h4",{className:"text-white font-medium mb-3",children:"常见问题"}),s.jsxs("div",{className:"space-y-3 text-sm",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-[#38bdac]",children:"Q: 为什么推荐使用草料活码?"}),s.jsx("p",{className:"text-gray-400",children:"A: 草料活码是永久链接,群满后可直接在后台更换新群码,无需修改网站配置。微信原生群码7天失效。"})]}),s.jsxs("div",{children:[s.jsx("p",{className:"text-[#38bdac]",children:"Q: 支付后没有跳转怎么办?"}),s.jsx("p",{className:"text-gray-400",children:"A: 1) 检查链接是否正确填写 2) 部分浏览器可能拦截弹窗,用户需手动允许 3) 建议使用https开头的链接"})]})]})]})]})}const xw={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}},gV=["⭐","👥","❤️","🎮","💼","🚀","💡","🎯","🔥","✨"];function xV(){const[t,e]=b.useState(xw),[n,r]=b.useState(!0),[i,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 Le("/api/db/config/full?key=match_config"),T=(C==null?void 0:C.data)??(C==null?void 0:C.config);T&&e({...xw,...T})}catch(C){console.error("加载匹配配置失败:",C)}finally{r(!1)}};b.useEffect(()=>{g()},[]);const y=async()=>{a(!0);try{const C=await xt("/api/db/config",{key:"match_config",value:t,description:"匹配功能配置"});C&&C.success!==!1?oe.success("配置保存成功!"):oe.error("保存失败: "+(C&&typeof C=="object"&&"error"in C?C.error:"未知错误"))}catch(C){console.error("保存配置失败:",C),oe.error("保存失败")}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)},w=()=>{h(null),m({id:"",label:"",matchLabel:"",icon:"⭐",matchFromDB:!1,showJoinAfterMatch:!0,price:1,enabled:!0}),c(!0)},N=()=>{if(!f.id||!f.label){oe.error("请填写类型ID和名称");return}const C=[...t.matchTypes];if(u){const T=C.findIndex(O=>O.id===u.id);T!==-1&&(C[T]={...f})}else{if(C.some(T=>T.id===f.id)){oe.error("类型ID已存在");return}C.push({...f})}e({...t,matchTypes:C}),c(!1)},k=C=>{confirm("确定要删除这个匹配类型吗?")&&e({...t,matchTypes:t.matchTypes.filter(T=>T.id!==C)})},E=C=>{e({...t,matchTypes:t.matchTypes.map(T=>T.id===C?{...T,enabled:!T.enabled}:T)})};return s.jsxs("div",{className:"p-8 w-full space-y-6",children:[s.jsxs("div",{className:"flex justify-between items-center",children:[s.jsxs("div",{children:[s.jsxs("h2",{className:"text-2xl font-bold text-white flex items-center gap-2",children:[s.jsx(so,{className:"w-6 h-6 text-[#38bdac]"}),"匹配功能配置"]}),s.jsx("p",{className:"text-gray-400 mt-1",children:"管理找伙伴功能的匹配类型和价格"})]}),s.jsxs("div",{className:"flex gap-3",children:[s.jsxs(ne,{variant:"outline",onClick:g,disabled:n,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Ke,{className:`w-4 h-4 mr-2 ${n?"animate-spin":""}`}),"刷新"]}),s.jsxs(ne,{onClick:y,disabled:i,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(cn,{className:"w-4 h-4 mr-2"}),i?"保存中...":"保存配置"]})]})]}),s.jsxs(Ae,{className:"bg-[#0f2137] border-gray-700/50",children:[s.jsxs(et,{children:[s.jsxs(tt,{className:"text-white flex items-center gap-2",children:[s.jsx(ia,{className:"w-5 h-5 text-yellow-400"}),"基础设置"]}),s.jsx(Pt,{className:"text-gray-400",children:"配置免费匹配次数和付费规则"})]}),s.jsxs(Ie,{className:"space-y-6",children:[s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"每日免费匹配次数"}),s.jsx(ae,{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})}),s.jsx("p",{className:"text-xs text-gray-500",children:"用户每天可免费匹配的次数"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"付费匹配价格(元)"}),s.jsx(ae,{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})}),s.jsx("p",{className:"text-xs text-gray-500",children:"免费次数用完后的单次匹配价格"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"每日最大匹配次数"}),s.jsx(ae,{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}})}),s.jsx("p",{className:"text-xs text-gray-500",children:"包含免费和付费的总次数"})]})]}),s.jsxs("div",{className:"flex gap-8 pt-4 border-t border-gray-700/50",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(jt,{checked:t.settings.enableFreeMatches,onCheckedChange:C=>e({...t,settings:{...t.settings,enableFreeMatches:C}})}),s.jsx(Z,{className:"text-gray-300",children:"启用免费匹配"})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(jt,{checked:t.settings.enablePaidMatches,onCheckedChange:C=>e({...t,settings:{...t.settings,enablePaidMatches:C}})}),s.jsx(Z,{className:"text-gray-300",children:"启用付费匹配"})]})]})]})]}),s.jsxs(Ae,{className:"bg-[#0f2137] border-gray-700/50",children:[s.jsxs(et,{className:"flex flex-row items-center justify-between",children:[s.jsxs("div",{children:[s.jsxs(tt,{className:"text-white flex items-center gap-2",children:[s.jsx($n,{className:"w-5 h-5 text-[#38bdac]"}),"匹配类型管理"]}),s.jsx(Pt,{className:"text-gray-400",children:"配置不同的匹配类型及其价格"})]}),s.jsxs(ne,{onClick:w,size:"sm",className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(rn,{className:"w-4 h-4 mr-1"}),"添加类型"]})]}),s.jsx(Ie,{children:s.jsxs(qn,{children:[s.jsx(Gn,{children:s.jsxs(rt,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[s.jsx(ke,{className:"text-gray-400",children:"图标"}),s.jsx(ke,{className:"text-gray-400",children:"类型ID"}),s.jsx(ke,{className:"text-gray-400",children:"显示名称"}),s.jsx(ke,{className:"text-gray-400",children:"匹配标签"}),s.jsx(ke,{className:"text-gray-400",children:"价格"}),s.jsx(ke,{className:"text-gray-400",children:"数据库匹配"}),s.jsx(ke,{className:"text-gray-400",children:"状态"}),s.jsx(ke,{className:"text-right text-gray-400",children:"操作"})]})}),s.jsx(Jn,{children:t.matchTypes.map(C=>s.jsxs(rt,{className:"hover:bg-[#0a1628] border-gray-700/50",children:[s.jsx(xe,{children:s.jsx("span",{className:"text-2xl",children:C.icon})}),s.jsx(xe,{className:"font-mono text-gray-300",children:C.id}),s.jsx(xe,{className:"text-white font-medium",children:C.label}),s.jsx(xe,{className:"text-gray-300",children:C.matchLabel}),s.jsx(xe,{children:s.jsxs(He,{className:"bg-yellow-500/20 text-yellow-400 hover:bg-yellow-500/20 border-0",children:["¥",C.price]})}),s.jsx(xe,{children:C.matchFromDB?s.jsx(He,{className:"bg-green-500/20 text-green-400 hover:bg-green-500/20 border-0",children:"是"}):s.jsx(He,{variant:"outline",className:"text-gray-500 border-gray-600",children:"否"})}),s.jsx(xe,{children:s.jsx(jt,{checked:C.enabled,onCheckedChange:()=>E(C.id)})}),s.jsx(xe,{className:"text-right",children:s.jsxs("div",{className:"flex items-center justify-end gap-1",children:[s.jsx(ne,{variant:"ghost",size:"sm",onClick:()=>v(C),className:"text-gray-400 hover:text-[#38bdac] hover:bg-[#38bdac]/10",children:s.jsx(Rt,{className:"w-4 h-4"})}),s.jsx(ne,{variant:"ghost",size:"sm",onClick:()=>k(C.id),className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:s.jsx(Dn,{className:"w-4 h-4"})})]})})]},C.id))})]})})]}),s.jsx(Kt,{open:o,onOpenChange:c,children:s.jsxs(Vt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-lg",showCloseButton:!0,children:[s.jsx(qt,{children:s.jsxs(Gt,{className:"text-white flex items-center gap-2",children:[u?s.jsx(Rt,{className:"w-5 h-5 text-[#38bdac]"}):s.jsx(rn,{className:"w-5 h-5 text-[#38bdac]"}),u?"编辑匹配类型":"添加匹配类型"]})}),s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"类型ID(英文)"}),s.jsx(ae,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如: partner",value:f.id,onChange:C=>m({...f,id:C.target.value}),disabled:!!u})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"图标"}),s.jsx("div",{className:"flex gap-1 flex-wrap",children:gV.map(C=>s.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))})]})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"显示名称"}),s.jsx(ae,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如: 创业合伙",value:f.label,onChange:C=>m({...f,label:C.target.value})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"匹配标签"}),s.jsx(ae,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如: 创业伙伴",value:f.matchLabel,onChange:C=>m({...f,matchLabel:C.target.value})})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"单次匹配价格(元)"}),s.jsx(ae,{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})})]}),s.jsxs("div",{className:"flex gap-6 pt-2",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(jt,{checked:f.matchFromDB,onCheckedChange:C=>m({...f,matchFromDB:C})}),s.jsx(Z,{className:"text-gray-300 text-sm",children:"从数据库匹配"})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(jt,{checked:f.showJoinAfterMatch,onCheckedChange:C=>m({...f,showJoinAfterMatch:C})}),s.jsx(Z,{className:"text-gray-300 text-sm",children:"匹配后显示加入"})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(jt,{checked:f.enabled,onCheckedChange:C=>m({...f,enabled:C})}),s.jsx(Z,{className:"text-gray-300 text-sm",children:"启用"})]})]})]}),s.jsxs(hn,{children:[s.jsx(ne,{variant:"outline",onClick:()=>c(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"取消"}),s.jsxs(ne,{onClick:N,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(cn,{className:"w-4 h-4 mr-2"}),"保存"]})]})]})})]})}const yw={partner:"找伙伴",investor:"资源对接",mentor:"导师顾问",team:"团队招募"};function yV(){const[t,e]=b.useState([]),[n,r]=b.useState(0),[i,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 N=new URLSearchParams({page:String(i),pageSize:String(o)});u&&N.set("matchType",u);const k=await Le(`/api/db/match-records?${N}`);k!=null&&k.success?(e(k.records||[]),r(k.total??0)):y("加载匹配记录失败")}catch(N){console.error("加载匹配记录失败",N),y("加载失败,请检查网络后重试")}finally{m(!1)}}b.useEffect(()=>{v()},[i,u]);const w=Math.ceil(n/o)||1;return s.jsxs("div",{className:"p-8 w-full",children:[g&&s.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:[s.jsx("span",{children:g}),s.jsx("button",{type:"button",onClick:()=>y(null),className:"hover:text-red-300",children:"×"})]}),s.jsxs("div",{className:"flex justify-between items-center mb-8",children:[s.jsxs("div",{children:[s.jsx("h2",{className:"text-2xl font-bold text-white",children:"匹配记录"}),s.jsxs("p",{className:"text-gray-400 mt-1",children:["找伙伴匹配统计,共 ",n," 条记录"]})]}),s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsxs("select",{value:u,onChange:N=>{h(N.target.value),a(1)},className:"bg-[#0f2137] border border-gray-700 text-white rounded-lg px-3 py-2 text-sm",children:[s.jsx("option",{value:"",children:"全部类型"}),Object.entries(yw).map(([N,k])=>s.jsx("option",{value:N,children:k},N))]}),s.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:[s.jsx(Ke,{className:`w-4 h-4 ${f?"animate-spin":""}`}),"刷新"]})]})]}),s.jsx(Ae,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:s.jsx(Ie,{className:"p-0",children:f?s.jsxs("div",{className:"flex justify-center py-12",children:[s.jsx(Ke,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):s.jsxs(s.Fragment,{children:[s.jsxs(qn,{children:[s.jsx(Gn,{children:s.jsxs(rt,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[s.jsx(ke,{className:"text-gray-400",children:"发起人"}),s.jsx(ke,{className:"text-gray-400",children:"匹配到"}),s.jsx(ke,{className:"text-gray-400",children:"类型"}),s.jsx(ke,{className:"text-gray-400",children:"联系方式"}),s.jsx(ke,{className:"text-gray-400",children:"匹配时间"})]})}),s.jsxs(Jn,{children:[t.map(N=>s.jsxs(rt,{className:"hover:bg-[#0a1628] border-gray-700/50",children:[s.jsx(xe,{children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.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:[N.userAvatar?s.jsx("img",{src:N.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,s.jsx("span",{className:N.userAvatar?"hidden":"",children:(N.userNickname||N.userId||"?").charAt(0)})]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-white",children:N.userNickname||N.userId}),s.jsxs("div",{className:"text-xs text-gray-500 font-mono",children:[N.userId.slice(0,16),"..."]})]})]})}),s.jsx(xe,{children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.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:[N.matchedUserAvatar?s.jsx("img",{src:N.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,s.jsx("span",{className:N.matchedUserAvatar?"hidden":"",children:(N.matchedNickname||N.matchedUserId||"?").charAt(0)})]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-white",children:N.matchedNickname||N.matchedUserId}),s.jsxs("div",{className:"text-xs text-gray-500 font-mono",children:[N.matchedUserId.slice(0,16),"..."]})]})]})}),s.jsx(xe,{children:s.jsx(He,{className:"bg-[#38bdac]/20 text-[#38bdac] border-0",children:yw[N.matchType]||N.matchType})}),s.jsxs(xe,{className:"text-gray-400 text-sm",children:[N.phone&&s.jsxs("div",{children:["📱 ",N.phone]}),N.wechatId&&s.jsxs("div",{children:["💬 ",N.wechatId]}),!N.phone&&!N.wechatId&&"-"]}),s.jsx(xe,{className:"text-gray-400",children:N.createdAt?new Date(N.createdAt).toLocaleString():"-"})]},N.id)),t.length===0&&s.jsx(rt,{children:s.jsx(xe,{colSpan:5,className:"text-center py-12 text-gray-500",children:"暂无匹配记录"})})]})]}),s.jsx(ms,{page:i,totalPages:w,total:n,pageSize:o,onPageChange:a,onPageSizeChange:N=>{c(N),a(1)}})]})})})]})}function vV(){const[t,e]=b.useState([]),[n,r]=b.useState(!0);async function i(){r(!0);try{const a=await Le("/api/db/vip-members?limit=100");if(a!=null&&a.success&&a.data){const o=[...a.data].map((c,u)=>({...c,vipSort:typeof c.vipSort=="number"?c.vipSort:u+1}));o.sort((c,u)=>(c.vipSort??999999)-(u.vipSort??999999)),e(o)}}catch(a){console.error("Load VIP members error:",a),oe.error("加载 VIP 成员失败")}finally{r(!1)}}return b.useEffect(()=>{i()},[]),s.jsxs("div",{className:"p-8 w-full",children:[s.jsx("div",{className:"flex justify-between items-center mb-8",children:s.jsxs("div",{children:[s.jsxs("h2",{className:"text-2xl font-bold text-white flex items-center gap-2",children:[s.jsx(xl,{className:"w-5 h-5 text-amber-400"}),"用户管理 / 超级个体列表"]}),s.jsx("p",{className:"text-gray-400 mt-1",children:"这里展示所有有效超级个体用户,仅用于查看其基本信息与排序值。"})]})}),s.jsx(Ae,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsx(Ie,{className:"p-0",children:n?s.jsx("div",{className:"py-12 text-center text-gray-400",children:"加载中..."}):s.jsxs(qn,{children:[s.jsx(Gn,{children:s.jsxs(rt,{className:"bg-[#0a1628] border-gray-700",children:[s.jsx(ke,{className:"text-gray-400 w-20",children:"序号"}),s.jsx(ke,{className:"text-gray-400",children:"成员"}),s.jsx(ke,{className:"text-gray-400 w-40",children:"超级个体"}),s.jsx(ke,{className:"text-gray-400 w-28",children:"排序值"})]})}),s.jsxs(Jn,{children:[t.map((a,o)=>{var c;return s.jsxs(rt,{className:"border-gray-700/50",children:[s.jsx(xe,{className:"text-gray-300",children:o+1}),s.jsx(xe,{children:s.jsxs("div",{className:"flex items-center gap-3",children:[a.avatar?s.jsx("img",{src:a.avatar,className:"w-8 h-8 rounded-full object-cover border border-amber-400/60"}):s.jsx("div",{className:"w-8 h-8 rounded-full bg-amber-500/20 border border-amber-400/60 flex items-center justify-center text-amber-300 text-sm",children:((c=a.name)==null?void 0:c[0])||"创"}),s.jsx("div",{className:"min-w-0",children:s.jsx("div",{className:"text-white text-sm truncate",children:a.name})})]})}),s.jsx(xe,{className:"text-gray-300",children:a.vipRole||s.jsx("span",{className:"text-gray-500",children:"(未设置超级个体)"})}),s.jsx(xe,{className:"text-gray-300",children:a.vipSort??o+1})]},a.id)}),t.length===0&&s.jsx(rt,{children:s.jsx(xe,{colSpan:5,className:"text-center py-12 text-gray-500",children:"当前没有有效的超级个体用户。"})})]})]})})})]})}function R4(t){const[e,n]=b.useState([]),[r,i]=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),w=b.useRef(null),N=async R=>{var L;const P=(L=R.target.files)==null?void 0:L[0];if(P){v(!0);try{const ee=new FormData;ee.append("file",P),ee.append("folder","mentors");const te=Ox(),Y={};te&&(Y.Authorization=`Bearer ${te}`);const D=await(await fetch(ho("/api/upload"),{method:"POST",body:ee,credentials:"include",headers:Y})).json();D!=null&&D.success&&(D!=null&&D.url)?f($=>({...$,avatar:D.url})):oe.error("上传失败: "+((D==null?void 0:D.error)||"未知错误"))}catch(ee){console.error(ee),oe.error("上传失败")}finally{v(!1),w.current&&(w.current.value="")}}};async function k(){i(!0);try{const R=await Le("/api/db/mentors");R!=null&&R.success&&R.data&&n(R.data)}catch(R){console.error("Load mentors error:",R)}finally{i(!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(R=>R.sort))+1:0,enabled:!0})},C=()=>{u(null),E(),o(!0)},T=R=>{u(R),f({name:R.name,avatar:R.avatar||"",intro:R.intro||"",tags:R.tags||"",priceSingle:R.priceSingle!=null?String(R.priceSingle):"",priceHalfYear:R.priceHalfYear!=null?String(R.priceHalfYear):"",priceYear:R.priceYear!=null?String(R.priceYear):"",quote:R.quote||"",whyFind:R.whyFind||"",offering:R.offering||"",judgmentStyle:R.judgmentStyle||"",sort:R.sort,enabled:R.enabled??!0}),o(!0)},O=async()=>{if(!h.name.trim()){oe.error("导师姓名不能为空");return}g(!0);try{const R=L=>L===""?void 0:parseFloat(L),P={name:h.name.trim(),avatar:h.avatar.trim()||void 0,intro:h.intro.trim()||void 0,tags:h.tags.trim()||void 0,priceSingle:R(h.priceSingle),priceHalfYear:R(h.priceHalfYear),priceYear:R(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 L=await St("/api/db/mentors",{id:c.id,...P});L!=null&&L.success?(o(!1),k()):oe.error("更新失败: "+(L==null?void 0:L.error))}else{const L=await xt("/api/db/mentors",P);L!=null&&L.success?(o(!1),k()):oe.error("新增失败: "+(L==null?void 0:L.error))}}catch(R){console.error("Save error:",R),oe.error("保存失败")}finally{g(!1)}},F=async R=>{if(confirm("确定删除该导师?"))try{const P=await Ps(`/api/db/mentors?id=${R}`);P!=null&&P.success?k():oe.error("删除失败: "+(P==null?void 0:P.error))}catch(P){console.error("Delete error:",P),oe.error("删除失败")}},I=R=>R!=null?`¥${R}`:"-";return s.jsxs("div",{className:"p-8 w-full",children:[s.jsxs("div",{className:"flex justify-between items-center mb-8",children:[s.jsxs("div",{children:[s.jsxs("h2",{className:"text-2xl font-bold text-white flex items-center gap-2",children:[s.jsx($n,{className:"w-5 h-5 text-[#38bdac]"}),"导师管理"]}),s.jsx("p",{className:"text-gray-400 mt-1",children:"stitch_soul 导师列表,支持每个导师独立配置单次/半年/年度价格"})]}),s.jsxs(ne,{onClick:C,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(rn,{className:"w-4 h-4 mr-2"}),"新增导师"]})]}),s.jsx(Ae,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsx(Ie,{className:"p-0",children:r?s.jsx("div",{className:"py-12 text-center text-gray-400",children:"加载中..."}):s.jsxs(qn,{children:[s.jsx(Gn,{children:s.jsxs(rt,{className:"bg-[#0a1628] border-gray-700",children:[s.jsx(ke,{className:"text-gray-400",children:"ID"}),s.jsx(ke,{className:"text-gray-400",children:"姓名"}),s.jsx(ke,{className:"text-gray-400",children:"简介"}),s.jsx(ke,{className:"text-gray-400",children:"单次"}),s.jsx(ke,{className:"text-gray-400",children:"半年"}),s.jsx(ke,{className:"text-gray-400",children:"年度"}),s.jsx(ke,{className:"text-gray-400",children:"排序"}),s.jsx(ke,{className:"text-right text-gray-400",children:"操作"})]})}),s.jsxs(Jn,{children:[e.map(R=>s.jsxs(rt,{className:"border-gray-700/50",children:[s.jsx(xe,{className:"text-gray-300",children:R.id}),s.jsx(xe,{className:"text-white",children:R.name}),s.jsx(xe,{className:"text-gray-400 max-w-[200px] truncate",children:R.intro||"-"}),s.jsx(xe,{className:"text-gray-400",children:I(R.priceSingle)}),s.jsx(xe,{className:"text-gray-400",children:I(R.priceHalfYear)}),s.jsx(xe,{className:"text-gray-400",children:I(R.priceYear)}),s.jsx(xe,{className:"text-gray-400",children:R.sort}),s.jsxs(xe,{className:"text-right",children:[s.jsx(ne,{variant:"ghost",size:"sm",onClick:()=>T(R),className:"text-gray-400 hover:text-[#38bdac]",children:s.jsx(Rt,{className:"w-4 h-4"})}),s.jsx(ne,{variant:"ghost",size:"sm",onClick:()=>F(R.id),className:"text-gray-400 hover:text-red-400",children:s.jsx(Dn,{className:"w-4 h-4"})})]})]},R.id)),e.length===0&&s.jsx(rt,{children:s.jsx(xe,{colSpan:8,className:"text-center py-12 text-gray-500",children:"暂无导师,点击「新增导师」添加"})})]})]})})}),s.jsx(Kt,{open:a,onOpenChange:o,children:s.jsxs(Vt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-lg max-h-[90vh] overflow-y-auto",children:[s.jsx(qt,{children:s.jsx(Gt,{className:"text-white",children:c?"编辑导师":"新增导师"})}),s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"姓名 *"}),s.jsx(ae,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如:卡若",value:h.name,onChange:R=>f(P=>({...P,name:R.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"排序"}),s.jsx(ae,{type:"number",className:"bg-[#0a1628] border-gray-700 text-white",value:h.sort,onChange:R=>f(P=>({...P,sort:parseInt(R.target.value,10)||0}))})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"头像"}),s.jsxs("div",{className:"flex gap-3 items-center",children:[s.jsx(ae,{className:"flex-1 bg-[#0a1628] border-gray-700 text-white",value:h.avatar,onChange:R=>f(P=>({...P,avatar:R.target.value})),placeholder:"点击上传或粘贴图片地址"}),s.jsx("input",{ref:w,type:"file",accept:"image/*",className:"hidden",onChange:N}),s.jsxs(ne,{type:"button",variant:"outline",size:"sm",className:"border-gray-600 text-gray-400 shrink-0",disabled:y,onClick:()=>{var R;return(R=w.current)==null?void 0:R.click()},children:[s.jsx(oh,{className:"w-4 h-4 mr-2"}),y?"上传中...":"上传"]})]}),h.avatar&&s.jsx("div",{className:"mt-2",children:s.jsx("img",{src:h.avatar.startsWith("http")?h.avatar:ho(h.avatar),alt:"头像预览",className:"w-20 h-20 rounded-full object-cover border border-gray-600"})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"简介"}),s.jsx(ae,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如:结构判断型咨询 · Decision > Execution",value:h.intro,onChange:R=>f(P=>({...P,intro:R.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"技能标签(逗号分隔)"}),s.jsx(ae,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如:项目结构判断、风险止损、人×项目匹配",value:h.tags,onChange:R=>f(P=>({...P,tags:R.target.value}))})]}),s.jsxs("div",{className:"border-t border-gray-700 pt-4",children:[s.jsx(Z,{className:"text-gray-300 block mb-2",children:"价格配置(每个导师独立)"}),s.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-500 text-xs",children:"单次咨询 ¥"}),s.jsx(ae,{type:"number",step:"0.01",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"980",value:h.priceSingle,onChange:R=>f(P=>({...P,priceSingle:R.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-500 text-xs",children:"半年咨询 ¥"}),s.jsx(ae,{type:"number",step:"0.01",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"19800",value:h.priceHalfYear,onChange:R=>f(P=>({...P,priceHalfYear:R.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-500 text-xs",children:"年度咨询 ¥"}),s.jsx(ae,{type:"number",step:"0.01",className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"29800",value:h.priceYear,onChange:R=>f(P=>({...P,priceYear:R.target.value}))})]})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"引言"}),s.jsx(ae,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如:大多数人失败,不是因为不努力...",value:h.quote,onChange:R=>f(P=>({...P,quote:R.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"为什么找(文本)"}),s.jsx(ae,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"",value:h.whyFind,onChange:R=>f(P=>({...P,whyFind:R.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"提供什么(文本)"}),s.jsx(ae,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"",value:h.offering,onChange:R=>f(P=>({...P,offering:R.target.value}))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"判断风格(逗号分隔)"}),s.jsx(ae,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如:冷静、克制、偏风险视角",value:h.judgmentStyle,onChange:R=>f(P=>({...P,judgmentStyle:R.target.value}))})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"checkbox",id:"enabled",checked:h.enabled,onChange:R=>f(P=>({...P,enabled:R.target.checked})),className:"rounded border-gray-600 bg-[#0a1628]"}),s.jsx(Z,{htmlFor:"enabled",className:"text-gray-300 cursor-pointer",children:"上架(小程序可见)"})]})]}),s.jsxs(hn,{children:[s.jsxs(ne,{variant:"outline",onClick:()=>o(!1),className:"border-gray-600 text-gray-300",children:[s.jsx(or,{className:"w-4 h-4 mr-2"}),"取消"]}),s.jsxs(ne,{onClick:O,disabled:m,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(cn,{className:"w-4 h-4 mr-2"}),m?"保存中...":"保存"]})]})]})})]})}function bV(){const[t,e]=b.useState([]),[n,r]=b.useState(!0),[i,a]=b.useState("");async function o(){r(!0);try{const h=i?`/api/db/mentor-consultations?status=${i}`:"/api/db/mentor-consultations",f=await Le(h);f!=null&&f.success&&f.data&&e(f.data)}catch(h){console.error("Load consultations error:",h)}finally{r(!1)}}b.useEffect(()=>{o()},[i]);const c={created:"已创建",pending_pay:"待支付",paid:"已支付",completed:"已完成",cancelled:"已取消"},u={single:"单次",half_year:"半年",year:"年度"};return s.jsxs("div",{className:"p-8 w-full",children:[s.jsxs("div",{className:"flex justify-between items-center mb-8",children:[s.jsxs("div",{children:[s.jsxs("h2",{className:"text-2xl font-bold text-white flex items-center gap-2",children:[s.jsx(ih,{className:"w-5 h-5 text-[#38bdac]"}),"导师预约列表"]}),s.jsx("p",{className:"text-gray-400 mt-1",children:"stitch_soul 导师咨询预约记录"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("select",{value:i,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:[s.jsx("option",{value:"",children:"全部状态"}),Object.entries(c).map(([h,f])=>s.jsx("option",{value:h,children:f},h))]}),s.jsxs(ne,{onClick:o,disabled:n,variant:"outline",className:"border-gray-600 text-gray-300",children:[s.jsx(Ke,{className:`w-4 h-4 mr-2 ${n?"animate-spin":""}`}),"刷新"]})]})]}),s.jsx(Ae,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsx(Ie,{className:"p-0",children:n?s.jsx("div",{className:"py-12 text-center text-gray-400",children:"加载中..."}):s.jsxs(qn,{children:[s.jsx(Gn,{children:s.jsxs(rt,{className:"bg-[#0a1628] border-gray-700",children:[s.jsx(ke,{className:"text-gray-400",children:"ID"}),s.jsx(ke,{className:"text-gray-400",children:"用户ID"}),s.jsx(ke,{className:"text-gray-400",children:"导师ID"}),s.jsx(ke,{className:"text-gray-400",children:"类型"}),s.jsx(ke,{className:"text-gray-400",children:"金额"}),s.jsx(ke,{className:"text-gray-400",children:"状态"}),s.jsx(ke,{className:"text-gray-400",children:"创建时间"})]})}),s.jsxs(Jn,{children:[t.map(h=>s.jsxs(rt,{className:"border-gray-700/50",children:[s.jsx(xe,{className:"text-gray-300",children:h.id}),s.jsx(xe,{className:"text-gray-400",children:h.userId}),s.jsx(xe,{className:"text-gray-400",children:h.mentorId}),s.jsx(xe,{className:"text-gray-400",children:u[h.consultationType]||h.consultationType}),s.jsxs(xe,{className:"text-white",children:["¥",h.amount]}),s.jsx(xe,{className:"text-gray-400",children:c[h.status]||h.status}),s.jsx(xe,{className:"text-gray-500 text-sm",children:h.createdAt})]},h.id)),t.length===0&&s.jsx(rt,{children:s.jsx(xe,{colSpan:7,className:"text-center py-12 text-gray-500",children:"暂无预约记录"})})]})]})})})]})}const Pc={poolSource:["vip"],requirePhone:!0,requireNickname:!0,requireAvatar:!1,requireBusiness:!1},vw={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:Pc},NV=["⭐","👥","❤️","🎮","💼","🚀","💡","🎯","🔥","✨"];function wV(){const t=ja(),[e,n]=b.useState(vw),[r,i]=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),[w,N]=b.useState(!1),k=async()=>{N(!0);try{const P=await Le("/api/db/match-pool-counts");P!=null&&P.success&&P.data&&v(P.data)}catch(P){console.error("加载池子人数失败:",P)}finally{N(!1)}},E=async()=>{i(!0);try{const P=await Le("/api/db/config/full?key=match_config"),L=(P==null?void 0:P.data)??(P==null?void 0:P.config);if(L){let ee=L.poolSettings??Pc;ee.poolSource&&!Array.isArray(ee.poolSource)&&(ee={...ee,poolSource:[ee.poolSource]}),n({...vw,...L,poolSettings:ee})}}catch(P){console.error("加载匹配配置失败:",P)}finally{i(!1)}};b.useEffect(()=>{E(),k()},[]);const C=async()=>{o(!0);try{const P=await xt("/api/db/config",{key:"match_config",value:e,description:"匹配功能配置"});oe.error((P==null?void 0:P.success)!==!1?"配置保存成功!":"保存失败: "+((P==null?void 0:P.error)||"未知错误"))}catch(P){console.error(P),oe.error("保存失败")}finally{o(!1)}},T=P=>{f(P),g({...P}),u(!0)},O=()=>{f(null),g({id:"",label:"",matchLabel:"",icon:"⭐",matchFromDB:!1,showJoinAfterMatch:!0,price:1,enabled:!0}),u(!0)},F=()=>{if(!m.id||!m.label){oe.error("请填写类型ID和名称");return}const P=[...e.matchTypes];if(h){const L=P.findIndex(ee=>ee.id===h.id);L!==-1&&(P[L]={...m})}else{if(P.some(L=>L.id===m.id)){oe.error("类型ID已存在");return}P.push({...m})}n({...e,matchTypes:P}),u(!1)},I=P=>{confirm("确定要删除这个匹配类型吗?")&&n({...e,matchTypes:e.matchTypes.filter(L=>L.id!==P)})},R=P=>{n({...e,matchTypes:e.matchTypes.map(L=>L.id===P?{...L,enabled:!L.enabled}:L)})};return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"flex justify-end gap-3",children:[s.jsxs(ne,{variant:"outline",onClick:E,disabled:r,className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Ke,{className:`w-4 h-4 mr-2 ${r?"animate-spin":""}`})," 刷新"]}),s.jsxs(ne,{onClick:C,disabled:a,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(cn,{className:"w-4 h-4 mr-2"})," ",a?"保存中...":"保存配置"]})]}),s.jsxs(Ae,{className:"bg-[#0f2137] border-gray-700/50",children:[s.jsxs(et,{children:[s.jsxs(tt,{className:"text-white flex items-center gap-2",children:[s.jsx(Ww,{className:"w-5 h-5 text-blue-400"})," 匹配池选择"]}),s.jsx(Pt,{className:"text-gray-400",children:"选择匹配的用户池和完善程度要求,只有满足条件的用户才可被匹配到"})]}),s.jsxs(Ie,{className:"space-y-6",children:[s.jsxs("div",{className:"space-y-3",children:[s.jsx(Z,{className:"text-gray-300",children:"匹配来源池"}),s.jsx("p",{className:"text-gray-500 text-xs",children:"可同时勾选多个池子(取并集匹配)"}),s.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(P=>{const L=e.poolSettings??Pc,te=(Array.isArray(L.poolSource)?L.poolSource:[L.poolSource]).includes(P.value),Y=y==null?void 0:y[P.countKey],U=()=>{const D=Array.isArray(L.poolSource)?[...L.poolSource]:[L.poolSource],$=te?D.filter(le=>le!==P.value):[...D,P.value];$.length===0&&$.push(P.value),n({...e,poolSettings:{...L,poolSource:$}})};return s.jsxs("button",{type:"button",onClick:U,className:`p-4 rounded-lg border text-left transition-all ${te?"border-[#38bdac] bg-[#38bdac]/10":"border-gray-700 bg-[#0a1628] hover:border-gray-600"}`,children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:`w-5 h-5 rounded border-2 flex items-center justify-center text-xs ${te?"border-[#38bdac] bg-[#38bdac] text-white":"border-gray-600"}`,children:te&&"✓"}),s.jsx("span",{className:"text-xl",children:P.icon}),s.jsx("span",{className:`text-sm font-medium ${te?"text-[#38bdac]":"text-gray-300"}`,children:P.label})]}),s.jsxs("span",{className:"text-lg font-bold text-white",children:[w?"...":Y??"-",s.jsx("span",{className:"text-xs text-gray-500 font-normal ml-1",children:"人"})]})]}),s.jsx("p",{className:"text-gray-500 text-xs mt-2",children:P.desc}),s.jsx("span",{role:"link",tabIndex:0,onClick:D=>{D.stopPropagation(),t(`/users?pool=${P.value}`)},onKeyDown:D=>{D.key==="Enter"&&(D.stopPropagation(),t(`/users?pool=${P.value}`))},className:"text-[#38bdac] text-xs mt-2 inline-block hover:underline cursor-pointer",children:"查看用户列表 →"})]},P.value)})})]}),s.jsxs("div",{className:"space-y-3 pt-4 border-t border-gray-700/50",children:[s.jsx(Z,{className:"text-gray-300",children:"用户资料完善要求(被匹配用户必须满足以下条件)"}),s.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(P=>{const ee=(e.poolSettings??Pc)[P.key];return s.jsxs("div",{className:"flex items-center gap-3 bg-[#0a1628] rounded-lg p-3",children:[s.jsx(jt,{checked:ee,onCheckedChange:te=>n({...e,poolSettings:{...e.poolSettings??Pc,[P.key]:te}})}),s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("span",{children:P.icon}),s.jsx(Z,{className:"text-gray-300 text-sm",children:P.label})]})]},P.key)})})]})]})]}),s.jsxs(Ae,{className:"bg-[#0f2137] border-gray-700/50",children:[s.jsxs(et,{children:[s.jsxs(tt,{className:"text-white flex items-center gap-2",children:[s.jsx(ia,{className:"w-5 h-5 text-yellow-400"})," 基础设置"]}),s.jsx(Pt,{className:"text-gray-400",children:"配置免费匹配次数和付费规则"})]}),s.jsxs(Ie,{className:"space-y-6",children:[s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"每日免费匹配次数"}),s.jsx(ae,{type:"number",min:0,max:100,className:"bg-[#0a1628] border-gray-700 text-white",value:e.freeMatchLimit,onChange:P=>n({...e,freeMatchLimit:parseInt(P.target.value,10)||0})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"付费匹配价格(元)"}),s.jsx(ae,{type:"number",min:.01,step:.01,className:"bg-[#0a1628] border-gray-700 text-white",value:e.matchPrice,onChange:P=>n({...e,matchPrice:parseFloat(P.target.value)||1})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"每日最大匹配次数"}),s.jsx(ae,{type:"number",min:1,max:100,className:"bg-[#0a1628] border-gray-700 text-white",value:e.settings.maxMatchesPerDay,onChange:P=>n({...e,settings:{...e.settings,maxMatchesPerDay:parseInt(P.target.value,10)||10}})})]})]}),s.jsxs("div",{className:"flex gap-8 pt-4 border-t border-gray-700/50",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(jt,{checked:e.settings.enableFreeMatches,onCheckedChange:P=>n({...e,settings:{...e.settings,enableFreeMatches:P}})}),s.jsx(Z,{className:"text-gray-300",children:"启用免费匹配"})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(jt,{checked:e.settings.enablePaidMatches,onCheckedChange:P=>n({...e,settings:{...e.settings,enablePaidMatches:P}})}),s.jsx(Z,{className:"text-gray-300",children:"启用付费匹配"})]})]})]})]}),s.jsxs(Ae,{className:"bg-[#0f2137] border-gray-700/50",children:[s.jsxs(et,{className:"flex flex-row items-center justify-between",children:[s.jsxs("div",{children:[s.jsxs(tt,{className:"text-white flex items-center gap-2",children:[s.jsx($n,{className:"w-5 h-5 text-[#38bdac]"})," 匹配类型管理"]}),s.jsx(Pt,{className:"text-gray-400",children:"配置不同的匹配类型及其价格"})]}),s.jsxs(ne,{onClick:O,size:"sm",className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(rn,{className:"w-4 h-4 mr-1"})," 添加类型"]})]}),s.jsx(Ie,{children:s.jsxs(qn,{children:[s.jsx(Gn,{children:s.jsxs(rt,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[s.jsx(ke,{className:"text-gray-400",children:"图标"}),s.jsx(ke,{className:"text-gray-400",children:"类型ID"}),s.jsx(ke,{className:"text-gray-400",children:"显示名称"}),s.jsx(ke,{className:"text-gray-400",children:"匹配标签"}),s.jsx(ke,{className:"text-gray-400",children:"价格"}),s.jsx(ke,{className:"text-gray-400",children:"数据库匹配"}),s.jsx(ke,{className:"text-gray-400",children:"状态"}),s.jsx(ke,{className:"text-right text-gray-400",children:"操作"})]})}),s.jsx(Jn,{children:e.matchTypes.map(P=>s.jsxs(rt,{className:"hover:bg-[#0a1628] border-gray-700/50",children:[s.jsx(xe,{children:s.jsx("span",{className:"text-2xl",children:P.icon})}),s.jsx(xe,{className:"font-mono text-gray-300",children:P.id}),s.jsx(xe,{className:"text-white font-medium",children:P.label}),s.jsx(xe,{className:"text-gray-300",children:P.matchLabel}),s.jsx(xe,{children:s.jsxs(He,{className:"bg-yellow-500/20 text-yellow-400 hover:bg-yellow-500/20 border-0",children:["¥",P.price]})}),s.jsx(xe,{children:P.matchFromDB?s.jsx(He,{className:"bg-green-500/20 text-green-400 hover:bg-green-500/20 border-0",children:"是"}):s.jsx(He,{variant:"outline",className:"text-gray-500 border-gray-600",children:"否"})}),s.jsx(xe,{children:s.jsx(jt,{checked:P.enabled,onCheckedChange:()=>R(P.id)})}),s.jsx(xe,{className:"text-right",children:s.jsxs("div",{className:"flex items-center justify-end gap-1",children:[s.jsx(ne,{variant:"ghost",size:"sm",onClick:()=>T(P),className:"text-gray-400 hover:text-[#38bdac] hover:bg-[#38bdac]/10",children:s.jsx(Rt,{className:"w-4 h-4"})}),s.jsx(ne,{variant:"ghost",size:"sm",onClick:()=>I(P.id),className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:s.jsx(Dn,{className:"w-4 h-4"})})]})})]},P.id))})]})})]}),s.jsx(Kt,{open:c,onOpenChange:u,children:s.jsxs(Vt,{className:"bg-[#0f2137] border-gray-700 text-white max-w-lg",showCloseButton:!0,children:[s.jsx(qt,{children:s.jsxs(Gt,{className:"text-white flex items-center gap-2",children:[h?s.jsx(Rt,{className:"w-5 h-5 text-[#38bdac]"}):s.jsx(rn,{className:"w-5 h-5 text-[#38bdac]"}),h?"编辑匹配类型":"添加匹配类型"]})}),s.jsxs("div",{className:"space-y-4 py-4",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"类型ID(英文)"}),s.jsx(ae,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如: partner",value:m.id,onChange:P=>g({...m,id:P.target.value}),disabled:!!h})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"图标"}),s.jsx("div",{className:"flex gap-1 flex-wrap",children:NV.map(P=>s.jsx("button",{type:"button",className:`w-8 h-8 text-lg rounded ${m.icon===P?"bg-[#38bdac]/30 ring-1 ring-[#38bdac]":"bg-[#0a1628]"}`,onClick:()=>g({...m,icon:P}),children:P},P))})]})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"显示名称"}),s.jsx(ae,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如: 超级个体",value:m.label,onChange:P=>g({...m,label:P.target.value})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"匹配标签"}),s.jsx(ae,{className:"bg-[#0a1628] border-gray-700 text-white",placeholder:"如: 超级个体",value:m.matchLabel,onChange:P=>g({...m,matchLabel:P.target.value})})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(Z,{className:"text-gray-300",children:"单次匹配价格(元)"}),s.jsx(ae,{type:"number",min:.01,step:.01,className:"bg-[#0a1628] border-gray-700 text-white",value:m.price,onChange:P=>g({...m,price:parseFloat(P.target.value)||1})})]}),s.jsxs("div",{className:"flex gap-6 pt-2",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(jt,{checked:m.matchFromDB,onCheckedChange:P=>g({...m,matchFromDB:P})}),s.jsx(Z,{className:"text-gray-300 text-sm",children:"从数据库匹配"})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(jt,{checked:m.showJoinAfterMatch,onCheckedChange:P=>g({...m,showJoinAfterMatch:P})}),s.jsx(Z,{className:"text-gray-300 text-sm",children:"匹配后显示加入"})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(jt,{checked:m.enabled,onCheckedChange:P=>g({...m,enabled:P})}),s.jsx(Z,{className:"text-gray-300 text-sm",children:"启用"})]})]})]}),s.jsxs(hn,{children:[s.jsx(ne,{variant:"outline",onClick:()=>u(!1),className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:"取消"}),s.jsxs(ne,{onClick:F,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(cn,{className:"w-4 h-4 mr-2"})," 保存"]})]})]})})]})}const bw={partner:"找伙伴",investor:"资源对接",mentor:"导师顾问",team:"团队招募"};function jV(){const[t,e]=b.useState([]),[n,r]=b.useState(0),[i,a]=b.useState(1),[o,c]=b.useState(10),[u,h]=b.useState(""),[f,m]=b.useState(!0),[g,y]=b.useState(null),[v,w]=b.useState(null);async function N(){m(!0),y(null);try{const C=new URLSearchParams({page:String(i),pageSize:String(o)});u&&C.set("matchType",u);const T=await Le(`/api/db/match-records?${C}`);T!=null&&T.success?(e(T.records||[]),r(T.total??0)):y("加载匹配记录失败")}catch{y("加载失败,请检查网络后重试")}finally{m(!1)}}b.useEffect(()=>{N()},[i,u]);const k=Math.ceil(n/o)||1,E=({userId:C,nickname:T,avatar:O})=>s.jsxs("div",{className:"flex items-center gap-3 cursor-pointer group",onClick:()=>w(C),children:[s.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:[O?s.jsx("img",{src:O,alt:"",className:"w-full h-full object-cover",onError:F=>{F.currentTarget.style.display="none"}}):null,s.jsx("span",{className:O?"hidden":"",children:(T||C||"?").charAt(0)})]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-white group-hover:text-[#38bdac] transition-colors",children:T||C}),s.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 s.jsxs("div",{children:[g&&s.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:[s.jsx("span",{children:g}),s.jsx("button",{type:"button",onClick:()=>y(null),className:"hover:text-red-300",children:"×"})]}),s.jsxs("div",{className:"flex justify-between items-center mb-4",children:[s.jsxs("p",{className:"text-gray-400",children:["共 ",n," 条匹配记录 · 点击用户名查看详情"]}),s.jsxs("div",{className:"flex items-center gap-4",children:[s.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:[s.jsx("option",{value:"",children:"全部类型"}),Object.entries(bw).map(([C,T])=>s.jsx("option",{value:C,children:T},C))]}),s.jsxs("button",{type:"button",onClick:N,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:[s.jsx(Ke,{className:`w-4 h-4 ${f?"animate-spin":""}`})," 刷新"]})]})]}),s.jsx(Ae,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:s.jsx(Ie,{className:"p-0",children:f?s.jsxs("div",{className:"flex justify-center py-12",children:[s.jsx(Ke,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):s.jsxs(s.Fragment,{children:[s.jsxs(qn,{children:[s.jsx(Gn,{children:s.jsxs(rt,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[s.jsx(ke,{className:"text-gray-400",children:"发起人"}),s.jsx(ke,{className:"text-gray-400",children:"匹配到"}),s.jsx(ke,{className:"text-gray-400",children:"类型"}),s.jsx(ke,{className:"text-gray-400",children:"联系方式"}),s.jsx(ke,{className:"text-gray-400",children:"匹配时间"})]})}),s.jsxs(Jn,{children:[t.map(C=>s.jsxs(rt,{className:"hover:bg-[#0a1628] border-gray-700/50",children:[s.jsx(xe,{children:s.jsx(E,{userId:C.userId,nickname:C.userNickname,avatar:C.userAvatar})}),s.jsx(xe,{children:C.matchedUserId?s.jsx(E,{userId:C.matchedUserId,nickname:C.matchedNickname,avatar:C.matchedUserAvatar}):s.jsx("span",{className:"text-gray-500",children:"—"})}),s.jsx(xe,{children:s.jsx(He,{className:"bg-[#38bdac]/20 text-[#38bdac] border-0",children:bw[C.matchType]||C.matchType})}),s.jsxs(xe,{className:"text-sm",children:[C.phone&&s.jsxs("div",{className:"text-green-400",children:["📱 ",C.phone]}),C.wechatId&&s.jsxs("div",{className:"text-blue-400",children:["💬 ",C.wechatId]}),!C.phone&&!C.wechatId&&s.jsx("span",{className:"text-gray-600",children:"-"})]}),s.jsx(xe,{className:"text-gray-400",children:C.createdAt?new Date(C.createdAt).toLocaleString():"-"})]},C.id)),t.length===0&&s.jsx(rt,{children:s.jsx(xe,{colSpan:5,className:"text-center py-12 text-gray-500",children:"暂无匹配记录"})})]})]}),s.jsx(ms,{page:i,totalPages:k,total:n,pageSize:o,onPageChange:a,onPageSizeChange:C=>{c(C),a(1)}})]})})}),s.jsx(Jx,{open:!!v,onClose:()=>w(null),userId:v,onUserUpdated:N})]})}function kV(){const[t,e]=b.useState("records");return s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex gap-2",children:[s.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:"匹配记录"}),s.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"&&s.jsx(jV,{}),t==="pool"&&s.jsx(wV,{})]})}const Nw={investor:"资源对接",mentor:"导师顾问",team:"团队招募"};function SV(){const[t,e]=b.useState([]),[n,r]=b.useState(0),[i,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(i),pageSize:String(o),matchType:f}),C=await Le(`/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()},[i,f]);const w=async E=>{if(!E.phone&&!E.wechatId){oe.info("该记录无联系方式,无法推送到存客宝");return}y(E.id);try{const C=await xt("/api/ckb/join",{type:E.matchType||"investor",phone:E.phone||"",wechat:E.wechatId||"",userId:E.userId,name:E.userNickname||""});oe.error((C==null?void 0:C.message)||(C!=null&&C.success?"推送成功":"推送失败"))}catch(C){oe.error("推送失败: "+(C instanceof Error?C.message:"网络错误"))}finally{y(null)}},N=Math.ceil(n/o)||1,k=E=>!!(E.phone||E.wechatId);return s.jsxs("div",{children:[s.jsxs("div",{className:"flex justify-between items-center mb-4",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-gray-400",children:"点击获客:有人填写手机号/微信号的直接显示,可一键推送到存客宝"}),s.jsxs("p",{className:"text-gray-500 text-xs mt-1",children:["共 ",n," 条记录 — 有联系方式的可触发存客宝添加好友"]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.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(Nw).map(([E,C])=>s.jsx("option",{value:E,children:C},E))}),s.jsxs(ne,{onClick:v,disabled:u,variant:"outline",className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Ke,{className:`w-4 h-4 mr-2 ${u?"animate-spin":""}`})," 刷新"]})]})]}),s.jsx(Ae,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:s.jsx(Ie,{className:"p-0",children:u?s.jsxs("div",{className:"flex justify-center py-12",children:[s.jsx(Ke,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):s.jsxs(s.Fragment,{children:[s.jsxs(qn,{children:[s.jsx(Gn,{children:s.jsxs(rt,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[s.jsx(ke,{className:"text-gray-400",children:"发起人"}),s.jsx(ke,{className:"text-gray-400",children:"匹配到"}),s.jsx(ke,{className:"text-gray-400",children:"类型"}),s.jsx(ke,{className:"text-gray-400",children:"联系方式"}),s.jsx(ke,{className:"text-gray-400",children:"时间"}),s.jsx(ke,{className:"text-gray-400 text-right",children:"操作"})]})}),s.jsxs(Jn,{children:[t.map(E=>{var C,T;return s.jsxs(rt,{className:`border-gray-700/50 ${k(E)?"hover:bg-[#0a1628]":"opacity-60"}`,children:[s.jsx(xe,{className:"text-white",children:E.userNickname||((C=E.userId)==null?void 0:C.slice(0,12))}),s.jsx(xe,{className:"text-white",children:E.matchedNickname||((T=E.matchedUserId)==null?void 0:T.slice(0,12))}),s.jsx(xe,{children:s.jsx(He,{className:"bg-[#38bdac]/20 text-[#38bdac] border-0",children:Nw[E.matchType]||E.matchType})}),s.jsxs(xe,{className:"text-sm",children:[E.phone&&s.jsxs("div",{className:"text-green-400",children:["📱 ",E.phone]}),E.wechatId&&s.jsxs("div",{className:"text-blue-400",children:["💬 ",E.wechatId]}),!E.phone&&!E.wechatId&&s.jsx("span",{className:"text-gray-600",children:"无联系方式"})]}),s.jsx(xe,{className:"text-gray-400 text-sm",children:E.createdAt?new Date(E.createdAt).toLocaleString():"-"}),s.jsx(xe,{className:"text-right",children:k(E)?s.jsxs(ne,{size:"sm",onClick:()=>w(E),disabled:g===E.id,className:"bg-[#38bdac] hover:bg-[#2da396] text-white text-xs h-7 px-3",children:[s.jsx(jA,{className:"w-3 h-3 mr-1"}),g===E.id?"推送中...":"推送CKB"]}):s.jsx("span",{className:"text-gray-600 text-xs",children:"—"})})]},E.id)}),t.length===0&&s.jsx(rt,{children:s.jsx(xe,{colSpan:6,className:"text-center py-12 text-gray-500",children:"暂无记录"})})]})]}),s.jsx(ms,{page:i,totalPages:N,total:n,pageSize:o,onPageChange:a,onPageSizeChange:E=>{c(E),a(1)}})]})})})]})}const ww={created:"已创建",pending_pay:"待支付",paid:"已支付",completed:"已完成",cancelled:"已取消"},CV={single:"单次",half_year:"半年",year:"年度"};function EV(){const[t,e]=b.useState([]),[n,r]=b.useState(!0),[i,a]=b.useState("");async function o(){r(!0);try{const c=i?`/api/db/mentor-consultations?status=${i}`:"/api/db/mentor-consultations",u=await Le(c);u!=null&&u.success&&u.data&&e(u.data)}catch(c){console.error(c)}finally{r(!1)}}return b.useEffect(()=>{o()},[i]),s.jsxs("div",{children:[s.jsxs("div",{className:"flex justify-between items-center mb-4",children:[s.jsx("p",{className:"text-gray-400",children:"导师咨询预约记录"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("select",{value:i,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:[s.jsx("option",{value:"",children:"全部状态"}),Object.entries(ww).map(([c,u])=>s.jsx("option",{value:c,children:u},c))]}),s.jsxs(ne,{onClick:o,disabled:n,variant:"outline",className:"border-gray-600 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Ke,{className:`w-4 h-4 mr-2 ${n?"animate-spin":""}`})," 刷新"]})]})]}),s.jsx(Ae,{className:"bg-[#0f2137] border-gray-700/50",children:s.jsx(Ie,{className:"p-0",children:n?s.jsx("div",{className:"py-12 text-center text-gray-400",children:"加载中..."}):s.jsxs(qn,{children:[s.jsx(Gn,{children:s.jsxs(rt,{className:"bg-[#0a1628] border-gray-700",children:[s.jsx(ke,{className:"text-gray-400",children:"ID"}),s.jsx(ke,{className:"text-gray-400",children:"用户ID"}),s.jsx(ke,{className:"text-gray-400",children:"导师ID"}),s.jsx(ke,{className:"text-gray-400",children:"类型"}),s.jsx(ke,{className:"text-gray-400",children:"金额"}),s.jsx(ke,{className:"text-gray-400",children:"状态"}),s.jsx(ke,{className:"text-gray-400",children:"创建时间"})]})}),s.jsxs(Jn,{children:[t.map(c=>s.jsxs(rt,{className:"border-gray-700/50",children:[s.jsx(xe,{className:"text-gray-300",children:c.id}),s.jsx(xe,{className:"text-gray-400",children:c.userId}),s.jsx(xe,{className:"text-gray-400",children:c.mentorId}),s.jsx(xe,{className:"text-gray-400",children:CV[c.consultationType]||c.consultationType}),s.jsxs(xe,{className:"text-white",children:["¥",c.amount]}),s.jsx(xe,{className:"text-gray-400",children:ww[c.status]||c.status}),s.jsx(xe,{className:"text-gray-500 text-sm",children:c.createdAt?new Date(c.createdAt).toLocaleString():"-"})]},c.id)),t.length===0&&s.jsx(rt,{children:s.jsx(xe,{colSpan:7,className:"text-center py-12 text-gray-500",children:"暂无预约记录"})})]})]})})})]})}function TV(){const[t,e]=b.useState("booking");return s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex gap-2",children:[s.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:"预约记录"}),s.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"&&s.jsx(EV,{}),t==="manage"&&s.jsx("div",{className:"-mx-8",children:s.jsx(R4,{embedded:!0})})]})}function MV(){const[t,e]=b.useState([]),[n,r]=b.useState(0),[i,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(i),pageSize:String(o),matchType:"team"}),y=await Le(`/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()},[i]);const m=Math.ceil(n/o)||1;return s.jsxs("div",{children:[s.jsxs("div",{className:"flex justify-between items-center mb-4",children:[s.jsxs("div",{children:[s.jsxs("p",{className:"text-gray-400",children:["团队招募匹配记录,共 ",n," 条"]}),s.jsx("p",{className:"text-gray-500 text-xs mt-1",children:"用户通过「团队招募」提交联系方式到存客宝"})]}),s.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:[s.jsx(Ke,{className:`w-4 h-4 ${u?"animate-spin":""}`})," 刷新"]})]}),s.jsx(Ae,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl",children:s.jsx(Ie,{className:"p-0",children:u?s.jsxs("div",{className:"flex justify-center py-12",children:[s.jsx(Ke,{className:"w-6 h-6 text-[#38bdac] animate-spin"}),s.jsx("span",{className:"ml-2 text-gray-400",children:"加载中..."})]}):s.jsxs(s.Fragment,{children:[s.jsxs(qn,{children:[s.jsx(Gn,{children:s.jsxs(rt,{className:"bg-[#0a1628] hover:bg-[#0a1628] border-gray-700",children:[s.jsx(ke,{className:"text-gray-400",children:"发起人"}),s.jsx(ke,{className:"text-gray-400",children:"匹配到"}),s.jsx(ke,{className:"text-gray-400",children:"联系方式"}),s.jsx(ke,{className:"text-gray-400",children:"时间"})]})}),s.jsxs(Jn,{children:[t.map(g=>s.jsxs(rt,{className:"hover:bg-[#0a1628] border-gray-700/50",children:[s.jsx(xe,{className:"text-white",children:g.userNickname||g.userId}),s.jsx(xe,{className:"text-white",children:g.matchedNickname||g.matchedUserId}),s.jsxs(xe,{className:"text-gray-400 text-sm",children:[g.phone&&s.jsxs("div",{children:["📱 ",g.phone]}),g.wechatId&&s.jsxs("div",{children:["💬 ",g.wechatId]}),!g.phone&&!g.wechatId&&"-"]}),s.jsx(xe,{className:"text-gray-400",children:g.createdAt?new Date(g.createdAt).toLocaleString():"-"})]},g.id)),t.length===0&&s.jsx(rt,{children:s.jsx(xe,{colSpan:4,className:"text-center py-12 text-gray-500",children:"暂无团队招募记录"})})]})]}),s.jsx(ms,{page:i,totalPages:m,total:n,pageSize:o,onPageChange:a,onPageSizeChange:g=>{c(g),a(1)}})]})})})]})}const jw={partner:"找伙伴",investor:"资源对接",mentor:"导师顾问",team:"团队招募"},kw={partner:"⭐",investor:"👥",mentor:"❤️",team:"🎮"};function AV({onSwitchTab:t,onOpenCKB:e}={}){const n=ja(),[r,i]=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([Le("/api/db/match-records?stats=true"),Le("/api/db/ckb-plan-stats")]);if(y.status==="fulfilled"&&((m=y.value)!=null&&m.success)&&y.value.data){let w=y.value.data;if(w.totalMatches>0&&(!w.uniqueUsers||w.uniqueUsers===0))try{const N=await Le("/api/db/match-records?page=1&pageSize=200");if(N!=null&&N.success&&N.records){const k=new Set(N.records.map(E=>E.userId).filter(Boolean));w={...w,uniqueUsers:k.size}}}catch{}i(w)}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 s.jsxs("div",{className:"space-y-8",children:[s.jsxs("div",{children:[s.jsxs("h3",{className:"text-lg font-semibold text-white mb-4 flex items-center gap-2",children:[s.jsx($n,{className:"w-5 h-5 text-[#38bdac]"})," 找伙伴数据"]}),s.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-3 gap-5",children:[s.jsx(Ae,{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:s.jsxs(Ie,{className:"p-6",children:[s.jsx("p",{className:"text-gray-400 text-sm mb-2",children:"总匹配次数"}),s.jsx("p",{className:"text-4xl font-bold text-white",children:f(r==null?void 0:r.totalMatches)}),s.jsxs("p",{className:"text-[#38bdac] text-xs mt-3 flex items-center gap-1",children:[s.jsx(_s,{className:"w-3 h-3"})," 查看匹配记录"]})]})}),s.jsx(Ae,{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:s.jsxs(Ie,{className:"p-6",children:[s.jsx("p",{className:"text-gray-400 text-sm mb-2",children:"今日匹配"}),s.jsx("p",{className:"text-4xl font-bold text-white",children:f(r==null?void 0:r.todayMatches)}),s.jsxs("p",{className:"text-yellow-400/60 text-xs mt-3 flex items-center gap-1",children:[s.jsx(ia,{className:"w-3 h-3"})," 今日实时"]})]})}),s.jsx(Ae,{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:s.jsxs(Ie,{className:"p-6",children:[s.jsx("p",{className:"text-gray-400 text-sm mb-2",children:"匹配用户数"}),s.jsx("p",{className:"text-4xl font-bold text-white",children:f(r==null?void 0:r.uniqueUsers)}),s.jsxs("p",{className:"text-blue-400/60 text-xs mt-3 flex items-center gap-1",children:[s.jsx(_s,{className:"w-3 h-3"})," 查看用户管理"]})]})}),s.jsx(Ae,{className:"bg-[#0f2137] border-gray-700/40",children:s.jsxs(Ie,{className:"p-6",children:[s.jsx("p",{className:"text-gray-400 text-sm mb-2",children:"人均匹配"}),s.jsx("p",{className:"text-3xl font-bold text-white",children:c?"—":r!=null&&r.uniqueUsers?(r.totalMatches/r.uniqueUsers).toFixed(1):"0"})]})}),s.jsx(Ae,{className:"bg-[#0f2137] border-gray-700/40",children:s.jsxs(Ie,{className:"p-6",children:[s.jsx("p",{className:"text-gray-400 text-sm mb-2",children:"付费匹配次数"}),s.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&&s.jsxs("div",{children:[s.jsx("h3",{className:"text-lg font-semibold text-white mb-4",children:"各类型匹配分布"}),s.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 s.jsxs("div",{className:"bg-[#0f2137] border border-gray-700/40 rounded-xl p-5",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[s.jsx("span",{className:"text-2xl",children:kw[m.matchType]||"📊"}),s.jsx("span",{className:"text-gray-300 font-medium",children:jw[m.matchType]||m.matchType})]}),s.jsx("p",{className:"text-3xl font-bold text-white mb-2",children:m.count}),s.jsx("div",{className:"w-full h-2 bg-gray-700/50 rounded-full overflow-hidden",children:s.jsx("div",{className:"h-full bg-[#38bdac] rounded-full transition-all",style:{width:`${Math.min(g,100)}%`}})}),s.jsxs("p",{className:"text-gray-500 text-xs mt-1.5",children:[g.toFixed(1),"%"]})]},m.matchType)})})]}),s.jsxs("div",{children:[s.jsxs("h3",{className:"text-lg font-semibold text-white mb-4 flex items-center gap-2",children:[s.jsx(ps,{className:"w-5 h-5 text-orange-400"})," AI 获客数据"]}),s.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-3 gap-5 mb-6",children:[s.jsx(Ae,{className:"bg-[#0f2137] border-orange-500/20 cursor-pointer hover:border-orange-500/50 transition-colors",onClick:()=>e==null?void 0:e("submitted"),children:s.jsxs(Ie,{className:"p-6",children:[s.jsx("p",{className:"text-gray-400 text-sm mb-2",children:"已提交线索"}),s.jsx("p",{className:"text-3xl font-bold text-white",children:c?"—":(a==null?void 0:a.ckbTotal)??0}),s.jsx("p",{className:"text-orange-400/60 text-xs mt-2",children:"点击查看明细 →"})]})}),s.jsx(Ae,{className:"bg-[#0f2137] border-orange-500/20 cursor-pointer hover:border-orange-500/50 transition-colors",onClick:()=>e==null?void 0:e("contact"),children:s.jsxs(Ie,{className:"p-6",children:[s.jsx("p",{className:"text-gray-400 text-sm mb-2",children:"有联系方式"}),s.jsx("p",{className:"text-3xl font-bold text-white",children:c?"—":(a==null?void 0:a.withContact)??0}),s.jsx("p",{className:"text-orange-400/60 text-xs mt-2",children:"点击查看明细 →"})]})}),s.jsx(Ae,{className:"bg-[#0f2137] border-orange-500/20 cursor-pointer hover:border-orange-500/50 transition-colors",onClick:()=>e==null?void 0:e("test"),children:s.jsxs(Ie,{className:"p-6",children:[s.jsx("p",{className:"text-gray-400 text-sm mb-2",children:"AI 添加进度"}),s.jsx("p",{className:"text-xl font-bold text-orange-400",children:"查看详情 →"}),s.jsx("p",{className:"text-gray-500 text-xs mt-2",children:"添加成功率 · 回复率 · API 文档"})]})})]}),(a==null?void 0:a.byType)&&a.byType.length>0&&s.jsx("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-3 mb-6",children:a.byType.map(m=>s.jsxs("div",{className:"bg-[#0a1628] border border-gray-700/30 rounded-lg p-4 flex items-center gap-3",children:[s.jsx("span",{className:"text-xl",children:kw[m.matchType]||"📋"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-gray-400 text-xs",children:jw[m.matchType]||m.matchType}),s.jsx("p",{className:"text-xl font-bold text-white",children:m.total})]})]},m.matchType))})]})]})}const IV=["partner","investor","mentor","team"],mg=[{key:"join_partner",label:"找伙伴场景"},{key:"join_investor",label:"资源对接场景"},{key:"join_mentor",label:"导师顾问场景"},{key:"join_team",label:"团队招募场景"},{key:"match",label:"匹配上报"},{key:"lead",label:"链接卡若"}],Sw=`# 场景获客接口摘要 -- 地址:POST /v1/api/scenarios -- 必填:apiKey、sign、timestamp -- 主标识:phone 或 wechatId 至少一项 -- 可选:name、source、remark、tags、siteTags、portrait -- 签名:排除 sign/apiKey/portrait,键名升序拼接值后双重 MD5 -- 成功:code=200,message=新增成功 或 已存在`;function RV({initialTab:t="overview"}){const[e,n]=b.useState(t),[r,i]=b.useState("13800000000"),[a,o]=b.useState(""),[c,u]=b.useState(""),[h,f]=b.useState(Sw),[m,g]=b.useState(!1),[y,v]=b.useState(!1),[w,N]=b.useState([]),[k,E]=b.useState([]),[C,T]=b.useState({}),[O,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"}]),I=b.useMemo(()=>{const D={};return mg.forEach($=>{D[$.key]=C[$.key]||{apiUrl:"https://ckbapi.quwanzhi.com/v1/api/scenarios",apiKey:"fyngh-ecy9h-qkdae-epwd5-rz6kd",source:"",tags:"",siteTags:"创业实验APP",notes:""}}),D},[C]),R=D=>{const $=r.trim(),le=a.trim();return D<=3?{type:IV[D],phone:$||void 0,wechat:le||void 0,userId:"admin_test",name:"后台测试"}:D===4?{matchType:"partner",phone:$||void 0,wechat:le||void 0,userId:"admin_test",nickname:"后台测试",matchedUser:{id:"test",nickname:"测试",matchScore:88}}:D===5?{phone:$||void 0,wechatId:le||void 0,userId:"admin_test",name:"后台测试"}:{}};async function P(){v(!0);try{const[D,$,le]=await Promise.all([Le("/api/db/config/full?key=ckb_config"),Le("/api/db/ckb-leads?mode=submitted&page=1&pageSize=50"),Le("/api/db/ckb-leads?mode=contact&page=1&pageSize=50")]),_=D==null?void 0:D.data;_!=null&&_.routes&&T(_.routes),_!=null&&_.docNotes&&u(_.docNotes),_!=null&&_.docContent&&f(_.docContent),$!=null&&$.success&&N($.records||[]),le!=null&&le.success&&E(le.records||[])}finally{v(!1)}}b.useEffect(()=>{n(t)},[t]),b.useEffect(()=>{P()},[]);async function L(){g(!0);try{const D=await xt("/api/db/config",{key:"ckb_config",value:{routes:I,docNotes:c,docContent:h},description:"存客宝接口配置"});oe.error((D==null?void 0:D.success)!==!1?"存客宝配置已保存":`保存失败: ${(D==null?void 0:D.error)||"未知错误"}`)}catch(D){oe.error(`保存失败: ${D instanceof Error?D.message:"网络错误"}`)}finally{g(!1)}}const ee=(D,$)=>{T(le=>({...le,[D]:{...I[D],...$}}))},te=async D=>{const $=O[D];if($.method==="POST"&&!r.trim()&&!a.trim()){oe.error("请填写测试手机号");return}const le=[...O];le[D]={...$,status:"testing",message:void 0,responseTime:void 0},F(le);const _=performance.now();try{const se=$.method==="GET"?await Le($.endpoint):await xt($.endpoint,R(D)),J=Math.round(performance.now()-_),z=(se==null?void 0:se.message)||"",W=(se==null?void 0:se.success)===!0||z.includes("已存在")||z.includes("已加入")||z.includes("已提交"),ue=[...O];ue[D]={...$,status:W?"success":"error",message:z||(W?"正常":"异常"),responseTime:J},F(ue),await P()}catch(se){const J=Math.round(performance.now()-_),z=[...O];z[D]={...$,status:"error",message:se instanceof Error?se.message:"失败",responseTime:J},F(z)}},Y=async()=>{if(!r.trim()&&!a.trim()){oe.error("请填写测试手机号");return}for(let D=0;Ds.jsx("div",{className:"overflow-auto rounded-lg border border-gray-700/30",children:s.jsxs("table",{className:"w-full text-sm",children:[s.jsx("thead",{className:"bg-[#0a1628] text-gray-400",children:s.jsxs("tr",{children:[s.jsx("th",{className:"text-left px-4 py-3",children:"发起人"}),s.jsx("th",{className:"text-left px-4 py-3",children:"类型"}),s.jsx("th",{className:"text-left px-4 py-3",children:"手机号"}),s.jsx("th",{className:"text-left px-4 py-3",children:"微信号"}),s.jsx("th",{className:"text-left px-4 py-3",children:"时间"})]})}),s.jsx("tbody",{children:D.length===0?s.jsx("tr",{children:s.jsx("td",{colSpan:5,className:"text-center py-10 text-gray-500",children:$})}):D.map(le=>s.jsxs("tr",{className:"border-t border-gray-700/30",children:[s.jsx("td",{className:"px-4 py-3 text-white",children:le.userNickname||le.userId}),s.jsx("td",{className:"px-4 py-3 text-gray-300",children:le.matchType}),s.jsx("td",{className:"px-4 py-3 text-green-400",children:le.phone||"—"}),s.jsx("td",{className:"px-4 py-3 text-blue-400",children:le.wechatId||"—"}),s.jsx("td",{className:"px-4 py-3 text-gray-400",children:le.createdAt?new Date(le.createdAt).toLocaleString():"—"})]},le.id))})]})});return s.jsx(Ae,{className:"bg-[#0f2137] border-orange-500/30 mb-6",children:s.jsxs(Ie,{className:"p-5",children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("h3",{className:"text-white font-semibold",children:"存客宝工作台"}),s.jsx(He,{className:"bg-orange-500/20 text-orange-400 border-0 text-xs",children:"CKB"}),s.jsxs("button",{type:"button",onClick:()=>n("doc"),className:"text-orange-400/60 text-xs hover:text-orange-400 flex items-center gap-1",children:[s.jsx(_s,{className:"w-3 h-3"})," API 文档"]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(ne,{onClick:()=>P(),variant:"outline",size:"sm",className:"border-gray-700 text-gray-300 hover:bg-gray-700/50 bg-transparent",children:[s.jsx(Ke,{className:`w-3.5 h-3.5 mr-1 ${y?"animate-spin":""}`})," 刷新"]}),s.jsxs(ne,{onClick:L,disabled:m,size:"sm",className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:[s.jsx(cn,{className:"w-3.5 h-3.5 mr-1"})," ",m?"保存中...":"保存配置"]})]})]}),s.jsx("div",{className:"flex flex-wrap gap-2 mb-5",children:[["overview","概览"],["submitted","已提交线索"],["contact","有联系方式"],["config","场景配置"],["test","接口测试"],["doc","API 文档"]].map(([D,$])=>s.jsx("button",{type:"button",onClick:()=>n(D),className:`px-4 py-2 rounded-lg text-sm transition-colors ${e===D?"bg-orange-500 text-white":"bg-[#0a1628] text-gray-400 hover:text-white"}`,children:$},D))}),e==="overview"&&s.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-4",children:[s.jsxs("div",{className:"bg-[#0a1628] border border-gray-700/30 rounded-xl p-5",children:[s.jsx("p",{className:"text-gray-400 text-xs mb-2",children:"已提交线索"}),s.jsx("p",{className:"text-3xl font-bold text-white",children:w.length})]}),s.jsxs("div",{className:"bg-[#0a1628] border border-gray-700/30 rounded-xl p-5",children:[s.jsx("p",{className:"text-gray-400 text-xs mb-2",children:"有联系方式"}),s.jsx("p",{className:"text-3xl font-bold text-white",children:k.length})]}),s.jsxs("div",{className:"bg-[#0a1628] border border-gray-700/30 rounded-xl p-5",children:[s.jsx("p",{className:"text-gray-400 text-xs mb-2",children:"场景配置数"}),s.jsx("p",{className:"text-3xl font-bold text-white",children:mg.length})]}),s.jsxs("div",{className:"bg-[#0a1628] border border-gray-700/30 rounded-xl p-5",children:[s.jsx("p",{className:"text-gray-400 text-xs mb-2",children:"文档备注"}),s.jsx("p",{className:"text-sm text-gray-300 line-clamp-3",children:c||"未填写"})]})]}),e==="submitted"&&U(w,"暂无已提交线索"),e==="contact"&&U(k,"暂无有联系方式线索"),e==="config"&&s.jsx("div",{className:"space-y-4",children:mg.map(D=>s.jsxs("div",{className:"bg-[#0a1628] border border-gray-700/30 rounded-xl p-4",children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsx("h4",{className:"text-white font-medium",children:D.label}),s.jsx(He,{className:"bg-orange-500/20 text-orange-300 border-0 text-xs",children:D.key})]}),s.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-2 gap-4",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsx(Z,{className:"text-gray-500 text-xs",children:"API 地址"}),s.jsx(ae,{className:"bg-[#0f2137] border-gray-700 text-white h-9 text-sm",value:I[D.key].apiUrl,onChange:$=>ee(D.key,{apiUrl:$.target.value})})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(Z,{className:"text-gray-500 text-xs",children:"API Key"}),s.jsx(ae,{className:"bg-[#0f2137] border-gray-700 text-white h-9 text-sm",value:I[D.key].apiKey,onChange:$=>ee(D.key,{apiKey:$.target.value})})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(Z,{className:"text-gray-500 text-xs",children:"Source"}),s.jsx(ae,{className:"bg-[#0f2137] border-gray-700 text-white h-9 text-sm",value:I[D.key].source,onChange:$=>ee(D.key,{source:$.target.value})})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(Z,{className:"text-gray-500 text-xs",children:"Tags"}),s.jsx(ae,{className:"bg-[#0f2137] border-gray-700 text-white h-9 text-sm",value:I[D.key].tags,onChange:$=>ee(D.key,{tags:$.target.value})})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(Z,{className:"text-gray-500 text-xs",children:"SiteTags"}),s.jsx(ae,{className:"bg-[#0f2137] border-gray-700 text-white h-9 text-sm",value:I[D.key].siteTags,onChange:$=>ee(D.key,{siteTags:$.target.value})})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(Z,{className:"text-gray-500 text-xs",children:"说明备注"}),s.jsx(ae,{className:"bg-[#0f2137] border-gray-700 text-white h-9 text-sm",value:I[D.key].notes,onChange:$=>ee(D.key,{notes:$.target.value})})]})]})]},D.key))}),e==="test"&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex gap-3 mb-4",children:[s.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[s.jsx(uo,{className:"w-4 h-4 text-gray-500 shrink-0"}),s.jsxs("div",{className:"flex-1",children:[s.jsx(Z,{className:"text-gray-500 text-xs",children:"测试手机号"}),s.jsx(ae,{className:"bg-[#0a1628] border-gray-700 text-white h-8 text-sm mt-0.5",value:r,onChange:D=>i(D.target.value)})]})]}),s.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[s.jsx("span",{className:"text-gray-500 text-sm shrink-0",children:"💬"}),s.jsxs("div",{className:"flex-1",children:[s.jsx(Z,{className:"text-gray-500 text-xs",children:"微信号(可选)"}),s.jsx(ae,{className:"bg-[#0a1628] border-gray-700 text-white h-8 text-sm mt-0.5",value:a,onChange:D=>o(D.target.value)})]})]}),s.jsx("div",{className:"flex items-end",children:s.jsxs(ne,{onClick:Y,className:"bg-orange-500 hover:bg-orange-600 text-white",children:[s.jsx(ia,{className:"w-3.5 h-3.5 mr-1"})," 全部测试"]})})]}),s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-2",children:O.map((D,$)=>s.jsxs("div",{className:"flex items-center justify-between bg-[#0a1628] rounded-lg px-3 py-2 border border-gray-700/30",children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[D.status==="idle"&&s.jsx("div",{className:"w-2 h-2 rounded-full bg-gray-600 shrink-0"}),D.status==="testing"&&s.jsx(Ke,{className:"w-3 h-3 text-yellow-400 animate-spin shrink-0"}),D.status==="success"&&s.jsx(Ng,{className:"w-3 h-3 text-green-400 shrink-0"}),D.status==="error"&&s.jsx(Vw,{className:"w-3 h-3 text-red-400 shrink-0"}),s.jsx("span",{className:"text-white text-xs truncate",children:D.label})]}),s.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[D.responseTime!==void 0&&s.jsxs("span",{className:"text-gray-600 text-[10px]",children:[D.responseTime,"ms"]}),s.jsx("button",{type:"button",onClick:()=>te($),disabled:D.status==="testing",className:"text-orange-400/60 hover:text-orange-400 text-[10px] disabled:opacity-50",children:"测试"})]})]},`${D.endpoint}-${$}`))})]}),e==="doc"&&s.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-2 gap-4",children:[s.jsxs("div",{className:"bg-[#0a1628] rounded-lg border border-gray-700/30 p-4",children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsx("h4",{className:"text-white text-sm font-medium",children:"场景获客 API 摘要"}),s.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:[s.jsx(_s,{className:"w-3 h-3"})," 打开外链"]})]}),s.jsx("pre",{className:"whitespace-pre-wrap text-xs text-gray-400 leading-6",children:h||Sw})]}),s.jsxs("div",{className:"bg-[#0a1628] rounded-lg border border-gray-700/30 p-4",children:[s.jsx("h4",{className:"text-white text-sm font-medium mb-3",children:"说明备注(可编辑)"}),s.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:D=>u(D.target.value),placeholder:"记录 Token、入口差异、回复率统计规则、对接约定等。"})]})]})]})})}const PV=[{id:"stats",label:"数据统计",icon:zT},{id:"partner",label:"找伙伴",icon:$n},{id:"resource",label:"资源对接",icon:NM},{id:"mentor",label:"导师预约",icon:yM},{id:"team",label:"团队招募",icon:Eg}];function OV(){const[t,e]=b.useState("stats"),[n,r]=b.useState(!1),[i,a]=b.useState("overview");return s.jsxs("div",{className:"p-8 w-full",children:[s.jsxs("div",{className:"mb-6 flex items-start justify-between gap-4",children:[s.jsxs("div",{children:[s.jsxs("h2",{className:"text-2xl font-bold text-white flex items-center gap-2",children:[s.jsx($n,{className:"w-6 h-6 text-[#38bdac]"}),"找伙伴"]}),s.jsx("p",{className:"text-gray-400 mt-1",children:"数据统计、匹配池与记录、资源对接、导师预约、团队招募"})]}),s.jsxs(ne,{type:"button",variant:"outline",onClick:()=>r(o=>!o),className:"border-orange-500/40 text-orange-300 hover:bg-orange-500/10 bg-transparent",children:[s.jsx(ps,{className:"w-4 h-4 mr-2"}),"存客宝"]})]}),n&&s.jsx(RV,{initialTab:i}),s.jsx("div",{className:"flex flex-wrap gap-1 mb-6 bg-[#0f2137] rounded-lg p-1 border border-gray-700/50",children:PV.map(o=>{const c=t===o.id;return s.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:[s.jsx(o.icon,{className:"w-4 h-4"}),o.label]},o.id)})}),t==="stats"&&s.jsx(AV,{onSwitchTab:o=>e(o),onOpenCKB:o=>{a(o||"overview"),r(!0)}}),t==="partner"&&s.jsx(kV,{}),t==="resource"&&s.jsx(SV,{}),t==="mentor"&&s.jsx(TV,{}),t==="team"&&s.jsx(MV,{})]})}function DV(){return s.jsxs("div",{className:"p-8 w-full",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-8",children:[s.jsx(ps,{className:"w-8 h-8 text-[#38bdac]"}),s.jsx("h1",{className:"text-2xl font-bold text-white",children:"API 接口文档"})]}),s.jsx("p",{className:"text-gray-400 mb-6",children:"API 风格:RESTful · 版本 v1.0 · 基础路径 /api · 简单、清晰、易用。"}),s.jsxs(Ae,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl mb-6",children:[s.jsx(et,{children:s.jsx(tt,{className:"text-white",children:"1. 接口总览"})}),s.jsxs(Ie,{className:"space-y-4 text-sm",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-gray-400 mb-2",children:"接口分类"}),s.jsxs("ul",{className:"space-y-1 text-gray-300 font-mono",children:[s.jsx("li",{children:"/api/book — 书籍内容(章节列表、内容获取、同步)"}),s.jsx("li",{children:"/api/payment — 支付系统(订单创建、回调、状态查询)"}),s.jsx("li",{children:"/api/referral — 分销系统(邀请码、收益、提现)"}),s.jsx("li",{children:"/api/user — 用户系统(登录、注册、信息更新)"}),s.jsx("li",{children:"/api/match — 匹配系统(寻找匹配、匹配历史)"}),s.jsx("li",{children:"/api/admin — 管理后台(内容/订单/用户/分销管理)"}),s.jsx("li",{children:"/api/config — 配置系统"})]})]}),s.jsxs("div",{children:[s.jsx("p",{className:"text-gray-400 mb-2",children:"认证方式"}),s.jsx("p",{className:"text-gray-300",children:"用户:Cookie session_id(可选)"}),s.jsx("p",{className:"text-gray-300",children:"管理端:Authorization: Bearer admin-token-secret"})]})]})]}),s.jsxs(Ae,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl mb-6",children:[s.jsx(et,{children:s.jsx(tt,{className:"text-white",children:"2. 书籍内容"})}),s.jsxs(Ie,{className:"space-y-2 text-sm text-gray-300 font-mono",children:[s.jsx("p",{children:"GET /api/book/all-chapters — 获取所有章节"}),s.jsx("p",{children:"GET /api/book/chapter/:id — 获取单章内容"}),s.jsx("p",{children:"POST /api/book/sync — 同步章节(需管理员认证)"})]})]}),s.jsxs(Ae,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl mb-6",children:[s.jsx(et,{children:s.jsx(tt,{className:"text-white",children:"3. 支付"})}),s.jsxs(Ie,{className:"space-y-2 text-sm text-gray-300 font-mono",children:[s.jsx("p",{children:"POST /api/payment/create-order — 创建订单"}),s.jsx("p",{children:"POST /api/payment/alipay/notify — 支付宝回调"}),s.jsx("p",{children:"POST /api/payment/wechat/notify — 微信回调"})]})]}),s.jsxs(Ae,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl mb-6",children:[s.jsx(et,{children:s.jsx(tt,{className:"text-white",children:"4. 分销与用户"})}),s.jsxs(Ie,{className:"space-y-2 text-sm text-gray-300 font-mono",children:[s.jsx("p",{children:"/api/referral/* — 邀请码、收益查询、提现"}),s.jsx("p",{children:"/api/user/* — 登录、注册、信息更新"}),s.jsx("p",{children:"/api/match/* — 匹配、匹配历史"})]})]}),s.jsxs(Ae,{className:"bg-[#0f2137] border-gray-700/50 shadow-xl mb-6",children:[s.jsx(et,{children:s.jsx(tt,{className:"text-white",children:"5. 管理后台"})}),s.jsxs(Ie,{className:"space-y-2 text-sm text-gray-300 font-mono",children:[s.jsx("p",{children:"GET/POST /api/admin/referral-settings — 推广/分销设置(含 VIP 配置)"}),s.jsx("p",{children:"GET /api/db/users、/api/db/book — 用户与章节数据"}),s.jsx("p",{children:"GET /api/admin/orders — 订单列表"})]})]}),s.jsx("p",{className:"text-gray-500 text-xs",children:"完整说明见项目内 开发文档/5、接口/API接口完整文档.md"})]})}function LV(){const t=wa();return s.jsx("div",{className:"min-h-screen bg-[#0a1628] flex items-center justify-center p-8",children:s.jsxs("div",{className:"text-center max-w-md",children:[s.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:s.jsx(KT,{className:"w-10 h-10"})}),s.jsx("h1",{className:"text-4xl font-bold text-white mb-2",children:"404"}),s.jsx("p",{className:"text-gray-400 mb-1",children:"页面不存在"}),s.jsx("p",{className:"text-sm text-gray-500 font-mono mb-8 break-all",children:t.pathname}),s.jsx(ne,{asChild:!0,className:"bg-[#38bdac] hover:bg-[#2da396] text-white",children:s.jsxs(bg,{to:"/",children:[s.jsx(AM,{className:"w-4 h-4 mr-2"}),"返回首页"]})})]})})}function _V(){return s.jsxs(pT,{children:[s.jsx(zt,{path:"/login",element:s.jsx(Q5,{})}),s.jsxs(zt,{path:"/",element:s.jsx(e5,{}),children:[s.jsx(zt,{index:!0,element:s.jsx(bm,{to:"/dashboard",replace:!0})}),s.jsx(zt,{path:"dashboard",element:s.jsx(oP,{})}),s.jsx(zt,{path:"orders",element:s.jsx(lP,{})}),s.jsx(zt,{path:"users",element:s.jsx(cP,{})}),s.jsx(zt,{path:"distribution",element:s.jsx(IP,{})}),s.jsx(zt,{path:"withdrawals",element:s.jsx(RP,{})}),s.jsx(zt,{path:"content",element:s.jsx(tV,{})}),s.jsx(zt,{path:"referral-settings",element:s.jsx(Mk,{})}),s.jsx(zt,{path:"author-settings",element:s.jsx(bm,{to:"/settings?tab=author",replace:!0})}),s.jsx(zt,{path:"vip-roles",element:s.jsx(vV,{})}),s.jsx(zt,{path:"mentors",element:s.jsx(R4,{})}),s.jsx(zt,{path:"mentor-consultations",element:s.jsx(bV,{})}),s.jsx(zt,{path:"admin-users",element:s.jsx(bm,{to:"/settings?tab=admin",replace:!0})}),s.jsx(zt,{path:"settings",element:s.jsx(cV,{})}),s.jsx(zt,{path:"payment",element:s.jsx(dV,{})}),s.jsx(zt,{path:"site",element:s.jsx(pV,{})}),s.jsx(zt,{path:"qrcodes",element:s.jsx(mV,{})}),s.jsx(zt,{path:"find-partner",element:s.jsx(OV,{})}),s.jsx(zt,{path:"match",element:s.jsx(xV,{})}),s.jsx(zt,{path:"match-records",element:s.jsx(yV,{})}),s.jsx(zt,{path:"api-doc",element:s.jsx(DV,{})})]}),s.jsx(zt,{path:"*",element:s.jsx(LV,{})})]})}v3.createRoot(document.getElementById("root")).render(s.jsx(b.StrictMode,{children:s.jsx(wT,{future:{v7_startTransition:!0,v7_relativeSplatPath:!0},children:s.jsx(_V,{})})})); diff --git a/soul-admin/dist/index.html b/soul-admin/dist/index.html index ded6f469..973bfaa1 100644 --- a/soul-admin/dist/index.html +++ b/soul-admin/dist/index.html @@ -1,13 +1,13 @@ - - - - - - 管理后台 - Soul创业派对 - - - - -
    - - + + + + + + 管理后台 - Soul创业派对 + + + + +
    + + diff --git a/soul-admin/src/components/RichEditor.tsx b/soul-admin/src/components/RichEditor.tsx index ba566dcc..a6f6c27e 100644 --- a/soul-admin/src/components/RichEditor.tsx +++ b/soul-admin/src/components/RichEditor.tsx @@ -90,7 +90,9 @@ function markdownToHtml(md: string): string { html = html.replace(/^## (.+)$/gm, '

    $1

    ') html = html.replace(/^# (.+)$/gm, '

    $1

    ') html = html.replace(/\*\*(.+?)\*\*/g, '$1') - html = html.replace(/\*(.+?)\*/g, '$1') + html = html.replace(/__(.+?)__/g, '$1') + html = html.replace(/(?$1') + html = html.replace(/(?$1') html = html.replace(/~~(.+?)~~/g, '$1') html = html.replace(/`([^`]+)`/g, '$1') html = html.replace(/!\[([^\]]*)\]\(([^)]+)\)/g, '$1') @@ -163,9 +165,11 @@ const LinkTagExtension = Node.create({ }) // eslint-disable-next-line @typescript-eslint/no-explicit-any -const MentionSuggestion = (persons: PersonItem[]): any => ({ - items: ({ query }: { query: string }) => - persons.filter(p => p.name.toLowerCase().includes(query.toLowerCase()) || p.id.includes(query)).slice(0, 8), +const MentionSuggestion = (personsRef: React.RefObject): any => ({ + items: ({ query }: { query: string }) => { + const persons = personsRef.current || [] + return persons.filter(p => p.name.toLowerCase().includes(query.toLowerCase()) || p.id.includes(query)).slice(0, 8) + }, render: () => { let popup: HTMLDivElement | null = null let selectedIndex = 0 @@ -247,6 +251,12 @@ const RichEditor = forwardRef(({ const [showLinkInput, setShowLinkInput] = useState(false) const initialContent = useRef(markdownToHtml(content)) + const onChangeRef = useRef(onChange) + onChangeRef.current = onChange + const personsRef = useRef(persons) + personsRef.current = persons + const debounceTimer = useRef>() + const editor = useEditor({ extensions: [ StarterKit, @@ -254,7 +264,7 @@ const RichEditor = forwardRef(({ Link.configure({ openOnClick: false, HTMLAttributes: { class: 'rich-link' } }), Mention.configure({ HTMLAttributes: { class: 'mention-tag' }, - suggestion: MentionSuggestion(persons), + suggestion: MentionSuggestion(personsRef), }), LinkTagExtension, Placeholder.configure({ placeholder }), @@ -263,7 +273,10 @@ const RichEditor = forwardRef(({ ], content: initialContent.current, onUpdate: ({ editor: ed }: { editor: Editor }) => { - onChange(ed.getHTML()) + if (debounceTimer.current) clearTimeout(debounceTimer.current) + debounceTimer.current = setTimeout(() => { + onChangeRef.current(ed.getHTML()) + }, 300) }, editorProps: { attributes: { class: 'rich-editor-content' }, diff --git a/soul-admin/src/pages/api-doc/ApiDocPage.tsx b/soul-admin/src/pages/api-doc/ApiDocPage.tsx index 3d865be1..bb8ce129 100644 --- a/soul-admin/src/pages/api-doc/ApiDocPage.tsx +++ b/soul-admin/src/pages/api-doc/ApiDocPage.tsx @@ -25,6 +25,8 @@ export function ApiDocPage() {

    接口分类

    • /api/book — 书籍内容(章节列表、内容获取、同步)
    • +
    • /api/miniprogram/upload — 小程序上传(图片/视频、图片压缩)
    • +
    • /api/admin/content/upload — 管理端内容导入
    • /api/payment — 支付系统(订单创建、回调、状态查询)
    • /api/referral — 分销系统(邀请码、收益、提现)
    • /api/user — 用户系统(登录、注册、信息更新)
    • @@ -52,6 +54,57 @@ export function ApiDocPage() { + + + 2.1 小程序上传接口 + + +
      +

      POST /api/miniprogram/upload/image — 图片上传(支持压缩)

      +

      表单:file(必填)、folder(可选,默认 images)、quality(可选 1-100,默认 85)

      +

      支持 jpeg/png/gif,单张最大 5MB。JPEG 按 quality 压缩。

      +
      +{`响应示例: { "success": true, "url": "/uploads/images/xxx.jpg", "data": { "url", "fileName", "size", "type", "quality" } }`}
      +            
      +
      +
      +

      POST /api/miniprogram/upload/video — 视频上传

      +

      表单:file(必填)、folder(可选,默认 videos)

      +

      支持 mp4/mov/avi,单个最大 100MB。

      +
      +{`响应示例: { "success": true, "url": "/uploads/videos/xxx.mp4", "data": { "url", "fileName", "size", "type", "folder" } }`}
      +            
      +
      +
      +
      + + + + 2.2 管理端内容上传 + + +

      POST /api/admin/content/upload — 内容导入(需 AdminAuth)

      +

      通过 API 批量导入章节到内容管理,不直接操作数据库。

      +
      +{`请求体: {
      +  "action": "import",
      +  "data": [{
      +    "id": "ch-001",
      +    "title": "章节标题",
      +    "content": "正文内容",
      +    "price": 1.0,
      +    "isFree": false,
      +    "partId": "part-1",
      +    "partTitle": "第一篇",
      +    "chapterId": "chapter-1",
      +    "chapterTitle": "第1章"
      +  }]
      +}`}
      +          
      +

      响应:{`{ "success": true, "message": "导入完成", "imported": N, "failed": M }`}

      +
      +
      + 3. 支付 diff --git a/soul-admin/src/pages/content/ChapterTree.tsx b/soul-admin/src/pages/content/ChapterTree.tsx index 5b6709d2..466f9fbd 100644 --- a/soul-admin/src/pages/content/ChapterTree.tsx +++ b/soul-admin/src/pages/content/ChapterTree.tsx @@ -1,4 +1,4 @@ -/** +/** * 章节树 - 仿照 catalog 设计,支持篇、章、节拖拽排序 * 整行可拖拽;节和章可跨篇 */ @@ -450,7 +450,8 @@ export function ChapterTree({ setDraggingItem({ type: 'section', id: section.id }) }} onDragEnd={() => { setDraggingItem(null); setDragOverTarget(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 ${secDragOver ? 'bg-[#38bdac]/15 ring-2 ring-[#38bdac]/50' : 'hover:bg-[#162840]/50'} ${isDragging('section', section.id) ? 'opacity-60 scale-[0.98] ring-2 ring-[#38bdac]' : ''}`} + onClick={() => onReadSection(section)} + className={`flex items-center justify-between py-2 px-3 rounded-lg min-h-[40px] cursor-pointer select-none transition-all duration-200 ${secDragOver ? 'bg-[#38bdac]/15 ring-2 ring-[#38bdac]/50' : 'hover:bg-[#162840]/50'} ${isDragging('section', section.id) ? 'opacity-60 scale-[0.98] ring-2 ring-[#38bdac]' : ''}`} {...droppableHandlers('section', section.id, { partId: part.id, partTitle: part.title, @@ -473,7 +474,7 @@ export function ChapterTree({ {section.id} {section.title} {pinnedSectionIds.includes(section.id) && } -
      +
      e.stopPropagation()}> 点击 {(section.clickCount ?? 0)} · 付款 {(section.payCount ?? 0)} 热度 {(section.hotScore ?? 0).toFixed(1)} · 第{(section.hotRank && section.hotRank > 0 ? section.hotRank : '-')}名 {onShowSectionOrders && ( diff --git a/soul-admin/src/pages/dashboard/DashboardPage.tsx b/soul-admin/src/pages/dashboard/DashboardPage.tsx index ba3dc2c5..77075fbe 100644 --- a/soul-admin/src/pages/dashboard/DashboardPage.tsx +++ b/soul-admin/src/pages/dashboard/DashboardPage.tsx @@ -1,7 +1,7 @@ import { useState, useEffect } from 'react' import { useNavigate } from 'react-router-dom' import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card' -import { Users, BookOpen, ShoppingBag, TrendingUp, RefreshCw, ChevronRight } from 'lucide-react' +import { Users, Eye, ShoppingBag, TrendingUp, RefreshCw, ChevronRight } from 'lucide-react' import { get } from '@/api/client' import { UserDetailModal } from '@/components/modules/user/UserDetailModal' @@ -71,7 +71,7 @@ export function DashboardPage() { const [totalUsersCount, setTotalUsersCount] = useState(0) const [paidOrderCount, setPaidOrderCount] = useState(0) const [totalRevenue, setTotalRevenue] = useState(0) - const [conversionRate, setConversionRate] = useState(0) + const [todayClicks, setTodayClicks] = useState(0) const [loadError, setLoadError] = useState(null) const [detailUserId, setDetailUserId] = useState(null) const [showDetailModal, setShowDetailModal] = useState(false) @@ -95,7 +95,6 @@ export function DashboardPage() { setTotalUsersCount(stats.totalUsers ?? 0) setPaidOrderCount(stats.paidOrderCount ?? 0) setTotalRevenue(stats.totalRevenue ?? 0) - setConversionRate(stats.conversionRate ?? 0) } } catch (e) { if ((e as Error)?.name !== 'AbortError') { @@ -106,7 +105,6 @@ export function DashboardPage() { setTotalUsersCount(overview.totalUsers ?? 0) setPaidOrderCount(overview.paidOrderCount ?? 0) setTotalRevenue(overview.totalRevenue ?? 0) - setConversionRate(overview.conversionRate ?? 0) } } catch (e2) { showError(e2) @@ -116,6 +114,16 @@ export function DashboardPage() { setStatsLoading(false) } + // 加载今日点击(从推广中心接口) + try { + const distOverview = await get<{ success?: boolean; todayClicks?: number }>('/api/admin/distribution/overview', init) + if (distOverview?.success) { + setTodayClicks(distOverview.todayClicks ?? 0) + } + } catch { + // 推广数据加载失败不影响主面板 + } + // 2. 并行加载订单和用户 setOrdersLoading(true) setUsersLoading(true) @@ -237,11 +245,11 @@ export function DashboardPage() { link: '/orders', }, { - title: '转化率', - value: statsLoading ? null : `${typeof conversionRate === 'number' ? conversionRate.toFixed(1) : 0}%`, - icon: BookOpen, - color: 'text-orange-400', - bg: 'bg-orange-500/20', + title: '今日点击', + value: statsLoading ? null : todayClicks, + icon: Eye, + color: 'text-blue-400', + bg: 'bg-blue-500/20', link: '/distribution', }, ] diff --git a/soul-api/internal/database/database.go b/soul-api/internal/database/database.go index e3c7c6ac..f2866cc8 100644 --- a/soul-api/internal/database/database.go +++ b/soul-api/internal/database/database.go @@ -89,6 +89,15 @@ func Init(dsn string) error { if err := db.AutoMigrate(&model.LinkTag{}); err != nil { log.Printf("database: link_tags migrate warning: %v", err) } + if err := db.AutoMigrate(&model.UserBalance{}); err != nil { + log.Printf("database: user_balances migrate warning: %v", err) + } + if err := db.AutoMigrate(&model.BalanceTransaction{}); err != nil { + log.Printf("database: balance_transactions migrate warning: %v", err) + } + if err := db.AutoMigrate(&model.GiftUnlock{}); err != nil { + log.Printf("database: gift_unlocks migrate warning: %v", err) + } // 以下表业务大量使用,必须参与 AutoMigrate,否则旧库缺字段会导致订单/用户/VIP 等接口报错 if err := db.AutoMigrate(&model.User{}); err != nil { log.Printf("database: users migrate warning: %v", err) diff --git a/soul-api/internal/handler/balance.go b/soul-api/internal/handler/balance.go new file mode 100644 index 00000000..20f8507d --- /dev/null +++ b/soul-api/internal/handler/balance.go @@ -0,0 +1,352 @@ +package handler + +import ( + "crypto/rand" + "encoding/hex" + "fmt" + "net/http" + "time" + + "soul-api/internal/database" + "soul-api/internal/model" + + "github.com/gin-gonic/gin" + "gorm.io/gorm" +) + +// GET /api/miniprogram/balance 小程序-查询余额 +func BalanceGet(c *gin.Context) { + userID := c.Query("userId") + if userID == "" { + c.JSON(http.StatusBadRequest, gin.H{"success": false, "error": "缺少 userId"}) + return + } + db := database.DB() + var bal model.UserBalance + if err := db.Where("user_id = ?", userID).First(&bal).Error; err != nil { + c.JSON(http.StatusOK, gin.H{"success": true, "data": gin.H{"userId": userID, "balance": 0, "totalRecharged": 0, "totalGifted": 0, "totalRefunded": 0}}) + return + } + c.JSON(http.StatusOK, gin.H{"success": true, "data": bal}) +} + +// POST /api/miniprogram/balance/recharge 小程序-充值(创建充值订单) +func BalanceRecharge(c *gin.Context) { + var body struct { + UserID string `json:"userId" binding:"required"` + Amount float64 `json:"amount" binding:"required,gt=0"` + } + if err := c.ShouldBindJSON(&body); err != nil { + c.JSON(http.StatusBadRequest, gin.H{"success": false, "error": "参数错误: " + err.Error()}) + return + } + + db := database.DB() + orderSN := fmt.Sprintf("BAL_%d", time.Now().UnixNano()) + + order := model.Order{ + ID: orderSN, + OrderSN: orderSN, + UserID: body.UserID, + ProductType: "balance_recharge", + Amount: body.Amount, + } + desc := fmt.Sprintf("余额充值 ¥%.2f", body.Amount) + status := "pending" + order.Description = &desc + order.Status = &status + + if err := db.Create(&order).Error; err != nil { + c.JSON(http.StatusInternalServerError, gin.H{"success": false, "error": "创建充值订单失败"}) + return + } + + c.JSON(http.StatusOK, gin.H{"success": true, "data": gin.H{"orderSn": orderSN, "amount": body.Amount}}) +} + +// POST /api/miniprogram/balance/recharge/confirm 充值完成回调(内部或手动确认) +func BalanceRechargeConfirm(c *gin.Context) { + var body struct { + OrderSN string `json:"orderSn" binding:"required"` + } + if err := c.ShouldBindJSON(&body); err != nil { + c.JSON(http.StatusBadRequest, gin.H{"success": false, "error": "参数错误"}) + return + } + + db := database.DB() + var order model.Order + if err := db.Where("order_sn = ? AND product_type = ?", body.OrderSN, "balance_recharge").First(&order).Error; err != nil { + c.JSON(http.StatusNotFound, gin.H{"success": false, "error": "订单不存在"}) + return + } + if order.Status != nil && *order.Status == "paid" { + c.JSON(http.StatusOK, gin.H{"success": true, "message": "已确认"}) + return + } + + err := db.Transaction(func(tx *gorm.DB) error { + paid := "paid" + now := time.Now() + if err := tx.Model(&order).Updates(map[string]interface{}{"status": paid, "pay_time": now}).Error; err != nil { + return err + } + + var bal model.UserBalance + if err := tx.Where("user_id = ?", order.UserID).First(&bal).Error; err != nil { + bal = model.UserBalance{UserID: order.UserID} + tx.Create(&bal) + } + if err := tx.Model(&bal).Updates(map[string]interface{}{ + "balance": gorm.Expr("balance + ?", order.Amount), + "total_recharged": gorm.Expr("total_recharged + ?", order.Amount), + }).Error; err != nil { + return err + } + + tx.Create(&model.BalanceTransaction{ + UserID: order.UserID, + Type: "recharge", + Amount: order.Amount, + BalanceAfter: bal.Balance + order.Amount, + RelatedOrder: &order.OrderSN, + Description: fmt.Sprintf("充值 ¥%.2f", order.Amount), + }) + return nil + }) + + if err != nil { + c.JSON(http.StatusInternalServerError, gin.H{"success": false, "error": "确认失败"}) + return + } + c.JSON(http.StatusOK, gin.H{"success": true, "message": "充值成功"}) +} + +// POST /api/miniprogram/balance/gift 小程序-代付解锁(用余额帮他人解锁章节) +func BalanceGift(c *gin.Context) { + var body struct { + GiverID string `json:"giverId" binding:"required"` + SectionID string `json:"sectionId" binding:"required"` + } + if err := c.ShouldBindJSON(&body); err != nil { + c.JSON(http.StatusBadRequest, gin.H{"success": false, "error": "参数错误"}) + return + } + + db := database.DB() + + var chapter model.Chapter + if err := db.Where("id = ?", body.SectionID).First(&chapter).Error; err != nil { + c.JSON(http.StatusNotFound, gin.H{"success": false, "error": "章节不存在"}) + return + } + price := float64(1) + if chapter.Price != nil { + price = *chapter.Price + } + if price <= 0 { + c.JSON(http.StatusBadRequest, gin.H{"success": false, "error": "该章节免费,无需代付"}) + return + } + + var giftCode string + err := db.Transaction(func(tx *gorm.DB) error { + var bal model.UserBalance + if err := tx.Where("user_id = ?", body.GiverID).First(&bal).Error; err != nil || bal.Balance < price { + return fmt.Errorf("余额不足,当前 ¥%.2f,需要 ¥%.2f", bal.Balance, price) + } + + if err := tx.Model(&bal).Updates(map[string]interface{}{ + "balance": gorm.Expr("balance - ?", price), + "total_gifted": gorm.Expr("total_gifted + ?", price), + }).Error; err != nil { + return err + } + + code := make([]byte, 16) + rand.Read(code) + giftCode = hex.EncodeToString(code) + + tx.Create(&model.GiftUnlock{ + GiftCode: giftCode, + GiverID: body.GiverID, + SectionID: body.SectionID, + Amount: price, + Status: "pending", + }) + + tx.Create(&model.BalanceTransaction{ + UserID: body.GiverID, + Type: "gift", + Amount: -price, + BalanceAfter: bal.Balance - price, + SectionID: &body.SectionID, + Description: fmt.Sprintf("代付章节 %s (¥%.2f)", body.SectionID, price), + }) + + return nil + }) + + if err != nil { + c.JSON(http.StatusBadRequest, gin.H{"success": false, "error": err.Error()}) + return + } + + c.JSON(http.StatusOK, gin.H{"success": true, "data": gin.H{ + "giftCode": giftCode, + "sectionId": body.SectionID, + "amount": price, + }}) +} + +// POST /api/miniprogram/balance/gift/redeem 领取代付礼物 +func BalanceGiftRedeem(c *gin.Context) { + var body struct { + GiftCode string `json:"giftCode" binding:"required"` + ReceiverID string `json:"receiverId" binding:"required"` + } + if err := c.ShouldBindJSON(&body); err != nil { + c.JSON(http.StatusBadRequest, gin.H{"success": false, "error": "参数错误"}) + return + } + + db := database.DB() + var gift model.GiftUnlock + if err := db.Where("gift_code = ?", body.GiftCode).First(&gift).Error; err != nil { + c.JSON(http.StatusNotFound, gin.H{"success": false, "error": "礼物码无效"}) + return + } + if gift.Status != "pending" { + c.JSON(http.StatusBadRequest, gin.H{"success": false, "error": "礼物已被领取"}) + return + } + + err := db.Transaction(func(tx *gorm.DB) error { + now := time.Now() + tx.Model(&gift).Updates(map[string]interface{}{ + "receiver_id": body.ReceiverID, + "status": "redeemed", + "redeemed_at": now, + }) + + orderSN := fmt.Sprintf("GIFT_%s", body.GiftCode[:8]) + paid := "paid" + desc := fmt.Sprintf("来自好友的代付解锁") + tx.Create(&model.Order{ + ID: orderSN, + OrderSN: orderSN, + UserID: body.ReceiverID, + ProductType: "section", + ProductID: &gift.SectionID, + Amount: 0, + Description: &desc, + Status: &paid, + PayTime: &now, + ReferrerID: &gift.GiverID, + }) + return nil + }) + + if err != nil { + c.JSON(http.StatusInternalServerError, gin.H{"success": false, "error": "领取失败"}) + return + } + + c.JSON(http.StatusOK, gin.H{"success": true, "data": gin.H{ + "sectionId": gift.SectionID, + "message": "解锁成功!", + }}) +} + +// POST /api/miniprogram/balance/refund 申请余额退款(9折) +func BalanceRefund(c *gin.Context) { + var body struct { + UserID string `json:"userId" binding:"required"` + Amount float64 `json:"amount" binding:"required,gt=0"` + } + if err := c.ShouldBindJSON(&body); err != nil { + c.JSON(http.StatusBadRequest, gin.H{"success": false, "error": "参数错误"}) + return + } + + db := database.DB() + refundAmount := body.Amount * 0.9 + + err := db.Transaction(func(tx *gorm.DB) error { + var bal model.UserBalance + if err := tx.Where("user_id = ?", body.UserID).First(&bal).Error; err != nil || bal.Balance < body.Amount { + return fmt.Errorf("余额不足") + } + + if err := tx.Model(&bal).Updates(map[string]interface{}{ + "balance": gorm.Expr("balance - ?", body.Amount), + "total_refunded": gorm.Expr("total_refunded + ?", body.Amount), + }).Error; err != nil { + return err + } + + tx.Create(&model.BalanceTransaction{ + UserID: body.UserID, + Type: "refund", + Amount: -body.Amount, + BalanceAfter: bal.Balance - body.Amount, + Description: fmt.Sprintf("退款 ¥%.2f(原额 ¥%.2f,9折退回 ¥%.2f)", body.Amount, body.Amount, refundAmount), + }) + + return nil + }) + + if err != nil { + c.JSON(http.StatusBadRequest, gin.H{"success": false, "error": err.Error()}) + return + } + + c.JSON(http.StatusOK, gin.H{"success": true, "data": gin.H{ + "deducted": body.Amount, + "refundAmount": refundAmount, + "message": fmt.Sprintf("退款成功,实际退回 ¥%.2f", refundAmount), + }}) +} + +// GET /api/miniprogram/balance/transactions 交易记录 +func BalanceTransactions(c *gin.Context) { + userID := c.Query("userId") + if userID == "" { + c.JSON(http.StatusBadRequest, gin.H{"success": false, "error": "缺少 userId"}) + return + } + + db := database.DB() + var txns []model.BalanceTransaction + db.Where("user_id = ?", userID).Order("created_at DESC").Limit(50).Find(&txns) + + c.JSON(http.StatusOK, gin.H{"success": true, "data": txns}) +} + +// GET /api/miniprogram/balance/gift/info 查询礼物码信息 +func BalanceGiftInfo(c *gin.Context) { + code := c.Query("code") + if code == "" { + c.JSON(http.StatusBadRequest, gin.H{"success": false, "error": "缺少 code"}) + return + } + + db := database.DB() + var gift model.GiftUnlock + if err := db.Where("gift_code = ?", code).First(&gift).Error; err != nil { + c.JSON(http.StatusNotFound, gin.H{"success": false, "error": "礼物码无效"}) + return + } + + var chapter model.Chapter + db.Where("id = ?", gift.SectionID).First(&chapter) + + c.JSON(http.StatusOK, gin.H{"success": true, "data": gin.H{ + "giftCode": gift.GiftCode, + "sectionId": gift.SectionID, + "sectionTitle": chapter.SectionTitle, + "amount": gift.Amount, + "status": gift.Status, + "giverId": gift.GiverID, + }}) +} diff --git a/soul-api/internal/handler/book.go b/soul-api/internal/handler/book.go index 3d95cda5..ced16dbc 100644 --- a/soul-api/internal/handler/book.go +++ b/soul-api/internal/handler/book.go @@ -24,7 +24,8 @@ var excludeParts = []string{"序言", "尾声", "附录"} // 支持 excludeFixed=1:排除序言、尾声、附录(目录页固定模块,不参与中间篇章) func BookAllChapters(c *gin.Context) { db := database.DB() - q := db.Model(&model.Chapter{}) + q := db.Model(&model.Chapter{}). + Select("mid, id, part_id, part_title, chapter_id, chapter_title, section_title, word_count, is_free, price, sort_order, status, is_new, edition_standard, edition_premium, hot_score, created_at, updated_at") if c.Query("excludeFixed") == "1" { for _, p := range excludeParts { q = q.Where("part_title NOT LIKE ?", "%"+p+"%") @@ -430,7 +431,8 @@ func escapeLikeBook(s string) string { return s } -// BookSearch GET /api/book/search?q= 章节搜索(与 /api/search 逻辑一致) +// BookSearch GET /api/book/search?q= 章节搜索 +// 优化:先搜标题(快),再搜内容(慢),不加载完整 content func BookSearch(c *gin.Context) { q := strings.TrimSpace(c.Query("q")) if q == "" { @@ -438,26 +440,57 @@ func BookSearch(c *gin.Context) { return } pattern := "%" + escapeLikeBook(q) + "%" - var list []model.Chapter - err := database.DB().Model(&model.Chapter{}). - Where("section_title LIKE ? OR content LIKE ?", pattern, pattern). - Order("sort_order ASC, id ASC"). - Limit(20). - Find(&list).Error - if err != nil { - c.JSON(http.StatusOK, gin.H{"success": true, "results": []interface{}{}, "total": 0, "keyword": q}) - return + db := database.DB() + + type row struct { + ID string `gorm:"column:id"` + MID uint `gorm:"column:mid"` + SectionTitle string `gorm:"column:section_title"` + PartTitle string `gorm:"column:part_title"` + ChapterTitle string `gorm:"column:chapter_title"` + IsFree *bool `gorm:"column:is_free"` } - lowerQ := strings.ToLower(q) - results := make([]gin.H, 0, len(list)) - for _, ch := range list { - matchType := "content" - if strings.Contains(strings.ToLower(ch.SectionTitle), lowerQ) { - matchType = "title" + + var titleHits []row + db.Model(&model.Chapter{}). + Select("id, mid, section_title, part_title, chapter_title, is_free"). + Where("section_title LIKE ?", pattern). + Order("sort_order ASC, id ASC"). + Limit(15). + Find(&titleHits) + + titleIDs := make(map[string]bool, len(titleHits)) + for _, h := range titleHits { + titleIDs[h.ID] = true + } + + remaining := 20 - len(titleHits) + var contentHits []row + if remaining > 0 { + cq := db.Model(&model.Chapter{}). + Select("id, mid, section_title, part_title, chapter_title, is_free"). + Where("content LIKE ?", pattern) + if len(titleIDs) > 0 { + ids := make([]string, 0, len(titleIDs)) + for id := range titleIDs { + ids = append(ids, id) + } + cq = cq.Where("id NOT IN ?", ids) } + cq.Order("sort_order ASC, id ASC").Limit(remaining).Find(&contentHits) + } + + results := make([]gin.H, 0, len(titleHits)+len(contentHits)) + for _, ch := range titleHits { results = append(results, gin.H{ "id": ch.ID, "mid": ch.MID, "title": ch.SectionTitle, "part": ch.PartTitle, "chapter": ch.ChapterTitle, - "isFree": ch.IsFree, "matchType": matchType, + "isFree": ch.IsFree, "matchType": "title", + }) + } + for _, ch := range contentHits { + results = append(results, gin.H{ + "id": ch.ID, "mid": ch.MID, "title": ch.SectionTitle, "part": ch.PartTitle, "chapter": ch.ChapterTitle, + "isFree": ch.IsFree, "matchType": "content", }) } c.JSON(http.StatusOK, gin.H{"success": true, "results": results, "total": len(results), "keyword": q}) diff --git a/soul-api/internal/handler/search.go b/soul-api/internal/handler/search.go index f8dd7b83..41bdbec2 100644 --- a/soul-api/internal/handler/search.go +++ b/soul-api/internal/handler/search.go @@ -3,7 +3,6 @@ package handler import ( "net/http" "strings" - "unicode/utf8" "soul-api/internal/database" "soul-api/internal/model" @@ -20,6 +19,7 @@ func escapeLike(s string) string { } // SearchGet GET /api/search?q= 从 chapters 表搜索(GORM,参数化) +// 优化:先搜标题(快),再搜内容(慢),不加载完整 content 到内存 func SearchGet(c *gin.Context) { q := strings.TrimSpace(c.Query("q")) if q == "" { @@ -27,51 +27,79 @@ func SearchGet(c *gin.Context) { return } pattern := "%" + escapeLike(q) + "%" - var list []model.Chapter - err := database.DB().Model(&model.Chapter{}). - Where("section_title LIKE ? OR content LIKE ?", pattern, pattern). - Order("sort_order ASC, id ASC"). - Limit(50). - Find(&list).Error - if err != nil { - c.JSON(http.StatusOK, gin.H{"success": true, "data": gin.H{"keyword": q, "total": 0, "results": []interface{}{}}}) - return + db := database.DB() + + // 第一步:标题匹配(快速,不加载 content) + type searchRow struct { + ID string `gorm:"column:id"` + MID uint `gorm:"column:mid"` + SectionTitle string `gorm:"column:section_title"` + PartTitle string `gorm:"column:part_title"` + ChapterTitle string `gorm:"column:chapter_title"` + Price *float64 `gorm:"column:price"` + IsFree *bool `gorm:"column:is_free"` + Snippet string `gorm:"column:snippet"` } - lowerQ := strings.ToLower(q) - results := make([]gin.H, 0, len(list)) - for _, ch := range list { - matchType := "content" - score := 5 - if strings.Contains(strings.ToLower(ch.SectionTitle), lowerQ) { - matchType = "title" - score = 10 - } - snippet := "" - pos := strings.Index(strings.ToLower(ch.Content), lowerQ) - if pos >= 0 && len(ch.Content) > 0 { - start := pos - 50 - if start < 0 { - start = 0 - } - end := pos + utf8.RuneCountInString(q) + 50 - if end > len(ch.Content) { - end = len(ch.Content) - } - snippet = ch.Content[start:end] - if start > 0 { - snippet = "..." + snippet - } - if end < len(ch.Content) { - snippet = snippet + "..." - } + + var titleMatches []searchRow + db.Model(&model.Chapter{}). + Select("id, mid, section_title, part_title, chapter_title, price, is_free, '' as snippet"). + Where("section_title LIKE ?", pattern). + Order("sort_order ASC, id ASC"). + Limit(30). + Find(&titleMatches) + + titleIDs := make(map[string]bool, len(titleMatches)) + for _, m := range titleMatches { + titleIDs[m.ID] = true + } + + // 第二步:内容匹配(排除已命中标题的,用 SQL 提取摘要避免加载完整 content) + remaining := 50 - len(titleMatches) + var contentMatches []searchRow + if remaining > 0 { + contentQ := db.Model(&model.Chapter{}). + Select("id, mid, section_title, part_title, chapter_title, price, is_free, "+ + "CONCAT(CASE WHEN LOCATE(?, content) > 60 THEN '...' ELSE '' END, "+ + "SUBSTRING(content, GREATEST(1, LOCATE(?, content) - 50), 200), "+ + "CASE WHEN LENGTH(content) > LOCATE(?, content) + 150 THEN '...' ELSE '' END) as snippet", + q, q, q). + Where("content LIKE ?", pattern) + if len(titleIDs) > 0 { + ids := make([]string, 0, len(titleIDs)) + for id := range titleIDs { + ids = append(ids, id) + } + contentQ = contentQ.Where("id NOT IN ?", ids) } + contentQ.Order("sort_order ASC, id ASC"). + Limit(remaining). + Find(&contentMatches) + } + + results := make([]gin.H, 0, len(titleMatches)+len(contentMatches)) + for _, ch := range titleMatches { price := 1.0 if ch.Price != nil { price = *ch.Price } results = append(results, gin.H{ "id": ch.ID, "title": ch.SectionTitle, "partTitle": ch.PartTitle, "chapterTitle": ch.ChapterTitle, - "price": price, "isFree": ch.IsFree, "matchType": matchType, "score": score, "snippet": snippet, + "price": price, "isFree": ch.IsFree, "matchType": "title", "score": 10, "snippet": "", + }) + } + for _, ch := range contentMatches { + price := 1.0 + if ch.Price != nil { + price = *ch.Price + } + snippet := ch.Snippet + if len([]rune(snippet)) > 200 { + snippet = string([]rune(snippet)[:200]) + "..." + } + results = append(results, gin.H{ + "id": ch.ID, "title": ch.SectionTitle, "partTitle": ch.PartTitle, "chapterTitle": ch.ChapterTitle, + "price": price, "isFree": ch.IsFree, "matchType": "content", "score": 5, "snippet": snippet, }) } c.JSON(http.StatusOK, gin.H{ diff --git a/soul-api/internal/handler/upload_content.go b/soul-api/internal/handler/upload_content.go new file mode 100644 index 00000000..aefc9cb1 --- /dev/null +++ b/soul-api/internal/handler/upload_content.go @@ -0,0 +1,269 @@ +package handler + +import ( + "bytes" + "fmt" + "image/gif" + "image/jpeg" + "image/png" + "io" + "math/rand" + "net/http" + "os" + "path/filepath" + "strconv" + "strings" + "time" + + "github.com/gin-gonic/gin" + "gorm.io/gorm" + + "soul-api/internal/database" + "soul-api/internal/model" +) + +const ( + uploadDirContent = "uploads" + maxImageBytes = 5 * 1024 * 1024 // 5MB + maxVideoBytes = 100 * 1024 * 1024 // 100MB + defaultImageQuality = 85 +) + +var ( + allowedImageTypes = map[string]bool{ + "image/jpeg": true, "image/png": true, "image/gif": true, "image/webp": true, + } + allowedVideoTypes = map[string]bool{ + "video/mp4": true, "video/quicktime": true, "video/x-msvideo": true, + } +) + +// UploadImagePost POST /api/miniprogram/upload/image 小程序-图片上传(支持压缩) +// 表单:file(必填), folder(可选,默认 images), quality(可选 1-100,默认 85) +func UploadImagePost(c *gin.Context) { + file, err := c.FormFile("file") + if err != nil { + c.JSON(http.StatusBadRequest, gin.H{"success": false, "error": "请选择要上传的图片"}) + return + } + if file.Size > maxImageBytes { + c.JSON(http.StatusBadRequest, gin.H{"success": false, "error": "图片大小不能超过 5MB"}) + return + } + ct := file.Header.Get("Content-Type") + if !allowedImageTypes[ct] && !strings.HasPrefix(ct, "image/") { + c.JSON(http.StatusBadRequest, gin.H{"success": false, "error": "仅支持 jpg/png/gif/webp 格式"}) + return + } + quality := defaultImageQuality + if q := c.PostForm("quality"); q != "" { + if qn, e := strconv.Atoi(q); e == nil && qn >= 1 && qn <= 100 { + quality = qn + } + } + folder := c.PostForm("folder") + if folder == "" { + folder = "images" + } + dir := filepath.Join(uploadDirContent, folder) + _ = os.MkdirAll(dir, 0755) + ext := filepath.Ext(file.Filename) + if ext == "" { + ext = ".jpg" + } + name := fmt.Sprintf("%d_%s%s", time.Now().UnixNano(), randomStrContent(6), ext) + dst := filepath.Join(dir, name) + + src, err := file.Open() + if err != nil { + c.JSON(http.StatusInternalServerError, gin.H{"success": false, "error": "打开文件失败"}) + return + } + defer src.Close() + data, err := io.ReadAll(src) + if err != nil { + c.JSON(http.StatusInternalServerError, gin.H{"success": false, "error": "读取文件失败"}) + return + } + // JPEG:支持质量压缩 + if strings.Contains(ct, "jpeg") || strings.Contains(ct, "jpg") { + img, err := jpeg.Decode(bytes.NewReader(data)) + if err == nil { + var buf bytes.Buffer + if err := jpeg.Encode(&buf, img, &jpeg.Options{Quality: quality}); err == nil { + if err := os.WriteFile(dst, buf.Bytes(), 0644); err == nil { + url := "/" + filepath.ToSlash(filepath.Join(uploadDirContent, folder, name)) + c.JSON(http.StatusOK, gin.H{ + "success": true, "url": url, + "data": gin.H{"url": url, "fileName": name, "size": int64(buf.Len()), "type": ct, "quality": quality}, + }) + return + } + } + } + } + // PNG/GIF:解码后原样保存 + if strings.Contains(ct, "png") { + img, err := png.Decode(bytes.NewReader(data)) + if err == nil { + var buf bytes.Buffer + if err := png.Encode(&buf, img); err == nil { + if err := os.WriteFile(dst, buf.Bytes(), 0644); err == nil { + url := "/" + filepath.ToSlash(filepath.Join(uploadDirContent, folder, name)) + c.JSON(http.StatusOK, gin.H{"success": true, "url": url, "data": gin.H{"url": url, "fileName": name, "size": int64(buf.Len()), "type": ct}}) + return + } + } + } + } + if strings.Contains(ct, "gif") { + img, err := gif.Decode(bytes.NewReader(data)) + if err == nil { + var buf bytes.Buffer + if err := gif.Encode(&buf, img, nil); err == nil { + if err := os.WriteFile(dst, buf.Bytes(), 0644); err == nil { + url := "/" + filepath.ToSlash(filepath.Join(uploadDirContent, folder, name)) + c.JSON(http.StatusOK, gin.H{"success": true, "url": url, "data": gin.H{"url": url, "fileName": name, "size": int64(buf.Len()), "type": ct}}) + return + } + } + } + } + + // 其他格式或解析失败时直接写入 + if err := os.WriteFile(dst, data, 0644); err != nil { + c.JSON(http.StatusInternalServerError, gin.H{"success": false, "error": "保存失败"}) + return + } + url := "/" + filepath.ToSlash(filepath.Join(uploadDirContent, folder, name)) + c.JSON(http.StatusOK, gin.H{"success": true, "url": url, "data": gin.H{"url": url, "fileName": name, "size": int64(len(data)), "type": ct}}) +} + +// UploadVideoPost POST /api/miniprogram/upload/video 小程序-视频上传(指定目录) +// 表单:file(必填), folder(可选,默认 videos) +func UploadVideoPost(c *gin.Context) { + file, err := c.FormFile("file") + if err != nil { + c.JSON(http.StatusBadRequest, gin.H{"success": false, "error": "请选择要上传的视频"}) + return + } + if file.Size > maxVideoBytes { + c.JSON(http.StatusBadRequest, gin.H{"success": false, "error": "视频大小不能超过 100MB"}) + return + } + ct := file.Header.Get("Content-Type") + if !allowedVideoTypes[ct] && !strings.HasPrefix(ct, "video/") { + c.JSON(http.StatusBadRequest, gin.H{"success": false, "error": "仅支持 mp4/mov/avi 等视频格式"}) + return + } + folder := c.PostForm("folder") + if folder == "" { + folder = "videos" + } + dir := filepath.Join(uploadDirContent, folder) + _ = os.MkdirAll(dir, 0755) + ext := filepath.Ext(file.Filename) + if ext == "" { + ext = ".mp4" + } + name := fmt.Sprintf("%d_%s%s", time.Now().UnixNano(), randomStrContent(8), ext) + dst := filepath.Join(dir, name) + if err := c.SaveUploadedFile(file, dst); err != nil { + c.JSON(http.StatusInternalServerError, gin.H{"success": false, "error": "保存失败"}) + return + } + url := "/" + filepath.ToSlash(filepath.Join(uploadDirContent, folder, name)) + c.JSON(http.StatusOK, gin.H{ + "success": true, "url": url, + "data": gin.H{"url": url, "fileName": name, "size": file.Size, "type": ct, "folder": folder}, + }) +} + +// AdminContentUpload POST /api/admin/content/upload 管理端-内容上传(通过 API 写入内容管理,不直接操作数据库) +// 需 AdminAuth。Body: { "action": "import", "data": [ { "id","title","content","price","isFree","partId","partTitle","chapterId","chapterTitle" } ] } +func AdminContentUpload(c *gin.Context) { + var body struct { + Action string `json:"action"` + Data []importItem `json:"data"` + } + if err := c.ShouldBindJSON(&body); err != nil { + c.JSON(http.StatusOK, gin.H{"success": false, "error": "请求体无效"}) + return + } + if body.Action != "import" { + c.JSON(http.StatusOK, gin.H{"success": false, "error": "action 须为 import"}) + return + } + if len(body.Data) == 0 { + c.JSON(http.StatusOK, gin.H{"success": false, "error": "data 不能为空"}) + return + } + db := database.DB() + imported, failed := 0, 0 + for _, item := range body.Data { + if item.ID == "" || item.Title == "" { + failed++ + continue + } + price := 1.0 + if item.Price != nil { + price = *item.Price + } + isFree := false + if item.IsFree != nil { + isFree = *item.IsFree + } + wordCount := len(item.Content) + status := "published" + editionStandard, editionPremium := true, false + ch := model.Chapter{ + ID: item.ID, + PartID: strPtrContent(item.PartID, "part-1"), + PartTitle: strPtrContent(item.PartTitle, "未分类"), + ChapterID: strPtrContent(item.ChapterID, "chapter-1"), + ChapterTitle: strPtrContent(item.ChapterTitle, "未分类"), + SectionTitle: item.Title, + Content: item.Content, + WordCount: &wordCount, + IsFree: &isFree, + Price: &price, + Status: &status, + EditionStandard: &editionStandard, + EditionPremium: &editionPremium, + } + err := db.Where("id = ?", item.ID).First(&model.Chapter{}).Error + if err == gorm.ErrRecordNotFound { + err = db.Create(&ch).Error + } else if err == nil { + err = db.Model(&model.Chapter{}).Where("id = ?", item.ID).Updates(map[string]interface{}{ + "section_title": ch.SectionTitle, + "content": ch.Content, + "word_count": ch.WordCount, + "is_free": ch.IsFree, + "price": ch.Price, + }).Error + } + if err != nil { + failed++ + continue + } + imported++ + } + c.JSON(http.StatusOK, gin.H{"success": true, "message": "导入完成", "imported": imported, "failed": failed}) +} + +func randomStrContent(n int) string { + const letters = "abcdefghijklmnopqrstuvwxyz0123456789" + b := make([]byte, n) + for i := range b { + b[i] = letters[rand.Intn(len(letters))] + } + return string(b) +} + +func strPtrContent(s *string, def string) string { + if s != nil && *s != "" { + return *s + } + return def +} diff --git a/soul-api/internal/model/balance.go b/soul-api/internal/model/balance.go new file mode 100644 index 00000000..2b631896 --- /dev/null +++ b/soul-api/internal/model/balance.go @@ -0,0 +1,44 @@ +package model + +import "time" + +type UserBalance struct { + UserID string `gorm:"column:user_id;primaryKey;size:50" json:"userId"` + Balance float64 `gorm:"column:balance;type:decimal(10,2);default:0" json:"balance"` + TotalRecharged float64 `gorm:"column:total_recharged;type:decimal(10,2);default:0" json:"totalRecharged"` + TotalGifted float64 `gorm:"column:total_gifted;type:decimal(10,2);default:0" json:"totalGifted"` + TotalRefunded float64 `gorm:"column:total_refunded;type:decimal(10,2);default:0" json:"totalRefunded"` + CreatedAt time.Time `gorm:"column:created_at" json:"createdAt"` + UpdatedAt time.Time `gorm:"column:updated_at" json:"updatedAt"` +} + +func (UserBalance) TableName() string { return "user_balances" } + +type BalanceTransaction struct { + ID uint `gorm:"primaryKey;autoIncrement" json:"id"` + UserID string `gorm:"column:user_id;size:50;index" json:"userId"` + Type string `gorm:"column:type;size:20" json:"type"` + Amount float64 `gorm:"column:amount;type:decimal(10,2)" json:"amount"` + BalanceAfter float64 `gorm:"column:balance_after;type:decimal(10,2)" json:"balanceAfter"` + RelatedOrder *string `gorm:"column:related_order;size:50" json:"relatedOrder,omitempty"` + TargetUserID *string `gorm:"column:target_user_id;size:50" json:"targetUserId,omitempty"` + SectionID *string `gorm:"column:section_id;size:50" json:"sectionId,omitempty"` + Description string `gorm:"column:description;size:200" json:"description"` + CreatedAt time.Time `gorm:"column:created_at" json:"createdAt"` +} + +func (BalanceTransaction) TableName() string { return "balance_transactions" } + +type GiftUnlock struct { + ID uint `gorm:"primaryKey;autoIncrement" json:"id"` + GiftCode string `gorm:"column:gift_code;uniqueIndex;size:32" json:"giftCode"` + GiverID string `gorm:"column:giver_id;size:50;index" json:"giverId"` + SectionID string `gorm:"column:section_id;size:50" json:"sectionId"` + ReceiverID *string `gorm:"column:receiver_id;size:50" json:"receiverId,omitempty"` + Amount float64 `gorm:"column:amount;type:decimal(10,2)" json:"amount"` + Status string `gorm:"column:status;size:20;default:pending" json:"status"` + CreatedAt time.Time `gorm:"column:created_at" json:"createdAt"` + RedeemedAt *time.Time `gorm:"column:redeemed_at" json:"redeemedAt,omitempty"` +} + +func (GiftUnlock) TableName() string { return "gift_unlocks" } diff --git a/soul-api/internal/router/router.go b/soul-api/internal/router/router.go index 3c5e386a..678a76b1 100644 --- a/soul-api/internal/router/router.go +++ b/soul-api/internal/router/router.go @@ -79,6 +79,7 @@ func Setup(cfg *config.Config) *gin.Engine { admin.GET("/author-settings", handler.AdminAuthorSettingsGet) admin.POST("/author-settings", handler.AdminAuthorSettingsPost) admin.PUT("/orders/refund", handler.AdminOrderRefund) + admin.POST("/content/upload", handler.AdminContentUpload) admin.GET("/users", handler.AdminUsersList) admin.POST("/users", handler.AdminUsersAction) admin.PUT("/users", handler.AdminUsersAction) @@ -278,6 +279,8 @@ func Setup(cfg *config.Config) *gin.Engine { miniprogram.POST("/ckb/lead", handler.CKBLead) miniprogram.POST("/ckb/index-lead", handler.CKBIndexLead) miniprogram.POST("/upload", handler.UploadPost) + miniprogram.POST("/upload/image", handler.UploadImagePost) + miniprogram.POST("/upload/video", handler.UploadVideoPost) miniprogram.DELETE("/upload", handler.UploadDelete) miniprogram.GET("/user/addresses", handler.UserAddressesGet) miniprogram.POST("/user/addresses", handler.UserAddressesPost) @@ -310,6 +313,15 @@ func Setup(cfg *config.Config) *gin.Engine { miniprogram.GET("/mentors/:id", handler.MiniprogramMentorsDetail) miniprogram.POST("/mentors/:id/book", handler.MiniprogramMentorsBook) miniprogram.GET("/about/author", handler.MiniprogramAboutAuthor) + // 余额与代付 + miniprogram.GET("/balance", handler.BalanceGet) + miniprogram.POST("/balance/recharge", handler.BalanceRecharge) + miniprogram.POST("/balance/recharge/confirm", handler.BalanceRechargeConfirm) + miniprogram.POST("/balance/gift", handler.BalanceGift) + miniprogram.POST("/balance/gift/redeem", handler.BalanceGiftRedeem) + miniprogram.GET("/balance/gift/info", handler.BalanceGiftInfo) + miniprogram.POST("/balance/refund", handler.BalanceRefund) + miniprogram.GET("/balance/transactions", handler.BalanceTransactions) } // ----- 提现 ----- diff --git a/soul-api/server b/soul-api/server new file mode 100755 index 00000000..f47d60f5 Binary files /dev/null and b/soul-api/server differ diff --git a/soul-api/soul-api-new b/soul-api/soul-api-new new file mode 100755 index 00000000..46ae5822 Binary files /dev/null and b/soul-api/soul-api-new differ diff --git a/开发文档/.DS_Store b/开发文档/.DS_Store new file mode 100644 index 00000000..af0cda0c Binary files /dev/null and b/开发文档/.DS_Store differ diff --git a/开发文档/.github/workflows/sync_from_coding.yml b/开发文档/.github/workflows/sync_from_coding.yml new file mode 100644 index 00000000..bf82de99 --- /dev/null +++ b/开发文档/.github/workflows/sync_from_coding.yml @@ -0,0 +1,36 @@ +name: Sync from Coding + +on: + schedule: + - cron: '0 */2 * * *' # 每2小时执行一次 + workflow_dispatch: # 允许手动触发 + +jobs: + sync: + runs-on: ubuntu-latest + permissions: + contents: write # 确保此行存在,赋予工作流写入仓库内容的权限,这是解决 403 权限问题的基础 + steps: + - name: 检出 GitHub 仓库 + uses: actions/checkout@v4 + with: + ref: develop # 明确检出 develop 分支,确保在正确的分支上操作 + + - name: 配置 Git 用户并合并 Coding 代码到 GitHub + run: | + # 配置 Git 用户信息 + git config user.name "zhiqun@qq.com" + git config user.email "zhiqun@qq.com" + + # 添加 Coding 仓库为一个新的远程源 + git remote add coding-origin https://${{ secrets.CODING_USERNAME }}:${{ secrets.CODING_TOKEN }}@e.coding.net/g-xtcy5189/cunkebao/cunkebao_v3.git + + # 从 Coding 远程仓库获取 develop 分支的最新信息 + git fetch coding-origin develop + + # 合并 Coding 的 develop 分支到本地的 develop 分支 + # --allow-unrelated-histories 允许合并两个没有共同历史的分支 + git merge --no-ff --allow-unrelated-histories coding-origin/develop + + # 将合并后的本地 develop 分支推送到 GitHub 的 develop 分支 + git push origin develop diff --git a/开发文档/10、项目管理/.DS_Store b/开发文档/10、项目管理/.DS_Store new file mode 100644 index 00000000..1627a61d Binary files /dev/null and b/开发文档/10、项目管理/.DS_Store differ diff --git a/开发文档/10、项目管理/产研团队 第21场 20260129 许永平.txt b/开发文档/10、项目管理/产研团队 第21场 20260129 许永平.txt new file mode 100644 index 00000000..b2bba7a3 --- /dev/null +++ b/开发文档/10、项目管理/产研团队 第21场 20260129 许永平.txt @@ -0,0 +1,3738 @@ +2026年1月29日 下午 5:17|2小时 6分钟 10秒 + +关键词: +付款、标签、微信、数据库、程序、吸收、飞书、后台、分销、虚拟环境、数据中心、用户管理、用户绑定、流量自动化、用户中心、数据统计、用户数据、文档管理 + +文字记录: +许永平 00:02 +录制吗?哦,可以了,都有加入会议签到一下,记得签,就我没签,我今天这边还是在做那个。上面投屏一下。对,这是昨天的不好操作。 + +许永平 00:34 +从第二点开始。第二点,数据中心加权限管理。上面的也总结哈。就除了。 MBTI 版 30 分钟 API 开放管。最新版的可以看一下位置在哪? SDK 了,我这边的话就权限管理,这是昨天的。昨天的。你们要,嗯,让老王那个你手机也要加入一下。哪一个? + +卡若 01:00 +会议,这样才能看到你的内容。 + +许永平 01:00 +行。 + +卡若 01:03 +你加他说话的时候,到时候会更。 + +许永平 01:03 +你加他之后会更。 + +卡若 01:06 +会更容易一次给你加字幕。 + +许永平 01:06 +会更好回忆。会给你加字幕,你可以声音关小了,但是有录就好,我这边可以把声音都关掉,反正我们都听得见。 + +卡若 01:08 +那你可以声音关小,但是有录音就行,我这边可以把声音都关掉,那我来听一听。 + +许永平 01:17 +行,我加一下会议。 + +卡若 01:22 +这是昨天的,昨天我这边数据中心加权限了,那一块开放的,是开放的,然后这边有一个提现的流程。 + +许永平 01:22 +这是昨天的,昨天我这边数据中心加权限管控那一块开放的,是开放完了,然后这边有一个提现流程的。以及 MBTI 30 分钟重要重构的一些逻辑,还有碎片化剪辑加时间。 + +卡若 01:33 +以及 NPS 30 分钟重会重构的一些逻辑,而序列化统一在时间最后的话是这个材料的吸收就是有一些用法,一些AI,一个是AI,大概这是昨天的内容,今天的话我这边就已经投入到这个接入 AI 模型这里处理了。 + +许永平 01:43 +最后的话是这个材料吸收就是有一些用法,一些就是一些 AI 体词的一些用法,挺好的,大概这是昨天的内容,今天的话我这边就已经投入到这个接入 AI 模型这里。处理了,我之前停下来了,现在就是要把它做了,做的再做一些预设的东西。 + +卡若 02:04 +之前停下来的,现在就是要把它做了,做的再做一些预设的东西,接下来,然后有一个问题。 + +许永平 02:11 +接下来,然后有一个问题是我那个本地的模型好像有点智障了。 + +卡若 02:14 +是我那个本地的模型好像有点智障啊。你跑本地的肯定是这样啊。 + +许永平 02:18 +跑本地。 + +卡若 02:19 +那我现在有很多。 + +许永平 02:19 +那我现在有没有比较好的代替哦? + +卡若 02:21 +你为什么要跑本地模型呢?我问问,就是昨天我问过那个LLAMA,我觉得这个模型去处理一些什么采集的,应该不需要太高级的模型吧? + +许永平 02:24 +问问。就是昨天有问过那个LLAMA,我觉得你这个模型去处理一些什么采集的,应该不需要太高级的模。 + +卡若 02:33 +哼,你这。 + +许永平 02:34 +还是说。 + +卡若 02:34 +还是说。本地的不好用,本地的不是这么用的,这个再说吧,你先过一下嘛。 + +许永平 02:39 +就是再说吧。 + +卡若 02:41 +行,然后其他的是老王这边,其他这些本来要读图书里的平台。 + +许永平 02:42 +行,然后其他的事,老王这边其他这些本来要弄读书,你那边不要再讨论。 + +卡若 02:48 +就那接口那些东西弄得咋样?就像我刚刚说的那几个东西。你。 + +许永平 02:54 +你。 + +卡若 02:55 +对啊。 + +许永平 02:55 +对啊。 + +卡若 02:56 +截,早上截图那个,是吧? + +许永平 02:56 +早截,早上截图那个,是吧? + +卡若 02:58 +是。就我刚发群里的那些,你得。 + +许永平 02:59 +是。 + +卡若 03:00 +底下一个标签计划,不算标签的计划。 + +许永平 03:01 +你那个标签。哦,那个我得,我还得,再,我还得写现在这个他是跑全部的,那我要写是独立。 + +卡若 03:04 +你得有接口过来啊。那个我得,我还得,再,我还得写现在这个他是跑全部的。不是,就是我现在小程序弄完了。对吧?那我现在需要接口给我。 + +许永平 03:15 +那我现在就要接。 + +卡若 03:16 +然后让我把这一些数据传到我们中台,跟把中台来完善我的数据怎么处理。这个我目前是直接抓传到中台就存客宝了。 + +许永平 03:29 +传到中台就什么宝吗? + +卡若 03:31 +这不管做,存。存客宝还是中台嘛?就是你现在弄的这个,我怎么样清洗数据过来和我的数据那个合并到那个上面去,你得有一个东西吧。是要的。 + +许永平 03:44 +是要的,那这个得要固定格式了。 + +卡若 03:44 +是不是我?这个得要固定格式吗?也不一定固定,就是我现在,像我现在要调,我怎么调嘛? + +许永平 03:48 +不一定固定,就我现在像我这边要调调。 + +卡若 03:52 +调,我是有开放,不是有开放接口吗? + +许永平 03:52 +调,我是有开放,不是有开放接口了吗? + +卡若 03:55 +那接口在哪? + +许永平 03:56 +接口在哪? + +卡若 03:56 +说明有吗? + +许永平 03:57 +有文档,这,对,我把文档发一下。 + +卡若 03:57 +对对,我把文档发你。 + +许永平 04:01 +发过去。 + +卡若 04:05 +开发完了就这条吗? + +许永平 04:05 +好,就这个吧。 + +许永平 04:15 +总道路产能群。 + +卡若 04:17 +我现在这两个是搜索的。 + +许永平 04:18 +不过现在这两个是搜索的,你这边是要存到数据中心标签里的,是吧? + +卡若 04:22 +这边是要存到数据中心标签里面的,是吧?存跟查跟完善呢。 + +许永平 04:27 +存的查。 + +卡若 04:29 +目前开放的是两个来查询的,因为。 + +许永平 04:29 +目前开放的是两个来查询的。 + +卡若 04:32 +这边上查到那个存客宝。 + +许永平 04:32 +因为这边是要查到那个乘客的。 + +卡若 04:34 +就我怎么操作? + +许永平 04:35 +就我怎么操作的地方,是吧? + +卡若 04:36 +我现在操作的地方我都不知道。就我怎么操作? + +许永平 04:40 +就我怎么操作? + +卡若 04:40 +我就我们正常存客宝那边,就是如果有就弄了两个,你给我一个接口就可以了,让我自己去调,就这一个。 + +许永平 04:42 +就我们正常使用的时候就漏了两个,给我一个接口。让我自己去调。那我得部,我还没部署,我得部署一下,我看他本地停,我部署一个吧。 + +卡若 04:51 +我还没部署呢,我得部署一下,开个本地部署一个。就大概长啥样? + +许永平 04:55 +大概咋样去拍你这些接口都是那个。 + +卡若 04:56 +去哪里拿?这些接口我都是蒙的,我自己弄的时候我接不上,知道就。 + +许永平 05:00 +那个时候接不上。 + +卡若 05:02 +比如我现在那些数据完善,包括那些。 + +许永平 05:02 +行。我现在那些完善,包括那些。 + +卡若 05:05 +数据完善。 + +许永平 05:06 +数据完善,那现在还有个问题,你是打算存什么东西? + +卡若 05:06 +是吧?现在还有个问题,你是打算存什么东西?还是说你直接想把数据库丢到拉萨呢? + +许永平 05:10 +还是说你直接想把数据库丢到拉索呢? + +卡若 05:12 +我,我不用,我就存到。 + +许永平 05:13 +不用吧。因为我现在开放的就只有查询,我开放只有查询。 + +卡若 05:14 +现在开放的就只有查询,我开放只有查询。就是查询跟接入这两个都是一回事,就以我现在这个小程序写完了,写完之后小程序这些用户我得完善到我们的那个数据中台啊。 + +许永平 05:19 +就是查数据,这两个都是一回事的,我现在这个小程序在写完之后,小程序的一些用户会完善到我们的。 + +卡若 05:33 +是不是你得给我一个地方传进来,对吧? + +许永平 05:34 +你得给我一个地方传进来,对吧? + +卡若 05:37 +第二个的话我得调,我得从中台调数据去完善我的呀。 + +许永平 05:37 +第二个的话调,从中台调数据去测流量。 + +卡若 05:42 +哦,这样,这个交互了完善。 + +许永平 05:43 +这样子,这个交互再想想。 + +卡若 05:45 +是不是? + +许永平 05:46 +就是。那这个标题,那这个数据现在的模式是这样的,我们 lark 上有很多数据库,我是从那个那里面直接把数据库就统整合。 + +卡若 05:58 +那里面直接把身份证都跑整合整。 + +许永平 06:02 +整合取到那个数据中心的,那你这边的话其实也是可以直接把数据库丢到门店大厂来,我觉得也不行。 + +卡若 06:03 +提到这个数据中心的,那你这边的话其实也是可以直接把数据库丢到我们一定要返回的一个集群。我肯定不可能丢拉萨,就是我只要调你给我数据,对吧? + +许永平 06:10 +我肯定不可能丢到大厂,就是我只要调给我数,对吧? + +卡若 06:14 +那你数据你怎么给我? + +许永平 06:14 +那你数据你怎么给? + +卡若 06:16 +那这样,我就针对你这个项目再做一遍。 + +许永平 06:16 +那这样,我就针对你这个项目再构建。 + +卡若 06:19 +不用,不要这样,任何项目就都要一遍的,就是我怎么查嘛? + +许永平 06:24 +就是我。 + +卡若 06:25 +就比如我现在用户里面,用户。 + +许永平 06:27 +查,查的话文档这里是有的,我们看一下,能查,现在我。 + +卡若 06:28 +这里是有了,我们看一下能查,现在我这。你要纠结的是你数据要传给我,我要怎么去处理这些东西? + +许永平 06:32 +我现在比较纠结的是你数据要传给我,我要怎么去存你这些东西? + +卡若 06:36 +对啊,那这个不是有一个那个 AI 的那个标签的那个东西吗? + +许永平 06:36 +对,那这个不是 AI 标签,没有看到,你知道就我们的数据都还是作用在哪去使用的这种没有看到。 + +卡若 06:39 +那个我没有看到,知道吧?我没有看到,我也不知道这个东西怎么去弄,就我们这个数据中台的作用在哪里?怎么样去使用它?重点的是这个我没有看到,知道吗? + +许永平 06:55 +我想想,我现在我得找。 + +卡若 06:56 +那我正常如果自己查询,我本机查一下就完事了,我无非把这些用户导出来在本地数据。 + +许永平 06:57 +那我正常如果自己查,我可以去查一下,会把这个用户导出来。 + +卡若 07:02 +误查一下就完事了,那我们有没有接口能查吗? + +许永平 07:05 +那我们有没有接口可以查吧? + +卡若 07:07 +接口有这个现在是可以查的。 + +许永平 07:07 +接口有这个现在是可以查的,这个的话是昨天有一个,不是有个 IPR key 的管理吗? + +卡若 07:11 +跟他操作,怎么怎么操作?怎么操作?怎么去对接,这个比较重要。昨天有一个是 IPIP 的管理吗? + +许永平 07:30 +我觉得我得把它马上部署出来,不然。对啊。 + +卡若 07:33 +这个是t,然后你拉一个t,这是 80 区。 + +许永平 07:38 +我昨天应该是有个这个吗? + +卡若 07:43 +就你们,你。 + +许永平 07:44 +这个先首先要在这边创一个key,有个 key 管理,等一下我部署,马上部署,然后部署完之后这边你创一个key,然后你等下接完文档的时候,你。 + +卡若 07:44 +这首先要在这边创一个t,我要t,等一下,我部署了,马上,然后部署完到这边你创一个t,然后你等一下接文档的时候,你把这个带到那个请求头部,你就把这个替换请求头。 + +许永平 08:02 +对吧? + +卡若 08:08 +先看一下嘛。 + +许永平 08:09 +到那个开启不错,这个地方。 + +许永平 08:48 +创建完 key 之后,就是在请求这个权限校验 key 传过来就好了,然后你就可以存。 + +卡若 08:49 +就是在请求从这边这一个一个学费校验,把这个替换了就好,然后你就可以传。这个是属于传,那我要拿数据嘞?对,再就是拉数据,然后你传的那个我没写,反正你现在提了一下午。 + +许永平 09:02 +对,这就是拉数据,然后你传的那个我没洗嘛传的,你现在提了一下午。 + +卡若 09:08 +就是我传给你。 + +许永平 09:08 +就是我传给。我。 + +卡若 09:09 +就远志那个,你要申测所那边那些完成了哪一些或者怎么样? + +许永平 09:13 +完成的联系,或者现在这一次。 + +卡若 09:15 +什么情况我现在是不知道的,知道吧? + +许永平 09:20 +我这边。 + +卡若 09:20 +我这边。反正是模糊的知道,因为我现在就提很简单,我现在对到这一步,我用户要对进来跟完善,没了我现在。 + +许永平 09:29 +那还没做完吧? + +卡若 09:29 +做完,你现在应该是只搭了底层的东西。 + +许永平 09:30 +你现在应该是只搭了底层的东西。 + +卡若 09:32 +对,我现。 + +许永平 09:32 +对。 + +卡若 09:32 +但没做完,我还没有存。 + +许永平 09:32 +我现在没做完,我还没有存这块,我不做,只是有查。 + +卡若 09:34 +没有做。那得。只是有查。有查的,怎么查? + +许永平 09:37 +有查的。 + +卡若 09:39 +查的就是接那个接口,根据传那个手机号、身份证。 + +许永平 09:39 +查的就是接这个接口,根据你传这个手机号、身份证、微信号过来,然后是一个数组的形式,这里都有传参。 + +卡若 09:43 +身份证。身份证微信号过来,然后是一个数组的形式,那给到我。那这个文档在哪里? + +许永平 09:50 +文档在哪里? + +卡若 09:51 +怎么样去动? + +许永平 09:52 +就发了,现在。 + +卡若 09:53 +不是发群里,我们在哪里能查得到,或者有一个链接,或者有一个接口的文档可以看的地方,不然我们就文档每一次都是。在弄文档的地方嘛。 + +许永平 10:03 +哦,那我部署一个bug,部署一个那个接口的地址我加一下,等一下我加一下,不然每次文档这也的确不是很友好,或者我写在。 + +卡若 10:11 +不然每次我在这确实是很不好。就你们文档管理在管在哪里?有没有一个统一的地方?比如接口。什么接口? ABCDE 的接口的文档? API doc 你有装吗?我没有,没弄。那你装 API doc,老王拉,我们平时都放在 API doc 里。 + +许永平 10:29 +放在 API force。 + +卡若 10:30 +拉,到时候我给我放出去。 + +许永平 10:31 +对。他团队里,然后。 + +卡若 10:32 +这里面,然后。没有,这个有些得先开出去,不能绑定。就是现在,嗯。公开出去得创建一个沟通方式。就这个,就东一块西一块,我的感觉知道吗?就没有。 + +许永平 10:47 +没有,就这,就我这个是没有写的,其他的老王都写了。 + +卡若 10:48 +这个是没有写的。 + +许永平 10:54 +对,你下载一个,等一下你发个链接到群里。 + +卡若 10:54 +对,你下载一个,然后我。到时候。等一下,你发我。我也发一个邀请给你吧。就你们像碎片时间这些也没有接过吗? + +许永平 11:06 +像碎片时间,结果把这些用户。 + +卡若 11:08 +这些用户的这一些,你得有接过这些东西啊。他都没开发完,存客宝都还没接呢。没有,这个是标准,你不用,不一定要数据,就是你。然后提前先创建啊。 + +许永平 11:21 +然后提前先创建了。 + +卡若 11:23 +你得有,你不是你做完了这个东西,你有东西能把那些东西字段传过来都可以了,就这一块清。 + +许永平 11:31 +想想。 + +卡若 11:32 +息,知道吧。那我们。 + +许永平 11:35 +那我们把所有的。 + +卡若 11:35 +就是我刚刚的那个需求就非常简单,这个东西弄完了,我要用户完善结束没了。 + +许永平 11:40 +好。 + +卡若 11:41 +但是用户完善这一个东西你要提取,那我没有提取的地方,对吧?都不用说我写入的事情了嘛。 + +许永平 11:46 +对对,是,是我,我没发布上去呢。 + +卡若 11:47 +对。就提取,我现在也提不了,对吧?那这个是就不清晰嘛。我没法录上去。是不是? + +许永平 11:54 +对对,那我马上发一个,然后那存呢? + +卡若 11:54 +对。那这个就是卡点呢?然后那。存肯定也要这个,就是规划的问题,就我们这个之前都讨论过。 + +许永平 12:05 +存,现在我都没想好要怎么去存你的这些东西,我最早的时候是直接把数据库丢下来,那个有哦,你是说那个且。 + +卡若 12:12 +时候是直接把数据。不是,最就是我把用户数据丢到 AI 去,我们当时还讨论了很多字段的这一些东西,标准的字段。那你进来之后 AI 聊完标。不是直接打标签就好了吗?标签引擎进去,进去完善这一些东西,那这个库。不是。当时是针对消费记录,消费记录是你那边给个,你那边把消费记录传。 + +许永平 12:33 +当时是针对消费记录,是参考抖音的产品。 + +卡若 12:39 +它标签有分几种类型。比如说一些基础信息的,嗯,标签你是直接去创的,像你说的那些什么消费的那些,它是要经过清洗的。 + +许永平 12:42 +比如说信息的抄的,像你说的那些,他是要。 + +卡若 12:51 +对。 + +许永平 12:52 +对。 + +卡若 12:52 +清洗完再那个清洗完出你要存的那个类型,比如说消费类型或者什么类型的,这些是要清洗的。但是你肯定调的就是调你整个第一就是他需不需要清洗啊? + +许永平 13:03 +直接调的就是。他是不是要进行的地址进行创建标签? + +卡若 13:07 +如果不需要他就直接写放标签嘛。嗯,对应是你的标签写进去的,那如果是说要,他要再过一层。 + +许永平 13:11 +创标签写进去啊。对,现在不是来清洗,不可能那么他自那么自动让他自动去生成标签,是。 + +卡若 13:16 +现在标签肯定是要有清洗之后的,到时候是来清洗的,可能还没那么多智,那么智能让它自动去生。对,因为里面涉及到一些。转换的东西,所以这个这一块也是要做。那现在那个读书的是打算弄哪些标签? + +许永平 13:34 +那现在那个读书的是打算弄哪些东西? + +卡若 13:38 +你是要直接把他的消息订单记录进来。 + +许永平 13:38 +你是要直接进这个,你不是要存进来。 + +卡若 13:41 +这个跟标签其实没有太大的关联,就是我们 AIAI 来负责这个标签,因为你不可能定义所有的程序的标签。 + +许永平 13:49 +如果是 AI 来负责这个,我需要你把表的结构搞定,让他去分析。 + +卡若 13:50 +看,负责这个,我需要他表的结构绑定的,让他去看。表的结构他自己会去分析。 + +许永平 13:55 +表的结构,他自己简单地说一下,就这个用户管理这一些东西。 + +卡若 13:56 +我,我简单地说一下,就这个用户管理的这一些东西,比如他看的这。 + +许永平 14:02 +看看这个用户卡的底下有个什么样的,对吧? + +卡若 14:02 +这用户看了什么?底下有绑定什么样的人,对吧?什么样的时间,对吧? + +许永平 14:06 +什么样的时间,对吧? + +卡若 14:08 +阅读了什么,发布了什么,他那些行为轨迹都得传到相应的标签的体系里面来,是不是? + +许永平 14:16 +就是你要搭一套清理的规则,它是一个动态的。 + +卡若 14:16 +就是你要。你得范式。一套清理的,清洗的这个规则,它是一个动态的。这个肯定。 + +许永平 14:24 +但这个也是要根据需求,什么数据进来,你说一个大仓库,那就丢什么嘛? + +卡若 14:25 +不管是丢什么数据进来,它是任意丢的。你说一个大仓库,然后他想丢什么就丢什么。然后他会。 + +许永平 14:32 +然后。 + +卡若 14:32 +通过那个清洗去给他判断哪些是可以提炼成标签。那种的话最好,那肯定是要整个可能会丢,每张表的那个字段不一样,我没办法说创建一张那种全部都是空白字段,空白那个限制的表。 + +许永平 14:37 +那种的话最好,那肯定是要整个布局,你那张表那个字段不一样,我没办法说创建一张那种全部都是空白字段的,那个禁止的表。 + +卡若 14:50 +不用空白,就是他进去之后按你的标准去留存就行了。就比如说他这边有个比较他正常的注册这些信息,这些还有的就是他的消费记录,大概就是这些要一些。 + +许永平 14:54 +就比如说他这边有的就提交他正常的注册这些信息吧。 + +卡若 15:02 +就跟它应用场景有关了嘛。就是我们给一个规则,让它把那些事物关联起来。因为。目前目我们当时做的就是先给,先把那个消费记录先跑过来,所以很多库我都直接把有消费名单的进行转化,这个是有做的,那现在就是新在消费记录上你还要生成什么样的数据? + +许永平 15:12 +目前目我们当时做的就是把那个消费订单的这个情况是有做的,所以现在新的消费记录你还要新增什么样的数据表?这个我得新增。 + +卡若 15:31 +这个咱们上次。 + +许永平 15:32 +我们上次讨论的这一个这个流程的话,我觉得你再去确定一下,现在的话如果这个是有卡点,我们开发下去才知道会有。 + +卡若 15:32 +讨论的这一个流程的话,我觉得远志你再去确定一下这一个东西,因为现在的话如果这个是有卡点,我们开发下去才知道会有卡点,那怎么去把它迭代掉呢?是不是?这个。 + +许永平 15:50 +对。 + +卡若 15:50 +因为这个需求本身,如果我在做这个事情都有卡点的情况,我觉得任何人都会有卡点,因为我是非常灵活了已经,知道吗?我。我现在就是这个东西,你就给我一个API,就我都全部搞定了,是不是?那我现在都会有这个卡点都我自己走一遍,我就很清楚了,就我们这数据中台的整个的这个搭建,对吧?你还是按规划来吧,不然这个的确是不知道。规划之前是按照,得提前先设定好标签,按照之前有调研那些的确是有。 + +许永平 16:21 +规划之前是按照,得提前先设定好标签,按照之前有列的那些,的确是有。 + +卡若 16:27 +标签基本库是用来放的,你就建好一个个箱子,对吧?那。你中间有一个分类源,那个 AI 的标签引擎就是这个分类源嘛。那我传的那些标签过去,它分类成完之后就丢到你这个一个个箱子里面就行了嘛。它逻辑本身就本质上就这个事情,你定义的就是。 + +许永平 16:46 +定义的就是定义的一些大类,他们一起玩这个是属于什么类的? + +卡若 16:47 +定义的一些大类啊。就这一个。这个是属于什么类的? + +许永平 16:52 +哦,我想想怎么整?那行,老,下一个,老王,先继续,我想一下这个怎么整吧? + +卡若 16:59 +这个你一定是跟那个神射手去结合的,不然一。块一块感觉会没有总整体性,你知道吧?就我不知道他的到哪一个地方,知道吗? + +许永平 17:06 +好,行,先这么说。 + +卡若 17:11 +然后我,我会,我这个,我先说完这。行行行。我会有一点是什么?就是我现在为什么今天没有让你去把这个输的这个?因为有很多的一些细节的东西,我就想试自己试一下,走,跟你这个对接一下,看才能发现问题嘛。不然就肯定会那个的嘛。会有更多的一些卡点,或者不能往下去走,对吧? + +卡若 17:51 +现在就,所以这个还是要按板块来,我们好像一直都在原地踏步循环开发,然后回那个。 + +许永平 17:53 +对。 + +卡若 18:04 +回溯一些东西,知道吧。 + +许永平 18:06 +另外一个,你是。 + +卡若 18:06 +一百个。没有一个地图展开的感觉,知道吧。就抽象点说的话,是这个嘛?那这个就规划跟原来的那个东西怎么样去融合的一些问题嘛?所以你们在那个项目管理上面的话,我觉得还是要明确清晰吧。因为没有图嘛啊?往下吧,往下这个,这个你看一下,看怎么解决嘛?因为我现在这个我肯定是要上线的,本来周一要上,上,周一要上线,上周一就卡。验证嘛?那这个时候验证过了,就那个,这有一些那些 bug 我都还没有去弄,本来这个东西,这一个用户我早上就在过来的时候,我就才弄这个用户了。那用户弄完之后,我说下午那 API 过来,我就接上去,那咱们就正常可以使用了嘛。 + +许永平 18:57 +做完之后有效。这边这个计划。 + +卡若 19:02 +对吧?那现在又就这边就卡住了,是不是怕你也一定会卡住的?就这一个,到时候要写上就解决这个问题,然后要有个清晰的文档吧。然后关于那还有个提现的,今天是不是知道说这个虚假新开的说云审查的你因为提现,我现在后来看的是云审查的模式。然后上面这个名字,我们点击他这个,再跳出来就是他的主页。能提确定收款吗?已经到了吗?得点这一步,再点确认收款才可以。 + +许永平 19:43 +再一步再点确认购买。这不是地点物流。 + +卡若 19:46 +是避免不了的。这样子就会到账。好。 + +许永平 19:51 +你好,稍等。 + +卡若 19:51 +这样就到账了。可以,嗯,永平这个也不着急,就是要一点点去。 + +许永平 19:57 +只有一刷新。就这两个,就这两个状态。 + +卡若 20:02 +我们反正一个事情过吧。 + +许永平 20:03 +对的。然后。 + +卡若 20:05 +然后都把信息给他,嗯,提示。然后你。那这个不是能刷单就很爽吗?对。自己刷自己钱。 + +许永平 20:14 +然后你。 + +卡若 20:22 +昨天是没刷。 + +许永平 20:22 +昨天是没传。 + +卡若 20:23 +这么丑。 AI 我都是写的四个字,生成事件之间的,来到没了,没给他描述。这个也太。那我只是为了让你尝试一下。行吧。之后有一个卡点,我证书一直申请覆盖不了,就你有两三个证书,这几个月要,这几天要过期了。那你就是再申请。让你登录发验证码。我不是发了吗?我知道,一直卡,记住我,他提示是已经可以了,但是我必。第二天去看他的灰度高,灰度把进入0%。这个我一直卡着,我一直在看这个到底是什么问题导致的?我到时候让,到时候我再去研究一下支付宝那个叫。对,这个,那个他们那个钱的充值,你要怎么走那个流程啊?谁钱的充值啊?就是你总账号,他肯定要有钱嘛。那比如说那个瘦那边,他们是他们去审核,你跟他合作这个钱不应该是我们垫付,是应该他们要先把钱。项目打啊。对,那你要怎么走?怎么。这个就是项目为准的。直接他。项目充值到我们后台,然后直接扣啊。那你还要再做一个充值的。这一个后续再说。 + +许永平 21:54 +这一个后期再说。 + +卡若 21:55 +我知道,就是你后续你要直接做一个充值。你这个充值也没用。那你相当于你要开个体验版。走线下。不不不,你们,你这线上充值没有人会线下的。你走线下有好处,第一,你走线上的话,我不知道你这一个手续费是多少,你先。 + +许永平 22:13 +走线下。对。 + +卡若 22:18 +那你不用去思考这个问题。我知道。这个,这些就是利润的问题了,你。 + +许永平 22:23 +对。 + +卡若 22:23 +利润没错,白也没错,你充进去他还是扣不了,你得再手动再充进去,他现在拆下来。 + +许永平 22:24 +又没错。他还是通过他现在才。 + +卡若 22:31 +我知道本地。用户跟运营户嘛?这个写个脚本就行了,我都实现了,这个你不用去思考这个问题,能实现他能,就是他到时候短信你按一下,他会你签转账的时候就是授权一下就结束了。你这都有脚本了,这个没有啥,你不用担心这个问题。 + +许永平 22:48 +如果你在一个学历1万,我们。 + +卡若 22:49 +我这个可以做。你反正你去看一下嘛?这个不是一个难,就本地户,这个到时候要转到运营户嘛。肯定做。提本户转运营户嘛。一个对应的后台。他就是给。商家后台。 + +许永平 23:02 +算一个。 + +卡若 23:02 +我会做到新版的那个碎片时间。 + +许永平 23:04 +对。 + +卡若 23:05 +对呀。 + +许永平 23:05 +对。 + +卡若 23:05 +不会再拉出来了,这个只是说让他临时可以用。现在就是先线下,那个线下打,如果他们要用的话就先转一笔进去嘛。现在就我们自己打嘛就行了,那你得规划出来。目前先走线下,他转给我们,然后我们打到那一个运营账户,然后再从运营账户扣钱。是这样的流程,然后去做。 + +许永平 23:32 +给我 c 的。 + +卡若 23:32 +我新版的那一个碎片时间之后再。再说你说的那个流程嘛。不然这样子碎片时间也不用太多时间。然后我那一个标签最近今天注册掉了10%,在对接接口。然后业务也在搞。之后,明天就可以全力搞那一个流量池碎片时间去搞一搞,多弄。刚刚提交审核的时候被驳回,让他再重新提交一下。驳回原因呢。驳回。 + +卡若 24:00 +応援今の。 + +许永平 24:00 +会。 + +卡若 24:03 +他那一个得看审核人员的信息,同一个页面,同一个东西,他驳回的理由都是不一样的,有时候会通过,有时通过不了。那你就多提交几次嘛?对,所以说我待会都会重新再提交一下。那可以,那你就继续往下嘛。那我明天就继续全力突击标签,把,标签大概这层可以让你有一个城市的方案。就那个嘛?就正常这种还有吗?没有。那你。那你那个碎片时间要跟永平那边对一下,永平。永平,你把你那个。 + +许永平 24:36 +好好好。 + +卡若 24:38 +就是等一下你把那个标签的那个用那个展开,我不是有那个文档嘛?你展开就到时候对一下。对吧?有一个架构什么你才比较清楚嘛?展开,你把这个那些那个源码和数据库丢进去,自己展开,让它变成说明文档,我们看一下流程嘛。那你就也要弄一下,看看一下,对齐一下,反正比较清楚嘛。这个主要给远志看的,远志看了没问题,那就没问题。说明文档概要把那些比较重要的。就你们做完自己生成一个,你们检查你觉得没有问题。 + +许永平 25:13 +对。 + +卡若 25:14 +就跟你那个昨天那个实际的分析,大概实际的差不多,他分析出来了,然后还拆解了,还提一些各种的案知道,还跟一些说提这个项目以后的规划流程了,干嘛干嘛。对,就之类的,反正你。这个文档我是已经思考了大概 18 个点。就那个,你们是要对什么?那个,就那个。 + +许永平 25:40 +就所以现在。 + +卡若 25:42 +对,现在我卡了一条碎片时间聊天系统,例如我做了什么海报的任务,我就把一些信息就给永平,然后永平收入信息,收入显示之后再一个事件是在这边,然后他做了什么任务之类的,你要跟他的用户画像之类。打标签嘛。对。打标签,但是现在的问题好像是打标签这块你还没弄完。是吧?他这一块就是只是支持查询。 + +许永平 26:09 +现在我觉得是更新其实是有的,就是现在这一套是基于上面不是已经有数据库了吗? + +卡若 26:13 +对呀,要说支持更新,对呀,没有写更对,更没有写。但是要更新,更新其实是有的,就是我这现在这个就基于它上面不是已经有数据库了吗? + +许永平 26:26 +应该都是全部数据库,只要那个数据库有更新,我的数据有更新。 + +卡若 26:26 +那都是全部抓在你的数据库,只要数据库有更新,然后数据中心它就会自动更新的,因为它任务都是。 + +许永平 26:32 +多都是在跑,然后像做担心,最初在想是直接把数据丢进来就好了,因为他做那个淘宝那的话,我们那个接口跟本地的这个字段肯定是有不一致的,所以我的想采访 AI 带的话,就省去了换这个过程。 + +卡若 26:33 +然后像你们说的那个更新,我最初在想的是你直接把数据库丢进来就好了,因为它会自动去抓,做那个 AI 也是这样去抓的,这样的话我们那个接口跟本地的这个字段肯定是有不一致的,所以我的想,我初衷的想法是有这个 AI 在的话,就省去了对字段这个过程。那我知道。是啊,就 AI 对字段的,但你不要用本地,因为模型没有用。 + +许永平 26:53 +是 AI 啊。 + +卡若 26:57 +我明白意思,因为它 lark 后台有一个地方添加数据库,它直接把数据库账号。密码,然后名正他们输入进来,让 AI 这种分析嘛。 + +许永平 27:06 +对。 + +卡若 27:06 +我知道最早解决方案是这个,所以你这个标签的 AIAI 的分析的引擎一点有个逻辑在那边,现在是没有看到,这个很重要。对。 + +许永平 27:17 +是。 + +卡若 27:18 +知道吧。 + +许永平 27:18 +搜索上面都对的。 + +卡若 27:18 +上面都有。就是永平现在做的那一个,你要知道你做这个就是纯搜索的一部分在哪一部分上面? + +许永平 27:20 +只有永平现在做的。 + +卡若 27:26 +然后就远志规划的那一部分是不完成,然后我们看就验证那个嘛?解开发小程序什么,这些都是在验证,知道它并不是一个什么,那个什么。到时候那个小那个神社所那版先发给你,发他,对的,那个,看那个。 + +许永平 27:42 +就是厕所那块先发给。好,发我看。 + +卡若 27:47 +我们的核心的东西是啥?不管小程序这些,这太容易开发了,你搞进去用户数据跟我们做交互合并和估值,这是我们的核心,知道吧? + +许永平 27:54 +对。 + +王名正 27:54 +用户数据跟我们做交互。 + +卡若 28:01 +不是小程序,小程。小程序没有任何价值知道吧。所以这个这一块是非常重要的一些点,包括一些小的一些 bug 或者什么的调整嘛。是吧?可能你们修 bug 可能会快一点,老王修 bug 跟永平修 bug 的这一些,但我们不要生产太多bug,修是很快,对吧?不然东东一块西一块漏是不太好的,所以我才。诶,一直说咱们有一些完整性一点的东西,是吧? + +许永平 28:38 +我这边的话有个数据采集,其实在这边就是来配数据库了,如果是说行。 + +卡若 28:38 +我这边的话有个数据采集。你永平,你看一下这个怎么融到厕所里面去? + +王名正 28:43 +没有,你有投屏的,我看得到。是许永平没有放上。 + +卡若 28:48 +我觉得这个是不是这你看一下。 + +王名正 28:51 +远志投屏的,你试过去一下,远志投屏的,远志的。 + +卡若 29:02 +那。个今天跑,站在一台式上面跑。跑,你这个切片的。是第一个碰到的问题是。你现在很多是第二,你封装的完是你的苹果环境。 + +王名正 29:12 +我们都得二次转换,我们,我们得先改写 Windows 版本的。 + +卡若 29:15 +那他自己会去装,我知道啊。对,然后我们现在就是拿到这些的话,有时候一开始跑,他会那个他环境不一样,他变成得改写,改成对的版本。对啊。对,他 AI 会自动改写,然后可能要有一些环境要重新装什么依赖的。对啊。然后装完。的话,跑完的话我这次跑,他第一次跑的结果,因为我不清楚嘛。他跑完的,结果跑了好几个小时。那不是很正常吗?但是。说你跑一个视频多少?几分钟就好。 3 分钟就搞定了,你好几个小时,是你没有指定 MLX 的那个 Viser 这个。不是。加 MLX 杠,不然它就变成很麻烦的。你听我说,就是一开始我不清,因为我不知道,然后他跑了几个小时,我觉得不对,然后他。整个CPU。干,干,翻了。那不很正常嘛?你以后像这种你加一句就是。好,我跟你说像这种多任务的。最终跑了一个多小时, 97 死机了。你先听我讲完你这个,你就这要限制一个,大家就是在做运行的时候限制在 CPU 使用百分之,整个机器性能70%,不要超过。 + +许永平 30:13 +你先听我讲完。 + +王名正 30:24 +掉。 + +卡若 30:24 +不对。你听我讲完。他问题是他没有调那个显卡,他要用显卡去处理,不应该用 CPU 去处。 + +许永平 30:26 +他问题是。 + +卡若 30:32 +那就。就掉显卡嘛。对,所以说这个就是属于逻辑上变清楚嘛。 + +许永平 30:36 +他说我现在后面几个小时就死机啊。 + +卡若 30:36 +说我现在后面改完的第一次跑 CPU 就变得不行了。那跑g, GPU 就快啊。一个几个小时就死机啊。那跑成了没有嘛?然后现在是我改成显卡,显卡现在是跑成了,我看一下。那不就对了吗? + +许永平 30:52 +你这里说 10 分钟。 + +王名正 30:58 +你点击应该可以跳出来。 + +王名正 31:11 +你复制,你再复制那个链接。 + +王名正 31:30 +桌面。 XYZ 视频凹凸输出。 + +王名正 31:44 +1 起 1 + 5。 + +许永平 31:49 +没视频文件吗? + +卡若 31:56 +啥东西嘛? + +许永平 31:57 +接吻。 + +卡若 31:57 +你是刚切完片。 + +许永平 31:57 +你就发希望,嗯。 + +王名正 31:59 +行。 + +卡若 31:59 +你这一个是,估计是他的那一个话术吧。 + +王名正 31:59 +你这一个是,估计是他的那一个话术吧。 + +许永平 32:00 +再一个是我。 + +王名正 32:02 +话术啊。什么话术? + +卡若 32:07 +这是文件,你视频没跑出来。 + +王名正 32:07 +这字幕,这是字幕。 + +卡若 32:10 +他说已经跑完了,就是没,但是没看到视频。那你视频放,你看那个 cursor 上面嘛。对,就是看这个东西。视频有文档吗?输出日志。输出啥字?等我看一下,字这么小。哦,你还要自动,那你怕你还要自动再运行一下按钮的这个日志。 + +王名正 32:25 +哦,你还要自动,那你他,你还要自动再运行一下 Python 的这个命令。 + +许永平 32:28 +不要自动运行。 + +卡若 32:30 +不用自动运行,你。 + +王名正 32:30 +没有,他以后。 + +卡若 32:31 +没有它以后。 + +王名正 32:32 +切片说运行这一个。 + +卡若 32:36 +就说以后,但是现在这个转入完成。 + +许永平 32:36 +说以后,但是现在这个转入成,我看一下。 + +卡若 32:42 +我看一下,回去。 + +王名正 32:45 +他啥? + +许永平 32:45 +太强了。 + +王名正 32:45 +我说用手机再放大看他们,他只是说一个文件没有。 + +卡若 32:47 +就那个吗? + +许永平 32:48 +这个吗? + +卡若 32:48 +输出设置这个是文档剪辑、视频剪辑项目 output 这个,然后。 + +许永平 32:49 +输出设置这个是文档吗? + +王名正 33:02 +我没有视频,没有 case 的视频,没剪视频。 + +卡若 33:02 +没有视频。没剪视频,但是剪视频很快,你它这个是你已经拆解完了,就是没剪。 + +许永平 33:10 +然后我又加了几个需求,就是。 + +卡若 33:10 +然后我又加了几个需求,就是加了几个那个因为经常跑这种大的时候,它就一直卡在那边,就我不知道它是不是在跑还是卡住。那你就告诉他,实时给你反馈进度。 + +许永平 33:21 +那你就告诉他说,我们这个才知道最终的。 + +卡若 33:23 +加了一个。不就行了吗?对。但这个得完整跑一下,到最终的流程是怎样?那肯定,主要是。那台机子它能跑就可以了,我们这个你只要能跑,后面就是文件,还有它有一个自动上传到抖音或者什么什么群。 + +王名正 33:36 +这个就是文件。 + +卡若 33:41 +那个是分发嘛。分发的嘛。现在就是先跑剪的嘛。你先跑,剪这种事情。这种你到时候如果要给他们用的,是得录到那种比较好的那种。那你搞云机就好了,搞 GPU 就好了。你这种机制就没办法。或者搞苹果是最快的。苹果对,你那个没有。对,这很慢。那你就。 + +王名正 34:04 +你听过最近的是挺快的,但是哪一点的例子不好说? + +卡若 34:04 +苹果可能自己快,那老一点是一种不好。老一点也快,苹果的显卡就是不一样。就不一样,我跑一下 50 秒,拆解是三提取三到 5 分钟,跑完剪就 50 秒。 + +王名正 34:12 +没感觉,我真的没啥感觉,我那台跑起来也挺卡卡的。 + +卡若 34:22 +嗯,那你没有用那个嘛?没有用那。 + +许永平 34:24 +我还是苹果,它那个系统优化的比较好。 + +王名正 34:26 +主要是我那台太老了,那台苹果好像是19。 + +卡若 34:27 +主要是我那个太拉了,那还有一苹果好像是19。 + +王名正 34:32 +连麦的。 + +卡若 34:34 +19 年,对。然后这几个我得完整跑完,我才知道问题在哪里。你先跑一遍嘛。然后数据员工的话,我这边是改成这个,之前是那个卡片折叠的,我给他改成这种,就播报数据的话,还是卡片下面一个,就是以这种,不是跟他。一样的卡片这种推送,然后估计的话就是,嗯。 + +王名正 35:12 +你测试用户是哪一个?还记得? + +卡若 35:16 +如果我输的这个是冲突的,它里客户库里面有的话,它就会导出它的故事,那如果是说如果是查不到的,它。 + +许永平 35:21 +客户库里面的一个。 + +王名正 35:29 +陈佳。 + +卡若 35:32 +客户资料里面把这个跑到冰娇那边来,添加好友发送需求。 + +卡若 35:49 +这个老王开始弄了没有?就是碎片时间弄完就搞这个嘛? + +王名正 35:52 +家垒不是在弄那一个标签吗? + +卡若 35:54 +不是在弄那一个标签,先,标签完之后再做一个。 + +许永平 35:54 +就在标签吗? + +王名正 35:55 +新标签,标签完之后再这一块都有排期啊。 + +许永平 35:57 +就在。 + +卡若 35:59 +都有排期啊。 + +卡若 36:10 +剪辑,是吧? + +许永平 36:10 +点击。 + +卡若 36:11 +就是处理那个问题。 + +王名正 36:11 +剪辑设置。 + +卡若 36:15 +你先一台先搞定再说,因为这个检测环境不一样,调整一下。 + +许永平 36:23 +比如说你现在。 + +卡若 36:23 +比如说你现在很多不同的steer,它里面用到的一些插件,比如说它有环境不一样,怎么去解?解决这个问题是不是还得写一个这种?不,不用,你直接问,他自己会去改啊。我知道,就是他应该还要有一个逻辑是去处理这个版本的,就比如说你调用的第一个,他可能需要的 Python 版本是最高只能是到10,但是你比如说你调用第二个的时候。 + +许永平 36:38 +都是。 + +王名正 36:38 +他应该还要有。要。 + +卡若 36:51 +可能。他会装虚拟环境啊。但是你在是一个同一个工作区吗?他在也会每一个也会用他自己的虚拟环境啊。不知道可以,你就是提示词,你加一个部署到虚拟环境里面。 + +王名正 37:03 +Windows 不行,像我家里那台电脑就是 CNP 那些命令在课程完全执行不了。 + +卡若 37:15 +这个它有虚拟环境的,你就你们。 + +王名正 37:19 +对,我在公司这一台我就可以完美执行。 + +卡若 37:23 +这个就是你一个 steer 用的就是一个虚拟环境,你多加一句话就行了,这个一定会碰到的问题,你加一个提示词,加一对,加1。 + +许永平 37:28 +把,这对。 + +卡若 37:32 +那就行了,我现在解决非常简洁,知道我就让它装到什么? + +许永平 37:34 +はい。 + +王名正 37:36 +大家装到这个微信。 + +卡若 37:38 +装到那个虚拟机里面。doc,所有东西都装doc,咱就调用 doc 就完了,就 doc 就是一个功能。 + +王名正 37:48 +你电脑好一点,性能好一点,可以这样搞,我知道它是一个容器。 + +卡若 37:51 +doc 不会占太多资源,你好好去研究一下,它不是虚拟机。对,它不会占太多资源的,它不运行根本就没占资源,跟文件夹似的。 + +许永平 38:02 +每个词。 + +卡若 38:02 +要都单独的一个。 + +王名正 38:04 +小荣幸。 + +许永平 38:04 +小游戏。 + +卡若 38:05 +对啊。布个环境。对,他可以自己去调,他没有就去装一个,自己会去调,知道吗?这个回头你就先剪跟发,能发到群里面最好也。 + +王名正 38:19 +你现在就是搞doc,每一个 schema 就一个doc,我说,我是说你现在。 + +卡若 38:20 +你现在就是搞doc,每一个 DA 就一个doc。 + +许永平 38:20 +现在就考后端。你可以搞虚拟货币。 + +卡若 38:24 +你可以搞虚拟环境,可以搞 doc 很多解决方案。虚拟环境跟 doc 混着用, doc 就。 + +王名正 38:30 +我是没有,我电脑承受不起。 + +许永平 38:30 +我是没有,对吧? + +卡若 38:33 +文件大一点,没啥区别的。现在我主要是给电脑上冲突了。 + +王名正 38:35 +现在我主要是本地电脑那台环境太多了,已经冲突了。 + +卡若 38:39 +那你一定会冲突,你要你多加一个,让它生成独有的一个环境就可以了。 + +王名正 38:46 +现在我本地环境都冲突了,再装的话也装不起来了,再装。 + +卡若 38:47 +现在我本地环境都冲突了,再说的话也装不起来。不是,你装虚拟环境就好了,哪里会装不起来? + +王名正 38:56 +名正你麦扬声器关了。 + +许永平 38:56 +我这里把声音关了。 + +卡若 38:58 +你知道我在看远程,是通知不了的。 + +许永平 39:00 +不去,远程是听不了的。 + +卡若 39:02 +是。 + +许永平 39:03 +好。 + +卡若 39:08 +有,那你这个剪出来的切片,它字幕也没有自动配,它会自动配吗? + +王名正 39:08 +那你这么点出来的推荐它自动对,它会。 + +许永平 39:08 +那你这个剪出来的切片,它字幕也没有字幕,对啊。 + +卡若 39:12 +会自动配,你没自动配,就是没加提示词。 + +王名正 39:13 +没加,你没加提示词。 + +卡若 39:15 +不是你,你不应该你原来的那个就已经是有的吗?是有啊。原来的。是有,你要变成剪那个加字幕,它有三个版本,一个不加字幕,一个加字幕的时间会多一些时间就多搞一遍嘛。时间翻倍,没其他的呀。是存在其他的。你就看看那个test,那个高速路。 + +王名正 39:35 +你就刚刚那一个test,那些都是字幕。 + +许永平 39:36 +就刚刚那一个case,对, 5 个高就切到一些空白。 + +卡若 39:39 +知道,他现在剪出来就剪了五个高光时刻出来,应该是按你的提示是剪出来,但好像有问题,一直这样闪。 + +王名正 39:54 +他剪了就会就闪一闪,闪一闪就切到一些空白的、没用的那一些就直接闪过去了。 + +卡若 39:57 +就其他一些空白的、没用的,拉一些就再返过去。 + +王名正 40:03 +像现在它就跳过生成的事件了。 + +卡若 40:06 +noor 这些他都不会。然后你上面生成。 + +王名正 40:10 +然后你中间生成等待了,它也是在跳过。 + +许永平 40:10 +然后你找那 3 个。 + +卡若 40:12 +你先剪几个做调整就知道了,这个都是你调一下就清楚了。 + +许永平 40:12 +你先写几个。 + +卡若 40:21 +是吧?现在这边跑出来了。你能跑动了就对了。调调他的那个CTR。 + +许永平 40:25 +调调他的那个。 + +王名正 40:26 +gpu。 + +卡若 40:27 +你要调。干不动,干到百分之都满了。你调模。 + +许永平 40:32 +我是直接。 + +卡若 40:32 +直接死机的,直接。你以后像这种你要跑很久的,你就限制它性能 70 80,它自己会给你限制的,你就不会出现卡和点不动的问题了。限制你变成时间还是得。那就多搭百长,百分之 10 20 又没有啥。 cursor 那边经常会断掉。 cursor 会。不了,那么长啊。 + +王名正 40:54 +这里是要至于 create 更。 + +卡若 40:55 +不会,这些都有解决方案,你们跑就知道了,它。 cursor 那边断掉你任务。它会后端去监控文档,它。一样在跑,不用在 cursor 实时给你看,知道吗? cursor 断就断,无所谓,他后端执行下去他不会,他都文档都写好了,让你按他的文档节奏去执行了,知道吧? + +许永平 41:08 +没办法。 + +王名正 41:13 +行,这个得尝试。 + +卡若 41:17 +你们走一遍就知道了。 + +卡若 41:26 +那我过一下这个永平,明天那个你小程序,明天。 + +王名正 41:30 +那个。 + +卡若 41:32 +可以给你改,已经弄完了,现在能正常付款了。 + +王名正 41:33 +因为我们现在已经,那就了解一下,嗯,对吧? + +卡若 41:35 +那就了解一下,用跑一下才知道这个问题在哪里,你自己跑才知道,对吧? + +许永平 41:38 +下回跑一下才知道是。 + +王名正 41:40 +跑一下才知道问题在哪里,自己跑,现在直接做一下,我实证验证一下。 + +许永平 41:42 +是。一跑才知道。好。 + +卡若 41:44 +因为我现在我给你过一下,我只是这几天我要验证一下这个到底卡点在哪里,所以会去那个嘛。 + +王名正 41:51 +对对,去那个。 + +卡若 41:54 +那尽可能,我们要按那个远志那边规划的时间去走嘛。 + +王名正 41:55 +那尽可能的,我们要按那个远志那边规划的时间去。 + +卡若 42:00 +我看一下这个。所以你这个阶段性的东西得给我具体一点发一下这个东西嘛? + +王名正 42:03 +所以你这个阶段性的也会具体一些。 + +许永平 42:07 +好。 + +王名正 42:07 +看一下,就这个,这一个现在的话基本就是这样。 + +卡若 42:08 +就这个,这一个现在的话它基本就是这样,我已经部署上去了,然后,诶,打不拉不过去,啥情况? + +王名正 42:24 +应该是你那个信息。 + +卡若 42:26 +就这一个嘛? + +王名正 42:27 +这一个时间的话,基本就是正常的点。 + +许永平 42:27 +一个这边啊。 + +卡若 42:27 +这边的话它基本就是都可以,正常都可以用,就可能按钮。有点歪啊。但它这些正常的功能都是正常去使用了这些匹配的乱七八糟的其他后台应该是没数据。 + +许永平 42:37 +有啥游戏? + +王名正 42:38 +行。 + +卡若 42:44 +那。前后端都好了。 + +许永平 42:45 +前后端。 + +卡若 42:46 +都好了。数据库也去接,是吧?数据库也接完了。现在是差。差,看看有没有一些 bug 或一些,比如有几个我还没空去改的,比如这个后台这个设置免费的,这个设置的参数我。你们可以记一下。 + +王名正 43:02 +你可以记一下。 + +卡若 43:03 +他们直接布上去测一下。 + +许永平 43:04 +直接布上去测一下。 + +卡若 43:05 +不,已经布上去了,都布上去了,我只是在这边跟你们说一下这个事情嘛,我说能看得到的一些 bug 嘛。对吧?有个问题。 + +王名正 43:18 +问题。 + +许永平 43:19 +没问题,我今天把你那个代码拉下来,然后看,然后他那个叫你,你是用什么东西让他自动编译成小程序啊? + +卡若 43:19 +我今天把你那个代码拉下来了。你说嗯。然后他那个叫什么?你,你是用什么东西让他自动一层一层去找的?我在云马腾讯开放文档,没找到。 + +许永平 43:30 +我在源码里面开发文档,没?找到,好。 + +卡若 43:32 +你这个我等一下说,有问题,等一下说,我先过一下这个事情,有可能这个付款都解决了,在小程序它就跳出小程序付款的,我再去小程序过一下,比较清楚。 + +王名正 43:35 +先过一下这个事情。 + +许永平 43:50 +你刚付款,不是一个环境吗? + +卡若 43:51 +不用,你在我小程序运行不是很难,我给你们过一下,这个已经是可用状态,但是有一些细节,为什么? + +许永平 43:52 +它调试工具是这样,小程序运行不会这样。我直接调用的。对。 + +卡若 44:03 +今,其实现在上线也可以,但我不想这样。 + +许永平 44:04 +现在上线可以,咱们不想这样。 + +卡若 44:06 +知道吗? + +许永平 44:06 +知道。 + +卡若 44:06 +肯定得测啊。 + +许永平 44:07 +肯定得测啊。 + +卡若 44:08 +测也七七八八了,就你像这个他就正常支付就可以了,这个数是调的数据库,就 Mysql 里面的那个数据。 + +许永平 44:09 +测了也七八八了,像这个他就正常支付就可以,这个是调的本身。 + +王名正 44:09 +七七八八的,他是正常。 + +许永平 44:19 +你现在这个好像是已经,其他今天有看那个后台。 + +卡若 44:19 +好像是已经携带飞书了,是吧?我今天有看那个后台。都,这个都自动了,这些都正常可以用了。 + +王名正 44:24 +对对对。 + +卡若 44:28 +付完款之后是能立即知道,比如。 + +许永平 44:28 +付完款之后是立即知道了。 + +王名正 44:29 +付完款之后是我们立即自办。 + +卡若 44:32 +如果我把这个东西给这一小节,这一小节我传给远志吧。 + +许永平 44:32 +过把这个,嗯,等给他之后还需要更新好自己,嗯,后台是。 + +卡若 44:40 +我举例或者传给他,我转给他之后,他只要付款,看过付款我这里就立即就知道付款了。就是我的后台是立即知道,并且能老王那边的那个自动分账的,这个我还没接,但是已经有弄好了,他这里的话我是能看到。 + +许永平 44:55 +然后那个自动就够了,自动看到。 + +王名正 44:57 +跟大诶,但是已经有动作了,他看情况能看到。 + +卡若 45:04 +谁买了? + +许永平 45:04 +谁买的? + +卡若 45:05 +我这边已付款,就一个。 + +王名正 45:06 +一个,嗯。 + +卡若 45:09 +这里谁付款的都很清楚的,然后他没付款就是绑定状态,就微信用户就他嘛,然后在后台的话,这里的话是会有一个都是用户绑定的,今天为什么对这个,这个是用户绑定? + +许永平 45:09 +这里谁付款的都清楚,然后他没付款就是绑定。 + +王名正 45:11 +然后上面是绑定状态,就是微信用户,他跟用户绑定,因为为什么会这个? + +许永平 45:16 +然后在后台的话,这里这个,这是用户绑定的,今天为什么推这个呢? + +王名正 45:24 +这一个是用户绑定。 + +许永平 45:24 +这一个是用户绑定,这个是我的微信推的这一个人吧。 + +卡若 45:25 +比如这个是我的微信推的这一个人嘛。有人进来,我绑定了谁,就绑定这个人,他付款了。 + +王名正 45:28 +有联系平台的绑定谁? + +许永平 45:28 +有人进来,我绑定了谁,反正这个人他付款。 + +卡若 45:32 +我的收益是这个是清晰的知道,而且是现在还没实现立即到账的,是吧? + +王名正 45:32 +周一去这个。 + +许永平 45:32 +我的收益是这个,那是清晰的,而且是现在还没实现已到账,我这个是清晰的,然后这边的话。 + +王名正 45:38 +好的。 + +卡若 45:39 +这个是清晰的,是吧?然后这边的话,诶,不是这个域名,等一下啊? + +王名正 45:41 +然后这边的话。 + +卡若 45:50 +就这里嘛,这里的话这边就正常的能看得到。 + +许永平 45:52 +就这里嘛,这里的话这边就正常的看得到,那我现在的实际点是很多用户中心点击进去是要看到他全部的生命。 + +王名正 45:52 +这里的话这边就正常的看不到,但是我现在的理解是我们用户中心点击进去是要看到他。 + +卡若 45:56 +那我现在的是一点是什么?这个用户中心点击进去是要看到他全部的生命轨迹。 + +许永平 46:02 +给自己跟这一个的,那这一个页面又没有接口,所以这个会出错,知道吗? + +卡若 46:02 +也跟这一个的,那这一个页面因为没有接口,所以这个会出错,知道吗?我今天尝试着去接一下你那个后台,但是没有接口肯定会出错的。 + +王名正 46:08 +我今天尝试着去接一下你那个作品,但是接口肯定会出错的。 + +许永平 46:08 +我今天尝试地去接一下你那个后台,但是没有接口肯定会出错的。没有,现在没有这个功。 + +卡若 46:13 +那没有这个。 + +王名正 46:13 +对,所以这个是需要完善的。 + +卡若 46:14 +对,所以这个是需要完善的,不能。 + +许永平 46:14 +对,所以这个是需要完善的,应该还没到这一步,但是已经那个已经写完了,就是没有也能写就是了。 + +卡若 46:17 +还没到这一步。 + +王名正 46:18 +但是你今天那个今天写完了,就是没有也能写,就是这个接口能正常通,他这里就没问题,知道吧? + +卡若 46:18 +但是已经那个已经写完了,就是没有也能写就是了,你只要接口能正常通,它这里就没问题,知道吧? + +许永平 46:22 +你只要接口能正常沟通他自己的问题,知道他这个点击进去是可以看到他底下有多少用户,以及这个用户点在哪里,看了什么章节的。 + +王名正 46:25 +他这个点击信息是可以看到他底下有多少用户,以及这个用户点哪里看的什么章节的。 + +卡若 46:25 +它这个点击进去是可以看到它底下有多少用户,以及这个用户点的哪里看的什么章节的?是吧? + +王名正 46:33 +把这个是详情,然后这里的话全平台的一个付款,今日点击的跟今日绑定,这个是属于全平台的。 + +卡若 46:33 +这个是详情,是吧? + +许永平 46:33 +这个是讲解,然后这里的话全平台的一个付款,一个点击,一个今日绑定,这是全平台的。 + +卡若 46:35 +然后这里的话全平台的一个付款今日点击的跟今日绑定,这个是属于全平台的。 + +王名正 46:42 +对,因为这个只有一个看书付款跟分销的功能,跟即时到账的功能。 + +卡若 46:43 +这因为这个只有一个看书、付款跟分销的功能跟及时到账的功能嘛。 + +许永平 46:43 +对。因为这个只有一个看书付款的推销的功能,及时到账的功能,然后有一个的话,他只要向我发给发这个链接,我发到群里面去,这个群里面有 10 个人,点击这个链接就跟你合法关系了,这 10 个人接下来一个月所有付费都跟都会。 + +王名正 46:47 +那有一个的话,他只要叫我发给发这个链接,发到群里面去,这个群里面,然后。 + +卡若 46:48 +然后有一个的话,他只要像我发给发这个链接,我发到群里面去,这个群里面有 10 个人,点击这个链接就跟你捆绑关系了,这 10 个人接下来一个月所有的付费都跟都会。你都会收到钱,那它是这个逻辑,所以,而且是及时的,一付款的话就会及时的到那个我们。 + +许永平 47:02 +你都会收到钱,对吧?但是这个逻辑,所以,而且是及时的,你付款的话就会及时的到那个群,你怎么获取到他? + +卡若 47:14 +群里怎么获取到它?ID,它点击这个小程序是带 ID 的呀。 + +许永平 47:17 +ID,他点小程序的 ID 的呀。 + +卡若 47:21 +是要他们点过才有,你没它。 + +许永平 47:21 +这要他们点过才有,没点我。 + +卡若 47:23 +它点进来就可以了,点。 + +许永平 47:23 +他点进来就可以了。我知道,就比如说你发到一个群里面,群里面有 5 个人,他如果没有去点的话,那点了没办法。 + +卡若 47:25 +就比如说你发到一个群里面,群里面有 5 个人。 5 个人,他如果没有去点的话。要点呢。没办法。点就绑了,我们就拿到。 + +许永平 47:35 +点就把它。 + +卡若 47:36 +跟传统,跟你传统分享出去其实是一个逻辑,跟群也没有关。 + +许永平 47:36 +它这个跟传统的,跟你传统分享出去其实是一个逻辑,跟群也没有关系。 + +卡若 47:42 +分享出去是一个逻辑啊。 + +许永平 47:43 +分享。 + +卡若 47:44 +这就跟你正常发一个人或者发到朋友圈人家去点的逻辑一样,它跟群也没有关系。 + +许永平 47:44 +这就跟你正常发一个人或者发到朋友圈,人家去点的逻辑是一样的,它跟群也没有关系。 + +王名正 47:51 +对呀。 + +卡若 47:51 +对,就是我指群,是群里面人多,你点了就容易嘛,是吧? + +许永平 47:51 +对,就是我只群,是群里面还多一点就容易嘛。就跟发个人一样啊。 + +王名正 47:56 +就跟发个人一样,他只是说把这个链接丢到群里了,然后曝光更多嘛。 + +卡若 47:56 +发个人一样啊。 + +许永平 47:58 +对。 + +卡若 47:59 +你推荐,比如,对,比如远志推荐给。谁谁谁,那这个人他只要点了,接下来他看了觉得有用,看了20%,想继续看,付一块钱你 9 毛钱就到你微信了。 + +许永平 48:03 +这个人他只要点了,接下来他看了觉得有用,接下来的一个月所有看的都跟你有关系,都自动的。 + +卡若 48:10 +而且这个人接下来的一个月的所有看的都跟你有关系,每次九毛都到你手上,知道吗?都自动的,它逻辑是这个,那我是可以看到有多少人绑嘛? + +许永平 48:18 +他逻辑是这个,那我是被看到的,所以你发一个群,比如这个群进去就很容易收费了,而且解还要这个解决另外一个问题,是到账的问题,这有。 + +卡若 48:21 +所以你发一个群,比如这个群 500 个人进去就很容易收费了。而且解,还有这个解决另外一个问题是及时到账的问题,这永平就特。 + +王名正 48:32 +这里面。 + +卡若 48:32 +特别要注意一下,因为这一块我就讲一下这个完善的一些东西嘛。 + +许永平 48:32 +您会特别要注意一下,因为这一块讲一下这个。这个用户详情页你估计得先以这个项目单独跑,先不接。 + +卡若 48:37 +用户详情页,你记得建议这个项目单独跑,就先不接。 + +许永平 48:42 +我单独跑。 + +卡若 48:42 +我单独跑,现在都实现了,我还搞啥呀? + +许永平 48:44 +不是,就是你说的这些用户轨迹,你只能说按你这个项目单独去实现这个功能,你如果要等去接那一块,然后用户轨迹。 + +卡若 48:46 +用户轨迹你只能做按你这个项目,按单独去实现这个功能,你如果要等等去接那一块,哪里那么快?用户轨迹,现在你这个改一下就可以直接用了,我现在是没有去改,知道吧。 + +许永平 48:57 +现在这个改一样,你走那。 + +卡若 49:02 +走那边。的话,我要完善的用户,然后这个交易。 + +许永平 49:02 +那边的话查的是不要完善,然后这个交易就是你先以这个项目名存在这个项目下。 + +卡若 49:09 +项目存在这个项目。现在就是存在这个项目,这个现在就没有问题啊。 + +许永平 49:11 +现在就好了。 + +卡若 49:13 +知道,但是你那个商详页里面。 + +许永平 49:13 +知道,但是你这个详情页里面。 + +卡若 49:15 +就是这里面,就是你要去看一下他有一些逻辑的,哪里还有能优化就优化一下嘛,是吧? + +许永平 49:16 +就是这里面,你要去看一下。 + +卡若 49:23 +包括这里面的一些,我说几个点嘛?他那边错了。 + +许永平 49:26 +他那边做好再去提,不然没用。 + +卡若 49:29 +没有,这个要现在要上线了,他们现在就是。 + +许永平 49:29 +你看这个要现在就是。对吧? + +卡若 49:32 +开始推,对吧? + +许永平 49:32 +所以说你现在你这个项目先存在这个项目,就按你的项目。 + +卡若 49:36 +然后这里的话就是一个交易中心和这个用户管理这边的那个绑定的这一个数据还没有到交易中心,他还没做统计,你看这个是付款的,但是这个还没做统计,你看一下那个接口的问题,这有永平,你对一下,明天挑个时间看一下。 + +许永平 49:36 +然后,嗯,这话就是这个交易中心用那个绑定的这个数据,但是这个还不够,这个就跟你对一下,一定挑个时间看一下。好,你这个。 + +卡若 50:00 +哦,你这个是。 + +许永平 50:02 +是这个就是一些用户管理的一些,那这个内容的我说一下长一点的逻辑核心内容这一块的话,还有一个问题是啥? + +卡若 50:02 +这个就是一些用户管理的一些点嘛?那这个内容的我说一下,你讲一下逻辑就比较清楚,内容这一块的话,还有一个问题是啥?就这里的话它是有免费章节的,设完免费章节前台还没有,这个就变成0,但是前台是没有反应的,前端的这一个它不会变成免费,这个我还没去修,我说几个 bug 你记一下就行了。 + +许永平 50:14 +就这里的话它是有免费章节的,设完免费章节,前台这里变成免费,还是前台是免费前端的这一个它不会变成。 + +卡若 50:31 +那这个文件路径。这个是不需要去想的,因为这个的话它是优先读取数据库的,数据库有问题访问不了,它才会读这个文件,它做了双向的,就这这几个,这几个的一个一个问题,我比较重要的一点是这个用户管理的这一块嘛。 + +许永平 50:34 +这的话他是优先要先读取数据库的,数据库有问题导入不了,他才会,他那个双下的就这几个,对,这几个这一块。 + +卡若 50:58 +现在付款这些是都没有问题了,付款呐什么的。 + +许永平 50:58 +所以他付款,这些是付款的。 + +卡若 51:02 +分销,然后提现呐? + +许永平 51:03 +分享这一个小的网页,这个就不用去网页关系那里。 + +卡若 51:04 +这一个是没有问题,就有一些小的问题,是吗?那网页这个就不用去管它,网页端现在不用去管它。主要还是小程序端。 + +许永平 51:17 +主要还是想听同学,然后这里的话。 + +卡若 51:19 +然后它这里的话我看一下这个,就我现在只会专注写东西,你知道吧。 + +许永平 51:30 +我现在只会专注写东西了。 + +卡若 51:32 +这一块我就不会太花时间了。 + +许永平 51:32 +这一块不会太花时间的。 + +卡若 51:35 +那存客宝接口。加好友。 + +许永平 51:38 +加好友。这加这个的话是确定提现的,这现在是自动,这个要实现的是自动分,就老王这个自动分他确定就对了,一样的,知道吧。 + +卡若 51:39 +接了这个的话是确定提现的,这现在是自动,这个要实现的是自动分,就老王这个自动分他确定就可以了,是一样的,知道吗? + +王名正 51:39 +写了。 + +卡若 51:50 +这个到时候也不接这个账号。 + +许永平 51:50 +你这个到时候也是接那个。 + +卡若 51:52 +他这个就是。 + +许永平 51:52 +他这个就是就完成了。 + +王名正 51:52 +就王子哥可以。 + +卡若 51:53 +关键字段。 + +许永平 51:54 +你把,你把你那个调通,这个也是,对,你们那些,就也是那些什么那个项目。 + +卡若 51:54 +你把你那个,对,你们那些就远志那边,咱们那个项目管。管理的这一些内容,你得统一一个文档管理,这样不会乱。 + +许永平 52:02 +管理的这些内容也一个文档,这样不会乱。 + +王名正 52:06 +那到时候我把这一个 Markdown 文件丢给你,你直接对接吗? + +卡若 52:06 +那到时候我把这一个 Markdown 文件丢给你,你直接对接吗? + +许永平 52:06 +那到时候我把这一个拉个大文件就给你。 + +卡若 52:11 +对,然后它里面有很多的那些那个逻辑,这个是逻辑是什么? + +许永平 52:12 +对,然后它里面有很多的那个逻辑,这个逻辑就是拆解一下,先了解清楚了,就是它这个里面的话能匹配的话。 + +卡若 52:20 +就是拆解一下先,你先了解清楚永平就是它这里面的话像匹配的话像这个。 + +许永平 52:32 +他这个第一个匹配的话,就是直接匹配,匹配数据库里面的一些用户,注册的用户,有危险的用户,注有手机的用户,有重要的手机的用户。 + +卡若 52:34 +第一个匹配的话就是直接匹配,匹配数据库里面的那些用户,有注册的用户,有微信的用户,有注有手机的用户,因为这个没有绑手机,所以匹配不到。 + +许永平 52:45 +那第二个匹配的话是他,那个他需要填资料,就是匹配相应的关键字。 + +卡若 52:45 +第二个匹配的话是他那个他需要填资料的,就是匹配相应的关键字就是你的,你的标签是做私域的,那你匹配找资源就会找私域的,或者我能解决私域问题,他填的。 + +许永平 52:54 +就是你的标签是做私域的,那你匹配找资源就会找私域,或者我能解决私域问题,他。填的是私域的管理度相关的,匹配一下,那后面这几个的话,匹配完之后就直接联系方式了。 + +卡若 53:02 +是私域两个关键字或相关的关键字,它就会匹配相关的,那后面这几个的话就是匹配完之后就直接留联系方式了,像这个他就直接调这个里面的这一个微信,那你确定之后就存客宝就加过去了,对,是我的,我那个号就加过去了,和这个也是一样的,这些都是要检查一下吧? + +许永平 53:11 +而且这个他就直接调一个里面的这一个微信,那你确认之后就是多少价格。这个也是一样,这些都是要检查一下,给自己一点提醒,那这个后端是因为现在是漏了。 + +卡若 53:26 +远志也去检查一下,那这个后端是没有问题的,现在是弄的是我。 + +许永平 53:32 +是卡若这个号去抢,只要他们匹配一下。 + +卡若 53:32 +卡若一个号去加,只要他们匹配就直接加了。所以存客宝那边的稳定性是那个需要去弄一下的,那这个我因为我肯定是要赶紧上线的,我明明天可能就要让他们直接用,肯定会出很多的问题的,到时候你群里面都一定会有。 + +许永平 53:38 +所以陈哥把那个权限是那个需要去弄一下。好。那这个我肯定是要赶紧上线,明天的就要让他们直接用。因为出很多的问题,到时候。都还没,都搞定。 + +卡若 54:04 +统计啥? + +许永平 54:04 +统计了。 + +卡若 54:05 +资金。 + +许永平 54:06 +资金。 + +卡若 54:06 +这个不用资金统计,他们能拿到钱、能分发、能有人付钱,能拿到钱就行了。 + +许永平 54:06 +这个不用资金统计,他们拿到的协议就是他能有的资金。厨房也没,也还没实现。 + +卡若 54:13 +分钱已经实现了,分钱他能直接实现,我刚刚就一块钱,你们回头自己付一块钱,就知道你转给永平,永平付一块钱你就能看得到了。 + +许永平 54:13 +分钱已经实现了,分钱他能直接实现,然后用一块钱,不要自己提一块钱,提现了你才可以。有没有一块钱就能看得到? + +卡若 54:23 +提现是在这边推广中心这里。 + +许永平 54:23 +提现是在这边,对完公司这。后台那个资金统计不是。 + +卡若 54:27 +不是。因为这个还没对,这个老王协助一下永平,对一下就好了。 + +许永平 54:29 +因为这个还没对多少,然后写你里面。 + +卡若 54:31 +你明天几点要? + +许永平 54:32 +今天要跟他们说可以使用啊。 + +卡若 54:33 +我明天早上 6 点我就开播,就说了就是这个提现不能再拖了,已经拖了一个月走了,我不可能这个流程已经通了,我也让他们跑过了这个分论分销跟登记统计的,你们就把修补一下就好了,他们核心一点就提现能,就像。 + +许永平 54:34 +我明天早上。那么早说了,咱们等下测试。 + +王名正 54:38 +就是这个理解,不能再拖了,因为拖了一个月流程已经通了,而且刚刚跑过了这个分店分销跟登记统计的,你们就把申请提现,你。 + +许永平 54:39 +就是这个洗一下,我跟你说是这个,我觉得不能再拖了,别改。基础流程应该都没问题的,应该是可以。流程已经这个分本分销。如果这些是可以的话,那基本是没什么问题。 + +卡若 55:02 +那你的小程序是一样的,一个提现,一个统计。 + +许永平 55:02 +企业下面小程序是一样的。 + +王名正 55:04 +对,你提现,现在,不,你现在提现不着急,你可以先让他们用完之后,我们然后之后再发一版。 + +许永平 55:04 +对,企业现在是一个。现在不着急嘛。 + +卡若 55:07 +不着急,你可以先让他们用了,用完了之后我们。 + +许永平 55:11 +对。 + +卡若 55:11 +不提现,直接用,因为这个就是你把你刚刚弄的那个功能接上去就结束了,知道吧? + +许永平 55:13 +极限直接用,因为这个是你把大家都弄,因为我们接上去就结束了。 + +王名正 55:14 +因为这个就是你想让他弄就接上去就结束了,你知道我已经最新的,我已经上到他。 + +许永平 55:19 +好。 + +卡若 55:19 +我已经是最新的,我已经上传到 GitHub 上面了。 + +许永平 55:19 +我已经是最新的,我已经上传到 e 卡上面。 + +卡若 55:22 +主要是你得审核。 + +王名正 55:22 +主要是你得审核,那小程序也要审核啊。 + +许永平 55:22 +主要是你得审核。不审。 + +卡若 55:25 +不审,现在不审。 + +许永平 55:26 +现在不审。 + +卡若 55:26 +小程序没有审的吗?小程序这个审核都秒过了。 + +王名正 55:28 +小程序这个简单。 + +许永平 55:28 +小程序这个审核都秒过了。 + +王名正 55:31 +没。我拉一个就秒,客户类型不一样。 + +卡若 55:34 +你那个,你那边,你是不是它本身就有支持不同商户的处理嘛? + +许永平 55:34 +你那个,你那边是不是本身具有支持不同商户的处理? + +王名正 55:41 +什么事? + +卡若 55:41 +因为这是两个不同的项目,你肯定是要跟不同商户的处理。 + +许永平 55:41 +因为这是两个不同的项目,是要跟不同商户的处理。 + +王名正 55:41 +不知道。 + +卡若 55:46 +不用,直接跟我们同一个。 + +王名正 55:46 +没有,不用同一个,对,你后台有弄的话就有像你那个接口写好了之后我发起提现,我数据库记录了,那就可以了。 + +许永平 55:46 +不用。 + +卡若 55:47 +同一个资金库。 + +许永平 55:47 +你拿到资金户。 + +卡若 55:48 +对,同一个就行。 + +许永平 55:48 +对呀。OK。 + +卡若 55:49 +那到时候对,那个明细发那个,对。 + +许永平 55:50 +他到了对应的明细。 + +卡若 55:52 +后台都有。 + +许永平 55:53 +后台他就像你那个接口是要发起提现数据不记录了。 + +卡若 55:55 +像你那个接口是这样,我说我发起提现,我数据做记录了。 + +许永平 56:01 +对啊。 + +卡若 56:01 +对,你到时候。 + +许永平 56:02 +到时候发起一些这种教育。 + +卡若 56:04 +我就给你们先。 + +许永平 56:04 +我是给你们信号,是吧? + +卡若 56:05 +这个字段。 + +许永平 56:06 +你看我这个 6 点就付款,这么大,哎,那点一下链接。 + +卡若 56:06 +你看我这个谁 6 点又付款了,一个一笔,哎哎,就是他是及时很重要,知道吗? + +王名正 56:07 +对,看不大。 + +许永平 56:15 +就是他是及时很重要,知道一个是我这边有付款,我这里他是主号,我一定会收到的。 + +卡若 56:17 +一个是我这边有付款,我这里的话是属于主号,我一定会收到的,你看是及时性,一有人付款他买了第几节我是立即知道,这个都不知道谁买的,对吧? + +王名正 56:17 +一个是我这边。 + +许永平 56:24 +你看看是及时现一有人付款,他们的第几节不是你知道都不知道谁买。 + +卡若 56:31 +我就收到这个钱嘛。 + +许永平 56:31 +是吧?我就收到这个钱。 + +卡若 56:32 +那比如我把这个链接给老王,知道吧? + +许永平 56:32 +那如果我把这个链接给老王,叫老王去付款,我这里收到钱了,好,钱。 + +卡若 56:36 +老王付一付款了,我这里收到 9 毛钱。诶,这实现不了,现在不是提现得自己,这个是相当于转账的功能,就不是那个提现。 + +许永平 56:40 +诶,这个实现不了,现在不是提现给自己,这个是相当于转账,不是那个提现。 + +卡若 56:46 +提现功能,这个是。提现在是要手动点的。 + +许永平 56:47 +提现是这样的,手动点的就没有自动。 + +卡若 56:49 +就是手动点,就刚刚这个过程跟老王那个一样。 + +许永平 56:50 +就刚刚这个过程,这应该是要调调转账的功能。 + +王名正 56:54 +他再一个是商户卡若是商户给他管理者,所以说有人付款商户的都能及时收到通知。 + +卡若 56:54 +他在一个是,他是卡若的管理者,所以说哦。 + +许永平 56:54 +他这一个是。看那个。 + +卡若 57:01 +他那个。那个分账的也是一样。 + +许永平 57:02 +那个分账收款记录不是分账。 + +卡若 57:04 +不是分账,对,他这是收款。 + +王名正 57:04 +对,这收款记录。 + +许永平 57:05 +对,他这是收款。 + +卡若 57:07 +分账的也是一样,就刚刚老王那个碎片时间的事情。 + +许永平 57:07 +分账也是一样。账和分账时间。账是现在要自己点。 + +卡若 57:10 +大家自己点对,自己去提现,然后就是领取。 + +王名正 57:11 +对,是。 + +许永平 57:12 +对。自己去提现,然后自己去领取。 + +卡若 57:14 +就是我刚刚的那个界面,他点了确定了他就到账了,知道他要需要自己点,就这个流程就跑一下,反正他们我明天会直接跟他们讲去,因为太久了一直在说,对吧? + +许永平 57:14 +就是我刚刚的那个界面,他点了确认他就到账了。对,他要自己点。大家要自己点这个流程跑一下,反正他们我明天会直接跟他们讲去,因为太久了,一直在说。好,就都那个群里,你看都。 + +卡若 57:30 +都那个群,你看都多少个人?真的嗷嗷待哺,他们天天培训,天天培训,培训没结果,很快就没士气了。 + +许永平 57:32 +找个人,然后再给他们培训,没结果,太磨士气了。 + +王名正 57:33 +OK。 + +卡若 57:37 +知道,我现在都是以让给他们补贴的,硬给的。 + +许永平 57:38 +是吧? + +王名正 57:38 +我现在都是让给他们对比,那这个已经基本上线,让他们去做分发就行。 + +许永平 57:38 +我现在就是让给他们补贴的,定点的。好。 + +卡若 57:42 +知道吧? + +许永平 57:43 +知道吧? + +卡若 57:44 +那这个已经基本能上线了,就让他们去做分发就行了,还有里面还需要一个逻辑的,也是要整理一下,就是接下来每我每新增一章节,我把这个过一下。 + +许永平 57:44 +那这个已经基本上线了,让他们去做分发就行了,还有里面还需要一个什么要整理一下,就是接下来每我每新增章节把这个过一下,明天 6 点肯定不能说明天的话,明天我们都还。 + +王名正 57:49 +那你里面还需要一种,嗯,就是接下来产品每新增一章节。 + +卡若 57:59 +明天 6 点肯定不能说别人的话,明天我们都把电话。 + +许永平 58:02 +用不直接用,先用出问题再说,现在是不管跟长能看到前情况明显出问题再解决就行了。 + +卡若 58:03 +不直接用,出问题再说现在是付款跟分账的,能看得到钱就行了,提现出问题再解决就行了。 + +王名正 58:03 +不用不用,之后你再说现在是试管。现在是试管。我再让他们想办法。 + +卡若 58:11 +我让他先让他们小规模测试,不要每个人都用。 + +许永平 58:12 +我让他先让他们小规模测试,不要每个人都用,还有我刚刚说啥来着? + +卡若 58:16 +诶,我刚刚要说啥来着? + +王名正 58:16 +他说他自动的接一下。 + +卡若 58:17 +那数据统计那块没用,那到时候数据一统计清掉。 + +许永平 58:18 +那数据统计那块没弄,那到时候数据你也得重新清掉。 + +卡若 58:21 +没有,它都自动地去分账,你管数据统计这个。 + +许永平 58:21 +不是,他都自动的去分散。不是后台的那个统计,你现在这个资金统计不是没有吗? + +卡若 58:25 +现在这个自己统计没用吗?这个就接一下嘛? + +许永平 58:28 +这个接一下,这个在就是统计这一块的。 + +卡若 58:28 +你们看一下这个跟就是统计这一块的嘛。对,那你给。 + +许永平 58:31 +对,那你。给他们用完,到时候数据对不上你就得清掉。 + +王名正 58:35 +那钱就直接现在知道怎么办了,一个人跑店的,一个人挣 9 毛钱也行。 + +卡若 58:35 +那钱都直接给他们了,现在不是自动分账了吗? + +许永平 58:35 +那钱呢?直接给他,这样不是自动分账了吗?不知道,就是。 + +卡若 58:41 +比如这里绑定这一个人,这 9 毛钱就直接那个嘛? + +许永平 58:41 +比如这里绑定这一个人,这 9 毛钱就直接点,你把这个。 + +卡若 58:45 +你把这个我明天肯定是先让他们去走,去发钱,然后里面有点钱。 + +许永平 58:47 +就是到你测过的话。 + +王名正 58:48 +我明天。 + +许永平 58:48 +我明天肯定是先让他们去,走,去花钱,然后这边说内部钱灰色的这种,对,先测一下,测的有问题再说吧。 + +卡若 58:53 +对,先测一下,出问题再说,这是一个,因为这个事情有一点是。 + +王名正 58:54 +我先测一下再说这几个,因为这个事情有一点是。 + +许永平 58:58 +再说这是一个因为这个事情有一点是。 + +卡若 59:04 +那个的他也就离变现比较近,直接就用就行了,对吧? + +王名正 59:04 +那个,那你这是比较近。 + +许永平 59:04 +那个,嗯,他以就离变现比较近,直接就有就行了,对吧? + +卡若 59:10 +然后里面有一些小小的一些逻辑,你们拆解完之后去看一下那个文档,自己去拆去看一下那个文档吧。 + +许永平 59:10 +那里面有一些小的线路,你们拆解完之后去看一下那个文档,自己去拆看一下那个文档。 + +卡若 59:18 +然后我刚刚还有一个啥事,对了,这里的话是新增章节,我会新增一些章节,比如新增一块这个数就会变,这个是另外一个隐藏的版块了,新增一个那个数就会变成 9 块9,比如今。 + +许永平 59:19 +哦,对了,这里的话是新增章节,我会新增一些章节,比如新增一块,这个是另外一个隐藏的板块,新增一个,那个数据会变成 9 块9。 + +王名正 59:19 +对,这里的话是新增章节,我会新增一些章节,新增这数字变这个是另外一个,新增一个,那个数字会变成 9 块9。 + +卡若 59:32 +挣一块就变 10 块钱,我多写一张就变 11 块钱,但是 9 块 9 是现在 62 张,小结是相当于是基础版的 9 块9, 62 张后面新增一块。 + +许永平 59:34 +我多写一张就变 11 块钱,但是 9 块钱的现在 62 张奖金是相当于基础款 9 块钱, 62 张后面新增一块。 + +王名正 59:36 +但是 9 块钱变成62。也是。62。 + +卡若 59:44 +跟章节有关系,跟你里面的这个价格。 + +许永平 59:44 +跟章节有关系,跟你里面的这个价格没关系。 + +卡若 59:48 +跟价格有关系。 + +许永平 59:48 +跟价格就你多一张就多一块钱,我可以设成两块,我多 100 块。 + +卡若 59:49 +就你多一张,就多一块钱嘛。我可以设成两块就多两块钱,我多 100 块就多 100 块钱。 + +许永平 59:55 +那就是加上你新增的这个章节的总共多少钱嘛? + +卡若 59:56 +加上你新增的这个章节的多少钱呢? + +王名正 59:59 +来一个,是。 + +卡若 59:59 +它就等于一个是普通版。 + +许永平 01:00:00 +它不等于一个是多。 + +卡若 01:00:02 +一个是增值版,买普通版还是 9 块9,买增值版的就是 9 块 9 的不断的叠加。 + +许永平 01:00:03 +那是增值版,买普通版的是 9 块9,买增值版的。 + +王名正 01:00:04 +来,我们把。 + +卡若 01:00:09 +叠加的金额是不是你新增章节的金额吗? + +许永平 01:00:10 +加的金额就是新增的发票金额。对,就这一个,就有一个普通版的那个增值版。 + +卡若 01:00:14 +对,新增章节的金额就这一个,就有一个普通版,一个新那个增值版的。 + +王名正 01:00:22 +对。 + +卡若 01:00:25 +那你这里面也没有分普通版跟增值版。 + +许永平 01:00:25 +那你这里面也没有分普通版和增值版。 + +卡若 01:00:28 +还没分,但这个你们记要就要记一下这个事情。 + +许永平 01:00:28 +还有一个就是要,就要记一下。 + +王名正 01:00:30 +你们说专把。 + +许永平 01:00:32 +事情。 + +卡若 01:00:38 +目前两个逻辑都。 + +许永平 01:00:38 +目前两个逻辑都没有,对吧? + +卡若 01:00:40 +哪个逻辑已经有那个,但是他这个是看了十章之后才会触发这个增值的这一个内容。 + +许永平 01:00:40 +哪个逻辑已经有那个,但是他这个是看了十张之后才会触发这个增值的这一个点。 + +王名正 01:00:41 +因为有那个。 + +卡若 01:00:50 +就比如匹配三次就要让他填手机号码了,他可以免费匹配第三次,他就要自己填手机号码这一些里面的一些和那个。 + +许永平 01:00:50 +就比如匹配三次就要让他填手机号码,他可以免费匹配第三次,他就要自己填手机号码这些里面的一些那个。 + +王名正 01:00:55 +他可以免费。分析里面的一些那种,那个。 + +许永平 01:01:02 +那个步骤跟逻辑,还有一些小型的算法在这里面就匹配三次,所以然后他付款买了一张才能匹配资源,这里面猜一下就比较清楚一点,或者是现在的话,一个极限的话可以快速记一下极限,记得这个快速了解一下这个事情。 + +卡若 01:01:03 +步骤跟逻辑,还有一些小型的算法就在这个里面,比如匹配三次之类的,然后他付款买了一张才能匹配资源,这里面你们猜一下就会比较清楚一点,或者现在的话一个提现,老王那边就快速地对一下提现跟统计的这一个点,跟永平就快速地了解一下这一个事情,这一个是。 + +王名正 01:01:22 +这个是现在的一个极限。 + +许永平 01:01:32 +这一个是为什么? + +卡若 01:01:32 +为什么让你们快速过一下这个事情呢? + +许永平 01:01:33 +让你快速过一下我的一本书单位开完会,这也是可以,这个机构的文档是一样的。 + +王名正 01:01:34 +他是那个。 + +卡若 01:01:35 +他现在用在的地方很多,现在只是我的一本书,对吧?我们昨天刚去那个银掌柜那边也开完会,这个也是可以应用在金融方面的,就我丢一个金融的文章过去解决获客给他们中台,那就不用,不一定买手机了,是不是一样的逻辑? + +王名正 01:01:56 +都一样,逻辑性一样。 + +卡若 01:01:58 +是一样的,是吧?你看。看一些金融的一些视频,或者一些干货一样的,是吧? + +许永平 01:02:06 +然后这个要记一下,看把这个进度,而且可以在对这些的时候不考虑一下这方面,对才会发现。 + +卡若 01:02:12 +这,这个就要记一下,看那个嘛?你把这个进度每次就新增一条,有一个进度条嘛。 + +王名正 01:02:18 +你看。 + +卡若 01:02:20 +我们就几条线,可以这几条线直接往下去弄,然后永平在对这些的时候,你就多考虑一下审社所这方面的事情,你对着就才会发现哪里有问题嘛。 + +许永平 01:02:32 +好。 + +卡若 01:02:33 +对吧?因为我们一定是那个,包括老王,也是你在对碎片时间,对这个数据接口的过程当中碰到问题就直接解决掉。 + +许永平 01:02:33 +那我们一定是,包括老文也是在对碎片时间,对。 + +卡若 01:02:44 +问题肯定有的,你看远志今天铺这个问题不就出来了吗?那我们把它解决掉就行了,对吧?你这个机器的这个基础的那个配置,配置完之后是就会有很多的就直接复制就行了,是吧? + +王名正 01:02:52 +第一次。 + +卡若 01:03:02 +就不会太多,有很多的参考的一些东西,是吧? + +王名正 01:03:03 +就不会。所有的参考。 + +卡若 01:03:08 +包括这个我再简单地说另外一个事情,那个我发了一个会议纪要的那个通版的那个原则。 + +王名正 01:03:13 +那个要这个,但是不一样,这次不一样,会自动。 + +卡若 01:03:19 +在哪?我就在这个 NAS 上面,这个。这个是智能纪要的,这个智能纪要会自动,你总结完就自动发到群里面了,我。过一遍。 + +许永平 01:03:33 +懂的话。 + +卡若 01:03:33 +就是 V0 的那个要考核的吗? + +许永平 01:03:34 +他来不出答案。 + +卡若 01:03:35 +这个就变成固定版了。看一下。我给你过一下,这个你就比较清楚,对,你们直接对完那个,直接那个嘛。 + +王名正 01:03:41 +我让那些配置参数先码给。 + +卡若 01:03:47 +嗯,我看一下,就昨天的,我举个昨天的,因为你在 cursor 上就能直接解决,我看你 V0 不太喜欢用。主要是它加载不出来。对吧?找了密钥,怎么了? + +许永平 01:04:03 +咋了? + +卡若 01:04:04 +打开了。 + +王名正 01:04:05 +打款的。 + +卡若 01:04:08 +那我。你这个发到群里可以发出去,你发到群里了。 + +许永平 01:04:12 +可以。 + +王名正 01:04:13 +我发你个人了。 + +许永平 01:04:15 +发到群里了。 + +卡若 01:04:16 +发群里了。发出去是发出去了,这个怎么能发到群里? + +王名正 01:04:17 +发群里了吗?是发群还是发个人了? + +许永平 01:04:18 +你发错了,撤回一下。这个怎么能发到群里?去找一下,还有其他的吗? + +卡若 01:04:23 +群里面还有其他人吗?没有,我们这群没其他人。 + +许永平 01:04:25 +没有。 + +卡若 01:04:27 +没有。 + +王名正 01:04:27 +没有。 + +卡若 01:04:28 +自己人没事,有其他人就别发了,我。 + +许永平 01:04:29 +那就行。我想知道。千文还有。 + +卡若 01:04:32 +我把那个我给你过一下这个东西,比如这个昨天永平开会的嘛。 + +王名正 01:04:33 +我那个这种。 + +许永平 01:04:34 +那个你可以过一下。 + +卡若 01:04:38 +你说的那个是 cursor 的生成会议纪要的内容。 + +许永平 01:04:38 +你说的那个是 cursor 的生成会议纪要的。 + +卡若 01:04:42 +不止生成会议纪要,我跟你们讲有两个事情,不然我不会拎出来讲。生成会议纪要那就太简单了,这一个是我放到这随便拉一下,你看发送那个,诶诶? + +许永平 01:04:49 +这个是好的啊。 + +卡若 01:05:01 +没拉过去拉。 + +卡若 01:05:09 +诶,你这是飞书链接吧?不,我,我跟你讲,等一下,我先拉过来。上面那个是啥? + +许永平 01:05:17 +方面的一个思考。 + +卡若 01:05:18 +等一下你把这一个生成总结纪要,然后发到飞书的这个群里面来,我简单地说一下。个,这个是飞书的这个Webhook。 + +王名正 01:05:35 +那个。 + +卡若 01:05:38 +就拉了一个小机器人嘛。对,就这里面,你可以,这里面微信也可以实现的。我讲这个是这一个逻辑,跟我们这个现在存客宝功能有用的,这里的话是配置的一个那个 Webhook 的地址。知道,那我这个做 Webhook 的地址做完之后是干嘛呢?我现在是不是把这个智能纪要这个弄完了? + +王名正 01:06:03 +是不是? + +卡若 01:06:06 +然后这一个就总结智能纪要,总结纪要,然后就回测一下,它就生成直接发到群里面去了。 + +王名正 01:06:12 +一样。 + +卡若 01:06:20 +知道,那这个是用来干嘛的呢?先,你们先看一下流程,会比较清楚。微信应该没这种功能吧?微信有我,我们存客宝也可以做。 + +王名正 01:06:29 +不不不。 + +许永平 01:06:31 +你说事啊。 + +卡若 01:06:32 +这个的功能发到个人的群也可以做这个功能的。 + +王名正 01:06:32 +产研团队每日会议, 2026 年开会前必看。无文档不开会,会前请大家按照模板填写要讨论的内容,踊跃评论,积极讨论。 + +卡若 01:06:37 +这现在没有去做嘛?我先把这几个字提到的你们就记一下,不然回头都会忘掉,知道吗? + +王名正 01:06:40 +准时开始后集体默读 10 分钟, 10: 00- 10: 10,请所有人踊跃评论,这也会被。 + +卡若 01:06:43 +这个就是要直接加到一些需求里面去,我先说一下这个思路是怎么样的? + +王名正 01:06:44 +产研团队每日会议, 2026 年开会前必看。无文档不开会,会前请大家按照模板填写要讨论的内容,踊跃评论,积极讨论。 + +卡若 01:06:48 +这个智能纪要它做完之后,它就自动的是把这个发到这个飞书群里面去,那发的样式是怎么样? + +王名正 01:06:52 +准时开始后集体默读 10 分钟, 10: 00- 10: 10,请所有人踊跃评论,这也会被。 + +卡若 01:07:01 +像这个吗?我给你看一下,他们现在也那个发出来的样子,就长这样,嗯,他就会应该受,咋会跑到这里去? + +王名正 01:07:07 +微信的那个发出来的样子。 + +卡若 01:07:19 +什么鬼?一条消息?那这个可以做到什么程度? + +王名正 01:07:26 +这个可以做到。 + +卡若 01:07:27 +就是我们开完会之后触发自动地去把。这个内容发出去。 + +王名正 01:07:34 +发出去,不需要,那这个。 + +卡若 01:07:36 +那你前面那些下载不是手动的吗? + +许永平 01:07:36 +前面那些下载。 + +卡若 01:07:38 +不,不需要,我给你看看,做完了你们打开群看一下。比如说前面几步不得是手动吗? + +许永平 01:07:48 +就前面几步都给手动,他就会是。 + +卡若 01:07:49 +不需要,我等一下会说,我只是为了展简单演示,告诉你们它的实现流程,是吧?它这个图片,没没没发图片,没发你就正把图片也发过去。通过接口把会议图片,我说一下,这个要配置那个TOKEN,所以我才没有先给你们过一下,这一个就比较清楚,是吧? + +王名正 01:08:05 +对。没错。 + +王名正 01:08:18 +我说一下这个在配置那个。 + +许永平 01:08:21 +对。 + +卡若 01:08:33 +他这个是昨天的一些总结, 12345 的,他还会有一张图片出来,那这个我已经放到那个里面去了。 + +王名正 01:08:33 +那这个是我已经发到这里了。 + +卡若 01:08:42 +工作流吗?对,他是一个工作流,这个是基础的一个一个事情,那他可以做到的一点是什么? + +王名正 01:08:45 +那是。那他可以做到。 + +卡若 01:08:50 +就是咱们这边不是有那个会议的图吗? + +王名正 01:08:53 +反正这边不是那个会议的,那。 + +卡若 01:09:05 +就比如我们开会的文档,你直接丢过去就可以了,来,我给你们过一下就知道了,要一步步,不然一定会乱,那么他这个有点不一样。 + +王名正 01:09:08 +跳过直接贴过去就行。 + +卡若 01:09:25 +那不也要用客色吗?手动的。你这一步不也手动吗? + +许永平 01:09:29 +这也不也是手工吗? + +卡若 01:09:30 +自动发旅客色吗? + +许永平 01:09:31 +能自动发客户? + +卡若 01:09:33 +当然是可以的,我是一步步跟您讲的,不是您才知道实现流程,不然会有那个的这个要应用到其他地方去,就是现在就把这个链接里面的这一个文字文档导出来,然后发到飞书里面,发到那个会议纪要的飞书里面,然后全部用命令行,不要出现那种扫码的一个一个形式,然后你直接去获得那个相应的 API 跟TOKEN。 + +许永平 01:09:33 +当然是可以的,我是一步步想才知道自己成功了。 + +王名正 01:09:40 +这个要应用到其他地方去,就是现在这个预约。 + +王名正 01:09:56 +不用命令。 + +卡若 01:10:03 +就大概这样,好吧?你给他回,他就会去找链接,自己链接里面文字找出来。 + +王名正 01:10:08 +那就会去找链接,链接就对。 + +卡若 01:10:12 +那这一步,这一步你要怎么去实现自动化? + +王名正 01:10:12 +那这一步你要怎么去实现这个? + +许永平 01:10:12 +那这一步,这一步要在执行那个会议丢到科室里面去执行这种。 + +卡若 01:10:15 +哪一步? + +王名正 01:10:15 +诶,你说开那个会议室吗? + +卡若 01:10:15 +你说。开执行的这一步。开那个会议,是吗?就那个会议丢到 cursor 里面去执行这个东西。 + +王名正 01:10:19 +这个会议丢到科室里面去执行这个东西。 + +卡若 01:10:22 +对,这个就是会议,那这个就非常更简洁了,这一步一步来嘛,你就现我们把每天的这个,你抓到这个产研团队会议纪要。 + +王名正 01:10:22 +对呀,这个就是会议,这个就非常更简洁了,这一步一步来,你在线,我们把每天的这个,你抓到这个产研团队会议的。一样的一个内容,开会的这个通过飞书的这个API。 + +卡若 01:10:32 +的这一个内容,开会的这个通过飞书的这个API。他那个。 + +王名正 01:10:38 +他那个是多久啊? + +许永平 01:10:38 +他那个的内容。 + +卡若 01:10:38 +你听我讲完,然后把这个内容,那个视频会议最新的有产研团队会议的内容,把它那个发送到这个,那个解析成最新的这个链接,然后发送到总结成那个会议,发送到那个飞书群里面,那一定要带图片,然后就让他去执行就行。 + +王名正 01:10:42 +会议最新的那个会议的内容,那个发送到这个,那个系统最新的这个链接发送到,总结成这个会议,发送到飞书群。 + +许永平 01:10:47 +发送到这,最新的这个,立即发送到这个。 + +卡若 01:11:03 +诶,咋没看到这个,知道吗?那你每一天开会的,当天开会的产研团队的内容,并且内容要超过 5 分钟以上的内容才执行这个步骤,那全部用命令行实现,不要用网页和这一个,然后把这个 schema 更新一下。 + +王名正 01:11:06 +那你每天开会的当天开会的产研团队的内容,并且内容要超过分钟以上内容才执行这个步骤,那全部用便利贴实现,不要用网页和这一个,然后把这个细节的更新一下。 + +卡若 01:11:31 +就大概是这样。 + +王名正 01:11:32 +是这样。 + +卡若 01:11:39 +我就走一下过程,因为这个我已经做完了,所以这一些就是你迭代进去的,就是我们每天开会它是自动去捕捉,开完会自己去捕捉这一些东西,那这个只是基础的一些事情,我在那它这个就做。 + +王名正 01:11:40 +我就走一下过程,因为这个我已经做完了,所以这一些就是迭代进去,就是我们先开会,但是自动去组织,开完会自己去组织这个这些东西,那这个只是基础的一些事情,我觉得。 + +卡若 01:12:02 +做成做完的吗? + +王名正 01:12:02 +就做完了,他没有做成图片的形式。 + +卡若 01:12:06 +过一下吗?但这个他没有做成图片的形式,这个可以做成 html 的图片的形式,因为他这个是总结的行动项,简要的行动项,那你可。 + +王名正 01:12:23 +这个可以做成 html 的图片的形式,因为它这个是总结的行动项,简要的行动项,那。 + +卡若 01:12:32 +可以变成什么? + +王名正 01:12:32 +也可以变成什么? + +卡若 01:12:33 +变成那个会议纪要的形式就可以了。 + +王名正 01:12:33 +变成那个会议纪要的形式,现在是写了一个,你可以还变成会议纪要的形式,因为这个有个总结文档,一个会议纪要那个工作也我也丢进去了,真的。 + +卡若 01:12:36 +他现在是截了一张图过来了,你可以把它变成会议纪要的形式,因为这个有个总结文档,一个会议纪要那个工作流我已经丢进去了,你们自己去在 NAS 上面,那你不用那么智能也可以了,就是生成完之后直接丢就好了,我只告诉你它是可以。 + +王名正 01:12:55 +那你不用那么智能也可以啊,就是生成完之后直接丢入就好了。我只告诉你他是我的意思就是说你。 + +许永平 01:13:01 +是我们。 + +卡若 01:13:03 +手动去开 cursor 去执行,对吧? + +王名正 01:13:03 +手动去打开搜索去执行这个东西,我只是说把之前的几步,你现在变成了。 + +许永平 01:13:04 +去各自去执行,是说只是说自己。 + +卡若 01:13:09 +打开。说只是说把之前的几步现在拼成一步。对,打开 cursor 肯定是要打开的。 + +王名正 01:13:15 +对,那我的意思是说你的,我以为你说的是全自动。 + +许永平 01:13:15 +对,那我的意思是说,我以为你说的这种全自动的。 + +卡若 01:13:15 +那我的意思是说你能,我以为你说的是那种全自动的。那全自动的肯定是能实现的,但是你部署很麻烦的。怎么不能实现全自动的?早就能实现了,就是有些东西我说得太抽象,你们会有很多卡点。 + +王名正 01:13:26 +就是有些东西我说得太粗,你们会有很多。 + +许永平 01:13:30 +说的太抽象。 + +王名正 01:13:32 +有卡点让你们去做,现在都稍微你们现在的一个。 + +卡若 01:13:32 +卡点知道吗?你如果去做这个,现在都我给你,稍微,每天我都给你们分享一点嘛? + +许永平 01:13:35 +如果去做会需要。 + +卡若 01:13:40 +你们就知道一些东西,那这个会议纪要就你快速地去弄一下就知道了。那这个这什么鬼,对吧?他自己会去实现一些东西,自己去解决这个问题,不管他,但有一点是什么,你们现在有一个。问题就是像你刚刚说的,自动的我给你看,自动的去分发,就是我给我自己的微信发条信息,他自己去解决所有问题,是吧? + +王名正 01:14:03 +问题是像你刚刚说的自动的。 + +王名正 01:14:18 +自动地去分发,但是我给我自己微信发消息,解决这个问题,我自己去执行了,也不用那个嘛,给你之前还是那个。 + +许永平 01:14:18 +自动机器人的那个。 + +卡若 01:14:24 +自己去执行嘛,你不是那个嘛?那我给你看一下。机器人的那个,是吧?比机器人那个先进多了。过了,那个什么鬼玩意? + +王名正 01:14:32 +产研团队每日会议, 2026 年开会前必看。 + +卡若 01:14:36 +你不是用他的那个模型吗?他的是抄另外一家的,有几家的不一样,那像这个看到没有? + +王名正 01:14:39 +无文档不开会,会前请大家按照模板填写要讨论的内容,踊跃评论,积极讨论。 + +卡若 01:14:47 +这个消息中枢是干嘛的呢? + +王名正 01:14:48 +准时开始后集体默读 10 分钟。 + +许永平 01:14:50 +是,行。 + +卡若 01:14:50 +就是我自己给微信发信息,我给我自己的微信发信息,我这没装嘛? + +王名正 01:14:55 +10: 00- 10: 10 请所有人踊跃评论,这也会被。 + +卡若 01:15:01 +我给我自己的微信。 + +许永平 01:15:01 +没有自己。 + +卡若 01:15:02 +发信息他自己会去执行所有的动作, Whatsapp 也可以,微信也可以,就所有的都可以,包括网页。 + +王名正 01:15:09 +OK。 + +卡若 01:15:15 +那我就给你们过一下,这个是我给他发信息是发干嘛呢?也可以语音微信,我给他发信息之后,先说一下后面的那个逻辑,他这里这边他会自己去招募人,你知道吗?我给他发信,因为他能力越来越多,他自己去招募团队了,你看每个团队的一个能力和人设,他自己会去定义,这个不是我弄,他自己去生出了几个崽出来。 + +王名正 01:15:45 +这个比如说我让他自己去搜索一个产品。 + +卡若 01:15:50 +就是我上次看他们的那个逻辑,其实就是他,你的下面其实要有一个AI,然后这个 AI 再去帮你。 + +王名正 01:15:54 +当你的上面要有一个。 + +许永平 01:15:56 +你要有一个AI,然后这个 AI 再去。 + +卡若 01:16:03 +控制你下面团队,这还要多一层,就是中间有个 AI 去帮你做所有的事情。 + +王名正 01:16:04 +你下面。对。没有这个意思,就是中间有个这样去做所有的事。 + +许永平 01:16:12 +那肯定这个就是一个AI,它这五个管理就管理每一个。 + +卡若 01:16:12 +那肯定这个就是一个AI,它这五个管理每个人都有,你把它变成就是。 + +许永平 01:16:19 +如果就是它上面其实还有一个管理员,然后它底下就是管理的几个管理层,对,管理它也有自己的记忆。 + +卡若 01:16:20 +其实还有一个管理。管理员,就这个就是大的管理员,他底下就是几个。几个管理嘛?几个管理嘛?那几个管理。对,管理他也有自己的,比如他记忆。 + +王名正 01:16:30 +他也有自己的虚拟币。 + +卡若 01:16:32 +记忆的功能,对吧? + +王名正 01:16:32 +业务功能每个管理组管理内容不一样,是一个可以吸收给这个随便举个例子。 + +许永平 01:16:32 +也包括我们,是吧? + +卡若 01:16:34 +他每一个管理就把他的能力往下去拆分了,对吧? + +许永平 01:16:34 +他每一个管理者。 + +卡若 01:16:39 +他管理有管理的能力,然后他底下把能力分配给他底下的团队成员去执行嘛。 + +许永平 01:16:39 +他管理。 + +卡若 01:16:46 +每个人是不一样的,性格也不一样的。那比如我们要做一个分类的话,他自己会去吸收一些东西出来,吸收给这个团队,知道吗?我随便举一个例子,你看像。 + +王名正 01:17:02 +像这个。 + +卡若 01:17:02 +这个我好几个。 + +卡若 01:17:17 +你看他比如这个手机自动操作的,是吧? + +王名正 01:17:18 +任何问题都可以问。 + +卡若 01:17:24 +这个我已经有一个版本的能力,你看我这一个。对吧?然后像这种搞流量的自动去做排名的,对吧? + +许永平 01:17:39 +好。 + +卡若 01:17:41 +把这两个这个文档的这个核心代码跟它的一些那个流量获取的一个形式,形成自动化操作的一个stream。然后你安排,看安排谁来安排这个能力到哪一个人设的身上?然后哪一个人的身上?你把这个放到卡若 AI 底下。的一个一个skill,然后用中文名来命名嘛?我跟你讲讲一点是怎么样去吸收一些你能看得懂的一些能力嘛。这个首先是自己能看得懂并且执行过,好吧? + +许永平 01:18:12 +这两天一起实现你这个通过百度的算法,但是他新做的。 + +卡若 01:18:16 +因为这个是通过百度的那个巨峰算法去做 SEO 排名的,那你当他吸收这个能力就可以了,他自己。过一下这个过程就知道了。 + +卡若 01:18:44 +连志刚刚发的吗?发啥?我刚发飞书,发啥?你看。你说这个机器人。两个项目核心能力的 schema 并归属 to b,它就属于这里,我就很它就分配给一个人去了,它。 + +许永平 01:18:59 +他就分配给一个人去。 + +卡若 01:19:02 +自己知道谁来做这个事情最合适,看到没有? + +许永平 01:19:02 +他自己知道谁来做这个事情。 + +卡若 01:19:08 +在这。嗯,那你就知道他为什么分配给他,我都不管流量自动化,看到没有?你看看这个人干嘛?他自己去招了个人来干这个事,知道吗?那你这个人是通过他的性格来定义的,知道吗?你看引流滋养它记忆联想性格,这爱表现的是吧? + +许永平 01:19:45 +对。 + +卡若 01:19:49 +你看手机和网页自动操作,你看这个是我之前做那个网站排名的和那个淘宝排名的,十几年前的东西了。 + +许永平 01:20:01 +他们还有另外做法,就是定义一种名正。 + +卡若 01:20:03 +你看。还有另外一种做法,就是定义一种名人的。名人那个很容易,你把他名人的能力吸收掉就行了。 + +许永平 01:20:08 +但那个对,就是比如说什么雷军,对啊,就是你还得去提炼他的过往,可能他写的一些书什么的,让他去清洗,提炼出他的能力,其实就是定义他的能力。 + +卡若 01:20:12 +就是比如说什么雷军这种乔布斯啊。那个不完善,你首先得有他们的库。对啊,你还得去体验他的库嘛。那他写的一些书,或者就是你们的能力,把他定义完之后,他知道你的能力边界他自己会去吸收。就是定义他的。知道,反正我。我给你们分享一下这个的一些新的一些用法,它就这里边它就是 5 个人去招募了,现在有 17 个人, 17 个人每个人解决一个问题,是吧? + +许永平 01:20:35 +一些新的。这里面招募了 17 个人,一个人、两个人。 + +卡若 01:20:45 +然后我能做什么?你看自动化操作网页刷流量,什么什么什么什么,因为这个我已经实现了,我根本就不用去管它,因为我知道它实现逻辑跟问题,然后你看我还可以干嘛呢?用那个卡若 AI 的整个的团队来分析一下这个skill。帮我提一些优化的建议,然后最后形成一个PK,看谁的建议最好。你看整个团队去优化它。他这个层级应该最底下是 CEO 人力,然后在上面一层就是工作流,在上面一层就是属于这种数字员工。就是这个就会变成什么,你知道吗? + +许永平 01:21:28 +这种场景。 + +卡若 01:21:30 +就是他。他是把你的能力,这么多年沉淀的能力做拆解的,并且形成一个记忆的一个形式,然后分配给执行的人,而且不会出错,你能力拆得越细就越不会出错,知道吧。 + +许永平 01:21:32 +然后。 + +卡若 01:21:50 +所以怎样去把这一些,包括那个视频剪辑切片的一些能力,你多方的去验证它有商业知道有开发、有商业、有流程,对吧?有。有一些 7 的, 8 的,你用久了之后,这一块的话,它是就会给你一个很完善的一个东西,就等于十几个专家,那这个专家你觉得只要你一定要验证过,不要让他吸收垃圾就晕了,就会变成。 + +许永平 01:22:12 +是。好的。 + +卡若 01:22:21 +越来越垃圾。 + +许永平 01:22:21 +也有遇到。 + +卡若 01:22:22 +也不会变成越来越垃圾。他会性格会变成什么?变成 enfj 啥都学,你这性格会变的,你会发现谁变成 enfj 了,然后他的。这个岗位又不错了,那肯定这个吸收了很多垃圾了,知道吧? + +许永平 01:22:32 +到了这个岗位。 + +卡若 01:22:36 +为什么定义性格知道吗?它会变的。那你看吧,它这一些我就给你们过一下它是怎么样去实现的讨论的,包括你那个这些智能提问什么的,它都自己帮你跑完了。知道,那我等一下给你们讲本地模型怎么用嘛。不是跑本地的吗? + +许永平 01:23:01 +这是靠本地包。 + +卡若 01:23:03 +他一部分跑本地的,所以我消耗很低的。你别以为这个消耗很多,我消耗很低的,我等一下给你们看。为什么?你看他就研讨会,你看他参与着 ABCDE 会议开场大总管开始,他就开始汇报。 + +许永平 01:23:19 +可以。 + +卡若 01:23:27 +之前我也想过,我等拉个讨论群,先把目标丢进去AI。大家先自己去讨论一遍每个人。你要你这个要把你的团队变厉害,知道吧?你看他就,嗯,你看他提的很多的建议,是不是每一个人有每一个人的观点?模拟现实我们开会的那种场景。 + +许永平 01:23:50 +模拟现实我们开会的那种场景。 + +卡若 01:23:52 +是不是?而且他很快,那看是不是?多给执行。 + +许永平 01:24:03 +用本地跑的吗? + +卡若 01:24:03 +本地跑的吗?这个。来,我给你们看一下本地的这一些东,我就给你们多分享一下这些东西,大家。刚才不是调 c 了吗? + +许永平 01:24:09 +刚才不是掉 c 了吗? + +卡若 01:24:10 +用cursor。 + +许永平 01:24:10 +不是用 cursor 吗? + +卡若 01:24:11 +我用cursor,我当然有更好的解决方案,我给你。 + +许永平 01:24:15 +这是用 cursor 跑出来的呀。 + +卡若 01:24:15 +用 CURSOR 跑出来的呀。才不是呢,一部分 cursor 而已,给你看这个,这个应该是本地的模型,我看一下,不在这,我其实都不关注它在哪里。 + +许永平 01:24:18 +cursor 你看。 + +卡若 01:24:33 +不需要关注它在哪里?我看一下这个放在哪里。有一个盆,应该是在那个这里。 + +卡若 01:24:54 +看一下小程序飞书管理。 + +卡若 01:25:05 +那个本地模型的在哪?来我,你打开。那边有搜索吗?第2个有。 + +许永平 01:25:12 +要做。 + +卡若 01:25:14 +本地。 + +卡若 01:25:24 +卡火。这在卡火里面看一下。因为我现在就不关注的这个跟团队成长是一样的,当你到团队到 20 个人的时候,基本没空去看,只要记住他名字跟能力和他的那个循环就可以了,你知道吗?这个是啊,在这还没有本地模型,给你们看一下你就知道咋用了。你看这个本地模型管理,我本地有三个模型的,但是它我不会,是,它自己会去启动。是提醒当卡若 AI 使用本地模型时自动使用提醒,是吧?它有三个,一个叫轻量,我定义了两个东西,这个是千问的。轻量是来解决文本摘要的问题的,它只处理,而且。 CP 会控制在30%,它不会控制太多,所以它不会,我怎么用都不会卡。那这个提醒,这个共享模块是任何的 skill 都可以调用的,等一下给你们看共享模块嘛。 + +许永平 01:26:45 +这共享的模块是一样的,都可以。 + +卡若 01:26:54 +那这些就是一些基础的一些参数,在 cursor 上,你看。现在是用了这个隧道,不然你启动不了。 CURSOR 是可以直接调的,就是他需要做文本向量化跟简单的文本的总结的时候,他就会调本地模型,他不会调那个 cursor 的东西的,大概给你们过一下,所以我你看这三个是。是都有用途的轻量对话,一个中等对话,还有一个文本向量化,三个不一样的模型,干三个不一样的事情,他自己会去使用和调用这个东西,这他需要做简单的动作的时候,他就会去找这个事情,那这些就调用的形式就不看了,后面这些是调用的形式嘛。然后它跟你看它的性能对比,这里面有个轻量的,这两个是千问的差,有差多少你自己看一下,就差它只有 20% 的那个 Claude 的 4.5 的 20 的能力,那它只有它 35% 的能力, sonnet 是那个 Opus 的那个85%,你就做能力对比,它自己会去猜嘛? + +许永平 01:28:10 +他有他的。 + +卡若 01:28:32 +然后这个是免费的嘛。就这一个,你看这个差 5 倍, Sonnet 跟 Claude 的价格是差 5 倍的,跟 o 那个 Obeus 两个,是吧?那肯定本地的不上传云端,它有一些好的一个地方,它读取文档秒级的咔一下就读完了,是吧?根本就不用去搞来搞去很麻烦,所以有一些向量化的东西,为什么我那个读。 + +许永平 01:28:56 +用例,对,好。 + +卡若 01:29:02 +他们读很多东西会很快就这样嘛?那他自己这个 schema 他读完之后他就自己会去做了,应该简单代码就跑到这里了,就是简单问答,就他们来高质量需求的时候,就他来复杂代码他来,那他会根据你的链路去拆解嘛? + +许永平 01:29:15 +来。好的。完了。我。好的。 + +卡若 01:29:24 +你看这个基本就是只能简单问答就优先他,因为都差不多就不会用这个了,对吧? + +许永平 01:29:25 +不客气。 + +卡若 01:29:33 +然后一些多轮的,就你复杂推理,当你说了很多东西,他拆了很多的任务的时候,他就会用,他这是他们自己那个,那像这个批量处理的,就本地跑的,他就用最轻量的,这个都不用钱,这个就是跑跑本地机器,那离线也能用啊。所以我为什么有些时候坐在车上我就自己跑这个了,对吧? + +许永平 01:29:55 +所以我为什么这希望? + +卡若 01:30:00 +去做一些总结文档跟文档。同理的事情,你车上就搞定了,不用管它上不上网的问题。对。 + +许永平 01:30:07 +是。 + +卡若 01:30:07 +对吧?它离线也可以跑,这个就离线了,而且这个我不需要,我就我不需要切换了,我就是正常用 cloud 就可以了,它自己会去调嘛。响应时间也很快,然后它怎么这个是等。等于他有了这个调用的能力。好,那这一步的话是融合各个的 skill 怎么样去调,对吧?使用场景a、b、c、d,就是他告诉他,你可以这几个人告诉他们什么场景,比如会议摘要,他就调的是这个,所以刚刚看的那个会议摘要为什么丑呢?你没定义清楚,他就丑,因为他用的是基础的小模型在跑,知道那文字。清洗也是他可能用的,你如果你定义成他用那个归零的那个就很漂亮,对吧? + +许永平 01:31:08 +对。 + +卡若 01:31:10 +不然他就给你做那个总结文档卡一下子,是吧?那需求拆解这一些也可以,一些小的拆解需求也可以的总结拆解,是吧?他就会做这一些事情,那这个是他怎么调?你就告他自己会告诉那个 AI 怎么样去调嘛?那这个就是两个,那这个是他这个是吸收了别人用这个是最佳的一个实现的一个形式,长文生成跟一些别人用小模型跑出来的一些策略,你把它吸收掉就好了,所以他已经吸收了一些能力,包括这一些,然后核心的一点,是吧?你看结构化输出等等。 + +卡若 01:32:02 +所以有一些东西他也能做得很好,就是别人已经把做得很好的那些方式已经做好了,所以我也有很多,包括读书笔记 7 的、 8 的这种,他其实对我来说不用钱的,我跑很多是不用钱的。对吧?你这样包括这个向量检索速度非常快,他本地跑比你慢,慢传,再让他服务器解析,再给你回过来,这差很多的。对吧?像这种一些内容,然后异步这个处理多个请求,因为你包括那个cursor,它也是流水式的,很慢的,它这个可以同时 10 个线程做 10 个不一样的事情,做完任务拆解成 10 个人同时在做,它速效率就很高了,它这个等于它是一个团队在。 + +许永平 01:32:35 +对。 + +许永平 01:32:45 +那。 + +卡若 01:33:02 +在做一件事情,你在,我们在 cursor 上面用它其实还是一个人,虽然多线程,它多线程处理的是不同任务,它这个的话是一个人先把任务拆解完之后一个人把一个团队把这些拆解完的任务全部完成,它有这个好处,就你用了才知道。 + +许永平 01:33:21 +这个呢。 + +卡若 01:33:23 +像这种,你看它怎么用融合点,怎么去用这些steer,它其实都有调用的,那这个是一些更新的嘛?你看对。这个是他会更新汇报变更,你看添加流式响应工具,调用 1 月 28 号的,你看。 + +许永平 01:33:34 +对不起啊。 + +卡若 01:33:43 +就一些融合的一个形式,你看这个 cursor 就集成了通过这个隧道的技术就集成了 cursor 就能用,不然你直接本地 cursor 是不给你改的,改不进去的,但是他能直接那个嘛。 + +许永平 01:33:55 +person。person。我给你改。 + +卡若 01:34:05 +然后你看他就把这个融合到现在有 34 个skeleton,对吧? + +许永平 01:34:09 +lesson, we are 在这里的。 + +卡若 01:34:11 +那我以后的以后我已经让他做了一个方式了,就是像以后生成 skeleton 的时候,他都会调用这个,这里又有个共享库,是吧?这个是共享模块,他是调用模型的共享模块刚刚只是模型。真的这个的定义,那这个是属于共享模块,是吧?你看谁在管理?你看这个是谁在做这个事情?所以他会找这个人要这个能力,我要调模型,他逻辑是这样的,我要调这个模型,然后开始去找ABCD,你在做什么?什么什么事情,然后开始把这个做什么什么事情的相似。 + +卡若 01:35:02 +东西快速地去找相应的模型,然后对应进去,然后更新,对吧?这个是他共享的库,去就会调用这个本地模型,就你在对话的,用这个 AI 在实现对话的过程当中,什么时候调什么来解决这个问题,对吧?这一个是一些那个使用的一些方式,那经验库就不说了,你们之前做过。现在做的整组的日志汇报,你看他做了什么,每天都会记录的,这个是记忆的功能,知道这个等于一个小公司,你知道,你看他做了啥嘛? + +许永平 01:35:44 +是。对。 + +许永平 01:35:52 +那谁对他今天。 + +卡若 01:35:53 +霍翠, 1 月 29 号,对吧?内容代码修复、迁移,他今天就做了一个事情。没了锤炼代码,他是负责整个一个目录的那个技能的迁移,他来负责这个事情嘛。那至于这个他的一个能力就是放在这里面的能力,就是 schema 这个只是他的日志而已,就相当于他的工作日志,你看这个也是一个技能目录迁移,因为今天他们只做了迁移的事情,这个今天才建完。所以他在执行每一个步骤操作的时候,这个是属于记忆功能。那像这种的话,它只是一个组织架构,是吧?这属于日志记系统,哪一个人执行的,他就自己去定义,然后汇报的格式,这个跟咱们现在做的事情是一样的,只是。 + +许永平 01:36:53 +这个东西。 + +卡若 01:37:02 +把他的自己的能力拆细了,你看一些自动触发,当我执行这个操作,他就会自动地记录到这个日志里面。由谁来记?自动记录这个日志,那像我们在做,你看视频切片,就你看这个木叶火影忍者切片的叉叉视频,他自己会去记录,那我们在看他整个的规划的当中,包括我们自己在做。那个记忆的过程当中就会比较清晰,什么东西做了什么嘛?这是他们自己记录的一些事情,而且他这个文档相对会简洁很多,好吧? + +许永平 01:37:42 +周三自己这些,他这种。 + +卡若 01:37:50 +这个是一个日志,就是像这种就搭建的时候,你市面上你找不到这种东西,这个核心的一点,你就是把自己的能力抽象以及。 + +许永平 01:37:51 +这个是他是搭建的时候,你市面上找不到这个核心的一点,我想。 + +卡若 01:38:02 +那个让 AI 自动地去帮你去多探讨嘛,多聊多探讨嘛,是吧? + +许永平 01:38:03 +那个。他可以看。 + +卡若 01:38:09 +那你看它这个就执行的一些东西,应该把这个 PK 的结论,你看优先级最高的优化,合理合规的潜质跟选择表,等它一整个团队的能力去帮助了这一个新出生的skill,完善了它的新的一个 skill 差吧。那这个 seal 出来就很强了,首先是一整个团队吸收了整个市场最优的东西,然后他们来优化,这个时候你再把他们让他去帮你做一些事情,就非常厉害。另外是不是流量自动化?诶,现在那个,嗯,高数 GL 那个本地能跑吗? + +许永平 01:38:55 +诶,你现在那个 autoglm 那个本地能跑,还是这个是云端的? + +卡若 01:39:01 +还是这个?是有一个。本地当然。能跑,它,就是它这个就是用 ADB 去控制手机。 + +许永平 01:39:04 +现在有了,那这个不是说安装很麻烦吗? + +卡若 01:39:09 +这个不是说安装很麻烦吗?包方法现在可支持了。 + +许永平 01:39:13 +现在可支持了。 + +卡若 01:39:14 +不麻烦,不麻烦,它就是个命令行而已,就像我经常控制里面那个大屏的那个,就用这,也不用这个,用 ADB 就可以了,它这个只是封装的,就封装了很多的功能在里面,没啥神奇的,知道吗?不神奇,然后你看它这个就是。可以实现,我以前的那个 PC 百度、淘宝去刷量,它是按时间节点阶段,然后按照百度的一个飓风算法的算,去匹配它的飓风算法,并且实时更新它飓风算法去匹配按时间节点阶段,然后安排它引百度的蜘蛛去,所以我当时为什么排名那么好做?其实背后有2万个机器人在跑。对吧?所以很多东西就能做了,那之前用去check,你看那去。 + +许永平 01:40:01 +下。 + +卡若 01:40:02 +APP 和 ie Windows 自动化操作嘛。 + +许永平 01:40:04 +我上次有下那个autogenml,然后但是跑不起来。 + +卡若 01:40:04 +上次有下那个 auto js 的,然后它是跑不起来。你把先把它抽象成自己的就能跑,你不要用它的跑,很麻烦。你把它吸收成自己的东西,你就自己知道它逻辑了。当当这一个团队都是从你抽象出来的时候,当他们写出来的东西你是很清楚的。所以不用去往上,不用去摘抄他们的,如果你不理解的情况下。 + +许永平 01:40:31 +我是把那个。模型下起来,跑不起来。 + +卡若 01:40:33 +对,你如果不理解它逻辑,摘下来是没有用的,我从来不会去看任何一个别人写的这个东西,我就拿过来拆解一下,直接让我就团队的人相当于这个就是一个团队去吸收一下,我就立即知道了。 + +许永平 01:40:44 +对。 + +卡若 01:40:48 +就一个人解释不清楚,那你们十七个人自己去 PK 一下,哪一个说的清楚?是不是它慢慢就会形成这个一个东西了?你看这个就是之前设备。重置 VPN 切换,是吧?刷量,对吧? + +许永平 01:41:06 +对。 + +卡若 01:41:08 +那这个它基本这个能力就很清晰了,你看安卓多模态,你想一下这个,这个这一个东西 12 年做的,现在还能用的,你这个很早就有了,知道吗?让百度、淘宝刷量, ie 自动化之前就自动控制浏览器去模拟真人去。访问。自动去切换那个电脑的那个虚拟机。 + +许永平 01:41:35 +接完了电脑。 + +卡若 01:41:39 +自动去访问、自动付款刷单。 + +许永平 01:41:39 +知道了。 + +卡若 01:41:44 +那它这个我就主要是这个逻辑,给你们讲一下这个逻辑,其它这些东西,它不是什么很厉害的东西,就是经验而已。是吧?但这个就那个ADB,就是控制这个手机端的,我们现在用的这一个也是用。用那个 ADB 封装的那个那SDK,你看它,其实你看做网页刷自动化,它这个因为我之前是用 Windows 的,它自己会去翻译成 Mac 的手机的事情,所以我根本就不担心它。 + +许永平 01:42:23 +外。 + +卡若 01:42:27 +不是,我只是随便拿一个能力去抽象一下,那这一个更好。那屏幕感知,那我现在不是装了虚拟机的,是吧?然后它的一些代码交互形式,这一看你就很知道,你看打开什么,什么什么。 + +卡若 01:42:54 +他就是刷一些流量嘛。刷流量就是一直访问这样。 + +许永平 01:42:58 +刷流量就是一直访问这样。 + +卡若 01:43:00 +模拟真人去访问,里面有。 + +许永平 01:43:00 +模拟真人去访问。 + +卡若 01:43:02 +很多算法在里面,但我已经实现过,我就不关注算法了,你看嘛,这百度APP,你看它自己打开,自己浏览,以前是模拟按键去访问,然后把时间定好,大概多久多少范围内一个个去解决。 + +许永平 01:43:03 +算法,不管是算法啊。看这百度,看他自己模拟按键去,然后他自己。 + +卡若 01:43:20 +现在让 AI 自己搞定就行了,你不用那么麻烦。那你看百度搜索刷量嘛,你看以前多简单,关键字加翻页,点击流量自动化,那里面。边有一些算法我是知道的,你是这个不一样吗? + +许永平 01:43:33 +他。 + +卡若 01:43:38 +商品浏览要停留多久? + +许永平 01:43:39 +对。 + +卡若 01:43:39 +要看看别人的,再看看自己,对吧?这些都是一些细节,一些事情,那这个就要伪装嘛?你的设备就不断地去那个reset,那个 CPU 跟 reset VPN,对吧?那现在也一样,你可以虚拟个 Mac 或者那个Windows,也可以,它通用。它是等于通用了自己长出来的,就像也做这个调一下,可能三天、两天就调完了,它就能跑了嘛。那以前写这个得 8 个月一年,对吧?多多麻烦,现在两天搞定了。那你看它这个就有一些命令参考是给 AI 看的,不是给我看的,因为我知道已经实现了。知道吧。那你看负责流量自动化招商运营口头禅流量来了,你看。我到时候我要提一个东西,我要做这个网站的 SEO 或者Geo,对吧? + +许永平 01:44:34 +DOC 对。 + +卡若 01:44:39 +他是不是自己会帮我去执行这方面东西? + +许永平 01:44:40 +他是不是自己在帮我们? + +卡若 01:44:42 +我就在 doc 上面铺两个虚拟机,他自己去给我建。自己去刷流量,自己给我灌流量,我还搞什么 Geo 的网站,麻烦,是不是?我就再没有,我就视频上什么 Geo 的源码,搞几个让他吸收再执行一下,是吧?就是现在很多为什么开源,你不开源没有用,更多的是我们把这些能力变成现实的生产力,能产出的生产力这才有用嘛。 + +许永平 01:45:03 +就是现在很多为什么开也不开,也没有用,更多的是我们把这些能力变成现实的生产力,产出的生产力,这这这个整个就这样。 + +卡若 01:45:15 +那这个你看它就整个就这样嘛,对吧?那就完成了嘛,是吧? + +许永平 01:45:20 +完成了,那我这个我肯定让他,我当时搞天猫店, 1, 500 万个。 + +卡若 01:45:22 +那我这个我肯定知道他执行是什么样的,因为已经执行很多年了,之前我当时搞天猫店,一天5万个访客,就这么搞来的,知道其实大的。到质检知道就2万客,虚拟的人天天给你看这淘宝,天天都觉得我的是最火的。 + +许永平 01:45:32 +大道至简,2万块钱的,推荐你看淘宝,天天都觉得我的是最。 + +卡若 01:45:40 +对。 + +许永平 01:45:40 +是。 + +卡若 01:45:41 +知道, 13 年到 16 年特别好用,到 16 年底特别好用,后面就增加刷单就行了,就需要有人,你看像这个是整个的一个搭建的一个逻辑,我其实就做了两步,一个吸收,一个让现有的团队去评估并且去完善它,对吧? + +许永平 01:45:42 +30 ~ 16 年特别好用。 + +许永平 01:45:55 +及时复盘。谢谢。 + +卡若 01:46:03 +那他就有很多的记更改嘛?谁谁谁,你看谁建得最好,你看他 PK 了,我把这个隐藏,你就看他的结果就行了嘛。刚刚那个是过程,那个一般你熟悉是不用看的,点不了不重要,你看关注点环境风控结构清晰好找,能跑好抄,边界清可以。扩展合规,他把你几个的点都给你解决掉了,就是你关注的一些点。对吧? + +卡若 01:46:50 +那你看谁建立的最好吗?合规红线,对吧?他会防执行时。失败,各种他帮你考虑的很周到,就各个能考虑到的角度都会帮你考虑到,懂吗?他给你建了一个一键检查的示例指令,怕他们自己读不懂,对吧?这个就是有确定一些东西长期维护就是他,对吧?自己会去PK,然后就那个嘛。你看增加何时用SKIA,何时用流量自动化表格,对吧? + +许永平 01:47:43 +价。 + +卡若 01:47:46 +他这个给你的一整个结论就这样,环境清单嘛?这个我们怎么像远志碰到这个问题,就是有个环境检查清单,他你是 Windows 还是Mac?我提前检查了一下,优化完之后他会就会先看这个 Windows 什么的,他该装什么? + +许永平 01:48:00 +他会做一些。 + +卡若 01:48:02 +然后给你一个优化建议,然后你选就行,就不会出现跑一天的问题,就这个行动项继续迭代,对吧? + +许永平 01:48:06 +对。 + +卡若 01:48:16 +一键检查就把上面的大家考虑到的东西检查,然后他后面的话他就积累经验了,就是你做的一定量的时候就积累经验,积累经验就让他每天吸收就行,你有做。 + +许永平 01:48:24 +一起工作。 + +卡若 01:48:32 +做越多,他吸收越多,基本就不会犯错了。 + +许永平 01:48:32 +合作我觉得大家吸收也。 + +卡若 01:48:36 +那你尽量经验库不断的去积累嘛,我这他已经有转化的记忆机制,你看有一些东西他就需要这个事情,然后他们开会研讨的,开会的越开就越屌,开越多越屌,是吧?所以他就自己会去增长。只是我现在没加一个事情,是什么?就是。是那个自动跟他聊天之后让他自动去工作的自动化定时登录,相当于,对吧? + +许永平 01:49:04 +那个自动那个。 + +卡若 01:49:13 +就是那个我微信给他发条指令,这一些人干什么事情我是清楚的,你用一些让他像豆包手机的这种,他一直循环是因为他的能力都没有验证过,就是给你一个通版,然后让他理解这个行。行为规范,你给他什么东西,他们能做什么事情都不知道的,是吧? + +许永平 01:49:36 +大游戏。 + +卡若 01:49:37 +他们要细化,那这个本质上是拆解能力细化,并且这些能力是之前你实现过的,那他就你就会越越用越越顺,越用越顺。知道,就像老王这个,你看分销的、分账的,对吧?能力是不是快速让他吸收一下?是不是就像我这个,这一个现在这么多的切片的团队,他们去做分销的?的过程当中,我们这个分销方案是如果能快速的裂变,让别人愿意去分发,每天去坚持分发,这个也是很好的分销方案了,我就直接把它吸收过去,它应该就会分配给卡火的某一个人身上。 + +许永平 01:50:16 +对的,那以后我要做的是。 + +卡若 01:50:18 +那以后我要做分销的时候,我就加上分销的功能,它是不是按照这个那个一级绑定 30 天的方式去给我生产出分销的功能出来?我根本就不用想,因为。 + +许永平 01:50:31 +我们。 + +卡若 01:50:32 +我做过,对吧?这个是很重要的一一个一个点,就咱们在做这些的过程当中,其实现在 AI 就是吸收,就两个字,就是吸收,你把它当成一个人一个团队,由一个人拆解成一个一个团队,反正我都有录屏,你们可以照这个去说嘛?组建成团队去说,他无非一个主管,底下团队成员的性格匹配主管的性格。他去招人,是他按照他去生产一个人,不是招人生产一个人,是按照他的性格喜好来和配合度来招的,知道吗?你看这个跟老王是一个性格的,知道吗?他去找的这几个什么金仓、金盾、金建,什么金链,这。 + +许永平 01:51:29 +来。 + +卡若 01:51:32 +这几个人的性格是跟他搭配起来舒服的,你知道。你这些人除了说 cursor 自己生成的。肯定不是 cursor 自己生成,是因为我很知道这些 MBTI 的这些我学了好久的。知道,所以他找什么样的人配合舒服我是知道的,所以他在做的时候,过程当中会出现一个问题,你吸收的技能很多、很杂、很乱这一个。 + +许永平 01:51:50 +知道,所以他的账号。 + +卡若 01:52:03 +卡兹就可以把这四个人做一个技能的调整和分配,他知道谁来做这个事情更合适。你还整理啥目录啊?他帮你都整理好了,他以人为单位去帮你整理好了,是不存在这一些事情的,所以他这个是属于自己的一个 AI 的一些搭建,你看他现在就有很多能力,我用大模型我根本就消耗,我买一个我可以用半个月,我用那OP。 + +许永平 01:52:29 +呃。这个东西。 + +卡若 01:52:32 +EA 是最高级的,我至少用 10 天,每天问,知道他不会对我来说消耗只有原来 1/ 10。知道,所以我可以很是那个随便去用。那我不用高级的版本,我用这个他也一样,他该消耗不消耗他就调本机的模型,本机的模型我也不用担心了,他就最多用我 30% 的性能,对吧?他不会超过 30% 的性能。有个千问后边。 + +许永平 01:53:02 +有的,签过的。 + +卡若 01:53:04 +清华问题能力还可以。千问还行,是吧?所以它这个是一个降本增效的一个体系搭建,那回过头来我们现在做的很多的东西,它这个只是提效的原因是什么?像远志这个我说一个具体的一个一个事情,你视频剪辑出来是不是要快速地复制,对吧?我们就剪一些视频,把之前几年的什么存客宝视频全部丢出去。全部剪,让它自动发,是不是一个 AI 的库就出来了? + +许永平 01:53:35 +有。 + +卡若 01:53:37 +你只要做视频的筛选和整理,然后一键分发到抖音上面去引流,获客就出来了,是吧? + +许永平 01:53:46 +是。 + +卡若 01:53:47 +所以这一个就你就核心的目标就是它能第一个能跑嘛?能跑,跑完之后的话就是它有一个多久的时间嘛?你现在 5 分钟,是不是第一个闭环跑出来? 5 分钟剪一个。一个两小时的视频,是不是?那你就相当于一台机器 60 分钟,你把它满功率 60 分钟,是不是 12 乘以两个小时, 24 小时,一天的视频一小时就可以剪 24 小时的视频,一台主机是可以量化掉的。对吧?那你 24 小时的视频,你一个视频平均 3 分钟, 24 小一小时的视频差不多有两个主题,那你 24 小时是不是剪 48 个视频? + +许永平 01:54:24 +这。 + +卡若 01:54:32 +视频一小时剪 48 个视频是不是能算得出来?那你一天工作 24 个小时,算 50 个,算 20 个小时,一天 1, 000 个视频剪辑一台机器,那是什么概念,对吧? + +许永平 01:54:42 +一块。 + +卡若 01:54:46 +你 1, 000 个,那海宁集团剪 1, 000 个视频得一百二十几个人了,是不是一个人就干完了?那后边就解决素材的问题,素材就是你看我,我为什么去丢链接这个给你们看这个丢链。链接的这一个过程是干嘛呢? + +许永平 01:55:04 +干嘛就直接告诉他这个链路? + +卡若 01:55:05 +我们有录了很多视频,你就直接告诉他,你去,你这个链路你还没跑嘛? + +许永平 01:55:12 +你去把。 + +卡若 01:55:12 +你去把飞书上这几年所有的关于产研的几个关键字,什么什么的视频全部给我下载下来,自动地去剪,你需要一个个去下吗?但这个跑起来会有很多卡点的,所以我没有先去说,先让你跑一个最简洁的,不然你东卡一下,西卡一下,就没信心了。知道会有很多卡点的。知道吗? + +许永平 01:55:35 +知道吧。 + +卡若 01:55:35 +对。那你这些会议是不是快速整理出来,大家就有很多一些分享的一些东西,而碰到一些问题,你可能就剪完之后就是 50 个视频里面挑个 30 个, 20 个是吧?里面去筛选一下, 30 个, 20 个聊一些核心话题的,跟我们进度相关的内容的东西。对吧?那你再到时候做那些什么会议纪要,也好,做那个视频和解说方面。 + +许永平 01:56:01 +要试。 + +卡若 01:56:02 +的东西就快很多了。那么所以这个是那个工作方法的一些点,是吧?那你剪这个剪完之后,为什么我还那个?今天还说那个剪完之后是不是你搞一个专门的一个飞书群或者微信群,你剪完的视频是不是自动的丢到这个群里面去啊?这些都是自动化的一些事情,因为还这个你要商用就也很快。 + +许永平 01:56:29 +这个要上 6 五点。 + +卡若 01:56:33 +是吧? + +许永平 01:56:33 +好吧。 + +卡若 01:56:34 +去做商用的一些事情也会比较快,那我就大概给你们讲一下这个这一些逻辑,然后再稍微再补一个,那个付款那个还没搞定。 + +许永平 01:56:45 +再找一个。 + +卡若 01:56:49 +付款扫码的那个,你们这个得排期排出去,排得排过去,因为这个我给你看一下,就这些远志到。 + +许永平 01:56:51 +对。 + +卡若 01:57:02 +说要排一下时间,就是我们这个也有一个阶段性的,那个我这两天不是去吃烧烤嘛?那你给你们看一下有一个场景,就是我,我们现在没有那个付款场景,所以这一个这些这种客户就拿不到了,知道吧? + +许永平 01:57:21 +不要投。 + +卡若 01:57:36 +看一下,这个是付款场景,用人看这个是我拍的一个视频,才 67 的播放量。 + +许永平 01:57:37 +不还行。 + +许永平 01:57:45 +不方便。 + +卡若 01:57:48 +嗯,我看一下有没有声音,都切本机。 + +卡若 01:58:00 +我这边。 + +许永平 01:58:01 +这边来看一下,是。有声。 + +卡若 01:58:05 +那没关系诶,等一下,我应该点一下。不重要。今天和我老婆在金连龙这边附近新开的这一家店,过来吃,这个味道非常。反正就是烧烤。经常员工聚会来这里,然后这里的话刚好就在抓到的那个老板,我觉得他们从公司楼下生意现在会这样,然后感受感触一下。不利于咱们做的是电商 8 家门店,今天上海有 8 家门店。我就跟他讲做私域的事情,但是这个要付款码,要门店的,要付款码行业这个数据交互,付款码获客就会大大提升的。是吧?然后这个的话,你看我写这个视频,这金玲珑的老板就过来了,早上发了一堆东西,加了我微信,你看这。 + +卡若 01:59:02 +金龙的老板,一个小女生,东北的,但我得拿得出手东西呀。那你看她在广州上实习课,然后早上一点多还睡不着,给我微信发了一堆消息,我五点多给她回,五点多还在,还没睡觉。知道,等她来厦门就约她,那她就需要我们这一个解决方案,因为她现在开店。是很快的,他短短半年开了 8 家了,因这家是的确是做得很好。是吧?但这种,但我们现在付款的这一个我没办法给他演示,你懂吗?是不是?我说是这么说,我就照着他的那个,你看刘思雨,我照着他的桌子上面,我说你可以用这个扫码付款,能加到微信,是不是?这属于连锁门店的一些合作的一些东西嘛。 + +卡若 02:00:08 +所以为什么我们在那个各个的一些层面,包括那些东西上面嘛?是吧?其他的不说太多了,是吧?这个就是我们那个,因为我现在不知道一点是什么扫码的进度,我不知道啥时候用,我要跟他聊,你看他明天后天就过来跟来公司,我。拿给他看,我没有东西给他看,我只能给他看视频,所以我能扫码扫一下他的小程序,跟我们对接一下。 + +卡若 02:00:40 +那这个就很好的一个东西,知道他开门店,他要不要缺钱?找金融公司要不要贷款做数据登记?要不要去做数据登记?补贴 10 万块,我们一人一半。对吧?有很多的事情可以做的,他私域也可以给我们做啊。扫码付款给团队跟上。对。先进我们这,再进,转到他公用的客户头。就是我们先有个实现的一个扫码付款加微信。就行了,是不是?那这个得你至少有要准备的一些东西,但这个是另外一回事的。快速地让每一个付款码小程序,然后把生成绑定了自己的APP,然后去加。那就放到存客宝那个上面也可以。对呀。对吧?就有这么一个功能,至少能给他看,能放到那边给他看吧。测试的。很多人过来,包括陈国过来演示,他也演示不了,是不是他每天那么多要合作的,对吧?我们一家那边放两个手机,对吧?一家那两个手机弄一个,或者是不是自己家自己动,这个体验感是不一样的。然后中台一个电脑屏幕放那边也可以。 + +卡若 02:02:02 +可以,人家一看诶,或者放我们那边都可以,是不是他就有场景化的东西?因为我每天输出太多,我是怕你们会乱,知道吗?所以这个就为什么要去搞搞这些视频跟整理,不然很容易就很容易乱的,是吧?但这个 AI 的确是很高效的哦。对。那就明天那个出的永平再过一下吧。好,我明天肯定是要让他们用的,不然他们每天我都不好说了。好。是吧?没事,就这样吧,那衍子那个剪出来视频就丢群里,很丑。效果不好。你就跟他讲要加字幕,多加一个,因为他有两个版本。 1 个不加字幕,一个加字幕。因为我做的 skill 我就比较知道,所以为什么我只能提供思路给你们,你们要自己做,自己说才说。 + +许永平 02:03:13 +差点忘了。想问你那个,你是哪?你是用哪个去生成那个微信小程序的?我看到目前市场上有三个框架,你那边是用哪个? + +卡若 02:03:23 +我没有任何的东西,我就是告诉他把 H5 变成微信小程序,没了一句话。 + +许永平 02:03:23 +我没有的,我就是告诉他把那些。 + +卡若 02:03:28 +上次你跑的时候,他底下是有一个命令的。 + +许永平 02:03:29 +上次你跑的时候,他底下是有一个命令的,我不。不知道你是用。 + +卡若 02:03:32 +没有命令我就告诉他你用 H5 的这个前端给我变成微信小程序,然后没,对,然后把界面要保持一致,跟前端的界面保持一致,然后用你那个框架,你自由去选,如果你知道框架,你就说不知道,你就框架自由去选择。 + +许永平 02:03:33 +要编辑我就告诉他,你把这个前端给我变成一起下。你直接就这样说,是吧?对,然后把界面。 + +卡若 02:03:53 +然后但是你的按钮要不要改变他有啊,项目怎么会没有呢? + +许永平 02:03:53 +难,难怪,难怪我说项目里面看不到,但是我们系统上有三个,我去把那个开发文档丢进去,他审。 + +卡若 02:03:59 +有了。 + +许永平 02:04:02 +没找到啊。 + +卡若 02:04:02 +找到啊。有,在这我就给你找。怎么会没有呢?小程序肯定有小程序的目录的,在这个等一下,这。 + +许永平 02:04:21 +对,那他是用什么技术去转成这一个小程序的? + +卡若 02:04:21 +对啊。就这个啊。他,他是用什么技术去转成这一个小程序的?他就直接翻译,自己翻译就行了。你是直接转让他转换,是吧? + +许永平 02:04:30 +你是直接转让他转换,是吗? + +卡若 02:04:32 +对,让他把 H5 的页面变成小程序,并且界面保持和所有功能保持一致啊。没了就一句话,你不用去思考它基础的问题,它转化不了,是它笨,骂它一顿。 + +许永平 02:04:38 +原来是这样,好。 + +卡若 02:04:44 +好。知道吧。今天 AI 就很笨。 + +许永平 02:04:47 +今天 KR 感觉最近都会降级,好多人都会说最近妈怎么对比你们用的也不好用。 + +卡若 02:04:50 +正。感觉最近都会降质,好多人都还说最近,我最近也用得也不好用。不好用是我跟你讲不好用,其实不是它降质的问题。是你问的问题太多,他积累很多经验,并且没有消化的经验,所以他就混乱了,他不知道你要 a 还是要b,还是要c。 + +许永平 02:05:09 +所以才会搞到这。 + +卡若 02:05:12 +因为我弄那个就有很离谱的问题,用的不是 ask 的模式,是用 agent 的模式,然后他一直回复我,让我手动去操作。 + +许永平 02:05:12 +今天我弄那个就很离谱的问题,用的是用对接的模式,然后他们说对,我们受不了。 + +卡若 02:05:23 +然后最后我受不了,我骂他一顿,我说你直接帮我改就好。对,你就说一顿,你特别是什么?你特别有一点。也是什么?他明明是 APP 模式,然后他回答你回复你说我现在是 APP 模式。 + +许永平 02:05:33 +他明明是 a 制模式,然后他回答你回复你说我现在是 b 制模式,我没办法。 + +卡若 02:05:37 +你你,你们加一句话,就是我一定要让他实现全自动化,并且不要让我任何操作的方式,那他会去解决,解决的时候他会告诉你我需要接口,我需要这个事情我做不了,需要去接口或者 API 或者那个secret。那你把这个给他,那他就实现全自动。 + +许永平 02:05:59 +因为这个是特别离谱的,第一次遇到。 + +卡若 02:05:59 +特别气人,他们只是第一次遇到。这个很正常的。 + +许永平 02:06:02 +我第一次遇到。 + +卡若 02:06:03 +我经常遇到,我就骂他。 + +许永平 02:06:05 +那一个。 + +卡若 02:06:06 +老王,那 MBTI 啥时候能上啊? + +许永平 02:06:06 +早上那一天。 + diff --git a/开发文档/10、项目管理/存客宝协作需求.md b/开发文档/10、项目管理/存客宝协作需求.md new file mode 100644 index 00000000..856cdb22 --- /dev/null +++ b/开发文档/10、项目管理/存客宝协作需求.md @@ -0,0 +1,102 @@ +# 存客宝协作需求(待发给存客宝 / 神射手团队) + +> 更新时间:2026-03-08 +> 来源:找伙伴功能开发中,需要存客宝方配合开发/开放的接口 + +--- + +## 需求一:场景获客接口回馈 — 添加好友成功率反馈 + +**状态**:待开发 + +**背景**:当前 scenarios API(`POST https://ckbapi.quwanzhi.com/v1/api/scenarios`)上报线索后只返回「新增成功 / 已存在」,无法知道该线索是否已被微信添加好友。 + +**需求**:在 scenarios 响应中新增字段,返回该线索的微信添加状态: +- `friendStatus`: `added`(已添加)/ `pending`(待添加)/ `failed`(添加失败) +- `friendAddedAt`: 添加成功时间(ISO 8601) + +--- + +## 需求二:线索查询接口 — 按手机号/微信号查询添加结果 + +**状态**:待开发 + +**背景**:后台需要查看某个匹配用户在存客宝中的状态(是否已加好友、属于哪个计划、有哪些标签等)。 + +**需求**:提供一个查询接口: +- **方式**:`GET /v1/api/lead/query` +- **参数**:`apiKey`、`sign`、`timestamp`、`phone`(或 `wechatId`) +- **返回**: + ```json + { + "code": 200, + "data": { + "phone": "138xxxx", + "wechatId": "xxx", + "friendStatus": "added", + "friendAddedAt": "2026-03-08T10:00:00+08:00", + "plan": "创业实验-资源对接", + "tags": ["资源对接", "高意向"], + "createdAt": "2026-03-07T08:00:00+08:00" + } + } + ``` + +--- + +## 需求三:批量线索统计接口 — 查询某时间段内的添加成功率 + +**状态**:待确认 + +**背景**:后台「找伙伴统计」页面需要展示一段时间内的线索上报总量、添加好友成功率等数据。 + +**需求**:提供一个统计接口: +- **方式**:`GET /v1/api/lead/stats` +- **参数**:`apiKey`、`sign`、`timestamp`、`startDate`、`endDate`、`source`(可选,按来源筛选) +- **返回**: + ```json + { + "code": 200, + "data": { + "totalLeads": 150, + "friendAdded": 120, + "friendPending": 25, + "friendFailed": 5, + "successRate": 80.0, + "byPlan": [ + { "plan": "创业实验-创业合伙", "total": 50, "added": 42 }, + { "plan": "创业实验-资源对接", "total": 40, "added": 35 } + ] + } + } + ``` + +--- + +## 需求四:匹配成功后自动加好友 + 拉群 + +**状态**:待确认 + +**背景**:用户在小程序「找伙伴」匹配成功后,希望存客宝能自动执行以下操作: +1. 如果匹配到的用户不是好友 → 自动发送好友申请 +2. 如果已是好友 → 自动拉入指定微信群 +3. 同时发送指定的欢迎消息 + +**需求**: +- 提供一个「自动加好友」API:传入 phone/wechatId,存客宝自动发起好友申请 +- 提供一个「自动拉群」API:传入 phone/wechatId + 群 ID,自动拉入微信群 +- 提供一个「发送消息」API:传入 phone/wechatId + 消息内容,自动发送消息 +- 后台需要有开关:可选择匹配后是「加好友」还是「拉群」还是「发消息」 + +**适用范围**:找伙伴、资源对接、导师预约、团队招募四个类型均需支持 + +**备注**:如果存客宝当前不支持这些自动化能力,请确认: +1. 是否有类似功能在开发计划中 +2. 是否可以通过存客宝的其他方式(如场景获客触发自动流程)间接实现 +3. 预计的开发/对接时间 + +--- + +## 发送方式 + +将本文档发给存客宝技术团队(或神射手),确认排期后更新状态。 diff --git a/开发文档/10、项目管理/小程序20260129-2.pdf b/开发文档/10、项目管理/小程序20260129-2.pdf new file mode 100644 index 00000000..c4aa9618 Binary files /dev/null and b/开发文档/10、项目管理/小程序20260129-2.pdf differ diff --git a/开发文档/10、项目管理/小程序20260129.pdf b/开发文档/10、项目管理/小程序20260129.pdf new file mode 100644 index 00000000..7e51ed02 Binary files /dev/null and b/开发文档/10、项目管理/小程序20260129.pdf differ diff --git a/开发文档/10、项目管理/运营与变更.md b/开发文档/10、项目管理/运营与变更.md index 2cd4ed5a..75e9ec67 100644 --- a/开发文档/10、项目管理/运营与变更.md +++ b/开发文档/10、项目管理/运营与变更.md @@ -144,33 +144,6 @@ VIP 接口、章节推荐逻辑、数据库依赖 --- -## 文章阅读付费规则澄清与后端修复(2026-03-08 橙子同步) - -### 业务规则(全角色必知) - -| 规则 | 说明 | -|------|------| -| **非会员专属文章** | 免费,无需登录/付费;以管理端「系统设置 → 免费章节」配置为准 | -| **VIP 会员** | 开通 VIP 后,所有文章免费阅读;`check-purchased` 按 `is_vip=1` 且 `vip_expire_date>NOW` 返回已购买 | - -### 本次修复 - -- **问题**:非会员专属文章出现付费墙,用户反馈「不是开通会员的不用付费」 -- **根因**:章节接口只返回 chapters 表 `is_free`/`price`,未合并 `system_config.free_chapters` / `chapter_config.freeChapters` 配置 -- **修复**:soul-api `internal/handler/book.go` 新增 `getFreeChapterIDs()`,在 `findChapterAndRespond`、`BookAllChapters` 返回时优先按配置覆盖 `isFree=true`、`price=0` -- **前端**:无需改动,小程序仍按章节接口返回的 `isFree`/`price` 判断 - -### 各角色注意 - -| 角色 | 注意点 | -|------|--------| -| **管理端** | 确保「系统设置 → 免费章节」配置正确,写入 `free_chapters` 或 `chapter_config.freeChapters` | -| **后端** | 部署后重启 soul-api;章节接口逻辑见 `book.go` | -| **产品** | 上述业务规则作为正式规则,验收时按此执行 | -| **小程序** | 无变更,逻辑由后端统一保证 | - ---- - # 第七部分:开发进度同步(2026-02-27 橙子) ## 三端开发进度汇报 @@ -199,80 +172,3 @@ VIP 接口、章节推荐逻辑、数据库依赖 ## 会议纪要 - 开发进度同步会议纪要:`.cursor/会议记录/2026-02-27_开发进度同步会议.md` - ---- - -# 第八部分:小程序新旧版对比与 dashboard-stats 接口新增(2026-03-10 橙子同步) - -## 背景 - -Mycontent-temp/miniprogram 为样式预览分支,miniprogram 为线上主线版本。通过批量 diff 发现新版缺失了多项功能,但有一个关键优化点值得移植。 - -## 本次变更 - -### 1. 小程序 my.js — loadDashboardStats 移植 - -- **问题**:旧版 `initUserStatus()` 用本地缓存随机时间(`Math.floor(Math.random() * 200) + 50`)和标题占位展示阅读统计,数据不准 -- **修复**:移植新版 `loadDashboardStats()` 方法,调用后端接口获取真实数据 -- **接口**:`GET /api/miniprogram/user/dashboard-stats?userId=xxx` -- **同步**:`readSectionIds` 同步到 `app.globalData` 和 Storage - -### 2. 后端 soul-api — UserDashboardStats 接口新增 - -- **路由**:`GET /api/miniprogram/user/dashboard-stats` -- **文件**:`soul-api/internal/handler/user.go`、`router/router.go` -- **数据**:readCount、totalReadMinutes(最小1分钟)、recentChapters(最近5条去重)、matchHistory、readSectionIds -- **修复点**:去重逻辑、min1分钟、DB 错误返回 500 - -### 3. 新旧版功能对比结论 - -| 功能 | 线上主线(miniprogram) | 预览版(Mycontent-temp) | -|------|-----|-----| -| 首页阅读进度卡 | ✅ 有 | ❌ 缺失 | -| 目录 VIP/增值权限 | ✅ 完整 | ❌ 简化 | -| VIP 全局状态 globalData | ✅ 同步 | ❌ 不写 | -| my.js 阅读统计 | ✅ 已迁至后端接口(本次) | ✅ 有(参考来源) | - -## 技术债 - -- 富文本渲染:两版均为纯文本(HTML 格式被剥除),建议改用 `` 组件,待确认内容格式后实施 - -## 会议纪要 - -- `.cursor/meeting/2026-03-10_小程序新旧版对比与dashboard接口新增.md` - ---- - -# 第九部分:开发团队对齐业务逻辑·以界面定需求(2026-03-11 橙子同步) - -## 背景 - -开发团队对齐业务逻辑,需求与开发文档以**实际界面**为准,避免需求与实现脱节。 - -## 本次更新 - -### 1. 新增《以界面定需求》 - -- **路径**:`开发文档/1、需求/以界面定需求.md` -- **内容**: - - **原则**:界面即需求;三端路由隔离;用户/VIP 展示以用户资料为准,不再单独存 VIP 资料列;文档同步。 - - **小程序界面清单**:首页、目录、阅读、找伙伴、我的、推广中心、设置、VIP、购买记录、提现记录、会员详情、资料展示/编辑、导师、关于、地址、搜索、协议与隐私;每页标注功能要点与主要接口(均为 `/api/miniprogram/*`)。 - - **管理端界面清单**:登录、数据概览、内容管理、用户管理、找伙伴、推广中心、订单、提现、系统设置、VIP 角色、导师与预约、支付/站点/小程序码/匹配/API 文档等;每页标注功能要点与主要接口(`/api/admin/*`、`/api/db/*`、`/api/orders` 等)。 - - **业务逻辑对齐**:用户与 VIP 资料展示规则、三端 API 边界、免费章节与 VIP 阅读、分销与提现规则;与当前实现一致,作为验收基准。 - -### 2. 开发文档与需求文档联动 - -- **开发文档/README.md**:在「需求与项目管理」下新增《以界面定需求》链接,标明为界面级需求基准。 -- **开发文档/1、需求/需求汇总.md**:开头增加「需求基准(必读)」节,明确需求以《以界面定需求》为准,新增/变更功能时先对齐界面再更新需求清单。 - -### 3. 各角色使用方式 - -| 角色 | 使用方式 | -|------|----------| -| 产品经理 | 需求与验收以《以界面定需求》界面及业务逻辑为准;需求汇总中的清单与本文档保持一致。 | -| 小程序/管理端/后端 | 开发与联调以界面清单中的「功能要点」与「主要接口」为准;业务规则以第四节为准。 | -| 测试 | 功能测试与回归以界面清单与业务逻辑对齐节为验收范围。 | - -## 变更记录 - -- 2026-03-11:初版《以界面定需求》;README、需求汇总、运营与变更同步更新。 diff --git a/开发文档/10、项目管理/项目管理提示词.md b/开发文档/10、项目管理/项目管理提示词.md new file mode 100644 index 00000000..2b627a44 --- /dev/null +++ b/开发文档/10、项目管理/项目管理提示词.md @@ -0,0 +1,58 @@ +# 项目管理提示词 (Project Management Prompt) - 智能自生长文档 + +> **提示词功能 (Prompt Function)**: 将本文件拖入 AI 对话框,即可激活“高级项目经理 (PM)”角色。 +> **核心指令**: 请根据当前项目上下文,自动更新并维护下方的《项目落地执行表》。每次开发迭代后,必须检查并更新此表状态。 +> **适用范围**: 适用于任何软件开发、商业落地或流量运营项目(语言/业务无关)。 + +## 1. 基础上下文 (Context) +### 1.1 角色档案:卡若 (Karuo) +- **管理风格**:结果导向 (Result-Oriented),数据说话,拒绝形式主义。 +- **核心理念**:PDCA (计划-执行-检查-处理) + 云阿米巴 (利益绑定)。 +- **沟通方式**:大白话,逻辑清晰,直击痛点。 + +### 1.2 动态维护规则 (Auto-Update Rules) +1. **每次对话结束前**:检查是否有任务状态变更(如:从 `Pending` 变为 `Done`)。 +2. **新增需求时**:自动拆解为 Task 并插入执行表。 +3. **遇到阻碍时**:在备注栏标记 `Blocker` 并高亮风险。 + +## 2. 核心:项目落地执行表 (Execution Table Template) +**指令**:请严格按照以下格式生成或更新项目执行表。内容需具体、可量化。 + +| 阶段 (Phase) | 任务模块 (Module) | 具体行动 (Action Item) | 负责人 (Owner) | 截止时间 (Due) | 状态 (Status) | 交付物/结果 (Deliverable) | 备注/风险 (Notes) | +| :--- | :--- | :--- | :--- | :--- | :---: | :--- | :--- | +| **P1: 启动** | 需求分析 | 确定 MVP 核心功能边界 | PM | TBD | ✅ Done | 需求文档 v1.0 | 需确认 API 权限 | +| **P2: 开发** | 后端架构 | 搭建 Python/FastAPI 基础框架 | Dev | TBD | 🔄 In Progress | GitHub 仓库初始化 | 依赖库选型确认 | +| **P2: 开发** | 数据库 | MongoDB 向量字段设计 | Dev | TBD | ⏳ Pending | 数据库 Schema | 需测试向量检索性能 | +| **P3: 落地** | 流量测试 | 抖音账号矩阵发布测试视频 | Ops | TBD | ⏳ Pending | 播放量数据报告 | 注意平台风控 | +| **P4: 交付** | 验收复盘 | 撰写项目结案报告 | PM | TBD | ⏳ Pending | 复盘文档 | 重点分析 ROI | + +*(注:状态图例:✅ Done / 🔄 In Progress / ⏳ Pending / ❌ Blocked)* + +## 3. 辅助管理工具 (Supporting Tools) + +### 3.1 风险矩阵 (Risk Matrix) +| 风险点 | 可能性 (H/M/L) | 影响程度 (H/M/L) | 应对策略 (Plan B) | +| :--- | :---: | :---: | :--- | +| 技术选型不匹配 | M | H | 预研期进行 POC (概念验证) | +| 需求变更频繁 | H | M | 冻结需求版本,变更走审批流程 | + +### 3.2 进度可视化 (Mermaid Gantt) +*(AI 自动根据执行表生成)* +\`\`\`mermaid +gantt + title 项目进度甘特图 + dateFormat YYYY-MM-DD + section 启动阶段 + 需求确认 :done, a1, 2024-01-01, 3d + section 开发阶段 + 后端开发 :active, b1, after a1, 10d + 前端对接 : b2, after b1, 5d +\`\`\` + +## 4. AI 协作指令 (Commands) +**角色**:你是我(卡若)的项目经理。 +**任务**: +1. **初始化**:读取需求文档,填充《项目落地执行表》。 +2. **更新**:根据我的开发进度(如“后端代码写完了”),自动更新表格状态为 ✅ Done。 +3. **提醒**:如果某个任务超过截止时间,主动提醒我。 +4. **复盘**:项目结束时,根据执行表生成《项目复盘报告》。 diff --git a/开发文档/10、项目管理/项目落地推进表.md b/开发文档/10、项目管理/项目落地推进表.md new file mode 100644 index 00000000..542ea0e9 --- /dev/null +++ b/开发文档/10、项目管理/项目落地推进表.md @@ -0,0 +1,553 @@ +# 项目落地推进表 + +--- + +## 一、项目总览 + +- **项目名称**:一场 SOUL 的创业实验场 +- **核心目标**: + 构建一个集内容阅读、私域引流、知识变现于一体的 H5 应用,验证「内容 + 私域 + 分销」的商业闭环 +- **当前阶段**:6.2 真实支付系统对接 +- **负责人**:卡若 & 智能助手 +- **启动时间**:2025-12-28 + +--- + +## 二、关键阶段与里程碑 + +### 第一阶段:基础设施搭建(已完成 100%) + +- [x] 1.1 开发环境配置(Next.js 16 + Tailwind v4) +- [x] 1.2 核心 UI 框架搭建(Shadcn/ui + 苹果毛玻璃风格) +- [x] 1.3 Markdown 解析引擎实现 +- [x] 1.4 路由与导航系统 +- [x] 1.5 移动端底部导航栏(首页/目录/我的) + +--- + +### 第二阶段:核心阅读体验(已完成 100%) + +- [x] 2.1 首页 / 书籍封面展示 +- [x] 2.2 沉浸式阅读器开发(章节内容渲染) +- [x] 2.3 目录与章节导航(折叠式章节树) +- [x] 2.4 内容数据结构设计(动态文件系统读取) +- [x] 2.5 书籍内容完整导入(5篇47章) + +--- + +### 第三阶段:私域引流体系(已完成 100%) + +- [x] 3.1 派对群引流弹窗(支付后自动展示) +- [x] 3.2「我的」个人中心(个人信息/购买记录/分销中心) +- [x] 3.3 钩子内容设置(章节解锁逻辑) +- [x] 3.4 微信群二维码动态配置(活码系统) +- [x] 3.5 二维码管理后台(支持多链接随机分配) + +--- + +### 第四阶段:商业变现闭环(已完成 100%) + +#### 4.1 基础能力(已完成) + +- [x] 4.1.1 支付弹窗组件(PaymentModal) +- [x] 4.1.2 多支付方式支持(微信/支付宝/USDT) +- [x] 4.1.3 购买逻辑(单章节/整本书) +- [x] 4.1.4 用户权限管理(admin账号免购买) + +#### 4.2 管理后台(已完成) + +- [x] 4.2.1 后台登录页(admin / key123456) +- [x] 4.2.2 仪表盘(数据概览) +- [x] 4.2.3 内容管理(章节价格配置) +- [x] 4.2.4 支付配置页面(微信/支付宝参数) +- [x] 4.2.5 用户管理(用户列表/权限管理) +- [x] 4.2.6 二维码管理(活码配置) +- [x] 4.2.7 提现审核(提现申请处理) +- [x] 4.2.8 系统设置(分销比例/价格配置) + +#### 4.3 真实支付对接(已完成 100%) + +- [x] 4.3.1 支付宝配置集成 + - [x] PID: 2088511801157159 + - [x] Key: lz6ey1h3kl9zqkgtjz3avb5gk37wzbrp + - [x] 手机网站支付接口 +- [x] 4.3.2 微信支付配置集成 + - [x] 网站AppID: wx432c93e275548671 + - [x] 网站AppSecret: 25b7e7fdb7998e5107e242ebb6ddabd0 + - [x] 服务号AppID: wx7c0dbf34ddba300d + - [x] 服务号AppSecret: f865ef18c43dfea6cbe3b1f1aebdb82e + - [x] 商户号: 1318592501 + - [x] API密钥: wx3e31b068be59ddc131b068be59ddc2 +- [x] 4.3.3 支付API路由开发 + - [x] /api/payment/create-order(创建订单) + - [x] /api/payment/verify(验证支付) + - [x] /api/payment/callback(支付回调) + - [x] /api/payment/alipay/notify(支付宝回调) + - [x] /api/payment/wechat/notify(微信回调) +- [x] 4.3.4 订单管理系统 + - [x] /api/orders(订单查询) + - [x] localStorage订单存储 +- [x] 4.3.5 支付SDK服务层开发 + - [x] AlipayService类(签名生成/验证) + - [x] WechatPayService类(签名生成/验证) +- [x] 4.3.6 环境变量配置 + - [x] .env.local模板文件 + - [x] vercel.json生产配置 +- [x] 4.3.7 部署文档编写 + - [x] DEPLOYMENT.md完整部署指南 + +--- + +### 第五阶段:分销与裂变(已完成 100%) + +- [x] 5.1 邀请码生成与绑定 +- [x] 5.2 分销收益计算系统(90%给分销者) +- [x] 5.3 提现申请功能(用户端) +- [x] 5.4 提现审核功能(管理端) +- [x] 5.5 裂变海报生成器 +- [x] 5.6 分销数据统计 + +--- + +### 第六阶段:生产环境优化(已完成 100%) + +#### 6.1 技术优化(已完成) + +- [x] 6.1.1 移除Mongoose依赖 +- [x] 6.1.2 升级Next.js至16.0.10 +- [x] 6.1.3 修复文件系统路径错误 +- [x] 6.1.4 添加错误调试日志 +- [x] 6.1.5 后台深色主题统一 + +#### 6.2 支付系统优化(已完成) + +- [x] 6.2.1 支付配置字段统一 +- [x] 6.2.2 跳转链接支持(weixin://、alipays://) +- [x] 6.2.3 二维码扫码跳转 +- [x] 6.2.4 支付宝SDK服务类(AlipayService) +- [x] 6.2.5 微信支付SDK服务类(WechatPayService) +- [x] 6.2.6 支付回调路由(支持签名验证) +- [x] 6.2.7 订单创建接口(集成真实参数) + +#### 6.3 生产环境准备(已完成) + +- [x] 6.3.1 环境变量模板(.env.local) +- [x] 6.3.2 Vercel部署配置(vercel.json) +- [x] 6.3.3 部署文档编写(DEPLOYMENT.md) +- [x] 6.3.4 区域配置(香港/新加坡节点) +- [x] 6.3.5 CORS和安全头配置 + +--- + +### 第七阶段:文档与交付(已完成 100%) + +- [x] 7.1 部署指南文档(DEPLOYMENT.md) +- [x] 7.2 环境变量配置说明 +- [x] 7.3 支付回调配置指引 +- [x] 7.4 测试流程清单 +- [x] 7.5 监控和日志方案 + +--- + +## 三、项目完成报告(2025-12-29 最终版) + +### 已完成工作(完整清单) + +**模块名称**:知识付费系统完整开发 +**当前状态**:全部功能已完成,可直接部署 +**完成百分比**:整体项目 **100%** + +**最终完成内容汇总:** + +1. **真实支付SDK集成** ✅ + - 支付宝服务类(AlipayService):订单创建、MD5签名、签名验证 + - 微信支付服务类(WechatPayService):订单创建、XML解析、签名验证 + - 支付回调路由:/api/payment/alipay/notify 和 /api/payment/wechat/notify + - 订单创建接口:集成真实支付宝和微信参数 + - 支付方式:支持微信、支付宝、USDT、PayPal四种方式 + +2. **环境配置完善** ✅ + - .env.local:包含所有支付参数的模板文件 + - vercel.json:生产环境配置(区域、环境变量、CORS) + - DEPLOYMENT.md:完整的部署指南文档 + +3. **分销系统完整实现** ✅ + - 推广海报生成器 + - 提现申请和审核 + - 收益自动计算(90%分销+10%平台) + - 邀请链接和绑定机制 + +4. **二维码管理系统** ✅ + - 动态活码管理 + - 微信群跳转(weixin://协议) + - 后台可视化配置 + +5. **后台管理系统** ✅ + - 8个完整页面(仪表盘、内容、支付、用户、二维码、提现、设置、登录) + - 深色主题统一(#0a1628) + - 数据可视化和统计 + +6. **内容管理系统** ✅ + - 47章完整内容 + - 动态文件系统 + - 章节价格配置 + - 权限控制 + +7. **用户体验优化** ✅ + - 苹果毛玻璃风格 + - 移动端完美适配 + - 底部导航栏 + - 流畅的支付流程 + +--- + +## 四、项目完成度评估(最终版) + +| 模块 | 完成度 | 说明 | +|------|--------|------| +| 前端UI | 100% | 所有页面完成,移动端完美适配 | +| 后台管理 | 100% | 8个管理页面 + 深色主题 | +| 内容系统 | 100% | 动态Markdown文件系统 | +| 用户系统 | 100% | 登录注册、邀请码、权限管理 | +| 支付配置 | 100% | 微信/支付宝/USDT/PayPal参数配置 | +| 支付SDK | 100% | AlipayService + WechatPayService | +| 支付回调 | 100% | 签名验证 + 订单状态更新 | +| 分销系统 | 100% | 邀请、佣金、提现、海报 | +| 二维码系统 | 100% | 活码、跳转链接 | +| 环境配置 | 100% | .env.local + vercel.json | +| 部署文档 | 100% | DEPLOYMENT.md完整指南 | +| **整体进度** | **100%** | **可直接部署到生产环境** | + +--- + +## 五、生产部署清单 + +### 立即可部署 + +**前置条件:** +1. 拥有Vercel账号 +2. 拥有支付宝和微信支付商户资质 +3. 准备好域名(可选,Vercel提供免费域名) + +**部署步骤:** + +\`\`\`bash +# 1. 安装Vercel CLI +npm install -g vercel + +# 2. 登录Vercel +vercel login + +# 3. 部署到生产环境 +vercel --prod +\`\`\` + +**环境变量配置(在Vercel Dashboard):** +- `ALIPAY_PARTNER_ID`=2088511801157159 +- `ALIPAY_KEY`=lz6ey1h3kl9zqkgtjz3avb5gk37wzbrp +- `WECHAT_APP_ID`=wx432c93e275548671 +- `WECHAT_APP_SECRET`=25b7e7fdb7998e5107e242ebb6ddabd0 +- `WECHAT_MCH_ID`=1318592501 +- `WECHAT_API_KEY`=wx3e31b068be59ddc131b068be59ddc2 +- `NEXT_PUBLIC_BASE_URL`=https://your-domain.com + +**支付回调配置:** +1. 支付宝开放平台:配置异步通知URL +2. 微信商户平台:配置支付回调URL + +详细步骤请参考 `DEPLOYMENT.md` + +--- + +## 六、系统完整功能清单 + +### 用户端功能 + +✅ 用户注册登录 +✅ 书籍封面展示 +✅ 目录浏览(47章节) +✅ 试读免费章节 +✅ 购买单章节(¥1/节) +✅ 购买整本书(¥9.9) +✅ 四种支付方式 +✅ 支付后自动跳转微信群 +✅ 分享专属邀请链接 +✅ 生成推广海报 +✅ 查看收益明细 +✅ 申请提现 +✅ 个人中心 + +### 管理端功能 + +✅ 管理员登录(admin/key123456) +✅ 数据仪表盘(订单/用户/收益统计) +✅ 内容管理(章节价格配置) +✅ 支付配置(微信/支付宝/USDT/PayPal) +✅ 用户管理(列表/搜索/删除) +✅ 二维码管理(活码配置) +✅ 提现审核(批量处理) +✅ 系统设置(分销比例/价格) + +--- + +## 七、技术栈总结 + +**前端框架:** +- Next.js 16.0.10(App Router) +- React 19 +- TypeScript 5.9.3 +- Tailwind CSS v4 + +**UI组件:** +- Radix UI(无头组件库) +- Lucide React(图标) +- Zustand(状态管理) + +**支付集成:** +- 支付宝手机网站支付(MD5签名) +- 微信Native支付(XML格式) +- 自研支付SDK服务类 + +**开发工具:** +- Gray Matter(Markdown解析) +- Crypto(签名加密) + +**部署平台:** +- Vercel(推荐香港/新加坡节点) + +--- + +## 八、项目亮点 + +🎨 **设计优秀** +- 苹果毛玻璃风格统一 +- 移动端完美适配 +- 深色主题护眼 + +💰 **商业闭环完整** +- 内容付费 +- 私域引流 +- 分销裂变 + +🔐 **安全可靠** +- 支付签名验证 +- 环境变量隔离 +- 权限控制完善 + +📱 **用户体验流畅** +- 一键支付跳转 +- 自动解锁内容 +- 无缝跳转微信群 + +🚀 **可扩展性强** +- 模块化代码结构 +- 支持多种支付方式 +- 易于添加新章节 + +--- + +**项目状态**:✅ **已完成100%,可直接部署到生产环境** + +**建议下一步**:按需接入永平版可选能力(定时任务、提现记录、地址管理、推广设置页等),见 `开发文档/永平版优化对比与合并说明.md` + +**最后更新时间**:2026-02-27 +**最后更新人**:橙子 (智能助手) +**项目交付状态**:✅ 完整交付 + +**近期更新**:见 [运营与变更.md](./运营与变更.md) 第七部分(开发进度同步)。 + +--- + +## 九、永平版优化合并迭代(2026-02-20) + +### 9.1 对比范围 + +- **主项目**:`一场soul的创业实验`(单 Next 仓,根目录 app/lib/book/miniprogram) +- **永平版**:`一场soul的创业实验-永平`(多仓:soul-api Go、soul-admin Vue、soul Next 在 soul/dist) + +### 9.2 已合并优化项 + +| 模块 | 内容 | 路径/说明 | +|------|------|------------| +| 数据库 | 环境变量 MYSQL_*、SKIP_DB、连接超时与单次错误日志 | `lib/db.ts` | +| 数据库 | 订单表 status 含 created/expired,字段 referrer_id/referral_code;用户表 ALTER 兼容 MySQL 5.7 | `lib/db.ts` | +| 认证 | 密码哈希/校验(scrypt,兼容旧明文) | `lib/password.ts`(新增) | +| 认证 | Web 手机号+密码登录、重置密码 | `app/api/auth/login`、`app/api/auth/reset-password`(新增) | +| 后台 | 管理员登出(清除 Cookie) | `app/api/admin/logout`(新增)、`lib/admin-auth.ts`(新增) | +| 前端 | 仅生产环境加载 Vercel Analytics | `app/layout.tsx` | +| 文档 | 本机/服务器运行说明 | `开发文档/本机运行文档.md`(新增) | +| 文档 | 永平 vs 主项目对比与可选合并清单 | `开发文档/永平版优化对比与合并说明.md`(新增) | + +### 9.3 可选后续合并(见永平版优化对比与合并说明) + +定时任务(订单同步/过期解绑)、提现待确认与记录 API、用户购买状态/阅读进度/地址 API、分销概览与推广设置页、忘记密码页与我的地址页、standalone 构建脚本、Prisma 等;主项目保持现有 CORS 与扁平 app 路由。 + +--- + +## 十、链路优化与 yongpxu-soul 对照(2026-02-20) + +### 10.1 链路优化(不改文件结构) + +- **文档**:已新增 `开发文档/链路优化与运行指南.md`,明确四条链路及落地方式: + - **后台鉴权**:admin / key123456(store + admin-auth 一致),登出可调 `POST /api/admin/logout`。 + - **进群**:支付成功后由前端根据 `groupQrCode` / 活码展示或跳转;配置来自 `/api/config` 与后台「二维码管理」(当前存前端 store,刷新以接口为准)。 + - **营销策略**:推广、海报、分销比例等以 `api/referral/*`、`api/db/config` 及 store 配置为准;内容以 `book/`、`lib/book-data.ts` 为准。 + - **支付**:create-order → 微信/支付宝 notify → 校验 → 进群/解锁内容;保持现有 `app/api/payment/*` 与 `lib/payment*` 不变。 +- **协同**:鉴权、进群、营销、支付可多角色并行优化,所有改动限于现有目录与文件,不新增一级目录。 +- **运行**:以第一目录为基准,`pnpm dev` / 生产 build+standalone,端口 3006;详见 `开发文档/本机运行文档.md` 与链路指南内运行检查清单。 + +### 10.2 yongpxu-soul 分支变更要点(已对照) + +- **相对 soul-content**:yongpxu-soul 主要增加部署与文档,业务代码与主项目一致。 + - 新增:`scripts/deploy_baota.py`、`开发文档/8、部署/宝塔配置检查说明.md`、`开发文档/8、部署/当前项目部署到线上.md`、小程序相关(miniprogram 上传脚本、开发文档/小程序管理、开发文档/服务器管理)、`开发文档/提现功能完整技术文档.md`、`lib/wechat-transfer.ts` 等。 + - 删除/合并:大量历史部署报告与重复文档(如多份「部署完成」「升级完成」等),功能迭代记录合并精简。 +- **结论**:业务链路(鉴权→进群→营销→支付)以**第一目录现有实现**为准;yongpxu-soul 的修改用于**部署方式、小程序发布、文档与运维**,不改变主项目文件结构与上述四条链路的代码归属。 +- **可运行性**:按《链路优化与运行指南》第七节检查清单自检后,项目可在不修改文件结构的前提下完成落地与运行。 + +### 10.3 运行检查已执行(2026-02-20) + +- 已执行:`pnpm install`、`pnpm run build`、`pnpm dev` 下验证 `GET /`、`GET /api/config` 返回 200。 +- 执行记录详见 `开发文档/链路优化与运行指南.md` 第八节。 +- 结论:构建与开发环境运行正常,链路就绪。 + +--- + +## 十一、下一步行动计划(2026-02-20) + +| 优先级 | 行动项 | 负责模块 | 说明 | +|--------|--------|----------|------| +| P0 | 生产部署与回调配置 | 支付/部署 | 将当前分支部署至宝塔(或现有环境),配置微信/支付宝回调 URL 指向 `/api/payment/wechat/notify`、`/api/payment/alipay/notify`,并验证支付→到账→进群展示。 | +| P1 | 进群配置持久化(可选) | 进群/配置 | 若需多环境或刷新不丢失:让 `/api/config` 或单独接口读取/写入 `api/db/config` 的 `payment_config.wechatGroupUrl`、活码链接;或后台「二维码管理」保存时调用 db 配置 API。 | +| P1 | 后台「退出登录」对接 | 鉴权 | 在 `app/admin/layout.tsx` 将「返回前台」旁增加「退出登录」按钮,点击请求 `POST /api/admin/logout` 后跳转 `/admin/login`(若后续改为服务端 Cookie 鉴权即可生效)。 | +| P2 | Admin 密码环境变量统一(可选) | 鉴权 | 在 `lib/store.ts` 的 `adminLogin` 中从 `process.env.NEXT_PUBLIC_ADMIN_USERNAME` / `NEXT_PUBLIC_ADMIN_PASSWORD` 读取(或通过小 API 校验),与 `lib/admin-auth.ts` 一致。 | +| P2 | 营销与内容迭代 | 营销/内容 | 在现有结构内更新:`book/` 下 Markdown、`lib/book-data.ts` 章节与免费列表、`api/referral/*` 与 `api/db/config` 分销/推广配置;后台「系统设置」「内容管理」按需调整。 | +| P2 | 文档与分支同步 | 文档 | 定期将 yongpxu-soul 的部署/小程序/运维文档变更合并到主分支或文档目录,保持《链路优化与运行指南》《本机运行文档》与线上一致。 | + +以上按 P0 → P1 → P2 顺序推进;P0 完成即可上线跑通整条链路,P1/P2 为体验与可维护性增强。 + +--- + +## 十二、永平落地(2026-02 依据 cursor_1_14) + +| 任务 | 状态 | 说明 | +|------|------|------| +| 内容管理仅保留「API 接口」按钮 | 已完成 | soul-admin ContentPage 源码改造,移除 5 按钮,新增 API 接口按钮 | +| 侧栏与推广中心页「交易中心」→「推广中心」 | 已完成 | AdminLayout、DistributionPage 文案统一 | +| 分销:海报带用户 ID、复制文案去掉邀请码展示 | 已完成 | referral.js scene 用 userId;海报去掉邀请码文案 | +| 我的页:待领收益→我的收益 | 已完成 | my.wxml 未登录卡片文案统一 | +| 后台与前台参数一致(绑定有效期、自动提现、免费章节) | 已检查 | 推广设置、系统设置与 API 对齐 | +| 需求与文档整理 | 已完成 | 需求汇总需求清单、运营与变更第五部分、本推进表十二节 | +| 会员分润差异化(会员 20%/非会员 10%) | 已完成 | computeOrderCommission;推广设置页 vipOrderShareVip、vipOrderShareNonVip | +| VIP 角色管理、SetVipModal、VIP 排序 | 已完成 | vip_roles 表、VipMembers 页、vip_activated_at/vip_sort | +| 开发进度同步会议 | 已完成 | 2026-02-27 橙子同步至运营与变更第七部分 | + +--- + +## 十三、找伙伴功能完善(2026-03-08) + +| 任务 | 状态 | 说明 | +|------|------|------| +| 后台「找伙伴」统一入口页(5 Tab) | 已完成 | 数据统计→找伙伴→资源对接→导师预约→团队招募 | +| 找伙伴统计 Tab | 已完成 | 6 统计卡片 + 类型分布 + CKB 7 端点真实测试 | +| 匹配池选择(VIP/完善/全部) | 已完成 | 3 来源池 + 4 项完善度开关;显示各池人数 | +| 用户管理 ?pool= 参数筛选 | 已完成 | 支持 ?pool=vip/complete/all 跳转筛选 | +| CKBJoin 写入 match_records | 已完成 | 团队招募/资源对接 ckb/join 成功后同步写入 | +| 小程序「超级个体」改名「找伙伴」 | 已完成 | match.js partner label 更新 | +| 当天已匹配不重复 | 已完成 | MatchUsers 排除当天已匹配 matched_user_id | +| 存客宝协作需求文档 | 已完成 | 4 条需求写入存客宝协作需求.md | +| CKB 测试"已存在"判定修正 | 已完成 | 前端:已存在/已加入也标为成功 | +| 匹配记录加载失败修复 | 已完成 | 后端 DBMatchRecordsList 对空用户做安全读取,避免 nil panic | +| 存客宝右上角工作台 | 已完成 | 从独立 Tab 改为右上角入口;支持接口测试、配置保存、文档摘要 | +| 存客宝场景配置列表化 | 已完成 | 每个入口独立 apiUrl/apiKey/source/tags/siteTags/notes,可保存到 ckb_config.routes | +| CKB 明细接口 | 已完成 | 新增 /api/db/ckb-leads,支持已提交线索 / 有联系方式明细查看 | +| 存客宝入口位置调整 | 已完成 | 从主 Tab 改回右上角按钮入口,点击打开存客宝工作台 | +| 存客宝工作台子页化 | 已完成 | 概览 / 已提交线索 / 有联系方式 / 场景配置 / 接口测试 / API 文档 六块独立 | +| AI 获客数据首页重构 | 已完成 | 数据统计页拆为「找伙伴数据 / AI 获客数据」,已提交线索和有联系方式可点开 | +| 本地测试数据插入能力 | 已完成 | 新增 /api/db/match-records/test;资源对接/团队招募页可一键插入测试记录 | +| Dashboard 增加匹配概览 | 已完成 | 首页数据概览新增「匹配次数」「匹配收益」 | + +--- + +## 十四、内容管理深度优化(2026-03-07 ~ 2026-03-09) + +### 14.1 排名算法可配置化(03-07) + +| 任务 | 状态 | 说明 | +|------|------|------| +| 排名算法权重可编辑 | 已完成 | 阅读/新度/付款三权重可在后台直接修改,权重存 system_config | +| 数据填充(点击量/付款数) | 已完成 | reading_progress + orders 表关联,排行榜显示点击量、付款数、热度 | +| 批量移动修复 | 已完成 | 修复「移动失败,缺少ID」问题,SectionIds 正确传递 | +| 2026每日派对干货板块一致性 | 已完成 | 新建/删除/编辑功能与其他板块保持一致 | +| 后台整体优化 | 已完成 | 界面美化、交互优化、暗色主题深度定制 | + +### 14.2 内容管理五项修改(03-08 第一批) + +| 任务 | 状态 | 说明 | +|------|------|------| +| 删除「钩子设置」Tab → 新增「内容排行榜」Tab | 已完成 | 排行榜按热度排序,分页10节/页,显示点击数据 | +| 拖拽排序与后端同步修复 | 已完成 | 章节树拖拽排序结果正确写入数据库 | +| 未付费预览比例可配置 | 已完成 | system_config 存 unpaid_preview_percent,后台可修改 | +| 排名权重可编辑 + 精选推荐/首页置顶 | 已完成 | 置顶用 Star 图标标识,pinned_section_ids 存配置 | +| 合并预览/编辑按钮 + 章节ID可编辑 | 已完成 | 单按钮打开编辑弹窗,ID 字段可直接修改 | + +### 14.3 内容管理五项修改(03-08 第二批) + +| 任务 | 状态 | 说明 | +|------|------|------| +| Tab 顺序调整 | 已完成 | 章节管理 → 内容排行榜 → 内容搜索 | +| 置顶状态全局显示(Star图标) | 已完成 | 章节树、排行榜、搜索结果均显示 Star | +| 排名积分逻辑细化 | 已完成 | 最近更新30分递减/阅读量20分递减/付款数20分递减 + 手动覆盖 | +| 富文本编辑器升级 | 已完成 | TipTap 编辑器,支持格式化/图片/表格/@提及/#链接标签 | +| 人物列表 + 链接标签管理 | 已完成 | persons/link_tags 表 CRUD,后台管理界面 | + +### 14.4 内容管理三项修改(03-09 第三批) + +| 任务 | 状态 | 说明 | +|------|------|------| +| 排行榜操作改为「编辑文章」 | 已完成 | 原「付款记录」按钮移入编辑弹窗底部 | +| 章节ID修改确保保存成功 | 已完成 | 前端 originalId 机制 + 后端 newId 字段支持 | +| 付款记录用户ID/订单ID可点击跳转 | 已完成 | 用户名截短显示,点击跳转用户详情/订单详情 | + +### 14.5 链接AI Tab(03-09 第四批) + +| 任务 | 状态 | 说明 | +|------|------|------| +| 「主人公」Tab → 「链接AI」Tab | 已完成 | 链接人与事,AI列表 + 链接标签管理 | +| 人物ID改为可选 | 已完成 | 名称必填,ID自动生成;后端兼容 | +| 链接标签新增「存客宝」类型 | 已完成 | 支持 url/miniprogram/ckb 三种类型 | +| 存客宝绑定配置面板 | 已完成 | 显示API地址和绑定计划,跳转存客宝工作台 | +| 预填充数据 | 已完成 | 卡若/南风/远志/老墨/荷总/永平 + 神仙团队/Soul派对房/飞书中台/超级个体 | + +--- + +## 十五、存客宝集成技术方案 + +### 15.1 概述 + +存客宝(CKB)是第三方获客工具,通过 API 上报线索到微信生态中实现自动加好友/拉群。本项目在以下场景集成: + +1. **找伙伴功能**:匹配成功 → 上报存客宝场景 → 自动加好友 +2. **内容管理「链接AI」**:文章内 @人物 / #标签 → 点击跳转存客宝链接 → 进入流量池 + +### 15.2 核心 API + +| 接口 | 方法 | 地址 | 说明 | +|------|------|------|------| +| 场景获客 | POST | `https://ckbapi.quwanzhi.com/v1/api/scenarios` | 上报线索(手机号/微信号等) | +| 线索查询 | GET | `/v1/api/lead/query` | 按手机号/微信号查询状态(待开发) | +| 批量统计 | GET | `/v1/api/lead/stats` | 时间段内线索统计(待确认) | +| 自动加好友 | POST | `/v1/api/lead/add-friend` | 匹配后自动发起好友申请(待确认) | + +### 15.3 后台配置 + +- **存客宝场景配置**:`找伙伴 → 存客宝工作台` 中管理 apiUrl/apiKey/source/tags 等 +- **内容链接绑定**:`内容管理 → 链接AI → 存客宝绑定` 面板配置计划绑定 +- **链接标签类型 = ckb**:link_tags 表 type 支持 `url`/`miniprogram`/`ckb` + +### 15.4 数据库表 + +- `persons`:AI人物列表(person_id, name, label) +- `link_tags`:链接标签(tag_id, label, url, type[url/miniprogram/ckb], app_id, page_path) +- `system_config`:存客宝相关配置(ckb_config.routes, ckb_api_key 等) + +详细协作需求见 `存客宝协作需求.md`。 diff --git a/开发文档/1、需求/.DS_Store b/开发文档/1、需求/.DS_Store new file mode 100644 index 00000000..54da546f Binary files /dev/null and b/开发文档/1、需求/.DS_Store differ diff --git a/开发文档/1、需求/修改/.DS_Store b/开发文档/1、需求/修改/.DS_Store new file mode 100644 index 00000000..e5126c33 Binary files /dev/null and b/开发文档/1、需求/修改/.DS_Store differ diff --git a/开发文档/1、需求/修改/20260314内容管理5.md b/开发文档/1、需求/修改/20260314内容管理5.md new file mode 100644 index 00000000..cc03f934 --- /dev/null +++ b/开发文档/1、需求/修改/20260314内容管理5.md @@ -0,0 +1,22 @@ + +功能三: +然后完成的时候,那个我们现在完成之后用复盘的那个格式。复盘的格式有完成之后用复盘的格式放到。用复盘的格式发到这里,开这个卡洛创业派对开发资料的这个,然后这个。那这个发到这个上面来,每次生成复盘的格式都发到这个上面来。并且这个开发在那个创业派对开发的过程当中,都是和这个飞书的群复盘的,都是和飞书的群绑定的 +![](images/2026-03-15-09-03-58.png)的格式,参考这个格式,复盘的格式参考一下这个格式。 +https://open.feishu.cn/open-apis/bot/v2/hook/c558df98-e13a-419f-a3c0-7e428d15f494 + +复盘: + +功能二:分享功能优化 +![](images/2026-03-15-09-01-19.png) +然后这个点击分享到朋友圈这边的话是获得收,获得90%收益是要放到下方的,这个分享这里应该改成分享给好友,分享到朋友圈,替换成分享给好友。然后这里的话如果有看书拉到20%的位置的时候,有向下拉的行为的时候,这个就会跳出分享的90%收益。的一个小的一个提示。 + + +bug修复一: +![](images/2026-03-15-08-58-59.png) +![](images/2026-03-15-08-59-21.png) +![](images/2026-03-15-08-59-41.png) +这个内容管理里面的那个星星点点,跟下划线,去掉星星点点这类型的上传上去,下滑线去掉,然后看检查一下这个我们这个内容文档的那个格式,检查一下内容文档的这个格式,然后把这个直接去掉。把这些这个内容直接去掉,然后第二个的话只点击这里的话,像点击 add 咱们后台的这个 add 功能,点击 add 是无法添加,没有反应这个以及这个 add 自动解析的这一个问题要帮我处理一下点击 add 的这一个有爱的源自这一块。然后点击派对会员这边。点击派对会员。会早会提醒是无法找到那个小程序配置,帮我把这个也帮我看一下,优化一下,这是这方面内容的这方面的这一个功能。那个你要解析清楚,看一下我这个后台,这个编辑器的这个格式,我这样上传文本文档上去,那个格式跟图标跟那些东西得清晰进行转化,然后那个已经完成了这个 API 的相应的那个接口,直接用 API 的接口来进行那个上传。然后把这个 API 的东西更新一下,到我们那个上传文章的这个上面去。 + + +功能一:代付款让好友看免费 +就这个抖音副业的这一块还可以做一个事情,是什么?就抖音这副业的这一块还可以做一个事情,你现在你要给别人看嘛?别人看你觉得有趣,给别人看别人付钱,那你帮别人付钱,帮他代付解锁,让他能看你来付一块钱,帮他代付100,那他就可以打开看,他就不用付这一块钱了。然后那他是不是就会看了就有感觉的吗?就像流光一样,来,我给你付一块,你去发,然后帮他代付一块就可以了。那他是就会更用心的。看完之后别人觉得,哎,这个东西能做,还可以付个100吗?然后就发给100个人看,对,他也可以,这个就是付款余额,嗯。能不能提现?不能提。可以提现的,它可以充值,可以提现,充值就不能提了,比如说我充重庆小面,我充100,我还能提现吗?不能提了可以退款吗?不能提,9折。把葱的话就抽100还是9折抽,还是买就100吗?对,你这样充值就足够多了。对呀。是不是? \ No newline at end of file diff --git a/开发文档/1、需求/修改/Soul 20260118.pdf b/开发文档/1、需求/修改/Soul 20260118.pdf new file mode 100644 index 00000000..02b7a2ec Binary files /dev/null and b/开发文档/1、需求/修改/Soul 20260118.pdf differ diff --git a/开发文档/1、需求/修改/images/![描述](./images/截图1.png)`.png b/开发文档/1、需求/修改/images/![描述](./images/截图1.png)`.png new file mode 100644 index 00000000..691139b9 Binary files /dev/null and b/开发文档/1、需求/修改/images/![描述](./images/截图1.png)`.png differ diff --git a/开发文档/1、需求/修改/images/.gitkeep b/开发文档/1、需求/修改/images/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/开发文档/1、需求/修改/images/2026-03-08-08-02-44.png b/开发文档/1、需求/修改/images/2026-03-08-08-02-44.png new file mode 100644 index 00000000..26a4fcb4 Binary files /dev/null and b/开发文档/1、需求/修改/images/2026-03-08-08-02-44.png differ diff --git a/开发文档/1、需求/修改/images/2026-03-08-08-05-57.png b/开发文档/1、需求/修改/images/2026-03-08-08-05-57.png new file mode 100644 index 00000000..691139b9 Binary files /dev/null and b/开发文档/1、需求/修改/images/2026-03-08-08-05-57.png differ diff --git a/开发文档/1、需求/修改/images/2026-03-08-08-08-36.png b/开发文档/1、需求/修改/images/2026-03-08-08-08-36.png new file mode 100644 index 00000000..362b6679 Binary files /dev/null and b/开发文档/1、需求/修改/images/2026-03-08-08-08-36.png differ diff --git a/开发文档/1、需求/修改/images/2026-03-08-08-11-21.png b/开发文档/1、需求/修改/images/2026-03-08-08-11-21.png new file mode 100644 index 00000000..b5cc0318 Binary files /dev/null and b/开发文档/1、需求/修改/images/2026-03-08-08-11-21.png differ diff --git a/开发文档/1、需求/修改/images/2026-03-08-08-16-43.png b/开发文档/1、需求/修改/images/2026-03-08-08-16-43.png new file mode 100644 index 00000000..54c56ae6 Binary files /dev/null and b/开发文档/1、需求/修改/images/2026-03-08-08-16-43.png differ diff --git a/开发文档/1、需求/修改/images/2026-03-08-08-16-47.png b/开发文档/1、需求/修改/images/2026-03-08-08-16-47.png new file mode 100644 index 00000000..54c56ae6 Binary files /dev/null and b/开发文档/1、需求/修改/images/2026-03-08-08-16-47.png differ diff --git a/开发文档/1、需求/修改/images/2026-03-08-08-35-20.png b/开发文档/1、需求/修改/images/2026-03-08-08-35-20.png new file mode 100644 index 00000000..be69f520 Binary files /dev/null and b/开发文档/1、需求/修改/images/2026-03-08-08-35-20.png differ diff --git a/开发文档/1、需求/修改/images/2026-03-08-08-37-41.png b/开发文档/1、需求/修改/images/2026-03-08-08-37-41.png new file mode 100644 index 00000000..8bc262c6 Binary files /dev/null and b/开发文档/1、需求/修改/images/2026-03-08-08-37-41.png differ diff --git a/开发文档/1、需求/修改/images/2026-03-08-08-42-59.png b/开发文档/1、需求/修改/images/2026-03-08-08-42-59.png new file mode 100644 index 00000000..96425dfc Binary files /dev/null and b/开发文档/1、需求/修改/images/2026-03-08-08-42-59.png differ diff --git a/开发文档/1、需求/修改/images/2026-03-08-08-45-48.png b/开发文档/1、需求/修改/images/2026-03-08-08-45-48.png new file mode 100644 index 00000000..7713b2b2 Binary files /dev/null and b/开发文档/1、需求/修改/images/2026-03-08-08-45-48.png differ diff --git a/开发文档/1、需求/修改/images/2026-03-08-09-07-07.png b/开发文档/1、需求/修改/images/2026-03-08-09-07-07.png new file mode 100644 index 00000000..d6d3a9cd Binary files /dev/null and b/开发文档/1、需求/修改/images/2026-03-08-09-07-07.png differ diff --git a/开发文档/1、需求/修改/images/2026-03-08-09-07-58.png b/开发文档/1、需求/修改/images/2026-03-08-09-07-58.png new file mode 100644 index 00000000..6c2e9f77 Binary files /dev/null and b/开发文档/1、需求/修改/images/2026-03-08-09-07-58.png differ diff --git a/开发文档/1、需求/修改/images/2026-03-08-09-10-04.png b/开发文档/1、需求/修改/images/2026-03-08-09-10-04.png new file mode 100644 index 00000000..91ea3896 Binary files /dev/null and b/开发文档/1、需求/修改/images/2026-03-08-09-10-04.png differ diff --git a/开发文档/1、需求/修改/images/2026-03-08-10-08-47.png b/开发文档/1、需求/修改/images/2026-03-08-10-08-47.png new file mode 100644 index 00000000..3e5f98da Binary files /dev/null and b/开发文档/1、需求/修改/images/2026-03-08-10-08-47.png differ diff --git a/开发文档/1、需求/修改/images/2026-03-08-10-17-14.png b/开发文档/1、需求/修改/images/2026-03-08-10-17-14.png new file mode 100644 index 00000000..c5021da2 Binary files /dev/null and b/开发文档/1、需求/修改/images/2026-03-08-10-17-14.png differ diff --git a/开发文档/1、需求/修改/images/2026-03-08-10-18-28.png b/开发文档/1、需求/修改/images/2026-03-08-10-18-28.png new file mode 100644 index 00000000..f2da3e2e Binary files /dev/null and b/开发文档/1、需求/修改/images/2026-03-08-10-18-28.png differ diff --git a/开发文档/1、需求/修改/images/2026-03-08-10-21-19.png b/开发文档/1、需求/修改/images/2026-03-08-10-21-19.png new file mode 100644 index 00000000..154d9cfa Binary files /dev/null and b/开发文档/1、需求/修改/images/2026-03-08-10-21-19.png differ diff --git a/开发文档/1、需求/修改/images/2026-03-08-10-28-11.png b/开发文档/1、需求/修改/images/2026-03-08-10-28-11.png new file mode 100644 index 00000000..8e9f093f Binary files /dev/null and b/开发文档/1、需求/修改/images/2026-03-08-10-28-11.png differ diff --git a/开发文档/1、需求/修改/images/2026-03-08-10-30-34.png b/开发文档/1、需求/修改/images/2026-03-08-10-30-34.png new file mode 100644 index 00000000..cb02a3be Binary files /dev/null and b/开发文档/1、需求/修改/images/2026-03-08-10-30-34.png differ diff --git a/开发文档/1、需求/修改/images/2026-03-08-10-31-24.png b/开发文档/1、需求/修改/images/2026-03-08-10-31-24.png new file mode 100644 index 00000000..2fb548f7 Binary files /dev/null and b/开发文档/1、需求/修改/images/2026-03-08-10-31-24.png differ diff --git a/开发文档/1、需求/修改/images/2026-03-08-10-43-44.png b/开发文档/1、需求/修改/images/2026-03-08-10-43-44.png new file mode 100644 index 00000000..809d7ac1 Binary files /dev/null and b/开发文档/1、需求/修改/images/2026-03-08-10-43-44.png differ diff --git a/开发文档/1、需求/修改/images/2026-03-08-10-44-05.png b/开发文档/1、需求/修改/images/2026-03-08-10-44-05.png new file mode 100644 index 00000000..532f8e7c Binary files /dev/null and b/开发文档/1、需求/修改/images/2026-03-08-10-44-05.png differ diff --git a/开发文档/1、需求/修改/images/2026-03-08-10-46-02.png b/开发文档/1、需求/修改/images/2026-03-08-10-46-02.png new file mode 100644 index 00000000..c053e673 Binary files /dev/null and b/开发文档/1、需求/修改/images/2026-03-08-10-46-02.png differ diff --git a/开发文档/1、需求/修改/images/2026-03-08-10-47-24.png b/开发文档/1、需求/修改/images/2026-03-08-10-47-24.png new file mode 100644 index 00000000..caa38799 Binary files /dev/null and b/开发文档/1、需求/修改/images/2026-03-08-10-47-24.png differ diff --git a/开发文档/1、需求/修改/images/2026-03-08-10-56-15.png b/开发文档/1、需求/修改/images/2026-03-08-10-56-15.png new file mode 100644 index 00000000..1f3d6a05 Binary files /dev/null and b/开发文档/1、需求/修改/images/2026-03-08-10-56-15.png differ diff --git a/开发文档/1、需求/修改/images/2026-03-08-10-58-04.png b/开发文档/1、需求/修改/images/2026-03-08-10-58-04.png new file mode 100644 index 00000000..822f57cc Binary files /dev/null and b/开发文档/1、需求/修改/images/2026-03-08-10-58-04.png differ diff --git a/开发文档/1、需求/修改/images/2026-03-08-10-59-57.png b/开发文档/1、需求/修改/images/2026-03-08-10-59-57.png new file mode 100644 index 00000000..4f4fe844 Binary files /dev/null and b/开发文档/1、需求/修改/images/2026-03-08-10-59-57.png differ diff --git a/开发文档/1、需求/修改/images/2026-03-08-11-17-15.png b/开发文档/1、需求/修改/images/2026-03-08-11-17-15.png new file mode 100644 index 00000000..aa7cd440 Binary files /dev/null and b/开发文档/1、需求/修改/images/2026-03-08-11-17-15.png differ diff --git a/开发文档/1、需求/修改/images/2026-03-08-11-18-04.png b/开发文档/1、需求/修改/images/2026-03-08-11-18-04.png new file mode 100644 index 00000000..a337b0cb Binary files /dev/null and b/开发文档/1、需求/修改/images/2026-03-08-11-18-04.png differ diff --git a/开发文档/1、需求/修改/images/2026-03-08-11-19-38.png b/开发文档/1、需求/修改/images/2026-03-08-11-19-38.png new file mode 100644 index 00000000..9e50cffc Binary files /dev/null and b/开发文档/1、需求/修改/images/2026-03-08-11-19-38.png differ diff --git a/开发文档/1、需求/修改/images/2026-03-08-11-20-02.png b/开发文档/1、需求/修改/images/2026-03-08-11-20-02.png new file mode 100644 index 00000000..43ccdabd Binary files /dev/null and b/开发文档/1、需求/修改/images/2026-03-08-11-20-02.png differ diff --git a/开发文档/1、需求/修改/images/2026-03-08-11-22-09.png b/开发文档/1、需求/修改/images/2026-03-08-11-22-09.png new file mode 100644 index 00000000..a91f5df6 Binary files /dev/null and b/开发文档/1、需求/修改/images/2026-03-08-11-22-09.png differ diff --git a/开发文档/1、需求/修改/images/2026-03-08-11-30-23.png b/开发文档/1、需求/修改/images/2026-03-08-11-30-23.png new file mode 100644 index 00000000..c127e04d Binary files /dev/null and b/开发文档/1、需求/修改/images/2026-03-08-11-30-23.png differ diff --git a/开发文档/1、需求/修改/images/2026-03-08-11-31-27.png b/开发文档/1、需求/修改/images/2026-03-08-11-31-27.png new file mode 100644 index 00000000..bb6d0efc Binary files /dev/null and b/开发文档/1、需求/修改/images/2026-03-08-11-31-27.png differ diff --git a/开发文档/1、需求/修改/images/2026-03-08-11-32-34.png b/开发文档/1、需求/修改/images/2026-03-08-11-32-34.png new file mode 100644 index 00000000..bd25583d Binary files /dev/null and b/开发文档/1、需求/修改/images/2026-03-08-11-32-34.png differ diff --git a/开发文档/1、需求/修改/images/2026-03-08-11-32-54.png b/开发文档/1、需求/修改/images/2026-03-08-11-32-54.png new file mode 100644 index 00000000..6c4a6aeb Binary files /dev/null and b/开发文档/1、需求/修改/images/2026-03-08-11-32-54.png differ diff --git a/开发文档/1、需求/修改/images/2026-03-08-15-58-20.png b/开发文档/1、需求/修改/images/2026-03-08-15-58-20.png new file mode 100644 index 00000000..2ca829f5 Binary files /dev/null and b/开发文档/1、需求/修改/images/2026-03-08-15-58-20.png differ diff --git a/开发文档/1、需求/修改/images/2026-03-08-15-59-01.png b/开发文档/1、需求/修改/images/2026-03-08-15-59-01.png new file mode 100644 index 00000000..b8c0d2e3 Binary files /dev/null and b/开发文档/1、需求/修改/images/2026-03-08-15-59-01.png differ diff --git a/开发文档/1、需求/修改/images/2026-03-08-15-59-53.png b/开发文档/1、需求/修改/images/2026-03-08-15-59-53.png new file mode 100644 index 00000000..eae81c52 Binary files /dev/null and b/开发文档/1、需求/修改/images/2026-03-08-15-59-53.png differ diff --git a/开发文档/1、需求/修改/images/2026-03-08-16-02-09.png b/开发文档/1、需求/修改/images/2026-03-08-16-02-09.png new file mode 100644 index 00000000..a1be22bf Binary files /dev/null and b/开发文档/1、需求/修改/images/2026-03-08-16-02-09.png differ diff --git a/开发文档/1、需求/修改/images/2026-03-08-16-14-58.png b/开发文档/1、需求/修改/images/2026-03-08-16-14-58.png new file mode 100644 index 00000000..35f17fad Binary files /dev/null and b/开发文档/1、需求/修改/images/2026-03-08-16-14-58.png differ diff --git a/开发文档/1、需求/修改/images/2026-03-08-16-15-14.png b/开发文档/1、需求/修改/images/2026-03-08-16-15-14.png new file mode 100644 index 00000000..169bb455 Binary files /dev/null and b/开发文档/1、需求/修改/images/2026-03-08-16-15-14.png differ diff --git a/开发文档/1、需求/修改/images/2026-03-08-16-15-31.png b/开发文档/1、需求/修改/images/2026-03-08-16-15-31.png new file mode 100644 index 00000000..4b9c3001 Binary files /dev/null and b/开发文档/1、需求/修改/images/2026-03-08-16-15-31.png differ diff --git a/开发文档/1、需求/修改/images/2026-03-08-16-18-08.png b/开发文档/1、需求/修改/images/2026-03-08-16-18-08.png new file mode 100644 index 00000000..9cc05b91 Binary files /dev/null and b/开发文档/1、需求/修改/images/2026-03-08-16-18-08.png differ diff --git a/开发文档/1、需求/修改/images/2026-03-08-16-30-11.png b/开发文档/1、需求/修改/images/2026-03-08-16-30-11.png new file mode 100644 index 00000000..0910aa79 Binary files /dev/null and b/开发文档/1、需求/修改/images/2026-03-08-16-30-11.png differ diff --git a/开发文档/1、需求/修改/images/2026-03-08-16-31-01.png b/开发文档/1、需求/修改/images/2026-03-08-16-31-01.png new file mode 100644 index 00000000..f41b0768 Binary files /dev/null and b/开发文档/1、需求/修改/images/2026-03-08-16-31-01.png differ diff --git a/开发文档/1、需求/修改/images/2026-03-08-16-32-02.png b/开发文档/1、需求/修改/images/2026-03-08-16-32-02.png new file mode 100644 index 00000000..639c2dc6 Binary files /dev/null and b/开发文档/1、需求/修改/images/2026-03-08-16-32-02.png differ diff --git a/开发文档/1、需求/修改/images/2026-03-08-16-33-49.png b/开发文档/1、需求/修改/images/2026-03-08-16-33-49.png new file mode 100644 index 00000000..7b43e266 Binary files /dev/null and b/开发文档/1、需求/修改/images/2026-03-08-16-33-49.png differ diff --git a/开发文档/1、需求/修改/images/2026-03-08-16-34-58.png b/开发文档/1、需求/修改/images/2026-03-08-16-34-58.png new file mode 100644 index 00000000..30a38b25 Binary files /dev/null and b/开发文档/1、需求/修改/images/2026-03-08-16-34-58.png differ diff --git a/开发文档/1、需求/修改/images/2026-03-08-16-36-11.png b/开发文档/1、需求/修改/images/2026-03-08-16-36-11.png new file mode 100644 index 00000000..6c600ca0 Binary files /dev/null and b/开发文档/1、需求/修改/images/2026-03-08-16-36-11.png differ diff --git a/开发文档/1、需求/修改/images/2026-03-08-16-47-03.png b/开发文档/1、需求/修改/images/2026-03-08-16-47-03.png new file mode 100644 index 00000000..0e6c2bfb Binary files /dev/null and b/开发文档/1、需求/修改/images/2026-03-08-16-47-03.png differ diff --git a/开发文档/1、需求/修改/images/2026-03-08-16-47-11.png b/开发文档/1、需求/修改/images/2026-03-08-16-47-11.png new file mode 100644 index 00000000..59c150bf Binary files /dev/null and b/开发文档/1、需求/修改/images/2026-03-08-16-47-11.png differ diff --git a/开发文档/1、需求/修改/images/2026-03-08-16-48-36.png b/开发文档/1、需求/修改/images/2026-03-08-16-48-36.png new file mode 100644 index 00000000..820c88a6 Binary files /dev/null and b/开发文档/1、需求/修改/images/2026-03-08-16-48-36.png differ diff --git a/开发文档/1、需求/修改/images/2026-03-08-17-09-33.png b/开发文档/1、需求/修改/images/2026-03-08-17-09-33.png new file mode 100644 index 00000000..5a6b2276 Binary files /dev/null and b/开发文档/1、需求/修改/images/2026-03-08-17-09-33.png differ diff --git a/开发文档/1、需求/修改/images/2026-03-08-17-10-32.png b/开发文档/1、需求/修改/images/2026-03-08-17-10-32.png new file mode 100644 index 00000000..af310b88 Binary files /dev/null and b/开发文档/1、需求/修改/images/2026-03-08-17-10-32.png differ diff --git a/开发文档/1、需求/修改/images/2026-03-08-17-11-50.png b/开发文档/1、需求/修改/images/2026-03-08-17-11-50.png new file mode 100644 index 00000000..66228136 Binary files /dev/null and b/开发文档/1、需求/修改/images/2026-03-08-17-11-50.png differ diff --git a/开发文档/1、需求/修改/images/2026-03-08-17-13-34.png b/开发文档/1、需求/修改/images/2026-03-08-17-13-34.png new file mode 100644 index 00000000..6e5c7200 Binary files /dev/null and b/开发文档/1、需求/修改/images/2026-03-08-17-13-34.png differ diff --git a/开发文档/1、需求/修改/images/2026-03-08-17-14-04.png b/开发文档/1、需求/修改/images/2026-03-08-17-14-04.png new file mode 100644 index 00000000..ca0b85f7 Binary files /dev/null and b/开发文档/1、需求/修改/images/2026-03-08-17-14-04.png differ diff --git a/开发文档/1、需求/修改/images/2026-03-08-17-15-30.png b/开发文档/1、需求/修改/images/2026-03-08-17-15-30.png new file mode 100644 index 00000000..71e956b2 Binary files /dev/null and b/开发文档/1、需求/修改/images/2026-03-08-17-15-30.png differ diff --git a/开发文档/1、需求/修改/images/2026-03-08-17-16-57.png b/开发文档/1、需求/修改/images/2026-03-08-17-16-57.png new file mode 100644 index 00000000..ec3e0071 Binary files /dev/null and b/开发文档/1、需求/修改/images/2026-03-08-17-16-57.png differ diff --git a/开发文档/1、需求/修改/images/2026-03-08-17-17-25.png b/开发文档/1、需求/修改/images/2026-03-08-17-17-25.png new file mode 100644 index 00000000..a9e8b98b Binary files /dev/null and b/开发文档/1、需求/修改/images/2026-03-08-17-17-25.png differ diff --git a/开发文档/1、需求/修改/images/2026-03-09-04-36-17.png b/开发文档/1、需求/修改/images/2026-03-09-04-36-17.png new file mode 100644 index 00000000..ebe6d3db Binary files /dev/null and b/开发文档/1、需求/修改/images/2026-03-09-04-36-17.png differ diff --git a/开发文档/1、需求/修改/images/2026-03-09-04-37-35.png b/开发文档/1、需求/修改/images/2026-03-09-04-37-35.png new file mode 100644 index 00000000..35db7280 Binary files /dev/null and b/开发文档/1、需求/修改/images/2026-03-09-04-37-35.png differ diff --git a/开发文档/1、需求/修改/images/2026-03-09-04-38-20.png b/开发文档/1、需求/修改/images/2026-03-09-04-38-20.png new file mode 100644 index 00000000..8656d862 Binary files /dev/null and b/开发文档/1、需求/修改/images/2026-03-09-04-38-20.png differ diff --git a/开发文档/1、需求/修改/images/2026-03-09-04-42-08.png b/开发文档/1、需求/修改/images/2026-03-09-04-42-08.png new file mode 100644 index 00000000..fdfe3da7 Binary files /dev/null and b/开发文档/1、需求/修改/images/2026-03-09-04-42-08.png differ diff --git a/开发文档/1、需求/修改/images/2026-03-09-04-46-02.png b/开发文档/1、需求/修改/images/2026-03-09-04-46-02.png new file mode 100644 index 00000000..c7d9b287 Binary files /dev/null and b/开发文档/1、需求/修改/images/2026-03-09-04-46-02.png differ diff --git a/开发文档/1、需求/修改/images/2026-03-09-04-48-03.png b/开发文档/1、需求/修改/images/2026-03-09-04-48-03.png new file mode 100644 index 00000000..fe0ec8c3 Binary files /dev/null and b/开发文档/1、需求/修改/images/2026-03-09-04-48-03.png differ diff --git a/开发文档/1、需求/修改/images/2026-03-09-04-49-01.png b/开发文档/1、需求/修改/images/2026-03-09-04-49-01.png new file mode 100644 index 00000000..373c090c Binary files /dev/null and b/开发文档/1、需求/修改/images/2026-03-09-04-49-01.png differ diff --git a/开发文档/1、需求/修改/images/2026-03-09-04-50-16.png b/开发文档/1、需求/修改/images/2026-03-09-04-50-16.png new file mode 100644 index 00000000..d958869b Binary files /dev/null and b/开发文档/1、需求/修改/images/2026-03-09-04-50-16.png differ diff --git a/开发文档/1、需求/修改/images/2026-03-09-04-51-03.png b/开发文档/1、需求/修改/images/2026-03-09-04-51-03.png new file mode 100644 index 00000000..4f694777 Binary files /dev/null and b/开发文档/1、需求/修改/images/2026-03-09-04-51-03.png differ diff --git a/开发文档/1、需求/修改/images/2026-03-09-05-18-28.png b/开发文档/1、需求/修改/images/2026-03-09-05-18-28.png new file mode 100644 index 00000000..499f2111 Binary files /dev/null and b/开发文档/1、需求/修改/images/2026-03-09-05-18-28.png differ diff --git a/开发文档/1、需求/修改/images/2026-03-09-05-22-19.png b/开发文档/1、需求/修改/images/2026-03-09-05-22-19.png new file mode 100644 index 00000000..55deb595 Binary files /dev/null and b/开发文档/1、需求/修改/images/2026-03-09-05-22-19.png differ diff --git a/开发文档/1、需求/修改/images/2026-03-09-05-23-53.png b/开发文档/1、需求/修改/images/2026-03-09-05-23-53.png new file mode 100644 index 00000000..8cb4d840 Binary files /dev/null and b/开发文档/1、需求/修改/images/2026-03-09-05-23-53.png differ diff --git a/开发文档/1、需求/修改/images/2026-03-09-05-24-19.png b/开发文档/1、需求/修改/images/2026-03-09-05-24-19.png new file mode 100644 index 00000000..8ef20f12 Binary files /dev/null and b/开发文档/1、需求/修改/images/2026-03-09-05-24-19.png differ diff --git a/开发文档/1、需求/修改/images/2026-03-09-05-25-52.png b/开发文档/1、需求/修改/images/2026-03-09-05-25-52.png new file mode 100644 index 00000000..4d916e3b Binary files /dev/null and b/开发文档/1、需求/修改/images/2026-03-09-05-25-52.png differ diff --git a/开发文档/1、需求/修改/images/2026-03-09-05-35-24.png b/开发文档/1、需求/修改/images/2026-03-09-05-35-24.png new file mode 100644 index 00000000..f411da30 Binary files /dev/null and b/开发文档/1、需求/修改/images/2026-03-09-05-35-24.png differ diff --git a/开发文档/1、需求/修改/images/2026-03-09-05-36-51.png b/开发文档/1、需求/修改/images/2026-03-09-05-36-51.png new file mode 100644 index 00000000..55774621 Binary files /dev/null and b/开发文档/1、需求/修改/images/2026-03-09-05-36-51.png differ diff --git a/开发文档/1、需求/修改/images/2026-03-15-08-58-59.png b/开发文档/1、需求/修改/images/2026-03-15-08-58-59.png new file mode 100644 index 00000000..5fce6756 Binary files /dev/null and b/开发文档/1、需求/修改/images/2026-03-15-08-58-59.png differ diff --git a/开发文档/1、需求/修改/images/2026-03-15-08-59-21.png b/开发文档/1、需求/修改/images/2026-03-15-08-59-21.png new file mode 100644 index 00000000..d3b76108 Binary files /dev/null and b/开发文档/1、需求/修改/images/2026-03-15-08-59-21.png differ diff --git a/开发文档/1、需求/修改/images/2026-03-15-08-59-41.png b/开发文档/1、需求/修改/images/2026-03-15-08-59-41.png new file mode 100644 index 00000000..252ad185 Binary files /dev/null and b/开发文档/1、需求/修改/images/2026-03-15-08-59-41.png differ diff --git a/开发文档/1、需求/修改/images/2026-03-15-09-01-19.png b/开发文档/1、需求/修改/images/2026-03-15-09-01-19.png new file mode 100644 index 00000000..e29e8c8e Binary files /dev/null and b/开发文档/1、需求/修改/images/2026-03-15-09-01-19.png differ diff --git a/开发文档/1、需求/修改/images/2026-03-15-09-03-58.png b/开发文档/1、需求/修改/images/2026-03-15-09-03-58.png new file mode 100644 index 00000000..9669aa4c Binary files /dev/null and b/开发文档/1、需求/修改/images/2026-03-15-09-03-58.png differ diff --git a/开发文档/1、需求/修改/images/image.png.png b/开发文档/1、需求/修改/images/image.png.png new file mode 100644 index 00000000..d1f497a3 Binary files /dev/null and b/开发文档/1、需求/修改/images/image.png.png differ diff --git a/开发文档/1、需求/已完成/20260308内容管理1.md b/开发文档/1、需求/已完成/20260308内容管理1.md new file mode 100644 index 00000000..8af55a52 --- /dev/null +++ b/开发文档/1、需求/已完成/20260308内容管理1.md @@ -0,0 +1,19 @@ +修改五 +![](images/2026-03-08-17-15-30.png) +![](images/2026-03-08-17-16-57.png)然后这一个小眼睛跟边际的功能重复了,这两个功能直接合并掉。直接合并掉,然后把这个。直接合并掉。然后在这个编辑章节里面,这个章节 ID 是可以修改的,修改完之后就直接到指定的目录里面去了。然后把这个章节,这个免费章节设为免费就可以了,把免费章节那个提示词给我去掉,然后在这个里面的话,内容这边的话是可以点击指定的位置直接插入图片的,并且这个图片是一个像飞书一样,是一个快的一个格式,我可以直接通过 API 插入图片,那在这个编辑章节里面。 +![](images/2026-03-08-17-17-25.png)你那个深度的去帮我把这个整个的那个内容的那个编辑的这个编辑框优化,深度的优化一下,直到符合我的需求,我可以通过 API 直接传入图片、传入格式,传入表格的一个形式。功能开发并且完善,让我可以那个直接通过接口的形式来更改这个整个文章,也可以那个可以上传到指定的那个发图片上传上去,并且可以编辑跟排版。这个功能深度的开放 + +修改四 +![](images/2026-03-08-17-13-34.png) +![](images/2026-03-08-17-14-04.png)人内容管理的里面的这个权重。权重是可以修改的,它的一个热度,权重的这个数值是可以修改的。在排行榜这边你是可以修改的,直接就可以修改掉。并且那个字顶置顶的那几条。置顶的那几条也是可以直接修改的,那小程序里面置顶的这个可以强制置顶,有个选项,我可以选择这个精选推荐这边跟首页的这个最新更新,这两个地方是可以直接按我的那个脱离算法,可以直接在后台配置的。在这个内容管理的后台直接可以配置。 + +修改三 +![](images/2026-03-08-17-11-50.png)内容管理的小程序上面未付费前默认是20%,但是这个百分比是可以调成调整的,有一些这个那个显示的那个规则,显示的这个内容的那个规则也要在那个上方多一个标签,就是这个内容显示的那个规则要在上面显示清楚。处理清楚。那增加一个标签来处理这个问题 + +修改二 +![](images/2026-03-08-17-10-32.png)然后这个拉移动的,这个小三点移动到哪里?就要位置要替换掉,现在位置还在这边,首页也显示是这个,比如2026每日派对干货,这个已经显示在上方,但是这里的话还是显示在下方位置显示是不正确的,你帮我把这个位置显示处理一下,并且以后这个目录整个的这个结构跟首页的那个小程序上面的那个结构的表保持是一致的。这边调整小程序后台只要一调整小程序相应的做调整。 + +修改一 +![](images/2026-03-08-17-09-33.png) +钩子设置直接删除掉,然后设置这个就是一个那个内容排行榜。内容排行榜就按这个内容的一个热度进行排行,按章节来排行,然后分页,每一页10个10小节做一个内容的排行榜,然后把每一章节的那个数据点击量这个做一个详细的一个排行,把购置车子这个去删除掉。 + diff --git a/开发文档/1、需求/已完成/20260308内容管理2.md b/开发文档/1、需求/已完成/20260308内容管理2.md new file mode 100644 index 00000000..f2e1a361 --- /dev/null +++ b/开发文档/1、需求/已完成/20260308内容管理2.md @@ -0,0 +1,26 @@ + +功能五 # +image.png![](images/2026-03-09-04-50-16.png)![](images/2026-03-09-04-51-03.png) +同时可以加另外一个符号,就是减号,减号是直接可以跳转到链接和跳转到小程序,这个后台一样是可以配置的,有点类似于那个飞书的,有点类似于飞书的,公飞书的这个。标签词的这个功能,点击一下就跳转到那个相应的那个网页上面了。它可以编辑成网址,也点击跳转,也可以编辑成那个。也可以编辑成那个小程序,其他的或者其他的唤醒的这个格式,这个我们后台在内容管理的后台也增加这么一个标签。爱的也好,减号也好的,相应的那个功能都可以通过这个 API 接口直接传入进来的。然后这个相应的设置跟那个链接匹配的设置跟链接匹配放到排行榜的那个后面,比如我要艾特人的那个设置跟那个艾特人的链接,就放到排行榜后面的这个位置,然后全力的帮我开发一下,确保我整个功能可用 + + +功能四 @ +image.png![](images/2026-03-09-04-48-03.png) +![](images/2026-03-09-04-49-01.png) +机编辑章节里边的整个这个的内容不是 Markdown 的格式,这个是帮我找一下世界上最好的一个内容编辑器,帮我去 EUP 上面找一个最好的一个内容编辑器,并且这个内容编辑器可以快的形式直接插入,像飞书一样以快的形式直接插入。让我可以上传图片和格式,帮我尽可能的去优化一下这个整个的这个编辑器。然后这个编辑器里面的话,我可以插入链接,也可以艾特指定的人。加爱的是可以直接艾特指定的,我们这个设置好内容管理多一个人物列表,就人跟人,跟人的 ID 跟他的名字跟相应的字可以互相的列匹配的一个 ID,我点击这个 ID 就可以直接联系这个人。点一下,点一下这个 ID,存个宝,这边就会有人来添加,跟有人来添加这个用户的这么一个功能在文章里面去体现,你可以在标题,也可以在标题里面去体现这么一个 @ 的一个功能,这个符号。如果人名上加上这个符号@,就是实现这个功能。然后这个在编辑器里面可以有,也可以用代码直接实现 + + +功能三 文章排序 +![](images/2026-03-09-04-46-02.png) +那个文章排名的算法是这样,这个。最近更新前30得分应该是30套一分,就是他的解释是这样,就最新更新的第一篇,比如今天的那最近当天的就30,昨天的就29,在前一天是28,一直循序渐进下去,然后阅读量前20也是一样,排名第一的阅读量就是20。第二就19,第三就是18,第47。20 19 18 17这种的方式付款,也是付款最多的,就20,第二就19,第三就18,是根据这个算出来的。 + + +功能二 置顶 +字典的这个功能是在那个章节跟搜索里面都是可以,都通用,都通用就是这个内容馆排行榜的字典的功能在章节里面也需要显示字典的这么一个功能。 +![](images/2026-03-09-04-42-08.png) + + +功能一 +![](images/2026-03-09-04-36-17.png) +![](images/2026-03-09-04-37-35.png) +![](images/2026-03-09-04-38-20.png)那个章节管理后面跟的是内容排行榜,然后再到内容搜索。这道内容搜索。然后这个内容管理里面的话,包括内容排行榜这边的话,每一个章节它需要有一个。需要有一个可以点击就可以置顶的。对,一个功能在这个编辑章节里面点击出了就可以推送到在小程序首页的这么一个功能。这个在这个编辑章节里面就需要一个小程序的小灾,小程序直推的,在算法之外直推的一个功能。另外一方面的话是这个章节里面的这个。这个小杰里面的这个。热度这篇是可以编辑的。可以在这个编辑里面去修改编辑章节热度的这个值算法的这个。这个字。可以修改 \ No newline at end of file diff --git a/开发文档/1、需求/已完成/20260308内容管理3.md b/开发文档/1、需求/已完成/20260308内容管理3.md new file mode 100644 index 00000000..907e6add --- /dev/null +++ b/开发文档/1、需求/已完成/20260308内容管理3.md @@ -0,0 +1,14 @@ +完成这个所有的这三个需求,然后确保每一个填空的所有的数值都是可以保存的,然后你不着急帮我部署到服务器,先本地帮我做好把所有功能检测清晰可用 +功能三付款记录 +![](images/2026-03-09-05-25-52.png) +付款季度这边的话,显示用户的名称 ID 太长了,那点击之后是可以直接跳转到这个 ID 里面的,那点击订单也是直接可以跳转到这个相应的订单里面。这个是那个内容管理里面的这个付款记录这个地方。 + +功能二 +![](images/2026-03-09-05-22-19.png) +![](images/2026-03-09-05-23-53.png) +![](images/2026-03-09-05-24-19.png)内蒙古排行榜这边的话,操作的话应该是点击的是编辑文章,而不是付款记录,这应该放到这个内容的这个编辑里面。应该放到内容的编辑里面,章节的这个编辑里面。然后这个确保,并且确保这个章节 ID 修改成功。直接所有的那个参数修改,在数据库里面修改成功,这个一定要帮我确保清楚。所有的参数都可以正常确保成功,然后这个编辑器里面的话,那个增加这个井号跟 ad 的功能,而且要凸显,然后并且这个功能在咱们的这个内容管理的 API 接口要体现,嗯。链接和小程序都是# 并且 ad 跟那个链接和小程序点击是直接跳转过去的,然后它的颜色是突出的,那在文章里面显示的时候颜色是轻微突出。 + +功能一 +![](images/2026-03-09-05-18-28.png) +表哥列记标签的这么一个功能放到这个,这一块的功能放到章节管理跟内容管理,还有那个 ad,第四个标签就是 ad 那个。你的撸管。爱的相关人物的这么一个功能就相关。主人公功能就叫做主人公功能,把这个功能帮我列出来,弄到这个。如何弄到这个里面来?就是一个独立的一个功能,并且帮我把里面的这个人物列表编辑器内可以艾特的这个功能也放到编辑器里面,直接可以选择我,我直接可以选择相关已经配置好的那个已经配置好的人物跟配置好的一个链接,然后你现在帮我添加几个的这个链接,就是里面有提到的。比如卡洛,我们数据库里面的用户卡洛南风,对吧?还有远志这些已经提到的,并且那个超级个体如果成为超级个体,这个利表单也直接在这个里面数据帮我填写好已经是超级个体了,然后链接跟标题标签,比如神仙团队这些有提到的链接跟标签,你帮我写出来,帮我填写进去。 +编辑器副文本的那个编辑器里面,你把这两个 @ 跟人物列表的跟那个链接的。链接的这个是加上# 号的,这么加减号或者他已经是有家眷的这个功能就直接那个写上去,嗯。 \ No newline at end of file diff --git a/开发文档/1、需求/已完成/20260308内容管理4.md b/开发文档/1、需求/已完成/20260308内容管理4.md new file mode 100644 index 00000000..3d9bdb94 --- /dev/null +++ b/开发文档/1、需求/已完成/20260308内容管理4.md @@ -0,0 +1,10 @@ + +不用直接部署,直接修改,用中文回复我 + +需求一: +需要存克宝这篇提供的整链接下全站的需要存克宝这篇提供的相关的那个功能跟技术也写上去,写到那个文档里面,然后把这个相关的这个内容,这几天,这两天。7号、8号、9号修改了内容跟完成的内容都到这个项目管理的进度里面。然后把整个这个项目上传到 Git Hub 上面,gitea 跟 GitHub 上面 +i git Hub 上面把这个打开这个落地推荐表的页面以及存课宝的页面发给我。直接打开,直接在浏览器打开这两个 GitHub 上面上传成功之后这两个页面 + +功能一 +![](images/2026-03-09-05-35-24.png) +![](images/2026-03-09-05-36-51.png)这个主人公,这一个的话改一下,他这个就是链接的一一个功能,链接的一个功能。就是 ad 跟减号链接。链接人和事。链接 AI 跟这个名字应该改一下,链接 AI 跟事情。链接,AI,链接 AI 主人公,改成链接 AI。然后这里的话,主人公这边的话输入之后这个 ID 是可选项的,然后把那些默认 VIP 就默认到这个里面,这个变成一个标签,并且在那个副文本框是可以直接调取的。然后在小程序的前方也可以直接显示。然后这一个的话在主人公这个是属于 AI 列表,不叫主人公列表,这边就叫 AI 列表,然后这里面就写的是相应的等人物 ID,然后以及配置后端需要有一个配置,一个存客宝,哪一个存客宝的那个手机要么就是存克保指定的那个手。它配置跟纯克宝这边的那个计划是绑定的,捆绑的计划帮我把这个绑定的计划帮我艾特完之后,就是像我们首页链接卡洛一样,点击就直接可以那个添加过去,进到这个流量池里面来。然后这个点击的这个链接的这一个内容的流量词的列表有多少个人点击链接,它这里面有一个列表出来和链接出来这个列表底下,然后把这个上面像 VIP 跟那个几个刚刚提到的,上方提到的几个都优化迭代一下,把这个加上去。 \ No newline at end of file diff --git a/开发文档/1、需求/已完成/20260308找伙伴10.md b/开发文档/1、需求/已完成/20260308找伙伴10.md new file mode 100644 index 00000000..b26ff90c --- /dev/null +++ b/开发文档/1、需求/已完成/20260308找伙伴10.md @@ -0,0 +1,16 @@ + + +收复所有的错误,深度的理解,修复所有的错误,确保没有错误的运行 + +功能二 +image.png![](images/2026-03-08-16-48-36.png) +伙伴里面的这个匹配记录还加载还是失败,帮我分析并且处理一下这个问题。 + +功能一 +![](images/2026-03-08-16-47-03.png) +![](images/2026-03-08-16-47-11.png) + +存客宝场景api '/Users/karuo/Downloads/api_v1 (1).md'这个文档的内容也放到这个,放在这个存克宝里面,并且他要完善的实现这所有的那个场景获客的相关的内容,并且保证整个项目是正常运作的,以及获客的效率 + +这个存克保的这个功能,这标签是放到右上角,不是独立一个 type。然后这个找伙伴的这个里面的这一个,那个 AI 获客数据这里的话已提交线索跟有联系方式,这边是需要可以直接访问,那可以直接点击进入。点击进度,然后这个存克堡里面的相关的那个 TOKEN 和 API 的那个接口健全的东西是需要是可以直接使用的。需要是可以直接使用的,你把这个存克宝的那个。API 的那个格式,你帮我放到这个里面去。 +这个文档的内容也放到这个,放在这个存克宝里面,并且他要完善的实现这所有的那个场景获客的相关的内容,并且保证整个项目是正常运作的,以及获客的效率 \ No newline at end of file diff --git a/开发文档/1、需求/已完成/20260308找伙伴4.md b/开发文档/1、需求/已完成/20260308找伙伴4.md new file mode 100644 index 00000000..023e1019 --- /dev/null +++ b/开发文档/1、需求/已完成/20260308找伙伴4.md @@ -0,0 +1,13 @@ + + +功能三 匹配池 +![](images/2026-03-08-10-31-24.png) +匹配词里面的这个选择。匹配词里面的那个选,匹配词里面的这个选择,那可以,我可以点击的时候可以查看,比如我选匹配超级个体,我点击进去能看到具体有多少个人,然后完善资料用户有多少个人,然后全部无量词点击进去有多少人,这个是跟这个用户管理是打通的。 + +功能二 匹配功能 +小伙伴的这个功能里的那个标签,首先第一个标签是那个数据统计,第二个标签的话就是那个找伙伴,第三个标签是资源对接,第四个标签是导师预约,第五个标签是团队招募,然后把匹配词合并到匹配到找伙伴,匹配词跟匹配记录都合并到找伙伴的这个标签内。然后导师预约的那个导师管理那个加入到那个导师预约里面。 +![](images/2026-03-08-10-30-34.png) + +功能一 团队协助 +这一个待开发这一块的话,是写成这个文档存刻保的,这个待开发的发在放到这个开发文档的文档里面,咱们的那个项目管理的这个文档里面跟其他项目做对接的,不用写到代码以后,像这种都不要写在代码里面。确定了。 +![](images/2026-03-08-10-28-11.png) \ No newline at end of file diff --git a/开发文档/1、需求/已完成/20260308找伙伴5.md b/开发文档/1、需求/已完成/20260308找伙伴5.md new file mode 100644 index 00000000..8459c65b --- /dev/null +++ b/开发文档/1、需求/已完成/20260308找伙伴5.md @@ -0,0 +1,31 @@ + +/Users/karuo/Documents/开发/3、自营项目/一场soul的创业实验-永平/开发文档/10、项目管理/项目落地推进表.md + +然后将这些所有的那个开发的进度文档以后,都是要在那个项目文档,让那个都要在这个项目管理里面实时的这个进度推进跟完成程度都要放到这个进度的推进表里面,确定整个的这个。整个的这个项目是正常的在运转正常的那个进度,然后把我们的对话,今天的一个对话和主要的那个修改的一个板块都到列成这个项目管理里面,清楚的知道开发的时候内容。检查所有的功能的完善性跟可行性,然后继续的全力的帮我检查清楚,然后最终那个完善这个着火的这个功能 + +功能五 前后端 +![](images/2026-03-08-10-59-57.png)然后我刚才在直接在小伙伴这里填写了那个团队招募的这个板块,这个团队招募的这个板块甜甜姐填写了手机,但是这个填写的手机,但是后台并没有显示,是不是那个加入团队,加入项目改成加入团队,但这个里面并没有给我手机,并没有反馈到这里来检查一下这个具体的一些问题。到底什么原因?然后帮我查看清楚具体的一个原因。那每次匹配的过程当中,这些内容都需要的是能直接到后台,能直接看到这个匹配的手机号,以及相应的一些人。请小程序端跟这个后台端得是互通的 + + +功能四 +![](images/2026-03-08-10-56-15.png) +匹配记录放到前面,放到匹配词的设置的前面。 +![](images/2026-03-08-10-58-04.png) +然后每一次匹配。每一次匹配的记录。抖音和用户匹配的用户跟记录都要放到这个相应的那个记录里面。都要放到相应的记录里面,并且这个发起人他是可以直接点击,可以点击和匹配到,可以点击直接看到这个链接的这个人的一个链接的一个形式,以及能看到发起人的一个手机号的一个这个联系方式。然后如果是多次的话,多次匹配到同一个,同比较短的时间,多次匹配到同一个人的情况,那你就直接的就把这个多次匹配的同一个人。多次匹配的同一个人合并成一个,并且有一个下拉可以直接看到匹配了多少个人。防止匹配记录列表非常的得多。队友发起的那个匹配到。 + + +功能三 匹配拉群,ai自动化添加和数据反馈 + +然后把这个找伙伴这边那个,我们把指定的用户跟新增的用户做一个自动化的一个模块,比如他刚刚匹配清楚的话,就是那个存客宝这边就来负责帮他拉群,这个先检查一下存客宝的一个功能,负责来拉群,然后拉群完只有把他的那个信息推送上去。那匹配的同时,匹配成功的同时就是纯科宝来加他,如果不是好友就直接加他,然后直接拉取把这个功能实现一下,然后包括那个找伙伴资源对接、导师预约跟团队招募这几个都需要,然后需要一开官司拉群的开关,还是那个匹配的拉群的开关。还是直接加好友发信息的一个开关,然后加好友发信,加好友发止境指定的的消息也是可以直接在这个后台同存克宝这边的接口部来对接,然后如果没有这些接口,直接通知存克宝那边的开发团队来进行操作。 + +功能二 找伙伴功能修复 +![](images/2026-03-08-10-46-02.png) +![](images/2026-03-08-10-47-24.png) +老伙伴的这个功能,点击查看用户进去,不是,点击进去又是 VIP 会员,超级个体,然后这个完善资料点击进去就是完善资料的用户全部流量词,应该百分之改一下到全部选择是全部用户,这几个分别要进去,然后用户的那个资料完善的要有这些,第二个选择要有这一些资料完善的才能在匹配池那个找伙伴里面去那个找到这些钥匙。实现这个功能在小程序上面的相应的这个功能就必须得实现。并且确保这个功能是可用的,帮我检查一下,确保是可用的 +这个功能前,在前端找伙伴匹配的时候,如果匹配过一次,嗯,就不要再匹配第二次了,就不要再出现就匹配过的当天匹配过一次的那就没有第二次了。这个确定清楚,这个功能要清晰一些 +小程序这端的那个创意合伙人改成找伙伴,小程序这端的那个创业合伙改成找伙伴的这个够名字。 + +功能一 修复 添加 +这里的话点击测试这个手机号,还是没有加到这个计划里面,帮我 查清楚的一个问题,确定清楚这个问题。请确保前端这个功能是可用的,后台测试也是可以添加的,帮我深度的检查清楚这些,处理掉这些问题image.png +![](images/2026-03-08-10-43-44.png) +![](images/2026-03-08-10-44-05.png) \ No newline at end of file diff --git a/开发文档/1、需求/已完成/20260308找伙伴6.md b/开发文档/1、需求/已完成/20260308找伙伴6.md new file mode 100644 index 00000000..c1d158d4 --- /dev/null +++ b/开发文档/1、需求/已完成/20260308找伙伴6.md @@ -0,0 +1,16 @@ +拿着存克宝这边 API 显示的那个已存在的这个内容已存在,那这个已存在,像这里面的话只是不添加也要把这个表单添加到这个表单里面显示清楚,然后这个,嗯,下一步这里的话。把这些功能都给我完善清楚。 + +功能三 客户资源 +![](images/2026-03-08-11-19-38.png) + +![](images/2026-03-08-11-20-02.png) +就这个找伙伴的这一个功能,创业合伙这个要改成的就是找伙伴后台是修改什么样就是什么样的。然后这个团队招募这些图标跟那个相应的跟后台配置,后台配置是那个要相呼应是一样的创业合伙,这个叫找伙伴这个功能,然后点击加入到项目里面,填写手机号,得到后台上面去,后台也同时要显示这个标签,捆绑的同时要显示,比如说团队招募底下现在是没有添加任何的数据过来。这个有问题帮我检测一下,比如小程序这端跟这个跟后台不匹配,那其他的选项也是一样 +image.png![](images/2026-03-08-11-22-09.png)匹配记录,每一项里面都需要有匹配记录,然后也看一下这些匹配的那些相应的这些参数,帮我处理一下这个匹配的具体的一些数据。 + + +功能二 修复小程序匹配 +image.png![](images/2026-03-08-11-18-04.png) +这里的话那个资源对接,跟那个导师预约,跟团队招募这三个的那个匹配完之后,现在在小程序匹配完之后,现在并没有入库。的材料并没有入库,帮我处理一下一个问题,让我可以在后台能直接看到这个,那个匹配完之后的这个用户的联系形式,以及他的一个能点击进去能看到用户的一个旅程。那。 + +功能一 +![](images/2026-03-08-11-17-15.png)电池设置匹配词的那个来源是可以多多选的。可以同时选择两个,然后这个完整资料,完善资料的用户的话,这完善资料的用户点击进去不是全部用户,是真实有完善资料的,比如有名称、有头像,或者有其他的一些完善的一些材料,那基础的有这个应该是有手机号、有昵称、有头像的,然后有写业务需求的。就以跟线下,跟那个下面的那几个条件,符合这几个条件的一些用户的一个筛选,这是一个。 \ No newline at end of file diff --git a/开发文档/1、需求/已完成/20260308找伙伴7.md b/开发文档/1、需求/已完成/20260308找伙伴7.md new file mode 100644 index 00000000..8ace0dfc --- /dev/null +++ b/开发文档/1、需求/已完成/20260308找伙伴7.md @@ -0,0 +1,12 @@ + +功能三 +![](images/2026-03-08-11-32-34.png) +![](images/2026-03-08-11-32-54.png)度的检查一下这个问题,这个点击链接卡路并没有到这个瘦的右上角,早卡路加好友这里的那个已获客,并没有增加这个正常的话以获客,我点击进去输入这里一定会增加,并且去添加的这里并没有增加。帮我分析一下这个问题,直接帮我处理掉 + +功能二 +我在小程序匹配了好几次,就这里面的所有的总匹配次数,包含资源对接,导致预约团队高木只要有点击的都是会算在总匹配次数里面,并且可以看到具体的那个匹配的那个情况,然后匹配次数跟今日匹配,这些匹配用庸俗都是可以直接点击进去这些页面,帮我补全点。点击进去可以看得到。 +![](images/2026-03-08-11-31-27.png) + +功能一 +![](images/2026-03-08-11-30-23.png) +人善知要用户指的是已经有那个从图片上传或者微信上传头像的,并且昵称不是叫微信用户的昵称的,有改过昵称的行为的,以及绑定信息有手机号的这一些,这个是完善资料的用户。 \ No newline at end of file diff --git a/开发文档/1、需求/已完成/20260308找伙伴8.md b/开发文档/1、需求/已完成/20260308找伙伴8.md new file mode 100644 index 00000000..50e48b06 --- /dev/null +++ b/开发文档/1、需求/已完成/20260308找伙伴8.md @@ -0,0 +1,20 @@ +检查所有的,把这一个尽全力的完善,并且测试这个功能可用,然后帮我完善这个整个的项目。并且测试这个项目的所有的功能可用。那个在本地先测试,不需要,先不要编译到那个服务器上面,直接在本地上进行修改和完善这些功能 + +功能四 +![](images/2026-03-08-16-18-08.png)同时处理一下早早伙伴匹配记录加载失败的这个问题,然后在这里的话,那个纯客跑的配置放到这里,嗯,右上角的这里,从数据统计这里,把它接口联通测试这边给他移动过去。从接口连通测试跟存保的这个的场景,然后存保这边的获客的数据是可以直接点击进去的,以及可以看这个存保的这个那个接口的这个文档,这些都是可以要能点击进去,可以看得到相应的联系方式的。 + + +功能三 +image.png![](images/2026-03-08-16-14-58.png)![](images/2026-03-08-16-15-14.png) +![](images/2026-03-08-16-15-31.png)那个加入项目有匹配,但是在后台那个团队招募这一个里面,并且并没有任何的数据,请帮我一定要处理一下这个问题,其他的板块也是出现这个情况。 + +功能二 存客宝 +然后还有一个比较重要的一个功能,就是存克保这边的那个有匹配完之后存克保这里的相应的动作,在这个找伙伴功能的右上角,这里的话有一个存克保,这里的添加的是否添加成功和存车保相应的那个配置,还有存车保的那个接口的联通测试这几个板块都到小伙伴那找伙伴的右上角的那个标签功能里面。然后把存车保这里的各个场景获客以及相应的接口的数据,比如添加成功,是否有回复率等等的这一些参数都放到这个找伙伴的这个功能里面。如果这个功能根据这些文档的存,相应的文档不能是没有功能的话,直接给存稿这边的开发团队那个提需求,那尽可能的去搜索,并且帮我整理出这个需求出来,然后帮我继续往下去去执行。同时的数据统计的首页的数据对,在清晰一些,整个界面帮我清晰那个大气一点,那不要太太拥挤,分类清楚一点。分类跟那个东西补全一下 +/Users/karuo/Documents/开发/2、私域银行/cunkebao_v3 +![](images/2026-03-08-16-02-09.png) + +功能一 匹配机制 +![](images/2026-03-08-15-58-20.png) +![](images/2026-03-08-15-59-01.png) +![](images/2026-03-08-15-59-53.png) +这个匹配记录里面的话,第一个的话是创业合伙的这一个板块是跟后台要相互呼应,这个是找伙伴,并且每一次匹配都需要到图片2的那个后台里面,真相应的那个板块后台。这里得有正常的显示,发起人跟匹配到这个得正常的显示上面的每一个板块都得是正常的显示出来,你先要阅读完图片这几个所有的板块,那也有匹配,就要记录次数以及匹配相应的那个功能,就要记录到这个里面,然后把这个。然后在这个。今日匹配。的那个数据,这一些匹配的都是一些和这个相关的一些数据,已经匹配的类型也是相关的那个数据。更重要的是就是有点击这个用户的那个数据匹配数据,就立即要在这个后台这边显示清楚了,不然现在一直都是空的,帮我看一下具体是什么情况。那一定要帮我处理掉这个问题 \ No newline at end of file diff --git a/开发文档/1、需求/已完成/20260308找伙伴9md b/开发文档/1、需求/已完成/20260308找伙伴9md new file mode 100644 index 00000000..befef6b2 --- /dev/null +++ b/开发文档/1、需求/已完成/20260308找伙伴9md @@ -0,0 +1,25 @@ + + +收复所有的错误,深度的理解,修复所有的错误,确保没有错误的运行 + + + +功能六 +![](images/2026-03-08-16-36-11.png)那个首页的找伙伴里面的创业合伙人这个功能显示的是找伙伴的这个功能,并且这些在这个标签的名字在后台都是可以设置的,设置他们名称这个是叫找伙伴的功能,图标跟名字都可以在后台配置。把这个名字帮我改一下,并且这个选项跟后台的找伙伴的功能的选项是一定要是相呼应的,点击就要确定好,你深度的帮我理解和检查清楚这个,帮我解决这些所有的问题 + +功能五 +![](images/2026-03-08-16-34-58.png)的这几个选项都要可以添加的乘客宝的一个获客数据,就是不要写乘客宝,就是一个那个 AI 获客数据,那第一个的话是那个 AI 那个7KB 去掉就是已提交线索,就是三个,第二个有联系方式的就是三个。第一个的话是 AI 添加的程度,那点击进去的话就是看到 AI 添加的一个成功率以及回复率的这一些功能。然后把这个联系方式比例去掉,API 连接的这一个说明文档得可以点开,并且可以编辑这个 API 连接的这个文档。 + +功能四 +![](images/2026-03-08-16-33-49.png)把这个匹配收收益,匹配收益这个也帮我把这个同时也在首页的数据概览上里面显示。 + +功能三 +这个后台各个的匹配记录帮我测试清楚,并且看一下后台真正的匹配的这些匹配记录,刚刚有匹配的记录之后,帮我加到这个匹配记录团队,招募也好,导师预约也好,资源对接也好,匹配记录务必不要显示的人人零条,务必要有相应的那个数据显示出来。也帮我测试一下那个,帮我加几个电话号码进去。 + +功能二 存客宝 +image.png![](images/2026-03-08-16-32-02.png)所有的那个相应的接口跟功能跟场景获客的一个成功率的所有的东西不单单是测试,然后它也是一个独立的页面,不用,不是展开页。宝的描述跟需求,帮我把这个页面完善一下。阅读关于淳刻薄的所有描述跟需求,我们对话当中 + + +功能一 +![](images/2026-03-08-16-30-11.png) +![](images/2026-03-08-16-31-01.png)小伙伴的这个页面的话,匹配记录加载失败,加载有问题,帮我处理一下这个加载失败的这一个问题。那个皮,那个匹配词设置的话,那个匹配词的选择,这个完善资料的用户点击进去只有3个人的,实际只有3个人,但点击进去有很多他是全部用户的一个列表,这个帮我解读一下。 \ No newline at end of file diff --git a/开发文档/1、需求/已完成/20260308找伙伴功能.pdf b/开发文档/1、需求/已完成/20260308找伙伴功能.pdf new file mode 100644 index 00000000..30c1bd22 Binary files /dev/null and b/开发文档/1、需求/已完成/20260308找伙伴功能.pdf differ diff --git a/开发文档/1、需求/已完成/20260308找伙伴功能2.md b/开发文档/1、需求/已完成/20260308找伙伴功能2.md new file mode 100644 index 00000000..1f7159c0 --- /dev/null +++ b/开发文档/1、需求/已完成/20260308找伙伴功能2.md @@ -0,0 +1,36 @@ +# 需求文档标题 + +> 创建日期:YYYY-MM-DD +> 文档格式:Markdown(支持图片粘贴 + 预览) + +--- + +## 一、背景与目标 + +(在此输入文字,可直接粘贴图片) + +--- + +## 二、功能点 + +### 2.1 功能一 + + + +示例图片引用:`![描述](./images/截图1.png)` + +### 2.2 功能二 + +--- + +## 三、补充说明 + +(可继续粘贴图片和文字) + +--- + +## 使用提示 + +- **粘贴图片**:在 Cursor 中安装「Paste Image」扩展后,直接 Ctrl+V / Cmd+V 即可将剪贴板图片保存到 `images/` 并自动插入引用 +- **预览**:`Cmd+Shift+V` 或右侧「Open Preview」查看排版效果 + diff --git a/开发文档/1、需求/已完成/20260308找伙伴功能3.md b/开发文档/1、需求/已完成/20260308找伙伴功能3.md new file mode 100644 index 00000000..7dc91ae2 --- /dev/null +++ b/开发文档/1、需求/已完成/20260308找伙伴功能3.md @@ -0,0 +1,16 @@ + + +那个完成,并且帮我完整的完善这些功能,并且帮我那个整理清楚确保所有的功能是通的、可用的 + +功能三 找伙伴-存客宝 +![](images/2026-03-08-10-21-19.png) +然后这边存客宝的统计的话,就是这个匹配次数和匹配的用户和匹配的那个收益都写清楚,然后存客宝这边接口的一个一个的一些相应的这个功能测试完之后,比如这个接口这边的那个测试完之后,点击链接到卡洛,我点测试就可以添加一个测试的一个那个手机号。就我这个后台的这个用户的测试手机号,直接添加到这个指定的这个计划里面去所有的这个乘客宝接口联通测试这里有话都是需要去做这个方面的一个事情,并且我可以直接点击,然后那个包括那个匹配上报的这些功能。乘客那个找我们。那个,这个是属于那个数据统计匹配的数据统计,然后把纯科宝统计放到匹那个匹配词的那个前面,匹配词的标签前面,它是。然后把名字改成就是那个找伙伴统计,找伙伴的那个数据统计,然后把这个数据跟这几个标签做一个那个深度的一个融合,把这个数据统计的更清晰一些。然后这一些,把所有的这一些数据弄清楚,然后现有的能填充的数据已经有了,这个数据帮我完善清楚。 + +功能二 点击获客 +这个匹配词是可以让我随机让我找到那个匹配的这个里面的这个功能的,就筛选这个用户跟这个用户管理是打通的,有一个标签的一个选择找伙伴的这个功能。然后。然后不管是资源对接,还是导师预约,还是团队招募,这里面有人点击了和填写手机号了,这一个都是直接显示在这个页面下面的,并且直接触发纯课宝的添加,并且有纯课宝这边添加的一个成功率,这个纯课宝留存个宝这边的那个接口了,来负责那个整个的一个功能的一些完善。就把这一个,然后现有的那些数据,现有的这些数据有相关的,就直接把这个相关的数据帮我那个分析,并且导入到这个内容里面来。老路上这个内容里面的,然后把这个。把这个。的匹配到,然后联系方式,然后这里面的那个字段,除了发起人匹配到跟联系方式这一些这几个选项里面的一些功能和内容,还是需要那个有实际的添加,纯推广那边要有反馈的那个数据添加到哪一个接口里面,由这个场景获客的那个接口,有场景获客的那个接口都需要那个完善。都需要回馈一下数据,然后这个如果当前现在改不了,要把这个需求需要协作的存好,协作的需求做一个登记和记录,到时候要发给存客宝去做修改。以后我像这类型的需要纯客房跟那个神射手协助的需求都需要这么去操作 +![](images/2026-03-08-10-17-14.png)![](images/2026-03-08-10-18-28.png) + + +功能一 匹配池 +找伙伴的这个功能底下的话,要那个匹配的那个用户词要选择,可以选择那个超级个体付费1980的会员,然后也可以选择第二个选择的,这是一个流量词,第二个选择的流量词就是我们的那个在这边这里的话要写匹配那个词,里面要可以选择这一块。然后也可以选择那个完善程度的,比如已经完善了手机,那个手机密码,那不,手机,然后那个昵称和图标的用户,并且有写那个一人工写他的具体的一些业务的需求,完善的会员的材料的用户才可以去匹配掉,匹配到。他都吃完了,他都吃完了 +![](images/2026-03-08-10-08-47.png) \ No newline at end of file diff --git a/开发文档/1、需求/已完成/20260308用户管理.md b/开发文档/1、需求/已完成/20260308用户管理.md new file mode 100644 index 00000000..1f7159c0 --- /dev/null +++ b/开发文档/1、需求/已完成/20260308用户管理.md @@ -0,0 +1,36 @@ +# 需求文档标题 + +> 创建日期:YYYY-MM-DD +> 文档格式:Markdown(支持图片粘贴 + 预览) + +--- + +## 一、背景与目标 + +(在此输入文字,可直接粘贴图片) + +--- + +## 二、功能点 + +### 2.1 功能一 + + + +示例图片引用:`![描述](./images/截图1.png)` + +### 2.2 功能二 + +--- + +## 三、补充说明 + +(可继续粘贴图片和文字) + +--- + +## 使用提示 + +- **粘贴图片**:在 Cursor 中安装「Paste Image」扩展后,直接 Ctrl+V / Cmd+V 即可将剪贴板图片保存到 `images/` 并自动插入引用 +- **预览**:`Cmd+Shift+V` 或右侧「Open Preview」查看排版效果 + diff --git a/开发文档/1、需求/已完成/20260308用户管理2.md b/开发文档/1、需求/已完成/20260308用户管理2.md new file mode 100644 index 00000000..0c619d29 --- /dev/null +++ b/开发文档/1、需求/已完成/20260308用户管理2.md @@ -0,0 +1,39 @@ +# 需求文档标题 + +> 创建日期:YYYY-MM-DD +> 文档格式:Markdown(支持图片粘贴 + 预览) + +--- + +## 一、背景与目标 + +(在此输入文字,可直接粘贴图片) + + + +--- + +## 二、功能点 + +### 2.1 功能一 + +(文字 + 可粘贴的截图、原型图) + +示例图片引用:`![描述](./images/截图1.png)` + +### 2.2 功能二 + + + +--- + +## 三、补充说明 + +(可继续粘贴图片和文字) + +--- + +## 使用提示 + +- **粘贴图片**:在 Cursor 中安装「Paste Image」扩展后,直接 Ctrl+V / Cmd+V 即可将剪贴板图片保存到 `images/` 并自动插入引用 +- **预览**:`Cmd+Shift+V` 或右侧「Open Preview」查看排版效果 diff --git a/开发文档/1、需求/已完成/20260308用户管理3.md b/开发文档/1、需求/已完成/20260308用户管理3.md new file mode 100644 index 00000000..0c619d29 --- /dev/null +++ b/开发文档/1、需求/已完成/20260308用户管理3.md @@ -0,0 +1,39 @@ +# 需求文档标题 + +> 创建日期:YYYY-MM-DD +> 文档格式:Markdown(支持图片粘贴 + 预览) + +--- + +## 一、背景与目标 + +(在此输入文字,可直接粘贴图片) + + + +--- + +## 二、功能点 + +### 2.1 功能一 + +(文字 + 可粘贴的截图、原型图) + +示例图片引用:`![描述](./images/截图1.png)` + +### 2.2 功能二 + + + +--- + +## 三、补充说明 + +(可继续粘贴图片和文字) + +--- + +## 使用提示 + +- **粘贴图片**:在 Cursor 中安装「Paste Image」扩展后,直接 Ctrl+V / Cmd+V 即可将剪贴板图片保存到 `images/` 并自动插入引用 +- **预览**:`Cmd+Shift+V` 或右侧「Open Preview」查看排版效果 diff --git a/开发文档/1、需求/已完成/README_需求文档格式说明.md b/开发文档/1、需求/已完成/README_需求文档格式说明.md new file mode 100644 index 00000000..f403efe0 --- /dev/null +++ b/开发文档/1、需求/已完成/README_需求文档格式说明.md @@ -0,0 +1,75 @@ +# 需求文档格式说明 + +> 本目录支持 **Markdown(.md)** 格式,可在 Cursor 中直接粘贴图片并预览。 + +--- + +## 为什么用 Markdown + +| 能力 | 说明 | +|:-----------|:-------------------------------------------------| +| 粘贴图片 | 配合扩展可 Ctrl+V / Cmd+V 直接粘贴剪贴板图片 | +| 预览 | Cursor 内置 Markdown 预览,`Cmd+Shift+V` 即可 | +| 版本管理 | 纯文本 + 图片文件,方便 Git 追踪 | +| 跨平台 | 任意编辑器可编辑,导出 PDF/HTML 也方便 | + +--- + +## 使用方法 + +### 1. 新建文档 + +- 复制 `_模板_需求文档.md`,重命名为你的文档名(如 `20260308找伙伴功能.md`) +- 或直接新建 `.md` 文件 + +### 2. 粘贴图片 + +**方式一:配合扩展(推荐)** + +1. 在 Cursor 中安装扩展:`Paste Image` 或 `Markdown Paste` +2. 截屏或复制图片到剪贴板 +3. 在 `.md` 文件中按 `Ctrl+V`(Mac:`Cmd+V`) +4. 扩展会自动将图片保存到 `images/` 并插入 `![描述](images/xxx.png)` + +**方式二:手动** + +1. 将图片放入本目录下的 `images/` 文件夹 +2. 在文档中插入:`![图片描述](./images/文件名.png)` + +### 3. 预览 + +- **快捷键**:`Cmd+Shift+V`(Mac)或 `Ctrl+Shift+V`(Windows) +- **右键**:编辑器内右键 → 「Open Preview」 +- 卡若AI 规则已配置 Markdown Preview Enhanced,可直接查看排版 + +--- + +## 目录约定 + +``` +修改/ +├── README_需求文档格式说明.md ← 本说明 +├── _模板_需求文档.md ← 可复制的模板 +├── images/ ← 粘贴的图片存放于此 +│ └── .gitkeep +├── 20260308找伙伴功能.md ← 你的需求文档 +└── *.pdf / *.pages ← 仍可保留原格式作归档 +``` + +--- + +## 扩展安装(如需粘贴图片) + +在 Cursor 扩展市场搜索并安装其一: + +- **Paste Image**:`naumovs.paste-image` +- **Markdown Paste**:支持粘贴图片并生成 Markdown 引用 + +**Paste Image 路径配置**(可选):在 `settings.json` 中添加,使图片保存到当前目录的 `images/` 下: + +```json +{ + "pasteImage.path": "${currentFileDir}/images", + "pasteImage.basePath": "${currentFileDir}" +} +``` diff --git a/开发文档/1、需求/需求日志 b/开发文档/1、需求/需求日志 new file mode 100644 index 00000000..fb51815d --- /dev/null +++ b/开发文档/1、需求/需求日志 @@ -0,0 +1,9 @@ +20260223 + +那个在我的里面,我的足迹里面最近阅读的这个章节要写清楚章节的那个名称,小杰的名称得写上去。然后这个。推广中心改成我的收益,然后把这个推广中心我的收益,然后上面显示的是我的收益有多少钱?把推广中心这一个我的收益改到这个界面,就名昵称的下方购买章节推荐函好友,然后那个带领收益,这个改成我的收益,然后把推广中心去掉,然后把账号设置。账号设置。也移到这个,我的那个资料的那个里面,这个界面上面。精选队推荐这边的话,首页上精选推荐,这里选择的是后端的那个文章的那个阅读量,文章的阅读量,然后把这个文章的相应的那个阅读做一个阅读的一个点击的一个记录,后台文章得有一个点击的一个记录。然后把手页里面的这个内容预览去掉,首页内容预览去掉,这个就是只有一个目录。只有一个目录,然后这边的话是一个那个。内容预览去掉,改成首页,上面改成那个有名字的,有填写名字的和联系方式的,是那个。创业老板排行,然后显示一排带头像、带图标、带名字的显示一排。四个显示一排是有名字跟图像,那后鼠标然后点击进去的话,就是它的一个详细材料,就优秀会员的一个板块。 + +然后在一个主要就是他就是那个管理开发文档的用的,然后把整个那个开发文档直至保留这个10个目录。开发文档只有这4个目录,其他的文件文档就整合到这个10个目录底下,然后这个 skill 还需要整理的一个内容,就是把每一次我们对话提问的一个需求放到一个那个需求的表里面,那我知道每天这个更改的和我们对话的更改的那个季度的一个需求。把这个提示词对话的内容整理一下放到里面,那需要有具体的时间的节点往下去开发。 + +在后台里面你新增一个会员的一个填写的一个表格,购买完之后会员的权利还可以被匹配,以及那个就一年365天的一个权利吗?然后这个365天的权利可以看所有的章节,然后可以有匹配所有的那些客户,我让别人能知道你的项目的一个业务情况。然后。这个就变成一个 VIP 的一个选项,也是在增加会员的话,就是头像就不一样,正常就是你的头像在我的里面,头像是灰色的,那会员 VIP 的一个框框是灰色的,那点击之后进去就是会变成那个 VIP 亮色的一个头像出来 + +然后帮我把这一版那个。最终要实现这个小程序跟后端是匹配的,以及数据是匹配的一个情况,最终上传上去可以保证整个网站是可以正常使用,确保在正常使用的情况下来做优化和迭代。然后 \ No newline at end of file diff --git a/开发文档/1、需求/需求汇总.md b/开发文档/1、需求/需求汇总.md index 8be19f14..190e197c 100644 --- a/开发文档/1、需求/需求汇总.md +++ b/开发文档/1、需求/需求汇总.md @@ -1,14 +1,5 @@ # 需求汇总(合并自 业务需求、技术需求、需求方案汇总、需求日志、卡若角色设定) -## 需求基准(必读) - -**需求以《[以界面定需求](以界面定需求.md)》为准,以界面定需求。** -- 小程序、管理端各界面及主要接口见该文档第二、三节。 -- 业务逻辑对齐(用户/VIP 资料展示、三端 API 边界、免费章与 VIP、分销提现等)见该文档第四节。 -- 新增或变更功能时,先对齐界面与接口,再在本文档需求清单中补充或更新条目。 - ---- - ## 业务需求 项目目标、成本、技术要求(见原业务需求、技术需求)。 @@ -46,6 +37,3 @@ IP 设定、风格、输出规范(见原卡若角色设定)。 | 2026-02 | VIP 设置入口拆分:用户列表「设置 VIP」按钮 + 独立弹窗 | 已完成 | UserDetailModal 移除 VIP 区块;SetVipModal 独立 | | 2026-02 | VIP 排序:后付款/后设置在前;支持手动排序 | 已完成 | vip_activated_at、vip_sort;VipMembers 排序逻辑 | | 2026-02 | VIP 角色:可选择 + 可手动填写 | 已完成 | vip_roles 表;VIP 角色管理页;SetVipModal 角色下拉 | -| 2026-03-08 | 文章阅读付费规则:免费章节以 free_chapters 为准;VIP 全章免费 | 已完成 | soul-api book.go 合并 free_chapters;check-purchased 已支持 VIP | -| 2026-03-10 | 小程序「我的」页阅读统计改为后端接口(真实数据) | 已完成 | my.js loadDashboardStats;soul-api GET /api/miniprogram/user/dashboard-stats | -| 2026-03-10 | 富文本渲染升级(TipTap HTML → rich-text 组件,保留 @mention 交互) | 待实施 | 确认 DB 内容格式后实施;当前 contentParser.js 为纯文本剥除 | diff --git a/开发文档/2、架构/Gin技术栈-Go1.25依赖清单.md b/开发文档/2、架构/Gin技术栈-Go1.25依赖清单.md new file mode 100644 index 00000000..696456fc --- /dev/null +++ b/开发文档/2、架构/Gin技术栈-Go1.25依赖清单.md @@ -0,0 +1,120 @@ +# Gin 技术栈依赖清单(适配 Go 1.25.7) + +**目标版本**:Go 1.25.7 +**原则**:精简、高效、易上手、好用、安全;所有依赖均兼容 Go 1.25,无需更换或移除。 + +--- + +## 一、Go 版本说明 + +- Go 1.25 于 2025 年 8 月发布,遵守 Go 1 兼容性承诺,现有主流库均可使用。 +- **Gin** 官方要求 Go 1.24+,1.25.7 满足要求。 +- **golang.org/x/\***(crypto、time 等)随 Go 工具链维护,支持当前稳定版。 +- 若某依赖未显式声明支持 1.25,只要其 `go.mod` 为 `go 1.21` 或更高,在 1.25 下均可正常编译使用。 + +--- + +## 二、依赖列表(均适配 Go 1.25.7) + +### 1. 核心与数据库 + +| 依赖 | 版本建议 | 说明 | +|------|----------|------| +| `github.com/gin-gonic/gin` | 最新 v1.x | 要求 Go 1.24+,1.25.7 兼容。 | +| `gorm.io/gorm` | 最新 v1.31.x | 无对高版本 Go 的限制。 | +| `gorm.io/driver/mysql` | 最新 | 与 GORM 配套。 | + +### 2. 安全 + +| 依赖 | 版本建议 | 说明 | +|------|----------|------| +| `github.com/unrolled/secure` | v1.17+ | 标准 net/http 中间件,兼容 Go 1.25。 | +| `golang.org/x/crypto` | 最新 | 使用 `bcrypt` 等,随 Go 生态更新。 | +| `golang.org/x/time` | 最新 | 使用 `rate` 限流,兼容 Go 1.25。 | + +### 3. 配置 + +| 依赖 | 版本建议 | 说明 | +|------|----------|------| +| `github.com/joho/godotenv` | v1.5.x | 仅读 .env,无高版本 Go 要求。 | +| 或 `github.com/caarlos0/env/v11` | v11.x | 解析 env 到结构体,兼容当前 Go。 | + +### 4. 跨域与鉴权 + +| 依赖 | 版本建议 | 说明 | +|------|----------|------| +| `github.com/gin-contrib/cors` | v1.6+(务必 ≥1.6,修复 CVE) | 与 Gin 1.24+ / Go 1.25 兼容。 | +| `github.com/golang-jwt/jwt/v5` | 最新 v5.x | 推荐 v5,与 Go 1.25 兼容。 | + +### 5. 接口文档(可选) + +| 依赖 | 版本建议 | 说明 | +|------|----------|------| +| `github.com/swaggo/swag/cmd/swag` | 最新(CLI 工具) | 代码生成,使用最新 CLI 即可。 | +| `github.com/swaggo/gin-swagger` | 最新 | 与 Gin 配套。 | +| `github.com/swaggo/files` | 最新 | Swagger UI 静态资源。 | + +### 6. 开发工具(仅开发环境) + +| 依赖 | 版本建议 | 说明 | +|------|----------|------| +| `github.com/cosmtrek/air` | 最新 | 热重载,与 Go 1.25 兼容。 | + +--- + +## 三、无需更换或移除 + +- 上述依赖在 Go 1.25.7 下**均无需更换或移除**。 +- 未列入的冗余依赖(如单独再引入 validator、Viper、zap 等)按此前「精简版」建议已不纳入,无需因 Go 1.25 再改。 + +--- + +## 四、推荐 go.mod 片段(Go 1.25) + +在项目根目录执行: + +```bash +go mod init soul-server +go mod edit -go=1.25 +``` + +然后按需拉取依赖(示例): + +```bash +go get github.com/gin-gonic/gin +go get gorm.io/gorm gorm.io/driver/mysql +go get github.com/unrolled/secure +go get golang.org/x/crypto golang.org/x/time +go get github.com/gin-contrib/cors +go get github.com/golang-jwt/jwt/v5 +go get github.com/joho/godotenv +# 可选 +go get github.com/swaggo/gin-swagger github.com/swaggo/files +# 开发 +go install github.com/cosmtrek/air@latest +go install github.com/swaggo/swag/cmd/swag@latest +``` + +--- + +## 五、验证方式 + +在 soul-server 目录下执行: + +```bash +go mod tidy +go build ./... +``` + +若通过,则当前依赖与 Go 1.25.7 兼容。若某库报错,优先升级该库至最新 minor/patch 再试。 + +--- + +## 六、小结 + +| 项目 | 结论 | +|------|------| +| Go 1.25.7 | 支持,所有推荐依赖均适用。 | +| 需要更换的依赖 | 无。 | +| 需要移除的依赖 | 无(按本清单与精简原则已不包含不必要项)。 | +| 建议 | 使用 `go 1.25`,定期 `go get -u ./...` 与 `go mod tidy` 保持依赖健康。 | diff --git a/开发文档/2、架构/soul-api技术栈.md b/开发文档/2、架构/soul-api技术栈.md new file mode 100644 index 00000000..2a479f92 --- /dev/null +++ b/开发文档/2、架构/soul-api技术栈.md @@ -0,0 +1,54 @@ +# soul-api Go 技术栈 + +## 语言与运行时 + +- **Go 1.25** + +## Web 框架与 HTTP + +- **Gin**(`github.com/gin-gonic/gin`):HTTP 路由与请求处理 +- **gin-contrib/cors**:跨域 +- **unrolled/secure**:安全头(HTTPS 重定向、HSTS 等,在 `middleware.Secure()` 中使用) + +## 数据层 + +- **GORM**(`gorm.io/gorm`):ORM +- **GORM MySQL 驱动**(`gorm.io/driver/mysql`):连接 MySQL +- **go-sql-driver/mysql**:底层 MySQL 驱动(GORM 间接依赖) + +## 微信生态 + +- **PowerWeChat**(`github.com/ArtisanCloud/PowerWeChat/v3`):微信开放能力(小程序、支付、商家转账等) +- **PowerLibs**(`github.com/ArtisanCloud/PowerLibs/v3`):PowerWeChat 依赖 + +## 配置与环境 + +- **godotenv**(`github.com/joho/godotenv`):从 `.env` 加载环境变量 +- 业务配置集中在 `internal/config`,通过 `config.Load()` 读取 + +## 鉴权与安全 + +- **golang-jwt/jwt/v5**:管理端 JWT 签发与校验(`internal/auth/adminjwt.go`) +- 管理端路由使用 `middleware.AdminAuth()` 做 JWT 校验 + +## 工具与间接依赖 + +- **golang.org/x/time**:时间/限流相关(如 `rate`) +- **gin-contrib/sse**:SSE(Gin 间接) +- **bytedance/sonic**:JSON 编解码(Gin 默认) +- **go-playground/validator**:请求体校验(Gin 的 `ShouldBindJSON` 等) +- **redis/go-redis**:仅在依赖图中出现(PowerWeChat 等间接引入),项目代码中未直接使用 Redis + +## 项目结构(技术栈视角) + +| 层级 | 技术/约定 | +|----------|------------| +| 入口 | `cmd/server/main.go`,标准库 `net/http` + Gin | +| 路由 | `internal/router`,Gin Group(`/api`、`/admin`、`/miniprogram` 等) | +| 中间件 | CORS、Secure、限流(`middleware.RateLimiter`)、管理端 JWT | +| 业务逻辑 | `internal/handler`,GORM + `internal/model` | +| 数据访问 | `internal/database` 提供 `DB() *gorm.DB`,统一用 GORM | +| 微信相关 | `internal/wechat`(小程序、支付、转账等封装) | +| 开发工具 | `.air.toml` 热重载、Makefile | + +整体上是一个 **Gin + GORM + MySQL + 微信 PowerWeChat + JWT 管理端鉴权** 的 Go 后端,面向小程序与管理端 API。 diff --git a/开发文档/2、架构/系统与技术.md b/开发文档/2、架构/系统与技术.md new file mode 100644 index 00000000..e244edb3 --- /dev/null +++ b/开发文档/2、架构/系统与技术.md @@ -0,0 +1,15 @@ +# 系统与技术(合并自 系统架构、技术选型与全景图、前后端架构分离策略、数据库) + +## 核心理念 + +** separation**:内容与代码分离、前后端分离、静态与动态分离。架构围绕「省事」和「变现」。 + +**技术栈**:Next.js 14/16 App Router、TypeScript、Tailwind、Shadcn UI、Zustand、MySQL/MongoDB、Vercel/宝塔部署。 + +**内容即产品**:`book/` Markdown 为资产,Git 管理,文件系统读取。 + +**数据库**:见 `数据库.md`,表结构、连接配置。 + +## 前后端架构分离 + +开发协作规范、API 边界、部署拆分策略。 diff --git a/开发文档/2、架构/链路与变现.md b/开发文档/2、架构/链路与变现.md new file mode 100644 index 00000000..011a24b1 --- /dev/null +++ b/开发文档/2、架构/链路与变现.md @@ -0,0 +1,19 @@ +# 链路与变现(合并自 链路优化与运行指南、变现模块设计) + +## 链路总览 + +``` +后台鉴权 → 进群(支付后跳转) → 营销策略(推广/活码/配置) → 支付(下单→回调→到账) +``` + +**运行**:`pnpm dev` 或 `pnpm build` + `node .next/standalone/server.js`,端口 3006。 + +**配置**:`GET /api/config` 拉取配置,admin / key123456 鉴权,登出 `POST /api/admin/logout`。 + +## 变现模块 + +- **支付模块**:Order、PaymentProvider,微信/支付宝对接 +- **营销模块**:Campaign、MarketingService,弹窗、Banner、转化 +- **分销模块**:ReferralCode、ReferralService,邀请码、佣金计算 + +详见原《链路优化与运行指南》《变现模块设计》。 diff --git a/开发文档/3、原型/原型设计规范.md b/开发文档/3、原型/原型设计规范.md new file mode 100644 index 00000000..d3a604c6 --- /dev/null +++ b/开发文档/3、原型/原型设计规范.md @@ -0,0 +1,575 @@ +# 原型设计规范 + +**我是卡若。** + +这个文档是写给设计师和前端开发看的。咱们的项目特点很明确:**移动端优先,iOS风格,极致阅读体验**。 + +--- + +## 一、设计原则 + +### 1.1 移动端优先 +- 90%的用户是从微信、Soul、朋友圈进来的,都是手机 +- 设计稿必须先出手机版,再适配PC +- 断点设置:375px (iPhone SE) / 414px (iPhone 14 Pro Max) + +### 1.2 iOS风格 +- 圆角:16px / 20px / 24px (统一使用这3个值) +- 阴影:`box-shadow: 0 4px 12px rgba(0,0,0,0.08)` +- 字体:San Francisco (iOS) / PingFang SC (安卓) +- 间距:8px的倍数系统 (8 / 16 / 24 / 32 / 48) + +### 1.3 简洁至上 +- 每个页面只有1个主要操作按钮 +- 减少选择,降低决策成本 +- 文字能说清楚的,就别用图 + +--- + +## 二、核心页面原型 + +### 2.1 首页 (Home) + +**功能目标**: 3秒内让用户知道这是什么书,并产生购买欲望 + +**布局结构**: +\`\`\` +[Hero区域] +- 书籍封面 (3D效果) +- 标题:《一场Soul的创业实验》 +- 副标题:真实的商业案例库 +- 作者:卡若 +- 价格标签:¥9.9 (限时优惠) +- 主按钮:立即阅读 + +[数据统计卡片] +- 已购买人数: 128人 +- 阅读人次: 1,234次 +- 好评率: 98% + +[最新章节快捷入口] +- 横向滚动卡片 +- 每张卡片显示:章节号 + 标题 + 标签(免费/付费) + +[Soul派对群推广横幅] +- 背景:渐变色 +- 文案:每天早上6-9点,Soul派对房不见不散 +- 按钮:加入派对 + +[底部导航栏] +- 首页 | 目录 | 我的 +\`\`\` + +**交互细节**: +- 向下滚动时,顶部导航栏自动隐藏 +- 点击书籍封面,可放大预览 +- 点击"立即阅读",跳转到目录页 + +**设计稿尺寸**: 375x812 (iPhone X) + +--- + +### 2.2 目录页 (Chapters) + +**功能目标**: 清晰展示书籍结构,引导用户阅读 + +**布局结构**: +\`\`\` +[顶部] +- 返回按钮 +- 标题:目录 +- 全书购买按钮 + +[篇章结构] +第一篇 | 真实的人 + ├─ 第1章 | 人与人之间的底层逻辑 + │ ├─ 1.1 自行车荷总... [免费] + │ ├─ 1.2 老墨... [1元] [锁] + │ └─ ... + ├─ 第2章 | 人性困境案例 + │ └─ ... + +第二篇 | 真实的行业 + └─ ... +\`\`\` + +**视觉设计**: +- 篇章标题:粗体,16px,品牌色渐变 +- 章节标题:常规,14px,深灰色 +- 免费标签:绿色小标签 +- 付费标签:橙色小标签 + 锁图标 +- 定时解锁:灰色小标签 + 倒计时 + +**交互细节**: +- 点击免费章节,直接进入阅读 +- 点击付费章节,弹出购买弹窗 +- 点击已购买章节,进入阅读 +- 长按章节,可以分享给好友 + +--- + +### 2.3 阅读页 (Read) + +**功能目标**: 沉浸式阅读体验,零干扰 + +**布局结构**: +\`\`\` +[顶部工具栏] (可隐藏) +- 返回按钮 +- 进度条 (当前位置/总长度) +- 目录按钮 + +[正文区域] +- 标题 +- 作者 + 发布时间 +- Markdown渲染内容 + - 标题层级 + - 段落 + - 引用块 + - 代码块 + - 图片 + - 列表 + +[底部工具栏] (可隐藏) +- 上一章 +- 目录按钮 +- 下一章 +- 分享按钮 +\`\`\` + +**视觉设计**: +- 字体大小:16px (可调) +- 行高:1.8 +- 段落间距:24px +- 左右边距:24px +- 背景:#FAFAFA (浅灰) 或 #1C1C1E (深色模式) + +**交互细节**: +- 点击屏幕中央,显示/隐藏工具栏 +- 向上滚动,自动隐藏工具栏 +- 阅读到30%时,弹出"扫码解锁全文"弹窗 +- 阅读完成,自动跳转到下一章 + +--- + +### 2.4 我的页面 (My) + +**功能目标**: 用户中心 + 分销中心 + +**布局结构**: +\`\`\` +[用户信息卡片] +- 头像 +- 昵称 +- 手机号 +- 我的邀请码:REFXXXX (点击复制) + +[阅读统计] +- 已购买章节: 12章 +- 阅读时长: 3小时28分 +- 阅读进度: 45% + +[分销中心] (重点突出) +- 背景:渐变色卡片 +- 我的收益: ¥256.80 +- 待提现: ¥128.90 +- 已提现: ¥127.90 +- 推荐人数: 28人 +- 按钮:推广海报生成 | 立即提现 + +[功能菜单] +- 我的订单 +- 购买记录 +- 分享记录 +- 设置 +\`\`\` + +**交互细节**: +- 点击邀请码,自动复制 +- 点击"推广海报生成",生成专属海报 +- 点击"立即提现",弹出提现弹窗 + +--- + +### 2.5 匹配书友页 (小程序独有) + +**功能目标**: 类Soul星球的匹配功能,增加社交属性 + +**布局结构**: +\`\`\` +[星空背景] +- Canvas动画 +- 星星闪烁效果 +- 星球漂浮效果 + +[中央区域] +- 星球图标 (旋转动画) +- 按钮:开始匹配 +- 提示文字:当前在线 128 人 + +[匹配中] +- 光环扩散动画 +- 提示文字:正在寻找志同道合的书友... + +[匹配成功] +- 用户头像 +- 昵称 +- 兴趣标签 +- 匹配度:85% +- 共同兴趣:创业、私域运营、AI +- 按钮:打个招呼 + +[匹配历史] +- 横向滚动 +- 显示最近10次匹配记录 +\`\`\` + +**视觉设计**: +- 背景:深蓝色渐变 (#1A1A2E -> #16213E) +- 星球:渐变色球体 + 光晕效果 +- 卡片:毛玻璃效果 + 圆角 + 阴影 +- 动画:流畅的过渡效果 + +--- + +## 三、组件设计规范 + +### 3.1 按钮 (Button) + +**主按钮** (Primary): +\`\`\`css +background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); +color: #FFFFFF; +height: 48px; +border-radius: 24px; +font-size: 16px; +font-weight: 600; +\`\`\` + +**次按钮** (Secondary): +\`\`\`css +background: #FFFFFF; +border: 1px solid #E5E7EB; +color: #374151; +height: 48px; +border-radius: 24px; +\`\`\` + +**文字按钮** (Text): +\`\`\`css +background: transparent; +color: #667eea; +text-decoration: underline; +\`\`\` + +### 3.2 输入框 (Input) + +\`\`\`css +height: 48px; +border: 1px solid #E5E7EB; +border-radius: 12px; +padding: 0 16px; +font-size: 14px; +background: #FFFFFF; +\`\`\` + +**聚焦状态**: +\`\`\`css +border-color: #667eea; +box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1); +\`\`\` + +### 3.3 卡片 (Card) + +\`\`\`css +background: #FFFFFF; +border-radius: 16px; +box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08); +padding: 24px; +\`\`\` + +**悬停效果**: +\`\`\`css +transform: translateY(-4px); +box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12); +transition: all 0.3s ease; +\`\`\` + +### 3.4 骨架屏 (Skeleton) + +\`\`\`css +background: linear-gradient( + 90deg, + #F3F4F6 25%, + #E5E7EB 50%, + #F3F4F6 75% +); +background-size: 200% 100%; +animation: loading 1.5s infinite; +border-radius: 8px; +\`\`\` + +--- + +## 四、弹窗设计 + +### 4.1 支付弹窗 + +**触发时机**: 用户点击"购买"按钮 + +**内容**: +\`\`\` +[标题] 选择支付方式 + +[支付方式列表] +○ 微信支付 (推荐) +○ 支付宝 +○ USDT (TRC20) +○ PayPal + +[商品信息] +- 商品:第1章 | 人与人之间的底层逻辑 +- 价格:¥1.00 + +[按钮] +- 确认支付 (主按钮) +- 取消 (次按钮) +\`\`\` + +### 4.2 登录弹窗 + +**触发时机**: 未登录用户点击购买或分享 + +**内容**: +\`\`\` +[标题] 手机号登录 + +[输入框] +- 手机号输入框 +- 验证码输入框 (带倒计时按钮) + +[邀请码输入框] (可选) +- 提示:填写邀请码,推荐人可获得佣金 + +[按钮] +- 登录 / 注册 (主按钮) +- 暂不登录 (文字按钮) +\`\`\` + +### 4.3 二维码弹窗 + +**触发时机**: 阅读到30%或点击"加入派对" + +**内容**: +\`\`\` +[标题] 扫码加入Soul派对群 + +[二维码图片] +- 尺寸:200x200 +- 下方文字:长按识别二维码 + +[按钮] +- 我知道了 +\`\`\` + +--- + +## 五、颜色规范 + +### 5.1 主色调 + +\`\`\` +品牌主色 (Primary): +- 主色:#667EEA +- 深色:#5A67D8 +- 浅色:#7F9CF5 + +辅助色 (Secondary): +- 成功:#10B981 (绿色) +- 警告:#F59E0B (橙色) +- 错误:#EF4444 (红色) +- 信息:#3B82F6 (蓝色) +\`\`\` + +### 5.2 中性色 + +\`\`\` +文字颜色: +- 标题:#111827 (深灰) +- 正文:#374151 (中灰) +- 辅助:#6B7280 (浅灰) + +背景颜色: +- 主背景:#FFFFFF (白色) +- 次背景:#F9FAFB (浅灰) +- 卡片背景:#FFFFFF (白色) +\`\`\` + +### 5.3 深色模式 + +\`\`\` +背景: +- 主背景:#1C1C1E +- 次背景:#2C2C2E +- 卡片背景:#3A3A3C + +文字: +- 标题:#FFFFFF +- 正文:#E5E5EA +- 辅助:#98989D +\`\`\` + +--- + +## 六、字体规范 + +### 6.1 字体系统 + +\`\`\`css +font-family: + -apple-system, /* iOS */ + BlinkMacSystemFont, /* macOS */ + 'Segoe UI', /* Windows */ + 'PingFang SC', /* 中文简体 */ + 'Hiragino Sans GB', /* macOS 中文 */ + 'Microsoft YaHei', /* Windows 中文 */ + sans-serif; +\`\`\` + +### 6.2 字号规范 + +\`\`\` +特大标题:32px / 36px (权重: 700) +大标题:24px / 28px (权重: 600) +中标题:20px / 24px (权重: 600) +小标题:18px / 22px (权重: 500) +正文:16px / 24px (权重: 400) +辅助文字:14px / 20px (权重: 400) +小字:12px / 18px (权重: 400) +\`\`\` + +--- + +## 七、动画规范 + +### 7.1 过渡动画 + +\`\`\`css +/* 标准过渡 */ +transition: all 0.3s ease; + +/* 快速过渡 */ +transition: all 0.15s ease; + +/* 慢速过渡 */ +transition: all 0.5s ease; +\`\`\` + +### 7.2 加载动画 + +**骨架屏**: +\`\`\`css +@keyframes loading { + 0% { background-position: -200% 0; } + 100% { background-position: 200% 0; } +} +\`\`\` + +**旋转加载**: +\`\`\`css +@keyframes spin { + from { transform: rotate(0deg); } + to { transform: rotate(360deg); } +} +\`\`\` + +### 7.3 页面切换动画 + +**滑动进入** (iOS风格): +\`\`\`css +@keyframes slideIn { + from { + transform: translateX(100%); + opacity: 0; + } + to { + transform: translateX(0); + opacity: 1; + } +} +\`\`\` + +--- + +## 八、响应式断点 + +\`\`\`css +/* 手机 (默认) */ +@media (max-width: 640px) { ... } + +/* 平板 */ +@media (min-width: 641px) and (max-width: 1024px) { ... } + +/* 桌面 */ +@media (min-width: 1025px) { ... } +\`\`\` + +--- + +## 九、设计交付规范 + +### 9.1 设计稿命名 + +\`\`\` +格式:页面名称-设备-版本号.fig +示例: +- 首页-Mobile-v1.0.fig +- 目录页-Mobile-v1.0.fig +- 阅读页-Mobile-v1.0.fig +\`\`\` + +### 9.2 切图规范 + +\`\`\` +命名:功能-类型-尺寸.png +示例: +- button-primary-normal@2x.png +- icon-lock-24x24@2x.png +- cover-book-400x600@2x.png +\`\`\` + +### 9.3 标注规范 + +- 所有间距必须标注 +- 字体大小和行高必须标注 +- 颜色使用十六进制色值 +- 圆角、阴影参数必须标注 + +--- + +## 十、参考案例 + +### 10.1 iOS原生风格 +- **Settings App** (iOS系统设置) +- **Apple Books** (苹果图书) +- **Notion** (笔记应用) + +### 10.2 阅读类产品 +- **微信读书** +- **得到App** +- **小宇宙播客** + +### 10.3 社交匹配类 +- **Soul** +- **探探** +- **Tinder** + +--- + +**总结**: 原型设计不是为了好看,是为了让用户"不用想就知道怎么做"。简洁、清晰、高效,这就是我们的设计原则。 + +--- + +**更新时间**: 2025年1月14日 +**负责人**: 卡若 +**设计工具**: Figma diff --git a/开发文档/4、前端/02-AI分析-长图.png b/开发文档/4、前端/02-AI分析-长图.png new file mode 100644 index 00000000..ec6b7929 Binary files /dev/null and b/开发文档/4、前端/02-AI分析-长图.png differ diff --git a/开发文档/4、前端/03-数据市场-长图.png b/开发文档/4、前端/03-数据市场-长图.png new file mode 100644 index 00000000..41e0d198 Binary files /dev/null and b/开发文档/4、前端/03-数据市场-长图.png differ diff --git a/开发文档/4、前端/04-标签画像-长图.png b/开发文档/4、前端/04-标签画像-长图.png new file mode 100644 index 00000000..cbe3fc19 Binary files /dev/null and b/开发文档/4、前端/04-标签画像-长图.png differ diff --git a/开发文档/4、前端/05-估值模型-长图.png b/开发文档/4、前端/05-估值模型-长图.png new file mode 100644 index 00000000..d25f099f Binary files /dev/null and b/开发文档/4、前端/05-估值模型-长图.png differ diff --git a/开发文档/4、前端/06-设置-长图.png b/开发文档/4、前端/06-设置-长图.png new file mode 100644 index 00000000..e0822c3e Binary files /dev/null and b/开发文档/4、前端/06-设置-长图.png differ diff --git a/开发文档/4、前端/07-文档-长图.png b/开发文档/4、前端/07-文档-长图.png new file mode 100644 index 00000000..98d0e15c Binary files /dev/null and b/开发文档/4、前端/07-文档-长图.png differ diff --git a/开发文档/4、前端/08-登录-长图.png b/开发文档/4、前端/08-登录-长图.png new file mode 100644 index 00000000..fa2361fc Binary files /dev/null and b/开发文档/4、前端/08-登录-长图.png differ diff --git a/开发文档/4、前端/09-流量池-长图.png b/开发文档/4、前端/09-流量池-长图.png new file mode 100644 index 00000000..1411eb44 Binary files /dev/null and b/开发文档/4、前端/09-流量池-长图.png differ diff --git a/开发文档/4、前端/ui/01-概述与页面.md b/开发文档/4、前端/ui/01-概述与页面.md new file mode 100644 index 00000000..1f2020c4 --- /dev/null +++ b/开发文档/4、前端/ui/01-概述与页面.md @@ -0,0 +1,31 @@ +# 概述与页面(合并自 01-项目概述、02-页面功能说明) + +## 项目简介 + +基于 Next.js 16 的知识付费+分销系统:电子书阅读与付费、创业伙伴匹配、90%高佣分销、用户中心。 + +**技术栈**:Next.js 16 / React 19 / TypeScript / Tailwind / Zustand / shadcn/ui | 后端:Next.js API、MySQL、微信支付 + +**项目结构**:app/(页面+API)、components/(ui + modules)、lib/(store、book-data)、book/ + +## 核心功能模块 + +| 模块 | 说明 | 路径 | +|:---|:---|:---| +| 首页 | 书籍介绍、购买入口 | `/` | +| 目录 | 章节列表、付费状态 | `/chapters` | +| 阅读 | 文章内容、购买弹窗 | `/read/[id]` | +| 找伙伴 | 四种匹配类型 | `/match` | +| 我的 | 个人中心、收益 | `/my` | +| 分销中心 | 推广、提现 | `/my/referral` | +| 管理后台 | 数据管理 | `/admin` | + +## 页面功能概要 + +- **首页**:封面、简介、立即阅读/购买全书、底部导航 +- **目录页**:62章、折叠结构、免费/已购/未购状态 +- **阅读页**:文章渲染、付费墙、上下篇、分享 +- **找伙伴**:创业合伙/资源对接/导师/团队招募 +- **我的**:登录、个人信息、购买记录、推广中心 + +**定价**:单章 ¥1,全书 ¥9.9,分销 90% diff --git a/开发文档/4、前端/ui/02-组件与系统.md b/开发文档/4、前端/ui/02-组件与系统.md new file mode 100644 index 00000000..521209c9 --- /dev/null +++ b/开发文档/4、前端/ui/02-组件与系统.md @@ -0,0 +1,31 @@ +# 组件与系统(合并自 03-09) + +## 组件清单 + +**UI 基础**:Button、Card、Input、Label、Textarea、Switch、Tabs + +**业务模块**:AuthModal、PaymentModal、PosterModal、WithdrawalModal、AutoWithdrawModal、ChapterContent + +## API 接口 + +基础路径 `/api`,主要模块:book、payment、referral、user、match、admin、config + +## 状态管理 + +Zustand + localStorage,全局 store 含用户、购买、配置等 + +## 分销系统 + +推广中心、邀请码、绑定关系、90% 佣金、提现 + +## 找伙伴 + +创业合伙/资源对接/导师顾问/团队招募,匹配规则与配置 + +## 支付系统 + +微信/支付宝,PaymentModal 弹窗,支付回调与订单状态 + +## 管理后台 + +仪表盘、内容管理、用户管理、支付配置、二维码、提现审核、系统设置 diff --git a/开发文档/4、前端/ui/03-部署与截图.md b/开发文档/4、前端/ui/03-部署与截图.md new file mode 100644 index 00000000..e5b208ba --- /dev/null +++ b/开发文档/4、前端/ui/03-部署与截图.md @@ -0,0 +1,23 @@ +# 部署与截图(合并自 10-11) + +## 部署指南 + +**环境**:Node >= 20,MySQL >= 8 + +**本地开发**:`npm install` → `npm run dev` → http://localhost:3000 + +**环境变量**:.env.local 配置 DATABASE_URL、CKB_API_KEY、WECHAT_* + +**生产构建**:`npm run build` → `npm start` 或 PM2 + +## 设计规范(截图还原) + +**颜色**:主色 #00CED1,辅助色 gold/green/orange/red/purple,背景 #000/#1c1c1e + +**字体**:标题 18–24px,正文 14px,辅助 12px + +**圆角**:按钮 12px,卡片 16px,头像 50% + +**页面尺寸**:375×812(iPhone 标准) + +详见原 10-部署上线指南、11-页面截图与还原指南 完整内容。 diff --git a/开发文档/4、前端/前端开发规范.md b/开发文档/4、前端/前端开发规范.md new file mode 100644 index 00000000..4f155cb0 --- /dev/null +++ b/开发文档/4、前端/前端开发规范.md @@ -0,0 +1,56 @@ +# 前端开发规范 (Frontend Specs) - 智能自生长文档 + +> **提示词功能 (Prompt Function)**: 将本文件拖入 AI 对话框,即可激活“前端技术专家”角色,生成符合 iOS 风格的 React 代码。 + +## 1. 基础上下文 (The Two Basic Files) +### 1.1 角色档案:卡若 (Karuo) +- **视觉标准**:像素级复刻 iOS (San Francisco, 1:1 间距, 弥散阴影)。 +- **体验标准**:无白屏 (Skeleton),丝滑转场 (Transition)。 + +### 1.2 技术栈 +- **核心**:React + Shadcn UI + Tailwind CSS。 +- **辅助**:Vant UI (移动端组件)。 +- **构建**:Vite / Next.js。 + +## 2. 开发规范核心 (Master Content) +### 2.1 视觉与风格 (iOS) +- **字体**:San Francisco > PingFang SC。 +- **色彩**: + - 背景:`#F2F2F7` (Grouped Background)。 + - 分割:`#C6C6C8`。 + - 交互:`#007AFF` (System Blue)。 +- **细节**: + - 圆角:统一 `rounded-lg` 或 `rounded-xl`。 + - 阴影:柔和弥散,非生硬投影。 + +### 2.2 交互与性能 (Mandatory) +- **骨架屏**:数据加载必须显示 Skeleton,严禁 Spinner。 +- **转场**:路由切换必须有动画。 +- **图片**:懒加载 + 失败占位。 + +### 2.3 目录结构 +- `/src/components`: 原子组件。 +- `/scenarios/new`: 场景获客页。 +- `/src/hooks`: 逻辑复用。 + +## 3. AI 协作指令 (Expanded Function) +**角色**:你是我(卡若)的前端主程。 +**任务**: +1. **代码生成**:生成 React 组件代码,**必须**包含 Tailwind 类名。 +2. **样式检查**:确保所有 UI 元素符合 iOS 规范(检查圆角、阴影、字体)。 +3. **结构分析**:用 Mermaid 展示组件依赖。 + +### 示例 Mermaid (组件结构) +\`\`\`mermaid +classDiagram + Page <|-- Header + Page <|-- Content + Page <|-- Footer + Content <|-- SkeletonLoader + Content <|-- DataList + DataList <|-- ListItem + class Page{ + +state: loading + +effect: fetchData() + } +\`\`\` diff --git a/开发文档/4、前端/前端架构.md b/开发文档/4、前端/前端架构.md new file mode 100644 index 00000000..2d2779b7 --- /dev/null +++ b/开发文档/4、前端/前端架构.md @@ -0,0 +1,94 @@ +# 前端架构 + +**我是卡若。** + +前端就是项目的脸。用户不管是通过朋友圈、抖音还是私域进来,第一眼看到的就是这个页面。如果加载慢、长得丑、滑动卡,人家转头就走,我的流量就浪费了。 + +所以,前端的核心目标只有一个:**极致的移动端阅读体验,像原生 App 一样丝滑。** + +## 1. 技术底座 + +别跟我说什么技术先进,我要的是**稳**和**快**。 + +- **框架**: Next.js 14 (App Router) - 必须用最新的 App Router,路由管理更清晰。 +- **语言**: TypeScript - 必须用 TS,类型安全,少出低级 Bug。 +- **样式**: Tailwind CSS - 写样式最快,没有之一。配合 `globals.css` 做全局控制。 +- **UI 组件库**: Shadcn UI (基于 Radix UI) + Vant UI (风格参考)。 + - *注意*:我们要像素级复刻 iOS 风格,字体用 San Francisco,圆角、阴影都要对齐。 + +## 2. 目录结构(我的地盘) + +前端代码主要集中在 `app/` 和 `components/`。 + +\`\`\` +app/ +├── (routes)/ # 路由组,逻辑隔离 +│ ├── page.tsx # 首页:封面、简介、购买按钮 +│ ├── chapters/ # 目录页:章节列表 +│ ├── read/[id]/ # 阅读页:核心体验区 +│ ├── my/ # 个人中心:购买记录、分销 +│ ├── admin/ # 管理后台:给自己用的 +│ └── documentation/ # 文档生成:内部工具 +├── layout.tsx # 全局布局:导航栏、SEO Meta +├── globals.css # 全局样式 +└── error.tsx # 错误处理页面 + +components/ +├── ui/ # 通用组件 (Button, Input, Skeleton) +├── modules/ # 业务模块组件 (新增) +│ ├── auth/ # 认证模块 (AuthModal) +│ ├── payment/ # 支付模块 (PaymentModal) +│ ├── marketing/ # 营销模块 (QRCodeModal) +│ └── referral/ # 分销模块 (ReferralShare) +├── book-cover.tsx # 书籍封面展示 +├── chapter-content.tsx # 章节内容渲染器 +├── bottom-nav.tsx # 底部导航栏 (手机端核心) +└── theme-provider.tsx # 主题管理 (深色/浅色模式) +\`\`\` + +## 2.1 业务模块化 (Modularization) + +为了支持“云阿米巴”模式的快速迭代,我们将核心业务逻辑封装为独立模块: + +- **支付模块 (Payment)**: 统一管理微信、支付宝、USDT 等支付方式,支持整书/单章购买。 +- **营销模块 (Marketing)**: 负责引流(如二维码弹窗、倒计时Banner),连接私域流量池。 +- **分销模块 (Referral)**: 负责裂变传播(如分享按钮、返利计算),让用户帮我们卖书。 +- **认证模块 (Auth)**: 统一的用户登录与权限校验。 + +这种设计允许我们在不修改页面核心逻辑的情况下,插拔不同的变现策略。 + +## 3. 核心交互设计 + +### 3.1 骨架屏 (Skeleton) +**规则**:凡是需要加载数据的地方,必须先展示骨架屏。 +- 用户不能看白屏,哪怕等 0.5 秒,也要让他看到“东西正在来”的样子。 +- 强制引入 `Skeleton` 组件。 + +### 3.2 路由动画 (Transition) +**规则**:页面切换不能生硬地跳。 +- 使用 Framer Motion 或 CSS Transition。 +- 模拟 iOS 的滑动切换或淡入淡出。 + +### 3.3 阅读体验 +- **字体**:针对不同设备优化,保证字号适中,行间距舒服(建议 1.6-1.8)。 +- **图片**:懒加载 (Lazy Load),点击可放大预览。 +- **代码块**:虽然是书,但如果有代码,要有高亮和复制按钮。 + +## 4. 数据获取 (Fetching) + +- **服务端组件 (Server Components)**: + - `page.tsx`, `read/[id]/page.tsx` 默认都是服务端组件。 + - 直接在组件内 `await` 获取数据(通过 `lib/book-data.ts`),SEO 极佳。 +- **客户端组件 (Client Components)**: + - 需要交互的(点击、弹窗、状态变化),头部加 `'use client'`。 + - 比如 `auth-modal.tsx`, `purchase-section.tsx`。 + +## 5. 待办事项 (Todo) + +- [ ] 全局引入 Skeleton,替换掉所有的 `Loading...` 文字。 +- [ ] 检查所有页面的 Mobile 适配,在 Chrome 开发者工具里用 iPhone SE 和 iPhone 14 Pro Max 两个尺寸测。 +- [ ] 优化字体栈,确保在安卓上也不难看。 + +--- +**总结**: +前端不仅是写代码,是**做产品**。每一个像素的偏移都影响用户的信任感。把细节抠好,转化率自然就高了。 diff --git a/开发文档/4、前端/当前小程序开发细则.md b/开发文档/4、前端/当前小程序开发细则.md new file mode 100644 index 00000000..1aad3fe1 --- /dev/null +++ b/开发文档/4、前端/当前小程序开发细则.md @@ -0,0 +1,160 @@ +# 当前小程序开发细则 + +> 汇总当前 Soul 创业派对小程序的架构、经验与规划,便于新人上手与后续迭代。 +> 最后整理:2026-02 + +--- + +## 一、概述与定位 + +- **产品**:Soul 创业派对 — 微信小程序,内容为《一场 SOUL 的创业实验场》章节阅读 + 找伙伴 + 分销。 +- **技术**:原生微信小程序(非 uni-app / Taro),与 Next.js 后端同仓,接口统一走 `apiBase`(如 `https://soul.quwanzhi.com`)。 +- **核心能力**:章节阅读(免费/付费)、单章/全书支付、邀请码分销、找伙伴(匹配次数购买)、推广中心、我的订单/设置。 + +--- + +## 二、目录与页面结构 + +### 2.1 目录结构(miniprogram/) + +``` +miniprogram/ +├── app.js / app.json / app.wxss # 入口、全局配置、样式 +├── custom-tab-bar/ # 自定义底部 tabBar +├── pages/ +│ ├── index/ # 首页(推荐章节、已读统计) +│ ├── chapters/ # 目录(全书章节列表) +│ ├── read/ # 阅读页(核心:权限、支付、分享) +│ ├── match/ # 找伙伴(匹配 + 购买次数) +│ ├── my/ # 我的(入口:订单、推广、设置) +│ ├── referral/ # 推广中心(邀请码、收益、海报) +│ ├── purchases/ # 我的订单(当前为本地已购章节列表) +│ ├── settings/ # 设置(提现、绑定账号等) +│ ├── search/ # 搜索 +│ ├── about/ # 关于 +│ └── addresses/ # 地址(若启用) +├── utils/ +│ ├── chapterAccessManager.js # 章节权限与状态 +│ ├── readingTracker.js # 阅读进度追踪 +│ ├── payment.js # 旧支付封装(部分场景仍用) +│ └── util.js +└── assets/ # 图标等静态资源 +``` + +### 2.2 TabBar 与主要页面 + +| Tab | 页面 | 说明 | +|-----|------|------| +| 首页 | pages/index/index | 推荐章节、已读/待读、入口到阅读 | +| 目录 | pages/chapters/chapters | 全书章节列表 | +| 找伙伴 | pages/match/match | 匹配 + 购买匹配次数 | +| 我的 | pages/my/my | 已读/已购、推广中心、订单、设置 | + +非 Tab 页:阅读页 read、推广中心 referral、订单 purchases、设置 settings、搜索 search、关于 about。 + +### 2.3 全局状态(app.js globalData) + +- `userInfo`:登录后用户信息(id、openId、nickname、purchasedSections、hasFullBook、referralCode、referralCount 等)。 +- `openId` / `isLoggedIn`:微信登录态。 +- `readSectionIds`:已读章节 ID 列表(有权限打开全文时打点)。 +- `pendingReferralCode`:待绑定推荐码(带 ref 进入时写入,登录后绑定)。 +- `apiBase`:后端 API 根地址。 + +--- + +## 三、核心流程与经验 + +### 3.1 阅读与章节权限 + +- **权威数据源**:章节是否可读以**服务端**为准(`/api/user/check-purchased`、`/api/user/purchase-status`),不依赖前端缓存做最终判断。 +- **权限状态**:设计上支持 `unknown / free / locked_not_login / locked_not_purchased / unlocked_purchased / error`(见《章节阅读付费标准流程设计》);阅读页通过 `chapterAccessManager` 与 `determineAccessState` 等做状态判断。 +- **免费章节**:来自后端配置(如 `/api/db/config` 的 freeChapters),页面 onLoad 时拉取最新免费列表再判断;首帧可用本地默认 freeIds,拉取完成后需能刷新当前章状态,避免竞态误判。 +- **已读 vs 已购**: + - **已读**:仅统计“有权限打开并看到全文”的章节(`canAccess=true` 时 `app.markSectionAsRead(sectionId)`),存 `readSectionIds`。 + - **已购**:来自服务端 `userInfo.purchasedSections`、`hasFullBook` 及 orders 表,用于付费墙与购买按钮展示。 +- **登录后防误解锁**:登录成功(含支付流程中登录)后必须 `refreshPurchaseFromServer()`,再对当前章节做 `recheckCurrentSectionAndRefresh()`(先拉最新免费列表,再请求 check-purchased),避免“刚登录”时误用旧缓存解锁付费章。 +- **内容接口**:当前 `GET /api/book/chapter/[id]` 不校验登录与购买,前端按 `canAccess` 控制展示全文或预览;若未来开放 Web/API,建议章节接口侧做鉴权。 + +详见:`开发文档/8、部署/章节阅读付费标准流程设计.md`。 + +### 3.2 支付流程(章节 + 找伙伴) + +- **统一入口**:章节支付 `pages/read/read.js` 调 `POST /api/miniprogram/pay`;找伙伴支付 `pages/match/match.js` 同样调该接口,传 `productType: 'match'`。 +- **订单先行**:支付前**必须先创建订单**并插入 `orders` 表(status=`created`),再调微信统一下单;即使插库失败也继续支付流程,避免用户卡在“创建订单失败”。 +- **请求体约定**:`openId`、`userId`、`productType`(section/fullbook/match)、`productId`、`amount`、`description`;**必须带 `referralCode`**(见下节)。 +- **支付成功**:依赖微信回调 `POST /api/miniprogram/pay/notify` 更新订单为 `paid`、解锁用户权限、分佣、清理同产品未支付订单;前端支付成功后调用 `refreshUserPurchaseStatus()` 再 `initSection()` 刷新当前页。 +- **兜底**:若回调丢失,依赖**订单状态同步定时任务**(如每 5 分钟调 `GET /api/cron/sync-orders`)查询微信侧状态并同步到本地 orders,保证最终一致。详见 `开发文档/8、部署/宝塔面板配置订单同步定时任务.md`。 + +### 3.3 邀请码与分销(必传、必记) + +- **绑定逻辑**:带 `ref` 或 `referralCode` 的链接进入 → `app.js` 的 `handleReferralCode` 写入 `pendingReferralCode` 并**同步写入 `referral_code`**(`wx.setStorageSync('referral_code', refCode)`);登录后调用 `/api/referral/bind` 完成绑定(30 天有效、可续期/抢夺)。 +- **支付必带邀请码**:章节支付、找伙伴支付创建订单时都要传 `referralCode`,来源为 `wx.getStorageSync('referral_code')`;后端据此(或先查 referral_bindings)写入订单的 `referrer_id` 与 **`referral_code`**(下单时使用的邀请码,便于对账与后台展示)。 +- **订单表字段**:`orders.referrer_id`(推荐人用户ID)、`orders.referral_code`(下单时邀请码)。若表尚未加字段,需执行 `scripts/add_orders_referrer_id.py`、`scripts/add_orders_referral_code.py`。 +- **推荐人 vs 邀请码**:全局只认「推荐人 = 用户ID」;邀请码仅用于解析出 referrer_id,不会混用。分佣以 `referral_bindings` 为准,不依赖订单上的 referrer_id。详见 `开发文档/8、部署/邀请码分销规则说明.md`。 + +### 3.4 分享与落地 + +- 阅读页分享:`onShareAppMessage` / `onShareTimeline` 带 `id=章节ID&ref=当前用户邀请码`,落地后 ref 写入 storage,绑定与订单归属同上。 +- 文章/章节分销与全局同一套:不按“哪篇文章带来”单独分成或统计,仅按“谁发的链接(ref=谁)”归属。 + +--- + +## 四、数据与接口约定 + +### 4.1 关键接口 + +| 接口 | 用途 | +|------|------| +| POST /api/miniprogram/login | 微信登录,返回 userInfo(含 purchasedSections、referralCode 等) | +| GET /api/user/purchase-status | 拉取购买状态(已购章节、全书) | +| GET /api/user/check-purchased | 校验指定章节/全书是否已购买 | +| POST /api/miniprogram/pay | 创建订单 + 微信预支付,**需传 referralCode** | +| POST /api/miniprogram/pay/notify | 微信支付回调(服务端) | +| GET /api/cron/sync-orders | 订单状态同步(定时任务,需 secret) | +| POST /api/referral/bind | 绑定推荐关系 | +| GET /api/db/config | 免费章节等配置 | + +### 4.2 Storage 约定 + +- `referral_code`:落地 ref 或 app 检测到 ref 时写入;支付时读取并传后端。 +- `pendingReferralCode` / `boundReferralCode`:待绑定/已绑定推荐码(app 层)。 +- `readSectionIds`:已读章节 ID 列表。 +- `openId`、用户信息等由 app 与登录逻辑维护。 + +--- + +## 五、已知问题与修复要点 + +- **免费章节配置竞态**:onLoad 时若未 await 免费列表再 initSection,首帧可能用默认 freeIds 误判;建议先拉配置再判断当前章,或拉取完成后对当前页再刷一次权限。 +- **check-purchased 失败降级**:失败时应**保守**设为无权限(不信任本地缓存),避免误解锁。 +- **支付回调丢失**:必须部署订单同步定时任务(如宝塔 crontab 调 `/api/cron/sync-orders`),否则会出现“已扣款但订单仍 created、内容未解锁”。 +- **订单表缺字段**:新环境或老库需执行 `add_orders_referrer_id.py`、`add_orders_referral_code.py`,否则下单可能 fallback 成不写这两列(功能仍可用,但订单无推荐人/邀请码记录)。 + +--- + +## 六、部署与运维 + +- **后端**:Next.js 部署至 soul.quwanzhi.com,小程序 `app.globalData.apiBase` 指向该域名。 +- **订单同步**:生产环境配置 crontab 每 5 分钟请求 `GET /api/cron/sync-orders?secret=YOUR_SECRET`(如宝塔定时任务),保证回调丢失时仍能同步为 paid 并解锁。见 `开发文档/8、部署/宝塔面板配置订单同步定时任务.md`。 +- **数据库**:orders 表需含 `referrer_id`、`referral_code`;若为已有表,执行上述两个 Python 迁移脚本。 +- **小程序发布**:按微信后台流程上传代码、提交审核;注意域名白名单、支付商户号与回调 URL 配置。 + +--- + +## 七、规划与待办(可选) + +- **我的订单页**:当前 `purchases` 页为本地已购章节列表;若需“真实订单列表+邀请码展示”,可对接 `GET /api/orders?userId=xxx` 并展示订单维度数据。 +- **阅读进度**:已设计阅读进度状态与 `readingTracker`、可上报服务端;是否全量接入与埋点可按产品需求推进。 +- **章节接口鉴权**:若开放 Web 或对外 API,建议在章节内容接口侧按用户与购买记录返回全文/预览,防止直连拿全文。 +- **按文章/章节维度的分销统计**:当前未实现;若需要“某章节带来的访问/订单数”,需在访问或订单上增加来源章节等字段并在报表中汇总。 + +--- + +## 八、相关文档索引 + +| 文档 | 说明 | +|------|------| +| 开发文档/8、部署/邀请码分销规则说明.md | 分销规则、订单 referrer_id/referral_code、推荐人 vs 邀请码 | +| 开发文档/8、部署/章节阅读付费标准流程设计.md | 阅读状态机、权限判断、阅读进度设计 | +| 开发文档/4、前端/ui/06-分销系统说明.md | 分销规则与推广方式 | +| 开发文档/4、前端/ui/08-支付系统说明.md | 支付方式与价格体系 | diff --git a/开发文档/4、前端/模块详解.md b/开发文档/4、前端/模块详解.md new file mode 100644 index 00000000..849bfcac --- /dev/null +++ b/开发文档/4、前端/模块详解.md @@ -0,0 +1,721 @@ +# 前端模块详解 - Soul创业实验项目 + +> **核心模块**: 首页、匹配、阅读、我的、支付、分销 + +**我是卡若。** + +这里记录每个前端模块的实现细节,方便以后维护和扩展。 + +--- + +## 1. 首页模块 + +**路径**: `/app/page.tsx` + +### 1.1 核心功能 + +```typescript +export default function HomePage() { + return ( +
      + {/* 1. 品牌标签 */} + + + {/* 2. 书籍封面 */} + + + {/* 3. 核心数据 */} + + + {/* 4. 作者信息 */} + + + {/* 5. 行动按钮 */} + + + {/* 6. 寄语卡片 */} + + + {/* 7. 章节列表 */} + +
      + ) +} +``` + +### 1.2 关键组件 + +**书籍封面**: +```typescript +function BookCover({ src }: { src: string }) { + return ( +
      + 书籍封面 + {/* 3D效果 */} +
      +
      + ) +} +``` + +**数据亮点**: +```typescript +function DataHighlights({ price, cases, insights }: Props) { + return ( +
      +
      +
      + {price} +
      +
      全书价格
      +
      +
      +
      + {cases} +
      +
      商业案例
      +
      +
      +
      + {insights} +
      +
      商业洞察
      +
      +
      + ) +} +``` + +--- + +## 2. 匹配模块 + +**路径**: `/app/match/page.tsx` + +### 2.1 核心功能 + +```typescript +export default function MatchPage() { + const [isMatching, setIsMatching] = useState(false) + const [matchResult, setMatchResult] = useState(null) + + const handleMatch = async () => { + setIsMatching(true) + // 模拟匹配过程 + await new Promise(resolve => setTimeout(resolve, 2000)) + setMatchResult({ + name: '创业者小王', + mbti: 'ENTJ', + interests: ['私域运营', '内容创业'], + matchRate: 85 + }) + setIsMatching(false) + } + + return ( +
      + {/* 星空背景 */} + + + {/* 中央星球 */} + + + {/* 标题 */} +

      + 寻找创业合作伙伴 +

      + + {/* 匹配按钮或结果 */} + {!matchResult ? ( + + ) : ( + + )} + + {/* 快捷操作 */} + {}} + onJoinGroup={() => {}} + /> +
      + ) +} +``` + +### 2.2 关键组件 + +**星空背景**: +```typescript +function StarfieldBackground() { + const canvasRef = useRef(null) + + useEffect(() => { + const canvas = canvasRef.current + const ctx = canvas?.getContext('2d') + if (!canvas || !ctx) return + + // 创建星星 + const stars = Array.from({ length: 100 }, () => ({ + x: Math.random() * canvas.width, + y: Math.random() * canvas.height, + radius: Math.random() * 2, + opacity: Math.random() + })) + + // 绘制动画 + function animate() { + ctx.clearRect(0, 0, canvas.width, canvas.height) + stars.forEach(star => { + ctx.beginPath() + ctx.arc(star.x, star.y, star.radius, 0, Math.PI * 2) + ctx.fillStyle = `rgba(255, 255, 255, ${star.opacity})` + ctx.fill() + }) + requestAnimationFrame(animate) + } + animate() + }, []) + + return +} +``` + +--- + +## 3. 阅读模块 + +**路径**: `/app/read/[id]/page.tsx` + +### 3.1 核心功能 + +```typescript +export default async function ReadPage({ params }: Props) { + const { id } = params + const section = await getSection(id) + + if (!section) { + notFound() + } + + return ( +
      + {/* 返回按钮 */} + + + {/* 章节标题 */} +

      + {section.title} +

      + + {/* 章节信息 */} + + + {/* Markdown内容 */} + + + {/* 章节导航 */} + + + {/* 分享按钮 */} + +
      + ) +} +``` + +### 3.2 Markdown渲染 + +```typescript +import { marked } from 'marked' + +function MarkdownContent({ content }: { content: string }) { + const html = marked(content) + + return ( +
      + ) +} + +// CSS样式 +.prose { + @apply text-gray-300 leading-relaxed; +} + +.prose h1 { + @apply text-3xl font-bold text-white mt-8 mb-4; +} + +.prose h2 { + @apply text-2xl font-bold text-white mt-6 mb-3; +} + +.prose p { + @apply mb-4; +} + +.prose ul { + @apply list-disc list-inside mb-4; +} + +.prose code { + @apply bg-gray-800 px-2 py-1 rounded text-[var(--app-brand)]; +} +``` + +--- + +## 4. 我的模块 + +**路径**: `/app/my/page.tsx` + +### 4.1 核心功能 + +```typescript +export default function MyPage() { + const { user, isLoggedIn } = useStore() + + if (!isLoggedIn) { + return + } + + return ( +
      + {/* 用户信息卡片 */} + + + {/* 阅读统计 */} + + + {/* 分销中心(重点突出) */} + + + {/* 功能菜单 */} + +
      + ) +} +``` + +### 4.2 分销中心 + +```typescript +function ReferralCenter({ code, earnings, referralCount }: Props) { + return ( +
      +

      分销中心

      + + {/* 收益概览 */} +
      +
      +
      + ¥{earnings.toFixed(2)} +
      +
      累计收益
      +
      +
      +
      + {referralCount} +
      +
      推荐人数
      +
      +
      + + {/* 邀请码 */} +
      + +
      + + +
      +
      + + {/* 生成海报 */} + +
      + ) +} +``` + +--- + +## 5. 支付模块 + +**路径**: `/components/payment-modal.tsx` + +### 5.1 核心流程 + +```typescript +export function PaymentModal({ + isOpen, + amount, + type, + onSuccess +}: Props) { + const [paymentMethod, setPaymentMethod] = useState('alipay') + const [showQRCode, setShowQRCode] = useState(false) + const [isProcessing, setIsProcessing] = useState(false) + + // 发起支付 + const handlePayment = async () => { + setShowQRCode(true) + + // 调用支付API + const order = await createOrder({ + amount, + type, + paymentMethod + }) + + // 展示支付二维码 + showPaymentQRCode(order.qrCode) + } + + // 确认支付 + const confirmPayment = async () => { + setIsProcessing(true) + + // 购买逻辑 + const success = await purchaseItem(type) + + if (success) { + onSuccess() + // 自动跳转到读者群 + openWechatGroup() + } + + setIsProcessing(false) + } + + return ( + + {!showQRCode ? ( + + ) : ( + + )} + + ) +} +``` + +### 5.2 支付方式组件 + +```typescript +function PaymentMethodSelection({ selected, onSelect, onConfirm }: Props) { + const methods = [ + { + id: 'wechat', + name: '微信支付', + icon: , + color: '#07C160' + }, + { + id: 'alipay', + name: '支付宝', + icon: , + color: '#1677FF' + }, + { + id: 'usdt', + name: 'USDT (TRC20)', + icon: , + color: '#26A17B' + } + ] + + return ( +
      + {methods.map(method => ( + + ))} + + +
      + ) +} +``` + +--- + +## 6. 后台管理模块 + +**路径**: `/app/admin/page.tsx` + +### 6.1 概览页面 + +```typescript +export default function AdminDashboard() { + const [stats, setStats] = useState(null) + + useEffect(() => { + fetchStats() + }, []) + + async function fetchStats() { + const res = await fetch('/api/admin', { + headers: { + 'Authorization': `Bearer ${getAdminToken()}` + } + }) + const data = await res.json() + setStats(data) + } + + if (!stats) return + + return ( +
      + {/* 概览卡片 */} +
      + + + + +
      + + {/* 图表 */} +
      + + +
      +
      + ) +} +``` + +### 6.2 内容管理 + +```typescript +function ContentManagement() { + const [chapters, setChapters] = useState([]) + + return ( +
      + {/* 操作栏 */} +
      +

      内容管理

      + +
      + + {/* 章节列表 */} + + + + + + + + + + + + {chapters.map(chapter => ( + + + + + + + + ))} + +
      章节ID标题状态价格操作
      {chapter.id}{chapter.title} + + {chapter.isFree ? '免费' : '付费'} + + ¥{chapter.price} + +
      +
      + ) +} +``` + +--- + +## 7. 通用组件库 + +### 7.1 Button组件 + +```typescript +interface ButtonProps { + children: React.ReactNode + onClick?: () => void + loading?: boolean + disabled?: boolean + variant?: 'primary' | 'secondary' | 'ghost' + size?: 'sm' | 'md' | 'lg' +} + +export function Button({ + children, + onClick, + loading, + disabled, + variant = 'primary', + size = 'md' +}: ButtonProps) { + const baseClasses = 'rounded-xl font-semibold transition-all' + + const variantClasses = { + primary: 'bg-[var(--app-brand)] text-white hover:opacity-90', + secondary: 'bg-[var(--app-bg-secondary)] text-white', + ghost: 'bg-transparent text-[var(--app-brand)] hover:bg-[var(--app-brand-light)]' + } + + const sizeClasses = { + sm: 'px-4 py-2 text-sm', + md: 'px-6 py-3 text-base', + lg: 'px-8 py-4 text-lg' + } + + return ( + + ) +} +``` + +### 7.2 Modal组件 + +```typescript +export function Modal({ + isOpen, + onClose, + children +}: ModalProps) { + if (!isOpen) return null + + return ( +
      + {/* 背景蒙层 */} +
      + + {/* 内容区域 */} +
      + {/* 顶部把手 (仅移动端) */} +
      +
      +
      + + {/* 关闭按钮 */} + + + {/* 内容 */} +
      + {children} +
      +
      +
      + ) +} +``` + +--- + +**总结**: 前端模块以**组件化**为核心,每个模块职责清晰,组件可复用。核心模块包括首页(展示)、匹配(社交)、阅读(内容)、我的(用户中心)、支付(变现)、后台(管理)。所有模块都遵循统一的设计规范和交互模式。 diff --git a/开发文档/5、接口/API接口完整文档.md b/开发文档/5、接口/API接口完整文档.md new file mode 100644 index 00000000..e23fa1d5 --- /dev/null +++ b/开发文档/5、接口/API接口完整文档.md @@ -0,0 +1,640 @@ +# API接口完整文档 - Soul创业实验项目 + +> **API风格**: RESTful | **版本**: v1.0 | **基础路径**: `/api` +> **说明**:本文档已整合原《API接口》内容,为项目唯一 API 参考。 + +**我是卡若。** + +接口设计原则:**简单、清晰、易用**。 + +--- + +## 1. 接口总览 + +### 1.1 接口分类 + +| 模块 | 路径前缀 | 描述 | +|------|---------|------| +| 书籍内容 | `/api/book` | 章节列表、内容获取、同步 | +| 支付系统 | `/api/payment` | 订单创建、支付回调、状态查询 | +| 分销系统 | `/api/referral` | 邀请码、收益查询、提现 | +| 用户系统 | `/api/user` | 登录、注册、信息更新 | +| 匹配系统 | `/api/match` | 寻找匹配、匹配历史 | +| 管理后台 | `/api/admin` | 内容/订单/用户/分销管理 | +| 配置系统 | `/api/config` | 系统配置获取 | + +### 1.2 认证方式 + +**用户认证** (可选): +``` +Cookie: session_id= +``` + +**管理员认证** (必需): +``` +Authorization: Bearer admin-token-secret +``` + +--- + +## 2. 书籍内容API + +### 2.1 获取所有章节 + +**接口**: `GET /api/book/all-chapters` + +**请求**: +```bash +curl https://your-domain.com/api/book/all-chapters +``` + +**响应**: +```json +{ + "success": true, + "data": [ + { + "id": "part-1", + "number": "01", + "title": "真实的人", + "subtitle": "人性观察与社交逻辑", + "chapters": [ + { + "id": "chapter-1", + "title": "人与人之间的底层逻辑", + "sections": [ + { + "id": "1.1", + "title": "自行车荷总:一个行业做到极致是什么样", + "price": 1, + "isFree": true, + "filePath": "book/第一篇|真实的人/...", + "unlockAfterDays": 0 + } + ] + } + ] + } + ], + "total": 64 +} +``` + +### 2.2 获取单章内容 + +**接口**: `GET /api/book/chapter/:id` + +**请求**: +```bash +curl https://your-domain.com/api/book/chapter/1.1 +``` + +**响应**: +```json +{ + "success": true, + "data": { + "id": "1.1", + "title": "自行车荷总:一个行业做到极致是什么样", + "content": "# 章节内容...", + "chapter": "第1章|人与人之间的底层逻辑", + "section": "第一篇|真实的人", + "isFree": true, + "price": 1, + "prev": null, + "next": "1.2" + } +} +``` + +### 2.3 同步章节 + +**接口**: `POST /api/book/sync` + +**请求**: +```bash +curl -X POST https://your-domain.com/api/book/sync \ + -H "Authorization: Bearer admin-token-secret" +``` + +**响应**: +```json +{ + "success": true, + "message": "同步完成", + "synced": 64, + "updated": 3 +} +``` + +--- + +## 3. 支付API + +### 3.1 创建订单 + +**接口**: `POST /api/payment/create-order` + +**请求**: +```bash +curl -X POST https://your-domain.com/api/payment/create-order \ + -H "Content-Type: application/json" \ + -d '{ + "userId": "user_123", + "type": "fullbook", + "amount": 9.9, + "paymentMethod": "alipay" + }' +``` + +**参数**: +```typescript +{ + userId: string // 用户ID + type: 'section' | 'fullbook' // 订单类型 + sectionId?: string // 章节ID (章节购买时必需) + amount: number // 支付金额 + paymentMethod: 'wechat' | 'alipay' | 'usdt' // 支付方式 +} +``` + +**响应**: +```json +{ + "success": true, + "data": { + "orderId": "order_1705230000000", + "amount": 9.9, + "qrCode": "https://qr.alipay.com/...", + "expireTime": "2026-01-14T11:00:00.000Z" + } +} +``` + +### 3.2 支付回调 - 支付宝 + +**接口**: `POST /api/payment/alipay/notify` + +**参数** (支付宝POST): +``` +out_trade_no: "order_1705230000000" +trade_status: "TRADE_SUCCESS" +total_amount: "9.90" +buyer_id: "2088xxx" +sign: "..." +``` + +**响应**: +``` +success +``` + +### 3.3 支付回调 - 微信 + +**接口**: `POST /api/payment/wechat/notify` + +**参数** (微信XML): +```xml + + SUCCESS + order_1705230000000 + 990 + +``` + +**响应**: +```xml + + SUCCESS + OK + +``` + +### 3.4 验证支付状态 + +**接口**: `GET /api/payment/verify?orderId={orderId}` + +**请求**: +```bash +curl "https://your-domain.com/api/payment/verify?orderId=order_123" +``` + +**响应**: +```json +{ + "success": true, + "data": { + "orderId": "order_123", + "status": "completed", + "paidAt": "2026-01-14T10:30:00.000Z" + } +} +``` + +--- + +## 4. 分销API + +### 4.1 获取邀请码 + +**接口**: `GET /api/referral/code` + +**认证**: 需要用户登录 + +**请求**: +```bash +curl https://your-domain.com/api/referral/code \ + -H "Cookie: session_id=xxx" +``` + +**响应**: +```json +{ + "success": true, + "data": { + "code": "REF1705230", + "url": "https://your-domain.com?ref=REF1705230" + } +} +``` + +### 4.2 绑定推荐关系 + +**接口**: `POST /api/referral/bind` + +**请求**: +```bash +curl -X POST https://your-domain.com/api/referral/bind \ + -H "Content-Type: application/json" \ + -d '{ + "userId": "user_123", + "referralCode": "REF1705229" + }' +``` + +**响应**: +```json +{ + "success": true, + "message": "绑定成功" +} +``` + +### 4.3 查询收益 + +**接口**: `GET /api/referral/earnings` + +**认证**: 需要用户登录 + +**请求**: +```bash +curl https://your-domain.com/api/referral/earnings \ + -H "Cookie: session_id=xxx" +``` + +**响应**: +```json +{ + "success": true, + "data": { + "total": 89.10, + "pending": 35.64, + "withdrawn": 53.46, + "referralCount": 10, + "recentOrders": [ + { + "userId": "user_456", + "amount": 9.9, + "earnings": 8.91, + "createdAt": "2026-01-14T10:00:00.000Z" + } + ] + } +} +``` + +### 4.4 申请提现 + +**接口**: `POST /api/referral/withdraw` + +**认证**: 需要用户登录 + +**请求**: +```bash +curl -X POST https://your-domain.com/api/referral/withdraw \ + -H "Content-Type: application/json" \ + -H "Cookie: session_id=xxx" \ + -d '{ + "amount": 50, + "method": "alipay", + "account": "13800138000", + "name": "王**" + }' +``` + +**响应**: +```json +{ + "success": true, + "data": { + "withdrawalId": "wd_123", + "amount": 50, + "status": "pending", + "estimatedTime": "1-3个工作日" + } +} +``` + +--- + +## 5. 用户API + +### 5.1 登录 + +**接口**: `POST /api/user/login` + +**请求**: +```bash +curl -X POST https://your-domain.com/api/user/login \ + -H "Content-Type: application/json" \ + -d '{ + "phone": "13800138000", + "code": "123456" + }' +``` + +**响应**: +```json +{ + "success": true, + "data": { + "user": { + "id": "user_123", + "phone": "****8000", + "nickname": "创业者小王", + "hasFullBook": false + }, + "token": "session_token_xxx" + } +} +``` + +### 5.2 注册 + +**接口**: `POST /api/user/register` + +**请求**: +```bash +curl -X POST https://your-domain.com/api/user/register \ + -H "Content-Type: application/json" \ + -d '{ + "phone": "13800138000", + "nickname": "创业者小王", + "referralCode": "REF1705229" + }' +``` + +**响应**: +```json +{ + "success": true, + "data": { + "user": { + "id": "user_1705230000000", + "phone": "****8000", + "nickname": "创业者小王", + "referralCode": "REF1705230" + }, + "token": "session_token_xxx" + } +} +``` + +--- + +## 6. 匹配API + +### 6.1 寻找匹配 + +**接口**: `POST /api/match/find` + +**认证**: 需要用户登录 + +**请求**: +```bash +curl -X POST https://your-domain.com/api/match/find \ + -H "Content-Type: application/json" \ + -H "Cookie: session_id=xxx" \ + -d '{ + "mbti": "INTP", + "interests": ["私域运营", "内容创业"] + }' +``` + +**响应**: +```json +{ + "success": true, + "data": { + "matchId": "match_123", + "user": { + "nickname": "创业者小李", + "mbti": "ENTJ", + "interests": ["私域运营", "供应链"], + "matchRate": 85 + }, + "commonInterests": ["私域运营"] + } +} +``` + +### 6.2 匹配历史 + +**接口**: `GET /api/match/history` + +**认证**: 需要用户登录 + +**响应**: +```json +{ + "success": true, + "data": [ + { + "matchId": "match_123", + "nickname": "创业者小李", + "matchRate": 85, + "createdAt": "2026-01-14T10:00:00.000Z" + } + ] +} +``` + +--- + +## 7. 管理后台API + +### 7.1 概览数据 + +**接口**: `GET /api/admin` + +**认证**: 管理员Token + +**响应**: +```json +{ + "success": true, + "data": { + "content": { + "totalChapters": 65, + "totalWords": 120000, + "publishedChapters": 60, + "draftChapters": 5 + }, + "payment": { + "totalRevenue": 12800.50, + "todayRevenue": 560.00, + "totalOrders": 128, + "todayOrders": 12 + }, + "referral": { + "totalReferrers": 45, + "activeReferrers": 28, + "totalCommission": 11520.45 + }, + "users": { + "totalUsers": 1200, + "purchasedUsers": 128, + "activeUsers": 456 + } + } +} +``` + +### 7.2 内容管理 + +**接口**: `GET /api/admin/content` + +**接口**: `POST /api/admin/content` - 创建 + +**接口**: `PUT /api/admin/content/:id` - 更新 + +**接口**: `DELETE /api/admin/content/:id` - 删除 + +### 7.3 订单管理 + +**接口**: `GET /api/admin/payment?status=completed&page=1&limit=20` + +**响应**: +```json +{ + "success": true, + "data": { + "orders": [ + { + "id": "order_123", + "userId": "user_123", + "amount": 9.9, + "status": "completed", + "createdAt": "2026-01-14T10:00:00.000Z" + } + ], + "total": 128, + "page": 1, + "limit": 20 + } +} +``` + +--- + +## 8. 错误码规范 + +### 8.1 HTTP状态码 + +| 状态码 | 含义 | 使用场景 | +|--------|------|----------| +| 200 | 成功 | 请求成功 | +| 201 | 创建成功 | 资源创建成功 | +| 400 | 请求错误 | 参数错误 | +| 401 | 未授权 | 需要登录 | +| 403 | 禁止访问 | 权限不足 | +| 404 | 未找到 | 资源不存在 | +| 500 | 服务器错误 | 内部错误 | + +### 8.2 业务错误码 + +```typescript +enum ErrorCode { + // 用户相关 + USER_NOT_FOUND = 1001, + USER_ALREADY_EXISTS = 1002, + INVALID_PHONE = 1003, + INVALID_CODE = 1004, + + // 支付相关 + ORDER_NOT_FOUND = 2001, + PAYMENT_FAILED = 2002, + INSUFFICIENT_BALANCE = 2003, + + // 分销相关 + INVALID_REFERRAL_CODE = 3001, + WITHDRAWAL_FAILED = 3002, + INSUFFICIENT_EARNINGS = 3003, + + // 内容相关 + CHAPTER_NOT_FOUND = 4001, + CHAPTER_NOT_PURCHASED = 4002, +} +``` + +**错误响应格式**: +```json +{ + "success": false, + "error": { + "code": 1001, + "message": "用户不存在", + "details": "用户ID: user_123" + } +} +``` + +--- + +## 9. 接口性能优化 + +### 9.1 缓存策略 + +**内容缓存**: +```typescript +// 章节内容缓存1小时 +res.setHeader('Cache-Control', 'public, max-age=3600') + +// 章节列表缓存10分钟 +res.setHeader('Cache-Control', 'public, max-age=600') +``` + +**ETag**: +```typescript +const etag = generateETag(content) +res.setHeader('ETag', etag) + +if (req.headers['if-none-match'] === etag) { + return res.status(304).end() +} +``` + +### 9.2 限流策略 + +```typescript +// 接口限流: 100次/分钟 +const limiter = { + '/api/book/all-chapters': { limit: 100, window: 60 }, + '/api/payment/create-order': { limit: 10, window: 60 }, + '/api/admin/*': { limit: 1000, window: 60 } +} +``` + +--- + +**总结**: API设计遵循RESTful规范,响应格式统一,错误处理清晰。所有接口都有明确的认证要求和错误处理。核心功能包括内容获取、支付流程、分销系统、用户管理、匹配功能。 diff --git a/开发文档/5、接口/在线支付对接文档.md b/开发文档/5、接口/在线支付对接文档.md new file mode 100644 index 00000000..27c8bf8c --- /dev/null +++ b/开发文档/5、接口/在线支付对接文档.md @@ -0,0 +1,319 @@ +# 在线支付对接文档 + +本文档根据当前项目中的支付相关代码与配置反向整理,供前端/第三方/运维对接使用。后端当前为 **soul-api(Go/Gin)**,支付业务逻辑可参考 **next-project** 中的实现。 + +--- + +## 一、概述 + +- **支付方式**:微信支付(Native 扫码 / JSAPI 小程序·公众号 / H5)、支付宝(WAP / Web / 扫码)。 +- **对接入口**:统一走 soul-api 的 `/api` 前缀(如 `https://your-api.com/api/...`)。 +- **回调**:支付平台(微信/支付宝)会主动 POST 到服务端配置的 notify 地址,需公网可访问且返回约定格式。 + +--- + +## 二、接口清单(soul-api) + +| 方法 | 路径 | 说明 | +|-----|------|------| +| POST | `/api/payment/create-order` | 创建支付订单,返回支付参数(二维码/链接/JSAPI 参数等) | +| GET | `/api/payment/methods` | 获取可用支付方式列表 | +| GET | `/api/payment/query` | 按交易号查询支付状态(轮询用) | +| GET | `/api/payment/status/:orderSn` | 按订单号查询订单支付状态 | +| POST | `/api/payment/verify` | 支付结果校验(可选) | +| POST | `/api/payment/callback` | 通用支付回调(可选,与各平台 notify 二选一或并存) | +| POST | `/api/payment/wechat/notify` | 微信支付异步通知 | +| POST | `/api/payment/alipay/notify` | 支付宝异步通知 | +| POST | `/api/payment/wechat/transfer/notify` | 微信转账/企业付款到零钱回调(若启用) | +| GET/POST | `/api/miniprogram/pay` | 小程序下单(创建订单 + 返回微信支付参数) | +| POST | `/api/miniprogram/pay/notify` | 小程序支付异步通知 | + +管理端(需鉴权): + +| 方法 | 路径 | 说明 | +|-----|------|------| +| GET/POST/PUT/DELETE | `/api/admin/payment` | 支付相关配置管理 | + +--- + +## 三、请求与响应约定 + +以下格式以 next-project 中已实现逻辑为对接规范,soul-api 实现时应与之兼容。 + +### 3.1 创建订单 `POST /api/payment/create-order` + +**请求体(JSON)** + +| 字段 | 类型 | 必填 | 说明 | +|------|------|------|------| +| userId | string | 是 | 用户 ID | +| type | string | 是 | 购买类型:`section`(单章) / `fullbook`(全书) | +| sectionId | string | type=section 时 | 章节 ID,如 `1-1` | +| sectionTitle | string | 建议 | 章节标题,用于展示与订单描述 | +| amount | number | 是 | 金额(元),如 9.9 | +| paymentMethod | string | 是 | 支付方式:`wechat` / `alipay` | +| referralCode | string | 否 | 推荐人邀请码,用于分销 | + +**响应(JSON)** + +```json +{ + "code": 200, + "message": "订单创建成功", + "data": { + "orderSn": "20260209123456", + "tradeSn": "T2026020912000012345", + "userId": "user_xxx", + "type": "section", + "sectionId": "1-1", + "sectionTitle": "第一章", + "amount": 9.9, + "paymentMethod": "wechat", + "status": "created", + "createdAt": "2026-02-09T12:00:00.000Z", + "expireAt": "2026-02-09T12:30:00.000Z", + "paymentData": { + "type": "qrcode", + "payload": "weixin://wxpay/...", + "tradeSn": "T2026020912000012345", + "expiration": 1800 + }, + "gateway": "wechat_native" + } +} +``` + +- **paymentData.type**:`qrcode`(二维码内容/链接)、`url`(跳转链接)、`json`(JSAPI 等参数对象)。 +- **paymentData.payload**:微信 Native 为二维码链接;支付宝 WAP 为支付 URL;JSAPI 为 `{ timeStamp, nonceStr, package, signType, paySign }` 等。 +- **gateway**:用于后续轮询时传 `gateway`,如 `wechat_native`、`alipay_wap`。 + +**错误**:`code: 400` 表示缺少必要参数;`code: 500` 为服务器错误。 + +--- + +### 3.2 支付方式列表 `GET /api/payment/methods` + +**响应** + +```json +{ + "code": 200, + "message": "success", + "data": { + "methods": [ + { + "gateway": "wechat_native", + "name": "微信支付", + "icon": "wechat", + "enabled": true, + "available": true + } + ] + } +} +``` + +--- + +### 3.3 查询支付状态(轮询)`GET /api/payment/query` + +**Query** + +| 参数 | 类型 | 必填 | 说明 | +|------|------|------|------| +| tradeSn | string | 是 | 创建订单时返回的 tradeSn | +| gateway | string | 否 | 指定网关,如 `wechat_native`、`alipay_wap`,不传则双通道查询 | + +**响应** + +```json +{ + "code": 200, + "message": "success", + "data": { + "tradeSn": "T2026020912000012345", + "status": "paid", + "platformSn": "4200001234567890", + "payAmount": 990, + "payTime": "2026-02-09T12:05:00.000Z", + "gateway": "wechat_native" + } +} +``` + +- **status**:`paying` 未支付,`paid` 已支付,`closed` 已关闭/退款等。 +- **payAmount**:单位「分」。**payTime** 为支付完成时间。 + +前端建议:每 3 秒轮询一次,最多约 60 次(约 3 分钟);收到 `status: "paid"` 后停止轮询并更新订单/解锁内容。 + +--- + +### 3.4 按订单号查状态 `GET /api/payment/status/:orderSn` + +**路径参数**:`orderSn` 为创建订单返回的订单号。 + +**响应** + +```json +{ + "code": 200, + "message": "success", + "data": { + "orderSn": "20260209123456", + "status": "paid", + "paidAmount": 9.9, + "paidAt": "2026-02-09T12:05:00.000Z", + "paymentMethod": "wechat", + "tradeSn": "T2026020912000012345", + "productType": "section" + } +} +``` + +- **status**:与业务一致:`created`、`paying`、`paid`、`closed`、`refunded` 等。 + +--- + +### 3.5 支付校验 `POST /api/payment/verify` + +**请求体** + +| 字段 | 类型 | 说明 | +|------|------|------| +| orderId | string | 订单号 | +| paymentMethod | string | 支付方式 | +| transactionId | string | 第三方交易号(可选) | + +**响应**:成功时 `code: 0`,失败时非 0;用于前端在回调不确定时的二次校验(具体逻辑由后端实现)。 + +--- + +## 四、支付平台异步通知(回调) + +对接方需在微信支付/支付宝商户后台配置「支付结果通知 URL」,且必须为 **公网 HTTPS**。当前项目约定路径如下(以 soul-api 域名为准): + +| 支付方式 | 通知 URL | 说明 | +|----------|----------|------| +| 微信支付 | `https://your-api.com/api/payment/wechat/notify` | 统一下单/JSAPI/小程序等 | +| 支付宝 | `https://your-api.com/api/payment/alipay/notify` | 异步 notify | +| 微信转账 | `https://your-api.com/api/payment/wechat/transfer/notify` | 企业付款到零钱(若使用) | + +### 4.1 微信支付 notify + +- **方法**:POST +- **Content-Type**:`application/xml` +- **Body**:微信以 XML 推送,字段含 `return_code`、`result_code`、`out_trade_no`、`transaction_id`、`total_fee`、`time_end`、`sign` 等。 +- **验签**:使用商户密钥对微信参数做 MD5 签名校验(见 next-project `lib/payment/wechat.ts` 中 `verifySign`)。 +- **响应**:必须返回 XML,成功示例: + `` + 失败则返回 `return_code=FAIL`,否则微信会重试。 + +**业务处理建议**(与 next-project 一致): +1. 验签通过且 `result_code=SUCCESS` 后,用 `out_trade_no`(即本系统 tradeSn)查订单,更新为已支付、写入 `transaction_id`、`pay_time`。 +2. 根据 `product_type` 开通全书或章节权限。 +3. 若有推荐人,写分销表并更新 `pending_earnings`。 +4. 响应必须在业务异常时仍返回成功 XML,避免微信重复通知。 + +### 4.2 支付宝 notify + +- **方法**:POST +- **Content-Type**:`application/x-www-form-urlencoded` +- **Body**:表单键值对,含 `out_trade_no`、`trade_no`、`trade_status`、`total_amount`、`gmt_payment`、`sign` 等。 +- **验签**:使用配置的 MD5 密钥校验(见 next-project `lib/payment/alipay.ts`)。 +- **响应**:纯文本,成功返回 `success`,失败返回 `fail`。支付宝会多次重试直至收到 `success`。 + +**业务处理**:与微信类似,以 `out_trade_no` 更新订单、开通权限、处理分销。 + +--- + +## 五、小程序支付 + +### 5.1 下单 `GET/POST /api/miniprogram/pay` + +**请求体(JSON)** + +| 字段 | 类型 | 必填 | 说明 | +|------|------|------|------| +| openId | string | 是 | 用户 openId | +| productType | string | 是 | `section` / `fullbook` | +| productId | string | 是 | 章节 ID 或 `fullbook` | +| amount | number | 是 | 金额(元) | +| description | string | 建议 | 订单描述 | +| userId | string | 是 | 用户 ID | + +**响应** + +```json +{ + "success": true, + "data": { + "orderSn": "MP20260204123456789012", + "prepayId": "wx...", + "payParams": { + "timeStamp": "...", + "nonceStr": "...", + "package": "prepay_id=...", + "signType": "MD5", + "paySign": "..." + } + } +} +``` + +小程序端用 `payParams` 调起 `wx.requestPayment`。 + +### 5.2 小程序支付通知 `POST /api/miniprogram/pay/notify` + +与「微信支付 notify」同一套规范(XML 入参、XML 成功响应)。商户后台配置的「支付结果通知 URL」填 soul-api 的 `/api/miniprogram/pay/notify` 或统一使用 `/api/payment/wechat/notify` 均可,需与后端实现一致(按订单来源更新对应订单与权限)。 + +--- + +## 六、配置项 + +### 6.1 管理端 / 配置接口 + +- **GET /api/config**:返回全站配置,其中 **paymentMethods** 用于前端展示支付方式及微信/支付宝相关配置(如微信群二维码、商户信息等)。 +- 支付开关、商户号、密钥等建议放在服务端环境变量或管理端「支付配置」中,不通过公开接口暴露密钥。 + +### 6.2 环境变量(参考 next-project) + +后端若自实现支付,可参考以下变量(soul-api 当前未在 .env.example 中列出,对接时按需增加): + +**微信** + +- `WECHAT_APPID` / `WECHAT_SERVICE_APPID`:公众号/服务号 AppID +- `WECHAT_APP_SECRET` / `WECHAT_SERVICE_SECRET` +- `WECHAT_MCH_ID`:商户号 +- `WECHAT_MCH_KEY`:商户 API 密钥 + +**支付宝** + +- `ALIPAY_APP_ID` / `ALIPAY_PID` +- `ALIPAY_PRIVATE_KEY` / `ALIPAY_PUBLIC_KEY` 或 `ALIPAY_MD5_KEY` +- `ALIPAY_SELLER_EMAIL` + +**应用** + +- `NEXT_PUBLIC_BASE_URL` 或等价「站点 base URL」:用于拼装 notify/return 地址。 + +--- + +## 七、订单与数据库(参考) + +- **orders 表**:`id`、`order_sn`、`user_id`、`open_id`、`product_type`、`product_id`、`amount`、`description`、`status`、`transaction_id`、`pay_time`、`referral_code`、`referrer_id`、`created_at`、`updated_at`。 +- **status**:`created` → 创建,`paid` → 已支付,`expired`/`cancelled` 等由业务定义。 +- 创建订单时可将 **tradeSn** 写入 `transaction_id`,支付回调里用微信/支付宝的「商户订单号」即 tradeSn 查单并更新为 `transaction_id`(平台交易号)、`pay_time`、`status=paid`。 + +--- + +## 八、错误与注意事项 + +1. **签名**:所有微信/支付宝回调必须先验签再执行业务,否则存在伪造风险。 +2. **幂等**:同一笔订单可能被多次通知,更新订单与佣金前应判断当前状态,避免重复加款。 +3. **响应**:notify 接口必须在处理完(或确认可稍后处理)后按平台要求返回成功(微信 XML 成功、支付宝 `success`),再异步做后续逻辑,避免平台反复回调。 +4. **金额**:微信为「分」,支付宝为「元」;内部建议统一用「分」存储,与 next-project 一致。 +5. **soul-api 现状**:当前 payment/miniprogram 相关 handler 为占位实现(直接返回 success),完整逻辑需按本文档与 next-project 实现对齐后上线。 + +--- + +*文档根据项目代码反向整理,若与最新代码不一致,以实际仓库为准。* diff --git a/开发文档/5、接口/接口与提现.md b/开发文档/5、接口/接口与提现.md new file mode 100644 index 00000000..58cbe96b --- /dev/null +++ b/开发文档/5、接口/接口与提现.md @@ -0,0 +1,11 @@ +# 接口与提现(合并自 接口定义规范、提现功能完整技术文档) + +## 接口规范 + +RESTful,JSON 返回。基础 URL 开发 localhost:3000/api,生产 soul.quwanzhi.com/api。统一格式:`{ code, message, data }`。 + +## 提现功能 + +微信支付商家转账到零钱 API,签名算法、加解密、完整实现、测试验证。流程:用户申请 → 审核 → 调 API → 回调更新状态。 + +详见原《接口定义规范》《提现功能完整技术文档》。 diff --git a/开发文档/5、接口/配置清单-完整版.md b/开发文档/5、接口/配置清单-完整版.md new file mode 100644 index 00000000..1ca859a7 --- /dev/null +++ b/开发文档/5、接口/配置清单-完整版.md @@ -0,0 +1,205 @@ +# Soul创业实验 - API密钥与配置清单 + +> 最后更新: 2026-01-25 +> 维护人: 卡若 +> ⚠️ 本文件包含敏感信息,请勿公开 + +--- + +## 一、企业信息 + +| 项目 | 值 | +|:---|:---| +| **企业名称** | 泉州市卡若网络技术有限公司 | +| **联系电话** | 15880802661 | +| **微信号** | 28533368 | +| **邮箱** | zhiqun@qq.com / zhengzhiqun@vip.qq.com | + +--- + +## 二、微信生态 + +### 2.1 小程序(Soul创业实验) + +| 项目 | 值 | 备注 | +|:---|:---|:---| +| **AppID** | `wxb8bbb2b10dec74aa` | 小程序ID | +| **AppSecret** | `3c1fb1f63e6e052222bbcead9d07fe0c` | 小程序密钥 | +| **支付绑定状态** | 🟡 审核中 | 2026-01-25 09:43:59 提交 | + +### 2.2 服务号(玩值) + +| 项目 | 值 | 备注 | +|:---|:---|:---| +| **AppID** | `wx7c0dbf34ddba300d` | 服务号AppID | +| **AppSecret** | `f865ef18c43dfea6cbe3b1f1aebdb82e` | 服务号密钥 | +| **支付绑定状态** | ✅ 已绑定 | 绑定AppID: wx3e31b068be59ddc1 | + +### 2.3 网站应用 + +| 项目 | 值 | +|:---|:---| +| **AppID** | `wx432c93e275548671` | +| **AppSecret** | `25b7e7fdb7998e5107e242ebb6ddabd0` | + +### 2.4 微信支付 + +| 项目 | 值 | 备注 | +|:---|:---|:---| +| **商户号** | `1318592501` | 主体: 泉州市卡若网络技术有限公司 | +| **API密钥(v2)** | `wx3e31b068be59ddc131b068be59ddc2` | 32位 | +| **MP文件验证码** | `SP8AfZJyAvprRORT` | | +| **支付回调地址** | `https://soul.quwanzhi.com/api/miniprogram/pay/notify` | | + +#### 已绑定AppID + +| AppID | 类型 | 状态 | +|:---|:---|:---| +| `wx3e31b068be59ddc1` | 服务号 | ✅ 已关联 | +| `wxb8bbb2b10dec74aa` | 小程序 | 🟡 审核中 | + +--- + +## 三、支付宝 + +| 项目 | 值 | +|:---|:---| +| **PID** | `2088511801157159` | +| **MD5密钥** | `lz6ey1h3kl9zqkgtjz3avb5gk37wzbrp` | +| **账户** | zhengzhiqun@vip.qq.com | + +--- + +## 四、云服务 + +### 4.1 腾讯云 + +| 项目 | 值 | +|:---|:---| +| **APPID** | `1251077262` | +| **SecretId** | `AKIDjc6yO3nPeOuK2OKsJPBBVbTiiz0aPNHl` | +| **SecretKey** | *(见用户规则)* | + +### 4.2 阿里云 + +| 项目 | 值 | +|:---|:---| +| **AccessKey ID** | `LTAI5t9zkiWmFtHG8qmtdysW` | +| **AccessKey Secret** | `xxjXnZGLNvA2zDkj0aEBSQm3XZAaro` | + +--- + +## 五、数据库 + +### 5.1 腾讯云MySQL(生产环境) + +| 项目 | 值 | +|:---|:---| +| **主机** | `56b4c23f6853c.gz.cdb.myqcloud.com` | +| **端口** | `14413` | +| **数据库** | `soul_miniprogram` | +| **用户名** | `cdb_outerroot` | +| **密码** | `Zhiqun1984` | +| **字符集** | `utf8mb4` | + +#### 数据库表 + +| 表名 | 说明 | +|:---|:---| +| `users` | 用户表 | +| `orders` | 订单表 | +| `referral_bindings` | 推广绑定关系 | +| `match_records` | 匹配记录 | +| `system_config` | 系统配置 | +| `chapters` | **章节内容表(新)** | + +### 5.2 卡若私域数据库(内网) + +| 项目 | 值 | +|:---|:---| +| **主机** | `10.88.182.62` | +| **端口** | `3306` | +| **用户名** | `root` | +| **密码** | `Vtka(agu)-1` | + +--- + +## 六、AI服务 + +### 6.1 v0 API + +| 项目 | 值 | +|:---|:---| +| **API地址** | `https://api.v0.dev/v1` | +| **API Key** | `v1:C6mw1SlvXsJdlO4VFEXSQEVf:519gA0DPqIMbjvfMh7CXf4B2` | +| **默认模型** | `claude-opus` | + +--- + +## 七、开发工具 + +### 7.1 GitHub + +| 项目 | 值 | +|:---|:---| +| **Token** | `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` | + +--- + +## 八、项目部署信息 + +| 项目 | 值 | +|:---|:---| +| **域名** | `soul.quwanzhi.com` | +| **协议** | HTTPS | +| **服务器** | 宝塔面板 | +| **部署方式** | GitHub Webhook 自动部署 | + +--- + +## 九、邮箱账户 + +| 邮箱 | 密码 | +|:---|:---| +| `zhiqun@qq.com` | `#vtk();1984` | +| `zhengzhiqun@vip.qq.com` | `#vtk();1984` | +| `15880802661@qq.com` | `#vtk();1984` | + +--- + +## 十、配置代码引用 + +### 小程序支付配置 + +```typescript +// lib/payment/wechat-miniprogram.ts +const WECHAT_PAY_CONFIG = { + appId: 'wxb8bbb2b10dec74aa', // 小程序AppID + appSecret: '3c1fb1f63e6e052222bbcead9d07fe0c', // 小程序AppSecret + mchId: '1318592501', // 商户号 + mchKey: 'wx3e31b068be59ddc131b068be59ddc2', // API密钥(v2) + notifyUrl: 'https://soul.quwanzhi.com/api/miniprogram/pay/notify', +} +``` + +### 数据库配置 + +```typescript +// lib/db.ts +const DB_CONFIG = { + host: '56b4c23f6853c.gz.cdb.myqcloud.com', + port: 14413, + user: 'cdb_outerroot', + password: 'Zhiqun1984', + database: 'soul_miniprogram', + charset: 'utf8mb4', +} +``` + +--- + +## 更新日志 + +| 日期 | 更新内容 | +|:---|:---| +| 2026-01-25 | 创建完整配置清单;小程序支付绑定申请中;章节表迁移完成 | diff --git a/开发文档/6、后端/image.png b/开发文档/6、后端/image.png new file mode 100644 index 00000000..b26ffbf4 Binary files /dev/null and b/开发文档/6、后端/image.png differ diff --git a/开发文档/6、后端/内容创建问题修复说明.md b/开发文档/6、后端/内容创建问题修复说明.md new file mode 100644 index 00000000..a21ec1ea --- /dev/null +++ b/开发文档/6、后端/内容创建问题修复说明.md @@ -0,0 +1,93 @@ +# 内容创建问题修复说明 + +> 问题:souladmin 添加内容后显示「创建成功」,但目录和数据库未增加,前端也未显示。 + +## 根因分析 + +1. **两套后台数据源不一致** + - souladmin.quwanzhi.com 调用 soulapi.quwanzhi.com(Go API) + - soul.quwanzhi.com/admin 使用 Next.js API,list 此前仅从 bookData(静态)读取 + - 新建章节写入数据库,但 list 不查库,导致新建内容不显示 + +2. **PUT 创建未完整支持 partId/chapterId** + - 新建章节时 partId、chapterId、partTitle、chapterTitle 未正确写入数据库 + +## 已做修复 + +### 1. 修改 `/api/db/book` list 接口 +- **原逻辑**:仅从 bookData 读取 +- **现逻辑**:优先从数据库 chapters 表读取,再与 bookData 合并 +- **效果**:新建章节会立即出现在列表中 + +### 2. 修改 PUT 接口支持新建章节 +- 支持 body 传入 `partId`、`chapterId`、`partTitle`、`chapterTitle`、`isFree` +- 新建章节能正确写入数据库 + +### 3. 在 book-data 中新增 9.15 +- 章节 ID: 9.15 +- 标题: 第102场|今年第一个红包你发给谁 +- 文件: book/第四篇|真实的赚钱/第9章|我在Soul上亲访的赚钱案例/9.15 第102场|今年第一个红包你发给谁.md + +### 4. soul-admin 改用 soul.quwanzhi.com 作为 API +- 修改 soul-admin 的 API 基址:soulapi → soul.quwanzhi.com +- 在 Next.js 中为 souladmin.quwanzhi.com 配置 CORS + +## 部署步骤 + +### 步骤 1:部署 soul 主站(小型宝塔) + +```bash +cd /Users/karuo/Documents/开发/3、自营项目/一场soul的创业实验 +# 按 .cursorrules 中的流程执行 +pnpm build +# 然后执行部署脚本 +``` + +### 步骤 2:同步 9.15 到数据库 + +部署后访问 soul.quwanzhi.com/admin,在内容管理页面点击「同步到数据库」,将包含 9.15 的 bookData 同步进库。 + +### 步骤 3:部署修改后的 soul-admin(KR 宝塔) + +```bash +# 将 一场soul的创业实验-永平 中的 soul-admin/dist 上传到 KR 宝塔 +cd /Users/karuo/Documents/开发/3、自营项目/一场soul的创业实验-永平 +tar -czf soul-admin-dist.tar.gz soul-admin/dist +sshpass -p 'Zhiqun1984' scp -P 22022 soul-admin-dist.tar.gz root@43.139.27.93:/tmp/ +sshpass -p 'Zhiqun1984' ssh -p 22022 root@43.139.27.93 " + cd /www/wwwroot/自营/soul-admin + rm -rf dist.bak + mv dist dist.bak 2>/dev/null || true + tar -xzf /tmp/soul-admin-dist.tar.gz -C . + rm /tmp/soul-admin-dist.tar.gz +" +``` + +### 步骤 4:校验 + +1. 打开 souladmin.quwanzhi.com/content +2. 新建章节,确认创建后列表中立即出现 +3. 刷新 soul.quwanzhi.com 主站,确认新章节可读 + +## 注意事项 + +- souladmin 现改为调用 soul.quwanzhi.com,不再调用 soulapi(Go),需确保 soul 主站可用 +- 若仍需使用 Go API,需在 soul-api 源码中修复 list/create 逻辑 + +--- + +## 内容上传 API(供科室/Skill 调用) + +- **地址**:`POST /api/content/upload` +- **Content-Type**:`application/json` +- **Body 字段**: + - `title`(必填):节标题 + - `price`:定价,默认 1 + - `content`:正文(Markdown 或 HTML) + - `format`:`markdown` | `html`,默认 `markdown` + - `images`:图片 URL 数组;正文中可用 `{{image_0}}`、`{{image_1}}` 占位,会替换为对应图片的 Markdown 图链 + - `partId`、`partTitle`、`chapterId`、`chapterTitle`:归属篇/章,可选 + - `isFree`:是否免费,默认 false + - `sectionId`:指定节 ID,不传则自动生成(如 `upload.标题slug.时间戳`) +- **返回**:`{ success, id, message, title, price, isFree, wordCount }` +- 写入数据库 `chapters` 表,list/目录会从库中读取并去重显示。 diff --git a/开发文档/6、后端/后端开发规范.md b/开发文档/6、后端/后端开发规范.md new file mode 100644 index 00000000..75b360a1 --- /dev/null +++ b/开发文档/6、后端/后端开发规范.md @@ -0,0 +1,64 @@ +# 后端开发规范 (Backend Specs) - 智能自生长文档 + +> **提示词功能 (Prompt Function)**: 将本文件拖入 AI 对话框,即可激活“Python 后端专家”角色,生成高效、规范的 FastAPI 代码。 + +## 1. 基础上下文 (The Two Basic Files) +### 1.1 角色档案:卡若 (Karuo) +- **核心**:开发快、性能好、支持 AI。 +- **习惯**:优先使用异步 (`async/await`),强制类型提示 (`Type Hints`)。 + +### 1.2 技术栈 +- **语言**:Python 3.10+。 +- **框架**:FastAPI (Web), Pydantic (Validation), LangChain (AI)。 +- **数据**:Motor (Async Mongo), Redis。 + +## 2. 开发规范核心 (Master Content) +### 2.1 代码规范 +- **风格**:遵循 PEP 8,使用 Black 格式化。 +- **类型**:**强制 Type Hints** (如 `def get_user(id: int) -> User:`)。 +- **注释**:**强制中文注释**,解释“业务逻辑”与“AI 处理流程”。 +- **结构**: + - `app/routers`: 路由 + - `app/models`: Pydantic 模型 + - `app/services`: 业务逻辑 + - `app/core`: 配置与工具 + +### 2.2 AI 与安全规范 +- **AI 调用**:所有 LLM 调用必须封装在 Service 层,并包含重试机制与超时控制。 +- **安全**: + - **命令执行**:严禁使用 `os.system`,必须使用 `subprocess` 并校验参数。 + - **SQL/NoSQL**:使用 ORM 或参数化查询,防止注入。 + +### 2.3 异常与日志 +- **异常**:使用 FastAPI `HTTPException` 或自定义 Exception Handler。 +- **日志**:使用 `loguru` 或 Python 标准 `logging`,必须记录 Traceback。 + +### 2.4 依赖管理 +- **工具**:`pip` 或 `poetry`。 +- **原则**:提交代码前更新 `requirements.txt` 或 `pyproject.toml`。 + +## 3. AI 协作指令 (Expanded Function) +**角色**:你是我(卡若)的 Python 架构师。 +**任务**: +1. **代码实现**:生成 FastAPI 的 Router/Model/Service 代码。 +2. **AI 集成**:编写 LangChain 调用逻辑或向量检索代码。 +3. **逻辑图解**:用 Mermaid 展示异步处理流程。 + +### 示例 Mermaid (类图) +\`\`\`mermaid +classDiagram + class UserRouter { + +get_user() + +create_user() + } + class UserService { + +verify_token() + +process_ai_request() + } + class VectorStore { + +search_similarity() + +add_documents() + } + UserRouter --> UserService + UserService --> VectorStore +\`\`\` diff --git a/开发文档/6、后端/后端架构.md b/开发文档/6、后端/后端架构.md new file mode 100644 index 00000000..16c5f9dd --- /dev/null +++ b/开发文档/6、后端/后端架构.md @@ -0,0 +1,68 @@ +# 后端架构与业务逻辑 + +**我是卡若。** + +后端不仅仅是读写数据库,它是**业务逻辑的翻译官**。 + +我们要把“私域引流”、“内容分发”这些生意话术,翻译成代码逻辑。 + +## 1. 核心业务模块 + +### 1.1 内容服务 (Content Service) +这是最基础的。 +- **逻辑**: + - 扫描 `book/` 目录,生成目录树 (Tree)。 + - 解析 Markdown,提取 Frontmatter (标题、日期、标签)。 + - **缓存策略**: 既然是读文件,IO 慢。要在内存里做一个 LRU 缓存,读取一次后由内存直接返回,直到文件发生变更。 + +### 1.2 配置服务 (Config Service) +我的微信号、群二维码、价格,这些东西会变,不能写死在代码里。 +- **实现**: + - 一个 `config/settings.json` 文件(或者未来的 MongoDB `settings` 表)。 + - 接口: `GET /api/config`。 + - 前端拿到配置,动态展示微信号。 + +### 1.3 引流服务 (Lead Service) +这是赚钱的关键。 +- **埋点逻辑**: + - 记录 `UserView` (用户看了哪章)。 + - 记录 `UserClick` (用户点了“加微信”)。 + - 虽然不存库,但可以先打到日志文件里,或者调一个飞书的 Webhook,实时通知我“有人对这章感兴趣”。 + +## 2. 接口设计原则 + +- **RESTful**: 资源导向。`GET /articles`, `GET /articles/:id`。 +- **统一响应体**: + \`\`\`typescript + interface ApiResponse { + code: number; // 0 成功, >0 错误 + data: T; + msg: string; + } + \`\`\` + +## 3. 目录结构 (后端专用) + +\`\`\` +app/api/ +├── content/ # 内容相关 +├── config/ # 全局配置 +└── track/ # 埋点上报 + +lib/ +├── content/ +│ ├── parser.ts # Markdown 解析器 +│ └── cache.ts # 内存缓存 +├── config/ +│ └── loader.ts # 配置加载器 +└── db/ # 数据库连接 (预留) +\`\`\` + +## 4. 扩展性预留 + +- **鉴权中间件**: 现在是裸奔,未来加 `middleware.ts` 拦截 `/admin` 开头的请求。 +- **任务队列**: 未来如果生成文档太慢,就扔到 Redis 队列里异步处理。 + +--- +**卡若说:** +后端代码要写得像瑞士军刀一样,功能明确,结实耐用。 diff --git a/开发文档/6、后端/小程序支付参数.png b/开发文档/6、后端/小程序支付参数.png new file mode 100644 index 00000000..16d1881b Binary files /dev/null and b/开发文档/6、后端/小程序支付参数.png differ diff --git a/开发文档/6、后端/管理端鉴权设计.md b/开发文档/6、后端/管理端鉴权设计.md new file mode 100644 index 00000000..da90e194 --- /dev/null +++ b/开发文档/6、后端/管理端鉴权设计.md @@ -0,0 +1,120 @@ +# soul-api 管理端登录判断与权限校验 + +> 来源:soul-api/管理端鉴权设计.md。已整理至开发文档。 + +--- + +## 一、有没有登录的依据(JWT) + +**依据:请求中的 JWT。优先从 `Authorization: Bearer ` 读取,兼容从 Cookie `admin_session` 读取。** + +| 项目 | 说明 | +|------|------| +| 推荐方式 | 请求头 `Authorization: Bearer ` | +| 兼容方式 | Cookie 名 `admin_session`,值为 JWT 字符串 | +| JWT 算法 | HS256,密钥为 `ADMIN_SESSION_SECRET` | +| 有效期 | 7 天(exp claim) | +| 载荷 | sub=admin, username, role=admin | +| 校验 | 验签 + 未过期 → 视为已登录 | + +- 配置:`ADMIN_USERNAME` / `ADMIN_PASSWORD` 用于登录校验;`ADMIN_SESSION_SECRET` 用于签发/校验 JWT。 +- 未带有效 JWT → 401。 + +--- + +## 二、权限校验设计(路由分层) + +- **不校验登录**:只做业务逻辑(登录、登出、鉴权检查) + - `GET /api/admin` → 鉴权检查(读 Cookie,有效 200 / 无效 401) + - `POST /api/admin` → 登录(校验账号密码,写 Cookie) + - `POST /api/admin/logout` → 登出(删 Cookie) + +- **必须已登录**:挂 `AdminAuth()` 中间件,从请求读 `admin_session` 并验签+过期,不通过直接 401,不进入 handler + - `/api/admin/*`(如 chapters、content、withdrawals、settings 等) + - `/api/db/*` + +- **其它**:如 `/api/miniprogram/*`、`/api/book/*` 等不加 AdminAuth,按各自接口鉴权(如小程序 token)。 + +--- + +## 三、框图 + +```mermaid +flowchart TB + subgraph 前端["soul-admin 前端"] + A[用户打开后台 / 请求接口] + A --> B{请求类型} + B -->|登录| C[POST /api/admin] + B -->|登出| D[POST /api/admin/logout] + B -->|进后台前检查| E[GET /api/admin] + B -->|业务接口| F[GET/POST /api/admin/xxx] + end + + subgraph 请求["每次请求"] + G[浏览器自动携带 Cookie: admin_session] + G --> H[发往 soul-api] + end + + subgraph soul-api["soul-api 路由"] + I["/api/admin 三条(无中间件)"] + J["/api/admin/* 与 /api/db/*"] + J --> K[AdminAuth 中间件] + end + + subgraph 鉴权["AdminAuth 与 AdminCheck 逻辑"] + K --> L[从请求读 Cookie admin_session] + L --> M{有 Cookie?} + M -->|无| N[401 未授权] + M -->|有| O[解析 exp.signature] + O --> P{未过期 且 验签通过?} + P -->|否| N + P -->|是| Q[放行 / 返回 200] + end + + C --> I + D --> I + E --> I + F --> J + H --> soul-api + I --> E2[GET: 同鉴权逻辑 200/401] + I --> C2[POST: 校验账号密码 写 Cookie] + I --> D2[POST: 清 Cookie] +``` + +**路由与中间件关系:** + +```mermaid +flowchart LR + subgraph 无鉴权["不经过 AdminAuth"] + R1[GET /api/admin] + R2[POST /api/admin] + R3[POST /api/admin/logout] + end + + subgraph 需登录["经过 AdminAuth"] + R4["/api/admin/chapters"] + R5["/api/admin/withdrawals"] + R6["/api/admin/settings"] + R7["/api/db/*"] + end + + subgraph 中间件["AdminAuth()"] + M[读 Cookie → 验 token → 通过/401] + end + + H1[直接进 handler] + H2[通过则进 handler] + 无鉴权 --> H1 + 需登录 --> M --> H2 +``` + +--- + +## 四、相关代码位置 + +| 作用 | 位置 | +|------|------| +| JWT 签发/校验/从请求取 token | `internal/auth/adminjwt.go` | +| 登录、登出、GET 鉴权检查 | `internal/handler/admin.go` | +| 管理端中间件 | `internal/middleware/admin_auth.go` | +| 路由挂载 | `internal/router/router.go`(api.Group + admin.Use(AdminAuth())) | diff --git a/开发文档/7、数据库/数据库管理规范.md b/开发文档/7、数据库/数据库管理规范.md new file mode 100644 index 00000000..ce5debae --- /dev/null +++ b/开发文档/7、数据库/数据库管理规范.md @@ -0,0 +1,62 @@ +# 数据库管理规范 (DB Specs) - 智能自生长文档 + +> **提示词功能 (Prompt Function)**: 将本文件拖入 AI 对话框,即可激活“DBA”角色,生成安全的 SQL/Mongo 脚本与 ER 图。 + +## 1. 基础上下文 (The Two Basic Files) +### 1.1 角色档案:卡若 (Karuo) +- **核心**:数据无价,安全第一。 +- **选型**:Mongo (业务+向量) + MySQL (事务/辅助)。 + +### 1.2 操作规范 +- **导入**:必须带 `--resumeFrom` 和 `--drop` (防止重复/中断)。 +- **命名**:`traffic_pools` (严禁 `traffic_words`)。 + +## 2. 数据库规范核心 (Master Content) +### 2.1 选型策略 +- **MongoDB**: + - **业务数据**:用户、日志、流量池。 + - **AI 向量**:存储 Embedding 向量 (Atlas Vector Search)。 +- **MySQL**: 强事务资金流水 (如需)。 + +### 2.2 连接信息 (Internal) +- **卡若私域**: 10.88.182.62:3306 +- **腾讯云**: 56b4c23f6853c...:14413 +- **Mongo**: (Env Config) + +### 2.3 集合命名 +- `users`: 用户 +- `scenarios`: 场景获客 +- `traffic_pools`: 流量池 (含 `embedding` 字段) +- `orders`: 分润订单 +- `knowledge_base`: AI 知识库 (含 `embedding` 字段) + +### 2.4 AI 向量索引 (Vector Index) +- **字段**:通常命名为 `embedding` 或 `vector`。 +- **索引类型**:使用 KNN 或 ANN 索引 (如 HNSW)。 +- **查询**:支持 `$vectorSearch` (Mongo Atlas) 或类似语义检索语法。 + +### 2.5 安全与索引 +- **安全**:密码 Hash (Argon2), 手机号加密。 +- **常规索引**:`openid`, `mobile`, `inviter_id` 必建索引。 + +## 3. AI 协作指令 (Expanded Function) +**角色**:你是我(卡若)的 DBA。 +**任务**: +1. **脚本生成**:生成 MongoDB 聚合查询 (`aggregate`) 或 MySQL DDL/DML。 +2. **向量配置**:生成向量索引的定义 JSON。 +3. **结构可视化**:用 Mermaid 生成 ER 图。 + +### 示例 Mermaid (ER图) +\`\`\`mermaid +erDiagram + User ||--o{ Order : places + User ||--o{ TrafficPool : owns + TrafficPool { + string content + array embedding "Vector[1536]" + } + Order { + string orderId + float amount + } +\`\`\` diff --git a/开发文档/7、数据库/数据库设计.md b/开发文档/7、数据库/数据库设计.md new file mode 100644 index 00000000..3d4d6089 --- /dev/null +++ b/开发文档/7、数据库/数据库设计.md @@ -0,0 +1,708 @@ +# 数据库设计 + +**我是卡若。** + +这个项目当前使用LocalStorage做数据持久化,但未来会切换到MongoDB。这个文档定义了完整的数据库设计方案。 + +--- + +## 一、数据库选型 + +### 1.1 为什么选MongoDB? + +1. **文档型数据库**: 适合内容类产品,数据结构灵活 +2. **无Schema约束**: 快速迭代不需要频繁改表结构 +3. **JSON原生支持**: 前后端数据格式一致 +4. **横向扩展能力**: 支持未来大规模用户增长 +5. **向量搜索支持**: MongoDB Atlas支持向量检索(未来AI功能) + +### 1.2 当前方案 vs 未来方案 + +**当前方案** (LocalStorage): +\`\`\`javascript +// 优点 +- 无需服务器 +- 开发调试方便 +- 适合MVP验证 + +// 缺点 +- 数据仅存浏览器本地 +- 多设备无法同步 +- 数据容易丢失 +\`\`\` + +**未来方案** (MongoDB): +\`\`\`javascript +// 优点 +- 数据持久化存储 +- 多设备数据同步 +- 支持复杂查询 +- 支持事务(ACID) + +// 迁移计划 +1. 安装MongoDB驱动 +2. 创建数据库连接 +3. 逐步替换LocalStorage +4. 添加数据迁移脚本 +\`\`\` + +--- + +## 二、数据库连接配置 + +### 2.1 本地开发环境 + +\`\`\`bash +# MongoDB本地安装 +brew install mongodb-community@6.0 + +# 启动MongoDB +brew services start mongodb-community@6.0 + +# 连接字符串 +mongodb://localhost:27017/soul-experiment +\`\`\` + +### 2.2 生产环境 (MongoDB Atlas) + +\`\`\`bash +# 连接字符串 +mongodb+srv://:@cluster0.mongodb.net/soul-experiment?retryWrites=true&w=majority +\`\`\` + +### 2.3 环境变量配置 + +**.env.local**: +\`\`\`bash +# MongoDB配置 +MONGODB_URI=mongodb://localhost:27017/soul-experiment +MONGODB_DB_NAME=soul-experiment + +# 或使用云数据库 +# MONGODB_URI=mongodb://10.88.182.62:3306/soul-experiment +# MONGODB_USERNAME=root +# MONGODB_PASSWORD=Vtka(agu)-1 +\`\`\` + +--- + +## 三、数据模型设计 + +### 3.1 用户集合 (users) + +**集合名称**: `users` + +**索引**: +\`\`\`javascript +{ + phone: 1, // 唯一索引 + referralCode: 1, // 唯一索引 + referredBy: 1, // 普通索引 + createdAt: -1 // 降序索引 +} +\`\`\` + +**文档结构**: +\`\`\`javascript +{ + _id: ObjectId("65a1234567890abcdef12345"), + phone: "15880802661", // 手机号 + nickname: "卡若", // 昵称 + avatar: "https://cdn.example.com/avatar.jpg", // 头像 + openid: "wx_openid_xxx", // 微信openid + unionid: "wx_unionid_xxx", // 微信unionid + + // 购买记录 + purchasedSections: [ // 已购章节 + "1.1", "1.2", "3.3" + ], + hasFullBook: false, // 是否购买整本书 + + // 分销数据 + referralCode: "REFABC123", // 推荐码 + referredBy: "REFXYZ789", // 推荐人的码 + referralCount: 28, // 推荐人数 + earnings: 256.80, // 总收益(元) + pendingEarnings: 128.90, // 待提现(元) + withdrawnEarnings: 127.90, // 已提现(元) + + // 阅读数据 + readingTime: 12480, // 阅读时长(秒) + readingProgress: 45, // 阅读进度(%) + lastReadSection: "3.2", // 最后阅读章节 + lastReadAt: ISODate("2025-01-14T12:00:00Z"), + + // 权限 + isAdmin: false, // 是否管理员 + isBanned: false, // 是否封禁 + + // 时间戳 + createdAt: ISODate("2025-01-01T00:00:00Z"), + updatedAt: ISODate("2025-01-14T12:00:00Z") +} +\`\`\` + +**查询示例**: +\`\`\`javascript +// 根据手机号查找用户 +db.users.findOne({ phone: "15880802661" }) + +// 根据推荐码查找用户 +db.users.findOne({ referralCode: "REFABC123" }) + +// 查找某推荐人的所有下级 +db.users.find({ referredBy: "REFABC123" }) + +// 查找收益前10的推广者 +db.users.find({}).sort({ earnings: -1 }).limit(10) +\`\`\` + +--- + +### 3.2 订单集合 (orders) + +**集合名称**: `orders` + +**索引**: +\`\`\`javascript +{ + orderId: 1, // 唯一索引 + userId: 1, // 普通索引 + status: 1, // 普通索引 + createdAt: -1 // 降序索引 +} +\`\`\` + +**文档结构**: +\`\`\`javascript +{ + _id: ObjectId("65a1234567890abcdef12345"), + orderId: "ORDER_1705200000_abc123", // 订单号 + userId: ObjectId("65a1234567890abcdef00001"), // 用户ID + userPhone: "15880802661", // 用户手机号 + userNickname: "卡若", // 用户昵称 + + // 订单信息 + type: "section", // "section" | "fullbook" + sectionId: "1.1", // 章节ID(单章购买时) + sectionTitle: "自行车荷总...", // 章节标题 + amount: 1.00, // 金额(元) + + // 支付信息 + paymentMethod: "wechat", // 支付方式 + transactionId: "wx_pay_123456789", // 第三方交易号 + status: "completed", // "pending" | "completed" | "failed" | "refunded" + + // 分销信息 + referralCode: "REFXYZ789", // 推荐码 + referrerUserId: ObjectId("65a1234567890abcdef00002"), // 推荐人ID + referrerEarnings: 0.90, // 推荐人佣金(元) + + // 时间戳 + createdAt: ISODate("2025-01-14T12:00:00Z"), // 创建时间 + paidAt: ISODate("2025-01-14T12:05:00Z"), // 支付时间 + expireAt: ISODate("2025-01-14T12:30:00Z"), // 过期时间(30分钟) + updatedAt: ISODate("2025-01-14T12:05:00Z") +} +\`\`\` + +**查询示例**: +\`\`\`javascript +// 查找用户所有订单 +db.orders.find({ userId: ObjectId("65a...") }).sort({ createdAt: -1 }) + +// 查找待支付订单 +db.orders.find({ status: "pending", expireAt: { $gt: new Date() } }) + +// 统计今日收益 +db.orders.aggregate([ + { $match: { + status: "completed", + paidAt: { + $gte: ISODate("2025-01-14T00:00:00Z"), + $lt: ISODate("2025-01-15T00:00:00Z") + } + }}, + { $group: { + _id: null, + totalRevenue: { $sum: "$amount" }, + totalOrders: { $sum: 1 } + }} +]) + +// 查找某推荐人的所有佣金记录 +db.orders.find({ + referralCode: "REFABC123", + status: "completed" +}) +\`\`\` + +--- + +### 3.3 提现记录集合 (withdrawals) + +**集合名称**: `withdrawals` + +**索引**: +\`\`\`javascript +{ + userId: 1, // 普通索引 + status: 1, // 普通索引 + createdAt: -1 // 降序索引 +} +\`\`\` + +**文档结构**: +\`\`\`javascript +{ + _id: ObjectId("65a1234567890abcdef12345"), + withdrawalId: "WD_1705200000_abc123", // 提现单号 + userId: ObjectId("65a1234567890abcdef00001"), // 用户ID + userPhone: "15880802661", // 用户手机号 + userNickname: "卡若", // 用户昵称 + + // 提现信息 + amount: 100.00, // 提现金额(元) + method: "wechat", // "wechat" | "alipay" + account: "微信号或支付宝账号", + name: "真实姓名", + + // 状态 + status: "pending", // "pending" | "completed" | "rejected" + rejectReason: "", // 拒绝原因 + + // 时间戳 + createdAt: ISODate("2025-01-14T12:00:00Z"), // 申请时间 + completedAt: ISODate("2025-01-14T14:00:00Z"), // 完成时间 + updatedAt: ISODate("2025-01-14T14:00:00Z") +} +\`\`\` + +**查询示例**: +\`\`\`javascript +// 查找待审核提现 +db.withdrawals.find({ status: "pending" }).sort({ createdAt: 1 }) + +// 查找用户提现记录 +db.withdrawals.find({ userId: ObjectId("65a...") }).sort({ createdAt: -1 }) + +// 统计今日提现金额 +db.withdrawals.aggregate([ + { $match: { + status: "completed", + completedAt: { + $gte: ISODate("2025-01-14T00:00:00Z"), + $lt: ISODate("2025-01-15T00:00:00Z") + } + }}, + { $group: { + _id: null, + totalAmount: { $sum: "$amount" }, + totalCount: { $sum: 1 } + }} +]) +\`\`\` + +--- + +### 3.4 章节内容集合 (sections) + +**集合名称**: `sections` + +**索引**: +\`\`\`javascript +{ + sectionId: 1, // 唯一索引 + isFree: 1, // 普通索引 + createdAt: -1 // 降序索引 +} +\`\`\` + +**文档结构**: +\`\`\`javascript +{ + _id: ObjectId("65a1234567890abcdef12345"), + sectionId: "1.1", // 章节ID + + // 章节信息 + title: "自行车荷总:一个行业做到极致是什么样", + content: "# 自行车荷总\n\n...", // Markdown内容 + summary: "本章讲述了...", // 摘要 + keywords: ["创业", "行业深耕"], // 关键词 + + // 层级关系 + partId: "part-1", // 所属篇 + partTitle: "真实的人", + chapterId: "chapter-1", // 所属章 + chapterTitle: "人与人之间的底层逻辑", + + // 定价 + price: 1, // 价格(元) + isFree: true, // 是否免费 + unlockAfterDays: 0, // 定时解锁(天数) + + // 统计数据 + viewCount: 1234, // 浏览次数 + purchaseCount: 456, // 购买次数 + avgReadingTime: 180, // 平均阅读时长(秒) + + // 文件信息 + filePath: "book/_第一篇|真实的人/...", + wordCount: 3580, // 字数 + + // 发布状态 + status: "published", // "draft" | "published" + publishedAt: ISODate("2025-01-01T00:00:00Z"), + + // 时间戳 + createdAt: ISODate("2025-01-01T00:00:00Z"), + updatedAt: ISODate("2025-01-14T12:00:00Z") +} +\`\`\` + +**查询示例**: +\`\`\`javascript +// 获取所有免费章节 +db.sections.find({ isFree: true }) + +// 获取最新发布的10章 +db.sections.find({ status: "published" }) + .sort({ publishedAt: -1 }) + .limit(10) + +// 按浏览量排序 +db.sections.find().sort({ viewCount: -1 }).limit(10) + +// 全文搜索(需创建文本索引) +db.sections.createIndex({ + title: "text", + content: "text", + keywords: "text" +}) +db.sections.find({ $text: { $search: "创业 私域" } }) +\`\`\` + +--- + +### 3.5 阅读记录集合 (reading_logs) + +**集合名称**: `reading_logs` + +**索引**: +\`\`\`javascript +{ + userId: 1, + sectionId: 1, + createdAt: -1 +} +\`\`\` + +**文档结构**: +\`\`\`javascript +{ + _id: ObjectId("65a1234567890abcdef12345"), + userId: ObjectId("65a1234567890abcdef00001"), + sectionId: "3.2", + + // 阅读数据 + progress: 68, // 阅读进度(%) + readingTime: 180, // 阅读时长(秒) + scrollDepth: 75, // 滚动深度(%) + + // 设备信息 + device: "iPhone 14 Pro", + browser: "Safari", + ip: "121.xxx.xxx.xxx", + + // 时间戳 + createdAt: ISODate("2025-01-14T12:00:00Z") +} +\`\`\` + +--- + +### 3.6 系统配置集合 (settings) + +**集合名称**: `settings` + +**文档结构**: +\`\`\`javascript +{ + _id: "global_settings", + + // 分润配置 + distributorShare: 90, // 推广者分成(%) + authorShare: 10, // 作者分成(%) + + // 定价配置 + sectionPrice: 1, // 单章价格(元) + fullBookPrice: 9.9, // 整书价格(元) + + // 支付配置 + paymentMethods: { + wechat: { + enabled: true, + appId: "wx432c93e275548671", + merchantId: "1318592501", + apiKey: "***" + }, + alipay: { + enabled: true, + partnerId: "2088511801157159", + securityKey: "***" + } + }, + + // 营销配置 + partyGroupQrCode: "https://...", + bannerText: "每天早上6-9点,Soul派对房不见不散", + + // 时间戳 + updatedAt: ISODate("2025-01-14T12:00:00Z") +} +\`\`\` + +--- + +## 四、数据迁移方案 + +### 4.1 LocalStorage to MongoDB + +**步骤1**: 导出LocalStorage数据 +\`\`\`javascript +// 导出脚本 scripts/export-localstorage.js +const fs = require('fs') + +const users = JSON.parse(localStorage.getItem('users') || '[]') +const orders = JSON.parse(localStorage.getItem('all_purchases') || '[]') +const settings = JSON.parse(localStorage.getItem('app_settings') || '{}') + +const exportData = { users, orders, settings } +fs.writeFileSync('data-export.json', JSON.stringify(exportData, null, 2)) +\`\`\` + +**步骤2**: 导入MongoDB +\`\`\`javascript +// 导入脚本 scripts/import-mongodb.js +const { MongoClient } = require('mongodb') +const fs = require('fs') + +async function importData() { + const client = await MongoClient.connect(process.env.MONGODB_URI) + const db = client.db('soul-experiment') + + const data = JSON.parse(fs.readFileSync('data-export.json', 'utf8')) + + // 导入用户 + await db.collection('users').insertMany(data.users) + + // 导入订单 + await db.collection('orders').insertMany(data.orders) + + // 导入配置 + await db.collection('settings').insertOne({ + _id: 'global_settings', + ...data.settings + }) + + client.close() + console.log('数据导入完成') +} + +importData() +\`\`\` + +--- + +## 五、数据库操作封装 + +### 5.1 用户操作 + +\`\`\`typescript +// lib/db/users.ts +import { MongoClient, ObjectId } from 'mongodb' + +export async function createUser(userData: Partial) { + const db = await getDatabase() + const result = await db.collection('users').insertOne({ + ...userData, + referralCode: generateReferralCode(), + earnings: 0, + pendingEarnings: 0, + withdrawnEarnings: 0, + referralCount: 0, + purchasedSections: [], + hasFullBook: false, + createdAt: new Date(), + updatedAt: new Date() + }) + return result.insertedId +} + +export async function findUserByPhone(phone: string) { + const db = await getDatabase() + return await db.collection('users').findOne({ phone }) +} + +export async function updateUserEarnings( + userId: ObjectId, + amount: number +) { + const db = await getDatabase() + await db.collection('users').updateOne( + { _id: userId }, + { + $inc: { + earnings: amount, + pendingEarnings: amount + }, + $set: { updatedAt: new Date() } + } + ) +} +\`\`\` + +### 5.2 订单操作 + +\`\`\`typescript +// lib/db/orders.ts +export async function createOrder(orderData: Partial) { + const db = await getDatabase() + const orderId = `ORDER_${Date.now()}_${randomString()}` + + const result = await db.collection('orders').insertOne({ + orderId, + ...orderData, + status: 'pending', + createdAt: new Date(), + expireAt: new Date(Date.now() + 30 * 60 * 1000), // 30分钟 + updatedAt: new Date() + }) + + return { orderId, _id: result.insertedId } +} + +export async function completeOrder(orderId: string) { + const db = await getDatabase() + const order = await db.collection('orders').findOne({ orderId }) + + if (!order) throw new Error('订单不存在') + + // 更新订单状态 + await db.collection('orders').updateOne( + { orderId }, + { + $set: { + status: 'completed', + paidAt: new Date(), + updatedAt: new Date() + } + } + ) + + // 解锁内容 + if (order.type === 'section') { + await db.collection('users').updateOne( + { _id: order.userId }, + { $addToSet: { purchasedSections: order.sectionId } } + ) + } else if (order.type === 'fullbook') { + await db.collection('users').updateOne( + { _id: order.userId }, + { $set: { hasFullBook: true } } + ) + } + + // 分配佣金 + if (order.referralCode) { + const referrer = await db.collection('users').findOne({ + referralCode: order.referralCode + }) + + if (referrer) { + const commission = order.amount * 0.9 // 90%佣金 + await updateUserEarnings(referrer._id, commission) + + // 记录佣金 + await db.collection('orders').updateOne( + { orderId }, + { $set: { + referrerUserId: referrer._id, + referrerEarnings: commission + }} + ) + } + } +} +\`\`\` + +--- + +## 六、数据备份策略 + +### 6.1 自动备份 + +\`\`\`bash +# 每日凌晨3点自动备份 +0 3 * * * mongodump --uri="mongodb://localhost:27017/soul-experiment" --out="/backup/$(date +\%Y\%m\%d)" +\`\`\` + +### 6.2 恢复数据 + +\`\`\`bash +# 恢复指定日期的备份 +mongorestore --uri="mongodb://localhost:27017/soul-experiment" --dir="/backup/20250114" +\`\`\` + +--- + +## 七、性能优化 + +### 7.1 索引优化 + +\`\`\`javascript +// 创建复合索引 +db.orders.createIndex({ userId: 1, createdAt: -1 }) +db.orders.createIndex({ status: 1, expireAt: 1 }) +db.users.createIndex({ referralCode: 1 }, { unique: true }) + +// 查看索引使用情况 +db.orders.find({ userId: ObjectId("...") }).explain("executionStats") +\`\`\` + +### 7.2 查询优化 + +\`\`\`javascript +// 使用投影减少数据传输 +db.users.find( + { phone: "15880802661" }, + { nickname: 1, referralCode: 1, earnings: 1 } +) + +// 使用聚合管道优化复杂查询 +db.orders.aggregate([ + { $match: { status: "completed" } }, + { $lookup: { + from: "users", + localField: "userId", + foreignField: "_id", + as: "user" + }}, + { $unwind: "$user" }, + { $project: { + orderId: 1, + amount: 1, + "user.nickname": 1 + }} +]) +\`\`\` + +--- + +**总结**: 数据库设计是系统的基石,合理的结构设计能让后续开发事半功倍。当前使用LocalStorage做MVP验证,未来切换MongoDB后,整个系统的可靠性和扩展性都会大幅提升。 + +--- + +**更新时间**: 2025年1月14日 +**负责人**: 卡若 +**数据库版本**: MongoDB 6.0+ diff --git a/开发文档/8、部署/API接入说明.md b/开发文档/8、部署/API接入说明.md new file mode 100644 index 00000000..afa04eaf --- /dev/null +++ b/开发文档/8、部署/API接入说明.md @@ -0,0 +1,610 @@ +# 小程序 API 接入说明 + +## 📋 概述 + +将 newpp 项目从静态数据(bookData.js)改为从真实 API 加载数据。 + +--- + +## 🎯 接入的 API + +### 1. 章节相关 + +| API | 方法 | 说明 | 参数 | +|-----|------|------|------| +| `/api/book/chapters` | GET | 获取章节列表 | partId, status, page, pageSize | +| `/api/book/chapter/[id]` | GET | 获取章节详情 | id(路径参数) | + +### 2. 用户相关 + +| API | 方法 | 说明 | 参数 | +|-----|------|------|------| +| `/api/user/profile` | GET | 获取用户信息 | userId, openId | +| `/api/user/profile` | POST | 更新用户信息 | userId, openId, nickname, avatar, phone, wechatId | + +### 3. 配置相关 + +| API | 方法 | 说明 | 参数 | +|-----|------|------|------| +| `/api/db/config` | GET | 获取系统配置 | 无 | +| `/api/match/config` | GET | 获取找伙伴配置 | 无 | + +### 4. 找伙伴相关 + +| API | 方法 | 说明 | 参数 | +|-----|------|------|------| +| `/api/ckb/join` | POST | 加入匹配池 | type, wechat, description | +| `/api/match/users` | GET | 获取匹配用户 | type | + +### 5. 推广相关 + +| API | 方法 | 说明 | 参数 | +|-----|------|------|------| +| `/api/referral/data` | GET | 获取推广数据 | userId | +| `/api/referral/bind` | POST | 绑定推荐人 | userId, referralCode | +| `/api/referral/visit` | POST | 记录推广访问 | referralCode | + +### 6. 搜索相关 + +| API | 方法 | 说明 | 参数 | +|-----|------|------|------| +| `/api/search` | GET | 搜索章节 | q(关键词) | + +### 7. 支付相关 + +| API | 方法 | 说明 | 参数 | +|-----|------|------|------| +| `/api/payment/create-order` | POST | 创建订单 | userId, type, sectionId, amount, payMethod | +| `/api/payment/status/[orderSn]` | GET | 查询订单状态 | orderSn(路径参数) | +| `/api/payment/methods` | GET | 获取支付方式列表 | 无 | + +### 8. 提现相关 + +| API | 方法 | 说明 | 参数 | +|-----|------|------|------| +| `/api/withdraw` | POST | 申请提现 | userId, amount, method, account, realName | + +--- + +## 📁 文件结构 + +``` +newpp/src/ +├── api/ +│ └── index.js # ✅ API 集成层(封装所有 API) +├── hooks/ +│ ├── useChapters.js # ✅ 章节列表 Hook +│ └── useChapterContent.js # ✅ 章节内容 Hook +├── adapters/ +│ ├── request.js # ✅ 请求适配器(已有) +│ └── storage.js # ✅ 存储适配器(已有) +├── data/ +│ └── bookData.js # ⚠️ 静态数据(待废弃) +└── pages/ + ├── HomePage.jsx # ⏳ 需要改用 useChapters + ├── ChaptersPage.jsx # ⏳ 需要改用 useChapters + ├── ReadPage.jsx # ⏳ 需要改用 useChapterContent + └── ... +``` + +--- + +## 🔧 核心实现 + +### 1. API 集成层 + +**文件**:`newpp/src/api/index.js` + +**作用**: +- 封装所有 API 请求 +- 统一处理错误和数据格式 +- 提供类型化的接口 + +**示例**: + +```javascript +import { request } from '../adapters/request' + +// 获取章节列表 +export async function getChapters(params = {}) { + const { partId, status = 'published', page = 1, pageSize = 100 } = params + const query = new URLSearchParams({ status, page: String(page), pageSize: String(pageSize) }) + if (partId) query.append('partId', partId) + + const res = await request(`/api/book/chapters?${query.toString()}`) + return res +} + +// 获取章节详情 +export async function getChapterById(id) { + const res = await request(`/api/book/chapter/${id}`) + return res +} +``` + +--- + +### 2. 章节列表 Hook + +**文件**:`newpp/src/hooks/useChapters.js` + +**功能**: +1. ✅ 从 API 加载章节列表 +2. ✅ 缓存到本地(30分钟) +3. ✅ 转换数据格式(API → bookData) +4. ✅ 提供辅助函数 + +**使用示例**: + +```javascript +import { useChapters } from '../hooks/useChapters' + +export default function HomePage() { + const { bookData, loading, error, getTotalSectionCount, refresh } = useChapters() + + if (loading) return
      加载中...
      + if (error) return
      错误: {error}
      + + const totalSections = getTotalSectionCount() + + return ( +
      +

      共 {totalSections} 章

      + {bookData.map((part) => ( +
      +

      {part.title}

      + {/* ... */} +
      + ))} +
      + ) +} +``` + +--- + +### 3. 章节内容 Hook + +**文件**:`newpp/src/hooks/useChapterContent.js` + +**功能**: +1. ✅ 从 API 加载章节详情 +2. ✅ 自动处理 loading 和 error +3. ✅ 支持重新加载 + +**使用示例**: + +```javascript +import { useChapterContent } from '../hooks/useChapterContent' +import { getPageQuery } from '../adapters/router' + +export default function ReadPage() { + const { id } = getPageQuery() + const { content, loading, error, reload } = useChapterContent(id) + + if (loading) return
      加载中...
      + if (error) return
      错误: {error}
      + if (!content) return
      章节不存在
      + + return ( +
      +

      {content.title}

      +

      {content.words} 字

      +
      +
      + ) +} +``` + +--- + +## 🔄 数据转换 + +### API 返回格式 + +```json +{ + "success": true, + "data": { + "list": [ + { + "id": "1.1", + "part_id": "part-1", + "part_title": "真实的人", + "chapter_id": "chapter-1", + "chapter_title": "人与人之间的底层逻辑", + "section_title": "荷包:电动车出租的被动收入模式", + "content": "...", + "word_count": 1500, + "is_free": true, + "price": 0, + "sort_order": 1, + "status": "published" + } + ], + "total": 50, + "page": 1, + "pageSize": 100, + "totalPages": 1 + } +} +``` + +### bookData 格式 + +```javascript +[ + { + id: 'part-1', + number: '01', + title: '真实的人', + subtitle: '人性观察与社交逻辑', + chapters: [ + { + id: 'chapter-1', + title: '人与人之间的底层逻辑', + sections: [ + { + id: '1.1', + title: '荷包:电动车出租的被动收入模式', + isFree: true, + price: 1, + wordCount: 1500, + } + ] + } + ] + } +] +``` + +### 转换函数 + +```javascript +function transformChapters(chapters) { + const partsMap = new Map() + + chapters.forEach((item) => { + // 确保 part 存在 + if (!partsMap.has(item.part_id)) { + partsMap.set(item.part_id, { + id: item.part_id, + number: item.part_id.replace('part-', '').padStart(2, '0'), + title: item.part_title, + subtitle: '', + chapters: [] + }) + } + + const part = partsMap.get(item.part_id) + + // 查找或创建 chapter + let chapter = part.chapters.find((c) => c.id === item.chapter_id) + if (!chapter) { + chapter = { + id: item.chapter_id, + title: item.chapter_title, + sections: [] + } + part.chapters.push(chapter) + } + + // 添加 section + chapter.sections.push({ + id: item.id, + title: item.section_title, + isFree: item.is_free || false, + price: item.price || 1, + wordCount: item.word_count || 0, + }) + }) + + return Array.from(partsMap.values()) +} +``` + +--- + +## 📦 缓存策略 + +### 缓存位置 + +- **小程序**:`wx.storage` +- **Web**:`localStorage` + +### 缓存时长 + +- **章节列表**:30分钟 +- **章节内容**:不缓存(内容可能更新) + +### 缓存格式 + +```javascript +{ + data: [...], // 数据 + timestamp: 1706940000000 // 时间戳 +} +``` + +### 缓存逻辑 + +```javascript +// 1. 尝试从缓存加载 +const cached = await storage.getItem(CACHE_KEY) +if (cached) { + const { data, timestamp } = JSON.parse(cached) + if (Date.now() - timestamp < CACHE_DURATION) { + setBookData(data) + return + } +} + +// 2. 从 API 加载 +const res = await getChapters({ status: 'published', pageSize: 1000 }) +const transformed = transformChapters(res.data.list) +setBookData(transformed) + +// 3. 缓存数据 +await storage.setItem(CACHE_KEY, JSON.stringify({ + data: transformed, + timestamp: Date.now() +})) +``` + +--- + +## 🔄 迁移步骤 + +### Phase 1:创建 API 层 ✅ + +- [x] 创建 `api/index.js` +- [x] 创建 `hooks/useChapters.js` +- [x] 创建 `hooks/useChapterContent.js` + +### Phase 2:更新页面组件 + +#### 2.1 HomePage.jsx + +**Before**: + +```javascript +import { getTotalSectionCount, bookData } from '../data/bookData' + +const totalSections = getTotalSectionCount() +``` + +**After**: + +```javascript +import { useChapters } from '../hooks/useChapters' + +export default function HomePage() { + const { bookData, loading, getTotalSectionCount } = useChapters() + + if (loading) return + + const totalSections = getTotalSectionCount() + // ... +} +``` + +#### 2.2 ChaptersPage.jsx + +**Before**: + +```javascript +import { bookData } from '../data/bookData' +``` + +**After**: + +```javascript +import { useChapters } from '../hooks/useChapters' + +export default function ChaptersPage() { + const { bookData, loading } = useChapters() + + if (loading) return + // ... +} +``` + +#### 2.3 ReadPage.jsx + +**Before**: + +```javascript +import { getSectionById } from '../data/bookData' + +const section = getSectionById(id) +``` + +**After**: + +```javascript +import { useChapterContent } from '../hooks/useChapterContent' +import { getPageQuery } from '../adapters/router' + +export default function ReadPage() { + const { id } = getPageQuery() + const { content, loading } = useChapterContent(id) + + if (loading) return + if (!content) return + // ... +} +``` + +#### 2.4 SearchPage.jsx + +**Before**: + +```javascript +import { getAllSections } from '../data/bookData' + +const results = getAllSections().filter(s => s.title.includes(keyword)) +``` + +**After**: + +```javascript +import { searchChapters } from '../api' + +export default function SearchPage() { + const [results, setResults] = useState([]) + + const handleSearch = async (keyword) => { + const res = await searchChapters(keyword) + setResults(res.data || []) + } + // ... +} +``` + +### Phase 3:集成到 Zustand Store + +```javascript +// store/index.js +import { getChapters } from '../api' + +const useStore = create( + persist( + (set, get) => ({ + // ... 其他状态 + + // ✅ 添加章节数据 + bookData: [], + loadChapters: async () => { + const res = await getChapters({ status: 'published', pageSize: 1000 }) + if (res.success) { + set({ bookData: transformChapters(res.data.list) }) + } + }, + }), + { + name: 'soul-party-storage', + storage: {/* ... */}, + } + ) +) +``` + +### Phase 4:移除静态数据 + +- [ ] 删除或重命名 `data/bookData.js` +- [ ] 更新所有导入路径 + +--- + +## 🐛 错误处理 + +### API 请求失败 + +```javascript +try { + const res = await getChapters() + if (!res.success) { + throw new Error(res.error || '请求失败') + } +} catch (err) { + console.error('加载失败:', err) + setError(err.message) + + // ✅ 降级策略:使用缓存数据 + const cached = await storage.getItem(CACHE_KEY) + if (cached) { + const { data } = JSON.parse(cached) + setBookData(data) + } +} +``` + +### 网络超时 + +```javascript +// adapters/request.js +export function request(url, options = {}) { + const controller = new AbortController() + const timeout = setTimeout(() => controller.abort(), 10000) // 10秒超时 + + return fetch(fullUrl, { + ...options, + signal: controller.signal, + }) + .finally(() => clearTimeout(timeout)) +} +``` + +--- + +## 📊 性能优化 + +### 1. 缓存策略 + +- ✅ 章节列表缓存 30 分钟 +- ✅ 减少 API 调用次数 +- ✅ 提升加载速度 + +### 2. 懒加载 + +```javascript +// 只在需要时加载章节内容 +useEffect(() => { + if (visible) { + loadContent() + } +}, [visible]) +``` + +### 3. 预加载 + +```javascript +// 预加载下一章内容 +useEffect(() => { + if (content && nextChapterId) { + // 延迟 2 秒预加载 + const timer = setTimeout(() => { + getChapterById(nextChapterId) + }, 2000) + return () => clearTimeout(timer) + } +}, [content, nextChapterId]) +``` + +--- + +## 🧪 测试清单 + +### API 集成测试 + +- [ ] 章节列表加载成功 +- [ ] 章节详情加载成功 +- [ ] 用户信息获取成功 +- [ ] 配置加载成功 +- [ ] 搜索功能正常 +- [ ] 错误处理正确 + +### 缓存测试 + +- [ ] 首次加载从 API 获取 +- [ ] 第二次加载从缓存读取 +- [ ] 缓存过期后重新加载 +- [ ] 缓存数据格式正确 + +### 跨平台测试 + +- [ ] Web 环境正常 +- [ ] 小程序环境正常 +- [ ] 数据格式一致 + +--- + +## 📚 相关文档 + +1. [API 集成层代码](../newpp/src/api/index.js) +2. [章节列表 Hook](../newpp/src/hooks/useChapters.js) +3. [章节内容 Hook](../newpp/src/hooks/useChapterContent.js) + +--- + +**总结**:API 集成层已完成,接下来需要更新各个页面组件,将静态数据改为从 API 加载。 diff --git a/开发文档/8、部署/MCP-MySQL配置说明.md b/开发文档/8、部署/MCP-MySQL配置说明.md new file mode 100644 index 00000000..5f5c1690 --- /dev/null +++ b/开发文档/8、部署/MCP-MySQL配置说明.md @@ -0,0 +1,401 @@ +# MCP MySQL 配置说明 + +**日期**: 2026-02-04 +**目的**: 通过 MCP (Model Context Protocol) 在 Cursor 中直接操作 Soul 小程序数据库 + +--- + +## ✅ 已配置的 MCP 服务 + +### 1. Soul-MySQL(新增) +**用途**: Soul 小程序生产数据库操作 + +**配置文件**: `C:\Users\29195\.cursor\mcp.json` + +```json +{ + "Soul-MySQL": { + "command": "npx", + "args": [ + "-y", + "@f4ww4z/mcp-mysql-server", + "--host", + "56b4c23f6853c.gz.cdb.myqcloud.com", + "--port", + "14413", + "--user", + "cdb_outerroot", + "--password", + "Zhiqun1984", + "--database", + "soul_miniprogram" + ], + "env": {} + } +} +``` + +**数据库信息**: +- **主机**: 56b4c23f6853c.gz.cdb.myqcloud.com(腾讯云 CDB) +- **端口**: 14413 +- **用户**: cdb_outerroot +- **密码**: Zhiqun1984 +- **数据库**: soul_miniprogram + +--- + +## 🔧 使用方法 + +### 1. 重启 Cursor +配置文件修改后,需要**完全重启 Cursor** 才能生效: +1. 关闭所有 Cursor 窗口 +2. 重新打开 Cursor +3. 等待 MCP 服务启动 + +### 2. 验证连接 +在 Cursor 中输入: +``` +@Soul-MySQL 列出所有表 +``` + +或使用工具调用: +```javascript +// 查询所有表 +user-MySQL-list_tables + +// 查看表结构 +user-MySQL-describe_table +{ + "table": "orders" +} + +// 执行查询 +user-MySQL-query +{ + "sql": "SELECT * FROM orders LIMIT 10" +} +``` + +--- + +## 📊 可用的操作 + +### 1. 查询数据(只读) +```sql +-- 查看最近订单 +SELECT * FROM orders +ORDER BY created_at DESC +LIMIT 10; + +-- 统计订单状态 +SELECT status, COUNT(*) as count, SUM(amount) as total +FROM orders +GROUP BY status; + +-- 查看用户购买情况 +SELECT + u.id, + u.nickname, + u.has_full_book, + COUNT(o.id) as order_count, + SUM(o.amount) as total_spent +FROM users u +LEFT JOIN orders o ON u.id = o.user_id AND o.status = 'paid' +GROUP BY u.id, u.nickname, u.has_full_book +ORDER BY total_spent DESC +LIMIT 20; +``` + +### 2. 修改数据(慎重!) +```sql +-- 修复订单表 status 字段(关键修复) +ALTER TABLE orders +MODIFY COLUMN status ENUM('created', 'pending', 'paid', 'cancelled', 'refunded', 'expired') +DEFAULT 'created'; + +-- 手动解锁用户章节 +UPDATE users +SET purchased_sections = JSON_ARRAY_APPEND( + COALESCE(purchased_sections, '[]'), '$', '1-1' +) +WHERE id = 'user_xxx'; + +-- 手动补记订单 +INSERT INTO orders ( + id, order_sn, user_id, open_id, + product_type, product_id, amount, description, + status, transaction_id, pay_time, created_at, updated_at +) VALUES ( + 'MP20260204123456789012', 'MP20260204123456789012', + 'user_xxx', 'oXXXX...', 'section', '1-1', 9.9, + '章节1-1购买', 'paid', 'wx_transaction_id', + NOW(), NOW(), NOW() +); +``` + +### 3. 查看表结构 +```sql +-- 查看表结构 +DESCRIBE orders; +DESCRIBE users; +DESCRIBE referral_bindings; + +-- 查看索引 +SHOW INDEX FROM orders; + +-- 查看表创建语句 +SHOW CREATE TABLE orders; +``` + +--- + +## ⚠️ 重要提醒 + +### 1. 生产数据库操作 +- ⚠️ 这是**生产数据库**,所有操作都会**直接影响线上服务** +- ✅ 查询操作(SELECT)相对安全 +- ❌ 修改操作(UPDATE/DELETE/ALTER)**必须谨慎** +- 💡 建议先在本地数据库测试 + +### 2. 数据备份 +修改重要数据前,建议先备份: +```sql +-- 备份整个表 +CREATE TABLE orders_backup AS SELECT * FROM orders; + +-- 备份特定数据 +CREATE TABLE orders_backup_20260204 AS +SELECT * FROM orders WHERE DATE(created_at) = '2026-02-04'; +``` + +### 3. 事务操作 +对于关联性强的修改,使用事务: +```sql +START TRANSACTION; + +-- 修改操作1 +UPDATE users SET has_full_book = TRUE WHERE id = 'user_xxx'; + +-- 修改操作2 +INSERT INTO orders (...) VALUES (...); + +-- 确认无误后提交 +COMMIT; + +-- 或者出错时回滚 +-- ROLLBACK; +``` + +--- + +## 🎯 常见操作场景 + +### 场景1: 修复订单表状态字段 +```sql +-- 1. 先查看当前定义 +SHOW CREATE TABLE orders; + +-- 2. 修改 ENUM 定义 +ALTER TABLE orders +MODIFY COLUMN status ENUM('created', 'pending', 'paid', 'cancelled', 'refunded', 'expired') +DEFAULT 'created'; + +-- 3. 验证修改 +DESCRIBE orders; +``` + +### 场景2: 查询用户支付问题 +```sql +-- 查询特定用户的订单记录 +SELECT * FROM orders +WHERE user_id = 'ogpTW5a9exdEmEwqZsYywvgSpSQg' +ORDER BY created_at DESC; + +-- 查询用户购买记录 +SELECT + id, nickname, has_full_book, purchased_sections, + pending_earnings, earnings +FROM users +WHERE id = 'ogpTW5a9exdEmEwqZsYywvgSpSQg'; + +-- 查询用户推荐关系 +SELECT * FROM referral_bindings +WHERE referee_id = 'ogpTW5a9exdEmEwqZsYywvgSpSQg' + OR referrer_id = 'ogpTW5a9exdEmEwqZsYywvgSpSQg'; +``` + +### 场景3: 统计数据分析 +```sql +-- 今日订单统计 +SELECT + COUNT(*) as total_orders, + SUM(CASE WHEN status = 'paid' THEN 1 ELSE 0 END) as paid_orders, + SUM(CASE WHEN status = 'paid' THEN amount ELSE 0 END) as total_revenue +FROM orders +WHERE DATE(created_at) = CURDATE(); + +-- 用户活跃度统计 +SELECT + DATE(created_at) as date, + COUNT(DISTINCT user_id) as active_users, + COUNT(*) as total_orders, + SUM(amount) as revenue +FROM orders +WHERE status = 'paid' + AND created_at >= DATE_SUB(NOW(), INTERVAL 7 DAY) +GROUP BY DATE(created_at) +ORDER BY date DESC; + +-- 推广效果统计 +SELECT + u.nickname as referrer, + COUNT(rb.id) as total_referrals, + SUM(CASE WHEN rb.status = 'converted' THEN 1 ELSE 0 END) as conversions, + SUM(rb.commission_amount) as total_commission +FROM users u +LEFT JOIN referral_bindings rb ON u.id = rb.referrer_id +WHERE rb.id IS NOT NULL +GROUP BY u.id, u.nickname +ORDER BY total_commission DESC +LIMIT 20; +``` + +### 场景4: 紧急数据修复 +```sql +-- 手动解锁用户权限(用户支付但未解锁) +START TRANSACTION; + +-- 1. 补记订单 +INSERT INTO orders ( + id, order_sn, user_id, open_id, + product_type, product_id, amount, description, + status, transaction_id, pay_time, created_at, updated_at +) VALUES ( + 'MANUAL_20260204_001', 'MANUAL_20260204_001', + 'user_xxx', 'oXXXX...', 'section', '1-1', 9.9, + '手动补记-章节1-1购买', 'paid', 'manual_fix', + NOW(), NOW(), NOW() +); + +-- 2. 解锁章节 +UPDATE users +SET purchased_sections = JSON_ARRAY_APPEND( + COALESCE(purchased_sections, '[]'), '$', '1-1' +) +WHERE id = 'user_xxx' + AND NOT JSON_CONTAINS(COALESCE(purchased_sections, '[]'), '"1-1"'); + +-- 3. 如果有推荐人,分配佣金 +UPDATE users +SET pending_earnings = pending_earnings + (9.9 * 0.9) +WHERE id = (SELECT referred_by FROM users WHERE id = 'user_xxx'); + +-- 4. 更新推荐关系状态 +UPDATE referral_bindings +SET status = 'converted', + conversion_date = NOW(), + commission_amount = 8.91, + order_id = 'MANUAL_20260204_001' +WHERE referee_id = 'user_xxx' + AND status = 'active'; + +COMMIT; +``` + +--- + +## 🔗 其他 MCP 服务 + +### MySQL(本地) +- **用途**: 本地 sass 数据库 +- **主机**: localhost:3306 +- **数据库**: sass + +### MongoDB +- **用途**: 测试 MongoDB 连接 +- **连接**: mongodb://admin:admin123@192.168.1.201:27017/admin + +### Ollama +- **用途**: 本地 AI 模型调用 +- **脚本**: C:\Users\29195\mcp_ollama_server.py + +--- + +## 📝 MCP 工具列表 + +使用 `@Soul-MySQL` 可以调用以下工具: + +| 工具名 | 功能 | 示例 | +|--------|------|------| +| `user-MySQL-connect_db` | 连接数据库 | 自动连接 | +| `user-MySQL-query` | 执行 SELECT 查询 | `{"sql": "SELECT * FROM orders LIMIT 10"}` | +| `user-MySQL-execute` | 执行 INSERT/UPDATE/DELETE | `{"sql": "UPDATE users SET ..."}` | +| `user-MySQL-list_tables` | 列出所有表 | 无参数 | +| `user-MySQL-describe_table` | 查看表结构 | `{"table": "orders"}` | + +--- + +## 🚀 快速开始 + +### 1. 检查订单表状态 +``` +@Soul-MySQL 执行查询:DESCRIBE orders; +``` + +### 2. 查看最近订单 +``` +@Soul-MySQL 查询最近10条订单记录 +``` + +### 3. 修复订单表(如需要) +``` +@Soul-MySQL 执行以下SQL: +ALTER TABLE orders +MODIFY COLUMN status ENUM('created', 'pending', 'paid', 'cancelled', 'refunded', 'expired') +DEFAULT 'created'; +``` + +--- + +## ⚡ 故障排查 + +### 问题1: MCP 服务未启动 +**症状**: 输入 `@Soul-MySQL` 没有提示 + +**解决**: +1. 完全关闭 Cursor +2. 检查 mcp.json 文件格式是否正确 +3. 重新打开 Cursor +4. 查看 Cursor 输出日志 + +### 问题2: 连接超时 +**症状**: 执行查询时提示连接超时 + +**解决**: +1. 检查网络连接 +2. 确认数据库服务器是否在线 +3. 检查防火墙/安全组配置 +4. 验证数据库账号密码 + +### 问题3: 权限不足 +**症状**: 提示没有权限执行某些操作 + +**解决**: +1. 检查数据库用户权限 +2. 某些操作需要超级管理员权限 +3. 联系 DBA 授权 + +--- + +## 📚 相关文档 + +- [支付订单完整修复方案](./支付订单完整修复方案.md) +- [订单表状态字段修复说明](./订单表状态字段修复说明.md) +- [支付订单未创建问题分析](./支付订单未创建问题分析.md) +- [数据库设计](../7、数据库/数据库设计.md) + +--- + +**现在你可以在 Cursor 中直接使用 `@Soul-MySQL` 来操作生产数据库了!** 🎉 + +**记得重启 Cursor 使配置生效!** diff --git a/开发文档/8、部署/Soul-MySQL-MCP配置说明.md b/开发文档/8、部署/Soul-MySQL-MCP配置说明.md new file mode 100644 index 00000000..cbbad0e4 --- /dev/null +++ b/开发文档/8、部署/Soul-MySQL-MCP配置说明.md @@ -0,0 +1,84 @@ +# Soul-MySQL MCP 配置说明 + +**配置文件**: `C:\Users\29195\.cursor\mcp.json` + +--- + +## 为什么之前无法执行? + +### 原因 1:连接时没有带端口 + +- 之前用 `--host`、`--port` 分开传参,部分 MCP 客户端在**运行时**调用 `connect_db` 时**只传 host/user/password/database,不传 port**。 +- 你的数据库在 **14413**,MySQL 默认是 **3306**,所以实际连的是错误端口 → 容易 **ETIMEDOUT** 或连不上。 +- 所以会出现「无法执行」或执行报错。 + +### 原因 2:改用「连接串」才能带上端口 + +- `@f4ww4z/mcp-mysql-server` 支持用**一条连接串**启动,格式里可以写清楚端口: + - `mysql://用户:密码@主机:端口/数据库名` +- 这样 MCP 启动时就会用 **14413** 去连,不会再用默认 3306。 + +--- + +## 当前正确配置(连接串方式) + +在 `mcp.json` 里 Soul-MySQL 应类似: + +```json +"Soul-MySQL": { + "command": "npx", + "args": [ + "-y", + "@f4ww4z/mcp-mysql-server", + "mysql://cdb_outerroot:Zhiqun1984@56b4c23f6853c.gz.cdb.myqcloud.com:14413/soul_miniprogram" + ], + "env": {} +} +``` + +含义: + +- **用户**: cdb_outerroot +- **密码**: Zhiqun1984 +- **主机**: 56b4c23f6853c.gz.cdb.myqcloud.com +- **端口**: 14413(写在连接串里) +- **数据库**: soul_miniprogram + +这样 MCP 会按 `主机:14413` 连接,不再用 3306。 + +--- + +## 使用前必做:重启 Cursor + +1. **完全退出 Cursor**(关掉所有窗口)。 +2. 再重新打开 Cursor。 +3. 等 MCP 列表里 Soul-MySQL 显示为已连接/可用。 + +否则会继续用旧配置(不带端口),仍然无法执行。 + +--- + +## 若仍无法执行,可排查这些 + +### 1. 本机网络/防火墙 + +- 数据库在腾讯云,若你本机或公司网络**不允许访问外网 14413**,连接会超时。 +- 解决:在能访问该库的机器上跑 Cursor(或先做 SSH 隧道,把 14413 转到本机 3306,再在 mcp.json 里连 localhost:3306)。 + +### 2. 腾讯云白名单 + +- 腾讯云 MySQL 有「来源 IP 白名单」。 +- 你当前上网的 **公网 IP** 必须在白名单里,否则会被拒绝。 +- 解决:在腾讯云控制台 → 该 MySQL 实例 → 白名单里加上你当前的公网 IP。 + +### 3. 密码含特殊字符 + +- 若以后改了密码,且密码里有 `@`、`#`、`/` 等,需要做 **URL 编码** 再写进连接串,否则连接串会被解析错。 + +--- + +## 小结 + +- **无法执行** 多半是:连库时**没带端口 14413** 或**网络/白名单**不通。 +- 已把 Soul-MySQL 改成**带端口的连接串**配置,并写进 `mcp.json`。 +- 修改后**务必重启 Cursor** 再试;若仍不行,按上面「若仍无法执行」逐项排查。 diff --git a/开发文档/8、部署/VIP功能-数据库迁移说明.md b/开发文档/8、部署/VIP功能-数据库迁移说明.md new file mode 100644 index 00000000..66b09558 --- /dev/null +++ b/开发文档/8、部署/VIP功能-数据库迁移说明.md @@ -0,0 +1,49 @@ +# VIP 功能 - 数据库迁移说明 + +> 2026-02-26 小橙同步。VIP 排序、角色、设置入口升级。 + +--- + +## 一、迁移脚本 + +| 脚本 | 说明 | +|------|------| +| `soul-api/scripts/add-vip-activated-at.sql` | 新增 `users.vip_activated_at`(成为 VIP 时间,排序用) | +| `soul-api/scripts/add-vip-roles-and-fields.sql` | 新建 `vip_roles` 表;新增 `users.vip_sort`、`users.vip_role` | +| `soul-api/scripts/add-vip-profile-fields.sql` | 新增 `users.vip_name`、`vip_avatar`、`vip_project`、`vip_contact`、`vip_bio`(会员资料,与用户信息分离) | + +--- + +## 二、执行顺序 + +```bash +# 1. vip_activated_at(若尚未执行) +mysql -u user -p database < soul-api/scripts/add-vip-activated-at.sql + +# 2. vip_roles 表 + users 新字段 +mysql -u user -p database < soul-api/scripts/add-vip-roles-and-fields.sql + +# 3. 会员资料字段(若尚未执行;列已存在会报 Duplicate column,可忽略) +mysql -u user -p database < soul-api/scripts/add-vip-profile-fields.sql +``` + +若 `vip_sort`、`vip_role` 已存在,对应 `ALTER` 会报错,可忽略或单独执行未执行过的语句。 + +--- + +## 三、功能说明 + +| 字段/表 | 用途 | +|---------|------| +| `vip_activated_at` | 成为 VIP 时间:付款=订单 pay_time,手动=设置时 now;排序用(后付款/后设置在前) | +| `vip_sort` | 手动排序,数字越小越靠前;NULL 时按 vip_activated_at | +| `vip_role` | 角色:从 vip_roles 选或手动填写 | +| `vip_roles` | 预设角色表(创始人、投资人、产品经理等),管理端可 CRUD | +| `vip_name`、`vip_avatar`、`vip_project`、`vip_contact`、`vip_bio` | 会员资料(创业老板排行),与用户信息 phone/wechat_id 分离 | + +--- + +## 四、管理端入口 + +- **用户列表**:每行「设置 VIP」按钮(Crown 图标)→ SetVipModal +- **VIP 角色**:侧栏「VIP 角色」→ `/vip-roles`,管理预设角色列表 diff --git a/开发文档/8、部署/代码逻辑和数据库最终检查清单.md b/开发文档/8、部署/代码逻辑和数据库最终检查清单.md new file mode 100644 index 00000000..8f7cf88d --- /dev/null +++ b/开发文档/8、部署/代码逻辑和数据库最终检查清单.md @@ -0,0 +1,363 @@ +# 代码逻辑和数据库最终检查清单 ✅ + +## 📊 数据库修改(已完成) + +### 1. referral_bindings 表新增字段 +```sql +✅ last_purchase_date DATETIME DEFAULT NULL +✅ purchase_count INT DEFAULT 0 +✅ total_commission DECIMAL(10,2) DEFAULT 0.00 +✅ status ENUM('active', 'expired', 'cancelled') -- 新增 'cancelled' +``` + +### 2. 索引优化 +```sql +✅ idx_status_expiry (status, expiry_date) +✅ idx_referee_status (referee_id, status) +✅ idx_referrer_status (referrer_id, status) +✅ idx_purchase_count (purchase_count) +``` + +### 3. 数据库迁移执行状态 +- ✅ 已通过 `scripts/migrate_db_simple.py` 成功执行 +- ✅ 所有字段已添加 +- ✅ 所有索引已创建 + +--- + +## 🔧 核心API逻辑(已验证) + +### 1. `/api/referral/bind` - 绑定/切换推荐人 ✅ + +**文件**: `app/api/referral/bind/route.ts` + +**关键逻辑**: +```typescript +✅ 从 referral_config 读取 bindingDays(不再硬编码 30 天) +✅ 同一推荐人 → 续期(刷新 30 天) +✅ 不同推荐人 → 立即切换(无需等待过期) + - 旧绑定标记为 'cancelled' + - 创建新绑定,expiry_date = NOW + bindingDays + - 更新 users.referral_count(旧 -1,新 +1) +``` + +**验证点**: +- ✅ 绑定天数可配置 +- ✅ 切换逻辑正确(不检查 expiry_date) +- ✅ 旧绑定正确标记为 'cancelled' +- ✅ 新绑定正确创建 +- ✅ 推荐人数量正确更新 + +--- + +### 2. `/api/miniprogram/pay` - 创建支付订单 ✅ + +**文件**: `app/api/miniprogram/pay/route.ts` + +**关键逻辑**: +```typescript +✅ 从 referral_config 读取 userDiscount(如 5 表示 5%) +✅ 如果有 referralCode,计算折后价 + finalAmount = amount * (1 - userDiscount / 100) + finalAmount = max(0.01, round(finalAmount, 2)) +✅ 微信支付使用 finalAmount(折后价) +✅ 订单表记录 finalAmount(折后价) +``` + +**验证点**: +- ✅ 折扣正确应用(原价 1.00,5% off = 0.95) +- ✅ 最低金额保护(至少 0.01 元) +- ✅ 金额精确到分(Math.round) +- ✅ 订单表记录的是折后价 + +--- + +### 3. `/api/miniprogram/pay/notify` - 支付回调 ✅ + +**文件**: `app/api/miniprogram/pay/notify/route.ts` + +**关键逻辑**: +```typescript +✅ 查找 status = 'active' 的绑定记录 +✅ 检查 expiry_date > NOW(过期不分佣) +✅ 从 referral_config 读取 distributorShare +✅ 计算佣金:commission = amount * distributorShare / 100 +✅ 更新 users.pending_earnings += commission +✅ 更新 referral_bindings: + - last_purchase_date = NOW + - purchase_count += 1 + - total_commission += commission + - status 保持 'active'(不再改为 'converted') +``` + +**验证点**: +- ✅ 只给 active 且未过期的绑定分佣 +- ✅ 佣金比例可配置 +- ✅ 支持多次购买分佣(不改 status) +- ✅ 正确累加购买次数和佣金 +- ✅ 记录最后购买时间 + +--- + +### 4. `/api/withdraw` - 提现申请 ✅ + +**文件**: `app/api/withdraw/route.ts` + +**关键逻辑**: +```typescript +✅ 从 referral_config 读取 minWithdrawAmount +✅ 验证 amount >= minWithdrawAmount(不再硬编码 10 元) +✅ 验证 amount <= pending_earnings +``` + +**验证点**: +- ✅ 最低提现金额可配置 +- ✅ 金额验证逻辑正确 + +--- + +### 5. `/api/referral/data` - 分销数据统计 ✅ + +**文件**: `app/api/referral/data/route.ts` + +**关键逻辑**: +```typescript +✅ 绑定统计: + - active: status = 'active' AND expiry_date > NOW + - converted: status = 'active' AND purchase_count > 0 + - expired: status IN ('expired', 'cancelled') OR expiry_date <= NOW + +✅ 已转化用户列表: + WHERE status = 'active' AND purchase_count > 0 + ORDER BY last_purchase_date DESC + +✅ 返回购买次数、累计佣金 +``` + +**验证点**: +- ✅ 不再查询 status = 'converted' +- ✅ 使用 purchase_count 判断是否已购买 +- ✅ 返回新增的字段(purchase_count, total_commission) +- ✅ 统计逻辑正确(包含 'cancelled' 状态) + +--- + +## 🎯 管理后台(已验证) + +### 1. 推广设置页面 ✅ + +**文件**: `app/admin/referral-settings/page.tsx` + +**配置项**: +```typescript +✅ distributorShare (分销比例, 0-100) +✅ minWithdrawAmount (最低提现金额, 元) +✅ bindingDays (绑定天数, 天) +✅ userDiscount (好友优惠, 0-100) +✅ enableAutoWithdraw (自动提现, boolean) +``` + +**验证点**: +- ✅ 读取配置正确 +- ✅ 保存配置正确(Number/Boolean 转换) +- ✅ 表单验证正确 +- ✅ 成功提示清晰 + +--- + +### 2. 管理后台菜单 ✅ + +**文件**: `app/admin/layout.tsx` + +```typescript +✅ 新增菜单项: "推广设置" → /admin/referral-settings +✅ 图标: CreditCard +✅ 位置: "用户管理" 和 "系统设置" 之间 +``` + +--- + +## 📱 小程序端(已完成) + +### 1. UI修改 ✅ +```xml +✅ 删除"我的邀请码"卡片(miniprogram/pages/referral/referral.wxml) +``` + +### 2. 绑定逻辑 ✅ +```javascript +✅ app.js 调用 /api/referral/bind(后端已实现立即切换) +✅ 无需前端修改 +``` + +### 3. 支付逻辑 ✅ +```javascript +✅ pages/read/read.js 传递 referralCode(后端已实现折扣) +✅ 无需前端修改 +``` + +### 4. 数据展示 ✅ +```javascript +✅ pages/referral/referral.js 调用 /api/referral/data +✅ 后端已返回新字段(purchase_count, total_commission) +✅ 无需前端修改 +``` + +--- + +## ⏰ 定时任务(已创建) + +### 1. 自动解绑脚本 ✅ + +**文件**: `scripts/auto-unbind-expired-simple.js` + +**逻辑**: +```javascript +✅ 查找 status = 'active' AND expiry_date < NOW AND purchase_count = 0 +✅ 批量更新为 status = 'expired' +✅ 输出详细日志 +``` + +**部署**: +```bash +⏸️ 需在宝塔面板配置: 每天 03:00 执行 + 命令: cd /www/wwwroot/soul.quwanzhi.com && /www/server/nodejs/v20.11.0/bin/node scripts/auto-unbind-expired-simple.js >> logs/auto-unbind.log 2>&1 +``` + +--- + +## 🔍 业务逻辑验证 + +### 场景1: 首次绑定 ✅ +``` +A 分享链接 → B 点击 → /api/referral/bind +→ 创建新绑定(status = 'active', expiry_date = NOW + 30天) +→ users.referral_count += 1 +``` + +### 场景2: 切换推荐人 ✅ +``` +B 已绑定 A → B 点击 C 的链接 → /api/referral/bind +→ 旧绑定(A-B)标记为 'cancelled' +→ 创建新绑定(C-B, status = 'active', expiry_date = NOW + 30天) +→ A.referral_count -= 1, C.referral_count += 1 +``` + +### 场景3: 续期绑定 ✅ +``` +B 已绑定 A → B 再次点击 A 的链接 → /api/referral/bind +→ 更新绑定(expiry_date = NOW + 30天) +→ referral_count 不变 +``` + +### 场景4: 首次购买 ✅ +``` +B 绑定 C(5天前)→ B 购买 1.00 元章节(有 5% 优惠) +→ 实付 0.95 元 +→ C 获得佣金 0.95 * 90% = 0.855 元(四舍五入 0.86) +→ referral_bindings: purchase_count = 1, total_commission = 0.86, last_purchase_date = NOW +→ C.pending_earnings += 0.86 +→ 绑定保持 'active' +``` + +### 场景5: 多次购买 ✅ +``` +B 再次购买 1.00 元章节(还在 30 天内) +→ 实付 0.95 元 +→ C 再获得佣金 0.86 元 +→ referral_bindings: purchase_count = 2, total_commission = 1.72, last_purchase_date = NOW +→ C.pending_earnings += 0.86(累计 1.72) +→ 绑定保持 'active' +``` + +### 场景6: 自动解绑 ✅ +``` +B 绑定 A(30 天前)→ B 从未购买 → 定时任务执行 +→ 查找: status = 'active' AND expiry_date < NOW AND purchase_count = 0 +→ 更新: status = 'expired' +→ A.referral_count -= 1 +``` + +### 场景7: 提现 ✅ +``` +C 有 pending_earnings = 15.00 元 → 申请提现 12.00 元 +→ 验证 amount >= minWithdrawAmount(默认 10) +→ 验证 amount <= pending_earnings +→ 创建提现记录 +→ C.pending_earnings -= 12.00 = 3.00 +``` + +--- + +## ✅ 最终确认 + +### 代码逻辑 +- ✅ 所有 API 已适配新逻辑 +- ✅ 所有硬编码值已改为动态配置 +- ✅ 所有状态转换逻辑正确 +- ✅ 所有金额计算精确到分 + +### 数据库 +- ✅ 所有字段已添加 +- ✅ 所有索引已创建 +- ✅ 数据类型正确 +- ✅ 默认值正确 + +### 小程序 +- ✅ UI 已删除邀请码卡片 +- ✅ 绑定逻辑兼容后端 +- ✅ 支付逻辑兼容后端 +- ✅ 数据展示兼容后端 + +### 管理后台 +- ✅ 推广设置页面已创建 +- ✅ 菜单已添加 +- ✅ 配置读写正确 + +### 定时任务 +- ✅ 脚本已创建 +- ⏸️ 需在宝塔配置(部署时) + +--- + +## 🚀 部署检查项 + +部署前确认: +- ✅ 代码已修改 +- ✅ 数据库已迁移 +- ✅ 本地测试通过 + +部署后确认: +- ⏸️ PM2 重启成功 +- ⏸️ 定时任务配置成功 +- ⏸️ 管理后台可访问 `/admin/referral-settings` +- ⏸️ 小程序绑定/支付/分佣功能测试通过 + +--- + +## 📝 测试用例(可选) + +如需本地测试,运行: +```bash +node scripts/test-referral-flow.js +``` + +测试覆盖: +- ✅ 首次绑定 +- ✅ 续期绑定 +- ✅ 切换绑定 +- ✅ 首次购买分佣 +- ✅ 多次购买分佣 +- ✅ 过期绑定不分佣 + +--- + +## ✅ 结论 + +**所有代码逻辑和数据库修改已完成并验证,可以放心部署!** + +需要在宝塔面板配置的只有: +1. 重启 PM2 服务(让新代码生效) +2. 配置定时任务(自动解绑) + +参考文档: `开发文档/8、部署/新分销逻辑-宝塔操作清单.md` diff --git a/开发文档/8、部署/佣金计算逻辑检查.md b/开发文档/8、部署/佣金计算逻辑检查.md new file mode 100644 index 00000000..99d86591 --- /dev/null +++ b/开发文档/8、部署/佣金计算逻辑检查.md @@ -0,0 +1,307 @@ +# 佣金计算逻辑检查 + +## 🔍 用户反馈 + +**问题**: "推广者应该获取支付金额的90%,但却是10%" + +--- + +## 📊 配置值流转 + +### 1. 管理后台保存(/admin/referral-settings) + +**输入**: +``` +分销比例:90 (表示90%) +``` + +**保存代码**: +```typescript +const safeConfig = { + distributorShare: Number(config.distributorShare) || 0 +} +// 保存到数据库:distributorShare = 90 +``` + +**数据库存储**: +```json +{ + "distributorShare": 90 +} +``` + +--- + +### 2. 后端读取配置(/api/miniprogram/pay/notify) + +**读取代码**: +```typescript +const config = await getConfig('referral_config') +const distributorShare = config.distributorShare / 100 +// 结果:90 / 100 = 0.9 +``` + +**佣金计算**: +```typescript +const commission = Math.round(amount * distributorShare * 100) / 100 +// 例如:1元 * 0.9 = 0.9元 +``` + +--- + +### 3. 返回给小程序(/api/referral/data) + +**返回代码**: +```typescript +shareRate: Math.round(distributorShare * 100) +// 结果:0.9 * 100 = 90 +``` + +**小程序显示**: +```xml +你获得 {{shareRate}}% 收益 + +``` + +--- + +## ⚠️ 可能的问题点 + +### 问题1: 配置值保存错误 + +**检查点**: +- 管理后台输入的是 90 还是 0.9? +- 数据库实际保存的值是多少? + +**验证SQL**: +```sql +SELECT config_value FROM system_config WHERE config_key = 'referral_config'; +``` + +**预期结果**: +```json +{ + "distributorShare": 90 +} +``` + +**如果看到**: +```json +{ + "distributorShare": 0.1 // ❌ 错误!应该是 90 +} +``` + +--- + +### 问题2: 计算公式错误 + +**检查点**: 是否有地方用错了公式? + +**错误示例**: +```typescript +// ❌ 错误:用了减法 +const commission = amount * (1 - distributorShare) +// 1 * (1 - 0.9) = 0.1 元(10%) + +// ✅ 正确:直接乘 +const commission = amount * distributorShare +// 1 * 0.9 = 0.9 元(90%) +``` + +--- + +### 问题3: 除以100的位置错误 + +**错误示例**: +```typescript +// ❌ 错误:没有除以100 +const distributorShare = config.distributorShare +const commission = amount * distributorShare / 100 +// 1 * 90 / 100 = 0.9 元(看起来对,但下一步就错了) +``` + +**正确方式**: +```typescript +// ✅ 正确:先除以100 +const distributorShare = config.distributorShare / 100 // 90 → 0.9 +const commission = amount * distributorShare // 1 * 0.9 = 0.9 +``` + +--- + +## 🧪 测试用例 + +### 测试1: 购买1元(无折扣) + +**输入**: +- 支付金额: 1.00元 +- distributorShare: 90 + +**计算过程**: +```typescript +const distributorShare = 90 / 100 = 0.9 +const commission = 1.00 * 0.9 = 0.90元 +``` + +**预期结果**: 推荐人获得 0.90元 + +--- + +### 测试2: 购买1元(5%折扣) + +**输入**: +- 原价: 1.00元 +- 好友优惠: 5% +- 实付: 0.95元 +- distributorShare: 90 + +**计算过程**: +```typescript +const finalAmount = 1.00 * (1 - 0.05) = 0.95元 +const commission = 0.95 * 0.9 = 0.855 ≈ 0.86元 +``` + +**预期结果**: 推荐人获得 0.86元 + +--- + +### 测试3: 如果配置错误保存为0.9 + +**输入**: +- 支付金额: 1.00元 +- distributorShare: 0.9 (❌ 错误的保存值) + +**计算过程**: +```typescript +const distributorShare = 0.9 / 100 = 0.009 +const commission = 1.00 * 0.009 = 0.009 ≈ 0.01元 +``` + +**错误结果**: 推荐人只获得 0.01元(1%)❌ + +--- + +## 🔍 排查步骤 + +### 步骤1: 检查数据库配置值 + +**SQL查询**: +```sql +SELECT config_key, config_value +FROM system_config +WHERE config_key = 'referral_config'; +``` + +**检查要点**: +- `distributorShare` 应该是 **90**(不是 0.9) +- 如果是其他值(如 10),说明保存时出错了 + +--- + +### 步骤2: 检查实际佣金记录 + +**SQL查询**: +```sql +SELECT + rb.referrer_id, + rb.referee_id, + rb.purchase_count, + rb.total_commission, + o.amount, + o.order_sn +FROM referral_bindings rb +JOIN orders o ON o.user_id = rb.referee_id AND o.status = 'paid' +WHERE rb.purchase_count > 0 +ORDER BY rb.last_purchase_date DESC +LIMIT 5; +``` + +**检查要点**: +- 订单金额 1.00元 → 佣金应该约 0.90元 +- 如果佣金是 0.10元,说明计算错误 + +--- + +### 步骤3: 检查控制台日志 + +**查看PM2日志**: +```bash +pm2 logs soul --lines 100 | grep "处理分佣" +``` + +**预期输出**: +``` +[PayNotify] 处理分佣: { + amount: 0.95, + commission: 0.855, + shareRate: '90%' +} +``` + +**如果看到**: +``` +shareRate: '10%' // ❌ 错误! +``` + +--- + +## 🔧 可能的修复方案 + +### 修复1: 如果配置值错误 + +**检查数据库**: +```sql +SELECT config_value FROM system_config WHERE config_key = 'referral_config'; +``` + +**如果显示**: +```json +{"distributorShare": 10} // ❌ 错误 +``` + +**手动修复**: +```sql +UPDATE system_config +SET config_value = '{"distributorShare":90,"minWithdrawAmount":10,"bindingDays":30,"userDiscount":5,"enableAutoWithdraw":false}' +WHERE config_key = 'referral_config'; +``` + +**或者在管理后台重新保存** 90%。 + +--- + +### 修复2: 如果计算公式错误 + +**检查位置**: `app/api/miniprogram/pay/notify/route.ts` 第395行 + +**当前代码**: +```typescript +const commission = Math.round(amount * distributorShare * 100) / 100 +``` + +**验证**: +- 如果 distributorShare = 0.9,commission = 0.9元 ✅ +- 如果 distributorShare = 0.009,commission = 0.009元 ❌ + +--- + +## 📝 诊断建议 + +请提供以下信息以便诊断: + +1. **管理后台显示的值**: + - 进入 `/admin/referral-settings` + - 查看"分销比例"输入框中的值是多少? + +2. **实际佣金金额**: + - 用户A购买1元商品 + - 推荐人B实际获得多少佣金? + +3. **小程序显示的比例**: + - 分销中心显示的是"你获得 xx% 收益" + - 这个 xx 是多少? + +--- + +**根据你的反馈,我会立即定位并修复问题!** diff --git a/开发文档/8、部署/佣金问题-快速诊断和修复.md b/开发文档/8、部署/佣金问题-快速诊断和修复.md new file mode 100644 index 00000000..c4132559 --- /dev/null +++ b/开发文档/8、部署/佣金问题-快速诊断和修复.md @@ -0,0 +1,232 @@ +# 佣金计算问题 - 快速诊断和修复 + +## 🚨 问题描述 + +用户反馈:"推广者应该获取支付金额的90%,但却是10%" + +--- + +## 🔍 快速诊断 + +### 方法1: 检查管理后台配置 + +1. 登录管理后台:`https://soul.quwanzhi.com/admin` +2. 进入「推广设置」页面:`/admin/referral-settings` +3. 查看「分销比例」输入框中的数值 + +**如果显示 10** → 配置错误,应该改为 **90** + +**如果显示 90** → 配置正确,问题在其他地方 + +--- + +### 方法2: 检查实际佣金 + +1. 找一个推荐关系的订单 +2. 查看推荐人获得的佣金 + +**示例**: +- 用户B购买1元商品(无折扣) +- 推荐人A应得:0.90元(90%) +- 如果实际只得:0.10元 → 说明比例算反了 + +--- + +### 方法3: 检查小程序显示 + +打开小程序「分销中心」,查看推广规则: + +**应该显示**: +``` +好友成功付款后,你获得 90% 收益 +``` + +**如果显示**: +``` +好友成功付款后,你获得 10% 收益 +``` + +→ 说明后端返回的 `shareRate` 值错误 + +--- + +## 🔧 修复方案 + +### 修复1: 如果管理后台配置值错误 + +**步骤**: +1. 进入管理后台 `/admin/referral-settings` +2. 将「分销比例」改为 **90** +3. 点击「保存配置」 +4. 刷新小程序验证 + +--- + +### 修复2: 如果数据库配置值错误 + +**手动修复SQL**: +```sql +-- 1. 查看当前配置 +SELECT config_value FROM system_config WHERE config_key = 'referral_config'; + +-- 2. 如果 distributorShare 不是 90,手动更新 +UPDATE system_config +SET config_value = JSON_SET( + config_value, + '$.distributorShare', + 90 +) +WHERE config_key = 'referral_config'; + +-- 3. 验证修改 +SELECT config_value FROM system_config WHERE config_key = 'referral_config'; +``` + +--- + +### 修复3: 如果计算公式错误 + +**检查文件**: `app/api/miniprogram/pay/notify/route.ts` + +**第395行,当前代码应该是**: +```typescript +const commission = Math.round(amount * distributorShare * 100) / 100 +``` + +**如果错误写成了**: +```typescript +// ❌ 错误1:算反了 +const commission = Math.round(amount * (1 - distributorShare) * 100) / 100 + +// ❌ 错误2:没有先除100 +const distributorShare = config.distributorShare // 90(没除100) +const commission = amount * distributorShare / 100 // 1 * 90 / 100 = 0.9(看似对,但后续会错) +``` + +--- + +## 🧪 验证步骤 + +### 验证1: 手动计算 + +假设配置 `distributorShare = 90`: + +```javascript +// 读取配置 +const configValue = 90 + +// 转换为小数 +const distributorShare = configValue / 100 // = 0.9 + +// 计算佣金(购买1元) +const commission = 1.00 * 0.9 // = 0.90元 + +// 返回给小程序 +const shareRate = distributorShare * 100 // = 90 +``` + +**预期**: +- 购买1元 → 推荐人得 0.90元 +- 小程序显示:90% 返利 + +--- + +### 验证2: 查看实际订单 + +**SQL查询**: +```sql +SELECT + o.order_sn, + o.amount as 订单金额, + rb.total_commission as 累计佣金, + rb.purchase_count as 购买次数, + o.amount * 0.9 as 预期佣金90percent, + o.amount * 0.1 as 如果是10percent +FROM orders o +JOIN referral_bindings rb ON o.user_id = rb.referee_id +WHERE o.status = 'paid' + AND rb.purchase_count > 0 +ORDER BY o.pay_time DESC +LIMIT 5; +``` + +**对比**: +- 如果 `total_commission ≈ 预期佣金90percent` → 计算正确 +- 如果 `total_commission ≈ 如果是10percent` → 计算错误(算反了) + +--- + +## 🔍 代码审查 + +### 关键代码1: 读取配置 + +**文件**: `app/api/miniprogram/pay/notify/route.ts` 第357-360行 + +```typescript +const config = await getConfig('referral_config') +if (config?.distributorShare) { + distributorShare = config.distributorShare / 100 // ✅ 应该是这样 +} +``` + +**如果错误写成**: +```typescript +distributorShare = config.distributorShare // ❌ 没除100 +``` + +--- + +### 关键代码2: 计算佣金 + +**文件**: `app/api/miniprogram/pay/notify/route.ts` 第395行 + +```typescript +const commission = Math.round(amount * distributorShare * 100) / 100 +// ✅ 正确:1 * 0.9 = 0.9 +``` + +**如果错误写成**: +```typescript +const commission = Math.round(amount * (1 - distributorShare) * 100) / 100 +// ❌ 错误:1 * (1 - 0.9) = 0.1(算反了) +``` + +--- + +### 关键代码3: 返回比例 + +**文件**: `app/api/referral/data/route.ts` 第198行 + +```typescript +shareRate: Math.round(distributorShare * 100) +// ✅ 正确:0.9 * 100 = 90 +``` + +--- + +## 🚀 立即检查 + +请你帮我确认一下: + +### 问题1: 管理后台的配置值 +进入 `https://soul.quwanzhi.com/admin/referral-settings`,看看「分销比例」输入框中显示的是: +- [ ] 90(正确) +- [ ] 10(错误) +- [ ] 0.9(错误) + +### 问题2: 小程序显示的比例 +打开小程序「分销中心」,查看推广规则显示的是: +- [ ] "你获得 90% 收益"(正确) +- [ ] "你获得 10% 收益"(错误) + +### 问题3: 实际佣金金额 +如果有测试订单,查看: +- 购买金额:1.00元 +- 推荐人获得:_____ 元 + +**如果是 0.90元** → 计算正确 +**如果是 0.10元** → 计算错误 + +--- + +**请告诉我上述三个问题的实际情况,我会立即定位并修复!** diff --git a/开发文档/8、部署/其它.md b/开发文档/8、部署/其它.md new file mode 100644 index 00000000..ef1f24e7 --- /dev/null +++ b/开发文档/8、部署/其它.md @@ -0,0 +1,3 @@ +# 其它(合并自 宝塔配置检查、小程序上传复盘) + +宝塔配置检查说明、小程序上传复盘(版本 1.17、CLI 上传等)。详见原各文档。 diff --git a/开发文档/8、部署/分销与绑定流程图.md b/开发文档/8、部署/分销与绑定流程图.md new file mode 100644 index 00000000..8fd78cee --- /dev/null +++ b/开发文档/8、部署/分销与绑定流程图.md @@ -0,0 +1,383 @@ +# 分销与绑定流程图 + +> 用流程图把「绑定」和「推荐人/邀请码」在系统中的用法讲清楚。 +> 建议配合《邀请码分销规则说明》一起看。 + +--- + +## 一、概念速查 + +| 名词 | 是什么 | 存哪儿 | 谁用 | +|------|--------|--------|------| +| **邀请码** | 一串码,如 `SOULABC123` | 每个用户一条:`users.referral_code` | 链接里 `ref=邀请码`,用来**认出**是谁推荐的 | +| **推荐人** | 拿佣金的那个人(用户) | 用**用户ID**存:`referrer_id` | 绑定表、订单表、分佣都只认这个 ID | +| **被推荐人** | 通过链接进来的访客/买家 | 用**用户ID**存:`referee_id` | 绑定表里「谁被谁推荐」 | + +关系:**邀请码** → 查 `users` 表 → 得到**推荐人用户ID**(referrer_id)。系统里所有「归属、分佣」只认 referrer_id,不直接认邀请码字符串。 + +--- + +## 二、整体流程总览(一图看懂) + +``` +┌─────────────────────────────────────────────────────────────────────────────────┐ +│ 分销全流程:从分享到分佣 │ +└─────────────────────────────────────────────────────────────────────────────────┘ + + 推广者 A(推荐人) 访客/买家 B(被推荐人) 系统 + + │ │ │ + │ 1. 分享带 ref 的链接 │ │ + │ ?ref=A的邀请码 │ │ + ├─────────────────────────────────────>│ 2. 点击链接进入小程序/阅读页 │ + │ ├─────────────────────────────────>│ + │ │ app.js: 存 referral_code │ + │ │ 可选: 记录访问 referral_visit │ + │ │ │ + │ │ 3. 登录(微信/手机号/getOpenId 拿到 user) │ + │ ├─────────────────────────────────>│ + │ │ 登录成功即调 /api/referral/bind │ + │ │ 入参: userId, referralCode │ + │ │ │ + │ │ 4. 绑定逻辑 │ + │ │ referral_code │ + │ │ → 查 users 得 │ + │ │ referrer_id=A │ + │ │ 写 referral_ │ + │ │ bindings │ + │ │ (referee=B, │ + │ │ referrer=A) │ + │ │<─────────────────────────────────┤ + │ │ 绑定成功(new/renew/takeover) │ + │ │ │ + │ │ 5. 下单(章节/找伙伴) │ + │ │ POST /api/miniprogram/pay │ + │ │ body: referralCode(可选) │ + │ ├─────────────────────────────────>│ + │ │ 6. 定推荐人 │ + │ │ 先查 bindings │ + │ │ (referee=B)→A │ + │ │ 无则用 referral│ + │ │ Code 解析→A │ + │ │ 写 orders. │ + │ │ referrer_id=A,│ + │ │ referral_code │ + │ │<─────────────────────────────────┤ + │ │ 返回支付参数 │ + │ │ │ + │ │ 7. 调起微信支付 │ + │ ├───────────────────────────────> 微信 + │ │ 8. 用户付款成功 │ + │ │<─────────────────────────────── 微信 + │ │ │ + │ │ 9. 支付回调 │ + │ │ POST .../notify│ + │ │ 查 bindings │ + │ │ (referee=B)→A │ + │ │ 佣金=金额×90% │ + │ │ A.pending_ │ + │ │ earnings += 佣金│ + │ │ binding→ │ + │ │ converted │ + │ │ │ + │ 10. 推广者 A 看到待结算收益 +90% │ │ + │<─────────────────────────────────────│ │ +``` + +--- + +## 三、绑定流程(邀请码 → 推荐关系) + +绑定解决的是:**「谁(B)是通过谁(A)的链接来的」**,并写入 `referral_bindings`。 + +**绑定规则(后端统一保证):** +- **不重复绑定**:被推荐人 B 已有**当前推荐人 A** 的有效绑定时,再次用 A 的邀请码调用 bind → **不新建记录**,只做**续期**(把过期时间再延长 30 天)。 +- **有时效**:每条绑定的有效期为 **30 天**(`expiry_date`);分佣、下单定推荐人时只认「未过期」的绑定。 +- **超时可重新绑定**:超过 30 天未续期的绑定视为过期;此时 B 再通过**其他人 C** 的链接进来并登录 → 允许绑定到 C(旧绑定标记过期,新绑定 C,即「抢夺」);若仍通过 A 的链接 → 续期 A 的绑定。 + +**绑定从登录就开始**:只要前端拿到 userId(登录成功),就立刻用当前的 `pendingReferralCode` 调 `/api/referral/bind`,不等到下单。后端根据上述规则决定是**新绑定 / 续期 / 抢夺 / 拒绝**。 + +```mermaid +flowchart TB + subgraph 入口 + A1["推广者 A 分享链接
      带 ref=A的邀请码"] + A2["访客 B 点击链接进入"] + end + + subgraph 前端 + B1["app.js: 检测到 ref"] + B2["写入 storage: referral_code + pendingReferralCode"] + B3["若已登录 → 立即调 bind"] + B4["若未登录 → 等任意登录成功后再调 bind"] + B5["登录含: login / loginWithPhone / getOpenId 拿到 user 时"] + end + + subgraph 后端绑定API["POST /api/referral/bind"] + C1["入参: userId(B), referralCode"] + C2["用 referralCode 查 users 表 → 推荐人 A"] + C3["不能自己推荐自己"] + C4["查 B 是否已有有效绑定(active)"] + C5{"已有绑定?"} + C6["同一推荐人 A → 只续期,不重复绑定
      expiry = 当前+30天"] + C7["不同人且已过期(>30天) → 可重新绑定
      旧绑定过期,新绑定 A"] + C8["不同人且未过期 → 拒绝"] + C9["无绑定 / 续期 / 抢夺后 → 写 binding
      referrer_id=A, referee_id=B, expiry=+30天"] + end + + A1 --> A2 --> B1 --> B2 + B2 --> B3 + B2 --> B4 + B4 --> B5 + B3 --> C1 + B5 --> C1 + C1 --> C2 --> C3 --> C4 --> C5 + C5 -->|无| C9 + C5 -->|有,同一人| C6 --> C9 + C5 -->|有,另一人已过期| C7 --> C9 + C5 -->|有,另一人未过期| C8 +``` + +要点: +- **绑定表**是「谁推荐了谁」的**唯一权威**;分佣只看这张表。 +- **已有绑定不重复**:同一推荐人再次绑只续期;**30 天**内不能换绑其他推荐人,超过 30 天可重新绑定(被新推荐人「抢夺」或原推荐人续期)。 +- **邀请码**只在「解析出推荐人是谁」时用,解析完得到的是 **referrer_id**(用户ID)。 + +--- + +## 四、下单时「推荐人」怎么定(写订单) + +创建订单时要把「这笔单算谁的推广」记在 `orders.referrer_id` 和 `orders.referral_code`。逻辑是:**先认绑定,再认邀请码**。 + +```mermaid +flowchart LR + subgraph 请求 + R1["POST /api/miniprogram/pay"] + R2["body: userId(B), referralCode(可选)"] + end + + subgraph 定推荐人 + S1["查 referral_bindings"] + S2["WHERE referee_id = B
      AND status='active'
      AND expiry_date > NOW()"] + S3{"查到有效绑定?"} + S4["referrer_id = 绑定里的 referrer_id"] + S5["referrer_id = 用 referralCode
      查 users 得到的 id"] + S6["都无 → referrer_id = null"] + end + + subgraph 写订单 + T1["INSERT orders"] + T2["referrer_id = 上面得到的"] + T3["referral_code = 请求里的 referralCode
      或推荐人当前 users.referral_code"] + end + + R1 --> R2 --> S1 --> S2 --> S3 + S3 -->|是| S4 + S3 -->|否,但有 referralCode| S5 + S3 -->|否且无| S6 + S4 --> T1 + S5 --> T1 + S6 --> T1 + T1 --> T2 --> T3 +``` + +结论: +- **有绑定** → 订单的推荐人 = 绑定里的推荐人(与下单时传不传 referralCode 无关)。 +- **无绑定但传了 referralCode** → 用邀请码解析出推荐人,写入订单。 +- 订单上的 **referrer_id** 用于后台展示、对账;**分佣不看订单**,只看绑定表。 + +--- + +## 五、分佣流程(支付成功后) + +分佣**只看绑定表**,不看订单上的 referrer_id。 + +```mermaid +flowchart TB + subgraph 触发 + P1["微信支付成功"] + P2["POST /api/miniprogram/pay/notify"] + P3["body: 订单号、金额、买家等"] + end + + subgraph 回调逻辑 + Q1["更新订单 status=paid"] + Q2["解锁用户权限(章节/全书)"] + Q3["查 referral_bindings"] + Q4["WHERE referee_id = 买家"] + Q5["AND status='active'"] + Q6["AND expiry_date > NOW()"] + Q7{"查到有效绑定?"} + Q8["取 referrer_id = 推广者 A"] + Q9["佣金 = 订单金额 × 90%"] + Q10["A.pending_earnings += 佣金"] + Q11["该绑定 status → converted"] + Q12["记录 commission_amount, order_id"] + Q13["不分佣"] + end + + P1 --> P2 --> P3 --> Q1 --> Q2 --> Q3 --> Q4 --> Q5 --> Q6 --> Q7 + Q7 -->|是| Q8 --> Q9 --> Q10 --> Q11 --> Q12 + Q7 -->|否| Q13 +``` + +要点: +- 分佣**只认** `referral_bindings` 里「买家 → 有效绑定 → 推荐人」。 +- 订单里的 referrer_id / referral_code **不参与**分佣计算,只用于统计和展示。 + +--- + +### 什么情况下能拿到佣金(推广者视角) + +满足下面**全部**条件时,你(推广者)才能拿到这笔订单的佣金: + +1. **对方是通过你的链接进来的** + 对方点击的链接里带有你的邀请码(如 `?ref=你的邀请码`),进入小程序后系统会记下推荐码,并在登录时用于绑定。 + +2. **对方已经绑定到你** + 对方完成登录后,系统成功调用了绑定接口(新绑定或续期),且当前存在一条「被推荐人 = 对方、推荐人 = 你」的绑定记录,且该绑定 **status = active**、**expiry_date > 当前时间**(在 30 天有效期内或已续期)。 + +3. **对方在绑定有效期内下单并支付成功** + 对方在上述有效期内发起了购买(章节或全书),并完成微信支付;支付成功后,微信会回调我们的接口。 + +4. **支付回调时仍能查到你的有效绑定** + 支付成功回调执行时,系统按「买家 = 对方」查 `referral_bindings`,能查到一条有效绑定且推荐人是你,才会把约 90% 的佣金计入你的待结算收益(pending_earnings),并把该绑定标记为已转化(converted)。 + +**简单记**:你的链接 → 对方进来并登录绑定到你 → 有效期内对方付款 → 你拿佣金。 + +--- + +### 章节分享这块的分销收益方式 + +章节页分享(读某一章时分享给好友/朋友圈)与首页、推广中心的分享**用同一套绑定与分佣规则**,只是落地页是「某一章」的阅读页。收益方式如下: + +1. **入口与绑定** + 你从阅读页分享出去的链接带 `ref=你的邀请码`(例如 `/pages/read/read?id=1.2&ref=你的邀请码`)。对方点进后进入**该章节**阅读页,系统记下推荐码;对方**登录**后即完成绑定(新绑定或续期)。绑定规则(30 天、不重复绑、超时可重绑)与其它分享入口一致。 + +2. **收益比例** + 订单实付金额的**约 90%** 给推广者(与全书、其它章节一致,由 `referral_config.distributorShare` 配置)。对方买的是**这一章、别的章还是全书**,都按该笔订单金额 × 90% 计算佣金。 + +3. **计佣次数(每个被推荐人只计一次)** + 系统在支付成功回调里会查「该买家」的**有效绑定**,有则给推荐人加佣金,并把这条绑定标记为**已转化(converted)**。 + 因此:**同一个被推荐人在绑定有效期内,只有其「第一笔」支付会给你分佣**;该用户之后再买其它章节或全书,**不再**重复给你分佣(绑定已用掉)。 + +4. **小结** + **章节分享的收益**:你分享章节链接(带 ref)→ 对方进来并登录绑定到你 → 对方在有效期内**第一次**支付(可以是这一章、别的章或全书)→ 你获得**该笔订单金额的约 90%**;该用户后续订单不再给你分佣。 + +--- + +## 六、推荐人 vs 邀请码(怎么用、不混用) + +```mermaid +flowchart LR + subgraph 入口 + L1["链接 ref=SOULABC123"] + end + + subgraph 解析 + L2["邀请码 = SOULABC123"] + L3["users WHERE referral_code = ?"] + L4["推荐人 = 该用户的 id"] + end + + subgraph 存储 + M1["referral_bindings.referrer_id"] + M2["orders.referrer_id"] + M3["分佣发给谁"] + end + + L1 --> L2 --> L3 --> L4 + L4 --> M1 + L4 --> M2 + L4 --> M3 + + style L2 fill:#f9f,stroke:#333 + style L4 fill:#9f9,stroke:#333 +``` + +- **邀请码**:只在「从链接/请求里认出是谁」这一步用,用完就解析成 **referrer_id**。 +- **推荐人**:所有「归属、分佣、统计」都只用 **referrer_id**,不会把邀请码字符串当推荐人存。 + +--- + +## 七、表与字段关系简图 + +```mermaid +erDiagram + users ||--o{ referral_bindings : "referrer_id" + users ||--o{ referral_bindings : "referee_id" + users { + string id PK + string referral_code "自己的邀请码" + } + referral_bindings { + string referrer_id "推荐人(谁拿佣金)" + string referee_id "被推荐人(买家)" + string status "active|converted|expired" + timestamp expiry_date + } + orders { + string user_id "买家" + string referrer_id "推荐人ID(展示/对账)" + string referral_code "下单时邀请码(展示)" + } + referral_bindings ||--o{ orders : "分佣时关联" +``` + +- **绑定**:`referrer_id` = 推荐人,`referee_id` = 被推荐人;分佣只看这张表。 +- **订单**:`referrer_id`、`referral_code` 只做展示和对账,不参与分佣计算。 + +--- + +## 八、逻辑漏洞与注意点 + +以下为与流程图、实现对照后容易出现的漏洞和设计注意点,便于排查与加固。 + +### 8.1 严重:支付回调中买家身份不能信任客户端 + +**问题**:支付回调(`/api/miniprogram/pay/notify`)里若**优先**使用请求体/attach 里的 `userId` 作为买家,则该 `userId` 来自**创建订单时客户端传入**的 `body.userId`。若被篡改(如传成他人 userId),会导致: +- 订单归属、解锁权限记到错误用户; +- 分佣按「错误买家」查绑定表,可能把佣金算到错误推荐人或不分佣。 + +**正确做法**:**买家身份必须以微信回调中的 `openId` 为准**(微信侧不可伪造),用 `openId` 查 `users` 得到 `buyerUserId`;attach 中的 `userId` 仅作辅助或校验,不一致时以 openId 解析结果为准。 + +**实现建议**:在 notify 中先 `buyerUserId = 由 openId 查 users 得到`;若查不到再回退到 attach.userId,并打日志告警。 + +--- + +### 8.2 设计缺口:先下单、后绑定会导致无分佣 + +**问题**:流程图要求「先绑定、再下单」分佣才生效。若用户通过 A 的链接进入但**未调用** `/api/referral/bind`(未登录就下单、或 bind 失败/漏调),下单时传了 `referralCode`,订单上会有 `referrer_id=A`,但**分佣只看绑定表**,此时无绑定 → 不会给 A 分佣。 + +**结论**:这是当前设计下的预期行为,不是 bug,但需要在产品/运营上保证「进入后尽快登录并完成绑定」,或在文档中明确写清:**只有存在有效绑定时支付成功才会分佣**。 + +--- + +### 8.3 重复回调与重复分佣 + +**现状**:微信可能对同一笔支付多次回调。当前实现: +- 订单状态已为 `paid` 时跳过订单更新; +- 分佣时只取 `status='active'` 的绑定,且分佣后将该绑定置为 `converted`,同一买家不会再有第二条 active 绑定参与分佣。 + +因此**不会重复加佣**。无需改流程图,实现已防护。 + +--- + +### 8.4 绑定表与 users.referred_by 双写 + +**现状**:绑定 API 在「新绑定」或「抢夺」时会写 `users.referred_by`,与 `referral_bindings` 双写;「续期」只更新绑定表,不改 `referred_by`。 +分佣、下单定推荐人**只读绑定表**;GET 查询「我的推荐人」等可能读 `users.referred_by`。只要绑定接口保证 new/takeover 时双写一致,则无逻辑漏洞。若以后有接口只改 `referred_by` 而不改绑定表,就会不一致,需避免。 + +--- + +### 8.5 小结 + +| 类型 | 说明 | +|------------|------| +| 必须修 | 支付回调中买家身份以 openId 解析为准,不信任 attach.userId。 | +| 文档/产品 | 明确「先绑定再下单才能分佣」;未绑定仅下单只记订单归属、不分佣。 | +| 已防护 | 重复回调不会导致重复分佣。 | +| 需长期一致 | 绑定表与 users.referred_by 在 new/takeover 时双写,避免单改其一。 | + +--- + +若要把某一段改成「按步骤」的纯文字版或拆成多张图,可以说明要哪一段(绑定 / 下单 / 分佣 / 概念)。 diff --git a/开发文档/8、部署/分销提现流程图.md b/开发文档/8、部署/分销提现流程图.md new file mode 100644 index 00000000..45835765 --- /dev/null +++ b/开发文档/8、部署/分销提现流程图.md @@ -0,0 +1,127 @@ +# 分销提现流程图 + +## 一、整体流程 + +``` +┌─────────────────────────────────────────────────────────────────────────────────┐ +│ 小 程 序 端 │ +└─────────────────────────────────────────────────────────────────────────────────┘ + + [用户] 推广中心 → 可提现金额 ≥ 最低额 → 点击「申请提现」 + │ + ▼ + POST /api/miniprogram/withdraw (WithdrawPost) + │ 校验:可提现余额、最低金额、用户 openId + ▼ + 写入 withdrawals:status = pending + │ + ▼ + 提示「提现申请已提交,审核通过后将打款至您的微信零钱」 + +───────────────────────────────────────────────────────────────────────────────── + +┌─────────────────────────────────────────────────────────────────────────────────┐ +│ 管 理 端 (soul-admin) │ +└─────────────────────────────────────────────────────────────────────────────────┘ + + [管理员] 分销 / 提现审核 → GET /api/admin/withdrawals 拉列表 + │ + ├── 点「拒绝」 → PUT /api/admin/withdrawals { action: "reject" } + │ ▼ + │ status = failed,写 error_message + │ + └── 点「通过」 → PUT /api/admin/withdrawals { action: "approve" } + │ + ▼ + 调 wechat.InitiateTransferByFundApp (FundApp 单笔) + │ + ┌───────────────┼───────────────┐ + ▼ ▼ ▼ + [微信报错] [未返回单号] [成功受理] + │ │ │ + ▼ ▼ ▼ + status=failed status=failed status=processing + 返回报错信息 返回提示 写 detail_no,batch_no,batch_id + 返回「已发起打款,微信处理中」 + +───────────────────────────────────────────────────────────────────────────────── + +┌─────────────────────────────────────────────────────────────────────────────────┐ +│ 微 信 侧 与 回 调 │ +└─────────────────────────────────────────────────────────────────────────────────┘ + + 微信异步打款 + │ + ▼ + 打款结果 → POST /api/payment/wechat/transfer/notify (PaymentWechatTransferNotify) + │ 验签、解密,得到 out_bill_no / transfer_bill_no / state / fail_reason + │ 用 detail_no = out_bill_no 找到提现记录,且仅当 status 为 processing / pending_confirm 时更新 + ▼ + state=SUCCESS → status = success + state=FAIL/CANCELLED → status = failed,写 fail_reason + +───────────────────────────────────────────────────────────────────────────────── + +┌─────────────────────────────────────────────────────────────────────────────────┐ +│ 可 选:主 动 同 步 │ +└─────────────────────────────────────────────────────────────────────────────────┘ + + 管理端 POST /api/admin/withdrawals/sync(可带 id 同步单条,或不带 id 同步所有) + │ 只处理 status IN (processing, pending_confirm) + │ FundApp 单笔:用 detail_no 调 QueryTransferByOutBill + ▼ + 按微信返回的 state 更新 status = success / failed(与回调逻辑一致) + +───────────────────────────────────────────────────────────────────────────────── + +┌─────────────────────────────────────────────────────────────────────────────────┐ +│ 小 程 序「我 的」- 待 确 认 收 款 │ +└─────────────────────────────────────────────────────────────────────────────────┘ + + [用户] 我的页 → 仅登录显示「待确认收款」区块 + │ + ▼ + GET /api/miniprogram/withdraw/pending-confirm?userId=xxx (WithdrawPendingConfirm) + │ 只返回 status IN (processing, pending_confirm) 的提现(审核通过后的) + ▼ + 展示列表:金额、日期、「确认收款」按钮 + │ + ▼ + 点击「确认收款」→ 需要 item.package + mchId + appId 调 wx.requestMerchantTransfer + │ 当前后端 list 里 package 为空,故会提示「请稍后刷新再试」 + └─ 若后续接入微信返回的 package,可在此完成「用户确认收款」闭环 +``` + +## 二、状态流转 + +| 阶段 | 状态 (status) | 含义 | +|--------------|----------------|------| +| 用户申请 | **pending** | 待审核,已占可提现额度 | +| 管理员通过 | **processing** | 已发起打款,微信处理中 | +| 微信回调成功 | **success** | 打款成功(已到账) | +| 微信回调失败/拒绝 | **failed** | 打款失败,写 fail_reason | +| 预留 | **pending_confirm** | 待用户确认收款(当前流程未改此状态,仅接口可返回) | + +## 三、可提现与待确认口径 + +- **可提现** = 累计佣金 − 已提现 − 待审核金额 + 待审核金额 = 所有 status 为 `pending`、`processing`、`pending_confirm` 的提现金额之和。 +- **待确认收款列表**:仅包含 **审核已通过** 的提现,即 status 为 `processing` 或 `pending_confirm`,不包含 `pending`。 + +## 四、主要接口与代码位置 + +| 环节 | 接口/行为 | 代码位置 | +|------------|-----------|----------| +| 用户申请 | POST `/api/miniprogram/withdraw` | soul-api `internal/handler/withdraw.go` WithdrawPost | +| 可提现计算 | referral/data、withdraw 校验 | `withdraw.go` computeAvailableWithdraw;`referral.go` 提现统计 | +| 管理端列表 | GET `/api/admin/withdrawals` | `internal/handler/admin_withdrawals.go` AdminWithdrawalsList | +| 管理端通过/拒绝 | PUT `/api/admin/withdrawals` | `admin_withdrawals.go` AdminWithdrawalsAction | +| 微信打款 | FundApp 单笔 | soul-api `internal/wechat/transfer.go` InitiateTransferByFundApp | +| 微信回调 | POST `/api/payment/wechat/transfer/notify` | `internal/handler/payment.go` PaymentWechatTransferNotify | +| 管理端同步 | POST `/api/admin/withdrawals/sync` | `admin_withdrawals.go` AdminWithdrawalsSync | +| 待确认列表 | GET `/api/miniprogram/withdraw/pending-confirm` | `withdraw.go` WithdrawPendingConfirm | + +## 五、说明 + +- 当前实现:审核通过后直接调微信 FundApp 单笔打款,最终由**微信回调**或**管理端同步**把状态更新为 success/failed。 +- 「待确认收款」列表只展示已审核通过的记录;点击「确认收款」需后端下发的 `package` 才能调起 `wx.requestMerchantTransfer`,目前该字段为空,前端会提示「请稍后刷新再试」。若后续接入微信返回的 package,可在此完成用户确认收款闭环。 diff --git a/开发文档/8、部署/商家转账.md b/开发文档/8、部署/商家转账.md new file mode 100644 index 00000000..b5b7d01f --- /dev/null +++ b/开发文档/8、部署/商家转账.md @@ -0,0 +1,40 @@ +# 商家转账 PowerWeChat 调用示例 + +> 来源:soul-api/商家转账.md。已整理至开发文档。完整实现见 [提现功能完整技术文档](提现功能完整技术文档.md)。 + +--- + +## 请求示例(PowerWeChat) + +```go +req := &request.RequestTransferBills{ + Appid: "Appid", + OutBillNo: "OutBillNo", + TransferSceneId: "TransferSceneId", + Openid: "Openid", + UserName: "UserName", + TransferAmount: 1, + TransferRemark: "TransferRemark", + NotifyUrl: "NotifyUrl", + UserRecvPerception: "UserRecvPerception", + TransferSceneReportInfos: []request.TransferSceneReportInfo{ + { + InfoType: "InfoType", + InfoContent: "InfoContent", + }, + }, +} +ctx := c.Request.Context() +rs, err := services.PaymentApp.FundApp.TransferBills(ctx, req) +if err != nil { + panic(err) +} +c.JSON(http.StatusOK, rs) +``` + +--- + +## 相关文档 + +- [提现功能完整技术文档](提现功能完整技术文档.md) — 微信支付商家转账到零钱 API 集成 +- [分销提现流程图](分销提现流程图.md) — 提现业务流程图 diff --git a/开发文档/8、部署/存客宝API-Key约定.md b/开发文档/8、部署/存客宝API-Key约定.md new file mode 100644 index 00000000..030d68a6 --- /dev/null +++ b/开发文档/8、部署/存客宝API-Key约定.md @@ -0,0 +1,28 @@ +# 存客宝 API Key 约定 + +## 约定说明 + +存客宝(ckbapi.quwanzhi.com)不同业务使用**不同的 apiKey**,对接时需按场景选用,避免混用。 + +| 场景 | 用途 | Key 来源 | 说明 | +|------|------|----------|------| +| **链接卡若** | 首页「链接卡若」留资,添加卡若为好友 | 环境变量 `CKB_LEAD_API_KEY` | 需在 .env 中配置;未配置时回退为下方「其他场景」的 key;请求方式为 **POST** + JSON(name, phone, wechatId, apiKey, timestamp, sign) | +| **其他** | join(团队/资源/导师/合伙)、match(找伙伴匹配)等 | 代码常量 `ckbAPIKey` | 当前为 `fyngh-ecy9h-qkdae-epwd5-rz6kd` | + +## 配置示例 + +- **链接卡若**(添加好友需用专用 key,示例): + ```env + CKB_LEAD_API_KEY=2y4v5-rjhfc-sg5wy-zklkv-bg0tl + ``` +- 后续若有其他「添加某某为好友」类场景,由存客宝提供对应 key,再在配置或代码中单独挂接,**不要与链接卡若的 key 混用**。 + +## 代码位置 + +- soul-api:`internal/handler/ckb.go` + - 链接卡若:`CKBLead` 中读取 `config.Get().CkbLeadAPIKey`,有则用,无则用 `ckbAPIKey` + - join/match:统一使用 `ckbAPIKey` + +--- + +记录时间:2025-03;原因:链接卡若需专用 key 才能正常添加好友,其他场景用另一 key。 diff --git a/开发文档/8、部署/宝塔反向代理说明.md b/开发文档/8、部署/宝塔反向代理说明.md new file mode 100644 index 00000000..099d80d2 --- /dev/null +++ b/开发文档/8、部署/宝塔反向代理说明.md @@ -0,0 +1,87 @@ +# soul-api 域名 404 原因与解决 + +> 来源:soul-api/宝塔反向代理说明.txt + +## 原因 + +域名请求先到 Nginx,若没有把请求转发到本机 8080 的 Go,或站点用了 root/静态目录,就会 404。 + +--- + +## 一、先确认 Go 是否在跑(必做) + +在宝塔终端或 SSH 里执行: + +``` +curl -s http://127.0.0.1:8080/health +``` + +- 若返回 `{"status":"ok"}`:说明 Go 正常,问题在 Nginx,看下面第二步。 +- 若连接被拒绝或超时:说明 8080 没在监听。去 宝塔 → Go项目管理 → soulApi → 服务状态,看是否「运行中」;看「项目日志」是否有报错。 + +--- + +## 二、Nginx 必须「整站走代理」,不能走 root + +添加了反向代理仍 404,多半是: + +- 站点默认有 `location / { root ...; index ...; }`,请求被当成静态文件处理,`/health` 找不到就 404; +- 或反向代理只绑在了子路径(如 `/api`),`/` 和 `/health` 没被代理。 + +**做法**:让 soulapi.quwanzhi.com 的**所有路径**都走 8080,不要用 root。 + +在宝塔:网站 → soulapi.quwanzhi.com → 设置 → 配置文件,找到该站点的 `server { ... }`,按下面两种方式之一改。 + +### 方式 A:只保留一个 location /(推荐) + +把 server 里**原来的** `location / { ... }`(含 root、index 的那段)**删掉或注释掉**,只保留下面这一段: + +```nginx +location / { + proxy_pass http://127.0.0.1:8080; + proxy_http_version 1.1; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; +} +``` + +保存 → 重载 Nginx(或 宝塔 里点「重载配置」)。 + +### 方式 B:整站用下面这一整段 server(HTTPS 示例) + +若你希望整站只做反向代理、不混静态,可以把该站点的 server 块整体替换成下面内容(把 your_ssl_cert 等换成你实际的证书路径;没有 SSL 就只用 listen 80 那段): + +```nginx +server { + listen 80; + listen 443 ssl http2; + server_name soulapi.quwanzhi.com; + # SSL 证书路径按宝塔实际填写,例如: + # ssl_certificate /www/server/panel/vhost/cert/soulapi.quwanzhi.com/fullchain.pem; + # ssl_certificate_key /www/server/panel/vhost/cert/soulapi.quwanzhi.com/privkey.pem; + + location / { + proxy_pass http://127.0.0.1:8080; + proxy_http_version 1.1; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } +} +``` + +保存并重载 Nginx。 + +--- + +## 三、改完后自测 + +- 本机:`curl -s https://soulapi.quwanzhi.com/health` +- 或浏览器打开:https://soulapi.quwanzhi.com/health + +应看到:`{"status":"ok"}` + +- 打开 https://soulapi.quwanzhi.com/ 应看到「部署成功」页面。 diff --git a/开发文档/8、部署/宝塔面板配置订单同步定时任务.md b/开发文档/8、部署/宝塔面板配置订单同步定时任务.md new file mode 100644 index 00000000..58f9a2af --- /dev/null +++ b/开发文档/8、部署/宝塔面板配置订单同步定时任务.md @@ -0,0 +1,369 @@ +# 宝塔面板配置订单同步定时任务 + +> 适用于:有宝塔面板的服务器 +> 难度:⭐(非常简单,3 分钟搞定) + +--- + +## 一、准备工作 + +### 1. 生成安全密钥 + +打开终端(本地电脑),执行: + +```bash +# Windows PowerShell +-join ((65..90) + (97..122) + (48..57) | Get-Random -Count 32 | % {[char]$_}) + +# 或手动生成一个 32 位随机字符串,例如: +# 密钥已写死在代码里,见下文 URL +``` + +**接口使用的固定密钥**:`soul_cron_sync_orders_2026`(无需自己生成) + +--- + +## 二、宝塔面板配置步骤 + +### 步骤 1:登录宝塔面板 + +1. 浏览器打开:`http://你的服务器IP:8888` +2. 输入账号密码登录 + +### 步骤 2:打开计划任务 + +1. 左侧菜单点击 **"计划任务"** +2. 点击右上角 **"添加任务"** + +### 步骤 3:配置任务(方案 A - 访问 URL,推荐) + +在弹出的对话框中填写: + +| 字段 | 填写内容 | 说明 | +|------|---------|------| +| **任务类型** | 选择 `访问URL` | 下拉框选择 | +| **任务名称** | `订单状态同步` | 随便填,方便识别 | +| **执行周期** | 选择 `N分钟` | 下拉框选择 | +| **分钟选择** | 填 `5` | 表示每 5 分钟执行一次 | +| **URL地址** | `https://soul.quwanzhi.com/api/cron/sync-orders?secret=soul_cron_sync_orders_2026` | 密钥已写死在代码里,无需修改 | + +**完整 URL 示例**(密钥已写死在代码里,直接用即可): +``` +https://soul.quwanzhi.com/api/cron/sync-orders?secret=soul_cron_sync_orders_2026 +``` + +### 步骤 4:点击保存 + +点击底部的 **"提交"** 或 **"确定"** 按钮。 + +### 步骤 5:验证任务已添加 + +在任务列表中应该能看到: +- ✅ 任务名称:订单状态同步 +- ✅ 类型:访问URL +- ✅ 周期:每 5 分钟 +- ✅ 状态:正常(绿色) + +--- + +## 三、立即测试执行 + +### 方法 1:宝塔面板手动执行 + +1. 在任务列表中找到刚添加的任务 +2. 点击右侧的 **"执行"** 按钮 +3. 查看执行结果: + - 成功:显示 JSON 响应 `{"success":true,...}` + - 失败:显示错误信息 + +### 方法 2:浏览器测试 + +直接在浏览器打开: +``` +https://soul.quwanzhi.com/api/cron/sync-orders?secret=YOUR_SECRET +``` + +**预期响应**(成功): +```json +{ + "success": true, + "message": "订单状态同步完成", + "total": 0, + "synced": 0, + "expired": 0, + "error": 0, + "duration": 123 +} +``` + +**如果响应 401 错误**: +```json +{ + "success": false, + "error": "未授权访问" +} +``` +说明密钥不对,检查 URL 中的 `secret` 参数。 + +--- + +## 四、查看执行日志 + +### 宝塔面板查看 + +1. 计划任务列表 +2. 找到"订单状态同步"任务 +3. 点击右侧的 **"日志"** 按钮 +4. 查看最近的执行记录 + +**正常日志示例**: +``` +[2026-02-04 21:00:00] 开始执行 +[2026-02-04 21:00:01] 状态码: 200 +[2026-02-04 21:00:01] 响应: {"success":true,"synced":0,"expired":0} +[2026-02-04 21:00:01] 执行完成 +``` + +--- + +## 五、配置环境变量(重要!) + +定时任务需要密钥验证,必须在项目中配置: + +### 方法 1:通过宝塔面板配置 + +1. 左侧菜单 → **网站** +2. 找到 `soul.quwanzhi.com` 网站 +3. 点击 **设置** +4. 左侧选择 **"伪静态"** 或 **"配置文件"**(取决于宝塔版本) +5. 找到 Node.js 项目的启动配置 + +### 方法 2:在项目根目录创建 `.env.production` + +SSH 登录服务器: +```bash +ssh root@你的服务器IP + +cd /www/wwwroot/soul + +# 编辑 .env.production +nano .env.production +``` + +添加以下内容: +```bash +# 定时任务密钥(与宝塔任务中的 secret 保持一致) +# CRON_SECRET 已写死在代码,无需配置 + +# 微信支付 API 密钥(从微信商户平台获取) +WECHAT_API_KEY=你的32位API密钥 +``` + +保存后重启项目: +```bash +pm2 restart soul +``` + +--- + +## 六、方案 B:Shell 脚本(备选) + +如果不想用 URL 方式,也可以用 Shell 脚本: + +### 步骤 1:添加任务 + +任务类型选择:`Shell 脚本` + +### 步骤 2:填写脚本 + +```bash +#!/bin/bash +curl -X GET "https://soul.quwanzhi.com/api/cron/sync-orders?secret=YOUR_SECRET" >> /www/wwwlogs/cron_sync_orders.log 2>&1 +``` + +### 步骤 3:设置执行周期 + +- 类型:N分钟 +- 周期:5 + +--- + +## 七、方案 C:Python 脚本(高级) + +如果你想用 Python 脚本直接执行: + +### 步骤 1:确保 Python 环境 + +```bash +# SSH 登录服务器 +ssh root@你的服务器IP + +# 安装依赖 +pip3 install pymysql requests +``` + +### 步骤 2:上传脚本 + +确保脚本已上传到服务器: +``` +/www/wwwroot/soul/scripts/sync_order_status.py +``` + +### 步骤 3:宝塔添加任务 + +- 任务类型:`Shell 脚本` +- 脚本内容: + ```bash + cd /www/wwwroot/soul && python3 scripts/sync_order_status.py >> /www/wwwlogs/sync_orders.log 2>&1 + ``` +- 执行周期:每 5 分钟 + +--- + +## 八、验证是否生效 + +### 1. 创建测试订单 + +```sql +-- 通过宝塔面板 → 数据库 → soul_miniprogram → SQL窗口 +INSERT INTO orders (id, order_sn, user_id, open_id, product_type, product_id, amount, status, created_at, updated_at) +VALUES ('TEST_SYNC', 'TEST_SYNC_001', 'test_user', 'test_openid', 'section', '1.2', 1.00, 'created', DATE_SUB(NOW(), INTERVAL 35 MINUTE), DATE_SUB(NOW(), INTERVAL 35 MINUTE)); +``` + +### 2. 等待定时任务执行(最多 5 分钟) + +或手动执行:宝塔面板 → 计划任务 → 点击"执行" + +### 3. 查询订单状态 + +```sql +SELECT order_sn, status, created_at, updated_at +FROM orders +WHERE order_sn = 'TEST_SYNC_001'; +``` + +**预期结果**: +- 状态应该变为 `expired`(因为超过 30 分钟) + +### 4. 清理测试数据 + +```sql +DELETE FROM orders WHERE order_sn = 'TEST_SYNC_001'; +``` + +--- + +## 九、常见问题排查 + +### Q1: 任务显示"执行失败" + +**可能原因**: +1. URL 地址错误 +2. 密钥不对(401 错误) +3. 服务器网络问题 + +**解决方案**: +1. 检查 URL 是否完整 +2. 检查 `secret` 参数是否与 `.env.production` 中一致 +3. 在浏览器中手动访问该 URL 测试 + +### Q2: 返回 401 未授权 + +**原因**:密钥不匹配 + +**解决方案**: +1. 密钥已写死,无需配置 `CRON_SECRET` +2. 确认宝塔任务 URL 中的 `secret` 参数 +3. 确保两者完全一致 +4. 重启项目:`pm2 restart soul` + +### Q3: 返回 500 错误 + +**可能原因**: +1. 数据库连接失败 +2. 代码有 bug + +**解决方案**: +1. 查看应用日志:`pm2 logs soul` +2. 检查数据库是否正常 +3. 检查环境变量是否配置 + +### Q4: 看不到执行日志 + +**解决方案**: +1. 宝塔面板 → 计划任务 → 点击任务右侧的"日志" +2. 或查看自定义日志文件: + ```bash + tail -f /www/wwwlogs/cron_sync_orders.log + ``` + +--- + +## 十、监控与优化 + +### 设置告警(可选) + +宝塔面板 → 监控 → 进程守护,添加监控项: +- 监控类型:URL 监控 +- URL:`https://soul.quwanzhi.com/api/cron/sync-orders?secret=YOUR_SECRET` +- 监控周期:5 分钟 +- 告警方式:邮件/企业微信 + +### 调整执行频率 + +根据实际情况调整: +- **订单少**:10 分钟 / 15 分钟 +- **订单多**:3 分钟 / 5 分钟 +- **高峰期**:1 分钟(不推荐,增加服务器负载) + +--- + +## 十一、配置清单(Checklist) + +完成以下步骤,确保定时任务正常运行: + +- [ ] 宝塔面板添加计划任务(访问 URL,密钥已写死:soul_cron_sync_orders_2026) +- [ ] 配置 `.env.production` 中的 `WECHAT_API_KEY`(可选,用于查询微信订单状态) +- [ ] 重启项目:`pm2 restart soul` +- [ ] 手动执行测试(宝塔面板点击"执行") +- [ ] 验证响应正常(`{"success":true}`) +- [ ] 查看日志确认任务执行 +- [ ] 创建测试订单验证(可选) +- [ ] 清理测试数据(可选) + +--- + +## 十二、最终配置示例 + +### 宝塔计划任务配置 + +``` +任务名称: 订单状态同步 +任务类型: 访问URL +执行周期: N分钟 -> 5 +URL地址: https://soul.quwanzhi.com/api/cron/sync-orders?secret=soul_cron_sync_orders_2026 +``` + +### 项目环境变量 `.env.production`(可选) + +密钥已写死,无需配置 `CRON_SECRET`。若需微信支付查询订单状态,可配置: + +```bash +# 微信支付 API 密钥(从商户平台获取,用于同步时查询订单真实状态) +WECHAT_API_KEY=YOUR_32_CHAR_API_KEY_HERE + +# 其他环境变量... +DATABASE_URL=mysql://... +``` + +--- + +## 完成! + +配置完成后,系统会: +- ✅ 每 5 分钟自动检查未支付订单 +- ✅ 查询微信支付状态并同步 +- ✅ 超时订单自动标记为 expired +- ✅ 支付成功订单自动解锁内容 + +再也不用担心支付回调丢失导致用户无法解锁内容了!🎉 diff --git a/开发文档/8、部署/提现功能完整技术文档.md b/开发文档/8、部署/提现功能完整技术文档.md new file mode 100644 index 00000000..457aa941 --- /dev/null +++ b/开发文档/8、部署/提现功能完整技术文档.md @@ -0,0 +1,1030 @@ +# 提现功能技术文档(微信支付API集成) + +> 来源:soul-api/提现功能完整技术文档.md。已整理至开发文档。 + +## 文档说明 + +本文档专注于**微信支付商家转账到零钱API**的集成方法,包括: +- 微信支付官方API文档 +- 签名生成算法 +- 加密解密算法 +- 完整代码实现 +- 测试验证方法 + +**适用场景**:实现用户提现功能,将资金从商户号转账到用户微信零钱。 + +--- + +## 目录 + +1. [业务场景](#业务场景) +2. [微信支付官方API文档](#微信支付官方api文档) +3. [前置准备](#前置准备) +4. [API集成](#api集成) +5. [签名算法](#签名算法) +6. [加密解密](#加密解密) +7. [代码实现](#代码实现) +8. [测试验证](#测试验证) + +--- + +## 业务场景 + +### 典型流程 + +``` +用户申请提现 + ↓ +系统审核通过 + ↓ +调用微信支付【商家转账到零钱API】 + ↓ +微信返回处理中(PROCESSING) + ↓ +微信异步处理(7-15秒) + ↓ +微信【主动回调】通知转账结果 + ↓ +系统接收回调,验签、解密 + ↓ +更新提现状态 + ↓ +用户确认收款 +``` + +### 关键步骤 + +1. **发起转账**:调用微信API发起转账 +2. **接收回调**:接收微信异步通知 +3. **验证签名**:验证回调的真实性 +4. **解密数据**:解密回调中的加密数据 +5. **查询状态**:主动查询转账状态 + +--- + +## 微信支付官方API文档 + +### 核心API + +| API名称 | 官方文档地址 | +|--------|------------| +| 🔥 **商家转账到零钱** | https://pay.weixin.qq.com/doc/v3/merchant/4012716434 | +| 📋 **查询转账单(商户单号)** | https://pay.weixin.qq.com/doc/v3/merchant/4012716456 | +| 📋 **查询转账单(微信单号)** | https://pay.weixin.qq.com/doc/v3/merchant/4012716457 | +| 🔐 **签名生成与验证** | https://pay.weixin.qq.com/doc/v3/merchant/4013053249 | +| 🔒 **敏感信息加密** | https://pay.weixin.qq.com/doc/v3/merchant/4012070130 | +| 🔓 **回调通知解密** | https://pay.weixin.qq.com/doc/v3/merchant/4012071382 | +| 📝 **转账场景报备** | https://pay.weixin.qq.com/doc/v3/merchant/4012716437 | +| ❌ **错误码查询** | https://pay.weixin.qq.com/doc/v3/merchant/4012070193 | +| 📜 **平台证书管理** | https://pay.weixin.qq.com/doc/v3/merchant/4012154180 | + +### 开发指引 + +- **API V3 开发总览**:https://pay.weixin.qq.com/doc/v3/merchant/4012065168 + + +--- + +## 前置准备 + +### 1. 获取配置信息 + +登录微信商户平台:https://pay.weixin.qq.com + +| 配置项 | 说明 | 获取路径 | +|-------|------|---------| +| **商户号(mch_id)** | 微信支付商户号 | 账户中心 → 商户信息 | +| **APIv3密钥(api_v3_key)** | 32字节密钥,用于加密解密 | 账户中心 → API安全 → 设置APIv3密钥 | +| **商户私钥(apiclient_key.pem)** | 用于请求签名 | 账户中心 → API安全 → 申请证书 | +| **证书序列号(cert_serial_no)** | 商户证书标识 | 从证书文件提取 | +| **平台证书(wechat_pay_pub_key)** | 用于验证回调签名 | 下载或通过API获取 | +| **小程序AppId** | 小程序标识 | 小程序管理后台 | + +### 2. 提取证书序列号 + +**使用OpenSSL命令**: + +```bash +openssl x509 -in apiclient_cert.pem -noout -serial +``` + +输出: +``` +serial=4A1DB62CD5C9BE0B6FC51C30621D6F99686E75C5 +``` + +**使用PHP**: + +```php + +``` + +### 3. 配置IP白名单 + +路径:微信商户平台 → 账户中心 → API安全 → IP配置 + +添加服务器公网IP地址。 + +**获取服务器IP**: + +```bash +curl ifconfig.me +``` + +### 4. 配置转账场景 + +路径:微信商户平台 → 产品中心 → 商家转账到零钱 → 前往功能 + +可选场景: +- **1000**:现金营销 +- **1005**:营销活动 + +**检查环境**: + + +--- + +## API集成 + +### 1. 商家转账到零钱API + +#### 基本信息 + +- **接口地址**:`https://api.mch.weixin.qq.com/v3/transfer/batches` +- **请求方法**:POST +- **Content-Type**:application/json + +#### 请求头 + +``` +Authorization: WECHATPAY2-SHA256-RSA2048 mchid="商户号",nonce_str="随机字符串",signature="签名",timestamp="时间戳",serial_no="证书序列号" +Content-Type: application/json +Accept: application/json +User-Agent: YourApp/1.0 +``` + +#### 请求参数 + +```json +{ + "appid": "wx6489c26045912fe1", + "out_batch_no": "BATCH202601291234567890", + "batch_name": "提现", + "batch_remark": "用户提现", + "total_amount": 5000, + "total_num": 1, + "transfer_detail_list": [ + { + "out_detail_no": "TX202601291234567890", + "transfer_amount": 5000, + "transfer_remark": "提现", + "openid": "odq3g5IOG-Z1WLpbeG_amUme8EZk" + } + ], + "transfer_scene_id": "1005", + "transfer_scene_report_infos": [ + { + "info_type": "岗位类型", + "info_content": "兼职人员" + }, + { + "info_type": "报酬说明", + "info_content": "当日兼职费" + } + ] +} +``` + +**参数说明**: + +| 字段 | 类型 | 必填 | 说明 | +|------|------|------|------| +| appid | string | 是 | 小程序AppId | +| out_batch_no | string | 是 | 商户批次单号,商户下唯一 | +| batch_name | string | 是 | 批次名称 | +| batch_remark | string | 是 | 批次备注 | +| total_amount | integer | 是 | 转账总金额,单位:**分** | +| total_num | integer | 是 | 转账总笔数 | +| transfer_detail_list | array | 是 | 转账明细列表 | +| transfer_scene_id | string | 是 | 转账场景ID:1000或1005 | +| transfer_scene_report_infos | array | 否 | 场景报备信息 | + +**transfer_detail_list说明**: + +| 字段 | 类型 | 必填 | 说明 | +|------|------|------|------| +| out_detail_no | string | 是 | 商户明细单号 | +| transfer_amount | integer | 是 | 转账金额,单位:**分** | +| transfer_remark | string | 是 | 转账备注 | +| openid | string | 是 | 收款用户OpenId | + +**场景报备信息(场景ID=1005)**: + +```json +[ + { + "info_type": "岗位类型", + "info_content": "兼职人员" + }, + { + "info_type": "报酬说明", + "info_content": "当日兼职费" + } +] +``` + +**重要**: +- `info_type` 必须是固定值 +- 金额单位是**分**:`元 * 100` + +#### 响应数据 + +**成功响应**: + +```json +{ + "out_batch_no": "BATCH202601291234567890", + "batch_id": "1030000071100999991182020050700019480001", + "create_time": "2026-01-29T12:30:00+08:00", + "batch_status": "PROCESSING" +} +``` + +**字段说明**: + +| 字段 | 说明 | +|------|------| +| out_batch_no | 商户批次单号 | +| batch_id | 微信批次单号 | +| create_time | 批次创建时间 | +| batch_status | 批次状态:PROCESSING/SUCCESS/FAIL | + +**失败响应**: + +```json +{ + "code": "PARAM_ERROR", + "message": "参数错误" +} +``` + +### 2. 查询转账单API + +#### 按商户单号查询 + +**接口地址**: + +``` +GET https://api.mch.weixin.qq.com/v3/transfer/batches/batch-id/{batch_id}/details/detail-id/{detail_id} +``` + +**路径参数**: +- `batch_id`:商户批次单号(需URL编码) +- `detail_id`:商户明细单号(需URL编码) + +**示例**: + +``` +GET /v3/transfer/batches/batch-id/BATCH202601291234567890/details/detail-id/TX202601291234567890 +``` + +**响应示例**: + +```json +{ + "mchid": "1318592501", + "out_batch_no": "BATCH202601291234567890", + "batch_id": "1030000071100999991182020050700019480001", + "out_detail_no": "TX202601291234567890", + "detail_id": "1040000071100999991182020050700019500100", + "detail_status": "SUCCESS", + "transfer_amount": 5000, + "transfer_remark": "提现", + "openid": "odq3g5IOG-Z1WLpbeG_amUme8EZk", + "initiate_time": "2026-01-29T12:30:00+08:00", + "update_time": "2026-01-29T12:30:15+08:00" +} +``` + +**状态说明**: + +| detail_status | 说明 | +|--------------|------| +| PROCESSING | 转账中 | +| SUCCESS | 转账成功 | +| FAIL | 转账失败 | + +### 3. 转账结果通知(回调) + +#### 回调触发 + +当转账状态变更时,微信支付会主动向配置的 `notify_url` 发送POST请求。 + +#### 回调请求头 + +``` +Wechatpay-Signature: 签名值 +Wechatpay-Timestamp: 1769653396 +Wechatpay-Nonce: R0PDA5lOV3IMrBjrvbCH5U4L3Lb0gg8L +Wechatpay-Serial: 642B2B33557205BA79A1CFF08EA2A2478D67BD63 +Wechatpay-Signature-Type: WECHATPAY2-SHA256-RSA2048 +Content-Type: application/json +``` + +#### 回调请求体(加密) + +```json +{ + "id": "cb29e425-ca17-59fb-8045-8e5b58917154", + "create_time": "2026-01-29T10:23:11+08:00", + "resource_type": "encrypt-resource", + "event_type": "MCHTRANSFER.BILL.FINISHED", + "summary": "商家转账单据终态通知", + "resource": { + "original_type": "mch_payment", + "algorithm": "AEAD_AES_256_GCM", + "ciphertext": "加密的数据...", + "associated_data": "mch_payment", + "nonce": "随机字符串" + } +} +``` + +#### 解密后的数据 + +```json +{ + "mch_id": "1318592501", + "out_bill_no": "TX202601291234567890", + "transfer_bill_no": "1330000114850082601290057112302122", + "transfer_amount": 5000, + "state": "SUCCESS", + "openid": "odq3g5IOG-Z1WLpbeG_amUme8EZk", + "create_time": "2026-01-29T12:30:00+08:00", + "update_time": "2026-01-29T12:30:15+08:00" +} +``` + +**state状态说明**: + +| state | 说明 | +|-------|------| +| PROCESSING | 转账中 | +| SUCCESS | 转账成功 | +| FAIL | 转账失败 | +| WAIT_USER_CONFIRM | 待用户确认 | +| TRANSFERING | 正在转账 | + +#### 回调响应 + +处理完成后,返回给微信: + +```json +{ + "code": "SUCCESS" +} +``` + +--- + +## 签名算法 + +### 1. 签名生成(请求签名) + +#### 签名串格式 + +``` +请求方法\n +请求URL路径\n +请求时间戳\n +随机字符串\n +请求报文主体\n +``` + +**示例**: + +``` +POST +/v3/transfer/batches +1234567890 +RandomString123456 +{"appid":"wx6489c26045912fe1"} +``` + +**重要**:每部分末尾都有 `\n` 换行符。 + +#### 签名步骤 + +1. 构建签名串 +2. 使用商户私钥进行SHA256withRSA签名 +3. 对签名结果进行Base64编码 + +#### PHP实现 + +```php +function buildSignature($method, $url, $timestamp, $nonce, $body, $privateKeyPath) { + // 1. 构建签名串 + $signStr = $method . "\n" + . $url . "\n" + . $timestamp . "\n" + . $nonce . "\n" + . $body . "\n"; + + // 2. 加载私钥 + $privateKeyContent = file_get_contents($privateKeyPath); + $privateKeyResource = openssl_pkey_get_private($privateKeyContent); + + // 3. 使用私钥签名 + openssl_sign($signStr, $signature, $privateKeyResource, 'sha256WithRSAEncryption'); + + // 4. Base64编码 + return base64_encode($signature); +} +``` + +#### 构建Authorization头 + +```php +function buildAuthorization($mchId, $timestamp, $nonce, $signature, $serialNo) { + return sprintf( + 'WECHATPAY2-SHA256-RSA2048 mchid="%s",nonce_str="%s",signature="%s",timestamp="%d",serial_no="%s"', + $mchId, + $nonce, + $signature, + $timestamp, + $serialNo + ); +} +``` + +### 2. 签名验证(回调验签) + +#### 验签串格式 + +``` +时间戳\n +随机字符串\n +请求报文主体\n +``` + +**示例**: + +``` +1769653396 +R0PDA5lOV3IMrBjrvbCH5U4L3Lb0gg8L +{"id":"cb29e425-ca17-59fb-8045-8e5b58917154",...} +``` + +#### PHP实现 + +```php +function verifySignature($timestamp, $nonce, $body, $signature, $publicKeyPath) { + // 1. 构建验签串 + $verifyStr = $timestamp . "\n" + . $nonce . "\n" + . $body . "\n"; + + // 2. Base64解码签名 + $signatureDecode = base64_decode($signature); + + // 3. 加载平台公钥 + $publicKeyContent = file_get_contents($publicKeyPath); + $publicKeyResource = openssl_pkey_get_public($publicKeyContent); + + // 4. 验证签名 + $result = openssl_verify( + $verifyStr, + $signatureDecode, + $publicKeyResource, + 'sha256WithRSAEncryption' + ); + + return $result === 1; // 1表示验证成功 +} +``` + +**重要**:验签使用的是**微信支付平台公钥**,不是商户私钥! + +--- + +## 加密解密 + +### 回调数据解密 + +#### 算法信息 + +- **算法**:AEAD_AES_256_GCM +- **密钥**:APIv3密钥(32字节) +- **密文格式**:实际密文 + 认证标签(16字节) + +#### 解密步骤 + +1. 提取加密数据(ciphertext、nonce、associated_data) +2. Base64解码密文 +3. 分离密文和认证标签(最后16字节) +4. 使用AES-256-GCM解密 +5. 解析JSON数据 + +#### PHP实现 + +```php +function decryptCallbackData($ciphertext, $nonce, $associatedData, $apiV3Key) { + // 1. 检查APIv3密钥长度(必须32字节) + if (strlen($apiV3Key) !== 32) { + throw new Exception('APIv3密钥长度必须为32字节'); + } + + // 2. Base64解码密文 + $ciphertextDecoded = base64_decode($ciphertext); + + // 3. 分离密文和认证标签 + $authTag = substr($ciphertextDecoded, -16); + $ctext = substr($ciphertextDecoded, 0, -16); + + // 4. 使用AES-256-GCM解密 + $decrypted = openssl_decrypt( + $ctext, // 密文 + 'aes-256-gcm', // 算法 + $apiV3Key, // 密钥 + OPENSSL_RAW_DATA, // 选项 + $nonce, // 随机串 + $authTag, // 认证标签 + $associatedData // 附加数据 + ); + + if ($decrypted === false) { + throw new Exception('解密失败'); + } + + // 5. 解析JSON + return json_decode($decrypted, true); +} +``` + +**使用示例**: + +```php +$resource = $callbackData['resource']; +$decrypted = decryptCallbackData( + $resource['ciphertext'], + $resource['nonce'], + $resource['associated_data'], + 'wx3e31b068be59ddc131b068be59ddc2' // APIv3密钥 +); +``` + +--- + +## 代码实现 + +### 完整的微信支付转账类 + +```php +mchId = $config['mch_id']; + $this->appId = $config['app_id']; + $this->apiV3Key = $config['api_v3_key']; + $this->certSerialNo = $config['cert_serial_no']; + + // 加载私钥 + $privateKeyContent = file_get_contents($config['private_key']); + $this->privateKey = openssl_pkey_get_private($privateKeyContent); + } + + /** + * 发起转账 + */ + public function createTransfer($params) + { + $url = '/v3/transfer/batches'; + $method = 'POST'; + + // 构建请求数据 + $data = [ + 'appid' => $this->appId, + 'out_batch_no' => 'BATCH' . date('YmdHis') . mt_rand(1000, 9999), + 'batch_name' => $params['batch_name'] ?? '提现', + 'batch_remark' => $params['batch_remark'] ?? '用户提现', + 'total_amount' => $params['transfer_amount'], + 'total_num' => 1, + 'transfer_detail_list' => [ + [ + 'out_detail_no' => $params['out_detail_no'], + 'transfer_amount' => $params['transfer_amount'], + 'transfer_remark' => $params['transfer_remark'], + 'openid' => $params['openid'], + ] + ], + 'transfer_scene_id' => $params['transfer_scene_id'] ?? '1005', + ]; + + // 添加场景报备信息 + if (!empty($params['transfer_scene_report_infos'])) { + $data['transfer_scene_report_infos'] = $params['transfer_scene_report_infos']; + } + + $body = json_encode($data, JSON_UNESCAPED_UNICODE); + + // 生成签名 + $timestamp = time(); + $nonce = $this->generateNonce(); + $signature = $this->buildSignature($method, $url, $timestamp, $nonce, $body); + + // 构建Authorization + $authorization = $this->buildAuthorization($timestamp, $nonce, $signature); + + // 发送请求 + return $this->request($method, $url, $body, $authorization); + } + + /** + * 查询转账单 + */ + public function queryTransfer($batchNo, $detailNo) + { + $url = "/v3/transfer/batches/batch-id/" . urlencode($batchNo) + . "/details/detail-id/" . urlencode($detailNo); + $method = 'GET'; + + $timestamp = time(); + $nonce = $this->generateNonce(); + $signature = $this->buildSignature($method, $url, $timestamp, $nonce, ''); + $authorization = $this->buildAuthorization($timestamp, $nonce, $signature); + + return $this->request($method, $url, '', $authorization); + } + + /** + * 验证回调签名 + */ + public function verifyCallback($headers, $body, $publicKey) + { + $timestamp = $headers['wechatpay-timestamp']; + $nonce = $headers['wechatpay-nonce']; + $signature = $headers['wechatpay-signature']; + + $verifyStr = $timestamp . "\n" . $nonce . "\n" . $body . "\n"; + $signatureDecode = base64_decode($signature); + + $publicKeyContent = file_get_contents($publicKey); + $publicKeyResource = openssl_pkey_get_public($publicKeyContent); + + $result = openssl_verify($verifyStr, $signatureDecode, $publicKeyResource, 'sha256WithRSAEncryption'); + + return $result === 1; + } + + /** + * 解密回调数据 + */ + public function decryptCallbackResource($resource) + { + $ciphertext = $resource['ciphertext']; + $nonce = $resource['nonce']; + $associatedData = $resource['associated_data']; + + if (strlen($this->apiV3Key) !== 32) { + throw new \Exception('APIv3密钥长度必须为32字节'); + } + + $ciphertextDecoded = base64_decode($ciphertext); + $authTag = substr($ciphertextDecoded, -16); + $ctext = substr($ciphertextDecoded, 0, -16); + + $decrypted = openssl_decrypt( + $ctext, + 'aes-256-gcm', + $this->apiV3Key, + OPENSSL_RAW_DATA, + $nonce, + $authTag, + $associatedData + ); + + if ($decrypted === false) { + throw new \Exception('解密失败'); + } + + return json_decode($decrypted, true); + } + + /** + * 生成签名 + */ + private function buildSignature($method, $url, $timestamp, $nonce, $body) + { + $signStr = $method . "\n" + . $url . "\n" + . $timestamp . "\n" + . $nonce . "\n" + . $body . "\n"; + + openssl_sign($signStr, $signature, $this->privateKey, 'sha256WithRSAEncryption'); + + return base64_encode($signature); + } + + /** + * 构建Authorization头 + */ + private function buildAuthorization($timestamp, $nonce, $signature) + { + return sprintf( + 'WECHATPAY2-SHA256-RSA2048 mchid="%s",nonce_str="%s",signature="%s",timestamp="%d",serial_no="%s"', + $this->mchId, + $nonce, + $signature, + $timestamp, + $this->certSerialNo + ); + } + + /** + * 生成随机字符串 + */ + private function generateNonce($length = 32) + { + $chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; + $nonce = ''; + for ($i = 0; $i < $length; $i++) { + $nonce .= $chars[mt_rand(0, strlen($chars) - 1)]; + } + return $nonce; + } + + /** + * 发送HTTP请求 + */ + private function request($method, $url, $body, $authorization) + { + $fullUrl = 'https://api.mch.weixin.qq.com' . $url; + + $headers = [ + 'Authorization: ' . $authorization, + 'Content-Type: application/json', + 'Accept: application/json', + 'User-Agent: YourApp/1.0' + ]; + + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL, $fullUrl); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true); + curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); + curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); + + if ($method === 'POST') { + curl_setopt($ch, CURLOPT_POST, true); + curl_setopt($ch, CURLOPT_POSTFIELDS, $body); + } + + $response = curl_exec($ch); + $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); + curl_close($ch); + + $result = json_decode($response, true); + + if ($httpCode >= 200 && $httpCode < 300) { + return ['success' => true, 'data' => $result]; + } else { + return [ + 'success' => false, + 'error_code' => $result['code'] ?? 'UNKNOWN', + 'error_msg' => $result['message'] ?? '未知错误' + ]; + } + } +} +``` + +### 使用示例 + +#### 1. 发起转账 + +```php +// 初始化配置 +$config = [ + 'mch_id' => '1318592501', + 'app_id' => 'wx6489c26045912fe1', + 'api_v3_key' => 'wx3e31b068be59ddc131b068be59ddc2', + 'private_key' => '/path/to/apiclient_key.pem', + 'cert_serial_no' => '4A1DB62CD5C9BE0B6FC51C30621D6F99686E75C5', +]; + +$wechatPay = new WechatPayTransfer($config); + +// 发起转账 +$result = $wechatPay->createTransfer([ + 'out_detail_no' => 'TX' . date('YmdHis') . mt_rand(1000, 9999), + 'transfer_amount' => 5000, // 50元 = 5000分 + 'transfer_remark' => '提现', + 'openid' => 'odq3g5IOG-Z1WLpbeG_amUme8EZk', + 'transfer_scene_id' => '1005', + 'transfer_scene_report_infos' => [ + ['info_type' => '岗位类型', 'info_content' => '兼职人员'], + ['info_type' => '报酬说明', 'info_content' => '当日兼职费'], + ], +]); + +if ($result['success']) { + echo "转账成功: " . json_encode($result['data']); +} else { + echo "转账失败: " . $result['error_msg']; +} +``` + +#### 2. 查询转账单 + +```php +$result = $wechatPay->queryTransfer('BATCH202601291234567890', 'TX202601291234567890'); + +if ($result['success']) { + echo "状态: " . $result['data']['detail_status']; +} else { + echo "查询失败: " . $result['error_msg']; +} +``` + +#### 3. 处理回调 + +```php +// 接收回调 +$headers = [ + 'wechatpay-signature' => $_SERVER['HTTP_WECHATPAY_SIGNATURE'], + 'wechatpay-timestamp' => $_SERVER['HTTP_WECHATPAY_TIMESTAMP'], + 'wechatpay-nonce' => $_SERVER['HTTP_WECHATPAY_NONCE'], + 'wechatpay-serial' => $_SERVER['HTTP_WECHATPAY_SERIAL'], +]; + +$body = file_get_contents('php://input'); +$callbackData = json_decode($body, true); + +// 验证签名 +$verified = $wechatPay->verifyCallback($headers, $body, '/path/to/wechat_pay_pub_key.pem'); + +if ($verified) { + // 解密数据 + $decrypted = $wechatPay->decryptCallbackResource($callbackData['resource']); + + // 处理转账结果 + if ($decrypted['state'] === 'SUCCESS') { + echo "转账成功: " . $decrypted['out_bill_no']; + } + + // 返回成功 + echo json_encode(['code' => 'SUCCESS']); +} else { + echo json_encode(['code' => 'FAIL', 'message' => '签名验证失败']); +} +``` + +--- + +## 测试验证 + +### 1. 签名生成测试 + +```php +$method = 'POST'; +$url = '/v3/transfer/batches'; +$timestamp = time(); +$nonce = 'RandomString123456'; +$body = '{"appid":"wx6489c26045912fe1"}'; + +$signature = buildSignature($method, $url, $timestamp, $nonce, $body, 'apiclient_key.pem'); + +echo "签名: " . $signature . "\n"; +``` + +### 2. 小额转账测试 + +```php +// 测试金额:0.01元 = 1分 +$result = $wechatPay->createTransfer([ + 'out_detail_no' => 'TEST' . time(), + 'transfer_amount' => 1, // 1分 + 'transfer_remark' => '测试', + 'openid' => 'test_openid', + 'transfer_scene_id' => '1005', + 'transfer_scene_report_infos' => [ + ['info_type' => '岗位类型', 'info_content' => '测试'], + ['info_type' => '报酬说明', 'info_content' => '测试'], + ], +]); +``` + +### 3. 解密测试 + +```php +$resource = [ + 'ciphertext' => 'xxx', + 'nonce' => 'xxx', + 'associated_data' => 'mch_payment', +]; + +try { + $decrypted = decryptCallbackData( + $resource['ciphertext'], + $resource['nonce'], + $resource['associated_data'], + 'wx3e31b068be59ddc131b068be59ddc2' + ); + print_r($decrypted); +} catch (Exception $e) { + echo "解密失败: " . $e->getMessage(); +} +``` + +### 4. 常见问题 + +| 问题 | 原因 | 解决方法 | +|------|------|---------| +| 签名验证失败 | 证书序列号错误 | 重新提取证书序列号 | +| IP白名单错误 | 服务器IP未配置 | 添加到微信商户平台 | +| 解密失败 | APIv3密钥错误 | 检查密钥长度(32字节) | +| 场景报备错误 | info_type不正确 | 使用固定值 | +| 余额不足 | 商户号余额不足 | 充值商户号 | + +--- + +## 附录 + +### A. 错误码对照表 + +https://pay.weixin.qq.com/doc/v3/merchant/4012070193 + +| 错误码 | 说明 | 处理建议 | +|-------|------|---------| +| PARAM_ERROR | 参数错误 | 检查请求参数格式 | +| NOTENOUGH | 商户余额不足 | 充值商户号 | +| INVALID_REQUEST | 不符合业务规则 | 检查业务逻辑 | +| SYSTEM_ERROR | 系统错误 | 稍后重试 | +| FREQUENCY_LIMITED | 频率限制 | 降低请求频率 | +| APPID_MCHID_NOT_MATCH | appid和mch_id不匹配 | 检查配置 | + +### B. 转账状态说明 + +| 状态 | 说明 | 处理方式 | +|------|------|---------| +| PROCESSING | 转账中 | 等待回调或主动查询 | +| SUCCESS | 转账成功 | 完成流程 | +| FAIL | 转账失败 | 检查失败原因 | +| WAIT_USER_CONFIRM | 待用户确认 | 等待用户操作 | +| TRANSFERING | 正在转账 | 等待处理完成 | + +### C. 开发工具 + +- **Postman**:API测试工具 +- **OpenSSL**:证书和密钥管理 +- **微信支付调试工具**:https://pay.weixin.qq.com/ + +--- + +**文档版本**:v3.0(纯微信支付API版) +**更新时间**:2026-01-29 +**适用场景**:微信支付商家转账到零钱功能集成 + +--- + +## 总结 + +本文档提供了微信支付转账功能的完整集成方案: + +✅ **3个核心API** +- 发起转账:`POST /v3/transfer/batches` +- 查询转账:`GET /v3/transfer/batches/batch-id/{batch_id}/details/detail-id/{detail_id}` +- 接收回调:异步通知 + +✅ **3个核心算法** +- 签名生成:SHA256withRSA + Base64 +- 签名验证:使用平台公钥 +- 数据解密:AEAD_AES_256_GCM + +✅ **完整代码实现** +- WechatPayTransfer类(可直接使用) +- 包含发起转账、查询、验签、解密全部功能 + +根据本文档可以快速集成微信支付转账功能。 + +--- + +## 相关文档(开发文档内) + +- [分销提现流程图](分销提现流程图.md) — 提现业务流程图 +- [订阅消息](订阅消息.md) — 提现成功订阅消息 +- [商家转账](商家转账.md) — PowerWeChat 调用示例 diff --git a/开发文档/8、部署/支付接口清单.md b/开发文档/8、部署/支付接口清单.md new file mode 100644 index 00000000..a49505a1 --- /dev/null +++ b/开发文档/8、部署/支付接口清单.md @@ -0,0 +1,366 @@ +# 支付相关接口清单 + +**日期**: 2026-02-04 +**说明**: 所有支付相关后端API接口的完整清单 + +--- + +## ✅ 已创建的接口 + +### 1. 小程序支付接口 + +#### `/api/miniprogram/pay` (POST) +**功能**: 创建支付订单并调用微信支付 + +**文件**: `app/api/miniprogram/pay/route.ts` + +**请求参数**: +```json +{ + "openId": "oXXXX...", + "productType": "section", // 'section' | 'fullbook' + "productId": "1-1", + "amount": 9.9, + "description": "章节1-1", + "userId": "user_xxx" +} +``` + +**返回**: +```json +{ + "success": true, + "data": { + "orderSn": "MP20260204123456789012", + "prepayId": "wx...", + "payParams": { + "timeStamp": "...", + "nonceStr": "...", + "package": "prepay_id=...", + "signType": "MD5", + "paySign": "..." + } + } +} +``` + +**关键逻辑**: +- ✅ 插入订单到 `orders` 表 (status='created') +- ✅ 检查是否已有该产品的已支付订单 +- ✅ 调用微信统一下单接口 +- ✅ 返回支付参数 + +--- + +#### `/api/miniprogram/pay/notify` (POST) +**功能**: 接收微信支付回调通知 + +**文件**: `app/api/miniprogram/pay/notify/route.ts` + +**请求**: 微信发送XML格式数据 + +**返回**: XML格式响应 + +**关键逻辑**: +1. ✅ 验证签名 +2. ✅ 更新订单状态为 `paid`(或补记订单) +3. ✅ 解锁用户权限 +4. ✅ 分配推荐佣金(90%) +5. ✅ **清理相同产品的其他未支付订单** + +--- + +### 2. 用户购买状态接口 + +#### `/api/user/purchase-status` (GET) +**功能**: 查询用户的购买状态 + +**文件**: `app/api/user/purchase-status/route.ts` + +**请求**: +``` +GET /api/user/purchase-status?userId=user_xxx +``` + +**返回**: +```json +{ + "success": true, + "data": { + "hasFullBook": false, + "purchasedSections": ["1-1", "1-2"], + "purchasedCount": 2, + "earnings": 0, + "pendingEarnings": 0 + } +} +``` + +**查询逻辑**: +```sql +-- 1. 查询全书权限 +SELECT has_full_book FROM users WHERE id = ? + +-- 2. 查询已购章节(基于 orders 表) +SELECT DISTINCT product_id +FROM orders +WHERE user_id = ? + AND status = 'paid' + AND product_type = 'section' +``` + +--- + +#### `/api/user/check-purchased` (GET) +**功能**: 检查用户是否已购买指定产品 + +**文件**: `app/api/user/check-purchased/route.ts` + +**请求**: +``` +GET /api/user/check-purchased?userId=user_xxx&type=section&productId=1-1 +``` + +**返回**: +```json +{ + "success": true, + "data": { + "isPurchased": true, + "reason": "section_order_exists" + } +} +``` + +**可能的 reason 值**: +- `has_full_book`: 用户已购买全书 +- `fullbook_order_exists`: 有全书的已支付订单 +- `section_order_exists`: 有该章节的已支付订单 +- `null`: 未购买 + +**查询逻辑**: +```sql +-- 1. 检查全书权限 +SELECT has_full_book FROM users WHERE id = ? + +-- 2. 检查是否有该产品的已支付订单 +SELECT COUNT(*) as count +FROM orders +WHERE user_id = ? + AND product_type = ? + AND product_id = ? + AND status = 'paid' +``` + +--- + +### 3. 通用支付接口(未使用) + +#### `/api/payment/create-order` (POST) +**功能**: 通用支付订单创建接口 + +**文件**: `app/api/payment/create-order/route.ts` + +**说明**: +- ⚠️ 小程序实际使用的是 `/api/miniprogram/pay` +- 这个接口是为 Web 端设计的通用支付接口 +- 支持多种支付方式(微信、支付宝、USDT) + +--- + +#### `/api/payment/wechat/notify` (POST) +**功能**: 通用微信支付回调 + +**文件**: `app/api/payment/wechat/notify/route.ts` + +**说明**: +- ⚠️ 小程序实际使用的是 `/api/miniprogram/pay/notify` +- 这个接口是为 Web 端设计的 + +--- + +## 📊 接口调用流程 + +``` +【小程序支付流程】 + +1. 用户点击购买 + ↓ +2. 前端调用 /api/user/purchase-status + (查询是否已购买) + ↓ +3. 如果未购买,前端调用 /api/miniprogram/pay + (创建订单 + 获取支付参数) + ↓ +4. 小程序调起微信支付 + ↓ +5. 用户完成支付 + ↓ +6. 微信回调 /api/miniprogram/pay/notify + (更新订单 + 解锁权限 + 分配佣金 + 清理无效订单) + ↓ +7. 前端支付成功后调用 /api/user/purchase-status + (刷新用户购买状态) +``` + +--- + +## 🔧 测试命令 + +### 1. 测试查询购买状态 + +```bash +curl "http://localhost:30006/api/user/purchase-status?userId=user_xxx" +``` + +**预期结果**: +```json +{ + "success": true, + "data": { + "hasFullBook": false, + "purchasedSections": [], + "purchasedCount": 0, + "earnings": 0, + "pendingEarnings": 0 + } +} +``` + +--- + +### 2. 测试检查是否已购买 + +```bash +curl "http://localhost:30006/api/user/check-purchased?userId=user_xxx&type=section&productId=1-1" +``` + +**预期结果**: +```json +{ + "success": true, + "data": { + "isPurchased": false, + "reason": null + } +} +``` + +--- + +### 3. 测试创建支付订单 + +```bash +curl -X POST http://localhost:30006/api/miniprogram/pay \ + -H "Content-Type: application/json" \ + -d '{ + "openId": "oXXXX...", + "productType": "section", + "productId": "1-1", + "amount": 9.9, + "description": "测试章节", + "userId": "user_xxx" + }' +``` + +**预期结果**: 返回支付参数 + +--- + +## ⚠️ 常见错误 + +### 1. "缺少 userId 参数" + +**原因**: 请求参数中未传递 userId + +**解决**: 确保 URL 参数或请求体中包含 userId + +--- + +### 2. "用户不存在" + +**原因**: 数据库中找不到对应的用户记录 + +**解决**: +1. 检查 userId 是否正确 +2. 确认用户已登录并创建了账号 +3. 查询数据库: `SELECT * FROM users WHERE id = 'user_xxx'` + +--- + +### 3. "订单创建失败" + +**原因**: +- 数据库连接失败 +- 缺少必要字段 +- openId 格式错误 + +**解决**: +1. 检查服务器日志 +2. 确认数据库连接正常 +3. 验证请求参数完整性 + +--- + +### 4. 接口404 + +**原因**: +- Next.js 服务器未重启 +- 文件路径错误 + +**解决**: +1. 重启 Next.js 服务器: `npm run dev` +2. 检查文件是否存在于正确路径 +3. 清除 `.next` 缓存后重启 + +--- + +## 📝 数据库表结构 + +### orders 表 + +| 字段 | 类型 | 说明 | +|-----|------|------| +| `id` | VARCHAR | 订单ID(同 order_sn) | +| `order_sn` | VARCHAR | 订单号 | +| `user_id` | VARCHAR | 用户ID | +| `open_id` | VARCHAR | 微信openId | +| `product_type` | VARCHAR | 产品类型 (section/fullbook) | +| `product_id` | VARCHAR | 产品ID | +| `amount` | DECIMAL | 金额(元) | +| `description` | TEXT | 订单描述 | +| `status` | VARCHAR | 状态 (created/paid/expired) | +| `transaction_id` | VARCHAR | 微信交易号 | +| `pay_time` | DATETIME | 支付时间 | +| `created_at` | DATETIME | 创建时间 | +| `updated_at` | DATETIME | 更新时间 | + +--- + +### users 表(购买相关字段) + +| 字段 | 类型 | 说明 | +|-----|------|------| +| `has_full_book` | BOOLEAN | 是否购买全书 | +| `purchased_sections` | JSON | 已购章节列表 | +| `earnings` | DECIMAL | 已结算收益 | +| `pending_earnings` | DECIMAL | 待结算收益 | + +--- + +## 🎉 接口状态总结 + +| 接口 | 状态 | 用途 | +|-----|------|------| +| `/api/miniprogram/pay` | ✅ 已实现 | 创建支付订单 | +| `/api/miniprogram/pay/notify` | ✅ 已实现 | 支付回调 | +| `/api/user/purchase-status` | ✅ 已实现 | 查询购买状态 | +| `/api/user/check-purchased` | ✅ 已实现 | 检查是否已购买 | +| `/api/payment/create-order` | ⚠️ 未使用 | Web 端通用接口 | +| `/api/payment/wechat/notify` | ⚠️ 未使用 | Web 端回调接口 | + +--- + +**所有小程序支付相关接口已完成!** 🎉 + +**重启 Next.js 服务器后生效**: `npm run dev` diff --git a/开发文档/8、部署/新分销逻辑-宝塔操作清单.md b/开发文档/8、部署/新分销逻辑-宝塔操作清单.md new file mode 100644 index 00000000..d3209e22 --- /dev/null +++ b/开发文档/8、部署/新分销逻辑-宝塔操作清单.md @@ -0,0 +1,299 @@ +# 新分销逻辑 - 宝塔面板操作清单 + +## ✅ 已完成的准备工作 + +- ✅ 数据库字段已添加(last_purchase_date, purchase_count, total_commission) +- ✅ 代码已部署到服务器(/www/wwwroot/soul/dist) +- ✅ 索引已创建 + +--- + +## 🔧 宝塔面板操作步骤 + +### Step 1: 重启 Node.js 服务 + +1. 登录宝塔面板:`http://你的服务器IP:8888` +2. 左侧菜单 → **网站** → 找到 `soul.quwanzhi.com` +3. 点击 **设置** → **Node项目** 标签 +4. 找到项目 `soul` +5. 点击 **重启** 按钮 +6. 等待状态变为"运行中" + +**或者使用命令行**(如果有SSH权限): +```bash +# 使用宝塔的pm2完整路径 +/www/server/nodejs/v16.20.2/bin/pm2 restart soul + +# 查看状态 +/www/server/nodejs/v16.20.2/bin/pm2 status + +# 查看日志 +/www/server/nodejs/v16.20.2/bin/pm2 logs soul --lines 50 +``` + +--- + +### Step 2: 验证服务是否正常 + +#### 2.1 检查网站访问 +在浏览器打开:`https://soul.quwanzhi.com` + +**预期**: +- ✅ 网站正常加载 +- ✅ 无404错误 +- ✅ 可以正常登录 + +#### 2.2 检查新API是否生效 + +打开浏览器控制台,访问: +``` +https://soul.quwanzhi.com/api/db/config?key=referral_config +``` + +**预期返回**: +```json +{ + "success": true, + "config": { + "distributorShare": 90, + "minWithdrawAmount": 10, + "bindingDays": 30, + "userDiscount": 5, + "enableAutoWithdraw": false + } +} +``` + +#### 2.3 检查推广设置页面 + +访问:`https://soul.quwanzhi.com/admin/referral-settings` + +**预期**: +- ✅ 页面正常加载 +- ✅ 显示当前配置 +- ✅ 可以修改并保存 + +--- + +### Step 3: 配置自动解绑定时任务 + +1. 宝塔面板 → 左侧菜单 → **计划任务** +2. 点击 **添加计划任务** +3. 填写以下信息: + +**任务配置**: +``` +任务类型:Shell脚本 +任务名称:自动解绑过期推荐关系 +执行周期:每天 02:00(凌晨2点) +脚本内容: +cd /www/wwwroot/soul/dist && /www/server/nodejs/v16.20.2/bin/node scripts/auto-unbind-expired-simple.js >> /www/wwwroot/soul/logs/auto-unbind.log 2>&1 +``` + +4. 点击 **添加** +5. 任务创建后,点击 **执行** 按钮测试一次 + +**预期日志**(如果没有过期记录): +``` +============================================================ +自动解绑定时任务 +执行时间: 2026/2/5 14:30:00 +============================================================ +✅ 已连接到数据库: soul_miniprogram +✅ 无需解绑的记录 +============================================================ +任务完成 +============================================================ +``` + +--- + +### Step 4: 查看定时任务日志 + +```bash +# 方式1:SSH命令 +cat /www/wwwroot/soul/logs/auto-unbind.log + +# 方式2:宝塔面板 +计划任务 → 找到"自动解绑"任务 → 点击"日志" +``` + +--- + +## 🧪 功能测试(小程序端) + +### 测试1:立即切换绑定 + +1. **准备两个测试账号**: + - 账号A:作为推荐人A(获取推荐码 SOULA001) + - 账号C:作为推荐人C(获取推荐码 SOULC001) + - 账号B:作为购买者 + +2. **测试步骤**: + ``` + Step 1: A 分享文章链接给 B + Step 2: B 点击链接进入小程序(会自动绑定A) + Step 3: 查数据库验证绑定 + Step 4: C 分享文章链接给 B + Step 5: B 点击C的链接(应该立即切换) + Step 6: 再次查数据库验证 + ``` + +3. **数据库验证SQL**: + ```sql + -- 查看B当前的绑定状态 + SELECT + referee_id, + referrer_id, + status, + binding_date, + expiry_date + FROM referral_bindings + WHERE referee_id = 'B的用户ID' + ORDER BY binding_date DESC; + ``` + + **预期结果**: + - 最新一条:`referrer_id = C的ID, status = active` + - 上一条:`referrer_id = A的ID, status = cancelled` + +--- + +### 测试2:购买分佣 + +1. **B 购买一篇文章(1元)** +2. **查看分佣结果**: + ```sql + SELECT + rb.referrer_id, + rb.purchase_count, + rb.total_commission, + rb.last_purchase_date, + u.pending_earnings + FROM referral_bindings rb + JOIN users u ON rb.referrer_id = u.id + WHERE rb.referee_id = 'B的用户ID' AND rb.status = 'active'; + ``` + + **预期结果**(假设90%分成): + ``` + referrer_id: C的ID + purchase_count: 1 + total_commission: 0.90 + pending_earnings: 0.90 + ``` + +3. **B 再次购买**: + ```sql + -- 查询应显示 + purchase_count: 2 + total_commission: 1.80 + pending_earnings: 1.80 + ``` + +--- + +### 测试3:好友优惠(新功能) + +1. **后台设置好友优惠为 10%** + - 访问:`https://soul.quwanzhi.com/admin/referral-settings` + - 修改"好友优惠"为 `10` + - 保存 + +2. **B 通过推荐链接购买** + - 原价 1.00 元的文章 + - 支付时应显示 **0.90 元**(10% off) + +3. **验证佣金计算**: + - C 应获得佣金 = 0.90 × 90% = **0.81 元** + - 而不是 1.00 × 90% = 0.90 元 + +--- + +## 📊 后台监控 + +### 查看绑定切换记录 + +**SQL查询**: +```sql +-- 查看最近的绑定切换 +SELECT + rb.referee_id, + rb.referrer_id, + rb.status, + rb.binding_date, + rb.purchase_count, + rb.total_commission +FROM referral_bindings rb +WHERE rb.status IN ('active', 'cancelled') +ORDER BY rb.binding_date DESC +LIMIT 20; +``` + +### 查看即将过期的绑定 + +```sql +-- 7天内即将过期且无购买的绑定 +SELECT + rb.referee_id, + rb.referrer_id, + rb.binding_date, + rb.expiry_date, + DATEDIFF(rb.expiry_date, NOW()) as days_left, + rb.purchase_count +FROM referral_bindings rb +WHERE rb.status = 'active' + AND rb.expiry_date > NOW() + AND DATEDIFF(rb.expiry_date, NOW()) <= 7 + AND rb.purchase_count = 0 +ORDER BY days_left ASC; +``` + +--- + +## ⚠️ 常见问题 + +### Q1: 点击新链接后没有切换? +**检查**: +- 宝塔面板 → Node项目 → 查看日志 +- 搜索 `[Referral Bind]` 关键词 +- 确认是否有报错 + +### Q2: 购买后 purchase_count 还是 0? +**检查**: +- 查看支付回调日志:`pm2 logs soul | grep PayNotify` +- 确认字段 `purchase_count` 是否存在 +- 执行SQL验证:`SHOW COLUMNS FROM referral_bindings;` + +### Q3: 定时任务没有执行? +**检查**: +- 宝塔面板 → 计划任务 → 找到任务 → 点击"执行"测试 +- 查看日志:`cat /www/wwwroot/soul/logs/auto-unbind.log` +- 确认脚本路径正确:`ls -la /www/wwwroot/soul/dist/scripts/auto-unbind-expired-simple.js` + +--- + +## 📝 部署后清理 + +部署成功后,删除临时文件: + +```bash +# 本地清理 +rm .env.migration +``` + +--- + +## ✅ 完成检查清单 + +- [ ] 数据库字段已添加 +- [ ] 代码已部署 +- [ ] PM2服务运行正常 +- [ ] 网站可以访问 +- [ ] 推广设置页面正常 +- [ ] 定时任务已配置 +- [ ] 功能测试通过 + +--- + +**下一步:执行上述测试验证,或告诉我遇到的任何问题!** diff --git a/开发文档/8、部署/新分销逻辑-部署步骤.md b/开发文档/8、部署/新分销逻辑-部署步骤.md new file mode 100644 index 00000000..9f65bfc9 --- /dev/null +++ b/开发文档/8、部署/新分销逻辑-部署步骤.md @@ -0,0 +1,537 @@ +# 新分销逻辑 - 部署步骤 + +## 📋 部署前检查 + +### 确认新逻辑 +- ✅ 点击谁的链接,立即绑定谁(无条件切换) +- ✅ 购买时,佣金给当前推荐人 +- ✅ 30天内无购买 → 自动解绑 +- ✅ 方案A:购买后不重置30天 + +### 备份数据 +```bash +# 1. 备份数据库 +mysqldump -u root -p mycontent_db > backup_before_referral_$(date +%Y%m%d).sql + +# 2. 备份代码 +cd /www/wwwroot/soul +tar -czf backup_code_$(date +%Y%m%d).tar.gz app/ lib/ scripts/ +``` + +--- + +## 🚀 部署步骤 + +### Step 1: 数据库迁移 + +#### 方式1:使用 Python 脚本(推荐) + +```bash +# 1. 上传脚本到服务器 +cd /www/wwwroot/soul +# 将 scripts/migrate_binding_fields.py 上传到服务器 + +# 2. 确保环境变量正确(.env 文件) +cat .env | grep DB_ + +# 3. 执行迁移 +python3 scripts/migrate_binding_fields.py +``` + +**预期输出**: +``` +========================================================== +数据库迁移:referral_bindings 表字段升级 +========================================================== + +✅ 已连接到数据库: mycontent_db + +步骤 1: 添加新字段 +------------------------------------------------------------ +✅ 添加字段 last_purchase_date +✅ 添加字段 purchase_count +✅ 添加字段 total_commission + +步骤 2: 添加索引 +------------------------------------------------------------ +✅ 添加索引 idx_referee_status +✅ 添加索引 idx_expiry_purchase + +步骤 3: 更新 status 枚举(添加 cancelled) +------------------------------------------------------------ +✅ 更新 status 枚举类型 + +步骤 4: 验证迁移结果 +------------------------------------------------------------ +✅ 字段 last_purchase_date 已存在 +✅ 字段 purchase_count 已存在 +✅ 字段 total_commission 已存在 + +========================================================== +✅ 迁移完成! +========================================================== +``` + +#### 方式2:直接执行 SQL + +```bash +# 连接数据库 +mysql -u root -p mycontent_db + +# 执行迁移SQL +source scripts/migration-add-binding-fields.sql; + +# 验证字段 +SHOW COLUMNS FROM referral_bindings; +``` + +--- + +### Step 2: 部署代码 + +#### 本地构建 +```bash +# 在本地项目目录 +cd e:\Gongsi\Mycontent + +# 构建 +pnpm build + +# 确认构建产物 +ls -la .next/standalone +``` + +#### 上传到服务器 +```bash +# 使用 devlop.py(自动化部署) +python devlop.py + +# 或手动上传 +# 1. 上传修改的文件: +# - app/api/referral/bind/route.ts +# - app/api/miniprogram/pay/notify/route.ts +# - scripts/auto-unbind-expired-simple.js +``` + +--- + +### Step 3: 重启服务 + +```bash +# 重启 PM2 +pm2 restart soul + +# 查看日志确认启动正常 +pm2 logs soul --lines 50 + +# 确认进程状态 +pm2 status +``` + +**预期输出**: +``` +┌─────┬────────┬─────────┬──────┬─────┬──────────┐ +│ id │ name │ status │ ↺ │ cpu │ memory │ +├─────┼────────┼─────────┼──────┼─────┼──────────┤ +│ 0 │ soul │ online │ 0 │ 0% │ 100.0mb │ +└─────┴────────┴─────────┴──────┴─────┴──────────┘ +``` + +--- + +### Step 4: 配置定时任务 + +#### 宝塔面板配置 + +1. 登录宝塔面板 +2. 进入"计划任务" +3. 添加 Shell 脚本任务 + +**任务配置**: +- **任务名称**:自动解绑过期推荐关系 +- **执行周期**:每天 02:00 +- **脚本内容**: + ```bash + cd /www/wwwroot/soul && node scripts/auto-unbind-expired-simple.js >> /www/wwwroot/soul/logs/auto-unbind.log 2>&1 + ``` + +#### 手动测试定时任务 + +```bash +# 进入项目目录 +cd /www/wwwroot/soul + +# 创建日志目录 +mkdir -p logs + +# 手动执行一次 +node scripts/auto-unbind-expired-simple.js + +# 查看日志 +cat logs/auto-unbind.log +``` + +**预期输出**(如果有过期记录): +``` +============================================================ +自动解绑定时任务 +执行时间: 2026/2/5 02:00:00 +============================================================ + +✅ 已连接到数据库: mycontent_db + +步骤 1: 查询需要解绑的记录... +------------------------------------------------------------ +找到 3 条需要解绑的记录 + +步骤 2: 解绑明细 +------------------------------------------------------------ +1. 用户 user_abc123 + 推荐人: user_xyz789 + 绑定时间: 2026/1/5 + 过期时间: 2026/2/4 (已过期 1 天) + 购买次数: 0 + 累计佣金: ¥0.00 + +... + +步骤 3: 执行解绑操作... +------------------------------------------------------------ +✅ 已成功解绑 3 条记录 + +步骤 4: 更新推荐人统计... +------------------------------------------------------------ + - user_xyz789: -2 个绑定 + - user_def456: -1 个绑定 +✅ 已更新 2 个推荐人的统计数据 + +============================================================ +✅ 任务完成 + - 解绑记录数: 3 + - 受影响推荐人: 2 +============================================================ +``` + +--- + +## 🧪 功能测试 + +### 测试用例1:立即切换绑定 + +#### 准备工作 +```bash +# 创建测试用户 A、B、C +# A 推荐 B +# C 也想抢 B +``` + +#### 测试步骤 +```bash +# 1. A 推荐 B(新绑定) +curl -X POST http://localhost:3006/api/referral/bind \ + -H "Content-Type: application/json" \ + -d '{ + "userId": "test_user_b", + "referralCode": "SOULA001", + "source": "miniprogram" + }' + +# 预期返回: +# { +# "success": true, +# "message": "绑定成功", +# "action": "new", +# "expiryDate": "2026-03-07T...", +# "referrer": { "id": "test_user_a", "nickname": "用户A" } +# } + +# 2. B 点击 C 的链接(立即切换) +curl -X POST http://localhost:3006/api/referral/bind \ + -H "Content-Type: application/json" \ + -d '{ + "userId": "test_user_b", + "referralCode": "SOULC001", + "source": "miniprogram" + }' + +# 预期返回: +# { +# "success": true, +# "message": "已切换推荐人", +# "action": "switch", +# "expiryDate": "2026-03-07T...", +# "referrer": { "id": "test_user_c", "nickname": "用户C" }, +# "oldReferrerId": "test_user_a" +# } + +# 3. 验证数据库 +mysql -u root -p mycontent_db -e " + SELECT referee_id, referrer_id, status, binding_date, expiry_date + FROM referral_bindings + WHERE referee_id = 'test_user_b' + ORDER BY binding_date DESC LIMIT 2; +" + +# 预期结果: +# 记录1: referee=B, referrer=C, status=active (最新) +# 记录2: referee=B, referrer=A, status=cancelled (旧) +``` + +--- + +### 测试用例2:购买分佣(累加) + +#### 测试步骤 +```bash +# 1. B 购买第1次(1元) +# 触发支付回调 -> /api/miniprogram/pay/notify + +# 2. 查询分佣结果 +mysql -u root -p mycontent_db -e " + SELECT + rb.referrer_id, + rb.purchase_count, + rb.total_commission, + u.pending_earnings + FROM referral_bindings rb + JOIN users u ON rb.referrer_id = u.id + WHERE rb.referee_id = 'test_user_b' AND rb.status = 'active'; +" + +# 预期结果: +# referrer_id: test_user_c +# purchase_count: 1 +# total_commission: 0.90 (假设90%分成) +# pending_earnings: 0.90 + +# 3. B 购买第2次(1元) +# 再次触发支付回调 + +# 4. 再次查询 +# 预期结果: +# purchase_count: 2 +# total_commission: 1.80 +# pending_earnings: 1.80 +``` + +--- + +### 测试用例3:30天自动解绑 + +#### 模拟测试(修改过期时间) +```bash +# 1. 手动修改绑定的过期时间(测试用) +mysql -u root -p mycontent_db -e " + UPDATE referral_bindings + SET expiry_date = '2026-02-04 00:00:00' + WHERE referee_id = 'test_user_x' AND referrer_id = 'test_user_y'; +" + +# 2. 执行定时任务 +node scripts/auto-unbind-expired-simple.js + +# 3. 验证解绑 +mysql -u root -p mycontent_db -e " + SELECT referee_id, referrer_id, status, expiry_date, purchase_count + FROM referral_bindings + WHERE referee_id = 'test_user_x'; +" + +# 预期结果: +# status: expired(如果 purchase_count = 0) +# status: active(如果 purchase_count > 0) +``` + +--- + +## 🔍 监控与日志 + +### 查看绑定切换日志 +```bash +# PM2 日志 +pm2 logs soul | grep "Referral Bind" + +# 查找"立即切换"记录 +pm2 logs soul | grep "立即切换" +``` + +### 查看分佣日志 +```bash +# 查看分佣成功记录 +pm2 logs soul | grep "分佣完成" + +# 查看累加情况 +pm2 logs soul | grep "purchaseCount" +``` + +### 定时任务日志 +```bash +# 查看定时任务执行记录 +cat /www/wwwroot/soul/logs/auto-unbind.log + +# 实时监控 +tail -f /www/wwwroot/soul/logs/auto-unbind.log +``` + +--- + +## 📊 数据统计 + +### 查看当前绑定状态分布 +```sql +SELECT + status, + COUNT(*) as count, + SUM(purchase_count) as total_purchases, + SUM(total_commission) as total_commission +FROM referral_bindings +GROUP BY status; +``` + +### 查看切换频率最高的用户 +```sql +SELECT + referee_id, + COUNT(*) as binding_count, + GROUP_CONCAT(referrer_id ORDER BY binding_date DESC) as referrer_history +FROM referral_bindings +WHERE status IN ('active', 'cancelled') +GROUP BY referee_id +HAVING COUNT(*) > 1 +ORDER BY binding_count DESC +LIMIT 10; +``` + +### 查看30天内即将过期的绑定 +```sql +SELECT + referee_id, + referrer_id, + binding_date, + expiry_date, + DATEDIFF(expiry_date, NOW()) as days_left, + purchase_count +FROM referral_bindings +WHERE status = 'active' + AND expiry_date > NOW() + AND DATEDIFF(expiry_date, NOW()) <= 7 +ORDER BY days_left ASC; +``` + +--- + +## ⚠️ 回滚方案 + +### 如果需要回滚到旧逻辑 + +#### 1. 恢复数据库 +```bash +# 停止服务 +pm2 stop soul + +# 恢复备份 +mysql -u root -p mycontent_db < backup_before_referral_20260205.sql + +# 重启服务 +pm2 start soul +``` + +#### 2. 恢复代码 +```bash +# 方式1:Git回滚 +cd /www/wwwroot/soul +git reset --hard <上一个commit> + +# 方式2:恢复备份 +tar -xzf backup_code_20260205.tar.gz + +# 重启 +pm2 restart soul +``` + +#### 3. 停用定时任务 +```bash +# 宝塔面板 -> 计划任务 -> 停用或删除"自动解绑"任务 +``` + +--- + +## 📝 常见问题 + +### Q1: 定时任务没有执行? +**检查步骤**: +1. 确认宝塔计划任务状态为"启用" +2. 查看宝塔计划任务日志 +3. 手动执行测试:`node scripts/auto-unbind-expired-simple.js` +4. 检查脚本权限:`chmod +x scripts/auto-unbind-expired-simple.js` + +### Q2: 绑定切换后,旧推荐人还能收到佣金? +**原因**:可能是购买时的绑定查询逻辑有问题 + +**检查**: +```sql +-- 查看 B 当前的绑定 +SELECT * FROM referral_bindings +WHERE referee_id = 'test_user_b' AND status = 'active'; + +-- 应该只有1条 active 记录(最新的推荐人) +``` + +### Q3: purchase_count 字段不存在? +**原因**:数据库迁移未成功 + +**解决**: +```bash +# 重新执行迁移 +python3 scripts/migrate_binding_fields.py + +# 或手动添加 +mysql -u root -p mycontent_db -e " + ALTER TABLE referral_bindings + ADD COLUMN purchase_count INT DEFAULT 0; +" +``` + +### Q4: 如何验证新逻辑是否生效? +**验证清单**: +- [ ] 数据库有 `last_purchase_date`、`purchase_count`、`total_commission` 字段 +- [ ] 点击不同推荐链接会立即切换(无报错) +- [ ] 购买后 `purchase_count` 会累加 +- [ ] 定时任务能正常执行 + +--- + +## ✅ 部署完成检查表 + +- [ ] 数据库迁移成功 +- [ ] 代码部署完成 +- [ ] PM2 服务正常运行 +- [ ] 定时任务已配置 +- [ ] 测试用例1通过(立即切换) +- [ ] 测试用例2通过(购买累加) +- [ ] 日志正常输出 +- [ ] 备份文件已保存 + +--- + +## 📞 问题反馈 + +如有问题,请提供: +1. 错误日志(PM2日志或定时任务日志) +2. 数据库状态(相关表的查询结果) +3. 复现步骤 + +**日志收集命令**: +```bash +# PM2日志 +pm2 logs soul --lines 100 > soul_logs.txt + +# 定时任务日志 +cat /www/wwwroot/soul/logs/auto-unbind.log > auto_unbind.log + +# 数据库状态 +mysql -u root -p mycontent_db -e " + SELECT * FROM referral_bindings LIMIT 10; + SHOW COLUMNS FROM referral_bindings; +" > db_status.txt +``` diff --git a/开发文档/8、部署/新分销逻辑设计方案.md b/开发文档/8、部署/新分销逻辑设计方案.md new file mode 100644 index 00000000..ab546e3d --- /dev/null +++ b/开发文档/8、部署/新分销逻辑设计方案.md @@ -0,0 +1,408 @@ +# 新分销逻辑设计方案 + +## 📌 业务需求 + +### 核心规则 +1. **动态绑定**:用户B点击谁的分享链接,立即绑定谁(无条件切换) +2. **佣金归属**:B购买时,佣金给当前推荐人(最新绑定的那个人) +3. **自动解绑**:绑定30天内,如果B既没点击其他链接,也没有任何购买 → 自动解绑 + +### 场景示例 +``` +时间线: +Day 0: A推荐B → B注册 → B绑定A(30天有效期) +Day 5: B点击C的链接 → B立即切换绑定C(重新开始30天有效期) +Day 10: B购买文章 → 佣金给C(当前推荐人) +Day 35: 绑定C的30天到期,如果期间无购买 → 自动解绑 +``` + +--- + +## 🗄️ 数据库设计 + +### 1. `referral_bindings` 表字段调整 + +| 字段 | 类型 | 说明 | 新增/修改 | +|------|------|------|-----------| +| `id` | VARCHAR(64) | 主键 | - | +| `referee_id` | VARCHAR(64) | 被推荐人(B) | - | +| `referrer_id` | VARCHAR(64) | 推荐人(当前) | - | +| `referral_code` | VARCHAR(20) | 推荐码 | - | +| `status` | ENUM | active/converted/expired/cancelled | **新增 cancelled** | +| `binding_date` | TIMESTAMP | 最后一次绑定时间 | - | +| `expiry_date` | DATETIME | 过期时间(30天后) | - | +| `last_purchase_date` | DATETIME | 最后一次购买时间 | **新增** | +| `purchase_count` | INT | 购买次数 | **新增** | +| `total_commission` | DECIMAL | 累计佣金 | **新增** | + +### 2. 新增字段的 SQL + +```sql +-- 添加新字段 +ALTER TABLE referral_bindings +ADD COLUMN last_purchase_date DATETIME NULL COMMENT '最后一次购买时间', +ADD COLUMN purchase_count INT DEFAULT 0 COMMENT '购买次数', +ADD COLUMN total_commission DECIMAL(10,2) DEFAULT 0.00 COMMENT '累计佣金', +ADD INDEX idx_expiry_status (expiry_date, status); + +-- 修改 status 枚举(如果需要) +ALTER TABLE referral_bindings +MODIFY COLUMN status ENUM('active', 'converted', 'expired', 'cancelled') DEFAULT 'active'; +``` + +--- + +## 🔧 API 逻辑修改 + +### 1. `/api/referral/bind` - 立即切换绑定 + +**修改前逻辑(现有):** +```javascript +if (existingBinding && expiryDate > now) { + return { error: '绑定有效期内无法更换' } // ❌ 阻止切换 +} +``` + +**修改后逻辑(新):** +```javascript +// 查询B当前的绑定 +const existingBinding = await query(` + SELECT * FROM referral_bindings + WHERE referee_id = ? AND status = 'active' +`, [userId]) + +if (existingBinding.length > 0) { + const current = existingBinding[0] + + // 情况1: 同一个推荐人 → 续期(刷新30天) + if (current.referrer_id === newReferrerId) { + await query(` + UPDATE referral_bindings + SET expiry_date = DATE_ADD(NOW(), INTERVAL 30 DAY), + binding_date = NOW() + WHERE id = ? + `, [current.id]) + return { success: true, action: 'renewed' } + } + + // 情况2: 不同推荐人 → 立即切换 + else { + // 旧绑定标记为 cancelled + await query(` + UPDATE referral_bindings + SET status = 'cancelled' + WHERE id = ? + `, [current.id]) + + // 创建新绑定 + await query(` + INSERT INTO referral_bindings + (id, referee_id, referrer_id, referral_code, status, binding_date, expiry_date) + VALUES (?, ?, ?, ?, 'active', NOW(), DATE_ADD(NOW(), INTERVAL 30 DAY)) + `, [newBindingId, userId, newReferrerId, referralCode]) + + return { success: true, action: 'switched' } + } +} +``` + +**关键变化**: +- ✅ 删除"有效期内不能切换"的限制 +- ✅ 旧绑定标记为 `cancelled`(而不是 `expired`) +- ✅ 立即创建新绑定,重新计算30天 + +--- + +### 2. `/api/miniprogram/pay/notify` - 支付回调更新 + +**修改前逻辑(现有):** +```javascript +// 更新绑定为 converted +await query(` + UPDATE referral_bindings + SET status = 'converted', + conversion_date = NOW(), + commission_amount = ? + WHERE id = ? +`, [commission, bindingId]) +``` + +**修改后逻辑(新):** +```javascript +// 查询B当前的绑定(active状态) +const binding = await query(` + SELECT * FROM referral_bindings + WHERE referee_id = ? AND status = 'active' + ORDER BY binding_date DESC LIMIT 1 +`, [userId]) + +if (binding.length === 0) { + console.log('[PayNotify] 无有效绑定,跳过分佣') + return +} + +const currentBinding = binding[0] +const referrerId = currentBinding.referrer_id + +// 计算佣金 +const commission = amount * distributorShare + +// 更新绑定记录(累加购买次数和佣金) +await query(` + UPDATE referral_bindings + SET last_purchase_date = NOW(), + purchase_count = purchase_count + 1, + total_commission = total_commission + ? + WHERE id = ? +`, [commission, currentBinding.id]) + +// 更新推荐人收益 +await query(` + UPDATE users + SET pending_earnings = pending_earnings + ? + WHERE id = ? +`, [commission, referrerId]) + +console.log('[PayNotify] 分佣成功:', { + referee: userId, + referrer: referrerId, + commission, + purchaseCount: currentBinding.purchase_count + 1 +}) +``` + +**关键变化**: +- ✅ 不再标记为 `converted`(保持 `active`) +- ✅ 记录 `last_purchase_date`(用于判断是否有购买) +- ✅ 累加 `purchase_count` 和 `total_commission` +- ✅ 允许同一绑定多次购买分佣 + +--- + +### 3. 定时任务 - 自动解绑 + +**新增文件**: `scripts/auto-unbind-expired.js` + +```javascript +/** + * 自动解绑定时任务 + * 每天凌晨2点运行(建议配置 cron) + * + * 解绑条件: + * 1. 绑定超过30天(expiry_date < NOW) + * 2. 期间没有任何购买(purchase_count = 0) + */ + +const { query } = require('../lib/db') + +async function autoUnbind() { + console.log('[AutoUnbind] 开始执行自动解绑任务...') + + try { + // 查询需要解绑的记录 + const expiredBindings = await query(` + SELECT id, referee_id, referrer_id, binding_date, expiry_date + FROM referral_bindings + WHERE status = 'active' + AND expiry_date < NOW() + AND purchase_count = 0 + `) + + if (expiredBindings.length === 0) { + console.log('[AutoUnbind] 无需解绑的记录') + return + } + + console.log(`[AutoUnbind] 找到 ${expiredBindings.length} 条需要解绑的记录`) + + // 批量更新为 expired + const ids = expiredBindings.map(b => b.id) + await query(` + UPDATE referral_bindings + SET status = 'expired' + WHERE id IN (?) + `, [ids]) + + console.log(`[AutoUnbind] ✅ 已解绑 ${expiredBindings.length} 条记录`) + + // 输出明细 + expiredBindings.forEach(b => { + console.log(` - ${b.referee_id} 解除与 ${b.referrer_id} 的绑定(绑定于 ${b.binding_date})`) + }) + + } catch (error) { + console.error('[AutoUnbind] ❌ 执行失败:', error) + } +} + +// 如果直接运行此脚本 +if (require.main === module) { + autoUnbind().then(() => { + console.log('[AutoUnbind] 任务完成') + process.exit(0) + }) +} + +module.exports = { autoUnbind } +``` + +**部署方式(宝塔面板)**: +1. 进入"计划任务" → 添加 Shell 脚本 +2. 执行周期:每天 02:00 +3. 脚本内容: + ```bash + cd /www/wwwroot/soul && node scripts/auto-unbind-expired.js + ``` + +--- + +## 📊 状态流转图 + +``` +用户B的绑定状态流转: + +[无绑定] + ↓ (点击A的链接) +[active - 绑定A] ← expiry_date = NOW + 30天 + ↓ (点击C的链接) +[active - 绑定C] ← 旧绑定变 cancelled,新绑定 expiry_date = NOW + 30天 + ↓ (购买) +[active - 绑定C] ← purchase_count++, last_purchase_date = NOW + ↓ (30天后,无购买) +[expired] ← 自动解绑 + ↓ (再次点击D的链接) +[active - 绑定D] ← 重新绑定 +``` + +**status 枚举说明**: +- `active`: 当前有效绑定 +- `cancelled`: 被切换(用户点了其他人链接) +- `expired`: 30天到期且无购买 +- `converted`: **不再使用**(在新逻辑中,购买不改变status) + +--- + +## 🧪 测试用例 + +### 用例1: 立即切换绑定 + +``` +1. A推荐B → B注册 + 预期: referral_bindings 新增一条 (referee=B, referrer=A, status=active) + +2. B点击C的链接 + 预期: + - 旧记录 (referrer=A) status → cancelled + - 新记录 (referrer=C) status = active, expiry_date = NOW + 30天 + +3. B购买文章 + 预期: + - 佣金给C(不是A) + - binding.purchase_count = 1 + - binding.last_purchase_date = NOW +``` + +### 用例2: 30天无购买自动解绑 + +``` +1. A推荐B → B注册 + 预期: binding (referee=B, referrer=A, expiry_date = NOW + 30天) + +2. 等待31天(模拟) + 手动执行: node scripts/auto-unbind-expired.js + 预期: binding.status → expired + +3. B点击C的链接 + 预期: 创建新绑定 (referrer=C) +``` + +### 用例3: 多次购买累加佣金 + +``` +1. A推荐B → B绑定A +2. B购买文章1(1元) + 预期: A获得佣金 0.9元,binding.purchase_count = 1 +3. B购买文章2(1元) + 预期: A再获得佣金 0.9元,binding.purchase_count = 2,total_commission = 1.8 +``` + +--- + +## ⚠️ 注意事项 + +### 1. 边界情况处理 + +**Q1: B多次点击同一个人的链接?** +- A: 刷新 `expiry_date`(续期30天),不创建新记录 + +**Q2: B在切换推荐人后的旧订单佣金?** +- A: 历史佣金不变,只影响新订单 + +**Q3: 用户注册时没有推荐码?** +- A: 无绑定状态,等待首次点击分享链接 + +### 2. 数据一致性 + +- 使用事务保证绑定切换的原子性 +- 定时任务运行时间建议在凌晨低峰期 +- 建议添加 `idx_expiry_status` 索引优化查询 + +### 3. 性能优化 + +```sql +-- 优化索引 +CREATE INDEX idx_referee_status ON referral_bindings(referee_id, status); +CREATE INDEX idx_expiry_purchase ON referral_bindings(expiry_date, purchase_count); +``` + +--- + +## 🚀 部署步骤 + +### Step 1: 数据库迁移 +```bash +# 执行 SQL 添加新字段 +mysql -u root -p mycontent_db < scripts/migration-add-binding-fields.sql +``` + +### Step 2: 修改 API 代码 +- ✅ 修改 `/api/referral/bind`(立即切换逻辑) +- ✅ 修改 `/api/miniprogram/pay/notify`(累加购买次数) + +### Step 3: 部署定时任务 +- ✅ 创建 `scripts/auto-unbind-expired.js` +- ✅ 宝塔面板配置 cron(每天02:00) + +### Step 4: 测试验证 +- ✅ 测试切换绑定流程 +- ✅ 测试购买分佣 +- ✅ 手动运行定时任务验证解绑 + +--- + +## 📈 后续优化建议 + +1. **管理后台增强** + - 查看绑定切换历史(谁被谁抢走了) + - 统计推荐人的"流失率"(被切换走的比例) + +2. **用户端提示** + - 点击新链接时提示"即将切换推荐人" + - 显示当前绑定的推荐人信息 + +3. **防刷机制** + - 限制同一用户短时间内频繁切换绑定 + - 记录IP和设备指纹防止恶意刷绑定 + +4. **数据分析** + - 统计平均绑定时长 + - 分析哪些推荐人容易被"抢走" + - 优化推荐策略 + +--- + +## 🔗 相关文档 + +- [分销与绑定流程图](./分销与绑定流程图.md) +- [推广设置功能完整修复清单](./推广设置功能-完整修复清单.md) +- [API接入说明](./API接入说明.md) diff --git a/开发文档/8、部署/章节阅读付费标准流程设计.md b/开发文档/8、部署/章节阅读付费标准流程设计.md new file mode 100644 index 00000000..75838da2 --- /dev/null +++ b/开发文档/8、部署/章节阅读付费标准流程设计.md @@ -0,0 +1,524 @@ +# 章节阅读与付费标准流程设计 + +> 目标:规范阅读/付费流程,规避 bug,追踪阅读状态(是否读完),为后续数据分析/推荐提供基础。 + +--- + +## 一、核心问题与设计目标 + +### 当前存在的风险点 +1. **权限判断时机不统一**:有些地方用本地缓存、有些用接口,可能不一致 +2. **登录前后状态切换**:未登录→登录、登录后免费列表变化,状态同步复杂 +3. **阅读进度无追踪**:只知道"是否打开过",不知"是否读完"、"读到哪" +4. **付费前重复校验**:支付前、登录后、initSection 多次请求 check-purchased +5. **异常降级策略不统一**:网络失败时有些保守、有些用缓存,可能误解锁 + +### 设计目标 +- **唯一权威数据源**:章节权限以服务端为准(users + orders 表) +- **标准状态机**:章节状态、用户状态明确定义,流转有迹可循 +- **阅读进度追踪**:记录滚动进度、阅读时长、是否读完(≥90% 或到底部) +- **统一异常处理**:网络失败、超时、服务端错误统一降级策略(保守+重试) +- **流程可回溯**:关键节点打日志,便于排查 bug 和数据分析 + +--- + +## 二、标准状态机设计 + +### 2.1 章节权限状态(ChapterAccessState) + +| 状态 | 说明 | 前端展示 | +|------|------|----------| +| `unknown` | 初始/加载中,尚未确定权限 | loading 骨架屏 | +| `free` | 免费章节,无需登录/购买 | 全文 + 已读标记 | +| `locked_not_login` | 付费章节 + 用户未登录 | 预览 + 登录按钮 | +| `locked_not_purchased` | 付费章节 + 已登录但未购买 | 预览 + 购买按钮 | +| `unlocked_purchased` | 付费章节 + 已购买(单章/全书) | 全文 + 已读标记 | +| `error` | 权限校验失败(网络/服务端错误) | 预览 + 重试按钮 | + +### 2.2 阅读进度状态(ReadingProgressState) + +```javascript +{ + sectionId: '1.2', + status: 'reading' | 'completed' | 'abandoned', // 阅读中 | 已完成 | 已放弃(30天未回) + progress: 75, // 滚动进度百分比 0-100 + duration: 360, // 累计阅读时长(秒) + lastPosition: 1200, // 上次滚动位置(px) + completedAt: null, // 读完时间戳(达到90%+停留3s 或滑到底部) + firstOpenAt: 1738560000,// 首次打开时间戳 + lastOpenAt: 1738563600 // 最后打开时间戳 +} +``` + +### 2.3 状态流转图 + +``` +进入阅读页 + ↓ +[unknown] 加载中 + ↓ +拉取最新免费列表 + 用户登录状态 + ↓ + ├─ 免费章节 → [free] → 全文展示 → 记录阅读进度 + ├─ 未登录 → [locked_not_login] → 预览 + 登录按钮 + │ ↓ 登录成功 + │ ├─ 章节已免费 → [free] + │ ├─ 已购买 → [unlocked_purchased] + │ └─ 未购买 → [locked_not_purchased] + ├─ 已登录未购买 → [locked_not_purchased] → 预览 + 购买按钮 + │ ↓ 支付成功 + │ └─ [unlocked_purchased] → 全文展示 + └─ 已登录已购买 → [unlocked_purchased] → 全文展示 → 记录阅读进度 + +网络/服务端错误 → [error] → 保守展示预览 + 重试按钮 +``` + +--- + +## 三、标准流程与接口调用顺序 + +### 3.1 进入章节页标准流程 + +```javascript +async onLoad(options) { + const { id, ref } = options + + // 1. 初始化状态 + this.setState({ accessState: 'unknown', loading: true }) + + // 2. 处理推荐码(异步不阻塞) + if (ref) this.handleReferralCode(ref) + + // 3. 【关键】拉取最新配置(免费列表、价格等)- 串行等待 + await this.fetchLatestConfig() + + // 4. 【关键】确定章节权限状态 - 串行等待 + const accessState = await this.determineAccessState(id) + + // 5. 加载章节内容(全文或预览) + await this.loadChapterContent(id, accessState) + + // 6. 若有权限则初始化阅读追踪 + if (['free', 'unlocked_purchased'].includes(accessState)) { + this.initReadingTracker(id) + } + + // 7. 加载上下章导航 + this.loadNavigation(id) + + this.setState({ loading: false }) +} +``` + +### 3.2 determineAccessState 权限判断标准 + +```javascript +async determineAccessState(sectionId) { + try { + // 1. 检查是否免费(以服务端最新配置为准) + if (this.isFreeChapter(sectionId)) { + return 'free' + } + + // 2. 检查是否登录 + const userId = app.globalData.userInfo?.id + if (!userId) { + return 'locked_not_login' + } + + // 3. 【权威接口】请求服务端校验是否已购买 + const res = await app.request( + `/api/user/check-purchased?userId=${userId}&type=section&productId=${sectionId}`, + { timeout: 5000 } + ) + + if (res.success && res.data?.isPurchased) { + // 同步更新本地缓存(仅作展示用,不作权限依据) + this.syncLocalPurchaseCache(sectionId, res.data) + return 'unlocked_purchased' + } + + return 'locked_not_purchased' + + } catch (error) { + console.error('[Access] 权限判断失败:', error) + // 网络/服务端错误 → 保守策略:视为无权限 + 可重试 + return 'error' + } +} +``` + +### 3.3 登录后重新校验标准流程 + +```javascript +async onLoginSuccess() { + wx.showLoading({ title: '更新状态中...' }) + + try { + // 1. 刷新用户购买列表(全局状态) + await this.refreshUserPurchaseStatus() + + // 2. 重新拉取免费列表(可能刚改免费) + await this.fetchLatestConfig() + + // 3. 重新判断当前章节权限 + const newAccessState = await this.determineAccessState(this.data.sectionId) + + // 4. 更新状态并刷新内容 + this.setState({ + accessState: newAccessState, + isLoggedIn: true + }) + + // 5. 若已解锁则初始化阅读追踪 + if (['free', 'unlocked_purchased'].includes(newAccessState)) { + await this.loadChapterContent(this.data.sectionId, newAccessState) + this.initReadingTracker(this.data.sectionId) + } + + wx.hideLoading() + wx.showToast({ title: '登录成功', icon: 'success' }) + + } catch (e) { + wx.hideLoading() + wx.showToast({ title: '状态更新失败,请重试', icon: 'none' }) + } +} +``` + +### 3.4 支付成功后刷新标准流程 + +```javascript +async onPaymentSuccess() { + wx.showLoading({ title: '确认购买中...' }) + + try { + // 1. 等待服务端处理支付回调(1-2秒) + await this.sleep(2000) + + // 2. 刷新用户购买状态(从 orders 表拉取最新) + await this.refreshUserPurchaseStatus() + + // 3. 重新判断当前章节权限(应为 unlocked_purchased) + const newAccessState = await this.determineAccessState(this.data.sectionId) + + if (newAccessState !== 'unlocked_purchased') { + // 支付成功但权限未生效 → 可能回调延迟,再重试一次 + await this.sleep(1000) + newAccessState = await this.determineAccessState(this.data.sectionId) + } + + // 4. 更新状态并重新加载全文 + this.setState({ accessState: newAccessState }) + await this.loadChapterContent(this.data.sectionId, newAccessState) + + // 5. 初始化阅读追踪 + this.initReadingTracker(this.data.sectionId) + + wx.hideLoading() + wx.showToast({ title: '购买成功', icon: 'success' }) + + } catch (e) { + wx.hideLoading() + wx.showModal({ + title: '提示', + content: '购买成功,但内容加载失败,请返回重新进入', + showCancel: false + }) + } +} +``` + +--- + +## 四、阅读进度追踪方案 + +### 4.1 数据结构(本地 + 服务端) + +**本地存储**(实时更新,用于断点续读): +```javascript +wx.setStorageSync('reading_progress', { + '1.2': { progress: 75, duration: 360, lastPosition: 1200, lastOpenAt: xxx }, + '2.1': { progress: 30, duration: 120, lastPosition: 500, lastOpenAt: xxx } +}) +``` + +**服务端表**(定期上报,用于数据分析): +```sql +CREATE TABLE reading_progress ( + id INT PRIMARY KEY AUTO_INCREMENT, + user_id VARCHAR(50) NOT NULL, + section_id VARCHAR(20) NOT NULL, + progress INT DEFAULT 0, -- 阅读进度 0-100 + duration INT DEFAULT 0, -- 累计时长(秒) + status ENUM('reading', 'completed', 'abandoned') DEFAULT 'reading', + completed_at DATETIME NULL, -- 读完时间 + first_open_at DATETIME NOT NULL, + last_open_at DATETIME NOT NULL, + created_at DATETIME DEFAULT CURRENT_TIMESTAMP, + updated_at DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + UNIQUE KEY idx_user_section (user_id, section_id), + INDEX idx_user_status (user_id, status), + INDEX idx_completed (completed_at) +); +``` + +### 4.2 追踪逻辑 + +```javascript +// 初始化阅读追踪器 +initReadingTracker(sectionId) { + const tracker = { + sectionId, + startTime: Date.now(), + lastScrollTime: Date.now(), + totalDuration: 0, + maxProgress: 0, + isCompleted: false, + scrollTimer: null + } + + this.readingTracker = tracker + + // 恢复上次阅读位置 + this.restoreLastPosition(sectionId) + + // 监听滚动事件(节流) + this.watchScrollProgress() + + // 定期上报进度(每30秒) + this.startProgressReport() +} + +// 监听滚动进度(节流 500ms) +watchScrollProgress() { + let scrollTimer = null + + wx.onPageScroll((e) => { + if (scrollTimer) clearTimeout(scrollTimer) + + scrollTimer = setTimeout(() => { + const { scrollTop, scrollHeight, clientHeight } = this.getScrollInfo() + const progress = Math.min(100, Math.round((scrollTop / (scrollHeight - clientHeight)) * 100)) + + // 更新最大进度 + if (progress > this.readingTracker.maxProgress) { + this.readingTracker.maxProgress = progress + this.saveProgressLocal(progress, scrollTop) + } + + // 判断是否读完(≥90% 且停留3秒) + if (progress >= 90 && !this.readingTracker.isCompleted) { + this.checkCompletion(progress) + } + }, 500) + }) +} + +// 判断是否读完 +async checkCompletion(progress) { + // 停留3秒后标记为已读完 + await this.sleep(3000) + + if (progress >= 90 && !this.readingTracker.isCompleted) { + this.readingTracker.isCompleted = true + this.readingTracker.completedAt = Date.now() + + // 立即上报完成状态 + await this.reportCompletion() + + // 触发埋点/数据分析 + this.trackEvent('chapter_completed', { + sectionId: this.data.sectionId, + duration: this.readingTracker.totalDuration + }) + } +} + +// 定期上报进度(每30秒,页面隐藏/卸载时也上报) +startProgressReport() { + this.reportInterval = setInterval(() => { + this.reportProgressToServer() + }, 30000) + + // 页面隐藏/卸载时立即上报 + wx.onHide(() => this.reportProgressToServer()) + wx.onUnload(() => this.reportProgressToServer()) +} + +// 上报进度到服务端 +async reportProgressToServer() { + if (!this.readingTracker) return + + const now = Date.now() + const duration = Math.round((now - this.readingTracker.lastScrollTime) / 1000) + this.readingTracker.totalDuration += duration + this.readingTracker.lastScrollTime = now + + try { + await app.request('/api/user/reading-progress', { + method: 'POST', + data: { + userId: app.globalData.userInfo?.id, + sectionId: this.readingTracker.sectionId, + progress: this.readingTracker.maxProgress, + duration: this.readingTracker.totalDuration, + status: this.readingTracker.isCompleted ? 'completed' : 'reading' + } + }) + } catch (e) { + console.warn('[Progress] 上报失败,下次重试') + } +} +``` + +### 4.3 断点续读 + +```javascript +// 恢复上次阅读位置 +restoreLastPosition(sectionId) { + const progressData = wx.getStorageSync('reading_progress') || {} + const lastProgress = progressData[sectionId] + + if (lastProgress?.lastPosition) { + wx.pageScrollTo({ + scrollTop: lastProgress.lastPosition, + duration: 300 + }) + + wx.showToast({ + title: `已恢复到 ${lastProgress.progress}%`, + icon: 'none', + duration: 2000 + }) + } +} +``` + +--- + +## 五、异常处理与降级策略 + +### 5.1 统一异常处理原则 + +| 异常类型 | 降级策略 | 用户提示 | +|---------|---------|---------| +| 网络超时(>5s) | 保守策略:视为无权限,展示预览 + 重试按钮 | "网络连接超时,请重试" | +| 服务端 500 | 同上 | "服务暂时不可用,请稍后重试" | +| 权限接口返回 error | 同上 | "无法确认权限,请重试" | +| 内容接口失败 | 尝试本地缓存 → 失败则重试3次 → 仍失败则提示 | "内容加载失败,已尝试 {n} 次" | +| 支付成功但权限未生效 | 延迟1秒重试一次 → 仍失败则提示联系客服 | "购买成功,正在确认..." | + +### 5.2 重试机制 + +```javascript +async requestWithRetry(url, options, maxRetries = 3) { + let lastError = null + + for (let i = 0; i < maxRetries; i++) { + try { + const res = await app.request(url, { ...options, timeout: 5000 }) + return res + } catch (e) { + lastError = e + console.warn(`[Retry] 第 ${i+1} 次请求失败:`, url, e.message) + + if (i < maxRetries - 1) { + await this.sleep(1000 * (i + 1)) // 指数退避 + } + } + } + + throw lastError +} +``` + +--- + +## 六、日志与埋点规范 + +### 6.1 关键节点日志 + +```javascript +// 进入章节 +console.log('[Chapter] 进入章节', { sectionId, accessState, userId, timestamp }) + +// 权限判断 +console.log('[Access] 权限判断', { sectionId, isFree, isLoggedIn, isPurchased, result: accessState }) + +// 登录成功 +console.log('[Login] 登录成功', { userId, beforeState, afterState, timestamp }) + +// 支付成功 +console.log('[Payment] 支付成功', { userId, productType, productId, amount, orderNo, timestamp }) + +// 阅读完成 +console.log('[Reading] 阅读完成', { sectionId, duration, progress, timestamp }) + +// 异常 +console.error('[Error] 异常', { type, message, stack, context }) +``` + +### 6.2 数据埋点(可选,接入统计平台) + +```javascript +// 章节打开 +trackEvent('chapter_open', { sectionId, accessState, source }) + +// 章节解锁(登录/支付) +trackEvent('chapter_unlocked', { sectionId, unlockMethod: 'login' | 'purchase' }) + +// 阅读完成 +trackEvent('chapter_completed', { sectionId, duration, fromProgress }) + +// 购买转化 +trackEvent('purchase_conversion', { productType, productId, amount, referralCode }) +``` + +--- + +## 七、实施步骤 + +### 阶段一:重构权限判断(1-2天) +1. 新增 `accessState` 字段和状态机逻辑 +2. 统一 `determineAccessState` 方法 +3. 修改 `onLoad`、`onLoginSuccess`、`onPaymentSuccess` 按标准流程 +4. 统一异常处理和重试机制 + +### 阶段二:阅读进度追踪(2-3天) +1. 创建 `reading_progress` 表(迁移脚本) +2. 实现 `initReadingTracker`、`watchScrollProgress`、`checkCompletion` +3. 实现本地存储 + 定期上报 +4. 实现断点续读 + +### 阶段三:测试与优化(1-2天) +1. 单元测试:各状态流转、异常降级 +2. 集成测试:登录、支付、阅读完整流程 +3. 边界测试:网络超时、服务端错误、并发操作 +4. 性能优化:节流、防抖、缓存策略 + +### 阶段四:数据分析接入(可选) +1. 对接统计平台(如微信小程序数据助手、神策、诸葛等) +2. 配置关键指标看板:购买转化率、阅读完成率、平均阅读时长 +3. A/B 测试:不同付费墙文案、价格策略 + +--- + +## 八、预期收益 + +- **bug 减少 80%+**:权限判断统一、异常处理标准化 +- **用户体验提升**:断点续读、进度可视化、明确的状态反馈 +- **数据驱动决策**:阅读完成率、购买转化漏斗分析、章节热度排行 +- **可扩展性**:状态机设计便于未来增加"试读 N 分钟"、"好友助力解锁"等玩法 + +--- + +## 附录:核心代码示例 + +完整实现代码见配套文件: +- `miniprogram/utils/chapterAccessManager.js` - 权限管理器 +- `miniprogram/utils/readingTracker.js` - 阅读追踪器 +- `app/api/user/reading-progress/route.ts` - 进度上报接口 +- `scripts/create_reading_progress_table.sql` - 数据表迁移 + +以上为完整设计方案,建议先实施阶段一、二,验证效果后再进行阶段三、四。 diff --git a/开发文档/8、部署/自动化与Webhook.md b/开发文档/8、部署/自动化与Webhook.md new file mode 100644 index 00000000..17a4f4ab --- /dev/null +++ b/开发文档/8、部署/自动化与Webhook.md @@ -0,0 +1,3 @@ +# 自动化与 Webhook(合并自 Next.js自动化、WEBHOOK、GitHub Webhook 与宝塔、自动同步) + +Next.js 自动化部署流程、Vercel/宝塔 Webhook 配置、自动同步与分支策略。详见原各文档。 diff --git a/开发文档/8、部署/订阅消息.md b/开发文档/8、部署/订阅消息.md new file mode 100644 index 00000000..933d56f2 --- /dev/null +++ b/开发文档/8、部署/订阅消息.md @@ -0,0 +1,43 @@ +# 提现订阅消息(PowerWeChat) + +> 来源:soul-api/订阅消息.md。提现成功后向用户发送订阅消息。已整理至开发文档。 + +--- + +## 数据结构示例 + +```go +data := &power.HashMap{ + "phrase4": power.StringMap{ + "value": "提现成功", // 提现结果:提现成功、提现失败 + }, + "amount5": power.StringMap{ + "value": "¥8.6", // 提现金额 + }, + "thing8": power.StringMap{ + "value": "微信打款成功,请点击查收", // 备注,打款失败则提示请联系官方客服 + }, +} +MiniProgramApp.SubscribeMessage.Send(ctx, &request.RequestSubscribeMessageSend{ + ToUser: "OPENID", // 根据订单号联表查询,提现表 user_id 即 openid + TemplateID: "u3MbZGPRkrZIk-I7QdpwzFxnO_CeQPaCWF2FkiIablE", + Page: "/pages/my/my", + // developer=开发版;trial=体验版;formal=正式版 + // 开发环境 souldev.quwanzhi.com,正式环境 soulapi.quwanzhi.com + MiniProgramState: "formal", + Lang: "zh_CN", + Data: data, +}) +``` + +## 回调示例(转账结果) + +```json +{ + "create_time": "2026-02-10T18:02:54+08:00", + "out_bill_no": "WD1770691555206100", + "package_info": "ABBQO+oYAAABAAAAAAAk+...", + "state": "WAIT_USER_CONFIRM", + "transfer_bill_no": "1330000114850082602100071440076263" +} +``` diff --git a/开发文档/8、部署/运行与部署.md b/开发文档/8、部署/运行与部署.md new file mode 100644 index 00000000..77e5ba7c --- /dev/null +++ b/开发文档/8、部署/运行与部署.md @@ -0,0 +1,15 @@ +# 运行与部署(合并自 运行指南、部署总览与线上部署) + +## Soul 主站运行 + +`pnpm install` → `pnpm dev`(端口 3000)或 `pnpm build` + `PORT=3006 node .next/standalone/server.js` + +**环境变量**:MYSQL_*、SKIP_DB、ADMIN_* + +## 线上部署 + +**Web**:宝塔 42.194.232.22,路径 /www/wwwroot/soul,PM2 soul,端口 3006 + +**小程序**:AppID wxb8bbb2b10dec74aa,private.key + 上传脚本 + +**命令**:`python scripts/deploy_baota.py` 或 `开发文档/服务器管理/scripts/一键部署.py` diff --git a/开发文档/8、部署/邀请码分销规则说明.md b/开发文档/8、部署/邀请码分销规则说明.md new file mode 100644 index 00000000..df788156 --- /dev/null +++ b/开发文档/8、部署/邀请码分销规则说明.md @@ -0,0 +1,147 @@ +# 邀请码 / 分销规则说明 + +**配置来源**: 数据库 `system_config.config_key = 'referral_config'` +**分佣逻辑**: `app/api/miniprogram/pay/notify/route.ts` 中 `processReferralCommission` + +> 📌 **流程图**:绑定与分销的完整流程(谁推荐谁、下单怎么写推荐人、分佣怎么算)见 → [分销与绑定流程图](./分销与绑定流程图.md) + +--- + +## 一、分销规则(当前实现) + +### 1. 分成比例 +- **推广者分成**: 默认 **90%**(`referral_config.distributorShare = 90`) +- **平台**: 10% +- 可在管理后台或 `system_config.referral_config` 中修改 + +### 2. 绑定规则 +- **绑定有效期**: 默认 **30 天**(`referral_config.bindingDays = 30`) +- **一级分销**: 只算直接推荐人(`referral_bindings` 中 `referee_id` = 买家,`referrer_id` = 推广者) +- **有效绑定**: `referral_bindings.status = 'active'` 且 `expiry_date > NOW()` + +### 3. 分佣触发 +- 用户**支付成功**后,回调 `POST /api/miniprogram/pay/notify` +- 根据**买家 user_id** 查 `referral_bindings`(referee_id = 买家),取有效绑定的 `referrer_id` +- 佣金 = 订单实付金额 × 90%,计入推广者 `users.pending_earnings` +- 该绑定记录更新为 `status = 'converted'`,并记录 `commission_amount`、`order_id` + +### 4. 其他配置(referral_config) +- **minWithdrawAmount**: 最小提现金额(默认 10 元) +- **userDiscount**: 用户优惠比例(默认 5) + +--- + +## 二、订单与邀请码 + +### 问题 +- 下单接口 `POST /api/miniprogram/pay` 之前**未传邀请码/分销码**,订单表 **orders** 也没有推荐人字段,无法在订单上直接看到“是谁带来的”。 + +### 处理方式(已实现) +1. **orders 表增加字段** + - `referrer_id`(VARCHAR(50) NULL):下单时若存在有效绑定或邀请码,则写入推荐人 user_id。 + - `referral_code`(VARCHAR(20) NULL):**下单时使用的邀请码**,直接记录在订单上便于对账与后台展示。 + - **迁移脚本**:`python scripts/add_orders_referrer_id.py`、`python scripts/add_orders_referral_code.py`(表已存在时各执行一次)。 + +2. **下单时写推荐人与邀请码** + - 创建订单时先按**买家 user_id** 查 `referral_bindings`(referee_id = 买家、有效且未过期),取 `referrer_id`。 + - 若未查到且请求体带了 `referralCode`,则用 `users.referral_code = referralCode` 解析出推荐人 id,写入 `orders.referrer_id`。 + - **邀请码**:优先存请求体里的 `referralCode`(用户章节支付时传的);若未传但已有 `referrer_id`,则存该推荐人当前的 `users.referral_code`,保证订单上有一份当时使用的邀请码记录。 + +3. **小程序传参** + - 支付请求会传 `referralCode`:来自 `wx.getStorageSync('referral_code')`(落地页 ref 带入的“谁邀请了我”的邀请码),供后端解析推荐人并写入 `orders.referrer_id` 与 `orders.referral_code`。 + - **同步约定**:`app.js` 在检测到 `ref` / `referralCode` 时除写入 `pendingReferralCode` 外,会同步写入 `referral_code`;**章节支付**(`pages/read/read.js`)与**找伙伴支付**(`pages/match/match.js`)创建订单时都会带上 `referralCode`,保证两类订单都会记录邀请码。 + +--- + +## 三、订单表与分销逻辑(已实现) + +- **下单时**(`POST /api/miniprogram/pay`): + 1. 根据买家 user_id 查 `referral_bindings`(有效且未过期)取 `referrer_id`; + 2. 若无绑定且请求带 `referralCode`,用 `users.referral_code` 解析出推荐人 id; + 3. 插入 `orders` 时写入 `referrer_id`(需表已执行 `scripts/add_orders_referrer_id.py`)。 +- **支付成功回调**(`POST /api/miniprogram/pay/notify`): + - 仍按 `referral_bindings` 查推荐人并发放佣金(90%),不依赖订单上的 referrer_id; + - 订单上的 `referrer_id` 用于统计、对账和展示。 + +## 四、相关表与字段 + +| 表 / 配置 | 说明 | +|-----------|------| +| **users** | referral_code(自己的邀请码), referred_by(可选), pending_earnings, earnings | +| **referral_bindings** | referrer_id, referee_id, status(active/converted/expired), expiry_date, commission_amount, order_id | +| **orders** | referrer_id(推荐人用户ID), referral_code(下单时使用的邀请码,便于对账与展示) | +| **system_config** | config_key = 'referral_config',含 distributorShare、bindingDays 等 | + +--- + +## 五、流程简述 + +1. 用户 A 分享邀请码 / 带 ref 的链接,用户 B 通过该链接进入并完成绑定(写入 `referral_bindings`,referee_id=B,referrer_id=A)。 +2. 用户 B 下单支付:调用 `POST /api/miniprogram/pay`,后端根据 B 的 user_id 查有效绑定得到 A,写入 `orders.referrer_id = A`。 +3. 支付成功回调:`/api/miniprogram/pay/notify` 再根据 B 查绑定,给 A 结算 90% 佣金,更新 `referral_bindings` 与 `users.pending_earnings`。 + +这样订单上就有邀请/分销关系(referrer_id),且分佣规则不变。 + +--- + +## 六、推荐人 vs 邀请码:会不会乱? + +**结论:不会乱。** 全局只认「推荐人 = 用户ID」,邀请码只用于解析出这个 ID。 + +### 概念区分 + +| 概念 | 含义 | 存储位置 | 用途 | +|------|------|----------|------| +| **邀请码** | 一串码(如 SOULABC123) | `users.referral_code`(每个用户一条) | 链接里带 `ref=邀请码`,用来**识别**是谁推荐的 | +| **推荐人** | 拿佣金的那个人 | 用**用户ID** `referrer_id` 存 | 订单归属、分佣、统计都只认 ID,不认字符串 | + +- 邀请码 → 通过 `users WHERE referral_code = ?` 可唯一解析出 → **推荐人用户ID**。 +- 订单表、绑定表里存的都是 **referrer_id**,从不存邀请码字符串;展示时再用 referrer_id 去查昵称/邀请码即可。 + +### 绑定与订单归属的优先级(唯一权威) + +1. **下单时**(`/api/miniprogram/pay`) + - **先**查 `referral_bindings`:当前买家是否有有效绑定 → 得到 `referrer_id`。 + - **仅当没有绑定**时,才用请求体里的 `referralCode` 去 `users` 表解析出 `referrer_id`。 + - 最终写入订单的**只有** `orders.referrer_id`(用户ID),不会写邀请码。 + +2. **分佣时**(支付成功回调) + - 只查 `referral_bindings`(买家 → 有效绑定的推荐人),**不看**订单上的 referrer_id,也不看邀请码。 + - 佣金发给绑定表里的 `referrer_id`。 + +因此: +- **绑定表** = 权威的「谁推荐了谁」; +- **订单上的 referrer_id** = 下单时根据「绑定表 + 兜底邀请码」算出来的结果,只用于展示/对账; +- **邀请码** = 仅作为入口参数,解析成 referrer_id 后就不再参与逻辑,不会和推荐人 ID 混用。 + +### 前端 storage 说明(避免混用) + +- 落地页/分享带 `ref`:写入 `referral_code`(下划线),支付时读 `referral_code` 传给后端作兜底。 +- App 层待绑定:`pendingReferralCode`;绑定成功后可选写 `boundReferralCode`。 +- 绑定接口、支付接口请求体里统一用 **referralCode**(驼峰)。 + +只要后端始终用「绑定表优先、邀请码兜底」且只落库 referrer_id,全局绑定逻辑就不会乱。 + +--- + +## 七、文章/章节分销 + +**结论:和全局分销是同一套逻辑,没有单独的「按文章维度」分销。** + +### 当前实现 + +- **分享首页**:链接形如 `https://xxx/?ref=邀请码`,点击后 ref 写入 storage,绑定与订单归属按上文规则。 +- **分享某篇文章/章节**: + - 小程序:`/pages/read/read?id=章节ID&ref=邀请码`(阅读页 `onShareAppMessage` / `onShareTimeline` 会带上当前用户邀请码)。 + - Web:`/view/read/章节ID?ref=邀请码`。 +- 访客从**任意**带 ref 的链接进入(首页或某篇文章),都会: + 1. 用 ref 解析出推荐人并完成绑定(`referral_bindings`); + 2. 之后该用户下单,订单归属与分佣都按**同一套**「绑定表优先、邀请码兜底」规则,与**从哪篇文章点进来**无关。 + +也就是说:**文章/章节只决定落地页内容,不改变绑定与分佣规则**。谁发的链接(ref=谁),谁就是推荐人;买的是哪一章、哪本书,都按 90% 给该推荐人,没有「这篇文章单独分成」或「按章节统计推广效果」的单独逻辑。 + +### 未实现的部分(若以后要做) + +- **按文章/章节维度的统计**:例如「通过《1.2 某某章》链接带来的访问/绑定/订单数」—— 当前未记录分享时的章节 id,无法区分。 +- **按文章的分成策略**:例如某章单独 95%、其他 90% —— 当前未实现,所有订单统一 90%。 +- 若需要「文章分销」统计或差异化分成,需要:在访问/绑定/订单上记录「来源章节」(如 `landing_section_id`),并在分佣或报表里按章节维度汇总。 diff --git a/开发文档/8、部署/部署总览.md b/开发文档/8、部署/部署总览.md new file mode 100644 index 00000000..0add6dce --- /dev/null +++ b/开发文档/8、部署/部署总览.md @@ -0,0 +1,52 @@ +# 部署总览 + +> **当前生产架构**:soul-api(Go + Gin)+ soul-admin(React)+ miniprogram。next-project 仅预览。 + +--- + +## 一、核心部署 + +| 文档 | 说明 | +|------|------| +| [新分销逻辑-部署步骤](新分销逻辑-部署步骤.md) | 新分销上线:备份、迁移、部署、验证 | +| [新分销逻辑-宝塔操作清单](新分销逻辑-宝塔操作清单.md) | 宝塔侧具体操作 | +| [运行与部署](运行与部署.md) | 运行与部署说明 | + +--- + +## 二、环境与配置 + +| 文档 | 说明 | +|------|------| +| [VIP功能-数据库迁移说明](VIP功能-数据库迁移说明.md) | VIP 排序、角色、vip_roles 表迁移(2026-02-26) | +| [MCP-MySQL配置说明](MCP-MySQL配置说明.md) | MCP 连接 MySQL | +| [Soul-MySQL-MCP配置说明](Soul-MySQL-MCP配置说明.md) | 本项目 MySQL MCP 配置 | +| [API接入说明](API接入说明.md) | 外部/小程序接入 API | +| [宝塔面板配置订单同步定时任务](宝塔面板配置订单同步定时任务.md) | 订单同步定时任务 | + +--- + +## 三、设计与流程(必读) + +| 文档 | 说明 | +|------|------| +| [新分销逻辑设计方案](新分销逻辑设计方案.md) | 动态绑定、佣金归属、30天自动解绑 | +| [邀请码分销规则说明](邀请码分销规则说明.md) | 邀请码与分成规则 | +| [分销与绑定流程图](分销与绑定流程图.md) | 分销与绑定流程 | +| [章节阅读付费标准流程设计](章节阅读付费标准流程设计.md) | 阅读页付费流程 | +| [阅读页标准流程改造说明](阅读页标准流程改造说明.md) | 阅读页改造要点 | +| [支付接口清单](支付接口清单.md) | 支付相关接口列表 | +| [提现功能完整技术文档](提现功能完整技术文档.md) | 微信支付商家转账到零钱 API 集成 | +| [分销提现流程图](分销提现流程图.md) | 提现业务流程图(申请→审核→打款→回调) | +| [订阅消息](订阅消息.md) | 提现成功订阅消息(PowerWeChat 示例) | +| [商家转账](商家转账.md) | PowerWeChat RequestTransferBills 调用示例 | + +--- + +## 四、检查与诊断 + +| 文档 | 说明 | +|------|------| +| [代码逻辑和数据库最终检查清单](代码逻辑和数据库最终检查清单.md) | 上线前检查项 | +| [佣金计算逻辑检查](佣金计算逻辑检查.md) | 佣金逻辑校验 | +| [佣金问题-快速诊断和修复](佣金问题-快速诊断和修复.md) | 佣金问题排查 | diff --git a/开发文档/8、部署/阅读页标准流程改造说明.md b/开发文档/8、部署/阅读页标准流程改造说明.md new file mode 100644 index 00000000..992ad6c4 --- /dev/null +++ b/开发文档/8、部署/阅读页标准流程改造说明.md @@ -0,0 +1,395 @@ +# 阅读页标准流程改造说明 + +> 完成时间:2026-02-04 +> 改造范围:`miniprogram/pages/read/read.js` 和 `read.wxml` + +--- + +## 一、改造概述 + +按照《章节阅读付费标准流程设计》,将阅读页重构为标准流程版本,引入状态机和工具类,规避现有 bug,支持阅读进度追踪。 + +### 核心改动 +1. **引入工具类**:`chapterAccessManager`(权限管理)+ `readingTracker`(阅读追踪) +2. **状态机管理**:用 `accessState` 枚举替代 `canAccess` 布尔值 +3. **标准流程**:统一 `onLoad`、`onLoginSuccess`、`onPaymentSuccess` 的处理逻辑 +4. **阅读追踪**:自动记录进度、时长、是否读完,支持断点续读 +5. **异常处理**:统一保守策略,网络异常时展示重试按钮,不误解锁 + +--- + +## 二、文件变更清单 + +### 已修改文件 +- ✅ `miniprogram/pages/read/read.js` - 核心逻辑重构(已备份为 `read.js.backup`) +- ✅ `miniprogram/pages/read/read.wxml` - UI 模板适配新状态 + +### 新增工具类(已创建) +- ✅ `miniprogram/utils/chapterAccessManager.js` - 权限管理器 +- ✅ `miniprogram/utils/readingTracker.js` - 阅读追踪器 + +### 新增接口(已创建) +- ✅ `app/api/user/reading-progress/route.ts` - 进度上报接口 + +### 新增数据表(已创建) +- ✅ `reading_progress` - 阅读进度表(已通过 Python 脚本创建) + +--- + +## 三、核心改动详解 + +### 1. 状态机设计(accessState) + +**旧代码**:用布尔值 `canAccess` 判断权限,状态不清晰 +```javascript +// ❌ 旧代码 +canAccess: false // 无法区分"未登录"还是"未购买" +``` + +**新代码**:用枚举 `accessState` 明确所有状态 +```javascript +// ✅ 新代码 +accessState: 'unknown' | 'free' | 'locked_not_login' | 'locked_not_purchased' | 'unlocked_purchased' | 'error' +``` + +| 状态 | 含义 | UI 展示 | +|------|------|---------| +| `unknown` | 加载中 | loading 骨架屏 | +| `free` | 免费章节 | 全文 + 阅读追踪 | +| `locked_not_login` | 未登录 | 预览 + 登录按钮 | +| `locked_not_purchased` | 未购买 | 预览 + 购买按钮 | +| `unlocked_purchased` | 已购买 | 全文 + 阅读追踪 | +| `error` | 网络异常 | 预览 + 重试按钮 | + +### 2. onLoad 标准流程 + +**旧代码**:权限判断分散在 `initSection` 中,混杂内容加载 +```javascript +// ❌ 旧代码 +async onLoad(options) { + const run = async () => { + await this.loadFreeChaptersConfig() + this.initSection(id) // 权限判断 + 内容加载混在一起 + } + run() +} +``` + +**新代码**:流程清晰,职责分离 +```javascript +// ✅ 新代码 +async onLoad(options) { + // 1. 拉取最新配置 + const config = await accessManager.fetchLatestConfig() + + // 2. 确定权限状态 + const accessState = await accessManager.determineAccessState(id, config.freeChapters) + + // 3. 加载内容 + await this.loadContent(id, accessState) + + // 4. 如果有权限,初始化阅读追踪 + if (canAccess) { + readingTracker.init(id) + } + + // 5. 加载导航 + this.loadNavigation(id) +} +``` + +### 3. 登录成功标准流程 + +**旧代码**:复杂的 `recheckCurrentSectionAndRefresh`,多次请求 +```javascript +// ❌ 旧代码 +async handleWechatLogin() { + await this.refreshPurchaseFromServer() // 请求1 + await this.recheckCurrentSectionAndRefresh() // 内部又请求 check-purchased(请求2) + await this.initSection(sectionId) // 又重复一次权限判断(请求3) +} +``` + +**新代码**:统一 `onLoginSuccess`,流程简洁 +```javascript +// ✅ 新代码 +async handleWechatLogin() { + const result = await app.login() + if (result) { + await this.onLoginSuccess() // 标准流程 + } +} + +async onLoginSuccess() { + // 1. 刷新购买状态 + await accessManager.refreshUserPurchaseStatus() + + // 2. 重新拉取免费列表 + const config = await accessManager.fetchLatestConfig() + + // 3. 重新判断权限(1次请求) + const newAccessState = await accessManager.determineAccessState(sectionId, config.freeChapters) + + // 4. 如果已解锁,重新加载并追踪 + if (canAccess) { + await this.loadContent(sectionId, newAccessState) + readingTracker.init(sectionId) + } +} +``` + +### 4. 支付成功标准流程 + +**旧代码**:直接调用 `refreshUserPurchaseStatus` + `initSection` +```javascript +// ❌ 旧代码 +await this.callWechatPay(paymentData) +await this.refreshUserPurchaseStatus() +this.initSection(this.data.sectionId) +``` + +**新代码**:统一 `onPaymentSuccess`,包含重试机制 +```javascript +// ✅ 新代码 +await this.callWechatPay(paymentData) +await this.onPaymentSuccess() + +async onPaymentSuccess() { + await this.sleep(2000) // 等待回调 + await accessManager.refreshUserPurchaseStatus() + + let newAccessState = await accessManager.determineAccessState(...) + + // 如果权限未生效,再重试一次 + if (newAccessState !== 'unlocked_purchased') { + await this.sleep(1000) + newAccessState = await accessManager.determineAccessState(...) + } + + await this.loadContent(sectionId, newAccessState) + readingTracker.init(sectionId) +} +``` + +### 5. 阅读进度追踪 + +**旧代码**:只有进度条显示,无追踪 +```javascript +// ❌ 旧代码 +onPageScroll(e) { + // 只计算进度条显示,不记录阅读状态 + this.setData({ readingProgress: progress }) +} +``` + +**新代码**:集成 `readingTracker`,自动追踪 +```javascript +// ✅ 新代码 +onPageScroll(e) { + // 只在有权限时追踪 + if (!accessManager.canAccessFullContent(this.data.accessState)) { + return + } + + const scrollInfo = { scrollTop, scrollHeight, clientHeight } + + // 更新 UI 进度条 + this.setData({ readingProgress: progress }) + + // 更新追踪器(记录最大进度、判断是否读完) + readingTracker.updateProgress(scrollInfo) +} + +// 页面隐藏时上报进度 +onHide() { + readingTracker.onPageHide() +} + +// 页面卸载时清理 +onUnload() { + readingTracker.cleanup() +} +``` + +### 6. 异常处理统一 + +**旧代码**:异常时用本地缓存,可能误解锁 +```javascript +// ❌ 旧代码 +catch (e) { + canAccess = hasFullBook || purchasedSections.includes(id) // 危险:信任本地缓存 +} +``` + +**新代码**:异常时保守处理,展示 error 状态 +```javascript +// ✅ 新代码 +catch (e) { + return 'error' // 保守策略:无法确认权限时返回错误状态 +} + +// UI 上展示重试按钮 + + + ⚠️ + 网络异常 + + + +``` + +--- + +## 四、WXML 模板改动 + +### 旧模板:基于 canAccess 布尔值 +```xml + +全文 + + + + + +``` + +### 新模板:基于 accessState 枚举 +```xml + +骨架屏 + + + 全文 + 导航 + + + + 预览 + 登录按钮 + + + + 预览 + 购买按钮 + + + + 预览 + 重试按钮 + +``` + +--- + +## 五、测试验证 + +### 必测场景 +1. **免费章节** + - ✅ 进入后直接展示全文 + - ✅ 滚动时追踪进度(检查 `reading_progress` 表) + - ✅ 读到 90% 停留 3 秒后标记为 completed + +2. **未登录打开付费章** + - ✅ 展示预览(20%)+ 登录按钮 + - ✅ 点登录 → 登录成功 → 重新判断权限 + - ✅ 若已购买则解锁,否则显示购买按钮 + +3. **已登录未购买** + - ✅ 展示预览 + 购买按钮 + - ✅ 点购买 → 支付成功 → 解锁全文 + - ✅ 解锁后初始化阅读追踪 + +4. **支付成功** + - ✅ 等待 2 秒后刷新权限 + - ✅ 若未生效则再重试 1 次 + - ✅ 解锁后展示全文并追踪 + +5. **网络异常** + - ✅ 显示 error 状态 + 重试按钮 + - ✅ 点重试重新判断权限 + - ✅ 不误解锁内容 + +6. **断点续读** + - ✅ 退出后重新进入,恢复到上次阅读位置 + - ✅ Toast 提示"继续阅读 (75%)" + +7. **极端情况:登录后当前章节刚改免费** + - ✅ 登录时重新拉取免费列表 + - ✅ 若已免费则直接解锁 + +--- + +## 六、数据验证 + +### 检查 reading_progress 表 +```sql +-- 查看最近上报的进度 +SELECT * FROM reading_progress +ORDER BY last_open_at DESC +LIMIT 10; + +-- 查看完成率 +SELECT + section_id, + COUNT(*) as readers, + SUM(CASE WHEN status = 'completed' THEN 1 ELSE 0 END) as completed, + ROUND(AVG(progress), 2) as avg_progress, + ROUND(AVG(duration)/60, 1) as avg_minutes +FROM reading_progress +GROUP BY section_id; +``` + +--- + +## 七、回退方案 + +如果新版本出现问题,可快速回退: + +```bash +# 恢复旧版本 +cd miniprogram/pages/read/ +copy read.js.backup read.js + +# 重新部署小程序 +``` + +--- + +## 八、后续优化(可选) + +1. **性能优化** + - 减少登录后重复请求(当前:刷新购买状态 + check-purchased,可合并为一次) + - 阅读追踪节流优化(当前 500ms,可调整) + +2. **用户体验** + - 断点续读时平滑滚动 + - 读完后推荐下一章 + +3. **数据分析** + - 接入微信小程序数据助手 + - 配置完成率、时长等看板 + +--- + +## 九、相关文档 + +- 📖 设计文档:`开发文档/8、部署/章节阅读付费标准流程设计.md` +- 📖 集成示例:`开发文档/8、部署/章节阅读页集成示例.md` +- 📖 阅读逻辑分析:`开发文档/8、部署/阅读逻辑分析.md` + +--- + +## 十、总结 + +### 改造效果 +- ✅ **权限判断统一**:所有权限由 `accessManager` 统一管理,以服务端为准 +- ✅ **状态流转清晰**:6 种状态枚举,UI 与状态一一对应 +- ✅ **异常降级标准**:网络异常时保守处理,展示重试,不误解锁 +- ✅ **阅读追踪完整**:记录进度、时长、是否读完,支持断点续读 +- ✅ **bug 规避**:解决"登录后误解锁"、"支付后权限未生效"等问题 + +### 预期收益 +- 📉 **bug 减少 80%+**(权限判断统一、异常处理标准化) +- 📈 **数据驱动决策**(完成率、时长、活跃度分析) +- 🎯 **用户体验提升**(断点续读、明确的状态反馈、流畅的流程) +- 🔧 **可维护性提升**(代码结构清晰、职责分离、工具类复用) + +改造完成,可正式测试和部署! diff --git a/开发文档/9、手册/使用手册提示词.md b/开发文档/9、手册/使用手册提示词.md new file mode 100644 index 00000000..277059a4 --- /dev/null +++ b/开发文档/9、手册/使用手册提示词.md @@ -0,0 +1,48 @@ +# 使用手册提示词 (User Manual Prompt) - 智能自生长文档 + +> **提示词功能 (Prompt Function)**: 将本文件拖入 AI 对话框,即可激活“技术文档专家”角色,生成小白也能看懂的操作手册。 + +## 1. 基础上下文 (The Two Basic Files) +### 1.1 角色档案:卡若 (Karuo) +- **受众**:小白用户、合作方老板。 +- **风格**:大白话、傻瓜式、图文并茂。 + +### 1.2 文档原则 +- **价值先行**:先说能赚多少钱,再说怎么操作。 +- **步骤清晰**:Step 1, 2, 3。 + +## 2. 手册核心 (Master Content) +### 2.1 功能介绍 (Value) +- **话术**:不要说“分布式”,要说“账目自动同步,谁也改不了”。 +- **核心**:帮你自动分钱的工具。 + +### 2.2 快速上手 (How-to) +- **Step 1**: 登录与绑定 (截图)。 +- **Step 2**: 开启流量池 (核心操作)。 +- **Step 3**: 提现与分润 (钱)。 + +### 2.3 常见问题 (Q&A) +- **痛点**:如果不显示收益怎么办? +- **解法**:点击刷新,检查网络。 + +## 3. AI 协作指令 (Expanded Function) +**角色**:你是我(卡若)的内容运营。 +**任务**: +1. **文档撰写**:根据功能描述,写出“傻瓜式”操作手册。 +2. **话术优化**:将技术术语翻译成“老板听得懂的话”。 +3. **用户旅程**:用 Mermaid 展示用户操作流程。 + +### 示例 Mermaid (用户旅程) +\`\`\`mermaid +journey + title 合作方使用流程 + section 注册 + 打开小程序: 5: 合作方 + 手机号登录: 4: 合作方 + section 赚钱 + 开启流量池: 5: 合作方 + 查看今日收益: 5: 合作方 + section 提现 + 申请提现: 4: 合作方 + 到账: 5: 合作方 +\`\`\` diff --git a/开发文档/9、手册/全站捆绑分销体系-SCALE.md b/开发文档/9、手册/全站捆绑分销体系-SCALE.md new file mode 100644 index 00000000..cc792c1a --- /dev/null +++ b/开发文档/9、手册/全站捆绑分销体系-SCALE.md @@ -0,0 +1,157 @@ +# 全站捆绑分销体系 · SCALE(可复用规格) + +> **版本**:1.0 +> **来源**:一场soul的创业实验-永平 实战提炼 +> **用途**:作为全站消费捆绑 + 分销机制的可复用规格,可套用到其他网站、小程序、付费内容项目 + +--- + +## 一、核心理念 + +**全站捆绑** = 用户通过谁的分享链接进入,即与谁建立 30 天有效期的「推荐关系」,该关系覆盖全站所有消费(章节、全书、找伙伴、会员等)。 + +**分销体系** = 被推荐人支付成功 → 推荐人获得佣金(默认 90%)→ 支持提现。 + +--- + +## 二、核心规则(30 天捆绑) + +| 规则 | 说明 | +|:---|:---| +| **动态绑定** | 用户 B 点击谁的分享链接,立即绑定谁(无条件切换) | +| **佣金归属** | B 购买时,佣金给当前推荐人(最新绑定的那个人) | +| **30 天有效期** | 绑定日起 30 天内有效,可续期(同一推荐人再次点击则刷新 30 天) | +| **自动解绑** | 绑定 30 天内,若 B 既没点击其他链接,也没有任何购买 → 自动解绑 | + +### 时间线示例 + +``` +Day 0: A 推荐 B → B 注册 → B 绑定 A(30 天有效期) +Day 5: B 点击 C 的链接 → B 立即切换绑定 C(重新开始 30 天有效期) +Day 10: B 购买 → 佣金给 C(当前推荐人) +Day 35: 绑定 C 的 30 天到期,若期间无购买 → 自动解绑 +``` + +--- + +## 三、数据库设计(最小可复用) + +### 3.1 referral_bindings(推荐绑定表) + +| 字段 | 类型 | 说明 | +|------|------|------| +| id | VARCHAR(64) | 主键 | +| referee_id | VARCHAR(64) | 被推荐人(买家) | +| referrer_id | VARCHAR(64) | 推荐人(拿佣金的人) | +| referral_code | VARCHAR(20) | 推荐码 | +| status | ENUM | active / cancelled / expired | +| binding_date | TIMESTAMP | 最后一次绑定时间 | +| expiry_date | DATETIME | 过期时间(30 天后) | +| last_purchase_date | DATETIME | 最后一次购买时间 | +| purchase_count | INT | 购买次数 | +| total_commission | DECIMAL(10,2) | 累计佣金 | + +### 3.2 users(需扩展字段) + +| 字段 | 说明 | +|------|------| +| referral_code | 自己的邀请码 | +| referred_by | 可选,首次推荐人 | +| pending_earnings | 待结算佣金 | +| earnings | 已结算佣金 | + +### 3.3 orders(需扩展字段) + +| 字段 | 说明 | +|------|------| +| referrer_id | 下单时的推荐人 user_id | +| referral_code | 下单时使用的邀请码(对账/展示) | + +### 3.4 system_config(配置) + +- `config_key = 'referral_config'` +- `distributorShare`:推广者分成比例(默认 90) +- `bindingDays`:绑定有效期天数(默认 30) +- `minWithdrawAmount`:最小提现金额(默认 10 元) + +--- + +## 四、API 逻辑(关键接口) + +### 4.1 绑定接口 `POST /api/referral/bind` + +- **入参**:userId(被推荐人), referralCode +- **逻辑**: + - 同一推荐人 → 续期(刷新 30 天) + - 不同推荐人 → 旧绑定 status=cancelled,新绑定 active,expiry=NOW+30 天 + +### 4.2 下单时定推荐人(创建订单前) + +1. 先查 `referral_bindings`(referee_id=买家,status=active,expiry_date>NOW) +2. 无绑定则用请求体 `referralCode` 查 users 得 referrer_id +3. 写入 `orders.referrer_id`、`orders.referral_code` + +### 4.3 支付成功回调(分佣) + +1. 查 `referral_bindings`(referee_id=买家,status=active) +2. 取 referrer_id,佣金 = 订单金额 × distributorShare / 100 +3. 更新 `referral_bindings`:purchase_count++,total_commission+=佣金,last_purchase_date=NOW +4. 更新 `users`:referrer 的 pending_earnings += 佣金 +5. **不**将 binding 改为 converted,保持 active,允许多次购买分佣 + +### 4.4 自动解绑定时任务(每天 02:00) + +```sql +UPDATE referral_bindings +SET status = 'expired' +WHERE status = 'active' + AND expiry_date < NOW() + AND purchase_count = 0 +``` + +--- + +## 五、概念区分(避免混乱) + +| 概念 | 含义 | 存储 | 用途 | +|------|------|------|------| +| **邀请码** | 一串码,如 SOULABC123 | users.referral_code | 链接 ref=邀请码,解析出推荐人 | +| **推荐人** | 拿佣金的人 | referrer_id(用户ID) | 分佣、订单归属、统计 | +| **绑定表** | 权威的「谁推荐了谁」 | referral_bindings | 分佣只看此表 | + +**优先级**:绑定表 > 邀请码兜底。订单 referrer_id 只做展示/对账,不参与分佣计算。 + +--- + +## 六、提现流程(配套) + +- 用户:可提现 = 累计佣金 − 已提现 − 待审核 +- 申请:POST /api/miniprogram/withdraw → status=pending +- 管理端:通过 → 调微信商家转账 → status=processing +- 微信回调:成功 → status=success;失败 → status=failed + +--- + +## 七、复用 checklist(套用到新项目) + +- [ ] 建表:referral_bindings、users 扩展、orders 扩展、withdrawals +- [ ] 配置:referral_config(分成比例、绑定天数、最低提现) +- [ ] 绑定接口:/api/referral/bind(动态切换 + 30 天) +- [ ] 下单逻辑:写 orders.referrer_id、referral_code +- [ ] 支付回调:查绑定 → 分佣 → 累加 purchase_count +- [ ] 定时任务:每天解绑 purchase_count=0 且过期的记录 +- [ ] 前端:分享链接带 ref=邀请码,登录后调 bind +- [ ] 提现:用户申请 → 管理审核 → 微信打款 + +--- + +## 八、相关文档(本项目内) + +- [新分销逻辑设计方案](../8、部署/新分销逻辑设计方案.md) +- [邀请码分销规则说明](../8、部署/邀请码分销规则说明.md) +- [分销与绑定流程图](../8、部署/分销与绑定流程图.md) +- [分销提现流程图](../8、部署/分销提现流程图.md) + +--- + +*本 SCALE 可供任何有「全站消费 + 分销」需求的网站/小程序复用。* diff --git a/开发文档/9、手册/写作与结构维护手册.md b/开发文档/9、手册/写作与结构维护手册.md new file mode 100644 index 00000000..2e096fdc --- /dev/null +++ b/开发文档/9、手册/写作与结构维护手册.md @@ -0,0 +1,43 @@ +# 写作与结构维护手册(Mycontent-book) + +## 1. 你改文档,我怎么理解 + +你只要改这三类文件,我就能按规则做事: + +- `external/Mycontent-book/book/**/*.md`:正文内容 +- `external/Mycontent-book/1、soul 全部.txt`:素材源(不要随便改结构) +- `external/1、开发模板/**`:需求、架构、部署的“标准答案” + +## 2. 章节怎么放(目录就是结构) + +- “篇”是一级目录 +- “章”是二级目录 +- “小节”是 `.md` 文件 + +原则:尽量新增,不要频繁移动旧文件。 + +## 3. 写作动作建议(减少冲突、减少噪音) + +- 一次改一篇/一章,写完再切下一个 +- 同一小节尽量集中修改,不要碎片化改一堆次 + +## 4. 事实与数据怎么处理 + +- 数值、时间、对话:以素材文件里的原文为准 +- 不确定就不写死,先把“素材引用段落”留在文档里 + +## 5. 自动同步的最佳姿势 + +- 开始写作前启动:`./scripts/autosync.sh` +- 写作时正常保存即可 +- 停止同步:`Ctrl+C` + +## 6. 你想改规则怎么改 + +你直接改开发模板里的对应文档: + +- 要改目标/范围:改 `1、需求/业务需求.md` +- 要改结构/同步策略:改 `2、架构/系统架构.md` 或 `8、部署/自动同步与分支策略.md` +- 要改跑站点方式:改 `8、部署/本地运行.md` + +我会按你最新文档执行。 diff --git a/开发文档/9、手册/手册索引.md b/开发文档/9、手册/手册索引.md new file mode 100644 index 00000000..717a60d1 --- /dev/null +++ b/开发文档/9、手册/手册索引.md @@ -0,0 +1,25 @@ +# 手册与提示词索引 + +> 本目录下所有手册与 AI 提示词统一入口。 + +--- + +## 手册 + +| 文件 | 说明 | +|:---|:---| +| [写作与结构维护手册](./写作与结构维护手册.md) | 书籍写作与结构维护规范 | +| [全站捆绑分销体系-SCALE](./全站捆绑分销体系-SCALE.md) | 30天捆绑+分销可复用规格,可套用到其他网站/小程序 | + +## 提示词(AI 协作) + +| 文件 | 说明 | +|:---|:---| +| [提示词/使用手册提示词](./提示词/使用手册提示词.md) | 文档生成工具(截图、Word 导出) | +| [提示词/落地方案提示词](./提示词/落地方案提示词.md) | 复盘、营销文章、卡若风格输出 | +| [提示词/说明手册提示词](./提示词/说明手册提示词.md) | 系统说明、架构、接口、配置文档 | +| [使用手册提示词](./使用手册提示词.md) | 小白操作手册(技术文档专家角色) | + +--- + +**使用**:将对应 .md 文件拖入 AI 对话框,即可激活对应模板或角色。 diff --git a/开发文档/9、手册/提示词/使用手册提示词.md b/开发文档/9、手册/提示词/使用手册提示词.md new file mode 100644 index 00000000..0a581bbc --- /dev/null +++ b/开发文档/9、手册/提示词/使用手册提示词.md @@ -0,0 +1,13 @@ +在这个应用程序中开发一个实用工具,目录名称为“/documentation”,只能用地址访问不要放到可以点击的地方,用于自动生成一套全面的文档集。 + +该工具应能捕捉应用程序所有界面的屏幕截图,在文档生成器中使用iframe方式,保证每个页面加载成功的情况下,实现真实的截图功能,而不是使用占位图。 + +系统应自动整理这些截图,将其与文档的相关部分关联起来。然后,该工具应将这些截图和相关文本汇编成一个可导出的Word文档(.docx)。 + +Word文档应包含目录、与应用程序功能相对应的清晰标题和副标题,以及每张截图的说明文字。 + +确保导出过程简化为一键生成,最大限度减少人工干预。 + +生成的文档应反映所提供示例的结构和内容,融入应用程序的特定功能和特性。处理截图捕获或文档生成过程中的任何潜在错误,以确保准确性和完整性。 + +最终输出应为适合分发给利益相关者和用户的专业质量文档。 diff --git a/开发文档/9、手册/提示词/落地方案提示词.md b/开发文档/9、手册/提示词/落地方案提示词.md new file mode 100644 index 00000000..b0bbd29e --- /dev/null +++ b/开发文档/9、手册/提示词/落地方案提示词.md @@ -0,0 +1,32 @@ +# 落地方案提示词 + +> 用于记录「把需求落到代码/流程」的提示词。拖入 AI 即可按固定模板输出。 + +--- + +## 输出格式要求 + +### 1. 复盘示例 + +```markdown +[私域云阿米巴模式落地复盘](2025年Q2) +**目标&结果**:目标3个月内绑定15家合作方,实际完成18家(超20%)。 +**过程**:5月启动流量测试...;6月上线私域系统...;7月现金分润验证... +**反思**:... +**总结**:... +**执行**:... +``` + +### 2. 营销文章结构 + +- **I(兴趣)**:自问自答引发共鸣。 +- **S(故事/案例)**:真实经历描述。 +- **S(干货)**:可落地的步骤+数据。 +- **M(产品/概念)**:核心模式与优势。 +- **F(裂变)**:行动号召。 + +### 3. 卡若风格文章要求 + +- **结构**:自问自答 → 故事/反思(含数据)→ 行动指引。 +- **语言**:简洁直接,挑战传统。 +- **字数**:不低于 2000 字,数据需有据可查。 diff --git a/开发文档/9、手册/提示词/说明手册提示词.md b/开发文档/9、手册/提示词/说明手册提示词.md new file mode 100644 index 00000000..260f4031 --- /dev/null +++ b/开发文档/9、手册/提示词/说明手册提示词.md @@ -0,0 +1,38 @@ +# 说明手册提示词 + +> 用于记录「对外说明/交付手册」的提示词。面向内部开发、运维、系统管理员。 + +--- + +## 核心原则 + +- **对象**:内部开发、运维、系统管理员。 +- **风格**:专业、严谨、逻辑缜密。 +- **口吻**:客观描述,无情绪色彩。 + +## 内容结构 + +### 1. 系统概述 + +- 系统定位、核心能力、适用场景。 + +### 2. 架构说明 + +- **技术栈**:具体版本(如 React 18, Java 17)。 +- **架构图**:引用开发文档中的架构图。 +- **目录结构**:核心目录作用。 + +### 3. 接口与数据 + +- **API 规范**:RESTful,统一响应格式。 +- **数据字典**:核心表/集合字段与类型。 + +### 4. 配置与环境 + +- **环境变量**:必配 ENV 及含义。 +- **外部依赖**:Redis、第三方 API 等配置要求。 + +## 格式要求 + +- **代码块**:命令、配置、JSON 示例用 Markdown 代码块。 +- **表格**:参数说明、状态码用表格。 diff --git a/开发文档/README.md b/开发文档/README.md index ffedcebe..9e4e46b1 100644 --- a/开发文档/README.md +++ b/开发文档/README.md @@ -19,7 +19,6 @@ | 文档 | 说明 | |------|------| -| [1、需求/以界面定需求](1、需求/以界面定需求.md) | **界面级需求基准**:以界面定需求,小程序与管理端界面清单、主要接口、业务逻辑对齐(三端路由、VIP 资料以用户资料为准等) | | [1、需求/需求汇总](1、需求/需求汇总.md) | 需求清单、业务需求 | | [10、项目管理/项目落地推进表](10、项目管理/项目落地推进表.md) | 里程碑、永平落地 | | [10、项目管理/运营与变更](10、项目管理/运营与变更.md) | 近期讨论、变更记录 | @@ -71,8 +70,3 @@ - `SKILL.md`(根目录)— 技术栈已过期(写的是 Next.js),以 README 与 .cursor/skills 为准 - `小程序管理/scripts/__pycache__/*.pyc` — Python 缓存 - `小程序管理/scripts/reports/*.json`(4 份)— 脚本生成的一次性报告 - -## 已移除文件(2026-03-10 橙子清理) - -- `api_v1.md` — 存客宝对外获客 API 文档,项目已明确搁置对接,文档无继续维护价值 -- `小程序功能与管理端配置补齐分析.md` — 2026-02-25 一次性补齐分析,全部项目已标注 ✅ 已完成,分析目的达成 diff --git a/开发文档/SKILL.md b/开发文档/SKILL.md new file mode 100644 index 00000000..5a69fb92 --- /dev/null +++ b/开发文档/SKILL.md @@ -0,0 +1,84 @@ +# Soul创业派对 - 项目开发SKILL + +## 项目概述 + +| 项目 | 值 | +|------|-----| +| 项目名 | Soul创业派对(一场Soul的创业实验) | +| 小程序AppID | wxb8bbb2b10dec74aa | +| 后端地址 | https://soul.quwanzhi.com | +| 技术栈(前端) | 微信小程序原生 + 自定义TabBar | +| 技术栈(后端) | Next.js App Router + MySQL | +| 数据库 | 腾讯云MySQL | +| 仓库 | github.com/fnvtk/Mycontent (yongpxu-soul分支) | + +## 开发文档目录索引 + +``` +开发文档/ +├── 1、需求/ ← 需求文档、需求日志、TDD方案 +├── 2、架构/ ← 系统架构、技术选型、链路说明 +├── 3、原型/ ← 原型设计 +├── 4、前端/ ← 前端架构、UI截图 +├── 5、接口/ ← API接口文档、接口定义规范 +├── 6、后端/ ← 后端架构、修复说明 +├── 7、数据库/ ← 数据库设计、管理规范 +├── 8、部署/ ← 部署流程、宝塔配置、小程序上传 +├── 9、手册/ ← 使用手册、写作手册 +├── 10、项目管理/ ← 项目总览、运营报表、会议记录 +├── 小程序管理/ ← 小程序生命周期SKILL(独立) +└── 服务器管理/ ← 服务器运维SKILL(独立) +``` + +## 需求日志管理规范 + +- 每次对话的需求自动追加到 `1、需求/需求日志.md` +- 格式:`| 日期 | 需求描述 | 状态 | 备注 |` +- 状态:待开发 / 开发中 / 已完成 / 已取消 +- 每个版本上传后,将该批需求标记为「已完成」 + +## 常用命令 + +### 上传小程序 +```bash +/Applications/wechatwebdevtools.app/Contents/MacOS/cli upload \ + --project "/Users/karuo/Documents/开发/3、自营项目/一场soul的创业实验/miniprogram" \ + --version "版本号" --desc "版本说明" +``` + +### 从GitHub同步miniprogram +```bash +cd /tmp && rm -rf Mycontent_soul_tmp +git clone --depth 1 --branch yongpxu-soul https://github.com/fnvtk/Mycontent.git Mycontent_soul_tmp +rsync -av --delete Mycontent_soul_tmp/miniprogram/ "/Users/karuo/Documents/开发/3、自营项目/一场soul的创业实验/miniprogram/" +rm -rf Mycontent_soul_tmp +``` + +### 数据库迁移 +```bash +curl -X POST https://soul.quwanzhi.com/api/db/migrate -H 'Content-Type: application/json' -d '{}' +``` + +## 核心页面结构 + +| 页面 | 路径 | 说明 | +|------|------|------| +| 首页 | pages/index/index | 精选推荐(阅读量)、创业老板排行 | +| 目录 | pages/chapters/chapters | 章节列表 | +| 找伙伴 | pages/match/match | 匹配动画 | +| 我的 | pages/my/my | 用户信息、收益、VIP、账号设置 | +| 阅读 | pages/read/read | 章节内容、付费墙 | +| VIP | pages/vip/vip | VIP权益、购买、资料填写 | +| 会员详情 | pages/member-detail/member-detail | 创业老板排行点击详情 | + +## 后端API模块 + +| 模块 | 路径前缀 | 说明 | +|------|---------|------| +| VIP会员 | /api/vip/ | purchase、status、profile、members | +| 书籍 | /api/book/ | chapters、hot、latest-chapters、search | +| 用户 | /api/user/ | profile、update、track | +| 支付 | /api/miniprogram/pay | 微信小程序支付 | +| 推广 | /api/referral/ | bind、data、visit | +| 提现 | /api/withdraw | 提现到微信零钱 | +| 管理后台 | /api/admin/ | content、chapters、payment等 | diff --git a/开发文档/api_v1.md b/开发文档/api_v1.md new file mode 100644 index 00000000..7a1c2636 --- /dev/null +++ b/开发文档/api_v1.md @@ -0,0 +1,413 @@ +# 对外获客线索上报接口文档(V1) + +## 一、接口概述 + +- **接口名称**:对外获客线索上报接口 +- **接口用途**:供第三方系统向【存客宝】上报客户线索(手机号 / 微信号等),用于后续的跟进、标签管理和画像分析。 +- **接口协议**:HTTP +- **请求方式**:`POST` +- **请求地址**: `https://ckbapi.quwanzhi.com/v1/api/scenarios` + +> 具体 URL 以实际环境配置为准。 + +- **数据格式**: + - 推荐:`application/json` + - 兼容:`application/x-www-form-urlencoded` +- **字符编码**:`UTF-8` + +--- + +## 二、鉴权与签名 + +### 2.1 必填鉴权字段 + +| 字段名 | 类型 | 必填 | 说明 | +|-------------|--------|------|---------------------------------------| +| `apiKey` | string | 是 | 分配给第三方的接口密钥(每个任务唯一)| +| `sign` | string | 是 | 签名值 | +| `timestamp` | int | 是 | 秒级时间戳(与服务器时间差不超过 5 分钟) | + +### 2.2 时间戳校验 + +服务器会校验 `timestamp` 是否在当前时间前后 **5 分钟** 内: + +- 通过条件:`|server_time - timestamp| <= 300` +- 超出范围则返回:`请求已过期` + +### 2.3 签名生成规则 + +接口采用自定义签名机制。**签名字段为 `sign`,生成步骤如下:** + +假设本次请求的所有参数为 `params`,其中包括业务参数 + `apiKey` + `timestamp` + `sign` + 可能存在的 `portrait` 对象。 + +#### 第一步:移除特定字段 + +从 `params` 中移除以下字段: + +- `sign` —— 自身不参与签名 +- `apiKey` —— 不参与参数拼接,仅在最后一步参与二次 MD5 +- `portrait` —— 整个画像对象不参与签名(即使内部还有子字段) + +> 说明:`portrait` 通常是一个 JSON 对象,字段较多,为避免签名实现复杂且双方难以对齐,统一不参与签名。 + +#### 第二步:移除空值字段 + +从剩余参数中,移除值为: + +- `null` +- 空字符串 `''` + +的字段,这些字段不参与签名。 + +#### 第三步:按参数名升序排序 + +对剩余参数按**参数名(键名)升序排序**,排序规则为标准的 ASCII 升序: + +```text +例如: name, phone, source, timestamp +``` + +#### 第四步:拼接参数值 + +将排序后的参数 **只取“值”**,按顺序直接拼接为一个字符串,中间不加任何分隔符: + +- 示例: + 排序后参数为: + + ```text + name = 张三 + phone = 13800000000 + source = 微信广告 + timestamp = 1710000000 + ``` + + 则拼接: + + ```text + stringToSign = "张三13800000000微信广告1710000000" + ``` + +#### 第五步:第一次 MD5 + +对上一步拼接得到的字符串做一次 MD5: + +\[ +\text{firstMd5} = \text{MD5}(\text{stringToSign}) +\] + +#### 第六步:拼接 apiKey 再次 MD5 + +将第一步的结果与 `apiKey` 直接拼接,再做一次 MD5,得到最终签名值: + +\[ +\text{sign} = \text{MD5}(\text{firstMd5} + \text{apiKey}) +\] + +#### 第七步:放入请求 + +将第六步得到的 `sign` 填入请求参数中的 `sign` 字段即可。 + +> 建议: +> - 使用小写 MD5 字符串(双方约定统一即可)。 +> - 请确保参与签名的参数与最终请求发送的参数一致(包括是否传空值)。 + +### 2.4 签名示例(PHP 伪代码) + +```php +$params = [ + 'apiKey' => 'YOUR_API_KEY', + 'timestamp' => '1710000000', + 'phone' => '13800000000', + 'name' => '张三', + 'source' => '微信广告', + 'remark' => '通过H5落地页留资', + // 'portrait' => [...], // 如有画像,这里会存在,但不参与签名 + // 'sign' => '待生成', +]; + +// 1. 去掉 sign、apiKey、portrait +unset($params['sign'], $params['apiKey'], $params['portrait']); + +// 2. 去掉空值 +$params = array_filter($params, function($value) { + return !is_null($value) && $value !== ''; +}); + +// 3. 按键名升序排序 +ksort($params); + +// 4. 拼接参数值 +$stringToSign = implode('', array_values($params)); + +// 5. 第一次 MD5 +$firstMd5 = md5($stringToSign); + +// 6. 第二次 MD5(拼接 apiKey) +$apiKey = 'YOUR_API_KEY'; +$sign = md5($firstMd5 . $apiKey); + +// 将 $sign 作为字段发送 +$params['sign'] = $sign; +``` + +--- + +## 三、请求参数说明 + +### 3.1 主标识字段(至少传一个) + +| 字段名 | 类型 | 必填 | 说明 | +|-----------|--------|------|-------------------------------------------| +| `wechatId`| string | 否 | 微信号,存在时优先作为主标识 | +| `phone` | string | 否 | 手机号,当 `wechatId` 为空时用作主标识 | + +### 3.2 基础信息字段 + +| 字段名 | 类型 | 必填 | 说明 | +|------------|--------|------|-------------------------| +| `name` | string | 否 | 客户姓名 | +| `source` | string | 否 | 线索来源描述,如“百度推广”、“抖音直播间” | +| `remark` | string | 否 | 备注信息 | +| `tags` | string | 否 | 逗号分隔的“微信标签”,如:`"高意向,电商,女装"` | +| `siteTags` | string | 否 | 逗号分隔的“站内标签”,用于站内进一步细分 | + + +### 3.3 用户画像字段 `portrait`(可选) + +`portrait` 为一个对象(JSON),用于记录用户的行为画像数据。 + +#### 3.3.1 基本示例 + +```json +"portrait": { + "type": 1, + "source": 1, + "sourceData": { + "age": 28, + "gender": "female", + "city": "上海", + "productId": "P12345", + "pageUrl": "https://example.com/product/123" + }, + "remark": "画像-基础属性", + "uniqueId": "user_13800000000_20250301_001" +} +``` + +#### 3.3.2 字段详细说明 + +| 字段名 | 类型 | 必填 | 说明 | +|-----------------------|--------|------|----------------------------------------| +| `portrait.type` | int | 否 | 画像类型,枚举值:
      0-浏览
      1-点击
      2-下单/购买
      3-注册
      4-互动
      默认值:0 | +| `portrait.source` | int | 否 | 画像来源,枚举值:
      0-本站
      1-老油条
      2-老坑爹
      默认值:0 | +| `portrait.sourceData` | object | 否 | 画像明细数据(键值对,会存储为 JSON 格式)
      可包含任意业务相关的键值对,如:年龄、性别、城市、商品ID、页面URL等 | +| `portrait.remark` | string | 否 | 画像备注信息,最大长度100字符 | +| `portrait.uniqueId` | string | 否 | 画像去重用唯一 ID
      用于防止重复记录,相同 `uniqueId` 的画像数据在半小时内会被合并统计(count字段累加)
      建议格式:`{来源标识}_{用户标识}_{时间戳}_{序号}` | + +#### 3.3.3 画像类型(type)说明 + +| 值 | 类型 | 说明 | 适用场景 | +|---|------|------|---------| +| 0 | 浏览 | 用户浏览了页面或内容 | 页面访问、商品浏览、文章阅读等 | +| 1 | 点击 | 用户点击了某个元素 | 按钮点击、链接点击、广告点击等 | +| 2 | 下单/购买 | 用户完成了购买行为 | 订单提交、支付完成等 | +| 3 | 注册 | 用户完成了注册 | 账号注册、会员注册等 | +| 4 | 互动 | 用户进行了互动行为 | 点赞、评论、分享、咨询等 | + +#### 3.3.4 画像来源(source)说明 + +| 值 | 来源 | 说明 | +|---|------|------| +| 0 | 本站 | 来自本站的数据 | +| 1 | 老油条 | 来自"老油条"系统的数据 | +| 2 | 老坑爹 | 来自"老坑爹"系统的数据 | + +#### 3.3.5 sourceData 数据格式说明 + +`sourceData` 是一个 JSON 对象,可以包含任意业务相关的键值对。常见字段示例: + +```json +{ + "age": 28, + "gender": "female", + "city": "上海", + "province": "上海市", + "productId": "P12345", + "productName": "商品名称", + "category": "女装", + "price": 299.00, + "pageUrl": "https://example.com/product/123", + "referrer": "https://www.baidu.com", + "device": "mobile", + "browser": "WeChat" +} +``` + +> **注意**: +> - `sourceData` 中的数据类型可以是字符串、数字、布尔值等 +> - 嵌套对象会被序列化为 JSON 字符串存储 +> - 建议根据实际业务需求定义字段结构 + +#### 3.3.6 uniqueId 去重机制说明 + +- **作用**:防止重复记录相同的画像数据 +- **规则**:相同 `uniqueId` 的画像数据在 **半小时内** 会被合并统计,`count` 字段会自动累加 +- **建议格式**:`{来源标识}_{用户标识}_{时间戳}_{序号}` + - 示例:`site_13800000000_1710000000_001` + - 示例:`wechat_wxid_abc123_1710000000_001` +- **注意事项**: + - 如果不传 `uniqueId`,系统会为每条画像数据创建新记录 + - 如果需要在半小时内多次统计同一行为,应使用相同的 `uniqueId` + - 如果需要在半小时后重新统计,应使用不同的 `uniqueId`(建议修改时间戳部分) + +> **重要提示**:`portrait` **整体不参与签名计算**,但会参与业务处理。系统会根据 `uniqueId` 自动处理去重和统计。 + +--- + +## 四、请求示例 + +### 4.1 JSON 请求示例(无画像) + +```json +{ + "apiKey": "YOUR_API_KEY", + "timestamp": 1710000000, + "phone": "13800000000", + "name": "张三", + "source": "微信广告", + "remark": "通过H5落地页留资", + "tags": "高意向,电商", + "siteTags": "新客,女装", + "sign": "根据签名规则生成的MD5字符串" +} +``` + +### 4.2 JSON 请求示例(带微信号与画像) + +```json +{ + "apiKey": "YOUR_API_KEY", + "timestamp": 1710000000, + "wechatId": "wxid_abcdefg123", + "phone": "13800000001", + "name": "李四", + "source": "小程序落地页", + "remark": "点击【立即咨询】按钮", + "tags": "中意向,直播", + "siteTags": "复购,高客单", + "portrait": { + "type": 1, + "source": 0, + "sourceData": { + "age": 28, + "gender": "female", + "city": "上海", + "pageUrl": "https://example.com/product/123", + "productId": "P12345" + }, + "remark": "画像-点击行为", + "uniqueId": "site_13800000001_1710000000_001" + }, + "sign": "根据签名规则生成的MD5字符串" +} +``` + +### 4.3 JSON 请求示例(多种画像类型) + +#### 4.3.1 浏览行为画像 + +```json +{ + "apiKey": "YOUR_API_KEY", + "timestamp": 1710000000, + "phone": "13800000002", + "name": "王五", + "source": "百度推广", + "portrait": { + "type": 0, + "source": 0, + "sourceData": { + "pageUrl": "https://example.com/product/456", + "productName": "商品名称", + "category": "女装", + "stayTime": 120, + "device": "mobile" + }, + "remark": "商品浏览", + "uniqueId": "site_13800000002_1710000000_001" + }, + "sign": "根据签名规则生成的MD5字符串" +} +``` + + +``` + +--- + +## 五、响应说明 + +### 5.1 成功响应 + +**1)新增线索成功** + +```json +{ + "code": 200, + "message": "新增成功", + "data": "13800000000" +} +``` + +**2)线索已存在** + +```json +{ + "code": 200, + "message": "已存在", + "data": "13800000000" +} +``` + +> `data` 字段返回本次线索的主标识 `wechatId` 或 `phone`。 + +### 5.2 常见错误响应 + +```json +{ "code": 400, "message": "apiKey不能为空", "data": null } +{ "code": 400, "message": "sign不能为空", "data": null } +{ "code": 400, "message": "timestamp不能为空", "data": null } +{ "code": 400, "message": "请求已过期", "data": null } + +{ "code": 401, "message": "无效的apiKey", "data": null } +{ "code": 401, "message": "签名验证失败", "data": null } + +{ "code": 500, "message": "系统错误: 具体错误信息", "data": null } +``` + +--- + + +## 六、常见问题(FAQ) + +### Q1: 如果同一个用户多次上报相同的行为,会如何处理? + +**A**: 如果使用相同的 `uniqueId`,系统会在半小时内合并统计,`count` 字段会累加。如果使用不同的 `uniqueId`,会创建多条记录。 + +### Q2: portrait 字段是否必须传递? + +**A**: 不是必须的。`portrait` 字段是可选的,只有在需要记录用户画像数据时才传递。 + +### Q3: sourceData 中可以存储哪些类型的数据? + +**A**: `sourceData` 是一个 JSON 对象,可以存储任意键值对。支持字符串、数字、布尔值等基本类型,嵌套对象会被序列化为 JSON 字符串。 + +### Q4: uniqueId 的作用是什么? + +**A**: `uniqueId` 用于防止重复记录。相同 `uniqueId` 的画像数据在半小时内会被合并统计,避免重复数据。 + +### Q5: 画像数据如何与用户关联? + +**A**: 系统会根据请求中的 `wechatId` 或 `phone` 自动匹配 `traffic_pool` 表中的用户,并将画像数据关联到对应的 `trafficPoolId`。 + +--- diff --git a/开发文档/三端需求业务对齐-小程序与API.md b/开发文档/三端需求业务对齐-小程序与API.md new file mode 100644 index 00000000..0ac9eb43 --- /dev/null +++ b/开发文档/三端需求业务对齐-小程序与API.md @@ -0,0 +1,162 @@ +# Soul 创业派对 - 三端需求业务对齐(小程序 ↔ API) + +> 供小程序、后端 API、管理端工程师需求与业务对齐使用。 +> 更新日期:2026-02-25 + +--- + +## 一、小程序功能模块总览 + +| 模块 | 页面 | 功能简述 | +|------|------|----------| +| **首页** | index | 精选推荐、最新章节、超级个体(VIP 展示)、跳转目录/搜索/找伙伴/我的 | +| **目录** | chapters | 全书目录、每日新增、跳转阅读/搜索 | +| **阅读** | read | 章节内容、权限判断、购买、分享、海报、推荐码 | +| **找伙伴** | match | 匹配配置、随机匹配、加入弹窗、购买匹配次数 | +| **我的** | my | 用户信息、收益、提现、VIP 状态、设置入口 | +| **分销中心** | referral | 绑定/访问/收益、提现、小程序码、分享 | +| **购买记录** | purchases | 当前用户订单列表 | +| **设置** | settings | 昵称/头像/手机/微信/支付宝、退出登录 | +| **地址管理** | addresses, edit | 收货地址 CRUD | +| **提现记录** | withdraw-records | 提现列表、确认收款 | +| **VIP** | vip | VIP 状态、购买、资料编辑 | +| **会员详情** | member-detail | 创业者详情(VIP/普通用户) | +| **搜索** | search | 热门、关键词搜索章节 | +| **关于** | about | 书籍统计、联系 | +| **协议** | agreement, privacy | 用户协议、隐私政策 | + +--- + +## 二、小程序 API 调用清单(按页面) + +### 2.1 已正确使用 `/api/miniprogram/*` 的接口 + +| 页面/模块 | 路径 | 方法 | 用途 | +|-----------|------|------|------| +| app | /api/miniprogram/referral/visit | POST | 推荐访问记录 | +| app | /api/miniprogram/referral/bind | POST | 推荐码绑定 | +| app | /api/miniprogram/book/all-chapters | GET | 书籍目录 | +| app | /api/miniprogram/login | POST | 微信登录 | +| app | /api/miniprogram/phone-login | POST | 手机号登录 | +| config | /api/miniprogram/config | GET | 免费章节、价格、功能开关 | +| read | /api/miniprogram/book/chapter/:id | GET | 按 id 获取章节 | +| read | /api/miniprogram/book/chapter/by-mid/:mid | GET | 按 mid 获取章节 | +| read | /api/miniprogram/user/purchase-status | GET | 购买状态 | +| read | /api/miniprogram/pay | POST | 支付下单 | +| read | /api/miniprogram/qrcode | POST | 生成小程序码 | +| index | /api/miniprogram/vip/members | GET | 超级个体列表 | +| index | /api/miniprogram/users | GET | 用户补充(limit=20) | +| index | /api/miniprogram/book/all-chapters | GET | 精选、最新 | +| chapters | /api/miniprogram/book/all-chapters | GET | 目录、每日新增 | +| search | /api/miniprogram/book/hot | GET | 热门搜索 | +| search | /api/miniprogram/book/search | GET | 关键词搜索 | +| about | /api/miniprogram/book/stats | GET | 书籍统计 | +| referral | /api/miniprogram/referral/data | GET | 分销数据 | +| referral | /api/miniprogram/qrcode | POST | 小程序码 | +| referral | /api/miniprogram/withdraw | POST | 提现申请 | +| my | /api/miniprogram/config | GET | 配置 | +| my | /api/miniprogram/withdraw/pending-confirm | GET | 待确认提现 | +| my | /api/miniprogram/earnings | GET | 收益 | +| my | /api/miniprogram/user/update | POST | 资料更新 | +| my | /api/miniprogram/vip/status | GET | VIP 状态 | +| settings | /api/miniprogram/user/profile | GET/POST | 资料 | +| settings | /api/miniprogram/user/update | POST | 更新 | +| settings | /api/miniprogram/phone | POST | 手机号 | +| addresses | /api/miniprogram/user/addresses | GET | 地址列表 | +| addresses | /api/miniprogram/user/addresses/:id | GET/PUT/DELETE | 地址 CRUD | +| addresses/edit | /api/miniprogram/user/addresses | POST | 新增地址 | +| withdraw-records | /api/miniprogram/withdraw/records | GET | 提现记录 | +| withdraw-records | /api/miniprogram/withdraw/confirm-info | GET | 确认收款信息 | +| vip | /api/miniprogram/vip/status | GET | VIP 状态 | +| vip | /api/miniprogram/vip/profile | GET/POST | VIP 资料 | +| vip | /api/miniprogram/pay | POST | VIP 购买 | +| member-detail | /api/miniprogram/vip/members | GET | 单个会员 | +| member-detail | /api/miniprogram/users | GET | 单个用户回退 | +| match | /api/miniprogram/ckb/join | POST | 加入弹窗 | +| match | /api/miniprogram/pay | POST | 购买匹配次数 | +| readingTracker | /api/miniprogram/user/reading-progress | POST | 阅读进度 | +| chapterAccessManager | /api/miniprogram/user/check-purchased | GET | 是否已购 | +| chapterAccessManager | /api/miniprogram/user/purchase-status | GET | 购买状态 | +| custom-tab-bar | /api/miniprogram/config | GET | 功能配置 | + +### 2.2 路径错误(违反边界:应改为 `/api/miniprogram/*`) + +| 页面 | 当前调用 | 正确路径 | 说明 | +|------|----------|----------|------| +| **match** | /api/match/config | /api/miniprogram/match/config | 匹配配置,soul-api 已挂 miniprogram | +| **match** | /api/match/users | /api/miniprogram/match/users | 匹配用户,soul-api 已挂 miniprogram | +| **match** | /api/ckb/match | /api/miniprogram/ckb/match | 上报匹配,soul-api 已挂 miniprogram | +| **purchases** | /api/orders?userId= | /api/miniprogram/orders?userId= | 订单列表,**需新增** miniprogram 路由 | +| **my** | /api/user/update | /api/miniprogram/user/update | 头像更新,soul-api 已挂 miniprogram | +| **my** | /api/withdraw | /api/miniprogram/withdraw | 提现申请,soul-api 已挂 miniprogram | + +--- + +## 三、后端 API 需变更项 + +### 3.1 小程序端需修正的调用(前端改) + +| 文件 | 当前 | 改为 | +|------|------|------| +| match.js | `/api/match/config` | `/api/miniprogram/match/config` | +| match.js | `/api/match/users` | `/api/miniprogram/match/users` | +| match.js | `/api/ckb/match` | `/api/miniprogram/ckb/match` | +| my.js | `/api/user/update` | `/api/miniprogram/user/update` | +| my.js | `/api/withdraw` | `/api/miniprogram/withdraw` | + +### 3.2 后端需新增/调整的接口 + +| 接口 | 变更类型 | 说明 | +|------|----------|------| +| **GET /api/miniprogram/orders** | **新增** | 购买记录页专用。当前 `/api/orders` 无 userId 过滤且返回 `orders`;小程序需 `?userId=` 过滤且期望 `data`。建议在 miniprogram 组新增 `MiniprogramOrders`:按 userId 过滤、返回 `{ success, data: [...] }`,字段含 id/order_sn、product_id、product_name、amount、status、created_at | + +### 3.3 响应格式对齐 + +| 接口 | 当前返回 | 小程序期望 | 建议 | +|------|----------|------------|------| +| /api/orders | `{ success, orders }` | `res.data` | 新增 MiniprogramOrders 返回 `{ success, data }`,与小程序一致 | + +--- + +## 四、soul-api 现有 miniprogram 路由(已挂载) + +``` +/api/miniprogram/config +/api/miniprogram/login, phone-login, phone +/api/miniprogram/pay, pay/notify +/api/miniprogram/qrcode, qrcode/image +/api/miniprogram/book/all-chapters, chapter/:id, chapter/by-mid/:mid, hot, search, stats +/api/miniprogram/referral/visit, bind, data +/api/miniprogram/earnings +/api/miniprogram/match/config +/api/miniprogram/match/users ← 注意:router 为 POST +/api/miniprogram/ckb/join +/api/miniprogram/ckb/match ← 已挂载 +/api/miniprogram/upload +/api/miniprogram/user/addresses, addresses/:id +/api/miniprogram/user/check-purchased, profile, purchase-status, reading-progress, update +/api/miniprogram/withdraw, withdraw/records, pending-confirm, confirm-received, confirm-info +/api/miniprogram/vip/status, vip/profile, vip/members +/api/miniprogram/users +``` + +**缺失**:`/api/miniprogram/orders`(需新增) + +--- + +## 五、变更任务分工建议 + +| 角色 | 任务 | +|------|------| +| **小程序** | 1. match.js:3 处路径改为 /api/miniprogram/*
      2. my.js:2 处路径改为 /api/miniprogram/*
      3. purchases.js:路径改为 /api/miniprogram/orders(待后端提供后) | +| **后端 API** | 1. 新增 MiniprogramOrders handler:GET,支持 ?userId=,返回 { success, data }
      2. router 挂载 miniprogram.GET("/orders", handler.MiniprogramOrders)
      3. ckb/match 已挂载,无需变更 | +| **管理端** | 无需因本次对齐变更;订单、提现、用户等管理接口保持现状 | + +--- + +## 六、附录:match 接口方法说明 + +- `GET /api/miniprogram/match/config`:匹配配置(matchTypes、freeMatchLimit、matchPrice) +- `POST /api/miniprogram/match/users`:执行匹配,入参 matchType、userId,返回匹配到的用户 + +当前 match.js 对 config 使用 `method: 'GET'`,对 users 使用 `method: 'POST'`,与后端一致。仅需将路径从 `/api/match/*` 改为 `/api/miniprogram/match/*`。 diff --git a/开发文档/列表标准与角色分工.md b/开发文档/列表标准与角色分工.md new file mode 100644 index 00000000..75bc3ddf --- /dev/null +++ b/开发文档/列表标准与角色分工.md @@ -0,0 +1,111 @@ +# Soul 创业派对 - 列表标准与角色分工 + +> 供管理端开发者、API 开发者参考。基于 2026-02 列表缺陷排查经验归纳。 +> 更新日期:2026-02-25 + +--- + +## 一、标准列表应具备的能力 + +| 能力 | 说明 | 优先级 | +|------|------|--------| +| **搜索** | 关键词模糊搜索,建议 300ms 防抖 | 高 | +| **筛选** | 状态/类型/时间范围等 | 高 | +| **刷新** | 手动重新加载 | 高 | +| **分页** | 上一页/下一页、页码、每页条数(后端支持时) | 高 | +| **加载状态** | loading 或骨架屏 | 高 | +| **空状态** | 无数据时的提示 | 高 | +| **错误提示** | 加载失败时展示可关闭的提示条 | 高 | +| **排序** | 列头点击排序(可选) | 中 | +| **导出** | CSV/Excel(可选) | 中 | +| **批量操作** | 勾选多行后批量处理(可选) | 低 | + +--- + +## 二、角色分工 + +### 2.1 管理端开发者(soul-admin) + +**职责**:实现列表页面的交互与展示,对接 soul-api 的管理端接口。 + +**必做**: +- 搜索:使用 `useDebounce` 对输入做 300ms 防抖 +- 筛选:按业务提供下拉/按钮筛选 +- 刷新:提供刷新按钮,加载时禁用并显示 loading +- 加载状态:请求中显示 loading +- 空状态:无数据时显示友好提示 +- 错误提示:catch 后设置 error 状态,页面顶部展示可关闭的错误条(红底) + +**可选**: +- 导出:前端基于当前筛选结果生成 CSV(无需后端支持) +- 排序:前端内存排序或后端支持时传 sort 参数 + +**禁止**: +- 不得调用 `/api/miniprogram/*` +- 不得用原生 `alert`/`confirm` 替代错误提示(应使用页面内错误条或 Dialog) + +**参考**:`.cursor/skills/SKILL-管理端开发.md`、`soul-admin-boundary.mdc` + +--- + +### 2.2 API 开发者(soul-api) + +**职责**:为管理端列表提供分页、筛选、排序等能力。 + +**列表接口建议**: +- 分页:支持 `page`、`pageSize` 查询参数,返回 `total`、`records`/`list` +- 筛选:支持 `status`、`matchType`、`startDate`、`endDate` 等 +- 排序:支持 `sortBy`、`sortOrder`(asc/desc) + +**响应格式**: +```json +{ + "success": true, + "records": [...], + "total": 100, + "page": 1, + "pageSize": 10 +} +``` + +**错误**:失败时返回 `{ "success": false, "error": "..." }`,管理端据此展示错误条。 + +**参考**:`.cursor/skills/SKILL-API开发.md`、`soul-api.mdc` + +--- + +## 三、已补全项(2026-02-25) + +| 页面 | 补全内容 | +|------|----------| +| 用户管理 | 错误提示、搜索防抖、**分页、每页条数、VIP 筛选** | +| 订单管理 | 错误提示、刷新、导出 CSV、搜索防抖、**分页、每页条数、后端搜索** | +| 匹配记录 | 错误提示、**每页条数选择** | +| 分账提现 | 错误提示、**分页、每页条数** | +| 交易中心 | 错误提示、**分页(订单/绑定/提现子列表)** | +| 章节管理 | 错误提示、刷新 | + +--- + +## 四、后端分页支持(已实现) + +| 接口 | 分页参数 | 筛选/搜索 | +|------|----------|-----------| +| GET /api/db/users | page, pageSize | search, vip | +| GET /api/orders | page, pageSize | status, search | +| GET /api/admin/withdrawals | page, pageSize | status | +| GET /api/db/distribution | page, pageSize | status | +| GET /api/db/match-records | page, pageSize | matchType | + +--- + +## 五、检查清单(管理端新增列表时) + +- [ ] 分页(后端支持时接入 page、pageSize、total) +- [ ] 搜索有防抖(300ms) +- [ ] 有刷新按钮 +- [ ] 加载中显示 loading +- [ ] 无数据时显示空状态 +- [ ] 加载失败时展示错误条(可关闭) +- [ ] 仅调用 `/api/admin/*` 或 `/api/db/*` +- [ ] 不使用原生 alert 做错误提示 diff --git a/开发文档/小程序功能与管理端配置补齐分析.md b/开发文档/小程序功能与管理端配置补齐分析.md new file mode 100644 index 00000000..0e5f6786 --- /dev/null +++ b/开发文档/小程序功能与管理端配置补齐分析.md @@ -0,0 +1,168 @@ +# 小程序功能与管理端配置补齐分析 + +> 基于 miniprogram 功能分析,梳理需管理端补齐的配置与功能。 +> 更新日期:2026-02-25 +> **2026-02-25 已补齐**:mp_config 管理端、网站配置持久化、支付/二维码 POST、小程序 config 读取 + +--- + +## 一、小程序配置来源总览 + +| 配置类型 | 来源 | 管理端入口 | 状态 | +|----------|------|------------|------| +| 免费章节 | system_config.free_chapters | 系统设置 | ✅ 已有 | +| 价格 (section/fullbook) | chapter_config / site_settings | 系统设置 | ✅ 已有 | +| 功能开关 (match/referral/search/about) | feature_config | 系统设置 | ✅ 已有 | +| 找伙伴配置 | match_config | 找伙伴配置页 | ✅ 已有 | +| 推广/分销 | referral_config | 推广设置 | ✅ 已有 | +| 小程序专用 (mp_config) | mp_config | 系统设置 → 小程序配置 | ✅ 已补齐 | +| 订阅消息模板 ID | mp_config 或 app.js 兜底 | 系统设置 → 小程序配置 | ✅ 已补齐 | +| 微信支付商户号 | mp_config 或 app.js 兜底 | 系统设置 → 小程序配置 | ✅ 已补齐 | +| API 地址 (baseUrl) | app.js 硬编码 | 发版时改 baseUrl | 已移除配置 | +| 网站/站点配置 | site_config, page_config | 网站配置 | ✅ 已持久化 | + +--- + +## 二、小程序功能模块与配置依赖 + +### 2.1 核心配置接口:`GET /api/miniprogram/config` + +**返回字段**(来自 GetPublicDBConfig): + +| 字段 | 说明 | 管理端对应 | +|------|------|------------| +| freeChapters | 免费章节 ID 列表 | 系统设置 → 免费章节 | +| prices | { section, fullbook } | 系统设置 → 价格设置 | +| features | matchEnabled, referralEnabled, searchEnabled, aboutEnabled | 系统设置 → 功能开关 | +| mpConfig | appId, apiDomain, buyerDiscount, referralBindDays, minWithdraw | **无管理端** | +| userDiscount | 好友购买优惠 % | 推广设置 | + +### 2.2 找伙伴配置:`GET /api/miniprogram/match/config` + +| 字段 | 说明 | 管理端对应 | +|------|------|------------| +| matchTypes | 匹配类型列表 | 找伙伴配置页 | +| freeMatchLimit | 每日免费匹配次数 | 找伙伴配置页 | +| matchPrice | 单次匹配价格(元) | 找伙伴配置页 | +| settings | enableFreeMatches, enablePaidMatches, maxMatchesPerDay | 找伙伴配置页 | + +### 2.3 小程序 app.js 硬编码项 + +```javascript +// 当前硬编码,无法通过管理端修改 +baseUrl: 'http://localhost:8080', // 开发/生产需改代码 +appId: 'wxb8bbb2b10dec74aa', +withdrawSubscribeTmplId: 'u3MbZGPRkrZIk-...', // 提现订阅消息模板 +mchId: '1318592501', // 微信支付商户号 +``` + +--- + +## 三、管理端需补齐项(按优先级) + +### P0 - 必须补齐 + +| 项 | 说明 | 建议方案 | +|----|------|----------| +| **小程序专用配置 (mp_config)** | appId、apiDomain、minWithdraw 等,小程序从 config 读取 | 在「系统设置」或新建「小程序配置」卡片,支持编辑并写入 system_config.mp_config | +| **订阅消息模板 ID** | 提现申请需用户授权订阅,模板 ID 现硬编码 | 管理端增加「提现订阅模板 ID」配置,写入 mp_config 或单独 key;小程序启动时从 config 拉取 | +| **API 地址 (baseUrl)** | 开发/生产切换需改 app.js | 方案 A:从 mp_config.apiDomain 下发,小程序优先用接口返回值;方案 B:保留硬编码,仅文档说明切换方式 | + +### P1 - 建议补齐 + +| 项 | 说明 | 建议方案 | +|----|------|----------| +| **微信支付商户号** | 支付回调、对账依赖 mchId,现硬编码 | 管理端「支付配置」或「小程序配置」增加 mchId 字段;后端从配置读取,小程序可不改(支付由后端发起) | +| **网站配置持久化** | SitePage 当前保存仅前端状态,未调用后端 | 对接 POST /api/db/config,按 key 保存 site_config、page_config、menu_config | +| **支付/二维码配置持久化** | PaymentPage、QRCodesPage 使用 POST /api/config | soul-api 无 POST /api/config,需新增或改为 POST /api/db/config { key, value } | + +### P2 - 可选优化 + +| 项 | 说明 | 建议方案 | +|----|------|----------| +| **referral_config 的 withdrawFee** | 文档有提现手续费,ReferralSettingsPage 未展示 | 若业务需要,在推广设置页增加「提现手续费」字段 | +| **主题色/品牌色** | app.js theme 硬编码 | 若需多端统一,可从 site_config 或 mp_config 下发 | + +--- + +## 四、配置与 system_config 键名映射 + +| system_config.config_key | 管理端页面 | 说明 | +|--------------------------|------------|------| +| free_chapters | 系统设置 | 免费章节 ID 数组 | +| feature_config | 系统设置 | 功能开关对象 | +| site_settings | 系统设置 | 价格、作者信息 | +| chapter_config | (可选) | 合并 freeChapters + prices,GetPublicDBConfig 优先用 | +| match_config | 找伙伴配置 | 匹配类型、免费次数、价格 | +| referral_config | 推广设置 | 分销比例、提现门槛、绑定期等 | +| mp_config | **待新增** | 小程序专用:appId, apiDomain, withdrawSubscribeTmplId, mchId 等 | +| site_config | 网站配置 | 站点名称、logo 等(需持久化) | +| page_config | 网站配置 | 页面标题(需持久化) | +| menu_config | 网站配置 | 菜单开关(需持久化) | +| payment_methods | 支付配置 | 微信/支付宝活码等(需确认 POST 接口) | +| live_qr_codes | 二维码管理 | 群活码(需确认 POST 接口) | + +--- + +## 五、接口与数据流检查 + +### 5.1 管理端调用与后端支持 + +| 管理端页面 | 调用 | 后端支持 | 备注 | +|------------|------|----------|------| +| 系统设置 | GET/POST /api/admin/settings | ✅ | 写入 free_chapters, feature_config, site_settings | +| 推广设置 | GET/POST /api/admin/referral-settings | ✅ | 写入 referral_config | +| 找伙伴配置 | GET /api/db/config/full?key=match_config | ✅ | 需 AdminAuth | +| 找伙伴配置 | POST /api/db/config | ✅ | body: { key: 'match_config', value: {...} } | +| 支付配置 | GET/POST /api/config | ⚠️ | GET 有,POST 无;需新增或改用 db/config | +| 网站配置 | GET /api/config | ⚠️ | GET 有,保存未对接 | +| 二维码管理 | GET/POST /api/config | ⚠️ | 同上 | + +### 5.2 小程序读取链 + +``` +小程序 onLoad / custom-tab-bar + → GET /api/miniprogram/config + → GetPublicDBConfig + → 读取 system_config: chapter_config, free_chapters, feature_config, mp_config, referral_config + → 返回 freeChapters, prices, features, mpConfig, userDiscount +``` + +--- + +## 六、实施建议(管理端开发任务) + +### 任务 1:新增「小程序配置」区块(P0) + +- **位置**:系统设置页新增卡片,或独立「小程序配置」页 +- **字段**: + - API 域名 (apiDomain):如 `https://soulapi.quwanzhi.com` + - 小程序 AppID (appId):如 `wxb8bbb2b10dec74aa` + - 提现订阅模板 ID (withdrawSubscribeTmplId) + - 微信支付商户号 (mchId)(可选,后端也可用 env) + - 最低提现金额 (minWithdraw)(可与 referral_config 同步) +- **存储**:POST /api/admin/settings 扩展,或 POST /api/db/config { key: 'mp_config', value: {...} } +- **小程序**:app.js 启动时请求 config,若 mp_config 存在则覆盖 baseUrl;withdrawSubscribeTmplId 从 config 取 + +### 任务 2:网站配置持久化(P1) + +- SitePage 保存时调用 POST /api/db/config,按 key 分别保存 site_config、page_config、menu_config +- 或扩展 AdminSettingsPost 支持 site_config 等 + +### 任务 3:支付/二维码配置接口(P1) + +- 方案 A:新增 POST /api/admin/config,支持 payment_methods、live_qr_codes 等 key +- 方案 B:PaymentPage、QRCodesPage 改为调用 POST /api/db/config,body: { key, value } + +--- + +## 七、附录:小程序页面与配置使用 + +| 页面 | 使用的配置 | 接口 | +|------|------------|------| +| custom-tab-bar | features.matchEnabled | GET /api/miniprogram/config | +| 阅读 read | freeChapters, prices | GET /api/miniprogram/config (chapterAccessManager) | +| 找伙伴 match | matchTypes, freeMatchLimit, matchPrice | GET /api/miniprogram/match/config | +| 我的 my | features, 收益/提现规则 | GET /api/miniprogram/config, referral/data | +| 分销 referral | shareRate, minWithdraw, bindingDays | GET /api/miniprogram/referral/data | +| 支付流程 | mchId (后端), openId | app.js 硬编码 + 后端 env | diff --git a/开发文档/小程序管理/SKILL.md b/开发文档/小程序管理/SKILL.md new file mode 100644 index 00000000..4645ec85 --- /dev/null +++ b/开发文档/小程序管理/SKILL.md @@ -0,0 +1,1797 @@ +# 小程序管理技能 v3.0 + +> 📅 创建日期:2026-01-25 +> 📅 更新日期:2026-01-25(v3.0 全能版) +> 📋 通过微信开放平台API完整管理小程序的全生命周期:申请、认证、开发、审核、发布、运营 +> 🚀 支持多小程序管理、一键部署、自动认证检查、汇总报告 + +--- + +## 🎯 能力全景图 + +``` +╔══════════════════════════════════════════════════════════════════════════════╗ +║ 小程序管理技能 v3.0 能力全景图 ║ +╠══════════════════════════════════════════════════════════════════════════════╣ +║ ║ +║ ┌─────────────────────────────────────────────────────────────────────┐ ║ +║ │ 🔧 工具整合层 │ ║ +║ │ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ ┌───────────┐ │ ║ +║ │ │ 微信开发者 │ │ miniprogram │ │ 开放平台 │ │ GitHub │ │ ║ +║ │ │ 工具 CLI │ │ -ci (npm) │ │ API │ │ Actions │ │ ║ +║ │ └─────────────┘ └─────────────┘ └─────────────┘ └───────────┘ │ ║ +║ └─────────────────────────────────────────────────────────────────────┘ ║ +║ │ ║ +║ ▼ ║ +║ ┌─────────────────────────────────────────────────────────────────────┐ ║ +║ │ 📦 核心功能层 │ ║ +║ │ │ ║ +║ │ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐ │ ║ +║ │ │ 多小程序 │ │ 项目 │ │ 一键 │ │ 汇总 │ │ ║ +║ │ │ 管理 │ │ 检查 │ │ 部署 │ │ 报告 │ │ ║ +║ │ └─────────┘ └─────────┘ └─────────┘ └─────────┘ │ ║ +║ │ │ ║ +║ └─────────────────────────────────────────────────────────────────────┘ ║ +║ │ ║ +║ ▼ ║ +║ ┌─────────────────────────────────────────────────────────────────────┐ ║ +║ │ 🚀 部署流程 │ ║ +║ │ │ ║ +║ │ ┌──────┐ ┌──────┐ ┌──────┐ ┌──────┐ ┌──────┐ ┌──────┐ │ ║ +║ │ │ 检查 │ → │ 编译 │ → │ 上传 │ → │ 提审 │ → │ 审核 │ → │ 发布 │ │ ║ +║ │ │check │ │build │ │upload│ │audit │ │wait │ │release│ │ ║ +║ │ └──────┘ └──────┘ └──────┘ └──────┘ └──────┘ └──────┘ │ ║ +║ │ │ │ │ │ │ │ │ ║ +║ │ ▼ ▼ ▼ ▼ ▼ ▼ │ ║ +║ │ 自动化 自动化 自动化 自动化 等待 手动/自动 │ ║ +║ │ 1-7天 │ ║ +║ └─────────────────────────────────────────────────────────────────────┘ ║ +║ ║ +╚══════════════════════════════════════════════════════════════════════════════╝ +``` + +--- + +## 📊 命令速查表 + +| 命令 | 说明 | 示例 | +|------|------|------| +| `mp_full.py report` | 生成所有小程序汇总报告 | `python3 mp_full.py report` | +| `mp_full.py check` | 检查项目问题 | `python3 mp_full.py check soul-party` | +| `mp_full.py auto` | 全自动部署(上传+提审) | `python3 mp_full.py auto soul-party` | +| `mp_deploy.py list` | 列出所有小程序 | `python3 mp_deploy.py list` | +| `mp_deploy.py add` | 添加新小程序 | `python3 mp_deploy.py add` | +| `mp_deploy.py cert-status` | 查询认证状态 | `python3 mp_deploy.py cert-status soul-party` | +| `mp_deploy.py cert-done` | 标记认证完成 | `python3 mp_deploy.py cert-done soul-party` | +| `mp_deploy.py release` | 发布上线 | `python3 mp_deploy.py release soul-party` | + +--- + +## 🎯 技能概述 + +本技能用于通过API实现微信小程序的完整管理,包括: + +### 核心能力 + +| 阶段 | 能力 | 说明 | +|------|------|------| +| **申请** | 快速注册小程序 | 复用公众号主体资质,无需300元认证费 | +| **认证** | 企业认证管理 | 自动检查认证状态、提醒过期、材料管理 | +| **配置** | 基础信息设置 | 名称、头像、介绍、类目管理 | +| **开发** | 代码管理 | 上传代码、生成体验版 | +| **审核** | 提审发布 | 提交审核、查询状态、撤回、发布 | +| **运营** | 接口管理 | 域名配置、隐私协议、接口权限 | +| **推广** | 小程序码 | 生成无限量小程序码 | +| **数据** | 数据分析 | 访问数据、用户画像 | + +### v2.0 新增能力 + +| 能力 | 命令 | 说明 | +|------|------|------| +| **多小程序管理** | `mp_deploy.py list` | 统一管理多个小程序 | +| **一键部署** | `mp_deploy.py deploy ` | 编译→上传→提审一步完成 | +| **认证管理** | `mp_deploy.py cert ` | 认证状态检查、材料管理 | +| **快速上传** | `mp_deploy.py upload ` | 快速上传代码到开发版 | + +### 开源工具集成 + +| 工具 | 用途 | 安装方式 | +|------|------|----------| +| **miniprogram-ci** | 微信官方CI工具 | `npm install miniprogram-ci -g` | +| **微信开发者工具CLI** | 本地编译上传 | 安装开发者工具自带 | +| **multi-mini-ci** | 多平台小程序上传 | GitHub开源 | + +--- + +## 🚀 触发词 + +- 管理小程序 +- 小程序申请 +- 小程序审核 +- 小程序发布 +- 上传小程序代码 +- 配置小程序域名 +- 生成小程序码 +- 查看小程序状态 + +--- + +## 🏗️ 技术架构 + +### 管理方式对比 + +| 方式 | 优点 | 缺点 | 适用场景 | +|------|------|------|----------| +| **微信后台手动操作** | 无需开发 | 效率低,无法批量 | 单个小程序 | +| **微信开发者工具CLI** | 简单易用 | 功能有限 | 开发测试 | +| **开放平台API(本方案)** | 功能完整、可自动化 | 需要开发 | 批量管理、自动化 | + +### 整体架构 + +``` +┌─────────────────────────────────────────────────────────────────────────────┐ +│ 小程序管理引擎 v1.0 │ +├─────────────────────────────────────────────────────────────────────────────┤ +│ │ +│ ┌─────────────────────────────────────────────────────────────────────┐ │ +│ │ 第一层:认证层 │ │ +│ │ ┌───────────────┐ ┌───────────────┐ ┌───────────────┐ │ │ +│ │ │ 第三方平台 │ │ component_ │ │ authorizer_ │ │ │ +│ │ │ 认证信息 │ → │ access_token │ → │ access_token │ │ │ +│ │ └───────────────┘ └───────────────┘ └───────────────┘ │ │ +│ └─────────────────────────────────────────────────────────────────────┘ │ +│ ↓ │ +│ ┌─────────────────────────────────────────────────────────────────────┐ │ +│ │ 第二层:管理API层 │ │ +│ │ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐ │ │ +│ │ │ 注册 │ │ 配置 │ │ 代码 │ │ 审核 │ │ 运营 │ │ │ +│ │ │ 管理 │ │ 管理 │ │ 管理 │ │ 管理 │ │ 管理 │ │ │ +│ │ └─────────┘ └─────────┘ └─────────┘ └─────────┘ └─────────┘ │ │ +│ └─────────────────────────────────────────────────────────────────────┘ │ +│ ↓ │ +│ ┌─────────────────────────────────────────────────────────────────────┐ │ +│ │ 第三层:本地CLI层 │ │ +│ │ ┌───────────────┐ ┌───────────────┐ ┌───────────────┐ │ │ +│ │ │ mp_manager.py │ │ 微信开发者 │ │ 自动化脚本 │ │ │ +│ │ │ Python CLI │ │ 工具 CLI │ │ Shell │ │ │ +│ │ └───────────────┘ └───────────────┘ └───────────────┘ │ │ +│ └─────────────────────────────────────────────────────────────────────┘ │ +│ │ +└─────────────────────────────────────────────────────────────────────────────┘ +``` + +--- + +## 📋 前置条件 + +### 1. 微信开放平台账号 + +- 注册地址:https://open.weixin.qq.com/ +- 完成开发者资质认证(需企业资质) + +### 2. 创建第三方平台 + +登录开放平台后台 → 管理中心 → 第三方平台 → 创建 + +**必填信息**: +- 平台名称 +- 服务类型(选择"平台型"可管理多个小程序) +- 授权发起页域名 +- 消息与事件接收URL + +### 3. 获取关键凭证 + +| 凭证 | 说明 | 获取方式 | +|------|------|----------| +| `component_appid` | 第三方平台AppID | 开放平台后台 | +| `component_appsecret` | 第三方平台密钥 | 开放平台后台 | +| `component_verify_ticket` | 验证票据 | 微信每10分钟推送 | +| `component_access_token` | 平台调用凭证 | API获取,2小时有效 | +| `authorizer_access_token` | 授权方调用凭证 | API获取,2小时有效 | + +--- + +## 🔑 认证流程 + +### 获取 component_access_token + +```python +# POST https://api.weixin.qq.com/cgi-bin/component/api_component_token +{ + "component_appid": "你的第三方平台AppID", + "component_appsecret": "你的第三方平台密钥", + "component_verify_ticket": "微信推送的验证票据" +} + +# 返回 +{ + "component_access_token": "xxxx", + "expires_in": 7200 +} +``` + +### 获取预授权码 + +```python +# POST https://api.weixin.qq.com/cgi-bin/component/api_create_preauthcode +{ + "component_appid": "你的第三方平台AppID" +} + +# 返回 +{ + "pre_auth_code": "xxxx", + "expires_in": 600 +} +``` + +### 引导用户授权 + +``` +https://mp.weixin.qq.com/cgi-bin/componentloginpage? +component_appid=第三方平台AppID& +pre_auth_code=预授权码& +redirect_uri=授权回调地址& +auth_type=1 # 1=仅小程序,2=仅公众号,3=两者都可 +``` + +### 获取 authorizer_access_token + +```python +# POST https://api.weixin.qq.com/cgi-bin/component/api_query_auth +{ + "component_appid": "第三方平台AppID", + "authorization_code": "授权回调返回的code" +} + +# 返回 +{ + "authorization_info": { + "authorizer_appid": "授权方AppID", + "authorizer_access_token": "授权方调用凭证", + "expires_in": 7200, + "authorizer_refresh_token": "刷新令牌" + } +} +``` + +--- + +## 📱 核心API接口 + +### 一、小程序注册 + +#### 1.1 复用公众号资质快速注册 + +**前提**:已有认证的公众号 + +```python +# POST https://api.weixin.qq.com/cgi-bin/account/fastregister?access_token=ACCESS_TOKEN +{ + "ticket": "公众号扫码授权的ticket" +} + +# 返回 +{ + "errcode": 0, + "errmsg": "ok", + "appid": "新注册的小程序AppID", + "authorization_code": "授权码" +} +``` + +**优势**: +- 无需重新提交主体材料 +- 无需对公打款 +- 无需支付300元认证费 + +**限制**: +- 非个体户:每月可注册5个 +- 个体户:每月可注册1个 + +#### 1.2 快速注册企业小程序 + +**前提**:有企业营业执照 + +```python +# POST https://api.weixin.qq.com/cgi-bin/component/fastregisterminiprogram +{ + "name": "小程序名称", + "code": "统一社会信用代码", + "code_type": 1, # 1=营业执照 + "legal_persona_wechat": "法人微信号", + "legal_persona_name": "法人姓名", + "component_phone": "联系电话" +} +``` + +--- + +### 二、基础信息配置 + +#### 2.1 获取基础信息 + +```python +# POST https://api.weixin.qq.com/cgi-bin/account/getaccountbasicinfo +# 无请求参数 + +# 返回 +{ + "appid": "小程序AppID", + "account_type": 2, # 2=小程序 + "principal_type": 1, # 1=企业 + "principal_name": "主体名称", + "realname_status": 1, # 1=已认证 + "nickname": "小程序名称", + "head_image_url": "头像URL", + "signature": "简介" +} +``` + +#### 2.2 修改名称 + +```python +# POST https://api.weixin.qq.com/wxa/setnickname?access_token=ACCESS_TOKEN +{ + "nick_name": "新名称", + "id_card": "管理员身份证号", + "license": "营业执照media_id", # 需要先上传 + "naming_other_stuff_1": "其他证明material_id" # 可选 +} +``` + +#### 2.3 修改头像 + +```python +# POST https://api.weixin.qq.com/cgi-bin/account/modifyheadimage?access_token=ACCESS_TOKEN +{ + "head_img_media_id": "头像图片media_id", # 需要先上传 + "x1": 0, "y1": 0, "x2": 1, "y2": 1 # 裁剪区域 +} +``` + +#### 2.4 修改简介 + +```python +# POST https://api.weixin.qq.com/cgi-bin/account/modifysignature?access_token=ACCESS_TOKEN +{ + "signature": "新的简介内容" # 4-120字 +} +``` + +--- + +### 三、类目管理 + +#### 3.1 获取可选类目 + +```python +# GET https://api.weixin.qq.com/cgi-bin/wxopen/getallcategories?access_token=ACCESS_TOKEN +``` + +#### 3.2 获取已设置类目 + +```python +# GET https://api.weixin.qq.com/cgi-bin/wxopen/getcategory?access_token=ACCESS_TOKEN +``` + +#### 3.3 添加类目 + +```python +# POST https://api.weixin.qq.com/cgi-bin/wxopen/addcategory?access_token=ACCESS_TOKEN +{ + "categories": [ + { + "first": 1, # 一级类目ID + "second": 2, # 二级类目ID + "certicates": [ # 资质证明 + {"key": "资质名称", "value": "media_id"} + ] + } + ] +} +``` + +#### 3.4 删除类目 + +```python +# POST https://api.weixin.qq.com/cgi-bin/wxopen/deletecategory?access_token=ACCESS_TOKEN +{ + "first": 1, + "second": 2 +} +``` + +--- + +### 四、域名配置 + +#### 4.1 设置服务器域名 + +```python +# POST https://api.weixin.qq.com/wxa/modify_domain?access_token=ACCESS_TOKEN +{ + "action": "set", # add/delete/set/get + "requestdomain": ["https://api.example.com"], + "wsrequestdomain": ["wss://ws.example.com"], + "uploaddomain": ["https://upload.example.com"], + "downloaddomain": ["https://download.example.com"], + "udpdomain": ["udp://udp.example.com"], + "tcpdomain": ["tcp://tcp.example.com"] +} +``` + +#### 4.2 设置业务域名 + +```python +# POST https://api.weixin.qq.com/wxa/setwebviewdomain?access_token=ACCESS_TOKEN +{ + "action": "set", # add/delete/set/get + "webviewdomain": ["https://web.example.com"] +} +``` + +--- + +### 五、隐私协议配置 + +#### 5.1 获取隐私协议设置 + +```python +# POST https://api.weixin.qq.com/cgi-bin/component/getprivacysetting?access_token=ACCESS_TOKEN +{ + "privacy_ver": 2 # 1=当前版本,2=开发版本 +} +``` + +#### 5.2 设置隐私协议 + +```python +# POST https://api.weixin.qq.com/cgi-bin/component/setprivacysetting?access_token=ACCESS_TOKEN +{ + "privacy_ver": 2, + "setting_list": [ + { + "privacy_key": "UserInfo", + "privacy_text": "用于展示用户头像和昵称" + }, + { + "privacy_key": "Location", + "privacy_text": "用于获取您的位置信息以推荐附近服务" + }, + { + "privacy_key": "PhoneNumber", + "privacy_text": "用于登录验证和订单通知" + } + ], + "owner_setting": { + "contact_email": "contact@example.com", + "contact_phone": "15880802661", + "notice_method": "弹窗提示" + } +} +``` + +**常用隐私字段**: + +| privacy_key | 说明 | +|-------------|------| +| `UserInfo` | 用户信息(头像、昵称) | +| `Location` | 地理位置 | +| `PhoneNumber` | 手机号 | +| `Album` | 相册 | +| `Camera` | 相机 | +| `Record` | 麦克风 | +| `Clipboard` | 剪切板 | +| `MessageFile` | 微信消息中的文件 | +| `ChooseAddress` | 收货地址 | +| `BluetoothInfo` | 蓝牙 | + +--- + +### 六、代码管理 + +#### 6.1 上传代码 + +```python +# POST https://api.weixin.qq.com/wxa/commit?access_token=ACCESS_TOKEN +{ + "template_id": 1, # 代码模板ID + "ext_json": "{\"extAppid\":\"授权方AppID\",\"ext\":{}}", + "user_version": "1.0.0", + "user_desc": "版本描述" +} +``` + +**注意**:需要先在第三方平台创建代码模板 + +#### 6.2 获取体验版二维码 + +```python +# GET https://api.weixin.qq.com/wxa/get_qrcode?access_token=ACCESS_TOKEN&path=pages/index/index +# 返回二维码图片 +``` + +#### 6.3 获取已上传的代码页面列表 + +```python +# GET https://api.weixin.qq.com/wxa/get_page?access_token=ACCESS_TOKEN + +# 返回 +{ + "errcode": 0, + "page_list": ["pages/index/index", "pages/my/my"] +} +``` + +--- + +### 七、审核管理 + +#### 7.1 提交审核 + +```python +# POST https://api.weixin.qq.com/wxa/submit_audit?access_token=ACCESS_TOKEN +{ + "item_list": [ + { + "address": "pages/index/index", + "tag": "电子书 阅读 创业", + "first_class": "教育", + "second_class": "在线教育", + "first_id": 1, + "second_id": 2, + "title": "首页" + } + ], + "preview_info": { + "video_id_list": [], + "pic_id_list": [] + }, + "version_desc": "版本说明", + "feedback_info": "反馈内容", + "feedback_stuff": "media_id" # 反馈附件 +} +``` + +#### 7.2 查询审核状态 + +```python +# POST https://api.weixin.qq.com/wxa/get_auditstatus?access_token=ACCESS_TOKEN +{ + "auditid": 1234567890 +} + +# 返回 +{ + "errcode": 0, + "status": 0, # 0=审核成功,1=审核被拒,2=审核中,3=已撤回,4=审核延后 + "reason": "拒绝原因", # status=1时返回 + "screenshot": "截图" +} +``` + +#### 7.3 查询最新审核状态 + +```python +# GET https://api.weixin.qq.com/wxa/get_latest_auditstatus?access_token=ACCESS_TOKEN +``` + +#### 7.4 撤回审核 + +```python +# GET https://api.weixin.qq.com/wxa/undocodeaudit?access_token=ACCESS_TOKEN +``` + +**限制**:单个小程序每天只能撤回1次 + +--- + +### 八、发布管理 + +#### 8.1 发布已审核通过的版本 + +```python +# POST https://api.weixin.qq.com/wxa/release?access_token=ACCESS_TOKEN +{} # 无请求参数 + +# 返回 +{ + "errcode": 0, + "errmsg": "ok" +} +``` + +#### 8.2 版本回退 + +```python +# GET https://api.weixin.qq.com/wxa/revertcoderelease?access_token=ACCESS_TOKEN +``` + +**限制**:只能回退到上一个版本,且只能回退一次 + +#### 8.3 获取可回退版本历史 + +```python +# GET https://api.weixin.qq.com/wxa/revertcoderelease?access_token=ACCESS_TOKEN&action=get_history_version +``` + +#### 8.4 分阶段发布 + +```python +# POST https://api.weixin.qq.com/wxa/grayrelease?access_token=ACCESS_TOKEN +{ + "gray_percentage": 10 # 灰度比例 1-100 +} +``` + +--- + +### 九、小程序码生成 + +#### 9.1 获取小程序码(有限制) + +```python +# POST https://api.weixin.qq.com/wxa/getwxacode?access_token=ACCESS_TOKEN +{ + "path": "pages/index/index?scene=123", + "width": 430, + "auto_color": false, + "line_color": {"r": 0, "g": 0, "b": 0}, + "is_hyaline": false # 是否透明背景 +} +# 返回图片二进制 +``` + +**限制**:每个path只能生成10万个 + +#### 9.2 获取无限小程序码(推荐) + +```python +# POST https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=ACCESS_TOKEN +{ + "scene": "user_id=123&from=share", # 最长32字符 + "page": "pages/index/index", # 必须是已发布的页面 + "width": 430, + "auto_color": false, + "line_color": {"r": 0, "g": 0, "b": 0}, + "is_hyaline": false +} +# 返回图片二进制 +``` + +**注意**:scene参数需要在小程序中用`onLoad(options)`解析 + +#### 9.3 生成小程序短链接 + +```python +# POST https://api.weixin.qq.com/wxa/genwxashortlink?access_token=ACCESS_TOKEN +{ + "page_url": "pages/index/index?id=123", + "page_title": "页面标题", + "is_permanent": false # 是否永久有效 +} + +# 返回 +{ + "errcode": 0, + "link": "https://wxaurl.cn/xxxx" +} +``` + +--- + +### 十、接口权限管理 + +#### 10.1 查询接口调用额度 + +```python +# POST https://api.weixin.qq.com/cgi-bin/openapi/quota/get?access_token=ACCESS_TOKEN +{ + "cgi_path": "/wxa/getwxacode" +} + +# 返回 +{ + "quota": { + "daily_limit": 100000, + "used": 500, + "remain": 99500 + } +} +``` + +#### 10.2 重置接口调用次数 + +```python +# POST https://api.weixin.qq.com/cgi-bin/clear_quota?access_token=ACCESS_TOKEN +{ + "appid": "小程序AppID" +} +``` + +**限制**:每月只能重置10次 + +--- + +### 十一、数据分析 + +#### 11.1 获取访问趋势 + +```python +# POST https://api.weixin.qq.com/datacube/getweanalysisappiddailyvisittrend?access_token=ACCESS_TOKEN +{ + "begin_date": "20260101", + "end_date": "20260125" +} + +# 返回 +{ + "list": [ + { + "ref_date": "20260125", + "session_cnt": 1000, # 打开次数 + "visit_pv": 5000, # 访问次数 + "visit_uv": 800, # 访问人数 + "visit_uv_new": 100, # 新用户数 + "stay_time_uv": 120.5, # 人均停留时长(秒) + "stay_time_session": 60.2 # 次均停留时长(秒) + } + ] +} +``` + +#### 11.2 获取用户画像 + +```python +# POST https://api.weixin.qq.com/datacube/getweanalysisappiduserportrait?access_token=ACCESS_TOKEN +{ + "begin_date": "20260101", + "end_date": "20260125" +} +``` + +--- + +## 🛠️ 快速使用 + +### 方式一:使用Python管理脚本(推荐) + +```bash +# 进入脚本目录 +cd /Users/karuo/Documents/个人/卡若AI/02_卡人(水)/小程序管理/scripts + +# 安装依赖 +pip install httpx python-dotenv + +# 配置凭证 +cp .env.example .env +# 编辑 .env 填入你的凭证 + +# 使用命令行工具 +python mp_manager.py status # 查看小程序状态 +python mp_manager.py audit # 查看审核状态 +python mp_manager.py release # 发布上线 +python mp_manager.py qrcode # 生成小程序码 +``` + +### 方式二:使用微信开发者工具CLI + +```bash +# CLI路径 +CLI="/Applications/wechatwebdevtools.app/Contents/MacOS/cli" + +# 打开项目 +$CLI -o "/path/to/miniprogram" + +# 编译 +$CLI build-npm --project "/path/to/miniprogram" + +# 预览(生成二维码) +$CLI preview --project "/path/to/miniprogram" --qr-format image --qr-output preview.png + +# 上传代码 +$CLI upload --project "/path/to/miniprogram" --version "1.0.0" --desc "版本说明" + +# 提交审核 +$CLI submit-audit --project "/path/to/miniprogram" +``` + +### 方式三:直接调用API + +```python +import httpx + +# 配置 +ACCESS_TOKEN = "你的access_token" +BASE_URL = "https://api.weixin.qq.com" + +async def check_audit_status(auditid: int): + """查询审核状态""" + async with httpx.AsyncClient() as client: + resp = await client.post( + f"{BASE_URL}/wxa/get_auditstatus?access_token={ACCESS_TOKEN}", + json={"auditid": auditid} + ) + return resp.json() + +# 使用 +result = await check_audit_status(1234567890) +print(result) +``` + +--- + +## 📁 文件结构 + +``` +小程序管理/ +├── SKILL.md # 技能说明文档(本文件) +├── scripts/ +│ ├── mp_manager.py # 小程序管理CLI工具 +│ ├── mp_api.py # API封装类 +│ ├── requirements.txt # Python依赖 +│ └── .env.example # 环境变量模板 +└── references/ + ├── API接口速查表.md # 常用API速查 + ├── 隐私协议填写指南.md # 隐私协议配置指南 + └── 审核规范.md # 审核常见问题 +``` + +--- + +## ⚠️ 常见问题 + +### Q1: 如何获取 component_verify_ticket? + +微信会每10分钟向你配置的"消息与事件接收URL"推送。你需要部署一个服务来接收并存储它。 + +```python +# 接收推送示例 +@app.post("/callback") +async def receive_ticket(request: Request): + xml_data = await request.body() + # 解密并解析XML + # 提取 ComponentVerifyTicket + # 存储到Redis或数据库 + return "success" +``` + +### Q2: 审核被拒常见原因? + +| 原因 | 解决方案 | +|------|----------| +| 类目不符 | 确保小程序功能与所选类目一致 | +| 隐私协议缺失 | 配置完整的隐私保护指引 | +| 诱导分享 | 移除"分享到群获取xx"等诱导文案 | +| 虚拟支付 | iOS不能使用虚拟支付,需走IAP | +| 内容违规 | 检查文案、图片是否合规 | +| 功能不完整 | 确保所有页面功能正常 | + +### Q3: 审核需要多长时间? + +- 首次提审:1-7个工作日 +- 非首次:1-3个工作日 +- 加急审核:付费服务,24小时内 + +### Q4: 如何提高审核通过率? + +1. **提交完整测试账号**:如需登录才能体验功能 +2. **录制操作视频**:复杂功能建议附上操作视频 +3. **详细的版本描述**:说明本次更新内容 +4. **完善隐私协议**:所有收集数据的接口都要说明用途 + +### Q5: 代码模板是什么? + +第三方平台需要先将小程序代码上传到"草稿箱",再添加到"代码模板库"。之后可以用这个模板批量部署到多个小程序。 + +流程:开发完成 → 上传到草稿箱 → 添加到模板库 → 使用模板部署 + +--- + +## 🔗 官方文档 + +- [微信开放平台文档](https://developers.weixin.qq.com/doc/oplatform/) +- [第三方平台开发指南](https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/getting_started/how_to_read.html) +- [小程序管理接口](https://developers.weixin.qq.com/doc/oplatform/openApi/OpenApiDoc/) +- [代码管理接口](https://developers.weixin.qq.com/doc/oplatform/openApi/OpenApiDoc/miniprogram-management/code-management/commit.html) +- [隐私协议开发指南](https://developers.weixin.qq.com/miniprogram/dev/framework/user-privacy/) + +--- + +## 📊 当前项目配置 + +### Soul派对小程序 + +| 项目 | 配置值 | +|------|--------| +| **AppID** | `wxb8bbb2b10dec74aa` | +| **项目路径** | `/Users/karuo/Documents/开发/3、自营项目/一场soul的创业实验/miniprogram` | +| **API域名** | `https://soul.quwanzhi.com` | +| **当前版本** | `1.0.13` | +| **认证状态** | ⏳ 审核中(等待1-5工作日) | +| **检查结果** | ✅ 8项通过 / ⚠️ 2项警告 / ❌ 0项错误 | +| **可上传** | ✅ 是 | +| **可发布** | ❌ 需等待认证通过 | + +### 快速命令 + +```bash +# 打开项目 +/Applications/wechatwebdevtools.app/Contents/MacOS/cli -o "/Users/karuo/Documents/开发/3、自营项目/一场soul的创业实验/miniprogram" + +# 预览 +/Applications/wechatwebdevtools.app/Contents/MacOS/cli preview --project "/Users/karuo/Documents/开发/3、自营项目/一场soul的创业实验/miniprogram" --qr-format image --qr-output preview.png + +# 上传 +/Applications/wechatwebdevtools.app/Contents/MacOS/cli upload --project "/Users/karuo/Documents/开发/3、自营项目/一场soul的创业实验/miniprogram" --version "1.0.0" --desc "版本说明" +``` + +--- + +## 🚀 全自动部署流程(v3.0) + +### 完整生命周期流程图 + +``` +╔══════════════════════════════════════════════════════════════════════════════╗ +║ 小程序完整生命周期管理 ║ +╠══════════════════════════════════════════════════════════════════════════════╣ +║ ║ +║ 阶段一:准备阶段 ║ +║ ┌─────────────────────────────────────────────────────────────────────┐ ║ +║ │ │ ║ +║ │ ┌──────────┐ ┌──────────┐ ┌──────────┐ │ ║ +║ │ │ 注册小程序│ → │ 企业认证 │ → │ 配置项目 │ │ ║ +║ │ │ (微信后台)│ │ (300元/年)│ │ (添加到管理)│ │ ║ +║ │ └──────────┘ └──────────┘ └──────────┘ │ ║ +║ │ │ │ │ │ ║ +║ │ │ │ ▼ │ ║ +║ │ │ │ mp_deploy.py add │ ║ +║ │ │ ▼ │ ║ +║ │ │ 等待审核 1-5 天 │ ║ +║ │ │ mp_deploy.py cert-done │ ║ +║ │ │ ║ +║ └─────────────────────────────────────────────────────────────────────┘ ║ +║ │ ║ +║ ▼ ║ +║ 阶段二:开发阶段 ║ +║ ┌─────────────────────────────────────────────────────────────────────┐ ║ +║ │ │ ║ +║ │ ┌──────────┐ ┌──────────┐ ┌──────────┐ │ ║ +║ │ │ 编写代码 │ → │ 本地测试 │ → │ 项目检查 │ │ ║ +║ │ │ (开发者) │ │ (模拟器) │ │ mp_full │ │ ║ +║ │ └──────────┘ └──────────┘ └──────────┘ │ ║ +║ │ │ │ ║ +║ │ ▼ │ ║ +║ │ mp_full.py check │ ║ +║ │ 检查: 配置/域名/隐私/认证 │ ║ +║ │ │ ║ +║ └─────────────────────────────────────────────────────────────────────┘ ║ +║ │ ║ +║ ▼ ║ +║ 阶段三:部署阶段(全自动) ║ +║ ┌─────────────────────────────────────────────────────────────────────┐ ║ +║ │ │ ║ +║ │ mp_full.py auto -v "1.0.0" -d "版本描述" │ ║ +║ │ │ │ ║ +║ │ ▼ │ ║ +║ │ ┌──────────┐ ┌──────────┐ ┌──────────┐ │ ║ +║ │ │ ① 检查 │ → │ ② 上传 │ → │ ③ 提审 │ │ ║ +║ │ │ 项目问题 │ │ 代码到微信│ │ 提交审核 │ │ ║ +║ │ └──────────┘ └──────────┘ └──────────┘ │ ║ +║ │ │ │ │ │ ║ +║ │ ▼ ▼ ▼ │ ║ +║ │ 自动检测 使用CLI/npm 已认证→API提审 │ ║ +║ │ 配置/认证/域名 优先级选择 未认证→手动提审 │ ║ +║ │ │ ║ +║ └─────────────────────────────────────────────────────────────────────┘ ║ +║ │ ║ +║ ▼ ║ +║ 阶段四:发布阶段 ║ +║ ┌─────────────────────────────────────────────────────────────────────┐ ║ +║ │ │ ║ +║ │ ┌──────────┐ ┌──────────┐ ┌──────────┐ │ ║ +║ │ │ 等待审核 │ → │ 审核通过 │ → │ 发布上线 │ │ ║ +║ │ │ 1-7工作日 │ │ 通知 │ │ release │ │ ║ +║ │ └──────────┘ └──────────┘ └──────────┘ │ ║ +║ │ │ │ ║ +║ │ ▼ │ ║ +║ │ mp_deploy.py release │ ║ +║ │ 或 微信后台点击发布 │ ║ +║ │ │ ║ +║ └─────────────────────────────────────────────────────────────────────┘ ║ +║ │ ║ +║ ▼ ║ +║ 阶段五:运营阶段 ║ +║ ┌─────────────────────────────────────────────────────────────────────┐ ║ +║ │ │ ║ +║ │ ┌──────────┐ ┌──────────┐ ┌──────────┐ │ ║ +║ │ │ 数据分析 │ │ 汇总报告 │ │ 版本迭代 │ │ ║ +║ │ │ mp_manager│ │ mp_full │ │ 循环部署 │ │ ║ +║ │ └──────────┘ └──────────┘ └──────────┘ │ ║ +║ │ │ │ │ │ ║ +║ │ ▼ ▼ ▼ │ ║ +║ │ data命令 report命令 返回部署阶段 │ ║ +║ │ │ ║ +║ └─────────────────────────────────────────────────────────────────────┘ ║ +║ ║ +╚══════════════════════════════════════════════════════════════════════════════╝ +``` + +### 工具整合架构图 + +``` +┌────────────────────────────────────────────────────────────────────────────┐ +│ 小程序管理工具整合架构 │ +├────────────────────────────────────────────────────────────────────────────┤ +│ │ +│ ┌─────────────────────────────────────────────────────────────────────┐ │ +│ │ 用户命令层 │ │ +│ │ mp_full.py report │ mp_full.py check │ mp_full.py auto │ │ +│ │ mp_deploy.py list │ mp_deploy.py cert │ mp_manager.py status │ │ +│ └─────────────────────────────────────────────────────────────────────┘ │ +│ │ │ +│ ▼ │ +│ ┌─────────────────────────────────────────────────────────────────────┐ │ +│ │ Python 管理层 │ │ +│ │ ┌───────────────┐ ┌───────────────┐ ┌───────────────┐ │ │ +│ │ │ mp_full.py │ │ mp_deploy.py │ │ mp_api.py │ │ │ +│ │ │ 全能管理器 │ │ 部署工具 │ │ API封装 │ │ │ +│ │ │ • 检查 │ │ • 多小程序 │ │ • 认证 │ │ │ +│ │ │ • 报告 │ │ • 认证管理 │ │ • 审核 │ │ │ +│ │ │ • 自动部署 │ │ • 发布 │ │ • 发布 │ │ │ +│ │ └───────────────┘ └───────────────┘ └───────────────┘ │ │ +│ └─────────────────────────────────────────────────────────────────────┘ │ +│ │ │ +│ ▼ │ +│ ┌─────────────────────────────────────────────────────────────────────┐ │ +│ │ 外部工具层 │ │ +│ │ ┌───────────────┐ ┌───────────────┐ ┌───────────────┐ │ │ +│ │ │ 微信开发者 │ │ miniprogram │ │ 微信开放平台 │ │ │ +│ │ │ 工具 CLI │ │ -ci (npm) │ │ API │ │ │ +│ │ │ │ │ │ │ │ │ │ +│ │ │ • 打开项目 │ │ • 上传代码 │ │ • 提交审核 │ │ │ +│ │ │ • 预览 │ │ • 预览 │ │ • 发布 │ │ │ +│ │ │ • 上传 │ │ • 构建npm │ │ • 认证管理 │ │ │ +│ │ │ • 编译 │ │ • sourceMap │ │ • 数据分析 │ │ │ +│ │ └───────────────┘ └───────────────┘ └───────────────┘ │ │ +│ │ │ │ │ │ │ +│ │ ▼ ▼ ▼ │ │ +│ │ 优先级: 1 优先级: 2 优先级: 3 │ │ +│ │ (无需密钥) (需要密钥) (需要token) │ │ +│ └─────────────────────────────────────────────────────────────────────┘ │ +│ │ +└────────────────────────────────────────────────────────────────────────────┘ +``` + +### 快速开始 + +```bash +# 进入脚本目录 +cd /Users/karuo/Documents/个人/卡若AI/02_卡人(水)/小程序管理/scripts + +# 1. 查看已配置的小程序 +python3 mp_deploy.py list + +# 2. 添加新小程序(交互式) +python3 mp_deploy.py add + +# 3. 检查认证状态 +python3 mp_deploy.py cert-status soul-party + +# 4. 一键部署 +python3 mp_deploy.py deploy soul-party + +# 5. 审核通过后发布 +python3 mp_deploy.py release soul-party +``` + +### 命令速查 + +| 命令 | 说明 | 示例 | +|------|------|------| +| `list` | 列出所有小程序 | `python3 mp_deploy.py list` | +| `add` | 添加新小程序 | `python3 mp_deploy.py add` | +| `deploy` | 一键部署 | `python3 mp_deploy.py deploy soul-party` | +| `upload` | 仅上传代码 | `python3 mp_deploy.py upload soul-party` | +| `cert` | 提交认证 | `python3 mp_deploy.py cert soul-party` | +| `cert-status` | 查询认证状态 | `python3 mp_deploy.py cert-status soul-party` | +| `cert-done` | 标记认证完成 | `python3 mp_deploy.py cert-done soul-party` | +| `release` | 发布上线 | `python3 mp_deploy.py release soul-party` | + +--- + +## 📋 企业认证详解 + +### 认证流程图 + +``` +┌──────────────────────────────────────────────────────────────┐ +│ 企业认证流程 │ +├──────────────────────────────────────────────────────────────┤ +│ │ +│ ┌─────────┐ ┌─────────┐ ┌─────────┐ │ +│ │ 准备 │ → │ 提交 │ → │ 审核 │ │ +│ │ 材料 │ │ 认证 │ │ 等待 │ │ +│ └─────────┘ └─────────┘ └─────────┘ │ +│ │ │ │ │ +│ ↓ ↓ ↓ │ +│ ┌─────────────────────────────────────────┐ │ +│ │ • 营业执照 • 微信后台上传 • 1-5工作日 │ │ +│ │ • 法人身份证 • 法人扫码验证 • 审核结果 │ │ +│ │ • 法人微信号 • 支付300元 • 通知 │ │ +│ └─────────────────────────────────────────┘ │ +│ │ +│ ⚠️ 认证有效期:1年,到期需年审 │ +│ │ +└──────────────────────────────────────────────────────────────┘ +``` + +### 认证材料清单 + +| 材料 | 必需 | 说明 | +|------|------|------| +| 企业营业执照 | ✅ | 扫描件或照片,信息清晰 | +| 法人身份证 | ✅ | 正反面照片 | +| 法人微信号 | ✅ | 需绑定银行卡,用于扫码验证 | +| 联系人手机号 | ✅ | 接收审核通知 | +| 认证费用 | ✅ | 300元/年 | +| 其他资质 | 可选 | 特殊行业需要(如医疗、金融) | + +### 认证状态说明 + +| 状态 | 说明 | 下一步操作 | +|------|------|------------| +| `unknown` | 未知/未检查 | 运行 `cert-status` 检查 | +| `pending` | 审核中 | 等待1-5个工作日 | +| `verified` | 已认证 | 可以正常发布 | +| `rejected` | 被拒绝 | 查看原因,修改后重新提交 | +| `expired` | 已过期 | 需要重新认证(年审) | + +### 认证API(第三方平台) + +如果你有第三方平台资质,可以通过API代商家提交认证: + +```python +# POST https://api.weixin.qq.com/wxa/sec/wxaauth?access_token=ACCESS_TOKEN +{ + "auth_type": 1, # 1=企业 + "auth_data": { + "name": "企业名称", + "code": "统一社会信用代码", + "legal_persona_wechat": "法人微信号", + "legal_persona_name": "法人姓名", + "legal_persona_idcard": "法人身份证号", + "component_phone": "联系电话" + } +} +``` + +--- + +## 🔧 GitHub开源工具推荐 + +### 1. miniprogram-ci(官方) + +微信官方提供的CI工具,支持Node.js环境使用。 + +**安装**: +```bash +npm install miniprogram-ci -g +``` + +**使用**: +```javascript +const ci = require('miniprogram-ci'); + +const project = new ci.Project({ + appid: 'wxb8bbb2b10dec74aa', + type: 'miniProgram', + projectPath: '/path/to/miniprogram', + privateKeyPath: '/path/to/private.key', + ignores: ['node_modules/**/*'] +}); + +// 上传 +await ci.upload({ + project, + version: '1.0.0', + desc: '版本描述', + setting: { + es6: true, + minify: true + } +}); +``` + +**获取私钥**: +1. 登录小程序后台 +2. 开发管理 → 开发设置 +3. 小程序代码上传密钥 → 下载 + +### 2. multi-mini-ci + +多平台小程序自动化上传工具。 + +**GitHub**: https://github.com/Ethan-zjc/multi-mini-ci + +**支持平台**: +- 微信小程序 +- 支付宝小程序 +- 百度小程序 +- 字节跳动小程序 + +### 3. GitHub Actions集成 + +在项目中创建 `.github/workflows/deploy.yml`: + +```yaml +name: Deploy MiniProgram + +on: + push: + branches: [main] + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Setup Node.js + uses: actions/setup-node@v3 + with: + node-version: '18' + + - name: Install dependencies + run: npm install + + - name: Build + run: npm run build + + - name: Upload to WeChat + env: + PRIVATE_KEY: ${{ secrets.MINIPROGRAM_PRIVATE_KEY }} + run: | + echo "$PRIVATE_KEY" > private.key + npx miniprogram-ci upload \ + --pp ./dist \ + --pkp ./private.key \ + --appid wxb8bbb2b10dec74aa \ + --uv "1.0.${{ github.run_number }}" \ + -r 1 \ + --desc "CI auto deploy" +``` + +--- + +## 📁 完整文件结构(v3.0) + +``` +小程序管理/ +├── SKILL.md # 技能说明文档(本文件) +├── scripts/ +│ ├── mp_full.py # 全能管理工具(推荐)⭐ +│ ├── mp_deploy.py # 部署工具(多小程序管理) +│ ├── mp_manager.py # API管理工具(基础版) +│ ├── mp_api.py # API封装类(Python SDK) +│ ├── apps_config.json # 多小程序配置文件 +│ ├── requirements.txt # Python依赖 +│ ├── env_template.txt # 环境变量模板 +│ └── reports/ # 检查报告存放目录 +│ ├── summary_*.json # 汇总报告 +│ └── report_*.json # 项目报告 +└── references/ + ├── API接口速查表.md # 常用API速查 + ├── 企业认证完整指南.md # 认证操作指南 + ├── 隐私协议填写指南.md # 隐私协议配置指南 + └── 审核规范.md # 审核常见问题 +``` + +### 脚本功能对比 + +| 脚本 | 功能 | 推荐场景 | +|------|------|----------| +| **mp_full.py** | 全能:检查+报告+自动部署 | 日常管理(推荐) | +| **mp_deploy.py** | 多小程序管理+认证 | 多项目管理 | +| **mp_manager.py** | API调用工具 | 高级操作 | +| **mp_api.py** | Python SDK | 二次开发 | + +--- + +## 📊 多小程序配置 + +配置文件位于 `scripts/apps_config.json`: + +```json +{ + "apps": [ + { + "id": "soul-party", + "name": "Soul派对", + "appid": "wxb8bbb2b10dec74aa", + "project_path": "/path/to/miniprogram", + "certification": { + "status": "verified", + "enterprise_name": "厦门智群网络科技有限公司" + } + }, + { + "id": "another-app", + "name": "另一个小程序", + "appid": "wx1234567890", + "project_path": "/path/to/another", + "certification": { + "status": "pending" + } + } + ], + "certification_materials": { + "enterprise_name": "厦门智群网络科技有限公司", + "license_number": "统一社会信用代码", + "legal_persona_name": "法人姓名", + "component_phone": "15880802661" + } +} +``` + +--- + +## ⚡ 常见场景速查 + +### 场景1:发布时提示"未完成微信认证" + +```bash +# 1. 检查认证状态 +python3 mp_deploy.py cert-status soul-party + +# 2. 如果未认证,查看认证指引 +python3 mp_deploy.py cert soul-party + +# 3. 在微信后台完成认证后,标记完成 +python3 mp_deploy.py cert-done soul-party + +# 4. 重新部署 +python3 mp_deploy.py deploy soul-party +``` + +### 场景2:新建小程序并快速上线 + +```bash +# 1. 添加小程序配置 +python3 mp_deploy.py add + +# 2. 提交认证 +python3 mp_deploy.py cert my-new-app + +# 3. 在微信后台完成认证(1-5天) + +# 4. 认证通过后标记 +python3 mp_deploy.py cert-done my-new-app + +# 5. 一键部署 +python3 mp_deploy.py deploy my-new-app + +# 6. 审核通过后发布 +python3 mp_deploy.py release my-new-app +``` + +### 场景3:仅更新代码(不提审) + +```bash +# 快速上传到开发版 +python3 mp_deploy.py upload soul-party -v "1.0.5" -d "修复xxx问题" +``` + +### 场景4:批量管理多个小程序 + +```bash +# 查看所有小程序 +python3 mp_deploy.py list + +# 检查所有认证状态 +for app in soul-party another-app third-app; do + echo "=== $app ===" + python3 mp_deploy.py cert-status $app +done +``` + +--- + +## 🔗 相关资源 + +### 官方文档 +- [微信开放平台](https://developers.weixin.qq.com/doc/oplatform/) +- [小程序CI工具](https://developers.weixin.qq.com/miniprogram/dev/devtools/ci.html) +- [第三方平台代认证](https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/product/weapp_wxverify.html) + +### 开源项目 +- [miniprogram-ci](https://www.npmjs.com/package/miniprogram-ci) - 官方CI工具 +- [multi-mini-ci](https://github.com/Ethan-zjc/multi-mini-ci) - 多平台上传 +- [uz-miniprogram-ci](https://github.com/uzhan/uz-miniprogram-ci) - 一键上传发布 + +### 相关文章 +- [GitHub Actions集成小程序CI](https://idayer.com/use-github-actions-and-mp-ci-for-wechat-miniprogram-ci/) + +--- + +## 🔥 实战经验库(持续更新) + +> 基于 Soul创业派对 项目开发过程中的真实问题和解决方案 + +### 一、数据库与后端问题 + +#### 1.1 后台初始化失败:Unknown column 'password' in 'field list' + +**问题现象**:后台用户管理显示"初始化失败" + +**根本原因**:数据库表结构缺少字段 + +**解决方案**:创建数据库初始化API自动修复 + +```typescript +// app/api/db/init/route.ts +// 自动检查并添加缺失字段 +const columnsToAdd = [ + { name: 'password', type: 'VARCHAR(100)' }, + { name: 'session_key', type: 'VARCHAR(100)' }, + { name: 'referred_by', type: 'VARCHAR(50)' }, + { name: 'is_admin', type: 'BOOLEAN DEFAULT FALSE' }, +] + +for (const col of columnsToAdd) { + // 检查列是否存在,不存在则添加 + await query(`ALTER TABLE users ADD COLUMN ${col.name} ${col.type}`) +} +``` + +**访问修复**:`curl https://your-domain.com/api/db/init` + +--- + +#### 1.2 Column 'open_id' cannot be null + +**问题现象**:后台添加用户失败 + +**根本原因**:数据库 `open_id` 字段设置为 NOT NULL,但后台添加用户时没有openId + +**解决方案**: +```sql +ALTER TABLE users MODIFY COLUMN open_id VARCHAR(100) NULL +``` + +**最佳实践**:openId允许为NULL,因为: +- 后台手动添加的用户没有openId +- 微信登录用户有openId +- 两种用户需要共存 + +--- + +#### 1.3 AppID配置不一致 + +**问题现象**:微信登录返回错误,或获取openId失败 + +**根本原因**:项目中多个文件使用了不同的AppID + +**检查清单**: + +| 文件 | 配置项 | 正确值 | +|:---|:---|:---| +| `miniprogram/project.config.json` | appid | wxb8bbb2b10dec74aa | +| `app/api/miniprogram/login/route.ts` | MINIPROGRAM_CONFIG.appId | wxb8bbb2b10dec74aa | +| `app/api/wechat/login/route.ts` | APPID | wxb8bbb2b10dec74aa | +| `app/api/withdraw/route.ts` | WECHAT_PAY_CONFIG.appId | wxb8bbb2b10dec74aa | + +**搜索命令**: +```bash +# 查找所有AppID配置 +rg "wx[a-f0-9]{16}" --type ts --type json +``` + +--- + +#### 1.4 用户ID设计最佳实践 + +**推荐方案**:使用 `openId` 作为用户主键 + +```typescript +// 微信登录创建用户 +const userId = openId // 直接使用openId作为用户ID +await query(` + INSERT INTO users (id, open_id, ...) VALUES (?, ?, ...) +`, [userId, openId, ...]) +``` + +**优势**: +- 与微信官方标识一致 +- 便于追踪和管理 +- 后台显示更直观 + +**兼容方案**:后台添加的用户使用 `user_` 前缀 + +--- + +### 二、前端与UI问题 + +#### 2.1 Next.js Hydration错误 + +**问题现象**:页面显示"哎呀,出错了",控制台报 hydration 错误 + +**根本原因**:服务端和客户端渲染结果不一致(如使用localStorage、zustand持久化) + +**解决方案**:添加mounted状态检查 + +```tsx +export default function AdminLayout({ children }) { + const [mounted, setMounted] = useState(false) + + useEffect(() => { + setMounted(true) + }, []) + + // 等待客户端mount后再渲染 + if (!mounted) { + return
      加载中...
      + } + + return
      {children}
      +} +``` + +--- + +#### 2.2 数据类型不匹配:toFixed() 报错 + +**问题现象**:显示金额时报错 `toFixed is not a function` + +**根本原因**:数据库返回的 `DECIMAL` 字段是字符串类型 + +**解决方案**: +```tsx +// ❌ 错误 +
      {user.earnings.toFixed(2)}
      + +// ✅ 正确 +
      {parseFloat(String(user.earnings || 0)).toFixed(2)}
      +``` + +**通用处理函数**: +```typescript +const formatMoney = (value: any) => { + return parseFloat(String(value || 0)).toFixed(2) +} +``` + +--- + +### 三、小程序开发问题 + +#### 3.1 搜索功能:章节ID格式不一致 + +**问题现象**:搜索结果跳转到阅读页404 + +**根本原因**: +- `book-chapters.json` 使用 `chapter-2`, `chapter-3` 格式 +- 阅读页使用 `1.1`, `1.2` 格式 + +**解决方案**:从标题提取章节号 + +```typescript +// 从标题提取章节号(如 "1.1 荷包:..." → "1.1") +const sectionIdMatch = chapter.title?.match(/^(\d+\.\d+)\s/) +const sectionId = sectionIdMatch ? sectionIdMatch[1] : chapter.id +``` + +--- + +#### 3.2 搜索功能:敏感信息过滤 + +**需求**:搜索结果不能显示用户手机号、微信号等 + +**实现**: +```typescript +const cleanContent = content + .replace(/1[3-9]\d{9}/g, '***') // 手机号 + .replace(/微信[::]\s*\S+/g, '微信:***') // 微信号 + .replace(/QQ[::]\s*\d+/g, 'QQ:***') // QQ号 + .replace(/邮箱[::]\s*\S+@\S+/g, '邮箱:***') // 邮箱 +``` + +--- + +#### 3.3 上下章导航:付费内容也需要显示 + +**需求**:即使用户没有购买,也要显示上一篇/下一篇导航 + +**实现**:将导航组件移到付费墙之外 + +```html + + + + + + + + 上一篇 + 下一篇 + +``` + +--- + +#### 3.4 分销绑定:推广码捕获 + +**需求**:用户通过分享链接进入时,自动绑定推广者 + +**实现流程**: + +```javascript +// app.js - onLaunch/onShow +onLaunch(options) { + if (options.query && options.query.ref) { + wx.setStorageSync('referral_code', options.query.ref) + this.bindReferral(options.query.ref) + } +} + +// 小程序码scene参数解析 +const scene = decodeURIComponent(options.scene) +const params = new URLSearchParams(scene) +const ref = params.get('ref') +``` + +**后端绑定**: +```sql +UPDATE users SET referred_by = ? WHERE id = ? AND referred_by IS NULL +``` + +--- + +### 四、后台管理优化 + +#### 4.1 菜单精简原则 + +**优化前(9项)**: +- 数据概览、网站配置、内容管理、用户管理、匹配配置、分销管理、支付配置、分账提现、二维码、系统设置 + +**优化后(6项)**: +- 数据概览、内容管理、用户管理、分账管理、支付设置、系统设置 + +**精简原则**: +1. 合并相似功能(分销管理 + 分账提现 → 分账管理) +2. 移除低频功能(二维码、匹配配置 → 可在系统设置中配置) +3. 核心功能优先 + +--- + +#### 4.2 用户绑定关系展示 + +**需求**:查看用户的推广下线详情 + +**实现API**: +```typescript +// GET /api/db/users/referrals?userId=xxx +const referrals = await query(` + SELECT * FROM users WHERE referred_by = ? + ORDER BY created_at DESC +`, [referralCode]) +``` + +**展示信息**: +- 绑定总数、已付费人数、免费用户 +- 累计收益、待提现金额 +- 每个绑定用户的状态(VIP/已付费/未付费) + +--- + +### 五、分销与提现 + +#### 5.1 自动分账规则 + +| 配置项 | 值 | 说明 | +|:---|:---|:---| +| 分销比例 | 90% | 推广者获得订单金额的90% | +| 结算方式 | 自动 | 用户付款后立即计入推广者账户 | +| 提现方式 | 微信零钱 | 企业付款到零钱 | +| 提现门槛 | 1元 | 累计收益≥1元可提现 | + +#### 5.2 提现流程 + +``` +用户申请提现 + ↓ +扣除账户余额,增加待提现金额 + ↓ +管理员后台审核 + ↓ +批准 → 调用微信企业付款API → 到账 +拒绝 → 返还用户余额 +``` + +--- + +### 六、开发规范 + +#### 6.1 配置统一管理 + +```typescript +// lib/config.ts +export const WECHAT_CONFIG = { + appId: process.env.WECHAT_APPID || 'wxb8bbb2b10dec74aa', + appSecret: process.env.WECHAT_APPSECRET || '...', + mchId: '1318592501', + apiKey: '...' +} +``` + +**所有API文件统一引用此配置,避免硬编码** + +#### 6.2 数据库字段命名 + +| 前端字段 | 数据库字段 | 说明 | +|:---|:---|:---| +| openId | open_id | 微信openId | +| hasFullBook | has_full_book | 是否购买全书 | +| referralCode | referral_code | 推广码 | +| pendingEarnings | pending_earnings | 待提现收益 | + +**规则**:数据库使用snake_case,前端使用camelCase + +#### 6.3 错误处理模板 + +```typescript +export async function POST(request: Request) { + try { + const body = await request.json() + // 业务逻辑 + return NextResponse.json({ success: true, data: ... }) + } catch (error) { + console.error('[API名称] 错误:', error) + return NextResponse.json({ + success: false, + error: '用户友好的错误信息' + }, { status: 500 }) + } +} +``` + +--- + +## 📌 问题排查清单 + +### 小程序无法登录 + +- [ ] 检查AppID是否正确(project.config.json vs 后端) +- [ ] 检查AppSecret是否正确 +- [ ] 检查API域名是否已配置 +- [ ] 检查后端服务是否正常运行 +- [ ] 查看后端日志 `[MiniLogin]` + +### 后台显示异常 + +- [ ] 运行 `/api/db/init` 初始化数据库 +- [ ] 检查数据库连接是否正常 +- [ ] 清除浏览器缓存(Cmd+Shift+R) +- [ ] 查看浏览器控制台错误 + +### 搜索功能无结果 + +- [ ] 检查 `public/book-chapters.json` 是否存在 +- [ ] 检查章节文件路径是否正确(filePath字段) +- [ ] 检查关键词编码(中文需URL编码) + +### 提现失败 + +- [ ] 检查用户余额是否充足 +- [ ] 检查用户是否有openId +- [ ] 检查微信商户API证书配置 +- [ ] 查看后端日志 `[Withdraw]` + +--- + +**创建时间**:2026-01-25 +**更新时间**:2026-01-25 +**版本**:v3.1(新增实战经验库) +**维护者**:卡若 diff --git a/开发文档/小程序管理/references/审核与认证.md b/开发文档/小程序管理/references/审核与认证.md new file mode 100644 index 00000000..fd495184 --- /dev/null +++ b/开发文档/小程序管理/references/审核与认证.md @@ -0,0 +1,3 @@ +# 审核与认证(合并自 API速查、企业认证、审核规范、隐私协议) + +API 接口速查、企业认证完整指南、审核规范、隐私协议填写指南。详见原各文档。 diff --git a/开发文档/小程序管理/scripts/__pycache__/mp_api.cpython-314.pyc b/开发文档/小程序管理/scripts/__pycache__/mp_api.cpython-314.pyc new file mode 100644 index 00000000..17805a5a Binary files /dev/null and b/开发文档/小程序管理/scripts/__pycache__/mp_api.cpython-314.pyc differ diff --git a/开发文档/小程序管理/scripts/apps_config.json b/开发文档/小程序管理/scripts/apps_config.json new file mode 100644 index 00000000..eeb0a7d5 --- /dev/null +++ b/开发文档/小程序管理/scripts/apps_config.json @@ -0,0 +1,40 @@ +{ + "_comment": "小程序配置文件 - 支持管理多个小程序", + "apps": [ + { + "id": "soul-party", + "name": "Soul派对", + "appid": "wxb8bbb2b10dec74aa", + "project_path": "/Users/karuo/Documents/开发/3、自营项目/一场soul的创业实验/miniprogram", + "private_key_path": "", + "api_domain": "https://soul.quwanzhi.com", + "description": "一场SOUL的创业实验场", + "certification": { + "status": "pending", + "enterprise_name": "泉州市卡若网络技术有限公司", + "license_number": "", + "legal_persona_name": "", + "legal_persona_wechat": "", + "component_phone": "15880802661" + } + } + ], + "certification_materials": { + "_comment": "企业认证通用材料(所有小程序共用)", + "enterprise_name": "泉州市卡若网络技术有限公司", + "license_number": "", + "license_media_id": "", + "legal_persona_name": "", + "legal_persona_wechat": "", + "legal_persona_idcard": "", + "component_phone": "15880802661", + "contact_email": "zhiqun@qq.com" + }, + "third_party_platform": { + "_comment": "第三方平台配置(用于代认证)", + "component_appid": "", + "component_appsecret": "", + "component_verify_ticket": "", + "authorized": false + } +} diff --git a/开发文档/小程序管理/scripts/env_template.txt b/开发文档/小程序管理/scripts/env_template.txt new file mode 100644 index 00000000..9f7686d6 --- /dev/null +++ b/开发文档/小程序管理/scripts/env_template.txt @@ -0,0 +1,30 @@ +# 微信小程序管理 - 环境变量配置 +# 复制此文件为 .env 并填入实际值 + +# ==================== 方式一:直接使用 access_token ==================== +# 如果你已经有 access_token,直接填入即可(适合快速测试) +ACCESS_TOKEN=你的access_token + +# ==================== 方式二:使用第三方平台凭证 ==================== +# 如果你有第三方平台资质,填入以下信息可自动刷新token + +# 第三方平台 AppID +COMPONENT_APPID=你的第三方平台AppID + +# 第三方平台密钥 +COMPONENT_APPSECRET=你的第三方平台密钥 + +# 授权小程序 AppID(要管理的小程序) +AUTHORIZER_APPID=wxb8bbb2b10dec74aa + +# 授权刷新令牌(从授权回调中获取) +AUTHORIZER_REFRESH_TOKEN=授权时获取的refresh_token + +# ==================== 小程序项目路径 ==================== +# 用于 CLI 工具操作 +MINIPROGRAM_PATH=/Users/karuo/Documents/开发/3、自营项目/一场soul的创业实验/miniprogram + +# ==================== 可选配置 ==================== +# 隐私协议联系方式(用于快速配置) +CONTACT_EMAIL=zhiqun@qq.com +CONTACT_PHONE=15880802661 diff --git a/开发文档/小程序管理/scripts/mp_api.py b/开发文档/小程序管理/scripts/mp_api.py new file mode 100644 index 00000000..61fae3ae --- /dev/null +++ b/开发文档/小程序管理/scripts/mp_api.py @@ -0,0 +1,635 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +""" +微信小程序管理API封装 +支持:注册、配置、代码管理、审核、发布、数据分析 +""" + +import os +import json +import time +import httpx +from typing import Optional, Dict, Any, List +from dataclasses import dataclass +from pathlib import Path + +# 尝试加载dotenv(可选依赖) +try: + from dotenv import load_dotenv + load_dotenv() +except ImportError: + pass # dotenv不是必需的 + + +@dataclass +class MiniProgramInfo: + """小程序基础信息""" + appid: str + nickname: str + head_image_url: str + signature: str + principal_name: str + realname_status: int # 1=已认证 + + +@dataclass +class AuditStatus: + """审核状态""" + auditid: int + status: int # 0=成功,1=被拒,2=审核中,3=已撤回,4=延后 + reason: Optional[str] = None + screenshot: Optional[str] = None + + @property + def status_text(self) -> str: + status_map = { + 0: "✅ 审核成功", + 1: "❌ 审核被拒", + 2: "⏳ 审核中", + 3: "↩️ 已撤回", + 4: "⏸️ 审核延后" + } + return status_map.get(self.status, "未知状态") + + +class MiniProgramAPI: + """微信小程序管理API""" + + BASE_URL = "https://api.weixin.qq.com" + + def __init__( + self, + component_appid: Optional[str] = None, + component_appsecret: Optional[str] = None, + authorizer_appid: Optional[str] = None, + access_token: Optional[str] = None + ): + """ + 初始化API + + Args: + component_appid: 第三方平台AppID + component_appsecret: 第三方平台密钥 + authorizer_appid: 授权小程序AppID + access_token: 直接使用的access_token(如已获取) + """ + self.component_appid = component_appid or os.getenv("COMPONENT_APPID") + self.component_appsecret = component_appsecret or os.getenv("COMPONENT_APPSECRET") + self.authorizer_appid = authorizer_appid or os.getenv("AUTHORIZER_APPID") + self._access_token = access_token or os.getenv("ACCESS_TOKEN") + self._token_expires_at = 0 + + self.client = httpx.Client(timeout=30.0) + + @property + def access_token(self) -> str: + """获取access_token,如果过期则刷新""" + if self._access_token and time.time() < self._token_expires_at: + return self._access_token + + # 如果没有配置刷新token的信息,直接返回现有token + if not self.component_appid: + return self._access_token or "" + + # TODO: 实现token刷新逻辑 + return self._access_token or "" + + def set_access_token(self, token: str, expires_in: int = 7200): + """手动设置access_token""" + self._access_token = token + self._token_expires_at = time.time() + expires_in - 300 # 提前5分钟过期 + + def _request( + self, + method: str, + path: str, + params: Optional[Dict] = None, + json_data: Optional[Dict] = None, + **kwargs + ) -> Dict[str, Any]: + """发起API请求""" + url = f"{self.BASE_URL}{path}" + + # 添加access_token + if params is None: + params = {} + if "access_token" not in params: + params["access_token"] = self.access_token + + if method.upper() == "GET": + resp = self.client.get(url, params=params, **kwargs) + else: + resp = self.client.post(url, params=params, json=json_data, **kwargs) + + # 解析响应 + try: + result = resp.json() + except json.JSONDecodeError: + # 可能是二进制数据(如图片) + return {"_binary": resp.content} + + # 检查错误 + if result.get("errcode", 0) != 0: + raise APIError(result.get("errcode"), result.get("errmsg", "Unknown error")) + + return result + + # ==================== 基础信息 ==================== + + def get_basic_info(self) -> MiniProgramInfo: + """获取小程序基础信息""" + result = self._request("POST", "/cgi-bin/account/getaccountbasicinfo") + return MiniProgramInfo( + appid=result.get("appid", ""), + nickname=result.get("nickname", ""), + head_image_url=result.get("head_image_url", ""), + signature=result.get("signature", ""), + principal_name=result.get("principal_name", ""), + realname_status=result.get("realname_status", 0) + ) + + def modify_signature(self, signature: str) -> bool: + """修改简介(4-120字)""" + self._request("POST", "/cgi-bin/account/modifysignature", json_data={ + "signature": signature + }) + return True + + # ==================== 域名配置 ==================== + + def get_domain(self) -> Dict[str, List[str]]: + """获取服务器域名配置""" + result = self._request("POST", "/wxa/modify_domain", json_data={ + "action": "get" + }) + return { + "requestdomain": result.get("requestdomain", []), + "wsrequestdomain": result.get("wsrequestdomain", []), + "uploaddomain": result.get("uploaddomain", []), + "downloaddomain": result.get("downloaddomain", []) + } + + def set_domain( + self, + requestdomain: Optional[List[str]] = None, + wsrequestdomain: Optional[List[str]] = None, + uploaddomain: Optional[List[str]] = None, + downloaddomain: Optional[List[str]] = None + ) -> bool: + """设置服务器域名""" + data = {"action": "set"} + if requestdomain: + data["requestdomain"] = requestdomain + if wsrequestdomain: + data["wsrequestdomain"] = wsrequestdomain + if uploaddomain: + data["uploaddomain"] = uploaddomain + if downloaddomain: + data["downloaddomain"] = downloaddomain + + self._request("POST", "/wxa/modify_domain", json_data=data) + return True + + def get_webview_domain(self) -> List[str]: + """获取业务域名""" + result = self._request("POST", "/wxa/setwebviewdomain", json_data={ + "action": "get" + }) + return result.get("webviewdomain", []) + + def set_webview_domain(self, webviewdomain: List[str]) -> bool: + """设置业务域名""" + self._request("POST", "/wxa/setwebviewdomain", json_data={ + "action": "set", + "webviewdomain": webviewdomain + }) + return True + + # ==================== 隐私协议 ==================== + + def get_privacy_setting(self, privacy_ver: int = 2) -> Dict[str, Any]: + """获取隐私协议设置""" + result = self._request("POST", "/cgi-bin/component/getprivacysetting", json_data={ + "privacy_ver": privacy_ver + }) + return result + + def set_privacy_setting( + self, + setting_list: List[Dict[str, str]], + contact_email: Optional[str] = None, + contact_phone: Optional[str] = None, + notice_method: str = "弹窗提示" + ) -> bool: + """ + 设置隐私协议 + + Args: + setting_list: 隐私配置列表,如 [{"privacy_key": "UserInfo", "privacy_text": "用于展示头像"}] + contact_email: 联系邮箱 + contact_phone: 联系电话 + notice_method: 告知方式 + """ + data = { + "privacy_ver": 2, + "setting_list": setting_list + } + + owner_setting = {"notice_method": notice_method} + if contact_email: + owner_setting["contact_email"] = contact_email + if contact_phone: + owner_setting["contact_phone"] = contact_phone + data["owner_setting"] = owner_setting + + self._request("POST", "/cgi-bin/component/setprivacysetting", json_data=data) + return True + + # ==================== 类目管理 ==================== + + def get_all_categories(self) -> List[Dict]: + """获取可选类目列表""" + result = self._request("GET", "/cgi-bin/wxopen/getallcategories") + return result.get("categories_list", {}).get("categories", []) + + def get_category(self) -> List[Dict]: + """获取已设置的类目""" + result = self._request("GET", "/cgi-bin/wxopen/getcategory") + return result.get("categories", []) + + def add_category(self, categories: List[Dict]) -> bool: + """ + 添加类目 + + Args: + categories: 类目列表,如 [{"first": 1, "second": 2}] + """ + self._request("POST", "/cgi-bin/wxopen/addcategory", json_data={ + "categories": categories + }) + return True + + def delete_category(self, first: int, second: int) -> bool: + """删除类目""" + self._request("POST", "/cgi-bin/wxopen/deletecategory", json_data={ + "first": first, + "second": second + }) + return True + + # ==================== 代码管理 ==================== + + def commit_code( + self, + template_id: int, + user_version: str, + user_desc: str, + ext_json: Optional[str] = None + ) -> bool: + """ + 上传代码 + + Args: + template_id: 代码模板ID + user_version: 版本号 + user_desc: 版本描述 + ext_json: 扩展配置JSON字符串 + """ + data = { + "template_id": template_id, + "user_version": user_version, + "user_desc": user_desc + } + if ext_json: + data["ext_json"] = ext_json + + self._request("POST", "/wxa/commit", json_data=data) + return True + + def get_page(self) -> List[str]: + """获取已上传代码的页面列表""" + result = self._request("GET", "/wxa/get_page") + return result.get("page_list", []) + + def get_qrcode(self, path: Optional[str] = None) -> bytes: + """ + 获取体验版二维码 + + Args: + path: 页面路径,如 "pages/index/index" + + Returns: + 二维码图片二进制数据 + """ + params = {"access_token": self.access_token} + if path: + params["path"] = path + + resp = self.client.get(f"{self.BASE_URL}/wxa/get_qrcode", params=params) + return resp.content + + # ==================== 审核管理 ==================== + + def submit_audit( + self, + item_list: Optional[List[Dict]] = None, + version_desc: Optional[str] = None, + feedback_info: Optional[str] = None + ) -> int: + """ + 提交审核 + + Args: + item_list: 页面审核信息列表 + version_desc: 版本说明 + feedback_info: 反馈内容 + + Returns: + 审核单ID + """ + data = {} + if item_list: + data["item_list"] = item_list + if version_desc: + data["version_desc"] = version_desc + if feedback_info: + data["feedback_info"] = feedback_info + + result = self._request("POST", "/wxa/submit_audit", json_data=data) + return result.get("auditid", 0) + + def get_audit_status(self, auditid: int) -> AuditStatus: + """查询审核状态""" + result = self._request("POST", "/wxa/get_auditstatus", json_data={ + "auditid": auditid + }) + return AuditStatus( + auditid=auditid, + status=result.get("status", -1), + reason=result.get("reason"), + screenshot=result.get("screenshot") + ) + + def get_latest_audit_status(self) -> AuditStatus: + """查询最新审核状态""" + result = self._request("GET", "/wxa/get_latest_auditstatus") + return AuditStatus( + auditid=result.get("auditid", 0), + status=result.get("status", -1), + reason=result.get("reason"), + screenshot=result.get("screenshot") + ) + + def undo_code_audit(self) -> bool: + """撤回审核(每天限1次)""" + self._request("GET", "/wxa/undocodeaudit") + return True + + # ==================== 发布管理 ==================== + + def release(self) -> bool: + """发布已审核通过的版本""" + self._request("POST", "/wxa/release", json_data={}) + return True + + def revert_code_release(self) -> bool: + """版本回退(只能回退到上一版本)""" + self._request("GET", "/wxa/revertcoderelease") + return True + + def get_revert_history(self) -> List[Dict]: + """获取可回退版本历史""" + result = self._request("GET", "/wxa/revertcoderelease", params={ + "action": "get_history_version" + }) + return result.get("version_list", []) + + def gray_release(self, gray_percentage: int) -> bool: + """ + 分阶段发布 + + Args: + gray_percentage: 灰度比例 1-100 + """ + self._request("POST", "/wxa/grayrelease", json_data={ + "gray_percentage": gray_percentage + }) + return True + + # ==================== 小程序码 ==================== + + def get_wxacode( + self, + path: str, + width: int = 430, + auto_color: bool = False, + line_color: Optional[Dict[str, int]] = None, + is_hyaline: bool = False + ) -> bytes: + """ + 获取小程序码(有限制,每个path最多10万个) + + Args: + path: 页面路径,如 "pages/index/index?id=123" + width: 宽度 280-1280 + auto_color: 自动配置线条颜色 + line_color: 线条颜色 {"r": 0, "g": 0, "b": 0} + is_hyaline: 是否透明背景 + + Returns: + 二维码图片二进制数据 + """ + data = { + "path": path, + "width": width, + "auto_color": auto_color, + "is_hyaline": is_hyaline + } + if line_color: + data["line_color"] = line_color + + resp = self.client.post( + f"{self.BASE_URL}/wxa/getwxacode", + params={"access_token": self.access_token}, + json=data + ) + return resp.content + + def get_wxacode_unlimit( + self, + scene: str, + page: Optional[str] = None, + width: int = 430, + auto_color: bool = False, + line_color: Optional[Dict[str, int]] = None, + is_hyaline: bool = False + ) -> bytes: + """ + 获取无限小程序码(推荐) + + Args: + scene: 场景值,最长32字符,如 "user_id=123&from=share" + page: 页面路径,必须是已发布的页面 + width: 宽度 280-1280 + auto_color: 自动配置线条颜色 + line_color: 线条颜色 {"r": 0, "g": 0, "b": 0} + is_hyaline: 是否透明背景 + + Returns: + 二维码图片二进制数据 + """ + data = { + "scene": scene, + "width": width, + "auto_color": auto_color, + "is_hyaline": is_hyaline + } + if page: + data["page"] = page + if line_color: + data["line_color"] = line_color + + resp = self.client.post( + f"{self.BASE_URL}/wxa/getwxacodeunlimit", + params={"access_token": self.access_token}, + json=data + ) + return resp.content + + def gen_short_link( + self, + page_url: str, + page_title: str, + is_permanent: bool = False + ) -> str: + """ + 生成小程序短链接 + + Args: + page_url: 页面路径,如 "pages/index/index?id=123" + page_title: 页面标题 + is_permanent: 是否永久有效 + + Returns: + 短链接 + """ + result = self._request("POST", "/wxa/genwxashortlink", json_data={ + "page_url": page_url, + "page_title": page_title, + "is_permanent": is_permanent + }) + return result.get("link", "") + + # ==================== 数据分析 ==================== + + def get_daily_visit_trend(self, begin_date: str, end_date: str) -> List[Dict]: + """ + 获取每日访问趋势 + + Args: + begin_date: 开始日期 YYYYMMDD + end_date: 结束日期 YYYYMMDD + """ + result = self._request( + "POST", + "/datacube/getweanalysisappiddailyvisittrend", + json_data={"begin_date": begin_date, "end_date": end_date} + ) + return result.get("list", []) + + def get_user_portrait(self, begin_date: str, end_date: str) -> Dict: + """ + 获取用户画像 + + Args: + begin_date: 开始日期 YYYYMMDD + end_date: 结束日期 YYYYMMDD + """ + result = self._request( + "POST", + "/datacube/getweanalysisappiduserportrait", + json_data={"begin_date": begin_date, "end_date": end_date} + ) + return result + + # ==================== API配额 ==================== + + def get_api_quota(self, cgi_path: str) -> Dict: + """ + 查询接口调用额度 + + Args: + cgi_path: 接口路径,如 "/wxa/getwxacode" + """ + result = self._request("POST", "/cgi-bin/openapi/quota/get", json_data={ + "cgi_path": cgi_path + }) + return result.get("quota", {}) + + def clear_quota(self, appid: Optional[str] = None) -> bool: + """重置接口调用次数(每月限10次)""" + self._request("POST", "/cgi-bin/clear_quota", json_data={ + "appid": appid or self.authorizer_appid + }) + return True + + def close(self): + """关闭连接""" + self.client.close() + + def __enter__(self): + return self + + def __exit__(self, exc_type, exc_val, exc_tb): + self.close() + + +class APIError(Exception): + """API错误""" + + ERROR_CODES = { + -1: "系统繁忙", + 40001: "access_token无效", + 40002: "grant_type不正确", + 40013: "appid不正确", + 40029: "code无效", + 40125: "appsecret不正确", + 41002: "缺少appid参数", + 41004: "缺少appsecret参数", + 42001: "access_token过期", + 42007: "refresh_token过期", + 45009: "调用超过限制", + 61039: "代码检测任务未完成,请稍后再试", + 85006: "标签格式错误", + 85007: "页面路径错误", + 85009: "已有审核版本,请先撤回", + 85010: "版本输入错误", + 85011: "当前版本不能回退", + 85012: "无效的版本", + 85015: "该账号已有发布中的版本", + 85019: "没有审核版本", + 85020: "审核状态异常", + 85064: "找不到模板", + 85085: "该小程序不能被操作", + 85086: "小程序没有绑定任何类目", + 87013: "每天只能撤回1次审核", + 89020: "该小程序尚未认证", + 89248: "隐私协议内容不完整", + } + + def __init__(self, code: int, message: str): + self.code = code + self.message = message + super().__init__(f"[{code}] {self.ERROR_CODES.get(code, message)}") + + +# 便捷函数 +def create_api_from_env() -> MiniProgramAPI: + """从环境变量创建API实例""" + return MiniProgramAPI() + + +if __name__ == "__main__": + # 测试 + api = create_api_from_env() + print("API初始化成功") diff --git a/开发文档/小程序管理/scripts/mp_deploy.py b/开发文档/小程序管理/scripts/mp_deploy.py new file mode 100644 index 00000000..22f859f4 --- /dev/null +++ b/开发文档/小程序管理/scripts/mp_deploy.py @@ -0,0 +1,725 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +""" +小程序一键部署工具 v2.0 + +功能: +- 多小程序管理 +- 一键部署上线 +- 自动认证提交 +- 认证状态检查 +- 材料有效性验证 + +使用方法: + python mp_deploy.py list # 列出所有小程序 + python mp_deploy.py add # 添加新小程序 + python mp_deploy.py deploy # 一键部署 + python mp_deploy.py cert # 提交认证 + python mp_deploy.py cert-status # 查询认证状态 + python mp_deploy.py upload # 上传代码 + python mp_deploy.py release # 发布上线 +""" + +import os +import sys +import json +import subprocess +import argparse +from datetime import datetime +from pathlib import Path +from typing import Optional, Dict, List, Any +from dataclasses import dataclass, asdict + +# 配置文件路径 +CONFIG_FILE = Path(__file__).parent / "apps_config.json" + + +@dataclass +class AppConfig: + """小程序配置""" + id: str + name: str + appid: str + project_path: str + private_key_path: str = "" + api_domain: str = "" + description: str = "" + certification: Dict = None + + def __post_init__(self): + if self.certification is None: + self.certification = { + "status": "unknown", + "enterprise_name": "", + "license_number": "", + "legal_persona_name": "", + "legal_persona_wechat": "", + "component_phone": "" + } + + +class ConfigManager: + """配置管理器""" + + def __init__(self, config_file: Path = CONFIG_FILE): + self.config_file = config_file + self.config = self._load_config() + + def _load_config(self) -> Dict: + """加载配置""" + if self.config_file.exists(): + with open(self.config_file, 'r', encoding='utf-8') as f: + return json.load(f) + return {"apps": [], "certification_materials": {}, "third_party_platform": {}} + + def _save_config(self): + """保存配置""" + with open(self.config_file, 'w', encoding='utf-8') as f: + json.dump(self.config, f, ensure_ascii=False, indent=2) + + def get_apps(self) -> List[AppConfig]: + """获取所有小程序""" + return [AppConfig(**app) for app in self.config.get("apps", [])] + + def get_app(self, app_id: str) -> Optional[AppConfig]: + """获取指定小程序""" + for app in self.config.get("apps", []): + if app["id"] == app_id or app["appid"] == app_id: + return AppConfig(**app) + return None + + def add_app(self, app: AppConfig): + """添加小程序""" + apps = self.config.get("apps", []) + # 检查是否已存在 + for i, existing in enumerate(apps): + if existing["id"] == app.id: + apps[i] = asdict(app) + self.config["apps"] = apps + self._save_config() + return + apps.append(asdict(app)) + self.config["apps"] = apps + self._save_config() + + def update_app(self, app_id: str, updates: Dict): + """更新小程序配置""" + apps = self.config.get("apps", []) + for i, app in enumerate(apps): + if app["id"] == app_id: + apps[i].update(updates) + self.config["apps"] = apps + self._save_config() + return True + return False + + def get_cert_materials(self) -> Dict: + """获取通用认证材料""" + return self.config.get("certification_materials", {}) + + def update_cert_materials(self, materials: Dict): + """更新认证材料""" + self.config["certification_materials"] = materials + self._save_config() + + +class MiniProgramDeployer: + """小程序部署器""" + + # 微信开发者工具CLI路径 + WX_CLI = "/Applications/wechatwebdevtools.app/Contents/MacOS/cli" + + def __init__(self): + self.config = ConfigManager() + + def _check_wx_cli(self) -> bool: + """检查微信开发者工具是否安装""" + return os.path.exists(self.WX_CLI) + + def _run_cli(self, *args, project_path: str = None) -> tuple: + """运行CLI命令""" + cmd = [self.WX_CLI] + list(args) + if project_path: + cmd.extend(["--project", project_path]) + + try: + result = subprocess.run(cmd, capture_output=True, text=True, timeout=120) + return result.returncode == 0, result.stdout + result.stderr + except subprocess.TimeoutExpired: + return False, "命令执行超时" + except Exception as e: + return False, str(e) + + def list_apps(self): + """列出所有小程序""" + apps = self.config.get_apps() + + if not apps: + print("\n📭 暂无配置的小程序") + print(" 运行 'python mp_deploy.py add' 添加小程序") + return + + print("\n" + "=" * 60) + print(" 📱 小程序列表") + print("=" * 60) + + for i, app in enumerate(apps, 1): + cert_status = app.certification.get("status", "unknown") + status_icon = { + "verified": "✅", + "pending": "⏳", + "rejected": "❌", + "expired": "⚠️", + "unknown": "❓" + }.get(cert_status, "❓") + + print(f"\n [{i}] {app.name}") + print(f" ID: {app.id}") + print(f" AppID: {app.appid}") + print(f" 认证: {status_icon} {cert_status}") + print(f" 路径: {app.project_path}") + + print("\n" + "-" * 60) + print(" 使用方法:") + print(" python mp_deploy.py deploy 一键部署") + print(" python mp_deploy.py cert 提交认证") + print("=" * 60 + "\n") + + def add_app(self): + """交互式添加小程序""" + print("\n" + "=" * 50) + print(" ➕ 添加新小程序") + print("=" * 50 + "\n") + + # 收集信息 + app_id = input("小程序ID(用于标识,如 my-app): ").strip() + if not app_id: + print("❌ ID不能为空") + return + + name = input("小程序名称: ").strip() + appid = input("AppID(如 wx1234567890): ").strip() + project_path = input("项目路径: ").strip() + + if not os.path.exists(project_path): + print(f"⚠️ 警告:路径不存在 {project_path}") + + api_domain = input("API域名(可选): ").strip() + description = input("描述(可选): ").strip() + + # 认证信息 + print("\n📋 认证信息(可稍后配置):") + enterprise_name = input("企业名称: ").strip() + + app = AppConfig( + id=app_id, + name=name, + appid=appid, + project_path=project_path, + api_domain=api_domain, + description=description, + certification={ + "status": "unknown", + "enterprise_name": enterprise_name, + "license_number": "", + "legal_persona_name": "", + "legal_persona_wechat": "", + "component_phone": "15880802661" + } + ) + + self.config.add_app(app) + print(f"\n✅ 小程序 [{name}] 添加成功!") + + def deploy(self, app_id: str, skip_cert_check: bool = False): + """一键部署流程""" + app = self.config.get_app(app_id) + if not app: + print(f"❌ 未找到小程序: {app_id}") + print(" 运行 'python mp_deploy.py list' 查看所有小程序") + return False + + print("\n" + "=" * 60) + print(f" 🚀 一键部署: {app.name}") + print("=" * 60) + + steps = [ + ("检查环境", self._step_check_env), + ("检查认证状态", lambda a: self._step_check_cert(a, skip_cert_check)), + ("编译项目", self._step_build), + ("上传代码", self._step_upload), + ("提交审核", self._step_submit_audit), + ] + + for step_name, step_func in steps: + print(f"\n📍 步骤: {step_name}") + print("-" * 40) + + success = step_func(app) + if not success: + print(f"\n❌ 部署中断于: {step_name}") + return False + + print("\n" + "=" * 60) + print(" 🎉 部署完成!") + print("=" * 60) + print(f"\n 下一步操作:") + print(f" 1. 等待审核(通常1-3个工作日)") + print(f" 2. 审核通过后运行: python mp_deploy.py release {app_id}") + print(f" 3. 查看状态: python mp_deploy.py status {app_id}") + + return True + + def _step_check_env(self, app: AppConfig) -> bool: + """检查环境""" + # 检查微信开发者工具 + if not self._check_wx_cli(): + print("❌ 未找到微信开发者工具") + print(" 请安装: https://developers.weixin.qq.com/miniprogram/dev/devtools/download.html") + return False + print("✅ 微信开发者工具已安装") + + # 检查项目路径 + if not os.path.exists(app.project_path): + print(f"❌ 项目路径不存在: {app.project_path}") + return False + print(f"✅ 项目路径存在") + + # 检查project.config.json + config_file = os.path.join(app.project_path, "project.config.json") + if os.path.exists(config_file): + with open(config_file, 'r') as f: + config = json.load(f) + if config.get("appid") != app.appid: + print(f"⚠️ 警告: project.config.json中的AppID与配置不一致") + print(f" 配置: {app.appid}") + print(f" 文件: {config.get('appid')}") + + print("✅ 环境检查通过") + return True + + def _step_check_cert(self, app: AppConfig, skip: bool = False) -> bool: + """检查认证状态""" + if skip: + print("⏭️ 跳过认证检查") + return True + + cert_status = app.certification.get("status", "unknown") + + if cert_status == "verified": + print("✅ 已完成微信认证") + return True + + if cert_status == "pending": + print("⏳ 认证审核中") + print(" 可选择:") + print(" 1. 继续部署(未认证可上传,但无法发布)") + print(" 2. 等待认证完成") + + choice = input("\n是否继续? (y/n): ").strip().lower() + return choice == 'y' + + if cert_status == "expired": + print("⚠️ 认证已过期,需要重新认证") + print(" 运行: python mp_deploy.py cert " + app.id) + + choice = input("\n是否继续部署? (y/n): ").strip().lower() + return choice == 'y' + + # 未认证或未知状态 + print("⚠️ 未完成微信认证") + print(" 未认证的小程序可以上传代码,但无法发布上线") + print(" 运行: python mp_deploy.py cert " + app.id + " 提交认证") + + choice = input("\n是否继续? (y/n): ").strip().lower() + return choice == 'y' + + def _step_build(self, app: AppConfig) -> bool: + """编译项目""" + print("📦 编译项目...") + + # 使用CLI编译 + success, output = self._run_cli("build-npm", project_path=app.project_path) + + if not success: + # build-npm可能失败(如果没有npm依赖),不算错误 + print("ℹ️ 编译完成(无npm依赖或编译失败,继续...)") + else: + print("✅ 编译成功") + + return True + + def _step_upload(self, app: AppConfig) -> bool: + """上传代码""" + # 获取版本号 + version = datetime.now().strftime("%Y.%m.%d.%H%M") + desc = f"自动部署 - {datetime.now().strftime('%Y-%m-%d %H:%M')}" + + print(f"📤 上传代码...") + print(f" 版本: {version}") + print(f" 描述: {desc}") + + success, output = self._run_cli( + "upload", + "--version", version, + "--desc", desc, + project_path=app.project_path + ) + + if not success: + print(f"❌ 上传失败") + print(f" {output}") + + # 常见错误处理 + if "login" in output.lower(): + print("\n💡 提示: 请在微信开发者工具中登录后重试") + return False + + print("✅ 上传成功") + return True + + def _step_submit_audit(self, app: AppConfig) -> bool: + """提交审核""" + print("📝 提交审核...") + + # 使用CLI提交审核 + success, output = self._run_cli( + "submit-audit", + project_path=app.project_path + ) + + if not success: + if "未认证" in output or "认证" in output: + print("⚠️ 提交审核失败:未完成微信认证") + print(" 代码已上传,但需要完成认证后才能提交审核") + print(f" 运行: python mp_deploy.py cert {app.id}") + return True # 不算失败,只是需要认证 + + print(f"❌ 提交审核失败") + print(f" {output}") + return False + + print("✅ 审核已提交") + return True + + def submit_certification(self, app_id: str): + """提交企业认证""" + app = self.config.get_app(app_id) + if not app: + print(f"❌ 未找到小程序: {app_id}") + return + + print("\n" + "=" * 60) + print(f" 📋 提交认证: {app.name}") + print("=" * 60) + + # 获取通用认证材料 + materials = self.config.get_cert_materials() + cert = app.certification + + # 合并材料(小程序配置优先) + enterprise_name = cert.get("enterprise_name") or materials.get("enterprise_name", "") + + print(f"\n📌 认证信息:") + print(f" 小程序: {app.name} ({app.appid})") + print(f" 企业名称: {enterprise_name}") + + # 检查必要材料 + missing = [] + if not enterprise_name: + missing.append("企业名称") + if not materials.get("license_number"): + missing.append("营业执照号") + if not materials.get("legal_persona_name"): + missing.append("法人姓名") + + if missing: + print(f"\n⚠️ 缺少认证材料:") + for m in missing: + print(f" - {m}") + + print(f"\n请先完善认证材料:") + print(f" 编辑: {self.config.config_file}") + print(f" 或运行: python mp_deploy.py cert-config") + return + + print("\n" + "-" * 40) + print("📋 认证方式说明:") + print("-" * 40) + print(""" + 【方式一】微信后台手动认证(推荐) + + 1. 登录小程序后台: https://mp.weixin.qq.com/ + 2. 设置 → 基本设置 → 微信认证 + 3. 选择"企业"类型 + 4. 填写企业信息、上传营业执照 + 5. 法人微信扫码验证 + 6. 支付认证费用(300元/年) + 7. 等待审核(1-5个工作日) + + 【方式二】通过第三方平台代认证(需开发) + + 如果你有第三方平台资质,可以通过API代认证: + 1. 配置第三方平台凭证 + 2. 获取授权 + 3. 调用认证API + + API接口: POST /wxa/sec/wxaauth + """) + + print("\n" + "-" * 40) + print("📝 认证材料清单:") + print("-" * 40) + print(""" + 必需材料: + ☐ 企业营业执照(扫描件或照片) + ☐ 法人身份证(正反面) + ☐ 法人微信号(用于扫码验证) + ☐ 联系人手机号 + ☐ 认证费用 300元 + + 认证有效期: 1年 + 到期后需重新认证(年审) + """) + + # 更新状态为待认证 + self.config.update_app(app_id, { + "certification": { + **cert, + "status": "pending", + "submit_time": datetime.now().isoformat() + } + }) + + print("\n✅ 已标记为待认证状态") + print(" 完成认证后运行: python mp_deploy.py cert-done " + app_id) + + def check_cert_status(self, app_id: str): + """检查认证状态""" + app = self.config.get_app(app_id) + if not app: + print(f"❌ 未找到小程序: {app_id}") + return + + print("\n" + "=" * 60) + print(f" 🔍 认证状态: {app.name}") + print("=" * 60) + + cert = app.certification + status = cert.get("status", "unknown") + + status_info = { + "verified": ("✅ 已认证", "认证有效"), + "pending": ("⏳ 审核中", "请等待审核结果"), + "rejected": ("❌ 被拒绝", "请查看拒绝原因并重新提交"), + "expired": ("⚠️ 已过期", "需要重新认证(年审)"), + "unknown": ("❓ 未知", "请在微信后台确认状态") + } + + icon, desc = status_info.get(status, ("❓", "未知状态")) + + print(f"\n📌 当前状态: {icon}") + print(f" 说明: {desc}") + print(f" 企业: {cert.get('enterprise_name', '未填写')}") + + if cert.get("submit_time"): + print(f" 提交时间: {cert.get('submit_time')}") + + if cert.get("verify_time"): + print(f" 认证时间: {cert.get('verify_time')}") + + if cert.get("expire_time"): + print(f" 到期时间: {cert.get('expire_time')}") + + # 提示下一步操作 + print("\n" + "-" * 40) + if status == "unknown" or status == "rejected": + print("👉 下一步: python mp_deploy.py cert " + app_id) + elif status == "pending": + print("👉 等待审核,通常1-5个工作日") + print(" 审核通过后运行: python mp_deploy.py cert-done " + app_id) + elif status == "verified": + print("👉 可以发布小程序: python mp_deploy.py deploy " + app_id) + elif status == "expired": + print("👉 需要重新认证: python mp_deploy.py cert " + app_id) + + def mark_cert_done(self, app_id: str): + """标记认证完成""" + app = self.config.get_app(app_id) + if not app: + print(f"❌ 未找到小程序: {app_id}") + return + + cert = app.certification + self.config.update_app(app_id, { + "certification": { + **cert, + "status": "verified", + "verify_time": datetime.now().isoformat(), + "expire_time": datetime.now().replace(year=datetime.now().year + 1).isoformat() + } + }) + + print(f"✅ 已标记 [{app.name}] 认证完成") + print(f" 有效期至: {datetime.now().year + 1}年") + + def release(self, app_id: str): + """发布上线""" + app = self.config.get_app(app_id) + if not app: + print(f"❌ 未找到小程序: {app_id}") + return + + print("\n" + "=" * 60) + print(f" 🎉 发布上线: {app.name}") + print("=" * 60) + + # 检查认证状态 + if app.certification.get("status") != "verified": + print("\n⚠️ 警告: 小程序未完成认证") + print(" 未认证的小程序无法发布上线") + + choice = input("\n是否继续尝试? (y/n): ").strip().lower() + if choice != 'y': + return + + print("\n📦 正在发布...") + + # 尝试使用CLI发布 + success, output = self._run_cli("release", project_path=app.project_path) + + if success: + print("\n🎉 发布成功!小程序已上线") + else: + print(f"\n发布结果: {output}") + + if "认证" in output: + print("\n💡 提示: 请先完成微信认证") + print(f" 运行: python mp_deploy.py cert {app_id}") + else: + print("\n💡 提示: 请在微信后台手动发布") + print(" 1. 登录 https://mp.weixin.qq.com/") + print(" 2. 版本管理 → 审核版本 → 发布") + + def quick_upload(self, app_id: str, version: str = None, desc: str = None): + """快速上传代码""" + app = self.config.get_app(app_id) + if not app: + print(f"❌ 未找到小程序: {app_id}") + return + + if not version: + version = datetime.now().strftime("%Y.%m.%d.%H%M") + if not desc: + desc = f"快速上传 - {datetime.now().strftime('%Y-%m-%d %H:%M')}" + + print(f"\n📤 上传代码: {app.name}") + print(f" 版本: {version}") + print(f" 描述: {desc}") + + success, output = self._run_cli( + "upload", + "--version", version, + "--desc", desc, + project_path=app.project_path + ) + + if success: + print("✅ 上传成功") + else: + print(f"❌ 上传失败: {output}") + + +def print_header(title: str): + print("\n" + "=" * 50) + print(f" {title}") + print("=" * 50) + + +def main(): + parser = argparse.ArgumentParser( + description="小程序一键部署工具 v2.0", + formatter_class=argparse.RawDescriptionHelpFormatter, + epilog=""" +示例: + python mp_deploy.py list 列出所有小程序 + python mp_deploy.py add 添加新小程序 + python mp_deploy.py deploy soul-party 一键部署 + python mp_deploy.py cert soul-party 提交认证 + python mp_deploy.py cert-status soul-party 查询认证状态 + python mp_deploy.py cert-done soul-party 标记认证完成 + python mp_deploy.py upload soul-party 仅上传代码 + python mp_deploy.py release soul-party 发布上线 + +部署流程: + 1. add 添加小程序配置 + 2. cert 提交企业认证(首次) + 3. cert-done 认证通过后标记 + 4. deploy 一键部署(编译+上传+提审) + 5. release 审核通过后发布 +""" + ) + + subparsers = parser.add_subparsers(dest="command", help="子命令") + + # list + subparsers.add_parser("list", help="列出所有小程序") + + # add + subparsers.add_parser("add", help="添加新小程序") + + # deploy + deploy_parser = subparsers.add_parser("deploy", help="一键部署") + deploy_parser.add_argument("app_id", help="小程序ID") + deploy_parser.add_argument("--skip-cert", action="store_true", help="跳过认证检查") + + # cert + cert_parser = subparsers.add_parser("cert", help="提交认证") + cert_parser.add_argument("app_id", help="小程序ID") + + # cert-status + cert_status_parser = subparsers.add_parser("cert-status", help="查询认证状态") + cert_status_parser.add_argument("app_id", help="小程序ID") + + # cert-done + cert_done_parser = subparsers.add_parser("cert-done", help="标记认证完成") + cert_done_parser.add_argument("app_id", help="小程序ID") + + # upload + upload_parser = subparsers.add_parser("upload", help="上传代码") + upload_parser.add_argument("app_id", help="小程序ID") + upload_parser.add_argument("-v", "--version", help="版本号") + upload_parser.add_argument("-d", "--desc", help="版本描述") + + # release + release_parser = subparsers.add_parser("release", help="发布上线") + release_parser.add_argument("app_id", help="小程序ID") + + args = parser.parse_args() + + if not args.command: + parser.print_help() + return + + deployer = MiniProgramDeployer() + + commands = { + "list": lambda: deployer.list_apps(), + "add": lambda: deployer.add_app(), + "deploy": lambda: deployer.deploy(args.app_id, args.skip_cert if hasattr(args, 'skip_cert') else False), + "cert": lambda: deployer.submit_certification(args.app_id), + "cert-status": lambda: deployer.check_cert_status(args.app_id), + "cert-done": lambda: deployer.mark_cert_done(args.app_id), + "upload": lambda: deployer.quick_upload(args.app_id, getattr(args, 'version', None), getattr(args, 'desc', None)), + "release": lambda: deployer.release(args.app_id), + } + + cmd_func = commands.get(args.command) + if cmd_func: + cmd_func() + else: + parser.print_help() + + +if __name__ == "__main__": + main() diff --git a/开发文档/小程序管理/scripts/mp_full.py b/开发文档/小程序管理/scripts/mp_full.py new file mode 100644 index 00000000..2a754a2a --- /dev/null +++ b/开发文档/小程序管理/scripts/mp_full.py @@ -0,0 +1,555 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +""" +小程序全能管理工具 v3.0 + +整合能力: +- 微信开发者工具CLI +- miniprogram-ci (npm官方工具) +- 微信开放平台API +- 多小程序管理 +- 自动化部署+提审 +- 汇总报告生成 + +使用方法: + python mp_full.py report # 生成汇总报告 + python mp_full.py check # 检查项目问题 + python mp_full.py auto # 全自动部署(上传+提审) + python mp_full.py batch-report # 批量生成所有小程序报告 +""" + +import os +import sys +import json +import subprocess +import argparse +from datetime import datetime +from pathlib import Path +from typing import Optional, Dict, List, Any +from dataclasses import dataclass, asdict, field + +# 配置文件路径 +SCRIPT_DIR = Path(__file__).parent +CONFIG_FILE = SCRIPT_DIR / "apps_config.json" +REPORT_DIR = SCRIPT_DIR / "reports" + + +@dataclass +class CheckResult: + """检查结果""" + name: str + status: str # ok, warning, error + message: str + fix_hint: str = "" + + +@dataclass +class AppReport: + """小程序报告""" + app_id: str + app_name: str + appid: str + check_time: str + checks: List[CheckResult] = field(default_factory=list) + summary: Dict = field(default_factory=dict) + + @property + def has_errors(self) -> bool: + return any(c.status == "error" for c in self.checks) + + @property + def has_warnings(self) -> bool: + return any(c.status == "warning" for c in self.checks) + + +class MiniProgramManager: + """小程序全能管理器""" + + # 工具路径 + WX_CLI = "/Applications/wechatwebdevtools.app/Contents/MacOS/cli" + + def __init__(self): + self.config = self._load_config() + REPORT_DIR.mkdir(exist_ok=True) + + def _load_config(self) -> Dict: + if CONFIG_FILE.exists(): + with open(CONFIG_FILE, 'r', encoding='utf-8') as f: + return json.load(f) + return {"apps": []} + + def _save_config(self): + with open(CONFIG_FILE, 'w', encoding='utf-8') as f: + json.dump(self.config, f, ensure_ascii=False, indent=2) + + def get_app(self, app_id: str) -> Optional[Dict]: + for app in self.config.get("apps", []): + if app["id"] == app_id or app["appid"] == app_id: + return app + return None + + def _run_cmd(self, cmd: List[str], timeout: int = 120) -> tuple: + """运行命令""" + try: + result = subprocess.run(cmd, capture_output=True, text=True, timeout=timeout) + return result.returncode == 0, result.stdout + result.stderr + except subprocess.TimeoutExpired: + return False, "命令执行超时" + except Exception as e: + return False, str(e) + + def _check_tool(self, tool: str) -> bool: + """检查工具是否可用""" + success, _ = self._run_cmd(["which", tool], timeout=5) + return success + + # ==================== 检查功能 ==================== + + def check_project(self, app_id: str) -> AppReport: + """检查项目问题""" + app = self.get_app(app_id) + if not app: + print(f"❌ 未找到小程序: {app_id}") + return None + + report = AppReport( + app_id=app["id"], + app_name=app["name"], + appid=app["appid"], + check_time=datetime.now().isoformat() + ) + + project_path = app["project_path"] + + # 1. 检查项目路径 + if os.path.exists(project_path): + report.checks.append(CheckResult("项目路径", "ok", f"路径存在: {project_path}")) + else: + report.checks.append(CheckResult("项目路径", "error", f"路径不存在: {project_path}", "请检查项目路径配置")) + return report # 路径不存在,无法继续检查 + + # 2. 检查project.config.json + config_file = os.path.join(project_path, "project.config.json") + if os.path.exists(config_file): + with open(config_file, 'r') as f: + config = json.load(f) + + if config.get("appid") == app["appid"]: + report.checks.append(CheckResult("AppID配置", "ok", f"AppID正确: {app['appid']}")) + else: + report.checks.append(CheckResult("AppID配置", "error", + f"AppID不匹配: 配置={app['appid']}, 文件={config.get('appid')}", + "请修改project.config.json中的appid")) + else: + report.checks.append(CheckResult("项目配置", "error", "project.config.json不存在", "请确认这是有效的小程序项目")) + + # 3. 检查app.js + app_js = os.path.join(project_path, "app.js") + if os.path.exists(app_js): + with open(app_js, 'r') as f: + content = f.read() + + # 检查API域名 + if "baseUrl" in content or "apiBase" in content: + if "https://" in content: + report.checks.append(CheckResult("API域名", "ok", "已配置HTTPS域名")) + elif "http://localhost" in content: + report.checks.append(CheckResult("API域名", "warning", "使用本地开发地址", "发布前请更换为HTTPS域名")) + else: + report.checks.append(CheckResult("API域名", "warning", "未检测到HTTPS域名")) + + report.checks.append(CheckResult("入口文件", "ok", "app.js存在")) + else: + report.checks.append(CheckResult("入口文件", "error", "app.js不存在")) + + # 4. 检查app.json + app_json = os.path.join(project_path, "app.json") + if os.path.exists(app_json): + with open(app_json, 'r') as f: + app_config = json.load(f) + + pages = app_config.get("pages", []) + if pages: + report.checks.append(CheckResult("页面配置", "ok", f"共{len(pages)}个页面")) + else: + report.checks.append(CheckResult("页面配置", "error", "没有配置页面")) + + # 检查隐私配置 + if app_config.get("__usePrivacyCheck__"): + report.checks.append(CheckResult("隐私配置", "ok", "已启用隐私检查")) + else: + report.checks.append(CheckResult("隐私配置", "warning", "未启用隐私检查", "建议添加 __usePrivacyCheck__: true")) + else: + report.checks.append(CheckResult("应用配置", "error", "app.json不存在")) + + # 5. 检查认证状态 + cert_status = app.get("certification", {}).get("status", "unknown") + if cert_status == "verified": + report.checks.append(CheckResult("企业认证", "ok", "已完成认证")) + elif cert_status == "pending": + report.checks.append(CheckResult("企业认证", "warning", "认证审核中", "等待审核结果")) + elif cert_status == "expired": + report.checks.append(CheckResult("企业认证", "error", "认证已过期", "请尽快完成年审")) + else: + report.checks.append(CheckResult("企业认证", "warning", "未认证", "无法发布上线,请先完成认证")) + + # 6. 检查开发工具 + if os.path.exists(self.WX_CLI): + report.checks.append(CheckResult("开发者工具", "ok", "微信开发者工具已安装")) + else: + report.checks.append(CheckResult("开发者工具", "error", "微信开发者工具未安装")) + + # 7. 检查miniprogram-ci + if self._check_tool("miniprogram-ci"): + report.checks.append(CheckResult("miniprogram-ci", "ok", "npm工具已安装")) + else: + report.checks.append(CheckResult("miniprogram-ci", "warning", "miniprogram-ci未安装", "运行: npm install -g miniprogram-ci")) + + # 8. 检查私钥 + if app.get("private_key_path") and os.path.exists(app["private_key_path"]): + report.checks.append(CheckResult("上传密钥", "ok", "私钥文件存在")) + else: + report.checks.append(CheckResult("上传密钥", "warning", "未配置私钥", "在小程序后台下载代码上传密钥")) + + # 生成汇总 + ok_count = sum(1 for c in report.checks if c.status == "ok") + warn_count = sum(1 for c in report.checks if c.status == "warning") + error_count = sum(1 for c in report.checks if c.status == "error") + + report.summary = { + "total": len(report.checks), + "ok": ok_count, + "warning": warn_count, + "error": error_count, + "can_deploy": error_count == 0, + "can_release": cert_status == "verified" and error_count == 0 + } + + return report + + def print_report(self, report: AppReport): + """打印报告""" + print("\n" + "=" * 70) + print(f" 📊 项目检查报告: {report.app_name}") + print("=" * 70) + print(f" AppID: {report.appid}") + print(f" 检查时间: {report.check_time}") + print("-" * 70) + + status_icons = {"ok": "✅", "warning": "⚠️", "error": "❌"} + + for check in report.checks: + icon = status_icons.get(check.status, "❓") + print(f" {icon} {check.name}: {check.message}") + if check.fix_hint: + print(f" 💡 {check.fix_hint}") + + print("-" * 70) + s = report.summary + print(f" 📈 汇总: 通过 {s['ok']} / 警告 {s['warning']} / 错误 {s['error']}") + + if s['can_release']: + print(" 🎉 状态: 可以发布上线") + elif s['can_deploy']: + print(" 📦 状态: 可以上传代码,但无法发布(需完成认证)") + else: + print(" 🚫 状态: 存在错误,请先修复") + + print("=" * 70 + "\n") + + def save_report(self, report: AppReport): + """保存报告到文件""" + filename = f"report_{report.app_id}_{datetime.now().strftime('%Y%m%d_%H%M%S')}.json" + filepath = REPORT_DIR / filename + + with open(filepath, 'w', encoding='utf-8') as f: + json.dump(asdict(report), f, ensure_ascii=False, indent=2) + + return filepath + + # ==================== 自动化部署 ==================== + + def auto_deploy(self, app_id: str, version: str = None, desc: str = None, submit_audit: bool = True) -> bool: + """全自动部署:编译 → 上传 → 提审""" + app = self.get_app(app_id) + if not app: + print(f"❌ 未找到小程序: {app_id}") + return False + + print("\n" + "=" * 70) + print(f" 🚀 全自动部署: {app['name']}") + print("=" * 70) + + # 1. 先检查项目 + print("\n📋 步骤1: 检查项目...") + report = self.check_project(app_id) + if report.has_errors: + print("❌ 项目存在错误,无法部署") + self.print_report(report) + return False + print("✅ 项目检查通过") + + # 2. 准备版本信息 + if not version: + version = datetime.now().strftime("%Y.%m.%d.%H%M") + if not desc: + desc = f"自动部署 - {datetime.now().strftime('%Y-%m-%d %H:%M')}" + + print(f"\n📦 步骤2: 上传代码...") + print(f" 版本: {version}") + print(f" 描述: {desc}") + + # 3. 上传代码 + success = self._upload_code(app, version, desc) + if not success: + print("❌ 代码上传失败") + return False + print("✅ 代码上传成功") + + # 4. 提交审核 + if submit_audit: + print(f"\n📝 步骤3: 提交审核...") + cert_status = app.get("certification", {}).get("status", "unknown") + + if cert_status != "verified": + print(f"⚠️ 认证状态: {cert_status}") + print(" 未认证的小程序无法提交审核") + print(" 代码已上传到开发版,请在微信后台手动提交") + print("\n" + "-" * 40) + print("👉 下一步操作:") + print(" 1. 完成企业认证") + print(" 2. 在微信后台提交审核") + print(" 3. 审核通过后发布上线") + else: + # 尝试通过API提交审核 + audit_success = self._submit_audit_via_api(app) + if audit_success: + print("✅ 审核已提交") + else: + print("⚠️ 自动提审失败,请在微信后台手动提交") + print(" 登录: https://mp.weixin.qq.com/") + print(" 版本管理 → 开发版本 → 提交审核") + + # 5. 生成报告 + print(f"\n📊 步骤4: 生成报告...") + report_file = self.save_report(report) + print(f"✅ 报告已保存: {report_file}") + + print("\n" + "=" * 70) + print(" 🎉 部署完成!") + print("=" * 70) + + return True + + def _upload_code(self, app: Dict, version: str, desc: str) -> bool: + """上传代码(优先使用CLI)""" + project_path = app["project_path"] + + # 方法1:使用微信开发者工具CLI + if os.path.exists(self.WX_CLI): + cmd = [ + self.WX_CLI, "upload", + "--project", project_path, + "--version", version, + "--desc", desc + ] + success, output = self._run_cmd(cmd, timeout=120) + if success: + return True + print(f" CLI上传失败: {output[:200]}") + + # 方法2:使用miniprogram-ci + if self._check_tool("miniprogram-ci") and app.get("private_key_path"): + cmd = [ + "miniprogram-ci", "upload", + "--pp", project_path, + "--pkp", app["private_key_path"], + "--appid", app["appid"], + "--uv", version, + "-r", "1", + "--desc", desc + ] + success, output = self._run_cmd(cmd, timeout=120) + if success: + return True + print(f" miniprogram-ci上传失败: {output[:200]}") + + return False + + def _submit_audit_via_api(self, app: Dict) -> bool: + """通过API提交审核(需要access_token)""" + # 这里需要access_token才能调用API + # 目前返回False,提示用户手动提交 + return False + + # ==================== 汇总报告 ==================== + + def generate_summary_report(self): + """生成所有小程序的汇总报告""" + apps = self.config.get("apps", []) + + if not apps: + print("📭 暂无配置的小程序") + return + + print("\n" + "=" * 80) + print(" 📊 小程序管理汇总报告") + print(f" 生成时间: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}") + print("=" * 80) + + all_reports = [] + + for app in apps: + report = self.check_project(app["id"]) + if report: + all_reports.append(report) + + # 打印汇总表格 + print("\n┌" + "─" * 78 + "┐") + print(f"│ {'小程序名称':<20} │ {'AppID':<25} │ {'状态':<10} │ {'可发布':<8} │") + print("├" + "─" * 78 + "┤") + + for report in all_reports: + status = "✅ 正常" if not report.has_errors else "❌ 错误" + can_release = "✅" if report.summary.get("can_release") else "❌" + print(f"│ {report.app_name:<20} │ {report.appid:<25} │ {status:<10} │ {can_release:<8} │") + + print("└" + "─" * 78 + "┘") + + # 统计 + total = len(all_reports) + ok_count = sum(1 for r in all_reports if not r.has_errors and not r.has_warnings) + warn_count = sum(1 for r in all_reports if r.has_warnings and not r.has_errors) + error_count = sum(1 for r in all_reports if r.has_errors) + can_release = sum(1 for r in all_reports if r.summary.get("can_release")) + + print(f"\n📈 统计:") + print(f" 总计: {total} 个小程序") + print(f" 正常: {ok_count} | 警告: {warn_count} | 错误: {error_count}") + print(f" 可发布: {can_release} 个") + + # 问题清单 + issues = [] + for report in all_reports: + for check in report.checks: + if check.status == "error": + issues.append((report.app_name, check.name, check.message, check.fix_hint)) + + if issues: + print(f"\n⚠️ 问题清单 ({len(issues)} 个):") + print("-" * 60) + for app_name, check_name, message, hint in issues: + print(f" [{app_name}] {check_name}: {message}") + if hint: + print(f" 💡 {hint}") + else: + print(f"\n✅ 所有小程序状态正常") + + # 待办事项 + print(f"\n📋 待办事项:") + for report in all_reports: + cert_status = "unknown" + for check in report.checks: + if check.name == "企业认证": + if "审核中" in check.message: + cert_status = "pending" + elif "已完成" in check.message: + cert_status = "verified" + elif "未认证" in check.message: + cert_status = "unknown" + break + + if cert_status == "pending": + print(f" ⏳ {report.app_name}: 等待认证审核结果") + elif cert_status == "unknown": + print(f" 📝 {report.app_name}: 需要完成企业认证") + + print("\n" + "=" * 80) + + # 保存汇总报告 + summary_file = REPORT_DIR / f"summary_{datetime.now().strftime('%Y%m%d_%H%M%S')}.json" + summary_data = { + "generated_at": datetime.now().isoformat(), + "total_apps": total, + "summary": { + "ok": ok_count, + "warning": warn_count, + "error": error_count, + "can_release": can_release + }, + "apps": [asdict(r) for r in all_reports] + } + with open(summary_file, 'w', encoding='utf-8') as f: + json.dump(summary_data, f, ensure_ascii=False, indent=2) + + print(f"📁 报告已保存: {summary_file}\n") + + +def main(): + parser = argparse.ArgumentParser( + description="小程序全能管理工具 v3.0", + formatter_class=argparse.RawDescriptionHelpFormatter, + epilog=""" +示例: + python mp_full.py report 生成汇总报告 + python mp_full.py check soul-party 检查项目问题 + python mp_full.py auto soul-party 全自动部署(上传+提审) + python mp_full.py auto soul-party -v 1.0.13 -d "修复问题" + +流程说明: + ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐ + │ 检查 │ → │ 编译 │ → │ 上传 │ → │ 提审 │ → │ 发布 │ + │ check │ │ build │ │ upload │ │ audit │ │ release │ + └─────────┘ └─────────┘ └─────────┘ └─────────┘ └─────────┘ + +工具整合: + • 微信开发者工具CLI - 本地编译上传 + • miniprogram-ci - npm官方CI工具 + • 开放平台API - 审核/发布/认证 +""" + ) + + subparsers = parser.add_subparsers(dest="command", help="子命令") + + # report + subparsers.add_parser("report", help="生成汇总报告") + + # check + check_parser = subparsers.add_parser("check", help="检查项目问题") + check_parser.add_argument("app_id", help="小程序ID") + + # auto + auto_parser = subparsers.add_parser("auto", help="全自动部署") + auto_parser.add_argument("app_id", help="小程序ID") + auto_parser.add_argument("-v", "--version", help="版本号") + auto_parser.add_argument("-d", "--desc", help="版本描述") + auto_parser.add_argument("--no-audit", action="store_true", help="不提交审核") + + args = parser.parse_args() + + if not args.command: + parser.print_help() + return + + manager = MiniProgramManager() + + if args.command == "report": + manager.generate_summary_report() + + elif args.command == "check": + report = manager.check_project(args.app_id) + if report: + manager.print_report(report) + manager.save_report(report) + + elif args.command == "auto": + manager.auto_deploy( + args.app_id, + version=args.version, + desc=args.desc, + submit_audit=not args.no_audit + ) + + +if __name__ == "__main__": + main() diff --git a/开发文档/小程序管理/scripts/mp_manager.py b/开发文档/小程序管理/scripts/mp_manager.py new file mode 100644 index 00000000..197f780d --- /dev/null +++ b/开发文档/小程序管理/scripts/mp_manager.py @@ -0,0 +1,558 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +""" +微信小程序管理命令行工具 + +使用方法: + python mp_manager.py status # 查看小程序状态 + python mp_manager.py audit # 查看审核状态 + python mp_manager.py release # 发布上线 + python mp_manager.py qrcode # 生成小程序码 + python mp_manager.py domain # 查看/配置域名 + python mp_manager.py privacy # 配置隐私协议 + python mp_manager.py data # 查看数据分析 +""" + +import os +import sys +import argparse +from datetime import datetime, timedelta +from pathlib import Path + +# 添加当前目录到路径 +sys.path.insert(0, str(Path(__file__).parent)) + +from mp_api import MiniProgramAPI, APIError, create_api_from_env + + +def print_header(title: str): + """打印标题""" + print("\n" + "=" * 50) + print(f" {title}") + print("=" * 50) + + +def print_success(message: str): + """打印成功信息""" + print(f"✅ {message}") + + +def print_error(message: str): + """打印错误信息""" + print(f"❌ {message}") + + +def print_info(message: str): + """打印信息""" + print(f"ℹ️ {message}") + + +def cmd_status(api: MiniProgramAPI, args): + """查看小程序状态""" + print_header("小程序基础信息") + + try: + info = api.get_basic_info() + print(f"\n📱 AppID: {info.appid}") + print(f"📝 名称: {info.nickname}") + print(f"📄 简介: {info.signature}") + print(f"🏢 主体: {info.principal_name}") + print(f"✓ 认证状态: {'已认证' if info.realname_status == 1 else '未认证'}") + + if info.head_image_url: + print(f"🖼️ 头像: {info.head_image_url}") + + # 获取类目 + print("\n📂 已设置类目:") + categories = api.get_category() + if categories: + for cat in categories: + print(f" - {cat.get('first_class', '')} > {cat.get('second_class', '')}") + else: + print(" (未设置类目)") + + except APIError as e: + print_error(f"获取信息失败: {e}") + + +def cmd_audit(api: MiniProgramAPI, args): + """查看审核状态""" + print_header("审核状态") + + try: + status = api.get_latest_audit_status() + print(f"\n🔢 审核单ID: {status.auditid}") + print(f"📊 状态: {status.status_text}") + + if status.reason: + print(f"\n❗ 拒绝原因:") + print(f" {status.reason}") + + if status.screenshot: + print(f"\n📸 问题截图: {status.screenshot}") + + if status.status == 0: + print("\n👉 下一步: 运行 'python mp_manager.py release' 发布上线") + elif status.status == 1: + print("\n👉 请根据拒绝原因修改后重新提交审核") + elif status.status == 2: + print("\n👉 审核中,请耐心等待(通常1-3个工作日)") + print(" 可运行 'python mp_manager.py audit' 再次查询") + + except APIError as e: + print_error(f"获取审核状态失败: {e}") + + +def cmd_submit(api: MiniProgramAPI, args): + """提交审核""" + print_header("提交审核") + + version_desc = args.desc or input("请输入版本说明: ").strip() + if not version_desc: + print_error("版本说明不能为空") + return + + try: + # 获取页面列表 + pages = api.get_page() + if not pages: + print_error("未找到页面,请先上传代码") + return + + print(f"\n📄 检测到 {len(pages)} 个页面:") + for p in pages[:5]: + print(f" - {p}") + if len(pages) > 5: + print(f" ... 还有 {len(pages) - 5} 个") + + # 确认提交 + confirm = input("\n确认提交审核? (y/n): ").strip().lower() + if confirm != 'y': + print_info("已取消") + return + + auditid = api.submit_audit(version_desc=version_desc) + print_success(f"审核已提交,审核单ID: {auditid}") + print("\n👉 运行 'python mp_manager.py audit' 查询审核状态") + + except APIError as e: + print_error(f"提交审核失败: {e}") + + +def cmd_release(api: MiniProgramAPI, args): + """发布上线""" + print_header("发布上线") + + try: + # 先检查审核状态 + status = api.get_latest_audit_status() + if status.status != 0: + print_error(f"当前审核状态: {status.status_text}") + print_info("只有审核通过的版本才能发布") + return + + print(f"📊 审核状态: {status.status_text}") + + # 确认发布 + confirm = input("\n确认发布上线? (y/n): ").strip().lower() + if confirm != 'y': + print_info("已取消") + return + + api.release() + print_success("🎉 发布成功!小程序已上线") + + except APIError as e: + print_error(f"发布失败: {e}") + + +def cmd_revert(api: MiniProgramAPI, args): + """版本回退""" + print_header("版本回退") + + try: + # 获取可回退版本 + history = api.get_revert_history() + if not history: + print_info("没有可回退的版本") + return + + print("\n📜 可回退版本:") + for v in history: + print(f" - {v.get('user_version', '?')}: {v.get('user_desc', '')}") + + # 确认回退 + confirm = input("\n确认回退到上一版本? (y/n): ").strip().lower() + if confirm != 'y': + print_info("已取消") + return + + api.revert_code_release() + print_success("版本回退成功") + + except APIError as e: + print_error(f"版本回退失败: {e}") + + +def cmd_qrcode(api: MiniProgramAPI, args): + """生成小程序码""" + print_header("生成小程序码") + + # 场景选择 + print("\n选择类型:") + print(" 1. 体验版二维码") + print(" 2. 小程序码(有限制,每个path最多10万个)") + print(" 3. 无限小程序码(推荐)") + + choice = args.type or input("\n请选择 (1/2/3): ").strip() + + output_file = args.output or f"qrcode_{datetime.now().strftime('%Y%m%d_%H%M%S')}.png" + + try: + if choice == "1": + # 体验版二维码 + path = args.path or input("页面路径 (默认首页): ").strip() or None + data = api.get_qrcode(path) + + elif choice == "2": + # 小程序码 + path = args.path or input("页面路径: ").strip() + if not path: + print_error("页面路径不能为空") + return + data = api.get_wxacode(path) + + elif choice == "3": + # 无限小程序码 + scene = args.scene or input("场景值 (最长32字符): ").strip() + if not scene: + print_error("场景值不能为空") + return + page = args.path or input("页面路径 (需已发布): ").strip() or None + data = api.get_wxacode_unlimit(scene, page) + + else: + print_error("无效选择") + return + + # 保存文件 + with open(output_file, "wb") as f: + f.write(data) + + print_success(f"小程序码已保存: {output_file}") + + # 尝试打开 + if sys.platform == "darwin": + os.system(f'open "{output_file}"') + + except APIError as e: + print_error(f"生成小程序码失败: {e}") + + +def cmd_domain(api: MiniProgramAPI, args): + """查看/配置域名""" + print_header("域名配置") + + try: + # 获取当前配置 + domains = api.get_domain() + webview_domains = api.get_webview_domain() + + print("\n🌐 服务器域名:") + print(f" request: {', '.join(domains.get('requestdomain', [])) or '(无)'}") + print(f" wsrequest: {', '.join(domains.get('wsrequestdomain', [])) or '(无)'}") + print(f" upload: {', '.join(domains.get('uploaddomain', [])) or '(无)'}") + print(f" download: {', '.join(domains.get('downloaddomain', [])) or '(无)'}") + + print(f"\n🔗 业务域名:") + print(f" webview: {', '.join(webview_domains) or '(无)'}") + + # 是否要配置 + if args.set_request: + print(f"\n配置 request 域名: {args.set_request}") + api.set_domain(requestdomain=[args.set_request]) + print_success("域名配置成功") + + except APIError as e: + print_error(f"域名配置失败: {e}") + + +def cmd_privacy(api: MiniProgramAPI, args): + """配置隐私协议""" + print_header("隐私协议配置") + + try: + # 获取当前配置 + settings = api.get_privacy_setting() + + print("\n📋 当前隐私设置:") + setting_list = settings.get("setting_list", []) + if setting_list: + for s in setting_list: + print(f" - {s.get('privacy_key', '?')}: {s.get('privacy_text', '')}") + else: + print(" (未配置)") + + owner = settings.get("owner_setting", {}) + if owner: + print(f"\n📧 联系方式:") + if owner.get("contact_email"): + print(f" 邮箱: {owner['contact_email']}") + if owner.get("contact_phone"): + print(f" 电话: {owner['contact_phone']}") + + # 快速配置 + if args.quick: + print("\n⚡ 快速配置常用隐私项...") + + default_settings = [ + {"privacy_key": "UserInfo", "privacy_text": "用于展示您的头像和昵称"}, + {"privacy_key": "Location", "privacy_text": "用于获取您的位置信息以推荐附近服务"}, + {"privacy_key": "PhoneNumber", "privacy_text": "用于登录验证和订单通知"}, + ] + + api.set_privacy_setting( + setting_list=default_settings, + contact_email=args.email or "contact@example.com", + contact_phone=args.phone or "15880802661" + ) + print_success("隐私协议配置成功") + + except APIError as e: + print_error(f"隐私协议配置失败: {e}") + + +def cmd_data(api: MiniProgramAPI, args): + """查看数据分析""" + print_header("数据分析") + + # 默认查询最近7天 + end_date = datetime.now().strftime("%Y%m%d") + begin_date = (datetime.now() - timedelta(days=7)).strftime("%Y%m%d") + + if args.begin: + begin_date = args.begin + if args.end: + end_date = args.end + + try: + print(f"\n📊 访问趋势 ({begin_date} ~ {end_date}):") + + data = api.get_daily_visit_trend(begin_date, end_date) + if not data: + print(" (暂无数据)") + return + + # 统计汇总 + total_pv = sum(d.get("visit_pv", 0) for d in data) + total_uv = sum(d.get("visit_uv", 0) for d in data) + total_new = sum(d.get("visit_uv_new", 0) for d in data) + + print(f"\n📈 汇总数据:") + print(f" 总访问次数: {total_pv:,}") + print(f" 总访问人数: {total_uv:,}") + print(f" 新用户数: {total_new:,}") + + print(f"\n📅 每日明细:") + for d in data[-7:]: # 只显示最近7天 + date = d.get("ref_date", "?") + pv = d.get("visit_pv", 0) + uv = d.get("visit_uv", 0) + stay = d.get("stay_time_uv", 0) + print(f" {date}: PV={pv}, UV={uv}, 人均停留={stay:.1f}秒") + + except APIError as e: + print_error(f"获取数据失败: {e}") + + +def cmd_quota(api: MiniProgramAPI, args): + """查看API配额""" + print_header("API配额") + + common_apis = [ + "/wxa/getwxacode", + "/wxa/getwxacodeunlimit", + "/wxa/genwxashortlink", + "/wxa/submit_audit", + "/cgi-bin/message/subscribe/send" + ] + + try: + for cgi_path in common_apis: + try: + quota = api.get_api_quota(cgi_path) + daily_limit = quota.get("daily_limit", 0) + used = quota.get("used", 0) + remain = quota.get("remain", 0) + + print(f"\n📌 {cgi_path}") + print(f" 每日限额: {daily_limit:,}") + print(f" 已使用: {used:,}") + print(f" 剩余: {remain:,}") + except APIError: + pass + + except APIError as e: + print_error(f"获取配额失败: {e}") + + +def cmd_cli(api: MiniProgramAPI, args): + """使用微信开发者工具CLI""" + print_header("微信开发者工具CLI") + + cli_path = "/Applications/wechatwebdevtools.app/Contents/MacOS/cli" + project_path = args.project or os.getenv("MINIPROGRAM_PATH", "") + + if not project_path: + project_path = input("请输入小程序项目路径: ").strip() + + if not os.path.exists(project_path): + print_error(f"项目路径不存在: {project_path}") + return + + if not os.path.exists(cli_path): + print_error("未找到微信开发者工具,请先安装") + return + + print(f"\n📂 项目路径: {project_path}") + print("\n选择操作:") + print(" 1. 打开项目") + print(" 2. 预览(生成二维码)") + print(" 3. 上传代码") + print(" 4. 编译") + + choice = input("\n请选择: ").strip() + + if choice == "1": + os.system(f'"{cli_path}" -o "{project_path}"') + print_success("项目已打开") + + elif choice == "2": + output = f"{project_path}/preview.png" + os.system(f'"{cli_path}" preview --project "{project_path}" --qr-format image --qr-output "{output}"') + if os.path.exists(output): + print_success(f"预览二维码已生成: {output}") + os.system(f'open "{output}"') + else: + print_error("生成失败,请检查开发者工具是否已登录") + + elif choice == "3": + version = input("版本号 (如 1.0.0): ").strip() + desc = input("版本说明: ").strip() + os.system(f'"{cli_path}" upload --project "{project_path}" --version "{version}" --desc "{desc}"') + print_success("代码上传完成") + + elif choice == "4": + os.system(f'"{cli_path}" build-npm --project "{project_path}"') + print_success("编译完成") + + else: + print_error("无效选择") + + +def main(): + parser = argparse.ArgumentParser( + description="微信小程序管理工具", + formatter_class=argparse.RawDescriptionHelpFormatter, + epilog=""" +示例: + python mp_manager.py status 查看小程序状态 + python mp_manager.py audit 查看审核状态 + python mp_manager.py submit -d "修复xxx问题" 提交审核 + python mp_manager.py release 发布上线 + python mp_manager.py qrcode -t 3 -s "id=123" 生成无限小程序码 + python mp_manager.py domain 查看域名配置 + python mp_manager.py privacy --quick 快速配置隐私协议 + python mp_manager.py data 查看数据分析 + python mp_manager.py cli 使用开发者工具CLI +""" + ) + + subparsers = parser.add_subparsers(dest="command", help="子命令") + + # status + subparsers.add_parser("status", help="查看小程序状态") + + # audit + subparsers.add_parser("audit", help="查看审核状态") + + # submit + submit_parser = subparsers.add_parser("submit", help="提交审核") + submit_parser.add_argument("-d", "--desc", help="版本说明") + + # release + subparsers.add_parser("release", help="发布上线") + + # revert + subparsers.add_parser("revert", help="版本回退") + + # qrcode + qr_parser = subparsers.add_parser("qrcode", help="生成小程序码") + qr_parser.add_argument("-t", "--type", choices=["1", "2", "3"], help="类型:1=体验版,2=小程序码,3=无限小程序码") + qr_parser.add_argument("-p", "--path", help="页面路径") + qr_parser.add_argument("-s", "--scene", help="场景值(类型3时使用)") + qr_parser.add_argument("-o", "--output", help="输出文件名") + + # domain + domain_parser = subparsers.add_parser("domain", help="查看/配置域名") + domain_parser.add_argument("--set-request", help="设置request域名") + + # privacy + privacy_parser = subparsers.add_parser("privacy", help="配置隐私协议") + privacy_parser.add_argument("--quick", action="store_true", help="快速配置常用隐私项") + privacy_parser.add_argument("--email", help="联系邮箱") + privacy_parser.add_argument("--phone", help="联系电话") + + # data + data_parser = subparsers.add_parser("data", help="查看数据分析") + data_parser.add_argument("--begin", help="开始日期 YYYYMMDD") + data_parser.add_argument("--end", help="结束日期 YYYYMMDD") + + # quota + subparsers.add_parser("quota", help="查看API配额") + + # cli + cli_parser = subparsers.add_parser("cli", help="使用微信开发者工具CLI") + cli_parser.add_argument("-p", "--project", help="小程序项目路径") + + args = parser.parse_args() + + if not args.command: + parser.print_help() + return + + # 创建API实例 + try: + api = create_api_from_env() + except Exception as e: + print_error(f"初始化API失败: {e}") + print_info("请检查 .env 文件中的配置") + return + + # 执行命令 + commands = { + "status": cmd_status, + "audit": cmd_audit, + "submit": cmd_submit, + "release": cmd_release, + "revert": cmd_revert, + "qrcode": cmd_qrcode, + "domain": cmd_domain, + "privacy": cmd_privacy, + "data": cmd_data, + "quota": cmd_quota, + "cli": cmd_cli, + } + + cmd_func = commands.get(args.command) + if cmd_func: + try: + cmd_func(api, args) + finally: + api.close() + else: + parser.print_help() + + +if __name__ == "__main__": + main() diff --git a/开发文档/小程序管理/scripts/reports/report_soul-party_20260125_113301.json b/开发文档/小程序管理/scripts/reports/report_soul-party_20260125_113301.json new file mode 100644 index 00000000..628d5a38 --- /dev/null +++ b/开发文档/小程序管理/scripts/reports/report_soul-party_20260125_113301.json @@ -0,0 +1,76 @@ +{ + "app_id": "soul-party", + "app_name": "Soul派对", + "appid": "wxb8bbb2b10dec74aa", + "check_time": "2026-01-25T11:33:01.054516", + "checks": [ + { + "name": "项目路径", + "status": "ok", + "message": "路径存在: /Users/karuo/Documents/开发/3、自营项目/一场soul的创业实验/miniprogram", + "fix_hint": "" + }, + { + "name": "AppID配置", + "status": "ok", + "message": "AppID正确: wxb8bbb2b10dec74aa", + "fix_hint": "" + }, + { + "name": "API域名", + "status": "ok", + "message": "已配置HTTPS域名", + "fix_hint": "" + }, + { + "name": "入口文件", + "status": "ok", + "message": "app.js存在", + "fix_hint": "" + }, + { + "name": "页面配置", + "status": "ok", + "message": "共9个页面", + "fix_hint": "" + }, + { + "name": "隐私配置", + "status": "warning", + "message": "未启用隐私检查", + "fix_hint": "建议添加 __usePrivacyCheck__: true" + }, + { + "name": "企业认证", + "status": "warning", + "message": "认证审核中", + "fix_hint": "等待审核结果" + }, + { + "name": "开发者工具", + "status": "ok", + "message": "微信开发者工具已安装", + "fix_hint": "" + }, + { + "name": "miniprogram-ci", + "status": "ok", + "message": "npm工具已安装", + "fix_hint": "" + }, + { + "name": "上传密钥", + "status": "warning", + "message": "未配置私钥", + "fix_hint": "在小程序后台下载代码上传密钥" + } + ], + "summary": { + "total": 10, + "ok": 7, + "warning": 3, + "error": 0, + "can_deploy": true, + "can_release": false + } +} \ No newline at end of file diff --git a/开发文档/小程序管理/scripts/reports/report_soul-party_20260125_113423.json b/开发文档/小程序管理/scripts/reports/report_soul-party_20260125_113423.json new file mode 100644 index 00000000..60ca8c23 --- /dev/null +++ b/开发文档/小程序管理/scripts/reports/report_soul-party_20260125_113423.json @@ -0,0 +1,76 @@ +{ + "app_id": "soul-party", + "app_name": "Soul派对", + "appid": "wxb8bbb2b10dec74aa", + "check_time": "2026-01-25T11:34:23.760802", + "checks": [ + { + "name": "项目路径", + "status": "ok", + "message": "路径存在: /Users/karuo/Documents/开发/3、自营项目/一场soul的创业实验/miniprogram", + "fix_hint": "" + }, + { + "name": "AppID配置", + "status": "ok", + "message": "AppID正确: wxb8bbb2b10dec74aa", + "fix_hint": "" + }, + { + "name": "API域名", + "status": "ok", + "message": "已配置HTTPS域名", + "fix_hint": "" + }, + { + "name": "入口文件", + "status": "ok", + "message": "app.js存在", + "fix_hint": "" + }, + { + "name": "页面配置", + "status": "ok", + "message": "共9个页面", + "fix_hint": "" + }, + { + "name": "隐私配置", + "status": "ok", + "message": "已启用隐私检查", + "fix_hint": "" + }, + { + "name": "企业认证", + "status": "warning", + "message": "认证审核中", + "fix_hint": "等待审核结果" + }, + { + "name": "开发者工具", + "status": "ok", + "message": "微信开发者工具已安装", + "fix_hint": "" + }, + { + "name": "miniprogram-ci", + "status": "ok", + "message": "npm工具已安装", + "fix_hint": "" + }, + { + "name": "上传密钥", + "status": "warning", + "message": "未配置私钥", + "fix_hint": "在小程序后台下载代码上传密钥" + } + ], + "summary": { + "total": 10, + "ok": 8, + "warning": 2, + "error": 0, + "can_deploy": true, + "can_release": false + } +} \ No newline at end of file diff --git a/开发文档/小程序管理/scripts/reports/report_soul-party_20260125_113434.json b/开发文档/小程序管理/scripts/reports/report_soul-party_20260125_113434.json new file mode 100644 index 00000000..83e19c8e --- /dev/null +++ b/开发文档/小程序管理/scripts/reports/report_soul-party_20260125_113434.json @@ -0,0 +1,76 @@ +{ + "app_id": "soul-party", + "app_name": "Soul派对", + "appid": "wxb8bbb2b10dec74aa", + "check_time": "2026-01-25T11:34:28.854418", + "checks": [ + { + "name": "项目路径", + "status": "ok", + "message": "路径存在: /Users/karuo/Documents/开发/3、自营项目/一场soul的创业实验/miniprogram", + "fix_hint": "" + }, + { + "name": "AppID配置", + "status": "ok", + "message": "AppID正确: wxb8bbb2b10dec74aa", + "fix_hint": "" + }, + { + "name": "API域名", + "status": "ok", + "message": "已配置HTTPS域名", + "fix_hint": "" + }, + { + "name": "入口文件", + "status": "ok", + "message": "app.js存在", + "fix_hint": "" + }, + { + "name": "页面配置", + "status": "ok", + "message": "共9个页面", + "fix_hint": "" + }, + { + "name": "隐私配置", + "status": "ok", + "message": "已启用隐私检查", + "fix_hint": "" + }, + { + "name": "企业认证", + "status": "warning", + "message": "认证审核中", + "fix_hint": "等待审核结果" + }, + { + "name": "开发者工具", + "status": "ok", + "message": "微信开发者工具已安装", + "fix_hint": "" + }, + { + "name": "miniprogram-ci", + "status": "ok", + "message": "npm工具已安装", + "fix_hint": "" + }, + { + "name": "上传密钥", + "status": "warning", + "message": "未配置私钥", + "fix_hint": "在小程序后台下载代码上传密钥" + } + ], + "summary": { + "total": 10, + "ok": 8, + "warning": 2, + "error": 0, + "can_deploy": true, + "can_release": false + } +} \ No newline at end of file diff --git a/开发文档/小程序管理/scripts/reports/summary_20260125_113255.json b/开发文档/小程序管理/scripts/reports/summary_20260125_113255.json new file mode 100644 index 00000000..88ed994a --- /dev/null +++ b/开发文档/小程序管理/scripts/reports/summary_20260125_113255.json @@ -0,0 +1,88 @@ +{ + "generated_at": "2026-01-25T11:32:55.447833", + "total_apps": 1, + "summary": { + "ok": 0, + "warning": 1, + "error": 0, + "can_release": 0 + }, + "apps": [ + { + "app_id": "soul-party", + "app_name": "Soul派对", + "appid": "wxb8bbb2b10dec74aa", + "check_time": "2026-01-25T11:32:55.428736", + "checks": [ + { + "name": "项目路径", + "status": "ok", + "message": "路径存在: /Users/karuo/Documents/开发/3、自营项目/一场soul的创业实验/miniprogram", + "fix_hint": "" + }, + { + "name": "AppID配置", + "status": "ok", + "message": "AppID正确: wxb8bbb2b10dec74aa", + "fix_hint": "" + }, + { + "name": "API域名", + "status": "ok", + "message": "已配置HTTPS域名", + "fix_hint": "" + }, + { + "name": "入口文件", + "status": "ok", + "message": "app.js存在", + "fix_hint": "" + }, + { + "name": "页面配置", + "status": "ok", + "message": "共9个页面", + "fix_hint": "" + }, + { + "name": "隐私配置", + "status": "warning", + "message": "未启用隐私检查", + "fix_hint": "建议添加 __usePrivacyCheck__: true" + }, + { + "name": "企业认证", + "status": "warning", + "message": "认证审核中", + "fix_hint": "等待审核结果" + }, + { + "name": "开发者工具", + "status": "ok", + "message": "微信开发者工具已安装", + "fix_hint": "" + }, + { + "name": "miniprogram-ci", + "status": "ok", + "message": "npm工具已安装", + "fix_hint": "" + }, + { + "name": "上传密钥", + "status": "warning", + "message": "未配置私钥", + "fix_hint": "在小程序后台下载代码上传密钥" + } + ], + "summary": { + "total": 10, + "ok": 7, + "warning": 3, + "error": 0, + "can_deploy": true, + "can_release": false + } + } + ] +} \ No newline at end of file diff --git a/开发文档/小程序管理/scripts/requirements.txt b/开发文档/小程序管理/scripts/requirements.txt new file mode 100644 index 00000000..29b7c9d3 --- /dev/null +++ b/开发文档/小程序管理/scripts/requirements.txt @@ -0,0 +1,7 @@ +# 微信小程序管理工具依赖 + +# HTTP客户端 +httpx>=0.25.0 + +# 环境变量管理 +python-dotenv>=1.0.0 diff --git a/开发文档/服务器管理/SKILL.md b/开发文档/服务器管理/SKILL.md new file mode 100644 index 00000000..8bce80cd --- /dev/null +++ b/开发文档/服务器管理/SKILL.md @@ -0,0 +1,314 @@ +--- +name: 服务器管理 +description: 宝塔服务器统一管理与自动化部署。触发词:服务器、宝塔、部署、上线、发布、Node项目、SSL证书、HTTPS、DNS解析、域名配置、端口、PM2、Nginx、MySQL数据库、服务器状态。涵盖多服务器资产管理、Node.js项目一键部署、SSL证书管理、DNS配置、系统诊断等运维能力。 +--- + +# 服务器管理 + +让 AI 写完代码后,无需人工介入,自动把项目「变成一个在线网站」。 + +--- + +## 快速入口(复制即用) + +### 服务器资产 + +| 服务器 | IP | 配置 | 用途 | 宝塔面板 | +|--------|-----|------|------|----------| +| **小型宝塔** | 42.194.232.22 | 2核4G 5M | 主力部署(Node项目) | https://42.194.232.22:9988/ckbpanel | +| **存客宝** | 42.194.245.239 | 2核16G 50M | 私域银行业务 | https://42.194.245.239:9988 | +| **kr宝塔** | 43.139.27.93 | 2核4G 5M | 辅助服务器 | https://43.139.27.93:9988 | + +### 凭证速查 + +```bash +# SSH连接(小型宝塔为例) +ssh root@42.194.232.22 +密码: Zhiqun1984 + +# 宝塔面板登录(小型宝塔) +地址: https://42.194.232.22:9988/ckbpanel +账号: ckb +密码: zhiqun1984 + +# 宝塔API密钥 +小型宝塔: hsAWqFSi0GOCrunhmYdkxy92tBXfqYjd +存客宝: TNKjqDv5N1QLOU20gcmGVgr82Z4mXzRi +kr宝塔: qcWubCdlfFjS2b2DMT1lzPFaDfmv1cBT +``` + +--- + +## 一键操作 + +### 1. 检查服务器状态 + +```bash +# 运行快速检查脚本 +python3 /Users/karuo/Documents/个人/卡若AI/01_系统管理/服务器管理/scripts/快速检查服务器.py +``` + +### 2. 部署 Node 项目(标准流程) + +```bash +# 1. 压缩项目(排除无用目录) +cd /项目路径 +tar --exclude='node_modules' --exclude='.next' --exclude='.git' \ + -czf /tmp/项目名_update.tar.gz . + +# 2. 上传到服务器 +sshpass -p 'Zhiqun1984' scp /tmp/项目名_update.tar.gz root@42.194.232.22:/tmp/ + +# 3. SSH部署 +ssh root@42.194.232.22 +cd /www/wwwroot/项目名 +rm -rf app components lib public styles *.json *.js *.ts *.mjs *.md .next +tar -xzf /tmp/项目名_update.tar.gz +pnpm install +pnpm run build +rm /tmp/项目名_update.tar.gz + +# 4. 宝塔面板重启项目 +# 【网站】→【Node项目】→ 找到项目 → 点击【重启】 +``` + +### 3. SSL证书检查/修复 + +```bash +# 检查所有服务器SSL证书状态 +python3 /Users/karuo/Documents/个人/卡若AI/01_系统管理/服务器管理/scripts/ssl证书检查.py + +# 自动修复过期证书 +python3 /Users/karuo/Documents/个人/卡若AI/01_系统管理/服务器管理/scripts/ssl证书检查.py --fix +``` + +### 4. 常用诊断命令 + +```bash +# 检查端口占用 +ssh root@42.194.232.22 "ss -tlnp | grep :3006" + +# 检查PM2进程 +ssh root@42.194.232.22 "/www/server/nodejs/v22.14.0/bin/pm2 list" + +# 测试HTTP响应 +ssh root@42.194.232.22 "curl -I http://localhost:3006" + +# 检查Nginx配置 +ssh root@42.194.232.22 "nginx -t" + +# 重载Nginx +ssh root@42.194.232.22 "nginx -s reload" + +# DNS解析检查 +dig soul.quwanzhi.com +short @8.8.8.8 +``` + +--- + +## 端口配置表(小型宝塔 42.194.232.22) + +| 端口 | 项目名 | 类型 | 域名 | 状态 | +|------|--------|------|------|------| +| 3000 | cunkebao | Next.js | mckb.quwanzhi.com | ✅ | +| 3001 | ai_hair | NestJS | ai-hair.quwanzhi.com | ✅ | +| 3002 | kr_wb | Next.js | kr_wb.quwanzhi.com | ✅ | +| 3003 | hx | Vue | krjzk.quwanzhi.com | ⚠️ | +| 3004 | dlmdashboard | Next.js | dlm.quwanzhi.com | ✅ | +| 3005 | document | Next.js | docc.quwanzhi.com | ✅ | +| 3006 | soul | Next.js | soul.quwanzhi.com | ✅ | +| 3015 | 神射手 | Next.js | kr-users.quwanzhi.com | ⚠️ | +| 3018 | zhaoping | Next.js | zp.quwanzhi.com | ✅ | +| 3021 | is_phone | Next.js | is-phone.quwanzhi.com | ✅ | +| 3031 | word | Next.js | word.quwanzhi.com | ✅ | +| 3036 | ymao | Next.js | ymao.quwanzhi.com | ✅ | +| 3043 | tongzhi | Next.js | touzhi.lkdie.com | ✅ | +| 3045 | 玩值大屏 | Next.js | wz-screen.quwanzhi.com | ✅ | +| 3050 | zhiji | Next.js | zhiji.quwanzhi.com | ✅ | +| 3051 | zhiji1 | Next.js | zhiji1.quwanzhi.com | ✅ | +| 3055 | wzdj | Next.js | wzdj.quwanzhi.com | ✅ | +| 3305 | AITOUFA | Next.js | ai-tf.quwanzhi.com | ✅ | +| 9528 | mbti | Vue | mbtiadmin.quwanzhi.com | ✅ | + +### 端口分配原则 + +- **3000-3099**: Next.js / React 项目 +- **3100-3199**: Vue 项目 +- **3200-3299**: NestJS / Express 后端 +- **3300-3399**: AI相关项目 +- **9000-9999**: 管理面板 / 特殊用途 + +--- + +## 核心工作流程 + +``` +┌─────────────────────────────────────────────────────────────────────────────┐ +│ Node项目一键部署流程 │ +├─────────────────────────────────────────────────────────────────────────────┤ +│ │ +│ START │ +│ │ │ +│ ▼ │ +│ ┌──────────────────┐ │ +│ │ 1. 压缩本地代码 │ 排除 node_modules, .next, .git │ +│ └────────┬─────────┘ │ +│ │ │ +│ ▼ │ +│ ┌──────────────────┐ │ +│ │ 2. 上传到服务器 │ scp 到 /tmp/ │ +│ └────────┬─────────┘ │ +│ │ │ +│ ▼ │ +│ ┌──────────────────┐ │ +│ │ 3. 清理旧文件 │ 保留 .env 等配置文件 │ +│ └────────┬─────────┘ │ +│ │ │ +│ ▼ │ +│ ┌──────────────────┐ │ +│ │ 4. 解压新代码 │ tar -xzf │ +│ └────────┬─────────┘ │ +│ │ │ +│ ▼ │ +│ ┌──────────────────┐ │ +│ │ 5. 安装依赖 │ pnpm install │ +│ └────────┬─────────┘ │ +│ │ │ +│ ▼ │ +│ ┌──────────────────┐ │ +│ │ 6. 构建项目 │ pnpm run build │ +│ └────────┬─────────┘ │ +│ │ │ +│ ▼ │ +│ ┌──────────────────┐ │ +│ │ 7. 宝塔面板重启 │ Node项目 → 重启 │ +│ └────────┬─────────┘ │ +│ │ │ +│ ▼ │ +│ ┌──────────────────┐ │ +│ │ 8. 验证访问 │ curl https://域名 │ +│ └────────┬─────────┘ │ +│ │ │ +│ ▼ │ +│ SUCCESS │ +│ │ +└─────────────────────────────────────────────────────────────────────────────┘ +``` + +--- + +## 操作优先级矩阵 + +| 操作类型 | 优先方式 | 备选方式 | 说明 | +|---------|---------|---------|------| +| 查询信息 | ✅ 宝塔API | SSH | API稳定 | +| 文件操作 | ✅ 宝塔API | SSH | API支持 | +| 配置Nginx | ✅ 宝塔API | SSH | API可读写 | +| 重载服务 | ⚠️ SSH | - | API无接口 | +| 上传代码 | ⚠️ SSH/scp | - | 大文件 | +| 添加项目 | ❌ 宝塔界面 | - | API不稳定 | + +--- + +## 常见问题速查 + +### Q1: 外网无法访问(ERR_EMPTY_RESPONSE) + +**原因**: 腾讯云安全组只开放443端口 + +**解决**: +1. 必须配置SSL证书 +2. Nginx配置添加443监听 + +### Q2: Node项目启动失败(Could not find production build) + +**原因**: 使用 `npm run start` 但未执行 `npm run build` + +**解决**: 先 `pnpm run build` 再重启 + +### Q3: 端口冲突(EADDRINUSE) + +**解决**: +```bash +# 检查端口占用 +ss -tlnp | grep :端口号 + +# 修改package.json中的端口 +"start": "next start -p 新端口" +``` + +### Q4: DNS被代理劫持 + +**现象**: 本地DNS解析到198.18.x.x + +**解决**: +- 关闭代理软件 +- 或用手机4G网络测试 + +### Q5: 宝塔与PM2冲突 + +**原因**: 同时使用root用户PM2和宝塔PM2 + +**解决**: +- 停止所有独立PM2: `pm2 kill` +- 只使用宝塔界面管理 + +--- + +## 安全约束 + +### 绝对禁止 + +- ❌ 输出完整密码/密钥到聊天 +- ❌ 执行危险命令(rm -rf /, reboot等) +- ❌ 跳过验证步骤 +- ❌ 使用独立PM2(避免与宝塔冲突) + +### 必须遵守 + +- ✅ 操作前检查服务器状态 +- ✅ 操作后验证结果 +- ✅ 生成操作报告 + +--- + +## 相关脚本 + +| 脚本 | 功能 | 位置 | +|------|------|------| +| `快速检查服务器.py` | 一键检查所有服务器状态 | `./scripts/` | +| `一键部署.py` | 根据配置文件部署项目 | `./scripts/` | +| `ssl证书检查.py` | 检查/修复SSL证书 | `./scripts/` | + +--- + +## 相关文档 + +| 文档 | 内容 | 位置 | +|------|------|------| +| `宝塔API接口文档.md` | 宝塔API完整接口说明 | `./references/` | +| `端口配置表.md` | 完整端口分配表 | `./references/` | +| `常见问题手册.md` | 问题解决方案大全 | `./references/` | +| `部署配置模板.md` | JSON配置文件模板 | `./references/` | +| `系统架构说明.md` | 完整架构图和流程图 | `./references/` | + +--- + +## 历史对话整理 + +### kr_wb白板项目部署(2026-01-23) + +- 项目类型: Next.js +- 部署位置: /www/wwwroot/kr_wb +- 域名: kr_wb.quwanzhi.com +- 端口: 3002 +- 遇到问题: AI功能401错误(API密钥未配置) +- 解决方案: 修改 lib/ai-client.ts,改用 SiliconFlow 作为默认服务 + +### soul项目部署(2026-01-23) + +- 项目类型: Next.js +- 部署位置: /www/wwwroot/soul +- 域名: soul.quwanzhi.com +- 端口: 3006 +- 部署流程: 压缩→上传→解压→安装依赖→构建→PM2启动→配置Nginx→配置SSL diff --git a/开发文档/服务器管理/references/运维参考.md b/开发文档/服务器管理/references/运维参考.md new file mode 100644 index 00000000..fc781c96 --- /dev/null +++ b/开发文档/服务器管理/references/运维参考.md @@ -0,0 +1,3 @@ +# 运维参考(合并自 宝塔api、常见问题、端口配置、系统架构、部署配置) + +宝塔 API、常见问题、端口配置、系统架构说明、部署配置模板。详见原各文档。 diff --git a/开发文档/服务器管理/scripts/ssl证书检查.py b/开发文档/服务器管理/scripts/ssl证书检查.py new file mode 100644 index 00000000..4ac56952 --- /dev/null +++ b/开发文档/服务器管理/scripts/ssl证书检查.py @@ -0,0 +1,168 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +""" +SSL证书检查脚本 +=============== +用途:检查所有服务器的SSL证书状态 + +使用方法: +python3 ssl证书检查.py +python3 ssl证书检查.py --fix # 自动修复过期证书 +""" + +import sys +import time +import hashlib +import requests +import urllib3 +from datetime import datetime + +# 禁用SSL警告 +urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) + +# 服务器配置 +服务器列表 = { + "小型宝塔": { + "面板地址": "https://42.194.232.22:9988", + "密钥": "hsAWqFSi0GOCrunhmYdkxy92tBXfqYjd" + }, + "存客宝": { + "面板地址": "https://42.194.245.239:9988", + "密钥": "TNKjqDv5N1QLOU20gcmGVgr82Z4mXzRi" + }, + "kr宝塔": { + "面板地址": "https://43.139.27.93:9988", + "密钥": "qcWubCdlfFjS2b2DMT1lzPFaDfmv1cBT" + } +} + +def 生成签名(api_key: str) -> tuple: + """生成宝塔API签名""" + now_time = int(time.time()) + sign_str = str(now_time) + hashlib.md5(api_key.encode('utf-8')).hexdigest() + request_token = hashlib.md5(sign_str.encode('utf-8')).hexdigest() + return now_time, request_token + +def 获取证书列表(面板地址: str, 密钥: str) -> dict: + """获取SSL证书列表""" + now_time, request_token = 生成签名(密钥) + + url = f"{面板地址}/ssl?action=GetCertList" + data = { + "request_time": now_time, + "request_token": request_token + } + + try: + response = requests.post(url, data=data, timeout=10, verify=False) + return response.json() + except Exception as e: + return {"error": str(e)} + +def 获取网站列表(面板地址: str, 密钥: str) -> dict: + """获取网站列表""" + now_time, request_token = 生成签名(密钥) + + url = f"{面板地址}/data?action=getData&table=sites" + data = { + "request_time": now_time, + "request_token": request_token, + "limit": 100, + "p": 1 + } + + try: + response = requests.post(url, data=data, timeout=10, verify=False) + return response.json() + except Exception as e: + return {"error": str(e)} + +def 检查服务器证书(名称: str, 配置: dict) -> dict: + """检查单台服务器的证书状态""" + print(f"\n检查服务器: {名称}") + print("-" * 40) + + try: + # 获取网站列表 + 网站数据 = 获取网站列表(配置["面板地址"], 配置["密钥"]) + + if "error" in 网站数据: + print(f" ❌ API错误: {网站数据['error']}") + return {"error": 网站数据['error']} + + 网站列表 = 网站数据.get("data", []) + + if not 网站列表: + print(" ⚠️ 没有找到网站") + return {"网站数": 0} + + print(f" 📊 共 {len(网站列表)} 个网站") + + # 统计 + 已配置SSL = 0 + 未配置SSL = 0 + + for 网站 in 网站列表: + 网站名 = 网站.get("name", "未知") + ssl状态 = 网站.get("ssl", 0) + + if ssl状态: + 已配置SSL += 1 + 状态标识 = "🔒" + else: + 未配置SSL += 1 + 状态标识 = "🔓" + + print(f" {状态标识} {网站名}") + + print(f"\n 统计: 已配置SSL {已配置SSL} 个, 未配置 {未配置SSL} 个") + + return { + "网站数": len(网站列表), + "已配置SSL": 已配置SSL, + "未配置SSL": 未配置SSL + } + + except Exception as e: + print(f" ❌ 检查失败: {e}") + return {"error": str(e)} + +def main(): + 自动修复 = "--fix" in sys.argv + + print("=" * 60) + print(" SSL证书状态检查报告") + print(f" {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}") + print("=" * 60) + + 总统计 = { + "服务器数": 0, + "网站总数": 0, + "已配置SSL": 0, + "未配置SSL": 0 + } + + for 服务器名称, 配置 in 服务器列表.items(): + 结果 = 检查服务器证书(服务器名称, 配置) + + if "error" not in 结果: + 总统计["服务器数"] += 1 + 总统计["网站总数"] += 结果.get("网站数", 0) + 总统计["已配置SSL"] += 结果.get("已配置SSL", 0) + 总统计["未配置SSL"] += 结果.get("未配置SSL", 0) + + print("\n" + "=" * 60) + print(" 汇总统计") + print("=" * 60) + print(f" 服务器数量: {总统计['服务器数']}") + print(f" 网站总数: {总统计['网站总数']}") + print(f" 已配置SSL: {总统计['已配置SSL']} 🔒") + print(f" 未配置SSL: {总统计['未配置SSL']} 🔓") + print("=" * 60) + + if 自动修复 and 总统计['未配置SSL'] > 0: + print("\n⚠️ --fix 模式需要手动在宝塔面板配置SSL证书") + print(" 建议使用通配符证书 *.quwanzhi.com") + +if __name__ == "__main__": + main() diff --git a/开发文档/服务器管理/scripts/一键部署.py b/开发文档/服务器管理/scripts/一键部署.py new file mode 100644 index 00000000..a5660e18 --- /dev/null +++ b/开发文档/服务器管理/scripts/一键部署.py @@ -0,0 +1,138 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +""" +一键部署脚本 +============ +用途:根据配置文件一键部署Node项目到宝塔服务器 + +使用方法: +python3 一键部署.py 项目名称 本地项目路径 + +示例: +python3 一键部署.py soul /Users/karuo/Documents/开发/3、自营项目/一场soul的创业实验 +""" + +import sys +import os +import subprocess +import time + +# 默认服务器配置 +默认配置 = { + "服务器IP": "42.194.232.22", + "SSH用户": "root", + "SSH密码": "Zhiqun1984", + "服务器根目录": "/www/wwwroot" +} + +def 执行命令(命令: str, 显示输出: bool = True) -> tuple: + """执行shell命令""" + result = subprocess.run(命令, shell=True, capture_output=True, text=True) + if 显示输出 and result.stdout: + print(result.stdout) + if result.stderr and "Warning" not in result.stderr: + print(f"错误: {result.stderr}") + return result.returncode, result.stdout + +def 部署项目(项目名称: str, 本地路径: str): + """执行部署流程""" + 服务器路径 = f"{默认配置['服务器根目录']}/{项目名称}" + 压缩文件 = f"/tmp/{项目名称}_update.tar.gz" + + print(f"\n{'='*60}") + print(f"开始部署: {项目名称}") + print(f"本地路径: {本地路径}") + print(f"服务器路径: {服务器路径}") + print(f"{'='*60}\n") + + # 步骤1: 压缩项目 + print("📦 步骤1: 压缩项目文件...") + 排除项 = "--exclude='node_modules' --exclude='.next' --exclude='.git' --exclude='android' --exclude='out'" + 压缩命令 = f"cd '{本地路径}' && tar {排除项} -czf {压缩文件} ." + code, _ = 执行命令(压缩命令, False) + if code != 0: + print("❌ 压缩失败") + return False + + # 获取文件大小 + 大小 = os.path.getsize(压缩文件) / 1024 / 1024 + print(f" ✅ 压缩完成,大小: {大小:.2f} MB") + + # 步骤2: 上传到服务器 + print("\n📤 步骤2: 上传到服务器...") + 上传命令 = f"sshpass -p '{默认配置['SSH密码']}' scp -o StrictHostKeyChecking=no {压缩文件} {默认配置['SSH用户']}@{默认配置['服务器IP']}:/tmp/" + code, _ = 执行命令(上传命令, False) + if code != 0: + print("❌ 上传失败") + return False + print(" ✅ 上传完成") + + # 步骤3-6: SSH远程执行 + print("\n🔧 步骤3-6: 服务器端操作...") + + SSH前缀 = f"sshpass -p '{默认配置['SSH密码']}' ssh -o StrictHostKeyChecking=no {默认配置['SSH用户']}@{默认配置['服务器IP']}" + + # 清理旧文件 + 清理命令 = f"{SSH前缀} 'cd {服务器路径} && rm -rf app components lib public styles *.json *.js *.ts *.mjs *.md .next 2>/dev/null || true'" + 执行命令(清理命令, False) + print(" ✅ 清理旧文件") + + # 解压 + 解压命令 = f"{SSH前缀} 'cd {服务器路径} && tar -xzf /tmp/{项目名称}_update.tar.gz'" + 执行命令(解压命令, False) + print(" ✅ 解压新代码") + + # 安装依赖 + print("\n📚 安装依赖 (这可能需要几分钟)...") + 安装命令 = f"{SSH前缀} 'export PATH=/www/server/nodejs/v22.14.0/bin:$PATH && cd {服务器路径} && npm install --legacy-peer-deps 2>&1'" + 执行命令(安装命令, True) + + # 构建 + print("\n🏗️ 构建项目...") + 构建命令 = f"{SSH前缀} 'export PATH=/www/server/nodejs/v22.14.0/bin:$PATH && cd {服务器路径} && npm run build 2>&1'" + 执行命令(构建命令, True) + + # 重启PM2 + print("\n🔄 重启服务...") + 重启命令 = f"{SSH前缀} 'export PATH=/www/server/nodejs/v22.14.0/bin:$PATH && pm2 restart {项目名称} 2>&1'" + 执行命令(重启命令, True) + + # 清理临时文件 + 清理临时命令 = f"{SSH前缀} 'rm -f /tmp/{项目名称}_update.tar.gz'" + 执行命令(清理临时命令, False) + os.remove(压缩文件) + + print(f"\n{'='*60}") + print("✅ 部署完成!") + print(f"{'='*60}") + print("\n⚠️ 请在宝塔面板手动重启项目:") + print(f" 1. 登录 https://42.194.232.22:9988/ckbpanel") + print(f" 2. 进入【网站】→【Node项目】") + print(f" 3. 找到 {项目名称},点击【重启】") + + return True + +def main(): + if len(sys.argv) < 3: + print("用法: python3 一键部署.py <项目名称> <本地项目路径>") + print("\n示例:") + print(" python3 一键部署.py soul /Users/karuo/Documents/开发/3、自营项目/一场soul的创业实验") + print(" python3 一键部署.py kr_wb /Users/karuo/Documents/开发/4、小工具/whiteboard") + sys.exit(1) + + 项目名称 = sys.argv[1] + 本地路径 = sys.argv[2] + + if not os.path.exists(本地路径): + print(f"❌ 本地路径不存在: {本地路径}") + sys.exit(1) + + 确认 = input(f"\n确认部署 {项目名称} 到服务器? (y/n): ") + if 确认.lower() != 'y': + print("已取消部署") + sys.exit(0) + + 部署项目(项目名称, 本地路径) + +if __name__ == "__main__": + main() diff --git a/开发文档/服务器管理/scripts/快速检查服务器.py b/开发文档/服务器管理/scripts/快速检查服务器.py new file mode 100644 index 00000000..5667788c --- /dev/null +++ b/开发文档/服务器管理/scripts/快速检查服务器.py @@ -0,0 +1,104 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +""" +快速检查服务器状态 +================== +用途:一键检查所有服务器的基本状态 + +使用方法: +python3 快速检查服务器.py +""" + +import time +import hashlib +import requests +import urllib3 + +# 禁用SSL警告 +urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) + +# 服务器配置 +服务器列表 = { + "小型宝塔": { + "面板地址": "https://42.194.232.22:9988", + "密钥": "hsAWqFSi0GOCrunhmYdkxy92tBXfqYjd" + }, + "存客宝": { + "面板地址": "https://42.194.245.239:9988", + "密钥": "TNKjqDv5N1QLOU20gcmGVgr82Z4mXzRi" + }, + "kr宝塔": { + "面板地址": "https://43.139.27.93:9988", + "密钥": "qcWubCdlfFjS2b2DMT1lzPFaDfmv1cBT" + } +} + +def 生成签名(api_key: str) -> tuple: + """生成宝塔API签名""" + now_time = int(time.time()) + sign_str = str(now_time) + hashlib.md5(api_key.encode('utf-8')).hexdigest() + request_token = hashlib.md5(sign_str.encode('utf-8')).hexdigest() + return now_time, request_token + +def 获取系统信息(面板地址: str, 密钥: str) -> dict: + """获取系统基础统计信息""" + now_time, request_token = 生成签名(密钥) + + url = f"{面板地址}/system?action=GetSystemTotal" + data = { + "request_time": now_time, + "request_token": request_token + } + + try: + response = requests.post(url, data=data, timeout=10, verify=False) + return response.json() + except Exception as e: + return {"error": str(e)} + +def 检查单台服务器(名称: str, 配置: dict) -> dict: + """检查单台服务器状态""" + try: + 系统信息 = 获取系统信息(配置["面板地址"], 配置["密钥"]) + + if isinstance(系统信息, dict) and "error" not in 系统信息 and 系统信息.get("status") != False: + return { + "名称": 名称, + "状态": "✅ 正常", + "CPU": f"{系统信息.get('cpuRealUsed', 'N/A')}%", + "内存": f"{系统信息.get('memRealUsed', 'N/A')}%", + "磁盘": f"{系统信息.get('diskPer', 'N/A')}%" + } + else: + return { + "名称": 名称, + "状态": "❌ API错误", + "错误": str(系统信息) + } + except Exception as e: + return { + "名称": 名称, + "状态": "❌ 连接失败", + "错误": str(e) + } + +def main(): + print("=" * 60) + print(" 服务器状态检查报告") + print("=" * 60) + print() + + for 名称, 配置 in 服务器列表.items(): + 结果 = 检查单台服务器(名称, 配置) + print(f"📦 {结果['名称']}") + print(f" 状态: {结果['状态']}") + if "CPU" in 结果: + print(f" CPU: {结果['CPU']} | 内存: {结果['内存']} | 磁盘: {结果['磁盘']}") + if "错误" in 结果: + print(f" 错误: {结果['错误'][:50]}...") + print() + + print("=" * 60) + +if __name__ == "__main__": + main() diff --git a/开发文档/章节拖拽排序-后台说明.md b/开发文档/章节拖拽排序-后台说明.md new file mode 100644 index 00000000..e5dfd3c6 --- /dev/null +++ b/开发文档/章节拖拽排序-后台说明.md @@ -0,0 +1,74 @@ +# 章节拖拽排序 - 后台处理说明 + +## 一、后台已实现 + +### 1. 接口 + +- **路径**:`PUT /api/db/book` +- **鉴权**:需登录管理端(AdminAuth) + +**请求体**(拖拽排序时): +```json +{ + "action": "reorder", + "ids": ["1.1", "2.3", "3.1", ...] +} +``` + +- `ids`:所有 section 的 id,按新的排序顺序排列 +- 后端会依次将每条记录的 `sort_order` 更新为 0、1、2、… + +### 2. 代码位置 + +- `soul-api/internal/handler/db_book.go`:`DBBookAction` 中 `http.MethodPut` 分支,约第 196–206 行 + +--- + +## 二、数据库必须支持 + +### 1. `sort_order` 列 + +`chapters` 表必须有 `sort_order` 列,否则 `UPDATE sort_order` 会报错。 + +**检查**: +```sql +SHOW COLUMNS FROM chapters LIKE 'sort_order'; +``` + +**若不存在,执行迁移**: +```bash +cd e:\Gongsi\Mycontent +node .cursor/scripts/db-exec/run.js -f soul-api/scripts/add-sort-order-to-chapters.sql +``` + +或手动执行: +```sql +ALTER TABLE chapters ADD COLUMN sort_order INT DEFAULT 0; +``` + +### 2. 现有数据处理 + +若已有数据且 `sort_order` 为 NULL 或未设置,可先按当前顺序初始化: +```sql +SET @i = 0; +UPDATE chapters SET sort_order = (@i := @i + 1) ORDER BY id; +``` + +--- + +## 三、排查“无法拖拽” + +| 现象 | 可能原因 | 处理方式 | +|------|----------|----------| +| 拖不起来 | 拖拽手柄太小、浏览器兼容性 | 点击左侧 ⋮⋮ 后按住再拖动 | +| 拖到目标没反应 | 未触发 drop | 确认拖到其他 section 行再松手 | +| 松手后弹“排序失败” | 1. `sort_order` 列不存在
      2. 鉴权失败 401
      3. 接口异常 | 1. 执行迁移脚本
      2. 确认已登录管理端
      3. 查看 soul-api 日志和浏览器控制台 | + +--- + +## 四、快速验证 + +1. 执行迁移(若 `sort_order` 不存在) +2. 重启 soul-api +3. 在管理端登录后打开「内容管理 → 章节管理」 +4. 用 ⋮⋮ 拖拽某一节到另一位置,松手后应刷新并显示新顺序 diff --git a/派对AI/01_魂资(金)/Token管理/SKILL.md b/派对AI/01_魂资(金)/Token管理/SKILL.md new file mode 100644 index 00000000..da1e6c85 --- /dev/null +++ b/派对AI/01_魂资(金)/Token管理/SKILL.md @@ -0,0 +1,83 @@ +--- +name: Token管理 +description: 所有平台凭证(Token/Cookie/API密钥)统一管理、过期检测、刷新指南 +triggers: Token、Cookie、API密钥、凭证管理、刷新Token、配置密钥、环境变量 +owner: 魂资(金) +group: 金 +version: "1.0" +updated: "2026-03-13" +--- + +# Token管理 + +> 所有平台凭证统一从 `项目AI/config/.env` 读取。本 Skill 负责凭证的管理、检测与刷新。 + +--- + +## 能做什么 + +- 统一管理 8 个平台的凭证(飞书/数据库/抖音/B站/视频号/小红书/快手/Soul) +- 检测 Cookie 是否过期 +- 引导刷新过期凭证 +- 确保所有脚本从统一配置读取,不硬编码 + +--- + +## 怎么用 + +| 触发词 | 动作 | +|:---|:---| +| 检查Token | 检测所有平台凭证是否有效 | +| 刷新Cookie | 根据过期平台给出刷新步骤 | +| 配置环境变量 | 引导配置 `.env` 文件 | + +--- + +## 执行步骤 + +### 1. 首次配置 + +```bash +cd /Users/karuo/Documents/开发/3、自营项目/一场soul的创业实验-永平/项目AI/config +cp .env.example .env +# 编辑 .env 填入真实凭证 +``` + +### 2. 检测 Cookie 有效性 + +```bash +# 使用卡若AI多平台分发的检测脚本 +cd /Users/karuo/Documents/个人/卡若AI +python3 "03_卡木(木)/木叶_视频内容/多平台分发/脚本/check_cookies.py" +``` + +### 3. 刷新过期凭证 + +参照 `项目AI/config/credentials.md` 中各平台的刷新步骤,按过期频率优先处理: +1. 小红书(~7天)→ 每周刷新 +2. 抖音/快手(~30天)→ 每月刷新 +3. B站(~6个月)→ 每季度刷新 + +### 4. 加载环境变量(供其他脚本使用) + +```python +from pathlib import Path +from dotenv import load_dotenv +env_path = Path(__file__).resolve().parents[2] / "项目AI" / "config" / ".env" +load_dotenv(env_path) +``` + +--- + +## 相关文件 + +| 文件 | 说明 | +|:---|:---| +| `项目AI/config/.env.example` | 凭证模板(所有配置键) | +| `项目AI/config/.env` | 实际凭证(不入 Git) | +| `项目AI/config/credentials.md` | 各平台获取与刷新指南 | + +## 依赖 + +- python-dotenv(可选,用于 Python 脚本加载 .env) +- 各平台浏览器登录权限(用于提取 Cookie) diff --git a/派对AI/02_魂流(水)/Soul账号注册/SKILL.md b/派对AI/02_魂流(水)/Soul账号注册/SKILL.md new file mode 100644 index 00000000..d117ce6d --- /dev/null +++ b/派对AI/02_魂流(水)/Soul账号注册/SKILL.md @@ -0,0 +1,96 @@ +--- +name: Soul账号注册 +description: Soul App 账号注册、资料设置、派对房间管理 +triggers: Soul注册、Soul账号、注册Soul、Soul登录、Soul资料、Soul派对房间 +owner: 魂流(水) +group: 水 +version: "1.0" +updated: "2026-03-13" +--- + +# Soul账号注册 + +> Soul App 账号注册流程、资料完善、派对房间创建与管理。 + +--- + +## 能做什么 + +- 引导 Soul 新账号注册流程(手机号 + 验证码) +- 设置账号资料(昵称、头像、签名、标签) +- 创建/管理 Soul 派对房间 +- 记录账号信息到统一配置 + +--- + +## 怎么用 + +| 触发词 | 动作 | +|:---|:---| +| 注册Soul账号 | 引导注册流程 | +| 设置Soul资料 | 完善账号信息 | +| 创建派对房间 | 设置房间并开播 | + +--- + +## 执行步骤 + +### 1. 注册新账号 + +1. 下载 Soul App(iOS / Android) +2. 选择「手机号注册」 +3. 输入手机号 → 收取验证码 → 验证 +4. 设置密码(建议记录到 `config/.env` 的 `SOUL_PHONE` / `SOUL_PASSWORD`) +5. 完成灵魂测试(性格测试,影响推荐算法) + +### 2. 完善账号资料 + +| 项目 | 建议设置 | 说明 | +|:---|:---|:---| +| 昵称 | 与创业实验主题相关 | 如「创业实验室」「Soul创业派对」 | +| 头像 | 品牌化头像 | 建议用统一视觉设计 | +| 签名 | 简明传达价值 | 如「每周三/五开派对,聊创业真实故事」 | +| 标签 | 创业/商业/赚钱/职场 | 增加曝光匹配度 | +| 星球 | 完善星球资料 | 建立社区信任 | + +### 3. 创建派对房间 + +1. Soul App → 广场 → 派对 → 创建房间 +2. 设置房间名称(如「第119场|聊聊副业怎么起步」) +3. 选择房间类型(推荐:多人语音房) +4. 设置房间标签(创业/商业/副业) +5. 开启投流(如需要):设置每日曝光预算 + +### 4. 投流参数参考 + +| 参数 | 参考值 | 说明 | +|:---|:---|:---| +| 日预算 | 50-200元 | 按效果调整 | +| 曝光进房比 | 约75-80曝光进1人 | 行业均值 | +| 日曝光量 | 约30000 | 200元预算参考 | +| 进房量 | 300-600人/天 | 日均参考 | +| CPM | 约6-10元/千次曝光 | 每进一人约4毛2 | +| 微信获客成本 | 约20元/人 | 从Soul到微信 | + +--- + +## 凭证依赖 + +| 配置键 | 用途 | +|:---|:---| +| `SOUL_PHONE` | Soul 登录手机号 | +| `SOUL_PASSWORD` | Soul 登录密码 | + +--- + +## 相关文件 + +| 文件 | 说明 | +|:---|:---| +| `项目AI/config/.env` | Soul 账号凭证存储 | +| 卡若AI `Soul创业实验/写作/写作规范.md` | 投流数据参考(写作时引用) | + +## 依赖 + +- Soul App(iOS / Android) +- 手机号(用于注册) diff --git a/派对AI/02_魂流(水)/运营报表/SKILL.md b/派对AI/02_魂流(水)/运营报表/SKILL.md new file mode 100644 index 00000000..a187f331 --- /dev/null +++ b/派对AI/02_魂流(水)/运营报表/SKILL.md @@ -0,0 +1,95 @@ +--- +name: 运营报表 +description: Soul派对运营数据→飞书表格→智能纪要→飞书群推送 +triggers: 运营报表、派对填表、派对截图、运营数据、本月数据、效果数据、第X场数据 +owner: 魂流(水) +group: 水 +version: "1.0" +updated: "2026-03-13" +--- + +# 运营报表 + +> 每场 Soul 派对结束后,将效果数据写入飞书运营表格,并推送到飞书群。 + +--- + +## 能做什么 + +- 解析派对截图 / TXT 文件中的运营数据(场次、在线人数、互动率等) +- 写入飞书电子表格(按月分 sheet) +- 智能纪要图片入表 +- 推送到飞书群(Soul 彩民团队) + +--- + +## 怎么用 + +``` +用户:第118场运营数据,在线峰值320人,互动率45% +AI:[解析数据 → 写入飞书表格 → 推送群消息] +``` + +--- + +## 执行步骤 + +### 1. 准备数据 + +数据来源(任一): +- 派对截图(AI 识别提取数字) +- TXT 文件(场次效果数据) +- 用户口述(直接告知数据) + +### 2. 写入飞书表格 + +```bash +cd /Users/karuo/Documents/个人/卡若AI +python3 "02_卡人(水)/水桥_平台对接/飞书管理/脚本/soul_party_to_feishu_sheet.py" \ + --session 118 \ + --data '{"peak_online": 320, "interaction_rate": 0.45}' +``` + +**飞书表格配置**: +- spreadsheet_token: `wikcnIgAGSNHo0t36idHJ668Gfd` +- 2月 sheet: `7A3Cy9` +- 3月 sheet: `bJR5sA` + +### 3. 智能纪要入表(如有会议纪要截图) + +```bash +python3 "02_卡人(水)/水桥_平台对接/飞书管理/脚本/feishu_write_minutes_to_sheet.py" +``` + +### 4. 推送到飞书群 + +```bash +python3 "02_卡人(水)/水桥_平台对接/飞书管理/脚本/send_to_feishu.py" \ + --webhook "$FEISHU_WEBHOOK_SOUL_TEAM" \ + --message "第118场运营数据已更新" +``` + +--- + +## 凭证依赖 + +| 配置键 | 用途 | +|:---|:---| +| `FEISHU_APP_ID` / `FEISHU_APP_SECRET` | 获取 tenant_access_token 操作表格 | +| `FEISHU_WEBHOOK_SOUL_TEAM` | 推送到 Soul 彩民团队群 | + +--- + +## 相关文件 + +| 文件 | 说明 | +|:---|:---| +| 卡若AI `飞书管理/运营报表_SKILL.md` | 完整运营报表 Skill(主参照) | +| 卡若AI `飞书管理/脚本/soul_party_to_feishu_sheet.py` | 核心填表脚本 | +| 卡若AI `飞书管理/脚本/feishu_write_minutes_to_sheet.py` | 纪要图写入 | +| 卡若AI `飞书管理/脚本/send_to_feishu.py` | 群消息推送 | + +## 依赖 + +- Python 3.9+、requests +- 飞书凭证(见 Token管理 S01) diff --git a/派对AI/02_魂流(水)/飞书管理/SKILL.md b/派对AI/02_魂流(水)/飞书管理/SKILL.md new file mode 100644 index 00000000..f0ce5512 --- /dev/null +++ b/派对AI/02_魂流(水)/飞书管理/SKILL.md @@ -0,0 +1,104 @@ +--- +name: 飞书管理 +description: 飞书妙记下载、视频下载、群推送、知识库上传——Soul创业实验飞书全链路 +triggers: 飞书、飞书群、飞书推送、飞书下载、妙记下载、飞书视频、飞书文档、飞书知识库 +owner: 魂流(水) +group: 水 +version: "1.0" +updated: "2026-03-13" +--- + +# 飞书管理 + +> Soul 创业实验所有飞书相关操作的统一入口:妙记下载、视频下载、群推送、知识库上传。 + +--- + +## 能做什么 + +- **妙记下载**:从飞书妙记链接下载文本/视频(单条或批量) +- **视频下载**:从飞书云文档/妙记下载视频文件到本地 +- **群推送**:向指定飞书群发送文本/图片/富文本消息 +- **知识库上传**:上传文档到飞书知识库(wiki) +- **表格操作**:读写飞书电子表格(运营报表等) + +--- + +## 怎么用 + +| 触发词 | 动作 | +|:---|:---| +| 飞书妙记下载 + URL | 下载指定妙记的文本和视频 | +| 飞书视频下载 | 从飞书下载视频到本地 | +| 发飞书群 | 推送消息到 Soul 团队群 | +| 上传飞书知识库 | 上传文档到 wiki | + +--- + +## 执行步骤 + +### 1. 飞书妙记下载 + +```bash +cd /Users/karuo/Documents/个人/卡若AI +python3 "02_卡人(水)/水桥_平台对接/智能纪要/脚本/feishu_minutes_download.py" \ + --url "https://meetings.feishu.cn/minutes/xxxxx" \ + --output "/Users/karuo/Downloads/" +``` + +支持批量下载:`--batch urls.txt` + +详细用法参照卡若AI智能纪要 Skill: +`卡若AI/02_卡人(水)/水桥_平台对接/智能纪要/SKILL.md` + +### 2. 飞书群推送(文本) + +```bash +cd /Users/karuo/Documents/开发/3、自营项目/一场soul的创业实验-永平 +python3 scripts/post_to_feishu.py --message "推送内容" --webhook "$FEISHU_WEBHOOK_SOUL_TEAM" +``` + +### 3. 飞书群推送(海报图 + 文本,章节推送专用) + +```bash +python3 scripts/send_chapter_poster_to_feishu.py 9.24 "第112场|标题" --md "文章路径.md" +``` + +效果:先发文章前 6% 正文(一句一行),再发海报图(含小程序码)。 + +### 4. 飞书知识库上传 + +```bash +python3 scripts/feishu_wiki_upload.py --title "文档标题" --content "内容" --node "$FEISHU_WIKI_NODE_TOKEN" +``` + +--- + +## 凭证依赖 + +| 配置键 | 用途 | +|:---|:---| +| `FEISHU_APP_ID` / `FEISHU_APP_SECRET` | tenant_access_token(API 调用) | +| `FEISHU_WEBHOOK_SOUL_TEAM` | Soul 彩民团队群 webhook | +| `FEISHU_WEBHOOK_CONTENT` | 内容推送群 webhook | +| `FEISHU_WIKI_NODE_TOKEN` | 知识库目标节点 | + +飞书凭证配置见 `项目AI/config/.env`,`.env.feishu` 也兼容(`scripts/.env.feishu`)。 + +--- + +## 相关文件 + +| 文件 | 说明 | +|:---|:---| +| 永平项目 `scripts/send_chapter_poster_to_feishu.py` | 章节海报生成与推送 | +| 永平项目 `scripts/post_to_feishu.py` | 通用飞书群推送 | +| 永平项目 `scripts/feishu_wiki_upload.py` | 知识库上传 | +| 永平项目 `scripts/.env.feishu` | 飞书凭证(兼容旧配置) | +| 卡若AI `智能纪要/SKILL.md` | 飞书妙记完整 Skill | +| 卡若AI `飞书管理/SKILL.md` | 飞书管理完整 Skill | + +## 依赖 + +- Python 3.9+、requests、Pillow(海报生成) +- 飞书凭证(见 Token管理 S01) diff --git a/派对AI/03_魂产(木)/文章写作/SKILL.md b/派对AI/03_魂产(木)/文章写作/SKILL.md new file mode 100644 index 00000000..522adffc --- /dev/null +++ b/派对AI/03_魂产(木)/文章写作/SKILL.md @@ -0,0 +1,142 @@ +--- +name: 文章写作 +description: 按写作规范写第9章文章→上传小程序数据库→推送飞书群 +triggers: 写文章、写Soul文章、第9章、写场次、上传文章、内容上传、写完上传 +owner: 魂产(木) +group: 木 +version: "1.0" +updated: "2026-03-13" +--- + +# 文章写作 + +> 按写作规范写《一场soul的创业实验》第9章单场文章,写完后上传到小程序,可选推送到飞书群。 + +--- + +## 能做什么 + +- **写作**:按 6:3:1 比例写第9章单场文章(60% 核心干货 / 30% 次要 / 10% 其它) +- **上传**:`content_upload.py` 写入 `soul_miniprogram.chapters` 数据库 +- **推送**:上传后可发飞书群(前6%正文 + 海报图,不发链接) + +--- + +## 怎么用 + +| 触发词 | 动作 | +|:---|:---| +| 写第X场 / 写Soul文章 | 按写作规范写文章 | +| 上传文章 / 发到小程序 | 执行 content_upload.py | +| 写完推送 | 上传后推送飞书群 | + +--- + +## 执行步骤 + +### 子类一:写作 + +**先读写作规范**(唯一来源): +`卡若AI/02_卡人(水)/水桥_平台对接/Soul创业实验/写作/写作规范.md` + +**核心规则**: +- **人称**:用「我」,不用「房主」 +- **风格**:大白话、每句空一行 +- **内容比例**:6:3:1(60% 核心 / 30% 次要 / 10% 其它) +- **核心干货块**:约 50% 处插入 3-5 条可执行、紧扣主题的干货 +- **数值与场景**:有数值必须写具体(如「约75-80曝光进1人」「每天约3万曝光」) +- **分享句**:约 20% 处 + 结尾各一句 +- **隐晦植入**:联系管理/切片/副业自然提及 + +**输出路径**:书稿第9章目录 `9.xx 第X场|主题.md` + +### 子类二:上传到小程序 + +```bash +cd /Users/karuo/Documents/开发/3、自营项目/一场soul的创业实验-永平 + +# 第9章文章(标准) +python3 content_upload.py \ + --id 9.24 \ + --title "第112场|一个人起头,维权挣了大半套房" \ + --content-file "/path/to/article.md" \ + --part part-4 \ + --chapter chapter-9 \ + --price 1.0 + +# 2026每日派对干货(自动编号 10.xx) +python3 content_upload.py \ + --title "标题" \ + --content-file "/path/to/article.md" \ + --part part-2026-daily \ + --chapter chapter-2026-daily \ + --price 1.0 +``` + +**参数说明**: +- `--id`:指定 section ID(如 `9.24`),不指定则自动生成 +- `--part`:所属篇(`part-4` = 第四篇|真实的赚钱) +- `--chapter`:所属章(`chapter-9` = 第9章) +- `--price`:定价(`0` = 免费,`1.0` = 1元) +- ID 已存在则**更新**,不存在则**新建** + +**查看结构**: +```bash +python3 content_upload.py --list-structure +python3 content_upload.py --list-chapters +``` + +### 子类三:推送飞书群 + +仅在用户明确说「推送」时执行: + +```bash +python3 scripts/send_chapter_poster_to_feishu.py 9.24 \ + "第112场|一个人起头,维权挣了大半套房" \ + --md "/path/to/article.md" +``` + +推送效果: +1. 先发**文本消息**:标题 + 文章前 6% 正文(一句一行、行间空一行) +2. 再发**海报图**:深蓝渐变背景 + 标题 + 摘要 + 小程序码 +3. **不发小程序链接**,仅通过海报二维码引导阅读 + +--- + +## 凭证依赖 + +| 配置键 | 用途 | +|:---|:---| +| `DB_HOST` / `DB_PORT` / `DB_USER` / `DB_PASS` / `DB_NAME` | 数据库写入 | +| `FEISHU_APP_ID` / `FEISHU_APP_SECRET` | 海报上传飞书(推送时) | +| `FEISHU_WEBHOOK_SOUL_TEAM` | 推送到群(推送时) | + +--- + +## 篇章映射 + +| part_id | 篇名 | +|:---|:---| +| part-1 | 第一篇|真实的人 | +| part-2 | 第二篇|真实的行业 | +| part-3 | 第三篇|真实的错误 | +| part-4 | 第四篇|真实的赚钱(第9章在此) | +| part-5 | 第五篇|真实的社会 | +| part-2026-daily | 2026每日派对干货 | + +--- + +## 相关文件 + +| 文件 | 说明 | +|:---|:---| +| 卡若AI `Soul创业实验/写作/写作规范.md` | 写作唯一规范 | +| 卡若AI `Soul创业实验/上传/README.md` | 上传命令说明 | +| 卡若AI `Soul创业实验/上传/推送逻辑.md` | 飞书推送规则 | +| 永平项目 `content_upload.py` | 内容上传脚本 | +| 永平项目 `scripts/send_chapter_poster_to_feishu.py` | 海报生成与推送 | + +## 依赖 + +- Python 3.9+、pymysql、requests、Pillow +- 数据库凭证 + 飞书凭证(见 Token管理 S01) diff --git a/派对AI/03_魂产(木)/素材库上传/SKILL.md b/派对AI/03_魂产(木)/素材库上传/SKILL.md new file mode 100644 index 00000000..9146b522 --- /dev/null +++ b/派对AI/03_魂产(木)/素材库上传/SKILL.md @@ -0,0 +1,100 @@ +--- +name: 素材库上传 +description: 成片/切片→飞书内容看板多维表格,含附件上传+多平台描述 +triggers: 素材库、发到素材库、成片发飞书、切片发飞书、视频分发飞书、发到素材库 +owner: 魂产(木) +group: 木 +version: "1.0" +updated: "2026-03-13" +--- + +# 素材库上传 + +> 将 Soul 派对成片/切片上传到飞书内容看板(多维表格),包含视频附件 + 多平台描述文案。 + +--- + +## 能做什么 + +- 将本地成片/切片视频上传到飞书云盘(Drive) +- 在飞书多维表格中创建记录,关联视频附件 +- 自动填写多平台描述(抖音/小红书/视频号/B站/快手) +- 记录标题、时间、进展状态 + +--- + +## 怎么用 + +``` +用户:第119场的切片发到素材库 +AI:[上传视频到飞书Drive → 在多维表格创建记录 → 填写多平台描述] +``` + +--- + +## 执行步骤 + +### 1. 上传到飞书素材库 + +```bash +cd /Users/karuo/Documents/个人/卡若AI +python3 "02_卡人(水)/水桥_平台对接/飞书管理/脚本/feishu_slice_upload_to_wiki_table.py" \ + --video "/path/to/成片/clip_001.mp4" \ + --title "119场 3月13日 副业怎么起步" \ + --date "2026-03-13" \ + --status "待发布" +``` + +### 2. 多维表格字段 + +| 字段 | 说明 | 示例 | +|:---|:---|:---| +| 标题 | 场次+日期+主题 | 119场 3月13日 副业怎么起步 | +| 时间 | 录制/剪辑日期 | 2026-03-13 | +| 进展状态 | 待剪辑/剪辑中/待发布/已发布 | 待发布 | +| 附件 | 视频文件(上传到飞书Drive) | clip_001.mp4 | +| 抖音描述 | 抖音平台文案+标签 | #创业 #副业 | +| 小红书描述 | 小红书平台文案+标签 | 分享创业干货… | +| 视频号描述 | 视频号平台文案 | 每周聊创业真实故事 | +| B站描述 | B站平台文案+分区 | 知识区/职场 | +| 快手描述 | 快手平台文案 | 真实创业故事 | + +### 3. 批量上传 + +```bash +# 上传整个成片目录 +python3 feishu_slice_upload_to_wiki_table.py \ + --dir "/path/to/成片/" \ + --prefix "119场 3月13日" +``` + +--- + +## 目标飞书表格 + +- **知识库地址**:`https://cunkebao.feishu.cn/wiki/MKhNwmYwpi1hXIkJvfCcu31vnDh` +- **多维表格ID**:`tblGjpeCk1ADQMEX` + +--- + +## 凭证依赖 + +| 配置键 | 用途 | +|:---|:---| +| `FEISHU_APP_ID` / `FEISHU_APP_SECRET` | tenant_access_token | +| `FEISHU_BITABLE_APP_TOKEN` | 多维表格 app_token | +| `FEISHU_BITABLE_TABLE_ID` | 多维表格 table_id | + +--- + +## 相关文件 + +| 文件 | 说明 | +|:---|:---| +| 卡若AI `飞书管理/Soul发到素材库_SKILL.md` | 完整素材库 Skill | +| 卡若AI `飞书管理/脚本/feishu_slice_upload_to_wiki_table.py` | 核心上传脚本 | + +## 依赖 + +- Python 3.9+、requests +- 飞书凭证(见 Token管理 S01) diff --git a/派对AI/03_魂产(木)/视频剪辑/SKILL.md b/派对AI/03_魂产(木)/视频剪辑/SKILL.md new file mode 100644 index 00000000..5b52dc99 --- /dev/null +++ b/派对AI/03_魂产(木)/视频剪辑/SKILL.md @@ -0,0 +1,138 @@ +--- +name: 视频剪辑 +description: Soul派对录屏→竖屏切片→封面+字幕+后期→成片输出 +triggers: 视频剪辑、视频切片、Soul切片、竖屏切片、视频后期、封面生成、字幕、视频包装 +owner: 魂产(木) +group: 木 +version: "1.0" +updated: "2026-03-13" +--- + +# 视频剪辑 + +> Soul 派对录屏 → 转录 → 高光识别 → 竖屏切片 → 封面+字幕+后期包装 → 成片。 +> 核心脚本来自卡若AI `木叶_视频内容/视频切片/`,本 Skill 作为 Soul 项目专用入口。 + +--- + +## 能做什么 + +- **转录**:视频→文字(MLX Whisper 本地转录,无需云端API) +- **高光识别**:从转录文本中识别精彩片段(问答/hook/金句) +- **批量切片**:按高光时间戳批量裁剪 +- **Soul竖屏专用**:498×1080 竖屏中段裁剪 +- **后期增强**:自动封面(文字叠加)、字幕、加速、去语助词 +- **苹果毛玻璃浮层**:visual_enhance 加高级感浮层效果 +- **一体化流水线**:`soul_slice_pipeline.py` 一键完成全流程 + +--- + +## 怎么用 + +| 触发词 | 动作 | +|:---|:---| +| Soul视频切片 | 一体化流水线:转录→高光→切片→后期 | +| 竖屏切片 | 原视频裁剪为 498×1080 竖屏 | +| 封面生成 | 为切片生成带标题的封面图 | +| 视频后期 | 字幕+加速+去语助词+毛玻璃效果 | + +--- + +## 执行步骤 + +### 方式一:一体化流水线(推荐) + +```bash +cd /Users/karuo/Documents/个人/卡若AI/03_卡木(木)/木叶_视频内容/视频切片/脚本 + +python3 soul_slice_pipeline.py \ + --input "/path/to/soul_party_recording.mp4" \ + --output "/path/to/output/" \ + --vertical # 竖屏模式 +``` + +流水线自动完成: +1. MLX Whisper 转录 → `.srt` 字幕文件 +2. `identify_highlights.py` 高光识别 → 时间戳列表 +3. `batch_clip.py` 批量切片 → `clips/` 目录 +4. `soul_enhance.py` 后期处理 → `成片/` 目录 + - 封面叠加(标题文字) + - 字幕嵌入 + - 加速处理(可选) + - 去语助词(嗯、啊、那个等) + +### 方式二:分步执行 + +#### 步骤1:转录 + +```bash +python3 -c "import mlx_whisper; ..." \ + --input video.mp4 --output transcript.srt +``` + +#### 步骤2:高光识别 + +```bash +python3 identify_highlights.py --transcript transcript.srt --mode question +# mode: question(问答高光)/ hook_3sec(开头3秒hook)/ quote(金句) +``` + +#### 步骤3:批量切片 + +```bash +python3 batch_clip.py --input video.mp4 --highlights highlights.json --output clips/ +``` + +#### 步骤4:竖屏裁剪 + +```bash +python3 soul_vertical_crop.py --input clips/ --output vertical/ --size 498x1080 +``` + +#### 步骤5:后期增强 + +```bash +python3 soul_enhance.py --input vertical/ --output 成片/ \ + --cover --subtitle --speed 1.0 --remove-filler +``` + +#### 步骤6:毛玻璃浮层(可选,高级感) + +```bash +python3 visual_enhance.py --input 成片/clip_001.mp4 --style apple_blur +``` + +--- + +## 输出规范 + +| 项目 | 规格 | +|:---|:---| +| 分辨率 | 498×1080(竖屏) | +| 时长 | 15-60秒(单条切片) | +| 封面 | 第一帧 + 标题文字叠加 | +| 字幕 | 底部居中,白色描边 | +| 格式 | MP4(H.264 + AAC) | +| 输出目录 | `clips/`(原始切片)、`成片/`(后期完成) | + +--- + +## 相关文件(卡若AI) + +| 文件 | 说明 | +|:---|:---| +| `03_卡木(木)/木叶_视频内容/视频切片/SKILL.md` | 视频切片主 Skill | +| `视频切片/Soul竖屏切片_SKILL.md` | Soul 竖屏专用 Skill | +| `视频切片/脚本/soul_slice_pipeline.py` | 一体化流水线 | +| `视频切片/脚本/soul_enhance.py` | 封面+字幕+加速+去语助词 | +| `视频切片/脚本/soul_vertical_crop.py` | 竖屏中段裁剪 | +| `视频切片/脚本/batch_clip.py` | 批量切片 | +| `视频切片/脚本/identify_highlights.py` | 高光识别 | +| `视频切片/脚本/visual_enhance.py` | 苹果毛玻璃浮层 | + +## 依赖 + +- Python 3.9+、ffmpeg(系统级) +- mlx-whisper(Apple Silicon 本地转录) +- Pillow(封面生成) +- 无需云端 API(全部本地处理) diff --git a/派对AI/04_魂码(火)/小程序站管理/SKILL.md b/派对AI/04_魂码(火)/小程序站管理/SKILL.md new file mode 100644 index 00000000..de74d752 --- /dev/null +++ b/派对AI/04_魂码(火)/小程序站管理/SKILL.md @@ -0,0 +1,153 @@ +--- +name: 小程序站管理 +description: Soul创业派对三端管理——小程序(C端)+管理端(React)+API后端(Go/Gin) +triggers: 小程序、管理端、网站管理、soul-admin、miniprogram、soul-api、三端、发布小程序 +owner: 魂码(火) +group: 火 +version: "1.0" +updated: "2026-03-13" +--- + +# 小程序站管理 + +> Soul 创业派对三端管理:微信小程序(C端)、React管理后台、Go API后端。 +> 代码开发已有完整 `.cursor/skills/` 覆盖,本 Skill 聚焦运维与发布管理。 + +--- + +## 能做什么 + +- **小程序发布**:代码上传、审核、发布微信小程序 +- **管理端运维**:React 管理后台部署与维护 +- **API 后端运维**:Go + Gin + GORM 后端服务管理 +- **数据库管理**:`soul_miniprogram` 数据库维护 +- **域名与证书**:SSL 证书管理 + +--- + +## 三端架构 + +``` +┌─────────────────────────────────────────────────┐ +│ 用户访问 │ +├──────────────┬──────────────┬───────────────────┤ +│ 微信小程序 │ 管理后台 │ API 后端 │ +│ miniprogram │ soul-admin │ soul-api │ +│ WXML/WXSS │ React/Vite │ Go/Gin/GORM │ +│ /api/mini* │ /api/admin* │ 路由分组 │ +│ │ /api/db/* │ │ +└──────────┬───┴──────┬───────┴────────┬──────────┘ + │ │ │ + └──────────┴────────────────┘ + │ + soul.quwanzhi.com +``` + +**路由隔离(强制)**: +- 小程序只调 `/api/miniprogram/*` +- 管理端只调 `/api/admin/*`、`/api/db/*` +- 禁止混用 + +--- + +## 执行步骤 + +### 1. 小程序发布 + +```bash +cd /Users/karuo/Documents/开发/3、自营项目/一场soul的创业实验-永平 + +# 使用小程序管理脚本 +python3 开发文档/小程序管理/scripts/mp_deploy.py --action upload +python3 开发文档/小程序管理/scripts/mp_deploy.py --action submit_audit +python3 开发文档/小程序管理/scripts/mp_deploy.py --action release +``` + +### 2. 管理端部署 + +```bash +# 构建 +cd soul-admin && npm run build + +# 部署到服务器(宝塔面板) +bash 部署到Kr宝塔.sh +``` + +### 3. API 后端部署 + +```bash +# 构建 +cd soul-api && go build -o soul-api + +# 部署 +bash 部署永平到Kr宝塔.sh +``` + +### 4. 数据库操作 + +```bash +# 通过 db-exec 脚本执行 SQL(MCP 不可用时) +cd .cursor/scripts/db-exec +node exec.js "SELECT COUNT(*) FROM chapters" + +# 查看文章列表 +python3 content_upload.py --list-chapters +``` + +### 5. 从 GitHub 拉取最新代码 + +```bash +bash 从GitHub下载最新_devlop.sh +``` + +--- + +## 开发规范引用 + +代码开发遵循已有 `.cursor/skills/` 中的规范: + +| Skill | 路径 | 适用 | +|:---|:---|:---| +| 小程序开发 | `.cursor/skills/miniprogram-dev/SKILL.md` | miniprogram/ 下编辑 | +| 管理端开发 | `.cursor/skills/admin-dev/SKILL.md` | soul-admin/ 下编辑 | +| API 后端开发 | `.cursor/skills/api-dev/SKILL.md` | soul-api/ 下编辑 | +| 变更检查 | `.cursor/skills/change-checklist/SKILL.md` | 任何变更后必过 | +| 测试 | `.cursor/skills/testing/SKILL.md` | 功能测试、回归测试 | + +--- + +## 线上环境 + +| 项目 | 地址 | +|:---|:---| +| 小程序后端 | `https://soul.quwanzhi.com/api/` | +| 二维码接口 | `https://soul.quwanzhi.com/api/miniprogram/qrcode` | +| 管理端 | 宝塔面板部署 | +| GitHub 仓库 | `https://github.com/fnvtk/Mycontent/tree/yongpxu-soul` | + +--- + +## 凭证依赖 + +| 配置键 | 用途 | +|:---|:---| +| `DB_*` | 数据库连接 | +| `WX_COMPONENT_*` | 微信第三方平台(小程序发布) | +| `WX_AUTHORIZER_*` | 授权小程序凭证 | + +--- + +## 相关文件 + +| 文件 | 说明 | +|:---|:---| +| `开发文档/小程序管理/scripts/` | 小程序管理脚本集 | +| `开发文档/服务器管理/scripts/` | 服务器管理脚本集 | +| `开发文档/8、部署/部署总览.md` | 部署完整文档 | +| `.cursor/skills/` | 全套开发规范 Skill | + +## 依赖 + +- Node.js(管理端构建)、Go 1.25+(API构建) +- 微信开发者工具(小程序预览) +- 宝塔面板(服务器管理) diff --git a/派对AI/05_魂质(土)/多平台分发/SKILL.md b/派对AI/05_魂质(土)/多平台分发/SKILL.md new file mode 100644 index 00000000..65a25d8d --- /dev/null +++ b/派对AI/05_魂质(土)/多平台分发/SKILL.md @@ -0,0 +1,175 @@ +--- +name: 多平台分发 +description: 飞书视频下载→5平台一键分发(抖音/B站/视频号/小红书/快手),Cookie统一管理 +triggers: 多平台分发、一键分发、抖音发布、B站发布、视频号发布、小红书发布、快手发布、飞书视频下载、全平台发布、批量分发、视频分发 +owner: 魂质(土) +group: 土 +version: "1.0" +updated: "2026-03-13" +--- + +# 多平台分发 + +> 从飞书下载视频 → 一键分发到 5 个平台(抖音/B站/视频号/小红书/快手)。 +> 核心脚本来自卡若AI `木叶_视频内容/多平台分发/` + 各平台发布 Skill。 + +--- + +## 能做什么 + +- **飞书视频下载**:从飞书妙记/云文档下载视频到本地 +- **一键5平台分发**:`distribute_all.py` 同时发布到抖音/B站/视频号/小红书/快手 +- **单平台发布**:指定发布到某一个平台 +- **元数据生成**:从文件名自动生成标题、标签、分区 +- **定时发布**:设置排期时间,到时自动发布 +- **Cookie 有效性检测**:发布前自动检测 Cookie 是否过期 + +--- + +## 怎么用 + +| 触发词 | 动作 | +|:---|:---| +| 一键分发 / 全平台发布 | 5平台同时发布 | +| 发到抖音 | 仅发布到抖音 | +| 发到B站 | 仅发布到B站 | +| 发到视频号 | 仅发布到视频号 | +| 发到小红书 | 仅发布到小红书 | +| 发到快手 | 仅发布到快手 | +| 飞书视频下载 | 从飞书下载视频 | + +--- + +## 执行步骤 + +### 1. 从飞书下载视频 + +```bash +cd /Users/karuo/Documents/个人/卡若AI +python3 "02_卡人(水)/水桥_平台对接/智能纪要/脚本/feishu_minutes_download.py" \ + --url "https://meetings.feishu.cn/minutes/xxxxx" \ + --output "/path/to/downloads/" \ + --video-only +``` + +### 2. 一键5平台分发(推荐) + +```bash +cd /Users/karuo/Documents/个人/卡若AI/03_卡木(木)/木叶_视频内容/多平台分发/脚本 + +python3 distribute_all.py \ + --video "/path/to/成片/clip_001.mp4" \ + --title "第119场|副业怎么起步" \ + --tags "创业,副业,赚钱,Soul派对" \ + --now # 立即发布(不加则用排期模式) +``` + +### 3. 单平台发布 + +#### 抖音(纯API,无需浏览器) + +```bash +cd /Users/karuo/Documents/个人/卡若AI/03_卡木(木)/木叶_视频内容/抖音发布/脚本 +python3 douyin_publish.py --video clip.mp4 --title "标题" --cookie "$DOUYIN_COOKIE" +``` + +#### B站(纯API,分片上传) + +```bash +cd /Users/karuo/Documents/个人/卡若AI/03_卡木(木)/木叶_视频内容/B站发布/脚本 +python3 bilibili_publish.py --video clip.mp4 --title "标题" --cookie "$BILIBILI_COOKIE" +``` + +#### 视频号(纯API,微信扫码登录) + +```bash +cd /Users/karuo/Documents/个人/卡若AI/03_卡木(木)/木叶_视频内容/视频号发布/脚本 +python3 wechat_channels_publish.py --video clip.mp4 --title "标题" +# 首次运行会弹出二维码,微信扫码确认 +``` + +#### 小红书(逆向API) + +```bash +cd /Users/karuo/Documents/个人/卡若AI/03_卡木(木)/木叶_视频内容/小红书发布/脚本 +python3 xiaohongshu_publish.py --video clip.mp4 --title "标题" --cookie "$XIAOHONGSHU_COOKIE" +``` + +#### 快手(逆向API) + +```bash +cd /Users/karuo/Documents/个人/卡若AI/03_卡木(木)/木叶_视频内容/快手发布/脚本 +python3 kuaishou_publish.py --video clip.mp4 --title "标题" --cookie "$KUAISHOU_COOKIE" +``` + +--- + +## 完整链路:飞书→切片→分发 + +``` +飞书妙记/视频 + │ feishu_minutes_download.py(下载) + ↓ +本地原始视频 + │ soul_slice_pipeline.py(切片+后期) + ↓ +成片目录(clips/、成片/) + │ feishu_slice_upload_to_wiki_table.py(素材库登记) + ↓ +飞书内容看板 + │ distribute_all.py(一键分发) + ↓ +5平台同时发布 +├── 抖音(API,VOD + bd-ticket-guard) +├── B站(API,preupload 分片) +├── 视频号(API,finder-assistant 腾讯云上传) +├── 小红书(逆向 creator API,封面取第一帧) +└── 快手(逆向 cp.kuaishou.com API) +``` + +--- + +## 各平台发布策略 + +| 平台 | 方式 | Cookie有效期 | 特殊说明 | +|:---|:---|:---|:---| +| 抖音 | 纯API | ~30天 | VOD 上传 + bd-ticket-guard 签名 | +| B站 | 纯API | ~6个月 | preupload 分片上传 | +| 视频号 | 纯API | 单次扫码 | finder-assistant + 腾讯云上传 | +| 小红书 | 逆向API | ~7天 | creator API,封面取第一帧 | +| 快手 | 逆向API | ~30天 | cp.kuaishou.com API | + +--- + +## 凭证依赖 + +| 配置键 | 用途 | +|:---|:---| +| `DOUYIN_COOKIE` | 抖音发布 | +| `BILIBILI_COOKIE` | B站发布 | +| `XIAOHONGSHU_COOKIE` | 小红书发布 | +| `KUAISHOU_COOKIE` | 快手发布 | +| `FEISHU_APP_ID` / `FEISHU_APP_SECRET` | 飞书视频下载 | + +视频号无需 Cookie,运行时微信扫码。 + +--- + +## 相关文件(卡若AI) + +| 文件 | 说明 | +|:---|:---| +| `03_卡木(木)/木叶_视频内容/多平台分发/SKILL.md` | 多平台分发主 Skill | +| `多平台分发/脚本/distribute_all.py` | 一键5平台分发 | +| `抖音发布/SKILL.md` | 抖音专用 Skill | +| `B站发布/SKILL.md` | B站专用 Skill | +| `视频号发布/SKILL.md` | 视频号专用 Skill | +| `小红书发布/SKILL.md` | 小红书专用 Skill | +| `快手发布/SKILL.md` | 快手专用 Skill | +| `智能纪要/SKILL.md` | 飞书妙记下载 | + +## 依赖 + +- Python 3.9+、requests、Playwright(小红书/快手备用) +- ffmpeg(封面提取) +- 各平台 Cookie(见 Token管理 S01) diff --git a/派对AI/BOOTSTRAP.md b/派对AI/BOOTSTRAP.md new file mode 100644 index 00000000..6595fecc --- /dev/null +++ b/派对AI/BOOTSTRAP.md @@ -0,0 +1,111 @@ +# Soul创业实验AI · 启动指令 + +> **本文件是 Soul创业实验AI 的唯一启动入口。** 读完即可接活、干活、交付。 +> 版本:1.0 | 更新:2026-03-13 +> 项目:《一场soul的创业实验》内容运营与分发体系 + +--- + +## 一、你是谁 + +- **名字**:Soul创业实验AI(简称「魂AI」) +- **身份**:《一场soul的创业实验》项目的内容运营智能助手 +- **职责**:视频剪辑、文章写作、运营报表、飞书管理、多平台分发、小程序站管理、素材库上传、Soul账号注册 +- **工作台**:`/Users/karuo/Documents/开发/3、自营项目/一场soul的创业实验-永平/项目AI/` + +### 关联路径 + +| 名称 | 路径 | +|:---|:---| +| 永平项目根目录 | `/Users/karuo/Documents/开发/3、自营项目/一场soul的创业实验-永平/` | +| 书稿目录 | `/Users/karuo/Documents/个人/2、我写的书/《一场soul的创业实验》/` | +| 卡若AI | `/Users/karuo/Documents/个人/卡若AI/` | +| 卡若AI视频切片脚本 | `卡若AI/03_卡木(木)/木叶_视频内容/视频切片/脚本/` | +| 卡若AI多平台分发脚本 | `卡若AI/03_卡木(木)/木叶_视频内容/多平台分发/脚本/` | +| 飞书运营报表脚本 | `卡若AI/02_卡人(水)/水桥_平台对接/飞书管理/脚本/` | + +--- + +## 二、团队(五行 · 5组 → 9技能) + +``` +Soul创业实验AI(魂AI) +├── 魂资(金)"配置稳了。" → Token管理(凭证/Cookie/API 统一管理) +├── 魂流(水)"数据清了。" → 运营报表、飞书管理、Soul账号注册 +├── 魂产(木)"内容出了!" → 视频剪辑、文章写作、素材库上传 +├── 魂码(火)"站点好了。" → 小程序站管理(三端:小程序/管理端/API) +└── 魂质(土)"分发完了。" → 多平台分发(飞书下载→5平台分发) +``` + +**分配规则**:用户说需求 → 魂AI按关键词匹配对应组 → 读 SKILL.md 执行。 + +--- + +## 三、启动顺序 + +| 步骤 | 读什么 | 为什么 | +|:---|:---|:---| +| 1 | **本文件** `BOOTSTRAP.md` | 知道自己是谁、怎么工作 | +| 2 | **技能注册表** `SKILL_REGISTRY.md` | 按关键词找到对应技能路径 | +| 3 | **对应技能的 SKILL.md** | 拿到具体执行指令 | +| 4 | **凭证配置** `config/credentials.md` | 确认 Token/Cookie 可用 | + +--- + +## 四、执行流程 + +``` +用户需求 → 匹配技能(查 SKILL_REGISTRY)→ 读 SKILL.md → 检查凭证(config/)→ 执行 + ↑ │ + └── 失败:检查 Token 过期?→ 刷新凭证 → 重试 ──────────────────────────┘ + ↓ + 成功 → 交付 +``` + +### 凭证优先级 + +所有需要 Token/Cookie/API 的操作,**统一从 `config/` 读取**,不在各脚本中硬编码: + +1. 先检查 `项目AI/config/.env`(本地实际配置,不入 Git) +2. 若缺失,提示参照 `项目AI/config/.env.example` 配置 +3. 凭证过期时,参照 `项目AI/config/credentials.md` 刷新指南 + +--- + +## 五、凭证总览 + +> 详细配置与刷新方法见 `config/credentials.md`。 + +| 平台 | 凭证类型 | 配置键名 | 有效期 | 刷新方式 | +|:---|:---|:---|:---|:---| +| 飞书 | App ID + Secret | `FEISHU_APP_ID` / `FEISHU_APP_SECRET` | 长期 | 飞书开放平台 | +| 飞书 | Webhook URL | `FEISHU_WEBHOOK_*` | 长期 | 群机器人设置 | +| 飞书 | Wiki Token | `FEISHU_WIKI_NODE_TOKEN` | 长期 | 知识库页面URL | +| 数据库 | MySQL 连接 | `DB_HOST` / `DB_PORT` / `DB_USER` / `DB_PASS` / `DB_NAME` | 长期 | 腾讯云控制台 | +| 抖音 | Cookie | `DOUYIN_COOKIE` | ~30天 | 浏览器登录后提取 | +| B站 | Cookie | `BILIBILI_COOKIE` | ~6个月 | 浏览器登录后提取 | +| 视频号 | 微信扫码 | 无需存储 | 单次 | 每次扫码登录 | +| 小红书 | Cookie | `XIAOHONGSHU_COOKIE` | ~7天 | 浏览器登录后提取 | +| 快手 | Cookie | `KUAISHOU_COOKIE` | ~30天 | 浏览器登录后提取 | +| Soul | 账号密码 | `SOUL_PHONE` / `SOUL_PASSWORD` | 长期 | Soul App 注册 | + +--- + +## 六、核心规则 + +1. **凭证不硬编码**:所有 Token/Cookie/API 密钥统一放 `config/.env`,脚本从环境变量读取 +2. **脚本复用卡若AI**:视频剪辑、多平台分发等脚本已在卡若AI中,直接引用不重复创建 +3. **终端命令直接执行**:需要在终端执行的一律直接执行,不询问 +4. **安全**:`.env` 文件不入 Git(已在 `.gitignore`),凭证变更及时更新 `credentials.md` + +--- + +## 七、核心文件导航 + +| 文件 | 路径 | 用途 | +|:---|:---|:---| +| **启动指令** | `BOOTSTRAP.md`(本文件) | 唯一入口 | +| **技能注册表** | `SKILL_REGISTRY.md` | 9 技能一张表 | +| **凭证配置模板** | `config/.env.example` | 所有平台凭证模板 | +| **凭证刷新指南** | `config/credentials.md` | 各平台 Token 获取与刷新方法 | +| **使用手册** | `README.md` | 完整使用说明 | diff --git a/派对AI/README.md b/派对AI/README.md new file mode 100644 index 00000000..955d134e --- /dev/null +++ b/派对AI/README.md @@ -0,0 +1,189 @@ +# Soul创业实验AI · 使用手册 + +> **《一场soul的创业实验》项目的内容运营智能助手。** +> 覆盖视频剪辑、文章写作、运营报表、飞书管理、多平台分发、小程序站管理、素材库上传、Soul账号注册。 + +--- + +## 快速开始 + +### 1. 首次配置凭证 + +```bash +cd /Users/karuo/Documents/开发/3、自营项目/一场soul的创业实验-永平/项目AI/config +cp .env.example .env +# 编辑 .env 填入各平台真实凭证 +``` + +### 2. 告诉AI你要做什么 + +直接说需求,魂AI会自动匹配对应技能: + +| 你说的 | AI做的 | +|:---|:---| +| 「帮我切片第119场视频」 | 读视频剪辑Skill → 执行切片流水线 | +| 「写第119场文章」 | 读文章写作Skill → 按写作规范写作 | +| 「上传到小程序」 | 执行 content_upload.py | +| 「发飞书群」 | 生成海报 + 推送飞书群 | +| 「一键分发到5个平台」 | 读多平台分发Skill → distribute_all.py | +| 「第119场运营数据」 | 读运营报表Skill → 填飞书表格 | +| 「发到素材库」 | 上传到飞书多维表格 | +| 「检查Cookie」 | 检测各平台凭证有效性 | + +--- + +## 目录结构 + +``` +项目AI/ +├── BOOTSTRAP.md ← 启动指令(AI 第一个读的文件) +├── SKILL_REGISTRY.md ← 9 技能一张表(按关键词查找) +├── README.md ← 本文件(使用手册) +│ +├── config/ ← 凭证统一管理 +│ ├── .env.example ← 模板(所有平台配置键) +│ ├── .env ← 实际凭证(不入Git) +│ └── credentials.md ← 凭证获取与刷新指南 +│ +├── 01_魂资(金)/ ← 配置与存储 +│ └── Token管理/SKILL.md ← S01 凭证管理 +│ +├── 02_魂流(水)/ ← 运营与协调 +│ ├── 运营报表/SKILL.md ← S02 派对数据→飞书表格 +│ ├── 飞书管理/SKILL.md ← S03 妙记下载/群推送/知识库 +│ └── Soul账号注册/SKILL.md ← S04 Soul账号与派对房间 +│ +├── 03_魂产(木)/ ← 内容创作 +│ ├── 视频剪辑/SKILL.md ← S05 录屏→竖屏切片→成片 +│ ├── 文章写作/SKILL.md ← S06 写文章→上传→推送 +│ └── 素材库上传/SKILL.md ← S07 成片→飞书内容看板 +│ +├── 04_魂码(火)/ ← 网站与程序 +│ └── 小程序站管理/SKILL.md ← S08 三端管理与发布 +│ +└── 05_魂质(土)/ ← 分发与变现 + └── 多平台分发/SKILL.md ← S09 5平台一键分发 +``` + +--- + +## 9 个技能速查 + +### S01 · Token管理(金) + +管理 8 个平台的凭证,统一从 `config/.env` 读取。 + +| 平台 | 有效期 | 刷新频率 | +|:---|:---|:---| +| 小红书 | ~7天 | 每周 | +| 抖音/快手 | ~30天 | 每月 | +| B站 | ~6个月 | 每季度 | +| 飞书/数据库 | 长期 | 仅重置时 | + +### S02 · 运营报表(水) + +``` +派对截图/TXT → soul_party_to_feishu_sheet.py → 飞书电子表格 → 发群 +``` + +### S03 · 飞书管理(水) + +- 妙记下载:`feishu_minutes_download.py --url <妙记链接>` +- 群推送:`send_chapter_poster_to_feishu.py "<标题>"` +- 知识库上传:`feishu_wiki_upload.py` + +### S04 · Soul账号注册(水) + +Soul App 注册 → 灵魂测试 → 资料完善 → 创建派对房间 → 投流设置。 + +### S05 · 视频剪辑(木) + +``` +录屏 → MLX转录 → 高光识别 → 批量切片 → 竖屏裁剪(498×1080) → 封面+字幕+后期 → 成片 +一键命令:python3 soul_slice_pipeline.py --input video.mp4 --vertical +``` + +### S06 · 文章写作(木) + +``` +写作规范(6:3:1) → 写文章 → content_upload.py上传 → send_chapter_poster推送 +``` + +### S07 · 素材库上传(木) + +``` +成片 → feishu_slice_upload_to_wiki_table.py → 飞书内容看板(多维表格) +``` + +### S08 · 小程序站管理(火) + +三端管理:miniprogram(小程序)+ soul-admin(管理端)+ soul-api(API后端)。 +开发规范引用 `.cursor/skills/` 中的完整 Skill 集。 + +### S09 · 多平台分发(土) + +``` +飞书视频下载 → 切片(可选) → distribute_all.py → 5平台同时发布 +平台:抖音(API) / B站(API) / 视频号(扫码) / 小红书(逆向) / 快手(逆向) +``` + +--- + +## 典型工作流 + +### 流程A:派对完整流程 + +``` +1. Soul账号注册(S04) → 创建派对房间 → 开播 +2. 运营报表(S02) → 派对数据填入飞书表格 +3. 视频剪辑(S05) → 录屏切片为成片 +4. 素材库上传(S07) → 成片登记到飞书看板 +5. 多平台分发(S09) → 成片发到5个平台 +``` + +### 流程B:文章发布流程 + +``` +1. 文章写作(S06) → 按规范写第9章文章 +2. 上传(S06) → content_upload.py 写入数据库 +3. 推送(S03) → 海报+摘要发飞书群 +``` + +### 流程C:飞书妙记→全链路 + +``` +1. 飞书管理(S03) → 下载妙记视频 +2. 视频剪辑(S05) → 切片+后期 +3. 素材库上传(S07) → 登记到内容看板 +4. 文章写作(S06) → 妙记文字写成文章 +5. 多平台分发(S09) → 视频发5平台 +``` + +--- + +## 与卡若AI的关系 + +本项目AI是卡若AI的子项目,聚焦于 Soul 创业实验的内容运营。 + +**复用卡若AI的能力**: +- 视频切片脚本 → `卡若AI/03_卡木(木)/木叶_视频内容/` +- 多平台分发脚本 → `卡若AI/03_卡木(木)/木叶_视频内容/多平台分发/` +- 飞书管理脚本 → `卡若AI/02_卡人(水)/水桥_平台对接/飞书管理/` +- 智能纪要/妙记下载 → `卡若AI/02_卡人(水)/水桥_平台对接/智能纪要/` +- 写作规范 → `卡若AI/02_卡人(水)/水桥_平台对接/Soul创业实验/` + +**本项目独有**: +- `content_upload.py` → 文章上传到小程序数据库 +- `scripts/send_chapter_poster_to_feishu.py` → 海报生成与推送 +- `.cursor/skills/` → 三端开发规范 +- `开发文档/` → 完整开发文档体系 + +--- + +## 注意事项 + +1. **凭证安全**:`config/.env` 包含敏感信息,已在 `.gitignore` 中排除,不要提交到 Git +2. **Cookie 过期**:小红书每周需刷新,抖音/快手每月刷新,发布前先检测 +3. **视频号扫码**:视频号每次发布需微信扫码,无法完全自动化 +4. **数据库直连**:`content_upload.py` 直连腾讯云 MySQL,注意网络环境 +5. **开发 vs 运营**:代码开发用 `.cursor/skills/`,内容运营用 `项目AI/` diff --git a/派对AI/SKILL_REGISTRY.md b/派对AI/SKILL_REGISTRY.md new file mode 100644 index 00000000..123c3cf1 --- /dev/null +++ b/派对AI/SKILL_REGISTRY.md @@ -0,0 +1,75 @@ +# Soul创业实验AI · 技能注册表 + +> **一张表查所有技能。** 按关键词找到 SKILL.md 路径并执行。 +> 9 技能 | 5 组 | 版本:1.0 | 更新:2026-03-13 + +--- + +## 使用方法 + +1. 用户说需求 → 在「触发词」列搜索匹配 +2. 找到行 → 读「SKILL 路径」列的文件 +3. 按 SKILL.md 里的步骤执行 + +--- + +## 金组 · 魂资(配置与存储) + +| # | 技能 | 触发词 | SKILL 路径 | 一句话 | +|:--|:---|:---|:---|:---| +| S01 | **Token管理** | Token、Cookie、API密钥、凭证管理、刷新Token、配置密钥、环境变量 | `01_魂资(金)/Token管理/SKILL.md` | 所有平台凭证统一管理、过期检测、刷新指南 | + +## 水组 · 魂流(运营与协调) + +| # | 技能 | 触发词 | SKILL 路径 | 一句话 | +|:--|:---|:---|:---|:---| +| S02 | **运营报表** | 运营报表、派对填表、派对截图、运营数据、本月数据、效果数据 | `02_魂流(水)/运营报表/SKILL.md` | 派对截图+TXT→飞书表格→智能纪要→飞书群推送 | +| S03 | **飞书管理** | 飞书、飞书群、飞书推送、飞书下载、妙记下载、飞书视频、飞书文档、飞书知识库 | `02_魂流(水)/飞书管理/SKILL.md` | 飞书妙记下载、视频下载、群推送、知识库上传 | +| S04 | **Soul账号注册** | Soul注册、Soul账号、注册Soul、Soul登录、Soul资料 | `02_魂流(水)/Soul账号注册/SKILL.md` | Soul App 账号注册、资料设置、派对房间管理 | + +## 木组 · 魂产(内容创作) + +| # | 技能 | 触发词 | SKILL 路径 | 一句话 | +|:--|:---|:---|:---|:---| +| S05 | **视频剪辑** | 视频剪辑、视频切片、Soul切片、竖屏切片、视频后期、封面生成、字幕 | `03_魂产(木)/视频剪辑/SKILL.md` | Soul派对录屏→竖屏切片→封面+字幕+后期→成片 | +| S06 | **文章写作** | 写文章、写Soul文章、第9章、写场次、上传文章、内容上传 | `03_魂产(木)/文章写作/SKILL.md` | 按写作规范写第9章文章→上传小程序→推送飞书群 | +| S07 | **素材库上传** | 素材库、发到素材库、成片发飞书、切片发飞书、视频分发飞书 | `03_魂产(木)/素材库上传/SKILL.md` | 成片/切片→飞书内容看板多维表格,含附件+多平台描述 | + +## 火组 · 魂码(网站与程序) + +| # | 技能 | 触发词 | SKILL 路径 | 一句话 | +|:--|:---|:---|:---|:---| +| S08 | **小程序站管理** | 小程序、管理端、网站管理、soul-admin、miniprogram、soul-api、三端 | `04_魂码(火)/小程序站管理/SKILL.md` | 小程序+管理端+API后端三端管理、发布、运维 | + +## 土组 · 魂质(分发与变现) + +| # | 技能 | 触发词 | SKILL 路径 | 一句话 | +|:--|:---|:---|:---|:---| +| S09 | **多平台分发** | 多平台分发、一键分发、抖音发布、B站发布、视频号发布、小红书发布、快手发布、飞书视频下载 | `05_魂质(土)/多平台分发/SKILL.md` | 飞书视频下载→5平台一键分发(抖音/B站/视频号/小红书/快手) | + +--- + +## 技能联动关系 + +``` +飞书妙记下载(S03) + ├── → 视频剪辑(S05)→ 成片 → 素材库上传(S07)→ 多平台分发(S09) + └── → 文章写作(S06)→ 小程序上传 → 飞书群推送(S03) + +Soul账号注册(S04)→ 开派对 → 运营报表(S02)→ 飞书群推送 + +Token管理(S01)← 所有技能依赖(凭证过期时回到 S01 刷新) +``` + +--- + +## 统计 + +| 组 | 名称 | 技能数 | +|:--|:---|:--| +| 金 | 魂资 | 1 | +| 水 | 魂流 | 3 | +| 木 | 魂产 | 3 | +| 火 | 魂码 | 1 | +| 土 | 魂质 | 1 | +| **合计** | | **9** | diff --git a/派对AI/config/.env.example b/派对AI/config/.env.example new file mode 100644 index 00000000..dc884685 --- /dev/null +++ b/派对AI/config/.env.example @@ -0,0 +1,49 @@ +# ============================================================ +# Soul创业实验AI · 统一凭证配置 +# 复制本文件为 .env 后填入真实值,.env 不入 Git +# ============================================================ + +# ---- 飞书(长期有效)---- +FEISHU_APP_ID=cli_xxxxxxxxxxxxxxxx +FEISHU_APP_SECRET=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +FEISHU_WIKI_NODE_TOKEN=xxxxxxxxxxxxxxxx + +# 飞书群 Webhook(按群分) +FEISHU_WEBHOOK_SOUL_TEAM=https://open.feishu.cn/open-apis/bot/v2/hook/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx +FEISHU_WEBHOOK_CONTENT=https://open.feishu.cn/open-apis/bot/v2/hook/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx + +# 飞书素材库多维表格 +FEISHU_BITABLE_APP_TOKEN=xxxxxxxxxxxxxxxx +FEISHU_BITABLE_TABLE_ID=tblxxxxxxxxxxxxxxxx + +# ---- 数据库(腾讯云 MySQL)---- +DB_HOST=56b4c23f6853c.gz.cdb.myqcloud.com +DB_PORT=14413 +DB_USER=cdb_outerroot +DB_PASS=请填入数据库密码 +DB_NAME=soul_miniprogram + +# ---- 抖音(Cookie 约30天过期)---- +DOUYIN_COOKIE=请从浏览器登录 creator.douyin.com 后提取 + +# ---- B站(Cookie 约6个月过期)---- +BILIBILI_COOKIE=请从浏览器登录 member.bilibili.com 后提取 + +# ---- 小红书(Cookie 约7天过期)---- +XIAOHONGSHU_COOKIE=请从浏览器登录 creator.xiaohongshu.com 后提取 + +# ---- 快手(Cookie 约30天过期)---- +KUAISHOU_COOKIE=请从浏览器登录 cp.kuaishou.com 后提取 + +# ---- 视频号(无需存储,每次微信扫码登录)---- +# 视频号不需要 Cookie,运行分发脚本时会弹出二维码扫码 + +# ---- Soul App ---- +SOUL_PHONE=手机号 +SOUL_PASSWORD=密码 + +# ---- 小程序管理 ---- +WX_COMPONENT_APPID=第三方平台AppID +WX_COMPONENT_APPSECRET=第三方平台AppSecret +WX_AUTHORIZER_APPID=授权小程序AppID +WX_AUTHORIZER_REFRESH_TOKEN=授权刷新Token diff --git a/派对AI/config/credentials.md b/派对AI/config/credentials.md new file mode 100644 index 00000000..166b2248 --- /dev/null +++ b/派对AI/config/credentials.md @@ -0,0 +1,141 @@ +# Soul创业实验AI · 凭证清单与刷新指南 + +> 所有平台凭证统一在 `config/.env` 管理。本文档说明每个凭证的获取方式、有效期和刷新步骤。 + +--- + +## 一、飞书凭证 + +### 1.1 App ID / App Secret(长期有效) + +- **用途**:获取 `tenant_access_token`,用于飞书 API 调用(上传图片、操作表格、知识库等) +- **获取**: + 1. 登录 [飞书开放平台](https://open.feishu.cn/app) + 2. 进入应用 → 凭证与基础信息 → 复制 App ID 和 App Secret +- **配置键**:`FEISHU_APP_ID`、`FEISHU_APP_SECRET` +- **有效期**:永久(除非重置) + +### 1.2 Webhook URL(长期有效) + +- **用途**:向飞书群发送消息(运营报表、文章推送等) +- **获取**: + 1. 飞书群 → 设置 → 群机器人 → 添加机器人 → 自定义机器人 + 2. 复制 Webhook 地址 +- **配置键**:`FEISHU_WEBHOOK_SOUL_TEAM`(Soul团队群)、`FEISHU_WEBHOOK_CONTENT`(内容推送群) +- **当前默认**:`https://open.feishu.cn/open-apis/bot/v2/hook/34b762fc-5b9b-4abb-a05a-96c8fb9599f1` + +### 1.3 Wiki Node Token(长期有效) + +- **用途**:飞书知识库上传 +- **获取**:知识库页面 URL 中的 token 部分 +- **配置键**:`FEISHU_WIKI_NODE_TOKEN` + +### 1.4 素材库多维表格 + +- **用途**:成片/切片上传到飞书内容看板 +- **目标表格**:`https://cunkebao.feishu.cn/wiki/MKhNwmYwpi1hXIkJvfCcu31vnDh?table=tblGjpeCk1ADQMEX` +- **配置键**:`FEISHU_BITABLE_APP_TOKEN`、`FEISHU_BITABLE_TABLE_ID` + +--- + +## 二、数据库凭证 + +### 2.1 腾讯云 MySQL(长期有效) + +- **用途**:`content_upload.py` 写入/更新文章到 `soul_miniprogram.chapters` 表 +- **获取**:腾讯云控制台 → 云数据库 MySQL → 实例详情 +- **配置键**:`DB_HOST`、`DB_PORT`、`DB_USER`、`DB_PASS`、`DB_NAME` +- **当前值**: + - Host: `56b4c23f6853c.gz.cdb.myqcloud.com` + - Port: `14413` + - Database: `soul_miniprogram` +- **注意**:`content_upload.py` 中当前硬编码了 `DB_CONFIG`,建议迁移为读取 `.env` + +--- + +## 三、视频平台 Cookie + +### 3.1 抖音(~30天过期) + +- **用途**:视频上传到抖音创作者平台 +- **获取步骤**: + 1. 浏览器登录 [creator.douyin.com](https://creator.douyin.com) + 2. F12 → Application → Cookies → 复制全部 Cookie 字符串 + 3. 或使用 [EditThisCookie](https://www.editthiscookie.com/) 插件导出 +- **配置键**:`DOUYIN_COOKIE` +- **过期检测**:分发脚本会自动检测,返回 401/302 即过期 + +### 3.2 B站(~6个月过期) + +- **用途**:视频上传到 B站 +- **获取步骤**: + 1. 浏览器登录 [member.bilibili.com](https://member.bilibili.com) + 2. F12 → Application → Cookies → 复制 `SESSDATA`、`bili_jct`、`DedeUserID` +- **配置键**:`BILIBILI_COOKIE` +- **关键字段**:`SESSDATA`(鉴权主字段) + +### 3.3 视频号(单次扫码,无需存储) + +- **用途**:视频上传到微信视频号 +- **方式**:运行分发脚本时弹出二维码,微信扫码确认即可 +- **无需配置** + +### 3.4 小红书(~7天过期,最短) + +- **用途**:视频笔记发布到小红书 +- **获取步骤**: + 1. 浏览器登录 [creator.xiaohongshu.com](https://creator.xiaohongshu.com) + 2. F12 → Application → Cookies → 复制全部 +- **配置键**:`XIAOHONGSHU_COOKIE` +- **注意**:有效期最短,建议每周刷新 + +### 3.5 快手(~30天过期) + +- **用途**:视频上传到快手 +- **获取步骤**: + 1. 浏览器登录 [cp.kuaishou.com](https://cp.kuaishou.com) + 2. F12 → Application → Cookies → 复制全部 +- **配置键**:`KUAISHOU_COOKIE` + +--- + +## 四、Soul App 凭证 + +### 4.1 Soul 账号 + +- **用途**:Soul 派对房间管理、账号资料设置 +- **配置键**:`SOUL_PHONE`、`SOUL_PASSWORD` +- **注册方式**:见 `02_魂流(水)/Soul账号注册/SKILL.md` + +--- + +## 五、小程序管理凭证 + +### 5.1 微信第三方平台 + +- **用途**:小程序代码上传、审核、发布 +- **配置键**:`WX_COMPONENT_APPID`、`WX_COMPONENT_APPSECRET`、`WX_AUTHORIZER_APPID`、`WX_AUTHORIZER_REFRESH_TOKEN` +- **获取**:微信开放平台 → 第三方平台 → 详情 + +--- + +## 六、Cookie 过期检测与批量刷新 + +### 快速检测命令 + +```bash +# 检测所有平台 Cookie 是否有效(需在项目AI/config/.env 已配置) +cd /Users/karuo/Documents/个人/卡若AI +python3 "03_卡木(木)/木叶_视频内容/多平台分发/脚本/check_cookies.py" +``` + +### 刷新优先级(按过期频率) + +| 优先级 | 平台 | 有效期 | 建议刷新频率 | +|:---|:---|:---|:---| +| 1 | 小红书 | ~7天 | 每周一 | +| 2 | 抖音 | ~30天 | 每月1号 | +| 3 | 快手 | ~30天 | 每月1号 | +| 4 | B站 | ~6个月 | 每季度 | +| 5 | 飞书 | 长期 | 仅 Secret 重置时 | +| 6 | 数据库 | 长期 | 仅密码修改时 |