@lark-base-open/base-database-app-sdk 0.3.0 → 0.3.1

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.3.1 - 2026-10-19
4
+
5
+ ### Fixed
6
+
7
+ - 人员选择器优先显示成员推荐结果中与当前语言匹配的结构化姓名;该语言姓名缺失时回退默认名称,避免误显示其他语言。
8
+
3
9
  ## 0.3.0 - 2026-10-16
4
10
 
5
11
  ### Added
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  用于开发以飞书多维表格为数据后端的 Base Database 应用,提供页面与服务端运行时、平台组件、版本化能力查询与测试工具。
4
4
 
5
- 安装:`npm install @lark-base-open/base-database-app-sdk@0.3.0`。从旧版本升级前请阅读 [变更与迁移说明](CHANGELOG.md)。
5
+ 安装:`npm install @lark-base-open/base-database-app-sdk@0.3.1`。从旧版本升级前请阅读 [变更与迁移说明](CHANGELOG.md)。
6
6
 
7
7
  运行环境需支持 ES2022;页面 API 需要 Base Database 页面宿主,服务端 API 用于 Node.js / FaaS。组件需要 React 与 React DOM 19.2,页面查询能力使用 @tanstack/react-query 5.104.1;npm 会安装声明的依赖与必需 peer。底层通信依赖 base-site-channel 0.1.6。
8
8
 
@@ -34,9 +34,9 @@ SDK 文档说明本版本 API、组件、兼容语义与可编译示例。业务
34
34
 
35
35
  ## npm 发布
36
36
 
37
- SDK 0.3.0 依赖已发布的 channel 0.1.6,锁文件必须解析到 `registry.npmjs.org` 的制品。AI Function 调用需要后端与宿主支持 `functions/:key/invoke`。
37
+ SDK 0.3.1 依赖已发布的 channel 0.1.6,锁文件必须解析到 `registry.npmjs.org` 的制品。AI Function 调用需要后端与宿主支持 `functions/:key/invoke`。
38
38
 
39
- 本版本拟发布到 `latest`。契约生成使用工程安装的 SDK `./codegen` 入口;已安装旧 SDK 的工程不会因为单独升级 CLI 而自动切换到 0.3.0。0.3.0 将批量 Mutation 的 ID、输入和输出绑定到生成契约,收紧公开类型接口;0.2.0 对直接 Function 调用的返回泛型也有不兼容变化,跨版本升级见 [迁移说明](CHANGELOG.md)。
39
+ 本版本拟发布到 `latest`。0.3.1 修复人员选择器在结构化多语言姓名中的语言选择与回退,不改变公开 API。契约生成使用工程安装的 SDK `./codegen` 入口;已安装旧 SDK 的工程不会因为单独升级 CLI 而自动切换到 0.3.1。0.3.0 将批量 Mutation 的 ID、输入和输出绑定到生成契约,收紧公开类型接口;0.2.0 对直接 Function 调用的返回泛型也有不兼容变化,跨版本升级见 [迁移说明](CHANGELOG.md)。
40
40
 
41
41
  每个不兼容版本的 `CHANGELOG.md` 都必须包含 `### Migration`,并依次写出四个非空四级标题:**会坏什么 / 怎么在代码里找受影响处 / 修改步骤 / 验证命令**。0.x 按 minor、1.0 起按 major 判断兼容线;兼容版本若提供 Migration,也使用相同格式。版本条目、编号和四段内容由 `check:migrations` 检查,缺失时测试与发布预检失败。
42
42
 
@@ -59,7 +59,7 @@ SDK 0.3.0 依赖已发布的 channel 0.1.6,锁文件必须解析到 `registry.
59
59
 
60
60
  - `npm whoami --registry=https://registry.npmjs.org/`
61
61
  - `npm publish --tag latest --registry=https://registry.npmjs.org/`
62
- - `npm view @lark-base-open/base-database-app-sdk@0.3.0 version dist --json --registry=https://registry.npmjs.org/`
62
+ - `npm view @lark-base-open/base-database-app-sdk@0.3.1 version dist --json --registry=https://registry.npmjs.org/`
63
63
  - `npm view @lark-base-open/base-database-app-sdk dist-tags versions --json --registry=https://registry.npmjs.org/`
64
64
 
65
- 回读应确认 `latest` 为 `0.3.0`。
65
+ 回读应确认 `latest` 为 `0.3.1`。
package/capabilities.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "schemaVersion": 1,
3
- "sdkVersion": "0.3.0",
3
+ "sdkVersion": "0.3.1",
4
4
  "capabilities": {
5
5
  "runtime.context": {
6
6
  "required": [
@@ -0,0 +1 @@
1
+ import{a as Le,b as Q,c as Fe}from"./chunk-ZKBZAK4L.js";import{a as pe}from"./chunk-3JX3FIBG.js";import{a as N}from"./chunk-OHPYKFCM.js";import{createContext as $t,useContext as Xe}from"react";import{createContext as Dt,useContext as Mt,useEffect as Lt,useSyncExternalStore as Ft}from"react";import{capabilityNames as Ct}from"@lark-base-open/base-site-channel/capabilities";import*as S from"@lark-base-open/base-site-channel/runtime";import{SITE_RUNTIME_PROTOCOL_VERSION as En,SiteRuntimeApi as ne,SiteRuntimeEvent as Un,SiteRuntimeFunction as Sn,SiteRuntimeErrorCode as Pn,readSiteAITextDelta as xn,isValidSiteFunctionName as kn}from"@lark-base-open/base-site-channel/runtime-contract";var V=()=>{throw new pe(Q.ContextInvalid,"\u5BBF\u4E3B\u80FD\u529B\u5B57\u6BB5\u65E0\u6548")};function me(e){if(!e||typeof e!="object")return V();if(e.capabilities===void 0)return Object.fromEntries(Object.entries(Le).filter(([,o])=>o.baseline).map(([o])=>[o,{version:1}]));let t=e.capabilities;if(!t||typeof t!="object"||Array.isArray(t))return V();let n=Object.entries(t);return n.some(([,o])=>!o||typeof o!="object"||Array.isArray(o)||!Number.isSafeInteger(o.version)||o.version<=0)?V():Object.fromEntries(n.map(([o,r])=>[o,{version:r.version}]))}function yt(e,t,n=1){if(!Number.isSafeInteger(n)||n<1)return V();let o=me(e);return Object.prototype.hasOwnProperty.call(o,t)&&o[t].version>=n}async function wt(e=E){return me(await e.getRuntimeContext())}var In=wt;async function vt(e,t=1,n=E){let o=await n.getRuntimeContext(),r=me(o),i=yt(o,e,t),a=o.capabilityUnavailable;if(a!==void 0&&(!a||typeof a!="object"||Array.isArray(a)))return V();let s=a&&Object.prototype.hasOwnProperty.call(a,e)?a[e]:void 0;return s!==void 0&&(!s||typeof s!="object"||!["permission-denied","region-unavailable","temporarily-unavailable"].includes(s.reason)||typeof s.retryable!="boolean")?V():{name:e,requiredVersion:t,version:Object.prototype.hasOwnProperty.call(r,e)?r[e].version:null,supported:i,source:o.capabilities===void 0?"host-baseline":"advertised",availability:i?s?.reason??"unknown":"unsupported"}}async function Oe(e,t=1,n=E){let o=await n.getRuntimeContext(),r=await vt(e,t,{getRuntimeContext:async()=>o});if(!r.supported)throw new Fe(e,t);let i={"permission-denied":Q.PermissionDenied,"region-unavailable":Q.RegionUnavailable,"temporarily-unavailable":Q.TemporarilyUnavailable};if(r.availability in i)throw new pe(i[r.availability],"\u5BBF\u4E3B\u660E\u786E\u62D2\u7EDD\u6B64\u80FD\u529B",void 0,o.capabilityUnavailable?.[e]?.retryable)}function Ne(e,t){let n,o=!1,r,i=new Promise(a=>{r=a});return e.registerApi(N.pairApi,async a=>{if(!a||!/^[A-Za-z0-9_-]{43}$/.test(a.challenge))throw new Error("INVALID_PAIRING_CHALLENGE");n=a.challenge;let s=n;o&&(o=!1,i=new Promise(u=>{r=u}));let c=await t(N.endpoint,{method:"POST",credentials:"omit",cache:"no-store",redirect:"error",headers:{"Content-Type":"application/json"},body:JSON.stringify({challenge:s})});if(!c.ok)throw new Error("DEVELOPMENT_PAIRING_FAILED");let d=await c.json();if(!/^[A-Za-z0-9_-]{43}$/.test(d.proof))throw new Error("INVALID_PAIRING_PROOF");return{proof:d.proof}}),e.subscribeEvent(N.pairedEvent,a=>{n&&a?.challenge===n&&(o=!0,r())}),{reset:()=>{n=void 0,o&&(o=!1,i=new Promise(a=>{r=a}))},wait:async()=>{let a;do a=i,await a;while(a!==i)}}}var je=typeof window<"u"&&window.location.protocol==="http:"&&window.location.hostname===N.host&&Number(window.location.port)>=N.portMin&&Number(window.location.port)<=N.portMax;var Be=S.siteRuntime,I=Be.getChannel?.()??Be.channel,Rt=je&&typeof window<"u"&&window.parent!==window?Ne(I,globalThis.fetch.bind(globalThis)):void 0;function $e(e,t=async()=>{}){let n=new Map,o=async(r,i)=>{await t();for(let a of Ct(r,i))try{await Oe(a,1,{getRuntimeContext:()=>e.invokeApi(ne.RuntimeContext,void 0)})}catch(s){throw s instanceof Error&&"code"in s?Object.assign(new S.SiteRuntimeInvocationError(String(s.code),s.message),s):s}};return{subscribeEvent:(r,i)=>e.subscribeEvent(r,i),emitEvent:async(r,i)=>(await o(r,i),e.emitEvent(r,i)),invokeApi:async(r,i,a)=>{let s=i?.requestId??i?.subscriptionId??i?.uploadId,c=r===ne.HttpRequestCancel||r===ne.AttachmentUploadCancel||r.endsWith(".close");if(c&&s&&n.has(s)){n.get(s).canceled=!0;return}let d={canceled:!1};!c&&s&&n.set(s,d);try{if(await o(r,i),d.canceled)throw new DOMException("The operation was aborted","AbortError");return s&&n.delete(s),await e.invokeApi(r,i,a)}finally{s&&n.get(s)===d&&n.delete(s)}}}}var Et={invokeApi:I.invokeApi.bind(I),emitEvent:I.emitEvent.bind(I),subscribeEvent:I.subscribeEvent.bind(I)},ge=$e(Et,async()=>{if(typeof window<"u"&&window.parent===window)throw new S.SiteRuntimeInvocationError("CHANNEL_UNAVAILABLE","\u9875\u9762\u672A\u8FDE\u63A5\u5BBF\u4E3B channel");await Rt?.wait()});I.invokeApi=ge.invokeApi;I.emitEvent=ge.emitEvent;var fe=class extends S.SiteRuntimeClient{constructor(t){super(t?$e(t):ge)}},jn=e=>new fe(e),E=S.siteRuntime,{invokeHttp:oe,invokeApi:Bn,getCurrentUser:Y,logout:he,requestEdit:Ut,uploadAttachment:$n,openLink:re}=E,St=(e=E,t)=>S.createSiteRuntimeFetch(e,t),D=St();var Pt=oe,xt=/^\/?(preview\/)?app\/([^/]+)(\/|$)/,He=/^[A-Za-z0-9_-]+$/,ze="/space/api/bitable/site/v1",kt="/space/api/box/file/temporary_download_url",G="preview",W=null;function At(){let t=(typeof globalThis.location>"u"?void 0:globalThis.location)?.ancestorOrigins?.[0];if(t)return t;let n=typeof globalThis.document>"u"?"":globalThis.document.referrer;if(!n)return"";try{return new URL(n).origin}catch{return""}}function be(){let e=typeof globalThis.location>"u"?"":globalThis.location.pathname,t=xt.exec(e),n=At();return t?{env:t[1]?G:"prod",gatewayOrigin:n,token:decodeURIComponent(t[2]??"")}:{env:"prod",gatewayOrigin:n,token:""}}function Z(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Tt(e){return e===G||e==="prod"}function It(e){if(!Z(e))return{};let t=typeof e.siteToken=="string"?e.siteToken.trim():"";return{...t?{token:t}:{},...Tt(e.env)?{env:e.env}:{}}}async function j(){return W||(W=(async()=>{let e=be(),t={};try{t=It(await E.getRuntimeContext())}catch(o){console.warn("Could not read the host Runtime context; inferring it from the artifact path",o)}let n={env:t.env??e.env,gatewayOrigin:e.gatewayOrigin,token:t.token??e.token};return n.token||console.error("Cannot determine the app token: the host did not provide siteToken and the current path does not match an artifact path"),n})().catch(e=>{throw W=null,e}),W)}function ye(e){return!!(e.tableId.trim()&&e.fieldId.trim()&&e.recordId.trim()&&e.fileToken.trim())}function qe(e,t){return JSON.stringify({bitablePerm:{tableId:t.tableId,attachments:{[t.fieldId]:{[t.recordId]:[t.fileToken]}},siteToken:e.token,siteEnv:e.env}})}function Ve(e,t){if(t instanceof Error)return t;let n=Z(t)?t.code:void 0,o=typeof n=="string"||typeof n=="number"?String(n):"",r=o==="REQUEST_TIMEOUT"||o==="10005"?`${e} timed out`:`${e} failed`;return Object.assign(new Error(`${r}${o?` (code ${o})`:""}`),{cause:t,...o?{code:o}:{}})}async function Ge(e,t=360,n={}){if(n.signal?.throwIfAborted(),!ye(e)||!Number.isFinite(t)||t<=0)throw new Error("Attachment location or image size is invalid");let o=await j();if(n.signal?.throwIfAborted(),!o.token)throw new Error("Cannot load the attachment image without an app token");let r=[120,360,720,1280].find(c=>c>=t)??1280,i=new URLSearchParams({extra:qe(o,e),width:String(r),height:String(r),policy:"allow_up",fallback_source:"1"}),a=await Pt({url:`/space/api/box/stream/download/v2/cover/${encodeURIComponent(e.fileToken)}?${i}`,init:{method:"GET",responseType:"arrayBuffer",timeoutMs:45e3},signal:n.signal}).catch(c=>{throw Ve("Attachment image request",c)});if(!a.ok){let c=a.headers.get("x-tt-logid");throw new Error(`Failed to load attachment image: HTTP ${a.status}${c?`, LogID ${c}`:""}`)}let s=await a.blob();if(!s.size||!s.type.startsWith("image/"))throw new Error("The host did not return a valid image");return s}async function _t(e,t){if(!e.token)throw new Error("Cannot get an attachment download URL without an app token");if(!ye(t))throw new Error("Cannot get an attachment download URL: the attachment location is incomplete");let n=await D(kt,{body:JSON.stringify({extra:qe(e,t),file_token:t.fileToken}),headers:{"content-type":"application/json"},method:"POST"}).catch(s=>{throw Ve("Attachment download URL request",s)}),o=n.headers?.get("x-tt-logid")?.trim(),r;try{r=await n.json()}catch{throw new Error(n.ok?`Attachment download URL response is not valid JSON${o?`, LogID ${o}`:""}`:`Failed to get attachment download URL: HTTP ${n.status}${o?`, LogID ${o}`:""}`)}let i=Z(r)?r.code:void 0;if(typeof i=="number"&&i!==0||typeof i=="string"&&i.trim()!==""&&i.trim()!=="0"){let s=new Error(`Attachment service could not provide a download URL (code ${String(i)}${o?`, LogID ${o}`:""})`);throw Object.assign(s,{code:String(i),cause:r})}if(!n.ok)throw new Error(`Failed to get attachment download URL: HTTP ${n.status}${o?`, LogID ${o}`:""}`);let a=Z(r)&&Z(r.data)&&typeof r.data.url=="string"?r.data.url.trim():"";if(!a)throw new Error(`Attachment download URL response is missing data.url${o?`, LogID ${o}`:""}`);return a}function Je(e){let t=new URLSearchParams;e.env===G&&t.set("env",G);let n=t.toString(),o=`${ze}/${encodeURIComponent(e.token)}/invoke_get`;return n?`${o}?${n}`:o}function Ke(e,t){if(!He.test(t))throw new TypeError(`functionId ${t} does not match the required pattern ${String(He)}`);let n=`${ze}/${encodeURIComponent(e.token)}/functions/${encodeURIComponent(t)}/invoke`;return e.env===G?`${n}?env=${encodeURIComponent(G)}`:n}async function qn(e,t){let n=await j();if(!n.token)throw new Error(`Cannot invoke Function ${e} without an app token`);let o=await oe({url:Ke(n,e),init:{body:JSON.stringify({params:t}),headers:{"content-type":"application/json"},method:"POST"}});if(!o.ok)throw new Error(`Function ${e} request failed: HTTP ${o.status}`);return await o.json()}async function Vn(e,t){if(!Array.isArray(t)||t.length<1||t.length>200||t.some(r=>r===null||typeof r!="object"||Array.isArray(r)))throw new TypeError("Mutation batch requires 1 to 200 named parameter objects");let n=await j();if(!n.token)throw new Error("\u5E94\u7528 token \u672A\u786E\u5B9A\uFF0C\u65E0\u6CD5\u8C03\u7528 Mutation");let o=await oe({url:Ke(n,e),init:{body:JSON.stringify({batch:t.map(r=>({params:r}))}),headers:{"content-type":"application/json"},method:"POST"}});if(!o.ok)throw new Error(`Mutation \u8C03\u7528\u5931\u8D25\uFF1AHTTP ${o.status}`);return await o.json()}async function Gn(e,t){let n=await _t(e,t);if(!(await re(n)).opened)throw new Error("The host did not open the attachment download link")}function Jn(e,t,n=360){if(!e.gatewayOrigin||!e.token||!ye(t))return"";let o=[120,360,720,1280].find(i=>i>=n)??1280,r=new URLSearchParams({extra:JSON.stringify({bitablePerm:{tableId:t.tableId,attachments:{[t.fieldId]:{[t.recordId]:[t.fileToken]}},baseAppToken:e.token}}),width:String(o),height:String(o),policy:"allow_up",fallback_source:"1"});return`${e.gatewayOrigin}/space/api/box/stream/download/v2/cover/${encodeURIComponent(t.fileToken)}?${r.toString()}`}var Re=Dt(void 0),Ye=[{id:"en",locale:"en-US",match:/^en(?:-|$)/},{id:"zh",locale:"zh-CN",match:/^zh(?:-|$)/},{id:"ja",locale:"ja-JP",match:/^ja(?:-|$)/}],ve=new Set,We,we=null;function Ce(e){if(typeof e!="string")return;let t=e.trim().replace(/_/g,"-").toLowerCase();return Ye.find(({match:n})=>n.test(t))?.id}function Ot(){return typeof navigator>"u"?void 0:navigator.language}function Nt(e,t){return Ce(e)??Ce(t)??"en"}function B(){return We??Nt(void 0,Ot())}function Ee(e=B()){return Ye.find(({id:t})=>t===e)?.locale??"en-US"}function jt(e){return ve.add(e),()=>ve.delete(e)}function Qe(e){We=Ce(e);let t=B();Ze(t);for(let n of ve)n();return t}function Ze(e){typeof document<"u"&&(document.documentElement.lang=Ee(e))}function Bt(){return we||(Ze(B()),we=E.getRuntimeContext().then(e=>Qe(e?.locale)).catch(()=>Qe(void 0))),we}function P(){let e=Mt(Re),t=Ft(jt,B,()=>"en");return Lt(()=>{e||Bt()},[e]),e??t}import{jsx as Ue}from"react/jsx-runtime";var Se=$t(null);function no({children:e,...t}){return Ue(Se.Provider,{value:t,children:Ue(Re.Provider,{value:t.locale,children:Ue("div",{className:"base-app-platform","data-theme":t.theme,children:e})})})}function oo(){let e=Xe(Se);if(!e)throw new Error("BASE_APP_PROVIDER_REQUIRED");return e}function ae(){return Xe(Se)}import{useState as X,useEffect as nt}from"react";import{QueryClient as Ht}from"@tanstack/react-query";var Pe=new Ht({defaultOptions:{queries:{retry:!1,staleTime:3e4,gcTime:3e4}}});function ie(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function se(e,t){let n=e[t];return typeof n=="string"?n.trim():""}function zt(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}function $(){return{baseBindings:[],name:"",description:"",isOwner:!1,allowEdit:!1,organization:""}}function qt(){let e=document.querySelector('meta[name="description"]');return e instanceof HTMLMetaElement?e:null}function Vt(e){if(e.name&&(document.title=e.name),e.description){let t=qt();t&&(t.content=e.description)}}function Gt(e){return Array.isArray(e)?e.reduce((t,n)=>{if(!ie(n))return t;let o=se(n,"baseToken");return o&&t.push({baseToken:o,tableIds:zt(n.tableIds)}),t},[]):[]}function Jt(e){if(!ie(e)||e.code!==0)return $();let t=e.data;if(!ie(t))return $();let n=t.site;return ie(n)?{baseBindings:Gt(n.baseBindings),description:se(n,"description"),name:se(n,"name"),isOwner:t.isOwner===!0,allowEdit:n.allowEdit===void 0?t.isOwner===!0:n.allowEdit===!0,organization:se(n,"organization")}:$()}async function et(e){try{let t=await D(Je(e),{method:"GET"});if(!t.ok)return $();let n=await t.json(),o=Jt(n);return Vt(o),o}catch{return $()}}async function J(){let e=await j();if(!e.token)return $();let t=await Y().catch(()=>null);return t?.userId?Pe.fetchQuery({queryKey:["project-meta",e.token,e.env,t.userId],queryFn:()=>et(e)}):et(e)}var Kt="https://feishu.cn/base/site/detail/overview";async function tt(){try{await E.requestEdit();return}catch{let{token:e}=await j(),t=new URL(Kt);if(t.searchParams.set("token",e),!(await re(t.toString())).opened)throw new Error("Management page was not opened")}}import{jsx as H,jsxs as ot}from"react/jsx-runtime";var Qt={en:{openFailed:"Unable to open the management page. Please try again.",editSite:"Edit and manage your apps",hidePanel:"Hide until next visit",hiddenConfirmation:"Edit button hidden until you reopen the app",dismissNotification:"Dismiss notification"},zh:{openFailed:"\u65E0\u6CD5\u6253\u5F00\u7BA1\u7406\u9875\u9762\uFF0C\u8BF7\u91CD\u8BD5",editSite:"\u7F16\u8F91\u4E0E\u7BA1\u7406\u5E94\u7528",hidePanel:"\u9690\u85CF\u9762\u677F",hiddenConfirmation:"\u7F16\u8F91\u6309\u94AE\u5DF2\u9690\u85CF\uFF0C\u76F4\u81F3\u4E0B\u6B21\u91CD\u65B0\u6253\u5F00\u5E94\u7528",dismissNotification:"\u5173\u95ED\u63D0\u793A"},ja:{openFailed:"\u7BA1\u7406\u30DA\u30FC\u30B8\u3092\u958B\u3051\u307E\u305B\u3093\u3067\u3057\u305F\u3002\u3082\u3046\u4E00\u5EA6\u304A\u8A66\u3057\u304F\u3060\u3055\u3044\u3002",editSite:"\u30A2\u30D7\u30EA\u3092\u7DE8\u96C6\u30FB\u7BA1\u7406",hidePanel:"\u6B21\u56DE\u306E\u30A2\u30AF\u30BB\u30B9\u307E\u3067\u975E\u8868\u793A",hiddenConfirmation:"\u7DE8\u96C6\u30DC\u30BF\u30F3\u3092\u975E\u8868\u793A\u306B\u3057\u307E\u3057\u305F\u3002\u30A2\u30D7\u30EA\u3092\u518D\u5EA6\u958B\u304F\u3068\u8868\u793A\u3055\u308C\u307E\u3059",dismissNotification:"\u901A\u77E5\u3092\u9589\u3058\u308B"}};function vo({position:e="bottom-right",className:t="",slots:n={}}){let o=Qt[P()],[r,i]=X(!1),[a,s]=X(!1),[c,d]=X(!1),[u,p]=X(!1),[h,g]=X(!1);nt(()=>{let b=!0;return J().then(F=>{b&&i(F.allowEdit&&be().env==="prod")}).catch(()=>{}),()=>{b=!1}},[]),nt(()=>{if(!c)return;let b=setTimeout(()=>d(!1),3e3);return()=>clearTimeout(b)},[c]);let m=n.trigger,v=n.tooltip;return r?a?c?ot("div",{className:"base-app-platform base-app-notice",role:"status",children:[o.hiddenConfirmation,H("button",{"aria-label":o.dismissNotification,onClick:()=>d(!1),children:"\xD7"})]}):null:ot("div",{className:`base-app-platform base-app-floating ${t}`,"data-position":e,children:[u?H("div",{role:"alert",children:o.openFailed}):null,h?H("div",{role:"tooltip",children:v?H(v,{text:o.editSite}):o.editSite}):null,H("button",{"aria-label":o.editSite,onFocus:()=>g(!0),onBlur:()=>g(!1),onMouseEnter:()=>g(!0),onMouseLeave:()=>g(!1),onClick:()=>{p(!1),tt().catch(()=>p(!0))},children:m?H(m,{}):"\u270E"}),H("button",{"aria-label":o.hidePanel,onClick:()=>{s(!0),d(!0)},children:"\xD7"})]}):null}var xe=new Set;function rt(e){return xe.add(e),()=>{xe.delete(e)}}function at(){for(let e of xe)e()}import{useEffect as Yt,useState as st}from"react";import*as M from"@radix-ui/react-popover";async function it(){try{let e=await Y();if(typeof e?.name=="string"&&e.name)return{name:e.name,avatarUrl:typeof e.avatarUrl=="string"?e.avatarUrl:"",tenantName:""}}catch{}try{let e=await D("/space/api/user/",{headers:{accept:"application/json"}});if(!e.ok)return null;let n=(await e.json()).data;return!n||typeof n.name!="string"||!n.name?null:{name:n.name,avatarUrl:typeof n.avatar_url=="string"?n.avatar_url:"",tenantName:typeof n.tenant_name=="string"?n.tenant_name:""}}catch{return null}}import{Fragment as Zt,jsx as x,jsxs as ke}from"react/jsx-runtime";var Wt={en:{account:"Account",logout:"Log out"},zh:{account:"\u8D26\u53F7",logout:"\u9000\u51FA\u767B\u5F55"},ja:{account:"\u30A2\u30AB\u30A6\u30F3\u30C8",logout:"\u30ED\u30B0\u30A2\u30A6\u30C8"}};function Mo({audience:e="enterprise",align:t="right",side:n="down",showName:o=!0,className:r="",slots:i={}}){let[a,s]=st(null),[c,d]=st(""),u=ae(),p=Wt[P()];if(Yt(()=>{if(e!=="enterprise")return;let m=!0;return Promise.all([it(),J().catch(()=>null)]).then(([v,b])=>{m&&(s(v),d(v?.tenantName||b?.organization||""))}),()=>{m=!1}},[e]),e!=="enterprise"||!a)return null;let h=i.trigger,g=i.organization;return ke(M.Root,{children:[x(M.Trigger,{asChild:!0,children:x("button",{className:`base-app-platform base-app-user-menu ${r}`,"aria-label":p.account,children:h?x(h,{user:a}):ke(Zt,{children:[a.avatarUrl?x("img",{src:a.avatarUrl,alt:"",referrerPolicy:"no-referrer"}):x("span",{children:a.name.slice(0,1)}),o?a.name:null]})})}),x(M.Portal,{children:ke(M.Content,{"data-theme":u?.theme,className:"base-app-platform base-app-popover",align:t==="right"?"end":"start",side:n==="up"?"top":"bottom",sideOffset:8,collisionPadding:8,children:[x("strong",{children:a.name}),g?x(g,{name:c}):x("p",{children:c}),x("button",{onClick:()=>{at(),Pe.clear(),he().catch(()=>{for(let m of["base-site-session","session","sl_session"])document.cookie=`${m}=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/`;window.location.reload()})},children:p.logout})]})})]})}import{useEffect as ce,useRef as ut,useState as z}from"react";import{Command as ee}from"cmdk";import{QueryClient as dn,useQuery as pn}from"@tanstack/react-query";var Xt="/space/api/mention/recommend.v2/",en="8",tn="4",nn="0",on=20,ct={en:{businessError:e=>`Could not search members (error code ${e})`,httpError:e=>`Member search request failed: HTTP ${e}`,invalidResponse:"Member search response has an invalid structure",noBoundBase:"Cannot search members: the application is not bound to a Base"},zh:{businessError:e=>`\u641C\u7D22\u6210\u5458\u5931\u8D25\uFF08\u9519\u8BEF\u7801 ${e}\uFF09`,httpError:e=>`\u641C\u7D22\u6210\u5458\u8BF7\u6C42\u5931\u8D25\uFF1AHTTP ${e}`,invalidResponse:"\u6210\u5458\u641C\u7D22\u54CD\u5E94\u7ED3\u6784\u65E0\u6548",noBoundBase:"\u65E0\u6CD5\u641C\u7D22\u6210\u5458\uFF1A\u5E94\u7528\u5C1A\u672A\u7ED1\u5B9A\u591A\u7EF4\u8868\u683C"},ja:{businessError:e=>`\u30E1\u30F3\u30D0\u30FC\u3092\u691C\u7D22\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F\uFF08\u30A8\u30E9\u30FC\u30B3\u30FC\u30C9 ${e}\uFF09`,httpError:e=>`\u30E1\u30F3\u30D0\u30FC\u691C\u7D22\u306E\u30EA\u30AF\u30A8\u30B9\u30C8\u306B\u5931\u6557\u3057\u307E\u3057\u305F\uFF1AHTTP ${e}`,invalidResponse:"\u30E1\u30F3\u30D0\u30FC\u691C\u7D22\u306E\u5FDC\u7B54\u5F62\u5F0F\u304C\u6B63\u3057\u304F\u3042\u308A\u307E\u305B\u3093",noBoundBase:"\u30E1\u30F3\u30D0\u30FC\u3092\u691C\u7D22\u3067\u304D\u307E\u305B\u3093\uFF1A\u30A2\u30D7\u30EA\u306BBase\u304C\u95A2\u9023\u4ED8\u3051\u3089\u308C\u3066\u3044\u307E\u305B\u3093"}};async function lt(e,t,n){let o=t??B(),r=ct[o],a=(await J()).baseBindings[0]?.baseToken;if(!a)throw new Error(r.noBoundBase);let s=new URLSearchParams({config_source:"0",obj_type:en,source:tn,token:a,type:nn,user_type:"0",content:e.trim().slice(0,50)}).toString(),c=await D(Xt,{signal:n,body:s,headers:{"content-type":"application/x-www-form-urlencoded"},method:"POST"});if(!c.ok)throw new Error(r.httpError(c.status));let d=await c.json();return{code:0,msg:"ok",data:rn(d,o)}}function rn(e,t=B()){let n=Ee(t),o=ct[t],r=an(e,o);if(!r)throw new Error(o.invalidResponse);let i=r.entities,a=k(i)?i.users:void 0;if(!k(a)||!Array.isArray(r.result_list))throw new Error(o.invalidResponse);let s=[],c=new Set;for(let d of r.result_list){if(!k(d)||Number(d.type)!==0)continue;let u=f(d.token);if(!u)continue;let p=a[u];if(!k(p))continue;let h=f(p.user_id)||f(p.id)||u,g=sn(p,n);if(!h||!g||c.has(h))continue;c.add(h);let m=f(p.avatar_url),v=f(p.open_id);if(s.push({avatar:{avatar_72:m,avatar_240:m,avatar_640:m,avatar_origin:m},department_ids:un(p.department_ids),description:cn(p,n),is_external:p.is_external===!0,name:g,user_id:h,...v?{open_id:v}:{}}),s.length>=on)break}return{users:s}}function an(e,t){if(k(e)){if(typeof e.code=="number"&&e.code!==0){let n=f(e.msg);throw Object.assign(new Error(n||t.businessError(e.code)),{code:String(e.code),cause:e})}return"entities"in e&&"result_list"in e?e:k(e.data)?e.data:void 0}}function sn(e,t){let n=e.display_name;if(typeof n=="string"&&n.trim())return n.trim();let o=t.toLowerCase().replace("-","_"),r=o.split("_")[0],i=k(n)?n:{},a=k(i.i18n_value)?i.i18n_value:i,s=r==="zh"?e.cn_name:r==="en"?e.en_name:void 0;return f(a[o])||f(a[r])||f(s)||f(i.value)||f(e.name)||f(e.en_name)||f(e.cn_name)}function cn(e,t){let n=e.is_external===!0?e.i18n_tenant:e.i18n_department;return ln(n,t)||f(e.department)}function ln(e,t){if(typeof e=="string")return e.trim();if(!k(e))return"";let n=t.toLowerCase().replace("-","_"),o=n.split("_")[0]??"",r=k(e.i18n_value)?e.i18n_value:e,i=f(r[n])||f(r[o]);if("i18n_value"in e)return i||f(e.value);let a=o==="zh"?f(r.zh_cn)||f(r.en_us):f(r.en_us)||f(r.zh_cn);return i||f(e.value)||a}function f(e){return typeof e=="string"?e.trim():""}function un(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}function k(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}import{Fragment as pt,jsx as R,jsxs as Ae}from"react/jsx-runtime";var mt={en:{invalidResponse:"Member search response has an invalid structure",loading:"Loading...",memberList:"Member list",noMatches:"No matching members. Try another search term.",noRecommendations:"No recommended members yet",recordCreator:"Add the person who created this record",searchFailed:"Member search failed",searchFailedCode:e=>`Could not search members (error code ${e})`,searchMembers:"Search members"},zh:{invalidResponse:"\u6210\u5458\u641C\u7D22\u54CD\u5E94\u7ED3\u6784\u65E0\u6548",loading:"\u52A0\u8F7D\u4E2D...",memberList:"\u6210\u5458\u5217\u8868",noMatches:"\u6CA1\u6709\u5339\u914D\u7684\u6210\u5458\uFF0C\u8BF7\u6362\u4E2A\u5173\u952E\u8BCD",noRecommendations:"\u6682\u65E0\u63A8\u8350\u6210\u5458",recordCreator:"\u6DFB\u52A0\u6B64\u8BB0\u5F55\u7684\u4EBA\u5458",searchFailed:"\u641C\u7D22\u6210\u5458\u5931\u8D25",searchFailedCode:e=>`\u641C\u7D22\u6210\u5458\u5931\u8D25\uFF08\u9519\u8BEF\u7801 ${e}\uFF09`,searchMembers:"\u641C\u7D22\u6210\u5458"},ja:{invalidResponse:"\u30E1\u30F3\u30D0\u30FC\u691C\u7D22\u306E\u5FDC\u7B54\u5F62\u5F0F\u304C\u6B63\u3057\u304F\u3042\u308A\u307E\u305B\u3093",loading:"\u8AAD\u307F\u8FBC\u307F\u4E2D...",memberList:"\u30E1\u30F3\u30D0\u30FC\u4E00\u89A7",noMatches:"\u4E00\u81F4\u3059\u308B\u30E1\u30F3\u30D0\u30FC\u304C\u3044\u307E\u305B\u3093\u3002\u5225\u306E\u30AD\u30FC\u30EF\u30FC\u30C9\u3067\u691C\u7D22\u3057\u3066\u304F\u3060\u3055\u3044\u3002",noRecommendations:"\u304A\u3059\u3059\u3081\u306E\u30E1\u30F3\u30D0\u30FC\u304C\u3044\u307E\u305B\u3093",recordCreator:"\u3053\u306E\u30EC\u30B3\u30FC\u30C9\u306E\u4F5C\u6210\u8005\u3092\u8FFD\u52A0",searchFailed:"\u30E1\u30F3\u30D0\u30FC\u306E\u691C\u7D22\u306B\u5931\u6557\u3057\u307E\u3057\u305F",searchFailedCode:e=>`\u30E1\u30F3\u30D0\u30FC\u3092\u691C\u7D22\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F\uFF08\u30A8\u30E9\u30FC\u30B3\u30FC\u30C9 ${e}\uFF09`,searchMembers:"\u30E1\u30F3\u30D0\u30FC\u3092\u691C\u7D22"}};function le(e){let[t,n]=z(!1),[o,r]=z(!1);ce(()=>r(!0),[]);let i=P(),a=mt[i],[s]=z(()=>new dn({defaultOptions:{queries:{retry:!1,staleTime:3e4,gcTime:3e4}}}));ce(()=>{let l=rt(()=>{n(!0),s.clear()});return()=>{l(),s.clear()}},[s]);let c=Object.prototype.hasOwnProperty.call(e,"value"),d=ut(c);ce(()=>{c!==d.current&&console.warn("UserSelectorPanel controlled mode changed")},[c]);let[u,p]=z(e.defaultValue),h=c?e.value:u,g=Array.isArray(h)?h:h?[h]:[],[m,v]=z(""),[b,F]=z(""),[A,K]=z(!1),O=ut(!1);ce(()=>{if(A)return;let l=setTimeout(()=>F(m.trim()),m.trim()?400:0);return()=>clearTimeout(l)},[m,A]);let y=pn({queryKey:["members",i,b],queryFn:async({signal:l})=>{let C=await lt(b,i,l);return mn(C,i)},enabled:!t&&o&&!A&&m.trim()===b},s),w=e.loading||y.isFetching||m.trim()!==b,T=!t&&!w&&!y.error&&y.data?[...y.data.users,...g.filter(l=>!y.data.users.some(C=>C.user_id===l.user_id))]:[],U=(l,C)=>{v(l),e.onSearch?.(l,{action:C})},ue=()=>{U("","AutoClear"),e.onClose?.()},bt=l=>{if(O.current)return;let C=g.some(de=>de.user_id===l.user_id),te=e.mode==="multiple"?C?g.filter(de=>de.user_id!==l.user_id):[...g,l]:C?void 0:l;c||p(te),e.onChange?.(te,{option:l,action:C?"Remove":"Select"}),C||e.onSelect?.(l,{option:l}),e.mode==="multiple"?U("","AutoClear"):ue()},Ie=e.slots?.empty,_e=e.slots?.loading,De=e.slots?.option,Me=e.slots?.footer;return Ae(ee,{shouldFilter:!1,loop:!0,className:`base-app-platform base-app-selector ${e.className??""}`,label:a.memberList,children:[R(ee.Input,{autoFocus:!0,placeholder:a.searchMembers,"aria-label":a.searchMembers,value:m,onValueChange:l=>U(l,"Input"),onCompositionStart:()=>{O.current=!0,K(!0)},onCompositionEnd:()=>{O.current=!1,K(!1)},onKeyDown:l=>{if(e.onKeyDown?.(l),l.defaultPrevented){l.stopPropagation();return}if(O.current||fn(l)){l.stopPropagation();return}l.key==="Escape"&&(l.preventDefault(),ue())}}),R(ee.List,{"aria-label":a.memberList,"aria-multiselectable":e.mode==="multiple"||void 0,children:w?R("div",{role:"status",children:_e?R(_e,{}):a.loading}):y.error?R("div",{role:"alert",children:a.searchFailed}):Ae(pt,{children:[e.onSelectRecordCreator?R(ee.Item,{value:"record-creator",onSelect:()=>{e.onSelectRecordCreator?.(),ue()},children:a.recordCreator}):null,T.map(l=>{let C=g.some(te=>te.user_id===l.user_id);return R(ee.Item,{value:l.user_id,onSelect:()=>bt(l),"data-checked":C,children:De?R(De,{user:l,selected:C}):Ae(pt,{children:[R("span",{children:l.name}),R("small",{children:e.getUserDescription?.(l)??l.description}),C?R("span",{"aria-label":"selected",children:"\u2713"}):null]})},l.user_id)}),!T.length&&!e.onSelectRecordCreator?R("div",{role:"status",children:Ie?R(Ie,{}):m.trim()?a.noMatches:a.noRecommendations}):null]})}),Me?R(Me,{}):null]})}function mn(e,t){let n=mt[t];if(!dt(e)||typeof e.code!="number")throw new Error(n.invalidResponse);if(e.code!==0){let o=typeof e.msg=="string"?e.msg.trim():"";throw Object.assign(new Error(o||n.searchFailedCode(e.code)),{code:String(e.code),cause:e})}if(!dt(e.data)||!Array.isArray(e.data.users))throw new Error(n.invalidResponse);return{users:e.data.users}}function dt(e){return typeof e=="object"&&e!==null}function fn(e){return e.nativeEvent?.isComposing===!0||e.keyCode===229}import{useState as gn,useRef as hn}from"react";import*as L from"@radix-ui/react-popover";import{jsx as _,jsxs as ft}from"react/jsx-runtime";var bn={en:{clearSelected:"Clear selected members",removeMember:e=>`Remove member ${e}`,selectMembers:"Select members"},zh:{clearSelected:"\u6E05\u9664\u5DF2\u9009\u6210\u5458",removeMember:e=>`\u79FB\u9664\u6210\u5458 ${e}`,selectMembers:"\u9009\u62E9\u6210\u5458"},ja:{clearSelected:"\u9078\u629E\u3057\u305F\u30E1\u30F3\u30D0\u30FC\u3092\u30AF\u30EA\u30A2",removeMember:e=>`\u30E1\u30F3\u30D0\u30FC ${e} \u3092\u524A\u9664`,selectMembers:"\u30E1\u30F3\u30D0\u30FC\u3092\u9078\u629E"}};function gt(e){let t=hn(null),n=ae(),o=bn[P()],[r,i]=gn(!1),a=Array.isArray(e.value)?e.value:e.value?[e.value]:[],s=u=>{i(u),u!==r&&e.onDropdownVisibleChange?.(u)},c=e.slots?.trigger,d=e.slots?.chip;return ft(L.Root,{open:r,onOpenChange:s,children:[ft("div",{ref:t,className:`base-app-platform base-app-editor ${e.className??""}`,onClickCapture:u=>{u.target.closest("[data-base-app-trigger]")&&e.onClick?.(u)},children:[_(L.Trigger,{asChild:!0,children:_("button",{type:"button","data-base-app-trigger":"","aria-label":o.selectMembers,onFocus:e.onFocus,onBlur:e.onBlur,children:c?_(c,{value:e.value}):a.length?a.map(u=>_("span",{children:d?_(d,{user:u}):u.name},u.user_id)):o.selectMembers})}),a.map(u=>_("button",{type:"button","aria-label":e.mode==="multiple"?o.removeMember(u.name):o.clearSelected,onClick:p=>{p.stopPropagation(),e.onChange?.(e.mode==="multiple"?a.filter(h=>h.user_id!==u.user_id):void 0),e.mode==="multiple"?e.onRemove?.(u):e.onClear?.()},children:"\xD7"},u.user_id))]}),_(L.Portal,{container:e.portalContainer??t.current?.closest("dialog")??void 0,children:_(L.Content,{"data-theme":n?.theme,className:"base-app-platform base-app-popover",sideOffset:4,collisionPadding:8,children:_(le,{...e,slots:void 0,onChange:(u,p)=>{e.onChange?.(u),p.action==="Remove"&&p.option&&e.onRemove?.(p.option)},onClose:()=>s(!1)})})})]})}import{useEffect as ht,useRef as yn,useState as Te}from"react";import{jsx as q,jsxs as vn}from"react/jsx-runtime";var wn={en:{decodeFailed:"Image could not be decoded",loadFailed:"Failed to load image",loading:"Loading image",retry:"Retry image"},zh:{decodeFailed:"\u56FE\u7247\u65E0\u6CD5\u89E3\u7801",loadFailed:"\u56FE\u7247\u52A0\u8F7D\u5931\u8D25",loading:"\u56FE\u7247\u52A0\u8F7D\u4E2D",retry:"\u91CD\u8BD5\u56FE\u7247"},ja:{decodeFailed:"\u753B\u50CF\u3092\u8868\u793A\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F",loadFailed:"\u753B\u50CF\u3092\u8AAD\u307F\u8FBC\u3081\u307E\u305B\u3093\u3067\u3057\u305F",loading:"\u753B\u50CF\u3092\u8AAD\u307F\u8FBC\u307F\u4E2D",retry:"\u753B\u50CF\u3092\u518D\u8AAD\u307F\u8FBC\u307F"}};function ir({attachment:e,size:t=360,alt:n,className:o,slots:r={}}){let i=P(),a=wn[i],s=yn(null),[c,d]=Te(!1),[u,p]=Te(0),[h,g]=Te({key:"",url:"",error:""}),{tableId:m,fieldId:v,recordId:b,fileToken:F}=e,A=JSON.stringify([m,v,b,F,t,u]);ht(()=>{if(typeof IntersectionObserver>"u"){d(!0);return}let w=new IntersectionObserver(T=>{T.some(U=>U.isIntersecting)&&(d(!0),w.disconnect())},{rootMargin:"200px"});return s.current&&w.observe(s.current),()=>w.disconnect()},[]),ht(()=>{if(!c)return;let w=new AbortController,T="";return Ge({tableId:m,fieldId:v,recordId:b,fileToken:F},t,{signal:w.signal}).then(U=>{w.signal.aborted||(T=URL.createObjectURL(U),g({key:A,url:T,error:""}))}).catch(U=>{w.signal.aborted||g({key:A,url:"",error:U instanceof Error?U.message:"",localError:U instanceof Error?void 0:"loadFailed"})}),()=>{w.abort(),T&&URL.revokeObjectURL(T)}},[c,A,m,v,b,F,t]);let K=r.loading,O=r.error,y=h.key===A?h:void 0;return q("span",{ref:s,className:`base-app-platform base-app-attachment ${o??""}`,"aria-busy":!y,children:y?.url?q("img",{src:y.url,alt:n,onError:()=>g({key:A,url:"",error:"",localError:"decodeFailed"})}):y?.error||y?.localError?O?q(O,{code:"ATTACHMENT_LOAD_FAILED",retry:()=>p(w=>w+1)}):vn("span",{children:[q("span",{role:"status",children:y.localError?a[y.localError]:y.error}),q("button",{type:"button",onClick:()=>p(w=>w+1),children:a.retry})]}):q("span",{role:"status",children:K?q(K,{}):a.loading})})}export{En as a,ne as b,Un as c,Sn as d,Pn as e,xn as f,kn as g,$e as h,ge as i,fe as j,jn as k,E as l,oe as m,Bn as n,Y as o,he as p,Ut as q,$n as r,re as s,St as t,D as u,me as v,yt as w,wt as x,In as y,vt as z,Oe as A,be as B,j as C,Ge as D,_t as E,Je as F,Ke as G,qn as H,Vn as I,Gn as J,Jn as K,Re as L,Nt as M,B as N,Ee as O,Bt as P,P as Q,no as R,oo as S,ae as T,Pe as U,vo as V,Mo as W,le as X,gt as Y,ir as Z};
@@ -1 +1 @@
1
- import{L as a,M as b,N as c,O as d,P as e,Q as f,R as g,S as h,T as i,V as j,W as k,X as l,Y as m,Z as n}from"./chunk-SOPR6BXP.js";import"./chunk-ZKBZAK4L.js";import"./chunk-3JX3FIBG.js";import"./chunk-OHPYKFCM.js";export{n as AttachmentImage,g as BaseAppProvider,k as DatabaseUserMenu,j as FloatingButton,a as UiLanguageContext,m as UserSelectorEditor,l as UserSelectorPanel,c as getUiLanguage,d as getUiLocale,e as initializeUiLanguage,b as selectUiLanguage,h as useBaseApp,i as useOptionalBaseApp,f as useUiLanguage};
1
+ import{L as a,M as b,N as c,O as d,P as e,Q as f,R as g,S as h,T as i,V as j,W as k,X as l,Y as m,Z as n}from"./chunk-FJAP37BR.js";import"./chunk-ZKBZAK4L.js";import"./chunk-3JX3FIBG.js";import"./chunk-OHPYKFCM.js";export{n as AttachmentImage,g as BaseAppProvider,k as DatabaseUserMenu,j as FloatingButton,a as UiLanguageContext,m as UserSelectorEditor,l as UserSelectorPanel,c as getUiLanguage,d as getUiLocale,e as initializeUiLanguage,b as selectUiLanguage,h as useBaseApp,i as useOptionalBaseApp,f as useUiLanguage};
package/dist/page.js CHANGED
@@ -1 +1 @@
1
- import{A as je,B as le,C as pe,D as fe,E as Se,F as Ae,G as ge,H as Ie,I as ke,J as ye,K as he,L as Ye,M as L,N as Je,O,P as Xe,Q as Ze,R as B,S as $e,T as et,U,V as G,W as tt,X as nt,Y as it,Z as rt,a as j,b as Y,c as J,d as X,e as Z,f as $,g as ee,h as x,i as M,j as te,k as ne,l as m,m as ie,n as re,o as ae,p as oe,q as se,r as ce,s as ue,t as de,u as me,v as ze,w as _,x as Ke,y as We,z as Qe}from"./chunk-SOPR6BXP.js";import{a as He,b as Ve,c as v,d as R}from"./chunk-ZKBZAK4L.js";import{a as qe}from"./chunk-3JX3FIBG.js";import"./chunk-OHPYKFCM.js";export*from"@lark-base-open/base-site-channel/runtime";import{installLinkGuard as Re}from"@lark-base-open/base-site-channel/runtime";function D(e={}){let t=!0,n,i=s=>{let c=R(s);e.onDiagnostic?e.onDiagnostic(c):console.warn("[Base Database SDK]",c)},a=e.runtime??m;return Promise.resolve().then(()=>a.getRuntimeContext()).then(s=>{if(t){if(!_(s,"link.open")){i(new v("link.open",1));return}n=Re(e)}}).catch(s=>{t&&i(s)}),()=>{t=!1,n?.()}}export*from"@lark-base-open/base-site-channel/runtime-contract";import{SiteChatbotStreamError as _t}from"@lark-base-open/base-site-channel/runtime";import*as u from"@lark-base-open/base-site-channel/runtime";var P=class extends u.SiteChatbotStreamAdapter{constructor(t){super({...t,channel:t.channel?x(t.channel):M})}},F=e=>({...e,channel:e?.channel?x(e.channel):M}),N=(e,t)=>u.callSiteAIFunction(e,F(t)),q=(e,t)=>u.invokeSiteAIFunctionStream(e,F(t)),H=(e,t)=>u.createSiteAIFunctionTask(e,F(t)),V=(e,t,n)=>u.getSiteAIFunctionTask(e,t,F(n));var Fe=new Set(["cancelled","failed","queued","running","succeeded"]);async function Te(e){let t=await N(e);return e.input&&!e.messages?k(t):t}function be(e){return q(e)}function o(e,t){for(let n of t){let i=e[n];if(typeof i=="string"&&i.trim())return i}}function Ce(e,t){for(let n of t){let i=e[n];if(typeof i=="number"&&Number.isFinite(i))return i}}function xe(e){let t=o(e,["capabilityType","capability_type","CapabilityType"]);return t==="image"||t==="video"?t:void 0}function Me(e){if(Array.isArray(e))return e.filter(b).map(t=>{let n=o(t,["size","Size"]),i=o(t,["token","Token"]),a=o(t,["url","URL"]);return{safetyStatus:o(t,["safetyStatus","safety_status","SafetyStatus"])??"",...n?{size:n}:{},...i?{token:i}:{},...a?{url:a}:{}}})}function De(e){if(!b(e))return;let t=e.durationSeconds??e.duration_seconds??e.DurationSeconds,n=o(e,["token","Token"]),i=o(e,["url","URL"]);return{...typeof t=="number"?{durationSeconds:t}:{},...n?{token:n}:{},...i?{url:i}:{}}}function T(e,t="INVALID_AI_FUNCTION_TASK"){let n=new Error(e);return n.name="SiteAIFunctionTaskError",n.code=t,n}function k(e){if(!b(e))throw T("AI Function task response has an invalid structure");let t=Pe(e);if(t)throw T(t.message,t.code);if("data"in e&&e.data!==void 0)return k(e.data);let n=o(e,["type","Type"]),i=o(e,["taskId","task_id","TaskID"]),a=e.status??e.Status;if(n!=="image_task"&&n!=="video_task"||!i||typeof a!="string"||!Fe.has(a))throw T("AI Function task response has an invalid structure");let s=Me(e.imageAssets??e.image_assets??e.ImageAssets),c=De(e.videoAsset??e.video_asset??e.VideoAsset),l=Ce(e,["progress","Progress"]),I=xe(e),p=o(e,["errCode","err_code","ErrCode"]),f=o(e,["errMessage","err_message","ErrMessage"]);return{...I?{capabilityType:I}:{},...p?{errCode:p}:{},...f?{errMessage:f}:{},...s?{imageAssets:s}:{},...l!==void 0?{progress:l}:{},...c?{videoAsset:c}:{},requestId:o(e,["requestId","request_id","RequestID"])??"",status:a,taskId:i,type:n}}function Pe(e){let t=e.code??e.Code;if(typeof t=="number"&&t!==0||typeof t=="string"&&t&&t!=="0")return{code:String(t),message:o(e,["msg","message","Message"])??"Failed to create the AI Function task"};let n=e.BaseResp??e.base_resp??e.baseResp;if(!b(n))return;let i=n.StatusCode??n.status_code??n.statusCode;if(typeof i=="number"&&i!==0||typeof i=="string"&&i&&i!=="0")return{code:String(i),message:o(n,["StatusMessage","status_message","statusMessage"])??"Failed to create the AI Function task"}}function Ee(e){return!!e.taskId.trim()&&(e.status==="queued"||e.status==="running")}async function we(e){return k(await H(e))}async function ve(e,t){if(!t.trim())throw T("AI Function task ID must not be empty");return k(await V(e,t))}function b(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}import{Component as _e,StrictMode as Le,useEffect as Oe,useState as Be}from"react";import{createRoot as Ue}from"react-dom/client";import{Fragment as Ge,jsx as d,jsxs as Ne}from"react/jsx-runtime";var E=new WeakSet,C=class extends _e{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}componentDidCatch(t){this.props.failed(t)}render(){let t=this.props.fallback;return this.state.failed?t?d(t,{code:"APP_BOOT_FAILED"}):d("div",{role:"alert",children:"APP_BOOT_FAILED"}):this.props.children}};function Tt(e){let t,n,i=new Promise((r,g)=>{t=r,n=g});i.catch(()=>{});let a=!1,s=!1,c=!1,l,I=()=>{},p=()=>{},f=r=>{try{e.onDiagnostic?.(R(r))}catch{}},S=r=>{f(r),!(a||s||c)&&(c=!0,n(r),e.reportLifecycle!==!1&&m.reportLoadFailed("APP_BOOT_FAILED").catch(f))},A;try{A=typeof e.root=="string"?document.querySelector(e.root):e.root??document.querySelector("#root")}catch(r){return S(r),{ready:i,dispose(){a=!0}}}if(!A)return S(new Error("APP_ROOT_NOT_FOUND")),{ready:i,dispose(){a=!0}};if(E.has(A))throw new Error("APP_ALREADY_STARTED");E.add(A);let z=()=>{a||(a=!0,I(),p(),l?.unmount(),E.delete(A),U.clear(),!s&&!c&&n(new Error("APP_DISPOSED")))},K=()=>{queueMicrotask(()=>{a||c||s||(s=!0,e.reportLifecycle===!1?t():m.ready().then(t,r=>{f(r),n(r)}))})};function W({locale:r,theme:g}){let[y,h]=Be();Oe(()=>(p=m.subscribeModeChanged(h),K(),()=>p()),[]);let Q=e.app,w=Ne(Ge,{children:[d(Q,{}),e.platformUI===!1?null:d(G,{})]});return d(B,{runtime:m,theme:g,locale:r,mode:y,onDiagnostic:e.onDiagnostic,children:e.providers?e.providers(w):w})}try{l=Ue(A);let r=e.slots?.loading;r&&l.render(d(C,{failed:S,fallback:e.slots?.error,children:d(r,{})})),m.getRuntimeContext().then(g=>{if(a||c)return;let y=e.locale&&e.locale!=="host"?e.locale:L(g.locale,"en");document.documentElement.lang=O(y),e.linkGuard!==!1&&(I=D({onDiagnostic:e.onDiagnostic}));let h=d(C,{failed:S,fallback:e.slots?.error,children:d(W,{locale:y,theme:e.theme&&e.theme!=="host"?e.theme:g.colorScheme==="dark"?"dark":"light"})});l.render(e.strictMode===!1?h:d(Le,{children:h}))}).catch(S)}catch(r){S(r)}return{ready:i,dispose:z}}export{rt as AttachmentImage,B as BaseAppProvider,He as CAPABILITY_CATALOG,v as CapabilityUnavailableError,tt as DatabaseUserMenu,Ve as DiagnosticCode,G as FloatingButton,qe as SDKError,j as SITE_RUNTIME_PROTOCOL_VERSION,P as SiteChatbotStreamAdapter,_t as SiteChatbotStreamError,Y as SiteRuntimeApi,te as SiteRuntimeClient,Z as SiteRuntimeErrorCode,J as SiteRuntimeEvent,X as SiteRuntimeFunction,Ye as UiLanguageContext,it as UserSelectorEditor,nt as UserSelectorPanel,he as buildAttachmentCoverUrl,ge as buildDatabaseInvokeFunctionPath,Ae as buildDatabaseInvokeGetPath,Te as callSiteAIFunction,R as classifyRuntimeError,we as createSiteAIFunctionTask,ne as createSiteRuntimeClient,de as createSiteRuntimeFetch,me as fetch,fe as fetchAttachmentCover,Se as fetchAttachmentDownloadUrl,Ke as getCapabilities,ae as getCurrentUser,le as getDatabaseContext,We as getRuntimeCapabilities,ve as getSiteAIFunctionTask,Je as getUiLanguage,O as getUiLocale,_ as hasCapability,Ee as hasRunnableMediaTask,Xe as initializeUiLanguage,D as installLinkGuard,re as invokeApi,Ie as invokeDatabaseFunction,ke as invokeDatabaseMutationBatch,ie as invokeHttp,be as invokeSiteAIFunctionStream,ee as isValidSiteFunctionName,oe as logout,k as normalizeSiteAIMediaTask,ye as openAttachmentDownload,ue as openLink,Qe as queryCapability,ze as readCapabilities,$ as readSiteAITextDelta,se as requestEdit,je as requireCapability,pe as resolveDatabaseContext,L as selectUiLanguage,m as siteRuntime,Tt as startBaseApp,ce as uploadAttachment,$e as useBaseApp,et as useOptionalBaseApp,Ze as useUiLanguage};
1
+ import{A as je,B as le,C as pe,D as fe,E as Se,F as Ae,G as ge,H as Ie,I as ke,J as ye,K as he,L as Ye,M as L,N as Je,O,P as Xe,Q as Ze,R as B,S as $e,T as et,U,V as G,W as tt,X as nt,Y as it,Z as rt,a as j,b as Y,c as J,d as X,e as Z,f as $,g as ee,h as x,i as M,j as te,k as ne,l as m,m as ie,n as re,o as ae,p as oe,q as se,r as ce,s as ue,t as de,u as me,v as ze,w as _,x as Ke,y as We,z as Qe}from"./chunk-FJAP37BR.js";import{a as He,b as Ve,c as v,d as R}from"./chunk-ZKBZAK4L.js";import{a as qe}from"./chunk-3JX3FIBG.js";import"./chunk-OHPYKFCM.js";export*from"@lark-base-open/base-site-channel/runtime";import{installLinkGuard as Re}from"@lark-base-open/base-site-channel/runtime";function D(e={}){let t=!0,n,i=s=>{let c=R(s);e.onDiagnostic?e.onDiagnostic(c):console.warn("[Base Database SDK]",c)},a=e.runtime??m;return Promise.resolve().then(()=>a.getRuntimeContext()).then(s=>{if(t){if(!_(s,"link.open")){i(new v("link.open",1));return}n=Re(e)}}).catch(s=>{t&&i(s)}),()=>{t=!1,n?.()}}export*from"@lark-base-open/base-site-channel/runtime-contract";import{SiteChatbotStreamError as _t}from"@lark-base-open/base-site-channel/runtime";import*as u from"@lark-base-open/base-site-channel/runtime";var P=class extends u.SiteChatbotStreamAdapter{constructor(t){super({...t,channel:t.channel?x(t.channel):M})}},F=e=>({...e,channel:e?.channel?x(e.channel):M}),N=(e,t)=>u.callSiteAIFunction(e,F(t)),q=(e,t)=>u.invokeSiteAIFunctionStream(e,F(t)),H=(e,t)=>u.createSiteAIFunctionTask(e,F(t)),V=(e,t,n)=>u.getSiteAIFunctionTask(e,t,F(n));var Fe=new Set(["cancelled","failed","queued","running","succeeded"]);async function Te(e){let t=await N(e);return e.input&&!e.messages?k(t):t}function be(e){return q(e)}function o(e,t){for(let n of t){let i=e[n];if(typeof i=="string"&&i.trim())return i}}function Ce(e,t){for(let n of t){let i=e[n];if(typeof i=="number"&&Number.isFinite(i))return i}}function xe(e){let t=o(e,["capabilityType","capability_type","CapabilityType"]);return t==="image"||t==="video"?t:void 0}function Me(e){if(Array.isArray(e))return e.filter(b).map(t=>{let n=o(t,["size","Size"]),i=o(t,["token","Token"]),a=o(t,["url","URL"]);return{safetyStatus:o(t,["safetyStatus","safety_status","SafetyStatus"])??"",...n?{size:n}:{},...i?{token:i}:{},...a?{url:a}:{}}})}function De(e){if(!b(e))return;let t=e.durationSeconds??e.duration_seconds??e.DurationSeconds,n=o(e,["token","Token"]),i=o(e,["url","URL"]);return{...typeof t=="number"?{durationSeconds:t}:{},...n?{token:n}:{},...i?{url:i}:{}}}function T(e,t="INVALID_AI_FUNCTION_TASK"){let n=new Error(e);return n.name="SiteAIFunctionTaskError",n.code=t,n}function k(e){if(!b(e))throw T("AI Function task response has an invalid structure");let t=Pe(e);if(t)throw T(t.message,t.code);if("data"in e&&e.data!==void 0)return k(e.data);let n=o(e,["type","Type"]),i=o(e,["taskId","task_id","TaskID"]),a=e.status??e.Status;if(n!=="image_task"&&n!=="video_task"||!i||typeof a!="string"||!Fe.has(a))throw T("AI Function task response has an invalid structure");let s=Me(e.imageAssets??e.image_assets??e.ImageAssets),c=De(e.videoAsset??e.video_asset??e.VideoAsset),l=Ce(e,["progress","Progress"]),I=xe(e),p=o(e,["errCode","err_code","ErrCode"]),f=o(e,["errMessage","err_message","ErrMessage"]);return{...I?{capabilityType:I}:{},...p?{errCode:p}:{},...f?{errMessage:f}:{},...s?{imageAssets:s}:{},...l!==void 0?{progress:l}:{},...c?{videoAsset:c}:{},requestId:o(e,["requestId","request_id","RequestID"])??"",status:a,taskId:i,type:n}}function Pe(e){let t=e.code??e.Code;if(typeof t=="number"&&t!==0||typeof t=="string"&&t&&t!=="0")return{code:String(t),message:o(e,["msg","message","Message"])??"Failed to create the AI Function task"};let n=e.BaseResp??e.base_resp??e.baseResp;if(!b(n))return;let i=n.StatusCode??n.status_code??n.statusCode;if(typeof i=="number"&&i!==0||typeof i=="string"&&i&&i!=="0")return{code:String(i),message:o(n,["StatusMessage","status_message","statusMessage"])??"Failed to create the AI Function task"}}function Ee(e){return!!e.taskId.trim()&&(e.status==="queued"||e.status==="running")}async function we(e){return k(await H(e))}async function ve(e,t){if(!t.trim())throw T("AI Function task ID must not be empty");return k(await V(e,t))}function b(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}import{Component as _e,StrictMode as Le,useEffect as Oe,useState as Be}from"react";import{createRoot as Ue}from"react-dom/client";import{Fragment as Ge,jsx as d,jsxs as Ne}from"react/jsx-runtime";var E=new WeakSet,C=class extends _e{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}componentDidCatch(t){this.props.failed(t)}render(){let t=this.props.fallback;return this.state.failed?t?d(t,{code:"APP_BOOT_FAILED"}):d("div",{role:"alert",children:"APP_BOOT_FAILED"}):this.props.children}};function Tt(e){let t,n,i=new Promise((r,g)=>{t=r,n=g});i.catch(()=>{});let a=!1,s=!1,c=!1,l,I=()=>{},p=()=>{},f=r=>{try{e.onDiagnostic?.(R(r))}catch{}},S=r=>{f(r),!(a||s||c)&&(c=!0,n(r),e.reportLifecycle!==!1&&m.reportLoadFailed("APP_BOOT_FAILED").catch(f))},A;try{A=typeof e.root=="string"?document.querySelector(e.root):e.root??document.querySelector("#root")}catch(r){return S(r),{ready:i,dispose(){a=!0}}}if(!A)return S(new Error("APP_ROOT_NOT_FOUND")),{ready:i,dispose(){a=!0}};if(E.has(A))throw new Error("APP_ALREADY_STARTED");E.add(A);let z=()=>{a||(a=!0,I(),p(),l?.unmount(),E.delete(A),U.clear(),!s&&!c&&n(new Error("APP_DISPOSED")))},K=()=>{queueMicrotask(()=>{a||c||s||(s=!0,e.reportLifecycle===!1?t():m.ready().then(t,r=>{f(r),n(r)}))})};function W({locale:r,theme:g}){let[y,h]=Be();Oe(()=>(p=m.subscribeModeChanged(h),K(),()=>p()),[]);let Q=e.app,w=Ne(Ge,{children:[d(Q,{}),e.platformUI===!1?null:d(G,{})]});return d(B,{runtime:m,theme:g,locale:r,mode:y,onDiagnostic:e.onDiagnostic,children:e.providers?e.providers(w):w})}try{l=Ue(A);let r=e.slots?.loading;r&&l.render(d(C,{failed:S,fallback:e.slots?.error,children:d(r,{})})),m.getRuntimeContext().then(g=>{if(a||c)return;let y=e.locale&&e.locale!=="host"?e.locale:L(g.locale,"en");document.documentElement.lang=O(y),e.linkGuard!==!1&&(I=D({onDiagnostic:e.onDiagnostic}));let h=d(C,{failed:S,fallback:e.slots?.error,children:d(W,{locale:y,theme:e.theme&&e.theme!=="host"?e.theme:g.colorScheme==="dark"?"dark":"light"})});l.render(e.strictMode===!1?h:d(Le,{children:h}))}).catch(S)}catch(r){S(r)}return{ready:i,dispose:z}}export{rt as AttachmentImage,B as BaseAppProvider,He as CAPABILITY_CATALOG,v as CapabilityUnavailableError,tt as DatabaseUserMenu,Ve as DiagnosticCode,G as FloatingButton,qe as SDKError,j as SITE_RUNTIME_PROTOCOL_VERSION,P as SiteChatbotStreamAdapter,_t as SiteChatbotStreamError,Y as SiteRuntimeApi,te as SiteRuntimeClient,Z as SiteRuntimeErrorCode,J as SiteRuntimeEvent,X as SiteRuntimeFunction,Ye as UiLanguageContext,it as UserSelectorEditor,nt as UserSelectorPanel,he as buildAttachmentCoverUrl,ge as buildDatabaseInvokeFunctionPath,Ae as buildDatabaseInvokeGetPath,Te as callSiteAIFunction,R as classifyRuntimeError,we as createSiteAIFunctionTask,ne as createSiteRuntimeClient,de as createSiteRuntimeFetch,me as fetch,fe as fetchAttachmentCover,Se as fetchAttachmentDownloadUrl,Ke as getCapabilities,ae as getCurrentUser,le as getDatabaseContext,We as getRuntimeCapabilities,ve as getSiteAIFunctionTask,Je as getUiLanguage,O as getUiLocale,_ as hasCapability,Ee as hasRunnableMediaTask,Xe as initializeUiLanguage,D as installLinkGuard,re as invokeApi,Ie as invokeDatabaseFunction,ke as invokeDatabaseMutationBatch,ie as invokeHttp,be as invokeSiteAIFunctionStream,ee as isValidSiteFunctionName,oe as logout,k as normalizeSiteAIMediaTask,ye as openAttachmentDownload,ue as openLink,Qe as queryCapability,ze as readCapabilities,$ as readSiteAITextDelta,se as requestEdit,je as requireCapability,pe as resolveDatabaseContext,L as selectUiLanguage,m as siteRuntime,Tt as startBaseApp,ce as uploadAttachment,$e as useBaseApp,et as useOptionalBaseApp,Ze as useUiLanguage};
@@ -7,6 +7,7 @@
7
7
  - [`FloatingButton`](exports.md#components) 保留 prod + allowEdit 权限显隐、隐藏直到重挂载、编辑失败提示。position 为 bottom-right/bottom-left;className 和 slots.trigger/tooltip 可覆盖展示,点击仍走宿主 request-edit/OpenLink。
8
8
  - [`DatabaseUserMenu`](exports.md#components) 保留 audience(personal 不渲染)、align、side、showName、className;slots.trigger 收到规范化 user,slots.organization 收到 name。弹层由 Radix 处理;登出清理平台缓存。
9
9
  - [`UserSelectorPanel`](exports.md#components) 保留 value/defaultValue、onChange(value,{option,action})、onSelect、onClose、onSelectRecordCreator、getUserDescription、onSearch、loading、mode、onKeyDown。不传 mode 为单选,multiple 为多选;已选项再次选择触发 Remove,选择后搜索 AutoClear。初始化后不应改变受控/非受控模式。
10
+ - 人员选择器读取成员推荐结果的结构化 `display_name.i18n_value` 时优先使用当前语言;目标语言缺失时依次回退同语言旧字段、`display_name.value` 和通用名称,再考虑其他语言旧字段。
10
11
  - [`UserSelectorEditor`](exports.md#components) 保留 value、onChange/onSelect/onClear/onRemove、onDropdownVisibleChange、onFocus/onBlur。增加 className、slots.trigger/chip、portalContainer。原生 dialog 自动作为 Portal 容器,其他焦点受限的弹窗可显式传 portalContainer。默认同 iframe document.body,不跨宿主 DOM。
11
12
  - [`AttachmentImage`](exports.md#components) 保留 attachment/size/alt/className;slots.loading 和 slots.error 可自定义,error 收到安全 code 与 retry。组件管理懒加载、AbortSignal 和 Blob URL 释放。
12
13
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lark-base-open/base-database-app-sdk",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "Base Database 页面与服务端 SDK、平台组件及测试工具",
5
5
  "type": "module",
6
6
  "sideEffects": [
@@ -1 +0,0 @@
1
- import{a as Le,b as Q,c as Fe}from"./chunk-ZKBZAK4L.js";import{a as pe}from"./chunk-3JX3FIBG.js";import{a as O}from"./chunk-OHPYKFCM.js";import{createContext as Ht,useContext as Xe}from"react";import{createContext as Mt,useContext as Lt,useEffect as Ft,useSyncExternalStore as Ot}from"react";import{capabilityNames as Rt}from"@lark-base-open/base-site-channel/capabilities";import*as S from"@lark-base-open/base-site-channel/runtime";import{SITE_RUNTIME_PROTOCOL_VERSION as En,SiteRuntimeApi as ne,SiteRuntimeEvent as Un,SiteRuntimeFunction as Sn,SiteRuntimeErrorCode as Pn,readSiteAITextDelta as xn,isValidSiteFunctionName as kn}from"@lark-base-open/base-site-channel/runtime-contract";var V=()=>{throw new pe(Q.ContextInvalid,"\u5BBF\u4E3B\u80FD\u529B\u5B57\u6BB5\u65E0\u6548")};function me(e){if(!e||typeof e!="object")return V();if(e.capabilities===void 0)return Object.fromEntries(Object.entries(Le).filter(([,o])=>o.baseline).map(([o])=>[o,{version:1}]));let t=e.capabilities;if(!t||typeof t!="object"||Array.isArray(t))return V();let n=Object.entries(t);return n.some(([,o])=>!o||typeof o!="object"||Array.isArray(o)||!Number.isSafeInteger(o.version)||o.version<=0)?V():Object.fromEntries(n.map(([o,r])=>[o,{version:r.version}]))}function wt(e,t,n=1){if(!Number.isSafeInteger(n)||n<1)return V();let o=me(e);return Object.prototype.hasOwnProperty.call(o,t)&&o[t].version>=n}async function vt(e=E){return me(await e.getRuntimeContext())}var In=vt;async function Ct(e,t=1,n=E){let o=await n.getRuntimeContext(),r=me(o),s=wt(o,e,t),a=o.capabilityUnavailable;if(a!==void 0&&(!a||typeof a!="object"||Array.isArray(a)))return V();let i=a&&Object.prototype.hasOwnProperty.call(a,e)?a[e]:void 0;return i!==void 0&&(!i||typeof i!="object"||!["permission-denied","region-unavailable","temporarily-unavailable"].includes(i.reason)||typeof i.retryable!="boolean")?V():{name:e,requiredVersion:t,version:Object.prototype.hasOwnProperty.call(r,e)?r[e].version:null,supported:s,source:o.capabilities===void 0?"host-baseline":"advertised",availability:s?i?.reason??"unknown":"unsupported"}}async function Oe(e,t=1,n=E){let o=await n.getRuntimeContext(),r=await Ct(e,t,{getRuntimeContext:async()=>o});if(!r.supported)throw new Fe(e,t);let s={"permission-denied":Q.PermissionDenied,"region-unavailable":Q.RegionUnavailable,"temporarily-unavailable":Q.TemporarilyUnavailable};if(r.availability in s)throw new pe(s[r.availability],"\u5BBF\u4E3B\u660E\u786E\u62D2\u7EDD\u6B64\u80FD\u529B",void 0,o.capabilityUnavailable?.[e]?.retryable)}function Ne(e,t){let n,o=!1,r,s=new Promise(a=>{r=a});return e.registerApi(O.pairApi,async a=>{if(!a||!/^[A-Za-z0-9_-]{43}$/.test(a.challenge))throw new Error("INVALID_PAIRING_CHALLENGE");n=a.challenge;let i=n;o&&(o=!1,s=new Promise(u=>{r=u}));let c=await t(O.endpoint,{method:"POST",credentials:"omit",cache:"no-store",redirect:"error",headers:{"Content-Type":"application/json"},body:JSON.stringify({challenge:i})});if(!c.ok)throw new Error("DEVELOPMENT_PAIRING_FAILED");let d=await c.json();if(!/^[A-Za-z0-9_-]{43}$/.test(d.proof))throw new Error("INVALID_PAIRING_PROOF");return{proof:d.proof}}),e.subscribeEvent(O.pairedEvent,a=>{n&&a?.challenge===n&&(o=!0,r())}),{reset:()=>{n=void 0,o&&(o=!1,s=new Promise(a=>{r=a}))},wait:async()=>{let a;do a=s,await a;while(a!==s)}}}var je=typeof window<"u"&&window.location.protocol==="http:"&&window.location.hostname===O.host&&Number(window.location.port)>=O.portMin&&Number(window.location.port)<=O.portMax;var Be=S.siteRuntime,T=Be.getChannel?.()??Be.channel,Et=je&&typeof window<"u"&&window.parent!==window?Ne(T,globalThis.fetch.bind(globalThis)):void 0;function $e(e,t=async()=>{}){let n=new Map,o=async(r,s)=>{await t();for(let a of Rt(r,s))try{await Oe(a,1,{getRuntimeContext:()=>e.invokeApi(ne.RuntimeContext,void 0)})}catch(i){throw i instanceof Error&&"code"in i?Object.assign(new S.SiteRuntimeInvocationError(String(i.code),i.message),i):i}};return{subscribeEvent:(r,s)=>e.subscribeEvent(r,s),emitEvent:async(r,s)=>(await o(r,s),e.emitEvent(r,s)),invokeApi:async(r,s,a)=>{let i=s?.requestId??s?.subscriptionId??s?.uploadId,c=r===ne.HttpRequestCancel||r===ne.AttachmentUploadCancel||r.endsWith(".close");if(c&&i&&n.has(i)){n.get(i).canceled=!0;return}let d={canceled:!1};!c&&i&&n.set(i,d);try{if(await o(r,s),d.canceled)throw new DOMException("The operation was aborted","AbortError");return i&&n.delete(i),await e.invokeApi(r,s,a)}finally{i&&n.get(i)===d&&n.delete(i)}}}}var Ut={invokeApi:T.invokeApi.bind(T),emitEvent:T.emitEvent.bind(T),subscribeEvent:T.subscribeEvent.bind(T)},ge=$e(Ut,async()=>{if(typeof window<"u"&&window.parent===window)throw new S.SiteRuntimeInvocationError("CHANNEL_UNAVAILABLE","\u9875\u9762\u672A\u8FDE\u63A5\u5BBF\u4E3B channel");await Et?.wait()});T.invokeApi=ge.invokeApi;T.emitEvent=ge.emitEvent;var fe=class extends S.SiteRuntimeClient{constructor(t){super(t?$e(t):ge)}},jn=e=>new fe(e),E=S.siteRuntime,{invokeHttp:oe,invokeApi:Bn,getCurrentUser:Y,logout:he,requestEdit:St,uploadAttachment:$n,openLink:re}=E,Pt=(e=E,t)=>S.createSiteRuntimeFetch(e,t),_=Pt();var xt=oe,kt=/^\/?(preview\/)?app\/([^/]+)(\/|$)/,He=/^[A-Za-z0-9_-]+$/,ze="/space/api/bitable/site/v1",At="/space/api/box/file/temporary_download_url",G="preview",W=null;function Tt(){let t=(typeof globalThis.location>"u"?void 0:globalThis.location)?.ancestorOrigins?.[0];if(t)return t;let n=typeof globalThis.document>"u"?"":globalThis.document.referrer;if(!n)return"";try{return new URL(n).origin}catch{return""}}function be(){let e=typeof globalThis.location>"u"?"":globalThis.location.pathname,t=kt.exec(e),n=Tt();return t?{env:t[1]?G:"prod",gatewayOrigin:n,token:decodeURIComponent(t[2]??"")}:{env:"prod",gatewayOrigin:n,token:""}}function Z(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function It(e){return e===G||e==="prod"}function _t(e){if(!Z(e))return{};let t=typeof e.siteToken=="string"?e.siteToken.trim():"";return{...t?{token:t}:{},...It(e.env)?{env:e.env}:{}}}async function N(){return W||(W=(async()=>{let e=be(),t={};try{t=_t(await E.getRuntimeContext())}catch(o){console.warn("Could not read the host Runtime context; inferring it from the artifact path",o)}let n={env:t.env??e.env,gatewayOrigin:e.gatewayOrigin,token:t.token??e.token};return n.token||console.error("Cannot determine the app token: the host did not provide siteToken and the current path does not match an artifact path"),n})().catch(e=>{throw W=null,e}),W)}function ye(e){return!!(e.tableId.trim()&&e.fieldId.trim()&&e.recordId.trim()&&e.fileToken.trim())}function qe(e,t){return JSON.stringify({bitablePerm:{tableId:t.tableId,attachments:{[t.fieldId]:{[t.recordId]:[t.fileToken]}},siteToken:e.token,siteEnv:e.env}})}function Ve(e,t){if(t instanceof Error)return t;let n=Z(t)?t.code:void 0,o=typeof n=="string"||typeof n=="number"?String(n):"",r=o==="REQUEST_TIMEOUT"||o==="10005"?`${e} timed out`:`${e} failed`;return Object.assign(new Error(`${r}${o?` (code ${o})`:""}`),{cause:t,...o?{code:o}:{}})}async function Ge(e,t=360,n={}){if(n.signal?.throwIfAborted(),!ye(e)||!Number.isFinite(t)||t<=0)throw new Error("Attachment location or image size is invalid");let o=await N();if(n.signal?.throwIfAborted(),!o.token)throw new Error("Cannot load the attachment image without an app token");let r=[120,360,720,1280].find(c=>c>=t)??1280,s=new URLSearchParams({extra:qe(o,e),width:String(r),height:String(r),policy:"allow_up",fallback_source:"1"}),a=await xt({url:`/space/api/box/stream/download/v2/cover/${encodeURIComponent(e.fileToken)}?${s}`,init:{method:"GET",responseType:"arrayBuffer",timeoutMs:45e3},signal:n.signal}).catch(c=>{throw Ve("Attachment image request",c)});if(!a.ok){let c=a.headers.get("x-tt-logid");throw new Error(`Failed to load attachment image: HTTP ${a.status}${c?`, LogID ${c}`:""}`)}let i=await a.blob();if(!i.size||!i.type.startsWith("image/"))throw new Error("The host did not return a valid image");return i}async function Dt(e,t){if(!e.token)throw new Error("Cannot get an attachment download URL without an app token");if(!ye(t))throw new Error("Cannot get an attachment download URL: the attachment location is incomplete");let n=await _(At,{body:JSON.stringify({extra:qe(e,t),file_token:t.fileToken}),headers:{"content-type":"application/json"},method:"POST"}).catch(i=>{throw Ve("Attachment download URL request",i)}),o=n.headers?.get("x-tt-logid")?.trim(),r;try{r=await n.json()}catch{throw new Error(n.ok?`Attachment download URL response is not valid JSON${o?`, LogID ${o}`:""}`:`Failed to get attachment download URL: HTTP ${n.status}${o?`, LogID ${o}`:""}`)}let s=Z(r)?r.code:void 0;if(typeof s=="number"&&s!==0||typeof s=="string"&&s.trim()!==""&&s.trim()!=="0"){let i=new Error(`Attachment service could not provide a download URL (code ${String(s)}${o?`, LogID ${o}`:""})`);throw Object.assign(i,{code:String(s),cause:r})}if(!n.ok)throw new Error(`Failed to get attachment download URL: HTTP ${n.status}${o?`, LogID ${o}`:""}`);let a=Z(r)&&Z(r.data)&&typeof r.data.url=="string"?r.data.url.trim():"";if(!a)throw new Error(`Attachment download URL response is missing data.url${o?`, LogID ${o}`:""}`);return a}function Je(e){let t=new URLSearchParams;e.env===G&&t.set("env",G);let n=t.toString(),o=`${ze}/${encodeURIComponent(e.token)}/invoke_get`;return n?`${o}?${n}`:o}function Ke(e,t){if(!He.test(t))throw new TypeError(`functionId ${t} does not match the required pattern ${String(He)}`);let n=`${ze}/${encodeURIComponent(e.token)}/functions/${encodeURIComponent(t)}/invoke`;return e.env===G?`${n}?env=${encodeURIComponent(G)}`:n}async function qn(e,t){let n=await N();if(!n.token)throw new Error(`Cannot invoke Function ${e} without an app token`);let o=await oe({url:Ke(n,e),init:{body:JSON.stringify({params:t}),headers:{"content-type":"application/json"},method:"POST"}});if(!o.ok)throw new Error(`Function ${e} request failed: HTTP ${o.status}`);return await o.json()}async function Vn(e,t){if(!Array.isArray(t)||t.length<1||t.length>200||t.some(r=>r===null||typeof r!="object"||Array.isArray(r)))throw new TypeError("Mutation batch requires 1 to 200 named parameter objects");let n=await N();if(!n.token)throw new Error("\u5E94\u7528 token \u672A\u786E\u5B9A\uFF0C\u65E0\u6CD5\u8C03\u7528 Mutation");let o=await oe({url:Ke(n,e),init:{body:JSON.stringify({batch:t.map(r=>({params:r}))}),headers:{"content-type":"application/json"},method:"POST"}});if(!o.ok)throw new Error(`Mutation \u8C03\u7528\u5931\u8D25\uFF1AHTTP ${o.status}`);return await o.json()}async function Gn(e,t){let n=await Dt(e,t);if(!(await re(n)).opened)throw new Error("The host did not open the attachment download link")}function Jn(e,t,n=360){if(!e.gatewayOrigin||!e.token||!ye(t))return"";let o=[120,360,720,1280].find(s=>s>=n)??1280,r=new URLSearchParams({extra:JSON.stringify({bitablePerm:{tableId:t.tableId,attachments:{[t.fieldId]:{[t.recordId]:[t.fileToken]}},baseAppToken:e.token}}),width:String(o),height:String(o),policy:"allow_up",fallback_source:"1"});return`${e.gatewayOrigin}/space/api/box/stream/download/v2/cover/${encodeURIComponent(t.fileToken)}?${r.toString()}`}var Re=Mt(void 0),Ye=[{id:"en",locale:"en-US",match:/^en(?:-|$)/},{id:"zh",locale:"zh-CN",match:/^zh(?:-|$)/},{id:"ja",locale:"ja-JP",match:/^ja(?:-|$)/}],ve=new Set,We,we=null;function Ce(e){if(typeof e!="string")return;let t=e.trim().replace(/_/g,"-").toLowerCase();return Ye.find(({match:n})=>n.test(t))?.id}function Nt(){return typeof navigator>"u"?void 0:navigator.language}function jt(e,t){return Ce(e)??Ce(t)??"en"}function j(){return We??jt(void 0,Nt())}function Ee(e=j()){return Ye.find(({id:t})=>t===e)?.locale??"en-US"}function Bt(e){return ve.add(e),()=>ve.delete(e)}function Qe(e){We=Ce(e);let t=j();Ze(t);for(let n of ve)n();return t}function Ze(e){typeof document<"u"&&(document.documentElement.lang=Ee(e))}function $t(){return we||(Ze(j()),we=E.getRuntimeContext().then(e=>Qe(e?.locale)).catch(()=>Qe(void 0))),we}function P(){let e=Lt(Re),t=Ot(Bt,j,()=>"en");return Ft(()=>{e||$t()},[e]),e??t}import{jsx as Ue}from"react/jsx-runtime";var Se=Ht(null);function no({children:e,...t}){return Ue(Se.Provider,{value:t,children:Ue(Re.Provider,{value:t.locale,children:Ue("div",{className:"base-app-platform","data-theme":t.theme,children:e})})})}function oo(){let e=Xe(Se);if(!e)throw new Error("BASE_APP_PROVIDER_REQUIRED");return e}function ae(){return Xe(Se)}import{useState as X,useEffect as nt}from"react";import{QueryClient as zt}from"@tanstack/react-query";var Pe=new zt({defaultOptions:{queries:{retry:!1,staleTime:3e4,gcTime:3e4}}});function ie(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function se(e,t){let n=e[t];return typeof n=="string"?n.trim():""}function qt(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}function B(){return{baseBindings:[],name:"",description:"",isOwner:!1,allowEdit:!1,organization:""}}function Vt(){let e=document.querySelector('meta[name="description"]');return e instanceof HTMLMetaElement?e:null}function Gt(e){if(e.name&&(document.title=e.name),e.description){let t=Vt();t&&(t.content=e.description)}}function Jt(e){return Array.isArray(e)?e.reduce((t,n)=>{if(!ie(n))return t;let o=se(n,"baseToken");return o&&t.push({baseToken:o,tableIds:qt(n.tableIds)}),t},[]):[]}function Kt(e){if(!ie(e)||e.code!==0)return B();let t=e.data;if(!ie(t))return B();let n=t.site;return ie(n)?{baseBindings:Jt(n.baseBindings),description:se(n,"description"),name:se(n,"name"),isOwner:t.isOwner===!0,allowEdit:n.allowEdit===void 0?t.isOwner===!0:n.allowEdit===!0,organization:se(n,"organization")}:B()}async function et(e){try{let t=await _(Je(e),{method:"GET"});if(!t.ok)return B();let n=await t.json(),o=Kt(n);return Gt(o),o}catch{return B()}}async function J(){let e=await N();if(!e.token)return B();let t=await Y().catch(()=>null);return t?.userId?Pe.fetchQuery({queryKey:["project-meta",e.token,e.env,t.userId],queryFn:()=>et(e)}):et(e)}var Qt="https://feishu.cn/base/site/detail/overview";async function tt(){try{await E.requestEdit();return}catch{let{token:e}=await N(),t=new URL(Qt);if(t.searchParams.set("token",e),!(await re(t.toString())).opened)throw new Error("Management page was not opened")}}import{jsx as $,jsxs as ot}from"react/jsx-runtime";var Yt={en:{openFailed:"Unable to open the management page. Please try again.",editSite:"Edit and manage your apps",hidePanel:"Hide until next visit",hiddenConfirmation:"Edit button hidden until you reopen the app",dismissNotification:"Dismiss notification"},zh:{openFailed:"\u65E0\u6CD5\u6253\u5F00\u7BA1\u7406\u9875\u9762\uFF0C\u8BF7\u91CD\u8BD5",editSite:"\u7F16\u8F91\u4E0E\u7BA1\u7406\u5E94\u7528",hidePanel:"\u9690\u85CF\u9762\u677F",hiddenConfirmation:"\u7F16\u8F91\u6309\u94AE\u5DF2\u9690\u85CF\uFF0C\u76F4\u81F3\u4E0B\u6B21\u91CD\u65B0\u6253\u5F00\u5E94\u7528",dismissNotification:"\u5173\u95ED\u63D0\u793A"},ja:{openFailed:"\u7BA1\u7406\u30DA\u30FC\u30B8\u3092\u958B\u3051\u307E\u305B\u3093\u3067\u3057\u305F\u3002\u3082\u3046\u4E00\u5EA6\u304A\u8A66\u3057\u304F\u3060\u3055\u3044\u3002",editSite:"\u30A2\u30D7\u30EA\u3092\u7DE8\u96C6\u30FB\u7BA1\u7406",hidePanel:"\u6B21\u56DE\u306E\u30A2\u30AF\u30BB\u30B9\u307E\u3067\u975E\u8868\u793A",hiddenConfirmation:"\u7DE8\u96C6\u30DC\u30BF\u30F3\u3092\u975E\u8868\u793A\u306B\u3057\u307E\u3057\u305F\u3002\u30A2\u30D7\u30EA\u3092\u518D\u5EA6\u958B\u304F\u3068\u8868\u793A\u3055\u308C\u307E\u3059",dismissNotification:"\u901A\u77E5\u3092\u9589\u3058\u308B"}};function vo({position:e="bottom-right",className:t="",slots:n={}}){let o=Yt[P()],[r,s]=X(!1),[a,i]=X(!1),[c,d]=X(!1),[u,p]=X(!1),[g,f]=X(!1);nt(()=>{let b=!0;return J().then(L=>{b&&s(L.allowEdit&&be().env==="prod")}).catch(()=>{}),()=>{b=!1}},[]),nt(()=>{if(!c)return;let b=setTimeout(()=>d(!1),3e3);return()=>clearTimeout(b)},[c]);let m=n.trigger,v=n.tooltip;return r?a?c?ot("div",{className:"base-app-platform base-app-notice",role:"status",children:[o.hiddenConfirmation,$("button",{"aria-label":o.dismissNotification,onClick:()=>d(!1),children:"\xD7"})]}):null:ot("div",{className:`base-app-platform base-app-floating ${t}`,"data-position":e,children:[u?$("div",{role:"alert",children:o.openFailed}):null,g?$("div",{role:"tooltip",children:v?$(v,{text:o.editSite}):o.editSite}):null,$("button",{"aria-label":o.editSite,onFocus:()=>f(!0),onBlur:()=>f(!1),onMouseEnter:()=>f(!0),onMouseLeave:()=>f(!1),onClick:()=>{p(!1),tt().catch(()=>p(!0))},children:m?$(m,{}):"\u270E"}),$("button",{"aria-label":o.hidePanel,onClick:()=>{i(!0),d(!0)},children:"\xD7"})]}):null}var xe=new Set;function rt(e){return xe.add(e),()=>{xe.delete(e)}}function at(){for(let e of xe)e()}import{useEffect as Wt,useState as st}from"react";import*as D from"@radix-ui/react-popover";async function it(){try{let e=await Y();if(typeof e?.name=="string"&&e.name)return{name:e.name,avatarUrl:typeof e.avatarUrl=="string"?e.avatarUrl:"",tenantName:""}}catch{}try{let e=await _("/space/api/user/",{headers:{accept:"application/json"}});if(!e.ok)return null;let n=(await e.json()).data;return!n||typeof n.name!="string"||!n.name?null:{name:n.name,avatarUrl:typeof n.avatar_url=="string"?n.avatar_url:"",tenantName:typeof n.tenant_name=="string"?n.tenant_name:""}}catch{return null}}import{Fragment as Xt,jsx as x,jsxs as ke}from"react/jsx-runtime";var Zt={en:{account:"Account",logout:"Log out"},zh:{account:"\u8D26\u53F7",logout:"\u9000\u51FA\u767B\u5F55"},ja:{account:"\u30A2\u30AB\u30A6\u30F3\u30C8",logout:"\u30ED\u30B0\u30A2\u30A6\u30C8"}};function Mo({audience:e="enterprise",align:t="right",side:n="down",showName:o=!0,className:r="",slots:s={}}){let[a,i]=st(null),[c,d]=st(""),u=ae(),p=Zt[P()];if(Wt(()=>{if(e!=="enterprise")return;let m=!0;return Promise.all([it(),J().catch(()=>null)]).then(([v,b])=>{m&&(i(v),d(v?.tenantName||b?.organization||""))}),()=>{m=!1}},[e]),e!=="enterprise"||!a)return null;let g=s.trigger,f=s.organization;return ke(D.Root,{children:[x(D.Trigger,{asChild:!0,children:x("button",{className:`base-app-platform base-app-user-menu ${r}`,"aria-label":p.account,children:g?x(g,{user:a}):ke(Xt,{children:[a.avatarUrl?x("img",{src:a.avatarUrl,alt:"",referrerPolicy:"no-referrer"}):x("span",{children:a.name.slice(0,1)}),o?a.name:null]})})}),x(D.Portal,{children:ke(D.Content,{"data-theme":u?.theme,className:"base-app-platform base-app-popover",align:t==="right"?"end":"start",side:n==="up"?"top":"bottom",sideOffset:8,collisionPadding:8,children:[x("strong",{children:a.name}),f?x(f,{name:c}):x("p",{children:c}),x("button",{onClick:()=>{at(),Pe.clear(),he().catch(()=>{for(let m of["base-site-session","session","sl_session"])document.cookie=`${m}=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/`;window.location.reload()})},children:p.logout})]})})]})}import{useEffect as ce,useRef as dt,useState as z}from"react";import{Command as ee}from"cmdk";import{QueryClient as dn,useQuery as pn}from"@tanstack/react-query";var en="/space/api/mention/recommend.v2/",tn="8",nn="4",on="0",rn=20,ct={en:{businessError:e=>`Could not search members (error code ${e})`,httpError:e=>`Member search request failed: HTTP ${e}`,invalidResponse:"Member search response has an invalid structure",noBoundBase:"Cannot search members: the application is not bound to a Base"},zh:{businessError:e=>`\u641C\u7D22\u6210\u5458\u5931\u8D25\uFF08\u9519\u8BEF\u7801 ${e}\uFF09`,httpError:e=>`\u641C\u7D22\u6210\u5458\u8BF7\u6C42\u5931\u8D25\uFF1AHTTP ${e}`,invalidResponse:"\u6210\u5458\u641C\u7D22\u54CD\u5E94\u7ED3\u6784\u65E0\u6548",noBoundBase:"\u65E0\u6CD5\u641C\u7D22\u6210\u5458\uFF1A\u5E94\u7528\u5C1A\u672A\u7ED1\u5B9A\u591A\u7EF4\u8868\u683C"},ja:{businessError:e=>`\u30E1\u30F3\u30D0\u30FC\u3092\u691C\u7D22\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F\uFF08\u30A8\u30E9\u30FC\u30B3\u30FC\u30C9 ${e}\uFF09`,httpError:e=>`\u30E1\u30F3\u30D0\u30FC\u691C\u7D22\u306E\u30EA\u30AF\u30A8\u30B9\u30C8\u306B\u5931\u6557\u3057\u307E\u3057\u305F\uFF1AHTTP ${e}`,invalidResponse:"\u30E1\u30F3\u30D0\u30FC\u691C\u7D22\u306E\u5FDC\u7B54\u5F62\u5F0F\u304C\u6B63\u3057\u304F\u3042\u308A\u307E\u305B\u3093",noBoundBase:"\u30E1\u30F3\u30D0\u30FC\u3092\u691C\u7D22\u3067\u304D\u307E\u305B\u3093\uFF1A\u30A2\u30D7\u30EA\u306BBase\u304C\u95A2\u9023\u4ED8\u3051\u3089\u308C\u3066\u3044\u307E\u305B\u3093"}};async function lt(e,t,n){let o=t??j(),r=ct[o],a=(await J()).baseBindings[0]?.baseToken;if(!a)throw new Error(r.noBoundBase);let i=new URLSearchParams({config_source:"0",obj_type:tn,source:nn,token:a,type:on,user_type:"0",content:e.trim().slice(0,50)}).toString(),c=await _(en,{signal:n,body:i,headers:{"content-type":"application/x-www-form-urlencoded"},method:"POST"});if(!c.ok)throw new Error(r.httpError(c.status));let d=await c.json();return{code:0,msg:"ok",data:an(d,o)}}function an(e,t=j()){let n=Ee(t),o=ct[t],r=sn(e,o);if(!r)throw new Error(o.invalidResponse);let s=r.entities,a=H(s)?s.users:void 0;if(!H(a)||!Array.isArray(r.result_list))throw new Error(o.invalidResponse);let i=[],c=new Set;for(let d of r.result_list){if(!H(d)||Number(d.type)!==0)continue;let u=h(d.token);if(!u)continue;let p=a[u];if(!H(p))continue;let g=h(p.user_id)||h(p.id)||u,f=cn(p,n);if(!g||!f||c.has(g))continue;c.add(g);let m=h(p.avatar_url),v=h(p.open_id);if(i.push({avatar:{avatar_72:m,avatar_240:m,avatar_640:m,avatar_origin:m},department_ids:un(p.department_ids),description:ln(p,n),is_external:p.is_external===!0,name:f,user_id:g,...v?{open_id:v}:{}}),i.length>=rn)break}return{users:i}}function sn(e,t){if(H(e)){if(typeof e.code=="number"&&e.code!==0){let n=h(e.msg);throw Object.assign(new Error(n||t.businessError(e.code)),{code:String(e.code),cause:e})}return"entities"in e&&"result_list"in e?e:H(e.data)?e.data:void 0}}function cn(e,t){return ut(e.display_name,t)||(t.toLowerCase().startsWith("zh")?h(e.cn_name):h(e.en_name))||h(e.name)||h(e.en_name)||h(e.cn_name)}function ln(e,t){let n=e.is_external===!0?e.i18n_tenant:e.i18n_department;return ut(n,t)||h(e.department)}function ut(e,t){if(typeof e=="string")return e.trim();if(!H(e))return"";let n=t.toLowerCase().replace("-","_"),o=n.split("_")[0]??"",r=o==="zh"?h(e.zh_cn)||h(e.en_us):h(e.en_us)||h(e.zh_cn);return h(e[n])||h(e[o])||r}function h(e){return typeof e=="string"?e.trim():""}function un(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}function H(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}import{Fragment as mt,jsx as R,jsxs as Ae}from"react/jsx-runtime";var ft={en:{invalidResponse:"Member search response has an invalid structure",loading:"Loading...",memberList:"Member list",noMatches:"No matching members. Try another search term.",noRecommendations:"No recommended members yet",recordCreator:"Add the person who created this record",searchFailed:"Member search failed",searchFailedCode:e=>`Could not search members (error code ${e})`,searchMembers:"Search members"},zh:{invalidResponse:"\u6210\u5458\u641C\u7D22\u54CD\u5E94\u7ED3\u6784\u65E0\u6548",loading:"\u52A0\u8F7D\u4E2D...",memberList:"\u6210\u5458\u5217\u8868",noMatches:"\u6CA1\u6709\u5339\u914D\u7684\u6210\u5458\uFF0C\u8BF7\u6362\u4E2A\u5173\u952E\u8BCD",noRecommendations:"\u6682\u65E0\u63A8\u8350\u6210\u5458",recordCreator:"\u6DFB\u52A0\u6B64\u8BB0\u5F55\u7684\u4EBA\u5458",searchFailed:"\u641C\u7D22\u6210\u5458\u5931\u8D25",searchFailedCode:e=>`\u641C\u7D22\u6210\u5458\u5931\u8D25\uFF08\u9519\u8BEF\u7801 ${e}\uFF09`,searchMembers:"\u641C\u7D22\u6210\u5458"},ja:{invalidResponse:"\u30E1\u30F3\u30D0\u30FC\u691C\u7D22\u306E\u5FDC\u7B54\u5F62\u5F0F\u304C\u6B63\u3057\u304F\u3042\u308A\u307E\u305B\u3093",loading:"\u8AAD\u307F\u8FBC\u307F\u4E2D...",memberList:"\u30E1\u30F3\u30D0\u30FC\u4E00\u89A7",noMatches:"\u4E00\u81F4\u3059\u308B\u30E1\u30F3\u30D0\u30FC\u304C\u3044\u307E\u305B\u3093\u3002\u5225\u306E\u30AD\u30FC\u30EF\u30FC\u30C9\u3067\u691C\u7D22\u3057\u3066\u304F\u3060\u3055\u3044\u3002",noRecommendations:"\u304A\u3059\u3059\u3081\u306E\u30E1\u30F3\u30D0\u30FC\u304C\u3044\u307E\u305B\u3093",recordCreator:"\u3053\u306E\u30EC\u30B3\u30FC\u30C9\u306E\u4F5C\u6210\u8005\u3092\u8FFD\u52A0",searchFailed:"\u30E1\u30F3\u30D0\u30FC\u306E\u691C\u7D22\u306B\u5931\u6557\u3057\u307E\u3057\u305F",searchFailedCode:e=>`\u30E1\u30F3\u30D0\u30FC\u3092\u691C\u7D22\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F\uFF08\u30A8\u30E9\u30FC\u30B3\u30FC\u30C9 ${e}\uFF09`,searchMembers:"\u30E1\u30F3\u30D0\u30FC\u3092\u691C\u7D22"}};function le(e){let[t,n]=z(!1),[o,r]=z(!1);ce(()=>r(!0),[]);let s=P(),a=ft[s],[i]=z(()=>new dn({defaultOptions:{queries:{retry:!1,staleTime:3e4,gcTime:3e4}}}));ce(()=>{let l=rt(()=>{n(!0),i.clear()});return()=>{l(),i.clear()}},[i]);let c=Object.prototype.hasOwnProperty.call(e,"value"),d=dt(c);ce(()=>{c!==d.current&&console.warn("UserSelectorPanel controlled mode changed")},[c]);let[u,p]=z(e.defaultValue),g=c?e.value:u,f=Array.isArray(g)?g:g?[g]:[],[m,v]=z(""),[b,L]=z(""),[k,K]=z(!1),F=dt(!1);ce(()=>{if(k)return;let l=setTimeout(()=>L(m.trim()),m.trim()?400:0);return()=>clearTimeout(l)},[m,k]);let y=pn({queryKey:["members",s,b],queryFn:async({signal:l})=>{let C=await lt(b,s,l);return mn(C,s)},enabled:!t&&o&&!k&&m.trim()===b},i),w=e.loading||y.isFetching||m.trim()!==b,A=!t&&!w&&!y.error&&y.data?[...y.data.users,...f.filter(l=>!y.data.users.some(C=>C.user_id===l.user_id))]:[],U=(l,C)=>{v(l),e.onSearch?.(l,{action:C})},ue=()=>{U("","AutoClear"),e.onClose?.()},yt=l=>{if(F.current)return;let C=f.some(de=>de.user_id===l.user_id),te=e.mode==="multiple"?C?f.filter(de=>de.user_id!==l.user_id):[...f,l]:C?void 0:l;c||p(te),e.onChange?.(te,{option:l,action:C?"Remove":"Select"}),C||e.onSelect?.(l,{option:l}),e.mode==="multiple"?U("","AutoClear"):ue()},Ie=e.slots?.empty,_e=e.slots?.loading,De=e.slots?.option,Me=e.slots?.footer;return Ae(ee,{shouldFilter:!1,loop:!0,className:`base-app-platform base-app-selector ${e.className??""}`,label:a.memberList,children:[R(ee.Input,{autoFocus:!0,placeholder:a.searchMembers,"aria-label":a.searchMembers,value:m,onValueChange:l=>U(l,"Input"),onCompositionStart:()=>{F.current=!0,K(!0)},onCompositionEnd:()=>{F.current=!1,K(!1)},onKeyDown:l=>{if(e.onKeyDown?.(l),l.defaultPrevented){l.stopPropagation();return}if(F.current||fn(l)){l.stopPropagation();return}l.key==="Escape"&&(l.preventDefault(),ue())}}),R(ee.List,{"aria-label":a.memberList,"aria-multiselectable":e.mode==="multiple"||void 0,children:w?R("div",{role:"status",children:_e?R(_e,{}):a.loading}):y.error?R("div",{role:"alert",children:a.searchFailed}):Ae(mt,{children:[e.onSelectRecordCreator?R(ee.Item,{value:"record-creator",onSelect:()=>{e.onSelectRecordCreator?.(),ue()},children:a.recordCreator}):null,A.map(l=>{let C=f.some(te=>te.user_id===l.user_id);return R(ee.Item,{value:l.user_id,onSelect:()=>yt(l),"data-checked":C,children:De?R(De,{user:l,selected:C}):Ae(mt,{children:[R("span",{children:l.name}),R("small",{children:e.getUserDescription?.(l)??l.description}),C?R("span",{"aria-label":"selected",children:"\u2713"}):null]})},l.user_id)}),!A.length&&!e.onSelectRecordCreator?R("div",{role:"status",children:Ie?R(Ie,{}):m.trim()?a.noMatches:a.noRecommendations}):null]})}),Me?R(Me,{}):null]})}function mn(e,t){let n=ft[t];if(!pt(e)||typeof e.code!="number")throw new Error(n.invalidResponse);if(e.code!==0){let o=typeof e.msg=="string"?e.msg.trim():"";throw Object.assign(new Error(o||n.searchFailedCode(e.code)),{code:String(e.code),cause:e})}if(!pt(e.data)||!Array.isArray(e.data.users))throw new Error(n.invalidResponse);return{users:e.data.users}}function pt(e){return typeof e=="object"&&e!==null}function fn(e){return e.nativeEvent?.isComposing===!0||e.keyCode===229}import{useState as gn,useRef as hn}from"react";import*as M from"@radix-ui/react-popover";import{jsx as I,jsxs as gt}from"react/jsx-runtime";var bn={en:{clearSelected:"Clear selected members",removeMember:e=>`Remove member ${e}`,selectMembers:"Select members"},zh:{clearSelected:"\u6E05\u9664\u5DF2\u9009\u6210\u5458",removeMember:e=>`\u79FB\u9664\u6210\u5458 ${e}`,selectMembers:"\u9009\u62E9\u6210\u5458"},ja:{clearSelected:"\u9078\u629E\u3057\u305F\u30E1\u30F3\u30D0\u30FC\u3092\u30AF\u30EA\u30A2",removeMember:e=>`\u30E1\u30F3\u30D0\u30FC ${e} \u3092\u524A\u9664`,selectMembers:"\u30E1\u30F3\u30D0\u30FC\u3092\u9078\u629E"}};function ht(e){let t=hn(null),n=ae(),o=bn[P()],[r,s]=gn(!1),a=Array.isArray(e.value)?e.value:e.value?[e.value]:[],i=u=>{s(u),u!==r&&e.onDropdownVisibleChange?.(u)},c=e.slots?.trigger,d=e.slots?.chip;return gt(M.Root,{open:r,onOpenChange:i,children:[gt("div",{ref:t,className:`base-app-platform base-app-editor ${e.className??""}`,onClickCapture:u=>{u.target.closest("[data-base-app-trigger]")&&e.onClick?.(u)},children:[I(M.Trigger,{asChild:!0,children:I("button",{type:"button","data-base-app-trigger":"","aria-label":o.selectMembers,onFocus:e.onFocus,onBlur:e.onBlur,children:c?I(c,{value:e.value}):a.length?a.map(u=>I("span",{children:d?I(d,{user:u}):u.name},u.user_id)):o.selectMembers})}),a.map(u=>I("button",{type:"button","aria-label":e.mode==="multiple"?o.removeMember(u.name):o.clearSelected,onClick:p=>{p.stopPropagation(),e.onChange?.(e.mode==="multiple"?a.filter(g=>g.user_id!==u.user_id):void 0),e.mode==="multiple"?e.onRemove?.(u):e.onClear?.()},children:"\xD7"},u.user_id))]}),I(M.Portal,{container:e.portalContainer??t.current?.closest("dialog")??void 0,children:I(M.Content,{"data-theme":n?.theme,className:"base-app-platform base-app-popover",sideOffset:4,collisionPadding:8,children:I(le,{...e,slots:void 0,onChange:(u,p)=>{e.onChange?.(u),p.action==="Remove"&&p.option&&e.onRemove?.(p.option)},onClose:()=>i(!1)})})})]})}import{useEffect as bt,useRef as yn,useState as Te}from"react";import{jsx as q,jsxs as vn}from"react/jsx-runtime";var wn={en:{decodeFailed:"Image could not be decoded",loadFailed:"Failed to load image",loading:"Loading image",retry:"Retry image"},zh:{decodeFailed:"\u56FE\u7247\u65E0\u6CD5\u89E3\u7801",loadFailed:"\u56FE\u7247\u52A0\u8F7D\u5931\u8D25",loading:"\u56FE\u7247\u52A0\u8F7D\u4E2D",retry:"\u91CD\u8BD5\u56FE\u7247"},ja:{decodeFailed:"\u753B\u50CF\u3092\u8868\u793A\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F",loadFailed:"\u753B\u50CF\u3092\u8AAD\u307F\u8FBC\u3081\u307E\u305B\u3093\u3067\u3057\u305F",loading:"\u753B\u50CF\u3092\u8AAD\u307F\u8FBC\u307F\u4E2D",retry:"\u753B\u50CF\u3092\u518D\u8AAD\u307F\u8FBC\u307F"}};function ir({attachment:e,size:t=360,alt:n,className:o,slots:r={}}){let s=P(),a=wn[s],i=yn(null),[c,d]=Te(!1),[u,p]=Te(0),[g,f]=Te({key:"",url:"",error:""}),{tableId:m,fieldId:v,recordId:b,fileToken:L}=e,k=JSON.stringify([m,v,b,L,t,u]);bt(()=>{if(typeof IntersectionObserver>"u"){d(!0);return}let w=new IntersectionObserver(A=>{A.some(U=>U.isIntersecting)&&(d(!0),w.disconnect())},{rootMargin:"200px"});return i.current&&w.observe(i.current),()=>w.disconnect()},[]),bt(()=>{if(!c)return;let w=new AbortController,A="";return Ge({tableId:m,fieldId:v,recordId:b,fileToken:L},t,{signal:w.signal}).then(U=>{w.signal.aborted||(A=URL.createObjectURL(U),f({key:k,url:A,error:""}))}).catch(U=>{w.signal.aborted||f({key:k,url:"",error:U instanceof Error?U.message:"",localError:U instanceof Error?void 0:"loadFailed"})}),()=>{w.abort(),A&&URL.revokeObjectURL(A)}},[c,k,m,v,b,L,t]);let K=r.loading,F=r.error,y=g.key===k?g:void 0;return q("span",{ref:i,className:`base-app-platform base-app-attachment ${o??""}`,"aria-busy":!y,children:y?.url?q("img",{src:y.url,alt:n,onError:()=>f({key:k,url:"",error:"",localError:"decodeFailed"})}):y?.error||y?.localError?F?q(F,{code:"ATTACHMENT_LOAD_FAILED",retry:()=>p(w=>w+1)}):vn("span",{children:[q("span",{role:"status",children:y.localError?a[y.localError]:y.error}),q("button",{type:"button",onClick:()=>p(w=>w+1),children:a.retry})]}):q("span",{role:"status",children:K?q(K,{}):a.loading})})}export{En as a,ne as b,Un as c,Sn as d,Pn as e,xn as f,kn as g,$e as h,ge as i,fe as j,jn as k,E as l,oe as m,Bn as n,Y as o,he as p,St as q,$n as r,re as s,Pt as t,_ as u,me as v,wt as w,vt as x,In as y,Ct as z,Oe as A,be as B,N as C,Ge as D,Dt as E,Je as F,Ke as G,qn as H,Vn as I,Gn as J,Jn as K,Re as L,jt as M,j as N,Ee as O,$t as P,P as Q,no as R,oo as S,ae as T,Pe as U,vo as V,Mo as W,le as X,ht as Y,ir as Z};