@objectstack/console 9.2.0 → 9.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{AiPendingActionsPage-B-n-gqzM.js → AiPendingActionsPage-Y9r83gqj.js} +1 -1
- package/dist/assets/{ApiConsolePage-uPTuvhXX.js → ApiConsolePage-Dwbms0Zh.js} +1 -1
- package/dist/assets/{AppManagementPage-CNpBOuFm.js → AppManagementPage-0JEALVYK.js} +1 -1
- package/dist/assets/ApprovalsInboxPage-B-drSsxQ.js +1 -0
- package/dist/assets/{AuditLogPage-_9ECzJM8.js → AuditLogPage-CXhNSVOU.js} +1 -1
- package/dist/assets/{ComponentNavView-CDdExuCL.js → ComponentNavView-BI4O_zkC.js} +1 -1
- package/dist/assets/ConsoleFloatingChatbot-CiODZIcp.js +1 -0
- package/dist/assets/{DeveloperHubPage-mdknfgGp.js → DeveloperHubPage-D-UigRUA.js} +1 -1
- package/dist/assets/FlowRunsPage-_UeeNdBc.js +1 -0
- package/dist/assets/{IntegrationsPage-7SUsLOvq.js → IntegrationsPage-DsWyxKR6.js} +2 -2
- package/dist/assets/{ProfilePage-D4yjFTMG.js → ProfilePage-T27zVrMO.js} +1 -1
- package/dist/assets/PublicFormsPage-Pd453sW6.js +1 -0
- package/dist/assets/{SettingsHub-7kLSZWnI.js → SettingsHub-B4oSx4ed.js} +1 -1
- package/dist/assets/{SettingsView-DqnY47y1.js → SettingsView-CkQEI5DW.js} +1 -1
- package/dist/assets/{SystemHubPage-DeiksJan.js → SystemHubPage-Di6eqozE.js} +1 -1
- package/dist/assets/assistantBus-B-xBT6j1.js +1 -0
- package/dist/assets/{data-adapter-D1EJuDUI.js → data-adapter-3AJO7A2o.js} +1 -1
- package/dist/assets/framework-crD8qZlm.js +34 -0
- package/dist/assets/{highlighted-body-OFNGDK62-Du4wVUV7.js → highlighted-body-OFNGDK62-B3OlR_Nx.js} +1 -1
- package/dist/assets/index-Cf7NsvAk.css +2 -0
- package/dist/assets/index-CiI7zDDo.js +32 -0
- package/dist/assets/{mergeServerFields-CNavewPY.js → mergeServerFields-DUkbynPg.js} +3 -3
- package/dist/assets/mermaid-GHXKKRXX-CBocchJ2.js +1 -0
- package/dist/assets/{plugin-calendar-u9Aa9OAR.js → plugin-calendar-ed7RoEFF.js} +1 -1
- package/dist/assets/{plugin-charts-DSBNwB9E.js → plugin-charts-QabQJ_NJ.js} +2 -2
- package/dist/assets/plugin-chatbot-Cy3tiXkg.js +120 -0
- package/dist/assets/plugin-dashboard-PA0xf59v.js +5 -0
- package/dist/assets/plugin-form-BABEMaum.js +1 -0
- package/dist/assets/plugin-gantt-BNjfLkTR.js +1 -0
- package/dist/assets/plugin-grid-BxyuFeJP.js +6 -0
- package/dist/assets/plugin-kanban-D4yCkUn_.js +1 -0
- package/dist/assets/plugin-map-C8Jxhxs1.js +1 -0
- package/dist/assets/{plugin-markdown-6MvgfANj.js → plugin-markdown-CR5TpghH.js} +1 -1
- package/dist/assets/plugin-report-rz8HUIsi.js +59 -0
- package/dist/assets/{plugin-timeline-DrUpbBdn.js → plugin-timeline-DQHQwtdw.js} +1 -1
- package/dist/assets/plugin-view-BykLknWa.js +1 -0
- package/dist/assets/plugins-views-CBO5qxO-.js +4 -0
- package/dist/assets/{src-s-NNbVef.js → src-Tw2eleSi.js} +1 -1
- package/dist/assets/{types-Decs33Tv.js → types-BkFEpiv3.js} +1 -1
- package/dist/assets/{ui-components-BbPoD3rS.js → ui-components-BrY5joKQ.js} +8 -8
- package/dist/assets/{ui-layout-CWeej0a8.js → ui-layout-KICrO2Oe.js} +1 -1
- package/dist/index.html +4 -4
- package/package.json +1 -1
- package/dist/assets/ApprovalsInboxPage-BFNNZBXy.js +0 -1
- package/dist/assets/ConsoleFloatingChatbot-DThmuzxB.js +0 -1
- package/dist/assets/FlowRunsPage-yleJQxJv.js +0 -1
- package/dist/assets/PublicFormsPage-DWj4wR8t.js +0 -1
- package/dist/assets/assistantBus-Bppk-Y9t.js +0 -1
- package/dist/assets/framework-CHiz03zG.js +0 -34
- package/dist/assets/index-B_NAVTba.js +0 -32
- package/dist/assets/index-DwG7_t-6.css +0 -2
- package/dist/assets/mermaid-GHXKKRXX-D0s_nNwO.js +0 -1
- package/dist/assets/plugin-chatbot-BzJE6C-F.js +0 -120
- package/dist/assets/plugin-dashboard-C5nSNZfG.js +0 -5
- package/dist/assets/plugin-form-DrL6xDfP.js +0 -1
- package/dist/assets/plugin-gantt-aDdnMW0u.js +0 -1
- package/dist/assets/plugin-grid-CSHgWd0O.js +0 -6
- package/dist/assets/plugin-kanban-D45w069C.js +0 -1
- package/dist/assets/plugin-map-ue6Mjnhb.js +0 -1
- package/dist/assets/plugin-report-QmyiWpfC.js +0 -59
- package/dist/assets/plugin-view-DS-dSLs-.js +0 -1
- package/dist/assets/plugins-views-DH1gGZh6.js +0 -4
|
@@ -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{B as r,H as i,lt as a,mt as o,r as s}from"./framework-CHiz03zG.js";import{$a as c,$t as l,Bn as u,Bs as d,Bt as f,Cn as p,Da as m,Dn as h,Dt as g,En as _,Et as v,Fn as y,Gi as b,Hi as x,Hs as S,Ht as C,In as w,Ln as T,Lr as E,Oa as D,Oo as ee,Ot as te,P as O,Pa as ne,Qa as re,Qr as k,Qt as A,Ri as ie,Rn as j,Rt as ae,Sn as M,Ss as N,Ta as P,Tn as oe,U as F,Vi as I,Vt as L,Wa as se,Wn as R,Xs as z,Zn as B,Zs as V,Zt as H,_n as ce,_o as U,an as le,ba as ue,bn as de,br as W,cn as G,dn as fe,en as K,eo as pe,et as me,fn as he,fs as ge,gi as _e,gn as ve,hi as ye,hn as be,hr as xe,ii as Se,in as q,kt as J,mi as Ce,mn as we,nt as Te,on as Ee,oo as De,pn as Oe,pr as Y,ps as X,qr as ke,rt as Ae,si as je,un as Z,vi as Me,vn as Ne,wn as Pe,xi as Fe,xn as Ie,yn as Le,zn as Re,zo as ze,zt as Be}from"./ui-components-BbPoD3rS.js";import{i as Ve}from"./vendor-ui-utils-rQOI1gAo.js";import{t as He}from"./plugin-form-DrL6xDfP.js";import{_ as Ue,a as We,c as Ge,d as Ke,g as qe,h as Je,n as Ye,o as Xe,p as Ze,r as Qe,s as $e,t as et,u as tt}from"./vendor-dndkit-DMFEUxSy.js";import{r as nt}from"./plugin-grid-CSHgWd0O.js";var Q=e(t(),1),$=n(),rt={list:`List`,detail:`Detail`,grid:`Grid`,kanban:`Kanban`,calendar:`Calendar`,timeline:`Timeline`,map:`Map`,gallery:`Gallery`,gantt:`Gantt`},it={list:m,detail:U,grid:c,kanban:ne,calendar:N,timeline:z,map:ue,gallery:se,gantt:Se},at=Ve(`flex gap-4`,{variants:{position:{top:`flex-col`,bottom:`flex-col-reverse`,left:`flex-row`,right:`flex-row-reverse`}},defaultVariants:{position:`top`}}),ot=Ve(`w-full`,{variants:{orientation:{horizontal:`w-full`,vertical:`w-48`}},defaultVariants:{orientation:`horizontal`}}),st=Ve(`flex gap-2`,{variants:{orientation:{horizontal:`flex-row flex-wrap`,vertical:`flex-col`}},defaultVariants:{orientation:`horizontal`}}),ct=Ve(``,{variants:{orientation:{horizontal:``,vertical:`flex h-auto flex-col items-stretch`}},defaultVariants:{orientation:`horizontal`}});function lt(e){return e.split(`-`).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``)}var ut={Home:`House`};function dt(e){if(!e)return null;let t=lt(e);return xe[ut[t]||t]||null}function ft(e){return e.label?e.label:rt[e.type]||e.type}function pt(e){return e.icon?dt(e.icon):it[e.type]||null}function mt(e){return e.activeView?e.activeView:e.defaultView?e.defaultView:e.views?.[0]?.type}var ht={share:Ce,settings:ye,duplicate:ze,delete:E},gt={share:`Share`,settings:`Settings`,duplicate:`Duplicate`,delete:`Delete`},_t=({schema:e,className:t,onViewChange:n,onCreateView:i,onViewAction:a,createViewLabel:o=`Create view`,...s})=>{let c=Q.useMemo(()=>e.storageKey?e.storageKey:`view-switcher${e.id?`-${e.id}`:``}`,[e.id,e.storageKey]),[l,u]=Q.useState(()=>mt(e));Q.useEffect(()=>{if(e.activeView){u(e.activeView);return}if(e.persistPreference)try{let t=localStorage.getItem(c);if(t){let n=e.views.find(e=>e.type===t)?.type;n&&u(n)}}catch{}},[e.activeView,e.persistPreference,e.views,c]),Q.useEffect(()=>{if(!(!e.persistPreference||!l||e.activeView))try{localStorage.setItem(c,l)}catch{}},[l,e.activeView,e.persistPreference,c]);let d=Q.useCallback(t=>{n?.(t),e.onViewChange&&typeof window<`u`&&window.dispatchEvent(new CustomEvent(e.onViewChange,{detail:{view:t}}))},[n,e.onViewChange]),p=Q.useCallback(e=>{u(e),d(e)},[d]),m=l||e.views?.[0]?.type,h=m||``,g=e.views.find(e=>e.type===m)||e.views?.[0],_=e.variant||`tabs`,v=e.position||`top`,y=v===`left`||v===`right`,b=y?`vertical`:`horizontal`,x=e.viewActions&&e.viewActions.length>0?(0,$.jsx)(`div`,{className:`flex items-center gap-1`,children:e.viewActions.map((e,t)=>{let n=e.icon&&dt(e.icon)||ht[e.type];return(0,$.jsx)(Y,{type:`button`,variant:`ghost`,size:`icon`,onClick:()=>a?.(e.type,m),title:gt[e.type]||e.type,children:n?(0,$.jsx)(n,{className:`h-3.5 w-3.5`}):null},`action-${e.type}-${t}`)})}):null,S=e.allowCreateView?(0,$.jsx)(Y,{type:`button`,variant:`ghost`,size:`icon`,onClick:()=>i?.(),title:o,children:(0,$.jsx)(ie,{className:`h-3.5 w-3.5`})}):null,w=(0,$.jsxs)(`div`,{className:V(ot({orientation:b}),`flex items-center gap-1`),children:[_===`dropdown`&&(0,$.jsxs)(ae,{value:h,onValueChange:e=>p(e),children:[(0,$.jsx)(L,{className:V(`w-full`,y?`h-10`:`h-9`),children:(0,$.jsx)(C,{placeholder:`Select view`})}),(0,$.jsx)(Be,{children:e.views.map((e,t)=>(0,$.jsx)(f,{value:e.type,children:ft(e)},`${e.type}-${t}`))})]}),_===`buttons`&&(0,$.jsx)(`div`,{className:V(st({orientation:b})),children:e.views.map((e,t)=>{let n=e.type===m,r=pt(e);return(0,$.jsxs)(Y,{type:`button`,size:`sm`,variant:n?`secondary`:`ghost`,className:V(`justify-start gap-2`,y?`w-full`:``),onClick:()=>p(e.type),children:[r?(0,$.jsx)(r,{className:`h-4 w-4`}):null,(0,$.jsx)(`span`,{children:ft(e)})]},`${e.type}-${t}`)})}),_===`tabs`&&(0,$.jsx)(me,{value:h,onValueChange:e=>p(e),children:(0,$.jsx)(Te,{className:V(ct({orientation:b})),children:e.views.map((e,t)=>{let n=pt(e);return(0,$.jsxs)(Ae,{value:e.type,className:V(`gap-2`,y?`justify-start`:``),children:[n?(0,$.jsx)(n,{className:`h-4 w-4`}):null,(0,$.jsx)(`span`,{children:ft(e)})]},`${e.type}-${t}`)})})}),x,S]}),T=g?.schema?Array.isArray(g.schema)?(0,$.jsx)(`div`,{className:`space-y-4`,children:g.schema.map((e,t)=>(0,$.jsx)(r,{schema:e,...s},`${g.type}-${t}`))}):(0,$.jsx)(r,{schema:g.schema,...s}):null;return(0,$.jsxs)(`div`,{className:V(at({position:v}),t),children:[(0,$.jsx)(`div`,{className:V(`shrink-0`,y?`flex flex-col`:`flex`),children:w}),(0,$.jsx)(`div`,{className:`flex-1 min-w-0`,children:T})]})},vt=r,yt=({schema:e,dataSource:t,className:n,views:r,activeViewId:i,onViewChange:o,onRowClick:s,onEdit:c,renderListView:l,toolbarAddon:d,onCreateView:f,onViewAction:p})=>{let[m,h]=(0,Q.useState)(null),g=(0,Q.useRef)(null);g.current=m;let[_,v]=(0,Q.useState)(!1),[b,x]=(0,Q.useState)(`create`),[S,C]=(0,Q.useState)(null),[E,D]=(0,Q.useState)(0);(0,Q.useEffect)(()=>{if(!(!t?.onMutation||!e.objectName)&&!l)return t.onMutation(t=>{t.resource===e.objectName&&D(e=>e+1)})},[t,e.objectName,l]);let[ee,te]=(0,Q.useState)([]),[ne,re]=(0,Q.useState)(!1),[k,A]=(0,Q.useState)({}),[j,ae]=(0,Q.useState)([]),M=e.listViews,N=M!=null&&Object.keys(M).length>0,[P,oe]=(0,Q.useState)(()=>e.defaultListView&&M?.[e.defaultListView]?e.defaultListView:M&&Object.keys(M)[0]||``),F=(0,Q.useMemo)(()=>!N||!P?null:M[P]||null,[N,P,M]),I=(0,Q.useMemo)(()=>r&&r.length>0?r:null,[r]),L=I!=null&&I.length>0,se=i||I?.[0]?.id,R=I?.find(e=>e.id===se)||I?.[0],z=(0,Q.useMemo)(()=>F?.type?F.type:R?.type?R.type:e.defaultViewType||`grid`,[F,R,e.defaultViewType]),B=e.navigation;(0,Q.useEffect)(()=>{let n=!0;return e.objectName&&t&&(async()=>{try{let r=await t.getObjectSchema(e.objectName);n&&h(r)}catch(e){console.error(`Failed to fetch object schema:`,e)}})(),()=>{n=!1}},[e.objectName,t]),(0,Q.useEffect)(()=>{let n=!0;return(async()=>{if(!l&&z!==`grid`&&!(!t||!e.objectName)){re(!0);try{let r=F?.filter||R?.filter||e.table?.defaultFilters||[],i=Object.entries(k).filter(([,e])=>e!==void 0&&e!==``&&e!==null).map(([e,t])=>[e,`=`,t]),o=[];o=r.length>0&&i.length>0?[`and`,...r,...i]:i.length===1?i[0]:i.length>1?[`and`,...i]:r;let s=j.length>0?j.map(e=>({field:e.field,order:e.direction})):F?.sort||R?.sort||e.table?.defaultSort||void 0,c=a(g.current?.fields),l=await t.find(e.objectName,{$filter:o.length>0?o:void 0,$orderby:s,$top:100,...c.length>0?{$expand:c}:{}}),u=[];Array.isArray(l)?u=l:l&&typeof l==`object`&&(Array.isArray(l.data)?u=l.data:Array.isArray(l.records)?u=l.records:Array.isArray(l.value)&&(u=l.value)),n&&te(u)}catch(e){console.error(`ObjectView data fetch error:`,e)}finally{n&&re(!1)}}})(),()=>{n=!1}},[e.objectName,t,z,k,j,E,F,R,l]);let H=e.layout||`drawer`,U=e.operations||e.table?.operations||{create:!0,read:!0,update:!0,delete:!0},le=(0,Q.useCallback)(()=>{H===`page`&&e.onNavigate?e.onNavigate(`new`,`edit`):(x(`create`),C(null),v(!0))},[H,e]),ue=(0,Q.useCallback)(t=>{if(c){c(t);return}if(H===`page`&&e.onNavigate){let n=t.id||t._id;e.onNavigate(n,`edit`)}else x(`edit`),C(t),v(!0)},[H,e,c]),de=(0,Q.useCallback)(t=>{if(H===`page`&&e.onNavigate){let n=t.id||t._id;e.onNavigate(n,`view`)}else x(`view`),C(t),v(!0)},[H,e]),W=(0,Q.useCallback)(t=>{if(s){s(t);return}if(B){if(B.mode===`none`||B.preventNavigation)return;if(B.mode===`new_window`||B.openNewTab){let n=t.id||t._id,r=`/${e.objectName}/${encodeURIComponent(String(n))}`;window.open(r,`_blank`);return}if(B.mode===`drawer`){x(`view`),C(t),v(!0);return}if(B.mode===`modal`){x(`view`),C(t),v(!0);return}if(B.mode===`page`){let n=t.id||t._id;e.onNavigate&&e.onNavigate(n,`view`);return}if(B.mode===`split`||B.mode===`popover`){x(`view`),C(t),v(!0);return}}U.read!==!1&&de(t)},[s,B,U.read,de,e]),G=(0,Q.useCallback)(e=>{D(e=>e+1)},[]),fe=(0,Q.useCallback)(e=>{D(e=>e+1)},[]),K=(0,Q.useCallback)(()=>{v(!1),C(null),D(e=>e+1)},[]),pe=(0,Q.useCallback)(()=>{v(!1),C(null)},[]);(0,Q.useCallback)(()=>{D(e=>e+1)},[]);let he=(0,Q.useMemo)(()=>!L||!I||I.length<=1?null:{type:`view-switcher`,variant:`tabs`,position:`top`,persistPreference:!0,storageKey:`view-pref-${e.objectName}`,defaultView:R?.type||`grid`,activeView:R?.type||`grid`,views:I.map(e=>({type:e.type,label:e.label,icon:{kanban:`kanban`,calendar:`calendar`,map:`map`,gallery:`layout-grid`,timeline:`activity`,gantt:`gantt-chart`,grid:`table`,list:`list`,detail:`file-text`,chart:`bar-chart-3`}[e.type]||`table`})),allowCreateView:e.allowCreateView,viewActions:e.viewActions},[L,I,R,e.objectName,e.allowCreateView,e.viewActions]),ge=(0,Q.useCallback)(e=>{if(!I)return;let t=I.find(t=>t.type===e);t&&o&&o(t.id)},[I,o]),_e=(0,Q.useCallback)(e=>{oe(e)},[]);(0,Q.useMemo)(()=>{if(e.showFilters===!1)return null;let t=e.filterableFields,n=m?.fields||{},r=(t?t.map(e=>[e,n[e]||{label:e}]):Object.entries(n).filter(([,e])=>!e.hidden).slice(0,8)).map(([e,t])=>{let n=t.type||`text`,r=`text`,i;return n===`number`||n===`currency`||n===`percent`?r=`number`:n===`boolean`||n===`toggle`?r=`boolean`:n===`date`||n===`datetime`?r=`date`:n===`select`||n===`status`||t.options?(r=`select`,i=(t.options||[]).map(e=>typeof e==`string`?{label:e,value:e}:{label:e.label,value:e.value})):(n===`lookup`||n===`master_detail`||n===`user`||n===`owner`)&&t.options&&t.options.length>0&&(r=`multi-select`,i=(t.options||[]).map(e=>typeof e==`string`?{label:e,value:e}:{label:e.label,value:e.value})),{field:e,label:t.label||e,type:r,placeholder:`Filter ${t.label||e}...`,...i?{options:i}:{}}});return r.length===0?null:{type:`filter-ui`,layout:`popover`,showClear:!0,showApply:!0,filters:r,values:k}},[e.showFilters,e.filterableFields,m,k]);let ye=e.showSort;(0,Q.useMemo)(()=>{if(ye===!1)return null;let e=m?.fields||{},t=Object.entries(e).filter(([,e])=>!e.hidden).slice(0,10).map(([e,t])=>({field:e,label:t.label||e}));return t.length===0?null:{type:`sort-ui`,variant:`dropdown`,multiple:!1,fields:t,sort:j}},[m,j,ye]);let xe=(0,Q.useCallback)(t=>{let n={objectName:e.objectName,fields:F?.columns||R?.columns||e.table?.fields,className:`h-full w-full`,showSearch:R?.showSearch??e.showSearch??!1,showSort:R?.showSort??e.showSort??!1,showFilters:R?.showFilters??e.showFilters??!1,striped:R?.striped??!1,bordered:R?.bordered??!1,color:R?.color},r=F?.options||R||{};switch(t){case`kanban`:{let e=r.kanban||{},t=e.groupByField||e.groupField||`status`,i=(Array.isArray(e.columns)&&e.columns.length>0?e.columns:n.fields)||[],{columns:a,groupByField:o,groupField:s,titleField:c,...l}=e;return{type:`object-kanban`,...n,groupBy:t,groupField:t,titleField:e.titleField||`name`,cardFields:i,...l}}case`calendar`:return{type:`object-calendar`,...n,startDateField:r.calendar?.startDateField||`start_date`,endDateField:r.calendar?.endDateField||`end_date`,titleField:r.calendar?.titleField||`name`,...r.calendar||{}};case`gallery`:return{type:`object-gallery`,...n,imageField:r.gallery?.imageField,titleField:r.gallery?.titleField||`name`,subtitleField:r.gallery?.subtitleField,...r.gallery||{}};case`timeline`:return{type:`object-timeline`,...n,dateField:r.timeline?.dateField||`created_at`,titleField:r.timeline?.titleField||`name`,...r.timeline||{}};case`gantt`:return{type:`object-gantt`,...n,startDateField:r.gantt?.startDateField||`start_date`,endDateField:r.gantt?.endDateField||`end_date`,progressField:r.gantt?.progressField||`progress`,dependenciesField:r.gantt?.dependenciesField||`dependencies`,...r.gantt||{}};case`map`:return{type:`object-map`,...n,locationField:r.map?.locationField||`location`,...r.map||{}};case`chart`:{let t=r.chart||{},n=Array.isArray(t.yAxisFields)&&t.yAxisFields[0]||t.valueField||`value`,i=t.xAxisField||t.categoryField||`name`;return{type:`object-chart`,objectName:e.objectName,chartType:t.chartType||`bar`,aggregate:{field:n,function:t.aggregation||`count`,groupBy:i},xAxisKey:i,series:[{dataKey:n,label:n}],className:`h-[400px] w-full`}}default:return null}},[e.objectName,e.table?.fields,F,R]),Se=(0,Q.useMemo)(()=>({type:`object-grid`,objectName:e.objectName,title:e.table?.title,description:e.table?.description,fields:F?.columns||R?.columns||e.table?.fields,columns:F?.columns||R?.columns||e.table?.columns,operations:{...U,create:!1},defaultFilters:F?.filter||R?.filter||e.table?.defaultFilters,defaultSort:F?.sort||R?.sort||e.table?.defaultSort,pageSize:e.table?.pageSize,selectable:e.table?.selectable,striped:R?.striped??e.table?.striped,bordered:R?.bordered??e.table?.bordered,className:e.table?.className}),[e,U,F,R]),q=()=>{let t=S?S.id||S._id:void 0;return{type:`object-form`,objectName:e.objectName,mode:b,recordId:t,title:e.form?.title,description:e.form?.description,fields:e.form?.fields,customFields:e.form?.customFields,groups:e.form?.groups,layout:e.form?.layout,columns:e.form?.columns,showSubmit:e.form?.showSubmit,submitText:e.form?.submitText,showCancel:e.form?.showCancel,cancelText:e.form?.cancelText,showReset:e.form?.showReset,initialValues:e.form?.initialValues,readOnly:e.form?.readOnly||b===`view`,className:e.form?.className,subforms:e.form?.subforms,onSuccess:K,onCancel:pe}},J=()=>{if(e.form?.title)return e.form.title;let t=m?.label||e.objectName;switch(b){case`create`:return`Create ${t}`;case`edit`:return`Edit ${t}`;case`view`:return`View ${t}`;default:return t}},Ce=(0,Q.useMemo)(()=>{let e=B?.width;return e?typeof e==`number`?`max-w-[${e}px]`:`max-w-[${e}]`:``},[B]),we=()=>(0,$.jsx)(be,{open:_,onOpenChange:v,direction:`right`,children:(0,$.jsxs)(ve,{className:V(`w-full sm:max-w-2xl`,Ce),children:[(0,$.jsxs)(Ne,{children:[(0,$.jsx)(Le,{children:J()}),e.form?.description&&(0,$.jsx)(ce,{children:e.form.description})]}),(0,$.jsx)(`div`,{className:`flex-1 overflow-y-auto px-4 pb-4`,children:(0,$.jsx)(He,{schema:q(),dataSource:t})})]})}),Ee=()=>(0,$.jsx)(y,{open:_,onOpenChange:v,children:(0,$.jsxs)(w,{className:V(`max-w-2xl max-h-[90vh] overflow-y-auto`,Ce),children:[(0,$.jsxs)(Re,{children:[(0,$.jsx)(u,{children:J()}),e.form?.description&&(0,$.jsx)(T,{children:e.form.description})]}),(0,$.jsx)(He,{schema:q(),dataSource:t})]})}),De=(0,Q.useMemo)(()=>Object.keys(k).some(e=>k[e]!==void 0&&k[e]!==``&&k[e]!==null)?Object.entries(k).filter(([,e])=>e!==void 0&&e!==``&&e!==null).map(([e,t])=>({field:e,operator:`equals`,value:t})):F?.filter||R?.filter||e.table?.defaultFilters,[k,F,R,e.table?.defaultFilters]),Oe=(0,Q.useMemo)(()=>j.length>0?j:F?.sort||R?.sort||e.table?.defaultSort,[j,F,R,e.table?.defaultSort]),X=()=>{let n=`${e.objectName}-${P||R?.id||`default`}-${z}-${E}`;if(l)return l({schema:{type:`list-view`,objectName:e.objectName,viewType:z,fields:F?.columns||R?.columns||e.table?.fields,filters:De,sort:Oe,rowHeight:R?.rowHeight,densityMode:R?.densityMode,groupBy:R?.groupBy,groupBy2:R?.groupBy2,grouping:R?.grouping,options:F?.options||R,showSearch:R?.showSearch??e.showSearch,showFilters:R?.showFilters??e.showFilters,showSort:R?.showSort??e.showSort,showHideFields:R?.showHideFields??e.showHideFields,showGroup:R?.showGroup??e.showGroup,showColor:R?.showColor??e.showColor,showDensity:R?.showDensity??e.showDensity,compactToolbar:R?.compactToolbar??e.compactToolbar,allowExport:R?.allowExport??e.allowExport,striped:R?.striped??e.striped,bordered:R?.bordered??e.bordered,color:R?.color??e.color,inlineEdit:R?.inlineEdit??e.inlineEdit,wrapHeaders:R?.wrapHeaders??e.wrapHeaders,clickIntoRecordDetails:R?.clickIntoRecordDetails??e.clickIntoRecordDetails,addRecordViaForm:R?.addRecordViaForm??e.addRecordViaForm,addDeleteRecordsInline:R?.addDeleteRecordsInline??e.addDeleteRecordsInline,collapseAllByDefault:R?.collapseAllByDefault??e.collapseAllByDefault,fieldTextColor:R?.fieldTextColor??e.fieldTextColor,prefixField:R?.prefixField??e.prefixField,showDescription:R?.showDescription??e.showDescription,navigation:R?.navigation??e.navigation,selection:R?.selection??e.selection,pagination:R?.pagination??e.pagination,searchableFields:R?.searchableFields??e.searchableFields,filterableFields:R?.filterableFields??e.filterableFields,resizable:R?.resizable??e.resizable,hiddenFields:R?.hiddenFields??e.hiddenFields,rowActions:R?.rowActions??e.rowActions,rowActionDefs:R?.rowActionDefs??e.rowActionDefs,bulkActions:R?.bulkActions??e.bulkActions,sharing:R?.sharing??e.sharing,addRecord:R?.addRecord??e.addRecord,conditionalFormatting:R?.conditionalFormatting??e.conditionalFormatting,quickFilters:R?.quickFilters??e.quickFilters,userFilters:R?.userFilters??e.userFilters,showRecordCount:R?.showRecordCount??e.showRecordCount,allowPrinting:R?.allowPrinting??e.allowPrinting,virtualScroll:R?.virtualScroll??e.virtualScroll,emptyState:R?.emptyState??e.emptyState,aria:R?.aria??e.aria,tabs:e.tabs,refreshTrigger:E},dataSource:t,onEdit:ue,onRowClick:W,className:`h-full`,refreshKey:E});if(z!==`grid`){let e=xe(z);if(e&&vt)return(0,$.jsx)(vt,{schema:e,dataSource:t,data:ee,loading:ne},n);if(!vt)return(0,$.jsx)(`div`,{className:`flex items-center justify-center h-40 text-muted-foreground`,children:(0,$.jsxs)(`p`,{children:[`SchemaRenderer not available. Install @object-ui/react to render `,z,` views.`]})})}return(0,$.jsx)(nt,{schema:Se,dataSource:t,onRowClick:W,onEdit:U.update===!1?void 0:ue,onDelete:U.delete===!1?void 0:G,onBulkDelete:U.delete===!1?void 0:fe},n)},ke=()=>{if(!N)return null;let e=Object.entries(M);return e.length<=1?null:(0,$.jsx)(me,{value:P,onValueChange:_e,className:`w-full`,children:(0,$.jsx)(Te,{className:`w-auto`,children:e.map(([e,t])=>(0,$.jsx)(Ae,{value:e,className:`text-sm`,children:t.label||e},e))})})},je=()=>{let t=e.showCreate!==!1&&U.create!==!1,n=e.showViewSwitcher===!0,r=ke();return!r&&!n&&!t&&!d?null:(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[r,(n||t||d)&&(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:n&&he&&(0,$.jsx)(_t,{schema:he,onViewChange:ge,onCreateView:f,onViewAction:p,className:`overflow-x-auto`})}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[d,t&&(0,$.jsxs)(Y,{size:`sm`,onClick:le,children:[(0,$.jsx)(ie,{className:`h-4 w-4`}),`Create`]})]})]})]})},Z=B?.mode===`modal`?`modal`:B?.mode===`drawer`?`drawer`:B?.mode===`split`?`split`:B?.mode===`popover`?`popover`:H,Me=e=>(0,$.jsx)(`div`,{className:`space-y-3`,children:(0,$.jsx)(He,{schema:q(),dataSource:t})}),Pe=(0,Q.useCallback)(e=>{e||pe()},[pe]);if(Z===`split`){let t=m?.label||e.objectName;return(0,$.jsxs)(`div`,{className:V(`flex flex-col h-full min-w-0 overflow-hidden`,n),children:[(e.title||e.description)&&(0,$.jsxs)(`div`,{className:`mb-4 shrink-0`,children:[e.title&&(0,$.jsx)(`h2`,{className:`text-2xl font-bold tracking-tight`,children:e.title}),e.description&&(0,$.jsx)(`p`,{className:`text-muted-foreground mt-1`,children:e.description})]}),(0,$.jsx)(`div`,{className:`mb-4 shrink-0`,children:je()}),(0,$.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:_&&S?(0,$.jsx)(O,{isOpen:_,selectedRecord:S,mode:`split`,close:pe,setIsOpen:Pe,width:B?.width,isOverlay:!0,title:`${t} Detail`,mainContent:(0,$.jsx)(`div`,{className:`h-full overflow-auto`,children:X()}),children:Me}):X()})]})}return(0,$.jsxs)(`div`,{className:V(`flex flex-col h-full min-w-0 overflow-hidden`,n),children:[(e.title||e.description)&&(0,$.jsxs)(`div`,{className:`mb-4 shrink-0`,children:[e.title&&(0,$.jsx)(`h2`,{className:`text-2xl font-bold tracking-tight`,children:e.title}),e.description&&(0,$.jsx)(`p`,{className:`text-muted-foreground mt-1`,children:e.description})]}),(0,$.jsx)(`div`,{className:`mb-4 shrink-0`,children:je()}),(0,$.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:X()}),Z===`drawer`&&we(),Z===`modal`&&Ee(),Z===`popover`&&_&&S&&(0,$.jsx)(O,{isOpen:_,selectedRecord:S,mode:`popover`,close:pe,setIsOpen:Pe,width:B?.width,isOverlay:!0,title:J(),children:Me})]})},bt=Ve(`flex`,{variants:{layout:{inline:`flex-col space-y-4`,popover:`items-center`,drawer:`items-center`}},defaultVariants:{layout:`inline`}}),xt=e=>e==null||e===``?!0:Array.isArray(e)?e.length===0:typeof e==`object`?Object.values(e).every(e=>e==null||e===``):!1,St=e=>Array.isArray(e)?{start:e[0]||``,end:e[1]||``}:e&&typeof e==`object`?{start:e.start||``,end:e.end||``}:{start:``,end:``},Ct=({schema:e,className:t,onChange:n})=>{let[r,i]=Q.useState(e.values||{}),[a,o]=Q.useState(!1);Q.useEffect(()=>{e.values&&i(e.values)},[e.values]);let s=Q.useCallback(t=>{n?.(t),e.onChange&&typeof window<`u`&&window.dispatchEvent(new CustomEvent(e.onChange,{detail:{values:t}}))},[n,e.onChange]),c=Q.useCallback((t,n)=>{let a={...r,[t]:n};i(a),e.showApply||s(a)},[s,e.showApply,r]),u=Q.useCallback(()=>{let t={};if(i(t),e.showApply){s(t);return}s(t)},[s,e.showApply]),d=Q.useCallback(()=>{s(r),o(!1)},[s,r]),p=Q.useMemo(()=>Object.values(r).filter(e=>!xt(e)).length,[r]),m=e=>{let t=e.label||e.field,n=e.placeholder||`Filter by ${t}`;switch(e.type){case`number`:return(0,$.jsx)(K,{type:`number`,value:r[e.field]??``,placeholder:n,onChange:t=>{let n=t.target.value,r=n===``?``:Number(n);c(e.field,r)}});case`select`:return(0,$.jsxs)(ae,{value:r[e.field]===void 0?``:String(r[e.field]),onValueChange:t=>{let n=e.options?.find(e=>String(e.value)===t);c(e.field,n?n.value:t)},children:[(0,$.jsx)(L,{children:(0,$.jsx)(C,{placeholder:n})}),(0,$.jsx)(Be,{children:e.options?.map(e=>(0,$.jsx)(f,{value:String(e.value),children:e.label},String(e.value)))})]});case`multi-select`:{let t=r[e.field],n=Array.isArray(t)?t:t?[t]:[];return(0,$.jsx)(`div`,{className:`max-h-40 overflow-y-auto space-y-0.5 border rounded-md p-2`,children:e.options?.map(t=>{let r=n.map(String).includes(String(t.value));return(0,$.jsxs)(`label`,{className:V(`flex items-center gap-2 text-sm py-1 px-1.5 rounded cursor-pointer`,r?`bg-primary/5 text-primary`:`hover:bg-muted`),children:[(0,$.jsx)(R,{checked:r,onCheckedChange:r=>{let i=r?[...n,t.value]:n.filter(e=>String(e)!==String(t.value));c(e.field,i)}}),(0,$.jsx)(`span`,{className:`truncate`,children:t.label})]},String(t.value))})})}case`date`:return(0,$.jsx)(K,{type:`date`,value:r[e.field]??``,onChange:t=>c(e.field,t.target.value)});case`date-range`:{let t=St(r[e.field]);return(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(K,{type:`date`,value:t.start??``,onChange:n=>{c(e.field,{...t,start:n.target.value})}}),(0,$.jsx)(K,{type:`date`,value:t.end??``,onChange:n=>{c(e.field,{...t,end:n.target.value})}})]})}case`boolean`:return(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(R,{checked:!!r[e.field],onCheckedChange:t=>c(e.field,!!t)}),(0,$.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:`Enabled`})]});default:return(0,$.jsx)(K,{value:r[e.field]??``,placeholder:n,onChange:t=>c(e.field,t.target.value)})}},h=(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:e.filters.map(e=>(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(q,{className:`text-xs text-muted-foreground`,children:e.label||e.field}),m(e)]},e.field))}),(e.showApply||e.showClear)&&(0,$.jsxs)(`div`,{className:`flex items-center justify-end gap-2 border-t pt-3`,children:[e.showClear&&(0,$.jsx)(Y,{type:`button`,variant:`ghost`,size:`sm`,onClick:u,children:`Clear`}),e.showApply&&(0,$.jsx)(Y,{type:`button`,size:`sm`,onClick:d,children:`Apply`})]})]}),g=e.layout||`inline`;return g===`popover`?(0,$.jsx)(`div`,{className:V(bt({layout:g}),t),children:(0,$.jsxs)(H,{open:a,onOpenChange:o,children:[(0,$.jsx)(l,{asChild:!0,children:(0,$.jsxs)(Y,{type:`button`,variant:p>0?`secondary`:`outline`,size:`sm`,className:`gap-2`,children:[(0,$.jsx)(je,{className:`h-4 w-4`}),`Filters`,p>0&&(0,$.jsx)(`span`,{className:`inline-flex h-5 min-w-[20px] items-center justify-center rounded-full bg-primary/10 px-1 text-xs font-medium text-primary`,children:p})]})}),(0,$.jsx)(A,{align:`start`,className:`w-[520px] p-4`,children:h})]})}):g===`drawer`?(0,$.jsxs)(`div`,{className:V(bt({layout:g}),t),children:[(0,$.jsxs)(Y,{type:`button`,variant:p>0?`secondary`:`outline`,size:`sm`,className:`gap-2`,onClick:()=>o(!0),children:[(0,$.jsx)(je,{className:`h-4 w-4`}),`Filters`,p>0&&(0,$.jsx)(`span`,{className:`inline-flex h-5 min-w-[20px] items-center justify-center rounded-full bg-primary/10 px-1 text-xs font-medium text-primary`,children:p})]}),(0,$.jsx)(be,{open:a,onOpenChange:o,children:(0,$.jsxs)(ve,{children:[(0,$.jsxs)(Ne,{children:[(0,$.jsx)(Le,{children:`Filters`}),(0,$.jsx)(ce,{children:`Refine the data with advanced filters.`})]}),(0,$.jsx)(`div`,{className:`px-4 pb-6`,children:h})]})})]}):(0,$.jsxs)(`div`,{className:V(bt({layout:g}),t),children:[h,!e.showApply&&e.showClear&&(0,$.jsxs)(Y,{type:`button`,variant:`ghost`,size:`sm`,className:`gap-2`,onClick:u,children:[(0,$.jsx)(W,{className:`h-3.5 w-3.5`}),`Clear filters`]})]})},wt=Ve(``,{variants:{variant:{buttons:`flex flex-wrap gap-2`,dropdown:`flex flex-wrap items-center gap-3`,builder:`space-y-3`}},defaultVariants:{variant:`dropdown`}}),Tt=e=>e?e.map(e=>({field:e.field,direction:e.direction})):[],Et=e=>e.map(e=>({id:`${e.field}-${e.direction}`,field:e.field,order:e.direction})),Dt=e=>e.filter(e=>e.field).map(e=>({field:e.field,direction:e.order})),Ot=({schema:e,className:t,onChange:n})=>{let[r,i]=Q.useState(()=>Tt(e.sort)),[a,o]=Q.useState(()=>Et(Tt(e.sort)));Q.useEffect(()=>{let t=Tt(e.sort);i(t),o(Et(t))},[e.sort]);let s=Q.useCallback(t=>{i(t),n?.(t),e.onChange&&typeof window<`u`&&window.dispatchEvent(new CustomEvent(e.onChange,{detail:{sort:t}}))},[n,e.onChange]),c=Q.useCallback(t=>{let n=r.find(e=>e.field===t),i=!!e.multiple;if(!n){s(i?[...r,{field:t,direction:`asc`}]:[{field:t,direction:`asc`}]);return}if(n.direction===`asc`){s(r.map(e=>e.field===t?{...e,direction:`desc`}:e));return}s(r.filter(e=>e.field!==t))},[s,e.multiple,r]);if((e.variant||`dropdown`)===`buttons`)return(0,$.jsx)(`div`,{className:V(wt({variant:`buttons`}),t),children:e.fields.map(e=>{let t=r.find(t=>t.field===e.field);return(0,$.jsxs)(Y,{type:`button`,variant:t?`secondary`:`outline`,size:`sm`,onClick:()=>c(e.field),className:`gap-2`,children:[(0,$.jsx)(`span`,{children:e.label||e.field}),t&&(0,$.jsx)(d,{className:V(`h-3.5 w-3.5 motion-safe:transition-transform motion-safe:duration-200`,t.direction===`desc`&&`rotate-180`),"aria-label":t.direction===`asc`?`ascending`:`descending`})]},e.field)})});if(e.multiple)return(0,$.jsx)(`div`,{className:V(wt({variant:`builder`}),t),children:(0,$.jsx)(F,{fields:e.fields.map(e=>({value:e.field,label:e.label||e.field})),value:a,onChange:e=>{o(e),s(Dt(e))}})});let l=r[0];return(0,$.jsxs)(`div`,{className:V(wt({variant:`dropdown`}),t),children:[(0,$.jsxs)(ae,{value:l?.field||``,onValueChange:e=>{if(!e){s([]);return}s([{field:e,direction:l?.direction||`asc`}])},children:[(0,$.jsx)(L,{className:`w-56`,children:(0,$.jsx)(C,{placeholder:`Select field`})}),(0,$.jsx)(Be,{children:e.fields.map(e=>(0,$.jsx)(f,{value:e.field,children:e.label||e.field},e.field))})]}),(0,$.jsxs)(ae,{value:l?.direction||`asc`,onValueChange:e=>{l?.field&&s([{field:l.field,direction:e}])},children:[(0,$.jsx)(L,{className:`w-36`,children:(0,$.jsx)(C,{})}),(0,$.jsxs)(Be,{children:[(0,$.jsx)(f,{value:`asc`,children:`Ascending`}),(0,$.jsx)(f,{value:`desc`,children:`Descending`})]})]})]})};function kt(){if(typeof crypto<`u`&&typeof crypto.randomUUID==`function`)return crypto.randomUUID();if(typeof crypto<`u`&&typeof crypto.getRandomValues==`function`){let e=new Uint8Array(16);return crypto.getRandomValues(e),Array.from(e,e=>e.toString(16).padStart(2,`0`)).join(``)}return Math.random().toString(36).slice(2)+Math.random().toString(36).slice(2)}function At(e,t,n,r){return`${e}/share/${t}/${n}?mode=readonly&token=${r}`}var jt=({objectName:e,viewId:t=`default`,baseUrl:n,onShare:r,className:i})=>{let[a,o]=Q.useState(null),[s,c]=Q.useState(!1),[u,d]=Q.useState(!1),[f,p]=Q.useState(``),[m,h]=Q.useState(``),g=n??(typeof window<`u`?window.location.origin:``),_=Q.useCallback(()=>{let n=At(g,e,t,kt());o(n),c(!1);let i=m?new Date(Date.now()+parseInt(m,10)*864e5).toISOString():void 0;r?.(n,{password:f||void 0,expiresAt:i})},[g,e,t,r,f,m]),v=Q.useCallback(async()=>{if(a)try{await navigator.clipboard.writeText(a),c(!0),setTimeout(()=>c(!1),2e3)}catch{let e=document.createElement(`textarea`);e.value=a,document.body.appendChild(e),e.select(),document.execCommand(`copy`),document.body.removeChild(e),c(!0),setTimeout(()=>c(!1),2e3)}},[a]);return(0,$.jsxs)(H,{open:u,onOpenChange:d,children:[(0,$.jsx)(l,{asChild:!0,children:(0,$.jsxs)(Y,{variant:`outline`,size:`sm`,className:V(`gap-2`,i),children:[(0,$.jsx)(Ce,{className:`h-4 w-4`}),`Share`]})}),(0,$.jsxs)(A,{className:`w-96 space-y-4`,align:`end`,children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`h4`,{className:`text-sm font-medium`,children:`Share View`}),(0,$.jsx)(B,{variant:`secondary`,className:`text-xs`,children:`Read-only`})]}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Generate a public link to share this view. Recipients can view data without logging in.`})]}),a?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(K,{value:a,readOnly:!0,className:`h-8 text-xs`,onClick:e=>e.target.select()}),(0,$.jsx)(Y,{variant:`outline`,size:`sm`,onClick:v,className:`shrink-0 gap-1`,children:s?(0,$.jsx)(X,{className:`h-4 w-4 text-green-500`}):(0,$.jsx)(ze,{className:`h-4 w-4`})})]}),(f||m)&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[f&&(0,$.jsxs)(B,{variant:`outline`,className:`text-xs gap-1`,children:[(0,$.jsx)(P,{className:`h-3 w-3`}),`Password protected`]}),m&&(0,$.jsxs)(B,{variant:`outline`,className:`text-xs gap-1`,children:[(0,$.jsx)(N,{className:`h-3 w-3`}),`Expires in `,m,` day`,m===`1`?``:`s`]})]})]}):(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs font-medium text-foreground`,children:[(0,$.jsx)(P,{className:`h-3.5 w-3.5`}),`Password protection (optional)`]}),(0,$.jsx)(K,{type:`password`,value:f,onChange:e=>p(e.target.value),placeholder:`Enter password...`,className:`h-8 text-xs`})]}),(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs font-medium text-foreground`,children:[(0,$.jsx)(N,{className:`h-3.5 w-3.5`}),`Expires after (optional)`]}),(0,$.jsxs)(`select`,{value:m,onChange:e=>h(e.target.value),className:`w-full h-8 text-xs rounded-md border border-input bg-background px-3`,children:[(0,$.jsx)(`option`,{value:``,children:`Never`}),(0,$.jsx)(`option`,{value:`1`,children:`1 day`}),(0,$.jsx)(`option`,{value:`7`,children:`7 days`}),(0,$.jsx)(`option`,{value:`30`,children:`30 days`}),(0,$.jsx)(`option`,{value:`90`,children:`90 days`})]})]}),(0,$.jsxs)(Y,{onClick:_,className:`w-full gap-2`,size:`sm`,children:[(0,$.jsx)(Ce,{className:`h-4 w-4`}),`Generate Link`]})]})]})]})};function Mt(){try{let{t:e}=s();return(t,n,r)=>{let i=e(t,r);return!i||i===t?n:i}}catch{return(e,t)=>t}}var Nt={private:0,team:1,organization:2,public:3},Pt=8,Ft=({id:e,disabled:t,children:n})=>{let{attributes:r,listeners:i,setNodeRef:a,transform:o,transition:s,isDragging:c}=Xe({id:e,disabled:t,attributes:{role:`tab`,roleDescription:`view tab`,tabIndex:0}});return(0,$.jsx)($.Fragment,{children:n({setNodeRef:a,style:{transform:Ue.Transform.toString(o),transition:s,zIndex:c?10:void 0,opacity:c?.5:void 0},listeners:i,attributes:r,isDragging:c})})},It=({views:e,activeViewId:t,onViewChange:n,viewTypeIcons:r={},config:i={},onAddView:a,onRenameView:o,onDuplicateView:s,onDeleteView:c,onSetDefaultView:l,onShareView:u,onSaveAsView:d,onPinView:f,onReorderViews:m,onChangeViewType:y,onConfigView:C,onManageViews:w,availableViewTypes:T,hasUnsavedChanges:O=!1,onResetChanges:A,className:j})=>{let{showAddButton:ae=!0,inlineRename:N=!0,contextMenu:F=!0,reorderable:L=!1,maxVisibleTabs:se=4,showIndicators:R=!0,showSaveAsView:z=!0,showPinnedSection:B=!0,showVisibilityGroups:H=!1}=i,ce=Mt(),[U,ue]=(0,Q.useState)(null),[W,me]=(0,Q.useState)(``),ve=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{U&&ve.current&&(ve.current.focus(),ve.current.select())},[U]);let ye=(0,Q.useCallback)(t=>{if(!N||!o)return;let n=e.find(e=>e.id===t);n&&(n.readonly||(ue(t),me(n.label)))},[N,o,e]),be=(0,Q.useCallback)(()=>{U&&W.trim()&&o&&o(U,W.trim()),ue(null),me(``)},[U,W,o]),xe=(0,Q.useCallback)(()=>{ue(null),me(``)},[]),Se=(0,Q.useMemo)(()=>e.length>0&&e.every(e=>!!e.readonly),[e]),q=(0,Q.useMemo)(()=>{let t=[...e];return t.sort((e,t)=>{if(B){let n=+!!e.isPinned,r=+!!t.isPinned;if(n!==r)return r-n}if(H){let n=Nt[e.visibility||`public`]??Nt.public,r=Nt[t.visibility||`public`]??Nt.public;if(n!==r)return n-r}return 0}),t},[e,B,H]),{visibleViews:Te,overflowViews:X}=(0,Q.useMemo)(()=>{let e=q.slice(0,se),n=q.slice(se),r=n.findIndex(e=>e.id===t);if(r===-1)return{visibleViews:e,overflowViews:n};let i=n[r],a=e.length>0?[...e.slice(0,-1),i]:[i],o=e.length>0?e[e.length-1]:null,s=n.filter((e,t)=>t!==r);return o&&s.unshift(o),{visibleViews:a,overflowViews:s}},[q,se,t]),Ae=qe(Je(Ke,{activationConstraint:{distance:Pt}}),Je(tt)),je=(0,Q.useCallback)(e=>{let{active:t,over:n}=e;if(!n||t.id===n.id||!m)return;let r=q.findIndex(e=>e.id===t.id),i=q.findIndex(e=>e.id===n.id);r===-1||i===-1||m(Ye(q,r,i).map(e=>e.id))},[q,m]),Me=ke,Ne=(0,Q.useCallback)(e=>{if(!H||e===0)return!1;let t=Te[e-1],n=Te[e],r=e=>e.visibility===`private`;return r(t)&&!r(n)},[H,Te]),Le=(e,i)=>{let a=e.id===t,d=r[e.type]||Me,ee=U===e.id,te=R&&(e.hasActiveFilters||e.hasActiveSort),O=Ne(i),A=!!e.readonly,ie=(e=>H?e.visibility===`private`?(0,$.jsx)(P,{"data-testid":`view-tab-visibility-${e.id}`,className:`h-3 w-3 text-muted-foreground shrink-0`}):e.visibility?(0,$.jsx)(pe,{"data-testid":`view-tab-visibility-${e.id}`,className:`h-3 w-3 text-muted-foreground shrink-0`}):null:null)(e),j=t=>(0,$.jsxs)(`div`,{"data-testid":`view-tab-${e.id}`,role:`tab`,tabIndex:0,"aria-selected":a,onClick:()=>!ee&&n(e.id),onDoubleClick:()=>ye(e.id),onKeyDown:t=>{!ee&&(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),n(e.id))},...t?.listeners??{},...t?.attributes??{},className:V(`group/tab inline-flex items-center gap-1.5 px-3 py-2 text-sm font-medium border-b-2 transition-colors whitespace-nowrap relative outline-none focus-visible:ring-2 focus-visible:ring-ring`,t?.isDragging?`cursor-grabbing`:`cursor-pointer`,a?`border-primary text-primary`:`border-transparent text-muted-foreground hover:text-foreground hover:border-border`),children:[L&&m&&(0,$.jsx)(`span`,{"data-testid":`view-tab-drag-handle-${e.id}`,"aria-hidden":`true`,className:V(`text-muted-foreground transition-opacity pointer-events-none`,`opacity-0 group-hover/tab:opacity-100`,t?.isDragging&&`opacity-100`),children:(0,$.jsx)(re,{className:`h-3 w-3`})}),B&&e.isPinned&&(0,$.jsx)(x,{"data-testid":`view-tab-pin-indicator-${e.id}`,className:`h-3 w-3 text-primary shrink-0`}),ie,(0,$.jsx)(d,{className:`h-3.5 w-3.5`}),ee?(0,$.jsx)(K,{ref:ve,"data-testid":`view-tab-rename-input-${e.id}`,value:W,onChange:e=>me(e.target.value),onBlur:be,onKeyDown:e=>{e.key===`Enter`&&be(),e.key===`Escape`&&xe()},className:`h-5 w-24 px-1 py-0 text-sm border-none focus-visible:ring-1`,onClick:e=>e.stopPropagation()}):(0,$.jsx)(`span`,{children:e.label}),A&&!Se&&(0,$.jsxs)(v,{children:[(0,$.jsx)(J,{asChild:!0,children:(0,$.jsx)(P,{"data-testid":`view-tab-readonly-${e.id}`,"aria-label":ce(`view.readonlyAriaLabel`,`Read-only view`),className:`h-3 w-3 text-muted-foreground shrink-0`})}),(0,$.jsx)(g,{side:`bottom`,className:`text-xs`,children:e.readonlyReason||ce(`view.readonlyTooltip`,`System view — defined in code, read-only.`)})]}),te&&(0,$.jsxs)(v,{children:[(0,$.jsx)(J,{asChild:!0,children:(0,$.jsxs)(`span`,{"data-testid":`view-tab-indicator-${e.id}`,className:`ml-1 inline-flex items-center gap-0.5 h-4 px-1 rounded-full bg-primary/10 text-primary shrink-0`,children:[e.hasActiveFilters&&(0,$.jsx)(De,{className:`h-2.5 w-2.5`}),e.hasActiveSort&&(0,$.jsx)(S,{className:`h-2.5 w-2.5`})]})}),(0,$.jsx)(g,{side:`bottom`,className:`text-xs`,children:[e.hasActiveFilters&&`Active filters`,e.hasActiveSort&&`Active sort`].filter(Boolean).join(`, `)})]}),e.isDefault&&(0,$.jsx)(k,{className:`h-3 w-3 text-amber-500 fill-amber-500 shrink-0`}),a&&(C||o||s||c)&&(0,$.jsxs)(le,{children:[(0,$.jsx)(we,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,"data-testid":`view-tab-actions-${e.id}`,className:`ml-0.5 h-4 w-4 flex items-center justify-center rounded hover:bg-accent shrink-0 opacity-70 hover:opacity-100 transition-opacity`,onClick:e=>e.stopPropagation(),onPointerDown:e=>e.stopPropagation(),onMouseDown:e=>e.stopPropagation(),"aria-label":ce(`view.tabActionsFor`,`View actions for ${e.label}`,{name:e.label}),children:(0,$.jsx)(ge,{className:`h-3 w-3`})})}),(0,$.jsxs)(Ee,{align:`start`,className:`min-w-[180px]`,onClick:e=>e.stopPropagation(),children:[C&&!A&&(0,$.jsxs)(G,{"data-testid":`view-tab-menu-config-${e.id}`,onClick:()=>C(e.id),children:[(0,$.jsx)(_e,{className:`h-4 w-4 mr-2`}),` Edit view config`]}),o&&!A&&(0,$.jsxs)(G,{"data-testid":`view-tab-menu-rename-${e.id}`,onClick:()=>ye(e.id),children:[(0,$.jsx)(b,{className:`h-4 w-4 mr-2`}),` Rename`]}),s&&(0,$.jsxs)(G,{"data-testid":`view-tab-menu-duplicate-${e.id}`,onClick:()=>s(e.id),children:[(0,$.jsx)(ze,{className:`h-4 w-4 mr-2`}),` Duplicate view`]}),u&&(0,$.jsxs)(G,{"data-testid":`view-tab-menu-share-${e.id}`,onClick:()=>u(e.id),children:[(0,$.jsx)(Ce,{className:`h-4 w-4 mr-2`}),` Share view`]}),l&&!A&&(0,$.jsxs)(G,{"data-testid":`view-tab-menu-default-${e.id}`,onClick:()=>l(e.id),children:[(0,$.jsx)(k,{className:`h-4 w-4 mr-2`}),` Set as default`]}),f&&!A&&(0,$.jsx)(G,{"data-testid":`view-tab-menu-pin-${e.id}`,onClick:()=>f(e.id,!e.isPinned),children:e.isPinned?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(I,{className:`h-4 w-4 mr-2`}),` Unpin view`]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(x,{className:`h-4 w-4 mr-2`}),` Pin view`]})}),y&&!A&&T&&T.length>0&&(0,$.jsxs)(fe,{children:[(0,$.jsxs)(Oe,{"data-testid":`view-tab-menu-change-type-${e.id}`,children:[(0,$.jsx)(ne,{className:`h-4 w-4 mr-2`}),` Change view type`]}),(0,$.jsx)(he,{children:T.map(t=>{let n=r[t.type]||Me;return(0,$.jsxs)(G,{"data-testid":`view-tab-menu-type-${e.id}-${t.type}`,disabled:t.type===e.type,onClick:()=>y(e.id,t.type),children:[(0,$.jsx)(n,{className:`h-4 w-4 mr-2`}),(0,$.jsx)(`span`,{children:t.label})]},t.type)})})]}),c&&!A&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Z,{}),(0,$.jsxs)(G,{"data-testid":`view-tab-menu-delete-${e.id}`,onClick:()=>c(e.id),className:`text-destructive focus:text-destructive`,children:[(0,$.jsx)(E,{className:`h-4 w-4 mr-2`}),` Delete view`]})]}),w&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Z,{}),(0,$.jsxs)(G,{"data-testid":`view-tab-menu-manage-${e.id}`,onClick:w,children:[(0,$.jsx)(D,{className:`h-4 w-4 mr-2`}),` Manage all views…`]})]})]})]})]}),ae=t=>!F||ee?t:(0,$.jsxs)(de,{children:[(0,$.jsx)(h,{asChild:!0,children:t}),(0,$.jsxs)(Ie,{children:[o&&!A&&(0,$.jsxs)(M,{"data-testid":`context-menu-rename-${e.id}`,onClick:()=>ye(e.id),children:[(0,$.jsx)(b,{className:`h-4 w-4 mr-2`}),` Rename`]}),s&&(0,$.jsxs)(M,{"data-testid":`context-menu-duplicate-${e.id}`,onClick:()=>s(e.id),children:[(0,$.jsx)(ze,{className:`h-4 w-4 mr-2`}),` Duplicate View`]}),u&&(0,$.jsxs)(M,{"data-testid":`context-menu-share-${e.id}`,onClick:()=>u(e.id),children:[(0,$.jsx)(Ce,{className:`h-4 w-4 mr-2`}),` Share View`]}),l&&!A&&(0,$.jsxs)(M,{"data-testid":`context-menu-default-${e.id}`,onClick:()=>l(e.id),children:[(0,$.jsx)(k,{className:`h-4 w-4 mr-2`}),` Set as Default`]}),f&&!A&&(0,$.jsx)(M,{"data-testid":`context-menu-pin-${e.id}`,onClick:()=>f(e.id,!e.isPinned),children:e.isPinned?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(I,{className:`h-4 w-4 mr-2`}),` Unpin View`]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(x,{className:`h-4 w-4 mr-2`}),` Pin View`]})}),y&&!A&&T&&T.length>0&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(p,{}),(0,$.jsxs)(Pe,{children:[(0,$.jsxs)(_,{"data-testid":`context-menu-change-type-${e.id}`,children:[(0,$.jsx)(ne,{className:`h-4 w-4 mr-2`}),` Change View Type`]}),(0,$.jsx)(oe,{"data-testid":`context-menu-type-submenu-${e.id}`,children:T.map(t=>{let n=r[t.type]||Me;return(0,$.jsxs)(M,{"data-testid":`context-menu-type-${e.id}-${t.type}`,disabled:t.type===e.type,onClick:()=>y(e.id,t.type),children:[(0,$.jsx)(n,{className:`h-4 w-4 mr-2`}),(0,$.jsxs)(`div`,{className:`flex flex-col`,children:[(0,$.jsx)(`span`,{children:t.label}),t.description&&(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:t.description})]})]},t.type)})})]})]}),c&&!A&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(p,{}),(0,$.jsxs)(M,{"data-testid":`context-menu-delete-${e.id}`,onClick:()=>c(e.id),className:`text-destructive focus:text-destructive`,children:[(0,$.jsx)(E,{className:`h-4 w-4 mr-2`}),` Delete View`]})]}),w&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(p,{}),(0,$.jsxs)(M,{"data-testid":`context-menu-manage-${e.id}`,onClick:w,children:[(0,$.jsx)(D,{className:`h-4 w-4 mr-2`}),` Manage all views…`]})]})]})]});return L&&m?(0,$.jsxs)(Q.Fragment,{children:[O&&(0,$.jsx)(`div`,{"data-testid":`view-tab-visibility-separator`,className:`w-px h-5 bg-border mx-1 self-center shrink-0`}),(0,$.jsx)(Ft,{id:e.id,children:({setNodeRef:e,style:t,listeners:n,attributes:r,isDragging:i})=>(0,$.jsx)(`div`,{ref:e,style:t,className:V(`flex`,i&&`z-10`),children:ae(j({listeners:n,attributes:r,isDragging:i}))})})]},e.id):(0,$.jsxs)(Q.Fragment,{children:[O&&(0,$.jsx)(`div`,{"data-testid":`view-tab-visibility-separator`,className:`w-px h-5 bg-border mx-1 self-center shrink-0`}),ae(j())]},e.id)},Re=(0,$.jsx)($.Fragment,{children:Te.map((e,t)=>Le(e,t))});return(0,$.jsx)(te,{children:(0,$.jsxs)(`div`,{"data-testid":`view-tab-bar`,className:V(`flex items-center gap-0.5 -mb-px`,j),children:[L&&m?(0,$.jsx)(Ge,{sensors:Ae,collisionDetection:Ze,onDragEnd:je,children:(0,$.jsx)(et,{items:Te.map(e=>e.id),strategy:Qe,children:(0,$.jsx)(`div`,{"data-testid":`view-tab-sortable-container`,className:`flex items-center gap-0.5`,children:Re})})}):Re,X.length>0&&(0,$.jsxs)(le,{children:[(0,$.jsx)(we,{asChild:!0,children:(0,$.jsxs)(`button`,{"data-testid":`view-tab-overflow`,className:`inline-flex items-center gap-1 px-2 py-2 text-sm text-muted-foreground hover:text-foreground transition-colors`,children:[(0,$.jsx)(ee,{className:`h-4 w-4`}),(0,$.jsxs)(`span`,{className:`text-xs`,children:[X.length,` more`]})]})}),(0,$.jsxs)(Ee,{align:`end`,children:[w&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(G,{"data-testid":`view-tab-overflow-manage`,onClick:w,className:`font-medium`,children:[(0,$.jsx)(D,{className:`h-4 w-4 mr-2`}),` Manage all views…`]}),(0,$.jsx)(Z,{})]}),X.map(e=>{let t=r[e.type]||Me;return(0,$.jsxs)(G,{"data-testid":`view-tab-overflow-${e.id}`,onClick:()=>n(e.id),children:[e.isPinned&&(0,$.jsx)(x,{className:`h-3 w-3 mr-1 text-primary shrink-0`}),(0,$.jsx)(t,{className:`h-4 w-4 mr-2`}),e.label,R&&(e.hasActiveFilters||e.hasActiveSort)&&(0,$.jsxs)(`span`,{className:`ml-auto inline-flex items-center gap-0.5 h-4 px-1 rounded-full bg-primary/10 text-primary`,children:[e.hasActiveFilters&&(0,$.jsx)(De,{className:`h-2.5 w-2.5`}),e.hasActiveSort&&(0,$.jsx)(S,{className:`h-2.5 w-2.5`})]})]},e.id)})]})]}),ae&&a&&(0,$.jsxs)(v,{children:[(0,$.jsx)(J,{asChild:!0,children:(0,$.jsx)(`button`,{"data-testid":`view-tab-add`,onClick:a,className:`inline-flex items-center px-2 py-2 text-muted-foreground hover:text-foreground transition-colors`,children:(0,$.jsx)(ie,{className:`h-4 w-4`})})}),(0,$.jsx)(g,{children:`Add View`})]}),z&&O&&(0,$.jsxs)(`div`,{"data-testid":`view-tab-save-as`,className:`flex items-center gap-1 ml-2 text-xs text-amber-600 dark:text-amber-400`,children:[(0,$.jsx)(Fe,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:`Unsaved changes`}),d&&(0,$.jsx)(Y,{variant:`ghost`,size:`sm`,"data-testid":`view-tab-save-as-btn`,className:`h-6 px-2 text-xs`,onClick:d,children:`Save as View`}),A&&(0,$.jsx)(Y,{variant:`ghost`,size:`sm`,"data-testid":`view-tab-reset-btn`,className:`h-6 px-2 text-xs`,onClick:A,children:`Reset`})]})]})})},Lt=ke,Rt=({view:e,isActive:t,Icon:n,isRenaming:r,onStartRename:i,onCommitRename:a,onCancelRename:o,onRowClick:s,onDelete:c,onDuplicate:l,onSetDefault:u,onSetPinned:d,onConfigView:f})=>{let{attributes:p,listeners:m,setNodeRef:h,transform:_,transition:y,isDragging:S}=Xe({id:e.id}),C={transform:Ue.Transform.toString(_),transition:y,opacity:S?.5:1},w=(0,Q.useRef)(null),[T,D]=(0,Q.useState)(e.label),O=!!e.readonly;(0,Q.useEffect)(()=>{r&&(D(e.label),requestAnimationFrame(()=>{w.current?.focus(),w.current?.select()}))},[r,e.label]);let ne=(0,Q.useCallback)(()=>{let t=T.trim();t&&t!==e.label?a(e.id,t):o()},[T,e.id,e.label,a,o]);return(0,$.jsxs)(`li`,{ref:h,style:C,"data-testid":`manage-views-row-${e.id}`,className:V(`group/row flex items-center gap-2 px-2 py-2 rounded-md border border-transparent`,`hover:bg-accent/50 transition-colors`,t&&`bg-accent/40 border-border`,S&&`shadow-md bg-background border-border z-10`),children:[(0,$.jsx)(`button`,{type:`button`,...p,...m,"aria-label":`Drag to reorder`,"data-testid":`manage-views-drag-${e.id}`,className:`shrink-0 h-6 w-5 flex items-center justify-center text-muted-foreground/40 hover:text-muted-foreground cursor-grab active:cursor-grabbing rounded hover:bg-accent`,onClick:e=>e.stopPropagation(),children:(0,$.jsx)(re,{className:`h-4 w-4`})}),(0,$.jsx)(n,{className:`shrink-0 h-4 w-4 text-muted-foreground`}),(0,$.jsx)(`div`,{className:`flex-1 min-w-0`,onClick:()=>{r||s?.(e.id)},children:r?(0,$.jsx)(K,{ref:w,value:T,onChange:e=>D(e.target.value),onBlur:ne,onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),ne()):e.key===`Escape`&&(e.preventDefault(),o())},onClick:e=>e.stopPropagation(),className:`h-7 text-sm`,"data-testid":`manage-views-rename-input-${e.id}`}):(0,$.jsxs)(`button`,{type:`button`,className:`w-full text-left text-sm font-medium truncate cursor-pointer flex items-center gap-1.5`,onDoubleClick:t=>{t.stopPropagation(),O||i(e.id)},title:e.label,children:[(0,$.jsx)(`span`,{className:`truncate`,children:e.label}),O&&(0,$.jsx)(P,{"aria-label":`Read-only view`,"data-testid":`manage-views-readonly-${e.id}`,className:`h-3 w-3 text-muted-foreground shrink-0`}),e.isDefault&&(0,$.jsxs)(`span`,{className:`ml-1 inline-flex items-center text-[10px] uppercase tracking-wide text-muted-foreground`,title:`Default view`,children:[(0,$.jsx)(k,{className:`h-3 w-3 mr-0.5 fill-current`}),` default`]})]})}),d&&!r&&!O&&(0,$.jsx)(te,{delayDuration:300,children:(0,$.jsxs)(v,{children:[(0,$.jsx)(J,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,"aria-label":e.isPinned?`Unpin view`:`Pin view`,"data-testid":`manage-views-pin-${e.id}`,onClick:t=>{t.stopPropagation(),d(e.id,!e.isPinned)},className:V(`shrink-0 h-7 w-7 inline-flex items-center justify-center rounded hover:bg-accent transition-colors`,e.isPinned?`text-amber-500`:`text-muted-foreground/40 opacity-0 group-hover/row:opacity-100`),children:e.isPinned?(0,$.jsx)(x,{className:`h-4 w-4 fill-current`}):(0,$.jsx)(x,{className:`h-4 w-4`})})}),(0,$.jsx)(g,{side:`top`,children:e.isPinned?`Unpin view`:`Pin view`})]})}),u&&!r&&!e.isDefault&&!O&&(0,$.jsx)(te,{delayDuration:300,children:(0,$.jsxs)(v,{children:[(0,$.jsx)(J,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,"aria-label":`Set as default`,"data-testid":`manage-views-default-${e.id}`,onClick:t=>{t.stopPropagation(),u(e.id)},className:`shrink-0 h-7 w-7 inline-flex items-center justify-center rounded hover:bg-accent text-muted-foreground/40 hover:text-foreground opacity-0 group-hover/row:opacity-100 transition-colors`,children:(0,$.jsx)(k,{className:`h-4 w-4`})})}),(0,$.jsx)(g,{side:`top`,children:`Set as default`})]})}),!r&&(c||l||f||u)&&(0,$.jsxs)(le,{children:[(0,$.jsx)(we,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,"aria-label":`Actions for ${e.label}`,"data-testid":`manage-views-actions-${e.id}`,onClick:e=>e.stopPropagation(),className:`shrink-0 h-7 w-7 inline-flex items-center justify-center rounded hover:bg-accent text-muted-foreground opacity-60 group-hover/row:opacity-100 transition-opacity`,children:(0,$.jsx)(ee,{className:`h-4 w-4`})})}),(0,$.jsxs)(Ee,{align:`end`,className:`min-w-[180px]`,children:[!O&&(0,$.jsxs)(G,{"data-testid":`manage-views-action-rename-${e.id}`,onClick:()=>i(e.id),children:[(0,$.jsx)(b,{className:`h-4 w-4 mr-2`}),` Rename`]}),l&&(0,$.jsxs)(G,{"data-testid":`manage-views-action-duplicate-${e.id}`,onClick:()=>l(e.id),children:[(0,$.jsx)(ze,{className:`h-4 w-4 mr-2`}),` Duplicate`]}),f&&!O&&(0,$.jsxs)(G,{"data-testid":`manage-views-action-config-${e.id}`,onClick:()=>f(e.id),children:[(0,$.jsx)(b,{className:`h-4 w-4 mr-2`}),` Edit configuration…`]}),u&&!e.isDefault&&!O&&(0,$.jsxs)(G,{"data-testid":`manage-views-action-default-${e.id}`,onClick:()=>u(e.id),children:[(0,$.jsx)(k,{className:`h-4 w-4 mr-2`}),` Set as default`]}),d&&!O&&(0,$.jsx)(G,{"data-testid":`manage-views-action-pin-${e.id}`,onClick:()=>d(e.id,!e.isPinned),children:e.isPinned?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(I,{className:`h-4 w-4 mr-2`}),` Unpin`]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(x,{className:`h-4 w-4 mr-2`}),` Pin`]})}),c&&!O&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Z,{}),(0,$.jsxs)(G,{"data-testid":`manage-views-action-delete-${e.id}`,onClick:()=>c(e.id),className:`text-destructive focus:text-destructive`,children:[(0,$.jsx)(E,{className:`h-4 w-4 mr-2`}),` Delete`]})]})]})]}),r&&(0,$.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[(0,$.jsx)(`button`,{type:`button`,"aria-label":`Save name`,onMouseDown:e=>e.preventDefault(),onClick:ne,className:`h-7 w-7 inline-flex items-center justify-center rounded hover:bg-accent text-emerald-600`,children:(0,$.jsx)(X,{className:`h-4 w-4`})}),(0,$.jsx)(`button`,{type:`button`,"aria-label":`Cancel rename`,onMouseDown:e=>e.preventDefault(),onClick:o,className:`h-7 w-7 inline-flex items-center justify-center rounded hover:bg-accent text-muted-foreground`,children:(0,$.jsx)(W,{className:`h-4 w-4`})})]})]})},zt=({open:e,onOpenChange:t,views:n,activeViewId:r,viewTypeIcons:i={},onRename:a,onDelete:o,onDuplicate:s,onSetDefault:c,onSetPinned:l,onReorder:d,onAddView:f,onConfigView:p})=>{let[m,h]=(0,Q.useState)(``),[g,_]=(0,Q.useState)(null),[v,b]=(0,Q.useState)(()=>n.map(e=>e.id));(0,Q.useEffect)(()=>{b(n.map(e=>e.id))},[n]),(0,Q.useEffect)(()=>{e||(_(null),h(``))},[e]);let x=(0,Q.useMemo)(()=>{let e=new Map(n.map(e=>[e.id,e]));return v.map(t=>e.get(t)).filter(Boolean)},[v,n]),S=(0,Q.useMemo)(()=>{if(!m.trim())return x;let e=m.toLowerCase();return x.filter(t=>t.label.toLowerCase().includes(e))},[x,m]),C=qe(Je(Ke,{activationConstraint:{distance:5}}),Je(tt,{coordinateGetter:We})),E=e=>{let{active:t,over:n}=e;if(!n||t.id===n.id)return;let r=v.indexOf(String(t.id)),i=v.indexOf(String(n.id));if(r<0||i<0)return;let a=Ye(v,r,i);b(a),d?.(a)},D=e=>{t(!1),requestAnimationFrame(()=>p?.(e))};return(0,$.jsx)(y,{open:e,onOpenChange:t,children:(0,$.jsxs)(w,{className:`sm:max-w-[560px] p-0 gap-0 overflow-hidden`,"data-testid":`manage-views-dialog`,children:[(0,$.jsxs)(Re,{className:`px-5 pt-5 pb-3`,children:[(0,$.jsx)(u,{className:`text-base`,children:`Manage views`}),(0,$.jsx)(T,{className:`text-xs`,children:`Reorder, rename, pin, or delete every view in this object.`})]}),(0,$.jsx)(`div`,{className:`px-5 pb-3`,children:(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(Me,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground pointer-events-none`}),(0,$.jsx)(K,{value:m,onChange:e=>h(e.target.value),placeholder:`Search views`,className:`pl-8 h-9`,"data-testid":`manage-views-search`})]})}),(0,$.jsx)(`div`,{className:`px-3 pb-3 max-h-[55vh] overflow-y-auto`,"data-testid":`manage-views-list`,children:S.length===0?(0,$.jsx)(`div`,{className:`text-center text-sm text-muted-foreground py-10`,children:`No views match your search.`}):(0,$.jsx)(Ge,{sensors:C,collisionDetection:Ze,onDragEnd:E,children:(0,$.jsx)(et,{items:S.map(e=>e.id),strategy:$e,children:(0,$.jsx)(`ul`,{className:`space-y-0.5`,children:S.map(e=>(0,$.jsx)(Rt,{view:e,Icon:i[e.type]||Lt,isActive:e.id===r,isRenaming:g===e.id,onStartRename:e=>_(e),onCancelRename:()=>_(null),onCommitRename:(e,t)=>{_(null),a?.(e,t)},onDelete:o,onDuplicate:s,onSetDefault:c,onSetPinned:l,onConfigView:p?D:void 0},e.id))})})})}),(0,$.jsxs)(j,{className:`border-t bg-muted/30 px-5 py-3 flex sm:justify-between gap-2`,children:[f?(0,$.jsxs)(Y,{variant:`ghost`,size:`sm`,onClick:()=>{t(!1),requestAnimationFrame(()=>f())},"data-testid":`manage-views-add`,className:`text-sm`,children:[(0,$.jsx)(ie,{className:`h-4 w-4 mr-1.5`}),` Add new view`]}):(0,$.jsx)(`span`,{}),(0,$.jsx)(Y,{size:`sm`,onClick:()=>t(!1),"data-testid":`manage-views-done`,children:`Done`})]})]})})};function Bt(e){let t=(e||``).toLowerCase();return[`integer`,`int`,`float`,`double`,`number`,`currency`,`money`,`percent`,`rating`].includes(t)?`number`:[`date`,`datetime`,`datetime_tz`,`timestamp`,`time`].includes(t)?`date`:[`boolean`,`bool`,`checkbox`,`switch`].includes(t)?`boolean`:[`select`,`picklist`,`single_select`,`multi_select`,`enum`,`status`,`lookup`,`master_detail`,`user`,`owner`].includes(t)?`select`:`text`}function Vt(e){return e.fields?Object.entries(e.fields).filter(([e,t])=>!(e.startsWith(`_`)||t?.hidden)).map(([e,t])=>({value:e,label:t.label||e,type:Bt(t.type),options:t.options,rawType:t.type,rawName:e})):[]}var Ht=new Set([`image`,`image_url`,`photo`,`picture`,`avatar`,`file`,`attachment`,`attachments`,`media`,`url`,`link`]),Ut=[`image`,`photo`,`picture`,`avatar`,`thumbnail`,`thumb`,`logo`,`cover`,`banner`,`icon`,`attachment`];function Wt(e){if(!e)return!1;let t=(e.rawType||e.type||``).toLowerCase();if(Ht.has(t))return!0;let n=(e.rawName||e.name||e.key||e.value||``).toLowerCase();return n?Ut.some(e=>n.includes(e)):!1}var Gt=new Set([`geolocation`,`geo`,`geo_point`,`geopoint`,`location`,`latlng`,`lnglat`]);function Kt(e,t){if(!e)return!1;let n=(e.rawType||e.type||``).toLowerCase();if(Gt.has(n))return!0;let r=(e.rawName||e.name||e.key||e.value||``).toLowerCase();return r?t===`latitude`?/(^|[_-])lat([^a-z]|itude)?($|[_-])/.test(r)||r===`lat`:/(^|[_-])(lng|lon|long)([^a-z]|gitude)?($|[_-])/.test(r)||r===`lng`||r===`lon`:!1}function qt(e,t){if(e.length!==0){for(let n of t){let t=e.find(e=>e.value.toLowerCase().includes(n));if(t)return t.value}return e[0]?.value}}var Jt=[`status`,`stage`,`state`,`priority`,`category`,`type`],Yt=[`start_date`,`startdate`,`due_date`,`duedate`,`event_date`,`date`,`created_at`,`createdat`,`created`],Xt=[`end_date`,`enddate`,`finish_date`,`completion_date`,`closed_at`],Zt=i,Qt=({schema:e})=>(0,$.jsx)(yt,{schema:e,dataSource:(0,Q.useContext)(Zt)?.dataSource??null});o.register(`object-view`,Qt,{namespace:`plugin-view`,label:`Object View`,category:`view`,icon:`LayoutDashboard`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`title`,type:`string`,label:`Title`},{name:`description`,type:`string`,label:`Description`},{name:`layout`,type:`enum`,label:`Form Layout`,enum:[`drawer`,`modal`,`page`]},{name:`defaultViewType`,type:`enum`,label:`Default View Type`,enum:[`grid`,`kanban`,`gallery`,`calendar`,`timeline`,`gantt`,`map`]},{name:`defaultListView`,type:`string`,label:`Default Named View`},{name:`showSearch`,type:`boolean`,label:`Show Search`},{name:`showFilters`,type:`boolean`,label:`Show Filters`},{name:`showCreate`,type:`boolean`,label:`Show Create Button`},{name:`showRefresh`,type:`boolean`,label:`Show Refresh Button`},{name:`showViewSwitcher`,type:`boolean`,label:`Show View Switcher`},{name:`listViews`,type:`object`,label:`Named List Views`},{name:`navigation`,type:`object`,label:`Navigation Config`},{name:`searchableFields`,type:`array`,label:`Searchable Fields`},{name:`filterableFields`,type:`array`,label:`Filterable Fields`}],defaultProps:{layout:`drawer`,defaultViewType:`grid`,showSearch:!0,showFilters:!0,showCreate:!0,showRefresh:!0,showViewSwitcher:!0}}),o.register(`view`,Qt,{namespace:`plugin-view`,label:`View`,category:`view`}),o.register(`view-switcher`,_t,{namespace:`view`,label:`View Switcher`,category:`view`,icon:`LayoutGrid`,inputs:[{name:`views`,type:`array`,label:`Views`,required:!0},{name:`defaultView`,type:`string`,label:`Default View`},{name:`activeView`,type:`string`,label:`Active View`},{name:`variant`,type:`enum`,label:`Variant`,enum:[`tabs`,`buttons`,`dropdown`]},{name:`position`,type:`enum`,label:`Position`,enum:[`top`,`bottom`,`left`,`right`]},{name:`persistPreference`,type:`boolean`,label:`Persist Preference`},{name:`storageKey`,type:`string`,label:`Storage Key`},{name:`onViewChange`,type:`string`,label:`On View Change Event`}],defaultProps:{variant:`tabs`,position:`top`,defaultView:`grid`,views:[{type:`grid`,label:`Grid`,schema:{type:`text`,content:`Grid view`}},{type:`list`,label:`List`,schema:{type:`text`,content:`List view`}}]}}),o.register(`filter-ui`,Ct,{namespace:`view`,label:`Filter UI`,category:`view`,icon:`SlidersHorizontal`,inputs:[{name:`filters`,type:`array`,label:`Filters`,required:!0},{name:`values`,type:`object`,label:`Values`},{name:`onChange`,type:`string`,label:`On Change Event`},{name:`showClear`,type:`boolean`,label:`Show Clear Button`},{name:`showApply`,type:`boolean`,label:`Show Apply Button`},{name:`layout`,type:`enum`,label:`Layout`,enum:[`inline`,`popover`,`drawer`]}],defaultProps:{layout:`inline`,showApply:!1,showClear:!0,filters:[{field:`name`,label:`Name`,type:`text`,placeholder:`Search name`},{field:`status`,label:`Status`,type:`select`,options:[{label:`Open`,value:`open`},{label:`Closed`,value:`closed`}]},{field:`created_at`,label:`Created`,type:`date`}]}}),o.register(`sort-ui`,Ot,{namespace:`view`,label:`Sort UI`,category:`view`,icon:`ArrowUpDown`,inputs:[{name:`fields`,type:`array`,label:`Fields`,required:!0},{name:`sort`,type:`array`,label:`Sort`},{name:`onChange`,type:`string`,label:`On Change Event`},{name:`multiple`,type:`boolean`,label:`Allow Multiple`},{name:`variant`,type:`enum`,label:`Variant`,enum:[`dropdown`,`buttons`]}],defaultProps:{variant:`dropdown`,multiple:!0,fields:[{field:`name`,label:`Name`},{field:`created_at`,label:`Created At`}],sort:[{field:`name`,direction:`asc`}]}}),o.register(`shared-view-link`,jt,{namespace:`view`,label:`Shared View Link`,category:`view`,icon:`Share2`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`viewId`,type:`string`,label:`View ID`},{name:`baseUrl`,type:`string`,label:`Base URL`}],defaultProps:{objectName:`objects`,viewId:`default`}}),o.register(`view:simple`,({schema:e,className:t,children:n,dataSource:r,...i})=>(0,$.jsx)(`div`,{className:t,style:e.props?.columns?{display:`grid`,gridTemplateColumns:`repeat(${e.props.columns}, 1fr)`,gap:`1rem`}:void 0,...i,children:n}),{namespace:`plugin-view`,label:`Simple View`,category:`view`});export{Kt as a,zt as c,Vt as i,It as l,Jt as n,Wt as o,Yt as r,qt as s,Xt as t,yt as u};
|