@objectstack/console 9.7.0 → 9.8.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/assets/{AdapterProvider-o2n9dY2j.js → AdapterProvider-CGofnJBf.js} +1 -1
- package/dist/assets/{AiPendingActionsPage-DGAL-HJ9.js → AiPendingActionsPage-CaJCvm5D.js} +1 -1
- package/dist/assets/{ApiConsolePage-DNuInlzy.js → ApiConsolePage-DGCgQ6RS.js} +1 -1
- package/dist/assets/{AppDocsIndex-DtACBq8P.js → AppDocsIndex-B_hZ36LW.js} +1 -1
- package/dist/assets/{AppManagementPage-BSgP2T9T.js → AppManagementPage-DN-u3YQP.js} +1 -1
- package/dist/assets/ApprovalsInboxPage-BbvtY-xj.js +1 -0
- package/dist/assets/{AuditLogPage-B_gxba-u.js → AuditLogPage-ffz9xeHl.js} +1 -1
- package/dist/assets/{ComponentNavView-BSV-rPCq.js → ComponentNavView-B6LSKpd-.js} +1 -1
- package/dist/assets/ConsoleFloatingChatbot-CsiQ_KDu.js +1 -0
- package/dist/assets/DashboardView-CsknMwAh.js +1 -0
- package/dist/assets/{DashboardWidgetInspector-CNmycNmj.js → DashboardWidgetInspector-DSLIsQS9.js} +1 -1
- package/dist/assets/{DeveloperHubPage-YvUkG7Lt.js → DeveloperHubPage-DZyjalsK.js} +1 -1
- package/dist/assets/{ExpressionProvider-Cuv0RaiR.js → ExpressionProvider-wi1dJ2tN.js} +1 -1
- package/dist/assets/FlowRunsPage-DcT6ntvZ.js +1 -0
- package/dist/assets/{IntegrationsPage-C8k36Ie_.js → IntegrationsPage-Dfl35fAT.js} +2 -2
- package/dist/assets/{InterfaceListPage-DTHEyaKG.js → InterfaceListPage-DAJiEE0k.js} +1 -1
- package/dist/assets/{ManagedByBadge-B60ZX6y9.js → ManagedByBadge-BAL_PuGz.js} +1 -1
- package/dist/assets/MarketplaceAccessDenied-BBUl4uOo.js +1 -0
- package/dist/assets/MarketplaceInstalledPage-CaN54GxZ.js +1 -0
- package/dist/assets/MarketplacePackagePage-SKgqOj7g.js +4 -0
- package/dist/assets/MarketplacePage-CoigR7d_.js +1 -0
- package/dist/assets/{MetadataInspector-zJtxyFau.js → MetadataInspector-BGWYqUse.js} +1 -1
- package/dist/assets/{MetadataProvider-BagIop6q.js → MetadataProvider-_6IU7cWK.js} +1 -1
- package/dist/assets/PageView-CxOhEFic.js +1 -0
- package/dist/assets/{ProfilePage-0yyBZHjT.js → ProfilePage-C11r_2xN.js} +1 -1
- package/dist/assets/PublicFormsPage-N0Wofan4.js +1 -0
- package/dist/assets/RecordDetailView-Bh6I2k3c.js +1 -0
- package/dist/assets/{RecordFormPage-DqFdHPz8.js → RecordFormPage-1zrrumdr.js} +1 -1
- package/dist/assets/ReportDefaultInspector--SQsifZI.js +1 -0
- package/dist/assets/{ReportView-Cx-qFxJZ.js → ReportView-q3jNGyaI.js} +1 -1
- package/dist/assets/{RuntimeDraftBar-Be6SQ4g6.js → RuntimeDraftBar-DaYAgW5v.js} +1 -1
- package/dist/assets/{SearchResultsPage-DkQMPMlE.js → SearchResultsPage-BRnB7VD4.js} +1 -1
- package/dist/assets/{SettingsHub-el09ZPJP.js → SettingsHub-CUCcntU9.js} +1 -1
- package/dist/assets/{SettingsView-BiYeb1nb.js → SettingsView-DRjJrXF9.js} +1 -1
- package/dist/assets/{SystemHubPage-QSk3FL5a.js → SystemHubPage-_i5E_SOC.js} +1 -1
- package/dist/assets/{data-adapter-BtpuYbBh.js → data-adapter-CzKUUIgi.js} +1 -1
- package/dist/assets/{framework-ZJouI0cJ.js → framework-DLckRGJs.js} +3 -3
- package/dist/assets/{highlighted-body-OFNGDK62-DfdyR_41.js → highlighted-body-OFNGDK62-JYK0hMjr.js} +1 -1
- package/dist/assets/index-DGuFGryh.css +2 -0
- package/dist/assets/index-JrHkY-wh.js +4 -0
- package/dist/assets/marketplaceApi-CucX7DD9.js +1 -0
- package/dist/assets/{mergeServerFields-DPrTk8u4.js → mergeServerFields-CM4cY1zR.js} +4 -4
- package/dist/assets/mermaid-GHXKKRXX-Bg8PoWKD.js +1 -0
- package/dist/assets/metadata-admin-B5WWi7HS.js +19 -0
- package/dist/assets/{plugin-calendar-CwYuZf8c.js → plugin-calendar-DCCbdIpj.js} +1 -1
- package/dist/assets/{plugin-charts-DhlEvpuy.js → plugin-charts-Do3qrshN.js} +2 -2
- package/dist/assets/plugin-chatbot-DF5LNhQ2.js +120 -0
- package/dist/assets/plugin-dashboard-BQ3awX8y.js +5 -0
- package/dist/assets/plugin-form-FmgnWzcl.js +1 -0
- package/dist/assets/plugin-gantt-CWw13thv.js +23 -0
- package/dist/assets/plugin-grid-Cd-2qFJP.js +6 -0
- package/dist/assets/plugin-kanban-CYKs5Fuv.js +1 -0
- package/dist/assets/{plugin-map-Cz9tJHoZ.js → plugin-map-DuGG00x5.js} +1 -1
- package/dist/assets/{plugin-markdown-_H-xFg2t.js → plugin-markdown-Du1ajwhj.js} +3 -2
- package/dist/assets/plugin-report-D0COS83c.js +59 -0
- package/dist/assets/{plugin-timeline-DjngAdR-.js → plugin-timeline-BBYlrrgQ.js} +1 -1
- package/dist/assets/plugin-view-BhoDHK4P.js +1 -0
- package/dist/assets/plugins-views-gs7PYt1Y.js +4 -0
- package/dist/assets/{resolveActionParams-ergReBd1.js → resolveActionParams-DjRjW-gD.js} +3 -3
- package/dist/assets/{skeletons-BRDBm95C.js → skeletons-Cdt8ttDk.js} +1 -1
- package/dist/assets/{src-B5JRlZgC.js → src-BPf-hjw2.js} +1 -1
- package/dist/assets/{types-fX7qb4I3.js → types-DjNzBgbB.js} +1 -1
- package/dist/assets/ui-components-B2CBE2Rs.js +42 -0
- package/dist/assets/{ui-layout-CswtJjnW.js → ui-layout-D19iPz4K.js} +1 -1
- package/dist/assets/{useActionModal-d8GNl1HP.js → useActionModal-BKaoxO40.js} +1 -1
- package/dist/index.html +4 -4
- package/package.json +1 -1
- package/dist/assets/ApprovalsInboxPage-jrTqrLxX.js +0 -1
- package/dist/assets/ConsoleFloatingChatbot-B1xDv7X-.js +0 -1
- package/dist/assets/DashboardView-BNUhTJ8Y.js +0 -1
- package/dist/assets/FlowRunsPage-DdjGSDw1.js +0 -1
- package/dist/assets/MarketplaceInstalledPage-DJN3P4aw.js +0 -1
- package/dist/assets/MarketplacePackagePage-BUrsYfA7.js +0 -4
- package/dist/assets/MarketplacePage-q23E8dYU.js +0 -1
- package/dist/assets/PageView-M09zUJqv.js +0 -1
- package/dist/assets/PublicFormsPage-BPEDFiNo.js +0 -1
- package/dist/assets/RecordDetailView-cj45YVH-.js +0 -1
- package/dist/assets/ReportDefaultInspector-D5dIioUJ.js +0 -1
- package/dist/assets/index-B99f8h8i.js +0 -4
- package/dist/assets/index-BXu9hpEZ.css +0 -2
- package/dist/assets/marketplaceApi-DCvJ2C6u.js +0 -1
- package/dist/assets/mermaid-GHXKKRXX-BF-AoOMn.js +0 -1
- package/dist/assets/metadata-admin-DT8BohcC.js +0 -19
- package/dist/assets/plugin-chatbot-CJsfoGAD.js +0 -120
- package/dist/assets/plugin-dashboard-CGRjBe2V.js +0 -5
- package/dist/assets/plugin-form-C5yl9byI.js +0 -1
- package/dist/assets/plugin-gantt-C5hIQDHF.js +0 -23
- package/dist/assets/plugin-grid-2QHjCxCx.js +0 -6
- package/dist/assets/plugin-kanban-LtqKit9T.js +0 -1
- package/dist/assets/plugin-report-DA6bVPuW.js +0 -59
- package/dist/assets/plugin-view-BUsWmCh-.js +0 -1
- package/dist/assets/plugins-views-yfd0iHKg.js +0 -4
- package/dist/assets/runtime-config-BeHVOPm3.js +0 -1
- package/dist/assets/ui-components-Bs-DxYrW.js +0 -42
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,l as n,r,t as i}from"./vendor-react-DR370ovB.js";import{$n as a,Ct as o,Et as s,Gi as c,Gn as l,Ki as u,So as d,St as f,Tt as p,Un as m,Wn as h,Z as g,_t as _,lc as v,ni as y,ro as b,vt as x,wt as S,xs as C,xt as w,yt as T,zt as E}from"./ui-components-Bs-DxYrW.js";import{_ as D,c as O,d as k,g as A,h as j,n as M,o as N,p as P,s as F,t as I,u as L}from"./vendor-dndkit-DMFEUxSy.js";var R=e(t(),1),z=i();function B(e){let t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);if(!t)return null;let n=parseInt(t[1],16)/255,r=parseInt(t[2],16)/255,i=parseInt(t[3],16)/255,a=Math.max(n,r,i),o=Math.min(n,r,i),s=0,c=0,l=(a+o)/2;if(a!==o){let e=a-o;switch(c=l>.5?e/(2-a-o):e/(a+o),a){case n:s=((r-i)/e+(r<i?6:0))/6;break;case r:s=((i-n)/e+2)/6;break;case i:s=((n-r)/e+4)/6;break}}return{h:s*360,s:c*100,l:l*100}}function V(e){let t=B(e);return t?`${Math.round(t.h)} ${Math.round(t.s)}% ${Math.round(t.l)}%`:null}function H(e){let t=B(e);if(!t)return null;let n=Math.max(t.l,65),r=t.s>80?Math.max(t.s-10,70):t.s;return`${Math.round(t.h)} ${Math.round(r)}% ${Math.round(n)}%`}function U(e){let t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);if(!t)return`0 0% 100%`;let n=e=>{let t=e/255;return t<=.03928?t/12.92:((t+.055)/1.055)**2.4},r=n(parseInt(t[1],16)),i=n(parseInt(t[2],16)),a=n(parseInt(t[3],16));return .2126*r+.7152*i+.0722*a>.6?`222 47% 11%`:`0 0% 100%`}function W(e,t){(0,R.useEffect)(()=>{let n=document.documentElement,r=()=>n.classList.contains(`dark`),i=()=>{if(e?.primaryColor){let t=V(e.primaryColor),i=H(e.primaryColor),a=r()&&i||t;a&&(n.style.setProperty(`--brand-primary`,e.primaryColor),n.style.setProperty(`--brand-primary-hsl`,t||a),n.style.setProperty(`--primary`,a),n.style.setProperty(`--primary-foreground`,r()?`222 47% 11%`:U(e.primaryColor)),n.style.setProperty(`--ring`,a),n.style.setProperty(`--sidebar-primary`,a),n.style.setProperty(`--sidebar-ring`,a))}else n.style.removeProperty(`--brand-primary`),n.style.removeProperty(`--brand-primary-hsl`),n.style.removeProperty(`--primary`),n.style.removeProperty(`--primary-foreground`),n.style.removeProperty(`--ring`),n.style.removeProperty(`--sidebar-primary`),n.style.removeProperty(`--sidebar-ring`);if(e?.accentColor){let t=V(e.accentColor),i=H(e.accentColor),a=r()&&i||t;a&&(n.style.setProperty(`--brand-accent`,e.accentColor),n.style.setProperty(`--brand-accent-hsl`,t||a),n.style.setProperty(`--accent`,a),n.style.setProperty(`--accent-foreground`,r()?`222 47% 11%`:U(e.accentColor)))}else n.style.removeProperty(`--brand-accent`),n.style.removeProperty(`--brand-accent-hsl`),n.style.removeProperty(`--accent`),n.style.removeProperty(`--accent-foreground`)};i();let a=new MutationObserver(e=>{for(let t of e)if(t.type===`attributes`&&t.attributeName===`class`){i();break}});if(a.observe(n,{attributes:!0,attributeFilter:[`class`]}),e?.favicon){let t=document.querySelector(`#favicon`)||document.querySelector(`link[rel="icon"]`);t&&(t.href=e.favicon)}return t&&(document.title=t),()=>{a.disconnect(),n.style.removeProperty(`--brand-primary`),n.style.removeProperty(`--brand-primary-hsl`),n.style.removeProperty(`--brand-accent`),n.style.removeProperty(`--brand-accent-hsl`),n.style.removeProperty(`--primary`),n.style.removeProperty(`--primary-foreground`),n.style.removeProperty(`--ring`),n.style.removeProperty(`--sidebar-primary`),n.style.removeProperty(`--sidebar-ring`),n.style.removeProperty(`--accent`),n.style.removeProperty(`--accent-foreground`)}},[e?.primaryColor,e?.accentColor,e?.favicon,t])}function G({sidebar:e,navbar:t,children:n,className:r,defaultOpen:i=!0,branding:a}){return W(a,a?.title),(0,z.jsxs)(s,{defaultOpen:i,className:`!flex-col h-svh overflow-hidden`,children:[(0,z.jsx)(`header`,{className:`sticky top-0 z-30 flex h-14 w-full shrink-0 items-center gap-2 border-b bg-background px-2 sm:px-4`,children:t}),(0,z.jsxs)(`div`,{className:`flex flex-1 min-h-0 w-full`,children:[e,(0,z.jsx)(w,{className:`min-w-0`,children:(0,z.jsx)(`main`,{className:v(`flex-1 min-w-0 overflow-auto p-3 sm:p-4 md:p-6 pb-20 sm:pb-4 md:pb-6`,r),children:n})})]})]})}function K(e){return e?g(e):d}function q(e,t){if(typeof e==`string`)return e;if(t){let n=t(e.key,{defaultValue:e.defaultValue,...e.params});if(n&&n!==e.key)return n}return e.defaultValue||e.key}function J(e,t,n,r,i,a,o){let s=q(e.label,n);if(typeof e.label!=`string`)return s;if(e.type===`object`&&e.objectName){if(e.viewName)return a?a(e.objectName,e.viewName,s):s;if(t)return t(e.objectName,s)}return r&&e.type===`dashboard`&&e.dashboardName?r(e.dashboardName,s):i&&e.type===`group`&&e.id?i(e.id,s):o&&e.id?o(e.id,s):s}var ee=e=>!(e===!1||e===`false`),Y=()=>!0,X=()=>!0,te=/\{(current_user_id|current_org_id|[a-z][a-z0-9_]*)\}/g;function Z(e,t){if(!e.includes(`{`))return e;let n=!1,r=e.replace(te,(e,r)=>{let i;return i=r===`current_user_id`?t?.currentUserId:r===`current_org_id`?t?.currentOrgId:t?.contextValues?.[r],i||(n=!0,``)});return n?null:r}function Q(e,t,n){switch(e.type){case`object`:{let r=`${t}/${e.objectName??``}`,i=e.recordId;if(i){let t=Z(i,n);if(t){let n=`${r}/record/${encodeURIComponent(t)}`;return{href:e.recordMode===`edit`?`${n}/edit`:n,external:!1}}}return{href:e.viewName?`${r}/view/${e.viewName}`:r,external:!1}}case`dashboard`:return{href:e.dashboardName?`${t}/dashboard/${e.dashboardName}`:`#`,external:!1};case`page`:{if(!e.pageName)return{href:`#`,external:!1};let r=e.params,i=`${t}/page/${e.pageName}`;if(r&&typeof r==`object`){let e=new URLSearchParams;for(let[t,i]of Object.entries(r))if(i!=null)if(typeof i==`string`){let r=Z(i,n);r!==null&&e.set(t,r)}else e.set(t,JSON.stringify(i));let t=e.toString();t&&(i+=`?${t}`)}return{href:i,external:!1}}case`report`:return{href:e.reportName?`${t}/report/${e.reportName}`:`#`,external:!1};case`url`:return{href:e.url??`#`,external:e.target===`_blank`};case`component`:{let r=e.componentRef;if(!r)return{href:`#`,external:!1};let i=r.split(`:`).filter(Boolean);if(i.length===0)return{href:`#`,external:!1};let a=e.params;if(i[0]===`metadata`){let e=i[1],r=a&&typeof a.type==`string`?a.type:void 0,o=a&&typeof a.name==`string`?a.name:void 0,s=``;if(a&&typeof a==`object`){let e=new URLSearchParams;for(let[t,r]of Object.entries(a))if(!(t===`type`||t===`name`)&&r!=null)if(typeof r==`string`){let i=Z(r,n);i&&e.set(t,i)}else e.set(t,JSON.stringify(r));let t=e.toString();t&&(s=`?${t}`)}return e===`directory`||!e?{href:`${t}/metadata${s}`,external:!1}:e===`resource`&&r?{href:`${t}/metadata${o?`/${encodeURIComponent(r)}/${encodeURIComponent(o)}`:`/${encodeURIComponent(r)}`}${s}`,external:!1}:{href:`${t}/metadata${s}`,external:!1}}let o=`${t}/component/${i.join(`/`)}`;if(a&&typeof a==`object`){let e=new URLSearchParams;for(let[t,n]of Object.entries(a))n!=null&&e.set(t,typeof n==`string`?n:JSON.stringify(n));let t=e.toString();t&&(o+=`?${t}`)}return{href:o,external:!1}}default:return{href:`#`,external:!1}}}function ne(e,t,n){if(t===`#`)return!1;if(n===t)return!0;let r=e.componentRef;return r&&r.split(`:`)[1]===`directory`?!1:e.type===`object`&&e.objectName?!(e.viewName||!n.startsWith(`${t}/`)||n.slice(t.length+1).startsWith(`view/`)):n.startsWith(`${t}/`)}function re(e,t){if(!t.trim())return e;let n=t.toLowerCase().trim();return e.reduce((e,r)=>{if(r.type===`separator`)return e;if(r.type===`group`&&r.children?.length){let n=re(r.children,t);return n.length>0&&e.push({...r,children:n}),e}return q(r.label).toLowerCase().includes(n)&&e.push(r),e},[])}var ie=5;function ae({item:e,basePath:t,evalVis:n,checkPerm:r,checkCap:i,onAction:a,enablePinning:o,onPinToggle:s,enableReorder:c,resolveObjectLabel:l,resolveDashboardLabel:u,resolveGroupLabel:d,resolveViewLabel:f,resolveItemLabel:p,t:m,templateContext:h}){let{attributes:g,listeners:_,setNodeRef:v,transform:y,transition:b,isDragging:x}=N({id:e.id,disabled:!c});return(0,z.jsx)(`div`,{ref:v,style:{transform:D.Transform.toString(y),transition:b,opacity:x?.5:void 0,zIndex:x?10:void 0},...g,children:(0,z.jsx)($,{item:e,basePath:t,evalVis:n,checkPerm:r,checkCap:i,onAction:a,enablePinning:o,onPinToggle:s,dragListeners:c?_:void 0,resolveObjectLabel:l,resolveDashboardLabel:u,resolveGroupLabel:d,resolveViewLabel:f,resolveItemLabel:p,t:m,templateContext:h})})}function $({item:e,basePath:t,evalVis:i,checkPerm:s,checkCap:d,onAction:g,enablePinning:v,onPinToggle:y,dragListeners:w,resolveObjectLabel:D,resolveDashboardLabel:O,resolveGroupLabel:k,resolveViewLabel:A,resolveItemLabel:j,t:M,templateContext:N}){let P=n(),F=(()=>{let t=e.expanded;if(typeof t==`boolean`)return t;if(typeof e.defaultOpen==`boolean`)return e.defaultOpen})(),I=e.type===`group`?e.children?.length??0:0,[L,B]=(0,R.useState)(R.useMemo(()=>{if(e.type!==`group`)return!1;let n=e=>{if(!e)return!1;for(let r of e){if(r.type===`group`){if(n(r.children))return!0;continue}let{href:e}=Q(r,t,N);if(ne(r,e,P.pathname))return!0}return!1};return n(e.children)},[e,t,P.pathname])?!0:F??!(I>=8));if(!i(e.visible)||e.requiredPermissions?.length&&!s(e.requiredPermissions))return null;let V=e.requiresObject,H=e.requiresService;if(V&&!d(`object`,V)||H&&!d(`service`,H))return null;if(e.type===`separator`)return(0,z.jsx)(E,{className:`my-2`});if(e.type===`group`){let n=(e.children??[]).slice().sort((e,t)=>(e.order??0)-(t.order??0));return(0,z.jsx)(m,{open:L,onOpenChange:B,children:(0,z.jsxs)(_,{children:[(0,z.jsx)(T,{asChild:!0,children:(0,z.jsxs)(l,{className:`flex w-full items-center justify-between`,children:[J(e,D,M,O,k,A,j),(0,z.jsx)(C,{className:`ml-auto h-4 w-4 transition-transform ${L?`rotate-90`:``}`})]})}),(0,z.jsx)(h,{children:(0,z.jsx)(x,{children:(0,z.jsx)(f,{children:n.map(e=>(0,z.jsx)($,{item:e,basePath:t,evalVis:i,checkPerm:s,checkCap:d,onAction:g,enablePinning:v,onPinToggle:y,resolveObjectLabel:D,resolveDashboardLabel:O,resolveGroupLabel:k,resolveViewLabel:A,resolveItemLabel:j,t:M,templateContext:N},e.id))})})})]})})}if(e.type===`action`){let n=K(e.icon),r=q(e.label,M);return(0,z.jsxs)(p,{children:[w&&(0,z.jsx)(`span`,{className:`absolute left-0.5 top-1/2 -translate-y-1/2 cursor-grab text-muted-foreground`,"aria-label":M?M(`console.nav.dragToReorder`,{defaultValue:`Drag to reorder`}):`Drag to reorder`,...w,children:(0,z.jsx)(b,{className:`h-3.5 w-3.5`})}),(0,z.jsxs)(S,{tooltip:r,onClick:()=>g?.(e),children:[(0,z.jsx)(n,{className:`h-4 w-4`}),(0,z.jsx)(`span`,{children:r}),e.badge!=null&&(0,z.jsx)(a,{variant:e.badgeVariant??`default`,className:`ml-auto text-[10px] px-1.5 py-0`,children:e.badge})]}),v&&y&&(0,z.jsx)(o,{showOnHover:!0,onClick:()=>y(e.id,!e.pinned,e,t),"aria-label":M?M(e.pinned?`console.nav.unpinItem`:`console.nav.pinItem`,{defaultValue:e.pinned?`Unpin ${r}`:`Pin ${r}`,name:r}):e.pinned?`Unpin ${r}`:`Pin ${r}`,children:e.pinned?(0,z.jsx)(u,{className:`h-3.5 w-3.5`}):(0,z.jsx)(c,{className:`h-3.5 w-3.5`})})]})}let U=K(e.icon),{href:W,external:G}=Q(e,t,N),ee=ne(e,W,P.pathname),Y=J(e,D,M,O,k,A,j),X=(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(U,{className:`h-4 w-4`}),(0,z.jsx)(`span`,{children:Y}),e.badge!=null&&(0,z.jsx)(a,{variant:e.badgeVariant??`default`,className:`ml-auto text-[10px] px-1.5 py-0`,children:e.badge})]});return(0,z.jsxs)(p,{children:[w&&(0,z.jsx)(`span`,{className:`absolute left-0.5 top-1/2 -translate-y-1/2 cursor-grab text-muted-foreground`,"aria-label":M?M(`console.nav.dragToReorder`,{defaultValue:`Drag to reorder`}):`Drag to reorder`,...w,children:(0,z.jsx)(b,{className:`h-3.5 w-3.5`})}),(0,z.jsx)(S,{asChild:!0,isActive:ee,tooltip:Y,children:G?(0,z.jsx)(`a`,{href:W,target:`_blank`,rel:`noopener noreferrer`,children:X}):(0,z.jsx)(r,{to:W,children:X})}),v&&y&&(0,z.jsx)(o,{showOnHover:!0,onClick:()=>y(e.id,!e.pinned,e,t),"aria-label":M?M(e.pinned?`console.nav.unpinItem`:`console.nav.pinItem`,{defaultValue:e.pinned?`Unpin ${Y}`:`Pin ${Y}`,name:Y}):e.pinned?`Unpin ${Y}`:`Pin ${Y}`,children:e.pinned?(0,z.jsx)(u,{className:`h-3.5 w-3.5`}):(0,z.jsx)(c,{className:`h-3.5 w-3.5`})})]})}function oe({items:e,basePath:t=``,evaluateVisibility:n=ee,checkPermission:r=Y,checkCapability:i=X,onAction:a,searchQuery:o,enablePinning:s,onPinToggle:c,enableReorder:l,onReorder:u,resolveObjectLabel:d,resolveDashboardLabel:p,resolveGroupLabel:m,resolveViewLabel:h,resolveItemLabel:g,t:v,templateContext:b}){let S=(0,R.useMemo)(()=>o?re(e,o):e,[e,o]),C=(0,R.useMemo)(()=>se(S),[S]),w=S.slice().sort((e,t)=>(e.order??0)-(t.order??0)),E=A(j(k,{activationConstraint:{distance:ie}}),j(L)),D=e=>{let{active:t,over:n}=e;if(!n||t.id===n.id||!u)return;let r=w.findIndex(e=>e.id===t.id),i=w.findIndex(e=>e.id===n.id);r===-1||i===-1||u(M(w,r,i).map((e,t)=>({...e,order:t})))},N={basePath:t,evalVis:n,checkPerm:r,checkCap:i,onAction:a,enablePinning:s,onPinToggle:c,resolveObjectLabel:d,resolveDashboardLabel:p,resolveGroupLabel:m,resolveViewLabel:h,resolveItemLabel:g,t:v,templateContext:b},B=w.some(e=>e.type===`group`),V=C.length>0&&s?(0,z.jsxs)(_,{children:[(0,z.jsxs)(T,{className:`flex items-center gap-1.5`,children:[(0,z.jsx)(y,{className:`h-3.5 w-3.5`}),v?v(`console.nav.favorites`,{defaultValue:`Favorites`}):`Favorites`]}),(0,z.jsx)(x,{children:(0,z.jsx)(f,{children:C.map(e=>(0,z.jsx)($,{item:e,...N},`fav-${e.id}`))})})]}):null;if(!B){let e=w.filter(e=>e.type!==`group`).map(e=>e.id);return(0,z.jsxs)(z.Fragment,{children:[V,(0,z.jsx)(_,{children:(0,z.jsx)(x,{children:l?(0,z.jsx)(O,{sensors:E,collisionDetection:P,onDragEnd:D,children:(0,z.jsx)(I,{items:e,strategy:F,children:(0,z.jsx)(f,{children:w.map(e=>(0,z.jsx)(ae,{item:e,enableReorder:l,...N},e.id))})})}):(0,z.jsx)(f,{children:w.map(e=>(0,z.jsx)($,{item:e,...N},e.id))})})})]})}let H=[],U=[],W=e=>{if(U.length===0)return;let t=U;U=[],H.push((0,z.jsx)(_,{children:(0,z.jsx)(x,{children:(0,z.jsx)(f,{children:t.map(e=>(0,z.jsx)($,{item:e,...N},e.id))})})},e))};return w.forEach((e,t)=>{e.type===`group`?(W(`leaf-${t}`),H.push((0,z.jsx)($,{item:e,...N},e.id))):U.push(e)}),W(`leaf-end`),(0,z.jsxs)(z.Fragment,{children:[V,H]})}function se(e){let t=[];for(let n of e)n.pinned&&n.type!==`group`&&n.type!==`separator`&&t.push(n),n.children?.length&&t.push(...se(n.children));return t}export{Q as n,G as r,oe as t};
|
|
1
|
+
import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,l as n,r,t as i}from"./vendor-react-DR370ovB.js";import{$n as a,Co as o,Cs as s,Ct as c,Et as l,Gn as u,Ki as d,St as f,Tt as p,Un as m,Wn as h,Z as g,_t as _,dc as v,io as y,ni as b,qi as x,vt as S,wt as C,xt as w,yt as T,zt as E}from"./ui-components-B2CBE2Rs.js";import{_ as D,c as O,d as k,g as A,h as j,n as M,o as N,p as P,s as F,t as I,u as L}from"./vendor-dndkit-DMFEUxSy.js";var R=e(t(),1),z=i();function B(e){let t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);if(!t)return null;let n=parseInt(t[1],16)/255,r=parseInt(t[2],16)/255,i=parseInt(t[3],16)/255,a=Math.max(n,r,i),o=Math.min(n,r,i),s=0,c=0,l=(a+o)/2;if(a!==o){let e=a-o;switch(c=l>.5?e/(2-a-o):e/(a+o),a){case n:s=((r-i)/e+(r<i?6:0))/6;break;case r:s=((i-n)/e+2)/6;break;case i:s=((n-r)/e+4)/6;break}}return{h:s*360,s:c*100,l:l*100}}function V(e){let t=B(e);return t?`${Math.round(t.h)} ${Math.round(t.s)}% ${Math.round(t.l)}%`:null}function H(e){let t=B(e);if(!t)return null;let n=Math.max(t.l,65),r=t.s>80?Math.max(t.s-10,70):t.s;return`${Math.round(t.h)} ${Math.round(r)}% ${Math.round(n)}%`}function U(e){let t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);if(!t)return`0 0% 100%`;let n=e=>{let t=e/255;return t<=.03928?t/12.92:((t+.055)/1.055)**2.4},r=n(parseInt(t[1],16)),i=n(parseInt(t[2],16)),a=n(parseInt(t[3],16));return .2126*r+.7152*i+.0722*a>.6?`222 47% 11%`:`0 0% 100%`}function W(e,t){(0,R.useEffect)(()=>{let n=document.documentElement,r=()=>n.classList.contains(`dark`),i=()=>{if(e?.primaryColor){let t=V(e.primaryColor),i=H(e.primaryColor),a=r()&&i||t;a&&(n.style.setProperty(`--brand-primary`,e.primaryColor),n.style.setProperty(`--brand-primary-hsl`,t||a),n.style.setProperty(`--primary`,a),n.style.setProperty(`--primary-foreground`,r()?`222 47% 11%`:U(e.primaryColor)),n.style.setProperty(`--ring`,a),n.style.setProperty(`--sidebar-primary`,a),n.style.setProperty(`--sidebar-ring`,a))}else n.style.removeProperty(`--brand-primary`),n.style.removeProperty(`--brand-primary-hsl`),n.style.removeProperty(`--primary`),n.style.removeProperty(`--primary-foreground`),n.style.removeProperty(`--ring`),n.style.removeProperty(`--sidebar-primary`),n.style.removeProperty(`--sidebar-ring`);if(e?.accentColor){let t=V(e.accentColor),i=H(e.accentColor),a=r()&&i||t;a&&(n.style.setProperty(`--brand-accent`,e.accentColor),n.style.setProperty(`--brand-accent-hsl`,t||a),n.style.setProperty(`--accent`,a),n.style.setProperty(`--accent-foreground`,r()?`222 47% 11%`:U(e.accentColor)))}else n.style.removeProperty(`--brand-accent`),n.style.removeProperty(`--brand-accent-hsl`),n.style.removeProperty(`--accent`),n.style.removeProperty(`--accent-foreground`)};i();let a=new MutationObserver(e=>{for(let t of e)if(t.type===`attributes`&&t.attributeName===`class`){i();break}});if(a.observe(n,{attributes:!0,attributeFilter:[`class`]}),e?.favicon){let t=document.querySelector(`#favicon`)||document.querySelector(`link[rel="icon"]`);t&&(t.href=e.favicon)}return t&&(document.title=t),()=>{a.disconnect(),n.style.removeProperty(`--brand-primary`),n.style.removeProperty(`--brand-primary-hsl`),n.style.removeProperty(`--brand-accent`),n.style.removeProperty(`--brand-accent-hsl`),n.style.removeProperty(`--primary`),n.style.removeProperty(`--primary-foreground`),n.style.removeProperty(`--ring`),n.style.removeProperty(`--sidebar-primary`),n.style.removeProperty(`--sidebar-ring`),n.style.removeProperty(`--accent`),n.style.removeProperty(`--accent-foreground`)}},[e?.primaryColor,e?.accentColor,e?.favicon,t])}function G({sidebar:e,navbar:t,children:n,className:r,defaultOpen:i=!0,branding:a}){return W(a,a?.title),(0,z.jsxs)(l,{defaultOpen:i,className:`!flex-col h-svh overflow-hidden`,children:[(0,z.jsx)(`header`,{className:`sticky top-0 z-30 flex h-14 w-full shrink-0 items-center gap-2 border-b bg-background px-2 sm:px-4`,children:t}),(0,z.jsxs)(`div`,{className:`flex flex-1 min-h-0 w-full`,children:[e,(0,z.jsx)(w,{className:`min-w-0`,children:(0,z.jsx)(`main`,{className:v(`flex-1 min-w-0 overflow-auto p-3 sm:p-4 md:p-6 pb-20 sm:pb-4 md:pb-6`,r),children:n})})]})]})}function K(e){return e?g(e):o}function q(e,t){if(typeof e==`string`)return e;if(t){let n=t(e.key,{defaultValue:e.defaultValue,...e.params});if(n&&n!==e.key)return n}return e.defaultValue||e.key}function J(e,t,n,r,i,a,o){let s=q(e.label,n);if(typeof e.label!=`string`)return s;if(e.type===`object`&&e.objectName){if(e.viewName)return a?a(e.objectName,e.viewName,s):s;if(t)return t(e.objectName,s)}return r&&e.type===`dashboard`&&e.dashboardName?r(e.dashboardName,s):i&&e.type===`group`&&e.id?i(e.id,s):o&&e.id?o(e.id,s):s}var ee=e=>!(e===!1||e===`false`),Y=()=>!0,X=()=>!0,te=/\{(current_user_id|current_org_id|[a-z][a-z0-9_]*)\}/g;function Z(e,t){if(!e.includes(`{`))return e;let n=!1,r=e.replace(te,(e,r)=>{let i;return i=r===`current_user_id`?t?.currentUserId:r===`current_org_id`?t?.currentOrgId:t?.contextValues?.[r],i||(n=!0,``)});return n?null:r}function Q(e,t,n){switch(e.type){case`object`:{let r=`${t}/${e.objectName??``}`,i=e.recordId;if(i){let t=Z(i,n);if(t){let n=`${r}/record/${encodeURIComponent(t)}`;return{href:e.recordMode===`edit`?`${n}/edit`:n,external:!1}}}return{href:e.viewName?`${r}/view/${e.viewName}`:r,external:!1}}case`dashboard`:return{href:e.dashboardName?`${t}/dashboard/${e.dashboardName}`:`#`,external:!1};case`page`:{if(!e.pageName)return{href:`#`,external:!1};let r=e.params,i=`${t}/page/${e.pageName}`;if(r&&typeof r==`object`){let e=new URLSearchParams;for(let[t,i]of Object.entries(r))if(i!=null)if(typeof i==`string`){let r=Z(i,n);r!==null&&e.set(t,r)}else e.set(t,JSON.stringify(i));let t=e.toString();t&&(i+=`?${t}`)}return{href:i,external:!1}}case`report`:return{href:e.reportName?`${t}/report/${e.reportName}`:`#`,external:!1};case`url`:return{href:e.url??`#`,external:e.target===`_blank`};case`component`:{let r=e.componentRef;if(!r)return{href:`#`,external:!1};let i=r.split(`:`).filter(Boolean);if(i.length===0)return{href:`#`,external:!1};let a=e.params;if(i[0]===`metadata`){let e=i[1],r=a&&typeof a.type==`string`?a.type:void 0,o=a&&typeof a.name==`string`?a.name:void 0,s=``;if(a&&typeof a==`object`){let e=new URLSearchParams;for(let[t,r]of Object.entries(a))if(!(t===`type`||t===`name`)&&r!=null)if(typeof r==`string`){let i=Z(r,n);i&&e.set(t,i)}else e.set(t,JSON.stringify(r));let t=e.toString();t&&(s=`?${t}`)}return e===`directory`||!e?{href:`${t}/metadata${s}`,external:!1}:e===`resource`&&r?{href:`${t}/metadata${o?`/${encodeURIComponent(r)}/${encodeURIComponent(o)}`:`/${encodeURIComponent(r)}`}${s}`,external:!1}:{href:`${t}/metadata${s}`,external:!1}}let o=`${t}/component/${i.join(`/`)}`;if(a&&typeof a==`object`){let e=new URLSearchParams;for(let[t,n]of Object.entries(a))n!=null&&e.set(t,typeof n==`string`?n:JSON.stringify(n));let t=e.toString();t&&(o+=`?${t}`)}return{href:o,external:!1}}default:return{href:`#`,external:!1}}}function ne(e,t,n){if(t===`#`)return!1;if(n===t)return!0;let r=e.componentRef;return r&&r.split(`:`)[1]===`directory`?!1:e.type===`object`&&e.objectName?!(e.viewName||!n.startsWith(`${t}/`)||n.slice(t.length+1).startsWith(`view/`)):n.startsWith(`${t}/`)}function re(e,t){if(!t.trim())return e;let n=t.toLowerCase().trim();return e.reduce((e,r)=>{if(r.type===`separator`)return e;if(r.type===`group`&&r.children?.length){let n=re(r.children,t);return n.length>0&&e.push({...r,children:n}),e}return q(r.label).toLowerCase().includes(n)&&e.push(r),e},[])}var ie=5;function ae({item:e,basePath:t,evalVis:n,checkPerm:r,checkCap:i,onAction:a,enablePinning:o,onPinToggle:s,enableReorder:c,resolveObjectLabel:l,resolveDashboardLabel:u,resolveGroupLabel:d,resolveViewLabel:f,resolveItemLabel:p,t:m,templateContext:h}){let{attributes:g,listeners:_,setNodeRef:v,transform:y,transition:b,isDragging:x}=N({id:e.id,disabled:!c});return(0,z.jsx)(`div`,{ref:v,style:{transform:D.Transform.toString(y),transition:b,opacity:x?.5:void 0,zIndex:x?10:void 0},...g,children:(0,z.jsx)($,{item:e,basePath:t,evalVis:n,checkPerm:r,checkCap:i,onAction:a,enablePinning:o,onPinToggle:s,dragListeners:c?_:void 0,resolveObjectLabel:l,resolveDashboardLabel:u,resolveGroupLabel:d,resolveViewLabel:f,resolveItemLabel:p,t:m,templateContext:h})})}function $({item:e,basePath:t,evalVis:i,checkPerm:o,checkCap:l,onAction:g,enablePinning:v,onPinToggle:b,dragListeners:w,resolveObjectLabel:D,resolveDashboardLabel:O,resolveGroupLabel:k,resolveViewLabel:A,resolveItemLabel:j,t:M,templateContext:N}){let P=n(),F=(()=>{let t=e.expanded;if(typeof t==`boolean`)return t;if(typeof e.defaultOpen==`boolean`)return e.defaultOpen})(),I=e.type===`group`?e.children?.length??0:0,[L,B]=(0,R.useState)(R.useMemo(()=>{if(e.type!==`group`)return!1;let n=e=>{if(!e)return!1;for(let r of e){if(r.type===`group`){if(n(r.children))return!0;continue}let{href:e}=Q(r,t,N);if(ne(r,e,P.pathname))return!0}return!1};return n(e.children)},[e,t,P.pathname])?!0:F??!(I>=8));if(!i(e.visible)||e.requiredPermissions?.length&&!o(e.requiredPermissions))return null;let V=e.requiresObject,H=e.requiresService;if(V&&!l(`object`,V)||H&&!l(`service`,H))return null;if(e.type===`separator`)return(0,z.jsx)(E,{className:`my-2`});if(e.type===`group`){let n=(e.children??[]).slice().sort((e,t)=>(e.order??0)-(t.order??0));return(0,z.jsx)(m,{open:L,onOpenChange:B,children:(0,z.jsxs)(_,{children:[(0,z.jsx)(T,{asChild:!0,children:(0,z.jsxs)(u,{className:`flex w-full items-center justify-between`,children:[J(e,D,M,O,k,A,j),(0,z.jsx)(s,{className:`ml-auto h-4 w-4 transition-transform ${L?`rotate-90`:``}`})]})}),(0,z.jsx)(h,{children:(0,z.jsx)(S,{children:(0,z.jsx)(f,{children:n.map(e=>(0,z.jsx)($,{item:e,basePath:t,evalVis:i,checkPerm:o,checkCap:l,onAction:g,enablePinning:v,onPinToggle:b,resolveObjectLabel:D,resolveDashboardLabel:O,resolveGroupLabel:k,resolveViewLabel:A,resolveItemLabel:j,t:M,templateContext:N},e.id))})})})]})})}if(e.type===`action`){let n=K(e.icon),r=q(e.label,M);return(0,z.jsxs)(p,{children:[w&&(0,z.jsx)(`span`,{className:`absolute left-0.5 top-1/2 -translate-y-1/2 cursor-grab text-muted-foreground`,"aria-label":M?M(`console.nav.dragToReorder`,{defaultValue:`Drag to reorder`}):`Drag to reorder`,...w,children:(0,z.jsx)(y,{className:`h-3.5 w-3.5`})}),(0,z.jsxs)(C,{tooltip:r,onClick:()=>g?.(e),children:[(0,z.jsx)(n,{className:`h-4 w-4`}),(0,z.jsx)(`span`,{children:r}),e.badge!=null&&(0,z.jsx)(a,{variant:e.badgeVariant??`default`,className:`ml-auto text-[10px] px-1.5 py-0`,children:e.badge})]}),v&&b&&(0,z.jsx)(c,{showOnHover:!0,onClick:()=>b(e.id,!e.pinned,e,t),"aria-label":M?M(e.pinned?`console.nav.unpinItem`:`console.nav.pinItem`,{defaultValue:e.pinned?`Unpin ${r}`:`Pin ${r}`,name:r}):e.pinned?`Unpin ${r}`:`Pin ${r}`,children:e.pinned?(0,z.jsx)(x,{className:`h-3.5 w-3.5`}):(0,z.jsx)(d,{className:`h-3.5 w-3.5`})})]})}let U=K(e.icon),{href:W,external:G}=Q(e,t,N),ee=ne(e,W,P.pathname),Y=J(e,D,M,O,k,A,j),X=(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(U,{className:`h-4 w-4`}),(0,z.jsx)(`span`,{children:Y}),e.badge!=null&&(0,z.jsx)(a,{variant:e.badgeVariant??`default`,className:`ml-auto text-[10px] px-1.5 py-0`,children:e.badge})]});return(0,z.jsxs)(p,{children:[w&&(0,z.jsx)(`span`,{className:`absolute left-0.5 top-1/2 -translate-y-1/2 cursor-grab text-muted-foreground`,"aria-label":M?M(`console.nav.dragToReorder`,{defaultValue:`Drag to reorder`}):`Drag to reorder`,...w,children:(0,z.jsx)(y,{className:`h-3.5 w-3.5`})}),(0,z.jsx)(C,{asChild:!0,isActive:ee,tooltip:Y,children:G?(0,z.jsx)(`a`,{href:W,target:`_blank`,rel:`noopener noreferrer`,children:X}):(0,z.jsx)(r,{to:W,children:X})}),v&&b&&(0,z.jsx)(c,{showOnHover:!0,onClick:()=>b(e.id,!e.pinned,e,t),"aria-label":M?M(e.pinned?`console.nav.unpinItem`:`console.nav.pinItem`,{defaultValue:e.pinned?`Unpin ${Y}`:`Pin ${Y}`,name:Y}):e.pinned?`Unpin ${Y}`:`Pin ${Y}`,children:e.pinned?(0,z.jsx)(x,{className:`h-3.5 w-3.5`}):(0,z.jsx)(d,{className:`h-3.5 w-3.5`})})]})}function oe({items:e,basePath:t=``,evaluateVisibility:n=ee,checkPermission:r=Y,checkCapability:i=X,onAction:a,searchQuery:o,enablePinning:s,onPinToggle:c,enableReorder:l,onReorder:u,resolveObjectLabel:d,resolveDashboardLabel:p,resolveGroupLabel:m,resolveViewLabel:h,resolveItemLabel:g,t:v,templateContext:y}){let x=(0,R.useMemo)(()=>o?re(e,o):e,[e,o]),C=(0,R.useMemo)(()=>se(x),[x]),w=x.slice().sort((e,t)=>(e.order??0)-(t.order??0)),E=A(j(k,{activationConstraint:{distance:ie}}),j(L)),D=e=>{let{active:t,over:n}=e;if(!n||t.id===n.id||!u)return;let r=w.findIndex(e=>e.id===t.id),i=w.findIndex(e=>e.id===n.id);r===-1||i===-1||u(M(w,r,i).map((e,t)=>({...e,order:t})))},N={basePath:t,evalVis:n,checkPerm:r,checkCap:i,onAction:a,enablePinning:s,onPinToggle:c,resolveObjectLabel:d,resolveDashboardLabel:p,resolveGroupLabel:m,resolveViewLabel:h,resolveItemLabel:g,t:v,templateContext:y},B=w.some(e=>e.type===`group`),V=C.length>0&&s?(0,z.jsxs)(_,{children:[(0,z.jsxs)(T,{className:`flex items-center gap-1.5`,children:[(0,z.jsx)(b,{className:`h-3.5 w-3.5`}),v?v(`console.nav.favorites`,{defaultValue:`Favorites`}):`Favorites`]}),(0,z.jsx)(S,{children:(0,z.jsx)(f,{children:C.map(e=>(0,z.jsx)($,{item:e,...N},`fav-${e.id}`))})})]}):null;if(!B){let e=w.filter(e=>e.type!==`group`).map(e=>e.id);return(0,z.jsxs)(z.Fragment,{children:[V,(0,z.jsx)(_,{children:(0,z.jsx)(S,{children:l?(0,z.jsx)(O,{sensors:E,collisionDetection:P,onDragEnd:D,children:(0,z.jsx)(I,{items:e,strategy:F,children:(0,z.jsx)(f,{children:w.map(e=>(0,z.jsx)(ae,{item:e,enableReorder:l,...N},e.id))})})}):(0,z.jsx)(f,{children:w.map(e=>(0,z.jsx)($,{item:e,...N},e.id))})})})]})}let H=[],U=[],W=e=>{if(U.length===0)return;let t=U;U=[],H.push((0,z.jsx)(_,{children:(0,z.jsx)(S,{children:(0,z.jsx)(f,{children:t.map(e=>(0,z.jsx)($,{item:e,...N},e.id))})})},e))};return w.forEach((e,t)=>{e.type===`group`?(W(`leaf-${t}`),H.push((0,z.jsx)($,{item:e,...N},e.id))):U.push(e)}),W(`leaf-end`),(0,z.jsxs)(z.Fragment,{children:[V,H]})}function se(e){let t=[];for(let n of e)n.pinned&&n.type!==`group`&&n.type!==`separator`&&t.push(n),n.children?.length&&t.push(...se(n.children));return t}export{Q as n,G as r,oe as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,t as n}from"./vendor-react-DR370ovB.js";import{f as r}from"./infrastructure-CJNwTVno.js";import{B as i}from"./framework-
|
|
1
|
+
import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,t as n}from"./vendor-react-DR370ovB.js";import{f as r}from"./infrastructure-CJNwTVno.js";import{B as i}from"./framework-DLckRGJs.js";import{Ft as a,Hn as o,It as s,Ln as c,Lt as l,Pt as u,Rn as d,Rt as f,Vn as p,_n as m,bn as h,dc as g,hr as _,vn as v,xn as y,yn as b,zn as x}from"./ui-components-B2CBE2Rs.js";import{n as S}from"./plugin-form-FmgnWzcl.js";import{a as C,c as w,i as T,s as E}from"./RecentItemsProvider-B76qldBH.js";var D=e(t(),1),O=n(),k=`objectui-favorites`,A=`objectui-nav-pins`,j=20,M=20;function N(e){let t=0,n=0,r=!1;for(let i of e)i.type===`nav`?(n++,n>M&&(r=!0)):(t++,t>j&&(r=!0));if(!r)return e;let i=[],a=0,o=0;for(let t of e)t.type===`nav`?o<M&&(i.push(t),o++):a<j&&(i.push(t),a++);return i}function P(e){try{let t=localStorage.getItem(C(k,e));return t?JSON.parse(t):[]}catch{return[]}}function F(e,t){try{localStorage.setItem(C(k,t),JSON.stringify(e))}catch{}}function I(e){let t;try{t=localStorage.getItem(A)}catch{return{migrated:e,didMigrate:!1}}if(!t)return{migrated:e,didMigrate:!1};let n=[];try{let e=JSON.parse(t);Array.isArray(e)&&(n=e.filter(e=>typeof e==`string`))}catch{}try{localStorage.removeItem(A)}catch{}if(n.length===0)return{migrated:e,didMigrate:!1};let r=new Set(e.filter(e=>e.type===`nav`&&e.navId).map(e=>e.navId)),i=new Date().toISOString(),a=[];for(let e of n)r.has(e)||a.push({id:`nav:${e}`,label:e,href:``,type:`nav`,navId:e,pinned:!0,favoritedAt:i});return a.length===0?{migrated:e,didMigrate:!0}:{migrated:[...e,...a],didMigrate:!0}}var L=(0,D.createContext)(null);function R({children:e}){let{user:t}=r(),n=t?.id??null,i=w(`favorites`),[a,o]=(0,D.useState)(()=>P(n));(0,D.useEffect)(()=>{o(P(n))},[n]),E(C(k,n),e=>{o(Array.isArray(e)?N(e.filter(e=>e&&typeof e.id==`string`)):[])});let s=(0,D.useRef)(0);(0,D.useEffect)(()=>{if(!i)return;let e=++s.current,t=!1;return(async()=>{try{let r=await i.load();if(t||e!==s.current)return;let a=N((Array.isArray(r)?r:[]).filter(e=>e&&typeof e.id==`string`)),l=P(n),u=new Set(a.filter(e=>e.type===`nav`&&e.navId).map(e=>e.navId)),d=l.filter(e=>e.type===`nav`&&e.navId&&!u.has(e.navId)),f=a,p=!1;d.length>0&&(f=N([...a,...d]),p=!0);let{migrated:m,didMigrate:h}=I(f);h&&(f=N(m),p=!0),o(f),F(f,n),p&&c.schedule(f)}catch{}})(),()=>{t=!0}},[i,n]),(0,D.useEffect)(()=>{i||o(e=>{let{migrated:t,didMigrate:r}=I(e);if(!r)return e;let i=N(t);return F(i,n),i})},[i,n]);let c=(0,D.useMemo)(()=>T(async e=>{i&&await i.save(e)},500),[i]);(0,D.useEffect)(()=>()=>{c.flush()},[c]);let l=(0,D.useCallback)(e=>{F(e,n),i&&c.schedule(e)},[n,i,c]),u=(0,D.useCallback)(e=>{o(t=>{if(t.some(t=>t.id===e.id))return t;let n=N([{...e,favoritedAt:new Date().toISOString()},...t]);return l(n),n})},[l]),d=(0,D.useCallback)(e=>{o(t=>{let n=t.filter(t=>t.id!==e);return l(n),n})},[l]),f=(0,D.useCallback)(e=>{o(t=>{let n=t.some(t=>t.id===e.id)?t.filter(t=>t.id!==e.id):N([{...e,favoritedAt:new Date().toISOString()},...t]);return l(n),n})},[l]),p=(0,D.useCallback)(()=>{o([]),l([])},[l]),m=(0,D.useCallback)((e,t)=>{!e||!t||o(n=>{let r=!1,i=n.map(n=>n.id===e&&n.label!==t?(r=!0,{...n,label:t}):n);return r?(l(i),i):n})},[l]),h=(0,D.useCallback)((e,t)=>{o(n=>{let r=!1,i=n.map(n=>n.id!==e||!!n.pinned===t?n:(r=!0,{...n,pinned:t}));return r?(l(i),i):n})},[l]),g=(0,D.useMemo)(()=>{let e=new Set;for(let t of a)t.pinned&&t.type===`nav`&&t.navId&&e.add(t.navId);return{favorites:a,addFavorite:u,removeFavorite:d,toggleFavorite:f,isFavorite:e=>a.some(t=>t.id===e),clearFavorites:p,refreshLabel:m,setPinned:h,isPinned:e=>a.some(t=>t.id===e&&!!t.pinned),pinnedNavIds:e}},[a,u,d,f,p,m,h]);return(0,O.jsx)(L.Provider,{value:g,children:e})}function z(){return(0,D.useContext)(L)||{favorites:[],addFavorite:()=>{},removeFavorite:()=>{},toggleFavorite:()=>{},isFavorite:()=>!1,clearFavorites:()=>{},refreshLabel:()=>{},setPinned:()=>{},isPinned:()=>!1,pinnedNavIds:new Set}}function B(){return`${``.replace(/\/$/,``)}/api/v1`}async function V(e,t){let n=await fetch(`${B()}${e}`,{credentials:`include`,headers:{"Content-Type":`application/json`,...t?.headers||{}},...t}),r=null;try{r=await n.json()}catch{}if(!n.ok){let e=Error(r?.error||`HTTP ${n.status}`);throw e.code=r?.code??`HTTP_${n.status}`,e.status=n.status,e}return r}function H(e,t,n){let[r,i]=(0,D.useState)(!1),[a,o]=(0,D.useState)(!0),[s,c]=(0,D.useState)([]),l=(0,D.useRef)(!1),u=(0,D.useCallback)(async()=>{if(!(!e||!t)&&!l.current){i(!0);try{c((await V(`/approvals/requests?object=${encodeURIComponent(e)}&recordId=${encodeURIComponent(t)}`))?.data??[]),o(!0)}catch(e){(e?.status===404||e?.status===501)&&(l.current=!0,o(!1))}finally{i(!1)}}},[e,t]);(0,D.useEffect)(()=>{if(!e||!t){c([]);return}u()},[e,t,u]);let d=(0,D.useMemo)(()=>s.find(e=>e.status===`pending`)??null,[s]),f=(0,D.useMemo)(()=>s.length===0?null:[...s].sort((e,t)=>{let n=e.submitted_at||e.completed_at||``;return(t.submitted_at||t.completed_at||``).localeCompare(n)})[0]??null,[s]),p=!!d&&!!n&&(d.pending_approvers??[]).includes(n),m=(0,D.useCallback)(async(e,t)=>{if(!d)throw Error(`No pending request`);let r=await V(`/approvals/requests/${encodeURIComponent(d.id)}/${e}`,{method:`POST`,body:JSON.stringify({...n?{actorId:n}:{},...t?.comment?{comment:t.comment}:{}})});return await u(),r?.request},[d,n,u]);return{loading:r,available:a,pendingRequest:d,latestRequest:f,canDecide:p,approve:(0,D.useCallback)(e=>m(`approve`,e),[m]),reject:(0,D.useCallback)(e=>m(`reject`,e),[m]),refresh:u}}var U={sm:`sm:max-w-sm`,default:`sm:max-w-lg`,lg:`sm:max-w-2xl`,xl:`sm:max-w-5xl`,full:`sm:max-w-[95vw] sm:w-full`},W={lg:`sm:max-w-2xl`,xl:`sm:max-w-3xl`,full:`sm:max-w-[95vw]`};function G(e){if(typeof e==`string`){let t=e.match(/^(create|new|add|edit|update)_(.+)$/);return t?{objectName:t[2],mode:t[1]===`edit`||t[1]===`update`?`edit`:`create`}:{objectName:e,mode:`create`}}return e&&typeof e==`object`?e.type&&!e.content&&!e.objectName&&!e.placement?{content:e}:e:{}}function K(e){let[t,n]=(0,D.useState)(null),r=(0,D.useCallback)(e=>{n(t=>(t?.resolve(e),null))},[]),C=(0,D.useCallback)(e=>new Promise(t=>{n({d:G(e),resolve:t})}),[]),w=null;if(t){let n=t.d,C=e=>{e||r({success:!1})};if(n.objectName&&!n.content)w=(0,O.jsx)(S,{schema:{type:`object-form`,formType:`modal`,objectName:n.objectName,mode:n.mode||`create`,recordId:n.recordId,title:n.title,description:n.description,fields:n.fields,modalSize:n.size,open:!0,onOpenChange:C,onSuccess:e=>r({success:!0,reload:!0,data:e}),onCancel:()=>r({success:!1}),showSubmit:!0,showCancel:!0},dataSource:e});else{let e=n.placement||`center`,t=n.content?(0,O.jsx)(i,{schema:n.content}):n.description?(0,O.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:n.description}):null;w=e===`side`?(0,O.jsx)(u,{open:!0,onOpenChange:C,children:(0,O.jsxs)(a,{side:n.side||`right`,className:g(`w-full overflow-y-auto`,W[n.size||`default`]),children:[n.title&&(0,O.jsxs)(l,{children:[(0,O.jsx)(f,{children:n.title}),n.description&&(0,O.jsx)(s,{children:n.description})]}),(0,O.jsx)(`div`,{className:`py-3`,children:t})]})}):e===`bottom`?(0,O.jsx)(m,{open:!0,onOpenChange:C,children:(0,O.jsxs)(v,{children:[n.title&&(0,O.jsxs)(h,{children:[(0,O.jsx)(y,{children:n.title}),n.description&&(0,O.jsx)(b,{children:n.description})]}),(0,O.jsx)(`div`,{className:`max-h-[75vh] overflow-y-auto px-4 pb-6`,children:t})]})}):(0,O.jsx)(c,{open:!0,onOpenChange:C,children:(0,O.jsxs)(d,{className:g(e===`fullscreen`?`h-[95vh] w-full max-w-[98vw] overflow-y-auto`:U[n.size||`default`]),children:[n.title&&(0,O.jsxs)(p,{children:[(0,O.jsx)(o,{children:n.title}),n.description&&(0,O.jsx)(x,{children:n.description})]}),(0,O.jsx)(`div`,{children:t}),!n.content&&(0,O.jsx)(`div`,{className:`flex justify-end`,children:(0,O.jsx)(_,{onClick:()=>r({success:!0}),children:`OK`})})]})})}}return{modalHandler:C,modalElement:w,closeModal:r}}export{z as i,H as n,R as r,K as t};
|
package/dist/index.html
CHANGED
|
@@ -18,12 +18,12 @@
|
|
|
18
18
|
<script>
|
|
19
19
|
window.process = window.process || { env: { NODE_ENV: 'development' }, version: '', platform: 'browser' };
|
|
20
20
|
</script>
|
|
21
|
-
<script type="module" crossorigin src="./assets/index-
|
|
21
|
+
<script type="module" crossorigin src="./assets/index-JrHkY-wh.js"></script>
|
|
22
22
|
<link rel="stylesheet" crossorigin href="./assets/ui-components-BL3SEdAz.css">
|
|
23
23
|
<link rel="stylesheet" crossorigin href="./assets/plugin-dashboard-DnNKJB60.css">
|
|
24
|
-
<link rel="stylesheet" crossorigin href="./assets/index-
|
|
25
|
-
<link rel="modulepreload" href="./assets/framework-
|
|
26
|
-
<link rel="modulepreload" href="./assets/ui-components-
|
|
24
|
+
<link rel="stylesheet" crossorigin href="./assets/index-DGuFGryh.css">
|
|
25
|
+
<link rel="modulepreload" href="./assets/framework-DLckRGJs.js" />
|
|
26
|
+
<link rel="modulepreload" href="./assets/ui-components-B2CBE2Rs.js" />
|
|
27
27
|
<link rel="modulepreload" href="./assets/vendor-radix-CSVEhP0L.js" />
|
|
28
28
|
<link rel="modulepreload" href="./assets/vendor-react-DR370ovB.js" />
|
|
29
29
|
</head>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@objectstack/console",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.8.0",
|
|
4
4
|
"description": "Prebuilt Console SPA pinned to this @objectstack/framework release. Source of truth: @object-ui/console (https://github.com/objectstack-ai/objectui).",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://github.com/objectstack-ai/framework/tree/main/packages/console",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,f as n,r,t as i}from"./vendor-react-DR370ovB.js";import{d as a,f as ee}from"./infrastructure-CJNwTVno.js";import{r as te}from"./framework-ZJouI0cJ.js";import{$n as ne,Bt as re,Fo as ie,Ft as ae,Go as oe,H as se,Ht as o,Ir as ce,It as le,Jn as ue,Jo as de,Kn as fe,Lt as pe,Mt as s,Pi as me,Pt as he,R as ge,Rt as _e,Si as ve,Sr as ye,Ss as be,Ut as xe,Vt as Se,Wt as Ce,_s as we,at as Te,cr as c,ct as l,dr as u,dt as Ee,fr as d,hr as f,hs as De,ir as Oe,it as ke,jr as Ae,lc as p,lr as m,lt as h,mr as je,nc as Me,nn as Ne,ns as Pe,nt as Fe,on as Ie,or as g,ot as Le,pr as _,qn as Re,qs as ze,rr as Be,rt as Ve,si as He,sr as v,ss as Ue,st as We,tt as Ge,ur as y,us as Ke,ut as qe,ws as Je,xi as Ye,xs as Xe,z as Ze,zt as Qe}from"./ui-components-Bs-DxYrW.js";import{r as b}from"./vendor-ui-utils-rQOI1gAo.js";var x=e(t(),1),$e=`${``.replace(/\/$/,``)}/api/v1`;async function S(e,t){let n=await fetch(`${$e}${e}`,{credentials:`include`,headers:{"Content-Type":`application/json`,...t?.headers||{}},...t}),r=null;try{r=await n.json()}catch{}if(!n.ok){let e=r?.code??`HTTP_${n.status}`,t=r?.message??r?.error??n.statusText,i=Error(`${e}: ${t}`);throw i.code=e,i.status=n.status,i.details=r,i}return r}var C={listProcesses(e={}){let t=new URLSearchParams;e.object&&t.set(`object`,e.object),e.activeOnly&&t.set(`activeOnly`,`true`);let n=t.toString();return S(`/approvals/processes${n?`?${n}`:``}`)},listRequests(e={}){let t=new URLSearchParams;e.status&&t.set(`status`,e.status),e.object&&t.set(`object`,e.object),e.recordId&&t.set(`recordId`,e.recordId);let n=Array.isArray(e.approverId)?e.approverId.filter(Boolean).join(`,`):e.approverId;n&&t.set(`approverId`,n),e.submitterId&&t.set(`submitterId`,e.submitterId),e.q?.trim()&&t.set(`q`,e.q.trim()),e.limit!=null&&t.set(`limit`,String(e.limit)),e.offset!=null&&t.set(`offset`,String(e.offset));let r=t.toString();return S(`/approvals/requests${r?`?${r}`:``}`)},async getRequest(e){return{data:await S(`/approvals/requests/${encodeURIComponent(e)}`)}},listActions(e){return S(`/approvals/requests/${encodeURIComponent(e)}/actions`)},async approve(e,t){let n=await S(`/approvals/requests/${encodeURIComponent(e)}/approve`,{method:`POST`,body:JSON.stringify(t)});return{data:n.request,finalized:n.finalized}},async reject(e,t){let n=await S(`/approvals/requests/${encodeURIComponent(e)}/reject`,{method:`POST`,body:JSON.stringify(t)});return{data:n.request,finalized:n.finalized}},async recall(e,t){return{data:(await S(`/approvals/requests/${encodeURIComponent(e)}/recall`,{method:`POST`,body:JSON.stringify(t)})).request,finalized:!0}},async reassign(e,t){return{data:(await S(`/approvals/requests/${encodeURIComponent(e)}/reassign`,{method:`POST`,body:JSON.stringify(t)})).request}},async remind(e,t={}){let n=await S(`/approvals/requests/${encodeURIComponent(e)}/remind`,{method:`POST`,body:JSON.stringify(t)});return{data:n.request,notified:n.notified}},async requestInfo(e,t){return{data:(await S(`/approvals/requests/${encodeURIComponent(e)}/request-info`,{method:`POST`,body:JSON.stringify(t)})).request}},async sendBack(e,t){let n=await S(`/approvals/requests/${encodeURIComponent(e)}/revise`,{method:`POST`,body:JSON.stringify(t)});return{data:n.request,autoRejected:n.autoRejected===!0}},async resubmit(e,t={}){let n=await S(`/approvals/requests/${encodeURIComponent(e)}/resubmit`,{method:`POST`,body:JSON.stringify(t)});return{data:n.request,resumed:n.resumed===!0}},async comment(e,t){return{data:(await S(`/approvals/requests/${encodeURIComponent(e)}/comment`,{method:`POST`,body:JSON.stringify(t)})).request}},async submit(e){return S(`/approvals/requests`,{method:`POST`,body:JSON.stringify(e)})}};function et(e){if(!e)return[];let t=new Set;e.id&&t.add(e.id),e.email&&t.add(e.email);let n=[...e.roles||[],...typeof e.role==`string`?e.role.split(`,`):[]];for(let e of n){let n=String(e).trim();n&&t.add(`role:${n}`)}return Array.from(t)}var w=i(),tt=50,nt={pending:`border-amber-200 bg-amber-50 text-amber-700 dark:border-amber-500/30 dark:bg-amber-500/10 dark:text-amber-400`,approved:`border-emerald-200 bg-emerald-50 text-emerald-700 dark:border-emerald-500/30 dark:bg-emerald-500/10 dark:text-emerald-400`,rejected:`border-red-200 bg-red-50 text-red-700 dark:border-red-500/30 dark:bg-red-500/10 dark:text-red-400`,recalled:`border-border bg-muted text-muted-foreground`,returned:`border-violet-200 bg-violet-50 text-violet-700 dark:border-violet-500/30 dark:bg-violet-500/10 dark:text-violet-400`};function rt(e){if(!e)return`—`;try{return new Date(e).toLocaleString()}catch{return e}}function T(e){return e?e.includes(`@`)?e:e.startsWith(`role:`)?`Role: ${e.slice(5)}`:e.length>14?`${e.slice(0,6)}…${e.slice(-4)}`:e:`—`}function E(e){return e&&String(e).replace(/^flow:/,``).trim().split(/[_\-\s]+/).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)||`—`}function it(e){return e.process_label||E(e.process_name)}function at(e){return e.step_label?e.step_label:e.current_step?E(e.current_step):null}function ot(e){return e.submitter_name||T(e.submitter_id)}function st(e,t){return t.pending_approver_names?.[e]||T(e)}function ct(e){return e.object_label||e.object_name}function D(e){return e.submitted_at||e.created_at||void 0}function O(e){let t=D(e);if(!t)return null;let n=Date.parse(t);return Number.isNaN(n)?null:(Date.now()-n)/36e5}function lt(e){if(e.status!==`pending`)return`text-muted-foreground`;let t=O(e);return t==null?`text-muted-foreground`:t>72?`text-red-600 dark:text-red-400 font-medium`:t>24?`text-amber-600 dark:text-amber-400`:`text-muted-foreground`}function ut(e){let t=Math.max(1,Math.round(Math.abs(e)/36e5));return t<48?`${t}h`:`${Math.round(t/24)}d`}var k=new Set([`id`,`created_at`,`updated_at`,`created_by`,`updated_by`,`organization_id`]);function A(e){return e.split(`_`).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)}function j(e,t){if(typeof t==`boolean`)return t?`✓`:`—`;if(typeof t==`number`){if(t>0xe8d4a51000&&/(_at$|_date$|^date_|_time$)/.test(e))try{return new Date(t).toLocaleDateString()}catch{}return t.toLocaleString()}let n=String(t);if(/^\d{4}-\d{2}-\d{2}T\d{2}/.test(n))try{return new Date(n).toLocaleString()}catch{}return n}var dt=/^[A-Za-z0-9_-]{15,}$/;function ft(e,t,n=6){if(!e||typeof e!=`object`||Array.isArray(e))return[];let r=[];for(let[i,a]of Object.entries(e)){if(k.has(i)||a==null||typeof a==`object`||String(a).trim()===``)continue;let e=t?.[i];if(!(!e&&typeof a==`string`&&dt.test(a.trim())&&!/^\d+$/.test(a.trim()))&&(r.push([A(i),e??j(i,a)]),r.length>=n))break}return r}function pt(){let{t:e,language:t}=te(),{user:i}=ee(),$e=a(),{appName:S}=n(),E=(0,x.useMemo)(()=>et(i),[i]),O=(0,x.useCallback)((t,n,r)=>String(e(`approvalsInbox.${t}`,{defaultValue:n,...r})),[e]),k=(0,x.useCallback)(e=>{if(!e)return`—`;let n=Date.parse(e);if(Number.isNaN(n))return e;let r=Math.round((Date.now()-n)/1e3);if(r<45)return O(`justNow`,`just now`);let i=Math.round(r/60);if(i<60)return O(`minutesAgo`,`{{count}}m ago`,{count:i});let a=Math.round(i/60);if(a<24)return O(`hoursAgo`,`{{count}}h ago`,{count:a});let ee=Math.round(a/24);if(ee<30)return O(`daysAgo`,`{{count}}d ago`,{count:ee});try{return new Date(e).toLocaleDateString(t)}catch{return e}},[O,t]),A=(0,x.useCallback)(e=>{switch(e){case`pending`:return O(`statusPending`,`Pending`);case`approved`:return O(`statusApproved`,`Approved`);case`rejected`:return O(`statusRejected`,`Rejected`);case`recalled`:return O(`statusRecalled`,`Recalled`);case`returned`:return O(`statusReturned`,`Returned for revision`);default:return e}},[O]),j=(0,x.useCallback)((e,t)=>{let n=e?.code??``,r=e?.status??0;return n===`NOT_IMPLEMENTED`||r===501?O(`recallUnavailable`,`Recall is not available on this deployment.`):n===`THROTTLED`||r===429?O(`remindThrottled`,`A reminder was sent recently — try again later.`):r===404?O(`requestGone`,`This request no longer exists. Refresh the list.`):n===`FORBIDDEN`||r===403?O(`notAllowed`,`You are not allowed to perform this action.`):n===`INVALID_STATE`||r===409?O(`alreadyDecided`,`This request was already decided. Refresh the list.`):e?.message||t},[O]);function dt({status:e}){return(0,w.jsx)(ne,{variant:`outline`,className:p(`font-medium`,nt[e]??``),children:A(e)})}let pt=(0,x.useCallback)(e=>`/apps/${S||`setup`}/${encodeURIComponent(e.object_name)}/record/${encodeURIComponent(e.record_id)}`,[S]),[M,mt]=(0,x.useState)(`pending`),[N,ht]=(0,x.useState)([]),[gt,_t]=(0,x.useState)(!1),[vt,yt]=(0,x.useState)(!1),[bt,xt]=(0,x.useState)(null),[St,Ct]=(0,x.useState)(null),[wt,Tt]=(0,x.useState)(0),[P,Et]=(0,x.useState)(null),[F,Dt]=(0,x.useState)(null),[Ot,kt]=(0,x.useState)([]),[At,jt]=(0,x.useState)(!1),[I,L]=(0,x.useState)(``),[R,Mt]=(0,x.useState)(``),[z,Nt]=(0,x.useState)(null),[B,Pt]=(0,x.useState)(``),[Ft,It]=(0,x.useState)(``),[Lt,Rt]=(0,x.useState)(`all`),[zt,Bt]=(0,x.useState)(`all`),[V,Vt]=(0,x.useState)(`all`),[H,Ht]=(0,x.useState)(new Set),[Ut,Wt]=(0,x.useState)(!1),[U,Gt]=(0,x.useState)(null),[Kt,qt]=(0,x.useState)(null),[Jt,Yt]=(0,x.useState)(!1),[Xt,Zt]=(0,x.useState)(``),[Qt,$t]=(0,x.useState)(!1),[en,tn]=(0,x.useState)(``),[nn,rn]=(0,x.useState)(!1),[an,on]=(0,x.useState)(``),[sn,cn]=(0,x.useState)(!1),[ln,un]=(0,x.useState)(``),[W,G]=(0,x.useState)(!1),[dn,fn]=(0,x.useState)([]),[pn,mn]=(0,x.useState)(-1);(0,x.useEffect)(()=>{if(M===`pending`)return;let e=window.setTimeout(()=>It(B),350);return()=>window.clearTimeout(e)},[B,M]);let K=(0,x.useCallback)(async()=>{_t(!0),Ct(null);try{let e=[];if(M===`pending`)e=E.length?(await C.listRequests({status:`pending`,approverId:E})).data:[],Tt(e.length),xt(null);else{let t={q:Ft||void 0,status:V===`all`?void 0:V,limit:tt,offset:0};if(M===`submitted`){let n=i?.id;if(n){let r=await C.listRequests({submitterId:n,...t});e=r.data,xt(r.total??r.data.length)}else e=[],xt(0)}else{let n=await C.listRequests(t);e=n.data,xt(n.total??n.data.length)}E.length&&C.listRequests({status:`pending`,approverId:E}).then(e=>Tt(e.data.length)).catch(()=>{})}e.sort((e,t)=>(D(t)||``).localeCompare(D(e)||``)),ht(e)}catch(e){Ct(e?.message||String(e)),ht([])}finally{_t(!1)}},[M,E,i?.id,Ft,V]);(0,x.useEffect)(()=>{K()},[K]);let hn=(0,x.useCallback)(async()=>{if(!(M===`pending`||vt)){yt(!0);try{let e=await C.listRequests({submitterId:M===`submitted`?i?.id??void 0:void 0,q:Ft||void 0,status:V===`all`?void 0:V,limit:tt,offset:N.length});ht(t=>{let n=new Set(t.map(e=>e.id));return[...t,...e.data.filter(e=>!n.has(e.id))]}),e.total!=null&&xt(e.total)}catch(e){b.error(j(e,O(`loadFailed`,`Failed to load request`)))}finally{yt(!1)}}},[M,vt,i?.id,Ft,V,N.length,j,O]),q=(0,x.useCallback)(async e=>{Et(e),jt(!0),L(``),Mt(``);try{let[t,n]=await Promise.all([C.getRequest(e),C.listActions(e)]);Dt(t.data),kt(n.data)}catch(e){b.error(j(e,O(`loadFailed`,`Failed to load request`))),Dt(null),kt([])}finally{jt(!1)}},[j,O]),gn=()=>{Et(null),Dt(null),kt([]),L(``),Mt(``)},J=(0,x.useCallback)(e=>{if(R.trim())return R.trim();if(!e)return i?.id||``;let t=new Set(e.pending_approvers||[]);for(let e of E)if(t.has(e))return e;return i?.id||``},[R,E,i?.id]),Y=(0,x.useCallback)(()=>{E.length&&C.listRequests({status:`pending`,approverId:E}).then(e=>Tt(e.data.length)).catch(()=>{})},[E]),_n=(0,x.useCallback)(async e=>{if(!F)return;let t=e===`recall`&&i?.id||J(F);if(!t){b.error(O(`noActor`,`Cannot determine the acting identity`));return}Nt(e);try{let n={actor_id:t,comment:I.trim()||void 0},r=await(e===`approve`?C.approve:e===`reject`?C.reject:C.recall)(F.id,n);if(b.success(e===`approve`?r.finalized?O(`approvedFinal`,`Approved`):O(`approvedWaiting`,`Approved — waiting on the remaining approvers`):e===`reject`?O(`rejectedToast`,`Rejected`):O(`recalledToast`,`Request recalled`)),L(``),e!==`recall`&&M===`pending`){let e=Rn.current,t=e.findIndex(e=>e.id===F.id),n=e[t+1]??e[t-1];K(),n&&n.id!==F.id?q(n.id):gn();return}let[i,a]=await Promise.all([C.getRequest(F.id),C.listActions(F.id)]);Dt(i.data),kt(a.data),K()}catch(e){b.error(j(e,O(`actionFailed`,`Action failed`)))}finally{Nt(null)}},[F,J,I,K,i?.id,j,O,M,q]),X=(0,x.useCallback)(async e=>{let[t,n]=await Promise.all([C.getRequest(e),C.listActions(e)]);Dt(t.data),kt(n.data),K()},[K]),vn=(0,x.useCallback)(async()=>{if(!(!F||!Xt.trim())){G(!0);try{await C.reassign(F.id,{actor_id:J(F),to:Xt.trim(),comment:I.trim()||void 0}),b.success(O(`reassignSuccess`,`Handed to {{to}}`,{to:Xt.trim()})),Yt(!1),Zt(``),L(``),await X(F.id),Y()}catch(e){b.error(j(e,O(`actionFailed`,`Action failed`)))}finally{G(!1)}}},[F,Xt,I,J,X,Y,j,O]),yn=(0,x.useCallback)(async()=>{if(F){G(!0);try{let e=await C.remind(F.id,{actor_id:i?.id});b.success(O(`remindSuccess`,`Reminder sent to {{count}} approver(s)`,{count:e.notified})),await X(F.id)}catch(e){b.error(j(e,O(`actionFailed`,`Action failed`)))}finally{G(!1)}}},[F,i?.id,X,j,O]),bn=(0,x.useCallback)(async()=>{if(!(!F||!en.trim())){G(!0);try{await C.requestInfo(F.id,{actor_id:J(F),comment:en.trim()}),b.success(O(`requestInfoSent`,`Sent back to the requester for more information`)),$t(!1),tn(``),await X(F.id)}catch(e){b.error(j(e,O(`actionFailed`,`Action failed`)))}finally{G(!1)}}},[F,en,J,X,j,O]),xn=(0,x.useCallback)(async()=>{if(F){G(!0);try{let e=await C.sendBack(F.id,{actor_id:J(F),comment:an.trim()||void 0});b.success(e.autoRejected?O(`sendBackAutoRejected`,`Revision limit reached — the request was auto-rejected`):O(`sendBackSuccess`,`Sent back for revision — the requester can now edit and resubmit`)),rn(!1),on(``),await X(F.id),Y()}catch(e){b.error(j(e,O(`actionFailed`,`Action failed`)))}finally{G(!1)}}},[F,an,J,X,Y,j,O]),Sn=(0,x.useCallback)(async()=>{if(F){cn(!0);try{await C.resubmit(F.id,{actor_id:i?.id,comment:I.trim()||void 0}),b.success(O(`resubmitSuccess`,`Resubmitted — a new approval round has opened`)),L(``),await X(F.id),Y()}catch(e){b.error(j(e,O(`actionFailed`,`Action failed`)))}finally{cn(!1)}}},[F,I,i?.id,X,Y,j,O]),Cn=(0,x.useCallback)(async()=>{if(!(!F||!ln.trim())){G(!0);try{await C.comment(F.id,{actor_id:i?.id,comment:ln.trim()}),un(``),await X(F.id)}catch(e){b.error(j(e,O(`actionFailed`,`Action failed`)))}finally{G(!1)}}},[F,ln,i?.id,X,j,O]),wn=(0,x.useCallback)(async()=>{if(!dn.length)try{let e=``.replace(/\/$/,``);fn(((await(await fetch(`${e}/api/v1/data/sys_user?limit=100`,{credentials:`include`})).json()).records||[]).filter(e=>e.email&&e.name&&e.id!==i?.id).map(e=>({name:String(e.name),email:String(e.email)})))}catch{}},[dn.length,i?.id]),Tn=(0,x.useMemo)(()=>{if(!F||F.status!==`pending`)return!1;let e=new Set(F.pending_approvers||[]);return E.some(t=>e.has(t))||R.trim().length>0},[F,E,R]),En=(0,x.useMemo)(()=>!F||F.status!==`pending`?!1:F.submitter_id===i?.id||R.trim().length>0,[F,i?.id,R]),Dn=(0,x.useMemo)(()=>!F||F.status!==`returned`?!1:F.submitter_id===i?.id||R.trim().length>0,[F,i?.id,R]),On=(0,x.useMemo)(()=>{let e=new Set;for(let t of N)e.add(it(t));return Array.from(e).sort()},[N]),kn=(0,x.useMemo)(()=>{let e=new Set;for(let t of N)t.object_name&&e.add(t.object_name);return Array.from(e).sort()},[N]),Z=(0,x.useMemo)(()=>{let e=B.trim().toLowerCase();return N.filter(t=>Lt!==`all`&&it(t)!==Lt||zt!==`all`&&t.object_name!==zt||V!==`all`&&t.status!==V?!1:M!==`pending`||!e?!0:[t.process_name,t.process_label,t.step_label,t.object_name,t.record_id,t.record_title,t.submitter_id,t.submitter_name,...t.pending_approvers||[]].filter(Boolean).join(` `).toLowerCase().includes(e))},[N,B,Lt,zt,V,M]),An=(0,x.useMemo)(()=>P?Z.findIndex(e=>e.id===P):-1,[Z,P]);(0,x.useEffect)(()=>{if(H.size===0)return;let e=new Set(Z.map(e=>e.id)),t=!1,n=new Set;for(let r of H)e.has(r)?n.add(r):t=!0;t&&Ht(n)},[Z,H]),(0,x.useEffect)(()=>{pn>=Z.length&&mn(Z.length-1)},[Z.length,pn]);let Q=(0,x.useCallback)(e=>{if(e.status!==`pending`)return!1;let t=new Set(E);return(e.pending_approvers||[]).some(e=>t.has(e))},[E]),$=(0,x.useMemo)(()=>Z.filter(e=>H.has(e.id)&&Q(e)),[Z,H,Q]),jn=Z.filter(e=>e.status===`pending`),Mn=jn.length>0&&jn.every(e=>H.has(e.id)),Nn=(0,x.useCallback)(()=>{Ht(e=>{if(Mn)return new Set;let t=new Set(e);for(let e of jn)t.add(e.id);return t})},[Mn,jn]),Pn=(0,x.useCallback)(e=>{Ht(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),Fn=(0,x.useCallback)(async e=>{let t=$;if(t.length===0)return;Wt(!0);let n=0,r=[];for(let a of t){let t=new Set(a.pending_approvers||[]),ee=E.find(e=>t.has(e))||i?.id||``;try{await(e===`approve`?C.approve:C.reject)(a.id,{actor_id:ee}),n++}catch{r.push(a.record_title||T(a.record_id))}}if(Wt(!1),Ht(new Set),r.length===0)b.success(e===`approve`?O(`bulkApproved`,`Approved {{count}} requests`,{count:n}):O(`bulkRejected`,`Rejected {{count}} requests`,{count:n}));else{let e=r.slice(0,3).join(`, `);b.error(O(`bulkPartial`,`{{ok}} succeeded, {{fail}} failed: {{which}}`,{ok:n,fail:r.length,which:e+(r.length>3?`…`:``)}))}K(),Y()},[$,E,i?.id,K,Y,O]),In=(0,x.useCallback)(async e=>{if(!Q(e)||Kt)return;let t=new Set(e.pending_approvers||[]),n=E.find(e=>t.has(e))||i?.id||``;qt(e.id);try{let t=await C.approve(e.id,{actor_id:n});b.success(t.finalized?O(`inlineApproved`,`Approved "{{title}}"`,{title:e.record_title||T(e.record_id)}):O(`approvedWaiting`,`Approved — waiting on the remaining approvers`)),K(),Y()}catch(e){b.error(j(e,O(`actionFailed`,`Action failed`)))}finally{qt(null)}},[Q,Kt,E,i?.id,K,Y,j,O]),Ln=(0,x.useCallback)(async()=>{let e=U;if(!e)return;let t=new Set(e.pending_approvers||[]),n=E.find(e=>t.has(e))||i?.id||``;qt(e.id),Gt(null);try{await C.reject(e.id,{actor_id:n}),b.success(O(`inlineRejected`,`Rejected "{{title}}"`,{title:e.record_title||T(e.record_id)})),K(),Y()}catch(e){b.error(j(e,O(`actionFailed`,`Action failed`)))}finally{qt(null)}},[U,E,i?.id,K,Y,j,O]),Rn=(0,x.useRef)(Z);Rn.current=Z;let zn=(0,x.useRef)(pn);zn.current=pn,(0,x.useEffect)(()=>{let e=e=>{if(P||U)return;let t=e.target,n=t?.tagName;if(n===`INPUT`||n===`TEXTAREA`||n===`SELECT`||t?.isContentEditable||document.querySelector(`[role="alertdialog"]`))return;let r=Rn.current;if(!r.length)return;let i=zn.current;e.key===`j`||e.key===`ArrowDown`?(e.preventDefault(),mn(Math.min(i+1,r.length-1))):e.key===`k`||e.key===`ArrowUp`?(e.preventDefault(),mn(Math.max(i-1,0))):e.key===`Enter`&&i>=0&&r[i]?(e.preventDefault(),q(r[i].id)):(e.key===`x`||e.key===` `)&&i>=0&&r[i]&&M===`pending`?(e.preventDefault(),Pn(r[i].id)):e.key===`a`&&i>=0&&r[i]?(e.preventDefault(),In(r[i])):e.key===`r`&&i>=0&&r[i]&&Q(r[i])&&(e.preventDefault(),Gt(r[i]))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[P,U,M,q,Pn,In,Q]),(0,x.useEffect)(()=>{if(!P)return;let e=e=>{if(e.key!==`ArrowLeft`&&e.key!==`ArrowRight`)return;let t=e.target,n=t?.tagName;if(n===`INPUT`||n===`TEXTAREA`||n===`SELECT`||t?.isContentEditable||document.querySelector(`[role="alertdialog"]`))return;let r=Rn.current,i=r.findIndex(e=>e.id===P);if(i<0)return;let a=e.key===`ArrowLeft`?r[i-1]:r[i+1];a&&(e.preventDefault(),q(a.id))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[P,q]);let Bn=!!B||Lt!==`all`||zt!==`all`||V!==`all`,Vn=e=>{mt(e),Vt(`all`),Rt(`all`),Bt(`all`),Pt(``),mn(-1)};function Hn({r:e}){return(0,w.jsxs)(`div`,{className:`min-w-0`,children:[(0,w.jsx)(`div`,{className:`font-medium truncate`,children:it(e)}),(0,w.jsxs)(`div`,{className:`text-xs text-muted-foreground truncate`,children:[at(e)||`—`,(e.round??1)>1&&(0,w.jsx)(`span`,{className:`ml-1.5 text-violet-600 dark:text-violet-400`,children:O(`roundChip`,`Round {{n}}`,{n:e.round})})]})]})}function Un({r:e}){return(0,w.jsxs)(`div`,{className:`min-w-0`,children:[(0,w.jsxs)(r,{to:pt(e),onClick:e=>e.stopPropagation(),className:`inline-flex items-center gap-1 text-sm hover:underline truncate max-w-full`,title:e.record_id,children:[(0,w.jsx)(`span`,{className:`truncate`,children:e.record_title||T(e.record_id)}),(0,w.jsx)(ie,{className:`h-3 w-3 shrink-0 text-muted-foreground`})]}),(0,w.jsx)(`div`,{className:`text-xs text-muted-foreground truncate`,children:ct(e)})]})}function Wn({r:e}){if(!Q(e))return null;let t=Kt===e.id;return(0,w.jsxs)(`div`,{className:`flex items-center gap-1 opacity-0 group-hover:opacity-100 focus-within:opacity-100 transition-opacity`,onClick:e=>e.stopPropagation(),children:[(0,w.jsx)(f,{size:`sm`,variant:`ghost`,className:`h-7 px-2 text-emerald-700 hover:text-emerald-800 hover:bg-emerald-50 dark:text-emerald-400`,disabled:t,onClick:()=>void In(e),"aria-label":O(`approve`,`Approve`),children:(0,w.jsx)(De,{className:`h-4 w-4`})}),(0,w.jsx)(f,{size:`sm`,variant:`ghost`,className:`h-7 px-2 text-red-600 hover:text-red-700 hover:bg-red-50 dark:text-red-400`,disabled:t,onClick:()=>Gt(e),"aria-label":O(`reject`,`Reject`),children:(0,w.jsx)(Ue,{className:`h-4 w-4`})})]})}return(0,w.jsxs)(`div`,{className:`flex flex-col gap-4 sm:gap-6 p-4 sm:p-6 max-w-6xl`,children:[(0,w.jsxs)(`header`,{className:`flex flex-col sm:flex-row sm:items-center sm:justify-between gap-2`,children:[(0,w.jsxs)(`div`,{children:[(0,w.jsxs)(`h1`,{className:`text-2xl font-semibold flex items-center gap-2`,children:[(0,w.jsx)(He,{className:`h-6 w-6`}),O(`title`,`Approvals Inbox`)]}),(0,w.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:O(`subtitle`,`Review and act on approval requests.`)})]}),(0,w.jsxs)(f,{variant:`outline`,size:`sm`,onClick:K,disabled:gt,className:`self-start sm:self-auto`,children:[(0,w.jsx)(me,{className:`h-4 w-4 mr-2 ${gt?`animate-spin`:``}`}),O(`refresh`,`Refresh`)]})]}),St&&(0,w.jsxs)(Be,{variant:`destructive`,children:[(0,w.jsx)(we,{className:`h-4 w-4`}),(0,w.jsx)(Oe,{children:St})]}),(0,w.jsxs)(Fe,{value:M,onValueChange:Vn,children:[(0,w.jsxs)(ke,{children:[(0,w.jsxs)(Te,{value:`pending`,children:[O(`tabMyPending`,`My Pending`),wt>0&&(0,w.jsx)(ne,{variant:`secondary`,className:`ml-2`,children:wt})]}),(0,w.jsx)(Te,{value:`submitted`,children:O(`tabSubmitted`,`Submitted by me`)}),(0,w.jsx)(Te,{value:`all`,children:O(`tabAll`,`All`)})]}),(0,w.jsxs)(Ve,{value:M,className:`mt-4 space-y-3`,children:[!gt&&(N.length>0||M!==`pending`&&(Ft||V!==`all`))&&(0,w.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,w.jsxs)(`div`,{className:`relative flex-1 min-w-[200px] max-w-sm`,children:[(0,w.jsx)(ve,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground`}),(0,w.jsx)(Ne,{value:B,onChange:e=>Pt(e.target.value),placeholder:O(`searchPlaceholder`,`Search record, process, requester…`),className:`pl-8 h-8 text-sm`}),B&&(0,w.jsx)(`button`,{type:`button`,onClick:()=>Pt(``),className:`absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,"aria-label":O(`clearSearch`,`Clear search`),children:(0,w.jsx)(ye,{className:`h-3.5 w-3.5`})})]}),M!==`pending`&&(0,w.jsxs)(re,{value:V,onValueChange:Vt,children:[(0,w.jsx)(xe,{className:`h-8 w-auto min-w-[130px] text-sm`,children:(0,w.jsx)(Ce,{placeholder:O(`statusFilter`,`Status`)})}),(0,w.jsxs)(Se,{children:[(0,w.jsx)(o,{value:`all`,children:O(`allStatuses`,`All statuses`)}),(0,w.jsx)(o,{value:`pending`,children:A(`pending`)}),(0,w.jsx)(o,{value:`approved`,children:A(`approved`)}),(0,w.jsx)(o,{value:`rejected`,children:A(`rejected`)}),(0,w.jsx)(o,{value:`recalled`,children:A(`recalled`)}),(0,w.jsx)(o,{value:`returned`,children:A(`returned`)})]})]}),On.length>1&&(0,w.jsxs)(re,{value:Lt,onValueChange:Rt,children:[(0,w.jsx)(xe,{className:`h-8 w-auto min-w-[140px] text-sm`,children:(0,w.jsx)(Ce,{placeholder:O(`processFilter`,`Process`)})}),(0,w.jsxs)(Se,{children:[(0,w.jsx)(o,{value:`all`,children:O(`allProcesses`,`All processes`)}),On.map(e=>(0,w.jsx)(o,{value:e,children:e},e))]})]}),kn.length>1&&(0,w.jsxs)(re,{value:zt,onValueChange:Bt,children:[(0,w.jsx)(xe,{className:`h-8 w-auto min-w-[140px] text-sm`,children:(0,w.jsx)(Ce,{placeholder:O(`objectFilter`,`Object`)})}),(0,w.jsxs)(Se,{children:[(0,w.jsx)(o,{value:`all`,children:O(`allObjects`,`All objects`)}),kn.map(e=>(0,w.jsx)(o,{value:e,children:e},e))]})]}),Bn&&(0,w.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:O(`filterCount`,`{{shown}} of {{total}}`,{shown:Z.length,total:N.length})})]}),M===`pending`&&H.size>0&&(0,w.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-3 py-2 rounded-md border bg-accent/30 text-sm`,children:[(0,w.jsxs)(`span`,{children:[(0,w.jsx)(`strong`,{children:H.size}),` `,O(`selected`,`selected`),$.length!==H.size&&(0,w.jsx)(`span`,{className:`text-muted-foreground ml-1`,children:O(`actionableCount`,`({{count}} actionable)`,{count:$.length})})]}),(0,w.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,w.jsxs)(g,{children:[(0,w.jsx)(je,{asChild:!0,children:(0,w.jsxs)(f,{size:`sm`,disabled:Ut||$.length===0,children:[(0,w.jsx)(De,{className:`h-3.5 w-3.5 mr-1`}),O(`approveN`,`Approve {{count}}`,{count:$.length||``})]})}),(0,w.jsxs)(m,{children:[(0,w.jsxs)(d,{children:[(0,w.jsx)(_,{children:O(`bulkApproveTitle`,`Approve {{count}} requests?`,{count:$.length})}),(0,w.jsx)(y,{children:O(`bulkApproveBody`,`Each request is approved with your identity and its flow continues down the approve branch.`)})]}),(0,w.jsxs)(u,{children:[(0,w.jsx)(c,{children:O(`cancel`,`Cancel`)}),(0,w.jsx)(v,{onClick:()=>Fn(`approve`),children:O(`approveN`,`Approve {{count}}`,{count:$.length})})]})]})]}),(0,w.jsxs)(g,{children:[(0,w.jsx)(je,{asChild:!0,children:(0,w.jsxs)(f,{size:`sm`,variant:`outline`,disabled:Ut||$.length===0,className:`border-destructive text-destructive hover:bg-destructive hover:text-destructive-foreground`,children:[(0,w.jsx)(Ue,{className:`h-3.5 w-3.5 mr-1`}),O(`rejectN`,`Reject {{count}}`,{count:$.length||``})]})}),(0,w.jsxs)(m,{children:[(0,w.jsxs)(d,{children:[(0,w.jsx)(_,{children:O(`bulkRejectTitle`,`Reject {{count}} requests?`,{count:$.length})}),(0,w.jsx)(y,{children:O(`bulkRejectBody`,`This rejects the selected requests and notifies their submitters.`)})]}),(0,w.jsxs)(u,{children:[(0,w.jsx)(c,{children:O(`cancel`,`Cancel`)}),(0,w.jsx)(v,{onClick:()=>Fn(`reject`),className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:O(`rejectN`,`Reject {{count}}`,{count:$.length})})]})]})]}),(0,w.jsx)(f,{size:`sm`,variant:`ghost`,onClick:()=>Ht(new Set),disabled:Ut,children:O(`clear`,`Clear`)})]})]}),gt?(0,w.jsxs)(`div`,{className:`space-y-2`,children:[(0,w.jsx)(s,{className:`h-10 w-full`}),(0,w.jsx)(s,{className:`h-10 w-full`}),(0,w.jsx)(s,{className:`h-10 w-full`})]}):N.length===0?(0,w.jsx)(`div`,{className:`flex items-center justify-center min-h-[240px] rounded-md border border-dashed`,children:(0,w.jsxs)(ge,{children:[(0,w.jsx)(se,{children:O(`emptyTitle`,`No requests`)}),(0,w.jsx)(Ze,{children:M===`pending`?O(`emptyPending`,`You're all caught up — nothing is waiting on you.`):O(`emptyOther`,`Nothing here yet.`)}),M===`pending`&&(0,w.jsx)(f,{variant:`link`,size:`sm`,className:`mt-1`,onClick:()=>Vn(`all`),children:O(`emptyViewAll`,`Browse all requests`)})]})}):Z.length===0?(0,w.jsx)(`div`,{className:`flex items-center justify-center min-h-[160px] rounded-md border border-dashed text-sm text-muted-foreground`,children:O(`noMatches`,`No matches for current filters.`)}):(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(Re,{className:`hidden md:block`,children:(0,w.jsx)(ue,{className:`p-0`,children:(0,w.jsxs)(Le,{children:[(0,w.jsx)(qe,{children:(0,w.jsxs)(Ee,{children:[M===`pending`&&(0,w.jsx)(h,{className:`w-10`,children:(0,w.jsx)(fe,{checked:Mn,onCheckedChange:Nn,"aria-label":O(`selectAll`,`Select all`),disabled:jn.length===0})}),(0,w.jsx)(h,{children:O(`colRequest`,`Request`)}),(0,w.jsx)(h,{children:O(`colRecord`,`Record`)}),(0,w.jsx)(h,{children:O(`colRequester`,`Requester`)}),(0,w.jsx)(h,{children:O(`colStatus`,`Status`)}),(0,w.jsx)(h,{children:O(`colWaiting`,`Submitted`)}),(0,w.jsx)(h,{className:`w-20`,"aria-label":O(`colActions`,`Actions`)})]})}),(0,w.jsx)(We,{children:Z.map((e,t)=>(0,w.jsxs)(Ee,{className:p(`group cursor-pointer hover:bg-accent/50`,pn===t&&`ring-2 ring-inset ring-ring bg-accent/30`),onClick:()=>{mn(t),q(e.id)},children:[M===`pending`&&(0,w.jsx)(l,{className:`w-10`,onClick:e=>e.stopPropagation(),children:(0,w.jsx)(fe,{checked:H.has(e.id),onCheckedChange:()=>Pn(e.id),disabled:e.status!==`pending`,"aria-label":O(`selectRow`,`Select request`)})}),(0,w.jsx)(l,{children:(0,w.jsx)(Hn,{r:e})}),(0,w.jsx)(l,{children:(0,w.jsx)(Un,{r:e})}),(0,w.jsx)(l,{children:(0,w.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm`,children:[(0,w.jsx)(Ae,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`}),(0,w.jsx)(`span`,{className:`truncate`,title:e.submitter_id||``,children:ot(e)})]})}),(0,w.jsx)(l,{children:(0,w.jsx)(dt,{status:e.status})}),(0,w.jsxs)(l,{className:p(`text-xs whitespace-nowrap`,lt(e)),title:rt(D(e)),children:[(0,w.jsx)(Pe,{className:`h-3 w-3 inline mr-1`}),k(D(e)),e.status===`pending`&&e.sla_due_at&&(0,w.jsx)(`div`,{className:p(`mt-0.5 text-[10px] font-medium`,Date.parse(e.sla_due_at)<Date.now()?`text-red-600 dark:text-red-400`:`text-muted-foreground`),children:Date.parse(e.sla_due_at)<Date.now()?O(`slaOverdue`,`SLA overdue {{dur}}`,{dur:ut(Date.now()-Date.parse(e.sla_due_at))}):O(`slaRemaining`,`SLA {{dur}} left`,{dur:ut(Date.parse(e.sla_due_at)-Date.now())})})]}),(0,w.jsx)(l,{className:`w-20`,children:(0,w.jsx)(Wn,{r:e})})]},e.id))})]})})}),(0,w.jsx)(`div`,{className:`md:hidden space-y-2`,children:Z.map(e=>(0,w.jsx)(Re,{className:`cursor-pointer active:bg-accent/50`,onClick:()=>void q(e.id),children:(0,w.jsxs)(ue,{className:`p-3 space-y-1.5`,children:[(0,w.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,w.jsx)(`div`,{className:`font-medium text-sm truncate`,children:it(e)}),(0,w.jsx)(dt,{status:e.status})]}),(0,w.jsxs)(`div`,{className:`text-sm truncate`,children:[e.record_title||T(e.record_id),(0,w.jsx)(`span`,{className:`text-muted-foreground text-xs ml-1.5`,children:ct(e)})]}),(0,w.jsxs)(`div`,{className:`flex items-center justify-between text-xs text-muted-foreground`,children:[(0,w.jsxs)(`span`,{className:`inline-flex items-center gap-1 truncate`,children:[(0,w.jsx)(Ae,{className:`h-3 w-3`}),ot(e)]}),(0,w.jsxs)(`span`,{className:p(`inline-flex items-center gap-1 whitespace-nowrap`,lt(e)),children:[(0,w.jsx)(Pe,{className:`h-3 w-3`}),k(D(e))]})]}),Q(e)&&(0,w.jsxs)(`div`,{className:`flex gap-2 pt-1`,onClick:e=>e.stopPropagation(),children:[(0,w.jsxs)(f,{size:`sm`,className:`h-7 flex-1`,disabled:Kt===e.id,onClick:()=>void In(e),children:[(0,w.jsx)(De,{className:`h-3.5 w-3.5 mr-1`}),O(`approve`,`Approve`)]}),(0,w.jsxs)(f,{size:`sm`,variant:`outline`,className:`h-7 flex-1 border-destructive text-destructive`,disabled:Kt===e.id,onClick:()=>Gt(e),children:[(0,w.jsx)(Ue,{className:`h-3.5 w-3.5 mr-1`}),O(`reject`,`Reject`)]})]})]})},e.id))}),M!==`pending`&&bt!=null&&(0,w.jsxs)(`div`,{className:`flex items-center justify-center gap-3 py-1`,children:[(0,w.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:O(`loadedOf`,`Loaded {{loaded}} of {{total}}`,{loaded:N.length,total:bt})}),N.length<bt&&(0,w.jsx)(f,{size:`sm`,variant:`outline`,disabled:vt,onClick:()=>void hn(),children:vt?O(`loadingMore`,`Loading…`):O(`loadMore`,`Load more`)})]}),(0,w.jsx)(`div`,{className:`hidden md:block text-[11px] text-muted-foreground`,children:O(`keyboardHint`,`Keyboard: j/k move · Enter open · x select · a approve · r reject`)})]})]})]}),(0,w.jsx)(g,{open:Jt,onOpenChange:e=>{e||(Yt(!1),Zt(``))},children:(0,w.jsxs)(m,{children:[(0,w.jsxs)(d,{children:[(0,w.jsx)(_,{children:O(`reassignTitle`,`Hand this approval to someone else?`)}),(0,w.jsx)(y,{children:O(`reassignBody`,`Your approver slot moves to the person you pick — they are notified and can act immediately.`)})]}),(0,w.jsxs)(`div`,{children:[(0,w.jsx)(Ie,{htmlFor:`reassign-to`,className:`text-xs`,children:O(`reassignTo`,`New approver`)}),(0,w.jsx)(Ne,{id:`reassign-to`,list:`reassign-user-options`,value:Xt,onChange:e=>Zt(e.target.value),placeholder:O(`reassignToPlaceholder`,`Pick a user or type an email / role:<name>`),className:`mt-1`}),(0,w.jsx)(`datalist`,{id:`reassign-user-options`,children:dn.map(e=>(0,w.jsx)(`option`,{value:e.email,children:e.name},e.email))})]}),(0,w.jsxs)(u,{children:[(0,w.jsx)(c,{children:O(`cancel`,`Cancel`)}),(0,w.jsx)(v,{disabled:!Xt.trim()||W,onClick:()=>void vn(),children:O(`reassignBtn`,`Reassign`)})]})]})}),(0,w.jsx)(g,{open:Qt,onOpenChange:e=>{e||($t(!1),tn(``))},children:(0,w.jsxs)(m,{children:[(0,w.jsxs)(d,{children:[(0,w.jsx)(_,{children:O(`requestInfoTitle`,`Ask the requester for more information?`)}),(0,w.jsx)(y,{children:O(`requestInfoBody`,`The request stays pending; the requester is notified and can reply on the thread.`)})]}),(0,w.jsx)(Ge,{value:en,onChange:e=>tn(e.target.value),rows:3,placeholder:O(`requestInfoPlaceholder`,`What do you need from the requester?`)}),(0,w.jsxs)(u,{children:[(0,w.jsx)(c,{children:O(`cancel`,`Cancel`)}),(0,w.jsx)(v,{disabled:!en.trim()||W,onClick:()=>void bn(),children:O(`requestInfoBtn`,`Request info`)})]})]})}),(0,w.jsx)(g,{open:nn,onOpenChange:e=>{e||(rn(!1),on(``))},children:(0,w.jsxs)(m,{children:[(0,w.jsxs)(d,{children:[(0,w.jsx)(_,{children:O(`sendBackTitle`,`Send this request back for revision?`)}),(0,w.jsx)(y,{children:O(`sendBackBody`,`This round ends and the record unlocks so the requester can fix the data. When they resubmit, a fresh approval round opens for all approvers.`)})]}),(0,w.jsx)(Ge,{value:an,onChange:e=>on(e.target.value),rows:3,placeholder:O(`sendBackPlaceholder`,`What needs to be fixed before this can be approved?`)}),(0,w.jsxs)(u,{children:[(0,w.jsx)(c,{children:O(`cancel`,`Cancel`)}),(0,w.jsx)(v,{disabled:W,onClick:()=>void xn(),children:O(`sendBackBtn`,`Send back`)})]})]})}),(0,w.jsx)(g,{open:!!U,onOpenChange:e=>!e&&Gt(null),children:(0,w.jsxs)(m,{children:[(0,w.jsxs)(d,{children:[(0,w.jsx)(_,{children:O(`rejectOneTitle`,`Reject "{{title}}"?`,{title:U?U.record_title||T(U.record_id):``})}),(0,w.jsx)(y,{children:O(`rejectOneBody`,`This rejects the request and notifies the submitter.`)})]}),(0,w.jsxs)(u,{children:[(0,w.jsx)(c,{children:O(`cancel`,`Cancel`)}),(0,w.jsx)(v,{onClick:()=>void Ln(),className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:O(`reject`,`Reject`)})]})]})}),(0,w.jsx)(he,{open:!!P,onOpenChange:e=>!e&&gn(),children:(0,w.jsxs)(ae,{className:`w-full sm:max-w-xl overflow-y-auto`,children:[(0,w.jsxs)(pe,{children:[(0,w.jsx)(_e,{children:F?it(F):O(`drawerTitle`,`Approval Request`)}),(0,w.jsx)(le,{children:F?at(F)||ct(F):``})]}),F&&An>=0&&Z.length>1&&(0,w.jsxs)(`div`,{className:`flex items-center justify-between mt-2 text-xs text-muted-foreground`,children:[(0,w.jsxs)(f,{variant:`ghost`,size:`sm`,className:`h-7 px-2`,disabled:An<=0,onClick:()=>{let e=Z[An-1];e&&q(e.id)},children:[(0,w.jsx)(be,{className:`h-4 w-4 mr-0.5`}),O(`prevRequest`,`Previous`)]}),(0,w.jsx)(`span`,{children:O(`positionOf`,`{{index}} of {{total}}`,{index:An+1,total:Z.length})}),(0,w.jsxs)(f,{variant:`ghost`,size:`sm`,className:`h-7 px-2`,disabled:An>=Z.length-1,onClick:()=>{let e=Z[An+1];e&&q(e.id)},children:[O(`nextRequest`,`Next`),(0,w.jsx)(Xe,{className:`h-4 w-4 ml-0.5`})]})]}),At?(0,w.jsxs)(`div`,{className:`space-y-2 mt-6`,children:[(0,w.jsx)(s,{className:`h-6 w-3/4`}),(0,w.jsx)(s,{className:`h-6 w-1/2`}),(0,w.jsx)(s,{className:`h-20 w-full`})]}):F?(0,w.jsxs)(`div`,{className:`space-y-4 mt-6`,children:[(0,w.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs text-muted-foreground`,children:[(0,w.jsx)(dt,{status:F.status}),(F.round??1)>1&&(0,w.jsx)(ne,{variant:`outline`,className:`text-[10px] border-violet-200 text-violet-700 dark:border-violet-500/30 dark:text-violet-400`,children:O(`roundChip`,`Round {{n}}`,{n:F.round})}),(0,w.jsxs)(`span`,{className:`inline-flex items-center gap-1`,title:rt(D(F)),children:[(0,w.jsx)(Pe,{className:`h-3 w-3`}),O(`submittedAgo`,`Submitted {{when}}`,{when:k(D(F))})]}),F.completed_at&&(0,w.jsxs)(`span`,{children:[`· `,O(`completedAt`,`Completed {{when}}`,{when:k(F.completed_at)})]}),F.status===`pending`&&F.sla_due_at&&(0,w.jsx)(ne,{variant:`outline`,className:p(`text-[10px]`,Date.parse(F.sla_due_at)<Date.now()?`border-red-200 bg-red-50 text-red-700 dark:border-red-500/30 dark:bg-red-500/10 dark:text-red-400`:`border-border text-muted-foreground`),children:Date.parse(F.sla_due_at)<Date.now()?O(`slaOverdue`,`SLA overdue {{dur}}`,{dur:ut(Date.now()-Date.parse(F.sla_due_at))}):O(`slaRemaining`,`SLA {{dur}} left`,{dur:ut(Date.parse(F.sla_due_at)-Date.now())})})]}),(0,w.jsx)(Re,{children:(0,w.jsxs)(ue,{className:`p-4 space-y-3`,children:[(0,w.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,w.jsxs)(`div`,{className:`min-w-0`,children:[(0,w.jsxs)(r,{to:pt(F),className:`text-base font-semibold hover:underline inline-flex items-center gap-1.5`,children:[(0,w.jsx)(`span`,{className:`truncate`,children:F.record_title||T(F.record_id)}),(0,w.jsx)(ie,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`})]}),(0,w.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:ct(F)})]}),(0,w.jsx)(`div`,{className:`text-right text-xs text-muted-foreground shrink-0`,children:(0,w.jsxs)(`div`,{className:`inline-flex items-center gap-1`,children:[(0,w.jsx)(Ae,{className:`h-3 w-3`}),(0,w.jsx)(`span`,{title:F.submitter_id||``,children:ot(F)})]})})]}),ft(F.payload,F.payload_display).length>0&&(0,w.jsx)(`div`,{className:`grid grid-cols-2 gap-x-4 gap-y-2 text-sm border-t pt-3`,children:ft(F.payload,F.payload_display).map(([e,t])=>(0,w.jsxs)(`div`,{className:`min-w-0`,children:[(0,w.jsx)(`div`,{className:`text-[11px] text-muted-foreground`,children:e}),(0,w.jsx)(`div`,{className:`truncate`,title:t,children:t})]},e))}),F.status===`pending`&&(F.pending_approvers||[]).length>0&&(0,w.jsxs)(`div`,{className:`border-t pt-3`,children:[(0,w.jsx)(`div`,{className:`text-[11px] text-muted-foreground mb-1`,children:O(`waitingOn`,`Waiting on`)}),(0,w.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:(F.pending_approvers||[]).map((e,t)=>(0,w.jsx)(ne,{variant:`outline`,className:`text-[11px]`,title:e,children:st(e,F)},t))})]})]})}),(F.flow_steps?.length??0)>1&&(0,w.jsx)(`div`,{className:`flex items-center px-1`,"aria-label":O(`stepProgress`,`Approval steps`),children:F.flow_steps.map((e,t)=>(0,w.jsxs)(x.Fragment,{children:[t>0&&(0,w.jsx)(`div`,{className:p(`h-px flex-1 mx-2`,e.state===`done`||e.state===`current`?`bg-emerald-300 dark:bg-emerald-700`:`bg-border`)}),(0,w.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0`,children:[(0,w.jsx)(`span`,{className:p(`flex items-center justify-center h-5 w-5 rounded-full text-[10px] font-semibold`,e.state===`done`&&`bg-emerald-500 text-white`,e.state===`current`&&`bg-amber-500 text-white ring-2 ring-amber-200 dark:ring-amber-500/30`,e.state===`upcoming`&&`bg-muted text-muted-foreground border`),children:e.state===`done`?(0,w.jsx)(Je,{className:`h-3 w-3`}):t+1}),(0,w.jsx)(`span`,{className:p(`text-xs`,e.state===`current`?`font-medium`:`text-muted-foreground`),children:e.label})]})]},e.id))}),(0,w.jsxs)(`div`,{children:[(0,w.jsx)(`h3`,{className:`text-sm font-semibold mb-3`,children:O(`history`,`Activity`)}),Ot.length===0?(0,w.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:O(`noActions`,`No actions yet.`)}):(0,w.jsx)(`ol`,{className:`relative space-y-3 pl-5 before:absolute before:left-[7px] before:top-1 before:bottom-1 before:w-px before:bg-border`,children:Ot.map(e=>{let t=e.action===`approve`?`bg-emerald-500`:e.action===`reject`?`bg-destructive`:e.action===`submit`?`bg-blue-500`:e.action===`reassign`?`bg-indigo-500`:e.action===`remind`||e.action===`request_info`?`bg-amber-500`:e.action===`comment`?`bg-slate-400`:e.action===`escalate`?`bg-red-500`:e.action===`revise`?`bg-violet-500`:e.action===`resubmit`?`bg-blue-500`:`bg-muted-foreground`,n=e.actor_id===`system:sla`?O(`systemSlaActor`,`System (SLA)`):e.actor_name??(e.actor_id&&e.actor_id===F.submitter_id?ot(F):T(e.actor_id)),r=e.action===`submit`?O(`actSubmit`,`Submitted`):e.action===`approve`?O(`actApprove`,`Approved`):e.action===`reject`?O(`actReject`,`Rejected`):e.action===`recall`?O(`actRecall`,`Recalled`):e.action===`reassign`?O(`actReassign`,`Reassigned`):e.action===`remind`?O(`actRemind`,`Reminder sent`):e.action===`request_info`?O(`actRequestInfo`,`Requested more info`):e.action===`comment`?O(`actComment`,`Commented`):e.action===`escalate`?O(`actEscalate`,`SLA escalated`):e.action===`revise`?O(`actRevise`,`Sent back for revision`):e.action===`resubmit`?O(`actResubmit`,`Resubmitted`):e.action;return(0,w.jsxs)(`li`,{className:`relative text-xs`,children:[(0,w.jsx)(`span`,{className:`absolute -left-[18px] top-1 h-3 w-3 rounded-full ring-2 ring-background ${t}`,"aria-hidden":!0}),(0,w.jsxs)(`div`,{className:`flex items-baseline gap-1.5 flex-wrap`,children:[(0,w.jsx)(`span`,{className:`font-medium`,children:r}),(0,w.jsx)(`span`,{className:`text-muted-foreground`,children:`·`}),(0,w.jsx)(`span`,{title:e.actor_id||``,children:n}),(0,w.jsx)(`span`,{className:`ml-auto text-muted-foreground text-[10px]`,title:rt(e.created_at),children:k(e.created_at)})]}),e.comment&&(0,w.jsxs)(`div`,{className:`text-muted-foreground italic mt-0.5`,children:[`"`,e.comment,`"`]})]},e.id)})}),F.status===`pending`&&(Tn||En)&&(0,w.jsxs)(`div`,{className:`flex items-center gap-2 mt-3`,children:[(0,w.jsx)(Ne,{value:ln,onChange:e=>un(e.target.value),onKeyDown:e=>{e.key===`Enter`&&ln.trim()&&(e.preventDefault(),Cn())},placeholder:O(`replyPlaceholder`,`Reply on this request…`),className:`h-8 text-sm`}),(0,w.jsx)(f,{size:`sm`,variant:`outline`,className:`h-8 px-2 shrink-0`,disabled:!ln.trim()||W,onClick:()=>void Cn(),children:(0,w.jsx)(Ye,{className:`h-3.5 w-3.5`})})]})]}),F.payload!=null&&(0,w.jsxs)(`details`,{className:`group`,children:[(0,w.jsx)(`summary`,{className:`cursor-pointer text-xs text-muted-foreground hover:text-foreground select-none`,children:O(`rawData`,`Raw data (JSON)`)}),(0,w.jsxs)(`div`,{className:`mt-2`,children:[(0,w.jsx)(`div`,{className:`flex justify-end`,children:(0,w.jsxs)(`button`,{type:`button`,onClick:async()=>{try{await navigator.clipboard.writeText(JSON.stringify(F.payload,null,2)),b.success(O(`copied`,`Copied`))}catch{b.error(O(`copyFailed`,`Copy failed`))}},className:`text-[10px] text-muted-foreground hover:text-foreground inline-flex items-center gap-1`,children:[(0,w.jsx)(de,{className:`h-3 w-3`}),O(`copy`,`Copy`)]})}),(0,w.jsx)(`pre`,{className:`text-[11px] bg-muted/50 rounded p-2 overflow-auto max-h-48 mt-1`,children:JSON.stringify(F.payload,null,2)})]})]}),F.status===`pending`&&(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(Qe,{}),(0,w.jsxs)(`div`,{className:`space-y-3`,children:[$e&&(0,w.jsxs)(`details`,{className:`group`,children:[(0,w.jsx)(`summary`,{className:`cursor-pointer text-xs text-muted-foreground hover:text-foreground select-none`,children:O(`overrideActor`,`Act as another identity (admin)`)}),(0,w.jsxs)(`div`,{className:`mt-2`,children:[(0,w.jsx)(Ie,{htmlFor:`actor-override`,className:`text-xs`,children:O(`actor`,`Actor`)}),(0,w.jsx)(`input`,{id:`actor-override`,type:`text`,value:R,onChange:e=>Mt(e.target.value),placeholder:`${O(`auto`,`Auto`)}: ${J(F)||`—`}`,className:`w-full mt-1 px-3 py-2 text-sm border rounded-md bg-background`}),(0,w.jsx)(`div`,{className:`text-[10px] text-muted-foreground mt-1`,children:O(`overrideHint`,`e.g. role:sales_manager. Leave blank to use the auto-detected identity.`)})]})]}),(0,w.jsxs)(`div`,{children:[(0,w.jsx)(Ie,{htmlFor:`comment`,className:`text-xs`,children:O(`comment`,`Comment (optional)`)}),(0,w.jsx)(`div`,{className:`flex flex-wrap gap-1.5 mt-1.5`,children:[O(`quickPhrase1`,`Approved — meets requirements.`),O(`quickPhrase2`,`Approved with conditions — please monitor execution.`),O(`quickPhrase3`,`Please add supporting material and resubmit.`)].map(e=>(0,w.jsx)(`button`,{type:`button`,onClick:()=>L(e),className:`text-[11px] px-2 py-0.5 rounded-full border text-muted-foreground hover:text-foreground hover:bg-accent transition-colors`,children:e},e))}),(0,w.jsx)(Ge,{id:`comment`,value:I,onChange:e=>L(e.target.value),rows:2,className:`mt-1`})]}),(0,w.jsxs)(`div`,{className:`flex gap-2 flex-wrap`,children:[(0,w.jsxs)(f,{size:`sm`,onClick:()=>_n(`approve`),disabled:!Tn||z!==null,children:[(0,w.jsx)(De,{className:`h-4 w-4 mr-1`}),z===`approve`?O(`approving`,`Approving…`):O(`approve`,`Approve`)]}),(0,w.jsxs)(g,{children:[(0,w.jsx)(je,{asChild:!0,children:(0,w.jsxs)(f,{size:`sm`,variant:`outline`,disabled:!Tn||z!==null,className:`border-destructive text-destructive hover:bg-destructive hover:text-destructive-foreground`,children:[(0,w.jsx)(Ue,{className:`h-4 w-4 mr-1`}),z===`reject`?O(`rejecting`,`Rejecting…`):O(`reject`,`Reject`)]})}),(0,w.jsxs)(m,{children:[(0,w.jsxs)(d,{children:[(0,w.jsx)(_,{children:O(`rejectTitle`,`Reject this request?`)}),(0,w.jsx)(y,{children:O(`rejectBody`,`This marks the request as rejected and notifies the submitter.`)})]}),(0,w.jsxs)(u,{children:[(0,w.jsx)(c,{children:O(`cancel`,`Cancel`)}),(0,w.jsx)(v,{onClick:()=>_n(`reject`),className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:O(`reject`,`Reject`)})]})]})]}),Tn&&(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)(f,{size:`sm`,variant:`outline`,disabled:z!==null||W,className:`border-violet-300 text-violet-700 hover:bg-violet-50 dark:text-violet-400`,onClick:()=>rn(!0),children:[(0,w.jsx)(oe,{className:`h-4 w-4 mr-1`}),O(`sendBackBtn`,`Send back`)]}),(0,w.jsxs)(f,{size:`sm`,variant:`outline`,disabled:z!==null||W,className:`border-amber-300 text-amber-700 hover:bg-amber-50 dark:text-amber-400`,onClick:()=>$t(!0),children:[(0,w.jsx)(Ke,{className:`h-4 w-4 mr-1`}),O(`requestInfoBtn`,`Request info`)]}),(0,w.jsxs)(f,{size:`sm`,variant:`outline`,disabled:z!==null||W,onClick:()=>{wn(),Yt(!0)},children:[(0,w.jsx)(Me,{className:`h-4 w-4 mr-1`}),O(`reassignBtn`,`Reassign`)]})]}),En&&(0,w.jsxs)(f,{size:`sm`,variant:`outline`,disabled:W,onClick:()=>void yn(),children:[(0,w.jsx)(ze,{className:`h-4 w-4 mr-1`}),O(`remindBtn`,`Send reminder`)]}),En&&(0,w.jsxs)(g,{children:[(0,w.jsx)(je,{asChild:!0,children:(0,w.jsxs)(f,{size:`sm`,variant:`outline`,disabled:z!==null,children:[(0,w.jsx)(ce,{className:`h-4 w-4 mr-1`}),z===`recall`?O(`recalling`,`Recalling…`):O(`recall`,`Recall`)]})}),(0,w.jsxs)(m,{children:[(0,w.jsxs)(d,{children:[(0,w.jsx)(_,{children:O(`recallTitle`,`Recall this request?`)}),(0,w.jsx)(y,{children:O(`recallBody`,`This withdraws your request. Approvers can no longer act on it, and the record is unlocked.`)})]}),(0,w.jsxs)(u,{children:[(0,w.jsx)(c,{children:O(`cancel`,`Cancel`)}),(0,w.jsx)(v,{onClick:()=>_n(`recall`),children:O(`recall`,`Recall`)})]})]})]})]}),!Tn&&(0,w.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:En?O(`whyDisabledSubmitter`,`You submitted this request, so you can recall it — but only the assigned approvers can approve or reject.`):O(`whyDisabled`,`Only the assigned approvers can act on this request. It is waiting on: {{who}}.`,{who:(F.pending_approvers||[]).map(e=>st(e,F)).join(`, `)||`—`})})]})]}),Dn&&(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(Qe,{}),(0,w.jsxs)(`div`,{className:`space-y-3`,children:[(0,w.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:O(`returnedHint`,`An approver sent this back to you. The record is unlocked — fix the data, then resubmit to start a new approval round.`)}),(0,w.jsxs)(`div`,{children:[(0,w.jsx)(Ie,{htmlFor:`resubmit-comment`,className:`text-xs`,children:O(`comment`,`Comment (optional)`)}),(0,w.jsx)(Ge,{id:`resubmit-comment`,value:I,onChange:e=>L(e.target.value),rows:2,className:`mt-1`,placeholder:O(`resubmitPlaceholder`,`What did you change?`)})]}),(0,w.jsxs)(`div`,{className:`flex gap-2 flex-wrap`,children:[(0,w.jsx)(f,{asChild:!0,size:`sm`,variant:`outline`,children:(0,w.jsxs)(r,{to:pt(F),children:[(0,w.jsx)(ie,{className:`h-4 w-4 mr-1`}),O(`editRecordBtn`,`Edit record`)]})}),(0,w.jsxs)(f,{size:`sm`,disabled:sn,onClick:()=>void Sn(),children:[(0,w.jsx)(me,{className:p(`h-4 w-4 mr-1`,sn&&`animate-spin`)}),sn?O(`resubmitting`,`Resubmitting…`):O(`resubmitBtn`,`Resubmit`)]}),(0,w.jsxs)(g,{children:[(0,w.jsx)(je,{asChild:!0,children:(0,w.jsxs)(f,{size:`sm`,variant:`outline`,disabled:sn,children:[(0,w.jsx)(ce,{className:`h-4 w-4 mr-1`}),O(`recall`,`Recall`)]})}),(0,w.jsxs)(m,{children:[(0,w.jsxs)(d,{children:[(0,w.jsx)(_,{children:O(`abandonTitle`,`Abandon this revision?`)}),(0,w.jsx)(y,{children:O(`abandonBody`,`This withdraws the request instead of resubmitting it. The approval ends here.`)})]}),(0,w.jsxs)(u,{children:[(0,w.jsx)(c,{children:O(`cancel`,`Cancel`)}),(0,w.jsx)(v,{onClick:()=>_n(`recall`),children:O(`recall`,`Recall`)})]})]})]})]})]})]})]}):null]})})]})}export{pt as ApprovalsInboxPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,l as n,t as r,u as i}from"./vendor-react-DR370ovB.js";import{r as a}from"./framework-ZJouI0cJ.js";import{Bt as o,Ht as s,Ut as c,Vt as l,Wt as u,ai as d,hr as f,vi as p,w as m}from"./ui-components-Bs-DxYrW.js";import{r as h}from"./vendor-ui-utils-rQOI1gAo.js";import{a as g,i as _,n as v}from"./MetadataProvider-BagIop6q.js";import{a as y,d as b,f as ee,p as te,r as x,t as ne,u as S}from"./plugin-chatbot-CJsfoGAD.js";import{i as C}from"./runtime-config-BeHVOPm3.js";import{a as re,i as ie,o as w,r as ae,s as T}from"./index-B99f8h8i.js";var E=e(t(),1),D=r(),O={data_chat:{zh:`智能助手`,en:`Assistant`},metadata_assistant:{zh:`元数据开发助手`,en:`Metadata Assistant`}};function k(e,t,n){let r=t?O[t]:void 0;return r?e?r.zh:r.en:n}function A(e,t,n,r,i){let a=(e??``).toLowerCase().startsWith(`zh`),o=k(a,n,r),s=i.slice(0,2).map(e=>e.label||e.name);if(a){let e=[s[0]?`查询最近创建的${s[0]}`:`帮我查询最近的数据`,s[0]?`统计${s[0]}的总数量`:`统计各对象的记录数量`,s[1]?`${s[1]}有哪些字段?`:`当前应用里有哪些数据对象?`].filter(Boolean);return{agentLabel:o,labels:{emptyTitle:`你好,我是${o}`,emptyDescription:`随时帮你查询和分析「${t}」中的数据。试试下面的问题,或直接输入你的需求。`,clear:`清空对话`,sendHint:`发送`,agentActivity:`执行过程`,toolCompleted:`已完成`,toolRunning:`运行中`,toolAwaitingApproval:`等待确认`,toolFailed:`失败`,toolDetailsHidden:`已隐藏工具参数和原始结果,仅保留过程摘要。`,copy:`复制`,copied:`已复制`,regenerate:`重新生成`,model:`模型`,submit:`发送`,uploadFiles:`上传文件`,stopResponse:`停止生成`,trace:`调试 trace`,viewTrace:`查看调试 trace`},placeholder:`向${o}提问…`,loadingPlaceholder:`正在加载助手…`,title:`${t} 智能助手`,newChat:`开启新对话`,share:`分享对话`,reviewDraft:e=>`查看 ${e} 项变更`,publishDrafts:`发布`,published:`已发布`,publishOk:`已发布,对象已生效。`,publishFailed:`发布失败`,seedWarn:`已发布,但部分示例数据未能载入。`,openBuiltApp:`打开应用`,suggestions:e}}let c=[s[0]?`Show the latest ${s[0]}`:`Show my most recent records`,s[0]?`How many ${s[0]} are there?`:`Count records by status`,s[1]?`What fields does ${s[1]} have?`:`What data can I work with here?`].filter(Boolean);return{agentLabel:o,labels:{emptyTitle:`Hi, I'm ${o}`,emptyDescription:`I can help you query and analyze your ${t} data. Try a prompt below, or just type your question.`,clear:`Clear`,sendHint:`to send`,agentActivity:`Agent activity`,toolCompleted:`Completed`,toolRunning:`Running`,toolAwaitingApproval:`Awaiting approval`,toolFailed:`Failed`,toolDetailsHidden:`Tool inputs and raw results are hidden in this view.`,copy:`Copy`,copied:`Copied`,regenerate:`Regenerate`,model:`Model`,submit:`Submit`,uploadFiles:`Upload files`,stopResponse:`Stop response`,trace:`trace`,viewTrace:`View trace`},placeholder:`Ask ${o}...`,loadingPlaceholder:`Loading assistant...`,title:`${t} Assistant`,newChat:`New chat`,share:`Share conversation`,reviewDraft:e=>`Review ${e} change${e===1?``:`s`}`,publishDrafts:`Publish`,published:`Published`,publishOk:`Published — objects are now live.`,publishFailed:`Publish failed`,seedWarn:`Published, but some sample data failed to load.`,openBuiltApp:`Open app`,suggestions:c}}var j=`/api/v1/ai`;function M(e){if(e)return e.replace(/\/$/,``);let t={BASE_URL:`./`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1,VITE_SENTRY_DSN:`https://1373a588ceb9da150b11e64bf85f583d@o4510356161757184.ingest.us.sentry.io/4511439670673408`,VITE_SENTRY_ENVIRONMENT:`production`,VITE_SENTRY_SEND_DEFAULT_PII:`true`,VITE_SERVER_URL:``,VITE_USE_MOCK_SERVER:`false`},n=t.VITE_AI_BASE_URL;return n?n.replace(/\/$/,``):`${(t.VITE_SERVER_URL??``).replace(/\/$/,``)}${j}`}function oe(e,t){if(!e||e.type!==`object`)return null;let n=e.label||e.name||`this object`;return(t??``).toLowerCase().startsWith(`zh`)?[`为「${n}」补充字段`,`为「${n}」建议校验规则`,`添加一个状态选项字段`]:[`Add fields to ${n}`,`Suggest validations for ${n}`,`Add a status picklist field`]}var N=new Set([`view`,`record`,`page`,`dashboard`,`design`,`report`,`metadata`]);function P(e){try{return decodeURIComponent(e)}catch{return e}}function se(e,t){let n=e.split(`/`).filter(Boolean),r=n.indexOf(`apps`);if(r===-1||n.length<r+3)return{};let i=P(n[r+2]);if(N.has(i)||!t.some(e=>e.name===i))return{};let a=n[r+3]?P(n[r+3]):void 0,o=a&&a!==`new`?a:void 0;return{objectName:i,...o?{recordId:o}:{}}}function F({appLabel:e,appName:t,objects:r,agents:b,agentsLoading:S,activeAgent:w,onAgentChange:O,showAgentPicker:k,chatApi:j,apiBase:M,defaultOpen:N=!1,conversationId:P,initialMessages:F}){let{language:I}=a(),L=i(),R=n(),z=E.useMemo(()=>se(R.pathname,r),[R.pathname,r]),{editor:B}=g(),V=E.useMemo(()=>!F||F.length===0?[]:te(F),[F]),H=E.useMemo(()=>b.find(e=>e.name===w)?.label??w??e,[b,w,e]),U=E.useMemo(()=>A(I,e,w,H,r),[I,e,w,H,r]),W=E.useMemo(()=>oe(B,I),[B,I]),{errorSuppressed:G,handleChatError:ce,setMessagesRef:le,resetSuppression:K}=ae({chatApi:j,conversationId:P}),{messages:q,isLoading:J,error:ue,sendMessage:Y,stop:de,reload:fe,clear:X,setMessages:Z}=ee({api:j,conversationId:P,onError:ce,body:{context:{activeApp:e,appName:t,objects:r.map(e=>({name:e.name,label:e.label})),agentName:w,autoPublishAiBuilds:C().features.autoPublishAiBuilds,...z.objectName?{objectName:z.objectName}:{},...z.recordId?{recordId:z.recordId}:{},...B?{editing:B}:{}}},initialMessages:V,autoResponse:!j,autoResponseText:r.length>0?`I can help you work with ${r.map(e=>e.label||e.name).join(`, `)}. What would you like to do?`:`Thanks for your message! I'm here to help you navigate and manage your data.`,autoResponseDelay:600});E.useEffect(()=>{le.current=Z},[Z]),E.useEffect(()=>{T(P,re(q))},[P,q]);let Q=ne({messages:q,apiBase:M,continueConversation:e=>{K(),Y(e)}}),pe=k&&b.length>1?(0,D.jsxs)(o,{value:w,onValueChange:O,disabled:S,children:[(0,D.jsx)(c,{className:`h-7 w-[180px] text-xs`,"data-testid":`floating-chatbot-agent-picker`,children:(0,D.jsx)(u,{placeholder:`Choose agent...`})}),(0,D.jsx)(l,{align:`end`,children:b.map(e=>(0,D.jsxs)(s,{value:e.name,className:`text-xs`,children:[(0,D.jsx)(`span`,{className:`font-medium`,children:e.label}),e.description?(0,D.jsx)(`span`,{className:`block text-muted-foreground text-[10px] truncate max-w-[220px]`,children:e.description}):null]},e.name))})]}):null,[me,$]=E.useState(!1),he=E.useMemo(()=>M.replace(/\/v1\/ai$/,``).replace(/\/ai$/,``)||`/api`,[M]),ge=(0,D.jsxs)(D.Fragment,{children:[q.length>0?(0,D.jsx)(f,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,"aria-label":U.newChat,title:U.newChat,"data-testid":`floating-chatbot-new`,onClick:X,children:(0,D.jsx)(d,{className:`h-4 w-4`})}):null,P?(0,D.jsx)(f,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,"aria-label":U.share,title:U.share,"data-testid":`floating-chatbot-share`,onClick:()=>$(!0),children:(0,D.jsx)(p,{className:`h-4 w-4`})}):null]});return(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(x,{floatingConfig:{position:`bottom-right`,defaultOpen:N,panelWidth:420,panelHeight:560,title:U.title,triggerSize:56},headerExtra:pe,headerActions:ge,messages:q,labels:U.labels,showAvatars:!0,hideClearBar:!0,assistantAvatarFallback:U.agentLabel,suggestions:q.length===0?W??U.suggestions:void 0,placeholder:w?U.placeholder:S?U.loadingPlaceholder:U.placeholder,onSendMessage:e=>{K(),Y(e)},onClear:X,onStop:J?de:void 0,onReload:fe,isLoading:J,error:G?void 0:ue,enableMarkdown:!0,onToolApprove:Q.decide,toolDecisions:Q.decisions,toolApproveLabel:`Approve & run`,toolDenyLabel:`Reject`,toolDenyReason:`Operator rejected from chat`,onReviewDraft:e=>{e[0]&&_(e[0])},toolReviewLabel:U.reviewDraft,onOpenBuiltApp:e=>L(`/apps/${encodeURIComponent(e)}`),openBuiltAppLabel:U.openBuiltApp,onPreviewDraftApp:(e,t)=>L(t?.materialized?`/apps/${encodeURIComponent(e)}`:`/apps/${encodeURIComponent(e)}?preview=draft`),onDraftArtifacts:e=>{for(let t of e)v(t)},fetchPendingDraftCount:ie,onPublishDrafts:async e=>{try{let t=await fetch(`/api/v1/packages/${encodeURIComponent(e)}/publish-drafts`,{method:`POST`,credentials:`include`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:`{}`}),n=await t.json().catch(()=>null);if(!t.ok||n?.success===!1)throw Error(n?.error?.message||`HTTP ${t.status}`);let r=n?.data?.failedCount??n?.failedCount??0;if(r)throw Error(String(r));let i=n?.data?.seedApplied??n?.seedApplied;i&&i.success===!1?h.warning(U.seedWarn,{description:i.error??(Array.isArray(i.errors)&&i.errors.length?String(i.errors[0]):void 0)}):h.success(U.publishOk);let a=(n?.data?.published??n?.published??[]).find(e=>e?.type===`app`&&e?.name);return a?.name&&L(`/apps/${encodeURIComponent(a.name)}`),{ok:!0,health:y(n)}}catch(e){return h.error(U.publishFailed,{description:e instanceof Error?e.message:void 0}),!1}},publishDraftsLabel:U.publishDrafts,publishedLabel:U.published,autoPublishDrafts:C().features.autoPublishAiBuilds}),P&&(0,D.jsx)(m,{open:me,onOpenChange:$,objectName:`ai_conversations`,recordId:P,recordLabel:`this conversation`,apiBase:he})]})}function I({appLabel:e,appName:t,objects:n,apiBase:r,defaultAgent:i,showAgentPicker:a,defaultOpen:o=!1,userId:s}){let c=E.useMemo(()=>M(r),[r]),l={BASE_URL:`./`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1,VITE_SENTRY_DSN:`https://1373a588ceb9da150b11e64bf85f583d@o4510356161757184.ingest.us.sentry.io/4511439670673408`,VITE_SENTRY_ENVIRONMENT:`production`,VITE_SENTRY_SEND_DEFAULT_PII:`true`,VITE_SERVER_URL:``,VITE_USE_MOCK_SERVER:`false`},u=l.VITE_AI_DEFAULT_AGENT,d=a??l.VITE_AI_SHOW_AGENT_PICKER===`true`,{agents:f,isLoading:p,error:m}=b({apiBase:c}),[h,g]=E.useState(void 0);E.useEffect(()=>{if(!h&&f.length>0){let e=S(f,i??u);e&&g(e)}},[f,h,i,u]);let _=h?`${c}/agents/${encodeURIComponent(h)}/chat`:void 0,{conversationId:v,initialMessages:y}=w({userId:s,scope:h,apiBase:c});return(0,D.jsx)(F,{appLabel:e,appName:t,objects:n,agents:f,agentsLoading:p,agentsError:m,activeAgent:h,onAgentChange:g,showAgentPicker:d,chatApi:_,apiBase:c,defaultOpen:o,conversationId:v,initialMessages:y},`${_??`local`}:${v??`pending`}`)}export{I as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as e,r as t}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as n,f as r,t as i}from"./vendor-react-DR370ovB.js";import{f as a}from"./infrastructure-CJNwTVno.js";import{T as o,r as s,w as c}from"./framework-ZJouI0cJ.js";import{As as l,Bn as u,Es as d,H as f,Hi as p,Hn as m,Ln as h,Qr as g,R as _,Ra as v,Rn as y,Sr as b,Va as x,Vn as S,Vr as C,Yi as w,fc as T,hr as E,js as D,rc as O,z as ee,zn as te,zr as k}from"./ui-components-Bs-DxYrW.js";import{r as A}from"./vendor-ui-utils-rQOI1gAo.js";import"./AdapterProvider-o2n9dY2j.js";import{n as ne}from"./plugin-form-C5yl9byI.js";import"./MetadataProvider-BagIop6q.js";import{r as re}from"./ExpressionProvider-Cuv0RaiR.js";import{C as ie,r as j}from"./mergeServerFields-DPrTk8u4.js";import{r as M}from"./utils-bipVuqQL.js";import{n as ae,r as oe,t as se}from"./MetadataInspector-zJtxyFau.js";import{r as N,t as P}from"./RuntimeDraftBar-Be6SQ4g6.js";import{n as ce}from"./skeletons-BRDBm95C.js";import{n as le}from"./plugin-dashboard-CGRjBe2V.js";import{n as F,t as I}from"./DashboardWidgetInspector-CNmycNmj.js";var L=e(n(),1),R=i();function ue({open:e,onClose:t,schema:n,selectedWidgetId:r,onSelectWidget:i,onSave:a,onChange:o,onRemoveWidget:c,name:l,metadataClient:u,onAfterChange:d}){let{t:f}=s(),p=(0,L.useMemo)(()=>j(),[]),[m,h]=(0,L.useState)(!1),[g,_]=(0,L.useState)(0),v=(0,L.useCallback)(e=>{h(!0),o({...n??{},...e})},[n,o]),y=(0,L.useCallback)(e=>{o(e),h(!1)},[o]),x=(0,L.useCallback)(e=>{i(e&&e.kind===`widget`?e.id:null)},[i]),S=Array.isArray(n?.widgets)?n.widgets:[],w=r?S.find(e=>e?.id===r):null;if(!e)return null;let T=typeof n?.name==`string`?n.name:``,D=w?f(`widget.editor.title`,{defaultValue:`Edit widget`}):f(`dashboard.editor.title`,{defaultValue:`Edit dashboard`});return(0,R.jsxs)(`aside`,{className:`hidden sm:flex w-[440px] shrink-0 flex-col border-l bg-background h-full`,"data-testid":`dashboard-config-panel`,role:`complementary`,"aria-label":D,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b px-4 py-2.5 shrink-0`,children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[w&&(0,R.jsx)(E,{variant:`ghost`,size:`sm`,onClick:()=>i(null),className:`h-7 w-7 p-0`,"aria-label":f(`dashboard.editor.backToDashboard`,{defaultValue:`Back to dashboard`}),title:f(`dashboard.editor.backToDashboard`,{defaultValue:`Back to dashboard`}),"data-testid":`dashboard-config-back`,children:(0,R.jsx)(O,{className:`h-4 w-4`})}),(0,R.jsx)(`div`,{className:`text-sm font-medium truncate`,children:D})]}),(0,R.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[w&&c&&(0,R.jsx)(E,{variant:`ghost`,size:`sm`,onClick:()=>c(r),className:`h-7 w-7 p-0 text-destructive hover:text-destructive`,"aria-label":f(`widget.editor.delete`,{defaultValue:`Delete widget`}),title:f(`widget.editor.delete`,{defaultValue:`Delete widget`}),"data-testid":`widget-delete-button`,children:(0,R.jsx)(C,{className:`h-3.5 w-3.5`})}),(0,R.jsx)(E,{variant:`ghost`,size:`sm`,onClick:t,className:`h-7 w-7 p-0`,"aria-label":f(`common.close`,{defaultValue:`Close`}),"data-testid":`dashboard-config-close`,children:(0,R.jsx)(b,{className:`h-4 w-4`})})]})]}),(0,R.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto p-4`,children:w?(0,R.jsx)(I,{type:`dashboard`,name:T,draft:n??{},selection:{kind:`widget`,id:r},onPatch:v,onClearSelection:()=>i(null),onSelectionChange:x,readOnly:!1,locale:p}):(0,R.jsx)(F,{type:`dashboard`,name:T,draft:n??{},onPatch:v,onSelectionChange:x,readOnly:!1,locale:p})}),(0,R.jsxs)(`div`,{"data-testid":`dashboard-config-footer`,className:`flex items-center justify-end gap-2 border-t px-4 py-2.5 shrink-0`,children:[(0,R.jsx)(P,{type:`dashboard`,name:l||T||void 0,metadataClient:u,dirty:m,onResume:y,savedSignal:g,onAfterChange:d}),(0,R.jsx)(E,{size:`sm`,onClick:()=>{a(n??{}),h(!1),_(e=>e+1)},"data-testid":`dashboard-config-save`,children:f(`common.save`,{defaultValue:`Save`})})]})]})}var z=t({DashboardView:()=>U}),B=[{type:`metric`,label:`KPI Metric`,Icon:k},{type:`bar`,label:`Bar Chart`,Icon:D},{type:`line`,label:`Line Chart`,Icon:l},{type:`pie`,label:`Pie Chart`,Icon:d},{type:`table`,label:`Table`,Icon:g},{type:`pivot`,label:`Pivot`,Icon:v}],V=0;function H(){return V+=1,`widget_${Date.now()}_${V}`}function de(e){return!e.widgets?.length||!e.widgets.some(e=>!e.id)?e:{...e,widgets:e.widgets.map(e=>e.id?e:{...e,id:H()})}}function fe(e){let t=B.find(t=>t.type===e);return t?`New ${t.label}`:`New Widget`}function U({dataSource:e}){let{dashboardName:t}=r(),{showDebug:n}=ae(),i=c(),l=ie(),{t:d}=s(),{dashboardLabel:g,dashboardDescription:v}=T(),{user:b}=a(),C=b?.role===`admin`,[D,O]=(0,L.useState)(!0),[k,j]=(0,L.useState)(!1),[P,F]=(0,L.useState)(null),[I,z]=(0,L.useState)(null),V=(0,L.useCallback)(e=>{z(t=>(t&&t.resolve(e),null))},[]),U=(0,L.useCallback)(e=>new Promise(t=>{let n;if(typeof e==`string`){let t=e.match(/^(create|new|add|edit|update)_(.+)$/);if(t){let e=t[1];n={objectName:t[2],mode:e===`edit`||e===`update`?`edit`:`create`}}else n={objectName:e,mode:`create`}}else n=e;z({schema:n,resolve:t})}),[]),pe=(0,L.useMemo)(()=>({export_dashboard_pdf:async()=>{A.info(d(`dashboardActions.pdfPreparing`));try{return window.print(),{success:!0}}catch(e){return A.error(d(`dashboardActions.exportFailed`,{message:e?.message||String(e)})),{success:!1,error:e?.message||String(e)}}},forecast_dashboard:async()=>(A.info(d(`dashboardActions.forecastSoon`)),{success:!0})}),[d]);(0,L.useEffect)(()=>{O(!0),J(null),j(!1),F(null),queueMicrotask(()=>O(!1))},[t]);let{dashboards:me,objects:W,refresh:G}=o(),{app:he}=re(),K=oe(me,t,he?._packageId),[q,J]=(0,L.useState)(null);(0,L.useEffect)(()=>{k||J(null)},[K]);let Y=(0,L.useCallback)(async e=>{try{l&&await N(`dashboard`,t,e,{metadataClient:l}),G().catch(()=>{})}catch(e){let t=e instanceof Error?e.message:String(e);console.warn(`[DashboardView] Auto-save failed:`,e),A.error(`Failed to save dashboard: ${t}`)}},[l,t,G]),ge=(0,L.useCallback)(()=>{J(de(K)),j(!0)},[K]),_e=(0,L.useCallback)(()=>{j(!1),F(null)},[]),ve=(0,L.useCallback)(e=>{if(!q)return;let t=H(),n={id:t,title:fe(e),type:e,layout:{x:0,y:q.widgets?.length??0,w:q.columns??2,h:1}},r={...q,widgets:[...q.widgets||[],n]};J(r),Y(r),F(t)},[q,Y]),ye=(0,L.useCallback)(e=>{if(!q)return;let t={...q,widgets:q.widgets.filter(t=>t.id!==e)};J(t),Y(t),P===e&&F(null)},[q,P,Y]),X=(0,L.useCallback)(e=>{let t=q||K;if(!t)return;let n={...t,widgets:e};J(n),Y(n)},[q,K,Y]),be=(q||K)??null,Z=(0,L.useMemo)(()=>new Set((W||[]).map(e=>e?.name).filter(Boolean)),[W]),Q=q||K,$=(0,L.useMemo)(()=>{if(!Q||Z.size===0)return Q;let e=Q.widgets;if(!Array.isArray(e)||e.length===0)return Q;let t=e.filter(e=>{let t=e?.requiresObject??e?.object;return t?Z.has(t):!0});return t.length===e.length?Q:{...Q,widgets:t}},[Q,Z]);return D?(0,R.jsx)(ce,{}):K?(0,R.jsxs)(`div`,{className:`flex flex-col h-full overflow-hidden bg-background`,children:[(0,R.jsxs)(`div`,{className:`flex flex-col sm:flex-row justify-between sm:items-center gap-3 sm:gap-4 p-4 sm:p-6 border-b shrink-0`,children:[(0,R.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(()=>{let e=M(($||K).title,d),t=M(K.label,d),n=g({name:K.name,label:t});return(0,R.jsx)(`h1`,{className:`text-lg sm:text-xl md:text-2xl font-bold tracking-tight truncate`,children:e||n||K.name})})(),(()=>{let e=($||K).description??K.description,t=v({name:K.name,description:M(e,d)});return t?(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1 line-clamp-2`,children:t}):null})()]}),(0,R.jsxs)(`div`,{className:`shrink-0 flex items-center gap-1.5`,children:[k&&(0,R.jsx)(`div`,{className:`flex items-center gap-1 mr-2`,role:`toolbar`,"aria-label":`Add widgets`,"data-testid":`dashboard-widget-toolbar`,children:B.map(({type:e,label:t,Icon:n})=>(0,R.jsxs)(`button`,{type:`button`,"data-testid":`dashboard-add-${e}`,onClick:()=>ve(e),className:`inline-flex items-center gap-1 rounded-md border border-input bg-background px-2 py-1.5 text-[11px] font-medium text-muted-foreground hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,title:`Add ${t}`,"aria-label":`Add ${t} widget`,children:[(0,R.jsx)(p,{className:`h-3 w-3`}),(0,R.jsx)(n,{className:`h-3 w-3`})]},e))}),C&&(0,R.jsxs)(`button`,{type:`button`,onClick:ge,className:`inline-flex items-center gap-1.5 rounded-md border border-input bg-background px-2.5 py-1.5 text-xs font-medium text-muted-foreground shadow-sm hover:bg-accent hover:text-accent-foreground`,"data-testid":`dashboard-edit-button`,children:[(0,R.jsx)(w,{className:`h-3.5 w-3.5`}),d(`common.edit`,{defaultValue:`Edit`})]})]})]}),(0,R.jsxs)(`div`,{className:`flex-1 overflow-hidden flex flex-col sm:flex-row relative`,children:[(0,R.jsx)(`div`,{className:`flex-1 min-w-0 overflow-auto p-2 sm:p-4 md:p-6`,children:(0,R.jsx)(le,{schema:$,dataSource:e,designMode:k,selectedWidgetId:P,onWidgetClick:F,onWidgetsReorder:X,modalHandler:U,scriptHandlers:pe,hideHeaderText:!0})}),(0,R.jsx)(ue,{open:k&&C,onClose:_e,schema:be,selectedWidgetId:P,onSelectWidget:F,onSave:Y,onChange:J,onRemoveWidget:ye,name:t,metadataClient:l,onAfterChange:()=>G().catch(()=>{})}),(0,R.jsx)(se,{open:n,sections:[{title:`Dashboard Configuration`,data:$}]})]}),I&&I.schema?.objectName?(0,R.jsx)(ne,{schema:{type:`object-form`,formType:`modal`,objectName:I.schema.objectName,mode:I.schema.mode||`create`,recordId:I.schema.recordId,title:I.schema.title,description:I.schema.description,fields:I.schema.fields,open:!0,onOpenChange:e=>{e||V({success:!1})},onSuccess:e=>{V({success:!0,reload:!0,data:e})},onCancel:()=>{V({success:!1})},showSubmit:!0,showCancel:!0},dataSource:i}):I?(0,R.jsx)(h,{open:!0,onOpenChange:e=>{e||V({success:!1})},children:(0,R.jsxs)(y,{children:[(0,R.jsxs)(S,{children:[(0,R.jsx)(m,{children:I.schema?.title||d(`actionDialog.defaultActionTitle`)}),I.schema?.description&&(0,R.jsx)(te,{children:I.schema.description})]}),(0,R.jsxs)(u,{children:[(0,R.jsx)(E,{variant:`outline`,onClick:()=>V({success:!1}),children:d(`actionDialog.cancel`)}),(0,R.jsx)(E,{onClick:()=>V({success:!0}),children:d(`actionDialog.ok`)})]})]})}):null]}):(0,R.jsx)(`div`,{className:`h-full flex items-center justify-center p-8`,children:(0,R.jsxs)(_,{children:[(0,R.jsx)(`div`,{className:`mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-muted`,children:(0,R.jsx)(x,{className:`h-6 w-6 text-muted-foreground`})}),(0,R.jsx)(f,{children:d(`empty.dashboardNotFound`)}),(0,R.jsx)(ee,{children:d(`empty.dashboardNotFoundDescription`,{name:t})})]})})}export{z as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,t as n}from"./vendor-react-DR370ovB.js";import{w as r}from"./framework-ZJouI0cJ.js";import{$n as i,Ft as a,Gt as o,It as s,Jn as c,Lt as l,Mt as u,Pi as d,Pt as f,Rt as p,Wi as m,Xn as h,Yn as g,Zn as _,_s as v,ct as y,dt as b,ft as x,hr as S,hs as C,ja as w,lt as T,nn as E,ns as D,on as O,ot as k,qn as A,ss as j,st as M,tt as N,ut as P,wr as F}from"./ui-components-Bs-DxYrW.js";import"./index-B99f8h8i.js";var I=e(t(),1),L=n();function R({status:e}){let t={success:{icon:C,cls:`text-emerald-600 border-emerald-300`},completed:{icon:C,cls:`text-emerald-600 border-emerald-300`},failed:{icon:j,cls:`text-red-600 border-red-300`},error:{icon:j,cls:`text-red-600 border-red-300`},running:{icon:w,cls:`text-blue-600 border-blue-300 animate-pulse`},pending:{icon:D,cls:`text-amber-600 border-amber-300`},skipped:{icon:v,cls:`text-muted-foreground`}}[e]??{icon:v,cls:`text-muted-foreground`},n=t.icon;return(0,L.jsxs)(i,{variant:`outline`,className:`text-[10px] font-mono inline-flex items-center gap-1 ${t.cls}`,children:[(0,L.jsx)(n,{className:`h-3 w-3`}),e]})}function z(e){if(!e)return`—`;try{return new Date(e).toLocaleString()}catch{return e}}function B(e,t){switch(t){case`number`:{if(e===``)return;let t=Number(e);return Number.isNaN(t)?e:t}case`boolean`:return e===`true`;case`object`:case`list`:case`array`:if(e.trim()===``)return;try{return JSON.parse(e)}catch{return e}default:return e}}function V({data:e}){return(0,L.jsx)(`pre`,{className:`rounded border bg-muted/30 p-2 text-xs font-mono overflow-auto whitespace-pre-wrap break-all max-h-96`,children:JSON.stringify(e,null,2)})}function H(){let e=r()?.getClient?.(),[t,n]=(0,I.useState)([]),[i,a]=(0,I.useState)(!0),[o,s]=(0,I.useState)(null),[l,f]=(0,I.useState)(``),[p,m]=(0,I.useState)(0),v=(0,I.useCallback)(async()=>{if(!e?.meta?.getItems){s(`meta.getItems is not available on this client`),a(!1);return}a(!0),s(null);try{let t=await e.meta.getItems(`flow`),r=(Array.isArray(t)?t:Array.isArray(t?.items)?t.items:Array.isArray(t?.value)?t.value:[]).map(e=>({name:e?.spec?.name??e?.name,label:e?.spec?.label,spec:e?.spec??e,updatedAt:e?.updatedAt??e?.updated_at})).filter(e=>e.name);n(r),!l&&r.length>0&&f(r[0].name)}catch(e){s(e?.message??String(e))}finally{a(!1)}},[e,l]);(0,I.useEffect)(()=>{v()},[v]);let y=(0,I.useMemo)(()=>t.find(e=>e.name===l)??null,[t,l]);return(0,L.jsxs)(`div`,{className:`flex flex-col gap-4 p-4 sm:p-6`,children:[(0,L.jsxs)(`div`,{className:`min-w-0`,children:[(0,L.jsxs)(`h1`,{className:`text-xl sm:text-2xl font-bold tracking-tight flex items-center gap-2`,children:[(0,L.jsx)(F,{className:`h-5 w-5`}),`Flow Runs`]}),(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:`Pick a flow, trigger a test run with sample inputs, and inspect recent run history`})]}),(0,L.jsxs)(A,{children:[(0,L.jsx)(h,{className:`pb-3`,children:(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(_,{className:`text-base`,children:`Flow`}),(0,L.jsx)(g,{children:`Select a flow definition to test`})]}),(0,L.jsxs)(S,{variant:`outline`,size:`sm`,onClick:v,disabled:i,children:[(0,L.jsx)(d,{className:`h-3.5 w-3.5 mr-2 ${i?`animate-spin`:``}`}),`Refresh`]})]})}),(0,L.jsxs)(c,{children:[i&&(0,L.jsx)(u,{className:`h-9 w-72`}),o&&(0,L.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:o}),!i&&!o&&t.length===0&&(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No flow definitions found.`}),!i&&!o&&t.length>0&&(0,L.jsx)(`select`,{value:l,onChange:e=>f(e.target.value),className:`flex h-9 w-full max-w-md rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm focus:outline-none focus:ring-1 focus:ring-ring`,children:t.map(e=>(0,L.jsx)(`option`,{value:e.name,children:e.label?`${e.label} (${e.name})`:e.name},e.name))})]})]}),y&&(0,L.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,L.jsx)(U,{client:e,flow:y.spec,onExecuted:()=>m(e=>e+1)}),(0,L.jsx)(W,{client:e,flowName:y.name,refreshKey:p})]})]})}function U({client:e,flow:t,onExecuted:n}){let r=(0,I.useMemo)(()=>(t?.variables??[]).filter(e=>e?.isInput),[t]),[a,o]=(0,I.useState)({}),[s,l]=(0,I.useState)(!1),[u,d]=(0,I.useState)(null),[f,p]=(0,I.useState)(null);(0,I.useEffect)(()=>{o({}),d(null),p(null)},[t?.name]);let v=(e,t)=>o(n=>({...n,[e]:t}));return(0,L.jsxs)(A,{children:[(0,L.jsxs)(h,{className:`pb-3`,children:[(0,L.jsx)(_,{className:`text-base`,children:`Test Run`}),(0,L.jsx)(g,{children:`Provide input values and invoke the flow`})]}),(0,L.jsxs)(c,{className:`space-y-3`,children:[r.length===0&&(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`This flow declares no input variables. Click Run to invoke with no parameters.`}),r.map(e=>(0,L.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,L.jsxs)(O,{htmlFor:`var-${e.name}`,className:`flex items-center gap-2`,children:[(0,L.jsx)(`span`,{className:`font-mono text-xs`,children:e.name}),(0,L.jsx)(i,{variant:`outline`,className:`text-[10px] font-mono`,children:e.type})]}),e.type===`boolean`?(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(x,{id:`var-${e.name}`,checked:a[e.name]===`true`,onCheckedChange:t=>v(e.name,t?`true`:`false`)}),(0,L.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:a[e.name]===`true`?`true`:`false`})]}):e.type===`object`||e.type===`list`||e.type===`array`?(0,L.jsx)(N,{id:`var-${e.name}`,placeholder:`JSON ${e.type}`,value:a[e.name]??``,onChange:t=>v(e.name,t.target.value),className:`font-mono text-xs min-h-[80px]`}):(0,L.jsx)(E,{id:`var-${e.name}`,type:e.type===`number`?`number`:`text`,value:a[e.name]??``,onChange:t=>v(e.name,t.target.value)})]},e.name)),(0,L.jsx)(`div`,{className:`pt-1`,children:(0,L.jsxs)(S,{onClick:async()=>{if(!e?.automation?.execute){p(`automation.execute is not available on this client`);return}l(!0),p(null),d(null);try{let i={};for(let e of r){let t=a[e.name];t!==void 0&&(i[e.name]=B(t,e.type))}d(await e.automation.execute(t.name,{params:i})),n?.()}catch(e){p(e?.message??String(e))}finally{l(!1)}},disabled:s,size:`sm`,children:[s?(0,L.jsx)(w,{className:`h-3.5 w-3.5 mr-2 animate-spin`}):(0,L.jsx)(m,{className:`h-3.5 w-3.5 mr-2`}),s?`Running…`:`Run Flow`]})}),(u||f)&&(0,L.jsxs)(`div`,{className:`pt-2 border-t mt-2 space-y-2`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium`,children:[f||u?.success===!1?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(j,{className:`h-4 w-4 text-red-500`}),` Failed`]}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(C,{className:`h-4 w-4 text-emerald-500`}),` Result`]}),typeof u?.durationMs==`number`&&(0,L.jsxs)(i,{variant:`secondary`,className:`text-[10px] font-mono`,children:[u.durationMs,` ms`]})]}),f&&(0,L.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:f}),u&&(0,L.jsx)(V,{data:u})]})]})]})}function W({client:e,flowName:t,refreshKey:n}){let[r,m]=(0,I.useState)([]),[v,x]=(0,I.useState)(!0),[C,E]=(0,I.useState)(null),[D,O]=(0,I.useState)(null),[j,N]=(0,I.useState)(null),[F,B]=(0,I.useState)(!1),[H,U]=(0,I.useState)(null),W=(0,I.useCallback)(async()=>{if(!e?.automation?.listRuns){E(`automation.listRuns is not available on this client`),x(!1);return}x(!0),E(null);try{let n=await e.automation.listRuns(t,{limit:20});m(Array.isArray(n)?n:n?.items??n?.runs??[])}catch(e){E(e?.message??String(e))}finally{x(!1)}},[e,t]);(0,I.useEffect)(()=>{W()},[W,n]);let G=async n=>{O(n),N(null),U(null),B(!0);try{let r=await e.automation.getRun(t,n);N(r?.run??r)}catch(e){U(e?.message??String(e))}finally{B(!1)}};return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(A,{children:[(0,L.jsx)(h,{className:`pb-3`,children:(0,L.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(_,{className:`text-base`,children:`Recent Runs`}),(0,L.jsx)(g,{className:`font-mono text-xs`,children:t})]}),(0,L.jsxs)(S,{variant:`outline`,size:`sm`,onClick:W,disabled:v,children:[v?(0,L.jsx)(w,{className:`h-3.5 w-3.5 mr-2 animate-spin`}):(0,L.jsx)(d,{className:`h-3.5 w-3.5 mr-2`}),`Refresh`]})]})}),(0,L.jsxs)(c,{children:[v&&(0,L.jsxs)(`div`,{className:`space-y-2`,children:[(0,L.jsx)(u,{className:`h-8 w-full`}),(0,L.jsx)(u,{className:`h-8 w-full`}),(0,L.jsx)(u,{className:`h-8 w-full`})]}),!v&&C&&(0,L.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:C}),!v&&!C&&r.length===0&&(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground py-6 text-center`,children:`No runs yet. Use the Test Run panel to invoke this flow.`}),!v&&!C&&r.length>0&&(0,L.jsxs)(k,{children:[(0,L.jsx)(P,{children:(0,L.jsxs)(b,{children:[(0,L.jsx)(T,{children:`Run`}),(0,L.jsx)(T,{children:`Status`}),(0,L.jsx)(T,{children:`Started`}),(0,L.jsx)(T,{className:`text-right`,children:`Duration`})]})}),(0,L.jsx)(M,{children:r.map(e=>(0,L.jsxs)(b,{className:`cursor-pointer`,onClick:()=>G(e.id),children:[(0,L.jsxs)(y,{className:`font-mono text-xs`,children:[e.id.slice(0,12),`…`]}),(0,L.jsx)(y,{children:(0,L.jsx)(R,{status:e.status})}),(0,L.jsx)(y,{className:`text-xs text-muted-foreground`,children:z(e.startedAt)}),(0,L.jsx)(y,{className:`text-right font-mono text-xs`,children:typeof e.durationMs==`number`?`${e.durationMs} ms`:`—`})]},e.id))})]})]})]}),(0,L.jsx)(f,{open:!!D,onOpenChange:e=>{e||(O(null),N(null))},children:(0,L.jsxs)(a,{side:`right`,className:`w-full sm:max-w-2xl p-0 flex flex-col`,children:[(0,L.jsxs)(l,{className:`p-4 border-b`,children:[(0,L.jsxs)(p,{className:`font-mono text-sm break-all`,children:[`Run `,D]}),(0,L.jsx)(s,{children:j&&(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,L.jsx)(R,{status:j.status}),typeof j.durationMs==`number`&&(0,L.jsxs)(i,{variant:`secondary`,className:`text-[10px] font-mono`,children:[j.durationMs,` ms`]}),(0,L.jsx)(`span`,{className:`text-xs`,children:z(j.startedAt)})]})})]}),(0,L.jsxs)(o,{className:`flex-1 p-4`,children:[F&&(0,L.jsxs)(`div`,{className:`space-y-2`,children:[(0,L.jsx)(u,{className:`h-16 w-full`}),(0,L.jsx)(u,{className:`h-16 w-full`}),(0,L.jsx)(u,{className:`h-16 w-full`})]}),H&&(0,L.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:H}),!F&&j&&(0,L.jsx)(`div`,{className:`space-y-3`,children:Array.isArray(j.steps)&&j.steps.length>0?j.steps.map((e,t)=>(0,L.jsxs)(`div`,{className:`rounded-md border p-3 space-y-2`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,L.jsxs)(`span`,{className:`text-muted-foreground font-mono text-xs`,children:[`#`,t+1]}),(0,L.jsx)(`span`,{className:`font-mono text-sm font-medium`,children:e.nodeLabel||e.nodeId}),e.nodeType&&(0,L.jsx)(i,{variant:`outline`,className:`text-[10px] font-mono`,children:e.nodeType}),(0,L.jsx)(R,{status:e.status}),typeof e.durationMs==`number`&&(0,L.jsxs)(i,{variant:`secondary`,className:`text-[10px] font-mono ml-auto`,children:[e.durationMs,` ms`]})]}),e.input!==void 0&&(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`div`,{className:`text-[10px] uppercase text-muted-foreground mb-1`,children:`Input`}),(0,L.jsx)(V,{data:e.input})]}),e.output!==void 0&&(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`div`,{className:`text-[10px] uppercase text-muted-foreground mb-1`,children:`Output`}),(0,L.jsx)(V,{data:e.output})]}),e.error&&(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`div`,{className:`text-[10px] uppercase text-red-500 mb-1`,children:`Error`}),(0,L.jsx)(V,{data:e.error})]})]},`${e.nodeId}-${t}`)):(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`div`,{className:`text-[10px] uppercase text-muted-foreground mb-1`,children:`Run`}),(0,L.jsx)(V,{data:j})]})})]})]})})]})}export{H as FlowRunsPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as e,r as t}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as n,f as r,t as i,u as a}from"./vendor-react-DR370ovB.js";import{d as o}from"./infrastructure-CJNwTVno.js";import{ht as s,r as c}from"./framework-ZJouI0cJ.js";import{$n as l,Fi as u,Fo as d,Jn as f,Mt as p,Vr as m,Xn as h,Zn as g,_s as _,ei as v,hr as y,qn as b,rc as x}from"./ui-components-Bs-DxYrW.js";import{_ as S,c as C,g as w,l as T}from"./marketplaceApi-DCvJ2C6u.js";var E=e(n(),1),D=i();function O(){let e=a(),{appName:t}=r(),n=o(),{t:i,language:s}=c(),v=t?`/apps/${t}`:``,[x,O]=(0,E.useState)([]),[k,A]=(0,E.useState)(`local`),[j,M]=(0,E.useState)(!0),[N,P]=(0,E.useState)(null),[F,I]=(0,E.useState)(null),L=async()=>{M(!0);try{let e=await C();e.connected?(A(`cloud`),O(e.items)):(A(`local`),O(await T()))}finally{M(!1)}};(0,E.useEffect)(()=>{L()},[]);let R=async e=>{if(confirm(i(`marketplace.uninstall.confirm`,{manifestId:e.manifestId,version:e.version}))){P(e.manifestId),I(null);try{await w(e.manifestId),I({ok:!0,message:i(`marketplace.uninstall.successInList`,{manifestId:e.manifestId})}),await L()}catch(e){I({ok:!1,message:e?.message??String(e)})}finally{P(null)}}};return n?(0,D.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,D.jsx)(`div`,{className:`flex justify-end`,children:(0,D.jsxs)(y,{variant:`outline`,size:`sm`,onClick:()=>void L(),disabled:j,children:[(0,D.jsx)(u,{className:`h-4 w-4 mr-1.5`,"aria-hidden":`true`}),i(`marketplace.refresh`)]})}),F&&(0,D.jsx)(`div`,{className:`rounded-md border p-3 text-sm ${F.ok?`border-green-500/30 bg-green-500/5 text-green-700 dark:text-green-400`:`border-destructive/30 bg-destructive/5 text-destructive`}`,children:(0,D.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,D.jsx)(_,{className:`h-4 w-4 mt-0.5 shrink-0`,"aria-hidden":`true`}),(0,D.jsx)(`div`,{children:F.message})]})}),j&&x.length===0?(0,D.jsx)(`div`,{className:`grid gap-3`,children:Array.from({length:3}).map((e,t)=>(0,D.jsx)(p,{className:`h-20 w-full`},t))}):x.length===0?(0,D.jsxs)(`div`,{className:`text-center py-12 text-sm text-muted-foreground border rounded-md`,children:[(0,D.jsx)(`p`,{children:i(`marketplace.installedEmpty`)}),(0,D.jsx)(y,{variant:`link`,className:`mt-2`,onClick:()=>e(`${v}/system/marketplace`),children:i(`marketplace.browseLink`)})]}):(0,D.jsx)(`div`,{className:`grid gap-3`,children:x.map(t=>(0,D.jsxs)(b,{children:[(0,D.jsxs)(h,{className:`flex flex-row items-start justify-between gap-3 pb-2`,children:[(0,D.jsxs)(`div`,{className:`min-w-0`,children:[(0,D.jsxs)(g,{className:`text-base truncate flex items-center gap-2`,children:[t.manifestId,(0,D.jsx)(l,{variant:`outline`,children:i(`marketplace.versionBadge`,{version:t.version})})]}),(0,D.jsxs)(`div`,{className:`text-xs text-muted-foreground mt-1 flex flex-wrap gap-x-3 gap-y-1`,children:[(0,D.jsx)(`span`,{children:i(`marketplace.installedAt`,{when:new Date(t.installedAt).toLocaleString(s||void 0)})}),t.installedBy&&(0,D.jsx)(`span`,{children:i(`marketplace.installedBy`,{user:t.installedBy})}),(0,D.jsxs)(`span`,{children:[i(`marketplace.installedPackageId`),` `,(0,D.jsx)(`code`,{className:`font-mono`,children:t.packageId})]})]})]}),(0,D.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,D.jsxs)(y,{variant:`ghost`,size:`sm`,onClick:()=>e(`${v}/system/marketplace/${t.packageId}`),children:[(0,D.jsx)(d,{className:`h-4 w-4 mr-1.5`,"aria-hidden":`true`}),i(`marketplace.action.details`)]}),k===`local`&&(0,D.jsxs)(y,{variant:`outline`,size:`sm`,onClick:()=>void R(t),disabled:N===t.manifestId,children:[(0,D.jsx)(m,{className:`h-4 w-4 mr-1.5`,"aria-hidden":`true`}),N===t.manifestId?i(`marketplace.action.uninstalling`):i(`marketplace.action.uninstall`)]})]})]}),k===`local`&&(0,D.jsx)(f,{className:`pt-0 text-xs text-muted-foreground`,dangerouslySetInnerHTML:{__html:i(`marketplace.cachedAs`,{path:`.objectstack/installed-packages/${t.manifestId.replace(/[^a-zA-Z0-9._-]/g,`_`)}.json`})}})]},t.manifestId))}),(0,D.jsx)(`p`,{className:`text-xs text-muted-foreground border-t pt-4`,dangerouslySetInnerHTML:{__html:i(`marketplace.installedAdditiveNote`)}})]}):(0,D.jsx)(S,{})}s.register(`marketplace:installed-list`,()=>(0,D.jsx)(O,{}),{namespace:`app-shell`,label:`Installed Marketplace Packages`,category:`plugin`,inputs:[]});var k=t({MarketplaceInstalledPage:()=>A});function A(){let e=a(),{appName:t}=r(),{t:n}=c(),i=t?`/apps/${t}`:``;return(0,D.jsxs)(`div`,{className:`flex flex-col gap-6 p-4 sm:p-6 max-w-5xl`,children:[(0,D.jsxs)(y,{variant:`ghost`,size:`sm`,className:`self-start`,onClick:()=>e(`${i}/system/marketplace`),children:[(0,D.jsx)(x,{className:`h-4 w-4 mr-1.5`,"aria-hidden":`true`}),n(`marketplace.back`)]}),(0,D.jsxs)(`div`,{children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,D.jsx)(v,{className:`h-6 w-6 text-primary`,"aria-hidden":`true`}),(0,D.jsx)(`h1`,{className:`text-xl sm:text-2xl font-bold tracking-tight`,children:n(`marketplace.installedTitle`)})]}),(0,D.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,dangerouslySetInnerHTML:{__html:n(`marketplace.installedSubtitle`)}})]}),(0,D.jsx)(O,{})]})}export{k as t};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{o as e,r as t}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as n,f as r,t as i,u as a}from"./vendor-react-DR370ovB.js";import{d as ee}from"./infrastructure-CJNwTVno.js";import{T as te,r as ne}from"./framework-ZJouI0cJ.js";import{$n as o,Bn as re,Bs as s,Bt as ie,Er as c,Fo as ae,Hn as oe,Ht as se,Io as ce,Jn as le,Kn as l,Ln as ue,Mt as u,Qo as d,Rn as de,Uo as fe,Ut as pe,Vn as me,Vr as f,Vt as he,Wt as ge,Xn as _e,Zn as ve,_i as p,_s as m,cn as ye,da as h,gi as be,gn as xe,hr as g,hs as _,ja as v,la as Se,mo as Ce,on as y,qn as we,rc as Te,sn as Ee,un as b,zn as De,zo as Oe}from"./ui-components-Bs-DxYrW.js";import"./MetadataProvider-BagIop6q.js";import{i as x}from"./runtime-config-BeHVOPm3.js";import{n as ke,t as Ae}from"./usePackageL10n-shLsxEAx.js";import{_ as je,a as Me,f as Ne,g as Pe,h as Fe,i as Ie,l as Le,m as Re,n as ze,o as Be,p as Ve,r as He,s as Ue,t as We}from"./marketplaceApi-DCvJ2C6u.js";var S=e(n(),1),C=i();function w(e){let t=e.replace(/\r\n/g,`
|
|
2
|
-
`).split(`
|
|
3
|
-
`),n=[],r=0;for(;r<t.length;){let e=t[r];if(e.startsWith("```")){let i=e.slice(3).trim();r++;let a=[];for(;r<t.length&&!t[r].startsWith("```");)a.push(t[r]),r++;r++,n.push({type:`code`,text:a.join(`
|
|
4
|
-
`),lang:i});continue}let i=/^(#{1,3})\s+(.*)$/.exec(e);if(i){let e=i[1].length;n.push({type:`h${e}`,text:i[2].trim()}),r++;continue}if(/^[-*]\s+/.test(e)){let e=[];for(;r<t.length&&/^[-*]\s+/.test(t[r]);)e.push(t[r].replace(/^[-*]\s+/,``)),r++;n.push({type:`ul`,items:e});continue}if(/^\d+\.\s+/.test(e)){let e=[];for(;r<t.length&&/^\d+\.\s+/.test(t[r]);)e.push(t[r].replace(/^\d+\.\s+/,``)),r++;n.push({type:`ol`,items:e});continue}if(!e.trim()){r++;continue}let a=[];for(;r<t.length&&t[r].trim()&&!/^#{1,3}\s+/.test(t[r])&&!/^[-*]\s+/.test(t[r])&&!/^\d+\.\s+/.test(t[r])&&!t[r].startsWith("```");)a.push(t[r]),r++;n.push({type:`p`,text:a.join(` `)})}return n}function T(e){let t=[],n=e,r=0,i=[{re:/`([^`]+)`/,render:e=>(0,C.jsx)(`code`,{className:`rounded bg-muted px-1.5 py-0.5 font-mono text-[0.85em]`,children:e[1]},`k${r++}`)},{re:/\*\*([^*]+)\*\*/,render:e=>(0,C.jsx)(`strong`,{className:`font-semibold text-foreground`,children:e[1]},`k${r++}`)},{re:/\*([^*]+)\*/,render:e=>(0,C.jsx)(`em`,{children:e[1]},`k${r++}`)},{re:/\[([^\]]+)\]\(([^)]+)\)/,render:e=>(0,C.jsx)(`a`,{href:e[2],target:`_blank`,rel:`noopener noreferrer`,className:`text-violet-600 underline-offset-2 hover:underline dark:text-violet-400`,children:e[1]},`k${r++}`)}];for(;n;){let e=-1,r=null,a=null;for(let t of i){let i=t.re.exec(n);i&&(e===-1||i.index<e)&&(e=i.index,r=i,a=t)}if(!r||!a){t.push(n);break}e>0&&t.push(n.slice(0,e)),t.push(a.render(r)),n=n.slice(e+r[0].length)}return(0,C.jsx)(C.Fragment,{children:t.map((e,t)=>(0,C.jsx)(S.Fragment,{children:e},t))})}function Ge({source:e,className:t}){let n=w(e);return(0,C.jsx)(`div`,{className:`flex flex-col gap-4 text-sm leading-relaxed text-foreground/90 ${t??``}`,children:n.map((e,t)=>{switch(e.type){case`h1`:return(0,C.jsx)(`h2`,{className:`mt-2 text-xl font-bold tracking-tight`,children:T(e.text??``)},t);case`h2`:return(0,C.jsx)(`h3`,{className:`mt-3 text-base font-semibold tracking-tight`,children:T(e.text??``)},t);case`h3`:return(0,C.jsx)(`h4`,{className:`mt-2 text-sm font-semibold tracking-tight text-foreground/80`,children:T(e.text??``)},t);case`p`:return(0,C.jsx)(`p`,{children:T(e.text??``)},t);case`ul`:return(0,C.jsx)(`ul`,{className:`ml-1 flex list-none flex-col gap-1.5`,children:(e.items??[]).map((e,t)=>(0,C.jsxs)(`li`,{className:`flex gap-2`,children:[(0,C.jsx)(`span`,{"aria-hidden":`true`,className:`mt-1.5 inline-block h-1.5 w-1.5 shrink-0 rounded-full bg-violet-500/70`}),(0,C.jsx)(`span`,{children:T(e)})]},t))},t);case`ol`:return(0,C.jsx)(`ol`,{className:`ml-5 flex list-decimal flex-col gap-1.5 marker:text-muted-foreground`,children:(e.items??[]).map((e,t)=>(0,C.jsx)(`li`,{className:`pl-1`,children:T(e)},t))},t);case`code`:return(0,C.jsx)(`pre`,{className:`overflow-x-auto rounded-lg border bg-muted/40 p-3 text-xs leading-relaxed`,children:(0,C.jsx)(`code`,{className:`font-mono`,children:e.text})},t)}return null})})}var E={node:`In-process · full trust`,sandbox:`Sandboxed`,worker:`Out-of-process`};function D({icon:e,label:t,items:n}){return!n||n.length===0?null:(0,C.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,C.jsx)(e,{className:`h-3.5 w-3.5 mt-0.5 text-muted-foreground shrink-0`,"aria-hidden":`true`}),(0,C.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,C.jsx)(`div`,{className:`text-xs font-medium`,children:t}),(0,C.jsx)(`div`,{className:`flex flex-wrap gap-1 mt-0.5`,children:n.map(e=>(0,C.jsx)(`code`,{className:`font-mono text-[11px] px-1 py-0.5 rounded bg-muted break-all`,children:e},e))})]})]})}function Ke({version:e}){let{t}=ne();if(!e?.contains_code)return null;let n=e.permissions??{},r=(n.services?.length??0)+(n.hooks?.length??0)+(n.network?.length??0)+(n.fs?.length??0)>0;return(0,C.jsxs)(`div`,{className:`rounded-md border border-amber-500/30 bg-amber-500/5 p-3 space-y-3 text-sm`,children:[(0,C.jsxs)(`div`,{className:`flex items-center gap-2 font-medium`,children:[(0,C.jsx)(d,{className:`h-4 w-4 text-amber-600 shrink-0`,"aria-hidden":`true`}),t(`marketplace.disclosure.containsCode`,{defaultValue:`This package contains code`})]}),(0,C.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[e.runtime&&(0,C.jsx)(o,{variant:`outline`,children:t(`marketplace.disclosure.runtime.${e.runtime}`,{defaultValue:E[e.runtime]??e.runtime})}),e.platform_verified?(0,C.jsxs)(o,{variant:`outline`,className:`gap-1 border-green-500/40 text-green-700 dark:text-green-400`,children:[(0,C.jsx)(be,{className:`h-3 w-3`,"aria-hidden":`true`}),t(`marketplace.disclosure.reviewed`,{defaultValue:`Reviewed & approved`})]}):(0,C.jsxs)(o,{variant:`outline`,className:`gap-1 border-amber-500/40 text-amber-700 dark:text-amber-400`,children:[(0,C.jsx)(p,{className:`h-3 w-3`,"aria-hidden":`true`}),t(`marketplace.disclosure.unreviewed`,{defaultValue:`Not yet reviewed`})]}),e.signed&&(0,C.jsxs)(o,{variant:`outline`,className:`gap-1`,children:[(0,C.jsx)(_,{className:`h-3 w-3`,"aria-hidden":`true`}),t(`marketplace.disclosure.signed`,{defaultValue:`Signed`})]})]}),r?(0,C.jsxs)(`div`,{className:`space-y-2`,children:[(0,C.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:t(`marketplace.disclosure.grantsIntro`,{defaultValue:`On install, this package will be granted:`})}),(0,C.jsx)(D,{icon:s,label:t(`marketplace.disclosure.services`,{defaultValue:`Platform services`}),items:n.services??void 0}),(0,C.jsx)(D,{icon:c,label:t(`marketplace.disclosure.hooks`,{defaultValue:`Lifecycle hooks`}),items:n.hooks??void 0}),(0,C.jsx)(D,{icon:h,label:t(`marketplace.disclosure.network`,{defaultValue:`Network access`}),items:n.network??void 0}),(0,C.jsx)(D,{icon:Ce,label:t(`marketplace.disclosure.fs`,{defaultValue:`Filesystem access`}),items:n.fs??void 0})]}):(0,C.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:t(`marketplace.disclosure.noPermissions`,{defaultValue:`Requests no special permissions.`})})]})}var O=t({MarketplacePackagePage:()=>k});function k(){let e=a(),{packageId:t,appName:n}=r(),i=ee(),{t:s,language:c}=ne(),d=n?`/apps/${n}`:``,{refresh:p}=te(),[h,be]=(0,S.useState)(null),[Ce,w]=(0,S.useState)(!0),[T,E]=(0,S.useState)(null),[D,O]=(0,S.useState)(!1),[k,qe]=(0,S.useState)([]),[Je,A]=(0,S.useState)(!1),[j,M]=(0,S.useState)(null),[N,P]=(0,S.useState)(``),[F,Ye]=(0,S.useState)(!1),[Xe,Ze]=(0,S.useState)(!1),[I,Qe]=(0,S.useState)(!1),[L,R]=(0,S.useState)(null),[z,$e]=(0,S.useState)(null),[B,V]=(0,S.useState)(null),[H,U]=(0,S.useState)(null),[W,G]=(0,S.useState)(null),[et,K]=(0,S.useState)([]),[q,J]=(0,S.useState)(!1),[Y,X]=(0,S.useState)(null);(0,S.useEffect)(()=>{if(!x().features.installLocal)return;let e=!1;return(async()=>{let t=await Le();e||K(t)})(),()=>{e=!0}},[t,Y]),(0,S.useEffect)(()=>{if(!t)return;let e=x().defaultEnvironmentId??``,n=!1;return(async()=>{let r=await ze(t,e);n||!r||(V(r),$e(r.version))})(),()=>{n=!0}},[t]),(0,S.useEffect)(()=>{let e=!1;return(async()=>{if(t){w(!0),E(null);try{let n=await He(t);e||be(n)}catch(t){e||E(t?.message??String(t))}finally{e||w(!1)}}})(),()=>{e=!0}},[t]);let tt=async()=>{O(!0),R(null),M(null);let e=x().defaultEnvironmentId;if(e){A(!1),P(e),qe([]);return}A(!0);try{let[e,t]=await Promise.all([Be(),Ue()]),n=e.filter(e=>{let n=e.organization_id;return n?t.has(String(n)):!1});qe(n),e.length>0&&n.length===0?M(s(`marketplace.install.noPermission`)):n.length===1&&P(n[0].id)}catch(e){let t=e?.status;M(t===401||t===403?s(`marketplace.install.signInFirst`):e?.message??String(e))}finally{A(!1)}},nt=async()=>{if(!(!t||!N)){Qe(!0),R(null);try{$e(((await Me({packageId:t,environmentId:N,seedSampleData:F}))?.installation?.version??h?.package?.latest_version?.version??h?.versions?.[0]?.version??``)||`installed`);try{let e=x().defaultEnvironmentId||N;if(e){let n=await ze(t,e);n&&V(n)}}catch{}let e=x().defaultEnvironmentId;if(!e||e===N)try{if(typeof sessionStorage<`u`)for(let e of Object.keys(sessionStorage))e.startsWith(`objectui:metadata:`)&&sessionStorage.removeItem(e);await p()}catch{}R({ok:!0,message:s(`marketplace.install.success`)})}catch(e){R({ok:!1,message:e?.message??String(e)})}finally{Qe(!1)}}},rt=async()=>{if(t){J(!0),X(null);try{let e=await Ie({packageId:t});try{await p(`app`)}catch{}X({ok:!0,message:s(`marketplace.install.localSuccess`,{version:e.version,name:h?.package?Ae(h.package,c).displayName:e.manifestId})})}catch(e){let t=e?.code,n=e?.message??String(e);t===`manifest_conflict`?n=s(`marketplace.install.localManifestConflict`,{message:n}):t===`unauthorized`?n=s(`marketplace.install.localUnauthorized`):t===`marketplace_unavailable`&&(n=s(`marketplace.install.localMarketplaceUnavailable`)),X({ok:!1,message:n})}finally{J(!1)}}},it=async()=>{if($&&confirm(s(`marketplace.uninstall.confirm`,{manifestId:$.manifestId,version:$.version}))){J(!0),X(null);try{await Pe($.manifestId);try{await p(`app`)}catch{}X({ok:!0,message:s(`marketplace.uninstall.successInDetail`,{manifestId:$.manifestId})})}catch(e){X({ok:!1,message:e?.message??String(e)})}finally{J(!1)}}},at=async()=>{if(B){U(`reseed`),G(null);try{let e=await Fe(B.installationId);e.ok?(V({...B,withSampleData:!0}),G({ok:!0,text:s(`marketplace.detail.reseedQueued`)||`Sample data will be re-seeded on next environment access.`})):G({ok:!1,text:e.error||`Re-seed failed`})}finally{U(null)}}},ot=async()=>{if(B&&confirm(s(`marketplace.detail.purgeConfirm`)||`Delete all sample records seeded by this package? User-added records will NOT be touched.`)){U(`purge`),G(null);try{let e=await Ve(B.installationId);if(e.ok){V({...B,withSampleData:!1});let t=e.deleted??0;G({ok:!0,text:t>0?s(`marketplace.detail.purgeSuccess`,{count:t})||`Removed ${t} sample record(s).`:s(`marketplace.detail.purgeNoData`)||`No sample records found to purge.`})}else G({ok:!1,text:e.error||`Purge failed`})}finally{U(null)}}},st=async()=>{if($){U(`reseed`),G(null);try{let e=await Re($.manifestId);K(e=>e.map(e=>e.manifestId===$.manifestId?{...e,withSampleData:!0}:e));let t=e.inserted??0,n=e.updated??0;G({ok:!0,text:s(`marketplace.detail.reseedLocalSuccess`,{inserted:t,updated:n})||`Sample data re-seeded (inserted=${t}, updated=${n}).`})}catch(e){G({ok:!1,text:e?.message||`Re-seed failed`})}finally{U(null)}}},ct=async()=>{if($&&confirm(s(`marketplace.detail.purgeConfirm`)||`Delete all sample records seeded by this package? User-added records will NOT be touched.`)){U(`purge`),G(null);try{let e=await Ne($.manifestId);K(e=>e.map(e=>e.manifestId===$.manifestId?{...e,withSampleData:!1}:e));let t=e.deleted??0;G({ok:!0,text:t>0?s(`marketplace.detail.purgeSuccess`,{count:t})||`Removed ${t} sample record(s).`:s(`marketplace.detail.purgeNoData`)||`No sample records found to purge.`})}catch(e){G({ok:!1,text:e?.message||`Purge failed`})}finally{U(null)}}};if(Ce)return(0,C.jsxs)(`div`,{className:`mx-auto w-full max-w-6xl flex flex-col gap-6 p-4 sm:p-6`,children:[(0,C.jsx)(u,{className:`h-8 w-32`}),(0,C.jsx)(u,{className:`h-16 w-full`}),(0,C.jsx)(u,{className:`h-64 w-full`})]});if(T||!h)return(0,C.jsxs)(`div`,{className:`mx-auto w-full max-w-6xl flex flex-col gap-6 p-4 sm:p-6`,children:[(0,C.jsxs)(g,{variant:`ghost`,size:`sm`,onClick:()=>e(`${d}/system/marketplace`),children:[(0,C.jsx)(Te,{className:`h-4 w-4 mr-1.5`,"aria-hidden":`true`}),s(`marketplace.back`)]}),(0,C.jsxs)(`div`,{className:`flex items-start gap-3 rounded-md border border-destructive/30 bg-destructive/5 p-4 text-sm`,children:[(0,C.jsx)(m,{className:`h-4 w-4 mt-0.5 text-destructive`,"aria-hidden":`true`}),(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`div`,{className:`font-medium text-destructive`,children:s(`marketplace.load.packageFailed`)}),(0,C.jsx)(`div`,{className:`text-muted-foreground mt-1`,children:T??s(`marketplace.load.notFound`)})]})]})]});let Z=h.package,Q=Ae(Z,c),lt=Z.latest_version?.version??h.versions[0]?.version??null,$=et.find(e=>e.manifestId===Z.manifest_id)??null,ut=!!Z.latest_version?.contains_code,dt=x().features.installLocal,ft=!lt||q||I||!dt&&!!z,pt=dt?{label:s(q?`marketplace.action.working`:$?`marketplace.action.reinstall`:`marketplace.action.install`),onClick:rt}:{label:I?s(`marketplace.action.installing`):z?s(`marketplace.action.installed`,{defaultValue:`Installed`}):s(`marketplace.action.installToCloud`),onClick:tt},mt=Z.category?s(`marketplace.category.${Z.category}`,{defaultValue:Z.category}):null;return i?(0,C.jsxs)(`div`,{className:`mx-auto w-full max-w-6xl flex flex-col gap-6 p-4 sm:p-6`,children:[(0,C.jsxs)(g,{variant:`ghost`,size:`sm`,className:`self-start -ml-2 text-muted-foreground hover:text-foreground`,onClick:()=>e(`${d}/system/marketplace`),children:[(0,C.jsx)(Te,{className:`h-4 w-4 mr-1.5`,"aria-hidden":`true`}),s(`marketplace.back`)]}),(0,C.jsxs)(`div`,{className:`flex items-start gap-5 flex-wrap sm:flex-nowrap rounded-2xl border bg-gradient-to-br from-primary/5 via-background to-background p-6 sm:p-8`,children:[(0,C.jsx)(ke,{iconUrl:Z.icon_url,displayName:Q.displayName,manifestId:Z.manifest_id,className:`h-20 w-20 rounded-2xl shadow-sm ring-1 ring-border shrink-0`,initialClassName:`text-3xl font-bold`}),(0,C.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,C.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,C.jsx)(`h1`,{className:`text-2xl sm:text-3xl font-bold tracking-tight truncate`,children:Q.displayName||Z.manifest_id}),Z.homepage_url&&(0,C.jsxs)(`a`,{href:Z.homepage_url,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors`,title:s(`marketplace.detail.homepage`),children:[(0,C.jsx)(ae,{className:`h-3.5 w-3.5`,"aria-hidden":`true`}),(0,C.jsx)(`span`,{className:`hidden sm:inline`,children:s(`marketplace.detail.homepage`)})]})]}),(0,C.jsxs)(`div`,{className:`text-sm text-muted-foreground mt-2 flex flex-wrap items-center gap-1.5`,children:[(0,C.jsx)(`code`,{className:`font-mono text-xs px-1.5 py-0.5 rounded bg-muted`,children:Z.manifest_id}),lt&&(0,C.jsx)(o,{variant:`outline`,children:s(`marketplace.versionBadge`,{version:lt})}),Z.publisher&&Z.publisher!==`private`&&(0,C.jsx)(o,{variant:Z.publisher===`objectstack`?`default`:`secondary`,children:Z.publisher}),mt&&(0,C.jsx)(o,{variant:`outline`,children:mt}),Z.license&&(0,C.jsx)(o,{variant:`outline`,className:`font-normal`,children:Z.license}),$&&(0,C.jsxs)(o,{variant:`default`,className:`bg-green-600 hover:bg-green-600 gap-1`,children:[(0,C.jsx)(_,{className:`h-3 w-3`,"aria-hidden":`true`}),s(`marketplace.detail.installedV`,{version:$.version})]}),!$&&z&&(0,C.jsxs)(o,{variant:`default`,className:`bg-green-600 hover:bg-green-600 gap-1`,children:[(0,C.jsx)(_,{className:`h-3 w-3`,"aria-hidden":`true`}),s(`marketplace.detail.installedV`,{version:z})]})]}),Q.description&&(0,C.jsx)(`p`,{className:`text-sm sm:text-base text-foreground/80 mt-3 max-w-2xl leading-relaxed`,children:Q.description})]}),(0,C.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0 self-start`,children:[(0,C.jsxs)(g,{onClick:pt.onClick,disabled:ft,size:`lg`,className:`min-w-[8rem]`,children:[(0,C.jsx)(Oe,{className:`h-4 w-4 mr-1.5`,"aria-hidden":`true`}),pt.label]}),$&&(0,C.jsxs)(Ee,{children:[(0,C.jsx)(xe,{asChild:!0,children:(0,C.jsx)(g,{variant:`outline`,size:`lg`,className:`px-2.5`,"aria-label":s(`marketplace.detail.moreOptions`),children:(0,C.jsx)(ce,{className:`h-4 w-4`,"aria-hidden":`true`})})}),(0,C.jsxs)(ye,{align:`end`,className:`w-56`,children:[(0,C.jsxs)(b,{onSelect:st,disabled:H!==null,children:[H===`reseed`?(0,C.jsx)(v,{className:`h-4 w-4 mr-2 animate-spin`,"aria-hidden":`true`}):(0,C.jsx)(fe,{className:`h-4 w-4 mr-2`,"aria-hidden":`true`}),$.withSampleData?s(`marketplace.detail.reseedAgain`)||`Re-seed sample data`:s(`marketplace.detail.addSampleData`)||`Add sample data`]}),(0,C.jsxs)(b,{onSelect:ct,disabled:H!==null||!$.withSampleData,className:`text-destructive focus:text-destructive`,children:[H===`purge`?(0,C.jsx)(v,{className:`h-4 w-4 mr-2 animate-spin`,"aria-hidden":`true`}):(0,C.jsx)(f,{className:`h-4 w-4 mr-2`,"aria-hidden":`true`}),s(`marketplace.detail.purgeSampleData`)||`Purge sample data`]}),(0,C.jsxs)(b,{onSelect:it,disabled:q,className:`text-destructive focus:text-destructive`,children:[(0,C.jsx)(f,{className:`h-4 w-4 mr-2`,"aria-hidden":`true`}),s(`marketplace.detail.uninstallFromRuntime`)]})]})]}),!$&&B&&!x().cloudUrl&&(0,C.jsxs)(Ee,{children:[(0,C.jsx)(xe,{asChild:!0,children:(0,C.jsx)(g,{variant:`outline`,size:`lg`,className:`px-2.5`,"aria-label":s(`marketplace.detail.moreOptions`)||`More options`,children:(0,C.jsx)(ce,{className:`h-4 w-4`,"aria-hidden":`true`})})}),(0,C.jsxs)(ye,{align:`end`,className:`w-56`,children:[(0,C.jsxs)(b,{onSelect:at,disabled:H!==null,children:[H===`reseed`?(0,C.jsx)(v,{className:`h-4 w-4 mr-2 animate-spin`,"aria-hidden":`true`}):(0,C.jsx)(fe,{className:`h-4 w-4 mr-2`,"aria-hidden":`true`}),B.withSampleData?s(`marketplace.detail.reseedAgain`)||`Re-seed sample data`:s(`marketplace.detail.addSampleData`)||`Add sample data`]}),(0,C.jsxs)(b,{onSelect:ot,disabled:H!==null||!B.withSampleData,className:`text-destructive focus:text-destructive`,children:[H===`purge`?(0,C.jsx)(v,{className:`h-4 w-4 mr-2 animate-spin`,"aria-hidden":`true`}):(0,C.jsx)(f,{className:`h-4 w-4 mr-2`,"aria-hidden":`true`}),s(`marketplace.detail.purgeSampleData`)||`Purge sample data`]})]})]})]})]}),W&&(0,C.jsxs)(`div`,{role:`status`,className:`flex items-start gap-2 rounded-md border p-3 text-sm ${W.ok?`border-green-500/30 bg-green-500/5 text-green-700 dark:text-green-400`:`border-destructive/30 bg-destructive/5 text-destructive`}`,children:[W.ok?(0,C.jsx)(_,{className:`h-4 w-4 mt-0.5 shrink-0`,"aria-hidden":`true`}):(0,C.jsx)(m,{className:`h-4 w-4 mt-0.5 shrink-0`,"aria-hidden":`true`}),(0,C.jsx)(`div`,{className:`flex-1`,children:W.text}),(0,C.jsx)(`button`,{type:`button`,className:`text-xs underline opacity-60 hover:opacity-100`,onClick:()=>G(null),children:s(`marketplace.action.dismiss`)})]}),Y&&(0,C.jsxs)(`div`,{role:`status`,className:`flex items-start gap-2 rounded-md border p-3 text-sm whitespace-pre-wrap ${Y.ok?`border-green-500/30 bg-green-500/5 text-green-700 dark:text-green-400`:`border-destructive/30 bg-destructive/5 text-destructive`}`,children:[Y.ok?(0,C.jsx)(_,{className:`h-4 w-4 mt-0.5 shrink-0`,"aria-hidden":`true`}):(0,C.jsx)(m,{className:`h-4 w-4 mt-0.5 shrink-0`,"aria-hidden":`true`}),(0,C.jsx)(`div`,{className:`flex-1`,children:Y.message}),(0,C.jsx)(`button`,{type:`button`,className:`text-xs underline opacity-60 hover:opacity-100`,onClick:()=>X(null),children:s(`marketplace.action.dismiss`)})]}),(0,C.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-3`,children:[(0,C.jsx)(`div`,{className:`lg:col-span-2 space-y-4`,children:(0,C.jsxs)(we,{children:[(0,C.jsx)(_e,{children:(0,C.jsx)(ve,{className:`text-base`,children:s(`marketplace.detail.about`)})}),(0,C.jsx)(le,{children:Q.readme?(0,C.jsx)(Ge,{source:Q.readme}):(0,C.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:s(`marketplace.detail.noReadme`)})})]})}),(0,C.jsx)(`div`,{className:`space-y-4`,children:(0,C.jsxs)(we,{children:[(0,C.jsx)(_e,{children:(0,C.jsx)(ve,{className:`text-base`,children:s(`marketplace.detail.versions`)})}),(0,C.jsx)(le,{children:h.versions.length===0?(0,C.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:s(`marketplace.detail.noApprovedVersions`)}):(0,C.jsx)(`ul`,{className:`space-y-2`,children:h.versions.map(e=>(0,C.jsxs)(`li`,{className:`flex items-center justify-between gap-2 text-sm`,children:[(0,C.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,C.jsx)(Se,{className:`h-3.5 w-3.5 text-muted-foreground`,"aria-hidden":`true`}),(0,C.jsxs)(`code`,{className:`font-mono`,children:[`v`,e.version]}),e.is_prerelease&&(0,C.jsx)(o,{variant:`outline`,className:`text-xs`,children:s(`marketplace.detail.prerelease`)})]}),(0,C.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.published_at?new Date(e.published_at).toLocaleDateString():`—`})]},e.id))})})]})})]}),(0,C.jsx)(ue,{open:D,onOpenChange:e=>{O(e),e||(R(null),Ze(!1))},children:(0,C.jsxs)(de,{children:[(0,C.jsxs)(me,{children:[(0,C.jsx)(oe,{children:s(`marketplace.install.dialogTitle`,{name:Q.displayName||Z.manifest_id})}),(0,C.jsx)(De,{children:x().defaultEnvironmentId?s(`marketplace.install.dialogDescCurrent`,{host:typeof window<`u`?window.location.host:``}):s(`marketplace.install.dialogDescPicker`)})]}),Je?(0,C.jsx)(u,{className:`h-10 w-full`}):j?(0,C.jsxs)(`div`,{className:`rounded-md border border-amber-500/30 bg-amber-500/5 p-3 text-sm space-y-2`,children:[(0,C.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,C.jsx)(m,{className:`h-4 w-4 mt-0.5 text-amber-600`,"aria-hidden":`true`}),(0,C.jsx)(`div`,{className:`flex-1`,children:j})]}),(0,C.jsx)(`a`,{href:We(Z.id),target:`_blank`,rel:`noopener noreferrer`,children:(0,C.jsxs)(g,{variant:`outline`,size:`sm`,className:`w-full`,children:[(0,C.jsx)(ae,{className:`h-4 w-4 mr-1.5`,"aria-hidden":`true`}),s(`marketplace.action.openOnCloud`)]})})]}):x().defaultEnvironmentId?(0,C.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,C.jsx)(l,{id:`seed`,checked:F,onCheckedChange:e=>Ye(e===!0)}),(0,C.jsx)(y,{htmlFor:`seed`,className:`text-sm font-normal cursor-pointer`,children:s(`marketplace.install.includeSampleData`)})]}):k.length===0?(0,C.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:s(`marketplace.install.noEnvs`)}):(0,C.jsxs)(`div`,{className:`space-y-4`,children:[(0,C.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,C.jsx)(y,{htmlFor:`env-select`,children:s(`marketplace.install.environment`)}),(0,C.jsxs)(ie,{value:N,onValueChange:P,children:[(0,C.jsx)(pe,{id:`env-select`,children:(0,C.jsx)(ge,{placeholder:s(`marketplace.install.environmentPlaceholder`)})}),(0,C.jsx)(he,{children:k.map(e=>(0,C.jsxs)(se,{value:e.id,children:[e.display_name||e.hostname||e.id,e.plan&&(0,C.jsxs)(`span`,{className:`text-muted-foreground`,children:[` · `,e.plan]})]},e.id))})]})]}),(0,C.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,C.jsx)(l,{id:`seed`,checked:F,onCheckedChange:e=>Ye(e===!0)}),(0,C.jsx)(y,{htmlFor:`seed`,className:`text-sm font-normal cursor-pointer`,children:s(`marketplace.install.includeSampleData`)})]})]}),ut&&!j&&(0,C.jsxs)(`div`,{className:`space-y-3`,children:[(0,C.jsx)(Ke,{version:Z.latest_version}),(0,C.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,C.jsx)(l,{id:`ack-perms`,checked:Xe,onCheckedChange:e=>Ze(e===!0)}),(0,C.jsx)(y,{htmlFor:`ack-perms`,className:`text-sm font-normal cursor-pointer leading-snug`,children:s(`marketplace.disclosure.acknowledge`,{defaultValue:`I understand this package runs code and grants the permissions above.`})})]})]}),L&&(0,C.jsx)(`div`,{className:`rounded-md border p-3 text-sm ${L.ok?`border-green-500/30 bg-green-500/5 text-green-700`:`border-destructive/30 bg-destructive/5 text-destructive`}`,children:L.message}),(0,C.jsxs)(re,{children:[(0,C.jsx)(g,{variant:`outline`,onClick:()=>O(!1),children:s(`marketplace.action.close`)}),!j&&(0,C.jsx)(g,{onClick:nt,disabled:!N||I||L?.ok===!0||ut&&!Xe,children:s(I?`marketplace.action.installing`:`marketplace.action.install`)})]})]})})]}):(0,C.jsx)(je,{})}export{O as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as e,r as t}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as n,f as r,t as i,u as a}from"./vendor-react-DR370ovB.js";import{d as ee}from"./infrastructure-CJNwTVno.js";import{r as o}from"./framework-ZJouI0cJ.js";import{$n as s,Fi as c,Jn as l,Mt as u,Si as te,Xn as d,Yn as f,Zn as p,_s as ne,bi as re,ei as m,hr as h,hs as g,la as _,nn as ie,qn as v}from"./ui-components-Bs-DxYrW.js";import{i as ae}from"./runtime-config-BeHVOPm3.js";import{n as y,t as b}from"./usePackageL10n-shLsxEAx.js";import{_ as x,a as S,c as oe,d as se,i as ce,l as C,u as w}from"./marketplaceApi-DCvJ2C6u.js";var T=t({MarketplacePage:()=>k}),E=e(n(),1),D=i();function O(){let{language:e,t}=o();return n=>{if(!n)return``;let r=new Date(n);if(Number.isNaN(r.getTime()))return``;let i=Math.floor((Date.now()-r.getTime())/864e5);if(i<1)return t(`marketplace.relativeTime.today`);try{let t=new Intl.RelativeTimeFormat(e||`en`,{numeric:`auto`});return i<30?t.format(-i,`day`):i<365?t.format(-Math.floor(i/30),`month`):t.format(-Math.floor(i/365),`year`)}catch{return i<30?t(`marketplace.relativeTime.daysAgo`,{count:i}):i<365?t(`marketplace.relativeTime.monthsAgo`,{count:Math.floor(i/30)}):t(`marketplace.relativeTime.yearsAgo`,{count:Math.floor(i/365)})}}}function k(){let e=a(),{appName:t}=r(),n=ee(),{t:i,language:T}=o(),k=O(),A=t?`/apps/${t}`:``,[j,M]=(0,E.useState)([]),[N,P]=(0,E.useState)(!0),[F,I]=(0,E.useState)(null),[L,R]=(0,E.useState)(``),[z,B]=(0,E.useState)(``),[V,H]=(0,E.useState)([]),[U,W]=(0,E.useState)([]),[G,K]=(0,E.useState)(null),[q,J]=(0,E.useState)(null),[le,Y]=(0,E.useState)(new Set),ue=(0,E.useMemo)(()=>{let e=new Map;for(let t of V)e.set(t.manifestId,t);return e},[V]),X=async()=>{P(!0),I(null);try{let[e,t,n,r]=await Promise.all([w({limit:100}),C(),se(),oe()]);M(e.items??[]),H(t),W(n.items??[]);let i=new Set;for(let e of t)i.add(e.manifestId);for(let e of r.items)i.add(e.manifestId);Y(i)}catch(e){I(e?.message??String(e)),M([])}finally{P(!1)}};(0,E.useEffect)(()=>{X()},[]);let de=async e=>{K(e.id),J(null);try{ae().features.installLocal?await ce({packageId:e.manifest_id||e.id,versionId:`latest`}):await S({packageId:e.id,environmentId:``,seedSampleData:!0}),J({ok:!0,text:i(`marketplace.org.installed`,{defaultValue:`Installed ${e.display_name}`,name:e.display_name})}),await X()}catch(e){J({ok:!1,text:e?.message??String(e)})}finally{K(null)}},Z=(0,E.useMemo)(()=>{let e=new Set;for(let t of j)t.category&&e.add(t.category);return Array.from(e).sort()},[j]),Q=e=>{let t=`marketplace.category.${e}`,n=i(t,{defaultValue:e});return n===t?e:n},$=(0,E.useMemo)(()=>{let e=L.trim().toLowerCase();return j.filter(t=>{if(z&&t.category!==z)return!1;if(!e)return!0;let n=b(t,T);return`${n.displayName} ${t.manifest_id} ${n.description??``}`.toLowerCase().includes(e)})},[j,L,z,T]);return n?(0,D.jsxs)(`div`,{className:`flex flex-col gap-6 p-4 sm:p-6`,children:[(0,D.jsxs)(`div`,{className:`flex items-start justify-between gap-4 flex-wrap`,children:[(0,D.jsxs)(`div`,{className:`min-w-0`,children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,D.jsx)(m,{className:`h-6 w-6 text-primary`,"aria-hidden":`true`}),(0,D.jsx)(`h1`,{className:`text-xl sm:text-2xl font-bold tracking-tight`,children:i(`marketplace.title`)})]}),(0,D.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:i(`marketplace.subtitle`)})]}),(0,D.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,D.jsxs)(h,{variant:`outline`,size:`sm`,onClick:()=>e(`${A}/system/marketplace/installed`),children:[(0,D.jsx)(re,{className:`h-4 w-4 mr-1.5`,"aria-hidden":`true`}),V.length>0?i(`marketplace.installedCount`,{count:V.length}):i(`marketplace.installed`)]}),(0,D.jsxs)(h,{variant:`outline`,size:`sm`,onClick:()=>void X(),disabled:N,children:[(0,D.jsx)(c,{className:`h-4 w-4 mr-1.5`,"aria-hidden":`true`}),i(`marketplace.refresh`)]})]})]}),(0,D.jsxs)(`div`,{className:`flex flex-col sm:flex-row gap-3`,children:[(0,D.jsxs)(`div`,{className:`relative flex-1`,children:[(0,D.jsx)(te,{className:`absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground`,"aria-hidden":`true`}),(0,D.jsx)(ie,{value:L,onChange:e=>R(e.target.value),placeholder:i(`marketplace.searchPlaceholder`),className:`pl-9`,"aria-label":i(`marketplace.searchAria`)})]}),Z.length>0&&(0,D.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[(0,D.jsx)(h,{size:`sm`,variant:z===``?`default`:`outline`,onClick:()=>B(``),children:i(`marketplace.all`)}),Z.map(e=>(0,D.jsx)(h,{size:`sm`,variant:z===e?`default`:`outline`,onClick:()=>B(e),children:Q(e)},e))]})]}),F&&(0,D.jsxs)(`div`,{className:`flex items-start gap-3 rounded-md border border-destructive/30 bg-destructive/5 p-4 text-sm`,children:[(0,D.jsx)(ne,{className:`h-4 w-4 mt-0.5 text-destructive`,"aria-hidden":`true`}),(0,D.jsxs)(`div`,{children:[(0,D.jsx)(`div`,{className:`font-medium text-destructive`,children:i(`marketplace.load.failed`)}),(0,D.jsx)(`div`,{className:`text-muted-foreground mt-1`,children:F}),(0,D.jsx)(`div`,{className:`text-xs text-muted-foreground mt-2`,dangerouslySetInnerHTML:{__html:i(`marketplace.load.failedHint`)}})]})]}),U.length>0&&(0,D.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,D.jsx)(m,{className:`h-5 w-5 text-primary`,"aria-hidden":`true`}),(0,D.jsx)(`h2`,{className:`text-sm font-semibold`,children:i(`marketplace.org.heading`,{defaultValue:`Your organization`})}),(0,D.jsx)(s,{variant:`secondary`,className:`text-xs`,children:U.length})]}),q&&(0,D.jsx)(`div`,{className:`rounded-md border p-3 text-sm ${q.ok?`border-green-500/30 bg-green-500/5 text-green-700 dark:text-green-400`:`border-destructive/30 bg-destructive/5 text-destructive`}`,children:q.text}),(0,D.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:U.map(e=>{let t=le.has(e.manifest_id);return(0,D.jsxs)(v,{className:`flex flex-col`,"data-testid":`org-card-${e.manifest_id}`,children:[(0,D.jsxs)(d,{className:`flex flex-row items-start gap-3 pb-2`,children:[(0,D.jsx)(y,{iconUrl:e.icon_url,displayName:e.display_name,manifestId:e.manifest_id}),(0,D.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,D.jsx)(p,{className:`text-base truncate`,children:e.display_name}),(0,D.jsx)(f,{className:`text-xs truncate`,children:(0,D.jsx)(`code`,{className:`font-mono`,children:e.manifest_id})})]}),e.visibility&&(0,D.jsx)(s,{variant:`outline`,className:`shrink-0 text-xs`,children:e.visibility})]}),(0,D.jsxs)(l,{className:`flex-1 flex flex-col gap-2`,children:[(0,D.jsx)(`p`,{className:`text-sm text-muted-foreground line-clamp-2`,children:e.description||i(`marketplace.noDescription`)}),(0,D.jsxs)(`div`,{className:`flex items-center gap-2 mt-auto pt-2 flex-wrap`,children:[e.latest_version&&(0,D.jsxs)(s,{variant:`outline`,className:`text-xs`,children:[(0,D.jsx)(_,{className:`h-3 w-3 mr-1`,"aria-hidden":`true`}),i(`marketplace.versionBadge`,{version:e.latest_version})]}),(0,D.jsx)(`div`,{className:`ml-auto`,children:t?(0,D.jsxs)(s,{variant:`default`,className:`text-xs bg-green-600 hover:bg-green-600`,children:[(0,D.jsx)(g,{className:`h-3 w-3 mr-1`,"aria-hidden":`true`}),i(`marketplace.org.installedBadge`,{defaultValue:`Installed`})]}):(0,D.jsx)(h,{size:`sm`,onClick:()=>void de(e),disabled:G===e.id,children:G===e.id?i(`marketplace.org.installing`,{defaultValue:`Installing…`}):i(`marketplace.org.install`,{defaultValue:`Install`})})})]})]})]},e.id)})}),(0,D.jsx)(`div`,{className:`border-b pt-2`})]}),N&&j.length===0?(0,D.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:Array.from({length:6}).map((e,t)=>(0,D.jsxs)(v,{children:[(0,D.jsxs)(d,{className:`pb-2`,children:[(0,D.jsx)(u,{className:`h-10 w-10 rounded-lg mb-2`}),(0,D.jsx)(u,{className:`h-5 w-3/4`}),(0,D.jsx)(u,{className:`h-4 w-1/2 mt-1`})]}),(0,D.jsx)(l,{children:(0,D.jsx)(u,{className:`h-12 w-full`})})]},t))}):$.length===0?(0,D.jsx)(`div`,{className:`text-center py-12 text-sm text-muted-foreground`,children:j.length===0?i(`marketplace.noApprovedYet`):i(`marketplace.noMatchFilters`)}):(0,D.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:$.map(t=>{let n=ue.get(t.manifest_id),r=b(t,T);return(0,D.jsxs)(v,{className:`cursor-pointer transition-colors hover:bg-accent/50 flex flex-col`,onClick:()=>e(`${A}/system/marketplace/${t.id}`),role:`link`,tabIndex:0,onKeyDown:n=>{(n.key===`Enter`||n.key===` `)&&(n.preventDefault(),e(`${A}/system/marketplace/${t.id}`))},"data-testid":`marketplace-card-${t.manifest_id}`,children:[(0,D.jsxs)(d,{className:`flex flex-row items-start gap-3 pb-2`,children:[(0,D.jsx)(y,{iconUrl:t.icon_url,displayName:r.displayName,manifestId:t.manifest_id}),(0,D.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,D.jsx)(p,{className:`text-base truncate`,children:r.displayName}),(0,D.jsx)(f,{className:`text-xs truncate`,children:(0,D.jsx)(`code`,{className:`font-mono`,children:t.manifest_id})})]}),t.publisher&&t.publisher!==`private`&&(0,D.jsx)(s,{variant:t.publisher===`objectstack`?`default`:`secondary`,className:`shrink-0`,children:t.publisher})]}),(0,D.jsxs)(l,{className:`flex-1 flex flex-col gap-2`,children:[(0,D.jsx)(`p`,{className:`text-sm text-muted-foreground line-clamp-2`,children:r.description||i(`marketplace.noDescription`)}),(0,D.jsxs)(`div`,{className:`flex items-center gap-2 mt-auto pt-2 flex-wrap`,children:[n&&(0,D.jsxs)(s,{variant:`default`,className:`text-xs bg-green-600 hover:bg-green-600`,children:[(0,D.jsx)(g,{className:`h-3 w-3 mr-1`,"aria-hidden":`true`}),i(`marketplace.installedBadge`,{version:n.version})]}),t.latest_version?.version&&(0,D.jsxs)(s,{variant:`outline`,className:`text-xs`,children:[(0,D.jsx)(_,{className:`h-3 w-3 mr-1`,"aria-hidden":`true`}),i(`marketplace.versionBadge`,{version:t.latest_version.version})]}),t.category&&(0,D.jsx)(s,{variant:`outline`,className:`text-xs`,children:Q(t.category)}),t.latest_version?.published_at&&(0,D.jsx)(`span`,{className:`text-xs text-muted-foreground ml-auto`,children:k(t.latest_version.published_at)})]})]})]},t.id)})})]}):(0,D.jsx)(x,{})}export{T as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as e,r as t}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as n,f as r,l as i,p as a,t as o,u as s}from"./vendor-react-DR370ovB.js";import{f as c,m as l}from"./infrastructure-CJNwTVno.js";import{B as u,O as d,T as f,r as p,w as m}from"./framework-ZJouI0cJ.js";import{H as h,R as g,So as _,Yi as v,fc as y,z as b}from"./ui-components-Bs-DxYrW.js";import{r as x}from"./vendor-ui-utils-rQOI1gAo.js";import"./MetadataProvider-BagIop6q.js";import{r as S}from"./ExpressionProvider-Cuv0RaiR.js";import{n as C,r as w,t as T}from"./MetadataInspector-zJtxyFau.js";import{t as E}from"./InterfaceListPage-DTHEyaKG.js";import{a as D,i as O,n as k,r as A,t as j}from"./resolveActionParams-ergReBd1.js";var M=e(n(),1),N=o(),P={id:`current-user`,name:`Demo User`,isPlatformAdmin:!1};function F(e){let{dataSource:t,objects:n,objectName:r,onRefresh:i}=e,a=s(),{user:o,activeOrganization:u}=c(),{fieldLabel:d,fieldOptionLabel:f,actionParamText:p,actionParamOptionLabel:m}=y(),h=(0,M.useMemo)(()=>r?n?.find(e=>e.name===r):void 0,[n,r]),g=r||h?.name,_=(0,M.useCallback)(()=>{i?.()},[i]),[v,b]=(0,M.useState)({open:!1,message:``}),[S,C]=(0,M.useState)({open:!1,params:[]}),[w,T]=(0,M.useState)({open:!1}),[E,F]=(0,M.useState)(null),I=(0,M.useRef)(new Set),L=(0,M.useCallback)((e,t)=>new Promise(n=>{T({open:!0,spec:e,data:t,resolve:n})}),[]),R=(0,M.useCallback)((e,t)=>new Promise(n=>{b({open:!0,message:e,options:t,resolve:n})}),[]),z=(0,M.useCallback)((e,t)=>new Promise(i=>{let a=t?.params&&!Array.isArray(t.params)?t.params._rowRecord:void 0,o=j(e,{objectName:r||h?.name||``,objects:n||[],fieldLabel:d,fieldOptionLabel:f,row:a}),s=r||h?.name;C({open:!0,params:o.map(e=>({...e,label:p(s,t?.name,e.name,`label`,e.label)??e.label,placeholder:p(s,t?.name,e.name,`placeholder`,e.placeholder)??e.placeholder,helpText:p(s,t?.name,e.name,`helpText`,e.helpText)??e.helpText,options:Array.isArray(e.options)?e.options.map(n=>({...n,label:m(s,t?.name,e.name,n.value,n.label)})):e.options})),title:t?.label||t?.title,description:t?.description,resolve:i})}),[r,h,n,d,f,p,m]),B=o?{id:o.id,name:o.name,avatar:o.image,isPlatformAdmin:o?.isPlatformAdmin??!1}:P,V=(0,M.useCallback)((e,t)=>{t?.type===`error`?x.error(e):x.success(e)},[]),H=(0,M.useCallback)((e,t)=>{t?.external||t?.newTab?window.open(e,`_blank`,`noopener,noreferrer`):a(e)},[a]),U=(0,M.useMemo)(()=>l(),[]),W=(0,M.useCallback)(async e=>{try{let n=e.target||e.name,r=e.params||{},i=typeof n==`string`?n:``;if(i.startsWith(`/`)||/^https?:\/\//i.test(i)){let t={...r},n=t._rowRecord;delete t._rowRecord;let a=i;n&&/\{[a-z_][a-z0-9_]*\}/i.test(a)&&(a=a.replace(/\{([a-z_][a-z0-9_]*)\}/gi,(e,t)=>{let r=n[t];return r==null?``:encodeURIComponent(String(r))}));let o=a.startsWith(`http`)?a:`${a}`,s=e.bodyShape&&typeof e.bodyShape==`object`&&e.bodyShape.wrap?e.bodyShape.wrap:void 0,c=s?{[s]:t}:{...t};if(n&&e.recordIdParam){let t=n[e.recordIdField||`id`];t!=null&&(c[e.recordIdParam]=t)}/\/api\/v1\/auth\//.test(a)&&!c.organizationId&&u?.id&&(c.organizationId=u.id),e.bodyExtra&&typeof e.bodyExtra==`object`&&Object.assign(c,e.bodyExtra);let l=(e.method||`POST`).toUpperCase(),d={method:l,headers:{"Content-Type":`application/json`},credentials:`include`};l!==`GET`&&l!==`DELETE`&&(d.body=JSON.stringify(c));let f=await U(o,d);if(!f.ok){let e=`HTTP ${f.status}`;try{let t=await f.json();e=t?.error||t?.message||e}catch{}return{success:!1,error:e}}let p=await f.json().catch(()=>({}));return e.refreshAfter!==!1&&_(),{success:!0,data:p,reload:e.refreshAfter!==!1}}let a=e.objectName||g;a&&typeof t?.execute==`function`?await t.execute(a,n,r):a&&r.recordId&&Object.keys(r).length>1&&typeof t?.update==`function`&&await t.update(a,r.recordId,r);let o=e.refreshAfter!==!1;return o&&_(),{success:!0,reload:o}}catch(e){return{success:!1,error:e.message}}},[t,g,U,u,_]),G=(0,M.useCallback)(async(e,t)=>{let n=e.target||e.name;if(!n)return{success:!1,error:`No flow target provided for flow action`};try{let r={...e.params||{}},i=r._rowRecord;delete r._rowRecord;let a=r.recordId??i?.id;if(a==null){let e=Array.isArray(t?.selectedRecords)?t.selectedRecords:[];if(e.length===1)a=e[0]?.id;else if(e.length>1)return{success:!1,error:`This flow runs on a single record — select exactly one row.`}}a!=null&&r.recordId==null&&(r.recordId=a);let o=await U(`/api/v1/automation/${encodeURIComponent(n)}/trigger`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({recordId:a,objectName:e.objectName||g,params:r})}),s=await o.json().catch(()=>null);if(!o.ok||s&&s.success===!1)return{success:!1,error:s?.error||`Flow "${n}" failed (HTTP ${o.status})`};let c=s?.data??{};if(c.status===`paused`&&c.screen)return F({flowName:n,runId:c.runId,screen:c.screen}),{success:!0};let l=e.refreshAfter!==!1;return l&&_(),{success:!0,data:s?.data,reload:l}}catch(e){return{success:!1,error:e.message}}},[U,g,_]),K=(0,M.useCallback)(async(e,t)=>{let n=e.target||e.name;if(!n)return{success:!1,error:`No action target provided`};let r=e.params&&!Array.isArray(e.params)?{...e.params}:{},i=r._rowRecord;delete r._rowRecord;let a=e.recordIdField||`id`,o=r.recordId??i?.[a];if(o==null){let e=Array.isArray(t?.selectedRecords)?t.selectedRecords:[];if(e.length===1)o=e[0]?.[a];else if(e.length>1)return{success:!1,error:`This action runs on a single record — select exactly one row.`}}let s=`${n}:${o??``}`;if(I.current.has(s))return{success:!1,error:`Action already in progress`};I.current.add(s);let c=null;if(e.opensInNewTab)try{c=window.open(`about:blank`,`_blank`),c&&(c.document.write(`<!doctype html><meta charset="utf-8"><title>正在打开… Opening…</title><body style="margin:0;font-family:system-ui,sans-serif;display:flex;flex-direction:column;align-items:center;justify-content:center;height:100vh;gap:16px;color:#4b5563"><div style="width:28px;height:28px;border:3px solid #e5e7eb;border-top-color:#6366f1;border-radius:50%;animation:s .8s linear infinite"></div><div>正在为你打开环境…</div><style>@keyframes s{to{transform:rotate(360deg)}}</style></body>`),c.document.close())}catch{c=null}try{let t=typeof e.newTabUrl==`string`?e.newTabUrl:``;if(e.opensInNewTab&&t){if(o==null){if(c)try{c.close()}catch{}return{success:!1,error:`This action runs on a single record — no record id available.`}}let n=`${window.location.origin}${t.replace(`{recordId}`,encodeURIComponent(String(o)))}`;if(c)try{c.location.href=n}catch{try{c.close()}catch{}window.location.href=n}else{let e=null;try{e=window.open(n,`_blank`)}catch{e=null}e||x(`浏览器拦截了弹窗 / Popup blocked`,{description:`点击在新标签页打开环境`,action:{label:`打开环境`,onClick:()=>{try{window.open(n,`_blank`)}catch{window.location.href=n}}},duration:1e4})}return e.refreshAfter===!0&&_(),{success:!0}}let i=e.objectName||g||`global`,a=await U(`/api/v1/actions/${encodeURIComponent(i)}/${encodeURIComponent(n)}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({recordId:o,params:r})}),s=await a.json().catch(()=>null);if(!a.ok||s&&s.success===!1){let e=s?.error||`Action "${n}" failed (HTTP ${a.status})`;if(c)try{c.close()}catch{}return x.error(e),{success:!1,error:e}}let l=e.refreshAfter!==!1;l&&_();let u=s?.data,d=u&&typeof u==`object`&&typeof u.redirectUrl==`string`?u.redirectUrl:null;if(d)if(c)try{c.location.href=d}catch{try{c.close()}catch{}window.location.href=d}else{let e=null;try{e=window.open(d,`_blank`)}catch{e=null}e||x(`浏览器拦截了弹窗 / Popup blocked`,{description:`点击在新标签页打开环境`,action:{label:`打开环境`,onClick:()=>{try{window.open(d,`_blank`)}catch{window.location.href=d}}},duration:1e4})}else if(c)try{c.close()}catch{}return{success:!0,data:u,reload:l}}catch(e){if(c)try{c.close()}catch{}let t=e.message;return x.error(t),{success:!1,error:t}}finally{I.current.delete(s)}},[U,g,_]);return{confirmHandler:R,toastHandler:V,navigateHandler:H,paramCollectionHandler:z,resultDialogHandler:L,apiHandler:W,flowHandler:G,serverActionHandler:K,authFetch:U,actionProviderProps:(0,M.useMemo)(()=>({context:{...r?{objectName:r}:{},user:B,apiBase:``,activeOrganization:u?{id:u.id,slug:u.slug,name:u.name}:null},onConfirm:R,onToast:V,onNavigate:H,onParamCollection:z,onResultDialog:L,handlers:{api:W,flow:G,script:K,modal:K}}),[r,B,u,R,V,H,z,L,W,G,K]),dialogs:(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(D,{state:v,onOpenChange:e=>{e||b({open:!1,message:``})}}),(0,N.jsx)(O,{state:S,onOpenChange:e=>{e||C({open:!1,params:[]})}}),(0,N.jsx)(A,{state:w,onAcknowledge:()=>{w.resolve?.(),T({open:!1})}}),(0,N.jsx)(k,{state:E,authFetch:U,baseUrl:``,onClose:()=>F(null),onComplete:()=>{F(null),_()}})]})}}function I({children:e,...t}){let n=F(t);return(0,N.jsxs)(d,{...n.actionProviderProps,children:[e,n.dialogs]})}var L=t({PageView:()=>R});function R(){let{t:e}=p(),{pageName:t}=r(),[n]=a(),{showDebug:o}=C(),l=s(),d=i(),{user:y}=c(),x=y?.role===`admin`,{pages:D,objects:O}=f(),{app:k}=S(),A=m(),[j,P]=(0,M.useState)(0),F=w(D,t,k?._packageId);if(!F)return(0,N.jsx)(`div`,{className:`h-full flex items-center justify-center p-8`,children:(0,N.jsxs)(g,{children:[(0,N.jsx)(`div`,{className:`mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-muted`,children:(0,N.jsx)(_,{className:`h-6 w-6 text-muted-foreground`})}),(0,N.jsx)(h,{children:e(`empty.pageNotFound`)}),(0,N.jsx)(b,{children:e(`empty.pageNotFoundDescription`,{name:t})})]})});let L=Object.fromEntries(n.entries()),R=d.pathname.match(/\/apps\/([^/]+)/)?.[1],z=x&&!!R&&!!t;return(0,N.jsx)(I,{dataSource:A,objects:O,onRefresh:()=>P(e=>e+1),children:(0,N.jsxs)(`div`,{className:`flex flex-row h-full w-full overflow-hidden relative`,children:[(0,N.jsxs)(`div`,{className:`flex-1 overflow-auto h-full relative`,children:[z&&(0,N.jsx)(`button`,{type:`button`,onClick:()=>{z&&l(`/apps/${R}/metadata/page/${encodeURIComponent(t)}`)},className:`absolute right-3 top-3 z-30 inline-flex h-7 w-7 items-center justify-center rounded-md border border-input bg-background/90 text-muted-foreground shadow-sm backdrop-blur hover:bg-accent hover:text-accent-foreground`,"data-testid":`page-edit-in-studio-button`,title:e(`common.editInStudio`,{defaultValue:`Edit in studio`}),"aria-label":e(`common.editInStudio`,{defaultValue:`Edit in studio`}),children:(0,N.jsx)(v,{className:`h-3.5 w-3.5`})}),F.interfaceConfig?.source?(0,N.jsx)(E,{page:F},j):(0,N.jsx)(u,{schema:{...F,type:F.type||`page`,context:{...F.context,params:L,refreshKey:j}}},j)]}),(0,N.jsx)(T,{open:o,sections:[{title:`Page Configuration`,data:F}]})]})})}export{F as n,L as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,t as n}from"./vendor-react-DR370ovB.js";import{w as r}from"./framework-ZJouI0cJ.js";import{$n as i,Bn as a,Fa as o,Fo as ee,Hi as te,Hn as s,Jn as ne,Jo as re,Li as c,Ln as l,Pi as ie,Qo as ae,Rn as u,Vn as d,Xn as oe,Yn as se,Zn as ce,ct as f,dt as p,hr as m,lt as h,nn as g,on as _,ot as le,qn as ue,st as de,ut as fe,yi as pe,zn as v}from"./ui-components-Bs-DxYrW.js";import{r as y}from"./vendor-ui-utils-rQOI1gAo.js";import"./index-B99f8h8i.js";var b=e(t(),1),x=n();function me(e){return e?e.replace(/^\/+/,``).match(/^forms\/([^/?#]+)/i)?.[1]??null:null}function S(e){return e.trim().toLowerCase().replace(/[^a-z0-9-_]+/g,`-`).replace(/^-+|-+$/g,``)}function C(){let e=r()?.getClient?.(),[t,n]=(0,b.useState)([]),[C,he]=(0,b.useState)([]),[w,T]=(0,b.useState)(!0),[E,D]=(0,b.useState)(null),[ge,O]=(0,b.useState)(!1),[k,A]=(0,b.useState)(``),[j,M]=(0,b.useState)(``),[N,P]=(0,b.useState)(!1),[_e,F]=(0,b.useState)(!1),[I,L]=(0,b.useState)(null),[R,z]=(0,b.useState)(``),[B,V]=(0,b.useState)(`thank-you`),[H,U]=(0,b.useState)(``),[W,G]=(0,b.useState)(``),[K,q]=(0,b.useState)(``),[J,Y]=(0,b.useState)(!1),X=async()=>{if(!e?.meta?.getItems){D(`meta.getItems is not available on this client`),T(!1);return}T(!0),D(null);try{let t=await e.meta.getItems(`view`),r=Array.isArray(t)?t:Array.isArray(t?.items)?t.items:Array.isArray(t?.value)?t.value:[],i=[],a=[];for(let e of r){let t=e?.spec??e;if(!(t?.sections||t?.groups||t?.form||t?.type===`simple`||t?.type===`tabbed`||t?.type===`wizard`||t?.viewType===`form`))continue;let n=t?.sharing,r=n?.publicLink,o=me(r);n?.allowAnonymous&&o&&r?i.push({name:t?.name??e?.name,label:t?.label,object:t?.object,slug:o,publicLink:r,updatedAt:e?.updatedAt??e?.updated_at,spec:t}):a.push({name:t?.name??e?.name,label:t?.label,object:t?.object,spec:t})}n(i),he(a)}catch(e){D(e?.message??String(e))}finally{T(!1)}};(0,b.useEffect)(()=>{X()},[]);let ve=typeof window<`u`?window.location.origin:``,Z=e=>`${ve}/console/f/${e}`,ye=e=>`<iframe src="${Z(e)}" width="100%" height="640" frameborder="0" style="border:0;"></iframe>`,be=e=>`<iframe\n src={\`${Z(e)}\`}\n title="Public form"\n style={{ width: '100%', height: 640, border: 0 }}\n/>`,Q=async(e,t)=>{try{await navigator.clipboard.writeText(t),y.success(`Copied ${e}`)}catch{y.error(`Clipboard unavailable`)}},xe=async()=>{if(!k||!j)return;let t=C.find(e=>e.name===k);if(!t)return;let n=S(j);if(!n){y.error(`Invalid slug`);return}let r={...t.spec,sharing:{...t.spec.sharing??{},enabled:!0,allowAnonymous:!0,publicLink:`/forms/${n}`}};P(!0);try{await e.meta.saveItem(`view`,t.name,r),y.success(`Published ${t.name}`),O(!1),A(``),M(``),await X()}catch(e){y.error(`Publish failed: ${e?.message??e}`)}finally{P(!1)}},Se=e=>{L(e),z(e.slug);let t=e.spec?.submitBehavior;V(t?.kind??`thank-you`),U(t?.title??``),G(t?.message??``),q(t?.url??``),F(!0)},Ce=async()=>{if(!I)return;let t=S(R);if(!t){y.error(`Invalid slug`);return}let n;switch(B){case`thank-you`:n={kind:`thank-you`},H&&(n.title=H),W&&(n.message=W);break;case`redirect`:if(!K){y.error(`Redirect URL is required`);return}n={kind:`redirect`,url:K};break;case`continue`:case`next-record`:n={kind:B};break}let r={...I.spec,sharing:{...I.spec.sharing??{},enabled:!0,allowAnonymous:!0,publicLink:`/forms/${t}`},submitBehavior:n};Y(!0);try{await e.meta.saveItem(`view`,I.name,r),y.success(`Saved ${I.name}`),F(!1),L(null),await X()}catch(e){y.error(`Save failed: ${e?.message??e}`)}finally{Y(!1)}},$=t.length>0;return(0,x.jsxs)(`div`,{className:`flex flex-1 flex-col gap-4 p-4 md:p-6 overflow-auto`,children:[(0,x.jsxs)(ue,{children:[(0,x.jsxs)(oe,{className:`flex flex-row items-start justify-between gap-4 space-y-0`,children:[(0,x.jsxs)(`div`,{children:[(0,x.jsxs)(ce,{className:`flex items-center gap-2`,children:[(0,x.jsx)(c,{className:`h-4 w-4`}),`Public Forms`]}),(0,x.jsx)(se,{children:`Forms anyone can fill out — no login required. Publish a form to get a shareable link; submissions land directly in the bound object.`})]}),(0,x.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,x.jsxs)(m,{variant:`default`,size:`sm`,onClick:()=>O(!0),disabled:C.length===0,title:C.length===0?`No non-public FormViews available`:`Publish a FormView`,children:[(0,x.jsx)(te,{className:`h-3.5 w-3.5`}),(0,x.jsx)(`span`,{className:`ml-1.5`,children:`Publish form…`})]}),(0,x.jsxs)(m,{variant:`outline`,size:`sm`,onClick:X,disabled:w,children:[(0,x.jsx)(ie,{className:`h-3.5 w-3.5 ${w?`animate-spin`:``}`}),(0,x.jsx)(`span`,{className:`ml-1.5`,children:`Refresh`})]})]})]}),(0,x.jsxs)(ne,{children:[E&&(0,x.jsx)(`div`,{className:`mb-3 rounded-md border border-destructive/40 bg-destructive/10 p-3 text-sm text-destructive`,children:E}),!w&&!$&&(0,x.jsxs)(`div`,{className:`rounded-md border border-dashed p-6 text-center text-sm text-muted-foreground`,children:[(0,x.jsx)(`p`,{className:`font-medium text-foreground`,children:`No public forms yet`}),(0,x.jsxs)(`p`,{className:`mt-1`,children:[`Click `,(0,x.jsx)(`strong`,{children:`Publish form…`}),` above to share an existing form, or build a new one in Views & Apps and mark it public.`]})]}),$&&(0,x.jsxs)(le,{children:[(0,x.jsx)(fe,{children:(0,x.jsxs)(p,{children:[(0,x.jsx)(h,{children:`Name`}),(0,x.jsx)(h,{children:`Object`}),(0,x.jsx)(h,{children:`Slug`}),(0,x.jsx)(h,{children:`Public URL`}),(0,x.jsx)(h,{className:`text-right`,children:`Actions`})]})}),(0,x.jsx)(de,{children:t.map(e=>{let t=Z(e.slug);return(0,x.jsxs)(p,{children:[(0,x.jsx)(f,{children:(0,x.jsxs)(`div`,{className:`flex flex-col`,children:[(0,x.jsx)(`span`,{className:`font-medium`,children:e.label??e.name}),(0,x.jsx)(`code`,{className:`text-xs text-muted-foreground`,children:e.name})]})}),(0,x.jsx)(f,{children:e.object?(0,x.jsx)(i,{variant:`secondary`,children:e.object}):(0,x.jsx)(`span`,{className:`text-muted-foreground`,children:`—`})}),(0,x.jsx)(f,{children:(0,x.jsx)(`code`,{className:`text-xs`,children:e.slug})}),(0,x.jsx)(f,{children:(0,x.jsxs)(`a`,{href:t,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-xs text-primary underline-offset-2 hover:underline`,children:[t,(0,x.jsx)(ee,{className:`h-3 w-3`})]})}),(0,x.jsx)(f,{className:`text-right`,children:(0,x.jsxs)(`div`,{className:`inline-flex gap-1`,children:[(0,x.jsx)(m,{variant:`ghost`,size:`sm`,title:`Copy URL`,onClick:()=>Q(`URL`,t),children:(0,x.jsx)(o,{className:`h-3.5 w-3.5`})}),(0,x.jsx)(m,{variant:`ghost`,size:`sm`,title:`Copy <iframe> embed`,onClick:()=>Q(`iframe snippet`,ye(e.slug)),children:(0,x.jsx)(ae,{className:`h-3.5 w-3.5`})}),(0,x.jsx)(m,{variant:`ghost`,size:`sm`,title:`Copy React snippet`,onClick:()=>Q(`React snippet`,be(e.slug)),children:(0,x.jsx)(re,{className:`h-3.5 w-3.5`})}),(0,x.jsx)(m,{variant:`ghost`,size:`sm`,title:`Edit sharing & post-submit behavior`,onClick:()=>Se(e),children:(0,x.jsx)(pe,{className:`h-3.5 w-3.5`})})]})})]},e.name)})})]})]})]}),(0,x.jsx)(l,{open:ge,onOpenChange:O,children:(0,x.jsxs)(u,{className:`sm:max-w-md`,children:[(0,x.jsxs)(d,{children:[(0,x.jsx)(s,{children:`Publish a FormView`}),(0,x.jsxs)(v,{children:[`Pick an existing FormView and turn it into a public form by enabling `,(0,x.jsx)(`code`,{className:`text-xs`,children:`sharing.allowAnonymous`}),` `,`and setting `,(0,x.jsx)(`code`,{className:`text-xs`,children:`publicLink`}),`.`]})]}),(0,x.jsxs)(`div`,{className:`space-y-3`,children:[(0,x.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,x.jsx)(_,{htmlFor:`publish-view`,children:`FormView`}),(0,x.jsxs)(`select`,{id:`publish-view`,className:`flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm`,value:k,onChange:e=>A(e.target.value),children:[(0,x.jsx)(`option`,{value:``,children:`— Select a FormView —`}),C.map(e=>(0,x.jsxs)(`option`,{value:e.name,children:[e.label??e.name,` (`,e.name,`) `,e.object?`· ${e.object}`:``]},e.name))]})]}),(0,x.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,x.jsx)(_,{htmlFor:`publish-slug`,children:`URL slug`}),(0,x.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,x.jsx)(`span`,{className:`text-xs text-muted-foreground whitespace-nowrap`,children:`/console/f/`}),(0,x.jsx)(g,{id:`publish-slug`,placeholder:`contact-us`,value:j,onChange:e=>M(e.target.value)})]}),(0,x.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Lowercase letters, digits, dashes and underscores only.`})]})]}),(0,x.jsxs)(a,{children:[(0,x.jsx)(m,{variant:`ghost`,onClick:()=>O(!1),disabled:N,children:`Cancel`}),(0,x.jsx)(m,{onClick:xe,disabled:N||!k||!j,children:N?`Publishing…`:`Publish`})]})]})}),(0,x.jsx)(l,{open:_e,onOpenChange:F,children:(0,x.jsxs)(u,{className:`sm:max-w-lg`,children:[(0,x.jsxs)(d,{children:[(0,x.jsx)(s,{children:I?`Edit ${I.label??I.name}`:`Edit form`}),(0,x.jsx)(v,{children:`Configure the public URL and what happens after submit.`})]}),(0,x.jsxs)(`div`,{className:`space-y-3`,children:[(0,x.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,x.jsx)(_,{htmlFor:`edit-slug`,children:`URL slug`}),(0,x.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,x.jsx)(`span`,{className:`text-xs text-muted-foreground whitespace-nowrap`,children:`/console/f/`}),(0,x.jsx)(g,{id:`edit-slug`,value:R,onChange:e=>z(e.target.value)})]})]}),(0,x.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,x.jsx)(_,{htmlFor:`edit-behavior`,children:`After submit`}),(0,x.jsxs)(`select`,{id:`edit-behavior`,className:`flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm`,value:B,onChange:e=>V(e.target.value),children:[(0,x.jsx)(`option`,{value:`thank-you`,children:`Show a thank-you panel`}),(0,x.jsx)(`option`,{value:`redirect`,children:`Redirect to a URL`}),(0,x.jsx)(`option`,{value:`continue`,children:`Reset for another response`}),(0,x.jsx)(`option`,{value:`next-record`,children:`Advance to next record (internal queues)`})]})]}),B===`thank-you`&&(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,x.jsx)(_,{htmlFor:`edit-tytitle`,children:`Title`}),(0,x.jsx)(g,{id:`edit-tytitle`,placeholder:`Thanks!`,value:H,onChange:e=>U(e.target.value)})]}),(0,x.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,x.jsx)(_,{htmlFor:`edit-tymsg`,children:`Message`}),(0,x.jsx)(g,{id:`edit-tymsg`,placeholder:`Your submission has been received.`,value:W,onChange:e=>G(e.target.value)})]})]}),B===`redirect`&&(0,x.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,x.jsx)(_,{htmlFor:`edit-url`,children:`Redirect URL`}),(0,x.jsx)(g,{id:`edit-url`,type:`url`,placeholder:`https://example.com/thanks`,value:K,onChange:e=>q(e.target.value)})]})]}),(0,x.jsxs)(a,{children:[(0,x.jsx)(m,{variant:`ghost`,onClick:()=>F(!1),disabled:J,children:`Cancel`}),(0,x.jsx)(m,{onClick:Ce,disabled:J||!R,children:J?`Saving…`:`Save`})]})]})})]})}export{C as PublicFormsPage};
|