@object-ui/runner 4.6.0 → 4.7.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.
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/KanbanImpl-BDEKBo0c.js","assets/sortable.esm-BEqMuziS.js","assets/KanbanEnhanced-DRJONZER.js","assets/ChartImpl-VXhwEQF3.js","assets/BarChart-73SHA5Pc.js","assets/AdvancedChartImpl-hdVtuhK5.js"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/KanbanImpl-tQCLvQ8D.js","assets/sortable.esm-pM20z7c8.js","assets/KanbanEnhanced-CWBk63YQ.js","assets/ChartImpl-CsWD-PjU.js","assets/BarChart-BnbK-aHq.js","assets/AdvancedChartImpl-CT2fx0UI.js"])))=>i.map(i=>d[i]);
2
2
  var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),s=(e,n)=>{let r={};for(var i in e)t(r,i,{get:e[i],enumerable:!0});return n||t(r,Symbol.toStringTag,{value:`Module`}),r},c=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},l=(n,r,a)=>(a=n==null?{}:e(i(n)),c(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var u=o((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.portal`),r=Symbol.for(`react.fragment`),i=Symbol.for(`react.strict_mode`),a=Symbol.for(`react.profiler`),o=Symbol.for(`react.consumer`),s=Symbol.for(`react.context`),c=Symbol.for(`react.forward_ref`),l=Symbol.for(`react.suspense`),u=Symbol.for(`react.memo`),d=Symbol.for(`react.lazy`),f=Symbol.for(`react.activity`),p=Symbol.iterator;function m(e){return typeof e!=`object`||!e?null:(e=p&&e[p]||e[`@@iterator`],typeof e==`function`?e:null)}var h={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},g=Object.assign,_={};function v(e,t,n){this.props=e,this.context=t,this.refs=_,this.updater=n||h}v.prototype.isReactComponent={},v.prototype.setState=function(e,t){if(typeof e!=`object`&&typeof e!=`function`&&e!=null)throw Error(`takes an object of state variables to update or a function which returns an object of state variables.`);this.updater.enqueueSetState(this,e,t,`setState`)},v.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,`forceUpdate`)};function y(){}y.prototype=v.prototype;function b(e,t,n){this.props=e,this.context=t,this.refs=_,this.updater=n||h}var x=b.prototype=new y;x.constructor=b,g(x,v.prototype),x.isPureReactComponent=!0;var S=Array.isArray;function C(){}var w={H:null,A:null,T:null,S:null},T=Object.prototype.hasOwnProperty;function E(e,n,r){var i=r.ref;return{$$typeof:t,type:e,key:n,ref:i===void 0?null:i,props:r}}function D(e,t){return E(e.type,t,e.props)}function O(e){return typeof e==`object`&&!!e&&e.$$typeof===t}function k(e){var t={"=":`=0`,":":`=2`};return`$`+e.replace(/[=:]/g,function(e){return t[e]})}var A=/\/+/g;function j(e,t){return typeof e==`object`&&e&&e.key!=null?k(``+e.key):t.toString(36)}function M(e){switch(e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason;default:switch(typeof e.status==`string`?e.then(C,C):(e.status=`pending`,e.then(function(t){e.status===`pending`&&(e.status=`fulfilled`,e.value=t)},function(t){e.status===`pending`&&(e.status=`rejected`,e.reason=t)})),e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason}}throw e}function N(e,r,i,a,o){var s=typeof e;(s===`undefined`||s===`boolean`)&&(e=null);var c=!1;if(e===null)c=!0;else switch(s){case`bigint`:case`string`:case`number`:c=!0;break;case`object`:switch(e.$$typeof){case t:case n:c=!0;break;case d:return c=e._init,N(c(e._payload),r,i,a,o)}}if(c)return o=o(e),c=a===``?`.`+j(e,0):a,S(o)?(i=``,c!=null&&(i=c.replace(A,`$&/`)+`/`),N(o,r,i,``,function(e){return e})):o!=null&&(O(o)&&(o=D(o,i+(o.key==null||e&&e.key===o.key?``:(``+o.key).replace(A,`$&/`)+`/`)+c)),r.push(o)),1;c=0;var l=a===``?`.`:a+`:`;if(S(e))for(var u=0;u<e.length;u++)a=e[u],s=l+j(a,u),c+=N(a,r,i,s,o);else if(u=m(e),typeof u==`function`)for(e=u.call(e),u=0;!(a=e.next()).done;)a=a.value,s=l+j(a,u++),c+=N(a,r,i,s,o);else if(s===`object`){if(typeof e.then==`function`)return N(M(e),r,i,a,o);throw r=String(e),Error(`Objects are not valid as a React child (found: `+(r===`[object Object]`?`object with keys {`+Object.keys(e).join(`, `)+`}`:r)+`). If you meant to render a collection of children, use an array instead.`)}return c}function P(e,t,n){if(e==null)return e;var r=[],i=0;return N(e,r,``,``,function(e){return t.call(n,e,i++)}),r}function F(e){if(e._status===-1){var t=e._result;t=t(),t.then(function(t){(e._status===0||e._status===-1)&&(e._status=1,e._result=t)},function(t){(e._status===0||e._status===-1)&&(e._status=2,e._result=t)}),e._status===-1&&(e._status=0,e._result=t)}if(e._status===1)return e._result.default;throw e._result}var I=typeof reportError==`function`?reportError:function(e){if(typeof window==`object`&&typeof window.ErrorEvent==`function`){var t=new window.ErrorEvent(`error`,{bubbles:!0,cancelable:!0,message:typeof e==`object`&&e&&typeof e.message==`string`?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process==`object`&&typeof process.emit==`function`){process.emit(`uncaughtException`,e);return}console.error(e)},L={map:P,forEach:function(e,t,n){P(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return P(e,function(){t++}),t},toArray:function(e){return P(e,function(e){return e})||[]},only:function(e){if(!O(e))throw Error(`React.Children.only expected to receive a single React element child.`);return e}};e.Activity=f,e.Children=L,e.Component=v,e.Fragment=r,e.Profiler=a,e.PureComponent=b,e.StrictMode=i,e.Suspense=l,e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=w,e.__COMPILER_RUNTIME={__proto__:null,c:function(e){return w.H.useMemoCache(e)}},e.cache=function(e){return function(){return e.apply(null,arguments)}},e.cacheSignal=function(){return null},e.cloneElement=function(e,t,n){if(e==null)throw Error(`The argument must be a React element, but you passed `+e+`.`);var r=g({},e.props),i=e.key;if(t!=null)for(a in t.key!==void 0&&(i=``+t.key),t)!T.call(t,a)||a===`key`||a===`__self`||a===`__source`||a===`ref`&&t.ref===void 0||(r[a]=t[a]);var a=arguments.length-2;if(a===1)r.children=n;else if(1<a){for(var o=Array(a),s=0;s<a;s++)o[s]=arguments[s+2];r.children=o}return E(e.type,i,r)},e.createContext=function(e){return e={$$typeof:s,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null},e.Provider=e,e.Consumer={$$typeof:o,_context:e},e},e.createElement=function(e,t,n){var r,i={},a=null;if(t!=null)for(r in t.key!==void 0&&(a=``+t.key),t)T.call(t,r)&&r!==`key`&&r!==`__self`&&r!==`__source`&&(i[r]=t[r]);var o=arguments.length-2;if(o===1)i.children=n;else if(1<o){for(var s=Array(o),c=0;c<o;c++)s[c]=arguments[c+2];i.children=s}if(e&&e.defaultProps)for(r in o=e.defaultProps,o)i[r]===void 0&&(i[r]=o[r]);return E(e,a,i)},e.createRef=function(){return{current:null}},e.forwardRef=function(e){return{$$typeof:c,render:e}},e.isValidElement=O,e.lazy=function(e){return{$$typeof:d,_payload:{_status:-1,_result:e},_init:F}},e.memo=function(e,t){return{$$typeof:u,type:e,compare:t===void 0?null:t}},e.startTransition=function(e){var t=w.T,n={};w.T=n;try{var r=e(),i=w.S;i!==null&&i(n,r),typeof r==`object`&&r&&typeof r.then==`function`&&r.then(C,I)}catch(e){I(e)}finally{t!==null&&n.types!==null&&(t.types=n.types),w.T=t}},e.unstable_useCacheRefresh=function(){return w.H.useCacheRefresh()},e.use=function(e){return w.H.use(e)},e.useActionState=function(e,t,n){return w.H.useActionState(e,t,n)},e.useCallback=function(e,t){return w.H.useCallback(e,t)},e.useContext=function(e){return w.H.useContext(e)},e.useDebugValue=function(){},e.useDeferredValue=function(e,t){return w.H.useDeferredValue(e,t)},e.useEffect=function(e,t){return w.H.useEffect(e,t)},e.useEffectEvent=function(e){return w.H.useEffectEvent(e)},e.useId=function(){return w.H.useId()},e.useImperativeHandle=function(e,t,n){return w.H.useImperativeHandle(e,t,n)},e.useInsertionEffect=function(e,t){return w.H.useInsertionEffect(e,t)},e.useLayoutEffect=function(e,t){return w.H.useLayoutEffect(e,t)},e.useMemo=function(e,t){return w.H.useMemo(e,t)},e.useOptimistic=function(e,t){return w.H.useOptimistic(e,t)},e.useReducer=function(e,t,n){return w.H.useReducer(e,t,n)},e.useRef=function(e){return w.H.useRef(e)},e.useState=function(e){return w.H.useState(e)},e.useSyncExternalStore=function(e,t,n){return w.H.useSyncExternalStore(e,t,n)},e.useTransition=function(){return w.H.useTransition()},e.version=`19.2.6`})),d=o(((e,t)=>{t.exports=u()})),f=o((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m)if(n(c)!==null)m=!0,S||(S=!0,O());else{var t=n(l);t!==null&&j(x,t.startTime-e)}}var S=!1,C=-1,w=5,T=-1;function E(){return g?!0:!(e.unstable_now()-T<w)}function D(){if(g=!1,S){var t=e.unstable_now();T=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(C),C=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&E());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&j(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?O():S=!1}}}var O;if(typeof y==`function`)O=function(){y(D)};else if(typeof MessageChannel<`u`){var k=new MessageChannel,A=k.port2;k.port1.onmessage=D,O=function(){A.postMessage(null)}}else O=function(){_(D,0)};function j(t,n){C=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):w=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,j(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,O()))),r},e.unstable_shouldYield=E,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),p=o(((e,t)=>{t.exports=f()})),m=o((e=>{var t=d();function n(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function r(){}var i={d:{f:r,r:function(){throw Error(n(522))},D:r,C:r,L:r,m:r,X:r,S:r,M:r},p:0,findDOMNode:null},a=Symbol.for(`react.portal`);function o(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:a,key:r==null?null:``+r,children:e,containerInfo:t,implementation:n}}var s=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function c(e,t){if(e===`font`)return``;if(typeof t==`string`)return t===`use-credentials`?t:``}e.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=i,e.createPortal=function(e,t){var r=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)throw Error(n(299));return o(e,t,null,r)},e.flushSync=function(e){var t=s.T,n=i.p;try{if(s.T=null,i.p=2,e)return e()}finally{s.T=t,i.p=n,i.d.f()}},e.preconnect=function(e,t){typeof e==`string`&&(t?(t=t.crossOrigin,t=typeof t==`string`?t===`use-credentials`?t:``:void 0):t=null,i.d.C(e,t))},e.prefetchDNS=function(e){typeof e==`string`&&i.d.D(e)},e.preinit=function(e,t){if(typeof e==`string`&&t&&typeof t.as==`string`){var n=t.as,r=c(n,t.crossOrigin),a=typeof t.integrity==`string`?t.integrity:void 0,o=typeof t.fetchPriority==`string`?t.fetchPriority:void 0;n===`style`?i.d.S(e,typeof t.precedence==`string`?t.precedence:void 0,{crossOrigin:r,integrity:a,fetchPriority:o}):n===`script`&&i.d.X(e,{crossOrigin:r,integrity:a,fetchPriority:o,nonce:typeof t.nonce==`string`?t.nonce:void 0})}},e.preinitModule=function(e,t){if(typeof e==`string`)if(typeof t==`object`&&t){if(t.as==null||t.as===`script`){var n=c(t.as,t.crossOrigin);i.d.M(e,{crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0})}}else t??i.d.M(e)},e.preload=function(e,t){if(typeof e==`string`&&typeof t==`object`&&t&&typeof t.as==`string`){var n=t.as,r=c(n,t.crossOrigin);i.d.L(e,n,{crossOrigin:r,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,type:typeof t.type==`string`?t.type:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0,referrerPolicy:typeof t.referrerPolicy==`string`?t.referrerPolicy:void 0,imageSrcSet:typeof t.imageSrcSet==`string`?t.imageSrcSet:void 0,imageSizes:typeof t.imageSizes==`string`?t.imageSizes:void 0,media:typeof t.media==`string`?t.media:void 0})}},e.preloadModule=function(e,t){if(typeof e==`string`)if(t){var n=c(t.as,t.crossOrigin);i.d.m(e,{as:typeof t.as==`string`&&t.as!==`script`?t.as:void 0,crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0})}else i.d.m(e)},e.requestFormReset=function(e){i.d.r(e)},e.unstable_batchedUpdates=function(e,t){return e(t)},e.useFormState=function(e,t,n){return s.H.useFormState(e,t,n)},e.useFormStatus=function(){return s.H.useHostTransitionStatus()},e.version=`19.2.6`})),h=o(((e,t)=>{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=m()})),g=o((e=>{var t=p(),n=d(),r=h();function i(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function a(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function o(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function s(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function c(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function l(e){if(o(e)!==e)throw Error(i(188))}function u(e){var t=e.alternate;if(!t){if(t=o(e),t===null)throw Error(i(188));return t===e?e:null}for(var n=e,r=t;;){var a=n.return;if(a===null)break;var s=a.alternate;if(s===null){if(r=a.return,r!==null){n=r;continue}break}if(a.child===s.child){for(s=a.child;s;){if(s===n)return l(a),e;if(s===r)return l(a),t;s=s.sibling}throw Error(i(188))}if(n.return!==r.return)n=a,r=s;else{for(var c=!1,u=a.child;u;){if(u===n){c=!0,n=a,r=s;break}if(u===r){c=!0,r=a,n=s;break}u=u.sibling}if(!c){for(u=s.child;u;){if(u===n){c=!0,n=s,r=a;break}if(u===r){c=!0,r=s,n=a;break}u=u.sibling}if(!c)throw Error(i(189))}}if(n.alternate!==r)throw Error(i(190))}if(n.tag!==3)throw Error(i(188));return n.stateNode.current===n?e:t}function f(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=f(e),t!==null)return t;e=e.sibling}return null}var m=Object.assign,g=Symbol.for(`react.element`),_=Symbol.for(`react.transitional.element`),v=Symbol.for(`react.portal`),y=Symbol.for(`react.fragment`),b=Symbol.for(`react.strict_mode`),x=Symbol.for(`react.profiler`),S=Symbol.for(`react.consumer`),C=Symbol.for(`react.context`),w=Symbol.for(`react.forward_ref`),T=Symbol.for(`react.suspense`),E=Symbol.for(`react.suspense_list`),D=Symbol.for(`react.memo`),O=Symbol.for(`react.lazy`),k=Symbol.for(`react.activity`),A=Symbol.for(`react.memo_cache_sentinel`),j=Symbol.iterator;function M(e){return typeof e!=`object`||!e?null:(e=j&&e[j]||e[`@@iterator`],typeof e==`function`?e:null)}var N=Symbol.for(`react.client.reference`);function P(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===N?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case y:return`Fragment`;case x:return`Profiler`;case b:return`StrictMode`;case T:return`Suspense`;case E:return`SuspenseList`;case k:return`Activity`}if(typeof e==`object`)switch(e.$$typeof){case v:return`Portal`;case C:return e.displayName||`Context`;case S:return(e._context.displayName||`Context`)+`.Consumer`;case w:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case D:return t=e.displayName||null,t===null?P(e.type)||`Memo`:t;case O:t=e._payload,e=e._init;try{return P(e(t))}catch{}}return null}var F=Array.isArray,I=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,L=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ee={pending:!1,data:null,method:null,action:null},te=[],ne=-1;function R(e){return{current:e}}function z(e){0>ne||(e.current=te[ne],te[ne]=null,ne--)}function re(e,t){ne++,te[ne]=e.current,e.current=t}var B=R(null),ie=R(null),ae=R(null),oe=R(null);function V(e,t){switch(re(ae,t),re(ie,e),re(B,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Pd(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Pd(t),e=Fd(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}z(B),re(B,e)}function se(){z(B),z(ie),z(ae)}function ce(e){e.memoizedState!==null&&re(oe,e);var t=B.current,n=Fd(t,e.type);t!==n&&(re(ie,e),re(B,n))}function le(e){ie.current===e&&(z(B),z(ie)),oe.current===e&&(z(oe),Gf._currentValue=ee)}var ue,de;function fe(e){if(ue===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);ue=t&&t[1]||``,de=-1<e.stack.indexOf(`
3
3
  at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
4
4
  `+ue+e+de}var pe=!1;function me(e,t){if(!e||pe)return``;pe=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var r={DetermineComponentFrameRoot:function(){try{if(t){var n=function(){throw Error()};if(Object.defineProperty(n.prototype,`props`,{set:function(){throw Error()}}),typeof Reflect==`object`&&Reflect.construct){try{Reflect.construct(n,[])}catch(e){var r=e}Reflect.construct(e,[],n)}else{try{n.call()}catch(e){r=e}e.call(n.prototype)}}else{try{throw Error()}catch(e){r=e}(n=e())&&typeof n.catch==`function`&&n.catch(function(){})}}catch(e){if(e&&r&&typeof e.stack==`string`)return[e.stack,r.stack]}return[null,null]}};r.DetermineComponentFrameRoot.displayName=`DetermineComponentFrameRoot`;var i=Object.getOwnPropertyDescriptor(r.DetermineComponentFrameRoot,`name`);i&&i.configurable&&Object.defineProperty(r.DetermineComponentFrameRoot,`name`,{value:`DetermineComponentFrameRoot`});var a=r.DetermineComponentFrameRoot(),o=a[0],s=a[1];if(o&&s){var c=o.split(`
@@ -101,7 +101,7 @@ Defaulting to \`null\`.`}var Krt=Lrt,qrt=zrt,Jrt=H.forwardRef(({className:e,valu
101
101
  ${h?`border-primary bg-primary/5 text-primary`:`border-muted-foreground/25 hover:border-primary/50 text-muted-foreground hover:text-foreground`}
102
102
  `,role:`button`,tabIndex:0,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),a.current?.click())},children:[(0,U.jsx)(s$,{className:`size-8 ${h?`text-primary`:`text-muted-foreground`}`}),(0,U.jsxs)(`div`,{className:`text-center`,children:[(0,U.jsx)(`p`,{className:`text-sm font-medium`,children:h?`Drop files here`:`Drag & drop files here`}),(0,U.jsxs)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:[`or click to browse`,m?` • use the camera button below`:``]})]})]}),m&&(0,U.jsxs)(Q,{type:`button`,variant:`outline`,size:`sm`,className:`w-full`,onClick:e=>{e.stopPropagation(),o.current?.click()},"data-testid":`file-field-camera-button`,children:[(0,U.jsx)(Jp,{className:`size-4 mr-2`}),m===`user`?`Take selfie`:`Take photo`]}),S&&(0,U.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,"data-testid":`file-field-uploading`,children:[(0,U.jsx)(GI,{className:`size-3 animate-spin`}),(0,U.jsxs)(`span`,{children:[`Uploading…`,Object.keys(b).length>0&&` (${Math.round(Object.values(b).reduce((e,t)=>e+t,0)/Object.keys(b).length*100)}%)`]})]}),_.length>0&&(0,U.jsx)(`div`,{className:`space-y-0.5`,children:_.map((e,t)=>(0,U.jsx)(`p`,{className:`text-xs text-destructive`,children:e},t))}),w.length>0&&(0,U.jsx)(`div`,{className:`space-y-1`,children:w.map((e,t)=>(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-2 p-2 bg-muted/50 rounded-md border`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2 flex-1 min-w-0`,children:[j(e)&&e.url?(0,U.jsx)(`img`,{src:e.url,alt:e.name,className:`size-8 object-cover rounded shrink-0`}):j(e)?(0,U.jsx)(PN,{className:`size-4 text-muted-foreground shrink-0`}):(0,U.jsx)(bE,{className:`size-4 text-muted-foreground shrink-0`}),(0,U.jsx)(`span`,{className:`text-sm truncate`,children:e.name||e.original_name||`File`}),e.size&&(0,U.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`(`,(e.size/1024).toFixed(1),` KB)`]})]}),(0,U.jsx)(Q,{type:`button`,variant:`ghost`,size:`sm`,onClick:e=>{e.stopPropagation(),A(t)},className:`h-6 w-6 p-0`,children:(0,U.jsx)(c$,{className:`size-3`})})]},t))})]})]})}var l9=H7((()=>{})),Qpt=U7({ImageCropperDialog:()=>$pt}),$pt,emt=H7((()=>{$pt=({open:e,onOpenChange:t,src:n,outputType:r=`image/png`,outputName:i=`cropped.png`,onConfirm:a})=>{let o=(0,H.useRef)(null),s=(0,H.useRef)(null),[c,l]=(0,H.useState)(0),[u,d]=(0,H.useState)({x:0,y:0,width:100,height:100}),[f,p]=(0,H.useState)(null),[m,h]=(0,H.useState)(!1);(0,H.useEffect)(()=>{if(!e||!n)return;h(!1);let t=new Image;t.crossOrigin=`anonymous`,t.onload=()=>{s.current=t;let e=t.naturalWidth*.8,n=t.naturalHeight*.8;d({x:(t.naturalWidth-e)/2,y:(t.naturalHeight-n)/2,width:e,height:n}),l(0),h(!0)},t.onerror=()=>h(!1),t.src=n},[e,n]),(0,H.useEffect)(()=>{if(!m||!s.current||!o.current)return;let e=s.current,t=o.current,n=t.getContext(`2d`);if(!n)return;let r=480/e.naturalWidth,i=e.naturalHeight*r;t.width=480,t.height=i,n.clearRect(0,0,480,i),n.save(),n.translate(480/2,i/2),n.rotate(c*Math.PI/180);let a=c%180==0?480:i,l=c%180==0?i:480;n.drawImage(e,-a/2,-l/2,a,l),n.restore();let d=u.x*r,f=u.y*r,p=u.width*r,h=u.height*r;n.fillStyle=`rgba(0,0,0,0.45)`,n.fillRect(0,0,480,f),n.fillRect(0,f+h,480,i-f-h),n.fillRect(0,f,d,h),n.fillRect(d+p,f,480-d-p,h),n.strokeStyle=`#3b82f6`,n.lineWidth=2,n.strokeRect(d,f,p,h)},[m,u,c]);let g=(0,H.useCallback)(e=>{if(!s.current||!o.current)return;let t=o.current.getBoundingClientRect(),n=s.current.naturalWidth/t.width;p({ox:(e.clientX-t.left)*n,oy:(e.clientY-t.top)*n,cx:u.x,cy:u.y}),e.target.setPointerCapture(e.pointerId)},[u]),_=(0,H.useCallback)(e=>{if(!f||!s.current||!o.current)return;let t=o.current.getBoundingClientRect(),n=s.current.naturalWidth/t.width,r=(e.clientX-t.left)*n-f.ox,i=(e.clientY-t.top)*n-f.oy,a=Math.max(0,Math.min(f.cx+r,s.current.naturalWidth-u.width)),c=Math.max(0,Math.min(f.cy+i,s.current.naturalHeight-u.height));d(e=>({...e,x:a,y:c}))},[f,u.width,u.height]),v=(0,H.useCallback)(()=>p(null),[]),y=(0,H.useCallback)(()=>l(e=>(e+90)%360),[]),b=(0,H.useCallback)(async()=>{if(!s.current)return;let e=s.current,n=document.createElement(`canvas`),o=u.width,l=u.height;n.width=c%180==0?o:l,n.height=c%180==0?l:o;let d=n.getContext(`2d`);if(!d)return;d.save(),d.translate(n.width/2,n.height/2),d.rotate(c*Math.PI/180),d.drawImage(e,u.x,u.y,o,l,-o/2,-l/2,o,l),d.restore();let f=await new Promise(e=>n.toBlob(e,r));f&&(a(f,i),t(!1))},[u,c,i,r,a,t]);return(0,U.jsx)(j2,{open:e,onOpenChange:t,children:(0,U.jsxs)(N2,{className:`max-w-xl`,children:[(0,U.jsxs)(P2,{children:[(0,U.jsx)(I2,{children:`Crop & rotate image`}),(0,U.jsx)(L2,{children:`Drag the highlighted box to reposition the crop. Use the rotate button to spin the image in 90° increments.`})]}),(0,U.jsxs)(`div`,{className:`flex flex-col items-center gap-3`,children:[m?(0,U.jsx)(`canvas`,{ref:o,"data-testid":`image-cropper-canvas`,role:`img`,"aria-label":`Image crop preview`,className:`border rounded-md cursor-move touch-none max-w-full`,onPointerDown:g,onPointerMove:_,onPointerUp:v,onPointerCancel:v}):(0,U.jsx)(`div`,{className:`flex h-[270px] w-full items-center justify-center text-sm text-muted-foreground`,children:`Loading image…`}),(0,U.jsxs)(`div`,{className:`flex w-full items-center justify-between text-xs text-muted-foreground`,children:[(0,U.jsxs)(`span`,{children:[`Crop: `,Math.round(u.width),` × `,Math.round(u.height),` px`]}),(0,U.jsxs)(`span`,{children:[`Rotation: `,c,`°`]})]})]}),(0,U.jsxs)(F2,{className:`flex justify-between sm:justify-between`,children:[(0,U.jsxs)(Q,{type:`button`,variant:`outline`,onClick:y,"data-testid":`image-cropper-rotate`,children:[(0,U.jsx)(NY,{className:`size-4 mr-2`}),`Rotate 90°`]}),(0,U.jsxs)(`div`,{className:`flex gap-2`,children:[(0,U.jsx)(Q,{type:`button`,variant:`ghost`,onClick:()=>t(!1),children:`Cancel`}),(0,U.jsxs)(Q,{type:`button`,onClick:b,disabled:!m,"data-testid":`image-cropper-confirm`,children:[(0,U.jsx)(Pb,{className:`size-4 mr-2`}),`Apply crop`]})]})]})]})})}})),tmt=U7({ImageField:()=>nmt});function nmt({value:e,onChange:t,field:n,readonly:r,...i}){let a=(0,H.useRef)(null),o=n||i.schema,s=o?.multiple||!1,c=o?.accept?o.accept.join(`,`):`image/*`,l=o?.crop!==!1,[u,d]=(0,H.useState)(null),{upload:f}=Zft(),[p,m]=(0,H.useState)(!1);if(r)return e?(0,U.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:(Array.isArray(e)?e:[e]).map((e,t)=>(0,U.jsx)(`img`,{src:e.url||``,alt:e.name||`Image ${t+1}`,className:`size-20 rounded-md object-cover border border-gray-200`},t))}):(0,U.jsx)(C7,{});let h=e?Array.isArray(e)?e:[e]:[],g=async e=>{let n=Array.from(e.target.files||[]);if(n.length!==0){m(!0);try{let e=await Promise.all(n.map(async e=>{let t=await f(e);return{name:t.name,original_name:e.name,size:t.size,mime_type:t.mimeType,url:t.url}}));t(s?[...h,...e]:e[0])}finally{m(!1),a.current&&(a.current.value=``)}}},_=e=>{if(s){let n=h.filter((t,n)=>n!==e);t(n.length>0?n:null)}else t(null)},v=(0,H.useCallback)(async(e,n)=>{if(u){m(!0);try{let r=await f(e),i={name:r.name||n,original_name:n,size:r.size,mime_type:r.mimeType,url:r.url};if(s){let e=[...h];e[u.index]=i,t(e)}else t(i)}finally{m(!1),d(null)}}},[u,h,s,t,f]),y=(0,H.useCallback)(e=>{let t=h[e];t?.url&&d({index:e,src:t.url,name:t.name||`image-${e}.png`})},[h]);return(0,U.jsxs)(`div`,{className:i.className,children:[(0,U.jsx)(`input`,{ref:a,type:`file`,multiple:s,accept:c,onChange:g,className:`hidden`}),(0,U.jsxs)(`div`,{className:`space-y-2`,children:[h.length>0&&(0,U.jsx)(`div`,{className:`grid grid-cols-4 gap-2`,children:h.map((e,t)=>(0,U.jsxs)(`div`,{className:`relative group`,children:[(0,U.jsx)(`img`,{src:e.url||``,alt:e.name||`Image ${t+1}`,className:`size-20 rounded-md object-cover border border-gray-200`}),(0,U.jsxs)(`div`,{className:`absolute top-1 right-1 flex gap-1 opacity-0 group-hover:opacity-100 transition-opacity`,children:[l&&(0,U.jsx)(Q,{type:`button`,variant:`secondary`,size:`sm`,onClick:()=>y(t),className:`h-6 w-6 p-0`,"aria-label":`Crop image ${t+1}`,"data-testid":`image-field-crop-${t}`,children:(0,U.jsx)(Pb,{className:`size-3`})}),(0,U.jsx)(Q,{type:`button`,variant:`destructive`,size:`sm`,onClick:()=>_(t),className:`h-6 w-6 p-0`,children:(0,U.jsx)(c$,{className:`size-3`})})]})]},t))}),(0,U.jsxs)(Q,{type:`button`,variant:`outline`,onClick:()=>a.current?.click(),className:`w-full`,disabled:p,"data-testid":`image-field-upload-button`,children:[p?(0,U.jsx)(GI,{className:`size-4 mr-2 animate-spin`}):(0,U.jsx)(PN,{className:`size-4 mr-2`}),p?`Uploading…`:h.length>0?`Add More Images`:`Upload Image`]})]}),l&&u&&(0,U.jsx)(H.Suspense,{fallback:null,children:(0,U.jsx)(rmt,{open:!0,onOpenChange:e=>!e&&d(null),src:u.src,outputName:u.name,onConfirm:v})})]})}var rmt,u9=H7((()=>{rmt=(0,H.lazy)(()=>Promise.resolve().then(()=>(emt(),Qpt)).then(e=>({default:e.ImageCropperDialog})))})),imt=U7({LocationField:()=>amt});function amt({value:e,onChange:t,field:n,readonly:r,...i}){let a=n||i.schema,o=e&&typeof e==`object`?`${e.latitude||0}, ${e.longitude||0}`:``;return r?(0,U.jsx)(`span`,{className:`text-sm`,children:o||(0,U.jsx)(C7,{})}):(0,U.jsx)(f6,{type:`text`,value:o,onChange:e=>{let n=e.target.value;if(!n.trim()){t(null);return}let r=n.split(`,`).map(e=>e.trim());if(r.length===2){let e=parseFloat(r[0]),n=parseFloat(r[1]);!isNaN(e)&&!isNaN(n)&&t({latitude:e,longitude:n})}},placeholder:a?.placeholder||`latitude, longitude`,disabled:r||i.disabled,className:i.className})}var d9=H7((()=>{})),omt=U7({FormulaField:()=>smt});function smt({value:e,field:t,...n}){let r=(t||n.schema)?.return_type||`text`;if(e==null)return(0,U.jsx)(C7,{className:n.className});let i;return i=r===`number`||r===`currency`?typeof e==`number`?e.toFixed(2):String(e):r===`boolean`?e?`Yes`:`No`:r===`date`?new Date(e).toLocaleDateString():String(e),(0,U.jsx)(`span`,{className:`text-sm font-mono text-gray-700 ${n.className||``}`,children:i})}var f9=H7((()=>{})),cmt=U7({SummaryField:()=>lmt});function lmt({value:e,field:t,...n}){let r=(t||n.schema)?.summary_type||`count`;if(e==null)return(0,U.jsx)(C7,{className:n.className});let i;return i=r===`count`?String(e):[`sum`,`avg`,`min`,`max`].includes(r)&&typeof e==`number`?e.toFixed(2):String(e),(0,U.jsx)(`span`,{className:`text-sm font-medium tabular-nums text-gray-700 ${n.className||``}`,children:i})}var p9=H7((()=>{})),umt=U7({AutoNumberField:()=>dmt});function dmt({value:e,field:t,...n}){return e==null?(0,U.jsx)(C7,{className:n.className}):(0,U.jsx)(`span`,{className:`text-sm font-mono text-gray-700 ${n.className||``}`,children:String(e)})}var m9=H7((()=>{})),fmt=U7({UserField:()=>pmt});function pmt({value:e,onChange:t,field:n,readonly:r,...i}){let a=(n||i.schema)?.multiple||!1;if(r){if(!e)return(0,U.jsx)(C7,{});let t=Array.isArray(e)?e:[e];return(0,U.jsxs)(`div`,{className:`flex -space-x-2`,children:[t.slice(0,3).map((e,t)=>{let n=e.name||e.username||`User`;return(0,U.jsx)(S1,{className:`size-8 border-2 border-white`,title:n,children:(0,U.jsx)(w1,{className:`bg-blue-500 text-white text-xs`,children:n.split(` `).map(e=>e[0]).join(``).toUpperCase().slice(0,2)})},t)}),t.length>3&&(0,U.jsx)(S1,{className:`size-8 border-2 border-white`,children:(0,U.jsxs)(w1,{className:`bg-gray-200 text-gray-600 text-xs`,children:[`+`,t.length-3]})})]})}let o=e?Array.isArray(e)?e:[e]:[],s=e=>{if(a){let n=o.filter((t,n)=>n!==e);t(n.length>0?n:null)}else t(null)};return(0,U.jsxs)(`div`,{className:i.className,children:[o.length>0&&(0,U.jsx)(`div`,{className:`flex flex-wrap gap-2 mb-2`,children:o.map((e,t)=>{let n=e.name||e.username||`User`;return(0,U.jsxs)(T1,{variant:`outline`,className:`gap-2 pr-1`,children:[(0,U.jsx)(S1,{className:`size-5`,children:(0,U.jsx)(w1,{className:`bg-blue-500 text-white text-xs`,children:n.split(` `).map(e=>e[0]).join(``).toUpperCase().slice(0,2)})}),(0,U.jsx)(`span`,{className:`text-sm`,children:n}),(0,U.jsx)(`button`,{type:`button`,onClick:()=>s(t),className:`ml-1 rounded-full hover:bg-gray-200 p-0.5`,children:(0,U.jsx)(c$,{className:`size-3`})})]},t)})}),(0,U.jsx)(`div`,{className:`text-sm text-gray-500 italic`,children:`User selection component requires integration with user management system`})]})}var h9=H7((()=>{})),mmt=U7({ObjectField:()=>hmt});function hmt({value:e,onChange:t,field:n,readonly:r,...i}){let a=n||i.schema,[o,s]=(0,H.useState)(()=>e==null?``:JSON.stringify(e,null,2)),[c,l]=(0,H.useState)(null);return(0,H.useEffect)(()=>{try{if(e==null){s(``);return}let t=o?JSON.parse(o):null;JSON.stringify(t)!==JSON.stringify(e)&&s(JSON.stringify(e,null,2))}catch{s(JSON.stringify(e,null,2))}},[e,o]),r?e?(0,U.jsx)(`pre`,{className:q(`text-xs bg-gray-50 p-2 rounded border border-gray-200 overflow-auto max-h-40`,i.className),children:JSON.stringify(e,null,2)}):(0,U.jsx)(C7,{}):(0,U.jsxs)(`div`,{className:`space-y-1`,children:[(0,U.jsx)(p7,{value:o,onChange:e=>{let n=e.target.value;if(s(n),l(null),!n.trim()){t(null);return}try{t(JSON.parse(n))}catch{l(`Invalid JSON`)}},placeholder:a?.placeholder||`{
103
103
  "key": "value"
104
- }`,disabled:r||i.disabled,className:q(`font-mono text-xs`,c?`border-red-500 focus-visible:ring-red-500`:``,i.className),rows:6}),c&&(0,U.jsx)(`p`,{className:`text-xs text-red-500`,children:c})]})}var g9=H7((()=>{})),gmt=U7({VectorField:()=>_mt});function _mt({value:e,field:t,...n}){let r=(t||n.schema)?.dimensions||(Array.isArray(e)?e.length:0);if(!e||!Array.isArray(e))return(0,U.jsx)(C7,{});let i=e.slice(0,3).map(e=>{let t=Number(e);return isNaN(t)?`0`:t.toFixed(4)}).join(`, `);return(0,U.jsxs)(`div`,{className:`text-sm ${n.className||``}`,children:[(0,U.jsxs)(`span`,{className:`font-mono text-gray-700`,children:[`[`,i,`...]`]}),(0,U.jsxs)(`span`,{className:`text-gray-500 ml-2`,children:[`(`,r,`D)`]})]})}var _9=H7((()=>{})),vmt=U7({GridField:()=>ymt});function ymt({value:e,field:t,readonly:n,...r}){let i=(t||r.schema)?.columns||[];return!e||!Array.isArray(e)?(0,U.jsx)(C7,{}):n?(0,U.jsx)(`div`,{className:q(`text-sm`,r.className),children:(0,U.jsxs)(`span`,{className:`text-foreground`,children:[e.length,` rows`]})}):(0,U.jsxs)(`div`,{className:q(`border border-border rounded-lg overflow-hidden`,r.className),children:[(0,U.jsx)(`div`,{className:`overflow-auto max-h-60`,children:(0,U.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,U.jsx)(`thead`,{className:`bg-muted border-b border-border`,children:(0,U.jsx)(`tr`,{children:i.map((e,t)=>(0,U.jsx)(`th`,{className:`px-3 py-2 text-left text-xs font-medium text-muted-foreground`,children:e.label||e.name},t))})}),(0,U.jsx)(`tbody`,{className:`divide-y divide-border`,children:e.slice(0,5).map((e,t)=>(0,U.jsx)(`tr`,{className:`hover:bg-muted/50 transition-colors`,children:i.map((t,n)=>(0,U.jsx)(`td`,{className:`px-3 py-2 text-foreground`,children:e[t.name]==null?(0,U.jsx)(C7,{}):String(e[t.name])},n))},t))})]})}),e.length>5&&(0,U.jsxs)(`div`,{className:`bg-muted px-3 py-2 text-xs text-muted-foreground border-t border-border`,children:[`Showing 5 of `,e.length,` rows`]})]})}var v9=H7((()=>{})),bmt=U7({ColorField:()=>xmt});function xmt({value:e,onChange:t,field:n,readonly:r,...i}){let a=n||i.schema;return r?(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(`div`,{className:`w-6 h-6 rounded border border-input`,style:{backgroundColor:e||`#000000`}}),(0,U.jsx)(`span`,{className:`text-sm`,children:e||(0,U.jsx)(C7,{})})]}):(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(`input`,{type:`color`,value:e||`#000000`,onChange:e=>t(e.target.value),disabled:r||i.disabled,className:`w-10 h-10 rounded border border-input cursor-pointer`}),(0,U.jsx)(f6,{type:`text`,value:e||``,onChange:e=>t(e.target.value),placeholder:a?.placeholder||`#000000`,disabled:r||i.disabled,className:i.className,pattern:`^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$`})]})}var y9=H7((()=>{})),Smt=U7({SliderField:()=>Cmt});function Cmt({value:e,onChange:t,field:n,readonly:r,...i}){let a=n||i.schema,o=a?.min??0,s=a?.max??100,c=a?.step??1;return r?(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(`span`,{className:`text-sm font-medium`,children:e??o}),(0,U.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`/ `,s]})]}):(0,U.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,U.jsx)(K5,{value:[e??o],onValueChange:e=>t(e[0]),min:o,max:s,step:c,disabled:r||i.disabled,className:i.className}),(0,U.jsx)(`span`,{className:`text-sm font-medium w-12 text-right`,children:e??o})]})}var b9=H7((()=>{})),wmt=U7({RatingField:()=>Tmt});function Tmt({value:e,onChange:t,field:n,readonly:r,className:i,...a}){let o=(n||a.schema)?.max??5,s=e??0,[c,l]=H.useState(null),u=c===null?s:c;return r?(0,U.jsxs)(`div`,{className:q(`flex items-center gap-1`,i),children:[Array.from({length:o},(e,t)=>(0,U.jsx)($Q,{className:`w-5 h-5 ${t<s?`fill-yellow-400 text-yellow-400`:`text-muted-foreground`}`},t)),(0,U.jsxs)(`span`,{className:`ml-2 text-sm text-muted-foreground`,children:[s,` / `,o]})]}):(0,U.jsxs)(`div`,{className:q(`flex items-center gap-1`,i),children:[Array.from({length:o},(e,n)=>(0,U.jsx)(`button`,{type:`button`,onClick:()=>t(n+1),onMouseEnter:()=>l(n+1),onMouseLeave:()=>l(null),className:`focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 rounded`,disabled:r||a.disabled,children:(0,U.jsx)($Q,{className:`w-5 h-5 transition-colors ${n<u?`fill-yellow-400 text-yellow-400 hover:fill-yellow-500 hover:text-yellow-500`:`text-muted-foreground hover:text-yellow-400`}`})},n)),(0,U.jsxs)(`span`,{className:`ml-2 text-sm text-muted-foreground`,children:[s,` / `,o]})]})}var x9=H7((()=>{})),Emt=U7({CodeField:()=>Dmt});function Dmt({value:e,onChange:t,field:n,readonly:r,...i}){let a=n||i.schema,o=a?.language??`javascript`;return r?(0,U.jsx)(`pre`,{className:q(`text-sm bg-muted p-2 rounded overflow-x-auto border`,i.className),children:(0,U.jsx)(`code`,{children:e||(0,U.jsx)(C7,{})})}):(0,U.jsx)(p7,{value:e||``,onChange:e=>t(e.target.value),placeholder:a?.placeholder||`// Write ${o} code here...`,disabled:r||i.disabled,className:q(`font-mono text-sm`,i.className),rows:12,spellCheck:!1})}var S9=H7((()=>{})),Omt=U7({AvatarField:()=>kmt});function kmt({value:e,onChange:t,field:n,readonly:r,...i}){let[a,o]=H.useState(!1),s=H.useRef(null),c=n||i.schema,l=e=>{let n=e.target.files?.[0];if(!n)return;if(!n.type.startsWith(`image/`)){console.error(`Please select an image file`);return}if(n.size>5*1024*1024){console.error(`File size must be less than 5MB`);return}let r=new FileReader;r.onloadend=()=>{t(r.result)},r.readAsDataURL(n)},u=()=>{t(``)},d=()=>(c?.defaultName||c?.label||`User`).split(` `).map(e=>e[0]).join(``).toUpperCase().slice(0,2);return r?(0,U.jsxs)(S1,{className:`w-16 h-16`,children:[e&&(0,U.jsx)(C1,{src:e,alt:c?.label}),(0,U.jsx)(w1,{children:d()})]}):(0,U.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,U.jsxs)(`div`,{className:`relative`,onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),children:[(0,U.jsxs)(S1,{className:`w-16 h-16`,children:[e&&(0,U.jsx)(C1,{src:e,alt:c?.label}),(0,U.jsx)(w1,{children:d()})]}),!r&&a&&e&&(0,U.jsx)(`button`,{type:`button`,onClick:u,className:`absolute -top-1 -right-1 bg-destructive text-destructive-foreground rounded-full p-1 hover:bg-destructive/90`,children:(0,U.jsx)(c$,{className:`w-3 h-3`})})]}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,U.jsx)(`input`,{ref:s,type:`file`,accept:`image/*`,onChange:l,className:`hidden`}),(0,U.jsxs)(Q,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>s.current?.click(),disabled:r||i.disabled,children:[(0,U.jsx)(s$,{className:`w-4 h-4 mr-2`}),e?`Change`:`Upload`,` Avatar`]}),(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`PNG, JPG up to 5MB`})]})]})}var C9=H7((()=>{})),Amt=U7({AddressField:()=>jmt});function jmt({value:e,onChange:t,field:n,readonly:r,...i}){let a=e||{},o=(e,n)=>{t({...a,[e]:n})},s=e=>[e.street,e.city,[e.state,e.zipCode].filter(Boolean).join(` `),e.country].filter(Boolean).join(`, `);if(r){let e=s(a);return e?(0,U.jsx)(`span`,{className:`text-sm`,children:e}):(0,U.jsx)(C7,{})}return(0,U.jsxs)(`div`,{className:`space-y-3`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(t6,{htmlFor:`street`,className:`text-xs`,children:`Street Address`}),(0,U.jsx)(f6,{id:`street`,type:`text`,value:a.street||``,onChange:e=>o(`street`,e.target.value),placeholder:`123 Main St`,disabled:r||i.disabled,className:i.className})]}),(0,U.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(t6,{htmlFor:`city`,className:`text-xs`,children:`City`}),(0,U.jsx)(f6,{id:`city`,type:`text`,value:a.city||``,onChange:e=>o(`city`,e.target.value),placeholder:`San Francisco`,disabled:r||i.disabled})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(t6,{htmlFor:`state`,className:`text-xs`,children:`State / Province`}),(0,U.jsx)(f6,{id:`state`,type:`text`,value:a.state||``,onChange:e=>o(`state`,e.target.value),placeholder:`CA`,disabled:r||i.disabled})]})]}),(0,U.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(t6,{htmlFor:`zipCode`,className:`text-xs`,children:`ZIP / Postal Code`}),(0,U.jsx)(f6,{id:`zipCode`,type:`text`,value:a.zipCode||``,onChange:e=>o(`zipCode`,e.target.value),placeholder:`94102`,disabled:r||i.disabled})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(t6,{htmlFor:`country`,className:`text-xs`,children:`Country`}),(0,U.jsx)(f6,{id:`country`,type:`text`,value:a.country||``,onChange:e=>o(`country`,e.target.value),placeholder:`United States`,disabled:r||i.disabled})]})]})]})}var w9=H7((()=>{})),Mmt=U7({GeolocationField:()=>Nmt});function Nmt({value:e,onChange:t,field:n,readonly:r,...i}){let[a,o]=H.useState(!1),s=e||{},c=(e,n)=>{t({...s,[e]:n?Number(n):void 0})},l=()=>{if(!navigator.geolocation){console.error(`Geolocation is not supported by this browser`);return}o(!0),navigator.geolocation.getCurrentPosition(e=>{t({latitude:e.coords.latitude,longitude:e.coords.longitude,accuracy:e.coords.accuracy}),o(!1)},e=>{console.error(`Error getting location:`,e.message),o(!1)},{enableHighAccuracy:!0,timeout:5e3,maximumAge:0})},u=e=>!e.latitude||!e.longitude?``:`${e.latitude.toFixed(6)}, ${e.longitude.toFixed(6)}`,d=()=>{if(!s.latitude||!s.longitude)return;let e=`https://www.google.com/maps?q=${s.latitude},${s.longitude}`;window.open(e,`_blank`)};if(r){let e=u(s);return(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(yR,{className:`w-4 h-4 text-muted-foreground`}),e?(0,U.jsx)(`span`,{className:`text-sm`,children:e}):(0,U.jsx)(C7,{}),s.latitude&&s.longitude&&(0,U.jsx)(Q,{type:`button`,variant:`link`,size:`sm`,onClick:d,className:`p-0 h-auto`,children:`View on map`})]})}return(0,U.jsxs)(`div`,{className:`space-y-3`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsxs)(Q,{type:`button`,variant:`outline`,size:`sm`,onClick:l,disabled:r||a,children:[(0,U.jsx)(Rb,{className:`w-4 h-4 mr-2`}),a?`Getting location...`:`Use Current Location`]}),s.latitude&&s.longitude&&(0,U.jsxs)(Q,{type:`button`,variant:`link`,size:`sm`,onClick:d,children:[(0,U.jsx)(yR,{className:`w-4 h-4 mr-2`}),`View on map`]})]}),(0,U.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(t6,{htmlFor:`latitude`,className:`text-xs`,children:`Latitude`}),(0,U.jsx)(f6,{id:`latitude`,type:`number`,value:s.latitude??``,onChange:e=>c(`latitude`,e.target.value),placeholder:`37.7749`,disabled:r||i.disabled,step:`any`,className:i.className})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(t6,{htmlFor:`longitude`,className:`text-xs`,children:`Longitude`}),(0,U.jsx)(f6,{id:`longitude`,type:`number`,value:s.longitude??``,onChange:e=>c(`longitude`,e.target.value),placeholder:`-122.4194`,disabled:r||i.disabled,step:`any`})]})]}),s.accuracy&&(0,U.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Accuracy: ±`,s.accuracy.toFixed(0),`m`]})]})}var T9=H7((()=>{})),Pmt=U7({SignatureField:()=>Fmt});function Fmt({value:e,onChange:t,readonly:n}){let r=(0,H.useRef)(null),[i,a]=H.useState(!1),[o,s]=H.useState(!e);(0,H.useEffect)(()=>{if(e&&r.current){let t=r.current.getContext(`2d`);if(t){let n=new Image;n.onload=()=>{t.drawImage(n,0,0),s(!1)},n.src=e}}},[e]);let c=e=>{if(n)return;a(!0),s(!1);let t=r.current;if(!t)return;let i=t.getContext(`2d`);if(!i)return;let o=t.getBoundingClientRect(),c=`touches`in e?e.touches[0].clientX-o.left:e.clientX-o.left,l=`touches`in e?e.touches[0].clientY-o.top:e.clientY-o.top;i.beginPath(),i.moveTo(c,l)},l=e=>{if(!i||n)return;let t=r.current;if(!t)return;let a=t.getContext(`2d`);if(!a)return;let o=t.getBoundingClientRect(),s=`touches`in e?e.touches[0].clientX-o.left:e.clientX-o.left,c=`touches`in e?e.touches[0].clientY-o.top:e.clientY-o.top;a.lineTo(s,c),a.strokeStyle=`#000`,a.lineWidth=2,a.lineCap=`round`,a.lineJoin=`round`,a.stroke()},u=()=>{if(!i)return;a(!1);let e=r.current;e&&t(e.toDataURL(`image/png`))};return n&&e?(0,U.jsx)(`div`,{className:`border rounded p-2 bg-white`,children:(0,U.jsx)(`img`,{src:e,alt:`Signature`,loading:`lazy`,className:`max-w-full h-auto`})}):n&&!e?(0,U.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:`No signature`}):(0,U.jsxs)(`div`,{className:`space-y-2`,children:[(0,U.jsx)(`div`,{className:`border rounded bg-white`,children:(0,U.jsx)(`canvas`,{ref:r,width:400,height:200,className:`w-full touch-none cursor-crosshair`,onMouseDown:c,onMouseMove:l,onMouseUp:u,onMouseLeave:u,onTouchStart:c,onTouchMove:l,onTouchEnd:u})}),(0,U.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:o?`Sign above`:`Signature captured`}),(0,U.jsxs)(Q,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>{let e=r.current;if(!e)return;let n=e.getContext(`2d`);n&&(n.clearRect(0,0,e.width,e.height),s(!0),t(``))},disabled:n||o,children:[(0,U.jsx)(gC,{className:`w-4 h-4 mr-2`}),`Clear`]})]})]})}var E9=H7((()=>{})),Imt=U7({QRCodeField:()=>Lmt});function Lmt({value:e,onChange:t,field:n,readonly:r,...i}){let[a,o]=H.useState(!1),s=n||i.schema;return r?(0,U.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,U.jsx)(`span`,{className:`text-sm flex-1 truncate`,children:e||(0,U.jsx)(C7,{})}),e&&(0,U.jsxs)(Q,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>o(!a),children:[(0,U.jsx)(yq,{className:`w-4 h-4 mr-2`}),a?`Hide`:`Show`,` QR`]})]}):(0,U.jsxs)(`div`,{className:`space-y-3`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(f6,{type:`text`,value:e||``,onChange:e=>t(e.target.value),placeholder:s?.placeholder||`Enter text for QR code`,disabled:r||i.disabled,className:i.className}),e&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(Q,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>{e&&navigator.clipboard.writeText(e)},children:(0,U.jsx)(ab,{className:`w-4 h-4`})}),(0,U.jsx)(Q,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>o(!a),children:(0,U.jsx)(yq,{className:`w-4 h-4`})})]})]}),a&&e&&(0,U.jsx)(`div`,{className:`border rounded p-4 bg-white flex justify-center`,children:(0,U.jsx)(`img`,{src:(e=>`https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=${encodeURIComponent(e)}`)(e),alt:`QR Code`,className:`w-48 h-48`})}),e&&(0,U.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`QR code contains: `,e.length,` characters`]})]})}var D9=H7((()=>{}));W7(),G7(),K7(),J7(),Y7(),X7(),Z7(),Q7(),$7(),e9(),t9(),i9(),a9(),o9(),s9(),c9(),l9(),u9(),d9(),f9(),p9(),m9(),h9(),g9(),_9(),v9(),y9(),b9(),x9(),S9(),C9(),w9(),T9(),E9(),D9(),emt(),Fpt(),W7(),G7(),K7(),J7(),Y7(),a9(),o9(),X7(),Z7(),Q7(),$7(),s9(),c9(),e9(),t9(),i9(),jpt(),l9(),u9(),d9(),f9(),p9(),m9(),h9(),g9(),_9(),v9(),y9(),b9(),x9(),S9(),C9(),w9(),T9(),E9(),D9();var O9=new Map;function k9(e){if(!e||typeof e!=`object`)return;for(let t of[`name`,`full_name`,`display_name`,`label`,`title`,`subject`,`username`]){let n=e[t];if(typeof n==`string`&&n.trim())return n.trim();if(typeof n==`number`)return String(n)}let t=e.first_name,n=e.last_name,r=[e.salutation,t,n].filter(e=>typeof e==`string`&&e.trim()).map(e=>e.trim()).join(` `);if(r)return r;let i=e.email;if(typeof i==`string`&&i.trim())return i.trim()}function Rmt(e){if(typeof e!=`string`||!/^[A-Za-z0-9_-]{12,32}$/.test(e))return!1;let t=/[A-Z]/.test(e),n=/[a-z]/.test(e),r=/[0-9_-]/.test(e);return t&&n||t&&r||n&&r}function zmt(e,t){let n=H.useContext(ge)?.dataSource,[,r]=H.useState(0),i=!!e&&!!n&&typeof n.find==`function`&&(typeof t==`string`||typeof t==`number`)&&t!==``,a=i?`${e}:${String(t)}`:``;if(H.useEffect(()=>{if(!i)return;let o=O9.get(a);if(o&&o.state!==`pending`&&o.promise==null||o?.state===`pending`)return;let s=(async()=>{try{let r;if(typeof n.findOne==`function`)r=await n.findOne(e,t);else{let i=await n.find(e,{$filter:{id:t},options:{$top:1}});r=(Array.isArray(i)?i:i?.value||i?.data||[])[0]}let i=k9(r);O9.set(a,{state:`ok`,name:i})}catch{O9.set(a,{state:`err`})}r(e=>e+1)})();O9.set(a,{state:`pending`,promise:s})},[a,i,e,t,n]),!i)return;let o=O9.get(a);return o?.state===`ok`?o.name:void 0}function Bmt(){try{let{t:e}=Vn();return(t,n)=>{let r=e(t);return!r||r===t?n:r}}catch{return(e,t)=>t}}function A9(e){if(e==null||typeof e==`string`||typeof e==`number`||typeof e==`boolean`)return e;if(e instanceof Date)return e.toISOString();if(Array.isArray(e))return e.map(e=>{if(typeof e==`object`&&e){let t=e;return String(t.name||t.label||t.id||t._id||`[Object]`)}return String(e)}).join(`, `);if(typeof e==`object`){let t=e;return`$numberDecimal`in t?Number(t.$numberDecimal):`$oid`in t?String(t.$oid):`$date`in t?String(t.$date):String(t.name||t.label||t.id||t._id||`[Object]`)}return String(e)}function Vmt(e,t=`USD`){try{return new Intl.NumberFormat(`en-US`,{style:`currency`,currency:t}).format(e)}catch{return`${t} ${e.toFixed(2)}`}}function Hmt(e,t=2){try{return new Intl.NumberFormat(`en-US`,{minimumFractionDigits:t,maximumFractionDigits:t}).format(e)}catch{return e.toFixed(t)}}function Umt(e,t=0){return`${(e>-1&&e<1?e*100:e).toFixed(t)}%`}function Wmt(e){return e.replace(/[_-]/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}function Gmt(e){if(e==null||e===``)return`—`;let t=e instanceof Date?e:new Date(e);if(!(t instanceof Date)||isNaN(t.getTime()))return`—`;let n=new Date,r=new Date(n.getFullYear(),n.getMonth(),n.getDate()),i=new Date(t.getFullYear(),t.getMonth(),t.getDate()).getTime()-r.getTime(),a=Math.round(i/(1e3*60*60*24));if(a===0)return`Today`;if(a===1)return`Tomorrow`;if(a===-1)return`Yesterday`;if(a<-1){let e=Math.abs(a);return e<=7?`Overdue ${e}d`:j9(t)}return a>1&&a<=7?`In ${a} days`:j9(t)}function j9(e,t){if(e==null||e===``)return`—`;let n=e instanceof Date?e:new Date(e);return!(n instanceof Date)||isNaN(n.getTime())?`—`:t===`short`?`${n.toLocaleDateString(`en-US`,{month:`short`})} ${n.getDate()}, '${String(n.getFullYear()).slice(-2)}`:t===`relative`?Gmt(n):n.toLocaleDateString(void 0,{year:`numeric`,month:`short`,day:`numeric`})}function Kmt(e){if(e==null||e===``)return`—`;let t=e instanceof Date?e:new Date(e);return!(t instanceof Date)||isNaN(t.getTime())?`—`:t.toLocaleDateString(void 0,{year:`numeric`,month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`})}function M9({value:e}){let t=A9(e);return t==null||t===``?(0,U.jsx)(C7,{}):(0,U.jsx)(`span`,{className:`truncate`,children:String(t)})}function qmt({value:e,field:t}){if(e==null)return(0,U.jsx)(C7,{});let n=A9(e),r=t.precision??0,i=Number(n);return(0,U.jsx)(`span`,{className:`tabular-nums`,children:isNaN(i)?String(n):new Intl.NumberFormat(`en-US`,{minimumFractionDigits:r,maximumFractionDigits:r}).format(i)})}function Jmt({value:e,field:t}){if(e==null)return(0,U.jsx)(C7,{});let n=A9(e),r=t,i=r.currency||r.defaultCurrency,a=Number(n),o=r.precision??r.scale??r.decimals??2;return(0,U.jsx)(`span`,{className:`tabular-nums font-medium whitespace-nowrap`,children:isNaN(a)?String(n):i?Vmt(a,i):Hmt(a,o)})}var Ymt=/progress|completion/;function Xmt({value:e,field:t}){if(e==null)return(0,U.jsx)(C7,{});let n=A9(e),r=t.precision??0,i=Number(n);if(isNaN(i))return(0,U.jsx)(`span`,{className:`tabular-nums whitespace-nowrap`,children:String(n)});let a=Ymt.test(t?.name?.toLowerCase()||``),o=a?i:i>-1&&i<1?i*100:i,s=a?`${i.toFixed(r)}%`:Umt(i,r),c=Math.max(0,Math.min(100,o));return(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(`div`,{className:`h-1.5 w-16 rounded-full bg-muted ring-1 ring-inset ring-border/60 overflow-hidden shrink-0`,role:`progressbar`,"aria-valuenow":c,"aria-valuemin":0,"aria-valuemax":100,children:(0,U.jsx)(`div`,{className:`h-full rounded-full bg-primary transition-all`,style:{width:`${c}%`}})}),(0,U.jsx)(`span`,{className:`tabular-nums whitespace-nowrap`,children:s})]})}var Zmt=new Set([`active`,`is_active`,`enabled`,`is_enabled`,`verified`,`is_verified`]);function Qmt({value:e,field:t}){if(e==null)return(0,U.jsx)(`span`,{className:`flex items-center justify-center`,children:(0,U.jsx)(C7,{})});let n=t?.name?.toLowerCase()||``;return n===`completed`||n===`is_completed`||n===`done`||n===`is_done`?(0,U.jsx)(`div`,{className:`flex items-center justify-center`,children:e?(0,U.jsx)(`div`,{className:`size-5 rounded-full bg-green-500 flex items-center justify-center`,role:`img`,"aria-label":`Completed`,"data-testid":`completion-indicator`,children:(0,U.jsx)(Yp,{className:`size-3 text-white`})}):(0,U.jsx)(`div`,{className:`size-5 rounded-full border-2 border-muted-foreground/30`,role:`img`,"aria-label":`Not completed`,"data-testid":`completion-indicator`})}):Zmt.has(n)&&!e?(0,U.jsxs)(T1,{variant:`destructive`,className:`text-xs`,"data-testid":`boolean-warning-badge`,children:[t?.label||Wmt(n),` — Off`]}):(0,U.jsx)(`div`,{className:`flex items-center justify-start`,children:(0,U.jsx)(p2,{checked:!!e,disabled:!0,className:`pointer-events-none`})})}function $mt({value:e,field:t}){if(!e)return(0,U.jsx)(C7,{});let n=A9(e),r=t,i=j9(n,r.format||`relative`),a=n==null?null:new Date(n),o=a!==null&&!isNaN(a.getTime()),s=new Date;s.setHours(0,0,0,0);let c=String(r?.name||r?.accessorKey||r?.key||``).toLowerCase(),l=(r?.dueLike===!0||/(^|_)(due|deadline|expires?|expiry|expiration|expected_close|target_close|sla|return_by|renewal|next_action)(_|$)/.test(c))&&o&&a<s,u=o?a.toISOString():String(n);return(0,U.jsx)(`span`,{className:`tabular-nums${l?` text-red-600`:``}`,title:u,children:i})}function eht({value:e}){if(!e)return(0,U.jsx)(C7,{});let t=A9(e),n=t==null?null:new Date(t);if(n===null||isNaN(n.getTime()))return(0,U.jsx)(C7,{});let r=n.toLocaleDateString(void 0,{month:`numeric`,day:`numeric`,year:`numeric`}),i=n.toLocaleTimeString(void 0,{hour:`numeric`,minute:`2-digit`,hour12:!0}).toLowerCase();return(0,U.jsxs)(`span`,{className:`tabular-nums text-sm whitespace-nowrap`,children:[(0,U.jsx)(`span`,{children:r}),(0,U.jsx)(`span`,{className:`ml-2 text-muted-foreground`,children:i})]})}var tht={critical:`red`,urgent:`red`,high:`orange`,medium:`yellow`,normal:`blue`,low:`gray`,none:`gray`,paid:`green`,completed:`green`,done:`green`,active:`green`,approved:`green`,resolved:`green`,pending:`yellow`,waiting:`yellow`,on_hold:`yellow`,shipped:`blue`,in_progress:`blue`,open:`blue`,processing:`blue`,draft:`gray`,new:`gray`,inactive:`gray`,closed:`gray`,cancelled:`red`,canceled:`red`,rejected:`red`,failed:`red`,overdue:`red`,delivered:`purple`,archived:`indigo`,contacted:`blue`,qualified:`purple`,converted:`green`,won:`green`,lost:`red`,紧急:`red`,严重:`red`,高:`orange`,中:`yellow`,普通:`blue`,低:`gray`,无:`gray`,新建:`gray`,草稿:`gray`,待处理:`yellow`,待审核:`yellow`,待联系:`yellow`,挂起:`yellow`,进行中:`blue`,处理中:`blue`,已联系:`blue`,跟进中:`blue`,已发货:`blue`,打开:`blue`,已确认:`green`,已审核:`green`,已通过:`green`,已完成:`green`,已支付:`green`,已签收:`green`,已转化:`green`,成单:`green`,赢得:`green`,已签约:`green`,已交付:`purple`,已归档:`indigo`,已关闭:`gray`,已取消:`red`,已拒绝:`red`,失败:`red`,逾期:`red`,流失:`red`,丢失:`red`},N9={gray:`bg-gray-50 text-gray-700 border-gray-200 dark:bg-gray-800/50 dark:text-gray-200 dark:border-gray-700/60`,red:`bg-red-50 text-red-700 border-red-200 dark:bg-red-950/40 dark:text-red-300 dark:border-red-900/60`,orange:`bg-orange-50 text-orange-700 border-orange-200 dark:bg-orange-950/40 dark:text-orange-300 dark:border-orange-900/60`,yellow:`bg-yellow-50 text-yellow-800 border-yellow-200 dark:bg-yellow-950/40 dark:text-yellow-300 dark:border-yellow-900/60`,green:`bg-green-50 text-green-700 border-green-200 dark:bg-green-950/40 dark:text-green-300 dark:border-green-900/60`,blue:`bg-blue-50 text-blue-700 border-blue-200 dark:bg-blue-950/40 dark:text-blue-300 dark:border-blue-900/60`,indigo:`bg-indigo-50 text-indigo-700 border-indigo-200 dark:bg-indigo-950/40 dark:text-indigo-300 dark:border-indigo-900/60`,purple:`bg-purple-50 text-purple-700 border-purple-200 dark:bg-purple-950/40 dark:text-purple-300 dark:border-purple-900/60`,pink:`bg-pink-50 text-pink-700 border-pink-200 dark:bg-pink-950/40 dark:text-pink-300 dark:border-pink-900/60`},nht={gray:`bg-gray-400 dark:bg-gray-500`,red:`bg-red-500`,orange:`bg-orange-500`,yellow:`bg-yellow-500`,green:`bg-green-500`,blue:`bg-blue-500`,indigo:`bg-indigo-500`,purple:`bg-purple-500`,pink:`bg-pink-500`},rht=[`blue`,`green`,`purple`,`orange`,`pink`,`indigo`,`yellow`,`red`];function iht(e){let t=5381;for(let n=0;n<e.length;n++)t=(t<<5)+t^e.charCodeAt(n);return rht[Math.abs(t)%rht.length]}function P9(e,t){if(e&&N9[e])return N9[e];if(t==null||t===``)return`bg-muted text-muted-foreground border-border`;let n=String(t).toLowerCase().replace(/[\s-]/g,`_`),r=tht[n];return r&&N9[r]?N9[r]:N9[iht(n)]}function F9({value:e,field:t}){let n=t,r=n.options||[],i=n.appearance===`dot`?`dot`:`badge`;if(e==null||e===``)return(0,U.jsx)(C7,{});let a=e=>{let t=r.find(t=>t.value===e);if(t)return t;let n=String(e).toLowerCase();return r.find(e=>String(e.value).toLowerCase()===n)},o=(e,t)=>{let n=a(e),r=n?.label||Wmt(String(e));return i===`dot`?(0,U.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-sm`,children:[(0,U.jsx)(`span`,{className:q(`h-1.5 w-1.5 rounded-full shrink-0`,nht[n?.color||tht[String(e).toLowerCase().replace(/[\s-]/g,`_`)]||iht(String(e).toLowerCase().replace(/[\s-]/g,`_`))]||nht.gray),"aria-hidden":`true`}),(0,U.jsx)(`span`,{className:`truncate`,children:r})]},t):(0,U.jsx)(T1,{variant:`outline`,className:P9(n?.color,e),children:r},t)};return Array.isArray(e)?(0,U.jsx)(`div`,{className:q(`flex flex-wrap`,i===`dot`?`gap-x-3 gap-y-1`:`gap-1`),children:e.map((e,t)=>o(e,t))}):o(e)}function aht({value:e}){if(!e)return(0,U.jsx)(C7,{});let t=Bmt(),n=String(A9(e)??``),[r,i]=H.useState(!1);return(0,U.jsxs)(`span`,{className:`inline-flex items-center gap-1 group/email`,children:[(0,U.jsx)(Q,{variant:`link`,className:`p-0 h-auto font-normal text-blue-600 hover:text-blue-800`,asChild:!0,children:(0,U.jsx)(`a`,{href:`mailto:${n}`,onClick:e=>e.stopPropagation(),children:n})}),(0,U.jsx)(`button`,{type:`button`,className:`opacity-0 group-hover/email:opacity-100 transition-opacity p-0.5 rounded hover:bg-muted`,onClick:e=>{e.stopPropagation(),e.preventDefault(),navigator.clipboard.writeText(n).then(()=>{i(!0),setTimeout(()=>i(!1),2e3)}).catch(()=>{})},"aria-label":t(`detail.copyEmail`,`Copy email`),children:r?(0,U.jsx)(Yp,{className:`h-3 w-3 text-green-600`}):(0,U.jsx)(ab,{className:`h-3 w-3 text-muted-foreground`})})]})}function oht({value:e}){if(!e)return(0,U.jsx)(C7,{});let t=String(A9(e)??``);return(0,U.jsx)(Q,{variant:`link`,className:`p-0 h-auto font-normal text-blue-600 hover:text-blue-800`,asChild:!0,children:(0,U.jsx)(`a`,{href:t,target:`_blank`,rel:`noopener noreferrer`,onClick:e=>e.stopPropagation(),children:t})})}function sht({value:e}){if(!e)return(0,U.jsx)(C7,{});let t=Bmt(),n=String(A9(e)??``),[r,i]=H.useState(!1);return(0,U.jsxs)(`span`,{className:`inline-flex items-center gap-1 group/phone`,children:[(0,U.jsxs)(`a`,{href:`tel:${n}`,className:`inline-flex items-center gap-1 text-blue-600 hover:text-blue-800`,onClick:e=>e.stopPropagation(),children:[(0,U.jsx)(WG,{className:`h-3 w-3`}),n]}),(0,U.jsx)(`button`,{type:`button`,className:`opacity-0 group-hover/phone:opacity-100 transition-opacity p-0.5 rounded hover:bg-muted`,onClick:e=>{e.stopPropagation(),e.preventDefault(),navigator.clipboard.writeText(n).then(()=>{i(!0),setTimeout(()=>i(!1),2e3)}).catch(()=>{})},"aria-label":t(`detail.copyPhone`,`Copy phone number`),children:r?(0,U.jsx)(Yp,{className:`h-3 w-3 text-green-600`}):(0,U.jsx)(ab,{className:`h-3 w-3 text-muted-foreground`})})]})}function cht({value:e,field:t}){if(!e)return(0,U.jsx)(C7,{});if(t.multiple,Array.isArray(e)){let t=e.length;return(0,U.jsxs)(`span`,{className:`text-sm text-gray-600`,children:[t,` `,t===1?`file`:`files`]})}return(0,U.jsx)(`span`,{className:`text-sm truncate`,children:e.name||e.original_name||`File`})}function lht({value:e}){return e?Array.isArray(e)?(0,U.jsxs)(`div`,{className:`flex -space-x-2`,children:[e.slice(0,3).map((e,t)=>(0,U.jsx)(`img`,{src:e.url||``,alt:e.name||`Image ${t+1}`,className:`size-8 rounded-md border-2 border-white object-cover`},t)),e.length>3&&(0,U.jsxs)(`div`,{className:`size-8 rounded-md border-2 border-white bg-gray-100 flex items-center justify-center text-xs font-medium text-gray-600`,children:[`+`,e.length-3]})]}):(0,U.jsx)(`img`,{src:e.url||``,alt:e.name||`Image`,className:`size-10 rounded-md object-cover`}):(0,U.jsx)(C7,{})}function I9({value:e,field:t}){let n=t.reference_to,r=(()=>{if(Array.isArray(e))return e.find(e=>e!=null&&(typeof e==`string`||typeof e==`number`)&&e!==``);if(e!=null&&e!==``&&(typeof e==`string`||typeof e==`number`)&&typeof e!=`object`)return e})(),i=zmt(n,r);if(e==null||e===``)return(0,U.jsx)(C7,{});if(!Array.isArray(e)&&typeof e==`object`){let t=e,n=k9(t)||String(t.id||t._id||``);if(n)return(0,U.jsx)(`span`,{className:`truncate`,children:n})}let a=t.options||[],o=e=>{if(a.length>0){let t=a.find(t=>String(t.value)===String(e));if(t)return{text:t.label,muted:!1}}return e===r&&i?{text:i,muted:!1}:Rmt(e)?{text:`—`,muted:!0}:{text:String(e),muted:!1}};if(Array.isArray(e))return(0,U.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:e.map((e,t)=>{let n,r=!1;if(typeof e==`object`&&e)n=k9(e)||String(e.id||e._id||`[Object]`);else{let t=o(e);n=t.text,r=t.muted}return(0,U.jsx)(`span`,{className:q(`inline-flex items-center px-2 py-0.5 rounded text-xs font-medium`,r?`bg-muted/40 text-muted-foreground`:`bg-gray-50 text-gray-700 dark:bg-gray-800/50 dark:text-gray-200`),children:n},t)})});if(typeof e==`object`&&e)return(0,U.jsx)(`span`,{className:`truncate`,children:k9(e)||String(e.id||e._id||`[Object]`)});let{text:s,muted:c}=o(e);return(0,U.jsx)(`span`,{className:q(`truncate`,c&&`text-muted-foreground`),children:s})}function uht({value:e}){let t=A9(e);return t==null||t===``?(0,U.jsx)(C7,{}):(0,U.jsx)(`span`,{className:`text-gray-700 font-mono text-sm`,children:String(t)})}function L9({value:e}){if(!e)return(0,U.jsx)(C7,{});if(typeof e!=`object`)return(0,U.jsx)(`span`,{className:`truncate`,children:String(e)});if(Array.isArray(e))return(0,U.jsxs)(`div`,{className:`flex -space-x-2`,children:[e.slice(0,3).map((e,t)=>{if(typeof e!=`object`||!e)return(0,U.jsx)(`span`,{className:`truncate text-sm`,children:String(e)},t);let n=e.name||e.username||`User`;return(0,U.jsx)(S1,{className:`size-8 border-2 border-white`,title:n,children:(0,U.jsx)(w1,{className:`bg-blue-500 text-white text-xs`,children:n.split(` `).map(e=>e[0]).join(``).toUpperCase().slice(0,2)})},t)}),e.length>3&&(0,U.jsx)(S1,{className:`size-8 border-2 border-white`,children:(0,U.jsxs)(w1,{className:`bg-gray-200 text-gray-600 text-xs`,children:[`+`,e.length-3]})})]});let t=e.name||e.username||`User`;return(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(S1,{className:`size-8`,children:(0,U.jsx)(w1,{className:`bg-blue-500 text-white text-xs`,children:t.split(` `).map(e=>e[0]).join(``).toUpperCase().slice(0,2)})}),(0,U.jsx)(`span`,{className:`truncate`,children:t})]})}var R9=new Map;function z9(e,t){R9.set(e,t)}var dht={phone:`phone`,tel:`phone`,telephone:`phone`,email:`email`,url:`url`,uri:`url`,link:`url`,currency:`currency`,money:`currency`,percent:`percent`,percentage:`percent`},fht=new Set([`text`,`textarea`,`string`,`longtext`,``]);function B9(e){if(!e)return`text`;if(typeof e==`string`)return e;let t=(e.type||``).toLowerCase(),n=e.format,r=typeof n==`string`?n.toLowerCase():``;return r&&dht[r]&&fht.has(t)?dht[r]:e.type||`text`}function V9(e){return R9.has(e)?R9.get(e):{text:M9,textarea:M9,markdown:M9,html:M9,number:qmt,currency:Jmt,percent:Xmt,boolean:Qmt,date:$mt,datetime:eht,time:M9,select:F9,status:F9,lookup:I9,master_detail:I9,email:aht,url:oht,phone:sht,file:cht,image:lht,formula:uht,summary:uht,auto_number:M9,user:L9,owner:L9,password:()=>(0,U.jsx)(`span`,{children:`••••••`}),location:M9,object:()=>(0,U.jsx)(`span`,{className:`text-gray-500 italic`,children:`[Object]`}),vector:()=>(0,U.jsx)(`span`,{className:`text-gray-500 italic`,children:`[Vector]`}),grid:()=>(0,U.jsx)(`span`,{className:`text-gray-500 italic`,children:`[Grid]`})}[e]||M9}z9(`lookup`,I9),z9(`master_detail`,I9),z9(`select`,F9),z9(`status`,F9),z9(`user`,L9),z9(`owner`,L9),Mpt(V9);var pht={text:()=>Promise.resolve().then(()=>(W7(),$ft)).then(e=>({default:e.TextField})),textarea:()=>Promise.resolve().then(()=>(e9(),bpt)).then(e=>({default:e.TextAreaField})),number:()=>Promise.resolve().then(()=>(G7(),tpt)).then(e=>({default:e.NumberField})),boolean:()=>Promise.resolve().then(()=>(K7(),rpt)).then(e=>({default:e.BooleanField})),select:()=>Promise.resolve().then(()=>(J7(),spt)).then(e=>({default:e.SelectField})),date:()=>Promise.resolve().then(()=>(Y7(),lpt)).then(e=>({default:e.DateField})),datetime:()=>Promise.resolve().then(()=>(a9(),Hpt)).then(e=>({default:e.DateTimeField})),time:()=>Promise.resolve().then(()=>(o9(),Wpt)).then(e=>({default:e.TimeField})),email:()=>Promise.resolve().then(()=>(X7(),dpt)).then(e=>({default:e.EmailField})),phone:()=>Promise.resolve().then(()=>(Z7(),ppt)).then(e=>({default:e.PhoneField})),url:()=>Promise.resolve().then(()=>(Q7(),hpt)).then(e=>({default:e.UrlField})),currency:()=>Promise.resolve().then(()=>($7(),_pt)).then(e=>({default:e.CurrencyField})),percent:()=>Promise.resolve().then(()=>(s9(),Kpt)).then(e=>({default:e.PercentField})),password:()=>Promise.resolve().then(()=>(c9(),Jpt)).then(e=>({default:e.PasswordField})),markdown:()=>Promise.resolve().then(()=>(t9(),Spt)).then(e=>({default:e.RichTextField})),html:()=>Promise.resolve().then(()=>(t9(),Spt)).then(e=>({default:e.RichTextField})),lookup:()=>Promise.resolve().then(()=>(i9(),Ipt)).then(e=>({default:e.LookupField})),master_detail:()=>Promise.resolve().then(()=>(i9(),Ipt)).then(e=>({default:e.LookupField})),file:()=>Promise.resolve().then(()=>(l9(),Xpt)).then(e=>({default:e.FileField})),image:()=>Promise.resolve().then(()=>(u9(),tmt)).then(e=>({default:e.ImageField})),location:()=>Promise.resolve().then(()=>(d9(),imt)).then(e=>({default:e.LocationField})),formula:()=>Promise.resolve().then(()=>(f9(),omt)).then(e=>({default:e.FormulaField})),summary:()=>Promise.resolve().then(()=>(p9(),cmt)).then(e=>({default:e.SummaryField})),auto_number:()=>Promise.resolve().then(()=>(m9(),umt)).then(e=>({default:e.AutoNumberField})),user:()=>Promise.resolve().then(()=>(h9(),fmt)).then(e=>({default:e.UserField})),owner:()=>Promise.resolve().then(()=>(h9(),fmt)).then(e=>({default:e.UserField})),object:()=>Promise.resolve().then(()=>(g9(),mmt)).then(e=>({default:e.ObjectField})),vector:()=>Promise.resolve().then(()=>(_9(),gmt)).then(e=>({default:e.VectorField})),grid:()=>Promise.resolve().then(()=>(v9(),vmt)).then(e=>({default:e.GridField})),color:()=>Promise.resolve().then(()=>(y9(),bmt)).then(e=>({default:e.ColorField})),slider:()=>Promise.resolve().then(()=>(b9(),Smt)).then(e=>({default:e.SliderField})),rating:()=>Promise.resolve().then(()=>(x9(),wmt)).then(e=>({default:e.RatingField})),code:()=>Promise.resolve().then(()=>(S9(),Emt)).then(e=>({default:e.CodeField})),avatar:()=>Promise.resolve().then(()=>(C9(),Omt)).then(e=>({default:e.AvatarField})),address:()=>Promise.resolve().then(()=>(w9(),Amt)).then(e=>({default:e.AddressField})),geolocation:()=>Promise.resolve().then(()=>(T9(),Mmt)).then(e=>({default:e.GeolocationField})),signature:()=>Promise.resolve().then(()=>(E9(),Pmt)).then(e=>({default:e.SignatureField})),qrcode:()=>Promise.resolve().then(()=>(D9(),Imt)).then(e=>({default:e.QRCodeField}))};function mht(e){let t=pht[e];if(!t){console.warn(`Unknown field type: ${e}`);return}let n=H.lazy(t);b.register(e,n,{namespace:`field`})}function hht(){Object.keys(pht).forEach(e=>{mht(e)})}hht();var ght=(0,H.createContext)(null);ght.displayName=`PermissionContext`;function H9(){let e=(0,H.useContext)(ght);return(0,H.useMemo)(()=>e?{...e,can:(t,n)=>e.check(t,n).allowed,cannot:(t,n)=>!e.check(t,n).allowed}:{check:()=>({allowed:!0}),checkField:()=>!0,getFieldPermissions:()=>[],getRowFilter:()=>void 0,roles:[],isLoaded:!1,can:()=>!0,cannot:()=>!1},[e])}function U9(e){let{checkField:t,getFieldPermissions:n}=H9(),r=(0,H.useMemo)(()=>n(e),[n,e]);return(0,H.useMemo)(()=>({permissions:r,canRead:n=>t(e,n,`read`),canWrite:n=>t(e,n,`write`),readableFields:n=>n.filter(n=>t(e,n,`read`)),writableFields:n=>n.filter(n=>t(e,n,`write`))}),[r,t,e])}var _ht=new Set([`textarea`,`markdown`,`html`,`grid`,`rich-text`,`field:textarea`,`field:markdown`,`field:html`,`field:grid`,`field:rich-text`]);function vht(e){return _ht.has(e)}function yht(e,t){let n;if(n=e<=3?1:e<=10?2:3,t!==void 0){if(t<640)return Math.min(n,1);if(t<900)return Math.min(n,2)}return n}function bht(e,t){return t<=1?e:e.map(e=>e.span===void 0&&e.type&&vht(e.type)?{...e,span:t}:e)}function xht(e,t,n){if(t!==void 0)return{fields:bht(e,t),columns:t};let r=yht(e.length,n);return{fields:bht(e,r),columns:r}}function Sht(e,t){return function(){try{let n=Vn();return n.t(t)===t?{t:(t,n)=>{let r=e[t]||t;if(n)for(let[e,t]of Object.entries(n))r=r.replace(`{{${e}}}`,String(t));return r}}:{t:n.t}}catch{return{t:(t,n)=>{let r=e[t]||t;if(n)for(let[e,t]of Object.entries(n))r=r.replace(`{{${e}}}`,String(t));return r}}}}}var W9=Sht({"detail.back":`Back`,"detail.edit":`Edit`,"detail.editInline":`Edit`,"detail.save":`Save`,"detail.saveChanges":`Save changes`,"detail.editFieldsInline":`Edit fields inline`,"detail.cancel":`Cancel`,"detail.cancelEdit":`Discard changes`,"detail.openInNewTab":`Open in new tab`,"detail.share":`Share`,"detail.duplicate":`Duplicate`,"detail.export":`Export`,"detail.viewHistory":`View history`,"detail.delete":`Delete`,"detail.moreActions":`More actions`,"detail.addToFavorites":`Add to favorites`,"detail.removeFromFavorites":`Remove from favorites`,"detail.previousRecord":`Previous record`,"detail.nextRecord":`Next record`,"detail.recordOf":`{{current}} of {{total}}`,"detail.recordNotFound":`Record not found`,"detail.recordNotFoundDescription":`The record you are looking for does not exist or may have been deleted.`,"detail.goBack":`Go back`,"detail.details":`Details`,"detail.related":`Related`,"detail.relatedRecords":`{{count}} records`,"detail.relatedRecordOne":`{{count}} record`,"detail.noRelatedRecords":`No related records found`,"detail.loading":`Loading...`,"detail.copyToClipboard":`Copy to clipboard`,"detail.copied":`Copied!`,"detail.deleteConfirmation":`Are you sure you want to delete this record?`,"detail.editRecord":`Edit record`,"detail.viewAll":`View All`,"detail.new":`New`,"detail.emptyValue":`—`,"detail.activity":`Activity`,"detail.copyRecordId":`Copy record ID`,"detail.showEmptyFields":`Show {{count}} empty fields`,"detail.hideEmptyFields":`Hide empty fields`,"detail.editRow":`Edit`,"detail.deleteRow":`Delete`,"detail.deleteRowConfirmation":`Are you sure you want to delete this record?`,"detail.actions":`Actions`,"detail.previousPage":`Previous`,"detail.nextPage":`Next`,"detail.pageOf":`Page {{current}} of {{total}}`,"detail.sortBy":`Sort by`,"detail.filterPlaceholder":`Filter...`,"detail.highlightFields":`Key Fields`,"detail.comments":`Comments`,"detail.searchComments":`Search comments…`,"detail.addCommentPlaceholder":`Add a comment… (Ctrl+Enter to submit)`,"detail.noMatchingComments":`No matching comments`,"detail.noCommentsYet":`No comments yet`,"detail.pinned":`Pinned`,"detail.pin":`Pin`,"detail.unpin":`Unpin`,"detail.justNow":`just now`,"detail.minutesAgo":`{{count}}m ago`,"detail.hoursAgo":`{{count}}h ago`,"detail.daysAgo":`{{count}}d ago`,"detail.createdBy":`Created by`,"detail.updatedBy":`Updated by`,"detail.dropFilesToUpload":`Drop files here or click to upload`,"detail.attachmentCount":`{{count}} attachment`,"detail.attachmentCountPlural":`{{count}} attachments`,"detail.removeAttachment":`Remove attachment`,"detail.unifiedDiff":`Unified diff`,"detail.sideBySideDiff":`Side-by-side diff`,"detail.noChanges":`No changes`,"detail.previousVersion":`Previous`,"detail.currentVersion":`Current`,"detail.discussion":`Discussion`,"detail.showDiscussion":`Show Discussion ({{count}})`,"detail.hideDiscussion":`Hide discussion`,"detail.bold":`Bold (Ctrl+B)`,"detail.italic":`Italic (Ctrl+I)`,"detail.listFormat":`List`,"detail.inlineCode":`Inline code`,"detail.mentionSomeone":`Mention someone`,"detail.preview":`Preview`,"detail.submitComment":`Submit (Ctrl+Enter)`,"detail.sendComment":`Send`,"detail.writeComment":`Write a comment…`,"detail.subscribedTooltip":`Subscribed — click to unsubscribe`,"detail.unsubscribedTooltip":`Subscribe to notifications`,"detail.firstRecord":`First record (Home)`,"detail.previousRecordKey":`Previous record (←)`,"detail.nextRecordKey":`Next record (→)`,"detail.lastRecord":`Last record (End)`,"detail.noRecords":`No records`,"detail.searchWhileNavigating":`Search while navigating`,"detail.searchRecords":`Search records…`,"detail.allActivity":`All Activity`,"detail.commentsOnly":`Comments Only`,"detail.fieldChangesFilter":`Field Changes`,"detail.tasksOnly":`Tasks Only`,"detail.leaveCommentPlaceholder":`Leave a comment… (Ctrl+Enter to submit)`,"detail.noActivity":`No activity recorded`,"detail.loadMore":`Load more`,"detail.edited":`(edited)`,"detail.via":`via {{source}}`,"detail.replyCount":`{{count}} reply`,"detail.replyCountPlural":`{{count}} replies`,"detail.replyPlaceholder":`Reply…`,"detail.filterActivity":`Filter activity`,"detail.openDiscussion":`Open discussion panel`,"detail.closeDiscussion":`Close discussion panel`,"detail.subscribeAriaLabel":`Subscribe to notifications`,"detail.unsubscribeAriaLabel":`Unsubscribe from notifications`,"detail.clearSearch":`Clear search`},`detail.back`);function Cht(e,t){return!e||e<=1||t<=1?``:t===2?e>=2?`md:col-span-2`:``:e===2?`md:col-span-2`:e>=3?`md:col-span-2 lg:col-span-3`:``}var G9=({section:e,data:t,className:n,objectSchema:r,objectName:i,isEditing:a=!1,onFieldChange:o,virtualScroll:s})=>{let[c,l]=H.useState(e.defaultCollapsed??!1),[u,d]=H.useState(null),[f,p]=H.useState(void 0),[m,h]=H.useState(!1),{t:g}=W9(),{fieldLabel:_,translateOptions:v}=Gn(),y=H.useCallback((e,t)=>{let n=t==null?``:String(t);navigator.clipboard.writeText(n).then(()=>{d(e),setTimeout(()=>d(null),2e3)})},[]),b=H.useCallback(e=>{let n=t?.[e.name]??e.value;return n==null||n===``},[t]),x=H.useMemo(()=>e.fields.filter(b).length,[e.fields,b]),S=C5(),C=S?3:6,w=S?.2:.5,T=e.fields.length-x,E=!e.hideEmpty&&!a&&e.fields.length>=C&&x/e.fields.length>=w&&T>0,D=!m&&(e.hideEmpty||E)?e.fields.filter(e=>!b(e)):e.fields;if(D.length===0&&x===e.fields.length)return null;let{fields:O,columns:k}=xht(D,e.columns),A=e=>{let n=t?.[e.name]??e.value;if(e.render)return(0,U.jsx)(Se,{schema:e.render,data:{...t,value:n}});let s=Cht(e.span,k),c=r?.fields?.[e.name],l={...e};if(c){!e.type&&c.type&&(l.type=c.type),c.options&&!l.options&&(l.options=c.options),c.currency&&!l.currency&&(l.currency=c.currency),c.precision!==void 0&&l.precision===void 0&&(l.precision=c.precision),c.format&&!l.format&&(l.format=c.format);let t=c.reference_to||c.reference;t&&!l.reference_to&&(l.reference_to=t),c.reference_field&&!l.reference_field&&(l.reference_field=c.reference_field)}i&&Array.isArray(l.options)&&l.options.length>0&&(l.options=v(i,e.name,l.options));let d=(()=>{if(n==null)return(0,U.jsx)(`span`,{className:`text-muted-foreground/50 text-xs italic`,children:`—`});let t=B9(l)||e.type;if(t){let e=V9(t);if(e)return(0,U.jsx)(e,{value:n,field:l})}return String(n)})(),f=n!=null&&n!==``,p=u===e.name;return(0,U.jsxs)(`div`,{className:q(`space-y-1.5 group`,s),children:[(0,U.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:_(i||``,e.name,e.label||e.name)}),a&&!e.readonly?(0,U.jsx)(`div`,{className:`min-h-[44px] sm:min-h-0`,children:(()=>{let t=l.type||e.type;if(t===`select`&&Array.isArray(l.options)&&l.options.length>0)return(0,U.jsx)(cpt,{field:l,value:n==null?``:String(n),onChange:t=>o?.(e.name,t)});if(t===`boolean`)return(0,U.jsx)(ipt,{field:l,value:!!n,onChange:t=>o?.(e.name,t)});let r=t===`date`||t===`datetime`;return(0,U.jsx)(`input`,{type:t===`number`?`number`:r?`date`:`text`,className:`w-full px-2 py-1.5 text-sm border rounded-md bg-background focus:outline-none focus:ring-2 focus:ring-ring`,value:n==null?``:r?(()=>{let e=String(n);if(/^\d{4}-\d{2}-\d{2}/.test(e))return e.slice(0,10);let t=new Date(e);return isNaN(t.getTime())?``:t.toLocaleDateString(`en-CA`)})():String(n),onChange:t=>{let n=t.target.value;if(r&&n){let t=new Date(n+`T00:00:00`).toISOString();o?.(e.name,t)}else o?.(e.name,n)}})})()}):(0,U.jsxs)(`div`,{className:q(`flex items-start justify-between gap-2 min-h-[44px] sm:min-h-0 rounded-md`,f&&`cursor-pointer active:bg-muted/60 transition-colors`),onClick:f?()=>y(e.name,n):void 0,onKeyDown:f?t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),y(e.name,n))}:void 0,role:f?`button`:void 0,tabIndex:f?0:void 0,children:[(0,U.jsx)(`div`,{className:`text-sm flex-1 break-words py-1`,children:d}),f&&(0,U.jsx)(P5,{children:(0,U.jsxs)(F5,{children:[(0,U.jsx)(I5,{asChild:!0,children:(0,U.jsx)(Q,{variant:`ghost`,size:`icon`,className:`h-6 w-6 opacity-0 group-hover:opacity-100 transition-opacity shrink-0`,onClick:t=>{t.stopPropagation(),y(e.name,n)},children:p?(0,U.jsx)(Yp,{className:`h-3 w-3 text-green-600`}):(0,U.jsx)(ab,{className:`h-3 w-3`})})}),(0,U.jsx)(L5,{children:g(p?`detail.copied`:`detail.copyToClipboard`)})]})})]})]},e.name)},j=s?.enabled===!0,M=s?.batchSize??20;H.useEffect(()=>{if(!j){p(void 0);return}if(O.length<=M){p(void 0);return}p(M);let e=setTimeout(()=>p(void 0),100);return()=>clearTimeout(e)},[j,O.length,M]);let N=f===void 0?O:O.slice(0,f),P=x>0&&(e.hideEmpty||E),F=(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`div`,{className:q(`grid gap-3 sm:gap-4`,k===1?`grid-cols-1`:k===2?`grid-cols-1 md:grid-cols-2`:`grid-cols-1 md:grid-cols-2 lg:grid-cols-3`),children:N.map(A)}),P&&(0,U.jsx)(`div`,{className:`mt-3 -ml-2`,children:(0,U.jsxs)(Q,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>h(e=>!e),className:`h-7 px-2 text-xs text-muted-foreground hover:text-foreground`,children:[(0,U.jsx)(m?AC:MC,{className:`h-3.5 w-3.5 mr-1.5`}),m?g(`detail.hideEmptyFields`,{defaultValue:`Hide empty fields`}):g(`detail.showEmptyFields`,{count:x,defaultValue:`Show ${x} empty field${x===1?``:`s`}`})]})})]});return!e.title&&!e.collapsible&&e.showBorder===!1?(0,U.jsx)(`div`,{className:q(n),children:F}):e.collapsible?(0,U.jsx)(m2,{open:!c,onOpenChange:e=>l(!e),className:n,children:(0,U.jsxs)(E0,{children:[(0,U.jsx)(h2,{asChild:!0,children:(0,U.jsxs)(D0,{className:q(`cursor-pointer hover:bg-muted/50 transition-colors`,e.headerColor&&`bg-${e.headerColor}`),children:[(0,U.jsxs)(O0,{className:`flex items-center justify-between`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.icon&&(0,U.jsx)(`span`,{className:`text-muted-foreground`,children:e.icon}),(0,U.jsx)(`span`,{children:e.title}),e.fields&&(0,U.jsx)(T1,{variant:`secondary`,className:`ml-2 text-xs`,children:e.fields.length})]}),(0,U.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,U.jsx)(c?Qp:Xp,{className:`h-4 w-4 text-muted-foreground`})})]}),e.description&&!c&&(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1.5`,children:e.description})]})}),(0,U.jsx)(g2,{children:(0,U.jsx)(A0,{className:`pt-4 sm:pt-6 px-3 sm:px-6`,children:F})})]})}):(0,U.jsxs)(E0,{className:q(e.showBorder===!1?`border-none shadow-none`:``,n),children:[e.title&&(0,U.jsxs)(D0,{className:q(e.headerColor&&`bg-${e.headerColor}`),children:[(0,U.jsx)(O0,{className:`flex items-center justify-between`,children:(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.icon&&(0,U.jsx)(`span`,{className:`text-muted-foreground`,children:e.icon}),(0,U.jsx)(`span`,{children:e.title})]})}),e.description&&(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1.5`,children:e.description})]}),(0,U.jsx)(A0,{className:`pt-4 sm:pt-6 px-3 sm:px-6`,children:F})]})},wht=({tabs:e,data:t,className:n})=>{let[r,i]=H.useState(e[0]?.key),a=e.filter(e=>typeof e.visible==`boolean`?e.visible:(e.visible,!0));return(0,U.jsxs)(l7,{value:r,onValueChange:i,className:n,children:[(0,U.jsx)(u7,{className:`w-full justify-start border-b rounded-none bg-transparent p-0`,children:a.map(e=>(0,U.jsx)(d7,{value:e.key,className:`relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent`,children:(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.icon&&(0,U.jsx)(`span`,{children:e.icon}),(0,U.jsx)(`span`,{children:e.label}),e.badge&&(0,U.jsx)(T1,{variant:`secondary`,className:`ml-1`,children:e.badge})]})},e.key))}),a.map(e=>(0,U.jsx)(f7,{value:e.key,className:`mt-4`,children:(0,U.jsx)(H.Suspense,{fallback:null,children:Array.isArray(e.content)?(0,U.jsx)(`div`,{className:`space-y-4`,children:e.content.map((e,n)=>(0,U.jsx)(Se,{schema:e,data:t},n))}):(0,U.jsx)(Se,{schema:e.content,data:t})})},e.key))]})};function Tht(e){return e&&u$[e.split(/[-_\s]/).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``)]||BN}var K9=({title:e,type:t,api:n,data:r,schema:i,columns:a,className:o,dataSource:s,objectName:c,onNew:l,onViewAll:u,onRowEdit:d,onRowDelete:f,onRowClick:p,maxColumns:m=6,pageSize:h,sortable:g=!1,filterable:_=!1,collapsible:v=!1,defaultCollapsed:y=!1,referenceField:b,icon:x})=>{let S=r!==void 0,C=r??[],[w,T]=H.useState(C),[E,D]=H.useState(!1),[O,k]=H.useState(0),[A,j]=H.useState(null),[M,N]=H.useState(`asc`),[P,F]=H.useState(``),[I,L]=H.useState(null),[ee,te]=H.useState(y),[ne,R]=H.useState({}),{t:z}=W9(),{fieldLabel:re}=Gn();H.useEffect(()=>{S&&T(r??[])},[r,S]),H.useEffect(()=>{n&&s?.getObjectSchema&&!a?.length&&s.getObjectSchema(n).then(L).catch(e=>{console.warn(`[RelatedList] Failed to fetch schema for ${n}:`,e)})},[n,s,a]),H.useEffect(()=>{n&&!S&&(D(!0),s&&typeof s.find==`function`?s.find(n).then(e=>{T(Array.isArray(e)?e:Array.isArray(e?.data)?e.data:[]),D(!1)}).catch(e=>{console.error(`Failed to fetch related data:`,e),D(!1)}):fetch(n).then(e=>e.json()).then(e=>{T(Array.isArray(e)?e:e?.data||[])}).catch(e=>{console.error(`Failed to fetch related data:`,e)}).finally(()=>D(!1)))},[n,S,s]),H.useEffect(()=>{if(!s?.find||!I?.fields||!w.length)return;let e=I.fields,t=[];for(let[n,r]of Object.entries(e)){if(!r||r.type!==`lookup`&&r.type!==`master_detail`)continue;let e=r.reference_to||r.reference;if(!e)continue;let i=new Set;for(let e of w){let t=e?.[n];t!=null&&(typeof t==`string`&&t?i.add(t):typeof t==`number`&&i.add(String(t)))}let a=ne[n]||{},o=Array.from(i).filter(e=>!(e in a));o.length>0&&t.push({fieldName:n,target:e,ids:o})}if(t.length===0)return;let n=!1;return Promise.all(t.map(({fieldName:e,target:t,ids:n})=>s.find(t,{$filter:{id:{$in:n}},$top:n.length}).then(t=>{let n=Array.isArray(t)?t:t?.data||[],r={};for(let e of n){let t=e?.id||e?._id;t&&(r[String(t)]=e?.full_name||e?.fullname||e?.display_name||e?.name||e?.subject||e?.title||e?.label||e?.code||String(t))}return{fieldName:e,map:r}}).catch(t=>(console.warn(`[RelatedList] Failed to resolve lookups for ${e}:`,t),{fieldName:e,map:{}})))).then(e=>{n||R(t=>{let n={...t};for(let{fieldName:t,map:r}of e)n[t]={...n[t]||{},...r};return n})}),()=>{n=!0}},[s,I,w]);let B=H.useMemo(()=>{if(!P)return w;let e=P.toLowerCase();return w.filter(t=>Object.values(t).some(t=>t!=null&&String(t).toLowerCase().includes(e)))},[w,P]),ie=H.useMemo(()=>A?[...B].sort((e,t)=>{let n=e[A],r=t[A];if(n==null&&r==null)return 0;if(n==null)return 1;if(r==null)return-1;let i=String(n).localeCompare(String(r),void 0,{numeric:!0});return M===`asc`?i:-i}):B,[B,A,M]),ae=h&&h>0?h:0,oe=ae?Math.max(1,Math.ceil(ie.length/ae)):1,V=ae?ie.slice(O*ae,(O+1)*ae):ie;H.useEffect(()=>{k(0)},[P,A,M]);let se=H.useCallback(e=>{A===e?N(e=>e===`asc`?`desc`:`asc`):(j(e),N(`asc`))},[A]),[ce,le]=H.useState(null),ue=H.useCallback(e=>{le(e)},[]),de=H.useCallback(()=>{ce&&f?.(ce),le(null)},[ce,f]),fe=H9(),pe=H.useMemo(()=>{let e=c||n||``,t=t=>!fe?.isLoaded||!e?t:t.filter(t=>{let n=t?.accessorKey||t?.field||t?.name;return n?fe.checkField(e,String(n),`read`):!0}),r=e=>b?e.filter(e=>(e?.accessorKey||e?.field||e?.name)!==b):e,i=e=>e==null||typeof e==`string`&&e.trim()===``||Array.isArray(e)&&e.length===0,o=e=>w.length?e.filter(e=>{let t=e?.accessorKey||e?.field||e?.name;return t?w.some(e=>!i(e?.[t])):!0}):e;if(a&&a.length>0)return o(t(r(a)));if(!I?.fields)return[];let s=e,l=new Set([`image`,`file`,`attachment`,`rich_text`,`html`,`json`]),u=[`name`,`full_name`,`fullname`,`title`,`subject`,`label`,`code`,`number`],d=Object.entries(I.fields).filter(([e,t])=>!(e.startsWith(`_`)||e===`id`||e===b||t?.hidden||t?.type&&l.has(t.type)||fe?.isLoaded&&s&&!fe.checkField(s,e,`read`)));return d.sort(([e,t],[n,r])=>{let i=u.indexOf(e),a=u.indexOf(n),o=i>=0?i:100,s=a>=0?a:100;if(o!==s)return o-s;let c=t?.type===`select`||e.includes(`status`);return c===(r?.type===`select`||n.includes(`status`))?0:c?-1:1}),o(d.map(([e,t])=>{let n={accessorKey:e,header:re(s,e,t.label||e)};if(t.type){let r=V9(B9({type:t.type,format:t.format})||t.type);if(r){let i=t.type===`lookup`||t.type===`master_detail`?ne[e]:void 0,a=i&&Object.keys(i).length>0?Object.entries(i).map(([e,t])=>({value:e,label:t})):void 0,o={name:e,label:t.label||e,type:t.type,...(a||t.options)&&{options:a||t.options},...t.currency&&{currency:t.currency},...t.precision!==void 0&&{precision:t.precision},...t.format&&{format:t.format},...(t.reference_to||t.reference)&&{reference_to:t.reference_to||t.reference},...t.reference_field&&{reference_field:t.reference_field}};n.cell=e=>e==null?H.createElement(`span`,{className:`text-muted-foreground/50 text-xs italic`},`—`):H.createElement(r,{value:e,field:o})}}return n})).slice(0,Math.max(1,m))},[a,I,c,n,re,b,w,m,ne,fe]),me=!!d||!!f,he=H.useMemo(()=>{if(i)return i;switch(t){case`grid`:case`table`:return{type:`data-table`,data:V,columns:pe,pagination:!1,pageSize:ae||10,searchable:!1,exportable:!1,rowActions:me,onRowEdit:d,onRowDelete:f?ue:void 0,onRowClick:p};case`list`:return{type:`data-list`,data:V};default:return{type:`div`,children:`No view configured`}}},[t,V,pe,i,ae,me,d,f,ue,p]),ge=v?`cursor-pointer select-none`:void 0,_e=v?()=>te(e=>!e):void 0,ve=Tht(x),ye=!E&&w.length===0,be=_;return(0,U.jsxs)(E0,{className:q(`shadow-none`,ye&&`bg-muted/20`,o),children:[(0,U.jsx)(D0,{className:q(`py-3 px-4`,ge),onClick:_e,children:(0,U.jsxs)(O0,{className:`flex items-center justify-between gap-2 text-sm font-semibold`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[v&&(0,U.jsx)(ee?Qp:Xp,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`}),(0,U.jsx)(ve,{className:`h-4 w-4 text-muted-foreground shrink-0`,"aria-hidden":!0}),(0,U.jsx)(`span`,{className:`truncate`,children:e}),(0,U.jsx)(T1,{variant:`secondary`,className:q(`text-xs font-normal h-5 px-1.5`,w.length===0&&`bg-muted text-muted-foreground`),"aria-label":`${w.length} records`,children:w.length})]}),(0,U.jsx)(`div`,{className:`flex items-center gap-1 shrink-0`,children:l&&(0,U.jsxs)(Q,{variant:`outline`,size:`sm`,onClick:e=>{e.stopPropagation(),l()},className:`gap-1 h-7 text-xs shadow-none`,children:[(0,U.jsx)(zK,{className:`h-3.5 w-3.5`}),z(`detail.new`)]})})]})}),!ee&&(0,U.jsxs)(A0,{className:q(`pt-0`,ye?`pb-3 px-4`:`pb-4 px-4`),children:[be&&(0,U.jsx)(`div`,{className:`mb-3`,children:(0,U.jsx)(f6,{placeholder:z(`detail.filterPlaceholder`),value:P,onChange:e=>F(e.target.value),className:`h-8 text-sm`})}),g&&pe&&pe.length>0&&w.length>0&&(0,U.jsx)(`div`,{className:`flex flex-wrap gap-1 mb-3`,children:pe.map(e=>{let t=e.accessorKey||e.field||e.name;if(!t)return null;let n=e.header||e.label||t,r=A===t;return(0,U.jsxs)(Q,{variant:r?`secondary`:`ghost`,size:`sm`,className:`gap-1 h-7 text-xs`,onClick:()=>se(t),children:[(0,U.jsx)(Xu,{className:`h-3 w-3`}),n,r&&(M===`asc`?` ↑`:` ↓`)]},t)})}),E?(0,U.jsx)(`div`,{className:`flex items-center justify-center py-6 text-muted-foreground text-sm`,children:z(`detail.loading`)}):ye?(0,U.jsxs)(`div`,{className:`flex flex-col items-center justify-center gap-2 py-6 text-sm`,children:[(0,U.jsx)(ve,{className:`h-8 w-8 text-muted-foreground/40`,"aria-hidden":!0}),(0,U.jsx)(`span`,{className:`text-muted-foreground italic`,children:z(`detail.noRelatedRecords`)}),l&&(0,U.jsxs)(Q,{variant:`outline`,size:`sm`,onClick:l,className:`gap-1 h-7 text-xs mt-1`,children:[(0,U.jsx)(zK,{className:`h-3.5 w-3.5`}),z(`detail.new`)]})]}):(0,U.jsx)(Se,{schema:he}),ae>0&&ie.length>ae&&(0,U.jsxs)(`div`,{className:`flex items-center justify-between mt-3 pt-3 border-t`,children:[(0,U.jsxs)(Q,{variant:`outline`,size:`sm`,className:`h-7 text-xs gap-1`,disabled:O===0,onClick:()=>k(e=>Math.max(0,e-1)),children:[(0,U.jsx)(Zp,{className:`h-3 w-3`}),z(`detail.previousPage`)]}),(0,U.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:z(`detail.pageOf`,{current:O+1,total:oe})}),(0,U.jsxs)(Q,{variant:`outline`,size:`sm`,className:`h-7 text-xs gap-1`,disabled:O>=oe-1,onClick:()=>k(e=>Math.min(oe-1,e+1)),children:[z(`detail.nextPage`),(0,U.jsx)(Qp,{className:`h-3 w-3`})]})]}),u&&!ye&&ae>0&&ie.length>ae&&(0,U.jsx)(`div`,{className:`mt-3 pt-3 border-t flex justify-center`,children:(0,U.jsxs)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),u()},className:`text-xs text-muted-foreground hover:text-foreground inline-flex items-center gap-1 transition-colors`,children:[z(`detail.viewAll`),(0,U.jsx)(EC,{className:`h-3 w-3`})]})})]}),(0,U.jsx)(QXe,{open:ce!==null,onOpenChange:e=>{e||le(null)},children:(0,U.jsxs)(d1,{children:[(0,U.jsxs)(f1,{children:[(0,U.jsx)(m1,{children:z(`detail.deleteRowTitle`,{defaultValue:`Delete record`})}),(0,U.jsx)(h1,{children:z(`detail.deleteRowConfirmation`)})]}),(0,U.jsxs)(p1,{children:[(0,U.jsx)(_1,{children:z(`detail.cancel`,{defaultValue:`Cancel`})}),(0,U.jsx)(g1,{onClick:de,className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:z(`detail.delete`,{defaultValue:`Delete`})})]})]})})]})},Eht=({group:e,data:t,className:n,objectSchema:r,objectName:i,isEditing:a=!1,onFieldChange:o})=>{let s=e.collapsible??!0,[c,l]=H.useState(e.defaultCollapsed??!1),u=(0,U.jsx)(`div`,{className:`space-y-3 sm:space-y-4`,children:e.sections.map((e,n)=>(0,U.jsx)(G9,{section:e,data:t,objectSchema:r,objectName:i,isEditing:a,onFieldChange:o},n))});return s?(0,U.jsxs)(m2,{open:!c,onOpenChange:e=>l(!e),className:n,children:[(0,U.jsx)(h2,{asChild:!0,children:(0,U.jsxs)(`div`,{className:`flex items-center gap-2 pb-2 border-b cursor-pointer hover:bg-muted/50 transition-colors rounded-t-md px-2 py-1.5`,children:[(0,U.jsx)(c?Qp:Xp,{className:`h-4 w-4 text-muted-foreground shrink-0`}),e.icon&&(0,U.jsx)(`span`,{className:`text-muted-foreground`,children:e.icon}),(0,U.jsx)(`h3`,{className:`text-lg font-semibold`,children:e.title})]})}),e.description&&!c&&(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:e.description}),(0,U.jsx)(g2,{children:(0,U.jsx)(`div`,{className:`mt-3`,children:u})})]}):(0,U.jsxs)(`div`,{className:q(`space-y-3`,n),children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2 pb-2 border-b`,children:[e.icon&&(0,U.jsx)(`span`,{className:`text-muted-foreground`,children:e.icon}),(0,U.jsx)(`h3`,{className:`text-lg font-semibold`,children:e.title})]}),e.description&&(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e.description}),u]})},Dht=({fields:e,data:t,className:n,objectName:r,objectSchema:i})=>{let{fieldLabel:a}=Gn();if(!e.length||!t)return null;let o=e.filter(e=>{let n=t?.[e.name];return n!=null&&n!==``});return o.length===0?null:(0,U.jsx)(E0,{className:q(`bg-muted/30 border-dashed`,n),children:(0,U.jsx)(A0,{className:`@container py-3 px-4`,children:(0,U.jsx)(`div`,{className:q(`grid gap-4`,o.length===1?`grid-cols-1`:o.length===2?`grid-cols-1 @sm:grid-cols-2`:o.length===3?`grid-cols-1 @sm:grid-cols-3`:`grid-cols-1 @sm:grid-cols-2 @xl:grid-cols-4`),children:o.map(e=>{let n=t[e.name],o=i?.fields?.[e.name],s=e.type||o?.type,c={name:e.name,label:e.label,type:s||`text`,...o?.options&&{options:o.options},...o?.currency&&{currency:o.currency},...o?.precision!==void 0&&{precision:o.precision},...o?.format&&{format:o.format}},l=V9(B9(c)||s||`text`);return(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,U.jsxs)(`span`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:[e.icon&&(0,U.jsx)(`span`,{className:`mr-1`,children:e.icon}),a(r||``,e.name,e.label)]}),(0,U.jsx)(`span`,{className:`block min-w-0 truncate text-sm font-semibold`,children:(0,U.jsx)(l,{value:n,field:c})})]},e.name)})})})})};function Oht(e){try{let t=new Date(e),n=new Date().getTime()-t.getTime(),r=Math.floor(n/6e4);if(r<1)return`just now`;if(r<60)return`${r}m ago`;let i=Math.floor(r/60);if(i<24)return`${i}h ago`;let a=Math.floor(i/24);return a<7?`${a}d ago`:t.toLocaleDateString()}catch{return e}}var kht=({comments:e,onAddComment:t,onTogglePin:n,searchable:r=!1,className:i})=>{let{t:a}=W9(),[o,s]=H.useState(``),[c,l]=H.useState(!1),[u,d]=H.useState(``),f=H.useCallback(async()=>{let e=o.trim();if(!(!e||!t)){l(!0);try{await t(e),s(``)}finally{l(!1)}}},[o,t]),p=H.useCallback(e=>{e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),f())},[f]),m=H.useMemo(()=>[...u.trim()?e.filter(e=>{let t=u.trim().toLowerCase();return e.text.toLowerCase().includes(t)||e.author.toLowerCase().includes(t)}):e].sort((e,t)=>e.pinned&&!t.pinned?-1:!e.pinned&&t.pinned?1:0),[e,u]);return(0,U.jsxs)(E0,{className:q(``,i),children:[(0,U.jsx)(D0,{children:(0,U.jsxs)(O0,{className:`flex items-center gap-2 text-base`,children:[(0,U.jsx)(nB,{className:`h-4 w-4`}),a(`detail.comments`),(0,U.jsxs)(`span`,{className:`text-sm font-normal text-muted-foreground`,children:[`(`,e.length,`)`]})]})}),(0,U.jsxs)(A0,{className:`space-y-4`,children:[r&&(0,U.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,U.jsxs)(`div`,{className:`relative flex-1`,children:[(0,U.jsx)(vZ,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground`}),(0,U.jsx)(`input`,{className:`w-full rounded-md border border-input bg-background pl-8 pr-8 py-1.5 text-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring`,placeholder:a(`detail.searchComments`),value:u,onChange:e=>d(e.target.value),"aria-label":a(`detail.searchComments`)}),u&&(0,U.jsx)(`button`,{className:`absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,onClick:()=>d(``),"aria-label":a(`detail.clearSearch`),type:`button`,children:(0,U.jsx)(c$,{className:`h-3.5 w-3.5`})})]})}),t&&(0,U.jsxs)(`div`,{className:`flex gap-2`,children:[(0,U.jsx)(`textarea`,{className:`flex-1 min-h-[60px] rounded-md border border-input bg-background px-3 py-2 text-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring resize-none`,placeholder:a(`detail.addCommentPlaceholder`),value:o,onChange:e=>s(e.target.value),onKeyDown:p,disabled:c}),(0,U.jsx)(Q,{size:`icon`,variant:`default`,onClick:f,disabled:!o.trim()||c,className:`shrink-0 self-end`,children:(0,U.jsx)(DZ,{className:`h-4 w-4`})})]}),m.length===0?(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground text-center py-4`,children:u.trim()?a(`detail.noMatchingComments`):a(`detail.noCommentsYet`)}):(0,U.jsx)(`div`,{className:`space-y-3`,children:m.map(e=>(0,U.jsxs)(`div`,{className:q(`flex gap-3`,e.pinned&&`bg-muted/40 rounded-md p-2 -mx-2`),children:[(0,U.jsx)(`div`,{className:`shrink-0`,children:e.avatarUrl?(0,U.jsx)(`img`,{src:e.avatarUrl,alt:e.author,className:`h-8 w-8 rounded-full object-cover`}):(0,U.jsx)(`div`,{className:`h-8 w-8 rounded-full bg-muted flex items-center justify-center text-xs font-medium text-muted-foreground`,children:e.author.charAt(0).toUpperCase()})}),(0,U.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2 mb-0.5`,children:[(0,U.jsx)(`span`,{className:`text-sm font-medium truncate`,children:e.author}),(0,U.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:Oht(e.createdAt)}),e.pinned&&(0,U.jsxs)(`span`,{className:`text-xs text-amber-600 flex items-center gap-0.5`,children:[(0,U.jsx)(gK,{className:`h-3 w-3`}),a(`detail.pinned`)]})]}),(0,U.jsx)(`p`,{className:`text-sm whitespace-pre-wrap break-words`,children:e.text}),n&&(0,U.jsxs)(`button`,{type:`button`,className:`mt-1 text-xs text-muted-foreground hover:text-foreground flex items-center gap-1`,onClick:()=>n(e.id),"aria-label":e.pinned?a(`detail.unpin`):a(`detail.pin`),children:[(0,U.jsx)(gK,{className:`h-3 w-3`}),e.pinned?a(`detail.unpin`):a(`detail.pin`)]})]})]},e.id))})]})]})},Aht={field_change:QQ,create:sg,delete:r$,comment:nB,status_change:Mu},jht={field_change:`bg-blue-100 text-blue-600`,create:`bg-green-100 text-green-600`,delete:`bg-red-100 text-red-600`,comment:`bg-purple-100 text-purple-600`,status_change:`bg-amber-100 text-amber-600`};function Mht(e){try{let t=new Date(e),n=new Date().getTime()-t.getTime(),r=Math.floor(n/6e4);if(r<1)return`just now`;if(r<60)return`${r}m ago`;let i=Math.floor(r/60);if(i<24)return`${i}h ago`;let a=Math.floor(i/24);return a<7?`${a}d ago`:t.toLocaleDateString()}catch{return e}}function Nht(e){return e.description?e.description:e.type===`field_change`&&e.field?`Changed ${e.field.charAt(0).toUpperCase()+e.field.slice(1).replace(/_/g,` `)} from "${e.oldValue==null?`(empty)`:String(e.oldValue)}" to "${e.newValue==null?`(empty)`:String(e.newValue)}"`:e.type===`create`?`Created this record`:e.type===`delete`?`Deleted this record`:e.type===`status_change`&&e.field?`Changed status to "${e.newValue==null?`(empty)`:String(e.newValue)}"`:`Updated record`}var Pht={all:`All`,field_change:`Field Changes`,create:`Creates`,delete:`Deletes`,comment:`Comments`,status_change:`Status Changes`},Fht=({activities:e,filterable:t=!1,defaultFilter:n=`all`,className:r})=>{let[i,a]=H.useState(n),o=H.useMemo(()=>i===`all`?e:e.filter(e=>e.type===i),[e,i]);return(0,U.jsxs)(E0,{className:q(``,r),children:[(0,U.jsx)(D0,{children:(0,U.jsxs)(O0,{className:`flex items-center gap-2 text-base`,children:[(0,U.jsx)(Co,{className:`h-4 w-4`}),`Activity`,(0,U.jsxs)(`span`,{className:`text-sm font-normal text-muted-foreground`,children:[`(`,o.length,`)`]})]})}),(0,U.jsxs)(A0,{children:[t&&(0,U.jsx)(`div`,{className:`flex flex-wrap gap-1.5 mb-4`,role:`group`,"aria-label":`Activity type filter`,children:Object.keys(Pht).map(e=>(0,U.jsxs)(`button`,{type:`button`,className:q(`inline-flex items-center gap-1 rounded-full px-2.5 py-0.5 text-xs font-medium transition-colors`,i===e?`bg-primary text-primary-foreground`:`bg-muted text-muted-foreground hover:bg-muted/80`),onClick:()=>a(e),"aria-pressed":i===e,children:[e!==`all`&&H.createElement(Aht[e]||QQ,{className:`h-3 w-3`}),Pht[e]]},e))}),o.length===0?(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground text-center py-4`,children:`No activity recorded`}):(0,U.jsxs)(`div`,{className:`relative`,children:[(0,U.jsx)(`div`,{className:`absolute left-4 top-2 bottom-2 w-px bg-border`}),(0,U.jsx)(`div`,{className:`space-y-4`,children:o.map(e=>{let t=Aht[e.type]||QQ;return(0,U.jsxs)(`div`,{className:`flex gap-3 relative`,children:[(0,U.jsx)(`div`,{className:q(`shrink-0 h-8 w-8 rounded-full flex items-center justify-center z-10`,jht[e.type]||`bg-gray-100 text-gray-600`),children:(0,U.jsx)(t,{className:`h-3.5 w-3.5`})}),(0,U.jsxs)(`div`,{className:`flex-1 min-w-0 pt-1`,children:[(0,U.jsxs)(`p`,{className:`text-sm`,children:[(0,U.jsx)(`span`,{className:`font-medium`,children:e.user}),` `,(0,U.jsx)(`span`,{className:`text-muted-foreground`,children:Nht(e)})]}),(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:Mht(e.timestamp)})]})]},e.id)})})]})]})]})},Iht={create:`default`,update:`secondary`,delete:`destructive`,restore:`outline`,login:`outline`,logout:`outline`,permission_change:`secondary`,config_change:`secondary`,export:`outline`,import:`outline`};function q9(e){if(!e)return``;let t=e instanceof Date?e:new Date(e);return Number.isNaN(t.getTime())?String(e):t.toLocaleString()}var Lht=[[60,`second`],[60,`minute`],[24,`hour`],[7,`day`],[4.34524,`week`],[12,`month`],[1/0,`year`]];function Rht(e,t){if(!e)return``;let n=e instanceof Date?e:new Date(e);if(Number.isNaN(n.getTime()))return String(e);let r=(n.getTime()-Date.now())/1e3;for(let[n,i]of Lht){if(Math.abs(r)<n)try{return new Intl.RelativeTimeFormat(t,{numeric:`auto`}).format(Math.round(r),i)}catch{return q9(e)}r/=n}return q9(e)}function zht(e){if(!e)return`?`;let t=e.trim().split(/\s+/).filter(Boolean).slice(0,2);return t.length===0?`?`:t.map(e=>e.charAt(0).toUpperCase()).join(``)}function Bht(e){if(e==null||e===``)return`—`;if(typeof e==`string`)return e;if(typeof e==`number`||typeof e==`boolean`)return String(e);try{return JSON.stringify(e)}catch{return String(e)}}function Vht({entries:e,loading:t,emptyText:n,className:r,locale:i}){return t?(0,U.jsx)(`div`,{className:q(`space-y-3`,r),children:Array.from({length:4}).map((e,t)=>(0,U.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,U.jsx)(w5,{className:`h-8 w-8 rounded-full`}),(0,U.jsxs)(`div`,{className:`flex-1 space-y-2`,children:[(0,U.jsx)(w5,{className:`h-4 w-1/3`}),(0,U.jsx)(w5,{className:`h-3 w-1/2`})]})]},t))}):!e||e.length===0?(0,U.jsx)(`div`,{className:q(`flex items-center justify-center rounded-md border border-dashed py-10 text-sm text-muted-foreground`,r),children:n??`No history yet`}):(0,U.jsx)(P5,{delayDuration:150,children:(0,U.jsx)(`ol`,{className:q(`space-y-4`,r),children:e.map((e,t)=>{let n=Iht[(e.action??``).toLowerCase()]??`outline`,r=typeof e.user_name==`string`&&e.user_name.trim()||`Unknown user`,a=q9(e.created_at),o=Rht(e.created_at,i),s=typeof e.user_avatar==`string`?e.user_avatar:void 0;return(0,U.jsxs)(`li`,{className:`flex items-start gap-3`,children:[(0,U.jsxs)(S1,{className:`h-8 w-8 mt-0.5 shrink-0`,children:[s?(0,U.jsx)(C1,{src:s,alt:r}):null,(0,U.jsx)(w1,{className:`text-[10px] font-medium`,children:zht(e.user_name)})]}),(0,U.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,U.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-2 gap-y-1`,children:[(0,U.jsx)(`span`,{className:`text-sm font-medium text-foreground`,children:r}),e.action&&(0,U.jsx)(T1,{variant:n,className:`text-[10px] uppercase tracking-wide`,children:e.action}),a&&(0,U.jsxs)(F5,{children:[(0,U.jsx)(I5,{asChild:!0,children:(0,U.jsx)(`span`,{className:`text-xs text-muted-foreground cursor-help`,"aria-label":a,children:o||a})}),(0,U.jsx)(L5,{children:a})]})]}),e.summary&&(0,U.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:e.summary}),e.changes&&e.changes.length>0&&(0,U.jsx)(`ul`,{className:`mt-1.5 space-y-0.5 text-xs text-muted-foreground`,children:e.changes.map(e=>(0,U.jsxs)(`li`,{className:`leading-relaxed`,children:[(0,U.jsx)(`span`,{className:`font-medium text-foreground`,children:e.label||e.field}),`: `,(0,U.jsx)(`span`,{className:`line-through opacity-70`,children:Bht(e.from)}),` → `,(0,U.jsx)(`span`,{className:`text-foreground`,children:Bht(e.to)})]},e.field))})]})]},e.id??t)})})})}var J9={createdAt:`created_at`,createdBy:`created_by`,updatedAt:`updated_at`,updatedBy:`updated_by`};function Hht(e){if(!e)return null;if(e instanceof Date)return isNaN(e.getTime())?null:e;if(typeof e==`string`||typeof e==`number`){let t=new Date(e);return isNaN(t.getTime())?null:t}return null}function Uht(e,t){let n=Date.now()-e.getTime(),r=Math.max(0,Math.floor(n/1e3));if(r<60)return t(`detail.justNow`);let i=Math.floor(r/60);if(i<60)return t(`detail.minutesAgo`,{count:i});let a=Math.floor(i/60);return a<24?t(`detail.hoursAgo`,{count:a}):t(`detail.daysAgo`,{count:Math.floor(a/24)})}function Wht(e){try{return new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`short`}).format(e)}catch{return e.toISOString()}}var Ght=({value:e,objectSchema:t,fieldName:n})=>{if(e==null||e===``)return null;let r=t?.fields?.[n],i=r?.reference_to||r?.reference,a={name:n,type:r?.type||(i?`lookup`:`text`),...i&&{reference_to:i},...r?.reference_field&&{reference_field:r.reference_field}},o=B9(a)||a.type;if(o){let t=V9(o);if(t)return(0,U.jsx)(`span`,{className:`inline-flex items-center [&_a]:text-inherit [&_a]:hover:underline`,children:(0,U.jsx)(t,{value:e,field:a})})}return(0,U.jsx)(`span`,{children:String(e)})},Kht=({label:e,user:t,date:n,objectSchema:r,userField:i,t:a})=>{if(!t&&!n)return null;let o=n?(0,U.jsx)(P5,{delayDuration:200,children:(0,U.jsxs)(F5,{children:[(0,U.jsx)(I5,{asChild:!0,children:(0,U.jsx)(`time`,{dateTime:n.toISOString(),className:`cursor-default underline decoration-dotted decoration-muted-foreground/40 underline-offset-2`,children:Uht(n,a)})}),(0,U.jsx)(L5,{side:`top`,children:Wht(n)})]})}):null;return(0,U.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,U.jsx)(`span`,{className:`text-muted-foreground/70`,children:e}),t?(0,U.jsx)(Ght,{value:t,objectSchema:r,fieldName:i}):null,t&&o?(0,U.jsx)(`span`,{className:`text-muted-foreground/40`,children:`·`}):null,o]})},qht=({data:e,objectSchema:t,objectName:n,className:r})=>{let{t:i}=W9();if(!e)return null;let a=Hht(e[J9.createdAt]),o=Hht(e[J9.updatedAt]),s=e[J9.createdBy],c=e[J9.updatedBy],l=!!(a||s),u=a&&o&&Math.abs(o.getTime()-a.getTime())<2e3,d=!!(o||c)&&!(u&&(s!=null&&c!=null&&String(s)===String(c)||!c));return!l&&!d?null:(0,U.jsxs)(`div`,{className:q(`mt-6 pt-3 border-t border-border/40`,`flex flex-wrap items-center gap-x-4 gap-y-1`,`text-xs text-muted-foreground`,r),"data-testid":`record-meta-footer`,children:[l&&(0,U.jsx)(Kht,{label:i(`detail.createdBy`),user:s,date:a,objectSchema:t,userField:J9.createdBy,t:i}),d&&(0,U.jsx)(Kht,{label:i(`detail.updatedBy`),user:c,date:o,objectSchema:t,userField:J9.updatedBy,t:i})]})},Jht=5;function Yht(e,t,n,r){if(e&&typeof e==`object`){if(t.primaryField){let n=e[t.primaryField];if(n!=null&&n!==``)return String(n)}let r=n?.titleFormat,i=typeof r==`string`?r:r&&typeof r==`object`&&typeof r.source==`string`?r.source:void 0;if(i){let t=`[-\\u2013\\u2014|/·,:]`,n=!1,r=i.replace(/\{([^{}]+)\}/g,(t,r)=>{let i=String(r).trim().split(`.`),a=e;for(let e of i){if(a==null)break;a=a[e]}if(a&&typeof a==`object`){let e=a,t=e.name??e.full_name??e.display_name??e.label??e.title??e.subject??null;(t==null||typeof t==`string`&&!t.trim())&&(t=[e.salutation,e.first_name,e.last_name].filter(e=>typeof e==`string`&&e.trim()).map(e=>e.trim()).join(` `)||(typeof e.email==`string`&&e.email.trim()?e.email.trim():null)),a=t}return a!=null&&a!==``?(n=!0,String(a)):`\0`});if(n){let e=r.replace(RegExp(`\\s*${t}\\s*`,`g`),``).replace(RegExp(`\\s*${t}\\s*`,`g`),``).replace(RegExp(`\0`,`g`),``).replace(/\s+/g,` `).trim();if(e)return e}}}if(t.title)return t.title;if(e&&typeof e==`object`)for(let t of[`name`,`full_name`,`fullName`,`title`,`subject`,`label`,`display_name`,`displayName`]){let n=e[t];if(typeof n==`string`&&n.trim())return n.trim();if(n!=null&&n!==``)return String(n)}return r}var Y9=({schema:e,dataSource:t,className:n,onEdit:r,onDelete:i,onBack:a,inlineEdit:o=!1,onFieldSave:s,discussionSlot:c,rightRail:l,objectLabel:u,onDataLoaded:d})=>{let[f,p]=H.useState(e.data),[m,h]=H.useState(!e.data&&!!(e.api&&e.resourceId||t&&e.objectName&&e.resourceId)),[g,_]=H.useState(!1),[v,y]=H.useState(!1),[b,x]=H.useState({}),[C,w]=H.useState(null),[T,E]=H.useState(!1),{t:D}=W9(),{fieldOptionLabel:O}=Gn(),k=H9(),A=H.useMemo(()=>{if(!k?.isLoaded||!e.objectName)return e;let t=t=>k.checkField(e.objectName,t,`read`),n=e=>e&&e.filter(e=>{let n=typeof e==`string`?e:e?.name;return!n||t(n)});return{...e,fields:n(e.fields),sections:e.sections?.map(e=>({...e,fields:n(e.fields)})),summaryFields:n(e.summaryFields)}},[e,k]);H.useEffect(()=>{f&&d&&d(f)},[f,d]);let j=H.useMemo(()=>{if(A.summaryFields&&A.summaryFields.length>0)return[];let e=[...A.sections?.flatMap(e=>e.fields)||[],...A.fields||[]],t={};for(let n of e)t[n.name]||(t[n.name]=n);if(C?.fields)for(let[e,n]of Object.entries(C.fields))t[e]={...t[e]||{},...n,name:e};let n=e=>f?.[e]!==void 0&&f?.[e]!==null&&f?.[e]!==``,r=[],i=[`status`,`stage`,`state`,`phase`].find(e=>t[e]&&n(e))||Object.keys(t).find(e=>t[e]?.type===`select`&&n(e));i&&r.push(i);let a=Object.keys(t).find(e=>(t[e]?.type===`currency`||/amount|revenue|value|total|price/i.test(e))&&n(e));a&&!r.includes(a)&&r.push(a);let o=Object.keys(t).find(e=>(t[e]?.type===`date`||t[e]?.type===`datetime`)&&/close|due|start|end|expected/i.test(e)&&n(e));return o&&!r.includes(o)&&r.push(o),r},[A.summaryFields,A.sections,A.fields,C,f]),M=A.summaryFields&&A.summaryFields.length>0?A.summaryFields:j,N=H.useCallback(()=>{A.resourceId&&navigator.clipboard.writeText(String(A.resourceId)).then(()=>{E(!0),setTimeout(()=>E(!1),1500)})},[A.resourceId]);H.useEffect(()=>{let e=!0;if(A.data){p(A.data),h(!1);return}if(t&&A.objectName&&A.resourceId){h(!0),w(null),p(null);let n=A.objectName,r=A.resourceId,i=`${n}-`,a=[...A.sections?.flatMap(e=>e.fields)||[],...A.fields||[]];(t.getObjectSchema?t.getObjectSchema(n).catch(()=>null):Promise.resolve(null)).then(o=>{if(!e)return;w(o);let s=S(o?.fields,a),c=s.length>0?{$expand:s}:void 0,l=c?t.findOne(n,r,c):t.findOne(n,r),u=()=>{let a=String(r),o=a.startsWith(i)?a.slice(i.length):`${i}${a}`;return(c?t.findOne(n,o,c):t.findOne(n,o)).then(t=>{e&&(p(t),h(!1))}).catch(()=>{e&&(p(null),h(!1))})};return l.catch(()=>null).then(t=>{if(e){if(t){p(t),h(!1);return}return u()}})}).catch(t=>{e&&(console.error(`Failed to fetch detail data:`,t),h(!1))})}else A.api&&A.resourceId&&(h(!0),fetch(`${A.api}/${A.resourceId}`).then(e=>e.json()).then(t=>{e&&p(t?.data||t)}).catch(e=>{console.error(`Failed to fetch detail data:`,e)}).finally(()=>{e&&h(!1)}));return()=>{e=!1}},[A.api,A.resourceId,A.objectName,t,A.sections,A.fields]);let P=H.useCallback(()=>{if(a)a();else if(A.onNavigate){let e=A.backUrl||(A.objectName?`/${A.objectName}`:`/`);A.onNavigate(e,{replace:!0})}else A.backUrl?window.location.href=A.backUrl:window.history.back()},[a,A]),F=H.useCallback(()=>{r?r():A.onNavigate&&A.editUrl?A.onNavigate(A.editUrl):A.onNavigate&&A.objectName&&A.resourceId?A.onNavigate(`/${A.objectName}/${A.resourceId}/edit`):A.editUrl&&(window.location.href=A.editUrl)},[r,A]),I=H.useCallback(()=>{let e=A.deleteConfirmation||D(`detail.deleteConfirmation`);window.confirm(e)&&(i?.(),A.onNavigate&&A.objectName&&A.onNavigate(`/${A.objectName}`,{replace:!0}))},[i,A]),L=H.useCallback(()=>{navigator.share&&A.objectName&&A.resourceId?navigator.share({title:A.title||D(`detail.details`),text:`${A.objectName} #${A.resourceId}`,url:window.location.href}).catch(e=>console.log(`Share failed:`,e)):navigator.clipboard.writeText(window.location.href).then(()=>{console.log(`Link copied to clipboard`)})},[A]),ee=H.useCallback(()=>{_(!g)},[g]),te=H.useCallback(()=>{if(v){let e=Object.entries(b);if(e.length>0){let t={...f,...b};p(t),e.forEach(([e,n])=>{s?.(e,n,t)})}x({})}y(!v)},[v,b,f,s]),ne=H.useCallback(()=>{x({}),y(!1)},[]),R=H.useCallback((e,t)=>{x(n=>({...n,[e]:t}))},[]);H.useEffect(()=>{if(!A.recordNavigation)return;let e=A.recordNavigation,t=t=>{let n=t.target?.tagName;n===`INPUT`||n===`TEXTAREA`||t.target?.isContentEditable||(t.key===`ArrowLeft`&&e.currentIndex>0?(t.preventDefault(),e.onNavigate(e.recordIds[e.currentIndex-1])):t.key===`ArrowRight`&&e.currentIndex<e.recordIds.length-1&&(t.preventDefault(),e.onNavigate(e.recordIds[e.currentIndex+1])))};return document.addEventListener(`keydown`,t),()=>document.removeEventListener(`keydown`,t)},[A.recordNavigation]);let z=H.useMemo(()=>A.related??[],[A.related]),re=H.useMemo(()=>{let e=[];return e.push({name:`sys_share`,label:D(`detail.share`),icon:`share-2`,type:`script`,onClick:L}),A.showEdit&&e.push({name:`sys_edit_mobile`,label:D(`detail.edit`),icon:`edit`,type:`script`,className:`sm:hidden`,onClick:F}),o&&e.push({name:`sys_toggle_inline_edit_mobile`,label:D(v?`detail.save`:`detail.editInline`),icon:`edit`,type:`script`,className:`sm:hidden`,onClick:te}),A.showDelete&&e.push({name:`sys_delete`,label:D(`detail.delete`),icon:`trash-2`,type:`script`,variant:`destructive`,tags:[`separator-before`],onClick:I}),e},[D,A.showEdit,A.showDelete,o,v,L,F,te,I]),B=H.useMemo(()=>{let e=A.actions??[];if(re.length===0)return e;let t=!1,n=e.map(e=>{let n=e;if(n&&typeof n==`object`&&n.type===`action:bar`&&(!n.location||n.location===`record_header`)){t=!0;let e=Array.isArray(n.systemActions)?n.systemActions:[];return{...n,systemActions:[...e,...re]}}return e});return t||n.push({type:`action:bar`,location:`record_header`,systemActions:re}),n},[A.actions,re]);return m||A.loading?(0,U.jsxs)(`div`,{className:q(`space-y-4`,n),children:[(0,U.jsx)(w5,{className:`h-10 w-full`}),(0,U.jsx)(w5,{className:`h-64 w-full`}),(0,U.jsx)(w5,{className:`h-48 w-full`})]}):!f&&!A.data?(0,U.jsxs)(`div`,{className:q(`flex flex-col items-center justify-center py-16 text-center`,n),children:[(0,U.jsx)(`p`,{className:`text-lg font-semibold`,children:D(`detail.recordNotFound`)}),(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:D(`detail.recordNotFoundDescription`)}),(A.showBack??!0)&&(0,U.jsxs)(Q,{variant:`outline`,size:`sm`,onClick:P,className:`mt-4 gap-2`,children:[(0,U.jsx)(Eu,{className:`h-4 w-4`}),D(`detail.goBack`)]})]}):(0,U.jsx)(P5,{children:(0,U.jsxs)(`div`,{className:q(`space-y-6`,n),children:[A.showHeader!==!1&&(0,U.jsxs)(`div`,{className:`flex flex-col sm:flex-row items-start justify-between gap-3 sm:gap-4 pb-4 border-b`,children:[(0,U.jsxs)(`div`,{className:`flex items-start gap-2 sm:gap-3 flex-1 min-w-0`,children:[(A.showBack??!0)&&(0,U.jsxs)(F5,{children:[(0,U.jsx)(I5,{asChild:!0,children:(0,U.jsx)(Q,{variant:`ghost`,size:`icon`,onClick:P,className:`shrink-0 mt-1`,children:(0,U.jsx)(Eu,{className:`h-4 w-4`})})}),(0,U.jsx)(L5,{children:D(`detail.back`)})]}),(0,U.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,U.jsx)(`h1`,{className:`text-xl sm:text-2xl font-bold truncate`,children:Yht(f,A,C,D(`detail.details`))}),M.map(e=>{let t=f?.[e];if(t==null||t===``)return null;let n=(A.sections||[]).flatMap(e=>e.fields).concat(A.fields||[]).find(t=>t.name===e),r=C?.fields?.[e],i=n?.type||r?.type,a=String(t),o=null;try{if(i===`currency`){let e=Number(t);Number.isNaN(e)||(a=new Intl.NumberFormat(void 0,{style:`currency`,currency:n?.currency||r?.currency||`USD`,maximumFractionDigits:0}).format(e))}else if(i===`date`||i===`datetime`){let e=new Date(t);Number.isNaN(e.getTime())||(a=i===`datetime`?e.toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`}):e.toLocaleDateString(void 0,{dateStyle:`medium`}))}else if(i===`percent`){let e=Number(t);if(!Number.isNaN(e)){a=`${e}%`;let t=e<=1?e*100:e;o=Math.max(0,Math.min(100,t))}}else if(i===`select`||i===`status`||i===`multiselect`){let i=n?.options||r?.options,o=String(t);if(Array.isArray(i)){let e=i.find(e=>String(e?.value??e)===String(t));e?.label&&(o=e.label)}else if(i&&typeof i==`object`){let e=i[String(t)];e?.label&&(o=e.label)}a=A.objectName?O(A.objectName,e,String(t),o):o}}catch{}return o===null?(0,U.jsx)(T1,{variant:`secondary`,className:`text-xs bg-primary/10 text-primary border-transparent hover:bg-primary/15`,"aria-label":`${e}: ${a}`,children:a},e):(0,U.jsxs)(T1,{variant:`secondary`,className:`text-xs bg-primary/10 text-primary border-transparent hover:bg-primary/15 gap-1.5 pl-2 pr-2`,"aria-label":`${e}: ${a}`,children:[(0,U.jsx)(`span`,{className:`relative inline-block h-1.5 w-12 rounded-full bg-primary/20 overflow-hidden`,"aria-hidden":!0,children:(0,U.jsx)(`span`,{className:`absolute inset-y-0 left-0 rounded-full bg-primary`,style:{width:`${o}%`}})}),a]},e)}),(0,U.jsxs)(F5,{children:[(0,U.jsx)(I5,{asChild:!0,children:(0,U.jsx)(Q,{variant:`ghost`,size:`icon`,className:`h-6 w-6 shrink-0`,onClick:ee,"aria-label":D(g?`detail.removeFromFavorites`:`detail.addToFavorites`),children:g?(0,U.jsx)($Q,{className:`h-4 w-4 fill-yellow-400 text-yellow-400`}):(0,U.jsx)($Q,{className:`h-4 w-4 text-muted-foreground`})})}),(0,U.jsx)(L5,{children:D(g?`detail.removeFromFavorites`:`detail.addToFavorites`)})]})]}),A.objectName&&(0,U.jsxs)(`p`,{className:`text-sm text-muted-foreground mt-1 flex items-center gap-1`,children:[(0,U.jsx)(`span`,{className:`font-medium`,children:u||A.objectName}),A.resourceId&&(0,U.jsxs)(F5,{children:[(0,U.jsx)(I5,{asChild:!0,children:(0,U.jsx)(Q,{variant:`ghost`,size:`icon`,className:`h-5 w-5 shrink-0 text-muted-foreground/60 hover:text-foreground`,onClick:N,"aria-label":D(`detail.copyRecordId`,{defaultValue:`Copy record ID`}),children:T?(0,U.jsx)(Yp,{className:`h-3 w-3 text-green-600`}):(0,U.jsx)(ab,{className:`h-3 w-3`})})}),(0,U.jsx)(L5,{children:T?D(`detail.copied`,{defaultValue:`Copied`}):D(`detail.copyRecordId`,{defaultValue:`Copy record ID`})})]})]})]})]}),(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 shrink-0 w-full sm:w-auto`,children:[A.recordNavigation&&(0,U.jsxs)(`div`,{className:`flex items-center gap-1 mr-2`,children:[(0,U.jsxs)(F5,{children:[(0,U.jsx)(I5,{asChild:!0,children:(0,U.jsx)(Q,{variant:`outline`,size:`icon`,className:`h-8 w-8`,disabled:A.recordNavigation.currentIndex<=0,onClick:()=>{let e=A.recordNavigation;e.currentIndex>0&&e.onNavigate(e.recordIds[e.currentIndex-1])},children:(0,U.jsx)(Zp,{className:`h-4 w-4`})})}),(0,U.jsx)(L5,{children:D(`detail.previousRecord`)})]}),(0,U.jsx)(`span`,{className:`text-xs text-muted-foreground whitespace-nowrap px-1`,children:D(`detail.recordOf`,{current:A.recordNavigation.currentIndex+1,total:A.recordNavigation.recordIds.length})}),(0,U.jsxs)(F5,{children:[(0,U.jsx)(I5,{asChild:!0,children:(0,U.jsx)(Q,{variant:`outline`,size:`icon`,className:`h-8 w-8`,disabled:A.recordNavigation.currentIndex>=A.recordNavigation.recordIds.length-1,onClick:()=>{let e=A.recordNavigation;e.currentIndex<e.recordIds.length-1&&e.onNavigate(e.recordIds[e.currentIndex+1])},children:(0,U.jsx)(Qp,{className:`h-4 w-4`})})}),(0,U.jsx)(L5,{children:D(`detail.nextRecord`)})]})]}),o&&(0,U.jsxs)(U.Fragment,{children:[v&&(0,U.jsxs)(F5,{children:[(0,U.jsx)(I5,{asChild:!0,children:(0,U.jsxs)(Q,{variant:`ghost`,size:`sm`,onClick:ne,className:`gap-2 hidden sm:inline-flex`,children:[(0,U.jsx)(c$,{className:`h-4 w-4`}),(0,U.jsx)(`span`,{className:`hidden sm:inline`,children:D(`detail.cancel`)})]})}),(0,U.jsx)(L5,{children:D(`detail.cancelEdit`)})]}),(0,U.jsxs)(F5,{children:[(0,U.jsx)(I5,{asChild:!0,children:(0,U.jsx)(Q,{variant:v?`default`:`outline`,size:`sm`,onClick:te,className:`gap-2 hidden sm:inline-flex`,children:v?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(Yp,{className:`h-4 w-4`}),(0,U.jsx)(`span`,{className:`hidden sm:inline`,children:D(`detail.save`)})]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(QQ,{className:`h-4 w-4`}),(0,U.jsx)(`span`,{className:`hidden sm:inline`,children:D(`detail.editInline`)})]})})}),(0,U.jsx)(L5,{children:D(v?`detail.saveChanges`:`detail.editFieldsInline`)})]})]}),A.showEdit&&(0,U.jsxs)(F5,{children:[(0,U.jsx)(I5,{asChild:!0,children:(0,U.jsxs)(Q,{variant:`default`,onClick:F,className:`gap-2 hidden sm:inline-flex`,children:[(0,U.jsx)(QQ,{className:`h-4 w-4`}),(0,U.jsx)(`span`,{className:`hidden sm:inline`,children:D(`detail.edit`)})]})}),(0,U.jsx)(L5,{children:D(`detail.editRecord`)})]}),B.map((e,t)=>(0,U.jsx)(Se,{schema:e,data:f},`header-action-${t}`))]})]}),A.header&&(0,U.jsx)(`div`,{children:(0,U.jsx)(Se,{schema:A.header,data:f})}),A.highlightFields&&A.highlightFields.length>0&&(0,U.jsx)(Dht,{fields:A.highlightFields,data:f,objectName:A.objectName,objectSchema:C}),A.autoTabs&&!A.tabs?.length?(()=>{let e=z.length>0,n=!!A.activities&&A.activities.length>0,r=!!c,i=!!A.history,a=(0,U.jsxs)(`div`,{className:`space-y-3 sm:space-y-4`,children:[A.sectionGroups&&A.sectionGroups.length>0&&A.sectionGroups.map((e,t)=>(0,U.jsx)(Eht,{group:e,data:{...f,...b},objectSchema:C,objectName:A.objectName,isEditing:v,onFieldChange:R},t)),A.sections&&A.sections.length>0&&A.sections.map((e,t)=>(0,U.jsx)(G9,{section:e,data:{...f,...b},objectSchema:C,objectName:A.objectName,isEditing:v,onFieldChange:R},t)),A.fields&&A.fields.length>0&&!A.sections?.length&&(0,U.jsx)(G9,{section:{fields:A.fields,columns:A.columns},data:{...f,...b},objectSchema:C,objectName:A.objectName,isEditing:v,onFieldChange:R}),A.comments&&(0,U.jsx)(kht,{comments:A.comments,onAddComment:A.onAddComment})]});return!e&&!n&&!r&&!i?(0,U.jsx)(`div`,{className:`mt-2`,children:a}):(0,U.jsxs)(l7,{defaultValue:`details`,className:`w-full`,children:[(0,U.jsxs)(u7,{className:`w-full justify-start border-b rounded-none bg-transparent p-0`,children:[(0,U.jsx)(d7,{value:`details`,className:`relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent`,children:D(`detail.details`)}),e&&(0,U.jsx)(d7,{value:`related`,className:`relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent`,children:(0,U.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[D(`detail.related`),(0,U.jsx)(T1,{variant:`secondary`,className:`text-xs bg-primary/10 text-primary border-transparent`,children:z.length})]})}),n&&(0,U.jsx)(d7,{value:`activity`,className:`relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent`,children:(0,U.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[D(`detail.activity`),(0,U.jsx)(T1,{variant:`secondary`,className:`text-xs bg-primary/10 text-primary border-transparent`,children:A.activities.length})]})}),r&&(0,U.jsx)(d7,{value:`discussion`,className:`relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent`,children:D(`detail.discussion`,{defaultValue:`Discussion`})}),i&&(0,U.jsx)(d7,{value:`history`,className:`relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent`,children:(0,U.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[D(`detail.history`,{defaultValue:`History`}),!A.history.loading&&A.history.entries.length>0&&(0,U.jsx)(T1,{variant:`secondary`,className:`text-xs bg-primary/10 text-primary border-transparent`,children:A.history.entries.length})]})})]}),(0,U.jsx)(f7,{value:`details`,className:`mt-4`,children:a}),e&&(0,U.jsx)(f7,{value:`related`,className:`mt-4`,children:(0,U.jsx)(`div`,{className:`space-y-3`,children:z.map((e,n)=>(0,U.jsx)(K9,{title:e.title,type:e.type,api:e.api,data:e.data,columns:e.columns,dataSource:t,objectName:e.api,referenceField:e.referenceField,icon:e.icon,onNew:e.onNew,onViewAll:e.onViewAll,onRowClick:e.onRowClick,onRowEdit:e.onRowEdit,onRowDelete:e.onRowDelete,collapsible:!0,pageSize:Jht},n))})}),n&&(0,U.jsx)(f7,{value:`activity`,className:`mt-4`,children:(0,U.jsx)(Fht,{activities:A.activities})}),r&&(0,U.jsx)(f7,{value:`discussion`,className:`mt-4`,children:c}),i&&(0,U.jsx)(f7,{value:`history`,className:`mt-4`,children:(0,U.jsx)(Vht,{entries:A.history.entries,loading:A.history.loading,emptyText:A.history.emptyText??D(`detail.historyEmpty`,{defaultValue:`No history yet`})})})]})})():(0,U.jsxs)(U.Fragment,{children:[A.sectionGroups&&A.sectionGroups.length>0&&(0,U.jsx)(`div`,{className:`space-y-3 sm:space-y-4`,children:A.sectionGroups.map((e,t)=>(0,U.jsx)(Eht,{group:e,data:{...f,...b},objectSchema:C,objectName:A.objectName,isEditing:v,onFieldChange:R},t))}),A.sections&&A.sections.length>0&&(0,U.jsx)(`div`,{className:`space-y-3 sm:space-y-4`,children:A.sections.map((e,t)=>(0,U.jsx)(G9,{section:e,data:{...f,...b},objectSchema:C,objectName:A.objectName,isEditing:v,onFieldChange:R},t))}),A.fields&&A.fields.length>0&&!A.sections?.length&&(0,U.jsx)(G9,{section:{fields:A.fields,columns:A.columns},data:{...f,...b},objectSchema:C,objectName:A.objectName,isEditing:v,onFieldChange:R}),A.tabs&&A.tabs.length>0&&(0,U.jsx)(wht,{tabs:A.tabs,data:f}),z.length>0&&(0,U.jsxs)(`div`,{className:`space-y-3`,children:[(0,U.jsx)(`h2`,{className:`text-lg font-semibold`,children:D(`detail.related`)}),z.map((e,n)=>(0,U.jsx)(K9,{title:e.title,type:e.type,api:e.api,data:e.data,columns:e.columns,dataSource:t,objectName:e.api,referenceField:e.referenceField,icon:e.icon,onNew:e.onNew,onViewAll:e.onViewAll,onRowClick:e.onRowClick,onRowEdit:e.onRowEdit,onRowDelete:e.onRowDelete,collapsible:!0,pageSize:Jht},n))]}),A.comments&&(0,U.jsx)(kht,{comments:A.comments,onAddComment:A.onAddComment}),A.activities&&A.activities.length>0&&(0,U.jsx)(Fht,{activities:A.activities})]}),(0,U.jsx)(qht,{data:{...f,...b},objectSchema:C,objectName:A.objectName}),A.footer&&(0,U.jsx)(`div`,{children:(0,U.jsx)(Se,{schema:A.footer,data:f})})]})})},Xht=e=>typeof e==`string`?e:e&&typeof e==`object`&&(e.field||e.name)||null,Zht=e=>{let{"data-obj-id":t,"data-obj-type":n,style:r,...i}=e||{};return{designer:{"data-obj-id":t,"data-obj-type":n,style:r},rest:i}},Qht=({schema:e={},className:t,...n})=>{let r=He(),{designer:i}=Zht(n);if(!r)return(0,U.jsx)(`div`,{className:t,"data-record-details-placeholder":!0,...i,children:(0,U.jsx)(`div`,{className:`text-xs text-muted-foreground italic px-3 py-2 border border-dashed rounded`,children:`record:details — bind a record to preview`})});let a=e.layout===`inline`||e.layout===`compact`?`horizontal`:`vertical`,o=r.objectName||``,s=H9(),{readableFields:c}=U9(o),l=Array.isArray(e.requiredPermissions)?e.requiredPermissions:[];if(l.length>0&&o&&!l.every(e=>s.can(o,e)))return(0,U.jsx)(`div`,{className:t,...i,role:`status`,"aria-live":`polite`,children:(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground italic`,children:`Insufficient permissions to view details.`})});let u=e.enforceFieldSecurity===!0,d=Array.isArray(e.redactFields)?e.redactFields:[],f=e=>{if(!e||!u&&d.length===0)return e;let t=e.map(Xht).filter(e=>!!e),n=new Set((u&&o?c(t):t).filter(e=>!d.includes(e)));return e.filter(e=>{let t=Xht(e);return t?n.has(t):!0})},p=e=>typeof e==`string`?{name:e}:e&&typeof e==`object`&&!e.name&&e.field?{...e,name:e.field}:e,m=e=>Array.isArray(e)?e.map(p):e,h=m(f(e.fields)),g=Array.isArray(e.sections)?e.sections.map(e=>({...e,title:e.title??e.label,fields:m(f(e.fields))})):e.sections,_={type:`detail-view`,objectName:r.objectName,resourceId:r.recordId,data:r.data,layout:a,columns:e.columns,sections:g,fields:h,showBack:!1,showHeader:e.showHeader??!1};return(0,U.jsx)(`div`,{className:t,...i,children:(0,U.jsx)(Y9,{schema:_,dataSource:r.dataSource})})},$ht=e=>typeof e==`string`?e:e&&typeof e==`object`&&(e.field||e.name||e.key)||null,egt=e=>{let{"data-obj-id":t,"data-obj-type":n,style:r,...i}=e||{};return{designer:{"data-obj-id":t,"data-obj-type":n,style:r},rest:i}},tgt=({schema:e={},className:t,...n})=>{let r=He(),{designer:i}=egt(n),a=e.title||e.objectName||`Related`,o=e.objectName;if(!o)return(0,U.jsx)(`div`,{className:t,...i,children:(0,U.jsx)(`div`,{className:`text-xs text-muted-foreground italic px-3 py-2 border border-dashed rounded`,children:`record:related_list — missing objectName`})});let s=H9(),{readableFields:c}=U9(o),l=Array.isArray(e.requiredPermissions)?e.requiredPermissions:[];if(l.length>0&&!l.every(e=>s.can(o,e)))return(0,U.jsx)(`div`,{className:t,...i,role:`status`,"aria-live":`polite`,children:(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground italic`,children:`Insufficient permissions to view related list.`})});let u=e.enforceFieldSecurity===!0,d=Array.isArray(e.redactFields)?e.redactFields:[],f=Array.isArray(e.columns)?e.columns:[],p=f;if(u||d.length>0){let e=f.map($ht).filter(e=>!!e),t=new Set((u?c(e):e).filter(e=>!d.includes(e)));p=f.filter(e=>{let n=$ht(e);return n?t.has(n):!0})}return(0,U.jsx)(`div`,{className:t,...i,children:(0,U.jsx)(K9,{title:a,type:`table`,api:o,objectName:o,referenceField:e.relationshipField,columns:p,pageSize:e.limit,dataSource:r?.dataSource})})},ngt=e=>{let{"data-obj-id":t,"data-obj-type":n,style:r,...i}=e||{};return{designer:{"data-obj-id":t,"data-obj-type":n,style:r},rest:i}},rgt=({schema:e={},className:t,...n})=>{let r=He(),{designer:i}=ngt(n),a=r?.objectName||``,o=H9(),{readableFields:s}=U9(a),c=Array.isArray(e.requiredPermissions)?e.requiredPermissions:[];if(c.length>0&&a&&!c.every(e=>o.can(a,e)))return(0,U.jsx)(`div`,{className:t,...i,role:`status`,"aria-live":`polite`,children:(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground italic`,children:`Insufficient permissions to view highlights.`})});let l=(Array.isArray(e.fields)?e.fields:[]).map(e=>typeof e==`string`?{name:e}:{name:e?.name,label:e?.label,icon:e?.icon,type:e?.type}).filter(e=>typeof e.name==`string`&&e.name.length>0),u=e.enforceFieldSecurity===!0,d=Array.isArray(e.redactFields)?e.redactFields:[],f=u&&a?new Set(s(l.map(e=>e.name))):null,p=l.filter(e=>!(d.includes(e.name)||f&&!f.has(e.name)));return(0,U.jsx)(`div`,{className:t,...i,children:(0,U.jsx)(Dht,{fields:p,data:r?.data,objectName:r?.objectName,objectSchema:r?.objectSchema})})},igt=({change:e,className:t})=>{let n=e.fieldLabel??e.field.charAt(0).toUpperCase()+e.field.slice(1).replace(/_/g,` `),r=e.oldDisplayValue??(e.oldValue==null?`(empty)`:String(e.oldValue)),i=e.newDisplayValue??(e.newValue==null?`(empty)`:String(e.newValue));return(0,U.jsxs)(`div`,{className:q(`flex items-center gap-1.5 text-sm flex-wrap`,t),children:[(0,U.jsx)(`span`,{className:`font-medium text-foreground`,children:n}),(0,U.jsx)(`span`,{className:`text-muted-foreground line-through`,children:r}),(0,U.jsx)(Ru,{className:`h-3 w-3 text-muted-foreground shrink-0`}),(0,U.jsx)(`span`,{className:`text-foreground`,children:i})]})},agt=[`👍`,`❤️`,`🎉`,`😂`,`😮`,`😢`],ogt=({reactions:e,onToggleReaction:t,emojiOptions:n=agt,className:r})=>{let[i,a]=H.useState(!1),o=H.useCallback(e=>{t?.(e),a(!1)},[t]);return(0,U.jsxs)(`div`,{className:q(`flex items-center gap-1 flex-wrap`,r),children:[e.map(e=>(0,U.jsxs)(`button`,{type:`button`,className:q(`inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-xs border transition-colors`,e.reacted?`bg-primary/10 border-primary/30 text-primary`:`bg-muted border-border text-muted-foreground hover:bg-muted/80`),onClick:()=>o(e.emoji),disabled:!t,"aria-label":`${e.emoji} ${e.count} reaction${e.count===1?``:`s`}`,children:[(0,U.jsx)(`span`,{children:e.emoji}),(0,U.jsx)(`span`,{children:e.count})]},e.emoji)),t&&(0,U.jsxs)(`div`,{className:`relative`,children:[(0,U.jsx)(Q,{variant:`ghost`,size:`icon`,className:`h-6 w-6`,onClick:()=>a(!i),"aria-label":`Add reaction`,children:(0,U.jsx)(KQ,{className:`h-3.5 w-3.5`})}),i&&(0,U.jsx)(`div`,{className:`absolute bottom-full mb-1 left-0 bg-popover border rounded-md shadow-md z-50 p-1.5 flex gap-1`,role:`listbox`,"aria-label":`Emoji picker`,children:n.map(t=>(0,U.jsx)(`button`,{type:`button`,className:`hover:bg-accent rounded p-1 text-base transition-colors`,onClick:()=>o(t),role:`option`,"aria-selected":e.some(e=>e.emoji===t&&e.reacted),children:t},t))})]})]})};function sgt(e){try{let t=new Date(e),n=new Date().getTime()-t.getTime(),r=Math.floor(n/6e4);if(r<1)return`just now`;if(r<60)return`${r}m ago`;let i=Math.floor(r/60);if(i<24)return`${i}h ago`;let a=Math.floor(i/24);return a<7?`${a}d ago`:t.toLocaleDateString()}catch{return e}}var cgt=({parentItem:e,replies:t,onAddReply:n,showReplyInput:r=!0,className:i})=>{let{t:a}=W9(),[o,s]=H.useState(!1),[c,l]=H.useState(``),[u,d]=H.useState(!1),f=H.useCallback(async()=>{let t=c.trim();if(!(!t||!n)){d(!0);try{await n(e.id,t),l(``)}finally{d(!1)}}},[c,n,e.id]),p=H.useCallback(e=>{e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),f())},[f]);return t.length===0&&!r?null:(0,U.jsxs)(`div`,{className:q(`ml-10 mt-1`,i),children:[t.length>0&&(0,U.jsxs)(`button`,{type:`button`,className:`flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors mb-1`,onClick:()=>s(!o),"aria-expanded":o,children:[(0,U.jsx)(o?Xp:Qp,{className:`h-3 w-3`}),(0,U.jsx)(nB,{className:`h-3 w-3`}),(0,U.jsx)(`span`,{children:t.length===1?a(`detail.replyCount`,{count:t.length}):a(`detail.replyCountPlural`,{count:t.length})})]}),o&&(0,U.jsx)(`div`,{className:`space-y-2 border-l-2 border-border pl-3`,children:t.map(e=>(0,U.jsxs)(`div`,{className:`flex gap-2`,children:[(0,U.jsx)(`div`,{className:`shrink-0`,children:e.actorAvatarUrl?(0,U.jsx)(`img`,{src:e.actorAvatarUrl,alt:e.actor,className:`h-6 w-6 rounded-full object-cover`}):(0,U.jsx)(`div`,{className:`h-6 w-6 rounded-full bg-muted flex items-center justify-center text-[10px] font-medium text-muted-foreground`,children:e.actor.charAt(0).toUpperCase()})}),(0,U.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,U.jsx)(`span`,{className:`text-xs font-medium`,children:e.actor}),(0,U.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:sgt(e.createdAt)})]}),(0,U.jsx)(`p`,{className:`text-xs whitespace-pre-wrap break-words`,children:e.body})]})]},e.id))}),r&&n&&(0,U.jsxs)(`div`,{className:`flex gap-1.5 mt-1.5`,children:[(0,U.jsx)(`input`,{className:`flex-1 rounded-md border border-input bg-background px-2 py-1 text-xs placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring`,placeholder:a(`detail.replyPlaceholder`),value:c,onChange:e=>l(e.target.value),onKeyDown:p,disabled:u}),(0,U.jsx)(Q,{variant:`ghost`,size:`icon`,className:`h-6 w-6 shrink-0`,onClick:f,disabled:!c.trim()||u,"aria-label":`Send reply`,children:(0,U.jsx)(DZ,{className:`h-3 w-3`})})]})]})},lgt=({subscription:e,onToggle:t,className:n})=>{let{t:r}=W9(),[i,a]=H.useState(!1),o=H.useCallback(async()=>{if(t){a(!0);try{await t(!e.subscribed)}finally{a(!1)}}},[t,e.subscribed]);return(0,U.jsx)(Q,{variant:`ghost`,size:`icon`,className:q(`h-8 w-8`,n),onClick:o,disabled:i||!t,"aria-label":e.subscribed?r(`detail.unsubscribeAriaLabel`):r(`detail.subscribeAriaLabel`),title:e.subscribed?r(`detail.subscribedTooltip`):r(`detail.unsubscribedTooltip`),children:e.subscribed?(0,U.jsx)(Gp,{className:`h-4 w-4 text-primary`}):(0,U.jsx)(Wp,{className:`h-4 w-4 text-muted-foreground`})})},ugt={comment:nB,field_change:QQ,task:YQ,event:qp,system:l$,email:HL,call:WG},dgt={comment:`bg-purple-100 text-purple-600`,field_change:`bg-blue-100 text-blue-600`,task:`bg-green-100 text-green-600`,event:`bg-amber-100 text-amber-600`,system:`bg-gray-100 text-gray-600`,email:`bg-indigo-100 text-indigo-600`,call:`bg-teal-100 text-teal-600`};function fgt(e){return[{value:`all`,label:e(`detail.allActivity`)},{value:`comments_only`,label:e(`detail.commentsOnly`)},{value:`changes_only`,label:e(`detail.fieldChangesFilter`)},{value:`tasks_only`,label:e(`detail.tasksOnly`)}]}function pgt(e){try{let t=new Date(e),n=new Date().getTime()-t.getTime(),r=Math.floor(n/6e4);if(r<1)return`just now`;if(r<60)return`${r}m ago`;let i=Math.floor(r/60);if(i<24)return`${i}h ago`;let a=Math.floor(i/24);return a<7?`${a}d ago`:t.toLocaleDateString()}catch{return e}}function mgt(e,t){switch(t){case`comments_only`:return e.filter(e=>e.type===`comment`);case`changes_only`:return e.filter(e=>e.type===`field_change`);case`tasks_only`:return e.filter(e=>e.type===`task`);default:return e}}var X9=({items:e,config:t,filterMode:n,onFilterChange:r,hasMore:i=!1,onLoadMore:a,loading:o=!1,onAddComment:s,onAddReply:c,onToggleReaction:l,subscription:u,onToggleSubscription:d,collapseWhenEmpty:f=!1,titleLabel:p,emptyLabel:m,className:h})=>{let{t:g}=W9(),[_,v]=H.useState(`all`),[y,b]=H.useState(``),[x,S]=H.useState(!1),[C,w]=H.useState(!1),T=n??_,E=t?.showFilterToggle!==!1,D=t?.showCommentInput!==!1&&!!s,O=t?.enableReactions??!1,k=t?.enableThreading??!1,A=t?.showSubscriptionToggle??!1,j=H.useMemo(()=>mgt(e,T),[e,T]),M=H.useMemo(()=>k?j.filter(e=>!e.parentId):j,[j,k]),N=H.useMemo(()=>{if(!k)return new Map;let e=new Map;for(let t of j)if(t.parentId){let n=e.get(t.parentId)??[];n.push(t),e.set(t.parentId,n)}return e},[j,k]),P=H.useCallback(e=>{r?r(e):v(e)},[r]),F=H.useCallback(async()=>{let e=y.trim();if(!(!e||!s)){S(!0);try{await s(e),b(``)}finally{S(!1)}}},[y,s]),I=H.useCallback(e=>{e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),F())},[F]),L=H.useCallback(async()=>{if(a){w(!0);try{await a()}finally{w(!1)}}},[a]);return(0,U.jsxs)(E0,{className:q(``,h),children:[(0,U.jsx)(D0,{children:(0,U.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,U.jsxs)(O0,{className:`flex items-center gap-2 text-base`,children:[(0,U.jsx)(Co,{className:`h-4 w-4`}),p??g(`detail.activity`),(0,U.jsxs)(`span`,{className:`text-sm font-normal text-muted-foreground`,children:[`(`,j.length,`)`]})]}),(0,U.jsx)(`div`,{className:`flex items-center gap-1`,children:A&&u&&(0,U.jsx)(lgt,{subscription:u,onToggle:d})})]})}),(0,U.jsxs)(A0,{className:`space-y-4`,children:[E&&(0,U.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,U.jsx)(`select`,{className:`rounded-md border border-input bg-background px-2.5 py-1.5 text-sm focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring`,value:T,onChange:e=>P(e.target.value),"aria-label":g(`detail.filterActivity`),children:fgt(g).map(e=>(0,U.jsx)(`option`,{value:e.value,children:e.label},e.value))})}),D&&(0,U.jsxs)(`div`,{className:`flex gap-2`,children:[(0,U.jsx)(`textarea`,{className:`flex-1 min-h-[60px] rounded-md border border-input bg-background px-3 py-2 text-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring resize-none`,placeholder:g(`detail.leaveCommentPlaceholder`),value:y,onChange:e=>b(e.target.value),onKeyDown:I,disabled:x}),(0,U.jsxs)(Q,{variant:`default`,onClick:F,disabled:!y.trim()||x,className:`shrink-0 self-end gap-1.5`,"aria-label":g(`detail.submitComment`),title:g(`detail.submitComment`),children:[(0,U.jsx)(DZ,{className:`h-4 w-4`}),(0,U.jsx)(`span`,{children:g(`detail.sendComment`)})]})]}),j.length===0?f?null:(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground text-center py-4`,children:m??g(`detail.noActivity`)}):(0,U.jsxs)(`div`,{className:`relative`,children:[(0,U.jsx)(`div`,{className:`absolute left-4 top-2 bottom-2 w-px bg-border`}),(0,U.jsx)(`div`,{className:`space-y-4`,children:M.map(e=>{let t=ugt[e.type]||l$,n=dgt[e.type]||`bg-gray-100 text-gray-600`,r=N.get(e.id)??[];return(0,U.jsxs)(`div`,{children:[(0,U.jsxs)(`div`,{className:`flex gap-3 relative`,children:[(0,U.jsx)(`div`,{className:q(`shrink-0 h-8 w-8 rounded-full flex items-center justify-center z-10`,n),children:e.actorAvatarUrl?(0,U.jsx)(`img`,{src:e.actorAvatarUrl,alt:e.actor,className:`h-8 w-8 rounded-full object-cover`}):(0,U.jsx)(t,{className:`h-3.5 w-3.5`})}),(0,U.jsxs)(`div`,{className:`flex-1 min-w-0 pt-1`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2 mb-0.5`,children:[(0,U.jsx)(`span`,{className:`text-sm font-medium`,children:e.actor}),e.source&&(0,U.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:g(`detail.via`,{source:e.source})}),(0,U.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:pgt(e.createdAt)}),e.edited&&(0,U.jsx)(`span`,{className:`text-xs text-muted-foreground italic`,children:g(`detail.edited`)}),e.pinned&&(0,U.jsxs)(`span`,{className:`text-xs text-amber-600`,children:[`📌 `,g(`detail.pinned`)]})]}),e.body&&(0,U.jsx)(`p`,{className:`text-sm whitespace-pre-wrap break-words text-muted-foreground`,children:e.body}),e.type===`field_change`&&e.fieldChanges&&(0,U.jsx)(`div`,{className:`space-y-1 mt-1`,children:e.fieldChanges.map((e,t)=>(0,U.jsx)(igt,{change:e},t))}),O&&e.reactions&&e.reactions.length>0&&(0,U.jsx)(`div`,{className:`mt-1.5`,children:(0,U.jsx)(ogt,{reactions:e.reactions,onToggleReaction:l?t=>l(e.id,t):void 0})}),O&&(!e.reactions||e.reactions.length===0)&&l&&(0,U.jsx)(`div`,{className:`mt-1.5`,children:(0,U.jsx)(ogt,{reactions:[],onToggleReaction:t=>l(e.id,t)})})]})]}),k&&(e.replyCount??0)>0&&(0,U.jsx)(cgt,{parentItem:e,replies:r,onAddReply:c,showReplyInput:!!c})]},e.id)})})]}),i&&(0,U.jsx)(`div`,{className:`text-center pt-2`,children:(0,U.jsxs)(Q,{variant:`ghost`,size:`sm`,onClick:L,disabled:C,"aria-label":g(`detail.loadMore`),children:[C?(0,U.jsx)(GI,{className:`h-4 w-4 animate-spin mr-1`}):(0,U.jsx)(Xp,{className:`h-4 w-4 mr-1`}),g(`detail.loadMore`)]})})]})]})},hgt=e=>{let{"data-obj-id":t,"data-obj-type":n,style:r,...i}=e||{};return{designer:{"data-obj-id":t,"data-obj-type":n,style:r},rest:i}},ggt=({schema:e={},className:t,...n})=>{He();let{designer:r}=hgt(n);return(0,U.jsx)(`div`,{className:t,...r,children:(0,U.jsx)(X9,{items:[],config:e})})},_gt=({config:e,items:t,hasMore:n,onLoadMore:r,loading:i,onAddComment:a,onAddReply:o,onToggleReaction:s,subscription:c,onToggleSubscription:l,filterMode:u,onFilterChange:d,collapseWhenEmpty:f=!1,className:p})=>{let m=e?.position??`right`,h=e?.width??`360px`,g=e?.collapsible??!0,_=f&&t.length===0||(e?.defaultCollapsed??!1),{t:v}=W9(),[y,b]=H.useState(_);return m===`right`||m===`left`?y&&g?(0,U.jsx)(`div`,{className:q(`flex items-start pt-4`,m===`right`?`border-l`:`border-r`,p),children:(0,U.jsx)(Q,{variant:`ghost`,size:`icon`,className:`h-8 w-8 mx-1`,onClick:()=>b(!1),"aria-label":v(`detail.openDiscussion`),children:(0,U.jsx)(wW,{className:`h-4 w-4`})})}):(0,U.jsxs)(`div`,{className:q(`flex flex-col overflow-hidden`,m===`right`?`border-l`:`border-r`,p),style:{width:h,minWidth:h},children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-3 border-b`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(nB,{className:`h-4 w-4`}),(0,U.jsx)(`span`,{className:`text-sm font-medium`,children:v(`detail.discussion`)})]}),g&&(0,U.jsx)(Q,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:()=>b(!0),"aria-label":v(`detail.closeDiscussion`),children:(0,U.jsx)(c$,{className:`h-3.5 w-3.5`})})]}),(0,U.jsx)(`div`,{className:`flex-1 overflow-y-auto`,children:(0,U.jsx)(X9,{items:t,config:e?.feed,hasMore:n,onLoadMore:r,loading:i,onAddComment:a,onAddReply:o,onToggleReaction:s,subscription:c,onToggleSubscription:l,filterMode:u,onFilterChange:d,collapseWhenEmpty:f,titleLabel:v(`detail.discussion`),emptyLabel:v(`detail.noCommentsYet`),className:`border-0 shadow-none`})})]}):(0,U.jsx)(`div`,{className:q(``,p),children:g&&y?(0,U.jsxs)(Q,{variant:`ghost`,className:`w-full justify-start gap-2 text-muted-foreground`,onClick:()=>b(!1),"aria-label":v(`detail.showDiscussion`,{count:t.length}),children:[(0,U.jsx)(nB,{className:`h-4 w-4`}),(0,U.jsx)(`span`,{children:v(`detail.showDiscussion`,{count:t.length})})]}):(0,U.jsxs)(`div`,{children:[g&&(0,U.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium`,children:[(0,U.jsx)(nB,{className:`h-4 w-4`}),v(`detail.discussion`)]}),(0,U.jsx)(Q,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:()=>b(!0),"aria-label":v(`detail.hideDiscussion`),children:(0,U.jsx)(yW,{className:`h-3.5 w-3.5`})})]}),(0,U.jsx)(X9,{items:t,config:e?.feed,hasMore:n,onLoadMore:r,loading:i,onAddComment:a,onAddReply:o,onToggleReaction:s,subscription:c,onToggleSubscription:l,filterMode:u,onFilterChange:d,collapseWhenEmpty:f,titleLabel:v(`detail.discussion`),emptyLabel:v(`detail.noCommentsYet`)})]})})},vgt=e=>{let{"data-obj-id":t,"data-obj-type":n,style:r,...i}=e||{};return{designer:{"data-obj-id":t,"data-obj-type":n,style:r},rest:i}},ygt=({schema:e={},className:t,...n})=>{He();let{designer:r}=vgt(n);return(0,U.jsx)(`div`,{className:t,...r,children:(0,U.jsx)(_gt,{items:[],config:e})})},bgt=e=>{let{"data-obj-id":t,"data-obj-type":n,style:r,...i}=e||{};return{designer:{"data-obj-id":t,"data-obj-type":n,style:r},rest:i}},xgt=({schema:e={},className:t,...n})=>{let r=He(),{designer:i}=bgt(n),a=Array.isArray(e.stages)?e.stages:[],o=e.statusField,s=o&&r?.data?r.data[o]:void 0,c=a.findIndex(e=>e.value===s);return c<0&&(c=-1),a.length===0?(0,U.jsx)(`div`,{className:t,...i,children:(0,U.jsx)(`div`,{className:`text-xs text-muted-foreground italic px-3 py-2 border border-dashed rounded`,children:`record:path — no stages configured`})}):(0,U.jsx)(`div`,{className:q(`flex w-full items-stretch gap-1`,t),role:`list`,"aria-label":e.aria?.label||`Record path`,...i,children:a.map((e,t)=>{let n=c>=0&&t<c,r=t===c;return(0,U.jsx)(`div`,{role:`listitem`,"aria-current":r?`step`:void 0,className:q(`relative flex-1 px-4 py-2 text-xs font-medium border text-center`,`first:rounded-l-md last:rounded-r-md`,r&&`bg-primary text-primary-foreground border-primary`,n&&`bg-muted text-muted-foreground`,!r&&!n&&`bg-background text-foreground/70`),children:(0,U.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[n&&(0,U.jsx)(`span`,{"aria-hidden":!0,children:`✓`}),e.label]})},`${e.value}-${t}`)})})},Sgt=e=>{let{"data-obj-id":t,"data-obj-type":n,style:r,...i}=e||{};return{designer:{"data-obj-id":t,"data-obj-type":n,style:r},rest:i}},Cgt=({schema:e={},className:t,...n})=>{let r=He(),{designer:i}=Sgt(n),a=H9(),o=Array.isArray(e.actions)?e.actions:Array.isArray(e.properties?.actions)?e.properties.actions:[],s=r?.objectName||``,c=Array.isArray(e.requiredPermissions)?e.requiredPermissions:[];if(c.length>0&&s&&!c.every(e=>a.can(s,e)))return(0,U.jsx)(`div`,{className:t,...i,role:`status`,"aria-live":`polite`,children:(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground italic`,children:`Insufficient permissions to view quick actions.`})});let l=e.location||`record_header`,{getActionsForLocation:u,executeAction:d}=Ne({actions:o,context:{record:r?.data,recordId:r?.recordId,objectName:r?.objectName}}),f=o.length>0?u(l):[];if(f.length===0)return(0,U.jsx)(`div`,{className:t,...i,children:(0,U.jsx)(`div`,{className:`text-xs text-muted-foreground italic px-3 py-2 border border-dashed rounded`,children:`record:quick_actions — no actions configured`})});let p=e.align||`end`,m=p===`start`?`justify-start`:p===`center`?`justify-center`:`justify-end`;return(0,U.jsx)(`div`,{className:q(`flex flex-wrap items-center gap-2`,l===`record_header`&&!e.inline&&`-mt-12 sm:-mt-14 mb-2 relative z-10`,m,t),role:`toolbar`,"aria-label":e.aria?.label||`Quick actions`,...i,children:f.map((t,n)=>{let r=t.label||t.name||`Action ${n+1}`;return(0,U.jsx)(Q,{variant:t.variant||e.variant||`default`,size:t.size||e.size||`sm`,disabled:typeof t.disabled==`boolean`?t.disabled:void 0,onClick:()=>{if(typeof t.onClick==`function`){t.onClick();return}t.name&&d(t.name)},children:r},t.name||`qa-${n}`)})})},wgt=new Set([`id`,`_id`,`__v`,`created_at`,`updated_at`,`createdAt`,`updatedAt`,`created_by`,`updated_by`,`organization_id`,`tenant_id`,`owner_id`,`deleted_at`,`is_deleted`]),Tgt=480,Egt=95;function Dgt({open:e,onClose:t,title:n,record:r,objectName:i,recordId:a,dataSource:o,objectSchema:s,width:c=`min(960px, 60vw)`,columns:l=2,systemFields:u=wgt,onFieldSave:d,onDelete:f,resizable:p=!0,fullPageHref:m}){let{t:h}=W9(),g=`objectui.drawerWidth.${i}`,[_,v]=H.useState(()=>{if(typeof window>`u`||!p)return null;try{let e=window.localStorage.getItem(g);if(e){let t=parseInt(e,10);if(Number.isFinite(t)&&t>=Tgt)return t}}catch{}return null}),y=H.useMemo(()=>p&&_!=null?`${_}px`:typeof c==`number`?`${c}px`:c,[p,_,c]),b=y?{width:y,maxWidth:y}:void 0,x=H.useRef(null),S=H.useCallback(e=>{if(!p)return;e.preventDefault();let t=_??(typeof window<`u`?Math.min(window.innerWidth*.6,960):720);x.current={startX:e.clientX,startWidth:t};let n=e=>{let t=x.current;if(!t)return;let n=t.startX-e.clientX,r=typeof window<`u`?window.innerWidth*Egt/100:1600,i=Math.min(r,Math.max(Tgt,t.startWidth+n));v(Math.round(i))},r=()=>{x.current,x.current=null,window.removeEventListener(`pointermove`,n),window.removeEventListener(`pointerup`,r),window.removeEventListener(`pointercancel`,r);try{v(e=>(e!=null&&window.localStorage.setItem(g,String(e)),e))}catch{}};window.addEventListener(`pointermove`,n),window.addEventListener(`pointerup`,r),window.addEventListener(`pointercancel`,r)},[p,_,g]),C=s?.fields??{},w=(Object.keys(C).length?Object.keys(C):Object.keys(r)).filter(e=>!u.has(e)&&!e.startsWith(`__`)).filter(e=>e in r).filter(e=>!C[e]?.hidden).map(e=>{let t=C[e]||{},n=t.type===`lookup`||t.type===`master_detail`||t.type===`reference`;return{name:e,label:t.label,type:t.type,readonly:!!t.readonly||n,options:t.options,currency:t.currency,precision:t.precision,format:t.format,reference_to:t.reference_to??t.referenceTo??t.target,reference_field:t.reference_field??t.referenceField,required:t.required,validation:t.validation,placeholder:t.placeholder,description:t.description}});return(0,U.jsx)(_5,{open:e,onOpenChange:e=>{e||t()},children:(0,U.jsxs)(v5,{side:`right`,className:`w-full overflow-y-auto p-0 sm:!max-w-none`,style:b,onOpenAutoFocus:e=>e.preventDefault(),children:[p&&(0,U.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize drawer`,onPointerDown:S,className:`hidden sm:block absolute left-0 top-0 h-full w-1.5 cursor-col-resize select-none bg-transparent hover:bg-primary/30 active:bg-primary/50 transition-colors z-10`}),(0,U.jsx)(y5,{className:`sr-only`,children:(0,U.jsx)(b5,{children:n})}),(0,U.jsx)(`div`,{className:`px-6 pt-6 pb-6`,children:(0,U.jsx)(Y9,{dataSource:o,inlineEdit:!0,schema:{type:`detail-view`,objectName:i,resourceId:String(a),data:r,showDelete:!0,columns:l,fields:w,actions:m?[{type:`action:bar`,location:`record_header`,systemActions:[{name:`sys_open_new_tab`,label:h(`detail.openInNewTab`),icon:`external-link`,type:`script`,onClick:()=>window.open(m,`_blank`,`noopener`)}]}]:void 0},onFieldSave:async(e,t)=>{try{await d?.(e,t)}catch(e){console.error(`[RecordDetailDrawer] inline field save failed:`,e)}},onDelete:async()=>{try{await f?.(),t()}catch(e){console.error(`[RecordDetailDrawer] delete failed:`,e)}}})})]})})}function Ogt(e,t){if(typeof window>`u`)return null;let n=window.location.pathname,r=`/${e}`,i=n.indexOf(r);return`${i>=0?n.slice(0,i):n.replace(/\/$/,``)}/${e}/record/${encodeURIComponent(String(t))}`}b.register(`detail-view`,Y9,{namespace:`plugin-detail`,label:`Detail View`,category:`Views`,icon:`FileText`,inputs:[{name:`title`,type:`string`,label:`Title`},{name:`objectName`,type:`string`,label:`Object Name`},{name:`resourceId`,type:`string`,label:`Resource ID`},{name:`api`,type:`string`,label:`API Endpoint`},{name:`data`,type:`object`,label:`Data`},{name:`layout`,type:`enum`,label:`Layout Mode`,enum:[`vertical`,`horizontal`,`grid`]},{name:`columns`,type:`number`,label:`Grid Columns`},{name:`sections`,type:`array`,label:`Sections`},{name:`fields`,type:`array`,label:`Fields`},{name:`tabs`,type:`array`,label:`Tabs`},{name:`related`,type:`array`,label:`Related Lists`},{name:`actions`,type:`array`,label:`Actions`},{name:`showBack`,type:`boolean`,label:`Show Back Button`,defaultValue:!0},{name:`backUrl`,type:`string`,label:`Back URL`},{name:`showEdit`,type:`boolean`,label:`Show Edit Button`,defaultValue:!1},{name:`editUrl`,type:`string`,label:`Edit URL`},{name:`showDelete`,type:`boolean`,label:`Show Delete Button`,defaultValue:!1},{name:`deleteConfirmation`,type:`string`,label:`Delete Confirmation Message`},{name:`loading`,type:`boolean`,label:`Show Loading State`},{name:`header`,type:`object`,label:`Custom Header`},{name:`footer`,type:`object`,label:`Custom Footer`}],defaultProps:{title:`Detail View`,showBack:!0,showEdit:!1,showDelete:!1,sections:[],fields:[],tabs:[],related:[]}}),b.register(`detail-section`,G9,{namespace:`plugin-detail`,label:`Detail Section`,category:`Detail Components`,inputs:[{name:`title`,type:`string`,label:`Title`},{name:`description`,type:`string`,label:`Description`},{name:`fields`,type:`array`,label:`Fields`,required:!0},{name:`collapsible`,type:`boolean`,label:`Collapsible`,defaultValue:!1},{name:`defaultCollapsed`,type:`boolean`,label:`Default Collapsed`,defaultValue:!1},{name:`columns`,type:`number`,label:`Columns`,defaultValue:2},{name:`showBorder`,type:`boolean`,label:`Show Border`,defaultValue:!0},{name:`headerColor`,type:`string`,label:`Header Color`}]}),b.register(`related-list`,K9,{namespace:`plugin-detail`,label:`Related List`,category:`Detail Components`,inputs:[{name:`title`,type:`string`,label:`Title`,required:!0},{name:`type`,type:`enum`,label:`Type`,enum:[{label:`List`,value:`list`},{label:`Grid`,value:`grid`},{label:`Table`,value:`table`}],defaultValue:`table`},{name:`api`,type:`string`,label:`API Endpoint`},{name:`data`,type:`array`,label:`Data`},{name:`columns`,type:`array`,label:`Columns`}]}),b.register(`detail`,Y9,{namespace:`view`,category:`view`,label:`Detail`,icon:`FileText`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`recordId`,type:`string`,label:`Record ID`},{name:`fields`,type:`array`,label:`Fields`}]}),b.register(`record:details`,Qht,{namespace:`record`,category:`record`,label:`Record Details`,icon:`FileText`}),b.register(`record:related_list`,tgt,{namespace:`record`,category:`record`,label:`Related List`,icon:`List`}),b.register(`record:highlights`,rgt,{namespace:`record`,category:`record`,label:`Highlights Panel`,icon:`Star`}),b.register(`record:activity`,ggt,{namespace:`record`,category:`record`,label:`Activity Timeline`,icon:`Activity`}),b.register(`record:chatter`,ygt,{namespace:`record`,category:`record`,label:`Chatter Feed`,icon:`MessageSquare`}),b.register(`record:path`,xgt,{namespace:`record`,category:`record`,label:`Path / Stepper`,icon:`GitBranch`}),b.register(`record:quick_actions`,Cgt,{namespace:`record`,category:`record`,label:`Quick Actions`,icon:`Zap`});var kgt=({schema:e,dataSource:t,className:n,data:r,loading:i,onRowClick:a,onCardClick:o,...s})=>{let{translateOptions:c}=Gn(),l=Array.isArray(r),[u,d]=(0,H.useState)([]),[f,p]=(0,H.useState)(null),[m,h]=(0,H.useState)(l?i??!1:!1),[g,_]=(0,H.useState)(null),[v,y]=(0,H.useState)(0),b=ve(e.bind);(0,H.useEffect)(()=>{if(!l&&!(!t?.onMutation||!e.objectName))return t.onMutation(t=>{t.resource===e.objectName&&y(e=>e+1)})},[t,e.objectName,l]),(0,H.useEffect)(()=>{l&&i!==void 0&&h(i)},[i,l]),(0,H.useEffect)(()=>{let n=!0;return(async()=>{if(!(!t||!e.objectName))try{let r=await t.getObjectSchema(e.objectName);n&&p(r)}catch(e){console.warn(`Failed to fetch object def`,e)}})(),()=>{n=!1}},[e.objectName,t]),(0,H.useEffect)(()=>{if(l)return;let n=!0;return e.objectName&&!b&&!e.data&&(async()=>{if(!(!t||typeof t.find!=`function`||!e.objectName)){n&&h(!0);try{let r=S(f?.fields),i=x(await t.find(e.objectName,{options:{$top:100},$filter:e.filter,...r.length>0?{$expand:r}:{}}));n&&d(i)}catch(e){console.error(`[ObjectKanban] Fetch error:`,e),n&&_(e)}finally{n&&h(!1)}}})(),()=>{n=!1}},[e.objectName,t,b,e.data,e.filter,l,f,v]);let C=(l?r:void 0)||b||e.data||u,w=(0,H.useMemo)(()=>{if(!Array.isArray(C))return[];let t=e.cardTitle||e.titleField,n=[`name`,`full_name`,`fullName`,`title`,`subject`,`label`,`display_name`,`displayName`],r=f?.titleFormat,i=typeof r==`string`?r:r&&typeof r==`object`&&typeof r.source==`string`?r.source:void 0,a=f?.NAME_FIELD_KEY,o=(e,t)=>{let n=`[-\\u2013\\u2014|/·,:]`,r=!1,i=e.replace(/\{([^{}]+)\}/g,(e,n)=>{let i=t[n.trim()];return i!=null&&i!==``?(r=!0,String(i)):`\0`});return r?i.replace(RegExp(`\\s*${n}\\s*`,`g`),``).replace(RegExp(`\\s*${n}\\s*`,`g`),``).replace(RegExp(`\0`,`g`),``).replace(/\s+/g,` `).trim():``};return C.map(r=>{let s;if(t&&(s=r[t],typeof s==`string`&&(s=s.trim())),!s&&i){let e=o(i,r);e&&(s=e)}if(!s&&a){let e=r[a];typeof e==`string`?s=e.trim():e&&(s=e)}if(!s)for(let e of n){let t=r[e],n=typeof t==`string`?t.trim():t;if(n){s=n;break}}let c=e=>e>=1e6?`$${(e/1e6).toFixed(1).replace(/\.0$/,``)}M`:e>=1e3?`$${Math.round(e/1e3)}K`:`$${e}`,l=/^[A-Za-z0-9_-]{12,32}$/,u=e=>{if(typeof e!=`string`||!l.test(e))return!1;let t=/[A-Z]/.test(e),n=/[a-z]/.test(e),r=/[0-9_-]/.test(e);return t&&n||t&&r||n&&r},d=e=>{let t=r[e];if(t==null||t===``)return;if(typeof t==`object`){let e=t;for(let t of[`name`,`full_name`,`display_name`,`label`,`title`,`username`]){let n=e[t];if(typeof n==`string`&&n.trim())return n.trim()}return}if(typeof t!=`string`)return String(t);let n=f?.fields?.[e];if(!((n?.type===`lookup`||n?.type===`master_detail`||n?.type===`reference`)&&u(t))&&!u(t))return t},p=[],m=Array.isArray(e.cardFields)?e.cardFields:[],h=new Set([...t?[t]:[],...a?[a]:[],`name`,`full_name`,`title`,`subject`,`display_name`]),g=e=>{let t=f?.fields?.[e],n=r[e];if(n==null||n===``)return;if(typeof n==`number`)return t?.type===`currency`||/amount|value|revenue|price|cost|total/.test(e)?c(n):String(n);if(typeof n==`string`){let r=t?.type,i=/(_date|_at|_time|_on|_by_date)$|^(date|datetime|created|updated|modified)$/i.test(e);if(r===`date`||i&&r===void 0){let e=j9(n,`short`);if(e&&e!==`—`)return e}if(r===`datetime`||i&&r===void 0&&/T\d{2}:\d{2}/.test(n)){let e=Kmt(n);if(e&&e!==`—`)return e}}if(typeof n==`object`)return d(e);let i=d(e);if(i!==void 0)return t?.options?.find(e=>String(e.value).toLowerCase()===String(n).toLowerCase())?.label||String(i)},_=[];if(m.length>0)for(let e of m){if(h.has(e))continue;let t=f?.fields?.[e],n=r[e];if(!(n==null||n===``))if(t?.type===`picklist`||t?.type===`multipicklist`||Array.isArray(t?.options)&&t.options.length>0){let e=t?.options?.find(e=>String(e.value).toLowerCase()===String(n).toLowerCase()),r=e?.label||String(n),i=P9(e?.color,n);_.push({label:r,colorClass:i})}else{let n=g(e);if(n){let e=t?.label;p.push(e?`${e}: ${n}`:n)}}}else{let e=[`amount`,`value`,`deal_value`,`expected_value`,`opportunity_value`].find(e=>typeof r[e]==`number`);e&&p.push(c(r[e]));let t=[`company`,`company_name`,`account`,`account_name`,`organization`],n;for(let e of t){let t=d(e);if(t){n=t;break}}n&&(!s||!String(s).includes(n))&&p.push(n);let i=[`owner`,`owner_name`,`assignee`,`assignee_name`],a;for(let e of i){let t=d(e);if(t){a=t;break}}a&&p.push(`@${a}`);for(let e of[`priority`,`severity`,`industry`,`rating`]){let t=r[e];if(t!=null&&t!==``){let n=(f?.fields?.[e])?.options?.find(e=>String(e.value).toLowerCase()===String(t).toLowerCase()),r=n?.label||String(t),i=P9(n?.color,t);if(_.push({label:r,colorClass:i}),_.length>=2)break}}}let v=r.description,y=(v==null||v===``||typeof v==`string`&&u(v))&&p.length>0?p.join(` · `):void 0;return{...r,id:r.id||r._id,title:s||`Untitled`,...y?{cardSubtitle:y}:{},...!Array.isArray(r.badges)&&_.length>0?{badges:_}:{}}})},[C,e,f]),T=(0,H.useMemo)(()=>{if(e.columns&&e.columns.length>0)if(typeof e.columns[0]==`string`){if(!e.groupBy)return e.columns.map(e=>({id:e,title:e}))}else return e.columns;if(e.groupBy&&f?.fields?.[e.groupBy]?.options){let t=f.fields[e.groupBy].options.map(e=>({value:e.value,label:e.label}));return(e.objectName?c(e.objectName,e.groupBy,t):t).map(e=>({id:e.value,title:e.label}))}if(e.groupBy&&w.length>0){let t=new Set(w.map(t=>t[e.groupBy]));return Array.from(t).map(e=>({id:String(e),title:String(e)}))}return[]},[e.columns,e.groupBy,e.objectName,w,f,c]),E=e.swimlaneField||e.grouping?.fields?.[0]?.field,D={...e,data:w,columns:T,className:n||e.className,...E?{swimlaneField:E}:{}},O=e.navigation??{mode:`drawer`,width:`min(960px, 60vw)`},k=a??o;!k&&(O.mode===`drawer`||O.mode===`modal`||O.mode===`split`||O.mode);let A=Te({navigation:O,objectName:e.objectName,onRowClick:k});if(g)return(0,U.jsxs)(`div`,{className:`p-4 border border-destructive/50 rounded bg-destructive/10 text-destructive`,children:[`Error loading kanban data: `,g.message]});let j=e.objectName?`${e.objectName.charAt(0).toUpperCase()+e.objectName.slice(1).replace(/_/g,` `)} Detail`:`Card Details`,M=H.useCallback(async(n,r,i,a)=>{let o=e.groupBy,s=e.objectName;if(!(!o||r===i)&&(l||d(e=>e.map(e=>String(e.id??e._id)===String(n)?{...e,[o]:i}:e)),!(!s||!t?.update)))try{await t.update(s,String(n),{[o]:i})}catch(e){console.warn(`[ObjectKanban] Failed to persist card move`,e),l||d(e=>e.map(e=>String(e.id??e._id)===String(n)?{...e,[o]:r}:e))}},[e.groupBy,e.objectName,t,l]);return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(Mgt,{schema:{...D,onCardClick:(e,t)=>{A.handleClick(e,t),o?.(e)},onCardMove:M}}),A.isOverlay&&A.isOpen&&A.selectedRecord&&(()=>{let n=e.objectName,r=A.selectedRecord,i=r.id??r._id;if(!n||i==null)return null;let a=e.cardTitle??e.titleField,o=a&&r[a]?String(r[a]):j;return(0,U.jsx)(Dgt,{open:!0,onClose:A.close,title:o,record:r,objectName:n,recordId:i,dataSource:t,objectSchema:f,width:A.width??`min(960px, 60vw)`,fullPageHref:Ogt(n,i)??void 0,onFieldSave:async(e,r)=>{t?.update&&(await t.update(n,String(i),{[e]:r}),d(t=>t.map(t=>String(t.id??t._id)===String(i)?{...t,[e]:r}:t)))},onDelete:async()=>{t?.delete&&(await t.delete(n,String(i)),d(e=>e.filter(e=>String(e.id??e._id)!==String(i))))}})})()]})},Agt=H.lazy(()=>$(()=>import(`./KanbanImpl-BDEKBo0c.js`),__vite__mapDeps([0,1]))),jgt=H.lazy(()=>$(()=>import(`./KanbanEnhanced-DRJONZER.js`),__vite__mapDeps([2,1]))),Mgt=({schema:e})=>{let t=H.useMemo(()=>{let{columns:t=[],data:n,groupBy:r,coverImageField:i}=e,a=e=>{if(!i)return e;let t=e[i];if(!t)return e;let n=typeof t==`string`?t:t?.url;return n?{...e,coverImage:n}:e};if(n&&r&&Array.isArray(n)){let e={};t.forEach(t=>{t.id&&(e[String(t.id).toLowerCase()]=t.id),t.title&&(e[String(t.title).toLowerCase()]=t.id)});let i=n.reduce((t,n)=>{let i=String(n[r]??``),o=e[i.toLowerCase()]??i;return t[o]||(t[o]=[]),t[o].push(a(n)),t},{});return t.map(e=>({...e,cards:[...(e.cards||[]).map(a),...i[e.id]||[]]}))}return t.map(e=>({...e,cards:(e.cards||[]).map(a)}))},[e]);return(0,U.jsx)(H.Suspense,{fallback:(0,U.jsx)(w5,{className:`w-full h-[600px]`}),children:(0,U.jsx)(Agt,{columns:t,onCardMove:e.onCardMove,onCardClick:e.onCardClick,className:e.className,quickAdd:e.quickAdd,onQuickAdd:e.onQuickAdd,coverImageField:e.coverImageField,conditionalFormatting:e.conditionalFormatting,swimlaneField:e.swimlaneField})})};b.register(`kanban-ui`,Mgt,{namespace:`plugin-kanban`,label:`Kanban Board`,icon:`LayoutDashboard`,category:`plugin`,inputs:[{name:`columns`,type:`array`,label:`Columns`,description:`Array of { id, title, cards, limit, className }`,required:!0},{name:`onCardMove`,type:`code`,label:`On Card Move`,description:`Callback when a card is moved`,advanced:!0},{name:`className`,type:`string`,label:`CSS Class`}],defaultProps:{columns:[{id:`todo`,title:`To Do`,cards:[{id:`card-1`,title:`Task 1`,description:`This is the first task`,badges:[{label:`High Priority`,variant:`destructive`},{label:`Feature`,variant:`default`}]},{id:`card-2`,title:`Task 2`,description:`This is the second task`,badges:[{label:`Bug`,variant:`destructive`}]}]},{id:`in-progress`,title:`In Progress`,limit:3,cards:[{id:`card-3`,title:`Task 3`,description:`Currently working on this`,badges:[{label:`In Progress`,variant:`default`}]}]},{id:`done`,title:`Done`,cards:[{id:`card-4`,title:`Task 4`,description:`This task is completed`,badges:[{label:`Completed`,variant:`outline`}]},{id:`card-5`,title:`Task 5`,description:`Another completed task`,badges:[{label:`Completed`,variant:`outline`}]}]}],className:`w-full`}}),b.register(`kanban-enhanced`,({schema:e})=>{let t=H.useMemo(()=>{let{columns:t=[],data:n,groupBy:r}=e;if(n&&r&&Array.isArray(n)){let e=n.reduce((e,t)=>{let n=t[r];return e[n]||(e[n]=[]),e[n].push(t),e},{});return t.map(t=>({...t,cards:[...t.cards||[],...e[t.id]||[]]}))}return t},[e]);return(0,U.jsx)(H.Suspense,{fallback:(0,U.jsx)(w5,{className:`w-full h-[600px]`}),children:(0,U.jsx)(jgt,{columns:t,onCardMove:e.onCardMove,onColumnToggle:e.onColumnToggle,enableVirtualScrolling:e.enableVirtualScrolling,virtualScrollThreshold:e.virtualScrollThreshold,className:e.className,quickAdd:e.quickAdd,onQuickAdd:e.onQuickAdd,conditionalFormatting:e.conditionalFormatting})})},{namespace:`plugin-kanban`,label:`Kanban Board (Enhanced)`,icon:`LayoutGrid`,category:`plugin`,inputs:[{name:`columns`,type:`array`,label:`Columns`,required:!0},{name:`enableVirtualScrolling`,type:`boolean`,label:`Virtual Scrolling`,defaultValue:!1},{name:`virtualScrollThreshold`,type:`number`,label:`Virtual Scroll Threshold`,defaultValue:50},{name:`onCardMove`,type:`code`,label:`On Card Move`,advanced:!0},{name:`onColumnToggle`,type:`code`,label:`On Column Toggle`,advanced:!0},{name:`className`,type:`string`,label:`CSS Class`}],defaultProps:{columns:[],enableVirtualScrolling:!1,virtualScrollThreshold:50,className:`w-full`}});var Ngt=({schema:e,...t})=>{let{dataSource:n}=_e()||{};return(0,U.jsx)(kgt,{schema:e,dataSource:n,...t})};b.register(`object-kanban`,Ngt,{namespace:`plugin-kanban`,label:`Object Kanban`,category:`view`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`columns`,type:`array`,label:`Columns`}]}),b.register(`kanban`,Ngt,{namespace:`view`,label:`Kanban Board`,category:`view`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`columns`,type:`array`,label:`Columns`}]});var Pgt=H.lazy(()=>$(()=>import(`./ChartImpl-VXhwEQF3.js`),__vite__mapDeps([3,4]))),Fgt=H.lazy(()=>$(()=>import(`./AdvancedChartImpl-hdVtuhK5.js`),__vite__mapDeps([5,4]))),Igt=({schema:e})=>(0,U.jsx)(H.Suspense,{fallback:(0,U.jsx)(w5,{className:`w-full h-48 sm:h-64 md:h-80 lg:h-[400px]`}),children:(0,U.jsx)(Pgt,{data:e.data,dataKey:e.dataKey,xAxisKey:e.xAxisKey,height:e.height,className:e.className,color:e.color})}),Z9=({schema:e,onChartClick:t})=>{let n=H.useMemo(()=>{let t=e.series,n=e.xAxisKey,r=e.config;if(n||(e.index?n=e.index:e.category&&(n=e.category)),t||(e.categories?t=e.categories.map(e=>({dataKey:e})):e.value&&(t=[{dataKey:e.value}])),!r&&t){let n=e.colors||[`hsl(var(--chart-1))`,`hsl(var(--chart-2))`,`hsl(var(--chart-3))`],i={};t.forEach((e,t)=>{i[e.dataKey]={label:e.label||e.dataKey,color:n[t%n.length]}}),r=i}return{chartType:e.chartType,data:Array.isArray(e.data)?e.data:[],config:r,xAxisKey:n,series:t,className:e.className}},[e]);return(0,U.jsx)(H.Suspense,{fallback:(0,U.jsx)(w5,{className:`w-full h-48 sm:h-64 md:h-80 lg:h-[400px]`}),children:(0,U.jsx)(Fgt,{chartType:n.chartType,data:n.data,config:n.config,xAxisKey:n.xAxisKey,series:n.series,className:n.className,onChartClick:t})})};function Q9(e){return e.replace(/[_-]/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}function Lgt(e,t){let{field:n,function:r,groupBy:i}=t,a={};for(let t of e){let e=String(t[i]??`Unknown`);a[e]||(a[e]=[]),a[e].push(t)}return Object.entries(a).map(([e,t])=>{let a=t.map(e=>Number(e[n])||0),o;switch(r){case`count`:o=t.length;break;case`avg`:o=a.length>0?a.reduce((e,t)=>e+t,0)/a.length:0;break;case`min`:o=a.length>0?Math.min(...a):0;break;case`max`:o=a.length>0?Math.max(...a):0;break;default:o=a.reduce((e,t)=>e+t,0);break}return{[i]:e,[n]:o}})}async function Rgt(e,t,n,r,i){if(!e.length||!t)return e;let a=i||((e,t)=>t),o=`__raw_${t}`,s=n?.fields?.[t];if(!s){let n=/^\d{4}-\d{2}-\d{2}/;return e.map(e=>{let r=e[t],i=String(r??``),s=n.test(i)?i:Q9(i);return{...e,[t]:a(i,s),[o]:r}})}let c=s.type;if(c===`select`||c===`picklist`||c===`dropdown`){let n=s.options||[];if(n.length===0)return e.map(e=>{let n=e[t],r=String(n??``),i=Q9(r);return{...e,[t]:a(r,i),[o]:n}});let r={};for(let e of n)typeof e==`string`?r[e]=e:e&&typeof e==`object`&&(r[String(e.value)]=e.label||String(e.value));return e.map(e=>{let n=e[t],i=String(n??``),s=r[i]||Q9(i);return{...e,[t]:a(i,s),[o]:n}})}if(c===`lookup`||c===`master_detail`){let n=s.reference_to||s.reference;if(!n||!r||typeof r.find!=`function`)return e.map(e=>({...e,[o]:e[t]}));let i=[...new Set(e.map(e=>e[t]).filter(e=>e!=null))];if(i.length===0)return e.map(e=>({...e,[o]:e[t]}));let a=s.id_field||`id`;try{let c=x(await r.find(n,{$filter:{[a]:{$in:i}},$top:i.length})),l=s.reference_field||s.display_field||`name`,u={};for(let e of c){let t=String(e[a]??e.id??e._id??``),n=e[l]||e.name||e.label||e.title||t;t&&(u[t]=String(n))}return e.map(e=>{let n=e[t],r=String(n??``);return{...e,[t]:u[r]||r,[o]:n}})}catch(n){return console.warn(`[ObjectChart] Failed to resolve lookup labels:`,n),e.map(e=>({...e,[o]:e[t]}))}}if(c===`date`||c===`datetime`||c===`date_time`||c===`timestamp`||c===`time`)return e.map(e=>({...e,[o]:e[t]}));let l=/^\d{4}-\d{2}-\d{2}/;return e.map(e=>{let n=e[t],r=String(n??``);return{...e,[t]:l.test(r)?r:Q9(r),[o]:n}})}var zgt=e=>{let{schema:t}=e,n=(0,H.useContext)(ge),r=e.dataSource||n?.dataSource,i=ve(t.bind),{fieldOptionLabel:a}=Gn(),o=(0,H.useRef)(a);(0,H.useEffect)(()=>{o.current=a},[a]);let[s,c]=(0,H.useState)([]),[l,u]=(0,H.useState)(!1),[d,f]=(0,H.useState)(null),[p,m]=(0,H.useState)(null),h=(0,H.useMemo)(()=>t.aggregate?JSON.stringify(t.aggregate):``,[t.aggregate]),g=(0,H.useMemo)(()=>t.filter?JSON.stringify(t.filter):``,[t.filter]),_=(0,H.useCallback)(async(e,n)=>{if(!(!e||!t.objectName)){n.current&&(u(!0),f(null));try{let r,i=me(t.filter);if(t.aggregate&&typeof e.aggregate==`function`){let n=await e.aggregate(t.objectName,{field:t.aggregate.field,function:t.aggregate.function,groupBy:t.aggregate.groupBy,filter:i});r=Array.isArray(n)?n:[]}else if(typeof e.find==`function`)r=x(await e.find(t.objectName,{$filter:i})),t.aggregate&&r.length>0&&(r=Lgt(r,t.aggregate));else return;let a=t.aggregate?.groupBy||t.xAxisKey;if(a&&typeof e.getObjectSchema==`function`)try{let n=await e.getObjectSchema(t.objectName);r=await Rgt(r,a,n,e,(e,n)=>o.current(t.objectName,a,e,n))}catch{}n.current&&c(r)}catch(e){console.error(`[ObjectChart] Fetch error:`,e),n.current&&f(e instanceof Error?e.message:`Failed to load chart data`)}finally{n.current&&u(!1)}}},[t.objectName,h,g,t.xAxisKey]);(0,H.useEffect)(()=>{let e={current:!0};return t.objectName&&!i&&!t.data&&_(r,e),()=>{e.current=!1}},[t.objectName,r,i,t.data,g,h,_]);let v=i||t.data||s,y=Array.isArray(v)?v:[],b=t.drillDown,S=t.aggregate?.groupBy||t.xAxisKey,C=(0,H.useMemo)(()=>{if(!S)return new Map;let e=new Map,t=`__raw_${S}`;for(let n of y){let r=n?.[S];if(r==null)continue;let i=t in(n||{})?n[t]:r;e.set(String(r),i)}return e},[y,S]),w={...t,data:y};if(l&&y.length===0)return(0,U.jsx)(`div`,{className:`flex items-center justify-center text-muted-foreground text-sm p-4 `+(t.className||``),"data-testid":`chart-loading`,children:`Loading chart data…`});if(d)return(0,U.jsxs)(`div`,{className:`flex flex-col items-center justify-center gap-2 p-4 `+(t.className||``),"data-testid":`chart-error`,role:`alert`,children:[(0,U.jsx)(Em,{className:`h-6 w-6 text-destructive opacity-60`}),(0,U.jsx)(`p`,{className:`text-xs text-destructive font-medium`,children:`Failed to load chart data`}),(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground max-w-xs text-center`,children:d})]});if(!r&&t.objectName&&y.length===0)return(0,U.jsxs)(`div`,{className:`flex items-center justify-center text-muted-foreground text-sm p-4 `+(t.className||``),"data-testid":`chart-no-datasource`,children:[`No data source available for “`,t.objectName,`”`]});let T=pe(b)?e=>{let t=e.category,n=t!=null&&C.has(String(t))?C.get(String(t)):t;m({...e,category:n,categoryLabel:t,scope:`cell`})}:void 0,E=p&&t.objectName?(()=>{let e=de(b,p,{groupByField:S}),n={...t.filter||{},...e},i=fe(b,p,t.title||`Details`),a=b?.target??`drawer`,o=(0,U.jsx)(`div`,{className:`overflow-auto`,"data-testid":`chart-drill-body`,children:(0,U.jsx)(Se,{schema:{type:`object-data-table`,objectName:t.objectName,filter:n,pagination:!0,pageSize:b?.maxRows,columns:b?.columns?.map(e=>({accessorKey:e,header:e}))},dataSource:r})});return a===`dialog`?(0,U.jsx)(j2,{open:!0,onOpenChange:e=>!e&&m(null),children:(0,U.jsxs)(N2,{className:`max-w-4xl`,children:[(0,U.jsx)(P2,{children:(0,U.jsx)(I2,{children:i})}),o]})}):(0,U.jsx)(_5,{open:!0,onOpenChange:e=>!e&&m(null),children:(0,U.jsxs)(v5,{side:`right`,className:`w-full sm:max-w-2xl md:max-w-3xl lg:max-w-4xl flex flex-col`,children:[(0,U.jsx)(y5,{children:(0,U.jsx)(b5,{children:i})}),(0,U.jsx)(`div`,{className:`flex-1 overflow-hidden mt-2`,children:o})]})})})():null;return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(Z9,{...e,schema:w,onChartClick:T}),E]})};b.register(`object-chart`,zgt,{namespace:`plugin-charts`,label:`Object Chart`,category:`view`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`data`,type:`array`,label:`Data`,description:`Optional static data`},{name:`filter`,type:`array`,label:`Filter`},{name:`aggregate`,type:`object`,label:`Aggregate`,description:`Aggregation config: { field, function, groupBy }`}]}),b.register(`bar-chart`,Igt,{namespace:`plugin-charts`,label:`Bar Chart`,category:`plugin`,inputs:[{name:`data`,type:`array`,label:`Data`,required:!0},{name:`dataKey`,type:`string`,label:`Data Key`,defaultValue:`value`},{name:`xAxisKey`,type:`string`,label:`X-Axis Key`,defaultValue:`name`},{name:`height`,type:`number`,label:`Height`,defaultValue:400},{name:`color`,type:`color`,label:`Color`,defaultValue:`#8884d8`}],defaultProps:{data:[{name:`Jan`,value:400},{name:`Feb`,value:300},{name:`Mar`,value:600},{name:`Apr`,value:800},{name:`May`,value:500}],dataKey:`value`,xAxisKey:`name`,height:400,color:`#8884d8`}}),b.register(`chart`,zgt,{namespace:`view`,category:`view`,label:`Chart`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`type`,type:`string`,label:`Chart Type`},{name:`categoryField`,type:`string`,label:`Category Field`},{name:`valueField`,type:`string`,label:`Value Field`}]}),b.register(`chart`,Z9,{namespace:`plugin-charts`,label:`Chart`,category:`plugin`,inputs:[{name:`chartType`,type:`enum`,label:`Chart Type`,enum:[{label:`Bar`,value:`bar`},{label:`Line`,value:`line`},{label:`Area`,value:`area`},{label:`Pie`,value:`pie`},{label:`Donut`,value:`donut`},{label:`Radar`,value:`radar`},{label:`Scatter`,value:`scatter`}],defaultValue:`bar`},{name:`data`,type:`code`,label:`Data (JSON)`,required:!0},{name:`config`,type:`code`,label:`Config (JSON)`},{name:`xAxisKey`,type:`string`,label:`X Axis Key`,defaultValue:`name`},{name:`series`,type:`code`,label:`Series (JSON Array)`,required:!0},{name:`className`,type:`string`,label:`CSS Class`}],defaultProps:{chartType:`bar`,data:[{name:`Jan`,sales:400,revenue:240},{name:`Feb`,sales:300,revenue:139},{name:`Mar`,sales:600,revenue:380},{name:`Apr`,sales:800,revenue:430},{name:`May`,sales:500,revenue:220}],config:{sales:{label:`Sales`,color:`#8884d8`},revenue:{label:`Revenue`,color:`#82ca9d`}},xAxisKey:`name`,series:[{dataKey:`sales`},{dataKey:`revenue`}]}}),b.register(`chart:bar`,Z9,{namespace:`plugin-charts`,label:`Bar Chart (Alias)`,category:`plugin`,defaultProps:{chartType:`bar`}}),b.register(`pie-chart`,Z9,{namespace:`plugin-charts`,label:`Pie Chart`,category:`plugin`,defaultProps:{chartType:`pie`}}),b.register(`donut-chart`,Z9,{namespace:`plugin-charts`,label:`Donut Chart`,category:`plugin`,defaultProps:{chartType:`donut`}}),b.register(`radar-chart`,Z9,{namespace:`plugin-charts`,label:`Radar Chart`,category:`plugin`,defaultProps:{chartType:`radar`}}),b.register(`scatter-chart`,Z9,{namespace:`plugin-charts`,label:`Scatter Chart`,category:`plugin`,defaultProps:{chartType:`scatter`}});var $9=e=>e?gft(e):null,Bgt=({item:e,currentPath:t,isSidebarOpen:n,onNavigate:r,level:i=0})=>{let a=t===e.path,o=e.children?.some(e=>e.path===t),[s,c]=H.useState(o),l=$9(e.icon);return H.useEffect(()=>{o&&c(!0)},[o]),e.children&&e.children.length>0?(0,U.jsxs)(m2,{open:s,onOpenChange:c,className:`w-full`,children:[(0,U.jsxs)(h2,{className:`flex w-full items-center justify-between py-2 text-sm font-medium rounded-md transition-colors text-muted-foreground hover:bg-muted hover:text-foreground ${n?`px-3`:`justify-center px-2 cursor-pointer`}`,children:[(0,U.jsxs)(`div`,{className:`flex items-center overflow-hidden`,children:[l&&(0,U.jsx)(l,{className:`h-4 w-4 shrink-0 ${n?`mr-3`:``}`}),(0,U.jsx)(`span`,{className:`whitespace-nowrap overflow-hidden transition-all duration-300 ${n?`opacity-100 w-auto`:`opacity-0 w-0 hidden`}`,children:e.label})]}),n&&(0,U.jsx)(Xp,{className:`h-4 w-4 transition-transform ${s?`rotate-180`:``}`})]}),(0,U.jsx)(g2,{className:`space-y-1 overflow-hidden data-[state=closed]:animate-collapsible-up data-[state=open]:animate-collapsible-down`,children:n&&e.children.map((e,a)=>(0,U.jsx)(Bgt,{item:e,currentPath:t,isSidebarOpen:n,onNavigate:r,level:i+1},a))})]}):(0,U.jsxs)(`a`,{href:e.path||`#`,onClick:t=>e.path&&r(t,e.path),title:n?void 0:e.label,className:`flex items-center py-2 text-sm font-medium rounded-md transition-colors ${a?`bg-primary text-primary-foreground`:`text-muted-foreground hover:bg-muted hover:text-foreground`} ${n?`px-3`:`justify-center px-2`} ${i>0&&n?`pl-10`:``}`,children:[l&&(0,U.jsx)(l,{className:`h-4 w-4 shrink-0 ${n?`mr-3`:``} ${a?`text-primary-foreground`:`text-muted-foreground group-hover:text-foreground`}`}),(0,U.jsx)(`span`,{className:`whitespace-nowrap overflow-hidden transition-all duration-300 ${n?`opacity-100 w-auto`:`opacity-0 w-0 hidden`}`,children:e.label})]})},Vgt=({app:e,children:t,currentPath:n,onNavigate:r})=>{let i=e.layout||`sidebar`,[a,o]=H.useState(!0),[s,c]=H.useState(`light`);H.useEffect(()=>{c(localStorage.getItem(`theme`)===`dark`||!(`theme`in localStorage)&&window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`)},[]),H.useEffect(()=>{s===`dark`?(document.documentElement.classList.add(`dark`),localStorage.setItem(`theme`,`dark`)):(document.documentElement.classList.remove(`dark`),localStorage.setItem(`theme`,`light`))},[s]);let l=()=>{c(e=>e===`dark`?`light`:`dark`)},u=(e,t)=>{e.preventDefault(),r?r(t):window.location.href=t};if(i===`empty`)return(0,U.jsx)(`main`,{className:e.className,children:t});let d=e.logo&&!e.logo.includes(`/`)&&!e.logo.includes(`.`)?$9(e.logo):null;return(0,U.jsxs)(`div`,{className:`flex min-h-screen w-full bg-background ${e.className||``}`,children:[i===`sidebar`&&(0,U.jsxs)(`aside`,{className:`
104
+ }`,disabled:r||i.disabled,className:q(`font-mono text-xs`,c?`border-red-500 focus-visible:ring-red-500`:``,i.className),rows:6}),c&&(0,U.jsx)(`p`,{className:`text-xs text-red-500`,children:c})]})}var g9=H7((()=>{})),gmt=U7({VectorField:()=>_mt});function _mt({value:e,field:t,...n}){let r=(t||n.schema)?.dimensions||(Array.isArray(e)?e.length:0);if(!e||!Array.isArray(e))return(0,U.jsx)(C7,{});let i=e.slice(0,3).map(e=>{let t=Number(e);return isNaN(t)?`0`:t.toFixed(4)}).join(`, `);return(0,U.jsxs)(`div`,{className:`text-sm ${n.className||``}`,children:[(0,U.jsxs)(`span`,{className:`font-mono text-gray-700`,children:[`[`,i,`...]`]}),(0,U.jsxs)(`span`,{className:`text-gray-500 ml-2`,children:[`(`,r,`D)`]})]})}var _9=H7((()=>{})),vmt=U7({GridField:()=>ymt});function ymt({value:e,field:t,readonly:n,...r}){let i=(t||r.schema)?.columns||[];return!e||!Array.isArray(e)?(0,U.jsx)(C7,{}):n?(0,U.jsx)(`div`,{className:q(`text-sm`,r.className),children:(0,U.jsxs)(`span`,{className:`text-foreground`,children:[e.length,` rows`]})}):(0,U.jsxs)(`div`,{className:q(`border border-border rounded-lg overflow-hidden`,r.className),children:[(0,U.jsx)(`div`,{className:`overflow-auto max-h-60`,children:(0,U.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,U.jsx)(`thead`,{className:`bg-muted border-b border-border`,children:(0,U.jsx)(`tr`,{children:i.map((e,t)=>(0,U.jsx)(`th`,{className:`px-3 py-2 text-left text-xs font-medium text-muted-foreground`,children:e.label||e.name},t))})}),(0,U.jsx)(`tbody`,{className:`divide-y divide-border`,children:e.slice(0,5).map((e,t)=>(0,U.jsx)(`tr`,{className:`hover:bg-muted/50 transition-colors`,children:i.map((t,n)=>(0,U.jsx)(`td`,{className:`px-3 py-2 text-foreground`,children:e[t.name]==null?(0,U.jsx)(C7,{}):String(e[t.name])},n))},t))})]})}),e.length>5&&(0,U.jsxs)(`div`,{className:`bg-muted px-3 py-2 text-xs text-muted-foreground border-t border-border`,children:[`Showing 5 of `,e.length,` rows`]})]})}var v9=H7((()=>{})),bmt=U7({ColorField:()=>xmt});function xmt({value:e,onChange:t,field:n,readonly:r,...i}){let a=n||i.schema;return r?(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(`div`,{className:`w-6 h-6 rounded border border-input`,style:{backgroundColor:e||`#000000`}}),(0,U.jsx)(`span`,{className:`text-sm`,children:e||(0,U.jsx)(C7,{})})]}):(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(`input`,{type:`color`,value:e||`#000000`,onChange:e=>t(e.target.value),disabled:r||i.disabled,className:`w-10 h-10 rounded border border-input cursor-pointer`}),(0,U.jsx)(f6,{type:`text`,value:e||``,onChange:e=>t(e.target.value),placeholder:a?.placeholder||`#000000`,disabled:r||i.disabled,className:i.className,pattern:`^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$`})]})}var y9=H7((()=>{})),Smt=U7({SliderField:()=>Cmt});function Cmt({value:e,onChange:t,field:n,readonly:r,...i}){let a=n||i.schema,o=a?.min??0,s=a?.max??100,c=a?.step??1;return r?(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(`span`,{className:`text-sm font-medium`,children:e??o}),(0,U.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`/ `,s]})]}):(0,U.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,U.jsx)(K5,{value:[e??o],onValueChange:e=>t(e[0]),min:o,max:s,step:c,disabled:r||i.disabled,className:i.className}),(0,U.jsx)(`span`,{className:`text-sm font-medium w-12 text-right`,children:e??o})]})}var b9=H7((()=>{})),wmt=U7({RatingField:()=>Tmt});function Tmt({value:e,onChange:t,field:n,readonly:r,className:i,...a}){let o=(n||a.schema)?.max??5,s=e??0,[c,l]=H.useState(null),u=c===null?s:c;return r?(0,U.jsxs)(`div`,{className:q(`flex items-center gap-1`,i),children:[Array.from({length:o},(e,t)=>(0,U.jsx)($Q,{className:`w-5 h-5 ${t<s?`fill-yellow-400 text-yellow-400`:`text-muted-foreground`}`},t)),(0,U.jsxs)(`span`,{className:`ml-2 text-sm text-muted-foreground`,children:[s,` / `,o]})]}):(0,U.jsxs)(`div`,{className:q(`flex items-center gap-1`,i),children:[Array.from({length:o},(e,n)=>(0,U.jsx)(`button`,{type:`button`,onClick:()=>t(n+1),onMouseEnter:()=>l(n+1),onMouseLeave:()=>l(null),className:`focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 rounded`,disabled:r||a.disabled,children:(0,U.jsx)($Q,{className:`w-5 h-5 transition-colors ${n<u?`fill-yellow-400 text-yellow-400 hover:fill-yellow-500 hover:text-yellow-500`:`text-muted-foreground hover:text-yellow-400`}`})},n)),(0,U.jsxs)(`span`,{className:`ml-2 text-sm text-muted-foreground`,children:[s,` / `,o]})]})}var x9=H7((()=>{})),Emt=U7({CodeField:()=>Dmt});function Dmt({value:e,onChange:t,field:n,readonly:r,...i}){let a=n||i.schema,o=a?.language??`javascript`;return r?(0,U.jsx)(`pre`,{className:q(`text-sm bg-muted p-2 rounded overflow-x-auto border`,i.className),children:(0,U.jsx)(`code`,{children:e||(0,U.jsx)(C7,{})})}):(0,U.jsx)(p7,{value:e||``,onChange:e=>t(e.target.value),placeholder:a?.placeholder||`// Write ${o} code here...`,disabled:r||i.disabled,className:q(`font-mono text-sm`,i.className),rows:12,spellCheck:!1})}var S9=H7((()=>{})),Omt=U7({AvatarField:()=>kmt});function kmt({value:e,onChange:t,field:n,readonly:r,...i}){let[a,o]=H.useState(!1),s=H.useRef(null),c=n||i.schema,l=e=>{let n=e.target.files?.[0];if(!n)return;if(!n.type.startsWith(`image/`)){console.error(`Please select an image file`);return}if(n.size>5*1024*1024){console.error(`File size must be less than 5MB`);return}let r=new FileReader;r.onloadend=()=>{t(r.result)},r.readAsDataURL(n)},u=()=>{t(``)},d=()=>(c?.defaultName||c?.label||`User`).split(` `).map(e=>e[0]).join(``).toUpperCase().slice(0,2);return r?(0,U.jsxs)(S1,{className:`w-16 h-16`,children:[e&&(0,U.jsx)(C1,{src:e,alt:c?.label}),(0,U.jsx)(w1,{children:d()})]}):(0,U.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,U.jsxs)(`div`,{className:`relative`,onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),children:[(0,U.jsxs)(S1,{className:`w-16 h-16`,children:[e&&(0,U.jsx)(C1,{src:e,alt:c?.label}),(0,U.jsx)(w1,{children:d()})]}),!r&&a&&e&&(0,U.jsx)(`button`,{type:`button`,onClick:u,className:`absolute -top-1 -right-1 bg-destructive text-destructive-foreground rounded-full p-1 hover:bg-destructive/90`,children:(0,U.jsx)(c$,{className:`w-3 h-3`})})]}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,U.jsx)(`input`,{ref:s,type:`file`,accept:`image/*`,onChange:l,className:`hidden`}),(0,U.jsxs)(Q,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>s.current?.click(),disabled:r||i.disabled,children:[(0,U.jsx)(s$,{className:`w-4 h-4 mr-2`}),e?`Change`:`Upload`,` Avatar`]}),(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`PNG, JPG up to 5MB`})]})]})}var C9=H7((()=>{})),Amt=U7({AddressField:()=>jmt});function jmt({value:e,onChange:t,field:n,readonly:r,...i}){let a=e||{},o=(e,n)=>{t({...a,[e]:n})},s=e=>[e.street,e.city,[e.state,e.zipCode].filter(Boolean).join(` `),e.country].filter(Boolean).join(`, `);if(r){let e=s(a);return e?(0,U.jsx)(`span`,{className:`text-sm`,children:e}):(0,U.jsx)(C7,{})}return(0,U.jsxs)(`div`,{className:`space-y-3`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(t6,{htmlFor:`street`,className:`text-xs`,children:`Street Address`}),(0,U.jsx)(f6,{id:`street`,type:`text`,value:a.street||``,onChange:e=>o(`street`,e.target.value),placeholder:`123 Main St`,disabled:r||i.disabled,className:i.className})]}),(0,U.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(t6,{htmlFor:`city`,className:`text-xs`,children:`City`}),(0,U.jsx)(f6,{id:`city`,type:`text`,value:a.city||``,onChange:e=>o(`city`,e.target.value),placeholder:`San Francisco`,disabled:r||i.disabled})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(t6,{htmlFor:`state`,className:`text-xs`,children:`State / Province`}),(0,U.jsx)(f6,{id:`state`,type:`text`,value:a.state||``,onChange:e=>o(`state`,e.target.value),placeholder:`CA`,disabled:r||i.disabled})]})]}),(0,U.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(t6,{htmlFor:`zipCode`,className:`text-xs`,children:`ZIP / Postal Code`}),(0,U.jsx)(f6,{id:`zipCode`,type:`text`,value:a.zipCode||``,onChange:e=>o(`zipCode`,e.target.value),placeholder:`94102`,disabled:r||i.disabled})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(t6,{htmlFor:`country`,className:`text-xs`,children:`Country`}),(0,U.jsx)(f6,{id:`country`,type:`text`,value:a.country||``,onChange:e=>o(`country`,e.target.value),placeholder:`United States`,disabled:r||i.disabled})]})]})]})}var w9=H7((()=>{})),Mmt=U7({GeolocationField:()=>Nmt});function Nmt({value:e,onChange:t,field:n,readonly:r,...i}){let[a,o]=H.useState(!1),s=e||{},c=(e,n)=>{t({...s,[e]:n?Number(n):void 0})},l=()=>{if(!navigator.geolocation){console.error(`Geolocation is not supported by this browser`);return}o(!0),navigator.geolocation.getCurrentPosition(e=>{t({latitude:e.coords.latitude,longitude:e.coords.longitude,accuracy:e.coords.accuracy}),o(!1)},e=>{console.error(`Error getting location:`,e.message),o(!1)},{enableHighAccuracy:!0,timeout:5e3,maximumAge:0})},u=e=>!e.latitude||!e.longitude?``:`${e.latitude.toFixed(6)}, ${e.longitude.toFixed(6)}`,d=()=>{if(!s.latitude||!s.longitude)return;let e=`https://www.google.com/maps?q=${s.latitude},${s.longitude}`;window.open(e,`_blank`)};if(r){let e=u(s);return(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(yR,{className:`w-4 h-4 text-muted-foreground`}),e?(0,U.jsx)(`span`,{className:`text-sm`,children:e}):(0,U.jsx)(C7,{}),s.latitude&&s.longitude&&(0,U.jsx)(Q,{type:`button`,variant:`link`,size:`sm`,onClick:d,className:`p-0 h-auto`,children:`View on map`})]})}return(0,U.jsxs)(`div`,{className:`space-y-3`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsxs)(Q,{type:`button`,variant:`outline`,size:`sm`,onClick:l,disabled:r||a,children:[(0,U.jsx)(Rb,{className:`w-4 h-4 mr-2`}),a?`Getting location...`:`Use Current Location`]}),s.latitude&&s.longitude&&(0,U.jsxs)(Q,{type:`button`,variant:`link`,size:`sm`,onClick:d,children:[(0,U.jsx)(yR,{className:`w-4 h-4 mr-2`}),`View on map`]})]}),(0,U.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(t6,{htmlFor:`latitude`,className:`text-xs`,children:`Latitude`}),(0,U.jsx)(f6,{id:`latitude`,type:`number`,value:s.latitude??``,onChange:e=>c(`latitude`,e.target.value),placeholder:`37.7749`,disabled:r||i.disabled,step:`any`,className:i.className})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(t6,{htmlFor:`longitude`,className:`text-xs`,children:`Longitude`}),(0,U.jsx)(f6,{id:`longitude`,type:`number`,value:s.longitude??``,onChange:e=>c(`longitude`,e.target.value),placeholder:`-122.4194`,disabled:r||i.disabled,step:`any`})]})]}),s.accuracy&&(0,U.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Accuracy: ±`,s.accuracy.toFixed(0),`m`]})]})}var T9=H7((()=>{})),Pmt=U7({SignatureField:()=>Fmt});function Fmt({value:e,onChange:t,readonly:n}){let r=(0,H.useRef)(null),[i,a]=H.useState(!1),[o,s]=H.useState(!e);(0,H.useEffect)(()=>{if(e&&r.current){let t=r.current.getContext(`2d`);if(t){let n=new Image;n.onload=()=>{t.drawImage(n,0,0),s(!1)},n.src=e}}},[e]);let c=e=>{if(n)return;a(!0),s(!1);let t=r.current;if(!t)return;let i=t.getContext(`2d`);if(!i)return;let o=t.getBoundingClientRect(),c=`touches`in e?e.touches[0].clientX-o.left:e.clientX-o.left,l=`touches`in e?e.touches[0].clientY-o.top:e.clientY-o.top;i.beginPath(),i.moveTo(c,l)},l=e=>{if(!i||n)return;let t=r.current;if(!t)return;let a=t.getContext(`2d`);if(!a)return;let o=t.getBoundingClientRect(),s=`touches`in e?e.touches[0].clientX-o.left:e.clientX-o.left,c=`touches`in e?e.touches[0].clientY-o.top:e.clientY-o.top;a.lineTo(s,c),a.strokeStyle=`#000`,a.lineWidth=2,a.lineCap=`round`,a.lineJoin=`round`,a.stroke()},u=()=>{if(!i)return;a(!1);let e=r.current;e&&t(e.toDataURL(`image/png`))};return n&&e?(0,U.jsx)(`div`,{className:`border rounded p-2 bg-white`,children:(0,U.jsx)(`img`,{src:e,alt:`Signature`,loading:`lazy`,className:`max-w-full h-auto`})}):n&&!e?(0,U.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:`No signature`}):(0,U.jsxs)(`div`,{className:`space-y-2`,children:[(0,U.jsx)(`div`,{className:`border rounded bg-white`,children:(0,U.jsx)(`canvas`,{ref:r,width:400,height:200,className:`w-full touch-none cursor-crosshair`,onMouseDown:c,onMouseMove:l,onMouseUp:u,onMouseLeave:u,onTouchStart:c,onTouchMove:l,onTouchEnd:u})}),(0,U.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:o?`Sign above`:`Signature captured`}),(0,U.jsxs)(Q,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>{let e=r.current;if(!e)return;let n=e.getContext(`2d`);n&&(n.clearRect(0,0,e.width,e.height),s(!0),t(``))},disabled:n||o,children:[(0,U.jsx)(gC,{className:`w-4 h-4 mr-2`}),`Clear`]})]})]})}var E9=H7((()=>{})),Imt=U7({QRCodeField:()=>Lmt});function Lmt({value:e,onChange:t,field:n,readonly:r,...i}){let[a,o]=H.useState(!1),s=n||i.schema;return r?(0,U.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,U.jsx)(`span`,{className:`text-sm flex-1 truncate`,children:e||(0,U.jsx)(C7,{})}),e&&(0,U.jsxs)(Q,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>o(!a),children:[(0,U.jsx)(yq,{className:`w-4 h-4 mr-2`}),a?`Hide`:`Show`,` QR`]})]}):(0,U.jsxs)(`div`,{className:`space-y-3`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(f6,{type:`text`,value:e||``,onChange:e=>t(e.target.value),placeholder:s?.placeholder||`Enter text for QR code`,disabled:r||i.disabled,className:i.className}),e&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(Q,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>{e&&navigator.clipboard.writeText(e)},children:(0,U.jsx)(ab,{className:`w-4 h-4`})}),(0,U.jsx)(Q,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>o(!a),children:(0,U.jsx)(yq,{className:`w-4 h-4`})})]})]}),a&&e&&(0,U.jsx)(`div`,{className:`border rounded p-4 bg-white flex justify-center`,children:(0,U.jsx)(`img`,{src:(e=>`https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=${encodeURIComponent(e)}`)(e),alt:`QR Code`,className:`w-48 h-48`})}),e&&(0,U.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`QR code contains: `,e.length,` characters`]})]})}var D9=H7((()=>{}));W7(),G7(),K7(),J7(),Y7(),X7(),Z7(),Q7(),$7(),e9(),t9(),i9(),a9(),o9(),s9(),c9(),l9(),u9(),d9(),f9(),p9(),m9(),h9(),g9(),_9(),v9(),y9(),b9(),x9(),S9(),C9(),w9(),T9(),E9(),D9(),emt(),Fpt(),W7(),G7(),K7(),J7(),Y7(),a9(),o9(),X7(),Z7(),Q7(),$7(),s9(),c9(),e9(),t9(),i9(),jpt(),l9(),u9(),d9(),f9(),p9(),m9(),h9(),g9(),_9(),v9(),y9(),b9(),x9(),S9(),C9(),w9(),T9(),E9(),D9();var O9=new Map;function k9(e){if(!e||typeof e!=`object`)return;for(let t of[`name`,`full_name`,`display_name`,`label`,`title`,`subject`,`username`]){let n=e[t];if(typeof n==`string`&&n.trim())return n.trim();if(typeof n==`number`)return String(n)}let t=e.first_name,n=e.last_name,r=[e.salutation,t,n].filter(e=>typeof e==`string`&&e.trim()).map(e=>e.trim()).join(` `);if(r)return r;let i=e.email;if(typeof i==`string`&&i.trim())return i.trim()}function Rmt(e){if(typeof e!=`string`||!/^[A-Za-z0-9_-]{12,32}$/.test(e))return!1;let t=/[A-Z]/.test(e),n=/[a-z]/.test(e),r=/[0-9_-]/.test(e);return t&&n||t&&r||n&&r}function zmt(e,t){let n=H.useContext(ge)?.dataSource,[,r]=H.useState(0),i=!!e&&!!n&&typeof n.find==`function`&&(typeof t==`string`||typeof t==`number`)&&t!==``,a=i?`${e}:${String(t)}`:``;if(H.useEffect(()=>{if(!i)return;let o=O9.get(a);if(o&&o.state!==`pending`&&o.promise==null||o?.state===`pending`)return;let s=(async()=>{try{let r;if(typeof n.findOne==`function`)r=await n.findOne(e,t);else{let i=await n.find(e,{$filter:{id:t},options:{$top:1}});r=(Array.isArray(i)?i:i?.value||i?.data||[])[0]}let i=k9(r);O9.set(a,{state:`ok`,name:i})}catch{O9.set(a,{state:`err`})}r(e=>e+1)})();O9.set(a,{state:`pending`,promise:s})},[a,i,e,t,n]),!i)return;let o=O9.get(a);return o?.state===`ok`?o.name:void 0}function Bmt(){try{let{t:e}=Vn();return(t,n)=>{let r=e(t);return!r||r===t?n:r}}catch{return(e,t)=>t}}function A9(e){if(e==null||typeof e==`string`||typeof e==`number`||typeof e==`boolean`)return e;if(e instanceof Date)return e.toISOString();if(Array.isArray(e))return e.map(e=>{if(typeof e==`object`&&e){let t=e;return String(t.name||t.label||t.id||t._id||`[Object]`)}return String(e)}).join(`, `);if(typeof e==`object`){let t=e;return`$numberDecimal`in t?Number(t.$numberDecimal):`$oid`in t?String(t.$oid):`$date`in t?String(t.$date):String(t.name||t.label||t.id||t._id||`[Object]`)}return String(e)}function Vmt(e,t=`USD`){try{return new Intl.NumberFormat(`en-US`,{style:`currency`,currency:t}).format(e)}catch{return`${t} ${e.toFixed(2)}`}}function Hmt(e,t=2){try{return new Intl.NumberFormat(`en-US`,{minimumFractionDigits:t,maximumFractionDigits:t}).format(e)}catch{return e.toFixed(t)}}function Umt(e,t=0){return`${(e>-1&&e<1?e*100:e).toFixed(t)}%`}function Wmt(e){return e.replace(/[_-]/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}function Gmt(e){if(e==null||e===``)return`—`;let t=e instanceof Date?e:new Date(e);if(!(t instanceof Date)||isNaN(t.getTime()))return`—`;let n=new Date,r=new Date(n.getFullYear(),n.getMonth(),n.getDate()),i=new Date(t.getFullYear(),t.getMonth(),t.getDate()).getTime()-r.getTime(),a=Math.round(i/(1e3*60*60*24));if(a===0)return`Today`;if(a===1)return`Tomorrow`;if(a===-1)return`Yesterday`;if(a<-1){let e=Math.abs(a);return e<=7?`Overdue ${e}d`:j9(t)}return a>1&&a<=7?`In ${a} days`:j9(t)}function j9(e,t){if(e==null||e===``)return`—`;let n=e instanceof Date?e:new Date(e);return!(n instanceof Date)||isNaN(n.getTime())?`—`:t===`short`?`${n.toLocaleDateString(`en-US`,{month:`short`})} ${n.getDate()}, '${String(n.getFullYear()).slice(-2)}`:t===`relative`?Gmt(n):n.toLocaleDateString(void 0,{year:`numeric`,month:`short`,day:`numeric`})}function Kmt(e){if(e==null||e===``)return`—`;let t=e instanceof Date?e:new Date(e);return!(t instanceof Date)||isNaN(t.getTime())?`—`:t.toLocaleDateString(void 0,{year:`numeric`,month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`})}function M9({value:e}){let t=A9(e);return t==null||t===``?(0,U.jsx)(C7,{}):(0,U.jsx)(`span`,{className:`truncate`,children:String(t)})}function qmt({value:e,field:t}){if(e==null)return(0,U.jsx)(C7,{});let n=A9(e),r=t.precision??0,i=Number(n);return(0,U.jsx)(`span`,{className:`tabular-nums`,children:isNaN(i)?String(n):new Intl.NumberFormat(`en-US`,{minimumFractionDigits:r,maximumFractionDigits:r}).format(i)})}function Jmt({value:e,field:t}){if(e==null)return(0,U.jsx)(C7,{});let n=A9(e),r=t,i=r.currency||r.defaultCurrency,a=Number(n),o=r.precision??r.scale??r.decimals??2;return(0,U.jsx)(`span`,{className:`tabular-nums font-medium whitespace-nowrap`,children:isNaN(a)?String(n):i?Vmt(a,i):Hmt(a,o)})}var Ymt=/progress|completion/;function Xmt({value:e,field:t}){if(e==null)return(0,U.jsx)(C7,{});let n=A9(e),r=t.precision??0,i=Number(n);if(isNaN(i))return(0,U.jsx)(`span`,{className:`tabular-nums whitespace-nowrap`,children:String(n)});let a=Ymt.test(t?.name?.toLowerCase()||``),o=a?i:i>-1&&i<1?i*100:i,s=a?`${i.toFixed(r)}%`:Umt(i,r),c=Math.max(0,Math.min(100,o));return(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(`div`,{className:`h-1.5 w-16 rounded-full bg-muted ring-1 ring-inset ring-border/60 overflow-hidden shrink-0`,role:`progressbar`,"aria-valuenow":c,"aria-valuemin":0,"aria-valuemax":100,children:(0,U.jsx)(`div`,{className:`h-full rounded-full bg-primary transition-all`,style:{width:`${c}%`}})}),(0,U.jsx)(`span`,{className:`tabular-nums whitespace-nowrap`,children:s})]})}var Zmt=new Set([`active`,`is_active`,`enabled`,`is_enabled`,`verified`,`is_verified`]);function Qmt({value:e,field:t}){if(e==null)return(0,U.jsx)(`span`,{className:`flex items-center justify-center`,children:(0,U.jsx)(C7,{})});let n=t?.name?.toLowerCase()||``;return n===`completed`||n===`is_completed`||n===`done`||n===`is_done`?(0,U.jsx)(`div`,{className:`flex items-center justify-center`,children:e?(0,U.jsx)(`div`,{className:`size-5 rounded-full bg-green-500 flex items-center justify-center`,role:`img`,"aria-label":`Completed`,"data-testid":`completion-indicator`,children:(0,U.jsx)(Yp,{className:`size-3 text-white`})}):(0,U.jsx)(`div`,{className:`size-5 rounded-full border-2 border-muted-foreground/30`,role:`img`,"aria-label":`Not completed`,"data-testid":`completion-indicator`})}):Zmt.has(n)&&!e?(0,U.jsxs)(T1,{variant:`destructive`,className:`text-xs`,"data-testid":`boolean-warning-badge`,children:[t?.label||Wmt(n),` — Off`]}):(0,U.jsx)(`div`,{className:`flex items-center justify-start`,children:(0,U.jsx)(p2,{checked:!!e,disabled:!0,className:`pointer-events-none`})})}function $mt({value:e,field:t}){if(!e)return(0,U.jsx)(C7,{});let n=A9(e),r=t,i=j9(n,r.format||`relative`),a=n==null?null:new Date(n),o=a!==null&&!isNaN(a.getTime()),s=new Date;s.setHours(0,0,0,0);let c=String(r?.name||r?.accessorKey||r?.key||``).toLowerCase(),l=(r?.dueLike===!0||/(^|_)(due|deadline|expires?|expiry|expiration|expected_close|target_close|sla|return_by|renewal|next_action)(_|$)/.test(c))&&o&&a<s,u=o?a.toISOString():String(n);return(0,U.jsx)(`span`,{className:`tabular-nums${l?` text-red-600`:``}`,title:u,children:i})}function eht({value:e}){if(!e)return(0,U.jsx)(C7,{});let t=A9(e),n=t==null?null:new Date(t);if(n===null||isNaN(n.getTime()))return(0,U.jsx)(C7,{});let r=n.toLocaleDateString(void 0,{month:`numeric`,day:`numeric`,year:`numeric`}),i=n.toLocaleTimeString(void 0,{hour:`numeric`,minute:`2-digit`,hour12:!0}).toLowerCase();return(0,U.jsxs)(`span`,{className:`tabular-nums text-sm whitespace-nowrap`,children:[(0,U.jsx)(`span`,{children:r}),(0,U.jsx)(`span`,{className:`ml-2 text-muted-foreground`,children:i})]})}var tht={critical:`red`,urgent:`red`,high:`orange`,medium:`yellow`,normal:`blue`,low:`gray`,none:`gray`,paid:`green`,completed:`green`,done:`green`,active:`green`,approved:`green`,resolved:`green`,pending:`yellow`,waiting:`yellow`,on_hold:`yellow`,shipped:`blue`,in_progress:`blue`,open:`blue`,processing:`blue`,draft:`gray`,new:`gray`,inactive:`gray`,closed:`gray`,cancelled:`red`,canceled:`red`,rejected:`red`,failed:`red`,overdue:`red`,delivered:`purple`,archived:`indigo`,contacted:`blue`,qualified:`purple`,converted:`green`,won:`green`,lost:`red`,紧急:`red`,严重:`red`,高:`orange`,中:`yellow`,普通:`blue`,低:`gray`,无:`gray`,新建:`gray`,草稿:`gray`,待处理:`yellow`,待审核:`yellow`,待联系:`yellow`,挂起:`yellow`,进行中:`blue`,处理中:`blue`,已联系:`blue`,跟进中:`blue`,已发货:`blue`,打开:`blue`,已确认:`green`,已审核:`green`,已通过:`green`,已完成:`green`,已支付:`green`,已签收:`green`,已转化:`green`,成单:`green`,赢得:`green`,已签约:`green`,已交付:`purple`,已归档:`indigo`,已关闭:`gray`,已取消:`red`,已拒绝:`red`,失败:`red`,逾期:`red`,流失:`red`,丢失:`red`},N9={gray:`bg-gray-50 text-gray-700 border-gray-200 dark:bg-gray-800/50 dark:text-gray-200 dark:border-gray-700/60`,red:`bg-red-50 text-red-700 border-red-200 dark:bg-red-950/40 dark:text-red-300 dark:border-red-900/60`,orange:`bg-orange-50 text-orange-700 border-orange-200 dark:bg-orange-950/40 dark:text-orange-300 dark:border-orange-900/60`,yellow:`bg-yellow-50 text-yellow-800 border-yellow-200 dark:bg-yellow-950/40 dark:text-yellow-300 dark:border-yellow-900/60`,green:`bg-green-50 text-green-700 border-green-200 dark:bg-green-950/40 dark:text-green-300 dark:border-green-900/60`,blue:`bg-blue-50 text-blue-700 border-blue-200 dark:bg-blue-950/40 dark:text-blue-300 dark:border-blue-900/60`,indigo:`bg-indigo-50 text-indigo-700 border-indigo-200 dark:bg-indigo-950/40 dark:text-indigo-300 dark:border-indigo-900/60`,purple:`bg-purple-50 text-purple-700 border-purple-200 dark:bg-purple-950/40 dark:text-purple-300 dark:border-purple-900/60`,pink:`bg-pink-50 text-pink-700 border-pink-200 dark:bg-pink-950/40 dark:text-pink-300 dark:border-pink-900/60`},nht={gray:`bg-gray-400 dark:bg-gray-500`,red:`bg-red-500`,orange:`bg-orange-500`,yellow:`bg-yellow-500`,green:`bg-green-500`,blue:`bg-blue-500`,indigo:`bg-indigo-500`,purple:`bg-purple-500`,pink:`bg-pink-500`},rht=[`blue`,`green`,`purple`,`orange`,`pink`,`indigo`,`yellow`,`red`];function iht(e){let t=5381;for(let n=0;n<e.length;n++)t=(t<<5)+t^e.charCodeAt(n);return rht[Math.abs(t)%rht.length]}function P9(e,t){if(e&&N9[e])return N9[e];if(t==null||t===``)return`bg-muted text-muted-foreground border-border`;let n=String(t).toLowerCase().replace(/[\s-]/g,`_`),r=tht[n];return r&&N9[r]?N9[r]:N9[iht(n)]}function F9({value:e,field:t}){let n=t,r=n.options||[],i=n.appearance===`dot`?`dot`:`badge`;if(e==null||e===``)return(0,U.jsx)(C7,{});let a=e=>{let t=r.find(t=>t.value===e);if(t)return t;let n=String(e).toLowerCase();return r.find(e=>String(e.value).toLowerCase()===n)},o=(e,t)=>{let n=a(e),r=n?.label||Wmt(String(e));return i===`dot`?(0,U.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-sm`,children:[(0,U.jsx)(`span`,{className:q(`h-1.5 w-1.5 rounded-full shrink-0`,nht[n?.color||tht[String(e).toLowerCase().replace(/[\s-]/g,`_`)]||iht(String(e).toLowerCase().replace(/[\s-]/g,`_`))]||nht.gray),"aria-hidden":`true`}),(0,U.jsx)(`span`,{className:`truncate`,children:r})]},t):(0,U.jsx)(T1,{variant:`outline`,className:P9(n?.color,e),children:r},t)};return Array.isArray(e)?(0,U.jsx)(`div`,{className:q(`flex flex-wrap`,i===`dot`?`gap-x-3 gap-y-1`:`gap-1`),children:e.map((e,t)=>o(e,t))}):o(e)}function aht({value:e}){if(!e)return(0,U.jsx)(C7,{});let t=Bmt(),n=String(A9(e)??``),[r,i]=H.useState(!1);return(0,U.jsxs)(`span`,{className:`inline-flex items-center gap-1 group/email`,children:[(0,U.jsx)(Q,{variant:`link`,className:`p-0 h-auto font-normal text-blue-600 hover:text-blue-800`,asChild:!0,children:(0,U.jsx)(`a`,{href:`mailto:${n}`,onClick:e=>e.stopPropagation(),children:n})}),(0,U.jsx)(`button`,{type:`button`,className:`opacity-0 group-hover/email:opacity-100 transition-opacity p-0.5 rounded hover:bg-muted`,onClick:e=>{e.stopPropagation(),e.preventDefault(),navigator.clipboard.writeText(n).then(()=>{i(!0),setTimeout(()=>i(!1),2e3)}).catch(()=>{})},"aria-label":t(`detail.copyEmail`,`Copy email`),children:r?(0,U.jsx)(Yp,{className:`h-3 w-3 text-green-600`}):(0,U.jsx)(ab,{className:`h-3 w-3 text-muted-foreground`})})]})}function oht({value:e}){if(!e)return(0,U.jsx)(C7,{});let t=String(A9(e)??``);return(0,U.jsx)(Q,{variant:`link`,className:`p-0 h-auto font-normal text-blue-600 hover:text-blue-800`,asChild:!0,children:(0,U.jsx)(`a`,{href:t,target:`_blank`,rel:`noopener noreferrer`,onClick:e=>e.stopPropagation(),children:t})})}function sht({value:e}){if(!e)return(0,U.jsx)(C7,{});let t=Bmt(),n=String(A9(e)??``),[r,i]=H.useState(!1);return(0,U.jsxs)(`span`,{className:`inline-flex items-center gap-1 group/phone`,children:[(0,U.jsxs)(`a`,{href:`tel:${n}`,className:`inline-flex items-center gap-1 text-blue-600 hover:text-blue-800`,onClick:e=>e.stopPropagation(),children:[(0,U.jsx)(WG,{className:`h-3 w-3`}),n]}),(0,U.jsx)(`button`,{type:`button`,className:`opacity-0 group-hover/phone:opacity-100 transition-opacity p-0.5 rounded hover:bg-muted`,onClick:e=>{e.stopPropagation(),e.preventDefault(),navigator.clipboard.writeText(n).then(()=>{i(!0),setTimeout(()=>i(!1),2e3)}).catch(()=>{})},"aria-label":t(`detail.copyPhone`,`Copy phone number`),children:r?(0,U.jsx)(Yp,{className:`h-3 w-3 text-green-600`}):(0,U.jsx)(ab,{className:`h-3 w-3 text-muted-foreground`})})]})}function cht({value:e,field:t}){if(!e)return(0,U.jsx)(C7,{});if(t.multiple,Array.isArray(e)){let t=e.length;return(0,U.jsxs)(`span`,{className:`text-sm text-gray-600`,children:[t,` `,t===1?`file`:`files`]})}return(0,U.jsx)(`span`,{className:`text-sm truncate`,children:e.name||e.original_name||`File`})}function lht({value:e}){return e?Array.isArray(e)?(0,U.jsxs)(`div`,{className:`flex -space-x-2`,children:[e.slice(0,3).map((e,t)=>(0,U.jsx)(`img`,{src:e.url||``,alt:e.name||`Image ${t+1}`,className:`size-8 rounded-md border-2 border-white object-cover`},t)),e.length>3&&(0,U.jsxs)(`div`,{className:`size-8 rounded-md border-2 border-white bg-gray-100 flex items-center justify-center text-xs font-medium text-gray-600`,children:[`+`,e.length-3]})]}):(0,U.jsx)(`img`,{src:e.url||``,alt:e.name||`Image`,className:`size-10 rounded-md object-cover`}):(0,U.jsx)(C7,{})}function I9({value:e,field:t}){let n=t.reference_to,r=(()=>{if(Array.isArray(e))return e.find(e=>e!=null&&(typeof e==`string`||typeof e==`number`)&&e!==``);if(e!=null&&e!==``&&(typeof e==`string`||typeof e==`number`)&&typeof e!=`object`)return e})(),i=zmt(n,r);if(e==null||e===``)return(0,U.jsx)(C7,{});if(!Array.isArray(e)&&typeof e==`object`){let t=e,n=k9(t)||String(t.id||t._id||``);if(n)return(0,U.jsx)(`span`,{className:`truncate`,children:n})}let a=t.options||[],o=e=>{if(a.length>0){let t=a.find(t=>String(t.value)===String(e));if(t)return{text:t.label,muted:!1}}return e===r&&i?{text:i,muted:!1}:Rmt(e)?{text:`—`,muted:!0}:{text:String(e),muted:!1}};if(Array.isArray(e))return(0,U.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:e.map((e,t)=>{let n,r=!1;if(typeof e==`object`&&e)n=k9(e)||String(e.id||e._id||`[Object]`);else{let t=o(e);n=t.text,r=t.muted}return(0,U.jsx)(`span`,{className:q(`inline-flex items-center px-2 py-0.5 rounded text-xs font-medium`,r?`bg-muted/40 text-muted-foreground`:`bg-gray-50 text-gray-700 dark:bg-gray-800/50 dark:text-gray-200`),children:n},t)})});if(typeof e==`object`&&e)return(0,U.jsx)(`span`,{className:`truncate`,children:k9(e)||String(e.id||e._id||`[Object]`)});let{text:s,muted:c}=o(e);return(0,U.jsx)(`span`,{className:q(`truncate`,c&&`text-muted-foreground`),children:s})}function uht({value:e}){let t=A9(e);return t==null||t===``?(0,U.jsx)(C7,{}):(0,U.jsx)(`span`,{className:`text-gray-700 font-mono text-sm`,children:String(t)})}function L9({value:e}){if(!e)return(0,U.jsx)(C7,{});if(typeof e!=`object`)return(0,U.jsx)(`span`,{className:`truncate`,children:String(e)});if(Array.isArray(e))return(0,U.jsxs)(`div`,{className:`flex -space-x-2`,children:[e.slice(0,3).map((e,t)=>{if(typeof e!=`object`||!e)return(0,U.jsx)(`span`,{className:`truncate text-sm`,children:String(e)},t);let n=e.name||e.username||`User`;return(0,U.jsx)(S1,{className:`size-8 border-2 border-white`,title:n,children:(0,U.jsx)(w1,{className:`bg-blue-500 text-white text-xs`,children:n.split(` `).map(e=>e[0]).join(``).toUpperCase().slice(0,2)})},t)}),e.length>3&&(0,U.jsx)(S1,{className:`size-8 border-2 border-white`,children:(0,U.jsxs)(w1,{className:`bg-gray-200 text-gray-600 text-xs`,children:[`+`,e.length-3]})})]});let t=e.name||e.username||`User`;return(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(S1,{className:`size-8`,children:(0,U.jsx)(w1,{className:`bg-blue-500 text-white text-xs`,children:t.split(` `).map(e=>e[0]).join(``).toUpperCase().slice(0,2)})}),(0,U.jsx)(`span`,{className:`truncate`,children:t})]})}var R9=new Map;function z9(e,t){R9.set(e,t)}var dht={phone:`phone`,tel:`phone`,telephone:`phone`,email:`email`,url:`url`,uri:`url`,link:`url`,currency:`currency`,money:`currency`,percent:`percent`,percentage:`percent`},fht=new Set([`text`,`textarea`,`string`,`longtext`,``]);function B9(e){if(!e)return`text`;if(typeof e==`string`)return e;let t=(e.type||``).toLowerCase(),n=e.format,r=typeof n==`string`?n.toLowerCase():``;return r&&dht[r]&&fht.has(t)?dht[r]:e.type||`text`}function V9(e){return R9.has(e)?R9.get(e):{text:M9,textarea:M9,markdown:M9,html:M9,number:qmt,currency:Jmt,percent:Xmt,boolean:Qmt,date:$mt,datetime:eht,time:M9,select:F9,status:F9,lookup:I9,master_detail:I9,email:aht,url:oht,phone:sht,file:cht,image:lht,formula:uht,summary:uht,auto_number:M9,user:L9,owner:L9,password:()=>(0,U.jsx)(`span`,{children:`••••••`}),location:M9,object:()=>(0,U.jsx)(`span`,{className:`text-gray-500 italic`,children:`[Object]`}),vector:()=>(0,U.jsx)(`span`,{className:`text-gray-500 italic`,children:`[Vector]`}),grid:()=>(0,U.jsx)(`span`,{className:`text-gray-500 italic`,children:`[Grid]`})}[e]||M9}z9(`lookup`,I9),z9(`master_detail`,I9),z9(`select`,F9),z9(`status`,F9),z9(`user`,L9),z9(`owner`,L9),Mpt(V9);var pht={text:()=>Promise.resolve().then(()=>(W7(),$ft)).then(e=>({default:e.TextField})),textarea:()=>Promise.resolve().then(()=>(e9(),bpt)).then(e=>({default:e.TextAreaField})),number:()=>Promise.resolve().then(()=>(G7(),tpt)).then(e=>({default:e.NumberField})),boolean:()=>Promise.resolve().then(()=>(K7(),rpt)).then(e=>({default:e.BooleanField})),select:()=>Promise.resolve().then(()=>(J7(),spt)).then(e=>({default:e.SelectField})),date:()=>Promise.resolve().then(()=>(Y7(),lpt)).then(e=>({default:e.DateField})),datetime:()=>Promise.resolve().then(()=>(a9(),Hpt)).then(e=>({default:e.DateTimeField})),time:()=>Promise.resolve().then(()=>(o9(),Wpt)).then(e=>({default:e.TimeField})),email:()=>Promise.resolve().then(()=>(X7(),dpt)).then(e=>({default:e.EmailField})),phone:()=>Promise.resolve().then(()=>(Z7(),ppt)).then(e=>({default:e.PhoneField})),url:()=>Promise.resolve().then(()=>(Q7(),hpt)).then(e=>({default:e.UrlField})),currency:()=>Promise.resolve().then(()=>($7(),_pt)).then(e=>({default:e.CurrencyField})),percent:()=>Promise.resolve().then(()=>(s9(),Kpt)).then(e=>({default:e.PercentField})),password:()=>Promise.resolve().then(()=>(c9(),Jpt)).then(e=>({default:e.PasswordField})),markdown:()=>Promise.resolve().then(()=>(t9(),Spt)).then(e=>({default:e.RichTextField})),html:()=>Promise.resolve().then(()=>(t9(),Spt)).then(e=>({default:e.RichTextField})),lookup:()=>Promise.resolve().then(()=>(i9(),Ipt)).then(e=>({default:e.LookupField})),master_detail:()=>Promise.resolve().then(()=>(i9(),Ipt)).then(e=>({default:e.LookupField})),file:()=>Promise.resolve().then(()=>(l9(),Xpt)).then(e=>({default:e.FileField})),image:()=>Promise.resolve().then(()=>(u9(),tmt)).then(e=>({default:e.ImageField})),location:()=>Promise.resolve().then(()=>(d9(),imt)).then(e=>({default:e.LocationField})),formula:()=>Promise.resolve().then(()=>(f9(),omt)).then(e=>({default:e.FormulaField})),summary:()=>Promise.resolve().then(()=>(p9(),cmt)).then(e=>({default:e.SummaryField})),auto_number:()=>Promise.resolve().then(()=>(m9(),umt)).then(e=>({default:e.AutoNumberField})),user:()=>Promise.resolve().then(()=>(h9(),fmt)).then(e=>({default:e.UserField})),owner:()=>Promise.resolve().then(()=>(h9(),fmt)).then(e=>({default:e.UserField})),object:()=>Promise.resolve().then(()=>(g9(),mmt)).then(e=>({default:e.ObjectField})),vector:()=>Promise.resolve().then(()=>(_9(),gmt)).then(e=>({default:e.VectorField})),grid:()=>Promise.resolve().then(()=>(v9(),vmt)).then(e=>({default:e.GridField})),color:()=>Promise.resolve().then(()=>(y9(),bmt)).then(e=>({default:e.ColorField})),slider:()=>Promise.resolve().then(()=>(b9(),Smt)).then(e=>({default:e.SliderField})),rating:()=>Promise.resolve().then(()=>(x9(),wmt)).then(e=>({default:e.RatingField})),code:()=>Promise.resolve().then(()=>(S9(),Emt)).then(e=>({default:e.CodeField})),avatar:()=>Promise.resolve().then(()=>(C9(),Omt)).then(e=>({default:e.AvatarField})),address:()=>Promise.resolve().then(()=>(w9(),Amt)).then(e=>({default:e.AddressField})),geolocation:()=>Promise.resolve().then(()=>(T9(),Mmt)).then(e=>({default:e.GeolocationField})),signature:()=>Promise.resolve().then(()=>(E9(),Pmt)).then(e=>({default:e.SignatureField})),qrcode:()=>Promise.resolve().then(()=>(D9(),Imt)).then(e=>({default:e.QRCodeField}))};function mht(e){let t=pht[e];if(!t){console.warn(`Unknown field type: ${e}`);return}let n=H.lazy(t);b.register(e,n,{namespace:`field`})}function hht(){Object.keys(pht).forEach(e=>{mht(e)})}hht();var ght=(0,H.createContext)(null);ght.displayName=`PermissionContext`;function H9(){let e=(0,H.useContext)(ght);return(0,H.useMemo)(()=>e?{...e,can:(t,n)=>e.check(t,n).allowed,cannot:(t,n)=>!e.check(t,n).allowed}:{check:()=>({allowed:!0}),checkField:()=>!0,getFieldPermissions:()=>[],getRowFilter:()=>void 0,roles:[],isLoaded:!1,can:()=>!0,cannot:()=>!1},[e])}function U9(e){let{checkField:t,getFieldPermissions:n}=H9(),r=(0,H.useMemo)(()=>n(e),[n,e]);return(0,H.useMemo)(()=>({permissions:r,canRead:n=>t(e,n,`read`),canWrite:n=>t(e,n,`write`),readableFields:n=>n.filter(n=>t(e,n,`read`)),writableFields:n=>n.filter(n=>t(e,n,`write`))}),[r,t,e])}var _ht=new Set([`textarea`,`markdown`,`html`,`grid`,`rich-text`,`field:textarea`,`field:markdown`,`field:html`,`field:grid`,`field:rich-text`]);function vht(e){return _ht.has(e)}function yht(e,t){let n;if(n=e<=3?1:e<=10?2:3,t!==void 0){if(t<640)return Math.min(n,1);if(t<900)return Math.min(n,2)}return n}function bht(e,t){return t<=1?e:e.map(e=>e.span===void 0&&e.type&&vht(e.type)?{...e,span:t}:e)}function xht(e,t,n){if(t!==void 0)return{fields:bht(e,t),columns:t};let r=yht(e.length,n);return{fields:bht(e,r),columns:r}}function Sht(e,t){return function(){try{let n=Vn();return n.t(t)===t?{t:(t,n)=>{let r=e[t]||t;if(n)for(let[e,t]of Object.entries(n))r=r.replace(`{{${e}}}`,String(t));return r}}:{t:n.t}}catch{return{t:(t,n)=>{let r=e[t]||t;if(n)for(let[e,t]of Object.entries(n))r=r.replace(`{{${e}}}`,String(t));return r}}}}}var W9=Sht({"detail.back":`Back`,"detail.edit":`Edit`,"detail.editInline":`Edit`,"detail.save":`Save`,"detail.saveChanges":`Save changes`,"detail.editFieldsInline":`Edit fields inline`,"detail.cancel":`Cancel`,"detail.cancelEdit":`Discard changes`,"detail.openInNewTab":`Open in new tab`,"detail.share":`Share`,"detail.duplicate":`Duplicate`,"detail.export":`Export`,"detail.viewHistory":`View history`,"detail.delete":`Delete`,"detail.moreActions":`More actions`,"detail.addToFavorites":`Add to favorites`,"detail.removeFromFavorites":`Remove from favorites`,"detail.previousRecord":`Previous record`,"detail.nextRecord":`Next record`,"detail.recordOf":`{{current}} of {{total}}`,"detail.recordNotFound":`Record not found`,"detail.recordNotFoundDescription":`The record you are looking for does not exist or may have been deleted.`,"detail.goBack":`Go back`,"detail.details":`Details`,"detail.related":`Related`,"detail.relatedRecords":`{{count}} records`,"detail.relatedRecordOne":`{{count}} record`,"detail.noRelatedRecords":`No related records found`,"detail.loading":`Loading...`,"detail.copyToClipboard":`Copy to clipboard`,"detail.copied":`Copied!`,"detail.deleteConfirmation":`Are you sure you want to delete this record?`,"detail.editRecord":`Edit record`,"detail.viewAll":`View All`,"detail.new":`New`,"detail.emptyValue":`—`,"detail.activity":`Activity`,"detail.copyRecordId":`Copy record ID`,"detail.showEmptyFields":`Show {{count}} empty fields`,"detail.hideEmptyFields":`Hide empty fields`,"detail.editRow":`Edit`,"detail.deleteRow":`Delete`,"detail.deleteRowConfirmation":`Are you sure you want to delete this record?`,"detail.actions":`Actions`,"detail.previousPage":`Previous`,"detail.nextPage":`Next`,"detail.pageOf":`Page {{current}} of {{total}}`,"detail.sortBy":`Sort by`,"detail.filterPlaceholder":`Filter...`,"detail.highlightFields":`Key Fields`,"detail.comments":`Comments`,"detail.searchComments":`Search comments…`,"detail.addCommentPlaceholder":`Add a comment… (Ctrl+Enter to submit)`,"detail.noMatchingComments":`No matching comments`,"detail.noCommentsYet":`No comments yet`,"detail.pinned":`Pinned`,"detail.pin":`Pin`,"detail.unpin":`Unpin`,"detail.justNow":`just now`,"detail.minutesAgo":`{{count}}m ago`,"detail.hoursAgo":`{{count}}h ago`,"detail.daysAgo":`{{count}}d ago`,"detail.createdBy":`Created by`,"detail.updatedBy":`Updated by`,"detail.dropFilesToUpload":`Drop files here or click to upload`,"detail.attachmentCount":`{{count}} attachment`,"detail.attachmentCountPlural":`{{count}} attachments`,"detail.removeAttachment":`Remove attachment`,"detail.unifiedDiff":`Unified diff`,"detail.sideBySideDiff":`Side-by-side diff`,"detail.noChanges":`No changes`,"detail.previousVersion":`Previous`,"detail.currentVersion":`Current`,"detail.discussion":`Discussion`,"detail.showDiscussion":`Show Discussion ({{count}})`,"detail.hideDiscussion":`Hide discussion`,"detail.bold":`Bold (Ctrl+B)`,"detail.italic":`Italic (Ctrl+I)`,"detail.listFormat":`List`,"detail.inlineCode":`Inline code`,"detail.mentionSomeone":`Mention someone`,"detail.preview":`Preview`,"detail.submitComment":`Submit (Ctrl+Enter)`,"detail.sendComment":`Send`,"detail.writeComment":`Write a comment…`,"detail.subscribedTooltip":`Subscribed — click to unsubscribe`,"detail.unsubscribedTooltip":`Subscribe to notifications`,"detail.firstRecord":`First record (Home)`,"detail.previousRecordKey":`Previous record (←)`,"detail.nextRecordKey":`Next record (→)`,"detail.lastRecord":`Last record (End)`,"detail.noRecords":`No records`,"detail.searchWhileNavigating":`Search while navigating`,"detail.searchRecords":`Search records…`,"detail.allActivity":`All Activity`,"detail.commentsOnly":`Comments Only`,"detail.fieldChangesFilter":`Field Changes`,"detail.tasksOnly":`Tasks Only`,"detail.leaveCommentPlaceholder":`Leave a comment… (Ctrl+Enter to submit)`,"detail.noActivity":`No activity recorded`,"detail.loadMore":`Load more`,"detail.edited":`(edited)`,"detail.via":`via {{source}}`,"detail.replyCount":`{{count}} reply`,"detail.replyCountPlural":`{{count}} replies`,"detail.replyPlaceholder":`Reply…`,"detail.filterActivity":`Filter activity`,"detail.openDiscussion":`Open discussion panel`,"detail.closeDiscussion":`Close discussion panel`,"detail.subscribeAriaLabel":`Subscribe to notifications`,"detail.unsubscribeAriaLabel":`Unsubscribe from notifications`,"detail.clearSearch":`Clear search`},`detail.back`);function Cht(e,t){return!e||e<=1||t<=1?``:t===2?e>=2?`md:col-span-2`:``:e===2?`md:col-span-2`:e>=3?`md:col-span-2 lg:col-span-3`:``}var G9=({section:e,data:t,className:n,objectSchema:r,objectName:i,isEditing:a=!1,onFieldChange:o,virtualScroll:s})=>{let[c,l]=H.useState(e.defaultCollapsed??!1),[u,d]=H.useState(null),[f,p]=H.useState(void 0),[m,h]=H.useState(!1),{t:g}=W9(),{fieldLabel:_,translateOptions:v}=Gn(),y=H.useCallback((e,t)=>{let n=t==null?``:String(t);navigator.clipboard.writeText(n).then(()=>{d(e),setTimeout(()=>d(null),2e3)})},[]),b=H.useCallback(e=>{let n=t?.[e.name]??e.value;return n==null||n===``},[t]),x=H.useMemo(()=>e.fields.filter(b).length,[e.fields,b]),S=C5(),C=S?3:6,w=S?.2:.5,T=e.fields.length-x,E=!e.hideEmpty&&!a&&e.fields.length>=C&&x/e.fields.length>=w&&T>0,D=!m&&(e.hideEmpty||E)?e.fields.filter(e=>!b(e)):e.fields;if(D.length===0&&x===e.fields.length)return null;let{fields:O,columns:k}=xht(D,e.columns),A=e=>{let n=t?.[e.name]??e.value;if(e.render)return(0,U.jsx)(Se,{schema:e.render,data:{...t,value:n}});let s=Cht(e.span,k),c=r?.fields?.[e.name],l={...e};if(c){!e.type&&c.type&&(l.type=c.type),c.options&&!l.options&&(l.options=c.options),c.currency&&!l.currency&&(l.currency=c.currency),c.precision!==void 0&&l.precision===void 0&&(l.precision=c.precision),c.format&&!l.format&&(l.format=c.format);let t=c.reference_to||c.reference;t&&!l.reference_to&&(l.reference_to=t),c.reference_field&&!l.reference_field&&(l.reference_field=c.reference_field)}i&&Array.isArray(l.options)&&l.options.length>0&&(l.options=v(i,e.name,l.options));let d=(()=>{if(n==null)return(0,U.jsx)(`span`,{className:`text-muted-foreground/50 text-xs italic`,children:`—`});let t=B9(l)||e.type;if(t){let e=V9(t);if(e)return(0,U.jsx)(e,{value:n,field:l})}return String(n)})(),f=n!=null&&n!==``,p=u===e.name;return(0,U.jsxs)(`div`,{className:q(`space-y-1.5 group`,s),children:[(0,U.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:_(i||``,e.name,e.label||e.name)}),a&&!e.readonly?(0,U.jsx)(`div`,{className:`min-h-[44px] sm:min-h-0`,children:(()=>{let t=l.type||e.type;if(t===`select`&&Array.isArray(l.options)&&l.options.length>0)return(0,U.jsx)(cpt,{field:l,value:n==null?``:String(n),onChange:t=>o?.(e.name,t)});if(t===`boolean`)return(0,U.jsx)(ipt,{field:l,value:!!n,onChange:t=>o?.(e.name,t)});let r=t===`date`||t===`datetime`;return(0,U.jsx)(`input`,{type:t===`number`?`number`:r?`date`:`text`,className:`w-full px-2 py-1.5 text-sm border rounded-md bg-background focus:outline-none focus:ring-2 focus:ring-ring`,value:n==null?``:r?(()=>{let e=String(n);if(/^\d{4}-\d{2}-\d{2}/.test(e))return e.slice(0,10);let t=new Date(e);return isNaN(t.getTime())?``:t.toLocaleDateString(`en-CA`)})():String(n),onChange:t=>{let n=t.target.value;if(r&&n){let t=new Date(n+`T00:00:00`).toISOString();o?.(e.name,t)}else o?.(e.name,n)}})})()}):(0,U.jsxs)(`div`,{className:q(`flex items-start justify-between gap-2 min-h-[44px] sm:min-h-0 rounded-md`,f&&`cursor-pointer active:bg-muted/60 transition-colors`),onClick:f?()=>y(e.name,n):void 0,onKeyDown:f?t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),y(e.name,n))}:void 0,role:f?`button`:void 0,tabIndex:f?0:void 0,children:[(0,U.jsx)(`div`,{className:`text-sm flex-1 break-words py-1`,children:d}),f&&(0,U.jsx)(P5,{children:(0,U.jsxs)(F5,{children:[(0,U.jsx)(I5,{asChild:!0,children:(0,U.jsx)(Q,{variant:`ghost`,size:`icon`,className:`h-6 w-6 opacity-0 group-hover:opacity-100 transition-opacity shrink-0`,onClick:t=>{t.stopPropagation(),y(e.name,n)},children:p?(0,U.jsx)(Yp,{className:`h-3 w-3 text-green-600`}):(0,U.jsx)(ab,{className:`h-3 w-3`})})}),(0,U.jsx)(L5,{children:g(p?`detail.copied`:`detail.copyToClipboard`)})]})})]})]},e.name)},j=s?.enabled===!0,M=s?.batchSize??20;H.useEffect(()=>{if(!j){p(void 0);return}if(O.length<=M){p(void 0);return}p(M);let e=setTimeout(()=>p(void 0),100);return()=>clearTimeout(e)},[j,O.length,M]);let N=f===void 0?O:O.slice(0,f),P=x>0&&(e.hideEmpty||E),F=(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`div`,{className:q(`grid gap-3 sm:gap-4`,k===1?`grid-cols-1`:k===2?`grid-cols-1 md:grid-cols-2`:`grid-cols-1 md:grid-cols-2 lg:grid-cols-3`),children:N.map(A)}),P&&(0,U.jsx)(`div`,{className:`mt-3 -ml-2`,children:(0,U.jsxs)(Q,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>h(e=>!e),className:`h-7 px-2 text-xs text-muted-foreground hover:text-foreground`,children:[(0,U.jsx)(m?AC:MC,{className:`h-3.5 w-3.5 mr-1.5`}),m?g(`detail.hideEmptyFields`,{defaultValue:`Hide empty fields`}):g(`detail.showEmptyFields`,{count:x,defaultValue:`Show ${x} empty field${x===1?``:`s`}`})]})})]});return!e.title&&!e.collapsible&&e.showBorder===!1?(0,U.jsx)(`div`,{className:q(n),children:F}):e.collapsible?(0,U.jsx)(m2,{open:!c,onOpenChange:e=>l(!e),className:n,children:(0,U.jsxs)(E0,{children:[(0,U.jsx)(h2,{asChild:!0,children:(0,U.jsxs)(D0,{className:q(`cursor-pointer hover:bg-muted/50 transition-colors`,e.headerColor&&`bg-${e.headerColor}`),children:[(0,U.jsxs)(O0,{className:`flex items-center justify-between`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.icon&&(0,U.jsx)(`span`,{className:`text-muted-foreground`,children:e.icon}),(0,U.jsx)(`span`,{children:e.title}),e.fields&&(0,U.jsx)(T1,{variant:`secondary`,className:`ml-2 text-xs`,children:e.fields.length})]}),(0,U.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,U.jsx)(c?Qp:Xp,{className:`h-4 w-4 text-muted-foreground`})})]}),e.description&&!c&&(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1.5`,children:e.description})]})}),(0,U.jsx)(g2,{children:(0,U.jsx)(A0,{className:`pt-4 sm:pt-6 px-3 sm:px-6`,children:F})})]})}):(0,U.jsxs)(E0,{className:q(e.showBorder===!1?`border-none shadow-none`:``,n),children:[e.title&&(0,U.jsxs)(D0,{className:q(e.headerColor&&`bg-${e.headerColor}`),children:[(0,U.jsx)(O0,{className:`flex items-center justify-between`,children:(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.icon&&(0,U.jsx)(`span`,{className:`text-muted-foreground`,children:e.icon}),(0,U.jsx)(`span`,{children:e.title})]})}),e.description&&(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1.5`,children:e.description})]}),(0,U.jsx)(A0,{className:`pt-4 sm:pt-6 px-3 sm:px-6`,children:F})]})},wht=({tabs:e,data:t,className:n})=>{let[r,i]=H.useState(e[0]?.key),a=e.filter(e=>typeof e.visible==`boolean`?e.visible:(e.visible,!0));return(0,U.jsxs)(l7,{value:r,onValueChange:i,className:n,children:[(0,U.jsx)(u7,{className:`w-full justify-start border-b rounded-none bg-transparent p-0`,children:a.map(e=>(0,U.jsx)(d7,{value:e.key,className:`relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent`,children:(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.icon&&(0,U.jsx)(`span`,{children:e.icon}),(0,U.jsx)(`span`,{children:e.label}),e.badge&&(0,U.jsx)(T1,{variant:`secondary`,className:`ml-1`,children:e.badge})]})},e.key))}),a.map(e=>(0,U.jsx)(f7,{value:e.key,className:`mt-4`,children:(0,U.jsx)(H.Suspense,{fallback:null,children:Array.isArray(e.content)?(0,U.jsx)(`div`,{className:`space-y-4`,children:e.content.map((e,n)=>(0,U.jsx)(Se,{schema:e,data:t},n))}):(0,U.jsx)(Se,{schema:e.content,data:t})})},e.key))]})};function Tht(e){return e&&u$[e.split(/[-_\s]/).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``)]||BN}var K9=({title:e,type:t,api:n,data:r,schema:i,columns:a,className:o,dataSource:s,objectName:c,onNew:l,onViewAll:u,onRowEdit:d,onRowDelete:f,onRowClick:p,maxColumns:m=6,pageSize:h,sortable:g=!1,filterable:_=!1,collapsible:v=!1,defaultCollapsed:y=!1,referenceField:b,icon:x})=>{let S=r!==void 0,C=r??[],[w,T]=H.useState(C),[E,D]=H.useState(!1),[O,k]=H.useState(0),[A,j]=H.useState(null),[M,N]=H.useState(`asc`),[P,F]=H.useState(``),[I,L]=H.useState(null),[ee,te]=H.useState(y),[ne,R]=H.useState({}),{t:z}=W9(),{fieldLabel:re}=Gn();H.useEffect(()=>{S&&T(r??[])},[r,S]),H.useEffect(()=>{n&&s?.getObjectSchema&&!a?.length&&s.getObjectSchema(n).then(L).catch(e=>{console.warn(`[RelatedList] Failed to fetch schema for ${n}:`,e)})},[n,s,a]),H.useEffect(()=>{n&&!S&&(D(!0),s&&typeof s.find==`function`?s.find(n).then(e=>{T(Array.isArray(e)?e:Array.isArray(e?.data)?e.data:[]),D(!1)}).catch(e=>{console.error(`Failed to fetch related data:`,e),D(!1)}):fetch(n).then(e=>e.json()).then(e=>{T(Array.isArray(e)?e:e?.data||[])}).catch(e=>{console.error(`Failed to fetch related data:`,e)}).finally(()=>D(!1)))},[n,S,s]),H.useEffect(()=>{if(!s?.find||!I?.fields||!w.length)return;let e=I.fields,t=[];for(let[n,r]of Object.entries(e)){if(!r||r.type!==`lookup`&&r.type!==`master_detail`)continue;let e=r.reference_to||r.reference;if(!e)continue;let i=new Set;for(let e of w){let t=e?.[n];t!=null&&(typeof t==`string`&&t?i.add(t):typeof t==`number`&&i.add(String(t)))}let a=ne[n]||{},o=Array.from(i).filter(e=>!(e in a));o.length>0&&t.push({fieldName:n,target:e,ids:o})}if(t.length===0)return;let n=!1;return Promise.all(t.map(({fieldName:e,target:t,ids:n})=>s.find(t,{$filter:{id:{$in:n}},$top:n.length}).then(t=>{let n=Array.isArray(t)?t:t?.data||[],r={};for(let e of n){let t=e?.id||e?._id;t&&(r[String(t)]=e?.full_name||e?.fullname||e?.display_name||e?.name||e?.subject||e?.title||e?.label||e?.code||String(t))}return{fieldName:e,map:r}}).catch(t=>(console.warn(`[RelatedList] Failed to resolve lookups for ${e}:`,t),{fieldName:e,map:{}})))).then(e=>{n||R(t=>{let n={...t};for(let{fieldName:t,map:r}of e)n[t]={...n[t]||{},...r};return n})}),()=>{n=!0}},[s,I,w]);let B=H.useMemo(()=>{if(!P)return w;let e=P.toLowerCase();return w.filter(t=>Object.values(t).some(t=>t!=null&&String(t).toLowerCase().includes(e)))},[w,P]),ie=H.useMemo(()=>A?[...B].sort((e,t)=>{let n=e[A],r=t[A];if(n==null&&r==null)return 0;if(n==null)return 1;if(r==null)return-1;let i=String(n).localeCompare(String(r),void 0,{numeric:!0});return M===`asc`?i:-i}):B,[B,A,M]),ae=h&&h>0?h:0,oe=ae?Math.max(1,Math.ceil(ie.length/ae)):1,V=ae?ie.slice(O*ae,(O+1)*ae):ie;H.useEffect(()=>{k(0)},[P,A,M]);let se=H.useCallback(e=>{A===e?N(e=>e===`asc`?`desc`:`asc`):(j(e),N(`asc`))},[A]),[ce,le]=H.useState(null),ue=H.useCallback(e=>{le(e)},[]),de=H.useCallback(()=>{ce&&f?.(ce),le(null)},[ce,f]),fe=H9(),pe=H.useMemo(()=>{let e=c||n||``,t=t=>!fe?.isLoaded||!e?t:t.filter(t=>{let n=t?.accessorKey||t?.field||t?.name;return n?fe.checkField(e,String(n),`read`):!0}),r=e=>b?e.filter(e=>(e?.accessorKey||e?.field||e?.name)!==b):e,i=e=>e==null||typeof e==`string`&&e.trim()===``||Array.isArray(e)&&e.length===0,o=e=>w.length?e.filter(e=>{let t=e?.accessorKey||e?.field||e?.name;return t?w.some(e=>!i(e?.[t])):!0}):e;if(a&&a.length>0)return o(t(r(a)));if(!I?.fields)return[];let s=e,l=new Set([`image`,`file`,`attachment`,`rich_text`,`html`,`json`]),u=[`name`,`full_name`,`fullname`,`title`,`subject`,`label`,`code`,`number`],d=Object.entries(I.fields).filter(([e,t])=>!(e.startsWith(`_`)||e===`id`||e===b||t?.hidden||t?.type&&l.has(t.type)||fe?.isLoaded&&s&&!fe.checkField(s,e,`read`)));return d.sort(([e,t],[n,r])=>{let i=u.indexOf(e),a=u.indexOf(n),o=i>=0?i:100,s=a>=0?a:100;if(o!==s)return o-s;let c=t?.type===`select`||e.includes(`status`);return c===(r?.type===`select`||n.includes(`status`))?0:c?-1:1}),o(d.map(([e,t])=>{let n={accessorKey:e,header:re(s,e,t.label||e)};if(t.type){let r=V9(B9({type:t.type,format:t.format})||t.type);if(r){let i=t.type===`lookup`||t.type===`master_detail`?ne[e]:void 0,a=i&&Object.keys(i).length>0?Object.entries(i).map(([e,t])=>({value:e,label:t})):void 0,o={name:e,label:t.label||e,type:t.type,...(a||t.options)&&{options:a||t.options},...t.currency&&{currency:t.currency},...t.precision!==void 0&&{precision:t.precision},...t.format&&{format:t.format},...(t.reference_to||t.reference)&&{reference_to:t.reference_to||t.reference},...t.reference_field&&{reference_field:t.reference_field}};n.cell=e=>e==null?H.createElement(`span`,{className:`text-muted-foreground/50 text-xs italic`},`—`):H.createElement(r,{value:e,field:o})}}return n})).slice(0,Math.max(1,m))},[a,I,c,n,re,b,w,m,ne,fe]),me=!!d||!!f,he=H.useMemo(()=>{if(i)return i;switch(t){case`grid`:case`table`:return{type:`data-table`,data:V,columns:pe,pagination:!1,pageSize:ae||10,searchable:!1,exportable:!1,rowActions:me,onRowEdit:d,onRowDelete:f?ue:void 0,onRowClick:p};case`list`:return{type:`data-list`,data:V};default:return{type:`div`,children:`No view configured`}}},[t,V,pe,i,ae,me,d,f,ue,p]),ge=v?`cursor-pointer select-none`:void 0,_e=v?()=>te(e=>!e):void 0,ve=Tht(x),ye=!E&&w.length===0,be=_;return(0,U.jsxs)(E0,{className:q(`shadow-none`,ye&&`bg-muted/20`,o),children:[(0,U.jsx)(D0,{className:q(`py-3 px-4`,ge),onClick:_e,children:(0,U.jsxs)(O0,{className:`flex items-center justify-between gap-2 text-sm font-semibold`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[v&&(0,U.jsx)(ee?Qp:Xp,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`}),(0,U.jsx)(ve,{className:`h-4 w-4 text-muted-foreground shrink-0`,"aria-hidden":!0}),(0,U.jsx)(`span`,{className:`truncate`,children:e}),(0,U.jsx)(T1,{variant:`secondary`,className:q(`text-xs font-normal h-5 px-1.5`,w.length===0&&`bg-muted text-muted-foreground`),"aria-label":`${w.length} records`,children:w.length})]}),(0,U.jsx)(`div`,{className:`flex items-center gap-1 shrink-0`,children:l&&(0,U.jsxs)(Q,{variant:`outline`,size:`sm`,onClick:e=>{e.stopPropagation(),l()},className:`gap-1 h-7 text-xs shadow-none`,children:[(0,U.jsx)(zK,{className:`h-3.5 w-3.5`}),z(`detail.new`)]})})]})}),!ee&&(0,U.jsxs)(A0,{className:q(`pt-0`,ye?`pb-3 px-4`:`pb-4 px-4`),children:[be&&(0,U.jsx)(`div`,{className:`mb-3`,children:(0,U.jsx)(f6,{placeholder:z(`detail.filterPlaceholder`),value:P,onChange:e=>F(e.target.value),className:`h-8 text-sm`})}),g&&pe&&pe.length>0&&w.length>0&&(0,U.jsx)(`div`,{className:`flex flex-wrap gap-1 mb-3`,children:pe.map(e=>{let t=e.accessorKey||e.field||e.name;if(!t)return null;let n=e.header||e.label||t,r=A===t;return(0,U.jsxs)(Q,{variant:r?`secondary`:`ghost`,size:`sm`,className:`gap-1 h-7 text-xs`,onClick:()=>se(t),children:[(0,U.jsx)(Xu,{className:`h-3 w-3`}),n,r&&(M===`asc`?` ↑`:` ↓`)]},t)})}),E?(0,U.jsx)(`div`,{className:`flex items-center justify-center py-6 text-muted-foreground text-sm`,children:z(`detail.loading`)}):ye?(0,U.jsxs)(`div`,{className:`flex flex-col items-center justify-center gap-2 py-6 text-sm`,children:[(0,U.jsx)(ve,{className:`h-8 w-8 text-muted-foreground/40`,"aria-hidden":!0}),(0,U.jsx)(`span`,{className:`text-muted-foreground italic`,children:z(`detail.noRelatedRecords`)}),l&&(0,U.jsxs)(Q,{variant:`outline`,size:`sm`,onClick:l,className:`gap-1 h-7 text-xs mt-1`,children:[(0,U.jsx)(zK,{className:`h-3.5 w-3.5`}),z(`detail.new`)]})]}):(0,U.jsx)(Se,{schema:he}),ae>0&&ie.length>ae&&(0,U.jsxs)(`div`,{className:`flex items-center justify-between mt-3 pt-3 border-t`,children:[(0,U.jsxs)(Q,{variant:`outline`,size:`sm`,className:`h-7 text-xs gap-1`,disabled:O===0,onClick:()=>k(e=>Math.max(0,e-1)),children:[(0,U.jsx)(Zp,{className:`h-3 w-3`}),z(`detail.previousPage`)]}),(0,U.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:z(`detail.pageOf`,{current:O+1,total:oe})}),(0,U.jsxs)(Q,{variant:`outline`,size:`sm`,className:`h-7 text-xs gap-1`,disabled:O>=oe-1,onClick:()=>k(e=>Math.min(oe-1,e+1)),children:[z(`detail.nextPage`),(0,U.jsx)(Qp,{className:`h-3 w-3`})]})]}),u&&!ye&&ae>0&&ie.length>ae&&(0,U.jsx)(`div`,{className:`mt-3 pt-3 border-t flex justify-center`,children:(0,U.jsxs)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),u()},className:`text-xs text-muted-foreground hover:text-foreground inline-flex items-center gap-1 transition-colors`,children:[z(`detail.viewAll`),(0,U.jsx)(EC,{className:`h-3 w-3`})]})})]}),(0,U.jsx)(QXe,{open:ce!==null,onOpenChange:e=>{e||le(null)},children:(0,U.jsxs)(d1,{children:[(0,U.jsxs)(f1,{children:[(0,U.jsx)(m1,{children:z(`detail.deleteRowTitle`,{defaultValue:`Delete record`})}),(0,U.jsx)(h1,{children:z(`detail.deleteRowConfirmation`)})]}),(0,U.jsxs)(p1,{children:[(0,U.jsx)(_1,{children:z(`detail.cancel`,{defaultValue:`Cancel`})}),(0,U.jsx)(g1,{onClick:de,className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:z(`detail.delete`,{defaultValue:`Delete`})})]})]})})]})},Eht=({group:e,data:t,className:n,objectSchema:r,objectName:i,isEditing:a=!1,onFieldChange:o})=>{let s=e.collapsible??!0,[c,l]=H.useState(e.defaultCollapsed??!1),u=(0,U.jsx)(`div`,{className:`space-y-3 sm:space-y-4`,children:e.sections.map((e,n)=>(0,U.jsx)(G9,{section:e,data:t,objectSchema:r,objectName:i,isEditing:a,onFieldChange:o},n))});return s?(0,U.jsxs)(m2,{open:!c,onOpenChange:e=>l(!e),className:n,children:[(0,U.jsx)(h2,{asChild:!0,children:(0,U.jsxs)(`div`,{className:`flex items-center gap-2 pb-2 border-b cursor-pointer hover:bg-muted/50 transition-colors rounded-t-md px-2 py-1.5`,children:[(0,U.jsx)(c?Qp:Xp,{className:`h-4 w-4 text-muted-foreground shrink-0`}),e.icon&&(0,U.jsx)(`span`,{className:`text-muted-foreground`,children:e.icon}),(0,U.jsx)(`h3`,{className:`text-lg font-semibold`,children:e.title})]})}),e.description&&!c&&(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:e.description}),(0,U.jsx)(g2,{children:(0,U.jsx)(`div`,{className:`mt-3`,children:u})})]}):(0,U.jsxs)(`div`,{className:q(`space-y-3`,n),children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2 pb-2 border-b`,children:[e.icon&&(0,U.jsx)(`span`,{className:`text-muted-foreground`,children:e.icon}),(0,U.jsx)(`h3`,{className:`text-lg font-semibold`,children:e.title})]}),e.description&&(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e.description}),u]})},Dht=({fields:e,data:t,className:n,objectName:r,objectSchema:i})=>{let{fieldLabel:a}=Gn();if(!e.length||!t)return null;let o=e.filter(e=>{let n=t?.[e.name];return n!=null&&n!==``});return o.length===0?null:(0,U.jsx)(E0,{className:q(`bg-muted/30 border-dashed`,n),children:(0,U.jsx)(A0,{className:`@container py-3 px-4`,children:(0,U.jsx)(`div`,{className:q(`grid gap-4`,o.length===1?`grid-cols-1`:o.length===2?`grid-cols-1 @sm:grid-cols-2`:o.length===3?`grid-cols-1 @sm:grid-cols-3`:`grid-cols-1 @sm:grid-cols-2 @xl:grid-cols-4`),children:o.map(e=>{let n=t[e.name],o=i?.fields?.[e.name],s=e.type||o?.type,c={name:e.name,label:e.label,type:s||`text`,...o?.options&&{options:o.options},...o?.currency&&{currency:o.currency},...o?.precision!==void 0&&{precision:o.precision},...o?.format&&{format:o.format}},l=V9(B9(c)||s||`text`);return(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,U.jsxs)(`span`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:[e.icon&&(0,U.jsx)(`span`,{className:`mr-1`,children:e.icon}),a(r||``,e.name,e.label)]}),(0,U.jsx)(`span`,{className:`block min-w-0 truncate text-sm font-semibold`,children:(0,U.jsx)(l,{value:n,field:c})})]},e.name)})})})})};function Oht(e){try{let t=new Date(e),n=new Date().getTime()-t.getTime(),r=Math.floor(n/6e4);if(r<1)return`just now`;if(r<60)return`${r}m ago`;let i=Math.floor(r/60);if(i<24)return`${i}h ago`;let a=Math.floor(i/24);return a<7?`${a}d ago`:t.toLocaleDateString()}catch{return e}}var kht=({comments:e,onAddComment:t,onTogglePin:n,searchable:r=!1,className:i})=>{let{t:a}=W9(),[o,s]=H.useState(``),[c,l]=H.useState(!1),[u,d]=H.useState(``),f=H.useCallback(async()=>{let e=o.trim();if(!(!e||!t)){l(!0);try{await t(e),s(``)}finally{l(!1)}}},[o,t]),p=H.useCallback(e=>{e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),f())},[f]),m=H.useMemo(()=>[...u.trim()?e.filter(e=>{let t=u.trim().toLowerCase();return e.text.toLowerCase().includes(t)||e.author.toLowerCase().includes(t)}):e].sort((e,t)=>e.pinned&&!t.pinned?-1:!e.pinned&&t.pinned?1:0),[e,u]);return(0,U.jsxs)(E0,{className:q(``,i),children:[(0,U.jsx)(D0,{children:(0,U.jsxs)(O0,{className:`flex items-center gap-2 text-base`,children:[(0,U.jsx)(nB,{className:`h-4 w-4`}),a(`detail.comments`),(0,U.jsxs)(`span`,{className:`text-sm font-normal text-muted-foreground`,children:[`(`,e.length,`)`]})]})}),(0,U.jsxs)(A0,{className:`space-y-4`,children:[r&&(0,U.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,U.jsxs)(`div`,{className:`relative flex-1`,children:[(0,U.jsx)(vZ,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground`}),(0,U.jsx)(`input`,{className:`w-full rounded-md border border-input bg-background pl-8 pr-8 py-1.5 text-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring`,placeholder:a(`detail.searchComments`),value:u,onChange:e=>d(e.target.value),"aria-label":a(`detail.searchComments`)}),u&&(0,U.jsx)(`button`,{className:`absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,onClick:()=>d(``),"aria-label":a(`detail.clearSearch`),type:`button`,children:(0,U.jsx)(c$,{className:`h-3.5 w-3.5`})})]})}),t&&(0,U.jsxs)(`div`,{className:`flex gap-2`,children:[(0,U.jsx)(`textarea`,{className:`flex-1 min-h-[60px] rounded-md border border-input bg-background px-3 py-2 text-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring resize-none`,placeholder:a(`detail.addCommentPlaceholder`),value:o,onChange:e=>s(e.target.value),onKeyDown:p,disabled:c}),(0,U.jsx)(Q,{size:`icon`,variant:`default`,onClick:f,disabled:!o.trim()||c,className:`shrink-0 self-end`,children:(0,U.jsx)(DZ,{className:`h-4 w-4`})})]}),m.length===0?(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground text-center py-4`,children:u.trim()?a(`detail.noMatchingComments`):a(`detail.noCommentsYet`)}):(0,U.jsx)(`div`,{className:`space-y-3`,children:m.map(e=>(0,U.jsxs)(`div`,{className:q(`flex gap-3`,e.pinned&&`bg-muted/40 rounded-md p-2 -mx-2`),children:[(0,U.jsx)(`div`,{className:`shrink-0`,children:e.avatarUrl?(0,U.jsx)(`img`,{src:e.avatarUrl,alt:e.author,className:`h-8 w-8 rounded-full object-cover`}):(0,U.jsx)(`div`,{className:`h-8 w-8 rounded-full bg-muted flex items-center justify-center text-xs font-medium text-muted-foreground`,children:e.author.charAt(0).toUpperCase()})}),(0,U.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2 mb-0.5`,children:[(0,U.jsx)(`span`,{className:`text-sm font-medium truncate`,children:e.author}),(0,U.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:Oht(e.createdAt)}),e.pinned&&(0,U.jsxs)(`span`,{className:`text-xs text-amber-600 flex items-center gap-0.5`,children:[(0,U.jsx)(gK,{className:`h-3 w-3`}),a(`detail.pinned`)]})]}),(0,U.jsx)(`p`,{className:`text-sm whitespace-pre-wrap break-words`,children:e.text}),n&&(0,U.jsxs)(`button`,{type:`button`,className:`mt-1 text-xs text-muted-foreground hover:text-foreground flex items-center gap-1`,onClick:()=>n(e.id),"aria-label":e.pinned?a(`detail.unpin`):a(`detail.pin`),children:[(0,U.jsx)(gK,{className:`h-3 w-3`}),e.pinned?a(`detail.unpin`):a(`detail.pin`)]})]})]},e.id))})]})]})},Aht={field_change:QQ,create:sg,delete:r$,comment:nB,status_change:Mu},jht={field_change:`bg-blue-100 text-blue-600`,create:`bg-green-100 text-green-600`,delete:`bg-red-100 text-red-600`,comment:`bg-purple-100 text-purple-600`,status_change:`bg-amber-100 text-amber-600`};function Mht(e){try{let t=new Date(e),n=new Date().getTime()-t.getTime(),r=Math.floor(n/6e4);if(r<1)return`just now`;if(r<60)return`${r}m ago`;let i=Math.floor(r/60);if(i<24)return`${i}h ago`;let a=Math.floor(i/24);return a<7?`${a}d ago`:t.toLocaleDateString()}catch{return e}}function Nht(e){return e.description?e.description:e.type===`field_change`&&e.field?`Changed ${e.field.charAt(0).toUpperCase()+e.field.slice(1).replace(/_/g,` `)} from "${e.oldValue==null?`(empty)`:String(e.oldValue)}" to "${e.newValue==null?`(empty)`:String(e.newValue)}"`:e.type===`create`?`Created this record`:e.type===`delete`?`Deleted this record`:e.type===`status_change`&&e.field?`Changed status to "${e.newValue==null?`(empty)`:String(e.newValue)}"`:`Updated record`}var Pht={all:`All`,field_change:`Field Changes`,create:`Creates`,delete:`Deletes`,comment:`Comments`,status_change:`Status Changes`},Fht=({activities:e,filterable:t=!1,defaultFilter:n=`all`,className:r})=>{let[i,a]=H.useState(n),o=H.useMemo(()=>i===`all`?e:e.filter(e=>e.type===i),[e,i]);return(0,U.jsxs)(E0,{className:q(``,r),children:[(0,U.jsx)(D0,{children:(0,U.jsxs)(O0,{className:`flex items-center gap-2 text-base`,children:[(0,U.jsx)(Co,{className:`h-4 w-4`}),`Activity`,(0,U.jsxs)(`span`,{className:`text-sm font-normal text-muted-foreground`,children:[`(`,o.length,`)`]})]})}),(0,U.jsxs)(A0,{children:[t&&(0,U.jsx)(`div`,{className:`flex flex-wrap gap-1.5 mb-4`,role:`group`,"aria-label":`Activity type filter`,children:Object.keys(Pht).map(e=>(0,U.jsxs)(`button`,{type:`button`,className:q(`inline-flex items-center gap-1 rounded-full px-2.5 py-0.5 text-xs font-medium transition-colors`,i===e?`bg-primary text-primary-foreground`:`bg-muted text-muted-foreground hover:bg-muted/80`),onClick:()=>a(e),"aria-pressed":i===e,children:[e!==`all`&&H.createElement(Aht[e]||QQ,{className:`h-3 w-3`}),Pht[e]]},e))}),o.length===0?(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground text-center py-4`,children:`No activity recorded`}):(0,U.jsxs)(`div`,{className:`relative`,children:[(0,U.jsx)(`div`,{className:`absolute left-4 top-2 bottom-2 w-px bg-border`}),(0,U.jsx)(`div`,{className:`space-y-4`,children:o.map(e=>{let t=Aht[e.type]||QQ;return(0,U.jsxs)(`div`,{className:`flex gap-3 relative`,children:[(0,U.jsx)(`div`,{className:q(`shrink-0 h-8 w-8 rounded-full flex items-center justify-center z-10`,jht[e.type]||`bg-gray-100 text-gray-600`),children:(0,U.jsx)(t,{className:`h-3.5 w-3.5`})}),(0,U.jsxs)(`div`,{className:`flex-1 min-w-0 pt-1`,children:[(0,U.jsxs)(`p`,{className:`text-sm`,children:[(0,U.jsx)(`span`,{className:`font-medium`,children:e.user}),` `,(0,U.jsx)(`span`,{className:`text-muted-foreground`,children:Nht(e)})]}),(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:Mht(e.timestamp)})]})]},e.id)})})]})]})]})},Iht={create:`default`,update:`secondary`,delete:`destructive`,restore:`outline`,login:`outline`,logout:`outline`,permission_change:`secondary`,config_change:`secondary`,export:`outline`,import:`outline`};function q9(e){if(!e)return``;let t=e instanceof Date?e:new Date(e);return Number.isNaN(t.getTime())?String(e):t.toLocaleString()}var Lht=[[60,`second`],[60,`minute`],[24,`hour`],[7,`day`],[4.34524,`week`],[12,`month`],[1/0,`year`]];function Rht(e,t){if(!e)return``;let n=e instanceof Date?e:new Date(e);if(Number.isNaN(n.getTime()))return String(e);let r=(n.getTime()-Date.now())/1e3;for(let[n,i]of Lht){if(Math.abs(r)<n)try{return new Intl.RelativeTimeFormat(t,{numeric:`auto`}).format(Math.round(r),i)}catch{return q9(e)}r/=n}return q9(e)}function zht(e){if(!e)return`?`;let t=e.trim().split(/\s+/).filter(Boolean).slice(0,2);return t.length===0?`?`:t.map(e=>e.charAt(0).toUpperCase()).join(``)}function Bht(e){if(e==null||e===``)return`—`;if(typeof e==`string`)return e;if(typeof e==`number`||typeof e==`boolean`)return String(e);try{return JSON.stringify(e)}catch{return String(e)}}function Vht({entries:e,loading:t,emptyText:n,className:r,locale:i}){return t?(0,U.jsx)(`div`,{className:q(`space-y-3`,r),children:Array.from({length:4}).map((e,t)=>(0,U.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,U.jsx)(w5,{className:`h-8 w-8 rounded-full`}),(0,U.jsxs)(`div`,{className:`flex-1 space-y-2`,children:[(0,U.jsx)(w5,{className:`h-4 w-1/3`}),(0,U.jsx)(w5,{className:`h-3 w-1/2`})]})]},t))}):!e||e.length===0?(0,U.jsx)(`div`,{className:q(`flex items-center justify-center rounded-md border border-dashed py-10 text-sm text-muted-foreground`,r),children:n??`No history yet`}):(0,U.jsx)(P5,{delayDuration:150,children:(0,U.jsx)(`ol`,{className:q(`space-y-4`,r),children:e.map((e,t)=>{let n=Iht[(e.action??``).toLowerCase()]??`outline`,r=typeof e.user_name==`string`&&e.user_name.trim()||`Unknown user`,a=q9(e.created_at),o=Rht(e.created_at,i),s=typeof e.user_avatar==`string`?e.user_avatar:void 0;return(0,U.jsxs)(`li`,{className:`flex items-start gap-3`,children:[(0,U.jsxs)(S1,{className:`h-8 w-8 mt-0.5 shrink-0`,children:[s?(0,U.jsx)(C1,{src:s,alt:r}):null,(0,U.jsx)(w1,{className:`text-[10px] font-medium`,children:zht(e.user_name)})]}),(0,U.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,U.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-2 gap-y-1`,children:[(0,U.jsx)(`span`,{className:`text-sm font-medium text-foreground`,children:r}),e.action&&(0,U.jsx)(T1,{variant:n,className:`text-[10px] uppercase tracking-wide`,children:e.action}),a&&(0,U.jsxs)(F5,{children:[(0,U.jsx)(I5,{asChild:!0,children:(0,U.jsx)(`span`,{className:`text-xs text-muted-foreground cursor-help`,"aria-label":a,children:o||a})}),(0,U.jsx)(L5,{children:a})]})]}),e.summary&&(0,U.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:e.summary}),e.changes&&e.changes.length>0&&(0,U.jsx)(`ul`,{className:`mt-1.5 space-y-0.5 text-xs text-muted-foreground`,children:e.changes.map(e=>(0,U.jsxs)(`li`,{className:`leading-relaxed`,children:[(0,U.jsx)(`span`,{className:`font-medium text-foreground`,children:e.label||e.field}),`: `,(0,U.jsx)(`span`,{className:`line-through opacity-70`,children:Bht(e.from)}),` → `,(0,U.jsx)(`span`,{className:`text-foreground`,children:Bht(e.to)})]},e.field))})]})]},e.id??t)})})})}var J9={createdAt:`created_at`,createdBy:`created_by`,updatedAt:`updated_at`,updatedBy:`updated_by`};function Hht(e){if(!e)return null;if(e instanceof Date)return isNaN(e.getTime())?null:e;if(typeof e==`string`||typeof e==`number`){let t=new Date(e);return isNaN(t.getTime())?null:t}return null}function Uht(e,t){let n=Date.now()-e.getTime(),r=Math.max(0,Math.floor(n/1e3));if(r<60)return t(`detail.justNow`);let i=Math.floor(r/60);if(i<60)return t(`detail.minutesAgo`,{count:i});let a=Math.floor(i/60);return a<24?t(`detail.hoursAgo`,{count:a}):t(`detail.daysAgo`,{count:Math.floor(a/24)})}function Wht(e){try{return new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`short`}).format(e)}catch{return e.toISOString()}}var Ght=({value:e,objectSchema:t,fieldName:n})=>{if(e==null||e===``)return null;let r=t?.fields?.[n],i=r?.reference_to||r?.reference,a={name:n,type:r?.type||(i?`lookup`:`text`),...i&&{reference_to:i},...r?.reference_field&&{reference_field:r.reference_field}},o=B9(a)||a.type;if(o){let t=V9(o);if(t)return(0,U.jsx)(`span`,{className:`inline-flex items-center [&_a]:text-inherit [&_a]:hover:underline`,children:(0,U.jsx)(t,{value:e,field:a})})}return(0,U.jsx)(`span`,{children:String(e)})},Kht=({label:e,user:t,date:n,objectSchema:r,userField:i,t:a})=>{if(!t&&!n)return null;let o=n?(0,U.jsx)(P5,{delayDuration:200,children:(0,U.jsxs)(F5,{children:[(0,U.jsx)(I5,{asChild:!0,children:(0,U.jsx)(`time`,{dateTime:n.toISOString(),className:`cursor-default underline decoration-dotted decoration-muted-foreground/40 underline-offset-2`,children:Uht(n,a)})}),(0,U.jsx)(L5,{side:`top`,children:Wht(n)})]})}):null;return(0,U.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,U.jsx)(`span`,{className:`text-muted-foreground/70`,children:e}),t?(0,U.jsx)(Ght,{value:t,objectSchema:r,fieldName:i}):null,t&&o?(0,U.jsx)(`span`,{className:`text-muted-foreground/40`,children:`·`}):null,o]})},qht=({data:e,objectSchema:t,objectName:n,className:r})=>{let{t:i}=W9();if(!e)return null;let a=Hht(e[J9.createdAt]),o=Hht(e[J9.updatedAt]),s=e[J9.createdBy],c=e[J9.updatedBy],l=!!(a||s),u=a&&o&&Math.abs(o.getTime()-a.getTime())<2e3,d=!!(o||c)&&!(u&&(s!=null&&c!=null&&String(s)===String(c)||!c));return!l&&!d?null:(0,U.jsxs)(`div`,{className:q(`mt-6 pt-3 border-t border-border/40`,`flex flex-wrap items-center gap-x-4 gap-y-1`,`text-xs text-muted-foreground`,r),"data-testid":`record-meta-footer`,children:[l&&(0,U.jsx)(Kht,{label:i(`detail.createdBy`),user:s,date:a,objectSchema:t,userField:J9.createdBy,t:i}),d&&(0,U.jsx)(Kht,{label:i(`detail.updatedBy`),user:c,date:o,objectSchema:t,userField:J9.updatedBy,t:i})]})},Jht=5;function Yht(e,t,n,r){if(e&&typeof e==`object`){if(t.primaryField){let n=e[t.primaryField];if(n!=null&&n!==``)return String(n)}let r=n?.titleFormat,i=typeof r==`string`?r:r&&typeof r==`object`&&typeof r.source==`string`?r.source:void 0;if(i){let t=`[-\\u2013\\u2014|/·,:]`,n=!1,r=i.replace(/\{([^{}]+)\}/g,(t,r)=>{let i=String(r).trim().split(`.`),a=e;for(let e of i){if(a==null)break;a=a[e]}if(a&&typeof a==`object`){let e=a,t=e.name??e.full_name??e.display_name??e.label??e.title??e.subject??null;(t==null||typeof t==`string`&&!t.trim())&&(t=[e.salutation,e.first_name,e.last_name].filter(e=>typeof e==`string`&&e.trim()).map(e=>e.trim()).join(` `)||(typeof e.email==`string`&&e.email.trim()?e.email.trim():null)),a=t}return a!=null&&a!==``?(n=!0,String(a)):`\0`});if(n){let e=r.replace(RegExp(`\\s*${t}\\s*`,`g`),``).replace(RegExp(`\\s*${t}\\s*`,`g`),``).replace(RegExp(`\0`,`g`),``).replace(/\s+/g,` `).trim();if(e)return e}}}if(t.title)return t.title;if(e&&typeof e==`object`)for(let t of[`name`,`full_name`,`fullName`,`title`,`subject`,`label`,`display_name`,`displayName`]){let n=e[t];if(typeof n==`string`&&n.trim())return n.trim();if(n!=null&&n!==``)return String(n)}return r}var Y9=({schema:e,dataSource:t,className:n,onEdit:r,onDelete:i,onBack:a,inlineEdit:o=!1,onFieldSave:s,discussionSlot:c,rightRail:l,objectLabel:u,onDataLoaded:d})=>{let[f,p]=H.useState(e.data),[m,h]=H.useState(!e.data&&!!(e.api&&e.resourceId||t&&e.objectName&&e.resourceId)),[g,_]=H.useState(!1),[v,y]=H.useState(!1),[b,x]=H.useState({}),[C,w]=H.useState(null),[T,E]=H.useState(!1),{t:D}=W9(),{fieldOptionLabel:O}=Gn(),k=H9(),A=H.useMemo(()=>{if(!k?.isLoaded||!e.objectName)return e;let t=t=>k.checkField(e.objectName,t,`read`),n=e=>e&&e.filter(e=>{let n=typeof e==`string`?e:e?.name;return!n||t(n)});return{...e,fields:n(e.fields),sections:e.sections?.map(e=>({...e,fields:n(e.fields)})),summaryFields:n(e.summaryFields)}},[e,k]);H.useEffect(()=>{f&&d&&d(f)},[f,d]);let j=H.useMemo(()=>{if(A.summaryFields&&A.summaryFields.length>0)return[];let e=[...A.sections?.flatMap(e=>e.fields)||[],...A.fields||[]],t={};for(let n of e)t[n.name]||(t[n.name]=n);if(C?.fields)for(let[e,n]of Object.entries(C.fields))t[e]={...t[e]||{},...n,name:e};let n=e=>f?.[e]!==void 0&&f?.[e]!==null&&f?.[e]!==``,r=[],i=[`status`,`stage`,`state`,`phase`].find(e=>t[e]&&n(e))||Object.keys(t).find(e=>t[e]?.type===`select`&&n(e));i&&r.push(i);let a=Object.keys(t).find(e=>(t[e]?.type===`currency`||/amount|revenue|value|total|price/i.test(e))&&n(e));a&&!r.includes(a)&&r.push(a);let o=Object.keys(t).find(e=>(t[e]?.type===`date`||t[e]?.type===`datetime`)&&/close|due|start|end|expected/i.test(e)&&n(e));return o&&!r.includes(o)&&r.push(o),r},[A.summaryFields,A.sections,A.fields,C,f]),M=A.summaryFields&&A.summaryFields.length>0?A.summaryFields:j,N=H.useCallback(()=>{A.resourceId&&navigator.clipboard.writeText(String(A.resourceId)).then(()=>{E(!0),setTimeout(()=>E(!1),1500)})},[A.resourceId]);H.useEffect(()=>{let e=!0;if(A.data){p(A.data),h(!1);return}if(t&&A.objectName&&A.resourceId){h(!0),w(null),p(null);let n=A.objectName,r=A.resourceId,i=`${n}-`,a=[...A.sections?.flatMap(e=>e.fields)||[],...A.fields||[]];(t.getObjectSchema?t.getObjectSchema(n).catch(()=>null):Promise.resolve(null)).then(o=>{if(!e)return;w(o);let s=S(o?.fields,a),c=s.length>0?{$expand:s}:void 0,l=c?t.findOne(n,r,c):t.findOne(n,r),u=()=>{let a=String(r),o=a.startsWith(i)?a.slice(i.length):`${i}${a}`;return(c?t.findOne(n,o,c):t.findOne(n,o)).then(t=>{e&&(p(t),h(!1))}).catch(()=>{e&&(p(null),h(!1))})};return l.catch(()=>null).then(t=>{if(e){if(t){p(t),h(!1);return}return u()}})}).catch(t=>{e&&(console.error(`Failed to fetch detail data:`,t),h(!1))})}else A.api&&A.resourceId&&(h(!0),fetch(`${A.api}/${A.resourceId}`).then(e=>e.json()).then(t=>{e&&p(t?.data||t)}).catch(e=>{console.error(`Failed to fetch detail data:`,e)}).finally(()=>{e&&h(!1)}));return()=>{e=!1}},[A.api,A.resourceId,A.objectName,t,A.sections,A.fields]);let P=H.useCallback(()=>{if(a)a();else if(A.onNavigate){let e=A.backUrl||(A.objectName?`/${A.objectName}`:`/`);A.onNavigate(e,{replace:!0})}else A.backUrl?window.location.href=A.backUrl:window.history.back()},[a,A]),F=H.useCallback(()=>{r?r():A.onNavigate&&A.editUrl?A.onNavigate(A.editUrl):A.onNavigate&&A.objectName&&A.resourceId?A.onNavigate(`/${A.objectName}/${A.resourceId}/edit`):A.editUrl&&(window.location.href=A.editUrl)},[r,A]),I=H.useCallback(()=>{let e=A.deleteConfirmation||D(`detail.deleteConfirmation`);window.confirm(e)&&(i?.(),A.onNavigate&&A.objectName&&A.onNavigate(`/${A.objectName}`,{replace:!0}))},[i,A]),L=H.useCallback(()=>{navigator.share&&A.objectName&&A.resourceId?navigator.share({title:A.title||D(`detail.details`),text:`${A.objectName} #${A.resourceId}`,url:window.location.href}).catch(e=>console.log(`Share failed:`,e)):navigator.clipboard.writeText(window.location.href).then(()=>{console.log(`Link copied to clipboard`)})},[A]),ee=H.useCallback(()=>{_(!g)},[g]),te=H.useCallback(()=>{if(v){let e=Object.entries(b);if(e.length>0){let t={...f,...b};p(t),e.forEach(([e,n])=>{s?.(e,n,t)})}x({})}y(!v)},[v,b,f,s]),ne=H.useCallback(()=>{x({}),y(!1)},[]),R=H.useCallback((e,t)=>{x(n=>({...n,[e]:t}))},[]);H.useEffect(()=>{if(!A.recordNavigation)return;let e=A.recordNavigation,t=t=>{let n=t.target?.tagName;n===`INPUT`||n===`TEXTAREA`||t.target?.isContentEditable||(t.key===`ArrowLeft`&&e.currentIndex>0?(t.preventDefault(),e.onNavigate(e.recordIds[e.currentIndex-1])):t.key===`ArrowRight`&&e.currentIndex<e.recordIds.length-1&&(t.preventDefault(),e.onNavigate(e.recordIds[e.currentIndex+1])))};return document.addEventListener(`keydown`,t),()=>document.removeEventListener(`keydown`,t)},[A.recordNavigation]);let z=H.useMemo(()=>A.related??[],[A.related]),re=H.useMemo(()=>{let e=[];return e.push({name:`sys_share`,label:D(`detail.share`),icon:`share-2`,type:`script`,onClick:L}),A.showEdit&&e.push({name:`sys_edit_mobile`,label:D(`detail.edit`),icon:`edit`,type:`script`,className:`sm:hidden`,onClick:F}),o&&e.push({name:`sys_toggle_inline_edit_mobile`,label:D(v?`detail.save`:`detail.editInline`),icon:`edit`,type:`script`,className:`sm:hidden`,onClick:te}),A.showDelete&&e.push({name:`sys_delete`,label:D(`detail.delete`),icon:`trash-2`,type:`script`,variant:`destructive`,tags:[`separator-before`],onClick:I}),e},[D,A.showEdit,A.showDelete,o,v,L,F,te,I]),B=H.useMemo(()=>{let e=A.actions??[];if(re.length===0)return e;let t=!1,n=e.map(e=>{let n=e;if(n&&typeof n==`object`&&n.type===`action:bar`&&(!n.location||n.location===`record_header`)){t=!0;let e=Array.isArray(n.systemActions)?n.systemActions:[];return{...n,systemActions:[...e,...re]}}return e});return t||n.push({type:`action:bar`,location:`record_header`,systemActions:re}),n},[A.actions,re]);return m||A.loading?(0,U.jsxs)(`div`,{className:q(`space-y-4`,n),children:[(0,U.jsx)(w5,{className:`h-10 w-full`}),(0,U.jsx)(w5,{className:`h-64 w-full`}),(0,U.jsx)(w5,{className:`h-48 w-full`})]}):!f&&!A.data?(0,U.jsxs)(`div`,{className:q(`flex flex-col items-center justify-center py-16 text-center`,n),children:[(0,U.jsx)(`p`,{className:`text-lg font-semibold`,children:D(`detail.recordNotFound`)}),(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:D(`detail.recordNotFoundDescription`)}),(A.showBack??!0)&&(0,U.jsxs)(Q,{variant:`outline`,size:`sm`,onClick:P,className:`mt-4 gap-2`,children:[(0,U.jsx)(Eu,{className:`h-4 w-4`}),D(`detail.goBack`)]})]}):(0,U.jsx)(P5,{children:(0,U.jsxs)(`div`,{className:q(`space-y-6`,n),children:[A.showHeader!==!1&&(0,U.jsxs)(`div`,{className:`flex flex-col sm:flex-row items-start justify-between gap-3 sm:gap-4 pb-4 border-b`,children:[(0,U.jsxs)(`div`,{className:`flex items-start gap-2 sm:gap-3 flex-1 min-w-0`,children:[(A.showBack??!0)&&(0,U.jsxs)(F5,{children:[(0,U.jsx)(I5,{asChild:!0,children:(0,U.jsx)(Q,{variant:`ghost`,size:`icon`,onClick:P,className:`shrink-0 mt-1`,children:(0,U.jsx)(Eu,{className:`h-4 w-4`})})}),(0,U.jsx)(L5,{children:D(`detail.back`)})]}),(0,U.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,U.jsx)(`h1`,{className:`text-xl sm:text-2xl font-bold truncate`,children:Yht(f,A,C,D(`detail.details`))}),M.map(e=>{let t=f?.[e];if(t==null||t===``)return null;let n=(A.sections||[]).flatMap(e=>e.fields).concat(A.fields||[]).find(t=>t.name===e),r=C?.fields?.[e],i=n?.type||r?.type,a=String(t),o=null;try{if(i===`currency`){let e=Number(t);Number.isNaN(e)||(a=new Intl.NumberFormat(void 0,{style:`currency`,currency:n?.currency||r?.currency||`USD`,maximumFractionDigits:0}).format(e))}else if(i===`date`||i===`datetime`){let e=new Date(t);Number.isNaN(e.getTime())||(a=i===`datetime`?e.toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`}):e.toLocaleDateString(void 0,{dateStyle:`medium`}))}else if(i===`percent`){let e=Number(t);if(!Number.isNaN(e)){a=`${e}%`;let t=e<=1?e*100:e;o=Math.max(0,Math.min(100,t))}}else if(i===`select`||i===`status`||i===`multiselect`){let i=n?.options||r?.options,o=String(t);if(Array.isArray(i)){let e=i.find(e=>String(e?.value??e)===String(t));e?.label&&(o=e.label)}else if(i&&typeof i==`object`){let e=i[String(t)];e?.label&&(o=e.label)}a=A.objectName?O(A.objectName,e,String(t),o):o}}catch{}return o===null?(0,U.jsx)(T1,{variant:`secondary`,className:`text-xs bg-primary/10 text-primary border-transparent hover:bg-primary/15`,"aria-label":`${e}: ${a}`,children:a},e):(0,U.jsxs)(T1,{variant:`secondary`,className:`text-xs bg-primary/10 text-primary border-transparent hover:bg-primary/15 gap-1.5 pl-2 pr-2`,"aria-label":`${e}: ${a}`,children:[(0,U.jsx)(`span`,{className:`relative inline-block h-1.5 w-12 rounded-full bg-primary/20 overflow-hidden`,"aria-hidden":!0,children:(0,U.jsx)(`span`,{className:`absolute inset-y-0 left-0 rounded-full bg-primary`,style:{width:`${o}%`}})}),a]},e)}),(0,U.jsxs)(F5,{children:[(0,U.jsx)(I5,{asChild:!0,children:(0,U.jsx)(Q,{variant:`ghost`,size:`icon`,className:`h-6 w-6 shrink-0`,onClick:ee,"aria-label":D(g?`detail.removeFromFavorites`:`detail.addToFavorites`),children:g?(0,U.jsx)($Q,{className:`h-4 w-4 fill-yellow-400 text-yellow-400`}):(0,U.jsx)($Q,{className:`h-4 w-4 text-muted-foreground`})})}),(0,U.jsx)(L5,{children:D(g?`detail.removeFromFavorites`:`detail.addToFavorites`)})]})]}),A.objectName&&(0,U.jsxs)(`p`,{className:`text-sm text-muted-foreground mt-1 flex items-center gap-1`,children:[(0,U.jsx)(`span`,{className:`font-medium`,children:u||A.objectName}),A.resourceId&&(0,U.jsxs)(F5,{children:[(0,U.jsx)(I5,{asChild:!0,children:(0,U.jsx)(Q,{variant:`ghost`,size:`icon`,className:`h-5 w-5 shrink-0 text-muted-foreground/60 hover:text-foreground`,onClick:N,"aria-label":D(`detail.copyRecordId`,{defaultValue:`Copy record ID`}),children:T?(0,U.jsx)(Yp,{className:`h-3 w-3 text-green-600`}):(0,U.jsx)(ab,{className:`h-3 w-3`})})}),(0,U.jsx)(L5,{children:T?D(`detail.copied`,{defaultValue:`Copied`}):D(`detail.copyRecordId`,{defaultValue:`Copy record ID`})})]})]})]})]}),(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 shrink-0 w-full sm:w-auto`,children:[A.recordNavigation&&(0,U.jsxs)(`div`,{className:`flex items-center gap-1 mr-2`,children:[(0,U.jsxs)(F5,{children:[(0,U.jsx)(I5,{asChild:!0,children:(0,U.jsx)(Q,{variant:`outline`,size:`icon`,className:`h-8 w-8`,disabled:A.recordNavigation.currentIndex<=0,onClick:()=>{let e=A.recordNavigation;e.currentIndex>0&&e.onNavigate(e.recordIds[e.currentIndex-1])},children:(0,U.jsx)(Zp,{className:`h-4 w-4`})})}),(0,U.jsx)(L5,{children:D(`detail.previousRecord`)})]}),(0,U.jsx)(`span`,{className:`text-xs text-muted-foreground whitespace-nowrap px-1`,children:D(`detail.recordOf`,{current:A.recordNavigation.currentIndex+1,total:A.recordNavigation.recordIds.length})}),(0,U.jsxs)(F5,{children:[(0,U.jsx)(I5,{asChild:!0,children:(0,U.jsx)(Q,{variant:`outline`,size:`icon`,className:`h-8 w-8`,disabled:A.recordNavigation.currentIndex>=A.recordNavigation.recordIds.length-1,onClick:()=>{let e=A.recordNavigation;e.currentIndex<e.recordIds.length-1&&e.onNavigate(e.recordIds[e.currentIndex+1])},children:(0,U.jsx)(Qp,{className:`h-4 w-4`})})}),(0,U.jsx)(L5,{children:D(`detail.nextRecord`)})]})]}),o&&(0,U.jsxs)(U.Fragment,{children:[v&&(0,U.jsxs)(F5,{children:[(0,U.jsx)(I5,{asChild:!0,children:(0,U.jsxs)(Q,{variant:`ghost`,size:`sm`,onClick:ne,className:`gap-2 hidden sm:inline-flex`,children:[(0,U.jsx)(c$,{className:`h-4 w-4`}),(0,U.jsx)(`span`,{className:`hidden sm:inline`,children:D(`detail.cancel`)})]})}),(0,U.jsx)(L5,{children:D(`detail.cancelEdit`)})]}),(0,U.jsxs)(F5,{children:[(0,U.jsx)(I5,{asChild:!0,children:(0,U.jsx)(Q,{variant:v?`default`:`outline`,size:`sm`,onClick:te,className:`gap-2 hidden sm:inline-flex`,children:v?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(Yp,{className:`h-4 w-4`}),(0,U.jsx)(`span`,{className:`hidden sm:inline`,children:D(`detail.save`)})]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(QQ,{className:`h-4 w-4`}),(0,U.jsx)(`span`,{className:`hidden sm:inline`,children:D(`detail.editInline`)})]})})}),(0,U.jsx)(L5,{children:D(v?`detail.saveChanges`:`detail.editFieldsInline`)})]})]}),A.showEdit&&(0,U.jsxs)(F5,{children:[(0,U.jsx)(I5,{asChild:!0,children:(0,U.jsxs)(Q,{variant:`default`,onClick:F,className:`gap-2 hidden sm:inline-flex`,children:[(0,U.jsx)(QQ,{className:`h-4 w-4`}),(0,U.jsx)(`span`,{className:`hidden sm:inline`,children:D(`detail.edit`)})]})}),(0,U.jsx)(L5,{children:D(`detail.editRecord`)})]}),B.map((e,t)=>(0,U.jsx)(Se,{schema:e,data:f},`header-action-${t}`))]})]}),A.header&&(0,U.jsx)(`div`,{children:(0,U.jsx)(Se,{schema:A.header,data:f})}),A.highlightFields&&A.highlightFields.length>0&&(0,U.jsx)(Dht,{fields:A.highlightFields,data:f,objectName:A.objectName,objectSchema:C}),A.autoTabs&&!A.tabs?.length?(()=>{let e=z.length>0,n=!!A.activities&&A.activities.length>0,r=!!c,i=!!A.history,a=(0,U.jsxs)(`div`,{className:`space-y-3 sm:space-y-4`,children:[A.sectionGroups&&A.sectionGroups.length>0&&A.sectionGroups.map((e,t)=>(0,U.jsx)(Eht,{group:e,data:{...f,...b},objectSchema:C,objectName:A.objectName,isEditing:v,onFieldChange:R},t)),A.sections&&A.sections.length>0&&A.sections.map((e,t)=>(0,U.jsx)(G9,{section:e,data:{...f,...b},objectSchema:C,objectName:A.objectName,isEditing:v,onFieldChange:R},t)),A.fields&&A.fields.length>0&&!A.sections?.length&&(0,U.jsx)(G9,{section:{fields:A.fields,columns:A.columns},data:{...f,...b},objectSchema:C,objectName:A.objectName,isEditing:v,onFieldChange:R}),A.comments&&(0,U.jsx)(kht,{comments:A.comments,onAddComment:A.onAddComment})]});return!e&&!n&&!r&&!i?(0,U.jsx)(`div`,{className:`mt-2`,children:a}):(0,U.jsxs)(l7,{defaultValue:`details`,className:`w-full`,children:[(0,U.jsxs)(u7,{className:`w-full justify-start border-b rounded-none bg-transparent p-0`,children:[(0,U.jsx)(d7,{value:`details`,className:`relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent`,children:D(`detail.details`)}),e&&(0,U.jsx)(d7,{value:`related`,className:`relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent`,children:(0,U.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[D(`detail.related`),(0,U.jsx)(T1,{variant:`secondary`,className:`text-xs bg-primary/10 text-primary border-transparent`,children:z.length})]})}),n&&(0,U.jsx)(d7,{value:`activity`,className:`relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent`,children:(0,U.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[D(`detail.activity`),(0,U.jsx)(T1,{variant:`secondary`,className:`text-xs bg-primary/10 text-primary border-transparent`,children:A.activities.length})]})}),r&&(0,U.jsx)(d7,{value:`discussion`,className:`relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent`,children:D(`detail.discussion`,{defaultValue:`Discussion`})}),i&&(0,U.jsx)(d7,{value:`history`,className:`relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent`,children:(0,U.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[D(`detail.history`,{defaultValue:`History`}),!A.history.loading&&A.history.entries.length>0&&(0,U.jsx)(T1,{variant:`secondary`,className:`text-xs bg-primary/10 text-primary border-transparent`,children:A.history.entries.length})]})})]}),(0,U.jsx)(f7,{value:`details`,className:`mt-4`,children:a}),e&&(0,U.jsx)(f7,{value:`related`,className:`mt-4`,children:(0,U.jsx)(`div`,{className:`space-y-3`,children:z.map((e,n)=>(0,U.jsx)(K9,{title:e.title,type:e.type,api:e.api,data:e.data,columns:e.columns,dataSource:t,objectName:e.api,referenceField:e.referenceField,icon:e.icon,onNew:e.onNew,onViewAll:e.onViewAll,onRowClick:e.onRowClick,onRowEdit:e.onRowEdit,onRowDelete:e.onRowDelete,collapsible:!0,pageSize:Jht},n))})}),n&&(0,U.jsx)(f7,{value:`activity`,className:`mt-4`,children:(0,U.jsx)(Fht,{activities:A.activities})}),r&&(0,U.jsx)(f7,{value:`discussion`,className:`mt-4`,children:c}),i&&(0,U.jsx)(f7,{value:`history`,className:`mt-4`,children:(0,U.jsx)(Vht,{entries:A.history.entries,loading:A.history.loading,emptyText:A.history.emptyText??D(`detail.historyEmpty`,{defaultValue:`No history yet`})})})]})})():(0,U.jsxs)(U.Fragment,{children:[A.sectionGroups&&A.sectionGroups.length>0&&(0,U.jsx)(`div`,{className:`space-y-3 sm:space-y-4`,children:A.sectionGroups.map((e,t)=>(0,U.jsx)(Eht,{group:e,data:{...f,...b},objectSchema:C,objectName:A.objectName,isEditing:v,onFieldChange:R},t))}),A.sections&&A.sections.length>0&&(0,U.jsx)(`div`,{className:`space-y-3 sm:space-y-4`,children:A.sections.map((e,t)=>(0,U.jsx)(G9,{section:e,data:{...f,...b},objectSchema:C,objectName:A.objectName,isEditing:v,onFieldChange:R},t))}),A.fields&&A.fields.length>0&&!A.sections?.length&&(0,U.jsx)(G9,{section:{fields:A.fields,columns:A.columns},data:{...f,...b},objectSchema:C,objectName:A.objectName,isEditing:v,onFieldChange:R}),A.tabs&&A.tabs.length>0&&(0,U.jsx)(wht,{tabs:A.tabs,data:f}),z.length>0&&(0,U.jsxs)(`div`,{className:`space-y-3`,children:[(0,U.jsx)(`h2`,{className:`text-lg font-semibold`,children:D(`detail.related`)}),z.map((e,n)=>(0,U.jsx)(K9,{title:e.title,type:e.type,api:e.api,data:e.data,columns:e.columns,dataSource:t,objectName:e.api,referenceField:e.referenceField,icon:e.icon,onNew:e.onNew,onViewAll:e.onViewAll,onRowClick:e.onRowClick,onRowEdit:e.onRowEdit,onRowDelete:e.onRowDelete,collapsible:!0,pageSize:Jht},n))]}),A.comments&&(0,U.jsx)(kht,{comments:A.comments,onAddComment:A.onAddComment}),A.activities&&A.activities.length>0&&(0,U.jsx)(Fht,{activities:A.activities})]}),(0,U.jsx)(qht,{data:{...f,...b},objectSchema:C,objectName:A.objectName}),A.footer&&(0,U.jsx)(`div`,{children:(0,U.jsx)(Se,{schema:A.footer,data:f})})]})})},Xht=e=>typeof e==`string`?e:e&&typeof e==`object`&&(e.field||e.name)||null,Zht=e=>{let{"data-obj-id":t,"data-obj-type":n,style:r,...i}=e||{};return{designer:{"data-obj-id":t,"data-obj-type":n,style:r},rest:i}},Qht=({schema:e={},className:t,...n})=>{let r=He(),{designer:i}=Zht(n);if(!r)return(0,U.jsx)(`div`,{className:t,"data-record-details-placeholder":!0,...i,children:(0,U.jsx)(`div`,{className:`text-xs text-muted-foreground italic px-3 py-2 border border-dashed rounded`,children:`record:details — bind a record to preview`})});let a=e.layout===`inline`||e.layout===`compact`?`horizontal`:`vertical`,o=r.objectName||``,s=H9(),{readableFields:c}=U9(o),l=Array.isArray(e.requiredPermissions)?e.requiredPermissions:[];if(l.length>0&&o&&!l.every(e=>s.can(o,e)))return(0,U.jsx)(`div`,{className:t,...i,role:`status`,"aria-live":`polite`,children:(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground italic`,children:`Insufficient permissions to view details.`})});let u=e.enforceFieldSecurity===!0,d=Array.isArray(e.redactFields)?e.redactFields:[],f=e=>{if(!e||!u&&d.length===0)return e;let t=e.map(Xht).filter(e=>!!e),n=new Set((u&&o?c(t):t).filter(e=>!d.includes(e)));return e.filter(e=>{let t=Xht(e);return t?n.has(t):!0})},p=e=>typeof e==`string`?{name:e}:e&&typeof e==`object`&&!e.name&&e.field?{...e,name:e.field}:e,m=e=>Array.isArray(e)?e.map(p):e,h=m(f(e.fields)),g=Array.isArray(e.sections)?e.sections.map(e=>({...e,title:e.title??e.label,fields:m(f(e.fields))})):e.sections,_={type:`detail-view`,objectName:r.objectName,resourceId:r.recordId,data:r.data,layout:a,columns:e.columns,sections:g,fields:h,showBack:!1,showHeader:e.showHeader??!1};return(0,U.jsx)(`div`,{className:t,...i,children:(0,U.jsx)(Y9,{schema:_,dataSource:r.dataSource})})},$ht=e=>typeof e==`string`?e:e&&typeof e==`object`&&(e.field||e.name||e.key)||null,egt=e=>{let{"data-obj-id":t,"data-obj-type":n,style:r,...i}=e||{};return{designer:{"data-obj-id":t,"data-obj-type":n,style:r},rest:i}},tgt=({schema:e={},className:t,...n})=>{let r=He(),{designer:i}=egt(n),a=e.title||e.objectName||`Related`,o=e.objectName;if(!o)return(0,U.jsx)(`div`,{className:t,...i,children:(0,U.jsx)(`div`,{className:`text-xs text-muted-foreground italic px-3 py-2 border border-dashed rounded`,children:`record:related_list — missing objectName`})});let s=H9(),{readableFields:c}=U9(o),l=Array.isArray(e.requiredPermissions)?e.requiredPermissions:[];if(l.length>0&&!l.every(e=>s.can(o,e)))return(0,U.jsx)(`div`,{className:t,...i,role:`status`,"aria-live":`polite`,children:(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground italic`,children:`Insufficient permissions to view related list.`})});let u=e.enforceFieldSecurity===!0,d=Array.isArray(e.redactFields)?e.redactFields:[],f=Array.isArray(e.columns)?e.columns:[],p=f;if(u||d.length>0){let e=f.map($ht).filter(e=>!!e),t=new Set((u?c(e):e).filter(e=>!d.includes(e)));p=f.filter(e=>{let n=$ht(e);return n?t.has(n):!0})}return(0,U.jsx)(`div`,{className:t,...i,children:(0,U.jsx)(K9,{title:a,type:`table`,api:o,objectName:o,referenceField:e.relationshipField,columns:p,pageSize:e.limit,dataSource:r?.dataSource})})},ngt=e=>{let{"data-obj-id":t,"data-obj-type":n,style:r,...i}=e||{};return{designer:{"data-obj-id":t,"data-obj-type":n,style:r},rest:i}},rgt=({schema:e={},className:t,...n})=>{let r=He(),{designer:i}=ngt(n),a=r?.objectName||``,o=H9(),{readableFields:s}=U9(a),c=Array.isArray(e.requiredPermissions)?e.requiredPermissions:[];if(c.length>0&&a&&!c.every(e=>o.can(a,e)))return(0,U.jsx)(`div`,{className:t,...i,role:`status`,"aria-live":`polite`,children:(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground italic`,children:`Insufficient permissions to view highlights.`})});let l=(Array.isArray(e.fields)?e.fields:[]).map(e=>typeof e==`string`?{name:e}:{name:e?.name,label:e?.label,icon:e?.icon,type:e?.type}).filter(e=>typeof e.name==`string`&&e.name.length>0),u=e.enforceFieldSecurity===!0,d=Array.isArray(e.redactFields)?e.redactFields:[],f=u&&a?new Set(s(l.map(e=>e.name))):null,p=l.filter(e=>!(d.includes(e.name)||f&&!f.has(e.name)));return(0,U.jsx)(`div`,{className:t,...i,children:(0,U.jsx)(Dht,{fields:p,data:r?.data,objectName:r?.objectName,objectSchema:r?.objectSchema})})},igt=({change:e,className:t})=>{let n=e.fieldLabel??e.field.charAt(0).toUpperCase()+e.field.slice(1).replace(/_/g,` `),r=e.oldDisplayValue??(e.oldValue==null?`(empty)`:String(e.oldValue)),i=e.newDisplayValue??(e.newValue==null?`(empty)`:String(e.newValue));return(0,U.jsxs)(`div`,{className:q(`flex items-center gap-1.5 text-sm flex-wrap`,t),children:[(0,U.jsx)(`span`,{className:`font-medium text-foreground`,children:n}),(0,U.jsx)(`span`,{className:`text-muted-foreground line-through`,children:r}),(0,U.jsx)(Ru,{className:`h-3 w-3 text-muted-foreground shrink-0`}),(0,U.jsx)(`span`,{className:`text-foreground`,children:i})]})},agt=[`👍`,`❤️`,`🎉`,`😂`,`😮`,`😢`],ogt=({reactions:e,onToggleReaction:t,emojiOptions:n=agt,className:r})=>{let[i,a]=H.useState(!1),o=H.useCallback(e=>{t?.(e),a(!1)},[t]);return(0,U.jsxs)(`div`,{className:q(`flex items-center gap-1 flex-wrap`,r),children:[e.map(e=>(0,U.jsxs)(`button`,{type:`button`,className:q(`inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-xs border transition-colors`,e.reacted?`bg-primary/10 border-primary/30 text-primary`:`bg-muted border-border text-muted-foreground hover:bg-muted/80`),onClick:()=>o(e.emoji),disabled:!t,"aria-label":`${e.emoji} ${e.count} reaction${e.count===1?``:`s`}`,children:[(0,U.jsx)(`span`,{children:e.emoji}),(0,U.jsx)(`span`,{children:e.count})]},e.emoji)),t&&(0,U.jsxs)(`div`,{className:`relative`,children:[(0,U.jsx)(Q,{variant:`ghost`,size:`icon`,className:`h-6 w-6`,onClick:()=>a(!i),"aria-label":`Add reaction`,children:(0,U.jsx)(KQ,{className:`h-3.5 w-3.5`})}),i&&(0,U.jsx)(`div`,{className:`absolute bottom-full mb-1 left-0 bg-popover border rounded-md shadow-md z-50 p-1.5 flex gap-1`,role:`listbox`,"aria-label":`Emoji picker`,children:n.map(t=>(0,U.jsx)(`button`,{type:`button`,className:`hover:bg-accent rounded p-1 text-base transition-colors`,onClick:()=>o(t),role:`option`,"aria-selected":e.some(e=>e.emoji===t&&e.reacted),children:t},t))})]})]})};function sgt(e){try{let t=new Date(e),n=new Date().getTime()-t.getTime(),r=Math.floor(n/6e4);if(r<1)return`just now`;if(r<60)return`${r}m ago`;let i=Math.floor(r/60);if(i<24)return`${i}h ago`;let a=Math.floor(i/24);return a<7?`${a}d ago`:t.toLocaleDateString()}catch{return e}}var cgt=({parentItem:e,replies:t,onAddReply:n,showReplyInput:r=!0,className:i})=>{let{t:a}=W9(),[o,s]=H.useState(!1),[c,l]=H.useState(``),[u,d]=H.useState(!1),f=H.useCallback(async()=>{let t=c.trim();if(!(!t||!n)){d(!0);try{await n(e.id,t),l(``)}finally{d(!1)}}},[c,n,e.id]),p=H.useCallback(e=>{e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),f())},[f]);return t.length===0&&!r?null:(0,U.jsxs)(`div`,{className:q(`ml-10 mt-1`,i),children:[t.length>0&&(0,U.jsxs)(`button`,{type:`button`,className:`flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors mb-1`,onClick:()=>s(!o),"aria-expanded":o,children:[(0,U.jsx)(o?Xp:Qp,{className:`h-3 w-3`}),(0,U.jsx)(nB,{className:`h-3 w-3`}),(0,U.jsx)(`span`,{children:t.length===1?a(`detail.replyCount`,{count:t.length}):a(`detail.replyCountPlural`,{count:t.length})})]}),o&&(0,U.jsx)(`div`,{className:`space-y-2 border-l-2 border-border pl-3`,children:t.map(e=>(0,U.jsxs)(`div`,{className:`flex gap-2`,children:[(0,U.jsx)(`div`,{className:`shrink-0`,children:e.actorAvatarUrl?(0,U.jsx)(`img`,{src:e.actorAvatarUrl,alt:e.actor,className:`h-6 w-6 rounded-full object-cover`}):(0,U.jsx)(`div`,{className:`h-6 w-6 rounded-full bg-muted flex items-center justify-center text-[10px] font-medium text-muted-foreground`,children:e.actor.charAt(0).toUpperCase()})}),(0,U.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,U.jsx)(`span`,{className:`text-xs font-medium`,children:e.actor}),(0,U.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:sgt(e.createdAt)})]}),(0,U.jsx)(`p`,{className:`text-xs whitespace-pre-wrap break-words`,children:e.body})]})]},e.id))}),r&&n&&(0,U.jsxs)(`div`,{className:`flex gap-1.5 mt-1.5`,children:[(0,U.jsx)(`input`,{className:`flex-1 rounded-md border border-input bg-background px-2 py-1 text-xs placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring`,placeholder:a(`detail.replyPlaceholder`),value:c,onChange:e=>l(e.target.value),onKeyDown:p,disabled:u}),(0,U.jsx)(Q,{variant:`ghost`,size:`icon`,className:`h-6 w-6 shrink-0`,onClick:f,disabled:!c.trim()||u,"aria-label":`Send reply`,children:(0,U.jsx)(DZ,{className:`h-3 w-3`})})]})]})},lgt=({subscription:e,onToggle:t,className:n})=>{let{t:r}=W9(),[i,a]=H.useState(!1),o=H.useCallback(async()=>{if(t){a(!0);try{await t(!e.subscribed)}finally{a(!1)}}},[t,e.subscribed]);return(0,U.jsx)(Q,{variant:`ghost`,size:`icon`,className:q(`h-8 w-8`,n),onClick:o,disabled:i||!t,"aria-label":e.subscribed?r(`detail.unsubscribeAriaLabel`):r(`detail.subscribeAriaLabel`),title:e.subscribed?r(`detail.subscribedTooltip`):r(`detail.unsubscribedTooltip`),children:e.subscribed?(0,U.jsx)(Gp,{className:`h-4 w-4 text-primary`}):(0,U.jsx)(Wp,{className:`h-4 w-4 text-muted-foreground`})})},ugt={comment:nB,field_change:QQ,task:YQ,event:qp,system:l$,email:HL,call:WG},dgt={comment:`bg-purple-100 text-purple-600`,field_change:`bg-blue-100 text-blue-600`,task:`bg-green-100 text-green-600`,event:`bg-amber-100 text-amber-600`,system:`bg-gray-100 text-gray-600`,email:`bg-indigo-100 text-indigo-600`,call:`bg-teal-100 text-teal-600`};function fgt(e){return[{value:`all`,label:e(`detail.allActivity`)},{value:`comments_only`,label:e(`detail.commentsOnly`)},{value:`changes_only`,label:e(`detail.fieldChangesFilter`)},{value:`tasks_only`,label:e(`detail.tasksOnly`)}]}function pgt(e){try{let t=new Date(e),n=new Date().getTime()-t.getTime(),r=Math.floor(n/6e4);if(r<1)return`just now`;if(r<60)return`${r}m ago`;let i=Math.floor(r/60);if(i<24)return`${i}h ago`;let a=Math.floor(i/24);return a<7?`${a}d ago`:t.toLocaleDateString()}catch{return e}}function mgt(e,t){switch(t){case`comments_only`:return e.filter(e=>e.type===`comment`);case`changes_only`:return e.filter(e=>e.type===`field_change`);case`tasks_only`:return e.filter(e=>e.type===`task`);default:return e}}var X9=({items:e,config:t,filterMode:n,onFilterChange:r,hasMore:i=!1,onLoadMore:a,loading:o=!1,onAddComment:s,onAddReply:c,onToggleReaction:l,subscription:u,onToggleSubscription:d,collapseWhenEmpty:f=!1,titleLabel:p,emptyLabel:m,className:h})=>{let{t:g}=W9(),[_,v]=H.useState(`all`),[y,b]=H.useState(``),[x,S]=H.useState(!1),[C,w]=H.useState(!1),T=n??_,E=t?.showFilterToggle!==!1,D=t?.showCommentInput!==!1&&!!s,O=t?.enableReactions??!1,k=t?.enableThreading??!1,A=t?.showSubscriptionToggle??!1,j=H.useMemo(()=>mgt(e,T),[e,T]),M=H.useMemo(()=>k?j.filter(e=>!e.parentId):j,[j,k]),N=H.useMemo(()=>{if(!k)return new Map;let e=new Map;for(let t of j)if(t.parentId){let n=e.get(t.parentId)??[];n.push(t),e.set(t.parentId,n)}return e},[j,k]),P=H.useCallback(e=>{r?r(e):v(e)},[r]),F=H.useCallback(async()=>{let e=y.trim();if(!(!e||!s)){S(!0);try{await s(e),b(``)}finally{S(!1)}}},[y,s]),I=H.useCallback(e=>{e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),F())},[F]),L=H.useCallback(async()=>{if(a){w(!0);try{await a()}finally{w(!1)}}},[a]);return(0,U.jsxs)(E0,{className:q(``,h),children:[(0,U.jsx)(D0,{children:(0,U.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,U.jsxs)(O0,{className:`flex items-center gap-2 text-base`,children:[(0,U.jsx)(Co,{className:`h-4 w-4`}),p??g(`detail.activity`),(0,U.jsxs)(`span`,{className:`text-sm font-normal text-muted-foreground`,children:[`(`,j.length,`)`]})]}),(0,U.jsx)(`div`,{className:`flex items-center gap-1`,children:A&&u&&(0,U.jsx)(lgt,{subscription:u,onToggle:d})})]})}),(0,U.jsxs)(A0,{className:`space-y-4`,children:[E&&(0,U.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,U.jsx)(`select`,{className:`rounded-md border border-input bg-background px-2.5 py-1.5 text-sm focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring`,value:T,onChange:e=>P(e.target.value),"aria-label":g(`detail.filterActivity`),children:fgt(g).map(e=>(0,U.jsx)(`option`,{value:e.value,children:e.label},e.value))})}),D&&(0,U.jsxs)(`div`,{className:`flex gap-2`,children:[(0,U.jsx)(`textarea`,{className:`flex-1 min-h-[60px] rounded-md border border-input bg-background px-3 py-2 text-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring resize-none`,placeholder:g(`detail.leaveCommentPlaceholder`),value:y,onChange:e=>b(e.target.value),onKeyDown:I,disabled:x}),(0,U.jsxs)(Q,{variant:`default`,onClick:F,disabled:!y.trim()||x,className:`shrink-0 self-end gap-1.5`,"aria-label":g(`detail.submitComment`),title:g(`detail.submitComment`),children:[(0,U.jsx)(DZ,{className:`h-4 w-4`}),(0,U.jsx)(`span`,{children:g(`detail.sendComment`)})]})]}),j.length===0?f?null:(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground text-center py-4`,children:m??g(`detail.noActivity`)}):(0,U.jsxs)(`div`,{className:`relative`,children:[(0,U.jsx)(`div`,{className:`absolute left-4 top-2 bottom-2 w-px bg-border`}),(0,U.jsx)(`div`,{className:`space-y-4`,children:M.map(e=>{let t=ugt[e.type]||l$,n=dgt[e.type]||`bg-gray-100 text-gray-600`,r=N.get(e.id)??[];return(0,U.jsxs)(`div`,{children:[(0,U.jsxs)(`div`,{className:`flex gap-3 relative`,children:[(0,U.jsx)(`div`,{className:q(`shrink-0 h-8 w-8 rounded-full flex items-center justify-center z-10`,n),children:e.actorAvatarUrl?(0,U.jsx)(`img`,{src:e.actorAvatarUrl,alt:e.actor,className:`h-8 w-8 rounded-full object-cover`}):(0,U.jsx)(t,{className:`h-3.5 w-3.5`})}),(0,U.jsxs)(`div`,{className:`flex-1 min-w-0 pt-1`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2 mb-0.5`,children:[(0,U.jsx)(`span`,{className:`text-sm font-medium`,children:e.actor}),e.source&&(0,U.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:g(`detail.via`,{source:e.source})}),(0,U.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:pgt(e.createdAt)}),e.edited&&(0,U.jsx)(`span`,{className:`text-xs text-muted-foreground italic`,children:g(`detail.edited`)}),e.pinned&&(0,U.jsxs)(`span`,{className:`text-xs text-amber-600`,children:[`📌 `,g(`detail.pinned`)]})]}),e.body&&(0,U.jsx)(`p`,{className:`text-sm whitespace-pre-wrap break-words text-muted-foreground`,children:e.body}),e.type===`field_change`&&e.fieldChanges&&(0,U.jsx)(`div`,{className:`space-y-1 mt-1`,children:e.fieldChanges.map((e,t)=>(0,U.jsx)(igt,{change:e},t))}),O&&e.reactions&&e.reactions.length>0&&(0,U.jsx)(`div`,{className:`mt-1.5`,children:(0,U.jsx)(ogt,{reactions:e.reactions,onToggleReaction:l?t=>l(e.id,t):void 0})}),O&&(!e.reactions||e.reactions.length===0)&&l&&(0,U.jsx)(`div`,{className:`mt-1.5`,children:(0,U.jsx)(ogt,{reactions:[],onToggleReaction:t=>l(e.id,t)})})]})]}),k&&(e.replyCount??0)>0&&(0,U.jsx)(cgt,{parentItem:e,replies:r,onAddReply:c,showReplyInput:!!c})]},e.id)})})]}),i&&(0,U.jsx)(`div`,{className:`text-center pt-2`,children:(0,U.jsxs)(Q,{variant:`ghost`,size:`sm`,onClick:L,disabled:C,"aria-label":g(`detail.loadMore`),children:[C?(0,U.jsx)(GI,{className:`h-4 w-4 animate-spin mr-1`}):(0,U.jsx)(Xp,{className:`h-4 w-4 mr-1`}),g(`detail.loadMore`)]})})]})]})},hgt=e=>{let{"data-obj-id":t,"data-obj-type":n,style:r,...i}=e||{};return{designer:{"data-obj-id":t,"data-obj-type":n,style:r},rest:i}},ggt=({schema:e={},className:t,...n})=>{He();let{designer:r}=hgt(n);return(0,U.jsx)(`div`,{className:t,...r,children:(0,U.jsx)(X9,{items:[],config:e})})},_gt=({config:e,items:t,hasMore:n,onLoadMore:r,loading:i,onAddComment:a,onAddReply:o,onToggleReaction:s,subscription:c,onToggleSubscription:l,filterMode:u,onFilterChange:d,collapseWhenEmpty:f=!1,className:p})=>{let m=e?.position??`right`,h=e?.width??`360px`,g=e?.collapsible??!0,_=f&&t.length===0||(e?.defaultCollapsed??!1),{t:v}=W9(),[y,b]=H.useState(_);return m===`right`||m===`left`?y&&g?(0,U.jsx)(`div`,{className:q(`flex items-start pt-4`,m===`right`?`border-l`:`border-r`,p),children:(0,U.jsx)(Q,{variant:`ghost`,size:`icon`,className:`h-8 w-8 mx-1`,onClick:()=>b(!1),"aria-label":v(`detail.openDiscussion`),children:(0,U.jsx)(wW,{className:`h-4 w-4`})})}):(0,U.jsxs)(`div`,{className:q(`flex flex-col overflow-hidden`,m===`right`?`border-l`:`border-r`,p),style:{width:h,minWidth:h},children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-3 border-b`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(nB,{className:`h-4 w-4`}),(0,U.jsx)(`span`,{className:`text-sm font-medium`,children:v(`detail.discussion`)})]}),g&&(0,U.jsx)(Q,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:()=>b(!0),"aria-label":v(`detail.closeDiscussion`),children:(0,U.jsx)(c$,{className:`h-3.5 w-3.5`})})]}),(0,U.jsx)(`div`,{className:`flex-1 overflow-y-auto`,children:(0,U.jsx)(X9,{items:t,config:e?.feed,hasMore:n,onLoadMore:r,loading:i,onAddComment:a,onAddReply:o,onToggleReaction:s,subscription:c,onToggleSubscription:l,filterMode:u,onFilterChange:d,collapseWhenEmpty:f,titleLabel:v(`detail.discussion`),emptyLabel:v(`detail.noCommentsYet`),className:`border-0 shadow-none`})})]}):(0,U.jsx)(`div`,{className:q(``,p),children:g&&y?(0,U.jsxs)(Q,{variant:`ghost`,className:`w-full justify-start gap-2 text-muted-foreground`,onClick:()=>b(!1),"aria-label":v(`detail.showDiscussion`,{count:t.length}),children:[(0,U.jsx)(nB,{className:`h-4 w-4`}),(0,U.jsx)(`span`,{children:v(`detail.showDiscussion`,{count:t.length})})]}):(0,U.jsxs)(`div`,{children:[g&&(0,U.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium`,children:[(0,U.jsx)(nB,{className:`h-4 w-4`}),v(`detail.discussion`)]}),(0,U.jsx)(Q,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:()=>b(!0),"aria-label":v(`detail.hideDiscussion`),children:(0,U.jsx)(yW,{className:`h-3.5 w-3.5`})})]}),(0,U.jsx)(X9,{items:t,config:e?.feed,hasMore:n,onLoadMore:r,loading:i,onAddComment:a,onAddReply:o,onToggleReaction:s,subscription:c,onToggleSubscription:l,filterMode:u,onFilterChange:d,collapseWhenEmpty:f,titleLabel:v(`detail.discussion`),emptyLabel:v(`detail.noCommentsYet`)})]})})},vgt=e=>{let{"data-obj-id":t,"data-obj-type":n,style:r,...i}=e||{};return{designer:{"data-obj-id":t,"data-obj-type":n,style:r},rest:i}},ygt=({schema:e={},className:t,...n})=>{He();let{designer:r}=vgt(n);return(0,U.jsx)(`div`,{className:t,...r,children:(0,U.jsx)(_gt,{items:[],config:e})})},bgt=e=>{let{"data-obj-id":t,"data-obj-type":n,style:r,...i}=e||{};return{designer:{"data-obj-id":t,"data-obj-type":n,style:r},rest:i}},xgt=({schema:e={},className:t,...n})=>{let r=He(),{designer:i}=bgt(n),a=Array.isArray(e.stages)?e.stages:[],o=e.statusField,s=o&&r?.data?r.data[o]:void 0,c=a.findIndex(e=>e.value===s);return c<0&&(c=-1),a.length===0?(0,U.jsx)(`div`,{className:t,...i,children:(0,U.jsx)(`div`,{className:`text-xs text-muted-foreground italic px-3 py-2 border border-dashed rounded`,children:`record:path — no stages configured`})}):(0,U.jsx)(`div`,{className:q(`flex w-full items-stretch gap-1`,t),role:`list`,"aria-label":e.aria?.label||`Record path`,...i,children:a.map((e,t)=>{let n=c>=0&&t<c,r=t===c;return(0,U.jsx)(`div`,{role:`listitem`,"aria-current":r?`step`:void 0,className:q(`relative flex-1 px-4 py-2 text-xs font-medium border text-center`,`first:rounded-l-md last:rounded-r-md`,r&&`bg-primary text-primary-foreground border-primary`,n&&`bg-muted text-muted-foreground`,!r&&!n&&`bg-background text-foreground/70`),children:(0,U.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[n&&(0,U.jsx)(`span`,{"aria-hidden":!0,children:`✓`}),e.label]})},`${e.value}-${t}`)})})},Sgt=e=>{let{"data-obj-id":t,"data-obj-type":n,style:r,...i}=e||{};return{designer:{"data-obj-id":t,"data-obj-type":n,style:r},rest:i}},Cgt=({schema:e={},className:t,...n})=>{let r=He(),{designer:i}=Sgt(n),a=H9(),o=Array.isArray(e.actions)?e.actions:Array.isArray(e.properties?.actions)?e.properties.actions:[],s=r?.objectName||``,c=Array.isArray(e.requiredPermissions)?e.requiredPermissions:[];if(c.length>0&&s&&!c.every(e=>a.can(s,e)))return(0,U.jsx)(`div`,{className:t,...i,role:`status`,"aria-live":`polite`,children:(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground italic`,children:`Insufficient permissions to view quick actions.`})});let l=e.location||`record_header`,{getActionsForLocation:u,executeAction:d}=Ne({actions:o,context:{record:r?.data,recordId:r?.recordId,objectName:r?.objectName}}),f=o.length>0?u(l):[];if(f.length===0)return(0,U.jsx)(`div`,{className:t,...i,children:(0,U.jsx)(`div`,{className:`text-xs text-muted-foreground italic px-3 py-2 border border-dashed rounded`,children:`record:quick_actions — no actions configured`})});let p=e.align||`end`,m=p===`start`?`justify-start`:p===`center`?`justify-center`:`justify-end`;return(0,U.jsx)(`div`,{className:q(`flex flex-wrap items-center gap-2`,l===`record_header`&&!e.inline&&`-mt-12 sm:-mt-14 mb-2 relative z-10`,m,t),role:`toolbar`,"aria-label":e.aria?.label||`Quick actions`,...i,children:f.map((t,n)=>{let r=t.label||t.name||`Action ${n+1}`;return(0,U.jsx)(Q,{variant:t.variant||e.variant||`default`,size:t.size||e.size||`sm`,disabled:typeof t.disabled==`boolean`?t.disabled:void 0,onClick:()=>{if(typeof t.onClick==`function`){t.onClick();return}t.name&&d(t.name)},children:r},t.name||`qa-${n}`)})})},wgt=new Set([`id`,`_id`,`__v`,`created_at`,`updated_at`,`createdAt`,`updatedAt`,`created_by`,`updated_by`,`organization_id`,`tenant_id`,`owner_id`,`deleted_at`,`is_deleted`]),Tgt=480,Egt=95;function Dgt({open:e,onClose:t,title:n,record:r,objectName:i,recordId:a,dataSource:o,objectSchema:s,width:c=`min(960px, 60vw)`,columns:l=2,systemFields:u=wgt,onFieldSave:d,onDelete:f,resizable:p=!0,fullPageHref:m}){let{t:h}=W9(),g=`objectui.drawerWidth.${i}`,[_,v]=H.useState(()=>{if(typeof window>`u`||!p)return null;try{let e=window.localStorage.getItem(g);if(e){let t=parseInt(e,10);if(Number.isFinite(t)&&t>=Tgt)return t}}catch{}return null}),y=H.useMemo(()=>p&&_!=null?`${_}px`:typeof c==`number`?`${c}px`:c,[p,_,c]),b=y?{width:y,maxWidth:y}:void 0,x=H.useRef(null),S=H.useCallback(e=>{if(!p)return;e.preventDefault();let t=_??(typeof window<`u`?Math.min(window.innerWidth*.6,960):720);x.current={startX:e.clientX,startWidth:t};let n=e=>{let t=x.current;if(!t)return;let n=t.startX-e.clientX,r=typeof window<`u`?window.innerWidth*Egt/100:1600,i=Math.min(r,Math.max(Tgt,t.startWidth+n));v(Math.round(i))},r=()=>{x.current,x.current=null,window.removeEventListener(`pointermove`,n),window.removeEventListener(`pointerup`,r),window.removeEventListener(`pointercancel`,r);try{v(e=>(e!=null&&window.localStorage.setItem(g,String(e)),e))}catch{}};window.addEventListener(`pointermove`,n),window.addEventListener(`pointerup`,r),window.addEventListener(`pointercancel`,r)},[p,_,g]),C=s?.fields??{},w=(Object.keys(C).length?Object.keys(C):Object.keys(r)).filter(e=>!u.has(e)&&!e.startsWith(`__`)).filter(e=>e in r).filter(e=>!C[e]?.hidden).map(e=>{let t=C[e]||{},n=t.type===`lookup`||t.type===`master_detail`||t.type===`reference`;return{name:e,label:t.label,type:t.type,readonly:!!t.readonly||n,options:t.options,currency:t.currency,precision:t.precision,format:t.format,reference_to:t.reference_to??t.referenceTo??t.target,reference_field:t.reference_field??t.referenceField,required:t.required,validation:t.validation,placeholder:t.placeholder,description:t.description}});return(0,U.jsx)(_5,{open:e,onOpenChange:e=>{e||t()},children:(0,U.jsxs)(v5,{side:`right`,className:`w-full overflow-y-auto p-0 sm:!max-w-none`,style:b,onOpenAutoFocus:e=>e.preventDefault(),children:[p&&(0,U.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize drawer`,onPointerDown:S,className:`hidden sm:block absolute left-0 top-0 h-full w-1.5 cursor-col-resize select-none bg-transparent hover:bg-primary/30 active:bg-primary/50 transition-colors z-10`}),(0,U.jsx)(y5,{className:`sr-only`,children:(0,U.jsx)(b5,{children:n})}),(0,U.jsx)(`div`,{className:`px-6 pt-6 pb-6`,children:(0,U.jsx)(Y9,{dataSource:o,inlineEdit:!0,schema:{type:`detail-view`,objectName:i,resourceId:String(a),data:r,showDelete:!0,columns:l,fields:w,actions:m?[{type:`action:bar`,location:`record_header`,systemActions:[{name:`sys_open_new_tab`,label:h(`detail.openInNewTab`),icon:`external-link`,type:`script`,onClick:()=>window.open(m,`_blank`,`noopener`)}]}]:void 0},onFieldSave:async(e,t)=>{try{await d?.(e,t)}catch(e){console.error(`[RecordDetailDrawer] inline field save failed:`,e)}},onDelete:async()=>{try{await f?.(),t()}catch(e){console.error(`[RecordDetailDrawer] delete failed:`,e)}}})})]})})}function Ogt(e,t){if(typeof window>`u`)return null;let n=window.location.pathname,r=`/${e}`,i=n.indexOf(r);return`${i>=0?n.slice(0,i):n.replace(/\/$/,``)}/${e}/record/${encodeURIComponent(String(t))}`}b.register(`detail-view`,Y9,{namespace:`plugin-detail`,label:`Detail View`,category:`Views`,icon:`FileText`,inputs:[{name:`title`,type:`string`,label:`Title`},{name:`objectName`,type:`string`,label:`Object Name`},{name:`resourceId`,type:`string`,label:`Resource ID`},{name:`api`,type:`string`,label:`API Endpoint`},{name:`data`,type:`object`,label:`Data`},{name:`layout`,type:`enum`,label:`Layout Mode`,enum:[`vertical`,`horizontal`,`grid`]},{name:`columns`,type:`number`,label:`Grid Columns`},{name:`sections`,type:`array`,label:`Sections`},{name:`fields`,type:`array`,label:`Fields`},{name:`tabs`,type:`array`,label:`Tabs`},{name:`related`,type:`array`,label:`Related Lists`},{name:`actions`,type:`array`,label:`Actions`},{name:`showBack`,type:`boolean`,label:`Show Back Button`,defaultValue:!0},{name:`backUrl`,type:`string`,label:`Back URL`},{name:`showEdit`,type:`boolean`,label:`Show Edit Button`,defaultValue:!1},{name:`editUrl`,type:`string`,label:`Edit URL`},{name:`showDelete`,type:`boolean`,label:`Show Delete Button`,defaultValue:!1},{name:`deleteConfirmation`,type:`string`,label:`Delete Confirmation Message`},{name:`loading`,type:`boolean`,label:`Show Loading State`},{name:`header`,type:`object`,label:`Custom Header`},{name:`footer`,type:`object`,label:`Custom Footer`}],defaultProps:{title:`Detail View`,showBack:!0,showEdit:!1,showDelete:!1,sections:[],fields:[],tabs:[],related:[]}}),b.register(`detail-section`,G9,{namespace:`plugin-detail`,label:`Detail Section`,category:`Detail Components`,inputs:[{name:`title`,type:`string`,label:`Title`},{name:`description`,type:`string`,label:`Description`},{name:`fields`,type:`array`,label:`Fields`,required:!0},{name:`collapsible`,type:`boolean`,label:`Collapsible`,defaultValue:!1},{name:`defaultCollapsed`,type:`boolean`,label:`Default Collapsed`,defaultValue:!1},{name:`columns`,type:`number`,label:`Columns`,defaultValue:2},{name:`showBorder`,type:`boolean`,label:`Show Border`,defaultValue:!0},{name:`headerColor`,type:`string`,label:`Header Color`}]}),b.register(`related-list`,K9,{namespace:`plugin-detail`,label:`Related List`,category:`Detail Components`,inputs:[{name:`title`,type:`string`,label:`Title`,required:!0},{name:`type`,type:`enum`,label:`Type`,enum:[{label:`List`,value:`list`},{label:`Grid`,value:`grid`},{label:`Table`,value:`table`}],defaultValue:`table`},{name:`api`,type:`string`,label:`API Endpoint`},{name:`data`,type:`array`,label:`Data`},{name:`columns`,type:`array`,label:`Columns`}]}),b.register(`detail`,Y9,{namespace:`view`,category:`view`,label:`Detail`,icon:`FileText`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`recordId`,type:`string`,label:`Record ID`},{name:`fields`,type:`array`,label:`Fields`}]}),b.register(`record:details`,Qht,{namespace:`record`,category:`record`,label:`Record Details`,icon:`FileText`}),b.register(`record:related_list`,tgt,{namespace:`record`,category:`record`,label:`Related List`,icon:`List`}),b.register(`record:highlights`,rgt,{namespace:`record`,category:`record`,label:`Highlights Panel`,icon:`Star`}),b.register(`record:activity`,ggt,{namespace:`record`,category:`record`,label:`Activity Timeline`,icon:`Activity`}),b.register(`record:chatter`,ygt,{namespace:`record`,category:`record`,label:`Chatter Feed`,icon:`MessageSquare`}),b.register(`record:path`,xgt,{namespace:`record`,category:`record`,label:`Path / Stepper`,icon:`GitBranch`}),b.register(`record:quick_actions`,Cgt,{namespace:`record`,category:`record`,label:`Quick Actions`,icon:`Zap`});var kgt=({schema:e,dataSource:t,className:n,data:r,loading:i,onRowClick:a,onCardClick:o,...s})=>{let{translateOptions:c}=Gn(),l=Array.isArray(r),[u,d]=(0,H.useState)([]),[f,p]=(0,H.useState)(null),[m,h]=(0,H.useState)(l?i??!1:!1),[g,_]=(0,H.useState)(null),[v,y]=(0,H.useState)(0),b=ve(e.bind);(0,H.useEffect)(()=>{if(!l&&!(!t?.onMutation||!e.objectName))return t.onMutation(t=>{t.resource===e.objectName&&y(e=>e+1)})},[t,e.objectName,l]),(0,H.useEffect)(()=>{l&&i!==void 0&&h(i)},[i,l]),(0,H.useEffect)(()=>{let n=!0;return(async()=>{if(!(!t||!e.objectName))try{let r=await t.getObjectSchema(e.objectName);n&&p(r)}catch(e){console.warn(`Failed to fetch object def`,e)}})(),()=>{n=!1}},[e.objectName,t]),(0,H.useEffect)(()=>{if(l)return;let n=!0;return e.objectName&&!b&&!e.data&&(async()=>{if(!(!t||typeof t.find!=`function`||!e.objectName)){n&&h(!0);try{let r=S(f?.fields),i=x(await t.find(e.objectName,{options:{$top:100},$filter:e.filter,...r.length>0?{$expand:r}:{}}));n&&d(i)}catch(e){console.error(`[ObjectKanban] Fetch error:`,e),n&&_(e)}finally{n&&h(!1)}}})(),()=>{n=!1}},[e.objectName,t,b,e.data,e.filter,l,f,v]);let C=(l?r:void 0)||b||e.data||u,w=(0,H.useMemo)(()=>{if(!Array.isArray(C))return[];let t=e.cardTitle||e.titleField,n=[`name`,`full_name`,`fullName`,`title`,`subject`,`label`,`display_name`,`displayName`],r=f?.titleFormat,i=typeof r==`string`?r:r&&typeof r==`object`&&typeof r.source==`string`?r.source:void 0,a=f?.NAME_FIELD_KEY,o=(e,t)=>{let n=`[-\\u2013\\u2014|/·,:]`,r=!1,i=e.replace(/\{([^{}]+)\}/g,(e,n)=>{let i=t[n.trim()];return i!=null&&i!==``?(r=!0,String(i)):`\0`});return r?i.replace(RegExp(`\\s*${n}\\s*`,`g`),``).replace(RegExp(`\\s*${n}\\s*`,`g`),``).replace(RegExp(`\0`,`g`),``).replace(/\s+/g,` `).trim():``};return C.map(r=>{let s;if(t&&(s=r[t],typeof s==`string`&&(s=s.trim())),!s&&i){let e=o(i,r);e&&(s=e)}if(!s&&a){let e=r[a];typeof e==`string`?s=e.trim():e&&(s=e)}if(!s)for(let e of n){let t=r[e],n=typeof t==`string`?t.trim():t;if(n){s=n;break}}let c=e=>e>=1e6?`$${(e/1e6).toFixed(1).replace(/\.0$/,``)}M`:e>=1e3?`$${Math.round(e/1e3)}K`:`$${e}`,l=/^[A-Za-z0-9_-]{12,32}$/,u=e=>{if(typeof e!=`string`||!l.test(e))return!1;let t=/[A-Z]/.test(e),n=/[a-z]/.test(e),r=/[0-9_-]/.test(e);return t&&n||t&&r||n&&r},d=e=>{let t=r[e];if(t==null||t===``)return;if(typeof t==`object`){let e=t;for(let t of[`name`,`full_name`,`display_name`,`label`,`title`,`username`]){let n=e[t];if(typeof n==`string`&&n.trim())return n.trim()}return}if(typeof t!=`string`)return String(t);let n=f?.fields?.[e];if(!((n?.type===`lookup`||n?.type===`master_detail`||n?.type===`reference`)&&u(t))&&!u(t))return t},p=[],m=Array.isArray(e.cardFields)?e.cardFields:[],h=new Set([...t?[t]:[],...a?[a]:[],`name`,`full_name`,`title`,`subject`,`display_name`]),g=e=>{let t=f?.fields?.[e],n=r[e];if(n==null||n===``)return;if(typeof n==`number`)return t?.type===`currency`||/amount|value|revenue|price|cost|total/.test(e)?c(n):String(n);if(typeof n==`string`){let r=t?.type,i=/(_date|_at|_time|_on|_by_date)$|^(date|datetime|created|updated|modified)$/i.test(e);if(r===`date`||i&&r===void 0){let e=j9(n,`short`);if(e&&e!==`—`)return e}if(r===`datetime`||i&&r===void 0&&/T\d{2}:\d{2}/.test(n)){let e=Kmt(n);if(e&&e!==`—`)return e}}if(typeof n==`object`)return d(e);let i=d(e);if(i!==void 0)return t?.options?.find(e=>String(e.value).toLowerCase()===String(n).toLowerCase())?.label||String(i)},_=[];if(m.length>0)for(let e of m){if(h.has(e))continue;let t=f?.fields?.[e],n=r[e];if(!(n==null||n===``))if(t?.type===`picklist`||t?.type===`multipicklist`||Array.isArray(t?.options)&&t.options.length>0){let e=t?.options?.find(e=>String(e.value).toLowerCase()===String(n).toLowerCase()),r=e?.label||String(n),i=P9(e?.color,n);_.push({label:r,colorClass:i})}else{let n=g(e);if(n){let e=t?.label;p.push(e?`${e}: ${n}`:n)}}}else{let e=[`amount`,`value`,`deal_value`,`expected_value`,`opportunity_value`].find(e=>typeof r[e]==`number`);e&&p.push(c(r[e]));let t=[`company`,`company_name`,`account`,`account_name`,`organization`],n;for(let e of t){let t=d(e);if(t){n=t;break}}n&&(!s||!String(s).includes(n))&&p.push(n);let i=[`owner`,`owner_name`,`assignee`,`assignee_name`],a;for(let e of i){let t=d(e);if(t){a=t;break}}a&&p.push(`@${a}`);for(let e of[`priority`,`severity`,`industry`,`rating`]){let t=r[e];if(t!=null&&t!==``){let n=(f?.fields?.[e])?.options?.find(e=>String(e.value).toLowerCase()===String(t).toLowerCase()),r=n?.label||String(t),i=P9(n?.color,t);if(_.push({label:r,colorClass:i}),_.length>=2)break}}}let v=r.description,y=(v==null||v===``||typeof v==`string`&&u(v))&&p.length>0?p.join(` · `):void 0;return{...r,id:r.id||r._id,title:s||`Untitled`,...y?{cardSubtitle:y}:{},...!Array.isArray(r.badges)&&_.length>0?{badges:_}:{}}})},[C,e,f]),T=(0,H.useMemo)(()=>{if(e.columns&&e.columns.length>0)if(typeof e.columns[0]==`string`){if(!e.groupBy)return e.columns.map(e=>({id:e,title:e}))}else return e.columns;if(e.groupBy&&f?.fields?.[e.groupBy]?.options){let t=f.fields[e.groupBy].options.map(e=>({value:e.value,label:e.label}));return(e.objectName?c(e.objectName,e.groupBy,t):t).map(e=>({id:e.value,title:e.label}))}if(e.groupBy&&w.length>0){let t=new Set(w.map(t=>t[e.groupBy]));return Array.from(t).map(e=>({id:String(e),title:String(e)}))}return[]},[e.columns,e.groupBy,e.objectName,w,f,c]),E=e.swimlaneField||e.grouping?.fields?.[0]?.field,D={...e,data:w,columns:T,className:n||e.className,...E?{swimlaneField:E}:{}},O=e.navigation??{mode:`drawer`,width:`min(960px, 60vw)`},k=a??o;!k&&(O.mode===`drawer`||O.mode===`modal`||O.mode===`split`||O.mode);let A=Te({navigation:O,objectName:e.objectName,onRowClick:k});if(g)return(0,U.jsxs)(`div`,{className:`p-4 border border-destructive/50 rounded bg-destructive/10 text-destructive`,children:[`Error loading kanban data: `,g.message]});let j=e.objectName?`${e.objectName.charAt(0).toUpperCase()+e.objectName.slice(1).replace(/_/g,` `)} Detail`:`Card Details`,M=H.useCallback(async(n,r,i,a)=>{let o=e.groupBy,s=e.objectName;if(!(!o||r===i)&&(l||d(e=>e.map(e=>String(e.id??e._id)===String(n)?{...e,[o]:i}:e)),!(!s||!t?.update)))try{await t.update(s,String(n),{[o]:i})}catch(e){console.warn(`[ObjectKanban] Failed to persist card move`,e),l||d(e=>e.map(e=>String(e.id??e._id)===String(n)?{...e,[o]:r}:e))}},[e.groupBy,e.objectName,t,l]);return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(Mgt,{schema:{...D,onCardClick:(e,t)=>{A.handleClick(e,t),o?.(e)},onCardMove:M}}),A.isOverlay&&A.isOpen&&A.selectedRecord&&(()=>{let n=e.objectName,r=A.selectedRecord,i=r.id??r._id;if(!n||i==null)return null;let a=e.cardTitle??e.titleField,o=a&&r[a]?String(r[a]):j;return(0,U.jsx)(Dgt,{open:!0,onClose:A.close,title:o,record:r,objectName:n,recordId:i,dataSource:t,objectSchema:f,width:A.width??`min(960px, 60vw)`,fullPageHref:Ogt(n,i)??void 0,onFieldSave:async(e,r)=>{t?.update&&(await t.update(n,String(i),{[e]:r}),d(t=>t.map(t=>String(t.id??t._id)===String(i)?{...t,[e]:r}:t)))},onDelete:async()=>{t?.delete&&(await t.delete(n,String(i)),d(e=>e.filter(e=>String(e.id??e._id)!==String(i))))}})})()]})},Agt=H.lazy(()=>$(()=>import(`./KanbanImpl-tQCLvQ8D.js`),__vite__mapDeps([0,1]))),jgt=H.lazy(()=>$(()=>import(`./KanbanEnhanced-CWBk63YQ.js`),__vite__mapDeps([2,1]))),Mgt=({schema:e})=>{let t=H.useMemo(()=>{let{columns:t=[],data:n,groupBy:r,coverImageField:i}=e,a=e=>{if(!i)return e;let t=e[i];if(!t)return e;let n=typeof t==`string`?t:t?.url;return n?{...e,coverImage:n}:e};if(n&&r&&Array.isArray(n)){let e={};t.forEach(t=>{t.id&&(e[String(t.id).toLowerCase()]=t.id),t.title&&(e[String(t.title).toLowerCase()]=t.id)});let i=n.reduce((t,n)=>{let i=String(n[r]??``),o=e[i.toLowerCase()]??i;return t[o]||(t[o]=[]),t[o].push(a(n)),t},{});return t.map(e=>({...e,cards:[...(e.cards||[]).map(a),...i[e.id]||[]]}))}return t.map(e=>({...e,cards:(e.cards||[]).map(a)}))},[e]);return(0,U.jsx)(H.Suspense,{fallback:(0,U.jsx)(w5,{className:`w-full h-[600px]`}),children:(0,U.jsx)(Agt,{columns:t,onCardMove:e.onCardMove,onCardClick:e.onCardClick,className:e.className,quickAdd:e.quickAdd,onQuickAdd:e.onQuickAdd,coverImageField:e.coverImageField,conditionalFormatting:e.conditionalFormatting,swimlaneField:e.swimlaneField})})};b.register(`kanban-ui`,Mgt,{namespace:`plugin-kanban`,label:`Kanban Board`,icon:`LayoutDashboard`,category:`plugin`,inputs:[{name:`columns`,type:`array`,label:`Columns`,description:`Array of { id, title, cards, limit, className }`,required:!0},{name:`onCardMove`,type:`code`,label:`On Card Move`,description:`Callback when a card is moved`,advanced:!0},{name:`className`,type:`string`,label:`CSS Class`}],defaultProps:{columns:[{id:`todo`,title:`To Do`,cards:[{id:`card-1`,title:`Task 1`,description:`This is the first task`,badges:[{label:`High Priority`,variant:`destructive`},{label:`Feature`,variant:`default`}]},{id:`card-2`,title:`Task 2`,description:`This is the second task`,badges:[{label:`Bug`,variant:`destructive`}]}]},{id:`in-progress`,title:`In Progress`,limit:3,cards:[{id:`card-3`,title:`Task 3`,description:`Currently working on this`,badges:[{label:`In Progress`,variant:`default`}]}]},{id:`done`,title:`Done`,cards:[{id:`card-4`,title:`Task 4`,description:`This task is completed`,badges:[{label:`Completed`,variant:`outline`}]},{id:`card-5`,title:`Task 5`,description:`Another completed task`,badges:[{label:`Completed`,variant:`outline`}]}]}],className:`w-full`}}),b.register(`kanban-enhanced`,({schema:e})=>{let t=H.useMemo(()=>{let{columns:t=[],data:n,groupBy:r}=e;if(n&&r&&Array.isArray(n)){let e=n.reduce((e,t)=>{let n=t[r];return e[n]||(e[n]=[]),e[n].push(t),e},{});return t.map(t=>({...t,cards:[...t.cards||[],...e[t.id]||[]]}))}return t},[e]);return(0,U.jsx)(H.Suspense,{fallback:(0,U.jsx)(w5,{className:`w-full h-[600px]`}),children:(0,U.jsx)(jgt,{columns:t,onCardMove:e.onCardMove,onColumnToggle:e.onColumnToggle,enableVirtualScrolling:e.enableVirtualScrolling,virtualScrollThreshold:e.virtualScrollThreshold,className:e.className,quickAdd:e.quickAdd,onQuickAdd:e.onQuickAdd,conditionalFormatting:e.conditionalFormatting})})},{namespace:`plugin-kanban`,label:`Kanban Board (Enhanced)`,icon:`LayoutGrid`,category:`plugin`,inputs:[{name:`columns`,type:`array`,label:`Columns`,required:!0},{name:`enableVirtualScrolling`,type:`boolean`,label:`Virtual Scrolling`,defaultValue:!1},{name:`virtualScrollThreshold`,type:`number`,label:`Virtual Scroll Threshold`,defaultValue:50},{name:`onCardMove`,type:`code`,label:`On Card Move`,advanced:!0},{name:`onColumnToggle`,type:`code`,label:`On Column Toggle`,advanced:!0},{name:`className`,type:`string`,label:`CSS Class`}],defaultProps:{columns:[],enableVirtualScrolling:!1,virtualScrollThreshold:50,className:`w-full`}});var Ngt=({schema:e,...t})=>{let{dataSource:n}=_e()||{};return(0,U.jsx)(kgt,{schema:e,dataSource:n,...t})};b.register(`object-kanban`,Ngt,{namespace:`plugin-kanban`,label:`Object Kanban`,category:`view`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`columns`,type:`array`,label:`Columns`}]}),b.register(`kanban`,Ngt,{namespace:`view`,label:`Kanban Board`,category:`view`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`columns`,type:`array`,label:`Columns`}]});var Pgt=H.lazy(()=>$(()=>import(`./ChartImpl-CsWD-PjU.js`),__vite__mapDeps([3,4]))),Fgt=H.lazy(()=>$(()=>import(`./AdvancedChartImpl-CT2fx0UI.js`),__vite__mapDeps([5,4]))),Igt=({schema:e})=>(0,U.jsx)(H.Suspense,{fallback:(0,U.jsx)(w5,{className:`w-full h-48 sm:h-64 md:h-80 lg:h-[400px]`}),children:(0,U.jsx)(Pgt,{data:e.data,dataKey:e.dataKey,xAxisKey:e.xAxisKey,height:e.height,className:e.className,color:e.color})}),Z9=({schema:e,onChartClick:t})=>{let n=H.useMemo(()=>{let t=e.series,n=e.xAxisKey,r=e.config;if(n||(e.index?n=e.index:e.category&&(n=e.category)),t||(e.categories?t=e.categories.map(e=>({dataKey:e})):e.value&&(t=[{dataKey:e.value}])),!r&&t){let n=e.colors||[`hsl(var(--chart-1))`,`hsl(var(--chart-2))`,`hsl(var(--chart-3))`],i={};t.forEach((e,t)=>{i[e.dataKey]={label:e.label||e.dataKey,color:n[t%n.length]}}),r=i}return{chartType:e.chartType,data:Array.isArray(e.data)?e.data:[],config:r,xAxisKey:n,series:t,className:e.className}},[e]);return(0,U.jsx)(H.Suspense,{fallback:(0,U.jsx)(w5,{className:`w-full h-48 sm:h-64 md:h-80 lg:h-[400px]`}),children:(0,U.jsx)(Fgt,{chartType:n.chartType,data:n.data,config:n.config,xAxisKey:n.xAxisKey,series:n.series,className:n.className,onChartClick:t})})};function Q9(e){return e.replace(/[_-]/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}function Lgt(e,t){let{field:n,function:r,groupBy:i}=t,a={};for(let t of e){let e=String(t[i]??`Unknown`);a[e]||(a[e]=[]),a[e].push(t)}return Object.entries(a).map(([e,t])=>{let a=t.map(e=>Number(e[n])||0),o;switch(r){case`count`:o=t.length;break;case`avg`:o=a.length>0?a.reduce((e,t)=>e+t,0)/a.length:0;break;case`min`:o=a.length>0?Math.min(...a):0;break;case`max`:o=a.length>0?Math.max(...a):0;break;default:o=a.reduce((e,t)=>e+t,0);break}return{[i]:e,[n]:o}})}async function Rgt(e,t,n,r,i){if(!e.length||!t)return e;let a=i||((e,t)=>t),o=`__raw_${t}`,s=n?.fields?.[t];if(!s){let n=/^\d{4}-\d{2}-\d{2}/;return e.map(e=>{let r=e[t],i=String(r??``),s=n.test(i)?i:Q9(i);return{...e,[t]:a(i,s),[o]:r}})}let c=s.type;if(c===`select`||c===`picklist`||c===`dropdown`){let n=s.options||[];if(n.length===0)return e.map(e=>{let n=e[t],r=String(n??``),i=Q9(r);return{...e,[t]:a(r,i),[o]:n}});let r={};for(let e of n)typeof e==`string`?r[e]=e:e&&typeof e==`object`&&(r[String(e.value)]=e.label||String(e.value));return e.map(e=>{let n=e[t],i=String(n??``),s=r[i]||Q9(i);return{...e,[t]:a(i,s),[o]:n}})}if(c===`lookup`||c===`master_detail`){let n=s.reference_to||s.reference;if(!n||!r||typeof r.find!=`function`)return e.map(e=>({...e,[o]:e[t]}));let i=[...new Set(e.map(e=>e[t]).filter(e=>e!=null))];if(i.length===0)return e.map(e=>({...e,[o]:e[t]}));let a=s.id_field||`id`;try{let c=x(await r.find(n,{$filter:{[a]:{$in:i}},$top:i.length})),l=s.reference_field||s.display_field||`name`,u={};for(let e of c){let t=String(e[a]??e.id??e._id??``),n=e[l]||e.name||e.label||e.title||t;t&&(u[t]=String(n))}return e.map(e=>{let n=e[t],r=String(n??``);return{...e,[t]:u[r]||r,[o]:n}})}catch(n){return console.warn(`[ObjectChart] Failed to resolve lookup labels:`,n),e.map(e=>({...e,[o]:e[t]}))}}if(c===`date`||c===`datetime`||c===`date_time`||c===`timestamp`||c===`time`)return e.map(e=>({...e,[o]:e[t]}));let l=/^\d{4}-\d{2}-\d{2}/;return e.map(e=>{let n=e[t],r=String(n??``);return{...e,[t]:l.test(r)?r:Q9(r),[o]:n}})}var zgt=e=>{let{schema:t}=e,n=(0,H.useContext)(ge),r=e.dataSource||n?.dataSource,i=ve(t.bind),{fieldOptionLabel:a}=Gn(),o=(0,H.useRef)(a);(0,H.useEffect)(()=>{o.current=a},[a]);let[s,c]=(0,H.useState)([]),[l,u]=(0,H.useState)(!1),[d,f]=(0,H.useState)(null),[p,m]=(0,H.useState)(null),h=(0,H.useMemo)(()=>t.aggregate?JSON.stringify(t.aggregate):``,[t.aggregate]),g=(0,H.useMemo)(()=>t.filter?JSON.stringify(t.filter):``,[t.filter]),_=(0,H.useCallback)(async(e,n)=>{if(!(!e||!t.objectName)){n.current&&(u(!0),f(null));try{let r,i=me(t.filter);if(t.aggregate&&typeof e.aggregate==`function`){let n=await e.aggregate(t.objectName,{field:t.aggregate.field,function:t.aggregate.function,groupBy:t.aggregate.groupBy,filter:i});r=Array.isArray(n)?n:[]}else if(typeof e.find==`function`)r=x(await e.find(t.objectName,{$filter:i})),t.aggregate&&r.length>0&&(r=Lgt(r,t.aggregate));else return;let a=t.aggregate?.groupBy||t.xAxisKey;if(a&&typeof e.getObjectSchema==`function`)try{let n=await e.getObjectSchema(t.objectName);r=await Rgt(r,a,n,e,(e,n)=>o.current(t.objectName,a,e,n))}catch{}n.current&&c(r)}catch(e){console.error(`[ObjectChart] Fetch error:`,e),n.current&&f(e instanceof Error?e.message:`Failed to load chart data`)}finally{n.current&&u(!1)}}},[t.objectName,h,g,t.xAxisKey]);(0,H.useEffect)(()=>{let e={current:!0};return t.objectName&&!i&&!t.data&&_(r,e),()=>{e.current=!1}},[t.objectName,r,i,t.data,g,h,_]);let v=i||t.data||s,y=Array.isArray(v)?v:[],b=t.drillDown,S=t.aggregate?.groupBy||t.xAxisKey,C=(0,H.useMemo)(()=>{if(!S)return new Map;let e=new Map,t=`__raw_${S}`;for(let n of y){let r=n?.[S];if(r==null)continue;let i=t in(n||{})?n[t]:r;e.set(String(r),i)}return e},[y,S]),w={...t,data:y};if(l&&y.length===0)return(0,U.jsx)(`div`,{className:`flex items-center justify-center text-muted-foreground text-sm p-4 `+(t.className||``),"data-testid":`chart-loading`,children:`Loading chart data…`});if(d)return(0,U.jsxs)(`div`,{className:`flex flex-col items-center justify-center gap-2 p-4 `+(t.className||``),"data-testid":`chart-error`,role:`alert`,children:[(0,U.jsx)(Em,{className:`h-6 w-6 text-destructive opacity-60`}),(0,U.jsx)(`p`,{className:`text-xs text-destructive font-medium`,children:`Failed to load chart data`}),(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground max-w-xs text-center`,children:d})]});if(!r&&t.objectName&&y.length===0)return(0,U.jsxs)(`div`,{className:`flex items-center justify-center text-muted-foreground text-sm p-4 `+(t.className||``),"data-testid":`chart-no-datasource`,children:[`No data source available for “`,t.objectName,`”`]});let T=pe(b)?e=>{let t=e.category,n=t!=null&&C.has(String(t))?C.get(String(t)):t;m({...e,category:n,categoryLabel:t,scope:`cell`})}:void 0,E=p&&t.objectName?(()=>{let e=de(b,p,{groupByField:S}),n={...t.filter||{},...e},i=fe(b,p,t.title||`Details`),a=b?.target??`drawer`,o=(0,U.jsx)(`div`,{className:`overflow-auto`,"data-testid":`chart-drill-body`,children:(0,U.jsx)(Se,{schema:{type:`object-data-table`,objectName:t.objectName,filter:n,pagination:!0,pageSize:b?.maxRows,columns:b?.columns?.map(e=>({accessorKey:e,header:e}))},dataSource:r})});return a===`dialog`?(0,U.jsx)(j2,{open:!0,onOpenChange:e=>!e&&m(null),children:(0,U.jsxs)(N2,{className:`max-w-4xl`,children:[(0,U.jsx)(P2,{children:(0,U.jsx)(I2,{children:i})}),o]})}):(0,U.jsx)(_5,{open:!0,onOpenChange:e=>!e&&m(null),children:(0,U.jsxs)(v5,{side:`right`,className:`w-full sm:max-w-2xl md:max-w-3xl lg:max-w-4xl flex flex-col`,children:[(0,U.jsx)(y5,{children:(0,U.jsx)(b5,{children:i})}),(0,U.jsx)(`div`,{className:`flex-1 overflow-hidden mt-2`,children:o})]})})})():null;return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(Z9,{...e,schema:w,onChartClick:T}),E]})};b.register(`object-chart`,zgt,{namespace:`plugin-charts`,label:`Object Chart`,category:`view`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`data`,type:`array`,label:`Data`,description:`Optional static data`},{name:`filter`,type:`array`,label:`Filter`},{name:`aggregate`,type:`object`,label:`Aggregate`,description:`Aggregation config: { field, function, groupBy }`}]}),b.register(`bar-chart`,Igt,{namespace:`plugin-charts`,label:`Bar Chart`,category:`plugin`,inputs:[{name:`data`,type:`array`,label:`Data`,required:!0},{name:`dataKey`,type:`string`,label:`Data Key`,defaultValue:`value`},{name:`xAxisKey`,type:`string`,label:`X-Axis Key`,defaultValue:`name`},{name:`height`,type:`number`,label:`Height`,defaultValue:400},{name:`color`,type:`color`,label:`Color`,defaultValue:`#8884d8`}],defaultProps:{data:[{name:`Jan`,value:400},{name:`Feb`,value:300},{name:`Mar`,value:600},{name:`Apr`,value:800},{name:`May`,value:500}],dataKey:`value`,xAxisKey:`name`,height:400,color:`#8884d8`}}),b.register(`chart`,zgt,{namespace:`view`,category:`view`,label:`Chart`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`type`,type:`string`,label:`Chart Type`},{name:`categoryField`,type:`string`,label:`Category Field`},{name:`valueField`,type:`string`,label:`Value Field`}]}),b.register(`chart`,Z9,{namespace:`plugin-charts`,label:`Chart`,category:`plugin`,inputs:[{name:`chartType`,type:`enum`,label:`Chart Type`,enum:[{label:`Bar`,value:`bar`},{label:`Line`,value:`line`},{label:`Area`,value:`area`},{label:`Pie`,value:`pie`},{label:`Donut`,value:`donut`},{label:`Radar`,value:`radar`},{label:`Scatter`,value:`scatter`}],defaultValue:`bar`},{name:`data`,type:`code`,label:`Data (JSON)`,required:!0},{name:`config`,type:`code`,label:`Config (JSON)`},{name:`xAxisKey`,type:`string`,label:`X Axis Key`,defaultValue:`name`},{name:`series`,type:`code`,label:`Series (JSON Array)`,required:!0},{name:`className`,type:`string`,label:`CSS Class`}],defaultProps:{chartType:`bar`,data:[{name:`Jan`,sales:400,revenue:240},{name:`Feb`,sales:300,revenue:139},{name:`Mar`,sales:600,revenue:380},{name:`Apr`,sales:800,revenue:430},{name:`May`,sales:500,revenue:220}],config:{sales:{label:`Sales`,color:`#8884d8`},revenue:{label:`Revenue`,color:`#82ca9d`}},xAxisKey:`name`,series:[{dataKey:`sales`},{dataKey:`revenue`}]}}),b.register(`chart:bar`,Z9,{namespace:`plugin-charts`,label:`Bar Chart (Alias)`,category:`plugin`,defaultProps:{chartType:`bar`}}),b.register(`pie-chart`,Z9,{namespace:`plugin-charts`,label:`Pie Chart`,category:`plugin`,defaultProps:{chartType:`pie`}}),b.register(`donut-chart`,Z9,{namespace:`plugin-charts`,label:`Donut Chart`,category:`plugin`,defaultProps:{chartType:`donut`}}),b.register(`radar-chart`,Z9,{namespace:`plugin-charts`,label:`Radar Chart`,category:`plugin`,defaultProps:{chartType:`radar`}}),b.register(`scatter-chart`,Z9,{namespace:`plugin-charts`,label:`Scatter Chart`,category:`plugin`,defaultProps:{chartType:`scatter`}});var $9=e=>e?gft(e):null,Bgt=({item:e,currentPath:t,isSidebarOpen:n,onNavigate:r,level:i=0})=>{let a=t===e.path,o=e.children?.some(e=>e.path===t),[s,c]=H.useState(o),l=$9(e.icon);return H.useEffect(()=>{o&&c(!0)},[o]),e.children&&e.children.length>0?(0,U.jsxs)(m2,{open:s,onOpenChange:c,className:`w-full`,children:[(0,U.jsxs)(h2,{className:`flex w-full items-center justify-between py-2 text-sm font-medium rounded-md transition-colors text-muted-foreground hover:bg-muted hover:text-foreground ${n?`px-3`:`justify-center px-2 cursor-pointer`}`,children:[(0,U.jsxs)(`div`,{className:`flex items-center overflow-hidden`,children:[l&&(0,U.jsx)(l,{className:`h-4 w-4 shrink-0 ${n?`mr-3`:``}`}),(0,U.jsx)(`span`,{className:`whitespace-nowrap overflow-hidden transition-all duration-300 ${n?`opacity-100 w-auto`:`opacity-0 w-0 hidden`}`,children:e.label})]}),n&&(0,U.jsx)(Xp,{className:`h-4 w-4 transition-transform ${s?`rotate-180`:``}`})]}),(0,U.jsx)(g2,{className:`space-y-1 overflow-hidden data-[state=closed]:animate-collapsible-up data-[state=open]:animate-collapsible-down`,children:n&&e.children.map((e,a)=>(0,U.jsx)(Bgt,{item:e,currentPath:t,isSidebarOpen:n,onNavigate:r,level:i+1},a))})]}):(0,U.jsxs)(`a`,{href:e.path||`#`,onClick:t=>e.path&&r(t,e.path),title:n?void 0:e.label,className:`flex items-center py-2 text-sm font-medium rounded-md transition-colors ${a?`bg-primary text-primary-foreground`:`text-muted-foreground hover:bg-muted hover:text-foreground`} ${n?`px-3`:`justify-center px-2`} ${i>0&&n?`pl-10`:``}`,children:[l&&(0,U.jsx)(l,{className:`h-4 w-4 shrink-0 ${n?`mr-3`:``} ${a?`text-primary-foreground`:`text-muted-foreground group-hover:text-foreground`}`}),(0,U.jsx)(`span`,{className:`whitespace-nowrap overflow-hidden transition-all duration-300 ${n?`opacity-100 w-auto`:`opacity-0 w-0 hidden`}`,children:e.label})]})},Vgt=({app:e,children:t,currentPath:n,onNavigate:r})=>{let i=e.layout||`sidebar`,[a,o]=H.useState(!0),[s,c]=H.useState(`light`);H.useEffect(()=>{c(localStorage.getItem(`theme`)===`dark`||!(`theme`in localStorage)&&window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`)},[]),H.useEffect(()=>{s===`dark`?(document.documentElement.classList.add(`dark`),localStorage.setItem(`theme`,`dark`)):(document.documentElement.classList.remove(`dark`),localStorage.setItem(`theme`,`light`))},[s]);let l=()=>{c(e=>e===`dark`?`light`:`dark`)},u=(e,t)=>{e.preventDefault(),r?r(t):window.location.href=t};if(i===`empty`)return(0,U.jsx)(`main`,{className:e.className,children:t});let d=e.logo&&!e.logo.includes(`/`)&&!e.logo.includes(`.`)?$9(e.logo):null;return(0,U.jsxs)(`div`,{className:`flex min-h-screen w-full bg-background ${e.className||``}`,children:[i===`sidebar`&&(0,U.jsxs)(`aside`,{className:`
105
105
  shrink-0 border-r bg-background hidden md:flex flex-col h-screen sticky top-0 z-30 transition-all duration-300 ease-in-out
106
106
  ${a?`w-64`:`w-[70px]`}
107
107
  `,children:[(0,U.jsxs)(`div`,{className:`h-14 flex items-center border-b font-semibold text-lg tracking-tight transition-all ${a?`px-6`:`justify-center px-0`}`,children:[d?(0,U.jsx)(d,{className:`h-6 w-6`}):e.logo?(0,U.jsx)(`img`,{src:e.logo,alt:e.title,className:`h-6 w-auto`}):(0,U.jsx)(Kp,{className:`h-6 w-6`}),(0,U.jsx)(`span`,{className:`ml-2 whitespace-nowrap overflow-hidden transition-all duration-300 ${a?`opacity-100 w-auto`:`opacity-0 w-0 hidden`}`,children:e.title||e.name||`Object UI`})]}),(0,U.jsx)(`nav`,{className:`flex-1 p-2 space-y-1 overflow-y-auto overflow-x-hidden`,children:e.menu?.map((e,t)=>(0,U.jsx)(Bgt,{item:e,currentPath:n,isSidebarOpen:a,onNavigate:u},t))}),e.version&&a&&(0,U.jsxs)(`div`,{className:`p-4 border-t text-xs text-muted-foreground`,children:[`v`,e.version]})]}),(0,U.jsxs)(`div`,{className:`flex-1 flex flex-col min-w-0 overflow-hidden`,children:[(0,U.jsxs)(`header`,{className:`h-14 flex items-center justify-between px-4 md:px-6 bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/60 border-b z-20 sticky top-0`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,U.jsx)(`button`,{onClick:()=>o(!a),className:`p-2 -ml-2 text-muted-foreground hover:bg-muted hover:text-foreground rounded-md transition-colors`,children:(0,U.jsx)(YR,{className:`h-5 w-5`})}),(0,U.jsxs)(`div`,{className:`relative hidden md:block w-96`,children:[(0,U.jsx)(vZ,{className:`absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground`}),(0,U.jsx)(`input`,{type:`text`,placeholder:`Search...`,className:`w-full h-9 pl-9 pr-4 rounded-md border border-input bg-background text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50`})]})]}),(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(`button`,{onClick:l,className:`p-2 text-muted-foreground hover:text-foreground transition-colors rounded-md hover:bg-muted`,title:`Switch to ${s===`dark`?`light`:`dark`} mode`,children:s===`dark`?(0,U.jsx)(e$,{className:`h-5 w-5`}):(0,U.jsx)(pV,{className:`h-5 w-5`})}),e.actions?.filter(e=>e.type===`button`).map((e,t)=>{let n=e.icon?$9(e.icon):null;return(0,U.jsxs)(`button`,{className:e.variant===`ghost`?`relative p-2 text-muted-foreground hover:text-foreground transition-colors hover:bg-muted rounded-md`:`p-2`,title:e.label,children:[n&&(0,U.jsx)(n,{className:`h-5 w-5`}),e.label&&!e.icon&&(0,U.jsx)(`span`,{children:e.label})]},t)}),(!e.actions||!e.actions.some(e=>e.type===`button`))&&(0,U.jsxs)(`button`,{className:`relative p-2 text-muted-foreground hover:text-foreground transition-colors`,children:[(0,U.jsx)(Gp,{className:`h-5 w-5`}),(0,U.jsx)(`span`,{className:`absolute top-1.5 right-1.5 h-2 w-2 bg-red-600 rounded-full border-2 border-background`})]}),e.actions?.filter(e=>e.type===`user`).map((e,t)=>(0,U.jsxs)(Y3,{children:[(0,U.jsx)(X3,{asChild:!0,children:(0,U.jsx)(`button`,{className:`relative h-8 w-8 rounded-full border bg-muted overflow-hidden focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 hover:opacity-90 transition-opacity`,children:(0,U.jsxs)(S1,{className:`h-full w-full`,children:[(0,U.jsx)(C1,{src:e.avatar,alt:e.label||`User`}),(0,U.jsx)(w1,{children:e.label?.substring(0,2).toUpperCase()||`JD`})]})})}),(0,U.jsxs)(Z3,{className:`w-56`,align:`end`,forceMount:!0,children:[(0,U.jsx)($3,{className:`font-normal`,children:(0,U.jsxs)(`div`,{className:`flex flex-col space-y-1`,children:[(0,U.jsx)(`p`,{className:`text-sm font-medium leading-none`,children:e.label||`User`}),(0,U.jsx)(`p`,{className:`text-xs leading-none text-muted-foreground`,children:e.description||`user@example.com`})]})}),(0,U.jsx)(e6,{}),(0,U.jsx)(M9e,{children:e.items?.map((e,t)=>e.type===`separator`?(0,U.jsx)(e6,{},t):(0,U.jsxs)(Q3,{onSelect:()=>{e.onClick&&console.log(`Clicked`,e.label)},children:[e.label,e.shortcut&&(0,U.jsx)(R9e,{children:e.shortcut})]},t))})]})]},t))]})]}),(0,U.jsx)(`main`,{className:`flex-1 overflow-auto p-4 md:p-8 scroll-smooth`,children:(0,U.jsx)(`div`,{className:`mx-auto max-w-7xl animate-in fade-in slide-in-from-bottom-4 duration-500`,children:t})})]})]})},Hgt=class{appGlob=Object.assign({});pagesGlob=Object.assign({});rootGlob=Object.assign({});async loadAppConfig(){let e=`../app-data/app.json`;if(this.appGlob[e]){let t=await this.appGlob[e]();return t.default||t}return null}async loadPage(e){let t=e.replace(/^\//,``)||`index`;return await this.tryLoad(`../app-data/pages/${t}.json`)?await this.loadKey(`../app-data/pages/${t}.json`):await this.tryLoad(`../app-data/pages/${t}/index.json`)?await this.loadKey(`../app-data/pages/${t}/index.json`):t===`index`&&await this.tryLoad(`../app-data/index.json`)?await this.loadKey(`../app-data/index.json`):null}async tryLoad(e){return!!(this.pagesGlob[e]||this.rootGlob[e])}async loadKey(e){let t=this.pagesGlob[e]||this.rootGlob[e];if(!t)return null;let n=await t();return n.default||n}},Ugt=class{baseUrl;constructor(e=`/api`){this.baseUrl=e}async loadAppConfig(){try{let e=await fetch(`${this.baseUrl}/app.json`);return e.ok?await e.json():null}catch{return null}}async loadPage(e){try{let t=e===`/`?`/index`:e,n=await fetch(`${this.baseUrl}/pages${t}.json`);return n.ok?await n.json():null}catch{return null}}};function Wgt(){let[e,t]=(0,H.useState)(null),[n,r]=(0,H.useState)(null),[i,a]=(0,H.useState)(window.location.pathname),[o,s]=(0,H.useState)(null),[c,l]=(0,H.useState)(!0),u=(0,H.useMemo)(()=>{let e=new URLSearchParams(window.location.search).get(`api`);return e?(console.log(`🔌 Using Network Loader:`,e),new Ugt(e)):(console.log(`📦 Using Local Bundle Loader`),new Hgt)},[]);(0,H.useEffect)(()=>{(async()=>{try{let e=await u.loadAppConfig();e&&t(e)}catch(e){console.error(`Error loading app config`,e)}})()},[u]);let d=(0,H.useCallback)(e=>{window.history.pushState({},``,e),a(e),window.scrollTo(0,0)},[]);if((0,H.useEffect)(()=>{let e=()=>a(window.location.pathname);return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)},[]),(0,H.useEffect)(()=>{(async()=>{l(!0),s(null);try{let e=await u.loadPage(i);e?r(e):(s(`Page not found: ${i}`),r(i===`/`?{type:`page`,title:`Welcome to Object UI`,body:[{type:`div`,className:`p-10 text-center text-muted-foreground`,body:`No index page found.`}]}:null))}catch(e){console.error(e),s(`Failed to load page.`)}finally{l(!1)}})()},[i,u]),!e&&c)return(0,U.jsxs)(`div`,{className:`flex h-screen items-center justify-center text-slate-400`,children:[(0,U.jsx)(`div`,{className:`h-6 w-6 animate-spin rounded-full border-2 border-slate-200 border-t-slate-600 mr-2`}),`Loading App...`]});let f;return f=c?(0,U.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full text-slate-400 min-h-[50vh]`,children:[(0,U.jsx)(`div`,{className:`h-6 w-6 animate-spin rounded-full border-2 border-slate-200 border-t-slate-600 mr-2`}),`Loading Page...`]}):o||!n?(0,U.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full p-12 text-red-600`,children:[(0,U.jsx)(`h1`,{className:`text-2xl font-bold`,children:`404`}),(0,U.jsx)(`p`,{className:`mt-2 text-slate-600`,children:o||`Page not found`}),(0,U.jsx)(`button`,{onClick:()=>d(`/`),className:`mt-4 text-blue-600 hover:underline`,children:`Go Home`})]}):(0,U.jsx)(Se,{schema:n}),e?(0,U.jsx)(Vgt,{app:e,currentPath:i,onNavigate:d,children:f}):(0,U.jsx)(`div`,{className:`object-ui-app`,children:f})}he.createRoot(document.getElementById(`root`)).render((0,U.jsx)(H.StrictMode,{children:(0,U.jsx)(Wgt,{})}));export{l as $,F0e as A,zK as B,$0e as C,R0e as D,z0e as E,D0 as F,Fn as G,Xp as H,O0 as I,y as J,ze as K,T1 as L,E0 as M,A0 as N,L0e as O,k0 as P,s as Q,Q as R,K0e as S,V0e as T,er as U,Qp as V,Hn as W,d as X,h as Y,o as Z,W0e as _,w2e as a,U0e as b,n2e as c,q0e as d,J0e as f,Q0e as g,e2e as h,E2e as i,P0e as j,Z0 as k,X0e as l,$0 as m,K8 as n,r2 as o,Y0e as p,Be as q,f6 as r,n2 as s,Jft as t,Z0e as u,t2 as v,Q0 as w,t2e as x,e2 as y,o$ as z};