@revisium/admin 2.4.0-alpha.1 → 2.4.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.
|
@@ -366,7 +366,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
366
366
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var s=!0,o=!1,l;return{s:function(){r=r.call(t)},n:function(){var u=r.next();return s=u.done,u},e:function(u){o=!0,l=u},f:function(){try{!s&&r.return!=null&&r.return()}finally{if(o)throw l}}}}function MU(t,e){if(t){if(typeof t=="string")return Vj(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);if(r==="Object"&&t.constructor&&(r=t.constructor.name),r==="Map"||r==="Set")return Array.from(t);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return Vj(t,e)}}function Vj(t,e){(e==null||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function Dy(t){return t.slice(0).reverse()}function OU(t){var e=t.typeKey,r=t.defaultDropEffect,n=new WeakMap,i="data-drop-target-for-".concat(e),s="[".concat(i,"]");function o(p){return n.set(p.element,p),function(){return n.delete(p.element)}}function l(p){return IO(_O(p.element,{attribute:i,value:"true"}),o(p))}function c(p){var g,y,m,v,x,b=p.source,S=p.target,C=p.input,w=p.result,I=w===void 0?[]:w;if(!(S instanceof Element))return I;var R=S.closest(s);if(R==null)return I;var k=n.get(R);if(k==null)return I;var M={input:C,source:b,element:k.element};if(k.canDrop&&!k.canDrop(M))return c({source:b,target:k.element.parentElement,input:C,result:I});var N=(g=(y=k.getData)===null||y===void 0?void 0:y.call(k,M))!==null&&g!==void 0?g:{},D=(m=(v=k.getDropEffect)===null||v===void 0?void 0:v.call(k,M))!==null&&m!==void 0?m:r,K=!!(!((x=k.getIsSticky)===null||x===void 0)&&x.call(k,M)),E={data:N,element:k.element,dropEffect:D,sticky:K};return c({source:b,target:k.element.parentElement,input:C,result:[].concat(NU(I),[E])})}function u(p){var g=p.eventName,y=p.payload,m=Oy(y.location.current.dropTargets),v;try{for(m.s();!(v=m.n()).done;){var x,b=v.value,S=n.get(b.element),C=ll(ll({},y),{},{self:b});S==null||(x=S[g])===null||x===void 0||x.call(S,C)}}catch(w){m.e(w)}finally{m.f()}}var h={onGenerateDragPreview:u,onDrag:u,onDragStart:u,onDrop:u,onDropTargetChange:function(g){var y=g.payload,m=new Set(y.location.current.dropTargets.map(function(V){return V.element})),v=new Set,x=Oy(y.location.previous.dropTargets),b;try{for(x.s();!(b=x.n()).done;){var S,C=b.value;v.add(C.element);var w=n.get(C.element),I=m.has(C.element),R=ll(ll({},y),{},{self:C});if(w==null||(S=w.onDropTargetChange)===null||S===void 0||S.call(w,R),!I){var k;w==null||(k=w.onDragLeave)===null||k===void 0||k.call(w,R)}}}catch(V){x.e(V)}finally{x.f()}var M=Oy(y.location.current.dropTargets),N;try{for(M.s();!(N=M.n()).done;){var D,K,E=N.value;if(!v.has(E.element)){var F=ll(ll({},y),{},{self:E}),z=n.get(E.element);z==null||(D=z.onDropTargetChange)===null||D===void 0||D.call(z,F),z==null||(K=z.onDragEnter)===null||K===void 0||K.call(z,F)}}}catch(V){M.e(V)}finally{M.f()}}};function d(p){h[p.eventName](p)}function f(p){var g=p.source,y=p.target,m=p.input,v=p.current,x=c({source:g,target:y,input:m});if(x.length>=v.length)return x;for(var b=Dy(v),S=Dy(x),C=[],w=0;w<b.length;w++){var I=b[w],R=S[w];if(R!=null){C.push(R);continue}if(!I.sticky)break;var k=C[w-1],M=b[w-1];if(k?.element===M?.element){C.push(I);continue}break}return Dy(C)}return{dropTargetForConsumers:l,getIsOver:f,dispatchEvent:d}}function DU(t,e){var r=typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=FU(t))||e){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(u){throw u},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
367
367
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var s=!0,o=!1,l;return{s:function(){r=r.call(t)},n:function(){var u=r.next();return s=u.done,u},e:function(u){o=!0,l=u},f:function(){try{!s&&r.return!=null&&r.return()}finally{if(o)throw l}}}}function FU(t,e){if(t){if(typeof t=="string")return Hj(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);if(r==="Object"&&t.constructor&&(r=t.constructor.name),r==="Map"||r==="Set")return Array.from(t);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return Hj(t,e)}}function Hj(t,e){(e==null||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function qj(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),r.push.apply(r,n)}return r}function LU(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?qj(Object(r),!0).forEach(function(n){CO(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):qj(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function $U(){var t=new Set,e=null;function r(s){e&&(!s.canMonitor||s.canMonitor(e.canMonitorArgs))&&e.active.add(s)}function n(s){var o=LU({},s);return t.add(o),r(o),function(){t.delete(o),e&&e.active.delete(o)}}function i(s){var o=s.eventName,l=s.payload;if(o==="onGenerateDragPreview"){e={canMonitorArgs:{initial:l.location.initial,source:l.source},active:new Set};var c=DU(t),u;try{for(c.s();!(u=c.n()).done;){var h=u.value;r(h)}}catch(m){c.e(m)}finally{c.f()}}if(e){for(var d=Array.from(e.active),f=0,p=d;f<p.length;f++){var g=p[f];if(e.active.has(g)){var y;(y=g[o])===null||y===void 0||y.call(g,l)}}o==="onDrop"&&(e.active.clear(),e=null)}}return{dispatchEvent:i,monitorForConsumers:n}}function BU(t){var e=t.typeKey,r=t.mount,n=t.dispatchEventToSource,i=t.defaultDropEffect,s=$U(),o=OU({typeKey:e,defaultDropEffect:i});function l(h){n?.(h),o.dispatchEvent(h),s.dispatchEvent(h)}function c(h){var d=h.event,f=h.dragInterface;Bj.start({event:d,dragInterface:f,getDropTargetsOver:o.getIsOver,dispatchEvent:l})}function u(){function h(){var d={canStart:Bj.canStart,start:c};return r(d)}return jU({typeKey:e,mount:h})}return{registerUsage:u,dropTarget:o.dropTargetForConsumers,monitor:s.monitorForConsumers}}var ug=new WeakMap;function zU(t){return ug.set(t.element,t),function(){ug.delete(t.element)}}var LS=BU({typeKey:"element",defaultDropEffect:"move",mount:function(e){return Bm.bind(window,{type:"dragstart",listener:function(n){var i,s,o,l;if(e.canStart(n)){var c=n.target;if(!(c instanceof HTMLElement))return null;var u=ug.get(c);if(!u)return null;var h=FS(n),d={element:u.element,dragHandle:(i=u.dragHandle)!==null&&i!==void 0?i:null,input:h};if(u.canDrag&&!u.canDrag(d))return n.preventDefault(),null;if(u.dragHandle){var f=document.elementFromPoint(h.clientX,h.clientY);if(!u.dragHandle.contains(f))return n.preventDefault(),null}try{var p;(p=n.dataTransfer)===null||p===void 0||p.setData("application/vnd.pdnd","")}catch{}var g={element:u.element,dragHandle:(s=u.dragHandle)!==null&&s!==void 0?s:null,data:(o=(l=u.getInitialData)===null||l===void 0?void 0:l.call(u,d))!==null&&o!==void 0?o:{}},y={key:"element",startedFrom:"internal",payload:g};e.start({event:n,dragInterface:y})}}})},dispatchEventToSource:function(e){var r,n,i=e.eventName,s=e.payload;(r=ug.get(s.source.element))===null||r===void 0||(n=r[i])===null||n===void 0||n.call(r,s)}}),VU=LS.dropTarget,HU=LS.monitor;function qU(t){return IO(LS.registerUsage(),zU(t),_O(t.element,{attribute:"draggable",value:"true"}))}const zm=0,Yo=1,Pc=2,jO=4;function Wj(t){return()=>t}function WU(t){t()}function rh(t,e){return r=>t(e(r))}function Gj(t,e){return()=>t(e)}function GU(t,e){return r=>t(e,r)}function $S(t){return t!==void 0}function UU(...t){return()=>{t.map(WU)}}function Nc(){}function Vm(t,e){return e(t),t}function KU(t,e){return e(t)}function Zt(...t){return t}function kt(t,e){return t(Yo,e)}function Qe(t,e){t(zm,e)}function BS(t){t(Pc)}function Nr(t){return t(jO)}function Fe(t,e){return kt(t,GU(e,zm))}function Ts(t,e){const r=t(Yo,n=>{r(),e(n)});return r}function Uj(t){let e,r;return n=>i=>{e=i,r&&clearTimeout(r),r=setTimeout(()=>{n(e)},t)}}function RO(t,e){return t===e}function Ut(t=RO){let e;return r=>n=>{t(e,n)||(e=n,r(n))}}function Ve(t){return e=>r=>{t(r)&&e(r)}}function Ae(t){return e=>rh(e,t)}function ms(t){return e=>()=>{e(t)}}function ye(t,...e){const r=ZU(...e);return(n,i)=>{switch(n){case Pc:BS(t);return;case Yo:return kt(t,r(i))}}}function Cs(t,e){return r=>n=>{r(e=t(e,n))}}function sc(t){return e=>r=>{t>0?t--:e(r)}}function Co(t){let e=null,r;return n=>i=>{e=i,!r&&(r=setTimeout(()=>{r=void 0,n(e)},t))}}function it(...t){const e=new Array(t.length);let r=0,n=null;const i=Math.pow(2,t.length)-1;return t.forEach((s,o)=>{const l=Math.pow(2,o);kt(s,c=>{const u=r;r=r|l,e[o]=c,u!==i&&r===i&&n&&(n(),n=null)})}),s=>o=>{const l=()=>{s([o].concat(e))};r===i?l():n=l}}function ZU(...t){return e=>t.reduceRight(KU,e)}function YU(t){let e,r;const n=()=>e?.();return function(i,s){switch(i){case Yo:return s?r===s?void 0:(n(),r=s,e=kt(t,s),e):(n(),Nc);case Pc:n(),r=null;return}}}function ve(t){let e=t;const r=gt();return(n,i)=>{switch(n){case zm:e=i;break;case Yo:{i(e);break}case jO:return e}return r(n,i)}}function Xr(t,e){return Vm(ve(e),r=>Fe(t,r))}function gt(){const t=[];return(e,r)=>{switch(e){case zm:t.slice().forEach(n=>{n(r)});return;case Pc:t.splice(0,t.length);return;case Yo:return t.push(r),()=>{const n=t.indexOf(r);n>-1&&t.splice(n,1)}}}}function ni(t){return Vm(gt(),e=>Fe(t,e))}function Ct(t,e=[],{singleton:r}={singleton:!0}){return{constructor:t,dependencies:e,id:XU(),singleton:r}}const XU=()=>Symbol();function JU(t){const e=new Map,r=({constructor:n,dependencies:i,id:s,singleton:o})=>{if(o&&e.has(s))return e.get(s);const l=n(i.map(c=>r(c)));return o&&e.set(s,l),l};return r(t)}function Cr(...t){const e=gt(),r=new Array(t.length);let n=0;const i=Math.pow(2,t.length)-1;return t.forEach((s,o)=>{const l=Math.pow(2,o);kt(s,c=>{r[o]=c,n=n|l,n===i&&Qe(e,r)})}),function(s,o){switch(s){case Pc:{BS(e);return}case Yo:return n===i&&o(r),kt(e,o)}}}function qe(t,e=RO){return ye(t,Ut(e))}function Kj(...t){return function(e,r){switch(e){case Pc:return;case Yo:return UU(...t.map(n=>kt(n,r)))}}}var $n=(t=>(t[t.DEBUG=0]="DEBUG",t[t.INFO=1]="INFO",t[t.WARN=2]="WARN",t[t.ERROR=3]="ERROR",t))($n||{});const QU={0:"debug",3:"error",1:"log",2:"warn"},eK=()=>typeof globalThis>"u"?window:globalThis,Xo=Ct(()=>{const t=ve(3);return{log:ve((e,r,n=1)=>{var i;const s=(i=eK().VIRTUOSO_LOG_LEVEL)!=null?i:Nr(t);n>=s&&console[QU[n]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",e,r)}),logLevel:t}},[],{singleton:!0});function ks(t,e,r){return zS(t,e,r).callbackRef}function zS(t,e,r){const n=Se.useRef(null);let i=o=>{};const s=Se.useMemo(()=>typeof ResizeObserver<"u"?new ResizeObserver(o=>{const l=()=>{const c=o[0].target;c.offsetParent!==null&&t(c)};r?l():requestAnimationFrame(l)}):null,[t,r]);return i=o=>{o&&e?(s?.observe(o),n.current=o):(n.current&&s?.unobserve(n.current),n.current=null)},{callbackRef:i,ref:n}}function TO(t,e,r,n,i,s,o,l,c){const u=Se.useCallback(h=>{const d=tK(h.children,e,l?"offsetWidth":"offsetHeight",i);let f=h.parentElement;for(;!f.dataset.virtuosoScroller;)f=f.parentElement;const p=f.lastElementChild.dataset.viewportType==="window";let g;p&&(g=f.ownerDocument.defaultView);const y=o?l?o.scrollLeft:o.scrollTop:p?l?g.scrollX||g.document.documentElement.scrollLeft:g.scrollY||g.document.documentElement.scrollTop:l?f.scrollLeft:f.scrollTop,m=o?l?o.scrollWidth:o.scrollHeight:p?l?g.document.documentElement.scrollWidth:g.document.documentElement.scrollHeight:l?f.scrollWidth:f.scrollHeight,v=o?l?o.offsetWidth:o.offsetHeight:p?l?g.innerWidth:g.innerHeight:l?f.offsetWidth:f.offsetHeight;n({scrollHeight:m,scrollTop:Math.max(y,0),viewportHeight:v}),s?.(l?Zj("column-gap",getComputedStyle(h).columnGap,i):Zj("row-gap",getComputedStyle(h).rowGap,i)),d!==null&&t(d)},[t,e,i,s,o,n,l]);return zS(u,r,c)}function tK(t,e,r,n){const i=t.length;if(i===0)return null;const s=[];for(let o=0;o<i;o++){const l=t.item(o);if(l.dataset.index===void 0)continue;const c=parseInt(l.dataset.index),u=parseFloat(l.dataset.knownSize),h=e(l,r);if(h===0&&n("Zero-sized element, this should not happen",{child:l},$n.ERROR),h===u)continue;const d=s[s.length-1];s.length===0||d.size!==h||d.endIndex!==c-1?s.push({endIndex:c,size:h,startIndex:c}):s[s.length-1].endIndex++}return s}function Zj(t,e,r){return e!=="normal"&&!(e!=null&&e.endsWith("px"))&&r(`${t} was not resolved to pixel value correctly`,e,$n.WARN),e==="normal"?0:parseInt(e??"0",10)}function VS(t,e,r){const n=Se.useRef(null),i=Se.useCallback(c=>{if(!(c!=null&&c.offsetParent))return;const u=c.getBoundingClientRect(),h=u.width;let d,f;if(e){const p=e.getBoundingClientRect(),g=u.top-p.top;f=p.height-Math.max(0,g),d=g+e.scrollTop}else{const p=o.current.ownerDocument.defaultView;f=p.innerHeight-Math.max(0,u.top),d=u.top+p.scrollY}n.current={offsetTop:d,visibleHeight:f,visibleWidth:h},t(n.current)},[t,e]),{callbackRef:s,ref:o}=zS(i,!0,r),l=Se.useCallback(()=>{i(o.current)},[i,o]);return Se.useEffect(()=>{var c;if(e){e.addEventListener("scroll",l);const u=new ResizeObserver(()=>{requestAnimationFrame(l)});return u.observe(e),()=>{e.removeEventListener("scroll",l),u.unobserve(e)}}else{const u=(c=o.current)==null?void 0:c.ownerDocument.defaultView;return u?.addEventListener("scroll",l),u?.addEventListener("resize",l),()=>{u?.removeEventListener("scroll",l),u?.removeEventListener("resize",l)}}},[l,e,o]),s}const In=Ct(()=>{const t=gt(),e=gt(),r=ve(0),n=gt(),i=ve(0),s=gt(),o=gt(),l=ve(0),c=ve(0),u=ve(0),h=ve(0),d=gt(),f=gt(),p=ve(!1),g=ve(!1),y=ve(!1);return Fe(ye(t,Ae(({scrollTop:m})=>m)),e),Fe(ye(t,Ae(({scrollHeight:m})=>m)),o),Fe(e,i),{deviation:r,fixedFooterHeight:u,fixedHeaderHeight:c,footerHeight:h,headerHeight:l,horizontalDirection:g,scrollBy:f,scrollContainerState:t,scrollHeight:o,scrollingInProgress:p,scrollTo:d,scrollTop:e,skipAnimationFrameInResizeObserver:y,smoothScrollTargetReached:n,statefulScrollTop:i,viewportHeight:s}},[],{singleton:!0}),nh={lvl:0};function kO(t,e){const r=t.length;if(r===0)return[];let{index:n,value:i}=e(t[0]);const s=[];for(let o=1;o<r;o++){const{index:l,value:c}=e(t[o]);s.push({end:l-1,start:n,value:i}),n=l,i=c}return s.push({end:1/0,start:n,value:i}),s}function Ht(t){return t===nh}function ih(t,e){if(!Ht(t))return e===t.k?t.v:e<t.k?ih(t.l,e):ih(t.r,e)}function Ji(t,e,r="k"){if(Ht(t))return[-1/0,void 0];if(Number(t[r])===e)return[t.k,t.v];if(Number(t[r])<e){const n=Ji(t.r,e,r);return n[0]===-1/0?[t.k,t.v]:n}return Ji(t.l,e,r)}function Qn(t,e,r){return Ht(t)?PO(e,r,1):e===t.k?wr(t,{k:e,v:r}):e<t.k?Yj(wr(t,{l:Qn(t.l,e,r)})):Yj(wr(t,{r:Qn(t.r,e,r)}))}function Bl(){return nh}function Hm(t,e,r){if(Ht(t))return[];const n=Ji(t,e)[0];return rK(ob(t,n,r))}function sb(t,e){if(Ht(t))return nh;const{k:r,l:n,r:i}=t;if(e===r){if(Ht(n))return i;if(Ht(i))return n;{const[s,o]=EO(n);return hp(wr(t,{k:s,l:AO(n),v:o}))}}else return e<r?hp(wr(t,{l:sb(n,e)})):hp(wr(t,{r:sb(i,e)}))}function Ca(t){return Ht(t)?[]:[...Ca(t.l),{k:t.k,v:t.v},...Ca(t.r)]}function ob(t,e,r){if(Ht(t))return[];const{k:n,l:i,r:s,v:o}=t;let l=[];return n>e&&(l=l.concat(ob(i,e,r))),n>=e&&n<=r&&l.push({k:n,v:o}),n<=r&&(l=l.concat(ob(s,e,r))),l}function hp(t){const{l:e,lvl:r,r:n}=t;if(n.lvl>=r-1&&e.lvl>=r-1)return t;if(r>n.lvl+1){if(Fy(e))return NO(wr(t,{lvl:r-1}));if(!Ht(e)&&!Ht(e.r))return wr(e.r,{l:wr(e,{r:e.r.l}),lvl:r,r:wr(t,{l:e.r.r,lvl:r-1})});throw new Error("Unexpected empty nodes")}else{if(Fy(t))return ab(wr(t,{lvl:r-1}));if(!Ht(n)&&!Ht(n.l)){const i=n.l,s=Fy(i)?n.lvl-1:n.lvl;return wr(i,{l:wr(t,{lvl:r-1,r:i.l}),lvl:i.lvl+1,r:ab(wr(n,{l:i.r,lvl:s}))})}else throw new Error("Unexpected empty nodes")}}function wr(t,e){return PO(e.k!==void 0?e.k:t.k,e.v!==void 0?e.v:t.v,e.lvl!==void 0?e.lvl:t.lvl,e.l!==void 0?e.l:t.l,e.r!==void 0?e.r:t.r)}function AO(t){return Ht(t.r)?t.l:hp(wr(t,{r:AO(t.r)}))}function Fy(t){return Ht(t)||t.lvl>t.r.lvl}function EO(t){return Ht(t.r)?[t.k,t.v]:EO(t.r)}function PO(t,e,r,n=nh,i=nh){return{k:t,l:n,lvl:r,r:i,v:e}}function Yj(t){return ab(NO(t))}function NO(t){const{l:e}=t;return!Ht(e)&&e.lvl===t.lvl?wr(e,{r:wr(t,{l:e.r})}):t}function ab(t){const{lvl:e,r}=t;return!Ht(r)&&!Ht(r.r)&&r.lvl===e&&r.r.lvl===e?wr(r,{l:wr(t,{r:r.l}),lvl:e+1}):t}function rK(t){return kO(t,({k:e,v:r})=>({index:e,value:r}))}function MO(t,e){return!!(t&&t.startIndex===e.startIndex&&t.endIndex===e.endIndex)}function sh(t,e){return!!(t&&t[0]===e[0]&&t[1]===e[1])}const HS=Ct(()=>({recalcInProgress:ve(!1)}),[],{singleton:!0});function OO(t,e,r){return t[hg(t,e,r)]}function hg(t,e,r,n=0){let i=t.length-1;for(;n<=i;){const s=Math.floor((n+i)/2),o=t[s],l=r(o,e);if(l===0)return s;if(l===-1){if(i-n<2)return s-1;i=s-1}else{if(i===n)return s;n=s+1}}throw new Error(`Failed binary finding record in array - ${t.join(",")}, searched for ${e}`)}function nK(t,e,r,n){const i=hg(t,e,n),s=hg(t,r,n,i);return t.slice(i,s+1)}function Qi(t,e){return Math.round(t.getBoundingClientRect()[e])}function qm(t){return!Ht(t.groupOffsetTree)}function qS({index:t},e){return e===t?0:e<t?-1:1}function iK(){return{groupIndices:[],groupOffsetTree:Bl(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:Bl()}}function sK(t,e){let r=Ht(t)?0:1/0;for(const n of e){const{endIndex:i,size:s,startIndex:o}=n;if(r=Math.min(r,o),Ht(t)){t=Qn(t,0,s);continue}const l=Hm(t,o-1,i+1);if(l.some(dK(n)))continue;let c=!1,u=!1;for(const{end:h,start:d,value:f}of l)c?(i>=d||s===f)&&(t=sb(t,d)):(u=f!==s,c=!0),h>i&&i>=d&&f!==s&&(t=Qn(t,i+1,f));u&&(t=Qn(t,o,s))}return[t,r]}function oK(t){return typeof t.groupIndex<"u"}function aK({offset:t},e){return e===t?0:e<t?-1:1}function oh(t,e,r){if(e.length===0)return 0;const{index:n,offset:i,size:s}=OO(e,t,qS),o=t-n,l=s*o+(o-1)*r+i;return l>0?l+r:l}function DO(t,e){if(!qm(e))return t;let r=0;for(;e.groupIndices[r]<=t+r;)r++;return t+r}function FO(t,e,r){if(oK(t))return e.groupIndices[t.groupIndex]+1;{const n=t.index==="LAST"?r:t.index;let i=DO(n,e);return i=Math.max(0,i,Math.min(r,i)),i}}function lK(t,e,r,n=0){return n>0&&(e=Math.max(e,OO(t,n,qS).offset)),kO(nK(t,e,r,aK),hK)}function cK(t,[e,r,n,i]){e.length>0&&n("received item sizes",e,$n.DEBUG);const s=t.sizeTree;let o=s,l=0;if(r.length>0&&Ht(s)&&e.length===2){const f=e[0].size,p=e[1].size;o=r.reduce((g,y)=>Qn(Qn(g,y,f),y+1,p),o)}else[o,l]=sK(o,e);if(o===s)return t;const{lastIndex:c,lastOffset:u,lastSize:h,offsetTree:d}=lb(t.offsetTree,l,o,i);return{groupIndices:r,groupOffsetTree:r.reduce((f,p)=>Qn(f,p,oh(p,d,i)),Bl()),lastIndex:c,lastOffset:u,lastSize:h,offsetTree:d,sizeTree:o}}function uK(t){return Ca(t).map(({k:e,v:r},n,i)=>{const s=i[n+1];return{endIndex:s?s.k-1:1/0,size:r,startIndex:e}})}function Xj(t,e){let r=0,n=0;for(;r<t;)r+=e[n+1]-e[n]-1,n++;return n-(r===t?0:1)}function lb(t,e,r,n){let i=t,s=0,o=0,l=0,c=0;if(e!==0){c=hg(i,e-1,qS),l=i[c].offset;const u=Ji(r,e-1);s=u[0],o=u[1],i.length&&i[c].size===Ji(r,e)[1]&&(c-=1),i=i.slice(0,c+1)}else i=[];for(const{start:u,value:h}of Hm(r,e,1/0)){const d=u-s,f=d*o+l+d*n;i.push({index:u,offset:f,size:h}),s=u,l=f,o=h}return{lastIndex:s,lastOffset:l,lastSize:o,offsetTree:i}}function hK(t){return{index:t.index,value:t}}function dK(t){const{endIndex:e,size:r,startIndex:n}=t;return i=>i.start===n&&(i.end===e||i.end===1/0)&&i.value===r}const fK={offsetHeight:"height",offsetWidth:"width"},Ds=Ct(([{log:t},{recalcInProgress:e}])=>{const r=gt(),n=gt(),i=Xr(n,0),s=gt(),o=gt(),l=ve(0),c=ve([]),u=ve(void 0),h=ve(void 0),d=ve((C,w)=>Qi(C,fK[w])),f=ve(void 0),p=ve(0),g=iK(),y=Xr(ye(r,it(c,t,p),Cs(cK,g),Ut()),g),m=Xr(ye(c,Ut(),Cs((C,w)=>({current:w,prev:C.current}),{current:[],prev:[]}),Ae(({prev:C})=>C)),[]);Fe(ye(c,Ve(C=>C.length>0),it(y,p),Ae(([C,w,I])=>{const R=C.reduce((k,M,N)=>Qn(k,M,oh(M,w.offsetTree,I)||N),Bl());return{...w,groupIndices:C,groupOffsetTree:R}})),y),Fe(ye(n,it(y),Ve(([C,{lastIndex:w}])=>C<w),Ae(([C,{lastIndex:w,lastSize:I}])=>[{endIndex:w,size:I,startIndex:C}])),r),Fe(u,h);const v=Xr(ye(u,Ae(C=>C===void 0)),!0);Fe(ye(h,Ve(C=>C!==void 0&&Ht(Nr(y).sizeTree)),Ae(C=>[{endIndex:0,size:C,startIndex:0}])),r);const x=ni(ye(r,it(y),Cs(({sizes:C},[w,I])=>({changed:I!==C,sizes:I}),{changed:!1,sizes:g}),Ae(C=>C.changed)));kt(ye(l,Cs((C,w)=>({diff:C.prev-w,prev:w}),{diff:0,prev:0}),Ae(C=>C.diff)),C=>{const{groupIndices:w}=Nr(y);if(C>0)Qe(e,!0),Qe(s,C+Xj(C,w));else if(C<0){const I=Nr(m);I.length>0&&(C-=Xj(-C,I)),Qe(o,C)}}),kt(ye(l,it(t)),([C,w])=>{C<0&&w("`firstItemIndex` prop should not be set to less than zero. If you don't know the total count, just use a very high value",{firstItemIndex:l},$n.ERROR)});const b=ni(s);Fe(ye(s,it(y),Ae(([C,w])=>{const I=w.groupIndices.length>0,R=[],k=w.lastSize;if(I){const M=ih(w.sizeTree,0);let N=0,D=0;for(;N<C;){const E=w.groupIndices[D],F=w.groupIndices.length===D+1?1/0:w.groupIndices[D+1]-E-1;R.push({endIndex:E,size:M,startIndex:E}),R.push({endIndex:E+1+F-1,size:k,startIndex:E+1}),D++,N+=F+1}const K=Ca(w.sizeTree);return N!==C&&K.shift(),K.reduce((E,{k:F,v:z})=>{let V=E.ranges;return E.prevSize!==0&&(V=[...E.ranges,{endIndex:F+C-1,size:E.prevSize,startIndex:E.prevIndex}]),{prevIndex:F+C,prevSize:z,ranges:V}},{prevIndex:C,prevSize:0,ranges:R}).ranges}return Ca(w.sizeTree).reduce((M,{k:N,v:D})=>({prevIndex:N+C,prevSize:D,ranges:[...M.ranges,{endIndex:N+C-1,size:M.prevSize,startIndex:M.prevIndex}]}),{prevIndex:0,prevSize:k,ranges:[]}).ranges})),r);const S=ni(ye(o,it(y,p),Ae(([C,{offsetTree:w},I])=>{const R=-C;return oh(R,w,I)})));return Fe(ye(o,it(y,p),Ae(([C,w,I])=>{if(w.groupIndices.length>0){if(Ht(w.sizeTree))return w;let R=Bl();const k=Nr(m);let M=0,N=0,D=0;for(;M<-C;){D=k[N];const K=k[N+1]-D-1;N++,M+=K+1}if(R=Ca(w.sizeTree).reduce((K,{k:E,v:F})=>Qn(K,Math.max(0,E+C),F),R),M!==-C){const K=ih(w.sizeTree,D);R=Qn(R,0,K);const E=Ji(w.sizeTree,-C+1)[1];R=Qn(R,1,E)}return{...w,sizeTree:R,...lb(w.offsetTree,0,R,I)}}else{const R=Ca(w.sizeTree).reduce((k,{k:M,v:N})=>Qn(k,Math.max(0,M+C),N),Bl());return{...w,sizeTree:R,...lb(w.offsetTree,0,R,I)}}})),y),{beforeUnshiftWith:b,data:f,defaultItemSize:h,firstItemIndex:l,fixedItemSize:u,gap:p,groupIndices:c,itemSize:d,listRefresh:x,shiftWith:o,shiftWithOffset:S,sizeRanges:r,sizes:y,statefulTotalCount:i,totalCount:n,trackItemSizes:v,unshiftWith:s}},Zt(Xo,HS),{singleton:!0});function pK(t){return t.reduce((e,r)=>(e.groupIndices.push(e.totalCount),e.totalCount+=r+1,e),{groupIndices:[],totalCount:0})}const LO=Ct(([{groupIndices:t,sizes:e,totalCount:r},{headerHeight:n,scrollTop:i}])=>{const s=gt(),o=gt(),l=ni(ye(s,Ae(pK)));return Fe(ye(l,Ae(c=>c.totalCount)),r),Fe(ye(l,Ae(c=>c.groupIndices)),t),Fe(ye(Cr(i,e,n),Ve(([c,u])=>qm(u)),Ae(([c,u,h])=>Ji(u.groupOffsetTree,Math.max(c-h,0),"v")[0]),Ut(),Ae(c=>[c])),o),{groupCounts:s,topItemsIndexes:o}},Zt(Ds,In)),Jo=Ct(([{log:t}])=>{const e=ve(!1),r=ni(ye(e,Ve(n=>n),Ut()));return kt(e,n=>{n&&Nr(t)("props updated",{},$n.DEBUG)}),{didMount:r,propsReady:e}},Zt(Xo),{singleton:!0}),gK=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function $O(t){const e=typeof t=="number"?{index:t}:t;return e.align||(e.align="start"),(!e.behavior||!gK)&&(e.behavior="auto"),e.offset||(e.offset=0),e}const Lh=Ct(([{gap:t,listRefresh:e,sizes:r,totalCount:n},{fixedFooterHeight:i,fixedHeaderHeight:s,footerHeight:o,headerHeight:l,scrollingInProgress:c,scrollTo:u,smoothScrollTargetReached:h,viewportHeight:d},{log:f}])=>{const p=gt(),g=gt(),y=ve(0);let m=null,v=null,x=null;function b(){m&&(m(),m=null),x&&(x(),x=null),v&&(clearTimeout(v),v=null),Qe(c,!1)}return Fe(ye(p,it(r,d,n,y,l,o,f),it(t,s,i),Ae(([[S,C,w,I,R,k,M,N],D,K,E])=>{const F=$O(S),{align:z,behavior:V,offset:H}=F,J=I-1,W=FO(F,C,J);let O=oh(W,C.offsetTree,D)+k;z==="end"?(O+=K+Ji(C.sizeTree,W)[1]-w+E,W===J&&(O+=M)):z==="center"?O+=(K+Ji(C.sizeTree,W)[1]-w+E)/2:O-=R,H&&(O+=H);const U=q=>{b(),q?(N("retrying to scroll to",{location:S},$n.DEBUG),Qe(p,S)):(Qe(g,!0),N("list did not change, scroll successful",{},$n.DEBUG))};if(b(),V==="smooth"){let q=!1;x=kt(e,A=>{q=q||A}),m=Ts(h,()=>{U(q)})}else m=Ts(ye(e,mK(150)),U);return v=setTimeout(()=>{b()},1200),Qe(c,!0),N("scrolling from index to",{behavior:V,index:W,top:O},$n.DEBUG),{behavior:V,top:O}})),u),{scrollTargetReached:g,scrollToIndex:p,topListHeight:y}},Zt(Ds,In,Xo),{singleton:!0});function mK(t){return e=>{const r=setTimeout(()=>{e(!1)},t);return n=>{n&&(e(!0),clearTimeout(r))}}}function WS(t,e){t==0?e():requestAnimationFrame(()=>{WS(t-1,e)})}function GS(t,e){const r=e-1;return typeof t=="number"?t:t.index==="LAST"?r:t.index}const $h=Ct(([{defaultItemSize:t,listRefresh:e,sizes:r},{scrollTop:n},{scrollTargetReached:i,scrollToIndex:s},{didMount:o}])=>{const l=ve(!0),c=ve(0),u=ve(!0);return Fe(ye(o,it(c),Ve(([h,d])=>!!d),ms(!1)),l),Fe(ye(o,it(c),Ve(([h,d])=>!!d),ms(!1)),u),kt(ye(Cr(e,o),it(l,r,t,u),Ve(([[,h],d,{sizeTree:f},p,g])=>h&&(!Ht(f)||$S(p))&&!d&&!g),it(c)),([,h])=>{Ts(i,()=>{Qe(u,!0)}),WS(4,()=>{Ts(n,()=>{Qe(l,!0)}),Qe(s,h)})}),{initialItemFinalLocationReached:u,initialTopMostItemIndex:c,scrolledToInitialItem:l}},Zt(Ds,In,Lh,Jo),{singleton:!0});function BO(t,e){return Math.abs(t-e)<1.01}const ah="up",Ru="down",yK="none",xK={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},vK=0,Bh=Ct(([{footerHeight:t,headerHeight:e,scrollBy:r,scrollContainerState:n,scrollTop:i,viewportHeight:s}])=>{const o=ve(!1),l=ve(!0),c=gt(),u=gt(),h=ve(4),d=ve(vK),f=Xr(ye(Kj(ye(qe(i),sc(1),ms(!0)),ye(qe(i),sc(1),ms(!1),Uj(100))),Ut()),!1),p=Xr(ye(Kj(ye(r,ms(!0)),ye(r,ms(!1),Uj(200))),Ut()),!1);Fe(ye(Cr(qe(i),qe(d)),Ae(([x,b])=>x<=b),Ut()),l),Fe(ye(l,Co(50)),u);const g=ni(ye(Cr(n,qe(s),qe(e),qe(t),qe(h)),Cs((x,[{scrollHeight:b,scrollTop:S},C,w,I,R])=>{const k=S+C-b>-R,M={scrollHeight:b,scrollTop:S,viewportHeight:C};if(k){let D,K;return S>x.state.scrollTop?(D="SCROLLED_DOWN",K=x.state.scrollTop-S):(D="SIZE_DECREASED",K=x.state.scrollTop-S||x.scrollTopDelta),{atBottom:!0,atBottomBecause:D,scrollTopDelta:K,state:M}}let N;return M.scrollHeight>x.state.scrollHeight?N="SIZE_INCREASED":C<x.state.viewportHeight?N="VIEWPORT_HEIGHT_DECREASING":S<x.state.scrollTop?N="SCROLLING_UPWARDS":N="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:N,state:M}},xK),Ut((x,b)=>x&&x.atBottom===b.atBottom))),y=Xr(ye(n,Cs((x,{scrollHeight:b,scrollTop:S,viewportHeight:C})=>{if(BO(x.scrollHeight,b))return{changed:!1,jump:0,scrollHeight:b,scrollTop:S};{const w=b-(S+C)<1;return x.scrollTop!==S&&w?{changed:!0,jump:x.scrollTop-S,scrollHeight:b,scrollTop:S}:{changed:!0,jump:0,scrollHeight:b,scrollTop:S}}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),Ve(x=>x.changed),Ae(x=>x.jump)),0);Fe(ye(g,Ae(x=>x.atBottom)),o),Fe(ye(o,Co(50)),c);const m=ve(Ru);Fe(ye(n,Ae(({scrollTop:x})=>x),Ut(),Cs((x,b)=>Nr(p)?{direction:x.direction,prevScrollTop:b}:{direction:b<x.prevScrollTop?ah:Ru,prevScrollTop:b},{direction:Ru,prevScrollTop:0}),Ae(x=>x.direction)),m),Fe(ye(n,Co(50),ms(yK)),m);const v=ve(0);return Fe(ye(f,Ve(x=>!x),ms(0)),v),Fe(ye(i,Co(100),it(f),Ve(([x,b])=>!!b),Cs(([x,b],[S])=>[b,S],[0,0]),Ae(([x,b])=>b-x)),v),{atBottomState:g,atBottomStateChange:c,atBottomThreshold:h,atTopStateChange:u,atTopThreshold:d,isAtBottom:o,isAtTop:l,isScrolling:f,lastJumpDueToItemResize:y,scrollDirection:m,scrollVelocity:v}},Zt(In)),dg="top",fg="bottom",Jj="none";function Qj(t,e,r){return typeof t=="number"?r===ah&&e===dg||r===Ru&&e===fg?t:0:r===ah?e===dg?t.main:t.reverse:e===fg?t.main:t.reverse}function e2(t,e){var r;return typeof t=="number"?t:(r=t[e])!=null?r:0}const US=Ct(([{deviation:t,fixedHeaderHeight:e,headerHeight:r,scrollTop:n,viewportHeight:i}])=>{const s=gt(),o=ve(0),l=ve(0),c=ve(0),u=Xr(ye(Cr(qe(n),qe(i),qe(r),qe(s,sh),qe(c),qe(o),qe(e),qe(t),qe(l)),Ae(([h,d,f,[p,g],y,m,v,x,b])=>{const S=h-x,C=m+v,w=Math.max(f-S,0);let I=Jj;const R=e2(b,dg),k=e2(b,fg);return p-=x,p+=f+v,g+=f+v,g-=x,p>h+C-R&&(I=ah),g<h-w+d+k&&(I=Ru),I!==Jj?[Math.max(S-f-Qj(y,dg,I)-R,0),S-w-v+d+Qj(y,fg,I)+k]:null}),Ve(h=>h!=null),Ut(sh)),[0,0]);return{increaseViewportBy:l,listBoundary:s,overscan:c,topListHeight:o,visibleRange:u}},Zt(In),{singleton:!0});function bK(t,e,r){if(qm(e)){const n=DO(t,e);return[{index:Ji(e.groupOffsetTree,n)[0],offset:0,size:0},{data:r?.[0],index:n,offset:0,size:0}]}return[{data:r?.[0],index:t,offset:0,size:0}]}const Ly={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function dp(t,e,r,n,i,s){const{lastIndex:o,lastOffset:l,lastSize:c}=i;let u=0,h=0;if(t.length>0){u=t[0].offset;const y=t[t.length-1];h=y.offset+y.size}const d=r-o,f=l+d*c+(d-1)*n,p=u,g=f-h;return{bottom:h,firstItemIndex:s,items:t2(t,i,s),offsetBottom:g,offsetTop:u,top:p,topItems:t2(e,i,s),topListHeight:e.reduce((y,m)=>m.size+y,0),totalCount:r}}function zO(t,e,r,n,i,s){let o=0;if(r.groupIndices.length>0)for(const h of r.groupIndices){if(h-o>=t)break;o++}const l=t+o,c=GS(e,l),u=Array.from({length:l}).map((h,d)=>({data:s[d+c],index:d+c,offset:0,size:0}));return dp(u,[],l,i,r,n)}function t2(t,e,r){if(t.length===0)return[];if(!qm(e))return t.map(u=>({...u,index:u.index+r,originalIndex:u.index}));const n=t[0].index,i=t[t.length-1].index,s=[],o=Hm(e.groupOffsetTree,n,i);let l,c=0;for(const u of t){(!l||l.end<u.index)&&(l=o.shift(),c=e.groupIndices.indexOf(l.start));let h;u.index===l.start?h={index:c,type:"group"}:h={groupIndex:c,index:u.index-(c+1)+r},s.push({...h,data:u.data,offset:u.offset,originalIndex:u.index,size:u.size})}return s}const rl=Ct(([{data:t,firstItemIndex:e,gap:r,sizes:n,totalCount:i},s,{listBoundary:o,topListHeight:l,visibleRange:c},{initialTopMostItemIndex:u,scrolledToInitialItem:h},{topListHeight:d},f,{didMount:p},{recalcInProgress:g}])=>{const y=ve([]),m=ve(0),v=gt();Fe(s.topItemsIndexes,y);const x=Xr(ye(Cr(p,g,qe(c,sh),qe(i),qe(n),qe(u),h,qe(y),qe(e),qe(r),t),Ve(([w,I,,R,,,,,,,k])=>{const M=k&&k.length!==R;return w&&!I&&!M}),Ae(([,,[w,I],R,k,M,N,D,K,E,F])=>{const z=k,{offsetTree:V,sizeTree:H}=z,J=Nr(m);if(R===0)return{...Ly,totalCount:R};if(w===0&&I===0)return J===0?{...Ly,totalCount:R}:zO(J,M,k,K,E,F||[]);if(Ht(H))return J>0?null:dp(bK(GS(M,R),z,F),[],R,E,z,K);const W=[];if(D.length>0){const L=D[0],Q=D[D.length-1];let ie=0;for(const Y of Hm(H,L,Q)){const ae=Y.value,pe=Math.max(Y.start,L),G=Math.min(Y.end,Q);for(let Z=pe;Z<=G;Z++)W.push({data:F?.[Z],index:Z,offset:ie,size:ae}),ie+=ae}}if(!N)return dp([],W,R,E,z,K);const O=D.length>0?D[D.length-1]+1:0,U=lK(V,w,I,O);if(U.length===0)return null;const q=R-1,A=Vm([],L=>{for(const Q of U){const ie=Q.value;let Y=ie.offset,ae=Q.start;const pe=ie.size;if(ie.offset<w){ae+=Math.floor((w-ie.offset+E)/(pe+E));const Z=ae-Q.start;Y+=Z*pe+Z*E}ae<O&&(Y+=(O-ae)*pe,ae=O);const G=Math.min(Q.end,q);for(let Z=ae;Z<=G&&!(Y>=I);Z++)L.push({data:F?.[Z],index:Z,offset:Y,size:pe}),Y+=pe+E}});return dp(A,W,R,E,z,K)}),Ve(w=>w!==null),Ut()),Ly);Fe(ye(t,Ve($S),Ae(w=>w?.length)),i),Fe(ye(x,Ae(w=>w.topListHeight)),d),Fe(d,l),Fe(ye(x,Ae(w=>[w.top,w.bottom])),o),Fe(ye(x,Ae(w=>w.items)),v);const b=ni(ye(x,Ve(({items:w})=>w.length>0),it(i,t),Ve(([{items:w},I])=>w[w.length-1].originalIndex===I-1),Ae(([,w,I])=>[w-1,I]),Ut(sh),Ae(([w])=>w))),S=ni(ye(x,Co(200),Ve(({items:w,topItems:I})=>w.length>0&&w[0].originalIndex===I.length),Ae(({items:w})=>w[0].index),Ut())),C=ni(ye(x,Ve(({items:w})=>w.length>0),Ae(({items:w})=>{let I=0,R=w.length-1;for(;w[I].type==="group"&&I<R;)I++;for(;w[R].type==="group"&&R>I;)R--;return{endIndex:w[R].index,startIndex:w[I].index}}),Ut(MO)));return{endReached:b,initialItemCount:m,itemsRendered:v,listState:x,rangeChanged:C,startReached:S,topItemsIndexes:y,...f}},Zt(Ds,LO,US,$h,Lh,Bh,Jo,HS),{singleton:!0}),VO=Ct(([{fixedFooterHeight:t,fixedHeaderHeight:e,footerHeight:r,headerHeight:n},{listState:i}])=>{const s=gt(),o=Xr(ye(Cr(r,t,n,e,i),Ae(([l,c,u,h,d])=>l+c+u+h+d.offsetBottom+d.bottom)),0);return Fe(qe(o),s),{totalListHeight:o,totalListHeightChanged:s}},Zt(In,rl),{singleton:!0}),wK=Ct(([{viewportHeight:t},{totalListHeight:e}])=>{const r=ve(!1),n=Xr(ye(Cr(r,t,e),Ve(([i])=>i),Ae(([,i,s])=>Math.max(0,i-s)),Co(0),Ut()),0);return{alignToBottom:r,paddingTopAddition:n}},Zt(In,VO),{singleton:!0});function r2(t){return t?t==="smooth"?"smooth":"auto":!1}const SK=(t,e)=>typeof t=="function"?r2(t(e)):e&&r2(t),CK=Ct(([{listRefresh:t,totalCount:e,fixedItemSize:r},{atBottomState:n,isAtBottom:i},{scrollToIndex:s},{scrolledToInitialItem:o},{didMount:l,propsReady:c},{log:u},{scrollingInProgress:h}])=>{const d=ve(!1),f=gt();let p=null;function g(m){Qe(s,{align:"end",behavior:m,index:"LAST"})}kt(ye(Cr(ye(qe(e),sc(1)),l),it(qe(d),i,o,h),Ae(([[m,v],x,b,S,C])=>{let w=v&&S,I="auto";return w&&(I=SK(x,b||C),w=w&&!!I),{followOutputBehavior:I,shouldFollow:w,totalCount:m}}),Ve(({shouldFollow:m})=>m)),({followOutputBehavior:m,totalCount:v})=>{p&&(p(),p=null),Nr(r)?requestAnimationFrame(()=>{Nr(u)("following output to ",{totalCount:v},$n.DEBUG),g(m)}):p=Ts(t,()=>{Nr(u)("following output to ",{totalCount:v},$n.DEBUG),g(m),p=null})});function y(m){const v=Ts(n,x=>{m&&!x.atBottom&&x.notAtBottomBecause==="SIZE_INCREASED"&&!p&&(Nr(u)("scrolling to bottom due to increased size",{},$n.DEBUG),g("auto"))});setTimeout(v,100)}return kt(ye(Cr(qe(d),e,c),Ve(([m,,v])=>m&&v),Cs(({value:m},[,v])=>({refreshed:m===v,value:v}),{refreshed:!1,value:0}),Ve(({refreshed:m})=>m),it(d,e)),([,m])=>{Nr(o)&&y(m!==!1)}),kt(f,()=>{y(Nr(d)!==!1)}),kt(Cr(qe(d),n),([m,v])=>{m&&!v.atBottom&&v.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&g("auto")}),{autoscrollToBottom:f,followOutput:d}},Zt(Ds,Bh,Lh,$h,Jo,Xo,In)),_K=Ct(([{data:t,firstItemIndex:e,gap:r,sizes:n},{initialTopMostItemIndex:i},{initialItemCount:s,listState:o},{didMount:l}])=>(Fe(ye(l,it(s),Ve(([,c])=>c!==0),it(i,n,e,r,t),Ae(([[,c],u,h,d,f,p=[]])=>zO(c,u,h,d,f,p))),o),{}),Zt(Ds,$h,rl,Jo),{singleton:!0}),IK=Ct(([{didMount:t},{scrollTo:e},{listState:r}])=>{const n=ve(0);return kt(ye(t,it(n),Ve(([,i])=>i!==0),Ae(([,i])=>({top:i}))),i=>{Ts(ye(r,sc(1),Ve(s=>s.items.length>1)),()=>{requestAnimationFrame(()=>{Qe(e,i)})})}),{initialScrollTop:n}},Zt(Jo,In,rl),{singleton:!0}),jK=({itemBottom:t,itemTop:e,locationParams:{align:r,behavior:n,...i},viewportBottom:s,viewportTop:o})=>e<o?{...i,align:r??"start",behavior:n}:t>s?{...i,align:r??"end",behavior:n}:null,RK=Ct(([{gap:t,sizes:e,totalCount:r},{fixedFooterHeight:n,fixedHeaderHeight:i,headerHeight:s,scrollingInProgress:o,scrollTop:l,viewportHeight:c},{scrollToIndex:u}])=>{const h=gt();return Fe(ye(h,it(e,c,r,s,i,n,l),it(t),Ae(([[d,f,p,g,y,m,v,x],b])=>{const{align:S,behavior:C,calculateViewLocation:w=jK,done:I,...R}=d,k=FO(d,f,g-1),M=oh(k,f.offsetTree,b)+y+m,N=M+Ji(f.sizeTree,k)[1],D=x+m,K=x+p-v,E=w({itemBottom:N,itemTop:M,locationParams:{align:S,behavior:C,...R},viewportBottom:K,viewportTop:D});return E?I&&Ts(ye(o,Ve(F=>!F),sc(Nr(o)?1:2)),I):I&&I(),E}),Ve(d=>d!==null)),u),{scrollIntoView:h}},Zt(Ds,In,Lh,rl,Xo),{singleton:!0}),HO=Ct(([{scrollVelocity:t}])=>{const e=ve(!1),r=gt(),n=ve(!1);return Fe(ye(t,it(n,e,r),Ve(([i,s])=>!!s),Ae(([i,s,o,l])=>{const{enter:c,exit:u}=s;if(o){if(u(i,l))return!1}else if(c(i,l))return!0;return o}),Ut()),e),kt(ye(Cr(e,t,r),it(n)),([[i,s,o],l])=>{i&&l&&l.change&&l.change(s,o)}),{isSeeking:e,scrollSeekConfiguration:n,scrollSeekRangeChanged:r,scrollVelocity:t}},Zt(Bh),{singleton:!0}),KS=Ct(([{scrollContainerState:t,scrollTo:e}])=>{const r=gt(),n=gt(),i=gt(),s=ve(!1),o=ve(void 0);return Fe(ye(Cr(r,n),Ae(([{scrollHeight:l,scrollTop:c,viewportHeight:u},{offsetTop:h}])=>({scrollHeight:l,scrollTop:Math.max(0,c-h),viewportHeight:u}))),t),Fe(ye(e,it(n),Ae(([l,{offsetTop:c}])=>({...l,top:l.top+c}))),i),{customScrollParent:o,useWindowScroll:s,windowScrollContainerState:r,windowScrollTo:i,windowViewportRect:n}},Zt(In)),TK=Ct(([{sizeRanges:t,sizes:e},{headerHeight:r,scrollTop:n},{initialTopMostItemIndex:i},{didMount:s},{useWindowScroll:o,windowScrollContainerState:l,windowViewportRect:c}])=>{const u=gt(),h=ve(void 0),d=ve(null),f=ve(null);return Fe(l,d),Fe(c,f),kt(ye(u,it(e,n,o,d,f,r)),([p,g,y,m,v,x,b])=>{const S=uK(g.sizeTree);m&&v!==null&&x!==null&&(y=v.scrollTop-x.offsetTop),y-=b,p({ranges:S,scrollTop:y})}),Fe(ye(h,Ve($S),Ae(kK)),i),Fe(ye(s,it(h),Ve(([,p])=>p!==void 0),Ut(),Ae(([,p])=>p.ranges)),t),{getState:u,restoreStateFrom:h}},Zt(Ds,In,$h,Jo,KS));function kK(t){return{align:"start",index:0,offset:t.scrollTop}}const AK=Ct(([{topItemsIndexes:t}])=>{const e=ve(0);return Fe(ye(e,Ve(r=>r>=0),Ae(r=>Array.from({length:r}).map((n,i)=>i))),t),{topItemCount:e}},Zt(rl));function qO(t){let e=!1,r;return()=>(e||(e=!0,r=t()),r)}const EK=qO(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),PK=Ct(([{deviation:t,scrollBy:e,scrollingInProgress:r,scrollTop:n},{isAtBottom:i,isScrolling:s,lastJumpDueToItemResize:o,scrollDirection:l},{listState:c},{beforeUnshiftWith:u,gap:h,shiftWithOffset:d,sizes:f},{log:p},{recalcInProgress:g}])=>{const y=ni(ye(c,it(o),Cs(([,v,x,b],[{bottom:S,items:C,offsetBottom:w,totalCount:I},R])=>{const k=S+w;let M=0;return x===I&&v.length>0&&C.length>0&&(C[0].originalIndex===0&&v[0].originalIndex===0||(M=k-b,M!==0&&(M+=R))),[M,C,I,k]},[0,[],0,0]),Ve(([v])=>v!==0),it(n,l,r,i,p,g),Ve(([,v,x,b,,,S])=>!S&&!b&&v!==0&&x===ah),Ae(([[v],,,,,x])=>(x("Upward scrolling compensation",{amount:v},$n.DEBUG),v))));function m(v){v>0?(Qe(e,{behavior:"auto",top:-v}),Qe(t,0)):(Qe(t,0),Qe(e,{behavior:"auto",top:-v}))}return kt(ye(y,it(t,s)),([v,x,b])=>{b&&EK()?Qe(t,x-v):m(-v)}),kt(ye(Cr(Xr(s,!1),t,g),Ve(([v,x,b])=>!v&&!b&&x!==0),Ae(([v,x])=>x),Co(1)),m),Fe(ye(d,Ae(v=>({top:-v}))),e),kt(ye(u,it(f,h),Ae(([v,{groupIndices:x,lastSize:b,sizeTree:S},C])=>{function w(I){return I*(b+C)}if(x.length===0)return w(v);{let I=0;const R=ih(S,0);let k=0,M=0;for(;k<v;){k++,I+=R;let N=x.length===M+1?1/0:x[M+1]-x[M]-1;k+N>v&&(I-=R,N=v-k+1),k+=N,I+=w(N),M++}return I}})),v=>{Qe(t,v),requestAnimationFrame(()=>{Qe(e,{top:v}),requestAnimationFrame(()=>{Qe(t,0),Qe(g,!1)})})}),{deviation:t}},Zt(In,Bh,rl,Ds,Xo,HS)),NK=Ct(([t,e,r,n,i,s,o,l,c,u])=>({...t,...e,...r,...n,...i,...s,...o,...l,...c,...u}),Zt(US,_K,Jo,HO,VO,IK,wK,KS,RK,Xo)),WO=Ct(([{data:t,defaultItemSize:e,firstItemIndex:r,fixedItemSize:n,gap:i,groupIndices:s,itemSize:o,sizeRanges:l,sizes:c,statefulTotalCount:u,totalCount:h,trackItemSizes:d},{initialItemFinalLocationReached:f,initialTopMostItemIndex:p,scrolledToInitialItem:g},y,m,v,{listState:x,topItemsIndexes:b,...S},{scrollToIndex:C},w,{topItemCount:I},{groupCounts:R},k])=>(Fe(S.rangeChanged,k.scrollSeekRangeChanged),Fe(ye(k.windowViewportRect,Ae(M=>M.visibleHeight)),y.viewportHeight),{data:t,defaultItemHeight:e,firstItemIndex:r,fixedItemHeight:n,gap:i,groupCounts:R,initialItemFinalLocationReached:f,initialTopMostItemIndex:p,scrolledToInitialItem:g,sizeRanges:l,topItemCount:I,topItemsIndexes:b,totalCount:h,...v,groupIndices:s,itemSize:o,listState:x,scrollToIndex:C,statefulTotalCount:u,trackItemSizes:d,...S,...k,...y,sizes:c,...m}),Zt(Ds,$h,In,TK,CK,rl,Lh,PK,AK,LO,NK));function MK(t,e){const r={},n={};let i=0;const s=t.length;for(;i<s;)n[t[i]]=1,i+=1;for(const o in e)Object.hasOwn(n,o)||(r[o]=e[o]);return r}const Md=typeof document<"u"?Se.useLayoutEffect:Se.useEffect;function ZS(t,e,r){const n=Object.keys(e.required||{}),i=Object.keys(e.optional||{}),s=Object.keys(e.methods||{}),o=Object.keys(e.events||{}),l=Se.createContext({});function c(m,v){m.propsReady&&Qe(m.propsReady,!1);for(const x of n){const b=m[e.required[x]];Qe(b,v[x])}for(const x of i)if(x in v){const b=m[e.optional[x]];Qe(b,v[x])}m.propsReady&&Qe(m.propsReady,!0)}function u(m){return s.reduce((v,x)=>(v[x]=b=>{const S=m[e.methods[x]];Qe(S,b)},v),{})}function h(m){return o.reduce((v,x)=>(v[x]=YU(m[e.events[x]]),v),{})}const d=Se.forwardRef((m,v)=>{const{children:x,...b}=m,[S]=Se.useState(()=>Vm(JU(t),I=>{c(I,b)})),[C]=Se.useState(Gj(h,S));Md(()=>{for(const I of o)I in b&&kt(C[I],b[I]);return()=>{Object.values(C).map(BS)}},[b,C,S]),Md(()=>{c(S,b)}),Se.useImperativeHandle(v,Wj(u(S)));const w=r;return a.jsx(l.Provider,{value:S,children:r?a.jsx(w,{...MK([...n,...i,...o],b),children:x}):x})}),f=m=>{const v=Se.useContext(l);return Se.useCallback(x=>{Qe(v[m],x)},[v,m])},p=m=>{const v=Se.useContext(l)[m],x=Se.useCallback(b=>kt(v,b),[v]);return Se.useSyncExternalStore(x,()=>Nr(v),()=>Nr(v))},g=m=>{const v=Se.useContext(l)[m],[x,b]=Se.useState(Gj(Nr,v));return Md(()=>kt(v,S=>{S!==x&&b(Wj(S))}),[v,x]),x},y=Se.version.startsWith("18")?p:g;return{Component:d,useEmitter:(m,v)=>{const x=Se.useContext(l)[m];Md(()=>kt(x,v),[v,x])},useEmitterValue:y,usePublisher:f}}const Wm=Se.createContext(void 0),GO=Se.createContext(void 0),UO=typeof document<"u"?Se.useLayoutEffect:Se.useEffect;function $y(t){return"self"in t}function OK(t){return"body"in t}function KO(t,e,r,n=Nc,i,s){const o=Se.useRef(null),l=Se.useRef(null),c=Se.useRef(null),u=Se.useCallback(f=>{let p,g,y;const m=f.target;if(OK(m)||$y(m)){const x=$y(m)?m:m.defaultView;y=s?x.scrollX:x.scrollY,p=s?x.document.documentElement.scrollWidth:x.document.documentElement.scrollHeight,g=s?x.innerWidth:x.innerHeight}else y=s?m.scrollLeft:m.scrollTop,p=s?m.scrollWidth:m.scrollHeight,g=s?m.offsetWidth:m.offsetHeight;const v=()=>{t({scrollHeight:p,scrollTop:Math.max(y,0),viewportHeight:g})};f.suppressFlushSync?v():U8.flushSync(v),l.current!==null&&(y===l.current||y<=0||y===p-g)&&(l.current=null,e(!0),c.current&&(clearTimeout(c.current),c.current=null))},[t,e,s]);Se.useEffect(()=>{const f=i||o.current;return n(i||o.current),u({suppressFlushSync:!0,target:f}),f.addEventListener("scroll",u,{passive:!0}),()=>{n(null),f.removeEventListener("scroll",u)}},[o,u,r,n,i]);function h(f){const p=o.current;if(!p||(s?"offsetWidth"in p&&p.offsetWidth===0:"offsetHeight"in p&&p.offsetHeight===0))return;const g=f.behavior==="smooth";let y,m,v;$y(p)?(m=Math.max(Qi(p.document.documentElement,s?"width":"height"),s?p.document.documentElement.scrollWidth:p.document.documentElement.scrollHeight),y=s?p.innerWidth:p.innerHeight,v=s?window.scrollX:window.scrollY):(m=p[s?"scrollWidth":"scrollHeight"],y=Qi(p,s?"width":"height"),v=p[s?"scrollLeft":"scrollTop"]);const x=m-y;if(f.top=Math.ceil(Math.max(Math.min(x,f.top),0)),BO(y,m)||f.top===v){t({scrollHeight:m,scrollTop:v,viewportHeight:y}),g&&e(!0);return}g?(l.current=f.top,c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{c.current=null,l.current=null,e(!0)},1e3)):l.current=null,s&&(f={behavior:f.behavior,left:f.top}),p.scrollTo(f)}function d(f){s&&(f={behavior:f.behavior,left:f.top}),o.current.scrollBy(f)}return{scrollByCallback:d,scrollerRef:o,scrollToCallback:h}}const By="-webkit-sticky",n2="sticky",ZO=qO(()=>{if(typeof document>"u")return n2;const t=document.createElement("div");return t.style.position=By,t.style.position===By?By:n2});function YS(t){return t}const DK=Ct(()=>{const t=ve(c=>`Item ${c}`),e=ve(null),r=ve(c=>`Group ${c}`),n=ve({}),i=ve(YS),s=ve("div"),o=ve(Nc),l=(c,u=null)=>Xr(ye(n,Ae(h=>h[c]),Ut()),u);return{components:n,computeItemKey:i,context:e,EmptyPlaceholder:l("EmptyPlaceholder"),FooterComponent:l("Footer"),GroupComponent:l("Group","div"),groupContent:r,HeaderComponent:l("Header"),HeaderFooterTag:s,ItemComponent:l("Item","div"),itemContent:t,ListComponent:l("List","div"),ScrollerComponent:l("Scroller","div"),scrollerRef:o,ScrollSeekPlaceholder:l("ScrollSeekPlaceholder"),TopItemListComponent:l("TopItemList")}}),FK=Ct(([t,e])=>({...t,...e}),Zt(WO,DK)),LK=({height:t})=>a.jsx("div",{style:{height:t}}),$K={overflowAnchor:"none",position:ZO(),zIndex:1},YO={overflowAnchor:"none"},BK={...YO,display:"inline-block",height:"100%"},i2=Se.memo(function({showTopList:t=!1}){const e=Ge("listState"),r=wi("sizeRanges"),n=Ge("useWindowScroll"),i=Ge("customScrollParent"),s=wi("windowScrollContainerState"),o=wi("scrollContainerState"),l=i||n?s:o,c=Ge("itemContent"),u=Ge("context"),h=Ge("groupContent"),d=Ge("trackItemSizes"),f=Ge("itemSize"),p=Ge("log"),g=wi("gap"),y=Ge("horizontalDirection"),{callbackRef:m}=TO(r,f,d,t?Nc:l,p,g,i,y,Ge("skipAnimationFrameInResizeObserver")),[v,x]=Se.useState(0);QS("deviation",E=>{v!==E&&x(E)});const b=Ge("EmptyPlaceholder"),S=Ge("ScrollSeekPlaceholder")||LK,C=Ge("ListComponent"),w=Ge("ItemComponent"),I=Ge("GroupComponent"),R=Ge("computeItemKey"),k=Ge("isSeeking"),M=Ge("groupIndices").length>0,N=Ge("alignToBottom"),D=Ge("initialItemFinalLocationReached"),K=t?{}:{boxSizing:"border-box",...y?{display:"inline-block",height:"100%",marginLeft:v!==0?v:N?"auto":0,paddingLeft:e.offsetTop,paddingRight:e.offsetBottom,whiteSpace:"nowrap"}:{marginTop:v!==0?v:N?"auto":0,paddingBottom:e.offsetBottom,paddingTop:e.offsetTop},...D?{}:{visibility:"hidden"}};return!t&&e.totalCount===0&&b?a.jsx(b,{...Kt(b,u)}):a.jsx(C,{...Kt(C,u),"data-testid":t?"virtuoso-top-item-list":"virtuoso-item-list",ref:m,style:K,children:(t?e.topItems:e.items).map(E=>{const F=E.originalIndex,z=R(F+e.firstItemIndex,E.data,u);return k?_.createElement(S,{...Kt(S,u),height:E.size,index:E.index,key:z,type:E.type||"item",...E.type==="group"?{}:{groupIndex:E.groupIndex}}):E.type==="group"?_.createElement(I,{...Kt(I,u),"data-index":F,"data-item-index":E.index,"data-known-size":E.size,key:z,style:$K},h(E.index,u)):_.createElement(w,{...Kt(w,u),...XO(w,E.data),"data-index":F,"data-item-group-index":E.groupIndex,"data-item-index":E.index,"data-known-size":E.size,key:z,style:y?BK:YO},M?c(E.index,E.groupIndex,E.data,u):c(E.index,E.data,u))})})}),zK={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},VK={outline:"none",overflowX:"auto",position:"relative"},Mc=t=>({height:"100%",position:"absolute",top:0,width:"100%",...t?{display:"flex",flexDirection:"column"}:{}}),HK={position:ZO(),top:0,width:"100%",zIndex:1};function Kt(t,e){if(typeof t!="string")return{context:e}}function XO(t,e){return{item:typeof t=="string"?void 0:e}}const qK=Se.memo(function(){const t=Ge("HeaderComponent"),e=wi("headerHeight"),r=Ge("HeaderFooterTag"),n=ks(Se.useMemo(()=>s=>{e(Qi(s,"height"))},[e]),!0,Ge("skipAnimationFrameInResizeObserver")),i=Ge("context");return t?a.jsx(r,{ref:n,children:a.jsx(t,{...Kt(t,i)})}):null}),WK=Se.memo(function(){const t=Ge("FooterComponent"),e=wi("footerHeight"),r=Ge("HeaderFooterTag"),n=ks(Se.useMemo(()=>s=>{e(Qi(s,"height"))},[e]),!0,Ge("skipAnimationFrameInResizeObserver")),i=Ge("context");return t?a.jsx(r,{ref:n,children:a.jsx(t,{...Kt(t,i)})}):null});function XS({useEmitter:t,useEmitterValue:e,usePublisher:r}){return Se.memo(function({children:n,style:i,...s}){const o=r("scrollContainerState"),l=e("ScrollerComponent"),c=r("smoothScrollTargetReached"),u=e("scrollerRef"),h=e("context"),d=e("horizontalDirection")||!1,{scrollByCallback:f,scrollerRef:p,scrollToCallback:g}=KO(o,c,l,u,void 0,d);return t("scrollTo",g),t("scrollBy",f),a.jsx(l,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:p,style:{...d?VK:zK,...i},tabIndex:0,...s,...Kt(l,h),children:n})})}function JS({useEmitter:t,useEmitterValue:e,usePublisher:r}){return Se.memo(function({children:n,style:i,...s}){const o=r("windowScrollContainerState"),l=e("ScrollerComponent"),c=r("smoothScrollTargetReached"),u=e("totalListHeight"),h=e("deviation"),d=e("customScrollParent"),f=e("context"),p=Se.useRef(null),g=e("scrollerRef"),{scrollByCallback:y,scrollerRef:m,scrollToCallback:v}=KO(o,c,l,g,d);return UO(()=>{var x;return m.current=d||((x=p.current)==null?void 0:x.ownerDocument.defaultView),()=>{m.current=null}},[m,d]),t("windowScrollTo",v),t("scrollBy",y),a.jsx(l,{ref:p,"data-virtuoso-scroller":!0,style:{position:"relative",...i,...u!==0?{height:u+h}:{}},...s,...Kt(l,f),children:n})})}const GK=({children:t})=>{const e=Se.useContext(Wm),r=wi("viewportHeight"),n=wi("fixedItemHeight"),i=Ge("alignToBottom"),s=Ge("horizontalDirection"),o=Se.useMemo(()=>rh(r,c=>Qi(c,s?"width":"height")),[r,s]),l=ks(o,!0,Ge("skipAnimationFrameInResizeObserver"));return Se.useEffect(()=>{e&&(r(e.viewportHeight),n(e.itemHeight))},[e,r,n]),a.jsx("div",{"data-viewport-type":"element",ref:l,style:Mc(i),children:t})},UK=({children:t})=>{const e=Se.useContext(Wm),r=wi("windowViewportRect"),n=wi("fixedItemHeight"),i=Ge("customScrollParent"),s=VS(r,i,Ge("skipAnimationFrameInResizeObserver")),o=Ge("alignToBottom");return Se.useEffect(()=>{e&&(n(e.itemHeight),r({offsetTop:0,visibleHeight:e.viewportHeight,visibleWidth:100}))},[e,r,n]),a.jsx("div",{"data-viewport-type":"window",ref:s,style:Mc(o),children:t})},KK=({children:t})=>{const e=Ge("TopItemListComponent")||"div",r=Ge("headerHeight"),n={...HK,marginTop:`${r}px`},i=Ge("context");return a.jsx(e,{style:n,...Kt(e,i),children:t})},ZK=Se.memo(function(t){const e=Ge("useWindowScroll"),r=Ge("topItemsIndexes").length>0,n=Ge("customScrollParent"),i=Ge("context"),s=n||e?JK:XK,o=n||e?UK:GK;return a.jsxs(s,{...t,...Kt(s,i),children:[r&&a.jsx(KK,{children:a.jsx(i2,{showTopList:!0})}),a.jsxs(o,{children:[a.jsx(qK,{}),a.jsx(i2,{}),a.jsx(WK,{})]})]})}),{Component:YK,useEmitter:QS,useEmitterValue:Ge,usePublisher:wi}=ZS(FK,{required:{},optional:{restoreStateFrom:"restoreStateFrom",context:"context",followOutput:"followOutput",itemContent:"itemContent",groupContent:"groupContent",overscan:"overscan",increaseViewportBy:"increaseViewportBy",totalCount:"totalCount",groupCounts:"groupCounts",topItemCount:"topItemCount",firstItemIndex:"firstItemIndex",initialTopMostItemIndex:"initialTopMostItemIndex",components:"components",atBottomThreshold:"atBottomThreshold",atTopThreshold:"atTopThreshold",computeItemKey:"computeItemKey",defaultItemHeight:"defaultItemHeight",fixedItemHeight:"fixedItemHeight",itemSize:"itemSize",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"HeaderFooterTag",data:"data",initialItemCount:"initialItemCount",initialScrollTop:"initialScrollTop",alignToBottom:"alignToBottom",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel",horizontalDirection:"horizontalDirection",skipAnimationFrameInResizeObserver:"skipAnimationFrameInResizeObserver"},methods:{scrollToIndex:"scrollToIndex",scrollIntoView:"scrollIntoView",scrollTo:"scrollTo",scrollBy:"scrollBy",autoscrollToBottom:"autoscrollToBottom",getState:"getState"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",totalListHeightChanged:"totalListHeightChanged",itemsRendered:"itemsRendered",groupIndices:"groupIndices"}},ZK),XK=XS({useEmitter:QS,useEmitterValue:Ge,usePublisher:wi}),JK=JS({useEmitter:QS,useEmitterValue:Ge,usePublisher:wi}),ui=YK,QK=Ct(()=>{const t=ve(c=>a.jsxs("td",{children:["Item $",c]})),e=ve(null),r=ve(null),n=ve(null),i=ve({}),s=ve(YS),o=ve(Nc),l=(c,u=null)=>Xr(ye(i,Ae(h=>h[c]),Ut()),u);return{components:i,computeItemKey:s,context:e,EmptyPlaceholder:l("EmptyPlaceholder"),FillerRow:l("FillerRow"),fixedFooterContent:n,fixedHeaderContent:r,itemContent:t,ScrollerComponent:l("Scroller","div"),scrollerRef:o,ScrollSeekPlaceholder:l("ScrollSeekPlaceholder"),TableBodyComponent:l("TableBody","tbody"),TableComponent:l("Table","table"),TableFooterComponent:l("TableFoot","tfoot"),TableHeadComponent:l("TableHead","thead"),TableRowComponent:l("TableRow","tr")}}),eZ=Ct(([t,e])=>({...t,...e}),Zt(WO,QK)),tZ=({height:t})=>a.jsx("tr",{children:a.jsx("td",{style:{height:t}})}),rZ=({height:t})=>a.jsx("tr",{children:a.jsx("td",{style:{border:0,height:t,padding:0}})}),nZ={overflowAnchor:"none"},s2=Se.memo(function({showTopList:t=!1}){const e=nt("listState"),r=nt("computeItemKey"),n=nt("firstItemIndex"),i=nt("isSeeking"),s=nt("ScrollSeekPlaceholder")||tZ,o=nt("context"),l=nt("TableRowComponent"),c=nt("fixedHeaderHeight"),u=nt("itemContent"),h=(t?e.topItems:[]).reduce((f,p,g)=>(g===0?f.push(p.size):f.push(f[g-1]+p.size),f),[]),d=(t?e.topItems:e.items).map(f=>{const p=f.originalIndex,g=r(p+n,f.data,o),y=t?p===0?0:h[p-1]:0;return i?_.createElement(s,{...Kt(s,o),height:f.size,index:f.index,key:g,type:f.type||"item"}):_.createElement(l,{...Kt(l,o),...XO(l,f.data),"data-index":p,"data-item-index":f.index,"data-known-size":f.size,key:g,style:t?{overflowAnchor:"none",position:"sticky",top:c+y,zIndex:2}:nZ},u(f.index,f.data,o))});return a.jsx(a.Fragment,{children:d})}),iZ=Se.memo(function(){const t=nt("listState"),e=nt("topItemsIndexes").length>0,r=Zi("sizeRanges"),n=nt("useWindowScroll"),i=nt("customScrollParent"),s=Zi("windowScrollContainerState"),o=Zi("scrollContainerState"),l=i||n?s:o,c=nt("trackItemSizes"),u=nt("itemSize"),h=nt("log"),{callbackRef:d,ref:f}=TO(r,u,c,l,h,void 0,i,!1,nt("skipAnimationFrameInResizeObserver")),[p,g]=Se.useState(0);eC("deviation",M=>{p!==M&&(f.current.style.marginTop=`${M}px`,g(M))});const y=nt("EmptyPlaceholder"),m=nt("FillerRow")||rZ,v=nt("TableBodyComponent"),x=nt("paddingTopAddition"),b=nt("statefulTotalCount"),S=nt("context");if(b===0&&y)return a.jsx(y,{...Kt(y,S)});const C=(e?t.topItems:[]).reduce((M,N)=>M+N.size,0),w=t.offsetTop+x+p-C,I=t.offsetBottom,R=w>0?a.jsx(m,{context:S,height:w},"padding-top"):null,k=I>0?a.jsx(m,{context:S,height:I},"padding-bottom"):null;return a.jsxs(v,{"data-testid":"virtuoso-item-list",ref:d,...Kt(v,S),children:[R,e&&a.jsx(s2,{showTopList:!0}),a.jsx(s2,{}),k]})}),sZ=({children:t})=>{const e=Se.useContext(Wm),r=Zi("viewportHeight"),n=Zi("fixedItemHeight"),i=ks(Se.useMemo(()=>rh(r,s=>Qi(s,"height")),[r]),!0,nt("skipAnimationFrameInResizeObserver"));return Se.useEffect(()=>{e&&(r(e.viewportHeight),n(e.itemHeight))},[e,r,n]),a.jsx("div",{"data-viewport-type":"element",ref:i,style:Mc(!1),children:t})},oZ=({children:t})=>{const e=Se.useContext(Wm),r=Zi("windowViewportRect"),n=Zi("fixedItemHeight"),i=nt("customScrollParent"),s=VS(r,i,nt("skipAnimationFrameInResizeObserver"));return Se.useEffect(()=>{e&&(n(e.itemHeight),r({offsetTop:0,visibleHeight:e.viewportHeight,visibleWidth:100}))},[e,r,n]),a.jsx("div",{"data-viewport-type":"window",ref:s,style:Mc(!1),children:t})},aZ=Se.memo(function(t){const e=nt("useWindowScroll"),r=nt("customScrollParent"),n=Zi("fixedHeaderHeight"),i=Zi("fixedFooterHeight"),s=nt("fixedHeaderContent"),o=nt("fixedFooterContent"),l=nt("context"),c=ks(Se.useMemo(()=>rh(n,v=>Qi(v,"height")),[n]),!0,nt("skipAnimationFrameInResizeObserver")),u=ks(Se.useMemo(()=>rh(i,v=>Qi(v,"height")),[i]),!0,nt("skipAnimationFrameInResizeObserver")),h=r||e?uZ:cZ,d=r||e?oZ:sZ,f=nt("TableComponent"),p=nt("TableHeadComponent"),g=nt("TableFooterComponent"),y=s?a.jsx(p,{ref:c,style:{position:"sticky",top:0,zIndex:2},...Kt(p,l),children:s()},"TableHead"):null,m=o?a.jsx(g,{ref:u,style:{bottom:0,position:"sticky",zIndex:1},...Kt(g,l),children:o()},"TableFoot"):null;return a.jsx(h,{...t,...Kt(h,l),children:a.jsx(d,{children:a.jsxs(f,{style:{borderSpacing:0,overflowAnchor:"none"},...Kt(f,l),children:[y,a.jsx(iZ,{},"TableBody"),m]})})})}),{Component:lZ,useEmitter:eC,useEmitterValue:nt,usePublisher:Zi}=ZS(eZ,{required:{},optional:{restoreStateFrom:"restoreStateFrom",context:"context",followOutput:"followOutput",firstItemIndex:"firstItemIndex",itemContent:"itemContent",fixedHeaderContent:"fixedHeaderContent",fixedFooterContent:"fixedFooterContent",overscan:"overscan",increaseViewportBy:"increaseViewportBy",totalCount:"totalCount",topItemCount:"topItemCount",initialTopMostItemIndex:"initialTopMostItemIndex",components:"components",groupCounts:"groupCounts",atBottomThreshold:"atBottomThreshold",atTopThreshold:"atTopThreshold",computeItemKey:"computeItemKey",defaultItemHeight:"defaultItemHeight",fixedItemHeight:"fixedItemHeight",itemSize:"itemSize",scrollSeekConfiguration:"scrollSeekConfiguration",data:"data",initialItemCount:"initialItemCount",initialScrollTop:"initialScrollTop",alignToBottom:"alignToBottom",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel"},methods:{scrollToIndex:"scrollToIndex",scrollIntoView:"scrollIntoView",scrollTo:"scrollTo",scrollBy:"scrollBy",getState:"getState"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",totalListHeightChanged:"totalListHeightChanged",itemsRendered:"itemsRendered",groupIndices:"groupIndices"}},aZ),cZ=XS({useEmitter:eC,useEmitterValue:nt,usePublisher:Zi}),uZ=JS({useEmitter:eC,useEmitterValue:nt,usePublisher:Zi}),hZ=lZ,o2={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},dZ={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:a2,floor:pg,max:Tu,min:zy,round:l2}=Math;function c2(t,e,r){return Array.from({length:e-t+1}).map((n,i)=>({data:r===null?null:r[i+t],index:i+t}))}function fZ(t){return{...dZ,items:t}}function Od(t,e){return t&&t.width===e.width&&t.height===e.height}function pZ(t,e){return t&&t.column===e.column&&t.row===e.row}const gZ=Ct(([{increaseViewportBy:t,listBoundary:e,overscan:r,visibleRange:n},{footerHeight:i,headerHeight:s,scrollBy:o,scrollContainerState:l,scrollTo:c,scrollTop:u,smoothScrollTargetReached:h,viewportHeight:d},f,p,{didMount:g,propsReady:y},{customScrollParent:m,useWindowScroll:v,windowScrollContainerState:x,windowScrollTo:b,windowViewportRect:S},C])=>{const w=ve(0),I=ve(0),R=ve(o2),k=ve({height:0,width:0}),M=ve({height:0,width:0}),N=gt(),D=gt(),K=ve(0),E=ve(null),F=ve({column:0,row:0}),z=gt(),V=gt(),H=ve(!1),J=ve(0),W=ve(!0),O=ve(!1),U=ve(!1);kt(ye(g,it(J),Ve(([Y,ae])=>!!ae)),()=>{Qe(W,!1)}),kt(ye(Cr(g,W,M,k,J,O),Ve(([Y,ae,pe,G,,Z])=>Y&&!ae&&pe.height!==0&&G.height!==0&&!Z)),([,,,,Y])=>{Qe(O,!0),WS(1,()=>{Qe(N,Y)}),Ts(ye(u),()=>{Qe(e,[0,0]),Qe(W,!0)})}),Fe(ye(V,Ve(Y=>Y!=null&&Y.scrollTop>0),ms(0)),I),kt(ye(g,it(V),Ve(([,Y])=>Y!=null)),([,Y])=>{Y&&(Qe(k,Y.viewport),Qe(M,Y.item),Qe(F,Y.gap),Y.scrollTop>0&&(Qe(H,!0),Ts(ye(u,sc(1)),ae=>{Qe(H,!1)}),Qe(c,{top:Y.scrollTop})))}),Fe(ye(k,Ae(({height:Y})=>Y)),d),Fe(ye(Cr(qe(k,Od),qe(M,Od),qe(F,(Y,ae)=>Y&&Y.column===ae.column&&Y.row===ae.row),qe(u)),Ae(([Y,ae,pe,G])=>({gap:pe,item:ae,scrollTop:G,viewport:Y}))),z),Fe(ye(Cr(qe(w),n,qe(F,pZ),qe(M,Od),qe(k,Od),qe(E),qe(I),qe(H),qe(W),qe(J)),Ve(([,,,,,,,Y])=>!Y),Ae(([Y,[ae,pe],G,Z,ne,ce,fe,,xe,$e])=>{const{column:bt,row:xt}=G,{height:_t,width:jt}=Z,{width:or}=ne;if(fe===0&&(Y===0||or===0))return o2;if(jt===0){const Qo=GS($e,Y),il=Qo+Math.max(fe-1,0);return fZ(c2(Qo,il,ce))}const pt=JO(or,jt,bt);let Fr,Er;xe?ae===0&&pe===0&&fe>0?(Fr=0,Er=fe-1):(Fr=pt*pg((ae+xt)/(_t+xt)),Er=pt*a2((pe+xt)/(_t+xt))-1,Er=zy(Y-1,Tu(Er,pt-1)),Fr=zy(Er,Tu(0,Fr))):(Fr=0,Er=-1);const Lr=c2(Fr,Er,ce),{bottom:jn,top:os}=u2(ne,G,Z,Lr),$r=a2(Y/pt),qn=$r*_t+($r-1)*xt-jn;return{bottom:jn,itemHeight:_t,items:Lr,itemWidth:jt,offsetBottom:qn,offsetTop:os,top:os}})),R),Fe(ye(E,Ve(Y=>Y!==null),Ae(Y=>Y.length)),w),Fe(ye(Cr(k,M,R,F),Ve(([Y,ae,{items:pe}])=>pe.length>0&&ae.height!==0&&Y.height!==0),Ae(([Y,ae,{items:pe},G])=>{const{bottom:Z,top:ne}=u2(Y,G,ae,pe);return[ne,Z]}),Ut(sh)),e);const q=ve(!1);Fe(ye(u,it(q),Ae(([Y,ae])=>ae||Y!==0)),q);const A=ni(ye(Cr(R,w),Ve(([{items:Y}])=>Y.length>0),it(q),Ve(([[Y,ae],pe])=>{const G=Y.items[Y.items.length-1].index===ae-1;return(pe||Y.bottom>0&&Y.itemHeight>0&&Y.offsetBottom===0&&Y.items.length===ae)&&G}),Ae(([[,Y]])=>Y-1),Ut())),L=ni(ye(qe(R),Ve(({items:Y})=>Y.length>0&&Y[0].index===0),ms(0),Ut())),Q=ni(ye(qe(R),it(H),Ve(([{items:Y},ae])=>Y.length>0&&!ae),Ae(([{items:Y}])=>({endIndex:Y[Y.length-1].index,startIndex:Y[0].index})),Ut(MO),Co(0)));Fe(Q,p.scrollSeekRangeChanged),Fe(ye(N,it(k,M,w,F),Ae(([Y,ae,pe,G,Z])=>{const ne=$O(Y),{align:ce,behavior:fe,offset:xe}=ne;let $e=ne.index;$e==="LAST"&&($e=G-1),$e=Tu(0,$e,zy(G-1,$e));let bt=cb(ae,Z,pe,$e);return ce==="end"?bt=l2(bt-ae.height+pe.height):ce==="center"&&(bt=l2(bt-ae.height/2+pe.height/2)),xe&&(bt+=xe),{behavior:fe,top:bt}})),c);const ie=Xr(ye(R,Ae(Y=>Y.offsetBottom+Y.bottom)),0);return Fe(ye(S,Ae(Y=>({height:Y.visibleHeight,width:Y.visibleWidth}))),k),{customScrollParent:m,data:E,deviation:K,footerHeight:i,gap:F,headerHeight:s,increaseViewportBy:t,initialItemCount:I,itemDimensions:M,overscan:r,restoreStateFrom:V,scrollBy:o,scrollContainerState:l,scrollHeight:D,scrollTo:c,scrollToIndex:N,scrollTop:u,smoothScrollTargetReached:h,totalCount:w,useWindowScroll:v,viewportDimensions:k,windowScrollContainerState:x,windowScrollTo:b,windowViewportRect:S,...p,gridState:R,horizontalDirection:U,initialTopMostItemIndex:J,totalListHeight:ie,...f,endReached:A,propsReady:y,rangeChanged:Q,startReached:L,stateChanged:z,stateRestoreInProgress:H,...C}},Zt(US,In,Bh,HO,Jo,KS,Xo));function JO(t,e,r){return Tu(1,pg((t+r)/(pg(e)+r)))}function u2(t,e,r,n){const{height:i}=r;if(i===void 0||n.length===0)return{bottom:0,top:0};const s=cb(t,e,r,n[0].index);return{bottom:cb(t,e,r,n[n.length-1].index)+i,top:s}}function cb(t,e,r,n){const i=JO(t.width,r.width,e.column),s=pg(n/i),o=s*r.height+Tu(0,s-1)*e.row;return o>0?o+e.row:o}const mZ=Ct(()=>{const t=ve(d=>`Item ${d}`),e=ve({}),r=ve(null),n=ve("virtuoso-grid-item"),i=ve("virtuoso-grid-list"),s=ve(YS),o=ve("div"),l=ve(Nc),c=(d,f=null)=>Xr(ye(e,Ae(p=>p[d]),Ut()),f),u=ve(!1),h=ve(!1);return Fe(qe(h),u),{components:e,computeItemKey:s,context:r,FooterComponent:c("Footer"),HeaderComponent:c("Header"),headerFooterTag:o,itemClassName:n,ItemComponent:c("Item","div"),itemContent:t,listClassName:i,ListComponent:c("List","div"),readyStateChanged:u,reportReadyState:h,ScrollerComponent:c("Scroller","div"),scrollerRef:l,ScrollSeekPlaceholder:c("ScrollSeekPlaceholder","div")}}),yZ=Ct(([t,e])=>({...t,...e}),Zt(gZ,mZ)),xZ=Se.memo(function(){const t=Xt("gridState"),e=Xt("listClassName"),r=Xt("itemClassName"),n=Xt("itemContent"),i=Xt("computeItemKey"),s=Xt("isSeeking"),o=Si("scrollHeight"),l=Xt("ItemComponent"),c=Xt("ListComponent"),u=Xt("ScrollSeekPlaceholder"),h=Xt("context"),d=Si("itemDimensions"),f=Si("gap"),p=Xt("log"),g=Xt("stateRestoreInProgress"),y=Si("reportReadyState"),m=ks(Se.useMemo(()=>v=>{const x=v.parentElement.parentElement.scrollHeight;o(x);const b=v.firstChild;if(b){const{height:S,width:C}=b.getBoundingClientRect();d({height:S,width:C})}f({column:h2("column-gap",getComputedStyle(v).columnGap,p),row:h2("row-gap",getComputedStyle(v).rowGap,p)})},[o,d,f,p]),!0,!1);return UO(()=>{t.itemHeight>0&&t.itemWidth>0&&y(!0)},[t]),g?null:a.jsx(c,{className:e,ref:m,...Kt(c,h),"data-testid":"virtuoso-item-list",style:{paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},children:t.items.map(v=>{const x=i(v.index,v.data,h);return s?a.jsx(u,{...Kt(u,h),height:t.itemHeight,index:v.index,width:t.itemWidth},x):_.createElement(l,{...Kt(l,h),className:r,"data-index":v.index,key:x},n(v.index,v.data,h))})})}),vZ=Se.memo(function(){const t=Xt("HeaderComponent"),e=Si("headerHeight"),r=Xt("headerFooterTag"),n=ks(Se.useMemo(()=>s=>{e(Qi(s,"height"))},[e]),!0,!1),i=Xt("context");return t?a.jsx(r,{ref:n,children:a.jsx(t,{...Kt(t,i)})}):null}),bZ=Se.memo(function(){const t=Xt("FooterComponent"),e=Si("footerHeight"),r=Xt("headerFooterTag"),n=ks(Se.useMemo(()=>s=>{e(Qi(s,"height"))},[e]),!0,!1),i=Xt("context");return t?a.jsx(r,{ref:n,children:a.jsx(t,{...Kt(t,i)})}):null}),wZ=({children:t})=>{const e=Se.useContext(GO),r=Si("itemDimensions"),n=Si("viewportDimensions"),i=ks(Se.useMemo(()=>s=>{n(s.getBoundingClientRect())},[n]),!0,!1);return Se.useEffect(()=>{e&&(n({height:e.viewportHeight,width:e.viewportWidth}),r({height:e.itemHeight,width:e.itemWidth}))},[e,n,r]),a.jsx("div",{ref:i,style:Mc(!1),children:t})},SZ=({children:t})=>{const e=Se.useContext(GO),r=Si("windowViewportRect"),n=Si("itemDimensions"),i=Xt("customScrollParent"),s=VS(r,i,!1);return Se.useEffect(()=>{e&&(n({height:e.itemHeight,width:e.itemWidth}),r({offsetTop:0,visibleHeight:e.viewportHeight,visibleWidth:e.viewportWidth}))},[e,r,n]),a.jsx("div",{ref:s,style:Mc(!1),children:t})},CZ=Se.memo(function({...t}){const e=Xt("useWindowScroll"),r=Xt("customScrollParent"),n=r||e?IZ:_Z,i=r||e?SZ:wZ,s=Xt("context");return a.jsx(n,{...t,...Kt(n,s),children:a.jsxs(i,{children:[a.jsx(vZ,{}),a.jsx(xZ,{}),a.jsx(bZ,{})]})})}),{useEmitter:QO,useEmitterValue:Xt,usePublisher:Si}=ZS(yZ,{optional:{context:"context",totalCount:"totalCount",overscan:"overscan",itemContent:"itemContent",components:"components",computeItemKey:"computeItemKey",data:"data",initialItemCount:"initialItemCount",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"headerFooterTag",listClassName:"listClassName",itemClassName:"itemClassName",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel",restoreStateFrom:"restoreStateFrom",initialTopMostItemIndex:"initialTopMostItemIndex",increaseViewportBy:"increaseViewportBy"},methods:{scrollTo:"scrollTo",scrollBy:"scrollBy",scrollToIndex:"scrollToIndex"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",stateChanged:"stateChanged",readyStateChanged:"readyStateChanged"}},CZ),_Z=XS({useEmitter:QO,useEmitterValue:Xt,usePublisher:Si}),IZ=JS({useEmitter:QO,useEmitterValue:Xt,usePublisher:Si});function h2(t,e,r){return e!=="normal"&&!(e!=null&&e.endsWith("px"))&&r(`${t} was not resolved to pixel value correctly`,e,$n.WARN),e==="normal"?0:parseInt(e??"0",10)}var jZ=class{_expandedNodes=We.map();_focusedNodes=We.map();_menuOpenNodes=We.map();_settingsOpenNodes=We.map();_dropNodes=We.map();_disabledDropNodes=We.map();_draggedOverNodes=We.map();_focusRequestCounts=We.map();_activeNodeId=null;constructor(){le(this,{},{autoBind:!0})}get activeNodeId(){return this._activeNodeId}setActiveNodeId(t){this._activeNodeId=t}isActive(t){return this._activeNodeId===t}getFocusRequestCount(t){return this._focusRequestCounts.get(t)??0}requestFocus(t){const e=this._focusRequestCounts.get(t)??0;this._focusRequestCounts.set(t,e+1)}isExpanded(t){return this._expandedNodes.get(t)??!0}setExpanded(t,e){this._expandedNodes.set(t,e)}toggleExpanded(t){this._expandedNodes.set(t,!this.isExpanded(t))}isFocused(t){return this._focusedNodes.get(t)??!1}setFocused(t,e){this._focusedNodes.set(t,e)}isMenuOpen(t){return this._menuOpenNodes.get(t)??!1}setMenuOpen(t,e){this._menuOpenNodes.set(t,e)}isSettingsOpen(t){return this._settingsOpenNodes.get(t)??!1}setSettingsOpen(t,e){this._settingsOpenNodes.set(t,e)}isDrop(t){return this._dropNodes.get(t)??!1}setDrop(t,e){this._dropNodes.set(t,e)}isDisabledDrop(t){return this._disabledDropNodes.get(t)??!1}setDisabledDrop(t,e){this._disabledDropNodes.set(t,e)}isDraggedOver(t){return this._draggedOverNodes.get(t)??!1}setDraggedOver(t,e){this._draggedOverNodes.set(t,e)}clearNode(t){this._expandedNodes.delete(t),this._focusedNodes.delete(t),this._menuOpenNodes.delete(t),this._settingsOpenNodes.delete(t),this._dropNodes.delete(t),this._disabledDropNodes.delete(t),this._draggedOverNodes.delete(t),this._focusRequestCounts.delete(t)}collapseAll(t,e){for(const r of t)this._expandedNodes.set(r,!1);if(e){const r=t[0];r!==void 0&&this._expandedNodes.set(r,!0)}}expandAll(t){for(const e of t)this._expandedNodes.set(e,!0)}reset(){this._expandedNodes.clear(),this._focusedNodes.clear(),this._menuOpenNodes.clear(),this._settingsOpenNodes.clear(),this._dropNodes.clear(),this._disabledDropNodes.clear(),this._draggedOverNodes.clear(),this._focusRequestCounts.clear(),this._activeNodeId=null}},RZ=class{state;label;formula;validation;actions;constructor(t,e,r=!1,n=!1){this._node=t,this._isRoot=r,this._isReadonly=n,this.state=e.state,this.label=e.label,this.formula=e.formula,this.validation=e.validation,this.actions=e.actions,le(this,{state:!1,label:!1,formula:!1,validation:!1,actions:!1},{autoBind:!0})}get nodeId(){return this._node.id()}get isRoot(){return this._isRoot}get isReadonly(){return this._isReadonly}get isObject(){return this._node.isObject()}get isArray(){return this._node.isArray()}get isPrimitive(){return this._node.isPrimitive()}get isRef(){return this._node.isRef()}get ref(){if(this._node.isRef())return this._node.ref()}get isForeignKey(){return this.label.isForeignKey}get defaultValue(){return this._node.defaultValue()}get defaultValueAsString(){const t=this.defaultValue;if(t==null)return"";switch(typeof t){case"string":return t;case"number":case"boolean":return String(t);default:return JSON.stringify(t)}}get hoverTargetClass(){return`hover-target-${this.nodeId}`}get shouldApplyFieldStyles(){return!this.state.isFocused&&!this.state.isMenuOpen&&!this.state.isSettingsOpen}get showMenu(){return!this._isReadonly}handleFieldBlur(){this.state.setFocused(!1),!this._node.name()&&!this._isRoot&&this.actions.remove()}},TZ=class{constructor(t,e){this._nodeId=t,this._treeState=e,le(this,{},{autoBind:!0})}get isExpanded(){return this._treeState.isExpanded(this._nodeId)}toggleExpanded(){this._treeState.toggleExpanded(this._nodeId)}get isFocused(){return this._treeState.isFocused(this._nodeId)}setFocused(t){t&&this._treeState.setActiveNodeId(this._nodeId),this._treeState.setFocused(this._nodeId,t)}get isMenuOpen(){return this._treeState.isMenuOpen(this._nodeId)}setMenuOpen(t){t&&this._treeState.setActiveNodeId(this._nodeId),this._treeState.setMenuOpen(this._nodeId,t)}get isSettingsOpen(){return this._treeState.isSettingsOpen(this._nodeId)}setSettingsOpen(t){t&&this._treeState.setActiveNodeId(this._nodeId),this._treeState.setSettingsOpen(this._nodeId,t)}get isDrop(){return this._treeState.isDrop(this._nodeId)}setDrop(t){this._treeState.setDrop(this._nodeId,t)}get isDisabledDrop(){return this._treeState.isDisabledDrop(this._nodeId)}setDisabledDrop(t){this._treeState.setDisabledDrop(this._nodeId,t)}get isDraggedOver(){return this._treeState.isDraggedOver(this._nodeId)}setDraggedOver(t){this._treeState.setDraggedOver(this._nodeId,t)}get isActive(){return this._treeState.isActive(this._nodeId)}activate(){this._treeState.setActiveNodeId(this._nodeId)}get focusRequestCount(){return this._treeState.getFocusRequestCount(this._nodeId)}requestFocus(){this._treeState.requestFocus(this._nodeId)}};const kZ={[Be.RowId]:"id",[Be.RowCreatedId]:"createdId",[Be.RowVersionId]:"versionId",[Be.RowCreatedAt]:"createdAt",[Be.RowPublishedAt]:"publishedAt",[Be.RowUpdatedAt]:"updatedAt",[Be.RowHash]:"hash",[Be.RowSchemaHash]:"schemaHash",[Be.File]:"File"},fs=t=>kZ[t]??t;let Zr=(function(t){return t.String="String",t.Number="Number",t.Boolean="Boolean",t.Object="Object",t.Array="Array",t.ForeignKeyString="ForeignKeyString",t.File="File",t.RowId="RowId",t.RowVersionId="RowVersionId",t.RowCreatedId="RowCreatedId",t.RowCreatedAt="RowCreatedAt",t.RowPublishedAt="RowPublishedAt",t.RowUpdatedAt="RowUpdatedAt",t.RowHash="RowHash",t.RowSchemaHash="RowSchemaHash",t.Markdown="Markdown",t})({});const AZ=[{id:Zr.String,label:"string"},{id:Zr.Number,label:"number"},{id:Zr.Boolean,label:"boolean"},{id:Zr.Object,label:"object"},{id:Zr.Array,label:"array"},{id:Zr.ForeignKeyString,label:"foreign key"}],EZ=[{id:"schemas-submenu",label:"Schemas",type:"submenu",items:[{id:Zr.File,label:fs(Be.File)},{id:Zr.Markdown,label:"Markdown"}]}],PZ=[{id:"system-fields-submenu",label:"System fields",type:"submenu",items:[{id:Zr.RowId,label:fs(Be.RowId)},{id:Zr.RowVersionId,label:fs(Be.RowVersionId)},{id:Zr.RowCreatedId,label:fs(Be.RowCreatedId),addDividerAfter:!0},{id:Zr.RowCreatedAt,label:fs(Be.RowCreatedAt)},{id:Zr.RowPublishedAt,label:fs(Be.RowPublishedAt)},{id:Zr.RowUpdatedAt,label:fs(Be.RowUpdatedAt),addDividerAfter:!0},{id:Zr.RowHash,label:fs(Be.RowHash)},{id:Zr.RowSchemaHash,label:fs(Be.RowSchemaHash)}]}],NZ=[{id:"types",options:AZ,addDividerAfter:!0},{id:"schemas",options:EZ,addDividerAfter:!0},{id:"system-fields",options:PZ}];var MZ=class{constructor(t,e,r){this._node=t,this._getTableId=e,this._isRoot=r,le(this,{},{autoBind:!0})}get name(){return this._isRoot?this._getTableId():this._node.name()}get nodeType(){return this._node.nodeType()}get typeLabel(){return this._node.isRef()?this.getRefLabel():this._node.isObject()?"object":this._node.isArray()?"array":this._node.foreignKey()!==void 0?"ForeignKey":this._node.contentMediaType?.()==="text/markdown"?"Markdown":this._node.nodeType()}get description(){return this._node.metadata().description}get isDeprecated(){return this._node.metadata().deprecated??!1}get foreignKeyTable(){return this._node.foreignKey()}get isForeignKey(){return this._node.foreignKey()!==void 0}getRefLabel(){const t=this._node.ref();return t?fs(t):"Ref"}},OZ=class{_inputValue=null;_inputError=null;constructor(t,e){this._node=t,this._schemaModel=e,le(this,{},{autoBind:!0})}get hasFormula(){return this._node.hasFormula()}get plainSchema(){return this._schemaModel.plainSchema}get rawExpression(){return this._node.formula()?.expression()??""}get formula(){if(this._inputValue!==null)return this._inputValue;if(!this.hasFormula)return"";const t=this._schemaModel.serializeFormula(this._node.id());return t||this.rawExpression}get inputValue(){return this._inputValue}get inputError(){return this._inputError}get schemaError(){return this._schemaModel.formulaErrors.find(t=>t.nodeId===this._node.id())?.message}get hasError(){return this._inputError!==null||this.schemaError!==void 0}get errorMessage(){return this._inputError??this.schemaError}setInputValue(t){this._inputValue=t,this._inputError=null}clearInput(){this._inputValue=null,this._inputError=null}hasFormulaErrorForNode(){return this._schemaModel.formulaErrors.some(t=>t.nodeId===this._node.id())}applyFormula(){if(this._inputValue===null)return!0;const t=this._inputValue.trim();try{return this._schemaModel.updateFormula(this._node.id(),t||void 0),this.hasFormulaErrorForNode()?!1:(this.clearInput(),!0)}catch(e){return me(()=>{this._inputError=e instanceof Error?e.message:"Invalid formula"}),!1}}},DZ=class{constructor(t,e,r,n,i){this._node=t,this._schemaModel=e,this._formula=r,this._getTableIdError=n,this._isRoot=i,le(this,{},{autoBind:!0})}get schemaError(){return this._schemaModel.validationErrors.find(t=>t.nodeId===this._node.id())?.message}get tableIdError(){return this._isRoot?this._getTableIdError():null}get formulaError(){return this._formula.errorMessage}get hasError(){return this.schemaError!==void 0||this.tableIdError!==null||this.formulaError!==void 0}get errorMessage(){return this.schemaError??this.tableIdError??this.formulaError}};const FZ={String:"string",Number:"number",Boolean:"boolean",Object:"object",Array:"array"};function ub(t){return FZ[t]??null}var LZ=class{constructor(t,e,r,n,i){this._node=t,this._schemaModel=e,this._callbacks=r,this._isRoot=n,this._isReadonly=i,le(this,{},{autoBind:!0})}get canRemove(){return!this._isReadonly&&!this._isRoot}get canAddProperty(){return!this._isReadonly&&this._node.isObject()}rename(t){if(!this._isReadonly){if(this._isRoot){this._callbacks.renameTable(t);return}t!==this._node.name()&&this._schemaModel.renameField(this._node.id(),t)}}changeType(t){if(this._isReadonly||this._isRoot)return;if(t==="ForeignKeyString"){this.changeToForeignKey();return}if(t==="Markdown"){this.changeToMarkdown();return}const e=this.typeIdToRefUri(t);if(e){const s=this._node.id(),o=this._schemaModel.changeFieldType(s,{$ref:e});o.isNull()||this._callbacks.onNodeReplaced(s,o.id());return}const r=ub(t);if(!r)return;const n=this._node.id(),i=this._schemaModel.changeFieldType(n,r);i.isNull()||(this._schemaModel.updateForeignKey(i.id(),void 0),this._callbacks.onNodeReplaced(n,i.id()))}changeToForeignKey(){const t=this._node.id();let e=t;this._node.nodeType()!=="string"&&(e=this._schemaModel.changeFieldType(t,"string").id()),this._schemaModel.updateForeignKey(e,""),this._callbacks.onNodeReplaced(t,e)}changeToMarkdown(){const t=this._node.id();let e=this._node;e.nodeType()!=="string"&&(e=this._schemaModel.changeFieldType(t,"string")),e.setContentMediaType("text/markdown"),this._callbacks.onNodeReplaced(t,e.id())}remove(){if(this._isReadonly||this._isRoot)return;const t=this._node.id();this._schemaModel.removeField(t)&&this._callbacks.onNodeRemoved(t)}addProperty(t=""){if(this._isReadonly||!this._node.isObject())return null;const e=this._schemaModel.addField(this._node.id(),t,"string");return e.isNull()?null:(this._callbacks.onNodeAdded(e.id()),e)}insertFieldAt(t,e){if(this._isReadonly||!this._node.isObject())return null;const r=this._schemaModel.insertFieldAt(this._node.id(),t,e,"string");return r.isNull()?null:(this._callbacks.onNodeAdded(r.id()),r)}setDescription(t){this._isReadonly||this._schemaModel.updateMetadata(this._node.id(),{description:t||void 0})}setDeprecated(t){this._isReadonly||this._schemaModel.updateMetadata(this._node.id(),{deprecated:t||void 0})}setDefaultValue(t){this._isReadonly||this._schemaModel.updateDefaultValue(this._node.id(),t)}setForeignKey(t){if(!this._isReadonly){if(t===void 0){this._schemaModel.updateForeignKey(this._node.id(),void 0);return}if(this._node.foreignKey()===void 0){const e=this._node.id();if(this._node.nodeType()!=="string"){const r=this._schemaModel.changeFieldType(e,"string");this._schemaModel.updateForeignKey(r.id(),t),this._callbacks.onNodeReplaced(e,r.id())}else this._schemaModel.updateForeignKey(e,t)}else this._schemaModel.updateForeignKey(this._node.id(),t)}}changeItemsType(t){if(this._isReadonly||!this._node.isArray())return;const e=this._node.items();if(e.isNull())return;const r=e.id();if(t==="ForeignKeyString"){this.changeItemsToForeignKey(e,r);return}if(t==="Markdown"){this.changeItemsToMarkdown(e,r);return}const n=this.typeIdToRefUri(t);if(n){const o=this._schemaModel.changeFieldType(r,{$ref:n});o.isNull()||this._callbacks.onNodeReplaced(r,o.id());return}const i=ub(t);if(!i)return;const s=this._schemaModel.changeFieldType(r,i);s.isNull()||(this._schemaModel.updateForeignKey(s.id(),void 0),this._callbacks.onNodeReplaced(r,s.id()))}changeItemsToForeignKey(t,e){let r=e;t.nodeType()!=="string"&&(r=this._schemaModel.changeFieldType(e,"string").id()),this._schemaModel.updateForeignKey(r,""),this._callbacks.onNodeReplaced(e,r)}changeItemsToMarkdown(t,e){let r=t;t.nodeType()!=="string"&&(r=this._schemaModel.changeFieldType(e,"string")),r.setContentMediaType("text/markdown"),this._callbacks.onNodeReplaced(e,r.id())}async selectForeignKey(){const t=await this._callbacks.selectForeignKey();t!==null&&this.setForeignKey(t)}typeIdToRefUri(t){return{File:Be.File,RowId:Be.RowId,RowCreatedId:Be.RowCreatedId,RowVersionId:Be.RowVersionId,RowCreatedAt:Be.RowCreatedAt,RowPublishedAt:Be.RowPublishedAt,RowUpdatedAt:Be.RowUpdatedAt,RowHash:Be.RowHash,RowSchemaHash:Be.RowSchemaHash}[t]??null}},$Z=class{create(t,e,r=!1,n=!1){const i=new TZ(t.id(),e.treeState),s=new MZ(t,e.getTableId,r),o=new OZ(t,e.schemaModel);return new RZ(t,{state:i,label:s,formula:o,validation:new DZ(t,e.schemaModel,o,e.getTableIdError,r),actions:new LZ(t,e.schemaModel,e.callbacks,r,n)},r,n)}},BZ=class{_cache=new Map;constructor(t,e,r){this._getSchemaModel=t,this._getContext=e,this._accessorFactory=r}get(t,e=!1,r=!1){const n=this._cache.get(t);if(n)return n;const i=this._getSchemaModel().nodeById(t),s=this._accessorFactory.create(i,this._getContext(),e,r);return this._cache.set(t,s),s}getChildren(t,e=!1){const r=this._getSchemaModel().nodeById(t);if(r.isNull())return[];const n=e||r.isRef();if(r.isObject())return r.properties().map(i=>this.get(i.id(),!1,n));if(r.isArray()){const i=r.items();if(!i.isNull())return[this.get(i.id(),!1,n)]}return[]}delete(t){this._cache.delete(t)}clear(){this._cache.clear()}entries(){return this._cache.entries()}},zZ=class{constructor(t,e,r){this._tableModel=t,this._accessorCache=e,this._getTableIdError=r,le(this,{},{autoBind:!0})}get validationErrors(){return this._tableModel.schema.validationErrors}get formulaErrors(){const t=this._tableModel.schema.formulaErrors,e=this.collectFormulaInputErrors();return[...t,...e]}get tableIdError(){return this._getTableIdError()}get hasErrors(){return this.validationErrors.length>0||this.formulaErrors.length>0||this.tableIdError!==null}get errorsCount(){let t=this.validationErrors.length+this.formulaErrors.length;return this.tableIdError!==null&&(t+=1),t}collectFormulaInputErrors(){const t=[];for(const[e,r]of this._accessorCache.entries()){const n=r.formula.inputError;n&&t.push({nodeId:e,fieldPath:r.label.name||void 0,message:n})}return t}},VZ=class{_viewMode="Tree";_loading=!1;constructor(){le(this,{},{autoBind:!0})}get viewMode(){return this._viewMode}setViewMode(t){this._viewMode=t}get loading(){return this._loading}setLoading(t){this._loading=t}};const HZ=[{fromType:"number",toType:"string",example:{before:123,after:"123"},dataLossSeverity:"none",stepName:"number → string"},{fromType:"boolean",toType:"string",example:{before:!0,after:"true"},dataLossSeverity:"none",stepName:"boolean → string"},{fromType:"boolean",toType:"number",example:{before:!0,after:1},dataLossSeverity:"none",stepName:"boolean → number"},{fromType:"string",toType:"number",example:{before:"123",after:123},dataLossSeverity:"possible",stepName:"string → number"},{fromType:"string",toType:"boolean",example:{before:"hello",after:!0},dataLossSeverity:"possible",stepName:"string → boolean"},{fromType:"number",toType:"boolean",example:{before:42,after:!0},dataLossSeverity:"possible",stepName:"number → boolean"},{fromType:"object",toType:"string",example:{before:{a:1},after:""},dataLossSeverity:"certain",stepName:"object → string"},{fromType:"object",toType:"number",example:{before:{a:1},after:0},dataLossSeverity:"certain",stepName:"object → number"},{fromType:"object",toType:"boolean",example:{before:{a:1},after:!1},dataLossSeverity:"certain",stepName:"object → boolean"},{fromType:"array",toType:"string",example:{before:["a","b"],after:"a"},dataLossSeverity:"possible",stepName:"array → string (first element)"},{fromType:"array",toType:"number",example:{before:[1,2],after:1},dataLossSeverity:"possible",stepName:"array → number (first element)"},{fromType:"array",toType:"boolean",example:{before:[!0,!1],after:!0},dataLossSeverity:"possible",stepName:"array → boolean (first element)"},{fromType:"string",toType:"object",example:{before:"hello",after:{}},dataLossSeverity:"certain",stepName:"string → object"},{fromType:"number",toType:"object",example:{before:42,after:{}},dataLossSeverity:"certain",stepName:"number → object"},{fromType:"boolean",toType:"object",example:{before:!0,after:{}},dataLossSeverity:"certain",stepName:"boolean → object"},{fromType:"string",toType:"array",example:{before:"hello",after:["hello"]},dataLossSeverity:"none",stepName:"wrap in array"},{fromType:"number",toType:"array",example:{before:42,after:[42]},dataLossSeverity:"none",stepName:"wrap in array"},{fromType:"boolean",toType:"array",example:{before:!0,after:[!0]},dataLossSeverity:"none",stepName:"wrap in array"},{fromType:"object",toType:"array",example:{before:{a:1},after:[]},dataLossSeverity:"certain",stepName:"object → array"},{fromType:"array",toType:"object",example:{before:[1,2],after:{}},dataLossSeverity:"certain",stepName:"array → object"}],e4={string:"hello",number:42,boolean:!0,object:{a:1},array:[1,2],ref:null,unknown:null},qZ=new Set(["string","number","boolean","object","array","ref","unknown"]);function d2(t){return qZ.has(t)?t:"unknown"}function f2(t){const e=/^array<(.+)>$/.exec(t);return e?.[1]?{baseType:"array",itemsType:d2(e[1])}:{baseType:d2(t)}}function t4(t,e){return t===e?null:HZ.find(r=>r.fromType===t&&r.toType===e)??null}function r4(t,e,r){if(e===r)return t;switch(r){case"string":return String(t);case"number":return typeof t=="boolean"?t?1:0:typeof t=="number"?t:0;case"boolean":return!!t;default:return t}}function Vy(t,e){if(t===e)return"none";const r=t4(t,e);return r?r.dataLossSeverity:"certain"}function WZ(t,e){const r=["none","possible","certain"];return r[Math.max(r.indexOf(t),r.indexOf(e))]??"certain"}function p2(t){return t.reduce((e,r)=>WZ(e,r.dataLossSeverity),"none")}function Hy(t){const{fromType:e,toType:r,fromItemsType:n,toItemsType:i}=t,s=[];if(r==="array"&&i!==void 0&&e!=="array"&&e!=="object"){if(s.push({name:"wrap in array",dataLossSeverity:"none"}),e!==i){const o=Vy(e,i);s.push({name:`${e} → ${i}`,dataLossSeverity:o})}}else if(e==="array"&&n!==void 0&&r!=="array"&&r!=="object"){if(s.push({name:"unwrap array (first element)",dataLossSeverity:"possible"}),n!==r){const o=Vy(n,r);s.push({name:`${n} → ${r}`,dataLossSeverity:o})}}else if(e==="object"||r==="object"||e==="array"||r==="array")s.push({name:`${e} → ${r}`,dataLossSeverity:"certain"});else{const o=Vy(e,r);s.push({name:`${e} → ${r}`,dataLossSeverity:o})}return s}function GZ(t,e){const r=e4[t];return{before:r,after:[r4(r,t,e)]}}function UZ(t,e){const r=e4[t];return{before:[r,r],after:r4(r,t,e)}}function KZ(t,e){if(t===e)return null;const r=f2(t),n=f2(e);if(r.baseType==="unknown"||n.baseType==="unknown")return null;if(n.baseType==="array"&&n.itemsType&&r.baseType!=="array"&&r.baseType!=="object"){const s=GZ(r.baseType,n.itemsType),o=Hy({fromType:r.baseType,toType:n.baseType,toItemsType:n.itemsType});return{fromType:t,toType:e,example:s,dataLossSeverity:p2(o),steps:o}}if(r.baseType==="array"&&r.itemsType&&n.baseType!=="array"&&n.baseType!=="object"){const s=UZ(r.itemsType,n.baseType),o=Hy({fromType:r.baseType,toType:n.baseType,fromItemsType:r.itemsType});return{fromType:t,toType:e,example:s,dataLossSeverity:p2(o),steps:o}}const i=t4(r.baseType,n.baseType);if(i){const s=Hy({fromType:r.baseType,toType:n.baseType});return{fromType:t,toType:e,example:i.example,dataLossSeverity:i.dataLossSeverity,steps:s}}return{fromType:t,toType:e,example:{before:"?",after:"?"},dataLossSeverity:"certain",steps:[{name:`${r.baseType} → ${n.baseType}`,dataLossSeverity:"certain"}]}}function ZZ(t){return t.$ref?"ref":t.type?t.type:"unknown"}function YZ(t){if(t.type==="string"&&t.foreignKey)return t.foreignKey||void 0}function XZ(t){if(t.value===void 0)return null;const e=t.value;return{value:Bw(t.value,{arrayItemCount:1}),type:ZZ(e),foreignKeyTableId:YZ(e)}}function gg(t,e){if(!t.isNull()){if(e(t),t.isObject())for(const r of t.properties())gg(r,e);else if(t.isArray()){const r=t.items();r.isNull()||gg(r,e)}}}var JZ=class{constructor(t,e){this._getSchemaModel=t,this._treeState=e}visibleNodeIds(){const t=this._getSchemaModel().root;if(t.isNull())return[];const e=[];return this.collectVisibleNodes(t,e,!0),e}findParentId(t){const e=this._getSchemaModel().root;return e.isNull()?null:this.findParentInTree(e,t)}isRootId(t){return this._getSchemaModel().root.id()===t}getNode(t){return this._getSchemaModel().nodeById(t)}nodeHasChildren(t){return t.isObject()?t.properties().length>0:t.isArray()?!t.items().isNull():!1}getFirstChildId(t){if(t.isObject()){const e=t.properties()[0];if(e)return e.id()}else if(t.isArray()){const e=t.items();if(!e.isNull())return e.id()}return null}collectVisibleNodes(t,e,r){if(!t.isNull()&&(e.push(t.id()),!(!r&&!this._treeState.isExpanded(t.id())))){if(t.isObject())for(const n of t.properties())this.collectVisibleNodes(n,e,!1);else if(t.isArray()){const n=t.items();n.isNull()||this.collectVisibleNodes(n,e,!1)}}}findParentInTree(t,e){return t.isNull()?null:t.isObject()?this.findParentInObject(t,e):t.isArray()?this.findParentInArray(t,e):null}findParentInObject(t,e){for(const r of t.properties()){if(r.id()===e)return t.id();const n=this.findParentInTree(r,e);if(n)return n}return null}findParentInArray(t,e){const r=t.items();return r.isNull()?null:r.id()===e?t.id():this.findParentInTree(r,e)}},QZ=class{constructor(t,e){this._treeState=t,this._getSchemaModel=e,le(this,{},{autoBind:!0})}collapseAll(){const t=this.collectAllNodeIds();this._treeState.collapseAll(t,!0)}expandAll(){const t=this.collectAllNodeIds();this._treeState.expandAll(t)}collapseIfComplex(t){this._getSchemaModel().nodeCount>=t&&this.collapseAll()}collapseRefNodes(){const t=this.collectRefNodeIds();for(const e of t)this._treeState.setExpanded(e,!1)}collectRefNodeIds(){const t=[];return gg(this._getSchemaModel().root,e=>{e.isRef()&&(e.isObject()||e.isArray())&&t.push(e.id())}),t}collectAllNodeIds(){const t=[];return gg(this._getSchemaModel().root,e=>{t.push(e.id())}),t}},eY=class{_mode="TREE_NAV";_skipNextEscape=!1;_suppressNextReturnFocus=!1;_containerRef=null;_disposers=[];constructor(t,e,r){this._treeState=t,this._navigator=e,this._accessors=r,le(this,{},{autoBind:!0}),this._disposers.push(bn(()=>{const n=this._treeState.activeNodeId;return n?this._treeState.isFocused(n):!1},(n,i)=>{n&&!i&&(this._mode="EDIT_NAME"),!n&&i&&(this._mode="TREE_NAV",this._skipNextEscape=!0,this._suppressNextReturnFocus?this._suppressNextReturnFocus=!1:this.deferReturnFocus())}))}get mode(){return this._mode}get visibleNodeIds(){return this._navigator.visibleNodeIds()}handleKeyDown(t){if(this._mode==="TREE_NAV"){if(t.key!=="Escape"&&(this._skipNextEscape=!1),t.key==="Tab"&&t.shiftKey){t.preventDefault(),this.moveToPrev();return}switch(t.key){case"ArrowDown":case"Tab":t.preventDefault(),this.moveToNext();return;case"ArrowUp":t.preventDefault(),this.moveToPrev();return;case"ArrowRight":t.preventDefault(),this.expandOrMoveToChild();return;case"ArrowLeft":t.preventDefault(),this.collapseOrMoveToParent();return;case" ":t.preventDefault(),this.toggleExpand();return;case"Enter":case"F2":case"i":t.preventDefault(),this.enterEditMode();return;case"Insert":t.preventDefault(),this.insertField();return;case"Delete":case"Backspace":t.preventDefault(),this.removeNode();return;case"Escape":if(t.preventDefault(),this._skipNextEscape){this._skipNextEscape=!1;return}this.deactivateOrRemoveEmpty();return}}}setContainerRef(t){this._containerRef&&!t&&document.removeEventListener("mousedown",this.handleNativeMouseDown),this._containerRef=t,this._containerRef&&document.addEventListener("mousedown",this.handleNativeMouseDown)}returnFocus(){this._containerRef&&!this._containerRef.contains(document.activeElement)&&this._containerRef.focus()}deactivate(){this._treeState.setActiveNodeId(null)}handleNativeMouseDown=t=>{this._skipNextEscape=!1;const e=t.target;if(e instanceof HTMLElement){if(this._containerRef?.contains(e)){this._suppressNextReturnFocus=!0,e.closest("[data-node-id]")||this._treeState.setActiveNodeId(null);return}e.closest('[role="menu"], [role="listbox"], [role="dialog"]')?this._suppressNextReturnFocus=!0:this._treeState.setActiveNodeId(null)}};handleEditEnter(){this.insertField()}handleNodeAdded(t){this._treeState.setActiveNodeId(t)}handleNodeReplaced(t,e){this._treeState.activeNodeId===t&&(this._treeState.setActiveNodeId(e),this._mode==="EDIT_NAME"&&(this._mode="TREE_NAV"),this.deferReturnFocus())}deferReturnFocus(){setTimeout(()=>this.returnFocus(),0)}dispose(){for(const t of this._disposers)t();this._disposers.length=0,this.setContainerRef(null)}moveToNext(){const t=this.visibleNodeIds;if(t.length===0)return;const e=this._treeState.activeNodeId;if(!e){const i=t[0];i!==void 0&&(this._treeState.setActiveNodeId(i),this.scrollToNode(i));return}const r=t.indexOf(e);if(r===-1||r>=t.length-1)return;const n=t[r+1];n!==void 0&&(this._treeState.setActiveNodeId(n),this.scrollToNode(n))}moveToPrev(){const t=this.visibleNodeIds;if(t.length===0)return;const e=this._treeState.activeNodeId;if(!e){const i=t.at(-1);i!==void 0&&(this._treeState.setActiveNodeId(i),this.scrollToNode(i));return}const r=t.indexOf(e);if(r<=0)return;const n=t[r-1];n!==void 0&&(this._treeState.setActiveNodeId(n),this.scrollToNode(n))}expandOrMoveToChild(){const t=this._treeState.activeNodeId;if(!t)return;const e=this._navigator.getNode(t);if(e.isNull()||!this._navigator.nodeHasChildren(e))return;if(!this._navigator.isRootId(t)&&!this._treeState.isExpanded(t)){this._treeState.setExpanded(t,!0);return}const r=this._navigator.getFirstChildId(e);r&&(this._treeState.setActiveNodeId(r),this.scrollToNode(r))}collapseOrMoveToParent(){const t=this._treeState.activeNodeId;if(!t)return;const e=this._navigator.getNode(t);if(e.isNull())return;if(!this._navigator.isRootId(t)&&this._navigator.nodeHasChildren(e)&&this._treeState.isExpanded(t)){this._treeState.setExpanded(t,!1);return}const r=this._navigator.findParentId(t);r&&(this._treeState.setActiveNodeId(r),this.scrollToNode(r))}toggleExpand(){const t=this._treeState.activeNodeId;if(!t)return;const e=this._navigator.getNode(t);e.isNull()||!this._navigator.isRootId(t)&&this._navigator.nodeHasChildren(e)&&this._treeState.toggleExpanded(t)}insertField(){const t=this._treeState.activeNodeId;if(!t)return;const e=this._navigator.getNode(t);if(e.isNull())return;if(e.isObject()){this._accessors.get(t).actions.insertFieldAt(0,"");return}const r=this._navigator.findParentId(t);if(!r)return;const n=this._navigator.getNode(r);if(n.isNull()||!n.isObject())return;const i=n.properties().findIndex(s=>s.id()===t);i!==-1&&this._accessors.get(r).actions.insertFieldAt(i+1,"")}enterEditMode(){const t=this._treeState.activeNodeId;t&&this._treeState.requestFocus(t)}deactivateOrRemoveEmpty(){const t=this._treeState.activeNodeId;if(!t)return;const e=this._navigator.getNode(t);if(!this._navigator.isRootId(t)&&!e.isNull()&&!e.name()){this.removeNode();return}this._treeState.setActiveNodeId(null)}removeNode(){const t=this._treeState.activeNodeId;if(!t)return;const e=this._accessors.get(t);if(!e.actions.canRemove)return;const r=this.visibleNodeIds.indexOf(t);e.actions.remove();const n=this.visibleNodeIds;if(n.length===0){this._treeState.setActiveNodeId(null);return}const i=n[Math.min(r,n.length-1)];i!==void 0&&this._treeState.setActiveNodeId(i)}scrollToNode(t){if(!this._containerRef)return;const e=this._containerRef.querySelector(`[data-node-id="${t}"]`);e&&e.scrollIntoView({block:"nearest",behavior:"smooth"})}};const tY={[Be.File]:Ww,[Be.RowId]:LE,[Be.RowCreatedId]:BE,[Be.RowVersionId]:$E,[Be.RowCreatedAt]:zE,[Be.RowPublishedAt]:VE,[Be.RowUpdatedAt]:HE,[Be.RowHash]:qE,[Be.RowSchemaHash]:WE};let g2=!1;function tC(){g2||(g2=!0,_$(I$(OL)))}const rY=14;var mg=class{_tableModel;_treeState;_onCancel;_onSelectForeignKey;accessors;validation;view;collapse;keyboard;constructor(t,e={},r=new $Z){tC(),this._tableModel=FE({tableId:e.tableId??"",schema:t,refSchemas:e.refSchemas??tY}),this._treeState=new jZ,this._onCancel=e.onCancel??null,this._onSelectForeignKey=e.onSelectForeignKey??null;const n={renameTable:o=>this.setTableId(o),onNodeRemoved:o=>this.handleNodeRemoved(o),onNodeAdded:o=>this.handleNodeAdded(o),onNodeReplaced:(o,l)=>this.handleNodeReplaced(o,l),selectForeignKey:()=>this.selectForeignKey()};this.accessors=new BZ(()=>this._tableModel.schema,()=>({schemaModel:this._tableModel.schema,treeState:this._treeState,getTableId:()=>this._tableModel.tableId,getTableIdError:()=>this.tableIdError,callbacks:n}),r),this.validation=new zZ(this._tableModel,this.accessors,()=>this.tableIdError),this.view=new VZ,this.collapse=new QZ(this._treeState,()=>this._tableModel.schema),this.keyboard=new eY(this._treeState,new JZ(()=>this._tableModel.schema,this._treeState),this.accessors);const i=e.collapseComplexSchemas??!1,s=e.collapseComplexity??rY;i&&this.collapse.collapseIfComplex(s),this.collapse.collapseRefNodes(),le(this,{accessors:!1,validation:!1,view:!1,collapse:!1,keyboard:!1},{autoBind:!0})}get tableModel(){return this._tableModel}get schemaModel(){return this._tableModel.schema}get treeState(){return this._treeState}get tableId(){return this._tableModel.tableId}get initialTableId(){return this._tableModel.baseTableId}get isTableIdChanged(){return this._tableModel.isRenamed}get tableIdError(){const t=this._tableModel.tableId;return t&&!TE(t)?RE:null}setTableId(t){this._tableModel.rename(t)}get rootAccessor(){return this.accessors.get(this._tableModel.schema.root.id(),!0)}get isDirty(){return this._tableModel.isDirty}get isValid(){return this._tableModel.schema.isValid&&this.tableIdError===null&&this._tableModel.tableId.length>0}get patchesCount(){return this.getPatches().length}get totalChangesCount(){return this.patchesCount+(this.isTableIdChanged?1:0)}markAsSaved(){this._tableModel.commit(),this.accessors.clear()}changeRootType(t){const e=this._tableModel.schema.root;if(e.isNull())return;if(t==="Array"&&!e.isArray()){this._tableModel.schema.wrapRootInArray()&&this.accessors.clear();return}const r=ub(t);r&&this._tableModel.schema.replaceRoot(r)&&this.accessors.clear()}async selectForeignKey(){return this._onSelectForeignKey?this._onSelectForeignKey():null}cancel(){this._onCancel?.()}getPatches(){return this._tableModel.schema.patches}getJsonPatches(){return this._tableModel.schema.jsonPatches}getPlainSchema(){return this._tableModel.schema.plainSchema}moveNode(t,e){this._tableModel.schema.moveNode(t,e),this.accessors.delete(t)}revert(){this._tableModel.revert(),this.accessors.clear(),this._treeState.reset()}dispose(){this.keyboard.dispose(),this.accessors.clear(),this._treeState.reset()}handleNodeRemoved(t){this.accessors.delete(t),this._treeState.clearNode(t),this._treeState.activeNodeId===t&&this._treeState.setActiveNodeId(null)}handleNodeAdded(t){this.collapseIfRefNode(t),this.keyboard.handleNodeAdded(t)}handleNodeReplaced(t,e){this.accessors.delete(t),t!==e&&this._treeState.clearNode(t),this._treeState.setMenuOpen(e,!1),this.keyboard.handleNodeReplaced(t,e),this.collapseIfRefNode(e)}collapseIfRefNode(t){const e=this._tableModel.schema.nodeById(t);e.isRef()&&(e.isObject()||e.isArray())&&this._treeState.setExpanded(t,!1)}},n4=class{constructor(t){this._core=t,le(this,{},{autoBind:!0})}get rootAccessor(){return this._core.rootAccessor}get schemaModel(){return this._core.schemaModel}getChildAccessors(t,e=!1){return this._core.accessors.getChildren(t,e)}changeRootType(t){this._core.changeRootType(t)}changeNodeType(t,e){t.isRoot?this._core.changeRootType(e):t.actions.changeType(e)}moveNode(t,e){this._core.moveNode(t,e)}selectForeignKey(){return this._core.selectForeignKey()}get keyboard(){return this._core.keyboard}},nY=class{_viewMode="Example";_loading=!1;constructor(t,e,r){this._tableModel=t,this._onApprove=e,this._onClose=r,le(this,{},{autoBind:!0})}get tableId(){return this._tableModel.tableId}get viewMode(){return this._viewMode}setViewMode(t){this._viewMode=t}get loading(){return this._loading}get plainSchema(){return this._tableModel.schema.plainSchema}get exampleData(){return this._tableModel.schema.generateDefaultValue({arrayItemCount:1})}async approve(){this._loading=!0;try{await this._onApprove()}finally{this._loading=!1}}close(){this._onClose()}},i4=class{constructor(t,e,r,n,i){this._tableModel=t,this._getTableIdError=e,this._getFormulaInputErrors=r,this._onRevert=n,this._onClose=i,le(this,{},{autoBind:!0})}get canRevert(){return this._onRevert!==void 0}revert(){this._onRevert?.(),this._onClose?.()}get tableId(){return this._tableModel.tableId}get tableIdError(){return this._getTableIdError()}get validationErrors(){return this._tableModel.schema.validationErrors}get formulaErrors(){const t=this._tableModel.schema.formulaErrors,e=this._getFormulaInputErrors();return[...t,...e]}get hasErrors(){return this.validationErrors.length>0||this.formulaErrors.length>0||this.tableIdError!==null}get errorsCount(){let t=this.validationErrors.length+this.formulaErrors.length;return this.tableIdError!==null&&(t+=1),t}},iY=class{_core;_onApprove;tree;_isErrorsDialogOpen=!1;_isCreateDialogOpen=!1;_createDialogViewMode="Example";constructor(t,e={}){t instanceof mg?this._core=t:this._core=new mg(t,e),this._onApprove=e.onApprove??null,this.tree=new n4(this._core),le(this,{tree:!1},{autoBind:!0})}get mode(){return"creating"}get tableId(){return this._core.tableId}get initialTableId(){return this._core.initialTableId}get isTableIdChanged(){return this._core.isTableIdChanged}get tableIdError(){return this._core.tableIdError}setTableId(t){this._core.setTableId(t)}get isDirty(){return this._core.isDirty}get isValid(){return this._core.isValid}markAsSaved(){this._core.markAsSaved()}get loading(){return this._core.view.loading}get viewMode(){return this._core.view.viewMode}setViewMode(t){this._core.view.setViewMode(t)}cancel(){this._core.cancel()}collapseAll(){this._core.collapse.collapseAll()}expandAll(){this._core.collapse.expandAll()}get showReviewErrorsButton(){return this._core.validation.hasErrors}get errorsCount(){return this._core.validation.errorsCount}get isErrorsDialogOpen(){return this._isErrorsDialogOpen}openErrorsDialog(){this._isErrorsDialogOpen=!0}closeErrorsDialog(){this._isErrorsDialogOpen=!1}get errorsDialogVM(){return new i4(this._core.tableModel,()=>this._core.tableIdError,()=>this._core.validation.collectFormulaInputErrors())}get showCreateTableButton(){return this._core.isValid&&!this._core.validation.hasErrors}get isCreateDialogOpen(){return this._isCreateDialogOpen}openCreateDialog(){this._isCreateDialogOpen=!0}closeCreateDialog(){this._isCreateDialogOpen=!1}get createDialogViewMode(){return this._createDialogViewMode}setCreateDialogViewMode(t){this._createDialogViewMode=t}get createDialogVM(){return new nY(this._core.tableModel,()=>this.approve(),()=>this.closeCreateDialog())}async approve(){if(this._onApprove){this._core.view.setLoading(!0);try{await this._onApprove()&&(this._core.markAsSaved(),this.closeCreateDialog())}finally{this._core.view.setLoading(!1)}}}getPlainSchema(){return this._core.getPlainSchema()}dispose(){this._core.dispose()}},sY=class{_viewMode="Changes";_loading=!1;constructor(t,e,r,n){this._tableModel=t,this._onApprove=e,this._onRevert=r,this._onClose=n,le(this,{},{autoBind:!0})}get tableId(){return this._tableModel.tableId}get initialTableId(){return this._tableModel.baseTableId}get isTableIdChanged(){return this._tableModel.isRenamed}get tableIdChange(){return this.isTableIdChanged?{initialTableId:this.initialTableId,currentTableId:this.tableId}:null}get patches(){return this._tableModel.schema.patches}get jsonPatches(){return this._tableModel.schema.jsonPatches}get patchesCount(){return this.patches.length}get totalChangesCount(){return this.patchesCount+(this.isTableIdChanged?1:0)}get hasChanges(){return this.patchesCount>0||this.isTableIdChanged}get viewMode(){return this._viewMode}setViewMode(t){this._viewMode=t}get loading(){return this._loading}async approve(){this._loading=!0;try{await this._onApprove()}finally{me(()=>{this._loading=!1})}}revert(){this._onRevert(),this._onClose()}close(){this._onClose()}},oY=class{_core;_onApprove;tree;_isErrorsDialogOpen=!1;_isChangesDialogOpen=!1;_updateDialogViewMode="Changes";constructor(t,e={}){t instanceof mg?this._core=t:this._core=new mg(t,e),this._onApprove=e.onApprove??null,this.tree=new n4(this._core),le(this,{tree:!1},{autoBind:!0})}get mode(){return"updating"}get tableId(){return this._core.tableId}get initialTableId(){return this._core.initialTableId}get isTableIdChanged(){return this._core.isTableIdChanged}get tableIdError(){return this._core.tableIdError}setTableId(t){this._core.setTableId(t)}get isDirty(){return this._core.isDirty}get isValid(){return this._core.isValid}markAsSaved(){this._core.markAsSaved()}get loading(){return this._core.view.loading}get viewMode(){return this._core.view.viewMode}setViewMode(t){this._core.view.setViewMode(t)}cancel(){this._core.cancel()}collapseAll(){this._core.collapse.collapseAll()}expandAll(){this._core.collapse.expandAll()}get showReviewErrorsButton(){return this._core.validation.hasErrors}get errorsCount(){return this._core.validation.errorsCount}get isErrorsDialogOpen(){return this._isErrorsDialogOpen}openErrorsDialog(){this._isErrorsDialogOpen=!0}closeErrorsDialog(){this._isErrorsDialogOpen=!1}get errorsDialogVM(){return new i4(this._core.tableModel,()=>this._core.tableIdError,()=>this._core.validation.collectFormulaInputErrors(),()=>this.revert(),()=>this.closeErrorsDialog())}get showApplyChangesButton(){return this._core.isValid&&!this._core.validation.hasErrors&&(this._core.isDirty||this._core.isTableIdChanged)}get totalChangesCount(){return this._core.totalChangesCount}get isChangesDialogOpen(){return this._isChangesDialogOpen}openChangesDialog(){this._isChangesDialogOpen=!0}closeChangesDialog(){this._isChangesDialogOpen=!1}get updateDialogViewMode(){return this._updateDialogViewMode}setUpdateDialogViewMode(t){this._updateDialogViewMode=t}get changesDialogVM(){return new sY(this._core.tableModel,()=>this.approve(),()=>this.revert(),()=>this.closeChangesDialog())}revert(){this._core.revert()}async approve(){if(this._onApprove){this._core.view.setLoading(!0);try{await this._onApprove()&&(this._core.markAsSaved(),this.closeChangesDialog())}finally{this._core.view.setLoading(!1)}}}getPlainSchema(){return this._core.getPlainSchema()}getPatches(){return this._core.getPatches()}getJsonPatches(){return this._core.getJsonPatches()}dispose(){this._core.dispose()}};const Ys=_.forwardRef(function(e,r){const{showArrow:n,children:i,disabled:s,portalled:o=!0,content:l,contentProps:c,portalRef:u,...h}=e;return s?a.jsx(a.Fragment,{children:i}):a.jsxs(bA,{...h,children:[a.jsx(wA,{asChild:!0,children:i}),a.jsx(je,{disabled:!o,container:u,children:a.jsx(SA,{children:a.jsxs(CA,{ref:r,...c,children:[n&&a.jsx(_A,{children:a.jsx(IA,{})}),l]})})})]})});let zl=(function(t){return t.Tree="Tree",t.Json="Json",t.RefBy="RefBy",t})({});const Dd=[{mode:zl.Tree,label:"Tree",icon:wP,dataTestId:"row-editor-mode-tree"},{mode:zl.Json,label:"JSON",icon:Jw,dataTestId:"row-editor-mode-json"},{mode:zl.RefBy,label:"References",icon:bP,dataTestId:"row-editor-mode-refs"}],aY=({mode:t,onChange:e,availableRefByMode:r})=>{const[n,i]=_.useState(!1),[s,o]=_.useState(!1),l=_.useMemo(()=>Dd.filter(h=>!(h.mode===zl.RefBy&&!r)),[r]),c=Dd.find(h=>h.mode===t)??Dd[0],u=h=>{const d=Dd.find(f=>f.mode===h.value);d&&e?.(d.mode)};return a.jsxs(Dt,{onOpenChange:({open:h})=>i(h),children:[a.jsx(Tr,{asChild:!0,children:a.jsx(be,{variant:"ghost",size:"sm",height:"2.5rem",color:"gray.500",_hover:{backgroundColor:"gray.50","& .caret":{opacity:1}},_focus:{outline:"none",boxShadow:"none"},_focusVisible:{outline:"none",boxShadow:"none"},"data-testid":"view-mode-switcher",px:"8px",gap:"2px",children:a.jsx(Ys,{open:!n&&s,onOpenChange:h=>o(h.open),content:"View mode",openDelay:500,closeDelay:0,children:a.jsxs("span",{style:{display:"flex",alignItems:"center",gap:"2px"},children:[a.jsx(He,{as:c.icon,boxSize:4}),a.jsx(He,{as:mm,boxSize:3,color:"gray.400",className:"caret",opacity:0,transition:"opacity 0.15s"})]})})})}),a.jsx(je,{children:a.jsx(Ft,{children:a.jsx(Lt,{minWidth:"140px",children:a.jsx(kA,{value:t,onValueChange:u,children:l.map(h=>a.jsxs(AA,{value:h.mode,"data-testid":h.dataTestId,cursor:"pointer",children:[a.jsx(nm,{}),a.jsx(He,{as:h.icon,boxSize:4,mr:"8px"}),h.label]},h.mode))})})})})]})},lY=({dataTestId:t,...e})=>a.jsx(lt,{"data-testid":t,_hover:{backgroundColor:"gray.100"},color:"gray.400",variant:"ghost",...e,children:a.jsx(wm,{})}),yg=({data:t,readonly:e,onChange:r,onBlur:n,onCopy:i})=>{const[s,o]=_.useState(""),l=JSON.stringify(t,null,3),[c,u]=_.useState(l),h=_.useRef(!1),d=h.current?c:l,f=_.useCallback(()=>{navigator.clipboard.writeText(d).then(()=>{i?.()})},[d,i]),p=_.useCallback(m=>{u(m);try{const v=JSON.parse(m);o(""),r?.(v)}catch(v){console.error(v),o("Invalid JSON")}},[r]),g=_.useCallback(()=>{h.current=!0,u(l)},[l]),y=_.useCallback(()=>{h.current=!1,u(l),n?.()},[n,l]);return a.jsxs(P,{position:"relative",width:"100%",flex:1,direction:"column",gap:"1rem",css:{"&:hover .copy-button":{visibility:"visible"}},children:[a.jsxs(T,{p:1,flex:1,children:[a.jsx(Ba,{value:d,extensions:[we.lineWrapping,nc()],editable:!e,theme:ec,maxWidth:"100%",basicSetup:{lineNumbers:!0,foldGutter:!0},onChange:p,onFocus:g,onBlur:y}),a.jsx(lY,{dataTestId:"json-card-copy-button","aria-label":"",position:"absolute",top:"8px",right:"8px",className:"copy-button",visibility:"hidden",onClick:f})]}),a.jsx(P,{height:"40px",paddingBottom:"8px",alignItems:"flex-end",backgroundColor:"white",width:"100%",position:"sticky",bottom:0,justifyContent:"center",children:a.jsx(j,{color:"gray",children:s})})]})};function cY(t){return t.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""").replaceAll("'","'")}const uY=new Set(["Backspace","Escape","Enter","ArrowRight","ArrowLeft","Delete"]);function hY(t){const{value:e,autoFocus:r,focusTrigger:n}=t,i=_.useRef(null),s=_.useRef(null),o=_.useRef(n),l=_.useRef(t);l.current=t;const c=_.useCallback(p=>{i.current=p},[]);_.useEffect(()=>{r&&i.current?.focus()},[r]),_.useLayoutEffect(()=>{if(globalThis.getSelection()&&s.current!==null&&i.current){const p=(i.current.textContent||"").length,g=Math.min(p,s.current),y=document.createRange(),m=globalThis.getSelection(),v=i.current.childNodes[0]??i.current;y.setStart(v,g),y.collapse(!0),m&&(m.removeAllRanges(),m.addRange(y))}}),_.useEffect(()=>{if(o.current===n)return;o.current=n,i.current?.focus();const p=globalThis.getSelection();if(i.current&&p){const g=document.createRange();g.selectNodeContents(i.current),g.collapse(!1),p.removeAllRanges(),p.addRange(g)}},[n]);const u=_.useCallback(p=>{const g=globalThis.getSelection();g&&g.rangeCount>0&&(s.current=g.getRangeAt(0).startOffset);const y=p.currentTarget.innerText,m=y===`
|
|
368
368
|
`?"":y;l.current.onChange?.(m)},[]),h=_.useCallback(()=>{l.current.onBlur?.(),s.current=null},[]),d=_.useCallback(()=>{l.current.onFocus?.()},[]),f=_.useCallback(p=>{const g=l.current;p.key==="Enter"&&(p.preventDefault(),g.value&&(i.current?.blur(),g.onEnter?.())),p.key==="Escape"&&(p.preventDefault(),i.current?.blur(),g.onEscape?.()),g.restrict&&!p.metaKey&&!p.ctrlKey&&!uY.has(p.key)&&!g.restrict.test(p.key)&&p.preventDefault()},[]);return{ref:c,contentEditable:!0,spellCheck:!1,dangerouslySetInnerHTML:{__html:cY(e)},onInput:u,onBlur:h,onFocus:d,onKeyDown:f}}const s4=({initValue:t,placeholder:e,autoFocus:r,onBlur:n,onChange:i,onEscape:s,onEnter:o,onFocus:l,focusTrigger:c,restrict:u,prefix:h,postfix:d,dataTestId:f,textDecoration:p})=>{const g=_.useRef(null),y=hY({value:t,onChange:i,onBlur:n,onFocus:l,onEscape:s,onEnter:o,restrict:u,autoFocus:r,focusTrigger:c}),m=y.ref,v=_.useCallback(S=>{g.current=S,m(S)},[m]),x=_.useCallback(()=>{g.current?.focus()},[]),b=!t&&e;return a.jsxs(P,{minWidth:0,width:b?"100%":void 0,position:"relative",cursor:"text",onClick:x,children:[!b&&h,a.jsx(T,{color:"blackAlpha.800",textDecoration:p,"data-testid":f,ref:v,contentEditable:y.contentEditable,spellCheck:y.spellCheck,dangerouslySetInnerHTML:y.dangerouslySetInnerHTML,outline:0,width:"100%",onBlur:y.onBlur,onFocus:y.onFocus,onInput:y.onInput,onKeyDown:y.onKeyDown}),!b&&d,b&&a.jsx(j,{cursor:"text",userSelect:"none",pointerEvents:"none",whiteSpace:"nowrap",color:"gray.400",position:"absolute",children:e})]})},dY=({height:t="2.5rem",title:e,onClick:r,disabled:n,isSelected:i,isLoading:s,icon:o,dataTestId:l})=>a.jsx(be,{"data-testid":l,_hover:{color:"gray.400",backgroundColor:"white"},_disabled:i?{backgroundColor:"gray.50",cursor:"not-allowed"}:void 0,alignSelf:"flex-start",color:"gray.300",fontWeight:"500",fontSize:16,height:t,disabled:n||i,loading:s,variant:"ghost",onClick:r,children:a.jsxs(P,{alignItems:"center",gap:"0.5rem",children:[o&&a.jsx(T,{fontSize:"sm",children:o}),a.jsx(j,{children:e})]})}),Gm=t=>a.jsx(dY,{...t,icon:a.jsx(Ah,{})}),fY=({height:t="2.5rem",onClick:e,disabled:r,dataTestId:n})=>a.jsx(be,{"data-testid":n,disabled:r,_hover:{backgroundColor:"gray.50"},alignSelf:"flex-start",color:"gray.400",height:t,variant:"ghost",onClick:e,width:"48px",children:a.jsx(He,{as:jc,size:"md"})}),pY=({height:t="2.5rem",onClick:e,isDisabled:r,dataTestId:n})=>a.jsx(be,{"data-testid":n,disabled:r,_hover:{backgroundColor:"gray.50"},alignSelf:"flex-start",height:t,variant:"ghost",onClick:e,children:a.jsx(He,{as:rz,boxSize:4,color:"gray.500"})}),gY=({dataTestId:t,...e})=>a.jsx(lt,{"data-testid":t,_hover:{backgroundColor:"gray.50"},color:"gray.400",variant:"ghost",size:"sm",...e,children:a.jsx(Xw,{})}),o4=re(({accessor:t,isCollapsible:e,isCollapsed:r,onToggleCollapse:n,field:i,hoverTargetClass:s,dataTestId:o,children:l})=>{const c=`dot-outline-${t.nodeId}`,u=`collapse-button-${t.nodeId}`,h=t.state.isActive&&!!t.label.name,d=e&&!r?{[`& .${c}`]:{visibility:"hidden"},[`& .${u}`]:{visibility:"visible"}}:{},f=h&&e&&!r?{[`& .${c}`]:{visibility:"hidden"},[`& .${u}`]:{visibility:"visible"}}:{},p=s?{[`&:hover .${s}`]:{opacity:1},...h?{[`& .${s}`]:{opacity:1}}:{}}:{},g=()=>{if(o)return r?`${o}-expand-button`:`${o}-collapse-button`};return a.jsxs(P,{flexDirection:"column",alignSelf:"flex-start",width:"100%",_hover:d,css:f,"data-node-id":t.nodeId,"data-active":t.state.isActive||void 0,children:[a.jsxs(P,{gap:"4px",alignItems:"center",height:"30px",mt:"2px",mb:"2px",position:"relative",css:p,backgroundColor:t.state.isActive?"gray.100":void 0,borderRadius:"4px",cursor:"default",children:[a.jsx(T,{position:"absolute",ml:"-60px",height:"100%",width:"60px"}),a.jsx(T,{className:c,color:"gray.300",visibility:r?"hidden":"visible",children:a.jsx(Uw,{})}),e&&a.jsx(lt,{"data-testid":g(),className:u,visibility:r?"visible":"hidden",_hover:{backgroundColor:"transparent"},ml:"-8px",position:"absolute",size:"xs",color:"gray.400",variant:"ghost",onClick:n,width:"26px",height:"26px",children:a.jsx(T,{rotate:r?"0":"90deg",children:a.jsx(xO,{})})}),i]}),l&&!r&&a.jsx(P,{ml:"7px",pl:"18px",borderLeftWidth:1,borderLeftStyle:"solid",borderLeftColor:"white",_hover:{borderLeftColor:"blackAlpha.200"},children:l})]})}),mY=({label:t,options:e,onSelect:r,dataTestIdPrefix:n,triggerId:i})=>a.jsxs(Dt,{positioning:{placement:"right-start",gutter:2},children:[a.jsxs(oo,{"data-testid":i,children:[a.jsx(T,{flex:"1",children:t}),a.jsx(za,{})]}),a.jsx(je,{children:a.jsx(Ft,{children:a.jsx(Lt,{children:e.map(s=>a.jsxs(_.Fragment,{children:[a.jsx(et,{value:s.id,"data-testid":`${n}-${s.id}`,onClick:()=>r(s.id),children:s.label}),s.type!=="submenu"&&s.addDividerAfter&&a.jsx(yr,{})]},s.id))})})})]}),a4=({menuButton:t,onSelect:e,dataTestId:r,open:n,onOpenChange:i})=>{const s=o=>{i?.(o.open)};return a.jsxs(Dt,{open:n,onOpenChange:s,children:[a.jsx(Tr,{asChild:!0,children:t}),a.jsx(je,{children:a.jsx(Ft,{children:a.jsx(Lt,{children:NZ.map(o=>a.jsxs(_.Fragment,{children:[o.options.map(l=>l.type==="submenu"?a.jsx(mY,{label:l.label,options:l.items,onSelect:e,triggerId:`${r}-menu-submenu-${l.id}`,dataTestIdPrefix:`${r}-menu-sub`},l.id):a.jsx(et,{value:l.id,"data-testid":`${r}-menu-type-${l.id}`,onClick:()=>e(l.id),children:l.label},l.id)),o.addDividerAfter&&a.jsx(yr,{})]},o.id))})})})]})},yY=({dataTestId:t,hoverClass:e,applyHoverStyles:r})=>a.jsx(Ys,{content:"Drag to move field to another object",positioning:{placement:"left"},children:a.jsx(P,{"data-testid":`${t}-drag-button`,className:e,position:"absolute",left:"-34px",opacity:r?0:1,cursor:"grab",_hover:{backgroundColor:"gray.50"},height:"100%",alignItems:"center",justifyContent:"center",borderRadius:"4px",marginLeft:"-6px",children:a.jsx(He,{as:EB,size:"md",color:"gray.300"})})}),xY=({dataTestId:t,errorMessage:e})=>a.jsx(Ys,{content:e,positioning:{placement:"top"},contentProps:{maxWidth:"400px"},children:a.jsx(T,{"data-testid":`${t}-error-indicator`,color:"red.500",cursor:"default",display:"flex",alignItems:"center",ml:"4px",children:a.jsx(vP,{})})}),qy=t=>{const e=t.accessor;return e&&typeof e=="object"&&"nodeId"in e?e:null},vY=({accessor:t,onDrop:e,canDrag:r,isDropTarget:n,canAcceptDrop:i})=>{const s=_.useRef(null);return _.useEffect(()=>{if(!r||!s.current)return;const o=qU({element:s.current,getInitialData:()=>({accessor:t})});return()=>o()},[t,r]),_.useEffect(()=>{if(!n||!s.current)return;const o=VU({element:s.current,onDrop:l=>{const c=qy(l.source.data);c&&i(c.nodeId)&&e&&e(c.nodeId),t.state.setDraggedOver(!1),t.state.setDrop(!1)},onDragEnter:l=>{const c=qy(l.source.data);c&&t.state.setDraggedOver(i(c.nodeId))},onDragLeave:()=>t.state.setDraggedOver(!1)});return()=>o()},[t,n,e,i]),_.useEffect(()=>HU({onDragStart:o=>{const l=qy(o.source.data);l&&(n&&i(l.nodeId)?t.state.setDrop(!0):t.state.setDisabledDrop(!0))},onDrop:()=>{t.state.setDrop(!1),t.state.setDisabledDrop(!1)}}),[t,n,i]),{dragAndDropRef:s,isDraggable:r,isDrop:t.state.isDrop,isDisabledDrop:t.state.isDisabledDrop,isDraggedOver:t.state.isDraggedOver}},bY=re(({accessor:t,treeVM:e,dataTestId:r,hoverTargetClass:n,onChangeType:i,rightContent:s})=>{const o=t.state.isActive&&!!t.label.name,l=!t.state.isFocused&&!o,c=l&&n?n:void 0,u=!!t.label.name,h=e.schemaModel.hasValidDropTarget(t.nodeId),{dragAndDropRef:d,isDraggable:f,isDrop:p,isDraggedOver:g,isDisabledDrop:y}=vY({accessor:t,canDrag:!t.isRoot&&!t.isReadonly&&u&&h,isDropTarget:t.isObject&&!t.isReadonly,canAcceptDrop:_.useCallback(v=>e.schemaModel.canMoveNode(v,t.nodeId),[t.nodeId,e.schemaModel]),onDrop:_.useCallback(v=>{e.moveNode(v,t.nodeId)},[e,t.nodeId])}),m=!t.isReadonly;return a.jsxs(P,{gap:"0.5rem",width:"100%",justifyContent:"flex-start",outline:0,children:[a.jsxs(P,{"data-testid":p?`${r}-drop`:void 0,ref:d,flex:u?0:1,position:"relative",whiteSpace:"nowrap",borderWidth:1,borderStyle:"dashed",borderColor:p?"gray.400":"transparent",backgroundColor:g?"gray.200":void 0,color:y?"gray.300":void 0,children:[f&&a.jsx(yY,{dataTestId:r,hoverClass:c,applyHoverStyles:l}),t.isReadonly?a.jsx(j,{color:"gray.400","data-testid":r,children:t.label.name}):a.jsx(s4,{dataTestId:r,autoFocus:!t.label.name,initValue:t.label.name,placeholder:t.isRoot?"Enter the name of the table":"Enter the name of the field",onBlur:t.handleFieldBlur,onFocus:()=>t.state.setFocused(!0),onChange:t.actions.rename,onEnter:e.keyboard.handleEditEnter,focusTrigger:t.state.focusRequestCount}),u&&t.validation.hasError&&a.jsx(xY,{dataTestId:r,errorMessage:t.validation.errorMessage??""})]}),u&&a.jsx(P,{gap:"0.5rem",alignItems:"center",children:a.jsx(T,{className:c,opacity:l?0:1,children:a.jsxs(P,{gap:"0.5rem",alignItems:"center",children:[m?a.jsx(a4,{dataTestId:r,onSelect:i,open:t.state.isMenuOpen,onOpenChange:t.state.setMenuOpen,menuButton:a.jsx(j,{"data-testid":`${r}-select-type-button`,color:"gray.400",textDecoration:"underline",cursor:"pointer",children:t.label.typeLabel})}):a.jsx(j,{"data-testid":`${r}-type-label`,color:"gray.400",children:t.label.typeLabel}),s]})})})]})}),l4=re(({accessor:t})=>{const e=t.label.description,r=t.formula.hasFormula,n=t.formula.formula,i=t.label.isDeprecated;return e||r||i?a.jsxs(P,{gap:"2px",alignItems:"center",children:[i&&a.jsx(Ys,{content:"Deprecated",positioning:{placement:"top"},children:a.jsx(T,{color:"orange.400",cursor:"default",display:"flex",alignItems:"center",children:a.jsx(oz,{})})}),r&&a.jsx(Ys,{content:`Formula: ${n}`,positioning:{placement:"top"},children:a.jsx(T,{color:"gray.400",cursor:"default",display:"flex",alignItems:"center",children:a.jsx(pP,{})})}),e&&a.jsx(Ys,{content:e,positioning:{placement:"top"},children:a.jsx(T,{color:"gray.400",cursor:"default",display:"flex",alignItems:"center",children:a.jsx(xP,{})})})]}):null}),wY=re(({accessor:t,dataTestId:e})=>{const[r,n]=_.useState(t.label.description??""),i=()=>{t.actions.setDescription(r||void 0)},s=o=>{o.stopPropagation(),o.nativeEvent.stopImmediatePropagation()};return a.jsxs(Dt,{positioning:{placement:"right-start",gutter:2},children:[a.jsxs(oo,{"data-testid":`${e}-description-menu`,children:[a.jsx(xP,{}),a.jsx(T,{flex:"1",children:"Description"}),t.label.description&&a.jsx(T,{color:"gray.400",fontSize:"xs",maxW:"80px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",children:t.label.description}),a.jsx(Yw,{})]}),a.jsx(je,{children:a.jsx(Ft,{children:a.jsx(Lt,{p:"2",minW:"280px",children:a.jsx(Th,{size:"sm",placeholder:"Add description...",value:r,onChange:o=>n(o.target.value),onBlur:i,onKeyDown:s,onKeyUp:s,rows:3,ref:_.useCallback(o=>{o&&requestAnimationFrame(()=>{o.focus({preventScroll:!0});const l=o.value.length;o.setSelectionRange(l,l)})},[]),"data-testid":`${e}-description-input`})})})})]})}),SY=(t,e,r)=>{const n=t.trim();if(!n)return null;try{const i=hB(n,e,r);return i?i.error:null}catch{return"Invalid formula"}},CY=re(({accessor:t,dataTestId:e})=>{const r=t.formula.formula,n=t.formula.errorMessage??null,[i,s]=_.useState(r),[o,l]=_.useState(n),c=_.useRef(i),u=_.useRef(r),h=p=>{const g=p.target.value;s(g),c.current=g,l(SY(g,t.label.name,t.formula.plainSchema))};_.useEffect(()=>{const p=t,g=u;return()=>{const y=c.current;y!==g.current&&(p.formula.setInputValue(y),p.formula.applyFormula())}},[t]);const d=o!==null,f=p=>{p.stopPropagation(),p.nativeEvent.stopImmediatePropagation()};return a.jsxs(a.Fragment,{children:[a.jsx(Th,{size:"sm",placeholder:"e.g. price * quantity",value:i,onChange:h,onKeyDown:f,onKeyUp:f,ref:_.useCallback(p=>{p&&requestAnimationFrame(()=>{p.focus({preventScroll:!0});const g=p.value.length;p.setSelectionRange(g,g)})},[]),rows:2,borderColor:d?"red.300":void 0,"data-testid":`${e}-formula-input`}),d&&a.jsx(T,{fontSize:"xs",color:"red.500",mt:1,"data-testid":`${e}-formula-error`,children:o}),!d&&i&&a.jsx(T,{fontSize:"xs",color:"gray.500",mt:1,children:"Field will be readOnly"})]})}),_Y=re(({accessor:t,dataTestId:e})=>{const r=t.formula.hasError;return a.jsxs(Dt,{positioning:{placement:"right-start",gutter:2},children:[a.jsxs(oo,{"data-testid":`${e}-formula-menu`,children:[a.jsx(pP,{}),a.jsx(T,{flex:"1",children:"Formula"}),t.formula.hasFormula&&a.jsx(T,{color:r?"red.400":"gray.400",fontSize:"xs",maxW:"80px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",children:t.formula.formula}),a.jsx(Yw,{})]}),a.jsx(je,{children:a.jsx(Ft,{children:a.jsx(Lt,{w:"280px",p:2,children:a.jsx(CY,{accessor:t,dataTestId:e})})})})]})});function IY(t,e){const r=e.label.nodeType;if(r==="number"){const n=Number(t);return Number.isNaN(n)?0:n}return r==="boolean"?t==="true":t}const jY=re(({accessor:t,dataTestId:e})=>{const[r,n]=_.useState(t.defaultValueAsString),i=()=>{t.actions.setDefaultValue(IY(r,t))},s=u=>{t.actions.setDefaultValue(u)},o=u=>{u.stopPropagation(),u.nativeEvent.stopImmediatePropagation()},l=t.label.nodeType==="boolean",c=t.label.nodeType==="number";return a.jsxs(Dt,{positioning:{placement:"right-start",gutter:2},children:[a.jsxs(oo,{"data-testid":`${e}-default-menu`,children:[a.jsx(nz,{}),a.jsx(T,{flex:"1",children:"Default value"}),t.defaultValueAsString&&a.jsx(T,{color:"gray.400",fontSize:"xs",maxW:"80px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",children:t.defaultValueAsString}),a.jsx(Yw,{})]}),a.jsx(je,{children:a.jsx(Ft,{children:a.jsx(Lt,{p:"2",minW:"200px",children:l?a.jsxs(EA,{value:"default-true",checked:t.defaultValue===!0,onCheckedChange:()=>s(t.defaultValue!==!0),"data-testid":`${e}-default-checkbox`,children:["true",a.jsx(nm,{})]}):a.jsx(Ot,{size:"sm",type:c?"number":"text",placeholder:c?"0":"default value",value:r,onChange:u=>n(u.target.value),onBlur:i,onKeyDown:o,onKeyUp:o,ref:_.useCallback(u=>{u&&requestAnimationFrame(()=>{u.focus({preventScroll:!0})})},[]),"data-testid":`${e}-default-input`})})})})]})}),c4=re(({accessor:t,dataTestId:e,showDelete:r=!0,showFormula:n=!1,showDefault:i=!1,onDelete:s})=>{const o=_.useRef(null),l=u=>{t.state.setSettingsOpen(u.open)},c=t.actions.canRemove;return a.jsxs(Dt,{open:t.state.isSettingsOpen,onOpenChange:l,positioning:{placement:"bottom-start"},children:[a.jsx(Tr,{asChild:!0,children:a.jsx(gY,{height:"26px",color:"gray.300",_hover:{color:"gray.400"},dataTestId:e})}),a.jsx(je,{children:a.jsx(Ft,{children:a.jsxs(Lt,{ref:o,minW:"220px",children:[a.jsx(wY,{accessor:t,dataTestId:e}),n&&a.jsx(_Y,{accessor:t,dataTestId:e}),i&&a.jsx(jY,{accessor:t,dataTestId:e}),a.jsx(yr,{}),a.jsxs(et,{value:"deprecated",onClick:()=>t.actions.setDeprecated(!t.label.isDeprecated),"data-testid":`${e}-deprecated`,children:[a.jsx(T,{w:"16px"}),t.label.isDeprecated?"Remove deprecated":"Mark as deprecated"]}),r&&a.jsxs(a.Fragment,{children:[a.jsx(yr,{}),a.jsxs(et,{value:"delete",color:c?"fg.error":"gray.400",disabled:!c,onClick:c?s:void 0,"data-testid":`${e}-delete`,_hover:c?{bg:"bg.error",color:"fg.error"}:void 0,children:[a.jsx(Sm,{}),a.jsx(T,{flex:"1",children:"Delete field"})]})]})]})})})]})}),RY=re(({accessor:t,dataTestId:e,showDelete:r=!0,showFormula:n=!1,showDefault:i=!1,onDelete:s})=>{const o=!t.isReadonly;return a.jsxs(a.Fragment,{children:[a.jsx(l4,{accessor:t}),o&&a.jsx(c4,{accessor:t,dataTestId:`${e}-setting-button`,showDelete:r,showFormula:n,showDefault:i,onDelete:s})]})}),zh=re(({accessor:t,treeVM:e,dataTestId:r,collapsible:n=!1,showFormula:i,showDefault:s,children:o})=>{const l=t.hoverTargetClass,c=n&&!t.isRoot;return a.jsx(o4,{accessor:t,isCollapsible:c,isCollapsed:c&&!t.state.isExpanded,onToggleCollapse:c?t.state.toggleExpanded:void 0,hoverTargetClass:l,dataTestId:r,field:a.jsx(bY,{accessor:t,treeVM:e,dataTestId:r,hoverTargetClass:l,onChangeType:u=>e.changeNodeType(t,u),rightContent:a.jsx(RY,{accessor:t,dataTestId:r,showDelete:!t.isRoot,showFormula:i,showDefault:s,onDelete:t.actions.remove})}),children:o})}),TY=re(({accessor:t,treeVM:e,dataTestId:r})=>{const n=t.isRoot&&!t.label.name,i=e.getChildAccessors(t.nodeId,t.isReadonly),s=!t.isReadonly&&!n;return a.jsx(zh,{accessor:t,treeVM:e,dataTestId:r,collapsible:!0,children:!n&&a.jsxs(P,{flexDirection:"column",width:"100%",children:[i.map((o,l)=>a.jsx(rC,{accessor:o,treeVM:e,dataTestId:`${r}-${l}`},o.nodeId)),s&&a.jsx(T,{ml:"-14px",children:a.jsx(Gm,{dataTestId:`${r}-create-field-button`,title:"Field",onClick:()=>t.actions.addProperty("")})})]})})}),kY=re(({accessor:t,dataTestId:e})=>{const r=t.label.foreignKeyTable;return a.jsx(P,{gap:"4px",alignItems:"center",height:"30px",mt:"2px",mb:"2px",children:a.jsx(P,{gap:"0.5rem",width:"100%",justifyContent:"flex-start",outline:0,_hover:{textDecoration:"underline",textDecorationColor:"gray.400"},onClick:t.actions.selectForeignKey,cursor:"pointer",children:a.jsx(j,{color:"gray.400","data-testid":`${e}-connect-foreign-key`,children:r||"<Connect table>"})})})}),AY=re(({accessor:t,treeVM:e,dataTestId:r})=>{if(t.isObject)return a.jsxs(P,{flexDirection:"column",width:"100%",children:[e.getChildAccessors(t.nodeId,t.isReadonly).map((n,i)=>a.jsx(rC,{accessor:n,treeVM:e,dataTestId:`${r}-${i}`},n.nodeId)),t.actions.canAddProperty&&a.jsx(T,{ml:"-14px",children:a.jsx(Gm,{dataTestId:`${r}-create-field-button`,title:"Field",onClick:()=>t.actions.addProperty("")})})]});if(t.isArray){const n=e.getChildAccessors(t.nodeId,t.isReadonly);if(n.length>0&&n[0])return a.jsx(u4,{accessor:t,childAccessor:n[0],treeVM:e,dataTestId:r})}return t.isForeignKey?a.jsx(kY,{accessor:t,dataTestId:r}):null}),u4=re(({accessor:t,childAccessor:e,treeVM:r,dataTestId:n})=>{const i=e.hoverTargetClass,s=e.shouldApplyFieldStyles,o=l=>{t.actions.changeItemsType(l)};return a.jsx(o4,{accessor:e,isCollapsible:!1,isCollapsed:!1,hoverTargetClass:i,field:a.jsxs(P,{gap:"0.5rem",alignItems:"center",children:[a.jsx(a4,{dataTestId:n,onSelect:o,open:e.state.isMenuOpen,onOpenChange:e.state.setMenuOpen,menuButton:a.jsx(j,{"data-testid":`${n}-select-type-button`,color:"gray.400",cursor:"pointer",textDecoration:"underline",outline:0,children:e.label.typeLabel})}),a.jsx(T,{className:s?i:void 0,opacity:s?0:1,children:a.jsxs(P,{gap:"0.5rem",alignItems:"center",children:[a.jsx(l4,{accessor:e}),e.showMenu&&a.jsx(c4,{accessor:e,dataTestId:`${n}-items-setting-button`,showDelete:!1,showFormula:e.isPrimitive,showDefault:e.isPrimitive})]})})]}),children:a.jsx(AY,{accessor:e,treeVM:r,dataTestId:`${n}-0`})})}),EY=re(({accessor:t,treeVM:e,dataTestId:r})=>{const n=e.getChildAccessors(t.nodeId,t.isReadonly);return a.jsx(zh,{accessor:t,treeVM:e,dataTestId:r,collapsible:!0,children:a.jsx(P,{flexDirection:"column",width:"100%",children:n.length>0&&n[0]?a.jsx(u4,{accessor:t,childAccessor:n[0],treeVM:e,dataTestId:r}):a.jsx(j,{color:"gray.400",fontSize:"sm",ml:"8px",children:"items"})})})}),PY=re(({accessor:t,treeVM:e,dataTestId:r})=>a.jsx(zh,{accessor:t,treeVM:e,dataTestId:r,showFormula:t.isPrimitive,showDefault:t.isPrimitive})),NY=re(({accessor:t,treeVM:e,dataTestId:r})=>{const n=_.useCallback(async()=>{const s=await e.selectForeignKey();s!==null&&t.actions.setForeignKey(s)},[e,t.actions]),i=t.label.foreignKeyTable;return a.jsx(zh,{accessor:t,treeVM:e,dataTestId:r,children:a.jsxs(P,{gap:"4px",alignItems:"center",height:"30px",mt:"2px",mb:"2px",children:[a.jsx(T,{color:"gray.300",children:a.jsx(Uw,{})}),a.jsx(P,{gap:"0.5rem",width:"100%",justifyContent:"flex-start",outline:0,_hover:{textDecoration:"underline",textDecorationColor:"gray.400"},onClick:n,cursor:"pointer",children:a.jsx(j,{color:"gray.400","data-testid":`${r}-connect-foreign-key`,children:i||"<Connect table>"})})]})})}),MY=re(({accessor:t,treeVM:e,dataTestId:r})=>a.jsx(zh,{accessor:t,treeVM:e,dataTestId:r})),rC=re(({accessor:t,treeVM:e,dataTestId:r,showItemsLabel:n})=>{const i=()=>t.isObject?a.jsx(TY,{accessor:t,treeVM:e,dataTestId:r}):t.isArray?a.jsx(EY,{accessor:t,treeVM:e,dataTestId:r}):t.isForeignKey?a.jsx(NY,{accessor:t,treeVM:e,dataTestId:r}):t.isRef?a.jsx(MY,{accessor:t,treeVM:e,dataTestId:r}):t.isPrimitive?a.jsx(PY,{accessor:t,treeVM:e,dataTestId:r}):null;return n?a.jsxs(T,{children:[a.jsx(j,{color:"gray.400",fontSize:"sm",ml:"-6px",mb:"-4px",children:"items"}),i()]}):i()}),ps=({children:t})=>a.jsx(T,{as:"span",px:"1",bg:"gray.100",borderRadius:"sm",whiteSpace:"nowrap",children:t}),xg=({children:t})=>a.jsx(T,{as:"code",px:1,py:.5,bg:"gray.100",borderRadius:"sm",fontFamily:"mono",children:t}),nC=({isOpen:t,onClose:e,title:r,children:n,footer:i,maxWidth:s="700px"})=>a.jsx(oi,{open:t,onOpenChange:({open:o})=>!o&&e(),size:"lg",children:a.jsxs(je,{children:[a.jsx(Ti,{}),a.jsx(ai,{children:a.jsxs(li,{maxWidth:s,children:[a.jsx(ki,{children:a.jsx(Ps,{children:r})}),a.jsx(Ai,{children:n}),i&&a.jsx(io,{children:a.jsx(P,{justify:"space-between",width:"100%",children:i})}),a.jsx(so,{})]})})]})}),iC=({leftContent:t,onCancel:e,onConfirm:r,confirmLabel:n="Confirm",confirmDisabled:i=!1,confirmLoading:s=!1,showConfirm:o=!0})=>a.jsxs(a.Fragment,{children:[t??a.jsx("div",{}),a.jsxs(P,{gap:2,children:[a.jsx(be,{variant:"outline",onClick:e,children:"Cancel"}),o&&r&&a.jsx(be,{variant:"outline",onClick:r,disabled:i,loading:s,children:n})]})]}),OY={add:Oa,remove:lP,move:Pp,replace:Fu},DY=t=>typeof t=="object"&&t!==null?JSON.stringify(t,null,2):JSON.stringify(t),m2=t=>t===void 0?"(none)":typeof t=="string"?t||'""':JSON.stringify(t),FY=t=>t.op==="move"&&t.from?O$(t.from):"",LY=(t,e,r)=>t==="remove"?[]:t==="add"&&r?e.filter(n=>n.property!=="default"):e,$Y=({schemaPatch:t})=>{const{patch:e,fieldName:r}=t,n=OY[e.op];switch(e.op){case"add":return a.jsxs(P,{align:"center",gap:1.5,children:[a.jsx(He,{as:n,color:"gray.400",boxSize:4,flexShrink:0}),a.jsxs(j,{fontSize:"sm",color:"gray.600",children:["Field ",a.jsx(ps,{children:r})," was added"]})]});case"remove":return a.jsxs(P,{align:"center",gap:1.5,children:[a.jsx(He,{as:n,color:"gray.400",boxSize:4,flexShrink:0}),a.jsxs(j,{fontSize:"sm",color:"gray.600",children:["Field ",a.jsx(ps,{children:r})," was removed"]})]});case"move":{const i=FY(e);return t.isRename?a.jsxs(P,{align:"center",gap:1.5,children:[a.jsx(He,{as:n,color:"gray.400",boxSize:4,flexShrink:0}),a.jsxs(j,{fontSize:"sm",color:"gray.600",children:["Renamed field ",a.jsx(ps,{children:i})," to"," ",a.jsx(ps,{children:r})]})]}):a.jsxs(P,{align:"center",gap:1.5,children:[a.jsx(He,{as:n,color:"gray.400",boxSize:4,flexShrink:0}),a.jsxs(j,{fontSize:"sm",color:"gray.600",children:["Moved field ",a.jsx(ps,{children:i})," to"," ",a.jsx(ps,{children:r})]}),t.movesIntoArray&&a.jsx(St,{size:"sm",colorPalette:"yellow",variant:"subtle",children:"data will be cloned"})]})}case"replace":return a.jsxs(P,{align:"center",gap:1.5,children:[a.jsx(He,{as:n,color:"gray.400",boxSize:4,flexShrink:0}),a.jsxs(j,{fontSize:"sm",color:"gray.600",children:["Field ",a.jsx(ps,{children:r})," was modified"]})]});default:return a.jsxs(P,{align:"center",gap:1.5,children:[a.jsx(He,{as:Fu,color:"gray.400",boxSize:4,flexShrink:0}),a.jsxs(j,{fontSize:"sm",color:"gray.600",children:["Field ",a.jsx(ps,{children:r})," was changed"]})]})}},BY=({example:t})=>{const{value:e,type:r,foreignKeyTableId:n}=t;if(n)return null;const i=DY(e),s=i.includes(`
|
|
369
|
-
`);return a.jsxs(P,{align:s?"flex-start":"center",gap:2,fontSize:"xs",color:"gray.500",pl:2,children:[a.jsx(j,{color:"gray.400",children:"default:"}),a.jsx(T,{as:"code",px:s?2:1,py:s?1.5:.5,bg:"gray.100",borderRadius:"sm",fontFamily:"mono",whiteSpace:s?"pre":"nowrap",children:i}),a.jsxs(j,{color:"gray.400",children:["(",r,")"]})]})},zY=({severity:t})=>t==="none"?null:t==="possible"?a.jsx(St,{size:"sm",colorPalette:"yellow",variant:"subtle",children:"data may be lost"}):a.jsx(St,{size:"sm",colorPalette:"red",variant:"subtle",children:"data loss"}),VY=({info:t})=>a.jsxs(ge,{align:"stretch",gap:1,pl:2,children:[a.jsxs(P,{align:"center",gap:2,fontSize:"xs",flexWrap:"wrap",children:[t.steps.map((e,r)=>a.jsxs(P,{align:"center",gap:1,children:[r>0&&a.jsx(j,{color:"gray.400",children:"+"}),a.jsx(St,{size:"sm",colorPalette:"gray",variant:"subtle",children:e.name})]},e.name)),a.jsx(zY,{severity:t.dataLossSeverity})]}),a.jsxs(P,{align:"center",gap:2,fontSize:"xs",color:"gray.500",children:[a.jsx(j,{color:"gray.400",children:"example:"}),a.jsx(xg,{children:JSON.stringify(t.example.before)}),a.jsx(He,{as:Zw,color:"gray.400",flexShrink:0}),a.jsx(xg,{children:JSON.stringify(t.example.after)})]})]}),HY=({label:t,fromValue:e,toValue:r})=>a.jsxs(P,{align:"center",gap:2,fontSize:"xs",color:"gray.500",pl:2,flexWrap:"wrap",children:[a.jsxs(j,{color:"gray.400",children:[t,":"]}),a.jsx(xg,{children:e}),a.jsx(He,{as:Zw,color:"gray.400",flexShrink:0}),a.jsx(xg,{children:r})]}),qY=re(({schemaPatch:t})=>{const{patch:e,typeChange:r,propertyChanges:n}=t,i=_.useMemo(()=>r?KZ(r.fromType,r.toType):null,[r]),s=_.useMemo(()=>e.op==="add"&&e.value!==void 0?XZ({path:e.path,value:e.value}):null,[e]),o=_.useMemo(()=>LY(e.op,n,s),[e.op,n,s]);return a.jsxs(T,{borderBottom:"1px solid",borderColor:"gray.100",py:4,px:5,_last:{borderBottom:"none"},_hover:{bg:"gray.50"},children:[a.jsx($Y,{schemaPatch:t}),s&&a.jsx(T,{mt:2,ml:8,children:a.jsx(BY,{example:s})}),i&&a.jsx(T,{mt:2,ml:8,children:a.jsx(VY,{info:i})}),o.map(l=>a.jsx(T,{mt:2,ml:8,children:a.jsx(HY,{label:l.property,fromValue:m2(l.from),toValue:m2(l.to)})},l.property))]})}),WY=({change:t})=>a.jsx(T,{borderBottom:"1px solid",borderColor:"gray.100",py:4,px:5,_last:{borderBottom:"none"},_hover:{bg:"gray.50"},children:a.jsxs(P,{align:"center",gap:1.5,children:[a.jsx(He,{as:Pp,color:"gray.400",boxSize:4,flexShrink:0}),a.jsxs(j,{fontSize:"sm",color:"gray.600",children:["Table renamed from ",a.jsx(ps,{children:t.initialTableId})," to"," ",a.jsx(ps,{children:t.currentTableId})]})]})}),Wy=({message:t,type:e,fieldPath:r})=>a.jsx(T,{py:2,px:4,children:a.jsxs(P,{align:"center",gap:2,children:[a.jsx(He,{as:vP,color:"gray.400",boxSize:4,flexShrink:0}),a.jsxs(j,{fontSize:"sm",color:"gray.600",children:[e==="formula"&&a.jsx(St,{size:"sm",colorPalette:"gray",variant:"subtle",mr:2,children:"formula"}),e==="tableId"&&a.jsx(St,{size:"sm",colorPalette:"gray",variant:"subtle",mr:2,children:"table name"}),r&&a.jsxs(T,{as:"span",fontWeight:"medium",children:[r,":"," "]}),t]})]})}),h4=({onRevert:t,disabled:e})=>a.jsxs(kr,{children:[a.jsx(ci,{asChild:!0,children:a.jsxs(be,{variant:"ghost",size:"sm",color:"gray.500",disabled:e,children:[a.jsx(He,{as:gm}),"Revert All"]})}),a.jsx(Ar,{children:a.jsxs(gr,{children:[a.jsx(Rh,{}),a.jsxs(Ei,{children:[a.jsx(j,{fontSize:"sm",mb:3,children:"This will revert all changes. Are you sure?"}),a.jsxs(P,{gap:2,justify:"flex-end",children:[a.jsx(Mo,{asChild:!0,children:a.jsx(be,{variant:"outline",size:"xs",children:"Cancel"})}),a.jsx(Mo,{asChild:!0,children:a.jsx(be,{variant:"outline",size:"xs",colorPalette:"red",onClick:t,children:"Revert"})})]})]})]})})]}),GY=re(({isOpen:t,onClose:e,vm:r})=>a.jsx(nC,{isOpen:t,onClose:e,title:`Review Errors for "${r.tableId}"`,footer:a.jsx(iC,{leftContent:r.canRevert?a.jsx(h4,{onRevert:r.revert}):void 0,onCancel:e,showConfirm:!1}),children:a.jsx(ge,{align:"stretch",gap:4,children:a.jsxs(T,{border:"1px solid",borderColor:"gray.200",borderRadius:"md",bg:"gray.50",overflow:"hidden",children:[a.jsx(T,{py:2,px:4,bg:"gray.100",borderBottom:"1px solid",borderColor:"gray.200",children:a.jsx(j,{fontSize:"sm",fontWeight:"medium",color:"gray.600",children:"Please fix the following errors before applying changes:"})}),a.jsxs(ge,{align:"stretch",gap:0,divideY:"1px",divideColor:"gray.100",children:[r.tableIdError&&a.jsx(Wy,{message:r.tableIdError,type:"tableId"},"tableId-error"),r.validationErrors.map(n=>a.jsx(Wy,{message:n.message,type:"validation"},`validation-${n.nodeId}`)),r.formulaErrors.map(n=>a.jsx(Wy,{message:n.message,type:"formula",fieldPath:n.fieldPath},`formula-${n.fieldPath??""}-${n.message}`))]})]})})})),UY=re(({isOpen:t,onClose:e,vm:r})=>{const n=`Apply Changes (${r.totalChangesCount})`;return a.jsx(nC,{isOpen:t,onClose:e,title:`Review Changes for "${r.tableId}"`,footer:a.jsx(iC,{leftContent:a.jsx(h4,{onRevert:r.revert,disabled:!r.hasChanges}),onCancel:e,onConfirm:r.approve,confirmLabel:n,confirmDisabled:!r.hasChanges,confirmLoading:r.loading}),children:a.jsx(ge,{align:"stretch",gap:4,children:r.hasChanges?a.jsxs(a.Fragment,{children:[a.jsxs(jA,{size:"sm",value:r.viewMode,onValueChange:i=>r.setViewMode(i.value),children:[a.jsx(RA,{}),a.jsx(TA,{items:["Changes","Patches"]})]}),a.jsx(T,{border:"1px solid",borderColor:"gray.200",borderRadius:"md",overflow:"hidden",maxHeight:"400px",overflowY:"auto",children:r.viewMode==="Changes"?a.jsxs(a.Fragment,{children:[r.tableIdChange&&a.jsx(WY,{change:r.tableIdChange}),r.patches.map(i=>a.jsx(qY,{schemaPatch:i},`${i.patch.op}:${i.patch.path}`))]}):a.jsx(yg,{readonly:!0,data:r.patches.map(i=>i.patch)})}),a.jsx(j,{fontSize:"xs",color:"gray.500",children:"Data in existing rows will be automatically transformed according to the new schema."})]}):a.jsx(P,{justify:"center",align:"center",minHeight:"100px",children:a.jsx(j,{color:"gray.400",fontSize:"sm",children:"No changes to apply"})})})})}),KY=re(({isOpen:t,onClose:e,vm:r})=>a.jsx(nC,{isOpen:t,onClose:e,title:`Create Table "${r.tableId}"`,footer:a.jsx(iC,{onCancel:e,onConfirm:r.approve,confirmLabel:"Create Table",confirmLoading:r.loading}),children:a.jsxs(ge,{align:"stretch",gap:4,children:[a.jsxs(jA,{size:"sm",value:r.viewMode,onValueChange:n=>r.setViewMode(n.value),children:[a.jsx(RA,{}),a.jsx(TA,{items:["Example","Schema"]})]}),a.jsx(T,{border:"1px solid",borderColor:"gray.200",borderRadius:"md",overflow:"hidden",maxHeight:"400px",overflowY:"auto",children:r.viewMode==="Example"?a.jsx(yg,{readonly:!0,data:r.exampleData??null}):a.jsx(yg,{readonly:!0,data:r.plainSchema??null})})]})})),d4=re(({vm:t,dataTestId:e,backButton:r,primaryAction:n,dialogs:i})=>a.jsxs(P,{flex:1,flexDirection:"column",gap:"0.5rem",css:{"&:hover .editor-hover-target":{opacity:1}},"data-testid":e,children:[a.jsxs(P,{justifyContent:"space-between",width:"100%",alignItems:"center",paddingBottom:"8px",children:[a.jsxs(T,{children:[r,t.showReviewErrorsButton&&a.jsxs(be,{size:"sm",variant:"ghost",onClick:t.openErrorsDialog,"data-testid":"schema-editor-review-errors-button",children:["Review Errors (",t.errorsCount,")"]}),n?.show&&a.jsx(be,{size:"sm",variant:"ghost",onClick:n.onClick,loading:t.loading,"data-testid":n.testId,children:n.label})]}),a.jsx(T,{className:"editor-hover-target",opacity:0,children:a.jsx(aY,{availableRefByMode:!1,mode:t.viewMode,onChange:s=>t.setViewMode(s)})})]}),t.viewMode===zl.Tree&&a.jsx(T,{ref:s=>t.tree.keyboard.setContainerRef(s),tabIndex:0,onKeyDown:t.tree.keyboard.handleKeyDown,outline:0,paddingBottom:"4rem",children:a.jsx(rC,{accessor:t.tree.rootAccessor,treeVM:t.tree,dataTestId:"root"})}),t.viewMode===zl.Json&&a.jsx(yg,{readonly:!0,data:t.getPlainSchema()}),a.jsx(GY,{isOpen:t.isErrorsDialogOpen,onClose:t.closeErrorsDialog,vm:t.errorsDialogVM}),i]})),ZY=re(({vm:t})=>a.jsx(d4,{vm:t,dataTestId:"schema-editor-creating",backButton:a.jsx(fY,{dataTestId:"close-create-table-button",onClick:t.cancel}),primaryAction:{show:t.showCreateTableButton,label:"Create Table",testId:"schema-editor-create-button",onClick:t.openCreateDialog},dialogs:a.jsx(KY,{isOpen:t.isCreateDialogOpen,onClose:t.closeCreateDialog,vm:t.createDialogVM})})),YY=re(({vm:t})=>a.jsx(d4,{vm:t,dataTestId:"schema-editor-updating",backButton:a.jsx(pY,{dataTestId:"back-to-table-list-button",onClick:t.cancel}),primaryAction:{show:t.showApplyChangesButton,label:`Apply Changes (${t.totalChangesCount})`,testId:"schema-editor-approve-button",onClick:t.openChangesDialog},dialogs:a.jsx(UY,{isOpen:t.isChangesDialogOpen,onClose:t.closeChangesDialog,vm:t.changesDialogVM})}));function hb(t,e){if(e.push({type:"node",node:t}),t.showChildren)for(const r of t.childNodes)hb(r,e);t.isArray()&&t.showAddButton&&e.push({type:"add-button",array:t,guides:[...t.guides,!1]})}function XY(t){const e=[];if(t.isObject())for(const r of t.children)hb(r,e);else hb(t,e);return e}var JY=class{_expanded=We.map();_focused=We.map();constructor(){le(this,{},{autoBind:!0})}isExpanded(t){return this._expanded.get(t)??!0}setExpanded(t,e){this._expanded.set(t,e)}toggleExpanded(t){this._expanded.set(t,!this.isExpanded(t))}isFocused(t){return this._focused.get(t)??!1}setFocused(t,e){this._focused.set(t,e)}expandAll(t){for(const e of t)this._expanded.set(e,!0)}collapseAll(t){for(const e of t)this._expanded.set(e,!1)}reset(){this._expanded.clear(),this._focused.clear()}},QY=class{_menu;_layout;constructor(t,e,r,n,i,s){this.node=t,this.parent=e,this._state=r,this._tree=n,this.editorContext=i,this._childResolver=s,le(this,{},{autoBind:!0})}setMenu(t){this._menu=t}setLayout(t){this._layout=t}get id(){return this.node.id}get name(){return this.node.name}get displayName(){return this.parent?this.node.name:this._rootDisplayName()}get testId(){if(!this.parent)return"root";const t=this.parent.testId;return t==="root"&&this.parent.isObject()?this.name:`${t}-${this.name}`}isPrimitive(){return this.node.isPrimitive()}isObject(){return this.node.isObject()}isArray(){return this.node.isArray()}get isExpanded(){return this._state.isExpanded}set isExpanded(t){this._state.setExpanded(t)}get isFocused(){return this._state.isFocused}expand(){this._state.setExpanded(!0)}collapse(){this._state.setExpanded(!1)}toggleExpanded(){this._state.toggleExpanded()}setFocused(t){this._state.setFocused(t)}get depth(){return this._layout.depth}get guides(){return this._layout.guides}get isCollapsible(){return this._layout.isCollapsible}get isCollapsibleTree(){return this._layout.isCollapsibleTree}get rendererType(){return this._layout.rendererType}get isContainer(){return this._layout.isContainer}get childNodes(){return this._childResolver.getChildren(this)}get showChildren(){return this._layout.showChildren}get collapsedLabel(){return this._layout.collapsedLabel}get isLongText(){return this._layout.isLongText}expandAll(){this._layout.expandAll()}collapseAll(){this._layout.collapseAll()}get menu(){return this._menu.menu}get formula(){if(this.node.isPrimitive())return this.node.formula?.expression}get isEditorReadOnly(){return this.editorContext?.isReadOnly??!1}get path(){return this._tree.pathOf(this.node).asString()}get isDirty(){return this.node.isDirty}get value(){return this.node.value}get defaultValue(){return this.node.defaultValue}get isReadOnly(){return this.node.isReadOnly}get isFieldReadOnly(){return this.isReadOnly||this.isEditorReadOnly}setValue(t){this.node.setValue(t)}get children(){return this.node.isObject()?this._childResolver.getChildren(this):[]}child(t){return this.children.find(e=>e.name===t)}get items(){return this.node.isArray()?this._childResolver.getChildren(this):[]}get length(){return this.node.isArray()?this.node.length:0}at(t){const e=this.items;if(!(t<0||t>=e.length))return e[t]}pushValue(t){this.node.pushValue(t)}removeAt(t){this.node.removeAt(t)}move(t,e){this.node.move(t,e)}insertAt(t){this.node.pushValue(null);const e=this.length-1;t<e&&this.node.move(e,t)}get showAddButton(){return this.isExpanded&&!this.isEditorReadOnly}isForeignKey(){return PE(this.node)}get foreignKeyTableId(){return this.node.foreignKey}isFile(){return this.rendererType==="file"}get fileStatus(){return this._getFileChildValue("status","")}get fileId(){return this._getFileChildValue("fileId","")}get fileUrl(){return this._getFileChildValue("url","")}get fileMimeType(){return this._getFileChildValue("mimeType","")}get fileWidth(){return this._getFileChildNumericValue("width")}get fileHeight(){return this._getFileChildNumericValue("height")}get callbacks(){return this.editorContext?.callbacks??null}getChildAccessors(){return this._childResolver.getChildren(this)}_getFileChildValue(t,e){if(!this.node.isObject())return e;const r=this.node.child(t);return r?.isPrimitive()?String(r.value):e}_rootDisplayName(){const t=this.node.schema;return"type"in t?`<${t.type}>`:this.node.name}_getFileChildNumericValue(t){if(!this.node.isObject())return 0;const e=this.node.child(t);return e?.isPrimitive()&&Number(e.value)||0}},eX=class{constructor(t,e){this._nodeId=t,this._treeState=e,le(this,{},{autoBind:!0})}get isExpanded(){return this._treeState.isExpanded(this._nodeId)}setExpanded(t){this._treeState.setExpanded(this._nodeId,t)}toggleExpanded(){this._treeState.toggleExpanded(this._nodeId)}get isFocused(){return this._treeState.isFocused(this._nodeId)}setFocused(t){this._treeState.setFocused(this._nodeId,t)}},tX=class{constructor(t){this._accessor=t,le(this,{},{autoBind:!0})}get menu(){return[...this.topMenu,...this.arrayOwnMenu,...this.arrayItemMenu,...this.bottomMenu]}get arrayItemContext(){const t=this._accessor.parent;if(!t||!t.node.isArray())return null;const e=t.node,r=e.value.indexOf(this._accessor.node);return r===-1?null:{index:r,arrayLength:e.value.length,insertAt:n=>t.insertAt(n),removeAt:n=>t.removeAt(n),move:(n,i)=>t.move(n,i)}}get topMenu(){return this._accessor.isCollapsibleTree?[{value:"expand",label:"Expand",handler:()=>this._accessor.expandAll()},{value:"collapse",label:"Collapse",handler:()=>this._accessor.collapseAll(),afterSeparator:!0}]:[]}get arrayOwnMenu(){return this._accessor.node.isArray()?[{value:"array",label:"Array",children:[...this._accessor.length>0?[{value:"add-first",label:"Add item to start",handler:()=>this._accessor.insertAt(0)}]:[],{value:"add-last",label:"Add item to end",handler:()=>this._accessor.pushValue(null)}]}]:[]}get arrayItemMenu(){const t=this.arrayItemContext;if(!t)return[];const e=t.arrayLength>1?this.buildMoveMenuItem(t):null;return[...e?[e]:[],{value:"item",label:"Item",children:[{value:"add-before",label:"Add before",handler:()=>t.insertAt(t.index)},{value:"add-after",label:"Add after",handler:()=>t.insertAt(t.index+1)}]},{value:"delete",label:"Delete",handler:()=>t.removeAt(t.index),afterSeparator:!0}]}buildMoveMenuItem(t){const{index:e,arrayLength:r}=t,n=e===0,i=e===r-1;return{value:"move",label:"Move",children:[...r>2&&e>1?[{value:"move-to-start",label:"to start",handler:()=>t.move(e,0)}]:[],...n?[]:[{value:"move-up",label:"up",handler:()=>t.move(e,e-1)}],...i?[]:[{value:"move-down",label:"down",handler:()=>t.move(e,e+1)}],...r>2&&e<r-2?[{value:"move-to-end",label:"to end",handler:()=>t.move(e,r-1)}]:[]]}}get bottomMenu(){const t=[{value:"json",label:"json",handler:()=>this.copyJson()}];return this._accessor.path&&t.push({value:"path",label:"path",handler:()=>this.copyPath()}),[{value:"copy",label:"Copy",children:t}]}async copyJson(){const t=JSON.stringify(this._accessor.node.getPlainValue(),null,2);await navigator.clipboard.writeText(t)}async copyPath(){await navigator.clipboard.writeText(this._accessor.path)}};const rX=64;var nX=class{constructor(t){this._accessor=t,le(this,{},{autoBind:!0})}get depth(){let t=0,e=this._accessor.parent;for(;e;)t++,e=e.parent;return t}get guides(){const t=[];let e=this._accessor.parent;for(;e;){if(e.parent){const r=e.parent.getChildAccessors().at(-1)?.id===e.id;t.unshift(!r)}else e.isObject()||t.unshift(!1);e=e.parent}return t}get isCollapsible(){return this._accessor.getChildAccessors().length>0}get isCollapsibleTree(){return this.isCollapsible||this._accessor.getChildAccessors().some(t=>t.isCollapsible)}get rendererType(){if(this._accessor.node.isObject()){const t=this._accessor.node.schema;return"$ref"in t&&t.$ref===Be.File?"file":"container"}if(this._accessor.node.isArray())return"container";if(PE(this._accessor.node))return"foreignKey";if(this._accessor.node.isPrimitive()){const t=this._accessor.value;if(typeof t=="boolean")return"boolean";if(typeof t=="number")return"number"}return"string"}get isContainer(){return this._accessor.node.isObject()||this._accessor.node.isArray()}get isRefNode(){return"$ref"in this._accessor.node.schema&&this.isContainer}get showChildren(){return this.isContainer&&this._accessor.isExpanded&&this._accessor.getChildAccessors().length>0}get collapsedLabel(){return this._accessor.node.isPrimitive()?this.primitiveCollapsedLabel:this._accessor.node.isObject()?Gy(this._accessor.children.length,"key","keys"):this._accessor.node.isArray()?Gy(this._accessor.length,"item","items"):""}get primitiveCollapsedLabel(){const t=this._accessor.value;if(typeof t!="string")return"";if(!t.trim())return"<empty text>";const e=t.trim().split(/\s+/).length;return Gy(e,"word","words","text: ")}get isLongText(){const t=this._accessor.value;return typeof t=="string"&&t.length>rX}expandAll(){this._accessor.expand();for(const t of this._accessor.getChildAccessors())t.isCollapsible&&t.expandAll()}collapseAll(){this._accessor.collapse();for(const t of this._accessor.getChildAccessors())t.isCollapsible&&t.collapseAll()}};function Gy(t,e,r,n=""){return`<${n}${t} ${t===1?e:r}>`}var iX=class{constructor(t,e,r){this._tree=t,this._treeState=e,this._editorContext=r}create(t,e,r){const n=new QY(t,e,new eX(t.id,this._treeState),this._tree,this._editorContext,r),i=new nX(n),s=new tX(n);return n.setLayout(i),n.setMenu(s),i.isRefNode&&this._treeState.setExpanded(t.id,!1),n}},sX=class{_cache=We.map();constructor(t){this._factory=t}getOrCreate(t,e){const r=this._cache.get(t.id);if(r)return r;const n=this._factory.create(t,e,this);return this._cache.set(t.id,n),n}getChildren(t){const e=t.node;return e.isObject()?e.children.map(r=>this.getOrCreate(r,t)):e.isArray()?e.value.map(r=>this.getOrCreate(r,t)):[]}clear(){this._cache.clear()}},oX=class{treeState=new JY;_cache;_root;constructor(t,e,r){this._cache=new sX(new iX(t,this.treeState,e)),this._root=this._cache.getOrCreate(t.root,null),r?.collapseComplexity&&this._collapseIfComplex(r.collapseComplexity),le(this,{treeState:!1},{autoBind:!0})}get root(){return this._root}get flattenedNodes(){return XY(this._root)}dispose(){this._cache.clear(),this.treeState.reset()}_collapseIfComplex(t){const e=this._collectAllNodeIds(this._root);e.length>=t&&(this.treeState.collapseAll(e),this.treeState.setExpanded(this._root.id,!0))}_collectAllNodeIds(t,e=[]){e.push(t.id);for(const r of t.getChildAccessors())this._collectAllNodeIds(r,e);return e}},aX=class{_rowModel;_core;_mode;_callbacks;_onChange;_onSave;_onCancel;_disposeReaction;_prevPatchCount=0;_rowId;_initialRowId;constructor(t,e,r){tC(),this._mode=r?.mode??"editing",this._rowId=r?.rowId??"",this._initialRowId=this._rowId,this._callbacks=r?.callbacks??null,this._onChange=r?.onChange??null,this._onSave=r?.onSave??null,this._onCancel=r?.onCancel??null,this._rowModel=DE({rowId:"editor",schema:t,data:e,refSchemas:r?.refSchemas}),this._core=new oX(this._rowModel.tree,this,{collapseComplexity:r?.collapseComplexity}),le(this,{},{autoBind:!0}),this._disposeReaction=this._onChange?bn(()=>this.patches,()=>this._emitChange()):null}get root(){return this._core.root}get flattenedNodes(){return this._core.flattenedNodes}get rowModel(){return this._rowModel}get mode(){return this._mode}get rowId(){return this._rowId}get initialRowId(){return this._initialRowId}get isRowIdChanged(){return this._rowId!==this._initialRowId}setRowId(t){this._rowId=t}get isDirty(){return this._rowModel.isDirty}get hasChanges(){return this.isDirty||this.isRowIdChanged}get isValid(){return this._rowModel.isValid}get errors(){return this._rowModel.errors}get isReadOnly(){return this._mode==="reading"}get callbacks(){return this._callbacks}get patches(){return this._rowModel.patches}getValue(){return this._rowModel.getPlainValue()}save(){const t=this.getValue(),e=this.patches;this.commit(),this._onSave?.(this._rowId,t,e)}markAsSaved(){this.commit()}cancel(){this._onCancel?.()}commit(){this._rowModel.commit(),this._prevPatchCount=0,this._initialRowId=this._rowId}revert(){this._rowModel.revert(),this._prevPatchCount=0}dispose(){this._disposeReaction?.(),this._core.dispose(),this._rowModel.dispose()}_emitChange(){if(!this._onChange||!this.isValid)return;const t=this.patches,e=t.slice(this._prevPatchCount);this._prevPatchCount=t.length,e.length>0&&this._onChange(e)}};function lX(t){return t.map((e,r)=>({key:`d${r}`,showLine:e}))}const cX=({guides:t})=>{const e=lX(t);return a.jsxs(P,{position:"relative",alignItems:"center",children:[a.jsx(T,{left:"-48px",width:"48px",height:"100%",position:"absolute"}),e.map(r=>a.jsx(T,{position:"relative",width:"24px",height:"100%",_before:r.showLine?{content:'""',position:"absolute",left:"8px",top:0,bottom:0,width:"1px",backgroundColor:"blackAlpha.200"}:void 0},r.key))]})},uX=(t,e)=>{if(t)return e?`${t}-expand`:`${t}-collapse`},hX=({isCollapsed:t,isCollapsible:e,toggleCollapsed:r,testId:n})=>a.jsxs(a.Fragment,{children:[!t&&a.jsx(P,{color:"gray.300",width:"16px",height:"28px",_groupHover:{display:e?"none":"flex"},alignItems:"center",justifyContent:"center",children:a.jsx(Uw,{})}),e&&a.jsx(P,{_groupHover:{display:"inline-flex",color:"gray.500"},display:t?"inline-flex":"none",_hover:{backgroundColor:"transparent"},color:"gray.400",onClick:r,width:"16px",height:"28px",alignItems:"center",justifyContent:"center",cursor:"pointer","data-testid":uX(n,t),children:a.jsx(T,{transform:t?"rotate(0deg)":"rotate(90deg)",children:a.jsx(xO,{size:16})})})]}),dX=({name:t,formula:e,description:r,isDeprecated:n})=>{const s=e&&r?a.jsxs(T,{children:[a.jsxs(P,{alignItems:"center",gap:"4px",marginBottom:"4px",fontWeight:"medium",children:[a.jsx(ey,{size:14}),a.jsx("span",{children:e})]}),a.jsx(T,{color:"gray.300",children:r})]}):e?a.jsxs(P,{alignItems:"center",gap:"4px",children:[a.jsx(ey,{size:14}),a.jsx("span",{children:e})]}):r||null,o=a.jsxs(P,{alignItems:"center",gap:"4px",color:"gray.400",children:[a.jsxs(j,{textDecoration:n?"line-through":void 0,children:[t,":"]}),e&&a.jsx(ey,{size:14})]});return a.jsx(P,{height:"28px",alignItems:"center",children:s?a.jsx(Ys,{openDelay:350,content:s,positioning:{placement:"right-end"},showArrow:!0,children:o}):o})},fX=({onClick:t,label:e})=>a.jsx(j,{ml:"8px",color:"gray.300",onClick:t,cursor:"pointer",children:e}),pX=re(({node:t})=>{const[e,r]=_.useState(!1);return t.menu.length===0?null:a.jsxs(Dt,{lazyMount:!0,unmountOnExit:!0,onOpenChange:({open:n})=>r(n),children:[a.jsx(Tr,{asChild:!0,children:a.jsx(P,{width:"24px",left:"-24px",position:"absolute",zIndex:1,alignItems:"center",justifyContent:"center",cursor:"pointer",children:a.jsx(P,{alignItems:"center",justifyContent:"center",mt:"2px",height:"24px",width:"12px",borderRadius:"4px",bg:"blackAlpha.50",backdropFilter:"blur(4px)",boxShadow:"0 0 0 1px rgba(0,0,0,0.06), 0 1px 1px rgba(0,0,0,0.08)",opacity:e?1:0,transition:e?"opacity 1s ease 0s":void 0,_groupHover:{opacity:1,transition:"opacity 0.5s ease 0s"},_hover:{boxShadow:"0 0 0 1px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.1)"},children:a.jsx(He,{size:"md",color:"gray.400",as:YE})})})}),a.jsx(je,{children:a.jsx(Ft,{children:a.jsx(Lt,{children:t.menu.map(n=>n.children?a.jsxs(Dt,{positioning:{placement:"right-start",gutter:2},children:[n.beforeSeparator&&a.jsx(yr,{}),a.jsxs(oo,{width:"100%",justifyContent:"space-between",children:[n.label," ",a.jsx(za,{})]}),n.afterSeparator&&a.jsx(yr,{}),a.jsx(je,{children:a.jsx(Ft,{children:a.jsx(Lt,{children:n.children.map(i=>a.jsxs(_.Fragment,{children:[i.beforeSeparator&&a.jsx(yr,{}),a.jsx(et,{value:i.value,onClick:i.handler,children:a.jsx(T,{flex:1,children:i.label})}),i.afterSeparator&&a.jsx(yr,{})]},i.value))})})})]},n.value):a.jsxs(_.Fragment,{children:[n.beforeSeparator&&a.jsx(yr,{}),a.jsx(et,{value:n.value,onClick:n.handler,children:a.jsx(T,{flex:1,children:n.label})}),n.afterSeparator&&a.jsx(yr,{})]},n.value))})})})]})}),Is=({node:t,name:e,guides:r,isCollapsible:n=!1,isExpanded:i=!0,onToggle:s,formula:o,description:l,isDeprecated:c,skipDot:u,skipField:h,skipMore:d,collapsedLabel:f,isReadOnly:p,testId:g,onMouseEnter:y,onMouseLeave:m,children:v})=>{const x=n&&!i,b=t&&!p;return a.jsxs(P,{width:"100%",onMouseEnter:y,onMouseLeave:m,position:"relative",className:"group","data-testid":g,children:[a.jsx(cX,{guides:r}),b&&a.jsx(pX,{node:t}),a.jsxs(P,{width:"100%",alignItems:"center",children:[a.jsxs(P,{children:[!u&&a.jsx(hX,{isCollapsed:x,isCollapsible:n,toggleCollapsed:s,testId:g}),!h&&a.jsx(dX,{name:e,formula:o,description:l,isDeprecated:c}),v]}),!d&&x&&f&&a.jsx(fX,{onClick:s,label:f})]})]})},gX=re(({node:t})=>{const e=_.useCallback(()=>{t.toggleExpanded()},[t]);return a.jsx(Is,{node:t,name:t.displayName,guides:t.guides,isCollapsible:t.isCollapsible,isExpanded:t.isExpanded,onToggle:e,collapsedLabel:t.collapsedLabel,isReadOnly:t.isEditorReadOnly,testId:t.testId})}),sC=re(({value:t,readonly:e,prefix:r="",postfix:n="",restrict:i,dataTestId:s,onChange:o,onFocus:l,onBlur:c})=>{const[u,h]=_.useState(!1),d=_.useCallback(()=>{h(!0),l?.()},[l]),f=_.useCallback(()=>{h(!1),c?.()},[c]);return a.jsx(T,{borderRadius:"4px",bgColor:u?"gray.100":void 0,_hover:{bgColor:e?void 0:"gray.100"},mt:"2px",ml:"2px",pl:"4px",pr:"4px",minHeight:"24px",minWidth:"15px",cursor:e?"text":void 0,children:e?`${r}${t}${n}`:a.jsx(s4,{dataTestId:s,prefix:r,postfix:n,initValue:t,onChange:o,onFocus:d,onBlur:f,restrict:i})})}),db=({value:t,setValue:e,readonly:r,dataTestId:n})=>{const[i,s]=_.useState(t);_.useEffect(()=>{s(t)},[t]);const o=_.useCallback(u=>{s(u)},[]),l=_.useCallback(()=>{e(i)},[i,e]),c=i?"":'"';return a.jsx(sC,{prefix:c,postfix:c,value:i,readonly:r,dataTestId:n,onChange:o,onBlur:l})},mX=re(({node:t})=>{const e=String(t.value),r=_.useCallback(i=>{t.setValue(i)},[t]),n=_.useCallback(()=>{t.toggleExpanded()},[t]);return t.isLongText?a.jsxs(a.Fragment,{children:[a.jsx(Is,{node:t,name:t.displayName,guides:t.guides,formula:t.formula,isCollapsible:!0,isExpanded:t.isExpanded,onToggle:n,collapsedLabel:t.collapsedLabel,isReadOnly:t.isEditorReadOnly,testId:t.testId}),t.isExpanded&&a.jsx(Is,{name:"",guides:[...t.guides,!0],skipDot:!0,skipField:!0,children:a.jsx(db,{value:e,setValue:r,readonly:t.isFieldReadOnly,dataTestId:`${t.testId}-editor`})})]}):a.jsx(Is,{node:t,name:t.displayName,guides:t.guides,formula:t.formula,isReadOnly:t.isEditorReadOnly,testId:t.testId,children:a.jsx(db,{value:e,setValue:r,readonly:t.isFieldReadOnly,dataTestId:`${t.testId}-editor`})})}),yX=/^[\d.eE+-]+$/,xX=({value:t,setValue:e,readonly:r,dataTestId:n})=>{const i=t.toString(),s=_.useRef(i),[o,l]=_.useState(i);return _.useEffect(()=>{l(i),s.current=i},[i]),a.jsx(sC,{value:o,readonly:r,dataTestId:n,onChange:_.useCallback(c=>{l(c)},[]),onBlur:_.useCallback(()=>{const c=o.trim(),u=Number(c);c!==""&&Number.isFinite(u)?(e(u),l(u.toString()),s.current=u.toString()):l(s.current)},[e,o]),restrict:yX})},vX=re(({node:t})=>{const e=_.useCallback(r=>{t.setValue(r)},[t]);return a.jsx(Is,{node:t,name:t.displayName,guides:t.guides,formula:t.formula,isReadOnly:t.isEditorReadOnly,testId:t.testId,children:a.jsx(xX,{value:Number(t.value),setValue:e,readonly:t.isFieldReadOnly,dataTestId:`${t.testId}-editor`})})}),f4=({isOpen:t,setIsOpen:e,trigger:r,children:n,disabled:i,width:s})=>{const o=_.useCallback(()=>{i||e(!0)},[i,e]);return a.jsxs(kr,{lazyMount:!0,unmountOnExit:!0,open:t,onOpenChange:({open:l})=>{i||e(l)},autoFocus:!1,closeOnInteractOutside:!i,modal:!1,positioning:{placement:"bottom-start"},children:[a.jsx(ci,{asChild:!0,children:a.jsx(T,{onClick:o,children:r})}),!i&&a.jsx(je,{children:a.jsx(Ar,{children:a.jsx(gr,{width:s,p:1,children:n})})})]})},y2=({children:t,onClick:e})=>a.jsx(T,{px:2,py:1.5,cursor:"pointer",borderRadius:"md",fontSize:"sm",_hover:{bg:"gray.100"},onClick:e,children:t}),bX=({children:t,onChange:e,disabled:r})=>{const[n,i]=_.useState(!1),s=_.useCallback(o=>{e(o==="true"),i(!1)},[e]);return a.jsxs(f4,{width:"60px",isOpen:n,setIsOpen:i,trigger:t,disabled:r,children:[a.jsx(y2,{onClick:()=>s("true"),children:"true"}),a.jsx(y2,{onClick:()=>s("false"),children:"false"})]})},wX=({value:t,setValue:e,readonly:r,dataTestId:n})=>{const i=t.toString(),[s,o]=_.useState(i);_.useEffect(()=>{o(i)},[i]);const l=_.useCallback(u=>{o(u)},[]),c=_.useCallback(()=>{const u=s.trim(),h=u.toLowerCase()==="false"||u==="0"?!1:!!u;o(h.toString()),e(h)},[e,s]);return a.jsx(bX,{onChange:_.useCallback(u=>{o(u.toString()),e(u)},[e]),disabled:r,children:a.jsx(sC,{value:s,readonly:r,dataTestId:n,onChange:l,onBlur:c})})},SX=re(({node:t})=>{const e=_.useCallback(r=>{t.setValue(r)},[t]);return a.jsx(Is,{node:t,name:t.displayName,guides:t.guides,formula:t.formula,isReadOnly:t.isEditorReadOnly,testId:t.testId,children:a.jsx(wX,{value:!!t.value,setValue:e,readonly:t.isFieldReadOnly,dataTestId:`${t.testId}-editor`})})}),CX=re(({node:t})=>{const e=String(t.value),r=!!e&&!!t.callbacks?.onNavigateToForeignKey,n=!e&&!t.isEditorReadOnly,i=_.useCallback(()=>{t.callbacks?.onNavigateToForeignKey?.(t.foreignKeyTableId,e)},[t,e]);return a.jsxs(P,{alignItems:"center",gap:"4px",children:[r&&a.jsx(lt,{"aria-label":"Navigate to foreign key",variant:"ghost",size:"2xs",color:"gray.500",_hover:{color:"black",bg:"gray.100"},onClick:i,"data-testid":`${t.testId}-fk-navigate`,children:a.jsx(az,{})}),n&&a.jsx(Ys,{openDelay:50,closeDelay:50,content:"This field requires a valid foreign key ID",children:a.jsx(P,{width:"24px",height:"24px",alignItems:"center",justifyContent:"center",color:"gray.400",children:a.jsx(gP,{})})})]})});var _X=class{_timer=null;constructor(t){this._delay=t}schedule(t){this._timer&&clearTimeout(this._timer),this._timer=setTimeout(t,this._delay)}dispose(){this._timer&&(clearTimeout(this._timer),this._timer=null)}},IX=class{_search="";_state="loading";_ids=[];_hasMore=!1;_initialized=!1;_disposeReaction=null;_debounce=new _X(300);constructor(t,e){this._tableId=t,this._onSearch=e,le(this,{},{autoBind:!0})}get search(){return this._search}get state(){return this._state}get ids(){return this._ids}get hasMore(){return this._hasMore}get showInput(){return this._state==="list"||this._state==="notFound"||this._state==="loading"&&this._initialized}get showFooter(){return this._state==="list"||this._state==="notFound"||this._state==="error"||this._state==="empty"}get showLoading(){return this._state==="loading"}get showNotFound(){return this._state==="notFound"}get showError(){return this._state==="error"}get showEmpty(){return this._state==="empty"}get showList(){return this._state==="list"}get tableId(){return this._tableId}init(){this._performSearch(),this._disposeReaction=bn(()=>this._search,()=>this._debouncedSearch())}setSearch(t){this._search=t}dispose(){this._disposeReaction?.(),this._disposeReaction=null,this._debounce.dispose()}_debouncedSearch(){this._debounce.schedule(()=>{this._performSearch()})}_resolveState(t,e){return t.length===0&&!e?"empty":t.length===0?"notFound":"list"}async _performSearch(){if(!this._onSearch){this._state="error";return}const t=this._search;try{this._state="loading";const e=await this._onSearch(this._tableId,t);me(()=>{this._search===t&&(this._initialized=!0,this._ids=e.ids,this._hasMore=e.hasMore,this._state=this._resolveState(e.ids,t))})}catch{me(()=>{this._search===t&&(this._state="error")})}}};const jX=({tableId:t,onClose:e})=>a.jsxs(P,{p:"4px",alignItems:"center",justifyContent:"space-between",children:[a.jsxs(j,{fontSize:"xs",color:"gray.600",fontWeight:"medium",children:['Select from "',t,'"']}),e&&a.jsx(lt,{"aria-label":"Close",variant:"ghost",size:"2xs",color:"gray.500",_hover:{color:"black"},onClick:e,children:a.jsx(_c,{})})]}),RX=({value:t,onChange:e})=>{const r=_.useCallback(i=>{e(i.target.value)},[e]),n=_.useCallback(()=>{e("")},[e]);return a.jsxs(T,{px:"4px",pb:"4px",position:"relative",children:[a.jsx(Ot,{value:t,onChange:r,placeholder:"Search by ID...",size:"sm","data-testid":"fk-search-input",autoFocus:!0}),t&&a.jsx(lt,{"aria-label":"Clear",variant:"ghost",size:"2xs",position:"absolute",right:"8px",top:"50%",transform:"translateY(-50%)",onClick:n,color:"gray.400",_hover:{color:"black"},children:a.jsx(_c,{})})]})},TX=({id:t,onSelect:e})=>a.jsx(T,{px:2,py:1.5,mr:"12px",cursor:"pointer",borderRadius:"md",fontSize:"sm",_hover:{bg:"gray.100"},onClick:_.useCallback(()=>{e(t)},[t,e]),"data-testid":`fk-item-${t}`,children:t}),kX=({ids:t,onSelect:e})=>a.jsx(T,{flex:1,overflowY:"auto","data-testid":"fk-list",children:t.map(r=>a.jsx(TX,{id:r,onSelect:e},r))}),AX=()=>a.jsx(P,{flex:1,justifyContent:"center",alignItems:"center","data-testid":"fk-empty",children:a.jsx(j,{fontSize:"sm",color:"gray.500",children:"No rows found in this table"})}),EX=({onOpenTableSearch:t,onCreateAndConnect:e})=>t||e?a.jsxs(Me,{mt:"4px",p:"4px",gap:2,borderTopWidth:"1px",borderColor:"gray.200",children:[t&&a.jsxs(be,{size:"xs",variant:"ghost",color:"gray.500",onClick:t,"data-testid":"fk-open-table-search",children:[a.jsx(XE,{}),"Open Table Search"]}),e&&a.jsxs(be,{size:"xs",variant:"ghost",color:"gray.500",onClick:e,"data-testid":"fk-create-and-connect",children:[a.jsx(Ah,{}),"Create & Connect"]})]}):null,PX=re(({tableId:t,onSearch:e,onSelect:r,onClose:n,onOpenTableSearch:i,onCreateAndConnect:s})=>{const[o]=_.useState(()=>new IX(t,e));return _.useEffect(()=>(o.init(),()=>o.dispose()),[o]),a.jsxs(P,{flexDirection:"column",height:"290px",width:"100%","data-testid":"fk-picker",children:[a.jsx(jX,{tableId:t,onClose:n}),o.showInput&&a.jsx(RX,{value:o.search,onChange:o.setSearch}),o.showLoading&&a.jsx(P,{flex:1,justifyContent:"center",alignItems:"center",children:a.jsx(vt,{size:"sm",color:"gray.400"})}),o.showNotFound&&a.jsx(P,{flex:1,justifyContent:"center",alignItems:"center",children:a.jsx(j,{fontSize:"sm",color:"gray.500",children:"No results found"})}),o.showError&&a.jsx(P,{flex:1,justifyContent:"center",alignItems:"center",children:a.jsx(j,{fontSize:"sm",color:"gray.500",children:"Could not load data"})}),o.showEmpty&&a.jsx(AX,{}),o.showList&&a.jsx(kX,{ids:o.ids,onSelect:r}),o.showFooter&&a.jsx(EX,{onOpenTableSearch:i,onCreateAndConnect:s})]})}),NX=({node:t,onSelect:e,disabled:r,children:n})=>{const[i,s]=_.useState(!1),o=t.callbacks?.onSearchForeignKey,l=_.useCallback(d=>{e(d),s(!1)},[e]),c=_.useCallback(()=>{s(!1)},[]),u=_.useCallback(async()=>{if(!t.callbacks?.onOpenTableSearch)return;const d=await t.callbacks.onOpenTableSearch(t.foreignKeyTableId);d&&l(d)},[t.callbacks,t.foreignKeyTableId,l]),h=_.useCallback(async()=>{if(!t.callbacks?.onCreateAndConnect)return;const d=await t.callbacks.onCreateAndConnect(t.foreignKeyTableId);d&&l(d)},[t.callbacks,t.foreignKeyTableId,l]);return o?a.jsx(f4,{isOpen:i,setIsOpen:s,trigger:n,disabled:r,width:"320px",children:a.jsx(PX,{tableId:t.foreignKeyTableId,onSearch:o,onSelect:l,onClose:c,onOpenTableSearch:t.callbacks?.onOpenTableSearch?u:void 0,onCreateAndConnect:t.callbacks?.onCreateAndConnect?h:void 0})}):a.jsx(a.Fragment,{children:n})},MX=re(({node:t})=>{const e=String(t.value),r=_.useCallback(i=>{t.setValue(i)},[t]),n=_.useCallback(i=>{t.setValue(i)},[t]);return a.jsx(Is,{node:t,name:t.displayName,guides:t.guides,formula:t.formula,isReadOnly:t.isEditorReadOnly,testId:t.testId,children:a.jsxs(P,{alignItems:"center",gap:"2px",children:[a.jsx(NX,{node:t,onSelect:n,disabled:t.isFieldReadOnly,children:a.jsx(db,{value:e,setValue:r,readonly:t.isFieldReadOnly,dataTestId:`${t.testId}-editor`})}),a.jsx(CX,{node:t})]})})}),x2=({onClick:t,dataTestId:e})=>a.jsx(lt,{"data-testid":e,"aria-label":"Open file",variant:"ghost",size:"2xs",color:"gray.400",_hover:{bg:"gray.100",color:"black"},onClick:t,children:a.jsx(Pl,{})}),OX=({url:t,availablePreview:e,width:r,height:n,onClick:i,dataTestId:s})=>e?a.jsxs(en,{lazyMount:!0,unmountOnExit:!0,openDelay:350,closeDelay:100,positioning:{gutter:16},children:[a.jsx(tn,{asChild:!0,children:a.jsx("span",{children:a.jsx(x2,{onClick:i,dataTestId:s})})}),a.jsx(je,{children:a.jsx(rn,{children:a.jsxs(nn,{children:[a.jsx(sn,{children:a.jsx(on,{})}),a.jsx(im,{aspectRatio:n>0?r/n:1,width:"400px",src:t,alt:"File preview"})]})})})]}):a.jsx(x2,{onClick:i,dataTestId:s}),DX=re(({node:t})=>{const e=_.useRef(null),r=t.fileUrl,n=t.fileId,i=t.fileStatus,s=t.fileMimeType,o=t.fileWidth,l=t.fileHeight,c=t.isEditorReadOnly,u=s.startsWith("image/"),h=!!r,d=!c&&!!t.callbacks?.onUploadFile&&(i==="ready"||i==="uploaded"),f=!h&&!d,p=_.useCallback(async m=>{const v=m.target.files?.[0];if(!v)return;m.target.value="";const x=await t.callbacks?.onUploadFile?.(n,v);x&&t.node.setValue(x,{internal:!0})},[t,n]),g=_.useCallback(()=>{t.callbacks?.onOpenFile?t.callbacks.onOpenFile(r):window.open(r,"_blank","noopener,noreferrer")},[t,r]),y=_.useCallback(()=>{e.current?.click()},[]);return a.jsxs(P,{alignItems:"center",children:[f&&a.jsx(Ys,{openDelay:50,closeDelay:50,content:c?"The file was not uploaded in this revision":"Save the row first, then upload the file",children:a.jsx(P,{width:"24px",height:"24px",alignItems:"center",justifyContent:"center",color:"gray.400",children:a.jsx(gP,{})})}),h&&a.jsx(OX,{url:r,availablePreview:u,width:o,height:l,onClick:g,dataTestId:`${t.testId}-open-file`}),d&&a.jsxs(T,{children:[a.jsx("input",{ref:e,type:"file",onChange:p,style:{display:"none"},"data-testid":`${t.testId}-file-input`}),a.jsx(lt,{"aria-label":"Upload file",variant:"ghost",size:"2xs",color:h?"gray.300":"gray.500",_hover:{bg:"gray.100",color:"black"},onClick:y,"data-testid":`${t.testId}-upload-file`,children:a.jsx(cz,{})})]})]})}),FX=re(({node:t})=>{const e=_.useCallback(()=>{t.toggleExpanded()},[t]);return a.jsx(Is,{node:t,name:t.displayName,guides:t.guides,isCollapsible:t.isCollapsible,isExpanded:t.isExpanded,onToggle:e,collapsedLabel:t.collapsedLabel,isReadOnly:t.isEditorReadOnly,testId:t.testId,skipMore:!0,children:a.jsx(DX,{node:t})})}),p4={container:gX,string:mX,number:vX,boolean:SX,foreignKey:MX,file:FX},LX=re(({item:t})=>{if(t.type==="node"){const r=p4[t.node.rendererType];return a.jsx(r,{node:t.node})}const e=()=>{t.array.pushValue(null)};return a.jsx(Is,{name:"",guides:t.guides,skipDot:!0,skipField:!0,skipMore:!0,children:a.jsx(Gm,{title:"Item",onClick:e,dataTestId:`${t.array.testId}-add-button`})})}),g4=re(({viewModel:t})=>{const e=_.useCallback((r,n)=>a.jsx(LX,{item:n}),[]);return a.jsx(ui,{data:t.flattenedNodes,itemContent:e,useWindowScroll:!0,style:{width:"100%",height:"100%"}})}),$X=re(({viewModel:t})=>{const e=p4[t.rendererType],{showChildren:r,childNodes:n}=t,i=t.isArray()&&t.showAddButton,s=_.useCallback(()=>{t.isArray()&&t.pushValue(null)},[t]);return a.jsxs(_.Fragment,{children:[a.jsx(e,{node:t}),r&&a.jsx(ge,{align:"stretch",gap:0,children:n.map(o=>a.jsx($X,{viewModel:o},o.id))}),i&&a.jsx(Is,{name:"",guides:[...t.guides,!1],skipDot:!0,skipField:!0,skipMore:!0,children:a.jsx(Gm,{title:"Item",onClick:s,dataTestId:`${t.testId}-add-button`})})]})});var Fd={},v2;function BX(){if(v2)return Fd;v2=1;var t=K8();return Fd.createRoot=t.createRoot,Fd.hydrateRoot=t.hydrateRoot,Fd}var zX=BX();const VX={BASE_URL:"/",DEV:!1,GIT_BRANCH_NAME:"master",GIT_COMMIT_HASH:"877715b",MODE:"production",PACKAGE_VERSION:"2.4.0-alpha.1",PROD:!0,REACT_APP_ENDPOINT_HOST:"",REACT_APP_ENDPOINT_PORT:"",REACT_APP_ENDPOINT_SERVER_URL:"/endpoint",REACT_APP_GRAPHQL_SERVER_URL:"/graphql",REACT_APP_SWAGGER_SERVER_URL:"/api",SSR:!1},ku=t=>{const e=VX[t];return globalThis.__env__?.[t]||e};var HX=(t,e,r,n,i,s,o,l)=>{let c=document.documentElement,u=["light","dark"];function h(p){(Array.isArray(t)?t:[t]).forEach(g=>{let y=g==="class",m=y&&s?i.map(v=>s[v]||v):i;y?(c.classList.remove(...m),c.classList.add(s&&s[p]?s[p]:p)):c.setAttribute(g,p)}),d(p)}function d(p){l&&u.includes(p)&&(c.style.colorScheme=p)}function f(){return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}if(n)h(n);else try{let p=localStorage.getItem(e)||r,g=o&&p==="system"?f():p;h(g)}catch{}},b2=["light","dark"],m4="(prefers-color-scheme: dark)",qX=typeof window>"u",y4=_.createContext(void 0),w2=t=>_.useContext(y4)?_.createElement(_.Fragment,null,t.children):_.createElement(GX,{...t}),WX=["light","dark"],GX=({forcedTheme:t,disableTransitionOnChange:e=!1,enableSystem:r=!0,enableColorScheme:n=!0,storageKey:i="theme",themes:s=WX,defaultTheme:o=r?"system":"light",attribute:l="data-theme",value:c,children:u,nonce:h,scriptProps:d})=>{let[f,p]=_.useState(()=>KX(i,o)),[g,y]=_.useState(()=>f==="system"?Uy():f),m=c?Object.values(c):s,v=_.useCallback(C=>{let w=C;if(!w)return;C==="system"&&r&&(w=Uy());let I=c?c[w]:w,R=e?ZX(h):null,k=document.documentElement,M=N=>{N==="class"?(k.classList.remove(...m),I&&k.classList.add(I)):N.startsWith("data-")&&(I?k.setAttribute(N,I):k.removeAttribute(N))};if(Array.isArray(l)?l.forEach(M):M(l),n){let N=b2.includes(o)?o:null,D=b2.includes(w)?w:N;k.style.colorScheme=D}R?.()},[h]),x=_.useCallback(C=>{let w=typeof C=="function"?C(f):C;p(w);try{localStorage.setItem(i,w)}catch{}},[f]),b=_.useCallback(C=>{let w=Uy(C);y(w),f==="system"&&r&&!t&&v("system")},[f,t]);_.useEffect(()=>{let C=window.matchMedia(m4);return C.addListener(b),b(C),()=>C.removeListener(b)},[b]),_.useEffect(()=>{let C=w=>{w.key===i&&(w.newValue?p(w.newValue):x(o))};return window.addEventListener("storage",C),()=>window.removeEventListener("storage",C)},[x]),_.useEffect(()=>{v(t??f)},[t,f]);let S=_.useMemo(()=>({theme:f,setTheme:x,forcedTheme:t,resolvedTheme:f==="system"?g:f,themes:r?[...s,"system"]:s,systemTheme:r?g:void 0}),[f,x,t,g,r,s]);return _.createElement(y4.Provider,{value:S},_.createElement(UX,{forcedTheme:t,storageKey:i,attribute:l,enableSystem:r,enableColorScheme:n,defaultTheme:o,value:c,themes:s,nonce:h,scriptProps:d}),u)},UX=_.memo(({forcedTheme:t,storageKey:e,attribute:r,enableSystem:n,enableColorScheme:i,defaultTheme:s,value:o,themes:l,nonce:c,scriptProps:u})=>{let h=JSON.stringify([r,e,s,t,l,o,n,i]).slice(1,-1);return _.createElement("script",{...u,suppressHydrationWarning:!0,nonce:typeof window>"u"?c:"",dangerouslySetInnerHTML:{__html:`(${HX.toString()})(${h})`}})}),KX=(t,e)=>{if(qX)return;let r;try{r=localStorage.getItem(t)||void 0}catch{}return r||e},ZX=t=>{let e=document.createElement("style");return t&&e.setAttribute("nonce",t),e.appendChild(document.createTextNode("*,*::before,*::after{-webkit-transition:none!important;-moz-transition:none!important;-o-transition:none!important;-ms-transition:none!important;transition:none!important}")),document.head.appendChild(e),()=>{window.getComputedStyle(document.body),setTimeout(()=>{document.head.removeChild(e)},1)}},Uy=t=>(t||(t=window.matchMedia(m4)),t.matches?"dark":"light");const YX=()=>_.useCallback(t=>{t&&t.focus()},[]);class XX{registrations=new Map;register(e,r,n){this.registrations.set(e,{factory:r,scope:n.scope})}get(e){const r=this.registrations.get(e);if(!r)throw new Error(`No provider found for ${e.name}`);return r.scope==="singleton"?(r.instance??=r.factory(),r.instance):r.factory()}}const $=new XX;let x4=class{constructor(e,r){this.operator=e,this.value=r,Object.defineProperty(this,"t",{writable:!0})}get notes(){return this.t}addNote(e){this.t=this.t||[],this.t.push(e)}},oC=class extends x4{};class Um extends oC{constructor(e,r){if(!Array.isArray(r))throw new Error(`"${e}" operator expects to receive an array of conditions`);super(e,r)}}const Vh="__itself__";let Km=class extends x4{constructor(e,r,n){super(e,n),this.field=r}};const v4=new oC("__null__",null),fb=Object.prototype.hasOwnProperty.call.bind(Object.prototype.hasOwnProperty);function JX(t,e){return e instanceof Um&&e.operator===t}function b4(t,e){return e.length===1?e[0]:new Um(t,(function r(n,i,s){const o=s||[];for(let l=0,c=i.length;l<c;l++){const u=i[l];JX(n,u)?r(n,u.value,o):o.push(u)}return o})(t,e))}const QX=t=>t,w4=()=>Object.create(null),S4=Object.defineProperty(w4(),"__@type@__",{value:"ignore value"});function eJ(t,e,r=!1){if(!t||t&&t.constructor!==Object)return!1;for(const n in t)if(fb(t,n)&&fb(e,n)&&(!r||t[n]!==S4))return!0;return!1}function tJ(t){const e=[];for(const r in t)fb(t,r)&&t[r]!==S4&&e.push(r);return e}function Ky(t,e){e!==v4&&t.push(e)}const C4=t=>b4("and",t),_4={compound(t,e,r){const n=(Array.isArray(e)?e:[e]).map(i=>r.parse(i));return new Um(t.name,n)},field:(t,e,r)=>new Km(t.name,r.field,e),document:(t,e)=>new oC(t.name,e)};let rJ=class{constructor(e,r=w4()){this.o=void 0,this.s=void 0,this.i=void 0,this.u=void 0,this.h=void 0,this.parse=this.parse.bind(this),this.u={operatorToConditionName:r.operatorToConditionName||QX,defaultOperatorName:r.defaultOperatorName||"eq",mergeFinalConditions:r.mergeFinalConditions||C4},this.o=Object.keys(e).reduce((n,i)=>(n[i]=Object.assign({name:this.u.operatorToConditionName(i)},e[i]),n),{}),this.s=Object.assign({},r.fieldContext,{field:"",query:{},parse:this.parse,hasOperators:n=>eJ(n,this.o,r.useIgnoreValue)}),this.i=Object.assign({},r.documentContext,{parse:this.parse,query:{}}),this.h=r.useIgnoreValue?tJ:Object.keys}setParse(e){this.parse=e,this.s.parse=e,this.i.parse=e}parseField(e,r,n,i){const s=this.o[r];if(!s)throw new Error(`Unsupported operator "${r}"`);if(s.type!=="field")throw new Error(`Unexpected ${s.type} operator "${r}" at field level`);return this.s.field=e,this.s.query=i,this.parseInstruction(s,n,this.s)}parseInstruction(e,r,n){return typeof e.validate=="function"&&e.validate(e,r),(e.parse||_4[e.type])(e,r,n)}parseFieldOperators(e,r){const n=[],i=this.h(r);for(let s=0,o=i.length;s<o;s++){const l=i[s];if(!this.o[l])throw new Error(`Field query for "${e}" may contain only operators or a plain object as a value`);Ky(n,this.parseField(e,l,r[l],r))}return n}parse(e){const r=[],n=this.h(e);this.i.query=e;for(let i=0,s=n.length;i<s;i++){const o=n[i],l=e[o],c=this.o[o];if(c){if(c.type!=="document"&&c.type!=="compound")throw new Error(`Cannot use parsing instruction for operator "${o}" in "document" context as it is supposed to be used in "${c.type}" context`);Ky(r,this.parseInstruction(c,l,this.i))}else this.s.hasOperators(l)?r.push(...this.parseFieldOperators(o,l)):Ky(r,this.parseField(o,this.u.defaultOperatorName,l,e))}return this.u.mergeFinalConditions(r)}};function Zy(t,e){const r=t[e];if(typeof r!="function")throw new Error(`Unable to interpret "${e}" condition. Did you forget to register interpreter for it?`);return r}function nJ(t){return t.operator}function iJ(t,e){const r=e,n=r&&r.getInterpreterName||nJ;let i;switch(r?r.numberOfArguments:0){case 1:i=o=>{const l=n(o,r);return Zy(t,l)(o,s)};break;case 3:i=(o,l,c)=>{const u=n(o,r);return Zy(t,u)(o,l,c,s)};break;default:i=(o,l)=>{const c=n(o,r);return Zy(t,c)(o,l,s)}}const s=Object.assign({},r,{interpret:i});return s.interpret}function sJ(t,e){return(r,...n)=>{const i=t(r,...n),s=e.bind(null,i);return s.ast=i,s}}function I4(t,e){if(!Array.isArray(e))throw new Error(`"${t.name}" expects value to be an array`)}function j4(t,e){if(I4(t,e),!e.length)throw new Error(`"${t.name}" expects to have at least one element in array`)}const aC=t=>(e,r)=>{if(typeof r!==t)throw new Error(`"${e.name}" expects value to be a "${t}"`)},R4={type:"compound",validate:j4,parse(t,e,{parse:r}){const n=e.map(i=>r(i));return b4(t.name,n)}},oJ=R4,aJ={type:"compound",validate:j4},lJ={type:"field",validate(t,e){if(!(e&&(e instanceof RegExp||e.constructor===Object)))throw new Error(`"${t.name}" expects to receive either regular expression or object of field operators`)},parse(t,e,r){const n=e instanceof RegExp?new Km("regex",r.field,e):r.parse(e,r);return new Um(t.name,[n])}},T4={type:"field",validate(t,e){if(!e||e.constructor!==Object)throw new Error(`"${t.name}" expects to receive an object with nested query or field level operators`)},parse(t,e,{parse:r,field:n,hasOperators:i}){const s=i(e)?r(e,{field:Vh}):r(e);return new Km(t.name,n,s)}},k4={type:"field",validate:aC("number")},Zm={type:"field",validate:I4},A4=Zm,E4=Zm,cJ={type:"field",validate(t,e){if(!Array.isArray(e)||e.length!==2)throw new Error(`"${t.name}" expects an array with 2 numeric elements`)}},P4={type:"field",validate:aC("boolean")},lC={type:"field",validate:function(t,e){if(!(typeof e=="string"||typeof e=="number"||e instanceof Date))throw new Error(`"${t.name}" expects value to be comparable (i.e., string, number or date)`)}},Ym=lC,N4=Ym,M4=Ym,cC={type:"field"},O4=cC,D4={type:"field",validate(t,e){if(!(e instanceof RegExp)&&typeof e!="string")throw new Error(`"${t.name}" expects value to be a regular expression or a string that represents regular expression`)},parse(t,e,r){const n=typeof e=="string"?new RegExp(e,r.query.$options||""):e;return new Km(t.name,r.field,n)}},F4={type:"field",parse:()=>v4},uJ={type:"document",validate:aC("function")};var hJ=Object.freeze({__proto__:null,$and:R4,$or:oJ,$nor:aJ,$not:lJ,$elemMatch:T4,$size:k4,$in:Zm,$nin:A4,$all:E4,$mod:cJ,$exists:P4,$gte:lC,$gt:Ym,$lt:N4,$lte:M4,$eq:cC,$ne:O4,$regex:D4,$options:F4,$where:uJ});let dJ=class extends rJ{constructor(e){super(e,{defaultOperatorName:"$eq",operatorToConditionName:r=>r.slice(1)})}parse(e,r){return r&&r.field?C4(this.parseFieldOperators(r.field,e)):super.parse(e)}};const pb=hJ;function uC(t,e,r){for(let n=0,i=t.length;n<i;n++)if(r(t[n],e)===0)return!0;return!1}function hC(t,e){return Array.isArray(t)&&Number.isNaN(Number(e))}function S2(t,e,r){if(!hC(t,e))return r(t,e);let n=[];for(let i=0;i<t.length;i++){const s=r(t[i],e);s!==void 0&&(n=n.concat(s))}return n}function nl(t){return(e,r,n)=>{const i=n.get(r,e.field);return Array.isArray(i)?i.some(s=>t(e,s,n)):t(e,i,n)}}const fJ=(t,e)=>t[e];function L4(t,e,r){const n=e.lastIndexOf(".");return n===-1?[t,e]:[r(t,e.slice(0,n)),e.slice(n+1)]}function pJ(t,e,r=fJ){if(e===Vh)return t;if(!t)throw new Error(`Unable to get field "${e}" out of ${String(t)}.`);return(function(n,i,s){if(i.indexOf(".")===-1)return S2(n,i,s);const o=i.split(".");let l=n;for(let c=0,u=o.length;c<u;c++)if(l=S2(l,o[c],s),!l||typeof l!="object")return l;return l})(t,e,r)}function $4(t,e){return t===e?0:t>e?1:-1}function B4(t,e={}){return iJ(t,Object.assign({get:pJ,compare:$4},e))}const z4=(t,e,{interpret:r})=>t.value.some(n=>r(n,e)),gJ=(t,e,r)=>!z4(t,e,r),V4=(t,e,{interpret:r})=>t.value.every(n=>r(n,e)),mJ=(t,e,{interpret:r})=>!r(t.value[0],e),dC=(t,e,{compare:r,get:n})=>{const i=n(e,t.field);return Array.isArray(i)&&!Array.isArray(t.value)?uC(i,t.value,r):r(i,t.value)===0},H4=(t,e,r)=>!dC(t,e,r),q4=nl((t,e,r)=>{const n=r.compare(e,t.value);return n===0||n===-1}),W4=nl((t,e,r)=>r.compare(e,t.value)===-1),G4=nl((t,e,r)=>r.compare(e,t.value)===1),U4=nl((t,e,r)=>{const n=r.compare(e,t.value);return n===0||n===1}),K4=(t,e,{get:r})=>{if(t.field===Vh)return e!==void 0;const[n,i]=L4(e,t.field,r),s=o=>o==null?!!o===t.value:o.hasOwnProperty(i)===t.value;return hC(n,i)?n.some(s):s(n)},yJ=nl((t,e)=>typeof e=="number"&&e%t.value[0]===t.value[1]),Z4=(t,e,{get:r})=>{const[n,i]=L4(e,t.field,r),s=o=>{const l=r(o,i);return Array.isArray(l)&&l.length===t.value};return t.field!==Vh&&hC(n,i)?n.some(s):s(n)},Y4=nl((t,e)=>typeof e=="string"&&t.value.test(e)),Xm=nl((t,e,{compare:r})=>uC(t.value,e,r)),X4=(t,e,r)=>!Xm(t,e,r),J4=(t,e,{compare:r,get:n})=>{const i=n(e,t.field);return Array.isArray(i)&&t.value.every(s=>uC(i,s,r))},Q4=(t,e,{interpret:r,get:n})=>{const i=n(e,t.field);return Array.isArray(i)&&i.some(s=>r(t.value,s))},xJ=(t,e)=>t.value.call(e);var vJ=Object.freeze({__proto__:null,or:z4,nor:gJ,and:V4,not:mJ,eq:dC,ne:H4,lte:q4,lt:W4,gt:G4,gte:U4,exists:K4,mod:yJ,size:Z4,regex:Y4,within:Xm,nin:X4,all:J4,elemMatch:Q4,where:xJ});const fC=Object.assign({},vJ,{in:Xm});B4(fC);function C2(t){return t===null||typeof t!="object"?t:t instanceof Date?t.getTime():t&&typeof t.toJSON=="function"?t.toJSON():t}const bJ=(t,e)=>$4(C2(t),C2(e));function pC(t,e,r){const n=new dJ(t),i=B4(e,Object.assign({compare:bJ},r));if(r&&r.forPrimitives){const s={field:Vh},o=n.parse;n.setParse(l=>o(l,s))}return sJ(n.parse,i)}pC(pb,fC);pC(["$and","$or"].reduce((t,e)=>(t[e]=Object.assign({},t[e],{type:"field"}),t),Object.assign({},pb,{$nor:Object.assign({},pb.$nor,{type:"field",parse:_4.compound})})),fC,{forPrimitives:!0});const e6=Object.hasOwn||((t,e)=>Object.prototype.hasOwnProperty.call(t,e));function gb(t){return Array.isArray(t)?t:[t]}const Il="__caslSubjectType__";function wJ(t,e){if(e){if(!e6(e,Il))Object.defineProperty(e,Il,{value:t});else if(t!==e[Il])throw new Error(`Trying to cast object to subject type ${t} but previously it was casted to ${e[Il]}`)}return e}const fp=t=>{const e=typeof t;return e==="string"||e==="function"},SJ=t=>t.modelName||t.name;function t6(t){return e6(t,Il)?t[Il]:SJ(t.constructor)}const _2={function:t=>t.constructor,string:t6};function I2(t,e,r){for(let n=r;n<e.length;n++)t.push(e[n])}function j2(t,e){if(!t||!t.length)return e||[];if(!e||!e.length)return t||[];let r=0,n=0;const i=[];for(;r<t.length&&n<e.length;)t[r].priority<e[n].priority?(i.push(t[r]),r++):(i.push(e[n]),n++);return I2(i,t,r),I2(i,e,n),i}function Ld(t,e,r){let n=t.get(e);return n||(n=r(),t.set(e,n)),n}const CJ=t=>t;function _J(t,e){if(Array.isArray(t.fields)&&!t.fields.length)throw new Error("`rawRule.fields` cannot be an empty array. https://bit.ly/390miLa");if(t.fields&&!e.fieldMatcher)throw new Error('You need to pass "fieldMatcher" option in order to restrict access by fields');if(t.conditions&&!e.conditionsMatcher)throw new Error('You need to pass "conditionsMatcher" option in order to restrict access by conditions')}class IJ{constructor(e,r,n=0){_J(e,r),this.action=r.resolveAction(e.action),this.subject=e.subject,this.inverted=!!e.inverted,this.conditions=e.conditions,this.reason=e.reason,this.origin=e,this.fields=e.fields?gb(e.fields):void 0,this.priority=n,this.t=r}i(){return this.conditions&&!this.o&&(this.o=this.t.conditionsMatcher(this.conditions)),this.o}get ast(){const e=this.i();return e?e.ast:void 0}matchesConditions(e){return this.conditions?!e||fp(e)?!this.inverted:this.i()(e):!0}matchesField(e){return this.fields?e?(this.u||(this.u=this.t.fieldMatcher(this.fields)),this.u(e)):!this.inverted:!0}}function jJ(t,e){const r={value:t,prev:e,next:null};return e&&(e.next=r),r}function RJ(t){t.next&&(t.next.prev=t.prev),t.prev&&(t.prev.next=t.next),t.next=t.prev=null}const TJ=t=>({value:t.value,prev:t.prev,next:t.next}),R2=()=>({rules:[],merged:!1}),T2=()=>new Map;class kJ{constructor(e=[],r={}){this.h=!1,this.l=new Map,this.p={conditionsMatcher:r.conditionsMatcher,fieldMatcher:r.fieldMatcher,resolveAction:r.resolveAction||CJ},this.$=r.anyAction||"manage",this.A=r.anySubjectType||"all",this.m=e,this.M=!!r.detectSubjectType,this.j=r.detectSubjectType||t6,this.v(e)}get rules(){return this.m}detectSubjectType(e){return fp(e)?e:e?this.j(e):this.A}update(e){const r={rules:e,ability:this,target:this};return this._("update",r),this.m=e,this.v(e),this._("updated",r),this}v(e){const r=new Map;let n;for(let i=e.length-1;i>=0;i--){const s=e.length-i-1,o=new IJ(e[i],this.p,s),l=gb(o.action),c=gb(o.subject||this.A);!this.h&&o.fields&&(this.h=!0);for(let u=0;u<c.length;u++){const h=Ld(r,c[u],T2);n===void 0&&(n=typeof c[u]),typeof c[u]!==n&&n!=="mixed"&&(n="mixed");for(let d=0;d<l.length;d++)Ld(h,l[d],R2).rules.push(o)}}if(this.l=r,n!=="mixed"&&!this.M){const i=_2[n]||_2.string;this.j=i}}possibleRulesFor(e,r=this.A){if(!fp(r))throw new Error('"possibleRulesFor" accepts only subject types (i.e., string or class) as the 2nd parameter');const n=Ld(this.l,r,T2),i=Ld(n,e,R2);if(i.merged)return i.rules;const s=e!==this.$&&n.has(this.$)?n.get(this.$).rules:void 0;let o=j2(i.rules,s);return r!==this.A&&(o=j2(o,this.possibleRulesFor(e,this.A))),i.rules=o,i.merged=!0,o}rulesFor(e,r,n){const i=this.possibleRulesFor(e,r);if(n&&typeof n!="string")throw new Error("The 3rd, `field` parameter is expected to be a string. See https://stalniy.github.io/casl/en/api/casl-ability#can-of-pure-ability for details");return this.h?i.filter(s=>s.matchesField(n)):i}actionsFor(e){if(!fp(e))throw new Error('"actionsFor" accepts only subject types (i.e., string or class) as a parameter');const r=new Set,n=this.l.get(e);n&&Array.from(n.keys()).forEach(s=>r.add(s));const i=e!==this.A?this.l.get(this.A):void 0;return i&&Array.from(i.keys()).forEach(s=>r.add(s)),Array.from(r)}on(e,r){this.F=this.F||new Map;const n=this.F,i=n.get(e)||null,s=jJ(r,i);return n.set(e,s),()=>{const o=n.get(e);!s.next&&!s.prev&&o===s?n.delete(e):s===o&&n.set(e,s.prev),RJ(s)}}_(e,r){if(!this.F)return;let n=this.F.get(e)||null;for(;n!==null;){const i=n.prev?TJ(n.prev):null;n.value(r),n=i}}}class AJ extends kJ{can(e,r,n){const i=this.relevantRuleFor(e,r,n);return!!i&&!i.inverted}relevantRuleFor(e,r,n){const i=this.detectSubjectType(r),s=this.rulesFor(e,i,n);for(let o=0,l=s.length;o<l;o++)if(s[o].matchesConditions(r))return s[o];return null}cannot(e,r,n){return!this.can(e,r,n)}}const EJ={$eq:cC,$ne:O4,$lt:N4,$lte:M4,$gt:Ym,$gte:lC,$in:Zm,$nin:A4,$all:E4,$size:k4,$regex:D4,$options:F4,$elemMatch:T4,$exists:P4},PJ={eq:dC,ne:H4,lt:W4,lte:q4,gt:G4,gte:U4,in:Xm,nin:X4,all:J4,size:Z4,regex:Y4,elemMatch:Q4,exists:K4,and:V4},NJ=pC(EJ,PJ),MJ=/[-/\\^$+?.()|[\]{}]/g,OJ=/\.?\*+\.?/g,DJ=/\*+/,FJ=/\./g;function LJ(t,e,r){const n=r[0]==="*"||t[0]==="."&&t[t.length-1]==="."?"+":"*",i=t.indexOf("**")===-1?"[^.]":".",s=t.replace(FJ,"\\$&").replace(DJ,i+n);return e+t.length===r.length?`(?:${s})?`:s}function $J(t,e,r){return t==="."&&(r[e-1]==="*"||r[e+1]==="*")?t:`\\${t}`}function BJ(t){const e=t.map(n=>n.replace(MJ,$J).replace(OJ,LJ)),r=e.length>1?`(?:${e.join("|")})`:e[0];return new RegExp(`^${r}$`)}const zJ=t=>{let e;return r=>(typeof e>"u"&&(e=t.every(n=>n.indexOf("*")===-1)?null:BJ(t)),e===null?t.indexOf(r)!==-1:e.test(r))};function VJ(t=[],e={}){return new AJ(t,Object.assign({conditionsMatcher:NJ,fieldMatcher:zJ},e))}const HJ=new Set(["read-project-private","read-project-public"]),qJ=["Table","Row","Branch","Revision","Endpoint"];class lh{ability=VJ();loadedScopes=new Set;addSystemPermissions(e){const r=this.scopeToKey({type:"system"});if(this.loadedScopes.has(r))return;const n=this.permissionsToRules(e,null),i=this.expandPermissions(e,null);this.ability.update([...this.ability.rules,...n,...i]),this.loadedScopes.add(r)}addOrganizationPermissions(e,r){const n=this.scopeToKey({type:"organization",organizationId:e});if(this.loadedScopes.has(n))return;const i={organizationId:e},s=this.permissionsToRules(r,i),o=this.expandPermissions(r,i);this.ability.update([...this.ability.rules,...s,...o]),this.loadedScopes.add(n)}addProjectPermissions(e,r){const n=this.scopeToKey({type:"project",projectId:e});if(this.loadedScopes.has(n))return;const i={projectId:e},s=this.permissionsToRules(r,i),o=this.expandPermissions(r,i);this.ability.update([...this.ability.rules,...s,...o]),this.loadedScopes.add(n)}can(e,r,n){const i=wJ(r,n??{});return this.ability.can(e,i)}cannot(e,r,n){return!this.can(e,r,n)}hasScope(e){return this.loadedScopes.has(this.scopeToKey(e))}clearAll(){this.ability.update([]),this.loadedScopes.clear()}scopeToKey(e){switch(e.type){case"system":return"system";case"organization":return`organization:${e.organizationId}`;case"project":return`project:${e.projectId}`}}permissionsToRules(e,r){return e.map(n=>this.permissionToRule(n,r))}permissionToRule(e,r){const n={action:e.action,subject:e.subject},i=this.mergeConditions(e.condition,r);return i&&(n.conditions=i),n}mergeConditions(e,r){const n=e&&Object.keys(e).length>0,i=r&&Object.keys(r).length>0;if(!(!n&&!i))return n&&i?{...e,...r}:n?{...e}:{...r}}expandPermissions(e,r){const n=[];for(const i of e)if(HJ.has(i.id))for(const s of qJ){const o={action:"read",subject:s};r&&Object.keys(r).length>0&&(o.conditions={...r}),n.push(o)}return n}}$.register(lh,()=>new lh,{scope:"singleton"});class Va{constructor(e){this.permissionService=e,le(this,{},{autoBind:!0})}setUserRole(e){if(e?.permissions){const r=e.permissions.map(n=>({id:n.id,action:n.action,subject:n.subject,condition:n.condition??null}));this.permissionService.addSystemPermissions(r)}}clearAll(){this.permissionService.clearAll()}get canCreateProject(){return this.permissionService.can("create","Project")}get canReadUser(){return this.permissionService.can("read","User")}get canCreateUser(){return this.permissionService.can("create","User")}get canAddUser(){return this.permissionService.can("add","User")}get canUpdateUser(){return this.permissionService.can("update","User")}get canDeleteUser(){return this.permissionService.can("delete","User")}get canManageUsers(){return this.canAddUser||this.canReadUser}get canReadOrganization(){return this.permissionService.can("read","Organization")}get canUpdateOrganization(){return this.permissionService.can("update","Organization")}get canDeleteOrganization(){return this.permissionService.can("delete","Organization")}}$.register(Va,()=>{const t=$.get(lh);return new Va(t)},{scope:"singleton"});class Dr{constructor(e){this.permissionService=e,le(this,{},{autoBind:!0})}_contextProvider=null;setContextProvider(e){this._contextProvider=e}get context(){return this._contextProvider?.()??{projectId:null,organizationId:null,isPublic:!1,projectRoleName:null}}get projectId(){return this.context.projectId}get organizationId(){return this.context.organizationId}get isPublic(){return this.context.isPublic}get projectRoleName(){return this.context.projectRoleName}getProjectContext(){const e=this.context,r={};return e.projectId&&(r.projectId=e.projectId),e.organizationId&&(r.organizationId=e.organizationId),r}can(e,r,n){const i=n??this.getProjectContext();return this.permissionService.can(e,r,Object.keys(i).length>0?i:void 0)}get canReadProject(){return this.can("read","Project",{...this.getProjectContext(),isPublic:this.context.isPublic})}get canUpdateProject(){return this.can("update","Project")}get canDeleteProject(){return this.can("delete","Project")}get canReadBranch(){return this.can("read","Branch")}get canCreateBranch(){return this.can("create","Branch")}get canDeleteBranch(){return this.can("delete","Branch")}get canReadRevision(){return this.can("read","Revision")}get canCreateRevision(){return this.can("create","Revision")}get canRevertRevision(){return this.can("revert","Revision")}get canReadTable(){return this.can("read","Table")}get canCreateTable(){return this.can("create","Table")}get canUpdateTable(){return this.can("update","Table")}get canDeleteTable(){return this.can("delete","Table")}get canReadRow(){return this.can("read","Row")}get canCreateRow(){return this.can("create","Row")}get canUpdateRow(){return this.can("update","Row")}get canDeleteRow(){return this.can("delete","Row")}get canReadEndpoint(){return this.can("read","Endpoint")}get canCreateEndpoint(){return this.can("create","Endpoint")}get canDeleteEndpoint(){return this.can("delete","Endpoint")}get canAddUser(){return this.can("add","User")}get canUpdateUser(){return this.can("update","User")}get canDeleteUser(){return this.can("delete","User")}get canReadUser(){return this.can("read","User")}get canManageUsers(){return this.canAddUser||this.canReadUser}get canAccessSettings(){return this.canUpdateProject||this.canDeleteProject}get canWrite(){return this.canCreateTable||this.canUpdateTable||this.canDeleteTable||this.canCreateRow||this.canUpdateRow||this.canDeleteRow}get isReadOnly(){return!this.canWrite}}$.register(Dr,()=>{const t=$.get(lh);return new Dr(t)},{scope:"singleton"});var vg=function(){return vg=Object.assign||function(e){for(var r,n=1,i=arguments.length;n<i;n++){r=arguments[n];for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(e[s]=r[s])}return e},vg.apply(this,arguments)};var pp=new Map,mb=new Map,r6=!0,bg=!1;function n6(t){return t.replace(/[\s,]+/g," ").trim()}function WJ(t){return n6(t.source.body.substring(t.start,t.end))}function GJ(t){var e=new Set,r=[];return t.definitions.forEach(function(n){if(n.kind==="FragmentDefinition"){var i=n.name.value,s=WJ(n.loc),o=mb.get(i);o&&!o.has(s)?r6&&console.warn("Warning: fragment with name "+i+` already exists.
|
|
369
|
+
`);return a.jsxs(P,{align:s?"flex-start":"center",gap:2,fontSize:"xs",color:"gray.500",pl:2,children:[a.jsx(j,{color:"gray.400",children:"default:"}),a.jsx(T,{as:"code",px:s?2:1,py:s?1.5:.5,bg:"gray.100",borderRadius:"sm",fontFamily:"mono",whiteSpace:s?"pre":"nowrap",children:i}),a.jsxs(j,{color:"gray.400",children:["(",r,")"]})]})},zY=({severity:t})=>t==="none"?null:t==="possible"?a.jsx(St,{size:"sm",colorPalette:"yellow",variant:"subtle",children:"data may be lost"}):a.jsx(St,{size:"sm",colorPalette:"red",variant:"subtle",children:"data loss"}),VY=({info:t})=>a.jsxs(ge,{align:"stretch",gap:1,pl:2,children:[a.jsxs(P,{align:"center",gap:2,fontSize:"xs",flexWrap:"wrap",children:[t.steps.map((e,r)=>a.jsxs(P,{align:"center",gap:1,children:[r>0&&a.jsx(j,{color:"gray.400",children:"+"}),a.jsx(St,{size:"sm",colorPalette:"gray",variant:"subtle",children:e.name})]},e.name)),a.jsx(zY,{severity:t.dataLossSeverity})]}),a.jsxs(P,{align:"center",gap:2,fontSize:"xs",color:"gray.500",children:[a.jsx(j,{color:"gray.400",children:"example:"}),a.jsx(xg,{children:JSON.stringify(t.example.before)}),a.jsx(He,{as:Zw,color:"gray.400",flexShrink:0}),a.jsx(xg,{children:JSON.stringify(t.example.after)})]})]}),HY=({label:t,fromValue:e,toValue:r})=>a.jsxs(P,{align:"center",gap:2,fontSize:"xs",color:"gray.500",pl:2,flexWrap:"wrap",children:[a.jsxs(j,{color:"gray.400",children:[t,":"]}),a.jsx(xg,{children:e}),a.jsx(He,{as:Zw,color:"gray.400",flexShrink:0}),a.jsx(xg,{children:r})]}),qY=re(({schemaPatch:t})=>{const{patch:e,typeChange:r,propertyChanges:n}=t,i=_.useMemo(()=>r?KZ(r.fromType,r.toType):null,[r]),s=_.useMemo(()=>e.op==="add"&&e.value!==void 0?XZ({path:e.path,value:e.value}):null,[e]),o=_.useMemo(()=>LY(e.op,n,s),[e.op,n,s]);return a.jsxs(T,{borderBottom:"1px solid",borderColor:"gray.100",py:4,px:5,_last:{borderBottom:"none"},_hover:{bg:"gray.50"},children:[a.jsx($Y,{schemaPatch:t}),s&&a.jsx(T,{mt:2,ml:8,children:a.jsx(BY,{example:s})}),i&&a.jsx(T,{mt:2,ml:8,children:a.jsx(VY,{info:i})}),o.map(l=>a.jsx(T,{mt:2,ml:8,children:a.jsx(HY,{label:l.property,fromValue:m2(l.from),toValue:m2(l.to)})},l.property))]})}),WY=({change:t})=>a.jsx(T,{borderBottom:"1px solid",borderColor:"gray.100",py:4,px:5,_last:{borderBottom:"none"},_hover:{bg:"gray.50"},children:a.jsxs(P,{align:"center",gap:1.5,children:[a.jsx(He,{as:Pp,color:"gray.400",boxSize:4,flexShrink:0}),a.jsxs(j,{fontSize:"sm",color:"gray.600",children:["Table renamed from ",a.jsx(ps,{children:t.initialTableId})," to"," ",a.jsx(ps,{children:t.currentTableId})]})]})}),Wy=({message:t,type:e,fieldPath:r})=>a.jsx(T,{py:2,px:4,children:a.jsxs(P,{align:"center",gap:2,children:[a.jsx(He,{as:vP,color:"gray.400",boxSize:4,flexShrink:0}),a.jsxs(j,{fontSize:"sm",color:"gray.600",children:[e==="formula"&&a.jsx(St,{size:"sm",colorPalette:"gray",variant:"subtle",mr:2,children:"formula"}),e==="tableId"&&a.jsx(St,{size:"sm",colorPalette:"gray",variant:"subtle",mr:2,children:"table name"}),r&&a.jsxs(T,{as:"span",fontWeight:"medium",children:[r,":"," "]}),t]})]})}),h4=({onRevert:t,disabled:e})=>a.jsxs(kr,{children:[a.jsx(ci,{asChild:!0,children:a.jsxs(be,{variant:"ghost",size:"sm",color:"gray.500",disabled:e,children:[a.jsx(He,{as:gm}),"Revert All"]})}),a.jsx(Ar,{children:a.jsxs(gr,{children:[a.jsx(Rh,{}),a.jsxs(Ei,{children:[a.jsx(j,{fontSize:"sm",mb:3,children:"This will revert all changes. Are you sure?"}),a.jsxs(P,{gap:2,justify:"flex-end",children:[a.jsx(Mo,{asChild:!0,children:a.jsx(be,{variant:"outline",size:"xs",children:"Cancel"})}),a.jsx(Mo,{asChild:!0,children:a.jsx(be,{variant:"outline",size:"xs",colorPalette:"red",onClick:t,children:"Revert"})})]})]})]})})]}),GY=re(({isOpen:t,onClose:e,vm:r})=>a.jsx(nC,{isOpen:t,onClose:e,title:`Review Errors for "${r.tableId}"`,footer:a.jsx(iC,{leftContent:r.canRevert?a.jsx(h4,{onRevert:r.revert}):void 0,onCancel:e,showConfirm:!1}),children:a.jsx(ge,{align:"stretch",gap:4,children:a.jsxs(T,{border:"1px solid",borderColor:"gray.200",borderRadius:"md",bg:"gray.50",overflow:"hidden",children:[a.jsx(T,{py:2,px:4,bg:"gray.100",borderBottom:"1px solid",borderColor:"gray.200",children:a.jsx(j,{fontSize:"sm",fontWeight:"medium",color:"gray.600",children:"Please fix the following errors before applying changes:"})}),a.jsxs(ge,{align:"stretch",gap:0,divideY:"1px",divideColor:"gray.100",children:[r.tableIdError&&a.jsx(Wy,{message:r.tableIdError,type:"tableId"},"tableId-error"),r.validationErrors.map(n=>a.jsx(Wy,{message:n.message,type:"validation"},`validation-${n.nodeId}`)),r.formulaErrors.map(n=>a.jsx(Wy,{message:n.message,type:"formula",fieldPath:n.fieldPath},`formula-${n.fieldPath??""}-${n.message}`))]})]})})})),UY=re(({isOpen:t,onClose:e,vm:r})=>{const n=`Apply Changes (${r.totalChangesCount})`;return a.jsx(nC,{isOpen:t,onClose:e,title:`Review Changes for "${r.tableId}"`,footer:a.jsx(iC,{leftContent:a.jsx(h4,{onRevert:r.revert,disabled:!r.hasChanges}),onCancel:e,onConfirm:r.approve,confirmLabel:n,confirmDisabled:!r.hasChanges,confirmLoading:r.loading}),children:a.jsx(ge,{align:"stretch",gap:4,children:r.hasChanges?a.jsxs(a.Fragment,{children:[a.jsxs(jA,{size:"sm",value:r.viewMode,onValueChange:i=>r.setViewMode(i.value),children:[a.jsx(RA,{}),a.jsx(TA,{items:["Changes","Patches"]})]}),a.jsx(T,{border:"1px solid",borderColor:"gray.200",borderRadius:"md",overflow:"hidden",maxHeight:"400px",overflowY:"auto",children:r.viewMode==="Changes"?a.jsxs(a.Fragment,{children:[r.tableIdChange&&a.jsx(WY,{change:r.tableIdChange}),r.patches.map(i=>a.jsx(qY,{schemaPatch:i},`${i.patch.op}:${i.patch.path}`))]}):a.jsx(yg,{readonly:!0,data:r.patches.map(i=>i.patch)})}),a.jsx(j,{fontSize:"xs",color:"gray.500",children:"Data in existing rows will be automatically transformed according to the new schema."})]}):a.jsx(P,{justify:"center",align:"center",minHeight:"100px",children:a.jsx(j,{color:"gray.400",fontSize:"sm",children:"No changes to apply"})})})})}),KY=re(({isOpen:t,onClose:e,vm:r})=>a.jsx(nC,{isOpen:t,onClose:e,title:`Create Table "${r.tableId}"`,footer:a.jsx(iC,{onCancel:e,onConfirm:r.approve,confirmLabel:"Create Table",confirmLoading:r.loading}),children:a.jsxs(ge,{align:"stretch",gap:4,children:[a.jsxs(jA,{size:"sm",value:r.viewMode,onValueChange:n=>r.setViewMode(n.value),children:[a.jsx(RA,{}),a.jsx(TA,{items:["Example","Schema"]})]}),a.jsx(T,{border:"1px solid",borderColor:"gray.200",borderRadius:"md",overflow:"hidden",maxHeight:"400px",overflowY:"auto",children:r.viewMode==="Example"?a.jsx(yg,{readonly:!0,data:r.exampleData??null}):a.jsx(yg,{readonly:!0,data:r.plainSchema??null})})]})})),d4=re(({vm:t,dataTestId:e,backButton:r,primaryAction:n,dialogs:i})=>a.jsxs(P,{flex:1,flexDirection:"column",gap:"0.5rem",css:{"&:hover .editor-hover-target":{opacity:1}},"data-testid":e,children:[a.jsxs(P,{justifyContent:"space-between",width:"100%",alignItems:"center",paddingBottom:"8px",children:[a.jsxs(T,{children:[r,t.showReviewErrorsButton&&a.jsxs(be,{size:"sm",variant:"ghost",onClick:t.openErrorsDialog,"data-testid":"schema-editor-review-errors-button",children:["Review Errors (",t.errorsCount,")"]}),n?.show&&a.jsx(be,{size:"sm",variant:"ghost",onClick:n.onClick,loading:t.loading,"data-testid":n.testId,children:n.label})]}),a.jsx(T,{className:"editor-hover-target",opacity:0,children:a.jsx(aY,{availableRefByMode:!1,mode:t.viewMode,onChange:s=>t.setViewMode(s)})})]}),t.viewMode===zl.Tree&&a.jsx(T,{ref:s=>t.tree.keyboard.setContainerRef(s),tabIndex:0,onKeyDown:t.tree.keyboard.handleKeyDown,outline:0,paddingBottom:"4rem",children:a.jsx(rC,{accessor:t.tree.rootAccessor,treeVM:t.tree,dataTestId:"root"})}),t.viewMode===zl.Json&&a.jsx(yg,{readonly:!0,data:t.getPlainSchema()}),a.jsx(GY,{isOpen:t.isErrorsDialogOpen,onClose:t.closeErrorsDialog,vm:t.errorsDialogVM}),i]})),ZY=re(({vm:t})=>a.jsx(d4,{vm:t,dataTestId:"schema-editor-creating",backButton:a.jsx(fY,{dataTestId:"close-create-table-button",onClick:t.cancel}),primaryAction:{show:t.showCreateTableButton,label:"Create Table",testId:"schema-editor-create-button",onClick:t.openCreateDialog},dialogs:a.jsx(KY,{isOpen:t.isCreateDialogOpen,onClose:t.closeCreateDialog,vm:t.createDialogVM})})),YY=re(({vm:t})=>a.jsx(d4,{vm:t,dataTestId:"schema-editor-updating",backButton:a.jsx(pY,{dataTestId:"back-to-table-list-button",onClick:t.cancel}),primaryAction:{show:t.showApplyChangesButton,label:`Apply Changes (${t.totalChangesCount})`,testId:"schema-editor-approve-button",onClick:t.openChangesDialog},dialogs:a.jsx(UY,{isOpen:t.isChangesDialogOpen,onClose:t.closeChangesDialog,vm:t.changesDialogVM})}));function hb(t,e){if(e.push({type:"node",node:t}),t.showChildren)for(const r of t.childNodes)hb(r,e);t.isArray()&&t.showAddButton&&e.push({type:"add-button",array:t,guides:[...t.guides,!1]})}function XY(t){const e=[];if(t.isObject())for(const r of t.children)hb(r,e);else hb(t,e);return e}var JY=class{_expanded=We.map();_focused=We.map();constructor(){le(this,{},{autoBind:!0})}isExpanded(t){return this._expanded.get(t)??!0}setExpanded(t,e){this._expanded.set(t,e)}toggleExpanded(t){this._expanded.set(t,!this.isExpanded(t))}isFocused(t){return this._focused.get(t)??!1}setFocused(t,e){this._focused.set(t,e)}expandAll(t){for(const e of t)this._expanded.set(e,!0)}collapseAll(t){for(const e of t)this._expanded.set(e,!1)}reset(){this._expanded.clear(),this._focused.clear()}},QY=class{_menu;_layout;constructor(t,e,r,n,i,s){this.node=t,this.parent=e,this._state=r,this._tree=n,this.editorContext=i,this._childResolver=s,le(this,{},{autoBind:!0})}setMenu(t){this._menu=t}setLayout(t){this._layout=t}get id(){return this.node.id}get name(){return this.node.name}get displayName(){return this.parent?this.node.name:this._rootDisplayName()}get testId(){if(!this.parent)return"root";const t=this.parent.testId;return t==="root"&&this.parent.isObject()?this.name:`${t}-${this.name}`}isPrimitive(){return this.node.isPrimitive()}isObject(){return this.node.isObject()}isArray(){return this.node.isArray()}get isExpanded(){return this._state.isExpanded}set isExpanded(t){this._state.setExpanded(t)}get isFocused(){return this._state.isFocused}expand(){this._state.setExpanded(!0)}collapse(){this._state.setExpanded(!1)}toggleExpanded(){this._state.toggleExpanded()}setFocused(t){this._state.setFocused(t)}get depth(){return this._layout.depth}get guides(){return this._layout.guides}get isCollapsible(){return this._layout.isCollapsible}get isCollapsibleTree(){return this._layout.isCollapsibleTree}get rendererType(){return this._layout.rendererType}get isContainer(){return this._layout.isContainer}get childNodes(){return this._childResolver.getChildren(this)}get showChildren(){return this._layout.showChildren}get collapsedLabel(){return this._layout.collapsedLabel}get isLongText(){return this._layout.isLongText}expandAll(){this._layout.expandAll()}collapseAll(){this._layout.collapseAll()}get menu(){return this._menu.menu}get formula(){if(this.node.isPrimitive())return this.node.formula?.expression}get isEditorReadOnly(){return this.editorContext?.isReadOnly??!1}get path(){return this._tree.pathOf(this.node).asString()}get isDirty(){return this.node.isDirty}get value(){return this.node.value}get defaultValue(){return this.node.defaultValue}get isReadOnly(){return this.node.isReadOnly}get isFieldReadOnly(){return this.isReadOnly||this.isEditorReadOnly}setValue(t){this.node.setValue(t)}get children(){return this.node.isObject()?this._childResolver.getChildren(this):[]}child(t){return this.children.find(e=>e.name===t)}get items(){return this.node.isArray()?this._childResolver.getChildren(this):[]}get length(){return this.node.isArray()?this.node.length:0}at(t){const e=this.items;if(!(t<0||t>=e.length))return e[t]}pushValue(t){this.node.pushValue(t)}removeAt(t){this.node.removeAt(t)}move(t,e){this.node.move(t,e)}insertAt(t){this.node.pushValue(null);const e=this.length-1;t<e&&this.node.move(e,t)}get showAddButton(){return this.isExpanded&&!this.isEditorReadOnly}isForeignKey(){return PE(this.node)}get foreignKeyTableId(){return this.node.foreignKey}isFile(){return this.rendererType==="file"}get fileStatus(){return this._getFileChildValue("status","")}get fileId(){return this._getFileChildValue("fileId","")}get fileUrl(){return this._getFileChildValue("url","")}get fileMimeType(){return this._getFileChildValue("mimeType","")}get fileWidth(){return this._getFileChildNumericValue("width")}get fileHeight(){return this._getFileChildNumericValue("height")}get callbacks(){return this.editorContext?.callbacks??null}getChildAccessors(){return this._childResolver.getChildren(this)}_getFileChildValue(t,e){if(!this.node.isObject())return e;const r=this.node.child(t);return r?.isPrimitive()?String(r.value):e}_rootDisplayName(){const t=this.node.schema;return"type"in t?`<${t.type}>`:this.node.name}_getFileChildNumericValue(t){if(!this.node.isObject())return 0;const e=this.node.child(t);return e?.isPrimitive()&&Number(e.value)||0}},eX=class{constructor(t,e){this._nodeId=t,this._treeState=e,le(this,{},{autoBind:!0})}get isExpanded(){return this._treeState.isExpanded(this._nodeId)}setExpanded(t){this._treeState.setExpanded(this._nodeId,t)}toggleExpanded(){this._treeState.toggleExpanded(this._nodeId)}get isFocused(){return this._treeState.isFocused(this._nodeId)}setFocused(t){this._treeState.setFocused(this._nodeId,t)}},tX=class{constructor(t){this._accessor=t,le(this,{},{autoBind:!0})}get menu(){return[...this.topMenu,...this.arrayOwnMenu,...this.arrayItemMenu,...this.bottomMenu]}get arrayItemContext(){const t=this._accessor.parent;if(!t||!t.node.isArray())return null;const e=t.node,r=e.value.indexOf(this._accessor.node);return r===-1?null:{index:r,arrayLength:e.value.length,insertAt:n=>t.insertAt(n),removeAt:n=>t.removeAt(n),move:(n,i)=>t.move(n,i)}}get topMenu(){return this._accessor.isCollapsibleTree?[{value:"expand",label:"Expand",handler:()=>this._accessor.expandAll()},{value:"collapse",label:"Collapse",handler:()=>this._accessor.collapseAll(),afterSeparator:!0}]:[]}get arrayOwnMenu(){return this._accessor.node.isArray()?[{value:"array",label:"Array",children:[...this._accessor.length>0?[{value:"add-first",label:"Add item to start",handler:()=>this._accessor.insertAt(0)}]:[],{value:"add-last",label:"Add item to end",handler:()=>this._accessor.pushValue(null)}]}]:[]}get arrayItemMenu(){const t=this.arrayItemContext;if(!t)return[];const e=t.arrayLength>1?this.buildMoveMenuItem(t):null;return[...e?[e]:[],{value:"item",label:"Item",children:[{value:"add-before",label:"Add before",handler:()=>t.insertAt(t.index)},{value:"add-after",label:"Add after",handler:()=>t.insertAt(t.index+1)}]},{value:"delete",label:"Delete",handler:()=>t.removeAt(t.index),afterSeparator:!0}]}buildMoveMenuItem(t){const{index:e,arrayLength:r}=t,n=e===0,i=e===r-1;return{value:"move",label:"Move",children:[...r>2&&e>1?[{value:"move-to-start",label:"to start",handler:()=>t.move(e,0)}]:[],...n?[]:[{value:"move-up",label:"up",handler:()=>t.move(e,e-1)}],...i?[]:[{value:"move-down",label:"down",handler:()=>t.move(e,e+1)}],...r>2&&e<r-2?[{value:"move-to-end",label:"to end",handler:()=>t.move(e,r-1)}]:[]]}}get bottomMenu(){const t=[{value:"json",label:"json",handler:()=>this.copyJson()}];return this._accessor.path&&t.push({value:"path",label:"path",handler:()=>this.copyPath()}),[{value:"copy",label:"Copy",children:t}]}async copyJson(){const t=JSON.stringify(this._accessor.node.getPlainValue(),null,2);await navigator.clipboard.writeText(t)}async copyPath(){await navigator.clipboard.writeText(this._accessor.path)}};const rX=64;var nX=class{constructor(t){this._accessor=t,le(this,{},{autoBind:!0})}get depth(){let t=0,e=this._accessor.parent;for(;e;)t++,e=e.parent;return t}get guides(){const t=[];let e=this._accessor.parent;for(;e;){if(e.parent){const r=e.parent.getChildAccessors().at(-1)?.id===e.id;t.unshift(!r)}else e.isObject()||t.unshift(!1);e=e.parent}return t}get isCollapsible(){return this._accessor.getChildAccessors().length>0}get isCollapsibleTree(){return this.isCollapsible||this._accessor.getChildAccessors().some(t=>t.isCollapsible)}get rendererType(){if(this._accessor.node.isObject()){const t=this._accessor.node.schema;return"$ref"in t&&t.$ref===Be.File?"file":"container"}if(this._accessor.node.isArray())return"container";if(PE(this._accessor.node))return"foreignKey";if(this._accessor.node.isPrimitive()){const t=this._accessor.value;if(typeof t=="boolean")return"boolean";if(typeof t=="number")return"number"}return"string"}get isContainer(){return this._accessor.node.isObject()||this._accessor.node.isArray()}get isRefNode(){return"$ref"in this._accessor.node.schema&&this.isContainer}get showChildren(){return this.isContainer&&this._accessor.isExpanded&&this._accessor.getChildAccessors().length>0}get collapsedLabel(){return this._accessor.node.isPrimitive()?this.primitiveCollapsedLabel:this._accessor.node.isObject()?Gy(this._accessor.children.length,"key","keys"):this._accessor.node.isArray()?Gy(this._accessor.length,"item","items"):""}get primitiveCollapsedLabel(){const t=this._accessor.value;if(typeof t!="string")return"";if(!t.trim())return"<empty text>";const e=t.trim().split(/\s+/).length;return Gy(e,"word","words","text: ")}get isLongText(){const t=this._accessor.value;return typeof t=="string"&&t.length>rX}expandAll(){this._accessor.expand();for(const t of this._accessor.getChildAccessors())t.isCollapsible&&t.expandAll()}collapseAll(){this._accessor.collapse();for(const t of this._accessor.getChildAccessors())t.isCollapsible&&t.collapseAll()}};function Gy(t,e,r,n=""){return`<${n}${t} ${t===1?e:r}>`}var iX=class{constructor(t,e,r){this._tree=t,this._treeState=e,this._editorContext=r}create(t,e,r){const n=new QY(t,e,new eX(t.id,this._treeState),this._tree,this._editorContext,r),i=new nX(n),s=new tX(n);return n.setLayout(i),n.setMenu(s),i.isRefNode&&this._treeState.setExpanded(t.id,!1),n}},sX=class{_cache=We.map();constructor(t){this._factory=t}getOrCreate(t,e){const r=this._cache.get(t.id);if(r)return r;const n=this._factory.create(t,e,this);return this._cache.set(t.id,n),n}getChildren(t){const e=t.node;return e.isObject()?e.children.map(r=>this.getOrCreate(r,t)):e.isArray()?e.value.map(r=>this.getOrCreate(r,t)):[]}clear(){this._cache.clear()}},oX=class{treeState=new JY;_cache;_root;constructor(t,e,r){this._cache=new sX(new iX(t,this.treeState,e)),this._root=this._cache.getOrCreate(t.root,null),r?.collapseComplexity&&this._collapseIfComplex(r.collapseComplexity),le(this,{treeState:!1},{autoBind:!0})}get root(){return this._root}get flattenedNodes(){return XY(this._root)}dispose(){this._cache.clear(),this.treeState.reset()}_collapseIfComplex(t){const e=this._collectAllNodeIds(this._root);e.length>=t&&(this.treeState.collapseAll(e),this.treeState.setExpanded(this._root.id,!0))}_collectAllNodeIds(t,e=[]){e.push(t.id);for(const r of t.getChildAccessors())this._collectAllNodeIds(r,e);return e}},aX=class{_rowModel;_core;_mode;_callbacks;_onChange;_onSave;_onCancel;_disposeReaction;_prevPatchCount=0;_rowId;_initialRowId;constructor(t,e,r){tC(),this._mode=r?.mode??"editing",this._rowId=r?.rowId??"",this._initialRowId=this._rowId,this._callbacks=r?.callbacks??null,this._onChange=r?.onChange??null,this._onSave=r?.onSave??null,this._onCancel=r?.onCancel??null,this._rowModel=DE({rowId:"editor",schema:t,data:e,refSchemas:r?.refSchemas}),this._core=new oX(this._rowModel.tree,this,{collapseComplexity:r?.collapseComplexity}),le(this,{},{autoBind:!0}),this._disposeReaction=this._onChange?bn(()=>this.patches,()=>this._emitChange()):null}get root(){return this._core.root}get flattenedNodes(){return this._core.flattenedNodes}get rowModel(){return this._rowModel}get mode(){return this._mode}get rowId(){return this._rowId}get initialRowId(){return this._initialRowId}get isRowIdChanged(){return this._rowId!==this._initialRowId}setRowId(t){this._rowId=t}get isDirty(){return this._rowModel.isDirty}get hasChanges(){return this.isDirty||this.isRowIdChanged}get isValid(){return this._rowModel.isValid}get errors(){return this._rowModel.errors}get isReadOnly(){return this._mode==="reading"}get callbacks(){return this._callbacks}get patches(){return this._rowModel.patches}getValue(){return this._rowModel.getPlainValue()}save(){const t=this.getValue(),e=this.patches;this.commit(),this._onSave?.(this._rowId,t,e)}markAsSaved(){this.commit()}cancel(){this._onCancel?.()}commit(){this._rowModel.commit(),this._prevPatchCount=0,this._initialRowId=this._rowId}revert(){this._rowModel.revert(),this._prevPatchCount=0}dispose(){this._disposeReaction?.(),this._core.dispose(),this._rowModel.dispose()}_emitChange(){if(!this._onChange||!this.isValid)return;const t=this.patches,e=t.slice(this._prevPatchCount);this._prevPatchCount=t.length,e.length>0&&this._onChange(e)}};function lX(t){return t.map((e,r)=>({key:`d${r}`,showLine:e}))}const cX=({guides:t})=>{const e=lX(t);return a.jsxs(P,{position:"relative",alignItems:"center",children:[a.jsx(T,{left:"-48px",width:"48px",height:"100%",position:"absolute"}),e.map(r=>a.jsx(T,{position:"relative",width:"24px",height:"100%",_before:r.showLine?{content:'""',position:"absolute",left:"8px",top:0,bottom:0,width:"1px",backgroundColor:"blackAlpha.200"}:void 0},r.key))]})},uX=(t,e)=>{if(t)return e?`${t}-expand`:`${t}-collapse`},hX=({isCollapsed:t,isCollapsible:e,toggleCollapsed:r,testId:n})=>a.jsxs(a.Fragment,{children:[!t&&a.jsx(P,{color:"gray.300",width:"16px",height:"28px",_groupHover:{display:e?"none":"flex"},alignItems:"center",justifyContent:"center",children:a.jsx(Uw,{})}),e&&a.jsx(P,{_groupHover:{display:"inline-flex",color:"gray.500"},display:t?"inline-flex":"none",_hover:{backgroundColor:"transparent"},color:"gray.400",onClick:r,width:"16px",height:"28px",alignItems:"center",justifyContent:"center",cursor:"pointer","data-testid":uX(n,t),children:a.jsx(T,{transform:t?"rotate(0deg)":"rotate(90deg)",children:a.jsx(xO,{size:16})})})]}),dX=({name:t,formula:e,description:r,isDeprecated:n})=>{const s=e&&r?a.jsxs(T,{children:[a.jsxs(P,{alignItems:"center",gap:"4px",marginBottom:"4px",fontWeight:"medium",children:[a.jsx(ey,{size:14}),a.jsx("span",{children:e})]}),a.jsx(T,{color:"gray.300",children:r})]}):e?a.jsxs(P,{alignItems:"center",gap:"4px",children:[a.jsx(ey,{size:14}),a.jsx("span",{children:e})]}):r||null,o=a.jsxs(P,{alignItems:"center",gap:"4px",color:"gray.400",children:[a.jsxs(j,{textDecoration:n?"line-through":void 0,children:[t,":"]}),e&&a.jsx(ey,{size:14})]});return a.jsx(P,{height:"28px",alignItems:"center",children:s?a.jsx(Ys,{openDelay:350,content:s,positioning:{placement:"right-end"},showArrow:!0,children:o}):o})},fX=({onClick:t,label:e})=>a.jsx(j,{ml:"8px",color:"gray.300",onClick:t,cursor:"pointer",children:e}),pX=re(({node:t})=>{const[e,r]=_.useState(!1);return t.menu.length===0?null:a.jsxs(Dt,{lazyMount:!0,unmountOnExit:!0,onOpenChange:({open:n})=>r(n),children:[a.jsx(Tr,{asChild:!0,children:a.jsx(P,{width:"24px",left:"-24px",position:"absolute",zIndex:1,alignItems:"center",justifyContent:"center",cursor:"pointer",children:a.jsx(P,{alignItems:"center",justifyContent:"center",mt:"2px",height:"24px",width:"12px",borderRadius:"4px",bg:"blackAlpha.50",backdropFilter:"blur(4px)",boxShadow:"0 0 0 1px rgba(0,0,0,0.06), 0 1px 1px rgba(0,0,0,0.08)",opacity:e?1:0,transition:e?"opacity 1s ease 0s":void 0,_groupHover:{opacity:1,transition:"opacity 0.5s ease 0s"},_hover:{boxShadow:"0 0 0 1px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.1)"},children:a.jsx(He,{size:"md",color:"gray.400",as:YE})})})}),a.jsx(je,{children:a.jsx(Ft,{children:a.jsx(Lt,{children:t.menu.map(n=>n.children?a.jsxs(Dt,{positioning:{placement:"right-start",gutter:2},children:[n.beforeSeparator&&a.jsx(yr,{}),a.jsxs(oo,{width:"100%",justifyContent:"space-between",children:[n.label," ",a.jsx(za,{})]}),n.afterSeparator&&a.jsx(yr,{}),a.jsx(je,{children:a.jsx(Ft,{children:a.jsx(Lt,{children:n.children.map(i=>a.jsxs(_.Fragment,{children:[i.beforeSeparator&&a.jsx(yr,{}),a.jsx(et,{value:i.value,onClick:i.handler,children:a.jsx(T,{flex:1,children:i.label})}),i.afterSeparator&&a.jsx(yr,{})]},i.value))})})})]},n.value):a.jsxs(_.Fragment,{children:[n.beforeSeparator&&a.jsx(yr,{}),a.jsx(et,{value:n.value,onClick:n.handler,children:a.jsx(T,{flex:1,children:n.label})}),n.afterSeparator&&a.jsx(yr,{})]},n.value))})})})]})}),Is=({node:t,name:e,guides:r,isCollapsible:n=!1,isExpanded:i=!0,onToggle:s,formula:o,description:l,isDeprecated:c,skipDot:u,skipField:h,skipMore:d,collapsedLabel:f,isReadOnly:p,testId:g,onMouseEnter:y,onMouseLeave:m,children:v})=>{const x=n&&!i,b=t&&!p;return a.jsxs(P,{width:"100%",onMouseEnter:y,onMouseLeave:m,position:"relative",className:"group","data-testid":g,children:[a.jsx(cX,{guides:r}),b&&a.jsx(pX,{node:t}),a.jsxs(P,{width:"100%",alignItems:"center",children:[a.jsxs(P,{children:[!u&&a.jsx(hX,{isCollapsed:x,isCollapsible:n,toggleCollapsed:s,testId:g}),!h&&a.jsx(dX,{name:e,formula:o,description:l,isDeprecated:c}),v]}),!d&&x&&f&&a.jsx(fX,{onClick:s,label:f})]})]})},gX=re(({node:t})=>{const e=_.useCallback(()=>{t.toggleExpanded()},[t]);return a.jsx(Is,{node:t,name:t.displayName,guides:t.guides,isCollapsible:t.isCollapsible,isExpanded:t.isExpanded,onToggle:e,collapsedLabel:t.collapsedLabel,isReadOnly:t.isEditorReadOnly,testId:t.testId})}),sC=re(({value:t,readonly:e,prefix:r="",postfix:n="",restrict:i,dataTestId:s,onChange:o,onFocus:l,onBlur:c})=>{const[u,h]=_.useState(!1),d=_.useCallback(()=>{h(!0),l?.()},[l]),f=_.useCallback(()=>{h(!1),c?.()},[c]);return a.jsx(T,{borderRadius:"4px",bgColor:u?"gray.100":void 0,_hover:{bgColor:e?void 0:"gray.100"},mt:"2px",ml:"2px",pl:"4px",pr:"4px",minHeight:"24px",minWidth:"15px",cursor:e?"text":void 0,children:e?`${r}${t}${n}`:a.jsx(s4,{dataTestId:s,prefix:r,postfix:n,initValue:t,onChange:o,onFocus:d,onBlur:f,restrict:i})})}),db=({value:t,setValue:e,readonly:r,dataTestId:n})=>{const[i,s]=_.useState(t);_.useEffect(()=>{s(t)},[t]);const o=_.useCallback(u=>{s(u)},[]),l=_.useCallback(()=>{e(i)},[i,e]),c=i?"":'"';return a.jsx(sC,{prefix:c,postfix:c,value:i,readonly:r,dataTestId:n,onChange:o,onBlur:l})},mX=re(({node:t})=>{const e=String(t.value),r=_.useCallback(i=>{t.setValue(i)},[t]),n=_.useCallback(()=>{t.toggleExpanded()},[t]);return t.isLongText?a.jsxs(a.Fragment,{children:[a.jsx(Is,{node:t,name:t.displayName,guides:t.guides,formula:t.formula,isCollapsible:!0,isExpanded:t.isExpanded,onToggle:n,collapsedLabel:t.collapsedLabel,isReadOnly:t.isEditorReadOnly,testId:t.testId}),t.isExpanded&&a.jsx(Is,{name:"",guides:[...t.guides,!0],skipDot:!0,skipField:!0,children:a.jsx(db,{value:e,setValue:r,readonly:t.isFieldReadOnly,dataTestId:`${t.testId}-editor`})})]}):a.jsx(Is,{node:t,name:t.displayName,guides:t.guides,formula:t.formula,isReadOnly:t.isEditorReadOnly,testId:t.testId,children:a.jsx(db,{value:e,setValue:r,readonly:t.isFieldReadOnly,dataTestId:`${t.testId}-editor`})})}),yX=/^[\d.eE+-]+$/,xX=({value:t,setValue:e,readonly:r,dataTestId:n})=>{const i=t.toString(),s=_.useRef(i),[o,l]=_.useState(i);return _.useEffect(()=>{l(i),s.current=i},[i]),a.jsx(sC,{value:o,readonly:r,dataTestId:n,onChange:_.useCallback(c=>{l(c)},[]),onBlur:_.useCallback(()=>{const c=o.trim(),u=Number(c);c!==""&&Number.isFinite(u)?(e(u),l(u.toString()),s.current=u.toString()):l(s.current)},[e,o]),restrict:yX})},vX=re(({node:t})=>{const e=_.useCallback(r=>{t.setValue(r)},[t]);return a.jsx(Is,{node:t,name:t.displayName,guides:t.guides,formula:t.formula,isReadOnly:t.isEditorReadOnly,testId:t.testId,children:a.jsx(xX,{value:Number(t.value),setValue:e,readonly:t.isFieldReadOnly,dataTestId:`${t.testId}-editor`})})}),f4=({isOpen:t,setIsOpen:e,trigger:r,children:n,disabled:i,width:s})=>{const o=_.useCallback(()=>{i||e(!0)},[i,e]);return a.jsxs(kr,{lazyMount:!0,unmountOnExit:!0,open:t,onOpenChange:({open:l})=>{i||e(l)},autoFocus:!1,closeOnInteractOutside:!i,modal:!1,positioning:{placement:"bottom-start"},children:[a.jsx(ci,{asChild:!0,children:a.jsx(T,{onClick:o,children:r})}),!i&&a.jsx(je,{children:a.jsx(Ar,{children:a.jsx(gr,{width:s,p:1,children:n})})})]})},y2=({children:t,onClick:e})=>a.jsx(T,{px:2,py:1.5,cursor:"pointer",borderRadius:"md",fontSize:"sm",_hover:{bg:"gray.100"},onClick:e,children:t}),bX=({children:t,onChange:e,disabled:r})=>{const[n,i]=_.useState(!1),s=_.useCallback(o=>{e(o==="true"),i(!1)},[e]);return a.jsxs(f4,{width:"60px",isOpen:n,setIsOpen:i,trigger:t,disabled:r,children:[a.jsx(y2,{onClick:()=>s("true"),children:"true"}),a.jsx(y2,{onClick:()=>s("false"),children:"false"})]})},wX=({value:t,setValue:e,readonly:r,dataTestId:n})=>{const i=t.toString(),[s,o]=_.useState(i);_.useEffect(()=>{o(i)},[i]);const l=_.useCallback(u=>{o(u)},[]),c=_.useCallback(()=>{const u=s.trim(),h=u.toLowerCase()==="false"||u==="0"?!1:!!u;o(h.toString()),e(h)},[e,s]);return a.jsx(bX,{onChange:_.useCallback(u=>{o(u.toString()),e(u)},[e]),disabled:r,children:a.jsx(sC,{value:s,readonly:r,dataTestId:n,onChange:l,onBlur:c})})},SX=re(({node:t})=>{const e=_.useCallback(r=>{t.setValue(r)},[t]);return a.jsx(Is,{node:t,name:t.displayName,guides:t.guides,formula:t.formula,isReadOnly:t.isEditorReadOnly,testId:t.testId,children:a.jsx(wX,{value:!!t.value,setValue:e,readonly:t.isFieldReadOnly,dataTestId:`${t.testId}-editor`})})}),CX=re(({node:t})=>{const e=String(t.value),r=!!e&&!!t.callbacks?.onNavigateToForeignKey,n=!e&&!t.isEditorReadOnly,i=_.useCallback(()=>{t.callbacks?.onNavigateToForeignKey?.(t.foreignKeyTableId,e)},[t,e]);return a.jsxs(P,{alignItems:"center",gap:"4px",children:[r&&a.jsx(lt,{"aria-label":"Navigate to foreign key",variant:"ghost",size:"2xs",color:"gray.500",_hover:{color:"black",bg:"gray.100"},onClick:i,"data-testid":`${t.testId}-fk-navigate`,children:a.jsx(az,{})}),n&&a.jsx(Ys,{openDelay:50,closeDelay:50,content:"This field requires a valid foreign key ID",children:a.jsx(P,{width:"24px",height:"24px",alignItems:"center",justifyContent:"center",color:"gray.400",children:a.jsx(gP,{})})})]})});var _X=class{_timer=null;constructor(t){this._delay=t}schedule(t){this._timer&&clearTimeout(this._timer),this._timer=setTimeout(t,this._delay)}dispose(){this._timer&&(clearTimeout(this._timer),this._timer=null)}},IX=class{_search="";_state="loading";_ids=[];_hasMore=!1;_initialized=!1;_disposeReaction=null;_debounce=new _X(300);constructor(t,e){this._tableId=t,this._onSearch=e,le(this,{},{autoBind:!0})}get search(){return this._search}get state(){return this._state}get ids(){return this._ids}get hasMore(){return this._hasMore}get showInput(){return this._state==="list"||this._state==="notFound"||this._state==="loading"&&this._initialized}get showFooter(){return this._state==="list"||this._state==="notFound"||this._state==="error"||this._state==="empty"}get showLoading(){return this._state==="loading"}get showNotFound(){return this._state==="notFound"}get showError(){return this._state==="error"}get showEmpty(){return this._state==="empty"}get showList(){return this._state==="list"}get tableId(){return this._tableId}init(){this._performSearch(),this._disposeReaction=bn(()=>this._search,()=>this._debouncedSearch())}setSearch(t){this._search=t}dispose(){this._disposeReaction?.(),this._disposeReaction=null,this._debounce.dispose()}_debouncedSearch(){this._debounce.schedule(()=>{this._performSearch()})}_resolveState(t,e){return t.length===0&&!e?"empty":t.length===0?"notFound":"list"}async _performSearch(){if(!this._onSearch){this._state="error";return}const t=this._search;try{this._state="loading";const e=await this._onSearch(this._tableId,t);me(()=>{this._search===t&&(this._initialized=!0,this._ids=e.ids,this._hasMore=e.hasMore,this._state=this._resolveState(e.ids,t))})}catch{me(()=>{this._search===t&&(this._state="error")})}}};const jX=({tableId:t,onClose:e})=>a.jsxs(P,{p:"4px",alignItems:"center",justifyContent:"space-between",children:[a.jsxs(j,{fontSize:"xs",color:"gray.600",fontWeight:"medium",children:['Select from "',t,'"']}),e&&a.jsx(lt,{"aria-label":"Close",variant:"ghost",size:"2xs",color:"gray.500",_hover:{color:"black"},onClick:e,children:a.jsx(_c,{})})]}),RX=({value:t,onChange:e})=>{const r=_.useCallback(i=>{e(i.target.value)},[e]),n=_.useCallback(()=>{e("")},[e]);return a.jsxs(T,{px:"4px",pb:"4px",position:"relative",children:[a.jsx(Ot,{value:t,onChange:r,placeholder:"Search by ID...",size:"sm","data-testid":"fk-search-input",autoFocus:!0}),t&&a.jsx(lt,{"aria-label":"Clear",variant:"ghost",size:"2xs",position:"absolute",right:"8px",top:"50%",transform:"translateY(-50%)",onClick:n,color:"gray.400",_hover:{color:"black"},children:a.jsx(_c,{})})]})},TX=({id:t,onSelect:e})=>a.jsx(T,{px:2,py:1.5,mr:"12px",cursor:"pointer",borderRadius:"md",fontSize:"sm",_hover:{bg:"gray.100"},onClick:_.useCallback(()=>{e(t)},[t,e]),"data-testid":`fk-item-${t}`,children:t}),kX=({ids:t,onSelect:e})=>a.jsx(T,{flex:1,overflowY:"auto","data-testid":"fk-list",children:t.map(r=>a.jsx(TX,{id:r,onSelect:e},r))}),AX=()=>a.jsx(P,{flex:1,justifyContent:"center",alignItems:"center","data-testid":"fk-empty",children:a.jsx(j,{fontSize:"sm",color:"gray.500",children:"No rows found in this table"})}),EX=({onOpenTableSearch:t,onCreateAndConnect:e})=>t||e?a.jsxs(Me,{mt:"4px",p:"4px",gap:2,borderTopWidth:"1px",borderColor:"gray.200",children:[t&&a.jsxs(be,{size:"xs",variant:"ghost",color:"gray.500",onClick:t,"data-testid":"fk-open-table-search",children:[a.jsx(XE,{}),"Open Table Search"]}),e&&a.jsxs(be,{size:"xs",variant:"ghost",color:"gray.500",onClick:e,"data-testid":"fk-create-and-connect",children:[a.jsx(Ah,{}),"Create & Connect"]})]}):null,PX=re(({tableId:t,onSearch:e,onSelect:r,onClose:n,onOpenTableSearch:i,onCreateAndConnect:s})=>{const[o]=_.useState(()=>new IX(t,e));return _.useEffect(()=>(o.init(),()=>o.dispose()),[o]),a.jsxs(P,{flexDirection:"column",height:"290px",width:"100%","data-testid":"fk-picker",children:[a.jsx(jX,{tableId:t,onClose:n}),o.showInput&&a.jsx(RX,{value:o.search,onChange:o.setSearch}),o.showLoading&&a.jsx(P,{flex:1,justifyContent:"center",alignItems:"center",children:a.jsx(vt,{size:"sm",color:"gray.400"})}),o.showNotFound&&a.jsx(P,{flex:1,justifyContent:"center",alignItems:"center",children:a.jsx(j,{fontSize:"sm",color:"gray.500",children:"No results found"})}),o.showError&&a.jsx(P,{flex:1,justifyContent:"center",alignItems:"center",children:a.jsx(j,{fontSize:"sm",color:"gray.500",children:"Could not load data"})}),o.showEmpty&&a.jsx(AX,{}),o.showList&&a.jsx(kX,{ids:o.ids,onSelect:r}),o.showFooter&&a.jsx(EX,{onOpenTableSearch:i,onCreateAndConnect:s})]})}),NX=({node:t,onSelect:e,disabled:r,children:n})=>{const[i,s]=_.useState(!1),o=t.callbacks?.onSearchForeignKey,l=_.useCallback(d=>{e(d),s(!1)},[e]),c=_.useCallback(()=>{s(!1)},[]),u=_.useCallback(async()=>{if(!t.callbacks?.onOpenTableSearch)return;const d=await t.callbacks.onOpenTableSearch(t.foreignKeyTableId);d&&l(d)},[t.callbacks,t.foreignKeyTableId,l]),h=_.useCallback(async()=>{if(!t.callbacks?.onCreateAndConnect)return;const d=await t.callbacks.onCreateAndConnect(t.foreignKeyTableId);d&&l(d)},[t.callbacks,t.foreignKeyTableId,l]);return o?a.jsx(f4,{isOpen:i,setIsOpen:s,trigger:n,disabled:r,width:"320px",children:a.jsx(PX,{tableId:t.foreignKeyTableId,onSearch:o,onSelect:l,onClose:c,onOpenTableSearch:t.callbacks?.onOpenTableSearch?u:void 0,onCreateAndConnect:t.callbacks?.onCreateAndConnect?h:void 0})}):a.jsx(a.Fragment,{children:n})},MX=re(({node:t})=>{const e=String(t.value),r=_.useCallback(i=>{t.setValue(i)},[t]),n=_.useCallback(i=>{t.setValue(i)},[t]);return a.jsx(Is,{node:t,name:t.displayName,guides:t.guides,formula:t.formula,isReadOnly:t.isEditorReadOnly,testId:t.testId,children:a.jsxs(P,{alignItems:"center",gap:"2px",children:[a.jsx(NX,{node:t,onSelect:n,disabled:t.isFieldReadOnly,children:a.jsx(db,{value:e,setValue:r,readonly:t.isFieldReadOnly,dataTestId:`${t.testId}-editor`})}),a.jsx(CX,{node:t})]})})}),x2=({onClick:t,dataTestId:e})=>a.jsx(lt,{"data-testid":e,"aria-label":"Open file",variant:"ghost",size:"2xs",color:"gray.400",_hover:{bg:"gray.100",color:"black"},onClick:t,children:a.jsx(Pl,{})}),OX=({url:t,availablePreview:e,width:r,height:n,onClick:i,dataTestId:s})=>e?a.jsxs(en,{lazyMount:!0,unmountOnExit:!0,openDelay:350,closeDelay:100,positioning:{gutter:16},children:[a.jsx(tn,{asChild:!0,children:a.jsx("span",{children:a.jsx(x2,{onClick:i,dataTestId:s})})}),a.jsx(je,{children:a.jsx(rn,{children:a.jsxs(nn,{children:[a.jsx(sn,{children:a.jsx(on,{})}),a.jsx(im,{aspectRatio:n>0?r/n:1,width:"400px",src:t,alt:"File preview"})]})})})]}):a.jsx(x2,{onClick:i,dataTestId:s}),DX=re(({node:t})=>{const e=_.useRef(null),r=t.fileUrl,n=t.fileId,i=t.fileStatus,s=t.fileMimeType,o=t.fileWidth,l=t.fileHeight,c=t.isEditorReadOnly,u=s.startsWith("image/"),h=!!r,d=!c&&!!t.callbacks?.onUploadFile&&(i==="ready"||i==="uploaded"),f=!h&&!d,p=_.useCallback(async m=>{const v=m.target.files?.[0];if(!v)return;m.target.value="";const x=await t.callbacks?.onUploadFile?.(n,v);x&&t.node.setValue(x,{internal:!0})},[t,n]),g=_.useCallback(()=>{t.callbacks?.onOpenFile?t.callbacks.onOpenFile(r):window.open(r,"_blank","noopener,noreferrer")},[t,r]),y=_.useCallback(()=>{e.current?.click()},[]);return a.jsxs(P,{alignItems:"center",children:[f&&a.jsx(Ys,{openDelay:50,closeDelay:50,content:c?"The file was not uploaded in this revision":"Save the row first, then upload the file",children:a.jsx(P,{width:"24px",height:"24px",alignItems:"center",justifyContent:"center",color:"gray.400",children:a.jsx(gP,{})})}),h&&a.jsx(OX,{url:r,availablePreview:u,width:o,height:l,onClick:g,dataTestId:`${t.testId}-open-file`}),d&&a.jsxs(T,{children:[a.jsx("input",{ref:e,type:"file",onChange:p,style:{display:"none"},"data-testid":`${t.testId}-file-input`}),a.jsx(lt,{"aria-label":"Upload file",variant:"ghost",size:"2xs",color:h?"gray.300":"gray.500",_hover:{bg:"gray.100",color:"black"},onClick:y,"data-testid":`${t.testId}-upload-file`,children:a.jsx(cz,{})})]})]})}),FX=re(({node:t})=>{const e=_.useCallback(()=>{t.toggleExpanded()},[t]);return a.jsx(Is,{node:t,name:t.displayName,guides:t.guides,isCollapsible:t.isCollapsible,isExpanded:t.isExpanded,onToggle:e,collapsedLabel:t.collapsedLabel,isReadOnly:t.isEditorReadOnly,testId:t.testId,skipMore:!0,children:a.jsx(DX,{node:t})})}),p4={container:gX,string:mX,number:vX,boolean:SX,foreignKey:MX,file:FX},LX=re(({item:t})=>{if(t.type==="node"){const r=p4[t.node.rendererType];return a.jsx(r,{node:t.node})}const e=()=>{t.array.pushValue(null)};return a.jsx(Is,{name:"",guides:t.guides,skipDot:!0,skipField:!0,skipMore:!0,children:a.jsx(Gm,{title:"Item",onClick:e,dataTestId:`${t.array.testId}-add-button`})})}),g4=re(({viewModel:t})=>{const e=_.useCallback((r,n)=>a.jsx(LX,{item:n}),[]);return a.jsx(ui,{data:t.flattenedNodes,itemContent:e,useWindowScroll:!0,style:{width:"100%",height:"100%"}})}),$X=re(({viewModel:t})=>{const e=p4[t.rendererType],{showChildren:r,childNodes:n}=t,i=t.isArray()&&t.showAddButton,s=_.useCallback(()=>{t.isArray()&&t.pushValue(null)},[t]);return a.jsxs(_.Fragment,{children:[a.jsx(e,{node:t}),r&&a.jsx(ge,{align:"stretch",gap:0,children:n.map(o=>a.jsx($X,{viewModel:o},o.id))}),i&&a.jsx(Is,{name:"",guides:[...t.guides,!1],skipDot:!0,skipField:!0,skipMore:!0,children:a.jsx(Gm,{title:"Item",onClick:s,dataTestId:`${t.testId}-add-button`})})]})});var Fd={},v2;function BX(){if(v2)return Fd;v2=1;var t=K8();return Fd.createRoot=t.createRoot,Fd.hydrateRoot=t.hydrateRoot,Fd}var zX=BX();const VX={BASE_URL:"/",DEV:!1,GIT_BRANCH_NAME:"HEAD",GIT_COMMIT_HASH:"37bdb06",MODE:"production",PACKAGE_VERSION:"2.4.0",PROD:!0,REACT_APP_ENDPOINT_HOST:"",REACT_APP_ENDPOINT_PORT:"",REACT_APP_ENDPOINT_SERVER_URL:"/endpoint",REACT_APP_GRAPHQL_SERVER_URL:"/graphql",REACT_APP_SWAGGER_SERVER_URL:"/api",SSR:!1},ku=t=>{const e=VX[t];return globalThis.__env__?.[t]||e};var HX=(t,e,r,n,i,s,o,l)=>{let c=document.documentElement,u=["light","dark"];function h(p){(Array.isArray(t)?t:[t]).forEach(g=>{let y=g==="class",m=y&&s?i.map(v=>s[v]||v):i;y?(c.classList.remove(...m),c.classList.add(s&&s[p]?s[p]:p)):c.setAttribute(g,p)}),d(p)}function d(p){l&&u.includes(p)&&(c.style.colorScheme=p)}function f(){return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}if(n)h(n);else try{let p=localStorage.getItem(e)||r,g=o&&p==="system"?f():p;h(g)}catch{}},b2=["light","dark"],m4="(prefers-color-scheme: dark)",qX=typeof window>"u",y4=_.createContext(void 0),w2=t=>_.useContext(y4)?_.createElement(_.Fragment,null,t.children):_.createElement(GX,{...t}),WX=["light","dark"],GX=({forcedTheme:t,disableTransitionOnChange:e=!1,enableSystem:r=!0,enableColorScheme:n=!0,storageKey:i="theme",themes:s=WX,defaultTheme:o=r?"system":"light",attribute:l="data-theme",value:c,children:u,nonce:h,scriptProps:d})=>{let[f,p]=_.useState(()=>KX(i,o)),[g,y]=_.useState(()=>f==="system"?Uy():f),m=c?Object.values(c):s,v=_.useCallback(C=>{let w=C;if(!w)return;C==="system"&&r&&(w=Uy());let I=c?c[w]:w,R=e?ZX(h):null,k=document.documentElement,M=N=>{N==="class"?(k.classList.remove(...m),I&&k.classList.add(I)):N.startsWith("data-")&&(I?k.setAttribute(N,I):k.removeAttribute(N))};if(Array.isArray(l)?l.forEach(M):M(l),n){let N=b2.includes(o)?o:null,D=b2.includes(w)?w:N;k.style.colorScheme=D}R?.()},[h]),x=_.useCallback(C=>{let w=typeof C=="function"?C(f):C;p(w);try{localStorage.setItem(i,w)}catch{}},[f]),b=_.useCallback(C=>{let w=Uy(C);y(w),f==="system"&&r&&!t&&v("system")},[f,t]);_.useEffect(()=>{let C=window.matchMedia(m4);return C.addListener(b),b(C),()=>C.removeListener(b)},[b]),_.useEffect(()=>{let C=w=>{w.key===i&&(w.newValue?p(w.newValue):x(o))};return window.addEventListener("storage",C),()=>window.removeEventListener("storage",C)},[x]),_.useEffect(()=>{v(t??f)},[t,f]);let S=_.useMemo(()=>({theme:f,setTheme:x,forcedTheme:t,resolvedTheme:f==="system"?g:f,themes:r?[...s,"system"]:s,systemTheme:r?g:void 0}),[f,x,t,g,r,s]);return _.createElement(y4.Provider,{value:S},_.createElement(UX,{forcedTheme:t,storageKey:i,attribute:l,enableSystem:r,enableColorScheme:n,defaultTheme:o,value:c,themes:s,nonce:h,scriptProps:d}),u)},UX=_.memo(({forcedTheme:t,storageKey:e,attribute:r,enableSystem:n,enableColorScheme:i,defaultTheme:s,value:o,themes:l,nonce:c,scriptProps:u})=>{let h=JSON.stringify([r,e,s,t,l,o,n,i]).slice(1,-1);return _.createElement("script",{...u,suppressHydrationWarning:!0,nonce:typeof window>"u"?c:"",dangerouslySetInnerHTML:{__html:`(${HX.toString()})(${h})`}})}),KX=(t,e)=>{if(qX)return;let r;try{r=localStorage.getItem(t)||void 0}catch{}return r||e},ZX=t=>{let e=document.createElement("style");return t&&e.setAttribute("nonce",t),e.appendChild(document.createTextNode("*,*::before,*::after{-webkit-transition:none!important;-moz-transition:none!important;-o-transition:none!important;-ms-transition:none!important;transition:none!important}")),document.head.appendChild(e),()=>{window.getComputedStyle(document.body),setTimeout(()=>{document.head.removeChild(e)},1)}},Uy=t=>(t||(t=window.matchMedia(m4)),t.matches?"dark":"light");const YX=()=>_.useCallback(t=>{t&&t.focus()},[]);class XX{registrations=new Map;register(e,r,n){this.registrations.set(e,{factory:r,scope:n.scope})}get(e){const r=this.registrations.get(e);if(!r)throw new Error(`No provider found for ${e.name}`);return r.scope==="singleton"?(r.instance??=r.factory(),r.instance):r.factory()}}const $=new XX;let x4=class{constructor(e,r){this.operator=e,this.value=r,Object.defineProperty(this,"t",{writable:!0})}get notes(){return this.t}addNote(e){this.t=this.t||[],this.t.push(e)}},oC=class extends x4{};class Um extends oC{constructor(e,r){if(!Array.isArray(r))throw new Error(`"${e}" operator expects to receive an array of conditions`);super(e,r)}}const Vh="__itself__";let Km=class extends x4{constructor(e,r,n){super(e,n),this.field=r}};const v4=new oC("__null__",null),fb=Object.prototype.hasOwnProperty.call.bind(Object.prototype.hasOwnProperty);function JX(t,e){return e instanceof Um&&e.operator===t}function b4(t,e){return e.length===1?e[0]:new Um(t,(function r(n,i,s){const o=s||[];for(let l=0,c=i.length;l<c;l++){const u=i[l];JX(n,u)?r(n,u.value,o):o.push(u)}return o})(t,e))}const QX=t=>t,w4=()=>Object.create(null),S4=Object.defineProperty(w4(),"__@type@__",{value:"ignore value"});function eJ(t,e,r=!1){if(!t||t&&t.constructor!==Object)return!1;for(const n in t)if(fb(t,n)&&fb(e,n)&&(!r||t[n]!==S4))return!0;return!1}function tJ(t){const e=[];for(const r in t)fb(t,r)&&t[r]!==S4&&e.push(r);return e}function Ky(t,e){e!==v4&&t.push(e)}const C4=t=>b4("and",t),_4={compound(t,e,r){const n=(Array.isArray(e)?e:[e]).map(i=>r.parse(i));return new Um(t.name,n)},field:(t,e,r)=>new Km(t.name,r.field,e),document:(t,e)=>new oC(t.name,e)};let rJ=class{constructor(e,r=w4()){this.o=void 0,this.s=void 0,this.i=void 0,this.u=void 0,this.h=void 0,this.parse=this.parse.bind(this),this.u={operatorToConditionName:r.operatorToConditionName||QX,defaultOperatorName:r.defaultOperatorName||"eq",mergeFinalConditions:r.mergeFinalConditions||C4},this.o=Object.keys(e).reduce((n,i)=>(n[i]=Object.assign({name:this.u.operatorToConditionName(i)},e[i]),n),{}),this.s=Object.assign({},r.fieldContext,{field:"",query:{},parse:this.parse,hasOperators:n=>eJ(n,this.o,r.useIgnoreValue)}),this.i=Object.assign({},r.documentContext,{parse:this.parse,query:{}}),this.h=r.useIgnoreValue?tJ:Object.keys}setParse(e){this.parse=e,this.s.parse=e,this.i.parse=e}parseField(e,r,n,i){const s=this.o[r];if(!s)throw new Error(`Unsupported operator "${r}"`);if(s.type!=="field")throw new Error(`Unexpected ${s.type} operator "${r}" at field level`);return this.s.field=e,this.s.query=i,this.parseInstruction(s,n,this.s)}parseInstruction(e,r,n){return typeof e.validate=="function"&&e.validate(e,r),(e.parse||_4[e.type])(e,r,n)}parseFieldOperators(e,r){const n=[],i=this.h(r);for(let s=0,o=i.length;s<o;s++){const l=i[s];if(!this.o[l])throw new Error(`Field query for "${e}" may contain only operators or a plain object as a value`);Ky(n,this.parseField(e,l,r[l],r))}return n}parse(e){const r=[],n=this.h(e);this.i.query=e;for(let i=0,s=n.length;i<s;i++){const o=n[i],l=e[o],c=this.o[o];if(c){if(c.type!=="document"&&c.type!=="compound")throw new Error(`Cannot use parsing instruction for operator "${o}" in "document" context as it is supposed to be used in "${c.type}" context`);Ky(r,this.parseInstruction(c,l,this.i))}else this.s.hasOperators(l)?r.push(...this.parseFieldOperators(o,l)):Ky(r,this.parseField(o,this.u.defaultOperatorName,l,e))}return this.u.mergeFinalConditions(r)}};function Zy(t,e){const r=t[e];if(typeof r!="function")throw new Error(`Unable to interpret "${e}" condition. Did you forget to register interpreter for it?`);return r}function nJ(t){return t.operator}function iJ(t,e){const r=e,n=r&&r.getInterpreterName||nJ;let i;switch(r?r.numberOfArguments:0){case 1:i=o=>{const l=n(o,r);return Zy(t,l)(o,s)};break;case 3:i=(o,l,c)=>{const u=n(o,r);return Zy(t,u)(o,l,c,s)};break;default:i=(o,l)=>{const c=n(o,r);return Zy(t,c)(o,l,s)}}const s=Object.assign({},r,{interpret:i});return s.interpret}function sJ(t,e){return(r,...n)=>{const i=t(r,...n),s=e.bind(null,i);return s.ast=i,s}}function I4(t,e){if(!Array.isArray(e))throw new Error(`"${t.name}" expects value to be an array`)}function j4(t,e){if(I4(t,e),!e.length)throw new Error(`"${t.name}" expects to have at least one element in array`)}const aC=t=>(e,r)=>{if(typeof r!==t)throw new Error(`"${e.name}" expects value to be a "${t}"`)},R4={type:"compound",validate:j4,parse(t,e,{parse:r}){const n=e.map(i=>r(i));return b4(t.name,n)}},oJ=R4,aJ={type:"compound",validate:j4},lJ={type:"field",validate(t,e){if(!(e&&(e instanceof RegExp||e.constructor===Object)))throw new Error(`"${t.name}" expects to receive either regular expression or object of field operators`)},parse(t,e,r){const n=e instanceof RegExp?new Km("regex",r.field,e):r.parse(e,r);return new Um(t.name,[n])}},T4={type:"field",validate(t,e){if(!e||e.constructor!==Object)throw new Error(`"${t.name}" expects to receive an object with nested query or field level operators`)},parse(t,e,{parse:r,field:n,hasOperators:i}){const s=i(e)?r(e,{field:Vh}):r(e);return new Km(t.name,n,s)}},k4={type:"field",validate:aC("number")},Zm={type:"field",validate:I4},A4=Zm,E4=Zm,cJ={type:"field",validate(t,e){if(!Array.isArray(e)||e.length!==2)throw new Error(`"${t.name}" expects an array with 2 numeric elements`)}},P4={type:"field",validate:aC("boolean")},lC={type:"field",validate:function(t,e){if(!(typeof e=="string"||typeof e=="number"||e instanceof Date))throw new Error(`"${t.name}" expects value to be comparable (i.e., string, number or date)`)}},Ym=lC,N4=Ym,M4=Ym,cC={type:"field"},O4=cC,D4={type:"field",validate(t,e){if(!(e instanceof RegExp)&&typeof e!="string")throw new Error(`"${t.name}" expects value to be a regular expression or a string that represents regular expression`)},parse(t,e,r){const n=typeof e=="string"?new RegExp(e,r.query.$options||""):e;return new Km(t.name,r.field,n)}},F4={type:"field",parse:()=>v4},uJ={type:"document",validate:aC("function")};var hJ=Object.freeze({__proto__:null,$and:R4,$or:oJ,$nor:aJ,$not:lJ,$elemMatch:T4,$size:k4,$in:Zm,$nin:A4,$all:E4,$mod:cJ,$exists:P4,$gte:lC,$gt:Ym,$lt:N4,$lte:M4,$eq:cC,$ne:O4,$regex:D4,$options:F4,$where:uJ});let dJ=class extends rJ{constructor(e){super(e,{defaultOperatorName:"$eq",operatorToConditionName:r=>r.slice(1)})}parse(e,r){return r&&r.field?C4(this.parseFieldOperators(r.field,e)):super.parse(e)}};const pb=hJ;function uC(t,e,r){for(let n=0,i=t.length;n<i;n++)if(r(t[n],e)===0)return!0;return!1}function hC(t,e){return Array.isArray(t)&&Number.isNaN(Number(e))}function S2(t,e,r){if(!hC(t,e))return r(t,e);let n=[];for(let i=0;i<t.length;i++){const s=r(t[i],e);s!==void 0&&(n=n.concat(s))}return n}function nl(t){return(e,r,n)=>{const i=n.get(r,e.field);return Array.isArray(i)?i.some(s=>t(e,s,n)):t(e,i,n)}}const fJ=(t,e)=>t[e];function L4(t,e,r){const n=e.lastIndexOf(".");return n===-1?[t,e]:[r(t,e.slice(0,n)),e.slice(n+1)]}function pJ(t,e,r=fJ){if(e===Vh)return t;if(!t)throw new Error(`Unable to get field "${e}" out of ${String(t)}.`);return(function(n,i,s){if(i.indexOf(".")===-1)return S2(n,i,s);const o=i.split(".");let l=n;for(let c=0,u=o.length;c<u;c++)if(l=S2(l,o[c],s),!l||typeof l!="object")return l;return l})(t,e,r)}function $4(t,e){return t===e?0:t>e?1:-1}function B4(t,e={}){return iJ(t,Object.assign({get:pJ,compare:$4},e))}const z4=(t,e,{interpret:r})=>t.value.some(n=>r(n,e)),gJ=(t,e,r)=>!z4(t,e,r),V4=(t,e,{interpret:r})=>t.value.every(n=>r(n,e)),mJ=(t,e,{interpret:r})=>!r(t.value[0],e),dC=(t,e,{compare:r,get:n})=>{const i=n(e,t.field);return Array.isArray(i)&&!Array.isArray(t.value)?uC(i,t.value,r):r(i,t.value)===0},H4=(t,e,r)=>!dC(t,e,r),q4=nl((t,e,r)=>{const n=r.compare(e,t.value);return n===0||n===-1}),W4=nl((t,e,r)=>r.compare(e,t.value)===-1),G4=nl((t,e,r)=>r.compare(e,t.value)===1),U4=nl((t,e,r)=>{const n=r.compare(e,t.value);return n===0||n===1}),K4=(t,e,{get:r})=>{if(t.field===Vh)return e!==void 0;const[n,i]=L4(e,t.field,r),s=o=>o==null?!!o===t.value:o.hasOwnProperty(i)===t.value;return hC(n,i)?n.some(s):s(n)},yJ=nl((t,e)=>typeof e=="number"&&e%t.value[0]===t.value[1]),Z4=(t,e,{get:r})=>{const[n,i]=L4(e,t.field,r),s=o=>{const l=r(o,i);return Array.isArray(l)&&l.length===t.value};return t.field!==Vh&&hC(n,i)?n.some(s):s(n)},Y4=nl((t,e)=>typeof e=="string"&&t.value.test(e)),Xm=nl((t,e,{compare:r})=>uC(t.value,e,r)),X4=(t,e,r)=>!Xm(t,e,r),J4=(t,e,{compare:r,get:n})=>{const i=n(e,t.field);return Array.isArray(i)&&t.value.every(s=>uC(i,s,r))},Q4=(t,e,{interpret:r,get:n})=>{const i=n(e,t.field);return Array.isArray(i)&&i.some(s=>r(t.value,s))},xJ=(t,e)=>t.value.call(e);var vJ=Object.freeze({__proto__:null,or:z4,nor:gJ,and:V4,not:mJ,eq:dC,ne:H4,lte:q4,lt:W4,gt:G4,gte:U4,exists:K4,mod:yJ,size:Z4,regex:Y4,within:Xm,nin:X4,all:J4,elemMatch:Q4,where:xJ});const fC=Object.assign({},vJ,{in:Xm});B4(fC);function C2(t){return t===null||typeof t!="object"?t:t instanceof Date?t.getTime():t&&typeof t.toJSON=="function"?t.toJSON():t}const bJ=(t,e)=>$4(C2(t),C2(e));function pC(t,e,r){const n=new dJ(t),i=B4(e,Object.assign({compare:bJ},r));if(r&&r.forPrimitives){const s={field:Vh},o=n.parse;n.setParse(l=>o(l,s))}return sJ(n.parse,i)}pC(pb,fC);pC(["$and","$or"].reduce((t,e)=>(t[e]=Object.assign({},t[e],{type:"field"}),t),Object.assign({},pb,{$nor:Object.assign({},pb.$nor,{type:"field",parse:_4.compound})})),fC,{forPrimitives:!0});const e6=Object.hasOwn||((t,e)=>Object.prototype.hasOwnProperty.call(t,e));function gb(t){return Array.isArray(t)?t:[t]}const Il="__caslSubjectType__";function wJ(t,e){if(e){if(!e6(e,Il))Object.defineProperty(e,Il,{value:t});else if(t!==e[Il])throw new Error(`Trying to cast object to subject type ${t} but previously it was casted to ${e[Il]}`)}return e}const fp=t=>{const e=typeof t;return e==="string"||e==="function"},SJ=t=>t.modelName||t.name;function t6(t){return e6(t,Il)?t[Il]:SJ(t.constructor)}const _2={function:t=>t.constructor,string:t6};function I2(t,e,r){for(let n=r;n<e.length;n++)t.push(e[n])}function j2(t,e){if(!t||!t.length)return e||[];if(!e||!e.length)return t||[];let r=0,n=0;const i=[];for(;r<t.length&&n<e.length;)t[r].priority<e[n].priority?(i.push(t[r]),r++):(i.push(e[n]),n++);return I2(i,t,r),I2(i,e,n),i}function Ld(t,e,r){let n=t.get(e);return n||(n=r(),t.set(e,n)),n}const CJ=t=>t;function _J(t,e){if(Array.isArray(t.fields)&&!t.fields.length)throw new Error("`rawRule.fields` cannot be an empty array. https://bit.ly/390miLa");if(t.fields&&!e.fieldMatcher)throw new Error('You need to pass "fieldMatcher" option in order to restrict access by fields');if(t.conditions&&!e.conditionsMatcher)throw new Error('You need to pass "conditionsMatcher" option in order to restrict access by conditions')}class IJ{constructor(e,r,n=0){_J(e,r),this.action=r.resolveAction(e.action),this.subject=e.subject,this.inverted=!!e.inverted,this.conditions=e.conditions,this.reason=e.reason,this.origin=e,this.fields=e.fields?gb(e.fields):void 0,this.priority=n,this.t=r}i(){return this.conditions&&!this.o&&(this.o=this.t.conditionsMatcher(this.conditions)),this.o}get ast(){const e=this.i();return e?e.ast:void 0}matchesConditions(e){return this.conditions?!e||fp(e)?!this.inverted:this.i()(e):!0}matchesField(e){return this.fields?e?(this.u||(this.u=this.t.fieldMatcher(this.fields)),this.u(e)):!this.inverted:!0}}function jJ(t,e){const r={value:t,prev:e,next:null};return e&&(e.next=r),r}function RJ(t){t.next&&(t.next.prev=t.prev),t.prev&&(t.prev.next=t.next),t.next=t.prev=null}const TJ=t=>({value:t.value,prev:t.prev,next:t.next}),R2=()=>({rules:[],merged:!1}),T2=()=>new Map;class kJ{constructor(e=[],r={}){this.h=!1,this.l=new Map,this.p={conditionsMatcher:r.conditionsMatcher,fieldMatcher:r.fieldMatcher,resolveAction:r.resolveAction||CJ},this.$=r.anyAction||"manage",this.A=r.anySubjectType||"all",this.m=e,this.M=!!r.detectSubjectType,this.j=r.detectSubjectType||t6,this.v(e)}get rules(){return this.m}detectSubjectType(e){return fp(e)?e:e?this.j(e):this.A}update(e){const r={rules:e,ability:this,target:this};return this._("update",r),this.m=e,this.v(e),this._("updated",r),this}v(e){const r=new Map;let n;for(let i=e.length-1;i>=0;i--){const s=e.length-i-1,o=new IJ(e[i],this.p,s),l=gb(o.action),c=gb(o.subject||this.A);!this.h&&o.fields&&(this.h=!0);for(let u=0;u<c.length;u++){const h=Ld(r,c[u],T2);n===void 0&&(n=typeof c[u]),typeof c[u]!==n&&n!=="mixed"&&(n="mixed");for(let d=0;d<l.length;d++)Ld(h,l[d],R2).rules.push(o)}}if(this.l=r,n!=="mixed"&&!this.M){const i=_2[n]||_2.string;this.j=i}}possibleRulesFor(e,r=this.A){if(!fp(r))throw new Error('"possibleRulesFor" accepts only subject types (i.e., string or class) as the 2nd parameter');const n=Ld(this.l,r,T2),i=Ld(n,e,R2);if(i.merged)return i.rules;const s=e!==this.$&&n.has(this.$)?n.get(this.$).rules:void 0;let o=j2(i.rules,s);return r!==this.A&&(o=j2(o,this.possibleRulesFor(e,this.A))),i.rules=o,i.merged=!0,o}rulesFor(e,r,n){const i=this.possibleRulesFor(e,r);if(n&&typeof n!="string")throw new Error("The 3rd, `field` parameter is expected to be a string. See https://stalniy.github.io/casl/en/api/casl-ability#can-of-pure-ability for details");return this.h?i.filter(s=>s.matchesField(n)):i}actionsFor(e){if(!fp(e))throw new Error('"actionsFor" accepts only subject types (i.e., string or class) as a parameter');const r=new Set,n=this.l.get(e);n&&Array.from(n.keys()).forEach(s=>r.add(s));const i=e!==this.A?this.l.get(this.A):void 0;return i&&Array.from(i.keys()).forEach(s=>r.add(s)),Array.from(r)}on(e,r){this.F=this.F||new Map;const n=this.F,i=n.get(e)||null,s=jJ(r,i);return n.set(e,s),()=>{const o=n.get(e);!s.next&&!s.prev&&o===s?n.delete(e):s===o&&n.set(e,s.prev),RJ(s)}}_(e,r){if(!this.F)return;let n=this.F.get(e)||null;for(;n!==null;){const i=n.prev?TJ(n.prev):null;n.value(r),n=i}}}class AJ extends kJ{can(e,r,n){const i=this.relevantRuleFor(e,r,n);return!!i&&!i.inverted}relevantRuleFor(e,r,n){const i=this.detectSubjectType(r),s=this.rulesFor(e,i,n);for(let o=0,l=s.length;o<l;o++)if(s[o].matchesConditions(r))return s[o];return null}cannot(e,r,n){return!this.can(e,r,n)}}const EJ={$eq:cC,$ne:O4,$lt:N4,$lte:M4,$gt:Ym,$gte:lC,$in:Zm,$nin:A4,$all:E4,$size:k4,$regex:D4,$options:F4,$elemMatch:T4,$exists:P4},PJ={eq:dC,ne:H4,lt:W4,lte:q4,gt:G4,gte:U4,in:Xm,nin:X4,all:J4,size:Z4,regex:Y4,elemMatch:Q4,exists:K4,and:V4},NJ=pC(EJ,PJ),MJ=/[-/\\^$+?.()|[\]{}]/g,OJ=/\.?\*+\.?/g,DJ=/\*+/,FJ=/\./g;function LJ(t,e,r){const n=r[0]==="*"||t[0]==="."&&t[t.length-1]==="."?"+":"*",i=t.indexOf("**")===-1?"[^.]":".",s=t.replace(FJ,"\\$&").replace(DJ,i+n);return e+t.length===r.length?`(?:${s})?`:s}function $J(t,e,r){return t==="."&&(r[e-1]==="*"||r[e+1]==="*")?t:`\\${t}`}function BJ(t){const e=t.map(n=>n.replace(MJ,$J).replace(OJ,LJ)),r=e.length>1?`(?:${e.join("|")})`:e[0];return new RegExp(`^${r}$`)}const zJ=t=>{let e;return r=>(typeof e>"u"&&(e=t.every(n=>n.indexOf("*")===-1)?null:BJ(t)),e===null?t.indexOf(r)!==-1:e.test(r))};function VJ(t=[],e={}){return new AJ(t,Object.assign({conditionsMatcher:NJ,fieldMatcher:zJ},e))}const HJ=new Set(["read-project-private","read-project-public"]),qJ=["Table","Row","Branch","Revision","Endpoint"];class lh{ability=VJ();loadedScopes=new Set;addSystemPermissions(e){const r=this.scopeToKey({type:"system"});if(this.loadedScopes.has(r))return;const n=this.permissionsToRules(e,null),i=this.expandPermissions(e,null);this.ability.update([...this.ability.rules,...n,...i]),this.loadedScopes.add(r)}addOrganizationPermissions(e,r){const n=this.scopeToKey({type:"organization",organizationId:e});if(this.loadedScopes.has(n))return;const i={organizationId:e},s=this.permissionsToRules(r,i),o=this.expandPermissions(r,i);this.ability.update([...this.ability.rules,...s,...o]),this.loadedScopes.add(n)}addProjectPermissions(e,r){const n=this.scopeToKey({type:"project",projectId:e});if(this.loadedScopes.has(n))return;const i={projectId:e},s=this.permissionsToRules(r,i),o=this.expandPermissions(r,i);this.ability.update([...this.ability.rules,...s,...o]),this.loadedScopes.add(n)}can(e,r,n){const i=wJ(r,n??{});return this.ability.can(e,i)}cannot(e,r,n){return!this.can(e,r,n)}hasScope(e){return this.loadedScopes.has(this.scopeToKey(e))}clearAll(){this.ability.update([]),this.loadedScopes.clear()}scopeToKey(e){switch(e.type){case"system":return"system";case"organization":return`organization:${e.organizationId}`;case"project":return`project:${e.projectId}`}}permissionsToRules(e,r){return e.map(n=>this.permissionToRule(n,r))}permissionToRule(e,r){const n={action:e.action,subject:e.subject},i=this.mergeConditions(e.condition,r);return i&&(n.conditions=i),n}mergeConditions(e,r){const n=e&&Object.keys(e).length>0,i=r&&Object.keys(r).length>0;if(!(!n&&!i))return n&&i?{...e,...r}:n?{...e}:{...r}}expandPermissions(e,r){const n=[];for(const i of e)if(HJ.has(i.id))for(const s of qJ){const o={action:"read",subject:s};r&&Object.keys(r).length>0&&(o.conditions={...r}),n.push(o)}return n}}$.register(lh,()=>new lh,{scope:"singleton"});class Va{constructor(e){this.permissionService=e,le(this,{},{autoBind:!0})}setUserRole(e){if(e?.permissions){const r=e.permissions.map(n=>({id:n.id,action:n.action,subject:n.subject,condition:n.condition??null}));this.permissionService.addSystemPermissions(r)}}clearAll(){this.permissionService.clearAll()}get canCreateProject(){return this.permissionService.can("create","Project")}get canReadUser(){return this.permissionService.can("read","User")}get canCreateUser(){return this.permissionService.can("create","User")}get canAddUser(){return this.permissionService.can("add","User")}get canUpdateUser(){return this.permissionService.can("update","User")}get canDeleteUser(){return this.permissionService.can("delete","User")}get canManageUsers(){return this.canAddUser||this.canReadUser}get canReadOrganization(){return this.permissionService.can("read","Organization")}get canUpdateOrganization(){return this.permissionService.can("update","Organization")}get canDeleteOrganization(){return this.permissionService.can("delete","Organization")}}$.register(Va,()=>{const t=$.get(lh);return new Va(t)},{scope:"singleton"});class Dr{constructor(e){this.permissionService=e,le(this,{},{autoBind:!0})}_contextProvider=null;setContextProvider(e){this._contextProvider=e}get context(){return this._contextProvider?.()??{projectId:null,organizationId:null,isPublic:!1,projectRoleName:null}}get projectId(){return this.context.projectId}get organizationId(){return this.context.organizationId}get isPublic(){return this.context.isPublic}get projectRoleName(){return this.context.projectRoleName}getProjectContext(){const e=this.context,r={};return e.projectId&&(r.projectId=e.projectId),e.organizationId&&(r.organizationId=e.organizationId),r}can(e,r,n){const i=n??this.getProjectContext();return this.permissionService.can(e,r,Object.keys(i).length>0?i:void 0)}get canReadProject(){return this.can("read","Project",{...this.getProjectContext(),isPublic:this.context.isPublic})}get canUpdateProject(){return this.can("update","Project")}get canDeleteProject(){return this.can("delete","Project")}get canReadBranch(){return this.can("read","Branch")}get canCreateBranch(){return this.can("create","Branch")}get canDeleteBranch(){return this.can("delete","Branch")}get canReadRevision(){return this.can("read","Revision")}get canCreateRevision(){return this.can("create","Revision")}get canRevertRevision(){return this.can("revert","Revision")}get canReadTable(){return this.can("read","Table")}get canCreateTable(){return this.can("create","Table")}get canUpdateTable(){return this.can("update","Table")}get canDeleteTable(){return this.can("delete","Table")}get canReadRow(){return this.can("read","Row")}get canCreateRow(){return this.can("create","Row")}get canUpdateRow(){return this.can("update","Row")}get canDeleteRow(){return this.can("delete","Row")}get canReadEndpoint(){return this.can("read","Endpoint")}get canCreateEndpoint(){return this.can("create","Endpoint")}get canDeleteEndpoint(){return this.can("delete","Endpoint")}get canAddUser(){return this.can("add","User")}get canUpdateUser(){return this.can("update","User")}get canDeleteUser(){return this.can("delete","User")}get canReadUser(){return this.can("read","User")}get canManageUsers(){return this.canAddUser||this.canReadUser}get canAccessSettings(){return this.canUpdateProject||this.canDeleteProject}get canWrite(){return this.canCreateTable||this.canUpdateTable||this.canDeleteTable||this.canCreateRow||this.canUpdateRow||this.canDeleteRow}get isReadOnly(){return!this.canWrite}}$.register(Dr,()=>{const t=$.get(lh);return new Dr(t)},{scope:"singleton"});var vg=function(){return vg=Object.assign||function(e){for(var r,n=1,i=arguments.length;n<i;n++){r=arguments[n];for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(e[s]=r[s])}return e},vg.apply(this,arguments)};var pp=new Map,mb=new Map,r6=!0,bg=!1;function n6(t){return t.replace(/[\s,]+/g," ").trim()}function WJ(t){return n6(t.source.body.substring(t.start,t.end))}function GJ(t){var e=new Set,r=[];return t.definitions.forEach(function(n){if(n.kind==="FragmentDefinition"){var i=n.name.value,s=WJ(n.loc),o=mb.get(i);o&&!o.has(s)?r6&&console.warn("Warning: fragment with name "+i+` already exists.
|
|
370
370
|
graphql-tag enforces all fragment names across your application to be unique; read more about
|
|
371
371
|
this in the docs: http://dev.apollodata.com/core/fragments.html#unique-names`):o||mb.set(i,o=new Set),o.add(s),e.has(s)||(e.add(s),r.push(n))}else r.push(n)}),vg(vg({},t),{definitions:r})}function UJ(t){var e=new Set(t.definitions);e.forEach(function(n){n.loc&&delete n.loc,Object.keys(n).forEach(function(i){var s=n[i];s&&typeof s=="object"&&e.add(s)})});var r=t.loc;return r&&(delete r.startToken,delete r.endToken),t}function KJ(t){var e=n6(t);if(!pp.has(e)){var r=VL(t,{experimentalFragmentVariables:bg,allowLegacyFragmentVariables:bg});if(!r||r.kind!=="Document")throw new Error("Not a valid GraphQL document.");pp.set(e,UJ(GJ(r)))}return pp.get(e)}function ue(t){for(var e=[],r=1;r<arguments.length;r++)e[r-1]=arguments[r];typeof t=="string"&&(t=[t]);var n=t[0];return e.forEach(function(i,s){i&&i.kind==="Document"?n+=i.loc.source.body:n+=i,n+=t[s+1]}),KJ(n)}function ZJ(){pp.clear(),mb.clear()}function YJ(){r6=!1}function XJ(){bg=!0}function JJ(){bg=!1}var qc={gql:ue,resetCaches:ZJ,disableFragmentWarnings:YJ,enableExperimentalFragmentVariables:XJ,disableExperimentalFragmentVariables:JJ};(function(t){t.gql=qc.gql,t.resetCaches=qc.resetCaches,t.disableFragmentWarnings=qc.disableFragmentWarnings,t.enableExperimentalFragmentVariables=qc.enableExperimentalFragmentVariables,t.disableExperimentalFragmentVariables=qc.disableExperimentalFragmentVariables})(ue||(ue={}));ue.default=ue;var vl=(t=>(t.Applied="applied",t.Failed="failed",t.Skipped="skipped",t))(vl||{}),mt=(t=>(t.Added="ADDED",t.Modified="MODIFIED",t.Removed="REMOVED",t.Renamed="RENAMED",t.RenamedAndModified="RENAMED_AND_MODIFIED",t))(mt||{}),xr=(t=>(t.Graphql="GRAPHQL",t.RestApi="REST_API",t))(xr||{}),fa=(t=>(t.CreatedAt="createdAt",t.Data="data",t.Id="id",t.PublishedAt="publishedAt",t.UpdatedAt="updatedAt",t))(fa||{}),gp=(t=>(t.Boolean="boolean",t.Float="float",t.Int="int",t.Text="text",t.Timestamp="timestamp",t))(gp||{}),gC=(t=>(t.Replace="replace",t))(gC||{}),i6=(t=>(t.Default="default",t.Insensitive="insensitive",t))(i6||{}),Jm=(t=>(t.All="all",t.Booleans="booleans",t.Keys="keys",t.Numbers="numbers",t.Strings="strings",t.Values="values",t))(Jm||{}),Qm=(t=>(t.Phrase="phrase",t.Plain="plain",t.Prefix="prefix",t.Tsquery="tsquery",t))(Qm||{}),Di=(t=>(t.Asc="asc",t.Desc="desc",t))(Di||{}),ka=(t=>(t.Developer="developer",t.Editor="editor",t.Reader="reader",t))(ka||{}),Po=(t=>(t.SystemAdmin="systemAdmin",t.SystemFullApiRead="systemFullApiRead",t.SystemUser="systemUser",t))(Po||{});const QJ=ue`
|
|
372
372
|
fragment BranchLoaderFragment on BranchModel {
|
|
@@ -1839,7 +1839,7 @@ this in the docs: http://dev.apollodata.com/core/fragments.html#unique-names`):o
|
|
|
1839
1839
|
}
|
|
1840
1840
|
}
|
|
1841
1841
|
${RQ}
|
|
1842
|
-
`,ete=(t,e,r,n)=>t();function tte(t,e=ete){return{getBranchForLoader(r,n){return e(i=>t.request(TQ,r,{...n,...i}),"getBranchForLoader","query",r)},getProject(r,n){return e(i=>t.request(kQ,r,{...n,...i}),"getProject","query",r)},getProjectForLoader(r,n){return e(i=>t.request(AQ,r,{...n,...i}),"getProjectForLoader","query",r)},getRevisionForLoader(r,n){return e(i=>t.request(EQ,r,{...n,...i}),"getRevisionForLoader","query",r)},getRowForLoader(r,n){return e(i=>t.request(PQ,r,{...n,...i}),"getRowForLoader","query",r)},getRowCountForeignKeysToForLoader(r,n){return e(i=>t.request(NQ,r,{...n,...i}),"getRowCountForeignKeysToForLoader","query",r)},ForeignKeysBy(r,n){return e(i=>t.request(MQ,r,{...n,...i}),"ForeignKeysBy","query",r)},ForeignKeysByRows(r,n){return e(i=>t.request(OQ,r,{...n,...i}),"ForeignKeysByRows","query",r)},getTableForLoader(r,n){return e(i=>t.request(DQ,r,{...n,...i}),"getTableForLoader","query",r)},updatePassword(r,n){return e(i=>t.request(FQ,r,{...n,...i}),"updatePassword","mutation",r)},createProject(r,n){return e(i=>t.request(LQ,r,{...n,...i}),"createProject","mutation",r)},findForeignKey(r,n){return e(i=>t.request($Q,r,{...n,...i}),"findForeignKey","query",r)},AdminDashboardStats(r,n){return e(i=>t.request(BQ,r,{...n,...i}),"AdminDashboardStats","query",r)},adminGetUser(r,n){return e(i=>t.request(zQ,r,{...n,...i}),"adminGetUser","query",r)},adminResetPassword(r,n){return e(i=>t.request(VQ,r,{...n,...i}),"adminResetPassword","mutation",r)},adminUsers(r,n){return e(i=>t.request(HQ,r,{...n,...i}),"adminUsers","query",r)},adminUser(r,n){return e(i=>t.request(qQ,r,{...n,...i}),"adminUser","query",r)},assetsTablesData(r,n){return e(i=>t.request(WQ,r,{...n,...i}),"assetsTablesData","query",r)},assetsRowsData(r,n){return e(i=>t.request(GQ,r,{...n,...i}),"assetsRowsData","query",r)},subSchemaItemsData(r,n){return e(i=>t.request(UQ,r,{...n,...i}),"subSchemaItemsData","query",r)},getProjectBranches(r,n){return e(i=>t.request(KQ,r,{...n,...i}),"getProjectBranches","query",r)},deleteBranch(r,n){return e(i=>t.request(ZQ,r,{...n,...i}),"deleteBranch","mutation",r)},getBranchesForSelect(r,n){return e(i=>t.request(YQ,r,{...n,...i}),"getBranchesForSelect","query",r)},getBranchRevisionsForCreate(r,n){return e(i=>t.request(XQ,r,{...n,...i}),"getBranchRevisionsForCreate","query",r)},createBranch(r,n){return e(i=>t.request(JQ,r,{...n,...i}),"createBranch","mutation",r)},GetRevisionChanges(r,n){return e(i=>t.request(QQ,r,{...n,...i}),"GetRevisionChanges","query",r)},GetTableChanges(r,n){return e(i=>t.request(eee,r,{...n,...i}),"GetTableChanges","query",r)},confirmEmailCode(r,n){return e(i=>t.request(tee,r,{...n,...i}),"confirmEmailCode","mutation",r)},getEndpointBranches(r,n){return e(i=>t.request(ree,r,{...n,...i}),"getEndpointBranches","query",r)},getProjectEndpoints(r,n){return e(i=>t.request(nee,r,{...n,...i}),"getProjectEndpoints","query",r)},getBranchRevisions(r,n){return e(i=>t.request(iee,r,{...n,...i}),"getBranchRevisions","query",r)},createEndpoint(r,n){return e(i=>t.request(see,r,{...n,...i}),"createEndpoint","mutation",r)},deleteEndpoint(r,n){return e(i=>t.request(oee,r,{...n,...i}),"deleteEndpoint","mutation",r)},loginGithub(r,n){return e(i=>t.request(aee,r,{...n,...i}),"loginGithub","mutation",r)},loginGoogle(r,n){return e(i=>t.request(lee,r,{...n,...i}),"loginGoogle","mutation",r)},login(r,n){return e(i=>t.request(cee,r,{...n,...i}),"login","mutation",r)},getMigrationBranches(r,n){return e(i=>t.request(uee,r,{...n,...i}),"getMigrationBranches","query",r)},getBranchMigrations(r,n){return e(i=>t.request(hee,r,{...n,...i}),"getBranchMigrations","query",r)},applyMigrations(r,n){return e(i=>t.request(dee,r,{...n,...i}),"applyMigrations","mutation",r)},getMigrations(r,n){return e(i=>t.request(fee,r,{...n,...i}),"getMigrations","query",r)},updateProject(r,n){return e(i=>t.request(pee,r,{...n,...i}),"updateProject","mutation",r)},deleteProjectForSettings(r,n){return e(i=>t.request(gee,r,{...n,...i}),"deleteProjectForSettings","mutation",r)},fetchTableForStack(r,n){return e(i=>t.request(mee,r,{...n,...i}),"fetchTableForStack","query",r)},createTableForStack(r,n){return e(i=>t.request(yee,r,{...n,...i}),"createTableForStack","mutation",r)},updateTableForStack(r,n){return e(i=>t.request(xee,r,{...n,...i}),"updateTableForStack","mutation",r)},renameTableForStack(r,n){return e(i=>t.request(vee,r,{...n,...i}),"renameTableForStack","mutation",r)},rowPageData(r,n){return e(i=>t.request(bee,r,{...n,...i}),"rowPageData","query",r)},signUp(r,n){return e(i=>t.request(wee,r,{...n,...i}),"signUp","mutation",r)},setUsername(r,n){return e(i=>t.request(See,r,{...n,...i}),"setUsername","mutation",r)},getUsersProject(r,n){return e(i=>t.request(Cee,r,{...n,...i}),"getUsersProject","query",r)},searchUsers(r,n){return e(i=>t.request(_ee,r,{...n,...i}),"searchUsers","query",r)},addUserToProject(r,n){return e(i=>t.request(Iee,r,{...n,...i}),"addUserToProject","mutation",r)},removeUserFromProject(r,n){return e(i=>t.request(jee,r,{...n,...i}),"removeUserFromProject","mutation",r)},updateUserProjectRole(r,n){return e(i=>t.request(Ree,r,{...n,...i}),"updateUserProjectRole","mutation",r)},createUser(r,n){return e(i=>t.request(Tee,r,{...n,...i}),"createUser","mutation",r)},configuration(r,n){return e(i=>t.request(kee,r,{...n,...i}),"configuration","query",r)},getMe(r,n){return e(i=>t.request(Aee,r,{...n,...i}),"getMe","query",r)},getProjectGraph(r,n){return e(i=>t.request(Eee,r,{...n,...i}),"getProjectGraph","query",r)},findBranches(r,n){return e(i=>t.request(Pee,r,{...n,...i}),"findBranches","query",r)},findRevisions(r,n){return e(i=>t.request(Nee,r,{...n,...i}),"findRevisions","query",r)},meProjectsList(r,n){return e(i=>t.request(Mee,r,{...n,...i}),"meProjectsList","query",r)},GetRowChanges(r,n){return e(i=>t.request(Oee,r,{...n,...i}),"GetRowChanges","query",r)},GetTableChangesForFilter(r,n){return e(i=>t.request(Dee,r,{...n,...i}),"GetTableChangesForFilter","query",r)},RowListRows(r,n){return e(i=>t.request(Fee,r,{...n,...i}),"RowListRows","query",r)},DeleteRow(r,n){return e(i=>t.request(Lee,r,{...n,...i}),"DeleteRow","mutation",r)},DeleteRows(r,n){return e(i=>t.request($ee,r,{...n,...i}),"DeleteRows","mutation",r)},PatchRowInline(r,n){return e(i=>t.request(Bee,r,{...n,...i}),"PatchRowInline","mutation",r)},GetTableViews(r,n){return e(i=>t.request(zee,r,{...n,...i}),"GetTableViews","query",r)},UpdateTableViews(r,n){return e(i=>t.request(Vee,r,{...n,...i}),"UpdateTableViews","mutation",r)},foreignKeyTableWithRows(r,n){return e(i=>t.request(Hee,r,{...n,...i}),"foreignKeyTableWithRows","query",r)},createRowForStack(r,n){return e(i=>t.request(qee,r,{...n,...i}),"createRowForStack","mutation",r)},updateRowForStack(r,n){return e(i=>t.request(Wee,r,{...n,...i}),"updateRowForStack","mutation",r)},renameRowForStack(r,n){return e(i=>t.request(Gee,r,{...n,...i}),"renameRowForStack","mutation",r)},searchRows(r,n){return e(i=>t.request(Uee,r,{...n,...i}),"searchRows","query",r)},revertChangesForSidebar(r,n){return e(i=>t.request(Kee,r,{...n,...i}),"revertChangesForSidebar","mutation",r)},createRevisionForSidebar(r,n){return e(i=>t.request(Zee,r,{...n,...i}),"createRevisionForSidebar","mutation",r)},createBranchForSidebar(r,n){return e(i=>t.request(Yee,r,{...n,...i}),"createBranchForSidebar","mutation",r)},deleteTableForList(r,n){return e(i=>t.request(Xee,r,{...n,...i}),"deleteTableForList","mutation",r)},tableListData(r,n){return e(i=>t.request(Jee,r,{...n,...i}),"tableListData","query",r)},tableRelationsData(r,n){return e(i=>t.request(Qee,r,{...n,...i}),"tableRelationsData","query",r)}}}const rte={BASE_URL:"/",DEV:!1,GIT_BRANCH_NAME:"master",GIT_COMMIT_HASH:"877715b",MODE:"production",PACKAGE_VERSION:"2.4.0-alpha.1",PROD:!0,REACT_APP_ENDPOINT_HOST:"",REACT_APP_ENDPOINT_PORT:"",REACT_APP_ENDPOINT_SERVER_URL:"/endpoint",REACT_APP_GRAPHQL_SERVER_URL:"/graphql",REACT_APP_SWAGGER_SERVER_URL:"/api",SSR:!1};class wg{constructor(){}get(e){const r=globalThis.__env__?.[e],n=rte[e];return r||n}}$.register(wg,()=>new wg,{scope:"singleton"});const Qt=({hideSidebar:t,sidebar:e,title:r,actions:n,children:i,footer:s})=>a.jsxs(P,{minHeight:"100vh",children:[!t&&a.jsxs(P,{borderRight:"1px solid",borderRightColor:"newGray.100",flexDirection:"column",justifyContent:e?"space-between":"flex-end",padding:"16px",width:"288px",minWidth:"288px",flexShrink:0,height:"100vh",top:0,position:"sticky",children:[e,s&&a.jsx(T,{alignSelf:"center",mt:"1rem",children:s})]}),a.jsxs(P,{alignItems:"center",flex:1,flexDirection:"column",width:"100%",children:[(r||n)&&a.jsxs(P,{alignItems:"center",backgroundColor:"white",borderBottom:"1px solid",borderBottomColor:"gray.50",justifyContent:"space-between",maxWidth:"900px",padding:"8px",width:"100%",position:"sticky",zIndex:1,top:0,children:[r,n]}),a.jsx(P,{flex:1,flexDirection:"column",maxWidth:"900px",padding:"1rem 1rem 0rem 1rem",width:"100%",children:i})]})]}),Ii=({height:t="2.5rem",title:e,onClick:r,disabled:n,isSelected:i,isLoading:s,icon:o,dataTestId:l})=>a.jsx(be,{"data-testid":l,_hover:{color:"gray.400",backgroundColor:"white"},_disabled:i?{backgroundColor:"gray.50",cursor:"not-allowed"}:void 0,alignSelf:"flex-start",color:"gray.300",fontWeight:"500",fontSize:16,height:t,disabled:n||i,loading:s,variant:"ghost",onClick:r,children:a.jsxs(P,{alignItems:"center",gap:"0.5rem",children:[o&&a.jsx(T,{fontSize:"sm",children:o}),a.jsx(j,{children:e})]})}),c6=t=>a.jsx(Ii,{...t,icon:a.jsx(Ah,{})}),r0=({height:t="2.5rem",loading:e,isDisabled:r,onClick:n,title:i,dataTestId:s})=>a.jsxs(be,{"data-testid":s,_hover:{backgroundColor:"gray.50"},alignSelf:"flex-start",color:"gray.400",height:t,loading:e,disabled:r,variant:"ghost",onClick:n,width:"48px",children:[a.jsx(He,{size:"sm",mr:i?8:0,children:a.jsx(Gw,{})}),i]}),u6=({height:t="2.5rem",onClick:e,disabled:r,dataTestId:n})=>a.jsx(be,{"data-testid":n,disabled:r,_hover:{backgroundColor:"gray.50"},alignSelf:"flex-start",color:"gray.400",height:t,variant:"ghost",onClick:e,width:"48px",children:a.jsx(He,{size:"md",children:a.jsx(jc,{})})}),h6=({dataTestId:t,...e})=>a.jsx(lt,{"data-testid":t,_hover:{backgroundColor:"gray.100"},color:"gray.400",variant:"ghost",size:"lg",width:"40px",height:"40px",...e,children:a.jsx(YE,{})}),Xs=({value:t,placeholder:e,autoFocus:r,onChange:n,onBlur:i,onEnter:s,width:o,height:l,type:c,dataTestId:u,autoComplete:h})=>{const d=YX();return a.jsx(Ot,{autoComplete:h,"data-testid":u,borderColor:"gray.100",padding:"0 9px",placeholder:e,ref:r?d:void 0,value:t,variant:"outline",onChange:n,onBlur:i,width:o,height:l,type:c,onKeyDown:s?f=>{f.key==="Enter"&&s()}:void 0})},yt=PA({placement:"top",pauseOnPageIdle:!0,duration:1500}),mp=PA({placement:"bottom",pauseOnPageIdle:!0,duration:1500}),k2=t=>a.jsxs(Z8,{width:{md:"sm"},children:[t.type==="loading"?a.jsx(vt,{size:"sm",color:"blue.solid"}):a.jsx(Y8,{}),a.jsxs(NA,{gap:"1",flex:"1",maxWidth:"100%",children:[t.title&&a.jsx(X8,{children:t.title}),t.description&&a.jsx(J8,{color:"gray.500",children:t.description})]}),t.action&&a.jsx(Q8,{children:t.action.label}),t.closable&&a.jsx(eL,{})]}),A2=()=>a.jsxs(je,{children:[a.jsx(i_,{toaster:yt,insetInline:{mdDown:"4"},children:t=>a.jsx(k2,{...t})}),a.jsx(i_,{toaster:mp,insetInline:{mdDown:"4"},children:t=>a.jsx(k2,{...t})})]}),ir=_.forwardRef(function(e,r){const{showArrow:n,children:i,disabled:s,portalled:o=!0,content:l,contentProps:c,portalRef:u,...h}=e;return s?i:a.jsxs(bA,{...h,children:[a.jsx(wA,{asChild:!0,children:i}),a.jsx(je,{disabled:!o,container:u,children:a.jsx(SA,{children:a.jsxs(CA,{ref:r,...c,children:[n&&a.jsx(_A,{children:a.jsx(IA,{})}),l]})})})]})});var $d={exports:{}},Yy={},$s={},sa={},Xy={},Jy={},Qy={},E2;function Sg(){return E2||(E2=1,(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.regexpCode=t.getEsmExportName=t.getProperty=t.safeStringify=t.stringify=t.strConcat=t.addCodeArg=t.str=t._=t.nil=t._Code=t.Name=t.IDENTIFIER=t._CodeOrName=void 0;class e{}t._CodeOrName=e,t.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;class r extends e{constructor(x){if(super(),!t.IDENTIFIER.test(x))throw new Error("CodeGen: name must be a valid identifier");this.str=x}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}}t.Name=r;class n extends e{constructor(x){super(),this._items=typeof x=="string"?[x]:x}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;const x=this._items[0];return x===""||x==='""'}get str(){var x;return(x=this._str)!==null&&x!==void 0?x:this._str=this._items.reduce((b,S)=>`${b}${S}`,"")}get names(){var x;return(x=this._names)!==null&&x!==void 0?x:this._names=this._items.reduce((b,S)=>(S instanceof r&&(b[S.str]=(b[S.str]||0)+1),b),{})}}t._Code=n,t.nil=new n("");function i(v,...x){const b=[v[0]];let S=0;for(;S<x.length;)l(b,x[S]),b.push(v[++S]);return new n(b)}t._=i;const s=new n("+");function o(v,...x){const b=[p(v[0])];let S=0;for(;S<x.length;)b.push(s),l(b,x[S]),b.push(s,p(v[++S]));return c(b),new n(b)}t.str=o;function l(v,x){x instanceof n?v.push(...x._items):x instanceof r?v.push(x):v.push(d(x))}t.addCodeArg=l;function c(v){let x=1;for(;x<v.length-1;){if(v[x]===s){const b=u(v[x-1],v[x+1]);if(b!==void 0){v.splice(x-1,3,b);continue}v[x++]="+"}x++}}function u(v,x){if(x==='""')return v;if(v==='""')return x;if(typeof v=="string")return x instanceof r||v[v.length-1]!=='"'?void 0:typeof x!="string"?`${v.slice(0,-1)}${x}"`:x[0]==='"'?v.slice(0,-1)+x.slice(1):void 0;if(typeof x=="string"&&x[0]==='"'&&!(v instanceof r))return`"${v}${x.slice(1)}`}function h(v,x){return x.emptyStr()?v:v.emptyStr()?x:o`${v}${x}`}t.strConcat=h;function d(v){return typeof v=="number"||typeof v=="boolean"||v===null?v:p(Array.isArray(v)?v.join(","):v)}function f(v){return new n(p(v))}t.stringify=f;function p(v){return JSON.stringify(v).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}t.safeStringify=p;function g(v){return typeof v=="string"&&t.IDENTIFIER.test(v)?new n(`.${v}`):i`[${v}]`}t.getProperty=g;function y(v){if(typeof v=="string"&&t.IDENTIFIER.test(v))return new n(`${v}`);throw new Error(`CodeGen: invalid export name: ${v}, use explicit $id name mapping`)}t.getEsmExportName=y;function m(v){return new n(v.toString())}t.regexpCode=m})(Qy)),Qy}var ex={},P2;function N2(){return P2||(P2=1,(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.ValueScope=t.ValueScopeName=t.Scope=t.varKinds=t.UsedValueState=void 0;const e=Sg();class r extends Error{constructor(u){super(`CodeGen: "code" for ${u} not defined`),this.value=u.value}}var n;(function(c){c[c.Started=0]="Started",c[c.Completed=1]="Completed"})(n||(t.UsedValueState=n={})),t.varKinds={const:new e.Name("const"),let:new e.Name("let"),var:new e.Name("var")};class i{constructor({prefixes:u,parent:h}={}){this._names={},this._prefixes=u,this._parent=h}toName(u){return u instanceof e.Name?u:this.name(u)}name(u){return new e.Name(this._newName(u))}_newName(u){const h=this._names[u]||this._nameGroup(u);return`${u}${h.index++}`}_nameGroup(u){var h,d;if(!((d=(h=this._parent)===null||h===void 0?void 0:h._prefixes)===null||d===void 0)&&d.has(u)||this._prefixes&&!this._prefixes.has(u))throw new Error(`CodeGen: prefix "${u}" is not allowed in this scope`);return this._names[u]={prefix:u,index:0}}}t.Scope=i;class s extends e.Name{constructor(u,h){super(h),this.prefix=u}setValue(u,{property:h,itemIndex:d}){this.value=u,this.scopePath=(0,e._)`.${new e.Name(h)}[${d}]`}}t.ValueScopeName=s;const o=(0,e._)`\n`;class l extends i{constructor(u){super(u),this._values={},this._scope=u.scope,this.opts={...u,_n:u.lines?o:e.nil}}get(){return this._scope}name(u){return new s(u,this._newName(u))}value(u,h){var d;if(h.ref===void 0)throw new Error("CodeGen: ref must be passed in value");const f=this.toName(u),{prefix:p}=f,g=(d=h.key)!==null&&d!==void 0?d:h.ref;let y=this._values[p];if(y){const x=y.get(g);if(x)return x}else y=this._values[p]=new Map;y.set(g,f);const m=this._scope[p]||(this._scope[p]=[]),v=m.length;return m[v]=h.ref,f.setValue(h,{property:p,itemIndex:v}),f}getValue(u,h){const d=this._values[u];if(d)return d.get(h)}scopeRefs(u,h=this._values){return this._reduceValues(h,d=>{if(d.scopePath===void 0)throw new Error(`CodeGen: name "${d}" has no value`);return(0,e._)`${u}${d.scopePath}`})}scopeCode(u=this._values,h,d){return this._reduceValues(u,f=>{if(f.value===void 0)throw new Error(`CodeGen: name "${f}" has no value`);return f.value.code},h,d)}_reduceValues(u,h,d={},f){let p=e.nil;for(const g in u){const y=u[g];if(!y)continue;const m=d[g]=d[g]||new Map;y.forEach(v=>{if(m.has(v))return;m.set(v,n.Started);let x=h(v);if(x){const b=this.opts.es5?t.varKinds.var:t.varKinds.const;p=(0,e._)`${p}${b} ${v} = ${x};${this.opts._n}`}else if(x=f?.(v))p=(0,e._)`${p}${x}${this.opts._n}`;else throw new r(v);m.set(v,n.Completed)})}return p}}t.ValueScope=l})(ex)),ex}var M2;function Ye(){return M2||(M2=1,(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.or=t.and=t.not=t.CodeGen=t.operators=t.varKinds=t.ValueScopeName=t.ValueScope=t.Scope=t.Name=t.regexpCode=t.stringify=t.getProperty=t.nil=t.strConcat=t.str=t._=void 0;const e=Sg(),r=N2();var n=Sg();Object.defineProperty(t,"_",{enumerable:!0,get:function(){return n._}}),Object.defineProperty(t,"str",{enumerable:!0,get:function(){return n.str}}),Object.defineProperty(t,"strConcat",{enumerable:!0,get:function(){return n.strConcat}}),Object.defineProperty(t,"nil",{enumerable:!0,get:function(){return n.nil}}),Object.defineProperty(t,"getProperty",{enumerable:!0,get:function(){return n.getProperty}}),Object.defineProperty(t,"stringify",{enumerable:!0,get:function(){return n.stringify}}),Object.defineProperty(t,"regexpCode",{enumerable:!0,get:function(){return n.regexpCode}}),Object.defineProperty(t,"Name",{enumerable:!0,get:function(){return n.Name}});var i=N2();Object.defineProperty(t,"Scope",{enumerable:!0,get:function(){return i.Scope}}),Object.defineProperty(t,"ValueScope",{enumerable:!0,get:function(){return i.ValueScope}}),Object.defineProperty(t,"ValueScopeName",{enumerable:!0,get:function(){return i.ValueScopeName}}),Object.defineProperty(t,"varKinds",{enumerable:!0,get:function(){return i.varKinds}}),t.operators={GT:new e._Code(">"),GTE:new e._Code(">="),LT:new e._Code("<"),LTE:new e._Code("<="),EQ:new e._Code("==="),NEQ:new e._Code("!=="),NOT:new e._Code("!"),OR:new e._Code("||"),AND:new e._Code("&&"),ADD:new e._Code("+")};class s{optimizeNodes(){return this}optimizeNames(A,L){return this}}class o extends s{constructor(A,L,Q){super(),this.varKind=A,this.name=L,this.rhs=Q}render({es5:A,_n:L}){const Q=A?r.varKinds.var:this.varKind,ie=this.rhs===void 0?"":` = ${this.rhs}`;return`${Q} ${this.name}${ie};`+L}optimizeNames(A,L){if(A[this.name.str])return this.rhs&&(this.rhs=E(this.rhs,A,L)),this}get names(){return this.rhs instanceof e._CodeOrName?this.rhs.names:{}}}class l extends s{constructor(A,L,Q){super(),this.lhs=A,this.rhs=L,this.sideEffects=Q}render({_n:A}){return`${this.lhs} = ${this.rhs};`+A}optimizeNames(A,L){if(!(this.lhs instanceof e.Name&&!A[this.lhs.str]&&!this.sideEffects))return this.rhs=E(this.rhs,A,L),this}get names(){const A=this.lhs instanceof e.Name?{}:{...this.lhs.names};return K(A,this.rhs)}}class c extends l{constructor(A,L,Q,ie){super(A,Q,ie),this.op=L}render({_n:A}){return`${this.lhs} ${this.op}= ${this.rhs};`+A}}class u extends s{constructor(A){super(),this.label=A,this.names={}}render({_n:A}){return`${this.label}:`+A}}class h extends s{constructor(A){super(),this.label=A,this.names={}}render({_n:A}){return`break${this.label?` ${this.label}`:""};`+A}}class d extends s{constructor(A){super(),this.error=A}render({_n:A}){return`throw ${this.error};`+A}get names(){return this.error.names}}class f extends s{constructor(A){super(),this.code=A}render({_n:A}){return`${this.code};`+A}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(A,L){return this.code=E(this.code,A,L),this}get names(){return this.code instanceof e._CodeOrName?this.code.names:{}}}class p extends s{constructor(A=[]){super(),this.nodes=A}render(A){return this.nodes.reduce((L,Q)=>L+Q.render(A),"")}optimizeNodes(){const{nodes:A}=this;let L=A.length;for(;L--;){const Q=A[L].optimizeNodes();Array.isArray(Q)?A.splice(L,1,...Q):Q?A[L]=Q:A.splice(L,1)}return A.length>0?this:void 0}optimizeNames(A,L){const{nodes:Q}=this;let ie=Q.length;for(;ie--;){const Y=Q[ie];Y.optimizeNames(A,L)||(F(A,Y.names),Q.splice(ie,1))}return Q.length>0?this:void 0}get names(){return this.nodes.reduce((A,L)=>D(A,L.names),{})}}class g extends p{render(A){return"{"+A._n+super.render(A)+"}"+A._n}}class y extends p{}class m extends g{}m.kind="else";class v extends g{constructor(A,L){super(L),this.condition=A}render(A){let L=`if(${this.condition})`+super.render(A);return this.else&&(L+="else "+this.else.render(A)),L}optimizeNodes(){super.optimizeNodes();const A=this.condition;if(A===!0)return this.nodes;let L=this.else;if(L){const Q=L.optimizeNodes();L=this.else=Array.isArray(Q)?new m(Q):Q}if(L)return A===!1?L instanceof v?L:L.nodes:this.nodes.length?this:new v(z(A),L instanceof v?[L]:L.nodes);if(!(A===!1||!this.nodes.length))return this}optimizeNames(A,L){var Q;if(this.else=(Q=this.else)===null||Q===void 0?void 0:Q.optimizeNames(A,L),!!(super.optimizeNames(A,L)||this.else))return this.condition=E(this.condition,A,L),this}get names(){const A=super.names;return K(A,this.condition),this.else&&D(A,this.else.names),A}}v.kind="if";class x extends g{}x.kind="for";class b extends x{constructor(A){super(),this.iteration=A}render(A){return`for(${this.iteration})`+super.render(A)}optimizeNames(A,L){if(super.optimizeNames(A,L))return this.iteration=E(this.iteration,A,L),this}get names(){return D(super.names,this.iteration.names)}}class S extends x{constructor(A,L,Q,ie){super(),this.varKind=A,this.name=L,this.from=Q,this.to=ie}render(A){const L=A.es5?r.varKinds.var:this.varKind,{name:Q,from:ie,to:Y}=this;return`for(${L} ${Q}=${ie}; ${Q}<${Y}; ${Q}++)`+super.render(A)}get names(){const A=K(super.names,this.from);return K(A,this.to)}}class C extends x{constructor(A,L,Q,ie){super(),this.loop=A,this.varKind=L,this.name=Q,this.iterable=ie}render(A){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(A)}optimizeNames(A,L){if(super.optimizeNames(A,L))return this.iterable=E(this.iterable,A,L),this}get names(){return D(super.names,this.iterable.names)}}class w extends g{constructor(A,L,Q){super(),this.name=A,this.args=L,this.async=Q}render(A){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(A)}}w.kind="func";class I extends p{render(A){return"return "+super.render(A)}}I.kind="return";class R extends g{render(A){let L="try"+super.render(A);return this.catch&&(L+=this.catch.render(A)),this.finally&&(L+=this.finally.render(A)),L}optimizeNodes(){var A,L;return super.optimizeNodes(),(A=this.catch)===null||A===void 0||A.optimizeNodes(),(L=this.finally)===null||L===void 0||L.optimizeNodes(),this}optimizeNames(A,L){var Q,ie;return super.optimizeNames(A,L),(Q=this.catch)===null||Q===void 0||Q.optimizeNames(A,L),(ie=this.finally)===null||ie===void 0||ie.optimizeNames(A,L),this}get names(){const A=super.names;return this.catch&&D(A,this.catch.names),this.finally&&D(A,this.finally.names),A}}class k extends g{constructor(A){super(),this.error=A}render(A){return`catch(${this.error})`+super.render(A)}}k.kind="catch";class M extends g{render(A){return"finally"+super.render(A)}}M.kind="finally";class N{constructor(A,L={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...L,_n:L.lines?`
|
|
1842
|
+
`,ete=(t,e,r,n)=>t();function tte(t,e=ete){return{getBranchForLoader(r,n){return e(i=>t.request(TQ,r,{...n,...i}),"getBranchForLoader","query",r)},getProject(r,n){return e(i=>t.request(kQ,r,{...n,...i}),"getProject","query",r)},getProjectForLoader(r,n){return e(i=>t.request(AQ,r,{...n,...i}),"getProjectForLoader","query",r)},getRevisionForLoader(r,n){return e(i=>t.request(EQ,r,{...n,...i}),"getRevisionForLoader","query",r)},getRowForLoader(r,n){return e(i=>t.request(PQ,r,{...n,...i}),"getRowForLoader","query",r)},getRowCountForeignKeysToForLoader(r,n){return e(i=>t.request(NQ,r,{...n,...i}),"getRowCountForeignKeysToForLoader","query",r)},ForeignKeysBy(r,n){return e(i=>t.request(MQ,r,{...n,...i}),"ForeignKeysBy","query",r)},ForeignKeysByRows(r,n){return e(i=>t.request(OQ,r,{...n,...i}),"ForeignKeysByRows","query",r)},getTableForLoader(r,n){return e(i=>t.request(DQ,r,{...n,...i}),"getTableForLoader","query",r)},updatePassword(r,n){return e(i=>t.request(FQ,r,{...n,...i}),"updatePassword","mutation",r)},createProject(r,n){return e(i=>t.request(LQ,r,{...n,...i}),"createProject","mutation",r)},findForeignKey(r,n){return e(i=>t.request($Q,r,{...n,...i}),"findForeignKey","query",r)},AdminDashboardStats(r,n){return e(i=>t.request(BQ,r,{...n,...i}),"AdminDashboardStats","query",r)},adminGetUser(r,n){return e(i=>t.request(zQ,r,{...n,...i}),"adminGetUser","query",r)},adminResetPassword(r,n){return e(i=>t.request(VQ,r,{...n,...i}),"adminResetPassword","mutation",r)},adminUsers(r,n){return e(i=>t.request(HQ,r,{...n,...i}),"adminUsers","query",r)},adminUser(r,n){return e(i=>t.request(qQ,r,{...n,...i}),"adminUser","query",r)},assetsTablesData(r,n){return e(i=>t.request(WQ,r,{...n,...i}),"assetsTablesData","query",r)},assetsRowsData(r,n){return e(i=>t.request(GQ,r,{...n,...i}),"assetsRowsData","query",r)},subSchemaItemsData(r,n){return e(i=>t.request(UQ,r,{...n,...i}),"subSchemaItemsData","query",r)},getProjectBranches(r,n){return e(i=>t.request(KQ,r,{...n,...i}),"getProjectBranches","query",r)},deleteBranch(r,n){return e(i=>t.request(ZQ,r,{...n,...i}),"deleteBranch","mutation",r)},getBranchesForSelect(r,n){return e(i=>t.request(YQ,r,{...n,...i}),"getBranchesForSelect","query",r)},getBranchRevisionsForCreate(r,n){return e(i=>t.request(XQ,r,{...n,...i}),"getBranchRevisionsForCreate","query",r)},createBranch(r,n){return e(i=>t.request(JQ,r,{...n,...i}),"createBranch","mutation",r)},GetRevisionChanges(r,n){return e(i=>t.request(QQ,r,{...n,...i}),"GetRevisionChanges","query",r)},GetTableChanges(r,n){return e(i=>t.request(eee,r,{...n,...i}),"GetTableChanges","query",r)},confirmEmailCode(r,n){return e(i=>t.request(tee,r,{...n,...i}),"confirmEmailCode","mutation",r)},getEndpointBranches(r,n){return e(i=>t.request(ree,r,{...n,...i}),"getEndpointBranches","query",r)},getProjectEndpoints(r,n){return e(i=>t.request(nee,r,{...n,...i}),"getProjectEndpoints","query",r)},getBranchRevisions(r,n){return e(i=>t.request(iee,r,{...n,...i}),"getBranchRevisions","query",r)},createEndpoint(r,n){return e(i=>t.request(see,r,{...n,...i}),"createEndpoint","mutation",r)},deleteEndpoint(r,n){return e(i=>t.request(oee,r,{...n,...i}),"deleteEndpoint","mutation",r)},loginGithub(r,n){return e(i=>t.request(aee,r,{...n,...i}),"loginGithub","mutation",r)},loginGoogle(r,n){return e(i=>t.request(lee,r,{...n,...i}),"loginGoogle","mutation",r)},login(r,n){return e(i=>t.request(cee,r,{...n,...i}),"login","mutation",r)},getMigrationBranches(r,n){return e(i=>t.request(uee,r,{...n,...i}),"getMigrationBranches","query",r)},getBranchMigrations(r,n){return e(i=>t.request(hee,r,{...n,...i}),"getBranchMigrations","query",r)},applyMigrations(r,n){return e(i=>t.request(dee,r,{...n,...i}),"applyMigrations","mutation",r)},getMigrations(r,n){return e(i=>t.request(fee,r,{...n,...i}),"getMigrations","query",r)},updateProject(r,n){return e(i=>t.request(pee,r,{...n,...i}),"updateProject","mutation",r)},deleteProjectForSettings(r,n){return e(i=>t.request(gee,r,{...n,...i}),"deleteProjectForSettings","mutation",r)},fetchTableForStack(r,n){return e(i=>t.request(mee,r,{...n,...i}),"fetchTableForStack","query",r)},createTableForStack(r,n){return e(i=>t.request(yee,r,{...n,...i}),"createTableForStack","mutation",r)},updateTableForStack(r,n){return e(i=>t.request(xee,r,{...n,...i}),"updateTableForStack","mutation",r)},renameTableForStack(r,n){return e(i=>t.request(vee,r,{...n,...i}),"renameTableForStack","mutation",r)},rowPageData(r,n){return e(i=>t.request(bee,r,{...n,...i}),"rowPageData","query",r)},signUp(r,n){return e(i=>t.request(wee,r,{...n,...i}),"signUp","mutation",r)},setUsername(r,n){return e(i=>t.request(See,r,{...n,...i}),"setUsername","mutation",r)},getUsersProject(r,n){return e(i=>t.request(Cee,r,{...n,...i}),"getUsersProject","query",r)},searchUsers(r,n){return e(i=>t.request(_ee,r,{...n,...i}),"searchUsers","query",r)},addUserToProject(r,n){return e(i=>t.request(Iee,r,{...n,...i}),"addUserToProject","mutation",r)},removeUserFromProject(r,n){return e(i=>t.request(jee,r,{...n,...i}),"removeUserFromProject","mutation",r)},updateUserProjectRole(r,n){return e(i=>t.request(Ree,r,{...n,...i}),"updateUserProjectRole","mutation",r)},createUser(r,n){return e(i=>t.request(Tee,r,{...n,...i}),"createUser","mutation",r)},configuration(r,n){return e(i=>t.request(kee,r,{...n,...i}),"configuration","query",r)},getMe(r,n){return e(i=>t.request(Aee,r,{...n,...i}),"getMe","query",r)},getProjectGraph(r,n){return e(i=>t.request(Eee,r,{...n,...i}),"getProjectGraph","query",r)},findBranches(r,n){return e(i=>t.request(Pee,r,{...n,...i}),"findBranches","query",r)},findRevisions(r,n){return e(i=>t.request(Nee,r,{...n,...i}),"findRevisions","query",r)},meProjectsList(r,n){return e(i=>t.request(Mee,r,{...n,...i}),"meProjectsList","query",r)},GetRowChanges(r,n){return e(i=>t.request(Oee,r,{...n,...i}),"GetRowChanges","query",r)},GetTableChangesForFilter(r,n){return e(i=>t.request(Dee,r,{...n,...i}),"GetTableChangesForFilter","query",r)},RowListRows(r,n){return e(i=>t.request(Fee,r,{...n,...i}),"RowListRows","query",r)},DeleteRow(r,n){return e(i=>t.request(Lee,r,{...n,...i}),"DeleteRow","mutation",r)},DeleteRows(r,n){return e(i=>t.request($ee,r,{...n,...i}),"DeleteRows","mutation",r)},PatchRowInline(r,n){return e(i=>t.request(Bee,r,{...n,...i}),"PatchRowInline","mutation",r)},GetTableViews(r,n){return e(i=>t.request(zee,r,{...n,...i}),"GetTableViews","query",r)},UpdateTableViews(r,n){return e(i=>t.request(Vee,r,{...n,...i}),"UpdateTableViews","mutation",r)},foreignKeyTableWithRows(r,n){return e(i=>t.request(Hee,r,{...n,...i}),"foreignKeyTableWithRows","query",r)},createRowForStack(r,n){return e(i=>t.request(qee,r,{...n,...i}),"createRowForStack","mutation",r)},updateRowForStack(r,n){return e(i=>t.request(Wee,r,{...n,...i}),"updateRowForStack","mutation",r)},renameRowForStack(r,n){return e(i=>t.request(Gee,r,{...n,...i}),"renameRowForStack","mutation",r)},searchRows(r,n){return e(i=>t.request(Uee,r,{...n,...i}),"searchRows","query",r)},revertChangesForSidebar(r,n){return e(i=>t.request(Kee,r,{...n,...i}),"revertChangesForSidebar","mutation",r)},createRevisionForSidebar(r,n){return e(i=>t.request(Zee,r,{...n,...i}),"createRevisionForSidebar","mutation",r)},createBranchForSidebar(r,n){return e(i=>t.request(Yee,r,{...n,...i}),"createBranchForSidebar","mutation",r)},deleteTableForList(r,n){return e(i=>t.request(Xee,r,{...n,...i}),"deleteTableForList","mutation",r)},tableListData(r,n){return e(i=>t.request(Jee,r,{...n,...i}),"tableListData","query",r)},tableRelationsData(r,n){return e(i=>t.request(Qee,r,{...n,...i}),"tableRelationsData","query",r)}}}const rte={BASE_URL:"/",DEV:!1,GIT_BRANCH_NAME:"HEAD",GIT_COMMIT_HASH:"37bdb06",MODE:"production",PACKAGE_VERSION:"2.4.0",PROD:!0,REACT_APP_ENDPOINT_HOST:"",REACT_APP_ENDPOINT_PORT:"",REACT_APP_ENDPOINT_SERVER_URL:"/endpoint",REACT_APP_GRAPHQL_SERVER_URL:"/graphql",REACT_APP_SWAGGER_SERVER_URL:"/api",SSR:!1};class wg{constructor(){}get(e){const r=globalThis.__env__?.[e],n=rte[e];return r||n}}$.register(wg,()=>new wg,{scope:"singleton"});const Qt=({hideSidebar:t,sidebar:e,title:r,actions:n,children:i,footer:s})=>a.jsxs(P,{minHeight:"100vh",children:[!t&&a.jsxs(P,{borderRight:"1px solid",borderRightColor:"newGray.100",flexDirection:"column",justifyContent:e?"space-between":"flex-end",padding:"16px",width:"288px",minWidth:"288px",flexShrink:0,height:"100vh",top:0,position:"sticky",children:[e,s&&a.jsx(T,{alignSelf:"center",mt:"1rem",children:s})]}),a.jsxs(P,{alignItems:"center",flex:1,flexDirection:"column",width:"100%",children:[(r||n)&&a.jsxs(P,{alignItems:"center",backgroundColor:"white",borderBottom:"1px solid",borderBottomColor:"gray.50",justifyContent:"space-between",maxWidth:"900px",padding:"8px",width:"100%",position:"sticky",zIndex:1,top:0,children:[r,n]}),a.jsx(P,{flex:1,flexDirection:"column",maxWidth:"900px",padding:"1rem 1rem 0rem 1rem",width:"100%",children:i})]})]}),Ii=({height:t="2.5rem",title:e,onClick:r,disabled:n,isSelected:i,isLoading:s,icon:o,dataTestId:l})=>a.jsx(be,{"data-testid":l,_hover:{color:"gray.400",backgroundColor:"white"},_disabled:i?{backgroundColor:"gray.50",cursor:"not-allowed"}:void 0,alignSelf:"flex-start",color:"gray.300",fontWeight:"500",fontSize:16,height:t,disabled:n||i,loading:s,variant:"ghost",onClick:r,children:a.jsxs(P,{alignItems:"center",gap:"0.5rem",children:[o&&a.jsx(T,{fontSize:"sm",children:o}),a.jsx(j,{children:e})]})}),c6=t=>a.jsx(Ii,{...t,icon:a.jsx(Ah,{})}),r0=({height:t="2.5rem",loading:e,isDisabled:r,onClick:n,title:i,dataTestId:s})=>a.jsxs(be,{"data-testid":s,_hover:{backgroundColor:"gray.50"},alignSelf:"flex-start",color:"gray.400",height:t,loading:e,disabled:r,variant:"ghost",onClick:n,width:"48px",children:[a.jsx(He,{size:"sm",mr:i?8:0,children:a.jsx(Gw,{})}),i]}),u6=({height:t="2.5rem",onClick:e,disabled:r,dataTestId:n})=>a.jsx(be,{"data-testid":n,disabled:r,_hover:{backgroundColor:"gray.50"},alignSelf:"flex-start",color:"gray.400",height:t,variant:"ghost",onClick:e,width:"48px",children:a.jsx(He,{size:"md",children:a.jsx(jc,{})})}),h6=({dataTestId:t,...e})=>a.jsx(lt,{"data-testid":t,_hover:{backgroundColor:"gray.100"},color:"gray.400",variant:"ghost",size:"lg",width:"40px",height:"40px",...e,children:a.jsx(YE,{})}),Xs=({value:t,placeholder:e,autoFocus:r,onChange:n,onBlur:i,onEnter:s,width:o,height:l,type:c,dataTestId:u,autoComplete:h})=>{const d=YX();return a.jsx(Ot,{autoComplete:h,"data-testid":u,borderColor:"gray.100",padding:"0 9px",placeholder:e,ref:r?d:void 0,value:t,variant:"outline",onChange:n,onBlur:i,width:o,height:l,type:c,onKeyDown:s?f=>{f.key==="Enter"&&s()}:void 0})},yt=PA({placement:"top",pauseOnPageIdle:!0,duration:1500}),mp=PA({placement:"bottom",pauseOnPageIdle:!0,duration:1500}),k2=t=>a.jsxs(Z8,{width:{md:"sm"},children:[t.type==="loading"?a.jsx(vt,{size:"sm",color:"blue.solid"}):a.jsx(Y8,{}),a.jsxs(NA,{gap:"1",flex:"1",maxWidth:"100%",children:[t.title&&a.jsx(X8,{children:t.title}),t.description&&a.jsx(J8,{color:"gray.500",children:t.description})]}),t.action&&a.jsx(Q8,{children:t.action.label}),t.closable&&a.jsx(eL,{})]}),A2=()=>a.jsxs(je,{children:[a.jsx(i_,{toaster:yt,insetInline:{mdDown:"4"},children:t=>a.jsx(k2,{...t})}),a.jsx(i_,{toaster:mp,insetInline:{mdDown:"4"},children:t=>a.jsx(k2,{...t})})]}),ir=_.forwardRef(function(e,r){const{showArrow:n,children:i,disabled:s,portalled:o=!0,content:l,contentProps:c,portalRef:u,...h}=e;return s?i:a.jsxs(bA,{...h,children:[a.jsx(wA,{asChild:!0,children:i}),a.jsx(je,{disabled:!o,container:u,children:a.jsx(SA,{children:a.jsxs(CA,{ref:r,...c,children:[n&&a.jsx(_A,{children:a.jsx(IA,{})}),l]})})})]})});var $d={exports:{}},Yy={},$s={},sa={},Xy={},Jy={},Qy={},E2;function Sg(){return E2||(E2=1,(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.regexpCode=t.getEsmExportName=t.getProperty=t.safeStringify=t.stringify=t.strConcat=t.addCodeArg=t.str=t._=t.nil=t._Code=t.Name=t.IDENTIFIER=t._CodeOrName=void 0;class e{}t._CodeOrName=e,t.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;class r extends e{constructor(x){if(super(),!t.IDENTIFIER.test(x))throw new Error("CodeGen: name must be a valid identifier");this.str=x}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}}t.Name=r;class n extends e{constructor(x){super(),this._items=typeof x=="string"?[x]:x}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;const x=this._items[0];return x===""||x==='""'}get str(){var x;return(x=this._str)!==null&&x!==void 0?x:this._str=this._items.reduce((b,S)=>`${b}${S}`,"")}get names(){var x;return(x=this._names)!==null&&x!==void 0?x:this._names=this._items.reduce((b,S)=>(S instanceof r&&(b[S.str]=(b[S.str]||0)+1),b),{})}}t._Code=n,t.nil=new n("");function i(v,...x){const b=[v[0]];let S=0;for(;S<x.length;)l(b,x[S]),b.push(v[++S]);return new n(b)}t._=i;const s=new n("+");function o(v,...x){const b=[p(v[0])];let S=0;for(;S<x.length;)b.push(s),l(b,x[S]),b.push(s,p(v[++S]));return c(b),new n(b)}t.str=o;function l(v,x){x instanceof n?v.push(...x._items):x instanceof r?v.push(x):v.push(d(x))}t.addCodeArg=l;function c(v){let x=1;for(;x<v.length-1;){if(v[x]===s){const b=u(v[x-1],v[x+1]);if(b!==void 0){v.splice(x-1,3,b);continue}v[x++]="+"}x++}}function u(v,x){if(x==='""')return v;if(v==='""')return x;if(typeof v=="string")return x instanceof r||v[v.length-1]!=='"'?void 0:typeof x!="string"?`${v.slice(0,-1)}${x}"`:x[0]==='"'?v.slice(0,-1)+x.slice(1):void 0;if(typeof x=="string"&&x[0]==='"'&&!(v instanceof r))return`"${v}${x.slice(1)}`}function h(v,x){return x.emptyStr()?v:v.emptyStr()?x:o`${v}${x}`}t.strConcat=h;function d(v){return typeof v=="number"||typeof v=="boolean"||v===null?v:p(Array.isArray(v)?v.join(","):v)}function f(v){return new n(p(v))}t.stringify=f;function p(v){return JSON.stringify(v).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}t.safeStringify=p;function g(v){return typeof v=="string"&&t.IDENTIFIER.test(v)?new n(`.${v}`):i`[${v}]`}t.getProperty=g;function y(v){if(typeof v=="string"&&t.IDENTIFIER.test(v))return new n(`${v}`);throw new Error(`CodeGen: invalid export name: ${v}, use explicit $id name mapping`)}t.getEsmExportName=y;function m(v){return new n(v.toString())}t.regexpCode=m})(Qy)),Qy}var ex={},P2;function N2(){return P2||(P2=1,(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.ValueScope=t.ValueScopeName=t.Scope=t.varKinds=t.UsedValueState=void 0;const e=Sg();class r extends Error{constructor(u){super(`CodeGen: "code" for ${u} not defined`),this.value=u.value}}var n;(function(c){c[c.Started=0]="Started",c[c.Completed=1]="Completed"})(n||(t.UsedValueState=n={})),t.varKinds={const:new e.Name("const"),let:new e.Name("let"),var:new e.Name("var")};class i{constructor({prefixes:u,parent:h}={}){this._names={},this._prefixes=u,this._parent=h}toName(u){return u instanceof e.Name?u:this.name(u)}name(u){return new e.Name(this._newName(u))}_newName(u){const h=this._names[u]||this._nameGroup(u);return`${u}${h.index++}`}_nameGroup(u){var h,d;if(!((d=(h=this._parent)===null||h===void 0?void 0:h._prefixes)===null||d===void 0)&&d.has(u)||this._prefixes&&!this._prefixes.has(u))throw new Error(`CodeGen: prefix "${u}" is not allowed in this scope`);return this._names[u]={prefix:u,index:0}}}t.Scope=i;class s extends e.Name{constructor(u,h){super(h),this.prefix=u}setValue(u,{property:h,itemIndex:d}){this.value=u,this.scopePath=(0,e._)`.${new e.Name(h)}[${d}]`}}t.ValueScopeName=s;const o=(0,e._)`\n`;class l extends i{constructor(u){super(u),this._values={},this._scope=u.scope,this.opts={...u,_n:u.lines?o:e.nil}}get(){return this._scope}name(u){return new s(u,this._newName(u))}value(u,h){var d;if(h.ref===void 0)throw new Error("CodeGen: ref must be passed in value");const f=this.toName(u),{prefix:p}=f,g=(d=h.key)!==null&&d!==void 0?d:h.ref;let y=this._values[p];if(y){const x=y.get(g);if(x)return x}else y=this._values[p]=new Map;y.set(g,f);const m=this._scope[p]||(this._scope[p]=[]),v=m.length;return m[v]=h.ref,f.setValue(h,{property:p,itemIndex:v}),f}getValue(u,h){const d=this._values[u];if(d)return d.get(h)}scopeRefs(u,h=this._values){return this._reduceValues(h,d=>{if(d.scopePath===void 0)throw new Error(`CodeGen: name "${d}" has no value`);return(0,e._)`${u}${d.scopePath}`})}scopeCode(u=this._values,h,d){return this._reduceValues(u,f=>{if(f.value===void 0)throw new Error(`CodeGen: name "${f}" has no value`);return f.value.code},h,d)}_reduceValues(u,h,d={},f){let p=e.nil;for(const g in u){const y=u[g];if(!y)continue;const m=d[g]=d[g]||new Map;y.forEach(v=>{if(m.has(v))return;m.set(v,n.Started);let x=h(v);if(x){const b=this.opts.es5?t.varKinds.var:t.varKinds.const;p=(0,e._)`${p}${b} ${v} = ${x};${this.opts._n}`}else if(x=f?.(v))p=(0,e._)`${p}${x}${this.opts._n}`;else throw new r(v);m.set(v,n.Completed)})}return p}}t.ValueScope=l})(ex)),ex}var M2;function Ye(){return M2||(M2=1,(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.or=t.and=t.not=t.CodeGen=t.operators=t.varKinds=t.ValueScopeName=t.ValueScope=t.Scope=t.Name=t.regexpCode=t.stringify=t.getProperty=t.nil=t.strConcat=t.str=t._=void 0;const e=Sg(),r=N2();var n=Sg();Object.defineProperty(t,"_",{enumerable:!0,get:function(){return n._}}),Object.defineProperty(t,"str",{enumerable:!0,get:function(){return n.str}}),Object.defineProperty(t,"strConcat",{enumerable:!0,get:function(){return n.strConcat}}),Object.defineProperty(t,"nil",{enumerable:!0,get:function(){return n.nil}}),Object.defineProperty(t,"getProperty",{enumerable:!0,get:function(){return n.getProperty}}),Object.defineProperty(t,"stringify",{enumerable:!0,get:function(){return n.stringify}}),Object.defineProperty(t,"regexpCode",{enumerable:!0,get:function(){return n.regexpCode}}),Object.defineProperty(t,"Name",{enumerable:!0,get:function(){return n.Name}});var i=N2();Object.defineProperty(t,"Scope",{enumerable:!0,get:function(){return i.Scope}}),Object.defineProperty(t,"ValueScope",{enumerable:!0,get:function(){return i.ValueScope}}),Object.defineProperty(t,"ValueScopeName",{enumerable:!0,get:function(){return i.ValueScopeName}}),Object.defineProperty(t,"varKinds",{enumerable:!0,get:function(){return i.varKinds}}),t.operators={GT:new e._Code(">"),GTE:new e._Code(">="),LT:new e._Code("<"),LTE:new e._Code("<="),EQ:new e._Code("==="),NEQ:new e._Code("!=="),NOT:new e._Code("!"),OR:new e._Code("||"),AND:new e._Code("&&"),ADD:new e._Code("+")};class s{optimizeNodes(){return this}optimizeNames(A,L){return this}}class o extends s{constructor(A,L,Q){super(),this.varKind=A,this.name=L,this.rhs=Q}render({es5:A,_n:L}){const Q=A?r.varKinds.var:this.varKind,ie=this.rhs===void 0?"":` = ${this.rhs}`;return`${Q} ${this.name}${ie};`+L}optimizeNames(A,L){if(A[this.name.str])return this.rhs&&(this.rhs=E(this.rhs,A,L)),this}get names(){return this.rhs instanceof e._CodeOrName?this.rhs.names:{}}}class l extends s{constructor(A,L,Q){super(),this.lhs=A,this.rhs=L,this.sideEffects=Q}render({_n:A}){return`${this.lhs} = ${this.rhs};`+A}optimizeNames(A,L){if(!(this.lhs instanceof e.Name&&!A[this.lhs.str]&&!this.sideEffects))return this.rhs=E(this.rhs,A,L),this}get names(){const A=this.lhs instanceof e.Name?{}:{...this.lhs.names};return K(A,this.rhs)}}class c extends l{constructor(A,L,Q,ie){super(A,Q,ie),this.op=L}render({_n:A}){return`${this.lhs} ${this.op}= ${this.rhs};`+A}}class u extends s{constructor(A){super(),this.label=A,this.names={}}render({_n:A}){return`${this.label}:`+A}}class h extends s{constructor(A){super(),this.label=A,this.names={}}render({_n:A}){return`break${this.label?` ${this.label}`:""};`+A}}class d extends s{constructor(A){super(),this.error=A}render({_n:A}){return`throw ${this.error};`+A}get names(){return this.error.names}}class f extends s{constructor(A){super(),this.code=A}render({_n:A}){return`${this.code};`+A}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(A,L){return this.code=E(this.code,A,L),this}get names(){return this.code instanceof e._CodeOrName?this.code.names:{}}}class p extends s{constructor(A=[]){super(),this.nodes=A}render(A){return this.nodes.reduce((L,Q)=>L+Q.render(A),"")}optimizeNodes(){const{nodes:A}=this;let L=A.length;for(;L--;){const Q=A[L].optimizeNodes();Array.isArray(Q)?A.splice(L,1,...Q):Q?A[L]=Q:A.splice(L,1)}return A.length>0?this:void 0}optimizeNames(A,L){const{nodes:Q}=this;let ie=Q.length;for(;ie--;){const Y=Q[ie];Y.optimizeNames(A,L)||(F(A,Y.names),Q.splice(ie,1))}return Q.length>0?this:void 0}get names(){return this.nodes.reduce((A,L)=>D(A,L.names),{})}}class g extends p{render(A){return"{"+A._n+super.render(A)+"}"+A._n}}class y extends p{}class m extends g{}m.kind="else";class v extends g{constructor(A,L){super(L),this.condition=A}render(A){let L=`if(${this.condition})`+super.render(A);return this.else&&(L+="else "+this.else.render(A)),L}optimizeNodes(){super.optimizeNodes();const A=this.condition;if(A===!0)return this.nodes;let L=this.else;if(L){const Q=L.optimizeNodes();L=this.else=Array.isArray(Q)?new m(Q):Q}if(L)return A===!1?L instanceof v?L:L.nodes:this.nodes.length?this:new v(z(A),L instanceof v?[L]:L.nodes);if(!(A===!1||!this.nodes.length))return this}optimizeNames(A,L){var Q;if(this.else=(Q=this.else)===null||Q===void 0?void 0:Q.optimizeNames(A,L),!!(super.optimizeNames(A,L)||this.else))return this.condition=E(this.condition,A,L),this}get names(){const A=super.names;return K(A,this.condition),this.else&&D(A,this.else.names),A}}v.kind="if";class x extends g{}x.kind="for";class b extends x{constructor(A){super(),this.iteration=A}render(A){return`for(${this.iteration})`+super.render(A)}optimizeNames(A,L){if(super.optimizeNames(A,L))return this.iteration=E(this.iteration,A,L),this}get names(){return D(super.names,this.iteration.names)}}class S extends x{constructor(A,L,Q,ie){super(),this.varKind=A,this.name=L,this.from=Q,this.to=ie}render(A){const L=A.es5?r.varKinds.var:this.varKind,{name:Q,from:ie,to:Y}=this;return`for(${L} ${Q}=${ie}; ${Q}<${Y}; ${Q}++)`+super.render(A)}get names(){const A=K(super.names,this.from);return K(A,this.to)}}class C extends x{constructor(A,L,Q,ie){super(),this.loop=A,this.varKind=L,this.name=Q,this.iterable=ie}render(A){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(A)}optimizeNames(A,L){if(super.optimizeNames(A,L))return this.iterable=E(this.iterable,A,L),this}get names(){return D(super.names,this.iterable.names)}}class w extends g{constructor(A,L,Q){super(),this.name=A,this.args=L,this.async=Q}render(A){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(A)}}w.kind="func";class I extends p{render(A){return"return "+super.render(A)}}I.kind="return";class R extends g{render(A){let L="try"+super.render(A);return this.catch&&(L+=this.catch.render(A)),this.finally&&(L+=this.finally.render(A)),L}optimizeNodes(){var A,L;return super.optimizeNodes(),(A=this.catch)===null||A===void 0||A.optimizeNodes(),(L=this.finally)===null||L===void 0||L.optimizeNodes(),this}optimizeNames(A,L){var Q,ie;return super.optimizeNames(A,L),(Q=this.catch)===null||Q===void 0||Q.optimizeNames(A,L),(ie=this.finally)===null||ie===void 0||ie.optimizeNames(A,L),this}get names(){const A=super.names;return this.catch&&D(A,this.catch.names),this.finally&&D(A,this.finally.names),A}}class k extends g{constructor(A){super(),this.error=A}render(A){return`catch(${this.error})`+super.render(A)}}k.kind="catch";class M extends g{render(A){return"finally"+super.render(A)}}M.kind="finally";class N{constructor(A,L={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...L,_n:L.lines?`
|
|
1843
1843
|
`:""},this._extScope=A,this._scope=new r.Scope({parent:A}),this._nodes=[new y]}toString(){return this._root.render(this.opts)}name(A){return this._scope.name(A)}scopeName(A){return this._extScope.name(A)}scopeValue(A,L){const Q=this._extScope.value(A,L);return(this._values[Q.prefix]||(this._values[Q.prefix]=new Set)).add(Q),Q}getScopeValue(A,L){return this._extScope.getValue(A,L)}scopeRefs(A){return this._extScope.scopeRefs(A,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(A,L,Q,ie){const Y=this._scope.toName(L);return Q!==void 0&&ie&&(this._constants[Y.str]=Q),this._leafNode(new o(A,Y,Q)),Y}const(A,L,Q){return this._def(r.varKinds.const,A,L,Q)}let(A,L,Q){return this._def(r.varKinds.let,A,L,Q)}var(A,L,Q){return this._def(r.varKinds.var,A,L,Q)}assign(A,L,Q){return this._leafNode(new l(A,L,Q))}add(A,L){return this._leafNode(new c(A,t.operators.ADD,L))}code(A){return typeof A=="function"?A():A!==e.nil&&this._leafNode(new f(A)),this}object(...A){const L=["{"];for(const[Q,ie]of A)L.length>1&&L.push(","),L.push(Q),(Q!==ie||this.opts.es5)&&(L.push(":"),(0,e.addCodeArg)(L,ie));return L.push("}"),new e._Code(L)}if(A,L,Q){if(this._blockNode(new v(A)),L&&Q)this.code(L).else().code(Q).endIf();else if(L)this.code(L).endIf();else if(Q)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(A){return this._elseNode(new v(A))}else(){return this._elseNode(new m)}endIf(){return this._endBlockNode(v,m)}_for(A,L){return this._blockNode(A),L&&this.code(L).endFor(),this}for(A,L){return this._for(new b(A),L)}forRange(A,L,Q,ie,Y=this.opts.es5?r.varKinds.var:r.varKinds.let){const ae=this._scope.toName(A);return this._for(new S(Y,ae,L,Q),()=>ie(ae))}forOf(A,L,Q,ie=r.varKinds.const){const Y=this._scope.toName(A);if(this.opts.es5){const ae=L instanceof e.Name?L:this.var("_arr",L);return this.forRange("_i",0,(0,e._)`${ae}.length`,pe=>{this.var(Y,(0,e._)`${ae}[${pe}]`),Q(Y)})}return this._for(new C("of",ie,Y,L),()=>Q(Y))}forIn(A,L,Q,ie=this.opts.es5?r.varKinds.var:r.varKinds.const){if(this.opts.ownProperties)return this.forOf(A,(0,e._)`Object.keys(${L})`,Q);const Y=this._scope.toName(A);return this._for(new C("in",ie,Y,L),()=>Q(Y))}endFor(){return this._endBlockNode(x)}label(A){return this._leafNode(new u(A))}break(A){return this._leafNode(new h(A))}return(A){const L=new I;if(this._blockNode(L),this.code(A),L.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(I)}try(A,L,Q){if(!L&&!Q)throw new Error('CodeGen: "try" without "catch" and "finally"');const ie=new R;if(this._blockNode(ie),this.code(A),L){const Y=this.name("e");this._currNode=ie.catch=new k(Y),L(Y)}return Q&&(this._currNode=ie.finally=new M,this.code(Q)),this._endBlockNode(k,M)}throw(A){return this._leafNode(new d(A))}block(A,L){return this._blockStarts.push(this._nodes.length),A&&this.code(A).endBlock(L),this}endBlock(A){const L=this._blockStarts.pop();if(L===void 0)throw new Error("CodeGen: not in self-balancing block");const Q=this._nodes.length-L;if(Q<0||A!==void 0&&Q!==A)throw new Error(`CodeGen: wrong number of nodes: ${Q} vs ${A} expected`);return this._nodes.length=L,this}func(A,L=e.nil,Q,ie){return this._blockNode(new w(A,L,Q)),ie&&this.code(ie).endFunc(),this}endFunc(){return this._endBlockNode(w)}optimize(A=1){for(;A-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(A){return this._currNode.nodes.push(A),this}_blockNode(A){this._currNode.nodes.push(A),this._nodes.push(A)}_endBlockNode(A,L){const Q=this._currNode;if(Q instanceof A||L&&Q instanceof L)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${L?`${A.kind}/${L.kind}`:A.kind}"`)}_elseNode(A){const L=this._currNode;if(!(L instanceof v))throw new Error('CodeGen: "else" without "if"');return this._currNode=L.else=A,this}get _root(){return this._nodes[0]}get _currNode(){const A=this._nodes;return A[A.length-1]}set _currNode(A){const L=this._nodes;L[L.length-1]=A}}t.CodeGen=N;function D(q,A){for(const L in A)q[L]=(q[L]||0)+(A[L]||0);return q}function K(q,A){return A instanceof e._CodeOrName?D(q,A.names):q}function E(q,A,L){if(q instanceof e.Name)return Q(q);if(!ie(q))return q;return new e._Code(q._items.reduce((Y,ae)=>(ae instanceof e.Name&&(ae=Q(ae)),ae instanceof e._Code?Y.push(...ae._items):Y.push(ae),Y),[]));function Q(Y){const ae=L[Y.str];return ae===void 0||A[Y.str]!==1?Y:(delete A[Y.str],ae)}function ie(Y){return Y instanceof e._Code&&Y._items.some(ae=>ae instanceof e.Name&&A[ae.str]===1&&L[ae.str]!==void 0)}}function F(q,A){for(const L in A)q[L]=(q[L]||0)-(A[L]||0)}function z(q){return typeof q=="boolean"||typeof q=="number"||q===null?!q:(0,e._)`!${U(q)}`}t.not=z;const V=O(t.operators.AND);function H(...q){return q.reduce(V)}t.and=H;const J=O(t.operators.OR);function W(...q){return q.reduce(J)}t.or=W;function O(q){return(A,L)=>A===e.nil?L:L===e.nil?A:(0,e._)`${U(A)} ${q} ${U(L)}`}function U(q){return q instanceof e.Name?q:(0,e._)`(${q})`}})(Jy)),Jy}var Je={},O2;function ut(){if(O2)return Je;O2=1,Object.defineProperty(Je,"__esModule",{value:!0}),Je.checkStrictMode=Je.getErrorPath=Je.Type=Je.useFunc=Je.setEvaluated=Je.evaluatedPropsToName=Je.mergeEvaluated=Je.eachItem=Je.unescapeJsonPointer=Je.escapeJsonPointer=Je.escapeFragment=Je.unescapeFragment=Je.schemaRefOrVal=Je.schemaHasRulesButRef=Je.schemaHasRules=Je.checkUnknownRules=Je.alwaysValidSchema=Je.toHash=void 0;const t=Ye(),e=Sg();function r(C){const w={};for(const I of C)w[I]=!0;return w}Je.toHash=r;function n(C,w){return typeof w=="boolean"?w:Object.keys(w).length===0?!0:(i(C,w),!s(w,C.self.RULES.all))}Je.alwaysValidSchema=n;function i(C,w=C.schema){const{opts:I,self:R}=C;if(!I.strictSchema||typeof w=="boolean")return;const k=R.RULES.keywords;for(const M in w)k[M]||S(C,`unknown keyword: "${M}"`)}Je.checkUnknownRules=i;function s(C,w){if(typeof C=="boolean")return!C;for(const I in C)if(w[I])return!0;return!1}Je.schemaHasRules=s;function o(C,w){if(typeof C=="boolean")return!C;for(const I in C)if(I!=="$ref"&&w.all[I])return!0;return!1}Je.schemaHasRulesButRef=o;function l({topSchemaRef:C,schemaPath:w},I,R,k){if(!k){if(typeof I=="number"||typeof I=="boolean")return I;if(typeof I=="string")return(0,t._)`${I}`}return(0,t._)`${C}${w}${(0,t.getProperty)(R)}`}Je.schemaRefOrVal=l;function c(C){return d(decodeURIComponent(C))}Je.unescapeFragment=c;function u(C){return encodeURIComponent(h(C))}Je.escapeFragment=u;function h(C){return typeof C=="number"?`${C}`:C.replace(/~/g,"~0").replace(/\//g,"~1")}Je.escapeJsonPointer=h;function d(C){return C.replace(/~1/g,"/").replace(/~0/g,"~")}Je.unescapeJsonPointer=d;function f(C,w){if(Array.isArray(C))for(const I of C)w(I);else w(C)}Je.eachItem=f;function p({mergeNames:C,mergeToName:w,mergeValues:I,resultToName:R}){return(k,M,N,D)=>{const K=N===void 0?M:N instanceof t.Name?(M instanceof t.Name?C(k,M,N):w(k,M,N),N):M instanceof t.Name?(w(k,N,M),M):I(M,N);return D===t.Name&&!(K instanceof t.Name)?R(k,K):K}}Je.mergeEvaluated={props:p({mergeNames:(C,w,I)=>C.if((0,t._)`${I} !== true && ${w} !== undefined`,()=>{C.if((0,t._)`${w} === true`,()=>C.assign(I,!0),()=>C.assign(I,(0,t._)`${I} || {}`).code((0,t._)`Object.assign(${I}, ${w})`))}),mergeToName:(C,w,I)=>C.if((0,t._)`${I} !== true`,()=>{w===!0?C.assign(I,!0):(C.assign(I,(0,t._)`${I} || {}`),y(C,I,w))}),mergeValues:(C,w)=>C===!0?!0:{...C,...w},resultToName:g}),items:p({mergeNames:(C,w,I)=>C.if((0,t._)`${I} !== true && ${w} !== undefined`,()=>C.assign(I,(0,t._)`${w} === true ? true : ${I} > ${w} ? ${I} : ${w}`)),mergeToName:(C,w,I)=>C.if((0,t._)`${I} !== true`,()=>C.assign(I,w===!0?!0:(0,t._)`${I} > ${w} ? ${I} : ${w}`)),mergeValues:(C,w)=>C===!0?!0:Math.max(C,w),resultToName:(C,w)=>C.var("items",w)})};function g(C,w){if(w===!0)return C.var("props",!0);const I=C.var("props",(0,t._)`{}`);return w!==void 0&&y(C,I,w),I}Je.evaluatedPropsToName=g;function y(C,w,I){Object.keys(I).forEach(R=>C.assign((0,t._)`${w}${(0,t.getProperty)(R)}`,!0))}Je.setEvaluated=y;const m={};function v(C,w){return C.scopeValue("func",{ref:w,code:m[w.code]||(m[w.code]=new e._Code(w.code))})}Je.useFunc=v;var x;(function(C){C[C.Num=0]="Num",C[C.Str=1]="Str"})(x||(Je.Type=x={}));function b(C,w,I){if(C instanceof t.Name){const R=w===x.Num;return I?R?(0,t._)`"[" + ${C} + "]"`:(0,t._)`"['" + ${C} + "']"`:R?(0,t._)`"/" + ${C}`:(0,t._)`"/" + ${C}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return I?(0,t.getProperty)(C).toString():"/"+h(C)}Je.getErrorPath=b;function S(C,w,I=C.opts.strictSchema){if(I){if(w=`strict mode: ${w}`,I===!0)throw new Error(w);C.self.logger.warn(w)}}return Je.checkStrictMode=S,Je}var Bd={},D2;function ns(){if(D2)return Bd;D2=1,Object.defineProperty(Bd,"__esModule",{value:!0});const t=Ye(),e={data:new t.Name("data"),valCxt:new t.Name("valCxt"),instancePath:new t.Name("instancePath"),parentData:new t.Name("parentData"),parentDataProperty:new t.Name("parentDataProperty"),rootData:new t.Name("rootData"),dynamicAnchors:new t.Name("dynamicAnchors"),vErrors:new t.Name("vErrors"),errors:new t.Name("errors"),this:new t.Name("this"),self:new t.Name("self"),scope:new t.Name("scope"),json:new t.Name("json"),jsonPos:new t.Name("jsonPos"),jsonLen:new t.Name("jsonLen"),jsonPart:new t.Name("jsonPart")};return Bd.default=e,Bd}var F2;function n0(){return F2||(F2=1,(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.extendErrors=t.resetErrorsCount=t.reportExtraError=t.reportError=t.keyword$DataError=t.keywordError=void 0;const e=Ye(),r=ut(),n=ns();t.keywordError={message:({keyword:m})=>(0,e.str)`must pass "${m}" keyword validation`},t.keyword$DataError={message:({keyword:m,schemaType:v})=>v?(0,e.str)`"${m}" keyword must be ${v} ($data)`:(0,e.str)`"${m}" keyword is invalid ($data)`};function i(m,v=t.keywordError,x,b){const{it:S}=m,{gen:C,compositeRule:w,allErrors:I}=S,R=d(m,v,x);b??(w||I)?c(C,R):u(S,(0,e._)`[${R}]`)}t.reportError=i;function s(m,v=t.keywordError,x){const{it:b}=m,{gen:S,compositeRule:C,allErrors:w}=b,I=d(m,v,x);c(S,I),C||w||u(b,n.default.vErrors)}t.reportExtraError=s;function o(m,v){m.assign(n.default.errors,v),m.if((0,e._)`${n.default.vErrors} !== null`,()=>m.if(v,()=>m.assign((0,e._)`${n.default.vErrors}.length`,v),()=>m.assign(n.default.vErrors,null)))}t.resetErrorsCount=o;function l({gen:m,keyword:v,schemaValue:x,data:b,errsCount:S,it:C}){if(S===void 0)throw new Error("ajv implementation error");const w=m.name("err");m.forRange("i",S,n.default.errors,I=>{m.const(w,(0,e._)`${n.default.vErrors}[${I}]`),m.if((0,e._)`${w}.instancePath === undefined`,()=>m.assign((0,e._)`${w}.instancePath`,(0,e.strConcat)(n.default.instancePath,C.errorPath))),m.assign((0,e._)`${w}.schemaPath`,(0,e.str)`${C.errSchemaPath}/${v}`),C.opts.verbose&&(m.assign((0,e._)`${w}.schema`,x),m.assign((0,e._)`${w}.data`,b))})}t.extendErrors=l;function c(m,v){const x=m.const("err",v);m.if((0,e._)`${n.default.vErrors} === null`,()=>m.assign(n.default.vErrors,(0,e._)`[${x}]`),(0,e._)`${n.default.vErrors}.push(${x})`),m.code((0,e._)`${n.default.errors}++`)}function u(m,v){const{gen:x,validateName:b,schemaEnv:S}=m;S.$async?x.throw((0,e._)`new ${m.ValidationError}(${v})`):(x.assign((0,e._)`${b}.errors`,v),x.return(!1))}const h={keyword:new e.Name("keyword"),schemaPath:new e.Name("schemaPath"),params:new e.Name("params"),propertyName:new e.Name("propertyName"),message:new e.Name("message"),schema:new e.Name("schema"),parentSchema:new e.Name("parentSchema")};function d(m,v,x){const{createErrors:b}=m.it;return b===!1?(0,e._)`{}`:f(m,v,x)}function f(m,v,x={}){const{gen:b,it:S}=m,C=[p(S,x),g(m,x)];return y(m,v,C),b.object(...C)}function p({errorPath:m},{instancePath:v}){const x=v?(0,e.str)`${m}${(0,r.getErrorPath)(v,r.Type.Str)}`:m;return[n.default.instancePath,(0,e.strConcat)(n.default.instancePath,x)]}function g({keyword:m,it:{errSchemaPath:v}},{schemaPath:x,parentSchema:b}){let S=b?v:(0,e.str)`${v}/${m}`;return x&&(S=(0,e.str)`${S}${(0,r.getErrorPath)(x,r.Type.Str)}`),[h.schemaPath,S]}function y(m,{params:v,message:x},b){const{keyword:S,data:C,schemaValue:w,it:I}=m,{opts:R,propertyName:k,topSchemaRef:M,schemaPath:N}=I;b.push([h.keyword,S],[h.params,typeof v=="function"?v(m):v||(0,e._)`{}`]),R.messages&&b.push([h.message,typeof x=="function"?x(m):x]),R.verbose&&b.push([h.schema,w],[h.parentSchema,(0,e._)`${M}${N}`],[n.default.data,C]),k&&b.push([h.propertyName,k])}})(Xy)),Xy}var L2;function nte(){if(L2)return sa;L2=1,Object.defineProperty(sa,"__esModule",{value:!0}),sa.boolOrEmptySchema=sa.topBoolOrEmptySchema=void 0;const t=n0(),e=Ye(),r=ns(),n={message:"boolean schema is false"};function i(l){const{gen:c,schema:u,validateName:h}=l;u===!1?o(l,!1):typeof u=="object"&&u.$async===!0?c.return(r.default.data):(c.assign((0,e._)`${h}.errors`,null),c.return(!0))}sa.topBoolOrEmptySchema=i;function s(l,c){const{gen:u,schema:h}=l;h===!1?(u.var(c,!1),o(l)):u.var(c,!0)}sa.boolOrEmptySchema=s;function o(l,c){const{gen:u,data:h}=l,d={gen:u,keyword:"false schema",data:h,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:l};(0,t.reportError)(d,n,void 0,c)}return sa}var Br={},oa={},$2;function d6(){if($2)return oa;$2=1,Object.defineProperty(oa,"__esModule",{value:!0}),oa.getRules=oa.isJSONType=void 0;const t=["string","number","integer","boolean","null","object","array"],e=new Set(t);function r(i){return typeof i=="string"&&e.has(i)}oa.isJSONType=r;function n(){const i={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...i,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},i.number,i.string,i.array,i.object],post:{rules:[]},all:{},keywords:{}}}return oa.getRules=n,oa}var Bs={},B2;function f6(){if(B2)return Bs;B2=1,Object.defineProperty(Bs,"__esModule",{value:!0}),Bs.shouldUseRule=Bs.shouldUseGroup=Bs.schemaHasRulesForType=void 0;function t({schema:n,self:i},s){const o=i.RULES.types[s];return o&&o!==!0&&e(n,o)}Bs.schemaHasRulesForType=t;function e(n,i){return i.rules.some(s=>r(n,s))}Bs.shouldUseGroup=e;function r(n,i){var s;return n[i.keyword]!==void 0||((s=i.definition.implements)===null||s===void 0?void 0:s.some(o=>n[o]!==void 0))}return Bs.shouldUseRule=r,Bs}var z2;function Cg(){if(z2)return Br;z2=1,Object.defineProperty(Br,"__esModule",{value:!0}),Br.reportTypeError=Br.checkDataTypes=Br.checkDataType=Br.coerceAndCheckDataType=Br.getJSONTypes=Br.getSchemaTypes=Br.DataType=void 0;const t=d6(),e=f6(),r=n0(),n=Ye(),i=ut();var s;(function(x){x[x.Correct=0]="Correct",x[x.Wrong=1]="Wrong"})(s||(Br.DataType=s={}));function o(x){const b=l(x.type);if(b.includes("null")){if(x.nullable===!1)throw new Error("type: null contradicts nullable: false")}else{if(!b.length&&x.nullable!==void 0)throw new Error('"nullable" cannot be used without "type"');x.nullable===!0&&b.push("null")}return b}Br.getSchemaTypes=o;function l(x){const b=Array.isArray(x)?x:x?[x]:[];if(b.every(t.isJSONType))return b;throw new Error("type must be JSONType or JSONType[]: "+b.join(","))}Br.getJSONTypes=l;function c(x,b){const{gen:S,data:C,opts:w}=x,I=h(b,w.coerceTypes),R=b.length>0&&!(I.length===0&&b.length===1&&(0,e.schemaHasRulesForType)(x,b[0]));if(R){const k=g(b,C,w.strictNumbers,s.Wrong);S.if(k,()=>{I.length?d(x,b,I):m(x)})}return R}Br.coerceAndCheckDataType=c;const u=new Set(["string","number","integer","boolean","null"]);function h(x,b){return b?x.filter(S=>u.has(S)||b==="array"&&S==="array"):[]}function d(x,b,S){const{gen:C,data:w,opts:I}=x,R=C.let("dataType",(0,n._)`typeof ${w}`),k=C.let("coerced",(0,n._)`undefined`);I.coerceTypes==="array"&&C.if((0,n._)`${R} == 'object' && Array.isArray(${w}) && ${w}.length == 1`,()=>C.assign(w,(0,n._)`${w}[0]`).assign(R,(0,n._)`typeof ${w}`).if(g(b,w,I.strictNumbers),()=>C.assign(k,w))),C.if((0,n._)`${k} !== undefined`);for(const N of S)(u.has(N)||N==="array"&&I.coerceTypes==="array")&&M(N);C.else(),m(x),C.endIf(),C.if((0,n._)`${k} !== undefined`,()=>{C.assign(w,k),f(x,k)});function M(N){switch(N){case"string":C.elseIf((0,n._)`${R} == "number" || ${R} == "boolean"`).assign(k,(0,n._)`"" + ${w}`).elseIf((0,n._)`${w} === null`).assign(k,(0,n._)`""`);return;case"number":C.elseIf((0,n._)`${R} == "boolean" || ${w} === null
|
|
1844
1844
|
|| (${R} == "string" && ${w} && ${w} == +${w})`).assign(k,(0,n._)`+${w}`);return;case"integer":C.elseIf((0,n._)`${R} === "boolean" || ${w} === null
|
|
1845
1845
|
|| (${R} === "string" && ${w} && ${w} == +${w} && !(${w} % 1))`).assign(k,(0,n._)`+${w}`);return;case"boolean":C.elseIf((0,n._)`${w} === "false" || ${w} === 0 || ${w} === null`).assign(k,!1).elseIf((0,n._)`${w} === "true" || ${w} === 1`).assign(k,!0);return;case"null":C.elseIf((0,n._)`${w} === "" || ${w} === 0 || ${w} === false`),C.assign(k,null);return;case"array":C.elseIf((0,n._)`${R} === "string" || ${R} === "number"
|
package/dist/index.html
CHANGED
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
opacity: 1;
|
|
22
22
|
}
|
|
23
23
|
</style>
|
|
24
|
-
<script type="module" crossorigin src="/assets/index-
|
|
24
|
+
<script type="module" crossorigin src="/assets/index-Bm4gz4e7.js"></script>
|
|
25
25
|
<link rel="modulepreload" crossorigin href="/assets/vendor-chakra-81WUgB9u.js">
|
|
26
26
|
<link rel="modulepreload" crossorigin href="/assets/vendor-mobx-RTHsWS6u.js">
|
|
27
27
|
<link rel="modulepreload" crossorigin href="/assets/vendor-react-B-wSUMrZ.js">
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@revisium/admin",
|
|
3
|
-
"version": "2.4.0
|
|
3
|
+
"version": "2.4.0",
|
|
4
4
|
"description": "Revisium is a tool (UI/API) inspired by JSON (JSON Schema) and Git, designed to provide a flexible and low-level headless CMS solution.",
|
|
5
5
|
"private": false,
|
|
6
6
|
"homepage": "https://revisium.io",
|