const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/chunks/vendor-export.js","assets/chunks/_commonjsHelpers.js"])))=>i.map(i=>d[i]);
import{_ as $e}from"./chunks/preload-helper.js?v=1775123024591";import{o as Oe,G as Me,b as Be,p as Le,q as Ge,s as je}from"./chunks/AppDialogProvider.js?v=1775123024591";import{c as fe,R as G,r as de,j as I,e as Ue,f as Ve}from"./chunks/vendor-react.js?v=1775123024591";import{z as X,A as we,M as Ie,k as He,E as We,G as ue,B as pe,H as qe,I as ze}from"./chunks/vendor-antd.js?v=1775123024591";import"./chunks/vendor-common.js?v=1775123024591";import{h as Xe,a as Je}from"./chunks/index2.js?v=1775123024591";import{c as Ye}from"./chunks/index3.js?v=1775123024591";import"./chunks/_commonjsHelpers.js?v=1775123024591";import"./chunks/_commonjs-dynamic-modules.js?v=1775123024591";import"./chunks/use-feedback-bridge.js?v=1775123024591";const Qe={Settings:"设置",Cancel:"取消","Show changes":"显示更改",Overview:"概览",Properties:"属性","Open Projects":"打开项目","User Account & Settings":"用户账户和设置","Click any element to edit it's properties":"点击任意元素以编辑其属性",Colors:"颜色","Validate implemented colors":"验证已实现的颜色","Open the Figma to inspecta plugin and click 'Copy page colors'":"打开 Figma 到 inspecta 插件并点击「复制页面颜色」","Once styles are copied, click 'Paste & compare Figma colors'":"样式复制后,点击「粘贴并比较 Figma 颜色」","Paste & compare Figma colors":"粘贴并比较 Figma 颜色","Page colors":"页面颜色","Grid view":"网格视图","List view":"列表视图","Background colors":"背景颜色","Text colors":"文本颜色","Border colors":"边框颜色",Fonts:"字体","Validate implemented fonts":"验证已实现的字体","Open the Figma to inspecta plugin and click 'Copy page fonts'":"打开 Figma 到 inspecta 插件并点击「复制页面字体」","Once styles are copied, click 'Paste & compare Figma fonts'":"样式复制后,点击「粘贴并比较 Figma 字体」","Paste & compare Figma fonts":"粘贴并比较 Figma 字体","Text content":"文本内容","Copy to AI":"复制到 AI","Send to Cursor":"发送到 Cursor","Reset text content":"重置文本内容",IMG:"图片","Placeholder image":"占位图片",Upload:"上传",Download:"下载","Auto (Webpage Default)":"自动(网页默认)",Fill:"填充",Cover:"覆盖",Contain:"包含",None:"无","Scale Down":"缩小",SVG:"SVG","SVG code will appear here...":"SVG 代码将显示在这里...","Upload SVG file":"上传 SVG 文件","Paste inline SVG code":"粘贴内联 SVG 代码","Download SVG as HTML":"下载 SVG 为 HTML","Copy SVG code":"复制 SVG 代码","Reset SVG to original":"重置 SVG 为原始状态",Layout:"布局",Display:"显示","Flex-setings":"Flex 设置",Direction:"方向",Align:"对齐",Justify:"对齐方式",Wrap:"换行",Gap:"间距",Size:"尺寸",Min:"最小",Max:"最大",W:"宽",H:"高","Min-W":"最小宽","Min-H":"最小高","Max-W":"最大宽","Max-H":"最大高",Background:"背景","Background Color":"背景颜色",Typography:"排版","Font Family":"字体族","Font Weight":"字重","Thin : 100":"细体 : 100","Extra Light : 200":"超细 : 200","Light : 300":"轻 : 300","Regular : 400":"常规 : 400","Medium : 500":"中等 : 500","Semi Bold : 600":"半粗 : 600","Bold : 700":"粗体 : 700","Extra Bold : 800":"超粗 : 800","Black : 900":"黑体 : 900","Font Size":"字体大小","Font Color":"字体颜色","Line Height":"行高","Letter Spacing":"字间距","Text Align":"文本对齐","Text Decoration":"文本装饰",Spacing:"间距",MARGIN:"外边距",PADDING:"内边距",Margin:"外边距",Padding:"内边距",Border:"边框","Border Type":"边框类型","Border Color":"边框颜色","Border Width":"边框宽度",Mixed:"混合","Border-radius (Corners)":"边框圆角(角)",Position:"位置","Position type":"位置类型",Static:"静态",Absolute:"绝对",Fixed:"固定",Relative:"相对",Sticky:"粘性","Z-Index":"层级","Relative to:":"相对于:",Parent:"父元素",Body:"主体","Box shadow":"盒子阴影",Opacity:"透明度","No changes":"无更改","1 change":"1 个更改",changes:"个更改","Export to File":"导出到文件","Copy All Changes":"复制所有更改","Copy All Changes to AI":"复制所有更改到 AI","Delete All Changes":"删除所有更改",Share:"分享","Share Changes":"分享更改","AI agent bridge":"AI 代理桥接",Disconnected:"已断开连接",Connected:"已连接","Connecting...":"连接中...","AI agent:":"AI 代理:","Cursor IDE":"Cursor IDE","GitHub Copilot":"GitHub Copilot","Setup guide":"设置指南","No CSS changes":"无 CSS 更改","Send CSS changes to Cursor (Localhost)":"发送 CSS 更改到 Cursor(本地主机)","Download the Cursor extension":"下载 Cursor 扩展","Install the extension on Cursor IDE:":"在 Cursor IDE 上安装扩展:","Press Cmd + Shift + P (on Mac) or Ctrl + Shift + P (on Windows/Linux).":"按 Cmd + Shift + P(Mac)或 Ctrl + Shift + P(Windows/Linux)。",'Type "Install from VSIX..." and select the':"输入「从 VSIX 安装...」并选择","Once installed, click to open inspecta server on your IDE bottom toolbar":"安装后,点击 IDE 底部工具栏上的 inspecta 服务器以打开","Inspecta: Closed (click to Open)":"Inspecta: 已关闭(点击打开)",'On inspecta, make CSS changes and click "Send to Cursor" from the element toolbar or from css changes panel.':"在 inspecta 中,进行 CSS 更改,然后从元素工具栏或 CSS 更改面板点击「发送到 Cursor」。",properties:"属性",Overlay:"叠加层",Changes:"更改","Image overlay":"图片叠加层","No image":"无图片","Paste Image from clipboard":"从剪贴板粘贴图片","Upload Image":"上传图片","Upload image or paste from clipboard":"上传图片或从剪贴板粘贴",Navigator:"导航器","Collapse All":"全部折叠","Close Inspecta":"关闭 Inspecta","Clear inspecta changes":"清除 inspecta 更改","Show spacing overlays":"显示间距叠加层","Download inspecta Figma plugin":"下载 inspecta Figma 插件",Theme:"主题","Give us a feedback":"给我们反馈","Toggle Distances":"切换距离","Toggle Info Popover":"切换信息弹出框","Toggle Rulers":"切换标尺","Toggle Outlines":"切换轮廓","Sample Color":"采样颜色","Toggle Image Overlay":"切换图片叠加层","Toggle Navigator":"切换导航器","Toggle Changes Panel":"切换更改面板","Toggle Properties Panel":"切换属性面板","Switch to Light Theme":"切换到浅色主题","Switch to Dark Theme":"切换到深色主题","Reset Panel Position":"重置面板位置","Toggle Inspect Mode Off":"关闭检查模式","Toggle Inspect Mode On":"打开检查模式","Collapse Panel":"折叠面板","Expand Panel":"展开面板","Collapse All ":"全部折叠 ","Expand All":"全部展开","Isolate element":"隔离元素","Paste Figma Style":"粘贴 Figma 样式","Paste from clipboard":"从剪贴板粘贴",Copied:"已复制","Apply styles to":"应用样式到","Selected element":"选中的元素",Class:"类","Pasted Styles":"粘贴的样式",Preview:"预览","New or updated":"新建或已更新","Reset (to be removed in production)":"重置(将在生产环境中移除)","Similar (unchanged)":"相似(未更改)",Apply:"应用",Delete:"删除","Global color change":"全局颜色更改","Global font change":"全局字体更改","Original:":"原始:","New:":"新建:","No fonts found":"未找到字体","Center element":"居中元素","Reset Position":"重置位置","Auto fix colors":"自动修复颜色","Auto fix fonts":"自动修复字体","Send to IDE only works on localhost":"发送到 IDE 仅在本地主机上工作","Send to Cursor IDE":"发送到 Cursor IDE","Send to GitHub Copilot":"发送到 GitHub Copilot","Copy for AI":"复制到 AI","Icon & SVG colors":"图标和 SVG 颜色",Unknown:"未知",Normal:"正常",Color:"颜色","Solid Color":"纯色",Solid:"纯色",Gradient:"渐变","Background Image":"背景图片",Custom:"自定义",Figma:"Figma",Variables:"变量","No Figma colors available. Paste Figma colors from the overview panel first.":"没有可用的 Figma 颜色。请先从概览面板粘贴 Figma 颜色。","No CSS variables available.":"没有可用的 CSS 变量。",Hover:"悬停",Outline:"轮廓","Select font...":"选择字体...","inspecta-ide-integration-1.0.0.vsix":"inspecta-ide-integration-1.0.0.vsix",Feedback:"反馈","Changes sent to Cursor":"更改已发送至 Cursor","Implementing changes on your codebase":"正在您的代码库上实施更改","Successfully Implemented":"实施成功","Changes cleared from panel":"面板中的更改已清除",State:"状态",Default:"默认","Apply to":"应用到","Open the Figma to inspecta plugin and click 'Copy page colors' or 'Copy page fonts'":"打开 Figma to Inspecta 插件,并点击「复制页面颜色」或「复制页面字体」","Once styles are copied, click 'Paste & Compare'":"样式复制后,点击「粘贴并比较」","Fetching page styles...":"正在获取页面样式...","Authentication cancelled":"身份验证已取消","Failed to open settings":"打开设置失败","Settings menu not found":"未找到设置菜单","Signed in successfully":"登录成功","Authentication not available":"身份验证不可用","Sign-in failed":"登录失败","Signed out successfully":"登出成功","Sign-out failed":"登出失败","✅ Text reset to original!":"✅ 文本已重置为原始状态!","ℹ️ No text changes found to clear":"ℹ️ 未发现可清除的文本更改","❌ Failed to clear text changes":"❌ 清除文本更改失败","No text element selected":"未选中任何文本元素","No text changes to generate prompt for":"没有可生成提示词的文本更改","📋 Text prompt copied to clipboard":"📋 文本提示词已复制到剪贴板","❌ Failed to copy prompt":"❌ 复制提示词失败","Unable to determine hostname":"无法确定主机名","❌ Send to IDE only works on localhost":"❌ 发送到 IDE 仅在 localhost 上可用","❌ Send to IDE not available":"❌ 发送到 IDE 不可用","❌ Error sending to IDE":"❌ 发送到 IDE 时出错","Share link copied to clipboard!":"分享链接已复制到剪贴板!","Access denied. This share may be private or you may not have permission to view it.":"访问被拒绝。该分享可能为私有,或者您没有查看权限。","Please sign in to share changes":"请登录以分享更改","Preparing share...":"正在准备分享...","No changes to share":"没有可分享的更改","Share link copied":"分享链接已复制","Access denied. Please check your permissions.":"访问被拒绝。请检查您的权限。","Network error. Please check your connection.":"网络错误。请检查您的连接。","Failed to share changes":"分享更改失败","Authentication expired. Please sign in again.":"身份验证已过期。请重新登录。","Login required to share changes":"需要登录才能分享更改","Authentication failed. Please try again.":"身份验证失败。请重试。","Shared changes applied successfully!":"已成功应用分享的更改!","Failed to apply shared changes":"应用分享的更改失败","All Inspecta changes cleared successfully":"所有 Inspecta 更改已成功清除","Failed to clear changes":"清除更改失败","Spacing overlays visible":"间距叠加层已显示","Spacing overlays hidden":"间距叠加层已隐藏","Breadcrumb visible":"面包屑已显示","Breadcrumb hidden":"面包屑已隐藏","Opening Figma plugin page...":"正在打开 Figma 插件页面...","Onboarding not available":"新手引导不可用","Invalid SVG file!":"无效的 SVG 文件!","SVG applied!":"SVG 已应用!","No inline SVG element selected in DOM to replace.":"DOM 中未选中可替换的内联 SVG 元素。","Please upload a valid SVG file!":"请上传有效的 SVG 文件!","No valid SVG code to download.":"没有可下载的有效 SVG 代码。","SVG downloaded!":"SVG 已下载!","SVG code copied to clipboard!":"SVG 代码已复制到剪贴板!","No SVG element selected to reset.":"未选中可重置的 SVG 元素。","No original SVG found to restore.":"未找到可恢复的原始 SVG。","Failed to parse original SVG.":"解析原始 SVG 失败。","Invalid original SVG.":"无效的原始 SVG。","SVG reset to original!":"SVG 已重置为原始状态!","Failed to reset SVG.":"重置 SVG 失败。","No element selected":"未选中任何元素","No changes found":"未发现任何更改","No changes found for selected element":"未发现所选元素的更改","Changes were already deleted":"更改已被删除","Deletion function not available":"删除功能不可用","✓ Deleted all changes for selected element":"✓ 已删除所选元素的所有更改","Error deleting changes":"删除更改时出错","No element selected.":"未选中任何元素。","Paste CSS feature not loaded. Please refresh the page.":"粘贴 CSS 功能未加载。请刷新页面。","CSS from Figma applied!":"来自 Figma 的 CSS 已应用!",'Nothing to paste. Copy element style from the inspecta Figma plugin first.':'没有可粘贴的内容。请先从 inspecta Figma 插件 复制元素样式。',"Failed to apply CSS from clipboard: ":"从剪贴板应用 CSS 失败: ","Clipboard CSS applied!":"剪贴板 CSS 已应用!","No changes applied.":"未应用任何更改。","Failed to apply clipboard CSS.":"应用剪贴板 CSS 失败。","SVG uploaded and displayed!":"SVG 已上传并显示!","No SVG element found to replace!":"未找到可替换的 SVG 元素!","No Figma colors available. Please paste Figma colors first.":"没有可用的 Figma 颜色。请先粘贴 Figma 颜色。","No colors with close suggestions found. All mismatched colors don't have close matches in Figma colors.":"未找到相近的颜色建议。所有不匹配的颜色在 Figma 中都没有相近匹配。","No Figma fonts available. Please paste Figma fonts first.":"没有可用的 Figma 字体。请先粘贴 Figma 字体。","No fonts with close suggestions found. All mismatched fonts don't have close matches in Figma fonts.":"未找到相近的字体建议。所有不匹配的字体在 Figma 中都没有相近匹配。","Preview mode":"预览模式","No image or SVG found in clipboard!":"剪贴板中未找到图片或 SVG!","Failed to read image or SVG from clipboard.":"从剪贴板读取图片或 SVG 失败。","Failed to read clipboard. Please check extension permissions.":"读取剪贴板失败。请检查扩展权限。","Failed to read clipboard: ":"读取剪贴板失败: ","Clipboard is empty. Copy styles from Inspecta Figma plugin first.":"剪贴板为空。请先从 Inspecta Figma 插件复制样式。",'Nothing to paste. Copy styles from the inspecta Figma plugin first.':'没有可粘贴的内容。请先从 inspecta Figma 插件 复制样式。','Clipboard does not contain colors or fonts. Copy styles from the inspecta Figma plugin first.':'剪贴板不包含颜色或字体。请先从 inspecta Figma 插件 复制样式。','Nothing to paste. Copy colors style from the inspecta Figma plugin first.':'没有可粘贴的内容。请先从 inspecta Figma 插件 复制颜色样式。',"Comparing colors...":"正在比较颜色...","All colors are matching!":"所有颜色都匹配!","Auto Fix":"自动修复","Unlock Image":"解锁图片","Lock Image":"锁定图片","Figma suggested colors":"Figma 建议颜色","Figma suggested fonts":"Figma 建议字体","Search...":"搜索...","Reset style":"重置样式","Apply (":"应用 (",elements:"个元素"},be=t=>{if(typeof window>"u")return Promise.resolve(!0);const e=t.getContainer??document.body,o=document.createElement("div");e.appendChild(o);const n=fe(o);return new Promise(a=>{const r=h=>{a(h),setTimeout(()=>{n.unmount(),o.remove()},0)},l=()=>G.createElement(we,null,G.createElement(Ie,{open:!0,title:t.title??"操作确认",okText:t.okText??"确定",cancelText:t.cancelText??"取消",maskClosable:!1,centered:!0,onOk:()=>r(!0),onCancel:()=>r(!1),destroyOnHidden:!0,zIndex:2147483648},G.createElement("div",{style:{whiteSpace:"pre-line"}},t.content)));n.render(G.createElement(l))})};let ne=null;const xe=t=>{if(!t)return t;let e=t.replace(/body\s*>\s*#root\s*>\s*div\.css-[\w-]+\s*\.ant-app\s*>?/gi,"");return e=e.replace(/div\.css-[\w-]+\s*\.ant-app\s*>?/gi,""),e=e.replace(/>\s*/g,">").replace(/\s{2,}/g," ").trim(),e.startsWith(">")&&(e=e.slice(1).trim()),e},Ze=()=>{if(ne||typeof document>"u")return;const t=document.createElement("div");t.id="inspecta-start-overlay",t.style.cssText=`
position: fixed;
inset: 0;
z-index: 2147483646;
background: rgba(0,0,0,0.85);
color: #fff;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 40px 24px;
gap: 14px;
box-sizing: border-box;
font-family: -apple-system,BlinkMacSystemFont,"Segoe UI","Helvetica Neue",Arial,sans-serif;
text-align: center;
`;const e=document.createElement("div");e.style.cssText=`
max-width: 640px;
width: 100%;
padding: 0;
margin: 0 auto;
text-align: left;
`;const o=document.createElement("div");o.textContent="Inspecta 模式启动指引",o.style.cssText=`
font-size: 22px;
font-weight: 600;
letter-spacing: 0.2px;
margin-bottom: 24px;
`;const n=document.createElement("ul");n.style.cssText=`
list-style: none;
margin: 0;
display: grid;
gap: 10px;
font-size: 15px;
line-height: 1.6;
text-align: left;
max-width: 560px;
`,[()=>{const r=document.createElement("li");r.style.cssText="display: flex; gap: 6px; flex-wrap: wrap;",r.append("1. 安装 Inspecta 扩展 ");const l=document.createElement("a");return l.href="https://inspecta.design/",l.target="_blank",l.rel="noreferrer",l.textContent="https://inspecta.design/",l.style.cssText="color: #8ec7ff; text-decoration: underline; font-weight: 600;",r.appendChild(l),r},()=>{const r=document.createElement("li");return r.textContent="2. 点击 Inspecta 扩展按钮开启页面编辑",r},()=>{const r=document.createElement("li");return r.textContent="3. 修改样式后可以让 AI 修改或者保存到强制样式",r},()=>{const r=document.createElement("li");return r.textContent="4. 修改文本后可以让 AI 修改或者直接批量更新到文件",r}].forEach(r=>{n.appendChild(r())}),e.appendChild(o),e.appendChild(n),t.appendChild(e),document.body.appendChild(t),ne=t},se=()=>{ne&&(ne.remove(),ne=null)},Ke=t=>{if(typeof window>"u")return;console.log("[Dev Template] Inspecta 模式已启用"),console.log("[Inspecta-Translator] 启动翻译脚本..."),Ze();let e=!0,o=null,n=null,a=null,r=null,l=null;const h=new WeakSet,S=c=>{const g=c.trim();return Qe[g]||null},s=c=>{if(h.has(c))return!1;let g=!1;if(c.nodeType===Node.TEXT_NODE&&c.textContent){const u=S(c.textContent);u&&u!==c.textContent&&(c.textContent=u,g=!0)}if(c.nodeType===Node.ELEMENT_NODE){const u=c;Array.from(u.attributes).forEach(y=>{const d=S(y.value);d&&d!==y.value&&(u.setAttribute(y.name,d),g=!0)})}return g&&h.add(c),g},i=c=>{const g=document.createTreeWalker(c,NodeFilter.SHOW_TEXT|NodeFilter.SHOW_ELEMENT);let u;for(;u=g.nextNode();)s(u)},f=c=>{if(!e)return;n&&(n.disconnect(),n=null),console.log("[Inspecta-Translator] 开始初始翻译"),i(c),console.log("[Inspecta-Translator] 初始翻译完成");const g=new Set,u=new MutationObserver(y=>{e&&(y.forEach(d=>{d.type==="childList"?d.addedNodes.forEach(x=>{(x.nodeType===Node.ELEMENT_NODE||x.nodeType===Node.TEXT_NODE)&&g.add(x)}):d.type==="characterData"&&g.add(d.target)}),a!==null&&clearTimeout(a),a=window.setTimeout(()=>{e&&(g.size>0&&(g.forEach(d=>{d.nodeType===Node.ELEMENT_NODE?i(d):s(d)}),g.clear()),a=null)},50))});u.observe(c,{childList:!0,subtree:!0,characterData:!0,attributes:!1}),n=u,r=c,console.log("[Inspecta-Translator] 翻译观察器已启动")},p=c=>{console.log("[Axhub] 开始获取 CSS 内容");const g=c.querySelector("#btn_toggle_changes");return g?(g.click(),console.log("[Axhub] 已点击打开 CSS 变化面板"),setTimeout(()=>{const u=c.querySelector("#full_css_content");if(!u){console.error("[Axhub] 未找到 #full_css_content 元素");return}console.log("[Axhub] 找到 CSS 内容容器:",u);const y=u.querySelectorAll(".change_item");console.log(`[Axhub] 找到 ${y.length} 个 change_item`);const d=[];y.forEach((E,v)=>{const F=E.querySelector(".inspecta_tag_input");if(!F){console.warn(`[Axhub] change_item ${v} 未找到 .inspecta_tag_input`);return}const M=F.getAttribute("rule"),A=xe(M||"");if(!A){console.warn(`[Axhub] change_item ${v} 的 rule 属性为空`);return}console.log(`[Axhub] change_item ${v} - rule: ${A}`);const P=E.querySelectorAll(".css_change_property");console.log(`[Axhub] change_item ${v} - 找到 ${P.length} 个属性`);const N=[];if(P.forEach((O,j)=>{const W=O.querySelector("input[type='checkbox']");if(!W){console.warn(`[Axhub] change_item ${v} - 属性 ${j} 未找到 checkbox`);return}const C=W.getAttribute("key"),k=W.getAttribute("cssvalue");C&&k?(N.push(` ${C}: ${k};`),console.log(`[Axhub] change_item ${v} - 属性 ${j}: ${C}: ${k}`)):console.warn(`[Axhub] change_item ${v} - 属性 ${j} 缺少 key 或 cssvalue`)}),N.length>0){const O=`${A} {
${N.join(`
`)}
}`;d.push(O),console.log(`[Axhub] change_item ${v} - 生成 CSS 规则:
${O}`)}});const x=d.join(`
`);return console.log(`[Axhub] 最终生成的 CSS (${d.length} 条规则):
${x}`),x},300),""):(console.error("[Axhub] 未找到 #btn_toggle_changes 按钮"),"")},w=async c=>{console.log("[Axhub] 开始保存 hack.css"),p(c),setTimeout(async()=>{const g=c.querySelector("#full_css_content");if(!g){console.warn("[Axhub] 未找到 CSS 内容");return}const u=g.querySelectorAll(".change_item"),y=[];u.forEach(A=>{const P=A.querySelector(".inspecta_tag_input"),N=xe((P==null?void 0:P.getAttribute("rule"))||"");if(!N)return;const O=A.querySelectorAll(".css_change_property"),j=[];O.forEach(W=>{const C=W.querySelector("input[type='checkbox']"),k=C==null?void 0:C.getAttribute("key"),B=C==null?void 0:C.getAttribute("cssvalue");k&&B&&j.push(` ${k}: ${B};`)}),j.length>0&&y.push(`${N} {
${j.join(`
`)}
}`)});const d=y.join(`
`);if(!d){console.warn("[Axhub] 没有可保存的 CSS 内容"),X.warning("当前没有可保存的 CSS 更改");return}console.log(`[Axhub] 准备保存的 CSS 内容:
`,d);const x=window.location.pathname.match(/\/(components|prototypes)\/([^\/]+)/);if(!x){console.error("[Axhub] 无法识别当前页面路径");return}const[,E,v]=x,F=`${E}/${v}`;if(console.log("[Axhub] 目标路径:",F),!await be({title:"更新强制样式",content:`确定要更新强制样式吗?
此操作会将当前的 CSS 修改保存到 hack.css 文件,
页面将自动热更新刷新以应用更改。`,okText:"更新",cancelText:"取消"})){console.log("[Axhub] 用户取消了保存操作");return}try{const A=await fetch("/api/hack-css/save",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:F,content:d})}),P=await A.json();A.ok?console.log("[Axhub] ✅ 保存成功:",P):console.error("[Axhub] ❌ 保存失败:",P)}catch(A){console.error("[Axhub] ❌ 请求失败:",A)}},500)},T=async c=>{console.log("[Axhub] ========== 开始清空 hack.css =========="),console.log("[Axhub] 当前 URL:",window.location.href),console.log("[Axhub] 当前 pathname:",window.location.pathname);const g=window.location.pathname.match(/\/(components|prototypes)\/([^\/]+)/);if(console.log("[Axhub] 路径匹配结果:",g),!g){console.error("[Axhub] ❌ 无法识别当前页面路径:",window.location.pathname);return}const[,u,y]=g,d=`${u}/${y}`;if(console.log("[Axhub] 解析结果 - type:",u,"name:",y),console.log("[Axhub] 目标路径:",d),!await be({title:"清空强制样式",content:`确定要清空强制样式吗?
此操作会删除 hack.css 文件并清空所有 Inspecta 修改,
页面将自动热更新刷新以应用更改。`,okText:"清空",cancelText:"取消"})){console.log("[Axhub] 用户取消了清空操作");return}const E={path:d};console.log("[Axhub] 请求体:",JSON.stringify(E)),console.log("[Axhub] 准备发送 POST 请求到: /api/hack-css/clear");try{const v=await fetch("/api/hack-css/clear",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(E)});console.log("[Axhub] ✅ 收到响应"),console.log("[Axhub] 响应状态:",v.status,v.statusText),console.log("[Axhub] 响应头:",Object.fromEntries(v.headers.entries()));const F=await v.json();if(console.log("[Axhub] 响应内容:",F),v.ok){console.log("[Axhub] ✅ 清空成功:",F);const M=c.querySelector("#btn_clear_inspecta_changes");M?(console.log("[Axhub] 找到清空 inspecta 按钮,准备点击"),M.click(),console.log("[Axhub] 已点击清空 inspecta 按钮")):console.warn("[Axhub] 未找到 #btn_clear_inspecta_changes 按钮"),console.log("[Axhub] 等待页面自动热更新...")}else console.error("[Axhub] ❌ 清空失败:",F)}catch(v){console.error("[Axhub] ❌ 请求异常:",v),console.error("[Axhub] 错误堆栈:",v instanceof Error?v.stack:"无堆栈信息")}console.log("[Axhub] ========== 清空流程结束 ==========")},_=async c=>{console.log("[Axhub] 开始保存文本文件");const g=document.querySelectorAll('.text-node-selected[contenteditable="true"][data-original-text]'),u=[];if(g.forEach(C=>{var te;const k=C.getAttribute("data-original-text"),B=((te=C.textContent)==null?void 0:te.trim())||"";k&&B&&k!==B&&u.push({original:k,current:B,element:C})}),u.length===0){X.info("没有发现文本更改");return}const y=window.location.pathname.match(/\/(components|prototypes)\/([^\/]+)/);if(!y){console.error("[Axhub] 无法识别当前页面路径"),X.error("无法识别当前页面路径");return}const[,d,x]=y,E=`${d}/${x}`,v=u.map(async({original:C})=>{try{const B=await(await fetch("/api/text-replace/count",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:E,searchText:C})})).json();return{original:C,count:B.count||0}}catch(k){return console.error(`[Axhub] 统计文本 "${C}" 失败:`,k),{original:C,count:0}}}),M=(await Promise.all(v)).reduce((C,{count:k})=>C+k,0),A=document.createElement("div");A.id="text_replace_overlay",A.style.cssText=`
position: fixed;
inset: 0;
background: rgba(0, 0, 0, 0.5);
z-index: 2147483646;
display: flex;
align-items: center;
justify-content: center;
`;const P=document.createElement("div");P.className="popup",P.style.cssText=`
width: 280px;
z-index: 2147483647;
`,P.innerHTML=`
`,A.appendChild(P),c.appendChild(A);const N=()=>{A.remove()},O=P.querySelector("#text_replace_close");O==null||O.addEventListener("click",C=>{C.stopPropagation(),N(),console.log("[Axhub] 用户取消了文本替换操作")});const j=P.querySelector("#text_replace_cancel");j==null||j.addEventListener("click",C=>{C.stopPropagation(),N(),console.log("[Axhub] 用户取消了文本替换操作")});const W=P.querySelector("#text_replace_confirm");W==null||W.addEventListener("click",async C=>{C.stopPropagation(),N();try{const k=u.map(async({original:V,current:q})=>await(await fetch("/api/text-replace/replace",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:E,searchText:V,replaceText:q})})).json()),B=await Promise.all(k),te=B.filter(V=>V.success).length,Fe=B.reduce((V,q)=>V+(q.changedFiles||0),0);te===B.length?(u.forEach(({current:V,element:q})=>{q.setAttribute("data-original-text",V),q.textContent!==V&&(q.textContent=V),console.log(`[Axhub] 已更新页面节点: "${q.getAttribute("data-original-text")}" -> "${V}"`)}),X.success(`替换成功!共修改了 ${Fe} 个文件`),console.log("[Axhub] ✅ 文本替换成功,页面节点已更新")):(X.warning(`部分替换失败,成功 ${te}/${B.length}`),console.warn("[Axhub] ⚠️ 部分文本替换失败"))}catch(k){console.error("[Axhub] ❌ 文本替换失败:",k),X.error("文本替换失败")}}),A.addEventListener("click",C=>{C.target===A&&(N(),console.log("[Axhub] 用户取消了文本替换操作"))})},D=c=>{console.log("[Axhub] 开始注入保存文本按钮");const g=()=>{var d;if(!e)return;const u=c.querySelector("#text_edit_copy_prompt");if(!u){console.log("[Axhub] text_edit_copy_prompt 按钮未找到,继续等待..."),setTimeout(g,100);return}if(console.log("[Axhub] 找到 text_edit_copy_prompt 按钮:",u),c.querySelector("#save_text_files_btn")){console.log("[Axhub] 保存文本按钮已存在,跳过注入");return}const y=document.createElement("div");y.id="save_text_files_btn",y.className="action_icon",y.innerHTML=`
`,(d=u.parentNode)==null||d.insertBefore(y,u),y.addEventListener("click",async x=>{x.stopPropagation(),console.log("[Axhub] 保存文本文件按钮被点击");const E=document.querySelector("#inspecta_app_container");E!=null&&E.shadowRoot?await _(E.shadowRoot):(console.error("[Axhub] 无法找到 shadowRoot"),X.error("无法显示对话框"))}),console.log("[Axhub] 保存文本按钮注入成功")};g()},m=c=>{console.log("[Inspecta-Custom] 开始注入自定义按钮");const g=()=>{var P;if(!e)return;const u=c.querySelector("#changes_action_export_to_file");if(!u){console.log("[Inspecta-Custom] changes_action_export_to_file 按钮未找到,继续等待..."),setTimeout(g,100);return}if(console.log("[Inspecta-Custom] 找到 changes_action_export_to_file 按钮:",u),c.querySelector("#btn_axhub_action")){console.log("[Inspecta-Custom] 自定义按钮已存在,跳过注入");return}const y=document.createElement("div");y.className="action_icon",y.id="btn_axhub_action",y.style.cssText="position: relative;",y.innerHTML=`
Axhub 功能
`;const d=document.createElement("div");d.id="axhub_menu",d.className="popup",d.innerHTML=`
`;const x=document.createElement("style");x.id="axhub_menu_style",x.textContent=`
#axhub_menu_overlay {
position: fixed;
inset: 0;
background: rgba(0, 0, 0, 0.5);
z-index: 2147483646;
display: none;
}
#axhub_menu_overlay.show {
display: block;
}
#axhub_menu {
position: fixed;
z-index: 2147483647;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
opacity: 0;
transition: opacity 0.2s ease-in-out;
pointer-events: none;
width: 280px;
display: none;
}
#axhub_menu.show {
opacity: 1;
pointer-events: auto;
display: block;
}
`,c.appendChild(x),(P=u.parentNode)==null||P.insertBefore(y,u);const E=document.createElement("div");E.id="axhub_menu_overlay",c.appendChild(E),c.appendChild(d),console.log("[Inspecta-Custom] Axhub 菜单已添加到 shadowRoot"),y.addEventListener("click",N=>{N.stopPropagation(),d.classList.contains("show")?(d.classList.remove("show"),E.classList.remove("show"),console.log("[Inspecta-Custom] Axhub 菜单关闭")):(d.classList.add("show"),E.classList.add("show"),console.log("[Inspecta-Custom] Axhub 菜单打开"))});const v=d.querySelector("#btn_axhub_close");v==null||v.addEventListener("click",N=>{N.stopPropagation(),d.classList.remove("show"),E.classList.remove("show"),console.log("[Inspecta-Custom] Axhub 菜单关闭(通过关闭按钮)")});const F=d.querySelector("#btn_axhub_save");F==null||F.addEventListener("click",async N=>{N.stopPropagation(),console.log("[Axhub] 保存按钮被点击"),d.classList.remove("show"),E.classList.remove("show"),await w(c)});const M=d.querySelector("#btn_axhub_clear");M==null||M.addEventListener("click",async N=>{N.stopPropagation(),console.log("[Axhub] 清空按钮被点击"),d.classList.remove("show"),E.classList.remove("show"),await T(c)}),E.addEventListener("click",N=>{N.target===E&&(d.classList.remove("show"),E.classList.remove("show"))});const A=N=>{const O=N.target;!y.contains(O)&&!d.contains(O)&&!E.contains(O)&&(d.classList.remove("show"),E.classList.remove("show"))};c.addEventListener("click",A),l=A,console.log("[Inspecta-Custom] 自定义按钮注入成功")};g()},R=()=>{if(!e)return;const c=document.querySelector("#inspecta_app_container");if(!c){console.log("[Inspecta-Translator] 容器不存在,等待注入...");return}if(console.log("[Inspecta-Translator] 找到容器:",c),!c.shadowRoot){console.log("[Inspecta-Translator] shadowRoot 不存在,等待创建...");return}console.log("[Inspecta-Translator] 找到 shadowRoot,开始翻译"),f(c.shadowRoot),m(c.shadowRoot),D(c.shadowRoot),se()};return(()=>{e&&(console.log("[Inspecta-Translator] 开始监听 Inspecta 容器注入"),R(),o=new MutationObserver(c=>{if(e)for(const g of c)g.type==="childList"&&g.addedNodes.forEach(u=>{if(u instanceof Element){if(u.id==="inspecta_app_container"){console.log("[Inspecta-Translator] 检测到 Inspecta 容器注入");const d=()=>{if(!e)return;const x=u;x.shadowRoot?(console.log("[Inspecta-Translator] shadowRoot 已创建"),o==null||o.disconnect(),f(x.shadowRoot),m(x.shadowRoot),D(x.shadowRoot),se()):(console.log("[Inspecta-Translator] shadowRoot 尚未创建,继续等待..."),setTimeout(d,100))};d()}const y=u.querySelector("#inspecta_app_container");if(y){console.log("[Inspecta-Translator] 在子节点中检测到 Inspecta 容器");const d=()=>{if(!e)return;const x=y;x.shadowRoot?(console.log("[Inspecta-Translator] shadowRoot 已创建"),o==null||o.disconnect(),f(x.shadowRoot),m(x.shadowRoot),D(x.shadowRoot),se()):(console.log("[Inspecta-Translator] shadowRoot 尚未创建,继续等待..."),setTimeout(d,100))};d()}}})}),o.observe(document.body,{childList:!0,subtree:!0}),console.log("[Inspecta-Translator] 监听器已启动"))})(),()=>{e=!1,o&&(o.disconnect(),o=null),n&&(n.disconnect(),n=null),a!==null&&(clearTimeout(a),a=null),r&&(l&&(r.removeEventListener("click",l),l=null),r.querySelectorAll("#axhub_menu_overlay, #axhub_menu, #btn_axhub_action, #save_text_files_btn, #axhub_menu_style, #text_replace_overlay").forEach(c=>c.remove())),se()}},et=()=>{let t=!1,e;return{enable:()=>{t||(t=!0,e=Ke())},disable:()=>{t&&(e==null||e(),e=void 0,t=!1)},isEnabled:()=>t,getStatus:()=>({enabled:t})}};let Se=!1,z=!1;const ee=new Set,ae=new Set,me="axhub-text-edit-style";let Z=null,Y=null;const Q=t=>{typeof window>"u"||window.parent&&window.parent!==window&&window.parent.postMessage(t,"*")},Pe=()=>document.getElementById("root"),le=t=>{var e;return((e=t.textContent)==null?void 0:e.trim())??""},tt=()=>{if(document.getElementById(me))return;const t=document.createElement("style");t.id=me,t.textContent=`
.text-node-edited {
background-color: rgba(250, 173, 20, 0.12);
}
`,document.head.appendChild(t)},ot=()=>{var t;(t=document.getElementById(me))==null||t.remove()},U=()=>{Q({type:"TEXT_EDIT_STATUS",enabled:z,editedCount:ee.size})},nt=()=>({enabled:z,editedCount:ee.size}),L=(t,e)=>{Q({type:"TEXT_EDIT_NOTICE",level:t,message:e})},Ne=t=>{const e=t.target;if(!e||!e.hasAttribute("data-axhub-text-edit"))return;const o=e.getAttribute("data-original-text")??"",n=le(e);o!==n?(ee.add(e),e.classList.add("text-node-edited")):(ee.delete(e),e.classList.remove("text-node-edited")),U()},ke=t=>{const e=t.tagName.toLowerCase();return!(["script","style","input","textarea","select","option"].includes(e)||t.getAttribute("contenteditable")==="false"||!le(t)||t.childElementCount>0&&!Array.from(t.childNodes).some(a=>{var r;return a.nodeType===Node.TEXT_NODE&&((r=a.textContent)==null?void 0:r.trim())}))},at=()=>{const t=Pe();if(!t)return[];const e=["p","span","div","h1","h2","h3","h4","h5","h6","li","td","th","label","a","button","strong","b","em","i"].join(",");return Array.from(t.querySelectorAll(e)).filter(ke)},De=t=>{t.length!==0&&(t.forEach(e=>{e.hasAttribute("data-original-text")||e.setAttribute("data-original-text",le(e));const o=e.getAttribute("contenteditable");o!==null&&e.setAttribute("data-axhub-original-contenteditable",o),e.setAttribute("data-axhub-text-edit","true"),e.setAttribute("contenteditable","true"),e.addEventListener("input",Ne)}),t.forEach(e=>ae.add(e)))},st=()=>{if(Z)return;const t=Pe();t&&(Z=new MutationObserver(e=>{if(!z)return;const o=[];if(e.forEach(r=>{r.addedNodes.forEach(l=>{var s;if(l.nodeType!==Node.ELEMENT_NODE)return;const h=l;h.matches&&h.matches("p,span,div,h1,h2,h3,h4,h5,h6,li,td,th,label,a,button,strong,b,em,i")&&o.push(h);const S=Array.from(((s=h.querySelectorAll)==null?void 0:s.call(h,"p,span,div,h1,h2,h3,h4,h5,h6,li,td,th,label,a,button,strong,b,em,i"))||[]);o.push(...S)})}),o.length===0)return;const a=o.filter(r=>!ae.has(r)).filter(ke);De(a),U()}),Z.observe(t,{childList:!0,subtree:!0}))},rt=()=>{Z&&(Z.disconnect(),Z=null)},Re=()=>{if(z){U();return}const t=at();if(t.length===0){L("info","没有发现可编辑文本"),U();return}tt(),De(t),st(),z=!0,U(),L("success","文本编辑模式已开启,点击页面文本即可编辑")},ye=t=>{if(!z){U();return}ae.forEach(e=>{if(e.removeEventListener("input",Ne),e.classList.remove("text-node-edited"),t){const n=e.getAttribute("data-original-text");n!==null&&(e.textContent=n)}const o=e.getAttribute("data-axhub-original-contenteditable");o!==null?(e.setAttribute("contenteditable",o),e.removeAttribute("data-axhub-original-contenteditable")):e.getAttribute("data-axhub-text-edit")==="true"&&e.removeAttribute("contenteditable"),e.getAttribute("data-axhub-text-edit")==="true"&&e.removeAttribute("data-axhub-text-edit")}),ee.clear(),ae.clear(),ot(),rt(),z=!1,U(),L("info","已退出文本编辑模式")},it=()=>{const t=[];return ae.forEach(e=>{const o=e.getAttribute("data-original-text"),n=le(e);o&&n&&o!==n&&t.push({original:o,current:n,element:e})}),t},ct=t=>{const e=new Map;t.forEach(a=>{const r=e.get(a.original)||{currents:new Set,elements:[]};r.currents.add(a.current),r.elements.push(a.element),e.set(a.original,r)});const o=[],n=[];return e.forEach((a,r)=>{if(a.currents.size>1){o.push({original:r,currents:Array.from(a.currents)});return}const[l]=Array.from(a.currents);n.push({original:r,current:l,elements:a.elements})}),{conflicts:o,groups:n}},lt=async t=>{if(Y){L("warning","已有保存确认在处理中");return}const e=it();if(e.length===0){L("info","没有发现文本更改"),U();return}const{conflicts:o,groups:n}=ct(e);if(o.length>0){Q({type:"TEXT_EDIT_CONFLICT",conflicts:o}),L("warning","存在相同原文但不同修改的内容,无法批量保存");return}const a=window.location.pathname.match(/\/(components|prototypes)\/([^\/]+)/);if(!a){L("error","无法识别当前页面路径");return}const[,r,l]=a,h=`${r}/${l}`;let S=0;try{const s=await fetch("/api/text-replace/count",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:h,replacements:n.map(({original:f})=>({searchText:f}))})}),i=await s.json();S=Number((i==null?void 0:i.totalCount)||0),s.ok||(console.error("[Axhub] 统计文本失败:",(i==null?void 0:i.error)||i),S=0)}catch(s){console.error("[Axhub] 统计文本失败:",s),S=0}Y={groups:n,totalCount:S,changedCount:e.length,exitAfterSave:t},Q({type:"TEXT_EDIT_SAVE_CONFIRM_REQUEST",totalCount:S,changedCount:e.length,exitAfterSave:t})},dt=async t=>{const e=t.data;if(!(!e||typeof e.type!="string"))switch(e.type){case"TEXT_EDIT_ENABLE":Re();break;case"TEXT_EDIT_SAVE":await lt(!!e.exitAfterSave);break;case"TEXT_EDIT_SAVE_CONFIRM":if(!Y){L("info","没有待确认的保存操作");break}if(!e.confirmed){Y=null,L("info","已取消保存");break}{const{exitAfterSave:o,totalCount:n}=Y,a=Y.groups;Y=null;const r=window.location.pathname.match(/\/(components|prototypes)\/([^\/]+)/);if(!r){L("error","无法识别当前页面路径");break}const[,l,h]=r,S=`${l}/${h}`;try{const s=await fetch("/api/text-replace/replace",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:S,replacements:a.map(({original:w,current:T})=>({searchText:w,replaceText:T}))})}),i=await s.json(),f=!!(i!=null&&i.success),p=Number((i==null?void 0:i.changedFiles)||0);if(s.ok&&f){if(a.forEach(({current:w,elements:T})=>{T.forEach(_=>{_.setAttribute("data-original-text",w),_.textContent!==w&&(_.textContent=w),_.classList.remove("text-node-edited"),ee.delete(_)})}),L("success",`替换成功!共替换 ${n} 处,修改了 ${p} 个文件`),Q({type:"TEXT_EDIT_SAVE_RESULT",success:!0,totalFiles:p,totalCount:n}),o){ye(!1);break}}else L("warning","文本替换失败"),Q({type:"TEXT_EDIT_SAVE_RESULT",success:!1,totalFiles:p,totalCount:n})}catch(s){console.error("[Axhub] 文本替换失败:",s),L("error","文本替换失败"),Q({type:"TEXT_EDIT_SAVE_RESULT",success:!1,totalFiles:0,totalCount:n})}U()}break;case"TEXT_EDIT_EXIT":ye(!!e.discardChanges);break;case"TEXT_EDIT_STATUS_REQUEST":U();break}},ut=()=>{typeof window>"u"||Se||(Se=!0,window.addEventListener("message",dt),U())},pt=()=>(ut(),{enable:()=>Re(),disable:(t=!1)=>ye(t),isEnabled:()=>z,getStatus:()=>nt()});function gt(t){return t.defaultPrompt}const ht=new Set(["claude","codex","gemini","opencode"]),Ee="32123";function b(t){return typeof t=="string"?t.trim():""}function ft(t){const e=b(t).toLowerCase();if(e){if(["1","true","yes","on"].includes(e))return!0;if(["0","false","no","off"].includes(e))return!1}}function mt(t){const e=new URLSearchParams(t),o=b(e.get("genieDebugTitle")).toLowerCase();return["1","true","yes","on"].includes(o)}function yt(t){var a,r,l;if(!t)return"[GenieDebug] unavailable";const e=t.currentConversation,o=t.currentElementTask,n=t.visibleTasks.map(h=>`${h.elementKey}:${h.status}:${h.sessionId??"-"}`).join(",");return["[GenieDebug]",`connected=${t.connected?1:0}`,`available=${t.available?1:0}`,`reusable=${t.hasReusableConversation?1:0}`,`channel=${((a=t.bridgeConfig)==null?void 0:a.integrationChannel)??"-"}`,`target=${((r=t.bridgeConfig)==null?void 0:r.targetClientId)??"-"}`,`agent=${((l=t.bridgeConfig)==null?void 0:l.provider)??"-"}`,`selected=${t.selectedElementKey??"-"}`,`session=${(e==null?void 0:e.sessionId)??"-"}`,`provider=${(e==null?void 0:e.provider)??"-"}`,`current=${o?`${o.elementKey}:${o.status}:${o.sessionId??"-"}`:"-"}`,`tasks=${n||"-"}`].join(" ")}function wt(t){try{const n=b(t==null?void 0:t.href);if(n){const a=new URL(n);return`${a.protocol}//${a.hostname}:${Ee}/api`}}catch{}const e=b(t==null?void 0:t.protocol)||"http:",o=b(t==null?void 0:t.hostname)||"localhost";return`${e}//${o}:${Ee}/api`}function ge(t){return b(t==null?void 0:t.path)}function bt(t){const e=b(t).toLowerCase();if(ht.has(e))return e}let Te=0;async function xt(){try{const t=await fetch("/api/assistant/runtime?autoStart=false");if(!t.ok)return{};const e=await t.json().catch(()=>({})),o=e&&typeof e=="object"?e:{},n=b(o.apiBaseUrl),a=b(o.projectPath);return{...n?{apiBaseUrl:n}:{},...a?{projectPath:a}:{}}}catch{return{}}}async function re(t,e){const o=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),n=await o.json().catch(()=>({}));return{ok:o.ok,status:o.status,data:n}}function ie(t,e){if(t&&typeof t=="object"){const o=t.error;if(typeof o=="string"&&o.trim())return o.trim()}return e}function St(){return Te+=1,`web-editor-dialog-${Te}`}function Et(){return typeof window>"u"?!1:!!(window.parent&&window.parent!==window)}async function Tt(t){if(!Et())return null;const e=St(),o={type:"WEB_EDITOR_DIALOG_REQUEST",requestId:e,...t};return new Promise(n=>{let a=!1;const r=()=>{typeof window>"u"||(window.removeEventListener("message",h),window.clearTimeout(S))},l=s=>{a||(a=!0,r(),n(s))},h=s=>{const i=s.data;!i||i.type!=="WEB_EDITOR_DIALOG_RESPONSE"||String(i.requestId||"")===e&&l(i.confirmed??!0)},S=window.setTimeout(()=>{l(null)},6e4);window.addEventListener("message",h),window.parent.postMessage(o,"*")})}function Ct(t){const e=new Map;t.forEach(a=>{const r=b(a.before),l=b(a.after);if(!r||!l||r===l)return;const h=e.get(r)??new Set;h.add(l),e.set(r,h)});const o=[],n=[];return e.forEach((a,r)=>{if(a.size>1){n.push({before:r,afterValues:Array.from(a)});return}const[l]=Array.from(a);o.push({before:r,after:l})}),{groups:o,conflicts:n}}async function he(t){const e=await Tt({kind:"confirm",title:"确认操作",description:t,confirmText:"确定",cancelText:"取消",tone:"brand",dismissible:!1});if(e!==null)return e;const o=Oe();return o?o.confirm({title:"确认操作",description:t,confirmText:"确定",cancelText:"取消",tone:"brand",dismissible:!1}):typeof window<"u"&&typeof window.confirm=="function"?window.confirm(t):!0}function H(t,e){const o=b(e);if(!o||typeof window>"u")return;if(window.parent&&window.parent!==window){const a={type:"WEB_EDITOR_NOTICE",level:t,message:o};window.parent.postMessage(a,"*");return}(t==="error"?console.error:t==="warning"?console.warn:console.info)(`[Axhub] ${o}`)}function Ce(t){const e=new URLSearchParams(t),o=b(e.get("genieApiBaseUrl")??e.get("apiBaseUrl")),n=b(e.get("genieIntegrationChannel")??e.get("integrationChannel")),a=b(e.get("genieTargetClientId")??e.get("integrationClientId")),r=b(e.get("cwd"))||b(e.get("workdir")),l=bt(e.get("provider")??e.get("tool")),h={};return o&&(h.apiBaseUrl=o),n&&(h.integrationChannel=n),a&&(h.targetClientId=a),r&&(h.projectPath=r),l&&(h.provider=l),h}function vt(t){const e=new URLSearchParams(t),o=ft(e.get("editorIntegrationWs")??e.get("editorWs")),n=b(e.get("editorApiBaseUrl")),a=b(e.get("editorIntegrationChannel")??e.get("editorChannel")),r=b(e.get("editorClientId")),l=b(e.get("editorSessionId")),h=b(e.get("editorPageUrl")),S={};return typeof o=="boolean"&&(S.enabled=o),n&&(S.apiBaseUrl=n),a&&(S.channel=a),r&&(S.clientId=r),l&&(S.sessionId=l),h&&(S.pageUrl=h),S}function _t(t,e){const n=b(t).match(/^\/(components|prototypes)\/([^/?#]+)/);if(!n)return null;const[,a,r]=n,l=`${a}/${r}`;return{kind:"prototype-entry",id:l,path:l,url:b(e)||void 0,meta:{group:a,name:r}}}const At=(t={})=>{let e=null,o=null,n=null,a="";const r=(i={})=>{var f,p,w,T,_;if(!e){const D=typeof window<"u"?Ce(window.location.search):{},m={breadcrumbs:!0,propertyPanel:!0,showCopyPromptAction:!0,...t.ui??{}},R=typeof window<"u"?vt(window.location.search):{},$=b(((f=t.integrationWs)==null?void 0:f.apiBaseUrl)??R.apiBaseUrl??(typeof window<"u"?wt(window.location):"")),c={...D,...t.genieBridge??{}},g={...c,apiBaseUrl:b(c.apiBaseUrl)||b(i.apiBaseUrl)||$,integrationChannel:b(c.integrationChannel)||Be,targetClientId:b(c.targetClientId)||Me,projectPath:b(c.projectPath)||b(i.projectPath)},u=!!(b(g.apiBaseUrl)&&b(g.integrationChannel)&&b(g.targetClientId)),y={...R,...t.integrationWs??{},apiBaseUrl:$},d=typeof y.enabled=="boolean"?y.enabled:!!($&&b(y.channel)&&b(y.clientId));e=Ye({...t,ui:m,host:{...t.host??{},getResourceContext:((p=t.host)==null?void 0:p.getResourceContext)??(()=>typeof window>"u"?null:_t(window.location.pathname,window.location.href)),buildCopyPrompt:((w=t.host)==null?void 0:w.buildCopyPrompt)??gt},genieBridge:{...t.genieBridge??{},...g,enabled:typeof((T=t.genieBridge)==null?void 0:T.enabled)=="boolean"?t.genieBridge.enabled:u,...(_=t.genieBridge)!=null&&_.onRequestWake?{onRequestWake:t.genieBridge.onRequestWake}:{}},integrationWs:{...t.integrationWs??{},...y,enabled:d}})}return e},l=async()=>e||(o||(o=(async()=>{var T,_;const i=typeof window<"u"?Ce(window.location.search):{},f=b(((T=t.genieBridge)==null?void 0:T.apiBaseUrl)??i.apiBaseUrl),p=b(((_=t.genieBridge)==null?void 0:_.projectPath)??i.projectPath),w=f&&p?{}:await xt();return r(w)})().finally(()=>{o=null})),o),h=()=>{typeof window<"u"&&n!==null&&(window.clearInterval(n),n=null),typeof document<"u"&&a&&(document.title=a)},S=()=>{if(typeof window>"u"||typeof document>"u"||!mt(window.location.search)||n!==null)return;a||(a=document.title);const i=()=>{var p;const f=((p=e==null?void 0:e.getDebugState)==null?void 0:p.call(e))??null;document.title=`${yt(f)} | ${a}`};i(),n=window.setInterval(i,250)},s=()=>{var p,w;const i=(p=e==null?void 0:e.getStatus)==null?void 0:p.call(e);if(i)return{undoCount:Number(i.undoCount??0),redoCount:Number(i.redoCount??0)};const f=(w=e==null?void 0:e.getHistoryCounts)==null?void 0:w.call(e);return{undoCount:(f==null?void 0:f.undoCount)??0,redoCount:(f==null?void 0:f.redoCount)??0}};return{enable:async()=>{typeof window>"u"||((await l()).start(),S())},disable:()=>{e==null||e.stop(),h()},isEnabled:()=>(e==null?void 0:e.getState().active)??!1,getStatus:()=>({active:(e==null?void 0:e.getState().active)??!1,...s()}),getDebugState:()=>{var i;return((i=e==null?void 0:e.getDebugState)==null?void 0:i.call(e))??null},saveTextChanges:async()=>{var g,u,y;const i=await l(),f=i.getEditedSnapshot(),p=ge(f.resource),w=i.getTextChanges();if(!p){H("error","当前页面路径无法识别,暂时不能保存文本。请刷新页面后再试。");return}if(!w.length){H("info","当前没有可保存的文本修改。");return}const{groups:T,conflicts:_}=Ct(w);if(_.length>0){const d=_.slice(0,3).map(E=>`“${E.before}”被改成了 ${E.afterValues.length} 个不同结果`).join(`
`),x=_.length>3?`
另有 ${_.length-3} 组冲突。`:"";H("warning",`检测到相同原文被修改成不同内容,暂时无法批量保存。
${d}${x}
请先统一这些文本修改后再保存。`);return}if(!T.length){H("info","当前没有可保存的文本修改。");return}let D=0;try{const d=await re("/api/text-replace/count",{path:p,replacements:T.map(({before:x})=>({searchText:x}))});if(!d.ok)throw new Error(ie(d.data,"统计文本修改数量失败"));D=Number(d.data.totalCount??0)}catch{D=0}const m=D>0?`检测到 ${T.length} 组文本修改,预计会替换 ${D} 处文本。
确定继续保存吗?`:`检测到 ${T.length} 组文本修改。
当前无法预估替换数量,确定继续保存吗?`;if(!await he(m))return;const R=await re("/api/text-replace/replace",{path:p,replacements:T.map(({before:d,after:x})=>({searchText:d,replaceText:x}))});if(!R.ok||((g=R.data)==null?void 0:g.success)!==!0)throw new Error(ie(R.data,"保存文本失败"));(u=i.acknowledgeSavedTextChanges)==null||u.call(i);const $=Number(((y=R.data)==null?void 0:y.changedFiles)??0),c=D>0?`文本已保存,共替换 ${D} 处,更新 ${$} 个文件。`:`文本已保存,更新 ${$} 个文件。`;H("success",c)},saveStyleChanges:async()=>{var _,D;const i=await l(),f=i.getEditedSnapshot(),p=ge(f.resource),w=i.getStyleChanges();if(!p){H("error","当前页面路径无法识别,暂时不能保存强制样式。请刷新页面后再试。");return}if(!w.cssText){H("info","当前没有可保存的强制样式调整。");return}if(!await he("确定保存当前的样式调整吗?保存后页面会自动刷新并生效。"))return;const T=await re("/api/hack-css/save",{path:p,content:w.cssText});if(!T.ok||((_=T.data)==null?void 0:_.success)!==!0)throw new Error(ie(T.data,"保存强制样式失败"));(D=i.acknowledgeSavedStyleChanges)==null||D.call(i),H("success","强制样式已保存。")},clearForcedStyles:async()=>{var T,_;const i=await l(),f=i.getEditedSnapshot(),p=ge(f.resource);if(!p){H("error","当前页面路径无法识别,暂时不能清空强制样式。请刷新页面后再试。");return}if(!await he("确定清空自定义样式吗?清空后页面会自动刷新并生效。"))return;const w=await re("/api/hack-css/clear",{path:p});if(!w.ok||((T=w.data)==null?void 0:T.success)!==!0)throw new Error(ie(w.data,"清空强制样式失败"));(_=i.acknowledgeSavedStyleChanges)==null||_.call(i),H("success","已清空自定义样式。")}}},It=t=>{if(!t)return"none";const e=new URLSearchParams(t),o=e.get("editor");return o==="inspecta"||o==="textEdit"||o==="webEditorV2"||o==="none"?o:e.get("inspecta")==="true"?"inspecta":"none"},Pt=t=>{const e=t??(typeof window<"u"?It(window.location.search):"none"),o=et(),n=pt(),a=At(),r={inspecta:o,textEdit:n,webEditorV2:a};let l="none",h=!1;const S=()=>{if(typeof window>"u")return;const p=window.DevTemplateBootstrap;p&&(p.inspectaMode=l==="inspecta")},s=async p=>{if(p===l)return;const w=l;l="none",w!=="none"&&await Promise.resolve(r[w].disable()),p!=="none"&&(await Promise.resolve(r[p].enable()),l=p),S()};return{api:{getMode:()=>l,enable:p=>s(p),disable:()=>s("none"),toggle:p=>s(l===p?"none":p),saveWebEditorTextChanges:()=>a.saveTextChanges(),saveWebEditorStyleChanges:()=>a.saveStyleChanges(),clearWebEditorForcedStyles:()=>a.clearForcedStyles(),getWebEditorDebugState:()=>a.getDebugState(),getStatus:()=>({mode:l,webEditor:a.getStatus(),textEdit:n.getStatus(),inspecta:o.getStatus()})},applyInitialMode:()=>{h||(h=!0,l==="none"&&e!=="none"&&s(e))},getMode:()=>l,getInitialMode:()=>e}},{Text:oe,Paragraph:ce}=He;let J=null;function Nt(){const{message:t}=we.useApp(),[e,o]=de.useState(!1),[n,a]=de.useState([]);de.useEffect(()=>{if(J={addError:s=>{const i={...s,timestamp:Date.now()};a(f=>[...f,i]),o(!0)}},window.showErrorDialog=(s,i)=>{J==null||J.addError({message:s,stack:i})},window.__ERROR_SYSTEM__){window.__ERROR_SYSTEM__.markReactReady();const s=window.__ERROR_SYSTEM__.getErrorQueue();s&&s.length>0&&(console.log(`[Error Dialog] 加载启动阶段的 ${s.length} 个错误`),s.forEach(i=>{J==null||J.addError({message:i.message,stack:i.stack})}))}},[]);const r=()=>{o(!1)},l=()=>{a([]),o(!1)},h=()=>{if(n.length===0)return;const s=n.map((i,f)=>{const p=new Date(i.timestamp).toLocaleTimeString();return`[${f+1}] ${p}
错误信息:${i.message}
堆栈信息:
${i.stack||"无堆栈信息"}`}).join(`
`+"=".repeat(80)+`
`);navigator.clipboard&&navigator.clipboard.writeText?navigator.clipboard.writeText(s).catch(()=>{S(s)}):S(s)},S=s=>{const i=document.createElement("textarea");i.value=s,i.style.position="fixed",i.style.opacity="0",document.body.appendChild(i),i.select();try{document.execCommand("copy")}catch{t.error("复制失败,请手动复制错误信息")}document.body.removeChild(i)};return I.jsx(Ie,{title:I.jsxs(ue,{children:[I.jsx(ze,{style:{color:"#ff4d4f"}}),I.jsxs("span",{children:["运行时错误 (",n.length,")"]})]}),open:e,onCancel:r,footer:I.jsxs(ue,{children:[I.jsx(pe,{onClick:l,children:"清空并关闭"}),I.jsx(pe,{onClick:r,children:"关闭"}),I.jsx(pe,{type:"primary",icon:I.jsx(qe,{}),onClick:h,children:"复制所有错误"})]}),width:700,style:{top:50},children:n.length>0&&I.jsx("div",{style:{maxHeight:"60vh",overflow:"auto"},children:I.jsx(We,{defaultActiveKey:[n.length-1],accordion:!0,items:n.map((s,i)=>({key:i,label:I.jsxs(ue,{children:[I.jsx(oe,{type:"secondary",children:new Date(s.timestamp).toLocaleTimeString()}),I.jsx(oe,{ellipsis:!0,style:{maxWidth:500},children:s.message})]}),children:I.jsxs("div",{children:[I.jsx(ce,{children:I.jsx(oe,{strong:!0,children:"错误信息:"})}),I.jsx(ce,{style:{marginBottom:16},children:I.jsx(oe,{children:s.message})}),s.stack&&I.jsxs(I.Fragment,{children:[I.jsx(ce,{children:I.jsx(oe,{strong:!0,children:"堆栈信息:"})}),I.jsx(ce,{children:I.jsx("pre",{style:{background:"#f5f5f5",border:"1px solid #e0e0e0",borderRadius:4,padding:12,fontSize:12,fontFamily:"Monaco, Menlo, Consolas, monospace",color:"#666",overflow:"auto",maxHeight:300,whiteSpace:"pre-wrap",wordBreak:"break-all",margin:0},children:s.stack})})]})]})}))})})})}function ve(t){let e=2166136261;for(let o=0;o{Rt(),K==null||K.applyInitialMode()},0)}catch(r){console.error("[Dev Template] 渲染失败:",r)}}const $t={...Ve,...Ue},Ot="/api/export/image-proxy";function Ae(t){var e;if(typeof window>"u"||!((e=window.location)!=null&&e.origin))return null;try{const o=new URL(t,document.baseURI).href;return new URL(o).origin===window.location.origin?null:`${window.location.origin}${Ot}?url=${encodeURIComponent(o)}`}catch{return null}}function Mt(t){const e=[];if(!t||t==="none")return e;const o=/url\((['"]?)(.*?)\1\)/g;let n=null;for(;(n=o.exec(t))!==null;){const a=String(n[2]||"").trim();a&&e.push(a)}return e}function Bt(t){const e=[];return[t,...Array.from(t.querySelectorAll("*"))].forEach(n=>{if(n instanceof HTMLImageElement){const f=n.getAttribute("src"),p=f?Ae(f):null;if(!f||!p)return;const w=n.getAttribute("srcset"),T=n.getAttribute("sizes");n.setAttribute("src",p),n.removeAttribute("srcset"),n.removeAttribute("sizes"),e.push(()=>{n.setAttribute("src",f),w!==null?n.setAttribute("srcset",w):n.removeAttribute("srcset"),T!==null?n.setAttribute("sizes",T):n.removeAttribute("sizes")});return}if(!(n instanceof HTMLElement))return;const a=n.style.backgroundImage,r=window.getComputedStyle(n).backgroundImage,l=a||r,h=Mt(l);if(h.length===0)return;let S=l,s=!1;if(h.forEach(f=>{const p=Ae(f);if(!p)return;const w=`url("${p}")`;S=S.replace(`url(${f})`,w).replace(`url('${f}')`,w).replace(`url("${f}")`,w),s=!0}),!s||S===l)return;const i=n.style.backgroundImage;n.style.setProperty("background-image",S,"important"),e.push(()=>{i?n.style.backgroundImage=i:n.style.removeProperty("background-image")})}),()=>{for(let n=e.length-1;n>=0;n-=1)e[n]()}}if(typeof window<"u"){const t=new URLSearchParams(window.location.search),e=t.get("scale"),o=t.get("width"),n=t.get("height"),a=document.getElementById("root");let r=null;const l=(s,i)=>{a&&(r||(r={width:a.style.width,height:a.style.height}),s&&Number.isFinite(s)?a.style.width=`${Math.round(s)}px`:r&&(a.style.width=r.width),i&&Number.isFinite(i)?a.style.height=`${Math.round(i)}px`:r&&(a.style.height=r.height))},h=()=>{!a||!r||(a.style.width=r.width,a.style.height=r.height,r=null)};if(a){if(e){const s=parseFloat(e);!isNaN(s)&&s>0&&(a.style.transform=`scale(${s})`,a.style.transformOrigin="top left",console.log(`[Dev Template] 应用缩放比例: ${s}`))}if(o||n){if(o){const s=parseInt(o);!isNaN(s)&&s>0&&(a.style.width=`${s}px`,console.log(`[Dev Template] 设置宽度: ${s}px`))}if(n){const s=parseInt(n);!isNaN(s)&&s>0&&(a.style.height=`${s}px`,console.log(`[Dev Template] 设置高度: ${s}px`))}}}K=Pt();const S=K.getInitialMode();window.DevTemplateBootstrap={renderComponent:Ft,React:G,ReactDOM:$t,inspectaMode:S==="inspecta",editors:K.api},console.log("[Dev Template Bootstrap] 已挂载到全局"),window.addEventListener("message",async s=>{var i,f,p,w,T,_,D;if(s.data&&s.data.type==="CAPTURE_SCREENSHOT"){console.log("[Dev Template] 收到截图请求",s.data);const m=window.__ERROR_SYSTEM__,R=((i=m==null?void 0:m.isErrorCaptureEnabled)==null?void 0:i.call(m))??!0;m!=null&&m.setErrorCaptureEnabled&&m.setErrorCaptureEnabled(!1);try{const $=await $e(()=>import("./chunks/vendor-export.js?v=1775123024591").then(g=>g.i),__vite__mapDeps([0,1])),c=document.getElementById("root");if(c){const g=c.style.marginLeft,u=c.style.marginRight,y=c.style.width,d=c.style.height;c.style.marginLeft="0",c.style.marginRight="0";const x=Number.isFinite(Number(s.data.targetWidth)),E=Number.isFinite(Number(s.data.targetHeight));x&&(c.style.width=`${Math.round(Number(s.data.targetWidth))}px`),E&&(c.style.height=`${Math.round(Number(s.data.targetHeight))}px`),(x||E)&&await new Promise(P=>setTimeout(P,100));const v=Bt(c),F=c.scrollWidth,M=c.scrollHeight;let A="";try{await new Promise(P=>setTimeout(P,80)),A=await $.toPng(c,{width:F,height:M,pixelRatio:2,skipAutoScale:!0,backgroundColor:"#fff",skipFonts:!1,cacheBust:!1,includeQueryParams:!0})}finally{v()}c.style.marginLeft=g,c.style.marginRight=u,c.style.width=y,c.style.height=d,window.parent.postMessage({type:"SCREENSHOT_CAPTURED",dataUrl:A,width:F,height:M},"*"),console.log("[Dev Template] 截图成功并发送")}}catch($){console.error("[Dev Template] 截图失败:",$),window.parent.postMessage({type:"SCREENSHOT_FAILED",error:String($)},"*")}finally{m!=null&&m.setErrorCaptureEnabled&&R&&m.setErrorCaptureEnabled(!0)}}if(s.data&&s.data.type==="RESET_SCREENSHOT_STYLES"){console.log("[Dev Template] 收到还原样式请求");const m=document.getElementById("root");m&&(m.style.width="",m.style.height="",m.style.marginLeft="",m.style.marginRight="",console.log("[Dev Template] 样式已还原"))}if(s.data&&s.data.type==="WEB_EDITOR_SET_ROOT_SIZE"){const m=Number(s.data.width),R=s.data.height?Number(s.data.height):void 0;Number.isFinite(m)&&(l(m,R),console.log("[Dev Template] WebEditor 设置 root 尺寸",{width:m,height:R}))}if(s.data&&s.data.type==="WEB_EDITOR_RESET_ROOT_SIZE"&&(h(),console.log("[Dev Template] WebEditor 恢复 root 尺寸")),s.data&&s.data.type==="EXPORT_FIGMA_JSON"){console.log("[Dev Template] 收到 Figma 导出请求",s.data);try{const m=document.getElementById("root"),R=m==null?void 0:m.getAttribute("data-page-id"),$=m==null?void 0:m.getAttribute("data-component-id"),c=R||$||((f=s.data)==null?void 0:f.widgetId),g=((p=s.data)==null?void 0:p.enableAutoLayout)!==!1,u=await Xe("#root",{rootName:((w=s.data)==null?void 0:w.rootName)||document.title||"FRAME",widgetId:c,enableAutoLayout:g});window.parent.postMessage({type:"FIGMA_JSON_READY",success:!0,json:u,...R?{pageId:R}:{},...$?{widgetId:$}:c?{widgetId:c}:{}},"*")}catch(m){console.error("[Dev Template] Figma 导出失败:",m),window.parent.postMessage({type:"FIGMA_JSON_READY",success:!1,error:String(m)},"*")}}if(s.data&&s.data.type==="EXPORT_AXURE_JSON"){console.log("[Dev Template] 收到 Axure 导出请求",s.data);try{const m=await Je("#root",{rootName:((T=s.data)==null?void 0:T.rootName)||document.title||"Page",preserveHierarchy:!!((_=s.data)!=null&&_.preserveHierarchy),preserveSvgIcons:((D=s.data)==null?void 0:D.preserveSvgIcons)!==!1});window.parent.postMessage({type:"AXURE_JSON_READY",success:!0,payload:m},"*")}catch(m){console.error("[Dev Template] Axure 导出失败:",m),window.parent.postMessage({type:"AXURE_JSON_READY",success:!1,error:String(m)},"*")}}})}