@revisium/admin 2.7.0-alpha.1 → 2.7.0-alpha.2

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.
@@ -379,7 +379,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
379
379
  `?(KR(e),e.i++):n===`\r`&&e.i+1<t.length&&t[e.i+1]===`
380
380
  `?(KR(e),e.i+=2):(e.currentField+=n,e.i++)}function JR(e){if(e.length===0)return[];let t={rows:[],currentRow:[],currentField:``,inQuotes:!1,i:0};for(;t.i<e.length;)t.inQuotes?GR(t,e):qR(t,e);return t.currentRow.push(t.currentField),WR(t.currentRow)&&t.rows.push(t.currentRow),t.rows}function YR(e){return e.includes(` `)||e.includes(`
381
381
  `)||e.includes(`"`)?`"${e.replaceAll(`"`,`""`)}"`:e}function XR(e,t,n){let r=[];for(let i=e.startRow;i<=e.endRow;i++){let a=[];for(let r=e.startCol;r<=e.endCol;r++){let e=t[i],o=n[r];e&&o&&a.push(YR(e.getCellVM(o).displayValue))}r.push(a.join(` `))}try{return navigator.clipboard.writeText(r.join(`
382
- `))}catch{return Promise.resolve()}}async function ZR(e,t,n,r){let i;try{i=await navigator.clipboard.readText()}catch{return}let a=JR(i);for(let[i,o]of a.entries()){let a=n[e+i];if(!a)break;for(let[e,n]of o.entries()){let i=r[t+e];if(!i)break;let o=a.getCellVM(i);o.isEditable&&o.applyPastedText(n)}}}function QR(e,t,n){let r=e.focusedCell;if(!r)return null;let i=t.findIndex(e=>e.field===r.field),a=n.findIndex(e=>e.rowId===r.rowId);return i===-1||a===-1?null:{colIndex:i,rowIndex:a}}function $R(e,t,n){for(let r=e.startRow;r<=e.endRow;r++)for(let i=e.startCol;i<=e.endCol;i++){let e=t[r],a=n[i];e&&a&&e.getCellVM(a).clearToDefault()}}var ez=`#ededed`,tz=`inset 0 -1px 0 0 ${ez}`;function nz(){return{"&::after":{content:`""`,position:`absolute`,top:0,bottom:0,width:`8px`,left:`-8px`,pointerEvents:`none`,transition:`opacity 0.15s`,opacity:`var(--shadow-right-opacity, 0)`,boxShadow:`inset -8px 0 12px -8px rgba(0,0,0,0.1)`}}}function rz(e,t){return t<=0?e:e===`0px`?`${t}px`:`calc(${e} + ${t}px)`}var iz=40,az=g(({field:e,columnsModel:t})=>{let[n,r]=(0,L.useState)(!1),i=(0,L.useRef)(0),a=(0,L.useRef)(0),o=(0,L.useRef)(0),s=(0,L.useRef)(null);return(0,L.useEffect)(()=>()=>{s.current&&s.current()},[]),(0,I.jsx)(A,{role:`separator`,position:`absolute`,right:`-4px`,top:0,bottom:0,width:`8px`,cursor:`col-resize`,zIndex:10,onMouseDown:(0,L.useCallback)(n=>{n.preventDefault(),n.stopPropagation();let c=t.resolveColumnWidth(e);i.current=n.clientX,a.current=c,r(!0),document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`;let l=n=>{cancelAnimationFrame(o.current),o.current=requestAnimationFrame(()=>{let r=n.clientX-i.current,o=Math.max(iz,a.current+r);t.setColumnWidth(e,o)})},u=()=>{cancelAnimationFrame(o.current),t.commitColumnWidth(),r(!1),document.body.style.cursor=``,document.body.style.userSelect=``,document.removeEventListener(`mousemove`,l),document.removeEventListener(`mouseup`,d),s.current=null},d=()=>{u()};s.current=u,document.addEventListener(`mousemove`,l),document.addEventListener(`mouseup`,d)},[e,t]),"data-testid":`resize-${e}`,children:(0,I.jsx)(A,{position:`absolute`,left:`3px`,top:0,bottom:0,width:`2px`,bg:n?`blue.500`:`transparent`,_groupHover:{bg:`blue.500`},transition:`background 0.1s`})})}),oz=g(({field:e,sortModel:t})=>{let n=t.getSortDirection(e),r=t.getSortIndex(e),i=t.sortCount>1;return n?(0,I.jsxs)(j,{alignItems:`center`,gap:`1px`,color:`blue.500`,fontSize:`xs`,flexShrink:0,"data-testid":`sort-indicator-${e}`,children:[n===`asc`?(0,I.jsx)(uk,{size:12}):(0,I.jsx)(ak,{size:12}),i&&r!==null&&(0,I.jsx)(A,{as:`span`,fontSize:`10px`,fontWeight:`medium`,lineHeight:1,children:r})]}):null}),sz=g(({field:e,columnsModel:t})=>t.isPinned(e)?(0,I.jsx)(j,{alignItems:`center`,color:`gray.400`,flexShrink:0,"data-testid":`pin-indicator-${e}`,children:(0,I.jsx)(Ck,{size:12})}):null),cz=g(({field:e,filterModel:t})=>t.hasFilterForField(e)?(0,I.jsx)(j,{alignItems:`center`,color:`gray.400`,flexShrink:0,"data-testid":`filter-indicator-${e}`,children:(0,I.jsx)(yk,{size:12})}):null),lz=({column:e})=>e.hasFormula?(0,I.jsx)(j,{alignItems:`center`,color:`gray.400`,flexShrink:0,"data-testid":`formula-indicator-${e.field}`,children:(0,I.jsx)(Yf,{size:12})}):null,uz=g(({field:e,sortModel:t})=>{let n=t.getSortDirection(e),r=t.isSorted(e);return(0,I.jsxs)(en,{positioning:{placement:`right-start`,gutter:2},lazyMount:!0,unmountOnExit:!0,children:[(0,I.jsxs)(nn,{children:[(0,I.jsx)(k,{flex:1,children:`Sort`}),(0,I.jsx)(mk,{})]}),(0,I.jsx)(R,{children:(0,I.jsx)(Ot,{children:(0,I.jsxs)(v,{minW:`160px`,children:[(0,I.jsxs)(gt,{value:`sort-asc`,onClick:()=>{t.setSingleSort(e,`asc`)},color:n===`asc`?`blue.600`:void 0,children:[(0,I.jsx)(ck,{}),(0,I.jsx)(k,{children:`Sort A → Z`})]}),(0,I.jsxs)(gt,{value:`sort-desc`,onClick:()=>{t.setSingleSort(e,`desc`)},color:n===`desc`?`blue.600`:void 0,children:[(0,I.jsx)(ik,{}),(0,I.jsx)(k,{children:`Sort Z → A`})]}),r&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(dt,{}),(0,I.jsxs)(gt,{value:`remove-sort`,onClick:()=>{t.removeSort(e)},children:[(0,I.jsx)(Dk,{}),(0,I.jsx)(k,{children:`Remove sort`})]})]})]})})})]})}),dz=g(({field:e,columnsModel:t})=>{let n=t.canMoveLeft(e),r=t.canMoveRight(e),i=t.canMoveToStart(e),a=t.canMoveToEnd(e);return!n&&!r?null:(0,I.jsxs)(en,{positioning:{placement:`right-start`,gutter:2},lazyMount:!0,unmountOnExit:!0,children:[(0,I.jsxs)(nn,{children:[(0,I.jsx)(k,{flex:1,children:`Move column`}),(0,I.jsx)(mk,{})]}),(0,I.jsx)(R,{children:(0,I.jsx)(Ot,{children:(0,I.jsxs)(v,{minW:`160px`,children:[n&&(0,I.jsxs)(gt,{value:`move-left`,onClick:()=>t.moveColumnLeft(e),children:[(0,I.jsx)(pk,{}),(0,I.jsx)(k,{children:`Move left`})]}),i&&(0,I.jsxs)(gt,{value:`move-to-start`,onClick:()=>t.moveColumnToStart(e),children:[(0,I.jsx)(ok,{}),(0,I.jsx)(k,{children:`Move to start`})]}),r&&(0,I.jsxs)(gt,{value:`move-right`,onClick:()=>t.moveColumnRight(e),children:[(0,I.jsx)(mk,{}),(0,I.jsx)(k,{children:`Move right`})]}),a&&(0,I.jsxs)(gt,{value:`move-to-end`,onClick:()=>t.moveColumnToEnd(e),children:[(0,I.jsx)(sk,{}),(0,I.jsx)(k,{children:`Move to end`})]})]})})})]})}),fz=(0,L.memo)(({field:e,name:t,fieldType:n,valuePrefix:r,onClick:i})=>(0,I.jsx)(gt,{value:r?`${r}-${e}`:e,onClick:()=>i(e),children:(0,I.jsxs)(A,{display:`flex`,alignItems:`center`,gap:2,width:`100%`,children:[(0,I.jsx)(A,{as:`span`,fontSize:`xs`,fontWeight:`medium`,color:`gray.400`,fontFamily:`mono`,minWidth:`20px`,children:sL(n)}),(0,I.jsx)(k,{truncate:!0,children:t||`(unnamed)`})]})})),pz=({group:e,parentVisible:t,valuePrefix:n,onClick:r})=>e.children.length===0&&!t?(0,I.jsx)(fz,{field:e.parent.field,name:e.parent.label,fieldType:e.parent.fieldType,valuePrefix:n,onClick:r}):(0,I.jsxs)(en,{positioning:{placement:`right-start`,gutter:2},lazyMount:!0,unmountOnExit:!0,children:[(0,I.jsxs)(nn,{"data-testid":`file-group-${e.parent.field}`,children:[(0,I.jsxs)(A,{display:`flex`,alignItems:`center`,gap:2,flex:1,children:[(0,I.jsx)(A,{as:`span`,fontSize:`xs`,fontWeight:`medium`,color:`gray.400`,fontFamily:`mono`,minWidth:`20px`,children:sL(e.parent.fieldType)}),(0,I.jsx)(k,{truncate:!0,children:e.parent.label})]}),(0,I.jsx)(mk,{})]}),(0,I.jsx)(R,{children:(0,I.jsx)(Ot,{children:(0,I.jsxs)(v,{maxH:`300px`,minW:`200px`,overflowY:`auto`,children:[!t&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(fz,{field:e.parent.field,name:e.parent.label,fieldType:e.parent.fieldType,valuePrefix:n,onClick:r}),(0,I.jsx)(dt,{})]}),e.children.map(e=>(0,I.jsx)(fz,{field:e.field,name:e.label,fieldType:e.fieldType,valuePrefix:n,onClick:r},e.field))]})})})]}),mz=({label:e,valuePrefix:t,availableFields:n,allColumns:r,onSelect:i})=>{if(n.length===0)return null;let a=EI(n,r);return(0,I.jsxs)(en,{positioning:{placement:`right-start`,gutter:2},lazyMount:!0,unmountOnExit:!0,children:[(0,I.jsxs)(nn,{children:[(0,I.jsx)(k,{flex:1,children:e}),(0,I.jsx)(mk,{})]}),(0,I.jsx)(R,{children:(0,I.jsx)(Ot,{children:(0,I.jsx)(v,{maxH:`300px`,minW:`200px`,overflowY:`auto`,children:a.map(e=>TI(e)?(0,I.jsx)(pz,{group:e,parentVisible:e.parentVisible,valuePrefix:t,onClick:i},e.parent.field):(0,I.jsx)(fz,{field:e.field,name:e.label,fieldType:e.fieldType,valuePrefix:t,onClick:i},e.field))})})})]})},hz=g(({column:e,columnsModel:t,sortModel:n,filterModel:r,onCopyPath:i,onClose:a})=>{let o=t.canRemoveColumn,s=t.availableFieldsToInsert,c=s.length>0,l=t.canMoveLeft(e.field)||t.canMoveRight(e.field),u=t.isPinned(e.field),d=t.canPinLeft(e.field),f=t.canPinRight(e.field);return(0,I.jsxs)(v,{minW:`180px`,children:[n&&e.isSortable&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(uz,{field:e.field,sortModel:n}),(0,I.jsx)(dt,{})]}),r&&e.isSortable&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(gt,{value:`add-filter`,onClick:()=>{r&&(r.addConditionForField(e.field),r.setOpen(!0))},children:[(0,I.jsx)(yk,{}),(0,I.jsx)(k,{children:`Add filter`})]}),(0,I.jsx)(dt,{})]}),u?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(gt,{value:`unpin`,onClick:()=>{t.unpin(e.field)},children:[(0,I.jsx)(Sk,{}),(0,I.jsx)(k,{children:`Unpin column`})]}),(0,I.jsx)(dt,{})]}):(0,I.jsxs)(I.Fragment,{children:[d&&(0,I.jsxs)(gt,{value:`pin-left`,onClick:()=>{t.pinLeft(e.field)},children:[(0,I.jsx)(Ck,{}),(0,I.jsx)(k,{children:`Pin to left`})]}),f&&(0,I.jsxs)(gt,{value:`pin-right`,onClick:()=>{t.pinRight(e.field)},children:[(0,I.jsx)(Ck,{}),(0,I.jsx)(k,{children:`Pin to right`})]}),(d||f)&&(0,I.jsx)(dt,{})]}),l&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(dz,{field:e.field,columnsModel:t}),(0,I.jsx)(dt,{})]}),c&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(mz,{label:`Insert before`,valuePrefix:`before`,availableFields:s,allColumns:t.allColumns,onSelect:n=>{t.insertColumnBefore(e.field,n),a?.()}}),(0,I.jsx)(mz,{label:`Insert after`,valuePrefix:`after`,availableFields:s,allColumns:t.allColumns,onSelect:n=>{t.insertColumnAfter(e.field,n),a?.()}}),(0,I.jsx)(dt,{})]}),(0,I.jsxs)(gt,{value:`hide`,disabled:!o,onClick:()=>{t.hideColumn(e.field)},children:[(0,I.jsx)(dne,{}),(0,I.jsx)(k,{children:`Hide column`})]}),(0,I.jsxs)(gt,{value:`hide-all`,disabled:!o,onClick:t.hideAll,children:[(0,I.jsx)(Qf,{}),(0,I.jsx)(k,{children:`Hide all columns`})]}),(0,I.jsx)(dt,{}),(0,I.jsxs)(gt,{value:`copy-path`,onClick:()=>{i?i(e.field):navigator.clipboard.writeText(e.field).catch(()=>{})},children:[(0,I.jsx)(vk,{}),(0,I.jsx)(k,{children:`Copy path`})]})]})});function gz(e){return{"&::after":{content:`""`,position:`absolute`,top:0,bottom:0,width:`8px`,pointerEvents:`none`,transition:`opacity 0.15s`,opacity:e.side===`left`?`var(--shadow-left-opacity, 0)`:`var(--shadow-right-opacity, 0)`,...e.side===`left`?{right:`-8px`,boxShadow:`inset 8px 0 12px -8px rgba(0,0,0,0.1)`}:{left:`-8px`,boxShadow:`inset -8px 0 12px -8px rgba(0,0,0,0.1)`}}}}function _z(e){return e?`${tz}, ${e.side===`left`?`inset -1px 0 0 0 ${ez}`:`inset 1px 0 0 0 ${ez}`}`:tz}var vz=g(({column:e,columnsModel:t,sortModel:n,filterModel:r,onCopyPath:i,stickyPosition:a})=>{let[o,s]=(0,L.useState)(!1),c=t.columnWidthCssVar(e.field),l=!!a;return(0,I.jsxs)(A,{as:`th`,position:l?`sticky`:`relative`,left:a?.side===`left`?a.offsetCss:void 0,right:a?.side===`right`?a.offsetCss:void 0,zIndex:l?2:void 0,width:c,minWidth:c,maxWidth:c,height:`inherit`,bg:`white`,boxShadow:_z(a),textAlign:`left`,fontWeight:`normal`,p:0,css:a?.isBoundary?gz(a):void 0,children:[(0,I.jsxs)(en,{positioning:{placement:`bottom-end`},lazyMount:!0,unmountOnExit:!0,open:o,onOpenChange:e=>s(e.open),children:[(0,I.jsx)(Lt,{asChild:!0,children:(0,I.jsxs)(j,{alignItems:`center`,height:`100%`,pl:`8px`,pr:`16px`,gap:`4px`,cursor:`pointer`,transition:`background 0.15s`,overflow:`hidden`,_hover:{bg:`gray.100`},"data-testid":`header-${e.field}`,children:[(0,I.jsx)(j,{alignItems:`center`,justifyContent:`center`,flexShrink:0,fontSize:`xs`,color:`gray.400`,width:`16px`,children:sL(e.fieldType)}),(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`500`,color:`gray.400`,whiteSpace:`nowrap`,textOverflow:`ellipsis`,overflow:`hidden`,flex:1,minWidth:0,textDecoration:e.isDeprecated?`line-through`:void 0,children:e.label}),(0,I.jsx)(lz,{column:e}),(0,I.jsx)(sz,{field:e.field,columnsModel:t}),r&&e.isSortable&&(0,I.jsx)(cz,{field:e.field,filterModel:r}),n&&e.isSortable&&(0,I.jsx)(oz,{field:e.field,sortModel:n})]})}),(0,I.jsx)(R,{children:(0,I.jsx)(Ot,{children:(0,I.jsx)(hz,{column:e,columnsModel:t,sortModel:n,filterModel:r,onCopyPath:i,onClose:()=>s(!1)})})})]}),(0,I.jsx)(az,{field:e.field,columnsModel:t})]})}),yz=g(({columnsModel:e})=>{let t=e.availableFieldsToAdd,n=e.availableSystemFieldsToAdd;if(!e.hasHiddenColumns)return null;let r=EI(t,e.allColumns);return(0,I.jsx)(j,{alignItems:`center`,px:`4px`,height:`100%`,children:(0,I.jsxs)(en,{positioning:{placement:`bottom-start`},lazyMount:!0,unmountOnExit:!0,children:[(0,I.jsx)(Lt,{asChild:!0,children:(0,I.jsx)(Ze,{"aria-label":`Add column`,size:`xs`,variant:`ghost`,color:`gray.400`,_hover:{bg:`gray.100`,color:`gray.600`},focusRing:`none`,"data-testid":`add-column-button`,children:(0,I.jsx)(ep,{})})}),(0,I.jsx)(R,{children:(0,I.jsx)(Ot,{children:(0,I.jsxs)(v,{minW:`200px`,maxH:`340px`,overflowY:`auto`,children:[(0,I.jsxs)(gt,{value:`add-all`,onClick:e.addAll,children:[(0,I.jsx)(Qf,{}),(0,I.jsx)(k,{children:`Add all columns`})]}),r.length>0&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(dt,{}),(0,I.jsxs)(tn,{children:[(0,I.jsx)(Ut,{fontWeight:`medium`,color:`gray.500`,fontSize:`xs`,children:`Data fields`}),r.map(t=>TI(t)?(0,I.jsx)(pz,{group:t,parentVisible:t.parentVisible,onClick:e.showColumn},t.parent.field):(0,I.jsx)(fz,{field:t.field,name:t.label,fieldType:t.fieldType,onClick:e.showColumn},t.field))]})]}),n.length>0&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(dt,{}),(0,I.jsxs)(tn,{children:[(0,I.jsx)(Ut,{fontWeight:`medium`,color:`gray.500`,fontSize:`xs`,children:`System fields`}),n.map(t=>(0,I.jsx)(fz,{field:t.field,name:t.label,fieldType:t.fieldType,onClick:e.showColumn},t.field))]})]})]})})})]})})}),bz=40,xz=40,Sz=g(({columnsModel:e,sortModel:t,filterModel:n,onCopyPath:r,showSelection:i})=>{let a=i?bz:0,o=e.hasHiddenColumns;return(0,I.jsxs)(A,{as:`tr`,height:`40px`,children:[i&&(0,I.jsx)(A,{as:`th`,width:`40px`,minWidth:`40px`,maxWidth:`40px`,bg:`white`,p:0,position:`sticky`,left:0,zIndex:2,boxShadow:tz}),e.visibleColumns.map(i=>(0,I.jsx)(vz,{column:i,columnsModel:e,sortModel:t,filterModel:n,onCopyPath:r,stickyPosition:Cz(i.field,e,a,o)},i.field)),o?(0,I.jsx)(A,{as:`th`,width:`100%`,minWidth:`${xz}px`,bg:`white`,p:0,position:`sticky`,right:0,zIndex:2,boxShadow:tz,css:e.pinnedRightCount===0?nz():void 0,children:(0,I.jsx)(yz,{columnsModel:e})}):(0,I.jsx)(A,{as:`th`,width:`100%`,bg:`white`,p:0,boxShadow:tz})]})});function Cz(e,t,n,r){let i=t.getColumnStickyLeftCss(e,n);if(i!==void 0)return{side:`left`,offsetCss:i,isBoundary:t.isStickyLeftBoundary(e)};let a=t.getColumnStickyRightCss(e);if(a!==void 0)return{side:`right`,offsetCss:rz(a,r?xz:0),isBoundary:t.isStickyRightBoundary(e)}}var wz=({rowId:e,testIdPrefix:t,onSelect:n,onDuplicate:r,onDelete:i})=>(0,I.jsxs)(I.Fragment,{children:[n&&(0,I.jsxs)(gt,{value:`select`,onClick:()=>n(e),"data-testid":`${t}-select-${e}`,children:[(0,I.jsx)(Kf,{}),(0,I.jsx)(k,{children:`Select`})]}),r&&(0,I.jsxs)(gt,{value:`duplicate`,onClick:()=>r(e),"data-testid":`${t}-duplicate-${e}`,children:[(0,I.jsx)(vk,{}),(0,I.jsx)(k,{children:`Duplicate`})]}),i&&(0,I.jsxs)(I.Fragment,{children:[(n||r)&&(0,I.jsx)(dt,{}),(0,I.jsxs)(gt,{value:`delete`,onClick:()=>i(e),"data-testid":`${t}-delete-${e}`,children:[(0,I.jsx)(Ek,{}),(0,I.jsx)(k,{color:`red.600`,children:`Delete`})]})]})]}),Tz=({rowId:e,onOpen:t,onPick:n,onSelect:r,onDuplicate:i,onDelete:a})=>{let[o,s]=(0,L.useState)(!1),c=n??t,l=n?Kf:df,u=n?`row-action-pick-${e}`:`row-action-open-${e}`,d=!!(t||r||i||a);return(0,I.jsx)(j,{position:`absolute`,right:`8px`,top:`50%`,transform:`translateY(-50%)`,alignItems:`center`,className:`row-action-buttons`,"data-menu-open":o||void 0,"data-testid":`row-action-buttons-${e}`,children:(0,I.jsxs)(j,{alignItems:`center`,height:`24px`,borderRadius:`6px`,bg:`white`,boxShadow:`0px 2px 8px rgba(0,0,0,0.16)`,overflow:`hidden`,"data-testid":`row-action-split-${e}`,children:[c&&(0,I.jsx)(j,{alignItems:`center`,justifyContent:`center`,height:`100%`,width:`28px`,minWidth:`28px`,cursor:`pointer`,_hover:{bg:`gray.100`},onClick:t=>{t.stopPropagation(),c(e)},"data-testid":u,children:(0,I.jsx)(Ve,{boxSize:`20px`,color:`gray.400`,as:l})}),d&&(0,I.jsxs)(en,{lazyMount:!0,unmountOnExit:!0,onOpenChange:({open:e})=>s(e),positioning:{placement:`bottom-start`},children:[(0,I.jsx)(Lt,{asChild:!0,children:(0,I.jsx)(j,{alignItems:`center`,justifyContent:`center`,height:`100%`,width:`18px`,minWidth:`18px`,cursor:`pointer`,borderLeft:c?`1px solid`:void 0,borderColor:`gray.100`,_hover:{bg:`gray.100`},onClick:e=>e.stopPropagation(),"data-testid":`row-action-trigger-${e}`,children:(0,I.jsx)(Ve,{as:nf,boxSize:`16px`,color:`gray.300`})})}),(0,I.jsx)(R,{children:(0,I.jsx)(Ot,{children:(0,I.jsxs)(v,{minW:`180px`,"data-testid":`row-action-menu-${e}`,children:[t&&(0,I.jsxs)(gt,{value:`open`,onClick:()=>t(e),"data-testid":`row-action-menu-open-${e}`,children:[(0,I.jsx)(df,{}),(0,I.jsx)(k,{children:`Open`})]}),t&&(r||i||a)&&(0,I.jsx)(dt,{}),(0,I.jsx)(wz,{rowId:e,testIdPrefix:`row-action`,onSelect:r,onDuplicate:i,onDelete:a})]})})})]})]})})},Ez=({rowId:e,isSelected:t,onToggleSelection:n})=>(0,I.jsx)(A,{as:`td`,width:`40px`,minWidth:`40px`,maxWidth:`40px`,p:0,position:`sticky`,left:0,zIndex:1,bg:`white`,boxShadow:`inset 0 -1px 0 0 ${ez}, inset -1px 0 0 0 ${ez}`,children:(0,I.jsx)(j,{alignItems:`center`,justifyContent:`center`,height:`100%`,children:(0,I.jsxs)(Ne,{checked:t,onCheckedChange:()=>n(),size:`sm`,"data-testid":`select-${e}`,children:[(0,I.jsx)($e,{}),(0,I.jsx)(Ye,{})]})})}),Dz=40,Oz=40;function kz(e){return{"&::after":{content:`""`,position:`absolute`,top:0,bottom:0,width:`8px`,pointerEvents:`none`,transition:`opacity 0.15s`,opacity:e===`left`?`var(--shadow-left-opacity, 0)`:`var(--shadow-right-opacity, 0)`,...e===`left`?{right:`-8px`,boxShadow:`inset 8px 0 12px -8px rgba(0,0,0,0.1)`}:{left:`-8px`,boxShadow:`inset -8px 0 12px -8px rgba(0,0,0,0.1)`}}}}function Az(e,t,n,r){let i=r&&n,a=i?{"& .row-action-buttons":{opacity:0},"&:hover .row-action-buttons, & .row-action-buttons[data-menu-open]":{opacity:1,transition:`opacity 0.15s ease`}}:{};if(e)return{...a,...kz(t)};if(i)return a}function jz(e,t,n,r){let i=t.getColumnStickyLeftCss(e.field,n),a=t.getColumnStickyRightCss(e.field),o=i!==void 0,s=a!==void 0,c=o||s,l=t.isStickyLeftBoundary(e.field),u=t.isStickyRightBoundary(e.field),d=s&&a!==void 0?rz(a,r):a;return{isSticky:c,isBoundary:l||u,boundarySide:o?`left`:`right`,leftCss:o?i:void 0,rightCss:s?d:void 0,colWidth:c?t.columnWidthCssVar(e.field):void 0}}function Mz(e,t){return e?`${tz}, ${t===`left`?`inset -1px 0 0 0 ${ez}`:`inset 1px 0 0 0 ${ez}`}`:tz}var Nz=g(({row:e,columnsModel:t,showSelection:n,onSearchForeignKey:r,onUploadFile:i,onOpenFile:a,onOpenRow:o,onPickRow:s,onSelectRow:c,onDuplicateRow:l,onDeleteRow:u})=>{let d=!!(o||s||c||l||u),f=n?Dz:0,p=t.hasHiddenColumns,m=p?Oz:0;return(0,I.jsxs)(I.Fragment,{children:[n&&(0,I.jsx)(Ez,{rowId:e.rowId,isSelected:e.isSelected,onToggleSelection:()=>e.toggleSelection()}),t.visibleColumns.map((n,p)=>{let h=e.getCellVM(n),g=p===0,_=g&&d&&!h.isEditing,v=jz(n,t,f,m);return(0,I.jsxs)(A,{as:`td`,width:v.colWidth,minWidth:v.colWidth,maxWidth:v.isSticky?v.colWidth:`0`,overflow:v.isBoundary?`visible`:`hidden`,borderRight:v.isSticky?void 0:`1px solid`,borderColor:v.isSticky?void 0:ez,p:0,position:v.isSticky?`sticky`:`relative`,left:v.leftCss,right:v.rightCss,zIndex:v.isSticky?1:void 0,bg:v.isSticky?`white`:void 0,boxShadow:Mz(v.isSticky,v.boundarySide),css:Az(v.isBoundary,v.boundarySide,d,g),children:[v.isBoundary?(0,I.jsx)(A,{overflow:`hidden`,children:(0,I.jsx)(UR,{cell:h,onSearchForeignKey:r,onUploadFile:i,onOpenFile:a})}):(0,I.jsx)(UR,{cell:h,onSearchForeignKey:r,onUploadFile:i,onOpenFile:a}),_&&(0,I.jsx)(Tz,{rowId:e.rowId,onOpen:o,onPick:s,onSelect:c,onDuplicate:l,onDelete:u})]},n.field)}),p?(0,I.jsx)(A,{as:`td`,width:`100%`,minWidth:`${Oz}px`,p:0,position:`sticky`,right:0,zIndex:1,bg:`white`,boxShadow:tz,css:t.pinnedRightCount===0?nz():void 0}):(0,I.jsx)(A,{as:`td`,width:`100%`,p:0,boxShadow:tz})]})}),Pz=g(({selection:e,allRowIds:t,onDuplicate:n,onDelete:r})=>{let i=e.isAllSelected(t);return(0,I.jsx)(tee,{open:e.isSelectionMode,children:(0,I.jsx)(R,{children:(0,I.jsx)(vt,{zIndex:5,children:(0,I.jsxs)(pt,{"data-testid":`selection-toolbar`,children:[(0,I.jsxs)(zt,{children:[e.selectedCount,` selected`]}),(0,I.jsx)(wt,{}),!i&&(0,I.jsxs)(N,{variant:`outline`,size:`sm`,onClick:()=>e.selectAll(t),"data-testid":`select-all`,children:[(0,I.jsx)(Kf,{}),`Select all`]}),n&&(0,I.jsxs)(N,{variant:`outline`,size:`sm`,onClick:()=>n(e.selectedIds),"data-testid":`duplicate-selected`,children:[(0,I.jsx)(vk,{}),`Duplicate`]}),r&&(0,I.jsxs)(N,{variant:`outline`,size:`sm`,onClick:()=>r(e.selectedIds),"data-testid":`delete-selected`,children:[(0,I.jsx)(Ek,{}),`Delete`]}),(0,I.jsx)(iee,{asChild:!0,children:(0,I.jsx)(N,{variant:`ghost`,size:`sm`,"aria-label":`Exit selection`,onClick:()=>e.exitSelectionMode(),"data-testid":`exit-selection`,children:(0,I.jsx)(ip,{})})})]})})})})}),Fz=({isOpen:e,onClose:t,onConfirm:n,count:r})=>{let i=(0,L.useRef)(null),a=r&&r>1?`Are you sure you want to delete ${r} rows?`:`Are you sure you want to delete this row?`;return(0,I.jsx)(Ue,{open:e,onOpenChange:({open:e})=>{e||t()},initialFocusEl:()=>i.current,role:`alertdialog`,children:(0,I.jsxs)(R,{children:[(0,I.jsx)(pe,{}),(0,I.jsx)(ue,{children:(0,I.jsxs)(_n,{maxWidth:`400px`,"data-testid":`delete-confirm-dialog`,children:[(0,I.jsx)(Ge,{children:(0,I.jsx)(qe,{children:`Delete confirmation`})}),(0,I.jsx)(be,{children:(0,I.jsx)(k,{children:a})}),(0,I.jsx)(w,{children:(0,I.jsxs)(j,{gap:2,children:[(0,I.jsx)(N,{ref:i,variant:`outline`,size:`sm`,onClick:t,"data-testid":`delete-cancel`,children:`Cancel`}),(0,I.jsx)(N,{colorPalette:`red`,size:`sm`,onClick:n,"data-testid":`delete-confirm`,children:`Delete`})]})})]})})]})})},Iz=({style:e,children:t,...n})=>(0,I.jsx)(`table`,{...n,style:{...e,width:`max-content`,minWidth:`100%`,tableLayout:`fixed`,borderCollapse:`separate`,borderSpacing:0},children:t}),Lz=({"data-index":e,context:t,style:n,children:r,...i})=>{let a=t?.rows[e];return(0,I.jsx)(`tr`,{...i,className:`group`,"data-testid":a?`row-${a.rowId}`:void 0,style:{...n,height:`40px`},children:r})},Rz={left:!1,right:!1},zz=class{_left=!1;_right=!1;_paused=!1;_dirty=!1;_onChange=null;get showLeftShadow(){return this._left}get showRightShadow(){return this._right}setOnChange(e){this._onChange=e}pause(){this._paused=!0,this._dirty=!1}resume(){this._paused=!1,this._dirty&&(this._dirty=!1,this._notify())}update(e,t){if(!(this._left===e&&this._right===t)){if(this._left=e,this._right=t,this._paused){this._dirty=!0;return}this._notify()}}reset(){if(!(!this._left&&!this._right)){if(this._left=!1,this._right=!1,this._paused){this._dirty=!0;return}this._notify()}}_notify(){this._onChange&&this._onChange({left:this._left,right:this._right})}};function Bz(e){return e instanceof HTMLElement?e:document.scrollingElement}function Vz(){let e=(0,L.useRef)(null);e.current||=new zz;let t=e.current,[n,r]=(0,L.useState)(Rz);t.setOnChange(r),(0,L.useEffect)(()=>()=>{t.setOnChange(null)},[t]);let i={"--shadow-left-opacity":n.left?`1`:`0`,"--shadow-right-opacity":n.right?`1`:`0`},a=(0,L.useRef)(null),o=(0,L.useRef)(0),s=(0,L.useRef)(null),c=(0,L.useCallback)(()=>{let e=a.current;if(!e)return;let n=Bz(e);if(!n)return;let r=n.scrollLeft,i=n.scrollWidth-n.clientWidth;t.update(r>0,i>1&&r<i-1)},[t]),l=(0,L.useCallback)(()=>{o.current&&cancelAnimationFrame(o.current),o.current=requestAnimationFrame(c)},[c]),u=(0,L.useCallback)(e=>{let n=a.current;if(n&&n.removeEventListener(`scroll`,l),s.current&&=(s.current.disconnect(),null),e){a.current=e,e.addEventListener(`scroll`,l,{passive:!0}),o.current=requestAnimationFrame(c);let t=Bz(e);if(t){let e=new ResizeObserver(l),n=t.querySelector(`table`);n&&e.observe(n),s.current=e}}else a.current=null,t.reset()},[l,c,t]);return(0,L.useEffect)(()=>()=>{let e=a.current;e&&e.removeEventListener(`scroll`,l),s.current&&s.current.disconnect(),o.current&&cancelAnimationFrame(o.current)},[l]),{shadowCssVars:i,shadowModel:t,setScrollerRef:u}}var Hz={Table:Iz,TableRow:Lz},Uz=g(({rows:e,columnsModel:t,cellFSM:n,selection:r,sortModel:i,filterModel:a,onSearchForeignKey:o,onUploadFile:s,onOpenFile:c,onOpenRow:l,onPickRow:u,onDeleteSelected:d,onDuplicateSelected:f,onDeleteRow:p,onDuplicateRow:m,onCopyPath:h,onEndReached:g,isLoadingMore:_,useWindowScroll:v})=>{let y=r.isSelectionMode,b=e.map(e=>e.rowId),[x,S]=(0,L.useState)(null),{shadowCssVars:C,shadowModel:w,setScrollerRef:T}=Vz(),E=t.isResizing;(0,L.useEffect)(()=>{E?w.pause():w.resume()},[E,w]);let[D,ee]=(0,L.useState)(null),te=(0,L.useCallback)(e=>{ee(e),t.setWrapperElement(e)},[t]);(0,L.useEffect)(()=>{if(!(!v||!D))return T(D),()=>{T(null)}},[v,D,T]);let ne=(0,L.useCallback)(e=>{r.enterSelectionMode(e)},[r]),O=(0,L.useCallback)(e=>{S({rowId:e})},[]),re=(0,L.useCallback)(e=>{S({batchIds:e})},[]),ie=(0,L.useCallback)(()=>{x?.rowId?(r.deselect(x.rowId),p?p(x.rowId):d&&d([x.rowId])):x?.batchIds&&(d?.(x.batchIds),r.exitSelectionMode()),S(null)},[x,p,d,r]),ae=(0,L.useCallback)(()=>{S(null)},[]),oe=x?.batchIds?.length,se=!!(p||d),ce=!!m,le=se||ce||!!f,ue=(0,L.useMemo)(()=>({copyRange:()=>{let r=n?.getSelectedRange(),i=t.visibleColumns;r&&XR(r,e,i)},pasteRange:()=>{if(!n)return;let r=t.visibleColumns,i=n.getSelectedRange(),a=QR(n,r,e);i?ZR(i.startRow,i.startCol,e,r):a&&ZR(a.rowIndex,a.colIndex,e,r)},clearRange:()=>{let r=n?.getSelectedRange(),i=t.visibleColumns;r&&$R(r,e,i)}}),[n,e,t]),de=(0,L.useCallback)(r=>{if(!n)return;let i=r.ctrlKey||r.metaKey,a=t.visibleColumns;if(i&&r.key===`v`&&n.focusedCell){let t=n.getSelectedRange(),i=QR(n,a,e);t?(r.preventDefault(),ZR(t.startRow,t.startCol,e,a)):i&&(r.preventDefault(),ZR(i.rowIndex,i.colIndex,e,a));return}if(n.hasSelection){if(i&&r.key===`c`){let t=n.getSelectedRange();t&&(r.preventDefault(),XR(t,e,a));return}if(r.key===`Delete`||r.key===`Backspace`){let t=n.getSelectedRange();t&&(r.preventDefault(),$R(t,e,a))}}},[n,e,t]),fe=(0,L.useCallback)((e,n)=>(0,I.jsx)(Nz,{row:n,columnsModel:t,showSelection:y,onSearchForeignKey:o,onUploadFile:s,onOpenFile:c,onOpenRow:l,onPickRow:u,onSelectRow:le?ne:void 0,onDuplicateRow:ce?m:void 0,onDeleteRow:se?O:void 0}),[t,y,o,s,c,l,u,le,se,ce,ne,m,O]),pe=(0,L.useCallback)(()=>(0,I.jsx)(Sz,{columnsModel:t,sortModel:i,filterModel:a,onCopyPath:h,showSelection:y}),[t,i,a,h,y]),me=(0,L.useMemo)(()=>({rows:e}),[e]),he=t.visibleColumns.length+(y?2:1),ge=(0,L.useCallback)(()=>_?(0,I.jsx)(`tfoot`,{children:(0,I.jsx)(`tr`,{children:(0,I.jsx)(`td`,{colSpan:he,style:{textAlign:`center`,padding:`16px 0`},children:(0,I.jsx)(Ht,{size:`sm`,color:`gray.400`})})})}):null,[_,he]),_e=(0,L.useMemo)(()=>({...Hz,Footer:ge}),[ge]);return t.visibleColumns.length===0?(0,I.jsx)(A,{p:4,children:(0,I.jsx)(k,{fontSize:`sm`,color:`gray.500`,children:`No columns to display.`})}):(0,I.jsxs)(nR.Provider,{value:n?ue:null,children:[(0,I.jsxs)(A,{ref:te,position:`relative`,height:v?void 0:`100%`,overflowX:`auto`,overflowY:v?`clip`:void 0,"data-testid":`table-widget`,onKeyDown:de,style:{...t.columnWidthCssVars,...C},children:[e.length===0?(0,I.jsxs)(A,{children:[(0,I.jsx)(`table`,{style:{width:`max-content`,minWidth:`100%`,tableLayout:`fixed`,borderCollapse:`separate`,borderSpacing:0},children:(0,I.jsx)(`thead`,{children:(0,I.jsx)(Sz,{columnsModel:t,sortModel:i,filterModel:a,onCopyPath:h,showSelection:y})})}),(0,I.jsx)(A,{p:4,children:(0,I.jsx)(k,{fontSize:`sm`,color:`gray.500`,children:`No rows to display.`})})]}):(0,I.jsx)(Foe,{useWindowScroll:v,style:v?void 0:{height:`100%`},data:e,context:me,defaultItemHeight:40,initialItemCount:Math.min(e.length,20),increaseViewportBy:2e3,endReached:g,fixedHeaderContent:pe,itemContent:fe,components:_e,scrollerRef:v?void 0:T}),(0,I.jsx)(Pz,{selection:r,allRowIds:b,onDuplicate:f,onDelete:d?re:void 0})]}),(0,I.jsx)(Fz,{isOpen:x!==null,onClose:ae,onConfirm:ie,count:oe})]})}),Wz=class{_cellFSM;_columnsModel;constructor(e,t){this._cellFSM=e,this._columnsModel=t,f(this,{},{autoBind:!0})}get _focusedColumn(){let e=this._cellFSM.focusedCell;return e?this._columnsModel.allColumns.find(t=>t.field===e.field)??null:null}get isVisible(){return this._focusedColumn!==null&&!this._cellFSM.hasSelection}get fieldLabel(){return this._focusedColumn?.label??``}get formulaExpression(){return this._focusedColumn?.formulaExpression}get foreignKeyTableId(){return this._focusedColumn?.foreignKeyTableId}},Gz=class{_totalCount=0;_baseTotalCount=0;_isFiltering=!1;_isRefetching=!1;constructor(){f(this,{},{autoBind:!0})}get totalCount(){return this._totalCount}get baseTotalCount(){return this._baseTotalCount}get isFiltering(){return this._isFiltering}get isRefetching(){return this._isRefetching}get text(){return this._isFiltering?`${this._totalCount} of ${this._baseTotalCount} ${this._baseTotalCount===1?`row`:`rows`}`:`${this._totalCount} ${this._totalCount===1?`row`:`rows`}`}setTotalCount(e){this._totalCount=e}setBaseTotalCount(e){this._baseTotalCount=e}setIsFiltering(e){this._isFiltering=e}setRefetching(e){this._isRefetching=e}decrementBaseTotalCount(e=1){this._baseTotalCount=Math.max(0,this._baseTotalCount-e),this._totalCount=Math.max(0,this._totalCount-e)}},Kz=class{_snapshot=null;_currentSnapshot=null;_canSave=!1;_isPopoverOpen=!1;_onSave=null;_onRevert=null;constructor(){f(this,{},{autoBind:!0})}get hasChanges(){return this._snapshot!==this._currentSnapshot}get isVisible(){return this.hasChanges}get canSave(){return this._canSave}get isPopoverOpen(){return this._isPopoverOpen}saveSnapshot(e){let t=JSON.stringify(e);this._snapshot=t,this._currentSnapshot=t}checkForChanges(e){this._currentSnapshot=JSON.stringify(e)}async save(){this._onSave&&await this._onSave()}revert(){this._onRevert&&this._onRevert(),this._currentSnapshot=this._snapshot}setCanSave(e){this._canSave=e}setPopoverOpen(e){this._isPopoverOpen=e}setOnSave(e){this._onSave=e}setOnRevert(e){this._onRevert=e}dispose(){this._onSave=null,this._onRevert=null}},qz=50,Jz=class{columns;filters;sorts;search;viewBadge;cellFSM;selection;rowCount;cellInfo;_dataSource;_pageSize;_breadcrumbs;_callbacks;_tableId;_schemaContext=new oI;_readonly=!1;_rows=[];_isBootstrapping=!0;_isLoadingMore=!1;_hasNextPage=!1;_endCursor=null;_savedViewState=null;constructor(e,t){this._dataSource=e,this._tableId=t.tableId,this._pageSize=t.pageSize??qz,this._readonly=t.readonly??!1,this._breadcrumbs=t.breadcrumbs??[],this._callbacks=t.callbacks??{},this.columns=new wI,this.filters=new oL,this.sorts=new TL,this.search=new xL(e=>this._handleSearch(e)),this.viewBadge=new Kz,this.cellFSM=new GL,this.selection=new jL,this.rowCount=new Gz,this.cellInfo=new Wz(this.cellFSM,this.columns),this.columns.setOnChange(()=>this._handleColumnsChange()),this.filters.setOnChange(()=>this._handleFilterChange()),this.filters.setOnApply(e=>this._handleFilterApply()),this.sorts.setOnChange(()=>this._handleSortChange()),this.sorts.setOnApply(e=>this._handleSortApply()),this.viewBadge.setOnSave(()=>this._handleViewSave()),this.viewBadge.setOnRevert(()=>this._handleViewRevert()),this.cellFSM.setOnReadonlyEditAttempt(this._callbacks.onReadonlyEditAttempt??null),f(this,{},{autoBind:!0}),queueMicrotask(()=>void this._bootstrap())}get rows(){return this._rows}get isBootstrapping(){return this._isBootstrapping}get isLoadingMore(){return this._isLoadingMore}get readonly(){return this._readonly}get tableId(){return this._tableId}get breadcrumbs(){return this._breadcrumbs}get callbacks(){return this._callbacks}getViewState(){return{columns:this.columns.serializeToViewColumns(),filters:null,sorts:this.sorts.serializeToViewSorts(),search:``}}applyViewState(e){this.columns.applyViewColumns(e.columns),this.sorts.applyViewSorts(e.sorts)}async loadMore(){if(!(!this._hasNextPage||this._isLoadingMore)){this._isLoadingMore=!0;try{let e=this._buildQuery(this._endCursor),t=await this._dataSource.fetchRows(e);c(()=>{this._appendRowVMs(t.rows),this._endCursor=t.endCursor,this._hasNextPage=t.hasNextPage,this._isLoadingMore=!1})}catch{c(()=>{this._isLoadingMore=!1})}}}async deleteRows(e){(await this._dataSource.deleteRows(e)).ok&&c(()=>{let t=new Set(e);this._rows=this._rows.filter(e=>!t.has(e.rowId)),this.rowCount.decrementBaseTotalCount(e.length),this.selection.exitSelectionMode(),this._updateNavigationContext()})}dispose(){this.columns.dispose(),this.filters.dispose(),this.sorts.dispose(),this.search.dispose(),this.viewBadge.dispose(),this.selection.exitSelectionMode(),this.cellFSM.blur();for(let e of this._rows)e.dispose()}async _bootstrap(){try{let e=await this._dataSource.fetchMetadata();c(()=>{this._schemaContext.init(e.dataSchema,e.refSchemas),this._readonly=this._readonly||e.readonly,this.viewBadge.setCanSave(!this._readonly)}),this.columns.init(this._schemaContext.allColumns),this.sorts.init(this._schemaContext.sortableFields),this.filters.init(this._schemaContext.filterableFields),e.viewState&&this.applyViewState(e.viewState),this._saveViewSnapshot(),await this._loadRows(),c(()=>{this._isBootstrapping=!1})}catch{c(()=>{this._isBootstrapping=!1})}}_buildQuery(e=null){return{where:this.filters.hasActiveFilters?this.filters.buildCurrentWhereClause():null,orderBy:this.sorts.serializeToQuerySorts(),search:this.search.debouncedQuery,first:this._pageSize,after:e}}async _loadRows(){let e=this._buildQuery(),t=await this._dataSource.fetchRows(e);c(()=>{this._replaceRowVMs(t.rows),this._endCursor=t.endCursor,this._hasNextPage=t.hasNextPage;let e=this.filters.hasActiveFilters||this.search.hasActiveSearch;this.rowCount.setTotalCount(t.totalCount),e||this.rowCount.setBaseTotalCount(t.totalCount),this.rowCount.setIsFiltering(e),this._updateNavigationContext()})}async _reloadRows(){this._isBootstrapping||(this.selection.exitSelectionMode(),this.cellFSM.blur(),await this._loadRows())}_replaceRowVMs(e){for(let e of this._rows)e.dispose();this._rows=this._createRowVMs(e)}_appendRowVMs(e){let t=this._createRowVMs(e);this._rows=[...this._rows,...t],this._updateNavigationContext()}_createRowVMs(e){let t=this._schemaContext.wrappedDataSchema;if(!t)return[];let n=kc({tableId:this._tableId,schema:t,rows:e.map(e=>({rowId:e.rowId,data:{data:e.data}})),refSchemas:this._schemaContext.fullRefSchemas}),r=new Map;for(let t of e)r.set(t.rowId,this._buildSystemValues(t));return n.rows.map(e=>new qL(e,e.rowId,this.cellFSM,this.selection,(e,t,n,r)=>this._commitCell(e,t,n,r),r.get(e.rowId),this._readonly))}_buildSystemValues(e){return{...e.systemFields,id:e.rowId}}_toPatchField(e){return nI(e)}async _commitCell(e,t,n,r){let i=this._toPatchField(t),a=(await this._dataSource.patchCells([{rowId:e,field:i,value:n}]))[0];a&&!a.ok&&c(()=>{let n=this._rows.find(t=>t.rowId===e);if(n&&r!==void 0){let e=n.rowModel.get(t);e?.isPrimitive()?e.setValue(r):e?.isObject()&&e.setValue(r,{internal:!0})}})}_updateNavigationContext(){this.cellFSM.setNavigationContext(this.columns.visibleColumns.map(e=>e.field),this._rows.map(e=>e.rowId))}_handleColumnsChange(){this.cellFSM.updateNavigationContext(this.columns.visibleColumns.map(e=>e.field),this.cellFSM.rowIds),this._checkViewChanges()}_handleFilterChange(){}_handleFilterApply(){this._reloadRows()}_handleSortChange(){this._checkViewChanges()}_handleSortApply(){this._reloadRows(),this._checkViewChanges()}_handleSearch(e){this._reloadRows()}async _handleViewSave(){try{let e=this.getViewState();(await this._dataSource.saveView(e)).ok&&this._saveViewSnapshot()}catch{}}_handleViewRevert(){this._savedViewState&&(this.applyViewState(this._savedViewState),this._reloadRows())}_saveViewSnapshot(){let e=this.getViewState();this._savedViewState=e,this.viewBadge.saveSnapshot(e)}_checkViewChanges(){this.viewBadge.checkForChanges(this.getViewState())}};function Yz(e,{delayMs:t=150,minShowMs:n=300}={}){let[r,i]=(0,L.useState)(!1),a=(0,L.useRef)(null);return(0,L.useEffect)(()=>{if(e){let e=setTimeout(()=>{a.current=Date.now(),i(!0)},t);return()=>clearTimeout(e)}if(a.current!==null){let e=n-(Date.now()-a.current);if(e>0){let t=setTimeout(()=>{a.current=null,i(!1)},e);return()=>clearTimeout(t)}a.current=null}i(!1)},[e,t,n]),r}var Xz=g(({model:e})=>e.isVisible?(0,I.jsxs)(j,{alignItems:`center`,gap:2,overflow:`hidden`,flexShrink:1,minW:0,children:[(0,I.jsx)(k,{fontSize:`sm`,color:`gray.500`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,"data-testid":`cell-info-field`,children:e.fieldLabel}),e.formulaExpression&&(0,I.jsxs)(k,{fontSize:`sm`,color:`purple.400`,fontFamily:`mono`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,"data-testid":`cell-info-formula`,children:[`= `,e.formulaExpression]}),e.foreignKeyTableId&&!e.formulaExpression&&(0,I.jsxs)(k,{fontSize:`sm`,color:`blue.400`,fontFamily:`mono`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,"data-testid":`cell-info-fk`,children:[`→ `,e.foreignKeyTableId]})]}):null),Zz=g(({model:e})=>(0,I.jsxs)(j,{alignItems:`center`,gap:2,children:[(0,I.jsx)(k,{fontSize:`sm`,color:`gray.500`,"data-testid":`row-count-text`,children:e.text}),e.isRefetching&&(0,I.jsx)(Ht,{size:`xs`,color:`gray.400`,"data-testid":`row-count-spinner`})]})),Qz=g(({model:e})=>{if(!e.isVisible)return null;let t=e.canSave?`orange`:`gray`,n=e.canSave?`orange.500`:`gray.400`,r=e.canSave?`unsaved`:`local`,i=e.canSave?`Unsaved view settings`:`Local view changes`,a=e.canSave?`Column order, widths, and sort settings will be saved to the Default view and shared with everyone.`:`View settings can only be saved in draft revisions. These changes are temporary and will be lost when you leave.`,o=e.canSave?`Revert`:`Reset`;return(0,I.jsxs)(ge,{open:e.isPopoverOpen,onOpenChange:t=>e.setPopoverOpen(t.open),lazyMount:!0,unmountOnExit:!0,children:[(0,I.jsx)(me,{asChild:!0,children:(0,I.jsxs)(It,{variant:`subtle`,size:`sm`,colorPalette:t,cursor:`pointer`,display:`flex`,alignItems:`center`,gap:1,_hover:{opacity:.8},"data-testid":`view-settings-badge`,children:[(0,I.jsx)(A,{width:`6px`,height:`6px`,borderRadius:`full`,bg:n}),r]})}),(0,I.jsx)(R,{children:(0,I.jsx)(se,{children:(0,I.jsxs)(le,{p:3,maxW:`300px`,children:[(0,I.jsxs)(P,{mb:2,children:[(0,I.jsx)(A,{color:`gray.400`,children:(0,I.jsx)(bk,{size:16})}),(0,I.jsx)(k,{fontWeight:`semibold`,fontSize:`sm`,children:i})]}),(0,I.jsx)(k,{fontSize:`sm`,color:`gray.600`,mb:3,children:a}),(0,I.jsxs)(P,{children:[(0,I.jsx)(N,{variant:`ghost`,size:`xs`,onClick:()=>{e.revert(),e.setPopoverOpen(!1)},"data-testid":`view-settings-revert`,children:o}),e.canSave&&(0,I.jsx)(N,{colorPalette:`blue`,size:`xs`,onClick:()=>{e.save(),e.setPopoverOpen(!1)},"data-testid":`view-settings-save`,children:`Save`})]})]})})})]})}),$z=40,eB=40,tB=8,nB=[120,150,120,100,130],rB=[[80,110,70,60,90],[100,90,100,80,110],[60,130,80,70,80],[90,100,60,90,100],[75,120,90,55,70],[110,80,75,80,120],[85,140,95,65,95],[95,70,110,85,80]],iB=({breadcrumbs:e,onBreadcrumbClick:t,showCreateButton:n,useWindowScroll:r})=>(0,I.jsxs)(A,{display:`flex`,flexDirection:`column`,height:r?void 0:`100%`,flex:r?1:void 0,children:[(0,I.jsxs)(j,{px:3,pt:`32px`,pb:`48px`,alignItems:`flex-start`,justifyContent:`space-between`,...r&&{position:`sticky`,top:0,zIndex:3,bg:`white`},children:[e.length>0?(0,I.jsx)(JN,{segments:e,highlightLast:!1,onSegmentClick:t,action:n?(0,I.jsx)(sn,{height:`32px`,width:`32px`,borderRadius:`6px`}):void 0}):(0,I.jsx)(A,{}),(0,I.jsxs)(j,{alignItems:`center`,gap:`8px`,children:[(0,I.jsx)(sn,{height:`32px`,width:`32px`,borderRadius:`6px`}),(0,I.jsx)(sn,{height:`32px`,width:`32px`,borderRadius:`6px`}),(0,I.jsx)(sn,{height:`32px`,width:`32px`,borderRadius:`6px`})]})]}),(0,I.jsxs)(A,{children:[(0,I.jsx)(j,{height:`${$z}px`,alignItems:`center`,px:3,borderBottom:`1px solid`,borderColor:`gray.100`,children:nB.map((e,t)=>(0,I.jsx)(A,{width:`${e}px`,flexShrink:0,children:(0,I.jsx)(sn,{height:`12px`,width:`60px`,borderRadius:`4px`})},`h-${t}`))}),rB.slice(0,tB).map((e,t)=>(0,I.jsx)(j,{height:`${eB}px`,alignItems:`center`,px:3,borderBottom:`1px solid`,borderColor:`gray.100`,children:nB.map((n,r)=>(0,I.jsx)(A,{width:`${n}px`,flexShrink:0,children:(0,I.jsx)(sn,{height:`14px`,width:`${e[r]}px`,borderRadius:`4px`})},`r-${t}-c-${r}`))},`r-${t}`))]})]}),aB=()=>{};function oB(e,t,n){return{onDeleteRow:e?void 0:e=>t.deleteRows([e]),onDuplicateRow:e?void 0:n.onDuplicateRow,onDeleteSelected:e?void 0:e=>t.deleteRows(e),onUploadFile:e?void 0:n.onUploadFile}}var sB=g(({viewModel:e,useWindowScroll:t})=>{let n=Yz(e.isBootstrapping);if(e.isBootstrapping)return n?(0,I.jsx)(iB,{breadcrumbs:e.breadcrumbs,onBreadcrumbClick:e.callbacks.onBreadcrumbClick,showCreateButton:!e.readonly&&!!e.callbacks.onCreateRow,useWindowScroll:t}):null;let r=e.readonly,{breadcrumbs:i,callbacks:a}=e;return(0,I.jsxs)(A,{display:`flex`,flexDirection:`column`,height:t?void 0:`100%`,flex:t?1:void 0,children:[(0,I.jsxs)(j,{px:3,pt:`32px`,pb:`48px`,alignItems:`flex-start`,justifyContent:`space-between`,...t&&{position:`sticky`,top:0,zIndex:3,bg:`white`},children:[i.length>0&&(0,I.jsx)(JN,{segments:i,highlightLast:!1,onSegmentClick:a.onBreadcrumbClick,action:a.onCreateRow?(0,I.jsx)(XN,{tooltip:`New row`,onClick:a.onCreateRow,dataTestId:`create-row-button`}):void 0}),(0,I.jsxs)(j,{alignItems:`center`,gap:`8px`,children:[(0,I.jsx)(CL,{model:e.search}),(0,I.jsx)(bL,{model:e.filters,availableFields:e.columns.filterableFields}),(0,I.jsx)(AL,{model:e.sorts,availableFields:e.columns.sortableFields,onChange:aB})]})]}),(0,I.jsx)(A,{flex:1,minHeight:0,children:(0,I.jsx)(Uz,{rows:e.rows,columnsModel:e.columns,cellFSM:e.cellFSM,selection:e.selection,sortModel:e.sorts,filterModel:e.filters,isLoadingMore:e.isLoadingMore,onEndReached:e.loadMore,onOpenRow:a.onOpenRow,onPickRow:a.onPickRow,...oB(r,e,a),onSearchForeignKey:a.onSearchForeignKey,onOpenFile:a.onOpenFile,onCopyPath:a.onCopyPath,useWindowScroll:t})}),(0,I.jsxs)(j,{px:3,py:2,alignItems:`center`,overflow:`hidden`,...t&&{position:`sticky`,bottom:0,bg:`white`,zIndex:3},children:[(0,I.jsx)(Zz,{model:e.rowCount}),(0,I.jsxs)(j,{alignItems:`center`,gap:3,overflow:`hidden`,flexShrink:1,minW:0,flex:1,justifyContent:`flex-end`,children:[(0,I.jsx)(Xz,{model:e.cellInfo}),(0,I.jsx)(Qz,{model:e.viewBadge})]})]})]})}),cB=Sn(),lB=e=>{let t={BASE_URL:`/`,DEV:!1,GIT_BRANCH_NAME:`HEAD`,GIT_COMMIT_HASH:`fa903ef`,MODE:`production`,PACKAGE_VERSION:`2.7.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}[e];return globalThis.__env__?.[e]||t},uB=(e,t,n,r,i,a,o,s)=>{let c=document.documentElement,l=[`light`,`dark`];function u(t){(Array.isArray(e)?e:[e]).forEach(e=>{let n=e===`class`,r=n&&a?i.map(e=>a[e]||e):i;n?(c.classList.remove(...r),c.classList.add(a&&a[t]?a[t]:t)):c.setAttribute(e,t)}),d(t)}function d(e){s&&l.includes(e)&&(c.style.colorScheme=e)}function f(){return window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`}if(r)u(r);else try{let e=localStorage.getItem(t)||n;u(o&&e===`system`?f():e)}catch{}},dB=[`light`,`dark`],fB=`(prefers-color-scheme: dark)`,pB=typeof window>`u`,mB=L.createContext(void 0),hB=e=>L.useContext(mB)?L.createElement(L.Fragment,null,e.children):L.createElement(_B,{...e}),gB=[`light`,`dark`],_B=({forcedTheme:e,disableTransitionOnChange:t=!1,enableSystem:n=!0,enableColorScheme:r=!0,storageKey:i=`theme`,themes:a=gB,defaultTheme:o=n?`system`:`light`,attribute:s=`data-theme`,value:c,children:l,nonce:u,scriptProps:d})=>{let[f,p]=L.useState(()=>yB(i,o)),[m,h]=L.useState(()=>f===`system`?xB():f),g=c?Object.values(c):a,_=L.useCallback(e=>{let i=e;if(!i)return;e===`system`&&n&&(i=xB());let a=c?c[i]:i,l=t?bB(u):null,d=document.documentElement,f=e=>{e===`class`?(d.classList.remove(...g),a&&d.classList.add(a)):e.startsWith(`data-`)&&(a?d.setAttribute(e,a):d.removeAttribute(e))};if(Array.isArray(s)?s.forEach(f):f(s),r){let e=dB.includes(o)?o:null,t=dB.includes(i)?i:e;d.style.colorScheme=t}l?.()},[u]),v=L.useCallback(e=>{let t=typeof e==`function`?e(f):e;p(t);try{localStorage.setItem(i,t)}catch{}},[f]),y=L.useCallback(t=>{h(xB(t)),f===`system`&&n&&!e&&_(`system`)},[f,e]);L.useEffect(()=>{let e=window.matchMedia(fB);return e.addListener(y),y(e),()=>e.removeListener(y)},[y]),L.useEffect(()=>{let e=e=>{e.key===i&&(e.newValue?p(e.newValue):v(o))};return window.addEventListener(`storage`,e),()=>window.removeEventListener(`storage`,e)},[v]),L.useEffect(()=>{_(e??f)},[e,f]);let b=L.useMemo(()=>({theme:f,setTheme:v,forcedTheme:e,resolvedTheme:f===`system`?m:f,themes:n?[...a,`system`]:a,systemTheme:n?m:void 0}),[f,v,e,m,n,a]);return L.createElement(mB.Provider,{value:b},L.createElement(vB,{forcedTheme:e,storageKey:i,attribute:s,enableSystem:n,enableColorScheme:r,defaultTheme:o,value:c,themes:a,nonce:u,scriptProps:d}),l)},vB=L.memo(({forcedTheme:e,storageKey:t,attribute:n,enableSystem:r,enableColorScheme:i,defaultTheme:a,value:o,themes:s,nonce:c,scriptProps:l})=>{let u=JSON.stringify([n,t,a,e,s,o,r,i]).slice(1,-1);return L.createElement(`script`,{...l,suppressHydrationWarning:!0,nonce:typeof window>`u`?c:``,dangerouslySetInnerHTML:{__html:`(${uB.toString()})(${u})`}})}),yB=(e,t)=>{if(pB)return;let n;try{n=localStorage.getItem(e)||void 0}catch{}return n||t},bB=e=>{let t=document.createElement(`style`);return e&&t.setAttribute(`nonce`,e),t.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(t),()=>{window.getComputedStyle(document.body),setTimeout(()=>{document.head.removeChild(t)},1)}},xB=e=>(e||=window.matchMedia(fB),e.matches?`dark`:`light`),SB=()=>(0,L.useCallback)(e=>{e&&e.focus()},[]),CB=(e,...t)=>{let n=(0,L.useRef)(null),[r,i]=(0,L.useState)(t),a=(0,L.useMemo)(()=>r.length!==t.length||r.some((e,n)=>e!==t[n])?(i(t),t):r,[t,r]);return n.current||=Y.get(e),(0,L.useEffect)(()=>{let e=n.current;return e?.init?.(...a),()=>{e?.dispose?.()}},[a]),n.current};function wB(e){let t=Object.prototype.toString.call(e);return e instanceof Date||typeof e==`object`&&t===`[object Date]`?new e.constructor(+e):typeof e==`number`||t===`[object Number]`||typeof e==`string`||t===`[object String]`?new Date(e):new Date(NaN)}function TB(e,t){return e instanceof Date?new e.constructor(t):new Date(t)}var EB=365.2425,DB=6048e5,OB=864e5,kB=43200,AB=1440,jB=3600*24;jB*7,jB*EB/12*3;var MB={};function NB(){return MB}function PB(e,t){let n=NB(),r=t?.weekStartsOn??t?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,i=wB(e),a=i.getDay(),o=(a<r?7:0)+a-r;return i.setDate(i.getDate()-o),i.setHours(0,0,0,0),i}function FB(e){return PB(e,{weekStartsOn:1})}function IB(e){let t=wB(e),n=t.getFullYear(),r=TB(e,0);r.setFullYear(n+1,0,4),r.setHours(0,0,0,0);let i=FB(r),a=TB(e,0);a.setFullYear(n,0,4),a.setHours(0,0,0,0);let o=FB(a);return t.getTime()>=i.getTime()?n+1:t.getTime()>=o.getTime()?n:n-1}function LB(e){let t=wB(e);return t.setHours(0,0,0,0),t}function RB(e){let t=wB(e),n=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()));return n.setUTCFullYear(t.getFullYear()),e-+n}function zB(e,t){let n=LB(e),r=LB(t),i=+n-RB(n),a=+r-RB(r);return Math.round((i-a)/OB)}function BB(e){let t=IB(e),n=TB(e,0);return n.setFullYear(t,0,4),n.setHours(0,0,0,0),FB(n)}function VB(e,t){let n=wB(e),r=wB(t),i=n.getTime()-r.getTime();return i<0?-1:i>0?1:i}function HB(e){return e instanceof Date||typeof e==`object`&&Object.prototype.toString.call(e)===`[object Date]`}function UB(e){if(!HB(e)&&typeof e!=`number`)return!1;let t=wB(e);return!isNaN(Number(t))}function WB(e,t){let n=wB(e),r=wB(t),i=n.getFullYear()-r.getFullYear(),a=n.getMonth()-r.getMonth();return i*12+a}function GB(e){return t=>{let n=(e?Math[e]:Math.trunc)(t);return n===0?0:n}}function KB(e,t){return wB(e)-+wB(t)}function qB(e){let t=wB(e);return t.setHours(23,59,59,999),t}function JB(e){let t=wB(e),n=t.getMonth();return t.setFullYear(t.getFullYear(),n+1,0),t.setHours(23,59,59,999),t}function YB(e){let t=wB(e);return+qB(t)==+JB(t)}function XB(e,t){let n=wB(e),r=wB(t),i=VB(n,r),a=Math.abs(WB(n,r)),o;if(a<1)o=0;else{n.getMonth()===1&&n.getDate()>27&&n.setDate(30),n.setMonth(n.getMonth()-i*a);let t=VB(n,r)===-i;YB(wB(e))&&a===1&&VB(e,r)===1&&(t=!1),o=i*(a-Number(t))}return o===0?0:o}function ZB(e,t,n){let r=KB(e,t)/1e3;return GB(n?.roundingMethod)(r)}function QB(e){let t=wB(e),n=TB(e,0);return n.setFullYear(t.getFullYear(),0,1),n.setHours(0,0,0,0),n}var $B={lessThanXSeconds:{one:`less than a second`,other:`less than {{count}} seconds`},xSeconds:{one:`1 second`,other:`{{count}} seconds`},halfAMinute:`half a minute`,lessThanXMinutes:{one:`less than a minute`,other:`less than {{count}} minutes`},xMinutes:{one:`1 minute`,other:`{{count}} minutes`},aboutXHours:{one:`about 1 hour`,other:`about {{count}} hours`},xHours:{one:`1 hour`,other:`{{count}} hours`},xDays:{one:`1 day`,other:`{{count}} days`},aboutXWeeks:{one:`about 1 week`,other:`about {{count}} weeks`},xWeeks:{one:`1 week`,other:`{{count}} weeks`},aboutXMonths:{one:`about 1 month`,other:`about {{count}} months`},xMonths:{one:`1 month`,other:`{{count}} months`},aboutXYears:{one:`about 1 year`,other:`about {{count}} years`},xYears:{one:`1 year`,other:`{{count}} years`},overXYears:{one:`over 1 year`,other:`over {{count}} years`},almostXYears:{one:`almost 1 year`,other:`almost {{count}} years`}},eV=(e,t,n)=>{let r,i=$B[e];return r=typeof i==`string`?i:t===1?i.one:i.other.replace(`{{count}}`,t.toString()),n?.addSuffix?n.comparison&&n.comparison>0?`in `+r:r+` ago`:r};function tV(e){return(t={})=>{let n=t.width?String(t.width):e.defaultWidth;return e.formats[n]||e.formats[e.defaultWidth]}}var nV={date:tV({formats:{full:`EEEE, MMMM do, y`,long:`MMMM do, y`,medium:`MMM d, y`,short:`MM/dd/yyyy`},defaultWidth:`full`}),time:tV({formats:{full:`h:mm:ss a zzzz`,long:`h:mm:ss a z`,medium:`h:mm:ss a`,short:`h:mm a`},defaultWidth:`full`}),dateTime:tV({formats:{full:`{{date}} 'at' {{time}}`,long:`{{date}} 'at' {{time}}`,medium:`{{date}}, {{time}}`,short:`{{date}}, {{time}}`},defaultWidth:`full`})},rV={lastWeek:`'last' eeee 'at' p`,yesterday:`'yesterday at' p`,today:`'today at' p`,tomorrow:`'tomorrow at' p`,nextWeek:`eeee 'at' p`,other:`P`},iV=(e,t,n,r)=>rV[e];function aV(e){return(t,n)=>{let r=n?.context?String(n.context):`standalone`,i;if(r===`formatting`&&e.formattingValues){let t=e.defaultFormattingWidth||e.defaultWidth,r=n?.width?String(n.width):t;i=e.formattingValues[r]||e.formattingValues[t]}else{let t=e.defaultWidth,r=n?.width?String(n.width):e.defaultWidth;i=e.values[r]||e.values[t]}let a=e.argumentCallback?e.argumentCallback(t):t;return i[a]}}var oV={ordinalNumber:(e,t)=>{let n=Number(e),r=n%100;if(r>20||r<10)switch(r%10){case 1:return n+`st`;case 2:return n+`nd`;case 3:return n+`rd`}return n+`th`},era:aV({values:{narrow:[`B`,`A`],abbreviated:[`BC`,`AD`],wide:[`Before Christ`,`Anno Domini`]},defaultWidth:`wide`}),quarter:aV({values:{narrow:[`1`,`2`,`3`,`4`],abbreviated:[`Q1`,`Q2`,`Q3`,`Q4`],wide:[`1st quarter`,`2nd quarter`,`3rd quarter`,`4th quarter`]},defaultWidth:`wide`,argumentCallback:e=>e-1}),month:aV({values:{narrow:[`J`,`F`,`M`,`A`,`M`,`J`,`J`,`A`,`S`,`O`,`N`,`D`],abbreviated:[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],wide:[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`]},defaultWidth:`wide`}),day:aV({values:{narrow:[`S`,`M`,`T`,`W`,`T`,`F`,`S`],short:[`Su`,`Mo`,`Tu`,`We`,`Th`,`Fr`,`Sa`],abbreviated:[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`],wide:[`Sunday`,`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`]},defaultWidth:`wide`}),dayPeriod:aV({values:{narrow:{am:`a`,pm:`p`,midnight:`mi`,noon:`n`,morning:`morning`,afternoon:`afternoon`,evening:`evening`,night:`night`},abbreviated:{am:`AM`,pm:`PM`,midnight:`midnight`,noon:`noon`,morning:`morning`,afternoon:`afternoon`,evening:`evening`,night:`night`},wide:{am:`a.m.`,pm:`p.m.`,midnight:`midnight`,noon:`noon`,morning:`morning`,afternoon:`afternoon`,evening:`evening`,night:`night`}},defaultWidth:`wide`,formattingValues:{narrow:{am:`a`,pm:`p`,midnight:`mi`,noon:`n`,morning:`in the morning`,afternoon:`in the afternoon`,evening:`in the evening`,night:`at night`},abbreviated:{am:`AM`,pm:`PM`,midnight:`midnight`,noon:`noon`,morning:`in the morning`,afternoon:`in the afternoon`,evening:`in the evening`,night:`at night`},wide:{am:`a.m.`,pm:`p.m.`,midnight:`midnight`,noon:`noon`,morning:`in the morning`,afternoon:`in the afternoon`,evening:`in the evening`,night:`at night`}},defaultFormattingWidth:`wide`})};function sV(e){return(t,n={})=>{let r=n.width,i=r&&e.matchPatterns[r]||e.matchPatterns[e.defaultMatchWidth],a=t.match(i);if(!a)return null;let o=a[0],s=r&&e.parsePatterns[r]||e.parsePatterns[e.defaultParseWidth],c=Array.isArray(s)?lV(s,e=>e.test(o)):cV(s,e=>e.test(o)),l;l=e.valueCallback?e.valueCallback(c):c,l=n.valueCallback?n.valueCallback(l):l;let u=t.slice(o.length);return{value:l,rest:u}}}function cV(e,t){for(let n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&t(e[n]))return n}function lV(e,t){for(let n=0;n<e.length;n++)if(t(e[n]))return n}function uV(e){return(t,n={})=>{let r=t.match(e.matchPattern);if(!r)return null;let i=r[0],a=t.match(e.parsePattern);if(!a)return null;let o=e.valueCallback?e.valueCallback(a[0]):a[0];o=n.valueCallback?n.valueCallback(o):o;let s=t.slice(i.length);return{value:o,rest:s}}}var dV={code:`en-US`,formatDistance:eV,formatLong:nV,formatRelative:iV,localize:oV,match:{ordinalNumber:uV({matchPattern:/^(\d+)(th|st|nd|rd)?/i,parsePattern:/\d+/i,valueCallback:e=>parseInt(e,10)}),era:sV({matchPatterns:{narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},defaultMatchWidth:`wide`,parsePatterns:{any:[/^b/i,/^(a|c)/i]},defaultParseWidth:`any`}),quarter:sV({matchPatterns:{narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},defaultMatchWidth:`wide`,parsePatterns:{any:[/1/i,/2/i,/3/i,/4/i]},defaultParseWidth:`any`,valueCallback:e=>e+1}),month:sV({matchPatterns:{narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},defaultMatchWidth:`wide`,parsePatterns:{narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},defaultParseWidth:`any`}),day:sV({matchPatterns:{narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},defaultMatchWidth:`wide`,parsePatterns:{narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},defaultParseWidth:`any`}),dayPeriod:sV({matchPatterns:{narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},defaultMatchWidth:`any`,parsePatterns:{any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},defaultParseWidth:`any`})},options:{weekStartsOn:0,firstWeekContainsDate:1}};function fV(e){let t=wB(e);return zB(t,QB(t))+1}function pV(e){let t=wB(e),n=FB(t)-+BB(t);return Math.round(n/DB)+1}function mV(e,t){let n=wB(e),r=n.getFullYear(),i=NB(),a=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??i.firstWeekContainsDate??i.locale?.options?.firstWeekContainsDate??1,o=TB(e,0);o.setFullYear(r+1,0,a),o.setHours(0,0,0,0);let s=PB(o,t),c=TB(e,0);c.setFullYear(r,0,a),c.setHours(0,0,0,0);let l=PB(c,t);return n.getTime()>=s.getTime()?r+1:n.getTime()>=l.getTime()?r:r-1}function hV(e,t){let n=NB(),r=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??n.firstWeekContainsDate??n.locale?.options?.firstWeekContainsDate??1,i=mV(e,t),a=TB(e,0);return a.setFullYear(i,0,r),a.setHours(0,0,0,0),PB(a,t)}function gV(e,t){let n=wB(e),r=PB(n,t)-+hV(n,t);return Math.round(r/DB)+1}function _V(e,t){return(e<0?`-`:``)+Math.abs(e).toString().padStart(t,`0`)}var vV={y(e,t){let n=e.getFullYear(),r=n>0?n:1-n;return _V(t===`yy`?r%100:r,t.length)},M(e,t){let n=e.getMonth();return t===`M`?String(n+1):_V(n+1,2)},d(e,t){return _V(e.getDate(),t.length)},a(e,t){let n=e.getHours()/12>=1?`pm`:`am`;switch(t){case`a`:case`aa`:return n.toUpperCase();case`aaa`:return n;case`aaaaa`:return n[0];default:return n===`am`?`a.m.`:`p.m.`}},h(e,t){return _V(e.getHours()%12||12,t.length)},H(e,t){return _V(e.getHours(),t.length)},m(e,t){return _V(e.getMinutes(),t.length)},s(e,t){return _V(e.getSeconds(),t.length)},S(e,t){let n=t.length,r=e.getMilliseconds();return _V(Math.trunc(r*10**(n-3)),t.length)}},yV={am:`am`,pm:`pm`,midnight:`midnight`,noon:`noon`,morning:`morning`,afternoon:`afternoon`,evening:`evening`,night:`night`},bV={G:function(e,t,n){let r=+(e.getFullYear()>0);switch(t){case`G`:case`GG`:case`GGG`:return n.era(r,{width:`abbreviated`});case`GGGGG`:return n.era(r,{width:`narrow`});default:return n.era(r,{width:`wide`})}},y:function(e,t,n){if(t===`yo`){let t=e.getFullYear(),r=t>0?t:1-t;return n.ordinalNumber(r,{unit:`year`})}return vV.y(e,t)},Y:function(e,t,n,r){let i=mV(e,r),a=i>0?i:1-i;return t===`YY`?_V(a%100,2):t===`Yo`?n.ordinalNumber(a,{unit:`year`}):_V(a,t.length)},R:function(e,t){return _V(IB(e),t.length)},u:function(e,t){return _V(e.getFullYear(),t.length)},Q:function(e,t,n){let r=Math.ceil((e.getMonth()+1)/3);switch(t){case`Q`:return String(r);case`QQ`:return _V(r,2);case`Qo`:return n.ordinalNumber(r,{unit:`quarter`});case`QQQ`:return n.quarter(r,{width:`abbreviated`,context:`formatting`});case`QQQQQ`:return n.quarter(r,{width:`narrow`,context:`formatting`});default:return n.quarter(r,{width:`wide`,context:`formatting`})}},q:function(e,t,n){let r=Math.ceil((e.getMonth()+1)/3);switch(t){case`q`:return String(r);case`qq`:return _V(r,2);case`qo`:return n.ordinalNumber(r,{unit:`quarter`});case`qqq`:return n.quarter(r,{width:`abbreviated`,context:`standalone`});case`qqqqq`:return n.quarter(r,{width:`narrow`,context:`standalone`});default:return n.quarter(r,{width:`wide`,context:`standalone`})}},M:function(e,t,n){let r=e.getMonth();switch(t){case`M`:case`MM`:return vV.M(e,t);case`Mo`:return n.ordinalNumber(r+1,{unit:`month`});case`MMM`:return n.month(r,{width:`abbreviated`,context:`formatting`});case`MMMMM`:return n.month(r,{width:`narrow`,context:`formatting`});default:return n.month(r,{width:`wide`,context:`formatting`})}},L:function(e,t,n){let r=e.getMonth();switch(t){case`L`:return String(r+1);case`LL`:return _V(r+1,2);case`Lo`:return n.ordinalNumber(r+1,{unit:`month`});case`LLL`:return n.month(r,{width:`abbreviated`,context:`standalone`});case`LLLLL`:return n.month(r,{width:`narrow`,context:`standalone`});default:return n.month(r,{width:`wide`,context:`standalone`})}},w:function(e,t,n,r){let i=gV(e,r);return t===`wo`?n.ordinalNumber(i,{unit:`week`}):_V(i,t.length)},I:function(e,t,n){let r=pV(e);return t===`Io`?n.ordinalNumber(r,{unit:`week`}):_V(r,t.length)},d:function(e,t,n){return t===`do`?n.ordinalNumber(e.getDate(),{unit:`date`}):vV.d(e,t)},D:function(e,t,n){let r=fV(e);return t===`Do`?n.ordinalNumber(r,{unit:`dayOfYear`}):_V(r,t.length)},E:function(e,t,n){let r=e.getDay();switch(t){case`E`:case`EE`:case`EEE`:return n.day(r,{width:`abbreviated`,context:`formatting`});case`EEEEE`:return n.day(r,{width:`narrow`,context:`formatting`});case`EEEEEE`:return n.day(r,{width:`short`,context:`formatting`});default:return n.day(r,{width:`wide`,context:`formatting`})}},e:function(e,t,n,r){let i=e.getDay(),a=(i-r.weekStartsOn+8)%7||7;switch(t){case`e`:return String(a);case`ee`:return _V(a,2);case`eo`:return n.ordinalNumber(a,{unit:`day`});case`eee`:return n.day(i,{width:`abbreviated`,context:`formatting`});case`eeeee`:return n.day(i,{width:`narrow`,context:`formatting`});case`eeeeee`:return n.day(i,{width:`short`,context:`formatting`});default:return n.day(i,{width:`wide`,context:`formatting`})}},c:function(e,t,n,r){let i=e.getDay(),a=(i-r.weekStartsOn+8)%7||7;switch(t){case`c`:return String(a);case`cc`:return _V(a,t.length);case`co`:return n.ordinalNumber(a,{unit:`day`});case`ccc`:return n.day(i,{width:`abbreviated`,context:`standalone`});case`ccccc`:return n.day(i,{width:`narrow`,context:`standalone`});case`cccccc`:return n.day(i,{width:`short`,context:`standalone`});default:return n.day(i,{width:`wide`,context:`standalone`})}},i:function(e,t,n){let r=e.getDay(),i=r===0?7:r;switch(t){case`i`:return String(i);case`ii`:return _V(i,t.length);case`io`:return n.ordinalNumber(i,{unit:`day`});case`iii`:return n.day(r,{width:`abbreviated`,context:`formatting`});case`iiiii`:return n.day(r,{width:`narrow`,context:`formatting`});case`iiiiii`:return n.day(r,{width:`short`,context:`formatting`});default:return n.day(r,{width:`wide`,context:`formatting`})}},a:function(e,t,n){let r=e.getHours()/12>=1?`pm`:`am`;switch(t){case`a`:case`aa`:return n.dayPeriod(r,{width:`abbreviated`,context:`formatting`});case`aaa`:return n.dayPeriod(r,{width:`abbreviated`,context:`formatting`}).toLowerCase();case`aaaaa`:return n.dayPeriod(r,{width:`narrow`,context:`formatting`});default:return n.dayPeriod(r,{width:`wide`,context:`formatting`})}},b:function(e,t,n){let r=e.getHours(),i;switch(i=r===12?yV.noon:r===0?yV.midnight:r/12>=1?`pm`:`am`,t){case`b`:case`bb`:return n.dayPeriod(i,{width:`abbreviated`,context:`formatting`});case`bbb`:return n.dayPeriod(i,{width:`abbreviated`,context:`formatting`}).toLowerCase();case`bbbbb`:return n.dayPeriod(i,{width:`narrow`,context:`formatting`});default:return n.dayPeriod(i,{width:`wide`,context:`formatting`})}},B:function(e,t,n){let r=e.getHours(),i;switch(i=r>=17?yV.evening:r>=12?yV.afternoon:r>=4?yV.morning:yV.night,t){case`B`:case`BB`:case`BBB`:return n.dayPeriod(i,{width:`abbreviated`,context:`formatting`});case`BBBBB`:return n.dayPeriod(i,{width:`narrow`,context:`formatting`});default:return n.dayPeriod(i,{width:`wide`,context:`formatting`})}},h:function(e,t,n){if(t===`ho`){let t=e.getHours()%12;return t===0&&(t=12),n.ordinalNumber(t,{unit:`hour`})}return vV.h(e,t)},H:function(e,t,n){return t===`Ho`?n.ordinalNumber(e.getHours(),{unit:`hour`}):vV.H(e,t)},K:function(e,t,n){let r=e.getHours()%12;return t===`Ko`?n.ordinalNumber(r,{unit:`hour`}):_V(r,t.length)},k:function(e,t,n){let r=e.getHours();return r===0&&(r=24),t===`ko`?n.ordinalNumber(r,{unit:`hour`}):_V(r,t.length)},m:function(e,t,n){return t===`mo`?n.ordinalNumber(e.getMinutes(),{unit:`minute`}):vV.m(e,t)},s:function(e,t,n){return t===`so`?n.ordinalNumber(e.getSeconds(),{unit:`second`}):vV.s(e,t)},S:function(e,t){return vV.S(e,t)},X:function(e,t,n){let r=e.getTimezoneOffset();if(r===0)return`Z`;switch(t){case`X`:return SV(r);case`XXXX`:case`XX`:return CV(r);default:return CV(r,`:`)}},x:function(e,t,n){let r=e.getTimezoneOffset();switch(t){case`x`:return SV(r);case`xxxx`:case`xx`:return CV(r);default:return CV(r,`:`)}},O:function(e,t,n){let r=e.getTimezoneOffset();switch(t){case`O`:case`OO`:case`OOO`:return`GMT`+xV(r,`:`);default:return`GMT`+CV(r,`:`)}},z:function(e,t,n){let r=e.getTimezoneOffset();switch(t){case`z`:case`zz`:case`zzz`:return`GMT`+xV(r,`:`);default:return`GMT`+CV(r,`:`)}},t:function(e,t,n){return _V(Math.trunc(e.getTime()/1e3),t.length)},T:function(e,t,n){return _V(e.getTime(),t.length)}};function xV(e,t=``){let n=e>0?`-`:`+`,r=Math.abs(e),i=Math.trunc(r/60),a=r%60;return a===0?n+String(i):n+String(i)+t+_V(a,2)}function SV(e,t){return e%60==0?(e>0?`-`:`+`)+_V(Math.abs(e)/60,2):CV(e,t)}function CV(e,t=``){let n=e>0?`-`:`+`,r=Math.abs(e),i=_V(Math.trunc(r/60),2),a=_V(r%60,2);return n+i+t+a}var wV=(e,t)=>{switch(e){case`P`:return t.date({width:`short`});case`PP`:return t.date({width:`medium`});case`PPP`:return t.date({width:`long`});default:return t.date({width:`full`})}},TV=(e,t)=>{switch(e){case`p`:return t.time({width:`short`});case`pp`:return t.time({width:`medium`});case`ppp`:return t.time({width:`long`});default:return t.time({width:`full`})}},EV={p:TV,P:(e,t)=>{let n=e.match(/(P+)(p+)?/)||[],r=n[1],i=n[2];if(!i)return wV(e,t);let a;switch(r){case`P`:a=t.dateTime({width:`short`});break;case`PP`:a=t.dateTime({width:`medium`});break;case`PPP`:a=t.dateTime({width:`long`});break;default:a=t.dateTime({width:`full`});break}return a.replace(`{{date}}`,wV(r,t)).replace(`{{time}}`,TV(i,t))}},DV=/^D+$/,OV=/^Y+$/,kV=[`D`,`DD`,`YY`,`YYYY`];function AV(e){return DV.test(e)}function jV(e){return OV.test(e)}function MV(e,t,n){let r=NV(e,t,n);if(console.warn(r),kV.includes(e))throw RangeError(r)}function NV(e,t,n){let r=e[0]===`Y`?`years`:`days of the month`;return`Use \`${e.toLowerCase()}\` instead of \`${e}\` (in \`${t}\`) for formatting ${r} to the input \`${n}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}var PV=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,FV=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,IV=/^'([^]*?)'?$/,LV=/''/g,RV=/[a-zA-Z]/;function zV(e,t,n){let r=NB(),i=n?.locale??r.locale??dV,a=n?.firstWeekContainsDate??n?.locale?.options?.firstWeekContainsDate??r.firstWeekContainsDate??r.locale?.options?.firstWeekContainsDate??1,o=n?.weekStartsOn??n?.locale?.options?.weekStartsOn??r.weekStartsOn??r.locale?.options?.weekStartsOn??0,s=wB(e);if(!UB(s))throw RangeError(`Invalid time value`);let c=t.match(FV).map(e=>{let t=e[0];if(t===`p`||t===`P`){let n=EV[t];return n(e,i.formatLong)}return e}).join(``).match(PV).map(e=>{if(e===`''`)return{isToken:!1,value:`'`};let t=e[0];if(t===`'`)return{isToken:!1,value:BV(e)};if(bV[t])return{isToken:!0,value:e};if(t.match(RV))throw RangeError("Format string contains an unescaped latin alphabet character `"+t+"`");return{isToken:!1,value:e}});i.localize.preprocessor&&(c=i.localize.preprocessor(s,c));let l={firstWeekContainsDate:a,weekStartsOn:o,locale:i};return c.map(r=>{if(!r.isToken)return r.value;let a=r.value;(!n?.useAdditionalWeekYearTokens&&jV(a)||!n?.useAdditionalDayOfYearTokens&&AV(a))&&MV(a,t,String(e));let o=bV[a[0]];return o(s,a,i.localize,l)}).join(``)}function BV(e){let t=e.match(IV);return t?t[1].replace(LV,`'`):e}function VV(e,t,n){let r=NB(),i=n?.locale??r.locale??dV,a=VB(e,t);if(isNaN(a))throw RangeError(`Invalid time value`);let o=Object.assign({},n,{addSuffix:n?.addSuffix,comparison:a}),s,c;a>0?(s=wB(t),c=wB(e)):(s=wB(e),c=wB(t));let l=ZB(c,s),u=(RB(c)-RB(s))/1e3,d=Math.round((l-u)/60),f;if(d<2)return n?.includeSeconds?l<5?i.formatDistance(`lessThanXSeconds`,5,o):l<10?i.formatDistance(`lessThanXSeconds`,10,o):l<20?i.formatDistance(`lessThanXSeconds`,20,o):l<40?i.formatDistance(`halfAMinute`,0,o):l<60?i.formatDistance(`lessThanXMinutes`,1,o):i.formatDistance(`xMinutes`,1,o):d===0?i.formatDistance(`lessThanXMinutes`,1,o):i.formatDistance(`xMinutes`,d,o);if(d<45)return i.formatDistance(`xMinutes`,d,o);if(d<90)return i.formatDistance(`aboutXHours`,1,o);if(d<1440){let e=Math.round(d/60);return i.formatDistance(`aboutXHours`,e,o)}else if(d<2520)return i.formatDistance(`xDays`,1,o);else if(d<43200){let e=Math.round(d/AB);return i.formatDistance(`xDays`,e,o)}else if(d<43200*2)return f=Math.round(d/kB),i.formatDistance(`aboutXMonths`,f,o);if(f=XB(c,s),f<12){let e=Math.round(d/kB);return i.formatDistance(`xMonths`,e,o)}else{let e=f%12,t=Math.trunc(f/12);return e<3?i.formatDistance(`aboutXYears`,t,o):e<9?i.formatDistance(`overXYears`,t,o):i.formatDistance(`almostXYears`,t+1,o)}}function HV(e,t){return VV(e,Date.now(),t)}function UV(e,t=`dd.MM.yyyy, HH:mm`,n){if(!e)return``;let r=new Date(e);return Number.isNaN(r.getTime())?(console.warn(`Invalid date:`,e),``):zV(r,t,{locale:n})}var WV=()=>globalThis.location.origin,GV=e=>navigator.clipboard.writeText(e),Y=new class{registrations=new Map;register(e,t,n){this.registrations.set(e,{factory:t,scope:n.scope})}get(e){let t=this.registrations.get(e);if(!t)throw Error(`No provider found for ${e.name}`);return t.scope===`singleton`?(t.instance??=t.factory(),t.instance):t.factory()}},KV=class extends Error{constructor(){super(`Aborted`),this.name=`AbortError`}},X=class e{_data=null;_error=null;_isLoading=!1;_isLoaded=!1;_abortController=null;static of(t,n){return new e(t,n)}constructor(e,t){this.fetchFunction=e,this.options=t,f(this)}get data(){return this._data}get isLoading(){return this._isLoading}get isLoaded(){return this._isLoaded}get error(){return this._error}get errorMessage(){return this._error?.response.errors?.[0].message}abort(){this._abortController?.abort(),this._abortController=null}setDataDirectly(e){this._data=e,this._isLoaded=!0}async fetch(...e){this.abort(),this._abortController=new AbortController;let t=this._abortController.signal;this.options?.skipResetting||this.reset();try{this.setIsLoading(!0);let n=await this.fetchFunction(...e);return t.aborted?{isRight:!1,error:new KV}:(this.setData(n),{isRight:!0,data:n})}catch(e){return t.aborted?{isRight:!1,error:new KV}:(console.error(e),this.setError(e),{isRight:!1,error:e})}finally{this.setIsLoading(!1),this.setIsLoaded(!0)}}reset(){this.setIsLoading(!1),this.setData(null),this.setError(null)}setData(e){this._data=e}setIsLoading(e){this._isLoading=e}setIsLoaded(e){this._isLoaded=e}setError(e){this._error=e}};function qV(e){return!e.isRight&&e.error instanceof KV}var JV=class{values;constructor(e){this.values=e,f(this,{},{autoBind:!0})}setValue(e,t){this.values[e]=t}get isValid(){return Object.values(this.values).every(Boolean)}},YV=e=>{if(e&&e.startsWith(`/`)&&!e.startsWith(`//`))return e},XV=e=>{if(!e)return null;try{let t=JSON.parse(e)?.redirect;return typeof t==`string`?t:null}catch{return null}},ZV=e=>{if(e)return JSON.stringify({redirect:e})},QV=()=>YV(new URLSearchParams(globalThis.location.search).get(`redirect`)),$V=e=>{let t=YV(e);return!t||t===`/`?``:`?redirect=${encodeURIComponent(t)}`},eH=function(e){return e.Loading=`loading`,e.Empty=`empty`,e.List=`list`,e.NotFound=`notFound`,e.Error=`error`,e}({}),tH=class{_state=eH.Loading;_items=[];_hasNextPage=!1;_endCursor=null;_totalCount=0;_isInitialLoad=!0;constructor(){f(this,{},{autoBind:!0})}get state(){return this._state}get items(){return this._items}get hasNextPage(){return this._hasNextPage}get endCursor(){return this._endCursor}get totalCount(){return this._totalCount}get isInitialLoad(){return this._isInitialLoad}get showLoading(){return this._state===eH.Loading&&this._isInitialLoad}get showEmpty(){return this._state===eH.Empty}get showNotFound(){return this._state===eH.NotFound}get showList(){return this._state===eH.List}get showError(){return this._state===eH.Error}setLoading(){this._state=eH.Loading}setError(){this._isInitialLoad=!1,this._state=eH.Error}setItems(e,t){this._isInitialLoad=!1,this._items=e,this._hasNextPage=t.hasNextPage,this._endCursor=t.endCursor,this._totalCount=t.totalCount,e.length>0?this._state=eH.List:t.isSearching?this._state=eH.NotFound:this._state=eH.Empty}appendItems(e,t){this._items=[...this._items,...e],this._hasNextPage=t.hasNextPage,this._endCursor=t.endCursor}removeItem(e){let t=this._items.length;this._items=this._items.filter(t=>!e(t));let n=t-this._items.length;this._totalCount=Math.max(0,this._totalCount-n)}updateStateAfterRemove(e){this._items.length===0&&(this._state=e?eH.NotFound:eH.Empty)}reset(){this._items=[],this._hasNextPage=!1,this._endCursor=null,this._isInitialLoad=!1,this._state=eH.Loading}resetToLoading(){this._items=[],this._hasNextPage=!1,this._endCursor=null,this._totalCount=0,this._isInitialLoad=!0,this._state=eH.Loading}},nH=class{cachedItemViewModels=u.map();constructor(e){this.dataSource=e,h(this,{cachedItemViewModels:u,showLoading:a,showEmpty:a,showList:a,showError:a,items:a,totalCount:a,hasNextPage:a,init:m,dispose:m,tryToFetchNextPage:m,getOrCreateItemViewModel:!1})}get showLoading(){return this.dataSource.state===eH.Loading&&this.dataSource.isInitialLoad}get showEmpty(){return this.dataSource.state===eH.Empty}get showList(){return this.dataSource.state===eH.List}get showError(){return this.dataSource.state===eH.Error}get items(){return this.dataSource.items.map(e=>this.getOrCreateItemViewModel(e))}get totalCount(){return this.dataSource.totalCount}get hasNextPage(){return this.dataSource.hasNextPage}init(){this.dataSource.load()}dispose(){this.dataSource.dispose(),this.cachedItemViewModels.clear()}async tryToFetchNextPage(){await this.dataSource.loadNextPage()}getOrCreateItemViewModel(e){let t=this.getItemKey(e),n=this.cachedItemViewModels.get(t);return n||(n=this.createItemViewModel(e),this.cachedItemViewModels.set(t,n)),n}},rH=class{listState=new tH;request;config;constructor(e,t={}){this.request=X.of(e,{skipResetting:!0}),this.config={pageSize:t.pageSize??50},h(this,{items:a,hasNextPage:a,totalCount:a,isLoading:a,isInitialLoad:a,state:a,load:m,loadNextPage:m,reset:m,dispose:m},{autoBind:!0})}get items(){return this.listState.items}get hasNextPage(){return this.listState.hasNextPage}get totalCount(){return this.listState.totalCount}get isLoading(){return this.request.isLoading}get isInitialLoad(){return this.listState.isInitialLoad}get state(){return this.listState.state}async load(e){this.listState.setLoading();let t=await this.request.fetch(this.buildFetchArgs(e));if(!t.isRight){if(qV(t))return;c(()=>{this.listState.setError()});return}c(()=>{let e=this.extractItems(t.data),n=this.extractPageInfo(t.data);this.listState.setItems(e,n)})}async loadNextPage(){if(!this.hasNextPage||this.isLoading)return!1;let e=await this.request.fetch(this.buildFetchArgs(void 0,this.listState.endCursor||void 0));return e.isRight?(c(()=>{let t=this.extractItems(e.data),n=this.extractPageInfo(e.data);this.listState.appendItems(t,{hasNextPage:n.hasNextPage,endCursor:n.endCursor})}),!0):!1}reset(){this.listState.reset(),this.request.abort()}dispose(){this.request.abort()}},iH=class{id=ds();pendingRequestInternal=null;resolverInternal=null;constructor(){h(this,{pendingRequestInternal:u,hasPendingRequest:a,pendingRequest:a,setPendingRequest:m,clearPendingRequest:m})}setResolver(e){this.resolverInternal=e}resolve(e){this.resolverInternal?.(e)}get hasPendingRequest(){return this.pendingRequestInternal!==null}get pendingRequest(){return this.pendingRequestInternal}setPendingRequest(e){this.pendingRequestInternal=e}clearPendingRequest(){this.pendingRequestInternal=null}init(){}dispose(){}};function aH(e,t,n){return{payload:e,resolve:t,reject:n}}var oH=class{stack=[];constructor(){h(this,{stack:u,initStack:m.bound,pushRequest:m.bound,resolveToParent:m.bound,rejectRequest:m.bound,cancelFromItem:m.bound,dispose:m.bound})}initStack(e){this.stack=[e],this.setupItemResolver(e)}pushRequest(e,t,n,r){let i=aH(t,n,r);e.setPendingRequest(i);let a=this.createItemForRequest(i);this.addItem(a)}resolveToParent(e,t){let n=this.stack.indexOf(e);if(n===-1)return;let r=this.stack[n-1];r?.pendingRequest&&(r.pendingRequest.resolve(t),r.clearPendingRequest()),this.stack.splice(n).forEach(e=>e.dispose())}rejectRequest(e){let t=this.stack.indexOf(e);t!==-1&&this.stack.splice(t+1).forEach(e=>e.dispose());let n=t-1;if(n>=0){let e=this.stack[n];e.pendingRequest&&(e.pendingRequest.reject(),e.clearPendingRequest())}}cancelFromItem(e){let t=this.stack.indexOf(e);t!==-1&&(this.stack.splice(t+1).forEach(e=>e.dispose()),e.pendingRequest&&(e.pendingRequest.reject(),e.clearPendingRequest()))}dispose(){this.stack.forEach(e=>e.dispose()),this.stack=[]}addItem(e){this.setupItemResolver(e),this.stack.push(e)}setupItemResolver(e){e.setResolver(t=>this.handleItemResult(e,t))}},sH=class{_isFullscreen=!1;_isInitialized=!1;_containerRef=null;constructor(){h(this,{_isFullscreen:u,_containerRef:u,setContainerRef:m.bound,toggleFullscreen:m.bound,init:m.bound,dispose:m.bound,handleFullscreenChange:m.bound})}get isFullscreen(){return this._isFullscreen}setContainerRef(e){this._containerRef=e}toggleFullscreen(){this._isFullscreen?this.exitFullscreen():this.enterFullscreen()}init(){this._isInitialized||(this._isInitialized=!0,document.addEventListener(`fullscreenchange`,this.handleFullscreenChange))}dispose(){this._isInitialized&&(this._isInitialized=!1,document.removeEventListener(`fullscreenchange`,this.handleFullscreenChange),this._containerRef=null,this._isFullscreen=!1)}async enterFullscreen(){if(this._containerRef)try{await this._containerRef.requestFullscreen()}catch(e){console.error(e)}}async exitFullscreen(){try{await document.exitFullscreen()}catch(e){console.error(e)}}handleFullscreenChange(){this._isFullscreen=document.fullscreenElement===this._containerRef}},cH=class{_timer=null;constructor(e){this.delayMs=e}schedule(e){this.cancel(),this._timer=setTimeout(e,this.delayMs)}cancel(){this._timer&&=(clearTimeout(this._timer),null)}dispose(){this.cancel()}},lH=class{constructor(e,t){this.operator=e,this.value=t,Object.defineProperty(this,`t`,{writable:!0})}get notes(){return this.t}addNote(e){this.t=this.t||[],this.t.push(e)}},uH=class extends lH{},dH=class extends uH{constructor(e,t){if(!Array.isArray(t))throw Error(`"${e}" operator expects to receive an array of conditions`);super(e,t)}},fH=`__itself__`,pH=class extends lH{constructor(e,t,n){super(e,n),this.field=t}},mH=new uH(`__null__`,null),hH=Object.prototype.hasOwnProperty.call.bind(Object.prototype.hasOwnProperty);function gH(e,t){return t instanceof dH&&t.operator===e}function _H(e,t){return t.length===1?t[0]:new dH(e,function e(t,n,r){let i=r||[];for(let r=0,a=n.length;r<a;r++){let a=n[r];gH(t,a)?e(t,a.value,i):i.push(a)}return i}(e,t))}var vH=e=>e,yH=()=>Object.create(null),bH=Object.defineProperty(yH(),`__@type@__`,{value:`ignore value`});function xH(e,t,n=!1){if(!e||e&&e.constructor!==Object)return!1;for(let r in e)if(hH(e,r)&&hH(t,r)&&(!n||e[r]!==bH))return!0;return!1}function SH(e){let t=[];for(let n in e)hH(e,n)&&e[n]!==bH&&t.push(n);return t}function CH(e,t){t!==mH&&e.push(t)}var wH=e=>_H(`and`,e),TH={compound(e,t,n){let r=(Array.isArray(t)?t:[t]).map(e=>n.parse(e));return new dH(e.name,r)},field:(e,t,n)=>new pH(e.name,n.field,t),document:(e,t)=>new uH(e.name,t)},EH=class{constructor(e,t=yH()){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:t.operatorToConditionName||vH,defaultOperatorName:t.defaultOperatorName||`eq`,mergeFinalConditions:t.mergeFinalConditions||wH},this.o=Object.keys(e).reduce((t,n)=>(t[n]=Object.assign({name:this.u.operatorToConditionName(n)},e[n]),t),{}),this.s=Object.assign({},t.fieldContext,{field:``,query:{},parse:this.parse,hasOperators:e=>xH(e,this.o,t.useIgnoreValue)}),this.i=Object.assign({},t.documentContext,{parse:this.parse,query:{}}),this.h=t.useIgnoreValue?SH:Object.keys}setParse(e){this.parse=e,this.s.parse=e,this.i.parse=e}parseField(e,t,n,r){let i=this.o[t];if(!i)throw Error(`Unsupported operator "${t}"`);if(i.type!==`field`)throw Error(`Unexpected ${i.type} operator "${t}" at field level`);return this.s.field=e,this.s.query=r,this.parseInstruction(i,n,this.s)}parseInstruction(e,t,n){return typeof e.validate==`function`&&e.validate(e,t),(e.parse||TH[e.type])(e,t,n)}parseFieldOperators(e,t){let n=[],r=this.h(t);for(let i=0,a=r.length;i<a;i++){let a=r[i];if(!this.o[a])throw Error(`Field query for "${e}" may contain only operators or a plain object as a value`);CH(n,this.parseField(e,a,t[a],t))}return n}parse(e){let t=[],n=this.h(e);this.i.query=e;for(let r=0,i=n.length;r<i;r++){let i=n[r],a=e[i],o=this.o[i];if(o){if(o.type!==`document`&&o.type!==`compound`)throw Error(`Cannot use parsing instruction for operator "${i}" in "document" context as it is supposed to be used in "${o.type}" context`);CH(t,this.parseInstruction(o,a,this.i))}else this.s.hasOperators(a)?t.push(...this.parseFieldOperators(i,a)):CH(t,this.parseField(i,this.u.defaultOperatorName,a,e))}return this.u.mergeFinalConditions(t)}};function DH(e,t){let n=e[t];if(typeof n!=`function`)throw Error(`Unable to interpret "${t}" condition. Did you forget to register interpreter for it?`);return n}function OH(e){return e.operator}function kH(e,t){let n=t,r=n&&n.getInterpreterName||OH,i;switch(n?n.numberOfArguments:0){case 1:i=t=>DH(e,r(t,n))(t,a);break;case 3:i=(t,i,o)=>DH(e,r(t,n))(t,i,o,a);break;default:i=(t,i)=>DH(e,r(t,n))(t,i,a)}let a=Object.assign({},n,{interpret:i});return a.interpret}function AH(e,t){return(n,...r)=>{let i=e(n,...r),a=t.bind(null,i);return a.ast=i,a}}EH.prototype.parseInstruction;function jH(e,t){if(!Array.isArray(t))throw Error(`"${e.name}" expects value to be an array`)}function MH(e,t){if(jH(e,t),!t.length)throw Error(`"${e.name}" expects to have at least one element in array`)}var NH=e=>(t,n)=>{if(typeof n!==e)throw Error(`"${t.name}" expects value to be a "${e}"`)},PH={type:`compound`,validate:MH,parse(e,t,{parse:n}){let r=t.map(e=>n(e));return _H(e.name,r)}},FH=PH,IH={type:`compound`,validate:MH},LH={type:`field`,validate(e,t){if(!(t&&(t instanceof RegExp||t.constructor===Object)))throw Error(`"${e.name}" expects to receive either regular expression or object of field operators`)},parse(e,t,n){let r=t instanceof RegExp?new pH(`regex`,n.field,t):n.parse(t,n);return new dH(e.name,[r])}},RH={type:`field`,validate(e,t){if(!t||t.constructor!==Object)throw Error(`"${e.name}" expects to receive an object with nested query or field level operators`)},parse(e,t,{parse:n,field:r,hasOperators:i}){let a=i(t)?n(t,{field:fH}):n(t);return new pH(e.name,r,a)}},zH={type:`field`,validate:NH(`number`)},BH={type:`field`,validate:jH},VH=BH,HH=BH,UH={type:`field`,validate(e,t){if(!Array.isArray(t)||t.length!==2)throw Error(`"${e.name}" expects an array with 2 numeric elements`)}},WH={type:`field`,validate:NH(`boolean`)},GH={type:`field`,validate:function(e,t){if(!(typeof t==`string`||typeof t==`number`||t instanceof Date))throw Error(`"${e.name}" expects value to be comparable (i.e., string, number or date)`)}},KH=GH,qH=KH,JH=KH,YH={type:`field`},XH=YH,ZH={type:`field`,validate(e,t){if(!(t instanceof RegExp)&&typeof t!=`string`)throw Error(`"${e.name}" expects value to be a regular expression or a string that represents regular expression`)},parse(e,t,n){let r=typeof t==`string`?new RegExp(t,n.query.$options||``):t;return new pH(e.name,n.field,r)}},QH={type:`field`,parse:()=>mH},$H={type:`document`,validate:NH(`function`)},eU=Object.freeze({__proto__:null,$and:PH,$or:FH,$nor:IH,$not:LH,$elemMatch:RH,$size:zH,$in:BH,$nin:VH,$all:HH,$mod:UH,$exists:WH,$gte:GH,$gt:KH,$lt:qH,$lte:JH,$eq:YH,$ne:XH,$regex:ZH,$options:QH,$where:$H}),tU=class extends EH{constructor(e){super(e,{defaultOperatorName:`$eq`,operatorToConditionName:e=>e.slice(1)})}parse(e,t){return t&&t.field?wH(this.parseFieldOperators(t.field,e)):super.parse(e)}},nU=eU;function rU(e,t,n){for(let r=0,i=e.length;r<i;r++)if(n(e[r],t)===0)return!0;return!1}function iU(e,t){return Array.isArray(e)&&Number.isNaN(Number(t))}function aU(e,t,n){if(!iU(e,t))return n(e,t);let r=[];for(let i=0;i<e.length;i++){let a=n(e[i],t);a!==void 0&&(r=r.concat(a))}return r}function oU(e){return(t,n,r)=>{let i=r.get(n,t.field);return Array.isArray(i)?i.some(n=>e(t,n,r)):e(t,i,r)}}var sU=(e,t)=>e[t];function cU(e,t,n){let r=t.lastIndexOf(`.`);return r===-1?[e,t]:[n(e,t.slice(0,r)),t.slice(r+1)]}function lU(e,t,n=sU){if(t===`__itself__`)return e;if(!e)throw Error(`Unable to get field "${t}" out of ${String(e)}.`);return function(e,t,n){if(t.indexOf(`.`)===-1)return aU(e,t,n);let r=t.split(`.`),i=e;for(let e=0,t=r.length;e<t;e++)if(i=aU(i,r[e],n),!i||typeof i!=`object`)return i;return i}(e,t,n)}function uU(e,t){return e===t?0:e>t?1:-1}function dU(e,t={}){return kH(e,Object.assign({get:lU,compare:uU},t))}var fU=(e,t,{interpret:n})=>e.value.some(e=>n(e,t)),pU=(e,t,n)=>!fU(e,t,n),mU=(e,t,{interpret:n})=>e.value.every(e=>n(e,t)),hU=(e,t,{interpret:n})=>!n(e.value[0],t),gU=(e,t,{compare:n,get:r})=>{let i=r(t,e.field);return Array.isArray(i)&&!Array.isArray(e.value)?rU(i,e.value,n):n(i,e.value)===0},_U=(e,t,n)=>!gU(e,t,n),vU=oU((e,t,n)=>{let r=n.compare(t,e.value);return r===0||r===-1}),yU=oU((e,t,n)=>n.compare(t,e.value)===-1),bU=oU((e,t,n)=>n.compare(t,e.value)===1),xU=oU((e,t,n)=>{let r=n.compare(t,e.value);return r===0||r===1}),SU=(e,t,{get:n})=>{if(e.field===`__itself__`)return t!==void 0;let[r,i]=cU(t,e.field,n),a=t=>t==null?!!t===e.value:t.hasOwnProperty(i)===e.value;return iU(r,i)?r.some(a):a(r)},CU=oU((e,t)=>typeof t==`number`&&t%e.value[0]===e.value[1]),wU=(e,t,{get:n})=>{let[r,i]=cU(t,e.field,n),a=t=>{let r=n(t,i);return Array.isArray(r)&&r.length===e.value};return e.field!==`__itself__`&&iU(r,i)?r.some(a):a(r)},TU=oU((e,t)=>typeof t==`string`&&e.value.test(t)),EU=oU((e,t,{compare:n})=>rU(e.value,t,n)),DU=(e,t,n)=>!EU(e,t,n),OU=(e,t,{compare:n,get:r})=>{let i=r(t,e.field);return Array.isArray(i)&&e.value.every(e=>rU(i,e,n))},kU=(e,t,{interpret:n,get:r})=>{let i=r(t,e.field);return Array.isArray(i)&&i.some(t=>n(e.value,t))},AU=Object.freeze({__proto__:null,or:fU,nor:pU,and:mU,not:hU,eq:gU,ne:_U,lte:vU,lt:yU,gt:bU,gte:xU,exists:SU,mod:CU,size:wU,regex:TU,within:EU,nin:DU,all:OU,elemMatch:kU,where:(e,t)=>e.value.call(t)}),jU=Object.assign({},AU,{in:EU});dU(jU);function MU(e){return typeof e!=`object`||!e?e:e instanceof Date?e.getTime():e&&typeof e.toJSON==`function`?e.toJSON():e}var NU=(e,t)=>uU(MU(e),MU(t));function PU(e,t,n){let r=new tU(e),i=dU(t,Object.assign({compare:NU},n));if(n&&n.forPrimitives){let e={field:fH},t=r.parse;r.setParse(n=>t(n,e))}return AH(r.parse,i)}PU(nU,jU),PU([`$and`,`$or`].reduce((e,t)=>(e[t]=Object.assign({},e[t],{type:`field`}),e),Object.assign({},nU,{$nor:Object.assign({},nU.$nor,{type:`field`,parse:TH.compound})})),jU,{forPrimitives:!0});var FU=Object.hasOwn||((e,t)=>Object.prototype.hasOwnProperty.call(e,t));function IU(e){return Array.isArray(e)?e:[e]}var LU=`__caslSubjectType__`;function RU(e,t){if(t){if(!FU(t,LU))Object.defineProperty(t,LU,{value:e});else if(e!==t[LU])throw Error(`Trying to cast object to subject type ${e} but previously it was casted to ${t[LU]}`)}return t}var zU=e=>{let t=typeof e;return t===`string`||t===`function`},BU=e=>e.modelName||e.name;function VU(e){return typeof e==`string`?e:BU(e)}function HU(e){return FU(e,LU)?e[LU]:BU(e.constructor)}var UU={function:e=>e.constructor,string:HU};function WU(e,t,n){for(let r=n;r<t.length;r++)e.push(t[r])}function GU(e,t){if(!e||!e.length)return t||[];if(!t||!t.length)return e||[];let n=0,r=0,i=[];for(;n<e.length&&r<t.length;)e[n].priority<t[r].priority?(i.push(e[n]),n++):(i.push(t[r]),r++);return WU(i,e,n),WU(i,t,r),i}function KU(e,t,n){let r=e.get(t);return r||(r=n(),e.set(t,r)),r}var qU=e=>e;function JU(e,t){if(Array.isArray(e.fields)&&!e.fields.length)throw Error("`rawRule.fields` cannot be an empty array. https://bit.ly/390miLa");if(e.fields&&!t.fieldMatcher)throw Error(`You need to pass "fieldMatcher" option in order to restrict access by fields`);if(e.conditions&&!t.conditionsMatcher)throw Error(`You need to pass "conditionsMatcher" option in order to restrict access by conditions`)}var YU=class{constructor(e,t,n=0){JU(e,t),this.action=t.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?IU(e.fields):void 0,this.priority=n,this.t=t}i(){return this.conditions&&!this.o&&(this.o=this.t.conditionsMatcher(this.conditions)),this.o}get ast(){let e=this.i();return e?e.ast:void 0}matchesConditions(e){return this.conditions?!e||zU(e)?!this.inverted:this.i()(e):!0}matchesField(e){return this.fields?e?(this.u||=this.t.fieldMatcher(this.fields),this.u(e)):!this.inverted:!0}};function XU(e,t){let n={value:e,prev:t,next:null};return t&&(t.next=n),n}function ZU(e){e.next&&(e.next.prev=e.prev),e.prev&&(e.prev.next=e.next),e.next=e.prev=null}var QU=e=>({value:e.value,prev:e.prev,next:e.next}),$U=()=>({rules:[],merged:!1}),eW=()=>new Map,tW=class{constructor(e=[],t={}){this.h=!1,this.l=new Map,this.p={conditionsMatcher:t.conditionsMatcher,fieldMatcher:t.fieldMatcher,resolveAction:t.resolveAction||qU},this.$=t.anyAction||`manage`,this.A=t.anySubjectType||`all`,this.m=e,this.M=!!t.detectSubjectType,this.j=t.detectSubjectType||HU,this.v(e)}get rules(){return this.m}detectSubjectType(e){return zU(e)?e:e?this.j(e):this.A}update(e){let t={rules:e,ability:this,target:this};return this._(`update`,t),this.m=e,this.v(e),this._(`updated`,t),this}v(e){let t=new Map,n;for(let r=e.length-1;r>=0;r--){let i=e.length-r-1,a=new YU(e[r],this.p,i),o=IU(a.action),s=IU(a.subject||this.A);!this.h&&a.fields&&(this.h=!0);for(let e=0;e<s.length;e++){let r=KU(t,s[e],eW);n===void 0&&(n=typeof s[e]),typeof s[e]!==n&&n!==`mixed`&&(n=`mixed`);for(let e=0;e<o.length;e++)KU(r,o[e],$U).rules.push(a)}}this.l=t,n!==`mixed`&&!this.M&&(this.j=UU[n]||UU.string)}possibleRulesFor(e,t=this.A){if(!zU(t))throw Error(`"possibleRulesFor" accepts only subject types (i.e., string or class) as the 2nd parameter`);let n=KU(this.l,t,eW),r=KU(n,e,$U);if(r.merged)return r.rules;let i=e!==this.$&&n.has(this.$)?n.get(this.$).rules:void 0,a=GU(r.rules,i);return t!==this.A&&(a=GU(a,this.possibleRulesFor(e,this.A))),r.rules=a,r.merged=!0,a}rulesFor(e,t,n){let r=this.possibleRulesFor(e,t);if(n&&typeof n!=`string`)throw 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?r.filter(e=>e.matchesField(n)):r}actionsFor(e){if(!zU(e))throw Error(`"actionsFor" accepts only subject types (i.e., string or class) as a parameter`);let t=new Set,n=this.l.get(e);n&&Array.from(n.keys()).forEach(e=>t.add(e));let r=e===this.A?void 0:this.l.get(this.A);return r&&Array.from(r.keys()).forEach(e=>t.add(e)),Array.from(t)}on(e,t){this.F=this.F||new Map;let n=this.F,r=XU(t,n.get(e)||null);return n.set(e,r),()=>{let t=n.get(e);!r.next&&!r.prev&&t===r?n.delete(e):r===t&&n.set(e,r.prev),ZU(r)}}_(e,t){if(!this.F)return;let n=this.F.get(e)||null;for(;n!==null;){let e=n.prev?QU(n.prev):null;n.value(t),n=e}}},nW=class extends tW{can(e,t,n){let r=this.relevantRuleFor(e,t,n);return!!r&&!r.inverted}relevantRuleFor(e,t,n){let r=this.detectSubjectType(t),i=this.rulesFor(e,r,n);for(let e=0,n=i.length;e<n;e++)if(i[e].matchesConditions(t))return i[e];return null}cannot(e,t,n){return!this.can(e,t,n)}},rW=PU({$eq:YH,$ne:XH,$lt:qH,$lte:JH,$gt:KH,$gte:GH,$in:BH,$nin:VH,$all:HH,$size:zH,$regex:ZH,$options:QH,$elemMatch:RH,$exists:WH},{eq:gU,ne:_U,lt:yU,lte:vU,gt:bU,gte:xU,in:EU,nin:DU,all:OU,size:wU,regex:TU,elemMatch:kU,exists:SU,and:mU}),iW=/[-/\\^$+?.()|[\]{}]/g,aW=/\.?\*+\.?/g,oW=/\*+/,sW=/\./g;function cW(e,t,n){let r=n[0]===`*`||e[0]===`.`&&e[e.length-1]===`.`?`+`:`*`,i=e.indexOf(`**`)===-1?`[^.]`:`.`,a=e.replace(sW,`\\$&`).replace(oW,i+r);return t+e.length===n.length?`(?:${a})?`:a}function lW(e,t,n){return e===`.`&&(n[t-1]===`*`||n[t+1]===`*`)?e:`\\${e}`}function uW(e){let t=e.map(e=>e.replace(iW,lW).replace(aW,cW)),n=t.length>1?`(?:${t.join(`|`)})`:t[0];return RegExp(`^${n}$`)}var dW=e=>{let t;return n=>(t===void 0&&(t=e.every(e=>e.indexOf(`*`)===-1)?null:uW(e)),t===null?e.indexOf(n)!==-1:t.test(n))};function fW(e=[],t={}){return new nW(e,Object.assign({conditionsMatcher:rW,fieldMatcher:dW},t))}var pW=e=>`Cannot execute "${e.action}" on "${e.subjectType}"`,mW=function(e){this.message=e};mW.prototype=Object.create(Error.prototype);var hW=class extends mW{static setDefaultMessage(e){this.P=typeof e==`string`?()=>e:e}static from(e){return new this(e)}constructor(e){super(``),this.ability=e,typeof Error.captureStackTrace==`function`&&(this.name=`ForbiddenError`,Error.captureStackTrace(this,this.constructor))}setMessage(e){return this.message=e,this}throwUnlessCan(e,t,n){let r=this.unlessCan(e,t,n);if(r)throw r}unlessCan(e,t,n){let r=this.ability.relevantRuleFor(e,t,n);if(r&&!r.inverted)return;this.action=e,this.subject=t,this.subjectType=VU(this.ability.detectSubjectType(t)),this.field=n;let i=r?r.reason:``;return this.message=this.message||i||this.constructor.P(this),this}};hW.P=pW,Object.freeze({__proto__:null});var gW=new Set([`read-project-private`,`read-project-public`]),_W=[`Table`,`Row`,`Branch`,`Revision`,`Endpoint`],vW=class{ability=fW();loadedScopes=new Set;addSystemPermissions(e){let t=this.scopeToKey({type:`system`});if(this.loadedScopes.has(t))return;let n=this.permissionsToRules(e,null),r=this.expandPermissions(e,null);this.ability.update([...this.ability.rules,...n,...r]),this.loadedScopes.add(t)}addOrganizationPermissions(e,t){let n=this.scopeToKey({type:`organization`,organizationId:e});if(this.loadedScopes.has(n))return;let r={organizationId:e},i=this.permissionsToRules(t,r),a=this.expandPermissions(t,r);this.ability.update([...this.ability.rules,...i,...a]),this.loadedScopes.add(n)}addProjectPermissions(e,t){let n=this.scopeToKey({type:`project`,projectId:e});if(this.loadedScopes.has(n))return;let r={projectId:e},i=this.permissionsToRules(t,r),a=this.expandPermissions(t,r);this.ability.update([...this.ability.rules,...i,...a]),this.loadedScopes.add(n)}addPublicReadPermissions(e){let t=`public:${e}`;if(this.loadedScopes.has(t))return;let n={projectId:e},r={action:`read`,subject:`Project`,conditions:{...n,isPublic:!0}},i=_W.map(e=>({action:`read`,subject:e,conditions:{...n}}));this.ability.update([...this.ability.rules,r,...i]),this.loadedScopes.add(t)}can(e,t,n){let r=RU(t,n?{...n}:{});return this.ability.can(e,r)}cannot(e,t,n){return!this.can(e,t,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,t){return e.map(e=>this.permissionToRule(e,t))}permissionToRule(e,t){let n={action:e.action,subject:e.subject},r=this.mergeConditions(e.condition,t);return r&&(n.conditions=r),n}mergeConditions(e,t){let n=e&&Object.keys(e).length>0,r=t&&Object.keys(t).length>0;if(!(!n&&!r))return n&&r?{...e,...t}:n?{...e}:{...t}}expandPermissions(e,t){let n=[];for(let r of e)if(gW.has(r.id))for(let e of _W){let r={action:`read`,subject:e};t&&Object.keys(t).length>0&&(r.conditions={...t}),n.push(r)}return n}};Y.register(vW,()=>new vW,{scope:`singleton`});var yW=class{constructor(e){this.permissionService=e,f(this,{},{autoBind:!0})}setUserRole(e){if(e?.permissions){let t=e.permissions.map(e=>({id:e.id,action:e.action,subject:e.subject,condition:e.condition??null}));this.permissionService.addSystemPermissions(t)}}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`)}};Y.register(yW,()=>new yW(Y.get(vW)),{scope:`singleton`});var bW=class{_contextProvider=null;constructor(e){this.permissionService=e,f(this,{},{autoBind:!0})}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(){let e=this.context,t={};return e.projectId&&(t.projectId=e.projectId),e.organizationId&&(t.organizationId=e.organizationId),t}can(e,t,n){let r=n??this.getProjectContext();return this.permissionService.can(e,t,Object.keys(r).length>0?r: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 canManageApiKeys(){return this.can(`manage`,`ApiKey`)}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}};Y.register(bW,()=>new bW(Y.get(vW)),{scope:`singleton`});var xW;n((()=>{xW=function(){return xW=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},xW.apply(this,arguments)}}))();var SW=new Map,CW=new Map,wW=!0,TW=!1;function EW(e){return e.replace(/[\s,]+/g,` `).trim()}function DW(e){return EW(e.source.body.substring(e.start,e.end))}function OW(e){var t=new Set,n=[];return e.definitions.forEach(function(e){if(e.kind===`FragmentDefinition`){var r=e.name.value,i=DW(e.loc),a=CW.get(r);a&&!a.has(i)?wW&&console.warn(`Warning: fragment with name `+r+` already exists.
382
+ `))}catch{return Promise.resolve()}}async function ZR(e,t,n,r){let i;try{i=await navigator.clipboard.readText()}catch{return}let a=JR(i);for(let[i,o]of a.entries()){let a=n[e+i];if(!a)break;for(let[e,n]of o.entries()){let i=r[t+e];if(!i)break;let o=a.getCellVM(i);o.isEditable&&o.applyPastedText(n)}}}function QR(e,t,n){let r=e.focusedCell;if(!r)return null;let i=t.findIndex(e=>e.field===r.field),a=n.findIndex(e=>e.rowId===r.rowId);return i===-1||a===-1?null:{colIndex:i,rowIndex:a}}function $R(e,t,n){for(let r=e.startRow;r<=e.endRow;r++)for(let i=e.startCol;i<=e.endCol;i++){let e=t[r],a=n[i];e&&a&&e.getCellVM(a).clearToDefault()}}var ez=`#ededed`,tz=`inset 0 -1px 0 0 ${ez}`;function nz(){return{"&::after":{content:`""`,position:`absolute`,top:0,bottom:0,width:`8px`,left:`-8px`,pointerEvents:`none`,transition:`opacity 0.15s`,opacity:`var(--shadow-right-opacity, 0)`,boxShadow:`inset -8px 0 12px -8px rgba(0,0,0,0.1)`}}}function rz(e,t){return t<=0?e:e===`0px`?`${t}px`:`calc(${e} + ${t}px)`}var iz=40,az=g(({field:e,columnsModel:t})=>{let[n,r]=(0,L.useState)(!1),i=(0,L.useRef)(0),a=(0,L.useRef)(0),o=(0,L.useRef)(0),s=(0,L.useRef)(null);return(0,L.useEffect)(()=>()=>{s.current&&s.current()},[]),(0,I.jsx)(A,{role:`separator`,position:`absolute`,right:`-4px`,top:0,bottom:0,width:`8px`,cursor:`col-resize`,zIndex:10,onMouseDown:(0,L.useCallback)(n=>{n.preventDefault(),n.stopPropagation();let c=t.resolveColumnWidth(e);i.current=n.clientX,a.current=c,r(!0),document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`;let l=n=>{cancelAnimationFrame(o.current),o.current=requestAnimationFrame(()=>{let r=n.clientX-i.current,o=Math.max(iz,a.current+r);t.setColumnWidth(e,o)})},u=()=>{cancelAnimationFrame(o.current),t.commitColumnWidth(),r(!1),document.body.style.cursor=``,document.body.style.userSelect=``,document.removeEventListener(`mousemove`,l),document.removeEventListener(`mouseup`,d),s.current=null},d=()=>{u()};s.current=u,document.addEventListener(`mousemove`,l),document.addEventListener(`mouseup`,d)},[e,t]),"data-testid":`resize-${e}`,children:(0,I.jsx)(A,{position:`absolute`,left:`3px`,top:0,bottom:0,width:`2px`,bg:n?`blue.500`:`transparent`,_groupHover:{bg:`blue.500`},transition:`background 0.1s`})})}),oz=g(({field:e,sortModel:t})=>{let n=t.getSortDirection(e),r=t.getSortIndex(e),i=t.sortCount>1;return n?(0,I.jsxs)(j,{alignItems:`center`,gap:`1px`,color:`blue.500`,fontSize:`xs`,flexShrink:0,"data-testid":`sort-indicator-${e}`,children:[n===`asc`?(0,I.jsx)(uk,{size:12}):(0,I.jsx)(ak,{size:12}),i&&r!==null&&(0,I.jsx)(A,{as:`span`,fontSize:`10px`,fontWeight:`medium`,lineHeight:1,children:r})]}):null}),sz=g(({field:e,columnsModel:t})=>t.isPinned(e)?(0,I.jsx)(j,{alignItems:`center`,color:`gray.400`,flexShrink:0,"data-testid":`pin-indicator-${e}`,children:(0,I.jsx)(Ck,{size:12})}):null),cz=g(({field:e,filterModel:t})=>t.hasFilterForField(e)?(0,I.jsx)(j,{alignItems:`center`,color:`gray.400`,flexShrink:0,"data-testid":`filter-indicator-${e}`,children:(0,I.jsx)(yk,{size:12})}):null),lz=({column:e})=>e.hasFormula?(0,I.jsx)(j,{alignItems:`center`,color:`gray.400`,flexShrink:0,"data-testid":`formula-indicator-${e.field}`,children:(0,I.jsx)(Yf,{size:12})}):null,uz=g(({field:e,sortModel:t})=>{let n=t.getSortDirection(e),r=t.isSorted(e);return(0,I.jsxs)(en,{positioning:{placement:`right-start`,gutter:2},lazyMount:!0,unmountOnExit:!0,children:[(0,I.jsxs)(nn,{children:[(0,I.jsx)(k,{flex:1,children:`Sort`}),(0,I.jsx)(mk,{})]}),(0,I.jsx)(R,{children:(0,I.jsx)(Ot,{children:(0,I.jsxs)(v,{minW:`160px`,children:[(0,I.jsxs)(gt,{value:`sort-asc`,onClick:()=>{t.setSingleSort(e,`asc`)},color:n===`asc`?`blue.600`:void 0,children:[(0,I.jsx)(ck,{}),(0,I.jsx)(k,{children:`Sort A → Z`})]}),(0,I.jsxs)(gt,{value:`sort-desc`,onClick:()=>{t.setSingleSort(e,`desc`)},color:n===`desc`?`blue.600`:void 0,children:[(0,I.jsx)(ik,{}),(0,I.jsx)(k,{children:`Sort Z → A`})]}),r&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(dt,{}),(0,I.jsxs)(gt,{value:`remove-sort`,onClick:()=>{t.removeSort(e)},children:[(0,I.jsx)(Dk,{}),(0,I.jsx)(k,{children:`Remove sort`})]})]})]})})})]})}),dz=g(({field:e,columnsModel:t})=>{let n=t.canMoveLeft(e),r=t.canMoveRight(e),i=t.canMoveToStart(e),a=t.canMoveToEnd(e);return!n&&!r?null:(0,I.jsxs)(en,{positioning:{placement:`right-start`,gutter:2},lazyMount:!0,unmountOnExit:!0,children:[(0,I.jsxs)(nn,{children:[(0,I.jsx)(k,{flex:1,children:`Move column`}),(0,I.jsx)(mk,{})]}),(0,I.jsx)(R,{children:(0,I.jsx)(Ot,{children:(0,I.jsxs)(v,{minW:`160px`,children:[n&&(0,I.jsxs)(gt,{value:`move-left`,onClick:()=>t.moveColumnLeft(e),children:[(0,I.jsx)(pk,{}),(0,I.jsx)(k,{children:`Move left`})]}),i&&(0,I.jsxs)(gt,{value:`move-to-start`,onClick:()=>t.moveColumnToStart(e),children:[(0,I.jsx)(ok,{}),(0,I.jsx)(k,{children:`Move to start`})]}),r&&(0,I.jsxs)(gt,{value:`move-right`,onClick:()=>t.moveColumnRight(e),children:[(0,I.jsx)(mk,{}),(0,I.jsx)(k,{children:`Move right`})]}),a&&(0,I.jsxs)(gt,{value:`move-to-end`,onClick:()=>t.moveColumnToEnd(e),children:[(0,I.jsx)(sk,{}),(0,I.jsx)(k,{children:`Move to end`})]})]})})})]})}),fz=(0,L.memo)(({field:e,name:t,fieldType:n,valuePrefix:r,onClick:i})=>(0,I.jsx)(gt,{value:r?`${r}-${e}`:e,onClick:()=>i(e),children:(0,I.jsxs)(A,{display:`flex`,alignItems:`center`,gap:2,width:`100%`,children:[(0,I.jsx)(A,{as:`span`,fontSize:`xs`,fontWeight:`medium`,color:`gray.400`,fontFamily:`mono`,minWidth:`20px`,children:sL(n)}),(0,I.jsx)(k,{truncate:!0,children:t||`(unnamed)`})]})})),pz=({group:e,parentVisible:t,valuePrefix:n,onClick:r})=>e.children.length===0&&!t?(0,I.jsx)(fz,{field:e.parent.field,name:e.parent.label,fieldType:e.parent.fieldType,valuePrefix:n,onClick:r}):(0,I.jsxs)(en,{positioning:{placement:`right-start`,gutter:2},lazyMount:!0,unmountOnExit:!0,children:[(0,I.jsxs)(nn,{"data-testid":`file-group-${e.parent.field}`,children:[(0,I.jsxs)(A,{display:`flex`,alignItems:`center`,gap:2,flex:1,children:[(0,I.jsx)(A,{as:`span`,fontSize:`xs`,fontWeight:`medium`,color:`gray.400`,fontFamily:`mono`,minWidth:`20px`,children:sL(e.parent.fieldType)}),(0,I.jsx)(k,{truncate:!0,children:e.parent.label})]}),(0,I.jsx)(mk,{})]}),(0,I.jsx)(R,{children:(0,I.jsx)(Ot,{children:(0,I.jsxs)(v,{maxH:`300px`,minW:`200px`,overflowY:`auto`,children:[!t&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(fz,{field:e.parent.field,name:e.parent.label,fieldType:e.parent.fieldType,valuePrefix:n,onClick:r}),(0,I.jsx)(dt,{})]}),e.children.map(e=>(0,I.jsx)(fz,{field:e.field,name:e.label,fieldType:e.fieldType,valuePrefix:n,onClick:r},e.field))]})})})]}),mz=({label:e,valuePrefix:t,availableFields:n,allColumns:r,onSelect:i})=>{if(n.length===0)return null;let a=EI(n,r);return(0,I.jsxs)(en,{positioning:{placement:`right-start`,gutter:2},lazyMount:!0,unmountOnExit:!0,children:[(0,I.jsxs)(nn,{children:[(0,I.jsx)(k,{flex:1,children:e}),(0,I.jsx)(mk,{})]}),(0,I.jsx)(R,{children:(0,I.jsx)(Ot,{children:(0,I.jsx)(v,{maxH:`300px`,minW:`200px`,overflowY:`auto`,children:a.map(e=>TI(e)?(0,I.jsx)(pz,{group:e,parentVisible:e.parentVisible,valuePrefix:t,onClick:i},e.parent.field):(0,I.jsx)(fz,{field:e.field,name:e.label,fieldType:e.fieldType,valuePrefix:t,onClick:i},e.field))})})})]})},hz=g(({column:e,columnsModel:t,sortModel:n,filterModel:r,onCopyPath:i,onClose:a})=>{let o=t.canRemoveColumn,s=t.availableFieldsToInsert,c=s.length>0,l=t.canMoveLeft(e.field)||t.canMoveRight(e.field),u=t.isPinned(e.field),d=t.canPinLeft(e.field),f=t.canPinRight(e.field);return(0,I.jsxs)(v,{minW:`180px`,children:[n&&e.isSortable&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(uz,{field:e.field,sortModel:n}),(0,I.jsx)(dt,{})]}),r&&e.isSortable&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(gt,{value:`add-filter`,onClick:()=>{r&&(r.addConditionForField(e.field),r.setOpen(!0))},children:[(0,I.jsx)(yk,{}),(0,I.jsx)(k,{children:`Add filter`})]}),(0,I.jsx)(dt,{})]}),u?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(gt,{value:`unpin`,onClick:()=>{t.unpin(e.field)},children:[(0,I.jsx)(Sk,{}),(0,I.jsx)(k,{children:`Unpin column`})]}),(0,I.jsx)(dt,{})]}):(0,I.jsxs)(I.Fragment,{children:[d&&(0,I.jsxs)(gt,{value:`pin-left`,onClick:()=>{t.pinLeft(e.field)},children:[(0,I.jsx)(Ck,{}),(0,I.jsx)(k,{children:`Pin to left`})]}),f&&(0,I.jsxs)(gt,{value:`pin-right`,onClick:()=>{t.pinRight(e.field)},children:[(0,I.jsx)(Ck,{}),(0,I.jsx)(k,{children:`Pin to right`})]}),(d||f)&&(0,I.jsx)(dt,{})]}),l&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(dz,{field:e.field,columnsModel:t}),(0,I.jsx)(dt,{})]}),c&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(mz,{label:`Insert before`,valuePrefix:`before`,availableFields:s,allColumns:t.allColumns,onSelect:n=>{t.insertColumnBefore(e.field,n),a?.()}}),(0,I.jsx)(mz,{label:`Insert after`,valuePrefix:`after`,availableFields:s,allColumns:t.allColumns,onSelect:n=>{t.insertColumnAfter(e.field,n),a?.()}}),(0,I.jsx)(dt,{})]}),(0,I.jsxs)(gt,{value:`hide`,disabled:!o,onClick:()=>{t.hideColumn(e.field)},children:[(0,I.jsx)(dne,{}),(0,I.jsx)(k,{children:`Hide column`})]}),(0,I.jsxs)(gt,{value:`hide-all`,disabled:!o,onClick:t.hideAll,children:[(0,I.jsx)(Qf,{}),(0,I.jsx)(k,{children:`Hide all columns`})]}),(0,I.jsx)(dt,{}),(0,I.jsxs)(gt,{value:`copy-path`,onClick:()=>{i?i(e.field):navigator.clipboard.writeText(e.field).catch(()=>{})},children:[(0,I.jsx)(vk,{}),(0,I.jsx)(k,{children:`Copy path`})]})]})});function gz(e){return{"&::after":{content:`""`,position:`absolute`,top:0,bottom:0,width:`8px`,pointerEvents:`none`,transition:`opacity 0.15s`,opacity:e.side===`left`?`var(--shadow-left-opacity, 0)`:`var(--shadow-right-opacity, 0)`,...e.side===`left`?{right:`-8px`,boxShadow:`inset 8px 0 12px -8px rgba(0,0,0,0.1)`}:{left:`-8px`,boxShadow:`inset -8px 0 12px -8px rgba(0,0,0,0.1)`}}}}function _z(e){return e?`${tz}, ${e.side===`left`?`inset -1px 0 0 0 ${ez}`:`inset 1px 0 0 0 ${ez}`}`:tz}var vz=g(({column:e,columnsModel:t,sortModel:n,filterModel:r,onCopyPath:i,stickyPosition:a})=>{let[o,s]=(0,L.useState)(!1),c=t.columnWidthCssVar(e.field),l=!!a;return(0,I.jsxs)(A,{as:`th`,position:l?`sticky`:`relative`,left:a?.side===`left`?a.offsetCss:void 0,right:a?.side===`right`?a.offsetCss:void 0,zIndex:l?2:void 0,width:c,minWidth:c,maxWidth:c,height:`inherit`,bg:`white`,boxShadow:_z(a),textAlign:`left`,fontWeight:`normal`,p:0,css:a?.isBoundary?gz(a):void 0,children:[(0,I.jsxs)(en,{positioning:{placement:`bottom-end`},lazyMount:!0,unmountOnExit:!0,open:o,onOpenChange:e=>s(e.open),children:[(0,I.jsx)(Lt,{asChild:!0,children:(0,I.jsxs)(j,{alignItems:`center`,height:`100%`,pl:`8px`,pr:`16px`,gap:`4px`,cursor:`pointer`,transition:`background 0.15s`,overflow:`hidden`,_hover:{bg:`gray.100`},"data-testid":`header-${e.field}`,children:[(0,I.jsx)(j,{alignItems:`center`,justifyContent:`center`,flexShrink:0,fontSize:`xs`,color:`gray.400`,width:`16px`,children:sL(e.fieldType)}),(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`500`,color:`gray.400`,whiteSpace:`nowrap`,textOverflow:`ellipsis`,overflow:`hidden`,flex:1,minWidth:0,textDecoration:e.isDeprecated?`line-through`:void 0,children:e.label}),(0,I.jsx)(lz,{column:e}),(0,I.jsx)(sz,{field:e.field,columnsModel:t}),r&&e.isSortable&&(0,I.jsx)(cz,{field:e.field,filterModel:r}),n&&e.isSortable&&(0,I.jsx)(oz,{field:e.field,sortModel:n})]})}),(0,I.jsx)(R,{children:(0,I.jsx)(Ot,{children:(0,I.jsx)(hz,{column:e,columnsModel:t,sortModel:n,filterModel:r,onCopyPath:i,onClose:()=>s(!1)})})})]}),(0,I.jsx)(az,{field:e.field,columnsModel:t})]})}),yz=g(({columnsModel:e})=>{let t=e.availableFieldsToAdd,n=e.availableSystemFieldsToAdd;if(!e.hasHiddenColumns)return null;let r=EI(t,e.allColumns);return(0,I.jsx)(j,{alignItems:`center`,px:`4px`,height:`100%`,children:(0,I.jsxs)(en,{positioning:{placement:`bottom-start`},lazyMount:!0,unmountOnExit:!0,children:[(0,I.jsx)(Lt,{asChild:!0,children:(0,I.jsx)(Ze,{"aria-label":`Add column`,size:`xs`,variant:`ghost`,color:`gray.400`,_hover:{bg:`gray.100`,color:`gray.600`},focusRing:`none`,"data-testid":`add-column-button`,children:(0,I.jsx)(ep,{})})}),(0,I.jsx)(R,{children:(0,I.jsx)(Ot,{children:(0,I.jsxs)(v,{minW:`200px`,maxH:`340px`,overflowY:`auto`,children:[(0,I.jsxs)(gt,{value:`add-all`,onClick:e.addAll,children:[(0,I.jsx)(Qf,{}),(0,I.jsx)(k,{children:`Add all columns`})]}),r.length>0&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(dt,{}),(0,I.jsxs)(tn,{children:[(0,I.jsx)(Ut,{fontWeight:`medium`,color:`gray.500`,fontSize:`xs`,children:`Data fields`}),r.map(t=>TI(t)?(0,I.jsx)(pz,{group:t,parentVisible:t.parentVisible,onClick:e.showColumn},t.parent.field):(0,I.jsx)(fz,{field:t.field,name:t.label,fieldType:t.fieldType,onClick:e.showColumn},t.field))]})]}),n.length>0&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(dt,{}),(0,I.jsxs)(tn,{children:[(0,I.jsx)(Ut,{fontWeight:`medium`,color:`gray.500`,fontSize:`xs`,children:`System fields`}),n.map(t=>(0,I.jsx)(fz,{field:t.field,name:t.label,fieldType:t.fieldType,onClick:e.showColumn},t.field))]})]})]})})})]})})}),bz=40,xz=40,Sz=g(({columnsModel:e,sortModel:t,filterModel:n,onCopyPath:r,showSelection:i})=>{let a=i?bz:0,o=e.hasHiddenColumns;return(0,I.jsxs)(A,{as:`tr`,height:`40px`,children:[i&&(0,I.jsx)(A,{as:`th`,width:`40px`,minWidth:`40px`,maxWidth:`40px`,bg:`white`,p:0,position:`sticky`,left:0,zIndex:2,boxShadow:tz}),e.visibleColumns.map(i=>(0,I.jsx)(vz,{column:i,columnsModel:e,sortModel:t,filterModel:n,onCopyPath:r,stickyPosition:Cz(i.field,e,a,o)},i.field)),o?(0,I.jsx)(A,{as:`th`,width:`100%`,minWidth:`${xz}px`,bg:`white`,p:0,position:`sticky`,right:0,zIndex:2,boxShadow:tz,css:e.pinnedRightCount===0?nz():void 0,children:(0,I.jsx)(yz,{columnsModel:e})}):(0,I.jsx)(A,{as:`th`,width:`100%`,bg:`white`,p:0,boxShadow:tz})]})});function Cz(e,t,n,r){let i=t.getColumnStickyLeftCss(e,n);if(i!==void 0)return{side:`left`,offsetCss:i,isBoundary:t.isStickyLeftBoundary(e)};let a=t.getColumnStickyRightCss(e);if(a!==void 0)return{side:`right`,offsetCss:rz(a,r?xz:0),isBoundary:t.isStickyRightBoundary(e)}}var wz=({rowId:e,testIdPrefix:t,onSelect:n,onDuplicate:r,onDelete:i})=>(0,I.jsxs)(I.Fragment,{children:[n&&(0,I.jsxs)(gt,{value:`select`,onClick:()=>n(e),"data-testid":`${t}-select-${e}`,children:[(0,I.jsx)(Kf,{}),(0,I.jsx)(k,{children:`Select`})]}),r&&(0,I.jsxs)(gt,{value:`duplicate`,onClick:()=>r(e),"data-testid":`${t}-duplicate-${e}`,children:[(0,I.jsx)(vk,{}),(0,I.jsx)(k,{children:`Duplicate`})]}),i&&(0,I.jsxs)(I.Fragment,{children:[(n||r)&&(0,I.jsx)(dt,{}),(0,I.jsxs)(gt,{value:`delete`,onClick:()=>i(e),"data-testid":`${t}-delete-${e}`,children:[(0,I.jsx)(Ek,{}),(0,I.jsx)(k,{color:`red.600`,children:`Delete`})]})]})]}),Tz=({rowId:e,onOpen:t,onPick:n,onSelect:r,onDuplicate:i,onDelete:a})=>{let[o,s]=(0,L.useState)(!1),c=n??t,l=n?Kf:df,u=n?`row-action-pick-${e}`:`row-action-open-${e}`,d=!!(t||r||i||a);return(0,I.jsx)(j,{position:`absolute`,right:`8px`,top:`50%`,transform:`translateY(-50%)`,alignItems:`center`,className:`row-action-buttons`,"data-menu-open":o||void 0,"data-testid":`row-action-buttons-${e}`,children:(0,I.jsxs)(j,{alignItems:`center`,height:`24px`,borderRadius:`6px`,bg:`white`,boxShadow:`0px 2px 8px rgba(0,0,0,0.16)`,overflow:`hidden`,"data-testid":`row-action-split-${e}`,children:[c&&(0,I.jsx)(j,{alignItems:`center`,justifyContent:`center`,height:`100%`,width:`28px`,minWidth:`28px`,cursor:`pointer`,_hover:{bg:`gray.100`},onClick:t=>{t.stopPropagation(),c(e)},"data-testid":u,children:(0,I.jsx)(Ve,{boxSize:`20px`,color:`gray.400`,as:l})}),d&&(0,I.jsxs)(en,{lazyMount:!0,unmountOnExit:!0,onOpenChange:({open:e})=>s(e),positioning:{placement:`bottom-start`},children:[(0,I.jsx)(Lt,{asChild:!0,children:(0,I.jsx)(j,{alignItems:`center`,justifyContent:`center`,height:`100%`,width:`18px`,minWidth:`18px`,cursor:`pointer`,borderLeft:c?`1px solid`:void 0,borderColor:`gray.100`,_hover:{bg:`gray.100`},onClick:e=>e.stopPropagation(),"data-testid":`row-action-trigger-${e}`,children:(0,I.jsx)(Ve,{as:nf,boxSize:`16px`,color:`gray.300`})})}),(0,I.jsx)(R,{children:(0,I.jsx)(Ot,{children:(0,I.jsxs)(v,{minW:`180px`,"data-testid":`row-action-menu-${e}`,children:[t&&(0,I.jsxs)(gt,{value:`open`,onClick:()=>t(e),"data-testid":`row-action-menu-open-${e}`,children:[(0,I.jsx)(df,{}),(0,I.jsx)(k,{children:`Open`})]}),t&&(r||i||a)&&(0,I.jsx)(dt,{}),(0,I.jsx)(wz,{rowId:e,testIdPrefix:`row-action`,onSelect:r,onDuplicate:i,onDelete:a})]})})})]})]})})},Ez=({rowId:e,isSelected:t,onToggleSelection:n})=>(0,I.jsx)(A,{as:`td`,width:`40px`,minWidth:`40px`,maxWidth:`40px`,p:0,position:`sticky`,left:0,zIndex:1,bg:`white`,boxShadow:`inset 0 -1px 0 0 ${ez}, inset -1px 0 0 0 ${ez}`,children:(0,I.jsx)(j,{alignItems:`center`,justifyContent:`center`,height:`100%`,children:(0,I.jsxs)(Ne,{checked:t,onCheckedChange:()=>n(),size:`sm`,"data-testid":`select-${e}`,children:[(0,I.jsx)($e,{}),(0,I.jsx)(Ye,{})]})})}),Dz=40,Oz=40;function kz(e){return{"&::after":{content:`""`,position:`absolute`,top:0,bottom:0,width:`8px`,pointerEvents:`none`,transition:`opacity 0.15s`,opacity:e===`left`?`var(--shadow-left-opacity, 0)`:`var(--shadow-right-opacity, 0)`,...e===`left`?{right:`-8px`,boxShadow:`inset 8px 0 12px -8px rgba(0,0,0,0.1)`}:{left:`-8px`,boxShadow:`inset -8px 0 12px -8px rgba(0,0,0,0.1)`}}}}function Az(e,t,n,r){let i=r&&n,a=i?{"& .row-action-buttons":{opacity:0},"&:hover .row-action-buttons, & .row-action-buttons[data-menu-open]":{opacity:1,transition:`opacity 0.15s ease`}}:{};if(e)return{...a,...kz(t)};if(i)return a}function jz(e,t,n,r){let i=t.getColumnStickyLeftCss(e.field,n),a=t.getColumnStickyRightCss(e.field),o=i!==void 0,s=a!==void 0,c=o||s,l=t.isStickyLeftBoundary(e.field),u=t.isStickyRightBoundary(e.field),d=s&&a!==void 0?rz(a,r):a;return{isSticky:c,isBoundary:l||u,boundarySide:o?`left`:`right`,leftCss:o?i:void 0,rightCss:s?d:void 0,colWidth:c?t.columnWidthCssVar(e.field):void 0}}function Mz(e,t){return e?`${tz}, ${t===`left`?`inset -1px 0 0 0 ${ez}`:`inset 1px 0 0 0 ${ez}`}`:tz}var Nz=g(({row:e,columnsModel:t,showSelection:n,onSearchForeignKey:r,onUploadFile:i,onOpenFile:a,onOpenRow:o,onPickRow:s,onSelectRow:c,onDuplicateRow:l,onDeleteRow:u})=>{let d=!!(o||s||c||l||u),f=n?Dz:0,p=t.hasHiddenColumns,m=p?Oz:0;return(0,I.jsxs)(I.Fragment,{children:[n&&(0,I.jsx)(Ez,{rowId:e.rowId,isSelected:e.isSelected,onToggleSelection:()=>e.toggleSelection()}),t.visibleColumns.map((n,p)=>{let h=e.getCellVM(n),g=p===0,_=g&&d&&!h.isEditing,v=jz(n,t,f,m);return(0,I.jsxs)(A,{as:`td`,width:v.colWidth,minWidth:v.colWidth,maxWidth:v.isSticky?v.colWidth:`0`,overflow:v.isBoundary?`visible`:`hidden`,borderRight:v.isSticky?void 0:`1px solid`,borderColor:v.isSticky?void 0:ez,p:0,position:v.isSticky?`sticky`:`relative`,left:v.leftCss,right:v.rightCss,zIndex:v.isSticky?1:void 0,bg:v.isSticky?`white`:void 0,boxShadow:Mz(v.isSticky,v.boundarySide),css:Az(v.isBoundary,v.boundarySide,d,g),children:[v.isBoundary?(0,I.jsx)(A,{overflow:`hidden`,children:(0,I.jsx)(UR,{cell:h,onSearchForeignKey:r,onUploadFile:i,onOpenFile:a})}):(0,I.jsx)(UR,{cell:h,onSearchForeignKey:r,onUploadFile:i,onOpenFile:a}),_&&(0,I.jsx)(Tz,{rowId:e.rowId,onOpen:o,onPick:s,onSelect:c,onDuplicate:l,onDelete:u})]},n.field)}),p?(0,I.jsx)(A,{as:`td`,width:`100%`,minWidth:`${Oz}px`,p:0,position:`sticky`,right:0,zIndex:1,bg:`white`,boxShadow:tz,css:t.pinnedRightCount===0?nz():void 0}):(0,I.jsx)(A,{as:`td`,width:`100%`,p:0,boxShadow:tz})]})}),Pz=g(({selection:e,allRowIds:t,onDuplicate:n,onDelete:r})=>{let i=e.isAllSelected(t);return(0,I.jsx)(tee,{open:e.isSelectionMode,children:(0,I.jsx)(R,{children:(0,I.jsx)(vt,{zIndex:5,children:(0,I.jsxs)(pt,{"data-testid":`selection-toolbar`,children:[(0,I.jsxs)(zt,{children:[e.selectedCount,` selected`]}),(0,I.jsx)(wt,{}),!i&&(0,I.jsxs)(N,{variant:`outline`,size:`sm`,onClick:()=>e.selectAll(t),"data-testid":`select-all`,children:[(0,I.jsx)(Kf,{}),`Select all`]}),n&&(0,I.jsxs)(N,{variant:`outline`,size:`sm`,onClick:()=>n(e.selectedIds),"data-testid":`duplicate-selected`,children:[(0,I.jsx)(vk,{}),`Duplicate`]}),r&&(0,I.jsxs)(N,{variant:`outline`,size:`sm`,onClick:()=>r(e.selectedIds),"data-testid":`delete-selected`,children:[(0,I.jsx)(Ek,{}),`Delete`]}),(0,I.jsx)(iee,{asChild:!0,children:(0,I.jsx)(N,{variant:`ghost`,size:`sm`,"aria-label":`Exit selection`,onClick:()=>e.exitSelectionMode(),"data-testid":`exit-selection`,children:(0,I.jsx)(ip,{})})})]})})})})}),Fz=({isOpen:e,onClose:t,onConfirm:n,count:r})=>{let i=(0,L.useRef)(null),a=r&&r>1?`Are you sure you want to delete ${r} rows?`:`Are you sure you want to delete this row?`;return(0,I.jsx)(Ue,{open:e,onOpenChange:({open:e})=>{e||t()},initialFocusEl:()=>i.current,role:`alertdialog`,children:(0,I.jsxs)(R,{children:[(0,I.jsx)(pe,{}),(0,I.jsx)(ue,{children:(0,I.jsxs)(_n,{maxWidth:`400px`,"data-testid":`delete-confirm-dialog`,children:[(0,I.jsx)(Ge,{children:(0,I.jsx)(qe,{children:`Delete confirmation`})}),(0,I.jsx)(be,{children:(0,I.jsx)(k,{children:a})}),(0,I.jsx)(w,{children:(0,I.jsxs)(j,{gap:2,children:[(0,I.jsx)(N,{ref:i,variant:`outline`,size:`sm`,onClick:t,"data-testid":`delete-cancel`,children:`Cancel`}),(0,I.jsx)(N,{colorPalette:`red`,size:`sm`,onClick:n,"data-testid":`delete-confirm`,children:`Delete`})]})})]})})]})})},Iz=({style:e,children:t,...n})=>(0,I.jsx)(`table`,{...n,style:{...e,width:`max-content`,minWidth:`100%`,tableLayout:`fixed`,borderCollapse:`separate`,borderSpacing:0},children:t}),Lz=({"data-index":e,context:t,style:n,children:r,...i})=>{let a=t?.rows[e];return(0,I.jsx)(`tr`,{...i,className:`group`,"data-testid":a?`row-${a.rowId}`:void 0,style:{...n,height:`40px`},children:r})},Rz={left:!1,right:!1},zz=class{_left=!1;_right=!1;_paused=!1;_dirty=!1;_onChange=null;get showLeftShadow(){return this._left}get showRightShadow(){return this._right}setOnChange(e){this._onChange=e}pause(){this._paused=!0,this._dirty=!1}resume(){this._paused=!1,this._dirty&&(this._dirty=!1,this._notify())}update(e,t){if(!(this._left===e&&this._right===t)){if(this._left=e,this._right=t,this._paused){this._dirty=!0;return}this._notify()}}reset(){if(!(!this._left&&!this._right)){if(this._left=!1,this._right=!1,this._paused){this._dirty=!0;return}this._notify()}}_notify(){this._onChange&&this._onChange({left:this._left,right:this._right})}};function Bz(e){return e instanceof HTMLElement?e:document.scrollingElement}function Vz(){let e=(0,L.useRef)(null);e.current||=new zz;let t=e.current,[n,r]=(0,L.useState)(Rz);t.setOnChange(r),(0,L.useEffect)(()=>()=>{t.setOnChange(null)},[t]);let i={"--shadow-left-opacity":n.left?`1`:`0`,"--shadow-right-opacity":n.right?`1`:`0`},a=(0,L.useRef)(null),o=(0,L.useRef)(0),s=(0,L.useRef)(null),c=(0,L.useCallback)(()=>{let e=a.current;if(!e)return;let n=Bz(e);if(!n)return;let r=n.scrollLeft,i=n.scrollWidth-n.clientWidth;t.update(r>0,i>1&&r<i-1)},[t]),l=(0,L.useCallback)(()=>{o.current&&cancelAnimationFrame(o.current),o.current=requestAnimationFrame(c)},[c]),u=(0,L.useCallback)(e=>{let n=a.current;if(n&&n.removeEventListener(`scroll`,l),s.current&&=(s.current.disconnect(),null),e){a.current=e,e.addEventListener(`scroll`,l,{passive:!0}),o.current=requestAnimationFrame(c);let t=Bz(e);if(t){let e=new ResizeObserver(l),n=t.querySelector(`table`);n&&e.observe(n),s.current=e}}else a.current=null,t.reset()},[l,c,t]);return(0,L.useEffect)(()=>()=>{let e=a.current;e&&e.removeEventListener(`scroll`,l),s.current&&s.current.disconnect(),o.current&&cancelAnimationFrame(o.current)},[l]),{shadowCssVars:i,shadowModel:t,setScrollerRef:u}}var Hz={Table:Iz,TableRow:Lz},Uz=g(({rows:e,columnsModel:t,cellFSM:n,selection:r,sortModel:i,filterModel:a,onSearchForeignKey:o,onUploadFile:s,onOpenFile:c,onOpenRow:l,onPickRow:u,onDeleteSelected:d,onDuplicateSelected:f,onDeleteRow:p,onDuplicateRow:m,onCopyPath:h,onEndReached:g,isLoadingMore:_,useWindowScroll:v})=>{let y=r.isSelectionMode,b=e.map(e=>e.rowId),[x,S]=(0,L.useState)(null),{shadowCssVars:C,shadowModel:w,setScrollerRef:T}=Vz(),E=t.isResizing;(0,L.useEffect)(()=>{E?w.pause():w.resume()},[E,w]);let[D,ee]=(0,L.useState)(null),te=(0,L.useCallback)(e=>{ee(e),t.setWrapperElement(e)},[t]);(0,L.useEffect)(()=>{if(!(!v||!D))return T(D),()=>{T(null)}},[v,D,T]);let ne=(0,L.useCallback)(e=>{r.enterSelectionMode(e)},[r]),O=(0,L.useCallback)(e=>{S({rowId:e})},[]),re=(0,L.useCallback)(e=>{S({batchIds:e})},[]),ie=(0,L.useCallback)(()=>{x?.rowId?(r.deselect(x.rowId),p?p(x.rowId):d&&d([x.rowId])):x?.batchIds&&(d?.(x.batchIds),r.exitSelectionMode()),S(null)},[x,p,d,r]),ae=(0,L.useCallback)(()=>{S(null)},[]),oe=x?.batchIds?.length,se=!!(p||d),ce=!!m,le=se||ce||!!f,ue=(0,L.useMemo)(()=>({copyRange:()=>{let r=n?.getSelectedRange(),i=t.visibleColumns;r&&XR(r,e,i)},pasteRange:()=>{if(!n)return;let r=t.visibleColumns,i=n.getSelectedRange(),a=QR(n,r,e);i?ZR(i.startRow,i.startCol,e,r):a&&ZR(a.rowIndex,a.colIndex,e,r)},clearRange:()=>{let r=n?.getSelectedRange(),i=t.visibleColumns;r&&$R(r,e,i)}}),[n,e,t]),de=(0,L.useCallback)(r=>{if(!n)return;let i=r.ctrlKey||r.metaKey,a=t.visibleColumns;if(i&&r.key===`v`&&n.focusedCell){let t=n.getSelectedRange(),i=QR(n,a,e);t?(r.preventDefault(),ZR(t.startRow,t.startCol,e,a)):i&&(r.preventDefault(),ZR(i.rowIndex,i.colIndex,e,a));return}if(n.hasSelection){if(i&&r.key===`c`){let t=n.getSelectedRange();t&&(r.preventDefault(),XR(t,e,a));return}if(r.key===`Delete`||r.key===`Backspace`){let t=n.getSelectedRange();t&&(r.preventDefault(),$R(t,e,a))}}},[n,e,t]),fe=(0,L.useCallback)((e,n)=>(0,I.jsx)(Nz,{row:n,columnsModel:t,showSelection:y,onSearchForeignKey:o,onUploadFile:s,onOpenFile:c,onOpenRow:l,onPickRow:u,onSelectRow:le?ne:void 0,onDuplicateRow:ce?m:void 0,onDeleteRow:se?O:void 0}),[t,y,o,s,c,l,u,le,se,ce,ne,m,O]),pe=(0,L.useCallback)(()=>(0,I.jsx)(Sz,{columnsModel:t,sortModel:i,filterModel:a,onCopyPath:h,showSelection:y}),[t,i,a,h,y]),me=(0,L.useMemo)(()=>({rows:e}),[e]),he=t.visibleColumns.length+(y?2:1),ge=(0,L.useCallback)(()=>_?(0,I.jsx)(`tfoot`,{children:(0,I.jsx)(`tr`,{children:(0,I.jsx)(`td`,{colSpan:he,style:{textAlign:`center`,padding:`16px 0`},children:(0,I.jsx)(Ht,{size:`sm`,color:`gray.400`})})})}):null,[_,he]),_e=(0,L.useMemo)(()=>({...Hz,Footer:ge}),[ge]);return t.visibleColumns.length===0?(0,I.jsx)(A,{p:4,children:(0,I.jsx)(k,{fontSize:`sm`,color:`gray.500`,children:`No columns to display.`})}):(0,I.jsxs)(nR.Provider,{value:n?ue:null,children:[(0,I.jsxs)(A,{ref:te,position:`relative`,height:v?void 0:`100%`,overflowX:`auto`,overflowY:v?`clip`:void 0,"data-testid":`table-widget`,onKeyDown:de,style:{...t.columnWidthCssVars,...C},children:[e.length===0?(0,I.jsxs)(A,{children:[(0,I.jsx)(`table`,{style:{width:`max-content`,minWidth:`100%`,tableLayout:`fixed`,borderCollapse:`separate`,borderSpacing:0},children:(0,I.jsx)(`thead`,{children:(0,I.jsx)(Sz,{columnsModel:t,sortModel:i,filterModel:a,onCopyPath:h,showSelection:y})})}),(0,I.jsx)(A,{p:4,children:(0,I.jsx)(k,{fontSize:`sm`,color:`gray.500`,children:`No rows to display.`})})]}):(0,I.jsx)(Foe,{useWindowScroll:v,style:v?void 0:{height:`100%`},data:e,context:me,defaultItemHeight:40,initialItemCount:Math.min(e.length,20),increaseViewportBy:2e3,endReached:g,fixedHeaderContent:pe,itemContent:fe,components:_e,scrollerRef:v?void 0:T}),(0,I.jsx)(Pz,{selection:r,allRowIds:b,onDuplicate:f,onDelete:d?re:void 0})]}),(0,I.jsx)(Fz,{isOpen:x!==null,onClose:ae,onConfirm:ie,count:oe})]})}),Wz=class{_cellFSM;_columnsModel;constructor(e,t){this._cellFSM=e,this._columnsModel=t,f(this,{},{autoBind:!0})}get _focusedColumn(){let e=this._cellFSM.focusedCell;return e?this._columnsModel.allColumns.find(t=>t.field===e.field)??null:null}get isVisible(){return this._focusedColumn!==null&&!this._cellFSM.hasSelection}get fieldLabel(){return this._focusedColumn?.label??``}get formulaExpression(){return this._focusedColumn?.formulaExpression}get foreignKeyTableId(){return this._focusedColumn?.foreignKeyTableId}},Gz=class{_totalCount=0;_baseTotalCount=0;_isFiltering=!1;_isRefetching=!1;constructor(){f(this,{},{autoBind:!0})}get totalCount(){return this._totalCount}get baseTotalCount(){return this._baseTotalCount}get isFiltering(){return this._isFiltering}get isRefetching(){return this._isRefetching}get text(){return this._isFiltering?`${this._totalCount} of ${this._baseTotalCount} ${this._baseTotalCount===1?`row`:`rows`}`:`${this._totalCount} ${this._totalCount===1?`row`:`rows`}`}setTotalCount(e){this._totalCount=e}setBaseTotalCount(e){this._baseTotalCount=e}setIsFiltering(e){this._isFiltering=e}setRefetching(e){this._isRefetching=e}decrementBaseTotalCount(e=1){this._baseTotalCount=Math.max(0,this._baseTotalCount-e),this._totalCount=Math.max(0,this._totalCount-e)}},Kz=class{_snapshot=null;_currentSnapshot=null;_canSave=!1;_isPopoverOpen=!1;_onSave=null;_onRevert=null;constructor(){f(this,{},{autoBind:!0})}get hasChanges(){return this._snapshot!==this._currentSnapshot}get isVisible(){return this.hasChanges}get canSave(){return this._canSave}get isPopoverOpen(){return this._isPopoverOpen}saveSnapshot(e){let t=JSON.stringify(e);this._snapshot=t,this._currentSnapshot=t}checkForChanges(e){this._currentSnapshot=JSON.stringify(e)}async save(){this._onSave&&await this._onSave()}revert(){this._onRevert&&this._onRevert(),this._currentSnapshot=this._snapshot}setCanSave(e){this._canSave=e}setPopoverOpen(e){this._isPopoverOpen=e}setOnSave(e){this._onSave=e}setOnRevert(e){this._onRevert=e}dispose(){this._onSave=null,this._onRevert=null}},qz=50,Jz=class{columns;filters;sorts;search;viewBadge;cellFSM;selection;rowCount;cellInfo;_dataSource;_pageSize;_breadcrumbs;_callbacks;_tableId;_schemaContext=new oI;_readonly=!1;_rows=[];_isBootstrapping=!0;_isLoadingMore=!1;_hasNextPage=!1;_endCursor=null;_savedViewState=null;constructor(e,t){this._dataSource=e,this._tableId=t.tableId,this._pageSize=t.pageSize??qz,this._readonly=t.readonly??!1,this._breadcrumbs=t.breadcrumbs??[],this._callbacks=t.callbacks??{},this.columns=new wI,this.filters=new oL,this.sorts=new TL,this.search=new xL(e=>this._handleSearch(e)),this.viewBadge=new Kz,this.cellFSM=new GL,this.selection=new jL,this.rowCount=new Gz,this.cellInfo=new Wz(this.cellFSM,this.columns),this.columns.setOnChange(()=>this._handleColumnsChange()),this.filters.setOnChange(()=>this._handleFilterChange()),this.filters.setOnApply(e=>this._handleFilterApply()),this.sorts.setOnChange(()=>this._handleSortChange()),this.sorts.setOnApply(e=>this._handleSortApply()),this.viewBadge.setOnSave(()=>this._handleViewSave()),this.viewBadge.setOnRevert(()=>this._handleViewRevert()),this.cellFSM.setOnReadonlyEditAttempt(this._callbacks.onReadonlyEditAttempt??null),f(this,{},{autoBind:!0}),queueMicrotask(()=>void this._bootstrap())}get rows(){return this._rows}get isBootstrapping(){return this._isBootstrapping}get isLoadingMore(){return this._isLoadingMore}get readonly(){return this._readonly}get tableId(){return this._tableId}get breadcrumbs(){return this._breadcrumbs}get callbacks(){return this._callbacks}getViewState(){return{columns:this.columns.serializeToViewColumns(),filters:null,sorts:this.sorts.serializeToViewSorts(),search:``}}applyViewState(e){this.columns.applyViewColumns(e.columns),this.sorts.applyViewSorts(e.sorts)}async loadMore(){if(!(!this._hasNextPage||this._isLoadingMore)){this._isLoadingMore=!0;try{let e=this._buildQuery(this._endCursor),t=await this._dataSource.fetchRows(e);c(()=>{this._appendRowVMs(t.rows),this._endCursor=t.endCursor,this._hasNextPage=t.hasNextPage,this._isLoadingMore=!1})}catch{c(()=>{this._isLoadingMore=!1})}}}async deleteRows(e){(await this._dataSource.deleteRows(e)).ok&&c(()=>{let t=new Set(e);this._rows=this._rows.filter(e=>!t.has(e.rowId)),this.rowCount.decrementBaseTotalCount(e.length),this.selection.exitSelectionMode(),this._updateNavigationContext()})}dispose(){this.columns.dispose(),this.filters.dispose(),this.sorts.dispose(),this.search.dispose(),this.viewBadge.dispose(),this.selection.exitSelectionMode(),this.cellFSM.blur();for(let e of this._rows)e.dispose()}async _bootstrap(){try{let e=await this._dataSource.fetchMetadata();c(()=>{this._schemaContext.init(e.dataSchema,e.refSchemas),this._readonly=this._readonly||e.readonly,this.viewBadge.setCanSave(!this._readonly)}),this.columns.init(this._schemaContext.allColumns),this.sorts.init(this._schemaContext.sortableFields),this.filters.init(this._schemaContext.filterableFields),e.viewState&&this.applyViewState(e.viewState),this._saveViewSnapshot(),await this._loadRows(),c(()=>{this._isBootstrapping=!1})}catch{c(()=>{this._isBootstrapping=!1})}}_buildQuery(e=null){return{where:this.filters.hasActiveFilters?this.filters.buildCurrentWhereClause():null,orderBy:this.sorts.serializeToQuerySorts(),search:this.search.debouncedQuery,first:this._pageSize,after:e}}async _loadRows(){let e=this._buildQuery(),t=await this._dataSource.fetchRows(e);c(()=>{this._replaceRowVMs(t.rows),this._endCursor=t.endCursor,this._hasNextPage=t.hasNextPage;let e=this.filters.hasActiveFilters||this.search.hasActiveSearch;this.rowCount.setTotalCount(t.totalCount),e||this.rowCount.setBaseTotalCount(t.totalCount),this.rowCount.setIsFiltering(e),this._updateNavigationContext()})}async _reloadRows(){this._isBootstrapping||(this.selection.exitSelectionMode(),this.cellFSM.blur(),await this._loadRows())}_replaceRowVMs(e){for(let e of this._rows)e.dispose();this._rows=this._createRowVMs(e)}_appendRowVMs(e){let t=this._createRowVMs(e);this._rows=[...this._rows,...t],this._updateNavigationContext()}_createRowVMs(e){let t=this._schemaContext.wrappedDataSchema;if(!t)return[];let n=kc({tableId:this._tableId,schema:t,rows:e.map(e=>({rowId:e.rowId,data:{data:e.data}})),refSchemas:this._schemaContext.fullRefSchemas}),r=new Map;for(let t of e)r.set(t.rowId,this._buildSystemValues(t));return n.rows.map(e=>new qL(e,e.rowId,this.cellFSM,this.selection,(e,t,n,r)=>this._commitCell(e,t,n,r),r.get(e.rowId),this._readonly))}_buildSystemValues(e){return{...e.systemFields,id:e.rowId}}_toPatchField(e){return nI(e)}async _commitCell(e,t,n,r){let i=this._toPatchField(t),a=(await this._dataSource.patchCells([{rowId:e,field:i,value:n}]))[0];a&&!a.ok&&c(()=>{let n=this._rows.find(t=>t.rowId===e);if(n&&r!==void 0){let e=n.rowModel.get(t);e?.isPrimitive()?e.setValue(r):e?.isObject()&&e.setValue(r,{internal:!0})}})}_updateNavigationContext(){this.cellFSM.setNavigationContext(this.columns.visibleColumns.map(e=>e.field),this._rows.map(e=>e.rowId))}_handleColumnsChange(){this.cellFSM.updateNavigationContext(this.columns.visibleColumns.map(e=>e.field),this.cellFSM.rowIds),this._checkViewChanges()}_handleFilterChange(){}_handleFilterApply(){this._reloadRows()}_handleSortChange(){this._checkViewChanges()}_handleSortApply(){this._reloadRows(),this._checkViewChanges()}_handleSearch(e){this._reloadRows()}async _handleViewSave(){try{let e=this.getViewState();(await this._dataSource.saveView(e)).ok&&this._saveViewSnapshot()}catch{}}_handleViewRevert(){this._savedViewState&&(this.applyViewState(this._savedViewState),this._reloadRows())}_saveViewSnapshot(){let e=this.getViewState();this._savedViewState=e,this.viewBadge.saveSnapshot(e)}_checkViewChanges(){this.viewBadge.checkForChanges(this.getViewState())}};function Yz(e,{delayMs:t=150,minShowMs:n=300}={}){let[r,i]=(0,L.useState)(!1),a=(0,L.useRef)(null);return(0,L.useEffect)(()=>{if(e){let e=setTimeout(()=>{a.current=Date.now(),i(!0)},t);return()=>clearTimeout(e)}if(a.current!==null){let e=n-(Date.now()-a.current);if(e>0){let t=setTimeout(()=>{a.current=null,i(!1)},e);return()=>clearTimeout(t)}a.current=null}i(!1)},[e,t,n]),r}var Xz=g(({model:e})=>e.isVisible?(0,I.jsxs)(j,{alignItems:`center`,gap:2,overflow:`hidden`,flexShrink:1,minW:0,children:[(0,I.jsx)(k,{fontSize:`sm`,color:`gray.500`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,"data-testid":`cell-info-field`,children:e.fieldLabel}),e.formulaExpression&&(0,I.jsxs)(k,{fontSize:`sm`,color:`purple.400`,fontFamily:`mono`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,"data-testid":`cell-info-formula`,children:[`= `,e.formulaExpression]}),e.foreignKeyTableId&&!e.formulaExpression&&(0,I.jsxs)(k,{fontSize:`sm`,color:`blue.400`,fontFamily:`mono`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,"data-testid":`cell-info-fk`,children:[`→ `,e.foreignKeyTableId]})]}):null),Zz=g(({model:e})=>(0,I.jsxs)(j,{alignItems:`center`,gap:2,children:[(0,I.jsx)(k,{fontSize:`sm`,color:`gray.500`,"data-testid":`row-count-text`,children:e.text}),e.isRefetching&&(0,I.jsx)(Ht,{size:`xs`,color:`gray.400`,"data-testid":`row-count-spinner`})]})),Qz=g(({model:e})=>{if(!e.isVisible)return null;let t=e.canSave?`orange`:`gray`,n=e.canSave?`orange.500`:`gray.400`,r=e.canSave?`unsaved`:`local`,i=e.canSave?`Unsaved view settings`:`Local view changes`,a=e.canSave?`Column order, widths, and sort settings will be saved to the Default view and shared with everyone.`:`View settings can only be saved in draft revisions. These changes are temporary and will be lost when you leave.`,o=e.canSave?`Revert`:`Reset`;return(0,I.jsxs)(ge,{open:e.isPopoverOpen,onOpenChange:t=>e.setPopoverOpen(t.open),lazyMount:!0,unmountOnExit:!0,children:[(0,I.jsx)(me,{asChild:!0,children:(0,I.jsxs)(It,{variant:`subtle`,size:`sm`,colorPalette:t,cursor:`pointer`,display:`flex`,alignItems:`center`,gap:1,_hover:{opacity:.8},"data-testid":`view-settings-badge`,children:[(0,I.jsx)(A,{width:`6px`,height:`6px`,borderRadius:`full`,bg:n}),r]})}),(0,I.jsx)(R,{children:(0,I.jsx)(se,{children:(0,I.jsxs)(le,{p:3,maxW:`300px`,children:[(0,I.jsxs)(P,{mb:2,children:[(0,I.jsx)(A,{color:`gray.400`,children:(0,I.jsx)(bk,{size:16})}),(0,I.jsx)(k,{fontWeight:`semibold`,fontSize:`sm`,children:i})]}),(0,I.jsx)(k,{fontSize:`sm`,color:`gray.600`,mb:3,children:a}),(0,I.jsxs)(P,{children:[(0,I.jsx)(N,{variant:`ghost`,size:`xs`,onClick:()=>{e.revert(),e.setPopoverOpen(!1)},"data-testid":`view-settings-revert`,children:o}),e.canSave&&(0,I.jsx)(N,{colorPalette:`blue`,size:`xs`,onClick:()=>{e.save(),e.setPopoverOpen(!1)},"data-testid":`view-settings-save`,children:`Save`})]})]})})})]})}),$z=40,eB=40,tB=8,nB=[120,150,120,100,130],rB=[[80,110,70,60,90],[100,90,100,80,110],[60,130,80,70,80],[90,100,60,90,100],[75,120,90,55,70],[110,80,75,80,120],[85,140,95,65,95],[95,70,110,85,80]],iB=({breadcrumbs:e,onBreadcrumbClick:t,showCreateButton:n,useWindowScroll:r})=>(0,I.jsxs)(A,{display:`flex`,flexDirection:`column`,height:r?void 0:`100%`,flex:r?1:void 0,children:[(0,I.jsxs)(j,{px:3,pt:`32px`,pb:`48px`,alignItems:`flex-start`,justifyContent:`space-between`,...r&&{position:`sticky`,top:0,zIndex:3,bg:`white`},children:[e.length>0?(0,I.jsx)(JN,{segments:e,highlightLast:!1,onSegmentClick:t,action:n?(0,I.jsx)(sn,{height:`32px`,width:`32px`,borderRadius:`6px`}):void 0}):(0,I.jsx)(A,{}),(0,I.jsxs)(j,{alignItems:`center`,gap:`8px`,children:[(0,I.jsx)(sn,{height:`32px`,width:`32px`,borderRadius:`6px`}),(0,I.jsx)(sn,{height:`32px`,width:`32px`,borderRadius:`6px`}),(0,I.jsx)(sn,{height:`32px`,width:`32px`,borderRadius:`6px`})]})]}),(0,I.jsxs)(A,{children:[(0,I.jsx)(j,{height:`${$z}px`,alignItems:`center`,px:3,borderBottom:`1px solid`,borderColor:`gray.100`,children:nB.map((e,t)=>(0,I.jsx)(A,{width:`${e}px`,flexShrink:0,children:(0,I.jsx)(sn,{height:`12px`,width:`60px`,borderRadius:`4px`})},`h-${t}`))}),rB.slice(0,tB).map((e,t)=>(0,I.jsx)(j,{height:`${eB}px`,alignItems:`center`,px:3,borderBottom:`1px solid`,borderColor:`gray.100`,children:nB.map((n,r)=>(0,I.jsx)(A,{width:`${n}px`,flexShrink:0,children:(0,I.jsx)(sn,{height:`14px`,width:`${e[r]}px`,borderRadius:`4px`})},`r-${t}-c-${r}`))},`r-${t}`))]})]}),aB=()=>{};function oB(e,t,n){return{onDeleteRow:e?void 0:e=>t.deleteRows([e]),onDuplicateRow:e?void 0:n.onDuplicateRow,onDeleteSelected:e?void 0:e=>t.deleteRows(e),onUploadFile:e?void 0:n.onUploadFile}}var sB=g(({viewModel:e,useWindowScroll:t})=>{let n=Yz(e.isBootstrapping);if(e.isBootstrapping)return n?(0,I.jsx)(iB,{breadcrumbs:e.breadcrumbs,onBreadcrumbClick:e.callbacks.onBreadcrumbClick,showCreateButton:!e.readonly&&!!e.callbacks.onCreateRow,useWindowScroll:t}):null;let r=e.readonly,{breadcrumbs:i,callbacks:a}=e;return(0,I.jsxs)(A,{display:`flex`,flexDirection:`column`,height:t?void 0:`100%`,flex:t?1:void 0,children:[(0,I.jsxs)(j,{px:3,pt:`32px`,pb:`48px`,alignItems:`flex-start`,justifyContent:`space-between`,...t&&{position:`sticky`,top:0,zIndex:3,bg:`white`},children:[i.length>0&&(0,I.jsx)(JN,{segments:i,highlightLast:!1,onSegmentClick:a.onBreadcrumbClick,action:a.onCreateRow?(0,I.jsx)(XN,{tooltip:`New row`,onClick:a.onCreateRow,dataTestId:`create-row-button`}):void 0}),(0,I.jsxs)(j,{alignItems:`center`,gap:`8px`,children:[(0,I.jsx)(CL,{model:e.search}),(0,I.jsx)(bL,{model:e.filters,availableFields:e.columns.filterableFields}),(0,I.jsx)(AL,{model:e.sorts,availableFields:e.columns.sortableFields,onChange:aB})]})]}),(0,I.jsx)(A,{flex:1,minHeight:0,children:(0,I.jsx)(Uz,{rows:e.rows,columnsModel:e.columns,cellFSM:e.cellFSM,selection:e.selection,sortModel:e.sorts,filterModel:e.filters,isLoadingMore:e.isLoadingMore,onEndReached:e.loadMore,onOpenRow:a.onOpenRow,onPickRow:a.onPickRow,...oB(r,e,a),onSearchForeignKey:a.onSearchForeignKey,onOpenFile:a.onOpenFile,onCopyPath:a.onCopyPath,useWindowScroll:t})}),(0,I.jsxs)(j,{px:3,py:2,alignItems:`center`,overflow:`hidden`,...t&&{position:`sticky`,bottom:0,bg:`white`,zIndex:3},children:[(0,I.jsx)(Zz,{model:e.rowCount}),(0,I.jsxs)(j,{alignItems:`center`,gap:3,overflow:`hidden`,flexShrink:1,minW:0,flex:1,justifyContent:`flex-end`,children:[(0,I.jsx)(Xz,{model:e.cellInfo}),(0,I.jsx)(Qz,{model:e.viewBadge})]})]})]})}),cB=Sn(),lB=e=>{let t={BASE_URL:`/`,DEV:!1,GIT_BRANCH_NAME:`HEAD`,GIT_COMMIT_HASH:`59fa0fa`,MODE:`production`,PACKAGE_VERSION:`2.7.0-alpha.2`,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}[e];return globalThis.__env__?.[e]||t},uB=(e,t,n,r,i,a,o,s)=>{let c=document.documentElement,l=[`light`,`dark`];function u(t){(Array.isArray(e)?e:[e]).forEach(e=>{let n=e===`class`,r=n&&a?i.map(e=>a[e]||e):i;n?(c.classList.remove(...r),c.classList.add(a&&a[t]?a[t]:t)):c.setAttribute(e,t)}),d(t)}function d(e){s&&l.includes(e)&&(c.style.colorScheme=e)}function f(){return window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`}if(r)u(r);else try{let e=localStorage.getItem(t)||n;u(o&&e===`system`?f():e)}catch{}},dB=[`light`,`dark`],fB=`(prefers-color-scheme: dark)`,pB=typeof window>`u`,mB=L.createContext(void 0),hB=e=>L.useContext(mB)?L.createElement(L.Fragment,null,e.children):L.createElement(_B,{...e}),gB=[`light`,`dark`],_B=({forcedTheme:e,disableTransitionOnChange:t=!1,enableSystem:n=!0,enableColorScheme:r=!0,storageKey:i=`theme`,themes:a=gB,defaultTheme:o=n?`system`:`light`,attribute:s=`data-theme`,value:c,children:l,nonce:u,scriptProps:d})=>{let[f,p]=L.useState(()=>yB(i,o)),[m,h]=L.useState(()=>f===`system`?xB():f),g=c?Object.values(c):a,_=L.useCallback(e=>{let i=e;if(!i)return;e===`system`&&n&&(i=xB());let a=c?c[i]:i,l=t?bB(u):null,d=document.documentElement,f=e=>{e===`class`?(d.classList.remove(...g),a&&d.classList.add(a)):e.startsWith(`data-`)&&(a?d.setAttribute(e,a):d.removeAttribute(e))};if(Array.isArray(s)?s.forEach(f):f(s),r){let e=dB.includes(o)?o:null,t=dB.includes(i)?i:e;d.style.colorScheme=t}l?.()},[u]),v=L.useCallback(e=>{let t=typeof e==`function`?e(f):e;p(t);try{localStorage.setItem(i,t)}catch{}},[f]),y=L.useCallback(t=>{h(xB(t)),f===`system`&&n&&!e&&_(`system`)},[f,e]);L.useEffect(()=>{let e=window.matchMedia(fB);return e.addListener(y),y(e),()=>e.removeListener(y)},[y]),L.useEffect(()=>{let e=e=>{e.key===i&&(e.newValue?p(e.newValue):v(o))};return window.addEventListener(`storage`,e),()=>window.removeEventListener(`storage`,e)},[v]),L.useEffect(()=>{_(e??f)},[e,f]);let b=L.useMemo(()=>({theme:f,setTheme:v,forcedTheme:e,resolvedTheme:f===`system`?m:f,themes:n?[...a,`system`]:a,systemTheme:n?m:void 0}),[f,v,e,m,n,a]);return L.createElement(mB.Provider,{value:b},L.createElement(vB,{forcedTheme:e,storageKey:i,attribute:s,enableSystem:n,enableColorScheme:r,defaultTheme:o,value:c,themes:a,nonce:u,scriptProps:d}),l)},vB=L.memo(({forcedTheme:e,storageKey:t,attribute:n,enableSystem:r,enableColorScheme:i,defaultTheme:a,value:o,themes:s,nonce:c,scriptProps:l})=>{let u=JSON.stringify([n,t,a,e,s,o,r,i]).slice(1,-1);return L.createElement(`script`,{...l,suppressHydrationWarning:!0,nonce:typeof window>`u`?c:``,dangerouslySetInnerHTML:{__html:`(${uB.toString()})(${u})`}})}),yB=(e,t)=>{if(pB)return;let n;try{n=localStorage.getItem(e)||void 0}catch{}return n||t},bB=e=>{let t=document.createElement(`style`);return e&&t.setAttribute(`nonce`,e),t.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(t),()=>{window.getComputedStyle(document.body),setTimeout(()=>{document.head.removeChild(t)},1)}},xB=e=>(e||=window.matchMedia(fB),e.matches?`dark`:`light`),SB=()=>(0,L.useCallback)(e=>{e&&e.focus()},[]),CB=(e,...t)=>{let n=(0,L.useRef)(null),[r,i]=(0,L.useState)(t),a=(0,L.useMemo)(()=>r.length!==t.length||r.some((e,n)=>e!==t[n])?(i(t),t):r,[t,r]);return n.current||=Y.get(e),(0,L.useEffect)(()=>{let e=n.current;return e?.init?.(...a),()=>{e?.dispose?.()}},[a]),n.current};function wB(e){let t=Object.prototype.toString.call(e);return e instanceof Date||typeof e==`object`&&t===`[object Date]`?new e.constructor(+e):typeof e==`number`||t===`[object Number]`||typeof e==`string`||t===`[object String]`?new Date(e):new Date(NaN)}function TB(e,t){return e instanceof Date?new e.constructor(t):new Date(t)}var EB=365.2425,DB=6048e5,OB=864e5,kB=43200,AB=1440,jB=3600*24;jB*7,jB*EB/12*3;var MB={};function NB(){return MB}function PB(e,t){let n=NB(),r=t?.weekStartsOn??t?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,i=wB(e),a=i.getDay(),o=(a<r?7:0)+a-r;return i.setDate(i.getDate()-o),i.setHours(0,0,0,0),i}function FB(e){return PB(e,{weekStartsOn:1})}function IB(e){let t=wB(e),n=t.getFullYear(),r=TB(e,0);r.setFullYear(n+1,0,4),r.setHours(0,0,0,0);let i=FB(r),a=TB(e,0);a.setFullYear(n,0,4),a.setHours(0,0,0,0);let o=FB(a);return t.getTime()>=i.getTime()?n+1:t.getTime()>=o.getTime()?n:n-1}function LB(e){let t=wB(e);return t.setHours(0,0,0,0),t}function RB(e){let t=wB(e),n=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()));return n.setUTCFullYear(t.getFullYear()),e-+n}function zB(e,t){let n=LB(e),r=LB(t),i=+n-RB(n),a=+r-RB(r);return Math.round((i-a)/OB)}function BB(e){let t=IB(e),n=TB(e,0);return n.setFullYear(t,0,4),n.setHours(0,0,0,0),FB(n)}function VB(e,t){let n=wB(e),r=wB(t),i=n.getTime()-r.getTime();return i<0?-1:i>0?1:i}function HB(e){return e instanceof Date||typeof e==`object`&&Object.prototype.toString.call(e)===`[object Date]`}function UB(e){if(!HB(e)&&typeof e!=`number`)return!1;let t=wB(e);return!isNaN(Number(t))}function WB(e,t){let n=wB(e),r=wB(t),i=n.getFullYear()-r.getFullYear(),a=n.getMonth()-r.getMonth();return i*12+a}function GB(e){return t=>{let n=(e?Math[e]:Math.trunc)(t);return n===0?0:n}}function KB(e,t){return wB(e)-+wB(t)}function qB(e){let t=wB(e);return t.setHours(23,59,59,999),t}function JB(e){let t=wB(e),n=t.getMonth();return t.setFullYear(t.getFullYear(),n+1,0),t.setHours(23,59,59,999),t}function YB(e){let t=wB(e);return+qB(t)==+JB(t)}function XB(e,t){let n=wB(e),r=wB(t),i=VB(n,r),a=Math.abs(WB(n,r)),o;if(a<1)o=0;else{n.getMonth()===1&&n.getDate()>27&&n.setDate(30),n.setMonth(n.getMonth()-i*a);let t=VB(n,r)===-i;YB(wB(e))&&a===1&&VB(e,r)===1&&(t=!1),o=i*(a-Number(t))}return o===0?0:o}function ZB(e,t,n){let r=KB(e,t)/1e3;return GB(n?.roundingMethod)(r)}function QB(e){let t=wB(e),n=TB(e,0);return n.setFullYear(t.getFullYear(),0,1),n.setHours(0,0,0,0),n}var $B={lessThanXSeconds:{one:`less than a second`,other:`less than {{count}} seconds`},xSeconds:{one:`1 second`,other:`{{count}} seconds`},halfAMinute:`half a minute`,lessThanXMinutes:{one:`less than a minute`,other:`less than {{count}} minutes`},xMinutes:{one:`1 minute`,other:`{{count}} minutes`},aboutXHours:{one:`about 1 hour`,other:`about {{count}} hours`},xHours:{one:`1 hour`,other:`{{count}} hours`},xDays:{one:`1 day`,other:`{{count}} days`},aboutXWeeks:{one:`about 1 week`,other:`about {{count}} weeks`},xWeeks:{one:`1 week`,other:`{{count}} weeks`},aboutXMonths:{one:`about 1 month`,other:`about {{count}} months`},xMonths:{one:`1 month`,other:`{{count}} months`},aboutXYears:{one:`about 1 year`,other:`about {{count}} years`},xYears:{one:`1 year`,other:`{{count}} years`},overXYears:{one:`over 1 year`,other:`over {{count}} years`},almostXYears:{one:`almost 1 year`,other:`almost {{count}} years`}},eV=(e,t,n)=>{let r,i=$B[e];return r=typeof i==`string`?i:t===1?i.one:i.other.replace(`{{count}}`,t.toString()),n?.addSuffix?n.comparison&&n.comparison>0?`in `+r:r+` ago`:r};function tV(e){return(t={})=>{let n=t.width?String(t.width):e.defaultWidth;return e.formats[n]||e.formats[e.defaultWidth]}}var nV={date:tV({formats:{full:`EEEE, MMMM do, y`,long:`MMMM do, y`,medium:`MMM d, y`,short:`MM/dd/yyyy`},defaultWidth:`full`}),time:tV({formats:{full:`h:mm:ss a zzzz`,long:`h:mm:ss a z`,medium:`h:mm:ss a`,short:`h:mm a`},defaultWidth:`full`}),dateTime:tV({formats:{full:`{{date}} 'at' {{time}}`,long:`{{date}} 'at' {{time}}`,medium:`{{date}}, {{time}}`,short:`{{date}}, {{time}}`},defaultWidth:`full`})},rV={lastWeek:`'last' eeee 'at' p`,yesterday:`'yesterday at' p`,today:`'today at' p`,tomorrow:`'tomorrow at' p`,nextWeek:`eeee 'at' p`,other:`P`},iV=(e,t,n,r)=>rV[e];function aV(e){return(t,n)=>{let r=n?.context?String(n.context):`standalone`,i;if(r===`formatting`&&e.formattingValues){let t=e.defaultFormattingWidth||e.defaultWidth,r=n?.width?String(n.width):t;i=e.formattingValues[r]||e.formattingValues[t]}else{let t=e.defaultWidth,r=n?.width?String(n.width):e.defaultWidth;i=e.values[r]||e.values[t]}let a=e.argumentCallback?e.argumentCallback(t):t;return i[a]}}var oV={ordinalNumber:(e,t)=>{let n=Number(e),r=n%100;if(r>20||r<10)switch(r%10){case 1:return n+`st`;case 2:return n+`nd`;case 3:return n+`rd`}return n+`th`},era:aV({values:{narrow:[`B`,`A`],abbreviated:[`BC`,`AD`],wide:[`Before Christ`,`Anno Domini`]},defaultWidth:`wide`}),quarter:aV({values:{narrow:[`1`,`2`,`3`,`4`],abbreviated:[`Q1`,`Q2`,`Q3`,`Q4`],wide:[`1st quarter`,`2nd quarter`,`3rd quarter`,`4th quarter`]},defaultWidth:`wide`,argumentCallback:e=>e-1}),month:aV({values:{narrow:[`J`,`F`,`M`,`A`,`M`,`J`,`J`,`A`,`S`,`O`,`N`,`D`],abbreviated:[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],wide:[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`]},defaultWidth:`wide`}),day:aV({values:{narrow:[`S`,`M`,`T`,`W`,`T`,`F`,`S`],short:[`Su`,`Mo`,`Tu`,`We`,`Th`,`Fr`,`Sa`],abbreviated:[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`],wide:[`Sunday`,`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`]},defaultWidth:`wide`}),dayPeriod:aV({values:{narrow:{am:`a`,pm:`p`,midnight:`mi`,noon:`n`,morning:`morning`,afternoon:`afternoon`,evening:`evening`,night:`night`},abbreviated:{am:`AM`,pm:`PM`,midnight:`midnight`,noon:`noon`,morning:`morning`,afternoon:`afternoon`,evening:`evening`,night:`night`},wide:{am:`a.m.`,pm:`p.m.`,midnight:`midnight`,noon:`noon`,morning:`morning`,afternoon:`afternoon`,evening:`evening`,night:`night`}},defaultWidth:`wide`,formattingValues:{narrow:{am:`a`,pm:`p`,midnight:`mi`,noon:`n`,morning:`in the morning`,afternoon:`in the afternoon`,evening:`in the evening`,night:`at night`},abbreviated:{am:`AM`,pm:`PM`,midnight:`midnight`,noon:`noon`,morning:`in the morning`,afternoon:`in the afternoon`,evening:`in the evening`,night:`at night`},wide:{am:`a.m.`,pm:`p.m.`,midnight:`midnight`,noon:`noon`,morning:`in the morning`,afternoon:`in the afternoon`,evening:`in the evening`,night:`at night`}},defaultFormattingWidth:`wide`})};function sV(e){return(t,n={})=>{let r=n.width,i=r&&e.matchPatterns[r]||e.matchPatterns[e.defaultMatchWidth],a=t.match(i);if(!a)return null;let o=a[0],s=r&&e.parsePatterns[r]||e.parsePatterns[e.defaultParseWidth],c=Array.isArray(s)?lV(s,e=>e.test(o)):cV(s,e=>e.test(o)),l;l=e.valueCallback?e.valueCallback(c):c,l=n.valueCallback?n.valueCallback(l):l;let u=t.slice(o.length);return{value:l,rest:u}}}function cV(e,t){for(let n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&t(e[n]))return n}function lV(e,t){for(let n=0;n<e.length;n++)if(t(e[n]))return n}function uV(e){return(t,n={})=>{let r=t.match(e.matchPattern);if(!r)return null;let i=r[0],a=t.match(e.parsePattern);if(!a)return null;let o=e.valueCallback?e.valueCallback(a[0]):a[0];o=n.valueCallback?n.valueCallback(o):o;let s=t.slice(i.length);return{value:o,rest:s}}}var dV={code:`en-US`,formatDistance:eV,formatLong:nV,formatRelative:iV,localize:oV,match:{ordinalNumber:uV({matchPattern:/^(\d+)(th|st|nd|rd)?/i,parsePattern:/\d+/i,valueCallback:e=>parseInt(e,10)}),era:sV({matchPatterns:{narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},defaultMatchWidth:`wide`,parsePatterns:{any:[/^b/i,/^(a|c)/i]},defaultParseWidth:`any`}),quarter:sV({matchPatterns:{narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},defaultMatchWidth:`wide`,parsePatterns:{any:[/1/i,/2/i,/3/i,/4/i]},defaultParseWidth:`any`,valueCallback:e=>e+1}),month:sV({matchPatterns:{narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},defaultMatchWidth:`wide`,parsePatterns:{narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},defaultParseWidth:`any`}),day:sV({matchPatterns:{narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},defaultMatchWidth:`wide`,parsePatterns:{narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},defaultParseWidth:`any`}),dayPeriod:sV({matchPatterns:{narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},defaultMatchWidth:`any`,parsePatterns:{any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},defaultParseWidth:`any`})},options:{weekStartsOn:0,firstWeekContainsDate:1}};function fV(e){let t=wB(e);return zB(t,QB(t))+1}function pV(e){let t=wB(e),n=FB(t)-+BB(t);return Math.round(n/DB)+1}function mV(e,t){let n=wB(e),r=n.getFullYear(),i=NB(),a=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??i.firstWeekContainsDate??i.locale?.options?.firstWeekContainsDate??1,o=TB(e,0);o.setFullYear(r+1,0,a),o.setHours(0,0,0,0);let s=PB(o,t),c=TB(e,0);c.setFullYear(r,0,a),c.setHours(0,0,0,0);let l=PB(c,t);return n.getTime()>=s.getTime()?r+1:n.getTime()>=l.getTime()?r:r-1}function hV(e,t){let n=NB(),r=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??n.firstWeekContainsDate??n.locale?.options?.firstWeekContainsDate??1,i=mV(e,t),a=TB(e,0);return a.setFullYear(i,0,r),a.setHours(0,0,0,0),PB(a,t)}function gV(e,t){let n=wB(e),r=PB(n,t)-+hV(n,t);return Math.round(r/DB)+1}function _V(e,t){return(e<0?`-`:``)+Math.abs(e).toString().padStart(t,`0`)}var vV={y(e,t){let n=e.getFullYear(),r=n>0?n:1-n;return _V(t===`yy`?r%100:r,t.length)},M(e,t){let n=e.getMonth();return t===`M`?String(n+1):_V(n+1,2)},d(e,t){return _V(e.getDate(),t.length)},a(e,t){let n=e.getHours()/12>=1?`pm`:`am`;switch(t){case`a`:case`aa`:return n.toUpperCase();case`aaa`:return n;case`aaaaa`:return n[0];default:return n===`am`?`a.m.`:`p.m.`}},h(e,t){return _V(e.getHours()%12||12,t.length)},H(e,t){return _V(e.getHours(),t.length)},m(e,t){return _V(e.getMinutes(),t.length)},s(e,t){return _V(e.getSeconds(),t.length)},S(e,t){let n=t.length,r=e.getMilliseconds();return _V(Math.trunc(r*10**(n-3)),t.length)}},yV={am:`am`,pm:`pm`,midnight:`midnight`,noon:`noon`,morning:`morning`,afternoon:`afternoon`,evening:`evening`,night:`night`},bV={G:function(e,t,n){let r=+(e.getFullYear()>0);switch(t){case`G`:case`GG`:case`GGG`:return n.era(r,{width:`abbreviated`});case`GGGGG`:return n.era(r,{width:`narrow`});default:return n.era(r,{width:`wide`})}},y:function(e,t,n){if(t===`yo`){let t=e.getFullYear(),r=t>0?t:1-t;return n.ordinalNumber(r,{unit:`year`})}return vV.y(e,t)},Y:function(e,t,n,r){let i=mV(e,r),a=i>0?i:1-i;return t===`YY`?_V(a%100,2):t===`Yo`?n.ordinalNumber(a,{unit:`year`}):_V(a,t.length)},R:function(e,t){return _V(IB(e),t.length)},u:function(e,t){return _V(e.getFullYear(),t.length)},Q:function(e,t,n){let r=Math.ceil((e.getMonth()+1)/3);switch(t){case`Q`:return String(r);case`QQ`:return _V(r,2);case`Qo`:return n.ordinalNumber(r,{unit:`quarter`});case`QQQ`:return n.quarter(r,{width:`abbreviated`,context:`formatting`});case`QQQQQ`:return n.quarter(r,{width:`narrow`,context:`formatting`});default:return n.quarter(r,{width:`wide`,context:`formatting`})}},q:function(e,t,n){let r=Math.ceil((e.getMonth()+1)/3);switch(t){case`q`:return String(r);case`qq`:return _V(r,2);case`qo`:return n.ordinalNumber(r,{unit:`quarter`});case`qqq`:return n.quarter(r,{width:`abbreviated`,context:`standalone`});case`qqqqq`:return n.quarter(r,{width:`narrow`,context:`standalone`});default:return n.quarter(r,{width:`wide`,context:`standalone`})}},M:function(e,t,n){let r=e.getMonth();switch(t){case`M`:case`MM`:return vV.M(e,t);case`Mo`:return n.ordinalNumber(r+1,{unit:`month`});case`MMM`:return n.month(r,{width:`abbreviated`,context:`formatting`});case`MMMMM`:return n.month(r,{width:`narrow`,context:`formatting`});default:return n.month(r,{width:`wide`,context:`formatting`})}},L:function(e,t,n){let r=e.getMonth();switch(t){case`L`:return String(r+1);case`LL`:return _V(r+1,2);case`Lo`:return n.ordinalNumber(r+1,{unit:`month`});case`LLL`:return n.month(r,{width:`abbreviated`,context:`standalone`});case`LLLLL`:return n.month(r,{width:`narrow`,context:`standalone`});default:return n.month(r,{width:`wide`,context:`standalone`})}},w:function(e,t,n,r){let i=gV(e,r);return t===`wo`?n.ordinalNumber(i,{unit:`week`}):_V(i,t.length)},I:function(e,t,n){let r=pV(e);return t===`Io`?n.ordinalNumber(r,{unit:`week`}):_V(r,t.length)},d:function(e,t,n){return t===`do`?n.ordinalNumber(e.getDate(),{unit:`date`}):vV.d(e,t)},D:function(e,t,n){let r=fV(e);return t===`Do`?n.ordinalNumber(r,{unit:`dayOfYear`}):_V(r,t.length)},E:function(e,t,n){let r=e.getDay();switch(t){case`E`:case`EE`:case`EEE`:return n.day(r,{width:`abbreviated`,context:`formatting`});case`EEEEE`:return n.day(r,{width:`narrow`,context:`formatting`});case`EEEEEE`:return n.day(r,{width:`short`,context:`formatting`});default:return n.day(r,{width:`wide`,context:`formatting`})}},e:function(e,t,n,r){let i=e.getDay(),a=(i-r.weekStartsOn+8)%7||7;switch(t){case`e`:return String(a);case`ee`:return _V(a,2);case`eo`:return n.ordinalNumber(a,{unit:`day`});case`eee`:return n.day(i,{width:`abbreviated`,context:`formatting`});case`eeeee`:return n.day(i,{width:`narrow`,context:`formatting`});case`eeeeee`:return n.day(i,{width:`short`,context:`formatting`});default:return n.day(i,{width:`wide`,context:`formatting`})}},c:function(e,t,n,r){let i=e.getDay(),a=(i-r.weekStartsOn+8)%7||7;switch(t){case`c`:return String(a);case`cc`:return _V(a,t.length);case`co`:return n.ordinalNumber(a,{unit:`day`});case`ccc`:return n.day(i,{width:`abbreviated`,context:`standalone`});case`ccccc`:return n.day(i,{width:`narrow`,context:`standalone`});case`cccccc`:return n.day(i,{width:`short`,context:`standalone`});default:return n.day(i,{width:`wide`,context:`standalone`})}},i:function(e,t,n){let r=e.getDay(),i=r===0?7:r;switch(t){case`i`:return String(i);case`ii`:return _V(i,t.length);case`io`:return n.ordinalNumber(i,{unit:`day`});case`iii`:return n.day(r,{width:`abbreviated`,context:`formatting`});case`iiiii`:return n.day(r,{width:`narrow`,context:`formatting`});case`iiiiii`:return n.day(r,{width:`short`,context:`formatting`});default:return n.day(r,{width:`wide`,context:`formatting`})}},a:function(e,t,n){let r=e.getHours()/12>=1?`pm`:`am`;switch(t){case`a`:case`aa`:return n.dayPeriod(r,{width:`abbreviated`,context:`formatting`});case`aaa`:return n.dayPeriod(r,{width:`abbreviated`,context:`formatting`}).toLowerCase();case`aaaaa`:return n.dayPeriod(r,{width:`narrow`,context:`formatting`});default:return n.dayPeriod(r,{width:`wide`,context:`formatting`})}},b:function(e,t,n){let r=e.getHours(),i;switch(i=r===12?yV.noon:r===0?yV.midnight:r/12>=1?`pm`:`am`,t){case`b`:case`bb`:return n.dayPeriod(i,{width:`abbreviated`,context:`formatting`});case`bbb`:return n.dayPeriod(i,{width:`abbreviated`,context:`formatting`}).toLowerCase();case`bbbbb`:return n.dayPeriod(i,{width:`narrow`,context:`formatting`});default:return n.dayPeriod(i,{width:`wide`,context:`formatting`})}},B:function(e,t,n){let r=e.getHours(),i;switch(i=r>=17?yV.evening:r>=12?yV.afternoon:r>=4?yV.morning:yV.night,t){case`B`:case`BB`:case`BBB`:return n.dayPeriod(i,{width:`abbreviated`,context:`formatting`});case`BBBBB`:return n.dayPeriod(i,{width:`narrow`,context:`formatting`});default:return n.dayPeriod(i,{width:`wide`,context:`formatting`})}},h:function(e,t,n){if(t===`ho`){let t=e.getHours()%12;return t===0&&(t=12),n.ordinalNumber(t,{unit:`hour`})}return vV.h(e,t)},H:function(e,t,n){return t===`Ho`?n.ordinalNumber(e.getHours(),{unit:`hour`}):vV.H(e,t)},K:function(e,t,n){let r=e.getHours()%12;return t===`Ko`?n.ordinalNumber(r,{unit:`hour`}):_V(r,t.length)},k:function(e,t,n){let r=e.getHours();return r===0&&(r=24),t===`ko`?n.ordinalNumber(r,{unit:`hour`}):_V(r,t.length)},m:function(e,t,n){return t===`mo`?n.ordinalNumber(e.getMinutes(),{unit:`minute`}):vV.m(e,t)},s:function(e,t,n){return t===`so`?n.ordinalNumber(e.getSeconds(),{unit:`second`}):vV.s(e,t)},S:function(e,t){return vV.S(e,t)},X:function(e,t,n){let r=e.getTimezoneOffset();if(r===0)return`Z`;switch(t){case`X`:return SV(r);case`XXXX`:case`XX`:return CV(r);default:return CV(r,`:`)}},x:function(e,t,n){let r=e.getTimezoneOffset();switch(t){case`x`:return SV(r);case`xxxx`:case`xx`:return CV(r);default:return CV(r,`:`)}},O:function(e,t,n){let r=e.getTimezoneOffset();switch(t){case`O`:case`OO`:case`OOO`:return`GMT`+xV(r,`:`);default:return`GMT`+CV(r,`:`)}},z:function(e,t,n){let r=e.getTimezoneOffset();switch(t){case`z`:case`zz`:case`zzz`:return`GMT`+xV(r,`:`);default:return`GMT`+CV(r,`:`)}},t:function(e,t,n){return _V(Math.trunc(e.getTime()/1e3),t.length)},T:function(e,t,n){return _V(e.getTime(),t.length)}};function xV(e,t=``){let n=e>0?`-`:`+`,r=Math.abs(e),i=Math.trunc(r/60),a=r%60;return a===0?n+String(i):n+String(i)+t+_V(a,2)}function SV(e,t){return e%60==0?(e>0?`-`:`+`)+_V(Math.abs(e)/60,2):CV(e,t)}function CV(e,t=``){let n=e>0?`-`:`+`,r=Math.abs(e),i=_V(Math.trunc(r/60),2),a=_V(r%60,2);return n+i+t+a}var wV=(e,t)=>{switch(e){case`P`:return t.date({width:`short`});case`PP`:return t.date({width:`medium`});case`PPP`:return t.date({width:`long`});default:return t.date({width:`full`})}},TV=(e,t)=>{switch(e){case`p`:return t.time({width:`short`});case`pp`:return t.time({width:`medium`});case`ppp`:return t.time({width:`long`});default:return t.time({width:`full`})}},EV={p:TV,P:(e,t)=>{let n=e.match(/(P+)(p+)?/)||[],r=n[1],i=n[2];if(!i)return wV(e,t);let a;switch(r){case`P`:a=t.dateTime({width:`short`});break;case`PP`:a=t.dateTime({width:`medium`});break;case`PPP`:a=t.dateTime({width:`long`});break;default:a=t.dateTime({width:`full`});break}return a.replace(`{{date}}`,wV(r,t)).replace(`{{time}}`,TV(i,t))}},DV=/^D+$/,OV=/^Y+$/,kV=[`D`,`DD`,`YY`,`YYYY`];function AV(e){return DV.test(e)}function jV(e){return OV.test(e)}function MV(e,t,n){let r=NV(e,t,n);if(console.warn(r),kV.includes(e))throw RangeError(r)}function NV(e,t,n){let r=e[0]===`Y`?`years`:`days of the month`;return`Use \`${e.toLowerCase()}\` instead of \`${e}\` (in \`${t}\`) for formatting ${r} to the input \`${n}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}var PV=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,FV=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,IV=/^'([^]*?)'?$/,LV=/''/g,RV=/[a-zA-Z]/;function zV(e,t,n){let r=NB(),i=n?.locale??r.locale??dV,a=n?.firstWeekContainsDate??n?.locale?.options?.firstWeekContainsDate??r.firstWeekContainsDate??r.locale?.options?.firstWeekContainsDate??1,o=n?.weekStartsOn??n?.locale?.options?.weekStartsOn??r.weekStartsOn??r.locale?.options?.weekStartsOn??0,s=wB(e);if(!UB(s))throw RangeError(`Invalid time value`);let c=t.match(FV).map(e=>{let t=e[0];if(t===`p`||t===`P`){let n=EV[t];return n(e,i.formatLong)}return e}).join(``).match(PV).map(e=>{if(e===`''`)return{isToken:!1,value:`'`};let t=e[0];if(t===`'`)return{isToken:!1,value:BV(e)};if(bV[t])return{isToken:!0,value:e};if(t.match(RV))throw RangeError("Format string contains an unescaped latin alphabet character `"+t+"`");return{isToken:!1,value:e}});i.localize.preprocessor&&(c=i.localize.preprocessor(s,c));let l={firstWeekContainsDate:a,weekStartsOn:o,locale:i};return c.map(r=>{if(!r.isToken)return r.value;let a=r.value;(!n?.useAdditionalWeekYearTokens&&jV(a)||!n?.useAdditionalDayOfYearTokens&&AV(a))&&MV(a,t,String(e));let o=bV[a[0]];return o(s,a,i.localize,l)}).join(``)}function BV(e){let t=e.match(IV);return t?t[1].replace(LV,`'`):e}function VV(e,t,n){let r=NB(),i=n?.locale??r.locale??dV,a=VB(e,t);if(isNaN(a))throw RangeError(`Invalid time value`);let o=Object.assign({},n,{addSuffix:n?.addSuffix,comparison:a}),s,c;a>0?(s=wB(t),c=wB(e)):(s=wB(e),c=wB(t));let l=ZB(c,s),u=(RB(c)-RB(s))/1e3,d=Math.round((l-u)/60),f;if(d<2)return n?.includeSeconds?l<5?i.formatDistance(`lessThanXSeconds`,5,o):l<10?i.formatDistance(`lessThanXSeconds`,10,o):l<20?i.formatDistance(`lessThanXSeconds`,20,o):l<40?i.formatDistance(`halfAMinute`,0,o):l<60?i.formatDistance(`lessThanXMinutes`,1,o):i.formatDistance(`xMinutes`,1,o):d===0?i.formatDistance(`lessThanXMinutes`,1,o):i.formatDistance(`xMinutes`,d,o);if(d<45)return i.formatDistance(`xMinutes`,d,o);if(d<90)return i.formatDistance(`aboutXHours`,1,o);if(d<1440){let e=Math.round(d/60);return i.formatDistance(`aboutXHours`,e,o)}else if(d<2520)return i.formatDistance(`xDays`,1,o);else if(d<43200){let e=Math.round(d/AB);return i.formatDistance(`xDays`,e,o)}else if(d<43200*2)return f=Math.round(d/kB),i.formatDistance(`aboutXMonths`,f,o);if(f=XB(c,s),f<12){let e=Math.round(d/kB);return i.formatDistance(`xMonths`,e,o)}else{let e=f%12,t=Math.trunc(f/12);return e<3?i.formatDistance(`aboutXYears`,t,o):e<9?i.formatDistance(`overXYears`,t,o):i.formatDistance(`almostXYears`,t+1,o)}}function HV(e,t){return VV(e,Date.now(),t)}function UV(e,t=`dd.MM.yyyy, HH:mm`,n){if(!e)return``;let r=new Date(e);return Number.isNaN(r.getTime())?(console.warn(`Invalid date:`,e),``):zV(r,t,{locale:n})}var WV=()=>globalThis.location.origin,GV=e=>navigator.clipboard.writeText(e),Y=new class{registrations=new Map;register(e,t,n){this.registrations.set(e,{factory:t,scope:n.scope})}get(e){let t=this.registrations.get(e);if(!t)throw Error(`No provider found for ${e.name}`);return t.scope===`singleton`?(t.instance??=t.factory(),t.instance):t.factory()}},KV=class extends Error{constructor(){super(`Aborted`),this.name=`AbortError`}},X=class e{_data=null;_error=null;_isLoading=!1;_isLoaded=!1;_abortController=null;static of(t,n){return new e(t,n)}constructor(e,t){this.fetchFunction=e,this.options=t,f(this)}get data(){return this._data}get isLoading(){return this._isLoading}get isLoaded(){return this._isLoaded}get error(){return this._error}get errorMessage(){return this._error?.response.errors?.[0].message}abort(){this._abortController?.abort(),this._abortController=null}setDataDirectly(e){this._data=e,this._isLoaded=!0}async fetch(...e){this.abort(),this._abortController=new AbortController;let t=this._abortController.signal;this.options?.skipResetting||this.reset();try{this.setIsLoading(!0);let n=await this.fetchFunction(...e);return t.aborted?{isRight:!1,error:new KV}:(this.setData(n),{isRight:!0,data:n})}catch(e){return t.aborted?{isRight:!1,error:new KV}:(console.error(e),this.setError(e),{isRight:!1,error:e})}finally{this.setIsLoading(!1),this.setIsLoaded(!0)}}reset(){this.setIsLoading(!1),this.setData(null),this.setError(null)}setData(e){this._data=e}setIsLoading(e){this._isLoading=e}setIsLoaded(e){this._isLoaded=e}setError(e){this._error=e}};function qV(e){return!e.isRight&&e.error instanceof KV}var JV=class{values;constructor(e){this.values=e,f(this,{},{autoBind:!0})}setValue(e,t){this.values[e]=t}get isValid(){return Object.values(this.values).every(Boolean)}},YV=e=>{if(e&&e.startsWith(`/`)&&!e.startsWith(`//`))return e},XV=e=>{if(!e)return null;try{let t=JSON.parse(e)?.redirect;return typeof t==`string`?t:null}catch{return null}},ZV=e=>{if(e)return JSON.stringify({redirect:e})},QV=()=>YV(new URLSearchParams(globalThis.location.search).get(`redirect`)),$V=e=>{let t=YV(e);return!t||t===`/`?``:`?redirect=${encodeURIComponent(t)}`},eH=function(e){return e.Loading=`loading`,e.Empty=`empty`,e.List=`list`,e.NotFound=`notFound`,e.Error=`error`,e}({}),tH=class{_state=eH.Loading;_items=[];_hasNextPage=!1;_endCursor=null;_totalCount=0;_isInitialLoad=!0;constructor(){f(this,{},{autoBind:!0})}get state(){return this._state}get items(){return this._items}get hasNextPage(){return this._hasNextPage}get endCursor(){return this._endCursor}get totalCount(){return this._totalCount}get isInitialLoad(){return this._isInitialLoad}get showLoading(){return this._state===eH.Loading&&this._isInitialLoad}get showEmpty(){return this._state===eH.Empty}get showNotFound(){return this._state===eH.NotFound}get showList(){return this._state===eH.List}get showError(){return this._state===eH.Error}setLoading(){this._state=eH.Loading}setError(){this._isInitialLoad=!1,this._state=eH.Error}setItems(e,t){this._isInitialLoad=!1,this._items=e,this._hasNextPage=t.hasNextPage,this._endCursor=t.endCursor,this._totalCount=t.totalCount,e.length>0?this._state=eH.List:t.isSearching?this._state=eH.NotFound:this._state=eH.Empty}appendItems(e,t){this._items=[...this._items,...e],this._hasNextPage=t.hasNextPage,this._endCursor=t.endCursor}removeItem(e){let t=this._items.length;this._items=this._items.filter(t=>!e(t));let n=t-this._items.length;this._totalCount=Math.max(0,this._totalCount-n)}updateStateAfterRemove(e){this._items.length===0&&(this._state=e?eH.NotFound:eH.Empty)}reset(){this._items=[],this._hasNextPage=!1,this._endCursor=null,this._isInitialLoad=!1,this._state=eH.Loading}resetToLoading(){this._items=[],this._hasNextPage=!1,this._endCursor=null,this._totalCount=0,this._isInitialLoad=!0,this._state=eH.Loading}},nH=class{cachedItemViewModels=u.map();constructor(e){this.dataSource=e,h(this,{cachedItemViewModels:u,showLoading:a,showEmpty:a,showList:a,showError:a,items:a,totalCount:a,hasNextPage:a,init:m,dispose:m,tryToFetchNextPage:m,getOrCreateItemViewModel:!1})}get showLoading(){return this.dataSource.state===eH.Loading&&this.dataSource.isInitialLoad}get showEmpty(){return this.dataSource.state===eH.Empty}get showList(){return this.dataSource.state===eH.List}get showError(){return this.dataSource.state===eH.Error}get items(){return this.dataSource.items.map(e=>this.getOrCreateItemViewModel(e))}get totalCount(){return this.dataSource.totalCount}get hasNextPage(){return this.dataSource.hasNextPage}init(){this.dataSource.load()}dispose(){this.dataSource.dispose(),this.cachedItemViewModels.clear()}async tryToFetchNextPage(){await this.dataSource.loadNextPage()}getOrCreateItemViewModel(e){let t=this.getItemKey(e),n=this.cachedItemViewModels.get(t);return n||(n=this.createItemViewModel(e),this.cachedItemViewModels.set(t,n)),n}},rH=class{listState=new tH;request;config;constructor(e,t={}){this.request=X.of(e,{skipResetting:!0}),this.config={pageSize:t.pageSize??50},h(this,{items:a,hasNextPage:a,totalCount:a,isLoading:a,isInitialLoad:a,state:a,load:m,loadNextPage:m,reset:m,dispose:m},{autoBind:!0})}get items(){return this.listState.items}get hasNextPage(){return this.listState.hasNextPage}get totalCount(){return this.listState.totalCount}get isLoading(){return this.request.isLoading}get isInitialLoad(){return this.listState.isInitialLoad}get state(){return this.listState.state}async load(e){this.listState.setLoading();let t=await this.request.fetch(this.buildFetchArgs(e));if(!t.isRight){if(qV(t))return;c(()=>{this.listState.setError()});return}c(()=>{let e=this.extractItems(t.data),n=this.extractPageInfo(t.data);this.listState.setItems(e,n)})}async loadNextPage(){if(!this.hasNextPage||this.isLoading)return!1;let e=await this.request.fetch(this.buildFetchArgs(void 0,this.listState.endCursor||void 0));return e.isRight?(c(()=>{let t=this.extractItems(e.data),n=this.extractPageInfo(e.data);this.listState.appendItems(t,{hasNextPage:n.hasNextPage,endCursor:n.endCursor})}),!0):!1}reset(){this.listState.reset(),this.request.abort()}dispose(){this.request.abort()}},iH=class{id=ds();pendingRequestInternal=null;resolverInternal=null;constructor(){h(this,{pendingRequestInternal:u,hasPendingRequest:a,pendingRequest:a,setPendingRequest:m,clearPendingRequest:m})}setResolver(e){this.resolverInternal=e}resolve(e){this.resolverInternal?.(e)}get hasPendingRequest(){return this.pendingRequestInternal!==null}get pendingRequest(){return this.pendingRequestInternal}setPendingRequest(e){this.pendingRequestInternal=e}clearPendingRequest(){this.pendingRequestInternal=null}init(){}dispose(){}};function aH(e,t,n){return{payload:e,resolve:t,reject:n}}var oH=class{stack=[];constructor(){h(this,{stack:u,initStack:m.bound,pushRequest:m.bound,resolveToParent:m.bound,rejectRequest:m.bound,cancelFromItem:m.bound,dispose:m.bound})}initStack(e){this.stack=[e],this.setupItemResolver(e)}pushRequest(e,t,n,r){let i=aH(t,n,r);e.setPendingRequest(i);let a=this.createItemForRequest(i);this.addItem(a)}resolveToParent(e,t){let n=this.stack.indexOf(e);if(n===-1)return;let r=this.stack[n-1];r?.pendingRequest&&(r.pendingRequest.resolve(t),r.clearPendingRequest()),this.stack.splice(n).forEach(e=>e.dispose())}rejectRequest(e){let t=this.stack.indexOf(e);t!==-1&&this.stack.splice(t+1).forEach(e=>e.dispose());let n=t-1;if(n>=0){let e=this.stack[n];e.pendingRequest&&(e.pendingRequest.reject(),e.clearPendingRequest())}}cancelFromItem(e){let t=this.stack.indexOf(e);t!==-1&&(this.stack.splice(t+1).forEach(e=>e.dispose()),e.pendingRequest&&(e.pendingRequest.reject(),e.clearPendingRequest()))}dispose(){this.stack.forEach(e=>e.dispose()),this.stack=[]}addItem(e){this.setupItemResolver(e),this.stack.push(e)}setupItemResolver(e){e.setResolver(t=>this.handleItemResult(e,t))}},sH=class{_isFullscreen=!1;_isInitialized=!1;_containerRef=null;constructor(){h(this,{_isFullscreen:u,_containerRef:u,setContainerRef:m.bound,toggleFullscreen:m.bound,init:m.bound,dispose:m.bound,handleFullscreenChange:m.bound})}get isFullscreen(){return this._isFullscreen}setContainerRef(e){this._containerRef=e}toggleFullscreen(){this._isFullscreen?this.exitFullscreen():this.enterFullscreen()}init(){this._isInitialized||(this._isInitialized=!0,document.addEventListener(`fullscreenchange`,this.handleFullscreenChange))}dispose(){this._isInitialized&&(this._isInitialized=!1,document.removeEventListener(`fullscreenchange`,this.handleFullscreenChange),this._containerRef=null,this._isFullscreen=!1)}async enterFullscreen(){if(this._containerRef)try{await this._containerRef.requestFullscreen()}catch(e){console.error(e)}}async exitFullscreen(){try{await document.exitFullscreen()}catch(e){console.error(e)}}handleFullscreenChange(){this._isFullscreen=document.fullscreenElement===this._containerRef}},cH=class{_timer=null;constructor(e){this.delayMs=e}schedule(e){this.cancel(),this._timer=setTimeout(e,this.delayMs)}cancel(){this._timer&&=(clearTimeout(this._timer),null)}dispose(){this.cancel()}},lH=class{constructor(e,t){this.operator=e,this.value=t,Object.defineProperty(this,`t`,{writable:!0})}get notes(){return this.t}addNote(e){this.t=this.t||[],this.t.push(e)}},uH=class extends lH{},dH=class extends uH{constructor(e,t){if(!Array.isArray(t))throw Error(`"${e}" operator expects to receive an array of conditions`);super(e,t)}},fH=`__itself__`,pH=class extends lH{constructor(e,t,n){super(e,n),this.field=t}},mH=new uH(`__null__`,null),hH=Object.prototype.hasOwnProperty.call.bind(Object.prototype.hasOwnProperty);function gH(e,t){return t instanceof dH&&t.operator===e}function _H(e,t){return t.length===1?t[0]:new dH(e,function e(t,n,r){let i=r||[];for(let r=0,a=n.length;r<a;r++){let a=n[r];gH(t,a)?e(t,a.value,i):i.push(a)}return i}(e,t))}var vH=e=>e,yH=()=>Object.create(null),bH=Object.defineProperty(yH(),`__@type@__`,{value:`ignore value`});function xH(e,t,n=!1){if(!e||e&&e.constructor!==Object)return!1;for(let r in e)if(hH(e,r)&&hH(t,r)&&(!n||e[r]!==bH))return!0;return!1}function SH(e){let t=[];for(let n in e)hH(e,n)&&e[n]!==bH&&t.push(n);return t}function CH(e,t){t!==mH&&e.push(t)}var wH=e=>_H(`and`,e),TH={compound(e,t,n){let r=(Array.isArray(t)?t:[t]).map(e=>n.parse(e));return new dH(e.name,r)},field:(e,t,n)=>new pH(e.name,n.field,t),document:(e,t)=>new uH(e.name,t)},EH=class{constructor(e,t=yH()){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:t.operatorToConditionName||vH,defaultOperatorName:t.defaultOperatorName||`eq`,mergeFinalConditions:t.mergeFinalConditions||wH},this.o=Object.keys(e).reduce((t,n)=>(t[n]=Object.assign({name:this.u.operatorToConditionName(n)},e[n]),t),{}),this.s=Object.assign({},t.fieldContext,{field:``,query:{},parse:this.parse,hasOperators:e=>xH(e,this.o,t.useIgnoreValue)}),this.i=Object.assign({},t.documentContext,{parse:this.parse,query:{}}),this.h=t.useIgnoreValue?SH:Object.keys}setParse(e){this.parse=e,this.s.parse=e,this.i.parse=e}parseField(e,t,n,r){let i=this.o[t];if(!i)throw Error(`Unsupported operator "${t}"`);if(i.type!==`field`)throw Error(`Unexpected ${i.type} operator "${t}" at field level`);return this.s.field=e,this.s.query=r,this.parseInstruction(i,n,this.s)}parseInstruction(e,t,n){return typeof e.validate==`function`&&e.validate(e,t),(e.parse||TH[e.type])(e,t,n)}parseFieldOperators(e,t){let n=[],r=this.h(t);for(let i=0,a=r.length;i<a;i++){let a=r[i];if(!this.o[a])throw Error(`Field query for "${e}" may contain only operators or a plain object as a value`);CH(n,this.parseField(e,a,t[a],t))}return n}parse(e){let t=[],n=this.h(e);this.i.query=e;for(let r=0,i=n.length;r<i;r++){let i=n[r],a=e[i],o=this.o[i];if(o){if(o.type!==`document`&&o.type!==`compound`)throw Error(`Cannot use parsing instruction for operator "${i}" in "document" context as it is supposed to be used in "${o.type}" context`);CH(t,this.parseInstruction(o,a,this.i))}else this.s.hasOperators(a)?t.push(...this.parseFieldOperators(i,a)):CH(t,this.parseField(i,this.u.defaultOperatorName,a,e))}return this.u.mergeFinalConditions(t)}};function DH(e,t){let n=e[t];if(typeof n!=`function`)throw Error(`Unable to interpret "${t}" condition. Did you forget to register interpreter for it?`);return n}function OH(e){return e.operator}function kH(e,t){let n=t,r=n&&n.getInterpreterName||OH,i;switch(n?n.numberOfArguments:0){case 1:i=t=>DH(e,r(t,n))(t,a);break;case 3:i=(t,i,o)=>DH(e,r(t,n))(t,i,o,a);break;default:i=(t,i)=>DH(e,r(t,n))(t,i,a)}let a=Object.assign({},n,{interpret:i});return a.interpret}function AH(e,t){return(n,...r)=>{let i=e(n,...r),a=t.bind(null,i);return a.ast=i,a}}EH.prototype.parseInstruction;function jH(e,t){if(!Array.isArray(t))throw Error(`"${e.name}" expects value to be an array`)}function MH(e,t){if(jH(e,t),!t.length)throw Error(`"${e.name}" expects to have at least one element in array`)}var NH=e=>(t,n)=>{if(typeof n!==e)throw Error(`"${t.name}" expects value to be a "${e}"`)},PH={type:`compound`,validate:MH,parse(e,t,{parse:n}){let r=t.map(e=>n(e));return _H(e.name,r)}},FH=PH,IH={type:`compound`,validate:MH},LH={type:`field`,validate(e,t){if(!(t&&(t instanceof RegExp||t.constructor===Object)))throw Error(`"${e.name}" expects to receive either regular expression or object of field operators`)},parse(e,t,n){let r=t instanceof RegExp?new pH(`regex`,n.field,t):n.parse(t,n);return new dH(e.name,[r])}},RH={type:`field`,validate(e,t){if(!t||t.constructor!==Object)throw Error(`"${e.name}" expects to receive an object with nested query or field level operators`)},parse(e,t,{parse:n,field:r,hasOperators:i}){let a=i(t)?n(t,{field:fH}):n(t);return new pH(e.name,r,a)}},zH={type:`field`,validate:NH(`number`)},BH={type:`field`,validate:jH},VH=BH,HH=BH,UH={type:`field`,validate(e,t){if(!Array.isArray(t)||t.length!==2)throw Error(`"${e.name}" expects an array with 2 numeric elements`)}},WH={type:`field`,validate:NH(`boolean`)},GH={type:`field`,validate:function(e,t){if(!(typeof t==`string`||typeof t==`number`||t instanceof Date))throw Error(`"${e.name}" expects value to be comparable (i.e., string, number or date)`)}},KH=GH,qH=KH,JH=KH,YH={type:`field`},XH=YH,ZH={type:`field`,validate(e,t){if(!(t instanceof RegExp)&&typeof t!=`string`)throw Error(`"${e.name}" expects value to be a regular expression or a string that represents regular expression`)},parse(e,t,n){let r=typeof t==`string`?new RegExp(t,n.query.$options||``):t;return new pH(e.name,n.field,r)}},QH={type:`field`,parse:()=>mH},$H={type:`document`,validate:NH(`function`)},eU=Object.freeze({__proto__:null,$and:PH,$or:FH,$nor:IH,$not:LH,$elemMatch:RH,$size:zH,$in:BH,$nin:VH,$all:HH,$mod:UH,$exists:WH,$gte:GH,$gt:KH,$lt:qH,$lte:JH,$eq:YH,$ne:XH,$regex:ZH,$options:QH,$where:$H}),tU=class extends EH{constructor(e){super(e,{defaultOperatorName:`$eq`,operatorToConditionName:e=>e.slice(1)})}parse(e,t){return t&&t.field?wH(this.parseFieldOperators(t.field,e)):super.parse(e)}},nU=eU;function rU(e,t,n){for(let r=0,i=e.length;r<i;r++)if(n(e[r],t)===0)return!0;return!1}function iU(e,t){return Array.isArray(e)&&Number.isNaN(Number(t))}function aU(e,t,n){if(!iU(e,t))return n(e,t);let r=[];for(let i=0;i<e.length;i++){let a=n(e[i],t);a!==void 0&&(r=r.concat(a))}return r}function oU(e){return(t,n,r)=>{let i=r.get(n,t.field);return Array.isArray(i)?i.some(n=>e(t,n,r)):e(t,i,r)}}var sU=(e,t)=>e[t];function cU(e,t,n){let r=t.lastIndexOf(`.`);return r===-1?[e,t]:[n(e,t.slice(0,r)),t.slice(r+1)]}function lU(e,t,n=sU){if(t===`__itself__`)return e;if(!e)throw Error(`Unable to get field "${t}" out of ${String(e)}.`);return function(e,t,n){if(t.indexOf(`.`)===-1)return aU(e,t,n);let r=t.split(`.`),i=e;for(let e=0,t=r.length;e<t;e++)if(i=aU(i,r[e],n),!i||typeof i!=`object`)return i;return i}(e,t,n)}function uU(e,t){return e===t?0:e>t?1:-1}function dU(e,t={}){return kH(e,Object.assign({get:lU,compare:uU},t))}var fU=(e,t,{interpret:n})=>e.value.some(e=>n(e,t)),pU=(e,t,n)=>!fU(e,t,n),mU=(e,t,{interpret:n})=>e.value.every(e=>n(e,t)),hU=(e,t,{interpret:n})=>!n(e.value[0],t),gU=(e,t,{compare:n,get:r})=>{let i=r(t,e.field);return Array.isArray(i)&&!Array.isArray(e.value)?rU(i,e.value,n):n(i,e.value)===0},_U=(e,t,n)=>!gU(e,t,n),vU=oU((e,t,n)=>{let r=n.compare(t,e.value);return r===0||r===-1}),yU=oU((e,t,n)=>n.compare(t,e.value)===-1),bU=oU((e,t,n)=>n.compare(t,e.value)===1),xU=oU((e,t,n)=>{let r=n.compare(t,e.value);return r===0||r===1}),SU=(e,t,{get:n})=>{if(e.field===`__itself__`)return t!==void 0;let[r,i]=cU(t,e.field,n),a=t=>t==null?!!t===e.value:t.hasOwnProperty(i)===e.value;return iU(r,i)?r.some(a):a(r)},CU=oU((e,t)=>typeof t==`number`&&t%e.value[0]===e.value[1]),wU=(e,t,{get:n})=>{let[r,i]=cU(t,e.field,n),a=t=>{let r=n(t,i);return Array.isArray(r)&&r.length===e.value};return e.field!==`__itself__`&&iU(r,i)?r.some(a):a(r)},TU=oU((e,t)=>typeof t==`string`&&e.value.test(t)),EU=oU((e,t,{compare:n})=>rU(e.value,t,n)),DU=(e,t,n)=>!EU(e,t,n),OU=(e,t,{compare:n,get:r})=>{let i=r(t,e.field);return Array.isArray(i)&&e.value.every(e=>rU(i,e,n))},kU=(e,t,{interpret:n,get:r})=>{let i=r(t,e.field);return Array.isArray(i)&&i.some(t=>n(e.value,t))},AU=Object.freeze({__proto__:null,or:fU,nor:pU,and:mU,not:hU,eq:gU,ne:_U,lte:vU,lt:yU,gt:bU,gte:xU,exists:SU,mod:CU,size:wU,regex:TU,within:EU,nin:DU,all:OU,elemMatch:kU,where:(e,t)=>e.value.call(t)}),jU=Object.assign({},AU,{in:EU});dU(jU);function MU(e){return typeof e!=`object`||!e?e:e instanceof Date?e.getTime():e&&typeof e.toJSON==`function`?e.toJSON():e}var NU=(e,t)=>uU(MU(e),MU(t));function PU(e,t,n){let r=new tU(e),i=dU(t,Object.assign({compare:NU},n));if(n&&n.forPrimitives){let e={field:fH},t=r.parse;r.setParse(n=>t(n,e))}return AH(r.parse,i)}PU(nU,jU),PU([`$and`,`$or`].reduce((e,t)=>(e[t]=Object.assign({},e[t],{type:`field`}),e),Object.assign({},nU,{$nor:Object.assign({},nU.$nor,{type:`field`,parse:TH.compound})})),jU,{forPrimitives:!0});var FU=Object.hasOwn||((e,t)=>Object.prototype.hasOwnProperty.call(e,t));function IU(e){return Array.isArray(e)?e:[e]}var LU=`__caslSubjectType__`;function RU(e,t){if(t){if(!FU(t,LU))Object.defineProperty(t,LU,{value:e});else if(e!==t[LU])throw Error(`Trying to cast object to subject type ${e} but previously it was casted to ${t[LU]}`)}return t}var zU=e=>{let t=typeof e;return t===`string`||t===`function`},BU=e=>e.modelName||e.name;function VU(e){return typeof e==`string`?e:BU(e)}function HU(e){return FU(e,LU)?e[LU]:BU(e.constructor)}var UU={function:e=>e.constructor,string:HU};function WU(e,t,n){for(let r=n;r<t.length;r++)e.push(t[r])}function GU(e,t){if(!e||!e.length)return t||[];if(!t||!t.length)return e||[];let n=0,r=0,i=[];for(;n<e.length&&r<t.length;)e[n].priority<t[r].priority?(i.push(e[n]),n++):(i.push(t[r]),r++);return WU(i,e,n),WU(i,t,r),i}function KU(e,t,n){let r=e.get(t);return r||(r=n(),e.set(t,r)),r}var qU=e=>e;function JU(e,t){if(Array.isArray(e.fields)&&!e.fields.length)throw Error("`rawRule.fields` cannot be an empty array. https://bit.ly/390miLa");if(e.fields&&!t.fieldMatcher)throw Error(`You need to pass "fieldMatcher" option in order to restrict access by fields`);if(e.conditions&&!t.conditionsMatcher)throw Error(`You need to pass "conditionsMatcher" option in order to restrict access by conditions`)}var YU=class{constructor(e,t,n=0){JU(e,t),this.action=t.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?IU(e.fields):void 0,this.priority=n,this.t=t}i(){return this.conditions&&!this.o&&(this.o=this.t.conditionsMatcher(this.conditions)),this.o}get ast(){let e=this.i();return e?e.ast:void 0}matchesConditions(e){return this.conditions?!e||zU(e)?!this.inverted:this.i()(e):!0}matchesField(e){return this.fields?e?(this.u||=this.t.fieldMatcher(this.fields),this.u(e)):!this.inverted:!0}};function XU(e,t){let n={value:e,prev:t,next:null};return t&&(t.next=n),n}function ZU(e){e.next&&(e.next.prev=e.prev),e.prev&&(e.prev.next=e.next),e.next=e.prev=null}var QU=e=>({value:e.value,prev:e.prev,next:e.next}),$U=()=>({rules:[],merged:!1}),eW=()=>new Map,tW=class{constructor(e=[],t={}){this.h=!1,this.l=new Map,this.p={conditionsMatcher:t.conditionsMatcher,fieldMatcher:t.fieldMatcher,resolveAction:t.resolveAction||qU},this.$=t.anyAction||`manage`,this.A=t.anySubjectType||`all`,this.m=e,this.M=!!t.detectSubjectType,this.j=t.detectSubjectType||HU,this.v(e)}get rules(){return this.m}detectSubjectType(e){return zU(e)?e:e?this.j(e):this.A}update(e){let t={rules:e,ability:this,target:this};return this._(`update`,t),this.m=e,this.v(e),this._(`updated`,t),this}v(e){let t=new Map,n;for(let r=e.length-1;r>=0;r--){let i=e.length-r-1,a=new YU(e[r],this.p,i),o=IU(a.action),s=IU(a.subject||this.A);!this.h&&a.fields&&(this.h=!0);for(let e=0;e<s.length;e++){let r=KU(t,s[e],eW);n===void 0&&(n=typeof s[e]),typeof s[e]!==n&&n!==`mixed`&&(n=`mixed`);for(let e=0;e<o.length;e++)KU(r,o[e],$U).rules.push(a)}}this.l=t,n!==`mixed`&&!this.M&&(this.j=UU[n]||UU.string)}possibleRulesFor(e,t=this.A){if(!zU(t))throw Error(`"possibleRulesFor" accepts only subject types (i.e., string or class) as the 2nd parameter`);let n=KU(this.l,t,eW),r=KU(n,e,$U);if(r.merged)return r.rules;let i=e!==this.$&&n.has(this.$)?n.get(this.$).rules:void 0,a=GU(r.rules,i);return t!==this.A&&(a=GU(a,this.possibleRulesFor(e,this.A))),r.rules=a,r.merged=!0,a}rulesFor(e,t,n){let r=this.possibleRulesFor(e,t);if(n&&typeof n!=`string`)throw 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?r.filter(e=>e.matchesField(n)):r}actionsFor(e){if(!zU(e))throw Error(`"actionsFor" accepts only subject types (i.e., string or class) as a parameter`);let t=new Set,n=this.l.get(e);n&&Array.from(n.keys()).forEach(e=>t.add(e));let r=e===this.A?void 0:this.l.get(this.A);return r&&Array.from(r.keys()).forEach(e=>t.add(e)),Array.from(t)}on(e,t){this.F=this.F||new Map;let n=this.F,r=XU(t,n.get(e)||null);return n.set(e,r),()=>{let t=n.get(e);!r.next&&!r.prev&&t===r?n.delete(e):r===t&&n.set(e,r.prev),ZU(r)}}_(e,t){if(!this.F)return;let n=this.F.get(e)||null;for(;n!==null;){let e=n.prev?QU(n.prev):null;n.value(t),n=e}}},nW=class extends tW{can(e,t,n){let r=this.relevantRuleFor(e,t,n);return!!r&&!r.inverted}relevantRuleFor(e,t,n){let r=this.detectSubjectType(t),i=this.rulesFor(e,r,n);for(let e=0,n=i.length;e<n;e++)if(i[e].matchesConditions(t))return i[e];return null}cannot(e,t,n){return!this.can(e,t,n)}},rW=PU({$eq:YH,$ne:XH,$lt:qH,$lte:JH,$gt:KH,$gte:GH,$in:BH,$nin:VH,$all:HH,$size:zH,$regex:ZH,$options:QH,$elemMatch:RH,$exists:WH},{eq:gU,ne:_U,lt:yU,lte:vU,gt:bU,gte:xU,in:EU,nin:DU,all:OU,size:wU,regex:TU,elemMatch:kU,exists:SU,and:mU}),iW=/[-/\\^$+?.()|[\]{}]/g,aW=/\.?\*+\.?/g,oW=/\*+/,sW=/\./g;function cW(e,t,n){let r=n[0]===`*`||e[0]===`.`&&e[e.length-1]===`.`?`+`:`*`,i=e.indexOf(`**`)===-1?`[^.]`:`.`,a=e.replace(sW,`\\$&`).replace(oW,i+r);return t+e.length===n.length?`(?:${a})?`:a}function lW(e,t,n){return e===`.`&&(n[t-1]===`*`||n[t+1]===`*`)?e:`\\${e}`}function uW(e){let t=e.map(e=>e.replace(iW,lW).replace(aW,cW)),n=t.length>1?`(?:${t.join(`|`)})`:t[0];return RegExp(`^${n}$`)}var dW=e=>{let t;return n=>(t===void 0&&(t=e.every(e=>e.indexOf(`*`)===-1)?null:uW(e)),t===null?e.indexOf(n)!==-1:t.test(n))};function fW(e=[],t={}){return new nW(e,Object.assign({conditionsMatcher:rW,fieldMatcher:dW},t))}var pW=e=>`Cannot execute "${e.action}" on "${e.subjectType}"`,mW=function(e){this.message=e};mW.prototype=Object.create(Error.prototype);var hW=class extends mW{static setDefaultMessage(e){this.P=typeof e==`string`?()=>e:e}static from(e){return new this(e)}constructor(e){super(``),this.ability=e,typeof Error.captureStackTrace==`function`&&(this.name=`ForbiddenError`,Error.captureStackTrace(this,this.constructor))}setMessage(e){return this.message=e,this}throwUnlessCan(e,t,n){let r=this.unlessCan(e,t,n);if(r)throw r}unlessCan(e,t,n){let r=this.ability.relevantRuleFor(e,t,n);if(r&&!r.inverted)return;this.action=e,this.subject=t,this.subjectType=VU(this.ability.detectSubjectType(t)),this.field=n;let i=r?r.reason:``;return this.message=this.message||i||this.constructor.P(this),this}};hW.P=pW,Object.freeze({__proto__:null});var gW=new Set([`read-project-private`,`read-project-public`]),_W=[`Table`,`Row`,`Branch`,`Revision`,`Endpoint`],vW=class{ability=fW();loadedScopes=new Set;addSystemPermissions(e){let t=this.scopeToKey({type:`system`});if(this.loadedScopes.has(t))return;let n=this.permissionsToRules(e,null),r=this.expandPermissions(e,null);this.ability.update([...this.ability.rules,...n,...r]),this.loadedScopes.add(t)}addOrganizationPermissions(e,t){let n=this.scopeToKey({type:`organization`,organizationId:e});if(this.loadedScopes.has(n))return;let r={organizationId:e},i=this.permissionsToRules(t,r),a=this.expandPermissions(t,r);this.ability.update([...this.ability.rules,...i,...a]),this.loadedScopes.add(n)}addProjectPermissions(e,t){let n=this.scopeToKey({type:`project`,projectId:e});if(this.loadedScopes.has(n))return;let r={projectId:e},i=this.permissionsToRules(t,r),a=this.expandPermissions(t,r);this.ability.update([...this.ability.rules,...i,...a]),this.loadedScopes.add(n)}addPublicReadPermissions(e){let t=`public:${e}`;if(this.loadedScopes.has(t))return;let n={projectId:e},r={action:`read`,subject:`Project`,conditions:{...n,isPublic:!0}},i=_W.map(e=>({action:`read`,subject:e,conditions:{...n}}));this.ability.update([...this.ability.rules,r,...i]),this.loadedScopes.add(t)}can(e,t,n){let r=RU(t,n?{...n}:{});return this.ability.can(e,r)}cannot(e,t,n){return!this.can(e,t,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,t){return e.map(e=>this.permissionToRule(e,t))}permissionToRule(e,t){let n={action:e.action,subject:e.subject},r=this.mergeConditions(e.condition,t);return r&&(n.conditions=r),n}mergeConditions(e,t){let n=e&&Object.keys(e).length>0,r=t&&Object.keys(t).length>0;if(!(!n&&!r))return n&&r?{...e,...t}:n?{...e}:{...t}}expandPermissions(e,t){let n=[];for(let r of e)if(gW.has(r.id))for(let e of _W){let r={action:`read`,subject:e};t&&Object.keys(t).length>0&&(r.conditions={...t}),n.push(r)}return n}};Y.register(vW,()=>new vW,{scope:`singleton`});var yW=class{constructor(e){this.permissionService=e,f(this,{},{autoBind:!0})}setUserRole(e){if(e?.permissions){let t=e.permissions.map(e=>({id:e.id,action:e.action,subject:e.subject,condition:e.condition??null}));this.permissionService.addSystemPermissions(t)}}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`)}};Y.register(yW,()=>new yW(Y.get(vW)),{scope:`singleton`});var bW=class{_contextProvider=null;constructor(e){this.permissionService=e,f(this,{},{autoBind:!0})}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(){let e=this.context,t={};return e.projectId&&(t.projectId=e.projectId),e.organizationId&&(t.organizationId=e.organizationId),t}can(e,t,n){let r=n??this.getProjectContext();return this.permissionService.can(e,t,Object.keys(r).length>0?r: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 canManageApiKeys(){return this.can(`manage`,`ApiKey`)}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}};Y.register(bW,()=>new bW(Y.get(vW)),{scope:`singleton`});var xW;n((()=>{xW=function(){return xW=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},xW.apply(this,arguments)}}))();var SW=new Map,CW=new Map,wW=!0,TW=!1;function EW(e){return e.replace(/[\s,]+/g,` `).trim()}function DW(e){return EW(e.source.body.substring(e.start,e.end))}function OW(e){var t=new Set,n=[];return e.definitions.forEach(function(e){if(e.kind===`FragmentDefinition`){var r=e.name.value,i=DW(e.loc),a=CW.get(r);a&&!a.has(i)?wW&&console.warn(`Warning: fragment with name `+r+` already exists.
383
383
  graphql-tag enforces all fragment names across your application to be unique; read more about
384
384
  this in the docs: http://dev.apollodata.com/core/fragments.html#unique-names`):a||CW.set(r,a=new Set),a.add(i),t.has(i)||(t.add(i),n.push(e))}else n.push(e)}),xW(xW({},e),{definitions:n})}function kW(e){var t=new Set(e.definitions);t.forEach(function(e){e.loc&&delete e.loc,Object.keys(e).forEach(function(n){var r=e[n];r&&typeof r==`object`&&t.add(r)})});var n=e.loc;return n&&(delete n.startToken,delete n.endToken),e}function AW(e){var t=EW(e);if(!SW.has(t)){var n=see(e,{experimentalFragmentVariables:TW,allowLegacyFragmentVariables:TW});if(!n||n.kind!==`Document`)throw Error(`Not a valid GraphQL document.`);SW.set(t,kW(OW(n)))}return SW.get(t)}function jW(e){var t=[...arguments].slice(1);typeof e==`string`&&(e=[e]);var n=e[0];return t.forEach(function(t,r){t&&t.kind===`Document`?n+=t.loc.source.body:n+=t,n+=e[r+1]}),AW(n)}function MW(){SW.clear(),CW.clear()}function NW(){wW=!1}function PW(){TW=!0}function FW(){TW=!1}var IW={gql:jW,resetCaches:MW,disableFragmentWarnings:NW,enableExperimentalFragmentVariables:PW,disableExperimentalFragmentVariables:FW};(function(e){e.gql=IW.gql,e.resetCaches=IW.resetCaches,e.disableFragmentWarnings=IW.disableFragmentWarnings,e.enableExperimentalFragmentVariables=IW.enableExperimentalFragmentVariables,e.disableExperimentalFragmentVariables=IW.disableExperimentalFragmentVariables})(jW||={}),jW.default=jW;var Z=jW,LW=function(e){return e.Applied=`applied`,e.Failed=`failed`,e.Skipped=`skipped`,e}({}),RW=function(e){return e.Active=`active`,e.Cancelled=`cancelled`,e.EarlyAdopter=`early_adopter`,e.Free=`free`,e.PastDue=`past_due`,e}({}),zW=function(e){return e.Added=`ADDED`,e.Modified=`MODIFIED`,e.Removed=`REMOVED`,e.Renamed=`RENAMED`,e.RenamedAndModified=`RENAMED_AND_MODIFIED`,e}({}),BW=function(e){return e.Graphql=`GRAPHQL`,e.RestApi=`REST_API`,e}({}),VW=function(e){return e.CreatedAt=`createdAt`,e.Data=`data`,e.Id=`id`,e.PublishedAt=`publishedAt`,e.UpdatedAt=`updatedAt`,e}({}),HW=function(e){return e.Boolean=`boolean`,e.Float=`float`,e.Int=`int`,e.Text=`text`,e.Timestamp=`timestamp`,e}({}),UW=function(e){return e.Replace=`replace`,e}({}),WW=function(e){return e.Default=`default`,e.Insensitive=`insensitive`,e}({}),GW=function(e){return e.All=`all`,e.Booleans=`booleans`,e.Keys=`keys`,e.Numbers=`numbers`,e.Strings=`strings`,e.Values=`values`,e}({}),KW=function(e){return e.Phrase=`phrase`,e.Plain=`plain`,e.Prefix=`prefix`,e.Tsquery=`tsquery`,e}({}),qW=function(e){return e.Asc=`asc`,e.Desc=`desc`,e}({}),JW=function(e){return e.Developer=`developer`,e.Editor=`editor`,e.OrganizationAdmin=`organizationAdmin`,e.OrganizationOwner=`organizationOwner`,e.Reader=`reader`,e}({}),YW=function(e){return e.Developer=`developer`,e.Editor=`editor`,e.Reader=`reader`,e}({}),XW=function(e){return e.SystemAdmin=`systemAdmin`,e.SystemFullApiRead=`systemFullApiRead`,e.SystemUser=`systemUser`,e}({}),ZW=Z`
385
385
  fragment BranchLoaderFragment on BranchModel {
@@ -2163,7 +2163,7 @@ this in the docs: http://dev.apollodata.com/core/fragments.html#unique-names`):a
2163
2163
  }
2164
2164
  }
2165
2165
  ${LG}
2166
- `,jq=(e,t,n,r)=>e();function Mq(e,t=jq){return{getBranchForLoader(n,r){return t(t=>e.request(RG,n,{...r,...t}),`getBranchForLoader`,`query`,n)},organizationProjects(n,r){return t(t=>e.request(zG,n,{...r,...t}),`organizationProjects`,`query`,n)},getProject(n,r){return t(t=>e.request(BG,n,{...r,...t}),`getProject`,`query`,n)},getProjectForLoader(n,r){return t(t=>e.request(VG,n,{...r,...t}),`getProjectForLoader`,`query`,n)},getRevisionForLoader(n,r){return t(t=>e.request(HG,n,{...r,...t}),`getRevisionForLoader`,`query`,n)},getRowForLoader(n,r){return t(t=>e.request(UG,n,{...r,...t}),`getRowForLoader`,`query`,n)},getRowCountForeignKeysToForLoader(n,r){return t(t=>e.request(WG,n,{...r,...t}),`getRowCountForeignKeysToForLoader`,`query`,n)},ForeignKeysBy(n,r){return t(t=>e.request(GG,n,{...r,...t}),`ForeignKeysBy`,`query`,n)},ForeignKeysByRows(n,r){return t(t=>e.request(KG,n,{...r,...t}),`ForeignKeysByRows`,`query`,n)},getTableForLoader(n,r){return t(t=>e.request(qG,n,{...r,...t}),`getTableForLoader`,`query`,n)},updatePassword(n,r){return t(t=>e.request(JG,n,{...r,...t}),`updatePassword`,`mutation`,n)},myApiKeys(n,r){return t(t=>e.request(YG,n,{...r,...t}),`myApiKeys`,`query`,n)},serviceApiKeys(n,r){return t(t=>e.request(XG,n,{...r,...t}),`serviceApiKeys`,`query`,n)},apiKeyById(n,r){return t(t=>e.request(ZG,n,{...r,...t}),`apiKeyById`,`query`,n)},createPersonalApiKey(n,r){return t(t=>e.request(QG,n,{...r,...t}),`createPersonalApiKey`,`mutation`,n)},createServiceApiKey(n,r){return t(t=>e.request($G,n,{...r,...t}),`createServiceApiKey`,`mutation`,n)},revokeApiKey(n,r){return t(t=>e.request(eK,n,{...r,...t}),`revokeApiKey`,`mutation`,n)},rotateApiKey(n,r){return t(t=>e.request(tK,n,{...r,...t}),`rotateApiKey`,`mutation`,n)},createProject(n,r){return t(t=>e.request(nK,n,{...r,...t}),`createProject`,`mutation`,n)},findForeignKey(n,r){return t(t=>e.request(rK,n,{...r,...t}),`findForeignKey`,`query`,n)},adminCacheStats(n,r){return t(t=>e.request(iK,n,{...r,...t}),`adminCacheStats`,`query`,n)},adminResetAllCache(n,r){return t(t=>e.request(aK,n,{...r,...t}),`adminResetAllCache`,`mutation`,n)},AdminDashboardStats(n,r){return t(t=>e.request(oK,n,{...r,...t}),`AdminDashboardStats`,`query`,n)},adminGetUser(n,r){return t(t=>e.request(sK,n,{...r,...t}),`adminGetUser`,`query`,n)},adminResetPassword(n,r){return t(t=>e.request(cK,n,{...r,...t}),`adminResetPassword`,`mutation`,n)},adminUsers(n,r){return t(t=>e.request(lK,n,{...r,...t}),`adminUsers`,`query`,n)},adminUser(n,r){return t(t=>e.request(uK,n,{...r,...t}),`adminUser`,`query`,n)},assetsTablesData(n,r){return t(t=>e.request(dK,n,{...r,...t}),`assetsTablesData`,`query`,n)},assetsRowsData(n,r){return t(t=>e.request(fK,n,{...r,...t}),`assetsRowsData`,`query`,n)},subSchemaItemsData(n,r){return t(t=>e.request(pK,n,{...r,...t}),`subSchemaItemsData`,`query`,n)},getProjectBranches(n,r){return t(t=>e.request(mK,n,{...r,...t}),`getProjectBranches`,`query`,n)},deleteBranch(n,r){return t(t=>e.request(hK,n,{...r,...t}),`deleteBranch`,`mutation`,n)},getBranchesForSelect(n,r){return t(t=>e.request(gK,n,{...r,...t}),`getBranchesForSelect`,`query`,n)},getBranchRevisionsForCreate(n,r){return t(t=>e.request(_K,n,{...r,...t}),`getBranchRevisionsForCreate`,`query`,n)},createBranch(n,r){return t(t=>e.request(vK,n,{...r,...t}),`createBranch`,`mutation`,n)},GetRevisionChanges(n,r){return t(t=>e.request(yK,n,{...r,...t}),`GetRevisionChanges`,`query`,n)},GetTableChanges(n,r){return t(t=>e.request(bK,n,{...r,...t}),`GetTableChanges`,`query`,n)},confirmEmailCode(n,r){return t(t=>e.request(xK,n,{...r,...t}),`confirmEmailCode`,`mutation`,n)},getEndpointBranches(n,r){return t(t=>e.request(SK,n,{...r,...t}),`getEndpointBranches`,`query`,n)},getProjectEndpoints(n,r){return t(t=>e.request(CK,n,{...r,...t}),`getProjectEndpoints`,`query`,n)},getBranchRevisions(n,r){return t(t=>e.request(wK,n,{...r,...t}),`getBranchRevisions`,`query`,n)},createEndpoint(n,r){return t(t=>e.request(TK,n,{...r,...t}),`createEndpoint`,`mutation`,n)},deleteEndpoint(n,r){return t(t=>e.request(EK,n,{...r,...t}),`deleteEndpoint`,`mutation`,n)},issueAccessToken(n,r){return t(t=>e.request(DK,n,{...r,...t}),`issueAccessToken`,`query`,n)},loginGithub(n,r){return t(t=>e.request(OK,n,{...r,...t}),`loginGithub`,`mutation`,n)},loginGoogle(n,r){return t(t=>e.request(kK,n,{...r,...t}),`loginGoogle`,`mutation`,n)},login(n,r){return t(t=>e.request(AK,n,{...r,...t}),`login`,`mutation`,n)},getMigrationBranches(n,r){return t(t=>e.request(jK,n,{...r,...t}),`getMigrationBranches`,`query`,n)},getBranchMigrations(n,r){return t(t=>e.request(MK,n,{...r,...t}),`getBranchMigrations`,`query`,n)},applyMigrations(n,r){return t(t=>e.request(NK,n,{...r,...t}),`applyMigrations`,`mutation`,n)},getMigrations(n,r){return t(t=>e.request(PK,n,{...r,...t}),`getMigrations`,`query`,n)},activateEarlyAccess(n,r){return t(t=>e.request(FK,n,{...r,...t}),`activateEarlyAccess`,`mutation`,n)},createCheckout(n,r){return t(t=>e.request(IK,n,{...r,...t}),`createCheckout`,`mutation`,n)},cancelSubscription(n,r){return t(t=>e.request(LK,n,{...r,...t}),`cancelSubscription`,`mutation`,n)},getLimitsPageData(n,r){return t(t=>e.request(RK,n,{...r,...t}),`getLimitsPageData`,`query`,n)},getLimitsPagePlans(n,r){return t(t=>e.request(zK,n,{...r,...t}),`getLimitsPagePlans`,`query`,n)},getUsersOrganization(n,r){return t(t=>e.request(BK,n,{...r,...t}),`getUsersOrganization`,`query`,n)},addUserToOrganization(n,r){return t(t=>e.request(VK,n,{...r,...t}),`addUserToOrganization`,`mutation`,n)},removeUserFromOrganization(n,r){return t(t=>e.request(HK,n,{...r,...t}),`removeUserFromOrganization`,`mutation`,n)},adminValidateProjectFileBytes(n,r){return t(t=>e.request(UK,n,{...r,...t}),`adminValidateProjectFileBytes`,`query`,n)},adminRestoreProjectFileBytes(n,r){return t(t=>e.request(WK,n,{...r,...t}),`adminRestoreProjectFileBytes`,`mutation`,n)},updateProject(n,r){return t(t=>e.request(GK,n,{...r,...t}),`updateProject`,`mutation`,n)},deleteProjectForSettings(n,r){return t(t=>e.request(KK,n,{...r,...t}),`deleteProjectForSettings`,`mutation`,n)},fetchTableForStack(n,r){return t(t=>e.request(qK,n,{...r,...t}),`fetchTableForStack`,`query`,n)},createTableForStack(n,r){return t(t=>e.request(JK,n,{...r,...t}),`createTableForStack`,`mutation`,n)},updateTableForStack(n,r){return t(t=>e.request(YK,n,{...r,...t}),`updateTableForStack`,`mutation`,n)},renameTableForStack(n,r){return t(t=>e.request(XK,n,{...r,...t}),`renameTableForStack`,`mutation`,n)},rowPageData(n,r){return t(t=>e.request(ZK,n,{...r,...t}),`rowPageData`,`query`,n)},signUp(n,r){return t(t=>e.request(QK,n,{...r,...t}),`signUp`,`mutation`,n)},setUsername(n,r){return t(t=>e.request($K,n,{...r,...t}),`setUsername`,`mutation`,n)},getUsersProject(n,r){return t(t=>e.request(eq,n,{...r,...t}),`getUsersProject`,`query`,n)},searchUsers(n,r){return t(t=>e.request(tq,n,{...r,...t}),`searchUsers`,`query`,n)},addUserToProject(n,r){return t(t=>e.request(nq,n,{...r,...t}),`addUserToProject`,`mutation`,n)},removeUserFromProject(n,r){return t(t=>e.request(rq,n,{...r,...t}),`removeUserFromProject`,`mutation`,n)},updateUserProjectRole(n,r){return t(t=>e.request(iq,n,{...r,...t}),`updateUserProjectRole`,`mutation`,n)},createUser(n,r){return t(t=>e.request(aq,n,{...r,...t}),`createUser`,`mutation`,n)},configuration(n,r){return t(t=>e.request(oq,n,{...r,...t}),`configuration`,`query`,n)},getMe(n,r){return t(t=>e.request(sq,n,{...r,...t}),`getMe`,`query`,n)},getProjectGraph(n,r){return t(t=>e.request(cq,n,{...r,...t}),`getProjectGraph`,`query`,n)},findBranches(n,r){return t(t=>e.request(lq,n,{...r,...t}),`findBranches`,`query`,n)},findRevisions(n,r){return t(t=>e.request(uq,n,{...r,...t}),`findRevisions`,`query`,n)},meProjectsList(n,r){return t(t=>e.request(dq,n,{...r,...t}),`meProjectsList`,`query`,n)},GetRowChanges(n,r){return t(t=>e.request(fq,n,{...r,...t}),`GetRowChanges`,`query`,n)},GetTableChangesForFilter(n,r){return t(t=>e.request(pq,n,{...r,...t}),`GetTableChangesForFilter`,`query`,n)},foreignKeyTableWithRows(n,r){return t(t=>e.request(mq,n,{...r,...t}),`foreignKeyTableWithRows`,`query`,n)},createRowForStack(n,r){return t(t=>e.request(hq,n,{...r,...t}),`createRowForStack`,`mutation`,n)},updateRowForStack(n,r){return t(t=>e.request(gq,n,{...r,...t}),`updateRowForStack`,`mutation`,n)},renameRowForStack(n,r){return t(t=>e.request(_q,n,{...r,...t}),`renameRowForStack`,`mutation`,n)},RowListRows(n,r){return t(t=>e.request(vq,n,{...r,...t}),`RowListRows`,`query`,n)},DeleteRow(n,r){return t(t=>e.request(yq,n,{...r,...t}),`DeleteRow`,`mutation`,n)},DeleteRows(n,r){return t(t=>e.request(bq,n,{...r,...t}),`DeleteRows`,`mutation`,n)},PatchRowInline(n,r){return t(t=>e.request(xq,n,{...r,...t}),`PatchRowInline`,`mutation`,n)},GetTableViews(n,r){return t(t=>e.request(Sq,n,{...r,...t}),`GetTableViews`,`query`,n)},UpdateTableViews(n,r){return t(t=>e.request(Cq,n,{...r,...t}),`UpdateTableViews`,`mutation`,n)},searchRows(n,r){return t(t=>e.request(wq,n,{...r,...t}),`searchRows`,`query`,n)},revertChangesForSidebar(n,r){return t(t=>e.request(Tq,n,{...r,...t}),`revertChangesForSidebar`,`mutation`,n)},createRevisionForSidebar(n,r){return t(t=>e.request(Eq,n,{...r,...t}),`createRevisionForSidebar`,`mutation`,n)},createBranchForSidebar(n,r){return t(t=>e.request(Dq,n,{...r,...t}),`createBranchForSidebar`,`mutation`,n)},deleteTableForList(n,r){return t(t=>e.request(Oq,n,{...r,...t}),`deleteTableForList`,`mutation`,n)},tableListData(n,r){return t(t=>e.request(kq,n,{...r,...t}),`tableListData`,`query`,n)},tableRelationsData(n,r){return t(t=>e.request(Aq,n,{...r,...t}),`tableRelationsData`,`query`,n)}}}var Nq=class{constructor(){}get(e){let t=globalThis.__env__?.[e],n={BASE_URL:`/`,DEV:!1,GIT_BRANCH_NAME:`HEAD`,GIT_COMMIT_HASH:`fa903ef`,MODE:`production`,PACKAGE_VERSION:`2.7.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}[e];return t||n}};Y.register(Nq,()=>new Nq,{scope:`singleton`});var Pq=`revisium:sidebar-collapsed`,Fq=200,Iq=class{_isCollapsed=!1;_isHoverExpanded=!1;_hoverDelay=new cH(Fq);_leaveDelay=new cH(Fq);_keyboardHandler=null;constructor(e){this.storage=e,this._isCollapsed=e.getItem(Pq)===`true`,f(this,{},{autoBind:!0}),s(()=>this._isCollapsed,e=>{this.storage.setItem(Pq,String(e))})}get isCollapsed(){return this._isCollapsed}get isHoverExpanded(){return this._isHoverExpanded}get isSidebarVisible(){return!this._isCollapsed||this._isHoverExpanded}toggle(){this._isCollapsed=!this._isCollapsed,this._isHoverExpanded=!1}setHoverExpanded(e){this._isHoverExpanded=e}startHoverIntent(){this._leaveDelay.cancel(),this._hoverDelay.schedule(()=>{this.setHoverExpanded(!0)})}cancelHoverIntent(){this._hoverDelay.cancel()}startLeaveIntent(){this._leaveDelay.schedule(()=>{this.setHoverExpanded(!1)})}cancelLeaveIntent(){this._leaveDelay.cancel()}dismissOverlay(){this.setHoverExpanded(!1)}initKeyboard(){this._keyboardHandler||(this._keyboardHandler=e=>{(e.metaKey||e.ctrlKey)&&e.key===`\\`&&(e.preventDefault(),this.toggle())},globalThis.addEventListener(`keydown`,this._keyboardHandler))}disposeKeyboard(){this._keyboardHandler&&=(globalThis.removeEventListener(`keydown`,this._keyboardHandler),null),this._hoverDelay.dispose(),this._leaveDelay.dispose()}};Y.register(Iq,()=>new Iq(localStorage),{scope:`singleton`});var Lq=({sidebar:e,footer:t})=>(0,I.jsxs)(I.Fragment,{children:[e,t&&(0,I.jsx)(A,{alignSelf:`center`,mt:`1rem`,children:t})]}),Rq=288,zq=48,Bq=`0.2s`,Vq=g(({hideSidebar:e,sidebar:t,title:n,actions:r,children:i,footer:a})=>{let o=Y.get(Iq);(0,L.useEffect)(()=>(o.initKeyboard(),()=>{o.disposeKeyboard()}),[o]);let s=!e,c=s&&o.isCollapsed,l=c&&o.isHoverExpanded,u=s?c?`${zq}px`:`${Rq}px`:`0px`;return(0,I.jsxs)(j,{minHeight:`100vh`,children:[s&&(0,I.jsx)(j,{width:u,minWidth:u,flexShrink:0,height:`100vh`,top:0,position:`sticky`,transition:`width ${Bq} ease, min-width ${Bq} ease`,overflow:`hidden`,children:c?(0,I.jsx)(j,{width:`${zq}px`,minWidth:`${zq}px`,height:`100vh`,flexDirection:`column`,alignItems:`center`,paddingTop:`20px`,onMouseEnter:o.startHoverIntent,onMouseLeave:o.cancelHoverIntent,children:(0,I.jsx)(A,{as:`button`,fontSize:`20px`,color:`newGray.400`,cursor:`pointer`,_hover:{color:`newGray.600`},display:`flex`,alignItems:`center`,onClick:o.toggle,"aria-label":`Toggle sidebar`,children:(0,I.jsx)(Zte,{})})}):(0,I.jsx)(j,{width:`${Rq}px`,minWidth:`${Rq}px`,borderRight:`1px solid`,borderRightColor:`newGray.100`,flexDirection:`column`,justifyContent:t?`space-between`:`flex-end`,padding:`16px`,height:`100vh`,children:(0,I.jsx)(Lq,{sidebar:t,footer:a})})}),c&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(A,{position:`fixed`,left:0,top:0,width:`100vw`,height:`100vh`,zIndex:9,pointerEvents:l?`auto`:`none`,onClick:o.dismissOverlay}),(0,I.jsx)(j,{position:`fixed`,left:0,top:0,width:`${Rq}px`,height:`100vh`,zIndex:10,backgroundColor:`white`,borderRight:`1px solid`,borderRightColor:`newGray.100`,flexDirection:`column`,justifyContent:t?`space-between`:`flex-end`,padding:`16px`,boxShadow:l?`4px 0 12px rgba(0, 0, 0, 0.08)`:`none`,transform:l?`translateX(0)`:`translateX(-${Rq}px)`,transition:`transform ${Bq} ease, box-shadow ${Bq} ease`,onMouseLeave:o.startLeaveIntent,onMouseEnter:o.cancelLeaveIntent,pointerEvents:l?`auto`:`none`,children:(0,I.jsx)(Lq,{sidebar:t,footer:a})})]}),(0,I.jsxs)(j,{flex:1,minWidth:0,flexDirection:`column`,alignItems:`center`,children:[(n||r)&&(0,I.jsxs)(j,{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:[n,r]}),(0,I.jsx)(j,{flex:1,flexDirection:`column`,maxWidth:`900px`,padding:`1rem 1rem 0rem 1rem`,width:`100%`,children:i})]})]})}),Hq=({height:e=`2.5rem`,title:t,onClick:n,disabled:r,isSelected:i,isLoading:a,icon:o,dataTestId:s})=>(0,I.jsx)(N,{"data-testid":s,_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:e,disabled:r||i,loading:a,variant:`ghost`,onClick:n,children:(0,I.jsxs)(j,{alignItems:`center`,gap:`0.5rem`,children:[o&&(0,I.jsx)(A,{fontSize:`sm`,children:o}),(0,I.jsx)(k,{children:t})]})}),Uq=e=>(0,I.jsx)(Hq,{...e,icon:(0,I.jsx)(af,{})}),Wq=({height:e=`2.5rem`,loading:t,isDisabled:n,onClick:r,title:i,dataTestId:a})=>(0,I.jsxs)(N,{"data-testid":a,_hover:{backgroundColor:`gray.50`},alignSelf:`flex-start`,color:`gray.400`,height:e,loading:t,disabled:n,variant:`ghost`,onClick:r,width:`48px`,children:[(0,I.jsx)(Ve,{size:`sm`,mr:i?8:0,children:(0,I.jsx)(ef,{})}),i]}),Gq=({height:e=`2.5rem`,onClick:t,disabled:n,dataTestId:r})=>(0,I.jsx)(N,{"data-testid":r,disabled:n,_hover:{backgroundColor:`gray.50`},alignSelf:`flex-start`,color:`gray.400`,height:e,variant:`ghost`,onClick:t,width:`48px`,children:(0,I.jsx)(Ve,{size:`md`,children:(0,I.jsx)(ip,{})})}),Kq=({dataTestId:e,...t})=>(0,I.jsx)(Ze,{"data-testid":e,_hover:{backgroundColor:`gray.100`},color:`gray.400`,variant:`ghost`,size:`lg`,width:`40px`,height:`40px`,...t,children:(0,I.jsx)(nf,{})}),qq=({value:e,placeholder:t,autoFocus:n,onChange:r,onBlur:i,onEnter:a,width:o,height:s,type:c,dataTestId:l,autoComplete:u})=>{let d=SB();return(0,I.jsx)(qt,{autoComplete:u,"data-testid":l,borderColor:`gray.100`,padding:`0 9px`,placeholder:t,ref:n?d:void 0,value:e,variant:`outline`,onChange:r,onBlur:i,width:o,height:s,type:c,onKeyDown:a?e=>{e.key===`Enter`&&a()}:void 0})},Jq=Rd({placement:`top`,pauseOnPageIdle:!0,duration:1500}),Yq=Rd({placement:`bottom`,pauseOnPageIdle:!0,duration:1500}),Xq=e=>(0,I.jsxs)(_t,{width:{md:`sm`},children:[e.type===`loading`?(0,I.jsx)(Ht,{size:`sm`,color:`blue.solid`}):(0,I.jsx)(ft,{}),(0,I.jsxs)(_e,{gap:`1`,flex:`1`,maxWidth:`100%`,children:[e.title&&(0,I.jsx)(eee,{children:e.title}),e.description&&(0,I.jsx)(ree,{color:`gray.500`,children:e.description})]}),e.action&&(0,I.jsx)(lt,{children:e.action.label}),e.closable&&(0,I.jsx)(Ft,{})]}),Zq=()=>(0,I.jsxs)(R,{children:[(0,I.jsx)(Rt,{toaster:Jq,insetInline:{mdDown:`4`},children:e=>(0,I.jsx)(Xq,{...e})}),(0,I.jsx)(Rt,{toaster:Yq,insetInline:{mdDown:`4`},children:e=>(0,I.jsx)(Xq,{...e})})]}),Qq=L.forwardRef(function(e,t){let{showArrow:n,children:r,disabled:i,portalled:a=!0,content:o,contentProps:s,portalRef:c,...l}=e;return i?r:(0,I.jsxs)(Wt,{...l,children:[(0,I.jsx)(Qt,{asChild:!0,children:r}),(0,I.jsx)(R,{disabled:!a,container:c,children:(0,I.jsx)(rt,{children:(0,I.jsxs)(Et,{ref:t,...s,children:[n&&(0,I.jsx)(Vt,{children:(0,I.jsx)(Yt,{})}),o]})})})]})}),$q={deprecated:{type:`boolean`},title:{type:`string`},description:{type:`string`}};({...$q});var eJ={type:{const:`string`},default:{type:`string`},readOnly:{type:`boolean`},pattern:{type:`string`,format:`regex`},enum:{type:`array`,items:{type:`string`},minItems:1,uniqueItems:!0},format:{type:`string`,enum:[`date-time`,`date`,`time`,`email`,`regex`]},contentMediaType:{type:`string`,enum:[`text/plain`,`text/markdown`,`text/html`,`application/json`,`application/schema+json`,`application/yaml`]},...$q};({...eJ}),{...eJ},{...$q},{...$q},{...$q},{...$q};var tJ=new(e(vd(),1)).default;tJ.addKeyword({keyword:`foreignKey`,type:`string`}),tJ.addFormat(`regex`,{type:`string`,validate:e=>{try{return new RegExp(e),!0}catch{return!1}}});var nJ=(e,t)=>({result:tJ.validate(e,t),errors:tJ.errors}),rJ=({dataTestId:e,...t})=>(0,I.jsx)(Ze,{"data-testid":e,_hover:{backgroundColor:`gray.100`},color:`gray.400`,variant:`ghost`,...t,children:(0,I.jsx)(qf,{})}),iJ={JsonCard:`_JsonCard_15gzu_1`,CopyButton:`_CopyButton_15gzu_1`},aJ=({data:e,readonly:t,onChange:n,schema:r,onBlur:i})=>{let[a,o]=(0,L.useState)(``),s=JSON.stringify(e,null,3),[c,l]=(0,L.useState)(s),u=(0,L.useRef)(!1),d=u.current?c:s,f=(0,L.useCallback)(async()=>{await navigator.clipboard.writeText(d),Jq.info({duration:1500,description:`Copied to clipboard`})},[d]),p=(0,L.useCallback)(e=>{l(e);try{let t=JSON.parse(e);if(r){let e=nJ(r,t);if(!e.result){o(`"${e.errors?.[0]?.instancePath||`/`}": ${e.errors?.[0]?.message}`);return}}o(``),n?.(t)}catch(e){console.error(e),o(`Invalid JSON`)}},[n,r]),m=(0,L.useCallback)(()=>{u.current=!0,l(s)},[s]),h=(0,L.useCallback)(()=>{u.current=!1,l(s),i?.()},[i,s]);return(0,I.jsxs)(j,{position:`relative`,width:`100%`,flex:1,className:iJ.JsonCard,direction:`column`,gap:`1rem`,children:[(0,I.jsxs)(A,{p:1,flex:1,children:[(0,I.jsx)(DO,{value:d,extensions:[G.lineWrapping,nk()],editable:!t,theme:pC,maxWidth:`100%`,basicSetup:{lineNumbers:!0,foldGutter:!0},onChange:p,onFocus:m,onBlur:h}),(0,I.jsx)(rJ,{dataTestId:`json-card-copy-button`,"aria-label":``,position:`absolute`,top:`8px`,right:`8px`,className:iJ.CopyButton,onClick:f})]}),(0,I.jsx)(j,{height:`40px`,paddingBottom:`8px`,alignItems:`flex-end`,backgroundColor:`white`,width:`100%`,position:`sticky`,bottom:0,justifyContent:`center`,children:(0,I.jsx)(k,{color:`gray`,children:a})})]})},oJ=g(()=>{let e=Y.get(Iq),t=e.isCollapsed&&e.isHoverExpanded,n=t?`Expand sidebar`:`Collapse sidebar`,r=t?Ite:Fte;return(0,I.jsx)(Qq,{content:n,children:(0,I.jsx)(A,{as:`button`,fontSize:`20px`,color:`newGray.400`,cursor:`pointer`,_hover:{color:`newGray.600`},display:`flex`,alignItems:`center`,flexShrink:0,onClick:e.toggle,opacity:+!!t,_groupHover:{opacity:1},transition:`opacity 0.15s ease`,"aria-label":n,children:(0,I.jsx)(r,{})})})}),sJ=({to:e,label:t,isActive:n,icon:r,onClick:i,badge:a})=>{let o=(0,I.jsxs)(j,{alignItems:`center`,backgroundColor:n?`newGray.100`:`transparent`,_hover:{backgroundColor:`newGray.100`},borderRadius:`8px`,height:`36px`,paddingX:`8px`,width:`100%`,color:n?`black`:`newGray.600`,fontWeight:`400`,textDecoration:`none`,fontSize:`14px`,minWidth:`0`,cursor:`pointer`,gap:`12px`,userSelect:`none`,onClick:i,children:[r&&(0,I.jsx)(A,{fontSize:`20px`,color:`newGray.400`,children:r}),(0,I.jsx)(A,{flex:`1`,minWidth:`0`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,overflow:`hidden`,children:t}),a!=null&&a>0&&(0,I.jsx)(A,{fontSize:`11px`,fontWeight:`600`,color:`newGray.400`,backgroundColor:`newGray.100`,borderRadius:`4px`,paddingX:`6px`,paddingY:`2px`,minWidth:`20px`,textAlign:`center`,children:a>99?`99+`:a})]});return e&&!i?(0,I.jsx)(An,{to:e,style:{textDecoration:`none`,width:`100%`},children:o}):o},cJ=g(({model:e,roleSlot:t,disableRemove:n})=>(0,I.jsx)(A,{borderWidth:`1px`,borderColor:`newGray.200`,borderRadius:`md`,padding:`1rem`,backgroundColor:`white`,_hover:{borderColor:`newGray.300`},transition:`border-color 0.2s`,children:(0,I.jsxs)(j,{justify:`space-between`,align:`center`,children:[(0,I.jsxs)(P,{gap:3,children:[(0,I.jsx)(A,{color:`newGray.400`,children:(0,I.jsx)(zf,{size:20})}),(0,I.jsxs)(A,{children:[(0,I.jsx)(k,{fontWeight:`500`,color:`newGray.600`,children:e.displayName}),e.username&&e.email&&(0,I.jsx)(k,{fontSize:`xs`,color:`newGray.400`,children:e.email})]})]}),(0,I.jsxs)(P,{gap:3,children:[t,e.canRemove&&(0,I.jsx)(N,{variant:`ghost`,size:`sm`,color:`red.500`,onClick:()=>e.remove(),loading:e.isRemoving,disabled:n,children:(0,I.jsx)(Rf,{})})]})]})})),lJ=g(({model:e,title:t,roleSelect:n})=>(0,I.jsx)(Ue,{open:e.isOpen,onOpenChange:({open:t})=>!t&&e.close(),size:`lg`,children:(0,I.jsxs)(R,{children:[(0,I.jsx)(pe,{}),(0,I.jsx)(ue,{children:(0,I.jsxs)(_n,{children:[(0,I.jsx)(Ge,{children:(0,I.jsx)(qe,{children:t})}),(0,I.jsx)(be,{children:(0,I.jsxs)(rn,{value:e.activeTab,onValueChange:({value:t})=>e.setActiveTab(t),children:[(0,I.jsxs)(et,{marginBottom:`1rem`,children:[(0,I.jsx)(fn,{value:`search`,children:`Search User`}),e.canCreateUser&&(0,I.jsx)(fn,{value:`create`,children:`Create New`})]}),(0,I.jsx)(bt,{value:`search`,children:(0,I.jsxs)(M,{align:`stretch`,gap:`1rem`,children:[(0,I.jsxs)(j,{flexDirection:`column`,gap:`0.5rem`,children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`500`,color:`gray.600`,children:`Search by username or email`}),(0,I.jsx)(qt,{placeholder:`Enter username or email...`,value:e.searchQuery,onChange:t=>e.setSearchQuery(t.target.value),autoComplete:`off`})]}),e.isSearching?(0,I.jsx)(j,{justify:`center`,padding:`2rem`,children:(0,I.jsx)(Ht,{})}):e.searchResults.length>0?(0,I.jsx)(M,{align:`stretch`,gap:`0.5rem`,maxHeight:`200px`,overflowY:`auto`,children:e.searchResults.map(t=>(0,I.jsx)(A,{padding:`0.75rem`,borderWidth:`1px`,borderColor:e.selectedUserId===t.id?`blue.500`:`newGray.200`,borderRadius:`md`,backgroundColor:e.selectedUserId===t.id?`blue.50`:`white`,cursor:`pointer`,onClick:()=>e.setSelectedUserId(t.id),_hover:{borderColor:`blue.300`},transition:`all 0.2s`,children:(0,I.jsxs)(j,{align:`center`,justify:`space-between`,children:[(0,I.jsxs)(j,{align:`center`,gap:2,children:[(0,I.jsx)(zf,{size:16}),(0,I.jsxs)(A,{children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`500`,children:t.username||t.email||t.id}),t.username&&t.email&&(0,I.jsx)(k,{fontSize:`xs`,color:`gray.500`,children:t.email})]})]}),e.selectedUserId===t.id&&(0,I.jsx)(Lte,{size:16,color:`var(--chakra-colors-blue-500)`})]})},t.id))}):e.searchQuery.length>0?(0,I.jsx)(k,{fontSize:`sm`,color:`gray.500`,textAlign:`center`,padding:`2rem`,children:`No users found`}):null,(0,I.jsxs)(j,{flexDirection:`column`,gap:`0.5rem`,children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`500`,color:`gray.600`,children:`Role`}),n]})]})}),e.canCreateUser&&(0,I.jsx)(bt,{value:`create`,children:(0,I.jsxs)(M,{align:`stretch`,gap:`1rem`,children:[(0,I.jsxs)(j,{flexDirection:`column`,gap:`0.5rem`,children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`500`,color:`gray.600`,children:`Username *`}),(0,I.jsx)(qt,{placeholder:`Enter username...`,value:e.newUsername,onChange:t=>e.setNewUsername(t.target.value),autoComplete:`off`})]}),(0,I.jsxs)(j,{flexDirection:`column`,gap:`0.5rem`,children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`500`,color:`gray.600`,children:`Password *`}),(0,I.jsx)(qt,{type:`password`,placeholder:`Enter password (min 6 characters)...`,value:e.newPassword,onChange:t=>e.setNewPassword(t.target.value),autoComplete:`new-password`})]}),(0,I.jsxs)(j,{flexDirection:`column`,gap:`0.5rem`,children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`500`,color:`gray.600`,children:`Email (optional)`}),(0,I.jsx)(qt,{type:`email`,placeholder:`Enter email...`,value:e.newEmail,onChange:t=>e.setNewEmail(t.target.value),autoComplete:`off`})]}),(0,I.jsxs)(j,{flexDirection:`column`,gap:`0.5rem`,children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`500`,color:`gray.600`,children:`Role`}),n]})]})})]})}),(0,I.jsxs)(w,{children:[(0,I.jsx)(N,{variant:`outline`,onClick:e.close,children:`Cancel`}),e.activeTab===`search`?(0,I.jsx)(N,{onClick:e.addSelectedUser,disabled:!e.canAddSelectedUser,loading:e.isAdding,children:`Add User`}):(0,I.jsx)(N,{onClick:e.createAndAddUser,disabled:!e.canCreateNewUser,loading:e.isCreating,children:`Create & Add`})]}),(0,I.jsx)(Ie,{})]})})]})})),uJ=g(({model:e,sidebar:t,label:n,emptyTitle:r,emptySubtitle:i,subtitle:a,onAddClick:o,modal:s,children:c})=>e.showInitialLoading?(0,I.jsx)(Vq,{sidebar:t,children:(0,I.jsx)(j,{justify:`center`,align:`center`,height:`200px`,children:(0,I.jsx)(Ht,{})})}):e.showError?(0,I.jsx)(Vq,{sidebar:t,children:(0,I.jsx)(j,{justify:`center`,align:`center`,height:`200px`,children:(0,I.jsxs)(k,{color:`red.500`,children:[`Error loading `,n.toLowerCase()]})})}):e.showNoMembers?(0,I.jsxs)(Vq,{sidebar:t,children:[(0,I.jsx)(A,{mb:`4rem`,children:(0,I.jsxs)(j,{justify:`center`,align:`center`,height:`200px`,flexDirection:`column`,gap:4,children:[(0,I.jsxs)(A,{textAlign:`center`,children:[(0,I.jsx)(Bf,{size:48,color:`var(--chakra-colors-newGray-400)`,style:{margin:`0 auto`}}),(0,I.jsx)(k,{color:`newGray.400`,mt:2,children:r}),(0,I.jsx)(k,{fontSize:`xs`,color:`newGray.400`,mt:1,children:i})]}),e.canAddMember&&(0,I.jsxs)(N,{color:`gray`,variant:`ghost`,size:`sm`,onClick:o,focusRing:`none`,children:[(0,I.jsx)(Pf,{}),`Add`]})]})}),s]}):(0,I.jsxs)(Vq,{sidebar:t,children:[(0,I.jsxs)(A,{mb:`4rem`,children:[(0,I.jsxs)(j,{justify:`space-between`,align:`center`,marginBottom:`0.5rem`,children:[(0,I.jsxs)(k,{fontSize:`20px`,fontWeight:`600`,color:`newGray.500`,children:[n,` (`,e.totalCount,`)`]}),e.canAddMember&&(0,I.jsxs)(N,{color:`gray`,variant:`ghost`,size:`sm`,onClick:o,children:[(0,I.jsx)(Pf,{}),`Add`]})]}),(0,I.jsx)(k,{fontSize:`xs`,color:`newGray.400`,marginBottom:`1.5rem`,children:a}),(0,I.jsx)(M,{align:`stretch`,gap:3,children:c}),e.hasNextPage&&(0,I.jsx)(j,{justify:`center`,mt:4,children:(0,I.jsx)(N,{variant:`plain`,onClick:()=>e.tryToFetchNextPage(),loading:e.isLoading,children:`Load more`})})]}),s]})),dJ=class e{graphQLClient;client;onUnauthorized=null;constructor(t){this.environmentService=t;let n=this.environmentService.get(`REACT_APP_GRAPHQL_SERVER_URL`);if(!n)throw Error(`Invalid REACT_APP_GRAPHQL_SERVER_URL`);this.graphQLClient=new cee(n,{credentials:`include`,responseMiddleware:t=>{if(t instanceof Pn&&e.isUnauthorized(t))return;let n=t?.response?.errors?.[0]?.message;n&&Jq.info({duration:3e3,description:n})}}),this.wrapRequestWithRefreshRetry(),this.client=Mq(this.graphQLClient)}setToken(e){this.graphQLClient.setHeaders(e?{Authorization:`Bearer ${e}`}:{})}setUnauthorizedHandler(e){this.onUnauthorized=e}wrapRequestWithRefreshRetry(){let t=this.graphQLClient.request.bind(this.graphQLClient),n=async(n,r,i)=>{try{return await t(n,r,i)}catch(a){if(!e.isUnauthorized(a)||!this.onUnauthorized||!await this.onUnauthorized())throw a;return await t(n,r,i)}};this.graphQLClient.request=n}static isUnauthorized(e){if(!(e instanceof Pn))return!1;if(e.response.status===401)return!0;let t=e.response?.errors;return!Array.isArray(t)||t.length===0?!1:t.some(e=>{if(typeof e!=`object`||!e)return!1;let t=e,n=typeof t.message==`string`?t.message:``;if(/^unauthorized$/i.test(n.trim()))return!0;let r=t.extensions?.code;return!!(typeof r==`string`&&/^UNAUTHENTICATED$/i.test(r)||t.extensions?.originalError?.statusCode===401)})}};Y.register(dJ,()=>new dJ(Y.get(Nq)),{scope:`singleton`});var Q=Y.get(dJ).client,fJ=`/api/auth/refresh`,pJ=`/api/auth/logout`,mJ=`rev_session`,hJ=class e{isLoaded=!1;user=null;token=null;refreshPromise=null;constructor(e,t,n){this.apiService=e,this.systemPermissions=t,this.permissionService=n,f(this),this.apiService.setUnauthorizedHandler(()=>this.tryRefresh())}async initialize(){if(!e.hasSessionCookie()){c(()=>{this.isLoaded=!0});return}try{await this.fetchMe()}catch{if(await this.tryRefresh())try{await this.fetchMe()}catch{}}c(()=>{this.isLoaded=!0})}async afterLogin(e){e!==void 0&&c(()=>{this.token=e}),await this.fetchMe()}setBearerToken(e){c(()=>{this.token=e}),this.apiService.setToken(e)}async logout(){try{await fetch(pJ,{method:`POST`,credentials:`include`})}catch{}this.apiService.setToken(null),c(()=>{this.user=null,this.token=null}),this.systemPermissions.clearAll()}async refresh(){return this.tryRefresh()}async fetchMe(){try{let e=await this.apiService.client.getMe();c(()=>{this.user=e.me}),this.systemPermissions.setUserRole(e.me.role??null),this.loadOrganizationPermissions(e.me)}catch(e){throw c(()=>{this.user=null}),e}}tryRefresh(){if(this.refreshPromise)return this.refreshPromise;let e=this.doRefresh();return c(()=>{this.refreshPromise=e}),e.finally(()=>{c(()=>{this.refreshPromise=null})}),e}async doRefresh(){try{return(await fetch(fJ,{method:`POST`,credentials:`include`})).ok}catch{return!1}}static hasSessionCookie(){if(typeof document>`u`)return!1;let e=document.cookie;return e?e.split(`;`).some(e=>e.trim()===`${mJ}=1`):!1}loadOrganizationPermissions(e){let t=e.organization?.userOrganization?.role?.permissions,n=e.organization?.id;if(t&&n){let e=t.map(e=>({id:e.id,action:e.action,subject:e.subject,condition:e.condition??null}));this.permissionService.addOrganizationPermissions(n,e)}}};Y.register(hJ,()=>{let e=new hJ(Y.get(dJ),Y.get(yW),Y.get(vW));return e.initialize(),e},{scope:`singleton`});var gJ=class{isLoaded=!1;error=null;data=null;constructor(e){this.apiService=e,f(this)}async initialize(){await this.init()}get availableSignUp(){return this.availableEmailSignUp||this.availableGoogleOauth||this.availableGithubOauth}get availableEmailSignUp(){return this.data?.availableEmailSignUp}get availableGoogleOauth(){return!!this.data?.google.available}get googleOauthClientId(){if(!this.data?.google.clientId)throw Error(`Invalid Google client id`);return this.data?.google.clientId}get availableGithubOauth(){return!!this.data?.github.available}get githubOauthClientId(){if(!this.data?.github.clientId)throw Error(`Invalid Github client id`);return this.data?.github.clientId}get billingEnabled(){return this.data?.billing.enabled??!1}get cacheEnabled(){return this.data?.cache?.enabled??!1}get noAuth(){return this.data?.noAuth??!1}async init(){await this.request()}async request(){try{let e=await this.apiService.client.configuration();this.setData(e.configuration)}catch(e){this.setError(e),console.error(e)}finally{this.setIsLoaded(!0)}}setData(e){this.data=e}setError(e){this.error=e}setIsLoaded(e){this.isLoaded=e}};Y.register(gJ,()=>{let e=new gJ(Y.get(dJ));return e.initialize(),e},{scope:`singleton`});var _J=class{constructor(e,t){this.authService=e,this.configurationService=t,f(this)}get isLoaded(){return this.authService.isLoaded&&this.configurationService.isLoaded}};Y.register(_J,()=>new _J(Y.get(hJ),Y.get(gJ)),{scope:`singleton`});var vJ=`sandbox`,yJ=`login`,bJ=`logout`,xJ=`signup`,SJ=`username`,CJ=`github`,wJ=`google`,TJ=`authorize`,EJ=`get-token`,DJ=`get-mcp-token`,OJ=`completed`,kJ=`confirm`,AJ=`:organizationId`,jJ=`-/settings`,MJ=`-/members`,NJ=`-/limits`,PJ=`:projectName`,FJ=`-/settings`,IJ=`-/users`,LJ=`-/api-keys`,RJ=`-/mcp`,zJ=`:branchName`,BJ=`-/changes`,VJ=`-/assets`,HJ=`-/migrations`,UJ=`-/endpoints`,WJ=`-/branches`,GJ=`-/relations`,KJ=`-/branch-map`,qJ=`:revisionIdOrTag`,JJ=`:tableId`,YJ=`:rowId`,XJ=`draft`,ZJ=`head`,QJ=`admin`,$J=`users`,eY=`:userId`,tY=`organizations`,nY=`cache`,rY=function(e){return e.Organization=`organization`,e.Project=`project`,e.Branch=`branch`,e.Revision=`revision`,e.Table=`table`,e.Row=`row`,e.Changes=`changes`,e.Assets=`assets`,e.Migrations=`migrations`,e.Endpoints=`endpoints`,e.Branches=`branches`,e.Relations=`relations`,e.BranchMap=`branchMap`,e.OrganizationOverview=`organizationOverview`,e.OrganizationSettings=`organizationSettings`,e.OrganizationMembers=`organizationMembers`,e.OrganizationLimits=`organizationLimits`,e.ProjectSettings=`projectSettings`,e.ProjectUsers=`projectUsers`,e.ProjectApiKeys=`projectApiKeys`,e.ProjectMcp=`projectMcp`,e.Admin=`admin`,e.AdminUsers=`adminUsers`,e.AdminUserDetail=`adminUserDetail`,e.AdminOrganizations=`adminOrganizations`,e.AdminCache=`adminCache`,e}({}),iY=async()=>Y.get(yW).canReadUser?!0:Cn(`/`),aY=async({request:e})=>{let t=Y.get(hJ),n=Y.get(gJ);if(!t.user){if(n.noAuth)try{let e=await Q.login({data:{emailOrUsername:`admin`,password:``}});return t.setBearerToken(e.login.accessToken),await t.afterLogin(),!0}catch(e){console.error(`noAuth bootstrap failed`,e),t.setBearerToken(null)}let r=new URL(e.url),i=$V(`${r.pathname}${r.search}`);return Cn(`${n.availableSignUp?`/${xJ}`:`/${yJ}`}${i}`)}return t.user.username?!0:Cn(`/${SJ}`)},oY=async e=>{let t=Y.get(hJ),n=Y.get(gJ);if(!t.user){if(n.noAuth){try{let e=await Q.login({data:{emailOrUsername:`admin`,password:``}});t.setBearerToken(e.login.accessToken),await t.afterLogin()}catch(e){console.error(`noAuth bootstrap failed`,e),t.setBearerToken(null)}return!0}return!0}return t.user.username?!0:Cn(`/${SJ}`)},sY=async()=>Y.get(hJ).user?Cn(`/`):!0,cY=async()=>{let e=Y.get(hJ),t=Y.get(gJ);return e.user||!t.availableSignUp?Cn(`/`):!0},lY=(...e)=>async t=>{let n=null;for(let r of e){let e=await r(t);if(e&&typeof e==`object`&&`status`in e&&e.status===302)return e;n=e}return n},uY=async()=>!0,dY=class{statsRequest=X.of(Q.adminCacheStats);resetRequest=X.of(Q.adminResetAllCache);configurationService;_resetSuccess=!1;_showConfirm=!1;constructor(e){this.configurationService=e,f(this,{},{autoBind:!0})}get cacheEnabled(){return this.configurationService.cacheEnabled}get isLoading(){return this.statsRequest.isLoading}get isResetting(){return this.resetRequest.isLoading}get resetSuccess(){return this._resetSuccess}get showConfirm(){return this._showConfirm}get totalHits(){return this.statsRequest.data?.adminCacheStats.totalHits??0}get totalMisses(){return this.statsRequest.data?.adminCacheStats.totalMisses??0}get totalWrites(){return this.statsRequest.data?.adminCacheStats.totalWrites??0}get totalDeletes(){return this.statsRequest.data?.adminCacheStats.totalDeletes??0}get totalClears(){return this.statsRequest.data?.adminCacheStats.totalClears??0}get overallHitRate(){return this.statsRequest.data?.adminCacheStats.overallHitRate??0}get byCategory(){return this.statsRequest.data?.adminCacheStats.byCategory??[]}get resetError(){return this.resetRequest.errorMessage??null}openConfirm(){this._showConfirm=!0,this._resetSuccess=!1}closeConfirm(){this._showConfirm=!1}async confirmReset(){this._showConfirm=!1,(await this.resetRequest.fetch({})).isRight&&(c(()=>{this._resetSuccess=!0}),this.statsRequest.fetch({}))}init(){this.cacheEnabled&&this.statsRequest.fetch({})}dispose(){this.statsRequest.abort(),this.resetRequest.abort()}};Y.register(dY,()=>new dY(Y.get(gJ)),{scope:`request`});var fY=({label:e,value:t,isLoading:n})=>(0,I.jsxs)(A,{padding:`24px`,borderRadius:`8px`,border:`1px solid`,borderColor:`gray.200`,backgroundColor:`white`,minWidth:`160px`,children:[(0,I.jsx)(k,{fontSize:`sm`,color:`gray.500`,marginBottom:`8px`,children:e}),n?(0,I.jsx)(Ht,{size:`sm`,color:`gray.400`}):(0,I.jsx)(k,{fontSize:`2xl`,fontWeight:`600`,color:`gray.900`,children:t})]}),pY=({keyName:e,hits:t,misses:n,writes:r,deletes:i,hitRate:a})=>(0,I.jsxs)(j,{padding:`12px 16px`,borderBottom:`1px solid`,borderColor:`gray.100`,alignItems:`center`,gap:`16px`,_last:{borderBottom:`none`},children:[(0,I.jsx)(k,{flex:`1`,fontSize:`sm`,fontWeight:`500`,fontFamily:`mono`,children:e}),(0,I.jsxs)(k,{fontSize:`sm`,color:`gray.600`,minWidth:`80px`,textAlign:`right`,children:[t,` hits`]}),(0,I.jsxs)(k,{fontSize:`sm`,color:`gray.600`,minWidth:`80px`,textAlign:`right`,children:[n,` misses`]}),(0,I.jsxs)(k,{fontSize:`sm`,color:`gray.600`,minWidth:`80px`,textAlign:`right`,children:[r,` writes`]}),(0,I.jsxs)(k,{fontSize:`sm`,color:`gray.600`,minWidth:`80px`,textAlign:`right`,children:[i,` del`]}),(0,I.jsxs)(k,{fontSize:`sm`,fontWeight:`500`,minWidth:`60px`,textAlign:`right`,children:[(a*100).toFixed(1),`%`]})]}),mY=g(()=>{let e=CB(dY);return(0,I.jsxs)(j,{flexDirection:`column`,height:`100%`,children:[(0,I.jsx)(j,{alignItems:`center`,backgroundColor:`white`,justifyContent:`space-between`,width:`100%`,position:`sticky`,zIndex:1,top:0,padding:`8px`,children:(0,I.jsx)(j,{alignItems:`center`,gap:`4px`,height:`40px`,children:(0,I.jsx)($t,{color:`gray`,fontWeight:`600`,fontSize:`16px`,children:(0,I.jsx)(Gt,{fontSize:`16px`,children:(0,I.jsx)(Dt,{children:(0,I.jsx)(Xt,{color:`gray`,children:`Cache`})})})})})}),e.cacheEnabled?(0,I.jsxs)(A,{padding:`8px`,paddingTop:`16px`,children:[(0,I.jsxs)(j,{gap:`16px`,flexWrap:`wrap`,marginBottom:`24px`,children:[(0,I.jsx)(fY,{label:`Hit Rate`,value:`${(e.overallHitRate*100).toFixed(1)}%`,isLoading:e.isLoading}),(0,I.jsx)(fY,{label:`Hits`,value:e.totalHits,isLoading:e.isLoading}),(0,I.jsx)(fY,{label:`Misses`,value:e.totalMisses,isLoading:e.isLoading}),(0,I.jsx)(fY,{label:`Writes`,value:e.totalWrites,isLoading:e.isLoading}),(0,I.jsx)(fY,{label:`Deletes`,value:e.totalDeletes,isLoading:e.isLoading}),(0,I.jsx)(fY,{label:`Clears`,value:e.totalClears,isLoading:e.isLoading})]}),e.byCategory.length>0&&(0,I.jsxs)(A,{marginBottom:`24px`,children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`600`,color:`gray.700`,marginBottom:`8px`,children:`By Cache Type`}),(0,I.jsx)(A,{border:`1px solid`,borderColor:`gray.200`,borderRadius:`8px`,backgroundColor:`white`,children:e.byCategory.map(e=>(0,I.jsx)(pY,{keyName:e.key,hits:e.hits,misses:e.misses,writes:e.writes,deletes:e.deletes,hitRate:e.hitRate},e.key))})]}),(0,I.jsxs)(A,{children:[(0,I.jsx)(N,{colorPalette:`red`,variant:`outline`,size:`sm`,onClick:e.openConfirm,loading:e.isResetting,children:`Reset All Cache`}),e.resetSuccess&&(0,I.jsx)(k,{fontSize:`sm`,color:`green.500`,marginTop:`8px`,children:`Cache has been cleared successfully`}),e.resetError&&(0,I.jsx)(k,{fontSize:`sm`,color:`red.500`,marginTop:`8px`,children:e.resetError})]})]}):(0,I.jsx)(A,{padding:`8px`,paddingTop:`16px`,children:(0,I.jsxs)(A,{padding:`24px`,borderRadius:`8px`,border:`1px solid`,borderColor:`gray.200`,backgroundColor:`white`,children:[(0,I.jsx)(k,{fontSize:`md`,fontWeight:`500`,color:`gray.500`,children:`Caching is disabled`}),(0,I.jsx)(k,{fontSize:`sm`,color:`gray.400`,marginTop:`4px`,children:`Set CACHE_ENABLED=1 to enable caching.`})]})}),(0,I.jsx)(Ue,{open:e.showConfirm,onOpenChange:({open:t})=>!t&&e.closeConfirm(),size:`md`,children:(0,I.jsxs)(R,{children:[(0,I.jsx)(pe,{}),(0,I.jsx)(ue,{children:(0,I.jsxs)(_n,{children:[(0,I.jsx)(Ge,{children:(0,I.jsx)(qe,{children:`Reset All Cache`})}),(0,I.jsx)(be,{children:(0,I.jsxs)(M,{align:`stretch`,gap:`1rem`,children:[(0,I.jsx)(k,{children:`Are you sure you want to clear the entire cache?`}),(0,I.jsx)(k,{fontSize:`sm`,color:`gray.600`,children:`This will flush all cached data including rows, revisions, auth, and billing caches. The cache will be rebuilt automatically as data is accessed.`})]})}),(0,I.jsxs)(w,{children:[(0,I.jsx)(oe,{asChild:!0,children:(0,I.jsx)(N,{variant:`outline`,children:`Cancel`})}),(0,I.jsx)(N,{colorPalette:`red`,onClick:e.confirmReset,children:`Reset Cache`})]}),(0,I.jsx)(Ie,{})]})})]})})]})}),hY=class{usersRequest=X.of(Q.AdminDashboardStats);constructor(){f(this,{},{autoBind:!0})}get isLoadingUsers(){return this.usersRequest.isLoading}get isLoadingProjects(){return!1}get usersCount(){return this.usersRequest.data?.searchUsers.totalCount??null}get projectsCount(){return null}init(){this.usersRequest.fetch({first:1})}dispose(){this.usersRequest.abort()}};Y.register(hY,()=>new hY,{scope:`request`});var gY=({label:e,value:t,isLoading:n})=>(0,I.jsxs)(A,{padding:`24px`,borderRadius:`8px`,border:`1px solid`,borderColor:`gray.200`,backgroundColor:`white`,minWidth:`200px`,children:[(0,I.jsx)(k,{fontSize:`sm`,color:`gray.500`,marginBottom:`8px`,children:e}),n?(0,I.jsx)(Ht,{size:`sm`,color:`gray.400`}):(0,I.jsx)(k,{fontSize:`2xl`,fontWeight:`600`,color:`gray.900`,children:t??`-`})]}),_Y=g(()=>{let e=CB(hY);return(0,I.jsxs)(j,{flexDirection:`column`,height:`100%`,children:[(0,I.jsx)(j,{alignItems:`center`,backgroundColor:`white`,justifyContent:`space-between`,width:`100%`,position:`sticky`,zIndex:1,top:0,padding:`8px`,children:(0,I.jsx)(j,{alignItems:`center`,gap:`4px`,height:`40px`,children:(0,I.jsx)($t,{color:`gray`,fontWeight:`600`,fontSize:`16px`,children:(0,I.jsx)(Gt,{fontSize:`16px`,children:(0,I.jsx)(Dt,{children:(0,I.jsx)(Xt,{color:`gray`,children:`Admin`})})})})})}),(0,I.jsx)(A,{padding:`8px`,paddingTop:`16px`,children:(0,I.jsxs)(j,{gap:`16px`,flexWrap:`wrap`,children:[(0,I.jsx)(gY,{label:`Total Users`,value:e.usersCount,isLoading:e.isLoadingUsers}),(0,I.jsx)(gY,{label:`Total Projects`,value:e.projectsCount,isLoading:e.isLoadingProjects})]})})]})}),vY=class{constructor(e){this.data=e,f(this)}get id(){return this.data.id}get name(){return this.data.name}get prefix(){return this.data.prefix}get type(){return this.data.type}get isExpired(){return this.data.expiresAt?new Date(this.data.expiresAt)<new Date:!1}get isRevoked(){return this.data.revokedAt!==null}get isActive(){return!this.isExpired&&!this.isRevoked}get statusLabel(){return this.isRevoked?`Revoked`:this.isExpired?`Expired`:`Active`}get lastUsedAt(){return this.data.lastUsedAt??null}get createdAt(){return this.data.createdAt}get expiresAt(){return this.data.expiresAt??null}get readOnly(){return this.data.readOnly}get organizationId(){return this.data.organizationId??null}get projectIds(){return this.data.projectIds}get resolvedProjects(){return this.data.projects}get permissionLabel(){if(this.data.type===`PERSONAL`)return this.data.readOnly?`Read only`:`Full access`;let e=this.data.permissions?.rules?.[0]?.action??[];return e.includes(`delete`)?`Full access`:e.includes(`create`)||e.includes(`update`)?`Read & Write`:`Read only`}get permissionColorPalette(){switch(this.permissionLabel){case`Full access`:return`orange`;case`Read & Write`:return`blue`;default:return`gray`}}},yY={Active:{colorPalette:`green`},Expired:{colorPalette:`yellow`},Revoked:{colorPalette:`gray`}},bY=({status:e})=>{let t=yY[e];return(0,I.jsx)(It,{variant:`subtle`,colorPalette:t.colorPalette,size:`sm`,children:e})};function xY(e){if(e==null)return``;let t=new Date(e);return Number.isNaN(t.getTime())?``:HV(t,{addSuffix:!0})}var SY=({name:e,prefix:t,status:n,permissionLabel:r,permissionColor:i,projects:a,lastUsedAt:o,createdAt:s,expiresAt:c,actions:l})=>(0,I.jsx)(A,{width:`100%`,p:4,borderWidth:`1px`,borderColor:`gray.200`,borderRadius:`lg`,bg:`white`,transition:`all 0.2s`,_hover:{borderColor:`gray.300`},children:(0,I.jsxs)(j,{justify:`space-between`,align:`center`,children:[(0,I.jsxs)(j,{flexDirection:`column`,gap:1,flex:1,minWidth:0,children:[(0,I.jsxs)(P,{gap:2,children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`600`,color:`gray.700`,truncate:!0,children:e}),n!==`Active`&&(0,I.jsx)(bY,{status:n}),(0,I.jsx)(It,{variant:`outline`,colorPalette:i,size:`sm`,children:r})]}),(0,I.jsxs)(P,{gap:2,children:[(0,I.jsx)(k,{fontSize:`xs`,fontFamily:`mono`,color:`gray.400`,children:t}),a.length>0&&(0,I.jsx)(P,{gap:1,children:a.map(e=>(0,I.jsx)(It,{variant:`outline`,colorPalette:`gray`,size:`sm`,children:e.name},e.id))}),a.length===0&&(0,I.jsx)(It,{variant:`outline`,colorPalette:`gray`,size:`sm`,children:`All projects`})]}),(0,I.jsxs)(P,{gap:4,mt:1,flexWrap:`wrap`,children:[(0,I.jsxs)(k,{fontSize:`xs`,color:`gray.500`,children:[`Created `,UV(s)]}),c&&(0,I.jsxs)(k,{fontSize:`xs`,color:`gray.500`,children:[`Expires `,UV(c)]}),(0,I.jsx)(k,{fontSize:`xs`,color:`gray.500`,children:o?`Last used ${xY(o)}`:`Never used`})]})]}),l&&(0,I.jsx)(P,{gap:1,children:l})]})}),CY=[{value:`30d`,label:`30 days`},{value:`60d`,label:`60 days`},{value:`90d`,label:`90 days`},{value:`1y`,label:`1 year`},{value:`none`,label:`No expiration`}],wY=[{value:`read-only`,label:`Read only`,description:`Can only read data`},{value:`read-write`,label:`Read & Write`,description:`Can read, create, and update data`},{value:`full-access`,label:`Full access`,description:`Can read, create, update, and delete data`}],TY=g(({model:e})=>(0,I.jsx)(Ue,{open:e.isCreateDialogOpen,onOpenChange:({open:t})=>!t&&e.closeCreateDialog(),size:`md`,children:(0,I.jsxs)(R,{children:[(0,I.jsx)(pe,{}),(0,I.jsx)(ue,{children:(0,I.jsxs)(_n,{children:[(0,I.jsx)(Ge,{children:(0,I.jsx)(qe,{children:e.mode===`personal`?`Create Personal API Key`:`Create Service API Key`})}),(0,I.jsx)(be,{children:(0,I.jsxs)(M,{align:`stretch`,gap:`1rem`,children:[(0,I.jsxs)(j,{flexDirection:`column`,gap:`0.5rem`,children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`500`,color:`gray.600`,children:`Name`}),(0,I.jsx)(qt,{placeholder:`e.g., CI/CD pipeline, Data sync...`,value:e.createKeyName,onChange:t=>e.setCreateKeyName(t.target.value),autoFocus:!0})]}),(0,I.jsxs)(j,{flexDirection:`column`,gap:`0.5rem`,children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`500`,color:`gray.600`,children:`Expiration`}),(0,I.jsx)(P,{gap:2,flexWrap:`wrap`,children:CY.map(t=>(0,I.jsx)(N,{size:`sm`,variant:e.createKeyExpirationPreset===t.value?`solid`:`outline`,onClick:()=>e.setExpirationPreset(t.value),children:t.label},t.value))})]}),e.mode===`personal`&&(0,I.jsxs)(j,{flexDirection:`column`,gap:`0.5rem`,children:[(0,I.jsx)(P,{gap:2,children:(0,I.jsxs)(A,{as:`button`,onClick:()=>e.setCreateKeyReadOnly(!e.createKeyReadOnly),display:`flex`,alignItems:`center`,gap:2,cursor:`pointer`,children:[(0,I.jsx)(A,{width:`18px`,height:`18px`,borderWidth:`1px`,borderColor:e.createKeyReadOnly?`blue.500`:`gray.300`,borderRadius:`sm`,bg:e.createKeyReadOnly?`blue.500`:`transparent`,display:`flex`,alignItems:`center`,justifyContent:`center`,transition:`all 0.2s`,children:e.createKeyReadOnly&&(0,I.jsx)(k,{color:`white`,fontSize:`xs`,fontWeight:`bold`,lineHeight:1,children:`✓`})}),(0,I.jsx)(k,{fontSize:`sm`,color:`gray.700`,children:`Read only`})]})}),(0,I.jsx)(k,{fontSize:`xs`,color:`gray.500`,pl:`26px`,children:`Key can only read data, not modify it`})]}),e.mode===`service`&&(0,I.jsxs)(j,{flexDirection:`column`,gap:`0.5rem`,children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`500`,color:`gray.600`,children:`Permissions`}),(0,I.jsx)(M,{align:`stretch`,gap:2,children:wY.map(t=>(0,I.jsxs)(A,{as:`button`,onClick:()=>e.setPermissionPreset(t.value),width:`100%`,p:3,borderWidth:`1px`,borderColor:e.createKeyPermissionPreset===t.value?`blue.400`:`gray.200`,borderRadius:`md`,bg:e.createKeyPermissionPreset===t.value?`blue.50`:`white`,cursor:`pointer`,textAlign:`left`,transition:`all 0.2s`,_hover:{borderColor:`blue.300`},children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`500`,color:`gray.700`,children:t.label}),(0,I.jsx)(k,{fontSize:`xs`,color:`gray.500`,children:t.description})]},t.value))})]}),e.defaultProjectId&&(0,I.jsx)(j,{align:`center`,gap:2,p:3,bg:`blue.50`,borderRadius:`md`,borderWidth:`1px`,borderColor:`blue.200`,children:(0,I.jsxs)(k,{fontSize:`sm`,color:`blue.700`,children:[`This key will be scoped to project `,(0,I.jsx)(`strong`,{children:e.defaultProjectId})]})})]})}),(0,I.jsxs)(w,{children:[(0,I.jsx)(oe,{asChild:!0,children:(0,I.jsx)(N,{variant:`outline`,children:`Cancel`})}),(0,I.jsx)(N,{onClick:e.createKey,disabled:!e.canCreateKey,loading:e.isMutating,children:`Create key`})]}),(0,I.jsx)(Ie,{})]})})]})})),EY=g(({isOpen:e,keyName:t,isLoading:n,onConfirm:r,onClose:i})=>(0,I.jsx)(Ue,{open:e,onOpenChange:({open:e})=>!e&&i(),size:`md`,children:(0,I.jsxs)(R,{children:[(0,I.jsx)(pe,{}),(0,I.jsx)(ue,{children:(0,I.jsxs)(_n,{children:[(0,I.jsx)(Ge,{children:(0,I.jsx)(qe,{children:`Revoke API Key`})}),(0,I.jsx)(be,{children:(0,I.jsxs)(M,{align:`stretch`,gap:`1rem`,children:[(0,I.jsxs)(k,{children:[`Are you sure you want to revoke the key `,(0,I.jsx)(`strong`,{children:t}),`?`]}),(0,I.jsx)(k,{fontSize:`sm`,color:`gray.600`,children:`This action cannot be undone. Any applications using this key will immediately lose access.`})]})}),(0,I.jsxs)(w,{children:[(0,I.jsx)(oe,{asChild:!0,children:(0,I.jsx)(N,{variant:`outline`,children:`Cancel`})}),(0,I.jsx)(N,{colorPalette:`red`,onClick:r,loading:n,children:`Revoke key`})]}),(0,I.jsx)(Ie,{})]})})]})})),DY=g(({isOpen:e,keyName:t,isLoading:n,onConfirm:r,onClose:i})=>(0,I.jsx)(Ue,{open:e,onOpenChange:({open:e})=>!e&&i(),size:`md`,children:(0,I.jsxs)(R,{children:[(0,I.jsx)(pe,{}),(0,I.jsx)(ue,{children:(0,I.jsxs)(_n,{children:[(0,I.jsx)(Ge,{children:(0,I.jsx)(qe,{children:`Rotate API Key`})}),(0,I.jsx)(be,{children:(0,I.jsxs)(M,{align:`stretch`,gap:`1rem`,children:[(0,I.jsxs)(k,{children:[`Are you sure you want to rotate the key `,(0,I.jsx)(`strong`,{children:t}),`?`]}),(0,I.jsx)(k,{fontSize:`sm`,color:`gray.600`,children:`This will generate a new secret and invalidate the current one. Any applications using the current key will need to be updated.`})]})}),(0,I.jsxs)(w,{children:[(0,I.jsx)(oe,{asChild:!0,children:(0,I.jsx)(N,{variant:`outline`,children:`Cancel`})}),(0,I.jsx)(N,{colorPalette:`orange`,onClick:r,loading:n,children:`Rotate key`})]}),(0,I.jsx)(Ie,{})]})})]})})),OY=g(({isOpen:e,secret:t,keyName:n,onClose:r})=>{let i=(0,L.useCallback)(async()=>{t&&(await navigator.clipboard.writeText(t),Jq.info({description:`Copied to clipboard`}))},[t]);return(0,I.jsx)(Ue,{open:e,onOpenChange:({open:e})=>!e&&r(),size:`md`,closeOnInteractOutside:!1,children:(0,I.jsxs)(R,{children:[(0,I.jsx)(pe,{}),(0,I.jsx)(ue,{children:(0,I.jsxs)(_n,{children:[(0,I.jsx)(Ge,{children:(0,I.jsx)(qe,{children:`Your API Key`})}),(0,I.jsx)(be,{children:(0,I.jsxs)(M,{align:`stretch`,gap:`1rem`,children:[n&&(0,I.jsxs)(k,{fontSize:`sm`,color:`gray.600`,children:[`Key `,(0,I.jsx)(`strong`,{children:n}),` has been created successfully.`]}),(0,I.jsx)(A,{children:(0,I.jsxs)(j,{gap:2,children:[(0,I.jsx)(qt,{value:t??``,readOnly:!0,fontFamily:`mono`,fontSize:`sm`,bg:`gray.50`}),(0,I.jsxs)(N,{variant:`outline`,onClick:i,flexShrink:0,children:[(0,I.jsx)(qf,{}),`Copy`]})]})}),(0,I.jsxs)(j,{align:`center`,gap:2,p:3,bg:`yellow.50`,borderRadius:`md`,borderWidth:`1px`,borderColor:`yellow.200`,children:[(0,I.jsx)(one,{color:`var(--chakra-colors-yellow-600)`}),(0,I.jsx)(k,{fontSize:`sm`,color:`yellow.800`,children:`Make sure to copy your API key now. You won't be able to see it again.`})]})]})}),(0,I.jsx)(w,{children:(0,I.jsx)(N,{onClick:r,children:`I've copied the key`})})]})})]})})}),kY=g(({model:e,showCreateButton:t=!0})=>((0,L.useEffect)(()=>(e.loadKeys().catch(e.handleLoadKeysError),()=>e.reset()),[e]),e.isLoaded?e.error?(0,I.jsx)(A,{p:4,bg:`red.50`,borderRadius:`md`,borderWidth:`1px`,borderColor:`red.200`,children:(0,I.jsx)(k,{fontSize:`sm`,color:`red.600`,children:e.error})}):(0,I.jsxs)(M,{align:`stretch`,gap:3,children:[t&&!e.isEmpty&&(0,I.jsxs)(j,{justify:`space-between`,align:`center`,children:[(0,I.jsx)(k,{fontSize:`sm`,color:`gray.500`,children:`${e.sortedItems.length} key${e.sortedItems.length===1?``:`s`}`}),(0,I.jsxs)(N,{size:`sm`,onClick:e.openCreateDialog,children:[(0,I.jsx)(Pf,{}),`Create key`]})]}),e.isEmpty&&e.isLoaded&&(0,I.jsxs)(A,{p:6,textAlign:`center`,borderWidth:`1px`,borderColor:`gray.200`,borderRadius:`lg`,bg:`gray.50`,children:[(0,I.jsx)(k,{fontSize:`sm`,color:`gray.500`,children:e.emptyStateMessage}),t&&(0,I.jsxs)(N,{size:`sm`,mt:3,onClick:e.openCreateDialog,children:[(0,I.jsx)(Pf,{}),`Create your first key`]})]}),e.sortedItems.map(t=>(0,I.jsx)(SY,{name:t.name,prefix:t.prefix,status:t.statusLabel,permissionLabel:t.permissionLabel,permissionColor:t.permissionColorPalette,projects:t.resolvedProjects,lastUsedAt:t.lastUsedAt,createdAt:t.createdAt,expiresAt:t.expiresAt,actions:t.isActive?(0,I.jsxs)(P,{gap:1,children:[(0,I.jsx)(N,{size:`xs`,variant:`ghost`,color:`gray.500`,_hover:{color:`orange.600`,bg:`orange.50`},onClick:()=>e.openRotateDialog(t.id),children:(0,I.jsx)(Ate,{})}),(0,I.jsx)(N,{size:`xs`,variant:`ghost`,color:`gray.500`,_hover:{color:`red.600`,bg:`red.50`},onClick:()=>e.openRevokeDialog(t.id),children:(0,I.jsx)(Rf,{})})]}):void 0},t.id)),(0,I.jsx)(TY,{model:e}),(0,I.jsx)(OY,{isOpen:e.isSecretDialogOpen,secret:e.lastSecret,keyName:e.lastCreatedKeyName,onClose:e.closeSecretDialog}),(0,I.jsx)(EY,{isOpen:e.isRevokeDialogOpen,keyName:e.selectedKey?.name,isLoading:e.isMutating,onConfirm:e.revokeKey,onClose:e.closeRevokeDialog}),(0,I.jsx)(DY,{isOpen:e.isRotateDialogOpen,keyName:e.selectedKey?.name,isLoading:e.isMutating,onConfirm:e.rotateKey,onClose:e.closeRotateDialog})]}):(0,I.jsx)(j,{justify:`center`,py:8,children:(0,I.jsx)(Ht,{size:`md`,color:`gray.400`})}))),AY=class{myKeysRequest=X.of(Q.myApiKeys,{skipResetting:!0});serviceKeysRequest=X.of(Q.serviceApiKeys,{skipResetting:!0});createPersonalRequest=X.of(Q.createPersonalApiKey);createServiceRequest=X.of(Q.createServiceApiKey);revokeRequest=X.of(Q.revokeApiKey);rotateRequest=X.of(Q.rotateApiKey);constructor(){f(this)}get isLoading(){return this.myKeysRequest.isLoading||this.serviceKeysRequest.isLoading}get error(){return this.myKeysRequest.errorMessage??this.serviceKeysRequest.errorMessage??null}get isMutating(){return this.createPersonalRequest.isLoading||this.createServiceRequest.isLoading||this.revokeRequest.isLoading||this.rotateRequest.isLoading}fetchPersonalKeys(){return this.myKeysRequest.fetch()}fetchServiceKeys(e){return this.serviceKeysRequest.fetch({organizationId:e})}async createPersonalKey(e){let t=await this.createPersonalRequest.fetch({data:e});return t.isRight?t.data.createPersonalApiKey:null}async createServiceKey(e){let t=await this.createServiceRequest.fetch({data:e});return t.isRight?t.data.createServiceApiKey:null}async revokeKey(e){let t=await this.revokeRequest.fetch({id:e});return t.isRight?t.data.revokeApiKey:null}async rotateKey(e){let t=await this.rotateRequest.fetch({id:e});return t.isRight?t.data.rotateApiKey:null}dispose(){this.myKeysRequest.abort(),this.serviceKeysRequest.abort(),this.createPersonalRequest.abort(),this.createServiceRequest.abort(),this.revokeRequest.abort(),this.rotateRequest.abort()}};Y.register(AY,()=>new AY,{scope:`request`});var jY={"read-only":[{action:[`read`],subject:[`all`]}],"read-write":[{action:[`read`,`create`,`update`],subject:[`all`]}],"full-access":[{action:[`read`,`create`,`update`,`delete`],subject:[`all`]}]},MY=class{_config={mode:`personal`};_items=[];_isLoaded=!1;_loadError=null;_isCreateDialogOpen=!1;_isSecretDialogOpen=!1;_isRevokeDialogOpen=!1;_isRotateDialogOpen=!1;_selectedKeyId=null;_lastSecret=null;_lastCreatedKeyName=null;createKeyName=``;createKeyReadOnly=!1;createKeyExpiresAt=null;createKeyExpirationPreset=`none`;createKeyPermissionPreset=`read-only`;constructor(e){this.dataSource=e,f(this,{},{autoBind:!0})}get mode(){return this._config.mode}get organizationId(){return this._config.organizationId}get defaultProjectId(){return this._config.defaultProjectId}get filterByProjectId(){return this._config.filterByProjectId}get items(){return this._items}get filteredItems(){if(!this._config.filterByProjectId)return this._items;let e=this._config.filterByProjectId;return this._items.filter(t=>t.projectIds.includes(e))}get sortedItems(){return[...this.filteredItems].sort((e,t)=>{let n={Active:0,Expired:1,Revoked:2},r=n[e.statusLabel]-n[t.statusLabel];return r===0?new Date(t.createdAt).getTime()-new Date(e.createdAt).getTime():r})}get isLoading(){return this.dataSource.isLoading}get isLoaded(){return this._isLoaded}get isMutating(){return this.dataSource.isMutating}get error(){return this._loadError??this.dataSource.error}get isEmpty(){return this.filteredItems.length===0}get isCreateDialogOpen(){return this._isCreateDialogOpen}get isSecretDialogOpen(){return this._isSecretDialogOpen}get isRevokeDialogOpen(){return this._isRevokeDialogOpen}get isRotateDialogOpen(){return this._isRotateDialogOpen}get selectedKeyId(){return this._selectedKeyId}get lastSecret(){return this._lastSecret}get lastCreatedKeyName(){return this._lastCreatedKeyName}get selectedKey(){return this._items.find(e=>e.id===this._selectedKeyId)}get canCreateKey(){return this.createKeyName.trim().length>0&&!this.isMutating}get emptyStateMessage(){return this._config.mode===`personal`?`No API keys yet. Create one for programmatic access to your data.`:`No integration keys for this organization.`}configure(e){this._config=e}init(){}dispose(){this.dataSource.dispose()}reset(){this._items=[],this._isLoaded=!1,this._loadError=null}async loadKeys(){if(c(()=>{this._loadError=null}),this._config.mode===`personal`){let e=await this.dataSource.fetchPersonalKeys();if(!e.isRight){if(qV(e))return;c(()=>{this._isLoaded=!0});return}c(()=>{this._items=e.data.myApiKeys.filter(e=>e.type!==`INTERNAL`).map(e=>new vY(e)),this._isLoaded=!0})}else if(this._config.organizationId){let e=await this.dataSource.fetchServiceKeys(this._config.organizationId);if(!e.isRight){if(qV(e))return;c(()=>{this._isLoaded=!0});return}c(()=>{this._items=e.data.serviceApiKeys.filter(e=>e.type!==`INTERNAL`).map(e=>new vY(e)),this._isLoaded=!0})}}handleLoadKeysError(e){console.error(e),c(()=>{this._loadError=e instanceof Error?e.message:`Failed to load API keys`,this._isLoaded=!0})}openCreateDialog(){this._isCreateDialogOpen=!0,this.createKeyName=``,this.createKeyReadOnly=!1,this.createKeyExpiresAt=null,this.createKeyExpirationPreset=`none`,this.createKeyPermissionPreset=`read-only`}closeCreateDialog(){this._isCreateDialogOpen=!1}setCreateKeyName(e){this.createKeyName=e}setCreateKeyReadOnly(e){this.createKeyReadOnly=e}setExpirationPreset(e){this.createKeyExpirationPreset=e;let t=new Date;switch(e){case`30d`:t.setDate(t.getDate()+30),this.createKeyExpiresAt=t.toISOString();break;case`60d`:t.setDate(t.getDate()+60),this.createKeyExpiresAt=t.toISOString();break;case`90d`:t.setDate(t.getDate()+90),this.createKeyExpiresAt=t.toISOString();break;case`1y`:t.setFullYear(t.getFullYear()+1),this.createKeyExpiresAt=t.toISOString();break;case`none`:this.createKeyExpiresAt=null;break}}setPermissionPreset(e){this.createKeyPermissionPreset=e}async createKey(){if(this.canCreateKey){if(this._config.mode===`personal`){let e={name:this.createKeyName.trim(),readOnly:this.createKeyReadOnly,expiresAt:this.createKeyExpiresAt??void 0,projectIds:this._config.defaultProjectId?[this._config.defaultProjectId]:void 0},t=await this.dataSource.createPersonalKey(e);t&&(c(()=>{this._lastSecret=t.secret,this._lastCreatedKeyName=t.apiKey.name,this._isCreateDialogOpen=!1,this._isSecretDialogOpen=!0}),await this.loadKeys())}else if(this._config.organizationId){let e={name:this.createKeyName.trim(),organizationId:this._config.organizationId,readOnly:this.createKeyReadOnly,expiresAt:this.createKeyExpiresAt??void 0,projectIds:this._config.defaultProjectId?[this._config.defaultProjectId]:void 0,permissions:{rules:jY[this.createKeyPermissionPreset]}},t=await this.dataSource.createServiceKey(e);t&&(c(()=>{this._lastSecret=t.secret,this._lastCreatedKeyName=t.apiKey.name,this._isCreateDialogOpen=!1,this._isSecretDialogOpen=!0}),await this.loadKeys())}}}closeSecretDialog(){this._isSecretDialogOpen=!1,this._lastSecret=null,this._lastCreatedKeyName=null}openRevokeDialog(e){this._selectedKeyId=e,this._isRevokeDialogOpen=!0}closeRevokeDialog(){this._isRevokeDialogOpen=!1,this._selectedKeyId=null}async revokeKey(){this._selectedKeyId&&await this.dataSource.revokeKey(this._selectedKeyId)&&(c(()=>{this._isRevokeDialogOpen=!1,this._selectedKeyId=null}),await this.loadKeys())}openRotateDialog(e){this._selectedKeyId=e,this._isRotateDialogOpen=!0}closeRotateDialog(){this._isRotateDialogOpen=!1,this._selectedKeyId=null}async rotateKey(){if(!this._selectedKeyId)return;let e=await this.dataSource.rotateKey(this._selectedKeyId);e&&(c(()=>{this._lastSecret=e.secret,this._lastCreatedKeyName=e.apiKey.name,this._isRotateDialogOpen=!1,this._selectedKeyId=null,this._isSecretDialogOpen=!0}),await this.loadKeys())}};Y.register(MY,()=>new MY(Y.get(AY)),{scope:`request`});var NY=g(({model:e})=>{let t=(0,L.useCallback)(async()=>{await e.savePassword()&&Jq.success({description:`Password updated successfully`})},[e]);return(0,I.jsx)(Ue,{open:e.isOpen,onOpenChange:({open:t})=>!t&&e.close(),size:`md`,children:(0,I.jsxs)(R,{children:[(0,I.jsx)(pe,{}),(0,I.jsx)(ue,{children:(0,I.jsxs)(_n,{children:[(0,I.jsx)(Ge,{children:(0,I.jsx)(qe,{children:`Account Settings`})}),(0,I.jsx)(be,{children:(0,I.jsxs)(rn,{value:e.activeTab,onValueChange:({value:t})=>e.setActiveTab(t),lazyMount:!0,unmountOnExit:!0,children:[(0,I.jsxs)(et,{marginBottom:`1rem`,children:[(0,I.jsxs)(fn,{value:`account`,children:[(0,I.jsx)(zf,{}),`Account`]}),(0,I.jsxs)(fn,{value:`password`,children:[(0,I.jsx)(Of,{}),`Password`]}),(0,I.jsxs)(fn,{value:`api-keys`,children:[(0,I.jsx)(Df,{}),`Personal Tokens`]})]}),(0,I.jsx)(bt,{value:`account`,children:(0,I.jsxs)(M,{align:`stretch`,gap:`1rem`,children:[e.username&&(0,I.jsxs)(j,{flexDirection:`column`,gap:`0.5rem`,children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`500`,color:`gray.600`,children:`Username`}),(0,I.jsx)(qt,{value:e.username,readOnly:!0})]}),e.email&&(0,I.jsxs)(j,{flexDirection:`column`,gap:`0.5rem`,children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`500`,color:`gray.600`,children:`Email`}),(0,I.jsx)(qt,{value:e.email,readOnly:!0})]}),(0,I.jsx)(A,{paddingTop:`1rem`,borderTop:`1px solid`,borderTopColor:`newGray.100`,children:(0,I.jsxs)(N,{variant:`outline`,onClick:e.logout,width:`100%`,children:[(0,I.jsx)(tne,{}),`Sign out`]})})]})}),(0,I.jsx)(bt,{value:`password`,children:(0,I.jsxs)(M,{align:`stretch`,gap:`1rem`,children:[e.hasPassword?(0,I.jsxs)(j,{flexDirection:`column`,gap:`0.5rem`,children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`500`,color:`gray.600`,children:`Current Password`}),(0,I.jsx)(qt,{type:`password`,placeholder:`Enter current password...`,value:e.oldPassword,onChange:t=>e.setOldPassword(t.target.value),autoComplete:`current-password`})]}):(0,I.jsx)(k,{fontSize:`sm`,color:`gray.500`,children:`You signed in with a social account. Set a password to enable password login.`}),(0,I.jsxs)(j,{flexDirection:`column`,gap:`0.5rem`,children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`500`,color:`gray.600`,children:e.hasPassword?`New Password`:`Password`}),(0,I.jsx)(qt,{type:`password`,placeholder:`Enter new password (min 8 characters)...`,value:e.newPassword,onChange:t=>e.setNewPassword(t.target.value),autoComplete:`new-password`})]}),(0,I.jsxs)(j,{flexDirection:`column`,gap:`0.5rem`,children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`500`,color:`gray.600`,children:`Confirm Password`}),(0,I.jsx)(qt,{type:`password`,placeholder:`Confirm new password...`,value:e.confirmPassword,onChange:t=>e.setConfirmPassword(t.target.value),autoComplete:`new-password`})]}),e.passwordError&&(0,I.jsx)(k,{fontSize:`sm`,color:`red.500`,children:e.passwordError}),e.error&&(0,I.jsx)(k,{fontSize:`sm`,color:`red.500`,children:e.error}),(0,I.jsx)(j,{justifyContent:`flex-end`,children:(0,I.jsx)(N,{onClick:t,disabled:!e.canSavePassword,loading:e.isLoading,children:e.hasPassword?`Update Password`:`Set Password`})})]})}),(0,I.jsx)(bt,{value:`api-keys`,children:(0,I.jsxs)(M,{align:`stretch`,gap:`1rem`,children:[(0,I.jsxs)(A,{children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`500`,color:`gray.700`,children:`Personal Access Keys`}),(0,I.jsx)(k,{fontSize:`xs`,color:`gray.500`,mt:1,children:`Personal keys act on your behalf and inherit your permissions. Use them for scripts, CLI tools, or any programmatic access to your data.`})]}),(0,I.jsx)(kY,{model:e.apiKeyManager})]})})]})}),(0,I.jsx)(Ie,{})]})})]})})}),PY=class{updatePasswordRequest=X.of(Q.updatePassword);constructor(){f(this)}get isLoading(){return this.updatePasswordRequest.isLoading}get error(){return this.updatePasswordRequest.errorMessage??null}async updatePassword(e){return(await this.updatePasswordRequest.fetch({data:{oldPassword:e.oldPassword,newPassword:e.newPassword}})).isRight}dispose(){this.updatePasswordRequest.abort()}};Y.register(PY,()=>new PY,{scope:`request`});var FY=class{_isOpen=!1;_activeTab=`account`;apiKeyManager;oldPassword=``;newPassword=``;confirmPassword=``;constructor(e,t,n){this.dataSource=e,this.authService=t,f(this,{},{autoBind:!0}),this.apiKeyManager=n,this.apiKeyManager.configure({mode:`personal`})}get isOpen(){return this._isOpen}get activeTab(){return this._activeTab}get isLoading(){return this.dataSource.isLoading}get error(){return this.dataSource.error}get username(){return this.authService.user?.username}get email(){return this.authService.user?.email}get hasPassword(){return this.authService.user?.hasPassword??!0}get canSavePassword(){return!(this.isLoading||this.newPassword.length<8||this.newPassword!==this.confirmPassword||this.hasPassword&&!this.oldPassword)}get passwordError(){return this.newPassword&&this.newPassword.length<8?`Password must be at least 8 characters`:this.confirmPassword&&this.newPassword!==this.confirmPassword?`Passwords do not match`:null}open(){this._isOpen=!0,this._activeTab=`account`,this.resetPasswordForm()}close(){this._isOpen=!1,this.resetPasswordForm()}setActiveTab(e){this._activeTab=e}setOldPassword(e){this.oldPassword=e}setNewPassword(e){this.newPassword=e}setConfirmPassword(e){this.confirmPassword=e}async savePassword(){if(!this.canSavePassword)return!1;let e=await this.dataSource.updatePassword({oldPassword:this.oldPassword,newPassword:this.newPassword});return e&&(this.resetPasswordForm(),await this.authService.fetchMe()),e}logout(){this.close(),globalThis.location.href=`/${bJ}`}resetPasswordForm(){this.oldPassword=``,this.newPassword=``,this.confirmPassword=``}init(){}dispose(){this.dataSource.dispose(),this.apiKeyManager.dispose()}};Y.register(FY,()=>new FY(Y.get(PY),Y.get(hJ),Y.get(MY)),{scope:`singleton`});var IY=g(()=>{let e=CB(FY);return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(j,{alignItems:`center`,backgroundColor:`transparent`,_hover:{backgroundColor:`newGray.100`},borderRadius:`8px`,height:`36px`,paddingX:`8px`,width:`100%`,color:`newGray.600`,fontWeight:`400`,fontSize:`14px`,minWidth:`0`,cursor:`pointer`,gap:`12px`,userSelect:`none`,onClick:e.open,children:[(0,I.jsx)(A,{fontSize:`20px`,color:`newGray.400`,children:(0,I.jsx)(zf,{})}),(0,I.jsx)(A,{flex:`1`,minWidth:`0`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,overflow:`hidden`,children:`Account Settings`})]}),(0,I.jsx)(NY,{model:e})]})}),LY=({onBack:e})=>(0,I.jsx)(j,{className:`group`,flexDirection:`column`,alignItems:`flex-start`,width:`100%`,minWidth:`0`,children:(0,I.jsxs)(j,{alignItems:`center`,gap:`8px`,padding:`4px`,width:`100%`,children:[(0,I.jsx)(A,{fontSize:`20px`,color:`newGray.400`,cursor:`pointer`,_hover:{color:`newGray.500`},onClick:e,display:`flex`,alignItems:`center`,flexShrink:0,children:(0,I.jsx)(pf,{})}),(0,I.jsx)(A,{color:`black`,fontWeight:`600`,fontSize:`18px`,lineHeight:`26px`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,overflow:`hidden`,children:`Admin`}),(0,I.jsx)(T,{}),(0,I.jsx)(oJ,{})]})}),RY=({to:e,label:t,isActive:n,icon:r})=>(0,I.jsx)(An,{to:e,style:{textDecoration:`none`,width:`100%`},children:(0,I.jsxs)(j,{alignItems:`center`,backgroundColor:n?`newGray.100`:`transparent`,_hover:{backgroundColor:`newGray.100`},borderRadius:`8px`,height:`36px`,paddingX:`8px`,width:`100%`,color:n?`black`:`newGray.600`,fontWeight:`400`,textDecoration:`none`,fontSize:`14px`,minWidth:`0`,cursor:`pointer`,gap:`12px`,userSelect:`none`,children:[(0,I.jsx)(A,{fontSize:`20px`,color:`newGray.400`,children:r}),(0,I.jsx)(A,{flex:`1`,minWidth:`0`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,overflow:`hidden`,children:t})]})}),zY=g(()=>{let e=kn(),t=Tn(),n=e.pathname,r=n===`/${QJ}`,i=n.startsWith(`/${QJ}/${$J}`),a=n.startsWith(`/${QJ}/${tY}`),o=n.startsWith(`/${QJ}/${nY}`);return(0,I.jsxs)(M,{alignItems:`flex-start`,gap:0,width:`100%`,flex:1,children:[(0,I.jsx)(LY,{onBack:(0,L.useCallback)(()=>{t(`/`)},[t])}),(0,I.jsx)(A,{width:`100%`,paddingY:`16px`,children:(0,I.jsx)(O,{borderColor:`newGray.100`})}),(0,I.jsxs)(j,{flexDirection:`column`,width:`100%`,gap:1,children:[(0,I.jsx)(RY,{to:`/${QJ}`,label:`Dashboard`,icon:(0,I.jsx)(Xte,{}),isActive:r}),(0,I.jsx)(RY,{to:`/${QJ}/${$J}`,label:`Users`,icon:(0,I.jsx)(Bf,{}),isActive:i}),(0,I.jsx)(RY,{to:`/${QJ}/${tY}`,label:`Organizations`,icon:(0,I.jsx)(Pte,{}),isActive:a}),(0,I.jsx)(RY,{to:`/${QJ}/${nY}`,label:`Cache`,icon:(0,I.jsx)(yf,{}),isActive:o})]}),(0,I.jsx)(T,{}),(0,I.jsx)(j,{flexDirection:`column`,width:`100%`,gap:1,children:(0,I.jsx)(IY,{})})]})}),BY=()=>(0,I.jsx)(Vq,{sidebar:(0,I.jsx)(zY,{}),children:(0,I.jsx)(En,{})}),VY=({breadcrumbs:e,headerRight:t,children:n})=>(0,I.jsxs)(j,{flexDirection:`column`,height:`100%`,children:[(0,I.jsxs)(j,{alignItems:`center`,backgroundColor:`white`,justifyContent:`space-between`,width:`100%`,position:`sticky`,zIndex:1,top:0,padding:`8px`,children:[(0,I.jsx)(j,{alignItems:`center`,gap:`4px`,height:`40px`,children:(0,I.jsx)($t,{color:`gray`,fontWeight:`600`,fontSize:`16px`,children:(0,I.jsxs)(Gt,{fontSize:`16px`,children:[(0,I.jsx)(Dt,{children:(0,I.jsx)(it,{asChild:!0,color:`gray`,children:(0,I.jsx)(An,{to:`/${QJ}`,children:`Admin`})})}),e.map((e,t)=>(0,I.jsxs)(L.Fragment,{children:[(0,I.jsx)(ut,{children:`/`}),(0,I.jsx)(Dt,{children:e.to?(0,I.jsx)(it,{asChild:!0,color:`gray`,children:(0,I.jsx)(An,{to:e.to,children:e.label})}):(0,I.jsx)(Xt,{color:`gray`,children:e.label})})]},t))]})})}),t]}),(0,I.jsx)(A,{flex:1,children:n})]}),HY=()=>(0,I.jsx)(VY,{breadcrumbs:[{label:`Organizations`}],children:(0,I.jsx)(M,{flex:1,justifyContent:`center`,gap:`8px`,color:`gray.400`,paddingY:`48px`,children:(0,I.jsx)(k,{fontSize:`md`,children:`Coming soon`})})}),UY=class{request=X.of(Q.adminGetUser);resetPasswordRequest=X.of(Q.adminResetPassword);_userId=null;_user=null;_newPassword=``;_resetPasswordSuccess=!1;constructor(){f(this,{},{autoBind:!0})}get isLoading(){return this.request.isLoading}get error(){return this.request.errorMessage??null}get user(){return this._user}get username(){return this._user?.username??null}get email(){return this._user?.email??null}get roleName(){return this._user?.role?.name??null}get newPassword(){return this._newPassword}get isResetPasswordLoading(){return this.resetPasswordRequest.isLoading}get resetPasswordError(){return this.resetPasswordRequest.errorMessage??null}get resetPasswordSuccess(){return this._resetPasswordSuccess}get canResetPassword(){return this._newPassword.length>=6}setUserId(e){this._userId=e,this.loadUser()}setNewPassword(e){this._newPassword=e,this._resetPasswordSuccess=!1}async resetPassword(){!this._userId||!this.canResetPassword||(await this.resetPasswordRequest.fetch({userId:this._userId,newPassword:this._newPassword})).isRight&&c(()=>{this._newPassword=``,this._resetPasswordSuccess=!0})}init(){this._userId&&this.loadUser()}dispose(){this.request.abort(),this.resetPasswordRequest.abort()}async loadUser(){if(!this._userId)return;let e=await this.request.fetch({userId:this._userId});e.isRight&&c(()=>{this._user=e.data.adminUser??null})}};Y.register(UY,()=>new UY,{scope:`request`});var WY=({label:e,value:t})=>(0,I.jsxs)(j,{gap:`16px`,alignItems:`baseline`,children:[(0,I.jsx)(k,{fontSize:`xs`,color:`newGray.400`,minWidth:`80px`,children:e}),(0,I.jsx)(k,{fontSize:`sm`,color:`newGray.600`,children:t||`-`})]}),GY=g(({model:e})=>(0,I.jsxs)(A,{padding:`16px`,borderWidth:`1px`,borderColor:`newGray.100`,borderRadius:`md`,marginTop:`16px`,children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`500`,color:`newGray.500`,marginBottom:`12px`,children:`Reset Password`}),(0,I.jsxs)(j,{gap:`12px`,alignItems:`flex-start`,children:[(0,I.jsx)(qt,{placeholder:`New password (min 6 characters)`,type:`password`,size:`sm`,value:e.newPassword,onChange:t=>e.setNewPassword(t.target.value),maxWidth:`300px`}),(0,I.jsx)(N,{size:`sm`,colorPalette:`gray`,onClick:e.resetPassword,disabled:!e.canResetPassword,loading:e.isResetPasswordLoading,children:`Reset`})]}),e.resetPasswordError&&(0,I.jsx)(k,{fontSize:`sm`,color:`red.500`,marginTop:`8px`,children:e.resetPasswordError}),e.resetPasswordSuccess&&(0,I.jsx)(k,{fontSize:`sm`,color:`green.500`,marginTop:`8px`,children:`Password has been reset successfully`})]})),KY=g(()=>{let{userId:e}=bn(),t=CB(UY);return(0,L.useEffect)(()=>{e&&t.setUserId(e)},[e,t]),(0,I.jsx)(VY,{breadcrumbs:(0,L.useMemo)(()=>[{label:`Users`,to:`/${QJ}/${$J}`},{label:t.username||e||``}],[t.username,e]),children:(0,I.jsxs)(A,{flex:1,padding:`8px`,children:[t.isLoading&&(0,I.jsx)(M,{flex:1,justifyContent:`center`,paddingY:`48px`,children:(0,I.jsx)(Ht,{size:`md`,color:`gray.400`})}),t.error&&(0,I.jsxs)(M,{flex:1,justifyContent:`center`,gap:`8px`,color:`gray.400`,paddingY:`48px`,children:[(0,I.jsx)(k,{fontSize:`md`,children:`Could not load user`}),(0,I.jsx)(k,{fontSize:`sm`,children:t.error})]}),!t.isLoading&&!t.error&&!t.user&&(0,I.jsx)(M,{flex:1,justifyContent:`center`,gap:`8px`,color:`gray.400`,paddingY:`48px`,children:(0,I.jsx)(k,{fontSize:`md`,children:`User not found`})}),t.user&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(A,{padding:`16px`,borderWidth:`1px`,borderColor:`newGray.100`,borderRadius:`md`,children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`500`,color:`newGray.500`,marginBottom:`12px`,children:`User Info`}),(0,I.jsxs)(M,{alignItems:`flex-start`,gap:`8px`,children:[(0,I.jsx)(WY,{label:`ID`,value:t.user.id}),(0,I.jsx)(WY,{label:`Username`,value:t.username}),(0,I.jsx)(WY,{label:`Email`,value:t.email}),(0,I.jsx)(WY,{label:`Role`,value:t.roleName})]})]}),(0,I.jsx)(GY,{model:t})]})]})})}),qY=class{request=X.of(Q.createUser);constructor(){f(this)}get isLoading(){return this.request.isLoading}get error(){return this.request.errorMessage??null}async create(e){let t=await this.request.fetch({username:e.username,password:e.password,email:e.email,roleId:e.roleId});return t.isRight&&t.data.createUser}dispose(){this.request.abort()}};Y.register(qY,()=>new qY,{scope:`request`});var JY=class{_isOpen=!1;_username=``;_password=``;_email=``;_selectedRole=XW.SystemUser;constructor(e,t,n){this.dataSource=e,this.systemPermissions=t,this.onUserCreated=n,f(this,{},{autoBind:!0})}get isOpen(){return this._isOpen}get canCreateUser(){return this.systemPermissions.canCreateUser}get username(){return this._username}get password(){return this._password}get email(){return this._email}get selectedRole(){return this._selectedRole}get isCreating(){return this.dataSource.isLoading}get canSubmit(){return this._username.trim().length>0&&this._password.length>=6&&!this.isCreating}open(){this._isOpen=!0,this.reset()}close(){this._isOpen=!1,this.reset()}setUsername(e){this._username=e}setPassword(e){this._password=e}setEmail(e){this._email=e}setSelectedRole(e){this._selectedRole=e}async createUser(){if(!this.canSubmit)return;let e=await this.dataSource.create({username:this._username.trim(),password:this._password,email:this._email.trim()||void 0,roleId:this._selectedRole});c(()=>{e&&(this.onUserCreated(),this.close())})}dispose(){this.dataSource.dispose()}reset(){this._username=``,this._password=``,this._email=``,this._selectedRole=XW.SystemUser}},YY=class extends rH{currentFilters={};constructor(){super(Q.adminUsers,{pageSize:50})}extractItems(e){return e.adminUsers.edges.map(e=>e.node)}extractPageInfo(e){return{hasNextPage:e.adminUsers.pageInfo.hasNextPage,endCursor:e.adminUsers.pageInfo.endCursor||null,totalCount:e.adminUsers.totalCount}}buildFetchArgs(e,t){return e&&(this.currentFilters=e),{first:this.config.pageSize,after:t,search:this.currentFilters.search||void 0}}};Y.register(YY,()=>new YY,{scope:`request`});var XY=class{constructor(e){this.data=e,f(this)}get id(){return this.data.id}get username(){return this.data.username??null}get email(){return this.data.email??null}get roleName(){return this.data.role?.name??null}get link(){return Dn(`/${QJ}/${$J}/:userId`,{userId:this.data.id})}},ZY=class extends nH{createUserModal;_searchQuery=``;_debounceTimer=null;constructor(e,t,n){super(e),this.createUserModal=new JY(t,n,()=>this.reload()),h(this,{_searchQuery:u,searchQuery:a,canCreateUser:a,setSearchQuery:m,reload:m,init:_,dispose:_})}getItemKey(e){return e.id}createItemViewModel(e){return new XY(e)}get canCreateUser(){return this.createUserModal.canCreateUser}get searchQuery(){return this._searchQuery}init(){this.dataSource.load()}dispose(){this._debounceTimer&&clearTimeout(this._debounceTimer),super.dispose(),this.createUserModal.dispose()}reload(){this.dataSource.load({search:this._searchQuery||void 0})}setSearchQuery(e){this._searchQuery=e,this._debounceTimer&&clearTimeout(this._debounceTimer),this._debounceTimer=setTimeout(()=>{this.dataSource.load({search:e||void 0})},300)}};Y.register(ZY,()=>new ZY(Y.get(YY),Y.get(qY),Y.get(yW)),{scope:`request`});var QY={[XW.SystemAdmin]:`System Admin`,[XW.SystemFullApiRead]:`Full API Read`,[XW.SystemUser]:`User`},$Y=g(({value:e,onChange:t,disabled:n})=>(0,I.jsx)(Qe,{size:`sm`,width:`160px`,...n&&{opacity:.5,pointerEvents:`none`},children:(0,I.jsx)(Xe,{value:e,onChange:e=>t(e.target.value),children:Object.values(XW).map(e=>(0,I.jsx)(`option`,{value:e,children:QY[e]},e))})})),eX=g(({model:e})=>(0,I.jsx)(Ue,{open:e.isOpen,onOpenChange:({open:t})=>!t&&e.close(),size:`md`,children:(0,I.jsxs)(R,{children:[(0,I.jsx)(pe,{}),(0,I.jsx)(ue,{children:(0,I.jsxs)(_n,{children:[(0,I.jsx)(Ge,{children:(0,I.jsx)(qe,{children:`Create User`})}),(0,I.jsx)(be,{children:(0,I.jsxs)(M,{align:`stretch`,gap:`1rem`,children:[(0,I.jsxs)(j,{flexDirection:`column`,gap:`0.5rem`,children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`500`,color:`gray.600`,children:`Username *`}),(0,I.jsx)(qt,{placeholder:`Enter username...`,value:e.username,onChange:t=>e.setUsername(t.target.value),autoComplete:`off`})]}),(0,I.jsxs)(j,{flexDirection:`column`,gap:`0.5rem`,children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`500`,color:`gray.600`,children:`Password *`}),(0,I.jsx)(qt,{type:`password`,placeholder:`Enter password (min 6 characters)...`,value:e.password,onChange:t=>e.setPassword(t.target.value),autoComplete:`new-password`})]}),(0,I.jsxs)(j,{flexDirection:`column`,gap:`0.5rem`,children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`500`,color:`gray.600`,children:`Email (optional)`}),(0,I.jsx)(qt,{type:`email`,placeholder:`Enter email...`,value:e.email,onChange:t=>e.setEmail(t.target.value),autoComplete:`off`})]}),(0,I.jsxs)(j,{flexDirection:`column`,gap:`0.5rem`,children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`500`,color:`gray.600`,children:`System Role`}),(0,I.jsx)($Y,{value:e.selectedRole,onChange:t=>e.setSelectedRole(t)})]})]})}),(0,I.jsxs)(w,{children:[(0,I.jsx)(N,{variant:`outline`,onClick:e.close,children:`Cancel`}),(0,I.jsx)(N,{onClick:e.createUser,disabled:!e.canSubmit,loading:e.isCreating,children:`Create`})]}),(0,I.jsx)(Ie,{})]})})]})})),tX=g(({model:e})=>(0,I.jsx)(A,{height:`2.5rem`,width:`100%`,children:(0,I.jsx)(An,{to:e.link,style:{textDecoration:`none`,width:`100%`},children:(0,I.jsxs)(j,{_hover:{backgroundColor:`gray.50`},alignItems:`center`,gap:`4px`,paddingLeft:`1rem`,height:`100%`,children:[(0,I.jsx)(j,{width:`200px`,children:(0,I.jsx)(k,{maxWidth:`190px`,textDecoration:`underline`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,overflow:`hidden`,children:e.username||e.email||`No username`})}),(0,I.jsx)(j,{alignItems:`center`,flex:1,minHeight:`40px`,children:(0,I.jsx)(k,{color:`gray.400`,fontWeight:`300`,ml:`16px`,children:e.roleName||`-`})})]})})})),nX=g(()=>{let e=CB(ZY);return(0,I.jsxs)(VY,{breadcrumbs:[{label:`Users`}],headerRight:(0,I.jsx)(j,{alignItems:`center`,gap:`8px`,children:(0,I.jsx)(qt,{placeholder:`Search...`,value:e.searchQuery,onChange:t=>e.setSearchQuery(t.target.value),variant:`flushed`,size:`sm`,width:`200px`,_placeholder:{color:`gray.400`}})}),children:[(0,I.jsxs)(A,{flex:1,paddingX:`16px`,paddingTop:`16px`,children:[e.canCreateUser&&(0,I.jsx)(j,{paddingBottom:`16px`,children:(0,I.jsxs)(N,{variant:`ghost`,size:`sm`,color:`gray`,onClick:()=>e.createUserModal.open(),children:[(0,I.jsx)(Pf,{}),`Add`]})}),e.showLoading&&(0,I.jsx)(M,{flex:1,justifyContent:`center`,children:(0,I.jsx)(Ht,{size:`md`,color:`gray.400`})}),e.showError&&(0,I.jsxs)(M,{flex:1,justifyContent:`center`,gap:`8px`,color:`gray.400`,children:[(0,I.jsx)(k,{fontSize:`md`,children:`Could not load users`}),(0,I.jsx)(k,{fontSize:`sm`,children:`Please retry later`})]}),e.showEmpty&&(0,I.jsxs)(M,{flex:1,justifyContent:`center`,gap:`8px`,color:`gray.400`,children:[(0,I.jsx)(Bf,{size:48}),(0,I.jsx)(k,{fontSize:`md`,children:`No users found`})]}),e.showList&&(0,I.jsx)(QM,{useWindowScroll:!0,totalCount:e.items.length,defaultItemHeight:40,endReached:e.hasNextPage?e.tryToFetchNextPage:void 0,itemContent:t=>{let n=e.items[t];return n?(0,I.jsx)(tX,{model:n},n.id):null}})]}),(0,I.jsx)(eX,{model:e.createUserModal})]})}),rX=i((e=>{e.removeLeadingAndTrailingHTTPWhitespace=e=>e.replace(/^[ \t\n\r]+/u,``).replace(/[ \t\n\r]+$/u,``),e.removeTrailingHTTPWhitespace=e=>e.replace(/[ \t\n\r]+$/u,``),e.isHTTPWhitespaceChar=e=>e===` `||e===` `||e===`
2166
+ `,jq=(e,t,n,r)=>e();function Mq(e,t=jq){return{getBranchForLoader(n,r){return t(t=>e.request(RG,n,{...r,...t}),`getBranchForLoader`,`query`,n)},organizationProjects(n,r){return t(t=>e.request(zG,n,{...r,...t}),`organizationProjects`,`query`,n)},getProject(n,r){return t(t=>e.request(BG,n,{...r,...t}),`getProject`,`query`,n)},getProjectForLoader(n,r){return t(t=>e.request(VG,n,{...r,...t}),`getProjectForLoader`,`query`,n)},getRevisionForLoader(n,r){return t(t=>e.request(HG,n,{...r,...t}),`getRevisionForLoader`,`query`,n)},getRowForLoader(n,r){return t(t=>e.request(UG,n,{...r,...t}),`getRowForLoader`,`query`,n)},getRowCountForeignKeysToForLoader(n,r){return t(t=>e.request(WG,n,{...r,...t}),`getRowCountForeignKeysToForLoader`,`query`,n)},ForeignKeysBy(n,r){return t(t=>e.request(GG,n,{...r,...t}),`ForeignKeysBy`,`query`,n)},ForeignKeysByRows(n,r){return t(t=>e.request(KG,n,{...r,...t}),`ForeignKeysByRows`,`query`,n)},getTableForLoader(n,r){return t(t=>e.request(qG,n,{...r,...t}),`getTableForLoader`,`query`,n)},updatePassword(n,r){return t(t=>e.request(JG,n,{...r,...t}),`updatePassword`,`mutation`,n)},myApiKeys(n,r){return t(t=>e.request(YG,n,{...r,...t}),`myApiKeys`,`query`,n)},serviceApiKeys(n,r){return t(t=>e.request(XG,n,{...r,...t}),`serviceApiKeys`,`query`,n)},apiKeyById(n,r){return t(t=>e.request(ZG,n,{...r,...t}),`apiKeyById`,`query`,n)},createPersonalApiKey(n,r){return t(t=>e.request(QG,n,{...r,...t}),`createPersonalApiKey`,`mutation`,n)},createServiceApiKey(n,r){return t(t=>e.request($G,n,{...r,...t}),`createServiceApiKey`,`mutation`,n)},revokeApiKey(n,r){return t(t=>e.request(eK,n,{...r,...t}),`revokeApiKey`,`mutation`,n)},rotateApiKey(n,r){return t(t=>e.request(tK,n,{...r,...t}),`rotateApiKey`,`mutation`,n)},createProject(n,r){return t(t=>e.request(nK,n,{...r,...t}),`createProject`,`mutation`,n)},findForeignKey(n,r){return t(t=>e.request(rK,n,{...r,...t}),`findForeignKey`,`query`,n)},adminCacheStats(n,r){return t(t=>e.request(iK,n,{...r,...t}),`adminCacheStats`,`query`,n)},adminResetAllCache(n,r){return t(t=>e.request(aK,n,{...r,...t}),`adminResetAllCache`,`mutation`,n)},AdminDashboardStats(n,r){return t(t=>e.request(oK,n,{...r,...t}),`AdminDashboardStats`,`query`,n)},adminGetUser(n,r){return t(t=>e.request(sK,n,{...r,...t}),`adminGetUser`,`query`,n)},adminResetPassword(n,r){return t(t=>e.request(cK,n,{...r,...t}),`adminResetPassword`,`mutation`,n)},adminUsers(n,r){return t(t=>e.request(lK,n,{...r,...t}),`adminUsers`,`query`,n)},adminUser(n,r){return t(t=>e.request(uK,n,{...r,...t}),`adminUser`,`query`,n)},assetsTablesData(n,r){return t(t=>e.request(dK,n,{...r,...t}),`assetsTablesData`,`query`,n)},assetsRowsData(n,r){return t(t=>e.request(fK,n,{...r,...t}),`assetsRowsData`,`query`,n)},subSchemaItemsData(n,r){return t(t=>e.request(pK,n,{...r,...t}),`subSchemaItemsData`,`query`,n)},getProjectBranches(n,r){return t(t=>e.request(mK,n,{...r,...t}),`getProjectBranches`,`query`,n)},deleteBranch(n,r){return t(t=>e.request(hK,n,{...r,...t}),`deleteBranch`,`mutation`,n)},getBranchesForSelect(n,r){return t(t=>e.request(gK,n,{...r,...t}),`getBranchesForSelect`,`query`,n)},getBranchRevisionsForCreate(n,r){return t(t=>e.request(_K,n,{...r,...t}),`getBranchRevisionsForCreate`,`query`,n)},createBranch(n,r){return t(t=>e.request(vK,n,{...r,...t}),`createBranch`,`mutation`,n)},GetRevisionChanges(n,r){return t(t=>e.request(yK,n,{...r,...t}),`GetRevisionChanges`,`query`,n)},GetTableChanges(n,r){return t(t=>e.request(bK,n,{...r,...t}),`GetTableChanges`,`query`,n)},confirmEmailCode(n,r){return t(t=>e.request(xK,n,{...r,...t}),`confirmEmailCode`,`mutation`,n)},getEndpointBranches(n,r){return t(t=>e.request(SK,n,{...r,...t}),`getEndpointBranches`,`query`,n)},getProjectEndpoints(n,r){return t(t=>e.request(CK,n,{...r,...t}),`getProjectEndpoints`,`query`,n)},getBranchRevisions(n,r){return t(t=>e.request(wK,n,{...r,...t}),`getBranchRevisions`,`query`,n)},createEndpoint(n,r){return t(t=>e.request(TK,n,{...r,...t}),`createEndpoint`,`mutation`,n)},deleteEndpoint(n,r){return t(t=>e.request(EK,n,{...r,...t}),`deleteEndpoint`,`mutation`,n)},issueAccessToken(n,r){return t(t=>e.request(DK,n,{...r,...t}),`issueAccessToken`,`query`,n)},loginGithub(n,r){return t(t=>e.request(OK,n,{...r,...t}),`loginGithub`,`mutation`,n)},loginGoogle(n,r){return t(t=>e.request(kK,n,{...r,...t}),`loginGoogle`,`mutation`,n)},login(n,r){return t(t=>e.request(AK,n,{...r,...t}),`login`,`mutation`,n)},getMigrationBranches(n,r){return t(t=>e.request(jK,n,{...r,...t}),`getMigrationBranches`,`query`,n)},getBranchMigrations(n,r){return t(t=>e.request(MK,n,{...r,...t}),`getBranchMigrations`,`query`,n)},applyMigrations(n,r){return t(t=>e.request(NK,n,{...r,...t}),`applyMigrations`,`mutation`,n)},getMigrations(n,r){return t(t=>e.request(PK,n,{...r,...t}),`getMigrations`,`query`,n)},activateEarlyAccess(n,r){return t(t=>e.request(FK,n,{...r,...t}),`activateEarlyAccess`,`mutation`,n)},createCheckout(n,r){return t(t=>e.request(IK,n,{...r,...t}),`createCheckout`,`mutation`,n)},cancelSubscription(n,r){return t(t=>e.request(LK,n,{...r,...t}),`cancelSubscription`,`mutation`,n)},getLimitsPageData(n,r){return t(t=>e.request(RK,n,{...r,...t}),`getLimitsPageData`,`query`,n)},getLimitsPagePlans(n,r){return t(t=>e.request(zK,n,{...r,...t}),`getLimitsPagePlans`,`query`,n)},getUsersOrganization(n,r){return t(t=>e.request(BK,n,{...r,...t}),`getUsersOrganization`,`query`,n)},addUserToOrganization(n,r){return t(t=>e.request(VK,n,{...r,...t}),`addUserToOrganization`,`mutation`,n)},removeUserFromOrganization(n,r){return t(t=>e.request(HK,n,{...r,...t}),`removeUserFromOrganization`,`mutation`,n)},adminValidateProjectFileBytes(n,r){return t(t=>e.request(UK,n,{...r,...t}),`adminValidateProjectFileBytes`,`query`,n)},adminRestoreProjectFileBytes(n,r){return t(t=>e.request(WK,n,{...r,...t}),`adminRestoreProjectFileBytes`,`mutation`,n)},updateProject(n,r){return t(t=>e.request(GK,n,{...r,...t}),`updateProject`,`mutation`,n)},deleteProjectForSettings(n,r){return t(t=>e.request(KK,n,{...r,...t}),`deleteProjectForSettings`,`mutation`,n)},fetchTableForStack(n,r){return t(t=>e.request(qK,n,{...r,...t}),`fetchTableForStack`,`query`,n)},createTableForStack(n,r){return t(t=>e.request(JK,n,{...r,...t}),`createTableForStack`,`mutation`,n)},updateTableForStack(n,r){return t(t=>e.request(YK,n,{...r,...t}),`updateTableForStack`,`mutation`,n)},renameTableForStack(n,r){return t(t=>e.request(XK,n,{...r,...t}),`renameTableForStack`,`mutation`,n)},rowPageData(n,r){return t(t=>e.request(ZK,n,{...r,...t}),`rowPageData`,`query`,n)},signUp(n,r){return t(t=>e.request(QK,n,{...r,...t}),`signUp`,`mutation`,n)},setUsername(n,r){return t(t=>e.request($K,n,{...r,...t}),`setUsername`,`mutation`,n)},getUsersProject(n,r){return t(t=>e.request(eq,n,{...r,...t}),`getUsersProject`,`query`,n)},searchUsers(n,r){return t(t=>e.request(tq,n,{...r,...t}),`searchUsers`,`query`,n)},addUserToProject(n,r){return t(t=>e.request(nq,n,{...r,...t}),`addUserToProject`,`mutation`,n)},removeUserFromProject(n,r){return t(t=>e.request(rq,n,{...r,...t}),`removeUserFromProject`,`mutation`,n)},updateUserProjectRole(n,r){return t(t=>e.request(iq,n,{...r,...t}),`updateUserProjectRole`,`mutation`,n)},createUser(n,r){return t(t=>e.request(aq,n,{...r,...t}),`createUser`,`mutation`,n)},configuration(n,r){return t(t=>e.request(oq,n,{...r,...t}),`configuration`,`query`,n)},getMe(n,r){return t(t=>e.request(sq,n,{...r,...t}),`getMe`,`query`,n)},getProjectGraph(n,r){return t(t=>e.request(cq,n,{...r,...t}),`getProjectGraph`,`query`,n)},findBranches(n,r){return t(t=>e.request(lq,n,{...r,...t}),`findBranches`,`query`,n)},findRevisions(n,r){return t(t=>e.request(uq,n,{...r,...t}),`findRevisions`,`query`,n)},meProjectsList(n,r){return t(t=>e.request(dq,n,{...r,...t}),`meProjectsList`,`query`,n)},GetRowChanges(n,r){return t(t=>e.request(fq,n,{...r,...t}),`GetRowChanges`,`query`,n)},GetTableChangesForFilter(n,r){return t(t=>e.request(pq,n,{...r,...t}),`GetTableChangesForFilter`,`query`,n)},foreignKeyTableWithRows(n,r){return t(t=>e.request(mq,n,{...r,...t}),`foreignKeyTableWithRows`,`query`,n)},createRowForStack(n,r){return t(t=>e.request(hq,n,{...r,...t}),`createRowForStack`,`mutation`,n)},updateRowForStack(n,r){return t(t=>e.request(gq,n,{...r,...t}),`updateRowForStack`,`mutation`,n)},renameRowForStack(n,r){return t(t=>e.request(_q,n,{...r,...t}),`renameRowForStack`,`mutation`,n)},RowListRows(n,r){return t(t=>e.request(vq,n,{...r,...t}),`RowListRows`,`query`,n)},DeleteRow(n,r){return t(t=>e.request(yq,n,{...r,...t}),`DeleteRow`,`mutation`,n)},DeleteRows(n,r){return t(t=>e.request(bq,n,{...r,...t}),`DeleteRows`,`mutation`,n)},PatchRowInline(n,r){return t(t=>e.request(xq,n,{...r,...t}),`PatchRowInline`,`mutation`,n)},GetTableViews(n,r){return t(t=>e.request(Sq,n,{...r,...t}),`GetTableViews`,`query`,n)},UpdateTableViews(n,r){return t(t=>e.request(Cq,n,{...r,...t}),`UpdateTableViews`,`mutation`,n)},searchRows(n,r){return t(t=>e.request(wq,n,{...r,...t}),`searchRows`,`query`,n)},revertChangesForSidebar(n,r){return t(t=>e.request(Tq,n,{...r,...t}),`revertChangesForSidebar`,`mutation`,n)},createRevisionForSidebar(n,r){return t(t=>e.request(Eq,n,{...r,...t}),`createRevisionForSidebar`,`mutation`,n)},createBranchForSidebar(n,r){return t(t=>e.request(Dq,n,{...r,...t}),`createBranchForSidebar`,`mutation`,n)},deleteTableForList(n,r){return t(t=>e.request(Oq,n,{...r,...t}),`deleteTableForList`,`mutation`,n)},tableListData(n,r){return t(t=>e.request(kq,n,{...r,...t}),`tableListData`,`query`,n)},tableRelationsData(n,r){return t(t=>e.request(Aq,n,{...r,...t}),`tableRelationsData`,`query`,n)}}}var Nq=class{constructor(){}get(e){let t=globalThis.__env__?.[e],n={BASE_URL:`/`,DEV:!1,GIT_BRANCH_NAME:`HEAD`,GIT_COMMIT_HASH:`59fa0fa`,MODE:`production`,PACKAGE_VERSION:`2.7.0-alpha.2`,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}[e];return t||n}};Y.register(Nq,()=>new Nq,{scope:`singleton`});var Pq=`revisium:sidebar-collapsed`,Fq=200,Iq=class{_isCollapsed=!1;_isHoverExpanded=!1;_hoverDelay=new cH(Fq);_leaveDelay=new cH(Fq);_keyboardHandler=null;constructor(e){this.storage=e,this._isCollapsed=e.getItem(Pq)===`true`,f(this,{},{autoBind:!0}),s(()=>this._isCollapsed,e=>{this.storage.setItem(Pq,String(e))})}get isCollapsed(){return this._isCollapsed}get isHoverExpanded(){return this._isHoverExpanded}get isSidebarVisible(){return!this._isCollapsed||this._isHoverExpanded}toggle(){this._isCollapsed=!this._isCollapsed,this._isHoverExpanded=!1}setHoverExpanded(e){this._isHoverExpanded=e}startHoverIntent(){this._leaveDelay.cancel(),this._hoverDelay.schedule(()=>{this.setHoverExpanded(!0)})}cancelHoverIntent(){this._hoverDelay.cancel()}startLeaveIntent(){this._leaveDelay.schedule(()=>{this.setHoverExpanded(!1)})}cancelLeaveIntent(){this._leaveDelay.cancel()}dismissOverlay(){this.setHoverExpanded(!1)}initKeyboard(){this._keyboardHandler||(this._keyboardHandler=e=>{(e.metaKey||e.ctrlKey)&&e.key===`\\`&&(e.preventDefault(),this.toggle())},globalThis.addEventListener(`keydown`,this._keyboardHandler))}disposeKeyboard(){this._keyboardHandler&&=(globalThis.removeEventListener(`keydown`,this._keyboardHandler),null),this._hoverDelay.dispose(),this._leaveDelay.dispose()}};Y.register(Iq,()=>new Iq(localStorage),{scope:`singleton`});var Lq=({sidebar:e,footer:t})=>(0,I.jsxs)(I.Fragment,{children:[e,t&&(0,I.jsx)(A,{alignSelf:`center`,mt:`1rem`,children:t})]}),Rq=288,zq=48,Bq=`0.2s`,Vq=g(({hideSidebar:e,sidebar:t,title:n,actions:r,children:i,footer:a})=>{let o=Y.get(Iq);(0,L.useEffect)(()=>(o.initKeyboard(),()=>{o.disposeKeyboard()}),[o]);let s=!e,c=s&&o.isCollapsed,l=c&&o.isHoverExpanded,u=s?c?`${zq}px`:`${Rq}px`:`0px`;return(0,I.jsxs)(j,{minHeight:`100vh`,children:[s&&(0,I.jsx)(j,{width:u,minWidth:u,flexShrink:0,height:`100vh`,top:0,position:`sticky`,transition:`width ${Bq} ease, min-width ${Bq} ease`,overflow:`hidden`,children:c?(0,I.jsx)(j,{width:`${zq}px`,minWidth:`${zq}px`,height:`100vh`,flexDirection:`column`,alignItems:`center`,paddingTop:`20px`,onMouseEnter:o.startHoverIntent,onMouseLeave:o.cancelHoverIntent,children:(0,I.jsx)(A,{as:`button`,fontSize:`20px`,color:`newGray.400`,cursor:`pointer`,_hover:{color:`newGray.600`},display:`flex`,alignItems:`center`,onClick:o.toggle,"aria-label":`Toggle sidebar`,children:(0,I.jsx)(Zte,{})})}):(0,I.jsx)(j,{width:`${Rq}px`,minWidth:`${Rq}px`,borderRight:`1px solid`,borderRightColor:`newGray.100`,flexDirection:`column`,justifyContent:t?`space-between`:`flex-end`,padding:`16px`,height:`100vh`,children:(0,I.jsx)(Lq,{sidebar:t,footer:a})})}),c&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(A,{position:`fixed`,left:0,top:0,width:`100vw`,height:`100vh`,zIndex:9,pointerEvents:l?`auto`:`none`,onClick:o.dismissOverlay}),(0,I.jsx)(j,{position:`fixed`,left:0,top:0,width:`${Rq}px`,height:`100vh`,zIndex:10,backgroundColor:`white`,borderRight:`1px solid`,borderRightColor:`newGray.100`,flexDirection:`column`,justifyContent:t?`space-between`:`flex-end`,padding:`16px`,boxShadow:l?`4px 0 12px rgba(0, 0, 0, 0.08)`:`none`,transform:l?`translateX(0)`:`translateX(-${Rq}px)`,transition:`transform ${Bq} ease, box-shadow ${Bq} ease`,onMouseLeave:o.startLeaveIntent,onMouseEnter:o.cancelLeaveIntent,pointerEvents:l?`auto`:`none`,children:(0,I.jsx)(Lq,{sidebar:t,footer:a})})]}),(0,I.jsxs)(j,{flex:1,minWidth:0,flexDirection:`column`,alignItems:`center`,children:[(n||r)&&(0,I.jsxs)(j,{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:[n,r]}),(0,I.jsx)(j,{flex:1,flexDirection:`column`,maxWidth:`900px`,padding:`1rem 1rem 0rem 1rem`,width:`100%`,children:i})]})]})}),Hq=({height:e=`2.5rem`,title:t,onClick:n,disabled:r,isSelected:i,isLoading:a,icon:o,dataTestId:s})=>(0,I.jsx)(N,{"data-testid":s,_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:e,disabled:r||i,loading:a,variant:`ghost`,onClick:n,children:(0,I.jsxs)(j,{alignItems:`center`,gap:`0.5rem`,children:[o&&(0,I.jsx)(A,{fontSize:`sm`,children:o}),(0,I.jsx)(k,{children:t})]})}),Uq=e=>(0,I.jsx)(Hq,{...e,icon:(0,I.jsx)(af,{})}),Wq=({height:e=`2.5rem`,loading:t,isDisabled:n,onClick:r,title:i,dataTestId:a})=>(0,I.jsxs)(N,{"data-testid":a,_hover:{backgroundColor:`gray.50`},alignSelf:`flex-start`,color:`gray.400`,height:e,loading:t,disabled:n,variant:`ghost`,onClick:r,width:`48px`,children:[(0,I.jsx)(Ve,{size:`sm`,mr:i?8:0,children:(0,I.jsx)(ef,{})}),i]}),Gq=({height:e=`2.5rem`,onClick:t,disabled:n,dataTestId:r})=>(0,I.jsx)(N,{"data-testid":r,disabled:n,_hover:{backgroundColor:`gray.50`},alignSelf:`flex-start`,color:`gray.400`,height:e,variant:`ghost`,onClick:t,width:`48px`,children:(0,I.jsx)(Ve,{size:`md`,children:(0,I.jsx)(ip,{})})}),Kq=({dataTestId:e,...t})=>(0,I.jsx)(Ze,{"data-testid":e,_hover:{backgroundColor:`gray.100`},color:`gray.400`,variant:`ghost`,size:`lg`,width:`40px`,height:`40px`,...t,children:(0,I.jsx)(nf,{})}),qq=({value:e,placeholder:t,autoFocus:n,onChange:r,onBlur:i,onEnter:a,width:o,height:s,type:c,dataTestId:l,autoComplete:u})=>{let d=SB();return(0,I.jsx)(qt,{autoComplete:u,"data-testid":l,borderColor:`gray.100`,padding:`0 9px`,placeholder:t,ref:n?d:void 0,value:e,variant:`outline`,onChange:r,onBlur:i,width:o,height:s,type:c,onKeyDown:a?e=>{e.key===`Enter`&&a()}:void 0})},Jq=Rd({placement:`top`,pauseOnPageIdle:!0,duration:1500}),Yq=Rd({placement:`bottom`,pauseOnPageIdle:!0,duration:1500}),Xq=e=>(0,I.jsxs)(_t,{width:{md:`sm`},children:[e.type===`loading`?(0,I.jsx)(Ht,{size:`sm`,color:`blue.solid`}):(0,I.jsx)(ft,{}),(0,I.jsxs)(_e,{gap:`1`,flex:`1`,maxWidth:`100%`,children:[e.title&&(0,I.jsx)(eee,{children:e.title}),e.description&&(0,I.jsx)(ree,{color:`gray.500`,children:e.description})]}),e.action&&(0,I.jsx)(lt,{children:e.action.label}),e.closable&&(0,I.jsx)(Ft,{})]}),Zq=()=>(0,I.jsxs)(R,{children:[(0,I.jsx)(Rt,{toaster:Jq,insetInline:{mdDown:`4`},children:e=>(0,I.jsx)(Xq,{...e})}),(0,I.jsx)(Rt,{toaster:Yq,insetInline:{mdDown:`4`},children:e=>(0,I.jsx)(Xq,{...e})})]}),Qq=L.forwardRef(function(e,t){let{showArrow:n,children:r,disabled:i,portalled:a=!0,content:o,contentProps:s,portalRef:c,...l}=e;return i?r:(0,I.jsxs)(Wt,{...l,children:[(0,I.jsx)(Qt,{asChild:!0,children:r}),(0,I.jsx)(R,{disabled:!a,container:c,children:(0,I.jsx)(rt,{children:(0,I.jsxs)(Et,{ref:t,...s,children:[n&&(0,I.jsx)(Vt,{children:(0,I.jsx)(Yt,{})}),o]})})})]})}),$q={deprecated:{type:`boolean`},title:{type:`string`},description:{type:`string`}};({...$q});var eJ={type:{const:`string`},default:{type:`string`},readOnly:{type:`boolean`},pattern:{type:`string`,format:`regex`},enum:{type:`array`,items:{type:`string`},minItems:1,uniqueItems:!0},format:{type:`string`,enum:[`date-time`,`date`,`time`,`email`,`regex`]},contentMediaType:{type:`string`,enum:[`text/plain`,`text/markdown`,`text/html`,`application/json`,`application/schema+json`,`application/yaml`]},...$q};({...eJ}),{...eJ},{...$q},{...$q},{...$q},{...$q};var tJ=new(e(vd(),1)).default;tJ.addKeyword({keyword:`foreignKey`,type:`string`}),tJ.addFormat(`regex`,{type:`string`,validate:e=>{try{return new RegExp(e),!0}catch{return!1}}});var nJ=(e,t)=>({result:tJ.validate(e,t),errors:tJ.errors}),rJ=({dataTestId:e,...t})=>(0,I.jsx)(Ze,{"data-testid":e,_hover:{backgroundColor:`gray.100`},color:`gray.400`,variant:`ghost`,...t,children:(0,I.jsx)(qf,{})}),iJ={JsonCard:`_JsonCard_15gzu_1`,CopyButton:`_CopyButton_15gzu_1`},aJ=({data:e,readonly:t,onChange:n,schema:r,onBlur:i})=>{let[a,o]=(0,L.useState)(``),s=JSON.stringify(e,null,3),[c,l]=(0,L.useState)(s),u=(0,L.useRef)(!1),d=u.current?c:s,f=(0,L.useCallback)(async()=>{await navigator.clipboard.writeText(d),Jq.info({duration:1500,description:`Copied to clipboard`})},[d]),p=(0,L.useCallback)(e=>{l(e);try{let t=JSON.parse(e);if(r){let e=nJ(r,t);if(!e.result){o(`"${e.errors?.[0]?.instancePath||`/`}": ${e.errors?.[0]?.message}`);return}}o(``),n?.(t)}catch(e){console.error(e),o(`Invalid JSON`)}},[n,r]),m=(0,L.useCallback)(()=>{u.current=!0,l(s)},[s]),h=(0,L.useCallback)(()=>{u.current=!1,l(s),i?.()},[i,s]);return(0,I.jsxs)(j,{position:`relative`,width:`100%`,flex:1,className:iJ.JsonCard,direction:`column`,gap:`1rem`,children:[(0,I.jsxs)(A,{p:1,flex:1,children:[(0,I.jsx)(DO,{value:d,extensions:[G.lineWrapping,nk()],editable:!t,theme:pC,maxWidth:`100%`,basicSetup:{lineNumbers:!0,foldGutter:!0},onChange:p,onFocus:m,onBlur:h}),(0,I.jsx)(rJ,{dataTestId:`json-card-copy-button`,"aria-label":``,position:`absolute`,top:`8px`,right:`8px`,className:iJ.CopyButton,onClick:f})]}),(0,I.jsx)(j,{height:`40px`,paddingBottom:`8px`,alignItems:`flex-end`,backgroundColor:`white`,width:`100%`,position:`sticky`,bottom:0,justifyContent:`center`,children:(0,I.jsx)(k,{color:`gray`,children:a})})]})},oJ=g(()=>{let e=Y.get(Iq),t=e.isCollapsed&&e.isHoverExpanded,n=t?`Expand sidebar`:`Collapse sidebar`,r=t?Ite:Fte;return(0,I.jsx)(Qq,{content:n,children:(0,I.jsx)(A,{as:`button`,fontSize:`20px`,color:`newGray.400`,cursor:`pointer`,_hover:{color:`newGray.600`},display:`flex`,alignItems:`center`,flexShrink:0,onClick:e.toggle,opacity:+!!t,_groupHover:{opacity:1},transition:`opacity 0.15s ease`,"aria-label":n,children:(0,I.jsx)(r,{})})})}),sJ=({to:e,label:t,isActive:n,icon:r,onClick:i,badge:a})=>{let o=(0,I.jsxs)(j,{alignItems:`center`,backgroundColor:n?`newGray.100`:`transparent`,_hover:{backgroundColor:`newGray.100`},borderRadius:`8px`,height:`36px`,paddingX:`8px`,width:`100%`,color:n?`black`:`newGray.600`,fontWeight:`400`,textDecoration:`none`,fontSize:`14px`,minWidth:`0`,cursor:`pointer`,gap:`12px`,userSelect:`none`,onClick:i,children:[r&&(0,I.jsx)(A,{fontSize:`20px`,color:`newGray.400`,children:r}),(0,I.jsx)(A,{flex:`1`,minWidth:`0`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,overflow:`hidden`,children:t}),a!=null&&a>0&&(0,I.jsx)(A,{fontSize:`11px`,fontWeight:`600`,color:`newGray.400`,backgroundColor:`newGray.100`,borderRadius:`4px`,paddingX:`6px`,paddingY:`2px`,minWidth:`20px`,textAlign:`center`,children:a>99?`99+`:a})]});return e&&!i?(0,I.jsx)(An,{to:e,style:{textDecoration:`none`,width:`100%`},children:o}):o},cJ=g(({model:e,roleSlot:t,disableRemove:n})=>(0,I.jsx)(A,{borderWidth:`1px`,borderColor:`newGray.200`,borderRadius:`md`,padding:`1rem`,backgroundColor:`white`,_hover:{borderColor:`newGray.300`},transition:`border-color 0.2s`,children:(0,I.jsxs)(j,{justify:`space-between`,align:`center`,children:[(0,I.jsxs)(P,{gap:3,children:[(0,I.jsx)(A,{color:`newGray.400`,children:(0,I.jsx)(zf,{size:20})}),(0,I.jsxs)(A,{children:[(0,I.jsx)(k,{fontWeight:`500`,color:`newGray.600`,children:e.displayName}),e.username&&e.email&&(0,I.jsx)(k,{fontSize:`xs`,color:`newGray.400`,children:e.email})]})]}),(0,I.jsxs)(P,{gap:3,children:[t,e.canRemove&&(0,I.jsx)(N,{variant:`ghost`,size:`sm`,color:`red.500`,onClick:()=>e.remove(),loading:e.isRemoving,disabled:n,children:(0,I.jsx)(Rf,{})})]})]})})),lJ=g(({model:e,title:t,roleSelect:n})=>(0,I.jsx)(Ue,{open:e.isOpen,onOpenChange:({open:t})=>!t&&e.close(),size:`lg`,children:(0,I.jsxs)(R,{children:[(0,I.jsx)(pe,{}),(0,I.jsx)(ue,{children:(0,I.jsxs)(_n,{children:[(0,I.jsx)(Ge,{children:(0,I.jsx)(qe,{children:t})}),(0,I.jsx)(be,{children:(0,I.jsxs)(rn,{value:e.activeTab,onValueChange:({value:t})=>e.setActiveTab(t),children:[(0,I.jsxs)(et,{marginBottom:`1rem`,children:[(0,I.jsx)(fn,{value:`search`,children:`Search User`}),e.canCreateUser&&(0,I.jsx)(fn,{value:`create`,children:`Create New`})]}),(0,I.jsx)(bt,{value:`search`,children:(0,I.jsxs)(M,{align:`stretch`,gap:`1rem`,children:[(0,I.jsxs)(j,{flexDirection:`column`,gap:`0.5rem`,children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`500`,color:`gray.600`,children:`Search by username or email`}),(0,I.jsx)(qt,{placeholder:`Enter username or email...`,value:e.searchQuery,onChange:t=>e.setSearchQuery(t.target.value),autoComplete:`off`})]}),e.isSearching?(0,I.jsx)(j,{justify:`center`,padding:`2rem`,children:(0,I.jsx)(Ht,{})}):e.searchResults.length>0?(0,I.jsx)(M,{align:`stretch`,gap:`0.5rem`,maxHeight:`200px`,overflowY:`auto`,children:e.searchResults.map(t=>(0,I.jsx)(A,{padding:`0.75rem`,borderWidth:`1px`,borderColor:e.selectedUserId===t.id?`blue.500`:`newGray.200`,borderRadius:`md`,backgroundColor:e.selectedUserId===t.id?`blue.50`:`white`,cursor:`pointer`,onClick:()=>e.setSelectedUserId(t.id),_hover:{borderColor:`blue.300`},transition:`all 0.2s`,children:(0,I.jsxs)(j,{align:`center`,justify:`space-between`,children:[(0,I.jsxs)(j,{align:`center`,gap:2,children:[(0,I.jsx)(zf,{size:16}),(0,I.jsxs)(A,{children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`500`,children:t.username||t.email||t.id}),t.username&&t.email&&(0,I.jsx)(k,{fontSize:`xs`,color:`gray.500`,children:t.email})]})]}),e.selectedUserId===t.id&&(0,I.jsx)(Lte,{size:16,color:`var(--chakra-colors-blue-500)`})]})},t.id))}):e.searchQuery.length>0?(0,I.jsx)(k,{fontSize:`sm`,color:`gray.500`,textAlign:`center`,padding:`2rem`,children:`No users found`}):null,(0,I.jsxs)(j,{flexDirection:`column`,gap:`0.5rem`,children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`500`,color:`gray.600`,children:`Role`}),n]})]})}),e.canCreateUser&&(0,I.jsx)(bt,{value:`create`,children:(0,I.jsxs)(M,{align:`stretch`,gap:`1rem`,children:[(0,I.jsxs)(j,{flexDirection:`column`,gap:`0.5rem`,children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`500`,color:`gray.600`,children:`Username *`}),(0,I.jsx)(qt,{placeholder:`Enter username...`,value:e.newUsername,onChange:t=>e.setNewUsername(t.target.value),autoComplete:`off`})]}),(0,I.jsxs)(j,{flexDirection:`column`,gap:`0.5rem`,children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`500`,color:`gray.600`,children:`Password *`}),(0,I.jsx)(qt,{type:`password`,placeholder:`Enter password (min 6 characters)...`,value:e.newPassword,onChange:t=>e.setNewPassword(t.target.value),autoComplete:`new-password`})]}),(0,I.jsxs)(j,{flexDirection:`column`,gap:`0.5rem`,children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`500`,color:`gray.600`,children:`Email (optional)`}),(0,I.jsx)(qt,{type:`email`,placeholder:`Enter email...`,value:e.newEmail,onChange:t=>e.setNewEmail(t.target.value),autoComplete:`off`})]}),(0,I.jsxs)(j,{flexDirection:`column`,gap:`0.5rem`,children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`500`,color:`gray.600`,children:`Role`}),n]})]})})]})}),(0,I.jsxs)(w,{children:[(0,I.jsx)(N,{variant:`outline`,onClick:e.close,children:`Cancel`}),e.activeTab===`search`?(0,I.jsx)(N,{onClick:e.addSelectedUser,disabled:!e.canAddSelectedUser,loading:e.isAdding,children:`Add User`}):(0,I.jsx)(N,{onClick:e.createAndAddUser,disabled:!e.canCreateNewUser,loading:e.isCreating,children:`Create & Add`})]}),(0,I.jsx)(Ie,{})]})})]})})),uJ=g(({model:e,sidebar:t,label:n,emptyTitle:r,emptySubtitle:i,subtitle:a,onAddClick:o,modal:s,children:c})=>e.showInitialLoading?(0,I.jsx)(Vq,{sidebar:t,children:(0,I.jsx)(j,{justify:`center`,align:`center`,height:`200px`,children:(0,I.jsx)(Ht,{})})}):e.showError?(0,I.jsx)(Vq,{sidebar:t,children:(0,I.jsx)(j,{justify:`center`,align:`center`,height:`200px`,children:(0,I.jsxs)(k,{color:`red.500`,children:[`Error loading `,n.toLowerCase()]})})}):e.showNoMembers?(0,I.jsxs)(Vq,{sidebar:t,children:[(0,I.jsx)(A,{mb:`4rem`,children:(0,I.jsxs)(j,{justify:`center`,align:`center`,height:`200px`,flexDirection:`column`,gap:4,children:[(0,I.jsxs)(A,{textAlign:`center`,children:[(0,I.jsx)(Bf,{size:48,color:`var(--chakra-colors-newGray-400)`,style:{margin:`0 auto`}}),(0,I.jsx)(k,{color:`newGray.400`,mt:2,children:r}),(0,I.jsx)(k,{fontSize:`xs`,color:`newGray.400`,mt:1,children:i})]}),e.canAddMember&&(0,I.jsxs)(N,{color:`gray`,variant:`ghost`,size:`sm`,onClick:o,focusRing:`none`,children:[(0,I.jsx)(Pf,{}),`Add`]})]})}),s]}):(0,I.jsxs)(Vq,{sidebar:t,children:[(0,I.jsxs)(A,{mb:`4rem`,children:[(0,I.jsxs)(j,{justify:`space-between`,align:`center`,marginBottom:`0.5rem`,children:[(0,I.jsxs)(k,{fontSize:`20px`,fontWeight:`600`,color:`newGray.500`,children:[n,` (`,e.totalCount,`)`]}),e.canAddMember&&(0,I.jsxs)(N,{color:`gray`,variant:`ghost`,size:`sm`,onClick:o,children:[(0,I.jsx)(Pf,{}),`Add`]})]}),(0,I.jsx)(k,{fontSize:`xs`,color:`newGray.400`,marginBottom:`1.5rem`,children:a}),(0,I.jsx)(M,{align:`stretch`,gap:3,children:c}),e.hasNextPage&&(0,I.jsx)(j,{justify:`center`,mt:4,children:(0,I.jsx)(N,{variant:`plain`,onClick:()=>e.tryToFetchNextPage(),loading:e.isLoading,children:`Load more`})})]}),s]})),dJ=class e{graphQLClient;client;onUnauthorized=null;constructor(t){this.environmentService=t;let n=this.environmentService.get(`REACT_APP_GRAPHQL_SERVER_URL`);if(!n)throw Error(`Invalid REACT_APP_GRAPHQL_SERVER_URL`);this.graphQLClient=new cee(n,{credentials:`include`,responseMiddleware:t=>{if(t instanceof Pn&&e.isUnauthorized(t))return;let n=t?.response?.errors?.[0]?.message;n&&Jq.info({duration:3e3,description:n})}}),this.wrapRequestWithRefreshRetry(),this.client=Mq(this.graphQLClient)}setToken(e){this.graphQLClient.setHeaders(e?{Authorization:`Bearer ${e}`}:{})}setUnauthorizedHandler(e){this.onUnauthorized=e}wrapRequestWithRefreshRetry(){let t=this.graphQLClient.request.bind(this.graphQLClient),n=async(n,r,i)=>{try{return await t(n,r,i)}catch(a){if(!e.isUnauthorized(a)||!this.onUnauthorized||!await this.onUnauthorized())throw a;return await t(n,r,i)}};this.graphQLClient.request=n}static isUnauthorized(e){if(!(e instanceof Pn))return!1;if(e.response.status===401)return!0;let t=e.response?.errors;return!Array.isArray(t)||t.length===0?!1:t.some(e=>{if(typeof e!=`object`||!e)return!1;let t=e,n=typeof t.message==`string`?t.message:``;if(/^unauthorized$/i.test(n.trim()))return!0;let r=t.extensions?.code;return!!(typeof r==`string`&&/^UNAUTHENTICATED$/i.test(r)||t.extensions?.originalError?.statusCode===401)})}};Y.register(dJ,()=>new dJ(Y.get(Nq)),{scope:`singleton`});var Q=Y.get(dJ).client,fJ=`/api/auth/refresh`,pJ=`/api/auth/logout`,mJ=`rev_session`,hJ=class e{isLoaded=!1;user=null;token=null;refreshPromise=null;constructor(e,t,n){this.apiService=e,this.systemPermissions=t,this.permissionService=n,f(this),this.apiService.setUnauthorizedHandler(()=>this.tryRefresh())}async initialize(){if(!e.hasSessionCookie()){c(()=>{this.isLoaded=!0});return}try{await this.fetchMe()}catch{if(await this.tryRefresh())try{await this.fetchMe()}catch{}}c(()=>{this.isLoaded=!0})}async afterLogin(e){e!==void 0&&c(()=>{this.token=e}),await this.fetchMe()}setBearerToken(e){c(()=>{this.token=e}),this.apiService.setToken(e)}async logout(){try{await fetch(pJ,{method:`POST`,credentials:`include`})}catch{}this.apiService.setToken(null),c(()=>{this.user=null,this.token=null}),this.systemPermissions.clearAll()}async refresh(){return this.tryRefresh()}async fetchMe(){try{let e=await this.apiService.client.getMe();c(()=>{this.user=e.me}),this.systemPermissions.setUserRole(e.me.role??null),this.loadOrganizationPermissions(e.me)}catch(e){throw c(()=>{this.user=null}),e}}tryRefresh(){if(this.refreshPromise)return this.refreshPromise;let e=this.doRefresh();return c(()=>{this.refreshPromise=e}),e.finally(()=>{c(()=>{this.refreshPromise=null})}),e}async doRefresh(){try{return(await fetch(fJ,{method:`POST`,credentials:`include`})).ok}catch{return!1}}static hasSessionCookie(){if(typeof document>`u`)return!1;let e=document.cookie;return e?e.split(`;`).some(e=>e.trim()===`${mJ}=1`):!1}loadOrganizationPermissions(e){let t=e.organization?.userOrganization?.role?.permissions,n=e.organization?.id;if(t&&n){let e=t.map(e=>({id:e.id,action:e.action,subject:e.subject,condition:e.condition??null}));this.permissionService.addOrganizationPermissions(n,e)}}};Y.register(hJ,()=>{let e=new hJ(Y.get(dJ),Y.get(yW),Y.get(vW));return e.initialize(),e},{scope:`singleton`});var gJ=class{isLoaded=!1;error=null;data=null;constructor(e){this.apiService=e,f(this)}async initialize(){await this.init()}get availableSignUp(){return this.availableEmailSignUp||this.availableGoogleOauth||this.availableGithubOauth}get availableEmailSignUp(){return this.data?.availableEmailSignUp}get availableGoogleOauth(){return!!this.data?.google.available}get googleOauthClientId(){if(!this.data?.google.clientId)throw Error(`Invalid Google client id`);return this.data?.google.clientId}get availableGithubOauth(){return!!this.data?.github.available}get githubOauthClientId(){if(!this.data?.github.clientId)throw Error(`Invalid Github client id`);return this.data?.github.clientId}get billingEnabled(){return this.data?.billing.enabled??!1}get cacheEnabled(){return this.data?.cache?.enabled??!1}get noAuth(){return this.data?.noAuth??!1}async init(){await this.request()}async request(){try{let e=await this.apiService.client.configuration();this.setData(e.configuration)}catch(e){this.setError(e),console.error(e)}finally{this.setIsLoaded(!0)}}setData(e){this.data=e}setError(e){this.error=e}setIsLoaded(e){this.isLoaded=e}};Y.register(gJ,()=>{let e=new gJ(Y.get(dJ));return e.initialize(),e},{scope:`singleton`});var _J=class{constructor(e,t){this.authService=e,this.configurationService=t,f(this)}get isLoaded(){return this.authService.isLoaded&&this.configurationService.isLoaded}};Y.register(_J,()=>new _J(Y.get(hJ),Y.get(gJ)),{scope:`singleton`});var vJ=`sandbox`,yJ=`login`,bJ=`logout`,xJ=`signup`,SJ=`username`,CJ=`github`,wJ=`google`,TJ=`authorize`,EJ=`get-token`,DJ=`get-mcp-token`,OJ=`completed`,kJ=`confirm`,AJ=`:organizationId`,jJ=`-/settings`,MJ=`-/members`,NJ=`-/limits`,PJ=`:projectName`,FJ=`-/settings`,IJ=`-/users`,LJ=`-/api-keys`,RJ=`-/mcp`,zJ=`:branchName`,BJ=`-/changes`,VJ=`-/assets`,HJ=`-/migrations`,UJ=`-/endpoints`,WJ=`-/branches`,GJ=`-/relations`,KJ=`-/branch-map`,qJ=`:revisionIdOrTag`,JJ=`:tableId`,YJ=`:rowId`,XJ=`draft`,ZJ=`head`,QJ=`admin`,$J=`users`,eY=`:userId`,tY=`organizations`,nY=`cache`,rY=function(e){return e.Organization=`organization`,e.Project=`project`,e.Branch=`branch`,e.Revision=`revision`,e.Table=`table`,e.Row=`row`,e.Changes=`changes`,e.Assets=`assets`,e.Migrations=`migrations`,e.Endpoints=`endpoints`,e.Branches=`branches`,e.Relations=`relations`,e.BranchMap=`branchMap`,e.OrganizationOverview=`organizationOverview`,e.OrganizationSettings=`organizationSettings`,e.OrganizationMembers=`organizationMembers`,e.OrganizationLimits=`organizationLimits`,e.ProjectSettings=`projectSettings`,e.ProjectUsers=`projectUsers`,e.ProjectApiKeys=`projectApiKeys`,e.ProjectMcp=`projectMcp`,e.Admin=`admin`,e.AdminUsers=`adminUsers`,e.AdminUserDetail=`adminUserDetail`,e.AdminOrganizations=`adminOrganizations`,e.AdminCache=`adminCache`,e}({}),iY=async()=>Y.get(yW).canReadUser?!0:Cn(`/`),aY=async({request:e})=>{let t=Y.get(hJ),n=Y.get(gJ);if(!t.user){if(n.noAuth)try{let e=await Q.login({data:{emailOrUsername:`admin`,password:``}});return t.setBearerToken(e.login.accessToken),await t.afterLogin(),!0}catch(e){console.error(`noAuth bootstrap failed`,e),t.setBearerToken(null)}let r=new URL(e.url),i=$V(`${r.pathname}${r.search}`);return Cn(`${n.availableSignUp?`/${xJ}`:`/${yJ}`}${i}`)}return t.user.username?!0:Cn(`/${SJ}`)},oY=async e=>{let t=Y.get(hJ),n=Y.get(gJ);if(!t.user){if(n.noAuth){try{let e=await Q.login({data:{emailOrUsername:`admin`,password:``}});t.setBearerToken(e.login.accessToken),await t.afterLogin()}catch(e){console.error(`noAuth bootstrap failed`,e),t.setBearerToken(null)}return!0}return!0}return t.user.username?!0:Cn(`/${SJ}`)},sY=async()=>Y.get(hJ).user?Cn(`/`):!0,cY=async()=>{let e=Y.get(hJ),t=Y.get(gJ);return e.user||!t.availableSignUp?Cn(`/`):!0},lY=(...e)=>async t=>{let n=null;for(let r of e){let e=await r(t);if(e&&typeof e==`object`&&`status`in e&&e.status===302)return e;n=e}return n},uY=async()=>!0,dY=class{statsRequest=X.of(Q.adminCacheStats);resetRequest=X.of(Q.adminResetAllCache);configurationService;_resetSuccess=!1;_showConfirm=!1;constructor(e){this.configurationService=e,f(this,{},{autoBind:!0})}get cacheEnabled(){return this.configurationService.cacheEnabled}get isLoading(){return this.statsRequest.isLoading}get isResetting(){return this.resetRequest.isLoading}get resetSuccess(){return this._resetSuccess}get showConfirm(){return this._showConfirm}get totalHits(){return this.statsRequest.data?.adminCacheStats.totalHits??0}get totalMisses(){return this.statsRequest.data?.adminCacheStats.totalMisses??0}get totalWrites(){return this.statsRequest.data?.adminCacheStats.totalWrites??0}get totalDeletes(){return this.statsRequest.data?.adminCacheStats.totalDeletes??0}get totalClears(){return this.statsRequest.data?.adminCacheStats.totalClears??0}get overallHitRate(){return this.statsRequest.data?.adminCacheStats.overallHitRate??0}get byCategory(){return this.statsRequest.data?.adminCacheStats.byCategory??[]}get resetError(){return this.resetRequest.errorMessage??null}openConfirm(){this._showConfirm=!0,this._resetSuccess=!1}closeConfirm(){this._showConfirm=!1}async confirmReset(){this._showConfirm=!1,(await this.resetRequest.fetch({})).isRight&&(c(()=>{this._resetSuccess=!0}),this.statsRequest.fetch({}))}init(){this.cacheEnabled&&this.statsRequest.fetch({})}dispose(){this.statsRequest.abort(),this.resetRequest.abort()}};Y.register(dY,()=>new dY(Y.get(gJ)),{scope:`request`});var fY=({label:e,value:t,isLoading:n})=>(0,I.jsxs)(A,{padding:`24px`,borderRadius:`8px`,border:`1px solid`,borderColor:`gray.200`,backgroundColor:`white`,minWidth:`160px`,children:[(0,I.jsx)(k,{fontSize:`sm`,color:`gray.500`,marginBottom:`8px`,children:e}),n?(0,I.jsx)(Ht,{size:`sm`,color:`gray.400`}):(0,I.jsx)(k,{fontSize:`2xl`,fontWeight:`600`,color:`gray.900`,children:t})]}),pY=({keyName:e,hits:t,misses:n,writes:r,deletes:i,hitRate:a})=>(0,I.jsxs)(j,{padding:`12px 16px`,borderBottom:`1px solid`,borderColor:`gray.100`,alignItems:`center`,gap:`16px`,_last:{borderBottom:`none`},children:[(0,I.jsx)(k,{flex:`1`,fontSize:`sm`,fontWeight:`500`,fontFamily:`mono`,children:e}),(0,I.jsxs)(k,{fontSize:`sm`,color:`gray.600`,minWidth:`80px`,textAlign:`right`,children:[t,` hits`]}),(0,I.jsxs)(k,{fontSize:`sm`,color:`gray.600`,minWidth:`80px`,textAlign:`right`,children:[n,` misses`]}),(0,I.jsxs)(k,{fontSize:`sm`,color:`gray.600`,minWidth:`80px`,textAlign:`right`,children:[r,` writes`]}),(0,I.jsxs)(k,{fontSize:`sm`,color:`gray.600`,minWidth:`80px`,textAlign:`right`,children:[i,` del`]}),(0,I.jsxs)(k,{fontSize:`sm`,fontWeight:`500`,minWidth:`60px`,textAlign:`right`,children:[(a*100).toFixed(1),`%`]})]}),mY=g(()=>{let e=CB(dY);return(0,I.jsxs)(j,{flexDirection:`column`,height:`100%`,children:[(0,I.jsx)(j,{alignItems:`center`,backgroundColor:`white`,justifyContent:`space-between`,width:`100%`,position:`sticky`,zIndex:1,top:0,padding:`8px`,children:(0,I.jsx)(j,{alignItems:`center`,gap:`4px`,height:`40px`,children:(0,I.jsx)($t,{color:`gray`,fontWeight:`600`,fontSize:`16px`,children:(0,I.jsx)(Gt,{fontSize:`16px`,children:(0,I.jsx)(Dt,{children:(0,I.jsx)(Xt,{color:`gray`,children:`Cache`})})})})})}),e.cacheEnabled?(0,I.jsxs)(A,{padding:`8px`,paddingTop:`16px`,children:[(0,I.jsxs)(j,{gap:`16px`,flexWrap:`wrap`,marginBottom:`24px`,children:[(0,I.jsx)(fY,{label:`Hit Rate`,value:`${(e.overallHitRate*100).toFixed(1)}%`,isLoading:e.isLoading}),(0,I.jsx)(fY,{label:`Hits`,value:e.totalHits,isLoading:e.isLoading}),(0,I.jsx)(fY,{label:`Misses`,value:e.totalMisses,isLoading:e.isLoading}),(0,I.jsx)(fY,{label:`Writes`,value:e.totalWrites,isLoading:e.isLoading}),(0,I.jsx)(fY,{label:`Deletes`,value:e.totalDeletes,isLoading:e.isLoading}),(0,I.jsx)(fY,{label:`Clears`,value:e.totalClears,isLoading:e.isLoading})]}),e.byCategory.length>0&&(0,I.jsxs)(A,{marginBottom:`24px`,children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`600`,color:`gray.700`,marginBottom:`8px`,children:`By Cache Type`}),(0,I.jsx)(A,{border:`1px solid`,borderColor:`gray.200`,borderRadius:`8px`,backgroundColor:`white`,children:e.byCategory.map(e=>(0,I.jsx)(pY,{keyName:e.key,hits:e.hits,misses:e.misses,writes:e.writes,deletes:e.deletes,hitRate:e.hitRate},e.key))})]}),(0,I.jsxs)(A,{children:[(0,I.jsx)(N,{colorPalette:`red`,variant:`outline`,size:`sm`,onClick:e.openConfirm,loading:e.isResetting,children:`Reset All Cache`}),e.resetSuccess&&(0,I.jsx)(k,{fontSize:`sm`,color:`green.500`,marginTop:`8px`,children:`Cache has been cleared successfully`}),e.resetError&&(0,I.jsx)(k,{fontSize:`sm`,color:`red.500`,marginTop:`8px`,children:e.resetError})]})]}):(0,I.jsx)(A,{padding:`8px`,paddingTop:`16px`,children:(0,I.jsxs)(A,{padding:`24px`,borderRadius:`8px`,border:`1px solid`,borderColor:`gray.200`,backgroundColor:`white`,children:[(0,I.jsx)(k,{fontSize:`md`,fontWeight:`500`,color:`gray.500`,children:`Caching is disabled`}),(0,I.jsx)(k,{fontSize:`sm`,color:`gray.400`,marginTop:`4px`,children:`Set CACHE_ENABLED=1 to enable caching.`})]})}),(0,I.jsx)(Ue,{open:e.showConfirm,onOpenChange:({open:t})=>!t&&e.closeConfirm(),size:`md`,children:(0,I.jsxs)(R,{children:[(0,I.jsx)(pe,{}),(0,I.jsx)(ue,{children:(0,I.jsxs)(_n,{children:[(0,I.jsx)(Ge,{children:(0,I.jsx)(qe,{children:`Reset All Cache`})}),(0,I.jsx)(be,{children:(0,I.jsxs)(M,{align:`stretch`,gap:`1rem`,children:[(0,I.jsx)(k,{children:`Are you sure you want to clear the entire cache?`}),(0,I.jsx)(k,{fontSize:`sm`,color:`gray.600`,children:`This will flush all cached data including rows, revisions, auth, and billing caches. The cache will be rebuilt automatically as data is accessed.`})]})}),(0,I.jsxs)(w,{children:[(0,I.jsx)(oe,{asChild:!0,children:(0,I.jsx)(N,{variant:`outline`,children:`Cancel`})}),(0,I.jsx)(N,{colorPalette:`red`,onClick:e.confirmReset,children:`Reset Cache`})]}),(0,I.jsx)(Ie,{})]})})]})})]})}),hY=class{usersRequest=X.of(Q.AdminDashboardStats);constructor(){f(this,{},{autoBind:!0})}get isLoadingUsers(){return this.usersRequest.isLoading}get isLoadingProjects(){return!1}get usersCount(){return this.usersRequest.data?.searchUsers.totalCount??null}get projectsCount(){return null}init(){this.usersRequest.fetch({first:1})}dispose(){this.usersRequest.abort()}};Y.register(hY,()=>new hY,{scope:`request`});var gY=({label:e,value:t,isLoading:n})=>(0,I.jsxs)(A,{padding:`24px`,borderRadius:`8px`,border:`1px solid`,borderColor:`gray.200`,backgroundColor:`white`,minWidth:`200px`,children:[(0,I.jsx)(k,{fontSize:`sm`,color:`gray.500`,marginBottom:`8px`,children:e}),n?(0,I.jsx)(Ht,{size:`sm`,color:`gray.400`}):(0,I.jsx)(k,{fontSize:`2xl`,fontWeight:`600`,color:`gray.900`,children:t??`-`})]}),_Y=g(()=>{let e=CB(hY);return(0,I.jsxs)(j,{flexDirection:`column`,height:`100%`,children:[(0,I.jsx)(j,{alignItems:`center`,backgroundColor:`white`,justifyContent:`space-between`,width:`100%`,position:`sticky`,zIndex:1,top:0,padding:`8px`,children:(0,I.jsx)(j,{alignItems:`center`,gap:`4px`,height:`40px`,children:(0,I.jsx)($t,{color:`gray`,fontWeight:`600`,fontSize:`16px`,children:(0,I.jsx)(Gt,{fontSize:`16px`,children:(0,I.jsx)(Dt,{children:(0,I.jsx)(Xt,{color:`gray`,children:`Admin`})})})})})}),(0,I.jsx)(A,{padding:`8px`,paddingTop:`16px`,children:(0,I.jsxs)(j,{gap:`16px`,flexWrap:`wrap`,children:[(0,I.jsx)(gY,{label:`Total Users`,value:e.usersCount,isLoading:e.isLoadingUsers}),(0,I.jsx)(gY,{label:`Total Projects`,value:e.projectsCount,isLoading:e.isLoadingProjects})]})})]})}),vY=class{constructor(e){this.data=e,f(this)}get id(){return this.data.id}get name(){return this.data.name}get prefix(){return this.data.prefix}get type(){return this.data.type}get isExpired(){return this.data.expiresAt?new Date(this.data.expiresAt)<new Date:!1}get isRevoked(){return this.data.revokedAt!==null}get isActive(){return!this.isExpired&&!this.isRevoked}get statusLabel(){return this.isRevoked?`Revoked`:this.isExpired?`Expired`:`Active`}get lastUsedAt(){return this.data.lastUsedAt??null}get createdAt(){return this.data.createdAt}get expiresAt(){return this.data.expiresAt??null}get readOnly(){return this.data.readOnly}get organizationId(){return this.data.organizationId??null}get projectIds(){return this.data.projectIds}get resolvedProjects(){return this.data.projects}get permissionLabel(){if(this.data.type===`PERSONAL`)return this.data.readOnly?`Read only`:`Full access`;let e=this.data.permissions?.rules?.[0]?.action??[];return e.includes(`delete`)?`Full access`:e.includes(`create`)||e.includes(`update`)?`Read & Write`:`Read only`}get permissionColorPalette(){switch(this.permissionLabel){case`Full access`:return`orange`;case`Read & Write`:return`blue`;default:return`gray`}}},yY={Active:{colorPalette:`green`},Expired:{colorPalette:`yellow`},Revoked:{colorPalette:`gray`}},bY=({status:e})=>{let t=yY[e];return(0,I.jsx)(It,{variant:`subtle`,colorPalette:t.colorPalette,size:`sm`,children:e})};function xY(e){if(e==null)return``;let t=new Date(e);return Number.isNaN(t.getTime())?``:HV(t,{addSuffix:!0})}var SY=({name:e,prefix:t,status:n,permissionLabel:r,permissionColor:i,projects:a,lastUsedAt:o,createdAt:s,expiresAt:c,actions:l})=>(0,I.jsx)(A,{width:`100%`,p:4,borderWidth:`1px`,borderColor:`gray.200`,borderRadius:`lg`,bg:`white`,transition:`all 0.2s`,_hover:{borderColor:`gray.300`},children:(0,I.jsxs)(j,{justify:`space-between`,align:`center`,children:[(0,I.jsxs)(j,{flexDirection:`column`,gap:1,flex:1,minWidth:0,children:[(0,I.jsxs)(P,{gap:2,children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`600`,color:`gray.700`,truncate:!0,children:e}),n!==`Active`&&(0,I.jsx)(bY,{status:n}),(0,I.jsx)(It,{variant:`outline`,colorPalette:i,size:`sm`,children:r})]}),(0,I.jsxs)(P,{gap:2,children:[(0,I.jsx)(k,{fontSize:`xs`,fontFamily:`mono`,color:`gray.400`,children:t}),a.length>0&&(0,I.jsx)(P,{gap:1,children:a.map(e=>(0,I.jsx)(It,{variant:`outline`,colorPalette:`gray`,size:`sm`,children:e.name},e.id))}),a.length===0&&(0,I.jsx)(It,{variant:`outline`,colorPalette:`gray`,size:`sm`,children:`All projects`})]}),(0,I.jsxs)(P,{gap:4,mt:1,flexWrap:`wrap`,children:[(0,I.jsxs)(k,{fontSize:`xs`,color:`gray.500`,children:[`Created `,UV(s)]}),c&&(0,I.jsxs)(k,{fontSize:`xs`,color:`gray.500`,children:[`Expires `,UV(c)]}),(0,I.jsx)(k,{fontSize:`xs`,color:`gray.500`,children:o?`Last used ${xY(o)}`:`Never used`})]})]}),l&&(0,I.jsx)(P,{gap:1,children:l})]})}),CY=[{value:`30d`,label:`30 days`},{value:`60d`,label:`60 days`},{value:`90d`,label:`90 days`},{value:`1y`,label:`1 year`},{value:`none`,label:`No expiration`}],wY=[{value:`read-only`,label:`Read only`,description:`Can only read data`},{value:`read-write`,label:`Read & Write`,description:`Can read, create, and update data`},{value:`full-access`,label:`Full access`,description:`Can read, create, update, and delete data`}],TY=g(({model:e})=>(0,I.jsx)(Ue,{open:e.isCreateDialogOpen,onOpenChange:({open:t})=>!t&&e.closeCreateDialog(),size:`md`,children:(0,I.jsxs)(R,{children:[(0,I.jsx)(pe,{}),(0,I.jsx)(ue,{children:(0,I.jsxs)(_n,{children:[(0,I.jsx)(Ge,{children:(0,I.jsx)(qe,{children:e.mode===`personal`?`Create Personal API Key`:`Create Service API Key`})}),(0,I.jsx)(be,{children:(0,I.jsxs)(M,{align:`stretch`,gap:`1rem`,children:[(0,I.jsxs)(j,{flexDirection:`column`,gap:`0.5rem`,children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`500`,color:`gray.600`,children:`Name`}),(0,I.jsx)(qt,{placeholder:`e.g., CI/CD pipeline, Data sync...`,value:e.createKeyName,onChange:t=>e.setCreateKeyName(t.target.value),autoFocus:!0})]}),(0,I.jsxs)(j,{flexDirection:`column`,gap:`0.5rem`,children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`500`,color:`gray.600`,children:`Expiration`}),(0,I.jsx)(P,{gap:2,flexWrap:`wrap`,children:CY.map(t=>(0,I.jsx)(N,{size:`sm`,variant:e.createKeyExpirationPreset===t.value?`solid`:`outline`,onClick:()=>e.setExpirationPreset(t.value),children:t.label},t.value))})]}),e.mode===`personal`&&(0,I.jsxs)(j,{flexDirection:`column`,gap:`0.5rem`,children:[(0,I.jsx)(P,{gap:2,children:(0,I.jsxs)(A,{as:`button`,onClick:()=>e.setCreateKeyReadOnly(!e.createKeyReadOnly),display:`flex`,alignItems:`center`,gap:2,cursor:`pointer`,children:[(0,I.jsx)(A,{width:`18px`,height:`18px`,borderWidth:`1px`,borderColor:e.createKeyReadOnly?`blue.500`:`gray.300`,borderRadius:`sm`,bg:e.createKeyReadOnly?`blue.500`:`transparent`,display:`flex`,alignItems:`center`,justifyContent:`center`,transition:`all 0.2s`,children:e.createKeyReadOnly&&(0,I.jsx)(k,{color:`white`,fontSize:`xs`,fontWeight:`bold`,lineHeight:1,children:`✓`})}),(0,I.jsx)(k,{fontSize:`sm`,color:`gray.700`,children:`Read only`})]})}),(0,I.jsx)(k,{fontSize:`xs`,color:`gray.500`,pl:`26px`,children:`Key can only read data, not modify it`})]}),e.mode===`service`&&(0,I.jsxs)(j,{flexDirection:`column`,gap:`0.5rem`,children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`500`,color:`gray.600`,children:`Permissions`}),(0,I.jsx)(M,{align:`stretch`,gap:2,children:wY.map(t=>(0,I.jsxs)(A,{as:`button`,onClick:()=>e.setPermissionPreset(t.value),width:`100%`,p:3,borderWidth:`1px`,borderColor:e.createKeyPermissionPreset===t.value?`blue.400`:`gray.200`,borderRadius:`md`,bg:e.createKeyPermissionPreset===t.value?`blue.50`:`white`,cursor:`pointer`,textAlign:`left`,transition:`all 0.2s`,_hover:{borderColor:`blue.300`},children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`500`,color:`gray.700`,children:t.label}),(0,I.jsx)(k,{fontSize:`xs`,color:`gray.500`,children:t.description})]},t.value))})]}),e.defaultProjectId&&(0,I.jsx)(j,{align:`center`,gap:2,p:3,bg:`blue.50`,borderRadius:`md`,borderWidth:`1px`,borderColor:`blue.200`,children:(0,I.jsxs)(k,{fontSize:`sm`,color:`blue.700`,children:[`This key will be scoped to project `,(0,I.jsx)(`strong`,{children:e.defaultProjectId})]})})]})}),(0,I.jsxs)(w,{children:[(0,I.jsx)(oe,{asChild:!0,children:(0,I.jsx)(N,{variant:`outline`,children:`Cancel`})}),(0,I.jsx)(N,{onClick:e.createKey,disabled:!e.canCreateKey,loading:e.isMutating,children:`Create key`})]}),(0,I.jsx)(Ie,{})]})})]})})),EY=g(({isOpen:e,keyName:t,isLoading:n,onConfirm:r,onClose:i})=>(0,I.jsx)(Ue,{open:e,onOpenChange:({open:e})=>!e&&i(),size:`md`,children:(0,I.jsxs)(R,{children:[(0,I.jsx)(pe,{}),(0,I.jsx)(ue,{children:(0,I.jsxs)(_n,{children:[(0,I.jsx)(Ge,{children:(0,I.jsx)(qe,{children:`Revoke API Key`})}),(0,I.jsx)(be,{children:(0,I.jsxs)(M,{align:`stretch`,gap:`1rem`,children:[(0,I.jsxs)(k,{children:[`Are you sure you want to revoke the key `,(0,I.jsx)(`strong`,{children:t}),`?`]}),(0,I.jsx)(k,{fontSize:`sm`,color:`gray.600`,children:`This action cannot be undone. Any applications using this key will immediately lose access.`})]})}),(0,I.jsxs)(w,{children:[(0,I.jsx)(oe,{asChild:!0,children:(0,I.jsx)(N,{variant:`outline`,children:`Cancel`})}),(0,I.jsx)(N,{colorPalette:`red`,onClick:r,loading:n,children:`Revoke key`})]}),(0,I.jsx)(Ie,{})]})})]})})),DY=g(({isOpen:e,keyName:t,isLoading:n,onConfirm:r,onClose:i})=>(0,I.jsx)(Ue,{open:e,onOpenChange:({open:e})=>!e&&i(),size:`md`,children:(0,I.jsxs)(R,{children:[(0,I.jsx)(pe,{}),(0,I.jsx)(ue,{children:(0,I.jsxs)(_n,{children:[(0,I.jsx)(Ge,{children:(0,I.jsx)(qe,{children:`Rotate API Key`})}),(0,I.jsx)(be,{children:(0,I.jsxs)(M,{align:`stretch`,gap:`1rem`,children:[(0,I.jsxs)(k,{children:[`Are you sure you want to rotate the key `,(0,I.jsx)(`strong`,{children:t}),`?`]}),(0,I.jsx)(k,{fontSize:`sm`,color:`gray.600`,children:`This will generate a new secret and invalidate the current one. Any applications using the current key will need to be updated.`})]})}),(0,I.jsxs)(w,{children:[(0,I.jsx)(oe,{asChild:!0,children:(0,I.jsx)(N,{variant:`outline`,children:`Cancel`})}),(0,I.jsx)(N,{colorPalette:`orange`,onClick:r,loading:n,children:`Rotate key`})]}),(0,I.jsx)(Ie,{})]})})]})})),OY=g(({isOpen:e,secret:t,keyName:n,onClose:r})=>{let i=(0,L.useCallback)(async()=>{t&&(await navigator.clipboard.writeText(t),Jq.info({description:`Copied to clipboard`}))},[t]);return(0,I.jsx)(Ue,{open:e,onOpenChange:({open:e})=>!e&&r(),size:`md`,closeOnInteractOutside:!1,children:(0,I.jsxs)(R,{children:[(0,I.jsx)(pe,{}),(0,I.jsx)(ue,{children:(0,I.jsxs)(_n,{children:[(0,I.jsx)(Ge,{children:(0,I.jsx)(qe,{children:`Your API Key`})}),(0,I.jsx)(be,{children:(0,I.jsxs)(M,{align:`stretch`,gap:`1rem`,children:[n&&(0,I.jsxs)(k,{fontSize:`sm`,color:`gray.600`,children:[`Key `,(0,I.jsx)(`strong`,{children:n}),` has been created successfully.`]}),(0,I.jsx)(A,{children:(0,I.jsxs)(j,{gap:2,children:[(0,I.jsx)(qt,{value:t??``,readOnly:!0,fontFamily:`mono`,fontSize:`sm`,bg:`gray.50`}),(0,I.jsxs)(N,{variant:`outline`,onClick:i,flexShrink:0,children:[(0,I.jsx)(qf,{}),`Copy`]})]})}),(0,I.jsxs)(j,{align:`center`,gap:2,p:3,bg:`yellow.50`,borderRadius:`md`,borderWidth:`1px`,borderColor:`yellow.200`,children:[(0,I.jsx)(one,{color:`var(--chakra-colors-yellow-600)`}),(0,I.jsx)(k,{fontSize:`sm`,color:`yellow.800`,children:`Make sure to copy your API key now. You won't be able to see it again.`})]})]})}),(0,I.jsx)(w,{children:(0,I.jsx)(N,{onClick:r,children:`I've copied the key`})})]})})]})})}),kY=g(({model:e,showCreateButton:t=!0})=>((0,L.useEffect)(()=>(e.loadKeys().catch(e.handleLoadKeysError),()=>e.reset()),[e]),e.isLoaded?e.error?(0,I.jsx)(A,{p:4,bg:`red.50`,borderRadius:`md`,borderWidth:`1px`,borderColor:`red.200`,children:(0,I.jsx)(k,{fontSize:`sm`,color:`red.600`,children:e.error})}):(0,I.jsxs)(M,{align:`stretch`,gap:3,children:[t&&!e.isEmpty&&(0,I.jsxs)(j,{justify:`space-between`,align:`center`,children:[(0,I.jsx)(k,{fontSize:`sm`,color:`gray.500`,children:`${e.sortedItems.length} key${e.sortedItems.length===1?``:`s`}`}),(0,I.jsxs)(N,{size:`sm`,onClick:e.openCreateDialog,children:[(0,I.jsx)(Pf,{}),`Create key`]})]}),e.isEmpty&&e.isLoaded&&(0,I.jsxs)(A,{p:6,textAlign:`center`,borderWidth:`1px`,borderColor:`gray.200`,borderRadius:`lg`,bg:`gray.50`,children:[(0,I.jsx)(k,{fontSize:`sm`,color:`gray.500`,children:e.emptyStateMessage}),t&&(0,I.jsxs)(N,{size:`sm`,mt:3,onClick:e.openCreateDialog,children:[(0,I.jsx)(Pf,{}),`Create your first key`]})]}),e.sortedItems.map(t=>(0,I.jsx)(SY,{name:t.name,prefix:t.prefix,status:t.statusLabel,permissionLabel:t.permissionLabel,permissionColor:t.permissionColorPalette,projects:t.resolvedProjects,lastUsedAt:t.lastUsedAt,createdAt:t.createdAt,expiresAt:t.expiresAt,actions:t.isActive?(0,I.jsxs)(P,{gap:1,children:[(0,I.jsx)(N,{size:`xs`,variant:`ghost`,color:`gray.500`,_hover:{color:`orange.600`,bg:`orange.50`},onClick:()=>e.openRotateDialog(t.id),children:(0,I.jsx)(Ate,{})}),(0,I.jsx)(N,{size:`xs`,variant:`ghost`,color:`gray.500`,_hover:{color:`red.600`,bg:`red.50`},onClick:()=>e.openRevokeDialog(t.id),children:(0,I.jsx)(Rf,{})})]}):void 0},t.id)),(0,I.jsx)(TY,{model:e}),(0,I.jsx)(OY,{isOpen:e.isSecretDialogOpen,secret:e.lastSecret,keyName:e.lastCreatedKeyName,onClose:e.closeSecretDialog}),(0,I.jsx)(EY,{isOpen:e.isRevokeDialogOpen,keyName:e.selectedKey?.name,isLoading:e.isMutating,onConfirm:e.revokeKey,onClose:e.closeRevokeDialog}),(0,I.jsx)(DY,{isOpen:e.isRotateDialogOpen,keyName:e.selectedKey?.name,isLoading:e.isMutating,onConfirm:e.rotateKey,onClose:e.closeRotateDialog})]}):(0,I.jsx)(j,{justify:`center`,py:8,children:(0,I.jsx)(Ht,{size:`md`,color:`gray.400`})}))),AY=class{myKeysRequest=X.of(Q.myApiKeys,{skipResetting:!0});serviceKeysRequest=X.of(Q.serviceApiKeys,{skipResetting:!0});createPersonalRequest=X.of(Q.createPersonalApiKey);createServiceRequest=X.of(Q.createServiceApiKey);revokeRequest=X.of(Q.revokeApiKey);rotateRequest=X.of(Q.rotateApiKey);constructor(){f(this)}get isLoading(){return this.myKeysRequest.isLoading||this.serviceKeysRequest.isLoading}get error(){return this.myKeysRequest.errorMessage??this.serviceKeysRequest.errorMessage??null}get isMutating(){return this.createPersonalRequest.isLoading||this.createServiceRequest.isLoading||this.revokeRequest.isLoading||this.rotateRequest.isLoading}fetchPersonalKeys(){return this.myKeysRequest.fetch()}fetchServiceKeys(e){return this.serviceKeysRequest.fetch({organizationId:e})}async createPersonalKey(e){let t=await this.createPersonalRequest.fetch({data:e});return t.isRight?t.data.createPersonalApiKey:null}async createServiceKey(e){let t=await this.createServiceRequest.fetch({data:e});return t.isRight?t.data.createServiceApiKey:null}async revokeKey(e){let t=await this.revokeRequest.fetch({id:e});return t.isRight?t.data.revokeApiKey:null}async rotateKey(e){let t=await this.rotateRequest.fetch({id:e});return t.isRight?t.data.rotateApiKey:null}dispose(){this.myKeysRequest.abort(),this.serviceKeysRequest.abort(),this.createPersonalRequest.abort(),this.createServiceRequest.abort(),this.revokeRequest.abort(),this.rotateRequest.abort()}};Y.register(AY,()=>new AY,{scope:`request`});var jY={"read-only":[{action:[`read`],subject:[`all`]}],"read-write":[{action:[`read`,`create`,`update`],subject:[`all`]}],"full-access":[{action:[`read`,`create`,`update`,`delete`],subject:[`all`]}]},MY=class{_config={mode:`personal`};_items=[];_isLoaded=!1;_loadError=null;_isCreateDialogOpen=!1;_isSecretDialogOpen=!1;_isRevokeDialogOpen=!1;_isRotateDialogOpen=!1;_selectedKeyId=null;_lastSecret=null;_lastCreatedKeyName=null;createKeyName=``;createKeyReadOnly=!1;createKeyExpiresAt=null;createKeyExpirationPreset=`none`;createKeyPermissionPreset=`read-only`;constructor(e){this.dataSource=e,f(this,{},{autoBind:!0})}get mode(){return this._config.mode}get organizationId(){return this._config.organizationId}get defaultProjectId(){return this._config.defaultProjectId}get filterByProjectId(){return this._config.filterByProjectId}get items(){return this._items}get filteredItems(){if(!this._config.filterByProjectId)return this._items;let e=this._config.filterByProjectId;return this._items.filter(t=>t.projectIds.includes(e))}get sortedItems(){return[...this.filteredItems].sort((e,t)=>{let n={Active:0,Expired:1,Revoked:2},r=n[e.statusLabel]-n[t.statusLabel];return r===0?new Date(t.createdAt).getTime()-new Date(e.createdAt).getTime():r})}get isLoading(){return this.dataSource.isLoading}get isLoaded(){return this._isLoaded}get isMutating(){return this.dataSource.isMutating}get error(){return this._loadError??this.dataSource.error}get isEmpty(){return this.filteredItems.length===0}get isCreateDialogOpen(){return this._isCreateDialogOpen}get isSecretDialogOpen(){return this._isSecretDialogOpen}get isRevokeDialogOpen(){return this._isRevokeDialogOpen}get isRotateDialogOpen(){return this._isRotateDialogOpen}get selectedKeyId(){return this._selectedKeyId}get lastSecret(){return this._lastSecret}get lastCreatedKeyName(){return this._lastCreatedKeyName}get selectedKey(){return this._items.find(e=>e.id===this._selectedKeyId)}get canCreateKey(){return this.createKeyName.trim().length>0&&!this.isMutating}get emptyStateMessage(){return this._config.mode===`personal`?`No API keys yet. Create one for programmatic access to your data.`:`No integration keys for this organization.`}configure(e){this._config=e}init(){}dispose(){this.dataSource.dispose()}reset(){this._items=[],this._isLoaded=!1,this._loadError=null}async loadKeys(){if(c(()=>{this._loadError=null}),this._config.mode===`personal`){let e=await this.dataSource.fetchPersonalKeys();if(!e.isRight){if(qV(e))return;c(()=>{this._isLoaded=!0});return}c(()=>{this._items=e.data.myApiKeys.filter(e=>e.type!==`INTERNAL`).map(e=>new vY(e)),this._isLoaded=!0})}else if(this._config.organizationId){let e=await this.dataSource.fetchServiceKeys(this._config.organizationId);if(!e.isRight){if(qV(e))return;c(()=>{this._isLoaded=!0});return}c(()=>{this._items=e.data.serviceApiKeys.filter(e=>e.type!==`INTERNAL`).map(e=>new vY(e)),this._isLoaded=!0})}}handleLoadKeysError(e){console.error(e),c(()=>{this._loadError=e instanceof Error?e.message:`Failed to load API keys`,this._isLoaded=!0})}openCreateDialog(){this._isCreateDialogOpen=!0,this.createKeyName=``,this.createKeyReadOnly=!1,this.createKeyExpiresAt=null,this.createKeyExpirationPreset=`none`,this.createKeyPermissionPreset=`read-only`}closeCreateDialog(){this._isCreateDialogOpen=!1}setCreateKeyName(e){this.createKeyName=e}setCreateKeyReadOnly(e){this.createKeyReadOnly=e}setExpirationPreset(e){this.createKeyExpirationPreset=e;let t=new Date;switch(e){case`30d`:t.setDate(t.getDate()+30),this.createKeyExpiresAt=t.toISOString();break;case`60d`:t.setDate(t.getDate()+60),this.createKeyExpiresAt=t.toISOString();break;case`90d`:t.setDate(t.getDate()+90),this.createKeyExpiresAt=t.toISOString();break;case`1y`:t.setFullYear(t.getFullYear()+1),this.createKeyExpiresAt=t.toISOString();break;case`none`:this.createKeyExpiresAt=null;break}}setPermissionPreset(e){this.createKeyPermissionPreset=e}async createKey(){if(this.canCreateKey){if(this._config.mode===`personal`){let e={name:this.createKeyName.trim(),readOnly:this.createKeyReadOnly,expiresAt:this.createKeyExpiresAt??void 0,projectIds:this._config.defaultProjectId?[this._config.defaultProjectId]:void 0},t=await this.dataSource.createPersonalKey(e);t&&(c(()=>{this._lastSecret=t.secret,this._lastCreatedKeyName=t.apiKey.name,this._isCreateDialogOpen=!1,this._isSecretDialogOpen=!0}),await this.loadKeys())}else if(this._config.organizationId){let e={name:this.createKeyName.trim(),organizationId:this._config.organizationId,readOnly:this.createKeyReadOnly,expiresAt:this.createKeyExpiresAt??void 0,projectIds:this._config.defaultProjectId?[this._config.defaultProjectId]:void 0,permissions:{rules:jY[this.createKeyPermissionPreset]}},t=await this.dataSource.createServiceKey(e);t&&(c(()=>{this._lastSecret=t.secret,this._lastCreatedKeyName=t.apiKey.name,this._isCreateDialogOpen=!1,this._isSecretDialogOpen=!0}),await this.loadKeys())}}}closeSecretDialog(){this._isSecretDialogOpen=!1,this._lastSecret=null,this._lastCreatedKeyName=null}openRevokeDialog(e){this._selectedKeyId=e,this._isRevokeDialogOpen=!0}closeRevokeDialog(){this._isRevokeDialogOpen=!1,this._selectedKeyId=null}async revokeKey(){this._selectedKeyId&&await this.dataSource.revokeKey(this._selectedKeyId)&&(c(()=>{this._isRevokeDialogOpen=!1,this._selectedKeyId=null}),await this.loadKeys())}openRotateDialog(e){this._selectedKeyId=e,this._isRotateDialogOpen=!0}closeRotateDialog(){this._isRotateDialogOpen=!1,this._selectedKeyId=null}async rotateKey(){if(!this._selectedKeyId)return;let e=await this.dataSource.rotateKey(this._selectedKeyId);e&&(c(()=>{this._lastSecret=e.secret,this._lastCreatedKeyName=e.apiKey.name,this._isRotateDialogOpen=!1,this._selectedKeyId=null,this._isSecretDialogOpen=!0}),await this.loadKeys())}};Y.register(MY,()=>new MY(Y.get(AY)),{scope:`request`});var NY=g(({model:e})=>{let t=(0,L.useCallback)(async()=>{await e.savePassword()&&Jq.success({description:`Password updated successfully`})},[e]);return(0,I.jsx)(Ue,{open:e.isOpen,onOpenChange:({open:t})=>!t&&e.close(),size:`md`,children:(0,I.jsxs)(R,{children:[(0,I.jsx)(pe,{}),(0,I.jsx)(ue,{children:(0,I.jsxs)(_n,{children:[(0,I.jsx)(Ge,{children:(0,I.jsx)(qe,{children:`Account Settings`})}),(0,I.jsx)(be,{children:(0,I.jsxs)(rn,{value:e.activeTab,onValueChange:({value:t})=>e.setActiveTab(t),lazyMount:!0,unmountOnExit:!0,children:[(0,I.jsxs)(et,{marginBottom:`1rem`,children:[(0,I.jsxs)(fn,{value:`account`,children:[(0,I.jsx)(zf,{}),`Account`]}),(0,I.jsxs)(fn,{value:`password`,children:[(0,I.jsx)(Of,{}),`Password`]}),(0,I.jsxs)(fn,{value:`api-keys`,children:[(0,I.jsx)(Df,{}),`Personal Tokens`]})]}),(0,I.jsx)(bt,{value:`account`,children:(0,I.jsxs)(M,{align:`stretch`,gap:`1rem`,children:[e.username&&(0,I.jsxs)(j,{flexDirection:`column`,gap:`0.5rem`,children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`500`,color:`gray.600`,children:`Username`}),(0,I.jsx)(qt,{value:e.username,readOnly:!0})]}),e.email&&(0,I.jsxs)(j,{flexDirection:`column`,gap:`0.5rem`,children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`500`,color:`gray.600`,children:`Email`}),(0,I.jsx)(qt,{value:e.email,readOnly:!0})]}),(0,I.jsx)(A,{paddingTop:`1rem`,borderTop:`1px solid`,borderTopColor:`newGray.100`,children:(0,I.jsxs)(N,{variant:`outline`,onClick:e.logout,width:`100%`,children:[(0,I.jsx)(tne,{}),`Sign out`]})})]})}),(0,I.jsx)(bt,{value:`password`,children:(0,I.jsxs)(M,{align:`stretch`,gap:`1rem`,children:[e.hasPassword?(0,I.jsxs)(j,{flexDirection:`column`,gap:`0.5rem`,children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`500`,color:`gray.600`,children:`Current Password`}),(0,I.jsx)(qt,{type:`password`,placeholder:`Enter current password...`,value:e.oldPassword,onChange:t=>e.setOldPassword(t.target.value),autoComplete:`current-password`})]}):(0,I.jsx)(k,{fontSize:`sm`,color:`gray.500`,children:`You signed in with a social account. Set a password to enable password login.`}),(0,I.jsxs)(j,{flexDirection:`column`,gap:`0.5rem`,children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`500`,color:`gray.600`,children:e.hasPassword?`New Password`:`Password`}),(0,I.jsx)(qt,{type:`password`,placeholder:`Enter new password (min 8 characters)...`,value:e.newPassword,onChange:t=>e.setNewPassword(t.target.value),autoComplete:`new-password`})]}),(0,I.jsxs)(j,{flexDirection:`column`,gap:`0.5rem`,children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`500`,color:`gray.600`,children:`Confirm Password`}),(0,I.jsx)(qt,{type:`password`,placeholder:`Confirm new password...`,value:e.confirmPassword,onChange:t=>e.setConfirmPassword(t.target.value),autoComplete:`new-password`})]}),e.passwordError&&(0,I.jsx)(k,{fontSize:`sm`,color:`red.500`,children:e.passwordError}),e.error&&(0,I.jsx)(k,{fontSize:`sm`,color:`red.500`,children:e.error}),(0,I.jsx)(j,{justifyContent:`flex-end`,children:(0,I.jsx)(N,{onClick:t,disabled:!e.canSavePassword,loading:e.isLoading,children:e.hasPassword?`Update Password`:`Set Password`})})]})}),(0,I.jsx)(bt,{value:`api-keys`,children:(0,I.jsxs)(M,{align:`stretch`,gap:`1rem`,children:[(0,I.jsxs)(A,{children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`500`,color:`gray.700`,children:`Personal Access Keys`}),(0,I.jsx)(k,{fontSize:`xs`,color:`gray.500`,mt:1,children:`Personal keys act on your behalf and inherit your permissions. Use them for scripts, CLI tools, or any programmatic access to your data.`})]}),(0,I.jsx)(kY,{model:e.apiKeyManager})]})})]})}),(0,I.jsx)(Ie,{})]})})]})})}),PY=class{updatePasswordRequest=X.of(Q.updatePassword);constructor(){f(this)}get isLoading(){return this.updatePasswordRequest.isLoading}get error(){return this.updatePasswordRequest.errorMessage??null}async updatePassword(e){return(await this.updatePasswordRequest.fetch({data:{oldPassword:e.oldPassword,newPassword:e.newPassword}})).isRight}dispose(){this.updatePasswordRequest.abort()}};Y.register(PY,()=>new PY,{scope:`request`});var FY=class{_isOpen=!1;_activeTab=`account`;apiKeyManager;oldPassword=``;newPassword=``;confirmPassword=``;constructor(e,t,n){this.dataSource=e,this.authService=t,f(this,{},{autoBind:!0}),this.apiKeyManager=n,this.apiKeyManager.configure({mode:`personal`})}get isOpen(){return this._isOpen}get activeTab(){return this._activeTab}get isLoading(){return this.dataSource.isLoading}get error(){return this.dataSource.error}get username(){return this.authService.user?.username}get email(){return this.authService.user?.email}get hasPassword(){return this.authService.user?.hasPassword??!0}get canSavePassword(){return!(this.isLoading||this.newPassword.length<8||this.newPassword!==this.confirmPassword||this.hasPassword&&!this.oldPassword)}get passwordError(){return this.newPassword&&this.newPassword.length<8?`Password must be at least 8 characters`:this.confirmPassword&&this.newPassword!==this.confirmPassword?`Passwords do not match`:null}open(){this._isOpen=!0,this._activeTab=`account`,this.resetPasswordForm()}close(){this._isOpen=!1,this.resetPasswordForm()}setActiveTab(e){this._activeTab=e}setOldPassword(e){this.oldPassword=e}setNewPassword(e){this.newPassword=e}setConfirmPassword(e){this.confirmPassword=e}async savePassword(){if(!this.canSavePassword)return!1;let e=await this.dataSource.updatePassword({oldPassword:this.oldPassword,newPassword:this.newPassword});return e&&(this.resetPasswordForm(),await this.authService.fetchMe()),e}logout(){this.close(),globalThis.location.href=`/${bJ}`}resetPasswordForm(){this.oldPassword=``,this.newPassword=``,this.confirmPassword=``}init(){}dispose(){this.dataSource.dispose(),this.apiKeyManager.dispose()}};Y.register(FY,()=>new FY(Y.get(PY),Y.get(hJ),Y.get(MY)),{scope:`singleton`});var IY=g(()=>{let e=CB(FY);return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(j,{alignItems:`center`,backgroundColor:`transparent`,_hover:{backgroundColor:`newGray.100`},borderRadius:`8px`,height:`36px`,paddingX:`8px`,width:`100%`,color:`newGray.600`,fontWeight:`400`,fontSize:`14px`,minWidth:`0`,cursor:`pointer`,gap:`12px`,userSelect:`none`,onClick:e.open,children:[(0,I.jsx)(A,{fontSize:`20px`,color:`newGray.400`,children:(0,I.jsx)(zf,{})}),(0,I.jsx)(A,{flex:`1`,minWidth:`0`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,overflow:`hidden`,children:`Account Settings`})]}),(0,I.jsx)(NY,{model:e})]})}),LY=({onBack:e})=>(0,I.jsx)(j,{className:`group`,flexDirection:`column`,alignItems:`flex-start`,width:`100%`,minWidth:`0`,children:(0,I.jsxs)(j,{alignItems:`center`,gap:`8px`,padding:`4px`,width:`100%`,children:[(0,I.jsx)(A,{fontSize:`20px`,color:`newGray.400`,cursor:`pointer`,_hover:{color:`newGray.500`},onClick:e,display:`flex`,alignItems:`center`,flexShrink:0,children:(0,I.jsx)(pf,{})}),(0,I.jsx)(A,{color:`black`,fontWeight:`600`,fontSize:`18px`,lineHeight:`26px`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,overflow:`hidden`,children:`Admin`}),(0,I.jsx)(T,{}),(0,I.jsx)(oJ,{})]})}),RY=({to:e,label:t,isActive:n,icon:r})=>(0,I.jsx)(An,{to:e,style:{textDecoration:`none`,width:`100%`},children:(0,I.jsxs)(j,{alignItems:`center`,backgroundColor:n?`newGray.100`:`transparent`,_hover:{backgroundColor:`newGray.100`},borderRadius:`8px`,height:`36px`,paddingX:`8px`,width:`100%`,color:n?`black`:`newGray.600`,fontWeight:`400`,textDecoration:`none`,fontSize:`14px`,minWidth:`0`,cursor:`pointer`,gap:`12px`,userSelect:`none`,children:[(0,I.jsx)(A,{fontSize:`20px`,color:`newGray.400`,children:r}),(0,I.jsx)(A,{flex:`1`,minWidth:`0`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,overflow:`hidden`,children:t})]})}),zY=g(()=>{let e=kn(),t=Tn(),n=e.pathname,r=n===`/${QJ}`,i=n.startsWith(`/${QJ}/${$J}`),a=n.startsWith(`/${QJ}/${tY}`),o=n.startsWith(`/${QJ}/${nY}`);return(0,I.jsxs)(M,{alignItems:`flex-start`,gap:0,width:`100%`,flex:1,children:[(0,I.jsx)(LY,{onBack:(0,L.useCallback)(()=>{t(`/`)},[t])}),(0,I.jsx)(A,{width:`100%`,paddingY:`16px`,children:(0,I.jsx)(O,{borderColor:`newGray.100`})}),(0,I.jsxs)(j,{flexDirection:`column`,width:`100%`,gap:1,children:[(0,I.jsx)(RY,{to:`/${QJ}`,label:`Dashboard`,icon:(0,I.jsx)(Xte,{}),isActive:r}),(0,I.jsx)(RY,{to:`/${QJ}/${$J}`,label:`Users`,icon:(0,I.jsx)(Bf,{}),isActive:i}),(0,I.jsx)(RY,{to:`/${QJ}/${tY}`,label:`Organizations`,icon:(0,I.jsx)(Pte,{}),isActive:a}),(0,I.jsx)(RY,{to:`/${QJ}/${nY}`,label:`Cache`,icon:(0,I.jsx)(yf,{}),isActive:o})]}),(0,I.jsx)(T,{}),(0,I.jsx)(j,{flexDirection:`column`,width:`100%`,gap:1,children:(0,I.jsx)(IY,{})})]})}),BY=()=>(0,I.jsx)(Vq,{sidebar:(0,I.jsx)(zY,{}),children:(0,I.jsx)(En,{})}),VY=({breadcrumbs:e,headerRight:t,children:n})=>(0,I.jsxs)(j,{flexDirection:`column`,height:`100%`,children:[(0,I.jsxs)(j,{alignItems:`center`,backgroundColor:`white`,justifyContent:`space-between`,width:`100%`,position:`sticky`,zIndex:1,top:0,padding:`8px`,children:[(0,I.jsx)(j,{alignItems:`center`,gap:`4px`,height:`40px`,children:(0,I.jsx)($t,{color:`gray`,fontWeight:`600`,fontSize:`16px`,children:(0,I.jsxs)(Gt,{fontSize:`16px`,children:[(0,I.jsx)(Dt,{children:(0,I.jsx)(it,{asChild:!0,color:`gray`,children:(0,I.jsx)(An,{to:`/${QJ}`,children:`Admin`})})}),e.map((e,t)=>(0,I.jsxs)(L.Fragment,{children:[(0,I.jsx)(ut,{children:`/`}),(0,I.jsx)(Dt,{children:e.to?(0,I.jsx)(it,{asChild:!0,color:`gray`,children:(0,I.jsx)(An,{to:e.to,children:e.label})}):(0,I.jsx)(Xt,{color:`gray`,children:e.label})})]},t))]})})}),t]}),(0,I.jsx)(A,{flex:1,children:n})]}),HY=()=>(0,I.jsx)(VY,{breadcrumbs:[{label:`Organizations`}],children:(0,I.jsx)(M,{flex:1,justifyContent:`center`,gap:`8px`,color:`gray.400`,paddingY:`48px`,children:(0,I.jsx)(k,{fontSize:`md`,children:`Coming soon`})})}),UY=class{request=X.of(Q.adminGetUser);resetPasswordRequest=X.of(Q.adminResetPassword);_userId=null;_user=null;_newPassword=``;_resetPasswordSuccess=!1;constructor(){f(this,{},{autoBind:!0})}get isLoading(){return this.request.isLoading}get error(){return this.request.errorMessage??null}get user(){return this._user}get username(){return this._user?.username??null}get email(){return this._user?.email??null}get roleName(){return this._user?.role?.name??null}get newPassword(){return this._newPassword}get isResetPasswordLoading(){return this.resetPasswordRequest.isLoading}get resetPasswordError(){return this.resetPasswordRequest.errorMessage??null}get resetPasswordSuccess(){return this._resetPasswordSuccess}get canResetPassword(){return this._newPassword.length>=6}setUserId(e){this._userId=e,this.loadUser()}setNewPassword(e){this._newPassword=e,this._resetPasswordSuccess=!1}async resetPassword(){!this._userId||!this.canResetPassword||(await this.resetPasswordRequest.fetch({userId:this._userId,newPassword:this._newPassword})).isRight&&c(()=>{this._newPassword=``,this._resetPasswordSuccess=!0})}init(){this._userId&&this.loadUser()}dispose(){this.request.abort(),this.resetPasswordRequest.abort()}async loadUser(){if(!this._userId)return;let e=await this.request.fetch({userId:this._userId});e.isRight&&c(()=>{this._user=e.data.adminUser??null})}};Y.register(UY,()=>new UY,{scope:`request`});var WY=({label:e,value:t})=>(0,I.jsxs)(j,{gap:`16px`,alignItems:`baseline`,children:[(0,I.jsx)(k,{fontSize:`xs`,color:`newGray.400`,minWidth:`80px`,children:e}),(0,I.jsx)(k,{fontSize:`sm`,color:`newGray.600`,children:t||`-`})]}),GY=g(({model:e})=>(0,I.jsxs)(A,{padding:`16px`,borderWidth:`1px`,borderColor:`newGray.100`,borderRadius:`md`,marginTop:`16px`,children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`500`,color:`newGray.500`,marginBottom:`12px`,children:`Reset Password`}),(0,I.jsxs)(j,{gap:`12px`,alignItems:`flex-start`,children:[(0,I.jsx)(qt,{placeholder:`New password (min 6 characters)`,type:`password`,size:`sm`,value:e.newPassword,onChange:t=>e.setNewPassword(t.target.value),maxWidth:`300px`}),(0,I.jsx)(N,{size:`sm`,colorPalette:`gray`,onClick:e.resetPassword,disabled:!e.canResetPassword,loading:e.isResetPasswordLoading,children:`Reset`})]}),e.resetPasswordError&&(0,I.jsx)(k,{fontSize:`sm`,color:`red.500`,marginTop:`8px`,children:e.resetPasswordError}),e.resetPasswordSuccess&&(0,I.jsx)(k,{fontSize:`sm`,color:`green.500`,marginTop:`8px`,children:`Password has been reset successfully`})]})),KY=g(()=>{let{userId:e}=bn(),t=CB(UY);return(0,L.useEffect)(()=>{e&&t.setUserId(e)},[e,t]),(0,I.jsx)(VY,{breadcrumbs:(0,L.useMemo)(()=>[{label:`Users`,to:`/${QJ}/${$J}`},{label:t.username||e||``}],[t.username,e]),children:(0,I.jsxs)(A,{flex:1,padding:`8px`,children:[t.isLoading&&(0,I.jsx)(M,{flex:1,justifyContent:`center`,paddingY:`48px`,children:(0,I.jsx)(Ht,{size:`md`,color:`gray.400`})}),t.error&&(0,I.jsxs)(M,{flex:1,justifyContent:`center`,gap:`8px`,color:`gray.400`,paddingY:`48px`,children:[(0,I.jsx)(k,{fontSize:`md`,children:`Could not load user`}),(0,I.jsx)(k,{fontSize:`sm`,children:t.error})]}),!t.isLoading&&!t.error&&!t.user&&(0,I.jsx)(M,{flex:1,justifyContent:`center`,gap:`8px`,color:`gray.400`,paddingY:`48px`,children:(0,I.jsx)(k,{fontSize:`md`,children:`User not found`})}),t.user&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(A,{padding:`16px`,borderWidth:`1px`,borderColor:`newGray.100`,borderRadius:`md`,children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`500`,color:`newGray.500`,marginBottom:`12px`,children:`User Info`}),(0,I.jsxs)(M,{alignItems:`flex-start`,gap:`8px`,children:[(0,I.jsx)(WY,{label:`ID`,value:t.user.id}),(0,I.jsx)(WY,{label:`Username`,value:t.username}),(0,I.jsx)(WY,{label:`Email`,value:t.email}),(0,I.jsx)(WY,{label:`Role`,value:t.roleName})]})]}),(0,I.jsx)(GY,{model:t})]})]})})}),qY=class{request=X.of(Q.createUser);constructor(){f(this)}get isLoading(){return this.request.isLoading}get error(){return this.request.errorMessage??null}async create(e){let t=await this.request.fetch({username:e.username,password:e.password,email:e.email,roleId:e.roleId});return t.isRight&&t.data.createUser}dispose(){this.request.abort()}};Y.register(qY,()=>new qY,{scope:`request`});var JY=class{_isOpen=!1;_username=``;_password=``;_email=``;_selectedRole=XW.SystemUser;constructor(e,t,n){this.dataSource=e,this.systemPermissions=t,this.onUserCreated=n,f(this,{},{autoBind:!0})}get isOpen(){return this._isOpen}get canCreateUser(){return this.systemPermissions.canCreateUser}get username(){return this._username}get password(){return this._password}get email(){return this._email}get selectedRole(){return this._selectedRole}get isCreating(){return this.dataSource.isLoading}get canSubmit(){return this._username.trim().length>0&&this._password.length>=6&&!this.isCreating}open(){this._isOpen=!0,this.reset()}close(){this._isOpen=!1,this.reset()}setUsername(e){this._username=e}setPassword(e){this._password=e}setEmail(e){this._email=e}setSelectedRole(e){this._selectedRole=e}async createUser(){if(!this.canSubmit)return;let e=await this.dataSource.create({username:this._username.trim(),password:this._password,email:this._email.trim()||void 0,roleId:this._selectedRole});c(()=>{e&&(this.onUserCreated(),this.close())})}dispose(){this.dataSource.dispose()}reset(){this._username=``,this._password=``,this._email=``,this._selectedRole=XW.SystemUser}},YY=class extends rH{currentFilters={};constructor(){super(Q.adminUsers,{pageSize:50})}extractItems(e){return e.adminUsers.edges.map(e=>e.node)}extractPageInfo(e){return{hasNextPage:e.adminUsers.pageInfo.hasNextPage,endCursor:e.adminUsers.pageInfo.endCursor||null,totalCount:e.adminUsers.totalCount}}buildFetchArgs(e,t){return e&&(this.currentFilters=e),{first:this.config.pageSize,after:t,search:this.currentFilters.search||void 0}}};Y.register(YY,()=>new YY,{scope:`request`});var XY=class{constructor(e){this.data=e,f(this)}get id(){return this.data.id}get username(){return this.data.username??null}get email(){return this.data.email??null}get roleName(){return this.data.role?.name??null}get link(){return Dn(`/${QJ}/${$J}/:userId`,{userId:this.data.id})}},ZY=class extends nH{createUserModal;_searchQuery=``;_debounceTimer=null;constructor(e,t,n){super(e),this.createUserModal=new JY(t,n,()=>this.reload()),h(this,{_searchQuery:u,searchQuery:a,canCreateUser:a,setSearchQuery:m,reload:m,init:_,dispose:_})}getItemKey(e){return e.id}createItemViewModel(e){return new XY(e)}get canCreateUser(){return this.createUserModal.canCreateUser}get searchQuery(){return this._searchQuery}init(){this.dataSource.load()}dispose(){this._debounceTimer&&clearTimeout(this._debounceTimer),super.dispose(),this.createUserModal.dispose()}reload(){this.dataSource.load({search:this._searchQuery||void 0})}setSearchQuery(e){this._searchQuery=e,this._debounceTimer&&clearTimeout(this._debounceTimer),this._debounceTimer=setTimeout(()=>{this.dataSource.load({search:e||void 0})},300)}};Y.register(ZY,()=>new ZY(Y.get(YY),Y.get(qY),Y.get(yW)),{scope:`request`});var QY={[XW.SystemAdmin]:`System Admin`,[XW.SystemFullApiRead]:`Full API Read`,[XW.SystemUser]:`User`},$Y=g(({value:e,onChange:t,disabled:n})=>(0,I.jsx)(Qe,{size:`sm`,width:`160px`,...n&&{opacity:.5,pointerEvents:`none`},children:(0,I.jsx)(Xe,{value:e,onChange:e=>t(e.target.value),children:Object.values(XW).map(e=>(0,I.jsx)(`option`,{value:e,children:QY[e]},e))})})),eX=g(({model:e})=>(0,I.jsx)(Ue,{open:e.isOpen,onOpenChange:({open:t})=>!t&&e.close(),size:`md`,children:(0,I.jsxs)(R,{children:[(0,I.jsx)(pe,{}),(0,I.jsx)(ue,{children:(0,I.jsxs)(_n,{children:[(0,I.jsx)(Ge,{children:(0,I.jsx)(qe,{children:`Create User`})}),(0,I.jsx)(be,{children:(0,I.jsxs)(M,{align:`stretch`,gap:`1rem`,children:[(0,I.jsxs)(j,{flexDirection:`column`,gap:`0.5rem`,children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`500`,color:`gray.600`,children:`Username *`}),(0,I.jsx)(qt,{placeholder:`Enter username...`,value:e.username,onChange:t=>e.setUsername(t.target.value),autoComplete:`off`})]}),(0,I.jsxs)(j,{flexDirection:`column`,gap:`0.5rem`,children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`500`,color:`gray.600`,children:`Password *`}),(0,I.jsx)(qt,{type:`password`,placeholder:`Enter password (min 6 characters)...`,value:e.password,onChange:t=>e.setPassword(t.target.value),autoComplete:`new-password`})]}),(0,I.jsxs)(j,{flexDirection:`column`,gap:`0.5rem`,children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`500`,color:`gray.600`,children:`Email (optional)`}),(0,I.jsx)(qt,{type:`email`,placeholder:`Enter email...`,value:e.email,onChange:t=>e.setEmail(t.target.value),autoComplete:`off`})]}),(0,I.jsxs)(j,{flexDirection:`column`,gap:`0.5rem`,children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`500`,color:`gray.600`,children:`System Role`}),(0,I.jsx)($Y,{value:e.selectedRole,onChange:t=>e.setSelectedRole(t)})]})]})}),(0,I.jsxs)(w,{children:[(0,I.jsx)(N,{variant:`outline`,onClick:e.close,children:`Cancel`}),(0,I.jsx)(N,{onClick:e.createUser,disabled:!e.canSubmit,loading:e.isCreating,children:`Create`})]}),(0,I.jsx)(Ie,{})]})})]})})),tX=g(({model:e})=>(0,I.jsx)(A,{height:`2.5rem`,width:`100%`,children:(0,I.jsx)(An,{to:e.link,style:{textDecoration:`none`,width:`100%`},children:(0,I.jsxs)(j,{_hover:{backgroundColor:`gray.50`},alignItems:`center`,gap:`4px`,paddingLeft:`1rem`,height:`100%`,children:[(0,I.jsx)(j,{width:`200px`,children:(0,I.jsx)(k,{maxWidth:`190px`,textDecoration:`underline`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,overflow:`hidden`,children:e.username||e.email||`No username`})}),(0,I.jsx)(j,{alignItems:`center`,flex:1,minHeight:`40px`,children:(0,I.jsx)(k,{color:`gray.400`,fontWeight:`300`,ml:`16px`,children:e.roleName||`-`})})]})})})),nX=g(()=>{let e=CB(ZY);return(0,I.jsxs)(VY,{breadcrumbs:[{label:`Users`}],headerRight:(0,I.jsx)(j,{alignItems:`center`,gap:`8px`,children:(0,I.jsx)(qt,{placeholder:`Search...`,value:e.searchQuery,onChange:t=>e.setSearchQuery(t.target.value),variant:`flushed`,size:`sm`,width:`200px`,_placeholder:{color:`gray.400`}})}),children:[(0,I.jsxs)(A,{flex:1,paddingX:`16px`,paddingTop:`16px`,children:[e.canCreateUser&&(0,I.jsx)(j,{paddingBottom:`16px`,children:(0,I.jsxs)(N,{variant:`ghost`,size:`sm`,color:`gray`,onClick:()=>e.createUserModal.open(),children:[(0,I.jsx)(Pf,{}),`Add`]})}),e.showLoading&&(0,I.jsx)(M,{flex:1,justifyContent:`center`,children:(0,I.jsx)(Ht,{size:`md`,color:`gray.400`})}),e.showError&&(0,I.jsxs)(M,{flex:1,justifyContent:`center`,gap:`8px`,color:`gray.400`,children:[(0,I.jsx)(k,{fontSize:`md`,children:`Could not load users`}),(0,I.jsx)(k,{fontSize:`sm`,children:`Please retry later`})]}),e.showEmpty&&(0,I.jsxs)(M,{flex:1,justifyContent:`center`,gap:`8px`,color:`gray.400`,children:[(0,I.jsx)(Bf,{size:48}),(0,I.jsx)(k,{fontSize:`md`,children:`No users found`})]}),e.showList&&(0,I.jsx)(QM,{useWindowScroll:!0,totalCount:e.items.length,defaultItemHeight:40,endReached:e.hasNextPage?e.tryToFetchNextPage:void 0,itemContent:t=>{let n=e.items[t];return n?(0,I.jsx)(tX,{model:n},n.id):null}})]}),(0,I.jsx)(eX,{model:e.createUserModal})]})}),rX=i((e=>{e.removeLeadingAndTrailingHTTPWhitespace=e=>e.replace(/^[ \t\n\r]+/u,``).replace(/[ \t\n\r]+$/u,``),e.removeTrailingHTTPWhitespace=e=>e.replace(/[ \t\n\r]+$/u,``),e.isHTTPWhitespaceChar=e=>e===` `||e===` `||e===`
2167
2167
  `||e===`\r`,e.solelyContainsHTTPTokenCodePoints=e=>/^[-!#$%&'*+.^_`|~A-Za-z0-9]*$/u.test(e),e.soleyContainsHTTPQuotedStringTokenCodePoints=e=>/^[\t\u0020-\u007E\u0080-\u00FF]*$/u.test(e),e.asciiLowercase=e=>e.replace(/[A-Z]/gu,e=>e.toLowerCase()),e.collectAnHTTPQuotedString=(e,t)=>{let n=``;for(t++;;){for(;t<e.length&&e[t]!==`"`&&e[t]!==`\\`;)n+=e[t],++t;if(t>=e.length)break;let r=e[t];if(++t,r===`\\`){if(t>=e.length){n+=`\\`;break}n+=e[t],++t}else break}return[n,t]}})),iX=i(((e,t)=>{var{asciiLowercase:n,solelyContainsHTTPTokenCodePoints:r,soleyContainsHTTPQuotedStringTokenCodePoints:i}=rX();t.exports=class{constructor(e){this._map=e}get size(){return this._map.size}get(e){return e=n(String(e)),this._map.get(e)}has(e){return e=n(String(e)),this._map.has(e)}set(e,t){if(e=n(String(e)),t=String(t),!r(e))throw Error(`Invalid MIME type parameter name "${e}": only HTTP token code points are valid.`);if(!i(t))throw Error(`Invalid MIME type parameter value "${t}": only HTTP quoted-string token code points are valid.`);return this._map.set(e,t)}clear(){this._map.clear()}delete(e){return e=n(String(e)),this._map.delete(e)}forEach(e,t){this._map.forEach(e,t)}keys(){return this._map.keys()}values(){return this._map.values()}entries(){return this._map.entries()}[Symbol.iterator](){return this._map[Symbol.iterator]()}}})),aX=i(((e,t)=>{var{removeLeadingAndTrailingHTTPWhitespace:n,removeTrailingHTTPWhitespace:r,isHTTPWhitespaceChar:i,solelyContainsHTTPTokenCodePoints:a,soleyContainsHTTPQuotedStringTokenCodePoints:o,asciiLowercase:s,collectAnHTTPQuotedString:c}=rX();t.exports=e=>{e=n(e);let t=0,l=``;for(;t<e.length&&e[t]!==`/`;)l+=e[t],++t;if(l.length===0||!a(l)||t>=e.length)return null;++t;let u=``;for(;t<e.length&&e[t]!==`;`;)u+=e[t],++t;if(u=r(u),u.length===0||!a(u))return null;let d={type:s(l),subtype:s(u),parameters:new Map};for(;t<e.length;){for(++t;i(e[t]);)++t;let n=``;for(;t<e.length&&e[t]!==`;`&&e[t]!==`=`;)n+=e[t],++t;if(n=s(n),t<e.length){if(e[t]===`;`)continue;++t}let l=null;if(e[t]===`"`)for([l,t]=c(e,t);t<e.length&&e[t]!==`;`;)++t;else{for(l=``;t<e.length&&e[t]!==`;`;)l+=e[t],++t;if(l=r(l),l===``)continue}n.length>0&&a(n)&&o(l)&&!d.parameters.has(n)&&d.parameters.set(n,l)}return d}})),oX=i(((e,t)=>{var{solelyContainsHTTPTokenCodePoints:n}=rX();t.exports=e=>{let t=`${e.type}/${e.subtype}`;if(e.parameters.size===0)return t;for(let[r,i]of e.parameters)t+=`;`,t+=r,t+=`=`,(!n(i)||i.length===0)&&(i=i.replace(/(["\\])/gu,`\\$1`),i=`"${i}"`),t+=i;return t}})),sX=e(i(((e,t)=>{var n=iX(),r=aX(),i=oX(),{asciiLowercase:a,solelyContainsHTTPTokenCodePoints:o}=rX();t.exports=class{constructor(e){e=String(e);let t=r(e);if(t===null)throw Error(`Could not parse MIME type string "${e}"`);this._type=t.type,this._subtype=t.subtype,this._parameters=new n(t.parameters)}static parse(e){try{return new this(e)}catch{return null}}get essence(){return`${this.type}/${this.subtype}`}get type(){return this._type}set type(e){if(e=a(String(e)),e.length===0)throw Error(`Invalid type: must be a non-empty string`);if(!o(e))throw Error(`Invalid type ${e}: must contain only HTTP token code points`);this._type=e}get subtype(){return this._subtype}set subtype(e){if(e=a(String(e)),e.length===0)throw Error(`Invalid subtype: must be a non-empty string`);if(!o(e))throw Error(`Invalid subtype ${e}: must contain only HTTP token code points`);this._subtype=e}get parameters(){return this._parameters}toString(){return i(this)}isJavaScript({prohibitParameters:e=!1}={}){switch(this._type){case`text`:switch(this._subtype){case`ecmascript`:case`javascript`:case`javascript1.0`:case`javascript1.1`:case`javascript1.2`:case`javascript1.3`:case`javascript1.4`:case`javascript1.5`:case`jscript`:case`livescript`:case`x-ecmascript`:case`x-javascript`:return!e||this._parameters.size===0;default:return!1}case`application`:switch(this._subtype){case`ecmascript`:case`javascript`:case`x-ecmascript`:case`x-javascript`:return!e||this._parameters.size===0;default:return!1}default:return!1}}isXML(){return this._subtype===`xml`&&(this._type===`text`||this._type===`application`)||this._subtype.endsWith(`+xml`)}isHTML(){return this._subtype===`html`&&this._type===`text`}}}))(),1);function cX(e,t){var n=typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=lX(e))||t&&e&&typeof e.length==`number`){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw TypeError(`Invalid attempt to iterate non-iterable instance.
2168
2168
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function lX(e,t){if(e){if(typeof e==`string`)return uX(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`)return Array.from(e);if(n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return uX(e,t)}}function uX(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function dX(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function fX(e,t,n){return t&&dX(e.prototype,t),n&&dX(e,n),e}var pX=function(){return typeof Symbol==`function`},mX=function(e){return pX()&&!!Symbol[e]},hX=function(e){return mX(e)?Symbol[e]:`@@`+e};pX()&&!mX(`observable`)&&(Symbol.observable=Symbol(`observable`));var gX=hX(`iterator`),_X=hX(`observable`),vX=hX(`species`);function yX(e,t){var n=e[t];if(n!=null){if(typeof n!=`function`)throw TypeError(n+` is not a function`);return n}}function bX(e){var t=e.constructor;return t!==void 0&&(t=t[vX],t===null&&(t=void 0)),t===void 0?jX:t}function xX(e){return e instanceof jX}function SX(e){SX.log?SX.log(e):setTimeout(function(){throw e})}function CX(e){Promise.resolve().then(function(){try{e()}catch(e){SX(e)}})}function wX(e){var t=e._cleanup;if(t!==void 0&&(e._cleanup=void 0,t))try{if(typeof t==`function`)t();else{var n=yX(t,`unsubscribe`);n&&n.call(t)}}catch(e){SX(e)}}function TX(e){e._observer=void 0,e._queue=void 0,e._state=`closed`}function EX(e){var t=e._queue;if(t){e._queue=void 0,e._state=`ready`;for(var n=0;n<t.length&&(DX(e,t[n].type,t[n].value),e._state!==`closed`);++n);}}function DX(e,t,n){e._state=`running`;var r=e._observer;try{var i=yX(r,t);switch(t){case`next`:i&&i.call(r,n);break;case`error`:if(TX(e),i)i.call(r,n);else throw n;break;case`complete`:TX(e),i&&i.call(r);break}}catch(e){SX(e)}e._state===`closed`?wX(e):e._state===`running`&&(e._state=`ready`)}function OX(e,t,n){if(e._state!==`closed`){if(e._state===`buffering`){e._queue.push({type:t,value:n});return}if(e._state!==`ready`){e._state=`buffering`,e._queue=[{type:t,value:n}],CX(function(){return EX(e)});return}DX(e,t,n)}}var kX=function(){function e(e,t){this._cleanup=void 0,this._observer=e,this._queue=void 0,this._state=`initializing`;var n=new AX(this);try{this._cleanup=t.call(void 0,n)}catch(e){n.error(e)}this._state===`initializing`&&(this._state=`ready`)}var t=e.prototype;return t.unsubscribe=function(){this._state!==`closed`&&(TX(this),wX(this))},fX(e,[{key:`closed`,get:function(){return this._state===`closed`}}]),e}(),AX=function(){function e(e){this._subscription=e}var t=e.prototype;return t.next=function(e){OX(this._subscription,`next`,e)},t.error=function(e){OX(this._subscription,`error`,e)},t.complete=function(){OX(this._subscription,`complete`)},fX(e,[{key:`closed`,get:function(){return this._subscription._state===`closed`}}]),e}(),jX=function(){function e(t){if(!(this instanceof e))throw TypeError(`Observable cannot be called as a function`);if(typeof t!=`function`)throw TypeError(`Observable initializer must be a function`);this._subscriber=t}var t=e.prototype;return t.subscribe=function(e){return(typeof e!=`object`||!e)&&(e={next:e,error:arguments[1],complete:arguments[2]}),new kX(e,this._subscriber)},t.forEach=function(e){var t=this;return new Promise(function(n,r){if(typeof e!=`function`){r(TypeError(e+` is not a function`));return}function i(){a.unsubscribe(),n()}var a=t.subscribe({next:function(t){try{e(t,i)}catch(e){r(e),a.unsubscribe()}},error:r,complete:n})})},t.map=function(e){var t=this;if(typeof e!=`function`)throw TypeError(e+` is not a function`);return new(bX(this))(function(n){return t.subscribe({next:function(t){try{t=e(t)}catch(e){return n.error(e)}n.next(t)},error:function(e){n.error(e)},complete:function(){n.complete()}})})},t.filter=function(e){var t=this;if(typeof e!=`function`)throw TypeError(e+` is not a function`);return new(bX(this))(function(n){return t.subscribe({next:function(t){try{if(!e(t))return}catch(e){return n.error(e)}n.next(t)},error:function(e){n.error(e)},complete:function(){n.complete()}})})},t.reduce=function(e){var t=this;if(typeof e!=`function`)throw TypeError(e+` is not a function`);var n=bX(this),r=arguments.length>1,i=!1,a=arguments[1];return new n(function(n){return t.subscribe({next:function(t){var o=!i;if(i=!0,!o||r)try{a=e(a,t)}catch(e){return n.error(e)}else a=t},error:function(e){n.error(e)},complete:function(){if(!i&&!r)return n.error(TypeError(`Cannot reduce an empty sequence`));n.next(a),n.complete()}})})},t.concat=function(){var e=this,t=[...arguments],n=bX(this);return new n(function(r){var i,a=0;function o(e){i=e.subscribe({next:function(e){r.next(e)},error:function(e){r.error(e)},complete:function(){a===t.length?(i=void 0,r.complete()):o(n.from(t[a++]))}})}return o(e),function(){i&&=(i.unsubscribe(),void 0)}})},t.flatMap=function(e){var t=this;if(typeof e!=`function`)throw TypeError(e+` is not a function`);var n=bX(this);return new n(function(r){var i=[],a=t.subscribe({next:function(t){if(e)try{t=e(t)}catch(e){return r.error(e)}var a=n.from(t).subscribe({next:function(e){r.next(e)},error:function(e){r.error(e)},complete:function(){var e=i.indexOf(a);e>=0&&i.splice(e,1),o()}});i.push(a)},error:function(e){r.error(e)},complete:function(){o()}});function o(){a.closed&&i.length===0&&r.complete()}return function(){i.forEach(function(e){return e.unsubscribe()}),a.unsubscribe()}})},t[_X]=function(){return this},e.from=function(t){var n=typeof this==`function`?this:e;if(t==null)throw TypeError(t+` is not an object`);var r=yX(t,_X);if(r){var i=r.call(t);if(Object(i)!==i)throw TypeError(i+` is not an object`);return xX(i)&&i.constructor===n?i:new n(function(e){return i.subscribe(e)})}if(mX(`iterator`)&&(r=yX(t,gX),r))return new n(function(e){CX(function(){if(!e.closed){for(var n=cX(r.call(t)),i;!(i=n()).done;){var a=i.value;if(e.next(a),e.closed)return}e.complete()}})});if(Array.isArray(t))return new n(function(e){CX(function(){if(!e.closed){for(var n=0;n<t.length;++n)if(e.next(t[n]),e.closed)return;e.complete()}})});throw TypeError(t+` is not observable`)},e.of=function(){var t=[...arguments];return new(typeof this==`function`?this:e)(function(e){CX(function(){if(!e.closed){for(var n=0;n<t.length;++n)if(e.next(t[n]),e.closed)return;e.complete()}})})},fX(e,null,[{key:vX,get:function(){return this}}]),e}();pX()&&Object.defineProperty(jX,Symbol(`extensions`),{value:{symbol:_X,hostReportError:SX},configurable:!0});var MX=i(((e,t)=>{var n=Object.prototype.hasOwnProperty,r=`~`;function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(r=!1));function a(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function o(e,t,n,i,o){if(typeof n!=`function`)throw TypeError(`The listener must be a function`);var s=new a(n,i||e,o),c=r?r+t:t;return e._events[c]?e._events[c].fn?e._events[c]=[e._events[c],s]:e._events[c].push(s):(e._events[c]=s,e._eventsCount++),e}function s(e,t){--e._eventsCount===0?e._events=new i:delete e._events[t]}function c(){this._events=new i,this._eventsCount=0}c.prototype.eventNames=function(){var e=[],t,i;if(this._eventsCount===0)return e;for(i in t=this._events)n.call(t,i)&&e.push(r?i.slice(1):i);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(t)):e},c.prototype.listeners=function(e){var t=r?r+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var i=0,a=n.length,o=Array(a);i<a;i++)o[i]=n[i].fn;return o},c.prototype.listenerCount=function(e){var t=r?r+e:e,n=this._events[t];return n?n.fn?1:n.length:0},c.prototype.emit=function(e,t,n,i,a,o){var s=r?r+e:e;if(!this._events[s])return!1;var c=this._events[s],l=arguments.length,u,d;if(c.fn){switch(c.once&&this.removeListener(e,c.fn,void 0,!0),l){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,t),!0;case 3:return c.fn.call(c.context,t,n),!0;case 4:return c.fn.call(c.context,t,n,i),!0;case 5:return c.fn.call(c.context,t,n,i,a),!0;case 6:return c.fn.call(c.context,t,n,i,a,o),!0}for(d=1,u=Array(l-1);d<l;d++)u[d-1]=arguments[d];c.fn.apply(c.context,u)}else{var f=c.length,p;for(d=0;d<f;d++)switch(c[d].once&&this.removeListener(e,c[d].fn,void 0,!0),l){case 1:c[d].fn.call(c[d].context);break;case 2:c[d].fn.call(c[d].context,t);break;case 3:c[d].fn.call(c[d].context,t,n);break;case 4:c[d].fn.call(c[d].context,t,n,i);break;default:if(!u)for(p=1,u=Array(l-1);p<l;p++)u[p-1]=arguments[p];c[d].fn.apply(c[d].context,u)}}return!0},c.prototype.on=function(e,t,n){return o(this,e,t,n,!1)},c.prototype.once=function(e,t,n){return o(this,e,t,n,!0)},c.prototype.removeListener=function(e,t,n,i){var a=r?r+e:e;if(!this._events[a])return this;if(!t)return s(this,a),this;var o=this._events[a];if(o.fn)o.fn===t&&(!i||o.once)&&(!n||o.context===n)&&s(this,a);else{for(var c=0,l=[],u=o.length;c<u;c++)(o[c].fn!==t||i&&!o[c].once||n&&o[c].context!==n)&&l.push(o[c]);l.length?this._events[a]=l.length===1?l[0]:l:s(this,a)}return this},c.prototype.removeAllListeners=function(e){var t;return e?(t=r?r+e:e,this._events[t]&&s(this,t)):(this._events=new i,this._eventsCount=0),this},c.prototype.off=c.prototype.removeListener,c.prototype.addListener=c.prototype.on,c.prefixed=r,c.EventEmitter=c,t!==void 0&&(t.exports=c)}));function NX(e){return e===null?`null`:Array.isArray(e)?`array`:typeof e}function PX(e){return NX(e)===`object`}function FX(e){return Array.isArray(e)&&e.length>0&&e.every(e=>`message`in e)}function IX(e,t){return e.length<124?e:t}var LX=`graphql-transport-ws`,RX;(function(e){e[e.InternalServerError=4500]=`InternalServerError`,e[e.InternalClientError=4005]=`InternalClientError`,e[e.BadRequest=4400]=`BadRequest`,e[e.BadResponse=4004]=`BadResponse`,e[e.Unauthorized=4401]=`Unauthorized`,e[e.Forbidden=4403]=`Forbidden`,e[e.SubprotocolNotAcceptable=4406]=`SubprotocolNotAcceptable`,e[e.ConnectionInitialisationTimeout=4408]=`ConnectionInitialisationTimeout`,e[e.ConnectionAcknowledgementTimeout=4504]=`ConnectionAcknowledgementTimeout`,e[e.SubscriberAlreadyExists=4409]=`SubscriberAlreadyExists`,e[e.TooManyInitialisationRequests=4429]=`TooManyInitialisationRequests`})(RX||={});var zX;(function(e){e.ConnectionInit=`connection_init`,e.ConnectionAck=`connection_ack`,e.Ping=`ping`,e.Pong=`pong`,e.Subscribe=`subscribe`,e.Next=`next`,e.Error=`error`,e.Complete=`complete`})(zX||={});function BX(e){if(!PX(e))throw Error(`Message is expected to be an object, but got ${NX(e)}`);if(!e.type)throw Error(`Message is missing the 'type' property`);if(typeof e.type!=`string`)throw Error(`Message is expects the 'type' property to be a string, but got ${NX(e.type)}`);switch(e.type){case zX.ConnectionInit:case zX.ConnectionAck:case zX.Ping:case zX.Pong:if(e.payload!=null&&!PX(e.payload))throw Error(`"${e.type}" message expects the 'payload' property to be an object or nullish or missing, but got "${e.payload}"`);break;case zX.Subscribe:if(typeof e.id!=`string`)throw Error(`"${e.type}" message expects the 'id' property to be a string, but got ${NX(e.id)}`);if(!e.id)throw Error(`"${e.type}" message requires a non-empty 'id' property`);if(!PX(e.payload))throw Error(`"${e.type}" message expects the 'payload' property to be an object, but got ${NX(e.payload)}`);if(typeof e.payload.query!=`string`)throw Error(`"${e.type}" message payload expects the 'query' property to be a string, but got ${NX(e.payload.query)}`);if(e.payload.variables!=null&&!PX(e.payload.variables))throw Error(`"${e.type}" message payload expects the 'variables' property to be a an object or nullish or missing, but got ${NX(e.payload.variables)}`);if(e.payload.operationName!=null&&NX(e.payload.operationName)!==`string`)throw Error(`"${e.type}" message payload expects the 'operationName' property to be a string or nullish or missing, but got ${NX(e.payload.operationName)}`);if(e.payload.extensions!=null&&!PX(e.payload.extensions))throw Error(`"${e.type}" message payload expects the 'extensions' property to be a an object or nullish or missing, but got ${NX(e.payload.extensions)}`);break;case zX.Next:if(typeof e.id!=`string`)throw Error(`"${e.type}" message expects the 'id' property to be a string, but got ${NX(e.id)}`);if(!e.id)throw Error(`"${e.type}" message requires a non-empty 'id' property`);if(!PX(e.payload))throw Error(`"${e.type}" message expects the 'payload' property to be an object, but got ${NX(e.payload)}`);break;case zX.Error:if(typeof e.id!=`string`)throw Error(`"${e.type}" message expects the 'id' property to be a string, but got ${NX(e.id)}`);if(!e.id)throw Error(`"${e.type}" message requires a non-empty 'id' property`);if(!FX(e.payload))throw Error(`"${e.type}" message expects the 'payload' property to be an array of GraphQL errors, but got ${JSON.stringify(e.payload)}`);break;case zX.Complete:if(typeof e.id!=`string`)throw Error(`"${e.type}" message expects the 'id' property to be a string, but got ${NX(e.id)}`);if(!e.id)throw Error(`"${e.type}" message requires a non-empty 'id' property`);break;default:throw Error(`Invalid message 'type' property "${e.type}"`)}return e}function VX(e,t){return BX(typeof e==`string`?JSON.parse(e,t):e)}function HX(e,t){return BX(e),JSON.stringify(e,t)}var UX=function(e){return this instanceof UX?(this.v=e,this):new UX(e)},WX=function(e,t,n){if(!Symbol.asyncIterator)throw TypeError(`Symbol.asyncIterator is not defined.`);var r=n.apply(e,t||[]),i,a=[];return i=Object.create((typeof AsyncIterator==`function`?AsyncIterator:Object).prototype),s(`next`),s(`throw`),s(`return`,o),i[Symbol.asyncIterator]=function(){return this},i;function o(e){return function(t){return Promise.resolve(t).then(e,d)}}function s(e,t){r[e]&&(i[e]=function(t){return new Promise(function(n,r){a.push([e,t,n,r])>1||c(e,t)})},t&&(i[e]=t(i[e])))}function c(e,t){try{l(r[e](t))}catch(e){f(a[0][3],e)}}function l(e){e.value instanceof UX?Promise.resolve(e.value.v).then(u,d):f(a[0][2],e)}function u(e){c(`next`,e)}function d(e){c(`throw`,e)}function f(e,t){e(t),a.shift(),a.length&&c(a[0][0],a[0][1])}};function GX(e){let{url:t,connectionParams:n,lazy:r=!0,onNonLazyError:i=console.error,lazyCloseTimeout:a=0,keepAlive:o=0,disablePong:s,connectionAckWaitTimeout:c=0,retryAttempts:l=5,retryWait:u=async function(e){let t=1e3;for(let n=0;n<e;n++)t*=2;await new Promise(e=>setTimeout(e,t+Math.floor(Math.random()*2700+300)))},shouldRetry:d=qX,isFatalConnectionProblem:f,on:p,webSocketImpl:m,generateID:h=function(){return`xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx`.replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==`x`?t:t&3|8).toString(16)})},jsonMessageReplacer:g,jsonMessageReviver:_}=e,v;if(m){if(!YX(m))throw Error(`Invalid WebSocket implementation provided`);v=m}else typeof WebSocket<`u`?v=WebSocket:typeof global<`u`?v=global.WebSocket||global.MozWebSocket:typeof window<`u`&&(v=window.WebSocket||window.MozWebSocket);if(!v)throw Error("WebSocket implementation missing; on Node you can `import WebSocket from 'ws';` and pass `webSocketImpl: WebSocket` to `createClient`");let y=v,b=(()=>{let e=(()=>{let e={};return{on(t,n){return e[t]=n,()=>{delete e[t]}},emit(t){var n;`id`in t&&((n=e[t.id])==null||n.call(e,t))}}})(),t={connecting:p?.connecting?[p.connecting]:[],opened:p?.opened?[p.opened]:[],connected:p?.connected?[p.connected]:[],ping:p?.ping?[p.ping]:[],pong:p?.pong?[p.pong]:[],message:p?.message?[e.emit,p.message]:[e.emit],closed:p?.closed?[p.closed]:[],error:p?.error?[p.error]:[]};return{onMessage:e.on,on(e,n){let r=t[e];return r.push(n),()=>{r.splice(r.indexOf(n),1)}},emit(e,...n){for(let r of[...t[e]])r(...n)}}})();function x(e){let t=[b.on(`error`,n=>{t.forEach(e=>e()),e(n)}),b.on(`closed`,n=>{t.forEach(e=>e()),e(n)})]}let S,C=0,w,T=!1,E=0,D=!1;async function ee(){clearTimeout(w);let[e,r]=await(S??=new Promise((e,r)=>(async()=>{if(T){if(await u(E),!C)return S=void 0,r({code:1e3,reason:`All Subscriptions Gone`});E++}b.emit(`connecting`,T);let i=new y(typeof t==`function`?await t():t,LX),a,l;function d(){isFinite(o)&&o>0&&(clearTimeout(l),l=setTimeout(()=>{i.readyState===y.OPEN&&(i.send(HX({type:zX.Ping})),b.emit(`ping`,!1,void 0))},o))}x(e=>{S=void 0,clearTimeout(a),clearTimeout(l),r(e),e instanceof KX&&(i.close(4499,`Terminated`),i.onerror=null,i.onclose=null)}),i.onerror=e=>b.emit(`error`,e),i.onclose=e=>b.emit(`closed`,e),i.onopen=async()=>{try{b.emit(`opened`,i);let e=typeof n==`function`?await n():n;if(i.readyState!==y.OPEN)return;i.send(HX(e?{type:zX.ConnectionInit,payload:e}:{type:zX.ConnectionInit},g)),isFinite(c)&&c>0&&(a=setTimeout(()=>{i.close(RX.ConnectionAcknowledgementTimeout,`Connection acknowledgement timeout`)},c)),d()}catch(e){b.emit(`error`,e),i.close(RX.InternalClientError,IX(e instanceof Error?e.message:Error(e).message,`Internal client error`))}};let f=!1;i.onmessage=({data:t})=>{try{let n=VX(t,_);if(b.emit(`message`,n),n.type===`ping`||n.type===`pong`){b.emit(n.type,!0,n.payload),n.type===`pong`?d():s||(i.send(HX(n.payload?{type:zX.Pong,payload:n.payload}:{type:zX.Pong})),b.emit(`pong`,!1,n.payload));return}if(f)return;if(n.type!==zX.ConnectionAck)throw Error(`First message cannot be of type ${n.type}`);clearTimeout(a),f=!0,b.emit(`connected`,i,n.payload,T),T=!1,E=0,e([i,new Promise((e,t)=>x(t))])}catch(e){i.onmessage=null,b.emit(`error`,e),i.close(RX.BadResponse,IX(e instanceof Error?e.message:Error(e).message,`Bad response`))}}})()));e.readyState===y.CLOSING&&await r;let i=()=>{},l=new Promise(e=>i=e);return[e,i,Promise.race([l.then(()=>{if(!C){let t=()=>e.close(1e3,`Normal Closure`);isFinite(a)&&a>0?w=setTimeout(()=>{e.readyState===y.OPEN&&t()},a):t()}}),r])]}function te(e){if(qX(e)&&(JX(e.code)||[RX.InternalServerError,RX.InternalClientError,RX.BadRequest,RX.BadResponse,RX.Unauthorized,RX.SubprotocolNotAcceptable,RX.SubscriberAlreadyExists,RX.TooManyInitialisationRequests].includes(e.code)))throw e;if(D)return!1;if(qX(e)&&e.code===1e3)return C>0;if(!l||E>=l||!d(e)||f?.(e))throw e;return T=!0}r||(async()=>{for(C++;;)try{let[,,e]=await ee();await e}catch(e){try{if(!te(e))return}catch(e){return i?.(e)}}})();function ne(e,t){let n=h(e),r=!1,i=!1,a=()=>{C--,r=!0};return(async()=>{for(C++;;)try{let[o,s,c]=await ee();if(r)return s();let l=b.onMessage(n,e=>{switch(e.type){case zX.Next:t.next(e.payload);return;case zX.Error:i=!0,r=!0,t.error(e.payload),a();return;case zX.Complete:r=!0,a();return}});o.send(HX({id:n,type:zX.Subscribe,payload:e},g)),a=()=>{!r&&o.readyState===y.OPEN&&o.send(HX({id:n,type:zX.Complete},g)),C--,r=!0,s()},await c.finally(l);return}catch(e){if(!te(e))return}})().then(()=>{i||t.complete()}).catch(e=>{t.error(e)}),()=>{r||a()}}return{on:b.on,subscribe:ne,iterate(e){let t=[],n={done:!1,error:null,resolve:()=>{}},r=ne(e,{next(e){t.push(e),n.resolve()},error(e){n.done=!0,n.error=e,n.resolve()},complete(){n.done=!0,n.resolve()}}),i=(function(){return WX(this,arguments,function*(){for(;;){for(t.length||(yield UX(new Promise(e=>n.resolve=e)));t.length;)yield yield UX(t.shift());if(n.error)throw n.error;if(n.done)return yield UX(void 0)}})})();return i.throw=async e=>(n.done||(n.done=!0,n.error=e,n.resolve()),{done:!0,value:void 0}),i.return=async()=>(r(),{done:!0,value:void 0}),i},async dispose(){if(D=!0,S){let[e]=await S;e.close(1e3,`Normal Closure`)}},terminate(){S&&b.emit(`closed`,new KX)}}}var KX=class extends Error{constructor(){super(...arguments),this.name=`TerminatedCloseEvent`,this.message=`4499: Terminated`,this.code=4499,this.reason=`Terminated`,this.wasClean=!1}};function qX(e){return PX(e)&&`code`in e&&`reason`in e}function JX(e){return[1e3,1001,1006,1005,1012,1013,1014].includes(e)?!1:e>=1e3&&e<=1999}function YX(e){return typeof e==`function`&&`constructor`in e&&`CLOSED`in e&&`CLOSING`in e&&`CONNECTING`in e&&`OPEN`in e}var XX=i(((e,t)=>{t.exports=n;function n(e){e||={},this.ms=e.min||100,this.max=e.max||1e4,this.factor=e.factor||2,this.jitter=e.jitter>0&&e.jitter<=1?e.jitter:0,this.attempts=0}n.prototype.duration=function(){var e=this.ms*this.factor**+ this.attempts++;if(this.jitter){var t=Math.random(),n=Math.floor(t*this.jitter*e);e=Math.floor(t*10)&1?e+n:e-n}return Math.min(e,this.max)|0},n.prototype.reset=function(){this.attempts=0},n.prototype.setMin=function(e){this.ms=e},n.prototype.setMax=function(e){this.max=e},n.prototype.setJitter=function(e){this.jitter=e}})),ZX=i((e=>{Object.defineProperty(e,`__esModule`,{value:!0});function t(e){return typeof e==`string`}e.default=t})),QX=i((e=>{Object.defineProperty(e,`__esModule`,{value:!0});function t(e){return typeof e==`object`&&!!e}e.default=t}));function $X(e){var t,n=e.Symbol;return typeof n==`function`?n.observable?t=n.observable:(t=n(`observable`),n.observable=t):t=`@@observable`,t}var eZ=n((()=>{})),tZ=r({default:()=>rZ}),nZ,rZ,iZ=n((()=>{eZ(),nZ=typeof self<`u`?self:typeof window<`u`?window:typeof global<`u`?global:typeof module<`u`?module:Function(`return this`)(),rZ=$X(nZ)})),aZ=i((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.GRAPHQL_SUBSCRIPTIONS=e.GRAPHQL_WS=void 0,e.GRAPHQL_WS=`graphql-ws`,e.GRAPHQL_SUBSCRIPTIONS=`graphql-subscriptions`})),oZ=i((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.WS_TIMEOUT=e.MIN_WS_TIMEOUT=void 0,e.MIN_WS_TIMEOUT=1e3,e.WS_TIMEOUT=3e4})),sZ=i((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=function(){function e(){throw Error(`Static Class`)}return e.GQL_CONNECTION_INIT=`connection_init`,e.GQL_CONNECTION_ACK=`connection_ack`,e.GQL_CONNECTION_ERROR=`connection_error`,e.GQL_CONNECTION_KEEP_ALIVE=`ka`,e.GQL_CONNECTION_TERMINATE=`connection_terminate`,e.GQL_START=`start`,e.GQL_DATA=`data`,e.GQL_ERROR=`error`,e.GQL_COMPLETE=`complete`,e.GQL_STOP=`stop`,e.SUBSCRIPTION_START=`subscription_start`,e.SUBSCRIPTION_DATA=`subscription_data`,e.SUBSCRIPTION_SUCCESS=`subscription_success`,e.SUBSCRIPTION_FAIL=`subscription_fail`,e.SUBSCRIPTION_END=`subscription_end`,e.INIT=`init`,e.INIT_SUCCESS=`init_success`,e.INIT_FAIL=`init_fail`,e.KEEP_ALIVE=`keepalive`,e}()})),cZ=i((e=>{var n=e&&e.__assign||function(){return n=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},n.apply(this,arguments)},r=e&&e.__awaiter||function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})},i=e&&e.__generator||function(e,t){var n={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},r,i,a,o;return o={next:s(0),throw:s(1),return:s(2)},typeof Symbol==`function`&&(o[Symbol.iterator]=function(){return this}),o;function s(e){return function(t){return c([e,t])}}function c(o){if(r)throw TypeError(`Generator is already executing.`);for(;n;)try{if(r=1,i&&(a=o[0]&2?i.return:o[0]?i.throw||((a=i.return)&&a.call(i),0):i.next)&&!(a=a.call(i,o[1])).done)return a;switch(i=0,a&&(o=[o[0]&2,a.value]),o[0]){case 0:case 1:a=o;break;case 4:return n.label++,{value:o[1],done:!1};case 5:n.label++,i=o[1],o=[0];continue;case 7:o=n.ops.pop(),n.trys.pop();continue;default:if((a=n.trys,!(a=a.length>0&&a[a.length-1]))&&(o[0]===6||o[0]===2)){n=0;continue}if(o[0]===3&&(!a||o[1]>a[0]&&o[1]<a[3])){n.label=o[1];break}if(o[0]===6&&n.label<a[1]){n.label=a[1],a=o;break}if(a&&n.label<a[2]){n.label=a[2],n.ops.push(o);break}a[2]&&n.ops.pop(),n.trys.pop();continue}o=t.call(e,n)}catch(e){o=[6,e],i=0}finally{r=a=0}if(o[0]&5)throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}},a=e&&e.__spreadArray||function(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||=Array.prototype.slice.call(t,0,r),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))};Object.defineProperty(e,`__esModule`,{value:!0}),e.SubscriptionClient=void 0;var o=typeof global<`u`?global:typeof window<`u`?window:{},s=o.WebSocket||o.MozWebSocket,c=XX(),l=MX(),u=ZX(),d=QX(),f=(Mn(),t(Fn)),p=(Nn(),t(In)),m=(iZ(),t(tZ)),h=aZ(),g=oZ(),_=sZ();e.SubscriptionClient=function(){function e(e,t,n,r){var i=t||{},a=i.connectionCallback,o=a===void 0?void 0:a,u=i.connectionParams,d=u===void 0?{}:u,f=i.minTimeout,p=f===void 0?g.MIN_WS_TIMEOUT:f,m=i.timeout,_=m===void 0?g.WS_TIMEOUT:m,v=i.reconnect,y=v===void 0?!1:v,b=i.reconnectionAttempts,x=b===void 0?1/0:b,S=i.lazy,C=S===void 0?!1:S,w=i.inactivityTimeout,T=w===void 0?0:w,E=i.wsOptionArguments,D=E===void 0?[]:E;if(this.wsImpl=n||s,!this.wsImpl)throw Error(`Unable to find native implementation, or alternative implementation for WebSocket!`);this.wsProtocols=r||h.GRAPHQL_WS,this.connectionCallback=o,this.url=e,this.operations={},this.nextOperationId=0,this.minWsTimeout=p,this.wsTimeout=_,this.unsentMessagesQueue=[],this.reconnect=y,this.reconnecting=!1,this.reconnectionAttempts=x,this.lazy=!!C,this.inactivityTimeout=T,this.closedByUser=!1,this.backoff=new c({jitter:.5}),this.eventEmitter=new l.EventEmitter,this.middlewares=[],this.client=null,this.maxConnectTimeGenerator=this.createMaxConnectTimeGenerator(),this.connectionParams=this.getConnectionParams(d),this.wsOptionArguments=D,this.lazy||this.connect()}return Object.defineProperty(e.prototype,`status`,{get:function(){return this.client===null?this.wsImpl.CLOSED:this.client.readyState},enumerable:!1,configurable:!0}),e.prototype.close=function(e,t){e===void 0&&(e=!0),t===void 0&&(t=!0),this.clearInactivityTimeout(),this.client!==null&&(this.closedByUser=t,e&&(this.clearCheckConnectionInterval(),this.clearMaxConnectTimeout(),this.clearTryReconnectTimeout(),this.unsubscribeAll(),this.sendMessage(void 0,_.default.GQL_CONNECTION_TERMINATE,null)),this.client.close(),this.client.onopen=null,this.client.onclose=null,this.client.onerror=null,this.client.onmessage=null,this.client=null,this.eventEmitter.emit(`disconnected`),e||this.tryReconnect())},e.prototype.request=function(e){var t,n=this.getObserver.bind(this),r=this.executeOperation.bind(this),i=this.unsubscribe.bind(this),a;return this.clearInactivityTimeout(),t={},t[m.default]=function(){return this},t.subscribe=function(t,o,s){var c=n(t,o,s);return a=r(e,function(e,t){e===null&&t===null?c.complete&&c.complete():e?c.error&&c.error(e[0]):c.next&&c.next(t)}),{unsubscribe:function(){a&&=(i(a),null)}}},t},e.prototype.on=function(e,t,n){var r=this.eventEmitter.on(e,t,n);return function(){r.off(e,t,n)}},e.prototype.onConnected=function(e,t){return this.on(`connected`,e,t)},e.prototype.onConnecting=function(e,t){return this.on(`connecting`,e,t)},e.prototype.onDisconnected=function(e,t){return this.on(`disconnected`,e,t)},e.prototype.onReconnected=function(e,t){return this.on(`reconnected`,e,t)},e.prototype.onReconnecting=function(e,t){return this.on(`reconnecting`,e,t)},e.prototype.onError=function(e,t){return this.on(`error`,e,t)},e.prototype.unsubscribeAll=function(){var e=this;Object.keys(this.operations).forEach(function(t){e.unsubscribe(t)})},e.prototype.applyMiddlewares=function(e){var t=this;return new Promise(function(n,r){(function(t,i){var a=function(o){if(o)r(o);else if(t.length>0){var s=t.shift();s&&s.applyMiddleware.apply(i,[e,a])}else n(e)};a()})(a([],t.middlewares,!0),t)})},e.prototype.use=function(e){var t=this;return e.map(function(e){if(typeof e.applyMiddleware==`function`)t.middlewares.push(e);else throw Error(`Middleware must implement the applyMiddleware function.`)}),this},e.prototype.getConnectionParams=function(e){return function(){return new Promise(function(t,n){if(typeof e==`function`)try{return t(e.call(null))}catch(e){return n(e)}t(e)})}},e.prototype.executeOperation=function(e,t){var n=this;this.client===null&&this.connect();var r=this.generateOperationId();return this.operations[r]={options:e,handler:t},this.applyMiddlewares(e).then(function(e){n.checkOperationOptions(e,t),n.operations[r]&&(n.operations[r]={options:e,handler:t},n.sendMessage(r,_.default.GQL_START,e))}).catch(function(e){n.unsubscribe(r),t(n.formatErrors(e))}),r},e.prototype.getObserver=function(e,t,n){return typeof e==`function`?{next:function(t){return e(t)},error:function(e){return t&&t(e)},complete:function(){return n&&n()}}:e},e.prototype.createMaxConnectTimeGenerator=function(){var e=this.minWsTimeout,t=this.wsTimeout;return new c({min:e,max:t,factor:1.2})},e.prototype.clearCheckConnectionInterval=function(){this.checkConnectionIntervalId&&=(clearInterval(this.checkConnectionIntervalId),null)},e.prototype.clearMaxConnectTimeout=function(){this.maxConnectTimeoutId&&=(clearTimeout(this.maxConnectTimeoutId),null)},e.prototype.clearTryReconnectTimeout=function(){this.tryReconnectTimeoutId&&=(clearTimeout(this.tryReconnectTimeoutId),null)},e.prototype.clearInactivityTimeout=function(){this.inactivityTimeoutId&&=(clearTimeout(this.inactivityTimeoutId),null)},e.prototype.setInactivityTimeout=function(){var e=this;this.inactivityTimeout>0&&Object.keys(this.operations).length===0&&(this.inactivityTimeoutId=setTimeout(function(){Object.keys(e.operations).length===0&&e.close()},this.inactivityTimeout))},e.prototype.checkOperationOptions=function(e,t){var n=e.query,r=e.variables,i=e.operationName;if(!n)throw Error(`Must provide a query.`);if(!t)throw Error(`Must provide an handler.`);if(!(0,u.default)(n)&&!(0,p.getOperationAST)(n,i)||i&&!(0,u.default)(i)||r&&!(0,d.default)(r))throw Error("Incorrect option types. query must be a string or a document,`operationName` must be a string, and `variables` must be an object.")},e.prototype.buildMessage=function(e,t,r){return{id:e,type:t,payload:r&&r.query?n(n({},r),{query:typeof r.query==`string`?r.query:(0,f.print)(r.query)}):r}},e.prototype.formatErrors=function(e){return Array.isArray(e)?e:e&&e.errors?this.formatErrors(e.errors):e&&e.message?[e]:[{name:`FormatedError`,message:`Unknown error`,originalError:e}]},e.prototype.sendMessage=function(e,t,n){this.sendMessageRaw(this.buildMessage(e,t,n))},e.prototype.sendMessageRaw=function(e){switch(this.status){case this.wsImpl.OPEN:var t=JSON.stringify(e);try{JSON.parse(t)}catch{this.eventEmitter.emit(`error`,Error(`Message must be JSON-serializable. Got: `+e))}this.client.send(t);break;case this.wsImpl.CONNECTING:this.unsentMessagesQueue.push(e);break;default:this.reconnecting||this.eventEmitter.emit(`error`,Error(`A message was not sent because socket is not connected, is closing or is already closed. Message was: `+JSON.stringify(e)))}},e.prototype.generateOperationId=function(){return String(++this.nextOperationId)},e.prototype.tryReconnect=function(){var e=this;if(!(!this.reconnect||this.backoff.attempts>=this.reconnectionAttempts)){this.reconnecting||=(Object.keys(this.operations).forEach(function(t){e.unsentMessagesQueue.push(e.buildMessage(t,_.default.GQL_START,e.operations[t].options))}),!0),this.clearTryReconnectTimeout();var t=this.backoff.duration();this.tryReconnectTimeoutId=setTimeout(function(){e.connect()},t)}},e.prototype.flushUnsentMessagesQueue=function(){var e=this;this.unsentMessagesQueue.forEach(function(t){e.sendMessageRaw(t)}),this.unsentMessagesQueue=[]},e.prototype.checkConnection=function(){if(this.wasKeepAliveReceived){this.wasKeepAliveReceived=!1;return}this.reconnecting||this.close(!1,!0)},e.prototype.checkMaxConnectTimeout=function(){var e=this;this.clearMaxConnectTimeout(),this.maxConnectTimeoutId=setTimeout(function(){e.status!==e.wsImpl.OPEN&&(e.reconnecting=!0,e.close(!1,!0))},this.maxConnectTimeGenerator.duration())},e.prototype.connect=function(){var e,t=this;this.client=new((e=this.wsImpl).bind.apply(e,a([void 0,this.url,this.wsProtocols],this.wsOptionArguments,!1))),this.checkMaxConnectTimeout(),this.client.onopen=function(){return r(t,void 0,void 0,function(){var e,t;return i(this,function(n){switch(n.label){case 0:if(this.status!==this.wsImpl.OPEN)return[3,4];this.clearMaxConnectTimeout(),this.closedByUser=!1,this.eventEmitter.emit(this.reconnecting?`reconnecting`:`connecting`),n.label=1;case 1:return n.trys.push([1,3,,4]),[4,this.connectionParams()];case 2:return e=n.sent(),this.sendMessage(void 0,_.default.GQL_CONNECTION_INIT,e),this.flushUnsentMessagesQueue(),[3,4];case 3:return t=n.sent(),this.sendMessage(void 0,_.default.GQL_CONNECTION_ERROR,t),this.flushUnsentMessagesQueue(),[3,4];case 4:return[2]}})})},this.client.onclose=function(){t.closedByUser||t.close(!1,!1)},this.client.onerror=function(e){t.eventEmitter.emit(`error`,e)},this.client.onmessage=function(e){var n=e.data;t.processReceivedData(n)}},e.prototype.processReceivedData=function(e){var t,r;try{t=JSON.parse(e),r=t.id}catch{throw Error(`Message must be JSON-parseable. Got: `+e)}if([_.default.GQL_DATA,_.default.GQL_COMPLETE,_.default.GQL_ERROR].indexOf(t.type)!==-1&&!this.operations[r]){this.unsubscribe(r);return}switch(t.type){case _.default.GQL_CONNECTION_ERROR:this.connectionCallback&&this.connectionCallback(t.payload);break;case _.default.GQL_CONNECTION_ACK:this.eventEmitter.emit(this.reconnecting?`reconnected`:`connected`,t.payload),this.reconnecting=!1,this.backoff.reset(),this.maxConnectTimeGenerator.reset(),this.connectionCallback&&this.connectionCallback();break;case _.default.GQL_COMPLETE:var i=this.operations[r].handler;delete this.operations[r],i.call(this,null,null);break;case _.default.GQL_ERROR:this.operations[r].handler(this.formatErrors(t.payload),null),delete this.operations[r];break;case _.default.GQL_DATA:var a=t.payload.errors?n(n({},t.payload),{errors:this.formatErrors(t.payload.errors)}):t.payload;this.operations[r].handler(null,a);break;case _.default.GQL_CONNECTION_KEEP_ALIVE:var o=this.wasKeepAliveReceived===void 0;this.wasKeepAliveReceived=!0,o&&this.checkConnection(),this.checkConnectionIntervalId&&(clearInterval(this.checkConnectionIntervalId),this.checkConnection()),this.checkConnectionIntervalId=setInterval(this.checkConnection.bind(this),this.wsTimeout);break;default:throw Error(`Invalid message type!`)}},e.prototype.unsubscribe=function(e){this.operations[e]&&(delete this.operations[e],this.setInactivityTimeout(),this.sendMessage(e,_.default.GQL_STOP,void 0))},e}()})),lZ=e(MX(),1),uZ=cZ(),dZ=(e=!1)=>e?`https://embed.apollo.local:3000`:`https://sandbox.embed.apollographql.com`,fZ=`SchemaError`,pZ=`SchemaResponse`,mZ=`ExplorerRequest`,hZ=`ExplorerResponse`,gZ=`ExplorerSubscriptionRequest`,_Z=`ExplorerSubscriptionResponse`,vZ=`ExplorerSubscriptionTermination`,yZ=`ExplorerSetSocketError`,bZ=`ExplorerSetSocketStatus`,xZ=e=>`apollo-embed-${e}`,SZ=`ExplorerListeningForHandshake`,CZ=`HandshakeResponse`,wZ=`SetPartialAuthenticationTokenForParent`,TZ=`TriggerLogoutInParent`,EZ=`ExplorerListeningForPartialToken`,DZ=`PartialAuthenticationTokenResponse`,OZ=`PreflightOAuthRequest`,kZ=`PreflightOAuthProviderResponse`,AZ=`PreflightOAuthResponse`,jZ=`IntrospectionQueryWithHeaders`,MZ=`ParentLogoutSuccess`,NZ=({legacyIncludeCookies:e})=>(t,n)=>fetch(t,Object.assign(Object.assign({},n),e?{credentials:`include`}:e===void 0?{}:{credentials:`omit`}));function PZ(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})}function FZ(e,t){if(e.body===null)throw Error(`Missing body`);if(typeof e.body.tee!=`function`)throw Error(`Streaming bodies not supported by provided fetch implementation`);let n=new TextDecoder(`utf-8`),r=``,i=`--${t.parameters.get(`boundary`)||`-`}`,a=e.body.getReader();return{closeReadableStream:()=>a.cancel(),observable:new jX(e=>{function t(){a.read().then(a=>{var o,s;if(a.done){(o=e.complete)==null||o.call(e);return}let c=n.decode(a.value);r+=c;let l=r.indexOf(i);for(;l>-1;){let t=r.slice(0,l);if(r=r.slice(l+i.length),t.trim()){let n=`\r
2169
2169
  \r
@@ -2184,7 +2184,7 @@ claude mcp list
2184
2184
  claude mcp show ${e.serverName}
2185
2185
 
2186
2186
  # Remove server
2187
- claude mcp remove ${e.serverName}`})]})]})})]}),(0,I.jsxs)(xt,{value:`config`,borderWidth:`0`,children:[(0,I.jsxs)(pn,{cursor:`pointer`,py:2,_hover:{bg:`newGray.50`},fontSize:`xs`,color:`newGray.500`,fontWeight:`500`,borderRadius:`sm`,px:2,mx:-2,children:[(0,I.jsx)(A,{flex:`1`,textAlign:`left`,children:`Option 2: Configuration File`}),(0,I.jsx)(an,{})]}),(0,I.jsx)(tt,{children:(0,I.jsx)(M,{align:`stretch`,gap:3,pt:2,pb:2,children:(0,I.jsxs)(A,{children:[(0,I.jsx)(k,{fontSize:`xs`,color:`newGray.400`,mb:2,children:`Add to your MCP configuration file (e.g., ~/.claude.json for Claude Code):`}),(0,I.jsxs)(A,{position:`relative`,className:`group`,children:[(0,I.jsx)(Jt,{display:`block`,whiteSpace:`pre`,p:3,fontSize:`xs`,bg:`newGray.50`,borderRadius:`md`,overflow:`auto`,children:e.claudeConfigSnippet}),(0,I.jsx)(Ze,{"aria-label":`Copy config`,size:`xs`,variant:`plain`,color:`newGray.400`,position:`absolute`,top:2,right:2,opacity:0,_groupHover:{opacity:1},onClick:n,children:(0,I.jsx)(vf,{})})]})]})})})]})]}),(0,I.jsxs)(A,{mt:4,pt:4,borderTopWidth:`1px`,borderColor:`newGray.100`,children:[(0,I.jsx)(k,{fontSize:`xs`,fontWeight:`500`,color:`newGray.500`,mb:2,children:`Authentication`}),(0,I.jsx)(k,{fontSize:`xs`,color:`newGray.400`,children:`When you start working with the MCP server, you will be prompted to authenticate using one of the available methods.`})]})]})]})})}),I1=3e3,L1=class{_oauthParams=null;_isAuthorizing=!1;_authorizeError=null;_isAuthorized=!1;_redirectUri=null;_redirectTimer=null;constructor(){f(this,{},{autoBind:!0})}get oauthClientName(){return this._oauthParams?.clientName??``}get isAuthorizing(){return this._isAuthorizing}get authorizeError(){return this._authorizeError}get isAuthorized(){return this._isAuthorized}get hasOAuthParams(){return this._oauthParams!==null}deny(){if(!this._oauthParams)return;let e=new URL(this._oauthParams.redirectUri);e.searchParams.set(`error`,`access_denied`),e.searchParams.set(`state`,this._oauthParams.state),globalThis.location.href=e.toString()}async approve(){if(this._oauthParams&&!(this._isAuthorizing||this._isAuthorized)){c(()=>{this._isAuthorizing=!0,this._authorizeError=null});try{let e=await fetch(`/oauth/authorize`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({client_id:this._oauthParams.clientId,redirect_uri:this._oauthParams.redirectUri,code_challenge:this._oauthParams.codeChallenge,state:this._oauthParams.state,...this._oauthParams.scope?{scope:this._oauthParams.scope}:{}})});if(!e.ok){let t=await e.json().catch(()=>null);throw Error(t?.message||`Authorization failed`)}let t=await e.json();c(()=>{this._isAuthorized=!0,this._redirectUri=t.redirect_uri,this._isAuthorizing=!1}),this._redirectTimer&&clearTimeout(this._redirectTimer),this._redirectTimer=setTimeout(()=>{this._redirectUri&&(globalThis.location.href=this._redirectUri)},I1)}catch(e){c(()=>{this._authorizeError=e instanceof Error?e.message:`Authorization failed`,this._isAuthorizing=!1})}}}redirectNow(){this._redirectTimer&&clearTimeout(this._redirectTimer),this._redirectUri&&(globalThis.location.href=this._redirectUri)}init(){let e=new URLSearchParams(globalThis.location.search),t=e.get(`client_id`),n=e.get(`client_name`),r=e.get(`redirect_uri`),i=e.get(`code_challenge`),a=e.get(`state`);if(t&&n&&r&&i&&a){try{new URL(r)}catch{return}this._oauthParams={clientId:t,clientName:n,redirectUri:r,codeChallenge:i,state:a,scope:e.get(`scope`)??void 0}}}dispose(){this._redirectTimer&&clearTimeout(this._redirectTimer)}};Y.register(L1,()=>new L1,{scope:`request`});var R1=g(({model:e})=>{let t=(0,L.useCallback)(()=>{e.redirectNow()},[e]);return(0,I.jsx)(Vq,{hideSidebar:!0,children:(0,I.jsx)(j,{alignItems:`center`,justifyContent:`center`,flex:1,children:(0,I.jsxs)(M,{gap:6,maxWidth:`400px`,textAlign:`center`,children:[(0,I.jsx)(k,{fontSize:`lg`,fontWeight:`500`,color:`newGray.500`,children:`Authorization Successful`}),(0,I.jsx)(k,{fontSize:`sm`,color:`newGray.400`,children:`Redirecting back to the application...`}),(0,I.jsx)(N,{variant:`outline`,colorPalette:`gray`,size:`sm`,onClick:t,children:`Continue now`})]})})})}),z1=g(()=>{let e=CB(L1),t=(0,L.useCallback)(async()=>{await e.approve()},[e]),n=(0,L.useCallback)(()=>{e.deny()},[e]);return e.hasOAuthParams?e.isAuthorized?(0,I.jsx)(R1,{model:e}):(0,I.jsx)(Vq,{hideSidebar:!0,children:(0,I.jsx)(j,{alignItems:`center`,justifyContent:`center`,flex:1,children:(0,I.jsxs)(M,{gap:6,maxWidth:`400px`,textAlign:`center`,children:[(0,I.jsx)(k,{fontSize:`lg`,fontWeight:`500`,color:`newGray.500`,children:`Authorize Application`}),(0,I.jsx)(A,{p:4,bg:`newGray.50`,borderRadius:`md`,borderWidth:`1px`,borderColor:`newGray.100`,width:`100%`,children:(0,I.jsxs)(k,{fontSize:`sm`,color:`newGray.400`,children:[(0,I.jsx)(k,{as:`span`,fontWeight:`600`,color:`newGray.500`,children:e.oauthClientName}),` `,`wants to access your Revisium account.`]})}),e.authorizeError&&(0,I.jsx)(A,{p:3,bg:`red.50`,borderRadius:`md`,borderWidth:`1px`,borderColor:`red.200`,width:`100%`,children:(0,I.jsx)(k,{fontSize:`xs`,color:`red.500`,children:e.authorizeError})}),(0,I.jsxs)(j,{gap:3,width:`100%`,children:[(0,I.jsx)(N,{flex:1,variant:`outline`,colorPalette:`gray`,size:`sm`,onClick:n,disabled:e.isAuthorizing,children:`Deny`}),(0,I.jsx)(N,{flex:1,colorPalette:`blue`,size:`sm`,onClick:t,loading:e.isAuthorizing,children:`Authorize`})]}),(0,I.jsx)(k,{fontSize:`xs`,color:`newGray.300`,children:`This will allow the application to access Revisium on your behalf.`})]})})}):(0,I.jsx)(Vq,{hideSidebar:!0,children:(0,I.jsx)(j,{alignItems:`center`,justifyContent:`center`,flex:1,children:(0,I.jsx)(k,{color:`newGray.400`,children:`Missing OAuth parameters.`})})})}),B1=class{_accessToken=null;_loading=!1;constructor(e){this.apiService=e,f(this,{},{autoBind:!0})}get hasAccessToken(){return!!this._accessToken}get accessToken(){return this._accessToken||``}get loading(){return this._loading}get truncatedToken(){let e=this.accessToken;return e.length<=30?e:`${e.slice(0,20)}...${e.slice(-10)}`}async copyAccessToken(){if(!this._accessToken)return!1;try{return await GV(this._accessToken),!0}catch{return!1}}init(){this.fetchAccessToken()}dispose(){this._accessToken=null}async fetchAccessToken(){c(()=>{this._loading=!0});try{let e=await this.apiService.client.issueAccessToken();c(()=>{this._accessToken=e.issueAccessToken.accessToken})}catch{c(()=>{this._accessToken=null})}finally{c(()=>{this._loading=!1})}}};Y.register(B1,()=>new B1(Y.get(dJ)),{scope:`request`});var V1=g(()=>{let e=CB(B1),t=Tn(),n=(0,L.useCallback)(async()=>{await e.copyAccessToken()?Jq.info({description:`Access token copied to clipboard`}):Jq.error({description:`Failed to copy token`})},[e]),r=(0,L.useCallback)(()=>{t(`/`)},[t]);return e.loading?(0,I.jsx)(Vq,{hideSidebar:!0,children:(0,I.jsx)(j,{alignItems:`center`,justifyContent:`center`,flex:1,children:(0,I.jsx)(k,{color:`newGray.400`,children:`Loading access token...`})})}):e.hasAccessToken?(0,I.jsx)(Vq,{hideSidebar:!0,children:(0,I.jsx)(j,{alignItems:`center`,justifyContent:`center`,flex:1,children:(0,I.jsxs)(M,{gap:6,maxWidth:`500px`,textAlign:`center`,children:[(0,I.jsx)(k,{fontSize:`lg`,fontWeight:`500`,color:`newGray.500`,children:`Access Token`}),(0,I.jsxs)(A,{width:`100%`,children:[(0,I.jsx)(k,{fontSize:`xs`,color:`newGray.400`,mb:2,children:`Copy this token to use with Revisium API or MCP tools:`}),(0,I.jsxs)(j,{align:`center`,gap:2,p:3,bg:`newGray.50`,borderRadius:`md`,borderWidth:`1px`,borderColor:`newGray.100`,children:[(0,I.jsx)(Jt,{fontSize:`xs`,color:`newGray.500`,bg:`transparent`,flex:1,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,children:e.truncatedToken}),(0,I.jsx)(Ze,{"aria-label":`Copy token`,size:`sm`,variant:`outline`,colorPalette:`gray`,onClick:n,children:(0,I.jsx)(vf,{})})]})]}),(0,I.jsx)(A,{p:4,bg:`newGray.50`,borderRadius:`md`,borderWidth:`1px`,borderColor:`newGray.100`,width:`100%`,children:(0,I.jsx)(k,{fontSize:`xs`,color:`newGray.400`,children:`You can now close this page and paste the token in your application.`})}),(0,I.jsx)(N,{variant:`outline`,colorPalette:`gray`,size:`sm`,onClick:r,children:`Go to Main Page`})]})})}):(0,I.jsx)(Vq,{hideSidebar:!0,children:(0,I.jsx)(j,{alignItems:`center`,justifyContent:`center`,flex:1,children:(0,I.jsx)(k,{color:`newGray.400`,children:`No access token available. Please login first.`})})})}),H1=({onClick:e})=>(0,I.jsx)(Uq,{dataTestId:`create-project-button`,title:`Project`,onClick:e}),U1=class{constructor(e,t){this.routerParams=e,this.authService=t,f(this,{},{autoBind:!0})}get organizationId(){return this.routerParams.organizationId??this.authService.user?.organizationId??``}get isAuthenticated(){return!!this.authService.user}};Y.register(U1,()=>new U1(Y.get(pQ),Y.get(hJ)),{scope:`singleton`});var W1=class{request=X.of(Q.createProject);constructor(){f(this)}get isLoading(){return this.request.isLoading}get error(){return this.request.errorMessage??null}get data(){return this.request.data}async create(e){return(await this.request.fetch({data:{organizationId:e.organizationId,projectName:e.projectName,branchName:e.branchName,fromRevisionId:e.fromRevisionId}})).isRight}dispose(){this.request.abort()}};Y.register(W1,()=>new W1,{scope:`request`});var G1=class{projectName=``;branchName=``;fromRevisionId=``;showingSettings=!1;constructor(e,t){this.dataSource=e,this.context=t,f(this,{},{autoBind:!0})}get isLoading(){return this.dataSource.isLoading}get error(){return this.dataSource.error}get canCreate(){return this.projectName.length>0&&!this.isLoading}get organizationId(){return this.context.organizationId}setProjectName(e){this.projectName=e}setBranchName(e){this.branchName=e}setFromRevisionId(e){this.fromRevisionId=e}toggleSettings(){this.showingSettings=!this.showingSettings}async create(){return this.dataSource.create({organizationId:this.organizationId,projectName:this.projectName,branchName:this.branchName||void 0,fromRevisionId:this.fromRevisionId||void 0})}init(){}dispose(){this.dataSource.dispose()}};Y.register(G1,()=>new G1(Y.get(W1),Y.get(U1)),{scope:`request`});var K1=({onClick:e,color:t,dataTestId:n})=>(0,I.jsx)(Ze,{_hover:{backgroundColor:`gray.100`},"data-testid":n,"aria-label":``,color:t||`gray.400`,variant:`ghost`,onClick:e,children:(0,I.jsx)(Xf,{})}),q1=g(({onComplete:e})=>{let t=CB(G1),n=(0,L.useCallback)(async()=>{await t.create()&&e?.()},[t,e]),r=(0,L.useCallback)(e=>{t.setProjectName(e.currentTarget.value)},[t]),i=(0,L.useCallback)(e=>{t.setBranchName(e.currentTarget.value)},[t]),a=(0,L.useCallback)(e=>{t.setFromRevisionId(e.currentTarget.value)},[t]);return(0,I.jsxs)(j,{alignSelf:`flex-start`,gap:`0.5rem`,children:[(0,I.jsx)(Gq,{onClick:e}),(0,I.jsxs)(j,{flexDirection:`column`,gap:`0.5rem`,children:[(0,I.jsx)(qq,{dataTestId:`create-project-name-input`,autoFocus:!0,height:`40px`,placeholder:`project name`,value:t.projectName,onChange:r,onEnter:n}),t.projectName&&t.showingSettings&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(qq,{dataTestId:`create-project-branch-name-input`,height:`40px`,placeholder:`branch name`,value:t.branchName,onChange:i,onEnter:n}),(0,I.jsx)(qq,{dataTestId:`create-project-from-revision-id-input`,height:`40px`,placeholder:`from revisionId`,value:t.fromRevisionId,onChange:a,onEnter:n})]})]}),t.projectName&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(Wq,{dataTestId:`create-project-approve-button`,loading:t.isLoading,onClick:n}),(0,I.jsx)(K1,{dataTestId:`create-project-settings-button`,color:t.showingSettings?`gray.400`:`gray.200`,onClick:t.toggleSettings})]})]})}),J1=class extends rH{constructor(e){super(Q.organizationProjects,{pageSize:100}),this.context=e}extractItems(e){return e.projects.edges.map(e=>e.node)}extractPageInfo(e){return{hasNextPage:e.projects.pageInfo.hasNextPage,endCursor:e.projects.pageInfo.endCursor||null,totalCount:e.projects.totalCount}}buildFetchArgs(e,t){return{data:{organizationId:this.context.organizationId,first:this.config.pageSize,after:t}}}};Y.register(J1,()=>new J1(Y.get(U1)),{scope:`request`});var Y1=class{constructor(e){this.project=e,f(this)}get id(){return this.project.id}get name(){return this.project.name}get isPublic(){return this.project.isPublic}get touched(){return this.project.rootBranch.touched}get link(){return Dn(`/app/${AJ}/${PJ}/${zJ}/${qJ}`,{organizationId:this.project.organizationId,projectName:this.project.name,branchName:this.project.rootBranch.name,revisionIdOrTag:XJ})}},X1=class extends nH{isCreatingProject=!1;constructor(e,t,n){super(e),this.permissionService=t,this.context=n,h(this,{isCreatingProject:u,canCreateProject:a,toggleCreatingProject:m.bound,handleProjectCreated:m.bound})}get canCreateProject(){return this.permissionService.can(`create`,`Project`,{organizationId:this.context.organizationId})}getItemKey(e){return e.id}createItemViewModel(e){return new Y1(e)}toggleCreatingProject(){this.isCreatingProject=!this.isCreatingProject}handleProjectCreated(){this.isCreatingProject=!1,this.init()}};Y.register(X1,()=>new X1(Y.get(J1),Y.get(vW),Y.get(U1)),{scope:`request`});var Z1=()=>{let e=yn();return{isProjectsActive:e.some(e=>e.id===rY.OrganizationOverview),isMembersActive:e.some(e=>e.id===rY.OrganizationMembers),isSettingsActive:e.some(e=>e.id===rY.OrganizationSettings),isLimitsActive:e.some(e=>e.id===rY.OrganizationLimits)}},Q1=class{constructor(e,t,n){this.context=e,this.permissionService=t,this.configurationService=n,f(this,{},{autoBind:!0})}get organizationId(){return this.context.organizationId}get isAuthenticated(){return this.context.isAuthenticated}get billingEnabled(){return this.configurationService.billingEnabled}get organizationCondition(){return{organizationId:this.organizationId}}get canManageMembers(){return this.permissionService.can(`add`,`User`,this.organizationCondition)}get canManageApiKeys(){return this.permissionService.can(`manage`,`ApiKey`,this.organizationCondition)}get canAccessSettings(){return this.permissionService.can(`update`,`Organization`,this.organizationCondition)}get projectsLink(){return Dn(`/app/${AJ}`,{organizationId:this.organizationId})}get membersLink(){return Dn(`/app/${AJ}/${MJ}`,{organizationId:this.organizationId})}get settingsLink(){return Dn(`/app/${AJ}/${jJ}`,{organizationId:this.organizationId})}get limitsLink(){return Dn(`/app/${AJ}/${NJ}`,{organizationId:this.organizationId})}init(){}dispose(){}};Y.register(Q1,()=>new Q1(Y.get(U1),Y.get(vW),Y.get(gJ)),{scope:`singleton`});var $1=g(({organizationId:e})=>{let t=Tn();return(0,I.jsx)(j,{className:`group`,flexDirection:`column`,alignItems:`flex-start`,width:`100%`,minWidth:`0`,children:(0,I.jsxs)(j,{alignItems:`center`,gap:`8px`,padding:`4px`,width:`100%`,minWidth:0,children:[(0,I.jsx)(A,{fontSize:`20px`,color:`newGray.400`,cursor:`pointer`,_hover:{color:`newGray.500`},onClick:()=>{t(`/`)},display:`flex`,alignItems:`center`,flexShrink:0,children:(0,I.jsx)(pf,{})}),(0,I.jsx)(A,{color:`black`,fontWeight:`600`,fontSize:`18px`,lineHeight:`26px`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,overflow:`hidden`,flex:1,minWidth:0,children:e}),(0,I.jsx)(T,{}),(0,I.jsx)(oJ,{})]})})}),e0=g(()=>{let e=CB(Q1),{isProjectsActive:t,isMembersActive:n,isSettingsActive:r,isLimitsActive:i}=Z1();return(0,I.jsxs)(M,{alignItems:`flex-start`,gap:0,width:`100%`,flex:1,children:[(0,I.jsx)($1,{organizationId:e.organizationId}),(0,I.jsx)(A,{width:`100%`,paddingY:`16px`,children:(0,I.jsx)(O,{borderColor:`newGray.100`})}),(0,I.jsxs)(j,{flexDirection:`column`,width:`100%`,gap:1,children:[(0,I.jsx)(sJ,{to:e.projectsLink,label:`Projects`,icon:(0,I.jsx)(Yte,{}),isActive:t}),e.canManageMembers&&(0,I.jsx)(sJ,{to:e.membersLink,label:`Members`,icon:(0,I.jsx)(Bf,{}),isActive:n}),e.canManageApiKeys&&(0,I.jsx)(sJ,{to:e.settingsLink,label:`API Keys`,icon:(0,I.jsx)(Df,{}),isActive:r}),e.billingEnabled&&(0,I.jsx)(sJ,{to:e.limitsLink,label:`Billing`,icon:(0,I.jsx)(zte,{}),isActive:i})]}),(0,I.jsx)(T,{}),(0,I.jsx)(j,{flexDirection:`column`,width:`100%`,gap:1,children:e.isAuthenticated?(0,I.jsx)(IY,{}):(0,I.jsx)(sJ,{to:`/${yJ}`,label:`Sign in`,icon:(0,I.jsx)(Ff,{}),isActive:!1})})]})}),t0=g(({model:e})=>(0,I.jsx)(A,{height:`2.5rem`,width:`100%`,children:(0,I.jsx)(j,{_hover:{backgroundColor:`gray.50`},alignItems:`center`,gap:`4px`,paddingLeft:`1rem`,children:(0,I.jsx)(j,{alignItems:`center`,flex:1,justifyContent:`space-between`,minHeight:`40px`,children:(0,I.jsxs)(j,{minWidth:`150px`,children:[(0,I.jsx)(k,{_hover:{textDecoration:`underline`},children:(0,I.jsx)(An,{to:e.link,children:e.name})}),e.touched&&(0,I.jsx)(k,{color:`gray.400`,ml:`4px`,children:`*`})]})})})})),n0=g(()=>{let e=CB(X1);return(0,I.jsx)(Vq,{sidebar:(0,I.jsx)(e0,{}),children:(0,I.jsx)(j,{flex:1,flexDirection:`column`,gap:`0.5rem`,paddingBottom:`1rem`,children:e.isCreatingProject?(0,I.jsx)(q1,{onComplete:e.handleProjectCreated}):(0,I.jsxs)(I.Fragment,{children:[e.canCreateProject&&(0,I.jsx)(H1,{onClick:e.toggleCreatingProject}),e.showLoading&&(0,I.jsx)(M,{flex:1,justifyContent:`center`,children:(0,I.jsx)(Ht,{size:`md`,color:`gray.400`})}),e.showError&&(0,I.jsxs)(M,{flex:1,justifyContent:`center`,gap:`8px`,color:`gray.400`,children:[(0,I.jsx)(k,{fontSize:`md`,children:`Could not load projects`}),(0,I.jsx)(k,{fontSize:`sm`,children:`Please retry later`})]}),e.showEmpty&&(0,I.jsx)(M,{flex:1,justifyContent:`center`,gap:`8px`,color:`gray.400`,children:(0,I.jsx)(k,{fontSize:`md`,children:`No projects yet`})}),e.showList&&(0,I.jsx)(QM,{useWindowScroll:!0,totalCount:e.totalCount,defaultItemHeight:40,endReached:e.hasNextPage?e.tryToFetchNextPage:void 0,itemContent:t=>{let n=e.items[t];return n?(0,I.jsx)(t0,{model:n},n.id):null}})]})})})}),r0=class{apiKeyManager;constructor(e,t,n){this.context=e,this.permissionService=t,f(this,{},{autoBind:!0}),this.apiKeyManager=n,this.apiKeyManager.configure({mode:`service`,organizationId:this.context.organizationId})}get organizationId(){return this.context.organizationId}get canManageServiceKeys(){return this.permissionService.can(`manage`,`ApiKey`,{organizationId:this.organizationId})}init(){}dispose(){this.apiKeyManager.dispose()}};Y.register(r0,()=>new r0(Y.get(U1),Y.get(vW),Y.get(MY)),{scope:`request`});var i0=g(()=>{let e=CB(r0);return(0,I.jsx)(Vq,{sidebar:(0,I.jsx)(e0,{}),children:(0,I.jsx)(A,{maxWidth:`600px`,width:`100%`,mb:`4rem`,children:(0,I.jsxs)(M,{align:`stretch`,gap:`2rem`,children:[(0,I.jsxs)(A,{children:[(0,I.jsx)(k,{fontSize:`20px`,fontWeight:`600`,color:`newGray.500`,mb:1,children:`API Keys`}),(0,I.jsx)(k,{fontSize:`xs`,color:`newGray.400`,children:`Service keys for automated integrations with this organization.`})]}),e.canManageServiceKeys&&(0,I.jsx)(kY,{model:e.apiKeyManager})]})})})}),a0=300,o0=class{_isOpen=!1;_activeTab=`search`;_searchQuery=``;_searchResults=[];_selectedUserId=null;_selectedRole=JW.Reader;_newUsername=``;_newPassword=``;_newEmail=``;_isAdding=!1;_isCreating=!1;debounceTimeout=null;searchRequest=X.of(Q.searchUsers);constructor(e,t,n){this.context=e,this.systemPermissions=t,this.onMemberAdded=n,f(this,{},{autoBind:!0})}get isOpen(){return this._isOpen}get activeTab(){return this._activeTab}get canCreateUser(){return this.systemPermissions.canCreateUser}get searchQuery(){return this._searchQuery}get searchResults(){return this._searchResults}get selectedUserId(){return this._selectedUserId}get selectedRole(){return this._selectedRole}get isSearching(){return this.searchRequest.isLoading}get canAddSelectedUser(){return this._selectedUserId!==null&&!this._isAdding}get isAdding(){return this._isAdding}get newUsername(){return this._newUsername}get newPassword(){return this._newPassword}get newEmail(){return this._newEmail}get isCreating(){return this._isCreating}get canCreateNewUser(){return this._newUsername.trim().length>0&&this._newPassword.length>=6&&!this._isCreating}open(){this._isOpen=!0,this.reset()}close(){this._isOpen=!1,this.reset()}setActiveTab(e){this._activeTab=e}setSearchQuery(e){this._searchQuery=e,this.debounceTimeout&&=(clearTimeout(this.debounceTimeout),null),e.trim()?this.debounceTimeout=setTimeout(()=>{this.search(),this.debounceTimeout=null},a0):this._searchResults=[]}setSelectedUserId(e){this._selectedUserId=e}setSelectedRole(e){this._selectedRole=e}setNewUsername(e){this._newUsername=e}setNewPassword(e){this._newPassword=e}setNewEmail(e){this._newEmail=e}async search(){if(this._searchQuery.trim().length===0){this._searchResults=[];return}let e=await this.searchRequest.fetch({search:this._searchQuery,first:20});c(()=>{e.isRight&&(this._searchResults=e.data.searchUsers.edges.map(e=>({id:e.node.id,username:e.node.username??null,email:e.node.email??null})))})}async addSelectedUser(){if(!(!this._selectedUserId||this._isAdding)){this._isAdding=!0;try{let e=await Q.addUserToOrganization({organizationId:this.context.organizationId,userId:this._selectedUserId,roleId:this._selectedRole});c(()=>{e.addUserToOrganization&&(this.onMemberAdded(),this.close())})}catch(e){console.error(`Failed to add member:`,e)}finally{c(()=>{this._isAdding=!1})}}}async createAndAddUser(){if(this.canCreateNewUser){this._isCreating=!0;try{if(!(await Q.createUser({username:this._newUsername.trim(),password:this._newPassword,email:this._newEmail.trim()||void 0,roleId:XW.SystemUser})).createUser)throw Error(`Failed to create user`);let e=(await Q.searchUsers({search:this._newUsername.trim(),first:1})).searchUsers.edges.find(e=>e.node.username===this._newUsername.trim());if(!e)throw Error(`Could not find newly created user`);let t=await Q.addUserToOrganization({organizationId:this.context.organizationId,userId:e.node.id,roleId:this._selectedRole});c(()=>{t.addUserToOrganization&&(this.onMemberAdded(),this.close())})}catch(e){console.error(`Failed to create and add member:`,e)}finally{c(()=>{this._isCreating=!1})}}}dispose(){this.debounceTimeout&&=(clearTimeout(this.debounceTimeout),null)}reset(){this.debounceTimeout&&=(clearTimeout(this.debounceTimeout),null),this._activeTab=`search`,this._searchQuery=``,this._searchResults=[],this._selectedUserId=null,this._selectedRole=JW.Reader,this._newUsername=``,this._newPassword=``,this._newEmail=``,this._isAdding=!1,this._isCreating=!1}},s0=class{_isRemoving=!1;constructor(e,t,n,r){this.context=e,this.permissionService=t,this.data=n,this.onRemoved=r,f(this,{},{autoBind:!0})}get id(){return this.data.id}get userId(){return this.data.user.id}get username(){return this.data.user.username??null}get email(){return this.data.user.email??null}get displayName(){return this.username||this.email||this.userId}get roleId(){return this.data.role.id}get roleName(){return this.data.role.name}get isOwner(){return this.roleId===JW.OrganizationOwner}get canRemove(){return this.isOwner?!1:this.permissionService.can(`delete`,`User`,{organizationId:this.context.organizationId})}get isRemoving(){return this._isRemoving}async remove(){if(!this._isRemoving){this._isRemoving=!0;try{let e=await Q.removeUserFromOrganization({organizationId:this.context.organizationId,userId:this.userId});c(()=>{e.removeUserFromOrganization&&this.onRemoved()})}catch(e){console.error(`Failed to remove member:`,e)}finally{c(()=>{this._isRemoving=!1})}}}},c0=function(e){return e.loading=`loading`,e.empty=`empty`,e.list=`list`,e.error=`error`,e}(c0||{}),l0=class{state=c0.loading;getMembersRequest=X.of(Q.getUsersOrganization,{skipResetting:!0});_items=[];_hasNextPage=!1;_endCursor=null;_totalCount=null;_isInitialLoad=!0;addMemberModal;constructor(e,t,n){this.context=e,this.permissionService=t,f(this,{},{autoBind:!0}),this.addMemberModal=new o0(e,n,this.handleMemberAdded)}get canAddMember(){return this.permissionService.can(`add`,`User`,{organizationId:this.context.organizationId})}get showInitialLoading(){return this.state===c0.loading&&this._isInitialLoad}get showError(){return this.state===c0.error}get showNoMembers(){return this.state===c0.empty&&this._totalCount===0}get showList(){return this.state===c0.list}get items(){return this._items}get totalCount(){return this._totalCount??0}get hasNextPage(){return this._hasNextPage}get isLoading(){return this.getMembersRequest.isLoading}init(){this.loadInitial()}dispose(){this.addMemberModal.dispose()}async tryToFetchNextPage(){if(!this._hasNextPage||this.isLoading||!this._endCursor)return;let e=await this.getMembersRequest.fetch({organizationId:this.context.organizationId,first:50,after:this._endCursor});c(()=>{if(e.isRight){let t=e.data.usersOrganization.edges.map(e=>this.createItemViewModel(e.node));this._items=[...this._items,...t],this._hasNextPage=e.data.usersOrganization.pageInfo.hasNextPage,this._endCursor=e.data.usersOrganization.pageInfo.endCursor??null}})}createItemViewModel(e){return new s0(this.context,this.permissionService,e,this.handleMemberRemoved)}handleMemberAdded=()=>{this._totalCount!==null&&this._totalCount++,this.reload()};handleMemberRemoved=()=>{this._totalCount!==null&&this._totalCount--,this.reload()};async reload(){this._items=[],this._hasNextPage=!1,this._endCursor=null,this._isInitialLoad=!1,this.state=c0.loading,await this.loadInitial()}async loadInitial(){let e=await this.getMembersRequest.fetch({organizationId:this.context.organizationId,first:50});if(!e.isRight){if(qV(e))return;c(()=>{this.state=c0.error});return}c(()=>{this._items=e.data.usersOrganization.edges.map(e=>this.createItemViewModel(e.node)),this._hasNextPage=e.data.usersOrganization.pageInfo.hasNextPage,this._endCursor=e.data.usersOrganization.pageInfo.endCursor??null,this._totalCount=e.data.usersOrganization.totalCount,this._items.length>0?this.state=c0.list:this.state=c0.empty})}};Y.register(l0,()=>new l0(Y.get(U1),Y.get(vW),Y.get(yW)),{scope:`request`});var u0=[JW.OrganizationAdmin,JW.Developer,JW.Editor,JW.Reader],d0={[JW.OrganizationOwner]:`Owner`,[JW.OrganizationAdmin]:`Admin`,[JW.Developer]:`Developer`,[JW.Editor]:`Editor`,[JW.Reader]:`Reader`},f0=g(({value:e,onChange:t,disabled:n})=>(0,I.jsx)(Qe,{size:`sm`,width:`120px`,...n&&{opacity:.5,pointerEvents:`none`},children:(0,I.jsx)(Xe,{value:e,onChange:e=>t(e.target.value),children:u0.map(e=>(0,I.jsx)(`option`,{value:e,children:d0[e]},e))})})),p0=g(({model:e})=>(0,I.jsx)(lJ,{model:e,title:`Add Member to Organization`,roleSelect:(0,I.jsx)(f0,{value:e.selectedRole,onChange:e.setSelectedRole})})),m0=g(({model:e})=>(0,I.jsx)(cJ,{model:e,roleSlot:(0,I.jsx)(k,{fontSize:`sm`,color:`newGray.500`,minWidth:`80px`,children:e.roleName})})),h0=g(()=>{let e=CB(l0);return(0,I.jsx)(uJ,{model:e,sidebar:(0,I.jsx)(e0,{}),label:`Members`,emptyTitle:`No members in this organization`,emptySubtitle:`Add team members to collaborate in this organization`,subtitle:`Manage team members and their access levels for this organization.`,onAddClick:()=>e.addMemberModal.open(),modal:(0,I.jsx)(p0,{model:e.addMemberModal}),children:e.items.map(e=>(0,I.jsx)(m0,{model:e},e.id))})}),g0=e=>e.toLocaleString(`en-US`),_0=e=>e>=1073741824?`${(e/1073741824).toFixed(1)} GB`:e>=1048576?`${(e/1048576).toFixed(1)} MB`:`${(e/1024).toFixed(1)} KB`,v0=e=>e==null?`Unlimited`:e.toLocaleString(`en-US`),y0=e=>e==null?`Unlimited`:e>=1073741824?`${(e/1073741824).toFixed(0)} GB`:e>=1048576?`${(e/1048576).toFixed(0)} MB`:`${(e/1024).toFixed(0)} KB`,b0=class{constructor(e,t){this.plan=e,this.parent=t,f(this,{},{autoBind:!0})}get id(){return this.plan.id}get name(){return this.plan.name}get price(){let e=this.parent.billingInterval===`yearly`,t=e?this.plan.yearlyPriceUsd:this.plan.monthlyPriceUsd;return t===0?`Free`:`$${t}/${e?`yr`:`mo`}`}get isCurrent(){return!!(this.plan.id===this.parent.currentPlanId||this.parent.isFree&&this.plan.monthlyPriceUsd===0)}get canUpgrade(){return!this.isCurrent&&this.plan.monthlyPriceUsd>0}get canDowngrade(){return!this.isCurrent&&this.plan.monthlyPriceUsd===0&&!this.parent.isFree}get earlyAccessAvailable(){return this.features.earlyAccessAvailable===!0}get buttonLabel(){return this.canUpgrade?this.earlyAccessAvailable?`Get Early Access`:`Upgrade`:this.canDowngrade?`Downgrade`:`Current Plan`}get buttonDisabled(){return!this.canUpgrade&&!this.canDowngrade}get projectsLimit(){return v0(this.plan.limits.projects)}get membersLimit(){return v0(this.plan.limits.seats)}get rowVersionsLimit(){return v0(this.plan.limits.rowVersions)}get storageLimit(){return y0(this.plan.limits.storageBytes)}get endpointsPerProjectLimit(){return v0(this.plan.limits.endpointsPerProject)}async handleClick(){this.canUpgrade?this.earlyAccessAvailable?await this.parent.activateEarlyAccess(this.plan.id):await this.parent.createCheckout(this.plan.id):this.canDowngrade&&await this.parent.cancelSubscription()}get features(){let e=this.plan.features;return typeof e==`object`&&e&&!Array.isArray(e)?e:{}}},x0={number:g0,storage:_0},S0=class{constructor(e,t,n,r=null){this.metric=e,this._label=t,this.formatMode=n,this._tooltip=r,f(this)}get label(){return this._label}get tooltip(){return this._tooltip}get current(){return x0[this.formatMode](this.metric.current)}get limit(){return this.metric.limit===null||this.metric.limit===void 0?`Unlimited`:x0[this.formatMode](this.metric.limit)}get isUnlimited(){return this.metric.limit===null||this.metric.limit===void 0}get percentage(){let e=this.metric.percentage??null;return e===null?null:Math.min(e,100)}get progressColor(){return this.percentage===null?`green`:this.percentage>90?`red`:this.percentage>70?`yellow`:`green`}},C0=`Total row versions across all projects. Each row change in a new revision creates a version. Unchanged rows in a new revision do not count.`,w0=class{dataRequest=X.of(e=>Q.getLimitsPageData({data:{organizationId:e}}),{skipResetting:!0});plansRequest=X.of(()=>Q.getLimitsPagePlans());earlyAccessRequest=X.of(Q.activateEarlyAccess);checkoutRequest=X.of(Q.createCheckout);cancelRequest=X.of(Q.cancelSubscription);billingInterval=`monthly`;isCancelDialogOpen=!1;constructor(e){this.context=e,f(this,{},{autoBind:!0})}get data(){return this.dataRequest.data}get plansData(){return this.plansRequest.data}get isLoading(){return this.dataRequest.isLoading&&!this.dataRequest.isLoaded}get isError(){return this.dataRequest.error!==null&&this.dataRequest.data===null}get billingEnabled(){return this.data?.configuration.billing.enabled??!1}get pageTitle(){return this.billingEnabled?`Billing`:`Usage`}get pageSubtitle(){return this.billingEnabled?`Plan, usage, and payment management.`:`Resource usage overview.`}get subscription(){return this.data?.organization.subscription??null}get usage(){return this.data?.organization.usage??null}get currentPlanId(){return this.subscription?.planId??``}get planStatus(){return this.subscription?.status??RW.Free}get isEarlyAdopter(){return this.planStatus===RW.EarlyAdopter}get isActive(){return this.planStatus===RW.Active}get isFree(){return this.planStatus===RW.Free}get isPastDue(){return this.planStatus===RW.PastDue}get isCancelled(){return this.planStatus===RW.Cancelled}get cancelAt(){return this.subscription?.cancelAt??null}get provider(){return this.subscription?.provider??null}get currentPeriodEnd(){return this.subscription?.currentPeriodEnd??null}get hasPaymentManagement(){return this.isActive||this.isPastDue}get statusTitle(){return this.isFree?`Free Plan`:this.isEarlyAdopter?`Pro Plan — Early Access`:this.isActive?`Pro Plan`:this.isPastDue?`Payment failed`:this.isCancelled?`Plan cancelled`:``}get statusSubtitle(){return this.isEarlyAdopter?`Free while in Early Access`:this.isActive&&this.currentPeriodEnd?`Renews ${new Date(this.currentPeriodEnd).toLocaleDateString()}`:this.isPastDue?`Please update your payment method`:this.isCancelled&&this.cancelAt?`Downgrades on ${new Date(this.cancelAt).toLocaleDateString()}`:null}get statusColor(){return this.isEarlyAdopter?`purple`:this.isActive?`green`:this.isPastDue?`orange`:this.isCancelled?`red`:`gray`}get usageItems(){let e=this.usage;return e?[new S0(e.rowVersions,`Row Versions`,`number`,C0),new S0(e.projects,`Projects`,`number`),new S0(e.seats,`Members`,`number`),new S0(e.storageBytes,`Storage`,`storage`)]:[]}get planItems(){return(this.plansData?.plans??[]).filter(e=>e.isPublic).map(e=>new b0(e,this))}setBillingInterval(e){this.billingInterval=e}async activateEarlyAccess(e){(await this.earlyAccessRequest.fetch({data:{organizationId:this.context.organizationId,planId:e}})).isRight&&this.reload()}async createCheckout(e){let t=await this.checkoutRequest.fetch({data:{organizationId:this.context.organizationId,planId:e,interval:this.billingInterval,successUrl:globalThis.location.href,cancelUrl:globalThis.location.href}});t.isRight&&(globalThis.location.href=t.data.createCheckout.checkoutUrl)}openCancelDialog(){this.isCancelDialogOpen=!0}closeCancelDialog(){this.isCancelDialogOpen=!1}async cancelSubscription(){(await this.cancelRequest.fetch({data:{organizationId:this.context.organizationId,cancelAtPeriodEnd:!0}})).isRight&&(c(()=>{this.isCancelDialogOpen=!1}),this.reload())}get isActionLoading(){return this.earlyAccessRequest.isLoading||this.checkoutRequest.isLoading||this.cancelRequest.isLoading}init(){this.dataRequest.fetch(this.context.organizationId),this.plansRequest.fetch()}dispose(){this.dataRequest.abort(),this.plansRequest.abort()}reload(){this.dataRequest.fetch(this.context.organizationId),this.plansRequest.fetch()}};Y.register(w0,()=>new w0(Y.get(U1)),{scope:`request`});var T0=g(({model:e})=>(0,I.jsxs)(P,{gap:2,children:[(0,I.jsx)(N,{size:`xs`,variant:e.billingInterval===`monthly`?`solid`:`outline`,onClick:()=>e.setBillingInterval(`monthly`),children:`Monthly`}),(0,I.jsx)(N,{size:`xs`,variant:e.billingInterval===`yearly`?`solid`:`outline`,onClick:()=>e.setBillingInterval(`yearly`),children:`Yearly`})]})),E0=g(({model:e})=>e.hasPaymentManagement?(0,I.jsxs)(A,{children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`600`,color:`gray.600`,mb:`0.5rem`,children:`Payment`}),(0,I.jsx)(A,{borderWidth:`1px`,borderColor:`gray.200`,borderRadius:`lg`,p:4,bg:`white`,children:(0,I.jsxs)(M,{align:`stretch`,gap:3,children:[e.provider&&(0,I.jsxs)(k,{fontSize:`sm`,color:`gray.600`,children:[`Provider: `,e.provider]}),(0,I.jsxs)(Ue,{open:e.isCancelDialogOpen,onOpenChange:t=>t.open?e.openCancelDialog():e.closeCancelDialog(),children:[(0,I.jsx)(N,{variant:`outline`,colorPalette:`red`,size:`sm`,alignSelf:`flex-start`,onClick:e.openCancelDialog,children:`Cancel Subscription`}),(0,I.jsxs)(R,{children:[(0,I.jsx)(pe,{}),(0,I.jsx)(ue,{children:(0,I.jsxs)(_n,{children:[(0,I.jsx)(Ge,{children:(0,I.jsx)(qe,{children:`Cancel Subscription`})}),(0,I.jsx)(be,{children:(0,I.jsx)(k,{children:`Your subscription will remain active until the end of the current billing period. After that, you'll be downgraded to the Free plan.`})}),(0,I.jsxs)(w,{children:[(0,I.jsx)(oe,{asChild:!0,children:(0,I.jsx)(N,{variant:`outline`,children:`Keep Subscription`})}),(0,I.jsx)(N,{colorPalette:`red`,onClick:e.cancelSubscription,disabled:e.isActionLoading,children:`Cancel Subscription`})]}),(0,I.jsx)(Ie,{})]})})]})]})]})})]}):null),D0=g(({model:e,parentModel:t})=>(0,I.jsx)(A,{borderWidth:`1px`,borderColor:e.isCurrent?`gray.400`:`gray.200`,borderRadius:`lg`,p:4,bg:`white`,flex:1,children:(0,I.jsxs)(M,{align:`start`,gap:3,children:[(0,I.jsxs)(P,{gap:2,children:[(0,I.jsx)(k,{fontSize:`md`,fontWeight:`600`,color:`gray.700`,children:e.name}),e.isCurrent&&(0,I.jsx)(It,{colorPalette:`gray`,variant:`subtle`,size:`sm`,children:`Current`})]}),(0,I.jsx)(k,{fontSize:`xl`,fontWeight:`700`,color:`gray.800`,children:e.price}),(0,I.jsxs)(M,{align:`start`,gap:1,children:[(0,I.jsxs)(k,{fontSize:`xs`,color:`gray.500`,children:[e.projectsLimit,` projects`]}),(0,I.jsxs)(k,{fontSize:`xs`,color:`gray.500`,children:[e.membersLimit,` members`]}),(0,I.jsxs)(k,{fontSize:`xs`,color:`gray.500`,children:[e.rowVersionsLimit,` row versions`]}),(0,I.jsxs)(k,{fontSize:`xs`,color:`gray.500`,children:[e.storageLimit,` storage`]}),(0,I.jsxs)(k,{fontSize:`xs`,color:`gray.500`,children:[e.endpointsPerProjectLimit,` endpoints / project`]})]}),(0,I.jsx)(N,{size:`sm`,variant:e.isCurrent?`outline`:`solid`,width:`100%`,disabled:e.buttonDisabled||t.isActionLoading,onClick:e.handleClick,children:e.buttonLabel})]})})),O0=g(({model:e})=>{if(!e.billingEnabled)return null;let t=e.statusColor;return(0,I.jsxs)(A,{borderWidth:`1px`,borderColor:`${t}.200`,borderRadius:`lg`,p:4,bg:`${t}.50`,children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`600`,color:`${t}.800`,children:e.statusTitle}),e.statusSubtitle&&(0,I.jsx)(k,{fontSize:`xs`,color:`${t}.600`,mt:1,children:e.statusSubtitle})]})}),k0=g(({model:e})=>(0,I.jsxs)(A,{borderWidth:`1px`,borderColor:`gray.200`,borderRadius:`lg`,p:4,bg:`white`,children:[(0,I.jsxs)(j,{justifyContent:`space-between`,alignItems:`center`,mb:2,children:[(0,I.jsxs)(P,{gap:1,children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`600`,color:`gray.600`,children:e.label}),e.tooltip&&(0,I.jsx)(Qq,{content:e.tooltip,showArrow:!0,contentProps:{maxWidth:`280px`},children:(0,I.jsx)(A,{fontSize:`14px`,color:`gray.400`,cursor:`help`,display:`flex`,alignItems:`center`,children:(0,I.jsx)(Qte,{})})})]}),e.isUnlimited&&(0,I.jsx)(It,{colorPalette:`green`,variant:`subtle`,size:`sm`,children:`Unlimited`})]}),(0,I.jsx)(k,{fontSize:`lg`,fontWeight:`600`,color:`gray.800`,mb:e.isUnlimited?0:2,children:e.isUnlimited?e.current:`${e.current} / ${e.limit}`}),!e.isUnlimited&&e.percentage!==null&&(0,I.jsx)(ie,{value:e.percentage,size:`sm`,colorPalette:e.progressColor,borderRadius:`full`,children:(0,I.jsx)(de,{children:(0,I.jsx)(Ae,{})})})]})),A0=g(()=>{let e=CB(w0);return e.isLoading?(0,I.jsx)(Vq,{sidebar:(0,I.jsx)(e0,{}),children:(0,I.jsx)(M,{flex:1,justifyContent:`center`,py:`4rem`,children:(0,I.jsx)(Ht,{size:`md`,color:`gray.400`})})}):e.isError?(0,I.jsx)(Vq,{sidebar:(0,I.jsx)(e0,{}),children:(0,I.jsxs)(M,{flex:1,justifyContent:`center`,gap:`8px`,color:`gray.400`,py:`4rem`,children:[(0,I.jsx)(k,{fontSize:`md`,children:`Could not load usage data`}),(0,I.jsx)(k,{fontSize:`sm`,children:`Please retry later`})]})}):(0,I.jsx)(Vq,{sidebar:(0,I.jsx)(e0,{}),children:(0,I.jsx)(A,{maxWidth:`700px`,width:`100%`,mb:`4rem`,children:(0,I.jsxs)(M,{align:`stretch`,gap:`2rem`,children:[(0,I.jsxs)(A,{children:[(0,I.jsx)(k,{fontSize:`20px`,fontWeight:`600`,color:`newGray.500`,mb:1,children:e.pageTitle}),(0,I.jsx)(k,{fontSize:`xs`,color:`newGray.400`,children:e.pageSubtitle})]}),(0,I.jsx)(O0,{model:e}),(0,I.jsxs)(A,{children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`600`,color:`gray.600`,mb:3,children:`Usage`}),(0,I.jsx)(j,{gap:3,flexWrap:`wrap`,children:e.usageItems.map(e=>(0,I.jsx)(A,{flex:`1`,minWidth:`150px`,children:(0,I.jsx)(k0,{model:e})},e.label))})]}),e.billingEnabled&&e.planItems.length>0&&(0,I.jsxs)(A,{children:[(0,I.jsxs)(j,{justifyContent:`space-between`,alignItems:`center`,mb:3,children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`600`,color:`gray.600`,children:`Plans`}),(0,I.jsx)(T0,{model:e})]}),(0,I.jsx)(j,{gap:3,flexWrap:`wrap`,children:e.planItems.map(t=>(0,I.jsx)(D0,{model:t,parentModel:e},t.id))})]}),e.billingEnabled&&(0,I.jsx)(E0,{model:e})]})})})}),j0=()=>(0,I.jsxs)(j,{alignItems:`center`,flex:1,gap:`1rem`,justifyContent:`center`,width:`100%`,height:`100%`,direction:`column`,children:[(0,I.jsx)(dp,{size:32,color:`gray`}),(0,I.jsx)(k,{color:`gray.400`,children:`Project not found`}),(0,I.jsx)(An,{to:`/`,children:(0,I.jsx)(mt,{fontSize:`sm`,children:`Go to home`})})]}),M0=({width:e})=>(0,I.jsxs)(j,{alignItems:`center`,height:`36px`,paddingX:`8px`,gap:`12px`,children:[(0,I.jsx)(sn,{height:`20px`,width:`20px`,borderRadius:`sm`}),(0,I.jsx)(sn,{height:`14px`,width:e,borderRadius:`sm`})]}),N0=({width:e})=>(0,I.jsx)(j,{alignItems:`center`,height:`36px`,paddingX:`8px`,children:(0,I.jsx)(sn,{height:`14px`,width:e,borderRadius:`sm`})}),P0=({projectName:e,organizationId:t})=>(0,I.jsxs)(M,{alignItems:`flex-start`,gap:0,width:`100%`,flex:1,children:[(0,I.jsx)(T$,{name:e,organizationName:t,roleName:null}),(0,I.jsx)(A,{width:`100%`,paddingY:`16px`,children:(0,I.jsx)(O,{borderColor:`newGray.100`})}),(0,I.jsxs)(j,{flexDirection:`column`,width:`100%`,gap:1,children:[(0,I.jsx)(M0,{width:`60px`}),(0,I.jsx)(N0,{width:`70px`}),(0,I.jsx)(M0,{width:`80px`}),(0,I.jsx)(M0,{width:`70px`}),(0,I.jsx)(M0,{width:`90px`}),(0,I.jsx)(M0,{width:`90px`}),(0,I.jsx)(N0,{width:`85px`}),(0,I.jsx)(N0,{width:`85px`})]}),(0,I.jsx)(T,{}),(0,I.jsx)(j,{flexDirection:`column`,width:`100%`,gap:1,children:(0,I.jsx)(IY,{})})]}),F0=150,I0=g(()=>{let e=Y.get(mQ),t=Y.get(pQ),[n,r]=(0,L.useState)(!1);return(0,L.useEffect)(()=>{if(!e.isInitLoading){r(!1);return}let t=setTimeout(()=>{r(!0)},F0);return()=>clearTimeout(t)},[e.isInitLoading]),e.isInitLoading?n?(0,I.jsx)(Vq,{sidebar:(0,I.jsx)(P0,{projectName:t.projectName??``,organizationId:t.organizationId??``})}):null:e.isProjectLoadFailed?(0,I.jsx)(j0,{}):(0,I.jsx)(En,{})}),L0=class{apiKeyManager;constructor(e,t,n,r){this.context=e,this.projectPermissions=t,this.permissionService=n,f(this,{},{autoBind:!0}),this.apiKeyManager=r;let i=this.projectPermissions.projectId??void 0;this.apiKeyManager.configure({mode:`service`,organizationId:this.context.organizationId,defaultProjectId:i,defaultProjectName:this.context.projectName,filterByProjectId:i})}get organizationId(){return this.context.organizationId}get projectName(){return this.context.projectName}get canManageServiceKeys(){let e=this.projectPermissions.projectId;return e?this.permissionService.can(`manage`,`ApiKey`,{projectId:e,organizationId:this.context.organizationId}):this.permissionService.can(`manage`,`ApiKey`,{organizationId:this.context.organizationId})}get organizationSettingsLink(){return`/app/${this.context.organizationId}/-/settings`}init(){}dispose(){this.apiKeyManager.dispose()}};Y.register(L0,()=>new L0(Y.get(mQ),Y.get(bW),Y.get(vW),Y.get(MY)),{scope:`request`});var R0=g(()=>{let e=CB(L0);return(0,I.jsx)(Vq,{sidebar:(0,I.jsx)(i1,{}),children:(0,I.jsx)(A,{maxWidth:`600px`,width:`100%`,mb:`4rem`,children:(0,I.jsxs)(M,{align:`stretch`,gap:`2rem`,children:[(0,I.jsxs)(A,{children:[(0,I.jsx)(k,{fontSize:`20px`,fontWeight:`600`,color:`newGray.500`,mb:1,children:`API Keys`}),(0,I.jsx)(k,{fontSize:`xs`,color:`newGray.400`,children:`Service keys scoped to this project for automated integrations.`})]}),e.canManageServiceKeys?(0,I.jsxs)(A,{children:[(0,I.jsx)(kY,{model:e.apiKeyManager}),(0,I.jsx)(mt,{asChild:!0,fontSize:`xs`,color:`gray.500`,mt:3,display:`inline-flex`,alignItems:`center`,children:(0,I.jsxs)(An,{to:e.organizationSettingsLink,children:[`Manage all organization keys`,(0,I.jsx)(uf,{style:{marginLeft:`4px`}})]})})]}):(0,I.jsxs)(A,{p:6,textAlign:`center`,borderWidth:`1px`,borderColor:`gray.200`,borderRadius:`lg`,bg:`gray.50`,children:[(0,I.jsx)(k,{fontSize:`sm`,color:`gray.500`,mb:2,children:`No API keys scoped to this project.`}),(0,I.jsx)(mt,{asChild:!0,fontSize:`xs`,color:`blue.500`,children:(0,I.jsxs)(An,{to:e.organizationSettingsLink,children:[`Contact an organization admin to manage API keys`,(0,I.jsx)(uf,{style:{marginLeft:`4px`}})]})})]})]})})})}),z0=[`B`,`KB`,`MB`,`GB`,`TB`,`PB`],B0=1024n;function V0(e){return`${BigInt(e).toLocaleString(`en-US`)} bytes`}function H0(e){let t=BigInt(e);if(t===0n)return`0 B`;let n=t<0n?-t:t,r=0,i=1n;for(;n>=i*B0&&r<z0.length-1;)i*=B0,r+=1;if(r===0)return`${t.toLocaleString(`en-US`)} ${z0[r]}`;let a=n*10n/i,o=a/10n,s=a%10n;return`${t<0n?`-`:``}${o.toLocaleString(`en-US`)}.${s.toString()} ${z0[r]}`}function U0(e){return`${H0(e)} (${V0(e)})`}function W0(e){if(e instanceof Pn){let t=e.response.errors?.[0];if(t?.message)return t.message}return e instanceof Error&&e.message?e.message:`Request failed`}var G0=class{validateRequest=X.of(e=>Q.adminValidateProjectFileBytes({data:{projectId:e}}));previewRestoreRequest=X.of(e=>Q.adminRestoreProjectFileBytes({data:{projectId:e,dryRun:!0}}));applyRestoreRequest=X.of(e=>Q.adminRestoreProjectFileBytes({data:{projectId:e,dryRun:!1}}));disposer;_restoreDialogOpen=!1;_restoreError=null;constructor(e,t){this.projectPermissions=e,this.permissionService=t,f(this,{},{autoBind:!0}),this.disposer=s(()=>this.projectPermissions.projectId,e=>{c(()=>{this._restoreDialogOpen=!1,this._restoreError=null}),this.previewRestoreRequest.abort(),this.applyRestoreRequest.abort(),e&&this.validate()},{fireImmediately:!0})}get report(){return this.validateRequest.data?.adminValidateProjectFileBytes??null}get preview(){return this.previewRestoreRequest.data?.adminRestoreProjectFileBytes??null}get isLoading(){return this.validateRequest.isLoading&&!this.validateRequest.isLoaded}get isRefreshing(){return this.validateRequest.isLoading&&this.validateRequest.isLoaded}get isPreviewLoading(){return this.previewRestoreRequest.isLoading}get isApplyingRestore(){return this.applyRestoreRequest.isLoading}get validateError(){return this.validateRequest.error?W0(this.validateRequest.error):null}get restoreError(){return this._restoreError}get hasManagePermission(){let e=this.projectPermissions.projectId,t=this.projectPermissions.organizationId;if(!e)return!1;let n={projectId:e};return t&&(n.organizationId=t),this.permissionService.can(`manage`,`FileUsage`,n)}get currentBytes(){return this.report?.currentFileBytes??`0`}get expectedBytes(){return this.report?.expectedFileBytes??`0`}get drift(){return this.report?.drift??`0`}get fileBlobCount(){return this.report?.fileBlobCount??0}get referenceCount(){return this.report?.referenceCount??0}get hasDrift(){return BigInt(this.drift)!==0n}get canRestore(){return this.hasDrift&&this.hasManagePermission}get restoreDialogOpen(){return this._restoreDialogOpen}get currentBytesLabel(){return U0(this.currentBytes)}get expectedBytesLabel(){return U0(this.expectedBytes)}get driftLabel(){return BigInt(this.drift)===0n?`0 B (0 bytes)`:`${H0(this.drift)} (${V0(this.drift)})`}get driftColor(){let e=BigInt(this.drift);return e===0n?`green.600`:e>0n?`orange.600`:`red.600`}get previewPreviousBytesLabel(){return U0(this.preview?.previousFileBytes??`0`)}get previewNextBytesLabel(){return U0(this.preview?.nextFileBytes??`0`)}get previewDriftLabel(){return!this.preview||BigInt(this.preview.drift)===0n?`0 B (0 bytes)`:`${H0(this.preview.drift)} (${V0(this.preview.drift)})`}openRestoreDialog(){this._restoreDialogOpen=!0}closeRestoreDialog(){this._restoreDialogOpen=!1,this._restoreError=null,this.previewRestoreRequest.abort(),this.applyRestoreRequest.abort()}async validate(){let e=this.projectPermissions.projectId;if(!e||!this.hasManagePermission)return;let t=await this.validateRequest.fetch(e);!t.isRight&&qV(t)}async previewRestore(){let e=this.projectPermissions.projectId;if(!e||!this.canRestore)return;c(()=>{this._restoreDialogOpen=!0,this._restoreError=null});let t=await this.previewRestoreRequest.fetch(e);if(!t.isRight){if(qV(t))return;c(()=>{this._restoreError=W0(t.error)})}}async applyRestore(){let e=this.projectPermissions.projectId;if(!e||!this.preview||!this.canRestore)return;c(()=>{this._restoreError=null});let t=await this.applyRestoreRequest.fetch(e);if(!t.isRight){if(qV(t))return;c(()=>{this._restoreError=W0(t.error)});return}c(()=>{this._restoreDialogOpen=!1,this._restoreError=null}),Jq.success({description:`Project file usage restored successfully`}),await this.validate()}init(){}dispose(){this.disposer(),this.validateRequest.abort(),this.previewRestoreRequest.abort(),this.applyRestoreRequest.abort()}};Y.register(G0,()=>new G0(Y.get(bW),Y.get(vW)),{scope:`request`});var K0=class{isDeleteDialogOpen=!1;deleteConfirmationText=``;updateRequest=X.of(Q.updateProject);deleteRequest=X.of(Q.deleteProjectForSettings);apiKeyManager;constructor(e,t,n,r,i,a){this.context=e,this.routerService=t,this.projectPermissions=n,this.permissionService=r,this.linkMaker=i,f(this,{},{autoBind:!0}),this.apiKeyManager=a;let o=this.projectPermissions.projectId??void 0;this.apiKeyManager.configure({mode:`service`,organizationId:this.context.organizationId,defaultProjectId:o,defaultProjectName:this.context.projectName,filterByProjectId:o})}get endpointsLink(){return this.linkMaker.makeEndpointsLink()}get canManageServiceKeys(){let e=this.projectPermissions.projectId;return e?this.permissionService.can(`manage`,`ApiKey`,{projectId:e,organizationId:this.context.organizationId}):this.permissionService.can(`manage`,`ApiKey`,{organizationId:this.context.organizationId})}get canManageFileUsage(){let e=this.projectPermissions.projectId;return e?this.permissionService.can(`manage`,`FileUsage`,{projectId:e,organizationId:this.context.organizationId}):!1}get organizationSettingsLink(){return`/app/${this.context.organizationId}/-/settings`}get canUpdateProject(){return this.projectPermissions.canUpdateProject}get hasDeletePermission(){return this.projectPermissions.canDeleteProject}get isPublic(){return this.context.isProjectPublic}get projectName(){return this.context.projectName}async setIsPublic(e){(await this.updateRequest.fetch({data:{isPublic:e,projectName:this.context.projectName,organizationId:this.context.organizationId}})).isRight&&(this.context.updateProject({isPublic:e}),Jq.info({duration:1500,description:e?`Project is now public`:`Project is now private`}))}openDeleteDialog(){this.isDeleteDialogOpen=!0,this.deleteConfirmationText=``}closeDeleteDialog(){this.isDeleteDialogOpen=!1,this.deleteConfirmationText=``}setDeleteConfirmationText(e){this.deleteConfirmationText=e}get canDeleteProject(){return this.deleteConfirmationText===this.projectName}async deleteProject(){if(this.canDeleteProject)try{(await this.deleteRequest.fetch({data:{organizationId:this.context.organizationId,projectName:this.context.projectName}})).isRight&&(this.closeDeleteDialog(),await this.routerService.navigate(`/`))}catch(e){console.error(e)}}init(){}dispose(){this.updateRequest.abort(),this.deleteRequest.abort(),this.apiKeyManager.dispose()}};Y.register(K0,()=>new K0(Y.get(mQ),Y.get(X9),Y.get(bW),Y.get(vW),Y.get(hQ),Y.get(MY)),{scope:`request`});var q0=({label:e,value:t,color:n=`gray.800`})=>(0,I.jsxs)(A,{borderWidth:`1px`,borderColor:`gray.200`,borderRadius:`lg`,bg:`white`,p:4,children:[(0,I.jsx)(k,{fontSize:`xs`,fontWeight:`600`,color:`gray.500`,mb:2,children:e}),(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`600`,color:n,children:t})]}),J0=g(({model:e})=>(0,I.jsxs)(A,{children:[(0,I.jsxs)(P,{justify:`space-between`,align:`center`,mb:3,children:[(0,I.jsxs)(A,{children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`600`,color:`gray.600`,children:`File Usage`}),(0,I.jsx)(k,{fontSize:`xs`,color:`gray.500`,mt:1,children:`Validate tracked file bytes and preview a restore before applying it.`})]}),(0,I.jsx)(N,{variant:`outline`,size:`sm`,onClick:e.validate,loading:e.isLoading||e.isRefreshing,disabled:e.isLoading,children:`Refresh`})]}),(0,I.jsx)(A,{borderWidth:`1px`,borderColor:`gray.200`,borderRadius:`lg`,bg:`gray.50`,p:4,children:e.isLoading?(0,I.jsxs)(P,{gap:3,children:[(0,I.jsx)(Ht,{size:`sm`,color:`gray.400`}),(0,I.jsx)(k,{fontSize:`sm`,color:`gray.600`,children:`Loading file usage…`})]}):(0,I.jsxs)(M,{align:`stretch`,gap:4,children:[(0,I.jsxs)(Se,{templateColumns:{base:`1fr`,md:`repeat(2, minmax(0, 1fr))`},gap:3,children:[(0,I.jsx)(q0,{label:`Current Bytes`,value:e.currentBytesLabel}),(0,I.jsx)(q0,{label:`Expected Bytes`,value:e.expectedBytesLabel}),(0,I.jsx)(q0,{label:`Drift`,value:e.driftLabel,color:e.driftColor}),(0,I.jsx)(q0,{label:`File Blobs`,value:e.fileBlobCount.toLocaleString(`en-US`)}),(0,I.jsx)(q0,{label:`References`,value:e.referenceCount.toLocaleString(`en-US`)})]}),e.validateError&&(0,I.jsx)(k,{fontSize:`sm`,color:`red.600`,children:e.validateError}),e.canRestore&&(0,I.jsxs)(P,{justify:`space-between`,align:`center`,flexWrap:`wrap`,gap:3,children:[(0,I.jsx)(k,{fontSize:`sm`,color:`gray.600`,children:`Drift detected. Preview the restore before applying any changes.`}),(0,I.jsx)(N,{size:`sm`,colorPalette:`orange`,onClick:e.previewRestore,loading:e.isPreviewLoading,children:`Restore File Bytes`})]})]})}),(0,I.jsx)(Ue,{open:e.restoreDialogOpen,onOpenChange:({open:t})=>!t&&e.closeRestoreDialog(),children:(0,I.jsxs)(R,{children:[(0,I.jsx)(pe,{}),(0,I.jsx)(ue,{children:(0,I.jsxs)(_n,{children:[(0,I.jsx)(Ge,{children:(0,I.jsx)(qe,{children:`Restore Project File Bytes`})}),(0,I.jsx)(be,{children:(0,I.jsx)(M,{align:`stretch`,gap:4,children:e.isPreviewLoading?(0,I.jsxs)(P,{gap:3,children:[(0,I.jsx)(Ht,{size:`sm`,color:`gray.400`}),(0,I.jsx)(k,{fontSize:`sm`,color:`gray.600`,children:`Preparing restore preview…`})]}):(0,I.jsxs)(I.Fragment,{children:[e.preview&&(0,I.jsxs)(Se,{templateColumns:`1fr`,gap:3,children:[(0,I.jsx)(q0,{label:`Previous Bytes`,value:e.previewPreviousBytesLabel}),(0,I.jsx)(q0,{label:`Next Bytes`,value:e.previewNextBytesLabel}),(0,I.jsx)(q0,{label:`Drift`,value:e.previewDriftLabel})]}),e.restoreError&&(0,I.jsx)(k,{fontSize:`sm`,color:`red.600`,children:e.restoreError}),!e.restoreError&&e.preview&&(0,I.jsx)(k,{fontSize:`sm`,color:`gray.600`,children:`Confirm to apply the previewed restore.`})]})})}),(0,I.jsxs)(w,{children:[(0,I.jsx)(oe,{asChild:!0,children:(0,I.jsx)(N,{variant:`outline`,children:`Cancel`})}),(0,I.jsx)(N,{colorPalette:`orange`,onClick:e.applyRestore,disabled:!e.preview||e.isPreviewLoading||!!e.restoreError,loading:e.isApplyingRestore,children:`Confirm Restore`})]})]})})]})})]})),Y0=({isSelected:e,onClick:t,icon:n,title:r,description:i,details:a,disabled:o})=>(0,I.jsx)(A,{onClick:o?void 0:t,width:`100%`,p:4,borderWidth:`1px`,borderColor:e?`gray.400`:`gray.200`,borderRadius:`lg`,bg:`white`,cursor:o?`not-allowed`:`pointer`,opacity:o?.6:1,textAlign:`left`,transition:`all 0.2s`,_hover:o?{}:{borderColor:`gray.400`},children:(0,I.jsxs)(P,{gap:3,align:`flex-start`,children:[(0,I.jsx)(Te,{size:`32px`,bg:`gray.100`,flexShrink:0,children:(0,I.jsx)(Ve,{as:n,boxSize:4,color:`gray.500`})}),(0,I.jsxs)(M,{align:`start`,gap:1,flex:1,children:[(0,I.jsxs)(P,{gap:2,children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`600`,color:`gray.700`,children:r}),e&&(0,I.jsx)(k,{fontSize:`xs`,color:`gray.500`,fontWeight:`500`,children:`Current`})]}),(0,I.jsx)(k,{fontSize:`xs`,color:`gray.600`,children:i}),(0,I.jsx)(A,{mt:1,children:a})]})]})}),X0=g(()=>{let e=CB(K0),t=CB(G0);return(0,I.jsx)(Vq,{sidebar:(0,I.jsx)(i1,{}),children:(0,I.jsx)(A,{maxWidth:`600px`,width:`100%`,mb:`4rem`,children:(0,I.jsxs)(M,{align:`stretch`,gap:`2rem`,children:[(0,I.jsxs)(A,{children:[(0,I.jsx)(k,{fontSize:`20px`,fontWeight:`600`,color:`newGray.500`,mb:1,children:`Settings`}),(0,I.jsx)(k,{fontSize:`xs`,color:`newGray.400`,children:`Project configuration and access controls.`})]}),(0,I.jsxs)(_e,{gap:`1.5rem`,children:[(0,I.jsxs)(A,{children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`600`,color:`gray.600`,mb:`0.5rem`,children:`Project Name`}),(0,I.jsx)(k,{fontSize:`md`,fontWeight:`500`,color:`gray.800`,children:e.projectName})]}),(0,I.jsxs)(A,{children:[(0,I.jsxs)(P,{justify:`space-between`,align:`center`,mb:3,children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`600`,color:`gray.600`,children:`Visibility`}),(0,I.jsx)(mt,{asChild:!0,fontSize:`xs`,color:`gray.500`,children:(0,I.jsxs)(An,{to:e.endpointsLink,children:[`View Endpoints`,(0,I.jsx)(Ve,{as:uf,ml:1})]})})]}),(0,I.jsxs)(M,{gap:3,children:[(0,I.jsx)(Y0,{isSelected:!e.isPublic,onClick:()=>e.setIsPublic(!1),icon:kf,title:`Private`,description:`Only authorized users can access this project.`,disabled:!e.canUpdateProject,details:(0,I.jsx)(k,{fontSize:`xs`,color:`gray.500`,children:`All API operations require authentication.`})}),(0,I.jsx)(Y0,{isSelected:e.isPublic,onClick:()=>e.setIsPublic(!0),icon:_f,title:`Public`,description:`Anyone can view the project and read data.`,disabled:!e.canUpdateProject,details:(0,I.jsxs)(M,{align:`start`,gap:0,children:[(0,I.jsx)(k,{fontSize:`xs`,color:`gray.500`,children:`UI and API read operations — no authentication required`}),(0,I.jsx)(k,{fontSize:`xs`,color:`gray.500`,children:`API write operations — authentication required`})]})})]})]}),(0,I.jsxs)(A,{children:[(0,I.jsxs)(P,{justify:`space-between`,align:`center`,mb:3,children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`600`,color:`gray.600`,children:`API Keys`}),(0,I.jsx)(mt,{asChild:!0,fontSize:`xs`,color:`gray.500`,children:(0,I.jsxs)(An,{to:e.organizationSettingsLink,children:[`Manage all organization keys`,(0,I.jsx)(Ve,{as:uf,ml:1})]})})]}),(0,I.jsx)(k,{fontSize:`xs`,color:`gray.500`,mb:`1rem`,children:`Service keys scoped to this project.`}),e.canManageServiceKeys?(0,I.jsx)(kY,{model:e.apiKeyManager}):(0,I.jsxs)(A,{p:4,textAlign:`center`,borderWidth:`1px`,borderColor:`gray.200`,borderRadius:`lg`,bg:`gray.50`,children:[(0,I.jsx)(k,{fontSize:`sm`,color:`gray.500`,children:`You don't have permission to manage API keys for this project.`}),(0,I.jsx)(mt,{asChild:!0,fontSize:`xs`,color:`blue.500`,mt:2,display:`inline-block`,children:(0,I.jsx)(An,{to:e.organizationSettingsLink,children:`Contact an organization admin to manage API keys`})})]})]}),e.canManageFileUsage&&(0,I.jsx)(J0,{model:t}),e.hasDeletePermission&&(0,I.jsxs)(A,{children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`600`,color:`gray.600`,mb:`0.5rem`,children:`Danger Zone`}),(0,I.jsx)(A,{borderWidth:`1px`,borderColor:`red.200`,borderRadius:`md`,padding:`1rem`,bg:`red.50`,children:(0,I.jsxs)(M,{align:`stretch`,gap:`0.75rem`,children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`500`,color:`red.800`,children:`Delete this project`}),(0,I.jsx)(k,{fontSize:`sm`,color:`red.600`,children:`Once you delete a project, there is no going back. Please be certain.`}),(0,I.jsxs)(Ue,{open:e.isDeleteDialogOpen,onOpenChange:t=>t.open?e.openDeleteDialog():e.closeDeleteDialog(),children:[(0,I.jsx)(ce,{asChild:!0,children:(0,I.jsx)(N,{variant:`outline`,colorScheme:`red`,size:`sm`,alignSelf:`flex-start`,children:`Delete project`})}),(0,I.jsxs)(R,{children:[(0,I.jsx)(pe,{}),(0,I.jsx)(ue,{children:(0,I.jsxs)(_n,{children:[(0,I.jsx)(Ge,{children:(0,I.jsx)(qe,{children:`Delete Project`})}),(0,I.jsx)(be,{children:(0,I.jsxs)(M,{align:`stretch`,gap:`1rem`,children:[(0,I.jsxs)(k,{children:[`This action `,(0,I.jsx)(`strong`,{children:`cannot be undone`}),`. This will permanently delete the`,` `,(0,I.jsx)(`strong`,{children:e.projectName}),` project and all of its data.`]}),(0,I.jsxs)(A,{children:[(0,I.jsxs)(k,{fontSize:`sm`,fontWeight:`500`,mb:`0.5rem`,children:[`Please type "`,e.projectName,`" to confirm`]}),(0,I.jsx)(qt,{value:e.deleteConfirmationText,onChange:t=>e.setDeleteConfirmationText(t.target.value),placeholder:e.projectName})]})]})}),(0,I.jsxs)(w,{children:[(0,I.jsx)(oe,{asChild:!0,children:(0,I.jsx)(N,{variant:`outline`,children:`Cancel`})}),(0,I.jsx)(N,{colorScheme:`red`,disabled:!e.canDeleteProject,onClick:e.deleteProject,children:`I understand the consequences, delete this project`})]}),(0,I.jsx)(Ie,{})]})})]})]})]})})]})]})]})})})}),Z0=300,Q0=class{_isOpen=!1;_activeTab=`search`;_searchQuery=``;_searchResults=[];_selectedUserId=null;_selectedRole=YW.Reader;_newUsername=``;_newPassword=``;_newEmail=``;_isAdding=!1;_isCreating=!1;debounceTimeout=null;searchRequest=X.of(Q.searchUsers);constructor(e,t,n){this.context=e,this.systemPermissions=t,this.onUserAdded=n,f(this,{},{autoBind:!0})}get isOpen(){return this._isOpen}get activeTab(){return this._activeTab}get canCreateUser(){return this.systemPermissions.canCreateUser}get searchQuery(){return this._searchQuery}get searchResults(){return this._searchResults}get selectedUserId(){return this._selectedUserId}get selectedRole(){return this._selectedRole}get isSearching(){return this.searchRequest.isLoading}get canAddSelectedUser(){return this._selectedUserId!==null&&!this._isAdding}get isAdding(){return this._isAdding}get newUsername(){return this._newUsername}get newPassword(){return this._newPassword}get newEmail(){return this._newEmail}get isCreating(){return this._isCreating}get canCreateNewUser(){return this._newUsername.trim().length>0&&this._newPassword.length>=6&&!this._isCreating}open(){this._isOpen=!0,this.reset()}close(){this._isOpen=!1,this.reset()}setActiveTab(e){this._activeTab=e}setSearchQuery(e){this._searchQuery=e,this.debounceTimeout&&=(clearTimeout(this.debounceTimeout),null),e.trim()?this.debounceTimeout=setTimeout(()=>{this.search(),this.debounceTimeout=null},Z0):this._searchResults=[]}setSelectedUserId(e){this._selectedUserId=e}setSelectedRole(e){this._selectedRole=e}setNewUsername(e){this._newUsername=e}setNewPassword(e){this._newPassword=e}setNewEmail(e){this._newEmail=e}async search(){if(this._searchQuery.trim().length===0){this._searchResults=[];return}let e=await this.searchRequest.fetch({search:this._searchQuery,first:20});c(()=>{e.isRight&&(this._searchResults=e.data.searchUsers.edges.map(e=>({id:e.node.id,username:e.node.username??null,email:e.node.email??null})))})}async addSelectedUser(){if(!(!this._selectedUserId||this._isAdding)){this._isAdding=!0;try{let e=await Q.addUserToProject({organizationId:this.context.organizationId,projectName:this.context.projectName,userId:this._selectedUserId,roleId:this._selectedRole});c(()=>{e.addUserToProject&&(this.onUserAdded(),this.close())})}catch(e){console.error(`Failed to add user:`,e)}finally{c(()=>{this._isAdding=!1})}}}async createAndAddUser(){if(this.canCreateNewUser){this._isCreating=!0;try{if(!(await Q.createUser({username:this._newUsername.trim(),password:this._newPassword,email:this._newEmail.trim()||void 0,roleId:XW.SystemUser})).createUser)throw Error(`Failed to create user`);let e=(await Q.searchUsers({search:this._newUsername.trim(),first:1})).searchUsers.edges.find(e=>e.node.username===this._newUsername.trim());if(!e)throw Error(`Could not find newly created user`);let t=await Q.addUserToProject({organizationId:this.context.organizationId,projectName:this.context.projectName,userId:e.node.id,roleId:this._selectedRole});c(()=>{t.addUserToProject&&(this.onUserAdded(),this.close())})}catch(e){console.error(`Failed to create and add user:`,e)}finally{c(()=>{this._isCreating=!1})}}}dispose(){this.debounceTimeout&&=(clearTimeout(this.debounceTimeout),null)}reset(){this.debounceTimeout&&=(clearTimeout(this.debounceTimeout),null),this._activeTab=`search`,this._searchQuery=``,this._searchResults=[],this._selectedUserId=null,this._selectedRole=YW.Reader,this._newUsername=``,this._newPassword=``,this._newEmail=``,this._isAdding=!1,this._isCreating=!1}},$0=class{_isUpdating=!1;_isRemoving=!1;_roleId;constructor(e,t,n,r){this.context=e,this.projectPermissions=t,this.data=n,this.onRemoved=r,f(this,{},{autoBind:!0}),this._roleId=this.data.role.id}get id(){return this.data.id}get userId(){return this.data.user.id}get username(){return this.data.user.username??null}get email(){return this.data.user.email??null}get displayName(){return this.username||this.email||this.userId}get roleId(){return this._roleId}get roleName(){return this.data.role.name}get canUpdateRole(){return this.projectPermissions.canUpdateUser}get canRemove(){return this.projectPermissions.canDeleteUser}get isUpdating(){return this._isUpdating}get isRemoving(){return this._isRemoving}async updateRole(e){if(!(this._isUpdating||e===this._roleId)){this._isUpdating=!0;try{let t=await Q.updateUserProjectRole({organizationId:this.context.organizationId,projectName:this.context.projectName,userId:this.userId,roleId:e});c(()=>{t.updateUserProjectRole&&(this._roleId=e)})}catch(e){console.error(`Failed to update user role:`,e)}finally{c(()=>{this._isUpdating=!1})}}}async remove(){if(!this._isRemoving){this._isRemoving=!0;try{let e=await Q.removeUserFromProject({organizationId:this.context.organizationId,projectName:this.context.projectName,userId:this.userId});c(()=>{e.removeUserFromProject&&this.onRemoved()})}catch(e){console.error(`Failed to remove user:`,e)}finally{c(()=>{this._isRemoving=!1})}}}},e2=function(e){return e.loading=`loading`,e.empty=`empty`,e.list=`list`,e.error=`error`,e}(e2||{}),t2=class{state=e2.loading;getUsersRequest=X.of(Q.getUsersProject,{skipResetting:!0});_items=[];_hasNextPage=!1;_endCursor=null;_totalCount=null;_isInitialLoad=!0;addUserModal;constructor(e,t,n){this.context=e,this.projectPermissions=t,this.systemPermissions=n,f(this,{},{autoBind:!0}),this.addUserModal=new Q0(e,n,this.handleUserAdded)}get canAddUser(){return this.projectPermissions.canAddUser}get canAddMember(){return this.canAddUser}get canCreateUser(){return this.systemPermissions.canCreateUser}get showInitialLoading(){return this.state===e2.loading&&this._isInitialLoad}get showError(){return this.state===e2.error}get showNoUsers(){return this.state===e2.empty&&this._totalCount===0}get showNoMembers(){return this.showNoUsers}get showList(){return this.state===e2.list}get items(){return this._items}get totalCount(){return this._totalCount??0}get hasNextPage(){return this._hasNextPage}get isLoading(){return this.getUsersRequest.isLoading}init(){this.loadInitial()}dispose(){}async tryToFetchNextPage(){if(!this._hasNextPage||this.isLoading||!this._endCursor)return;let e=await this.getUsersRequest.fetch({organizationId:this.organizationId,projectName:this.projectName,first:50,after:this._endCursor});c(()=>{if(e.isRight){let t=e.data.usersProject.edges.map(e=>this.createItemViewModel(e.node));this._items=[...this._items,...t],this._hasNextPage=e.data.usersProject.pageInfo.hasNextPage,this._endCursor=e.data.usersProject.pageInfo.endCursor??null}})}get organizationId(){return this.context.organizationId}get projectName(){return this.context.projectName}createItemViewModel(e){return new $0(this.context,this.projectPermissions,e,this.handleUserRemoved)}handleUserAdded=()=>{this._totalCount!==null&&this._totalCount++,this.reload()};handleUserRemoved=()=>{this._totalCount!==null&&this._totalCount--,this.reload()};async reload(){this._items=[],this._hasNextPage=!1,this._endCursor=null,this._isInitialLoad=!1,this.state=e2.loading,await this.loadInitial()}async loadInitial(){let e=await this.getUsersRequest.fetch({organizationId:this.organizationId,projectName:this.projectName,first:50});c(()=>{e.isRight?(this._items=e.data.usersProject.edges.map(e=>this.createItemViewModel(e.node)),this._hasNextPage=e.data.usersProject.pageInfo.hasNextPage,this._endCursor=e.data.usersProject.pageInfo.endCursor??null,this._totalCount=e.data.usersProject.totalCount,this._items.length>0?this.state=e2.list:this.state=e2.empty):this.state=e2.error})}};Y.register(t2,()=>new t2(Y.get(mQ),Y.get(bW),Y.get(yW)),{scope:`request`});var n2={[YW.Developer]:`Developer`,[YW.Editor]:`Editor`,[YW.Reader]:`Reader`},r2=g(({value:e,onChange:t,disabled:n})=>(0,I.jsx)(Qe,{size:`sm`,width:`120px`,...n&&{opacity:.5,pointerEvents:`none`},children:(0,I.jsx)(Xe,{value:e,onChange:e=>t(e.target.value),children:Object.values(YW).map(e=>(0,I.jsx)(`option`,{value:e,children:n2[e]},e))})})),i2=g(({model:e})=>(0,I.jsx)(lJ,{model:e,title:`Add User to Project`,roleSelect:(0,I.jsx)(r2,{value:e.selectedRole,onChange:e.setSelectedRole})})),a2=g(({model:e})=>(0,I.jsx)(cJ,{model:e,disableRemove:e.isUpdating,roleSlot:(0,I.jsxs)(I.Fragment,{children:[e.isUpdating&&(0,I.jsx)(Ht,{size:`sm`}),e.canUpdateRole?(0,I.jsx)(r2,{value:e.roleId,onChange:t=>e.updateRole(t),disabled:e.isUpdating}):(0,I.jsx)(k,{fontSize:`sm`,color:`newGray.500`,minWidth:`80px`,children:e.roleName})]})})),o2=g(()=>{let e=CB(t2);return(0,I.jsx)(uJ,{model:e,sidebar:(0,I.jsx)(i1,{}),label:`Users`,emptyTitle:`No users in this project`,emptySubtitle:`Add team members to collaborate on this project`,subtitle:`Manage team members and their access levels for this project.`,onAddClick:()=>e.addUserModal.open(),modal:(0,I.jsx)(i2,{model:e.addUserModal}),children:e.items.map(e=>(0,I.jsx)(a2,{model:e},e.id))})}),s2=g(()=>{let e=b$().make({revisionIdOrTag:XJ});return(0,I.jsxs)(j,{alignItems:`center`,justifyContent:`center`,gap:`4px`,paddingY:`8px`,paddingX:`4px`,backgroundColor:`newGray.50`,borderRadius:`6px`,position:`sticky`,top:0,zIndex:4,children:[(0,I.jsx)(k,{color:`newGray.400`,fontSize:`16px`,fontWeight:`400`,children:`You are viewing a read-only revision`}),(0,I.jsx)(An,{to:e,children:(0,I.jsx)(k,{color:`newGray.500`,fontSize:`16px`,fontWeight:`500`,textDecoration:`underline`,children:`Go to draft revision`})})]})}),c2=class{_tableId=void 0;_rowId=void 0;constructor(e){this.linkMaker=e,f(this,{},{autoBind:!0})}get breadcrumbs(){let e=[];return e.push({title:`Database`,href:this.linkMaker.currentBaseLink,isCurrentPage:!this._tableId,dataTestId:`breadcrumb-branch-tables`}),this._tableId&&e.push({title:this._tableId,href:Dn(`${this.linkMaker.currentBaseLink}/${JJ}`,{tableId:this._tableId}),isCurrentPage:!this._rowId,dataTestId:`breadcrumb-table-${this._tableId}`}),e}init(e,t){this._tableId=e,this._rowId=t}dispose(){}};Y.register(c2,()=>new c2(Y.get(hQ)),{scope:`request`});var l2=g(({rowIdEditable:e,rowIdReadonly:t,onLastSegmentClick:n})=>{let{tableId:r,rowId:i}=bn(),a=Tn(),o=CB(c2,r,i),s=o.breadcrumbs.map(e=>({label:e.title,dataTestId:e.dataTestId}));return t&&s.push({label:t}),(0,I.jsx)(JN,{segments:s,highlightLast:!1,onSegmentClick:(e,t)=>{t===o.breadcrumbs.length-1&&n?n():t<o.breadcrumbs.length&&a(o.breadcrumbs[t].href)},editable:e})}),u2=g(({showTitle:e=!0})=>{let t=!Y.get(mQ).isDraftRevision;return(0,I.jsx)(Vq,{sidebar:(0,I.jsx)(i1,{}),title:e?(0,I.jsx)(l2,{}):void 0,children:(0,I.jsxs)(j,{flex:1,flexDirection:`column`,gap:`1rem`,position:`relative`,children:[t&&(0,I.jsx)(s2,{}),(0,I.jsx)(j,{flexDirection:`column`,gap:`0.5rem`,flex:1,children:(0,I.jsx)(En,{})})]})})}),d2=g(()=>{let e=!Y.get(mQ).isDraftRevision;return(0,I.jsx)(Vq,{sidebar:(0,I.jsx)(i1,{}),children:(0,I.jsxs)(j,{flex:1,flexDirection:`column`,position:`relative`,marginTop:`-12px`,children:[e&&(0,I.jsx)(s2,{}),(0,I.jsx)(En,{})]})})}),f2=class{isLoading=!1;constructor(e,t,n){this.authService=e,this.routerService=t,this.apiService=n,f(this)}async confirmEmailCode(e){e?(await this.request(e),await this.routerService.navigate(`/`)):console.error(`Invalid code`)}init(){}dispose(){}async request(e){this.setIsLoading(!0);try{let t=await this.apiService.client.confirmEmailCode({data:{code:e}});return await this.authService.afterLogin(t.confirmEmailCode.accessToken),!0}catch(e){console.error(e)}finally{this.setIsLoading(!1)}}setIsLoading(e){this.isLoading=e}};Y.register(f2,()=>new f2(Y.get(hJ),Y.get(X9),Y.get(dJ)),{scope:`request`});var p2=g(()=>{let[e]=wn({code:``}),t=CB(f2);return(0,L.useEffect)(()=>{t.confirmEmailCode(e.get(`code`))},[t,e]),t.isLoading?(0,I.jsx)(y,{w:`100%`,h:`100%`,children:(0,I.jsx)(Ht,{})}):null}),Hse=()=>null,m2=class{isLoading=!1;constructor(e,t){this.apiService=e,this.authService=t,f(this)}async login(e){e?await this.loginRequest(e):console.error(`Invalid code`)}dispose(){}init(){}async loginRequest(e){this.setIsLoading(!0);try{let t=await this.apiService.client.loginGithub({data:{code:e}});return await this.authService.afterLogin(t.loginGithub.accessToken),!0}catch(e){console.error(e)}finally{this.setIsLoading(!1)}}setIsLoading(e){this.isLoading=e}};Y.register(m2,()=>new m2(Y.get(dJ),Y.get(hJ)),{scope:`request`});var Use=async({request:e})=>{let t=new URL(e.url).searchParams,n=t.get(`code`),r=YV(XV(t.get(`state`)));if(!n)throw Error(`Invalid code`);return await Y.get(m2).login(n),Cn(r||`/`)},Wse=async e=>Q.login(e),Gse=()=>`${globalThis.location.origin}/${yJ}/${CJ}`,h2=(e,t)=>{let n=Gse(),r=`https://github.com/login/oauth/authorize?client_id=${e}&redirect_uri=${encodeURIComponent(n)}&scope=user:email`,i=ZV(t);i&&(r+=`&state=${encodeURIComponent(i)}`),globalThis.location.href=r},g2=()=>`${globalThis.location.origin}/${yJ}/${wJ}`,_2=(e,t)=>{let n=g2(),r=`https://accounts.google.com/o/oauth2/v2/auth?client_id=${e}&redirect_uri=${encodeURIComponent(n)}&response_type=code&scope=profile email`,i=ZV(t);i&&(r+=`&state=${encodeURIComponent(i)}`),globalThis.location.href=r},v2=class{isLoading=!1;form=new JV({emailOrUsername:``,password:``});constructor(e,t,n){this.authService=e,this.configurationService=t,this.routerService=n,f(this)}get availableSignUp(){return this.configurationService.availableSignUp}get disableSubmitButton(){return!this.form.isValid}get availableOauth(){return this.configurationService.availableGoogleOauth}get availableGoogleOauth(){return this.configurationService.availableGoogleOauth}get availableGithubOauth(){return this.configurationService.availableGithubOauth}toGoogleOauth(){_2(this.configurationService.googleOauthClientId,QV())}toGithubOauth(){h2(this.configurationService.githubOauthClientId,QV())}async submit(){await this.login()&&await this.routerService.navigate(QV()||`/`)}dispose(){}init(){}async login(){this.setIsLoading(!0);try{let e=await Wse({data:this.form.values});return await this.authService.afterLogin(e.login.accessToken),!0}catch(e){console.error(e)}finally{this.setIsLoading(!1)}}setIsLoading(e){this.isLoading=e}};Y.register(v2,()=>new v2(Y.get(hJ),Y.get(gJ),Y.get(X9)),{scope:`request`});var Kse=g(()=>{let e=CB(v2),t=(0,L.useCallback)(t=>{e.form.setValue(`emailOrUsername`,t.currentTarget.value)},[e.form]),n=(0,L.useCallback)(t=>{e.form.setValue(`password`,t.currentTarget.value)},[e.form]),r=(0,L.useCallback)(async()=>{await e.submit()},[e]),i=(0,L.useCallback)(()=>{e.toGithubOauth()},[e]),a=(0,L.useCallback)(()=>{e.toGoogleOauth()},[e]);return(0,I.jsxs)(Vq,{hideSidebar:!0,children:[e.availableSignUp&&(0,I.jsxs)(j,{width:`100%`,gap:`8px`,justifyContent:`flex-end`,children:[(0,I.jsx)(k,{color:`gray.300`,children:`New to Revisium?`}),(0,I.jsx)(An,{to:`/signup`,children:(0,I.jsx)(mt,{color:`gray.300`,alignSelf:`center`,children:`Sign up`})})]}),(0,I.jsx)(j,{alignItems:`center`,justifyContent:`center`,flex:1,children:(0,I.jsxs)(j,{flexDirection:`column`,width:`16rem`,gap:`1rem`,alignItems:`center`,children:[e.availableOauth&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(j,{flexDirection:`column`,gap:`2px`,children:[e.availableGithubOauth&&(0,I.jsx)(Hq,{icon:(0,I.jsx)(cf,{}),onClick:i,title:`Continue with Github`}),e.availableGoogleOauth&&(0,I.jsx)(Hq,{icon:(0,I.jsx)(lf,{}),onClick:a,title:`Continue with Google`})]}),(0,I.jsxs)(j,{width:`100%`,alignItems:`center`,gap:`16px`,children:[(0,I.jsx)(A,{backgroundColor:`gray.100`,flex:1,height:`1px`}),(0,I.jsx)(k,{color:`gray.300`,fontSize:`12px`,children:`OR`}),(0,I.jsx)(A,{backgroundColor:`gray.100`,flex:1,height:`1px`})]})]}),(0,I.jsx)(qq,{dataTestId:`login-emailOrUsername-input`,autoFocus:!0,height:`40px`,placeholder:`username or email`,value:e.form.values.emailOrUsername,onChange:t,onEnter:r}),(0,I.jsx)(qq,{dataTestId:`login-password-input`,height:`40px`,placeholder:`password`,type:`password`,value:e.form.values.password,onChange:n,onEnter:r}),(0,I.jsx)(A,{visibility:e.disableSubmitButton?`hidden`:`visible`,children:(0,I.jsx)(Hq,{onClick:r,isLoading:e.isLoading,title:`Login`})})]})})]})}),y2=class{async getProject(e,t){return(await Q.getProjectForLoader({data:{organizationId:e,projectName:t}})).project}};Y.register(y2,()=>new y2,{scope:`singleton`});var b2=class{constructor(e,t){this.authService=e,this.projectContext=t,f(this)}async logout(){this.projectContext.clear(),await this.authService.logout()}dispose(){}init(){}};Y.register(b2,()=>new b2(Y.get(hJ),Y.get(mQ)),{scope:`request`});var qse=g(()=>{let e=CB(b2),t=Tn();return(0,L.useEffect)(()=>{let n=!1;return e.logout().finally(()=>{n||t(`/${yJ}`)}).catch(()=>void 0),()=>{n=!0}},[e,t]),null}),x2=class{isCreatingProject=!1;constructor(e){this.systemPermissions=e,f(this,{},{autoBind:!0})}get canAccessAdmin(){return this.systemPermissions.canReadUser}toggleCreatingProject(){this.isCreatingProject=!this.isCreatingProject}init(){}dispose(){}};Y.register(x2,()=>new x2(Y.get(yW)),{scope:`request`});var S2=class extends rH{constructor(){super(Q.meProjectsList,{pageSize:100})}extractItems(e){return e.meProjects.edges.map(e=>e.node)}extractPageInfo(e){return{hasNextPage:e.meProjects.pageInfo.hasNextPage,endCursor:e.meProjects.pageInfo.endCursor||null,totalCount:e.meProjects.totalCount}}buildFetchArgs(e,t){return{data:{first:this.config.pageSize,after:t}}}};Y.register(S2,()=>new S2,{scope:`request`});var Jse=e=>Dn(`/app/${AJ}`,{organizationId:e}),Yse=class{constructor(e){this.project=e,f(this)}get id(){return this.project.id}get name(){return this.project.name}get organizationId(){return this.project.organizationId}get touched(){return this.project.rootBranch.touched}get organizationLink(){return Jse(this.project.organizationId)}get link(){return Dn(`/app/${AJ}/${PJ}/${zJ}/${qJ}`,{organizationId:this.project.organizationId,projectName:this.project.name,branchName:this.project.rootBranch.name,revisionIdOrTag:XJ})}},C2=class extends nH{getItemKey(e){return e.id}createItemViewModel(e){return new Yse(e)}};Y.register(C2,()=>new C2(Y.get(S2)),{scope:`request`});var Xse=({onCreate:e})=>(0,I.jsxs)(M,{flex:1,justifyContent:`center`,gap:`8px`,color:`gray.400`,children:[(0,I.jsx)(k,{fontSize:`md`,children:`No projects yet`}),e?(0,I.jsx)(mt,{fontSize:`sm`,color:`gray.500`,_hover:{color:`gray.600`},onClick:e,cursor:`pointer`,children:`Create your first project to get started`}):(0,I.jsx)(k,{fontSize:`sm`,children:`Create your first project to get started`})]}),Zse=g(({model:e})=>(0,I.jsx)(A,{height:`2.5rem`,width:`100%`,children:(0,I.jsx)(j,{_hover:{backgroundColor:`gray.50`},alignItems:`center`,gap:`4px`,paddingLeft:`1rem`,"data-testid":`project-${e.name}`,children:(0,I.jsx)(j,{alignItems:`center`,flex:1,justifyContent:`space-between`,minHeight:`40px`,children:(0,I.jsxs)(j,{minWidth:`150px`,children:[(0,I.jsxs)(j,{gap:`4px`,children:[(0,I.jsx)(k,{color:`gray.300`,_hover:{textDecoration:`underline`},children:(0,I.jsx)(An,{to:e.organizationLink,children:e.organizationId})}),(0,I.jsx)(k,{color:`gray.300`,children:`/`}),(0,I.jsx)(k,{_hover:{textDecoration:`underline`},children:(0,I.jsx)(An,{to:e.link,"data-testid":`project-${e.organizationId}-${e.name}-link`,children:e.name})})]}),e.touched&&`*`]})})})})),Qse=g(({onCreateProject:e})=>{let t=CB(C2);return t.showLoading?(0,I.jsx)(M,{flex:1,justifyContent:`center`,children:(0,I.jsx)(Ht,{size:`md`,color:`gray.400`})}):t.showError?(0,I.jsxs)(M,{flex:1,justifyContent:`center`,gap:`8px`,color:`gray.400`,children:[(0,I.jsx)(k,{fontSize:`md`,children:`Could not load projects`}),(0,I.jsx)(k,{fontSize:`sm`,children:`Please retry later`})]}):t.showEmpty?(0,I.jsx)(Xse,{onCreate:e}):t.showList?(0,I.jsx)(QM,{useWindowScroll:!0,totalCount:t.totalCount,defaultItemHeight:40,endReached:t.hasNextPage?t.tryToFetchNextPage:void 0,itemContent:e=>{let n=t.items[e];return n?(0,I.jsx)(Zse,{model:n},n.id):null}}):null}),$se=()=>(0,I.jsx)(j,{className:`group`,flexDirection:`column`,alignItems:`flex-start`,width:`100%`,minWidth:`0`,children:(0,I.jsxs)(j,{alignItems:`center`,gap:`8px`,padding:`4px`,width:`100%`,children:[(0,I.jsx)(k,{color:`newGray.400`,fontWeight:`600`,fontSize:`18px`,lineHeight:`26px`,children:`Revisium`}),(0,I.jsxs)(j,{gap:`4px`,children:[(0,I.jsx)(`a`,{href:`https://revisium.io`,target:`_blank`,rel:`noopener noreferrer`,children:(0,I.jsx)(j,{fontSize:`16px`,color:`newGray.400`,_hover:{color:`newGray.600`},cursor:`pointer`,alignItems:`center`,children:(0,I.jsx)(Jte,{})})}),(0,I.jsx)(`a`,{href:`https://github.com/revisium/revisium`,target:`_blank`,rel:`noopener noreferrer`,children:(0,I.jsx)(j,{fontSize:`16px`,color:`newGray.400`,_hover:{color:`newGray.600`},cursor:`pointer`,alignItems:`center`,children:(0,I.jsx)(qte,{})})})]}),(0,I.jsx)(T,{}),(0,I.jsx)(oJ,{})]})}),ece=g(()=>{let e=CB(x2);return(0,I.jsxs)(M,{alignItems:`flex-start`,gap:0,width:`100%`,flex:1,children:[(0,I.jsx)($se,{}),(0,I.jsx)(A,{width:`100%`,paddingY:`16px`,children:(0,I.jsx)(O,{borderColor:`newGray.100`})}),e.canAccessAdmin&&(0,I.jsx)(j,{flexDirection:`column`,width:`100%`,gap:1,children:(0,I.jsx)(An,{to:`/admin`,style:{textDecoration:`none`,width:`100%`},children:(0,I.jsxs)(j,{alignItems:`center`,backgroundColor:`transparent`,_hover:{backgroundColor:`newGray.100`},borderRadius:`8px`,height:`36px`,paddingX:`8px`,width:`100%`,color:`newGray.600`,fontWeight:`400`,textDecoration:`none`,fontSize:`14px`,minWidth:`0`,cursor:`pointer`,gap:`12px`,userSelect:`none`,children:[(0,I.jsx)(A,{fontSize:`20px`,color:`newGray.400`,children:(0,I.jsx)(Sf,{})}),(0,I.jsx)(A,{flex:`1`,minWidth:`0`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,overflow:`hidden`,children:`Admin`})]})})}),(0,I.jsx)(T,{}),(0,I.jsx)(j,{flexDirection:`column`,width:`100%`,gap:1,children:(0,I.jsx)(IY,{})})]})}),tce=g(()=>{let e=CB(x2);return(0,I.jsx)(Vq,{title:(0,I.jsx)(A,{height:`40px`}),sidebar:(0,I.jsx)(ece,{}),children:(0,I.jsx)(j,{flex:1,flexDirection:`column`,gap:`0.5rem`,paddingBottom:`1rem`,children:e.isCreatingProject?(0,I.jsx)(q1,{onComplete:e.toggleCreatingProject}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(H1,{onClick:e.toggleCreatingProject}),(0,I.jsx)(Qse,{onCreateProject:e.toggleCreatingProject})]})})})}),w2=class{getMigrationsRequest=X.of(Q.getMigrations,{skipResetting:!0});getBranchesRequest=X.of(Q.getMigrationBranches);getBranchMigrationsRequest=X.of(Q.getBranchMigrations);applyMigrationsRequest=X.of(Q.applyMigrations);async getMigrations(e){let t=await this.getMigrationsRequest.fetch({data:{revisionId:e}});return t.isRight?{...t,data:t.data.revision.migrations??[]}:t}async getBranches(e,t){let n=await this.getBranchesRequest.fetch({data:{organizationId:e,projectName:t,first:100}});return n.isRight?n.data.branches.edges.map(e=>{let t=e.node;return{id:t.id,name:t.name,isRoot:t.isRoot,headRevisionId:t.head.id,draftRevisionId:t.draft.id}}):null}async getBranchMigrations(e){let t=await this.getBranchMigrationsRequest.fetch({data:{revisionId:e}});return t.isRight?t.data.revision.migrations??[]:null}async applyMigrations(e,t){let n=await this.applyMigrationsRequest.fetch({data:{revisionId:e,migrations:t}});return n.isRight?n.data.applyMigrations:null}dispose(){this.getMigrationsRequest.abort(),this.getBranchesRequest.abort(),this.getBranchMigrationsRequest.abort(),this.applyMigrationsRequest.abort()}};Y.register(w2,()=>new w2,{scope:`request`});var T2=function(e){return e.Table=`table`,e.Json=`json`,e}({});function nce(e){let t=[];for(let n of e)if(n.changeType===`init`&&t.push({migrationId:n.id,tableId:n.tableId,patch:{op:`add`,path:`/`,value:n.schema},timestamp:n.id,parentMigration:n}),n.changeType===`update`&&n.patches){let e=Array.isArray(n.patches)?n.patches:[n.patches];for(let r of e)r&&typeof r==`object`&&`op`in r&&`path`in r&&t.push({migrationId:n.id,tableId:n.tableId,patch:r,timestamp:n.id,parentMigration:n})}return t}function rce(e,t){let n=new Set(t.map(e=>e.id)),r=t[t.length-1]?.id??``,i=!1;return e.map(e=>n.has(e.id)?{status:`skip`,migration:e,reason:`Already applied`}:i?{status:`blocked`,migration:e,reason:`Blocked by previous conflict`}:r&&e.id<=r?(i=!0,{status:`conflict`,migration:e,reason:`Migration ID must be after ${r}`}):{status:`apply`,migration:e})}function ice(e){return e.filter(e=>e.status===`apply`).map(e=>e.migration)}function ace(e){return e.some(e=>e.status===`conflict`)}function oce(e){return{toApply:e.filter(e=>e.status===`apply`).length,toSkip:e.filter(e=>e.status===`skip`).length,conflicts:e.filter(e=>e.status===`conflict`).length,blocked:e.filter(e=>e.status===`blocked`).length}}var E2=class{_isOpen=!1;_sourceMigrations=[];_diffResult=[];_viewMode=T2.Table;_applyResult=null;_isApplying=!1;_virtuosoRef=null;constructor(e,t,n,r){this.context=e,this.dataSource=t,this.existingMigrations=n,this.onApplied=r,h(this,{_isOpen:u,_sourceMigrations:u,_diffResult:u,_viewMode:u,_applyResult:u,_isApplying:u,isOpen:a,previewItems:a,migrationsToApply:a,hasConflict:a,canApply:a,summary:a,canRemoveLast:a,viewMode:a,isApplying:a,applyResult:a,applyResultSummary:a,failedResults:a,showResult:a,setViewMode:m.bound,setVirtuosoRef:m.bound,removeLastMigration:m.bound,apply:m.bound,close:m.bound,resetBase:m.bound})}get isOpen(){return this._isOpen}get previewItems(){return this._diffResult}get migrationsToApply(){return ice(this._diffResult)}get hasConflict(){return ace(this._diffResult)}get canApply(){return!this.hasConflict&&this.migrationsToApply.length>0&&!this._isApplying}get summary(){return oce(this._diffResult)}get canRemoveLast(){return this._sourceMigrations.length>0}get viewMode(){return this._viewMode}get isApplying(){return this._isApplying}get applyResult(){return this._applyResult}get applyResultSummary(){if(!this._applyResult)return null;let e=this._applyResult.filter(e=>e.status===LW.Applied).length,t=this._applyResult.filter(e=>e.status===LW.Skipped).length,n=this._applyResult.filter(e=>e.status===LW.Failed).length;return{applied:e,skipped:t,failed:n,hasFailures:n>0}}get failedResults(){return this._applyResult?this._applyResult.filter(e=>e.status===LW.Failed):[]}get showResult(){return this._applyResult!==null}setViewMode(e){this._viewMode=e}setVirtuosoRef(e){this._virtuosoRef=e}removeLastMigration(){this._sourceMigrations.length!==0&&(this._sourceMigrations=this._sourceMigrations.slice(0,-1),this.recalculateDiff())}copyFilteredJson(){navigator.clipboard.writeText(JSON.stringify(this.migrationsToApply,null,2))}async apply(){if(!this.canApply)return;this._isApplying=!0;let e=await this.dataSource.applyMigrations(this.context.revisionId,this.migrationsToApply);c(()=>{this._isApplying=!1,e&&(this._applyResult=e,e.every(e=>e.status!==LW.Failed)&&(this.context.updateTouched(!0),this.onApplied()))})}close(){this._isOpen=!1,this.reset()}dispose(){this.reset()}recalculateDiff(){this._diffResult=rce(this._sourceMigrations,this.existingMigrations),this.scrollToLast()}resetBase(){this._sourceMigrations=[],this._diffResult=[],this._applyResult=null,this._isApplying=!1,this._virtuosoRef=null}scrollToLast(){this._diffResult.length>0&&this._viewMode===T2.Table&&setTimeout(()=>{this._virtuosoRef?.scrollToIndex({index:this._diffResult.length-1,behavior:`auto`})},100)}},D2=class{constructor(e){this.create=e}},sce=class extends E2{_branches=[];_selectedBranchId=null;_selectedRevision=XJ;_isLoadingBranches=!1;_isLoadingMigrations=!1;constructor(e,t,n,r,i){super(e,t,n,r),this.currentBranchId=i,h(this,{_branches:u,_selectedBranchId:u,_selectedRevision:u,_isLoadingBranches:u,_isLoadingMigrations:u,branches:a,hasNoBranches:a,selectedBranchId:a,selectedBranch:a,selectedRevision:a,isLoadingBranches:a,isLoadingMigrations:a,setSelectedBranchId:m.bound,setSelectedRevision:m.bound,open:m.bound})}get branches(){return this._branches.filter(e=>e.id!==this.currentBranchId)}get hasNoBranches(){return this.branches.length===0&&!this._isLoadingBranches}get selectedBranchId(){return this._selectedBranchId}get selectedBranch(){return this._branches.find(e=>e.id===this._selectedBranchId)??null}get selectedRevision(){return this._selectedRevision}get isLoadingBranches(){return this._isLoadingBranches}get isLoadingMigrations(){return this._isLoadingMigrations}setSelectedBranchId(e){this._selectedBranchId=e,this._applyResult=null,e?this.loadMigrations():(this._sourceMigrations=[],this._diffResult=[])}setSelectedRevision(e){this._selectedRevision=e,this._applyResult=null,this._selectedBranchId&&this.loadMigrations()}async open(){this._isOpen=!0,await this.loadBranches()}reset(){this._selectedBranchId=null,this._selectedRevision=XJ,this._branches=[],this._isLoadingBranches=!1,this._isLoadingMigrations=!1,this.resetBase()}async loadBranches(){this._isLoadingBranches=!0;let e=await this.dataSource.getBranches(this.context.organizationId,this.context.projectName);c(()=>{this._isLoadingBranches=!1,this._branches=e??[]})}async loadMigrations(){let e=this.selectedBranch;if(!e)return;let t=this._selectedRevision===`head`?e.headRevisionId:e.draftRevisionId;this._isLoadingMigrations=!0;let n=await this.dataSource.getBranchMigrations(t);c(()=>{this._isLoadingMigrations=!1,this._sourceMigrations=n??[],this.recalculateDiff()})}};Y.register(D2,()=>new D2((e,t,n)=>new sce(Y.get(mQ),Y.get(w2),e,t,n)),{scope:`request`});var O2=class{constructor(e){this.create=e}},cce=class extends E2{_jsonInput=``;_parseError=null;constructor(e,t,n,r){super(e,t,n,r),h(this,{_jsonInput:u,_parseError:u,jsonInput:a,parseError:a,setJsonInput:m.bound,open:m.bound})}get jsonInput(){return this._jsonInput}get parseError(){return this._parseError}setJsonInput(e){this._jsonInput=e,this._applyResult=null,this.parseAndDiff()}removeLastMigration(){this._sourceMigrations.length!==0&&(this._sourceMigrations=this._sourceMigrations.slice(0,-1),this._jsonInput=JSON.stringify(this._sourceMigrations,null,2),this.recalculateDiff())}open(){this._isOpen=!0}reset(){this._jsonInput=``,this._parseError=null,this.resetBase()}parseAndDiff(){if(!this._jsonInput.trim()){this._parseError=null,this._sourceMigrations=[],this._diffResult=[];return}try{let e=JSON.parse(this._jsonInput);if(!Array.isArray(e)){this._parseError=`Input must be an array of migrations`,this._sourceMigrations=[],this._diffResult=[];return}this._parseError=null,this._sourceMigrations=e,this.recalculateDiff()}catch{this._parseError=`Invalid JSON format`,this._sourceMigrations=[],this._diffResult=[]}}};Y.register(O2,()=>new O2((e,t)=>new cce(Y.get(mQ),Y.get(w2),e,t)),{scope:`request`});function lce(e){if(e===``)return``;let t=e.startsWith(`/`)?e.slice(1):e;if(t===``)return``;let n=t.split(`/`),r=``,i=0;for(;i<n.length;){let e=n[i];if(e===`properties`){if(i++,i<n.length){let e=n[i];e&&(r&&(r+=`.`),r+=e)}}else e===`items`&&(r+=`[*]`);i++}return r}function k2(e){return lce(e)||e}function uce(e){let t=e.patch.value;return!t||typeof t!=`object`?null:`$ref`in t&&typeof t.$ref==`string`?t.$ref:`type`in t&&typeof t.type==`string`?t.type:null}function A2(e){return{text:e}}function j2(e){return{text:e,highlight:!0}}function dce(e){return{text:e,gray:!0}}function fce(e){let{op:t,path:n,from:r}=e.patch,i=e.tableId,a=k2(n);switch(t){case`add`:{if(n===`/`)return{icon:Lf,segments:[A2(`Table `),j2(i),A2(` was created`)]};let t=uce(e),r=t?[dce(` (${t})`)]:[];return{icon:Pf,segments:[A2(`Field `),j2(a),...r,A2(` was added to table `),j2(i)]}}case`remove`:return{icon:jf,segments:[A2(`Field `),j2(a),A2(` was removed from table `),j2(i)]};case`replace`:return{icon:Mf,segments:[A2(`Field `),j2(a),A2(` was modified in table `),j2(i)]};case`move`:if(r){let e=k2(r);return{icon:ff,segments:[A2(`Renamed field `),j2(e),A2(` to `),j2(a),A2(` in table `),j2(i)]}}return{icon:ff,segments:[A2(`Moved field to `),j2(a),A2(` in table `),j2(i)]};default:return{icon:Mf,segments:[A2(`Operation `),j2(t),A2(` on `),j2(a),A2(` in table `),j2(i)]}}}function pce(e,t){return{icon:rne,segments:[A2(`Table `),j2(e),A2(` was renamed to `),j2(t)]}}function mce(e){return{icon:Rf,segments:[A2(`Table `),j2(e),A2(` was removed`)]}}function hce(e){let{changeType:t}=e.parentMigration;switch(t){case`init`:return{icon:Lf,segments:[A2(`Table `),j2(e.tableId),A2(` was created`)]};case`update`:return fce(e);case`rename`:{let t=e.parentMigration.nextTableId;return pce(e.tableId,t)}case`remove`:return mce(e.tableId);default:return{icon:Mf,segments:[A2(`Unknown operation on table `),j2(e.tableId)]}}}var M2=class{constructor(e){this.create=e}},gce=class{_isPopoverOpen=!1;constructor(e){this.data=e,f(this,{},{autoBind:!0})}get id(){return`${this.data.migrationId}-${this.data.patch.path}`}get isPopoverOpen(){return this._isPopoverOpen}setPopoverOpen(e){this._isPopoverOpen=e}get fullPatchData(){return this.data.parentMigration}get relativeTime(){return xY(this.data.migrationId)}get description(){return hce(this.data)}get descriptionSegments(){return this.description.segments}get descriptionIcon(){return this.description.icon}};Y.register(M2,()=>new M2(e=>new gce(e)),{scope:`request`});var N2=function(e){return e.loading=`loading`,e.empty=`empty`,e.list=`list`,e.error=`error`,e}(N2||{}),P2=class{_state=N2.loading;_viewMode=T2.Table;_migrations=[];_revisionReaction=null;_applyDialog=null;_applyFromBranchDialog=null;constructor(e,t,n,r,i,a){this.context=e,this.projectPermissions=t,this.dataSource=n,this.applyDialogFactory=r,this.applyFromBranchDialogFactory=i,this.migrationItemFactory=a,f(this,{},{autoBind:!0})}get showLoading(){return this._state===N2.loading}get showError(){return this._state===N2.error}get showEmpty(){return this._state===N2.empty}get showList(){return this._state===N2.list}get data(){return this._migrations}get patchItems(){return nce(this._migrations).reverse().map(e=>this.migrationItemFactory.create(e))}get items(){return this.patchItems}get viewMode(){return this._viewMode}get isTableMode(){return this._viewMode===T2.Table}setViewMode(e){this._viewMode=e}get isEmpty(){return this._migrations.length===0}get totalCount(){return this.patchItems.length}get migrationsCount(){return this._migrations.length}get canApplyMigrations(){return this.projectPermissions.canCreateTable}get branchName(){return this.context.branchName}get applyDialog(){return this._applyDialog}get applyFromBranchDialog(){return this._applyFromBranchDialog}openApplyDialog(){this._applyDialog=this.applyDialogFactory.create(this._migrations,this.handleMigrationsApplied),this._applyDialog.open()}openApplyFromBranchDialog(){this._applyFromBranchDialog=this.applyFromBranchDialogFactory.create(this._migrations,this.handleMigrationsApplied,this.context.branchId),this._applyFromBranchDialog.open()}copyMigrationsJson(){navigator.clipboard.writeText(JSON.stringify(this._migrations,null,2))}init(){this.load(),this._revisionReaction=s(()=>this.context.revisionId,()=>{this.reset(),this.load()})}dispose(){this._revisionReaction?.(),this._revisionReaction=null,this._applyDialog?.dispose(),this._applyFromBranchDialog?.dispose(),this.dataSource.dispose()}async reload(){await this.load()}reset(){this._state=N2.loading,this._migrations=[]}async load(){let e=await this.dataSource.getMigrations(this.context.revisionId);if(!e.isRight){if(qV(e))return;c(()=>{this._state=N2.error});return}c(()=>{this._migrations=e.data,this._state=e.data.length>0?N2.list:N2.empty})}handleMigrationsApplied=()=>{this.reload()}};Y.register(P2,()=>new P2(Y.get(mQ),Y.get(bW),Y.get(w2),Y.get(O2),Y.get(D2),Y.get(M2)),{scope:`request`});var F2=g(({summary:e,failedResults:t})=>(0,I.jsxs)(M,{align:`stretch`,gap:3,p:4,bg:e.hasFailures?`red.50`:`green.50`,borderRadius:`md`,children:[(0,I.jsxs)(P,{children:[(0,I.jsx)(Ve,{as:e.hasFailures?sne:hf,color:e.hasFailures?`red.500`:`green.500`,boxSize:5}),(0,I.jsx)(k,{fontWeight:`500`,color:e.hasFailures?`red.700`:`green.700`,children:e.hasFailures?`Apply failed`:`Successfully applied`})]}),(0,I.jsxs)(P,{gap:4,children:[e.applied>0&&(0,I.jsxs)(k,{fontSize:`sm`,color:`green.600`,children:[e.applied,` applied`]}),e.skipped>0&&(0,I.jsxs)(k,{fontSize:`sm`,color:`gray.500`,children:[e.skipped,` skipped`]}),e.failed>0&&(0,I.jsxs)(k,{fontSize:`sm`,color:`red.600`,children:[e.failed,` failed`]})]}),t.map(e=>(0,I.jsx)(A,{p:2,bg:`red.100`,borderRadius:`sm`,children:(0,I.jsxs)(k,{fontSize:`sm`,color:`red.700`,children:[e.id,`: `,e.error]})},e.id))]})),_ce=({isSelected:e,onClick:t,icon:n,dataTestId:r})=>(0,I.jsx)(Ze,{"data-testid":r,_disabled:e?{backgroundColor:`newGray.100`,cursor:`not-allowed`}:void 0,_hover:{backgroundColor:`gray.50`},disabled:e,alignSelf:`flex-start`,variant:`ghost`,onClick:t,width:`48px`,size:`sm`,children:n}),vce=[{mode:T2.Table,icon:(0,I.jsx)(cp,{}),dataTestId:`migrations-mode-table`},{mode:T2.Json,icon:(0,I.jsx)(op,{}),dataTestId:`migrations-mode-json`}],I2=({mode:e,onChange:t})=>(0,I.jsx)(j,{gap:`4px`,children:vce.map(n=>(0,I.jsx)(_ce,{dataTestId:n.dataTestId,isSelected:n.mode===e,onClick:()=>t(n.mode),icon:n.icon},n.mode))}),yce={apply:hf,skip:nne,conflict:Vf,blocked:Of},bce={apply:`green.500`,skip:`gray.400`,conflict:`orange.500`,blocked:`gray.400`};function xce(e){let{changeType:t,tableId:n}=e.migration;switch(t){case`init`:return`init: ${n} (new table)`;case`update`:return`update: ${n}`;case`rename`:return`rename: ${n} → ${e.migration.nextTableId}`;case`remove`:return`remove: ${n}`;default:return`${t}: ${n}`}}function Sce(e){switch(e){case`apply`:return`Apply`;case`skip`:return`Skip`;case`conflict`:return`Conflict`;case`blocked`:return`Blocked`;default:throw Error(`Unknown status: ${e}`)}}var Cce=g(({item:e,index:t,isLast:n,canRemove:r,onRemove:i})=>{let a=yce[e.status],o=bce[e.status],s=n&&r&&i&&e.status===`apply`,[c,l]=(0,L.useState)(!1),u=(0,I.jsxs)(j,{align:`center`,height:`40px`,px:3,borderBottom:`1px solid`,borderColor:`gray.100`,_hover:{bg:s?`red.50`:`gray.50`},gap:3,cursor:s?`pointer`:`default`,children:[(0,I.jsx)(k,{fontSize:`sm`,color:`gray.400`,minWidth:`24px`,children:t+1}),(0,I.jsxs)(j,{align:`center`,gap:2,minWidth:`90px`,children:[(0,I.jsx)(Ve,{as:a,color:o,boxSize:4}),(0,I.jsx)(k,{fontSize:`sm`,color:o,fontWeight:`500`,children:Sce(e.status)})]}),(0,I.jsx)(A,{flex:1,overflow:`hidden`,children:(0,I.jsxs)(k,{fontSize:`sm`,color:`gray.700`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,overflow:`hidden`,children:[xce(e),e.reason&&e.status!==`apply`&&(0,I.jsxs)(k,{as:`span`,fontSize:`xs`,color:`gray.400`,ml:2,children:[`(`,e.reason,`)`]})]})}),(0,I.jsx)(k,{fontSize:`xs`,color:`gray.400`,minWidth:`100px`,children:UV(e.migration.id,`dd.MM.yyyy HH:mm`)})]});return s?(0,I.jsxs)(ge,{open:c,onOpenChange:e=>l(e.open),children:[(0,I.jsx)(me,{asChild:!0,children:u}),(0,I.jsx)(se,{children:(0,I.jsxs)(le,{width:`auto`,children:[(0,I.jsx)(Pe,{children:(0,I.jsx)(hn,{})}),(0,I.jsx)(C,{p:3,children:(0,I.jsxs)(j,{direction:`column`,gap:2,children:[(0,I.jsx)(k,{fontSize:`sm`,children:`Exclude this migration from apply?`}),(0,I.jsxs)(j,{gap:2,justify:`flex-end`,children:[(0,I.jsx)(N,{size:`xs`,variant:`outline`,onClick:()=>l(!1),children:`Cancel`}),(0,I.jsx)(N,{size:`xs`,colorPalette:`red`,onClick:()=>{l(!1),i?.()},children:`Exclude`})]})]})})]})})]}):u}),L2=g(({diffItems:e,viewMode:t,onViewModeChange:n,onRemoveLast:r,canRemoveLast:i=!1,onVirtuosoRef:a,summary:o})=>{let s=t===T2.Table,c=(0,L.useCallback)(e=>{a?.(e)},[a]),l=(0,L.useMemo)(()=>e.map(e=>e.migration),[e]);return e.length===0?(0,I.jsx)(j,{justify:`center`,align:`center`,minHeight:`100px`,children:(0,I.jsx)(k,{color:`gray.400`,fontSize:`sm`,children:`No migrations to preview`})}):(0,I.jsxs)(M,{align:`stretch`,gap:3,children:[(0,I.jsxs)(P,{justify:`space-between`,children:[(0,I.jsxs)(P,{gap:4,children:[(0,I.jsxs)(k,{fontSize:`sm`,color:`gray.600`,children:[(0,I.jsx)(k,{as:`span`,fontWeight:`500`,color:`green.500`,children:o.toApply}),` `,`to apply`]}),o.toSkip>0&&(0,I.jsxs)(k,{fontSize:`sm`,color:`gray.400`,children:[o.toSkip,` to skip`]}),o.conflicts>0&&(0,I.jsxs)(k,{fontSize:`sm`,color:`orange.500`,children:[o.conflicts,` conflicts`]}),o.blocked>0&&(0,I.jsxs)(k,{fontSize:`sm`,color:`gray.400`,children:[o.blocked,` blocked`]})]}),(0,I.jsx)(I2,{mode:t,onChange:n})]}),s?(0,I.jsx)(A,{border:`1px solid`,borderColor:`gray.200`,borderRadius:`md`,overflow:`hidden`,height:`300px`,maxHeight:`300px`,children:(0,I.jsx)(QM,{ref:c,style:{height:`100%`},totalCount:e.length,data:e,itemContent:(t,n)=>(0,I.jsx)(Cce,{item:n,index:t,isLast:t===e.length-1,canRemove:i,onRemove:r})})}):(0,I.jsx)(A,{border:`1px solid`,borderColor:`gray.200`,borderRadius:`md`,overflow:`auto`,maxHeight:`300px`,children:(0,I.jsx)(aJ,{readonly:!0,data:l})})]})}),R2=g(({model:e})=>(0,I.jsx)(Ue,{open:e.isOpen,onOpenChange:({open:t})=>!t&&e.close(),size:`xl`,children:(0,I.jsxs)(R,{children:[(0,I.jsx)(pe,{}),(0,I.jsx)(ue,{children:(0,I.jsxs)(_n,{maxWidth:`800px`,children:[(0,I.jsx)(Ge,{children:(0,I.jsx)(qe,{children:`Apply Migrations from Branch`})}),(0,I.jsx)(be,{height:`500px`,overflow:`auto`,children:(0,I.jsx)(M,{align:`stretch`,gap:4,height:`100%`,children:e.showResult&&e.applyResultSummary?(0,I.jsx)(F2,{summary:e.applyResultSummary,failedResults:e.failedResults}):e.hasNoBranches?(0,I.jsxs)(j,{direction:`column`,align:`center`,justify:`center`,flex:1,gap:2,children:[(0,I.jsx)(k,{color:`gray.500`,children:`No other branches available`}),(0,I.jsx)(k,{fontSize:`sm`,color:`gray.400`,children:`Create a new branch to apply migrations from it`})]}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(P,{gap:4,children:[(0,I.jsxs)(j,{flexDirection:`column`,gap:2,flex:1,children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`500`,color:`gray.600`,children:`Source Branch`}),e.isLoadingBranches?(0,I.jsxs)(j,{align:`center`,gap:2,height:`40px`,children:[(0,I.jsx)(Ht,{size:`sm`}),(0,I.jsx)(k,{fontSize:`sm`,color:`gray.400`,children:`Loading branches...`})]}):(0,I.jsx)(Qe,{children:(0,I.jsxs)(Xe,{value:e.selectedBranchId??``,onChange:t=>e.setSelectedBranchId(t.target.value||null),children:[(0,I.jsx)(`option`,{value:``,children:`Select branch`}),e.branches.map(e=>(0,I.jsxs)(`option`,{value:e.id,children:[e.name,` `,e.isRoot?`(root)`:``]},e.id))]})})]}),(0,I.jsxs)(j,{flexDirection:`column`,gap:2,flex:1,children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`500`,color:`gray.600`,children:`Source Revision`}),(0,I.jsx)(Qe,{disabled:!e.selectedBranchId,children:(0,I.jsxs)(Xe,{value:e.selectedRevision,onChange:t=>e.setSelectedRevision(t.target.value),children:[(0,I.jsx)(`option`,{value:XJ,children:`Draft (working)`}),(0,I.jsx)(`option`,{value:ZJ,children:`Head (committed)`})]})})]})]}),e.selectedBranchId&&(0,I.jsxs)(j,{direction:`column`,flex:1,gap:4,children:[(0,I.jsx)(A,{height:`1px`,bg:`gray.200`}),e.isLoadingMigrations?(0,I.jsxs)(j,{justify:`center`,align:`center`,flex:1,children:[(0,I.jsx)(Ht,{}),(0,I.jsx)(k,{ml:3,color:`gray.500`,children:`Loading migrations...`})]}):e.previewItems.length===0?(0,I.jsx)(j,{justify:`center`,align:`center`,flex:1,children:(0,I.jsx)(k,{color:`gray.400`,children:`No new migrations to apply from this branch`})}):(0,I.jsxs)(I.Fragment,{children:[e.hasConflict&&(0,I.jsxs)(j,{align:`center`,gap:2,p:3,bg:`orange.50`,borderRadius:`md`,children:[(0,I.jsx)(Ve,{as:Vf,color:`orange.500`,boxSize:5}),(0,I.jsxs)(A,{children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`500`,color:`orange.700`,children:`Conflict detected`}),(0,I.jsx)(k,{fontSize:`xs`,color:`orange.600`,children:`Some migrations have conflicting timestamps.`})]})]}),(0,I.jsx)(L2,{diffItems:e.previewItems,viewMode:e.viewMode,onViewModeChange:e.setViewMode,summary:e.summary,canRemoveLast:e.canRemoveLast,onRemoveLast:e.removeLastMigration,onVirtuosoRef:e.setVirtuosoRef})]})]})]})})}),(0,I.jsxs)(w,{children:[(0,I.jsx)(N,{variant:`outline`,onClick:e.close,children:e.showResult?`Close`:`Cancel`}),!e.showResult&&(0,I.jsxs)(N,{onClick:e.apply,disabled:!e.canApply,loading:e.isApplying,children:[`Apply `,e.migrationsToApply.length>0&&`(${e.migrationsToApply.length})`]})]}),(0,I.jsx)(Ie,{})]})})]})})),z2=g(({model:e})=>(0,I.jsx)(Ue,{open:e.isOpen,onOpenChange:({open:t})=>!t&&e.close(),size:`xl`,children:(0,I.jsxs)(R,{children:[(0,I.jsx)(pe,{}),(0,I.jsx)(ue,{children:(0,I.jsxs)(_n,{maxWidth:`800px`,children:[(0,I.jsx)(Ge,{children:(0,I.jsx)(qe,{children:`Apply Migrations from JSON`})}),(0,I.jsx)(be,{children:(0,I.jsx)(M,{align:`stretch`,gap:4,children:e.showResult&&e.applyResultSummary?(0,I.jsx)(F2,{summary:e.applyResultSummary,failedResults:e.failedResults}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(A,{children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`500`,color:`gray.600`,mb:2,children:`Paste migrations JSON`}),(0,I.jsx)(A,{border:`1px solid`,borderColor:`gray.200`,borderRadius:`md`,overflow:`hidden`,children:(0,I.jsx)(DO,{value:e.jsonInput,onChange:e.setJsonInput,extensions:[G.lineWrapping,nk()],theme:pC,placeholder:`[{ "changeType": "init", "tableId": "posts", ... }]`,minHeight:`150px`,maxHeight:`200px`,basicSetup:{lineNumbers:!0,foldGutter:!0}})}),e.parseError&&(0,I.jsx)(k,{fontSize:`sm`,color:`red.500`,mt:1,children:e.parseError})]}),e.previewItems.length>0&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(A,{height:`1px`,bg:`gray.200`}),e.hasConflict&&(0,I.jsxs)(j,{align:`center`,gap:2,p:3,bg:`orange.50`,borderRadius:`md`,children:[(0,I.jsx)(Ve,{as:Vf,color:`orange.500`,boxSize:5}),(0,I.jsxs)(A,{children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`500`,color:`orange.700`,children:`Conflict detected`}),(0,I.jsx)(k,{fontSize:`xs`,color:`orange.600`,children:`Remove conflicting migrations from the end to proceed.`})]})]}),(0,I.jsx)(L2,{diffItems:e.previewItems,viewMode:e.viewMode,onViewModeChange:e.setViewMode,onRemoveLast:e.removeLastMigration,canRemoveLast:e.canRemoveLast,onVirtuosoRef:e.setVirtuosoRef,summary:e.summary})]})]})})}),(0,I.jsxs)(w,{children:[(0,I.jsx)(N,{variant:`outline`,onClick:e.close,children:e.showResult?`Close`:`Cancel`}),!e.showResult&&(0,I.jsxs)(N,{onClick:e.apply,disabled:!e.canApply,loading:e.isApplying,children:[`Apply `,e.migrationsToApply.length>0&&`(${e.migrationsToApply.length})`]})]}),(0,I.jsx)(Ie,{})]})})]})})),B2=g(({totalCount:e,branchName:t,viewMode:n,canApplyMigrations:r,onViewModeChange:i,onApplyFromJson:a,onApplyFromBranch:o})=>(0,I.jsxs)(A,{mb:6,position:`sticky`,top:0,bg:`white`,zIndex:10,pt:4,pb:2,children:[(0,I.jsxs)(P,{justify:`space-between`,align:`flex-start`,mb:1,children:[(0,I.jsxs)(k,{fontSize:`20px`,fontWeight:`600`,color:`newGray.500`,children:[`Migrations for `,t,` (`,e,` operations)`]}),r&&(0,I.jsxs)(en,{children:[(0,I.jsx)(Lt,{asChild:!0,children:(0,I.jsxs)(N,{size:`xs`,variant:`ghost`,color:`newGray.400`,children:[`Apply`,(0,I.jsx)(mf,{})]})}),(0,I.jsx)(R,{children:(0,I.jsx)(Ot,{children:(0,I.jsxs)(v,{children:[(0,I.jsx)(gt,{value:`json`,onClick:a,children:`From JSON`}),(0,I.jsx)(gt,{value:`branch`,onClick:o,children:`From Branch`})]})})})]})]}),(0,I.jsxs)(P,{gap:1,mb:4,children:[(0,I.jsx)(k,{fontSize:`xs`,color:`newGray.400`,children:`You can use Apply to merge schemas from other branches or import from external sources.`}),(0,I.jsxs)(mn,{openDelay:200,closeDelay:100,children:[(0,I.jsx)(ct,{children:(0,I.jsx)(Ve,{as:Ef,color:`newGray.400`,cursor:`help`})}),(0,I.jsx)(R,{children:(0,I.jsx)(on,{children:(0,I.jsxs)(nt,{maxWidth:`400px`,p:3,children:[(0,I.jsx)(Tt,{children:(0,I.jsx)(St,{})}),(0,I.jsxs)(M,{align:`start`,gap:3,children:[(0,I.jsx)(k,{fontSize:`xs`,color:`newGray.600`,fontWeight:`600`,children:`About Migrations`}),(0,I.jsx)(k,{fontSize:`xs`,color:`newGray.600`,children:`Schema changes are tracked as migrations that can be applied to synchronize schemas across branches and environments.`}),(0,I.jsxs)(M,{align:`start`,gap:1,children:[(0,I.jsx)(k,{fontSize:`xs`,color:`newGray.500`,fontWeight:`500`,children:`Recommended workflows:`}),(0,I.jsx)(k,{fontSize:`xs`,color:`newGray.500`,children:`• Edit schemas in feature branches, then apply to default`}),(0,I.jsx)(k,{fontSize:`xs`,color:`newGray.500`,children:`• Use default branch as read-only for schema, merge from others`}),(0,I.jsx)(k,{fontSize:`xs`,color:`newGray.500`,children:`• Export/import JSON between projects or instances`})]}),(0,I.jsx)(A,{p:2,bg:`orange.50`,borderRadius:`sm`,children:(0,I.jsx)(k,{fontSize:`xs`,color:`orange.600`,children:`Conflict resolution is not yet supported. Avoid parallel schema changes in multiple branches.`})}),(0,I.jsxs)(j,{gap:1,align:`center`,children:[(0,I.jsx)(k,{fontSize:`xs`,color:`newGray.400`,children:`For CI/CD automation, use`}),(0,I.jsx)(mt,{href:`https://github.com/revisium/revisium-cli`,target:`_blank`,rel:`noopener noreferrer`,fontSize:`xs`,color:`blue.500`,children:`revisium-cli`})]})]})]})})})]})]}),(0,I.jsx)(P,{justify:`flex-end`,children:(0,I.jsx)(I2,{mode:n,onChange:i})})]})),V2=(0,L.createContext)(null),wce=g(({index:e})=>{let t=(0,L.useContext)(V2);if(!t)return null;let n=t.items[e];return n?(0,I.jsxs)(ge,{lazyMount:!0,unmountOnExit:!0,positioning:{placement:`bottom-start`},open:n.isPopoverOpen,onOpenChange:({open:e})=>n.setPopoverOpen(e),children:[(0,I.jsx)(me,{asChild:!0,children:(0,I.jsx)(A,{py:3,px:4,cursor:`pointer`,borderBottom:`1px solid`,borderColor:`gray.50`,_hover:{bg:`gray.50`,"& .migration-icon":{color:`newGray.400`}},"data-testid":`migration-item-${e}`,children:(0,I.jsxs)(j,{align:`center`,gap:2,children:[(0,I.jsx)(Ve,{as:n.descriptionIcon,className:`migration-icon`,color:`newGray.300`,boxSize:4,flexShrink:0}),(0,I.jsx)(k,{fontSize:`sm`,color:`newGray.500`,lineHeight:`1.4`,flex:1,minWidth:0,children:n.descriptionSegments.map((e,t)=>e.highlight?(0,I.jsx)(A,{as:`span`,px:`1`,bg:`gray.100`,borderRadius:`sm`,whiteSpace:`nowrap`,children:e.text},t):e.gray?(0,I.jsx)(A,{as:`span`,color:`newGray.300`,children:e.text},t):(0,I.jsx)(`span`,{children:e.text},t))}),(0,I.jsx)(k,{fontSize:`xs`,color:`newGray.300`,flexShrink:0,whiteSpace:`nowrap`,children:n.relativeTime})]})})}),(0,I.jsx)(R,{children:(0,I.jsx)(se,{children:(0,I.jsxs)(le,{width:`800px`,maxHeight:`350px`,overflow:`auto`,children:[(0,I.jsx)(We,{}),(0,I.jsx)(C,{children:(0,I.jsx)(aJ,{readonly:!0,data:n.fullPatchData})})]})})})]}):null}),Tce=g(({items:e})=>{let t=(0,L.useMemo)(()=>({items:e}),[e]);return e.length===0?(0,I.jsx)(j,{justify:`center`,align:`center`,minHeight:`200px`,children:(0,I.jsx)(k,{color:`gray.400`,children:`No operations found`})}):(0,I.jsx)(V2.Provider,{value:t,children:(0,I.jsx)(QM,{useWindowScroll:!0,totalCount:e.length,defaultItemHeight:52,increaseViewportBy:1040,itemContent:e=>(0,I.jsx)(wce,{index:e})})})}),Ece=g(()=>{let e=CB(P2);return e.showLoading?(0,I.jsx)(j,{justify:`center`,align:`center`,height:`200px`,children:(0,I.jsx)(Ht,{})}):e.showError?(0,I.jsx)(j,{justify:`center`,align:`center`,height:`200px`,children:(0,I.jsx)(k,{color:`red.500`,children:`Error loading migrations`})}):e.showEmpty?(0,I.jsxs)(A,{mb:`4rem`,children:[(0,I.jsx)(B2,{totalCount:0,branchName:e.branchName,viewMode:e.viewMode,canApplyMigrations:e.canApplyMigrations,onViewModeChange:e.setViewMode,onApplyFromJson:e.openApplyDialog,onApplyFromBranch:e.openApplyFromBranchDialog}),(0,I.jsx)(j,{justify:`center`,align:`center`,height:`200px`,children:(0,I.jsx)(k,{color:`newGray.400`,children:`No migrations found`})}),e.applyDialog&&(0,I.jsx)(z2,{model:e.applyDialog}),e.applyFromBranchDialog&&(0,I.jsx)(R2,{model:e.applyFromBranchDialog})]}):e.showList?(0,I.jsxs)(A,{mb:`4rem`,children:[(0,I.jsx)(B2,{totalCount:e.totalCount,branchName:e.branchName,viewMode:e.viewMode,canApplyMigrations:e.canApplyMigrations,onViewModeChange:e.setViewMode,onApplyFromJson:e.openApplyDialog,onApplyFromBranch:e.openApplyFromBranchDialog}),e.isTableMode?(0,I.jsx)(Tce,{items:e.items}):(0,I.jsx)(aJ,{readonly:!0,data:e.data}),e.applyDialog&&(0,I.jsx)(z2,{model:e.applyDialog}),e.applyFromBranchDialog&&(0,I.jsx)(R2,{model:e.applyFromBranchDialog})]}):null});function H2(e){if(typeof e==`string`||typeof e==`number`)return``+e;let t=``;if(Array.isArray(e))for(let n=0,r;n<e.length;n++)(r=H2(e[n]))!==``&&(t+=(t&&` `)+r);else for(let n in e)e[n]&&(t+=(t&&` `)+n);return t}var Dce={value:()=>{}};function U2(){for(var e=0,t=arguments.length,n={},r;e<t;++e){if(!(r=arguments[e]+``)||r in n||/[\s.]/.test(r))throw Error(`illegal type: `+r);n[r]=[]}return new W2(n)}function W2(e){this._=e}function Oce(e,t){return e.trim().split(/^|\s+/).map(function(e){var n=``,r=e.indexOf(`.`);if(r>=0&&(n=e.slice(r+1),e=e.slice(0,r)),e&&!t.hasOwnProperty(e))throw Error(`unknown type: `+e);return{type:e,name:n}})}W2.prototype=U2.prototype={constructor:W2,on:function(e,t){var n=this._,r=Oce(e+``,n),i,a=-1,o=r.length;if(arguments.length<2){for(;++a<o;)if((i=(e=r[a]).type)&&(i=kce(n[i],e.name)))return i;return}if(t!=null&&typeof t!=`function`)throw Error(`invalid callback: `+t);for(;++a<o;)if(i=(e=r[a]).type)n[i]=G2(n[i],e.name,t);else if(t==null)for(i in n)n[i]=G2(n[i],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new W2(e)},call:function(e,t){if((i=arguments.length-2)>0)for(var n=Array(i),r=0,i,a;r<i;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(e))throw Error(`unknown type: `+e);for(a=this._[e],r=0,i=a.length;r<i;++r)a[r].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw Error(`unknown type: `+e);for(var r=this._[e],i=0,a=r.length;i<a;++i)r[i].value.apply(t,n)}};function kce(e,t){for(var n=0,r=e.length,i;n<r;++n)if((i=e[n]).name===t)return i.value}function G2(e,t,n){for(var r=0,i=e.length;r<i;++r)if(e[r].name===t){e[r]=Dce,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var K2={svg:`http://www.w3.org/2000/svg`,xhtml:`http://www.w3.org/1999/xhtml`,xlink:`http://www.w3.org/1999/xlink`,xml:`http://www.w3.org/XML/1998/namespace`,xmlns:`http://www.w3.org/2000/xmlns/`};function q2(e){var t=e+=``,n=t.indexOf(`:`);return n>=0&&(t=e.slice(0,n))!==`xmlns`&&(e=e.slice(n+1)),K2.hasOwnProperty(t)?{space:K2[t],local:e}:e}function Ace(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===`http://www.w3.org/1999/xhtml`&&t.documentElement.namespaceURI===`http://www.w3.org/1999/xhtml`?t.createElement(e):t.createElementNS(n,e)}}function jce(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function J2(e){var t=q2(e);return(t.local?jce:Ace)(t)}function Mce(){}function Y2(e){return e==null?Mce:function(){return this.querySelector(e)}}function Nce(e){typeof e!=`function`&&(e=Y2(e));for(var t=this._groups,n=t.length,r=Array(n),i=0;i<n;++i)for(var a=t[i],o=a.length,s=r[i]=Array(o),c,l,u=0;u<o;++u)(c=a[u])&&(l=e.call(c,c.__data__,u,a))&&(`__data__`in c&&(l.__data__=c.__data__),s[u]=l);return new u4(r,this._parents)}function Pce(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function Fce(){return[]}function X2(e){return e==null?Fce:function(){return this.querySelectorAll(e)}}function Ice(e){return function(){return Pce(e.apply(this,arguments))}}function Lce(e){e=typeof e==`function`?Ice(e):X2(e);for(var t=this._groups,n=t.length,r=[],i=[],a=0;a<n;++a)for(var o=t[a],s=o.length,c,l=0;l<s;++l)(c=o[l])&&(r.push(e.call(c,c.__data__,l,o)),i.push(c));return new u4(r,i)}function Z2(e){return function(){return this.matches(e)}}function Q2(e){return function(t){return t.matches(e)}}var Rce=Array.prototype.find;function zce(e){return function(){return Rce.call(this.children,e)}}function Bce(){return this.firstElementChild}function Vce(e){return this.select(e==null?Bce:zce(typeof e==`function`?e:Q2(e)))}var Hce=Array.prototype.filter;function Uce(){return Array.from(this.children)}function Wce(e){return function(){return Hce.call(this.children,e)}}function Gce(e){return this.selectAll(e==null?Uce:Wce(typeof e==`function`?e:Q2(e)))}function Kce(e){typeof e!=`function`&&(e=Z2(e));for(var t=this._groups,n=t.length,r=Array(n),i=0;i<n;++i)for(var a=t[i],o=a.length,s=r[i]=[],c,l=0;l<o;++l)(c=a[l])&&e.call(c,c.__data__,l,a)&&s.push(c);return new u4(r,this._parents)}function $2(e){return Array(e.length)}function qce(){return new u4(this._enter||this._groups.map($2),this._parents)}function e4(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}e4.prototype={constructor:e4,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function Jce(e){return function(){return e}}function Yce(e,t,n,r,i,a){for(var o=0,s,c=t.length,l=a.length;o<l;++o)(s=t[o])?(s.__data__=a[o],r[o]=s):n[o]=new e4(e,a[o]);for(;o<c;++o)(s=t[o])&&(i[o]=s)}function Xce(e,t,n,r,i,a,o){var s,c,l=new Map,u=t.length,d=a.length,f=Array(u),p;for(s=0;s<u;++s)(c=t[s])&&(f[s]=p=o.call(c,c.__data__,s,t)+``,l.has(p)?i[s]=c:l.set(p,c));for(s=0;s<d;++s)p=o.call(e,a[s],s,a)+``,(c=l.get(p))?(r[s]=c,c.__data__=a[s],l.delete(p)):n[s]=new e4(e,a[s]);for(s=0;s<u;++s)(c=t[s])&&l.get(f[s])===c&&(i[s]=c)}function Zce(e){return e.__data__}function Qce(e,t){if(!arguments.length)return Array.from(this,Zce);var n=t?Xce:Yce,r=this._parents,i=this._groups;typeof e!=`function`&&(e=Jce(e));for(var a=i.length,o=Array(a),s=Array(a),c=Array(a),l=0;l<a;++l){var u=r[l],d=i[l],f=d.length,p=$ce(e.call(u,u&&u.__data__,l,r)),m=p.length,h=s[l]=Array(m),g=o[l]=Array(m);n(u,d,h,g,c[l]=Array(f),p,t);for(var _=0,v=0,y,b;_<m;++_)if(y=h[_]){for(_>=v&&(v=_+1);!(b=g[v])&&++v<m;);y._next=b||null}}return o=new u4(o,r),o._enter=s,o._exit=c,o}function $ce(e){return typeof e==`object`&&`length`in e?e:Array.from(e)}function ele(){return new u4(this._exit||this._groups.map($2),this._parents)}function tle(e,t,n){var r=this.enter(),i=this,a=this.exit();return typeof e==`function`?(r=e(r),r&&=r.selection()):r=r.append(e+``),t!=null&&(i=t(i),i&&=i.selection()),n==null?a.remove():n(a),r&&i?r.merge(i).order():i}function nle(e){for(var t=e.selection?e.selection():e,n=this._groups,r=t._groups,i=n.length,a=r.length,o=Math.min(i,a),s=Array(i),c=0;c<o;++c)for(var l=n[c],u=r[c],d=l.length,f=s[c]=Array(d),p,m=0;m<d;++m)(p=l[m]||u[m])&&(f[m]=p);for(;c<i;++c)s[c]=n[c];return new u4(s,this._parents)}function rle(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var r=e[t],i=r.length-1,a=r[i],o;--i>=0;)(o=r[i])&&(a&&o.compareDocumentPosition(a)^4&&a.parentNode.insertBefore(o,a),a=o);return this}function ile(e){e||=ale;function t(t,n){return t&&n?e(t.__data__,n.__data__):!t-!n}for(var n=this._groups,r=n.length,i=Array(r),a=0;a<r;++a){for(var o=n[a],s=o.length,c=i[a]=Array(s),l,u=0;u<s;++u)(l=o[u])&&(c[u]=l);c.sort(t)}return new u4(i,this._parents).order()}function ale(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function ole(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function sle(){return Array.from(this)}function cle(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],i=0,a=r.length;i<a;++i){var o=r[i];if(o)return o}return null}function lle(){let e=0;for(let t of this)++e;return e}function ule(){return!this.node()}function dle(e){for(var t=this._groups,n=0,r=t.length;n<r;++n)for(var i=t[n],a=0,o=i.length,s;a<o;++a)(s=i[a])&&e.call(s,s.__data__,a,i);return this}function fle(e){return function(){this.removeAttribute(e)}}function ple(e){return function(){this.removeAttributeNS(e.space,e.local)}}function mle(e,t){return function(){this.setAttribute(e,t)}}function hle(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function gle(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function _le(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function vle(e,t){var n=q2(e);if(arguments.length<2){var r=this.node();return n.local?r.getAttributeNS(n.space,n.local):r.getAttribute(n)}return this.each((t==null?n.local?ple:fle:typeof t==`function`?n.local?_le:gle:n.local?hle:mle)(n,t))}function t4(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function yle(e){return function(){this.style.removeProperty(e)}}function ble(e,t,n){return function(){this.style.setProperty(e,t,n)}}function xle(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function Sle(e,t,n){return arguments.length>1?this.each((t==null?yle:typeof t==`function`?xle:ble)(e,t,n??``)):n4(this.node(),e)}function n4(e,t){return e.style.getPropertyValue(t)||t4(e).getComputedStyle(e,null).getPropertyValue(t)}function Cle(e){return function(){delete this[e]}}function wle(e,t){return function(){this[e]=t}}function Tle(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function Ele(e,t){return arguments.length>1?this.each((t==null?Cle:typeof t==`function`?Tle:wle)(e,t)):this.node()[e]}function r4(e){return e.trim().split(/^|\s+/)}function i4(e){return e.classList||new a4(e)}function a4(e){this._node=e,this._names=r4(e.getAttribute(`class`)||``)}a4.prototype={add:function(e){this._names.indexOf(e)<0&&(this._names.push(e),this._node.setAttribute(`class`,this._names.join(` `)))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute(`class`,this._names.join(` `)))},contains:function(e){return this._names.indexOf(e)>=0}};function o4(e,t){for(var n=i4(e),r=-1,i=t.length;++r<i;)n.add(t[r])}function s4(e,t){for(var n=i4(e),r=-1,i=t.length;++r<i;)n.remove(t[r])}function Dle(e){return function(){o4(this,e)}}function Ole(e){return function(){s4(this,e)}}function kle(e,t){return function(){(t.apply(this,arguments)?o4:s4)(this,e)}}function Ale(e,t){var n=r4(e+``);if(arguments.length<2){for(var r=i4(this.node()),i=-1,a=n.length;++i<a;)if(!r.contains(n[i]))return!1;return!0}return this.each((typeof t==`function`?kle:t?Dle:Ole)(n,t))}function jle(){this.textContent=``}function Mle(e){return function(){this.textContent=e}}function Nle(e){return function(){this.textContent=e.apply(this,arguments)??``}}function Ple(e){return arguments.length?this.each(e==null?jle:(typeof e==`function`?Nle:Mle)(e)):this.node().textContent}function Fle(){this.innerHTML=``}function Ile(e){return function(){this.innerHTML=e}}function Lle(e){return function(){this.innerHTML=e.apply(this,arguments)??``}}function Rle(e){return arguments.length?this.each(e==null?Fle:(typeof e==`function`?Lle:Ile)(e)):this.node().innerHTML}function zle(){this.nextSibling&&this.parentNode.appendChild(this)}function Ble(){return this.each(zle)}function Vle(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Hle(){return this.each(Vle)}function Ule(e){var t=typeof e==`function`?e:J2(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function Wle(){return null}function Gle(e,t){var n=typeof e==`function`?e:J2(e),r=t==null?Wle:typeof t==`function`?t:Y2(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function Kle(){var e=this.parentNode;e&&e.removeChild(this)}function qle(){return this.each(Kle)}function Jle(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Yle(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Xle(e){return this.select(e?Yle:Jle)}function Zle(e){return arguments.length?this.property(`__data__`,e):this.node().__data__}function Qle(e){return function(t){e.call(this,t,this.__data__)}}function $le(e){return e.trim().split(/^|\s+/).map(function(e){var t=``,n=e.indexOf(`.`);return n>=0&&(t=e.slice(n+1),e=e.slice(0,n)),{type:e,name:t}})}function eue(e){return function(){var t=this.__on;if(t){for(var n=0,r=-1,i=t.length,a;n<i;++n)a=t[n],(!e.type||a.type===e.type)&&a.name===e.name?this.removeEventListener(a.type,a.listener,a.options):t[++r]=a;++r?t.length=r:delete this.__on}}}function tue(e,t,n){return function(){var r=this.__on,i,a=Qle(t);if(r){for(var o=0,s=r.length;o<s;++o)if((i=r[o]).type===e.type&&i.name===e.name){this.removeEventListener(i.type,i.listener,i.options),this.addEventListener(i.type,i.listener=a,i.options=n),i.value=t;return}}this.addEventListener(e.type,a,n),i={type:e.type,name:e.name,value:t,listener:a,options:n},r?r.push(i):this.__on=[i]}}function nue(e,t,n){var r=$le(e+``),i,a=r.length,o;if(arguments.length<2){var s=this.node().__on;if(s){for(var c=0,l=s.length,u;c<l;++c)for(i=0,u=s[c];i<a;++i)if((o=r[i]).type===u.type&&o.name===u.name)return u.value}return}for(s=t?tue:eue,i=0;i<a;++i)this.each(s(r[i],t,n));return this}function c4(e,t,n){var r=t4(e),i=r.CustomEvent;typeof i==`function`?i=new i(t,n):(i=r.document.createEvent(`Event`),n?(i.initEvent(t,n.bubbles,n.cancelable),i.detail=n.detail):i.initEvent(t,!1,!1)),e.dispatchEvent(i)}function rue(e,t){return function(){return c4(this,e,t)}}function iue(e,t){return function(){return c4(this,e,t.apply(this,arguments))}}function aue(e,t){return this.each((typeof t==`function`?iue:rue)(e,t))}function*oue(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],i=0,a=r.length,o;i<a;++i)(o=r[i])&&(yield o)}var l4=[null];function u4(e,t){this._groups=e,this._parents=t}function d4(){return new u4([[document.documentElement]],l4)}function sue(){return this}u4.prototype=d4.prototype={constructor:u4,select:Nce,selectAll:Lce,selectChild:Vce,selectChildren:Gce,filter:Kce,data:Qce,enter:qce,exit:ele,join:tle,merge:nle,selection:sue,order:rle,sort:ile,call:ole,nodes:sle,node:cle,size:lle,empty:ule,each:dle,attr:vle,style:Sle,property:Ele,classed:Ale,text:Ple,html:Rle,raise:Ble,lower:Hle,append:Ule,insert:Gle,remove:qle,clone:Xle,datum:Zle,on:nue,dispatch:aue,[Symbol.iterator]:oue};function f4(e){return typeof e==`string`?new u4([[document.querySelector(e)]],[document.documentElement]):new u4([[e]],l4)}function cue(e){let t;for(;t=e.sourceEvent;)e=t;return e}function p4(e,t){if(e=cue(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var r=n.createSVGPoint();return r.x=e.clientX,r.y=e.clientY,r=r.matrixTransform(t.getScreenCTM().inverse()),[r.x,r.y]}if(t.getBoundingClientRect){var i=t.getBoundingClientRect();return[e.clientX-i.left-t.clientLeft,e.clientY-i.top-t.clientTop]}}return[e.pageX,e.pageY]}var lue={passive:!1},m4={capture:!0,passive:!1};function h4(e){e.stopImmediatePropagation()}function g4(e){e.preventDefault(),e.stopImmediatePropagation()}function _4(e){var t=e.document.documentElement,n=f4(e).on(`dragstart.drag`,g4,m4);`onselectstart`in t?n.on(`selectstart.drag`,g4,m4):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect=`none`)}function v4(e,t){var n=e.document.documentElement,r=f4(e).on(`dragstart.drag`,null);t&&(r.on(`click.drag`,g4,m4),setTimeout(function(){r.on(`click.drag`,null)},0)),`onselectstart`in n?r.on(`selectstart.drag`,null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}var y4=e=>()=>e;function b4(e,{sourceEvent:t,subject:n,target:r,identifier:i,active:a,x:o,y:s,dx:c,dy:l,dispatch:u}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:i,enumerable:!0,configurable:!0},active:{value:a,enumerable:!0,configurable:!0},x:{value:o,enumerable:!0,configurable:!0},y:{value:s,enumerable:!0,configurable:!0},dx:{value:c,enumerable:!0,configurable:!0},dy:{value:l,enumerable:!0,configurable:!0},_:{value:u}})}b4.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function uue(e){return!e.ctrlKey&&!e.button}function due(){return this.parentNode}function fue(e,t){return t??{x:e.x,y:e.y}}function pue(){return navigator.maxTouchPoints||`ontouchstart`in this}function x4(){var e=uue,t=due,n=fue,r=pue,i={},a=U2(`start`,`drag`,`end`),o=0,s,c,l,u,d=0;function f(e){e.on(`mousedown.drag`,p).filter(r).on(`touchstart.drag`,g).on(`touchmove.drag`,_,lue).on(`touchend.drag touchcancel.drag`,v).style(`touch-action`,`none`).style(`-webkit-tap-highlight-color`,`rgba(0,0,0,0)`)}function p(n,r){if(!(u||!e.call(this,n,r))){var i=y(this,t.call(this,n,r),n,r,`mouse`);i&&(f4(n.view).on(`mousemove.drag`,m,m4).on(`mouseup.drag`,h,m4),_4(n.view),h4(n),l=!1,s=n.clientX,c=n.clientY,i(`start`,n))}}function m(e){if(g4(e),!l){var t=e.clientX-s,n=e.clientY-c;l=t*t+n*n>d}i.mouse(`drag`,e)}function h(e){f4(e.view).on(`mousemove.drag mouseup.drag`,null),v4(e.view,l),g4(e),i.mouse(`end`,e)}function g(n,r){if(e.call(this,n,r)){var i=n.changedTouches,a=t.call(this,n,r),o=i.length,s,c;for(s=0;s<o;++s)(c=y(this,a,n,r,i[s].identifier,i[s]))&&(h4(n),c(`start`,n,i[s]))}}function _(e){var t=e.changedTouches,n=t.length,r,a;for(r=0;r<n;++r)(a=i[t[r].identifier])&&(g4(e),a(`drag`,e,t[r]))}function v(e){var t=e.changedTouches,n=t.length,r,a;for(u&&clearTimeout(u),u=setTimeout(function(){u=null},500),r=0;r<n;++r)(a=i[t[r].identifier])&&(h4(e),a(`end`,e,t[r]))}function y(e,t,r,s,c,l){var u=a.copy(),d=p4(l||r,t),p,m,h;if((h=n.call(e,new b4(`beforestart`,{sourceEvent:r,target:f,identifier:c,active:o,x:d[0],y:d[1],dx:0,dy:0,dispatch:u}),s))!=null)return p=h.x-d[0]||0,m=h.y-d[1]||0,function n(r,a,l){var g=d,_;switch(r){case`start`:i[c]=n,_=o++;break;case`end`:delete i[c],--o;case`drag`:d=p4(l||a,t),_=o;break}u.call(r,e,new b4(r,{sourceEvent:a,subject:h,target:f,identifier:c,active:_,x:d[0]+p,y:d[1]+m,dx:d[0]-g[0],dy:d[1]-g[1],dispatch:u}),s)}}return f.filter=function(t){return arguments.length?(e=typeof t==`function`?t:y4(!!t),f):e},f.container=function(e){return arguments.length?(t=typeof e==`function`?e:y4(e),f):t},f.subject=function(e){return arguments.length?(n=typeof e==`function`?e:y4(e),f):n},f.touchable=function(e){return arguments.length?(r=typeof e==`function`?e:y4(!!e),f):r},f.on=function(){var e=a.on.apply(a,arguments);return e===a?f:e},f.clickDistance=function(e){return arguments.length?(d=(e=+e)*e,f):Math.sqrt(d)},f}function S4(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function C4(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function w4(){}var T4=.7,E4=1/T4,D4=`\\s*([+-]?\\d+)\\s*`,O4=`\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*`,k4=`\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*`,mue=/^#([0-9a-f]{3,8})$/,hue=RegExp(`^rgb\\(${D4},${D4},${D4}\\)$`),gue=RegExp(`^rgb\\(${k4},${k4},${k4}\\)$`),_ue=RegExp(`^rgba\\(${D4},${D4},${D4},${O4}\\)$`),vue=RegExp(`^rgba\\(${k4},${k4},${k4},${O4}\\)$`),yue=RegExp(`^hsl\\(${O4},${k4},${k4}\\)$`),bue=RegExp(`^hsla\\(${O4},${k4},${k4},${O4}\\)$`),A4={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};S4(w4,N4,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:j4,formatHex:j4,formatHex8:xue,formatHsl:Sue,formatRgb:M4,toString:M4});function j4(){return this.rgb().formatHex()}function xue(){return this.rgb().formatHex8()}function Sue(){return W4(this).formatHsl()}function M4(){return this.rgb().formatRgb()}function N4(e){var t,n;return e=(e+``).trim().toLowerCase(),(t=mue.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?P4(t):n===3?new L4(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?F4(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?F4(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=hue.exec(e))?new L4(t[1],t[2],t[3],1):(t=gue.exec(e))?new L4(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=_ue.exec(e))?F4(t[1],t[2],t[3],t[4]):(t=vue.exec(e))?F4(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=yue.exec(e))?U4(t[1],t[2]/100,t[3]/100,1):(t=bue.exec(e))?U4(t[1],t[2]/100,t[3]/100,t[4]):A4.hasOwnProperty(e)?P4(A4[e]):e===`transparent`?new L4(NaN,NaN,NaN,0):null}function P4(e){return new L4(e>>16&255,e>>8&255,e&255,1)}function F4(e,t,n,r){return r<=0&&(e=t=n=NaN),new L4(e,t,n,r)}function Cue(e){return e instanceof w4||(e=N4(e)),e?(e=e.rgb(),new L4(e.r,e.g,e.b,e.opacity)):new L4}function I4(e,t,n,r){return arguments.length===1?Cue(e):new L4(e,t,n,r??1)}function L4(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}S4(L4,I4,C4(w4,{brighter(e){return e=e==null?E4:E4**+e,new L4(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?T4:T4**+e,new L4(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new L4(V4(this.r),V4(this.g),V4(this.b),B4(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:R4,formatHex:R4,formatHex8:wue,formatRgb:z4,toString:z4}));function R4(){return`#${H4(this.r)}${H4(this.g)}${H4(this.b)}`}function wue(){return`#${H4(this.r)}${H4(this.g)}${H4(this.b)}${H4((isNaN(this.opacity)?1:this.opacity)*255)}`}function z4(){let e=B4(this.opacity);return`${e===1?`rgb(`:`rgba(`}${V4(this.r)}, ${V4(this.g)}, ${V4(this.b)}${e===1?`)`:`, ${e})`}`}function B4(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function V4(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function H4(e){return e=V4(e),(e<16?`0`:``)+e.toString(16)}function U4(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new G4(e,t,n,r)}function W4(e){if(e instanceof G4)return new G4(e.h,e.s,e.l,e.opacity);if(e instanceof w4||(e=N4(e)),!e)return new G4;if(e instanceof G4)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,i=Math.min(t,n,r),a=Math.max(t,n,r),o=NaN,s=a-i,c=(a+i)/2;return s?(o=t===a?(n-r)/s+(n<r)*6:n===a?(r-t)/s+2:(t-n)/s+4,s/=c<.5?a+i:2-a-i,o*=60):s=c>0&&c<1?0:o,new G4(o,s,c,e.opacity)}function Tue(e,t,n,r){return arguments.length===1?W4(e):new G4(e,t,n,r??1)}function G4(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}S4(G4,Tue,C4(w4,{brighter(e){return e=e==null?E4:E4**+e,new G4(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?T4:T4**+e,new G4(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,i=2*n-r;return new L4(J4(e>=240?e-240:e+120,i,r),J4(e,i,r),J4(e<120?e+240:e-120,i,r),this.opacity)},clamp(){return new G4(K4(this.h),q4(this.s),q4(this.l),B4(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){let e=B4(this.opacity);return`${e===1?`hsl(`:`hsla(`}${K4(this.h)}, ${q4(this.s)*100}%, ${q4(this.l)*100}%${e===1?`)`:`, ${e})`}`}}));function K4(e){return e=(e||0)%360,e<0?e+360:e}function q4(e){return Math.max(0,Math.min(1,e||0))}function J4(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}var Y4=e=>()=>e;function Eue(e,t){return function(n){return e+n*t}}function Due(e,t,n){return e**=+n,t=t**+n-e,n=1/n,function(r){return(e+r*t)**+n}}function Oue(e){return(e=+e)==1?X4:function(t,n){return n-t?Due(t,n,e):Y4(isNaN(t)?n:t)}}function X4(e,t){var n=t-e;return n?Eue(e,n):Y4(isNaN(e)?t:e)}var Z4=(function e(t){var n=Oue(t);function r(e,t){var r=n((e=I4(e)).r,(t=I4(t)).r),i=n(e.g,t.g),a=n(e.b,t.b),o=X4(e.opacity,t.opacity);return function(t){return e.r=r(t),e.g=i(t),e.b=a(t),e.opacity=o(t),e+``}}return r.gamma=e,r})(1);function kue(e,t){t||=[];var n=e?Math.min(t.length,e.length):0,r=t.slice(),i;return function(a){for(i=0;i<n;++i)r[i]=e[i]*(1-a)+t[i]*a;return r}}function Aue(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function jue(e,t){var n=t?t.length:0,r=e?Math.min(n,e.length):0,i=Array(r),a=Array(n),o;for(o=0;o<r;++o)i[o]=n3(e[o],t[o]);for(;o<n;++o)a[o]=t[o];return function(e){for(o=0;o<r;++o)a[o]=i[o](e);return a}}function Mue(e,t){var n=new Date;return e=+e,t=+t,function(r){return n.setTime(e*(1-r)+t*r),n}}function Q4(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function Nue(e,t){var n={},r={},i;for(i in(typeof e!=`object`||!e)&&(e={}),(typeof t!=`object`||!t)&&(t={}),t)i in e?n[i]=n3(e[i],t[i]):r[i]=t[i];return function(e){for(i in n)r[i]=n[i](e);return r}}var $4=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,e3=new RegExp($4.source,`g`);function Pue(e){return function(){return e}}function Fue(e){return function(t){return e(t)+``}}function t3(e,t){var n=$4.lastIndex=e3.lastIndex=0,r,i,a,o=-1,s=[],c=[];for(e+=``,t+=``;(r=$4.exec(e))&&(i=e3.exec(t));)(a=i.index)>n&&(a=t.slice(n,a),s[o]?s[o]+=a:s[++o]=a),(r=r[0])===(i=i[0])?s[o]?s[o]+=i:s[++o]=i:(s[++o]=null,c.push({i:o,x:Q4(r,i)})),n=e3.lastIndex;return n<t.length&&(a=t.slice(n),s[o]?s[o]+=a:s[++o]=a),s.length<2?c[0]?Fue(c[0].x):Pue(t):(t=c.length,function(e){for(var n=0,r;n<t;++n)s[(r=c[n]).i]=r.x(e);return s.join(``)})}function n3(e,t){var n=typeof t,r;return t==null||n===`boolean`?Y4(t):(n===`number`?Q4:n===`string`?(r=N4(t))?(t=r,Z4):t3:t instanceof N4?Z4:t instanceof Date?Mue:Aue(t)?kue:Array.isArray(t)?jue:typeof t.valueOf!=`function`&&typeof t.toString!=`function`||isNaN(t)?Nue:Q4)(e,t)}var r3=180/Math.PI,i3={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function a3(e,t,n,r,i,a){var o,s,c;return(o=Math.sqrt(e*e+t*t))&&(e/=o,t/=o),(c=e*n+t*r)&&(n-=e*c,r-=t*c),(s=Math.sqrt(n*n+r*r))&&(n/=s,r/=s,c/=s),e*r<t*n&&(e=-e,t=-t,c=-c,o=-o),{translateX:i,translateY:a,rotate:Math.atan2(t,e)*r3,skewX:Math.atan(c)*r3,scaleX:o,scaleY:s}}var o3;function Iue(e){let t=new(typeof DOMMatrix==`function`?DOMMatrix:WebKitCSSMatrix)(e+``);return t.isIdentity?i3:a3(t.a,t.b,t.c,t.d,t.e,t.f)}function Lue(e){return e==null||(o3||=document.createElementNS(`http://www.w3.org/2000/svg`,`g`),o3.setAttribute(`transform`,e),!(e=o3.transform.baseVal.consolidate()))?i3:(e=e.matrix,a3(e.a,e.b,e.c,e.d,e.e,e.f))}function s3(e,t,n,r){function i(e){return e.length?e.pop()+` `:``}function a(e,r,i,a,o,s){if(e!==i||r!==a){var c=o.push(`translate(`,null,t,null,n);s.push({i:c-4,x:Q4(e,i)},{i:c-2,x:Q4(r,a)})}else (i||a)&&o.push(`translate(`+i+t+a+n)}function o(e,t,n,a){e===t?t&&n.push(i(n)+`rotate(`+t+r):(e-t>180?t+=360:t-e>180&&(e+=360),a.push({i:n.push(i(n)+`rotate(`,null,r)-2,x:Q4(e,t)}))}function s(e,t,n,a){e===t?t&&n.push(i(n)+`skewX(`+t+r):a.push({i:n.push(i(n)+`skewX(`,null,r)-2,x:Q4(e,t)})}function c(e,t,n,r,a,o){if(e!==n||t!==r){var s=a.push(i(a)+`scale(`,null,`,`,null,`)`);o.push({i:s-4,x:Q4(e,n)},{i:s-2,x:Q4(t,r)})}else (n!==1||r!==1)&&a.push(i(a)+`scale(`+n+`,`+r+`)`)}return function(t,n){var r=[],i=[];return t=e(t),n=e(n),a(t.translateX,t.translateY,n.translateX,n.translateY,r,i),o(t.rotate,n.rotate,r,i),s(t.skewX,n.skewX,r,i),c(t.scaleX,t.scaleY,n.scaleX,n.scaleY,r,i),t=n=null,function(e){for(var t=-1,n=i.length,a;++t<n;)r[(a=i[t]).i]=a.x(e);return r.join(``)}}}var Rue=s3(Iue,`px, `,`px)`,`deg)`),zue=s3(Lue,`, `,`)`,`)`),Bue=1e-12;function c3(e){return((e=Math.exp(e))+1/e)/2}function Vue(e){return((e=Math.exp(e))-1/e)/2}function Hue(e){return((e=Math.exp(2*e))-1)/(e+1)}var l3=(function e(t,n,r){function i(e,i){var a=e[0],o=e[1],s=e[2],c=i[0],l=i[1],u=i[2],d=c-a,f=l-o,p=d*d+f*f,m,h;if(p<Bue)h=Math.log(u/s)/t,m=function(e){return[a+e*d,o+e*f,s*Math.exp(t*e*h)]};else{var g=Math.sqrt(p),_=(u*u-s*s+r*p)/(2*s*n*g),v=(u*u-s*s-r*p)/(2*u*n*g),y=Math.log(Math.sqrt(_*_+1)-_);h=(Math.log(Math.sqrt(v*v+1)-v)-y)/t,m=function(e){var r=e*h,i=c3(y),c=s/(n*g)*(i*Hue(t*r+y)-Vue(y));return[a+c*d,o+c*f,s*i/c3(t*r+y)]}}return m.duration=h*1e3*t/Math.SQRT2,m}return i.rho=function(t){var n=Math.max(.001,+t),r=n*n;return e(n,r,r*r)},i})(Math.SQRT2,2,4),u3=0,d3=0,f3=0,p3=1e3,m3,h3,g3=0,_3=0,v3=0,y3=typeof performance==`object`&&performance.now?performance:Date,b3=typeof window==`object`&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function x3(){return _3||=(b3(Uue),y3.now()+v3)}function Uue(){_3=0}function S3(){this._call=this._time=this._next=null}S3.prototype=C3.prototype={constructor:S3,restart:function(e,t,n){if(typeof e!=`function`)throw TypeError(`callback is not a function`);n=(n==null?x3():+n)+(t==null?0:+t),!this._next&&h3!==this&&(h3?h3._next=this:m3=this,h3=this),this._call=e,this._time=n,T3()},stop:function(){this._call&&(this._call=null,this._time=1/0,T3())}};function C3(e,t,n){var r=new S3;return r.restart(e,t,n),r}function Wue(){x3(),++u3;for(var e=m3,t;e;)(t=_3-e._time)>=0&&e._call.call(void 0,t),e=e._next;--u3}function w3(){_3=(g3=y3.now())+v3,u3=d3=0;try{Wue()}finally{u3=0,Kue(),_3=0}}function Gue(){var e=y3.now(),t=e-g3;t>p3&&(v3-=t,g3=e)}function Kue(){for(var e,t=m3,n,r=1/0;t;)t._call?(r>t._time&&(r=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:m3=n);h3=e,T3(r)}function T3(e){u3||(d3&&=clearTimeout(d3),e-_3>24?(e<1/0&&(d3=setTimeout(w3,e-y3.now()-v3)),f3&&=clearInterval(f3)):(f3||=(g3=y3.now(),setInterval(Gue,p3)),u3=1,b3(w3)))}function E3(e,t,n){var r=new S3;return t=t==null?0:+t,r.restart(n=>{r.stop(),e(n+t)},t,n),r}var que=U2(`start`,`end`,`cancel`,`interrupt`),Jue=[];function D3(e,t,n,r,i,a){var o=e.__transition;if(!o)e.__transition={};else if(n in o)return;Yue(e,n,{name:t,index:r,group:i,on:que,tween:Jue,time:a.time,delay:a.delay,duration:a.duration,ease:a.ease,timer:null,state:0})}function O3(e,t){var n=A3(e,t);if(n.state>0)throw Error(`too late; already scheduled`);return n}function k3(e,t){var n=A3(e,t);if(n.state>3)throw Error(`too late; already running`);return n}function A3(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw Error(`transition not found`);return n}function Yue(e,t,n){var r=e.__transition,i;r[t]=n,n.timer=C3(a,0,n.time);function a(e){n.state=1,n.timer.restart(o,n.delay,n.time),n.delay<=e&&o(e-n.delay)}function o(a){var l,u,d,f;if(n.state!==1)return c();for(l in r)if(f=r[l],f.name===n.name){if(f.state===3)return E3(o);f.state===4?(f.state=6,f.timer.stop(),f.on.call(`interrupt`,e,e.__data__,f.index,f.group),delete r[l]):+l<t&&(f.state=6,f.timer.stop(),f.on.call(`cancel`,e,e.__data__,f.index,f.group),delete r[l])}if(E3(function(){n.state===3&&(n.state=4,n.timer.restart(s,n.delay,n.time),s(a))}),n.state=2,n.on.call(`start`,e,e.__data__,n.index,n.group),n.state===2){for(n.state=3,i=Array(d=n.tween.length),l=0,u=-1;l<d;++l)(f=n.tween[l].value.call(e,e.__data__,n.index,n.group))&&(i[++u]=f);i.length=u+1}}function s(t){for(var r=t<n.duration?n.ease.call(null,t/n.duration):(n.timer.restart(c),n.state=5,1),a=-1,o=i.length;++a<o;)i[a].call(e,r);n.state===5&&(n.on.call(`end`,e,e.__data__,n.index,n.group),c())}function c(){for(var i in n.state=6,n.timer.stop(),delete r[t],r)return;delete e.__transition}}function j3(e,t){var n=e.__transition,r,i,a=!0,o;if(n){for(o in t=t==null?null:t+``,n){if((r=n[o]).name!==t){a=!1;continue}i=r.state>2&&r.state<5,r.state=6,r.timer.stop(),r.on.call(i?`interrupt`:`cancel`,e,e.__data__,r.index,r.group),delete n[o]}a&&delete e.__transition}}function Xue(e){return this.each(function(){j3(this,e)})}function Zue(e,t){var n,r;return function(){var i=k3(this,e),a=i.tween;if(a!==n){r=n=a;for(var o=0,s=r.length;o<s;++o)if(r[o].name===t){r=r.slice(),r.splice(o,1);break}}i.tween=r}}function Que(e,t,n){var r,i;if(typeof n!=`function`)throw Error();return function(){var a=k3(this,e),o=a.tween;if(o!==r){i=(r=o).slice();for(var s={name:t,value:n},c=0,l=i.length;c<l;++c)if(i[c].name===t){i[c]=s;break}c===l&&i.push(s)}a.tween=i}}function $ue(e,t){var n=this._id;if(e+=``,arguments.length<2){for(var r=A3(this.node(),n).tween,i=0,a=r.length,o;i<a;++i)if((o=r[i]).name===e)return o.value;return null}return this.each((t==null?Zue:Que)(n,e,t))}function M3(e,t,n){var r=e._id;return e.each(function(){var e=k3(this,r);(e.value||={})[t]=n.apply(this,arguments)}),function(e){return A3(e,r).value[t]}}function N3(e,t){var n;return(typeof t==`number`?Q4:t instanceof N4?Z4:(n=N4(t))?(t=n,Z4):t3)(e,t)}function ede(e){return function(){this.removeAttribute(e)}}function tde(e){return function(){this.removeAttributeNS(e.space,e.local)}}function nde(e,t,n){var r,i=n+``,a;return function(){var o=this.getAttribute(e);return o===i?null:o===r?a:a=t(r=o,n)}}function rde(e,t,n){var r,i=n+``,a;return function(){var o=this.getAttributeNS(e.space,e.local);return o===i?null:o===r?a:a=t(r=o,n)}}function ide(e,t,n){var r,i,a;return function(){var o,s=n(this),c;return s==null?void this.removeAttribute(e):(o=this.getAttribute(e),c=s+``,o===c?null:o===r&&c===i?a:(i=c,a=t(r=o,s)))}}function ade(e,t,n){var r,i,a;return function(){var o,s=n(this),c;return s==null?void this.removeAttributeNS(e.space,e.local):(o=this.getAttributeNS(e.space,e.local),c=s+``,o===c?null:o===r&&c===i?a:(i=c,a=t(r=o,s)))}}function ode(e,t){var n=q2(e),r=n===`transform`?zue:N3;return this.attrTween(e,typeof t==`function`?(n.local?ade:ide)(n,r,M3(this,`attr.`+e,t)):t==null?(n.local?tde:ede)(n):(n.local?rde:nde)(n,r,t))}function sde(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function cde(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function lde(e,t){var n,r;function i(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&cde(e,i)),n}return i._value=t,i}function ude(e,t){var n,r;function i(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&sde(e,i)),n}return i._value=t,i}function dde(e,t){var n=`attr.`+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!=`function`)throw Error();var r=q2(e);return this.tween(n,(r.local?lde:ude)(r,t))}function fde(e,t){return function(){O3(this,e).delay=+t.apply(this,arguments)}}function pde(e,t){return t=+t,function(){O3(this,e).delay=t}}function mde(e){var t=this._id;return arguments.length?this.each((typeof e==`function`?fde:pde)(t,e)):A3(this.node(),t).delay}function hde(e,t){return function(){k3(this,e).duration=+t.apply(this,arguments)}}function gde(e,t){return t=+t,function(){k3(this,e).duration=t}}function _de(e){var t=this._id;return arguments.length?this.each((typeof e==`function`?hde:gde)(t,e)):A3(this.node(),t).duration}function vde(e,t){if(typeof t!=`function`)throw Error();return function(){k3(this,e).ease=t}}function yde(e){var t=this._id;return arguments.length?this.each(vde(t,e)):A3(this.node(),t).ease}function bde(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!=`function`)throw Error();k3(this,e).ease=n}}function xde(e){if(typeof e!=`function`)throw Error();return this.each(bde(this._id,e))}function Sde(e){typeof e!=`function`&&(e=Z2(e));for(var t=this._groups,n=t.length,r=Array(n),i=0;i<n;++i)for(var a=t[i],o=a.length,s=r[i]=[],c,l=0;l<o;++l)(c=a[l])&&e.call(c,c.__data__,l,a)&&s.push(c);return new F3(r,this._parents,this._name,this._id)}function Cde(e){if(e._id!==this._id)throw Error();for(var t=this._groups,n=e._groups,r=t.length,i=n.length,a=Math.min(r,i),o=Array(r),s=0;s<a;++s)for(var c=t[s],l=n[s],u=c.length,d=o[s]=Array(u),f,p=0;p<u;++p)(f=c[p]||l[p])&&(d[p]=f);for(;s<r;++s)o[s]=t[s];return new F3(o,this._parents,this._name,this._id)}function wde(e){return(e+``).trim().split(/^|\s+/).every(function(e){var t=e.indexOf(`.`);return t>=0&&(e=e.slice(0,t)),!e||e===`start`})}function Tde(e,t,n){var r,i,a=wde(t)?O3:k3;return function(){var o=a(this,e),s=o.on;s!==r&&(i=(r=s).copy()).on(t,n),o.on=i}}function Ede(e,t){var n=this._id;return arguments.length<2?A3(this.node(),n).on.on(e):this.each(Tde(n,e,t))}function Dde(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function Ode(){return this.on(`end.remove`,Dde(this._id))}function kde(e){var t=this._name,n=this._id;typeof e!=`function`&&(e=Y2(e));for(var r=this._groups,i=r.length,a=Array(i),o=0;o<i;++o)for(var s=r[o],c=s.length,l=a[o]=Array(c),u,d,f=0;f<c;++f)(u=s[f])&&(d=e.call(u,u.__data__,f,s))&&(`__data__`in u&&(d.__data__=u.__data__),l[f]=d,D3(l[f],t,n,f,l,A3(u,n)));return new F3(a,this._parents,t,n)}function Ade(e){var t=this._name,n=this._id;typeof e!=`function`&&(e=X2(e));for(var r=this._groups,i=r.length,a=[],o=[],s=0;s<i;++s)for(var c=r[s],l=c.length,u,d=0;d<l;++d)if(u=c[d]){for(var f=e.call(u,u.__data__,d,c),p,m=A3(u,n),h=0,g=f.length;h<g;++h)(p=f[h])&&D3(p,t,n,h,f,m);a.push(f),o.push(u)}return new F3(a,o,t,n)}var jde=d4.prototype.constructor;function Mde(){return new jde(this._groups,this._parents)}function Nde(e,t){var n,r,i;return function(){var a=n4(this,e),o=(this.style.removeProperty(e),n4(this,e));return a===o?null:a===n&&o===r?i:i=t(n=a,r=o)}}function P3(e){return function(){this.style.removeProperty(e)}}function Pde(e,t,n){var r,i=n+``,a;return function(){var o=n4(this,e);return o===i?null:o===r?a:a=t(r=o,n)}}function Fde(e,t,n){var r,i,a;return function(){var o=n4(this,e),s=n(this),c=s+``;return s??(c=s=(this.style.removeProperty(e),n4(this,e))),o===c?null:o===r&&c===i?a:(i=c,a=t(r=o,s))}}function Ide(e,t){var n,r,i,a=`style.`+t,o=`end.`+a,s;return function(){var c=k3(this,e),l=c.on,u=c.value[a]==null?s||=P3(t):void 0;(l!==n||i!==u)&&(r=(n=l).copy()).on(o,i=u),c.on=r}}function Lde(e,t,n){var r=(e+=``)==`transform`?Rue:N3;return t==null?this.styleTween(e,Nde(e,r)).on(`end.style.`+e,P3(e)):typeof t==`function`?this.styleTween(e,Fde(e,r,M3(this,`style.`+e,t))).each(Ide(this._id,e)):this.styleTween(e,Pde(e,r,t),n).on(`end.style.`+e,null)}function Rde(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function zde(e,t,n){var r,i;function a(){var a=t.apply(this,arguments);return a!==i&&(r=(i=a)&&Rde(e,a,n)),r}return a._value=t,a}function Bde(e,t,n){var r=`style.`+(e+=``);if(arguments.length<2)return(r=this.tween(r))&&r._value;if(t==null)return this.tween(r,null);if(typeof t!=`function`)throw Error();return this.tween(r,zde(e,t,n??``))}function Vde(e){return function(){this.textContent=e}}function Hde(e){return function(){this.textContent=e(this)??``}}function Ude(e){return this.tween(`text`,typeof e==`function`?Hde(M3(this,`text`,e)):Vde(e==null?``:e+``))}function Wde(e){return function(t){this.textContent=e.call(this,t)}}function Gde(e){var t,n;function r(){var r=e.apply(this,arguments);return r!==n&&(t=(n=r)&&Wde(r)),t}return r._value=e,r}function Kde(e){var t=`text`;if(arguments.length<1)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!=`function`)throw Error();return this.tween(t,Gde(e))}function qde(){for(var e=this._name,t=this._id,n=I3(),r=this._groups,i=r.length,a=0;a<i;++a)for(var o=r[a],s=o.length,c,l=0;l<s;++l)if(c=o[l]){var u=A3(c,t);D3(c,e,n,l,o,{time:u.time+u.delay+u.duration,delay:0,duration:u.duration,ease:u.ease})}return new F3(r,this._parents,e,n)}function Jde(){var e,t,n=this,r=n._id,i=n.size();return new Promise(function(a,o){var s={value:o},c={value:function(){--i===0&&a()}};n.each(function(){var n=k3(this,r),i=n.on;i!==e&&(t=(e=i).copy(),t._.cancel.push(s),t._.interrupt.push(s),t._.end.push(c)),n.on=t}),i===0&&a()})}var Yde=0;function F3(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function Xde(e){return d4().transition(e)}function I3(){return++Yde}var L3=d4.prototype;F3.prototype=Xde.prototype={constructor:F3,select:kde,selectAll:Ade,selectChild:L3.selectChild,selectChildren:L3.selectChildren,filter:Sde,merge:Cde,selection:Mde,transition:qde,call:L3.call,nodes:L3.nodes,node:L3.node,size:L3.size,empty:L3.empty,each:L3.each,on:Ede,attr:ode,attrTween:dde,style:Lde,styleTween:Bde,text:Ude,textTween:Kde,remove:Ode,tween:$ue,delay:mde,duration:_de,ease:yde,easeVarying:xde,end:Jde,[Symbol.iterator]:L3[Symbol.iterator]};function Zde(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var Qde={time:null,delay:0,duration:250,ease:Zde};function $de(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw Error(`transition ${t} not found`);return n}function efe(e){var t,n;e instanceof F3?(t=e._id,e=e._name):(t=I3(),(n=Qde).time=x3(),e=e==null?null:e+``);for(var r=this._groups,i=r.length,a=0;a<i;++a)for(var o=r[a],s=o.length,c,l=0;l<s;++l)(c=o[l])&&D3(c,e,t,l,o,n||$de(c,t));return new F3(r,this._parents,e,t)}d4.prototype.interrupt=Xue,d4.prototype.transition=efe;var R3=e=>()=>e;function tfe(e,{sourceEvent:t,target:n,transform:r,dispatch:i}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:i}})}function z3(e,t,n){this.k=e,this.x=t,this.y=n}z3.prototype={constructor:z3,scale:function(e){return e===1?this:new z3(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new z3(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return`translate(`+this.x+`,`+this.y+`) scale(`+this.k+`)`}};var B3=new z3(1,0,0);V3.prototype=z3.prototype;function V3(e){for(;!e.__zoom;)if(!(e=e.parentNode))return B3;return e.__zoom}function H3(e){e.stopImmediatePropagation()}function U3(e){e.preventDefault(),e.stopImmediatePropagation()}function nfe(e){return(!e.ctrlKey||e.type===`wheel`)&&!e.button}function rfe(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute(`viewBox`)?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function W3(){return this.__zoom||B3}function ife(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function afe(){return navigator.maxTouchPoints||`ontouchstart`in this}function ofe(e,t,n){var r=e.invertX(t[0][0])-n[0][0],i=e.invertX(t[1][0])-n[1][0],a=e.invertY(t[0][1])-n[0][1],o=e.invertY(t[1][1])-n[1][1];return e.translate(i>r?(r+i)/2:Math.min(0,r)||Math.max(0,i),o>a?(a+o)/2:Math.min(0,a)||Math.max(0,o))}function G3(){var e=nfe,t=rfe,n=ofe,r=ife,i=afe,a=[0,1/0],o=[[-1/0,-1/0],[1/0,1/0]],s=250,c=l3,l=U2(`start`,`zoom`,`end`),u,d,f,p=500,m=150,h=0,g=10;function _(e){e.property(`__zoom`,W3).on(`wheel.zoom`,w,{passive:!1}).on(`mousedown.zoom`,T).on(`dblclick.zoom`,E).filter(i).on(`touchstart.zoom`,D).on(`touchmove.zoom`,ee).on(`touchend.zoom touchcancel.zoom`,te).style(`-webkit-tap-highlight-color`,`rgba(0,0,0,0)`)}_.transform=function(e,t,n,r){var i=e.selection?e.selection():e;i.property(`__zoom`,W3),e===i?i.interrupt().each(function(){S(this,arguments).event(r).start().zoom(null,typeof t==`function`?t.apply(this,arguments):t).end()}):x(e,t,n,r)},_.scaleBy=function(e,t,n,r){_.scaleTo(e,function(){return this.__zoom.k*(typeof t==`function`?t.apply(this,arguments):t)},n,r)},_.scaleTo=function(e,r,i,a){_.transform(e,function(){var e=t.apply(this,arguments),a=this.__zoom,s=i==null?b(e):typeof i==`function`?i.apply(this,arguments):i,c=a.invert(s),l=typeof r==`function`?r.apply(this,arguments):r;return n(y(v(a,l),s,c),e,o)},i,a)},_.translateBy=function(e,r,i,a){_.transform(e,function(){return n(this.__zoom.translate(typeof r==`function`?r.apply(this,arguments):r,typeof i==`function`?i.apply(this,arguments):i),t.apply(this,arguments),o)},null,a)},_.translateTo=function(e,r,i,a,s){_.transform(e,function(){var e=t.apply(this,arguments),s=this.__zoom,c=a==null?b(e):typeof a==`function`?a.apply(this,arguments):a;return n(B3.translate(c[0],c[1]).scale(s.k).translate(typeof r==`function`?-r.apply(this,arguments):-r,typeof i==`function`?-i.apply(this,arguments):-i),e,o)},a,s)};function v(e,t){return t=Math.max(a[0],Math.min(a[1],t)),t===e.k?e:new z3(t,e.x,e.y)}function y(e,t,n){var r=t[0]-n[0]*e.k,i=t[1]-n[1]*e.k;return r===e.x&&i===e.y?e:new z3(e.k,r,i)}function b(e){return[(+e[0][0]+ +e[1][0])/2,(+e[0][1]+ +e[1][1])/2]}function x(e,n,r,i){e.on(`start.zoom`,function(){S(this,arguments).event(i).start()}).on(`interrupt.zoom end.zoom`,function(){S(this,arguments).event(i).end()}).tween(`zoom`,function(){var e=this,a=arguments,o=S(e,a).event(i),s=t.apply(e,a),l=r==null?b(s):typeof r==`function`?r.apply(e,a):r,u=Math.max(s[1][0]-s[0][0],s[1][1]-s[0][1]),d=e.__zoom,f=typeof n==`function`?n.apply(e,a):n,p=c(d.invert(l).concat(u/d.k),f.invert(l).concat(u/f.k));return function(e){if(e===1)e=f;else{var t=p(e),n=u/t[2];e=new z3(n,l[0]-t[0]*n,l[1]-t[1]*n)}o.zoom(null,e)}})}function S(e,t,n){return!n&&e.__zooming||new C(e,t)}function C(e,n){this.that=e,this.args=n,this.active=0,this.sourceEvent=null,this.extent=t.apply(e,n),this.taps=0}C.prototype={event:function(e){return e&&(this.sourceEvent=e),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit(`start`)),this},zoom:function(e,t){return this.mouse&&e!==`mouse`&&(this.mouse[1]=t.invert(this.mouse[0])),this.touch0&&e!==`touch`&&(this.touch0[1]=t.invert(this.touch0[0])),this.touch1&&e!==`touch`&&(this.touch1[1]=t.invert(this.touch1[0])),this.that.__zoom=t,this.emit(`zoom`),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit(`end`)),this},emit:function(e){var t=f4(this.that).datum();l.call(e,this.that,new tfe(e,{sourceEvent:this.sourceEvent,target:_,type:e,transform:this.that.__zoom,dispatch:l}),t)}};function w(t,...i){if(!e.apply(this,arguments))return;var s=S(this,i).event(t),c=this.__zoom,l=Math.max(a[0],Math.min(a[1],c.k*2**r.apply(this,arguments))),u=p4(t);if(s.wheel)(s.mouse[0][0]!==u[0]||s.mouse[0][1]!==u[1])&&(s.mouse[1]=c.invert(s.mouse[0]=u)),clearTimeout(s.wheel);else if(c.k===l)return;else s.mouse=[u,c.invert(u)],j3(this),s.start();U3(t),s.wheel=setTimeout(d,m),s.zoom(`mouse`,n(y(v(c,l),s.mouse[0],s.mouse[1]),s.extent,o));function d(){s.wheel=null,s.end()}}function T(t,...r){if(f||!e.apply(this,arguments))return;var i=t.currentTarget,a=S(this,r,!0).event(t),s=f4(t.view).on(`mousemove.zoom`,d,!0).on(`mouseup.zoom`,p,!0),c=p4(t,i),l=t.clientX,u=t.clientY;_4(t.view),H3(t),a.mouse=[c,this.__zoom.invert(c)],j3(this),a.start();function d(e){if(U3(e),!a.moved){var t=e.clientX-l,r=e.clientY-u;a.moved=t*t+r*r>h}a.event(e).zoom(`mouse`,n(y(a.that.__zoom,a.mouse[0]=p4(e,i),a.mouse[1]),a.extent,o))}function p(e){s.on(`mousemove.zoom mouseup.zoom`,null),v4(e.view,a.moved),U3(e),a.event(e).end()}}function E(r,...i){if(e.apply(this,arguments)){var a=this.__zoom,c=p4(r.changedTouches?r.changedTouches[0]:r,this),l=a.invert(c),u=a.k*(r.shiftKey?.5:2),d=n(y(v(a,u),c,l),t.apply(this,i),o);U3(r),s>0?f4(this).transition().duration(s).call(x,d,c,r):f4(this).call(_.transform,d,c,r)}}function D(t,...n){if(e.apply(this,arguments)){var r=t.touches,i=r.length,a=S(this,n,t.changedTouches.length===i).event(t),o,s,c,l;for(H3(t),s=0;s<i;++s)c=r[s],l=p4(c,this),l=[l,this.__zoom.invert(l),c.identifier],a.touch0?!a.touch1&&a.touch0[2]!==l[2]&&(a.touch1=l,a.taps=0):(a.touch0=l,o=!0,a.taps=1+!!u);u&&=clearTimeout(u),o&&(a.taps<2&&(d=l[0],u=setTimeout(function(){u=null},p)),j3(this),a.start())}}function ee(e,...t){if(this.__zooming){var r=S(this,t).event(e),i=e.changedTouches,a=i.length,s,c,l,u;for(U3(e),s=0;s<a;++s)c=i[s],l=p4(c,this),r.touch0&&r.touch0[2]===c.identifier?r.touch0[0]=l:r.touch1&&r.touch1[2]===c.identifier&&(r.touch1[0]=l);if(c=r.that.__zoom,r.touch1){var d=r.touch0[0],f=r.touch0[1],p=r.touch1[0],m=r.touch1[1],h=(h=p[0]-d[0])*h+(h=p[1]-d[1])*h,g=(g=m[0]-f[0])*g+(g=m[1]-f[1])*g;c=v(c,Math.sqrt(h/g)),l=[(d[0]+p[0])/2,(d[1]+p[1])/2],u=[(f[0]+m[0])/2,(f[1]+m[1])/2]}else if(r.touch0)l=r.touch0[0],u=r.touch0[1];else return;r.zoom(`touch`,n(y(c,l,u),r.extent,o))}}function te(e,...t){if(this.__zooming){var n=S(this,t).event(e),r=e.changedTouches,i=r.length,a,o;for(H3(e),f&&clearTimeout(f),f=setTimeout(function(){f=null},p),a=0;a<i;++a)o=r[a],n.touch0&&n.touch0[2]===o.identifier?delete n.touch0:n.touch1&&n.touch1[2]===o.identifier&&delete n.touch1;if(n.touch1&&!n.touch0&&(n.touch0=n.touch1,delete n.touch1),n.touch0)n.touch0[1]=this.__zoom.invert(n.touch0[0]);else if(n.end(),n.taps===2&&(o=p4(o,this),Math.hypot(d[0]-o[0],d[1]-o[1])<g)){var s=f4(this).on(`dblclick.zoom`);s&&s.apply(this,arguments)}}}return _.wheelDelta=function(e){return arguments.length?(r=typeof e==`function`?e:R3(+e),_):r},_.filter=function(t){return arguments.length?(e=typeof t==`function`?t:R3(!!t),_):e},_.touchable=function(e){return arguments.length?(i=typeof e==`function`?e:R3(!!e),_):i},_.extent=function(e){return arguments.length?(t=typeof e==`function`?e:R3([[+e[0][0],+e[0][1]],[+e[1][0],+e[1][1]]]),_):t},_.scaleExtent=function(e){return arguments.length?(a[0]=+e[0],a[1]=+e[1],_):[a[0],a[1]]},_.translateExtent=function(e){return arguments.length?(o[0][0]=+e[0][0],o[1][0]=+e[1][0],o[0][1]=+e[0][1],o[1][1]=+e[1][1],_):[[o[0][0],o[0][1]],[o[1][0],o[1][1]]]},_.constrain=function(e){return arguments.length?(n=e,_):n},_.duration=function(e){return arguments.length?(s=+e,_):s},_.interpolate=function(e){return arguments.length?(c=e,_):c},_.on=function(){var e=l.on.apply(l,arguments);return e===l?_:e},_.clickDistance=function(e){return arguments.length?(h=(e=+e)*e,_):Math.sqrt(h)},_.tapDistance=function(e){return arguments.length?(g=+e,_):g},_}var K3={error001:()=>`[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001`,error002:()=>`It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.`,error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>`The React Flow parent container needs a width and a height to render the graph.`,error005:()=>`Only child nodes can use a parent extent.`,error006:()=>`Can't create edge. An edge needs a source and a target.`,error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:t,sourceHandle:n,targetHandle:r})=>`Couldn't create edge for ${e} handle id: "${e===`source`?n:r}", edge id: ${t}.`,error010:()=>`Handle: No node id found. Make sure to only use a Handle inside a custom Node.`,error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(e=`react`)=>`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>`useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.`,error015:()=>`It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs.`},q3=[[-1/0,-1/0],[1/0,1/0]],J3=[`Enter`,` `,`Escape`],Y3={"node.a11yDescription.default":`Press enter or space to select a node. Press delete to remove it and escape to cancel.`,"node.a11yDescription.keyboardDisabled":`Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.`,"node.a11yDescription.ariaLiveMessage":({direction:e,x:t,y:n})=>`Moved selected node ${e}. New position, x: ${t}, y: ${n}`,"edge.a11yDescription.default":`Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.`,"controls.ariaLabel":`Control Panel`,"controls.zoomIn.ariaLabel":`Zoom In`,"controls.zoomOut.ariaLabel":`Zoom Out`,"controls.fitView.ariaLabel":`Fit View`,"controls.interactive.ariaLabel":`Toggle Interactivity`,"minimap.ariaLabel":`Mini Map`,"handle.ariaLabel":`Handle`},X3;(function(e){e.Strict=`strict`,e.Loose=`loose`})(X3||={});var Z3;(function(e){e.Free=`free`,e.Vertical=`vertical`,e.Horizontal=`horizontal`})(Z3||={});var Q3;(function(e){e.Partial=`partial`,e.Full=`full`})(Q3||={});var $3={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null},e6;(function(e){e.Bezier=`default`,e.Straight=`straight`,e.Step=`step`,e.SmoothStep=`smoothstep`,e.SimpleBezier=`simplebezier`})(e6||={});var t6;(function(e){e.Arrow=`arrow`,e.ArrowClosed=`arrowclosed`})(t6||={});var $;(function(e){e.Left=`left`,e.Top=`top`,e.Right=`right`,e.Bottom=`bottom`})($||={});var n6={[$.Left]:$.Right,[$.Right]:$.Left,[$.Top]:$.Bottom,[$.Bottom]:$.Top};function r6(e){return e===null?null:e?`valid`:`invalid`}var i6=e=>`id`in e&&`source`in e&&`target`in e,sfe=e=>`id`in e&&`position`in e&&!(`source`in e)&&!(`target`in e),a6=e=>`id`in e&&`internals`in e&&!(`source`in e)&&!(`target`in e),o6=(e,t=[0,0])=>{let{width:n,height:r}=j6(e),i=e.origin??t,a=n*i[0],o=r*i[1];return{x:e.position.x-a,y:e.position.y-o}},cfe=(e,t={nodeOrigin:[0,0]})=>e.length===0?{x:0,y:0,width:0,height:0}:_6(e.reduce((e,n)=>{let r=typeof n==`string`,i=!t.nodeLookup&&!r?n:void 0;return t.nodeLookup&&(i=r?t.nodeLookup.get(n):a6(n)?n:t.nodeLookup.get(n.id)),h6(e,i?y6(i,t.nodeOrigin):{x:0,y:0,x2:0,y2:0})},{x:1/0,y:1/0,x2:-1/0,y2:-1/0})),s6=(e,t={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},r=!1;return e.forEach(e=>{(t.filter===void 0||t.filter(e))&&(n=h6(n,y6(e)),r=!0)}),r?_6(n):{x:0,y:0,width:0,height:0}},c6=(e,t,[n,r,i]=[0,0,1],a=!1,o=!1)=>{let s={...T6(t,[n,r,i]),width:t.width/i,height:t.height/i},c=[];for(let t of e.values()){let{measured:e,selectable:n=!0,hidden:r=!1}=t;if(o&&!n||r)continue;let i=e.width??t.width??t.initialWidth??null,l=e.height??t.height??t.initialHeight??null,u=x6(s,v6(t)),d=(i??0)*(l??0),f=a&&u>0;(!t.internals.handleBounds||f||u>=d||t.dragging)&&c.push(t)}return c},lfe=(e,t)=>{let n=new Set;return e.forEach(e=>{n.add(e.id)}),t.filter(e=>n.has(e.source)||n.has(e.target))};function ufe(e,t){let n=new Map,r=t?.nodes?new Set(t.nodes.map(e=>e.id)):null;return e.forEach(e=>{e.measured.width&&e.measured.height&&(t?.includeHiddenNodes||!e.hidden)&&(!r||r.has(e.id))&&n.set(e.id,e)}),n}async function dfe({nodes:e,width:t,height:n,panZoom:r,minZoom:i,maxZoom:a},o){if(e.size===0)return Promise.resolve(!0);let s=O6(s6(ufe(e,o)),t,n,o?.minZoom??i,o?.maxZoom??a,o?.padding??.1);return await r.setViewport(s,{duration:o?.duration,ease:o?.ease,interpolate:o?.interpolate}),Promise.resolve(!0)}function l6({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:r=[0,0],nodeExtent:i,onError:a}){let o=n.get(e),s=o.parentId?n.get(o.parentId):void 0,{x:c,y:l}=s?s.internals.positionAbsolute:{x:0,y:0},u=o.origin??r,d=o.extent||i;if(o.extent===`parent`&&!o.expandParent)if(!s)a?.(`005`,K3.error005());else{let e=s.measured.width,t=s.measured.height;e&&t&&(d=[[c,l],[c+e,l+t]])}else s&&A6(o.extent)&&(d=[[o.extent[0][0]+c,o.extent[0][1]+l],[o.extent[1][0]+c,o.extent[1][1]+l]]);let f=A6(d)?d6(t,d,o.measured):t;return(o.measured.width===void 0||o.measured.height===void 0)&&a?.(`015`,K3.error015()),{position:{x:f.x-c+(o.measured.width??0)*u[0],y:f.y-l+(o.measured.height??0)*u[1]},positionAbsolute:f}}async function ffe({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:r,onBeforeDelete:i}){let a=new Set(e.map(e=>e.id)),o=[];for(let e of n){if(e.deletable===!1)continue;let t=a.has(e.id),n=!t&&e.parentId&&o.find(t=>t.id===e.parentId);(t||n)&&o.push(e)}let s=new Set(t.map(e=>e.id)),c=r.filter(e=>e.deletable!==!1),l=lfe(o,c);for(let e of c)s.has(e.id)&&!l.find(t=>t.id===e.id)&&l.push(e);if(!i)return{edges:l,nodes:o};let u=await i({nodes:o,edges:l});return typeof u==`boolean`?u?{edges:l,nodes:o}:{edges:[],nodes:[]}:u}var u6=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),d6=(e={x:0,y:0},t,n)=>({x:u6(e.x,t[0][0],t[1][0]-(n?.width??0)),y:u6(e.y,t[0][1],t[1][1]-(n?.height??0))});function f6(e,t,n){let{width:r,height:i}=j6(n),{x:a,y:o}=n.internals.positionAbsolute;return d6(e,[[a,o],[a+r,o+i]],t)}var p6=(e,t,n)=>e<t?u6(Math.abs(e-t),1,t)/t:e>n?-u6(Math.abs(e-n),1,t)/t:0,m6=(e,t,n=15,r=40)=>[p6(e.x,r,t.width-r)*n,p6(e.y,r,t.height-r)*n],h6=(e,t)=>({x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}),g6=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),_6=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),v6=(e,t=[0,0])=>{let{x:n,y:r}=a6(e)?e.internals.positionAbsolute:o6(e,t);return{x:n,y:r,width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}},y6=(e,t=[0,0])=>{let{x:n,y:r}=a6(e)?e.internals.positionAbsolute:o6(e,t);return{x:n,y:r,x2:n+(e.measured?.width??e.width??e.initialWidth??0),y2:r+(e.measured?.height??e.height??e.initialHeight??0)}},b6=(e,t)=>_6(h6(g6(e),g6(t))),x6=(e,t)=>{let n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),r=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*r)},S6=e=>C6(e.width)&&C6(e.height)&&C6(e.x)&&C6(e.y),C6=e=>!isNaN(e)&&isFinite(e),pfe=(e,t)=>{},w6=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),T6=({x:e,y:t},[n,r,i],a=!1,o=[1,1])=>{let s={x:(e-n)/i,y:(t-r)/i};return a?w6(s,o):s},E6=({x:e,y:t},[n,r,i])=>({x:e*i+n,y:t*i+r});function D6(e,t){if(typeof e==`number`)return Math.floor((t-t/(1+e))*.5);if(typeof e==`string`&&e.endsWith(`px`)){let t=parseFloat(e);if(!Number.isNaN(t))return Math.floor(t)}if(typeof e==`string`&&e.endsWith(`%`)){let n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(t*n*.01)}return console.error(`[React Flow] The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function mfe(e,t,n){if(typeof e==`string`||typeof e==`number`){let r=D6(e,n),i=D6(e,t);return{top:r,right:i,bottom:r,left:i,x:i*2,y:r*2}}if(typeof e==`object`){let r=D6(e.top??e.y??0,n),i=D6(e.bottom??e.y??0,n),a=D6(e.left??e.x??0,t),o=D6(e.right??e.x??0,t);return{top:r,right:o,bottom:i,left:a,x:a+o,y:r+i}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function hfe(e,t,n,r,i,a){let{x:o,y:s}=E6(e,[t,n,r]),{x:c,y:l}=E6({x:e.x+e.width,y:e.y+e.height},[t,n,r]),u=i-c,d=a-l;return{left:Math.floor(o),top:Math.floor(s),right:Math.floor(u),bottom:Math.floor(d)}}var O6=(e,t,n,r,i,a)=>{let o=mfe(a,t,n),s=(t-o.x)/e.width,c=(n-o.y)/e.height,l=u6(Math.min(s,c),r,i),u=e.x+e.width/2,d=e.y+e.height/2,f=t/2-u*l,p=n/2-d*l,m=hfe(e,f,p,l,t,n),h={left:Math.min(m.left-o.left,0),top:Math.min(m.top-o.top,0),right:Math.min(m.right-o.right,0),bottom:Math.min(m.bottom-o.bottom,0)};return{x:f-h.left+h.right,y:p-h.top+h.bottom,zoom:l}},k6=()=>typeof navigator<`u`&&navigator?.userAgent?.indexOf(`Mac`)>=0;function A6(e){return e!=null&&e!==`parent`}function j6(e){return{width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}}function M6(e){return(e.measured?.width??e.width??e.initialWidth)!==void 0&&(e.measured?.height??e.height??e.initialHeight)!==void 0}function N6(e,t={width:0,height:0},n,r,i){let a={...e},o=r.get(n);if(o){let e=o.origin||i;a.x+=o.internals.positionAbsolute.x-(t.width??0)*e[0],a.y+=o.internals.positionAbsolute.y-(t.height??0)*e[1]}return a}function P6(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function gfe(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}function _fe(e){return{...Y3,...e||{}}}function F6(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:r,containerBounds:i}){let{x:a,y:o}=B6(e),s=T6({x:a-(i?.left??0),y:o-(i?.top??0)},r),{x:c,y:l}=n?w6(s,t):s;return{xSnapped:c,ySnapped:l,...s}}var I6=e=>({width:e.offsetWidth,height:e.offsetHeight}),L6=e=>e?.getRootNode?.()||window?.document,vfe=[`INPUT`,`SELECT`,`TEXTAREA`];function R6(e){let t=e.composedPath?.()?.[0]||e.target;return t?.nodeType===1?vfe.includes(t.nodeName)||t.hasAttribute(`contenteditable`)||!!t.closest(`.nokey`):!1}var z6=e=>`clientX`in e,B6=(e,t)=>{let n=z6(e),r=n?e.clientX:e.touches?.[0].clientX,i=n?e.clientY:e.touches?.[0].clientY;return{x:r-(t?.left??0),y:i-(t?.top??0)}},V6=(e,t,n,r,i)=>{let a=t.querySelectorAll(`.${e}`);return!a||!a.length?null:Array.from(a).map(t=>{let a=t.getBoundingClientRect();return{id:t.getAttribute(`data-handleid`),type:e,nodeId:i,position:t.getAttribute(`data-handlepos`),x:(a.left-n.left)/r,y:(a.top-n.top)/r,...I6(t)}})};function H6({sourceX:e,sourceY:t,targetX:n,targetY:r,sourceControlX:i,sourceControlY:a,targetControlX:o,targetControlY:s}){let c=e*.125+i*.375+o*.375+n*.125,l=t*.125+a*.375+s*.375+r*.125;return[c,l,Math.abs(c-e),Math.abs(l-t)]}function U6(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function W6({pos:e,x1:t,y1:n,x2:r,y2:i,c:a}){switch(e){case $.Left:return[t-U6(t-r,a),n];case $.Right:return[t+U6(r-t,a),n];case $.Top:return[t,n-U6(n-i,a)];case $.Bottom:return[t,n+U6(i-n,a)]}}function G6({sourceX:e,sourceY:t,sourcePosition:n=$.Bottom,targetX:r,targetY:i,targetPosition:a=$.Top,curvature:o=.25}){let[s,c]=W6({pos:n,x1:e,y1:t,x2:r,y2:i,c:o}),[l,u]=W6({pos:a,x1:r,y1:i,x2:e,y2:t,c:o}),[d,f,p,m]=H6({sourceX:e,sourceY:t,targetX:r,targetY:i,sourceControlX:s,sourceControlY:c,targetControlX:l,targetControlY:u});return[`M${e},${t} C${s},${c} ${l},${u} ${r},${i}`,d,f,p,m]}function K6({sourceX:e,sourceY:t,targetX:n,targetY:r}){let i=Math.abs(n-e)/2,a=n<e?n+i:n-i,o=Math.abs(r-t)/2;return[a,r<t?r+o:r-o,i,o]}function yfe({sourceNode:e,targetNode:t,selected:n=!1,zIndex:r=0,elevateOnSelect:i=!1,zIndexMode:a=`basic`}){return a===`manual`?r:(i&&n?r+1e3:r)+Math.max(e.parentId||i&&e.selected?e.internals.z:0,t.parentId||i&&t.selected?t.internals.z:0)}function bfe({sourceNode:e,targetNode:t,width:n,height:r,transform:i}){let a=h6(y6(e),y6(t));return a.x===a.x2&&(a.x2+=1),a.y===a.y2&&(a.y2+=1),x6({x:-i[0]/i[2],y:-i[1]/i[2],width:n/i[2],height:r/i[2]},_6(a))>0}var xfe=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`xy-edge__${e}${t||``}-${n}${r||``}`,Sfe=(e,t)=>t.some(t=>t.source===e.source&&t.target===e.target&&(t.sourceHandle===e.sourceHandle||!t.sourceHandle&&!e.sourceHandle)&&(t.targetHandle===e.targetHandle||!t.targetHandle&&!e.targetHandle)),Cfe=(e,t,n={})=>{if(!e.source||!e.target)return K3.error006(),t;let r=n.getEdgeId||xfe,i;return i=i6(e)?{...e}:{...e,id:r(e)},Sfe(i,t)?t:(i.sourceHandle===null&&delete i.sourceHandle,i.targetHandle===null&&delete i.targetHandle,t.concat(i))};function q6({sourceX:e,sourceY:t,targetX:n,targetY:r}){let[i,a,o,s]=K6({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,i,a,o,s]}var J6={[$.Left]:{x:-1,y:0},[$.Right]:{x:1,y:0},[$.Top]:{x:0,y:-1},[$.Bottom]:{x:0,y:1}},wfe=({source:e,sourcePosition:t=$.Bottom,target:n})=>t===$.Left||t===$.Right?e.x<n.x?{x:1,y:0}:{x:-1,y:0}:e.y<n.y?{x:0,y:1}:{x:0,y:-1},Y6=(e,t)=>Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2);function Tfe({source:e,sourcePosition:t=$.Bottom,target:n,targetPosition:r=$.Top,center:i,offset:a,stepPosition:o}){let s=J6[t],c=J6[r],l={x:e.x+s.x*a,y:e.y+s.y*a},u={x:n.x+c.x*a,y:n.y+c.y*a},d=wfe({source:l,sourcePosition:t,target:u}),f=d.x===0?`y`:`x`,p=d[f],m=[],h,g,_={x:0,y:0},v={x:0,y:0},[,,y,b]=K6({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(s[f]*c[f]===-1){f===`x`?(h=i.x??l.x+(u.x-l.x)*o,g=i.y??(l.y+u.y)/2):(h=i.x??(l.x+u.x)/2,g=i.y??l.y+(u.y-l.y)*o);let e=[{x:h,y:l.y},{x:h,y:u.y}],t=[{x:l.x,y:g},{x:u.x,y:g}];m=s[f]===p?f===`x`?e:t:f===`x`?t:e}else{let i=[{x:l.x,y:u.y}],o=[{x:u.x,y:l.y}];if(m=f===`x`?s.x===p?o:i:s.y===p?i:o,t===r){let t=Math.abs(e[f]-n[f]);if(t<=a){let r=Math.min(a-1,a-t);s[f]===p?_[f]=(l[f]>e[f]?-1:1)*r:v[f]=(u[f]>n[f]?-1:1)*r}}if(t!==r){let e=f===`x`?`y`:`x`,t=s[f]===c[e],n=l[e]>u[e],r=l[e]<u[e];(s[f]===1&&(!t&&n||t&&r)||s[f]!==1&&(!t&&r||t&&n))&&(m=f===`x`?i:o)}let d={x:l.x+_.x,y:l.y+_.y},y={x:u.x+v.x,y:u.y+v.y};Math.max(Math.abs(d.x-m[0].x),Math.abs(y.x-m[0].x))>=Math.max(Math.abs(d.y-m[0].y),Math.abs(y.y-m[0].y))?(h=(d.x+y.x)/2,g=m[0].y):(h=m[0].x,g=(d.y+y.y)/2)}return[[e,{x:l.x+_.x,y:l.y+_.y},...m,{x:u.x+v.x,y:u.y+v.y},n],h,g,y,b]}function Efe(e,t,n,r){let i=Math.min(Y6(e,t)/2,Y6(t,n)/2,r),{x:a,y:o}=t;if(e.x===a&&a===n.x||e.y===o&&o===n.y)return`L${a} ${o}`;if(e.y===o){let t=e.x<n.x?-1:1,r=e.y<n.y?1:-1;return`L ${a+i*t},${o}Q ${a},${o} ${a},${o+i*r}`}let s=e.x<n.x?1:-1;return`L ${a},${o+i*(e.y<n.y?-1:1)}Q ${a},${o} ${a+i*s},${o}`}function X6({sourceX:e,sourceY:t,sourcePosition:n=$.Bottom,targetX:r,targetY:i,targetPosition:a=$.Top,borderRadius:o=5,centerX:s,centerY:c,offset:l=20,stepPosition:u=.5}){let[d,f,p,m,h]=Tfe({source:{x:e,y:t},sourcePosition:n,target:{x:r,y:i},targetPosition:a,center:{x:s,y:c},offset:l,stepPosition:u});return[d.reduce((e,t,n)=>{let r=``;return r=n>0&&n<d.length-1?Efe(d[n-1],t,d[n+1],o):`${n===0?`M`:`L`}${t.x} ${t.y}`,e+=r,e},``),f,p,m,h]}function Z6(e){return e&&!!(e.internals.handleBounds||e.handles?.length)&&!!(e.measured.width||e.width||e.initialWidth)}function Dfe(e){let{sourceNode:t,targetNode:n}=e;if(!Z6(t)||!Z6(n))return null;let r=t.internals.handleBounds||Q6(t.handles),i=n.internals.handleBounds||Q6(n.handles),a=e8(r?.source??[],e.sourceHandle),o=e8(e.connectionMode===X3.Strict?i?.target??[]:(i?.target??[]).concat(i?.source??[]),e.targetHandle);if(!a||!o)return e.onError?.(`008`,K3.error008(a?`target`:`source`,{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;let s=a?.position||$.Bottom,c=o?.position||$.Top,l=$6(t,a,s),u=$6(n,o,c);return{sourceX:l.x,sourceY:l.y,targetX:u.x,targetY:u.y,sourcePosition:s,targetPosition:c}}function Q6(e){if(!e)return null;let t=[],n=[];for(let r of e)r.width=r.width??1,r.height=r.height??1,r.type===`source`?t.push(r):r.type===`target`&&n.push(r);return{source:t,target:n}}function $6(e,t,n=$.Left,r=!1){let i=(t?.x??0)+e.internals.positionAbsolute.x,a=(t?.y??0)+e.internals.positionAbsolute.y,{width:o,height:s}=t??j6(e);if(r)return{x:i+o/2,y:a+s/2};switch(t?.position??n){case $.Top:return{x:i+o/2,y:a};case $.Right:return{x:i+o,y:a+s/2};case $.Bottom:return{x:i+o/2,y:a+s};case $.Left:return{x:i,y:a+s/2}}}function e8(e,t){return e&&(t?e.find(e=>e.id===t):e[0])||null}function t8(e,t){return e?typeof e==`string`?e:`${t?`${t}__`:``}${Object.keys(e).sort().map(t=>`${t}=${e[t]}`).join(`&`)}`:``}function Ofe(e,{id:t,defaultColor:n,defaultMarkerStart:r,defaultMarkerEnd:i}){let a=new Set;return e.reduce((e,o)=>([o.markerStart||r,o.markerEnd||i].forEach(r=>{if(r&&typeof r==`object`){let i=t8(r,t);a.has(i)||(e.push({id:i,color:r.color||n,...r}),a.add(i))}}),e),[]).sort((e,t)=>e.id.localeCompare(t.id))}var n8=1e3,kfe=10,r8={nodeOrigin:[0,0],nodeExtent:q3,elevateNodesOnSelect:!0,zIndexMode:`basic`,defaults:{}},Afe={...r8,checkEquality:!0};function i8(e,t){let n={...e};for(let e in t)t[e]!==void 0&&(n[e]=t[e]);return n}function jfe(e,t,n){let r=i8(r8,n);for(let n of e.values())if(n.parentId)s8(n,e,t,r);else{let e=d6(o6(n,r.nodeOrigin),A6(n.extent)?n.extent:r.nodeExtent,j6(n));n.internals.positionAbsolute=e}}function Mfe(e,t){if(!e.handles)return e.measured?t?.internals.handleBounds:void 0;let n=[],r=[];for(let t of e.handles){let i={id:t.id,width:t.width??1,height:t.height??1,nodeId:e.id,x:t.x,y:t.y,position:t.position,type:t.type};t.type===`source`?n.push(i):t.type===`target`&&r.push(i)}return{source:n,target:r}}function a8(e){return e===`manual`}function o8(e,t,n,r={}){let i=i8(Afe,r),a={i:0},o=new Map(t),s=i?.elevateNodesOnSelect&&!a8(i.zIndexMode)?n8:0,c=e.length>0;t.clear(),n.clear();for(let l of e){let e=o.get(l.id);if(i.checkEquality&&l===e?.internals.userNode)t.set(l.id,e);else{let n=d6(o6(l,i.nodeOrigin),A6(l.extent)?l.extent:i.nodeExtent,j6(l));e={...i.defaults,...l,measured:{width:l.measured?.width,height:l.measured?.height},internals:{positionAbsolute:n,handleBounds:Mfe(l,e),z:c8(l,s,i.zIndexMode),userNode:l}},t.set(l.id,e)}(e.measured===void 0||e.measured.width===void 0||e.measured.height===void 0)&&!e.hidden&&(c=!1),l.parentId&&s8(e,t,n,r,a)}return c}function Nfe(e,t){if(!e.parentId)return;let n=t.get(e.parentId);n?n.set(e.id,e):t.set(e.parentId,new Map([[e.id,e]]))}function s8(e,t,n,r,i){let{elevateNodesOnSelect:a,nodeOrigin:o,nodeExtent:s,zIndexMode:c}=i8(r8,r),l=e.parentId,u=t.get(l);if(!u){console.warn(`Parent node ${l} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}Nfe(e,n),i&&!u.parentId&&u.internals.rootParentIndex===void 0&&c===`auto`&&(u.internals.rootParentIndex=++i.i,u.internals.z=u.internals.z+i.i*kfe),i&&u.internals.rootParentIndex!==void 0&&(i.i=u.internals.rootParentIndex);let{x:d,y:f,z:p}=Pfe(e,u,o,s,a&&!a8(c)?n8:0,c),{positionAbsolute:m}=e.internals,h=d!==m.x||f!==m.y;(h||p!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:h?{x:d,y:f}:m,z:p}})}function c8(e,t,n){let r=C6(e.zIndex)?e.zIndex:0;return a8(n)?r:r+(e.selected?t:0)}function Pfe(e,t,n,r,i,a){let{x:o,y:s}=t.internals.positionAbsolute,c=j6(e),l=o6(e,n),u=A6(e.extent)?d6(l,e.extent,c):l,d=d6({x:o+u.x,y:s+u.y},r,c);e.extent===`parent`&&(d=f6(d,c,t));let f=c8(e,i,a),p=t.internals.z??0;return{x:d.x,y:d.y,z:p>=f?p+1:f}}function l8(e,t,n,r=[0,0]){let i=[],a=new Map;for(let n of e){let e=t.get(n.parentId);if(!e)continue;let r=b6(a.get(n.parentId)?.expandedRect??v6(e),n.rect);a.set(n.parentId,{expandedRect:r,parent:e})}return a.size>0&&a.forEach(({expandedRect:t,parent:a},o)=>{let s=a.internals.positionAbsolute,c=j6(a),l=a.origin??r,u=t.x<s.x?Math.round(Math.abs(s.x-t.x)):0,d=t.y<s.y?Math.round(Math.abs(s.y-t.y)):0,f=Math.max(c.width,Math.round(t.width)),p=Math.max(c.height,Math.round(t.height)),m=(f-c.width)*l[0],h=(p-c.height)*l[1];(u>0||d>0||m||h)&&(i.push({id:o,type:`position`,position:{x:a.position.x-u+m,y:a.position.y-d+h}}),n.get(o)?.forEach(t=>{e.some(e=>e.id===t.id)||i.push({id:t.id,type:`position`,position:{x:t.position.x+u,y:t.position.y+d}})})),(c.width<t.width||c.height<t.height||u||d)&&i.push({id:o,type:`dimensions`,setAttributes:!0,dimensions:{width:f+(u?l[0]*u-m:0),height:p+(d?l[1]*d-h:0)}})}),i}function Ffe(e,t,n,r,i,a,o){let s=r?.querySelector(`.xyflow__viewport`),c=!1;if(!s)return{changes:[],updatedInternals:c};let l=[],u=window.getComputedStyle(s),{m22:d}=new window.DOMMatrixReadOnly(u.transform),f=[];for(let r of e.values()){let e=t.get(r.id);if(!e)continue;if(e.hidden){t.set(e.id,{...e,internals:{...e.internals,handleBounds:void 0}}),c=!0;continue}let s=I6(r.nodeElement),u=e.measured.width!==s.width||e.measured.height!==s.height;if(s.width&&s.height&&(u||!e.internals.handleBounds||r.force)){let p=r.nodeElement.getBoundingClientRect(),m=A6(e.extent)?e.extent:a,{positionAbsolute:h}=e.internals;e.parentId&&e.extent===`parent`?h=f6(h,s,t.get(e.parentId)):m&&(h=d6(h,m,s));let g={...e,measured:s,internals:{...e.internals,positionAbsolute:h,handleBounds:{source:V6(`source`,r.nodeElement,p,d,e.id),target:V6(`target`,r.nodeElement,p,d,e.id)}}};t.set(e.id,g),e.parentId&&s8(g,t,n,{nodeOrigin:i,zIndexMode:o}),c=!0,u&&(l.push({id:e.id,type:`dimensions`,dimensions:s}),e.expandParent&&e.parentId&&f.push({id:e.id,parentId:e.parentId,rect:v6(g,i)}))}}if(f.length>0){let e=l8(f,t,n,i);l.push(...e)}return{changes:l,updatedInternals:c}}async function Ife({delta:e,panZoom:t,transform:n,translateExtent:r,width:i,height:a}){if(!t||!e.x&&!e.y)return Promise.resolve(!1);let o=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[i,a]],r),s=!!o&&(o.x!==n[0]||o.y!==n[1]||o.k!==n[2]);return Promise.resolve(s)}function u8(e,t,n,r,i,a){let o=i,s=r.get(o)||new Map;r.set(o,s.set(n,t)),o=`${i}-${e}`;let c=r.get(o)||new Map;if(r.set(o,c.set(n,t)),a){o=`${i}-${e}-${a}`;let s=r.get(o)||new Map;r.set(o,s.set(n,t))}}function d8(e,t,n){e.clear(),t.clear();for(let r of n){let{source:n,target:i,sourceHandle:a=null,targetHandle:o=null}=r,s={edgeId:r.id,source:n,target:i,sourceHandle:a,targetHandle:o},c=`${n}-${a}--${i}-${o}`;u8(`source`,s,`${i}-${o}--${n}-${a}`,e,n,a),u8(`target`,s,c,e,i,o),t.set(r.id,r)}}function f8(e,t){if(!e.parentId)return!1;let n=t.get(e.parentId);return n?n.selected?!0:f8(n,t):!1}function p8(e,t,n){let r=e;do{if(r?.matches?.(t))return!0;if(r===n)return!1;r=r?.parentElement}while(r);return!1}function Lfe(e,t,n,r){let i=new Map;for(let[a,o]of e)if((o.selected||o.id===r)&&(!o.parentId||!f8(o,e))&&(o.draggable||t&&o.draggable===void 0)){let t=e.get(a);t&&i.set(a,{id:a,position:t.position||{x:0,y:0},distance:{x:n.x-t.internals.positionAbsolute.x,y:n.y-t.internals.positionAbsolute.y},extent:t.extent,parentId:t.parentId,origin:t.origin,expandParent:t.expandParent,internals:{positionAbsolute:t.internals.positionAbsolute||{x:0,y:0}},measured:{width:t.measured.width??0,height:t.measured.height??0}})}return i}function m8({nodeId:e,dragItems:t,nodeLookup:n,dragging:r=!0}){let i=[];for(let[e,a]of t){let t=n.get(e)?.internals.userNode;t&&i.push({...t,position:a.position,dragging:r})}if(!e)return[i[0],i];let a=n.get(e)?.internals.userNode;return[a?{...a,position:t.get(e)?.position||a.position,dragging:r}:i[0],i]}function Rfe({dragItems:e,snapGrid:t,x:n,y:r}){let i=e.values().next().value;if(!i)return null;let a={x:n-i.distance.x,y:r-i.distance.y},o=w6(a,t);return{x:o.x-a.x,y:o.y-a.y}}function zfe({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:r,onDragStop:i}){let a={x:null,y:null},o=0,s=new Map,c=!1,l={x:0,y:0},u=null,d=!1,f=null,p=!1,m=!1,h=null;function g({noDragClassName:g,handleSelector:_,domNode:v,isSelectable:y,nodeId:b,nodeClickDistance:x=0}){f=f4(v);function S({x:e,y:n}){let{nodeLookup:i,nodeExtent:o,snapGrid:c,snapToGrid:l,nodeOrigin:u,onNodeDrag:d,onSelectionDrag:f,onError:p,updateNodePositions:g}=t();a={x:e,y:n};let _=!1,v=s.size>1,y=v&&o?g6(s6(s)):null,x=v&&l?Rfe({dragItems:s,snapGrid:c,x:e,y:n}):null;for(let[t,r]of s){if(!i.has(t))continue;let a={x:e-r.distance.x,y:n-r.distance.y};l&&(a=x?{x:Math.round(a.x+x.x),y:Math.round(a.y+x.y)}:w6(a,c));let s=null;if(v&&o&&!r.extent&&y){let{positionAbsolute:e}=r.internals,t=e.x-y.x+o[0][0],n=e.x+r.measured.width-y.x2+o[1][0],i=e.y-y.y+o[0][1],a=e.y+r.measured.height-y.y2+o[1][1];s=[[t,i],[n,a]]}let{position:d,positionAbsolute:f}=l6({nodeId:t,nextPosition:a,nodeLookup:i,nodeExtent:s||o,nodeOrigin:u,onError:p});_=_||r.position.x!==d.x||r.position.y!==d.y,r.position=d,r.internals.positionAbsolute=f}if(m||=_,_&&(g(s,!0),h&&(r||d||!b&&f))){let[e,t]=m8({nodeId:b,dragItems:s,nodeLookup:i});r?.(h,s,e,t),d?.(h,e,t),b||f?.(h,t)}}async function C(){if(!u)return;let{transform:e,panBy:n,autoPanSpeed:r,autoPanOnNodeDrag:i}=t();if(!i){c=!1,cancelAnimationFrame(o);return}let[s,d]=m6(l,u,r);(s!==0||d!==0)&&(a.x=(a.x??0)-s/e[2],a.y=(a.y??0)-d/e[2],await n({x:s,y:d})&&S(a)),o=requestAnimationFrame(C)}function w(r){let{nodeLookup:i,multiSelectionActive:o,nodesDraggable:c,transform:l,snapGrid:f,snapToGrid:p,selectNodesOnDrag:m,onNodeDragStart:h,onSelectionDragStart:g,unselectNodesAndEdges:_}=t();d=!0,(!m||!y)&&!o&&b&&(i.get(b)?.selected||_()),y&&m&&b&&e?.(b);let v=F6(r.sourceEvent,{transform:l,snapGrid:f,snapToGrid:p,containerBounds:u});if(a=v,s=Lfe(i,c,v,b),s.size>0&&(n||h||!b&&g)){let[e,t]=m8({nodeId:b,dragItems:s,nodeLookup:i});n?.(r.sourceEvent,s,e,t),h?.(r.sourceEvent,e,t),b||g?.(r.sourceEvent,t)}}let T=x4().clickDistance(x).on(`start`,e=>{let{domNode:n,nodeDragThreshold:r,transform:i,snapGrid:o,snapToGrid:s}=t();u=n?.getBoundingClientRect()||null,p=!1,m=!1,h=e.sourceEvent,r===0&&w(e),a=F6(e.sourceEvent,{transform:i,snapGrid:o,snapToGrid:s,containerBounds:u}),l=B6(e.sourceEvent,u)}).on(`drag`,e=>{let{autoPanOnNodeDrag:n,transform:r,snapGrid:i,snapToGrid:o,nodeDragThreshold:f,nodeLookup:m}=t(),g=F6(e.sourceEvent,{transform:r,snapGrid:i,snapToGrid:o,containerBounds:u});if(h=e.sourceEvent,(e.sourceEvent.type===`touchmove`&&e.sourceEvent.touches.length>1||b&&!m.has(b))&&(p=!0),!p){if(!c&&n&&d&&(c=!0,C()),!d){let t=B6(e.sourceEvent,u),n=t.x-l.x,r=t.y-l.y;Math.sqrt(n*n+r*r)>f&&w(e)}(a.x!==g.xSnapped||a.y!==g.ySnapped)&&s&&d&&(l=B6(e.sourceEvent,u),S(g))}}).on(`end`,e=>{if(!(!d||p)&&(c=!1,d=!1,cancelAnimationFrame(o),s.size>0)){let{nodeLookup:n,updateNodePositions:r,onNodeDragStop:a,onSelectionDragStop:o}=t();if(m&&=(r(s,!1),!1),i||a||!b&&o){let[t,r]=m8({nodeId:b,dragItems:s,nodeLookup:n,dragging:!1});i?.(e.sourceEvent,s,t,r),a?.(e.sourceEvent,t,r),b||o?.(e.sourceEvent,r)}}}).filter(e=>{let t=e.target;return!e.button&&(!g||!p8(t,`.${g}`,v))&&(!_||p8(t,_,v))});f.call(T)}function _(){f?.on(`.drag`,null)}return{update:g,destroy:_}}function Bfe(e,t,n){let r=[],i={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(let e of t.values())x6(i,v6(e))>0&&r.push(e);return r}var Vfe=250;function Hfe(e,t,n,r){let i=[],a=1/0,o=Bfe(e,n,t+Vfe);for(let n of o){let o=[...n.internals.handleBounds?.source??[],...n.internals.handleBounds?.target??[]];for(let s of o){if(r.nodeId===s.nodeId&&r.type===s.type&&r.id===s.id)continue;let{x:o,y:c}=$6(n,s,s.position,!0),l=Math.sqrt((o-e.x)**2+(c-e.y)**2);l>t||(l<a?(i=[{...s,x:o,y:c}],a=l):l===a&&i.push({...s,x:o,y:c}))}}if(!i.length)return null;if(i.length>1){let e=r.type===`source`?`target`:`source`;return i.find(t=>t.type===e)??i[0]}return i[0]}function h8(e,t,n,r,i,a=!1){let o=r.get(e);if(!o)return null;let s=i===`strict`?o.internals.handleBounds?.[t]:[...o.internals.handleBounds?.source??[],...o.internals.handleBounds?.target??[]],c=(n?s?.find(e=>e.id===n):s?.[0])??null;return c&&a?{...c,...$6(o,c,c.position,!0)}:c}function g8(e,t){return e||(t?.classList.contains(`target`)?`target`:t?.classList.contains(`source`)?`source`:null)}function Ufe(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}var _8=()=>!0;function Wfe(e,{connectionMode:t,connectionRadius:n,handleId:r,nodeId:i,edgeUpdaterType:a,isTarget:o,domNode:s,nodeLookup:c,lib:l,autoPanOnConnect:u,flowId:d,panBy:f,cancelConnection:p,onConnectStart:m,onConnect:h,onConnectEnd:g,isValidConnection:_=_8,onReconnectEnd:v,updateConnection:y,getTransform:b,getFromHandle:x,autoPanSpeed:S,dragThreshold:C=1,handleDomNode:w}){let T=L6(e.target),E=0,D,{x:ee,y:te}=B6(e),ne=g8(a,w),O=s?.getBoundingClientRect(),k=!1;if(!O||!ne)return;let re=h8(i,ne,r,c,t);if(!re)return;let ie=B6(e,O),ae=!1,oe=null,se=!1,ce=null;function le(){if(!u||!O)return;let[e,t]=m6(ie,O,S);f({x:e,y:t}),E=requestAnimationFrame(le)}let ue={...re,nodeId:i,type:ne,position:re.position},de=c.get(i),fe={inProgress:!0,isValid:null,from:$6(de,ue,$.Left,!0),fromHandle:ue,fromPosition:ue.position,fromNode:de,to:ie,toHandle:null,toPosition:n6[ue.position],toNode:null,pointer:ie};function pe(){k=!0,y(fe),m?.(e,{nodeId:i,handleId:r,handleType:ne})}C===0&&pe();function me(e){if(!k){let{x:t,y:n}=B6(e),r=t-ee,i=n-te;if(!(r*r+i*i>C*C))return;pe()}if(!x()||!ue){he(e);return}let a=b();ie=B6(e,O),D=Hfe(T6(ie,a,!1,[1,1]),n,c,ue),ae||=(le(),!0);let s=v8(e,{handle:D,connectionMode:t,fromNodeId:i,fromHandleId:r,fromType:o?`target`:`source`,isValidConnection:_,doc:T,lib:l,flowId:d,nodeLookup:c});ce=s.handleDomNode,oe=s.connection,se=Ufe(!!D,s.isValid);let u=c.get(i),f=u?$6(u,ue,$.Left,!0):fe.from,p={...fe,from:f,isValid:se,to:s.toHandle&&se?E6({x:s.toHandle.x,y:s.toHandle.y},a):ie,toHandle:s.toHandle,toPosition:se&&s.toHandle?s.toHandle.position:n6[ue.position],toNode:s.toHandle?c.get(s.toHandle.nodeId):null,pointer:ie};y(p),fe=p}function he(e){if(!(`touches`in e&&e.touches.length>0)){if(k){(D||ce)&&oe&&se&&h?.(oe);let{inProgress:t,...n}=fe,r={...n,toPosition:fe.toHandle?fe.toPosition:null};g?.(e,r),a&&v?.(e,r)}p(),cancelAnimationFrame(E),ae=!1,se=!1,oe=null,ce=null,T.removeEventListener(`mousemove`,me),T.removeEventListener(`mouseup`,he),T.removeEventListener(`touchmove`,me),T.removeEventListener(`touchend`,he)}}T.addEventListener(`mousemove`,me),T.addEventListener(`mouseup`,he),T.addEventListener(`touchmove`,me),T.addEventListener(`touchend`,he)}function v8(e,{handle:t,connectionMode:n,fromNodeId:r,fromHandleId:i,fromType:a,doc:o,lib:s,flowId:c,isValidConnection:l=_8,nodeLookup:u}){let d=a===`target`,f=t?o.querySelector(`.${s}-flow__handle[data-id="${c}-${t?.nodeId}-${t?.id}-${t?.type}"]`):null,{x:p,y:m}=B6(e),h=o.elementFromPoint(p,m),g=h?.classList.contains(`${s}-flow__handle`)?h:f,_={handleDomNode:g,isValid:!1,connection:null,toHandle:null};if(g){let e=g8(void 0,g),t=g.getAttribute(`data-nodeid`),a=g.getAttribute(`data-handleid`),o=g.classList.contains(`connectable`),s=g.classList.contains(`connectableend`);if(!t||!e)return _;let c={source:d?t:r,sourceHandle:d?a:i,target:d?r:t,targetHandle:d?i:a};_.connection=c,_.isValid=o&&s&&(n===X3.Strict?d&&e===`source`||!d&&e===`target`:t!==r||a!==i)&&l(c),_.toHandle=h8(t,e,a,u,n,!0)}return _}var y8={onPointerDown:Wfe,isValid:v8};function Gfe({domNode:e,panZoom:t,getTransform:n,getViewScale:r}){let i=f4(e);function a({translateExtent:e,width:a,height:o,zoomStep:s=1,pannable:c=!0,zoomable:l=!0,inversePan:u=!1}){let d=e=>{if(e.sourceEvent.type!==`wheel`||!t)return;let r=n(),i=e.sourceEvent.ctrlKey&&k6()?10:1,a=-e.sourceEvent.deltaY*(e.sourceEvent.deltaMode===1?.05:e.sourceEvent.deltaMode?1:.002)*s,o=r[2]*2**(a*i);t.scaleTo(o)},f=[0,0],p=G3().on(`start`,e=>{(e.sourceEvent.type===`mousedown`||e.sourceEvent.type===`touchstart`)&&(f=[e.sourceEvent.clientX??e.sourceEvent.touches[0].clientX,e.sourceEvent.clientY??e.sourceEvent.touches[0].clientY])}).on(`zoom`,c?i=>{let s=n();if(i.sourceEvent.type!==`mousemove`&&i.sourceEvent.type!==`touchmove`||!t)return;let c=[i.sourceEvent.clientX??i.sourceEvent.touches[0].clientX,i.sourceEvent.clientY??i.sourceEvent.touches[0].clientY],l=[c[0]-f[0],c[1]-f[1]];f=c;let d=r()*Math.max(s[2],Math.log(s[2]))*(u?-1:1),p={x:s[0]-l[0]*d,y:s[1]-l[1]*d},m=[[0,0],[a,o]];t.setViewportConstrained({x:p.x,y:p.y,zoom:s[2]},m,e)}:null).on(`zoom.wheel`,l?d:null);i.call(p,{})}function o(){i.on(`zoom`,null)}return{update:a,destroy:o,pointer:p4}}var b8=e=>({x:e.x,y:e.y,zoom:e.k}),x8=({x:e,y:t,zoom:n})=>B3.translate(e,t).scale(n),S8=(e,t)=>e.target.closest(`.${t}`),C8=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),Kfe=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,w8=(e,t=0,n=Kfe,r=()=>{})=>{let i=typeof t==`number`&&t>0;return i||r(),i?e.transition().duration(t).ease(n).on(`end`,r):e},T8=e=>{let t=e.ctrlKey&&k6()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function qfe({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:r,panOnScrollMode:i,panOnScrollSpeed:a,zoomOnPinch:o,onPanZoomStart:s,onPanZoom:c,onPanZoomEnd:l}){return u=>{if(S8(u,t))return u.ctrlKey&&u.preventDefault(),!1;u.preventDefault(),u.stopImmediatePropagation();let d=n.property(`__zoom`).k||1;if(u.ctrlKey&&o){let e=p4(u),t=d*2**T8(u);r.scaleTo(n,t,e,u);return}let f=u.deltaMode===1?20:1,p=i===Z3.Vertical?0:u.deltaX*f,m=i===Z3.Horizontal?0:u.deltaY*f;!k6()&&u.shiftKey&&i!==Z3.Vertical&&(p=u.deltaY*f,m=0),r.translateBy(n,-(p/d)*a,-(m/d)*a,{internal:!0});let h=b8(n.property(`__zoom`));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(c?.(u,h),e.panScrollTimeout=setTimeout(()=>{l?.(u,h),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,s?.(u,h))}}function Jfe({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(r,i){let a=r.type===`wheel`,o=!t&&a&&!r.ctrlKey,s=S8(r,e);if(r.ctrlKey&&a&&s&&r.preventDefault(),o||s)return null;r.preventDefault(),n.call(this,r,i)}}function Yfe({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return r=>{if(r.sourceEvent?.internal)return;let i=b8(r.transform);e.mouseButton=r.sourceEvent?.button||0,e.isZoomingOrPanning=!0,e.prevViewport=i,r.sourceEvent?.type===`mousedown`&&t(!0),n&&n?.(r.sourceEvent,i)}}function Xfe({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:r,onPanZoom:i}){return a=>{e.usedRightMouseButton=!!(n&&C8(t,e.mouseButton??0)),a.sourceEvent?.sync||r([a.transform.x,a.transform.y,a.transform.k]),i&&!a.sourceEvent?.internal&&i?.(a.sourceEvent,b8(a.transform))}}function Zfe({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:r,onPanZoomEnd:i,onPaneContextMenu:a}){return o=>{if(!o.sourceEvent?.internal&&(e.isZoomingOrPanning=!1,a&&C8(t,e.mouseButton??0)&&!e.usedRightMouseButton&&o.sourceEvent&&a(o.sourceEvent),e.usedRightMouseButton=!1,r(!1),i)){let t=b8(o.transform);e.prevViewport=t,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{i?.(o.sourceEvent,t)},n?150:0)}}}function Qfe({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:r,panOnScroll:i,zoomOnDoubleClick:a,userSelectionActive:o,noWheelClassName:s,noPanClassName:c,lib:l,connectionInProgress:u}){return d=>{let f=e||t,p=n&&d.ctrlKey,m=d.type===`wheel`;if(d.button===1&&d.type===`mousedown`&&(S8(d,`${l}-flow__node`)||S8(d,`${l}-flow__edge`)))return!0;if(!r&&!f&&!i&&!a&&!n||o||u&&!m||S8(d,s)&&m||S8(d,c)&&(!m||i&&m&&!e)||!n&&d.ctrlKey&&m)return!1;if(!n&&d.type===`touchstart`&&d.touches?.length>1)return d.preventDefault(),!1;if(!f&&!i&&!p&&m||!r&&(d.type===`mousedown`||d.type===`touchstart`)||Array.isArray(r)&&!r.includes(d.button)&&d.type===`mousedown`)return!1;let h=Array.isArray(r)&&r.includes(d.button)||!d.button||d.button<=1;return(!d.ctrlKey||m)&&h}}function $fe({domNode:e,minZoom:t,maxZoom:n,translateExtent:r,viewport:i,onPanZoom:a,onPanZoomStart:o,onPanZoomEnd:s,onDraggingChange:c}){let l={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{x:0,y:0,zoom:0},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},u=e.getBoundingClientRect(),d=G3().scaleExtent([t,n]).translateExtent(r),f=f4(e).call(d);v({x:i.x,y:i.y,zoom:u6(i.zoom,t,n)},[[0,0],[u.width,u.height]],r);let p=f.on(`wheel.zoom`),m=f.on(`dblclick.zoom`);d.wheelDelta(T8);function h(e,t){return f?new Promise(n=>{d?.interpolate(t?.interpolate===`linear`?n3:l3).transform(w8(f,t?.duration,t?.ease,()=>n(!0)),e)}):Promise.resolve(!1)}function g({noWheelClassName:e,noPanClassName:t,onPaneContextMenu:n,userSelectionActive:r,panOnScroll:i,panOnDrag:u,panOnScrollMode:h,panOnScrollSpeed:g,preventScrolling:v,zoomOnPinch:y,zoomOnScroll:b,zoomOnDoubleClick:x,zoomActivationKeyPressed:S,lib:C,onTransformChange:w,connectionInProgress:T,paneClickDistance:E,selectionOnDrag:D}){r&&!l.isZoomingOrPanning&&_();let ee=i&&!S&&!r;d.clickDistance(D?1/0:!C6(E)||E<0?0:E);let te=ee?qfe({zoomPanValues:l,noWheelClassName:e,d3Selection:f,d3Zoom:d,panOnScrollMode:h,panOnScrollSpeed:g,zoomOnPinch:y,onPanZoomStart:o,onPanZoom:a,onPanZoomEnd:s}):Jfe({noWheelClassName:e,preventScrolling:v,d3ZoomHandler:p});if(f.on(`wheel.zoom`,te,{passive:!1}),!r){let e=Yfe({zoomPanValues:l,onDraggingChange:c,onPanZoomStart:o});d.on(`start`,e);let t=Xfe({zoomPanValues:l,panOnDrag:u,onPaneContextMenu:!!n,onPanZoom:a,onTransformChange:w});d.on(`zoom`,t);let r=Zfe({zoomPanValues:l,panOnDrag:u,panOnScroll:i,onPaneContextMenu:n,onPanZoomEnd:s,onDraggingChange:c});d.on(`end`,r)}let ne=Qfe({zoomActivationKeyPressed:S,panOnDrag:u,zoomOnScroll:b,panOnScroll:i,zoomOnDoubleClick:x,zoomOnPinch:y,userSelectionActive:r,noPanClassName:t,noWheelClassName:e,lib:C,connectionInProgress:T});d.filter(ne),x?f.on(`dblclick.zoom`,m):f.on(`dblclick.zoom`,null)}function _(){d.on(`zoom`,null)}async function v(e,t,n){let r=x8(e),i=d?.constrain()(r,t,n);return i&&await h(i),new Promise(e=>e(i))}async function y(e,t){let n=x8(e);return await h(n,t),new Promise(e=>e(n))}function b(e){if(f){let t=x8(e),n=f.property(`__zoom`);(n.k!==e.zoom||n.x!==e.x||n.y!==e.y)&&d?.transform(f,t,null,{sync:!0})}}function x(){let e=f?V3(f.node()):{x:0,y:0,k:1};return{x:e.x,y:e.y,zoom:e.k}}function S(e,t){return f?new Promise(n=>{d?.interpolate(t?.interpolate===`linear`?n3:l3).scaleTo(w8(f,t?.duration,t?.ease,()=>n(!0)),e)}):Promise.resolve(!1)}function C(e,t){return f?new Promise(n=>{d?.interpolate(t?.interpolate===`linear`?n3:l3).scaleBy(w8(f,t?.duration,t?.ease,()=>n(!0)),e)}):Promise.resolve(!1)}function w(e){d?.scaleExtent(e)}function T(e){d?.translateExtent(e)}function E(e){let t=!C6(e)||e<0?0:e;d?.clickDistance(t)}return{update:g,destroy:_,setViewport:y,setViewportConstrained:v,getViewport:x,scaleTo:S,scaleBy:C,setScaleExtent:w,setTranslateExtent:T,syncViewport:b,setClickDistance:E}}var E8;(function(e){e.Line=`line`,e.Handle=`handle`})(E8||={});function epe({width:e,prevWidth:t,height:n,prevHeight:r,affectsX:i,affectsY:a}){let o=e-t,s=n-r,c=[o>0?1:o<0?-1:0,s>0?1:s<0?-1:0];return o&&i&&(c[0]*=-1),s&&a&&(c[1]*=-1),c}function D8(e){return{isHorizontal:e.includes(`right`)||e.includes(`left`),isVertical:e.includes(`bottom`)||e.includes(`top`),affectsX:e.includes(`left`),affectsY:e.includes(`top`)}}function O8(e,t){return Math.max(0,t-e)}function k8(e,t){return Math.max(0,e-t)}function A8(e,t,n){return Math.max(0,t-e,e-n)}function j8(e,t){return e?!t:t}function tpe(e,t,n,r,i,a,o,s){let{affectsX:c,affectsY:l}=t,{isHorizontal:u,isVertical:d}=t,f=u&&d,{xSnapped:p,ySnapped:m}=n,{minWidth:h,maxWidth:g,minHeight:_,maxHeight:v}=r,{x:y,y:b,width:x,height:S,aspectRatio:C}=e,w=Math.floor(u?p-e.pointerX:0),T=Math.floor(d?m-e.pointerY:0),E=x+(c?-w:w),D=S+(l?-T:T),ee=-a[0]*x,te=-a[1]*S,ne=A8(E,h,g),O=A8(D,_,v);if(o){let e=0,t=0;c&&w<0?e=O8(y+w+ee,o[0][0]):!c&&w>0&&(e=k8(y+E+ee,o[1][0])),l&&T<0?t=O8(b+T+te,o[0][1]):!l&&T>0&&(t=k8(b+D+te,o[1][1])),ne=Math.max(ne,e),O=Math.max(O,t)}if(s){let e=0,t=0;c&&w>0?e=k8(y+w,s[0][0]):!c&&w<0&&(e=O8(y+E,s[1][0])),l&&T>0?t=k8(b+T,s[0][1]):!l&&T<0&&(t=O8(b+D,s[1][1])),ne=Math.max(ne,e),O=Math.max(O,t)}if(i){if(u){let e=A8(E/C,_,v)*C;if(ne=Math.max(ne,e),o){let e=0;e=!c&&!l||c&&!l&&f?k8(b+te+E/C,o[1][1])*C:O8(b+te+(c?w:-w)/C,o[0][1])*C,ne=Math.max(ne,e)}if(s){let e=0;e=!c&&!l||c&&!l&&f?O8(b+E/C,s[1][1])*C:k8(b+(c?w:-w)/C,s[0][1])*C,ne=Math.max(ne,e)}}if(d){let e=A8(D*C,h,g)/C;if(O=Math.max(O,e),o){let e=0;e=!c&&!l||l&&!c&&f?k8(y+D*C+ee,o[1][0])/C:O8(y+(l?T:-T)*C+ee,o[0][0])/C,O=Math.max(O,e)}if(s){let e=0;e=!c&&!l||l&&!c&&f?O8(y+D*C,s[1][0])/C:k8(y+(l?T:-T)*C,s[0][0])/C,O=Math.max(O,e)}}}T+=T<0?O:-O,w+=w<0?ne:-ne,i&&(f?E>D*C?T=(j8(c,l)?-w:w)/C:w=(j8(c,l)?-T:T)*C:u?(T=w/C,l=c):(w=T*C,c=l));let k=c?y+w:y,re=l?b+T:b;return{width:x+(c?-w:w),height:S+(l?-T:T),x:a[0]*w*(c?-1:1)+k,y:a[1]*T*(l?-1:1)+re}}var M8={width:0,height:0,x:0,y:0},npe={...M8,pointerX:0,pointerY:0,aspectRatio:1};function rpe(e){return[[0,0],[e.measured.width,e.measured.height]]}function ipe(e,t,n){let r=t.position.x+e.position.x,i=t.position.y+e.position.y,a=e.measured.width??0,o=e.measured.height??0,s=n[0]*a,c=n[1]*o;return[[r-s,i-c],[r+a-s,i+o-c]]}function ape({domNode:e,nodeId:t,getStoreItems:n,onChange:r,onEnd:i}){let a=f4(e),o={controlDirection:D8(`bottom-right`),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function s({controlPosition:e,boundaries:s,keepAspectRatio:c,resizeDirection:l,onResizeStart:u,onResize:d,onResizeEnd:f,shouldResize:p}){let m={...M8},h={...npe};o={boundaries:s,resizeDirection:l,keepAspectRatio:c,controlDirection:D8(e)};let g,_=null,v=[],y,b,x,S=!1,C=x4().on(`start`,e=>{let{nodeLookup:r,transform:i,snapGrid:a,snapToGrid:o,nodeOrigin:s,paneDomNode:c}=n();if(g=r.get(t),!g)return;_=c?.getBoundingClientRect()??null;let{xSnapped:l,ySnapped:d}=F6(e.sourceEvent,{transform:i,snapGrid:a,snapToGrid:o,containerBounds:_});m={width:g.measured.width??0,height:g.measured.height??0,x:g.position.x??0,y:g.position.y??0},h={...m,pointerX:l,pointerY:d,aspectRatio:m.width/m.height},y=void 0,g.parentId&&(g.extent===`parent`||g.expandParent)&&(y=r.get(g.parentId),b=y&&g.extent===`parent`?rpe(y):void 0),v=[],x=void 0;for(let[e,n]of r)if(n.parentId===t&&(v.push({id:e,position:{...n.position},extent:n.extent}),n.extent===`parent`||n.expandParent)){let e=ipe(n,g,n.origin??s);x=x?[[Math.min(e[0][0],x[0][0]),Math.min(e[0][1],x[0][1])],[Math.max(e[1][0],x[1][0]),Math.max(e[1][1],x[1][1])]]:e}u?.(e,{...m})}).on(`drag`,e=>{let{transform:t,snapGrid:i,snapToGrid:a,nodeOrigin:s}=n(),c=F6(e.sourceEvent,{transform:t,snapGrid:i,snapToGrid:a,containerBounds:_}),l=[];if(!g)return;let{x:u,y:f,width:C,height:w}=m,T={},E=g.origin??s,{width:D,height:ee,x:te,y:ne}=tpe(h,o.controlDirection,c,o.boundaries,o.keepAspectRatio,E,b,x),O=D!==C,k=ee!==w,re=te!==u&&O,ie=ne!==f&&k;if(!re&&!ie&&!O&&!k)return;if((re||ie||E[0]===1||E[1]===1)&&(T.x=re?te:m.x,T.y=ie?ne:m.y,m.x=T.x,m.y=T.y,v.length>0)){let e=te-u,t=ne-f;for(let n of v)n.position={x:n.position.x-e+E[0]*(D-C),y:n.position.y-t+E[1]*(ee-w)},l.push(n)}if((O||k)&&(T.width=O&&(!o.resizeDirection||o.resizeDirection===`horizontal`)?D:m.width,T.height=k&&(!o.resizeDirection||o.resizeDirection===`vertical`)?ee:m.height,m.width=T.width,m.height=T.height),y&&g.expandParent){let e=E[0]*(T.width??0);T.x&&T.x<e&&(m.x=e,h.x-=T.x-e);let t=E[1]*(T.height??0);T.y&&T.y<t&&(m.y=t,h.y-=T.y-t)}let ae=epe({width:m.width,prevWidth:C,height:m.height,prevHeight:w,affectsX:o.controlDirection.affectsX,affectsY:o.controlDirection.affectsY}),oe={...m,direction:ae};p?.(e,oe)!==!1&&(S=!0,d?.(e,oe),r(T,l))}).on(`end`,e=>{S&&=(f?.(e,{...m}),i?.({...m}),!1)});a.call(C)}function c(){a.on(`.drag`,null)}return{update:s,destroy:c}}var ope=i((e=>{var t=gn(),n=d();function r(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var i=typeof Object.is==`function`?Object.is:r,a=n.useSyncExternalStore,o=t.useRef,s=t.useEffect,c=t.useMemo,l=t.useDebugValue;e.useSyncExternalStoreWithSelector=function(e,t,n,r,u){var d=o(null);if(d.current===null){var f={hasValue:!1,value:null};d.current=f}else f=d.current;d=c(function(){function e(e){if(!a){if(a=!0,o=e,e=r(e),u!==void 0&&f.hasValue){var t=f.value;if(u(t,e))return s=t}return s=e}if(t=s,i(o,e))return t;var n=r(e);return u!==void 0&&u(t,n)?(o=e,t):(o=e,s=n)}var a=!1,o,s,c=n===void 0?null:n;return[function(){return e(t())},c===null?void 0:function(){return e(c())}]},[t,n,r,u]);var p=a(e,d[0],d[1]);return s(function(){f.hasValue=!0,f.value=p},[p]),l(p),p}})),spe=e(i(((e,t)=>{t.exports=ope()}))(),1),N8=e=>{let t,n=new Set,r=(e,r)=>{let i=typeof e==`function`?e(t):e;if(!Object.is(i,t)){let e=t;t=r??(typeof i!=`object`||!i)?i:Object.assign({},t,i),n.forEach(n=>n(t,e))}},i=()=>t,a={setState:r,getState:i,getInitialState:()=>o,subscribe:e=>(n.add(e),()=>n.delete(e)),destroy:()=>{n.clear()}},o=t=e(r,i,a);return a},cpe=e=>e?N8(e):N8,{useDebugValue:lpe}=L.default,{useSyncExternalStoreWithSelector:upe}=spe.default,dpe=e=>e;function P8(e,t=dpe,n){let r=upe(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return lpe(r),r}var F8=(e,t)=>{let n=cpe(e),r=(e,r=t)=>P8(n,e,r);return Object.assign(r,n),r},fpe=(e,t)=>e?F8(e,t):F8;function I8(e,t){if(Object.is(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(let[n,r]of e)if(!Object.is(r,t.get(n)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||!Object.is(e[r],t[r]))return!1;return!0}var L8=(0,L.createContext)(null),ppe=L8.Provider,R8=K3.error001();function z8(e,t){let n=(0,L.useContext)(L8);if(n===null)throw Error(R8);return P8(n,e,t)}function B8(){let e=(0,L.useContext)(L8);if(e===null)throw Error(R8);return(0,L.useMemo)(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}var V8={display:`none`},mpe={position:`absolute`,width:1,height:1,margin:-1,border:0,padding:0,overflow:`hidden`,clip:`rect(0px, 0px, 0px, 0px)`,clipPath:`inset(100%)`},H8=`react-flow__node-desc`,U8=`react-flow__edge-desc`,hpe=`react-flow__aria-live`,gpe=e=>e.ariaLiveMessage,_pe=e=>e.ariaLabelConfig;function vpe({rfId:e}){let t=z8(gpe);return(0,I.jsx)(`div`,{id:`${hpe}-${e}`,"aria-live":`assertive`,"aria-atomic":`true`,style:mpe,children:t})}function ype({rfId:e,disableKeyboardA11y:t}){let n=z8(_pe);return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`div`,{id:`${H8}-${e}`,style:V8,children:t?n[`node.a11yDescription.default`]:n[`node.a11yDescription.keyboardDisabled`]}),(0,I.jsx)(`div`,{id:`${U8}-${e}`,style:V8,children:n[`edge.a11yDescription.default`]}),!t&&(0,I.jsx)(vpe,{rfId:e})]})}var W8=(0,L.forwardRef)(({position:e=`top-left`,children:t,className:n,style:r,...i},a)=>(0,I.jsx)(`div`,{className:H2([`react-flow__panel`,n,...`${e}`.split(`-`)]),style:r,ref:a,...i,children:t}));W8.displayName=`Panel`;function bpe({proOptions:e,position:t=`bottom-right`}){return e?.hideAttribution?null:(0,I.jsx)(W8,{position:t,className:`react-flow__attribution`,"data-message":`Please only hide this attribution when you are subscribed to React Flow Pro: https://pro.reactflow.dev`,children:(0,I.jsx)(`a`,{href:`https://reactflow.dev`,target:`_blank`,rel:`noopener noreferrer`,"aria-label":`React Flow attribution`,children:`React Flow`})})}var xpe=e=>{let t=[],n=[];for(let[,n]of e.nodeLookup)n.selected&&t.push(n.internals.userNode);for(let[,t]of e.edgeLookup)t.selected&&n.push(t);return{selectedNodes:t,selectedEdges:n}},G8=e=>e.id;function Spe(e,t){return I8(e.selectedNodes.map(G8),t.selectedNodes.map(G8))&&I8(e.selectedEdges.map(G8),t.selectedEdges.map(G8))}function Cpe({onSelectionChange:e}){let t=B8(),{selectedNodes:n,selectedEdges:r}=z8(xpe,Spe);return(0,L.useEffect)(()=>{let i={nodes:n,edges:r};e?.(i),t.getState().onSelectionChangeHandlers.forEach(e=>e(i))},[n,r,e]),null}var wpe=e=>!!e.onSelectionChangeHandlers;function Tpe({onSelectionChange:e}){let t=z8(wpe);return e||t?(0,I.jsx)(Cpe,{onSelectionChange:e}):null}var K8=[0,0],Epe={x:0,y:0,zoom:1},q8=[...`nodes.edges.defaultNodes.defaultEdges.onConnect.onConnectStart.onConnectEnd.onClickConnectStart.onClickConnectEnd.nodesDraggable.autoPanOnNodeFocus.nodesConnectable.nodesFocusable.edgesFocusable.edgesReconnectable.elevateNodesOnSelect.elevateEdgesOnSelect.minZoom.maxZoom.nodeExtent.onNodesChange.onEdgesChange.elementsSelectable.connectionMode.snapGrid.snapToGrid.translateExtent.connectOnClick.defaultEdgeOptions.fitView.fitViewOptions.onNodesDelete.onEdgesDelete.onDelete.onNodeDrag.onNodeDragStart.onNodeDragStop.onSelectionDrag.onSelectionDragStart.onSelectionDragStop.onMoveStart.onMove.onMoveEnd.noPanClassName.nodeOrigin.autoPanOnConnect.autoPanOnNodeDrag.onError.connectionRadius.isValidConnection.selectNodesOnDrag.nodeDragThreshold.connectionDragThreshold.onBeforeDelete.debug.autoPanSpeed.ariaLabelConfig.zIndexMode`.split(`.`),`rfId`],Dpe=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges}),J8={translateExtent:q3,nodeOrigin:K8,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:`nopan`,rfId:`1`};function Ope(e){let{setNodes:t,setEdges:n,setMinZoom:r,setMaxZoom:i,setTranslateExtent:a,setNodeExtent:o,reset:s,setDefaultNodesAndEdges:c}=z8(Dpe,I8),l=B8();(0,L.useEffect)(()=>(c(e.defaultNodes,e.defaultEdges),()=>{u.current=J8,s()}),[]);let u=(0,L.useRef)(J8);return(0,L.useEffect)(()=>{for(let s of q8){let c=e[s];c!==u.current[s]&&e[s]!==void 0&&(s===`nodes`?t(c):s===`edges`?n(c):s===`minZoom`?r(c):s===`maxZoom`?i(c):s===`translateExtent`?a(c):s===`nodeExtent`?o(c):s===`ariaLabelConfig`?l.setState({ariaLabelConfig:_fe(c)}):s===`fitView`?l.setState({fitViewQueued:c}):s===`fitViewOptions`?l.setState({fitViewOptions:c}):l.setState({[s]:c}))}u.current=e},q8.map(t=>e[t])),null}function Y8(){return typeof window>`u`||!window.matchMedia?null:window.matchMedia(`(prefers-color-scheme: dark)`)}function kpe(e){let[t,n]=(0,L.useState)(e===`system`?null:e);return(0,L.useEffect)(()=>{if(e!==`system`){n(e);return}let t=Y8(),r=()=>n(t?.matches?`dark`:`light`);return r(),t?.addEventListener(`change`,r),()=>{t?.removeEventListener(`change`,r)}},[e]),t===null?Y8()?.matches?`dark`:`light`:t}var X8=typeof document<`u`?document:null;function Z8(e=null,t={target:X8,actInsideInputWithModifier:!0}){let[n,r]=(0,L.useState)(!1),i=(0,L.useRef)(!1),a=(0,L.useRef)(new Set([])),[o,s]=(0,L.useMemo)(()=>{if(e!==null){let t=(Array.isArray(e)?e:[e]).filter(e=>typeof e==`string`).map(e=>e.replace(`+`,`
2187
+ claude mcp remove ${e.serverName}`})]})]})})]}),(0,I.jsxs)(xt,{value:`config`,borderWidth:`0`,children:[(0,I.jsxs)(pn,{cursor:`pointer`,py:2,_hover:{bg:`newGray.50`},fontSize:`xs`,color:`newGray.500`,fontWeight:`500`,borderRadius:`sm`,px:2,mx:-2,children:[(0,I.jsx)(A,{flex:`1`,textAlign:`left`,children:`Option 2: Configuration File`}),(0,I.jsx)(an,{})]}),(0,I.jsx)(tt,{children:(0,I.jsx)(M,{align:`stretch`,gap:3,pt:2,pb:2,children:(0,I.jsxs)(A,{children:[(0,I.jsx)(k,{fontSize:`xs`,color:`newGray.400`,mb:2,children:`Add to your MCP configuration file (e.g., ~/.claude.json for Claude Code):`}),(0,I.jsxs)(A,{position:`relative`,className:`group`,children:[(0,I.jsx)(Jt,{display:`block`,whiteSpace:`pre`,p:3,fontSize:`xs`,bg:`newGray.50`,borderRadius:`md`,overflow:`auto`,children:e.claudeConfigSnippet}),(0,I.jsx)(Ze,{"aria-label":`Copy config`,size:`xs`,variant:`plain`,color:`newGray.400`,position:`absolute`,top:2,right:2,opacity:0,_groupHover:{opacity:1},onClick:n,children:(0,I.jsx)(vf,{})})]})]})})})]})]}),(0,I.jsxs)(A,{mt:4,pt:4,borderTopWidth:`1px`,borderColor:`newGray.100`,children:[(0,I.jsx)(k,{fontSize:`xs`,fontWeight:`500`,color:`newGray.500`,mb:2,children:`Authentication`}),(0,I.jsx)(k,{fontSize:`xs`,color:`newGray.400`,children:`When you start working with the MCP server, you will be prompted to authenticate using one of the available methods.`})]})]})]})})}),I1=3e3,L1=class{_oauthParams=null;_isAuthorizing=!1;_authorizeError=null;_isAuthorized=!1;_redirectUri=null;_redirectTimer=null;constructor(){f(this,{},{autoBind:!0})}get oauthClientName(){return this._oauthParams?.clientName??``}get isAuthorizing(){return this._isAuthorizing}get authorizeError(){return this._authorizeError}get isAuthorized(){return this._isAuthorized}get hasOAuthParams(){return this._oauthParams!==null}deny(){if(!this._oauthParams)return;let e=new URL(this._oauthParams.redirectUri);e.searchParams.set(`error`,`access_denied`),e.searchParams.set(`state`,this._oauthParams.state),globalThis.location.href=e.toString()}async approve(){if(this._oauthParams&&!(this._isAuthorizing||this._isAuthorized)){c(()=>{this._isAuthorizing=!0,this._authorizeError=null});try{let e=await fetch(`/oauth/authorize`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({client_id:this._oauthParams.clientId,redirect_uri:this._oauthParams.redirectUri,code_challenge:this._oauthParams.codeChallenge,state:this._oauthParams.state,...this._oauthParams.scope?{scope:this._oauthParams.scope}:{}})});if(!e.ok){let t=await e.json().catch(()=>null);throw Error(t?.message||`Authorization failed`)}let t=await e.json();c(()=>{this._isAuthorized=!0,this._redirectUri=t.redirect_uri,this._isAuthorizing=!1}),this._redirectTimer&&clearTimeout(this._redirectTimer),this._redirectTimer=setTimeout(()=>{this._redirectUri&&(globalThis.location.href=this._redirectUri)},I1)}catch(e){c(()=>{this._authorizeError=e instanceof Error?e.message:`Authorization failed`,this._isAuthorizing=!1})}}}redirectNow(){this._redirectTimer&&clearTimeout(this._redirectTimer),this._redirectUri&&(globalThis.location.href=this._redirectUri)}init(){let e=new URLSearchParams(globalThis.location.search),t=e.get(`client_id`),n=e.get(`client_name`),r=e.get(`redirect_uri`),i=e.get(`code_challenge`),a=e.get(`state`);if(t&&n&&r&&i&&a){try{new URL(r)}catch{return}this._oauthParams={clientId:t,clientName:n,redirectUri:r,codeChallenge:i,state:a,scope:e.get(`scope`)??void 0}}}dispose(){this._redirectTimer&&clearTimeout(this._redirectTimer)}};Y.register(L1,()=>new L1,{scope:`request`});var R1=g(({model:e})=>{let t=(0,L.useCallback)(()=>{e.redirectNow()},[e]);return(0,I.jsx)(Vq,{hideSidebar:!0,children:(0,I.jsx)(j,{alignItems:`center`,justifyContent:`center`,flex:1,children:(0,I.jsxs)(M,{gap:6,maxWidth:`400px`,textAlign:`center`,children:[(0,I.jsx)(k,{fontSize:`lg`,fontWeight:`500`,color:`newGray.500`,children:`Authorization Successful`}),(0,I.jsx)(k,{fontSize:`sm`,color:`newGray.400`,children:`Redirecting back to the application...`}),(0,I.jsx)(N,{variant:`outline`,colorPalette:`gray`,size:`sm`,onClick:t,children:`Continue now`})]})})})}),z1=g(()=>{let e=CB(L1),t=(0,L.useCallback)(async()=>{await e.approve()},[e]),n=(0,L.useCallback)(()=>{e.deny()},[e]);return e.hasOAuthParams?e.isAuthorized?(0,I.jsx)(R1,{model:e}):(0,I.jsx)(Vq,{hideSidebar:!0,children:(0,I.jsx)(j,{alignItems:`center`,justifyContent:`center`,flex:1,children:(0,I.jsxs)(M,{gap:6,maxWidth:`400px`,textAlign:`center`,children:[(0,I.jsx)(k,{fontSize:`lg`,fontWeight:`500`,color:`newGray.500`,children:`Authorize Application`}),(0,I.jsx)(A,{p:4,bg:`newGray.50`,borderRadius:`md`,borderWidth:`1px`,borderColor:`newGray.100`,width:`100%`,children:(0,I.jsxs)(k,{fontSize:`sm`,color:`newGray.400`,children:[(0,I.jsx)(k,{as:`span`,fontWeight:`600`,color:`newGray.500`,children:e.oauthClientName}),` `,`wants to access your Revisium account.`]})}),e.authorizeError&&(0,I.jsx)(A,{p:3,bg:`red.50`,borderRadius:`md`,borderWidth:`1px`,borderColor:`red.200`,width:`100%`,children:(0,I.jsx)(k,{fontSize:`xs`,color:`red.500`,children:e.authorizeError})}),(0,I.jsxs)(j,{gap:3,width:`100%`,children:[(0,I.jsx)(N,{flex:1,variant:`outline`,colorPalette:`gray`,size:`sm`,onClick:n,disabled:e.isAuthorizing,children:`Deny`}),(0,I.jsx)(N,{flex:1,colorPalette:`blue`,size:`sm`,onClick:t,loading:e.isAuthorizing,children:`Authorize`})]}),(0,I.jsx)(k,{fontSize:`xs`,color:`newGray.300`,children:`This will allow the application to access Revisium on your behalf.`})]})})}):(0,I.jsx)(Vq,{hideSidebar:!0,children:(0,I.jsx)(j,{alignItems:`center`,justifyContent:`center`,flex:1,children:(0,I.jsx)(k,{color:`newGray.400`,children:`Missing OAuth parameters.`})})})}),B1=class{_accessToken=null;_loading=!1;constructor(e){this.apiService=e,f(this,{},{autoBind:!0})}get hasAccessToken(){return!!this._accessToken}get accessToken(){return this._accessToken||``}get loading(){return this._loading}get truncatedToken(){let e=this.accessToken;return e.length<=30?e:`${e.slice(0,20)}...${e.slice(-10)}`}async copyAccessToken(){if(!this._accessToken)return!1;try{return await GV(this._accessToken),!0}catch{return!1}}init(){this.fetchAccessToken()}dispose(){this._accessToken=null}async fetchAccessToken(){c(()=>{this._loading=!0});try{let e=await this.apiService.client.issueAccessToken();c(()=>{this._accessToken=e.issueAccessToken.accessToken})}catch{c(()=>{this._accessToken=null})}finally{c(()=>{this._loading=!1})}}};Y.register(B1,()=>new B1(Y.get(dJ)),{scope:`request`});var V1=g(()=>{let e=CB(B1),t=Tn(),n=(0,L.useCallback)(async()=>{await e.copyAccessToken()?Jq.info({description:`Access token copied to clipboard`}):Jq.error({description:`Failed to copy token`})},[e]),r=(0,L.useCallback)(()=>{t(`/`)},[t]);return e.loading?(0,I.jsx)(Vq,{hideSidebar:!0,children:(0,I.jsx)(j,{alignItems:`center`,justifyContent:`center`,flex:1,children:(0,I.jsx)(k,{color:`newGray.400`,children:`Loading access token...`})})}):e.hasAccessToken?(0,I.jsx)(Vq,{hideSidebar:!0,children:(0,I.jsx)(j,{alignItems:`center`,justifyContent:`center`,flex:1,children:(0,I.jsxs)(M,{gap:6,maxWidth:`500px`,textAlign:`center`,children:[(0,I.jsx)(k,{fontSize:`lg`,fontWeight:`500`,color:`newGray.500`,children:`Access Token`}),(0,I.jsxs)(A,{width:`100%`,children:[(0,I.jsx)(k,{fontSize:`xs`,color:`newGray.400`,mb:2,children:`Copy this token to use with Revisium API or MCP tools:`}),(0,I.jsxs)(j,{align:`center`,gap:2,p:3,bg:`newGray.50`,borderRadius:`md`,borderWidth:`1px`,borderColor:`newGray.100`,children:[(0,I.jsx)(Jt,{fontSize:`xs`,color:`newGray.500`,bg:`transparent`,flex:1,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,children:e.truncatedToken}),(0,I.jsx)(Ze,{"aria-label":`Copy token`,size:`sm`,variant:`outline`,colorPalette:`gray`,onClick:n,children:(0,I.jsx)(vf,{})})]})]}),(0,I.jsx)(A,{p:4,bg:`newGray.50`,borderRadius:`md`,borderWidth:`1px`,borderColor:`newGray.100`,width:`100%`,children:(0,I.jsx)(k,{fontSize:`xs`,color:`newGray.400`,children:`You can now close this page and paste the token in your application.`})}),(0,I.jsx)(N,{variant:`outline`,colorPalette:`gray`,size:`sm`,onClick:r,children:`Go to Main Page`})]})})}):(0,I.jsx)(Vq,{hideSidebar:!0,children:(0,I.jsx)(j,{alignItems:`center`,justifyContent:`center`,flex:1,children:(0,I.jsx)(k,{color:`newGray.400`,children:`No access token available. Please login first.`})})})}),H1=({onClick:e})=>(0,I.jsx)(Uq,{dataTestId:`create-project-button`,title:`Project`,onClick:e}),U1=class{constructor(e,t){this.routerParams=e,this.authService=t,f(this,{},{autoBind:!0})}get organizationId(){return this.routerParams.organizationId??this.authService.user?.organizationId??``}get isAuthenticated(){return!!this.authService.user}};Y.register(U1,()=>new U1(Y.get(pQ),Y.get(hJ)),{scope:`singleton`});var W1=class{request=X.of(Q.createProject);constructor(){f(this)}get isLoading(){return this.request.isLoading}get error(){return this.request.errorMessage??null}get data(){return this.request.data}async create(e){return(await this.request.fetch({data:{organizationId:e.organizationId,projectName:e.projectName,branchName:e.branchName,fromRevisionId:e.fromRevisionId}})).isRight}dispose(){this.request.abort()}};Y.register(W1,()=>new W1,{scope:`request`});var G1=class{projectName=``;branchName=``;fromRevisionId=``;showingSettings=!1;constructor(e,t){this.dataSource=e,this.context=t,f(this,{},{autoBind:!0})}get isLoading(){return this.dataSource.isLoading}get error(){return this.dataSource.error}get canCreate(){return this.projectName.length>0&&!this.isLoading}get organizationId(){return this.context.organizationId}setProjectName(e){this.projectName=e}setBranchName(e){this.branchName=e}setFromRevisionId(e){this.fromRevisionId=e}toggleSettings(){this.showingSettings=!this.showingSettings}async create(){return this.dataSource.create({organizationId:this.organizationId,projectName:this.projectName,branchName:this.branchName||void 0,fromRevisionId:this.fromRevisionId||void 0})}init(){}dispose(){this.dataSource.dispose()}};Y.register(G1,()=>new G1(Y.get(W1),Y.get(U1)),{scope:`request`});var K1=({onClick:e,color:t,dataTestId:n})=>(0,I.jsx)(Ze,{_hover:{backgroundColor:`gray.100`},"data-testid":n,"aria-label":``,color:t||`gray.400`,variant:`ghost`,onClick:e,children:(0,I.jsx)(Xf,{})}),q1=g(({onComplete:e})=>{let t=CB(G1),n=(0,L.useCallback)(async()=>{await t.create()&&e?.()},[t,e]),r=(0,L.useCallback)(e=>{t.setProjectName(e.currentTarget.value)},[t]),i=(0,L.useCallback)(e=>{t.setBranchName(e.currentTarget.value)},[t]),a=(0,L.useCallback)(e=>{t.setFromRevisionId(e.currentTarget.value)},[t]);return(0,I.jsxs)(j,{alignSelf:`flex-start`,gap:`0.5rem`,children:[(0,I.jsx)(Gq,{onClick:e}),(0,I.jsxs)(j,{flexDirection:`column`,gap:`0.5rem`,children:[(0,I.jsx)(qq,{dataTestId:`create-project-name-input`,autoFocus:!0,height:`40px`,placeholder:`project name`,value:t.projectName,onChange:r,onEnter:n}),t.projectName&&t.showingSettings&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(qq,{dataTestId:`create-project-branch-name-input`,height:`40px`,placeholder:`branch name`,value:t.branchName,onChange:i,onEnter:n}),(0,I.jsx)(qq,{dataTestId:`create-project-from-revision-id-input`,height:`40px`,placeholder:`from revisionId`,value:t.fromRevisionId,onChange:a,onEnter:n})]})]}),t.projectName&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(Wq,{dataTestId:`create-project-approve-button`,loading:t.isLoading,onClick:n}),(0,I.jsx)(K1,{dataTestId:`create-project-settings-button`,color:t.showingSettings?`gray.400`:`gray.200`,onClick:t.toggleSettings})]})]})}),J1=class extends rH{constructor(e){super(Q.organizationProjects,{pageSize:100}),this.context=e}extractItems(e){return e.projects.edges.map(e=>e.node)}extractPageInfo(e){return{hasNextPage:e.projects.pageInfo.hasNextPage,endCursor:e.projects.pageInfo.endCursor||null,totalCount:e.projects.totalCount}}buildFetchArgs(e,t){return{data:{organizationId:this.context.organizationId,first:this.config.pageSize,after:t}}}};Y.register(J1,()=>new J1(Y.get(U1)),{scope:`request`});var Y1=class{constructor(e){this.project=e,f(this)}get id(){return this.project.id}get name(){return this.project.name}get isPublic(){return this.project.isPublic}get touched(){return this.project.rootBranch.touched}get link(){return Dn(`/app/${AJ}/${PJ}/${zJ}/${qJ}`,{organizationId:this.project.organizationId,projectName:this.project.name,branchName:this.project.rootBranch.name,revisionIdOrTag:XJ})}},X1=class extends nH{isCreatingProject=!1;constructor(e,t,n){super(e),this.permissionService=t,this.context=n,h(this,{isCreatingProject:u,canCreateProject:a,toggleCreatingProject:m.bound,handleProjectCreated:m.bound})}get canCreateProject(){return this.permissionService.can(`create`,`Project`,{organizationId:this.context.organizationId})}getItemKey(e){return e.id}createItemViewModel(e){return new Y1(e)}toggleCreatingProject(){this.isCreatingProject=!this.isCreatingProject}handleProjectCreated(){this.isCreatingProject=!1,this.init()}};Y.register(X1,()=>new X1(Y.get(J1),Y.get(vW),Y.get(U1)),{scope:`request`});var Z1=()=>{let e=yn();return{isProjectsActive:e.some(e=>e.id===rY.OrganizationOverview),isMembersActive:e.some(e=>e.id===rY.OrganizationMembers),isSettingsActive:e.some(e=>e.id===rY.OrganizationSettings),isLimitsActive:e.some(e=>e.id===rY.OrganizationLimits)}},Q1=class{constructor(e,t,n){this.context=e,this.permissionService=t,this.configurationService=n,f(this,{},{autoBind:!0})}get organizationId(){return this.context.organizationId}get isAuthenticated(){return this.context.isAuthenticated}get billingEnabled(){return this.configurationService.billingEnabled}get organizationCondition(){return{organizationId:this.organizationId}}get canManageMembers(){return this.permissionService.can(`add`,`User`,this.organizationCondition)}get canManageApiKeys(){return this.permissionService.can(`manage`,`ApiKey`,this.organizationCondition)}get canAccessSettings(){return this.permissionService.can(`update`,`Organization`,this.organizationCondition)}get projectsLink(){return Dn(`/app/${AJ}`,{organizationId:this.organizationId})}get membersLink(){return Dn(`/app/${AJ}/${MJ}`,{organizationId:this.organizationId})}get settingsLink(){return Dn(`/app/${AJ}/${jJ}`,{organizationId:this.organizationId})}get limitsLink(){return Dn(`/app/${AJ}/${NJ}`,{organizationId:this.organizationId})}init(){}dispose(){}};Y.register(Q1,()=>new Q1(Y.get(U1),Y.get(vW),Y.get(gJ)),{scope:`singleton`});var $1=g(({organizationId:e})=>{let t=Tn();return(0,I.jsx)(j,{className:`group`,flexDirection:`column`,alignItems:`flex-start`,width:`100%`,minWidth:`0`,children:(0,I.jsxs)(j,{alignItems:`center`,gap:`8px`,padding:`4px`,width:`100%`,minWidth:0,children:[(0,I.jsx)(A,{fontSize:`20px`,color:`newGray.400`,cursor:`pointer`,_hover:{color:`newGray.500`},onClick:()=>{t(`/`)},display:`flex`,alignItems:`center`,flexShrink:0,children:(0,I.jsx)(pf,{})}),(0,I.jsx)(A,{color:`black`,fontWeight:`600`,fontSize:`18px`,lineHeight:`26px`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,overflow:`hidden`,flex:1,minWidth:0,children:e}),(0,I.jsx)(T,{}),(0,I.jsx)(oJ,{})]})})}),e0=g(()=>{let e=CB(Q1),{isProjectsActive:t,isMembersActive:n,isSettingsActive:r,isLimitsActive:i}=Z1();return(0,I.jsxs)(M,{alignItems:`flex-start`,gap:0,width:`100%`,flex:1,children:[(0,I.jsx)($1,{organizationId:e.organizationId}),(0,I.jsx)(A,{width:`100%`,paddingY:`16px`,children:(0,I.jsx)(O,{borderColor:`newGray.100`})}),(0,I.jsxs)(j,{flexDirection:`column`,width:`100%`,gap:1,children:[(0,I.jsx)(sJ,{to:e.projectsLink,label:`Projects`,icon:(0,I.jsx)(Yte,{}),isActive:t}),e.canManageMembers&&(0,I.jsx)(sJ,{to:e.membersLink,label:`Members`,icon:(0,I.jsx)(Bf,{}),isActive:n}),e.canManageApiKeys&&(0,I.jsx)(sJ,{to:e.settingsLink,label:`API Keys`,icon:(0,I.jsx)(Df,{}),isActive:r}),e.billingEnabled&&(0,I.jsx)(sJ,{to:e.limitsLink,label:`Billing`,icon:(0,I.jsx)(zte,{}),isActive:i})]}),(0,I.jsx)(T,{}),(0,I.jsx)(j,{flexDirection:`column`,width:`100%`,gap:1,children:e.isAuthenticated?(0,I.jsx)(IY,{}):(0,I.jsx)(sJ,{to:`/${yJ}`,label:`Sign in`,icon:(0,I.jsx)(Ff,{}),isActive:!1})})]})}),t0=g(({model:e})=>(0,I.jsx)(A,{height:`2.5rem`,width:`100%`,children:(0,I.jsx)(j,{_hover:{backgroundColor:`gray.50`},alignItems:`center`,gap:`4px`,paddingLeft:`1rem`,children:(0,I.jsx)(j,{alignItems:`center`,flex:1,justifyContent:`space-between`,minHeight:`40px`,children:(0,I.jsxs)(j,{minWidth:`150px`,children:[(0,I.jsx)(k,{_hover:{textDecoration:`underline`},children:(0,I.jsx)(An,{to:e.link,children:e.name})}),e.touched&&(0,I.jsx)(k,{color:`gray.400`,ml:`4px`,children:`*`})]})})})})),n0=g(()=>{let e=CB(X1);return(0,I.jsx)(Vq,{sidebar:(0,I.jsx)(e0,{}),children:(0,I.jsx)(j,{flex:1,flexDirection:`column`,gap:`0.5rem`,paddingBottom:`1rem`,children:e.isCreatingProject?(0,I.jsx)(q1,{onComplete:e.handleProjectCreated}):(0,I.jsxs)(I.Fragment,{children:[e.canCreateProject&&(0,I.jsx)(H1,{onClick:e.toggleCreatingProject}),e.showLoading&&(0,I.jsx)(M,{flex:1,justifyContent:`center`,children:(0,I.jsx)(Ht,{size:`md`,color:`gray.400`})}),e.showError&&(0,I.jsxs)(M,{flex:1,justifyContent:`center`,gap:`8px`,color:`gray.400`,children:[(0,I.jsx)(k,{fontSize:`md`,children:`Could not load projects`}),(0,I.jsx)(k,{fontSize:`sm`,children:`Please retry later`})]}),e.showEmpty&&(0,I.jsx)(M,{flex:1,justifyContent:`center`,gap:`8px`,color:`gray.400`,children:(0,I.jsx)(k,{fontSize:`md`,children:`No projects yet`})}),e.showList&&(0,I.jsx)(QM,{useWindowScroll:!0,totalCount:e.totalCount,defaultItemHeight:40,endReached:e.hasNextPage?e.tryToFetchNextPage:void 0,itemContent:t=>{let n=e.items[t];return n?(0,I.jsx)(t0,{model:n},n.id):null}})]})})})}),r0=class{apiKeyManager;constructor(e,t,n){this.context=e,this.permissionService=t,f(this,{},{autoBind:!0}),this.apiKeyManager=n,this.apiKeyManager.configure({mode:`service`,organizationId:this.context.organizationId})}get organizationId(){return this.context.organizationId}get canManageServiceKeys(){return this.permissionService.can(`manage`,`ApiKey`,{organizationId:this.organizationId})}init(){}dispose(){this.apiKeyManager.dispose()}};Y.register(r0,()=>new r0(Y.get(U1),Y.get(vW),Y.get(MY)),{scope:`request`});var i0=g(()=>{let e=CB(r0);return(0,I.jsx)(Vq,{sidebar:(0,I.jsx)(e0,{}),children:(0,I.jsx)(A,{maxWidth:`600px`,width:`100%`,mb:`4rem`,children:(0,I.jsxs)(M,{align:`stretch`,gap:`2rem`,children:[(0,I.jsxs)(A,{children:[(0,I.jsx)(k,{fontSize:`20px`,fontWeight:`600`,color:`newGray.500`,mb:1,children:`API Keys`}),(0,I.jsx)(k,{fontSize:`xs`,color:`newGray.400`,children:`Service keys for automated integrations with this organization.`})]}),e.canManageServiceKeys&&(0,I.jsx)(kY,{model:e.apiKeyManager})]})})})}),a0=300,o0=class{_isOpen=!1;_activeTab=`search`;_searchQuery=``;_searchResults=[];_selectedUserId=null;_selectedRole=JW.Reader;_newUsername=``;_newPassword=``;_newEmail=``;_isAdding=!1;_isCreating=!1;debounceTimeout=null;searchRequest=X.of(Q.searchUsers);constructor(e,t,n){this.context=e,this.systemPermissions=t,this.onMemberAdded=n,f(this,{},{autoBind:!0})}get isOpen(){return this._isOpen}get activeTab(){return this._activeTab}get canCreateUser(){return this.systemPermissions.canCreateUser}get searchQuery(){return this._searchQuery}get searchResults(){return this._searchResults}get selectedUserId(){return this._selectedUserId}get selectedRole(){return this._selectedRole}get isSearching(){return this.searchRequest.isLoading}get canAddSelectedUser(){return this._selectedUserId!==null&&!this._isAdding}get isAdding(){return this._isAdding}get newUsername(){return this._newUsername}get newPassword(){return this._newPassword}get newEmail(){return this._newEmail}get isCreating(){return this._isCreating}get canCreateNewUser(){return this._newUsername.trim().length>0&&this._newPassword.length>=6&&!this._isCreating}open(){this._isOpen=!0,this.reset()}close(){this._isOpen=!1,this.reset()}setActiveTab(e){this._activeTab=e}setSearchQuery(e){this._searchQuery=e,this.debounceTimeout&&=(clearTimeout(this.debounceTimeout),null),e.trim()?this.debounceTimeout=setTimeout(()=>{this.search(),this.debounceTimeout=null},a0):this._searchResults=[]}setSelectedUserId(e){this._selectedUserId=e}setSelectedRole(e){this._selectedRole=e}setNewUsername(e){this._newUsername=e}setNewPassword(e){this._newPassword=e}setNewEmail(e){this._newEmail=e}async search(){if(this._searchQuery.trim().length===0){this._searchResults=[];return}let e=await this.searchRequest.fetch({search:this._searchQuery,first:20});c(()=>{e.isRight&&(this._searchResults=e.data.searchUsers.edges.map(e=>({id:e.node.id,username:e.node.username??null,email:e.node.email??null})))})}async addSelectedUser(){if(!(!this._selectedUserId||this._isAdding)){this._isAdding=!0;try{let e=await Q.addUserToOrganization({organizationId:this.context.organizationId,userId:this._selectedUserId,roleId:this._selectedRole});c(()=>{e.addUserToOrganization&&(this.onMemberAdded(),this.close())})}catch(e){console.error(`Failed to add member:`,e)}finally{c(()=>{this._isAdding=!1})}}}async createAndAddUser(){if(this.canCreateNewUser){this._isCreating=!0;try{if(!(await Q.createUser({username:this._newUsername.trim(),password:this._newPassword,email:this._newEmail.trim()||void 0,roleId:XW.SystemUser})).createUser)throw Error(`Failed to create user`);let e=(await Q.searchUsers({search:this._newUsername.trim(),first:1})).searchUsers.edges.find(e=>e.node.username===this._newUsername.trim());if(!e)throw Error(`Could not find newly created user`);let t=await Q.addUserToOrganization({organizationId:this.context.organizationId,userId:e.node.id,roleId:this._selectedRole});c(()=>{t.addUserToOrganization&&(this.onMemberAdded(),this.close())})}catch(e){console.error(`Failed to create and add member:`,e)}finally{c(()=>{this._isCreating=!1})}}}dispose(){this.debounceTimeout&&=(clearTimeout(this.debounceTimeout),null)}reset(){this.debounceTimeout&&=(clearTimeout(this.debounceTimeout),null),this._activeTab=`search`,this._searchQuery=``,this._searchResults=[],this._selectedUserId=null,this._selectedRole=JW.Reader,this._newUsername=``,this._newPassword=``,this._newEmail=``,this._isAdding=!1,this._isCreating=!1}},s0=class{_isRemoving=!1;constructor(e,t,n,r){this.context=e,this.permissionService=t,this.data=n,this.onRemoved=r,f(this,{},{autoBind:!0})}get id(){return this.data.id}get userId(){return this.data.user.id}get username(){return this.data.user.username??null}get email(){return this.data.user.email??null}get displayName(){return this.username||this.email||this.userId}get roleId(){return this.data.role.id}get roleName(){return this.data.role.name}get isOwner(){return this.roleId===JW.OrganizationOwner}get canRemove(){return this.isOwner?!1:this.permissionService.can(`delete`,`User`,{organizationId:this.context.organizationId})}get isRemoving(){return this._isRemoving}async remove(){if(!this._isRemoving){this._isRemoving=!0;try{let e=await Q.removeUserFromOrganization({organizationId:this.context.organizationId,userId:this.userId});c(()=>{e.removeUserFromOrganization&&this.onRemoved()})}catch(e){console.error(`Failed to remove member:`,e)}finally{c(()=>{this._isRemoving=!1})}}}},c0=function(e){return e.loading=`loading`,e.empty=`empty`,e.list=`list`,e.error=`error`,e}(c0||{}),l0=class{state=c0.loading;getMembersRequest=X.of(Q.getUsersOrganization,{skipResetting:!0});_items=[];_hasNextPage=!1;_endCursor=null;_totalCount=null;_isInitialLoad=!0;addMemberModal;constructor(e,t,n){this.context=e,this.permissionService=t,f(this,{},{autoBind:!0}),this.addMemberModal=new o0(e,n,this.handleMemberAdded)}get canAddMember(){return this.permissionService.can(`add`,`User`,{organizationId:this.context.organizationId})}get showInitialLoading(){return this.state===c0.loading&&this._isInitialLoad}get showError(){return this.state===c0.error}get showNoMembers(){return this.state===c0.empty&&this._totalCount===0}get showList(){return this.state===c0.list}get items(){return this._items}get totalCount(){return this._totalCount??0}get hasNextPage(){return this._hasNextPage}get isLoading(){return this.getMembersRequest.isLoading}init(){this.loadInitial()}dispose(){this.addMemberModal.dispose()}async tryToFetchNextPage(){if(!this._hasNextPage||this.isLoading||!this._endCursor)return;let e=await this.getMembersRequest.fetch({organizationId:this.context.organizationId,first:50,after:this._endCursor});c(()=>{if(e.isRight){let t=e.data.usersOrganization.edges.map(e=>this.createItemViewModel(e.node));this._items=[...this._items,...t],this._hasNextPage=e.data.usersOrganization.pageInfo.hasNextPage,this._endCursor=e.data.usersOrganization.pageInfo.endCursor??null}})}createItemViewModel(e){return new s0(this.context,this.permissionService,e,this.handleMemberRemoved)}handleMemberAdded=()=>{this._totalCount!==null&&this._totalCount++,this.reload()};handleMemberRemoved=()=>{this._totalCount!==null&&this._totalCount--,this.reload()};async reload(){this._items=[],this._hasNextPage=!1,this._endCursor=null,this._isInitialLoad=!1,this.state=c0.loading,await this.loadInitial()}async loadInitial(){let e=await this.getMembersRequest.fetch({organizationId:this.context.organizationId,first:50});if(!e.isRight){if(qV(e))return;c(()=>{this.state=c0.error});return}c(()=>{this._items=e.data.usersOrganization.edges.map(e=>this.createItemViewModel(e.node)),this._hasNextPage=e.data.usersOrganization.pageInfo.hasNextPage,this._endCursor=e.data.usersOrganization.pageInfo.endCursor??null,this._totalCount=e.data.usersOrganization.totalCount,this._items.length>0?this.state=c0.list:this.state=c0.empty})}};Y.register(l0,()=>new l0(Y.get(U1),Y.get(vW),Y.get(yW)),{scope:`request`});var u0=[JW.OrganizationAdmin,JW.Developer,JW.Editor,JW.Reader],d0={[JW.OrganizationOwner]:`Owner`,[JW.OrganizationAdmin]:`Admin`,[JW.Developer]:`Developer`,[JW.Editor]:`Editor`,[JW.Reader]:`Reader`},f0=g(({value:e,onChange:t,disabled:n})=>(0,I.jsx)(Qe,{size:`sm`,width:`120px`,...n&&{opacity:.5,pointerEvents:`none`},children:(0,I.jsx)(Xe,{value:e,onChange:e=>t(e.target.value),children:u0.map(e=>(0,I.jsx)(`option`,{value:e,children:d0[e]},e))})})),p0=g(({model:e})=>(0,I.jsx)(lJ,{model:e,title:`Add Member to Organization`,roleSelect:(0,I.jsx)(f0,{value:e.selectedRole,onChange:e.setSelectedRole})})),m0=g(({model:e})=>(0,I.jsx)(cJ,{model:e,roleSlot:(0,I.jsx)(k,{fontSize:`sm`,color:`newGray.500`,minWidth:`80px`,children:e.roleName})})),h0=g(()=>{let e=CB(l0);return(0,I.jsx)(uJ,{model:e,sidebar:(0,I.jsx)(e0,{}),label:`Members`,emptyTitle:`No members in this organization`,emptySubtitle:`Add team members to collaborate in this organization`,subtitle:`Manage team members and their access levels for this organization.`,onAddClick:()=>e.addMemberModal.open(),modal:(0,I.jsx)(p0,{model:e.addMemberModal}),children:e.items.map(e=>(0,I.jsx)(m0,{model:e},e.id))})}),g0=e=>e.toLocaleString(`en-US`),_0=e=>e>=1073741824?`${(e/1073741824).toFixed(1)} GB`:e>=1048576?`${(e/1048576).toFixed(1)} MB`:`${(e/1024).toFixed(1)} KB`,v0=e=>e==null?`Unlimited`:e.toLocaleString(`en-US`),y0=e=>e==null?`Unlimited`:e>=1073741824?`${(e/1073741824).toFixed(0)} GB`:e>=1048576?`${(e/1048576).toFixed(0)} MB`:`${(e/1024).toFixed(0)} KB`,b0=class{constructor(e,t){this.plan=e,this.parent=t,f(this,{},{autoBind:!0})}get id(){return this.plan.id}get name(){return this.plan.name}get price(){let e=this.parent.billingInterval===`yearly`,t=e?this.plan.yearlyPriceUsd:this.plan.monthlyPriceUsd;return t===0?`Free`:`$${t}/${e?`yr`:`mo`}`}get isCurrent(){return!!(this.plan.id===this.parent.currentPlanId||this.parent.isFree&&this.plan.monthlyPriceUsd===0)}get canUpgrade(){return!this.isCurrent&&this.plan.monthlyPriceUsd>0}get canDowngrade(){return!this.isCurrent&&this.plan.monthlyPriceUsd===0&&!this.parent.isFree}get earlyAccessAvailable(){return this.features.earlyAccessAvailable===!0}get buttonLabel(){return this.canUpgrade?this.earlyAccessAvailable?`Get Early Access`:`Upgrade`:this.canDowngrade?`Downgrade`:`Current Plan`}get buttonDisabled(){return!this.canUpgrade&&!this.canDowngrade}get buttonHidden(){return this.canDowngrade}get projectsLimit(){return v0(this.plan.limits.projects)}get membersLimit(){return v0(this.plan.limits.seats)}get rowVersionsLimit(){return v0(this.plan.limits.rowVersions)}get storageLimit(){return y0(this.plan.limits.storageBytes)}get endpointsPerProjectLimit(){return v0(this.plan.limits.endpointsPerProject)}async handleClick(){this.canUpgrade?this.earlyAccessAvailable?await this.parent.activateEarlyAccess(this.plan.id):await this.parent.createCheckout(this.plan.id):this.canDowngrade&&await this.parent.cancelSubscription()}get features(){let e=this.plan.features;return typeof e==`object`&&e&&!Array.isArray(e)?e:{}}},x0={number:g0,storage:_0},S0=class{constructor(e,t,n,r=null){this.metric=e,this._label=t,this.formatMode=n,this._tooltip=r,f(this)}get label(){return this._label}get tooltip(){return this._tooltip}get current(){return x0[this.formatMode](this.metric.current)}get limit(){return this.metric.limit===null||this.metric.limit===void 0?`Unlimited`:x0[this.formatMode](this.metric.limit)}get isUnlimited(){return this.metric.limit===null||this.metric.limit===void 0}get percentage(){let e=this.metric.percentage??null;return e===null?null:Math.min(e,100)}get progressColor(){return this.percentage===null?`green`:this.percentage>90?`red`:this.percentage>70?`yellow`:`green`}},C0=`Total row versions across all projects. Each row change in a new revision creates a version. Unchanged rows in a new revision do not count.`,w0=class{dataRequest=X.of(e=>Q.getLimitsPageData({data:{organizationId:e}}),{skipResetting:!0});plansRequest=X.of(()=>Q.getLimitsPagePlans());earlyAccessRequest=X.of(Q.activateEarlyAccess);checkoutRequest=X.of(Q.createCheckout);cancelRequest=X.of(Q.cancelSubscription);billingInterval=`monthly`;isCancelDialogOpen=!1;constructor(e){this.context=e,f(this,{},{autoBind:!0})}get data(){return this.dataRequest.data}get plansData(){return this.plansRequest.data}get isLoading(){return this.dataRequest.isLoading&&!this.dataRequest.isLoaded}get isError(){return this.dataRequest.error!==null&&this.dataRequest.data===null}get billingEnabled(){return this.data?.configuration.billing.enabled??!1}get pageTitle(){return this.billingEnabled?`Billing`:`Usage`}get pageSubtitle(){return this.billingEnabled?`Plan, usage, and payment management.`:`Resource usage overview.`}get subscription(){return this.data?.organization.subscription??null}get usage(){return this.data?.organization.usage??null}get currentPlanId(){return this.subscription?.planId??``}get planStatus(){return this.subscription?.status??RW.Free}get isEarlyAdopter(){return this.planStatus===RW.EarlyAdopter}get isActive(){return this.planStatus===RW.Active}get isFree(){return this.planStatus===RW.Free}get isPastDue(){return this.planStatus===RW.PastDue}get isCancelled(){return this.planStatus===RW.Cancelled}get cancelAt(){return this.subscription?.cancelAt??null}get provider(){return this.subscription?.provider??null}get currentPeriodEnd(){return this.subscription?.currentPeriodEnd??null}get hasPaymentManagement(){return this.isActive||this.isPastDue}get statusTitle(){return this.isFree?`Free Plan`:this.isEarlyAdopter?`Pro Plan — Early Access`:this.isActive?`Pro Plan`:this.isPastDue?`Payment failed`:this.isCancelled?`Plan cancelled`:``}get statusSubtitle(){return this.isEarlyAdopter?`Free while in Early Access`:this.isActive&&this.currentPeriodEnd?`Renews ${new Date(this.currentPeriodEnd).toLocaleDateString()}`:this.isPastDue?`Please update your payment method`:this.isCancelled&&this.cancelAt?`Downgrades on ${new Date(this.cancelAt).toLocaleDateString()}`:null}get statusColor(){return this.isEarlyAdopter?`purple`:this.isActive?`green`:this.isPastDue?`orange`:this.isCancelled?`red`:`gray`}get usageItems(){let e=this.usage;return e?[new S0(e.rowVersions,`Row Versions`,`number`,C0),new S0(e.projects,`Projects`,`number`),new S0(e.seats,`Members`,`number`),new S0(e.storageBytes,`Storage`,`storage`)]:[]}get planItems(){return(this.plansData?.plans??[]).filter(e=>e.isPublic).map(e=>new b0(e,this))}setBillingInterval(e){this.billingInterval=e}async activateEarlyAccess(e){(await this.earlyAccessRequest.fetch({data:{organizationId:this.context.organizationId,planId:e}})).isRight&&this.reload()}async createCheckout(e){let t=await this.checkoutRequest.fetch({data:{organizationId:this.context.organizationId,planId:e,interval:this.billingInterval,successUrl:globalThis.location.href,cancelUrl:globalThis.location.href}});t.isRight&&(globalThis.location.href=t.data.createCheckout.checkoutUrl)}openCancelDialog(){this.isCancelDialogOpen=!0}closeCancelDialog(){this.isCancelDialogOpen=!1}async cancelSubscription(){(await this.cancelRequest.fetch({data:{organizationId:this.context.organizationId,cancelAtPeriodEnd:!0}})).isRight&&(c(()=>{this.isCancelDialogOpen=!1}),this.reload())}get isActionLoading(){return this.earlyAccessRequest.isLoading||this.checkoutRequest.isLoading||this.cancelRequest.isLoading}init(){this.dataRequest.fetch(this.context.organizationId),this.plansRequest.fetch()}dispose(){this.dataRequest.abort(),this.plansRequest.abort()}reload(){this.dataRequest.fetch(this.context.organizationId),this.plansRequest.fetch()}};Y.register(w0,()=>new w0(Y.get(U1)),{scope:`request`});var T0=g(({model:e})=>(0,I.jsxs)(P,{gap:2,children:[(0,I.jsx)(N,{size:`xs`,variant:e.billingInterval===`monthly`?`solid`:`outline`,onClick:()=>e.setBillingInterval(`monthly`),children:`Monthly`}),(0,I.jsx)(N,{size:`xs`,variant:e.billingInterval===`yearly`?`solid`:`outline`,onClick:()=>e.setBillingInterval(`yearly`),children:`Yearly`})]})),E0=g(({model:e})=>e.hasPaymentManagement?(0,I.jsxs)(A,{children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`600`,color:`gray.600`,mb:`0.5rem`,children:`Payment`}),(0,I.jsx)(A,{borderWidth:`1px`,borderColor:`gray.200`,borderRadius:`lg`,p:4,bg:`white`,children:(0,I.jsxs)(M,{align:`stretch`,gap:3,children:[e.provider&&(0,I.jsxs)(k,{fontSize:`sm`,color:`gray.600`,children:[`Provider: `,e.provider]}),(0,I.jsxs)(Ue,{open:e.isCancelDialogOpen,onOpenChange:t=>t.open?e.openCancelDialog():e.closeCancelDialog(),children:[(0,I.jsx)(N,{variant:`outline`,colorPalette:`red`,size:`sm`,alignSelf:`flex-start`,onClick:e.openCancelDialog,children:`Cancel Subscription`}),(0,I.jsxs)(R,{children:[(0,I.jsx)(pe,{}),(0,I.jsx)(ue,{children:(0,I.jsxs)(_n,{children:[(0,I.jsx)(Ge,{children:(0,I.jsx)(qe,{children:`Cancel Subscription`})}),(0,I.jsx)(be,{children:(0,I.jsx)(k,{children:`Your subscription will remain active until the end of the current billing period. After that, you'll be downgraded to the Free plan.`})}),(0,I.jsxs)(w,{children:[(0,I.jsx)(oe,{asChild:!0,children:(0,I.jsx)(N,{variant:`outline`,children:`Keep Subscription`})}),(0,I.jsx)(N,{colorPalette:`red`,onClick:e.cancelSubscription,disabled:e.isActionLoading,children:`Cancel Subscription`})]}),(0,I.jsx)(Ie,{})]})})]})]})]})})]}):null),D0=g(({model:e,parentModel:t})=>(0,I.jsx)(A,{borderWidth:`1px`,borderColor:e.isCurrent?`gray.400`:`gray.200`,borderRadius:`lg`,p:4,bg:`white`,flex:1,children:(0,I.jsxs)(M,{align:`start`,gap:3,children:[(0,I.jsxs)(P,{gap:2,children:[(0,I.jsx)(k,{fontSize:`md`,fontWeight:`600`,color:`gray.700`,children:e.name}),e.isCurrent&&(0,I.jsx)(It,{colorPalette:`gray`,variant:`subtle`,size:`sm`,children:`Current`})]}),(0,I.jsx)(k,{fontSize:`xl`,fontWeight:`700`,color:`gray.800`,children:e.price}),(0,I.jsxs)(M,{align:`start`,gap:1,children:[(0,I.jsxs)(k,{fontSize:`xs`,color:`gray.500`,children:[e.projectsLimit,` projects`]}),(0,I.jsxs)(k,{fontSize:`xs`,color:`gray.500`,children:[e.membersLimit,` members`]}),(0,I.jsxs)(k,{fontSize:`xs`,color:`gray.500`,children:[e.rowVersionsLimit,` row versions`]}),(0,I.jsxs)(k,{fontSize:`xs`,color:`gray.500`,children:[e.storageLimit,` storage`]}),(0,I.jsxs)(k,{fontSize:`xs`,color:`gray.500`,children:[e.endpointsPerProjectLimit,` endpoints / project`]})]}),(0,I.jsx)(N,{size:`sm`,variant:e.isCurrent?`outline`:`solid`,width:`100%`,visibility:e.buttonHidden?`hidden`:`visible`,disabled:e.buttonDisabled||t.isActionLoading,onClick:e.handleClick,children:e.buttonLabel})]})})),O0=g(({model:e})=>{if(!e.billingEnabled)return null;let t=e.statusColor;return(0,I.jsxs)(A,{borderWidth:`1px`,borderColor:`${t}.200`,borderRadius:`lg`,p:4,bg:`${t}.50`,children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`600`,color:`${t}.800`,children:e.statusTitle}),e.statusSubtitle&&(0,I.jsx)(k,{fontSize:`xs`,color:`${t}.600`,mt:1,children:e.statusSubtitle})]})}),k0=g(({model:e})=>(0,I.jsxs)(A,{borderWidth:`1px`,borderColor:`gray.200`,borderRadius:`lg`,p:4,bg:`white`,children:[(0,I.jsxs)(j,{justifyContent:`space-between`,alignItems:`center`,mb:2,children:[(0,I.jsxs)(P,{gap:1,children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`600`,color:`gray.600`,children:e.label}),e.tooltip&&(0,I.jsx)(Qq,{content:e.tooltip,showArrow:!0,contentProps:{maxWidth:`280px`},children:(0,I.jsx)(A,{fontSize:`14px`,color:`gray.400`,cursor:`help`,display:`flex`,alignItems:`center`,children:(0,I.jsx)(Qte,{})})})]}),e.isUnlimited&&(0,I.jsx)(It,{colorPalette:`green`,variant:`subtle`,size:`sm`,children:`Unlimited`})]}),(0,I.jsx)(k,{fontSize:`lg`,fontWeight:`600`,color:`gray.800`,mb:e.isUnlimited?0:2,children:e.isUnlimited?e.current:`${e.current} / ${e.limit}`}),!e.isUnlimited&&e.percentage!==null&&(0,I.jsx)(ie,{value:e.percentage,size:`sm`,colorPalette:e.progressColor,borderRadius:`full`,children:(0,I.jsx)(de,{children:(0,I.jsx)(Ae,{})})})]})),A0=g(()=>{let e=CB(w0);return e.isLoading?(0,I.jsx)(Vq,{sidebar:(0,I.jsx)(e0,{}),children:(0,I.jsx)(M,{flex:1,justifyContent:`center`,py:`4rem`,children:(0,I.jsx)(Ht,{size:`md`,color:`gray.400`})})}):e.isError?(0,I.jsx)(Vq,{sidebar:(0,I.jsx)(e0,{}),children:(0,I.jsxs)(M,{flex:1,justifyContent:`center`,gap:`8px`,color:`gray.400`,py:`4rem`,children:[(0,I.jsx)(k,{fontSize:`md`,children:`Could not load usage data`}),(0,I.jsx)(k,{fontSize:`sm`,children:`Please retry later`})]})}):(0,I.jsx)(Vq,{sidebar:(0,I.jsx)(e0,{}),children:(0,I.jsx)(A,{maxWidth:`700px`,width:`100%`,mb:`4rem`,children:(0,I.jsxs)(M,{align:`stretch`,gap:`2rem`,children:[(0,I.jsxs)(A,{children:[(0,I.jsx)(k,{fontSize:`20px`,fontWeight:`600`,color:`newGray.500`,mb:1,children:e.pageTitle}),(0,I.jsx)(k,{fontSize:`xs`,color:`newGray.400`,children:e.pageSubtitle})]}),(0,I.jsx)(O0,{model:e}),(0,I.jsxs)(A,{children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`600`,color:`gray.600`,mb:3,children:`Usage`}),(0,I.jsx)(j,{gap:3,flexWrap:`wrap`,children:e.usageItems.map(e=>(0,I.jsx)(A,{flex:`1`,minWidth:`150px`,children:(0,I.jsx)(k0,{model:e})},e.label))})]}),e.billingEnabled&&e.planItems.length>0&&(0,I.jsxs)(A,{children:[(0,I.jsxs)(j,{justifyContent:`space-between`,alignItems:`center`,mb:3,children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`600`,color:`gray.600`,children:`Plans`}),(0,I.jsx)(T0,{model:e})]}),(0,I.jsx)(j,{gap:3,flexWrap:`wrap`,children:e.planItems.map(t=>(0,I.jsx)(D0,{model:t,parentModel:e},t.id))})]}),e.billingEnabled&&(0,I.jsx)(E0,{model:e})]})})})}),j0=()=>(0,I.jsxs)(j,{alignItems:`center`,flex:1,gap:`1rem`,justifyContent:`center`,width:`100%`,height:`100%`,direction:`column`,children:[(0,I.jsx)(dp,{size:32,color:`gray`}),(0,I.jsx)(k,{color:`gray.400`,children:`Project not found`}),(0,I.jsx)(An,{to:`/`,children:(0,I.jsx)(mt,{fontSize:`sm`,children:`Go to home`})})]}),M0=({width:e})=>(0,I.jsxs)(j,{alignItems:`center`,height:`36px`,paddingX:`8px`,gap:`12px`,children:[(0,I.jsx)(sn,{height:`20px`,width:`20px`,borderRadius:`sm`}),(0,I.jsx)(sn,{height:`14px`,width:e,borderRadius:`sm`})]}),N0=({width:e})=>(0,I.jsx)(j,{alignItems:`center`,height:`36px`,paddingX:`8px`,children:(0,I.jsx)(sn,{height:`14px`,width:e,borderRadius:`sm`})}),P0=({projectName:e,organizationId:t})=>(0,I.jsxs)(M,{alignItems:`flex-start`,gap:0,width:`100%`,flex:1,children:[(0,I.jsx)(T$,{name:e,organizationName:t,roleName:null}),(0,I.jsx)(A,{width:`100%`,paddingY:`16px`,children:(0,I.jsx)(O,{borderColor:`newGray.100`})}),(0,I.jsxs)(j,{flexDirection:`column`,width:`100%`,gap:1,children:[(0,I.jsx)(M0,{width:`60px`}),(0,I.jsx)(N0,{width:`70px`}),(0,I.jsx)(M0,{width:`80px`}),(0,I.jsx)(M0,{width:`70px`}),(0,I.jsx)(M0,{width:`90px`}),(0,I.jsx)(M0,{width:`90px`}),(0,I.jsx)(N0,{width:`85px`}),(0,I.jsx)(N0,{width:`85px`})]}),(0,I.jsx)(T,{}),(0,I.jsx)(j,{flexDirection:`column`,width:`100%`,gap:1,children:(0,I.jsx)(IY,{})})]}),F0=150,I0=g(()=>{let e=Y.get(mQ),t=Y.get(pQ),[n,r]=(0,L.useState)(!1);return(0,L.useEffect)(()=>{if(!e.isInitLoading){r(!1);return}let t=setTimeout(()=>{r(!0)},F0);return()=>clearTimeout(t)},[e.isInitLoading]),e.isInitLoading?n?(0,I.jsx)(Vq,{sidebar:(0,I.jsx)(P0,{projectName:t.projectName??``,organizationId:t.organizationId??``})}):null:e.isProjectLoadFailed?(0,I.jsx)(j0,{}):(0,I.jsx)(En,{})}),L0=class{apiKeyManager;constructor(e,t,n,r){this.context=e,this.projectPermissions=t,this.permissionService=n,f(this,{},{autoBind:!0}),this.apiKeyManager=r;let i=this.projectPermissions.projectId??void 0;this.apiKeyManager.configure({mode:`service`,organizationId:this.context.organizationId,defaultProjectId:i,defaultProjectName:this.context.projectName,filterByProjectId:i})}get organizationId(){return this.context.organizationId}get projectName(){return this.context.projectName}get canManageServiceKeys(){let e=this.projectPermissions.projectId;return e?this.permissionService.can(`manage`,`ApiKey`,{projectId:e,organizationId:this.context.organizationId}):this.permissionService.can(`manage`,`ApiKey`,{organizationId:this.context.organizationId})}get organizationSettingsLink(){return`/app/${this.context.organizationId}/-/settings`}init(){}dispose(){this.apiKeyManager.dispose()}};Y.register(L0,()=>new L0(Y.get(mQ),Y.get(bW),Y.get(vW),Y.get(MY)),{scope:`request`});var R0=g(()=>{let e=CB(L0);return(0,I.jsx)(Vq,{sidebar:(0,I.jsx)(i1,{}),children:(0,I.jsx)(A,{maxWidth:`600px`,width:`100%`,mb:`4rem`,children:(0,I.jsxs)(M,{align:`stretch`,gap:`2rem`,children:[(0,I.jsxs)(A,{children:[(0,I.jsx)(k,{fontSize:`20px`,fontWeight:`600`,color:`newGray.500`,mb:1,children:`API Keys`}),(0,I.jsx)(k,{fontSize:`xs`,color:`newGray.400`,children:`Service keys scoped to this project for automated integrations.`})]}),e.canManageServiceKeys?(0,I.jsxs)(A,{children:[(0,I.jsx)(kY,{model:e.apiKeyManager}),(0,I.jsx)(mt,{asChild:!0,fontSize:`xs`,color:`gray.500`,mt:3,display:`inline-flex`,alignItems:`center`,children:(0,I.jsxs)(An,{to:e.organizationSettingsLink,children:[`Manage all organization keys`,(0,I.jsx)(uf,{style:{marginLeft:`4px`}})]})})]}):(0,I.jsxs)(A,{p:6,textAlign:`center`,borderWidth:`1px`,borderColor:`gray.200`,borderRadius:`lg`,bg:`gray.50`,children:[(0,I.jsx)(k,{fontSize:`sm`,color:`gray.500`,mb:2,children:`No API keys scoped to this project.`}),(0,I.jsx)(mt,{asChild:!0,fontSize:`xs`,color:`blue.500`,children:(0,I.jsxs)(An,{to:e.organizationSettingsLink,children:[`Contact an organization admin to manage API keys`,(0,I.jsx)(uf,{style:{marginLeft:`4px`}})]})})]})]})})})}),z0=[`B`,`KB`,`MB`,`GB`,`TB`,`PB`],B0=1024n;function V0(e){return`${BigInt(e).toLocaleString(`en-US`)} bytes`}function H0(e){let t=BigInt(e);if(t===0n)return`0 B`;let n=t<0n?-t:t,r=0,i=1n;for(;n>=i*B0&&r<z0.length-1;)i*=B0,r+=1;if(r===0)return`${t.toLocaleString(`en-US`)} ${z0[r]}`;let a=n*10n/i,o=a/10n,s=a%10n;return`${t<0n?`-`:``}${o.toLocaleString(`en-US`)}.${s.toString()} ${z0[r]}`}function U0(e){return`${H0(e)} (${V0(e)})`}function W0(e){if(e instanceof Pn){let t=e.response.errors?.[0];if(t?.message)return t.message}return e instanceof Error&&e.message?e.message:`Request failed`}var G0=class{validateRequest=X.of(e=>Q.adminValidateProjectFileBytes({data:{projectId:e}}));previewRestoreRequest=X.of(e=>Q.adminRestoreProjectFileBytes({data:{projectId:e,dryRun:!0}}));applyRestoreRequest=X.of(e=>Q.adminRestoreProjectFileBytes({data:{projectId:e,dryRun:!1}}));disposer;_restoreDialogOpen=!1;_restoreError=null;constructor(e,t){this.projectPermissions=e,this.permissionService=t,f(this,{},{autoBind:!0}),this.disposer=s(()=>this.projectPermissions.projectId,e=>{c(()=>{this._restoreDialogOpen=!1,this._restoreError=null}),this.previewRestoreRequest.abort(),this.applyRestoreRequest.abort(),e&&this.validate()},{fireImmediately:!0})}get report(){return this.validateRequest.data?.adminValidateProjectFileBytes??null}get preview(){return this.previewRestoreRequest.data?.adminRestoreProjectFileBytes??null}get isLoading(){return this.validateRequest.isLoading&&!this.validateRequest.isLoaded}get isRefreshing(){return this.validateRequest.isLoading&&this.validateRequest.isLoaded}get isPreviewLoading(){return this.previewRestoreRequest.isLoading}get isApplyingRestore(){return this.applyRestoreRequest.isLoading}get validateError(){return this.validateRequest.error?W0(this.validateRequest.error):null}get restoreError(){return this._restoreError}get hasManagePermission(){let e=this.projectPermissions.projectId,t=this.projectPermissions.organizationId;if(!e)return!1;let n={projectId:e};return t&&(n.organizationId=t),this.permissionService.can(`manage`,`FileUsage`,n)}get currentBytes(){return this.report?.currentFileBytes??`0`}get expectedBytes(){return this.report?.expectedFileBytes??`0`}get drift(){return this.report?.drift??`0`}get fileBlobCount(){return this.report?.fileBlobCount??0}get referenceCount(){return this.report?.referenceCount??0}get hasDrift(){return BigInt(this.drift)!==0n}get canRestore(){return this.hasDrift&&this.hasManagePermission}get restoreDialogOpen(){return this._restoreDialogOpen}get currentBytesLabel(){return U0(this.currentBytes)}get expectedBytesLabel(){return U0(this.expectedBytes)}get driftLabel(){return BigInt(this.drift)===0n?`0 B (0 bytes)`:`${H0(this.drift)} (${V0(this.drift)})`}get driftColor(){let e=BigInt(this.drift);return e===0n?`green.600`:e>0n?`orange.600`:`red.600`}get previewPreviousBytesLabel(){return U0(this.preview?.previousFileBytes??`0`)}get previewNextBytesLabel(){return U0(this.preview?.nextFileBytes??`0`)}get previewDriftLabel(){return!this.preview||BigInt(this.preview.drift)===0n?`0 B (0 bytes)`:`${H0(this.preview.drift)} (${V0(this.preview.drift)})`}openRestoreDialog(){this._restoreDialogOpen=!0}closeRestoreDialog(){this._restoreDialogOpen=!1,this._restoreError=null,this.previewRestoreRequest.abort(),this.applyRestoreRequest.abort()}async validate(){let e=this.projectPermissions.projectId;if(!e||!this.hasManagePermission)return;let t=await this.validateRequest.fetch(e);!t.isRight&&qV(t)}async previewRestore(){let e=this.projectPermissions.projectId;if(!e||!this.canRestore)return;c(()=>{this._restoreDialogOpen=!0,this._restoreError=null});let t=await this.previewRestoreRequest.fetch(e);if(!t.isRight){if(qV(t))return;c(()=>{this._restoreError=W0(t.error)})}}async applyRestore(){let e=this.projectPermissions.projectId;if(!e||!this.preview||!this.canRestore)return;c(()=>{this._restoreError=null});let t=await this.applyRestoreRequest.fetch(e);if(!t.isRight){if(qV(t))return;c(()=>{this._restoreError=W0(t.error)});return}c(()=>{this._restoreDialogOpen=!1,this._restoreError=null}),Jq.success({description:`Project file usage restored successfully`}),await this.validate()}init(){}dispose(){this.disposer(),this.validateRequest.abort(),this.previewRestoreRequest.abort(),this.applyRestoreRequest.abort()}};Y.register(G0,()=>new G0(Y.get(bW),Y.get(vW)),{scope:`request`});var K0=class{isDeleteDialogOpen=!1;deleteConfirmationText=``;updateRequest=X.of(Q.updateProject);deleteRequest=X.of(Q.deleteProjectForSettings);apiKeyManager;constructor(e,t,n,r,i,a){this.context=e,this.routerService=t,this.projectPermissions=n,this.permissionService=r,this.linkMaker=i,f(this,{},{autoBind:!0}),this.apiKeyManager=a;let o=this.projectPermissions.projectId??void 0;this.apiKeyManager.configure({mode:`service`,organizationId:this.context.organizationId,defaultProjectId:o,defaultProjectName:this.context.projectName,filterByProjectId:o})}get endpointsLink(){return this.linkMaker.makeEndpointsLink()}get canManageServiceKeys(){let e=this.projectPermissions.projectId;return e?this.permissionService.can(`manage`,`ApiKey`,{projectId:e,organizationId:this.context.organizationId}):this.permissionService.can(`manage`,`ApiKey`,{organizationId:this.context.organizationId})}get canManageFileUsage(){let e=this.projectPermissions.projectId;return e?this.permissionService.can(`manage`,`FileUsage`,{projectId:e,organizationId:this.context.organizationId}):!1}get organizationSettingsLink(){return`/app/${this.context.organizationId}/-/settings`}get canUpdateProject(){return this.projectPermissions.canUpdateProject}get hasDeletePermission(){return this.projectPermissions.canDeleteProject}get isPublic(){return this.context.isProjectPublic}get projectName(){return this.context.projectName}async setIsPublic(e){(await this.updateRequest.fetch({data:{isPublic:e,projectName:this.context.projectName,organizationId:this.context.organizationId}})).isRight&&(this.context.updateProject({isPublic:e}),Jq.info({duration:1500,description:e?`Project is now public`:`Project is now private`}))}openDeleteDialog(){this.isDeleteDialogOpen=!0,this.deleteConfirmationText=``}closeDeleteDialog(){this.isDeleteDialogOpen=!1,this.deleteConfirmationText=``}setDeleteConfirmationText(e){this.deleteConfirmationText=e}get canDeleteProject(){return this.deleteConfirmationText===this.projectName}async deleteProject(){if(this.canDeleteProject)try{(await this.deleteRequest.fetch({data:{organizationId:this.context.organizationId,projectName:this.context.projectName}})).isRight&&(this.closeDeleteDialog(),await this.routerService.navigate(`/`))}catch(e){console.error(e)}}init(){}dispose(){this.updateRequest.abort(),this.deleteRequest.abort(),this.apiKeyManager.dispose()}};Y.register(K0,()=>new K0(Y.get(mQ),Y.get(X9),Y.get(bW),Y.get(vW),Y.get(hQ),Y.get(MY)),{scope:`request`});var q0=({label:e,value:t,color:n=`gray.800`})=>(0,I.jsxs)(A,{borderWidth:`1px`,borderColor:`gray.200`,borderRadius:`lg`,bg:`white`,p:4,children:[(0,I.jsx)(k,{fontSize:`xs`,fontWeight:`600`,color:`gray.500`,mb:2,children:e}),(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`600`,color:n,children:t})]}),J0=g(({model:e})=>(0,I.jsxs)(A,{children:[(0,I.jsxs)(P,{justify:`space-between`,align:`center`,mb:3,children:[(0,I.jsxs)(A,{children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`600`,color:`gray.600`,children:`File Usage`}),(0,I.jsx)(k,{fontSize:`xs`,color:`gray.500`,mt:1,children:`Validate tracked file bytes and preview a restore before applying it.`})]}),(0,I.jsx)(N,{variant:`outline`,size:`sm`,onClick:e.validate,loading:e.isLoading||e.isRefreshing,disabled:e.isLoading,children:`Refresh`})]}),(0,I.jsx)(A,{borderWidth:`1px`,borderColor:`gray.200`,borderRadius:`lg`,bg:`gray.50`,p:4,children:e.isLoading?(0,I.jsxs)(P,{gap:3,children:[(0,I.jsx)(Ht,{size:`sm`,color:`gray.400`}),(0,I.jsx)(k,{fontSize:`sm`,color:`gray.600`,children:`Loading file usage…`})]}):(0,I.jsxs)(M,{align:`stretch`,gap:4,children:[(0,I.jsxs)(Se,{templateColumns:{base:`1fr`,md:`repeat(2, minmax(0, 1fr))`},gap:3,children:[(0,I.jsx)(q0,{label:`Current Bytes`,value:e.currentBytesLabel}),(0,I.jsx)(q0,{label:`Expected Bytes`,value:e.expectedBytesLabel}),(0,I.jsx)(q0,{label:`Drift`,value:e.driftLabel,color:e.driftColor}),(0,I.jsx)(q0,{label:`File Blobs`,value:e.fileBlobCount.toLocaleString(`en-US`)}),(0,I.jsx)(q0,{label:`References`,value:e.referenceCount.toLocaleString(`en-US`)})]}),e.validateError&&(0,I.jsx)(k,{fontSize:`sm`,color:`red.600`,children:e.validateError}),e.canRestore&&(0,I.jsxs)(P,{justify:`space-between`,align:`center`,flexWrap:`wrap`,gap:3,children:[(0,I.jsx)(k,{fontSize:`sm`,color:`gray.600`,children:`Drift detected. Preview the restore before applying any changes.`}),(0,I.jsx)(N,{size:`sm`,colorPalette:`orange`,onClick:e.previewRestore,loading:e.isPreviewLoading,children:`Restore File Bytes`})]})]})}),(0,I.jsx)(Ue,{open:e.restoreDialogOpen,onOpenChange:({open:t})=>!t&&e.closeRestoreDialog(),children:(0,I.jsxs)(R,{children:[(0,I.jsx)(pe,{}),(0,I.jsx)(ue,{children:(0,I.jsxs)(_n,{children:[(0,I.jsx)(Ge,{children:(0,I.jsx)(qe,{children:`Restore Project File Bytes`})}),(0,I.jsx)(be,{children:(0,I.jsx)(M,{align:`stretch`,gap:4,children:e.isPreviewLoading?(0,I.jsxs)(P,{gap:3,children:[(0,I.jsx)(Ht,{size:`sm`,color:`gray.400`}),(0,I.jsx)(k,{fontSize:`sm`,color:`gray.600`,children:`Preparing restore preview…`})]}):(0,I.jsxs)(I.Fragment,{children:[e.preview&&(0,I.jsxs)(Se,{templateColumns:`1fr`,gap:3,children:[(0,I.jsx)(q0,{label:`Previous Bytes`,value:e.previewPreviousBytesLabel}),(0,I.jsx)(q0,{label:`Next Bytes`,value:e.previewNextBytesLabel}),(0,I.jsx)(q0,{label:`Drift`,value:e.previewDriftLabel})]}),e.restoreError&&(0,I.jsx)(k,{fontSize:`sm`,color:`red.600`,children:e.restoreError}),!e.restoreError&&e.preview&&(0,I.jsx)(k,{fontSize:`sm`,color:`gray.600`,children:`Confirm to apply the previewed restore.`})]})})}),(0,I.jsxs)(w,{children:[(0,I.jsx)(oe,{asChild:!0,children:(0,I.jsx)(N,{variant:`outline`,children:`Cancel`})}),(0,I.jsx)(N,{colorPalette:`orange`,onClick:e.applyRestore,disabled:!e.preview||e.isPreviewLoading||!!e.restoreError,loading:e.isApplyingRestore,children:`Confirm Restore`})]})]})})]})})]})),Y0=({isSelected:e,onClick:t,icon:n,title:r,description:i,details:a,disabled:o})=>(0,I.jsx)(A,{onClick:o?void 0:t,width:`100%`,p:4,borderWidth:`1px`,borderColor:e?`gray.400`:`gray.200`,borderRadius:`lg`,bg:`white`,cursor:o?`not-allowed`:`pointer`,opacity:o?.6:1,textAlign:`left`,transition:`all 0.2s`,_hover:o?{}:{borderColor:`gray.400`},children:(0,I.jsxs)(P,{gap:3,align:`flex-start`,children:[(0,I.jsx)(Te,{size:`32px`,bg:`gray.100`,flexShrink:0,children:(0,I.jsx)(Ve,{as:n,boxSize:4,color:`gray.500`})}),(0,I.jsxs)(M,{align:`start`,gap:1,flex:1,children:[(0,I.jsxs)(P,{gap:2,children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`600`,color:`gray.700`,children:r}),e&&(0,I.jsx)(k,{fontSize:`xs`,color:`gray.500`,fontWeight:`500`,children:`Current`})]}),(0,I.jsx)(k,{fontSize:`xs`,color:`gray.600`,children:i}),(0,I.jsx)(A,{mt:1,children:a})]})]})}),X0=g(()=>{let e=CB(K0),t=CB(G0);return(0,I.jsx)(Vq,{sidebar:(0,I.jsx)(i1,{}),children:(0,I.jsx)(A,{maxWidth:`600px`,width:`100%`,mb:`4rem`,children:(0,I.jsxs)(M,{align:`stretch`,gap:`2rem`,children:[(0,I.jsxs)(A,{children:[(0,I.jsx)(k,{fontSize:`20px`,fontWeight:`600`,color:`newGray.500`,mb:1,children:`Settings`}),(0,I.jsx)(k,{fontSize:`xs`,color:`newGray.400`,children:`Project configuration and access controls.`})]}),(0,I.jsxs)(_e,{gap:`1.5rem`,children:[(0,I.jsxs)(A,{children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`600`,color:`gray.600`,mb:`0.5rem`,children:`Project Name`}),(0,I.jsx)(k,{fontSize:`md`,fontWeight:`500`,color:`gray.800`,children:e.projectName})]}),(0,I.jsxs)(A,{children:[(0,I.jsxs)(P,{justify:`space-between`,align:`center`,mb:3,children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`600`,color:`gray.600`,children:`Visibility`}),(0,I.jsx)(mt,{asChild:!0,fontSize:`xs`,color:`gray.500`,children:(0,I.jsxs)(An,{to:e.endpointsLink,children:[`View Endpoints`,(0,I.jsx)(Ve,{as:uf,ml:1})]})})]}),(0,I.jsxs)(M,{gap:3,children:[(0,I.jsx)(Y0,{isSelected:!e.isPublic,onClick:()=>e.setIsPublic(!1),icon:kf,title:`Private`,description:`Only authorized users can access this project.`,disabled:!e.canUpdateProject,details:(0,I.jsx)(k,{fontSize:`xs`,color:`gray.500`,children:`All API operations require authentication.`})}),(0,I.jsx)(Y0,{isSelected:e.isPublic,onClick:()=>e.setIsPublic(!0),icon:_f,title:`Public`,description:`Anyone can view the project and read data.`,disabled:!e.canUpdateProject,details:(0,I.jsxs)(M,{align:`start`,gap:0,children:[(0,I.jsx)(k,{fontSize:`xs`,color:`gray.500`,children:`UI and API read operations — no authentication required`}),(0,I.jsx)(k,{fontSize:`xs`,color:`gray.500`,children:`API write operations — authentication required`})]})})]})]}),(0,I.jsxs)(A,{children:[(0,I.jsxs)(P,{justify:`space-between`,align:`center`,mb:3,children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`600`,color:`gray.600`,children:`API Keys`}),(0,I.jsx)(mt,{asChild:!0,fontSize:`xs`,color:`gray.500`,children:(0,I.jsxs)(An,{to:e.organizationSettingsLink,children:[`Manage all organization keys`,(0,I.jsx)(Ve,{as:uf,ml:1})]})})]}),(0,I.jsx)(k,{fontSize:`xs`,color:`gray.500`,mb:`1rem`,children:`Service keys scoped to this project.`}),e.canManageServiceKeys?(0,I.jsx)(kY,{model:e.apiKeyManager}):(0,I.jsxs)(A,{p:4,textAlign:`center`,borderWidth:`1px`,borderColor:`gray.200`,borderRadius:`lg`,bg:`gray.50`,children:[(0,I.jsx)(k,{fontSize:`sm`,color:`gray.500`,children:`You don't have permission to manage API keys for this project.`}),(0,I.jsx)(mt,{asChild:!0,fontSize:`xs`,color:`blue.500`,mt:2,display:`inline-block`,children:(0,I.jsx)(An,{to:e.organizationSettingsLink,children:`Contact an organization admin to manage API keys`})})]})]}),e.canManageFileUsage&&(0,I.jsx)(J0,{model:t}),e.hasDeletePermission&&(0,I.jsxs)(A,{children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`600`,color:`gray.600`,mb:`0.5rem`,children:`Danger Zone`}),(0,I.jsx)(A,{borderWidth:`1px`,borderColor:`red.200`,borderRadius:`md`,padding:`1rem`,bg:`red.50`,children:(0,I.jsxs)(M,{align:`stretch`,gap:`0.75rem`,children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`500`,color:`red.800`,children:`Delete this project`}),(0,I.jsx)(k,{fontSize:`sm`,color:`red.600`,children:`Once you delete a project, there is no going back. Please be certain.`}),(0,I.jsxs)(Ue,{open:e.isDeleteDialogOpen,onOpenChange:t=>t.open?e.openDeleteDialog():e.closeDeleteDialog(),children:[(0,I.jsx)(ce,{asChild:!0,children:(0,I.jsx)(N,{variant:`outline`,colorScheme:`red`,size:`sm`,alignSelf:`flex-start`,children:`Delete project`})}),(0,I.jsxs)(R,{children:[(0,I.jsx)(pe,{}),(0,I.jsx)(ue,{children:(0,I.jsxs)(_n,{children:[(0,I.jsx)(Ge,{children:(0,I.jsx)(qe,{children:`Delete Project`})}),(0,I.jsx)(be,{children:(0,I.jsxs)(M,{align:`stretch`,gap:`1rem`,children:[(0,I.jsxs)(k,{children:[`This action `,(0,I.jsx)(`strong`,{children:`cannot be undone`}),`. This will permanently delete the`,` `,(0,I.jsx)(`strong`,{children:e.projectName}),` project and all of its data.`]}),(0,I.jsxs)(A,{children:[(0,I.jsxs)(k,{fontSize:`sm`,fontWeight:`500`,mb:`0.5rem`,children:[`Please type "`,e.projectName,`" to confirm`]}),(0,I.jsx)(qt,{value:e.deleteConfirmationText,onChange:t=>e.setDeleteConfirmationText(t.target.value),placeholder:e.projectName})]})]})}),(0,I.jsxs)(w,{children:[(0,I.jsx)(oe,{asChild:!0,children:(0,I.jsx)(N,{variant:`outline`,children:`Cancel`})}),(0,I.jsx)(N,{colorScheme:`red`,disabled:!e.canDeleteProject,onClick:e.deleteProject,children:`I understand the consequences, delete this project`})]}),(0,I.jsx)(Ie,{})]})})]})]})]})})]})]})]})})})}),Z0=300,Q0=class{_isOpen=!1;_activeTab=`search`;_searchQuery=``;_searchResults=[];_selectedUserId=null;_selectedRole=YW.Reader;_newUsername=``;_newPassword=``;_newEmail=``;_isAdding=!1;_isCreating=!1;debounceTimeout=null;searchRequest=X.of(Q.searchUsers);constructor(e,t,n){this.context=e,this.systemPermissions=t,this.onUserAdded=n,f(this,{},{autoBind:!0})}get isOpen(){return this._isOpen}get activeTab(){return this._activeTab}get canCreateUser(){return this.systemPermissions.canCreateUser}get searchQuery(){return this._searchQuery}get searchResults(){return this._searchResults}get selectedUserId(){return this._selectedUserId}get selectedRole(){return this._selectedRole}get isSearching(){return this.searchRequest.isLoading}get canAddSelectedUser(){return this._selectedUserId!==null&&!this._isAdding}get isAdding(){return this._isAdding}get newUsername(){return this._newUsername}get newPassword(){return this._newPassword}get newEmail(){return this._newEmail}get isCreating(){return this._isCreating}get canCreateNewUser(){return this._newUsername.trim().length>0&&this._newPassword.length>=6&&!this._isCreating}open(){this._isOpen=!0,this.reset()}close(){this._isOpen=!1,this.reset()}setActiveTab(e){this._activeTab=e}setSearchQuery(e){this._searchQuery=e,this.debounceTimeout&&=(clearTimeout(this.debounceTimeout),null),e.trim()?this.debounceTimeout=setTimeout(()=>{this.search(),this.debounceTimeout=null},Z0):this._searchResults=[]}setSelectedUserId(e){this._selectedUserId=e}setSelectedRole(e){this._selectedRole=e}setNewUsername(e){this._newUsername=e}setNewPassword(e){this._newPassword=e}setNewEmail(e){this._newEmail=e}async search(){if(this._searchQuery.trim().length===0){this._searchResults=[];return}let e=await this.searchRequest.fetch({search:this._searchQuery,first:20});c(()=>{e.isRight&&(this._searchResults=e.data.searchUsers.edges.map(e=>({id:e.node.id,username:e.node.username??null,email:e.node.email??null})))})}async addSelectedUser(){if(!(!this._selectedUserId||this._isAdding)){this._isAdding=!0;try{let e=await Q.addUserToProject({organizationId:this.context.organizationId,projectName:this.context.projectName,userId:this._selectedUserId,roleId:this._selectedRole});c(()=>{e.addUserToProject&&(this.onUserAdded(),this.close())})}catch(e){console.error(`Failed to add user:`,e)}finally{c(()=>{this._isAdding=!1})}}}async createAndAddUser(){if(this.canCreateNewUser){this._isCreating=!0;try{if(!(await Q.createUser({username:this._newUsername.trim(),password:this._newPassword,email:this._newEmail.trim()||void 0,roleId:XW.SystemUser})).createUser)throw Error(`Failed to create user`);let e=(await Q.searchUsers({search:this._newUsername.trim(),first:1})).searchUsers.edges.find(e=>e.node.username===this._newUsername.trim());if(!e)throw Error(`Could not find newly created user`);let t=await Q.addUserToProject({organizationId:this.context.organizationId,projectName:this.context.projectName,userId:e.node.id,roleId:this._selectedRole});c(()=>{t.addUserToProject&&(this.onUserAdded(),this.close())})}catch(e){console.error(`Failed to create and add user:`,e)}finally{c(()=>{this._isCreating=!1})}}}dispose(){this.debounceTimeout&&=(clearTimeout(this.debounceTimeout),null)}reset(){this.debounceTimeout&&=(clearTimeout(this.debounceTimeout),null),this._activeTab=`search`,this._searchQuery=``,this._searchResults=[],this._selectedUserId=null,this._selectedRole=YW.Reader,this._newUsername=``,this._newPassword=``,this._newEmail=``,this._isAdding=!1,this._isCreating=!1}},$0=class{_isUpdating=!1;_isRemoving=!1;_roleId;constructor(e,t,n,r){this.context=e,this.projectPermissions=t,this.data=n,this.onRemoved=r,f(this,{},{autoBind:!0}),this._roleId=this.data.role.id}get id(){return this.data.id}get userId(){return this.data.user.id}get username(){return this.data.user.username??null}get email(){return this.data.user.email??null}get displayName(){return this.username||this.email||this.userId}get roleId(){return this._roleId}get roleName(){return this.data.role.name}get canUpdateRole(){return this.projectPermissions.canUpdateUser}get canRemove(){return this.projectPermissions.canDeleteUser}get isUpdating(){return this._isUpdating}get isRemoving(){return this._isRemoving}async updateRole(e){if(!(this._isUpdating||e===this._roleId)){this._isUpdating=!0;try{let t=await Q.updateUserProjectRole({organizationId:this.context.organizationId,projectName:this.context.projectName,userId:this.userId,roleId:e});c(()=>{t.updateUserProjectRole&&(this._roleId=e)})}catch(e){console.error(`Failed to update user role:`,e)}finally{c(()=>{this._isUpdating=!1})}}}async remove(){if(!this._isRemoving){this._isRemoving=!0;try{let e=await Q.removeUserFromProject({organizationId:this.context.organizationId,projectName:this.context.projectName,userId:this.userId});c(()=>{e.removeUserFromProject&&this.onRemoved()})}catch(e){console.error(`Failed to remove user:`,e)}finally{c(()=>{this._isRemoving=!1})}}}},e2=function(e){return e.loading=`loading`,e.empty=`empty`,e.list=`list`,e.error=`error`,e}(e2||{}),t2=class{state=e2.loading;getUsersRequest=X.of(Q.getUsersProject,{skipResetting:!0});_items=[];_hasNextPage=!1;_endCursor=null;_totalCount=null;_isInitialLoad=!0;addUserModal;constructor(e,t,n){this.context=e,this.projectPermissions=t,this.systemPermissions=n,f(this,{},{autoBind:!0}),this.addUserModal=new Q0(e,n,this.handleUserAdded)}get canAddUser(){return this.projectPermissions.canAddUser}get canAddMember(){return this.canAddUser}get canCreateUser(){return this.systemPermissions.canCreateUser}get showInitialLoading(){return this.state===e2.loading&&this._isInitialLoad}get showError(){return this.state===e2.error}get showNoUsers(){return this.state===e2.empty&&this._totalCount===0}get showNoMembers(){return this.showNoUsers}get showList(){return this.state===e2.list}get items(){return this._items}get totalCount(){return this._totalCount??0}get hasNextPage(){return this._hasNextPage}get isLoading(){return this.getUsersRequest.isLoading}init(){this.loadInitial()}dispose(){}async tryToFetchNextPage(){if(!this._hasNextPage||this.isLoading||!this._endCursor)return;let e=await this.getUsersRequest.fetch({organizationId:this.organizationId,projectName:this.projectName,first:50,after:this._endCursor});c(()=>{if(e.isRight){let t=e.data.usersProject.edges.map(e=>this.createItemViewModel(e.node));this._items=[...this._items,...t],this._hasNextPage=e.data.usersProject.pageInfo.hasNextPage,this._endCursor=e.data.usersProject.pageInfo.endCursor??null}})}get organizationId(){return this.context.organizationId}get projectName(){return this.context.projectName}createItemViewModel(e){return new $0(this.context,this.projectPermissions,e,this.handleUserRemoved)}handleUserAdded=()=>{this._totalCount!==null&&this._totalCount++,this.reload()};handleUserRemoved=()=>{this._totalCount!==null&&this._totalCount--,this.reload()};async reload(){this._items=[],this._hasNextPage=!1,this._endCursor=null,this._isInitialLoad=!1,this.state=e2.loading,await this.loadInitial()}async loadInitial(){let e=await this.getUsersRequest.fetch({organizationId:this.organizationId,projectName:this.projectName,first:50});c(()=>{e.isRight?(this._items=e.data.usersProject.edges.map(e=>this.createItemViewModel(e.node)),this._hasNextPage=e.data.usersProject.pageInfo.hasNextPage,this._endCursor=e.data.usersProject.pageInfo.endCursor??null,this._totalCount=e.data.usersProject.totalCount,this._items.length>0?this.state=e2.list:this.state=e2.empty):this.state=e2.error})}};Y.register(t2,()=>new t2(Y.get(mQ),Y.get(bW),Y.get(yW)),{scope:`request`});var n2={[YW.Developer]:`Developer`,[YW.Editor]:`Editor`,[YW.Reader]:`Reader`},r2=g(({value:e,onChange:t,disabled:n})=>(0,I.jsx)(Qe,{size:`sm`,width:`120px`,...n&&{opacity:.5,pointerEvents:`none`},children:(0,I.jsx)(Xe,{value:e,onChange:e=>t(e.target.value),children:Object.values(YW).map(e=>(0,I.jsx)(`option`,{value:e,children:n2[e]},e))})})),i2=g(({model:e})=>(0,I.jsx)(lJ,{model:e,title:`Add User to Project`,roleSelect:(0,I.jsx)(r2,{value:e.selectedRole,onChange:e.setSelectedRole})})),a2=g(({model:e})=>(0,I.jsx)(cJ,{model:e,disableRemove:e.isUpdating,roleSlot:(0,I.jsxs)(I.Fragment,{children:[e.isUpdating&&(0,I.jsx)(Ht,{size:`sm`}),e.canUpdateRole?(0,I.jsx)(r2,{value:e.roleId,onChange:t=>e.updateRole(t),disabled:e.isUpdating}):(0,I.jsx)(k,{fontSize:`sm`,color:`newGray.500`,minWidth:`80px`,children:e.roleName})]})})),o2=g(()=>{let e=CB(t2);return(0,I.jsx)(uJ,{model:e,sidebar:(0,I.jsx)(i1,{}),label:`Users`,emptyTitle:`No users in this project`,emptySubtitle:`Add team members to collaborate on this project`,subtitle:`Manage team members and their access levels for this project.`,onAddClick:()=>e.addUserModal.open(),modal:(0,I.jsx)(i2,{model:e.addUserModal}),children:e.items.map(e=>(0,I.jsx)(a2,{model:e},e.id))})}),s2=g(()=>{let e=b$().make({revisionIdOrTag:XJ});return(0,I.jsxs)(j,{alignItems:`center`,justifyContent:`center`,gap:`4px`,paddingY:`8px`,paddingX:`4px`,backgroundColor:`newGray.50`,borderRadius:`6px`,position:`sticky`,top:0,zIndex:4,children:[(0,I.jsx)(k,{color:`newGray.400`,fontSize:`16px`,fontWeight:`400`,children:`You are viewing a read-only revision`}),(0,I.jsx)(An,{to:e,children:(0,I.jsx)(k,{color:`newGray.500`,fontSize:`16px`,fontWeight:`500`,textDecoration:`underline`,children:`Go to draft revision`})})]})}),c2=class{_tableId=void 0;_rowId=void 0;constructor(e){this.linkMaker=e,f(this,{},{autoBind:!0})}get breadcrumbs(){let e=[];return e.push({title:`Database`,href:this.linkMaker.currentBaseLink,isCurrentPage:!this._tableId,dataTestId:`breadcrumb-branch-tables`}),this._tableId&&e.push({title:this._tableId,href:Dn(`${this.linkMaker.currentBaseLink}/${JJ}`,{tableId:this._tableId}),isCurrentPage:!this._rowId,dataTestId:`breadcrumb-table-${this._tableId}`}),e}init(e,t){this._tableId=e,this._rowId=t}dispose(){}};Y.register(c2,()=>new c2(Y.get(hQ)),{scope:`request`});var l2=g(({rowIdEditable:e,rowIdReadonly:t,onLastSegmentClick:n})=>{let{tableId:r,rowId:i}=bn(),a=Tn(),o=CB(c2,r,i),s=o.breadcrumbs.map(e=>({label:e.title,dataTestId:e.dataTestId}));return t&&s.push({label:t}),(0,I.jsx)(JN,{segments:s,highlightLast:!1,onSegmentClick:(e,t)=>{t===o.breadcrumbs.length-1&&n?n():t<o.breadcrumbs.length&&a(o.breadcrumbs[t].href)},editable:e})}),u2=g(({showTitle:e=!0})=>{let t=!Y.get(mQ).isDraftRevision;return(0,I.jsx)(Vq,{sidebar:(0,I.jsx)(i1,{}),title:e?(0,I.jsx)(l2,{}):void 0,children:(0,I.jsxs)(j,{flex:1,flexDirection:`column`,gap:`1rem`,position:`relative`,children:[t&&(0,I.jsx)(s2,{}),(0,I.jsx)(j,{flexDirection:`column`,gap:`0.5rem`,flex:1,children:(0,I.jsx)(En,{})})]})})}),d2=g(()=>{let e=!Y.get(mQ).isDraftRevision;return(0,I.jsx)(Vq,{sidebar:(0,I.jsx)(i1,{}),children:(0,I.jsxs)(j,{flex:1,flexDirection:`column`,position:`relative`,marginTop:`-12px`,children:[e&&(0,I.jsx)(s2,{}),(0,I.jsx)(En,{})]})})}),f2=class{isLoading=!1;constructor(e,t,n){this.authService=e,this.routerService=t,this.apiService=n,f(this)}async confirmEmailCode(e){e?(await this.request(e),await this.routerService.navigate(`/`)):console.error(`Invalid code`)}init(){}dispose(){}async request(e){this.setIsLoading(!0);try{let t=await this.apiService.client.confirmEmailCode({data:{code:e}});return await this.authService.afterLogin(t.confirmEmailCode.accessToken),!0}catch(e){console.error(e)}finally{this.setIsLoading(!1)}}setIsLoading(e){this.isLoading=e}};Y.register(f2,()=>new f2(Y.get(hJ),Y.get(X9),Y.get(dJ)),{scope:`request`});var p2=g(()=>{let[e]=wn({code:``}),t=CB(f2);return(0,L.useEffect)(()=>{t.confirmEmailCode(e.get(`code`))},[t,e]),t.isLoading?(0,I.jsx)(y,{w:`100%`,h:`100%`,children:(0,I.jsx)(Ht,{})}):null}),Hse=()=>null,m2=class{isLoading=!1;constructor(e,t){this.apiService=e,this.authService=t,f(this)}async login(e){e?await this.loginRequest(e):console.error(`Invalid code`)}dispose(){}init(){}async loginRequest(e){this.setIsLoading(!0);try{let t=await this.apiService.client.loginGithub({data:{code:e}});return await this.authService.afterLogin(t.loginGithub.accessToken),!0}catch(e){console.error(e)}finally{this.setIsLoading(!1)}}setIsLoading(e){this.isLoading=e}};Y.register(m2,()=>new m2(Y.get(dJ),Y.get(hJ)),{scope:`request`});var Use=async({request:e})=>{let t=new URL(e.url).searchParams,n=t.get(`code`),r=YV(XV(t.get(`state`)));if(!n)throw Error(`Invalid code`);return await Y.get(m2).login(n),Cn(r||`/`)},Wse=async e=>Q.login(e),Gse=()=>`${globalThis.location.origin}/${yJ}/${CJ}`,h2=(e,t)=>{let n=Gse(),r=`https://github.com/login/oauth/authorize?client_id=${e}&redirect_uri=${encodeURIComponent(n)}&scope=user:email`,i=ZV(t);i&&(r+=`&state=${encodeURIComponent(i)}`),globalThis.location.href=r},g2=()=>`${globalThis.location.origin}/${yJ}/${wJ}`,_2=(e,t)=>{let n=g2(),r=`https://accounts.google.com/o/oauth2/v2/auth?client_id=${e}&redirect_uri=${encodeURIComponent(n)}&response_type=code&scope=profile email`,i=ZV(t);i&&(r+=`&state=${encodeURIComponent(i)}`),globalThis.location.href=r},v2=class{isLoading=!1;form=new JV({emailOrUsername:``,password:``});constructor(e,t,n){this.authService=e,this.configurationService=t,this.routerService=n,f(this)}get availableSignUp(){return this.configurationService.availableSignUp}get disableSubmitButton(){return!this.form.isValid}get availableOauth(){return this.configurationService.availableGoogleOauth}get availableGoogleOauth(){return this.configurationService.availableGoogleOauth}get availableGithubOauth(){return this.configurationService.availableGithubOauth}toGoogleOauth(){_2(this.configurationService.googleOauthClientId,QV())}toGithubOauth(){h2(this.configurationService.githubOauthClientId,QV())}async submit(){await this.login()&&await this.routerService.navigate(QV()||`/`)}dispose(){}init(){}async login(){this.setIsLoading(!0);try{let e=await Wse({data:this.form.values});return await this.authService.afterLogin(e.login.accessToken),!0}catch(e){console.error(e)}finally{this.setIsLoading(!1)}}setIsLoading(e){this.isLoading=e}};Y.register(v2,()=>new v2(Y.get(hJ),Y.get(gJ),Y.get(X9)),{scope:`request`});var Kse=g(()=>{let e=CB(v2),t=(0,L.useCallback)(t=>{e.form.setValue(`emailOrUsername`,t.currentTarget.value)},[e.form]),n=(0,L.useCallback)(t=>{e.form.setValue(`password`,t.currentTarget.value)},[e.form]),r=(0,L.useCallback)(async()=>{await e.submit()},[e]),i=(0,L.useCallback)(()=>{e.toGithubOauth()},[e]),a=(0,L.useCallback)(()=>{e.toGoogleOauth()},[e]);return(0,I.jsxs)(Vq,{hideSidebar:!0,children:[e.availableSignUp&&(0,I.jsxs)(j,{width:`100%`,gap:`8px`,justifyContent:`flex-end`,children:[(0,I.jsx)(k,{color:`gray.300`,children:`New to Revisium?`}),(0,I.jsx)(An,{to:`/signup`,children:(0,I.jsx)(mt,{color:`gray.300`,alignSelf:`center`,children:`Sign up`})})]}),(0,I.jsx)(j,{alignItems:`center`,justifyContent:`center`,flex:1,children:(0,I.jsxs)(j,{flexDirection:`column`,width:`16rem`,gap:`1rem`,alignItems:`center`,children:[e.availableOauth&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(j,{flexDirection:`column`,gap:`2px`,children:[e.availableGithubOauth&&(0,I.jsx)(Hq,{icon:(0,I.jsx)(cf,{}),onClick:i,title:`Continue with Github`}),e.availableGoogleOauth&&(0,I.jsx)(Hq,{icon:(0,I.jsx)(lf,{}),onClick:a,title:`Continue with Google`})]}),(0,I.jsxs)(j,{width:`100%`,alignItems:`center`,gap:`16px`,children:[(0,I.jsx)(A,{backgroundColor:`gray.100`,flex:1,height:`1px`}),(0,I.jsx)(k,{color:`gray.300`,fontSize:`12px`,children:`OR`}),(0,I.jsx)(A,{backgroundColor:`gray.100`,flex:1,height:`1px`})]})]}),(0,I.jsx)(qq,{dataTestId:`login-emailOrUsername-input`,autoFocus:!0,height:`40px`,placeholder:`username or email`,value:e.form.values.emailOrUsername,onChange:t,onEnter:r}),(0,I.jsx)(qq,{dataTestId:`login-password-input`,height:`40px`,placeholder:`password`,type:`password`,value:e.form.values.password,onChange:n,onEnter:r}),(0,I.jsx)(A,{visibility:e.disableSubmitButton?`hidden`:`visible`,children:(0,I.jsx)(Hq,{onClick:r,isLoading:e.isLoading,title:`Login`})})]})})]})}),y2=class{async getProject(e,t){return(await Q.getProjectForLoader({data:{organizationId:e,projectName:t}})).project}};Y.register(y2,()=>new y2,{scope:`singleton`});var b2=class{constructor(e,t){this.authService=e,this.projectContext=t,f(this)}async logout(){this.projectContext.clear(),await this.authService.logout()}dispose(){}init(){}};Y.register(b2,()=>new b2(Y.get(hJ),Y.get(mQ)),{scope:`request`});var qse=g(()=>{let e=CB(b2),t=Tn();return(0,L.useEffect)(()=>{let n=!1;return e.logout().finally(()=>{n||t(`/${yJ}`)}).catch(()=>void 0),()=>{n=!0}},[e,t]),null}),x2=class{isCreatingProject=!1;constructor(e){this.systemPermissions=e,f(this,{},{autoBind:!0})}get canAccessAdmin(){return this.systemPermissions.canReadUser}toggleCreatingProject(){this.isCreatingProject=!this.isCreatingProject}init(){}dispose(){}};Y.register(x2,()=>new x2(Y.get(yW)),{scope:`request`});var S2=class extends rH{constructor(){super(Q.meProjectsList,{pageSize:100})}extractItems(e){return e.meProjects.edges.map(e=>e.node)}extractPageInfo(e){return{hasNextPage:e.meProjects.pageInfo.hasNextPage,endCursor:e.meProjects.pageInfo.endCursor||null,totalCount:e.meProjects.totalCount}}buildFetchArgs(e,t){return{data:{first:this.config.pageSize,after:t}}}};Y.register(S2,()=>new S2,{scope:`request`});var Jse=e=>Dn(`/app/${AJ}`,{organizationId:e}),Yse=class{constructor(e){this.project=e,f(this)}get id(){return this.project.id}get name(){return this.project.name}get organizationId(){return this.project.organizationId}get touched(){return this.project.rootBranch.touched}get organizationLink(){return Jse(this.project.organizationId)}get link(){return Dn(`/app/${AJ}/${PJ}/${zJ}/${qJ}`,{organizationId:this.project.organizationId,projectName:this.project.name,branchName:this.project.rootBranch.name,revisionIdOrTag:XJ})}},C2=class extends nH{getItemKey(e){return e.id}createItemViewModel(e){return new Yse(e)}};Y.register(C2,()=>new C2(Y.get(S2)),{scope:`request`});var Xse=({onCreate:e})=>(0,I.jsxs)(M,{flex:1,justifyContent:`center`,gap:`8px`,color:`gray.400`,children:[(0,I.jsx)(k,{fontSize:`md`,children:`No projects yet`}),e?(0,I.jsx)(mt,{fontSize:`sm`,color:`gray.500`,_hover:{color:`gray.600`},onClick:e,cursor:`pointer`,children:`Create your first project to get started`}):(0,I.jsx)(k,{fontSize:`sm`,children:`Create your first project to get started`})]}),Zse=g(({model:e})=>(0,I.jsx)(A,{height:`2.5rem`,width:`100%`,children:(0,I.jsx)(j,{_hover:{backgroundColor:`gray.50`},alignItems:`center`,gap:`4px`,paddingLeft:`1rem`,"data-testid":`project-${e.name}`,children:(0,I.jsx)(j,{alignItems:`center`,flex:1,justifyContent:`space-between`,minHeight:`40px`,children:(0,I.jsxs)(j,{minWidth:`150px`,children:[(0,I.jsxs)(j,{gap:`4px`,children:[(0,I.jsx)(k,{color:`gray.300`,_hover:{textDecoration:`underline`},children:(0,I.jsx)(An,{to:e.organizationLink,children:e.organizationId})}),(0,I.jsx)(k,{color:`gray.300`,children:`/`}),(0,I.jsx)(k,{_hover:{textDecoration:`underline`},children:(0,I.jsx)(An,{to:e.link,"data-testid":`project-${e.organizationId}-${e.name}-link`,children:e.name})})]}),e.touched&&`*`]})})})})),Qse=g(({onCreateProject:e})=>{let t=CB(C2);return t.showLoading?(0,I.jsx)(M,{flex:1,justifyContent:`center`,children:(0,I.jsx)(Ht,{size:`md`,color:`gray.400`})}):t.showError?(0,I.jsxs)(M,{flex:1,justifyContent:`center`,gap:`8px`,color:`gray.400`,children:[(0,I.jsx)(k,{fontSize:`md`,children:`Could not load projects`}),(0,I.jsx)(k,{fontSize:`sm`,children:`Please retry later`})]}):t.showEmpty?(0,I.jsx)(Xse,{onCreate:e}):t.showList?(0,I.jsx)(QM,{useWindowScroll:!0,totalCount:t.totalCount,defaultItemHeight:40,endReached:t.hasNextPage?t.tryToFetchNextPage:void 0,itemContent:e=>{let n=t.items[e];return n?(0,I.jsx)(Zse,{model:n},n.id):null}}):null}),$se=()=>(0,I.jsx)(j,{className:`group`,flexDirection:`column`,alignItems:`flex-start`,width:`100%`,minWidth:`0`,children:(0,I.jsxs)(j,{alignItems:`center`,gap:`8px`,padding:`4px`,width:`100%`,children:[(0,I.jsx)(k,{color:`newGray.400`,fontWeight:`600`,fontSize:`18px`,lineHeight:`26px`,children:`Revisium`}),(0,I.jsxs)(j,{gap:`4px`,children:[(0,I.jsx)(`a`,{href:`https://revisium.io`,target:`_blank`,rel:`noopener noreferrer`,children:(0,I.jsx)(j,{fontSize:`16px`,color:`newGray.400`,_hover:{color:`newGray.600`},cursor:`pointer`,alignItems:`center`,children:(0,I.jsx)(Jte,{})})}),(0,I.jsx)(`a`,{href:`https://github.com/revisium/revisium`,target:`_blank`,rel:`noopener noreferrer`,children:(0,I.jsx)(j,{fontSize:`16px`,color:`newGray.400`,_hover:{color:`newGray.600`},cursor:`pointer`,alignItems:`center`,children:(0,I.jsx)(qte,{})})})]}),(0,I.jsx)(T,{}),(0,I.jsx)(oJ,{})]})}),ece=g(()=>{let e=CB(x2);return(0,I.jsxs)(M,{alignItems:`flex-start`,gap:0,width:`100%`,flex:1,children:[(0,I.jsx)($se,{}),(0,I.jsx)(A,{width:`100%`,paddingY:`16px`,children:(0,I.jsx)(O,{borderColor:`newGray.100`})}),e.canAccessAdmin&&(0,I.jsx)(j,{flexDirection:`column`,width:`100%`,gap:1,children:(0,I.jsx)(An,{to:`/admin`,style:{textDecoration:`none`,width:`100%`},children:(0,I.jsxs)(j,{alignItems:`center`,backgroundColor:`transparent`,_hover:{backgroundColor:`newGray.100`},borderRadius:`8px`,height:`36px`,paddingX:`8px`,width:`100%`,color:`newGray.600`,fontWeight:`400`,textDecoration:`none`,fontSize:`14px`,minWidth:`0`,cursor:`pointer`,gap:`12px`,userSelect:`none`,children:[(0,I.jsx)(A,{fontSize:`20px`,color:`newGray.400`,children:(0,I.jsx)(Sf,{})}),(0,I.jsx)(A,{flex:`1`,minWidth:`0`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,overflow:`hidden`,children:`Admin`})]})})}),(0,I.jsx)(T,{}),(0,I.jsx)(j,{flexDirection:`column`,width:`100%`,gap:1,children:(0,I.jsx)(IY,{})})]})}),tce=g(()=>{let e=CB(x2);return(0,I.jsx)(Vq,{title:(0,I.jsx)(A,{height:`40px`}),sidebar:(0,I.jsx)(ece,{}),children:(0,I.jsx)(j,{flex:1,flexDirection:`column`,gap:`0.5rem`,paddingBottom:`1rem`,children:e.isCreatingProject?(0,I.jsx)(q1,{onComplete:e.toggleCreatingProject}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(H1,{onClick:e.toggleCreatingProject}),(0,I.jsx)(Qse,{onCreateProject:e.toggleCreatingProject})]})})})}),w2=class{getMigrationsRequest=X.of(Q.getMigrations,{skipResetting:!0});getBranchesRequest=X.of(Q.getMigrationBranches);getBranchMigrationsRequest=X.of(Q.getBranchMigrations);applyMigrationsRequest=X.of(Q.applyMigrations);async getMigrations(e){let t=await this.getMigrationsRequest.fetch({data:{revisionId:e}});return t.isRight?{...t,data:t.data.revision.migrations??[]}:t}async getBranches(e,t){let n=await this.getBranchesRequest.fetch({data:{organizationId:e,projectName:t,first:100}});return n.isRight?n.data.branches.edges.map(e=>{let t=e.node;return{id:t.id,name:t.name,isRoot:t.isRoot,headRevisionId:t.head.id,draftRevisionId:t.draft.id}}):null}async getBranchMigrations(e){let t=await this.getBranchMigrationsRequest.fetch({data:{revisionId:e}});return t.isRight?t.data.revision.migrations??[]:null}async applyMigrations(e,t){let n=await this.applyMigrationsRequest.fetch({data:{revisionId:e,migrations:t}});return n.isRight?n.data.applyMigrations:null}dispose(){this.getMigrationsRequest.abort(),this.getBranchesRequest.abort(),this.getBranchMigrationsRequest.abort(),this.applyMigrationsRequest.abort()}};Y.register(w2,()=>new w2,{scope:`request`});var T2=function(e){return e.Table=`table`,e.Json=`json`,e}({});function nce(e){let t=[];for(let n of e)if(n.changeType===`init`&&t.push({migrationId:n.id,tableId:n.tableId,patch:{op:`add`,path:`/`,value:n.schema},timestamp:n.id,parentMigration:n}),n.changeType===`update`&&n.patches){let e=Array.isArray(n.patches)?n.patches:[n.patches];for(let r of e)r&&typeof r==`object`&&`op`in r&&`path`in r&&t.push({migrationId:n.id,tableId:n.tableId,patch:r,timestamp:n.id,parentMigration:n})}return t}function rce(e,t){let n=new Set(t.map(e=>e.id)),r=t[t.length-1]?.id??``,i=!1;return e.map(e=>n.has(e.id)?{status:`skip`,migration:e,reason:`Already applied`}:i?{status:`blocked`,migration:e,reason:`Blocked by previous conflict`}:r&&e.id<=r?(i=!0,{status:`conflict`,migration:e,reason:`Migration ID must be after ${r}`}):{status:`apply`,migration:e})}function ice(e){return e.filter(e=>e.status===`apply`).map(e=>e.migration)}function ace(e){return e.some(e=>e.status===`conflict`)}function oce(e){return{toApply:e.filter(e=>e.status===`apply`).length,toSkip:e.filter(e=>e.status===`skip`).length,conflicts:e.filter(e=>e.status===`conflict`).length,blocked:e.filter(e=>e.status===`blocked`).length}}var E2=class{_isOpen=!1;_sourceMigrations=[];_diffResult=[];_viewMode=T2.Table;_applyResult=null;_isApplying=!1;_virtuosoRef=null;constructor(e,t,n,r){this.context=e,this.dataSource=t,this.existingMigrations=n,this.onApplied=r,h(this,{_isOpen:u,_sourceMigrations:u,_diffResult:u,_viewMode:u,_applyResult:u,_isApplying:u,isOpen:a,previewItems:a,migrationsToApply:a,hasConflict:a,canApply:a,summary:a,canRemoveLast:a,viewMode:a,isApplying:a,applyResult:a,applyResultSummary:a,failedResults:a,showResult:a,setViewMode:m.bound,setVirtuosoRef:m.bound,removeLastMigration:m.bound,apply:m.bound,close:m.bound,resetBase:m.bound})}get isOpen(){return this._isOpen}get previewItems(){return this._diffResult}get migrationsToApply(){return ice(this._diffResult)}get hasConflict(){return ace(this._diffResult)}get canApply(){return!this.hasConflict&&this.migrationsToApply.length>0&&!this._isApplying}get summary(){return oce(this._diffResult)}get canRemoveLast(){return this._sourceMigrations.length>0}get viewMode(){return this._viewMode}get isApplying(){return this._isApplying}get applyResult(){return this._applyResult}get applyResultSummary(){if(!this._applyResult)return null;let e=this._applyResult.filter(e=>e.status===LW.Applied).length,t=this._applyResult.filter(e=>e.status===LW.Skipped).length,n=this._applyResult.filter(e=>e.status===LW.Failed).length;return{applied:e,skipped:t,failed:n,hasFailures:n>0}}get failedResults(){return this._applyResult?this._applyResult.filter(e=>e.status===LW.Failed):[]}get showResult(){return this._applyResult!==null}setViewMode(e){this._viewMode=e}setVirtuosoRef(e){this._virtuosoRef=e}removeLastMigration(){this._sourceMigrations.length!==0&&(this._sourceMigrations=this._sourceMigrations.slice(0,-1),this.recalculateDiff())}copyFilteredJson(){navigator.clipboard.writeText(JSON.stringify(this.migrationsToApply,null,2))}async apply(){if(!this.canApply)return;this._isApplying=!0;let e=await this.dataSource.applyMigrations(this.context.revisionId,this.migrationsToApply);c(()=>{this._isApplying=!1,e&&(this._applyResult=e,e.every(e=>e.status!==LW.Failed)&&(this.context.updateTouched(!0),this.onApplied()))})}close(){this._isOpen=!1,this.reset()}dispose(){this.reset()}recalculateDiff(){this._diffResult=rce(this._sourceMigrations,this.existingMigrations),this.scrollToLast()}resetBase(){this._sourceMigrations=[],this._diffResult=[],this._applyResult=null,this._isApplying=!1,this._virtuosoRef=null}scrollToLast(){this._diffResult.length>0&&this._viewMode===T2.Table&&setTimeout(()=>{this._virtuosoRef?.scrollToIndex({index:this._diffResult.length-1,behavior:`auto`})},100)}},D2=class{constructor(e){this.create=e}},sce=class extends E2{_branches=[];_selectedBranchId=null;_selectedRevision=XJ;_isLoadingBranches=!1;_isLoadingMigrations=!1;constructor(e,t,n,r,i){super(e,t,n,r),this.currentBranchId=i,h(this,{_branches:u,_selectedBranchId:u,_selectedRevision:u,_isLoadingBranches:u,_isLoadingMigrations:u,branches:a,hasNoBranches:a,selectedBranchId:a,selectedBranch:a,selectedRevision:a,isLoadingBranches:a,isLoadingMigrations:a,setSelectedBranchId:m.bound,setSelectedRevision:m.bound,open:m.bound})}get branches(){return this._branches.filter(e=>e.id!==this.currentBranchId)}get hasNoBranches(){return this.branches.length===0&&!this._isLoadingBranches}get selectedBranchId(){return this._selectedBranchId}get selectedBranch(){return this._branches.find(e=>e.id===this._selectedBranchId)??null}get selectedRevision(){return this._selectedRevision}get isLoadingBranches(){return this._isLoadingBranches}get isLoadingMigrations(){return this._isLoadingMigrations}setSelectedBranchId(e){this._selectedBranchId=e,this._applyResult=null,e?this.loadMigrations():(this._sourceMigrations=[],this._diffResult=[])}setSelectedRevision(e){this._selectedRevision=e,this._applyResult=null,this._selectedBranchId&&this.loadMigrations()}async open(){this._isOpen=!0,await this.loadBranches()}reset(){this._selectedBranchId=null,this._selectedRevision=XJ,this._branches=[],this._isLoadingBranches=!1,this._isLoadingMigrations=!1,this.resetBase()}async loadBranches(){this._isLoadingBranches=!0;let e=await this.dataSource.getBranches(this.context.organizationId,this.context.projectName);c(()=>{this._isLoadingBranches=!1,this._branches=e??[]})}async loadMigrations(){let e=this.selectedBranch;if(!e)return;let t=this._selectedRevision===`head`?e.headRevisionId:e.draftRevisionId;this._isLoadingMigrations=!0;let n=await this.dataSource.getBranchMigrations(t);c(()=>{this._isLoadingMigrations=!1,this._sourceMigrations=n??[],this.recalculateDiff()})}};Y.register(D2,()=>new D2((e,t,n)=>new sce(Y.get(mQ),Y.get(w2),e,t,n)),{scope:`request`});var O2=class{constructor(e){this.create=e}},cce=class extends E2{_jsonInput=``;_parseError=null;constructor(e,t,n,r){super(e,t,n,r),h(this,{_jsonInput:u,_parseError:u,jsonInput:a,parseError:a,setJsonInput:m.bound,open:m.bound})}get jsonInput(){return this._jsonInput}get parseError(){return this._parseError}setJsonInput(e){this._jsonInput=e,this._applyResult=null,this.parseAndDiff()}removeLastMigration(){this._sourceMigrations.length!==0&&(this._sourceMigrations=this._sourceMigrations.slice(0,-1),this._jsonInput=JSON.stringify(this._sourceMigrations,null,2),this.recalculateDiff())}open(){this._isOpen=!0}reset(){this._jsonInput=``,this._parseError=null,this.resetBase()}parseAndDiff(){if(!this._jsonInput.trim()){this._parseError=null,this._sourceMigrations=[],this._diffResult=[];return}try{let e=JSON.parse(this._jsonInput);if(!Array.isArray(e)){this._parseError=`Input must be an array of migrations`,this._sourceMigrations=[],this._diffResult=[];return}this._parseError=null,this._sourceMigrations=e,this.recalculateDiff()}catch{this._parseError=`Invalid JSON format`,this._sourceMigrations=[],this._diffResult=[]}}};Y.register(O2,()=>new O2((e,t)=>new cce(Y.get(mQ),Y.get(w2),e,t)),{scope:`request`});function lce(e){if(e===``)return``;let t=e.startsWith(`/`)?e.slice(1):e;if(t===``)return``;let n=t.split(`/`),r=``,i=0;for(;i<n.length;){let e=n[i];if(e===`properties`){if(i++,i<n.length){let e=n[i];e&&(r&&(r+=`.`),r+=e)}}else e===`items`&&(r+=`[*]`);i++}return r}function k2(e){return lce(e)||e}function uce(e){let t=e.patch.value;return!t||typeof t!=`object`?null:`$ref`in t&&typeof t.$ref==`string`?t.$ref:`type`in t&&typeof t.type==`string`?t.type:null}function A2(e){return{text:e}}function j2(e){return{text:e,highlight:!0}}function dce(e){return{text:e,gray:!0}}function fce(e){let{op:t,path:n,from:r}=e.patch,i=e.tableId,a=k2(n);switch(t){case`add`:{if(n===`/`)return{icon:Lf,segments:[A2(`Table `),j2(i),A2(` was created`)]};let t=uce(e),r=t?[dce(` (${t})`)]:[];return{icon:Pf,segments:[A2(`Field `),j2(a),...r,A2(` was added to table `),j2(i)]}}case`remove`:return{icon:jf,segments:[A2(`Field `),j2(a),A2(` was removed from table `),j2(i)]};case`replace`:return{icon:Mf,segments:[A2(`Field `),j2(a),A2(` was modified in table `),j2(i)]};case`move`:if(r){let e=k2(r);return{icon:ff,segments:[A2(`Renamed field `),j2(e),A2(` to `),j2(a),A2(` in table `),j2(i)]}}return{icon:ff,segments:[A2(`Moved field to `),j2(a),A2(` in table `),j2(i)]};default:return{icon:Mf,segments:[A2(`Operation `),j2(t),A2(` on `),j2(a),A2(` in table `),j2(i)]}}}function pce(e,t){return{icon:rne,segments:[A2(`Table `),j2(e),A2(` was renamed to `),j2(t)]}}function mce(e){return{icon:Rf,segments:[A2(`Table `),j2(e),A2(` was removed`)]}}function hce(e){let{changeType:t}=e.parentMigration;switch(t){case`init`:return{icon:Lf,segments:[A2(`Table `),j2(e.tableId),A2(` was created`)]};case`update`:return fce(e);case`rename`:{let t=e.parentMigration.nextTableId;return pce(e.tableId,t)}case`remove`:return mce(e.tableId);default:return{icon:Mf,segments:[A2(`Unknown operation on table `),j2(e.tableId)]}}}var M2=class{constructor(e){this.create=e}},gce=class{_isPopoverOpen=!1;constructor(e){this.data=e,f(this,{},{autoBind:!0})}get id(){return`${this.data.migrationId}-${this.data.patch.path}`}get isPopoverOpen(){return this._isPopoverOpen}setPopoverOpen(e){this._isPopoverOpen=e}get fullPatchData(){return this.data.parentMigration}get relativeTime(){return xY(this.data.migrationId)}get description(){return hce(this.data)}get descriptionSegments(){return this.description.segments}get descriptionIcon(){return this.description.icon}};Y.register(M2,()=>new M2(e=>new gce(e)),{scope:`request`});var N2=function(e){return e.loading=`loading`,e.empty=`empty`,e.list=`list`,e.error=`error`,e}(N2||{}),P2=class{_state=N2.loading;_viewMode=T2.Table;_migrations=[];_revisionReaction=null;_applyDialog=null;_applyFromBranchDialog=null;constructor(e,t,n,r,i,a){this.context=e,this.projectPermissions=t,this.dataSource=n,this.applyDialogFactory=r,this.applyFromBranchDialogFactory=i,this.migrationItemFactory=a,f(this,{},{autoBind:!0})}get showLoading(){return this._state===N2.loading}get showError(){return this._state===N2.error}get showEmpty(){return this._state===N2.empty}get showList(){return this._state===N2.list}get data(){return this._migrations}get patchItems(){return nce(this._migrations).reverse().map(e=>this.migrationItemFactory.create(e))}get items(){return this.patchItems}get viewMode(){return this._viewMode}get isTableMode(){return this._viewMode===T2.Table}setViewMode(e){this._viewMode=e}get isEmpty(){return this._migrations.length===0}get totalCount(){return this.patchItems.length}get migrationsCount(){return this._migrations.length}get canApplyMigrations(){return this.projectPermissions.canCreateTable}get branchName(){return this.context.branchName}get applyDialog(){return this._applyDialog}get applyFromBranchDialog(){return this._applyFromBranchDialog}openApplyDialog(){this._applyDialog=this.applyDialogFactory.create(this._migrations,this.handleMigrationsApplied),this._applyDialog.open()}openApplyFromBranchDialog(){this._applyFromBranchDialog=this.applyFromBranchDialogFactory.create(this._migrations,this.handleMigrationsApplied,this.context.branchId),this._applyFromBranchDialog.open()}copyMigrationsJson(){navigator.clipboard.writeText(JSON.stringify(this._migrations,null,2))}init(){this.load(),this._revisionReaction=s(()=>this.context.revisionId,()=>{this.reset(),this.load()})}dispose(){this._revisionReaction?.(),this._revisionReaction=null,this._applyDialog?.dispose(),this._applyFromBranchDialog?.dispose(),this.dataSource.dispose()}async reload(){await this.load()}reset(){this._state=N2.loading,this._migrations=[]}async load(){let e=await this.dataSource.getMigrations(this.context.revisionId);if(!e.isRight){if(qV(e))return;c(()=>{this._state=N2.error});return}c(()=>{this._migrations=e.data,this._state=e.data.length>0?N2.list:N2.empty})}handleMigrationsApplied=()=>{this.reload()}};Y.register(P2,()=>new P2(Y.get(mQ),Y.get(bW),Y.get(w2),Y.get(O2),Y.get(D2),Y.get(M2)),{scope:`request`});var F2=g(({summary:e,failedResults:t})=>(0,I.jsxs)(M,{align:`stretch`,gap:3,p:4,bg:e.hasFailures?`red.50`:`green.50`,borderRadius:`md`,children:[(0,I.jsxs)(P,{children:[(0,I.jsx)(Ve,{as:e.hasFailures?sne:hf,color:e.hasFailures?`red.500`:`green.500`,boxSize:5}),(0,I.jsx)(k,{fontWeight:`500`,color:e.hasFailures?`red.700`:`green.700`,children:e.hasFailures?`Apply failed`:`Successfully applied`})]}),(0,I.jsxs)(P,{gap:4,children:[e.applied>0&&(0,I.jsxs)(k,{fontSize:`sm`,color:`green.600`,children:[e.applied,` applied`]}),e.skipped>0&&(0,I.jsxs)(k,{fontSize:`sm`,color:`gray.500`,children:[e.skipped,` skipped`]}),e.failed>0&&(0,I.jsxs)(k,{fontSize:`sm`,color:`red.600`,children:[e.failed,` failed`]})]}),t.map(e=>(0,I.jsx)(A,{p:2,bg:`red.100`,borderRadius:`sm`,children:(0,I.jsxs)(k,{fontSize:`sm`,color:`red.700`,children:[e.id,`: `,e.error]})},e.id))]})),_ce=({isSelected:e,onClick:t,icon:n,dataTestId:r})=>(0,I.jsx)(Ze,{"data-testid":r,_disabled:e?{backgroundColor:`newGray.100`,cursor:`not-allowed`}:void 0,_hover:{backgroundColor:`gray.50`},disabled:e,alignSelf:`flex-start`,variant:`ghost`,onClick:t,width:`48px`,size:`sm`,children:n}),vce=[{mode:T2.Table,icon:(0,I.jsx)(cp,{}),dataTestId:`migrations-mode-table`},{mode:T2.Json,icon:(0,I.jsx)(op,{}),dataTestId:`migrations-mode-json`}],I2=({mode:e,onChange:t})=>(0,I.jsx)(j,{gap:`4px`,children:vce.map(n=>(0,I.jsx)(_ce,{dataTestId:n.dataTestId,isSelected:n.mode===e,onClick:()=>t(n.mode),icon:n.icon},n.mode))}),yce={apply:hf,skip:nne,conflict:Vf,blocked:Of},bce={apply:`green.500`,skip:`gray.400`,conflict:`orange.500`,blocked:`gray.400`};function xce(e){let{changeType:t,tableId:n}=e.migration;switch(t){case`init`:return`init: ${n} (new table)`;case`update`:return`update: ${n}`;case`rename`:return`rename: ${n} → ${e.migration.nextTableId}`;case`remove`:return`remove: ${n}`;default:return`${t}: ${n}`}}function Sce(e){switch(e){case`apply`:return`Apply`;case`skip`:return`Skip`;case`conflict`:return`Conflict`;case`blocked`:return`Blocked`;default:throw Error(`Unknown status: ${e}`)}}var Cce=g(({item:e,index:t,isLast:n,canRemove:r,onRemove:i})=>{let a=yce[e.status],o=bce[e.status],s=n&&r&&i&&e.status===`apply`,[c,l]=(0,L.useState)(!1),u=(0,I.jsxs)(j,{align:`center`,height:`40px`,px:3,borderBottom:`1px solid`,borderColor:`gray.100`,_hover:{bg:s?`red.50`:`gray.50`},gap:3,cursor:s?`pointer`:`default`,children:[(0,I.jsx)(k,{fontSize:`sm`,color:`gray.400`,minWidth:`24px`,children:t+1}),(0,I.jsxs)(j,{align:`center`,gap:2,minWidth:`90px`,children:[(0,I.jsx)(Ve,{as:a,color:o,boxSize:4}),(0,I.jsx)(k,{fontSize:`sm`,color:o,fontWeight:`500`,children:Sce(e.status)})]}),(0,I.jsx)(A,{flex:1,overflow:`hidden`,children:(0,I.jsxs)(k,{fontSize:`sm`,color:`gray.700`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,overflow:`hidden`,children:[xce(e),e.reason&&e.status!==`apply`&&(0,I.jsxs)(k,{as:`span`,fontSize:`xs`,color:`gray.400`,ml:2,children:[`(`,e.reason,`)`]})]})}),(0,I.jsx)(k,{fontSize:`xs`,color:`gray.400`,minWidth:`100px`,children:UV(e.migration.id,`dd.MM.yyyy HH:mm`)})]});return s?(0,I.jsxs)(ge,{open:c,onOpenChange:e=>l(e.open),children:[(0,I.jsx)(me,{asChild:!0,children:u}),(0,I.jsx)(se,{children:(0,I.jsxs)(le,{width:`auto`,children:[(0,I.jsx)(Pe,{children:(0,I.jsx)(hn,{})}),(0,I.jsx)(C,{p:3,children:(0,I.jsxs)(j,{direction:`column`,gap:2,children:[(0,I.jsx)(k,{fontSize:`sm`,children:`Exclude this migration from apply?`}),(0,I.jsxs)(j,{gap:2,justify:`flex-end`,children:[(0,I.jsx)(N,{size:`xs`,variant:`outline`,onClick:()=>l(!1),children:`Cancel`}),(0,I.jsx)(N,{size:`xs`,colorPalette:`red`,onClick:()=>{l(!1),i?.()},children:`Exclude`})]})]})})]})})]}):u}),L2=g(({diffItems:e,viewMode:t,onViewModeChange:n,onRemoveLast:r,canRemoveLast:i=!1,onVirtuosoRef:a,summary:o})=>{let s=t===T2.Table,c=(0,L.useCallback)(e=>{a?.(e)},[a]),l=(0,L.useMemo)(()=>e.map(e=>e.migration),[e]);return e.length===0?(0,I.jsx)(j,{justify:`center`,align:`center`,minHeight:`100px`,children:(0,I.jsx)(k,{color:`gray.400`,fontSize:`sm`,children:`No migrations to preview`})}):(0,I.jsxs)(M,{align:`stretch`,gap:3,children:[(0,I.jsxs)(P,{justify:`space-between`,children:[(0,I.jsxs)(P,{gap:4,children:[(0,I.jsxs)(k,{fontSize:`sm`,color:`gray.600`,children:[(0,I.jsx)(k,{as:`span`,fontWeight:`500`,color:`green.500`,children:o.toApply}),` `,`to apply`]}),o.toSkip>0&&(0,I.jsxs)(k,{fontSize:`sm`,color:`gray.400`,children:[o.toSkip,` to skip`]}),o.conflicts>0&&(0,I.jsxs)(k,{fontSize:`sm`,color:`orange.500`,children:[o.conflicts,` conflicts`]}),o.blocked>0&&(0,I.jsxs)(k,{fontSize:`sm`,color:`gray.400`,children:[o.blocked,` blocked`]})]}),(0,I.jsx)(I2,{mode:t,onChange:n})]}),s?(0,I.jsx)(A,{border:`1px solid`,borderColor:`gray.200`,borderRadius:`md`,overflow:`hidden`,height:`300px`,maxHeight:`300px`,children:(0,I.jsx)(QM,{ref:c,style:{height:`100%`},totalCount:e.length,data:e,itemContent:(t,n)=>(0,I.jsx)(Cce,{item:n,index:t,isLast:t===e.length-1,canRemove:i,onRemove:r})})}):(0,I.jsx)(A,{border:`1px solid`,borderColor:`gray.200`,borderRadius:`md`,overflow:`auto`,maxHeight:`300px`,children:(0,I.jsx)(aJ,{readonly:!0,data:l})})]})}),R2=g(({model:e})=>(0,I.jsx)(Ue,{open:e.isOpen,onOpenChange:({open:t})=>!t&&e.close(),size:`xl`,children:(0,I.jsxs)(R,{children:[(0,I.jsx)(pe,{}),(0,I.jsx)(ue,{children:(0,I.jsxs)(_n,{maxWidth:`800px`,children:[(0,I.jsx)(Ge,{children:(0,I.jsx)(qe,{children:`Apply Migrations from Branch`})}),(0,I.jsx)(be,{height:`500px`,overflow:`auto`,children:(0,I.jsx)(M,{align:`stretch`,gap:4,height:`100%`,children:e.showResult&&e.applyResultSummary?(0,I.jsx)(F2,{summary:e.applyResultSummary,failedResults:e.failedResults}):e.hasNoBranches?(0,I.jsxs)(j,{direction:`column`,align:`center`,justify:`center`,flex:1,gap:2,children:[(0,I.jsx)(k,{color:`gray.500`,children:`No other branches available`}),(0,I.jsx)(k,{fontSize:`sm`,color:`gray.400`,children:`Create a new branch to apply migrations from it`})]}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(P,{gap:4,children:[(0,I.jsxs)(j,{flexDirection:`column`,gap:2,flex:1,children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`500`,color:`gray.600`,children:`Source Branch`}),e.isLoadingBranches?(0,I.jsxs)(j,{align:`center`,gap:2,height:`40px`,children:[(0,I.jsx)(Ht,{size:`sm`}),(0,I.jsx)(k,{fontSize:`sm`,color:`gray.400`,children:`Loading branches...`})]}):(0,I.jsx)(Qe,{children:(0,I.jsxs)(Xe,{value:e.selectedBranchId??``,onChange:t=>e.setSelectedBranchId(t.target.value||null),children:[(0,I.jsx)(`option`,{value:``,children:`Select branch`}),e.branches.map(e=>(0,I.jsxs)(`option`,{value:e.id,children:[e.name,` `,e.isRoot?`(root)`:``]},e.id))]})})]}),(0,I.jsxs)(j,{flexDirection:`column`,gap:2,flex:1,children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`500`,color:`gray.600`,children:`Source Revision`}),(0,I.jsx)(Qe,{disabled:!e.selectedBranchId,children:(0,I.jsxs)(Xe,{value:e.selectedRevision,onChange:t=>e.setSelectedRevision(t.target.value),children:[(0,I.jsx)(`option`,{value:XJ,children:`Draft (working)`}),(0,I.jsx)(`option`,{value:ZJ,children:`Head (committed)`})]})})]})]}),e.selectedBranchId&&(0,I.jsxs)(j,{direction:`column`,flex:1,gap:4,children:[(0,I.jsx)(A,{height:`1px`,bg:`gray.200`}),e.isLoadingMigrations?(0,I.jsxs)(j,{justify:`center`,align:`center`,flex:1,children:[(0,I.jsx)(Ht,{}),(0,I.jsx)(k,{ml:3,color:`gray.500`,children:`Loading migrations...`})]}):e.previewItems.length===0?(0,I.jsx)(j,{justify:`center`,align:`center`,flex:1,children:(0,I.jsx)(k,{color:`gray.400`,children:`No new migrations to apply from this branch`})}):(0,I.jsxs)(I.Fragment,{children:[e.hasConflict&&(0,I.jsxs)(j,{align:`center`,gap:2,p:3,bg:`orange.50`,borderRadius:`md`,children:[(0,I.jsx)(Ve,{as:Vf,color:`orange.500`,boxSize:5}),(0,I.jsxs)(A,{children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`500`,color:`orange.700`,children:`Conflict detected`}),(0,I.jsx)(k,{fontSize:`xs`,color:`orange.600`,children:`Some migrations have conflicting timestamps.`})]})]}),(0,I.jsx)(L2,{diffItems:e.previewItems,viewMode:e.viewMode,onViewModeChange:e.setViewMode,summary:e.summary,canRemoveLast:e.canRemoveLast,onRemoveLast:e.removeLastMigration,onVirtuosoRef:e.setVirtuosoRef})]})]})]})})}),(0,I.jsxs)(w,{children:[(0,I.jsx)(N,{variant:`outline`,onClick:e.close,children:e.showResult?`Close`:`Cancel`}),!e.showResult&&(0,I.jsxs)(N,{onClick:e.apply,disabled:!e.canApply,loading:e.isApplying,children:[`Apply `,e.migrationsToApply.length>0&&`(${e.migrationsToApply.length})`]})]}),(0,I.jsx)(Ie,{})]})})]})})),z2=g(({model:e})=>(0,I.jsx)(Ue,{open:e.isOpen,onOpenChange:({open:t})=>!t&&e.close(),size:`xl`,children:(0,I.jsxs)(R,{children:[(0,I.jsx)(pe,{}),(0,I.jsx)(ue,{children:(0,I.jsxs)(_n,{maxWidth:`800px`,children:[(0,I.jsx)(Ge,{children:(0,I.jsx)(qe,{children:`Apply Migrations from JSON`})}),(0,I.jsx)(be,{children:(0,I.jsx)(M,{align:`stretch`,gap:4,children:e.showResult&&e.applyResultSummary?(0,I.jsx)(F2,{summary:e.applyResultSummary,failedResults:e.failedResults}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(A,{children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`500`,color:`gray.600`,mb:2,children:`Paste migrations JSON`}),(0,I.jsx)(A,{border:`1px solid`,borderColor:`gray.200`,borderRadius:`md`,overflow:`hidden`,children:(0,I.jsx)(DO,{value:e.jsonInput,onChange:e.setJsonInput,extensions:[G.lineWrapping,nk()],theme:pC,placeholder:`[{ "changeType": "init", "tableId": "posts", ... }]`,minHeight:`150px`,maxHeight:`200px`,basicSetup:{lineNumbers:!0,foldGutter:!0}})}),e.parseError&&(0,I.jsx)(k,{fontSize:`sm`,color:`red.500`,mt:1,children:e.parseError})]}),e.previewItems.length>0&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(A,{height:`1px`,bg:`gray.200`}),e.hasConflict&&(0,I.jsxs)(j,{align:`center`,gap:2,p:3,bg:`orange.50`,borderRadius:`md`,children:[(0,I.jsx)(Ve,{as:Vf,color:`orange.500`,boxSize:5}),(0,I.jsxs)(A,{children:[(0,I.jsx)(k,{fontSize:`sm`,fontWeight:`500`,color:`orange.700`,children:`Conflict detected`}),(0,I.jsx)(k,{fontSize:`xs`,color:`orange.600`,children:`Remove conflicting migrations from the end to proceed.`})]})]}),(0,I.jsx)(L2,{diffItems:e.previewItems,viewMode:e.viewMode,onViewModeChange:e.setViewMode,onRemoveLast:e.removeLastMigration,canRemoveLast:e.canRemoveLast,onVirtuosoRef:e.setVirtuosoRef,summary:e.summary})]})]})})}),(0,I.jsxs)(w,{children:[(0,I.jsx)(N,{variant:`outline`,onClick:e.close,children:e.showResult?`Close`:`Cancel`}),!e.showResult&&(0,I.jsxs)(N,{onClick:e.apply,disabled:!e.canApply,loading:e.isApplying,children:[`Apply `,e.migrationsToApply.length>0&&`(${e.migrationsToApply.length})`]})]}),(0,I.jsx)(Ie,{})]})})]})})),B2=g(({totalCount:e,branchName:t,viewMode:n,canApplyMigrations:r,onViewModeChange:i,onApplyFromJson:a,onApplyFromBranch:o})=>(0,I.jsxs)(A,{mb:6,position:`sticky`,top:0,bg:`white`,zIndex:10,pt:4,pb:2,children:[(0,I.jsxs)(P,{justify:`space-between`,align:`flex-start`,mb:1,children:[(0,I.jsxs)(k,{fontSize:`20px`,fontWeight:`600`,color:`newGray.500`,children:[`Migrations for `,t,` (`,e,` operations)`]}),r&&(0,I.jsxs)(en,{children:[(0,I.jsx)(Lt,{asChild:!0,children:(0,I.jsxs)(N,{size:`xs`,variant:`ghost`,color:`newGray.400`,children:[`Apply`,(0,I.jsx)(mf,{})]})}),(0,I.jsx)(R,{children:(0,I.jsx)(Ot,{children:(0,I.jsxs)(v,{children:[(0,I.jsx)(gt,{value:`json`,onClick:a,children:`From JSON`}),(0,I.jsx)(gt,{value:`branch`,onClick:o,children:`From Branch`})]})})})]})]}),(0,I.jsxs)(P,{gap:1,mb:4,children:[(0,I.jsx)(k,{fontSize:`xs`,color:`newGray.400`,children:`You can use Apply to merge schemas from other branches or import from external sources.`}),(0,I.jsxs)(mn,{openDelay:200,closeDelay:100,children:[(0,I.jsx)(ct,{children:(0,I.jsx)(Ve,{as:Ef,color:`newGray.400`,cursor:`help`})}),(0,I.jsx)(R,{children:(0,I.jsx)(on,{children:(0,I.jsxs)(nt,{maxWidth:`400px`,p:3,children:[(0,I.jsx)(Tt,{children:(0,I.jsx)(St,{})}),(0,I.jsxs)(M,{align:`start`,gap:3,children:[(0,I.jsx)(k,{fontSize:`xs`,color:`newGray.600`,fontWeight:`600`,children:`About Migrations`}),(0,I.jsx)(k,{fontSize:`xs`,color:`newGray.600`,children:`Schema changes are tracked as migrations that can be applied to synchronize schemas across branches and environments.`}),(0,I.jsxs)(M,{align:`start`,gap:1,children:[(0,I.jsx)(k,{fontSize:`xs`,color:`newGray.500`,fontWeight:`500`,children:`Recommended workflows:`}),(0,I.jsx)(k,{fontSize:`xs`,color:`newGray.500`,children:`• Edit schemas in feature branches, then apply to default`}),(0,I.jsx)(k,{fontSize:`xs`,color:`newGray.500`,children:`• Use default branch as read-only for schema, merge from others`}),(0,I.jsx)(k,{fontSize:`xs`,color:`newGray.500`,children:`• Export/import JSON between projects or instances`})]}),(0,I.jsx)(A,{p:2,bg:`orange.50`,borderRadius:`sm`,children:(0,I.jsx)(k,{fontSize:`xs`,color:`orange.600`,children:`Conflict resolution is not yet supported. Avoid parallel schema changes in multiple branches.`})}),(0,I.jsxs)(j,{gap:1,align:`center`,children:[(0,I.jsx)(k,{fontSize:`xs`,color:`newGray.400`,children:`For CI/CD automation, use`}),(0,I.jsx)(mt,{href:`https://github.com/revisium/revisium-cli`,target:`_blank`,rel:`noopener noreferrer`,fontSize:`xs`,color:`blue.500`,children:`revisium-cli`})]})]})]})})})]})]}),(0,I.jsx)(P,{justify:`flex-end`,children:(0,I.jsx)(I2,{mode:n,onChange:i})})]})),V2=(0,L.createContext)(null),wce=g(({index:e})=>{let t=(0,L.useContext)(V2);if(!t)return null;let n=t.items[e];return n?(0,I.jsxs)(ge,{lazyMount:!0,unmountOnExit:!0,positioning:{placement:`bottom-start`},open:n.isPopoverOpen,onOpenChange:({open:e})=>n.setPopoverOpen(e),children:[(0,I.jsx)(me,{asChild:!0,children:(0,I.jsx)(A,{py:3,px:4,cursor:`pointer`,borderBottom:`1px solid`,borderColor:`gray.50`,_hover:{bg:`gray.50`,"& .migration-icon":{color:`newGray.400`}},"data-testid":`migration-item-${e}`,children:(0,I.jsxs)(j,{align:`center`,gap:2,children:[(0,I.jsx)(Ve,{as:n.descriptionIcon,className:`migration-icon`,color:`newGray.300`,boxSize:4,flexShrink:0}),(0,I.jsx)(k,{fontSize:`sm`,color:`newGray.500`,lineHeight:`1.4`,flex:1,minWidth:0,children:n.descriptionSegments.map((e,t)=>e.highlight?(0,I.jsx)(A,{as:`span`,px:`1`,bg:`gray.100`,borderRadius:`sm`,whiteSpace:`nowrap`,children:e.text},t):e.gray?(0,I.jsx)(A,{as:`span`,color:`newGray.300`,children:e.text},t):(0,I.jsx)(`span`,{children:e.text},t))}),(0,I.jsx)(k,{fontSize:`xs`,color:`newGray.300`,flexShrink:0,whiteSpace:`nowrap`,children:n.relativeTime})]})})}),(0,I.jsx)(R,{children:(0,I.jsx)(se,{children:(0,I.jsxs)(le,{width:`800px`,maxHeight:`350px`,overflow:`auto`,children:[(0,I.jsx)(We,{}),(0,I.jsx)(C,{children:(0,I.jsx)(aJ,{readonly:!0,data:n.fullPatchData})})]})})})]}):null}),Tce=g(({items:e})=>{let t=(0,L.useMemo)(()=>({items:e}),[e]);return e.length===0?(0,I.jsx)(j,{justify:`center`,align:`center`,minHeight:`200px`,children:(0,I.jsx)(k,{color:`gray.400`,children:`No operations found`})}):(0,I.jsx)(V2.Provider,{value:t,children:(0,I.jsx)(QM,{useWindowScroll:!0,totalCount:e.length,defaultItemHeight:52,increaseViewportBy:1040,itemContent:e=>(0,I.jsx)(wce,{index:e})})})}),Ece=g(()=>{let e=CB(P2);return e.showLoading?(0,I.jsx)(j,{justify:`center`,align:`center`,height:`200px`,children:(0,I.jsx)(Ht,{})}):e.showError?(0,I.jsx)(j,{justify:`center`,align:`center`,height:`200px`,children:(0,I.jsx)(k,{color:`red.500`,children:`Error loading migrations`})}):e.showEmpty?(0,I.jsxs)(A,{mb:`4rem`,children:[(0,I.jsx)(B2,{totalCount:0,branchName:e.branchName,viewMode:e.viewMode,canApplyMigrations:e.canApplyMigrations,onViewModeChange:e.setViewMode,onApplyFromJson:e.openApplyDialog,onApplyFromBranch:e.openApplyFromBranchDialog}),(0,I.jsx)(j,{justify:`center`,align:`center`,height:`200px`,children:(0,I.jsx)(k,{color:`newGray.400`,children:`No migrations found`})}),e.applyDialog&&(0,I.jsx)(z2,{model:e.applyDialog}),e.applyFromBranchDialog&&(0,I.jsx)(R2,{model:e.applyFromBranchDialog})]}):e.showList?(0,I.jsxs)(A,{mb:`4rem`,children:[(0,I.jsx)(B2,{totalCount:e.totalCount,branchName:e.branchName,viewMode:e.viewMode,canApplyMigrations:e.canApplyMigrations,onViewModeChange:e.setViewMode,onApplyFromJson:e.openApplyDialog,onApplyFromBranch:e.openApplyFromBranchDialog}),e.isTableMode?(0,I.jsx)(Tce,{items:e.items}):(0,I.jsx)(aJ,{readonly:!0,data:e.data}),e.applyDialog&&(0,I.jsx)(z2,{model:e.applyDialog}),e.applyFromBranchDialog&&(0,I.jsx)(R2,{model:e.applyFromBranchDialog})]}):null});function H2(e){if(typeof e==`string`||typeof e==`number`)return``+e;let t=``;if(Array.isArray(e))for(let n=0,r;n<e.length;n++)(r=H2(e[n]))!==``&&(t+=(t&&` `)+r);else for(let n in e)e[n]&&(t+=(t&&` `)+n);return t}var Dce={value:()=>{}};function U2(){for(var e=0,t=arguments.length,n={},r;e<t;++e){if(!(r=arguments[e]+``)||r in n||/[\s.]/.test(r))throw Error(`illegal type: `+r);n[r]=[]}return new W2(n)}function W2(e){this._=e}function Oce(e,t){return e.trim().split(/^|\s+/).map(function(e){var n=``,r=e.indexOf(`.`);if(r>=0&&(n=e.slice(r+1),e=e.slice(0,r)),e&&!t.hasOwnProperty(e))throw Error(`unknown type: `+e);return{type:e,name:n}})}W2.prototype=U2.prototype={constructor:W2,on:function(e,t){var n=this._,r=Oce(e+``,n),i,a=-1,o=r.length;if(arguments.length<2){for(;++a<o;)if((i=(e=r[a]).type)&&(i=kce(n[i],e.name)))return i;return}if(t!=null&&typeof t!=`function`)throw Error(`invalid callback: `+t);for(;++a<o;)if(i=(e=r[a]).type)n[i]=G2(n[i],e.name,t);else if(t==null)for(i in n)n[i]=G2(n[i],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new W2(e)},call:function(e,t){if((i=arguments.length-2)>0)for(var n=Array(i),r=0,i,a;r<i;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(e))throw Error(`unknown type: `+e);for(a=this._[e],r=0,i=a.length;r<i;++r)a[r].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw Error(`unknown type: `+e);for(var r=this._[e],i=0,a=r.length;i<a;++i)r[i].value.apply(t,n)}};function kce(e,t){for(var n=0,r=e.length,i;n<r;++n)if((i=e[n]).name===t)return i.value}function G2(e,t,n){for(var r=0,i=e.length;r<i;++r)if(e[r].name===t){e[r]=Dce,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var K2={svg:`http://www.w3.org/2000/svg`,xhtml:`http://www.w3.org/1999/xhtml`,xlink:`http://www.w3.org/1999/xlink`,xml:`http://www.w3.org/XML/1998/namespace`,xmlns:`http://www.w3.org/2000/xmlns/`};function q2(e){var t=e+=``,n=t.indexOf(`:`);return n>=0&&(t=e.slice(0,n))!==`xmlns`&&(e=e.slice(n+1)),K2.hasOwnProperty(t)?{space:K2[t],local:e}:e}function Ace(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===`http://www.w3.org/1999/xhtml`&&t.documentElement.namespaceURI===`http://www.w3.org/1999/xhtml`?t.createElement(e):t.createElementNS(n,e)}}function jce(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function J2(e){var t=q2(e);return(t.local?jce:Ace)(t)}function Mce(){}function Y2(e){return e==null?Mce:function(){return this.querySelector(e)}}function Nce(e){typeof e!=`function`&&(e=Y2(e));for(var t=this._groups,n=t.length,r=Array(n),i=0;i<n;++i)for(var a=t[i],o=a.length,s=r[i]=Array(o),c,l,u=0;u<o;++u)(c=a[u])&&(l=e.call(c,c.__data__,u,a))&&(`__data__`in c&&(l.__data__=c.__data__),s[u]=l);return new u4(r,this._parents)}function Pce(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function Fce(){return[]}function X2(e){return e==null?Fce:function(){return this.querySelectorAll(e)}}function Ice(e){return function(){return Pce(e.apply(this,arguments))}}function Lce(e){e=typeof e==`function`?Ice(e):X2(e);for(var t=this._groups,n=t.length,r=[],i=[],a=0;a<n;++a)for(var o=t[a],s=o.length,c,l=0;l<s;++l)(c=o[l])&&(r.push(e.call(c,c.__data__,l,o)),i.push(c));return new u4(r,i)}function Z2(e){return function(){return this.matches(e)}}function Q2(e){return function(t){return t.matches(e)}}var Rce=Array.prototype.find;function zce(e){return function(){return Rce.call(this.children,e)}}function Bce(){return this.firstElementChild}function Vce(e){return this.select(e==null?Bce:zce(typeof e==`function`?e:Q2(e)))}var Hce=Array.prototype.filter;function Uce(){return Array.from(this.children)}function Wce(e){return function(){return Hce.call(this.children,e)}}function Gce(e){return this.selectAll(e==null?Uce:Wce(typeof e==`function`?e:Q2(e)))}function Kce(e){typeof e!=`function`&&(e=Z2(e));for(var t=this._groups,n=t.length,r=Array(n),i=0;i<n;++i)for(var a=t[i],o=a.length,s=r[i]=[],c,l=0;l<o;++l)(c=a[l])&&e.call(c,c.__data__,l,a)&&s.push(c);return new u4(r,this._parents)}function $2(e){return Array(e.length)}function qce(){return new u4(this._enter||this._groups.map($2),this._parents)}function e4(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}e4.prototype={constructor:e4,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function Jce(e){return function(){return e}}function Yce(e,t,n,r,i,a){for(var o=0,s,c=t.length,l=a.length;o<l;++o)(s=t[o])?(s.__data__=a[o],r[o]=s):n[o]=new e4(e,a[o]);for(;o<c;++o)(s=t[o])&&(i[o]=s)}function Xce(e,t,n,r,i,a,o){var s,c,l=new Map,u=t.length,d=a.length,f=Array(u),p;for(s=0;s<u;++s)(c=t[s])&&(f[s]=p=o.call(c,c.__data__,s,t)+``,l.has(p)?i[s]=c:l.set(p,c));for(s=0;s<d;++s)p=o.call(e,a[s],s,a)+``,(c=l.get(p))?(r[s]=c,c.__data__=a[s],l.delete(p)):n[s]=new e4(e,a[s]);for(s=0;s<u;++s)(c=t[s])&&l.get(f[s])===c&&(i[s]=c)}function Zce(e){return e.__data__}function Qce(e,t){if(!arguments.length)return Array.from(this,Zce);var n=t?Xce:Yce,r=this._parents,i=this._groups;typeof e!=`function`&&(e=Jce(e));for(var a=i.length,o=Array(a),s=Array(a),c=Array(a),l=0;l<a;++l){var u=r[l],d=i[l],f=d.length,p=$ce(e.call(u,u&&u.__data__,l,r)),m=p.length,h=s[l]=Array(m),g=o[l]=Array(m);n(u,d,h,g,c[l]=Array(f),p,t);for(var _=0,v=0,y,b;_<m;++_)if(y=h[_]){for(_>=v&&(v=_+1);!(b=g[v])&&++v<m;);y._next=b||null}}return o=new u4(o,r),o._enter=s,o._exit=c,o}function $ce(e){return typeof e==`object`&&`length`in e?e:Array.from(e)}function ele(){return new u4(this._exit||this._groups.map($2),this._parents)}function tle(e,t,n){var r=this.enter(),i=this,a=this.exit();return typeof e==`function`?(r=e(r),r&&=r.selection()):r=r.append(e+``),t!=null&&(i=t(i),i&&=i.selection()),n==null?a.remove():n(a),r&&i?r.merge(i).order():i}function nle(e){for(var t=e.selection?e.selection():e,n=this._groups,r=t._groups,i=n.length,a=r.length,o=Math.min(i,a),s=Array(i),c=0;c<o;++c)for(var l=n[c],u=r[c],d=l.length,f=s[c]=Array(d),p,m=0;m<d;++m)(p=l[m]||u[m])&&(f[m]=p);for(;c<i;++c)s[c]=n[c];return new u4(s,this._parents)}function rle(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var r=e[t],i=r.length-1,a=r[i],o;--i>=0;)(o=r[i])&&(a&&o.compareDocumentPosition(a)^4&&a.parentNode.insertBefore(o,a),a=o);return this}function ile(e){e||=ale;function t(t,n){return t&&n?e(t.__data__,n.__data__):!t-!n}for(var n=this._groups,r=n.length,i=Array(r),a=0;a<r;++a){for(var o=n[a],s=o.length,c=i[a]=Array(s),l,u=0;u<s;++u)(l=o[u])&&(c[u]=l);c.sort(t)}return new u4(i,this._parents).order()}function ale(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function ole(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function sle(){return Array.from(this)}function cle(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],i=0,a=r.length;i<a;++i){var o=r[i];if(o)return o}return null}function lle(){let e=0;for(let t of this)++e;return e}function ule(){return!this.node()}function dle(e){for(var t=this._groups,n=0,r=t.length;n<r;++n)for(var i=t[n],a=0,o=i.length,s;a<o;++a)(s=i[a])&&e.call(s,s.__data__,a,i);return this}function fle(e){return function(){this.removeAttribute(e)}}function ple(e){return function(){this.removeAttributeNS(e.space,e.local)}}function mle(e,t){return function(){this.setAttribute(e,t)}}function hle(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function gle(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function _le(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function vle(e,t){var n=q2(e);if(arguments.length<2){var r=this.node();return n.local?r.getAttributeNS(n.space,n.local):r.getAttribute(n)}return this.each((t==null?n.local?ple:fle:typeof t==`function`?n.local?_le:gle:n.local?hle:mle)(n,t))}function t4(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function yle(e){return function(){this.style.removeProperty(e)}}function ble(e,t,n){return function(){this.style.setProperty(e,t,n)}}function xle(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function Sle(e,t,n){return arguments.length>1?this.each((t==null?yle:typeof t==`function`?xle:ble)(e,t,n??``)):n4(this.node(),e)}function n4(e,t){return e.style.getPropertyValue(t)||t4(e).getComputedStyle(e,null).getPropertyValue(t)}function Cle(e){return function(){delete this[e]}}function wle(e,t){return function(){this[e]=t}}function Tle(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function Ele(e,t){return arguments.length>1?this.each((t==null?Cle:typeof t==`function`?Tle:wle)(e,t)):this.node()[e]}function r4(e){return e.trim().split(/^|\s+/)}function i4(e){return e.classList||new a4(e)}function a4(e){this._node=e,this._names=r4(e.getAttribute(`class`)||``)}a4.prototype={add:function(e){this._names.indexOf(e)<0&&(this._names.push(e),this._node.setAttribute(`class`,this._names.join(` `)))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute(`class`,this._names.join(` `)))},contains:function(e){return this._names.indexOf(e)>=0}};function o4(e,t){for(var n=i4(e),r=-1,i=t.length;++r<i;)n.add(t[r])}function s4(e,t){for(var n=i4(e),r=-1,i=t.length;++r<i;)n.remove(t[r])}function Dle(e){return function(){o4(this,e)}}function Ole(e){return function(){s4(this,e)}}function kle(e,t){return function(){(t.apply(this,arguments)?o4:s4)(this,e)}}function Ale(e,t){var n=r4(e+``);if(arguments.length<2){for(var r=i4(this.node()),i=-1,a=n.length;++i<a;)if(!r.contains(n[i]))return!1;return!0}return this.each((typeof t==`function`?kle:t?Dle:Ole)(n,t))}function jle(){this.textContent=``}function Mle(e){return function(){this.textContent=e}}function Nle(e){return function(){this.textContent=e.apply(this,arguments)??``}}function Ple(e){return arguments.length?this.each(e==null?jle:(typeof e==`function`?Nle:Mle)(e)):this.node().textContent}function Fle(){this.innerHTML=``}function Ile(e){return function(){this.innerHTML=e}}function Lle(e){return function(){this.innerHTML=e.apply(this,arguments)??``}}function Rle(e){return arguments.length?this.each(e==null?Fle:(typeof e==`function`?Lle:Ile)(e)):this.node().innerHTML}function zle(){this.nextSibling&&this.parentNode.appendChild(this)}function Ble(){return this.each(zle)}function Vle(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Hle(){return this.each(Vle)}function Ule(e){var t=typeof e==`function`?e:J2(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function Wle(){return null}function Gle(e,t){var n=typeof e==`function`?e:J2(e),r=t==null?Wle:typeof t==`function`?t:Y2(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function Kle(){var e=this.parentNode;e&&e.removeChild(this)}function qle(){return this.each(Kle)}function Jle(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Yle(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Xle(e){return this.select(e?Yle:Jle)}function Zle(e){return arguments.length?this.property(`__data__`,e):this.node().__data__}function Qle(e){return function(t){e.call(this,t,this.__data__)}}function $le(e){return e.trim().split(/^|\s+/).map(function(e){var t=``,n=e.indexOf(`.`);return n>=0&&(t=e.slice(n+1),e=e.slice(0,n)),{type:e,name:t}})}function eue(e){return function(){var t=this.__on;if(t){for(var n=0,r=-1,i=t.length,a;n<i;++n)a=t[n],(!e.type||a.type===e.type)&&a.name===e.name?this.removeEventListener(a.type,a.listener,a.options):t[++r]=a;++r?t.length=r:delete this.__on}}}function tue(e,t,n){return function(){var r=this.__on,i,a=Qle(t);if(r){for(var o=0,s=r.length;o<s;++o)if((i=r[o]).type===e.type&&i.name===e.name){this.removeEventListener(i.type,i.listener,i.options),this.addEventListener(i.type,i.listener=a,i.options=n),i.value=t;return}}this.addEventListener(e.type,a,n),i={type:e.type,name:e.name,value:t,listener:a,options:n},r?r.push(i):this.__on=[i]}}function nue(e,t,n){var r=$le(e+``),i,a=r.length,o;if(arguments.length<2){var s=this.node().__on;if(s){for(var c=0,l=s.length,u;c<l;++c)for(i=0,u=s[c];i<a;++i)if((o=r[i]).type===u.type&&o.name===u.name)return u.value}return}for(s=t?tue:eue,i=0;i<a;++i)this.each(s(r[i],t,n));return this}function c4(e,t,n){var r=t4(e),i=r.CustomEvent;typeof i==`function`?i=new i(t,n):(i=r.document.createEvent(`Event`),n?(i.initEvent(t,n.bubbles,n.cancelable),i.detail=n.detail):i.initEvent(t,!1,!1)),e.dispatchEvent(i)}function rue(e,t){return function(){return c4(this,e,t)}}function iue(e,t){return function(){return c4(this,e,t.apply(this,arguments))}}function aue(e,t){return this.each((typeof t==`function`?iue:rue)(e,t))}function*oue(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],i=0,a=r.length,o;i<a;++i)(o=r[i])&&(yield o)}var l4=[null];function u4(e,t){this._groups=e,this._parents=t}function d4(){return new u4([[document.documentElement]],l4)}function sue(){return this}u4.prototype=d4.prototype={constructor:u4,select:Nce,selectAll:Lce,selectChild:Vce,selectChildren:Gce,filter:Kce,data:Qce,enter:qce,exit:ele,join:tle,merge:nle,selection:sue,order:rle,sort:ile,call:ole,nodes:sle,node:cle,size:lle,empty:ule,each:dle,attr:vle,style:Sle,property:Ele,classed:Ale,text:Ple,html:Rle,raise:Ble,lower:Hle,append:Ule,insert:Gle,remove:qle,clone:Xle,datum:Zle,on:nue,dispatch:aue,[Symbol.iterator]:oue};function f4(e){return typeof e==`string`?new u4([[document.querySelector(e)]],[document.documentElement]):new u4([[e]],l4)}function cue(e){let t;for(;t=e.sourceEvent;)e=t;return e}function p4(e,t){if(e=cue(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var r=n.createSVGPoint();return r.x=e.clientX,r.y=e.clientY,r=r.matrixTransform(t.getScreenCTM().inverse()),[r.x,r.y]}if(t.getBoundingClientRect){var i=t.getBoundingClientRect();return[e.clientX-i.left-t.clientLeft,e.clientY-i.top-t.clientTop]}}return[e.pageX,e.pageY]}var lue={passive:!1},m4={capture:!0,passive:!1};function h4(e){e.stopImmediatePropagation()}function g4(e){e.preventDefault(),e.stopImmediatePropagation()}function _4(e){var t=e.document.documentElement,n=f4(e).on(`dragstart.drag`,g4,m4);`onselectstart`in t?n.on(`selectstart.drag`,g4,m4):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect=`none`)}function v4(e,t){var n=e.document.documentElement,r=f4(e).on(`dragstart.drag`,null);t&&(r.on(`click.drag`,g4,m4),setTimeout(function(){r.on(`click.drag`,null)},0)),`onselectstart`in n?r.on(`selectstart.drag`,null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}var y4=e=>()=>e;function b4(e,{sourceEvent:t,subject:n,target:r,identifier:i,active:a,x:o,y:s,dx:c,dy:l,dispatch:u}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:i,enumerable:!0,configurable:!0},active:{value:a,enumerable:!0,configurable:!0},x:{value:o,enumerable:!0,configurable:!0},y:{value:s,enumerable:!0,configurable:!0},dx:{value:c,enumerable:!0,configurable:!0},dy:{value:l,enumerable:!0,configurable:!0},_:{value:u}})}b4.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function uue(e){return!e.ctrlKey&&!e.button}function due(){return this.parentNode}function fue(e,t){return t??{x:e.x,y:e.y}}function pue(){return navigator.maxTouchPoints||`ontouchstart`in this}function x4(){var e=uue,t=due,n=fue,r=pue,i={},a=U2(`start`,`drag`,`end`),o=0,s,c,l,u,d=0;function f(e){e.on(`mousedown.drag`,p).filter(r).on(`touchstart.drag`,g).on(`touchmove.drag`,_,lue).on(`touchend.drag touchcancel.drag`,v).style(`touch-action`,`none`).style(`-webkit-tap-highlight-color`,`rgba(0,0,0,0)`)}function p(n,r){if(!(u||!e.call(this,n,r))){var i=y(this,t.call(this,n,r),n,r,`mouse`);i&&(f4(n.view).on(`mousemove.drag`,m,m4).on(`mouseup.drag`,h,m4),_4(n.view),h4(n),l=!1,s=n.clientX,c=n.clientY,i(`start`,n))}}function m(e){if(g4(e),!l){var t=e.clientX-s,n=e.clientY-c;l=t*t+n*n>d}i.mouse(`drag`,e)}function h(e){f4(e.view).on(`mousemove.drag mouseup.drag`,null),v4(e.view,l),g4(e),i.mouse(`end`,e)}function g(n,r){if(e.call(this,n,r)){var i=n.changedTouches,a=t.call(this,n,r),o=i.length,s,c;for(s=0;s<o;++s)(c=y(this,a,n,r,i[s].identifier,i[s]))&&(h4(n),c(`start`,n,i[s]))}}function _(e){var t=e.changedTouches,n=t.length,r,a;for(r=0;r<n;++r)(a=i[t[r].identifier])&&(g4(e),a(`drag`,e,t[r]))}function v(e){var t=e.changedTouches,n=t.length,r,a;for(u&&clearTimeout(u),u=setTimeout(function(){u=null},500),r=0;r<n;++r)(a=i[t[r].identifier])&&(h4(e),a(`end`,e,t[r]))}function y(e,t,r,s,c,l){var u=a.copy(),d=p4(l||r,t),p,m,h;if((h=n.call(e,new b4(`beforestart`,{sourceEvent:r,target:f,identifier:c,active:o,x:d[0],y:d[1],dx:0,dy:0,dispatch:u}),s))!=null)return p=h.x-d[0]||0,m=h.y-d[1]||0,function n(r,a,l){var g=d,_;switch(r){case`start`:i[c]=n,_=o++;break;case`end`:delete i[c],--o;case`drag`:d=p4(l||a,t),_=o;break}u.call(r,e,new b4(r,{sourceEvent:a,subject:h,target:f,identifier:c,active:_,x:d[0]+p,y:d[1]+m,dx:d[0]-g[0],dy:d[1]-g[1],dispatch:u}),s)}}return f.filter=function(t){return arguments.length?(e=typeof t==`function`?t:y4(!!t),f):e},f.container=function(e){return arguments.length?(t=typeof e==`function`?e:y4(e),f):t},f.subject=function(e){return arguments.length?(n=typeof e==`function`?e:y4(e),f):n},f.touchable=function(e){return arguments.length?(r=typeof e==`function`?e:y4(!!e),f):r},f.on=function(){var e=a.on.apply(a,arguments);return e===a?f:e},f.clickDistance=function(e){return arguments.length?(d=(e=+e)*e,f):Math.sqrt(d)},f}function S4(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function C4(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function w4(){}var T4=.7,E4=1/T4,D4=`\\s*([+-]?\\d+)\\s*`,O4=`\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*`,k4=`\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*`,mue=/^#([0-9a-f]{3,8})$/,hue=RegExp(`^rgb\\(${D4},${D4},${D4}\\)$`),gue=RegExp(`^rgb\\(${k4},${k4},${k4}\\)$`),_ue=RegExp(`^rgba\\(${D4},${D4},${D4},${O4}\\)$`),vue=RegExp(`^rgba\\(${k4},${k4},${k4},${O4}\\)$`),yue=RegExp(`^hsl\\(${O4},${k4},${k4}\\)$`),bue=RegExp(`^hsla\\(${O4},${k4},${k4},${O4}\\)$`),A4={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};S4(w4,N4,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:j4,formatHex:j4,formatHex8:xue,formatHsl:Sue,formatRgb:M4,toString:M4});function j4(){return this.rgb().formatHex()}function xue(){return this.rgb().formatHex8()}function Sue(){return W4(this).formatHsl()}function M4(){return this.rgb().formatRgb()}function N4(e){var t,n;return e=(e+``).trim().toLowerCase(),(t=mue.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?P4(t):n===3?new L4(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?F4(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?F4(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=hue.exec(e))?new L4(t[1],t[2],t[3],1):(t=gue.exec(e))?new L4(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=_ue.exec(e))?F4(t[1],t[2],t[3],t[4]):(t=vue.exec(e))?F4(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=yue.exec(e))?U4(t[1],t[2]/100,t[3]/100,1):(t=bue.exec(e))?U4(t[1],t[2]/100,t[3]/100,t[4]):A4.hasOwnProperty(e)?P4(A4[e]):e===`transparent`?new L4(NaN,NaN,NaN,0):null}function P4(e){return new L4(e>>16&255,e>>8&255,e&255,1)}function F4(e,t,n,r){return r<=0&&(e=t=n=NaN),new L4(e,t,n,r)}function Cue(e){return e instanceof w4||(e=N4(e)),e?(e=e.rgb(),new L4(e.r,e.g,e.b,e.opacity)):new L4}function I4(e,t,n,r){return arguments.length===1?Cue(e):new L4(e,t,n,r??1)}function L4(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}S4(L4,I4,C4(w4,{brighter(e){return e=e==null?E4:E4**+e,new L4(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?T4:T4**+e,new L4(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new L4(V4(this.r),V4(this.g),V4(this.b),B4(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:R4,formatHex:R4,formatHex8:wue,formatRgb:z4,toString:z4}));function R4(){return`#${H4(this.r)}${H4(this.g)}${H4(this.b)}`}function wue(){return`#${H4(this.r)}${H4(this.g)}${H4(this.b)}${H4((isNaN(this.opacity)?1:this.opacity)*255)}`}function z4(){let e=B4(this.opacity);return`${e===1?`rgb(`:`rgba(`}${V4(this.r)}, ${V4(this.g)}, ${V4(this.b)}${e===1?`)`:`, ${e})`}`}function B4(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function V4(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function H4(e){return e=V4(e),(e<16?`0`:``)+e.toString(16)}function U4(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new G4(e,t,n,r)}function W4(e){if(e instanceof G4)return new G4(e.h,e.s,e.l,e.opacity);if(e instanceof w4||(e=N4(e)),!e)return new G4;if(e instanceof G4)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,i=Math.min(t,n,r),a=Math.max(t,n,r),o=NaN,s=a-i,c=(a+i)/2;return s?(o=t===a?(n-r)/s+(n<r)*6:n===a?(r-t)/s+2:(t-n)/s+4,s/=c<.5?a+i:2-a-i,o*=60):s=c>0&&c<1?0:o,new G4(o,s,c,e.opacity)}function Tue(e,t,n,r){return arguments.length===1?W4(e):new G4(e,t,n,r??1)}function G4(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}S4(G4,Tue,C4(w4,{brighter(e){return e=e==null?E4:E4**+e,new G4(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?T4:T4**+e,new G4(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,i=2*n-r;return new L4(J4(e>=240?e-240:e+120,i,r),J4(e,i,r),J4(e<120?e+240:e-120,i,r),this.opacity)},clamp(){return new G4(K4(this.h),q4(this.s),q4(this.l),B4(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){let e=B4(this.opacity);return`${e===1?`hsl(`:`hsla(`}${K4(this.h)}, ${q4(this.s)*100}%, ${q4(this.l)*100}%${e===1?`)`:`, ${e})`}`}}));function K4(e){return e=(e||0)%360,e<0?e+360:e}function q4(e){return Math.max(0,Math.min(1,e||0))}function J4(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}var Y4=e=>()=>e;function Eue(e,t){return function(n){return e+n*t}}function Due(e,t,n){return e**=+n,t=t**+n-e,n=1/n,function(r){return(e+r*t)**+n}}function Oue(e){return(e=+e)==1?X4:function(t,n){return n-t?Due(t,n,e):Y4(isNaN(t)?n:t)}}function X4(e,t){var n=t-e;return n?Eue(e,n):Y4(isNaN(e)?t:e)}var Z4=(function e(t){var n=Oue(t);function r(e,t){var r=n((e=I4(e)).r,(t=I4(t)).r),i=n(e.g,t.g),a=n(e.b,t.b),o=X4(e.opacity,t.opacity);return function(t){return e.r=r(t),e.g=i(t),e.b=a(t),e.opacity=o(t),e+``}}return r.gamma=e,r})(1);function kue(e,t){t||=[];var n=e?Math.min(t.length,e.length):0,r=t.slice(),i;return function(a){for(i=0;i<n;++i)r[i]=e[i]*(1-a)+t[i]*a;return r}}function Aue(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function jue(e,t){var n=t?t.length:0,r=e?Math.min(n,e.length):0,i=Array(r),a=Array(n),o;for(o=0;o<r;++o)i[o]=n3(e[o],t[o]);for(;o<n;++o)a[o]=t[o];return function(e){for(o=0;o<r;++o)a[o]=i[o](e);return a}}function Mue(e,t){var n=new Date;return e=+e,t=+t,function(r){return n.setTime(e*(1-r)+t*r),n}}function Q4(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function Nue(e,t){var n={},r={},i;for(i in(typeof e!=`object`||!e)&&(e={}),(typeof t!=`object`||!t)&&(t={}),t)i in e?n[i]=n3(e[i],t[i]):r[i]=t[i];return function(e){for(i in n)r[i]=n[i](e);return r}}var $4=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,e3=new RegExp($4.source,`g`);function Pue(e){return function(){return e}}function Fue(e){return function(t){return e(t)+``}}function t3(e,t){var n=$4.lastIndex=e3.lastIndex=0,r,i,a,o=-1,s=[],c=[];for(e+=``,t+=``;(r=$4.exec(e))&&(i=e3.exec(t));)(a=i.index)>n&&(a=t.slice(n,a),s[o]?s[o]+=a:s[++o]=a),(r=r[0])===(i=i[0])?s[o]?s[o]+=i:s[++o]=i:(s[++o]=null,c.push({i:o,x:Q4(r,i)})),n=e3.lastIndex;return n<t.length&&(a=t.slice(n),s[o]?s[o]+=a:s[++o]=a),s.length<2?c[0]?Fue(c[0].x):Pue(t):(t=c.length,function(e){for(var n=0,r;n<t;++n)s[(r=c[n]).i]=r.x(e);return s.join(``)})}function n3(e,t){var n=typeof t,r;return t==null||n===`boolean`?Y4(t):(n===`number`?Q4:n===`string`?(r=N4(t))?(t=r,Z4):t3:t instanceof N4?Z4:t instanceof Date?Mue:Aue(t)?kue:Array.isArray(t)?jue:typeof t.valueOf!=`function`&&typeof t.toString!=`function`||isNaN(t)?Nue:Q4)(e,t)}var r3=180/Math.PI,i3={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function a3(e,t,n,r,i,a){var o,s,c;return(o=Math.sqrt(e*e+t*t))&&(e/=o,t/=o),(c=e*n+t*r)&&(n-=e*c,r-=t*c),(s=Math.sqrt(n*n+r*r))&&(n/=s,r/=s,c/=s),e*r<t*n&&(e=-e,t=-t,c=-c,o=-o),{translateX:i,translateY:a,rotate:Math.atan2(t,e)*r3,skewX:Math.atan(c)*r3,scaleX:o,scaleY:s}}var o3;function Iue(e){let t=new(typeof DOMMatrix==`function`?DOMMatrix:WebKitCSSMatrix)(e+``);return t.isIdentity?i3:a3(t.a,t.b,t.c,t.d,t.e,t.f)}function Lue(e){return e==null||(o3||=document.createElementNS(`http://www.w3.org/2000/svg`,`g`),o3.setAttribute(`transform`,e),!(e=o3.transform.baseVal.consolidate()))?i3:(e=e.matrix,a3(e.a,e.b,e.c,e.d,e.e,e.f))}function s3(e,t,n,r){function i(e){return e.length?e.pop()+` `:``}function a(e,r,i,a,o,s){if(e!==i||r!==a){var c=o.push(`translate(`,null,t,null,n);s.push({i:c-4,x:Q4(e,i)},{i:c-2,x:Q4(r,a)})}else (i||a)&&o.push(`translate(`+i+t+a+n)}function o(e,t,n,a){e===t?t&&n.push(i(n)+`rotate(`+t+r):(e-t>180?t+=360:t-e>180&&(e+=360),a.push({i:n.push(i(n)+`rotate(`,null,r)-2,x:Q4(e,t)}))}function s(e,t,n,a){e===t?t&&n.push(i(n)+`skewX(`+t+r):a.push({i:n.push(i(n)+`skewX(`,null,r)-2,x:Q4(e,t)})}function c(e,t,n,r,a,o){if(e!==n||t!==r){var s=a.push(i(a)+`scale(`,null,`,`,null,`)`);o.push({i:s-4,x:Q4(e,n)},{i:s-2,x:Q4(t,r)})}else (n!==1||r!==1)&&a.push(i(a)+`scale(`+n+`,`+r+`)`)}return function(t,n){var r=[],i=[];return t=e(t),n=e(n),a(t.translateX,t.translateY,n.translateX,n.translateY,r,i),o(t.rotate,n.rotate,r,i),s(t.skewX,n.skewX,r,i),c(t.scaleX,t.scaleY,n.scaleX,n.scaleY,r,i),t=n=null,function(e){for(var t=-1,n=i.length,a;++t<n;)r[(a=i[t]).i]=a.x(e);return r.join(``)}}}var Rue=s3(Iue,`px, `,`px)`,`deg)`),zue=s3(Lue,`, `,`)`,`)`),Bue=1e-12;function c3(e){return((e=Math.exp(e))+1/e)/2}function Vue(e){return((e=Math.exp(e))-1/e)/2}function Hue(e){return((e=Math.exp(2*e))-1)/(e+1)}var l3=(function e(t,n,r){function i(e,i){var a=e[0],o=e[1],s=e[2],c=i[0],l=i[1],u=i[2],d=c-a,f=l-o,p=d*d+f*f,m,h;if(p<Bue)h=Math.log(u/s)/t,m=function(e){return[a+e*d,o+e*f,s*Math.exp(t*e*h)]};else{var g=Math.sqrt(p),_=(u*u-s*s+r*p)/(2*s*n*g),v=(u*u-s*s-r*p)/(2*u*n*g),y=Math.log(Math.sqrt(_*_+1)-_);h=(Math.log(Math.sqrt(v*v+1)-v)-y)/t,m=function(e){var r=e*h,i=c3(y),c=s/(n*g)*(i*Hue(t*r+y)-Vue(y));return[a+c*d,o+c*f,s*i/c3(t*r+y)]}}return m.duration=h*1e3*t/Math.SQRT2,m}return i.rho=function(t){var n=Math.max(.001,+t),r=n*n;return e(n,r,r*r)},i})(Math.SQRT2,2,4),u3=0,d3=0,f3=0,p3=1e3,m3,h3,g3=0,_3=0,v3=0,y3=typeof performance==`object`&&performance.now?performance:Date,b3=typeof window==`object`&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function x3(){return _3||=(b3(Uue),y3.now()+v3)}function Uue(){_3=0}function S3(){this._call=this._time=this._next=null}S3.prototype=C3.prototype={constructor:S3,restart:function(e,t,n){if(typeof e!=`function`)throw TypeError(`callback is not a function`);n=(n==null?x3():+n)+(t==null?0:+t),!this._next&&h3!==this&&(h3?h3._next=this:m3=this,h3=this),this._call=e,this._time=n,T3()},stop:function(){this._call&&(this._call=null,this._time=1/0,T3())}};function C3(e,t,n){var r=new S3;return r.restart(e,t,n),r}function Wue(){x3(),++u3;for(var e=m3,t;e;)(t=_3-e._time)>=0&&e._call.call(void 0,t),e=e._next;--u3}function w3(){_3=(g3=y3.now())+v3,u3=d3=0;try{Wue()}finally{u3=0,Kue(),_3=0}}function Gue(){var e=y3.now(),t=e-g3;t>p3&&(v3-=t,g3=e)}function Kue(){for(var e,t=m3,n,r=1/0;t;)t._call?(r>t._time&&(r=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:m3=n);h3=e,T3(r)}function T3(e){u3||(d3&&=clearTimeout(d3),e-_3>24?(e<1/0&&(d3=setTimeout(w3,e-y3.now()-v3)),f3&&=clearInterval(f3)):(f3||=(g3=y3.now(),setInterval(Gue,p3)),u3=1,b3(w3)))}function E3(e,t,n){var r=new S3;return t=t==null?0:+t,r.restart(n=>{r.stop(),e(n+t)},t,n),r}var que=U2(`start`,`end`,`cancel`,`interrupt`),Jue=[];function D3(e,t,n,r,i,a){var o=e.__transition;if(!o)e.__transition={};else if(n in o)return;Yue(e,n,{name:t,index:r,group:i,on:que,tween:Jue,time:a.time,delay:a.delay,duration:a.duration,ease:a.ease,timer:null,state:0})}function O3(e,t){var n=A3(e,t);if(n.state>0)throw Error(`too late; already scheduled`);return n}function k3(e,t){var n=A3(e,t);if(n.state>3)throw Error(`too late; already running`);return n}function A3(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw Error(`transition not found`);return n}function Yue(e,t,n){var r=e.__transition,i;r[t]=n,n.timer=C3(a,0,n.time);function a(e){n.state=1,n.timer.restart(o,n.delay,n.time),n.delay<=e&&o(e-n.delay)}function o(a){var l,u,d,f;if(n.state!==1)return c();for(l in r)if(f=r[l],f.name===n.name){if(f.state===3)return E3(o);f.state===4?(f.state=6,f.timer.stop(),f.on.call(`interrupt`,e,e.__data__,f.index,f.group),delete r[l]):+l<t&&(f.state=6,f.timer.stop(),f.on.call(`cancel`,e,e.__data__,f.index,f.group),delete r[l])}if(E3(function(){n.state===3&&(n.state=4,n.timer.restart(s,n.delay,n.time),s(a))}),n.state=2,n.on.call(`start`,e,e.__data__,n.index,n.group),n.state===2){for(n.state=3,i=Array(d=n.tween.length),l=0,u=-1;l<d;++l)(f=n.tween[l].value.call(e,e.__data__,n.index,n.group))&&(i[++u]=f);i.length=u+1}}function s(t){for(var r=t<n.duration?n.ease.call(null,t/n.duration):(n.timer.restart(c),n.state=5,1),a=-1,o=i.length;++a<o;)i[a].call(e,r);n.state===5&&(n.on.call(`end`,e,e.__data__,n.index,n.group),c())}function c(){for(var i in n.state=6,n.timer.stop(),delete r[t],r)return;delete e.__transition}}function j3(e,t){var n=e.__transition,r,i,a=!0,o;if(n){for(o in t=t==null?null:t+``,n){if((r=n[o]).name!==t){a=!1;continue}i=r.state>2&&r.state<5,r.state=6,r.timer.stop(),r.on.call(i?`interrupt`:`cancel`,e,e.__data__,r.index,r.group),delete n[o]}a&&delete e.__transition}}function Xue(e){return this.each(function(){j3(this,e)})}function Zue(e,t){var n,r;return function(){var i=k3(this,e),a=i.tween;if(a!==n){r=n=a;for(var o=0,s=r.length;o<s;++o)if(r[o].name===t){r=r.slice(),r.splice(o,1);break}}i.tween=r}}function Que(e,t,n){var r,i;if(typeof n!=`function`)throw Error();return function(){var a=k3(this,e),o=a.tween;if(o!==r){i=(r=o).slice();for(var s={name:t,value:n},c=0,l=i.length;c<l;++c)if(i[c].name===t){i[c]=s;break}c===l&&i.push(s)}a.tween=i}}function $ue(e,t){var n=this._id;if(e+=``,arguments.length<2){for(var r=A3(this.node(),n).tween,i=0,a=r.length,o;i<a;++i)if((o=r[i]).name===e)return o.value;return null}return this.each((t==null?Zue:Que)(n,e,t))}function M3(e,t,n){var r=e._id;return e.each(function(){var e=k3(this,r);(e.value||={})[t]=n.apply(this,arguments)}),function(e){return A3(e,r).value[t]}}function N3(e,t){var n;return(typeof t==`number`?Q4:t instanceof N4?Z4:(n=N4(t))?(t=n,Z4):t3)(e,t)}function ede(e){return function(){this.removeAttribute(e)}}function tde(e){return function(){this.removeAttributeNS(e.space,e.local)}}function nde(e,t,n){var r,i=n+``,a;return function(){var o=this.getAttribute(e);return o===i?null:o===r?a:a=t(r=o,n)}}function rde(e,t,n){var r,i=n+``,a;return function(){var o=this.getAttributeNS(e.space,e.local);return o===i?null:o===r?a:a=t(r=o,n)}}function ide(e,t,n){var r,i,a;return function(){var o,s=n(this),c;return s==null?void this.removeAttribute(e):(o=this.getAttribute(e),c=s+``,o===c?null:o===r&&c===i?a:(i=c,a=t(r=o,s)))}}function ade(e,t,n){var r,i,a;return function(){var o,s=n(this),c;return s==null?void this.removeAttributeNS(e.space,e.local):(o=this.getAttributeNS(e.space,e.local),c=s+``,o===c?null:o===r&&c===i?a:(i=c,a=t(r=o,s)))}}function ode(e,t){var n=q2(e),r=n===`transform`?zue:N3;return this.attrTween(e,typeof t==`function`?(n.local?ade:ide)(n,r,M3(this,`attr.`+e,t)):t==null?(n.local?tde:ede)(n):(n.local?rde:nde)(n,r,t))}function sde(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function cde(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function lde(e,t){var n,r;function i(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&cde(e,i)),n}return i._value=t,i}function ude(e,t){var n,r;function i(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&sde(e,i)),n}return i._value=t,i}function dde(e,t){var n=`attr.`+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!=`function`)throw Error();var r=q2(e);return this.tween(n,(r.local?lde:ude)(r,t))}function fde(e,t){return function(){O3(this,e).delay=+t.apply(this,arguments)}}function pde(e,t){return t=+t,function(){O3(this,e).delay=t}}function mde(e){var t=this._id;return arguments.length?this.each((typeof e==`function`?fde:pde)(t,e)):A3(this.node(),t).delay}function hde(e,t){return function(){k3(this,e).duration=+t.apply(this,arguments)}}function gde(e,t){return t=+t,function(){k3(this,e).duration=t}}function _de(e){var t=this._id;return arguments.length?this.each((typeof e==`function`?hde:gde)(t,e)):A3(this.node(),t).duration}function vde(e,t){if(typeof t!=`function`)throw Error();return function(){k3(this,e).ease=t}}function yde(e){var t=this._id;return arguments.length?this.each(vde(t,e)):A3(this.node(),t).ease}function bde(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!=`function`)throw Error();k3(this,e).ease=n}}function xde(e){if(typeof e!=`function`)throw Error();return this.each(bde(this._id,e))}function Sde(e){typeof e!=`function`&&(e=Z2(e));for(var t=this._groups,n=t.length,r=Array(n),i=0;i<n;++i)for(var a=t[i],o=a.length,s=r[i]=[],c,l=0;l<o;++l)(c=a[l])&&e.call(c,c.__data__,l,a)&&s.push(c);return new F3(r,this._parents,this._name,this._id)}function Cde(e){if(e._id!==this._id)throw Error();for(var t=this._groups,n=e._groups,r=t.length,i=n.length,a=Math.min(r,i),o=Array(r),s=0;s<a;++s)for(var c=t[s],l=n[s],u=c.length,d=o[s]=Array(u),f,p=0;p<u;++p)(f=c[p]||l[p])&&(d[p]=f);for(;s<r;++s)o[s]=t[s];return new F3(o,this._parents,this._name,this._id)}function wde(e){return(e+``).trim().split(/^|\s+/).every(function(e){var t=e.indexOf(`.`);return t>=0&&(e=e.slice(0,t)),!e||e===`start`})}function Tde(e,t,n){var r,i,a=wde(t)?O3:k3;return function(){var o=a(this,e),s=o.on;s!==r&&(i=(r=s).copy()).on(t,n),o.on=i}}function Ede(e,t){var n=this._id;return arguments.length<2?A3(this.node(),n).on.on(e):this.each(Tde(n,e,t))}function Dde(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function Ode(){return this.on(`end.remove`,Dde(this._id))}function kde(e){var t=this._name,n=this._id;typeof e!=`function`&&(e=Y2(e));for(var r=this._groups,i=r.length,a=Array(i),o=0;o<i;++o)for(var s=r[o],c=s.length,l=a[o]=Array(c),u,d,f=0;f<c;++f)(u=s[f])&&(d=e.call(u,u.__data__,f,s))&&(`__data__`in u&&(d.__data__=u.__data__),l[f]=d,D3(l[f],t,n,f,l,A3(u,n)));return new F3(a,this._parents,t,n)}function Ade(e){var t=this._name,n=this._id;typeof e!=`function`&&(e=X2(e));for(var r=this._groups,i=r.length,a=[],o=[],s=0;s<i;++s)for(var c=r[s],l=c.length,u,d=0;d<l;++d)if(u=c[d]){for(var f=e.call(u,u.__data__,d,c),p,m=A3(u,n),h=0,g=f.length;h<g;++h)(p=f[h])&&D3(p,t,n,h,f,m);a.push(f),o.push(u)}return new F3(a,o,t,n)}var jde=d4.prototype.constructor;function Mde(){return new jde(this._groups,this._parents)}function Nde(e,t){var n,r,i;return function(){var a=n4(this,e),o=(this.style.removeProperty(e),n4(this,e));return a===o?null:a===n&&o===r?i:i=t(n=a,r=o)}}function P3(e){return function(){this.style.removeProperty(e)}}function Pde(e,t,n){var r,i=n+``,a;return function(){var o=n4(this,e);return o===i?null:o===r?a:a=t(r=o,n)}}function Fde(e,t,n){var r,i,a;return function(){var o=n4(this,e),s=n(this),c=s+``;return s??(c=s=(this.style.removeProperty(e),n4(this,e))),o===c?null:o===r&&c===i?a:(i=c,a=t(r=o,s))}}function Ide(e,t){var n,r,i,a=`style.`+t,o=`end.`+a,s;return function(){var c=k3(this,e),l=c.on,u=c.value[a]==null?s||=P3(t):void 0;(l!==n||i!==u)&&(r=(n=l).copy()).on(o,i=u),c.on=r}}function Lde(e,t,n){var r=(e+=``)==`transform`?Rue:N3;return t==null?this.styleTween(e,Nde(e,r)).on(`end.style.`+e,P3(e)):typeof t==`function`?this.styleTween(e,Fde(e,r,M3(this,`style.`+e,t))).each(Ide(this._id,e)):this.styleTween(e,Pde(e,r,t),n).on(`end.style.`+e,null)}function Rde(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function zde(e,t,n){var r,i;function a(){var a=t.apply(this,arguments);return a!==i&&(r=(i=a)&&Rde(e,a,n)),r}return a._value=t,a}function Bde(e,t,n){var r=`style.`+(e+=``);if(arguments.length<2)return(r=this.tween(r))&&r._value;if(t==null)return this.tween(r,null);if(typeof t!=`function`)throw Error();return this.tween(r,zde(e,t,n??``))}function Vde(e){return function(){this.textContent=e}}function Hde(e){return function(){this.textContent=e(this)??``}}function Ude(e){return this.tween(`text`,typeof e==`function`?Hde(M3(this,`text`,e)):Vde(e==null?``:e+``))}function Wde(e){return function(t){this.textContent=e.call(this,t)}}function Gde(e){var t,n;function r(){var r=e.apply(this,arguments);return r!==n&&(t=(n=r)&&Wde(r)),t}return r._value=e,r}function Kde(e){var t=`text`;if(arguments.length<1)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!=`function`)throw Error();return this.tween(t,Gde(e))}function qde(){for(var e=this._name,t=this._id,n=I3(),r=this._groups,i=r.length,a=0;a<i;++a)for(var o=r[a],s=o.length,c,l=0;l<s;++l)if(c=o[l]){var u=A3(c,t);D3(c,e,n,l,o,{time:u.time+u.delay+u.duration,delay:0,duration:u.duration,ease:u.ease})}return new F3(r,this._parents,e,n)}function Jde(){var e,t,n=this,r=n._id,i=n.size();return new Promise(function(a,o){var s={value:o},c={value:function(){--i===0&&a()}};n.each(function(){var n=k3(this,r),i=n.on;i!==e&&(t=(e=i).copy(),t._.cancel.push(s),t._.interrupt.push(s),t._.end.push(c)),n.on=t}),i===0&&a()})}var Yde=0;function F3(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function Xde(e){return d4().transition(e)}function I3(){return++Yde}var L3=d4.prototype;F3.prototype=Xde.prototype={constructor:F3,select:kde,selectAll:Ade,selectChild:L3.selectChild,selectChildren:L3.selectChildren,filter:Sde,merge:Cde,selection:Mde,transition:qde,call:L3.call,nodes:L3.nodes,node:L3.node,size:L3.size,empty:L3.empty,each:L3.each,on:Ede,attr:ode,attrTween:dde,style:Lde,styleTween:Bde,text:Ude,textTween:Kde,remove:Ode,tween:$ue,delay:mde,duration:_de,ease:yde,easeVarying:xde,end:Jde,[Symbol.iterator]:L3[Symbol.iterator]};function Zde(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var Qde={time:null,delay:0,duration:250,ease:Zde};function $de(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw Error(`transition ${t} not found`);return n}function efe(e){var t,n;e instanceof F3?(t=e._id,e=e._name):(t=I3(),(n=Qde).time=x3(),e=e==null?null:e+``);for(var r=this._groups,i=r.length,a=0;a<i;++a)for(var o=r[a],s=o.length,c,l=0;l<s;++l)(c=o[l])&&D3(c,e,t,l,o,n||$de(c,t));return new F3(r,this._parents,e,t)}d4.prototype.interrupt=Xue,d4.prototype.transition=efe;var R3=e=>()=>e;function tfe(e,{sourceEvent:t,target:n,transform:r,dispatch:i}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:i}})}function z3(e,t,n){this.k=e,this.x=t,this.y=n}z3.prototype={constructor:z3,scale:function(e){return e===1?this:new z3(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new z3(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return`translate(`+this.x+`,`+this.y+`) scale(`+this.k+`)`}};var B3=new z3(1,0,0);V3.prototype=z3.prototype;function V3(e){for(;!e.__zoom;)if(!(e=e.parentNode))return B3;return e.__zoom}function H3(e){e.stopImmediatePropagation()}function U3(e){e.preventDefault(),e.stopImmediatePropagation()}function nfe(e){return(!e.ctrlKey||e.type===`wheel`)&&!e.button}function rfe(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute(`viewBox`)?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function W3(){return this.__zoom||B3}function ife(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function afe(){return navigator.maxTouchPoints||`ontouchstart`in this}function ofe(e,t,n){var r=e.invertX(t[0][0])-n[0][0],i=e.invertX(t[1][0])-n[1][0],a=e.invertY(t[0][1])-n[0][1],o=e.invertY(t[1][1])-n[1][1];return e.translate(i>r?(r+i)/2:Math.min(0,r)||Math.max(0,i),o>a?(a+o)/2:Math.min(0,a)||Math.max(0,o))}function G3(){var e=nfe,t=rfe,n=ofe,r=ife,i=afe,a=[0,1/0],o=[[-1/0,-1/0],[1/0,1/0]],s=250,c=l3,l=U2(`start`,`zoom`,`end`),u,d,f,p=500,m=150,h=0,g=10;function _(e){e.property(`__zoom`,W3).on(`wheel.zoom`,w,{passive:!1}).on(`mousedown.zoom`,T).on(`dblclick.zoom`,E).filter(i).on(`touchstart.zoom`,D).on(`touchmove.zoom`,ee).on(`touchend.zoom touchcancel.zoom`,te).style(`-webkit-tap-highlight-color`,`rgba(0,0,0,0)`)}_.transform=function(e,t,n,r){var i=e.selection?e.selection():e;i.property(`__zoom`,W3),e===i?i.interrupt().each(function(){S(this,arguments).event(r).start().zoom(null,typeof t==`function`?t.apply(this,arguments):t).end()}):x(e,t,n,r)},_.scaleBy=function(e,t,n,r){_.scaleTo(e,function(){return this.__zoom.k*(typeof t==`function`?t.apply(this,arguments):t)},n,r)},_.scaleTo=function(e,r,i,a){_.transform(e,function(){var e=t.apply(this,arguments),a=this.__zoom,s=i==null?b(e):typeof i==`function`?i.apply(this,arguments):i,c=a.invert(s),l=typeof r==`function`?r.apply(this,arguments):r;return n(y(v(a,l),s,c),e,o)},i,a)},_.translateBy=function(e,r,i,a){_.transform(e,function(){return n(this.__zoom.translate(typeof r==`function`?r.apply(this,arguments):r,typeof i==`function`?i.apply(this,arguments):i),t.apply(this,arguments),o)},null,a)},_.translateTo=function(e,r,i,a,s){_.transform(e,function(){var e=t.apply(this,arguments),s=this.__zoom,c=a==null?b(e):typeof a==`function`?a.apply(this,arguments):a;return n(B3.translate(c[0],c[1]).scale(s.k).translate(typeof r==`function`?-r.apply(this,arguments):-r,typeof i==`function`?-i.apply(this,arguments):-i),e,o)},a,s)};function v(e,t){return t=Math.max(a[0],Math.min(a[1],t)),t===e.k?e:new z3(t,e.x,e.y)}function y(e,t,n){var r=t[0]-n[0]*e.k,i=t[1]-n[1]*e.k;return r===e.x&&i===e.y?e:new z3(e.k,r,i)}function b(e){return[(+e[0][0]+ +e[1][0])/2,(+e[0][1]+ +e[1][1])/2]}function x(e,n,r,i){e.on(`start.zoom`,function(){S(this,arguments).event(i).start()}).on(`interrupt.zoom end.zoom`,function(){S(this,arguments).event(i).end()}).tween(`zoom`,function(){var e=this,a=arguments,o=S(e,a).event(i),s=t.apply(e,a),l=r==null?b(s):typeof r==`function`?r.apply(e,a):r,u=Math.max(s[1][0]-s[0][0],s[1][1]-s[0][1]),d=e.__zoom,f=typeof n==`function`?n.apply(e,a):n,p=c(d.invert(l).concat(u/d.k),f.invert(l).concat(u/f.k));return function(e){if(e===1)e=f;else{var t=p(e),n=u/t[2];e=new z3(n,l[0]-t[0]*n,l[1]-t[1]*n)}o.zoom(null,e)}})}function S(e,t,n){return!n&&e.__zooming||new C(e,t)}function C(e,n){this.that=e,this.args=n,this.active=0,this.sourceEvent=null,this.extent=t.apply(e,n),this.taps=0}C.prototype={event:function(e){return e&&(this.sourceEvent=e),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit(`start`)),this},zoom:function(e,t){return this.mouse&&e!==`mouse`&&(this.mouse[1]=t.invert(this.mouse[0])),this.touch0&&e!==`touch`&&(this.touch0[1]=t.invert(this.touch0[0])),this.touch1&&e!==`touch`&&(this.touch1[1]=t.invert(this.touch1[0])),this.that.__zoom=t,this.emit(`zoom`),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit(`end`)),this},emit:function(e){var t=f4(this.that).datum();l.call(e,this.that,new tfe(e,{sourceEvent:this.sourceEvent,target:_,type:e,transform:this.that.__zoom,dispatch:l}),t)}};function w(t,...i){if(!e.apply(this,arguments))return;var s=S(this,i).event(t),c=this.__zoom,l=Math.max(a[0],Math.min(a[1],c.k*2**r.apply(this,arguments))),u=p4(t);if(s.wheel)(s.mouse[0][0]!==u[0]||s.mouse[0][1]!==u[1])&&(s.mouse[1]=c.invert(s.mouse[0]=u)),clearTimeout(s.wheel);else if(c.k===l)return;else s.mouse=[u,c.invert(u)],j3(this),s.start();U3(t),s.wheel=setTimeout(d,m),s.zoom(`mouse`,n(y(v(c,l),s.mouse[0],s.mouse[1]),s.extent,o));function d(){s.wheel=null,s.end()}}function T(t,...r){if(f||!e.apply(this,arguments))return;var i=t.currentTarget,a=S(this,r,!0).event(t),s=f4(t.view).on(`mousemove.zoom`,d,!0).on(`mouseup.zoom`,p,!0),c=p4(t,i),l=t.clientX,u=t.clientY;_4(t.view),H3(t),a.mouse=[c,this.__zoom.invert(c)],j3(this),a.start();function d(e){if(U3(e),!a.moved){var t=e.clientX-l,r=e.clientY-u;a.moved=t*t+r*r>h}a.event(e).zoom(`mouse`,n(y(a.that.__zoom,a.mouse[0]=p4(e,i),a.mouse[1]),a.extent,o))}function p(e){s.on(`mousemove.zoom mouseup.zoom`,null),v4(e.view,a.moved),U3(e),a.event(e).end()}}function E(r,...i){if(e.apply(this,arguments)){var a=this.__zoom,c=p4(r.changedTouches?r.changedTouches[0]:r,this),l=a.invert(c),u=a.k*(r.shiftKey?.5:2),d=n(y(v(a,u),c,l),t.apply(this,i),o);U3(r),s>0?f4(this).transition().duration(s).call(x,d,c,r):f4(this).call(_.transform,d,c,r)}}function D(t,...n){if(e.apply(this,arguments)){var r=t.touches,i=r.length,a=S(this,n,t.changedTouches.length===i).event(t),o,s,c,l;for(H3(t),s=0;s<i;++s)c=r[s],l=p4(c,this),l=[l,this.__zoom.invert(l),c.identifier],a.touch0?!a.touch1&&a.touch0[2]!==l[2]&&(a.touch1=l,a.taps=0):(a.touch0=l,o=!0,a.taps=1+!!u);u&&=clearTimeout(u),o&&(a.taps<2&&(d=l[0],u=setTimeout(function(){u=null},p)),j3(this),a.start())}}function ee(e,...t){if(this.__zooming){var r=S(this,t).event(e),i=e.changedTouches,a=i.length,s,c,l,u;for(U3(e),s=0;s<a;++s)c=i[s],l=p4(c,this),r.touch0&&r.touch0[2]===c.identifier?r.touch0[0]=l:r.touch1&&r.touch1[2]===c.identifier&&(r.touch1[0]=l);if(c=r.that.__zoom,r.touch1){var d=r.touch0[0],f=r.touch0[1],p=r.touch1[0],m=r.touch1[1],h=(h=p[0]-d[0])*h+(h=p[1]-d[1])*h,g=(g=m[0]-f[0])*g+(g=m[1]-f[1])*g;c=v(c,Math.sqrt(h/g)),l=[(d[0]+p[0])/2,(d[1]+p[1])/2],u=[(f[0]+m[0])/2,(f[1]+m[1])/2]}else if(r.touch0)l=r.touch0[0],u=r.touch0[1];else return;r.zoom(`touch`,n(y(c,l,u),r.extent,o))}}function te(e,...t){if(this.__zooming){var n=S(this,t).event(e),r=e.changedTouches,i=r.length,a,o;for(H3(e),f&&clearTimeout(f),f=setTimeout(function(){f=null},p),a=0;a<i;++a)o=r[a],n.touch0&&n.touch0[2]===o.identifier?delete n.touch0:n.touch1&&n.touch1[2]===o.identifier&&delete n.touch1;if(n.touch1&&!n.touch0&&(n.touch0=n.touch1,delete n.touch1),n.touch0)n.touch0[1]=this.__zoom.invert(n.touch0[0]);else if(n.end(),n.taps===2&&(o=p4(o,this),Math.hypot(d[0]-o[0],d[1]-o[1])<g)){var s=f4(this).on(`dblclick.zoom`);s&&s.apply(this,arguments)}}}return _.wheelDelta=function(e){return arguments.length?(r=typeof e==`function`?e:R3(+e),_):r},_.filter=function(t){return arguments.length?(e=typeof t==`function`?t:R3(!!t),_):e},_.touchable=function(e){return arguments.length?(i=typeof e==`function`?e:R3(!!e),_):i},_.extent=function(e){return arguments.length?(t=typeof e==`function`?e:R3([[+e[0][0],+e[0][1]],[+e[1][0],+e[1][1]]]),_):t},_.scaleExtent=function(e){return arguments.length?(a[0]=+e[0],a[1]=+e[1],_):[a[0],a[1]]},_.translateExtent=function(e){return arguments.length?(o[0][0]=+e[0][0],o[1][0]=+e[1][0],o[0][1]=+e[0][1],o[1][1]=+e[1][1],_):[[o[0][0],o[0][1]],[o[1][0],o[1][1]]]},_.constrain=function(e){return arguments.length?(n=e,_):n},_.duration=function(e){return arguments.length?(s=+e,_):s},_.interpolate=function(e){return arguments.length?(c=e,_):c},_.on=function(){var e=l.on.apply(l,arguments);return e===l?_:e},_.clickDistance=function(e){return arguments.length?(h=(e=+e)*e,_):Math.sqrt(h)},_.tapDistance=function(e){return arguments.length?(g=+e,_):g},_}var K3={error001:()=>`[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001`,error002:()=>`It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.`,error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>`The React Flow parent container needs a width and a height to render the graph.`,error005:()=>`Only child nodes can use a parent extent.`,error006:()=>`Can't create edge. An edge needs a source and a target.`,error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:t,sourceHandle:n,targetHandle:r})=>`Couldn't create edge for ${e} handle id: "${e===`source`?n:r}", edge id: ${t}.`,error010:()=>`Handle: No node id found. Make sure to only use a Handle inside a custom Node.`,error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(e=`react`)=>`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>`useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.`,error015:()=>`It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs.`},q3=[[-1/0,-1/0],[1/0,1/0]],J3=[`Enter`,` `,`Escape`],Y3={"node.a11yDescription.default":`Press enter or space to select a node. Press delete to remove it and escape to cancel.`,"node.a11yDescription.keyboardDisabled":`Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.`,"node.a11yDescription.ariaLiveMessage":({direction:e,x:t,y:n})=>`Moved selected node ${e}. New position, x: ${t}, y: ${n}`,"edge.a11yDescription.default":`Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.`,"controls.ariaLabel":`Control Panel`,"controls.zoomIn.ariaLabel":`Zoom In`,"controls.zoomOut.ariaLabel":`Zoom Out`,"controls.fitView.ariaLabel":`Fit View`,"controls.interactive.ariaLabel":`Toggle Interactivity`,"minimap.ariaLabel":`Mini Map`,"handle.ariaLabel":`Handle`},X3;(function(e){e.Strict=`strict`,e.Loose=`loose`})(X3||={});var Z3;(function(e){e.Free=`free`,e.Vertical=`vertical`,e.Horizontal=`horizontal`})(Z3||={});var Q3;(function(e){e.Partial=`partial`,e.Full=`full`})(Q3||={});var $3={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null},e6;(function(e){e.Bezier=`default`,e.Straight=`straight`,e.Step=`step`,e.SmoothStep=`smoothstep`,e.SimpleBezier=`simplebezier`})(e6||={});var t6;(function(e){e.Arrow=`arrow`,e.ArrowClosed=`arrowclosed`})(t6||={});var $;(function(e){e.Left=`left`,e.Top=`top`,e.Right=`right`,e.Bottom=`bottom`})($||={});var n6={[$.Left]:$.Right,[$.Right]:$.Left,[$.Top]:$.Bottom,[$.Bottom]:$.Top};function r6(e){return e===null?null:e?`valid`:`invalid`}var i6=e=>`id`in e&&`source`in e&&`target`in e,sfe=e=>`id`in e&&`position`in e&&!(`source`in e)&&!(`target`in e),a6=e=>`id`in e&&`internals`in e&&!(`source`in e)&&!(`target`in e),o6=(e,t=[0,0])=>{let{width:n,height:r}=j6(e),i=e.origin??t,a=n*i[0],o=r*i[1];return{x:e.position.x-a,y:e.position.y-o}},cfe=(e,t={nodeOrigin:[0,0]})=>e.length===0?{x:0,y:0,width:0,height:0}:_6(e.reduce((e,n)=>{let r=typeof n==`string`,i=!t.nodeLookup&&!r?n:void 0;return t.nodeLookup&&(i=r?t.nodeLookup.get(n):a6(n)?n:t.nodeLookup.get(n.id)),h6(e,i?y6(i,t.nodeOrigin):{x:0,y:0,x2:0,y2:0})},{x:1/0,y:1/0,x2:-1/0,y2:-1/0})),s6=(e,t={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},r=!1;return e.forEach(e=>{(t.filter===void 0||t.filter(e))&&(n=h6(n,y6(e)),r=!0)}),r?_6(n):{x:0,y:0,width:0,height:0}},c6=(e,t,[n,r,i]=[0,0,1],a=!1,o=!1)=>{let s={...T6(t,[n,r,i]),width:t.width/i,height:t.height/i},c=[];for(let t of e.values()){let{measured:e,selectable:n=!0,hidden:r=!1}=t;if(o&&!n||r)continue;let i=e.width??t.width??t.initialWidth??null,l=e.height??t.height??t.initialHeight??null,u=x6(s,v6(t)),d=(i??0)*(l??0),f=a&&u>0;(!t.internals.handleBounds||f||u>=d||t.dragging)&&c.push(t)}return c},lfe=(e,t)=>{let n=new Set;return e.forEach(e=>{n.add(e.id)}),t.filter(e=>n.has(e.source)||n.has(e.target))};function ufe(e,t){let n=new Map,r=t?.nodes?new Set(t.nodes.map(e=>e.id)):null;return e.forEach(e=>{e.measured.width&&e.measured.height&&(t?.includeHiddenNodes||!e.hidden)&&(!r||r.has(e.id))&&n.set(e.id,e)}),n}async function dfe({nodes:e,width:t,height:n,panZoom:r,minZoom:i,maxZoom:a},o){if(e.size===0)return Promise.resolve(!0);let s=O6(s6(ufe(e,o)),t,n,o?.minZoom??i,o?.maxZoom??a,o?.padding??.1);return await r.setViewport(s,{duration:o?.duration,ease:o?.ease,interpolate:o?.interpolate}),Promise.resolve(!0)}function l6({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:r=[0,0],nodeExtent:i,onError:a}){let o=n.get(e),s=o.parentId?n.get(o.parentId):void 0,{x:c,y:l}=s?s.internals.positionAbsolute:{x:0,y:0},u=o.origin??r,d=o.extent||i;if(o.extent===`parent`&&!o.expandParent)if(!s)a?.(`005`,K3.error005());else{let e=s.measured.width,t=s.measured.height;e&&t&&(d=[[c,l],[c+e,l+t]])}else s&&A6(o.extent)&&(d=[[o.extent[0][0]+c,o.extent[0][1]+l],[o.extent[1][0]+c,o.extent[1][1]+l]]);let f=A6(d)?d6(t,d,o.measured):t;return(o.measured.width===void 0||o.measured.height===void 0)&&a?.(`015`,K3.error015()),{position:{x:f.x-c+(o.measured.width??0)*u[0],y:f.y-l+(o.measured.height??0)*u[1]},positionAbsolute:f}}async function ffe({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:r,onBeforeDelete:i}){let a=new Set(e.map(e=>e.id)),o=[];for(let e of n){if(e.deletable===!1)continue;let t=a.has(e.id),n=!t&&e.parentId&&o.find(t=>t.id===e.parentId);(t||n)&&o.push(e)}let s=new Set(t.map(e=>e.id)),c=r.filter(e=>e.deletable!==!1),l=lfe(o,c);for(let e of c)s.has(e.id)&&!l.find(t=>t.id===e.id)&&l.push(e);if(!i)return{edges:l,nodes:o};let u=await i({nodes:o,edges:l});return typeof u==`boolean`?u?{edges:l,nodes:o}:{edges:[],nodes:[]}:u}var u6=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),d6=(e={x:0,y:0},t,n)=>({x:u6(e.x,t[0][0],t[1][0]-(n?.width??0)),y:u6(e.y,t[0][1],t[1][1]-(n?.height??0))});function f6(e,t,n){let{width:r,height:i}=j6(n),{x:a,y:o}=n.internals.positionAbsolute;return d6(e,[[a,o],[a+r,o+i]],t)}var p6=(e,t,n)=>e<t?u6(Math.abs(e-t),1,t)/t:e>n?-u6(Math.abs(e-n),1,t)/t:0,m6=(e,t,n=15,r=40)=>[p6(e.x,r,t.width-r)*n,p6(e.y,r,t.height-r)*n],h6=(e,t)=>({x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}),g6=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),_6=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),v6=(e,t=[0,0])=>{let{x:n,y:r}=a6(e)?e.internals.positionAbsolute:o6(e,t);return{x:n,y:r,width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}},y6=(e,t=[0,0])=>{let{x:n,y:r}=a6(e)?e.internals.positionAbsolute:o6(e,t);return{x:n,y:r,x2:n+(e.measured?.width??e.width??e.initialWidth??0),y2:r+(e.measured?.height??e.height??e.initialHeight??0)}},b6=(e,t)=>_6(h6(g6(e),g6(t))),x6=(e,t)=>{let n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),r=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*r)},S6=e=>C6(e.width)&&C6(e.height)&&C6(e.x)&&C6(e.y),C6=e=>!isNaN(e)&&isFinite(e),pfe=(e,t)=>{},w6=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),T6=({x:e,y:t},[n,r,i],a=!1,o=[1,1])=>{let s={x:(e-n)/i,y:(t-r)/i};return a?w6(s,o):s},E6=({x:e,y:t},[n,r,i])=>({x:e*i+n,y:t*i+r});function D6(e,t){if(typeof e==`number`)return Math.floor((t-t/(1+e))*.5);if(typeof e==`string`&&e.endsWith(`px`)){let t=parseFloat(e);if(!Number.isNaN(t))return Math.floor(t)}if(typeof e==`string`&&e.endsWith(`%`)){let n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(t*n*.01)}return console.error(`[React Flow] The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function mfe(e,t,n){if(typeof e==`string`||typeof e==`number`){let r=D6(e,n),i=D6(e,t);return{top:r,right:i,bottom:r,left:i,x:i*2,y:r*2}}if(typeof e==`object`){let r=D6(e.top??e.y??0,n),i=D6(e.bottom??e.y??0,n),a=D6(e.left??e.x??0,t),o=D6(e.right??e.x??0,t);return{top:r,right:o,bottom:i,left:a,x:a+o,y:r+i}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function hfe(e,t,n,r,i,a){let{x:o,y:s}=E6(e,[t,n,r]),{x:c,y:l}=E6({x:e.x+e.width,y:e.y+e.height},[t,n,r]),u=i-c,d=a-l;return{left:Math.floor(o),top:Math.floor(s),right:Math.floor(u),bottom:Math.floor(d)}}var O6=(e,t,n,r,i,a)=>{let o=mfe(a,t,n),s=(t-o.x)/e.width,c=(n-o.y)/e.height,l=u6(Math.min(s,c),r,i),u=e.x+e.width/2,d=e.y+e.height/2,f=t/2-u*l,p=n/2-d*l,m=hfe(e,f,p,l,t,n),h={left:Math.min(m.left-o.left,0),top:Math.min(m.top-o.top,0),right:Math.min(m.right-o.right,0),bottom:Math.min(m.bottom-o.bottom,0)};return{x:f-h.left+h.right,y:p-h.top+h.bottom,zoom:l}},k6=()=>typeof navigator<`u`&&navigator?.userAgent?.indexOf(`Mac`)>=0;function A6(e){return e!=null&&e!==`parent`}function j6(e){return{width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}}function M6(e){return(e.measured?.width??e.width??e.initialWidth)!==void 0&&(e.measured?.height??e.height??e.initialHeight)!==void 0}function N6(e,t={width:0,height:0},n,r,i){let a={...e},o=r.get(n);if(o){let e=o.origin||i;a.x+=o.internals.positionAbsolute.x-(t.width??0)*e[0],a.y+=o.internals.positionAbsolute.y-(t.height??0)*e[1]}return a}function P6(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function gfe(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}function _fe(e){return{...Y3,...e||{}}}function F6(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:r,containerBounds:i}){let{x:a,y:o}=B6(e),s=T6({x:a-(i?.left??0),y:o-(i?.top??0)},r),{x:c,y:l}=n?w6(s,t):s;return{xSnapped:c,ySnapped:l,...s}}var I6=e=>({width:e.offsetWidth,height:e.offsetHeight}),L6=e=>e?.getRootNode?.()||window?.document,vfe=[`INPUT`,`SELECT`,`TEXTAREA`];function R6(e){let t=e.composedPath?.()?.[0]||e.target;return t?.nodeType===1?vfe.includes(t.nodeName)||t.hasAttribute(`contenteditable`)||!!t.closest(`.nokey`):!1}var z6=e=>`clientX`in e,B6=(e,t)=>{let n=z6(e),r=n?e.clientX:e.touches?.[0].clientX,i=n?e.clientY:e.touches?.[0].clientY;return{x:r-(t?.left??0),y:i-(t?.top??0)}},V6=(e,t,n,r,i)=>{let a=t.querySelectorAll(`.${e}`);return!a||!a.length?null:Array.from(a).map(t=>{let a=t.getBoundingClientRect();return{id:t.getAttribute(`data-handleid`),type:e,nodeId:i,position:t.getAttribute(`data-handlepos`),x:(a.left-n.left)/r,y:(a.top-n.top)/r,...I6(t)}})};function H6({sourceX:e,sourceY:t,targetX:n,targetY:r,sourceControlX:i,sourceControlY:a,targetControlX:o,targetControlY:s}){let c=e*.125+i*.375+o*.375+n*.125,l=t*.125+a*.375+s*.375+r*.125;return[c,l,Math.abs(c-e),Math.abs(l-t)]}function U6(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function W6({pos:e,x1:t,y1:n,x2:r,y2:i,c:a}){switch(e){case $.Left:return[t-U6(t-r,a),n];case $.Right:return[t+U6(r-t,a),n];case $.Top:return[t,n-U6(n-i,a)];case $.Bottom:return[t,n+U6(i-n,a)]}}function G6({sourceX:e,sourceY:t,sourcePosition:n=$.Bottom,targetX:r,targetY:i,targetPosition:a=$.Top,curvature:o=.25}){let[s,c]=W6({pos:n,x1:e,y1:t,x2:r,y2:i,c:o}),[l,u]=W6({pos:a,x1:r,y1:i,x2:e,y2:t,c:o}),[d,f,p,m]=H6({sourceX:e,sourceY:t,targetX:r,targetY:i,sourceControlX:s,sourceControlY:c,targetControlX:l,targetControlY:u});return[`M${e},${t} C${s},${c} ${l},${u} ${r},${i}`,d,f,p,m]}function K6({sourceX:e,sourceY:t,targetX:n,targetY:r}){let i=Math.abs(n-e)/2,a=n<e?n+i:n-i,o=Math.abs(r-t)/2;return[a,r<t?r+o:r-o,i,o]}function yfe({sourceNode:e,targetNode:t,selected:n=!1,zIndex:r=0,elevateOnSelect:i=!1,zIndexMode:a=`basic`}){return a===`manual`?r:(i&&n?r+1e3:r)+Math.max(e.parentId||i&&e.selected?e.internals.z:0,t.parentId||i&&t.selected?t.internals.z:0)}function bfe({sourceNode:e,targetNode:t,width:n,height:r,transform:i}){let a=h6(y6(e),y6(t));return a.x===a.x2&&(a.x2+=1),a.y===a.y2&&(a.y2+=1),x6({x:-i[0]/i[2],y:-i[1]/i[2],width:n/i[2],height:r/i[2]},_6(a))>0}var xfe=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`xy-edge__${e}${t||``}-${n}${r||``}`,Sfe=(e,t)=>t.some(t=>t.source===e.source&&t.target===e.target&&(t.sourceHandle===e.sourceHandle||!t.sourceHandle&&!e.sourceHandle)&&(t.targetHandle===e.targetHandle||!t.targetHandle&&!e.targetHandle)),Cfe=(e,t,n={})=>{if(!e.source||!e.target)return K3.error006(),t;let r=n.getEdgeId||xfe,i;return i=i6(e)?{...e}:{...e,id:r(e)},Sfe(i,t)?t:(i.sourceHandle===null&&delete i.sourceHandle,i.targetHandle===null&&delete i.targetHandle,t.concat(i))};function q6({sourceX:e,sourceY:t,targetX:n,targetY:r}){let[i,a,o,s]=K6({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,i,a,o,s]}var J6={[$.Left]:{x:-1,y:0},[$.Right]:{x:1,y:0},[$.Top]:{x:0,y:-1},[$.Bottom]:{x:0,y:1}},wfe=({source:e,sourcePosition:t=$.Bottom,target:n})=>t===$.Left||t===$.Right?e.x<n.x?{x:1,y:0}:{x:-1,y:0}:e.y<n.y?{x:0,y:1}:{x:0,y:-1},Y6=(e,t)=>Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2);function Tfe({source:e,sourcePosition:t=$.Bottom,target:n,targetPosition:r=$.Top,center:i,offset:a,stepPosition:o}){let s=J6[t],c=J6[r],l={x:e.x+s.x*a,y:e.y+s.y*a},u={x:n.x+c.x*a,y:n.y+c.y*a},d=wfe({source:l,sourcePosition:t,target:u}),f=d.x===0?`y`:`x`,p=d[f],m=[],h,g,_={x:0,y:0},v={x:0,y:0},[,,y,b]=K6({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(s[f]*c[f]===-1){f===`x`?(h=i.x??l.x+(u.x-l.x)*o,g=i.y??(l.y+u.y)/2):(h=i.x??(l.x+u.x)/2,g=i.y??l.y+(u.y-l.y)*o);let e=[{x:h,y:l.y},{x:h,y:u.y}],t=[{x:l.x,y:g},{x:u.x,y:g}];m=s[f]===p?f===`x`?e:t:f===`x`?t:e}else{let i=[{x:l.x,y:u.y}],o=[{x:u.x,y:l.y}];if(m=f===`x`?s.x===p?o:i:s.y===p?i:o,t===r){let t=Math.abs(e[f]-n[f]);if(t<=a){let r=Math.min(a-1,a-t);s[f]===p?_[f]=(l[f]>e[f]?-1:1)*r:v[f]=(u[f]>n[f]?-1:1)*r}}if(t!==r){let e=f===`x`?`y`:`x`,t=s[f]===c[e],n=l[e]>u[e],r=l[e]<u[e];(s[f]===1&&(!t&&n||t&&r)||s[f]!==1&&(!t&&r||t&&n))&&(m=f===`x`?i:o)}let d={x:l.x+_.x,y:l.y+_.y},y={x:u.x+v.x,y:u.y+v.y};Math.max(Math.abs(d.x-m[0].x),Math.abs(y.x-m[0].x))>=Math.max(Math.abs(d.y-m[0].y),Math.abs(y.y-m[0].y))?(h=(d.x+y.x)/2,g=m[0].y):(h=m[0].x,g=(d.y+y.y)/2)}return[[e,{x:l.x+_.x,y:l.y+_.y},...m,{x:u.x+v.x,y:u.y+v.y},n],h,g,y,b]}function Efe(e,t,n,r){let i=Math.min(Y6(e,t)/2,Y6(t,n)/2,r),{x:a,y:o}=t;if(e.x===a&&a===n.x||e.y===o&&o===n.y)return`L${a} ${o}`;if(e.y===o){let t=e.x<n.x?-1:1,r=e.y<n.y?1:-1;return`L ${a+i*t},${o}Q ${a},${o} ${a},${o+i*r}`}let s=e.x<n.x?1:-1;return`L ${a},${o+i*(e.y<n.y?-1:1)}Q ${a},${o} ${a+i*s},${o}`}function X6({sourceX:e,sourceY:t,sourcePosition:n=$.Bottom,targetX:r,targetY:i,targetPosition:a=$.Top,borderRadius:o=5,centerX:s,centerY:c,offset:l=20,stepPosition:u=.5}){let[d,f,p,m,h]=Tfe({source:{x:e,y:t},sourcePosition:n,target:{x:r,y:i},targetPosition:a,center:{x:s,y:c},offset:l,stepPosition:u});return[d.reduce((e,t,n)=>{let r=``;return r=n>0&&n<d.length-1?Efe(d[n-1],t,d[n+1],o):`${n===0?`M`:`L`}${t.x} ${t.y}`,e+=r,e},``),f,p,m,h]}function Z6(e){return e&&!!(e.internals.handleBounds||e.handles?.length)&&!!(e.measured.width||e.width||e.initialWidth)}function Dfe(e){let{sourceNode:t,targetNode:n}=e;if(!Z6(t)||!Z6(n))return null;let r=t.internals.handleBounds||Q6(t.handles),i=n.internals.handleBounds||Q6(n.handles),a=e8(r?.source??[],e.sourceHandle),o=e8(e.connectionMode===X3.Strict?i?.target??[]:(i?.target??[]).concat(i?.source??[]),e.targetHandle);if(!a||!o)return e.onError?.(`008`,K3.error008(a?`target`:`source`,{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;let s=a?.position||$.Bottom,c=o?.position||$.Top,l=$6(t,a,s),u=$6(n,o,c);return{sourceX:l.x,sourceY:l.y,targetX:u.x,targetY:u.y,sourcePosition:s,targetPosition:c}}function Q6(e){if(!e)return null;let t=[],n=[];for(let r of e)r.width=r.width??1,r.height=r.height??1,r.type===`source`?t.push(r):r.type===`target`&&n.push(r);return{source:t,target:n}}function $6(e,t,n=$.Left,r=!1){let i=(t?.x??0)+e.internals.positionAbsolute.x,a=(t?.y??0)+e.internals.positionAbsolute.y,{width:o,height:s}=t??j6(e);if(r)return{x:i+o/2,y:a+s/2};switch(t?.position??n){case $.Top:return{x:i+o/2,y:a};case $.Right:return{x:i+o,y:a+s/2};case $.Bottom:return{x:i+o/2,y:a+s};case $.Left:return{x:i,y:a+s/2}}}function e8(e,t){return e&&(t?e.find(e=>e.id===t):e[0])||null}function t8(e,t){return e?typeof e==`string`?e:`${t?`${t}__`:``}${Object.keys(e).sort().map(t=>`${t}=${e[t]}`).join(`&`)}`:``}function Ofe(e,{id:t,defaultColor:n,defaultMarkerStart:r,defaultMarkerEnd:i}){let a=new Set;return e.reduce((e,o)=>([o.markerStart||r,o.markerEnd||i].forEach(r=>{if(r&&typeof r==`object`){let i=t8(r,t);a.has(i)||(e.push({id:i,color:r.color||n,...r}),a.add(i))}}),e),[]).sort((e,t)=>e.id.localeCompare(t.id))}var n8=1e3,kfe=10,r8={nodeOrigin:[0,0],nodeExtent:q3,elevateNodesOnSelect:!0,zIndexMode:`basic`,defaults:{}},Afe={...r8,checkEquality:!0};function i8(e,t){let n={...e};for(let e in t)t[e]!==void 0&&(n[e]=t[e]);return n}function jfe(e,t,n){let r=i8(r8,n);for(let n of e.values())if(n.parentId)s8(n,e,t,r);else{let e=d6(o6(n,r.nodeOrigin),A6(n.extent)?n.extent:r.nodeExtent,j6(n));n.internals.positionAbsolute=e}}function Mfe(e,t){if(!e.handles)return e.measured?t?.internals.handleBounds:void 0;let n=[],r=[];for(let t of e.handles){let i={id:t.id,width:t.width??1,height:t.height??1,nodeId:e.id,x:t.x,y:t.y,position:t.position,type:t.type};t.type===`source`?n.push(i):t.type===`target`&&r.push(i)}return{source:n,target:r}}function a8(e){return e===`manual`}function o8(e,t,n,r={}){let i=i8(Afe,r),a={i:0},o=new Map(t),s=i?.elevateNodesOnSelect&&!a8(i.zIndexMode)?n8:0,c=e.length>0;t.clear(),n.clear();for(let l of e){let e=o.get(l.id);if(i.checkEquality&&l===e?.internals.userNode)t.set(l.id,e);else{let n=d6(o6(l,i.nodeOrigin),A6(l.extent)?l.extent:i.nodeExtent,j6(l));e={...i.defaults,...l,measured:{width:l.measured?.width,height:l.measured?.height},internals:{positionAbsolute:n,handleBounds:Mfe(l,e),z:c8(l,s,i.zIndexMode),userNode:l}},t.set(l.id,e)}(e.measured===void 0||e.measured.width===void 0||e.measured.height===void 0)&&!e.hidden&&(c=!1),l.parentId&&s8(e,t,n,r,a)}return c}function Nfe(e,t){if(!e.parentId)return;let n=t.get(e.parentId);n?n.set(e.id,e):t.set(e.parentId,new Map([[e.id,e]]))}function s8(e,t,n,r,i){let{elevateNodesOnSelect:a,nodeOrigin:o,nodeExtent:s,zIndexMode:c}=i8(r8,r),l=e.parentId,u=t.get(l);if(!u){console.warn(`Parent node ${l} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}Nfe(e,n),i&&!u.parentId&&u.internals.rootParentIndex===void 0&&c===`auto`&&(u.internals.rootParentIndex=++i.i,u.internals.z=u.internals.z+i.i*kfe),i&&u.internals.rootParentIndex!==void 0&&(i.i=u.internals.rootParentIndex);let{x:d,y:f,z:p}=Pfe(e,u,o,s,a&&!a8(c)?n8:0,c),{positionAbsolute:m}=e.internals,h=d!==m.x||f!==m.y;(h||p!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:h?{x:d,y:f}:m,z:p}})}function c8(e,t,n){let r=C6(e.zIndex)?e.zIndex:0;return a8(n)?r:r+(e.selected?t:0)}function Pfe(e,t,n,r,i,a){let{x:o,y:s}=t.internals.positionAbsolute,c=j6(e),l=o6(e,n),u=A6(e.extent)?d6(l,e.extent,c):l,d=d6({x:o+u.x,y:s+u.y},r,c);e.extent===`parent`&&(d=f6(d,c,t));let f=c8(e,i,a),p=t.internals.z??0;return{x:d.x,y:d.y,z:p>=f?p+1:f}}function l8(e,t,n,r=[0,0]){let i=[],a=new Map;for(let n of e){let e=t.get(n.parentId);if(!e)continue;let r=b6(a.get(n.parentId)?.expandedRect??v6(e),n.rect);a.set(n.parentId,{expandedRect:r,parent:e})}return a.size>0&&a.forEach(({expandedRect:t,parent:a},o)=>{let s=a.internals.positionAbsolute,c=j6(a),l=a.origin??r,u=t.x<s.x?Math.round(Math.abs(s.x-t.x)):0,d=t.y<s.y?Math.round(Math.abs(s.y-t.y)):0,f=Math.max(c.width,Math.round(t.width)),p=Math.max(c.height,Math.round(t.height)),m=(f-c.width)*l[0],h=(p-c.height)*l[1];(u>0||d>0||m||h)&&(i.push({id:o,type:`position`,position:{x:a.position.x-u+m,y:a.position.y-d+h}}),n.get(o)?.forEach(t=>{e.some(e=>e.id===t.id)||i.push({id:t.id,type:`position`,position:{x:t.position.x+u,y:t.position.y+d}})})),(c.width<t.width||c.height<t.height||u||d)&&i.push({id:o,type:`dimensions`,setAttributes:!0,dimensions:{width:f+(u?l[0]*u-m:0),height:p+(d?l[1]*d-h:0)}})}),i}function Ffe(e,t,n,r,i,a,o){let s=r?.querySelector(`.xyflow__viewport`),c=!1;if(!s)return{changes:[],updatedInternals:c};let l=[],u=window.getComputedStyle(s),{m22:d}=new window.DOMMatrixReadOnly(u.transform),f=[];for(let r of e.values()){let e=t.get(r.id);if(!e)continue;if(e.hidden){t.set(e.id,{...e,internals:{...e.internals,handleBounds:void 0}}),c=!0;continue}let s=I6(r.nodeElement),u=e.measured.width!==s.width||e.measured.height!==s.height;if(s.width&&s.height&&(u||!e.internals.handleBounds||r.force)){let p=r.nodeElement.getBoundingClientRect(),m=A6(e.extent)?e.extent:a,{positionAbsolute:h}=e.internals;e.parentId&&e.extent===`parent`?h=f6(h,s,t.get(e.parentId)):m&&(h=d6(h,m,s));let g={...e,measured:s,internals:{...e.internals,positionAbsolute:h,handleBounds:{source:V6(`source`,r.nodeElement,p,d,e.id),target:V6(`target`,r.nodeElement,p,d,e.id)}}};t.set(e.id,g),e.parentId&&s8(g,t,n,{nodeOrigin:i,zIndexMode:o}),c=!0,u&&(l.push({id:e.id,type:`dimensions`,dimensions:s}),e.expandParent&&e.parentId&&f.push({id:e.id,parentId:e.parentId,rect:v6(g,i)}))}}if(f.length>0){let e=l8(f,t,n,i);l.push(...e)}return{changes:l,updatedInternals:c}}async function Ife({delta:e,panZoom:t,transform:n,translateExtent:r,width:i,height:a}){if(!t||!e.x&&!e.y)return Promise.resolve(!1);let o=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[i,a]],r),s=!!o&&(o.x!==n[0]||o.y!==n[1]||o.k!==n[2]);return Promise.resolve(s)}function u8(e,t,n,r,i,a){let o=i,s=r.get(o)||new Map;r.set(o,s.set(n,t)),o=`${i}-${e}`;let c=r.get(o)||new Map;if(r.set(o,c.set(n,t)),a){o=`${i}-${e}-${a}`;let s=r.get(o)||new Map;r.set(o,s.set(n,t))}}function d8(e,t,n){e.clear(),t.clear();for(let r of n){let{source:n,target:i,sourceHandle:a=null,targetHandle:o=null}=r,s={edgeId:r.id,source:n,target:i,sourceHandle:a,targetHandle:o},c=`${n}-${a}--${i}-${o}`;u8(`source`,s,`${i}-${o}--${n}-${a}`,e,n,a),u8(`target`,s,c,e,i,o),t.set(r.id,r)}}function f8(e,t){if(!e.parentId)return!1;let n=t.get(e.parentId);return n?n.selected?!0:f8(n,t):!1}function p8(e,t,n){let r=e;do{if(r?.matches?.(t))return!0;if(r===n)return!1;r=r?.parentElement}while(r);return!1}function Lfe(e,t,n,r){let i=new Map;for(let[a,o]of e)if((o.selected||o.id===r)&&(!o.parentId||!f8(o,e))&&(o.draggable||t&&o.draggable===void 0)){let t=e.get(a);t&&i.set(a,{id:a,position:t.position||{x:0,y:0},distance:{x:n.x-t.internals.positionAbsolute.x,y:n.y-t.internals.positionAbsolute.y},extent:t.extent,parentId:t.parentId,origin:t.origin,expandParent:t.expandParent,internals:{positionAbsolute:t.internals.positionAbsolute||{x:0,y:0}},measured:{width:t.measured.width??0,height:t.measured.height??0}})}return i}function m8({nodeId:e,dragItems:t,nodeLookup:n,dragging:r=!0}){let i=[];for(let[e,a]of t){let t=n.get(e)?.internals.userNode;t&&i.push({...t,position:a.position,dragging:r})}if(!e)return[i[0],i];let a=n.get(e)?.internals.userNode;return[a?{...a,position:t.get(e)?.position||a.position,dragging:r}:i[0],i]}function Rfe({dragItems:e,snapGrid:t,x:n,y:r}){let i=e.values().next().value;if(!i)return null;let a={x:n-i.distance.x,y:r-i.distance.y},o=w6(a,t);return{x:o.x-a.x,y:o.y-a.y}}function zfe({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:r,onDragStop:i}){let a={x:null,y:null},o=0,s=new Map,c=!1,l={x:0,y:0},u=null,d=!1,f=null,p=!1,m=!1,h=null;function g({noDragClassName:g,handleSelector:_,domNode:v,isSelectable:y,nodeId:b,nodeClickDistance:x=0}){f=f4(v);function S({x:e,y:n}){let{nodeLookup:i,nodeExtent:o,snapGrid:c,snapToGrid:l,nodeOrigin:u,onNodeDrag:d,onSelectionDrag:f,onError:p,updateNodePositions:g}=t();a={x:e,y:n};let _=!1,v=s.size>1,y=v&&o?g6(s6(s)):null,x=v&&l?Rfe({dragItems:s,snapGrid:c,x:e,y:n}):null;for(let[t,r]of s){if(!i.has(t))continue;let a={x:e-r.distance.x,y:n-r.distance.y};l&&(a=x?{x:Math.round(a.x+x.x),y:Math.round(a.y+x.y)}:w6(a,c));let s=null;if(v&&o&&!r.extent&&y){let{positionAbsolute:e}=r.internals,t=e.x-y.x+o[0][0],n=e.x+r.measured.width-y.x2+o[1][0],i=e.y-y.y+o[0][1],a=e.y+r.measured.height-y.y2+o[1][1];s=[[t,i],[n,a]]}let{position:d,positionAbsolute:f}=l6({nodeId:t,nextPosition:a,nodeLookup:i,nodeExtent:s||o,nodeOrigin:u,onError:p});_=_||r.position.x!==d.x||r.position.y!==d.y,r.position=d,r.internals.positionAbsolute=f}if(m||=_,_&&(g(s,!0),h&&(r||d||!b&&f))){let[e,t]=m8({nodeId:b,dragItems:s,nodeLookup:i});r?.(h,s,e,t),d?.(h,e,t),b||f?.(h,t)}}async function C(){if(!u)return;let{transform:e,panBy:n,autoPanSpeed:r,autoPanOnNodeDrag:i}=t();if(!i){c=!1,cancelAnimationFrame(o);return}let[s,d]=m6(l,u,r);(s!==0||d!==0)&&(a.x=(a.x??0)-s/e[2],a.y=(a.y??0)-d/e[2],await n({x:s,y:d})&&S(a)),o=requestAnimationFrame(C)}function w(r){let{nodeLookup:i,multiSelectionActive:o,nodesDraggable:c,transform:l,snapGrid:f,snapToGrid:p,selectNodesOnDrag:m,onNodeDragStart:h,onSelectionDragStart:g,unselectNodesAndEdges:_}=t();d=!0,(!m||!y)&&!o&&b&&(i.get(b)?.selected||_()),y&&m&&b&&e?.(b);let v=F6(r.sourceEvent,{transform:l,snapGrid:f,snapToGrid:p,containerBounds:u});if(a=v,s=Lfe(i,c,v,b),s.size>0&&(n||h||!b&&g)){let[e,t]=m8({nodeId:b,dragItems:s,nodeLookup:i});n?.(r.sourceEvent,s,e,t),h?.(r.sourceEvent,e,t),b||g?.(r.sourceEvent,t)}}let T=x4().clickDistance(x).on(`start`,e=>{let{domNode:n,nodeDragThreshold:r,transform:i,snapGrid:o,snapToGrid:s}=t();u=n?.getBoundingClientRect()||null,p=!1,m=!1,h=e.sourceEvent,r===0&&w(e),a=F6(e.sourceEvent,{transform:i,snapGrid:o,snapToGrid:s,containerBounds:u}),l=B6(e.sourceEvent,u)}).on(`drag`,e=>{let{autoPanOnNodeDrag:n,transform:r,snapGrid:i,snapToGrid:o,nodeDragThreshold:f,nodeLookup:m}=t(),g=F6(e.sourceEvent,{transform:r,snapGrid:i,snapToGrid:o,containerBounds:u});if(h=e.sourceEvent,(e.sourceEvent.type===`touchmove`&&e.sourceEvent.touches.length>1||b&&!m.has(b))&&(p=!0),!p){if(!c&&n&&d&&(c=!0,C()),!d){let t=B6(e.sourceEvent,u),n=t.x-l.x,r=t.y-l.y;Math.sqrt(n*n+r*r)>f&&w(e)}(a.x!==g.xSnapped||a.y!==g.ySnapped)&&s&&d&&(l=B6(e.sourceEvent,u),S(g))}}).on(`end`,e=>{if(!(!d||p)&&(c=!1,d=!1,cancelAnimationFrame(o),s.size>0)){let{nodeLookup:n,updateNodePositions:r,onNodeDragStop:a,onSelectionDragStop:o}=t();if(m&&=(r(s,!1),!1),i||a||!b&&o){let[t,r]=m8({nodeId:b,dragItems:s,nodeLookup:n,dragging:!1});i?.(e.sourceEvent,s,t,r),a?.(e.sourceEvent,t,r),b||o?.(e.sourceEvent,r)}}}).filter(e=>{let t=e.target;return!e.button&&(!g||!p8(t,`.${g}`,v))&&(!_||p8(t,_,v))});f.call(T)}function _(){f?.on(`.drag`,null)}return{update:g,destroy:_}}function Bfe(e,t,n){let r=[],i={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(let e of t.values())x6(i,v6(e))>0&&r.push(e);return r}var Vfe=250;function Hfe(e,t,n,r){let i=[],a=1/0,o=Bfe(e,n,t+Vfe);for(let n of o){let o=[...n.internals.handleBounds?.source??[],...n.internals.handleBounds?.target??[]];for(let s of o){if(r.nodeId===s.nodeId&&r.type===s.type&&r.id===s.id)continue;let{x:o,y:c}=$6(n,s,s.position,!0),l=Math.sqrt((o-e.x)**2+(c-e.y)**2);l>t||(l<a?(i=[{...s,x:o,y:c}],a=l):l===a&&i.push({...s,x:o,y:c}))}}if(!i.length)return null;if(i.length>1){let e=r.type===`source`?`target`:`source`;return i.find(t=>t.type===e)??i[0]}return i[0]}function h8(e,t,n,r,i,a=!1){let o=r.get(e);if(!o)return null;let s=i===`strict`?o.internals.handleBounds?.[t]:[...o.internals.handleBounds?.source??[],...o.internals.handleBounds?.target??[]],c=(n?s?.find(e=>e.id===n):s?.[0])??null;return c&&a?{...c,...$6(o,c,c.position,!0)}:c}function g8(e,t){return e||(t?.classList.contains(`target`)?`target`:t?.classList.contains(`source`)?`source`:null)}function Ufe(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}var _8=()=>!0;function Wfe(e,{connectionMode:t,connectionRadius:n,handleId:r,nodeId:i,edgeUpdaterType:a,isTarget:o,domNode:s,nodeLookup:c,lib:l,autoPanOnConnect:u,flowId:d,panBy:f,cancelConnection:p,onConnectStart:m,onConnect:h,onConnectEnd:g,isValidConnection:_=_8,onReconnectEnd:v,updateConnection:y,getTransform:b,getFromHandle:x,autoPanSpeed:S,dragThreshold:C=1,handleDomNode:w}){let T=L6(e.target),E=0,D,{x:ee,y:te}=B6(e),ne=g8(a,w),O=s?.getBoundingClientRect(),k=!1;if(!O||!ne)return;let re=h8(i,ne,r,c,t);if(!re)return;let ie=B6(e,O),ae=!1,oe=null,se=!1,ce=null;function le(){if(!u||!O)return;let[e,t]=m6(ie,O,S);f({x:e,y:t}),E=requestAnimationFrame(le)}let ue={...re,nodeId:i,type:ne,position:re.position},de=c.get(i),fe={inProgress:!0,isValid:null,from:$6(de,ue,$.Left,!0),fromHandle:ue,fromPosition:ue.position,fromNode:de,to:ie,toHandle:null,toPosition:n6[ue.position],toNode:null,pointer:ie};function pe(){k=!0,y(fe),m?.(e,{nodeId:i,handleId:r,handleType:ne})}C===0&&pe();function me(e){if(!k){let{x:t,y:n}=B6(e),r=t-ee,i=n-te;if(!(r*r+i*i>C*C))return;pe()}if(!x()||!ue){he(e);return}let a=b();ie=B6(e,O),D=Hfe(T6(ie,a,!1,[1,1]),n,c,ue),ae||=(le(),!0);let s=v8(e,{handle:D,connectionMode:t,fromNodeId:i,fromHandleId:r,fromType:o?`target`:`source`,isValidConnection:_,doc:T,lib:l,flowId:d,nodeLookup:c});ce=s.handleDomNode,oe=s.connection,se=Ufe(!!D,s.isValid);let u=c.get(i),f=u?$6(u,ue,$.Left,!0):fe.from,p={...fe,from:f,isValid:se,to:s.toHandle&&se?E6({x:s.toHandle.x,y:s.toHandle.y},a):ie,toHandle:s.toHandle,toPosition:se&&s.toHandle?s.toHandle.position:n6[ue.position],toNode:s.toHandle?c.get(s.toHandle.nodeId):null,pointer:ie};y(p),fe=p}function he(e){if(!(`touches`in e&&e.touches.length>0)){if(k){(D||ce)&&oe&&se&&h?.(oe);let{inProgress:t,...n}=fe,r={...n,toPosition:fe.toHandle?fe.toPosition:null};g?.(e,r),a&&v?.(e,r)}p(),cancelAnimationFrame(E),ae=!1,se=!1,oe=null,ce=null,T.removeEventListener(`mousemove`,me),T.removeEventListener(`mouseup`,he),T.removeEventListener(`touchmove`,me),T.removeEventListener(`touchend`,he)}}T.addEventListener(`mousemove`,me),T.addEventListener(`mouseup`,he),T.addEventListener(`touchmove`,me),T.addEventListener(`touchend`,he)}function v8(e,{handle:t,connectionMode:n,fromNodeId:r,fromHandleId:i,fromType:a,doc:o,lib:s,flowId:c,isValidConnection:l=_8,nodeLookup:u}){let d=a===`target`,f=t?o.querySelector(`.${s}-flow__handle[data-id="${c}-${t?.nodeId}-${t?.id}-${t?.type}"]`):null,{x:p,y:m}=B6(e),h=o.elementFromPoint(p,m),g=h?.classList.contains(`${s}-flow__handle`)?h:f,_={handleDomNode:g,isValid:!1,connection:null,toHandle:null};if(g){let e=g8(void 0,g),t=g.getAttribute(`data-nodeid`),a=g.getAttribute(`data-handleid`),o=g.classList.contains(`connectable`),s=g.classList.contains(`connectableend`);if(!t||!e)return _;let c={source:d?t:r,sourceHandle:d?a:i,target:d?r:t,targetHandle:d?i:a};_.connection=c,_.isValid=o&&s&&(n===X3.Strict?d&&e===`source`||!d&&e===`target`:t!==r||a!==i)&&l(c),_.toHandle=h8(t,e,a,u,n,!0)}return _}var y8={onPointerDown:Wfe,isValid:v8};function Gfe({domNode:e,panZoom:t,getTransform:n,getViewScale:r}){let i=f4(e);function a({translateExtent:e,width:a,height:o,zoomStep:s=1,pannable:c=!0,zoomable:l=!0,inversePan:u=!1}){let d=e=>{if(e.sourceEvent.type!==`wheel`||!t)return;let r=n(),i=e.sourceEvent.ctrlKey&&k6()?10:1,a=-e.sourceEvent.deltaY*(e.sourceEvent.deltaMode===1?.05:e.sourceEvent.deltaMode?1:.002)*s,o=r[2]*2**(a*i);t.scaleTo(o)},f=[0,0],p=G3().on(`start`,e=>{(e.sourceEvent.type===`mousedown`||e.sourceEvent.type===`touchstart`)&&(f=[e.sourceEvent.clientX??e.sourceEvent.touches[0].clientX,e.sourceEvent.clientY??e.sourceEvent.touches[0].clientY])}).on(`zoom`,c?i=>{let s=n();if(i.sourceEvent.type!==`mousemove`&&i.sourceEvent.type!==`touchmove`||!t)return;let c=[i.sourceEvent.clientX??i.sourceEvent.touches[0].clientX,i.sourceEvent.clientY??i.sourceEvent.touches[0].clientY],l=[c[0]-f[0],c[1]-f[1]];f=c;let d=r()*Math.max(s[2],Math.log(s[2]))*(u?-1:1),p={x:s[0]-l[0]*d,y:s[1]-l[1]*d},m=[[0,0],[a,o]];t.setViewportConstrained({x:p.x,y:p.y,zoom:s[2]},m,e)}:null).on(`zoom.wheel`,l?d:null);i.call(p,{})}function o(){i.on(`zoom`,null)}return{update:a,destroy:o,pointer:p4}}var b8=e=>({x:e.x,y:e.y,zoom:e.k}),x8=({x:e,y:t,zoom:n})=>B3.translate(e,t).scale(n),S8=(e,t)=>e.target.closest(`.${t}`),C8=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),Kfe=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,w8=(e,t=0,n=Kfe,r=()=>{})=>{let i=typeof t==`number`&&t>0;return i||r(),i?e.transition().duration(t).ease(n).on(`end`,r):e},T8=e=>{let t=e.ctrlKey&&k6()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function qfe({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:r,panOnScrollMode:i,panOnScrollSpeed:a,zoomOnPinch:o,onPanZoomStart:s,onPanZoom:c,onPanZoomEnd:l}){return u=>{if(S8(u,t))return u.ctrlKey&&u.preventDefault(),!1;u.preventDefault(),u.stopImmediatePropagation();let d=n.property(`__zoom`).k||1;if(u.ctrlKey&&o){let e=p4(u),t=d*2**T8(u);r.scaleTo(n,t,e,u);return}let f=u.deltaMode===1?20:1,p=i===Z3.Vertical?0:u.deltaX*f,m=i===Z3.Horizontal?0:u.deltaY*f;!k6()&&u.shiftKey&&i!==Z3.Vertical&&(p=u.deltaY*f,m=0),r.translateBy(n,-(p/d)*a,-(m/d)*a,{internal:!0});let h=b8(n.property(`__zoom`));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(c?.(u,h),e.panScrollTimeout=setTimeout(()=>{l?.(u,h),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,s?.(u,h))}}function Jfe({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(r,i){let a=r.type===`wheel`,o=!t&&a&&!r.ctrlKey,s=S8(r,e);if(r.ctrlKey&&a&&s&&r.preventDefault(),o||s)return null;r.preventDefault(),n.call(this,r,i)}}function Yfe({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return r=>{if(r.sourceEvent?.internal)return;let i=b8(r.transform);e.mouseButton=r.sourceEvent?.button||0,e.isZoomingOrPanning=!0,e.prevViewport=i,r.sourceEvent?.type===`mousedown`&&t(!0),n&&n?.(r.sourceEvent,i)}}function Xfe({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:r,onPanZoom:i}){return a=>{e.usedRightMouseButton=!!(n&&C8(t,e.mouseButton??0)),a.sourceEvent?.sync||r([a.transform.x,a.transform.y,a.transform.k]),i&&!a.sourceEvent?.internal&&i?.(a.sourceEvent,b8(a.transform))}}function Zfe({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:r,onPanZoomEnd:i,onPaneContextMenu:a}){return o=>{if(!o.sourceEvent?.internal&&(e.isZoomingOrPanning=!1,a&&C8(t,e.mouseButton??0)&&!e.usedRightMouseButton&&o.sourceEvent&&a(o.sourceEvent),e.usedRightMouseButton=!1,r(!1),i)){let t=b8(o.transform);e.prevViewport=t,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{i?.(o.sourceEvent,t)},n?150:0)}}}function Qfe({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:r,panOnScroll:i,zoomOnDoubleClick:a,userSelectionActive:o,noWheelClassName:s,noPanClassName:c,lib:l,connectionInProgress:u}){return d=>{let f=e||t,p=n&&d.ctrlKey,m=d.type===`wheel`;if(d.button===1&&d.type===`mousedown`&&(S8(d,`${l}-flow__node`)||S8(d,`${l}-flow__edge`)))return!0;if(!r&&!f&&!i&&!a&&!n||o||u&&!m||S8(d,s)&&m||S8(d,c)&&(!m||i&&m&&!e)||!n&&d.ctrlKey&&m)return!1;if(!n&&d.type===`touchstart`&&d.touches?.length>1)return d.preventDefault(),!1;if(!f&&!i&&!p&&m||!r&&(d.type===`mousedown`||d.type===`touchstart`)||Array.isArray(r)&&!r.includes(d.button)&&d.type===`mousedown`)return!1;let h=Array.isArray(r)&&r.includes(d.button)||!d.button||d.button<=1;return(!d.ctrlKey||m)&&h}}function $fe({domNode:e,minZoom:t,maxZoom:n,translateExtent:r,viewport:i,onPanZoom:a,onPanZoomStart:o,onPanZoomEnd:s,onDraggingChange:c}){let l={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{x:0,y:0,zoom:0},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},u=e.getBoundingClientRect(),d=G3().scaleExtent([t,n]).translateExtent(r),f=f4(e).call(d);v({x:i.x,y:i.y,zoom:u6(i.zoom,t,n)},[[0,0],[u.width,u.height]],r);let p=f.on(`wheel.zoom`),m=f.on(`dblclick.zoom`);d.wheelDelta(T8);function h(e,t){return f?new Promise(n=>{d?.interpolate(t?.interpolate===`linear`?n3:l3).transform(w8(f,t?.duration,t?.ease,()=>n(!0)),e)}):Promise.resolve(!1)}function g({noWheelClassName:e,noPanClassName:t,onPaneContextMenu:n,userSelectionActive:r,panOnScroll:i,panOnDrag:u,panOnScrollMode:h,panOnScrollSpeed:g,preventScrolling:v,zoomOnPinch:y,zoomOnScroll:b,zoomOnDoubleClick:x,zoomActivationKeyPressed:S,lib:C,onTransformChange:w,connectionInProgress:T,paneClickDistance:E,selectionOnDrag:D}){r&&!l.isZoomingOrPanning&&_();let ee=i&&!S&&!r;d.clickDistance(D?1/0:!C6(E)||E<0?0:E);let te=ee?qfe({zoomPanValues:l,noWheelClassName:e,d3Selection:f,d3Zoom:d,panOnScrollMode:h,panOnScrollSpeed:g,zoomOnPinch:y,onPanZoomStart:o,onPanZoom:a,onPanZoomEnd:s}):Jfe({noWheelClassName:e,preventScrolling:v,d3ZoomHandler:p});if(f.on(`wheel.zoom`,te,{passive:!1}),!r){let e=Yfe({zoomPanValues:l,onDraggingChange:c,onPanZoomStart:o});d.on(`start`,e);let t=Xfe({zoomPanValues:l,panOnDrag:u,onPaneContextMenu:!!n,onPanZoom:a,onTransformChange:w});d.on(`zoom`,t);let r=Zfe({zoomPanValues:l,panOnDrag:u,panOnScroll:i,onPaneContextMenu:n,onPanZoomEnd:s,onDraggingChange:c});d.on(`end`,r)}let ne=Qfe({zoomActivationKeyPressed:S,panOnDrag:u,zoomOnScroll:b,panOnScroll:i,zoomOnDoubleClick:x,zoomOnPinch:y,userSelectionActive:r,noPanClassName:t,noWheelClassName:e,lib:C,connectionInProgress:T});d.filter(ne),x?f.on(`dblclick.zoom`,m):f.on(`dblclick.zoom`,null)}function _(){d.on(`zoom`,null)}async function v(e,t,n){let r=x8(e),i=d?.constrain()(r,t,n);return i&&await h(i),new Promise(e=>e(i))}async function y(e,t){let n=x8(e);return await h(n,t),new Promise(e=>e(n))}function b(e){if(f){let t=x8(e),n=f.property(`__zoom`);(n.k!==e.zoom||n.x!==e.x||n.y!==e.y)&&d?.transform(f,t,null,{sync:!0})}}function x(){let e=f?V3(f.node()):{x:0,y:0,k:1};return{x:e.x,y:e.y,zoom:e.k}}function S(e,t){return f?new Promise(n=>{d?.interpolate(t?.interpolate===`linear`?n3:l3).scaleTo(w8(f,t?.duration,t?.ease,()=>n(!0)),e)}):Promise.resolve(!1)}function C(e,t){return f?new Promise(n=>{d?.interpolate(t?.interpolate===`linear`?n3:l3).scaleBy(w8(f,t?.duration,t?.ease,()=>n(!0)),e)}):Promise.resolve(!1)}function w(e){d?.scaleExtent(e)}function T(e){d?.translateExtent(e)}function E(e){let t=!C6(e)||e<0?0:e;d?.clickDistance(t)}return{update:g,destroy:_,setViewport:y,setViewportConstrained:v,getViewport:x,scaleTo:S,scaleBy:C,setScaleExtent:w,setTranslateExtent:T,syncViewport:b,setClickDistance:E}}var E8;(function(e){e.Line=`line`,e.Handle=`handle`})(E8||={});function epe({width:e,prevWidth:t,height:n,prevHeight:r,affectsX:i,affectsY:a}){let o=e-t,s=n-r,c=[o>0?1:o<0?-1:0,s>0?1:s<0?-1:0];return o&&i&&(c[0]*=-1),s&&a&&(c[1]*=-1),c}function D8(e){return{isHorizontal:e.includes(`right`)||e.includes(`left`),isVertical:e.includes(`bottom`)||e.includes(`top`),affectsX:e.includes(`left`),affectsY:e.includes(`top`)}}function O8(e,t){return Math.max(0,t-e)}function k8(e,t){return Math.max(0,e-t)}function A8(e,t,n){return Math.max(0,t-e,e-n)}function j8(e,t){return e?!t:t}function tpe(e,t,n,r,i,a,o,s){let{affectsX:c,affectsY:l}=t,{isHorizontal:u,isVertical:d}=t,f=u&&d,{xSnapped:p,ySnapped:m}=n,{minWidth:h,maxWidth:g,minHeight:_,maxHeight:v}=r,{x:y,y:b,width:x,height:S,aspectRatio:C}=e,w=Math.floor(u?p-e.pointerX:0),T=Math.floor(d?m-e.pointerY:0),E=x+(c?-w:w),D=S+(l?-T:T),ee=-a[0]*x,te=-a[1]*S,ne=A8(E,h,g),O=A8(D,_,v);if(o){let e=0,t=0;c&&w<0?e=O8(y+w+ee,o[0][0]):!c&&w>0&&(e=k8(y+E+ee,o[1][0])),l&&T<0?t=O8(b+T+te,o[0][1]):!l&&T>0&&(t=k8(b+D+te,o[1][1])),ne=Math.max(ne,e),O=Math.max(O,t)}if(s){let e=0,t=0;c&&w>0?e=k8(y+w,s[0][0]):!c&&w<0&&(e=O8(y+E,s[1][0])),l&&T>0?t=k8(b+T,s[0][1]):!l&&T<0&&(t=O8(b+D,s[1][1])),ne=Math.max(ne,e),O=Math.max(O,t)}if(i){if(u){let e=A8(E/C,_,v)*C;if(ne=Math.max(ne,e),o){let e=0;e=!c&&!l||c&&!l&&f?k8(b+te+E/C,o[1][1])*C:O8(b+te+(c?w:-w)/C,o[0][1])*C,ne=Math.max(ne,e)}if(s){let e=0;e=!c&&!l||c&&!l&&f?O8(b+E/C,s[1][1])*C:k8(b+(c?w:-w)/C,s[0][1])*C,ne=Math.max(ne,e)}}if(d){let e=A8(D*C,h,g)/C;if(O=Math.max(O,e),o){let e=0;e=!c&&!l||l&&!c&&f?k8(y+D*C+ee,o[1][0])/C:O8(y+(l?T:-T)*C+ee,o[0][0])/C,O=Math.max(O,e)}if(s){let e=0;e=!c&&!l||l&&!c&&f?O8(y+D*C,s[1][0])/C:k8(y+(l?T:-T)*C,s[0][0])/C,O=Math.max(O,e)}}}T+=T<0?O:-O,w+=w<0?ne:-ne,i&&(f?E>D*C?T=(j8(c,l)?-w:w)/C:w=(j8(c,l)?-T:T)*C:u?(T=w/C,l=c):(w=T*C,c=l));let k=c?y+w:y,re=l?b+T:b;return{width:x+(c?-w:w),height:S+(l?-T:T),x:a[0]*w*(c?-1:1)+k,y:a[1]*T*(l?-1:1)+re}}var M8={width:0,height:0,x:0,y:0},npe={...M8,pointerX:0,pointerY:0,aspectRatio:1};function rpe(e){return[[0,0],[e.measured.width,e.measured.height]]}function ipe(e,t,n){let r=t.position.x+e.position.x,i=t.position.y+e.position.y,a=e.measured.width??0,o=e.measured.height??0,s=n[0]*a,c=n[1]*o;return[[r-s,i-c],[r+a-s,i+o-c]]}function ape({domNode:e,nodeId:t,getStoreItems:n,onChange:r,onEnd:i}){let a=f4(e),o={controlDirection:D8(`bottom-right`),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function s({controlPosition:e,boundaries:s,keepAspectRatio:c,resizeDirection:l,onResizeStart:u,onResize:d,onResizeEnd:f,shouldResize:p}){let m={...M8},h={...npe};o={boundaries:s,resizeDirection:l,keepAspectRatio:c,controlDirection:D8(e)};let g,_=null,v=[],y,b,x,S=!1,C=x4().on(`start`,e=>{let{nodeLookup:r,transform:i,snapGrid:a,snapToGrid:o,nodeOrigin:s,paneDomNode:c}=n();if(g=r.get(t),!g)return;_=c?.getBoundingClientRect()??null;let{xSnapped:l,ySnapped:d}=F6(e.sourceEvent,{transform:i,snapGrid:a,snapToGrid:o,containerBounds:_});m={width:g.measured.width??0,height:g.measured.height??0,x:g.position.x??0,y:g.position.y??0},h={...m,pointerX:l,pointerY:d,aspectRatio:m.width/m.height},y=void 0,g.parentId&&(g.extent===`parent`||g.expandParent)&&(y=r.get(g.parentId),b=y&&g.extent===`parent`?rpe(y):void 0),v=[],x=void 0;for(let[e,n]of r)if(n.parentId===t&&(v.push({id:e,position:{...n.position},extent:n.extent}),n.extent===`parent`||n.expandParent)){let e=ipe(n,g,n.origin??s);x=x?[[Math.min(e[0][0],x[0][0]),Math.min(e[0][1],x[0][1])],[Math.max(e[1][0],x[1][0]),Math.max(e[1][1],x[1][1])]]:e}u?.(e,{...m})}).on(`drag`,e=>{let{transform:t,snapGrid:i,snapToGrid:a,nodeOrigin:s}=n(),c=F6(e.sourceEvent,{transform:t,snapGrid:i,snapToGrid:a,containerBounds:_}),l=[];if(!g)return;let{x:u,y:f,width:C,height:w}=m,T={},E=g.origin??s,{width:D,height:ee,x:te,y:ne}=tpe(h,o.controlDirection,c,o.boundaries,o.keepAspectRatio,E,b,x),O=D!==C,k=ee!==w,re=te!==u&&O,ie=ne!==f&&k;if(!re&&!ie&&!O&&!k)return;if((re||ie||E[0]===1||E[1]===1)&&(T.x=re?te:m.x,T.y=ie?ne:m.y,m.x=T.x,m.y=T.y,v.length>0)){let e=te-u,t=ne-f;for(let n of v)n.position={x:n.position.x-e+E[0]*(D-C),y:n.position.y-t+E[1]*(ee-w)},l.push(n)}if((O||k)&&(T.width=O&&(!o.resizeDirection||o.resizeDirection===`horizontal`)?D:m.width,T.height=k&&(!o.resizeDirection||o.resizeDirection===`vertical`)?ee:m.height,m.width=T.width,m.height=T.height),y&&g.expandParent){let e=E[0]*(T.width??0);T.x&&T.x<e&&(m.x=e,h.x-=T.x-e);let t=E[1]*(T.height??0);T.y&&T.y<t&&(m.y=t,h.y-=T.y-t)}let ae=epe({width:m.width,prevWidth:C,height:m.height,prevHeight:w,affectsX:o.controlDirection.affectsX,affectsY:o.controlDirection.affectsY}),oe={...m,direction:ae};p?.(e,oe)!==!1&&(S=!0,d?.(e,oe),r(T,l))}).on(`end`,e=>{S&&=(f?.(e,{...m}),i?.({...m}),!1)});a.call(C)}function c(){a.on(`.drag`,null)}return{update:s,destroy:c}}var ope=i((e=>{var t=gn(),n=d();function r(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var i=typeof Object.is==`function`?Object.is:r,a=n.useSyncExternalStore,o=t.useRef,s=t.useEffect,c=t.useMemo,l=t.useDebugValue;e.useSyncExternalStoreWithSelector=function(e,t,n,r,u){var d=o(null);if(d.current===null){var f={hasValue:!1,value:null};d.current=f}else f=d.current;d=c(function(){function e(e){if(!a){if(a=!0,o=e,e=r(e),u!==void 0&&f.hasValue){var t=f.value;if(u(t,e))return s=t}return s=e}if(t=s,i(o,e))return t;var n=r(e);return u!==void 0&&u(t,n)?(o=e,t):(o=e,s=n)}var a=!1,o,s,c=n===void 0?null:n;return[function(){return e(t())},c===null?void 0:function(){return e(c())}]},[t,n,r,u]);var p=a(e,d[0],d[1]);return s(function(){f.hasValue=!0,f.value=p},[p]),l(p),p}})),spe=e(i(((e,t)=>{t.exports=ope()}))(),1),N8=e=>{let t,n=new Set,r=(e,r)=>{let i=typeof e==`function`?e(t):e;if(!Object.is(i,t)){let e=t;t=r??(typeof i!=`object`||!i)?i:Object.assign({},t,i),n.forEach(n=>n(t,e))}},i=()=>t,a={setState:r,getState:i,getInitialState:()=>o,subscribe:e=>(n.add(e),()=>n.delete(e)),destroy:()=>{n.clear()}},o=t=e(r,i,a);return a},cpe=e=>e?N8(e):N8,{useDebugValue:lpe}=L.default,{useSyncExternalStoreWithSelector:upe}=spe.default,dpe=e=>e;function P8(e,t=dpe,n){let r=upe(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return lpe(r),r}var F8=(e,t)=>{let n=cpe(e),r=(e,r=t)=>P8(n,e,r);return Object.assign(r,n),r},fpe=(e,t)=>e?F8(e,t):F8;function I8(e,t){if(Object.is(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(let[n,r]of e)if(!Object.is(r,t.get(n)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||!Object.is(e[r],t[r]))return!1;return!0}var L8=(0,L.createContext)(null),ppe=L8.Provider,R8=K3.error001();function z8(e,t){let n=(0,L.useContext)(L8);if(n===null)throw Error(R8);return P8(n,e,t)}function B8(){let e=(0,L.useContext)(L8);if(e===null)throw Error(R8);return(0,L.useMemo)(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}var V8={display:`none`},mpe={position:`absolute`,width:1,height:1,margin:-1,border:0,padding:0,overflow:`hidden`,clip:`rect(0px, 0px, 0px, 0px)`,clipPath:`inset(100%)`},H8=`react-flow__node-desc`,U8=`react-flow__edge-desc`,hpe=`react-flow__aria-live`,gpe=e=>e.ariaLiveMessage,_pe=e=>e.ariaLabelConfig;function vpe({rfId:e}){let t=z8(gpe);return(0,I.jsx)(`div`,{id:`${hpe}-${e}`,"aria-live":`assertive`,"aria-atomic":`true`,style:mpe,children:t})}function ype({rfId:e,disableKeyboardA11y:t}){let n=z8(_pe);return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`div`,{id:`${H8}-${e}`,style:V8,children:t?n[`node.a11yDescription.default`]:n[`node.a11yDescription.keyboardDisabled`]}),(0,I.jsx)(`div`,{id:`${U8}-${e}`,style:V8,children:n[`edge.a11yDescription.default`]}),!t&&(0,I.jsx)(vpe,{rfId:e})]})}var W8=(0,L.forwardRef)(({position:e=`top-left`,children:t,className:n,style:r,...i},a)=>(0,I.jsx)(`div`,{className:H2([`react-flow__panel`,n,...`${e}`.split(`-`)]),style:r,ref:a,...i,children:t}));W8.displayName=`Panel`;function bpe({proOptions:e,position:t=`bottom-right`}){return e?.hideAttribution?null:(0,I.jsx)(W8,{position:t,className:`react-flow__attribution`,"data-message":`Please only hide this attribution when you are subscribed to React Flow Pro: https://pro.reactflow.dev`,children:(0,I.jsx)(`a`,{href:`https://reactflow.dev`,target:`_blank`,rel:`noopener noreferrer`,"aria-label":`React Flow attribution`,children:`React Flow`})})}var xpe=e=>{let t=[],n=[];for(let[,n]of e.nodeLookup)n.selected&&t.push(n.internals.userNode);for(let[,t]of e.edgeLookup)t.selected&&n.push(t);return{selectedNodes:t,selectedEdges:n}},G8=e=>e.id;function Spe(e,t){return I8(e.selectedNodes.map(G8),t.selectedNodes.map(G8))&&I8(e.selectedEdges.map(G8),t.selectedEdges.map(G8))}function Cpe({onSelectionChange:e}){let t=B8(),{selectedNodes:n,selectedEdges:r}=z8(xpe,Spe);return(0,L.useEffect)(()=>{let i={nodes:n,edges:r};e?.(i),t.getState().onSelectionChangeHandlers.forEach(e=>e(i))},[n,r,e]),null}var wpe=e=>!!e.onSelectionChangeHandlers;function Tpe({onSelectionChange:e}){let t=z8(wpe);return e||t?(0,I.jsx)(Cpe,{onSelectionChange:e}):null}var K8=[0,0],Epe={x:0,y:0,zoom:1},q8=[...`nodes.edges.defaultNodes.defaultEdges.onConnect.onConnectStart.onConnectEnd.onClickConnectStart.onClickConnectEnd.nodesDraggable.autoPanOnNodeFocus.nodesConnectable.nodesFocusable.edgesFocusable.edgesReconnectable.elevateNodesOnSelect.elevateEdgesOnSelect.minZoom.maxZoom.nodeExtent.onNodesChange.onEdgesChange.elementsSelectable.connectionMode.snapGrid.snapToGrid.translateExtent.connectOnClick.defaultEdgeOptions.fitView.fitViewOptions.onNodesDelete.onEdgesDelete.onDelete.onNodeDrag.onNodeDragStart.onNodeDragStop.onSelectionDrag.onSelectionDragStart.onSelectionDragStop.onMoveStart.onMove.onMoveEnd.noPanClassName.nodeOrigin.autoPanOnConnect.autoPanOnNodeDrag.onError.connectionRadius.isValidConnection.selectNodesOnDrag.nodeDragThreshold.connectionDragThreshold.onBeforeDelete.debug.autoPanSpeed.ariaLabelConfig.zIndexMode`.split(`.`),`rfId`],Dpe=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges}),J8={translateExtent:q3,nodeOrigin:K8,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:`nopan`,rfId:`1`};function Ope(e){let{setNodes:t,setEdges:n,setMinZoom:r,setMaxZoom:i,setTranslateExtent:a,setNodeExtent:o,reset:s,setDefaultNodesAndEdges:c}=z8(Dpe,I8),l=B8();(0,L.useEffect)(()=>(c(e.defaultNodes,e.defaultEdges),()=>{u.current=J8,s()}),[]);let u=(0,L.useRef)(J8);return(0,L.useEffect)(()=>{for(let s of q8){let c=e[s];c!==u.current[s]&&e[s]!==void 0&&(s===`nodes`?t(c):s===`edges`?n(c):s===`minZoom`?r(c):s===`maxZoom`?i(c):s===`translateExtent`?a(c):s===`nodeExtent`?o(c):s===`ariaLabelConfig`?l.setState({ariaLabelConfig:_fe(c)}):s===`fitView`?l.setState({fitViewQueued:c}):s===`fitViewOptions`?l.setState({fitViewOptions:c}):l.setState({[s]:c}))}u.current=e},q8.map(t=>e[t])),null}function Y8(){return typeof window>`u`||!window.matchMedia?null:window.matchMedia(`(prefers-color-scheme: dark)`)}function kpe(e){let[t,n]=(0,L.useState)(e===`system`?null:e);return(0,L.useEffect)(()=>{if(e!==`system`){n(e);return}let t=Y8(),r=()=>n(t?.matches?`dark`:`light`);return r(),t?.addEventListener(`change`,r),()=>{t?.removeEventListener(`change`,r)}},[e]),t===null?Y8()?.matches?`dark`:`light`:t}var X8=typeof document<`u`?document:null;function Z8(e=null,t={target:X8,actInsideInputWithModifier:!0}){let[n,r]=(0,L.useState)(!1),i=(0,L.useRef)(!1),a=(0,L.useRef)(new Set([])),[o,s]=(0,L.useMemo)(()=>{if(e!==null){let t=(Array.isArray(e)?e:[e]).filter(e=>typeof e==`string`).map(e=>e.replace(`+`,`
2188
2188
  `).replace(`
2189
2189
 
2190
2190
  `,`