@linkfox-web/app-kit 0.1.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{auth-JoGZ-Tg-.d.ts → auth-RGVm8hmz.d.ts} +6 -2
- package/dist/chunk-2YASMNNJ.js +2 -0
- package/dist/chunk-7K2XKPOX.js +1 -0
- package/dist/{chunk-GEWHO37N.js → chunk-SJFNXBPH.js} +1 -1
- package/dist/components/index.d.ts +15 -3
- package/dist/components/index.js +4 -4
- package/dist/react/index.d.ts +2 -2
- package/dist/react/index.js +1 -1
- package/dist/runtime/index.d.ts +4 -87
- package/dist/runtime/index.js +1 -1
- package/dist/word-tables-B3Zc1OiL.d.ts +198 -0
- package/package.json +7 -7
- package/dist/chunk-5LS4UNRR.js +0 -1
- package/dist/chunk-G7FP7VUB.js +0 -1
- package/dist/filter-spec-BHwe1PQ-.d.ts +0 -77
|
@@ -7,6 +7,7 @@ type AuthState = {
|
|
|
7
7
|
status: "anonymous";
|
|
8
8
|
} | {
|
|
9
9
|
status: "redirecting";
|
|
10
|
+
auto?: boolean;
|
|
10
11
|
} | {
|
|
11
12
|
status: "error";
|
|
12
13
|
message: string;
|
|
@@ -27,8 +28,11 @@ declare function authIdentity(): string;
|
|
|
27
28
|
declare function startAuth(): void;
|
|
28
29
|
/** 优先使用固定 Key;未配置时恢复 SSO 会话(http 会话)。 */
|
|
29
30
|
declare function loadApiKey(): Promise<void>;
|
|
30
|
-
/** 整页跳转到 SSO 授权页,登录后回到 redirectUri,再由 restoreSession
|
|
31
|
-
declare function login(
|
|
31
|
+
/** 整页跳转到 SSO 授权页,登录后回到 redirectUri,再由 restoreSession 回到当前页面。自动跳转不留历史记录,否则从授权页返回又会被跳走。 */
|
|
32
|
+
declare function login({ auto }?: {
|
|
33
|
+
auto?: boolean;
|
|
34
|
+
}): Promise<void>;
|
|
35
|
+
/** 用户主动退出:SSO 站点的登录态还在,在当前标签页记下标记,否则一刷新就会被自动登录回来;新开页面恢复自动登录。 */
|
|
32
36
|
declare function logout(): void;
|
|
33
37
|
/**
|
|
34
38
|
* 网关错误处理:
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{f as W,g as B,h as K,i as U,k as M,r as D,w as _}from"./chunk-7K2XKPOX.js";function he(e){return e.type==="range"||e.type==="dateRange"?[`${e.id}.gte`,`${e.id}.lte`]:[e.id]}function Q(e){return(e??"").split(",").map(t=>t.trim()).filter(Boolean)}function ke(e,t,o){let n=Q(e).filter(a=>a!==t);return o&&n.push(t),n.join(",")}function ye(e,t){for(let o of e){let n=o.items.find(a=>t===a.href||t.startsWith(`${a.href}/`));if(n)return{group:o,item:n}}return null}async function F(e){try{return await e}catch(t){throw _(t),t}}import*as y from"@linkfox-web/ai-tools/agent-os";var Z=2500,J=5,ee=3,Ne=[{id:"default",name:"通用助手"},{id:"linkfox-product-selection-agent",name:"选品 Agent"},{id:"linkfox-market-analysis-agent",name:"市场分析 Agent"},{id:"linkfox-listing-agent",name:"Listing Agent"},{id:"linkfox-image-agent",name:"图片 Agent"},{id:"linkfox-video-agent",name:"视频 Agent"}],te={read:"读取文件",execute:"执行命令",edit:"编辑文件",search:"搜索"},G=e=>e?.type==="text"||e?.type===void 0?e?.text??e?.value??"":"";function ne(e){return e.type!=="resource_link"||!e.uri?null:{name:decodeURIComponent(e.uri.split("?")[0].split("/").pop()??"")||e.name||"文件",uri:e.uri}}function re(e){let t=new Map,o="";return e.forEach((n,a)=>{if(n.sessionUpdate==="tool_call"||n.sessionUpdate==="tool_call_update"){let d=n.toolCallId??`step-${a}`,b=t.get(d),h=n.title?.replace(/\(.*\)$/,"")||b?.title||te[n.kind??""]||"处理中",x=n.status==="completed"?"done":n.status==="failed"?"failed":b?.status??"running";t.set(d,{id:d,title:h,status:x})}else(n.sessionUpdate==="agent_message_chunk"||n.sessionUpdate==null)&&(o+=G(n.content))}),{steps:[...t.values()],text:o}}function se(e){let t="",o=new Map;for(let{content:n}of e){if(!n)continue;let a=ne(n);a?o.set(a.uri,a):t+=G(n)}return{text:t,files:[...o.values()]}}function Ae(e){return F(y.cancelTask({messageId:e}))}async function Ee(e){try{return(await F(y.getShareUrl({messageId:e}))).shareUrl||void 0}catch{return}}async function Le(e,t,{signal:o,onUpdate:n,sessionId:a}){let d=await F(y.createTask(a?{prompt:e,modelId:t,sessionId:a}:{prompt:e,modelId:t},{signal:o}));if(!d.id)throw new W(500,"LinkFox OS 没有返回任务 ID");let b=d.id,h=d.sessionId||a||"";n({messageId:b,sessionId:h,steps:[],text:"",files:[],stopReason:""});let x=new Map,w=0,N=0;for(;;){await M(Z,o);let O=Math.max(0,w-J),I;try{I=await F(y.getTask({messageId:b,fromIndex:O},{signal:o})),N=0}catch(g){if(B(g)||U(g)||K(g)||++N>=ee)throw g;continue}I.eventList?.forEach((g,R)=>x.set(O+R,g)),w=I.eventTotal??w;let P=[...x.entries()].sort((g,R)=>g[0]-R[0]).map(([,g])=>g),A=re(P),v=I.message?.stopReason??"";if(v){let g=se(I.message?.agentMessageChunks??[]),R=A.steps.map(L=>L.status==="running"?{...L,status:"done"}:L);return{messageId:b,sessionId:h,steps:R,text:g.text||A.text,files:g.files,stopReason:v}}n({messageId:b,sessionId:h,steps:A.steps,text:A.text,files:[],stopReason:""})}}import{LinkfoxHttpError as oe}from"@linkfox-web/http";import*as u from"@linkfox-web/ai-tools/smart-table";function E(e,t){return new oe({service:"ai-tools",status:200,code:e,message:t})}var j=(e,t)=>(e.createdTime??"").localeCompare(t.createdTime??""),H=e=>Object.fromEntries(e.map(t=>[t.name,t.fieldId]));function V(e,t,o){let n=e.get(t);return n||(n=o(),e.set(t,n),n.catch(()=>e.delete(t))),n}function ie(){return typeof window>"u"?!1:/(^|\.)app\.linkfox\.com$/.test(window.location.hostname)}var ae=new Set(["主图"]);function _e(e){let t=e.fields??{},o=new Map,n=new Map,a=new Map;async function d(s){try{return await s}catch(i){throw _(i),i}}async function b(s){let i=[];for(let r=1;r<=50;r++){let c=await d(u[s]({page:r,perPage:100})),l=c.notebooks??[];if(i.push(...l),l.length===0||i.length>=(c.total??0))break}return i}async function h(){let{notebookId:s,notebookName:i}=e,r=await b("listMyTables");if(s){let k=r.find(T=>T.notebookId===s)??(await b("listSharedTables")).find(T=>T.notebookId===s);if(!k)throw E(404,`找不到配置的多维表 ${s},请检查 .env 的 NEXT_PUBLIC_NOTE_BOOK_ID 或 linkfox.config.ts`);return k}if(ie())throw E(500,"应用未绑定多维表(缺少 NEXT_PUBLIC_NOTE_BOOK_ID)。请重新打开应用完成初始化后再试。");let c=r.filter(k=>k.name===i).sort(j);if(c.length)return c[0];let l=(await b("listSharedTables")).filter(k=>k.name===i).sort(j);if(l.length)return l[0];let m=e.requestKeyPrefix??"linkfox-app",p=await d(u.createTable({name:i,requestKey:`${m}-${i}`}));return{notebookId:p.notebookId,name:p.notebookName,tables:[{tableId:p.tableId,name:p.name,url:p.url,refKey:p.refKey}]}}function x(){return V(o,D(),h)}function w(s,i){return V(n,`${D()}:${s}`,async()=>{let r=i??t[s];if(!r)throw E(500,`数据表 ${String(s)} 没有登记列定义,请在 linkfox.config.ts 的 smartTableConfig.fields 里补上`);let c=e.tables[s];if(!c)throw E(500,`数据表 ${String(s)} 没有登记表名,请在 smartTableConfig.tables 里补上`);let l=await x(),m=l.tables.find(f=>f.name===c);if(!m){let f=await d(u.addTable({notebookId:l.notebookId,name:c,fields:r})),S={tableId:f.tableId,name:f.name,url:f.url,refKey:f.refKey};return l.tables.push(S),{...S,fieldIds:H(f.fields??[])}}let{fields:p}=await d(u.listFields({tableId:m.tableId,includeChoices:!1})),k=r.filter(f=>ae.has(f.name)&&p.some(S=>S.name===f.name&&S.type!==f.type)),T=p;if(k.length){let f=k.map(C=>C.name);T=(await d(u.deleteFields({tableId:m.tableId,fieldNames:f,allowBreakingDependents:!0}))).fields??p.filter(C=>!f.includes(C.name))}let z=new Set(T.map(f=>f.name)),$=r.filter(f=>!z.has(f.name));for(let f=0;f<$.length;f+=50)T=(await d(u.addFields({tableId:m.tableId,fields:$.slice(f,f+50)}))).fields??T;return{...m,fieldIds:H(T)}})}function N(s){return d(u.listRecords(s))}async function O(s,i=100){let r=[];for(let c=1;c<=i;c++){let l=await N({...s,page:c,perPage:100});if(r.push(...l.records),l.records.length<100||r.length>=l.total)break}return r}async function I(s,i){let r=[];for(let c=0;c<i.length;c+=50){let l=i.slice(c,c+50),m=await d(u.createRecords({tableId:s,records:l.map(p=>({fields:p}))}));if(r.push(...m.records??[]),m.created!==l.length)throw E(500,`已写入 ${r.length} 条,但有 ${l.length-m.created} 条未写入成功`)}return r}async function P(s,i){for(let r=0;r<i.length;r+=100){let c=i.slice(r,r+100),l=await d(u.updateRecords({tableId:s,records:c}));if(l.updated!==c.length)throw E(404,`只更新了 ${l.updated}/${c.length} 条,记录可能已被删除,请刷新后重试`)}}async function A(s,i){for(let r=0;r<i.length;r+=100)await d(u.deleteRecords({tableId:s,recordIds:i.slice(r,r+100)}))}function v(s,i,r,c){let l=`${s}:${i}:${r}`,p=(a.get(l)??Promise.resolve()).catch(()=>{}).then(()=>d(u.uploadAttachment({tableId:s,recordId:i,fieldName:r,imageUrl:c})).then(k=>k.attachment));return a.set(l,p),p.finally(()=>{a.get(l)===p&&a.delete(l)}).catch(()=>{}),p}async function g(s,i,r,c,l){return(await N({tableId:s,perPage:100,fieldNames:l,filter:{conditions:[{fieldName:i,operator:"is",value:r}]}})).records.find(p=>p.recordId===c)??null}function R(){return Promise.all(Object.keys(t).map(s=>w(s)))}async function L(s){return(await w(s)).tableId}return{config:e,TABLE_FIELDS:t,getNotebook:x,ensureTable:w,listRecords:N,listAllRecords:O,createRecords:I,updateRecords:P,deleteRecords:A,uploadAttachment:v,getRecord:g,warmTables:R,tableIdOf:L}}var q;function Pe(e){q=e}function X(){return q}function le(e){return Array.isArray(e)&&e.every(t=>t&&typeof t=="object"&&"token"in t)}function ce(e){return le(e)?e[0]:void 0}function Ce(e,t="full"){let o=ce(e);return o&&(t==="thumb"?o.smThumbnailUrl??o.lgThumbnailUrl??o.presignedUrl:o.presignedUrl)||void 0}var de=e=>e==null?"":typeof e=="string"?e:String(e),De=e=>typeof e=="number"?e:Number(e)||0,$e=e=>de(e).split(/[,,、\n]/).map(t=>t.trim()).filter(Boolean),We=()=>new Date().toISOString();var fe=["启用","禁用"],ue=[{name:"词条",type:"singleLineText"},{name:"中文名",type:"singleLineText"},{name:"状态",type:"singleSelect",choices:fe.map(e=>({name:e}))},{name:"来源",type:"singleLineText"},{name:"创建时间",type:"date"}],pe={brandWords:"品牌词",sensitiveWords:"敏感词"},ge=Object.keys(pe);function me(e){function t(n){return e.ensureTable(n,ue)}async function o(){return(await Promise.all(ge.map(async a=>{let{tableId:d}=await t(a);return(await e.listAllRecords({tableId:d,fieldNames:["词条"],filter:{conditions:[{fieldName:"状态",operator:"is",value:"启用"}]}})).map(h=>String(h.fields.词条??"").trim()).filter(Boolean).map(h=>({word:h,kind:a}))}))).flat()}return{ensureWordTable:t,loadActiveWords:o}}function Ue(){let e=X();if(!e)throw new Error("多维表客户端尚未初始化:请确认模板的 lib/app-kit.ts 调用了 setActiveSmartTable(smartTable)");return me(e)}var be=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),Y=/[A-Za-z0-9]/;function Me(e){let t=e.map(o=>{let n=o.word.replace(/\s+/g," "),a=Y.test(n[0])?"(?<![\\p{L}\\p{N}])":"",d=Y.test(n[n.length-1])?"(?![\\p{L}\\p{N}])":"";return{hit:o,re:new RegExp(`${a}${be(n).replace(/ /g,"\\s+")}${d}`,"iu")}});return o=>{let n=o.filter(Boolean).join(`
|
|
2
|
+
`);return t.filter(a=>a.re.test(n)).map(a=>a.hit)}}export{he as a,Q as b,ke as c,ye as d,F as e,Ne as f,Ae as g,Ee as h,Le as i,_e as j,Pe as k,X as l,le as m,ce as n,Ce as o,de as p,De as q,$e as r,We as s,fe as t,ue as u,pe as v,me as w,Ue as x,Me as y};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var p;function j(t){p={...t}}function n(){if(!p)throw new Error("app-kit 未配置:请在模板的 lib/app-kit.ts 中调用 configureAppKit(),并在入口组件里 import 该文件");return p}function s(){return n().apiKey?.()?.trim()||void 0}import{isLinkfoxHttpError as u,LinkfoxHttpError as C}from"@linkfox-web/http";var L=/算力|余额不足|计费不足|套餐到期|充值|quota exceeded|insufficient balance/i,P=/invalid_token|the access token is invalid|expired or revoked/i,c="会话已过期,请重新登录";function l(t){if(!u(t))return!1;if(t.message===c)return!0;let e=typeof t.body=="string"?t.body:JSON.stringify(t.body??"");return P.test(`${t.message} ${e}`)}var x=class extends C{constructor(e,r){super({service:"app",status:0,code:e,message:r})}};function et(t){return t instanceof DOMException&&t.name==="AbortError"}function O(t){return u(t)&&t.service==="ai-tools"&&(String(t.code)==="402"||L.test(t.message))}function g(t){return u(t)&&t.service==="ai-tools"&&(String(t.code)==="401"||t.status===401)}function m(t){if(u(t)){let e=String(t.code??"");return e==="NETWORK_ERROR"?"网络请求失败,请检查网络后重试":e==="TIMEOUT"?"请求超时,请稍后重试":l(t)?c:e==="UNAUTHORIZED"?"登录已失效,请重新登录":g(t)?"工具网关鉴权失败:API Key 或登录已失效":O(t)?`算力余额不足,请前往 LinkFox 充值后重试(${t.message})`:t.message}return t instanceof Error?t.message:String(t)}var nt=(t,e)=>new Promise((r,k)=>{let v=setTimeout(r,t);e?.addEventListener("abort",()=>{clearTimeout(v),k(new DOMException("Aborted","AbortError"))})});import{recordAppVisit as N}from"@linkfox-web/ai-tools/smart-table";var U="public_app_id_xxx";function y(){let t=n().applicationId?.trim();if(!(!t||t===U))return t}function E(){let t=y();if(!t)return;let e=typeof window>"u"?void 0:window.location.href;N({appId:t,appUrl:e}).catch(()=>{})}import{configure as R}from"@linkfox-web/http";import"@linkfox-web/api-user-center";var T=!1;function S(){if(T)return;let t=n();R({services:{"ai-tools":{baseURL:t.gatewayBaseUrl,apiKey:s,apiKeyHeader:t.rewrite?"Authorization":"tool-gateway-api-key"},"third-party-sso":{baseURL:t.ssoBaseUrl}}}),T=!0}import{clearSession as M}from"@linkfox-web/http";import{clearThirdPartySsoSession as D,completeThirdPartySsoRedirect as $,getThirdPartyApplicationTeam as B,readThirdPartySsoSession as _,redirectToThirdPartySso as X}from"@linkfox-web/api-user-center";var b={status:"loading"},G=3e3,H=3e4,o=b,K=!1,h,w,I=new Set;function i(t){o=t,I.forEach(e=>e())}function St(t){return I.add(t),()=>{I.delete(t)}}function F(){return o}function wt(){return b}function It(){return o.status==="ready"?o.identity:""}function a(){clearTimeout(w),h=void 0}function f(){return`linkfox:sso:signed-out:${n().ssoClientId}`}function V(){if(new URLSearchParams(window.location.search).get("login")==="manual")return!1;try{if(window.sessionStorage.getItem(f()))return!1;let t=`linkfox:sso:auto-login:${n().ssoClientId}`;return Date.now()-Number(window.sessionStorage.getItem(t))<H?!1:(window.sessionStorage.setItem(t,String(Date.now())),!0)}catch{return!1}}function q(){try{return!!window.sessionStorage.getItem(f())}catch{return!1}}function z(t){h=t.accessToken;try{window.sessionStorage.removeItem(f())}catch{}clearTimeout(w),w=setTimeout(()=>{d()},Math.min(Math.max(t.expireAt-Date.now(),0),2147483647)),i({status:"ready",identity:`${n().ssoClientId}:${t.sub}`,userName:t.name}),E()}function At(){if(K)return;if(K=!0,s()){d();return}S();let t=n().ssoClientId,e=()=>{if(o.status!=="ready")return;let r=_(t);(!r||r.accessToken!==h)&&d()};window.addEventListener("focus",e),document.addEventListener("visibilitychange",e),window.addEventListener("pageshow",r=>{r.persisted&&o.status==="redirecting"&&i({status:"anonymous"})}),J()}async function J(){let t=n().ssoClientId;if(t){new URLSearchParams(window.location.search).has("state")&&i({status:"callback"});try{let e=await $(t);if(e&&e.returnTo!==window.location.href){window.location.replace(e.returnTo);return}}catch(e){a(),i({status:"error",action:"login",message:m(e)});return}}await d(),F().status==="anonymous"&&V()&&await Z({auto:!0})}async function d(){S();let t=s();if(t){a(),M(),i({status:"ready",apiKey:t,identity:"api-key",userName:"API Key 访问"});return}let e=n().ssoClientId;if(!e){a(),i({status:"error",action:"config",message:"请配置 NEXT_PUBLIC_LINKFOX_SSO_CLIENT_ID(开发使用 .env.local,构建使用 .env),然后重启或重新构建"});return}let r=_(e);if(r){z(r);return}a(),i({status:"anonymous"})}function W(){let t=n().basePath??"";return t?`${window.location.origin}${t}/`:window.location.origin}async function Y(){let t=y();if(t)try{return await B(n().ssoClientId,t,{timeout:G})}catch{return}}async function Z({auto:t=!1}={}){if(o.status!=="redirecting"){a(),i({status:"redirecting",auto:t});try{await X({clientId:n().ssoClientId,redirectUri:W(),replace:t,autoLogin:q()?!1:void 0,teamId:await Y()})}catch(e){i({status:"error",action:"login",message:m(e)})}}}function A(){D(n().ssoClientId),a(),i({status:"anonymous"})}function ht(){try{window.sessionStorage.setItem(f(),"1")}catch{}A()}function xt(t){if(l(t)){if(o.status!=="ready")return;A(),i({status:"error",action:"login",message:c});return}if(!(!g(t)||o.status!=="ready")){if(s()){a(),i({status:"error",action:"config",message:"API Key 已失效,请更新 NEXT_PUBLIC_LINKFOX_API_KEY 后重启开发服务或重新构建部署"});return}A(),i({status:"error",action:"login",message:"登录已失效,请重新登录"})}}function Et(t){return t.length<=8?"****":`${t.slice(0,4)}****${t.slice(-4)}`}function Tt(){return s()??null}export{j as a,n as b,s as c,c as d,l as e,x as f,et as g,O as h,g as i,m as j,nt as k,y as l,E as m,S as n,St as o,F as p,wt as q,It as r,At as s,d as t,Z as u,ht as v,xt as w,Et as x,Tt as y};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{o as g,p as l,q as c}from"./chunk-
|
|
1
|
+
import{o as g,p as l,q as c}from"./chunk-7K2XKPOX.js";import{useSyncExternalStore as T}from"react";function R(){return T(g,l,c)}import{useSyncExternalStore as f}from"react";var s="linkfox:timezone",u=new Set;function x(){return Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"}function m(){try{return localStorage.getItem(s)}catch{return null}}function w(){return m()||x()}function p(t){u.add(t);let e=r=>{r.key===s&&t()};return window.addEventListener("storage",e),()=>{u.delete(t),window.removeEventListener("storage",e)}}function U(t){try{t?localStorage.setItem(s,t):localStorage.removeItem(s)}catch{}u.forEach(e=>e())}function _(){return f(p,w,()=>"UTC")}function M(){return f(p,()=>m()===null,()=>!0)}function F(t,e=new Date){try{return new Intl.DateTimeFormat("en-US",{timeZone:t,timeZoneName:"longOffset"}).formatToParts(e).find(n=>n.type==="timeZoneName")?.value.replace("GMT","UTC")||"UTC"}catch{return""}}function y(t){if(t instanceof Date)return t;if(typeof t=="number")return new Date(t);let e=String(t).trim();return/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}(:\d{2})?$/.test(e)?new Date(`${e.replace(" ","T")}Z`):/^\d{4}-\d{2}-\d{2}$/.test(e)?new Date(`${e}T00:00:00Z`):new Date(e)}function d(t,e){let r=new Intl.DateTimeFormat("en-US",{timeZone:t,hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}).formatToParts(new Date(e)),n=o=>Number(r.find(i=>i.type===o)?.value);return Date.UTC(n("year"),n("month")-1,n("day"),n("hour"),n("minute"),n("second"))-e}function L(t,e,r=0){let[n,o,i]=t.split("-").map(Number),a=Date.UTC(n,o-1,i+r),b=a-d(e,a);return a-d(e,b)}function G(t,e){if(t==null||t==="")return"-";let r=y(t);return!r||Number.isNaN(r.getTime())?String(t):new Intl.DateTimeFormat("zh-CN",{timeZone:e,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}).format(r)}import{createContext as C,useContext as D,useEffect as h,useMemo as P,useState as A}from"react";import{jsx as $}from"react/jsx-runtime";var B="linkfox:agent-done",N=200,S=C(null);function K({children:t}){let[e,r]=A(!1),[n,o]=A(null),i=P(()=>({open:e,setOpen:r,page:n,setPage:o}),[e,n]);return $(S.Provider,{value:i,children:t})}function E(){let t=D(S);if(!t)throw new Error("useAgent 必须在 AgentProvider 内使用");return t}function V(t){let{setPage:e}=E(),r=t?JSON.stringify(t):"";h(()=>{e(r?JSON.parse(r):null)},[r,e]),h(()=>()=>e(null),[e])}function X(t,e,r){if(!e)return t;let n=["【页面上下文(系统自动带入)】",`当前页面:${e.source}`];if(e.table&&(r&&n.push(`多维表格:${r.name}(notebookId: ${r.notebookId})`),n.push(`数据表:${e.table.name}(tableId: ${e.table.id})`),n.push("读写数据请用 linkfox-smart-table 技能操作上述数据表,修改前确认字段名存在。")),e.records.length){let o=e.records.slice(0,N);n.push(`用户勾选的记录(${e.records.length} 条,格式:${e.idLabel??"recordId"} | 摘要):`),o.forEach(i=>n.push(`- ${i.id} | ${i.label}`)),e.records.length>o.length&&n.push(`(其余 ${e.records.length-o.length} 条未列出)`)}return n.push("","【用户要求】",t),n.join(`
|
|
2
2
|
`)}var Y=(t,e=60)=>t.length>e?`${t.slice(0,e)}…`:t;export{R as a,x as b,U as c,_ as d,M as e,F as f,L as g,G as h,B as i,K as j,E as k,V as l,X as m,Y as n};
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { JSX } from 'react';
|
|
3
|
-
import { N as NavGroup, U as UiFilterSpec, F as FilterValues } from '../
|
|
4
|
-
export { a as NavItem, f as findNav } from '../
|
|
3
|
+
import { N as NavGroup, U as UiFilterSpec, F as FilterValues, W as WordTableKey } from '../word-tables-B3Zc1OiL.js';
|
|
4
|
+
export { a as NavItem, f as findNav } from '../word-tables-B3Zc1OiL.js';
|
|
5
5
|
import { ThemeProvider as ThemeProvider$1 } from 'next-themes';
|
|
6
6
|
import 'lucide-react';
|
|
7
|
+
import '@linkfox-web/ai-tools/smart-table';
|
|
7
8
|
|
|
8
9
|
interface AgentSuggestions {
|
|
9
10
|
/** 按页面 source 结尾匹配的推荐提问 */
|
|
@@ -169,6 +170,17 @@ declare function ConfirmDialog({ open, onOpenChange, title, description, details
|
|
|
169
170
|
onConfirm: () => void;
|
|
170
171
|
}): react.JSX.Element;
|
|
171
172
|
|
|
173
|
+
/**
|
|
174
|
+
* 品牌词 / 敏感词管理页:词库增删改查、启停、分页。
|
|
175
|
+
*
|
|
176
|
+
* 页面只需要一行 `<WordManager kind="brandWords" description="…" />`;两张表的列定义、
|
|
177
|
+
* 建表与匹配规则都在 `@linkfox-web/app-kit/runtime` 的 `word-tables` 里。
|
|
178
|
+
*/
|
|
179
|
+
declare function WordManager({ kind, description }: {
|
|
180
|
+
kind: WordTableKey;
|
|
181
|
+
description: string;
|
|
182
|
+
}): react.JSX.Element;
|
|
183
|
+
|
|
172
184
|
/** 阶段通过情况:一行一个阶段,label 如「G1 新品初筛」 */
|
|
173
185
|
interface TaskCardStage {
|
|
174
186
|
key: string;
|
|
@@ -263,4 +275,4 @@ declare function Markdown({ children }: {
|
|
|
263
275
|
children: string;
|
|
264
276
|
}): JSX.Element;
|
|
265
277
|
|
|
266
|
-
export { AgentPanel, type AgentSuggestions, AgentToggle, AppShell, type AppShellProps, AppSidebar, type AppSidebarProps, AuthGate, ColumnPicker, ComboInput, type ComboOption, ConfirmDialog, type DataColumn, DataPagination, DataTable, FilterPanel, Markdown, NavGroup, PAGE_SIZE, type StageCounts, type StageNode, type StageNodeState, StageProgress, TaskCard, type TaskCardBudget, type TaskCardData, type TaskCardStage, TaskLog, ThemeProvider, TimezoneSelect, UserMenu, countsBalanced };
|
|
278
|
+
export { AgentPanel, type AgentSuggestions, AgentToggle, AppShell, type AppShellProps, AppSidebar, type AppSidebarProps, AuthGate, ColumnPicker, ComboInput, type ComboOption, ConfirmDialog, type DataColumn, DataPagination, DataTable, FilterPanel, Markdown, NavGroup, PAGE_SIZE, type StageCounts, type StageNode, type StageNodeState, StageProgress, TaskCard, type TaskCardBudget, type TaskCardData, type TaskCardStage, TaskLog, ThemeProvider, TimezoneSelect, UserMenu, WordManager, countsBalanced };
|
package/dist/components/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use client";import{a as ia,b as sa,c as la,d as Ee,f as Tt,g as fa,h as ga,i as ba,l as va}from"../chunk-G7FP7VUB.js";import{a as ot,b as It,c as xa,d as ha,e as Ca,f as rt,i as ya,j as wa,k as zt,m as Na}from"../chunk-GEWHO37N.js";import{g as ra,j as na,s as da,t as ca,u as pa,v as ma,x as ua}from"../chunk-5LS4UNRR.js";import{Fragment as Gn}from"react";import Fn from"next/link";import{usePathname as On}from"next/navigation";import Lt from"next/link";import{usePathname as Ur}from"next/navigation";import{ChevronRightIcon as Zr}from"lucide-react";import{Collapsible as Dt}from"radix-ui";import{jsx as At}from"react/jsx-runtime";function ge({...e}){return At(Dt.Root,{"data-slot":"collapsible",...e})}function be({...e}){return At(Dt.CollapsibleTrigger,{"data-slot":"collapsible-trigger",...e})}function ve({...e}){return At(Dt.CollapsibleContent,{"data-slot":"collapsible-content",...e})}import*as M from"react";import{cva as Er}from"class-variance-authority";import{cn as I}from"cn";import{Slot as _a}from"radix-ui";import*as Pa from"react";var vr=768,ka=`(max-width: ${vr-1}px)`;function xr(e){let t=window.matchMedia(ka);return t.addEventListener("change",e),()=>t.removeEventListener("change",e)}function Sa(){return Pa.useSyncExternalStore(xr,()=>window.matchMedia(ka).matches,()=>!1)}import{cva as hr}from"class-variance-authority";import{cn as Cr}from"cn";import{Slot as yr}from"radix-ui";import{jsx as Nr}from"react/jsx-runtime";var wr=hr("group/button inline-flex shrink-0 items-center justify-center rounded-lg border border-transparent bg-clip-padding text-sm font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/80",outline:"border-border bg-background hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground hover:bg-[color-mix(in_oklch,var(--secondary),var(--foreground)_5%)] aria-expanded:bg-secondary aria-expanded:text-secondary-foreground",ghost:"hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50",destructive:"bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-8 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",xs:"h-6 gap-1 rounded-[min(var(--radius-md),10px)] px-2 text-xs in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3",sm:"h-7 gap-1 rounded-[min(var(--radius-md),12px)] px-2.5 text-[0.8rem] in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5",lg:"h-9 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",icon:"size-8","icon-xs":"size-6 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-lg [&_svg:not([class*='size-'])]:size-3","icon-sm":"size-7 rounded-[min(var(--radius-md),12px)] in-data-[slot=button-group]:rounded-lg","icon-lg":"size-9"}},defaultVariants:{variant:"default",size:"default"}});function p({className:e,variant:t="default",size:a="default",asChild:o=!1,...r}){let i=o?yr.Root:"button";return Nr(i,{"data-slot":"button","data-variant":t,"data-size":a,className:Cr(wr({variant:t,size:a,className:e})),...r})}import{cn as Pr}from"cn";import{jsx as kr}from"react/jsx-runtime";function te({className:e,type:t,...a}){return kr("input",{type:t,"data-slot":"input",className:Pr("h-8 w-full min-w-0 rounded-lg border border-input bg-transparent px-2.5 py-1 text-base transition-colors outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40",e),...a})}import{cn as Sr}from"cn";import{Separator as Rr}from"radix-ui";import{jsx as Tr}from"react/jsx-runtime";function Ra({className:e,orientation:t="horizontal",decorative:a=!0,...o}){return Tr(Rr.Root,{"data-slot":"separator",decorative:a,orientation:t,className:Sr("shrink-0 bg-border data-horizontal:h-px data-horizontal:w-full data-vertical:w-px data-vertical:self-stretch",e),...o})}import{cn as _e}from"cn";import{Dialog as ae}from"radix-ui";import{XIcon as Ir}from"lucide-react";import{jsx as $,jsxs as Mt}from"react/jsx-runtime";function Ta({...e}){return $(ae.Root,{"data-slot":"sheet",...e})}function zr({...e}){return $(ae.Portal,{"data-slot":"sheet-portal",...e})}function Dr({className:e,...t}){return $(ae.Overlay,{"data-slot":"sheet-overlay",className:_e("fixed inset-0 z-50 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0",e),...t})}function Ia({className:e,children:t,side:a="right",showCloseButton:o=!0,...r}){return Mt(zr,{children:[$(Dr,{}),Mt(ae.Content,{"data-slot":"sheet-content","data-side":a,className:_e("fixed z-50 flex flex-col gap-4 bg-popover bg-clip-padding text-sm text-popover-foreground shadow-lg transition duration-200 ease-in-out data-[side=bottom]:inset-x-0 data-[side=bottom]:bottom-0 data-[side=bottom]:h-auto data-[side=bottom]:border-t data-[side=left]:inset-y-0 data-[side=left]:left-0 data-[side=left]:h-full data-[side=left]:w-3/4 data-[side=left]:border-r data-[side=right]:inset-y-0 data-[side=right]:right-0 data-[side=right]:h-full data-[side=right]:w-3/4 data-[side=right]:border-l data-[side=top]:inset-x-0 data-[side=top]:top-0 data-[side=top]:h-auto data-[side=top]:border-b data-[side=left]:sm:max-w-sm data-[side=right]:sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-[side=bottom]:data-open:slide-in-from-bottom-10 data-[side=left]:data-open:slide-in-from-left-10 data-[side=right]:data-open:slide-in-from-right-10 data-[side=top]:data-open:slide-in-from-top-10 data-closed:animate-out data-closed:fade-out-0 data-[side=bottom]:data-closed:slide-out-to-bottom-10 data-[side=left]:data-closed:slide-out-to-left-10 data-[side=right]:data-closed:slide-out-to-right-10 data-[side=top]:data-closed:slide-out-to-top-10",e),...r,children:[t,o&&$(ae.Close,{"data-slot":"sheet-close",asChild:!0,children:Mt(p,{variant:"ghost",className:"absolute top-3 right-3",size:"icon-sm",children:[$(Ir,{}),$("span",{className:"sr-only",children:"Close"})]})})]})]})}function za({className:e,...t}){return $("div",{"data-slot":"sheet-header",className:_e("flex flex-col gap-0.5 p-4",e),...t})}function Da({className:e,...t}){return $(ae.Title,{"data-slot":"sheet-title",className:_e("font-heading text-base font-medium text-foreground",e),...t})}function Aa({className:e,...t}){return $(ae.Description,{"data-slot":"sheet-description",className:_e("text-sm text-muted-foreground",e),...t})}import{cn as Ar}from"cn";import{jsx as Mr}from"react/jsx-runtime";function Ma({className:e,...t}){return Mr("div",{"data-slot":"skeleton",className:Ar("animate-pulse rounded-md bg-muted",e),...t})}import{cn as Br}from"cn";import{Tooltip as Ge}from"radix-ui";import{jsx as nt,jsxs as Lr}from"react/jsx-runtime";function Ba({...e}){return nt(Ge.Root,{"data-slot":"tooltip",...e})}function La({...e}){return nt(Ge.Trigger,{"data-slot":"tooltip-trigger",...e})}function Ea({className:e,sideOffset:t=0,children:a,...o}){return nt(Ge.Portal,{children:Lr(Ge.Content,{"data-slot":"tooltip-content",sideOffset:t,className:Br("z-50 inline-flex w-fit max-w-xs origin-(--radix-tooltip-content-transform-origin) items-center gap-1.5 rounded-md bg-foreground px-3 py-1.5 text-xs text-background has-data-[slot=kbd]:pr-1.5 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 **:data-[slot=kbd]:relative **:data-[slot=kbd]:isolate **:data-[slot=kbd]:z-50 **:data-[slot=kbd]:rounded-sm data-[state=delayed-open]:animate-in data-[state=delayed-open]:fade-in-0 data-[state=delayed-open]:zoom-in-95 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",e),...o,children:[a,nt(Ge.Arrow,{className:"z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground"})]})})}import{PanelLeftIcon as _r}from"lucide-react";import{jsx as x,jsxs as Fe}from"react/jsx-runtime";var Gr="sidebar_state",Fr=3600*24*7,Or="16rem",Vr="18rem",$r="3rem",Hr="b",Ga=M.createContext(null);function xe(){let e=M.useContext(Ga);if(!e)throw new Error("useSidebar must be used within a SidebarProvider.");return e}function Fa({defaultOpen:e=!0,open:t,onOpenChange:a,className:o,style:r,children:i,...s}){let n=Sa(),[l,c]=M.useState(!1),[f,k]=M.useState(e),w=t??f,S=M.useCallback(g=>{let y=typeof g=="function"?g(w):g;a?a(y):k(y),document.cookie=`${Gr}=${y}; path=/; max-age=${Fr}`},[a,w]),C=M.useCallback(()=>n?c(g=>!g):S(g=>!g),[n,S,c]);M.useEffect(()=>{let g=y=>{y.key===Hr&&(y.metaKey||y.ctrlKey)&&(y.preventDefault(),C())};return window.addEventListener("keydown",g),()=>window.removeEventListener("keydown",g)},[C]);let v=w?"expanded":"collapsed",P=M.useMemo(()=>({state:v,open:w,setOpen:S,isMobile:n,openMobile:l,setOpenMobile:c,toggleSidebar:C}),[v,w,S,n,l,c,C]);return x(Ga.Provider,{value:P,children:x("div",{"data-slot":"sidebar-wrapper",style:{"--sidebar-width":Or,"--sidebar-width-icon":$r,...r},className:I("group/sidebar-wrapper flex min-h-svh w-full has-data-[variant=inset]:bg-sidebar",o),...s,children:i})})}function Oa({side:e="left",variant:t="sidebar",collapsible:a="offcanvas",className:o,children:r,dir:i,...s}){let{isMobile:n,state:l,openMobile:c,setOpenMobile:f}=xe();return a==="none"?x("div",{"data-slot":"sidebar",className:I("flex h-full w-(--sidebar-width) flex-col bg-sidebar text-sidebar-foreground",o),...s,children:r}):n?x(Ta,{open:c,onOpenChange:f,...s,children:Fe(Ia,{dir:i,"data-sidebar":"sidebar","data-slot":"sidebar","data-mobile":"true",className:"w-(--sidebar-width) bg-sidebar p-0 text-sidebar-foreground [&>button]:hidden",style:{"--sidebar-width":Vr},side:e,children:[Fe(za,{className:"sr-only",children:[x(Da,{children:"Sidebar"}),x(Aa,{children:"Displays the mobile sidebar."})]}),x("div",{className:"flex h-full w-full flex-col",children:r})]})}):Fe("div",{className:"group peer hidden text-sidebar-foreground md:block","data-state":l,"data-collapsible":l==="collapsed"?a:"","data-variant":t,"data-side":e,"data-slot":"sidebar",children:[x("div",{"data-slot":"sidebar-gap",className:I("relative w-(--sidebar-width) bg-transparent transition-[width] duration-200 ease-linear","group-data-[collapsible=offcanvas]:w-0","group-data-[side=right]:rotate-180",t==="floating"||t==="inset"?"group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4)))]":"group-data-[collapsible=icon]:w-(--sidebar-width-icon)")}),x("div",{"data-slot":"sidebar-container","data-side":e,className:I("fixed inset-y-0 z-10 hidden h-svh w-(--sidebar-width) transition-[left,right,width] duration-200 ease-linear data-[side=left]:left-0 data-[side=left]:group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)] data-[side=right]:right-0 data-[side=right]:group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)] md:flex",t==="floating"||t==="inset"?"p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4))+2px)]":"group-data-[collapsible=icon]:w-(--sidebar-width-icon) group-data-[side=left]:border-r group-data-[side=right]:border-l",o),...s,children:x("div",{"data-sidebar":"sidebar","data-slot":"sidebar-inner",className:"flex size-full flex-col bg-sidebar group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:shadow-sm group-data-[variant=floating]:ring-1 group-data-[variant=floating]:ring-sidebar-border",children:r})})]})}function Va({className:e,onClick:t,...a}){let{toggleSidebar:o}=xe();return Fe(p,{"data-sidebar":"trigger","data-slot":"sidebar-trigger",variant:"ghost",size:"icon-sm",className:I(e),onClick:r=>{t?.(r),o()},...a,children:[x(_r,{}),x("span",{className:"sr-only",children:"Toggle Sidebar"})]})}function $a({className:e,...t}){let{toggleSidebar:a}=xe();return x("button",{"data-sidebar":"rail","data-slot":"sidebar-rail","aria-label":"Toggle Sidebar",tabIndex:-1,onClick:a,title:"Toggle Sidebar",className:I("absolute inset-y-0 z-20 hidden w-4 transition-all ease-linear group-data-[side=left]:-right-4 group-data-[side=right]:left-0 after:absolute after:inset-y-0 after:start-1/2 after:w-[2px] hover:after:bg-sidebar-border sm:flex ltr:-translate-x-1/2 rtl:-translate-x-1/2","in-data-[side=left]:cursor-w-resize in-data-[side=right]:cursor-e-resize","[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize","group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full hover:group-data-[collapsible=offcanvas]:bg-sidebar","[[data-side=left][data-collapsible=offcanvas]_&]:-right-2","[[data-side=right][data-collapsible=offcanvas]_&]:-left-2",e),...t})}function Ha({className:e,...t}){return x("main",{"data-slot":"sidebar-inset",className:I("relative flex w-full flex-1 flex-col bg-background md:peer-data-[variant=inset]:m-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow-sm md:peer-data-[variant=inset]:peer-data-[state=collapsed]:ml-2",e),...t})}function Ka({className:e,...t}){return x("div",{"data-slot":"sidebar-header","data-sidebar":"header",className:I("flex flex-col gap-2 p-2",e),...t})}function Ua({className:e,...t}){return x("div",{"data-slot":"sidebar-content","data-sidebar":"content",className:I("no-scrollbar flex min-h-0 flex-1 flex-col gap-0 overflow-auto group-data-[collapsible=icon]:overflow-hidden",e),...t})}function Za({className:e,...t}){return x("div",{"data-slot":"sidebar-group","data-sidebar":"group",className:I("relative flex w-full min-w-0 flex-col p-2",e),...t})}function Bt({className:e,...t}){return x("ul",{"data-slot":"sidebar-menu","data-sidebar":"menu",className:I("flex w-full min-w-0 flex-col gap-0",e),...t})}function it({className:e,...t}){return x("li",{"data-slot":"sidebar-menu-item","data-sidebar":"menu-item",className:I("group/menu-item relative",e),...t})}var Kr=Er("peer/menu-button group/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm ring-sidebar-ring outline-hidden transition-[width,height,padding] group-has-data-[sidebar=menu-action]/menu-item:pr-8 group-data-[collapsible=icon]:size-8! group-data-[collapsible=icon]:p-2! hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-open:hover:bg-sidebar-accent data-open:hover:text-sidebar-accent-foreground data-active:bg-sidebar-accent data-active:font-medium data-active:text-sidebar-accent-foreground [&_svg]:size-4 [&_svg]:shrink-0 [&>span:last-child]:truncate",{variants:{variant:{default:"hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",outline:"bg-background shadow-[0_0_0_1px_var(--sidebar-border)] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_var(--sidebar-accent)]"},size:{default:"h-8 text-sm",sm:"h-7 text-xs",lg:"h-12 text-sm group-data-[collapsible=icon]:p-0!"}},defaultVariants:{variant:"default",size:"default"}});function st({asChild:e=!1,isActive:t=!1,variant:a="default",size:o="default",tooltip:r,className:i,...s}){let n=e?_a.Root:"button",{isMobile:l,state:c}=xe(),f=x(n,{"data-slot":"sidebar-menu-button","data-sidebar":"menu-button","data-size":o,"data-active":t,className:I(Kr({variant:a,size:o}),i),...s});return r?(typeof r=="string"&&(r={children:r}),Fe(Ba,{children:[x(La,{asChild:!0,children:f}),x(Ea,{side:"right",align:"center",hidden:c!=="collapsed"||l,...r})]})):f}function qa({className:e,...t}){return x("ul",{"data-slot":"sidebar-menu-sub","data-sidebar":"menu-sub",className:I("mx-3.5 flex min-w-0 translate-x-px flex-col gap-1 border-l border-sidebar-border px-2.5 py-0.5 group-data-[collapsible=icon]:hidden",e),...t})}function Wa({className:e,...t}){return x("li",{"data-slot":"sidebar-menu-sub-item","data-sidebar":"menu-sub-item",className:I("group/menu-sub-item relative",e),...t})}function Xa({asChild:e=!1,size:t="md",isActive:a=!1,className:o,...r}){let i=e?_a.Root:"a";return x(i,{"data-slot":"sidebar-menu-sub-button","data-sidebar":"menu-sub-button","data-size":t,"data-active":a,className:I("flex h-7 min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-md px-2 text-sidebar-foreground ring-sidebar-ring outline-hidden group-data-[collapsible=icon]:hidden hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[size=md]:text-sm data-[size=sm]:text-xs data-active:bg-sidebar-accent data-active:text-sidebar-accent-foreground [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:text-sidebar-accent-foreground",o),...r})}import{jsx as b,jsxs as oe}from"react/jsx-runtime";function Et({nav:e,appName:t="LinkFox",appSubtitle:a,version:o}){let r=Ur(),i=Ee(e,r),{isMobile:s,setOpenMobile:n}=xe();return oe(Oa,{collapsible:"icon",children:[b(Ka,{children:b(Bt,{children:b(it,{children:b(st,{size:"lg",asChild:!0,children:oe(Lt,{href:"/",children:[b("div",{className:"flex aspect-square size-8 items-center justify-center rounded-lg bg-sidebar-primary font-semibold text-sidebar-primary-foreground",children:"LF"}),oe("div",{className:"flex flex-col gap-0.5 leading-none",children:[oe("span",{className:"flex items-center gap-1.5 font-medium",children:[t,o?b("span",{className:"rounded border px-1 text-[10px] leading-4 font-normal text-muted-foreground tabular-nums",children:o}):null]}),a?b("span",{className:"text-xs text-muted-foreground",children:a}):null]})]})})})})}),b(Ua,{children:b(Za,{children:b(Bt,{children:e.map(l=>{if(l.items.length===1){let c=l.items[0];return b(it,{children:b(st,{tooltip:l.title,isActive:i?.group===l,asChild:!0,children:oe(Lt,{href:c.href,onClick:()=>s&&n(!1),children:[b(l.icon,{}),b("span",{children:l.title})]})})},l.title)}return b(ge,{asChild:!0,defaultOpen:!0,className:"group/collapsible",children:oe(it,{children:[b(be,{asChild:!0,children:oe(st,{tooltip:l.title,isActive:i?.group===l,children:[b(l.icon,{}),b("span",{children:l.title}),b(Zr,{className:"ml-auto transition-transform group-data-[state=open]/collapsible:rotate-90"})]})}),b(ve,{children:b(qa,{children:l.items.map(c=>b(Wa,{children:b(Xa,{asChild:!0,isActive:i?.item===c,children:b(Lt,{href:c.href,onClick:()=>s&&n(!1),children:b("span",{children:c.title})})})},c.href))})})]})},l.title)})})})}),b($a,{})]})}import{useEffect as Ft,useRef as Ot,useState as ne}from"react";import{BotIcon as nn,CheckCircle2Icon as sn,ChevronDownIcon as ln,ExternalLinkIcon as dn,FileTextIcon as cn,MessageCirclePlusIcon as Qa,SendIcon as pn,SparklesIcon as eo,SquareIcon as mn,TableIcon as un,Trash2Icon as fn,XCircleIcon as gn,XIcon as to}from"lucide-react";import qr from"react-markdown";import Wr from"remark-gfm";import{jsx as he}from"react/jsx-runtime";function _(e,t){function a({node:o,...r}){return he(e,{className:t,...r})}return a}var Xr={p:_("p","my-1.5 leading-relaxed"),ul:_("ul","my-1.5 list-disc pl-5"),ol:_("ol","my-1.5 list-decimal pl-5"),li:_("li","my-0.5"),h1:_("h3","mt-3 mb-1 font-semibold"),h2:_("h3","mt-3 mb-1 font-semibold"),h3:_("h4","mt-2 mb-1 font-semibold"),a:({href:e,children:t})=>he("a",{href:e,target:"_blank",rel:"noopener noreferrer",className:"break-all text-primary underline underline-offset-2",children:t}),code:_("code","rounded bg-muted px-1 py-0.5 font-mono text-xs"),pre:_("pre","my-2 overflow-x-auto rounded-md bg-muted p-2 text-xs [&_code]:bg-transparent [&_code]:p-0"),table:({children:e})=>he("div",{className:"my-2 overflow-x-auto rounded-md border",children:he("table",{className:"w-full text-xs",children:e})}),th:_("th","border-b bg-muted px-2 py-1 text-left font-medium whitespace-nowrap"),td:_("td","border-b px-2 py-1 align-top"),blockquote:_("blockquote","my-2 border-l-2 pl-3 text-muted-foreground")};function _t({children:e}){return he("div",{className:"text-sm break-words",children:he(qr,{remarkPlugins:[Wr],components:Xr,children:e})})}import{cn as re}from"cn";import{Select as L}from"radix-ui";import{ChevronDownIcon as Ja,CheckIcon as Jr,ChevronUpIcon as Yr}from"lucide-react";import{jsx as R,jsxs as Gt}from"react/jsx-runtime";function lt({...e}){return R(L.Root,{"data-slot":"select",...e})}function Ya({className:e,...t}){return R(L.Group,{"data-slot":"select-group",className:re("scroll-my-1 p-1",e),...t})}function dt({...e}){return R(L.Value,{"data-slot":"select-value",...e})}function ct({className:e,size:t="default",children:a,...o}){return Gt(L.Trigger,{"data-slot":"select-trigger","data-size":t,className:re("flex w-fit items-center justify-between gap-1.5 rounded-lg border border-input bg-transparent py-2 pr-2 pl-2.5 text-sm whitespace-nowrap transition-colors outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-placeholder:text-muted-foreground data-[size=default]:h-8 data-[size=sm]:h-7 data-[size=sm]:rounded-[min(var(--radius-md),10px)] *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-1.5 dark:bg-input/30 dark:hover:bg-input/50 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...o,children:[a,R(L.Icon,{asChild:!0,children:R(Ja,{className:"pointer-events-none size-4 text-muted-foreground"})})]})}function pt({className:e,children:t,position:a="item-aligned",align:o="center",...r}){return R(L.Portal,{children:Gt(L.Content,{"data-slot":"select-content","data-align-trigger":a==="item-aligned",className:re("relative z-50 max-h-(--radix-select-content-available-height) min-w-36 origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 data-[align-trigger=true]:animate-none data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",a==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:a,align:o,...r,children:[R(jr,{}),R(L.Viewport,{"data-position":a,className:re("data-[position=popper]:h-(--radix-select-trigger-height) data-[position=popper]:w-full data-[position=popper]:min-w-(--radix-select-trigger-width)",a==="popper"&&""),children:t}),R(Qr,{})]})})}function Oe({className:e,children:t,...a}){return Gt(L.Item,{"data-slot":"select-item",className:re("relative flex w-full cursor-default items-center gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",e),...a,children:[R("span",{className:"pointer-events-none absolute right-2 flex size-4 items-center justify-center",children:R(L.ItemIndicator,{children:R(Jr,{className:"pointer-events-none"})})}),R(L.ItemText,{children:t})]})}function jr({className:e,...t}){return R(L.ScrollUpButton,{"data-slot":"select-scroll-up-button",className:re("z-10 flex cursor-default items-center justify-center bg-popover py-1 [&_svg:not([class*='size-'])]:size-4",e),...t,children:R(Yr,{})})}function Qr({className:e,...t}){return R(L.ScrollDownButton,{"data-slot":"select-scroll-down-button",className:re("z-10 flex cursor-default items-center justify-center bg-popover py-1 [&_svg:not([class*='size-'])]:size-4",e),...t,children:R(Ja,{})})}import{cn as en}from"cn";import{Loader2Icon as tn}from"lucide-react";import{jsx as an}from"react/jsx-runtime";function Y({className:e,...t}){return an(tn,{"data-slot":"spinner",role:"status","aria-label":"Loading",className:en("size-4 animate-spin",e),...t})}import{cn as on}from"cn";import{jsx as rn}from"react/jsx-runtime";function ja({className:e,...t}){return rn("textarea",{"data-slot":"textarea",className:on("flex field-sizing-content min-h-16 w-full rounded-lg border border-input bg-transparent px-2.5 py-2 text-base transition-colors outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40",e),...t})}import{cn as bn}from"cn";import{Fragment as yn,jsx as d,jsxs as h}from"react/jsx-runtime";var vn=["介绍一下这个应用现在能做什么","帮我梳理接下来可以加哪些功能"],xn="例如:帮我把当前页面的数据按状态汇总一下",ao=e=>Tt.find(t=>t.id===e)?.name??e;function Vt({suggestions:e}){let{open:t,setOpen:a,page:o}=zt(),[r,i]=ne(),[s,n]=ne([]),[l,c]=ne(""),[f,k]=ne("default"),[w,S]=ne(!0),[C,v]=ne(""),P=Ot(null),g=Ot(null),y=Ot(null),q=s.some(m=>m.running),Pt=!!o&&(!!o.table||o.records.length>0),Qe=()=>v("");Ft(()=>{!t||r||va()?.getNotebook().then(m=>i({notebookId:m.notebookId,name:m.name})).catch(()=>{})},[t,r]);let kt=o?`${o.table?.id}:${o.records.map(m=>m.id).join(",")}`:"",[mr,ur]=ne(kt);kt!==mr&&(ur(kt),S(!0)),Ft(()=>{y.current?.scrollIntoView({block:"end"})},[s]),Ft(()=>()=>P.current?.abort(),[]);let et=(m,Le)=>n(tt=>tt.map(W=>W.id===m?{...W,...Le}:W)),aa=async(m=l)=>{let Le=m.trim();if(!Le||q)return;let tt=w&&Pt?o:null,W=crypto.randomUUID(),St=C;n(F=>[...F,{id:W,input:Le,context:tt,modelId:f,running:!0,followUp:!!St}]),c("");let Rt=new AbortController;P.current=Rt,g.current=null;try{let F=await ba(Na(Le,St?null:tt,r),f,{signal:Rt.signal,sessionId:St||void 0,onUpdate:at=>{g.current=at.messageId,at.sessionId&&v(at.sessionId),et(W,{task:at})}});F.sessionId&&v(F.sessionId),et(W,{task:F,running:!1,error:F.stopReason==="end_turn"?void 0:`任务异常结束(${F.stopReason})`}),window.dispatchEvent(new Event(ya));let oa=await ga(F.messageId);oa&&et(W,{shareUrl:oa})}catch(F){et(W,{running:!1,error:ra(F)?"已停止":na(F)})}finally{P.current===Rt&&(P.current=null)}},fr=()=>{let m=g.current;P.current?.abort(),m&&fa(m).catch(()=>{})},gr=e?.items??[],br=(o?gr.find(m=>o.source.endsWith(m.match))?.items:void 0)??e?.fallback??vn;return h("aside",{"aria-label":"LinkFox OS 助手",className:bn("z-40 flex flex-col border-l bg-background","fixed inset-0 md:sticky md:top-0 md:h-svh md:w-1/4 md:min-w-90 md:shrink-0 md:self-start",!t&&"hidden"),children:[h("header",{className:"flex h-14 shrink-0 items-center gap-2 border-b px-3",children:[d(eo,{className:"size-4 text-primary"}),d("span",{className:"font-medium",children:"LinkFox OS"}),h(lt,{value:f,onValueChange:m=>{k(m),Qe()},disabled:q,children:[d(ct,{size:"sm",className:"ml-auto w-32","aria-label":"选择 Agent",children:d(dt,{})}),d(pt,{align:"end",children:Tt.map(m=>d(Oe,{value:m.id,children:m.name},m.id))})]}),d(p,{variant:"ghost",size:"icon-sm","aria-label":"开新对话(不保留上下文)",title:"开新对话:下一条消息不再续接当前会话",disabled:q||!C,onClick:Qe,children:d(Qa,{})}),d(p,{variant:"ghost",size:"icon-sm","aria-label":"清空对话",disabled:q||!s.length,onClick:()=>{n([]),Qe()},children:d(fn,{})}),d(p,{variant:"ghost",size:"icon-sm","aria-label":"关闭助手",onClick:()=>a(!1),children:d(to,{})})]}),h("div",{className:"min-h-0 flex-1 overflow-y-auto overscroll-contain px-3 py-3",children:[s.length===0?h("div",{className:"flex flex-col gap-3 py-6 text-sm text-muted-foreground",children:[h("div",{className:"flex items-center gap-2 text-foreground",children:[d(nn,{className:"size-5"}),d("span",{className:"font-medium",children:"让 LinkFox 帮你干活"})]}),d("p",{children:"描述你要完成的事,LinkFox OS 会自己调用选品、数据查询、生图、多维表等技能去执行。勾选的记录会自动带上。"}),d("div",{className:"flex flex-col gap-2",children:br.map(m=>d("button",{type:"button",className:"rounded-lg border px-3 py-2 text-left text-foreground transition-colors hover:bg-muted",onClick:()=>c(m),children:m},m))})]}):d("div",{className:"flex flex-col gap-4",children:s.map(m=>d(Cn,{item:m,notebook:r},m.id))}),d("div",{ref:y})]}),h("div",{className:"shrink-0 border-t p-3",children:[C?h("div",{className:"mb-2 flex items-center gap-2 text-xs text-muted-foreground",children:[d(Qa,{className:"size-3.5 shrink-0"}),h("span",{className:"min-w-0 flex-1",children:["接着上一轮聊(",ao(f)," 记得前面的内容,可以直接追问)"]}),d("button",{type:"button",className:"shrink-0 text-primary underline-offset-2 hover:underline",onClick:Qe,children:"开新对话"})]}):h(yn,{children:[Pt&&w&&o&&d(hn,{context:o,notebook:r,onRemove:()=>S(!1)}),Pt&&!w&&d("button",{type:"button",className:"mb-2 text-xs text-primary underline-offset-2 hover:underline",onClick:()=>S(!0),children:"重新带入当前页面的数据表和勾选记录"})]}),h("div",{className:"flex items-end gap-2",children:[d(ja,{value:l,onChange:m=>c(m.target.value),onKeyDown:m=>{m.key==="Enter"&&!m.shiftKey&&!m.nativeEvent.isComposing&&(m.preventDefault(),aa())},placeholder:C?"接着问,例如:把第 3 条展开说说 / 换个角度再看一遍":e?.placeholder??xn,"aria-label":"告诉 LinkFox 要做什么",className:"max-h-40 min-h-16 resize-none"}),q?d(p,{size:"icon",variant:"outline","aria-label":"停止",onClick:fr,children:d(mn,{})}):d(p,{size:"icon","aria-label":"发送",disabled:!l.trim(),onClick:()=>aa(),children:d(pn,{})})]}),d("p",{className:"mt-2 text-xs text-muted-foreground",children:"执行会消耗 LinkFox 算力。Enter 发送,Shift+Enter 换行。"})]})]})}function hn({context:e,notebook:t,onRemove:a}){let o=e.records.length;return h(ge,{className:"mb-2 rounded-lg border bg-muted/40 text-xs",children:[h("div",{className:"flex items-center gap-2 px-2.5 py-2",children:[d(un,{className:"size-3.5 shrink-0 text-muted-foreground"}),h("div",{className:"min-w-0 flex-1",children:[e.table&&h("div",{className:"truncate",children:[t?`${t.name} / `:"",e.table.name]}),d("div",{className:"text-muted-foreground",children:o?`已勾选 ${o} 条记录,将一并发送`:`当前页面:${e.source}`})]}),o>0&&d(be,{asChild:!0,children:d(p,{variant:"ghost",size:"icon-xs","aria-label":"查看勾选记录",className:"[&[data-state=open]>svg]:rotate-180",children:d(ln,{})})}),d(p,{variant:"ghost",size:"icon-xs","aria-label":"不带入上下文",onClick:a,children:d(to,{})})]}),o>0&&d(ve,{children:d("ul",{className:"max-h-32 overflow-y-auto border-t px-2.5 py-1.5",children:e.records.map(r=>d("li",{className:"truncate py-0.5",title:r.label,children:r.label},r.id))})})]})}function Cn({item:e,notebook:t}){let{task:a,context:o}=e,r=a?.steps??[];return h("div",{className:"flex flex-col gap-2",children:[h("div",{className:"ml-6 self-end rounded-lg bg-primary px-3 py-2 text-sm whitespace-pre-wrap text-primary-foreground",children:[e.input,o&&h("div",{className:"mt-1.5 border-t border-primary-foreground/20 pt-1.5 text-xs opacity-80",children:[o.table?`${t?`${t.name} / `:""}${o.table.name}`:o.source,o.records.length?` · 勾选 ${o.records.length} 条`:""]})]}),h("div",{className:"mr-2 flex flex-col gap-2 rounded-lg border px-3 py-2",children:[h("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[d("span",{children:ao(e.modelId)}),e.followUp&&d("span",{className:"rounded bg-muted px-1.5 py-0.5",children:"接上一轮"})]}),r.length>0&&d("ul",{className:"flex flex-col gap-1 text-xs",children:r.map(i=>h("li",{className:"flex items-center gap-1.5",children:[i.status==="running"?d(Y,{className:"size-3"}):i.status==="failed"?d(gn,{className:"size-3 text-destructive"}):d(sn,{className:"size-3 text-emerald-600"}),d("span",{className:"truncate",children:i.status==="running"?`正在调用 ${i.title}`:i.title})]},i.id))}),a?.text?d(_t,{children:a.text}):e.running&&h("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[d(Y,{})," ",a?"LinkFox 正在处理…":"正在提交任务…"]}),a&&a.files.length>0&&d("ul",{className:"flex flex-col gap-1",children:a.files.map(i=>d("li",{children:h("a",{href:i.uri,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 text-xs text-primary underline-offset-2 hover:underline",children:[d(cn,{className:"size-3.5 shrink-0"}),d("span",{className:"truncate",children:i.name})]})},i.uri))}),e.error&&d("div",{className:"text-sm text-destructive",children:e.error}),e.shareUrl&&h("a",{href:e.shareUrl,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 self-start text-xs text-muted-foreground underline-offset-2 hover:text-foreground hover:underline",children:["查看完整过程 ",d(dn,{className:"size-3"})]})]})]})}function $t(){let{open:e,setOpen:t}=zt();return h(p,{variant:e?"secondary":"default",size:"sm",onClick:()=>t(a=>!a),"aria-expanded":e,"aria-label":"让LinkFox帮你干活",children:[d(eo,{}),d("span",{className:"hidden sm:inline",children:"让LinkFox帮你干活"})]})}import{useMemo as Rn,useState as Tn}from"react";import{CheckIcon as go,GlobeIcon as In}from"lucide-react";import{Command as we}from"cmdk";import{cn as Ne}from"cn";import{cva as oo}from"class-variance-authority";import{cn as Ve}from"cn";import{jsx as $e}from"react/jsx-runtime";function Ce({className:e,...t}){return $e("div",{"data-slot":"input-group",role:"group",className:Ve("group/input-group relative flex h-8 w-full min-w-0 items-center rounded-lg border border-input transition-colors outline-none in-data-[slot=combobox-content]:focus-within:border-inherit in-data-[slot=combobox-content]:focus-within:ring-0 has-disabled:bg-input/50 has-disabled:opacity-50 has-[[data-slot=input-group-control]:focus-visible]:border-ring has-[[data-slot=input-group-control]:focus-visible]:ring-3 has-[[data-slot=input-group-control]:focus-visible]:ring-ring/50 has-[[data-slot][aria-invalid=true]]:border-destructive has-[[data-slot][aria-invalid=true]]:ring-3 has-[[data-slot][aria-invalid=true]]:ring-destructive/20 has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>textarea]:h-auto dark:bg-input/30 dark:has-disabled:bg-input/80 dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40 has-[>[data-align=block-end]]:[&>input]:pt-3 has-[>[data-align=block-start]]:[&>input]:pb-3 has-[>[data-align=inline-end]]:[&>input]:pr-1.5 has-[>[data-align=inline-start]]:[&>input]:pl-1.5",e),...t})}var wn=oo("flex h-auto cursor-text items-center justify-center gap-2 py-1.5 text-sm font-medium text-muted-foreground select-none group-data-[disabled=true]/input-group:opacity-50 [&>kbd]:rounded-[calc(var(--radius)-5px)] [&>svg:not([class*='size-'])]:size-4",{variants:{align:{"inline-start":"order-first pl-2 has-[>button]:ml-[-0.3rem] has-[>kbd]:ml-[-0.15rem]","inline-end":"order-last pr-2 has-[>button]:mr-[-0.3rem] has-[>kbd]:mr-[-0.15rem]","block-start":"order-first w-full justify-start px-2.5 pt-2 group-has-[>input]/input-group:pt-2 [.border-b]:pb-2","block-end":"order-last w-full justify-start px-2.5 pb-2 group-has-[>input]/input-group:pb-2 [.border-t]:pt-2"}},defaultVariants:{align:"inline-start"}});function ye({className:e,align:t="inline-start",...a}){return $e("div",{role:"group","data-slot":"input-group-addon","data-align":t,className:Ve(wn({align:t}),e),onClick:o=>{o.target.closest("button")||o.currentTarget.parentElement?.querySelector("input")?.focus()},...a})}var Nn=oo("flex items-center gap-2 text-sm shadow-none",{variants:{size:{xs:"h-6 gap-1 rounded-[calc(var(--radius)-3px)] px-1.5 [&>svg:not([class*='size-'])]:size-3.5",sm:"","icon-xs":"size-6 rounded-[calc(var(--radius)-3px)] p-0 has-[>svg]:p-0","icon-sm":"size-8 p-0 has-[>svg]:p-0"}},defaultVariants:{size:"xs"}});function ro({className:e,type:t="button",variant:a="ghost",size:o="xs",...r}){return $e(p,{type:t,"data-size":o,variant:a,className:Ve(Nn({size:o}),e),...r})}function no({className:e,...t}){return $e("span",{className:Ve("flex items-center gap-2 text-sm text-muted-foreground [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4",e),...t})}function mt({className:e,...t}){return $e(te,{"data-slot":"input-group-control",className:Ve("flex-1 rounded-none border-0 bg-transparent shadow-none ring-0 focus-visible:ring-0 disabled:bg-transparent aria-invalid:ring-0 dark:bg-transparent dark:disabled:bg-transparent",e),...t})}import{SearchIcon as Pn,CheckIcon as kn}from"lucide-react";import{jsx as X,jsxs as po}from"react/jsx-runtime";function io({className:e,...t}){return X(we,{"data-slot":"command",className:Ne("flex size-full flex-col overflow-hidden rounded-xl! bg-popover p-1 text-popover-foreground",e),...t})}function so({className:e,...t}){return X("div",{"data-slot":"command-input-wrapper",className:"p-1 pb-0",children:po(Ce,{className:"h-8! rounded-lg! border-input/30 bg-input/30 shadow-none! *:data-[slot=input-group-addon]:pl-2!",children:[X(we.Input,{"data-slot":"command-input",className:Ne("w-full text-sm outline-hidden disabled:cursor-not-allowed disabled:opacity-50",e),...t}),X(ye,{children:X(Pn,{className:"size-4 shrink-0 opacity-50"})})]})})}function lo({className:e,...t}){return X(we.List,{"data-slot":"command-list",className:Ne("no-scrollbar max-h-72 scroll-py-1 overflow-x-hidden overflow-y-auto outline-none",e),...t})}function co({className:e,...t}){return X(we.Empty,{"data-slot":"command-empty",className:Ne("py-6 text-center text-sm",e),...t})}function ut({className:e,...t}){return X(we.Group,{"data-slot":"command-group",className:Ne("overflow-hidden p-1 text-foreground **:[[cmdk-group-heading]]:px-2 **:[[cmdk-group-heading]]:py-1.5 **:[[cmdk-group-heading]]:text-xs **:[[cmdk-group-heading]]:font-medium **:[[cmdk-group-heading]]:text-muted-foreground",e),...t})}function Ht({className:e,children:t,...a}){return po(we.Item,{"data-slot":"command-item",className:Ne("group/command-item relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none in-data-[slot=dialog-content]:rounded-lg! data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 data-selected:bg-muted data-selected:text-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 data-selected:*:[svg]:text-foreground",e),...a,children:[t,X(kn,{className:"ml-auto opacity-0 group-has-data-[slot=command-shortcut]/command-item:hidden group-data-[checked=true]/command-item:opacity-100"})]})}import{cn as Sn}from"cn";import{Popover as ft}from"radix-ui";import{jsx as gt}from"react/jsx-runtime";function mo({...e}){return gt(ft.Root,{"data-slot":"popover",...e})}function uo({...e}){return gt(ft.Trigger,{"data-slot":"popover-trigger",...e})}function fo({className:e,align:t="center",sideOffset:a=4,...o}){return gt(ft.Portal,{children:gt(ft.Content,{"data-slot":"popover-content",align:t,sideOffset:a,className:Sn("z-50 flex w-72 origin-(--radix-popover-content-transform-origin) flex-col gap-2.5 rounded-lg bg-popover p-2.5 text-sm text-popover-foreground shadow-md ring-1 ring-foreground/10 outline-hidden duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",e),...o})})}import{cn as bo}from"cn";import{jsx as B,jsxs as ie}from"react/jsx-runtime";var Kt=["Asia/Shanghai","America/Los_Angeles","America/New_York","Europe/London","Europe/Berlin","Asia/Tokyo","UTC"];function zn(){try{return Intl.supportedValuesOf("timeZone")}catch{return Kt}}function Ut(){let[e,t]=Tn(!1),a=ha(),o=Ca(),r=Rn(()=>e?zn().filter(n=>!Kt.includes(n)).map(n=>({zone:n,offset:rt(n)})):[],[e]),i=n=>{xa(n),t(!1)},s=(n,l=rt(n))=>ie(Ht,{value:`${n} ${l}`,onSelect:()=>i(n),children:[B(go,{className:bo(!o&&n===a?"opacity-100":"opacity-0")}),B("span",{className:"truncate",children:n}),B("span",{className:"ml-auto text-xs text-muted-foreground",children:l})]},n);return ie(mo,{open:e,onOpenChange:t,children:[B(uo,{asChild:!0,children:ie(p,{variant:"outline",size:"sm","aria-label":"选择时区",children:[B(In,{"data-icon":"inline-start"}),B("span",{className:"hidden max-w-40 truncate sm:inline",children:a}),B("span",{className:"text-muted-foreground",children:rt(a)})]})}),B(fo,{align:"end",className:"w-80 p-0",children:ie(io,{children:[B(so,{placeholder:"搜索时区,如 Shanghai、UTC+08"}),ie(lo,{children:[B(co,{children:"没有匹配的时区"}),B(ut,{heading:"默认",children:ie(Ht,{value:`跟随浏览器 ${It()}`,onSelect:()=>i(null),children:[B(go,{className:bo(o?"opacity-100":"opacity-0")}),ie("span",{className:"truncate",children:["跟随浏览器(",It(),")"]})]})}),B(ut,{heading:"常用",children:Kt.map(n=>s(n))}),B(ut,{heading:"全部",children:r.map(n=>s(n.zone,n.offset))})]})]})})]})}import{LogOutIcon as Mn,UserIcon as Bn}from"lucide-react";import{cn as He}from"cn";import{DropdownMenu as H}from"radix-ui";import{CheckIcon as Dn,ChevronRightIcon as Wl}from"lucide-react";import{jsx as O,jsxs as An}from"react/jsx-runtime";function Pe({...e}){return O(H.Root,{"data-slot":"dropdown-menu",...e})}function ke({...e}){return O(H.Trigger,{"data-slot":"dropdown-menu-trigger",...e})}function Se({className:e,align:t="start",sideOffset:a=4,...o}){return O(H.Portal,{children:O(H.Content,{"data-slot":"dropdown-menu-content",sideOffset:a,align:t,className:He("z-50 max-h-(--radix-dropdown-menu-content-available-height) w-(--radix-dropdown-menu-trigger-width) min-w-32 origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover p-1 text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:overflow-hidden data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",e),...o})})}function Ke({...e}){return O(H.Group,{"data-slot":"dropdown-menu-group",...e})}function se({className:e,inset:t,variant:a="default",...o}){return O(H.Item,{"data-slot":"dropdown-menu-item","data-inset":t,"data-variant":a,className:He("group/dropdown-menu-item relative flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-inset:pl-7 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 data-[variant=destructive]:*:[svg]:text-destructive",e),...o})}function vo({className:e,children:t,checked:a,inset:o,...r}){return An(H.CheckboxItem,{"data-slot":"dropdown-menu-checkbox-item","data-inset":o,className:He("relative flex cursor-default items-center gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground focus:**:text-accent-foreground data-inset:pl-7 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),checked:a,...r,children:[O("span",{className:"pointer-events-none absolute right-2 flex items-center justify-center","data-slot":"dropdown-menu-checkbox-item-indicator",children:O(H.ItemIndicator,{children:O(Dn,{})})}),t]})}function Ue({className:e,inset:t,...a}){return O(H.Label,{"data-slot":"dropdown-menu-label","data-inset":t,className:He("px-1.5 py-1 text-xs font-medium text-muted-foreground data-inset:pl-7",e),...a})}function bt({className:e,...t}){return O(H.Separator,{"data-slot":"dropdown-menu-separator",className:He("-mx-1 my-1 h-px bg-border",e),...t})}import{Fragment as Ln,jsx as Re,jsxs as Ze}from"react/jsx-runtime";function Zt(){let e=ot();return e.status!=="ready"?null:Ze(Pe,{children:[Re(ke,{asChild:!0,children:Re(p,{variant:"ghost",size:"icon","aria-label":"账号",children:Re(Bn,{})})}),Ze(Se,{align:"end",children:[Re(Ue,{children:e.userName||"LinkFox 用户"}),e.apiKey&&Ze(Ue,{className:"font-normal text-muted-foreground",children:["API Key:",ua(e.apiKey)]}),!e.apiKey&&Ze(Ln,{children:[Re(bt,{}),Ze(se,{onSelect:ma,children:[Re(Mn,{}),"退出登录"]})]})]})]})}import{cn as Te}from"cn";import{Slot as En}from"radix-ui";import{ChevronRightIcon as _n,MoreHorizontalIcon as id}from"lucide-react";import{jsx as le,jsxs as ld}from"react/jsx-runtime";function xo({className:e,...t}){return le("nav",{"aria-label":"breadcrumb","data-slot":"breadcrumb",className:Te(e),...t})}function ho({className:e,...t}){return le("ol",{"data-slot":"breadcrumb-list",className:Te("flex flex-wrap items-center gap-1.5 text-sm wrap-break-word text-muted-foreground",e),...t})}function qt({className:e,...t}){return le("li",{"data-slot":"breadcrumb-item",className:Te("inline-flex items-center gap-1",e),...t})}function Co({asChild:e,className:t,...a}){let o=e?En.Root:"a";return le(o,{"data-slot":"breadcrumb-link",className:Te("transition-colors hover:text-foreground",t),...a})}function yo({className:e,...t}){return le("span",{"data-slot":"breadcrumb-page",role:"link","aria-disabled":"true","aria-current":"page",className:Te("font-normal text-foreground",e),...t})}function wo({children:e,className:t,...a}){return le("li",{"data-slot":"breadcrumb-separator",role:"presentation","aria-hidden":"true",className:Te("[&>svg]:size-3.5",t),...a,children:e??le(_n,{})})}import{jsx as T,jsxs as qe}from"react/jsx-runtime";function Vn({children:e,nav:t,appName:a,appSubtitle:o,version:r,suggestions:i}){let s=On(),n=Ee(t,s),l=n?[...new Set([n.group.title,n.item.title])]:[];return T(wa,{children:qe(Fa,{children:[T(Et,{nav:t,appName:a,appSubtitle:o,version:r}),qe(Ha,{className:"min-w-0",children:[qe("header",{className:"sticky top-0 z-10 flex h-14 shrink-0 items-center gap-2 border-b bg-background px-4",children:[T(Va,{className:"-ml-1"}),T(Ra,{orientation:"vertical",className:"mr-2 data-[orientation=vertical]:h-4"}),T(xo,{className:"min-w-0 flex-1",children:qe(ho,{children:[T(qt,{className:"hidden md:inline-flex",children:T(Co,{asChild:!0,children:T(Fn,{href:"/",children:"首页"})})}),l.map((c,f)=>qe(Gn,{children:[T(wo,{className:f===0?"hidden md:block":void 0}),T(qt,{className:f<l.length-1?"hidden md:inline-flex":void 0,children:f===l.length-1?T(yo,{children:c}):T("span",{children:c})})]},c))]})}),T($t,{}),T(Ut,{}),T(Zt,{})]}),T("main",{className:"flex min-w-0 flex-1 flex-col gap-4 p-4",children:e})]}),T(Vt,{suggestions:i})]})})}import{useEffect as Kn}from"react";import{CircleAlertIcon as Un,LogInIcon as Io,RotateCwIcon as Zn}from"lucide-react";import{cva as $n}from"class-variance-authority";import{cn as Ie}from"cn";import{jsx as ze}from"react/jsx-runtime";function No({className:e,...t}){return ze("div",{"data-slot":"empty",className:Ie("flex w-full min-w-0 flex-1 flex-col items-center justify-center gap-4 rounded-xl border-dashed p-6 text-center text-balance",e),...t})}function Po({className:e,...t}){return ze("div",{"data-slot":"empty-header",className:Ie("flex max-w-sm flex-col items-center gap-2",e),...t})}var Hn=$n("mb-2 flex shrink-0 items-center justify-center [&_svg]:pointer-events-none [&_svg]:shrink-0",{variants:{variant:{default:"bg-transparent",icon:"flex size-8 shrink-0 items-center justify-center rounded-lg bg-muted text-foreground [&_svg:not([class*='size-'])]:size-4"}},defaultVariants:{variant:"default"}});function ko({className:e,variant:t="default",...a}){return ze("div",{"data-slot":"empty-icon","data-variant":t,className:Ie(Hn({variant:t,className:e})),...a})}function So({className:e,...t}){return ze("div",{"data-slot":"empty-title",className:Ie("font-heading text-sm font-medium tracking-tight",e),...t})}function Ro({className:e,...t}){return ze("div",{"data-slot":"empty-description",className:Ie("text-sm/relaxed text-muted-foreground [&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary",e),...t})}function To({className:e,...t}){return ze("div",{"data-slot":"empty-content",className:Ie("flex w-full max-w-sm min-w-0 flex-col items-center gap-2.5 text-sm text-balance",e),...t})}import{jsx as G,jsxs as vt}from"react/jsx-runtime";function qn({children:e}){let t=ot();if(Kn(()=>{da()},[]),t.status==="ready")return e;if(t.status==="loading"||t.status==="callback")return vt("div",{className:"flex min-h-svh items-center justify-center gap-2",role:"status",children:[G(Y,{}),G("span",{children:t.status==="callback"?"正在完成登录…":"正在准备登录…"})]});let a=t.status==="error",o=t.status==="redirecting";return G("div",{className:"flex min-h-svh items-center justify-center bg-muted p-4",children:vt(No,{className:"max-w-md bg-background",children:[vt(Po,{children:[G(ko,{variant:"icon",children:a?G(Un,{}):G(Io,{})}),G(So,{children:a?"无法进入选品工作台":"登录 LinkFox"}),G(Ro,{children:a?t.message:"使用 LinkFox 账号登录,登录状态将在此浏览器中保留至到期或退出。"})]}),G(To,{children:vt(p,{disabled:o,onClick:a&&t.action==="config"?()=>{ca()}:()=>{pa()},children:[o?G(Y,{"data-icon":"inline-start"}):a?G(Zn,{"data-icon":"inline-start"}):G(Io,{"data-icon":"inline-start"}),o?"正在跳转…":a?"重试":"登录 LinkFox"]})})]})})}import*as zo from"react";import{ThemeProvider as Wn,useTheme as Xn}from"next-themes";import{jsx as Qn,jsxs as ei}from"react/jsx-runtime";function Jn({children:e,...t}){return ei(Wn,{attribute:"class",defaultTheme:"system",enableSystem:!0,disableTransitionOnChange:!0,...t,children:[Qn(jn,{}),e]})}function Yn(e){return e instanceof HTMLElement?e.isContentEditable||e.tagName==="INPUT"||e.tagName==="TEXTAREA"||e.tagName==="SELECT":!1}function jn(){let{resolvedTheme:e,setTheme:t}=Xn();return zo.useEffect(()=>{function a(o){o.defaultPrevented||o.repeat||o.metaKey||o.ctrlKey||o.altKey||o.key.toLowerCase()==="d"&&(Yn(o.target)||t(e==="dark"?"light":"dark"))}return window.addEventListener("keydown",a),()=>{window.removeEventListener("keydown",a)}},[e,t]),null}import{cn as ti}from"cn";import{Checkbox as Do}from"radix-ui";import{CheckIcon as ai}from"lucide-react";import{jsx as Wt}from"react/jsx-runtime";function de({className:e,...t}){return Wt(Do.Root,{"data-slot":"checkbox",className:ti("peer relative flex size-4 shrink-0 items-center justify-center rounded-[4px] border border-input transition-colors outline-none group-has-disabled/field:opacity-50 group-has-[:focus-visible]/field-label:ring-0 group-has-[:focus-visible]/field-label:not-data-checked:border-input after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 aria-invalid:aria-checked:border-primary dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:border-primary data-checked:bg-primary data-checked:text-primary-foreground group-has-[:focus-visible]/field-label:data-checked:border-primary dark:data-checked:bg-primary",e),...t,children:Wt(Do.Indicator,{"data-slot":"checkbox-indicator",className:"grid place-content-center text-current transition-none [&>svg]:size-3.5",children:Wt(ai,{})})})}import{cn as De}from"cn";import{jsx as ce}from"react/jsx-runtime";function Ao({className:e,...t}){return ce("div",{"data-slot":"table-container",className:"relative w-full overflow-x-auto",children:ce("table",{"data-slot":"table",className:De("w-full caption-bottom text-sm",e),...t})})}function Mo({className:e,...t}){return ce("thead",{"data-slot":"table-header",className:De("[&_tr]:border-b",e),...t})}function Bo({className:e,...t}){return ce("tbody",{"data-slot":"table-body",className:De("[&_tr:last-child]:border-0",e),...t})}function We({className:e,...t}){return ce("tr",{"data-slot":"table-row",className:De("border-b transition-colors hover:bg-muted/50 has-aria-expanded:bg-muted/50 data-[state=selected]:bg-muted",e),...t})}function xt({className:e,...t}){return ce("th",{"data-slot":"table-head",className:De("h-10 px-2 text-left align-middle font-medium text-foreground [&:has([role=checkbox])]:pr-0",e),...t})}function Ae({className:e,...t}){return ce("td",{"data-slot":"table-cell",className:De("p-2 align-middle break-words [&:has([role=checkbox])]:pr-0",e),...t})}import{cn as ht}from"cn";import{jsx as z,jsxs as Ct}from"react/jsx-runtime";var Lo=56,Eo=120;function oi({columns:e,rows:t,rowKey:a,renderCell:o,actions:r,actionsWidth:i=200,selection:s,onRowClick:n,loading:l,skeletonRows:c=8,empty:f,className:k}){let w=e.length+(s?1:0)+(r?1:0),C={"--dt-min-width":`${e.reduce((v,P)=>v+(P.width??Eo),0)+(s?Lo:0)+(r?i:0)}px`};return Ct(Ao,{style:C,className:ht("lg:[min-width:var(--dt-min-width)] max-lg:block",k),children:[z(Mo,{className:"max-lg:hidden",children:Ct(We,{children:[s&&z(xt,{style:{width:Lo},className:"lg:sticky lg:left-0 lg:z-20 lg:bg-card",children:z(de,{"aria-label":"全选本页",checked:s.pageAllSelected?!0:s.pageSomeSelected?"indeterminate":!1,disabled:!t.length,onCheckedChange:v=>s.onToggleAll(v===!0)})}),e.map(v=>z(xt,{style:{width:v.width??Eo},className:"break-words",children:v.label},v.key)),r&&z(xt,{style:{width:i},className:"text-right lg:sticky lg:right-0 lg:z-20 lg:border-l lg:bg-card",children:"操作"})]})}),Ct(Bo,{className:"max-lg:block",children:[l&&t.length===0?Array.from({length:c},(v,P)=>z(We,{className:"max-lg:block max-lg:border-0",children:z(Ae,{colSpan:w,className:"max-lg:block",children:z(Ma,{className:"h-10 w-full"})})},P)):t.map(v=>{let P=a(v);return Ct(We,{"data-state":s?.selected.has(P)?"selected":void 0,onClick:n?()=>n(v):void 0,className:ht("group/row",l&&"opacity-60",n&&"cursor-pointer","max-lg:mb-3 max-lg:block max-lg:rounded-lg max-lg:border max-lg:p-3"),children:[s&&z(Ae,{className:"max-lg:flex max-lg:items-center max-lg:border-0 max-lg:px-0 max-lg:py-1 lg:sticky lg:left-0 lg:z-10 lg:bg-card lg:group-hover/row:bg-muted",children:z(de,{"aria-label":"选择本行",checked:s.selected.has(P),onCheckedChange:g=>s.onToggleRow(v,g===!0),onClick:g=>g.stopPropagation()})}),e.map(g=>z(Ae,{"data-label":g.label,className:ht("align-top break-words","max-lg:flex max-lg:gap-3 max-lg:border-0 max-lg:px-0 max-lg:py-1","max-lg:before:w-24 max-lg:before:shrink-0 max-lg:before:text-xs max-lg:before:text-muted-foreground","max-lg:before:content-[attr(data-label)]"),children:z("div",{className:"min-w-0 flex-1",children:o(v,g)})},g.key)),r&&z(Ae,{className:ht("align-top text-right max-lg:flex max-lg:justify-end max-lg:border-0 max-lg:px-0 max-lg:py-1","lg:sticky lg:right-0 lg:z-10 lg:border-l lg:bg-card lg:group-hover/row:bg-muted"),children:z("div",{className:"flex justify-end gap-1",onClick:g=>g.stopPropagation(),children:r(v)})})]},P)}),!l&&t.length===0&&f?z(We,{className:"max-lg:block max-lg:border-0 hover:bg-transparent",children:z(Ae,{colSpan:w,className:"whitespace-normal max-lg:block",children:f})}):null]})]})}import{cn as Me}from"cn";import{ChevronLeftIcon as ri,ChevronRightIcon as ni,MoreHorizontalIcon as ii}from"lucide-react";import{jsx as V,jsxs as Xt}from"react/jsx-runtime";function _o({className:e,...t}){return V("nav",{role:"navigation","aria-label":"pagination","data-slot":"pagination",className:Me("mx-auto flex w-full justify-center",e),...t})}function Go({className:e,...t}){return V("ul",{"data-slot":"pagination-content",className:Me("flex items-center gap-0.5",e),...t})}function Xe({...e}){return V("li",{"data-slot":"pagination-item",...e})}function yt({className:e,isActive:t,size:a="icon",...o}){return V(p,{asChild:!0,variant:t?"outline":"ghost",size:a,className:Me(e),children:V("a",{"aria-current":t?"page":void 0,"data-slot":"pagination-link","data-active":t,...o})})}function Fo({className:e,text:t="Previous",...a}){return Xt(yt,{"aria-label":"Go to previous page",size:"default",className:Me("pl-1.5!",e),...a,children:[V(ri,{"data-icon":"inline-start"}),V("span",{className:"hidden sm:block",children:t})]})}function Oo({className:e,text:t="Next",...a}){return Xt(yt,{"aria-label":"Go to next page",size:"default",className:Me("pr-1.5!",e),...a,children:[V("span",{className:"hidden sm:block",children:t}),V(ni,{"data-icon":"inline-end"})]})}function Vo({className:e,...t}){return Xt("span",{"aria-hidden":!0,"data-slot":"pagination-ellipsis",className:Me("flex size-8 items-center justify-center [&_svg:not([class*='size-'])]:size-4",e),...t,children:[V(ii,{}),V("span",{className:"sr-only",children:"More pages"})]})}import{cn as $o}from"cn";import{jsx as K,jsxs as Jt}from"react/jsx-runtime";var Ho=20;function si(e,t){if(t<=7)return Array.from({length:t},(i,s)=>s+1);let a=[1],o=Math.max(2,e-1),r=Math.min(t-1,e+1);o>2&&a.push("…");for(let i=o;i<=r;i++)a.push(i);return r<t-1&&a.push("…"),a.push(t),a}function li({page:e,total:t,disabled:a,onChange:o,pageSize:r=Ho,note:i}){let s=Math.max(1,Math.ceil(t/r)),n=c=>f=>{f.preventDefault(),!(a||c<1||c>s||c===e)&&o(c)},l=c=>$o(c&&"pointer-events-none opacity-50");return Jt("div",{className:"flex flex-col items-center justify-between gap-2 sm:flex-row",children:[Jt("p",{className:"text-sm text-muted-foreground",children:["共 ",t.toLocaleString("zh-CN")," 条,第 ",e,"/",s," 页,每页 ",r," 条",i?K("span",{className:"ml-2",children:i}):null]}),K(_o,{className:"mx-0 w-auto",children:Jt(Go,{children:[K(Xe,{children:K(Fo,{href:"#",text:"上一页","aria-label":"上一页",onClick:n(e-1),className:l(a||e<=1)})}),si(e,s).map((c,f)=>c==="…"?K(Xe,{className:"hidden sm:block",children:K(Vo,{})},`e${f}`):K(Xe,{className:$o(c!==e&&"hidden sm:block"),children:K(yt,{href:"#",isActive:c===e,onClick:n(c),className:l(!!a),children:c})},c)),K(Xe,{children:K(Oo,{href:"#",text:"下一页","aria-label":"下一页",onClick:n(e+1),className:l(a||e>=s)})})]})})]})}import{useState as gi}from"react";import{ChevronDownIcon as bi,RotateCcwIcon as vi,SearchIcon as xi}from"lucide-react";import{ChevronDownIcon as di}from"lucide-react";import{jsx as j,jsxs as Ko}from"react/jsx-runtime";function Yt({id:e,value:t,onChange:a,options:o,placeholder:r,multiple:i}){let s=n=>{if(!i)return a(n);let l=t.split(/[,,、]/).map(c=>c.trim()).filter(Boolean);a(l.includes(n)?l.join(","):[...l,n].join(","))};return Ko(Ce,{children:[j(mt,{id:e,value:t,placeholder:r??"请选择或输入",onChange:n=>a(n.target.value)}),j(ye,{align:"inline-end",children:Ko(Pe,{children:[j(ke,{asChild:!0,children:j(ro,{size:"icon-xs","aria-label":"展开选项",children:j(di,{})})}),j(Se,{align:"end",className:"max-h-72 overflow-y-auto",children:j(Ke,{children:o.map(n=>j(se,{onSelect:()=>s(n.value),children:n.label??n.value},n.value))})})]})})]})}import{cn as Uo}from"cn";import{jsx as Wo}from"react/jsx-runtime";function Zo({className:e,size:t="default",...a}){return Wo("div",{"data-slot":"card","data-size":t,className:Uo("group/card flex flex-col gap-(--card-spacing) overflow-hidden rounded-xl bg-card py-(--card-spacing) text-sm text-card-foreground ring-1 ring-foreground/10 [--card-spacing:--spacing(4)] has-data-[slot=card-footer]:pb-0 has-[>img:first-child]:pt-0 data-[size=sm]:[--card-spacing:--spacing(3)] data-[size=sm]:has-data-[slot=card-footer]:pb-0 *:[img:first-child]:rounded-t-xl *:[img:last-child]:rounded-b-xl",e),...a})}function qo({className:e,...t}){return Wo("div",{"data-slot":"card-content",className:Uo("px-(--card-spacing)",e),...t})}import{useMemo as yc}from"react";import{cva as ui}from"class-variance-authority";import{cn as jt}from"cn";import{cn as ci}from"cn";import{Label as pi}from"radix-ui";import{jsx as mi}from"react/jsx-runtime";function Be({className:e,...t}){return mi(pi.Root,{"data-slot":"label",className:ci("flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",e),...t})}import{jsx as ea,jsxs as Sc}from"react/jsx-runtime";function Qt({className:e,...t}){return ea("div",{"data-slot":"field-group",className:jt("group/field-group @container/field-group flex w-full flex-col gap-5 data-[slot=checkbox-group]:gap-3 *:data-[slot=field-group]:gap-4",e),...t})}var fi=ui("group/field flex w-full gap-2 data-[invalid=true]:text-destructive",{variants:{orientation:{vertical:"flex-col *:w-full [&>.sr-only]:w-auto",horizontal:"flex-row items-center has-[>[data-slot=field-content]]:items-start *:data-[slot=field-label]:flex-auto has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px",responsive:"flex-col *:w-full @md/field-group:flex-row @md/field-group:items-center @md/field-group:*:w-auto @md/field-group:has-[>[data-slot=field-content]]:items-start @md/field-group:*:data-[slot=field-label]:flex-auto [&>.sr-only]:w-auto @md/field-group:has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px"}},defaultVariants:{orientation:"vertical"}});function pe({className:e,orientation:t="vertical",...a}){return ea("div",{role:"group","data-slot":"field","data-orientation":t,className:jt(fi({orientation:t}),e),...a})}function me({className:e,...t}){return ea(Be,{"data-slot":"field-label",className:jt("group/field-label peer/field-label flex w-fit gap-2 leading-snug group-data-[disabled=true]/field:opacity-50 has-data-checked:border-primary/30 has-data-checked:bg-primary/5 has-[>[data-slot=field]]:rounded-lg has-[>[data-slot=field]]:border has-[>[data-slot=field]]:not-has-[:disabled,[data-disabled]]:hover:bg-muted/50 has-[>[data-slot=field]]:has-[:focus-visible]:border-ring has-[>[data-slot=field]]:has-[:focus-visible]:ring-3 has-[>[data-slot=field]]:has-[:focus-visible]:ring-ring/50 *:data-[slot=field]:p-2.5 dark:has-data-checked:border-primary/20 dark:has-data-checked:bg-primary/10","has-[>[data-slot=field]]:w-full has-[>[data-slot=field]]:flex-col",e),...t})}import{cn as Xo}from"cn";import{jsx as u,jsxs as N}from"react/jsx-runtime";var Jo="grid grid-cols-1 gap-4 sm:grid-cols-2 xl:grid-cols-3 2xl:grid-cols-4";function Yo({spec:e,values:t,set:a,currency:o}){let r=`ff-${e.id}`;switch(e.type){case"range":{let i=e.price?o:e.unit,s=(n,l,c)=>N(Ce,{children:[u(mt,{id:n.endsWith("gte")?r:void 0,inputMode:"decimal","aria-label":`${e.label}${c}`,placeholder:l,value:t[n]??"",onChange:f=>a(n,f.target.value)}),i&&u(ye,{align:"inline-end",children:u(no,{children:i})})]});return N(pe,{children:[u(me,{htmlFor:r,children:e.label}),N("div",{className:"flex items-center gap-2",children:[s(`${e.id}.gte`,"最小","最小值"),u("span",{className:"text-muted-foreground",children:"至"}),s(`${e.id}.lte`,"最大","最大值")]})]})}case"dateRange":return N(pe,{children:[u(me,{htmlFor:r,children:e.label}),N("div",{className:"flex items-center gap-2",children:[u(te,{id:r,type:"date","aria-label":`${e.label}开始`,value:t[`${e.id}.gte`]??"",onChange:i=>a(`${e.id}.gte`,i.target.value)}),u("span",{className:"text-muted-foreground",children:"至"}),u(te,{type:"date","aria-label":`${e.label}结束`,value:t[`${e.id}.lte`]??"",onChange:i=>a(`${e.id}.lte`,i.target.value)})]})]});case"text":return N(pe,{children:[u(me,{htmlFor:r,children:e.label}),u(te,{id:r,placeholder:e.placeholder,value:t[e.id]??"",onChange:i=>a(e.id,i.target.value)})]});case"list":return N(pe,{children:[u(me,{htmlFor:r,children:e.label}),e.options?u(Yt,{id:r,placeholder:e.placeholder,value:t[e.id]??"",options:e.options.map(i=>({value:i})),multiple:e.multiple,onChange:i=>a(e.id,i)}):u(te,{id:r,placeholder:e.placeholder,value:t[e.id]??"",onChange:i=>a(e.id,i.target.value)})]});case"flags":{let i=sa(t[e.id]);return N(pe,{children:[u(me,{children:e.label}),u("div",{className:"flex flex-wrap gap-x-4 gap-y-2 pt-1",children:e.options.map(s=>N(Be,{className:"flex items-center gap-2 font-normal",children:[u(de,{checked:i.includes(s.value),onCheckedChange:n=>a(e.id,la(t[e.id],s.value,n===!0))}),s.label]},s.value))})]})}case"bool":case"select":{let i=e.type==="bool"?[{value:"yes",label:"是"},{value:"no",label:"否"}]:e.options,s=e.type==="select"&&e.required,n=s?t[e.id]||i[0]?.value:t[e.id]||"any";return N(pe,{children:[u(me,{htmlFor:r,children:e.label}),N(lt,{value:n,onValueChange:l=>a(e.id,l==="any"?"":l),children:[u(ct,{id:r,className:"w-full",children:u(dt,{})}),u(pt,{children:N(Ya,{children:[!s&&u(Oe,{value:"any",children:"不限"}),i.map(l=>u(Oe,{value:l.value,children:l.label},l.value))]})})]})]})}}}function hi({primary:e,more:t,values:a,onChange:o,onSearch:r,onReset:i,loading:s,currency:n,searchLabel:l="查询",searchIcon:c,disabled:f,prepend:k,append:w,note:S}){let[C,v]=gi(!1),P=(y,q)=>o({...a,[y]:q}),g=t.filter(y=>ia(y).some(q=>a[q])).length;return u(Zo,{children:u(qo,{children:N("form",{onSubmit:y=>{y.preventDefault(),r()},className:"flex flex-col gap-4",children:[N(Qt,{className:Jo,children:[k,e.map(y=>u(Yo,{spec:y,values:a,set:P,currency:n},y.id)),w]}),N(ge,{open:C,onOpenChange:v,children:[u(ve,{children:u(Qt,{className:Xo(Jo,"pb-4"),children:t.map(y=>u(Yo,{spec:y,values:a,set:P,currency:n},y.id))})}),N("div",{className:"flex flex-wrap items-center gap-2",children:[N(p,{type:"submit",disabled:s||f,children:[s?u(Y,{"data-icon":"inline-start"}):c??u(xi,{"data-icon":"inline-start"}),l]}),N(p,{type:"button",variant:"outline",onClick:i,children:[u(vi,{"data-icon":"inline-start"}),"重置"]}),t.length>0&&u(be,{asChild:!0,children:N(p,{type:"button",variant:"ghost",children:["更多条件",g?`(已填 ${g})`:"",u(bi,{"data-icon":"inline-end",className:Xo("transition-transform",C&&"rotate-180")})]})}),S&&u("p",{className:"text-xs text-muted-foreground sm:ml-auto",children:S})]})]})]})})})}import{Columns3Icon as Ci}from"lucide-react";import{jsx as ue,jsxs as Je}from"react/jsx-runtime";function yi({columns:e,visible:t,onChange:a,onReset:o}){return Je(Pe,{children:[ue(ke,{asChild:!0,children:Je(p,{variant:"outline",size:"sm",children:[ue(Ci,{"data-icon":"inline-start"}),"列设置"]})}),Je(Se,{align:"end",className:"max-h-96 w-56 overflow-y-auto",children:[Je(Ue,{children:["显示的列(",t.length,"/",e.length,")"]}),Je(Ke,{children:[ue(se,{onSelect:r=>(r.preventDefault(),o()),children:"恢复默认"}),ue(se,{onSelect:r=>(r.preventDefault(),a(e.map(i=>i.key))),children:"全部显示"})]}),ue(bt,{}),ue(Ke,{children:e.map(r=>ue(vo,{checked:t.includes(r.key),onSelect:i=>i.preventDefault(),onCheckedChange:i=>a(i?e.map(s=>s.key).filter(s=>s===r.key||t.includes(s)):t.filter(s=>s!==r.key)),children:r.label},r.key))})]})]})}import{useState as ki}from"react";import{cn as Q}from"cn";import{AlertDialog as ee}from"radix-ui";import{jsx as E,jsxs as Pi}from"react/jsx-runtime";function jo({...e}){return E(ee.Root,{"data-slot":"alert-dialog",...e})}function wi({...e}){return E(ee.Portal,{"data-slot":"alert-dialog-portal",...e})}function Ni({className:e,...t}){return E(ee.Overlay,{"data-slot":"alert-dialog-overlay",className:Q("fixed inset-0 z-50 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0",e),...t})}function Qo({className:e,size:t="default",...a}){return Pi(wi,{children:[E(Ni,{}),E(ee.Content,{"data-slot":"alert-dialog-content","data-size":t,className:Q("group/alert-dialog-content fixed top-1/2 left-1/2 z-50 grid w-full -translate-x-1/2 -translate-y-1/2 gap-4 rounded-xl bg-popover p-4 text-popover-foreground ring-1 ring-foreground/10 duration-100 outline-none max-w-[calc(100%-2rem)] sm:max-w-sm data-[size=sm]:sm:max-w-xs data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",e),...a})]})}function er({className:e,...t}){return E("div",{"data-slot":"alert-dialog-header",className:Q("grid grid-rows-[auto_1fr] place-items-center gap-1.5 text-center has-data-[slot=alert-dialog-media]:grid-rows-[auto_auto_1fr] has-data-[slot=alert-dialog-media]:gap-x-4 sm:group-data-[size=default]/alert-dialog-content:place-items-start sm:group-data-[size=default]/alert-dialog-content:text-left sm:group-data-[size=default]/alert-dialog-content:has-data-[slot=alert-dialog-media]:grid-rows-[auto_1fr]",e),...t})}function tr({className:e,...t}){return E("div",{"data-slot":"alert-dialog-footer",className:Q("-mx-4 -mb-4 flex flex-col-reverse gap-2 rounded-b-xl border-t bg-muted/50 p-4 group-data-[size=sm]/alert-dialog-content:grid group-data-[size=sm]/alert-dialog-content:grid-cols-2 sm:flex-row sm:justify-end",e),...t})}function ar({className:e,...t}){return E(ee.Title,{"data-slot":"alert-dialog-title",className:Q("font-heading text-base font-medium sm:group-data-[size=default]/alert-dialog-content:group-has-data-[slot=alert-dialog-media]/alert-dialog-content:col-start-2",e),...t})}function or({className:e,...t}){return E(ee.Description,{"data-slot":"alert-dialog-description",className:Q("text-sm text-balance text-muted-foreground md:text-pretty *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground",e),...t})}function rr({className:e,variant:t="default",size:a="default",...o}){return E(p,{variant:t,size:a,asChild:!0,children:E(ee.Action,{"data-slot":"alert-dialog-action",className:Q(e),...o})})}function nr({className:e,variant:t="outline",size:a="default",...o}){return E(p,{variant:t,size:a,asChild:!0,children:E(ee.Cancel,{"data-slot":"alert-dialog-cancel",className:Q(e),...o})})}import{jsx as J,jsxs as wt}from"react/jsx-runtime";function Si({open:e,onOpenChange:t,title:a,description:o,details:r,requireCheck:i,confirmLabel:s="确认",cancelLabel:n="取消",destructive:l,busy:c,onConfirm:f}){let[k,w]=ki(!1),S=!!i&&!k;return J(jo,{open:e,onOpenChange:C=>{C||w(!1),t(C)},children:wt(Qo,{children:[wt(er,{children:[J(ar,{children:a}),o&&J(or,{children:o})]}),r?.length?J("ul",{className:"list-disc space-y-1 pl-5 text-sm text-muted-foreground",children:r.map((C,v)=>J("li",{children:C},v))}):null,i&&wt(Be,{className:"flex items-start gap-2 text-sm font-normal",children:[J(de,{checked:k,onCheckedChange:C=>w(C===!0),className:"mt-0.5"}),J("span",{children:i})]}),wt(tr,{children:[J(nr,{children:n}),J(rr,{variant:l?"destructive":void 0,disabled:c||S,onClick:C=>{C.preventDefault(),!S&&f()},children:s})]})]})})}import{cva as Ri}from"class-variance-authority";import{cn as Ti}from"cn";import{Slot as Ii}from"radix-ui";import{jsx as Di}from"react/jsx-runtime";var zi=Ri("group/badge inline-flex h-5 w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-4xl border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-all focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3!",{variants:{variant:{default:"bg-primary text-primary-foreground [a]:hover:bg-primary/80",secondary:"bg-secondary text-secondary-foreground [a]:hover:bg-secondary/80",destructive:"bg-destructive/10 text-destructive focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:focus-visible:ring-destructive/40 [a]:hover:bg-destructive/20",outline:"border-border text-foreground [a]:hover:bg-muted [a]:hover:text-muted-foreground",ghost:"hover:bg-muted hover:text-muted-foreground dark:hover:bg-muted/50",link:"text-primary underline-offset-4 hover:underline"}},defaultVariants:{variant:"default"}});function ir({className:e,variant:t="default",asChild:a=!1,...o}){let r=a?Ii.Root:"span";return Di(r,{"data-slot":"badge","data-variant":t,className:Ti(zi({variant:t}),e),...o})}import{cn as Ai}from"cn";import{jsx as A,jsxs as U}from"react/jsx-runtime";var Mi={已完成:"border-emerald-600/40 bg-emerald-600/10 text-emerald-700 dark:text-emerald-400",需人工处理:"border-amber-600/40 bg-amber-600/10 text-amber-700 dark:text-amber-400",失败:"border-destructive/40 bg-destructive/10 text-destructive"};function Bi({task:e,running:t,onOpen:a,onStop:o,onRetry:r,className:i}){let s=e.budget&&(e.budget.used>0||e.budget.estimate)?e.budget.estimate?`${e.budget.used} / ${e.budget.estimate}${e.budget.unit??""}`:`${e.budget.used}${e.budget.unit??""}`:void 0;return U("div",{className:Ai("rounded-lg border p-3",i),children:[U("div",{className:"flex flex-wrap items-center gap-2",children:[A("button",{type:"button",className:"min-w-0 flex-1 truncate text-left font-medium text-primary underline-offset-4 hover:underline",onClick:a,children:e.code}),A(ir,{variant:"outline",className:Mi[e.status]??"",children:e.status||"—"})]}),(e.stage||e.hint)&&A("p",{className:"mt-1 text-xs text-muted-foreground",children:[e.stage,e.hint].filter(Boolean).join(" · ")}),e.stages?.length?A("div",{className:"mt-2 flex flex-wrap gap-1",children:e.stages.map(n=>U("span",{className:"rounded border px-1.5 py-0.5 text-xs tabular-nums",title:n.label,children:[n.label," ",n.pass,"/",n.input,n.todo?U("span",{className:"text-amber-600 dark:text-amber-400",children:[" +",n.todo]}):null]},n.key))}):null,U("dl",{className:"mt-2 grid grid-cols-2 gap-x-3 gap-y-1 text-xs text-muted-foreground",children:[s&&U("div",{className:"flex justify-between gap-2",children:[A("dt",{children:"算力"}),A("dd",{className:"tabular-nums",children:s})]}),e.rounds!=null&&U("div",{className:"flex justify-between gap-2",children:[A("dt",{children:"轮次"}),A("dd",{className:"tabular-nums",children:e.rounds})]}),e.startedAt&&U("div",{className:"flex justify-between gap-2",children:[A("dt",{children:"开始"}),A("dd",{className:"tabular-nums",children:e.startedAt})]}),e.lastActiveAt&&U("div",{className:"flex justify-between gap-2",children:[A("dt",{children:"最后活动"}),A("dd",{className:"tabular-nums",children:e.lastActiveAt})]})]}),U("div",{className:"mt-2 flex flex-wrap gap-1",children:[a&&A(p,{variant:"ghost",size:"sm",onClick:a,children:"查看"}),t&&o&&A(p,{variant:"ghost",size:"sm",onClick:o,children:"停止"}),r&&A(p,{variant:"ghost",size:"sm",onClick:r,children:"重试未完成"})]})]})}import{useEffect as dr,useRef as _i,useState as Gi}from"react";import{CheckIcon as Fi,CopyIcon as Oi}from"lucide-react";import{cn as sr}from"cn";import{ScrollArea as Ye}from"radix-ui";import{jsx as je,jsxs as Ei}from"react/jsx-runtime";function lr({className:e,children:t,...a}){return Ei(Ye.Root,{"data-slot":"scroll-area",className:sr("relative",e),...a,children:[je(Ye.Viewport,{"data-slot":"scroll-area-viewport",className:"size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1",children:t}),je(Li,{}),je(Ye.Corner,{})]})}function Li({className:e,orientation:t="vertical",...a}){return je(Ye.ScrollAreaScrollbar,{"data-slot":"scroll-area-scrollbar","data-orientation":t,orientation:t,className:sr("flex touch-none p-px transition-colors select-none data-horizontal:h-2.5 data-horizontal:flex-col data-horizontal:border-t data-horizontal:border-t-transparent data-vertical:h-full data-vertical:w-2.5 data-vertical:border-l data-vertical:border-l-transparent",e),...a,children:je(Ye.ScrollAreaThumb,{"data-slot":"scroll-area-thumb",className:"relative flex-1 rounded-full bg-border"})})}import{jsx as fe,jsxs as Nt}from"react/jsx-runtime";var Vi=/^\[(\d{4}-\d{2}-\d{2}T[\d:.]+Z)\]/;function $i(e,t){let a=e.match(Vi);if(!a)return e;let o=new Date(a[1]);return Number.isNaN(o.getTime())?e:`[${new Intl.DateTimeFormat("zh-CN",{timeZone:t,month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}).format(o)}]${e.slice(a[0].length)}`}function Hi({text:e,timeZone:t,className:a}){let o=String(e??"").trim(),r=o?o.split(`
|
|
2
|
-
`).map(c
|
|
3
|
-
`)),
|
|
4
|
-
`)}),
|
|
1
|
+
"use client";import{a as Ha,b as Ka,c as Ua,d as gt,f as pa,g as Ya,h as Ja,i as ja,l as Se,t as ma,v as ua,x as eo}from"../chunk-2YASMNNJ.js";import{a as Et,b as fa,c as to,d as Lt,e as ao,f as Ft,h as oo,i as ro,j as no,k as ga,m as io}from"../chunk-SJFNXBPH.js";import{g as $a,j as ue,s as Wa,t as Za,u as qa,v as Xa,x as Qa}from"../chunk-7K2XKPOX.js";import{Fragment as xi}from"react";import hi from"next/link";import{usePathname as Ci}from"next/navigation";import Ca from"next/link";import{usePathname as Nn}from"next/navigation";import{ChevronRightIcon as Pn}from"lucide-react";import{Collapsible as ba}from"radix-ui";import{jsx as va}from"react/jsx-runtime";function $e({...e}){return va(ba.Root,{"data-slot":"collapsible",...e})}function He({...e}){return va(ba.CollapsibleTrigger,{"data-slot":"collapsible-trigger",...e})}function Ke({...e}){return va(ba.CollapsibleContent,{"data-slot":"collapsible-content",...e})}import*as V from"react";import{cva as fn}from"class-variance-authority";import{cn as E}from"cn";import{Slot as Co}from"radix-ui";import*as so from"react";var qr=768,lo=`(max-width: ${qr-1}px)`;function Xr(e){let t=window.matchMedia(lo);return t.addEventListener("change",e),()=>t.removeEventListener("change",e)}function co(){return so.useSyncExternalStore(Xr,()=>window.matchMedia(lo).matches,()=>!1)}import{cva as Qr}from"class-variance-authority";import{cn as Yr}from"cn";import{Slot as Jr}from"radix-ui";import{jsx as en}from"react/jsx-runtime";var jr=Qr("group/button inline-flex shrink-0 items-center justify-center rounded-lg border border-transparent bg-clip-padding text-sm font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/80",outline:"border-border bg-background hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground hover:bg-[color-mix(in_oklch,var(--secondary),var(--foreground)_5%)] aria-expanded:bg-secondary aria-expanded:text-secondary-foreground",ghost:"hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50",destructive:"bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-8 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",xs:"h-6 gap-1 rounded-[min(var(--radius-md),10px)] px-2 text-xs in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3",sm:"h-7 gap-1 rounded-[min(var(--radius-md),12px)] px-2.5 text-[0.8rem] in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5",lg:"h-9 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",icon:"size-8","icon-xs":"size-6 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-lg [&_svg:not([class*='size-'])]:size-3","icon-sm":"size-7 rounded-[min(var(--radius-md),12px)] in-data-[slot=button-group]:rounded-lg","icon-lg":"size-9"}},defaultVariants:{variant:"default",size:"default"}});function u({className:e,variant:t="default",size:a="default",asChild:o=!1,...r}){let s=o?Jr.Root:"button";return en(s,{"data-slot":"button","data-variant":t,"data-size":a,className:Yr(jr({variant:t,size:a,className:e})),...r})}import{cn as tn}from"cn";import{jsx as an}from"react/jsx-runtime";function q({className:e,type:t,...a}){return an("input",{type:t,"data-slot":"input",className:tn("h-8 w-full min-w-0 rounded-lg border border-input bg-transparent px-2.5 py-1 text-base transition-colors outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40",e),...a})}import{cn as on}from"cn";import{Separator as rn}from"radix-ui";import{jsx as nn}from"react/jsx-runtime";function po({className:e,orientation:t="horizontal",decorative:a=!0,...o}){return nn(rn.Root,{"data-slot":"separator",decorative:a,orientation:t,className:on("shrink-0 bg-border data-horizontal:h-px data-horizontal:w-full data-vertical:w-px data-vertical:self-stretch",e),...o})}import{cn as bt}from"cn";import{Dialog as Re}from"radix-ui";import{XIcon as sn}from"lucide-react";import{jsx as ne,jsxs as xa}from"react/jsx-runtime";function mo({...e}){return ne(Re.Root,{"data-slot":"sheet",...e})}function ln({...e}){return ne(Re.Portal,{"data-slot":"sheet-portal",...e})}function dn({className:e,...t}){return ne(Re.Overlay,{"data-slot":"sheet-overlay",className:bt("fixed inset-0 z-50 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0",e),...t})}function uo({className:e,children:t,side:a="right",showCloseButton:o=!0,...r}){return xa(ln,{children:[ne(dn,{}),xa(Re.Content,{"data-slot":"sheet-content","data-side":a,className:bt("fixed z-50 flex flex-col gap-4 bg-popover bg-clip-padding text-sm text-popover-foreground shadow-lg transition duration-200 ease-in-out data-[side=bottom]:inset-x-0 data-[side=bottom]:bottom-0 data-[side=bottom]:h-auto data-[side=bottom]:border-t data-[side=left]:inset-y-0 data-[side=left]:left-0 data-[side=left]:h-full data-[side=left]:w-3/4 data-[side=left]:border-r data-[side=right]:inset-y-0 data-[side=right]:right-0 data-[side=right]:h-full data-[side=right]:w-3/4 data-[side=right]:border-l data-[side=top]:inset-x-0 data-[side=top]:top-0 data-[side=top]:h-auto data-[side=top]:border-b data-[side=left]:sm:max-w-sm data-[side=right]:sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-[side=bottom]:data-open:slide-in-from-bottom-10 data-[side=left]:data-open:slide-in-from-left-10 data-[side=right]:data-open:slide-in-from-right-10 data-[side=top]:data-open:slide-in-from-top-10 data-closed:animate-out data-closed:fade-out-0 data-[side=bottom]:data-closed:slide-out-to-bottom-10 data-[side=left]:data-closed:slide-out-to-left-10 data-[side=right]:data-closed:slide-out-to-right-10 data-[side=top]:data-closed:slide-out-to-top-10",e),...r,children:[t,o&&ne(Re.Close,{"data-slot":"sheet-close",asChild:!0,children:xa(u,{variant:"ghost",className:"absolute top-3 right-3",size:"icon-sm",children:[ne(sn,{}),ne("span",{className:"sr-only",children:"Close"})]})})]})]})}function fo({className:e,...t}){return ne("div",{"data-slot":"sheet-header",className:bt("flex flex-col gap-0.5 p-4",e),...t})}function go({className:e,...t}){return ne(Re.Title,{"data-slot":"sheet-title",className:bt("font-heading text-base font-medium text-foreground",e),...t})}function bo({className:e,...t}){return ne(Re.Description,{"data-slot":"sheet-description",className:bt("text-sm text-muted-foreground",e),...t})}import{cn}from"cn";import{jsx as pn}from"react/jsx-runtime";function _t({className:e,...t}){return pn("div",{"data-slot":"skeleton",className:cn("animate-pulse rounded-md bg-muted",e),...t})}import{cn as mn}from"cn";import{Tooltip as vt}from"radix-ui";import{jsx as Gt,jsxs as un}from"react/jsx-runtime";function vo({...e}){return Gt(vt.Root,{"data-slot":"tooltip",...e})}function xo({...e}){return Gt(vt.Trigger,{"data-slot":"tooltip-trigger",...e})}function ho({className:e,sideOffset:t=0,children:a,...o}){return Gt(vt.Portal,{children:un(vt.Content,{"data-slot":"tooltip-content",sideOffset:t,className:mn("z-50 inline-flex w-fit max-w-xs origin-(--radix-tooltip-content-transform-origin) items-center gap-1.5 rounded-md bg-foreground px-3 py-1.5 text-xs text-background has-data-[slot=kbd]:pr-1.5 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 **:data-[slot=kbd]:relative **:data-[slot=kbd]:isolate **:data-[slot=kbd]:z-50 **:data-[slot=kbd]:rounded-sm data-[state=delayed-open]:animate-in data-[state=delayed-open]:fade-in-0 data-[state=delayed-open]:zoom-in-95 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",e),...o,children:[a,Gt(vt.Arrow,{className:"z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground"})]})})}import{PanelLeftIcon as gn}from"lucide-react";import{jsx as k,jsxs as xt}from"react/jsx-runtime";var bn="sidebar_state",vn=3600*24*7,xn="16rem",hn="18rem",Cn="3rem",yn="b",yo=V.createContext(null);function Ue(){let e=V.useContext(yo);if(!e)throw new Error("useSidebar must be used within a SidebarProvider.");return e}function wo({defaultOpen:e=!0,open:t,onOpenChange:a,className:o,style:r,children:s,...n}){let i=co(),[l,c]=V.useState(!1),[f,T]=V.useState(e),P=t??f,v=V.useCallback(y=>{let w=typeof y=="function"?y(P):y;a?a(w):T(w),document.cookie=`${bn}=${w}; path=/; max-age=${vn}`},[a,P]),C=V.useCallback(()=>i?c(y=>!y):v(y=>!y),[i,v,c]);V.useEffect(()=>{let y=w=>{w.key===yn&&(w.metaKey||w.ctrlKey)&&(w.preventDefault(),C())};return window.addEventListener("keydown",y),()=>window.removeEventListener("keydown",y)},[C]);let h=P?"expanded":"collapsed",R=V.useMemo(()=>({state:h,open:P,setOpen:v,isMobile:i,openMobile:l,setOpenMobile:c,toggleSidebar:C}),[h,P,v,i,l,c,C]);return k(yo.Provider,{value:R,children:k("div",{"data-slot":"sidebar-wrapper",style:{"--sidebar-width":xn,"--sidebar-width-icon":Cn,...r},className:E("group/sidebar-wrapper flex min-h-svh w-full has-data-[variant=inset]:bg-sidebar",o),...n,children:s})})}function No({side:e="left",variant:t="sidebar",collapsible:a="offcanvas",className:o,children:r,dir:s,...n}){let{isMobile:i,state:l,openMobile:c,setOpenMobile:f}=Ue();return a==="none"?k("div",{"data-slot":"sidebar",className:E("flex h-full w-(--sidebar-width) flex-col bg-sidebar text-sidebar-foreground",o),...n,children:r}):i?k(mo,{open:c,onOpenChange:f,...n,children:xt(uo,{dir:s,"data-sidebar":"sidebar","data-slot":"sidebar","data-mobile":"true",className:"w-(--sidebar-width) bg-sidebar p-0 text-sidebar-foreground [&>button]:hidden",style:{"--sidebar-width":hn},side:e,children:[xt(fo,{className:"sr-only",children:[k(go,{children:"Sidebar"}),k(bo,{children:"Displays the mobile sidebar."})]}),k("div",{className:"flex h-full w-full flex-col",children:r})]})}):xt("div",{className:"group peer hidden text-sidebar-foreground md:block","data-state":l,"data-collapsible":l==="collapsed"?a:"","data-variant":t,"data-side":e,"data-slot":"sidebar",children:[k("div",{"data-slot":"sidebar-gap",className:E("relative w-(--sidebar-width) bg-transparent transition-[width] duration-200 ease-linear","group-data-[collapsible=offcanvas]:w-0","group-data-[side=right]:rotate-180",t==="floating"||t==="inset"?"group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4)))]":"group-data-[collapsible=icon]:w-(--sidebar-width-icon)")}),k("div",{"data-slot":"sidebar-container","data-side":e,className:E("fixed inset-y-0 z-10 hidden h-svh w-(--sidebar-width) transition-[left,right,width] duration-200 ease-linear data-[side=left]:left-0 data-[side=left]:group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)] data-[side=right]:right-0 data-[side=right]:group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)] md:flex",t==="floating"||t==="inset"?"p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4))+2px)]":"group-data-[collapsible=icon]:w-(--sidebar-width-icon) group-data-[side=left]:border-r group-data-[side=right]:border-l",o),...n,children:k("div",{"data-sidebar":"sidebar","data-slot":"sidebar-inner",className:"flex size-full flex-col bg-sidebar group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:shadow-sm group-data-[variant=floating]:ring-1 group-data-[variant=floating]:ring-sidebar-border",children:r})})]})}function Po({className:e,onClick:t,...a}){let{toggleSidebar:o}=Ue();return xt(u,{"data-sidebar":"trigger","data-slot":"sidebar-trigger",variant:"ghost",size:"icon-sm",className:E(e),onClick:r=>{t?.(r),o()},...a,children:[k(gn,{}),k("span",{className:"sr-only",children:"Toggle Sidebar"})]})}function ko({className:e,...t}){let{toggleSidebar:a}=Ue();return k("button",{"data-sidebar":"rail","data-slot":"sidebar-rail","aria-label":"Toggle Sidebar",tabIndex:-1,onClick:a,title:"Toggle Sidebar",className:E("absolute inset-y-0 z-20 hidden w-4 transition-all ease-linear group-data-[side=left]:-right-4 group-data-[side=right]:left-0 after:absolute after:inset-y-0 after:start-1/2 after:w-[2px] hover:after:bg-sidebar-border sm:flex ltr:-translate-x-1/2 rtl:-translate-x-1/2","in-data-[side=left]:cursor-w-resize in-data-[side=right]:cursor-e-resize","[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize","group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full hover:group-data-[collapsible=offcanvas]:bg-sidebar","[[data-side=left][data-collapsible=offcanvas]_&]:-right-2","[[data-side=right][data-collapsible=offcanvas]_&]:-left-2",e),...t})}function So({className:e,...t}){return k("main",{"data-slot":"sidebar-inset",className:E("relative flex w-full flex-1 flex-col bg-background md:peer-data-[variant=inset]:m-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow-sm md:peer-data-[variant=inset]:peer-data-[state=collapsed]:ml-2",e),...t})}function Ro({className:e,...t}){return k("div",{"data-slot":"sidebar-header","data-sidebar":"header",className:E("flex flex-col gap-2 p-2",e),...t})}function To({className:e,...t}){return k("div",{"data-slot":"sidebar-content","data-sidebar":"content",className:E("no-scrollbar flex min-h-0 flex-1 flex-col gap-0 overflow-auto group-data-[collapsible=icon]:overflow-hidden",e),...t})}function Io({className:e,...t}){return k("div",{"data-slot":"sidebar-group","data-sidebar":"group",className:E("relative flex w-full min-w-0 flex-col p-2",e),...t})}function ha({className:e,...t}){return k("ul",{"data-slot":"sidebar-menu","data-sidebar":"menu",className:E("flex w-full min-w-0 flex-col gap-0",e),...t})}function Ot({className:e,...t}){return k("li",{"data-slot":"sidebar-menu-item","data-sidebar":"menu-item",className:E("group/menu-item relative",e),...t})}var wn=fn("peer/menu-button group/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm ring-sidebar-ring outline-hidden transition-[width,height,padding] group-has-data-[sidebar=menu-action]/menu-item:pr-8 group-data-[collapsible=icon]:size-8! group-data-[collapsible=icon]:p-2! hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-open:hover:bg-sidebar-accent data-open:hover:text-sidebar-accent-foreground data-active:bg-sidebar-accent data-active:font-medium data-active:text-sidebar-accent-foreground [&_svg]:size-4 [&_svg]:shrink-0 [&>span:last-child]:truncate",{variants:{variant:{default:"hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",outline:"bg-background shadow-[0_0_0_1px_var(--sidebar-border)] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_var(--sidebar-accent)]"},size:{default:"h-8 text-sm",sm:"h-7 text-xs",lg:"h-12 text-sm group-data-[collapsible=icon]:p-0!"}},defaultVariants:{variant:"default",size:"default"}});function Vt({asChild:e=!1,isActive:t=!1,variant:a="default",size:o="default",tooltip:r,className:s,...n}){let i=e?Co.Root:"button",{isMobile:l,state:c}=Ue(),f=k(i,{"data-slot":"sidebar-menu-button","data-sidebar":"menu-button","data-size":o,"data-active":t,className:E(wn({variant:a,size:o}),s),...n});return r?(typeof r=="string"&&(r={children:r}),xt(vo,{children:[k(xo,{asChild:!0,children:f}),k(ho,{side:"right",align:"center",hidden:c!=="collapsed"||l,...r})]})):f}function Do({className:e,...t}){return k("ul",{"data-slot":"sidebar-menu-sub","data-sidebar":"menu-sub",className:E("mx-3.5 flex min-w-0 translate-x-px flex-col gap-1 border-l border-sidebar-border px-2.5 py-0.5 group-data-[collapsible=icon]:hidden",e),...t})}function zo({className:e,...t}){return k("li",{"data-slot":"sidebar-menu-sub-item","data-sidebar":"menu-sub-item",className:E("group/menu-sub-item relative",e),...t})}function Ao({asChild:e=!1,size:t="md",isActive:a=!1,className:o,...r}){let s=e?Co.Root:"a";return k(s,{"data-slot":"sidebar-menu-sub-button","data-sidebar":"menu-sub-button","data-size":t,"data-active":a,className:E("flex h-7 min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-md px-2 text-sidebar-foreground ring-sidebar-ring outline-hidden group-data-[collapsible=icon]:hidden hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[size=md]:text-sm data-[size=sm]:text-xs data-active:bg-sidebar-accent data-active:text-sidebar-accent-foreground [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:text-sidebar-accent-foreground",o),...r})}import{jsx as N,jsxs as Te}from"react/jsx-runtime";function ya({nav:e,appName:t="LinkFox",appSubtitle:a,version:o}){let r=Nn(),s=gt(e,r),{isMobile:n,setOpenMobile:i}=Ue();return Te(No,{collapsible:"icon",children:[N(Ro,{children:N(ha,{children:N(Ot,{children:N(Vt,{size:"lg",asChild:!0,children:Te(Ca,{href:"/",children:[N("div",{className:"flex aspect-square size-8 items-center justify-center rounded-lg bg-sidebar-primary font-semibold text-sidebar-primary-foreground",children:"LF"}),Te("div",{className:"flex flex-col gap-0.5 leading-none",children:[Te("span",{className:"flex items-center gap-1.5 font-medium",children:[t,o?N("span",{className:"rounded border px-1 text-[10px] leading-4 font-normal text-muted-foreground tabular-nums",children:o}):null]}),a?N("span",{className:"text-xs text-muted-foreground",children:a}):null]})]})})})})}),N(To,{children:N(Io,{children:N(ha,{children:e.map(l=>{if(l.items.length===1){let c=l.items[0];return N(Ot,{children:N(Vt,{tooltip:l.title,isActive:s?.group===l,asChild:!0,children:Te(Ca,{href:c.href,onClick:()=>n&&i(!1),children:[N(l.icon,{}),N("span",{children:l.title})]})})},l.title)}return N($e,{asChild:!0,defaultOpen:!0,className:"group/collapsible",children:Te(Ot,{children:[N(He,{asChild:!0,children:Te(Vt,{tooltip:l.title,isActive:s?.group===l,children:[N(l.icon,{}),N("span",{children:l.title}),N(Pn,{className:"ml-auto transition-transform group-data-[state=open]/collapsible:rotate-90"})]})}),N(Ke,{children:N(Do,{children:l.items.map(c=>N(zo,{children:N(Ao,{asChild:!0,isActive:s?.item===c,children:N(Ca,{href:c.href,onClick:()=>n&&i(!1),children:N("span",{children:c.title})})})},c.href))})})]})},l.title)})})})}),N(ko,{})]})}import{useEffect as Pa,useRef as ka,useState as Be}from"react";import{BotIcon as Fn,CheckCircle2Icon as _n,ChevronDownIcon as Gn,ExternalLinkIcon as On,FileTextIcon as Vn,MessageCirclePlusIcon as Eo,SendIcon as $n,SparklesIcon as Lo,SquareIcon as Hn,TableIcon as Kn,Trash2Icon as Un,XCircleIcon as Wn,XIcon as Fo}from"lucide-react";import kn from"react-markdown";import Sn from"remark-gfm";import{jsx as We}from"react/jsx-runtime";function X(e,t){function a({node:o,...r}){return We(e,{className:t,...r})}return a}var Rn={p:X("p","my-1.5 leading-relaxed"),ul:X("ul","my-1.5 list-disc pl-5"),ol:X("ol","my-1.5 list-decimal pl-5"),li:X("li","my-0.5"),h1:X("h3","mt-3 mb-1 font-semibold"),h2:X("h3","mt-3 mb-1 font-semibold"),h3:X("h4","mt-2 mb-1 font-semibold"),a:({href:e,children:t})=>We("a",{href:e,target:"_blank",rel:"noopener noreferrer",className:"break-all text-primary underline underline-offset-2",children:t}),code:X("code","rounded bg-muted px-1 py-0.5 font-mono text-xs"),pre:X("pre","my-2 overflow-x-auto rounded-md bg-muted p-2 text-xs [&_code]:bg-transparent [&_code]:p-0"),table:({children:e})=>We("div",{className:"my-2 overflow-x-auto rounded-md border",children:We("table",{className:"w-full text-xs",children:e})}),th:X("th","border-b bg-muted px-2 py-1 text-left font-medium whitespace-nowrap"),td:X("td","border-b px-2 py-1 align-top"),blockquote:X("blockquote","my-2 border-l-2 pl-3 text-muted-foreground")};function wa({children:e}){return We("div",{className:"text-sm break-words",children:We(kn,{remarkPlugins:[Sn],components:Rn,children:e})})}import{cn as Ie}from"cn";import{Select as U}from"radix-ui";import{ChevronDownIcon as Mo,CheckIcon as Tn,ChevronUpIcon as In}from"lucide-react";import{jsx as A,jsxs as Na}from"react/jsx-runtime";function De({...e}){return A(U.Root,{"data-slot":"select",...e})}function ht({className:e,...t}){return A(U.Group,{"data-slot":"select-group",className:Ie("scroll-my-1 p-1",e),...t})}function ze({...e}){return A(U.Value,{"data-slot":"select-value",...e})}function Ae({className:e,size:t="default",children:a,...o}){return Na(U.Trigger,{"data-slot":"select-trigger","data-size":t,className:Ie("flex w-fit items-center justify-between gap-1.5 rounded-lg border border-input bg-transparent py-2 pr-2 pl-2.5 text-sm whitespace-nowrap transition-colors outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-placeholder:text-muted-foreground data-[size=default]:h-8 data-[size=sm]:h-7 data-[size=sm]:rounded-[min(var(--radius-md),10px)] *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-1.5 dark:bg-input/30 dark:hover:bg-input/50 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...o,children:[a,A(U.Icon,{asChild:!0,children:A(Mo,{className:"pointer-events-none size-4 text-muted-foreground"})})]})}function Me({className:e,children:t,position:a="item-aligned",align:o="center",...r}){return A(U.Portal,{children:Na(U.Content,{"data-slot":"select-content","data-align-trigger":a==="item-aligned",className:Ie("relative z-50 max-h-(--radix-select-content-available-height) min-w-36 origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 data-[align-trigger=true]:animate-none data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",a==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:a,align:o,...r,children:[A(Dn,{}),A(U.Viewport,{"data-position":a,className:Ie("data-[position=popper]:h-(--radix-select-trigger-height) data-[position=popper]:w-full data-[position=popper]:min-w-(--radix-select-trigger-width)",a==="popper"&&""),children:t}),A(zn,{})]})})}function fe({className:e,children:t,...a}){return Na(U.Item,{"data-slot":"select-item",className:Ie("relative flex w-full cursor-default items-center gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",e),...a,children:[A("span",{className:"pointer-events-none absolute right-2 flex size-4 items-center justify-center",children:A(U.ItemIndicator,{children:A(Tn,{className:"pointer-events-none"})})}),A(U.ItemText,{children:t})]})}function Dn({className:e,...t}){return A(U.ScrollUpButton,{"data-slot":"select-scroll-up-button",className:Ie("z-10 flex cursor-default items-center justify-center bg-popover py-1 [&_svg:not([class*='size-'])]:size-4",e),...t,children:A(In,{})})}function zn({className:e,...t}){return A(U.ScrollDownButton,{"data-slot":"select-scroll-down-button",className:Ie("z-10 flex cursor-default items-center justify-center bg-popover py-1 [&_svg:not([class*='size-'])]:size-4",e),...t,children:A(Mo,{})})}import{cn as An}from"cn";import{Loader2Icon as Mn}from"lucide-react";import{jsx as Bn}from"react/jsx-runtime";function j({className:e,...t}){return Bn(Mn,{"data-slot":"spinner",role:"status","aria-label":"Loading",className:An("size-4 animate-spin",e),...t})}import{cn as En}from"cn";import{jsx as Ln}from"react/jsx-runtime";function Bo({className:e,...t}){return Ln("textarea",{"data-slot":"textarea",className:En("flex field-sizing-content min-h-16 w-full rounded-lg border border-input bg-transparent px-2.5 py-2 text-base transition-colors outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40",e),...t})}import{cn as Zn}from"cn";import{Fragment as Jn,jsx as p,jsxs as S}from"react/jsx-runtime";var qn=["介绍一下这个应用现在能做什么","帮我梳理接下来可以加哪些功能"],Xn="例如:帮我把当前页面的数据按状态汇总一下",_o=e=>pa.find(t=>t.id===e)?.name??e;function Sa({suggestions:e}){let{open:t,setOpen:a,page:o}=ga(),[r,s]=Be(),[n,i]=Be([]),[l,c]=Be(""),[f,T]=Be("default"),[P,v]=Be(!0),[C,h]=Be(""),R=ka(null),y=ka(null),w=ka(null),Z=n.some(g=>g.running),Ne=!!o&&(!!o.table||o.records.length>0),ce=()=>h("");Pa(()=>{!t||r||Se()?.getNotebook().then(g=>s({notebookId:g.notebookId,name:g.name})).catch(()=>{})},[t,r]);let J=o?`${o.table?.id}:${o.records.map(g=>g.id).join(",")}`:"",[mt,ut]=Be(J);J!==mt&&(ut(J),v(!0)),Pa(()=>{w.current?.scrollIntoView({block:"end"})},[n]),Pa(()=>()=>R.current?.abort(),[]);let pe=(g,m)=>i(I=>I.map(z=>z.id===g?{...z,...m}:z)),me=async(g=l)=>{let m=g.trim();if(!m||Z)return;let I=P&&Ne?o:null,z=crypto.randomUUID(),xe=C;i(B=>[...B,{id:z,input:m,context:I,modelId:f,running:!0,followUp:!!xe}]),c("");let re=new AbortController;R.current=re,y.current=null;try{let B=await ja(io(m,xe?null:I,r),f,{signal:re.signal,sessionId:xe||void 0,onUpdate:ke=>{y.current=ke.messageId,ke.sessionId&&h(ke.sessionId),pe(z,{task:ke})}});B.sessionId&&h(B.sessionId),pe(z,{task:B,running:!1,error:B.stopReason==="end_turn"?void 0:`任务异常结束(${B.stopReason})`}),window.dispatchEvent(new Event(ro));let Pe=await Ja(B.messageId);Pe&&pe(z,{shareUrl:Pe})}catch(B){pe(z,{running:!1,error:$a(B)?"已停止":ue(B)})}finally{R.current===re&&(R.current=null)}},ft=()=>{let g=y.current;R.current?.abort(),g&&Ya(g).catch(()=>{})},da=e?.items??[],ca=(o?da.find(g=>o.source.endsWith(g.match))?.items:void 0)??e?.fallback??qn;return S("aside",{"aria-label":"LinkFox OS 助手",className:Zn("z-40 flex flex-col border-l bg-background","fixed inset-0 md:sticky md:top-0 md:h-svh md:w-1/4 md:min-w-90 md:shrink-0 md:self-start",!t&&"hidden"),children:[S("header",{className:"flex h-14 shrink-0 items-center gap-2 border-b px-3",children:[p(Lo,{className:"size-4 text-primary"}),p("span",{className:"font-medium",children:"LinkFox OS"}),S(De,{value:f,onValueChange:g=>{T(g),ce()},disabled:Z,children:[p(Ae,{size:"sm",className:"ml-auto w-32","aria-label":"选择 Agent",children:p(ze,{})}),p(Me,{align:"end",children:pa.map(g=>p(fe,{value:g.id,children:g.name},g.id))})]}),p(u,{variant:"ghost",size:"icon-sm","aria-label":"开新对话(不保留上下文)",title:"开新对话:下一条消息不再续接当前会话",disabled:Z||!C,onClick:ce,children:p(Eo,{})}),p(u,{variant:"ghost",size:"icon-sm","aria-label":"清空对话",disabled:Z||!n.length,onClick:()=>{i([]),ce()},children:p(Un,{})}),p(u,{variant:"ghost",size:"icon-sm","aria-label":"关闭助手",onClick:()=>a(!1),children:p(Fo,{})})]}),S("div",{className:"min-h-0 flex-1 overflow-y-auto overscroll-contain px-3 py-3",children:[n.length===0?S("div",{className:"flex flex-col gap-3 py-6 text-sm text-muted-foreground",children:[S("div",{className:"flex items-center gap-2 text-foreground",children:[p(Fn,{className:"size-5"}),p("span",{className:"font-medium",children:"让 LinkFox 帮你干活"})]}),p("p",{children:"描述你要完成的事,LinkFox OS 会自己调用选品、数据查询、生图、多维表等技能去执行。勾选的记录会自动带上。"}),p("div",{className:"flex flex-col gap-2",children:ca.map(g=>p("button",{type:"button",className:"rounded-lg border px-3 py-2 text-left text-foreground transition-colors hover:bg-muted",onClick:()=>c(g),children:g},g))})]}):p("div",{className:"flex flex-col gap-4",children:n.map(g=>p(Yn,{item:g,notebook:r},g.id))}),p("div",{ref:w})]}),S("div",{className:"shrink-0 border-t p-3",children:[C?S("div",{className:"mb-2 flex items-center gap-2 text-xs text-muted-foreground",children:[p(Eo,{className:"size-3.5 shrink-0"}),S("span",{className:"min-w-0 flex-1",children:["接着上一轮聊(",_o(f)," 记得前面的内容,可以直接追问)"]}),p("button",{type:"button",className:"shrink-0 text-primary underline-offset-2 hover:underline",onClick:ce,children:"开新对话"})]}):S(Jn,{children:[Ne&&P&&o&&p(Qn,{context:o,notebook:r,onRemove:()=>v(!1)}),Ne&&!P&&p("button",{type:"button",className:"mb-2 text-xs text-primary underline-offset-2 hover:underline",onClick:()=>v(!0),children:"重新带入当前页面的数据表和勾选记录"})]}),S("div",{className:"flex items-end gap-2",children:[p(Bo,{value:l,onChange:g=>c(g.target.value),onKeyDown:g=>{g.key==="Enter"&&!g.shiftKey&&!g.nativeEvent.isComposing&&(g.preventDefault(),me())},placeholder:C?"接着问,例如:把第 3 条展开说说 / 换个角度再看一遍":e?.placeholder??Xn,"aria-label":"告诉 LinkFox 要做什么",className:"max-h-40 min-h-16 resize-none"}),Z?p(u,{size:"icon",variant:"outline","aria-label":"停止",onClick:ft,children:p(Hn,{})}):p(u,{size:"icon","aria-label":"发送",disabled:!l.trim(),onClick:()=>me(),children:p($n,{})})]}),p("p",{className:"mt-2 text-xs text-muted-foreground",children:"执行会消耗 LinkFox 算力。Enter 发送,Shift+Enter 换行。"})]})]})}function Qn({context:e,notebook:t,onRemove:a}){let o=e.records.length;return S($e,{className:"mb-2 rounded-lg border bg-muted/40 text-xs",children:[S("div",{className:"flex items-center gap-2 px-2.5 py-2",children:[p(Kn,{className:"size-3.5 shrink-0 text-muted-foreground"}),S("div",{className:"min-w-0 flex-1",children:[e.table&&S("div",{className:"truncate",children:[t?`${t.name} / `:"",e.table.name]}),p("div",{className:"text-muted-foreground",children:o?`已勾选 ${o} 条记录,将一并发送`:`当前页面:${e.source}`})]}),o>0&&p(He,{asChild:!0,children:p(u,{variant:"ghost",size:"icon-xs","aria-label":"查看勾选记录",className:"[&[data-state=open]>svg]:rotate-180",children:p(Gn,{})})}),p(u,{variant:"ghost",size:"icon-xs","aria-label":"不带入上下文",onClick:a,children:p(Fo,{})})]}),o>0&&p(Ke,{children:p("ul",{className:"max-h-32 overflow-y-auto border-t px-2.5 py-1.5",children:e.records.map(r=>p("li",{className:"truncate py-0.5",title:r.label,children:r.label},r.id))})})]})}function Yn({item:e,notebook:t}){let{task:a,context:o}=e,r=a?.steps??[];return S("div",{className:"flex flex-col gap-2",children:[S("div",{className:"ml-6 self-end rounded-lg bg-primary px-3 py-2 text-sm whitespace-pre-wrap text-primary-foreground",children:[e.input,o&&S("div",{className:"mt-1.5 border-t border-primary-foreground/20 pt-1.5 text-xs opacity-80",children:[o.table?`${t?`${t.name} / `:""}${o.table.name}`:o.source,o.records.length?` · 勾选 ${o.records.length} 条`:""]})]}),S("div",{className:"mr-2 flex flex-col gap-2 rounded-lg border px-3 py-2",children:[S("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[p("span",{children:_o(e.modelId)}),e.followUp&&p("span",{className:"rounded bg-muted px-1.5 py-0.5",children:"接上一轮"})]}),r.length>0&&p("ul",{className:"flex flex-col gap-1 text-xs",children:r.map(s=>S("li",{className:"flex items-center gap-1.5",children:[s.status==="running"?p(j,{className:"size-3"}):s.status==="failed"?p(Wn,{className:"size-3 text-destructive"}):p(_n,{className:"size-3 text-emerald-600"}),p("span",{className:"truncate",children:s.status==="running"?`正在调用 ${s.title}`:s.title})]},s.id))}),a?.text?p(wa,{children:a.text}):e.running&&S("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[p(j,{})," ",a?"LinkFox 正在处理…":"正在提交任务…"]}),a&&a.files.length>0&&p("ul",{className:"flex flex-col gap-1",children:a.files.map(s=>p("li",{children:S("a",{href:s.uri,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 text-xs text-primary underline-offset-2 hover:underline",children:[p(Vn,{className:"size-3.5 shrink-0"}),p("span",{className:"truncate",children:s.name})]})},s.uri))}),e.error&&p("div",{className:"text-sm text-destructive",children:e.error}),e.shareUrl&&S("a",{href:e.shareUrl,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 self-start text-xs text-muted-foreground underline-offset-2 hover:text-foreground hover:underline",children:["查看完整过程 ",p(On,{className:"size-3"})]})]})]})}function Ra(){let{open:e,setOpen:t}=ga();return S(u,{variant:e?"secondary":"default",size:"sm",onClick:()=>t(a=>!a),"aria-expanded":e,"aria-label":"让LinkFox帮你干活",children:[p(Lo,{}),p("span",{className:"hidden sm:inline",children:"让LinkFox帮你干活"})]})}import{useMemo as si,useState as li}from"react";import{CheckIcon as ar,GlobeIcon as di}from"lucide-react";import{Command as Qe}from"cmdk";import{cn as Ye}from"cn";import{cn as Ze}from"cn";import{Dialog as he}from"radix-ui";import{XIcon as jn}from"lucide-react";import{jsx as Q,jsxs as $t}from"react/jsx-runtime";function Go({...e}){return Q(he.Root,{"data-slot":"dialog",...e})}function ei({...e}){return Q(he.Portal,{"data-slot":"dialog-portal",...e})}function ti({className:e,...t}){return Q(he.Overlay,{"data-slot":"dialog-overlay",className:Ze("fixed inset-0 isolate z-50 bg-black/50 duration-100 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0",e),...t})}function Oo({className:e,children:t,showCloseButton:a=!0,...o}){return $t(ei,{children:[Q(ti,{}),$t(he.Content,{"data-slot":"dialog-content",className:Ze("fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-4 rounded-xl bg-popover p-4 text-sm text-popover-foreground ring-1 ring-foreground/10 duration-100 outline-none sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",e),...o,children:[t,a&&Q(he.Close,{"data-slot":"dialog-close",asChild:!0,children:$t(u,{variant:"ghost",className:"absolute top-2 right-2",size:"icon-sm",children:[Q(jn,{}),Q("span",{className:"sr-only",children:"关闭"})]})})]})]})}function Vo({className:e,...t}){return Q("div",{"data-slot":"dialog-header",className:Ze("flex flex-col gap-2",e),...t})}function $o({className:e,showCloseButton:t=!1,children:a,...o}){return $t("div",{"data-slot":"dialog-footer",className:Ze("-mx-4 -mb-4 flex flex-col-reverse gap-2 rounded-b-xl border-t bg-muted/50 p-4 sm:flex-row sm:justify-end",e),...o,children:[a,t&&Q(he.Close,{asChild:!0,children:Q(u,{variant:"outline",children:"Close"})})]})}function Ho({className:e,...t}){return Q(he.Title,{"data-slot":"dialog-title",className:Ze("font-heading text-base leading-none font-medium",e),...t})}function Ko({className:e,...t}){return Q(he.Description,{"data-slot":"dialog-description",className:Ze("text-sm text-muted-foreground *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground",e),...t})}import{cva as Uo}from"class-variance-authority";import{cn as Ct}from"cn";import{jsx as yt}from"react/jsx-runtime";function qe({className:e,...t}){return yt("div",{"data-slot":"input-group",role:"group",className:Ct("group/input-group relative flex h-8 w-full min-w-0 items-center rounded-lg border border-input transition-colors outline-none in-data-[slot=combobox-content]:focus-within:border-inherit in-data-[slot=combobox-content]:focus-within:ring-0 has-disabled:bg-input/50 has-disabled:opacity-50 has-[[data-slot=input-group-control]:focus-visible]:border-ring has-[[data-slot=input-group-control]:focus-visible]:ring-3 has-[[data-slot=input-group-control]:focus-visible]:ring-ring/50 has-[[data-slot][aria-invalid=true]]:border-destructive has-[[data-slot][aria-invalid=true]]:ring-3 has-[[data-slot][aria-invalid=true]]:ring-destructive/20 has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>textarea]:h-auto dark:bg-input/30 dark:has-disabled:bg-input/80 dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40 has-[>[data-align=block-end]]:[&>input]:pt-3 has-[>[data-align=block-start]]:[&>input]:pb-3 has-[>[data-align=inline-end]]:[&>input]:pr-1.5 has-[>[data-align=inline-start]]:[&>input]:pl-1.5",e),...t})}var ai=Uo("flex h-auto cursor-text items-center justify-center gap-2 py-1.5 text-sm font-medium text-muted-foreground select-none group-data-[disabled=true]/input-group:opacity-50 [&>kbd]:rounded-[calc(var(--radius)-5px)] [&>svg:not([class*='size-'])]:size-4",{variants:{align:{"inline-start":"order-first pl-2 has-[>button]:ml-[-0.3rem] has-[>kbd]:ml-[-0.15rem]","inline-end":"order-last pr-2 has-[>button]:mr-[-0.3rem] has-[>kbd]:mr-[-0.15rem]","block-start":"order-first w-full justify-start px-2.5 pt-2 group-has-[>input]/input-group:pt-2 [.border-b]:pb-2","block-end":"order-last w-full justify-start px-2.5 pb-2 group-has-[>input]/input-group:pb-2 [.border-t]:pt-2"}},defaultVariants:{align:"inline-start"}});function Xe({className:e,align:t="inline-start",...a}){return yt("div",{role:"group","data-slot":"input-group-addon","data-align":t,className:Ct(ai({align:t}),e),onClick:o=>{o.target.closest("button")||o.currentTarget.parentElement?.querySelector("input")?.focus()},...a})}var oi=Uo("flex items-center gap-2 text-sm shadow-none",{variants:{size:{xs:"h-6 gap-1 rounded-[calc(var(--radius)-3px)] px-1.5 [&>svg:not([class*='size-'])]:size-3.5",sm:"","icon-xs":"size-6 rounded-[calc(var(--radius)-3px)] p-0 has-[>svg]:p-0","icon-sm":"size-8 p-0 has-[>svg]:p-0"}},defaultVariants:{size:"xs"}});function Wo({className:e,type:t="button",variant:a="ghost",size:o="xs",...r}){return yt(u,{type:t,"data-size":o,variant:a,className:Ct(oi({size:o}),e),...r})}function Zo({className:e,...t}){return yt("span",{className:Ct("flex items-center gap-2 text-sm text-muted-foreground [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4",e),...t})}function Ht({className:e,...t}){return yt(q,{"data-slot":"input-group-control",className:Ct("flex-1 rounded-none border-0 bg-transparent shadow-none ring-0 focus-visible:ring-0 disabled:bg-transparent aria-invalid:ring-0 dark:bg-transparent dark:disabled:bg-transparent",e),...t})}import{SearchIcon as ri,CheckIcon as ni}from"lucide-react";import{jsx as ge,jsxs as Jo}from"react/jsx-runtime";function qo({className:e,...t}){return ge(Qe,{"data-slot":"command",className:Ye("flex size-full flex-col overflow-hidden rounded-xl! bg-popover p-1 text-popover-foreground",e),...t})}function Xo({className:e,...t}){return ge("div",{"data-slot":"command-input-wrapper",className:"p-1 pb-0",children:Jo(qe,{className:"h-8! rounded-lg! border-input/30 bg-input/30 shadow-none! *:data-[slot=input-group-addon]:pl-2!",children:[ge(Qe.Input,{"data-slot":"command-input",className:Ye("w-full text-sm outline-hidden disabled:cursor-not-allowed disabled:opacity-50",e),...t}),ge(Xe,{children:ge(ri,{className:"size-4 shrink-0 opacity-50"})})]})})}function Qo({className:e,...t}){return ge(Qe.List,{"data-slot":"command-list",className:Ye("no-scrollbar max-h-72 scroll-py-1 overflow-x-hidden overflow-y-auto outline-none",e),...t})}function Yo({className:e,...t}){return ge(Qe.Empty,{"data-slot":"command-empty",className:Ye("py-6 text-center text-sm",e),...t})}function Kt({className:e,...t}){return ge(Qe.Group,{"data-slot":"command-group",className:Ye("overflow-hidden p-1 text-foreground **:[[cmdk-group-heading]]:px-2 **:[[cmdk-group-heading]]:py-1.5 **:[[cmdk-group-heading]]:text-xs **:[[cmdk-group-heading]]:font-medium **:[[cmdk-group-heading]]:text-muted-foreground",e),...t})}function Ta({className:e,children:t,...a}){return Jo(Qe.Item,{"data-slot":"command-item",className:Ye("group/command-item relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none in-data-[slot=dialog-content]:rounded-lg! data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 data-selected:bg-muted data-selected:text-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 data-selected:*:[svg]:text-foreground",e),...a,children:[t,ge(ni,{className:"ml-auto opacity-0 group-has-data-[slot=command-shortcut]/command-item:hidden group-data-[checked=true]/command-item:opacity-100"})]})}import{cn as ii}from"cn";import{Popover as Ut}from"radix-ui";import{jsx as Wt}from"react/jsx-runtime";function jo({...e}){return Wt(Ut.Root,{"data-slot":"popover",...e})}function er({...e}){return Wt(Ut.Trigger,{"data-slot":"popover-trigger",...e})}function tr({className:e,align:t="center",sideOffset:a=4,...o}){return Wt(Ut.Portal,{children:Wt(Ut.Content,{"data-slot":"popover-content",align:t,sideOffset:a,className:ii("z-50 flex w-72 origin-(--radix-popover-content-transform-origin) flex-col gap-2.5 rounded-lg bg-popover p-2.5 text-sm text-popover-foreground shadow-md ring-1 ring-foreground/10 outline-hidden duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",e),...o})})}import{cn as or}from"cn";import{jsx as $,jsxs as Ee}from"react/jsx-runtime";var Ia=["Asia/Shanghai","America/Los_Angeles","America/New_York","Europe/London","Europe/Berlin","Asia/Tokyo","UTC"];function ci(){try{return Intl.supportedValuesOf("timeZone")}catch{return Ia}}function Da(){let[e,t]=li(!1),a=Lt(),o=ao(),r=si(()=>e?ci().filter(i=>!Ia.includes(i)).map(i=>({zone:i,offset:Ft(i)})):[],[e]),s=i=>{to(i),t(!1)},n=(i,l=Ft(i))=>Ee(Ta,{value:`${i} ${l}`,onSelect:()=>s(i),children:[$(ar,{className:or(!o&&i===a?"opacity-100":"opacity-0")}),$("span",{className:"truncate",children:i}),$("span",{className:"ml-auto text-xs text-muted-foreground",children:l})]},i);return Ee(jo,{open:e,onOpenChange:t,children:[$(er,{asChild:!0,children:Ee(u,{variant:"outline",size:"sm","aria-label":"选择时区",children:[$(di,{"data-icon":"inline-start"}),$("span",{className:"hidden max-w-40 truncate sm:inline",children:a}),$("span",{className:"text-muted-foreground",children:Ft(a)})]})}),$(tr,{align:"end",className:"w-80 p-0",children:Ee(qo,{children:[$(Xo,{placeholder:"搜索时区,如 Shanghai、UTC+08"}),Ee(Qo,{children:[$(Yo,{children:"没有匹配的时区"}),$(Kt,{heading:"默认",children:Ee(Ta,{value:`跟随浏览器 ${fa()}`,onSelect:()=>s(null),children:[$(ar,{className:or(o?"opacity-100":"opacity-0")}),Ee("span",{className:"truncate",children:["跟随浏览器(",fa(),")"]})]})}),$(Kt,{heading:"常用",children:Ia.map(i=>n(i))}),$(Kt,{heading:"全部",children:r.map(i=>n(i.zone,i.offset))})]})]})})]})}import{LogOutIcon as ui,UserIcon as fi}from"lucide-react";import{cn as wt}from"cn";import{DropdownMenu as ie}from"radix-ui";import{CheckIcon as pi,ChevronRightIcon as Kd}from"lucide-react";import{jsx as ee,jsxs as mi}from"react/jsx-runtime";function Je({...e}){return ee(ie.Root,{"data-slot":"dropdown-menu",...e})}function je({...e}){return ee(ie.Trigger,{"data-slot":"dropdown-menu-trigger",...e})}function et({className:e,align:t="start",sideOffset:a=4,...o}){return ee(ie.Portal,{children:ee(ie.Content,{"data-slot":"dropdown-menu-content",sideOffset:a,align:t,className:wt("z-50 max-h-(--radix-dropdown-menu-content-available-height) w-(--radix-dropdown-menu-trigger-width) min-w-32 origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover p-1 text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:overflow-hidden data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",e),...o})})}function Nt({...e}){return ee(ie.Group,{"data-slot":"dropdown-menu-group",...e})}function Le({className:e,inset:t,variant:a="default",...o}){return ee(ie.Item,{"data-slot":"dropdown-menu-item","data-inset":t,"data-variant":a,className:wt("group/dropdown-menu-item relative flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-inset:pl-7 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 data-[variant=destructive]:*:[svg]:text-destructive",e),...o})}function rr({className:e,children:t,checked:a,inset:o,...r}){return mi(ie.CheckboxItem,{"data-slot":"dropdown-menu-checkbox-item","data-inset":o,className:wt("relative flex cursor-default items-center gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground focus:**:text-accent-foreground data-inset:pl-7 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),checked:a,...r,children:[ee("span",{className:"pointer-events-none absolute right-2 flex items-center justify-center","data-slot":"dropdown-menu-checkbox-item-indicator",children:ee(ie.ItemIndicator,{children:ee(pi,{})})}),t]})}function Pt({className:e,inset:t,...a}){return ee(ie.Label,{"data-slot":"dropdown-menu-label","data-inset":t,className:wt("px-1.5 py-1 text-xs font-medium text-muted-foreground data-inset:pl-7",e),...a})}function Zt({className:e,...t}){return ee(ie.Separator,{"data-slot":"dropdown-menu-separator",className:wt("-mx-1 my-1 h-px bg-border",e),...t})}import{Fragment as gi,jsx as tt,jsxs as kt}from"react/jsx-runtime";function za(){let e=Et();return e.status!=="ready"?null:kt(Je,{children:[tt(je,{asChild:!0,children:tt(u,{variant:"ghost",size:"icon","aria-label":"账号",children:tt(fi,{})})}),kt(et,{align:"end",children:[tt(Pt,{children:e.userName||"LinkFox 用户"}),e.apiKey&&kt(Pt,{className:"font-normal text-muted-foreground",children:["API Key:",Qa(e.apiKey)]}),!e.apiKey&&kt(gi,{children:[tt(Zt,{}),kt(Le,{onSelect:Xa,children:[tt(ui,{}),"退出登录"]})]})]})]})}import{cn as at}from"cn";import{Slot as bi}from"radix-ui";import{ChevronRightIcon as vi,MoreHorizontalIcon as ac}from"lucide-react";import{jsx as Fe,jsxs as rc}from"react/jsx-runtime";function nr({className:e,...t}){return Fe("nav",{"aria-label":"breadcrumb","data-slot":"breadcrumb",className:at(e),...t})}function ir({className:e,...t}){return Fe("ol",{"data-slot":"breadcrumb-list",className:at("flex flex-wrap items-center gap-1.5 text-sm wrap-break-word text-muted-foreground",e),...t})}function Aa({className:e,...t}){return Fe("li",{"data-slot":"breadcrumb-item",className:at("inline-flex items-center gap-1",e),...t})}function sr({asChild:e,className:t,...a}){let o=e?bi.Root:"a";return Fe(o,{"data-slot":"breadcrumb-link",className:at("transition-colors hover:text-foreground",t),...a})}function lr({className:e,...t}){return Fe("span",{"data-slot":"breadcrumb-page",role:"link","aria-disabled":"true","aria-current":"page",className:at("font-normal text-foreground",e),...t})}function dr({children:e,className:t,...a}){return Fe("li",{"data-slot":"breadcrumb-separator",role:"presentation","aria-hidden":"true",className:at("[&>svg]:size-3.5",t),...a,children:e??Fe(vi,{})})}import{jsx as M,jsxs as St}from"react/jsx-runtime";function yi({children:e,nav:t,appName:a,appSubtitle:o,version:r,suggestions:s}){let n=Ci(),i=gt(t,n),l=i?[...new Set([i.group.title,i.item.title])]:[];return M(no,{children:St(wo,{children:[M(ya,{nav:t,appName:a,appSubtitle:o,version:r}),St(So,{className:"min-w-0",children:[St("header",{className:"sticky top-0 z-10 flex h-14 shrink-0 items-center gap-2 border-b bg-background px-4",children:[M(Po,{className:"-ml-1"}),M(po,{orientation:"vertical",className:"mr-2 data-[orientation=vertical]:h-4"}),M(nr,{className:"min-w-0 flex-1",children:St(ir,{children:[M(Aa,{className:"hidden md:inline-flex",children:M(sr,{asChild:!0,children:M(hi,{href:"/",children:"首页"})})}),l.map((c,f)=>St(xi,{children:[M(dr,{className:f===0?"hidden md:block":void 0}),M(Aa,{className:f<l.length-1?"hidden md:inline-flex":void 0,children:f===l.length-1?M(lr,{children:c}):M("span",{children:c})})]},c))]})}),M(Ra,{}),M(Da,{}),M(za,{})]}),M("main",{className:"flex min-w-0 flex-1 flex-col gap-4 p-4",children:e})]}),M(Sa,{suggestions:s})]})})}import{useEffect as Pi}from"react";import{CircleAlertIcon as ki,LogInIcon as mr,RotateCwIcon as Si}from"lucide-react";import{cva as wi}from"class-variance-authority";import{cn as ot}from"cn";import{jsx as rt}from"react/jsx-runtime";function qt({className:e,...t}){return rt("div",{"data-slot":"empty",className:ot("flex w-full min-w-0 flex-1 flex-col items-center justify-center gap-4 rounded-xl border-dashed p-6 text-center text-balance",e),...t})}function Xt({className:e,...t}){return rt("div",{"data-slot":"empty-header",className:ot("flex max-w-sm flex-col items-center gap-2",e),...t})}var Ni=wi("mb-2 flex shrink-0 items-center justify-center [&_svg]:pointer-events-none [&_svg]:shrink-0",{variants:{variant:{default:"bg-transparent",icon:"flex size-8 shrink-0 items-center justify-center rounded-lg bg-muted text-foreground [&_svg:not([class*='size-'])]:size-4"}},defaultVariants:{variant:"default"}});function cr({className:e,variant:t="default",...a}){return rt("div",{"data-slot":"empty-icon","data-variant":t,className:ot(Ni({variant:t,className:e})),...a})}function Qt({className:e,...t}){return rt("div",{"data-slot":"empty-title",className:ot("font-heading text-sm font-medium tracking-tight",e),...t})}function Yt({className:e,...t}){return rt("div",{"data-slot":"empty-description",className:ot("text-sm/relaxed text-muted-foreground [&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary",e),...t})}function pr({className:e,...t}){return rt("div",{"data-slot":"empty-content",className:ot("flex w-full max-w-sm min-w-0 flex-col items-center gap-2.5 text-sm text-balance",e),...t})}import{jsx as Y,jsxs as Jt}from"react/jsx-runtime";function Ri({children:e}){let t=Et();if(Pi(()=>{Wa()},[]),t.status==="ready")return e;let a=t.status==="redirecting"&&t.auto;if(t.status==="loading"||t.status==="callback"||a)return Jt("div",{className:"flex min-h-svh items-center justify-center gap-2",role:"status",children:[Y(j,{}),Y("span",{children:t.status==="callback"?"正在完成登录…":a?"正在跳转登录…":"正在准备登录…"})]});let o=t.status==="error",r=t.status==="redirecting";return Y("div",{className:"flex min-h-svh items-center justify-center bg-muted p-4",children:Jt(qt,{className:"max-w-md bg-background",children:[Jt(Xt,{children:[Y(cr,{variant:"icon",children:o?Y(ki,{}):Y(mr,{})}),Y(Qt,{children:o?"无法进入选品工作台":"登录 LinkFox"}),Y(Yt,{children:o?t.message:"使用 LinkFox 账号登录,登录状态将在此浏览器中保留至到期或退出。"})]}),Y(pr,{children:Jt(u,{disabled:r,onClick:o&&t.action==="config"?()=>{Za()}:()=>{qa()},children:[r?Y(j,{"data-icon":"inline-start"}):o?Y(Si,{"data-icon":"inline-start"}):Y(mr,{"data-icon":"inline-start"}),r?"正在跳转…":o?"重试":"登录 LinkFox"]})})]})})}import*as ur from"react";import{ThemeProvider as Ti,useTheme as Ii}from"next-themes";import{jsx as Mi,jsxs as Bi}from"react/jsx-runtime";function Di({children:e,...t}){return Bi(Ti,{attribute:"class",defaultTheme:"system",enableSystem:!0,disableTransitionOnChange:!0,...t,children:[Mi(Ai,{}),e]})}function zi(e){return e instanceof HTMLElement?e.isContentEditable||e.tagName==="INPUT"||e.tagName==="TEXTAREA"||e.tagName==="SELECT":!1}function Ai(){let{resolvedTheme:e,setTheme:t}=Ii();return ur.useEffect(()=>{function a(o){o.defaultPrevented||o.repeat||o.metaKey||o.ctrlKey||o.altKey||o.key.toLowerCase()==="d"&&(zi(o.target)||t(e==="dark"?"light":"dark"))}return window.addEventListener("keydown",a),()=>{window.removeEventListener("keydown",a)}},[e,t]),null}import{cn as Ei}from"cn";import{Checkbox as fr}from"radix-ui";import{CheckIcon as Li}from"lucide-react";import{jsx as Ma}from"react/jsx-runtime";function _e({className:e,...t}){return Ma(fr.Root,{"data-slot":"checkbox",className:Ei("peer relative flex size-4 shrink-0 items-center justify-center rounded-[4px] border border-input transition-colors outline-none group-has-disabled/field:opacity-50 group-has-[:focus-visible]/field-label:ring-0 group-has-[:focus-visible]/field-label:not-data-checked:border-input after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 aria-invalid:aria-checked:border-primary dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:border-primary data-checked:bg-primary data-checked:text-primary-foreground group-has-[:focus-visible]/field-label:data-checked:border-primary dark:data-checked:bg-primary",e),...t,children:Ma(fr.Indicator,{"data-slot":"checkbox-indicator",className:"grid place-content-center text-current transition-none [&>svg]:size-3.5",children:Ma(Li,{})})})}import{cn as nt}from"cn";import{jsx as Ge}from"react/jsx-runtime";function jt({className:e,...t}){return Ge("div",{"data-slot":"table-container",className:"relative w-full overflow-x-auto",children:Ge("table",{"data-slot":"table",className:nt("w-full caption-bottom text-sm",e),...t})})}function ea({className:e,...t}){return Ge("thead",{"data-slot":"table-header",className:nt("[&_tr]:border-b",e),...t})}function ta({className:e,...t}){return Ge("tbody",{"data-slot":"table-body",className:nt("[&_tr:last-child]:border-0",e),...t})}function be({className:e,...t}){return Ge("tr",{"data-slot":"table-row",className:nt("border-b transition-colors hover:bg-muted/50 has-aria-expanded:bg-muted/50 data-[state=selected]:bg-muted",e),...t})}function te({className:e,...t}){return Ge("th",{"data-slot":"table-head",className:nt("h-10 px-2 text-left align-middle font-medium text-foreground [&:has([role=checkbox])]:pr-0",e),...t})}function H({className:e,...t}){return Ge("td",{"data-slot":"table-cell",className:nt("p-2 align-middle break-words [&:has([role=checkbox])]:pr-0",e),...t})}import{cn as aa}from"cn";import{jsx as L,jsxs as oa}from"react/jsx-runtime";var gr=56,br=120;function Fi({columns:e,rows:t,rowKey:a,renderCell:o,actions:r,actionsWidth:s=200,selection:n,onRowClick:i,loading:l,skeletonRows:c=8,empty:f,className:T}){let P=e.length+(n?1:0)+(r?1:0),C={"--dt-min-width":`${e.reduce((h,R)=>h+(R.width??br),0)+(n?gr:0)+(r?s:0)}px`};return oa(jt,{style:C,className:aa("lg:[min-width:var(--dt-min-width)] max-lg:block",T),children:[L(ea,{className:"max-lg:hidden",children:oa(be,{children:[n&&L(te,{style:{width:gr},className:"lg:sticky lg:left-0 lg:z-20 lg:bg-card",children:L(_e,{"aria-label":"全选本页",checked:n.pageAllSelected?!0:n.pageSomeSelected?"indeterminate":!1,disabled:!t.length,onCheckedChange:h=>n.onToggleAll(h===!0)})}),e.map(h=>L(te,{style:{width:h.width??br},className:"break-words",children:h.label},h.key)),r&&L(te,{style:{width:s},className:"text-right lg:sticky lg:right-0 lg:z-20 lg:border-l lg:bg-card",children:"操作"})]})}),oa(ta,{className:"max-lg:block",children:[l&&t.length===0?Array.from({length:c},(h,R)=>L(be,{className:"max-lg:block max-lg:border-0",children:L(H,{colSpan:P,className:"max-lg:block",children:L(_t,{className:"h-10 w-full"})})},R)):t.map(h=>{let R=a(h);return oa(be,{"data-state":n?.selected.has(R)?"selected":void 0,onClick:i?()=>i(h):void 0,className:aa("group/row",l&&"opacity-60",i&&"cursor-pointer","max-lg:mb-3 max-lg:block max-lg:rounded-lg max-lg:border max-lg:p-3"),children:[n&&L(H,{className:"max-lg:flex max-lg:items-center max-lg:border-0 max-lg:px-0 max-lg:py-1 lg:sticky lg:left-0 lg:z-10 lg:bg-card lg:group-hover/row:bg-muted",children:L(_e,{"aria-label":"选择本行",checked:n.selected.has(R),onCheckedChange:y=>n.onToggleRow(h,y===!0),onClick:y=>y.stopPropagation()})}),e.map(y=>L(H,{"data-label":y.label,className:aa("align-top break-words","max-lg:flex max-lg:gap-3 max-lg:border-0 max-lg:px-0 max-lg:py-1","max-lg:before:w-24 max-lg:before:shrink-0 max-lg:before:text-xs max-lg:before:text-muted-foreground","max-lg:before:content-[attr(data-label)]"),children:L("div",{className:"min-w-0 flex-1",children:o(h,y)})},y.key)),r&&L(H,{className:aa("align-top text-right max-lg:flex max-lg:justify-end max-lg:border-0 max-lg:px-0 max-lg:py-1","lg:sticky lg:right-0 lg:z-10 lg:border-l lg:bg-card lg:group-hover/row:bg-muted"),children:L("div",{className:"flex justify-end gap-1",onClick:y=>y.stopPropagation(),children:r(h)})})]},R)}),!l&&t.length===0&&f?L(be,{className:"max-lg:block max-lg:border-0 hover:bg-transparent",children:L(H,{colSpan:P,className:"whitespace-normal max-lg:block",children:f})}):null]})]})}import{cn as it}from"cn";import{ChevronLeftIcon as _i,ChevronRightIcon as Gi,MoreHorizontalIcon as Oi}from"lucide-react";import{jsx as ae,jsxs as Ba}from"react/jsx-runtime";function vr({className:e,...t}){return ae("nav",{role:"navigation","aria-label":"pagination","data-slot":"pagination",className:it("mx-auto flex w-full justify-center",e),...t})}function xr({className:e,...t}){return ae("ul",{"data-slot":"pagination-content",className:it("flex items-center gap-0.5",e),...t})}function Rt({...e}){return ae("li",{"data-slot":"pagination-item",...e})}function ra({className:e,isActive:t,size:a="icon",...o}){return ae(u,{asChild:!0,variant:t?"outline":"ghost",size:a,className:it(e),children:ae("a",{"aria-current":t?"page":void 0,"data-slot":"pagination-link","data-active":t,...o})})}function hr({className:e,text:t="Previous",...a}){return Ba(ra,{"aria-label":"Go to previous page",size:"default",className:it("pl-1.5!",e),...a,children:[ae(_i,{"data-icon":"inline-start"}),ae("span",{className:"hidden sm:block",children:t})]})}function Cr({className:e,text:t="Next",...a}){return Ba(ra,{"aria-label":"Go to next page",size:"default",className:it("pr-1.5!",e),...a,children:[ae("span",{className:"hidden sm:block",children:t}),ae(Gi,{"data-icon":"inline-end"})]})}function yr({className:e,...t}){return Ba("span",{"aria-hidden":!0,"data-slot":"pagination-ellipsis",className:it("flex size-8 items-center justify-center [&_svg:not([class*='size-'])]:size-4",e),...t,children:[ae(Oi,{}),ae("span",{className:"sr-only",children:"More pages"})]})}import{cn as wr}from"cn";import{jsx as se,jsxs as Ea}from"react/jsx-runtime";var Tt=20;function Vi(e,t){if(t<=7)return Array.from({length:t},(s,n)=>n+1);let a=[1],o=Math.max(2,e-1),r=Math.min(t-1,e+1);o>2&&a.push("…");for(let s=o;s<=r;s++)a.push(s);return r<t-1&&a.push("…"),a.push(t),a}function La({page:e,total:t,disabled:a,onChange:o,pageSize:r=Tt,note:s}){let n=Math.max(1,Math.ceil(t/r)),i=c=>f=>{f.preventDefault(),!(a||c<1||c>n||c===e)&&o(c)},l=c=>wr(c&&"pointer-events-none opacity-50");return Ea("div",{className:"flex flex-col items-center justify-between gap-2 sm:flex-row",children:[Ea("p",{className:"text-sm text-muted-foreground",children:["共 ",t.toLocaleString("zh-CN")," 条,第 ",e,"/",n," 页,每页 ",r," 条",s?se("span",{className:"ml-2",children:s}):null]}),se(vr,{className:"mx-0 w-auto",children:Ea(xr,{children:[se(Rt,{children:se(hr,{href:"#",text:"上一页","aria-label":"上一页",onClick:i(e-1),className:l(a||e<=1)})}),Vi(e,n).map((c,f)=>c==="…"?se(Rt,{className:"hidden sm:block",children:se(yr,{})},`e${f}`):se(Rt,{className:wr(c!==e&&"hidden sm:block"),children:se(ra,{href:"#",isActive:c===e,onClick:i(c),className:l(!!a),children:c})},c)),se(Rt,{children:se(Cr,{href:"#",text:"下一页","aria-label":"下一页",onClick:i(e+1),className:l(a||e>=n)})})]})})]})}import{useState as Xi}from"react";import{ChevronDownIcon as Qi,RotateCcwIcon as Yi,SearchIcon as Ji}from"lucide-react";import{ChevronDownIcon as $i}from"lucide-react";import{jsx as Ce,jsxs as Nr}from"react/jsx-runtime";function st({id:e,value:t,onChange:a,options:o,placeholder:r,multiple:s}){let n=i=>{if(!s)return a(i);let l=t.split(/[,,、]/).map(c=>c.trim()).filter(Boolean);a(l.includes(i)?l.join(","):[...l,i].join(","))};return Nr(qe,{children:[Ce(Ht,{id:e,value:t,placeholder:r??"请选择或输入",onChange:i=>a(i.target.value)}),Ce(Xe,{align:"inline-end",children:Nr(Je,{children:[Ce(je,{asChild:!0,children:Ce(Wo,{size:"icon-xs","aria-label":"展开选项",children:Ce($i,{})})}),Ce(et,{align:"end",className:"max-h-72 overflow-y-auto",children:Ce(Nt,{children:o.map(i=>Ce(Le,{onSelect:()=>n(i.value),children:i.label??i.value},i.value))})})]})})]})}import{cn as Pr}from"cn";import{jsx as kr}from"react/jsx-runtime";function It({className:e,size:t="default",...a}){return kr("div",{"data-slot":"card","data-size":t,className:Pr("group/card flex flex-col gap-(--card-spacing) overflow-hidden rounded-xl bg-card py-(--card-spacing) text-sm text-card-foreground ring-1 ring-foreground/10 [--card-spacing:--spacing(4)] has-data-[slot=card-footer]:pb-0 has-[>img:first-child]:pt-0 data-[size=sm]:[--card-spacing:--spacing(3)] data-[size=sm]:has-data-[slot=card-footer]:pb-0 *:[img:first-child]:rounded-t-xl *:[img:last-child]:rounded-b-xl",e),...a})}function Dt({className:e,...t}){return kr("div",{"data-slot":"card-content",className:Pr("px-(--card-spacing)",e),...t})}import{useMemo as Wi}from"react";import{cva as Zi}from"class-variance-authority";import{cn as na}from"cn";import{cn as Hi}from"cn";import{Label as Ki}from"radix-ui";import{jsx as Ui}from"react/jsx-runtime";function lt({className:e,...t}){return Ui(Ki.Root,{"data-slot":"label",className:Hi("flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",e),...t})}import{jsx as dt,jsxs as yp}from"react/jsx-runtime";function ct({className:e,...t}){return dt("div",{"data-slot":"field-group",className:na("group/field-group @container/field-group flex w-full flex-col gap-5 data-[slot=checkbox-group]:gap-3 *:data-[slot=field-group]:gap-4",e),...t})}var qi=Zi("group/field flex w-full gap-2 data-[invalid=true]:text-destructive",{variants:{orientation:{vertical:"flex-col *:w-full [&>.sr-only]:w-auto",horizontal:"flex-row items-center has-[>[data-slot=field-content]]:items-start *:data-[slot=field-label]:flex-auto has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px",responsive:"flex-col *:w-full @md/field-group:flex-row @md/field-group:items-center @md/field-group:*:w-auto @md/field-group:has-[>[data-slot=field-content]]:items-start @md/field-group:*:data-[slot=field-label]:flex-auto [&>.sr-only]:w-auto @md/field-group:has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px"}},defaultVariants:{orientation:"vertical"}});function F({className:e,orientation:t="vertical",...a}){return dt("div",{role:"group","data-slot":"field","data-orientation":t,className:na(qi({orientation:t}),e),...a})}function _({className:e,...t}){return dt(lt,{"data-slot":"field-label",className:na("group/field-label peer/field-label flex w-fit gap-2 leading-snug group-data-[disabled=true]/field:opacity-50 has-data-checked:border-primary/30 has-data-checked:bg-primary/5 has-[>[data-slot=field]]:rounded-lg has-[>[data-slot=field]]:border has-[>[data-slot=field]]:not-has-[:disabled,[data-disabled]]:hover:bg-muted/50 has-[>[data-slot=field]]:has-[:focus-visible]:border-ring has-[>[data-slot=field]]:has-[:focus-visible]:ring-3 has-[>[data-slot=field]]:has-[:focus-visible]:ring-ring/50 *:data-[slot=field]:p-2.5 dark:has-data-checked:border-primary/20 dark:has-data-checked:bg-primary/10","has-[>[data-slot=field]]:w-full has-[>[data-slot=field]]:flex-col",e),...t})}function Sr({className:e,children:t,errors:a,...o}){let r=Wi(()=>{if(t)return t;if(!a?.length)return null;let s=[...new Map(a.map(n=>[n?.message,n])).values()];return s?.length==1?s[0]?.message:dt("ul",{className:"ml-4 flex list-disc flex-col gap-1",children:s.map((n,i)=>n?.message&&dt("li",{children:n.message},i))})},[t,a]);return r?dt("div",{role:"alert","data-slot":"field-error",className:na("text-sm font-normal text-destructive",e),...o,children:r}):null}import{cn as Rr}from"cn";import{jsx as x,jsxs as D}from"react/jsx-runtime";var Tr="grid grid-cols-1 gap-4 sm:grid-cols-2 xl:grid-cols-3 2xl:grid-cols-4";function Ir({spec:e,values:t,set:a,currency:o}){let r=`ff-${e.id}`;switch(e.type){case"range":{let s=e.price?o:e.unit,n=(i,l,c)=>D(qe,{children:[x(Ht,{id:i.endsWith("gte")?r:void 0,inputMode:"decimal","aria-label":`${e.label}${c}`,placeholder:l,value:t[i]??"",onChange:f=>a(i,f.target.value)}),s&&x(Xe,{align:"inline-end",children:x(Zo,{children:s})})]});return D(F,{children:[x(_,{htmlFor:r,children:e.label}),D("div",{className:"flex items-center gap-2",children:[n(`${e.id}.gte`,"最小","最小值"),x("span",{className:"text-muted-foreground",children:"至"}),n(`${e.id}.lte`,"最大","最大值")]})]})}case"dateRange":return D(F,{children:[x(_,{htmlFor:r,children:e.label}),D("div",{className:"flex items-center gap-2",children:[x(q,{id:r,type:"date","aria-label":`${e.label}开始`,value:t[`${e.id}.gte`]??"",onChange:s=>a(`${e.id}.gte`,s.target.value)}),x("span",{className:"text-muted-foreground",children:"至"}),x(q,{type:"date","aria-label":`${e.label}结束`,value:t[`${e.id}.lte`]??"",onChange:s=>a(`${e.id}.lte`,s.target.value)})]})]});case"text":return D(F,{children:[x(_,{htmlFor:r,children:e.label}),x(q,{id:r,placeholder:e.placeholder,value:t[e.id]??"",onChange:s=>a(e.id,s.target.value)})]});case"list":return D(F,{children:[x(_,{htmlFor:r,children:e.label}),e.options?x(st,{id:r,placeholder:e.placeholder,value:t[e.id]??"",options:e.options.map(s=>({value:s})),multiple:e.multiple,onChange:s=>a(e.id,s)}):x(q,{id:r,placeholder:e.placeholder,value:t[e.id]??"",onChange:s=>a(e.id,s.target.value)})]});case"flags":{let s=Ka(t[e.id]);return D(F,{children:[x(_,{children:e.label}),x("div",{className:"flex flex-wrap gap-x-4 gap-y-2 pt-1",children:e.options.map(n=>D(lt,{className:"flex items-center gap-2 font-normal",children:[x(_e,{checked:s.includes(n.value),onCheckedChange:i=>a(e.id,Ua(t[e.id],n.value,i===!0))}),n.label]},n.value))})]})}case"bool":case"select":{let s=e.type==="bool"?[{value:"yes",label:"是"},{value:"no",label:"否"}]:e.options,n=e.type==="select"&&e.required,i=n?t[e.id]||s[0]?.value:t[e.id]||"any";return D(F,{children:[x(_,{htmlFor:r,children:e.label}),D(De,{value:i,onValueChange:l=>a(e.id,l==="any"?"":l),children:[x(Ae,{id:r,className:"w-full",children:x(ze,{})}),x(Me,{children:D(ht,{children:[!n&&x(fe,{value:"any",children:"不限"}),s.map(l=>x(fe,{value:l.value,children:l.label},l.value))]})})]})]})}}}function ji({primary:e,more:t,values:a,onChange:o,onSearch:r,onReset:s,loading:n,currency:i,searchLabel:l="查询",searchIcon:c,disabled:f,prepend:T,append:P,note:v}){let[C,h]=Xi(!1),R=(w,Z)=>o({...a,[w]:Z}),y=t.filter(w=>Ha(w).some(Z=>a[Z])).length;return x(It,{children:x(Dt,{children:D("form",{onSubmit:w=>{w.preventDefault(),r()},className:"flex flex-col gap-4",children:[D(ct,{className:Tr,children:[T,e.map(w=>x(Ir,{spec:w,values:a,set:R,currency:i},w.id)),P]}),D($e,{open:C,onOpenChange:h,children:[x(Ke,{children:x(ct,{className:Rr(Tr,"pb-4"),children:t.map(w=>x(Ir,{spec:w,values:a,set:R,currency:i},w.id))})}),D("div",{className:"flex flex-wrap items-center gap-2",children:[D(u,{type:"submit",disabled:n||f,children:[n?x(j,{"data-icon":"inline-start"}):c??x(Ji,{"data-icon":"inline-start"}),l]}),D(u,{type:"button",variant:"outline",onClick:s,children:[x(Yi,{"data-icon":"inline-start"}),"重置"]}),t.length>0&&x(He,{asChild:!0,children:D(u,{type:"button",variant:"ghost",children:["更多条件",y?`(已填 ${y})`:"",x(Qi,{"data-icon":"inline-end",className:Rr("transition-transform",C&&"rotate-180")})]})}),v&&x("p",{className:"text-xs text-muted-foreground sm:ml-auto",children:v})]})]})]})})})}import{Columns3Icon as es}from"lucide-react";import{jsx as Oe,jsxs as zt}from"react/jsx-runtime";function ts({columns:e,visible:t,onChange:a,onReset:o}){return zt(Je,{children:[Oe(je,{asChild:!0,children:zt(u,{variant:"outline",size:"sm",children:[Oe(es,{"data-icon":"inline-start"}),"列设置"]})}),zt(et,{align:"end",className:"max-h-96 w-56 overflow-y-auto",children:[zt(Pt,{children:["显示的列(",t.length,"/",e.length,")"]}),zt(Nt,{children:[Oe(Le,{onSelect:r=>(r.preventDefault(),o()),children:"恢复默认"}),Oe(Le,{onSelect:r=>(r.preventDefault(),a(e.map(s=>s.key))),children:"全部显示"})]}),Oe(Zt,{}),Oe(Nt,{children:e.map(r=>Oe(rr,{checked:t.includes(r.key),onSelect:s=>s.preventDefault(),onCheckedChange:s=>a(s?e.map(n=>n.key).filter(n=>n===r.key||t.includes(n)):t.filter(n=>n!==r.key)),children:r.label},r.key))})]})]})}import{useState as ns}from"react";import{cn as ye}from"cn";import{AlertDialog as we}from"radix-ui";import{jsx as W,jsxs as rs}from"react/jsx-runtime";function Dr({...e}){return W(we.Root,{"data-slot":"alert-dialog",...e})}function as({...e}){return W(we.Portal,{"data-slot":"alert-dialog-portal",...e})}function os({className:e,...t}){return W(we.Overlay,{"data-slot":"alert-dialog-overlay",className:ye("fixed inset-0 z-50 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0",e),...t})}function zr({className:e,size:t="default",...a}){return rs(as,{children:[W(os,{}),W(we.Content,{"data-slot":"alert-dialog-content","data-size":t,className:ye("group/alert-dialog-content fixed top-1/2 left-1/2 z-50 grid w-full -translate-x-1/2 -translate-y-1/2 gap-4 rounded-xl bg-popover p-4 text-popover-foreground ring-1 ring-foreground/10 duration-100 outline-none max-w-[calc(100%-2rem)] sm:max-w-sm data-[size=sm]:sm:max-w-xs data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",e),...a})]})}function Ar({className:e,...t}){return W("div",{"data-slot":"alert-dialog-header",className:ye("grid grid-rows-[auto_1fr] place-items-center gap-1.5 text-center has-data-[slot=alert-dialog-media]:grid-rows-[auto_auto_1fr] has-data-[slot=alert-dialog-media]:gap-x-4 sm:group-data-[size=default]/alert-dialog-content:place-items-start sm:group-data-[size=default]/alert-dialog-content:text-left sm:group-data-[size=default]/alert-dialog-content:has-data-[slot=alert-dialog-media]:grid-rows-[auto_1fr]",e),...t})}function Mr({className:e,...t}){return W("div",{"data-slot":"alert-dialog-footer",className:ye("-mx-4 -mb-4 flex flex-col-reverse gap-2 rounded-b-xl border-t bg-muted/50 p-4 group-data-[size=sm]/alert-dialog-content:grid group-data-[size=sm]/alert-dialog-content:grid-cols-2 sm:flex-row sm:justify-end",e),...t})}function Br({className:e,...t}){return W(we.Title,{"data-slot":"alert-dialog-title",className:ye("font-heading text-base font-medium sm:group-data-[size=default]/alert-dialog-content:group-has-data-[slot=alert-dialog-media]/alert-dialog-content:col-start-2",e),...t})}function Er({className:e,...t}){return W(we.Description,{"data-slot":"alert-dialog-description",className:ye("text-sm text-balance text-muted-foreground md:text-pretty *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground",e),...t})}function Lr({className:e,variant:t="default",size:a="default",...o}){return W(u,{variant:t,size:a,asChild:!0,children:W(we.Action,{"data-slot":"alert-dialog-action",className:ye(e),...o})})}function Fr({className:e,variant:t="outline",size:a="default",...o}){return W(u,{variant:t,size:a,asChild:!0,children:W(we.Cancel,{"data-slot":"alert-dialog-cancel",className:ye(e),...o})})}import{jsx as ve,jsxs as ia}from"react/jsx-runtime";function Fa({open:e,onOpenChange:t,title:a,description:o,details:r,requireCheck:s,confirmLabel:n="确认",cancelLabel:i="取消",destructive:l,busy:c,onConfirm:f}){let[T,P]=ns(!1),v=!!s&&!T;return ve(Dr,{open:e,onOpenChange:C=>{C||P(!1),t(C)},children:ia(zr,{children:[ia(Ar,{children:[ve(Br,{children:a}),o&&ve(Er,{children:o})]}),r?.length?ve("ul",{className:"list-disc space-y-1 pl-5 text-sm text-muted-foreground",children:r.map((C,h)=>ve("li",{children:C},h))}):null,s&&ia(lt,{className:"flex items-start gap-2 text-sm font-normal",children:[ve(_e,{checked:T,onCheckedChange:C=>P(C===!0),className:"mt-0.5"}),ve("span",{children:s})]}),ia(Mr,{children:[ve(Fr,{children:i}),ve(Lr,{variant:l?"destructive":void 0,disabled:c||v,onClick:C=>{C.preventDefault(),!v&&f()},children:n})]})]})})}import{useCallback as us,useEffect as fs,useState as K}from"react";import{PencilIcon as gs,PlusIcon as bs,PowerIcon as vs,RotateCcwIcon as xs,SearchIcon as hs,Trash2Icon as Cs}from"lucide-react";import{toast as pt}from"sonner";import{cva as is}from"class-variance-authority";import{cn as _a}from"cn";import{jsx as Ga}from"react/jsx-runtime";var ss=is("group/alert relative grid w-full gap-0.5 rounded-lg border px-2.5 py-2 text-left text-sm has-data-[slot=alert-action]:relative has-data-[slot=alert-action]:pr-18 has-[>svg]:grid-cols-[auto_1fr] has-[>svg]:gap-x-2 *:[svg]:row-span-2 *:[svg]:translate-y-0.5 *:[svg]:text-current *:[svg:not([class*='size-'])]:size-4",{variants:{variant:{default:"bg-card text-card-foreground",destructive:"bg-card text-destructive *:data-[slot=alert-description]:text-destructive/90 *:[svg]:text-current"}},defaultVariants:{variant:"default"}});function _r({className:e,variant:t,...a}){return Ga("div",{"data-slot":"alert",role:"alert",className:_a(ss({variant:t}),e),...a})}function Gr({className:e,...t}){return Ga("div",{"data-slot":"alert-title",className:_a("font-medium group-has-[>svg]/alert:col-start-2 [&_a]:underline [&_a]:underline-offset-3 [&_a]:hover:text-foreground",e),...t})}function Or({className:e,...t}){return Ga("div",{"data-slot":"alert-description",className:_a("text-sm text-balance text-muted-foreground md:text-pretty [&_a]:underline [&_a]:underline-offset-3 [&_a]:hover:text-foreground [&_p:not(:last-child)]:mb-4",e),...t})}import{cva as ls}from"class-variance-authority";import{cn as ds}from"cn";import{Slot as cs}from"radix-ui";import{jsx as ms}from"react/jsx-runtime";var ps=ls("group/badge inline-flex h-5 w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-4xl border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-all focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3!",{variants:{variant:{default:"bg-primary text-primary-foreground [a]:hover:bg-primary/80",secondary:"bg-secondary text-secondary-foreground [a]:hover:bg-secondary/80",destructive:"bg-destructive/10 text-destructive focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:focus-visible:ring-destructive/40 [a]:hover:bg-destructive/20",outline:"border-border text-foreground [a]:hover:bg-muted [a]:hover:text-muted-foreground",ghost:"hover:bg-muted hover:text-muted-foreground dark:hover:bg-muted/50",link:"text-primary underline-offset-4 hover:underline"}},defaultVariants:{variant:"default"}});function sa({className:e,variant:t="default",asChild:a=!1,...o}){let r=a?cs.Root:"span";return ms(r,{"data-slot":"badge","data-variant":t,className:ds(ps({variant:t}),e),...o})}import{jsx as d,jsxs as b}from"react/jsx-runtime";var Vr=[{value:"手动添加"},{value:"侵权投诉"},{value:"商标库"},{value:"平台通知"},{value:"行业经验"}],At={word:"",cnName:"",status:"all",source:""},oe=e=>e==null?"":String(e);function ys({kind:e,description:t}){let a=ua[e],o=Lt(),[r,s]=K(),[n,i]=K(""),[l,c]=K(At),[f,T]=K(At),[P,v]=K(1),[C,h]=K([]),[R,y]=K(0),[w,Z]=K(!1),[Ne,ce]=K(null),[J,mt]=K(null),[ut,pe]=K(),me=us(async(m,I,z)=>{let xe=Se();if(!xe)throw new Error("多维表客户端尚未初始化");let re=[];I.word.trim()&&re.push({fieldName:"词条",operator:"contains",value:I.word.trim()}),I.cnName.trim()&&re.push({fieldName:"中文名",operator:"contains",value:I.cnName.trim()}),I.status!=="all"&&re.push({fieldName:"状态",operator:"is",value:I.status}),I.source.trim()&&re.push({fieldName:"来源",operator:"contains",value:I.source.trim()}),T(I),Z(!0);try{let B=Zr=>xe.listRecords({tableId:m,page:Zr,perPage:Tt,fieldNames:["词条","中文名","状态","来源","创建时间"],filter:re.length?{conjunction:"and",conditions:re}:void 0}),Pe=await B(z),ke=Math.max(1,Math.ceil(Pe.total/Tt));z>ke&&(z=ke,Pe=await B(z)),v(z),h(Pe.records),y(Pe.total)}catch(B){pt.error(`查询失败:${ue(B)}`)}finally{Z(!1)}},[]);fs(()=>{try{eo().ensureWordTable(e).then(m=>(s(m.tableId),me(m.tableId,At,1))).catch(m=>i(ue(m)))}catch(m){i(ue(m))}},[e,me]);let ft=()=>r?me(r,f,P):Promise.resolve(),da=m=>{m?.preventDefault(),r&&me(r,{...l},1)},Va=()=>{c(At),r&&me(r,At,1)},ca=async m=>{let I=Se();if(!r||!I)return;let z=m.fields.状态==="启用"?"禁用":"启用";pe(m.recordId);try{await I.updateRecords(r,[{recordId:m.recordId,fields:{状态:z}}]),pt.success(`已${z}「${oe(m.fields.词条)}」`),await ft()}catch(xe){pt.error(ue(xe))}finally{pe(void 0)}},g=async()=>{let m=Se();if(!(!r||!J||!m)){pe(J.recordId);try{await m.deleteRecords(r,[J.recordId]),pt.success(`已删除「${oe(J.fields.词条)}」`),mt(null),await ft()}catch(I){pt.error(ue(I))}finally{pe(void 0)}}};return n?b(_r,{variant:"destructive",children:[b(Gr,{children:["无法打开",a,"表"]}),d(Or,{children:n})]}):b("div",{className:"flex flex-col gap-4",children:[b("div",{children:[d("h1",{className:"text-lg font-semibold",children:a}),d("p",{className:"text-sm text-muted-foreground",children:t})]}),d(It,{children:d(Dt,{children:b("form",{onSubmit:da,children:[b(ct,{className:"grid grid-cols-1 gap-4 sm:grid-cols-2 xl:grid-cols-4",children:[b(F,{children:[d(_,{htmlFor:`${e}-q-word`,children:"词条"}),d(q,{id:`${e}-q-word`,value:l.word,placeholder:"包含",onChange:m=>c({...l,word:m.target.value})})]}),b(F,{children:[d(_,{htmlFor:`${e}-q-cn`,children:"中文名"}),d(q,{id:`${e}-q-cn`,value:l.cnName,placeholder:"包含",onChange:m=>c({...l,cnName:m.target.value})})]}),b(F,{children:[d(_,{htmlFor:`${e}-q-status`,children:"状态"}),b(De,{value:l.status,onValueChange:m=>c({...l,status:m}),children:[d(Ae,{id:`${e}-q-status`,className:"w-full",children:d(ze,{})}),d(Me,{children:b(ht,{children:[d(fe,{value:"all",children:"全部"}),ma.map(m=>d(fe,{value:m,children:m},m))]})})]})]}),b(F,{children:[d(_,{htmlFor:`${e}-q-source`,children:"来源"}),d(st,{id:`${e}-q-source`,value:l.source,options:Vr,onChange:m=>c({...l,source:m})})]})]}),b("div",{className:"mt-4 flex flex-wrap gap-2",children:[b(u,{type:"submit",disabled:!r||w,children:[d(hs,{"data-icon":"inline-start"}),"查询"]}),b(u,{type:"button",variant:"outline",onClick:Va,children:[d(xs,{"data-icon":"inline-start"}),"重置"]}),b(u,{type:"button",variant:"secondary",className:"sm:ml-auto",disabled:!r,onClick:()=>ce("new"),children:[d(bs,{"data-icon":"inline-start"}),"新增",a]})]})]})})}),d(It,{children:b(Dt,{className:"flex flex-col gap-4",children:[b(jt,{children:[d(ea,{children:b(be,{children:[d(te,{children:"词条"}),d(te,{children:"中文名"}),d(te,{children:"状态"}),d(te,{children:"来源"}),d(te,{children:"创建时间"}),d(te,{className:"sticky right-0 bg-background text-right",children:"操作"})]})}),d(ta,{children:(w||!r)&&C.length===0?Array.from({length:5},(m,I)=>d(be,{children:d(H,{colSpan:6,children:d(_t,{className:"h-6 w-full"})})},I)):C.map(m=>b(be,{className:w?"opacity-60":void 0,children:[d(H,{className:"font-medium",children:oe(m.fields.词条)}),d(H,{children:oe(m.fields.中文名)||"-"}),d(H,{children:d(sa,{variant:m.fields.状态==="启用"?"default":"secondary",children:oe(m.fields.状态)||"-"})}),d(H,{children:oe(m.fields.来源)||"-"}),d(H,{className:"whitespace-nowrap",children:oo(m.fields.创建时间,o)}),d(H,{className:"sticky right-0 bg-background",children:b("div",{className:"flex justify-end gap-1",children:[b(u,{variant:"ghost",size:"sm",onClick:()=>ce(m),children:[d(gs,{"data-icon":"inline-start"}),"修改"]}),b(u,{variant:"ghost",size:"sm",disabled:ut===m.recordId,onClick:()=>ca(m),children:[ut===m.recordId?d(j,{"data-icon":"inline-start"}):d(vs,{"data-icon":"inline-start"}),m.fields.状态==="启用"?"禁用":"启用"]}),b(u,{variant:"ghost",size:"sm",onClick:()=>mt(m),children:[d(Cs,{"data-icon":"inline-start"}),"删除"]})]})})]},m.recordId))})]}),!w&&r&&C.length===0&&d(qt,{children:b(Xt,{children:[b(Qt,{children:["暂无",a]}),b(Yt,{children:["点击「新增",a,"」添加第一条词条。"]})]})}),d(La,{page:P,total:R,disabled:w,onChange:m=>r&&me(r,f,m)})]})}),Ne&&r&&d(ws,{kind:e,tableId:r,record:Ne==="new"?null:Ne,onClose:()=>ce(null),onSaved:()=>{ce(null),ft()}}),d(Fa,{open:!!J,onOpenChange:m=>!m&&mt(null),title:`删除${a}「${oe(J?.fields.词条)}」?`,description:"删除后无法恢复。只想暂时不用的话,可以改为「禁用」。",confirmLabel:"删除",destructive:!0,busy:ut===J?.recordId,onConfirm:g})]})}function ws({kind:e,tableId:t,record:a,onClose:o,onSaved:r}){let s=ua[e],[n,i]=K({词条:oe(a?.fields.词条),中文名:oe(a?.fields.中文名),状态:oe(a?.fields.状态)||"启用",来源:oe(a?.fields.来源)||(a?"":"手动添加")}),[l,c]=K(""),[f,T]=K(!1);return d(Go,{open:!0,onOpenChange:v=>!v&&o(),children:d(Oo,{className:"flex max-h-[90svh] flex-col",children:b("form",{onSubmit:async v=>{v.preventDefault();let C=Se();if(!C){c("多维表客户端尚未初始化");return}let h=n.词条.trim();if(!h){c("请输入词条");return}T(!0),c("");try{if((await C.listRecords({tableId:t,perPage:5,fieldNames:["词条"],filter:{conditions:[{fieldName:"词条",operator:"is",value:h}]}})).records.some(w=>w.recordId!==a?.recordId)){c(`「${h}」已存在`);return}let y={...n,词条:h,中文名:n.中文名.trim(),来源:n.来源.trim()};a?await C.updateRecords(t,[{recordId:a.recordId,fields:y}]):await C.createRecords(t,[{...y,创建时间:new Date().toISOString()}]),pt.success(a?"已保存修改":`已新增${s}「${h}」`),r()}catch(R){c(ue(R))}finally{T(!1)}},className:"flex min-h-0 flex-1 flex-col gap-4",children:[b(Vo,{children:[d(Ho,{children:a?`修改${s}`:`新增${s}`}),d(Ko,{children:"启用状态的词条会在「添加到选品库」时用于过滤商品。"})]}),d("div",{className:"-mx-4 min-h-0 flex-1 overflow-y-auto overscroll-contain px-4",children:b(ct,{children:[b(F,{"data-invalid":l?!0:void 0,children:[d(_,{htmlFor:"word-term",children:"词条"}),d(q,{id:"word-term",autoFocus:!0,value:n.词条,"aria-invalid":l?!0:void 0,onChange:v=>i({...n,词条:v.target.value})}),l&&d(Sr,{children:l})]}),b(F,{children:[d(_,{htmlFor:"word-cn",children:"中文名"}),d(q,{id:"word-cn",value:n.中文名,onChange:v=>i({...n,中文名:v.target.value})})]}),b(F,{children:[d(_,{htmlFor:"word-status",children:"状态"}),b(De,{value:n.状态,onValueChange:v=>i({...n,状态:v}),children:[d(Ae,{id:"word-status",className:"w-full",children:d(ze,{})}),d(Me,{children:d(ht,{children:ma.map(v=>d(fe,{value:v,children:v},v))})})]})]}),b(F,{children:[d(_,{htmlFor:"word-source",children:"来源"}),d(st,{id:"word-source",value:n.来源,options:Vr,onChange:v=>i({...n,来源:v})})]})]})}),b($o,{children:[d(u,{type:"button",variant:"outline",onClick:o,children:"取消"}),b(u,{type:"submit",disabled:f,children:[f&&d(j,{"data-icon":"inline-start"}),"保存"]})]})]})})})}import{cn as Ns}from"cn";import{jsx as O,jsxs as le}from"react/jsx-runtime";var Ps={已完成:"border-emerald-600/40 bg-emerald-600/10 text-emerald-700 dark:text-emerald-400",需人工处理:"border-amber-600/40 bg-amber-600/10 text-amber-700 dark:text-amber-400",失败:"border-destructive/40 bg-destructive/10 text-destructive"};function ks({task:e,running:t,onOpen:a,onStop:o,onRetry:r,className:s}){let n=e.budget&&(e.budget.used>0||e.budget.estimate)?e.budget.estimate?`${e.budget.used} / ${e.budget.estimate}${e.budget.unit??""}`:`${e.budget.used}${e.budget.unit??""}`:void 0;return le("div",{className:Ns("rounded-lg border p-3",s),children:[le("div",{className:"flex flex-wrap items-center gap-2",children:[O("button",{type:"button",className:"min-w-0 flex-1 truncate text-left font-medium text-primary underline-offset-4 hover:underline",onClick:a,children:e.code}),O(sa,{variant:"outline",className:Ps[e.status]??"",children:e.status||"—"})]}),(e.stage||e.hint)&&O("p",{className:"mt-1 text-xs text-muted-foreground",children:[e.stage,e.hint].filter(Boolean).join(" · ")}),e.stages?.length?O("div",{className:"mt-2 flex flex-wrap gap-1",children:e.stages.map(i=>le("span",{className:"rounded border px-1.5 py-0.5 text-xs tabular-nums",title:i.label,children:[i.label," ",i.pass,"/",i.input,i.todo?le("span",{className:"text-amber-600 dark:text-amber-400",children:[" +",i.todo]}):null]},i.key))}):null,le("dl",{className:"mt-2 grid grid-cols-2 gap-x-3 gap-y-1 text-xs text-muted-foreground",children:[n&&le("div",{className:"flex justify-between gap-2",children:[O("dt",{children:"算力"}),O("dd",{className:"tabular-nums",children:n})]}),e.rounds!=null&&le("div",{className:"flex justify-between gap-2",children:[O("dt",{children:"轮次"}),O("dd",{className:"tabular-nums",children:e.rounds})]}),e.startedAt&&le("div",{className:"flex justify-between gap-2",children:[O("dt",{children:"开始"}),O("dd",{className:"tabular-nums",children:e.startedAt})]}),e.lastActiveAt&&le("div",{className:"flex justify-between gap-2",children:[O("dt",{children:"最后活动"}),O("dd",{className:"tabular-nums",children:e.lastActiveAt})]})]}),le("div",{className:"mt-2 flex flex-wrap gap-1",children:[a&&O(u,{variant:"ghost",size:"sm",onClick:a,children:"查看"}),t&&o&&O(u,{variant:"ghost",size:"sm",onClick:o,children:"停止"}),r&&O(u,{variant:"ghost",size:"sm",onClick:r,children:"重试未完成"})]})]})}import{useEffect as Kr,useRef as Ts,useState as Is}from"react";import{CheckIcon as Ds,CopyIcon as zs}from"lucide-react";import{cn as $r}from"cn";import{ScrollArea as Mt}from"radix-ui";import{jsx as Bt,jsxs as Rs}from"react/jsx-runtime";function Hr({className:e,children:t,...a}){return Rs(Mt.Root,{"data-slot":"scroll-area",className:$r("relative",e),...a,children:[Bt(Mt.Viewport,{"data-slot":"scroll-area-viewport",className:"size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1",children:t}),Bt(Ss,{}),Bt(Mt.Corner,{})]})}function Ss({className:e,orientation:t="vertical",...a}){return Bt(Mt.ScrollAreaScrollbar,{"data-slot":"scroll-area-scrollbar","data-orientation":t,orientation:t,className:$r("flex touch-none p-px transition-colors select-none data-horizontal:h-2.5 data-horizontal:flex-col data-horizontal:border-t data-horizontal:border-t-transparent data-vertical:h-full data-vertical:w-2.5 data-vertical:border-l data-vertical:border-l-transparent",e),...a,children:Bt(Mt.ScrollAreaThumb,{"data-slot":"scroll-area-thumb",className:"relative flex-1 rounded-full bg-border"})})}import{jsx as Ve,jsxs as la}from"react/jsx-runtime";var As=/^\[(\d{4}-\d{2}-\d{2}T[\d:.]+Z)\]/;function Ms(e,t){let a=e.match(As);if(!a)return e;let o=new Date(a[1]);return Number.isNaN(o.getTime())?e:`[${new Intl.DateTimeFormat("zh-CN",{timeZone:t,month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}).format(o)}]${e.slice(a[0].length)}`}function Bs({text:e,timeZone:t,className:a}){let o=String(e??"").trim(),r=o?o.split(`
|
|
2
|
+
`).map(c=>Ms(c,t)):[],s=Ts(null),[n,i]=Is(!1);Kr(()=>{s.current?.scrollIntoView({block:"nearest"})},[o]),Kr(()=>{if(!n)return;let c=setTimeout(()=>i(!1),1500);return()=>clearTimeout(c)},[n]);async function l(){try{await navigator.clipboard.writeText(r.join(`
|
|
3
|
+
`)),i(!0)}catch{}}return la("section",{className:a,children:[la("div",{className:"mb-2 flex flex-wrap items-center gap-2",children:[Ve("h3",{className:"text-sm font-medium",children:"工作流执行日志"}),Ve("span",{className:"text-xs text-muted-foreground",children:"保留最近 50 条 · 时间按所选时区"}),o&&la(u,{variant:"ghost",size:"sm",className:"ml-auto",onClick:()=>{l()},children:[n?Ve(Ds,{"data-icon":"inline-start"}):Ve(zs,{"data-icon":"inline-start"}),n?"已复制":"复制"]})]}),o?la(Hr,{className:"h-56 rounded border bg-muted/40",children:[Ve("pre",{className:"whitespace-pre-wrap break-words p-3 text-xs leading-relaxed",children:r.join(`
|
|
4
|
+
`)}),Ve("div",{ref:s})]}):Ve("p",{className:"rounded border border-dashed p-3 text-xs text-muted-foreground",children:"暂无执行日志"})]})}import{CheckIcon as Es,ChevronRightIcon as Ur,LoaderIcon as Ls,SettingsIcon as Fs}from"lucide-react";import{cn as Oa}from"cn";import{jsx as G,jsxs as de}from"react/jsx-runtime";var _s={done:"bg-emerald-600 text-white border-emerald-600",active:"bg-primary text-primary-foreground border-primary",idle:"bg-muted text-muted-foreground border-border"};function Wr(e){return e.input===0||e.input===e.pass+e.fail+e.todo}function Gs({startLabel:e="启动条件",startSummary:t,stages:a,countsOf:o,stateOf:r,current:s,onSelect:n,tail:i}){return de("div",{className:"flex flex-col gap-2 lg:flex-row lg:items-stretch",children:[de("div",{className:"flex min-w-0 items-center gap-2 rounded border bg-muted/40 px-3 py-2 lg:shrink-0",children:[G("span",{className:"flex size-6 shrink-0 items-center justify-center rounded-full border bg-background",children:G(Fs,{className:"size-3.5"})}),de("div",{className:"min-w-0",children:[G("p",{className:"text-sm font-medium",children:e}),G("p",{className:"truncate text-xs text-muted-foreground",children:t})]})]}),a.map((l,c)=>{let f=r(l.key),T=o(l.key),P=s===l.key,v=Wr(T);return de("div",{className:"flex min-w-0 items-stretch gap-2 lg:shrink-0",children:[G(Ur,{className:"hidden size-4 shrink-0 self-center text-muted-foreground lg:block"}),de(u,{variant:P?"secondary":"ghost",onClick:()=>n(l.key),"aria-pressed":P,className:Oa("h-auto w-full min-w-0 justify-start gap-2 border px-3 py-2 text-left lg:w-auto lg:min-w-40",P&&"border-primary"),children:[G("span",{className:Oa("flex size-6 shrink-0 items-center justify-center rounded-full border text-xs",_s[f]),children:f==="done"?G(Es,{className:"size-3.5"}):f==="active"?G(Ls,{className:"size-3.5 animate-spin"}):c+1}),de("span",{className:"min-w-0 flex-1",children:[G("span",{className:"block text-sm font-medium",children:l.label}),de("span",{className:"block text-xs tabular-nums text-muted-foreground",children:["输入 ",T.input," · 通过 ",G("span",{className:"text-emerald-600 dark:text-emerald-400",children:T.pass})," · 不通过"," ",T.fail," · 未完成 ",G("span",{className:Oa(T.todo>0&&"text-amber-600 dark:text-amber-400"),children:T.todo})]}),!v&&G("span",{className:"block text-xs text-amber-600 dark:text-amber-400",children:"数不平,正在执行中"})]})]})]},l.key)}),i&&de("div",{className:"flex min-w-0 items-stretch gap-2 lg:shrink-0",children:[G(Ur,{className:"hidden size-4 shrink-0 self-center text-muted-foreground lg:block"}),de("div",{className:"flex min-w-0 items-center gap-2 rounded border bg-muted/40 px-3 py-2 lg:min-w-32",children:[G("span",{className:"flex size-6 shrink-0 items-center justify-center rounded-full border bg-background",children:i.icon}),de("div",{className:"min-w-0",children:[G("p",{className:"text-sm font-medium",children:i.label}),G("p",{className:"text-xs tabular-nums text-muted-foreground",children:i.summary})]})]})]})]})}export{Sa as AgentPanel,Ra as AgentToggle,yi as AppShell,ya as AppSidebar,Ri as AuthGate,ts as ColumnPicker,st as ComboInput,Fa as ConfirmDialog,La as DataPagination,Fi as DataTable,ji as FilterPanel,wa as Markdown,Tt as PAGE_SIZE,Gs as StageProgress,ks as TaskCard,Bs as TaskLog,Di as ThemeProvider,Da as TimezoneSelect,za as UserMenu,ys as WordManager,Wr as countsBalanced,gt as findNav};
|
package/dist/react/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { A as AuthState } from '../auth-
|
|
2
|
-
export { a as authIdentity, g as getApiKey, b as getAuthState, h as handleGatewayError, i as initialAuthState, l as loadApiKey, c as login, d as logout, m as maskApiKey, s as startAuth, e as subscribeAuth } from '../auth-
|
|
1
|
+
import { A as AuthState } from '../auth-RGVm8hmz.js';
|
|
2
|
+
export { a as authIdentity, g as getApiKey, b as getAuthState, h as handleGatewayError, i as initialAuthState, l as loadApiKey, c as login, d as logout, m as maskApiKey, s as startAuth, e as subscribeAuth } from '../auth-RGVm8hmz.js';
|
|
3
3
|
import * as react from 'react';
|
|
4
4
|
|
|
5
5
|
/** 登录态:与 runtime 的状态机共用同一份订阅 */
|
package/dist/react/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{a as n,b as s,c as u,d as a,e as b,f as d,g,h,i as j,j as k,k as q,l as v,m as w,n as y}from"../chunk-
|
|
1
|
+
"use client";import{a as n,b as s,c as u,d as a,e as b,f as d,g,h,i as j,j as k,k as q,l as v,m as w,n as y}from"../chunk-SJFNXBPH.js";import{o,p as r,q as e,r as t,s as f,t as m,u as p,v as x,w as c,x as i,y as l}from"../chunk-7K2XKPOX.js";export{j as AGENT_DONE_EVENT,k as AgentProvider,t as authIdentity,s as browserTimeZone,w as buildAgentPrompt,h as formatDateTime,l as getApiKey,r as getAuthState,c as handleGatewayError,e as initialAuthState,m as loadApiKey,p as login,x as logout,i as maskApiKey,u as setTimeZone,f as startAuth,o as subscribeAuth,d as timeZoneOffset,y as truncate,q as useAgent,v as useAgentPageContext,n as useAuth,b as useIsBrowserTimeZone,a as useTimeZone,g as zonedDayStart};
|
package/dist/runtime/index.d.ts
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { LinkfoxHttpError } from '@linkfox-web/http';
|
|
2
|
-
export { F as FilterValues, N as NavGroup, a as NavItem, U as UiFilterSpec,
|
|
3
|
-
|
|
4
|
-
import { FieldInput, NotebookInfo as NotebookInfo$1, TableInfo as TableInfo$1, RecordFilter, SmartRecord } from '@linkfox-web/ai-tools/smart-table';
|
|
5
|
-
export { Attachment, FieldInfo, FieldType, FilterCondition, ListRecordsResult as ListRecordsResponse, RecordFilter, SmartRecord } from '@linkfox-web/ai-tools/smart-table';
|
|
6
|
-
export { A as AuthState, a as authIdentity, g as getApiKey, b as getAuthState, h as handleGatewayError, i as initialAuthState, l as loadApiKey, c as login, d as logout, m as maskApiKey, s as startAuth, e as subscribeAuth } from '../auth-JoGZ-Tg-.js';
|
|
2
|
+
export { b as FieldDef, F as FilterValues, N as NavGroup, a as NavItem, c as NotebookInfo, S as SmartTable, d as SmartTableConfig, e as SmartTableFieldDef, T as TableInfo, U as UiFilterSpec, g as WORD_FIELDS, h as WORD_KIND_LABEL, i as WORD_STATUS, j as WordHit, W as WordTableKey, k as activeSmartTable, l as activeWordTables, m as attachmentUrl, n as buildWordMatcher, o as createSmartTable, p as createWordTables, q as filterKeys, f as findNav, r as firstAttachment, s as flagList, t as isAttachmentList, u as nowIso, v as num, w as setActiveSmartTable, x as splitList, y as str, z as toggleFlag } from '../word-tables-B3Zc1OiL.js';
|
|
3
|
+
export { A as AuthState, a as authIdentity, g as getApiKey, b as getAuthState, h as handleGatewayError, i as initialAuthState, l as loadApiKey, c as login, d as logout, m as maskApiKey, s as startAuth, e as subscribeAuth } from '../auth-RGVm8hmz.js';
|
|
7
4
|
export { cn } from 'cn';
|
|
5
|
+
export { Attachment, FieldInfo, FieldType, FilterCondition, ListRecordsResult as ListRecordsResponse, RecordFilter, SmartRecord } from '@linkfox-web/ai-tools/smart-table';
|
|
8
6
|
import 'lucide-react';
|
|
9
7
|
|
|
10
8
|
/**
|
|
@@ -125,87 +123,6 @@ declare function runTask(prompt: string, modelId: string, { signal, onUpdate, se
|
|
|
125
123
|
sessionId?: string;
|
|
126
124
|
}): Promise<TaskView>;
|
|
127
125
|
|
|
128
|
-
type FieldDef = FieldInput;
|
|
129
|
-
type NotebookInfo = NotebookInfo$1;
|
|
130
|
-
/** 模板 `linkfox.config.ts` 的 `smartTableConfig` 结构(多数字段来自 `config/smart-table.json`) */
|
|
131
|
-
interface SmartTableFieldDef {
|
|
132
|
-
name: string;
|
|
133
|
-
type: string;
|
|
134
|
-
[key: string]: unknown;
|
|
135
|
-
}
|
|
136
|
-
interface SmartTableConfig {
|
|
137
|
-
/** 多维表(容器)名称 */
|
|
138
|
-
notebookName: string;
|
|
139
|
-
/** 多维表 id(nbk 开头):构建期由 NEXT_PUBLIC_NOTE_BOOK_ID 指定,留空则按名称查找 */
|
|
140
|
-
notebookId?: string;
|
|
141
|
-
/** 建多维表时的幂等键前缀,按应用区分 */
|
|
142
|
-
requestKeyPrefix?: string;
|
|
143
|
-
/** 数据表名称:key → 表名 */
|
|
144
|
-
tables: Record<string, string>;
|
|
145
|
-
/** 各数据表的列定义:ensureTable 建表/补列时使用 */
|
|
146
|
-
fields?: Record<string, readonly SmartTableFieldDef[]>;
|
|
147
|
-
}
|
|
148
|
-
/** 数据表信息 + 字段名 → fieldId(工作流触发条件要用) */
|
|
149
|
-
interface TableInfo extends TableInfo$1 {
|
|
150
|
-
fieldIds: Record<string, string>;
|
|
151
|
-
}
|
|
152
|
-
/**
|
|
153
|
-
* 按模板的 `smartTableConfig` 建一套多维表客户端。
|
|
154
|
-
*
|
|
155
|
-
* 用工厂而不是模块级单例:包不能读宿主的环境变量,表结构也只能由模板注入。
|
|
156
|
-
* 模板的 `lib/app-kit.ts` 里 `setActiveSmartTable(createSmartTable(smartTableConfig))`,
|
|
157
|
-
* 包内组件(如 LinkFox OS 助手)通过 `activeSmartTable()` 拿到同一个实例。
|
|
158
|
-
*/
|
|
159
|
-
declare function createSmartTable<C extends SmartTableConfig>(config: C): {
|
|
160
|
-
config: C;
|
|
161
|
-
TABLE_FIELDS: Record<string, st.FieldInput[]>;
|
|
162
|
-
getNotebook: () => Promise<st.NotebookInfo>;
|
|
163
|
-
ensureTable: (key: string, fields?: FieldDef[]) => Promise<TableInfo>;
|
|
164
|
-
listRecords: (params: {
|
|
165
|
-
tableId: string;
|
|
166
|
-
page?: number;
|
|
167
|
-
perPage?: number;
|
|
168
|
-
fieldNames?: string[];
|
|
169
|
-
filter?: RecordFilter;
|
|
170
|
-
}) => Promise<st.ListRecordsResult>;
|
|
171
|
-
listAllRecords: (params: {
|
|
172
|
-
tableId: string;
|
|
173
|
-
fieldNames?: string[];
|
|
174
|
-
filter?: RecordFilter;
|
|
175
|
-
}, maxPages?: number) => Promise<st.SmartRecord[]>;
|
|
176
|
-
createRecords: (tableId: string, rows: Record<string, unknown>[]) => Promise<st.SmartRecord[]>;
|
|
177
|
-
updateRecords: (tableId: string, records: SmartRecord[]) => Promise<void>;
|
|
178
|
-
deleteRecords: (tableId: string, recordIds: string[]) => Promise<void>;
|
|
179
|
-
uploadAttachment: (tableId: string, recordId: string, fieldName: string, imageUrl: string) => Promise<st.Attachment>;
|
|
180
|
-
getRecord: (tableId: string, primaryField: string, primaryValue: string, recordId: string, fieldNames?: string[]) => Promise<st.SmartRecord | null>;
|
|
181
|
-
warmTables: () => Promise<TableInfo[]>;
|
|
182
|
-
tableIdOf: (key: string) => Promise<string>;
|
|
183
|
-
};
|
|
184
|
-
type SmartTable = ReturnType<typeof createSmartTable>;
|
|
185
|
-
/** 模板在 `lib/app-kit.ts` 里注册;包内组件用它读写多维表 */
|
|
186
|
-
declare function setActiveSmartTable(client: SmartTable): void;
|
|
187
|
-
/**
|
|
188
|
-
* 没注册时返回 undefined,而不是抛错:包内组件(如助手面板)据此跳过需要多维表的功能,
|
|
189
|
-
* 模板漏了 `import "@/lib/app-kit"` 时页面不会整块崩掉。
|
|
190
|
-
*/
|
|
191
|
-
declare function activeSmartTable(): SmartTable | undefined;
|
|
192
|
-
declare function isAttachmentList(v: unknown): v is st.Attachment[];
|
|
193
|
-
/** 附件 cell 的第一项(附件列是数组,业务上主图只存一张) */
|
|
194
|
-
declare function firstAttachment(v: unknown): st.Attachment | undefined;
|
|
195
|
-
/**
|
|
196
|
-
* 附件 cell 的临时访问地址。
|
|
197
|
-
* 地址由多维表每次读取时重签(约 3 小时有效),所以只能在渲染 / 调用接口的当下取,不要存。
|
|
198
|
-
* prefer=thumb 取缩略图(列表用),full 取原图(生图 / 生文输入用)。
|
|
199
|
-
*/
|
|
200
|
-
declare function attachmentUrl(v: unknown, prefer?: "thumb" | "full"): string | undefined;
|
|
201
|
-
/** 单元格取值工具 */
|
|
202
|
-
declare const str: (v: unknown) => string;
|
|
203
|
-
declare const num: (v: unknown) => number;
|
|
204
|
-
/** 逗号 / 换行分隔的文本列 → 数组 */
|
|
205
|
-
declare const splitList: (v: unknown) => string[];
|
|
206
|
-
/** 多维表 date 列写入用 */
|
|
207
|
-
declare const nowIso: () => string;
|
|
208
|
-
|
|
209
126
|
/**
|
|
210
127
|
* 工作流身份判定:**不靠名字**认「这条流是不是我这条模板流」。
|
|
211
128
|
*
|
|
@@ -301,4 +218,4 @@ declare function isTriggerLinked(links: IRegisteredWorkflow[] | null, flowId: st
|
|
|
301
218
|
*/
|
|
302
219
|
declare function initLinkfoxSdk(): void;
|
|
303
220
|
|
|
304
|
-
export { AGENT_MODELS, type AppKitConfig, type
|
|
221
|
+
export { AGENT_MODELS, type AppKitConfig, type IClaimableFlow, type IRegisteredWorkflow, type IWorkflowClaim, LinkfoxError, SESSION_EXPIRED_MESSAGE, type TaskFile, type TaskStep, type TaskView, appKitConfig, cancelTask, claimWorkflows, configureAppKit, currentNotebookId, errorMessage, gateway, getApplicationId, getConfiguredApiKey, getShareUrl, initLinkfoxSdk, isAbortError, isApiKeyInvalid, isBalanceError, isSessionExpired, isTriggerLinked, keyOf, listRegisteredWorkflows, recordVisit, runTask, sleep, withWorkflowKey };
|
package/dist/runtime/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as S,b as K,c as O,d as z,e as p,f as M,g as Q,h as V,i as X,j as Z,k as ee,l as w,m as te,n as re,o as oe,p as ne,q as ie,r as se,s as le}from"../chunk-
|
|
1
|
+
import{a as S,b as K,c as O,d as z,e as p,f as M,g as Q,h as V,i as X,j as Z,k as ee,l as w,m as te,n as re,o as oe,p as ne,q as ie,r as se,s as le,t as fe,u as ae,v as de,w as ce,x as me,y as ue}from"../chunk-2YASMNNJ.js";import{a as b,b as T,c as W,d as h,e as C,f as R,g as $,h as F,i as L,j as B,k as N,l as D,m as E,n as I,o as P,p as j,q as v,r as A,s as J,t as U,u as Y,v as _,w as q,x as G,y as H}from"../chunk-7K2XKPOX.js";import*as g from"@linkfox-web/ai-tools/smart-table";var a=/key=([a-z0-9][a-z0-9-]*)/i;function y(e){let t=a.exec(e.description??"")?.[1];if(t)return t.toLowerCase();try{let r=JSON.parse(e.flowData??"{}");return a.exec(r.description??"")?.[1]?.toLowerCase()}catch{return}}function ge(e,t){if(a.test(e))return e;let r=e.trim();return r?`${r};key=${t}`:`key=${t}`}function xe(){return w()?.config.notebookId||void 0}async function ke(e){if(!e)return null;try{return((await p(g.listWorkflows({notebookId:e}))).workflows??[]).map(r=>({flowId:r.flowId,tableId:r.tableId??null}))}catch{return null}}function Ie(e){let{notebookId:t,names:r,flows:x,links:d}=e,c=d?new Set(d.map(n=>n.flowId)):null,i={};for(let[n,s]of Object.entries(r)){let k=t?`${s} (${t})`:s,m=o=>o.name===k,u=x.filter(o=>(c?.has(o.id)??!1)||m(o)),l=u.filter(o=>y(o)===n.toLowerCase());if(l.length){i[n]={key:n,flow:l[0],matchedBy:"key",duplicates:l.slice(1)};continue}let f=u.filter(o=>m(o)||(c&&t&&o.name.startsWith(`${s} (`))===!0);i[n]=f.length?{key:n,flow:f[0],matchedBy:"name",duplicates:f.slice(1)}:{key:n,duplicates:[]}}return i}function ye(e,t){if(!(!e||!t))return e.some(r=>r.flowId===t)}import{cn as De}from"cn";export{M as AGENT_MODELS,R as LinkfoxError,h as SESSION_EXPIRED_MESSAGE,ae as WORD_FIELDS,de as WORD_KIND_LABEL,fe as WORD_STATUS,w as activeSmartTable,me as activeWordTables,T as appKitConfig,oe as attachmentUrl,A as authIdentity,ue as buildWordMatcher,Q as cancelTask,Ie as claimWorkflows,De as cn,b as configureAppKit,Z as createSmartTable,ce as createWordTables,xe as currentNotebookId,B as errorMessage,S as filterKeys,z as findNav,re as firstAttachment,K as flagList,p as gateway,H as getApiKey,D as getApplicationId,j as getAuthState,W as getConfiguredApiKey,V as getShareUrl,q as handleGatewayError,I as initLinkfoxSdk,v as initialAuthState,$ as isAbortError,L as isApiKeyInvalid,te as isAttachmentList,F as isBalanceError,C as isSessionExpired,ye as isTriggerLinked,y as keyOf,ke as listRegisteredWorkflows,U as loadApiKey,Y as login,_ as logout,G as maskApiKey,le as nowIso,ie as num,E as recordVisit,X as runTask,ee as setActiveSmartTable,N as sleep,se as splitList,J as startAuth,ne as str,P as subscribeAuth,O as toggleFlag,ge as withWorkflowKey};
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import { LucideIcon } from 'lucide-react';
|
|
2
|
+
import * as st from '@linkfox-web/ai-tools/smart-table';
|
|
3
|
+
import { FieldInput, NotebookInfo as NotebookInfo$1, TableInfo as TableInfo$1, RecordFilter, SmartRecord } from '@linkfox-web/ai-tools/smart-table';
|
|
4
|
+
|
|
5
|
+
interface NavItem {
|
|
6
|
+
title: string;
|
|
7
|
+
href: string;
|
|
8
|
+
}
|
|
9
|
+
interface NavGroup {
|
|
10
|
+
title: string;
|
|
11
|
+
icon: LucideIcon;
|
|
12
|
+
items: NavItem[];
|
|
13
|
+
}
|
|
14
|
+
/** 根据路径找出面包屑:[菜单组, 页面];菜单由模板传入 */
|
|
15
|
+
declare function findNav(nav: NavGroup[], pathname: string): {
|
|
16
|
+
group: NavGroup;
|
|
17
|
+
item: NavItem;
|
|
18
|
+
} | null;
|
|
19
|
+
|
|
20
|
+
/** 搜索条件的界面描述(选品页、选品库、自动任务弹窗共用) */
|
|
21
|
+
type UiFilterSpec = {
|
|
22
|
+
type: "range";
|
|
23
|
+
id: string;
|
|
24
|
+
label: string;
|
|
25
|
+
unit?: string;
|
|
26
|
+
price?: boolean;
|
|
27
|
+
} | {
|
|
28
|
+
type: "dateRange";
|
|
29
|
+
id: string;
|
|
30
|
+
label: string;
|
|
31
|
+
} | {
|
|
32
|
+
type: "text";
|
|
33
|
+
id: string;
|
|
34
|
+
label: string;
|
|
35
|
+
placeholder?: string;
|
|
36
|
+
} | {
|
|
37
|
+
type: "list";
|
|
38
|
+
id: string;
|
|
39
|
+
label: string;
|
|
40
|
+
placeholder?: string;
|
|
41
|
+
options?: string[];
|
|
42
|
+
multiple?: boolean;
|
|
43
|
+
} | {
|
|
44
|
+
type: "bool";
|
|
45
|
+
id: string;
|
|
46
|
+
label: string;
|
|
47
|
+
}
|
|
48
|
+
/** required:接口必填项,不提供「不限」选项 */
|
|
49
|
+
| {
|
|
50
|
+
type: "select";
|
|
51
|
+
id: string;
|
|
52
|
+
label: string;
|
|
53
|
+
options: {
|
|
54
|
+
value: string;
|
|
55
|
+
label: string;
|
|
56
|
+
}[];
|
|
57
|
+
required?: boolean;
|
|
58
|
+
}
|
|
59
|
+
/** 一组开关:Keepa 的 buyBoxIsFBA 这类参数只认 true,不选就是不限;值是选中项的逗号拼接 */
|
|
60
|
+
| {
|
|
61
|
+
type: "flags";
|
|
62
|
+
id: string;
|
|
63
|
+
label: string;
|
|
64
|
+
options: {
|
|
65
|
+
value: string;
|
|
66
|
+
label: string;
|
|
67
|
+
}[];
|
|
68
|
+
};
|
|
69
|
+
/** 表单值:range / dateRange 用 `${id}.gte` / `${id}.lte`,其它用 id */
|
|
70
|
+
type FilterValues = Record<string, string>;
|
|
71
|
+
declare function filterKeys(spec: {
|
|
72
|
+
type: string;
|
|
73
|
+
id: string;
|
|
74
|
+
}): string[];
|
|
75
|
+
/** flags 的值 → 选中项数组 */
|
|
76
|
+
declare function flagList(value: string | undefined): string[];
|
|
77
|
+
declare function toggleFlag(value: string | undefined, flag: string, on: boolean): string;
|
|
78
|
+
|
|
79
|
+
type FieldDef = FieldInput;
|
|
80
|
+
type NotebookInfo = NotebookInfo$1;
|
|
81
|
+
/** 模板 `linkfox.config.ts` 的 `smartTableConfig` 结构(多数字段来自 `config/smart-table.json`) */
|
|
82
|
+
interface SmartTableFieldDef {
|
|
83
|
+
name: string;
|
|
84
|
+
type: string;
|
|
85
|
+
[key: string]: unknown;
|
|
86
|
+
}
|
|
87
|
+
interface SmartTableConfig {
|
|
88
|
+
/** 多维表(容器)名称 */
|
|
89
|
+
notebookName: string;
|
|
90
|
+
/** 多维表 id(nbk 开头):构建期由 NEXT_PUBLIC_NOTE_BOOK_ID 指定,留空则按名称查找 */
|
|
91
|
+
notebookId?: string;
|
|
92
|
+
/** 建多维表时的幂等键前缀,按应用区分 */
|
|
93
|
+
requestKeyPrefix?: string;
|
|
94
|
+
/** 数据表名称:key → 表名 */
|
|
95
|
+
tables: Record<string, string>;
|
|
96
|
+
/** 各数据表的列定义:ensureTable 建表/补列时使用 */
|
|
97
|
+
fields?: Record<string, readonly SmartTableFieldDef[]>;
|
|
98
|
+
}
|
|
99
|
+
/** 数据表信息 + 字段名 → fieldId(工作流触发条件要用) */
|
|
100
|
+
interface TableInfo extends TableInfo$1 {
|
|
101
|
+
fieldIds: Record<string, string>;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* 按模板的 `smartTableConfig` 建一套多维表客户端。
|
|
105
|
+
*
|
|
106
|
+
* 用工厂而不是模块级单例:包不能读宿主的环境变量,表结构也只能由模板注入。
|
|
107
|
+
* 模板的 `lib/app-kit.ts` 里 `setActiveSmartTable(createSmartTable(smartTableConfig))`,
|
|
108
|
+
* 包内组件(如 LinkFox OS 助手)通过 `activeSmartTable()` 拿到同一个实例。
|
|
109
|
+
*/
|
|
110
|
+
declare function createSmartTable<C extends SmartTableConfig>(config: C): {
|
|
111
|
+
config: C;
|
|
112
|
+
TABLE_FIELDS: Record<string, st.FieldInput[]>;
|
|
113
|
+
getNotebook: () => Promise<st.NotebookInfo>;
|
|
114
|
+
ensureTable: (key: string, fields?: FieldDef[]) => Promise<TableInfo>;
|
|
115
|
+
listRecords: (params: {
|
|
116
|
+
tableId: string;
|
|
117
|
+
page?: number;
|
|
118
|
+
perPage?: number;
|
|
119
|
+
fieldNames?: string[];
|
|
120
|
+
filter?: RecordFilter;
|
|
121
|
+
}) => Promise<st.ListRecordsResult>;
|
|
122
|
+
listAllRecords: (params: {
|
|
123
|
+
tableId: string;
|
|
124
|
+
fieldNames?: string[];
|
|
125
|
+
filter?: RecordFilter;
|
|
126
|
+
}, maxPages?: number) => Promise<st.SmartRecord[]>;
|
|
127
|
+
createRecords: (tableId: string, rows: Record<string, unknown>[]) => Promise<st.SmartRecord[]>;
|
|
128
|
+
updateRecords: (tableId: string, records: SmartRecord[]) => Promise<void>;
|
|
129
|
+
deleteRecords: (tableId: string, recordIds: string[]) => Promise<void>;
|
|
130
|
+
uploadAttachment: (tableId: string, recordId: string, fieldName: string, imageUrl: string) => Promise<st.Attachment>;
|
|
131
|
+
getRecord: (tableId: string, primaryField: string, primaryValue: string, recordId: string, fieldNames?: string[]) => Promise<st.SmartRecord | null>;
|
|
132
|
+
warmTables: () => Promise<TableInfo[]>;
|
|
133
|
+
tableIdOf: (key: string) => Promise<string>;
|
|
134
|
+
};
|
|
135
|
+
type SmartTable = ReturnType<typeof createSmartTable>;
|
|
136
|
+
/** 模板在 `lib/app-kit.ts` 里注册;包内组件用它读写多维表 */
|
|
137
|
+
declare function setActiveSmartTable(client: SmartTable): void;
|
|
138
|
+
/**
|
|
139
|
+
* 没注册时返回 undefined,而不是抛错:包内组件(如助手面板)据此跳过需要多维表的功能,
|
|
140
|
+
* 模板漏了 `import "@/lib/app-kit"` 时页面不会整块崩掉。
|
|
141
|
+
*/
|
|
142
|
+
declare function activeSmartTable(): SmartTable | undefined;
|
|
143
|
+
declare function isAttachmentList(v: unknown): v is st.Attachment[];
|
|
144
|
+
/** 附件 cell 的第一项(附件列是数组,业务上主图只存一张) */
|
|
145
|
+
declare function firstAttachment(v: unknown): st.Attachment | undefined;
|
|
146
|
+
/**
|
|
147
|
+
* 附件 cell 的临时访问地址。
|
|
148
|
+
* 地址由多维表每次读取时重签(约 3 小时有效),所以只能在渲染 / 调用接口的当下取,不要存。
|
|
149
|
+
* prefer=thumb 取缩略图(列表用),full 取原图(生图 / 生文输入用)。
|
|
150
|
+
*/
|
|
151
|
+
declare function attachmentUrl(v: unknown, prefer?: "thumb" | "full"): string | undefined;
|
|
152
|
+
/** 单元格取值工具 */
|
|
153
|
+
declare const str: (v: unknown) => string;
|
|
154
|
+
declare const num: (v: unknown) => number;
|
|
155
|
+
/** 逗号 / 换行分隔的文本列 → 数组 */
|
|
156
|
+
declare const splitList: (v: unknown) => string[];
|
|
157
|
+
/** 多维表 date 列写入用 */
|
|
158
|
+
declare const nowIso: () => string;
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* 品牌词 / 敏感词:选品应用在采集结果里做侵权拦截用的两本词库。
|
|
162
|
+
*
|
|
163
|
+
* 词库由用户在页面上维护,不能写死在代码里。表和列的语义在 5 个应用里完全一致,
|
|
164
|
+
* 所以连「建表 + 读启用词 + 生成匹配函数」一起做成公共件,随 SDK 升级。
|
|
165
|
+
*/
|
|
166
|
+
declare const WORD_STATUS: readonly ["启用", "禁用"];
|
|
167
|
+
/**
|
|
168
|
+
* 两本词的列定义。始终显式传给 `ensureTable`:早期几个模板的 `config/smart-table.json`
|
|
169
|
+
* 里这两张表登记的是「备注 / 创建时间戳」而不是「中文名 / 来源」,靠 config 建表会让
|
|
170
|
+
* 管理页写不进去;显式传这份定义,缺的列会在下次打开应用时补齐。
|
|
171
|
+
*/
|
|
172
|
+
declare const WORD_FIELDS: FieldDef[];
|
|
173
|
+
declare const WORD_KIND_LABEL: {
|
|
174
|
+
readonly brandWords: "品牌词";
|
|
175
|
+
readonly sensitiveWords: "敏感词";
|
|
176
|
+
};
|
|
177
|
+
type WordTableKey = keyof typeof WORD_KIND_LABEL;
|
|
178
|
+
interface WordHit {
|
|
179
|
+
word: string;
|
|
180
|
+
kind: WordTableKey;
|
|
181
|
+
}
|
|
182
|
+
/** 绑定到某个多维表客户端的词库操作;由 `activeWordTables()` 用已注册的客户端创建。 */
|
|
183
|
+
declare function createWordTables(table: SmartTable): {
|
|
184
|
+
ensureWordTable: (key: WordTableKey) => Promise<TableInfo>;
|
|
185
|
+
loadActiveWords: () => Promise<WordHit[]>;
|
|
186
|
+
};
|
|
187
|
+
/** 用 `setActiveSmartTable` 注册的客户端创建词库操作。 */
|
|
188
|
+
declare function activeWordTables(): {
|
|
189
|
+
ensureWordTable: (key: WordTableKey) => Promise<TableInfo>;
|
|
190
|
+
loadActiveWords: () => Promise<WordHit[]>;
|
|
191
|
+
};
|
|
192
|
+
/**
|
|
193
|
+
* 生成匹配函数:大小写不敏感;英文/数字开头或结尾的词按完整单词匹配(避免 "Apple" 命中 "Pineapple"),
|
|
194
|
+
* 中文等其它字符按包含匹配。
|
|
195
|
+
*/
|
|
196
|
+
declare function buildWordMatcher(words: WordHit[]): (texts: string[]) => WordHit[];
|
|
197
|
+
|
|
198
|
+
export { type FilterValues as F, type NavGroup as N, type SmartTable as S, type TableInfo as T, type UiFilterSpec as U, type WordTableKey as W, type NavItem as a, type FieldDef as b, type NotebookInfo as c, type SmartTableConfig as d, type SmartTableFieldDef as e, findNav as f, WORD_FIELDS as g, WORD_KIND_LABEL as h, WORD_STATUS as i, type WordHit as j, activeSmartTable as k, activeWordTables as l, attachmentUrl as m, buildWordMatcher as n, createSmartTable as o, createWordTables as p, filterKeys as q, firstAttachment as r, flagList as s, isAttachmentList as t, nowIso as u, num as v, setActiveSmartTable as w, splitList as x, str as y, toggleFlag as z };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@linkfox-web/app-kit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "LinkFox 应用模板公共运行时与组件:登录门禁、多维表客户端、列表/筛选/任务组件、LinkFox OS 助手",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -27,9 +27,9 @@
|
|
|
27
27
|
"react-markdown": "^10.1.0",
|
|
28
28
|
"remark-gfm": "^4.0.1",
|
|
29
29
|
"sonner": "^2.0.8",
|
|
30
|
-
"@linkfox-web/
|
|
31
|
-
"@linkfox-web/
|
|
32
|
-
"@linkfox-web/
|
|
30
|
+
"@linkfox-web/http": "^0.3.13",
|
|
31
|
+
"@linkfox-web/ai-tools": "^0.3.11",
|
|
32
|
+
"@linkfox-web/api-user-center": "^0.3.13"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@types/react": "19.3.0",
|
|
@@ -45,9 +45,9 @@
|
|
|
45
45
|
"react-markdown": "10.1.0",
|
|
46
46
|
"remark-gfm": "4.0.1",
|
|
47
47
|
"sonner": "2.0.8",
|
|
48
|
-
"@linkfox-web/ai-tools": "0.3.
|
|
49
|
-
"@linkfox-web/http": "0.3.
|
|
50
|
-
"@linkfox-web/api-user-center": "0.3.
|
|
48
|
+
"@linkfox-web/ai-tools": "0.3.11",
|
|
49
|
+
"@linkfox-web/http": "0.3.13",
|
|
50
|
+
"@linkfox-web/api-user-center": "0.3.13"
|
|
51
51
|
},
|
|
52
52
|
"publishConfig": {
|
|
53
53
|
"access": "public"
|
package/dist/chunk-5LS4UNRR.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var p;function F(t){p={...t}}function i(){if(!p)throw new Error("app-kit 未配置:请在模板的 lib/app-kit.ts 中调用 configureAppKit(),并在入口组件里 import 该文件");return p}function s(){return i().apiKey?.()?.trim()||void 0}import{isLinkfoxHttpError as u,LinkfoxHttpError as v}from"@linkfox-web/http";var _=/算力|余额不足|计费不足|套餐到期|充值|quota exceeded|insufficient balance/i,C=/invalid_token|the access token is invalid|expired or revoked/i,c="会话已过期,请重新登录";function f(t){if(!u(t))return!1;if(t.message===c)return!0;let e=typeof t.body=="string"?t.body:JSON.stringify(t.body??"");return C.test(`${t.message} ${e}`)}var x=class extends v{constructor(e,n){super({service:"app",status:0,code:e,message:n})}};function q(t){return t instanceof DOMException&&t.name==="AbortError"}function P(t){return u(t)&&t.service==="ai-tools"&&(String(t.code)==="402"||_.test(t.message))}function g(t){return u(t)&&t.service==="ai-tools"&&(String(t.code)==="401"||t.status===401)}function l(t){if(u(t)){let e=String(t.code??"");return e==="NETWORK_ERROR"?"网络请求失败,请检查网络后重试":e==="TIMEOUT"?"请求超时,请稍后重试":f(t)?c:e==="UNAUTHORIZED"?"登录已失效,请重新登录":g(t)?"工具网关鉴权失败:API Key 或登录已失效":P(t)?`算力余额不足,请前往 LinkFox 充值后重试(${t.message})`:t.message}return t instanceof Error?t.message:String(t)}var z=(t,e)=>new Promise((n,b)=>{let k=setTimeout(n,t);e?.addEventListener("abort",()=>{clearTimeout(k),b(new DOMException("Aborted","AbortError"))})});import{recordAppVisit as L}from"@linkfox-web/ai-tools/smart-table";var N="public_app_id_xxx";function R(){let t=i().applicationId?.trim();if(!(!t||t===N))return t}function E(){let t=R();if(!t)return;let e=typeof window>"u"?void 0:window.location.href;L({appId:t,appUrl:e}).catch(()=>{})}import{configure as U}from"@linkfox-web/http";import"@linkfox-web/api-user-center";var w=!1;function m(){if(w)return;let t=i();U({services:{"ai-tools":{baseURL:t.gatewayBaseUrl,apiKey:s,apiKeyHeader:t.rewrite?"Authorization":"tool-gateway-api-key"},"third-party-sso":{baseURL:t.ssoBaseUrl}}}),w=!0}import{clearSession as O}from"@linkfox-web/http";import{clearThirdPartySsoSession as D,completeThirdPartySsoRedirect as M,readThirdPartySsoSession as T,redirectToThirdPartySso as $}from"@linkfox-web/api-user-center";var K={status:"loading"},o=K,h=!1,A,y,S=new Set;function r(t){o=t,S.forEach(e=>e())}function ut(t){return S.add(t),()=>{S.delete(t)}}function ct(){return o}function dt(){return K}function pt(){return o.status==="ready"?o.identity:""}function a(){clearTimeout(y),A=void 0}function B(t){A=t.accessToken,clearTimeout(y),y=setTimeout(()=>{d()},Math.min(Math.max(t.expireAt-Date.now(),0),2147483647)),r({status:"ready",identity:`${i().ssoClientId}:${t.sub}`,userName:t.name}),E()}function ft(){if(h)return;if(h=!0,s()){d();return}m();let t=i().ssoClientId,e=()=>{if(o.status!=="ready")return;let n=T(t);(!n||n.accessToken!==A)&&d()};window.addEventListener("focus",e),document.addEventListener("visibilitychange",e),window.addEventListener("pageshow",n=>{n.persisted&&o.status==="redirecting"&&r({status:"anonymous"})}),X()}async function X(){let t=i().ssoClientId;if(t){new URLSearchParams(window.location.search).has("state")&&r({status:"callback"});try{let e=await M(t);if(e&&e.returnTo!==window.location.href){window.location.replace(e.returnTo);return}}catch(e){a(),r({status:"error",action:"login",message:l(e)});return}}await d()}async function d(){m();let t=s();if(t){a(),O(),r({status:"ready",apiKey:t,identity:"api-key",userName:"API Key 访问"});return}let e=i().ssoClientId;if(!e){a(),r({status:"error",action:"config",message:"请配置 NEXT_PUBLIC_LINKFOX_SSO_CLIENT_ID(开发使用 .env.local,构建使用 .env),然后重启或重新构建"});return}let n=T(e);if(n){B(n);return}a(),r({status:"anonymous"})}function H(){let t=i().basePath??"";return t?`${window.location.origin}${t}/`:window.location.origin}async function gt(){if(o.status!=="redirecting"){a(),r({status:"redirecting"});try{await $({clientId:i().ssoClientId,redirectUri:H()})}catch(t){r({status:"error",action:"login",message:l(t)})}}}function I(){D(i().ssoClientId),a(),r({status:"anonymous"})}function lt(t){if(f(t)){if(o.status!=="ready")return;I(),r({status:"error",action:"login",message:c});return}if(!(!g(t)||o.status!=="ready")){if(s()){a(),r({status:"error",action:"config",message:"API Key 已失效,请更新 NEXT_PUBLIC_LINKFOX_API_KEY 后重启开发服务或重新构建部署"});return}I(),r({status:"error",action:"login",message:"登录已失效,请重新登录"})}}function mt(t){return t.length<=8?"****":`${t.slice(0,4)}****${t.slice(-4)}`}function yt(){return s()??null}export{F as a,i as b,s as c,c as d,f as e,x as f,q as g,P as h,g as i,l as j,z as k,R as l,E as m,m as n,ut as o,ct as p,dt as q,pt as r,ft as s,d as t,gt as u,I as v,lt as w,mt as x,yt as y};
|
package/dist/chunk-G7FP7VUB.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{f as B,g as D,h as M,i as K,k as G,r as $,w as L}from"./chunk-5LS4UNRR.js";function ce(e){return e.type==="range"||e.type==="dateRange"?[`${e.id}.gte`,`${e.id}.lte`]:[e.id]}function W(e){return(e??"").split(",").map(t=>t.trim()).filter(Boolean)}function de(e,t,l){let s=W(e).filter(f=>f!==t);return l&&s.push(t),s.join(",")}function ue(e,t){for(let l of e){let s=l.items.find(f=>t===f.href||t.startsWith(`${f.href}/`));if(s)return{group:l,item:s}}return null}async function O(e){try{return await e}catch(t){throw L(t),t}}import*as w from"@linkfox-web/ai-tools/agent-os";var Y=2500,z=5,J=3,he=[{id:"default",name:"通用助手"},{id:"linkfox-product-selection-agent",name:"选品 Agent"},{id:"linkfox-market-analysis-agent",name:"市场分析 Agent"},{id:"linkfox-listing-agent",name:"Listing Agent"},{id:"linkfox-image-agent",name:"图片 Agent"},{id:"linkfox-video-agent",name:"视频 Agent"}],Z={read:"读取文件",execute:"执行命令",edit:"编辑文件",search:"搜索"},V=e=>e?.type==="text"||e?.type===void 0?e?.text??e?.value??"":"";function ee(e){return e.type!=="resource_link"||!e.uri?null:{name:decodeURIComponent(e.uri.split("?")[0].split("/").pop()??"")||e.name||"文件",uri:e.uri}}function te(e){let t=new Map,l="";return e.forEach((s,f)=>{if(s.sessionUpdate==="tool_call"||s.sessionUpdate==="tool_call_update"){let u=s.toolCallId??`step-${f}`,b=t.get(u),I=s.title?.replace(/\(.*\)$/,"")||b?.title||Z[s.kind??""]||"处理中",x=s.status==="completed"?"done":s.status==="failed"?"failed":b?.status??"running";t.set(u,{id:u,title:I,status:x})}else(s.sessionUpdate==="agent_message_chunk"||s.sessionUpdate==null)&&(l+=V(s.content))}),{steps:[...t.values()],text:l}}function ne(e){let t="",l=new Map;for(let{content:s}of e){if(!s)continue;let f=ee(s);f?l.set(f.uri,f):t+=V(s)}return{text:t,files:[...l.values()]}}function we(e){return O(w.cancelTask({messageId:e}))}async function Ie(e){try{return(await O(w.getShareUrl({messageId:e}))).shareUrl||void 0}catch{return}}async function xe(e,t,{signal:l,onUpdate:s,sessionId:f}){let u=await O(w.createTask(f?{prompt:e,modelId:t,sessionId:f}:{prompt:e,modelId:t},{signal:l}));if(!u.id)throw new B(500,"LinkFox OS 没有返回任务 ID");let b=u.id,I=u.sessionId||f||"";s({messageId:b,sessionId:I,steps:[],text:"",files:[],stopReason:""});let x=new Map,y=0,N=0;for(;;){await G(Y,l);let P=Math.max(0,y-z),T;try{T=await O(w.getTask({messageId:b,fromIndex:P},{signal:l})),N=0}catch(p){if(D(p)||K(p)||M(p)||++N>=J)throw p;continue}T.eventList?.forEach((p,R)=>x.set(P+R,p)),y=T.eventTotal??y;let C=[...x.entries()].sort((p,R)=>p[0]-R[0]).map(([,p])=>p),F=te(C),v=T.message?.stopReason??"";if(v){let p=ne(T.message?.agentMessageChunks??[]),R=F.steps.map(E=>E.status==="running"?{...E,status:"done"}:E);return{messageId:b,sessionId:I,steps:R,text:p.text||F.text,files:p.files,stopReason:v}}s({messageId:b,sessionId:I,steps:F.steps,text:F.text,files:[],stopReason:""})}}import{LinkfoxHttpError as re}from"@linkfox-web/http";import*as d from"@linkfox-web/ai-tools/smart-table";function A(e,t){return new re({service:"ai-tools",status:200,code:e,message:t})}var j=(e,t)=>(e.createdTime??"").localeCompare(t.createdTime??""),q=e=>Object.fromEntries(e.map(t=>[t.name,t.fieldId]));function H(e,t,l){let s=e.get(t);return s||(s=l(),e.set(t,s),s.catch(()=>e.delete(t))),s}function se(){return typeof window>"u"?!1:/(^|\.)app\.linkfox\.com$/.test(window.location.hostname)}var oe=new Set(["主图"]);function Se(e){let t=e.fields??{},l=new Map,s=new Map,f=new Map;async function u(r){try{return await r}catch(o){throw L(o),o}}async function b(r){let o=[];for(let n=1;n<=50;n++){let a=await u(d[r]({page:n,perPage:100})),i=a.notebooks??[];if(o.push(...i),i.length===0||o.length>=(a.total??0))break}return o}async function I(){let{notebookId:r,notebookName:o}=e,n=await b("listMyTables");if(r){let k=n.find(h=>h.notebookId===r)??(await b("listSharedTables")).find(h=>h.notebookId===r);if(!k)throw A(404,`找不到配置的多维表 ${r},请检查 .env 的 NEXT_PUBLIC_NOTE_BOOK_ID 或 linkfox.config.ts`);return k}if(se())throw A(500,"应用未绑定多维表(缺少 NEXT_PUBLIC_NOTE_BOOK_ID)。请重新打开应用完成初始化后再试。");let a=n.filter(k=>k.name===o).sort(j);if(a.length)return a[0];let i=(await b("listSharedTables")).filter(k=>k.name===o).sort(j);if(i.length)return i[0];let m=e.requestKeyPrefix??"linkfox-app",g=await u(d.createTable({name:o,requestKey:`${m}-${o}`}));return{notebookId:g.notebookId,name:g.notebookName,tables:[{tableId:g.tableId,name:g.name,url:g.url,refKey:g.refKey}]}}function x(){return H(l,$(),I)}function y(r,o){return H(s,`${$()}:${r}`,async()=>{let n=o??t[r];if(!n)throw A(500,`数据表 ${String(r)} 没有登记列定义,请在 linkfox.config.ts 的 smartTableConfig.fields 里补上`);let a=e.tables[r];if(!a)throw A(500,`数据表 ${String(r)} 没有登记表名,请在 smartTableConfig.tables 里补上`);let i=await x(),m=i.tables.find(c=>c.name===a);if(!m){let c=await u(d.addTable({notebookId:i.notebookId,name:a,fields:n})),S={tableId:c.tableId,name:c.name,url:c.url,refKey:c.refKey};return i.tables.push(S),{...S,fieldIds:q(c.fields??[])}}let{fields:g}=await u(d.listFields({tableId:m.tableId,includeChoices:!1})),k=n.filter(c=>oe.has(c.name)&&g.some(S=>S.name===c.name&&S.type!==c.type)),h=g;if(k.length){let c=k.map(_=>_.name);h=(await u(d.deleteFields({tableId:m.tableId,fieldNames:c,allowBreakingDependents:!0}))).fields??g.filter(_=>!c.includes(_.name))}let Q=new Set(h.map(c=>c.name)),U=n.filter(c=>!Q.has(c.name));for(let c=0;c<U.length;c+=50)h=(await u(d.addFields({tableId:m.tableId,fields:U.slice(c,c+50)}))).fields??h;return{...m,fieldIds:q(h)}})}function N(r){return u(d.listRecords(r))}async function P(r,o=100){let n=[];for(let a=1;a<=o;a++){let i=await N({...r,page:a,perPage:100});if(n.push(...i.records),i.records.length<100||n.length>=i.total)break}return n}async function T(r,o){let n=[];for(let a=0;a<o.length;a+=50){let i=o.slice(a,a+50),m=await u(d.createRecords({tableId:r,records:i.map(g=>({fields:g}))}));if(n.push(...m.records??[]),m.created!==i.length)throw A(500,`已写入 ${n.length} 条,但有 ${i.length-m.created} 条未写入成功`)}return n}async function C(r,o){for(let n=0;n<o.length;n+=100){let a=o.slice(n,n+100),i=await u(d.updateRecords({tableId:r,records:a}));if(i.updated!==a.length)throw A(404,`只更新了 ${i.updated}/${a.length} 条,记录可能已被删除,请刷新后重试`)}}async function F(r,o){for(let n=0;n<o.length;n+=100)await u(d.deleteRecords({tableId:r,recordIds:o.slice(n,n+100)}))}function v(r,o,n,a){let i=`${r}:${o}:${n}`,g=(f.get(i)??Promise.resolve()).catch(()=>{}).then(()=>u(d.uploadAttachment({tableId:r,recordId:o,fieldName:n,imageUrl:a})).then(k=>k.attachment));return f.set(i,g),g.finally(()=>{f.get(i)===g&&f.delete(i)}).catch(()=>{}),g}async function p(r,o,n,a,i){return(await N({tableId:r,perPage:100,fieldNames:i,filter:{conditions:[{fieldName:o,operator:"is",value:n}]}})).records.find(g=>g.recordId===a)??null}function R(){return Promise.all(Object.keys(t).map(r=>y(r)))}async function E(r){return(await y(r)).tableId}return{config:e,TABLE_FIELDS:t,getNotebook:x,ensureTable:y,listRecords:N,listAllRecords:P,createRecords:T,updateRecords:C,deleteRecords:F,uploadAttachment:v,getRecord:p,warmTables:R,tableIdOf:E}}var X;function Ne(e){X=e}function Fe(){return X}function ie(e){return Array.isArray(e)&&e.every(t=>t&&typeof t=="object"&&"token"in t)}function ae(e){return ie(e)?e[0]:void 0}function Ae(e,t="full"){let l=ae(e);return l&&(t==="thumb"?l.smThumbnailUrl??l.lgThumbnailUrl??l.presignedUrl:l.presignedUrl)||void 0}var le=e=>e==null?"":typeof e=="string"?e:String(e),Ee=e=>typeof e=="number"?e:Number(e)||0,Oe=e=>le(e).split(/[,,、\n]/).map(t=>t.trim()).filter(Boolean),Pe=()=>new Date().toISOString();export{ce as a,W as b,de as c,ue as d,O as e,he as f,we as g,Ie as h,xe as i,Se as j,Ne as k,Fe as l,ie as m,ae as n,Ae as o,le as p,Ee as q,Oe as r,Pe as s};
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import { LucideIcon } from 'lucide-react';
|
|
2
|
-
|
|
3
|
-
interface NavItem {
|
|
4
|
-
title: string;
|
|
5
|
-
href: string;
|
|
6
|
-
}
|
|
7
|
-
interface NavGroup {
|
|
8
|
-
title: string;
|
|
9
|
-
icon: LucideIcon;
|
|
10
|
-
items: NavItem[];
|
|
11
|
-
}
|
|
12
|
-
/** 根据路径找出面包屑:[菜单组, 页面];菜单由模板传入 */
|
|
13
|
-
declare function findNav(nav: NavGroup[], pathname: string): {
|
|
14
|
-
group: NavGroup;
|
|
15
|
-
item: NavItem;
|
|
16
|
-
} | null;
|
|
17
|
-
|
|
18
|
-
/** 搜索条件的界面描述(选品页、选品库、自动任务弹窗共用) */
|
|
19
|
-
type UiFilterSpec = {
|
|
20
|
-
type: "range";
|
|
21
|
-
id: string;
|
|
22
|
-
label: string;
|
|
23
|
-
unit?: string;
|
|
24
|
-
price?: boolean;
|
|
25
|
-
} | {
|
|
26
|
-
type: "dateRange";
|
|
27
|
-
id: string;
|
|
28
|
-
label: string;
|
|
29
|
-
} | {
|
|
30
|
-
type: "text";
|
|
31
|
-
id: string;
|
|
32
|
-
label: string;
|
|
33
|
-
placeholder?: string;
|
|
34
|
-
} | {
|
|
35
|
-
type: "list";
|
|
36
|
-
id: string;
|
|
37
|
-
label: string;
|
|
38
|
-
placeholder?: string;
|
|
39
|
-
options?: string[];
|
|
40
|
-
multiple?: boolean;
|
|
41
|
-
} | {
|
|
42
|
-
type: "bool";
|
|
43
|
-
id: string;
|
|
44
|
-
label: string;
|
|
45
|
-
}
|
|
46
|
-
/** required:接口必填项,不提供「不限」选项 */
|
|
47
|
-
| {
|
|
48
|
-
type: "select";
|
|
49
|
-
id: string;
|
|
50
|
-
label: string;
|
|
51
|
-
options: {
|
|
52
|
-
value: string;
|
|
53
|
-
label: string;
|
|
54
|
-
}[];
|
|
55
|
-
required?: boolean;
|
|
56
|
-
}
|
|
57
|
-
/** 一组开关:Keepa 的 buyBoxIsFBA 这类参数只认 true,不选就是不限;值是选中项的逗号拼接 */
|
|
58
|
-
| {
|
|
59
|
-
type: "flags";
|
|
60
|
-
id: string;
|
|
61
|
-
label: string;
|
|
62
|
-
options: {
|
|
63
|
-
value: string;
|
|
64
|
-
label: string;
|
|
65
|
-
}[];
|
|
66
|
-
};
|
|
67
|
-
/** 表单值:range / dateRange 用 `${id}.gte` / `${id}.lte`,其它用 id */
|
|
68
|
-
type FilterValues = Record<string, string>;
|
|
69
|
-
declare function filterKeys(spec: {
|
|
70
|
-
type: string;
|
|
71
|
-
id: string;
|
|
72
|
-
}): string[];
|
|
73
|
-
/** flags 的值 → 选中项数组 */
|
|
74
|
-
declare function flagList(value: string | undefined): string[];
|
|
75
|
-
declare function toggleFlag(value: string | undefined, flag: string, on: boolean): string;
|
|
76
|
-
|
|
77
|
-
export { type FilterValues as F, type NavGroup as N, type UiFilterSpec as U, type NavItem as a, filterKeys as b, flagList as c, findNav as f, toggleFlag as t };
|