@plank-cms/plank 0.17.1 → 0.17.3

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.
@@ -76,7 +76,7 @@ For more information, see https://radix-ui.com/primitives/docs/components/${t.do
76
76
  To pick up a draggable item, press the space bar.
77
77
  While dragging, use the arrow keys to move the item.
78
78
  Press space again to drop the item in its new position, or press escape to cancel.
79
- `},BT={onDragStart(e){let{active:t}=e;return`Picked up draggable item `+t.id+`.`},onDragOver(e){let{active:t,over:n}=e;return n?`Draggable item `+t.id+` was moved over droppable area `+n.id+`.`:`Draggable item `+t.id+` is no longer over a droppable area.`},onDragEnd(e){let{active:t,over:n}=e;return n?`Draggable item `+t.id+` was dropped over droppable area `+n.id:`Draggable item `+t.id+` was dropped.`},onDragCancel(e){let{active:t}=e;return`Dragging was cancelled. Draggable item `+t.id+` was dropped.`}};function VT(e){let{announcements:t=BT,container:n,hiddenTextDescribedById:r,screenReaderInstructions:i=zT}=e,{announce:a,announcement:o}=FT(),s=xT(`DndLiveRegion`),[c,l]=(0,v.useState)(!1);if((0,v.useEffect)(()=>{l(!0)},[]),LT((0,v.useMemo)(()=>({onDragStart(e){let{active:n}=e;a(t.onDragStart({active:n}))},onDragMove(e){let{active:n,over:r}=e;t.onDragMove&&a(t.onDragMove({active:n,over:r}))},onDragOver(e){let{active:n,over:r}=e;a(t.onDragOver({active:n,over:r}))},onDragEnd(e){let{active:n,over:r}=e;a(t.onDragEnd({active:n,over:r}))},onDragCancel(e){let{active:n,over:r}=e;a(t.onDragCancel({active:n,over:r}))}}),[a,t])),!c)return null;let u=v.createElement(v.Fragment,null,v.createElement(NT,{id:r,value:i.draggable}),v.createElement(PT,{id:s,announcement:o}));return n?(0,N.createPortal)(u,n):u}var HT;(function(e){e.DragStart=`dragStart`,e.DragMove=`dragMove`,e.DragEnd=`dragEnd`,e.DragCancel=`dragCancel`,e.DragOver=`dragOver`,e.RegisterDroppable=`registerDroppable`,e.SetDroppableDisabled=`setDroppableDisabled`,e.UnregisterDroppable=`unregisterDroppable`})(HT||={});function UT(){}function WT(e,t){return(0,v.useMemo)(()=>({sensor:e,options:t??{}}),[e,t])}function GT(){var e=[...arguments];return(0,v.useMemo)(()=>[...e].filter(e=>e!=null),[...e])}var KT=Object.freeze({x:0,y:0});function qT(e,t){return Math.sqrt((e.x-t.x)**2+(e.y-t.y)**2)}function JT(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return n-r}function YT(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return r-n}function XT(e,t){if(!e||e.length===0)return null;let[n]=e;return t?n[t]:n}function ZT(e,t,n){return t===void 0&&(t=e.left),n===void 0&&(n=e.top),{x:t+e.width*.5,y:n+e.height*.5}}var QT=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e,i=ZT(t,t.left,t.top),a=[];for(let e of r){let{id:t}=e,r=n.get(t);if(r){let n=qT(ZT(r),i);a.push({id:t,data:{droppableContainer:e,value:n}})}}return a.sort(JT)};function $T(e,t){let n=Math.max(t.top,e.top),r=Math.max(t.left,e.left),i=Math.min(t.left+t.width,e.left+e.width),a=Math.min(t.top+t.height,e.top+e.height),o=i-r,s=a-n;if(r<i&&n<a){let n=t.width*t.height,r=e.width*e.height,i=o*s,a=i/(n+r-i);return Number(a.toFixed(4))}return 0}var eE=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e,i=[];for(let e of r){let{id:r}=e,a=n.get(r);if(a){let n=$T(a,t);n>0&&i.push({id:r,data:{droppableContainer:e,value:n}})}}return i.sort(YT)};function tE(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function nE(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:KT}function rE(e){return function(t){return[...arguments].slice(1).reduce((t,n)=>({...t,top:t.top+e*n.y,bottom:t.bottom+e*n.y,left:t.left+e*n.x,right:t.right+e*n.x}),{...t})}}var iE=rE(1);function aE(e){if(e.startsWith(`matrix3d(`)){let t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}else if(e.startsWith(`matrix(`)){let t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}function oE(e,t,n){let r=aE(t);if(!r)return e;let{scaleX:i,scaleY:a,x:o,y:s}=r,c=e.left-o-(1-i)*parseFloat(n),l=e.top-s-(1-a)*parseFloat(n.slice(n.indexOf(` `)+1)),u=i?e.width/i:e.width,d=a?e.height/a:e.height;return{width:u,height:d,top:l,right:c+u,bottom:l+d,left:c}}var sE={ignoreTransform:!1};function cE(e,t){t===void 0&&(t=sE);let n=e.getBoundingClientRect();if(t.ignoreTransform){let{transform:t,transformOrigin:r}=cT(e).getComputedStyle(e);t&&(n=oE(n,t,r))}let{top:r,left:i,width:a,height:o,bottom:s,right:c}=n;return{top:r,left:i,width:a,height:o,bottom:s,right:c}}function lE(e){return cE(e,{ignoreTransform:!0})}function uE(e){let t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function dE(e,t){return t===void 0&&(t=cT(e).getComputedStyle(e)),t.position===`fixed`}function fE(e,t){t===void 0&&(t=cT(e).getComputedStyle(e));let n=/(auto|scroll|overlay)/;return[`overflow`,`overflowX`,`overflowY`].some(e=>{let r=t[e];return typeof r==`string`?n.test(r):!1})}function pE(e,t){let n=[];function r(i){if(t!=null&&n.length>=t||!i)return n;if(lT(i)&&i.scrollingElement!=null&&!n.includes(i.scrollingElement))return n.push(i.scrollingElement),n;if(!uT(i)||dT(i)||n.includes(i))return n;let a=cT(e).getComputedStyle(i);return i!==e&&fE(i,a)&&n.push(i),dE(i,a)?n:r(i.parentNode)}return e?r(e):n}function mE(e){let[t]=pE(e,1);return t??null}function hE(e){return!aT||!e?null:oT(e)?e:sT(e)?lT(e)||e===fT(e).scrollingElement?window:uT(e)?e:null:null}function gE(e){return oT(e)?e.scrollX:e.scrollLeft}function _E(e){return oT(e)?e.scrollY:e.scrollTop}function vE(e){return{x:gE(e),y:_E(e)}}var yE;(function(e){e[e.Forward=1]=`Forward`,e[e.Backward=-1]=`Backward`})(yE||={});function bE(e){return!aT||!e?!1:e===document.scrollingElement}function xE(e){let t={x:0,y:0},n=bE(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},r={x:e.scrollWidth-n.width,y:e.scrollHeight-n.height};return{isTop:e.scrollTop<=t.y,isLeft:e.scrollLeft<=t.x,isBottom:e.scrollTop>=r.y,isRight:e.scrollLeft>=r.x,maxScroll:r,minScroll:t}}var SE={x:.2,y:.2};function CE(e,t,n,r,i){let{top:a,left:o,right:s,bottom:c}=n;r===void 0&&(r=10),i===void 0&&(i=SE);let{isTop:l,isBottom:u,isLeft:d,isRight:f}=xE(e),p={x:0,y:0},m={x:0,y:0},h={height:t.height*i.y,width:t.width*i.x};return!l&&a<=t.top+h.height?(p.y=yE.Backward,m.y=r*Math.abs((t.top+h.height-a)/h.height)):!u&&c>=t.bottom-h.height&&(p.y=yE.Forward,m.y=r*Math.abs((t.bottom-h.height-c)/h.height)),!f&&s>=t.right-h.width?(p.x=yE.Forward,m.x=r*Math.abs((t.right-h.width-s)/h.width)):!d&&o<=t.left+h.width&&(p.x=yE.Backward,m.x=r*Math.abs((t.left+h.width-o)/h.width)),{direction:p,speed:m}}function wE(e){if(e===document.scrollingElement){let{innerWidth:e,innerHeight:t}=window;return{top:0,left:0,right:e,bottom:t,width:e,height:t}}let{top:t,left:n,right:r,bottom:i}=e.getBoundingClientRect();return{top:t,left:n,right:r,bottom:i,width:e.clientWidth,height:e.clientHeight}}function TE(e){return e.reduce((e,t)=>CT(e,vE(t)),KT)}function EE(e){return e.reduce((e,t)=>e+gE(t),0)}function DE(e){return e.reduce((e,t)=>e+_E(t),0)}function OE(e,t){if(t===void 0&&(t=cE),!e)return;let{top:n,left:r,bottom:i,right:a}=t(e);mE(e)&&(i<=0||a<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:`center`,inline:`center`})}var kE=[[`x`,[`left`,`right`],EE],[`y`,[`top`,`bottom`],DE]],AE=class{constructor(e,t){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;let n=pE(t),r=TE(n);this.rect={...e},this.width=e.width,this.height=e.height;for(let[e,t,i]of kE)for(let a of t)Object.defineProperty(this,a,{get:()=>{let t=i(n),o=r[e]-t;return this.rect[a]+o},enumerable:!0});Object.defineProperty(this,`rect`,{enumerable:!1})}},jE=class{constructor(e){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(e=>this.target?.removeEventListener(...e))},this.target=e}add(e,t,n){var r;(r=this.target)==null||r.addEventListener(e,t,n),this.listeners.push([e,t,n])}};function ME(e){let{EventTarget:t}=cT(e);return e instanceof t?e:fT(e)}function NE(e,t){let n=Math.abs(e.x),r=Math.abs(e.y);return typeof t==`number`?Math.sqrt(n**2+r**2)>t:`x`in t&&`y`in t?n>t.x&&r>t.y:`x`in t?n>t.x:`y`in t?r>t.y:!1}var PE;(function(e){e.Click=`click`,e.DragStart=`dragstart`,e.Keydown=`keydown`,e.ContextMenu=`contextmenu`,e.Resize=`resize`,e.SelectionChange=`selectionchange`,e.VisibilityChange=`visibilitychange`})(PE||={});function FE(e){e.preventDefault()}function IE(e){e.stopPropagation()}var LE;(function(e){e.Space=`Space`,e.Down=`ArrowDown`,e.Right=`ArrowRight`,e.Left=`ArrowLeft`,e.Up=`ArrowUp`,e.Esc=`Escape`,e.Enter=`Enter`,e.Tab=`Tab`})(LE||={});var RE={start:[LE.Space,LE.Enter],cancel:[LE.Esc],end:[LE.Space,LE.Enter,LE.Tab]},zE=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case LE.Right:return{...n,x:n.x+25};case LE.Left:return{...n,x:n.x-25};case LE.Down:return{...n,y:n.y+25};case LE.Up:return{...n,y:n.y-25}}},BE=class{constructor(e){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=e;let{event:{target:t}}=e;this.props=e,this.listeners=new jE(fT(t)),this.windowListeners=new jE(cT(t)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(PE.Resize,this.handleCancel),this.windowListeners.add(PE.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(PE.Keydown,this.handleKeyDown))}handleStart(){let{activeNode:e,onStart:t}=this.props,n=e.node.current;n&&OE(n),t(KT)}handleKeyDown(e){if(ET(e)){let{active:t,context:n,options:r}=this.props,{keyboardCodes:i=RE,coordinateGetter:a=zE,scrollBehavior:o=`smooth`}=r,{code:s}=e;if(i.end.includes(s)){this.handleEnd(e);return}if(i.cancel.includes(s)){this.handleCancel(e);return}let{collisionRect:c}=n.current,l=c?{x:c.left,y:c.top}:KT;this.referenceCoordinates||=l;let u=a(e,{active:t,context:n.current,currentCoordinates:l});if(u){let t=wT(u,l),r={x:0,y:0},{scrollableAncestors:i}=n.current;for(let n of i){let i=e.code,{isTop:a,isRight:s,isLeft:c,isBottom:l,maxScroll:d,minScroll:f}=xE(n),p=wE(n),m={x:Math.min(i===LE.Right?p.right-p.width/2:p.right,Math.max(i===LE.Right?p.left:p.left+p.width/2,u.x)),y:Math.min(i===LE.Down?p.bottom-p.height/2:p.bottom,Math.max(i===LE.Down?p.top:p.top+p.height/2,u.y))},h=i===LE.Right&&!s||i===LE.Left&&!c,g=i===LE.Down&&!l||i===LE.Up&&!a;if(h&&m.x!==u.x){let e=n.scrollLeft+t.x,a=i===LE.Right&&e<=d.x||i===LE.Left&&e>=f.x;if(a&&!t.y){n.scrollTo({left:e,behavior:o});return}a?r.x=n.scrollLeft-e:r.x=i===LE.Right?n.scrollLeft-d.x:n.scrollLeft-f.x,r.x&&n.scrollBy({left:-r.x,behavior:o});break}else if(g&&m.y!==u.y){let e=n.scrollTop+t.y,a=i===LE.Down&&e<=d.y||i===LE.Up&&e>=f.y;if(a&&!t.x){n.scrollTo({top:e,behavior:o});return}a?r.y=n.scrollTop-e:r.y=i===LE.Down?n.scrollTop-d.y:n.scrollTop-f.y,r.y&&n.scrollBy({top:-r.y,behavior:o});break}}this.handleMove(e,CT(wT(u,this.referenceCoordinates),r))}}}handleMove(e,t){let{onMove:n}=this.props;e.preventDefault(),n(t)}handleEnd(e){let{onEnd:t}=this.props;e.preventDefault(),this.detach(),t()}handleCancel(e){let{onCancel:t}=this.props;e.preventDefault(),this.detach(),t()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}};BE.activators=[{eventName:`onKeyDown`,handler:(e,t,n)=>{let{keyboardCodes:r=RE,onActivation:i}=t,{active:a}=n,{code:o}=e.nativeEvent;if(r.start.includes(o)){let t=a.activatorNode.current;return t&&e.target!==t?!1:(e.preventDefault(),i?.({event:e.nativeEvent}),!0)}return!1}}];function VE(e){return!!(e&&`distance`in e)}function HE(e){return!!(e&&`delay`in e)}var UE=class{constructor(e,t,n){n===void 0&&(n=ME(e.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=e,this.events=t;let{event:r}=e,{target:i}=r;this.props=e,this.events=t,this.document=fT(i),this.documentListeners=new jE(this.document),this.listeners=new jE(n),this.windowListeners=new jE(cT(i)),this.initialCoordinates=OT(r)??KT,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){let{events:e,props:{options:{activationConstraint:t,bypassActivationConstraint:n}}}=this;if(this.listeners.add(e.move.name,this.handleMove,{passive:!1}),this.listeners.add(e.end.name,this.handleEnd),e.cancel&&this.listeners.add(e.cancel.name,this.handleCancel),this.windowListeners.add(PE.Resize,this.handleCancel),this.windowListeners.add(PE.DragStart,FE),this.windowListeners.add(PE.VisibilityChange,this.handleCancel),this.windowListeners.add(PE.ContextMenu,FE),this.documentListeners.add(PE.Keydown,this.handleKeydown),t){if(n!=null&&n({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(HE(t)){this.timeoutId=setTimeout(this.handleStart,t.delay),this.handlePending(t);return}if(VE(t)){this.handlePending(t);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(e,t){let{active:n,onPending:r}=this.props;r(n,e,this.initialCoordinates,t)}handleStart(){let{initialCoordinates:e}=this,{onStart:t}=this.props;e&&(this.activated=!0,this.documentListeners.add(PE.Click,IE,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(PE.SelectionChange,this.removeTextSelection),t(e))}handleMove(e){let{activated:t,initialCoordinates:n,props:r}=this,{onMove:i,options:{activationConstraint:a}}=r;if(!n)return;let o=OT(e)??KT,s=wT(n,o);if(!t&&a){if(VE(a)){if(a.tolerance!=null&&NE(s,a.tolerance))return this.handleCancel();if(NE(s,a.distance))return this.handleStart()}if(HE(a)&&NE(s,a.tolerance))return this.handleCancel();this.handlePending(a,s);return}e.cancelable&&e.preventDefault(),i(o)}handleEnd(){let{onAbort:e,onEnd:t}=this.props;this.detach(),this.activated||e(this.props.active),t()}handleCancel(){let{onAbort:e,onCancel:t}=this.props;this.detach(),this.activated||e(this.props.active),t()}handleKeydown(e){e.code===LE.Esc&&this.handleCancel()}removeTextSelection(){var e;(e=this.document.getSelection())==null||e.removeAllRanges()}},WE={cancel:{name:`pointercancel`},move:{name:`pointermove`},end:{name:`pointerup`}},GE=class extends UE{constructor(e){let{event:t}=e,n=fT(t.target);super(e,WE,n)}};GE.activators=[{eventName:`onPointerDown`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return!n.isPrimary||n.button!==0?!1:(r?.({event:n}),!0)}}];var KE={move:{name:`mousemove`},end:{name:`mouseup`}},qE;(function(e){e[e.RightClick=2]=`RightClick`})(qE||={});var JE=class extends UE{constructor(e){super(e,KE,fT(e.event.target))}};JE.activators=[{eventName:`onMouseDown`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button===qE.RightClick?!1:(r?.({event:n}),!0)}}];var YE={cancel:{name:`touchcancel`},move:{name:`touchmove`},end:{name:`touchend`}},XE=class extends UE{constructor(e){super(e,YE)}static setup(){return window.addEventListener(YE.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(YE.move.name,e)};function e(){}}};XE.activators=[{eventName:`onTouchStart`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t,{touches:i}=n;return i.length>1?!1:(r?.({event:n}),!0)}}];var ZE;(function(e){e[e.Pointer=0]=`Pointer`,e[e.DraggableRect=1]=`DraggableRect`})(ZE||={});var QE;(function(e){e[e.TreeOrder=0]=`TreeOrder`,e[e.ReversedTreeOrder=1]=`ReversedTreeOrder`})(QE||={});function $E(e){let{acceleration:t,activator:n=ZE.Pointer,canScroll:r,draggingRect:i,enabled:a,interval:o=5,order:s=QE.TreeOrder,pointerCoordinates:c,scrollableAncestors:l,scrollableAncestorRects:u,delta:d,threshold:f}=e,p=tD({delta:d,disabled:!a}),[m,h]=hT(),g=(0,v.useRef)({x:0,y:0}),_=(0,v.useRef)({x:0,y:0}),y=(0,v.useMemo)(()=>{switch(n){case ZE.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case ZE.DraggableRect:return i}},[n,i,c]),b=(0,v.useRef)(null),x=(0,v.useCallback)(()=>{let e=b.current;if(!e)return;let t=g.current.x*_.current.x,n=g.current.y*_.current.y;e.scrollBy(t,n)},[]),S=(0,v.useMemo)(()=>s===QE.TreeOrder?[...l].reverse():l,[s,l]);(0,v.useEffect)(()=>{if(!a||!l.length||!y){h();return}for(let e of S){if(r?.(e)===!1)continue;let n=u[l.indexOf(e)];if(!n)continue;let{direction:i,speed:a}=CE(e,n,y,t,f);for(let e of[`x`,`y`])p[e][i[e]]||(a[e]=0,i[e]=0);if(a.x>0||a.y>0){h(),b.current=e,m(x,o),g.current=a,_.current=i;return}}g.current={x:0,y:0},_.current={x:0,y:0},h()},[t,x,r,h,a,o,JSON.stringify(y),JSON.stringify(p),m,l,S,u,JSON.stringify(f)])}var eD={x:{[yE.Backward]:!1,[yE.Forward]:!1},y:{[yE.Backward]:!1,[yE.Forward]:!1}};function tD(e){let{delta:t,disabled:n}=e,r=yT(t);return _T(e=>{if(n||!r||!e)return eD;let i={x:Math.sign(t.x-r.x),y:Math.sign(t.y-r.y)};return{x:{[yE.Backward]:e.x[yE.Backward]||i.x===-1,[yE.Forward]:e.x[yE.Forward]||i.x===1},y:{[yE.Backward]:e.y[yE.Backward]||i.y===-1,[yE.Forward]:e.y[yE.Forward]||i.y===1}}},[n,t,r])}function nD(e,t){let n=t==null?void 0:e.get(t),r=n?n.node.current:null;return _T(e=>t==null?null:r??e??null,[r,t])}function rD(e,t){return(0,v.useMemo)(()=>e.reduce((e,n)=>{let{sensor:r}=n,i=r.activators.map(e=>({eventName:e.eventName,handler:t(e.handler,n)}));return[...e,...i]},[]),[e,t])}var iD;(function(e){e[e.Always=0]=`Always`,e[e.BeforeDragging=1]=`BeforeDragging`,e[e.WhileDragging=2]=`WhileDragging`})(iD||={});var aD;(function(e){e.Optimized=`optimized`})(aD||={});var oD=new Map;function sD(e,t){let{dragging:n,dependencies:r,config:i}=t,[a,o]=(0,v.useState)(null),{frequency:s,measure:c,strategy:l}=i,u=(0,v.useRef)(e),d=g(),f=gT(d),p=(0,v.useCallback)(function(e){e===void 0&&(e=[]),!f.current&&o(t=>t===null?e:t.concat(e.filter(e=>!t.includes(e))))},[f]),m=(0,v.useRef)(null),h=_T(t=>{if(d&&!n)return oD;if(!t||t===oD||u.current!==e||a!=null){let t=new Map;for(let n of e){if(!n)continue;if(a&&a.length>0&&!a.includes(n.id)&&n.rect.current){t.set(n.id,n.rect.current);continue}let e=n.node.current,r=e?new AE(c(e),e):null;n.rect.current=r,r&&t.set(n.id,r)}return t}return t},[e,a,n,d,c]);return(0,v.useEffect)(()=>{u.current=e},[e]),(0,v.useEffect)(()=>{d||p()},[n,d]),(0,v.useEffect)(()=>{a&&a.length>0&&o(null)},[JSON.stringify(a)]),(0,v.useEffect)(()=>{d||typeof s!=`number`||m.current!==null||(m.current=setTimeout(()=>{p(),m.current=null},s))},[s,d,p,...r]),{droppableRects:h,measureDroppableContainers:p,measuringScheduled:a!=null};function g(){switch(l){case iD.Always:return!1;case iD.BeforeDragging:return n;default:return!n}}}function cD(e,t){return _T(n=>e?n||(typeof t==`function`?t(e):e):null,[t,e])}function lD(e,t){return cD(e,t)}function uD(e){let{callback:t,disabled:n}=e,r=mT(t),i=(0,v.useMemo)(()=>{if(n||typeof window>`u`||window.MutationObserver===void 0)return;let{MutationObserver:e}=window;return new e(r)},[r,n]);return(0,v.useEffect)(()=>()=>i?.disconnect(),[i]),i}function dD(e){let{callback:t,disabled:n}=e,r=mT(t),i=(0,v.useMemo)(()=>{if(n||typeof window>`u`||window.ResizeObserver===void 0)return;let{ResizeObserver:e}=window;return new e(r)},[n]);return(0,v.useEffect)(()=>()=>i?.disconnect(),[i]),i}function fD(e){return new AE(cE(e),e)}function pD(e,t,n){t===void 0&&(t=fD);let[r,i]=(0,v.useState)(null);function a(){i(r=>{if(!e)return null;if(e.isConnected===!1)return r??n??null;let i=t(e);return JSON.stringify(r)===JSON.stringify(i)?r:i})}let o=uD({callback(t){if(e)for(let n of t){let{type:t,target:r}=n;if(t===`childList`&&r instanceof HTMLElement&&r.contains(e)){a();break}}}}),s=dD({callback:a});return pT(()=>{a(),e?(s?.observe(e),o?.observe(document.body,{childList:!0,subtree:!0})):(s?.disconnect(),o?.disconnect())},[e]),r}function mD(e){return nE(e,cD(e))}var hD=[];function gD(e){let t=(0,v.useRef)(e),n=_T(n=>e?n&&n!==hD&&e&&t.current&&e.parentNode===t.current.parentNode?n:pE(e):hD,[e]);return(0,v.useEffect)(()=>{t.current=e},[e]),n}function _D(e){let[t,n]=(0,v.useState)(null),r=(0,v.useRef)(e),i=(0,v.useCallback)(e=>{let t=hE(e.target);t&&n(e=>e?(e.set(t,vE(t)),new Map(e)):null)},[]);return(0,v.useEffect)(()=>{let t=r.current;if(e!==t){a(t);let o=e.map(e=>{let t=hE(e);return t?(t.addEventListener(`scroll`,i,{passive:!0}),[t,vE(t)]):null}).filter(e=>e!=null);n(o.length?new Map(o):null),r.current=e}return()=>{a(e),a(t)};function a(e){e.forEach(e=>{hE(e)?.removeEventListener(`scroll`,i)})}},[i,e]),(0,v.useMemo)(()=>e.length?t?Array.from(t.values()).reduce((e,t)=>CT(e,t),KT):TE(e):KT,[e,t])}function vD(e,t){t===void 0&&(t=[]);let n=(0,v.useRef)(null);return(0,v.useEffect)(()=>{n.current=null},t),(0,v.useEffect)(()=>{let t=e!==KT;t&&!n.current&&(n.current=e),!t&&n.current&&(n.current=null)},[e]),n.current?wT(e,n.current):KT}function yD(e){(0,v.useEffect)(()=>{if(!aT)return;let t=e.map(e=>{let{sensor:t}=e;return t.setup==null?void 0:t.setup()});return()=>{for(let e of t)e?.()}},e.map(e=>{let{sensor:t}=e;return t}))}function bD(e,t){return(0,v.useMemo)(()=>e.reduce((e,n)=>{let{eventName:r,handler:i}=n;return e[r]=e=>{i(e,t)},e},{}),[e,t])}function xD(e){return(0,v.useMemo)(()=>e?uE(e):null,[e])}var SD=[];function CD(e,t){t===void 0&&(t=cE);let[n]=e,r=xD(n?cT(n):null),[i,a]=(0,v.useState)(SD);function o(){a(()=>e.length?e.map(e=>bE(e)?r:new AE(t(e),e)):SD)}let s=dD({callback:o});return pT(()=>{s?.disconnect(),o(),e.forEach(e=>s?.observe(e))},[e]),i}function wD(e){if(!e)return null;if(e.children.length>1)return e;let t=e.children[0];return uT(t)?t:e}function TD(e){let{measure:t}=e,[n,r]=(0,v.useState)(null),i=dD({callback:(0,v.useCallback)(e=>{for(let{target:n}of e)if(uT(n)){r(e=>{let r=t(n);return e?{...e,width:r.width,height:r.height}:r});break}},[t])}),[a,o]=vT((0,v.useCallback)(e=>{let n=wD(e);i?.disconnect(),n&&i?.observe(n),r(n?t(n):null)},[t,i]));return(0,v.useMemo)(()=>({nodeRef:a,rect:n,setRef:o}),[n,a,o])}var ED=[{sensor:GE,options:{}},{sensor:BE,options:{}}],DD={current:{}},OD={draggable:{measure:lE},droppable:{measure:lE,strategy:iD.WhileDragging,frequency:aD.Optimized},dragOverlay:{measure:cE}},kD=class extends Map{get(e){return e==null?void 0:super.get(e)??void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(e=>{let{disabled:t}=e;return!t})}getNodeFor(e){return this.get(e)?.node.current??void 0}},AD={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new kD,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:UT},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:OD,measureDroppableContainers:UT,windowRect:null,measuringScheduled:!1},jD={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:``},dispatch:UT,draggableNodes:new Map,over:null,measureDroppableContainers:UT},MD=(0,v.createContext)(jD),ND=(0,v.createContext)(AD);function PD(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new kD}}}function FD(e,t){switch(t.type){case HT.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case HT.DragMove:return e.draggable.active==null?e:{...e,draggable:{...e.draggable,translate:{x:t.coordinates.x-e.draggable.initialCoordinates.x,y:t.coordinates.y-e.draggable.initialCoordinates.y}}};case HT.DragEnd:case HT.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case HT.RegisterDroppable:{let{element:n}=t,{id:r}=n,i=new kD(e.droppable.containers);return i.set(r,n),{...e,droppable:{...e.droppable,containers:i}}}case HT.SetDroppableDisabled:{let{id:n,key:r,disabled:i}=t,a=e.droppable.containers.get(n);if(!a||r!==a.key)return e;let o=new kD(e.droppable.containers);return o.set(n,{...a,disabled:i}),{...e,droppable:{...e.droppable,containers:o}}}case HT.UnregisterDroppable:{let{id:n,key:r}=t,i=e.droppable.containers.get(n);if(!i||r!==i.key)return e;let a=new kD(e.droppable.containers);return a.delete(n),{...e,droppable:{...e.droppable,containers:a}}}default:return e}}function ID(e){let{disabled:t}=e,{active:n,activatorEvent:r,draggableNodes:i}=(0,v.useContext)(MD),a=yT(r),o=yT(n?.id);return(0,v.useEffect)(()=>{if(!t&&!r&&a&&o!=null){if(!ET(a)||document.activeElement===a.target)return;let e=i.get(o);if(!e)return;let{activatorNode:t,node:n}=e;if(!t.current&&!n.current)return;requestAnimationFrame(()=>{for(let e of[t.current,n.current]){if(!e)continue;let t=jT(e);if(t){t.focus();break}}})}},[r,t,i,o,a]),null}function LD(e,t){let{transform:n,...r}=t;return e!=null&&e.length?e.reduce((e,t)=>t({transform:e,...r}),n):n}function RD(e){return(0,v.useMemo)(()=>({draggable:{...OD.draggable,...e?.draggable},droppable:{...OD.droppable,...e?.droppable},dragOverlay:{...OD.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function zD(e){let{activeNode:t,measure:n,initialRect:r,config:i=!0}=e,a=(0,v.useRef)(!1),{x:o,y:s}=typeof i==`boolean`?{x:i,y:i}:i;pT(()=>{if(!o&&!s||!t){a.current=!1;return}if(a.current||!r)return;let e=t?.node.current;if(!e||e.isConnected===!1)return;let i=nE(n(e),r);if(o||(i.x=0),s||(i.y=0),a.current=!0,Math.abs(i.x)>0||Math.abs(i.y)>0){let t=mE(e);t&&t.scrollBy({top:i.y,left:i.x})}},[t,o,s,r,n])}var BD=(0,v.createContext)({...KT,scaleX:1,scaleY:1}),VD;(function(e){e[e.Uninitialized=0]=`Uninitialized`,e[e.Initializing=1]=`Initializing`,e[e.Initialized=2]=`Initialized`})(VD||={});var HD=(0,v.memo)(function(e){let{id:t,accessibility:n,autoScroll:r=!0,children:i,sensors:a=ED,collisionDetection:o=eE,measuring:s,modifiers:c,...l}=e,[u,d]=(0,v.useReducer)(FD,void 0,PD),[f,p]=RT(),[m,h]=(0,v.useState)(VD.Uninitialized),g=m===VD.Initialized,{draggable:{active:_,nodes:y,translate:b},droppable:{containers:x}}=u,S=_==null?null:y.get(_),C=(0,v.useRef)({initial:null,translated:null}),w=(0,v.useMemo)(()=>_==null?null:{id:_,data:S?.data??DD,rect:C},[_,S]),T=(0,v.useRef)(null),[E,D]=(0,v.useState)(null),[O,k]=(0,v.useState)(null),A=gT(l,Object.values(l)),j=xT(`DndDescribedBy`,t),M=(0,v.useMemo)(()=>x.getEnabled(),[x]),P=RD(s),{droppableRects:F,measureDroppableContainers:I,measuringScheduled:L}=sD(M,{dragging:g,dependencies:[b.x,b.y],config:P.droppable}),R=nD(y,_),ee=(0,v.useMemo)(()=>O?OT(O):null,[O]),te=Oe(),z=lD(R,P.draggable.measure);zD({activeNode:_==null?null:y.get(_),config:te.layoutShiftCompensation,initialRect:z,measure:P.draggable.measure});let B=pD(R,P.draggable.measure,z),V=pD(R?R.parentElement:null),ne=(0,v.useRef)({activatorEvent:null,active:null,activeNode:R,collisionRect:null,collisions:null,droppableRects:F,draggableNodes:y,draggingNode:null,draggingNodeRect:null,droppableContainers:x,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),H=x.getNodeFor(ne.current.over?.id),re=TD({measure:P.dragOverlay.measure}),ie=re.nodeRef.current??R,ae=g?re.rect??B:null,oe=!!(re.nodeRef.current&&re.rect),se=mD(oe?null:B),ce=xD(ie?cT(ie):null),le=gD(g?H??R:null),ue=CD(le),de=LD(c,{transform:{x:b.x-se.x,y:b.y-se.y,scaleX:1,scaleY:1},activatorEvent:O,active:w,activeNodeRect:B,containerNodeRect:V,draggingNodeRect:ae,over:ne.current.over,overlayNodeRect:re.rect,scrollableAncestors:le,scrollableAncestorRects:ue,windowRect:ce}),fe=ee?CT(ee,b):null,pe=_D(le),me=vD(pe),he=vD(pe,[B]),ge=CT(de,me),_e=ae?iE(ae,de):null,ve=w&&_e?o({active:w,collisionRect:_e,droppableRects:F,droppableContainers:M,pointerCoordinates:fe}):null,ye=XT(ve,`id`),[be,xe]=(0,v.useState)(null),Se=tE(oe?de:CT(de,he),be?.rect??null,B),Ce=(0,v.useRef)(null),we=(0,v.useCallback)((e,t)=>{let{sensor:n,options:r}=t;if(T.current==null)return;let i=y.get(T.current);if(!i)return;let a=e.nativeEvent;Ce.current=new n({active:T.current,activeNode:i,event:a,options:r,context:ne,onAbort(e){if(!y.get(e))return;let{onDragAbort:t}=A.current,n={id:e};t?.(n),f({type:`onDragAbort`,event:n})},onPending(e,t,n,r){if(!y.get(e))return;let{onDragPending:i}=A.current,a={id:e,constraint:t,initialCoordinates:n,offset:r};i?.(a),f({type:`onDragPending`,event:a})},onStart(e){let t=T.current;if(t==null)return;let n=y.get(t);if(!n)return;let{onDragStart:r}=A.current,i={activatorEvent:a,active:{id:t,data:n.data,rect:C}};(0,N.unstable_batchedUpdates)(()=>{r?.(i),h(VD.Initializing),d({type:HT.DragStart,initialCoordinates:e,active:t}),f({type:`onDragStart`,event:i}),D(Ce.current),k(a)})},onMove(e){d({type:HT.DragMove,coordinates:e})},onEnd:o(HT.DragEnd),onCancel:o(HT.DragCancel)});function o(e){return async function(){let{active:t,collisions:n,over:r,scrollAdjustedTranslate:i}=ne.current,o=null;if(t&&i){let{cancelDrop:s}=A.current;o={activatorEvent:a,active:t,collisions:n,delta:i,over:r},e===HT.DragEnd&&typeof s==`function`&&await Promise.resolve(s(o))&&(e=HT.DragCancel)}T.current=null,(0,N.unstable_batchedUpdates)(()=>{d({type:e}),h(VD.Uninitialized),xe(null),D(null),k(null),Ce.current=null;let t=e===HT.DragEnd?`onDragEnd`:`onDragCancel`;if(o){let e=A.current[t];e?.(o),f({type:t,event:o})}})}}},[y]),Te=rD(a,(0,v.useCallback)((e,t)=>(n,r)=>{let i=n.nativeEvent,a=y.get(r);if(T.current!==null||!a||i.dndKit||i.defaultPrevented)return;let o={active:a};e(n,t.options,o)===!0&&(i.dndKit={capturedBy:t.sensor},T.current=r,we(n,t))},[y,we]));yD(a),pT(()=>{B&&m===VD.Initializing&&h(VD.Initialized)},[B,m]),(0,v.useEffect)(()=>{let{onDragMove:e}=A.current,{active:t,activatorEvent:n,collisions:r,over:i}=ne.current;if(!t||!n)return;let a={active:t,activatorEvent:n,collisions:r,delta:{x:ge.x,y:ge.y},over:i};(0,N.unstable_batchedUpdates)(()=>{e?.(a),f({type:`onDragMove`,event:a})})},[ge.x,ge.y]),(0,v.useEffect)(()=>{let{active:e,activatorEvent:t,collisions:n,droppableContainers:r,scrollAdjustedTranslate:i}=ne.current;if(!e||T.current==null||!t||!i)return;let{onDragOver:a}=A.current,o=r.get(ye),s=o&&o.rect.current?{id:o.id,rect:o.rect.current,data:o.data,disabled:o.disabled}:null,c={active:e,activatorEvent:t,collisions:n,delta:{x:i.x,y:i.y},over:s};(0,N.unstable_batchedUpdates)(()=>{xe(s),a?.(c),f({type:`onDragOver`,event:c})})},[ye]),pT(()=>{ne.current={activatorEvent:O,active:w,activeNode:R,collisionRect:_e,collisions:ve,droppableRects:F,draggableNodes:y,draggingNode:ie,draggingNodeRect:ae,droppableContainers:x,over:be,scrollableAncestors:le,scrollAdjustedTranslate:ge},C.current={initial:ae,translated:_e}},[w,R,ve,_e,y,ie,ae,F,x,be,le,ge]),$E({...te,delta:b,draggingRect:_e,pointerCoordinates:fe,scrollableAncestors:le,scrollableAncestorRects:ue});let Ee=(0,v.useMemo)(()=>({active:w,activeNode:R,activeNodeRect:B,activatorEvent:O,collisions:ve,containerNodeRect:V,dragOverlay:re,draggableNodes:y,droppableContainers:x,droppableRects:F,over:be,measureDroppableContainers:I,scrollableAncestors:le,scrollableAncestorRects:ue,measuringConfiguration:P,measuringScheduled:L,windowRect:ce}),[w,R,B,O,ve,V,re,y,x,F,be,I,le,ue,P,L,ce]),De=(0,v.useMemo)(()=>({activatorEvent:O,activators:Te,active:w,activeNodeRect:B,ariaDescribedById:{draggable:j},dispatch:d,draggableNodes:y,over:be,measureDroppableContainers:I}),[O,Te,w,B,d,j,y,be,I]);return v.createElement(IT.Provider,{value:p},v.createElement(MD.Provider,{value:De},v.createElement(ND.Provider,{value:Ee},v.createElement(BD.Provider,{value:Se},i)),v.createElement(ID,{disabled:n?.restoreFocus===!1})),v.createElement(VT,{...n,hiddenTextDescribedById:j}));function Oe(){let e=E?.autoScrollEnabled===!1,t=typeof r==`object`?r.enabled===!1:r===!1,n=g&&!e&&!t;return typeof r==`object`?{...r,enabled:n}:{enabled:n}}}),UD=(0,v.createContext)(null),WD=`button`,GD=`Draggable`;function KD(e){let{id:t,data:n,disabled:r=!1,attributes:i}=e,a=xT(GD),{activators:o,activatorEvent:s,active:c,activeNodeRect:l,ariaDescribedById:u,draggableNodes:d,over:f}=(0,v.useContext)(MD),{role:p=WD,roleDescription:m=`draggable`,tabIndex:h=0}=i??{},g=c?.id===t,_=(0,v.useContext)(g?BD:UD),[y,b]=vT(),[x,S]=vT(),C=bD(o,t),w=gT(n);return pT(()=>(d.set(t,{id:t,key:a,node:y,activatorNode:x,data:w}),()=>{let e=d.get(t);e&&e.key===a&&d.delete(t)}),[d,t]),{active:c,activatorEvent:s,activeNodeRect:l,attributes:(0,v.useMemo)(()=>({role:p,tabIndex:h,"aria-disabled":r,"aria-pressed":g&&p===WD?!0:void 0,"aria-roledescription":m,"aria-describedby":u.draggable}),[r,p,h,g,m,u.draggable]),isDragging:g,listeners:r?void 0:C,node:y,over:f,setNodeRef:b,setActivatorNodeRef:S,transform:_}}function qD(){return(0,v.useContext)(ND)}var JD=`Droppable`,YD={timeout:25};function XD(e){let{data:t,disabled:n=!1,id:r,resizeObserverConfig:i}=e,a=xT(JD),{active:o,dispatch:s,over:c,measureDroppableContainers:l}=(0,v.useContext)(MD),u=(0,v.useRef)({disabled:n}),d=(0,v.useRef)(!1),f=(0,v.useRef)(null),p=(0,v.useRef)(null),{disabled:m,updateMeasurementsFor:h,timeout:g}={...YD,...i},_=gT(h??r),y=dD({callback:(0,v.useCallback)(()=>{if(!d.current){d.current=!0;return}p.current!=null&&clearTimeout(p.current),p.current=setTimeout(()=>{l(Array.isArray(_.current)?_.current:[_.current]),p.current=null},g)},[g]),disabled:m||!o}),[b,x]=vT((0,v.useCallback)((e,t)=>{y&&(t&&(y.unobserve(t),d.current=!1),e&&y.observe(e))},[y])),S=gT(t);return(0,v.useEffect)(()=>{!y||!b.current||(y.disconnect(),d.current=!1,y.observe(b.current))},[b,y]),(0,v.useEffect)(()=>(s({type:HT.RegisterDroppable,element:{id:r,key:a,disabled:n,node:b,rect:f,data:S}}),()=>s({type:HT.UnregisterDroppable,key:a,id:r})),[r]),(0,v.useEffect)(()=>{n!==u.current.disabled&&(s({type:HT.SetDroppableDisabled,id:r,key:a,disabled:n}),u.current.disabled=n)},[r,a,n,s]),{active:o,rect:f,isOver:c?.id===r,node:b,over:c,setNodeRef:x}}function ZD(e,t,n){let r=e.slice();return r.splice(n<0?r.length+n:n,0,r.splice(t,1)[0]),r}function QD(e,t){return e.reduce((e,n,r)=>{let i=t.get(n);return i&&(e[r]=i),e},Array(e.length))}function $D(e){return e!==null&&e>=0}function eO(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function tO(e){return typeof e==`boolean`?{draggable:e,droppable:e}:e}var nO=e=>{let{rects:t,activeIndex:n,overIndex:r,index:i}=e,a=ZD(t,r,n),o=t[i],s=a[i];return!s||!o?null:{x:s.left-o.left,y:s.top-o.top,scaleX:s.width/o.width,scaleY:s.height/o.height}},rO={scaleX:1,scaleY:1},iO=e=>{let{activeIndex:t,activeNodeRect:n,index:r,rects:i,overIndex:a}=e,o=i[t]??n;if(!o)return null;if(r===t){let e=i[a];return e?{x:0,y:t<a?e.top+e.height-(o.top+o.height):e.top-o.top,...rO}:null}let s=aO(i,r,t);return r>t&&r<=a?{x:0,y:-o.height-s,...rO}:r<t&&r>=a?{x:0,y:o.height+s,...rO}:{x:0,y:0,...rO}};function aO(e,t,n){let r=e[t],i=e[t-1],a=e[t+1];return r?n<t?i?r.top-(i.top+i.height):a?a.top-(r.top+r.height):0:a?a.top-(r.top+r.height):i?r.top-(i.top+i.height):0:0}var oO=`Sortable`,sO=v.createContext({activeIndex:-1,containerId:oO,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:nO,disabled:{draggable:!1,droppable:!1}});function cO(e){let{children:t,id:n,items:r,strategy:i=nO,disabled:a=!1}=e,{active:o,dragOverlay:s,droppableRects:c,over:l,measureDroppableContainers:u}=qD(),d=xT(oO,n),f=s.rect!==null,p=(0,v.useMemo)(()=>r.map(e=>typeof e==`object`&&`id`in e?e.id:e),[r]),m=o!=null,h=o?p.indexOf(o.id):-1,g=l?p.indexOf(l.id):-1,_=(0,v.useRef)(p),y=!eO(p,_.current),b=g!==-1&&h===-1||y,x=tO(a);pT(()=>{y&&m&&u(p)},[y,p,m,u]),(0,v.useEffect)(()=>{_.current=p},[p]);let S=(0,v.useMemo)(()=>({activeIndex:h,containerId:d,disabled:x,disableTransforms:b,items:p,overIndex:g,useDragOverlay:f,sortedRects:QD(p,c),strategy:i}),[h,d,x.draggable,x.droppable,b,p,g,c,f,i]);return v.createElement(sO.Provider,{value:S},t)}var lO=e=>{let{id:t,items:n,activeIndex:r,overIndex:i}=e;return ZD(n,r,i).indexOf(t)},uO=e=>{let{containerId:t,isSorting:n,wasDragging:r,index:i,items:a,newIndex:o,previousItems:s,previousContainerId:c,transition:l}=e;return!l||!r||s!==a&&i===o?!1:n?!0:o!==i&&t===c},dO={duration:200,easing:`ease`},fO=`transform`,pO=kT.Transition.toString({property:fO,duration:0,easing:`linear`}),mO={roleDescription:`sortable`};function hO(e){let{disabled:t,index:n,node:r,rect:i}=e,[a,o]=(0,v.useState)(null),s=(0,v.useRef)(n);return pT(()=>{if(!t&&n!==s.current&&r.current){let e=i.current;if(e){let t=cE(r.current,{ignoreTransform:!0}),n={x:e.left-t.left,y:e.top-t.top,scaleX:e.width/t.width,scaleY:e.height/t.height};(n.x||n.y)&&o(n)}}n!==s.current&&(s.current=n)},[t,n,r,i]),(0,v.useEffect)(()=>{a&&o(null)},[a]),a}function gO(e){let{animateLayoutChanges:t=uO,attributes:n,disabled:r,data:i,getNewIndex:a=lO,id:o,strategy:s,resizeObserverConfig:c,transition:l=dO}=e,{items:u,containerId:d,activeIndex:f,disabled:p,disableTransforms:m,sortedRects:h,overIndex:g,useDragOverlay:_,strategy:y}=(0,v.useContext)(sO),b=_O(r,p),x=u.indexOf(o),S=(0,v.useMemo)(()=>({sortable:{containerId:d,index:x,items:u},...i}),[d,i,x,u]),C=(0,v.useMemo)(()=>u.slice(u.indexOf(o)),[u,o]),{rect:w,node:T,isOver:E,setNodeRef:D}=XD({id:o,data:S,disabled:b.droppable,resizeObserverConfig:{updateMeasurementsFor:C,...c}}),{active:O,activatorEvent:k,activeNodeRect:A,attributes:j,setNodeRef:M,listeners:N,isDragging:P,over:F,setActivatorNodeRef:I,transform:L}=KD({id:o,data:S,attributes:{...mO,...n},disabled:b.draggable}),R=iT(D,M),ee=!!O,te=ee&&!m&&$D(f)&&$D(g),z=!_&&P,B=te?(z&&te?L:null)??(s??y)({rects:h,activeNodeRect:A,activeIndex:f,overIndex:g,index:x}):null,V=$D(f)&&$D(g)?a({id:o,items:u,activeIndex:f,overIndex:g}):x,ne=O?.id,H=(0,v.useRef)({activeId:ne,items:u,newIndex:V,containerId:d}),re=u!==H.current.items,ie=t({active:O,containerId:d,isDragging:P,isSorting:ee,id:o,index:x,items:u,newIndex:H.current.newIndex,previousItems:H.current.items,previousContainerId:H.current.containerId,transition:l,wasDragging:H.current.activeId!=null}),ae=hO({disabled:!ie,index:x,node:T,rect:w});return(0,v.useEffect)(()=>{ee&&H.current.newIndex!==V&&(H.current.newIndex=V),d!==H.current.containerId&&(H.current.containerId=d),u!==H.current.items&&(H.current.items=u)},[ee,V,d,u]),(0,v.useEffect)(()=>{if(ne===H.current.activeId)return;if(ne!=null&&H.current.activeId==null){H.current.activeId=ne;return}let e=setTimeout(()=>{H.current.activeId=ne},50);return()=>clearTimeout(e)},[ne]),{active:O,activeIndex:f,attributes:j,data:S,rect:w,index:x,newIndex:V,items:u,isOver:E,isSorting:ee,isDragging:P,listeners:N,node:T,overIndex:g,over:F,setNodeRef:R,setActivatorNodeRef:I,setDroppableNodeRef:D,setDraggableNodeRef:M,transform:ae??B,transition:oe()};function oe(){if(ae||re&&H.current.newIndex===x)return pO;if(!(z&&!ET(k)||!l)&&(ee||ie))return kT.Transition.toString({...l,property:fO})}}function _O(e,t){return typeof e==`boolean`?{draggable:e,droppable:!1}:{draggable:e?.draggable??t.draggable,droppable:e?.droppable??t.droppable}}LE.Down,LE.Right,LE.Up,LE.Left;function vO(e,t){let n=t.toLowerCase().split(`+`),r=n.includes(`mod`),i=n.includes(`shift`),a=n[n.length-1];return(r?e.metaKey||e.ctrlKey:!e.metaKey&&!e.ctrlKey)&&i===e.shiftKey&&!e.altKey&&e.key.toLowerCase()===a}function yO(e,t,n){let r=n?.enabled??!0,{register:i}=(0,v.useContext)(ba),a=(0,v.useRef)(t);(0,v.useEffect)(()=>{a.current=t}),(0,v.useEffect)(()=>{if(n?.label)return i(e,n.label)},[e,n?.label,i]),(0,v.useEffect)(()=>{function t(t){vO(t,e)&&(t.preventDefault(),r&&a.current())}return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e,r])}function bO(e,t){switch(e){case`string`:return{icon:Yo,label:`Text (string)`,color:`text-blue-600`,bg:`bg-blue-50`};case`text`:return{icon:Wo,label:`Long text (string)`,color:`text-sky-600`,bg:`bg-sky-50`};case`richtext`:return{icon:io,label:`Rich text (blocks)`,color:`text-violet-600`,bg:`bg-violet-50`};case`number`:return{icon:fo,label:t===`float`?`Decimal (number)`:`Integer (number)`,color:`text-orange-600`,bg:`bg-orange-50`};case`boolean`:return{icon:Ko,label:`Boolean`,color:`text-emerald-600`,bg:`bg-emerald-50`};case`datetime`:return{icon:La,label:`Date & time`,color:`text-amber-600`,bg:`bg-amber-50`};case`media`:return{icon:_o,label:`Media`,color:`text-rose-600`,bg:`bg-rose-50`};case`mixed`:return{icon:wo,label:`Mixed value`,color:`text-fuchsia-600`,bg:`bg-fuchsia-50`};case`media-gallery`:return{icon:Co,label:`Media Gallery`,color:`text-pink-600`,bg:`bg-pink-50`};case`relation`:return{icon:To,label:`Relation`,color:`text-indigo-600`,bg:`bg-indigo-50`};case`uid`:return{icon:oo,label:`UID`,color:`text-teal-600`,bg:`bg-teal-50`};case`array`:return{icon:wo,label:`Array`,color:`text-cyan-600`,bg:`bg-cyan-50`};case`navigation`:return{icon:Do,label:`Navigation`,color:`text-cyan-600`,bg:`bg-cyan-50`}}}var xO={full:`col-span-6`,"two-thirds":`col-span-4`,half:`col-span-3`,third:`col-span-2`},SO={string:`half`,text:`full`,richtext:`full`,number:`third`,boolean:`third`,datetime:`half`,media:`half`,"media-gallery":`full`,relation:`half`,uid:`half`,array:`full`,navigation:`full`};function CO({width:e}){let t=`rounded-sm bg-current`;return e===`full`?(0,U.jsx)(`div`,{className:`flex w-4 gap-px`,children:(0,U.jsx)(`div`,{className:`${t} h-2 w-full`})}):e===`two-thirds`?(0,U.jsxs)(`div`,{className:`flex w-4 gap-px`,children:[(0,U.jsx)(`div`,{className:`${t} h-2 flex-1`}),(0,U.jsx)(`div`,{className:`${t} h-2 flex-1`}),(0,U.jsx)(`div`,{className:`h-2 flex-1 rounded-sm bg-current opacity-25`})]}):e===`half`?(0,U.jsxs)(`div`,{className:`flex w-4 gap-px`,children:[(0,U.jsx)(`div`,{className:`${t} h-2 flex-1`}),(0,U.jsx)(`div`,{className:`${t} h-2 flex-1`})]}):(0,U.jsxs)(`div`,{className:`flex w-4 gap-px`,children:[(0,U.jsx)(`div`,{className:`${t} h-2 flex-1`}),(0,U.jsx)(`div`,{className:`h-2 flex-1 rounded-sm bg-current opacity-25`}),(0,U.jsx)(`div`,{className:`h-2 flex-1 rounded-sm bg-current opacity-25`})]})}var wO=[{value:`full`,label:`Full width`},{value:`half`,label:`Half`},{value:`third`,label:`1/3`},{value:`two-thirds`,label:`2/3`}];function TO({field:e,onWidthChange:t,onArraySubFieldWidthChange:n,onEdit:r,onDelete:i,dragListeners:a,dragAttributes:o}){let{icon:s,label:c,color:l,bg:u}=bO(e.type,e.subtype),d=e.width??`full`,f=!!a,p=e.type===`array`;return(0,U.jsxs)(`div`,{className:`rounded-lg border border-border bg-card shadow-xs`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-3`,children:[f&&(0,U.jsx)(`button`,{type:`button`,className:`flex shrink-0 cursor-grab items-center text-muted-foreground/40 hover:text-muted-foreground active:cursor-grabbing`,...a,...o,children:(0,U.jsx)(uo,{className:`size-4`})}),(0,U.jsx)(`div`,{className:`flex size-8 shrink-0 items-center justify-center rounded-md ${u}`,children:(0,U.jsx)(s,{className:`size-4 ${l}`})}),(0,U.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,U.jsxs)(`p`,{className:`truncate text-sm font-medium leading-tight`,children:[e.name,e.required&&(0,U.jsx)(`span`,{className:`ml-1 text-destructive`,children:`*`})]}),e.relationType===`one-to-many`&&(0,U.jsx)(`span`,{className:`shrink-0 rounded border border-indigo-200 bg-indigo-50 px-1 py-px text-[10px] font-medium text-indigo-600`,children:`Auto`})]}),(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.relationType===`one-to-many`?`Inverse relation · read-only`:c})]}),t&&!p&&(0,U.jsx)(`div`,{className:`flex shrink-0 items-center gap-px rounded-md border border-border p-0.5`,children:wO.map(({value:e,label:n})=>(0,U.jsx)(`button`,{type:`button`,title:n,onClick:()=>t(e),className:[`flex items-center justify-center rounded px-1.5 py-1 transition-colors`,d===e?`bg-foreground text-background`:`text-muted-foreground hover:text-foreground`].join(` `),children:(0,U.jsx)(CO,{width:e})},e))}),(r||i)&&(0,U.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,children:[r&&(0,U.jsx)(`button`,{type:`button`,title:`Edit field`,onClick:r,className:`flex size-7 items-center justify-center rounded text-muted-foreground transition-colors hover:bg-accent hover:text-accent-foreground`,children:(0,U.jsx)(No,{className:`size-3.5`})}),i&&(0,U.jsx)(`button`,{type:`button`,title:`Delete field`,onClick:i,className:`flex size-7 items-center justify-center rounded text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive`,children:(0,U.jsx)(qo,{className:`size-3.5`})})]})]}),p&&e.arrayFields&&e.arrayFields.length>0&&(0,U.jsx)(`div`,{className:`grid grid-cols-6 gap-2 px-3 pb-3`,children:e.arrayFields.map(e=>{let t=bO(e.type,e.subtype),r=t.icon;return(0,U.jsxs)(`div`,{className:`${xO[e.width??`full`]} rounded-md border border-dashed border-border p-2`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,U.jsx)(`div`,{className:`flex size-5 shrink-0 items-center justify-center rounded ${t.bg}`,children:(0,U.jsx)(r,{className:`size-3 ${t.color}`})}),(0,U.jsxs)(`span`,{className:`truncate text-xs font-medium`,children:[e.name,e.required&&(0,U.jsx)(`span`,{className:`ml-0.5 text-destructive`,children:`*`})]})]}),(0,U.jsx)(`p`,{className:`mt-0.5 truncate pl-6 text-[10px] text-muted-foreground`,children:t.label}),n&&(0,U.jsx)(`div`,{className:`mt-1 flex items-center gap-px rounded-md border border-border p-0.5`,children:wO.map(({value:t,label:r})=>(0,U.jsx)(`button`,{type:`button`,title:r,onClick:()=>n(e.name,t),className:[`flex items-center justify-center rounded px-1.5 py-1 transition-colors`,(e.width??`full`)===t?`bg-foreground text-background`:`text-muted-foreground hover:text-foreground`].join(` `),children:(0,U.jsx)(CO,{width:t})},t))})]},e.name)})})]})}var EO=v.forwardRef(({className:e,...t},n)=>(0,U.jsx)(bx,{ref:n,className:q(`peer size-4 shrink-0 rounded-sm border border-input shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground data-[state=checked]:border-primary`,e),...t,children:(0,U.jsx)(Sx,{className:`flex items-center justify-center text-current`,children:(0,U.jsx)(za,{className:`size-3`})})}));EO.displayName=bx.displayName;var DO=[{type:`string`,icon:Yo,label:`Text`,color:`text-blue-600`,bg:`bg-blue-50`},{type:`text`,icon:Wo,label:`Long Text`,color:`text-sky-600`,bg:`bg-sky-50`},{type:`richtext`,icon:io,label:`Rich Text`,color:`text-violet-600`,bg:`bg-violet-50`},{type:`number`,subtype:`integer`,icon:fo,label:`Integer`,color:`text-orange-600`,bg:`bg-orange-50`},{type:`number`,subtype:`float`,icon:fo,label:`Decimal`,color:`text-orange-600`,bg:`bg-orange-50`},{type:`boolean`,icon:Ko,label:`Boolean`,color:`text-emerald-600`,bg:`bg-emerald-50`},{type:`datetime`,icon:La,label:`Date & Time`,color:`text-amber-600`,bg:`bg-amber-50`},{type:`media`,icon:_o,label:`Media`,color:`text-rose-600`,bg:`bg-rose-50`},{type:`mixed`,icon:wo,label:`Mixed Value`,color:`text-fuchsia-600`,bg:`bg-fuchsia-50`}],OO={string:`half`,text:`full`,richtext:`full`,number:`third`,boolean:`third`,datetime:`half`,media:`half`,mixed:`half`},kO={type:`string`,subtype:void 0,name:``,required:!1,allowedTypes:[],width:`half`},AO=[{type:`string`,icon:Yo,label:`Text (string)`,description:`Titles, names, labels`,color:`text-blue-600`,bg:`bg-blue-50`},{type:`text`,icon:Wo,label:`Long text (string)`,description:`Plain text, paragraphs`,color:`text-sky-600`,bg:`bg-sky-50`},{type:`richtext`,icon:io,label:`Rich text (blocks)`,description:`Formatted HTML content`,color:`text-violet-600`,bg:`bg-violet-50`},{type:`uid`,icon:oo,label:`UID`,description:`Unique slug from a field`,color:`text-teal-600`,bg:`bg-teal-50`},{type:`boolean`,icon:Ko,label:`Boolean`,description:`True or false`,color:`text-emerald-600`,bg:`bg-emerald-50`},{type:`datetime`,icon:La,label:`Date & time`,description:`Timestamps and dates`,color:`text-amber-600`,bg:`bg-amber-50`},{type:`media`,icon:_o,label:`Media`,description:`Images, videos or files`,color:`text-rose-600`,bg:`bg-rose-50`},{type:`media-gallery`,icon:Co,label:`Media Gallery`,description:`Multiple images for galleries`,color:`text-pink-600`,bg:`bg-pink-50`},{type:`array`,icon:wo,label:`Array`,description:`Repeatable list of items`,color:`text-cyan-600`,bg:`bg-cyan-50`},{type:`navigation`,icon:Do,label:`Navigation`,description:`Nested navigation items`,color:`text-cyan-600`,bg:`bg-cyan-50`},{type:`number`,subtype:`integer`,icon:fo,label:`Integer (number)`,description:`Whole numbers`,color:`text-orange-600`,bg:`bg-orange-50`},{type:`number`,subtype:`float`,icon:fo,label:`Decimal (number)`,description:`Numbers with decimals`,color:`text-orange-600`,bg:`bg-orange-50`},{type:`relation`,icon:To,label:`Relation`,description:`Link to another content type`,color:`text-indigo-600`,bg:`bg-indigo-50`}],jO=[{value:`image`,label:`Images`},{value:`video`,label:`Videos`},{value:`audio`,label:`Audio`},{value:`document`,label:`Documents`}],MO=[{value:`many-to-one`,label:`Many-to-One`,description:`Many of these → one of the other`},{value:`one-to-one`,label:`One-to-One`,description:`One of these ↔ one of the other`},{value:`many-to-many`,label:`Many-to-Many`,description:`Many of these ↔ many of the other`}],NO=new Set(`all.analyse.analyze.and.any.array.as.asc.asymmetric.authorization.between.binary.both.case.cast.check.collate.column.constraint.create.cross.current_catalog.current_date.current_role.current_schema.current_time.current_timestamp.current_user.default.deferrable.desc.distinct.do.else.end.except.false.fetch.for.foreign.from.grant.group.having.in.initially.intersect.into.lateral.leading.limit.localtime.localtimestamp.not.null.offset.on.only.or.order.placing.primary.references.returning.select.session_user.some.symmetric.table.then.to.trailing.true.union.unique.user.using.variadic.when.where.window.with`.split(`.`));function PO(e){return NO.has(e.toLowerCase())}var FO={name:``,required:!1,relationType:`many-to-one`,relatedTable:``,relatedSlug:``,targetField:``,allowedTypes:[],arrayFields:[]};function IO({open:e,onOpenChange:t,existingNames:n,availableContentTypes:r,stringFields:i,initialField:a,onConfirm:o}){let[s,c]=(0,v.useState)(null),[l,u]=(0,v.useState)(FO),[d,f]=(0,v.useState)(``),[p,m]=(0,v.useState)(null),[h,g]=(0,v.useState)(``),[_,y]=(0,v.useState)(``),b=!!a;(0,v.useEffect)(()=>{e?a&&(c(AO.find(e=>e.type===a.type&&(e.subtype??void 0)===(a.subtype??void 0))??null),u({name:a.name,required:a.required??!1,relationType:a.relationType??`many-to-one`,relatedTable:a.relatedTable??``,relatedSlug:a.relatedSlug??``,targetField:a.targetField??``,allowedTypes:a.allowedTypes??[],arrayFields:a.arrayFields??[]})):(c(null),u(FO),f(``),m(null),g(``),y(``))},[e,a]);function x(e){t(e)}function S(e){c(e),u(FO),f(``),m(null),g(``),y(``)}function C(){b||(c(null),u(FO),f(``),m(null),g(``),y(``))}function w(){m({...kO}),g(``)}function T(e){m(t=>t?{...t,type:e.type,subtype:e.subtype,width:OO[e.type]}:{...kO,type:e.type,subtype:e.subtype,width:OO[e.type]})}function E(){if(!p)return;let e=p.name.trim();if(!e){g(`Name is required`);return}if(!/^[a-z][a-z0-9_]*$/.test(e)){g(`Lowercase letters, digits and underscores only`);return}if(PO(e)){g(`This name is reserved by SQL. Choose another one.`);return}if(l.arrayFields.some(t=>t.name===e)){g(`A sub-field with this name already exists`);return}let t={name:e,type:p.type,subtype:p.subtype,required:p.required||void 0,allowedTypes:p.type===`media`&&p.allowedTypes.length>0?p.allowedTypes:void 0,width:p.width};u(e=>({...e,arrayFields:[...e.arrayFields,t]})),m(null),g(``)}function D(e){u(t=>({...t,arrayFields:t.arrayFields.filter(t=>t.name!==e)}))}function O(e,t){u(n=>({...n,arrayFields:n.arrayFields.map((n,r)=>r===e?{...n,name:t}:n)})),y(``)}function k(){let e=l.arrayFields.map(e=>e.name.trim());return e.some(e=>!e)?(y(`All sub-fields must have a name.`),!1):e.some(e=>!/^[a-z][a-z0-9_]*$/.test(e))?(y(`Sub-field names must use lowercase letters, digits and underscores.`),!1):e.some(e=>PO(e))?(y(`One or more sub-field names are reserved by SQL.`),!1):new Set(e).size===e.length?!0:(y(`Sub-field names must be unique.`),!1)}function A(){let e=l.name.trim();return e?/^[a-z][a-z0-9_]*$/.test(e)?PO(e)?(f(`This name is reserved by SQL. Choose another one.`),!1):n.includes(e)&&e!==a?.name?(f(`A field with this name already exists`),!1):!0:(f(`Lowercase letters, digits and underscores only`),!1):(f(`Name is required`),!1)}function j(){!s||!A()||s.type===`array`&&!k()||(o({name:l.name.trim(),type:s.type,subtype:s.subtype,required:l.required||void 0,relationType:s.type===`relation`?l.relationType:void 0,relatedTable:s.type===`relation`?l.relatedTable:void 0,relatedSlug:s.type===`relation`?l.relatedSlug:void 0,targetField:s.type===`uid`?l.targetField:void 0,allowedTypes:s.type===`media`&&l.allowedTypes.length>0?l.allowedTypes:s.type===`media-gallery`?[`image`]:void 0,arrayFields:s.type===`array`?l.arrayFields.map(e=>({...e,name:e.name.trim()})):void 0,width:a?.width??SO[s.type]}),x(!1))}let M=!!s,N=s?.label.replace(/\s*\(.*?\)/,``)??``,P=b?`Edit field`:M?`${N} field`:`Add a field`;return(0,U.jsx)(yw,{open:e,onOpenChange:x,children:(0,U.jsxs)(Cw,{className:M?s?.type===`array`?`max-w-lg`:`max-w-md`:`max-w-3xl`,children:[(0,U.jsx)(ww,{children:(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[M&&!b&&(0,U.jsx)(`button`,{type:`button`,onClick:C,className:`flex size-7 items-center justify-center rounded text-muted-foreground hover:bg-accent hover:text-accent-foreground`,children:(0,U.jsx)(Pa,{className:`size-4`})}),(0,U.jsx)(Ew,{children:P})]})}),!M&&(0,U.jsx)(`div`,{className:`grid grid-cols-3 gap-2 pt-1`,children:AO.map(e=>{let t=e.icon,n=`${e.type}${e.subtype??``}`;return(0,U.jsxs)(`button`,{type:`button`,disabled:e.disabled,onClick:()=>!e.disabled&&S(e),className:`flex flex-col items-start gap-2 rounded-lg border border-border p-3 text-left transition-colors hover:border-primary hover:bg-accent disabled:cursor-not-allowed disabled:opacity-40`,children:[(0,U.jsx)(`div`,{className:`flex size-8 items-center justify-center rounded-md ${e.bg}`,children:(0,U.jsx)(t,{className:`size-4 ${e.color}`})}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`p`,{className:`text-sm font-medium`,children:e.label}),(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.disabled?`Coming soon`:e.description})]})]},n)})}),M&&(0,U.jsxs)(`div`,{className:`flex flex-col gap-4 pt-1`,children:[(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsx)(X,{htmlFor:`field-name`,children:`Field name`}),(0,U.jsx)(Hv,{id:`field-name`,placeholder:`e.g. article_title`,value:l.name,autoFocus:!0,onChange:e=>{u(t=>({...t,name:e.target.value})),f(``)},onKeyDown:e=>{e.key===`Enter`&&j()}}),d&&(0,U.jsx)(`p`,{className:`text-xs text-destructive`,children:d}),(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Lowercase letters, digits and underscores. Must start with a letter.`})]}),s?.type===`media`&&(0,U.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,U.jsx)(X,{children:`Allowed file types`}),(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground -mt-1`,children:`Leave all unchecked to allow any file type.`}),(0,U.jsx)(`div`,{className:`grid grid-cols-2 gap-2`,children:jO.map(({value:e,label:t})=>(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(EO,{id:`media-type-${e}`,checked:l.allowedTypes.includes(e),onCheckedChange:t=>u(n=>({...n,allowedTypes:t?[...n.allowedTypes,e]:n.allowedTypes.filter(t=>t!==e)}))}),(0,U.jsx)(X,{htmlFor:`media-type-${e}`,className:`cursor-pointer font-normal`,children:t})]},e))})]}),s?.type===`array`&&(0,U.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,U.jsx)(X,{children:`Sub-fields`}),!p&&(0,U.jsxs)(`button`,{type:`button`,onClick:w,className:`flex items-center gap-1 rounded px-2 py-1 text-xs text-muted-foreground transition-colors hover:bg-accent hover:text-accent-foreground`,children:[(0,U.jsx)(Po,{className:`size-3`}),`Add sub-field`]})]}),l.arrayFields.length===0&&!p&&(0,U.jsx)(`p`,{className:`rounded-md border border-dashed border-border px-3 py-4 text-center text-xs text-muted-foreground`,children:`No sub-fields yet. Add at least one to make this field useful.`}),l.arrayFields.length>0&&(0,U.jsx)(`div`,{className:`grid grid-cols-6 gap-1.5`,children:l.arrayFields.map((e,t)=>{let n=DO.find(t=>t.type===e.type&&(t.subtype??void 0)===(e.subtype??void 0)),r=n?.icon??Yo;return(0,U.jsxs)(`div`,{className:`${xO[e.width??`full`]} flex items-center gap-1.5 rounded-md border border-dashed border-border p-2`,children:[(0,U.jsx)(`div`,{className:`flex size-5 shrink-0 items-center justify-center rounded ${n?.bg??`bg-muted`}`,children:(0,U.jsx)(r,{className:`size-3 ${n?.color??`text-muted-foreground`}`})}),(0,U.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,U.jsx)(Hv,{value:e.name,onChange:e=>O(t,e.target.value),className:`h-6 px-1.5 text-xs`}),(0,U.jsx)(`p`,{className:`truncate text-[10px] text-muted-foreground`,children:n?.label})]}),(0,U.jsx)(`button`,{type:`button`,onClick:()=>D(e.name),className:`flex shrink-0 size-5 items-center justify-center rounded text-muted-foreground hover:text-destructive`,children:(0,U.jsx)(qo,{className:`size-3`})})]},`subfield-${t}`)})}),_&&(0,U.jsx)(`p`,{className:`text-xs text-destructive`,children:_}),p&&(0,U.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-lg border border-border bg-muted/30 p-3`,children:[(0,U.jsx)(`div`,{className:`grid grid-cols-4 gap-1.5`,children:DO.map(e=>{let t=e.icon,n=`${e.type}${e.subtype??``}`;return(0,U.jsxs)(`button`,{type:`button`,onClick:()=>T(e),className:[`flex items-center gap-1.5 rounded-md border px-2 py-1.5 text-left transition-colors`,p.type===e.type&&(p.subtype??void 0)===(e.subtype??void 0)?`border-primary bg-accent`:`border-border hover:border-primary hover:bg-accent`].join(` `),children:[(0,U.jsx)(`div`,{className:`flex size-5 shrink-0 items-center justify-center rounded ${e.bg}`,children:(0,U.jsx)(t,{className:`size-3 ${e.color}`})}),(0,U.jsx)(`span`,{className:`truncate text-xs font-medium`,children:e.label})]},n)})}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,U.jsx)(Hv,{placeholder:`sub_field_name`,autoFocus:!0,value:p.name,onChange:e=>{m(t=>t&&{...t,name:e.target.value}),g(``)},onKeyDown:e=>{e.key===`Enter`&&E()}}),h&&(0,U.jsx)(`p`,{className:`text-xs text-destructive`,children:h})]}),(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,U.jsx)(EO,{id:`subfield-required`,checked:p.required,onCheckedChange:e=>m(t=>t&&{...t,required:!!e})}),(0,U.jsx)(X,{htmlFor:`subfield-required`,className:`cursor-pointer font-normal text-sm`,children:`Required`})]}),(0,U.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,U.jsx)(J,{variant:`ghost`,size:`sm`,onClick:()=>{m(null),g(``)},children:`Cancel`}),(0,U.jsx)(J,{size:`sm`,onClick:E,children:`Add`})]})]})]})]}),s?.type===`uid`&&(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsx)(X,{children:`Source field`}),(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`The slug will be auto-generated from this field's value.`}),i.length>0?(0,U.jsxs)(Ow,{value:l.targetField,onValueChange:e=>u(t=>({...t,targetField:e})),children:[(0,U.jsx)(jw,{children:(0,U.jsx)(Aw,{placeholder:`Select a text field`})}),(0,U.jsx)(Pw,{children:i.map(e=>(0,U.jsx)(Iw,{value:e.name,children:e.name},e.name))})]}):(0,U.jsx)(`p`,{className:`rounded-md border border-border bg-muted px-3 py-2 text-xs text-muted-foreground`,children:`No short text fields available. Add a string field first.`})]}),s?.type===`relation`&&(0,U.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsx)(X,{children:`Relation type`}),(0,U.jsx)(`div`,{className:`grid grid-cols-1 gap-1.5`,children:MO.map(e=>(0,U.jsx)(`button`,{type:`button`,onClick:()=>u(t=>({...t,relationType:e.value})),className:`flex items-start gap-3 rounded-md border px-3 py-2 text-left transition-colors hover:border-primary ${l.relationType===e.value?`border-primary bg-accent`:`border-border`}`,children:(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`p`,{className:`text-sm font-medium leading-none`,children:e.label}),(0,U.jsx)(`p`,{className:`mt-0.5 text-xs text-muted-foreground`,children:e.description})]})},e.value))})]}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsx)(X,{children:`Related content type`}),r.length>0?(0,U.jsxs)(Ow,{value:l.relatedTable,onValueChange:e=>{let t=r.find(t=>t.tableName===e);u(n=>({...n,relatedTable:e,relatedSlug:t?.slug??``}))},children:[(0,U.jsx)(jw,{children:(0,U.jsx)(Aw,{placeholder:`Select a content type`})}),(0,U.jsx)(Pw,{children:r.map(e=>(0,U.jsx)(Iw,{value:e.tableName,children:e.name},e.tableName))})]}):(0,U.jsx)(Hv,{placeholder:`table_name`,value:l.relatedTable,onChange:e=>u(t=>({...t,relatedTable:e.target.value}))})]})]}),(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(EO,{id:`field-required`,checked:l.required,onCheckedChange:e=>u(t=>({...t,required:!!e}))}),(0,U.jsx)(X,{htmlFor:`field-required`,className:`cursor-pointer font-normal`,children:`Required field`})]}),(0,U.jsxs)(`div`,{className:`flex justify-end gap-2 border-t border-border pt-3`,children:[(0,U.jsx)(J,{variant:`outline`,onClick:()=>x(!1),children:`Cancel`}),(0,U.jsx)(J,{onClick:j,children:b?`Save changes`:`Add field`})]})]})]})})}function LO(e){return e.toLowerCase().replace(/\s+/g,`-`).replace(/[^a-z0-9-]/g,``).replace(/^-+|-+$/g,``)}function RO(e){return e.replace(/-/g,`_`)}function zO({field:e,onWidthChange:t,onArraySubFieldWidthChange:n,onEdit:r,onDelete:i}){let{attributes:a,listeners:o,setNodeRef:s,transform:c,transition:l,isDragging:u}=gO({id:e.name});return(0,U.jsx)(`div`,{ref:s,style:{transform:kT.Transform.toString(c),transition:l,opacity:u?.5:1},className:xO[e.width??`full`],children:(0,U.jsx)(TO,{field:e,dragListeners:o,dragAttributes:a,onWidthChange:t,onArraySubFieldWidthChange:n,onEdit:r,onDelete:i})})}function BO(){let{slug:e}=hr(),t=dr(),n=!e,{user:r}=ga(),i=r?.permissions??[],a=i.includes(`*`)||i.includes(`content-types:delete`),{data:o,loading:s}=wa(n?``:`/cms/admin/content-types/${e}`),{data:c,refetch:l}=wa(`/cms/admin/content-types`),{loading:u,request:d}=Vv(),{loading:f,request:p}=Vv(),[m,h]=(0,v.useState)(``),[g,_]=(0,v.useState)(``),[y,b]=(0,v.useState)(`collection`),[x,S]=(0,v.useState)([]),[C,w]=(0,v.useState)(!1),[T,E]=(0,v.useState)(null),[D,O]=(0,v.useState)(!1),k=(0,v.useRef)({name:``,slug:``,fields:`[]`});(0,v.useEffect)(()=>(window.addEventListener(`plank:content-types-changed`,l),()=>window.removeEventListener(`plank:content-types-changed`,l)),[l]),(0,v.useEffect)(()=>{if(n){h(``),_(``),b(`collection`),S([]),k.current={name:``,slug:``,fields:`[]`};return}o&&(h(o.name),_(o.slug),b(o.kind??`collection`),S(o.fields),k.current={name:o.name,slug:o.slug,fields:JSON.stringify(o.fields)})},[o,n]),(0,v.useEffect)(()=>{n&&m&&_(LO(m))},[n,m]);let A=m!==k.current.name||JSON.stringify(x)!==k.current.fields,j=(0,v.useRef)(!1),M=Fr((0,v.useCallback)(()=>j.current?!1:A,[A])),N=GT(WT(GE,{activationConstraint:{distance:5}}));function P(e){let{active:t,over:n}=e;!n||t.id===n.id||S(e=>ZD(e,e.findIndex(e=>e.name===t.id),e.findIndex(e=>e.name===n.id)))}function F(e){S(t=>[...t,e])}function I(e){S(t=>t.map(t=>t.name===T?.name?e:t)),E(null)}function L(e){S(t=>t.filter(t=>t.name!==e))}function R(e,t){S(n=>n.map(n=>n.name===e?{...n,width:t}:n))}function ee(e,t,n){S(r=>r.map(r=>r.name!==e||r.type!==`array`||!r.arrayFields?r:{...r,arrayFields:r.arrayFields.map(e=>e.name===t?{...e,width:n}:e)}))}async function te(){if(!m.trim()||!g.trim())return;let r=n?{name:m.trim(),slug:g,kind:y,tableName:RO(g),fields:x}:{name:m.trim(),slug:g,tableName:RO(g),fields:x};try{let i=await d(n?`/cms/admin/content-types`:`/cms/admin/content-types/${e}`,n?`POST`:`PUT`,r);h(i.name),_(i.slug),S(i.fields),k.current={name:i.name,slug:i.slug,fields:JSON.stringify(i.fields)},window.dispatchEvent(new CustomEvent(`plank:content-types-changed`)),(n||i.slug!==e)&&(j.current=!0,t(`/content-types/${i.slug}`,{replace:!0}))}catch{}}async function z(){if(a)try{await p(`/cms/admin/content-types/${e}`,`DELETE`),window.dispatchEvent(new CustomEvent(`plank:content-types-changed`)),t(`/content-types`,{replace:!0})}catch{}}let B=(c??[]).filter(t=>t.slug!==e).map(e=>({tableName:e.tableName,slug:e.slug,name:e.name})),V=x.filter(e=>e.type===`string`),ne=x.map(e=>e.name);return yO(`mod+s`,te,{enabled:A&&!u&&!!m.trim(),label:`Save content type`}),yO(`mod+k`,()=>w(!0),{label:`Add field`}),!n&&s?(0,U.jsxs)(`div`,{className:`flex items-center gap-2 py-12 text-muted-foreground`,children:[(0,U.jsx)(by,{className:`size-4`}),(0,U.jsx)(`span`,{className:`text-sm`,children:`Loading…`})]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(yy,{children:(0,U.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,U.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,U.jsx)(`input`,{value:m,onChange:e=>h(e.target.value),placeholder:`Content type name`,className:`bg-transparent text-2xl font-bold outline-none placeholder:text-muted-foreground/40 -mt-2`}),(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,U.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:`API ID:`}),(0,U.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:g||`—`})]}),n?(0,U.jsxs)(`div`,{className:`flex items-center gap-1 rounded-md border p-0.5`,children:[(0,U.jsxs)(`button`,{type:`button`,onClick:()=>b(`collection`),className:`flex items-center gap-1.5 rounded px-2 py-0.5 text-xs font-medium transition-colors ${y===`collection`?`bg-muted text-foreground`:`text-muted-foreground hover:text-foreground`}`,children:[(0,U.jsx)(Oo,{className:`size-3`}),`Collection`]}),(0,U.jsxs)(`button`,{type:`button`,onClick:()=>b(`single`),className:`flex items-center gap-1.5 rounded px-2 py-0.5 text-xs font-medium transition-colors ${y===`single`?`bg-muted text-foreground`:`text-muted-foreground hover:text-foreground`}`,children:[(0,U.jsx)(ao,{className:`size-3`}),`Single`]})]}):(0,U.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border px-2 py-0.5 text-xs font-medium text-muted-foreground ${y===`single`?`border-violet-500/30 bg-violet-500/10 text-violet-600 dark:text-violet-400`:``}`,children:[y===`single`?(0,U.jsx)(ao,{className:`size-3`}):(0,U.jsx)(Oo,{className:`size-3`}),y===`single`?`Single`:`Collection`]})]})]}),(0,U.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[!n&&a&&(0,U.jsx)(J,{variant:`ghost`,size:`icon`,className:`text-muted-foreground hover:text-destructive`,onClick:()=>O(!0),disabled:f,children:(0,U.jsx)(qo,{className:`size-4`})}),(0,U.jsxs)(J,{onClick:te,disabled:!A||u||!m.trim(),children:[u?(0,U.jsx)(by,{className:`size-4`}):null,`Save`]})]})]})}),(0,U.jsxs)(`section`,{className:`mt-24`,children:[x.length>0?(()=>{let e=x.filter(e=>e.relationType!==`one-to-many`),t=x.filter(e=>e.relationType===`one-to-many`);return(0,U.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[e.length>0&&(0,U.jsx)(HD,{sensors:N,collisionDetection:QT,onDragEnd:P,children:(0,U.jsx)(cO,{items:e.map(e=>e.name),strategy:iO,children:(0,U.jsx)(`div`,{className:`grid grid-cols-6 gap-3`,children:e.map(e=>(0,U.jsx)(zO,{field:e,onWidthChange:t=>R(e.name,t),onArraySubFieldWidthChange:(t,n)=>ee(e.name,t,n),onEdit:()=>E(e),onDelete:()=>L(e.name)},e.name))})})}),t.length>0&&(0,U.jsx)(`div`,{className:`grid grid-cols-6 gap-3`,children:t.map(e=>(0,U.jsx)(`div`,{className:`col-span-6`,children:(0,U.jsx)(TO,{field:e})},e.name))})]})})():(0,U.jsx)(Xw,{className:`border`,children:(0,U.jsxs)(Zw,{children:[(0,U.jsx)($w,{variant:`icon`,children:(0,U.jsx)(xo,{})}),(0,U.jsx)(eT,{children:`No fields yet`}),(0,U.jsx)(tT,{children:`Add your first field to define this content type's structure.`})]})}),(0,U.jsx)(`div`,{className:`mt-4`,children:(0,U.jsxs)(J,{variant:`outline`,onClick:()=>w(!0),className:`gap-2`,children:[(0,U.jsx)(Po,{className:`size-4`}),`Add field`]})}),(0,U.jsx)(IO,{open:C,onOpenChange:w,existingNames:ne,availableContentTypes:B,stringFields:V,onConfirm:F}),(0,U.jsx)(IO,{open:!!T,onOpenChange:e=>{e||E(null)},existingNames:ne,availableContentTypes:B,stringFields:V,initialField:T??void 0,onConfirm:I}),(0,U.jsx)(yw,{open:D,onOpenChange:O,children:(0,U.jsxs)(Cw,{className:`max-w-sm`,children:[(0,U.jsx)(ww,{children:(0,U.jsxs)(Ew,{children:[`Delete "`,m,`"?`]})}),(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`This will permanently delete the content type and all its entries. This action cannot be undone.`}),(0,U.jsxs)(Tw,{children:[(0,U.jsx)(J,{variant:`outline`,onClick:()=>O(!1),children:`Cancel`}),(0,U.jsxs)(J,{variant:`destructive`,onClick:z,disabled:f,children:[f?(0,U.jsx)(by,{className:`size-4`}):null,`Delete`]})]})]})}),(0,U.jsx)(yw,{open:M.state===`blocked`,onOpenChange:()=>M.reset?.(),children:(0,U.jsxs)(Cw,{className:`max-w-sm`,children:[(0,U.jsx)(ww,{children:(0,U.jsx)(Ew,{children:`Unsaved changes`})}),(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`You have unsaved changes. Leave without saving?`}),(0,U.jsxs)(Tw,{children:[(0,U.jsx)(J,{variant:`outline`,onClick:()=>M.reset?.(),children:`Stay`}),(0,U.jsx)(J,{variant:`destructive`,onClick:()=>M.proceed?.(),children:`Leave`})]})]})})]})]})}function VO(){let{pathname:e}=cr(),{user:t}=ga(),{data:n,loading:r,error:i,refetch:a}=wa(`/cms/admin/content-types`),{request:o}=Vv(),s=t?.permissions??[],c=s.includes(`*`)||s.includes(`content-types:write`);async function l(e,t){e.preventDefault(),e.stopPropagation(),await o(`/cms/admin/content-types/${t}/default`,`PUT`),a()}function u(t){return e===`/content/${t}`||e.startsWith(`/content/${t}/`)}let d=(n??[]).filter(e=>e.kind===`collection`),f=(n??[]).filter(e=>e.kind===`single`);return(0,U.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,U.jsx)(`div`,{className:`shrink-0 border-b border-sidebar-border px-4 py-3`,children:(0,U.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:`Content`})}),r&&(0,U.jsx)(`div`,{className:`flex items-center justify-center py-6`,children:(0,U.jsx)(by,{className:`size-4`})}),i&&(0,U.jsx)(`p`,{className:`px-4 py-3 text-xs text-destructive`,children:i}),!r&&!i&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,U.jsx)(`div`,{className:`shrink-0 px-4 py-2`,children:(0,U.jsx)(`p`,{className:`text-[11px] font-medium uppercase tracking-wider text-muted-foreground/60`,children:`Collection Types`})}),(0,U.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:d.length===0?(0,U.jsx)(`p`,{className:`px-4 pb-3 text-xs text-muted-foreground`,children:`No collection types yet.`}):(0,U.jsx)(`nav`,{className:`flex flex-col gap-0.5 px-2 pb-2`,children:d.map(e=>(0,U.jsxs)(qi,{to:`/content/${e.slug}`,className:[`group flex items-center gap-2.5 rounded-md px-2.5 py-1.5 text-sm transition-colors`,u(e.slug)?`bg-sidebar-accent text-sidebar-accent-foreground font-medium`:`text-sidebar-foreground hover:bg-sidebar-accent/50 hover:text-sidebar-accent-foreground`].join(` `),children:[(0,U.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name}),c&&(0,U.jsx)(`button`,{type:`button`,title:e.isDefault?`Default content type`:`Set as default`,onClick:t=>l(t,e.slug),className:[`shrink-0 rounded transition-colors`,e.isDefault?`text-amber-400`:`text-transparent group-hover:text-muted-foreground/40 hover:!text-amber-400`].join(` `),children:(0,U.jsx)(Ho,{className:`size-3.5 ${e.isDefault?`fill-amber-400`:``}`})})]},e.slug))})})]}),(0,U.jsx)(`div`,{className:`shrink-0 border-t border-sidebar-border`}),(0,U.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,U.jsx)(`div`,{className:`shrink-0 px-4 py-2`,children:(0,U.jsx)(`p`,{className:`text-[11px] font-medium uppercase tracking-wider text-muted-foreground/60`,children:`Single Types`})}),(0,U.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:f.length===0?(0,U.jsx)(`p`,{className:`px-4 pb-3 text-xs text-muted-foreground`,children:`No single types yet.`}):(0,U.jsx)(`nav`,{className:`flex flex-col gap-0.5 px-2 pb-2`,children:f.map(e=>(0,U.jsx)(qi,{to:`/content/${e.slug}`,className:[`group flex items-center gap-2.5 rounded-md px-2.5 py-1.5 text-sm transition-colors`,u(e.slug)?`bg-sidebar-accent text-sidebar-accent-foreground font-medium`:`text-sidebar-foreground hover:bg-sidebar-accent/50 hover:text-sidebar-accent-foreground`].join(` `),children:(0,U.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name})},e.slug))})})]})]})]})}function HO(){return qw((0,U.jsx)(VO,{})),(0,U.jsx)(Qr,{})}function UO(){let e=dr(),{data:t,loading:n}=wa(`/cms/admin/content-types`);return(0,v.useEffect)(()=>{!t||t.length===0||e(`/content/${(t.find(e=>e.isDefault)??t[0]).slug}`,{replace:!0})},[t,e]),n||t&&t.length>0?null:(0,U.jsxs)(Xw,{className:`border`,children:[(0,U.jsxs)(Zw,{children:[(0,U.jsx)($w,{variant:`icon`,children:(0,U.jsx)(xo,{})}),(0,U.jsx)(eT,{children:`No content types yet`}),(0,U.jsx)(tT,{children:`Create a content type in the Builder before managing content.`})]}),(0,U.jsx)(nT,{children:(0,U.jsx)(J,{onClick:()=>e(`/content-types/new`),children:`Go to Builder`})})]})}function WO({className:e,orientation:t=`horizontal`,decorative:n=!0,...r}){return(0,U.jsx)(RC,{"data-slot":`separator`,decorative:n,orientation:t,className:q(`shrink-0 bg-border data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px`,e),...r})}var GO=Ts(`group/field flex w-full gap-3 data-[invalid=true]:text-destructive`,{variants:{orientation:{vertical:[`flex-col [&>*]:w-full [&>.sr-only]:w-auto`],horizontal:[`flex-row items-center`,`[&>[data-slot=field-label]]:flex-auto`,`has-[>[data-slot=field-content]]:items-start has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px`],responsive:[`flex-col @md/field-group:flex-row @md/field-group:items-center [&>*]:w-full @md/field-group:[&>*]:w-auto [&>.sr-only]:w-auto`,`@md/field-group:[&>[data-slot=field-label]]:flex-auto`,`@md/field-group:has-[>[data-slot=field-content]]:items-start @md/field-group:has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px`]}},defaultVariants:{orientation:`vertical`}});function KO({className:e,orientation:t=`vertical`,...n}){return(0,U.jsx)(`div`,{role:`group`,"data-slot":`field`,"data-orientation":t,className:q(GO({orientation:t}),e),...n})}function qO({className:e,...t}){return(0,U.jsx)(X,{"data-slot":`field-label`,className:q(`group/field-label peer/field-label flex w-fit gap-2 leading-snug group-data-[disabled=true]/field:opacity-50`,`has-[>[data-slot=field]]:w-full has-[>[data-slot=field]]:flex-col has-[>[data-slot=field]]:rounded-md has-[>[data-slot=field]]:border [&>*]:data-[slot=field]:p-4`,`has-data-[state=checked]:border-primary has-data-[state=checked]:bg-primary/5 dark:has-data-[state=checked]:bg-primary/10`,e),...t})}function JO({className:e,...t}){return(0,U.jsx)(`nav`,{role:`navigation`,"aria-label":`pagination`,"data-slot":`pagination`,className:q(`mx-auto flex w-full justify-center`,e),...t})}function YO({className:e,...t}){return(0,U.jsx)(`ul`,{"data-slot":`pagination-content`,className:q(`flex flex-row items-center gap-1`,e),...t})}function XO({...e}){return(0,U.jsx)(`li`,{"data-slot":`pagination-item`,...e})}function ZO({className:e,isActive:t,size:n=`icon`,...r}){return(0,U.jsx)(`a`,{"aria-current":t?`page`:void 0,"data-slot":`pagination-link`,"data-active":t,className:q(Xc({variant:t?`outline`:`ghost`,size:n}),e),...r})}function QO({className:e,...t}){return(0,U.jsxs)(ZO,{"aria-label":`Go to previous page`,size:`default`,className:q(`gap-1 px-2.5 sm:pl-2.5`,e),...t,children:[(0,U.jsx)(Va,{}),(0,U.jsx)(`span`,{className:`hidden sm:block`,children:`Previous`})]})}function $O({className:e,...t}){return(0,U.jsxs)(ZO,{"aria-label":`Go to next page`,size:`default`,className:q(`gap-1 px-2.5 sm:pr-2.5`,e),...t,children:[(0,U.jsx)(`span`,{className:`hidden sm:block`,children:`Next`}),(0,U.jsx)(Ha,{})]})}function ek({page:e,totalPages:t,limit:n,onPageChange:r,onLimitChange:i}){return(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,U.jsxs)(KO,{orientation:`horizontal`,className:`w-fit`,children:[(0,U.jsx)(qO,{htmlFor:`select-rows-per-page`,children:`Rows per page`}),(0,U.jsxs)(Ow,{value:String(n),onValueChange:e=>i(Number(e)),children:[(0,U.jsx)(jw,{className:`w-20`,id:`select-rows-per-page`,children:(0,U.jsx)(Aw,{})}),(0,U.jsx)(Pw,{align:`start`,children:(0,U.jsxs)(kw,{children:[(0,U.jsx)(Iw,{value:`10`,children:`10`}),(0,U.jsx)(Iw,{value:`30`,children:`30`}),(0,U.jsx)(Iw,{value:`50`,children:`50`}),(0,U.jsx)(Iw,{value:`70`,children:`70`}),(0,U.jsx)(Iw,{value:`100`,children:`100`})]})})]})]}),(0,U.jsx)(JO,{className:`mx-0 w-auto`,children:(0,U.jsxs)(YO,{children:[(0,U.jsx)(XO,{children:(0,U.jsx)(QO,{href:`#`,onClick:t=>{t.preventDefault(),e>1&&r(e-1)},"aria-disabled":e===1,className:e===1?`pointer-events-none opacity-50`:``})}),(0,U.jsx)(XO,{children:(0,U.jsx)($O,{href:`#`,onClick:n=>{n.preventDefault(),e<t&&r(e+1)},"aria-disabled":e===t,className:e===t?`pointer-events-none opacity-50`:``})})]})})]})}var tk=4,nk={field:`created_at`,dir:`desc`},rk=[{name:`created_at`,label:`Created`},{name:`updated_at`,label:`Updated`},{name:`published_at`,label:`Published`}];function ik(e){return e.replace(/_/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}function ak(e){return e.find(e=>e.name===`title`)?.name??e.find(e=>e.name===`name`)?.name??e.find(e=>e.type===`uid`)?.name??e.find(e=>e.type===`string`)?.name??null}function ok(e){if(Array.isArray(e))return e.map(e=>String(e??``).trim()).filter(Boolean);let t=String(e??``).trim();return t?[t]:[]}function sk({relatedSlug:e,value:t,displayField:n}){let[r,i]=(0,v.useState)([]),[a,o]=(0,v.useState)(!1),s=ok(t);return(0,v.useEffect)(()=>{let r=ok(t);if(!e||r.length===0){i([]);return}let a=!1;o(!0);let s=localStorage.getItem(`plank_token`),c=s?{Authorization:`Bearer ${s}`}:{};return(n?Promise.resolve(n):fetch(`/cms/admin/content-types/${e}`,{headers:c}).then(e=>e.ok?e.json():null).then(e=>ak(e?.fields??[])).catch(()=>null)).then(t=>Promise.all(r.map(n=>fetch(`/cms/admin/entries/${e}/${n}`,{headers:c}).then(e=>e.ok?e.json():null).then(e=>e?String((t&&e[t])??e.title??e.name??n):n).catch(()=>n)))).then(e=>{a||i(e.filter(Boolean))}).catch(()=>{a||i(r)}).finally(()=>{a||o(!1)}),()=>{a=!0}},[e,n,t]),s.length===0?(0,U.jsx)(`span`,{className:`text-muted-foreground`,children:`—`}):a&&r.length===0?(0,U.jsx)(`span`,{className:`text-muted-foreground`,children:`…`}):(0,U.jsx)(`span`,{className:`font-medium truncate max-w-50 block`,children:r.join(`, `)})}function ck(e){return{visibleFields:e.slice(0,tk).map(e=>e.name),sort:nk}}function lk(e,t){if(!e)return ck(t);let n=(e.visibleFields??[]).filter(e=>{let n=String(e).split(`.`)[0];return t.some(e=>e.name===n)});return{visibleFields:n.length>0?n:t.slice(0,tk).map(e=>e.name),sort:e.sort??nk}}async function uk(e){let t=localStorage.getItem(`plank_token`),n=await fetch(`/cms/admin/users/me/prefs/view_${e}`,{headers:t?{Authorization:`Bearer ${t}`}:{}});if(!n.ok)return null;let{value:r}=await n.json();return r}async function dk(e,t){let n=localStorage.getItem(`plank_token`);await fetch(`/cms/admin/users/me/prefs/view_${e}`,{method:`PUT`,headers:{"Content-Type":`application/json`,...n?{Authorization:`Bearer ${n}`}:{}},body:JSON.stringify({value:t})})}function fk({value:e}){let[t,n]=(0,v.useState)(null);return(0,v.useEffect)(()=>{if(e.startsWith(`http`)){n(e);return}let t=localStorage.getItem(`plank_token`);fetch(`/cms/admin/media/${e}/url`,{headers:t?{Authorization:`Bearer ${t}`}:{}}).then(e=>e.ok?e.json():null).then(e=>n(e?.url??null)).catch(()=>{})},[e]),t?/\.(jpe?g|png|gif|webp|avif|svg)(\?|$)/i.test(t)?(0,U.jsx)(`img`,{src:t,alt:``,className:`size-8 object-cover`}):(0,U.jsxs)(`span`,{className:`flex items-center gap-1.5 text-muted-foreground text-xs`,children:[(0,U.jsx)(ao,{className:`size-3.5 shrink-0`}),(0,U.jsx)(`span`,{className:`truncate max-w-30`,children:`File`})]}):(0,U.jsx)(_o,{className:`size-4 text-muted-foreground`})}function pk({field:e,value:t,displayField:n}){let{timezone:r}=ya();if(t==null||t===``)return(0,U.jsx)(`span`,{className:`text-muted-foreground`,children:`—`});if(e.type===`boolean`)return t?(0,U.jsx)(za,{className:`size-4 text-primary`}):(0,U.jsx)(`span`,{className:`text-muted-foreground`,children:`—`});if(e.type===`datetime`)return(0,U.jsx)(`span`,{children:wy(String(t),r)});if(e.type===`number`)return(0,U.jsx)(`span`,{children:String(t)});if(e.type===`media`)return(0,U.jsx)(fk,{value:String(t)});if(e.type===`relation`)return(0,U.jsx)(sk,{relatedSlug:e.relatedSlug,value:t,displayField:n});if(e.type===`text`||e.type===`richtext`){let e=String(t);return(0,U.jsx)(`span`,{className:`text-muted-foreground truncate max-w-50 block`,children:e.length>60?e.slice(0,60)+`…`:e})}let i=String(t);return(0,U.jsx)(`span`,{className:e.type===`uid`?`font-mono text-xs text-muted-foreground truncate max-w-40 block`:`font-medium truncate max-w-50 block`,children:i.length>60?i.slice(0,60)+`…`:i})}function mk({entry:e}){let t=e._author_first_name,n=e._author_last_name,r=t||n?[t,n].filter(Boolean).join(` `):null,i=(0,U.jsx)(El,{avatarUrl:e._author_avatar_url,firstName:t,lastName:n,className:`size-7`,fallbackClassName:`text-[10px]`});return r?(0,U.jsxs)(Fv,{children:[(0,U.jsx)(Iv,{asChild:!0,children:i}),(0,U.jsx)(Lv,{children:r})]}):i}function hk({entry:e,fields:t}){let{timezone:n}=ya();if(e.status===`scheduled`)return(0,U.jsxs)(vw,{variant:`outline`,className:`border-blue-500 text-blue-600`,children:[(0,U.jsx)(Ia,{className:`size-3 mr-1`}),e.scheduled_for?Cy(e.scheduled_for,n):`Scheduled`]});if(e.status===`draft`)return(0,U.jsx)(vw,{variant:`outline`,children:`Draft`});if(e.status===`pending`)return e.review_rejected?(0,U.jsx)(vw,{variant:`destructive`,children:`Pending`}):(0,U.jsx)(vw,{className:`bg-amber-500 text-black hover:bg-amber-500`,children:`Pending`});if(e.status===`in_review`)return(0,U.jsx)(vw,{variant:`outline`,children:`In Review`});let r=(e,t)=>{if(t===`datetime`&&e&&typeof e==`string`){let t=new Date(e);return isNaN(t.getTime())?e:t.toISOString()}return e};return(0,U.jsx)(vw,{variant:e.published_data!=null&&t.some(t=>JSON.stringify(r(e[t.name],t.type))!==JSON.stringify(r(e.published_data[t.name],t.type)))?`secondary`:`default`,children:`Published`})}function gk({open:e,onOpenChange:t,allFields:n,config:r,onApply:i}){let[a,o]=(0,v.useState)(r.visibleFields),[s,c]=(0,v.useState)(r.sort);(0,v.useEffect)(()=>{e&&(o(r.visibleFields),c(r.sort))},[e,r]);let l=n.filter(e=>!a.some(t=>t.split(`.`)[0]===e.name));function u({fieldName:e}){let t=e.split(`.`)[0],r=n.find(e=>e.name===t)?.relatedSlug,{data:i}=wa(r?`/cms/admin/content-types/${r}`:null),s=a.find(e=>e.split(`.`)[0]===t),c=s&&s.includes(`.`)?s.split(`.`)[1]:void 0;function l(e,t){o(n=>n.map(n=>n.split(`.`)[0]===e?t?`${e}.${t}`:e:n))}return(0,v.useEffect)(()=>{if(!i?.fields||c)return;let e=[`title`,`name`],n=i.fields.find(t=>e.includes(t.name))||i.fields[0];n&&l(t,n.name)},[i,c,t]),i?.fields?(0,U.jsxs)(Ow,{value:c,onValueChange:e=>l(t,e),children:[(0,U.jsx)(jw,{className:`h-8 text-sm w-32`,children:(0,U.jsx)(Aw,{})}),(0,U.jsx)(Pw,{children:i.fields.map(e=>(0,U.jsx)(Iw,{value:e.name,children:e.name},e.name))})]}):null}function d(e,t){o(n=>{let r=n.indexOf(e);if(r===-1)return n;let i=[...n],a=r+t;return a<0||a>=i.length?n:([i[r],i[a]]=[i[a],i[r]],i)})}function f(e){o(t=>[...t,e])}function p(e){o(t=>t.filter(t=>t!==e))}let m=[...rk,...n.filter(e=>![`media`,`text`,`richtext`,`relation`].includes(e.type)).map(e=>({name:e.name,label:ik(e.name)}))];return(0,U.jsx)(yw,{open:e,onOpenChange:t,children:(0,U.jsxs)(Cw,{className:`max-w-md h-[80vh] flex flex-col`,children:[(0,U.jsx)(ww,{className:`flex-none`,children:(0,U.jsx)(Ew,{children:`Configure the view`})}),(0,U.jsxs)(`div`,{className:`flex flex-col flex-1 min-h-0 gap-5 py-1`,children:[(0,U.jsxs)(`div`,{className:`flex-none`,children:[(0,U.jsx)(`p`,{className:`mb-2 text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:`Displayed fields`}),a.length===0?(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground py-2`,children:`No fields selected.`}):(0,U.jsx)(`ul`,{className:`space-y-1`,children:a.map((e,t)=>{let r=String(e).split(`.`)[0],i=n.find(e=>e.name===r);return(0,U.jsxs)(`li`,{className:`flex items-center gap-2 rounded-md border px-3 py-2 text-sm`,children:[(0,U.jsx)(`span`,{className:`flex-1 font-medium`,children:ik(r)}),i&&(0,U.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:i.type}),i&&i.type===`relation`&&(0,U.jsx)(`div`,{className:`ml-2`,children:(0,U.jsx)(u,{fieldName:e})}),(0,U.jsx)(J,{size:`icon`,variant:`ghost`,disabled:t===0,onClick:()=>d(e,-1),className:`flex size-6 items-center justify-center rounded text-muted-foreground hover:bg-accent disabled:opacity-30`,children:(0,U.jsx)(Ua,{className:`size-3.5`})}),(0,U.jsx)(J,{size:`icon`,variant:`ghost`,disabled:t===a.length-1,onClick:()=>d(e,1),className:`flex size-6 items-center justify-center rounded text-muted-foreground hover:bg-accent disabled:opacity-30`,children:(0,U.jsx)(Ba,{className:`size-3.5`})}),(0,U.jsx)(J,{size:`icon`,variant:`ghost`,onClick:()=>p(e),className:`flex size-6 items-center justify-center rounded text-muted-foreground hover:bg-destructive/10 hover:text-destructive`,children:(0,U.jsx)(Ka,{className:`size-3.5`})})]},e)})})]}),l.length>0&&(0,U.jsxs)(`div`,{className:`flex flex-col flex-1 min-h-0`,children:[(0,U.jsx)(`p`,{className:`mb-2 text-xs font-medium text-muted-foreground uppercase tracking-wide flex-none`,children:`Available fields`}),(0,U.jsx)(`ul`,{className:`space-y-1 overflow-y-auto flex-1 min-h-0`,children:l.map(e=>(0,U.jsxs)(`li`,{className:`flex items-center gap-2 rounded-md border border-dashed px-3 py-2 text-sm text-muted-foreground`,children:[(0,U.jsx)(`span`,{className:`flex-1`,children:ik(e.name)}),(0,U.jsx)(`span`,{className:`text-xs`,children:e.type}),(0,U.jsx)(`button`,{type:`button`,onClick:()=>f(e.name),className:`flex size-6 items-center justify-center rounded text-muted-foreground hover:bg-accent hover:text-accent-foreground`,children:(0,U.jsx)(qa,{className:`size-3.5`})})]},e.name))})]}),(0,U.jsxs)(`div`,{className:`flex-none`,children:[(0,U.jsx)(`p`,{className:`mb-2 text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:`Sort entries`}),(0,U.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,U.jsxs)(Ow,{value:s.field,onValueChange:e=>c(t=>({...t,field:e})),children:[(0,U.jsx)(jw,{className:`h-8 text-sm`,children:(0,U.jsx)(Aw,{})}),(0,U.jsx)(Pw,{children:m.map(e=>(0,U.jsx)(Iw,{value:e.name,children:e.label},e.name))})]}),(0,U.jsxs)(Ow,{value:s.dir,onValueChange:e=>c(t=>({...t,dir:e})),children:[(0,U.jsx)(jw,{className:`h-8 text-sm`,children:(0,U.jsx)(Aw,{})}),(0,U.jsxs)(Pw,{children:[(0,U.jsx)(Iw,{value:`asc`,children:`Ascending`}),(0,U.jsx)(Iw,{value:`desc`,children:`Descending`})]})]})]})]})]}),(0,U.jsxs)(Tw,{className:`flex-none`,children:[(0,U.jsx)(J,{variant:`outline`,onClick:()=>t(!1),children:`Cancel`}),(0,U.jsx)(J,{onClick:()=>{i({visibleFields:a,sort:s}),t(!1)},children:`Apply`})]})]})})}function _k(){let{slug:e}=hr(),t=dr(),{timezone:n}=ya(),{user:r}=ga(),[i,a]=ea(),o=Math.max(1,Number(i.get(`page`)??1)),s=[10,30,50,70,100].includes(Number(i.get(`limit`)))?Number(i.get(`limit`)):10;function c(e){a(t=>(t.set(`page`,String(e)),t),{replace:!0})}function l(e){a(t=>(t.set(`limit`,String(e)),t.set(`page`,`1`),t),{replace:!0})}let[u,d]=(0,v.useState)(null),[f,p]=(0,v.useState)(!1),[m,h]=(0,v.useState)(null),[g,_]=(0,v.useState)(new Set),[y,b]=(0,v.useState)(!1),[x,S]=(0,v.useState)(!1),{loading:C,request:w}=Vv(),{data:T,loading:E}=wa(e?`/cms/admin/content-types/${e}`:null);(0,v.useEffect)(()=>{!T||!e||uk(e).then(e=>h(lk(e,T.fields))).catch(()=>h(ck(T.fields)))},[T?.slug]),(0,v.useEffect)(()=>{_(new Set)},[o,s]);let D=m??{visibleFields:T?.fields.slice(0,tk).map(e=>e.name)??[],sort:nk},{sort:O}=D,k=(D.visibleFields??[]).map(e=>{let t=String(e).split(`.`),n=t[0],r=t[1],i=T?.fields.find(e=>e.name===n);return i?{field:i,displayField:r}:null}).filter(Boolean),{data:A,loading:j,refetch:M}=wa(e&&m?`/cms/admin/content-types/${e}/entries?page=${o}&limit=${s}&sort=${O.field}&order=${O.dir}`:null);async function N(){!u||!e||(await w(`/cms/admin/entries/${e}/${u}`,`DELETE`),d(null),M())}let P=r?.permissions??[],F=P.includes(`*`)||P.includes(`entries:write`),I=P.includes(`*`)||P.includes(`entries:delete`),L=r?.role?.toLowerCase()===`viewer`,R=r?.role?.toLowerCase()===`contributor`,ee=r?.role?.toLowerCase()===`editor`,te=R||ee,z=e=>String(e.created_by??``)===String(r?.id??``),B=e=>!1,V=e=>F&&(!R||z(e))&&!B(e),ne=e=>I&&(!te||z(e)),H=[...g].filter(e=>{let t=(A?.data??[]).find(t=>t.id===e);return t?V(t):!1}),re=[...g].filter(e=>{let t=(A?.data??[]).find(t=>t.id===e);return t?ne(t):!1}),ie=(A?.data??[]).map(e=>e.id),ae=ie.length>0&&ie.every(e=>g.has(e)),oe=!ae&&ie.some(e=>g.has(e));function se(){_(e=>{let t=new Set(e);return ae?ie.forEach(e=>t.delete(e)):ie.forEach(e=>t.add(e)),t})}function ce(e){_(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}async function le(){if(!(!e||y)){b(!0);try{let t=localStorage.getItem(`plank_token`),n={"Content-Type":`application/json`,...t?{Authorization:`Bearer ${t}`}:{}};await Promise.all(H.map(t=>fetch(`/cms/admin/entries/${e}/${t}/status`,{method:`PATCH`,headers:n,body:JSON.stringify({status:`draft`})}))),_(new Set),M()}finally{b(!1)}}}async function ue(){if(!(!e||y)){b(!0);try{let t=localStorage.getItem(`plank_token`),n={...t?{Authorization:`Bearer ${t}`}:{}};await Promise.all(re.map(t=>fetch(`/cms/admin/entries/${e}/${t}`,{method:`DELETE`,headers:n}))),S(!1),_(new Set),M()}finally{b(!1)}}}function de(t){h(t),e&&dk(e,t).catch(()=>{}),c(1)}if(E||!m)return(0,U.jsxs)(`div`,{className:`flex items-center gap-2 py-12 text-muted-foreground`,children:[(0,U.jsx)(by,{className:`size-4`}),(0,U.jsx)(`span`,{className:`text-sm`,children:`Loading…`})]});if(!T)return null;let fe=Math.ceil((A?.total??0)/(A?.limit??20));return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(yy,{children:(0,U.jsxs)(`div`,{className:`mb-6 flex items-center justify-between gap-4`,children:[(0,U.jsx)(`h1`,{className:`text-2xl font-bold -mt-6`,children:T.name}),(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsxs)(J,{variant:`outline`,onClick:()=>p(!0),className:`gap-1.5`,children:[(0,U.jsx)(zo,{className:`size-3.5`}),`Configure the view`]}),F&&(0,U.jsxs)(J,{onClick:()=>t(`/content/${e}/new`),className:`gap-2`,children:[(0,U.jsx)(Po,{className:`size-4`}),`New entry`]})]})]})}),(0,U.jsxs)(`section`,{className:`mt-24`,children:[j&&(0,U.jsxs)(`div`,{className:`flex items-center gap-2 py-12 text-muted-foreground`,children:[(0,U.jsx)(by,{className:`size-4`}),(0,U.jsx)(`span`,{className:`text-sm`,children:`Loading entries…`})]}),!j&&(A?.data??[]).length===0&&(0,U.jsxs)(Xw,{className:`border`,children:[(0,U.jsxs)(Zw,{children:[(0,U.jsx)($w,{variant:`icon`,children:(0,U.jsx)(io,{})}),(0,U.jsx)(eT,{children:`No entries yet`}),(0,U.jsxs)(tT,{children:[`Create your first entry for `,T.name,`.`]})]}),(0,U.jsx)(nT,{children:F&&(0,U.jsx)(J,{onClick:()=>t(`/content/${e}/new`),children:`New entry`})})]}),!j&&(A?.data??[]).length>0&&(0,U.jsxs)(Pv,{children:[!L&&g.size>0&&(0,U.jsxs)(`div`,{className:`mb-3 flex items-center gap-3 rounded-lg border border-border bg-muted/50 px-4 py-2.5`,children:[(0,U.jsxs)(`span`,{className:`text-sm font-medium`,children:[g.size,` selected`]}),(0,U.jsxs)(`div`,{className:`flex items-center gap-2 ml-auto`,children:[(0,U.jsxs)(J,{variant:`outline`,size:`sm`,disabled:y||H.length===0,onClick:le,children:[y?(0,U.jsx)(by,{className:`size-3.5`}):null,`Unpublish`]}),I&&(0,U.jsxs)(J,{variant:`destructive`,size:`sm`,disabled:y||re.length===0,onClick:()=>S(!0),children:[(0,U.jsx)(qo,{className:`size-3.5`}),`Delete`]})]})]}),(0,U.jsx)(`div`,{className:`overflow-hidden rounded-lg border border-border`,children:(0,U.jsxs)(Rw,{className:`w-full`,children:[(0,U.jsx)(zw,{className:`border-b border-border font-bold uppercase`,children:(0,U.jsxs)(Vw,{className:`hover:bg-transparent`,children:[(0,U.jsx)(Hw,{className:`w-10 px-4 py-3`,children:!L&&(0,U.jsx)(EO,{checked:ae?!0:oe?`indeterminate`:!1,onCheckedChange:se,"aria-label":`Select all`})}),k.map(e=>(0,U.jsx)(Hw,{className:`px-4 py-3 text-left font-medium text-muted-foreground`,children:ik(e.field.name)},e.field.name)),(0,U.jsx)(Hw,{className:`px-4 py-3 text-left font-medium text-muted-foreground`,children:`Created`}),(0,U.jsx)(Hw,{className:`px-4 py-3 text-left font-medium text-muted-foreground`,children:`Updated`}),(0,U.jsx)(Hw,{className:`px-4 py-3 text-left font-medium text-muted-foreground`,children:`Pub / Sch`}),(0,U.jsx)(Hw,{className:`px-4 py-3 text-left font-medium text-muted-foreground`,children:`Status`}),(0,U.jsx)(Hw,{className:`px-4 py-3 text-left font-medium text-muted-foreground`,children:`Author`}),(0,U.jsx)(Hw,{className:`px-4 py-3`})]})}),(0,U.jsx)(Bw,{className:`divide-y divide-border`,children:(A?.data??[]).map(r=>(0,U.jsxs)(Vw,{className:`group transition-colors ${g.has(r.id)?`bg-muted/40`:`hover:bg-muted/30`} ${R&&!z(r)?`opacity-60`:``} ${B(r)?`opacity-60`:``}`,children:[(0,U.jsx)(Uw,{className:`w-10 px-4 py-3`,children:!L&&(0,U.jsx)(EO,{checked:g.has(r.id),onCheckedChange:()=>ce(r.id),"aria-label":`Select row`})}),k.map(e=>{let t=r[e.field.name],n=t;return e.field.type===`relation`?n=t:e.displayField&&(n=t&&typeof t==`object`?t[e.displayField]:t&&typeof t==`object`?t.title:t),(0,U.jsx)(Uw,{className:`px-4 py-3`,children:(0,U.jsx)(pk,{field:e.field,value:n,displayField:e.displayField})},e.field.name)}),(0,U.jsx)(Uw,{className:`px-4 py-3 text-muted-foreground whitespace-nowrap`,children:Cy(r.created_at,n)}),(0,U.jsx)(Uw,{className:`px-4 py-3 text-muted-foreground whitespace-nowrap`,children:Cy(r.updated_at,n)}),(0,U.jsx)(Uw,{className:`px-4 py-3 text-muted-foreground whitespace-nowrap`,children:r.status===`scheduled`&&r.scheduled_for?Cy(r.scheduled_for,n):r.published_at?Cy(r.published_at,n):`—`}),(0,U.jsx)(Uw,{className:`px-4 py-3`,children:(0,U.jsx)(hk,{entry:r,fields:T.fields})}),(0,U.jsx)(Uw,{className:`px-4 py-3`,children:(0,U.jsx)(mk,{entry:r})}),(0,U.jsx)(Uw,{className:`px-4 py-3`,children:(0,U.jsx)(`div`,{className:`flex items-center justify-end gap-1`,children:L?(0,U.jsx)(J,{size:`icon`,variant:`ghost`,onClick:()=>t(`/content/${e}/${r.id}`),className:`flex size-8 items-center justify-center rounded text-muted-foreground hover:bg-accent hover:text-accent-foreground`,children:(0,U.jsx)(to,{className:`size-3.5`})}):(0,U.jsxs)(U.Fragment,{children:[V(r)&&(0,U.jsx)(J,{size:`icon`,variant:`ghost`,onClick:()=>t(`/content/${e}/${r.id}`),className:`flex size-8 items-center justify-center rounded text-muted-foreground hover:bg-accent hover:text-accent-foreground`,children:(0,U.jsx)(No,{className:`size-3.5`})}),ne(r)&&(0,U.jsx)(J,{size:`icon`,variant:`ghost`,onClick:()=>d(r.id),className:`flex size-8 items-center justify-center rounded text-destructive hover:bg-destructive/10 hover:text-destructive`,children:(0,U.jsx)(qo,{className:`size-3.5`})})]})})})]},r.id))})]})}),(0,U.jsx)(`div`,{className:`mt-4`,children:(0,U.jsx)(ek,{page:o,totalPages:fe,limit:s,onPageChange:c,onLimitChange:l})})]}),m&&(0,U.jsx)(gk,{open:f,onOpenChange:p,allFields:T.fields,config:m,onApply:de}),(0,U.jsx)(yw,{open:!!u,onOpenChange:e=>{e||d(null)},children:(0,U.jsxs)(Cw,{className:`max-w-sm`,children:[(0,U.jsx)(ww,{children:(0,U.jsx)(Ew,{children:`Delete entry?`})}),(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`This action cannot be undone.`}),(0,U.jsxs)(Tw,{children:[(0,U.jsx)(J,{variant:`outline`,onClick:()=>d(null),children:`Cancel`}),(0,U.jsxs)(J,{variant:`destructive`,onClick:N,disabled:C,children:[C?(0,U.jsx)(by,{className:`size-4`}):null,`Delete`]})]})]})}),(0,U.jsx)(yw,{open:x,onOpenChange:e=>{e||S(!1)},children:(0,U.jsxs)(Cw,{className:`max-w-sm`,children:[(0,U.jsx)(ww,{children:(0,U.jsxs)(Ew,{children:[`Delete `,g.size,` `,g.size===1?`entry`:`entries`,`?`]})}),(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`This action cannot be undone.`}),(0,U.jsxs)(Tw,{children:[(0,U.jsx)(J,{variant:`outline`,onClick:()=>S(!1),children:`Cancel`}),(0,U.jsxs)(J,{variant:`destructive`,onClick:ue,disabled:y,children:[y?(0,U.jsx)(by,{className:`size-4`}):null,`Delete`]})]})]})})]})]})}function vk(){let{slug:e}=hr(),t=dr(),{user:n}=ga(),{data:r,loading:i}=wa(e?`/cms/admin/content-types/${e}`:null),a=r?.kind===`single`,{data:o,loading:s,error:c}=wa(a&&e?`/cms/admin/content-types/${e}/single`:null);return(0,v.useEffect)(()=>{if(!a||s)return;let r=n?.permissions??[],i=r.includes(`*`)||r.includes(`entries:write`);o?t(`/content/${e}/${o.id}`,{replace:!0}):c&&i&&t(`/content/${e}/new`,{replace:!0})},[a,s,o,c,e,t,n?.permissions]),i||a&&s?(0,U.jsxs)(`div`,{className:`flex items-center gap-2 py-12 text-muted-foreground`,children:[(0,U.jsx)(by,{className:`size-4`}),(0,U.jsx)(`span`,{className:`text-sm`,children:`Loading…`})]}):a?o?null:(0,U.jsx)(`div`,{className:`py-12 text-sm text-muted-foreground`,children:`No entry is available for this Single Type.`}):(0,U.jsx)(_k,{})}var yk=365.2425,bk=6048e5,xk=864e5,Sk=3600*24;Sk*7,Sk*yk/12*3;var Ck=Symbol.for(`constructDateFrom`);function wk(e,t){return typeof e==`function`?e(t):e&&typeof e==`object`&&Ck in e?e[Ck](t):e instanceof Date?new e.constructor(t):new Date(t)}function Tk(e,t){return wk(t||e,e)}function Ek(e,t,n){let r=Tk(e,n?.in);return isNaN(t)?wk(n?.in||e,NaN):(t&&r.setDate(r.getDate()+t),r)}function Dk(e,t,n){let r=Tk(e,n?.in);if(isNaN(t))return wk(n?.in||e,NaN);if(!t)return r;let i=r.getDate(),a=wk(n?.in||e,r.getTime());return a.setMonth(r.getMonth()+t+1,0),i>=a.getDate()?a:(r.setFullYear(a.getFullYear(),a.getMonth(),i),r)}var Ok={};function kk(){return Ok}function Ak(e,t){let n=kk(),r=t?.weekStartsOn??t?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,i=Tk(e,t?.in),a=i.getDay(),o=(a<r?7:0)+a-r;return i.setDate(i.getDate()-o),i.setHours(0,0,0,0),i}function jk(e,t){return Ak(e,{...t,weekStartsOn:1})}function Mk(e,t){let n=Tk(e,t?.in),r=n.getFullYear(),i=wk(n,0);i.setFullYear(r+1,0,4),i.setHours(0,0,0,0);let a=jk(i),o=wk(n,0);o.setFullYear(r,0,4),o.setHours(0,0,0,0);let s=jk(o);return n.getTime()>=a.getTime()?r+1:n.getTime()>=s.getTime()?r:r-1}function Nk(e){let t=Tk(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 Pk(e,...t){let n=wk.bind(null,e||t.find(e=>typeof e==`object`));return t.map(n)}function Fk(e,t){let n=Tk(e,t?.in);return n.setHours(0,0,0,0),n}function Ik(e,t,n){let[r,i]=Pk(n?.in,e,t),a=Fk(r),o=Fk(i),s=+a-Nk(a),c=+o-Nk(o);return Math.round((s-c)/xk)}function Lk(e,t){let n=Mk(e,t),r=wk(t?.in||e,0);return r.setFullYear(n,0,4),r.setHours(0,0,0,0),jk(r)}function Rk(e,t,n){return Ek(e,t*7,n)}function zk(e,t,n){return Dk(e,t*12,n)}function Bk(e,t){let n,r=t?.in;return e.forEach(e=>{!r&&typeof e==`object`&&(r=wk.bind(null,e));let t=Tk(e,r);(!n||n<t||isNaN(+t))&&(n=t)}),wk(r,n||NaN)}function Vk(e,t){let n,r=t?.in;return e.forEach(e=>{!r&&typeof e==`object`&&(r=wk.bind(null,e));let t=Tk(e,r);(!n||n>t||isNaN(+t))&&(n=t)}),wk(r,n||NaN)}function Hk(e,t,n){let[r,i]=Pk(n?.in,e,t);return+Fk(r)==+Fk(i)}function Uk(e){return e instanceof Date||typeof e==`object`&&Object.prototype.toString.call(e)===`[object Date]`}function Wk(e){return!(!Uk(e)&&typeof e!=`number`||isNaN(+Tk(e)))}function Gk(e,t,n){let[r,i]=Pk(n?.in,e,t),a=r.getFullYear()-i.getFullYear(),o=r.getMonth()-i.getMonth();return a*12+o}function Kk(e,t){let n=Tk(e,t?.in),r=n.getMonth();return n.setFullYear(n.getFullYear(),r+1,0),n.setHours(23,59,59,999),n}function qk(e,t){let[n,r]=Pk(e,t.start,t.end);return{start:n,end:r}}function Jk(e,t){let{start:n,end:r}=qk(t?.in,e),i=+n>+r,a=i?+n:+r,o=i?r:n;o.setHours(0,0,0,0),o.setDate(1);let s=t?.step??1;if(!s)return[];s<0&&(s=-s,i=!i);let c=[];for(;+o<=a;)c.push(wk(n,o)),o.setMonth(o.getMonth()+s);return i?c.reverse():c}function Yk(e,t){let n=Tk(e,t?.in);return n.setDate(1),n.setHours(0,0,0,0),n}function Xk(e,t){let n=Tk(e,t?.in),r=n.getFullYear();return n.setFullYear(r+1,0,0),n.setHours(23,59,59,999),n}function Zk(e,t){let n=Tk(e,t?.in);return n.setFullYear(n.getFullYear(),0,1),n.setHours(0,0,0,0),n}function Qk(e,t){let{start:n,end:r}=qk(t?.in,e),i=+n>+r,a=i?+n:+r,o=i?r:n;o.setHours(0,0,0,0),o.setMonth(0,1);let s=t?.step??1;if(!s)return[];s<0&&(s=-s,i=!i);let c=[];for(;+o<=a;)c.push(wk(n,o)),o.setFullYear(o.getFullYear()+s);return i?c.reverse():c}function $k(e,t){let n=kk(),r=t?.weekStartsOn??t?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,i=Tk(e,t?.in),a=i.getDay(),o=(a<r?-7:0)+6-(a-r);return i.setDate(i.getDate()+o),i.setHours(23,59,59,999),i}function eA(e,t){return $k(e,{...t,weekStartsOn:1})}var tA={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`}},nA=(e,t,n)=>{let r,i=tA[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 rA(e){return(t={})=>{let n=t.width?String(t.width):e.defaultWidth;return e.formats[n]||e.formats[e.defaultWidth]}}var iA={date:rA({formats:{full:`EEEE, MMMM do, y`,long:`MMMM do, y`,medium:`MMM d, y`,short:`MM/dd/yyyy`},defaultWidth:`full`}),time:rA({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:rA({formats:{full:`{{date}} 'at' {{time}}`,long:`{{date}} 'at' {{time}}`,medium:`{{date}}, {{time}}`,short:`{{date}}, {{time}}`},defaultWidth:`full`})},aA={lastWeek:`'last' eeee 'at' p`,yesterday:`'yesterday at' p`,today:`'today at' p`,tomorrow:`'tomorrow at' p`,nextWeek:`eeee 'at' p`,other:`P`},oA=(e,t,n,r)=>aA[e];function sA(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 cA={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:sA({values:{narrow:[`B`,`A`],abbreviated:[`BC`,`AD`],wide:[`Before Christ`,`Anno Domini`]},defaultWidth:`wide`}),quarter:sA({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:sA({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:sA({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:sA({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 lA(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)?dA(s,e=>e.test(o)):uA(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 uA(e,t){for(let n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&t(e[n]))return n}function dA(e,t){for(let n=0;n<e.length;n++)if(t(e[n]))return n}function fA(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 pA={code:`en-US`,formatDistance:nA,formatLong:iA,formatRelative:oA,localize:cA,match:{ordinalNumber:fA({matchPattern:/^(\d+)(th|st|nd|rd)?/i,parsePattern:/\d+/i,valueCallback:e=>parseInt(e,10)}),era:lA({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:lA({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:lA({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:lA({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:lA({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 mA(e,t){let n=Tk(e,t?.in);return Ik(n,Zk(n))+1}function hA(e,t){let n=Tk(e,t?.in),r=jk(n)-+Lk(n);return Math.round(r/bk)+1}function gA(e,t){let n=Tk(e,t?.in),r=n.getFullYear(),i=kk(),a=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??i.firstWeekContainsDate??i.locale?.options?.firstWeekContainsDate??1,o=wk(t?.in||e,0);o.setFullYear(r+1,0,a),o.setHours(0,0,0,0);let s=Ak(o,t),c=wk(t?.in||e,0);c.setFullYear(r,0,a),c.setHours(0,0,0,0);let l=Ak(c,t);return+n>=+s?r+1:+n>=+l?r:r-1}function _A(e,t){let n=kk(),r=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??n.firstWeekContainsDate??n.locale?.options?.firstWeekContainsDate??1,i=gA(e,t),a=wk(t?.in||e,0);return a.setFullYear(i,0,r),a.setHours(0,0,0,0),Ak(a,t)}function vA(e,t){let n=Tk(e,t?.in),r=Ak(n,t)-+_A(n,t);return Math.round(r/bk)+1}function yA(e,t){return(e<0?`-`:``)+Math.abs(e).toString().padStart(t,`0`)}var bA={y(e,t){let n=e.getFullYear(),r=n>0?n:1-n;return yA(t===`yy`?r%100:r,t.length)},M(e,t){let n=e.getMonth();return t===`M`?String(n+1):yA(n+1,2)},d(e,t){return yA(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 yA(e.getHours()%12||12,t.length)},H(e,t){return yA(e.getHours(),t.length)},m(e,t){return yA(e.getMinutes(),t.length)},s(e,t){return yA(e.getSeconds(),t.length)},S(e,t){let n=t.length,r=e.getMilliseconds();return yA(Math.trunc(r*10**(n-3)),t.length)}},xA={am:`am`,pm:`pm`,midnight:`midnight`,noon:`noon`,morning:`morning`,afternoon:`afternoon`,evening:`evening`,night:`night`},SA={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 bA.y(e,t)},Y:function(e,t,n,r){let i=gA(e,r),a=i>0?i:1-i;return t===`YY`?yA(a%100,2):t===`Yo`?n.ordinalNumber(a,{unit:`year`}):yA(a,t.length)},R:function(e,t){return yA(Mk(e),t.length)},u:function(e,t){return yA(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 yA(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 yA(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 bA.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 yA(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=vA(e,r);return t===`wo`?n.ordinalNumber(i,{unit:`week`}):yA(i,t.length)},I:function(e,t,n){let r=hA(e);return t===`Io`?n.ordinalNumber(r,{unit:`week`}):yA(r,t.length)},d:function(e,t,n){return t===`do`?n.ordinalNumber(e.getDate(),{unit:`date`}):bA.d(e,t)},D:function(e,t,n){let r=mA(e);return t===`Do`?n.ordinalNumber(r,{unit:`dayOfYear`}):yA(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 yA(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 yA(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 yA(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?xA.noon:r===0?xA.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?xA.evening:r>=12?xA.afternoon:r>=4?xA.morning:xA.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 bA.h(e,t)},H:function(e,t,n){return t===`Ho`?n.ordinalNumber(e.getHours(),{unit:`hour`}):bA.H(e,t)},K:function(e,t,n){let r=e.getHours()%12;return t===`Ko`?n.ordinalNumber(r,{unit:`hour`}):yA(r,t.length)},k:function(e,t,n){let r=e.getHours();return r===0&&(r=24),t===`ko`?n.ordinalNumber(r,{unit:`hour`}):yA(r,t.length)},m:function(e,t,n){return t===`mo`?n.ordinalNumber(e.getMinutes(),{unit:`minute`}):bA.m(e,t)},s:function(e,t,n){return t===`so`?n.ordinalNumber(e.getSeconds(),{unit:`second`}):bA.s(e,t)},S:function(e,t){return bA.S(e,t)},X:function(e,t,n){let r=e.getTimezoneOffset();if(r===0)return`Z`;switch(t){case`X`:return wA(r);case`XXXX`:case`XX`:return TA(r);default:return TA(r,`:`)}},x:function(e,t,n){let r=e.getTimezoneOffset();switch(t){case`x`:return wA(r);case`xxxx`:case`xx`:return TA(r);default:return TA(r,`:`)}},O:function(e,t,n){let r=e.getTimezoneOffset();switch(t){case`O`:case`OO`:case`OOO`:return`GMT`+CA(r,`:`);default:return`GMT`+TA(r,`:`)}},z:function(e,t,n){let r=e.getTimezoneOffset();switch(t){case`z`:case`zz`:case`zzz`:return`GMT`+CA(r,`:`);default:return`GMT`+TA(r,`:`)}},t:function(e,t,n){return yA(Math.trunc(e/1e3),t.length)},T:function(e,t,n){return yA(+e,t.length)}};function CA(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+yA(a,2)}function wA(e,t){return e%60==0?(e>0?`-`:`+`)+yA(Math.abs(e)/60,2):TA(e,t)}function TA(e,t=``){let n=e>0?`-`:`+`,r=Math.abs(e),i=yA(Math.trunc(r/60),2),a=yA(r%60,2);return n+i+t+a}var EA=(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`})}},DA=(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`})}},OA={p:DA,P:(e,t)=>{let n=e.match(/(P+)(p+)?/)||[],r=n[1],i=n[2];if(!i)return EA(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}}`,EA(r,t)).replace(`{{time}}`,DA(i,t))}},kA=/^D+$/,AA=/^Y+$/,jA=[`D`,`DD`,`YY`,`YYYY`];function MA(e){return kA.test(e)}function NA(e){return AA.test(e)}function PA(e,t,n){let r=FA(e,t,n);if(console.warn(r),jA.includes(e))throw RangeError(r)}function FA(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 IA=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,LA=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,RA=/^'([^]*?)'?$/,zA=/''/g,BA=/[a-zA-Z]/;function VA(e,t,n){let r=kk(),i=n?.locale??r.locale??pA,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=Tk(e,n?.in);if(!Wk(s))throw RangeError(`Invalid time value`);let c=t.match(LA).map(e=>{let t=e[0];if(t===`p`||t===`P`){let n=OA[t];return n(e,i.formatLong)}return e}).join(``).match(IA).map(e=>{if(e===`''`)return{isToken:!1,value:`'`};let t=e[0];if(t===`'`)return{isToken:!1,value:HA(e)};if(SA[t])return{isToken:!0,value:e};if(t.match(BA))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&&NA(a)||!n?.useAdditionalDayOfYearTokens&&MA(a))&&PA(a,t,String(e));let o=SA[a[0]];return o(s,a,i.localize,l)}).join(``)}function HA(e){let t=e.match(RA);return t?t[1].replace(zA,`'`):e}function UA(e,t){let n=Tk(e,t?.in),r=n.getFullYear(),i=n.getMonth(),a=wk(n,0);return a.setFullYear(r,i+1,0),a.setHours(0,0,0,0),a.getDate()}function WA(e,t){return Tk(e,t?.in).getMonth()}function GA(e,t){return Tk(e,t?.in).getFullYear()}function KA(e,t){return+Tk(e)>+Tk(t)}function qA(e,t){return+Tk(e)<+Tk(t)}function JA(e,t,n){let[r,i]=Pk(n?.in,e,t);return r.getFullYear()===i.getFullYear()&&r.getMonth()===i.getMonth()}function YA(e,t,n){let[r,i]=Pk(n?.in,e,t);return r.getFullYear()===i.getFullYear()}function XA(e,t,n){let r=Tk(e,n?.in),i=r.getFullYear(),a=r.getDate(),o=wk(n?.in||e,0);o.setFullYear(i,t,15),o.setHours(0,0,0,0);let s=UA(o);return r.setMonth(t,Math.min(a,s)),r}function ZA(e,t,n){let r=Tk(e,n?.in);return isNaN(+r)?wk(n?.in||e,NaN):(r.setFullYear(t),r)}function QA({className:e,...t}){return(0,U.jsx)(pw,{"data-slot":`tabs`,className:q(`flex flex-col gap-2`,e),...t})}function $A({className:e,...t}){return(0,U.jsx)(mw,{"data-slot":`tabs-list`,className:q(`inline-flex h-9 items-center justify-start rounded-lg bg-muted p-1 text-muted-foreground w-full`,e),...t})}function ej({className:e,...t}){return(0,U.jsx)(hw,{"data-slot":`tabs-trigger`,className:q(`inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow`,e),...t})}function tj({className:e,...t}){return(0,U.jsx)(gw,{"data-slot":`tabs-content`,className:q(`flex-1 outline-none`,e),...t})}function nj({className:e,...t}){return(0,U.jsx)(XC,{"data-slot":`switch`,className:q(`peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input`,e),...t,children:(0,U.jsx)(ZC,{className:q(`pointer-events-none block size-4 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0`)})})}function rj(e,t,n=`long`){return new Intl.DateTimeFormat(`en-US`,{hour:`numeric`,timeZone:e,timeZoneName:n}).format(t).split(/\s/g).slice(2).join(` `)}var ij={},aj={};function oj(e,t){try{let n=(ij[e]||=new Intl.DateTimeFormat(`en-US`,{timeZone:e,timeZoneName:`longOffset`}).format)(t).split(`GMT`)[1];return n in aj?aj[n]:cj(n,n.split(`:`))}catch{if(e in aj)return aj[e];let t=e?.match(sj);return t?cj(e,t.slice(1)):NaN}}var sj=/([+-]\d\d):?(\d\d)?/;function cj(e,t){let n=+(t[0]||0),r=+(t[1]||0),i=(t[2]||0)/60;return aj[e]=n*60+r>0?n*60+r+i:n*60-r-i}var lj=class e extends Date{constructor(...e){super(),e.length>1&&typeof e[e.length-1]==`string`&&(this.timeZone=e.pop()),this.internal=new Date,isNaN(oj(this.timeZone,this))?this.setTime(NaN):e.length?typeof e[0]==`number`&&(e.length===1||e.length===2&&typeof e[1]!=`number`)?this.setTime(e[0]):typeof e[0]==`string`?this.setTime(+new Date(e[0])):e[0]instanceof Date?this.setTime(+e[0]):(this.setTime(+new Date(...e)),pj(this,NaN),dj(this)):this.setTime(Date.now())}static tz(t,...n){return n.length?new e(...n,t):new e(Date.now(),t)}withTimeZone(t){return new e(+this,t)}getTimezoneOffset(){let e=-oj(this.timeZone,this);return e>0?Math.floor(e):Math.ceil(e)}setTime(e){return Date.prototype.setTime.apply(this,arguments),dj(this),+this}[Symbol.for(`constructDateFrom`)](t){return new e(+new Date(t),this.timeZone)}},uj=/^(get|set)(?!UTC)/;Object.getOwnPropertyNames(Date.prototype).forEach(e=>{if(!uj.test(e))return;let t=e.replace(uj,`$1UTC`);lj.prototype[t]&&(e.startsWith(`get`)?lj.prototype[e]=function(){return this.internal[t]()}:(lj.prototype[e]=function(){return Date.prototype[t].apply(this.internal,arguments),fj(this),+this},lj.prototype[t]=function(){return Date.prototype[t].apply(this,arguments),dj(this),+this}))});function dj(e){e.internal.setTime(+e),e.internal.setUTCSeconds(e.internal.getUTCSeconds()-Math.round(-oj(e.timeZone,e)*60))}function fj(e){Date.prototype.setFullYear.call(e,e.internal.getUTCFullYear(),e.internal.getUTCMonth(),e.internal.getUTCDate()),Date.prototype.setHours.call(e,e.internal.getUTCHours(),e.internal.getUTCMinutes(),e.internal.getUTCSeconds(),e.internal.getUTCMilliseconds()),pj(e)}function pj(e){let t=oj(e.timeZone,e),n=t>0?Math.floor(t):Math.ceil(t),r=new Date(+e);r.setUTCHours(r.getUTCHours()-1);let i=-new Date(+e).getTimezoneOffset(),a=i- -new Date(+r).getTimezoneOffset(),o=Date.prototype.getHours.apply(e)!==e.internal.getUTCHours();a&&o&&e.internal.setUTCMinutes(e.internal.getUTCMinutes()+a);let s=i-n;s&&Date.prototype.setUTCMinutes.call(e,Date.prototype.getUTCMinutes.call(e)+s);let c=new Date(+e);c.setUTCSeconds(0);let l=i>0?c.getSeconds():(c.getSeconds()-60)%60,u=Math.round(-(oj(e.timeZone,e)*60))%60;(u||l)&&(e.internal.setUTCSeconds(e.internal.getUTCSeconds()+u),Date.prototype.setUTCSeconds.call(e,Date.prototype.getUTCSeconds.call(e)+u+l));let d=oj(e.timeZone,e),f=d>0?Math.floor(d):Math.ceil(d),p=-new Date(+e).getTimezoneOffset()-f,m=f!==n,h=p-s;if(m&&h){Date.prototype.setUTCMinutes.call(e,Date.prototype.getUTCMinutes.call(e)+h);let t=oj(e.timeZone,e),n=f-(t>0?Math.floor(t):Math.ceil(t));n&&(e.internal.setUTCMinutes(e.internal.getUTCMinutes()+n),Date.prototype.setUTCMinutes.call(e,Date.prototype.getUTCMinutes.call(e)+n))}}var mj=class e extends lj{static tz(t,...n){return n.length?new e(...n,t):new e(Date.now(),t)}toISOString(){let[e,t,n]=this.tzComponents(),r=`${e}${t}:${n}`;return this.internal.toISOString().slice(0,-1)+r}toString(){return`${this.toDateString()} ${this.toTimeString()}`}toDateString(){let[e,t,n,r]=this.internal.toUTCString().split(` `);return`${e?.slice(0,-1)} ${n} ${t} ${r}`}toTimeString(){let e=this.internal.toUTCString().split(` `)[4],[t,n,r]=this.tzComponents();return`${e} GMT${t}${n}${r} (${rj(this.timeZone,this)})`}toLocaleString(e,t){return Date.prototype.toLocaleString.call(this,e,{...t,timeZone:t?.timeZone||this.timeZone})}toLocaleDateString(e,t){return Date.prototype.toLocaleDateString.call(this,e,{...t,timeZone:t?.timeZone||this.timeZone})}toLocaleTimeString(e,t){return Date.prototype.toLocaleTimeString.call(this,e,{...t,timeZone:t?.timeZone||this.timeZone})}tzComponents(){let e=this.getTimezoneOffset();return[e>0?`-`:`+`,String(Math.floor(Math.abs(e)/60)).padStart(2,`0`),String(Math.abs(e)%60).padStart(2,`0`)]}withTimeZone(t){return new e(+this,t)}[Symbol.for(`constructDateFrom`)](t){return new e(+new Date(t),this.timeZone)}},hj=5,gj=4;function _j(e,t){let n=t.startOfMonth(e),r=n.getDay()>0?n.getDay():7,i=t.addDays(e,-r+1),a=t.addDays(i,hj*7-1);return t.getMonth(e)===t.getMonth(a)?hj:gj}function vj(e,t){let n=t.startOfMonth(e),r=n.getDay();return r===1?n:r===0?t.addDays(n,-6):t.addDays(n,-1*(r-1))}function yj(e,t){let n=vj(e,t),r=_j(e,t);return t.addDays(n,r*7-1)}var bj={...pA,labels:{labelDayButton:(e,t,n,r)=>{let i;i=r&&typeof r.format==`function`?r.format.bind(r):(e,t)=>VA(e,t,{locale:pA,...n});let a=i(e,`PPPP`);return t.today&&(a=`Today, ${a}`),t.selected&&(a=`${a}, selected`),a},labelMonthDropdown:`Choose the Month`,labelNext:`Go to the Next Month`,labelPrevious:`Go to the Previous Month`,labelWeekNumber:e=>`Week ${e}`,labelYearDropdown:`Choose the Year`,labelGrid:(e,t,n)=>{let r;return r=n&&typeof n.format==`function`?n.format.bind(n):(e,n)=>VA(e,n,{locale:pA,...t}),r(e,`LLLL yyyy`)},labelGridcell:(e,t,n,r)=>{let i;i=r&&typeof r.format==`function`?r.format.bind(r):(e,t)=>VA(e,t,{locale:pA,...n});let a=i(e,`PPPP`);return t?.today&&(a=`Today, ${a}`),a},labelNav:`Navigation bar`,labelWeekNumberHeader:`Week Number`,labelWeekday:(e,t,n)=>{let r;return r=n&&typeof n.format==`function`?n.format.bind(n):(e,n)=>VA(e,n,{locale:pA,...t}),r(e,`cccc`)}}},xj=class e{constructor(e,t){this.Date=Date,this.today=()=>this.overrides?.today?this.overrides.today():this.options.timeZone?mj.tz(this.options.timeZone):new this.Date,this.newDate=(e,t,n)=>this.overrides?.newDate?this.overrides.newDate(e,t,n):this.options.timeZone?new mj(e,t,n,this.options.timeZone):new Date(e,t,n),this.addDays=(e,t)=>this.overrides?.addDays?this.overrides.addDays(e,t):Ek(e,t),this.addMonths=(e,t)=>this.overrides?.addMonths?this.overrides.addMonths(e,t):Dk(e,t),this.addWeeks=(e,t)=>this.overrides?.addWeeks?this.overrides.addWeeks(e,t):Rk(e,t),this.addYears=(e,t)=>this.overrides?.addYears?this.overrides.addYears(e,t):zk(e,t),this.differenceInCalendarDays=(e,t)=>this.overrides?.differenceInCalendarDays?this.overrides.differenceInCalendarDays(e,t):Ik(e,t),this.differenceInCalendarMonths=(e,t)=>this.overrides?.differenceInCalendarMonths?this.overrides.differenceInCalendarMonths(e,t):Gk(e,t),this.eachMonthOfInterval=e=>this.overrides?.eachMonthOfInterval?this.overrides.eachMonthOfInterval(e):Jk(e),this.eachYearOfInterval=e=>{let t=this.overrides?.eachYearOfInterval?this.overrides.eachYearOfInterval(e):Qk(e),n=new Set(t.map(e=>this.getYear(e)));if(n.size===t.length)return t;let r=[];return n.forEach(e=>{r.push(new Date(e,0,1))}),r},this.endOfBroadcastWeek=e=>this.overrides?.endOfBroadcastWeek?this.overrides.endOfBroadcastWeek(e):yj(e,this),this.endOfISOWeek=e=>this.overrides?.endOfISOWeek?this.overrides.endOfISOWeek(e):eA(e),this.endOfMonth=e=>this.overrides?.endOfMonth?this.overrides.endOfMonth(e):Kk(e),this.endOfWeek=(e,t)=>this.overrides?.endOfWeek?this.overrides.endOfWeek(e,t):$k(e,this.options),this.endOfYear=e=>this.overrides?.endOfYear?this.overrides.endOfYear(e):Xk(e),this.format=(e,t,n)=>{let r=this.overrides?.format?this.overrides.format(e,t,this.options):VA(e,t,this.options);return this.options.numerals&&this.options.numerals!==`latn`?this.replaceDigits(r):r},this.getISOWeek=e=>this.overrides?.getISOWeek?this.overrides.getISOWeek(e):hA(e),this.getMonth=(e,t)=>this.overrides?.getMonth?this.overrides.getMonth(e,this.options):WA(e,this.options),this.getYear=(e,t)=>this.overrides?.getYear?this.overrides.getYear(e,this.options):GA(e,this.options),this.getWeek=(e,t)=>this.overrides?.getWeek?this.overrides.getWeek(e,this.options):vA(e,this.options),this.isAfter=(e,t)=>this.overrides?.isAfter?this.overrides.isAfter(e,t):KA(e,t),this.isBefore=(e,t)=>this.overrides?.isBefore?this.overrides.isBefore(e,t):qA(e,t),this.isDate=e=>this.overrides?.isDate?this.overrides.isDate(e):Uk(e),this.isSameDay=(e,t)=>this.overrides?.isSameDay?this.overrides.isSameDay(e,t):Hk(e,t),this.isSameMonth=(e,t)=>this.overrides?.isSameMonth?this.overrides.isSameMonth(e,t):JA(e,t),this.isSameYear=(e,t)=>this.overrides?.isSameYear?this.overrides.isSameYear(e,t):YA(e,t),this.max=e=>this.overrides?.max?this.overrides.max(e):Bk(e),this.min=e=>this.overrides?.min?this.overrides.min(e):Vk(e),this.setMonth=(e,t)=>this.overrides?.setMonth?this.overrides.setMonth(e,t):XA(e,t),this.setYear=(e,t)=>this.overrides?.setYear?this.overrides.setYear(e,t):ZA(e,t),this.startOfBroadcastWeek=(e,t)=>this.overrides?.startOfBroadcastWeek?this.overrides.startOfBroadcastWeek(e,this):vj(e,this),this.startOfDay=e=>this.overrides?.startOfDay?this.overrides.startOfDay(e):Fk(e),this.startOfISOWeek=e=>this.overrides?.startOfISOWeek?this.overrides.startOfISOWeek(e):jk(e),this.startOfMonth=e=>this.overrides?.startOfMonth?this.overrides.startOfMonth(e):Yk(e),this.startOfWeek=(e,t)=>this.overrides?.startOfWeek?this.overrides.startOfWeek(e,this.options):Ak(e,this.options),this.startOfYear=e=>this.overrides?.startOfYear?this.overrides.startOfYear(e):Zk(e),this.options={locale:bj,...e},this.overrides=t}getDigitMap(){let{numerals:e=`latn`}=this.options,t=new Intl.NumberFormat(`en-US`,{numberingSystem:e}),n={};for(let e=0;e<10;e++)n[e.toString()]=t.format(e);return n}replaceDigits(e){let t=this.getDigitMap();return e.replace(/\d/g,e=>t[e]||e)}formatNumber(e){return this.replaceDigits(e.toString())}getMonthYearOrder(){let t=this.options.locale?.code;return t&&e.yearFirstLocales.has(t)?`year-first`:`month-first`}formatMonthYear(t){let{locale:n,timeZone:r,numerals:i}=this.options,a=n?.code;if(a&&e.yearFirstLocales.has(a))try{return new Intl.DateTimeFormat(a,{month:`long`,year:`numeric`,timeZone:r,numberingSystem:i}).format(t)}catch{}let o=this.getMonthYearOrder()===`year-first`?`y LLLL`:`LLLL y`;return this.format(t,o)}};xj.yearFirstLocales=new Set([`eu`,`hu`,`ja`,`ja-Hira`,`ja-JP`,`ko`,`ko-KR`,`lt`,`lt-LT`,`lv`,`lv-LV`,`mn`,`mn-MN`,`zh`,`zh-CN`,`zh-HK`,`zh-TW`]);var Sj=new xj,Cj=class{constructor(e,t,n=Sj){this.date=e,this.displayMonth=t,this.outside=!!(t&&!n.isSameMonth(e,t)),this.dateLib=n,this.isoDate=n.format(e,`yyyy-MM-dd`),this.displayMonthId=n.format(t,`yyyy-MM`),this.dateMonthId=n.format(e,`yyyy-MM`)}isEqualTo(e){return this.dateLib.isSameDay(e.date,this.date)&&this.dateLib.isSameMonth(e.displayMonth,this.displayMonth)}},wj=class{constructor(e,t){this.date=e,this.weeks=t}},Tj=class{constructor(e,t){this.days=t,this.weekNumber=e}};function Ej(e){return v.createElement(`button`,{...e})}function Dj(e){return v.createElement(`span`,{...e})}function Oj(e){let{size:t=24,orientation:n=`left`,className:r}=e;return v.createElement(`svg`,{className:r,width:t,height:t,viewBox:`0 0 24 24`},n===`up`&&v.createElement(`polygon`,{points:`6.77 17 12.5 11.43 18.24 17 20 15.28 12.5 8 5 15.28`}),n===`down`&&v.createElement(`polygon`,{points:`6.77 8 12.5 13.57 18.24 8 20 9.72 12.5 17 5 9.72`}),n===`left`&&v.createElement(`polygon`,{points:`16 18.112 9.81111111 12 16 5.87733333 14.0888889 4 6 12 14.0888889 20`}),n===`right`&&v.createElement(`polygon`,{points:`8 18.112 14.18888889 12 8 5.87733333 9.91111111 4 18 12 9.91111111 20`}))}function kj(e){let{day:t,modifiers:n,...r}=e;return v.createElement(`td`,{...r})}function Aj(e){let{day:t,modifiers:n,...r}=e,i=v.useRef(null);return v.useEffect(()=>{n.focused&&i.current?.focus()},[n.focused]),v.createElement(`button`,{ref:i,...r})}var jj;(function(e){e.Root=`root`,e.Chevron=`chevron`,e.Day=`day`,e.DayButton=`day_button`,e.CaptionLabel=`caption_label`,e.Dropdowns=`dropdowns`,e.Dropdown=`dropdown`,e.DropdownRoot=`dropdown_root`,e.Footer=`footer`,e.MonthGrid=`month_grid`,e.MonthCaption=`month_caption`,e.MonthsDropdown=`months_dropdown`,e.Month=`month`,e.Months=`months`,e.Nav=`nav`,e.NextMonthButton=`button_next`,e.PreviousMonthButton=`button_previous`,e.Week=`week`,e.Weeks=`weeks`,e.Weekday=`weekday`,e.Weekdays=`weekdays`,e.WeekNumber=`week_number`,e.WeekNumberHeader=`week_number_header`,e.YearsDropdown=`years_dropdown`})(jj||={});var Mj;(function(e){e.disabled=`disabled`,e.hidden=`hidden`,e.outside=`outside`,e.focused=`focused`,e.today=`today`})(Mj||={});var Nj;(function(e){e.range_end=`range_end`,e.range_middle=`range_middle`,e.range_start=`range_start`,e.selected=`selected`})(Nj||={});var Pj;(function(e){e.weeks_before_enter=`weeks_before_enter`,e.weeks_before_exit=`weeks_before_exit`,e.weeks_after_enter=`weeks_after_enter`,e.weeks_after_exit=`weeks_after_exit`,e.caption_after_enter=`caption_after_enter`,e.caption_after_exit=`caption_after_exit`,e.caption_before_enter=`caption_before_enter`,e.caption_before_exit=`caption_before_exit`})(Pj||={});function Fj(e){let{options:t,className:n,components:r,classNames:i,...a}=e,o=[i[jj.Dropdown],n].join(` `),s=t?.find(({value:e})=>e===a.value);return v.createElement(`span`,{"data-disabled":a.disabled,className:i[jj.DropdownRoot]},v.createElement(r.Select,{className:o,...a},t?.map(({value:e,label:t,disabled:n})=>v.createElement(r.Option,{key:e,value:e,disabled:n},t))),v.createElement(`span`,{className:i[jj.CaptionLabel],"aria-hidden":!0},s?.label,v.createElement(r.Chevron,{orientation:`down`,size:18,className:i[jj.Chevron]})))}function Ij(e){return v.createElement(`div`,{...e})}function Lj(e){return v.createElement(`div`,{...e})}function Rj(e){let{calendarMonth:t,displayIndex:n,...r}=e;return v.createElement(`div`,{...r},e.children)}function zj(e){let{calendarMonth:t,displayIndex:n,...r}=e;return v.createElement(`div`,{...r})}function Bj(e){return v.createElement(`table`,{...e})}function Vj(e){return v.createElement(`div`,{...e})}var Hj=(0,v.createContext)(void 0);function Uj(){let e=(0,v.useContext)(Hj);if(e===void 0)throw Error(`useDayPicker() must be used within a custom component.`);return e}function Wj(e){let{components:t}=Uj();return v.createElement(t.Dropdown,{...e})}function Gj(e){let{onPreviousClick:t,onNextClick:n,previousMonth:r,nextMonth:i,...a}=e,{components:o,classNames:s,labels:{labelPrevious:c,labelNext:l}}=Uj(),u=(0,v.useCallback)(e=>{i&&n?.(e)},[i,n]),d=(0,v.useCallback)(e=>{r&&t?.(e)},[r,t]);return v.createElement(`nav`,{...a},v.createElement(o.PreviousMonthButton,{type:`button`,className:s[jj.PreviousMonthButton],tabIndex:r?void 0:-1,"aria-disabled":r?void 0:!0,"aria-label":c(r),onClick:d},v.createElement(o.Chevron,{disabled:r?void 0:!0,className:s[jj.Chevron],orientation:`left`})),v.createElement(o.NextMonthButton,{type:`button`,className:s[jj.NextMonthButton],tabIndex:i?void 0:-1,"aria-disabled":i?void 0:!0,"aria-label":l(i),onClick:u},v.createElement(o.Chevron,{disabled:i?void 0:!0,orientation:`right`,className:s[jj.Chevron]})))}function Kj(e){let{components:t}=Uj();return v.createElement(t.Button,{...e})}function qj(e){return v.createElement(`option`,{...e})}function Jj(e){let{components:t}=Uj();return v.createElement(t.Button,{...e})}function Yj(e){let{rootRef:t,...n}=e;return v.createElement(`div`,{...n,ref:t})}function Xj(e){return v.createElement(`select`,{...e})}function Zj(e){let{week:t,...n}=e;return v.createElement(`tr`,{...n})}function Qj(e){return v.createElement(`th`,{...e})}function $j(e){return v.createElement(`thead`,{"aria-hidden":!0},v.createElement(`tr`,{...e}))}function eM(e){let{week:t,...n}=e;return v.createElement(`th`,{...n})}function tM(e){return v.createElement(`th`,{...e})}function nM(e){return v.createElement(`tbody`,{...e})}function rM(e){let{components:t}=Uj();return v.createElement(t.Dropdown,{...e})}var iM=s({Button:()=>Ej,CaptionLabel:()=>Dj,Chevron:()=>Oj,Day:()=>kj,DayButton:()=>Aj,Dropdown:()=>Fj,DropdownNav:()=>Ij,Footer:()=>Lj,Month:()=>Rj,MonthCaption:()=>zj,MonthGrid:()=>Bj,Months:()=>Vj,MonthsDropdown:()=>Wj,Nav:()=>Gj,NextMonthButton:()=>Kj,Option:()=>qj,PreviousMonthButton:()=>Jj,Root:()=>Yj,Select:()=>Xj,Week:()=>Zj,WeekNumber:()=>eM,WeekNumberHeader:()=>tM,Weekday:()=>Qj,Weekdays:()=>$j,Weeks:()=>nM,YearsDropdown:()=>rM});function aM(e,t,n=!1,r=Sj){let{from:i,to:a}=e,{differenceInCalendarDays:o,isSameDay:s}=r;return i&&a?(o(a,i)<0&&([i,a]=[a,i]),o(t,i)>=+!!n&&o(a,t)>=+!!n):!n&&a?s(a,t):!n&&i?s(i,t):!1}function oM(e){return!!(e&&typeof e==`object`&&`before`in e&&`after`in e)}function sM(e){return!!(e&&typeof e==`object`&&`from`in e)}function cM(e){return!!(e&&typeof e==`object`&&`after`in e)}function lM(e){return!!(e&&typeof e==`object`&&`before`in e)}function uM(e){return!!(e&&typeof e==`object`&&`dayOfWeek`in e)}function dM(e,t){return Array.isArray(e)&&e.every(t.isDate)}function fM(e,t,n=Sj){let r=Array.isArray(t)?t:[t],{isSameDay:i,differenceInCalendarDays:a,isAfter:o}=n;return r.some(t=>{if(typeof t==`boolean`)return t;if(n.isDate(t))return i(e,t);if(dM(t,n))return t.some(t=>i(e,t));if(sM(t))return aM(t,e,!1,n);if(uM(t))return Array.isArray(t.dayOfWeek)?t.dayOfWeek.includes(e.getDay()):t.dayOfWeek===e.getDay();if(oM(t)){let n=a(t.before,e),r=a(t.after,e),i=n>0,s=r<0;return o(t.before,t.after)?s&&i:i||s}return cM(t)?a(e,t.after)>0:lM(t)?a(t.before,e)>0:typeof t==`function`?t(e):!1})}function pM(e,t,n,r,i){let{disabled:a,hidden:o,modifiers:s,showOutsideDays:c,broadcastCalendar:l,today:u=i.today()}=t,{isSameDay:d,isSameMonth:f,startOfMonth:p,isBefore:m,endOfMonth:h,isAfter:g}=i,_=n&&p(n),v=r&&h(r),y={[Mj.focused]:[],[Mj.outside]:[],[Mj.disabled]:[],[Mj.hidden]:[],[Mj.today]:[]},b={};for(let t of e){let{date:e,displayMonth:n}=t,r=!!(n&&!f(e,n)),p=!!(_&&m(e,_)),h=!!(v&&g(e,v)),x=!!(a&&fM(e,a,i)),S=!!(o&&fM(e,o,i))||p||h||!l&&!c&&r||l&&c===!1&&r,C=d(e,u);r&&y.outside.push(t),x&&y.disabled.push(t),S&&y.hidden.push(t),C&&y.today.push(t),s&&Object.keys(s).forEach(n=>{let r=s?.[n];r&&fM(e,r,i)&&(b[n]?b[n].push(t):b[n]=[t])})}return e=>{let t={[Mj.focused]:!1,[Mj.disabled]:!1,[Mj.hidden]:!1,[Mj.outside]:!1,[Mj.today]:!1},n={};for(let n in y)t[n]=y[n].some(t=>t===e);for(let t in b)n[t]=b[t].some(t=>t===e);return{...t,...n}}}function mM(e,t,n={}){return Object.entries(e).filter(([,e])=>e===!0).reduce((e,[r])=>(n[r]?e.push(n[r]):t[Mj[r]]?e.push(t[Mj[r]]):t[Nj[r]]&&e.push(t[Nj[r]]),e),[t[jj.Day]])}function hM(e){return{...iM,...e}}function gM(e){let t={"data-mode":e.mode??void 0,"data-required":`required`in e?e.required:void 0,"data-multiple-months":e.numberOfMonths&&e.numberOfMonths>1||void 0,"data-week-numbers":e.showWeekNumber||void 0,"data-broadcast-calendar":e.broadcastCalendar||void 0,"data-nav-layout":e.navLayout||void 0};return Object.entries(e).forEach(([e,n])=>{e.startsWith(`data-`)&&(t[e]=n)}),t}function _M(){let e={};for(let t in jj)e[jj[t]]=`rdp-${jj[t]}`;for(let t in Mj)e[Mj[t]]=`rdp-${Mj[t]}`;for(let t in Nj)e[Nj[t]]=`rdp-${Nj[t]}`;for(let t in Pj)e[Pj[t]]=`rdp-${Pj[t]}`;return e}function vM(e,t,n){return(n??new xj(t)).formatMonthYear(e)}var yM=vM;function bM(e,t,n){return(n??new xj(t)).format(e,`d`)}function xM(e,t=Sj){return t.format(e,`LLLL`)}function SM(e,t,n){return(n??new xj(t)).format(e,`cccccc`)}function CM(e,t=Sj){return e<10?t.formatNumber(`0${e.toLocaleString()}`):t.formatNumber(`${e.toLocaleString()}`)}function wM(){return``}function TM(e,t=Sj){return t.format(e,`yyyy`)}var EM=TM,DM=s({formatCaption:()=>vM,formatDay:()=>bM,formatMonthCaption:()=>yM,formatMonthDropdown:()=>xM,formatWeekNumber:()=>CM,formatWeekNumberHeader:()=>wM,formatWeekdayName:()=>SM,formatYearCaption:()=>EM,formatYearDropdown:()=>TM});function OM(e){return e?.formatMonthCaption&&!e.formatCaption&&(e.formatCaption=e.formatMonthCaption),e?.formatYearCaption&&!e.formatYearDropdown&&(e.formatYearDropdown=e.formatYearCaption),{...DM,...e}}function kM(e,t,n,r){let i=(r??new xj(n)).format(e,`PPPP`);return t.today&&(i=`Today, ${i}`),t.selected&&(i=`${i}, selected`),i}var AM=kM;function jM(e,t,n){return(n??new xj(t)).formatMonthYear(e)}var MM=jM;function NM(e,t,n,r){let i=(r??new xj(n)).format(e,`PPPP`);return t?.today&&(i=`Today, ${i}`),i}function PM(e){return`Choose the Month`}function FM(){return``}var IM=`Go to the Next Month`;function LM(e,t){return IM}function RM(e){return`Go to the Previous Month`}function zM(e,t,n){return(n??new xj(t)).format(e,`cccc`)}function BM(e,t){return`Week ${e}`}function VM(e){return`Week Number`}function HM(e){return`Choose the Year`}var UM=s({labelCaption:()=>MM,labelDay:()=>AM,labelDayButton:()=>kM,labelGrid:()=>jM,labelGridcell:()=>NM,labelMonthDropdown:()=>PM,labelNav:()=>FM,labelNext:()=>LM,labelPrevious:()=>RM,labelWeekNumber:()=>BM,labelWeekNumberHeader:()=>VM,labelWeekday:()=>zM,labelYearDropdown:()=>HM}),WM=(e,t,n)=>t||(n?typeof n==`function`?n:(...e)=>n:e);function GM(e,t){let n=t.locale?.labels??{};return{...UM,...e??{},labelDayButton:WM(kM,e?.labelDayButton,n.labelDayButton),labelMonthDropdown:WM(PM,e?.labelMonthDropdown,n.labelMonthDropdown),labelNext:WM(LM,e?.labelNext,n.labelNext),labelPrevious:WM(RM,e?.labelPrevious,n.labelPrevious),labelWeekNumber:WM(BM,e?.labelWeekNumber,n.labelWeekNumber),labelYearDropdown:WM(HM,e?.labelYearDropdown,n.labelYearDropdown),labelGrid:WM(jM,e?.labelGrid,n.labelGrid),labelGridcell:WM(NM,e?.labelGridcell,n.labelGridcell),labelNav:WM(FM,e?.labelNav,n.labelNav),labelWeekNumberHeader:WM(VM,e?.labelWeekNumberHeader,n.labelWeekNumberHeader),labelWeekday:WM(zM,e?.labelWeekday,n.labelWeekday)}}function KM(e,t,n,r,i){let{startOfMonth:a,startOfYear:o,endOfYear:s,eachMonthOfInterval:c,getMonth:l}=i;return c({start:o(e),end:s(e)}).map(e=>{let o=r.formatMonthDropdown(e,i);return{value:l(e),label:o,disabled:t&&e<a(t)||n&&e>a(n)||!1}})}function qM(e,t={},n={}){let r={...t?.[jj.Day]};return Object.entries(e).filter(([,e])=>e===!0).forEach(([e])=>{r={...r,...n?.[e]}}),r}function JM(e,t,n,r){let i=r??e.today(),a=n?e.startOfBroadcastWeek(i,e):t?e.startOfISOWeek(i):e.startOfWeek(i),o=[];for(let t=0;t<7;t++){let n=e.addDays(a,t);o.push(n)}return o}function YM(e,t,n,r,i=!1){if(!e||!t)return;let{startOfYear:a,endOfYear:o,eachYearOfInterval:s,getYear:c}=r,l=s({start:a(e),end:o(t)});return i&&l.reverse(),l.map(e=>{let t=n.formatYearDropdown(e,r);return{value:c(e),label:t,disabled:!1}})}function XM(e,t={}){let{weekStartsOn:n,locale:r}=t,i=n??r?.options?.weekStartsOn??0,a=t=>{let n=typeof t==`number`||typeof t==`string`?new Date(t):t;return new mj(n.getFullYear(),n.getMonth(),n.getDate(),12,0,0,e)},o=e=>{let t=a(e);return new Date(t.getFullYear(),t.getMonth(),t.getDate(),0,0,0,0)};return{today:()=>a(mj.tz(e)),newDate:(t,n,r)=>new mj(t,n,r,12,0,0,e),startOfDay:e=>a(e),startOfWeek:(e,t)=>{let n=a(e),r=t?.weekStartsOn??i,o=(n.getDay()-r+7)%7;return n.setDate(n.getDate()-o),n},startOfISOWeek:e=>{let t=a(e),n=(t.getDay()-1+7)%7;return t.setDate(t.getDate()-n),t},startOfMonth:e=>{let t=a(e);return t.setDate(1),t},startOfYear:e=>{let t=a(e);return t.setMonth(0,1),t},endOfWeek:(e,t)=>{let n=a(e),r=(((t?.weekStartsOn??i)+6)%7-n.getDay()+7)%7;return n.setDate(n.getDate()+r),n},endOfISOWeek:e=>{let t=a(e),n=(7-t.getDay())%7;return t.setDate(t.getDate()+n),t},endOfMonth:e=>{let t=a(e);return t.setMonth(t.getMonth()+1,0),t},endOfYear:e=>{let t=a(e);return t.setMonth(11,31),t},eachMonthOfInterval:t=>{let n=a(t.start),r=a(t.end),i=[],o=new mj(n.getFullYear(),n.getMonth(),1,12,0,0,e),s=r.getFullYear()*12+r.getMonth();for(;o.getFullYear()*12+o.getMonth()<=s;)i.push(new mj(o,e)),o.setMonth(o.getMonth()+1,1);return i},addDays:(e,t)=>{let n=a(e);return n.setDate(n.getDate()+t),n},addWeeks:(e,t)=>{let n=a(e);return n.setDate(n.getDate()+t*7),n},addMonths:(e,t)=>{let n=a(e);return n.setMonth(n.getMonth()+t),n},addYears:(e,t)=>{let n=a(e);return n.setFullYear(n.getFullYear()+t),n},eachYearOfInterval:t=>{let n=a(t.start),r=a(t.end),i=[],o=new mj(n.getFullYear(),0,1,12,0,0,e);for(;o.getFullYear()<=r.getFullYear();)i.push(new mj(o,e)),o.setFullYear(o.getFullYear()+1,0,1);return i},getWeek:(e,t)=>vA(o(e),{weekStartsOn:t?.weekStartsOn??i,firstWeekContainsDate:t?.firstWeekContainsDate??r?.options?.firstWeekContainsDate??1}),getISOWeek:e=>hA(o(e)),differenceInCalendarDays:(e,t)=>Ik(o(e),o(t)),differenceInCalendarMonths:(e,t)=>Gk(o(e),o(t))}}var ZM=e=>e instanceof HTMLElement?e:null,QM=e=>[...e.querySelectorAll(`[data-animated-month]`)??[]],$M=e=>ZM(e.querySelector(`[data-animated-month]`)),eN=e=>ZM(e.querySelector(`[data-animated-caption]`)),tN=e=>ZM(e.querySelector(`[data-animated-weeks]`)),nN=e=>ZM(e.querySelector(`[data-animated-nav]`)),rN=e=>ZM(e.querySelector(`[data-animated-weekdays]`));function iN(e,t,{classNames:n,months:r,focused:i,dateLib:a}){let o=(0,v.useRef)(null),s=(0,v.useRef)(r),c=(0,v.useRef)(!1);(0,v.useLayoutEffect)(()=>{let l=s.current;if(s.current=r,!t||!e.current||!(e.current instanceof HTMLElement)||r.length===0||l.length===0||r.length!==l.length)return;let u=a.isSameMonth(r[0].date,l[0].date),d=a.isAfter(r[0].date,l[0].date),f=d?n[Pj.caption_after_enter]:n[Pj.caption_before_enter],p=d?n[Pj.weeks_after_enter]:n[Pj.weeks_before_enter],m=o.current,h=e.current.cloneNode(!0);if(h instanceof HTMLElement?(QM(h).forEach(e=>{if(!(e instanceof HTMLElement))return;let t=$M(e);t&&e.contains(t)&&e.removeChild(t);let n=eN(e);n&&n.classList.remove(f);let r=tN(e);r&&r.classList.remove(p)}),o.current=h):o.current=null,c.current||u||i)return;let g=m instanceof HTMLElement?QM(m):[],_=QM(e.current);if(_?.every(e=>e instanceof HTMLElement)&&g&&g.every(e=>e instanceof HTMLElement)){c.current=!0;let t=[];e.current.style.isolation=`isolate`;let r=nN(e.current);r&&(r.style.zIndex=`1`),_.forEach((i,a)=>{let o=g[a];if(!o)return;i.style.position=`relative`,i.style.overflow=`hidden`;let s=eN(i);s&&s.classList.add(f);let l=tN(i);l&&l.classList.add(p);let u=()=>{c.current=!1,e.current&&(e.current.style.isolation=``),r&&(r.style.zIndex=``),s&&s.classList.remove(f),l&&l.classList.remove(p),i.style.position=``,i.style.overflow=``,i.contains(o)&&i.removeChild(o)};t.push(u),o.style.pointerEvents=`none`,o.style.position=`absolute`,o.style.overflow=`hidden`,o.setAttribute(`aria-hidden`,`true`);let m=rN(o);m&&(m.style.opacity=`0`);let h=eN(o);h&&(h.classList.add(d?n[Pj.caption_before_exit]:n[Pj.caption_after_exit]),h.addEventListener(`animationend`,u));let _=tN(o);_&&_.classList.add(d?n[Pj.weeks_before_exit]:n[Pj.weeks_after_exit]),i.insertBefore(o,i.firstChild)})}})}function aN(e,t,n,r){let i=e[0],a=e[e.length-1],{ISOWeek:o,fixedWeeks:s,broadcastCalendar:c}=n??{},{addDays:l,differenceInCalendarDays:u,differenceInCalendarMonths:d,endOfBroadcastWeek:f,endOfISOWeek:p,endOfMonth:m,endOfWeek:h,isAfter:g,startOfBroadcastWeek:_,startOfISOWeek:v,startOfWeek:y}=r,b=c?_(i,r):o?v(i):y(i),x=c?f(a):o?p(m(a)):h(m(a)),S=t&&(c?f(t):o?p(t):h(t)),C=u(S&&g(x,S)?S:x,b),w=d(a,i)+1,T=[];for(let e=0;e<=C;e++){let t=l(b,e);T.push(t)}let E=(c?35:42)*w;if(s&&T.length<E){let e=E-T.length;for(let t=0;t<e;t++){let e=l(T[T.length-1],1);T.push(e)}}return T}function oN(e){let t=[];return e.reduce((e,n)=>{let r=n.weeks.reduce((e,t)=>e.concat(t.days.slice()),t.slice());return e.concat(r.slice())},t.slice())}function sN(e,t,n,r){let{numberOfMonths:i=1}=n,a=[];for(let n=0;n<i;n++){let i=r.addMonths(e,n);if(t&&i>t)break;a.push(i)}return a}function cN(e,t,n,r){let{month:i,defaultMonth:a,today:o=r.today(),numberOfMonths:s=1}=e,c=i||a||o,{differenceInCalendarMonths:l,addMonths:u,startOfMonth:d}=r;return n&&l(n,c)<s-1&&(c=u(n,-1*(s-1))),t&&l(c,t)<0&&(c=t),d(c)}function lN(e,t,n,r){let{addDays:i,endOfBroadcastWeek:a,endOfISOWeek:o,endOfMonth:s,endOfWeek:c,getISOWeek:l,getWeek:u,startOfBroadcastWeek:d,startOfISOWeek:f,startOfWeek:p}=r,m=e.reduce((e,m)=>{let h=n.broadcastCalendar?d(m,r):n.ISOWeek?f(m):p(m),g=n.broadcastCalendar?a(m):n.ISOWeek?o(s(m)):c(s(m)),_=t.filter(e=>e>=h&&e<=g),v=n.broadcastCalendar?35:42;if(n.fixedWeeks&&_.length<v){let e=t.filter(e=>{let t=v-_.length;return e>g&&e<=i(g,t)});_.push(...e)}let y=new wj(m,_.reduce((e,t)=>{let i=n.ISOWeek?l(t):u(t),a=e.find(e=>e.weekNumber===i),o=new Cj(t,m,r);return a?a.days.push(o):e.push(new Tj(i,[o])),e},[]));return e.push(y),e},[]);return n.reverseMonths?m.reverse():m}function uN(e,t){let{startMonth:n,endMonth:r}=e,{startOfYear:i,startOfDay:a,startOfMonth:o,endOfMonth:s,addYears:c,endOfYear:l,newDate:u,today:d}=t,{fromYear:f,toYear:p,fromMonth:m,toMonth:h}=e;!n&&m&&(n=m),!n&&f&&(n=t.newDate(f,0,1)),!r&&h&&(r=h),!r&&p&&(r=u(p,11,31));let g=e.captionLayout===`dropdown`||e.captionLayout===`dropdown-years`;return n?n=o(n):f?n=u(f,0,1):!n&&g&&(n=i(c(e.today??d(),-100))),r?r=s(r):p?r=u(p,11,31):!r&&g&&(r=l(e.today??d())),[n&&a(n),r&&a(r)]}function dN(e,t,n,r){if(n.disableNavigation)return;let{pagedNavigation:i,numberOfMonths:a=1}=n,{startOfMonth:o,addMonths:s,differenceInCalendarMonths:c}=r,l=i?a:1,u=o(e);if(!t||!(c(t,e)<a))return s(u,l)}function fN(e,t,n,r){if(n.disableNavigation)return;let{pagedNavigation:i,numberOfMonths:a}=n,{startOfMonth:o,addMonths:s,differenceInCalendarMonths:c}=r,l=i?a??1:1,u=o(e);if(!t||!(c(u,t)<=0))return s(u,-l)}function pN(e){return e.reduce((e,t)=>e.concat(t.weeks.slice()),[].slice())}function mN(e,t){let[n,r]=(0,v.useState)(e);return[t===void 0?n:t,r]}function hN(e,t){let[n,r]=uN(e,t),{startOfMonth:i,endOfMonth:a}=t,o=cN(e,n,r,t),[s,c]=mN(o,e.month?o:void 0);(0,v.useEffect)(()=>{c(cN(e,n,r,t))},[e.timeZone]);let{months:l,weeks:u,days:d,previousMonth:f,nextMonth:p}=(0,v.useMemo)(()=>{let i=sN(s,r,{numberOfMonths:e.numberOfMonths},t),o=lN(i,aN(i,e.endMonth?a(e.endMonth):void 0,{ISOWeek:e.ISOWeek,fixedWeeks:e.fixedWeeks,broadcastCalendar:e.broadcastCalendar},t),{broadcastCalendar:e.broadcastCalendar,fixedWeeks:e.fixedWeeks,ISOWeek:e.ISOWeek,reverseMonths:e.reverseMonths},t);return{months:o,weeks:pN(o),days:oN(o),previousMonth:fN(s,n,e,t),nextMonth:dN(s,r,e,t)}},[t,s.getTime(),r?.getTime(),n?.getTime(),e.disableNavigation,e.broadcastCalendar,e.endMonth?.getTime(),e.fixedWeeks,e.ISOWeek,e.numberOfMonths,e.pagedNavigation,e.reverseMonths]),{disableNavigation:m,onMonthChange:h}=e,g=e=>u.some(t=>t.days.some(t=>t.isEqualTo(e))),_=e=>{if(m)return;let t=i(e);n&&t<i(n)&&(t=i(n)),r&&t>i(r)&&(t=i(r)),c(t),h?.(t)};return{months:l,weeks:u,days:d,navStart:n,navEnd:r,previousMonth:f,nextMonth:p,goToMonth:_,goToDay:e=>{g(e)||_(e.date)}}}var gN;(function(e){e[e.Today=0]=`Today`,e[e.Selected=1]=`Selected`,e[e.LastFocused=2]=`LastFocused`,e[e.FocusedModifier=3]=`FocusedModifier`})(gN||={});function _N(e){return!e[Mj.disabled]&&!e[Mj.hidden]&&!e[Mj.outside]}function vN(e,t,n,r){let i,a=-1;for(let o of e){let e=t(o);_N(e)&&(e[Mj.focused]&&a<gN.FocusedModifier?(i=o,a=gN.FocusedModifier):r?.isEqualTo(o)&&a<gN.LastFocused?(i=o,a=gN.LastFocused):n(o.date)&&a<gN.Selected?(i=o,a=gN.Selected):e[Mj.today]&&a<gN.Today&&(i=o,a=gN.Today))}return i||=e.find(e=>_N(t(e))),i}function yN(e,t,n,r,i,a,o){let{ISOWeek:s,broadcastCalendar:c}=a,{addDays:l,addMonths:u,addWeeks:d,addYears:f,endOfBroadcastWeek:p,endOfISOWeek:m,endOfWeek:h,max:g,min:_,startOfBroadcastWeek:v,startOfISOWeek:y,startOfWeek:b}=o,x={day:l,week:d,month:u,year:f,startOfWeek:e=>c?v(e,o):s?y(e):b(e),endOfWeek:e=>c?p(e):s?m(e):h(e)}[e](n,t===`after`?1:-1);return t===`before`&&r?x=g([r,x]):t===`after`&&i&&(x=_([i,x])),x}function bN(e,t,n,r,i,a,o,s=0){if(s>365)return;let c=yN(e,t,n.date,r,i,a,o),l=!!(a.disabled&&fM(c,a.disabled,o)),u=!!(a.hidden&&fM(c,a.hidden,o)),d=new Cj(c,c,o);return!l&&!u?d:bN(e,t,d,r,i,a,o,s+1)}function xN(e,t,n,r,i){let{autoFocus:a}=e,[o,s]=(0,v.useState)(),c=vN(t.days,n,r||(()=>!1),o),[l,u]=(0,v.useState)(a?c:void 0);return{isFocusTarget:e=>!!c?.isEqualTo(e),setFocused:u,focused:l,blur:()=>{s(l),u(void 0)},moveFocus:(n,r)=>{if(!l)return;let a=bN(n,r,l,t.navStart,t.navEnd,e,i);a&&(e.disableNavigation&&!t.days.some(e=>e.isEqualTo(a))||(t.goToDay(a),u(a)))}}}function SN(e,t){let{selected:n,required:r,onSelect:i}=e,[a,o]=mN(n,i?n:void 0),s=i?n:a,{isSameDay:c}=t,l=e=>s?.some(t=>c(t,e))??!1,{min:u,max:d}=e;return{selected:s,select:(e,t,n)=>{let a=[...s??[]];if(l(e)){if(s?.length===u||r&&s?.length===1)return;a=s?.filter(t=>!c(t,e))}else a=s?.length===d?[e]:[...a,e];return i||o(a),i?.(a,e,t,n),a},isSelected:l}}function CN(e,t,n=0,r=0,i=!1,a=Sj){let{from:o,to:s}=t||{},{isSameDay:c,isAfter:l,isBefore:u}=a,d;if(!o&&!s)d={from:e,to:n>0?void 0:e};else if(o&&!s)d=c(o,e)?n===0?{from:o,to:e}:i?{from:o,to:void 0}:void 0:u(e,o)?{from:e,to:o}:{from:o,to:e};else if(o&&s)if(c(o,e)&&c(s,e))d=i?{from:o,to:s}:void 0;else if(c(o,e))d={from:o,to:n>0?void 0:e};else if(c(s,e))d={from:e,to:n>0?void 0:e};else if(u(e,o))d={from:e,to:s};else if(l(e,o))d={from:o,to:e};else if(l(e,s))d={from:o,to:e};else throw Error(`Invalid range`);if(d?.from&&d?.to){let t=a.differenceInCalendarDays(d.to,d.from);(r>0&&t>r||n>1&&t<n)&&(d={from:e,to:void 0})}return d}function wN(e,t,n=Sj){let r=Array.isArray(t)?t:[t],i=e.from,a=n.differenceInCalendarDays(e.to,e.from),o=Math.min(a,6);for(let e=0;e<=o;e++){if(r.includes(i.getDay()))return!0;i=n.addDays(i,1)}return!1}function TN(e,t,n=Sj){return aM(e,t.from,!1,n)||aM(e,t.to,!1,n)||aM(t,e.from,!1,n)||aM(t,e.to,!1,n)}function EN(e,t,n=Sj){let r=Array.isArray(t)?t:[t];if(r.filter(e=>typeof e!=`function`).some(t=>typeof t==`boolean`?t:n.isDate(t)?aM(e,t,!1,n):dM(t,n)?t.some(t=>aM(e,t,!1,n)):sM(t)?t.from&&t.to?TN(e,{from:t.from,to:t.to},n):!1:uM(t)?wN(e,t.dayOfWeek,n):oM(t)?n.isAfter(t.before,t.after)?TN(e,{from:n.addDays(t.after,1),to:n.addDays(t.before,-1)},n):fM(e.from,t,n)||fM(e.to,t,n):cM(t)||lM(t)?fM(e.from,t,n)||fM(e.to,t,n):!1))return!0;let i=r.filter(e=>typeof e==`function`);if(i.length){let t=e.from,r=n.differenceInCalendarDays(e.to,e.from);for(let e=0;e<=r;e++){if(i.some(e=>e(t)))return!0;t=n.addDays(t,1)}}return!1}function DN(e,t){let{disabled:n,excludeDisabled:r,resetOnSelect:i,selected:a,required:o,onSelect:s}=e,[c,l]=mN(a,s?a:void 0),u=s?a:c;return{selected:u,select:(a,c,d)=>{let{min:f,max:p}=e,m;if(a){let e=u?.from,n=u?.to,r=!!e&&!!n,s=!!e&&!!n&&t.isSameDay(e,n)&&t.isSameDay(a,e);m=i&&(r||!u?.from)?!o&&s?void 0:{from:a,to:void 0}:CN(a,u,f,p,o,t)}return r&&n&&m?.from&&m.to&&EN({from:m.from,to:m.to},n,t)&&(m.from=a,m.to=void 0),s||l(m),s?.(m,a,c,d),m},isSelected:e=>u&&aM(u,e,!1,t)}}function ON(e,t){let{selected:n,required:r,onSelect:i}=e,[a,o]=mN(n,i?n:void 0),s=i?n:a,{isSameDay:c}=t;return{selected:s,select:(e,t,n)=>{let a=e;return!r&&s&&s&&c(e,s)&&(a=void 0),i||o(a),i?.(a,e,t,n),a},isSelected:e=>s?c(s,e):!1}}function kN(e,t){let n=ON(e,t),r=SN(e,t),i=DN(e,t);switch(e.mode){case`single`:return n;case`multiple`:return r;case`range`:return i;default:return}}function AN(e,t){return e instanceof mj&&e.timeZone===t?e:new mj(e,t)}function jN(e,t,n){if(!n)return AN(e,t);let r=AN(e,t),i=new mj(r.getFullYear(),r.getMonth(),r.getDate(),12,0,0,t);return new Date(i.getTime())}function MN(e,t,n){return typeof e==`boolean`||typeof e==`function`?e:e instanceof Date?jN(e,t,n):Array.isArray(e)?e.map(e=>e instanceof Date?jN(e,t,n):e):sM(e)?{...e,from:e.from?AN(e.from,t):e.from,to:e.to?AN(e.to,t):e.to}:oM(e)?{before:jN(e.before,t,n),after:jN(e.after,t,n)}:cM(e)?{after:jN(e.after,t,n)}:lM(e)?{before:jN(e.before,t,n)}:e}function NN(e,t,n){return e&&(Array.isArray(e)?e.map(e=>MN(e,t,n)):MN(e,t,n))}function PN(e){let t=e,n=t.timeZone;if(n&&(t={...e,timeZone:n},t.today&&=AN(t.today,n),t.month&&=AN(t.month,n),t.defaultMonth&&=AN(t.defaultMonth,n),t.startMonth&&=AN(t.startMonth,n),t.endMonth&&=AN(t.endMonth,n),t.mode===`single`&&t.selected?t.selected=AN(t.selected,n):t.mode===`multiple`&&t.selected?t.selected=t.selected?.map(e=>AN(e,n)):t.mode===`range`&&t.selected&&(t.selected={from:t.selected.from?AN(t.selected.from,n):t.selected.from,to:t.selected.to?AN(t.selected.to,n):t.selected.to}),t.disabled!==void 0&&(t.disabled=NN(t.disabled,n)),t.hidden!==void 0&&(t.hidden=NN(t.hidden,n)),t.modifiers)){let e={};Object.keys(t.modifiers).forEach(r=>{e[r]=NN(t.modifiers?.[r],n)}),t.modifiers=e}let{components:r,formatters:i,labels:a,dateLib:o,locale:s,classNames:c}=(0,v.useMemo)(()=>{let e={...bj,...t.locale},n=t.broadcastCalendar?1:t.weekStartsOn,r=t.noonSafe&&t.timeZone?XM(t.timeZone,{weekStartsOn:n,locale:e}):void 0,i=t.dateLib&&r?{...r,...t.dateLib}:t.dateLib??r,a=new xj({locale:e,weekStartsOn:n,firstWeekContainsDate:t.firstWeekContainsDate,useAdditionalWeekYearTokens:t.useAdditionalWeekYearTokens,useAdditionalDayOfYearTokens:t.useAdditionalDayOfYearTokens,timeZone:t.timeZone,numerals:t.numerals},i);return{dateLib:a,components:hM(t.components),formatters:OM(t.formatters),labels:GM(t.labels,a.options),locale:e,classNames:{..._M(),...t.classNames}}},[t.locale,t.broadcastCalendar,t.weekStartsOn,t.firstWeekContainsDate,t.useAdditionalWeekYearTokens,t.useAdditionalDayOfYearTokens,t.timeZone,t.numerals,t.dateLib,t.noonSafe,t.components,t.formatters,t.labels,t.classNames]);t.today||(t={...t,today:o.today()});let{captionLayout:l,mode:u,navLayout:d,numberOfMonths:f=1,onDayBlur:p,onDayClick:m,onDayFocus:h,onDayKeyDown:g,onDayMouseEnter:_,onDayMouseLeave:y,onNextClick:b,onPrevClick:x,showWeekNumber:S,styles:C}=t,{formatCaption:w,formatDay:T,formatMonthDropdown:E,formatWeekNumber:D,formatWeekNumberHeader:O,formatWeekdayName:k,formatYearDropdown:A}=i,j=hN(t,o),{days:M,months:N,navStart:P,navEnd:F,previousMonth:I,nextMonth:L,goToMonth:R}=j,ee=pM(M,t,P,F,o),{isSelected:te,select:z,selected:B}=kN(t,o)??{},{blur:V,focused:ne,isFocusTarget:H,moveFocus:re,setFocused:ie}=xN(t,j,ee,te??(()=>!1),o),{labelDayButton:ae,labelGridcell:oe,labelGrid:se,labelMonthDropdown:ce,labelNav:le,labelPrevious:ue,labelNext:de,labelWeekday:fe,labelWeekNumber:pe,labelWeekNumberHeader:me,labelYearDropdown:he}=a,ge=(0,v.useMemo)(()=>JM(o,t.ISOWeek,t.broadcastCalendar,t.today),[o,t.ISOWeek,t.broadcastCalendar,t.today]),_e=u!==void 0||m!==void 0,ve=(0,v.useCallback)(()=>{I&&(R(I),x?.(I))},[I,R,x]),ye=(0,v.useCallback)(()=>{L&&(R(L),b?.(L))},[R,L,b]),be=(0,v.useCallback)((e,t)=>n=>{n.preventDefault(),n.stopPropagation(),ie(e),!t.disabled&&(z?.(e.date,t,n),m?.(e.date,t,n))},[z,m,ie]),xe=(0,v.useCallback)((e,t)=>n=>{ie(e),h?.(e.date,t,n)},[h,ie]),Se=(0,v.useCallback)((e,t)=>n=>{V(),p?.(e.date,t,n)},[V,p]),Ce=(0,v.useCallback)((e,n)=>r=>{let i={ArrowLeft:[r.shiftKey?`month`:`day`,t.dir===`rtl`?`after`:`before`],ArrowRight:[r.shiftKey?`month`:`day`,t.dir===`rtl`?`before`:`after`],ArrowDown:[r.shiftKey?`year`:`week`,`after`],ArrowUp:[r.shiftKey?`year`:`week`,`before`],PageUp:[r.shiftKey?`year`:`month`,`before`],PageDown:[r.shiftKey?`year`:`month`,`after`],Home:[`startOfWeek`,`before`],End:[`endOfWeek`,`after`]};if(i[r.key]){r.preventDefault(),r.stopPropagation();let[e,t]=i[r.key];re(e,t)}g?.(e.date,n,r)},[re,g,t.dir]),we=(0,v.useCallback)((e,t)=>n=>{_?.(e.date,t,n)},[_]),Te=(0,v.useCallback)((e,t)=>n=>{y?.(e.date,t,n)},[y]),Ee=(0,v.useCallback)(e=>t=>{let n=Number(t.target.value);R(o.setMonth(o.startOfMonth(e),n))},[o,R]),De=(0,v.useCallback)(e=>t=>{let n=Number(t.target.value);R(o.setYear(o.startOfMonth(e),n))},[o,R]),{className:Oe,style:ke}=(0,v.useMemo)(()=>({className:[c[jj.Root],t.className].filter(Boolean).join(` `),style:{...C?.[jj.Root],...t.style}}),[c,t.className,t.style,C]),Ae=gM(t),je=(0,v.useRef)(null);iN(je,!!t.animate,{classNames:c,months:N,focused:ne,dateLib:o});let Me={dayPickerProps:t,selected:B,select:z,isSelected:te,months:N,nextMonth:L,previousMonth:I,goToMonth:R,getModifiers:ee,components:r,classNames:c,styles:C,labels:a,formatters:i};return v.createElement(Hj.Provider,{value:Me},v.createElement(r.Root,{rootRef:t.animate?je:void 0,className:Oe,style:ke,dir:t.dir,id:t.id,lang:t.lang??s.code,nonce:t.nonce,title:t.title,role:t.role,"aria-label":t[`aria-label`],"aria-labelledby":t[`aria-labelledby`],...Ae},v.createElement(r.Months,{className:c[jj.Months],style:C?.[jj.Months]},!t.hideNavigation&&!d&&v.createElement(r.Nav,{"data-animated-nav":t.animate?`true`:void 0,className:c[jj.Nav],style:C?.[jj.Nav],"aria-label":le(),onPreviousClick:ve,onNextClick:ye,previousMonth:I,nextMonth:L}),N.map((e,n)=>v.createElement(r.Month,{"data-animated-month":t.animate?`true`:void 0,className:c[jj.Month],style:C?.[jj.Month],key:n,displayIndex:n,calendarMonth:e},d===`around`&&!t.hideNavigation&&n===0&&v.createElement(r.PreviousMonthButton,{type:`button`,className:c[jj.PreviousMonthButton],tabIndex:I?void 0:-1,"aria-disabled":I?void 0:!0,"aria-label":ue(I),onClick:ve,"data-animated-button":t.animate?`true`:void 0},v.createElement(r.Chevron,{disabled:I?void 0:!0,className:c[jj.Chevron],orientation:t.dir===`rtl`?`right`:`left`})),v.createElement(r.MonthCaption,{"data-animated-caption":t.animate?`true`:void 0,className:c[jj.MonthCaption],style:C?.[jj.MonthCaption],calendarMonth:e,displayIndex:n},l?.startsWith(`dropdown`)?v.createElement(r.DropdownNav,{className:c[jj.Dropdowns],style:C?.[jj.Dropdowns]},(()=>{let n=l===`dropdown`||l===`dropdown-months`?v.createElement(r.MonthsDropdown,{key:`month`,className:c[jj.MonthsDropdown],"aria-label":ce(),classNames:c,components:r,disabled:!!t.disableNavigation,onChange:Ee(e.date),options:KM(e.date,P,F,i,o),style:C?.[jj.Dropdown],value:o.getMonth(e.date)}):v.createElement(`span`,{key:`month`},E(e.date,o)),a=l===`dropdown`||l===`dropdown-years`?v.createElement(r.YearsDropdown,{key:`year`,className:c[jj.YearsDropdown],"aria-label":he(o.options),classNames:c,components:r,disabled:!!t.disableNavigation,onChange:De(e.date),options:YM(P,F,i,o,!!t.reverseYears),style:C?.[jj.Dropdown],value:o.getYear(e.date)}):v.createElement(`span`,{key:`year`},A(e.date,o));return o.getMonthYearOrder()===`year-first`?[a,n]:[n,a]})(),v.createElement(`span`,{role:`status`,"aria-live":`polite`,style:{border:0,clip:`rect(0 0 0 0)`,height:`1px`,margin:`-1px`,overflow:`hidden`,padding:0,position:`absolute`,width:`1px`,whiteSpace:`nowrap`,wordWrap:`normal`}},w(e.date,o.options,o))):v.createElement(r.CaptionLabel,{className:c[jj.CaptionLabel],role:`status`,"aria-live":`polite`},w(e.date,o.options,o))),d===`around`&&!t.hideNavigation&&n===f-1&&v.createElement(r.NextMonthButton,{type:`button`,className:c[jj.NextMonthButton],tabIndex:L?void 0:-1,"aria-disabled":L?void 0:!0,"aria-label":de(L),onClick:ye,"data-animated-button":t.animate?`true`:void 0},v.createElement(r.Chevron,{disabled:L?void 0:!0,className:c[jj.Chevron],orientation:t.dir===`rtl`?`left`:`right`})),n===f-1&&d===`after`&&!t.hideNavigation&&v.createElement(r.Nav,{"data-animated-nav":t.animate?`true`:void 0,className:c[jj.Nav],style:C?.[jj.Nav],"aria-label":le(),onPreviousClick:ve,onNextClick:ye,previousMonth:I,nextMonth:L}),v.createElement(r.MonthGrid,{role:`grid`,"aria-multiselectable":u===`multiple`||u===`range`,"aria-label":se(e.date,o.options,o)||void 0,className:c[jj.MonthGrid],style:C?.[jj.MonthGrid]},!t.hideWeekdays&&v.createElement(r.Weekdays,{"data-animated-weekdays":t.animate?`true`:void 0,className:c[jj.Weekdays],style:C?.[jj.Weekdays]},S&&v.createElement(r.WeekNumberHeader,{"aria-label":me(o.options),className:c[jj.WeekNumberHeader],style:C?.[jj.WeekNumberHeader],scope:`col`},O()),ge.map(e=>v.createElement(r.Weekday,{"aria-label":fe(e,o.options,o),className:c[jj.Weekday],key:String(e),style:C?.[jj.Weekday],scope:`col`},k(e,o.options,o)))),v.createElement(r.Weeks,{"data-animated-weeks":t.animate?`true`:void 0,className:c[jj.Weeks],style:C?.[jj.Weeks]},e.weeks.map(e=>v.createElement(r.Week,{className:c[jj.Week],key:e.weekNumber,style:C?.[jj.Week],week:e},S&&v.createElement(r.WeekNumber,{week:e,style:C?.[jj.WeekNumber],"aria-label":pe(e.weekNumber,{locale:s}),className:c[jj.WeekNumber],scope:`row`,role:`rowheader`},D(e.weekNumber,o)),e.days.map(e=>{let{date:n}=e,i=ee(e);if(i[Mj.focused]=!i.hidden&&!!ne?.isEqualTo(e),i[Nj.selected]=te?.(n)||i.selected,sM(B)){let{from:e,to:t}=B;i[Nj.range_start]=!!(e&&t&&o.isSameDay(n,e)),i[Nj.range_end]=!!(e&&t&&o.isSameDay(n,t)),i[Nj.range_middle]=aM(B,n,!0,o)}let a=qM(i,C,t.modifiersStyles),s=mM(i,c,t.modifiersClassNames),l=!_e&&!i.hidden?oe(n,i,o.options,o):void 0;return v.createElement(r.Day,{key:`${e.isoDate}_${e.displayMonthId}`,day:e,modifiers:i,className:s.join(` `),style:a,role:`gridcell`,"aria-selected":i.selected||void 0,"aria-label":l,"data-day":e.isoDate,"data-month":e.outside?e.dateMonthId:void 0,"data-selected":i.selected||void 0,"data-disabled":i.disabled||void 0,"data-hidden":i.hidden||void 0,"data-outside":e.outside||void 0,"data-focused":i.focused||void 0,"data-today":i.today||void 0},!i.hidden&&_e?v.createElement(r.DayButton,{className:c[jj.DayButton],style:C?.[jj.DayButton],type:`button`,day:e,modifiers:i,disabled:!i.focused&&i.disabled||void 0,"aria-disabled":i.focused&&i.disabled||void 0,tabIndex:H(e)?0:-1,"aria-label":ae(n,i,o.options,o),onClick:be(e,i),onBlur:Se(e,i),onFocus:xe(e,i),onKeyDown:Ce(e,i),onMouseEnter:we(e,i),onMouseLeave:Te(e,i)},T(n,o.options,o)):!i.hidden&&T(e.date,o.options,o))})))))))),t.footer&&v.createElement(r.Footer,{className:c[jj.Footer],style:C?.[jj.Footer],role:`status`,"aria-live":`polite`},t.footer)))}function FN({className:e,classNames:t,showOutsideDays:n=!0,captionLayout:r=`label`,buttonVariant:i=`ghost`,formatters:a,components:o,...s}){let c=_M();return(0,U.jsx)(PN,{showOutsideDays:n,className:q(`group/calendar bg-background p-3 [--cell-size:--spacing(8)] [[data-slot=card-content]_&]:bg-transparent [[data-slot=popover-content]_&]:bg-transparent`,String.raw`rtl:**:[.rdp-button\_next>svg]:rotate-180`,String.raw`rtl:**:[.rdp-button\_previous>svg]:rotate-180`,e),captionLayout:r,formatters:{formatMonthDropdown:e=>e.toLocaleString(`default`,{month:`short`}),...a},classNames:{root:q(`w-fit`,c.root),months:q(`relative flex flex-col gap-4 md:flex-row`,c.months),month:q(`flex w-full flex-col gap-4`,c.month),nav:q(`absolute inset-x-0 top-0 flex w-full items-center justify-between gap-1`,c.nav),button_previous:q(Xc({variant:i}),`size-(--cell-size) p-0 select-none aria-disabled:opacity-50`,c.button_previous),button_next:q(Xc({variant:i}),`size-(--cell-size) p-0 select-none aria-disabled:opacity-50`,c.button_next),month_caption:q(`flex h-(--cell-size) w-full items-center justify-center px-(--cell-size)`,c.month_caption),dropdowns:q(`flex h-(--cell-size) w-full items-center justify-center gap-1.5 text-sm font-medium`,c.dropdowns),dropdown_root:q(`relative rounded-md border border-input shadow-xs has-focus:border-ring has-focus:ring-[3px] has-focus:ring-ring/50`,c.dropdown_root),dropdown:q(`absolute inset-0 bg-popover opacity-0`,c.dropdown),caption_label:q(`font-medium select-none`,r===`label`?`text-sm`:`flex h-8 items-center gap-1 rounded-md pr-1 pl-2 text-sm [&>svg]:size-3.5 [&>svg]:text-muted-foreground`,c.caption_label),table:`w-full border-collapse`,weekdays:q(`flex`,c.weekdays),weekday:q(`flex-1 rounded-md text-[0.8rem] font-normal text-muted-foreground select-none`,c.weekday),week:q(`mt-2 flex w-full`,c.week),week_number_header:q(`w-(--cell-size) select-none`,c.week_number_header),week_number:q(`text-[0.8rem] text-muted-foreground select-none`,c.week_number),day:q(`group/day relative aspect-square h-full w-full p-0 text-center select-none [&:last-child[data-selected=true]_button]:rounded-r-md`,s.showWeekNumber?`[&:nth-child(2)[data-selected=true]_button]:rounded-l-md`:`[&:first-child[data-selected=true]_button]:rounded-l-md`,c.day),range_start:q(`rounded-l-md bg-accent`,c.range_start),range_middle:q(`rounded-none`,c.range_middle),range_end:q(`rounded-r-md bg-accent`,c.range_end),today:q(`rounded-md bg-accent text-accent-foreground data-[selected=true]:rounded-none`,c.today),outside:q(`text-muted-foreground aria-selected:text-muted-foreground`,c.outside),disabled:q(`text-muted-foreground opacity-50`,c.disabled),hidden:q(`invisible`,c.hidden),...t},components:{Root:({className:e,rootRef:t,...n})=>(0,U.jsx)(`div`,{"data-slot":`calendar`,ref:t,className:q(e),...n}),Chevron:({className:e,orientation:t,...n})=>t===`left`?(0,U.jsx)(Va,{className:q(`size-4`,e),...n}):t===`right`?(0,U.jsx)(Ha,{className:q(`size-4`,e),...n}):(0,U.jsx)(Ba,{className:q(`size-4`,e),...n}),DayButton:IN,WeekNumber:({children:e,...t})=>(0,U.jsx)(`td`,{...t,children:(0,U.jsx)(`div`,{className:`flex size-(--cell-size) items-center justify-center text-center`,children:e})}),...o},...s})}function IN({className:e,day:t,modifiers:n,...r}){let i=_M(),a=v.useRef(null);return v.useEffect(()=>{n.focused&&a.current?.focus()},[n.focused]),(0,U.jsx)(J,{ref:a,variant:`ghost`,size:`icon`,"data-day":t.date.toLocaleDateString(),"data-selected-single":n.selected&&!n.range_start&&!n.range_end&&!n.range_middle,"data-range-start":n.range_start,"data-range-end":n.range_end,"data-range-middle":n.range_middle,className:q(`flex aspect-square size-auto w-full min-w-(--cell-size) flex-col gap-1 leading-none font-normal`,`group-data-[focused=true]/day:relative group-data-[focused=true]/day:z-10`,`group-data-[focused=true]/day:border-ring group-data-[focused=true]/day:ring-[3px] group-data-[focused=true]/day:ring-ring/50`,`data-[range-end=true]:rounded-md data-[range-end=true]:bg-primary data-[range-end=true]:text-primary-foreground`,`data-[range-middle=true]:rounded-none data-[range-middle=true]:bg-accent data-[range-middle=true]:text-accent-foreground`,`data-[range-start=true]:rounded-md data-[range-start=true]:bg-primary data-[range-start=true]:text-primary-foreground`,`data-[selected-single=true]:bg-primary data-[selected-single=true]:text-primary-foreground`,`dark:hover:text-accent-foreground [&>span]:text-xs [&>span]:opacity-70`,i.day,e),...r})}function LN({...e}){return(0,U.jsx)(tS,{"data-slot":`popover`,...e})}function RN({...e}){return(0,U.jsx)(nS,{"data-slot":`popover-trigger`,...e})}function zN({className:e,align:t=`center`,sideOffset:n=4,...r}){return(0,U.jsx)(rS,{children:(0,U.jsx)(iS,{"data-slot":`popover-content`,align:t,sideOffset:n,className:q(`z-50 w-72 origin-(--radix-popover-content-transform-origin) rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-hidden`,`data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,`data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95`,`data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95`,e),...r})})}var BN=v.forwardRef(({className:e,...t},n)=>(0,U.jsx)(`textarea`,{className:q(`flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50`,e),ref:n,...t}));BN.displayName=`Textarea`;function VN({...e}){return(0,U.jsx)(yb,{"data-slot":`accordion`,...e})}function HN({className:e,...t}){return(0,U.jsx)(bb,{"data-slot":`accordion-item`,className:q(`border-b last:border-b-0`,e),...t})}function UN({className:e,children:t,...n}){return(0,U.jsx)(xb,{className:`flex`,children:(0,U.jsxs)(Sb,{"data-slot":`accordion-trigger`,className:q(`flex flex-1 items-start justify-between gap-4 rounded-md py-4 text-left text-sm font-medium transition-all outline-none hover:underline focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 [&[data-state=open]>svg]:rotate-180`,e),...n,children:[t,(0,U.jsx)(Ba,{className:`pointer-events-none size-4 shrink-0 translate-y-0.5 text-muted-foreground transition-transform duration-200`})]})})}function WN({className:e,children:t,...n}){return(0,U.jsx)(Cb,{"data-slot":`accordion-content`,className:`overflow-hidden text-sm data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down`,...n,children:(0,U.jsx)(`div`,{className:q(`pt-0 pb-4`,e),children:t})})}function GN(e){this.content=e}GN.prototype={constructor:GN,find:function(e){for(var t=0;t<this.content.length;t+=2)if(this.content[t]===e)return t;return-1},get:function(e){var t=this.find(e);return t==-1?void 0:this.content[t+1]},update:function(e,t,n){var r=n&&n!=e?this.remove(n):this,i=r.find(e),a=r.content.slice();return i==-1?a.push(n||e,t):(a[i+1]=t,n&&(a[i]=n)),new GN(a)},remove:function(e){var t=this.find(e);if(t==-1)return this;var n=this.content.slice();return n.splice(t,2),new GN(n)},addToStart:function(e,t){return new GN([e,t].concat(this.remove(e).content))},addToEnd:function(e,t){var n=this.remove(e).content.slice();return n.push(e,t),new GN(n)},addBefore:function(e,t,n){var r=this.remove(t),i=r.content.slice(),a=r.find(e);return i.splice(a==-1?i.length:a,0,t,n),new GN(i)},forEach:function(e){for(var t=0;t<this.content.length;t+=2)e(this.content[t],this.content[t+1])},prepend:function(e){return e=GN.from(e),e.size?new GN(e.content.concat(this.subtract(e).content)):this},append:function(e){return e=GN.from(e),e.size?new GN(this.subtract(e).content.concat(e.content)):this},subtract:function(e){var t=this;e=GN.from(e);for(var n=0;n<e.content.length;n+=2)t=t.remove(e.content[n]);return t},toObject:function(){var e={};return this.forEach(function(t,n){e[t]=n}),e},get size(){return this.content.length>>1}},GN.from=function(e){if(e instanceof GN)return e;var t=[];if(e)for(var n in e)t.push(n,e[n]);return new GN(t)};function KN(e,t,n){for(let r=0;;r++){if(r==e.childCount||r==t.childCount)return e.childCount==t.childCount?null:n;let i=e.child(r),a=t.child(r);if(i==a){n+=i.nodeSize;continue}if(!i.sameMarkup(a))return n;if(i.isText&&i.text!=a.text){for(let e=0;i.text[e]==a.text[e];e++)n++;return n}if(i.content.size||a.content.size){let e=KN(i.content,a.content,n+1);if(e!=null)return e}n+=i.nodeSize}}function qN(e,t,n,r){for(let i=e.childCount,a=t.childCount;;){if(i==0||a==0)return i==a?null:{a:n,b:r};let o=e.child(--i),s=t.child(--a),c=o.nodeSize;if(o==s){n-=c,r-=c;continue}if(!o.sameMarkup(s))return{a:n,b:r};if(o.isText&&o.text!=s.text){let e=0,t=Math.min(o.text.length,s.text.length);for(;e<t&&o.text[o.text.length-e-1]==s.text[s.text.length-e-1];)e++,n--,r--;return{a:n,b:r}}if(o.content.size||s.content.size){let e=qN(o.content,s.content,n-1,r-1);if(e)return e}n-=c,r-=c}}var Z=class e{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let t=0;t<e.length;t++)this.size+=e[t].nodeSize}nodesBetween(e,t,n,r=0,i){for(let a=0,o=0;o<t;a++){let s=this.content[a],c=o+s.nodeSize;if(c>e&&n(s,r+o,i||null,a)!==!1&&s.content.size){let i=o+1;s.nodesBetween(Math.max(0,e-i),Math.min(s.content.size,t-i),n,r+i)}o=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,n,r){let i=``,a=!0;return this.nodesBetween(e,t,(o,s)=>{let c=o.isText?o.text.slice(Math.max(e,s)-s,t-s):o.isLeaf?r?typeof r==`function`?r(o):r:o.type.spec.leafText?o.type.spec.leafText(o):``:``;o.isBlock&&(o.isLeaf&&c||o.isTextblock)&&n&&(a?a=!1:i+=n),i+=c},0),i}append(t){if(!t.size)return this;if(!this.size)return t;let n=this.lastChild,r=t.firstChild,i=this.content.slice(),a=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),a=1);a<t.content.length;a++)i.push(t.content[a]);return new e(i,this.size+t.size)}cut(t,n=this.size){if(t==0&&n==this.size)return this;let r=[],i=0;if(n>t)for(let e=0,a=0;a<n;e++){let o=this.content[e],s=a+o.nodeSize;s>t&&((a<t||s>n)&&(o=o.isText?o.cut(Math.max(0,t-a),Math.min(o.text.length,n-a)):o.cut(Math.max(0,t-a-1),Math.min(o.content.size,n-a-1))),r.push(o),i+=o.nodeSize),a=s}return new e(r,i)}cutByIndex(t,n){return t==n?e.empty:t==0&&n==this.content.length?this:new e(this.content.slice(t,n))}replaceChild(t,n){let r=this.content[t];if(r==n)return this;let i=this.content.slice(),a=this.size+n.nodeSize-r.nodeSize;return i[t]=n,new e(i,a)}addToStart(t){return new e([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new e(this.content.concat(t),this.size+t.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw RangeError(`Index `+e+` out of range for `+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,n=0;t<this.content.length;t++){let r=this.content[t];e(r,n,t),n+=r.nodeSize}}findDiffStart(e,t=0){return KN(this,e,t)}findDiffEnd(e,t=this.size,n=e.size){return qN(this,e,t,n)}findIndex(e){if(e==0)return YN(0,e);if(e==this.size)return YN(this.content.length,e);if(e>this.size||e<0)throw RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,n=0;;t++){let r=this.child(t),i=n+r.nodeSize;if(i>=e)return i==e?YN(t+1,i):YN(t,n);n=i}}toString(){return`<`+this.toStringInner()+`>`}toStringInner(){return this.content.join(`, `)}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(t,n){if(!n)return e.empty;if(!Array.isArray(n))throw RangeError(`Invalid input for Fragment.fromJSON`);return new e(n.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return e.empty;let n,r=0;for(let e=0;e<t.length;e++){let i=t[e];r+=i.nodeSize,e&&i.isText&&t[e-1].sameMarkup(i)?(n||=t.slice(0,e),n[n.length-1]=i.withText(n[n.length-1].text+i.text)):n&&n.push(i)}return new e(n||t,r)}static from(t){if(!t)return e.empty;if(t instanceof e)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new e([t],t.nodeSize);throw RangeError(`Can not convert `+t+` to a Fragment`+(t.nodesBetween?` (looks like multiple versions of prosemirror-model were loaded)`:``))}};Z.empty=new Z([],0);var JN={index:0,offset:0};function YN(e,t){return JN.index=e,JN.offset=t,JN}function XN(e,t){if(e===t)return!0;if(!(e&&typeof e==`object`)||!(t&&typeof t==`object`))return!1;let n=Array.isArray(e);if(Array.isArray(t)!=n)return!1;if(n){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!XN(e[n],t[n]))return!1}else{for(let n in e)if(!(n in t)||!XN(e[n],t[n]))return!1;for(let n in t)if(!(n in e))return!1}return!0}var ZN=class e{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,n=!1;for(let r=0;r<e.length;r++){let i=e[r];if(this.eq(i))return e;if(this.type.excludes(i.type))t||=e.slice(0,r);else if(i.type.excludes(this.type))return e;else !n&&i.type.rank>this.type.rank&&(t||=e.slice(0,r),t.push(this),n=!0),t&&t.push(i)}return t||=e.slice(),n||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&XN(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw RangeError(`Invalid input for Mark.fromJSON`);let n=e.marks[t.type];if(!n)throw RangeError(`There is no mark type ${t.type} in this schema`);let r=n.create(t.attrs);return n.checkAttrs(r.attrs),r}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].eq(t[n]))return!1;return!0}static setFrom(t){if(!t||Array.isArray(t)&&t.length==0)return e.none;if(t instanceof e)return[t];let n=t.slice();return n.sort((e,t)=>e.type.rank-t.type.rank),n}};ZN.none=[];var QN=class extends Error{},Q=class e{constructor(e,t,n){this.content=e,this.openStart=t,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,n){let r=eP(this.content,t+this.openStart,n);return r&&new e(r,this.openStart,this.openEnd)}removeBetween(t,n){return new e($N(this.content,t+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+`(`+this.openStart+`,`+this.openEnd+`)`}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(t,n){if(!n)return e.empty;let r=n.openStart||0,i=n.openEnd||0;if(typeof r!=`number`||typeof i!=`number`)throw RangeError(`Invalid input for Slice.fromJSON`);return new e(Z.fromJSON(t,n.content),r,i)}static maxOpen(t,n=!0){let r=0,i=0;for(let e=t.firstChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.firstChild)r++;for(let e=t.lastChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.lastChild)i++;return new e(t,r,i)}};Q.empty=new Q(Z.empty,0,0);function $N(e,t,n){let{index:r,offset:i}=e.findIndex(t),a=e.maybeChild(r),{index:o,offset:s}=e.findIndex(n);if(i==t||a.isText){if(s!=n&&!e.child(o).isText)throw RangeError(`Removing non-flat range`);return e.cut(0,t).append(e.cut(n))}if(r!=o)throw RangeError(`Removing non-flat range`);return e.replaceChild(r,a.copy($N(a.content,t-i-1,n-i-1)))}function eP(e,t,n,r){let{index:i,offset:a}=e.findIndex(t),o=e.maybeChild(i);if(a==t||o.isText)return r&&!r.canReplace(i,i,n)?null:e.cut(0,t).append(n).append(e.cut(t));let s=eP(o.content,t-a-1,n,o);return s&&e.replaceChild(i,o.copy(s))}function tP(e,t,n){if(n.openStart>e.depth)throw new QN(`Inserted content deeper than insertion position`);if(e.depth-n.openStart!=t.depth-n.openEnd)throw new QN(`Inconsistent open depths`);return nP(e,t,n,0)}function nP(e,t,n,r){let i=e.index(r),a=e.node(r);if(i==t.index(r)&&r<e.depth-n.openStart){let o=nP(e,t,n,r+1);return a.copy(a.content.replaceChild(i,o))}else if(!n.content.size)return sP(a,lP(e,t,r));else if(!n.openStart&&!n.openEnd&&e.depth==r&&t.depth==r){let r=e.parent,i=r.content;return sP(r,i.cut(0,e.parentOffset).append(n.content).append(i.cut(t.parentOffset)))}else{let{start:i,end:o}=uP(n,e);return sP(a,cP(e,i,o,t,r))}}function rP(e,t){if(!t.type.compatibleContent(e.type))throw new QN(`Cannot join `+t.type.name+` onto `+e.type.name)}function iP(e,t,n){let r=e.node(n);return rP(r,t.node(n)),r}function aP(e,t){let n=t.length-1;n>=0&&e.isText&&e.sameMarkup(t[n])?t[n]=e.withText(t[n].text+e.text):t.push(e)}function oP(e,t,n,r){let i=(t||e).node(n),a=0,o=t?t.index(n):i.childCount;e&&(a=e.index(n),e.depth>n?a++:e.textOffset&&(aP(e.nodeAfter,r),a++));for(let e=a;e<o;e++)aP(i.child(e),r);t&&t.depth==n&&t.textOffset&&aP(t.nodeBefore,r)}function sP(e,t){return e.type.checkContent(t),e.copy(t)}function cP(e,t,n,r,i){let a=e.depth>i&&iP(e,t,i+1),o=r.depth>i&&iP(n,r,i+1),s=[];return oP(null,e,i,s),a&&o&&t.index(i)==n.index(i)?(rP(a,o),aP(sP(a,cP(e,t,n,r,i+1)),s)):(a&&aP(sP(a,lP(e,t,i+1)),s),oP(t,n,i,s),o&&aP(sP(o,lP(n,r,i+1)),s)),oP(r,null,i,s),new Z(s)}function lP(e,t,n){let r=[];return oP(null,e,n,r),e.depth>n&&aP(sP(iP(e,t,n+1),lP(e,t,n+1)),r),oP(t,null,n,r),new Z(r)}function uP(e,t){let n=t.depth-e.openStart,r=t.node(n).copy(e.content);for(let e=n-1;e>=0;e--)r=t.node(e).copy(Z.from(r));return{start:r.resolveNoCache(e.openStart+n),end:r.resolveNoCache(r.content.size-e.openEnd-n)}}var dP=class e{constructor(e,t,n){this.pos=e,this.path=t,this.parentOffset=n,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw RangeError(`There is no position before the top-level node`);return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw RangeError(`There is no position after the top-level node`);return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let n=this.pos-this.path[this.path.length-1],r=e.child(t);return n?e.child(t).cut(n):r}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let n=this.path[t*3],r=t==0?0:this.path[t*3-1]+1;for(let t=0;t<e;t++)r+=n.child(t).nodeSize;return r}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return ZN.none;if(this.textOffset)return e.child(t).marks;let n=e.maybeChild(t-1),r=e.maybeChild(t);if(!n){let e=n;n=r,r=e}let i=n.marks;for(var a=0;a<i.length;a++)i[a].type.spec.inclusive===!1&&(!r||!i[a].isInSet(r.marks))&&(i=i[a--].removeFromSet(i));return i}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let n=t.marks,r=e.parent.maybeChild(e.index());for(var i=0;i<n.length;i++)n[i].type.spec.inclusive===!1&&(!r||!n[i].isInSet(r.marks))&&(n=n[i--].removeFromSet(n));return n}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let n=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);n>=0;n--)if(e.pos<=this.end(n)&&(!t||t(this.node(n))))return new hP(this,e,n);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e=``;for(let t=1;t<=this.depth;t++)e+=(e?`/`:``)+this.node(t).type.name+`_`+this.index(t-1);return e+`:`+this.parentOffset}static resolve(t,n){if(!(n>=0&&n<=t.content.size))throw RangeError(`Position `+n+` out of range`);let r=[],i=0,a=n;for(let e=t;;){let{index:t,offset:n}=e.content.findIndex(a),o=a-n;if(r.push(e,t,i+n),!o||(e=e.child(t),e.isText))break;a=o-1,i+=n+1}return new e(n,r,a)}static resolveCached(t,n){let r=mP.get(t);if(r)for(let e=0;e<r.elts.length;e++){let t=r.elts[e];if(t.pos==n)return t}else mP.set(t,r=new fP);let i=r.elts[r.i]=e.resolve(t,n);return r.i=(r.i+1)%pP,i}},fP=class{constructor(){this.elts=[],this.i=0}},pP=12,mP=new WeakMap,hP=class{constructor(e,t,n){this.$from=e,this.$to=t,this.depth=n}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}},gP=Object.create(null),_P=class e{constructor(e,t,n,r=ZN.none){this.type=e,this.attrs=t,this.marks=r,this.content=n||Z.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,n,r=0){this.content.nodesBetween(e,t,n,r,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,``)}textBetween(e,t,n,r){return this.content.textBetween(e,t,n,r)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,n){return this.type==e&&XN(this.attrs,t||e.defaultAttrs||gP)&&ZN.sameSet(this.marks,n||ZN.none)}copy(t=null){return t==this.content?this:new e(this.type,this.attrs,t,this.marks)}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.content,t)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,n=!1){if(e==t)return Q.empty;let r=this.resolve(e),i=this.resolve(t),a=n?0:r.sharedDepth(t),o=r.start(a);return new Q(r.node(a).content.cut(r.pos-o,i.pos-o),r.depth-a,i.depth-a)}replace(e,t,n){return tP(this.resolve(e),this.resolve(t),n)}nodeAt(e){for(let t=this;;){let{index:n,offset:r}=t.content.findIndex(e);if(t=t.maybeChild(n),!t)return null;if(r==e||t.isText)return t;e-=r+1}}childAfter(e){let{index:t,offset:n}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:n}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:n}=this.content.findIndex(e);if(n<e)return{node:this.content.child(t),index:t,offset:n};let r=this.content.child(t-1);return{node:r,index:t-1,offset:n-r.nodeSize}}resolve(e){return dP.resolveCached(this,e)}resolveNoCache(e){return dP.resolve(this,e)}rangeHasMark(e,t,n){let r=!1;return t>e&&this.nodesBetween(e,t,e=>(n.isInSet(e.marks)&&(r=!0),!r)),r}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+=`(`+this.content.toStringInner()+`)`),yP(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw Error(`Called contentMatchAt on a node with invalid content`);return t}canReplace(e,t,n=Z.empty,r=0,i=n.childCount){let a=this.contentMatchAt(e).matchFragment(n,r,i),o=a&&a.matchFragment(this.content,t);if(!o||!o.validEnd)return!1;for(let e=r;e<i;e++)if(!this.type.allowsMarks(n.child(e).marks))return!1;return!0}canReplaceWith(e,t,n,r){if(r&&!this.type.allowsMarks(r))return!1;let i=this.contentMatchAt(e).matchType(n),a=i&&i.matchFragment(this.content,t);return a?a.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=ZN.none;for(let t=0;t<this.marks.length;t++){let n=this.marks[t];n.type.checkAttrs(n.attrs),e=n.addToSet(e)}if(!ZN.sameSet(e,this.marks))throw RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(e=>e.type.name)}`);this.content.forEach(e=>e.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(e=>e.toJSON())),e}static fromJSON(e,t){if(!t)throw RangeError(`Invalid input for Node.fromJSON`);let n;if(t.marks){if(!Array.isArray(t.marks))throw RangeError(`Invalid mark data for Node.fromJSON`);n=t.marks.map(e.markFromJSON)}if(t.type==`text`){if(typeof t.text!=`string`)throw RangeError(`Invalid text node in JSON`);return e.text(t.text,n)}let r=Z.fromJSON(e,t.content),i=e.nodeType(t.type).create(t.attrs,r,n);return i.type.checkAttrs(i.attrs),i}};_P.prototype.text=void 0;var vP=class e extends _P{constructor(e,t,n,r){if(super(e,t,null,r),!n)throw RangeError(`Empty text nodes are not allowed`);this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):yP(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.text,t)}withText(t){return t==this.text?this:new e(this.type,this.attrs,t,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}};function yP(e,t){for(let n=e.length-1;n>=0;n--)t=e[n].type.name+`(`+t+`)`;return t}var bP=class e{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(t,n){let r=new xP(t,n);if(r.next==null)return e.empty;let i=SP(r);r.next&&r.err(`Unexpected trailing text`);let a=MP(kP(i));return NP(a,r),a}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,n=e.childCount){let r=this;for(let i=t;r&&i<n;i++)r=r.matchType(e.child(i).type);return r}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let n=0;n<e.next.length;n++)if(this.next[t].type==e.next[n].type)return!0;return!1}fillBefore(e,t=!1,n=0){let r=[this];function i(a,o){let s=a.matchFragment(e,n);if(s&&(!t||s.validEnd))return Z.from(o.map(e=>e.createAndFill()));for(let e=0;e<a.next.length;e++){let{type:t,next:n}=a.next[e];if(!(t.isText||t.hasRequiredAttrs())&&r.indexOf(n)==-1){r.push(n);let e=i(n,o.concat(t));if(e)return e}}return null}return i(this,[])}findWrapping(e){for(let t=0;t<this.wrapCache.length;t+=2)if(this.wrapCache[t]==e)return this.wrapCache[t+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),n=[{match:this,type:null,via:null}];for(;n.length;){let r=n.shift(),i=r.match;if(i.matchType(e)){let e=[];for(let t=r;t.type;t=t.via)e.push(t.type);return e.reverse()}for(let e=0;e<i.next.length;e++){let{type:a,next:o}=i.next[e];!a.isLeaf&&!a.hasRequiredAttrs()&&!(a.name in t)&&(!r.type||o.validEnd)&&(n.push({match:a.contentMatch,type:a,via:r}),t[a.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(n){e.push(n);for(let r=0;r<n.next.length;r++)e.indexOf(n.next[r].next)==-1&&t(n.next[r].next)}return t(this),e.map((t,n)=>{let r=n+(t.validEnd?`*`:` `)+` `;for(let n=0;n<t.next.length;n++)r+=(n?`, `:``)+t.next[n].type.name+`->`+e.indexOf(t.next[n].next);return r}).join(`
79
+ `},BT={onDragStart(e){let{active:t}=e;return`Picked up draggable item `+t.id+`.`},onDragOver(e){let{active:t,over:n}=e;return n?`Draggable item `+t.id+` was moved over droppable area `+n.id+`.`:`Draggable item `+t.id+` is no longer over a droppable area.`},onDragEnd(e){let{active:t,over:n}=e;return n?`Draggable item `+t.id+` was dropped over droppable area `+n.id:`Draggable item `+t.id+` was dropped.`},onDragCancel(e){let{active:t}=e;return`Dragging was cancelled. Draggable item `+t.id+` was dropped.`}};function VT(e){let{announcements:t=BT,container:n,hiddenTextDescribedById:r,screenReaderInstructions:i=zT}=e,{announce:a,announcement:o}=FT(),s=xT(`DndLiveRegion`),[c,l]=(0,v.useState)(!1);if((0,v.useEffect)(()=>{l(!0)},[]),LT((0,v.useMemo)(()=>({onDragStart(e){let{active:n}=e;a(t.onDragStart({active:n}))},onDragMove(e){let{active:n,over:r}=e;t.onDragMove&&a(t.onDragMove({active:n,over:r}))},onDragOver(e){let{active:n,over:r}=e;a(t.onDragOver({active:n,over:r}))},onDragEnd(e){let{active:n,over:r}=e;a(t.onDragEnd({active:n,over:r}))},onDragCancel(e){let{active:n,over:r}=e;a(t.onDragCancel({active:n,over:r}))}}),[a,t])),!c)return null;let u=v.createElement(v.Fragment,null,v.createElement(NT,{id:r,value:i.draggable}),v.createElement(PT,{id:s,announcement:o}));return n?(0,N.createPortal)(u,n):u}var HT;(function(e){e.DragStart=`dragStart`,e.DragMove=`dragMove`,e.DragEnd=`dragEnd`,e.DragCancel=`dragCancel`,e.DragOver=`dragOver`,e.RegisterDroppable=`registerDroppable`,e.SetDroppableDisabled=`setDroppableDisabled`,e.UnregisterDroppable=`unregisterDroppable`})(HT||={});function UT(){}function WT(e,t){return(0,v.useMemo)(()=>({sensor:e,options:t??{}}),[e,t])}function GT(){var e=[...arguments];return(0,v.useMemo)(()=>[...e].filter(e=>e!=null),[...e])}var KT=Object.freeze({x:0,y:0});function qT(e,t){return Math.sqrt((e.x-t.x)**2+(e.y-t.y)**2)}function JT(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return n-r}function YT(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return r-n}function XT(e,t){if(!e||e.length===0)return null;let[n]=e;return t?n[t]:n}function ZT(e,t,n){return t===void 0&&(t=e.left),n===void 0&&(n=e.top),{x:t+e.width*.5,y:n+e.height*.5}}var QT=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e,i=ZT(t,t.left,t.top),a=[];for(let e of r){let{id:t}=e,r=n.get(t);if(r){let n=qT(ZT(r),i);a.push({id:t,data:{droppableContainer:e,value:n}})}}return a.sort(JT)};function $T(e,t){let n=Math.max(t.top,e.top),r=Math.max(t.left,e.left),i=Math.min(t.left+t.width,e.left+e.width),a=Math.min(t.top+t.height,e.top+e.height),o=i-r,s=a-n;if(r<i&&n<a){let n=t.width*t.height,r=e.width*e.height,i=o*s,a=i/(n+r-i);return Number(a.toFixed(4))}return 0}var eE=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e,i=[];for(let e of r){let{id:r}=e,a=n.get(r);if(a){let n=$T(a,t);n>0&&i.push({id:r,data:{droppableContainer:e,value:n}})}}return i.sort(YT)};function tE(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function nE(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:KT}function rE(e){return function(t){return[...arguments].slice(1).reduce((t,n)=>({...t,top:t.top+e*n.y,bottom:t.bottom+e*n.y,left:t.left+e*n.x,right:t.right+e*n.x}),{...t})}}var iE=rE(1);function aE(e){if(e.startsWith(`matrix3d(`)){let t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}else if(e.startsWith(`matrix(`)){let t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}function oE(e,t,n){let r=aE(t);if(!r)return e;let{scaleX:i,scaleY:a,x:o,y:s}=r,c=e.left-o-(1-i)*parseFloat(n),l=e.top-s-(1-a)*parseFloat(n.slice(n.indexOf(` `)+1)),u=i?e.width/i:e.width,d=a?e.height/a:e.height;return{width:u,height:d,top:l,right:c+u,bottom:l+d,left:c}}var sE={ignoreTransform:!1};function cE(e,t){t===void 0&&(t=sE);let n=e.getBoundingClientRect();if(t.ignoreTransform){let{transform:t,transformOrigin:r}=cT(e).getComputedStyle(e);t&&(n=oE(n,t,r))}let{top:r,left:i,width:a,height:o,bottom:s,right:c}=n;return{top:r,left:i,width:a,height:o,bottom:s,right:c}}function lE(e){return cE(e,{ignoreTransform:!0})}function uE(e){let t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function dE(e,t){return t===void 0&&(t=cT(e).getComputedStyle(e)),t.position===`fixed`}function fE(e,t){t===void 0&&(t=cT(e).getComputedStyle(e));let n=/(auto|scroll|overlay)/;return[`overflow`,`overflowX`,`overflowY`].some(e=>{let r=t[e];return typeof r==`string`?n.test(r):!1})}function pE(e,t){let n=[];function r(i){if(t!=null&&n.length>=t||!i)return n;if(lT(i)&&i.scrollingElement!=null&&!n.includes(i.scrollingElement))return n.push(i.scrollingElement),n;if(!uT(i)||dT(i)||n.includes(i))return n;let a=cT(e).getComputedStyle(i);return i!==e&&fE(i,a)&&n.push(i),dE(i,a)?n:r(i.parentNode)}return e?r(e):n}function mE(e){let[t]=pE(e,1);return t??null}function hE(e){return!aT||!e?null:oT(e)?e:sT(e)?lT(e)||e===fT(e).scrollingElement?window:uT(e)?e:null:null}function gE(e){return oT(e)?e.scrollX:e.scrollLeft}function _E(e){return oT(e)?e.scrollY:e.scrollTop}function vE(e){return{x:gE(e),y:_E(e)}}var yE;(function(e){e[e.Forward=1]=`Forward`,e[e.Backward=-1]=`Backward`})(yE||={});function bE(e){return!aT||!e?!1:e===document.scrollingElement}function xE(e){let t={x:0,y:0},n=bE(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},r={x:e.scrollWidth-n.width,y:e.scrollHeight-n.height};return{isTop:e.scrollTop<=t.y,isLeft:e.scrollLeft<=t.x,isBottom:e.scrollTop>=r.y,isRight:e.scrollLeft>=r.x,maxScroll:r,minScroll:t}}var SE={x:.2,y:.2};function CE(e,t,n,r,i){let{top:a,left:o,right:s,bottom:c}=n;r===void 0&&(r=10),i===void 0&&(i=SE);let{isTop:l,isBottom:u,isLeft:d,isRight:f}=xE(e),p={x:0,y:0},m={x:0,y:0},h={height:t.height*i.y,width:t.width*i.x};return!l&&a<=t.top+h.height?(p.y=yE.Backward,m.y=r*Math.abs((t.top+h.height-a)/h.height)):!u&&c>=t.bottom-h.height&&(p.y=yE.Forward,m.y=r*Math.abs((t.bottom-h.height-c)/h.height)),!f&&s>=t.right-h.width?(p.x=yE.Forward,m.x=r*Math.abs((t.right-h.width-s)/h.width)):!d&&o<=t.left+h.width&&(p.x=yE.Backward,m.x=r*Math.abs((t.left+h.width-o)/h.width)),{direction:p,speed:m}}function wE(e){if(e===document.scrollingElement){let{innerWidth:e,innerHeight:t}=window;return{top:0,left:0,right:e,bottom:t,width:e,height:t}}let{top:t,left:n,right:r,bottom:i}=e.getBoundingClientRect();return{top:t,left:n,right:r,bottom:i,width:e.clientWidth,height:e.clientHeight}}function TE(e){return e.reduce((e,t)=>CT(e,vE(t)),KT)}function EE(e){return e.reduce((e,t)=>e+gE(t),0)}function DE(e){return e.reduce((e,t)=>e+_E(t),0)}function OE(e,t){if(t===void 0&&(t=cE),!e)return;let{top:n,left:r,bottom:i,right:a}=t(e);mE(e)&&(i<=0||a<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:`center`,inline:`center`})}var kE=[[`x`,[`left`,`right`],EE],[`y`,[`top`,`bottom`],DE]],AE=class{constructor(e,t){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;let n=pE(t),r=TE(n);this.rect={...e},this.width=e.width,this.height=e.height;for(let[e,t,i]of kE)for(let a of t)Object.defineProperty(this,a,{get:()=>{let t=i(n),o=r[e]-t;return this.rect[a]+o},enumerable:!0});Object.defineProperty(this,`rect`,{enumerable:!1})}},jE=class{constructor(e){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(e=>this.target?.removeEventListener(...e))},this.target=e}add(e,t,n){var r;(r=this.target)==null||r.addEventListener(e,t,n),this.listeners.push([e,t,n])}};function ME(e){let{EventTarget:t}=cT(e);return e instanceof t?e:fT(e)}function NE(e,t){let n=Math.abs(e.x),r=Math.abs(e.y);return typeof t==`number`?Math.sqrt(n**2+r**2)>t:`x`in t&&`y`in t?n>t.x&&r>t.y:`x`in t?n>t.x:`y`in t?r>t.y:!1}var PE;(function(e){e.Click=`click`,e.DragStart=`dragstart`,e.Keydown=`keydown`,e.ContextMenu=`contextmenu`,e.Resize=`resize`,e.SelectionChange=`selectionchange`,e.VisibilityChange=`visibilitychange`})(PE||={});function FE(e){e.preventDefault()}function IE(e){e.stopPropagation()}var LE;(function(e){e.Space=`Space`,e.Down=`ArrowDown`,e.Right=`ArrowRight`,e.Left=`ArrowLeft`,e.Up=`ArrowUp`,e.Esc=`Escape`,e.Enter=`Enter`,e.Tab=`Tab`})(LE||={});var RE={start:[LE.Space,LE.Enter],cancel:[LE.Esc],end:[LE.Space,LE.Enter,LE.Tab]},zE=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case LE.Right:return{...n,x:n.x+25};case LE.Left:return{...n,x:n.x-25};case LE.Down:return{...n,y:n.y+25};case LE.Up:return{...n,y:n.y-25}}},BE=class{constructor(e){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=e;let{event:{target:t}}=e;this.props=e,this.listeners=new jE(fT(t)),this.windowListeners=new jE(cT(t)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(PE.Resize,this.handleCancel),this.windowListeners.add(PE.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(PE.Keydown,this.handleKeyDown))}handleStart(){let{activeNode:e,onStart:t}=this.props,n=e.node.current;n&&OE(n),t(KT)}handleKeyDown(e){if(ET(e)){let{active:t,context:n,options:r}=this.props,{keyboardCodes:i=RE,coordinateGetter:a=zE,scrollBehavior:o=`smooth`}=r,{code:s}=e;if(i.end.includes(s)){this.handleEnd(e);return}if(i.cancel.includes(s)){this.handleCancel(e);return}let{collisionRect:c}=n.current,l=c?{x:c.left,y:c.top}:KT;this.referenceCoordinates||=l;let u=a(e,{active:t,context:n.current,currentCoordinates:l});if(u){let t=wT(u,l),r={x:0,y:0},{scrollableAncestors:i}=n.current;for(let n of i){let i=e.code,{isTop:a,isRight:s,isLeft:c,isBottom:l,maxScroll:d,minScroll:f}=xE(n),p=wE(n),m={x:Math.min(i===LE.Right?p.right-p.width/2:p.right,Math.max(i===LE.Right?p.left:p.left+p.width/2,u.x)),y:Math.min(i===LE.Down?p.bottom-p.height/2:p.bottom,Math.max(i===LE.Down?p.top:p.top+p.height/2,u.y))},h=i===LE.Right&&!s||i===LE.Left&&!c,g=i===LE.Down&&!l||i===LE.Up&&!a;if(h&&m.x!==u.x){let e=n.scrollLeft+t.x,a=i===LE.Right&&e<=d.x||i===LE.Left&&e>=f.x;if(a&&!t.y){n.scrollTo({left:e,behavior:o});return}a?r.x=n.scrollLeft-e:r.x=i===LE.Right?n.scrollLeft-d.x:n.scrollLeft-f.x,r.x&&n.scrollBy({left:-r.x,behavior:o});break}else if(g&&m.y!==u.y){let e=n.scrollTop+t.y,a=i===LE.Down&&e<=d.y||i===LE.Up&&e>=f.y;if(a&&!t.x){n.scrollTo({top:e,behavior:o});return}a?r.y=n.scrollTop-e:r.y=i===LE.Down?n.scrollTop-d.y:n.scrollTop-f.y,r.y&&n.scrollBy({top:-r.y,behavior:o});break}}this.handleMove(e,CT(wT(u,this.referenceCoordinates),r))}}}handleMove(e,t){let{onMove:n}=this.props;e.preventDefault(),n(t)}handleEnd(e){let{onEnd:t}=this.props;e.preventDefault(),this.detach(),t()}handleCancel(e){let{onCancel:t}=this.props;e.preventDefault(),this.detach(),t()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}};BE.activators=[{eventName:`onKeyDown`,handler:(e,t,n)=>{let{keyboardCodes:r=RE,onActivation:i}=t,{active:a}=n,{code:o}=e.nativeEvent;if(r.start.includes(o)){let t=a.activatorNode.current;return t&&e.target!==t?!1:(e.preventDefault(),i?.({event:e.nativeEvent}),!0)}return!1}}];function VE(e){return!!(e&&`distance`in e)}function HE(e){return!!(e&&`delay`in e)}var UE=class{constructor(e,t,n){n===void 0&&(n=ME(e.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=e,this.events=t;let{event:r}=e,{target:i}=r;this.props=e,this.events=t,this.document=fT(i),this.documentListeners=new jE(this.document),this.listeners=new jE(n),this.windowListeners=new jE(cT(i)),this.initialCoordinates=OT(r)??KT,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){let{events:e,props:{options:{activationConstraint:t,bypassActivationConstraint:n}}}=this;if(this.listeners.add(e.move.name,this.handleMove,{passive:!1}),this.listeners.add(e.end.name,this.handleEnd),e.cancel&&this.listeners.add(e.cancel.name,this.handleCancel),this.windowListeners.add(PE.Resize,this.handleCancel),this.windowListeners.add(PE.DragStart,FE),this.windowListeners.add(PE.VisibilityChange,this.handleCancel),this.windowListeners.add(PE.ContextMenu,FE),this.documentListeners.add(PE.Keydown,this.handleKeydown),t){if(n!=null&&n({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(HE(t)){this.timeoutId=setTimeout(this.handleStart,t.delay),this.handlePending(t);return}if(VE(t)){this.handlePending(t);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(e,t){let{active:n,onPending:r}=this.props;r(n,e,this.initialCoordinates,t)}handleStart(){let{initialCoordinates:e}=this,{onStart:t}=this.props;e&&(this.activated=!0,this.documentListeners.add(PE.Click,IE,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(PE.SelectionChange,this.removeTextSelection),t(e))}handleMove(e){let{activated:t,initialCoordinates:n,props:r}=this,{onMove:i,options:{activationConstraint:a}}=r;if(!n)return;let o=OT(e)??KT,s=wT(n,o);if(!t&&a){if(VE(a)){if(a.tolerance!=null&&NE(s,a.tolerance))return this.handleCancel();if(NE(s,a.distance))return this.handleStart()}if(HE(a)&&NE(s,a.tolerance))return this.handleCancel();this.handlePending(a,s);return}e.cancelable&&e.preventDefault(),i(o)}handleEnd(){let{onAbort:e,onEnd:t}=this.props;this.detach(),this.activated||e(this.props.active),t()}handleCancel(){let{onAbort:e,onCancel:t}=this.props;this.detach(),this.activated||e(this.props.active),t()}handleKeydown(e){e.code===LE.Esc&&this.handleCancel()}removeTextSelection(){var e;(e=this.document.getSelection())==null||e.removeAllRanges()}},WE={cancel:{name:`pointercancel`},move:{name:`pointermove`},end:{name:`pointerup`}},GE=class extends UE{constructor(e){let{event:t}=e,n=fT(t.target);super(e,WE,n)}};GE.activators=[{eventName:`onPointerDown`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return!n.isPrimary||n.button!==0?!1:(r?.({event:n}),!0)}}];var KE={move:{name:`mousemove`},end:{name:`mouseup`}},qE;(function(e){e[e.RightClick=2]=`RightClick`})(qE||={});var JE=class extends UE{constructor(e){super(e,KE,fT(e.event.target))}};JE.activators=[{eventName:`onMouseDown`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button===qE.RightClick?!1:(r?.({event:n}),!0)}}];var YE={cancel:{name:`touchcancel`},move:{name:`touchmove`},end:{name:`touchend`}},XE=class extends UE{constructor(e){super(e,YE)}static setup(){return window.addEventListener(YE.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(YE.move.name,e)};function e(){}}};XE.activators=[{eventName:`onTouchStart`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t,{touches:i}=n;return i.length>1?!1:(r?.({event:n}),!0)}}];var ZE;(function(e){e[e.Pointer=0]=`Pointer`,e[e.DraggableRect=1]=`DraggableRect`})(ZE||={});var QE;(function(e){e[e.TreeOrder=0]=`TreeOrder`,e[e.ReversedTreeOrder=1]=`ReversedTreeOrder`})(QE||={});function $E(e){let{acceleration:t,activator:n=ZE.Pointer,canScroll:r,draggingRect:i,enabled:a,interval:o=5,order:s=QE.TreeOrder,pointerCoordinates:c,scrollableAncestors:l,scrollableAncestorRects:u,delta:d,threshold:f}=e,p=tD({delta:d,disabled:!a}),[m,h]=hT(),g=(0,v.useRef)({x:0,y:0}),_=(0,v.useRef)({x:0,y:0}),y=(0,v.useMemo)(()=>{switch(n){case ZE.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case ZE.DraggableRect:return i}},[n,i,c]),b=(0,v.useRef)(null),x=(0,v.useCallback)(()=>{let e=b.current;if(!e)return;let t=g.current.x*_.current.x,n=g.current.y*_.current.y;e.scrollBy(t,n)},[]),S=(0,v.useMemo)(()=>s===QE.TreeOrder?[...l].reverse():l,[s,l]);(0,v.useEffect)(()=>{if(!a||!l.length||!y){h();return}for(let e of S){if(r?.(e)===!1)continue;let n=u[l.indexOf(e)];if(!n)continue;let{direction:i,speed:a}=CE(e,n,y,t,f);for(let e of[`x`,`y`])p[e][i[e]]||(a[e]=0,i[e]=0);if(a.x>0||a.y>0){h(),b.current=e,m(x,o),g.current=a,_.current=i;return}}g.current={x:0,y:0},_.current={x:0,y:0},h()},[t,x,r,h,a,o,JSON.stringify(y),JSON.stringify(p),m,l,S,u,JSON.stringify(f)])}var eD={x:{[yE.Backward]:!1,[yE.Forward]:!1},y:{[yE.Backward]:!1,[yE.Forward]:!1}};function tD(e){let{delta:t,disabled:n}=e,r=yT(t);return _T(e=>{if(n||!r||!e)return eD;let i={x:Math.sign(t.x-r.x),y:Math.sign(t.y-r.y)};return{x:{[yE.Backward]:e.x[yE.Backward]||i.x===-1,[yE.Forward]:e.x[yE.Forward]||i.x===1},y:{[yE.Backward]:e.y[yE.Backward]||i.y===-1,[yE.Forward]:e.y[yE.Forward]||i.y===1}}},[n,t,r])}function nD(e,t){let n=t==null?void 0:e.get(t),r=n?n.node.current:null;return _T(e=>t==null?null:r??e??null,[r,t])}function rD(e,t){return(0,v.useMemo)(()=>e.reduce((e,n)=>{let{sensor:r}=n,i=r.activators.map(e=>({eventName:e.eventName,handler:t(e.handler,n)}));return[...e,...i]},[]),[e,t])}var iD;(function(e){e[e.Always=0]=`Always`,e[e.BeforeDragging=1]=`BeforeDragging`,e[e.WhileDragging=2]=`WhileDragging`})(iD||={});var aD;(function(e){e.Optimized=`optimized`})(aD||={});var oD=new Map;function sD(e,t){let{dragging:n,dependencies:r,config:i}=t,[a,o]=(0,v.useState)(null),{frequency:s,measure:c,strategy:l}=i,u=(0,v.useRef)(e),d=g(),f=gT(d),p=(0,v.useCallback)(function(e){e===void 0&&(e=[]),!f.current&&o(t=>t===null?e:t.concat(e.filter(e=>!t.includes(e))))},[f]),m=(0,v.useRef)(null),h=_T(t=>{if(d&&!n)return oD;if(!t||t===oD||u.current!==e||a!=null){let t=new Map;for(let n of e){if(!n)continue;if(a&&a.length>0&&!a.includes(n.id)&&n.rect.current){t.set(n.id,n.rect.current);continue}let e=n.node.current,r=e?new AE(c(e),e):null;n.rect.current=r,r&&t.set(n.id,r)}return t}return t},[e,a,n,d,c]);return(0,v.useEffect)(()=>{u.current=e},[e]),(0,v.useEffect)(()=>{d||p()},[n,d]),(0,v.useEffect)(()=>{a&&a.length>0&&o(null)},[JSON.stringify(a)]),(0,v.useEffect)(()=>{d||typeof s!=`number`||m.current!==null||(m.current=setTimeout(()=>{p(),m.current=null},s))},[s,d,p,...r]),{droppableRects:h,measureDroppableContainers:p,measuringScheduled:a!=null};function g(){switch(l){case iD.Always:return!1;case iD.BeforeDragging:return n;default:return!n}}}function cD(e,t){return _T(n=>e?n||(typeof t==`function`?t(e):e):null,[t,e])}function lD(e,t){return cD(e,t)}function uD(e){let{callback:t,disabled:n}=e,r=mT(t),i=(0,v.useMemo)(()=>{if(n||typeof window>`u`||window.MutationObserver===void 0)return;let{MutationObserver:e}=window;return new e(r)},[r,n]);return(0,v.useEffect)(()=>()=>i?.disconnect(),[i]),i}function dD(e){let{callback:t,disabled:n}=e,r=mT(t),i=(0,v.useMemo)(()=>{if(n||typeof window>`u`||window.ResizeObserver===void 0)return;let{ResizeObserver:e}=window;return new e(r)},[n]);return(0,v.useEffect)(()=>()=>i?.disconnect(),[i]),i}function fD(e){return new AE(cE(e),e)}function pD(e,t,n){t===void 0&&(t=fD);let[r,i]=(0,v.useState)(null);function a(){i(r=>{if(!e)return null;if(e.isConnected===!1)return r??n??null;let i=t(e);return JSON.stringify(r)===JSON.stringify(i)?r:i})}let o=uD({callback(t){if(e)for(let n of t){let{type:t,target:r}=n;if(t===`childList`&&r instanceof HTMLElement&&r.contains(e)){a();break}}}}),s=dD({callback:a});return pT(()=>{a(),e?(s?.observe(e),o?.observe(document.body,{childList:!0,subtree:!0})):(s?.disconnect(),o?.disconnect())},[e]),r}function mD(e){return nE(e,cD(e))}var hD=[];function gD(e){let t=(0,v.useRef)(e),n=_T(n=>e?n&&n!==hD&&e&&t.current&&e.parentNode===t.current.parentNode?n:pE(e):hD,[e]);return(0,v.useEffect)(()=>{t.current=e},[e]),n}function _D(e){let[t,n]=(0,v.useState)(null),r=(0,v.useRef)(e),i=(0,v.useCallback)(e=>{let t=hE(e.target);t&&n(e=>e?(e.set(t,vE(t)),new Map(e)):null)},[]);return(0,v.useEffect)(()=>{let t=r.current;if(e!==t){a(t);let o=e.map(e=>{let t=hE(e);return t?(t.addEventListener(`scroll`,i,{passive:!0}),[t,vE(t)]):null}).filter(e=>e!=null);n(o.length?new Map(o):null),r.current=e}return()=>{a(e),a(t)};function a(e){e.forEach(e=>{hE(e)?.removeEventListener(`scroll`,i)})}},[i,e]),(0,v.useMemo)(()=>e.length?t?Array.from(t.values()).reduce((e,t)=>CT(e,t),KT):TE(e):KT,[e,t])}function vD(e,t){t===void 0&&(t=[]);let n=(0,v.useRef)(null);return(0,v.useEffect)(()=>{n.current=null},t),(0,v.useEffect)(()=>{let t=e!==KT;t&&!n.current&&(n.current=e),!t&&n.current&&(n.current=null)},[e]),n.current?wT(e,n.current):KT}function yD(e){(0,v.useEffect)(()=>{if(!aT)return;let t=e.map(e=>{let{sensor:t}=e;return t.setup==null?void 0:t.setup()});return()=>{for(let e of t)e?.()}},e.map(e=>{let{sensor:t}=e;return t}))}function bD(e,t){return(0,v.useMemo)(()=>e.reduce((e,n)=>{let{eventName:r,handler:i}=n;return e[r]=e=>{i(e,t)},e},{}),[e,t])}function xD(e){return(0,v.useMemo)(()=>e?uE(e):null,[e])}var SD=[];function CD(e,t){t===void 0&&(t=cE);let[n]=e,r=xD(n?cT(n):null),[i,a]=(0,v.useState)(SD);function o(){a(()=>e.length?e.map(e=>bE(e)?r:new AE(t(e),e)):SD)}let s=dD({callback:o});return pT(()=>{s?.disconnect(),o(),e.forEach(e=>s?.observe(e))},[e]),i}function wD(e){if(!e)return null;if(e.children.length>1)return e;let t=e.children[0];return uT(t)?t:e}function TD(e){let{measure:t}=e,[n,r]=(0,v.useState)(null),i=dD({callback:(0,v.useCallback)(e=>{for(let{target:n}of e)if(uT(n)){r(e=>{let r=t(n);return e?{...e,width:r.width,height:r.height}:r});break}},[t])}),[a,o]=vT((0,v.useCallback)(e=>{let n=wD(e);i?.disconnect(),n&&i?.observe(n),r(n?t(n):null)},[t,i]));return(0,v.useMemo)(()=>({nodeRef:a,rect:n,setRef:o}),[n,a,o])}var ED=[{sensor:GE,options:{}},{sensor:BE,options:{}}],DD={current:{}},OD={draggable:{measure:lE},droppable:{measure:lE,strategy:iD.WhileDragging,frequency:aD.Optimized},dragOverlay:{measure:cE}},kD=class extends Map{get(e){return e==null?void 0:super.get(e)??void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(e=>{let{disabled:t}=e;return!t})}getNodeFor(e){return this.get(e)?.node.current??void 0}},AD={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new kD,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:UT},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:OD,measureDroppableContainers:UT,windowRect:null,measuringScheduled:!1},jD={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:``},dispatch:UT,draggableNodes:new Map,over:null,measureDroppableContainers:UT},MD=(0,v.createContext)(jD),ND=(0,v.createContext)(AD);function PD(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new kD}}}function FD(e,t){switch(t.type){case HT.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case HT.DragMove:return e.draggable.active==null?e:{...e,draggable:{...e.draggable,translate:{x:t.coordinates.x-e.draggable.initialCoordinates.x,y:t.coordinates.y-e.draggable.initialCoordinates.y}}};case HT.DragEnd:case HT.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case HT.RegisterDroppable:{let{element:n}=t,{id:r}=n,i=new kD(e.droppable.containers);return i.set(r,n),{...e,droppable:{...e.droppable,containers:i}}}case HT.SetDroppableDisabled:{let{id:n,key:r,disabled:i}=t,a=e.droppable.containers.get(n);if(!a||r!==a.key)return e;let o=new kD(e.droppable.containers);return o.set(n,{...a,disabled:i}),{...e,droppable:{...e.droppable,containers:o}}}case HT.UnregisterDroppable:{let{id:n,key:r}=t,i=e.droppable.containers.get(n);if(!i||r!==i.key)return e;let a=new kD(e.droppable.containers);return a.delete(n),{...e,droppable:{...e.droppable,containers:a}}}default:return e}}function ID(e){let{disabled:t}=e,{active:n,activatorEvent:r,draggableNodes:i}=(0,v.useContext)(MD),a=yT(r),o=yT(n?.id);return(0,v.useEffect)(()=>{if(!t&&!r&&a&&o!=null){if(!ET(a)||document.activeElement===a.target)return;let e=i.get(o);if(!e)return;let{activatorNode:t,node:n}=e;if(!t.current&&!n.current)return;requestAnimationFrame(()=>{for(let e of[t.current,n.current]){if(!e)continue;let t=jT(e);if(t){t.focus();break}}})}},[r,t,i,o,a]),null}function LD(e,t){let{transform:n,...r}=t;return e!=null&&e.length?e.reduce((e,t)=>t({transform:e,...r}),n):n}function RD(e){return(0,v.useMemo)(()=>({draggable:{...OD.draggable,...e?.draggable},droppable:{...OD.droppable,...e?.droppable},dragOverlay:{...OD.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function zD(e){let{activeNode:t,measure:n,initialRect:r,config:i=!0}=e,a=(0,v.useRef)(!1),{x:o,y:s}=typeof i==`boolean`?{x:i,y:i}:i;pT(()=>{if(!o&&!s||!t){a.current=!1;return}if(a.current||!r)return;let e=t?.node.current;if(!e||e.isConnected===!1)return;let i=nE(n(e),r);if(o||(i.x=0),s||(i.y=0),a.current=!0,Math.abs(i.x)>0||Math.abs(i.y)>0){let t=mE(e);t&&t.scrollBy({top:i.y,left:i.x})}},[t,o,s,r,n])}var BD=(0,v.createContext)({...KT,scaleX:1,scaleY:1}),VD;(function(e){e[e.Uninitialized=0]=`Uninitialized`,e[e.Initializing=1]=`Initializing`,e[e.Initialized=2]=`Initialized`})(VD||={});var HD=(0,v.memo)(function(e){let{id:t,accessibility:n,autoScroll:r=!0,children:i,sensors:a=ED,collisionDetection:o=eE,measuring:s,modifiers:c,...l}=e,[u,d]=(0,v.useReducer)(FD,void 0,PD),[f,p]=RT(),[m,h]=(0,v.useState)(VD.Uninitialized),g=m===VD.Initialized,{draggable:{active:_,nodes:y,translate:b},droppable:{containers:x}}=u,S=_==null?null:y.get(_),C=(0,v.useRef)({initial:null,translated:null}),w=(0,v.useMemo)(()=>_==null?null:{id:_,data:S?.data??DD,rect:C},[_,S]),T=(0,v.useRef)(null),[E,D]=(0,v.useState)(null),[O,k]=(0,v.useState)(null),A=gT(l,Object.values(l)),j=xT(`DndDescribedBy`,t),M=(0,v.useMemo)(()=>x.getEnabled(),[x]),P=RD(s),{droppableRects:F,measureDroppableContainers:I,measuringScheduled:L}=sD(M,{dragging:g,dependencies:[b.x,b.y],config:P.droppable}),R=nD(y,_),ee=(0,v.useMemo)(()=>O?OT(O):null,[O]),te=Oe(),z=lD(R,P.draggable.measure);zD({activeNode:_==null?null:y.get(_),config:te.layoutShiftCompensation,initialRect:z,measure:P.draggable.measure});let B=pD(R,P.draggable.measure,z),V=pD(R?R.parentElement:null),ne=(0,v.useRef)({activatorEvent:null,active:null,activeNode:R,collisionRect:null,collisions:null,droppableRects:F,draggableNodes:y,draggingNode:null,draggingNodeRect:null,droppableContainers:x,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),H=x.getNodeFor(ne.current.over?.id),re=TD({measure:P.dragOverlay.measure}),ie=re.nodeRef.current??R,ae=g?re.rect??B:null,oe=!!(re.nodeRef.current&&re.rect),se=mD(oe?null:B),ce=xD(ie?cT(ie):null),le=gD(g?H??R:null),ue=CD(le),de=LD(c,{transform:{x:b.x-se.x,y:b.y-se.y,scaleX:1,scaleY:1},activatorEvent:O,active:w,activeNodeRect:B,containerNodeRect:V,draggingNodeRect:ae,over:ne.current.over,overlayNodeRect:re.rect,scrollableAncestors:le,scrollableAncestorRects:ue,windowRect:ce}),fe=ee?CT(ee,b):null,pe=_D(le),me=vD(pe),he=vD(pe,[B]),ge=CT(de,me),_e=ae?iE(ae,de):null,ve=w&&_e?o({active:w,collisionRect:_e,droppableRects:F,droppableContainers:M,pointerCoordinates:fe}):null,ye=XT(ve,`id`),[be,xe]=(0,v.useState)(null),Se=tE(oe?de:CT(de,he),be?.rect??null,B),Ce=(0,v.useRef)(null),we=(0,v.useCallback)((e,t)=>{let{sensor:n,options:r}=t;if(T.current==null)return;let i=y.get(T.current);if(!i)return;let a=e.nativeEvent;Ce.current=new n({active:T.current,activeNode:i,event:a,options:r,context:ne,onAbort(e){if(!y.get(e))return;let{onDragAbort:t}=A.current,n={id:e};t?.(n),f({type:`onDragAbort`,event:n})},onPending(e,t,n,r){if(!y.get(e))return;let{onDragPending:i}=A.current,a={id:e,constraint:t,initialCoordinates:n,offset:r};i?.(a),f({type:`onDragPending`,event:a})},onStart(e){let t=T.current;if(t==null)return;let n=y.get(t);if(!n)return;let{onDragStart:r}=A.current,i={activatorEvent:a,active:{id:t,data:n.data,rect:C}};(0,N.unstable_batchedUpdates)(()=>{r?.(i),h(VD.Initializing),d({type:HT.DragStart,initialCoordinates:e,active:t}),f({type:`onDragStart`,event:i}),D(Ce.current),k(a)})},onMove(e){d({type:HT.DragMove,coordinates:e})},onEnd:o(HT.DragEnd),onCancel:o(HT.DragCancel)});function o(e){return async function(){let{active:t,collisions:n,over:r,scrollAdjustedTranslate:i}=ne.current,o=null;if(t&&i){let{cancelDrop:s}=A.current;o={activatorEvent:a,active:t,collisions:n,delta:i,over:r},e===HT.DragEnd&&typeof s==`function`&&await Promise.resolve(s(o))&&(e=HT.DragCancel)}T.current=null,(0,N.unstable_batchedUpdates)(()=>{d({type:e}),h(VD.Uninitialized),xe(null),D(null),k(null),Ce.current=null;let t=e===HT.DragEnd?`onDragEnd`:`onDragCancel`;if(o){let e=A.current[t];e?.(o),f({type:t,event:o})}})}}},[y]),Te=rD(a,(0,v.useCallback)((e,t)=>(n,r)=>{let i=n.nativeEvent,a=y.get(r);if(T.current!==null||!a||i.dndKit||i.defaultPrevented)return;let o={active:a};e(n,t.options,o)===!0&&(i.dndKit={capturedBy:t.sensor},T.current=r,we(n,t))},[y,we]));yD(a),pT(()=>{B&&m===VD.Initializing&&h(VD.Initialized)},[B,m]),(0,v.useEffect)(()=>{let{onDragMove:e}=A.current,{active:t,activatorEvent:n,collisions:r,over:i}=ne.current;if(!t||!n)return;let a={active:t,activatorEvent:n,collisions:r,delta:{x:ge.x,y:ge.y},over:i};(0,N.unstable_batchedUpdates)(()=>{e?.(a),f({type:`onDragMove`,event:a})})},[ge.x,ge.y]),(0,v.useEffect)(()=>{let{active:e,activatorEvent:t,collisions:n,droppableContainers:r,scrollAdjustedTranslate:i}=ne.current;if(!e||T.current==null||!t||!i)return;let{onDragOver:a}=A.current,o=r.get(ye),s=o&&o.rect.current?{id:o.id,rect:o.rect.current,data:o.data,disabled:o.disabled}:null,c={active:e,activatorEvent:t,collisions:n,delta:{x:i.x,y:i.y},over:s};(0,N.unstable_batchedUpdates)(()=>{xe(s),a?.(c),f({type:`onDragOver`,event:c})})},[ye]),pT(()=>{ne.current={activatorEvent:O,active:w,activeNode:R,collisionRect:_e,collisions:ve,droppableRects:F,draggableNodes:y,draggingNode:ie,draggingNodeRect:ae,droppableContainers:x,over:be,scrollableAncestors:le,scrollAdjustedTranslate:ge},C.current={initial:ae,translated:_e}},[w,R,ve,_e,y,ie,ae,F,x,be,le,ge]),$E({...te,delta:b,draggingRect:_e,pointerCoordinates:fe,scrollableAncestors:le,scrollableAncestorRects:ue});let Ee=(0,v.useMemo)(()=>({active:w,activeNode:R,activeNodeRect:B,activatorEvent:O,collisions:ve,containerNodeRect:V,dragOverlay:re,draggableNodes:y,droppableContainers:x,droppableRects:F,over:be,measureDroppableContainers:I,scrollableAncestors:le,scrollableAncestorRects:ue,measuringConfiguration:P,measuringScheduled:L,windowRect:ce}),[w,R,B,O,ve,V,re,y,x,F,be,I,le,ue,P,L,ce]),De=(0,v.useMemo)(()=>({activatorEvent:O,activators:Te,active:w,activeNodeRect:B,ariaDescribedById:{draggable:j},dispatch:d,draggableNodes:y,over:be,measureDroppableContainers:I}),[O,Te,w,B,d,j,y,be,I]);return v.createElement(IT.Provider,{value:p},v.createElement(MD.Provider,{value:De},v.createElement(ND.Provider,{value:Ee},v.createElement(BD.Provider,{value:Se},i)),v.createElement(ID,{disabled:n?.restoreFocus===!1})),v.createElement(VT,{...n,hiddenTextDescribedById:j}));function Oe(){let e=E?.autoScrollEnabled===!1,t=typeof r==`object`?r.enabled===!1:r===!1,n=g&&!e&&!t;return typeof r==`object`?{...r,enabled:n}:{enabled:n}}}),UD=(0,v.createContext)(null),WD=`button`,GD=`Draggable`;function KD(e){let{id:t,data:n,disabled:r=!1,attributes:i}=e,a=xT(GD),{activators:o,activatorEvent:s,active:c,activeNodeRect:l,ariaDescribedById:u,draggableNodes:d,over:f}=(0,v.useContext)(MD),{role:p=WD,roleDescription:m=`draggable`,tabIndex:h=0}=i??{},g=c?.id===t,_=(0,v.useContext)(g?BD:UD),[y,b]=vT(),[x,S]=vT(),C=bD(o,t),w=gT(n);return pT(()=>(d.set(t,{id:t,key:a,node:y,activatorNode:x,data:w}),()=>{let e=d.get(t);e&&e.key===a&&d.delete(t)}),[d,t]),{active:c,activatorEvent:s,activeNodeRect:l,attributes:(0,v.useMemo)(()=>({role:p,tabIndex:h,"aria-disabled":r,"aria-pressed":g&&p===WD?!0:void 0,"aria-roledescription":m,"aria-describedby":u.draggable}),[r,p,h,g,m,u.draggable]),isDragging:g,listeners:r?void 0:C,node:y,over:f,setNodeRef:b,setActivatorNodeRef:S,transform:_}}function qD(){return(0,v.useContext)(ND)}var JD=`Droppable`,YD={timeout:25};function XD(e){let{data:t,disabled:n=!1,id:r,resizeObserverConfig:i}=e,a=xT(JD),{active:o,dispatch:s,over:c,measureDroppableContainers:l}=(0,v.useContext)(MD),u=(0,v.useRef)({disabled:n}),d=(0,v.useRef)(!1),f=(0,v.useRef)(null),p=(0,v.useRef)(null),{disabled:m,updateMeasurementsFor:h,timeout:g}={...YD,...i},_=gT(h??r),y=dD({callback:(0,v.useCallback)(()=>{if(!d.current){d.current=!0;return}p.current!=null&&clearTimeout(p.current),p.current=setTimeout(()=>{l(Array.isArray(_.current)?_.current:[_.current]),p.current=null},g)},[g]),disabled:m||!o}),[b,x]=vT((0,v.useCallback)((e,t)=>{y&&(t&&(y.unobserve(t),d.current=!1),e&&y.observe(e))},[y])),S=gT(t);return(0,v.useEffect)(()=>{!y||!b.current||(y.disconnect(),d.current=!1,y.observe(b.current))},[b,y]),(0,v.useEffect)(()=>(s({type:HT.RegisterDroppable,element:{id:r,key:a,disabled:n,node:b,rect:f,data:S}}),()=>s({type:HT.UnregisterDroppable,key:a,id:r})),[r]),(0,v.useEffect)(()=>{n!==u.current.disabled&&(s({type:HT.SetDroppableDisabled,id:r,key:a,disabled:n}),u.current.disabled=n)},[r,a,n,s]),{active:o,rect:f,isOver:c?.id===r,node:b,over:c,setNodeRef:x}}function ZD(e,t,n){let r=e.slice();return r.splice(n<0?r.length+n:n,0,r.splice(t,1)[0]),r}function QD(e,t){return e.reduce((e,n,r)=>{let i=t.get(n);return i&&(e[r]=i),e},Array(e.length))}function $D(e){return e!==null&&e>=0}function eO(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function tO(e){return typeof e==`boolean`?{draggable:e,droppable:e}:e}var nO=e=>{let{rects:t,activeIndex:n,overIndex:r,index:i}=e,a=ZD(t,r,n),o=t[i],s=a[i];return!s||!o?null:{x:s.left-o.left,y:s.top-o.top,scaleX:s.width/o.width,scaleY:s.height/o.height}},rO={scaleX:1,scaleY:1},iO=e=>{let{activeIndex:t,activeNodeRect:n,index:r,rects:i,overIndex:a}=e,o=i[t]??n;if(!o)return null;if(r===t){let e=i[a];return e?{x:0,y:t<a?e.top+e.height-(o.top+o.height):e.top-o.top,...rO}:null}let s=aO(i,r,t);return r>t&&r<=a?{x:0,y:-o.height-s,...rO}:r<t&&r>=a?{x:0,y:o.height+s,...rO}:{x:0,y:0,...rO}};function aO(e,t,n){let r=e[t],i=e[t-1],a=e[t+1];return r?n<t?i?r.top-(i.top+i.height):a?a.top-(r.top+r.height):0:a?a.top-(r.top+r.height):i?r.top-(i.top+i.height):0:0}var oO=`Sortable`,sO=v.createContext({activeIndex:-1,containerId:oO,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:nO,disabled:{draggable:!1,droppable:!1}});function cO(e){let{children:t,id:n,items:r,strategy:i=nO,disabled:a=!1}=e,{active:o,dragOverlay:s,droppableRects:c,over:l,measureDroppableContainers:u}=qD(),d=xT(oO,n),f=s.rect!==null,p=(0,v.useMemo)(()=>r.map(e=>typeof e==`object`&&`id`in e?e.id:e),[r]),m=o!=null,h=o?p.indexOf(o.id):-1,g=l?p.indexOf(l.id):-1,_=(0,v.useRef)(p),y=!eO(p,_.current),b=g!==-1&&h===-1||y,x=tO(a);pT(()=>{y&&m&&u(p)},[y,p,m,u]),(0,v.useEffect)(()=>{_.current=p},[p]);let S=(0,v.useMemo)(()=>({activeIndex:h,containerId:d,disabled:x,disableTransforms:b,items:p,overIndex:g,useDragOverlay:f,sortedRects:QD(p,c),strategy:i}),[h,d,x.draggable,x.droppable,b,p,g,c,f,i]);return v.createElement(sO.Provider,{value:S},t)}var lO=e=>{let{id:t,items:n,activeIndex:r,overIndex:i}=e;return ZD(n,r,i).indexOf(t)},uO=e=>{let{containerId:t,isSorting:n,wasDragging:r,index:i,items:a,newIndex:o,previousItems:s,previousContainerId:c,transition:l}=e;return!l||!r||s!==a&&i===o?!1:n?!0:o!==i&&t===c},dO={duration:200,easing:`ease`},fO=`transform`,pO=kT.Transition.toString({property:fO,duration:0,easing:`linear`}),mO={roleDescription:`sortable`};function hO(e){let{disabled:t,index:n,node:r,rect:i}=e,[a,o]=(0,v.useState)(null),s=(0,v.useRef)(n);return pT(()=>{if(!t&&n!==s.current&&r.current){let e=i.current;if(e){let t=cE(r.current,{ignoreTransform:!0}),n={x:e.left-t.left,y:e.top-t.top,scaleX:e.width/t.width,scaleY:e.height/t.height};(n.x||n.y)&&o(n)}}n!==s.current&&(s.current=n)},[t,n,r,i]),(0,v.useEffect)(()=>{a&&o(null)},[a]),a}function gO(e){let{animateLayoutChanges:t=uO,attributes:n,disabled:r,data:i,getNewIndex:a=lO,id:o,strategy:s,resizeObserverConfig:c,transition:l=dO}=e,{items:u,containerId:d,activeIndex:f,disabled:p,disableTransforms:m,sortedRects:h,overIndex:g,useDragOverlay:_,strategy:y}=(0,v.useContext)(sO),b=_O(r,p),x=u.indexOf(o),S=(0,v.useMemo)(()=>({sortable:{containerId:d,index:x,items:u},...i}),[d,i,x,u]),C=(0,v.useMemo)(()=>u.slice(u.indexOf(o)),[u,o]),{rect:w,node:T,isOver:E,setNodeRef:D}=XD({id:o,data:S,disabled:b.droppable,resizeObserverConfig:{updateMeasurementsFor:C,...c}}),{active:O,activatorEvent:k,activeNodeRect:A,attributes:j,setNodeRef:M,listeners:N,isDragging:P,over:F,setActivatorNodeRef:I,transform:L}=KD({id:o,data:S,attributes:{...mO,...n},disabled:b.draggable}),R=iT(D,M),ee=!!O,te=ee&&!m&&$D(f)&&$D(g),z=!_&&P,B=te?(z&&te?L:null)??(s??y)({rects:h,activeNodeRect:A,activeIndex:f,overIndex:g,index:x}):null,V=$D(f)&&$D(g)?a({id:o,items:u,activeIndex:f,overIndex:g}):x,ne=O?.id,H=(0,v.useRef)({activeId:ne,items:u,newIndex:V,containerId:d}),re=u!==H.current.items,ie=t({active:O,containerId:d,isDragging:P,isSorting:ee,id:o,index:x,items:u,newIndex:H.current.newIndex,previousItems:H.current.items,previousContainerId:H.current.containerId,transition:l,wasDragging:H.current.activeId!=null}),ae=hO({disabled:!ie,index:x,node:T,rect:w});return(0,v.useEffect)(()=>{ee&&H.current.newIndex!==V&&(H.current.newIndex=V),d!==H.current.containerId&&(H.current.containerId=d),u!==H.current.items&&(H.current.items=u)},[ee,V,d,u]),(0,v.useEffect)(()=>{if(ne===H.current.activeId)return;if(ne!=null&&H.current.activeId==null){H.current.activeId=ne;return}let e=setTimeout(()=>{H.current.activeId=ne},50);return()=>clearTimeout(e)},[ne]),{active:O,activeIndex:f,attributes:j,data:S,rect:w,index:x,newIndex:V,items:u,isOver:E,isSorting:ee,isDragging:P,listeners:N,node:T,overIndex:g,over:F,setNodeRef:R,setActivatorNodeRef:I,setDroppableNodeRef:D,setDraggableNodeRef:M,transform:ae??B,transition:oe()};function oe(){if(ae||re&&H.current.newIndex===x)return pO;if(!(z&&!ET(k)||!l)&&(ee||ie))return kT.Transition.toString({...l,property:fO})}}function _O(e,t){return typeof e==`boolean`?{draggable:e,droppable:!1}:{draggable:e?.draggable??t.draggable,droppable:e?.droppable??t.droppable}}LE.Down,LE.Right,LE.Up,LE.Left;function vO(e,t){let n=t.toLowerCase().split(`+`),r=n.includes(`mod`),i=n.includes(`shift`),a=n[n.length-1];return(r?e.metaKey||e.ctrlKey:!e.metaKey&&!e.ctrlKey)&&i===e.shiftKey&&!e.altKey&&e.key.toLowerCase()===a}function yO(e,t,n){let r=n?.enabled??!0,{register:i}=(0,v.useContext)(ba),a=(0,v.useRef)(t);(0,v.useEffect)(()=>{a.current=t}),(0,v.useEffect)(()=>{if(n?.label)return i(e,n.label)},[e,n?.label,i]),(0,v.useEffect)(()=>{function t(t){vO(t,e)&&(t.preventDefault(),r&&a.current())}return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e,r])}function bO(e,t){switch(e){case`string`:return{icon:Yo,label:`Text (string)`,color:`text-blue-600`,bg:`bg-blue-50`};case`text`:return{icon:Wo,label:`Long text (string)`,color:`text-sky-600`,bg:`bg-sky-50`};case`richtext`:return{icon:io,label:`Rich text (blocks)`,color:`text-violet-600`,bg:`bg-violet-50`};case`number`:return{icon:fo,label:t===`float`?`Decimal (number)`:`Integer (number)`,color:`text-orange-600`,bg:`bg-orange-50`};case`boolean`:return{icon:Ko,label:`Boolean`,color:`text-emerald-600`,bg:`bg-emerald-50`};case`datetime`:return{icon:La,label:`Date & time`,color:`text-amber-600`,bg:`bg-amber-50`};case`media`:return{icon:_o,label:`Media`,color:`text-rose-600`,bg:`bg-rose-50`};case`mixed`:return{icon:wo,label:`Mixed value`,color:`text-fuchsia-600`,bg:`bg-fuchsia-50`};case`media-gallery`:return{icon:Co,label:`Media Gallery`,color:`text-pink-600`,bg:`bg-pink-50`};case`relation`:return{icon:To,label:`Relation`,color:`text-indigo-600`,bg:`bg-indigo-50`};case`uid`:return{icon:oo,label:`UID`,color:`text-teal-600`,bg:`bg-teal-50`};case`array`:return{icon:wo,label:`Array`,color:`text-cyan-600`,bg:`bg-cyan-50`};case`navigation`:return{icon:Do,label:`Navigation`,color:`text-cyan-600`,bg:`bg-cyan-50`}}}var xO={full:`col-span-6`,"two-thirds":`col-span-4`,half:`col-span-3`,third:`col-span-2`},SO={string:`half`,text:`full`,richtext:`full`,number:`third`,boolean:`third`,datetime:`half`,media:`half`,"media-gallery":`full`,relation:`half`,uid:`half`,array:`full`,navigation:`full`};function CO({width:e}){let t=`rounded-sm bg-current`;return e===`full`?(0,U.jsx)(`div`,{className:`flex w-4 gap-px`,children:(0,U.jsx)(`div`,{className:`${t} h-2 w-full`})}):e===`two-thirds`?(0,U.jsxs)(`div`,{className:`flex w-4 gap-px`,children:[(0,U.jsx)(`div`,{className:`${t} h-2 flex-1`}),(0,U.jsx)(`div`,{className:`${t} h-2 flex-1`}),(0,U.jsx)(`div`,{className:`h-2 flex-1 rounded-sm bg-current opacity-25`})]}):e===`half`?(0,U.jsxs)(`div`,{className:`flex w-4 gap-px`,children:[(0,U.jsx)(`div`,{className:`${t} h-2 flex-1`}),(0,U.jsx)(`div`,{className:`${t} h-2 flex-1`})]}):(0,U.jsxs)(`div`,{className:`flex w-4 gap-px`,children:[(0,U.jsx)(`div`,{className:`${t} h-2 flex-1`}),(0,U.jsx)(`div`,{className:`h-2 flex-1 rounded-sm bg-current opacity-25`}),(0,U.jsx)(`div`,{className:`h-2 flex-1 rounded-sm bg-current opacity-25`})]})}var wO=[{value:`full`,label:`Full width`},{value:`half`,label:`Half`},{value:`third`,label:`1/3`},{value:`two-thirds`,label:`2/3`}];function TO({field:e,onWidthChange:t,onArraySubFieldWidthChange:n,onEdit:r,onDelete:i,dragListeners:a,dragAttributes:o}){let{icon:s,label:c,color:l,bg:u}=bO(e.type,e.subtype),d=e.width??`full`,f=!!a,p=e.type===`array`;return(0,U.jsxs)(`div`,{className:`rounded-lg border border-border bg-card shadow-xs`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-3`,children:[f&&(0,U.jsx)(`button`,{type:`button`,className:`flex shrink-0 cursor-grab items-center text-muted-foreground/40 hover:text-muted-foreground active:cursor-grabbing`,...a,...o,children:(0,U.jsx)(uo,{className:`size-4`})}),(0,U.jsx)(`div`,{className:`flex size-8 shrink-0 items-center justify-center rounded-md ${u}`,children:(0,U.jsx)(s,{className:`size-4 ${l}`})}),(0,U.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,U.jsxs)(`p`,{className:`truncate text-sm font-medium leading-tight`,children:[e.name,e.required&&(0,U.jsx)(`span`,{className:`ml-1 text-destructive`,children:`*`})]}),e.relationType===`one-to-many`&&(0,U.jsx)(`span`,{className:`shrink-0 rounded border border-indigo-200 bg-indigo-50 px-1 py-px text-[10px] font-medium text-indigo-600`,children:`Auto`})]}),(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.relationType===`one-to-many`?`Inverse relation · read-only`:c})]}),t&&!p&&(0,U.jsx)(`div`,{className:`flex shrink-0 items-center gap-px rounded-md border border-border p-0.5`,children:wO.map(({value:e,label:n})=>(0,U.jsx)(`button`,{type:`button`,title:n,onClick:()=>t(e),className:[`flex items-center justify-center rounded px-1.5 py-1 transition-colors`,d===e?`bg-foreground text-background`:`text-muted-foreground hover:text-foreground`].join(` `),children:(0,U.jsx)(CO,{width:e})},e))}),(r||i)&&(0,U.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,children:[r&&(0,U.jsx)(`button`,{type:`button`,title:`Edit field`,onClick:r,className:`flex size-7 items-center justify-center rounded text-muted-foreground transition-colors hover:bg-accent hover:text-accent-foreground`,children:(0,U.jsx)(No,{className:`size-3.5`})}),i&&(0,U.jsx)(`button`,{type:`button`,title:`Delete field`,onClick:i,className:`flex size-7 items-center justify-center rounded text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive`,children:(0,U.jsx)(qo,{className:`size-3.5`})})]})]}),p&&e.arrayFields&&e.arrayFields.length>0&&(0,U.jsx)(`div`,{className:`grid grid-cols-6 gap-2 px-3 pb-3`,children:e.arrayFields.map(e=>{let t=bO(e.type,e.subtype),r=t.icon;return(0,U.jsxs)(`div`,{className:`${xO[e.width??`full`]} rounded-md border border-dashed border-border p-2`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,U.jsx)(`div`,{className:`flex size-5 shrink-0 items-center justify-center rounded ${t.bg}`,children:(0,U.jsx)(r,{className:`size-3 ${t.color}`})}),(0,U.jsxs)(`span`,{className:`truncate text-xs font-medium`,children:[e.name,e.required&&(0,U.jsx)(`span`,{className:`ml-0.5 text-destructive`,children:`*`})]})]}),(0,U.jsx)(`p`,{className:`mt-0.5 truncate pl-6 text-[10px] text-muted-foreground`,children:t.label}),n&&(0,U.jsx)(`div`,{className:`mt-1 flex items-center gap-px rounded-md border border-border p-0.5`,children:wO.map(({value:t,label:r})=>(0,U.jsx)(`button`,{type:`button`,title:r,onClick:()=>n(e.name,t),className:[`flex items-center justify-center rounded px-1.5 py-1 transition-colors`,(e.width??`full`)===t?`bg-foreground text-background`:`text-muted-foreground hover:text-foreground`].join(` `),children:(0,U.jsx)(CO,{width:t})},t))})]},e.name)})})]})}var EO=v.forwardRef(({className:e,...t},n)=>(0,U.jsx)(bx,{ref:n,className:q(`peer size-4 shrink-0 rounded-sm border border-input shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground data-[state=checked]:border-primary`,e),...t,children:(0,U.jsx)(Sx,{className:`flex items-center justify-center text-current`,children:(0,U.jsx)(za,{className:`size-3`})})}));EO.displayName=bx.displayName;var DO=[{type:`string`,icon:Yo,label:`Text`,color:`text-blue-600`,bg:`bg-blue-50`},{type:`text`,icon:Wo,label:`Long Text`,color:`text-sky-600`,bg:`bg-sky-50`},{type:`richtext`,icon:io,label:`Rich Text`,color:`text-violet-600`,bg:`bg-violet-50`},{type:`number`,subtype:`integer`,icon:fo,label:`Integer`,color:`text-orange-600`,bg:`bg-orange-50`},{type:`number`,subtype:`float`,icon:fo,label:`Decimal`,color:`text-orange-600`,bg:`bg-orange-50`},{type:`boolean`,icon:Ko,label:`Boolean`,color:`text-emerald-600`,bg:`bg-emerald-50`},{type:`datetime`,icon:La,label:`Date & Time`,color:`text-amber-600`,bg:`bg-amber-50`},{type:`media`,icon:_o,label:`Media`,color:`text-rose-600`,bg:`bg-rose-50`},{type:`mixed`,icon:wo,label:`Mixed Value`,color:`text-fuchsia-600`,bg:`bg-fuchsia-50`}],OO={string:`half`,text:`full`,richtext:`full`,number:`third`,boolean:`third`,datetime:`half`,media:`half`,mixed:`half`},kO={type:`string`,subtype:void 0,name:``,required:!1,allowedTypes:[],width:`half`},AO=[{type:`string`,icon:Yo,label:`Text (string)`,description:`Titles, names, labels`,color:`text-blue-600`,bg:`bg-blue-50`},{type:`text`,icon:Wo,label:`Long text (string)`,description:`Plain text, paragraphs`,color:`text-sky-600`,bg:`bg-sky-50`},{type:`richtext`,icon:io,label:`Rich text (blocks)`,description:`Formatted HTML content`,color:`text-violet-600`,bg:`bg-violet-50`},{type:`uid`,icon:oo,label:`UID`,description:`Unique slug from a field`,color:`text-teal-600`,bg:`bg-teal-50`},{type:`boolean`,icon:Ko,label:`Boolean`,description:`True or false`,color:`text-emerald-600`,bg:`bg-emerald-50`},{type:`datetime`,icon:La,label:`Date & time`,description:`Timestamps and dates`,color:`text-amber-600`,bg:`bg-amber-50`},{type:`media`,icon:_o,label:`Media`,description:`Images, videos or files`,color:`text-rose-600`,bg:`bg-rose-50`},{type:`media-gallery`,icon:Co,label:`Media Gallery`,description:`Multiple images for galleries`,color:`text-pink-600`,bg:`bg-pink-50`},{type:`array`,icon:wo,label:`Array`,description:`Repeatable list of items`,color:`text-cyan-600`,bg:`bg-cyan-50`},{type:`navigation`,icon:Do,label:`Navigation`,description:`Nested navigation items`,color:`text-cyan-600`,bg:`bg-cyan-50`},{type:`number`,subtype:`integer`,icon:fo,label:`Integer (number)`,description:`Whole numbers`,color:`text-orange-600`,bg:`bg-orange-50`},{type:`number`,subtype:`float`,icon:fo,label:`Decimal (number)`,description:`Numbers with decimals`,color:`text-orange-600`,bg:`bg-orange-50`},{type:`relation`,icon:To,label:`Relation`,description:`Link to another content type`,color:`text-indigo-600`,bg:`bg-indigo-50`}],jO=[{value:`image`,label:`Images`},{value:`video`,label:`Videos`},{value:`audio`,label:`Audio`},{value:`document`,label:`Documents`}],MO=[{value:`many-to-one`,label:`Many-to-One`,description:`Many of these → one of the other`},{value:`one-to-one`,label:`One-to-One`,description:`One of these ↔ one of the other`},{value:`many-to-many`,label:`Many-to-Many`,description:`Many of these ↔ many of the other`}],NO=new Set(`all.analyse.analyze.and.any.array.as.asc.asymmetric.authorization.between.binary.both.case.cast.check.collate.column.constraint.create.cross.current_catalog.current_date.current_role.current_schema.current_time.current_timestamp.current_user.default.deferrable.desc.distinct.do.else.end.except.false.fetch.for.foreign.from.grant.group.having.in.initially.intersect.into.lateral.leading.limit.localtime.localtimestamp.not.null.offset.on.only.or.order.placing.primary.references.returning.select.session_user.some.symmetric.table.then.to.trailing.true.union.unique.user.using.variadic.when.where.window.with`.split(`.`));function PO(e){return NO.has(e.toLowerCase())}var FO={name:``,required:!1,relationType:`many-to-one`,relatedTable:``,relatedSlug:``,targetField:``,allowedTypes:[],arrayFields:[]};function IO({open:e,onOpenChange:t,existingNames:n,availableContentTypes:r,stringFields:i,initialField:a,onConfirm:o}){let[s,c]=(0,v.useState)(null),[l,u]=(0,v.useState)(FO),[d,f]=(0,v.useState)(``),[p,m]=(0,v.useState)(null),[h,g]=(0,v.useState)(``),[_,y]=(0,v.useState)(``),b=!!a;(0,v.useEffect)(()=>{e?a&&(c(AO.find(e=>e.type===a.type&&(e.subtype??void 0)===(a.subtype??void 0))??null),u({name:a.name,required:a.required??!1,relationType:a.relationType??`many-to-one`,relatedTable:a.relatedTable??``,relatedSlug:a.relatedSlug??``,targetField:a.targetField??``,allowedTypes:a.allowedTypes??[],arrayFields:a.arrayFields??[]})):(c(null),u(FO),f(``),m(null),g(``),y(``))},[e,a]);function x(e){t(e)}function S(e){c(e),u(FO),f(``),m(null),g(``),y(``)}function C(){b||(c(null),u(FO),f(``),m(null),g(``),y(``))}function w(){m({...kO}),g(``)}function T(e){m(t=>t?{...t,type:e.type,subtype:e.subtype,width:OO[e.type]}:{...kO,type:e.type,subtype:e.subtype,width:OO[e.type]})}function E(){if(!p)return;let e=p.name.trim();if(!e){g(`Name is required`);return}if(!/^[a-z][a-z0-9_]*$/.test(e)){g(`Lowercase letters, digits and underscores only`);return}if(PO(e)){g(`This name is reserved by SQL. Choose another one.`);return}if(l.arrayFields.some(t=>t.name===e)){g(`A sub-field with this name already exists`);return}let t={name:e,type:p.type,subtype:p.subtype,required:p.required||void 0,allowedTypes:p.type===`media`&&p.allowedTypes.length>0?p.allowedTypes:void 0,width:p.width};u(e=>({...e,arrayFields:[...e.arrayFields,t]})),m(null),g(``)}function D(e){u(t=>({...t,arrayFields:t.arrayFields.filter(t=>t.name!==e)}))}function O(e,t){u(n=>({...n,arrayFields:n.arrayFields.map((n,r)=>r===e?{...n,name:t}:n)})),y(``)}function k(){let e=l.arrayFields.map(e=>e.name.trim());return e.some(e=>!e)?(y(`All sub-fields must have a name.`),!1):e.some(e=>!/^[a-z][a-z0-9_]*$/.test(e))?(y(`Sub-field names must use lowercase letters, digits and underscores.`),!1):e.some(e=>PO(e))?(y(`One or more sub-field names are reserved by SQL.`),!1):new Set(e).size===e.length?!0:(y(`Sub-field names must be unique.`),!1)}function A(){let e=l.name.trim();return e?/^[a-z][a-z0-9_]*$/.test(e)?PO(e)?(f(`This name is reserved by SQL. Choose another one.`),!1):n.includes(e)&&e!==a?.name?(f(`A field with this name already exists`),!1):!0:(f(`Lowercase letters, digits and underscores only`),!1):(f(`Name is required`),!1)}function j(){!s||!A()||s.type===`array`&&!k()||(o({name:l.name.trim(),type:s.type,subtype:s.subtype,required:l.required||void 0,relationType:s.type===`relation`?l.relationType:void 0,relatedTable:s.type===`relation`?l.relatedTable:void 0,relatedSlug:s.type===`relation`?l.relatedSlug:void 0,targetField:s.type===`uid`?l.targetField:void 0,allowedTypes:s.type===`media`&&l.allowedTypes.length>0?l.allowedTypes:s.type===`media-gallery`?[`image`]:void 0,arrayFields:s.type===`array`?l.arrayFields.map(e=>({...e,name:e.name.trim()})):void 0,width:a?.width??SO[s.type]}),x(!1))}let M=!!s,N=s?.label.replace(/\s*\(.*?\)/,``)??``,P=b?`Edit field`:M?`${N} field`:`Add a field`;return(0,U.jsx)(yw,{open:e,onOpenChange:x,children:(0,U.jsxs)(Cw,{className:M?s?.type===`array`?`max-w-lg`:`max-w-md`:`max-w-3xl`,children:[(0,U.jsx)(ww,{children:(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[M&&!b&&(0,U.jsx)(`button`,{type:`button`,onClick:C,className:`flex size-7 items-center justify-center rounded text-muted-foreground hover:bg-accent hover:text-accent-foreground`,children:(0,U.jsx)(Pa,{className:`size-4`})}),(0,U.jsx)(Ew,{children:P})]})}),!M&&(0,U.jsx)(`div`,{className:`grid grid-cols-3 gap-2 pt-1`,children:AO.map(e=>{let t=e.icon,n=`${e.type}${e.subtype??``}`;return(0,U.jsxs)(`button`,{type:`button`,disabled:e.disabled,onClick:()=>!e.disabled&&S(e),className:`flex flex-col items-start gap-2 rounded-lg border border-border p-3 text-left transition-colors hover:border-primary hover:bg-accent disabled:cursor-not-allowed disabled:opacity-40`,children:[(0,U.jsx)(`div`,{className:`flex size-8 items-center justify-center rounded-md ${e.bg}`,children:(0,U.jsx)(t,{className:`size-4 ${e.color}`})}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`p`,{className:`text-sm font-medium`,children:e.label}),(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.disabled?`Coming soon`:e.description})]})]},n)})}),M&&(0,U.jsxs)(`div`,{className:`flex flex-col gap-4 pt-1`,children:[(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsx)(X,{htmlFor:`field-name`,children:`Field name`}),(0,U.jsx)(Hv,{id:`field-name`,placeholder:`e.g. article_title`,value:l.name,autoFocus:!0,onChange:e=>{u(t=>({...t,name:e.target.value})),f(``)},onKeyDown:e=>{e.key===`Enter`&&j()}}),d&&(0,U.jsx)(`p`,{className:`text-xs text-destructive`,children:d}),(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Lowercase letters, digits and underscores. Must start with a letter.`})]}),s?.type===`media`&&(0,U.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,U.jsx)(X,{children:`Allowed file types`}),(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground -mt-1`,children:`Leave all unchecked to allow any file type.`}),(0,U.jsx)(`div`,{className:`grid grid-cols-2 gap-2`,children:jO.map(({value:e,label:t})=>(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(EO,{id:`media-type-${e}`,checked:l.allowedTypes.includes(e),onCheckedChange:t=>u(n=>({...n,allowedTypes:t?[...n.allowedTypes,e]:n.allowedTypes.filter(t=>t!==e)}))}),(0,U.jsx)(X,{htmlFor:`media-type-${e}`,className:`cursor-pointer font-normal`,children:t})]},e))})]}),s?.type===`array`&&(0,U.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,U.jsx)(X,{children:`Sub-fields`}),!p&&(0,U.jsxs)(`button`,{type:`button`,onClick:w,className:`flex items-center gap-1 rounded px-2 py-1 text-xs text-muted-foreground transition-colors hover:bg-accent hover:text-accent-foreground`,children:[(0,U.jsx)(Po,{className:`size-3`}),`Add sub-field`]})]}),l.arrayFields.length===0&&!p&&(0,U.jsx)(`p`,{className:`rounded-md border border-dashed border-border px-3 py-4 text-center text-xs text-muted-foreground`,children:`No sub-fields yet. Add at least one to make this field useful.`}),l.arrayFields.length>0&&(0,U.jsx)(`div`,{className:`grid grid-cols-6 gap-1.5`,children:l.arrayFields.map((e,t)=>{let n=DO.find(t=>t.type===e.type&&(t.subtype??void 0)===(e.subtype??void 0)),r=n?.icon??Yo;return(0,U.jsxs)(`div`,{className:`${xO[e.width??`full`]} flex items-center gap-1.5 rounded-md border border-dashed border-border p-2`,children:[(0,U.jsx)(`div`,{className:`flex size-5 shrink-0 items-center justify-center rounded ${n?.bg??`bg-muted`}`,children:(0,U.jsx)(r,{className:`size-3 ${n?.color??`text-muted-foreground`}`})}),(0,U.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,U.jsx)(Hv,{value:e.name,onChange:e=>O(t,e.target.value),className:`h-6 px-1.5 text-xs`}),(0,U.jsx)(`p`,{className:`truncate text-[10px] text-muted-foreground`,children:n?.label})]}),(0,U.jsx)(`button`,{type:`button`,onClick:()=>D(e.name),className:`flex shrink-0 size-5 items-center justify-center rounded text-muted-foreground hover:text-destructive`,children:(0,U.jsx)(qo,{className:`size-3`})})]},`subfield-${t}`)})}),_&&(0,U.jsx)(`p`,{className:`text-xs text-destructive`,children:_}),p&&(0,U.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-lg border border-border bg-muted/30 p-3`,children:[(0,U.jsx)(`div`,{className:`grid grid-cols-4 gap-1.5`,children:DO.map(e=>{let t=e.icon,n=`${e.type}${e.subtype??``}`;return(0,U.jsxs)(`button`,{type:`button`,onClick:()=>T(e),className:[`flex items-center gap-1.5 rounded-md border px-2 py-1.5 text-left transition-colors`,p.type===e.type&&(p.subtype??void 0)===(e.subtype??void 0)?`border-primary bg-accent`:`border-border hover:border-primary hover:bg-accent`].join(` `),children:[(0,U.jsx)(`div`,{className:`flex size-5 shrink-0 items-center justify-center rounded ${e.bg}`,children:(0,U.jsx)(t,{className:`size-3 ${e.color}`})}),(0,U.jsx)(`span`,{className:`truncate text-xs font-medium`,children:e.label})]},n)})}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,U.jsx)(Hv,{placeholder:`sub_field_name`,autoFocus:!0,value:p.name,onChange:e=>{m(t=>t&&{...t,name:e.target.value}),g(``)},onKeyDown:e=>{e.key===`Enter`&&E()}}),h&&(0,U.jsx)(`p`,{className:`text-xs text-destructive`,children:h})]}),(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,U.jsx)(EO,{id:`subfield-required`,checked:p.required,onCheckedChange:e=>m(t=>t&&{...t,required:!!e})}),(0,U.jsx)(X,{htmlFor:`subfield-required`,className:`cursor-pointer font-normal text-sm`,children:`Required`})]}),(0,U.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,U.jsx)(J,{variant:`ghost`,size:`sm`,onClick:()=>{m(null),g(``)},children:`Cancel`}),(0,U.jsx)(J,{size:`sm`,onClick:E,children:`Add`})]})]})]})]}),s?.type===`uid`&&(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsx)(X,{children:`Source field`}),(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`The slug will be auto-generated from this field's value.`}),i.length>0?(0,U.jsxs)(Ow,{value:l.targetField,onValueChange:e=>u(t=>({...t,targetField:e})),children:[(0,U.jsx)(jw,{children:(0,U.jsx)(Aw,{placeholder:`Select a text field`})}),(0,U.jsx)(Pw,{children:i.map(e=>(0,U.jsx)(Iw,{value:e.name,children:e.name},e.name))})]}):(0,U.jsx)(`p`,{className:`rounded-md border border-border bg-muted px-3 py-2 text-xs text-muted-foreground`,children:`No short text fields available. Add a string field first.`})]}),s?.type===`relation`&&(0,U.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsx)(X,{children:`Relation type`}),(0,U.jsx)(`div`,{className:`grid grid-cols-1 gap-1.5`,children:MO.map(e=>(0,U.jsx)(`button`,{type:`button`,onClick:()=>u(t=>({...t,relationType:e.value})),className:`flex items-start gap-3 rounded-md border px-3 py-2 text-left transition-colors hover:border-primary ${l.relationType===e.value?`border-primary bg-accent`:`border-border`}`,children:(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`p`,{className:`text-sm font-medium leading-none`,children:e.label}),(0,U.jsx)(`p`,{className:`mt-0.5 text-xs text-muted-foreground`,children:e.description})]})},e.value))})]}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsx)(X,{children:`Related content type`}),r.length>0?(0,U.jsxs)(Ow,{value:l.relatedTable,onValueChange:e=>{let t=r.find(t=>t.tableName===e);u(n=>({...n,relatedTable:e,relatedSlug:t?.slug??``}))},children:[(0,U.jsx)(jw,{children:(0,U.jsx)(Aw,{placeholder:`Select a content type`})}),(0,U.jsx)(Pw,{children:r.map(e=>(0,U.jsx)(Iw,{value:e.tableName,children:e.name},e.tableName))})]}):(0,U.jsx)(Hv,{placeholder:`table_name`,value:l.relatedTable,onChange:e=>u(t=>({...t,relatedTable:e.target.value}))})]})]}),(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(EO,{id:`field-required`,checked:l.required,onCheckedChange:e=>u(t=>({...t,required:!!e}))}),(0,U.jsx)(X,{htmlFor:`field-required`,className:`cursor-pointer font-normal`,children:`Required field`})]}),(0,U.jsxs)(`div`,{className:`flex justify-end gap-2 border-t border-border pt-3`,children:[(0,U.jsx)(J,{variant:`outline`,onClick:()=>x(!1),children:`Cancel`}),(0,U.jsx)(J,{onClick:j,children:b?`Save changes`:`Add field`})]})]})]})})}function LO(e){return e.toLowerCase().replace(/\s+/g,`-`).replace(/[^a-z0-9-]/g,``).replace(/^-+|-+$/g,``)}function RO(e){return e.replace(/-/g,`_`)}function zO({field:e,onWidthChange:t,onArraySubFieldWidthChange:n,onEdit:r,onDelete:i}){let{attributes:a,listeners:o,setNodeRef:s,transform:c,transition:l,isDragging:u}=gO({id:e.name});return(0,U.jsx)(`div`,{ref:s,style:{transform:kT.Transform.toString(c),transition:l,opacity:u?.5:1},className:xO[e.width??`full`],children:(0,U.jsx)(TO,{field:e,dragListeners:o,dragAttributes:a,onWidthChange:t,onArraySubFieldWidthChange:n,onEdit:r,onDelete:i})})}function BO(){let{slug:e}=hr(),t=dr(),n=!e,{user:r}=ga(),i=r?.permissions??[],a=i.includes(`*`)||i.includes(`content-types:delete`),{data:o,loading:s}=wa(n?``:`/cms/admin/content-types/${e}`),{data:c,refetch:l}=wa(`/cms/admin/content-types`),{loading:u,request:d}=Vv(),{loading:f,request:p}=Vv(),[m,h]=(0,v.useState)(``),[g,_]=(0,v.useState)(``),[y,b]=(0,v.useState)(`collection`),[x,S]=(0,v.useState)([]),[C,w]=(0,v.useState)(!1),[T,E]=(0,v.useState)(null),[D,O]=(0,v.useState)(!1),k=(0,v.useRef)({name:``,slug:``,fields:`[]`});(0,v.useEffect)(()=>(window.addEventListener(`plank:content-types-changed`,l),()=>window.removeEventListener(`plank:content-types-changed`,l)),[l]),(0,v.useEffect)(()=>{if(n){h(``),_(``),b(`collection`),S([]),k.current={name:``,slug:``,fields:`[]`};return}o&&(h(o.name),_(o.slug),b(o.kind??`collection`),S(o.fields),k.current={name:o.name,slug:o.slug,fields:JSON.stringify(o.fields)})},[o,n]),(0,v.useEffect)(()=>{n&&m&&_(LO(m))},[n,m]);let A=m!==k.current.name||JSON.stringify(x)!==k.current.fields,j=(0,v.useRef)(!1),M=Fr((0,v.useCallback)(()=>j.current?!1:A,[A])),N=GT(WT(GE,{activationConstraint:{distance:5}}));function P(e){let{active:t,over:n}=e;!n||t.id===n.id||S(e=>ZD(e,e.findIndex(e=>e.name===t.id),e.findIndex(e=>e.name===n.id)))}function F(e){S(t=>[...t,e])}function I(e){S(t=>t.map(t=>t.name===T?.name?e:t)),E(null)}function L(e){S(t=>t.filter(t=>t.name!==e))}function R(e,t){S(n=>n.map(n=>n.name===e?{...n,width:t}:n))}function ee(e,t,n){S(r=>r.map(r=>r.name!==e||r.type!==`array`||!r.arrayFields?r:{...r,arrayFields:r.arrayFields.map(e=>e.name===t?{...e,width:n}:e)}))}async function te(){if(!m.trim()||!g.trim())return;let r=n?{name:m.trim(),slug:g,kind:y,tableName:RO(g),fields:x}:{name:m.trim(),slug:g,tableName:RO(g),fields:x};try{let i=await d(n?`/cms/admin/content-types`:`/cms/admin/content-types/${e}`,n?`POST`:`PUT`,r);h(i.name),_(i.slug),S(i.fields),k.current={name:i.name,slug:i.slug,fields:JSON.stringify(i.fields)},window.dispatchEvent(new CustomEvent(`plank:content-types-changed`)),(n||i.slug!==e)&&(j.current=!0,t(`/content-types/${i.slug}`,{replace:!0}))}catch{}}async function z(){if(a)try{await p(`/cms/admin/content-types/${e}`,`DELETE`),window.dispatchEvent(new CustomEvent(`plank:content-types-changed`)),t(`/content-types`,{replace:!0})}catch{}}let B=(c??[]).filter(t=>t.slug!==e).map(e=>({tableName:e.tableName,slug:e.slug,name:e.name})),V=x.filter(e=>e.type===`string`),ne=x.map(e=>e.name);return yO(`mod+s`,te,{enabled:A&&!u&&!!m.trim(),label:`Save content type`}),yO(`mod+k`,()=>w(!0),{label:`Add field`}),!n&&s?(0,U.jsxs)(`div`,{className:`flex items-center gap-2 py-12 text-muted-foreground`,children:[(0,U.jsx)(by,{className:`size-4`}),(0,U.jsx)(`span`,{className:`text-sm`,children:`Loading…`})]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(yy,{children:(0,U.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,U.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,U.jsx)(`input`,{value:m,onChange:e=>h(e.target.value),placeholder:`Content type name`,className:`bg-transparent text-2xl font-bold outline-none placeholder:text-muted-foreground/40 -mt-2`}),(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,U.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:`API ID:`}),(0,U.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:g||`—`})]}),n?(0,U.jsxs)(`div`,{className:`flex items-center gap-1 rounded-md border p-0.5`,children:[(0,U.jsxs)(`button`,{type:`button`,onClick:()=>b(`collection`),className:`flex items-center gap-1.5 rounded px-2 py-0.5 text-xs font-medium transition-colors ${y===`collection`?`bg-muted text-foreground`:`text-muted-foreground hover:text-foreground`}`,children:[(0,U.jsx)(Oo,{className:`size-3`}),`Collection`]}),(0,U.jsxs)(`button`,{type:`button`,onClick:()=>b(`single`),className:`flex items-center gap-1.5 rounded px-2 py-0.5 text-xs font-medium transition-colors ${y===`single`?`bg-muted text-foreground`:`text-muted-foreground hover:text-foreground`}`,children:[(0,U.jsx)(ao,{className:`size-3`}),`Single`]})]}):(0,U.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border px-2 py-0.5 text-xs font-medium text-muted-foreground ${y===`single`?`border-violet-500/30 bg-violet-500/10 text-violet-600 dark:text-violet-400`:``}`,children:[y===`single`?(0,U.jsx)(ao,{className:`size-3`}):(0,U.jsx)(Oo,{className:`size-3`}),y===`single`?`Single`:`Collection`]})]})]}),(0,U.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[!n&&a&&(0,U.jsx)(J,{variant:`ghost`,size:`icon`,className:`text-muted-foreground hover:text-destructive`,onClick:()=>O(!0),disabled:f,children:(0,U.jsx)(qo,{className:`size-4`})}),(0,U.jsxs)(J,{onClick:te,disabled:!A||u||!m.trim(),children:[u?(0,U.jsx)(by,{className:`size-4`}):null,`Save`]})]})]})}),(0,U.jsxs)(`section`,{className:`mt-24`,children:[x.length>0?(()=>{let e=x.filter(e=>e.relationType!==`one-to-many`),t=x.filter(e=>e.relationType===`one-to-many`);return(0,U.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[e.length>0&&(0,U.jsx)(HD,{sensors:N,collisionDetection:QT,onDragEnd:P,children:(0,U.jsx)(cO,{items:e.map(e=>e.name),strategy:iO,children:(0,U.jsx)(`div`,{className:`grid grid-cols-6 gap-3`,children:e.map(e=>(0,U.jsx)(zO,{field:e,onWidthChange:t=>R(e.name,t),onArraySubFieldWidthChange:(t,n)=>ee(e.name,t,n),onEdit:()=>E(e),onDelete:()=>L(e.name)},e.name))})})}),t.length>0&&(0,U.jsx)(`div`,{className:`grid grid-cols-6 gap-3`,children:t.map(e=>(0,U.jsx)(`div`,{className:`col-span-6`,children:(0,U.jsx)(TO,{field:e})},e.name))})]})})():(0,U.jsx)(Xw,{className:`border`,children:(0,U.jsxs)(Zw,{children:[(0,U.jsx)($w,{variant:`icon`,children:(0,U.jsx)(xo,{})}),(0,U.jsx)(eT,{children:`No fields yet`}),(0,U.jsx)(tT,{children:`Add your first field to define this content type's structure.`})]})}),(0,U.jsx)(`div`,{className:`mt-4`,children:(0,U.jsxs)(J,{variant:`outline`,onClick:()=>w(!0),className:`gap-2`,children:[(0,U.jsx)(Po,{className:`size-4`}),`Add field`]})}),(0,U.jsx)(IO,{open:C,onOpenChange:w,existingNames:ne,availableContentTypes:B,stringFields:V,onConfirm:F}),(0,U.jsx)(IO,{open:!!T,onOpenChange:e=>{e||E(null)},existingNames:ne,availableContentTypes:B,stringFields:V,initialField:T??void 0,onConfirm:I}),(0,U.jsx)(yw,{open:D,onOpenChange:O,children:(0,U.jsxs)(Cw,{className:`max-w-sm`,children:[(0,U.jsx)(ww,{children:(0,U.jsxs)(Ew,{children:[`Delete "`,m,`"?`]})}),(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`This will permanently delete the content type and all its entries. This action cannot be undone.`}),(0,U.jsxs)(Tw,{children:[(0,U.jsx)(J,{variant:`outline`,onClick:()=>O(!1),children:`Cancel`}),(0,U.jsxs)(J,{variant:`destructive`,onClick:z,disabled:f,children:[f?(0,U.jsx)(by,{className:`size-4`}):null,`Delete`]})]})]})}),(0,U.jsx)(yw,{open:M.state===`blocked`,onOpenChange:()=>M.reset?.(),children:(0,U.jsxs)(Cw,{className:`max-w-sm`,children:[(0,U.jsx)(ww,{children:(0,U.jsx)(Ew,{children:`Unsaved changes`})}),(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`You have unsaved changes. Leave without saving?`}),(0,U.jsxs)(Tw,{children:[(0,U.jsx)(J,{variant:`outline`,onClick:()=>M.reset?.(),children:`Stay`}),(0,U.jsx)(J,{variant:`destructive`,onClick:()=>M.proceed?.(),children:`Leave`})]})]})})]})]})}function VO(){let{pathname:e}=cr(),{user:t}=ga(),{data:n,loading:r,error:i,refetch:a}=wa(`/cms/admin/content-types`),{request:o}=Vv(),s=t?.permissions??[],c=s.includes(`*`)||s.includes(`content-types:write`);async function l(e,t){e.preventDefault(),e.stopPropagation(),await o(`/cms/admin/content-types/${t}/default`,`PUT`),a()}function u(t){return e===`/content/${t}`||e.startsWith(`/content/${t}/`)}let d=(n??[]).filter(e=>e.kind===`collection`),f=(n??[]).filter(e=>e.kind===`single`);return(0,U.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,U.jsx)(`div`,{className:`shrink-0 border-b border-sidebar-border px-4 py-3`,children:(0,U.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:`Content`})}),r&&(0,U.jsx)(`div`,{className:`flex items-center justify-center py-6`,children:(0,U.jsx)(by,{className:`size-4`})}),i&&(0,U.jsx)(`p`,{className:`px-4 py-3 text-xs text-destructive`,children:i}),!r&&!i&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,U.jsx)(`div`,{className:`shrink-0 px-4 py-2`,children:(0,U.jsx)(`p`,{className:`text-[11px] font-medium uppercase tracking-wider text-muted-foreground/60`,children:`Collection Types`})}),(0,U.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:d.length===0?(0,U.jsx)(`p`,{className:`px-4 pb-3 text-xs text-muted-foreground`,children:`No collection types yet.`}):(0,U.jsx)(`nav`,{className:`flex flex-col gap-0.5 px-2 pb-2`,children:d.map(e=>(0,U.jsxs)(qi,{to:`/content/${e.slug}`,className:[`group flex items-center gap-2.5 rounded-md px-2.5 py-1.5 text-sm transition-colors`,u(e.slug)?`bg-sidebar-accent text-sidebar-accent-foreground font-medium`:`text-sidebar-foreground hover:bg-sidebar-accent/50 hover:text-sidebar-accent-foreground`].join(` `),children:[(0,U.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name}),c&&(0,U.jsx)(`button`,{type:`button`,title:e.isDefault?`Default content type`:`Set as default`,onClick:t=>l(t,e.slug),className:[`shrink-0 rounded transition-colors`,e.isDefault?`text-amber-400`:`text-transparent group-hover:text-muted-foreground/40 hover:!text-amber-400`].join(` `),children:(0,U.jsx)(Ho,{className:`size-3.5 ${e.isDefault?`fill-amber-400`:``}`})})]},e.slug))})})]}),(0,U.jsx)(`div`,{className:`shrink-0 border-t border-sidebar-border`}),(0,U.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,U.jsx)(`div`,{className:`shrink-0 px-4 py-2`,children:(0,U.jsx)(`p`,{className:`text-[11px] font-medium uppercase tracking-wider text-muted-foreground/60`,children:`Single Types`})}),(0,U.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:f.length===0?(0,U.jsx)(`p`,{className:`px-4 pb-3 text-xs text-muted-foreground`,children:`No single types yet.`}):(0,U.jsx)(`nav`,{className:`flex flex-col gap-0.5 px-2 pb-2`,children:f.map(e=>(0,U.jsx)(qi,{to:`/content/${e.slug}`,className:[`group flex items-center gap-2.5 rounded-md px-2.5 py-1.5 text-sm transition-colors`,u(e.slug)?`bg-sidebar-accent text-sidebar-accent-foreground font-medium`:`text-sidebar-foreground hover:bg-sidebar-accent/50 hover:text-sidebar-accent-foreground`].join(` `),children:(0,U.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name})},e.slug))})})]})]})]})}function HO(){return qw((0,U.jsx)(VO,{})),(0,U.jsx)(Qr,{})}function UO(){let e=dr(),{data:t,loading:n}=wa(`/cms/admin/content-types`);return(0,v.useEffect)(()=>{!t||t.length===0||e(`/content/${(t.find(e=>e.isDefault)??t[0]).slug}`,{replace:!0})},[t,e]),n||t&&t.length>0?null:(0,U.jsxs)(Xw,{className:`border`,children:[(0,U.jsxs)(Zw,{children:[(0,U.jsx)($w,{variant:`icon`,children:(0,U.jsx)(xo,{})}),(0,U.jsx)(eT,{children:`No content types yet`}),(0,U.jsx)(tT,{children:`Create a content type in the Builder before managing content.`})]}),(0,U.jsx)(nT,{children:(0,U.jsx)(J,{onClick:()=>e(`/content-types/new`),children:`Go to Builder`})})]})}function WO({className:e,orientation:t=`horizontal`,decorative:n=!0,...r}){return(0,U.jsx)(RC,{"data-slot":`separator`,decorative:n,orientation:t,className:q(`shrink-0 bg-border data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px`,e),...r})}var GO=Ts(`group/field flex w-full gap-3 data-[invalid=true]:text-destructive`,{variants:{orientation:{vertical:[`flex-col [&>*]:w-full [&>.sr-only]:w-auto`],horizontal:[`flex-row items-center`,`[&>[data-slot=field-label]]:flex-auto`,`has-[>[data-slot=field-content]]:items-start has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px`],responsive:[`flex-col @md/field-group:flex-row @md/field-group:items-center [&>*]:w-full @md/field-group:[&>*]:w-auto [&>.sr-only]:w-auto`,`@md/field-group:[&>[data-slot=field-label]]:flex-auto`,`@md/field-group:has-[>[data-slot=field-content]]:items-start @md/field-group:has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px`]}},defaultVariants:{orientation:`vertical`}});function KO({className:e,orientation:t=`vertical`,...n}){return(0,U.jsx)(`div`,{role:`group`,"data-slot":`field`,"data-orientation":t,className:q(GO({orientation:t}),e),...n})}function qO({className:e,...t}){return(0,U.jsx)(X,{"data-slot":`field-label`,className:q(`group/field-label peer/field-label flex w-fit gap-2 leading-snug group-data-[disabled=true]/field:opacity-50`,`has-[>[data-slot=field]]:w-full has-[>[data-slot=field]]:flex-col has-[>[data-slot=field]]:rounded-md has-[>[data-slot=field]]:border [&>*]:data-[slot=field]:p-4`,`has-data-[state=checked]:border-primary has-data-[state=checked]:bg-primary/5 dark:has-data-[state=checked]:bg-primary/10`,e),...t})}function JO({className:e,...t}){return(0,U.jsx)(`nav`,{role:`navigation`,"aria-label":`pagination`,"data-slot":`pagination`,className:q(`mx-auto flex w-full justify-center`,e),...t})}function YO({className:e,...t}){return(0,U.jsx)(`ul`,{"data-slot":`pagination-content`,className:q(`flex flex-row items-center gap-1`,e),...t})}function XO({...e}){return(0,U.jsx)(`li`,{"data-slot":`pagination-item`,...e})}function ZO({className:e,isActive:t,size:n=`icon`,...r}){return(0,U.jsx)(`a`,{"aria-current":t?`page`:void 0,"data-slot":`pagination-link`,"data-active":t,className:q(Xc({variant:t?`outline`:`ghost`,size:n}),e),...r})}function QO({className:e,...t}){return(0,U.jsxs)(ZO,{"aria-label":`Go to previous page`,size:`default`,className:q(`gap-1 px-2.5 sm:pl-2.5`,e),...t,children:[(0,U.jsx)(Va,{}),(0,U.jsx)(`span`,{className:`hidden sm:block`,children:`Previous`})]})}function $O({className:e,...t}){return(0,U.jsxs)(ZO,{"aria-label":`Go to next page`,size:`default`,className:q(`gap-1 px-2.5 sm:pr-2.5`,e),...t,children:[(0,U.jsx)(`span`,{className:`hidden sm:block`,children:`Next`}),(0,U.jsx)(Ha,{})]})}function ek({page:e,totalPages:t,limit:n,onPageChange:r,onLimitChange:i}){return(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,U.jsxs)(KO,{orientation:`horizontal`,className:`w-fit`,children:[(0,U.jsx)(qO,{htmlFor:`select-rows-per-page`,children:`Rows per page`}),(0,U.jsxs)(Ow,{value:String(n),onValueChange:e=>i(Number(e)),children:[(0,U.jsx)(jw,{className:`w-20`,id:`select-rows-per-page`,children:(0,U.jsx)(Aw,{})}),(0,U.jsx)(Pw,{align:`start`,children:(0,U.jsxs)(kw,{children:[(0,U.jsx)(Iw,{value:`10`,children:`10`}),(0,U.jsx)(Iw,{value:`30`,children:`30`}),(0,U.jsx)(Iw,{value:`50`,children:`50`}),(0,U.jsx)(Iw,{value:`70`,children:`70`}),(0,U.jsx)(Iw,{value:`100`,children:`100`})]})})]})]}),(0,U.jsx)(JO,{className:`mx-0 w-auto`,children:(0,U.jsxs)(YO,{children:[(0,U.jsx)(XO,{children:(0,U.jsx)(QO,{href:`#`,onClick:t=>{t.preventDefault(),e>1&&r(e-1)},"aria-disabled":e===1,className:e===1?`pointer-events-none opacity-50`:``})}),(0,U.jsx)(XO,{children:(0,U.jsx)($O,{href:`#`,onClick:n=>{n.preventDefault(),e<t&&r(e+1)},"aria-disabled":e===t,className:e===t?`pointer-events-none opacity-50`:``})})]})})]})}var tk=4,nk={field:`created_at`,dir:`desc`},rk=[{name:`created_at`,label:`Created`},{name:`updated_at`,label:`Updated`},{name:`published_at`,label:`Published`}];function ik(e){return e.replace(/_/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}function ak(e){return e.find(e=>e.name===`title`)?.name??e.find(e=>e.name===`name`)?.name??e.find(e=>e.type===`uid`)?.name??e.find(e=>e.type===`string`)?.name??null}function ok(e){if(Array.isArray(e))return e.map(e=>String(e??``).trim()).filter(Boolean);let t=String(e??``).trim();return t?[t]:[]}function sk({relatedSlug:e,value:t,displayField:n}){let[r,i]=(0,v.useState)([]),[a,o]=(0,v.useState)(!1),s=ok(t);return(0,v.useEffect)(()=>{let r=ok(t);if(!e||r.length===0){i([]);return}let a=!1;o(!0);let s=localStorage.getItem(`plank_token`),c=s?{Authorization:`Bearer ${s}`}:{};return(n?Promise.resolve(n):fetch(`/cms/admin/content-types/${e}`,{headers:c}).then(e=>e.ok?e.json():null).then(e=>ak(e?.fields??[])).catch(()=>null)).then(t=>Promise.all(r.map(n=>fetch(`/cms/admin/entries/${e}/${n}`,{headers:c}).then(e=>e.ok?e.json():null).then(e=>e?String((t&&e[t])??e.title??e.name??n):n).catch(()=>n)))).then(e=>{a||i(e.filter(Boolean))}).catch(()=>{a||i(r)}).finally(()=>{a||o(!1)}),()=>{a=!0}},[e,n,t]),s.length===0?(0,U.jsx)(`span`,{className:`text-muted-foreground`,children:`—`}):a&&r.length===0?(0,U.jsx)(`span`,{className:`text-muted-foreground`,children:`…`}):(0,U.jsx)(`span`,{className:`font-medium truncate max-w-50 block`,children:r.join(`, `)})}function ck(e){return{visibleFields:e.slice(0,tk).map(e=>e.name),sort:nk}}function lk(e,t){if(!e)return ck(t);let n=(e.visibleFields??[]).filter(e=>{let n=String(e).split(`.`)[0];return t.some(e=>e.name===n)});return{visibleFields:n.length>0?n:t.slice(0,tk).map(e=>e.name),sort:e.sort??nk}}async function uk(e){let t=localStorage.getItem(`plank_token`),n=await fetch(`/cms/admin/users/me/prefs/view_${e}`,{headers:t?{Authorization:`Bearer ${t}`}:{}});if(!n.ok)return null;let{value:r}=await n.json();return r}async function dk(e,t){let n=localStorage.getItem(`plank_token`);await fetch(`/cms/admin/users/me/prefs/view_${e}`,{method:`PUT`,headers:{"Content-Type":`application/json`,...n?{Authorization:`Bearer ${n}`}:{}},body:JSON.stringify({value:t})})}function fk({value:e}){let[t,n]=(0,v.useState)(null);return(0,v.useEffect)(()=>{if(e.startsWith(`http`)){n(e);return}let t=localStorage.getItem(`plank_token`);fetch(`/cms/admin/media/${e}/url`,{headers:t?{Authorization:`Bearer ${t}`}:{}}).then(e=>e.ok?e.json():null).then(e=>n(e?.url??null)).catch(()=>{})},[e]),t?/\.(jpe?g|png|gif|webp|avif|svg)(\?|$)/i.test(t)?(0,U.jsx)(`img`,{src:t,alt:``,className:`size-8 object-cover`}):(0,U.jsxs)(`span`,{className:`flex items-center gap-1.5 text-muted-foreground text-xs`,children:[(0,U.jsx)(ao,{className:`size-3.5 shrink-0`}),(0,U.jsx)(`span`,{className:`truncate max-w-30`,children:`File`})]}):(0,U.jsx)(_o,{className:`size-4 text-muted-foreground`})}function pk({field:e,value:t,displayField:n}){let{timezone:r}=ya();if(t==null||t===``)return(0,U.jsx)(`span`,{className:`text-muted-foreground`,children:`—`});if(e.type===`boolean`)return t?(0,U.jsx)(za,{className:`size-4 text-primary`}):(0,U.jsx)(`span`,{className:`text-muted-foreground`,children:`—`});if(e.type===`datetime`)return(0,U.jsx)(`span`,{children:wy(String(t),r)});if(e.type===`number`)return(0,U.jsx)(`span`,{children:String(t)});if(e.type===`media`)return(0,U.jsx)(fk,{value:String(t)});if(e.type===`relation`)return(0,U.jsx)(sk,{relatedSlug:e.relatedSlug,value:t,displayField:n});if(e.type===`text`||e.type===`richtext`){let e=String(t);return(0,U.jsx)(`span`,{className:`text-muted-foreground truncate max-w-50 block`,children:e.length>60?e.slice(0,60)+`…`:e})}let i=String(t);return(0,U.jsx)(`span`,{className:e.type===`uid`?`font-mono text-xs text-muted-foreground truncate max-w-40 block`:`font-medium truncate max-w-50 block`,children:i.length>60?i.slice(0,60)+`…`:i})}function mk({entry:e}){let t=e._author_first_name,n=e._author_last_name,r=t||n?[t,n].filter(Boolean).join(` `):null,i=(0,U.jsx)(El,{avatarUrl:e._author_avatar_url,firstName:t,lastName:n,className:`size-7`,fallbackClassName:`text-[10px]`});return r?(0,U.jsxs)(Fv,{children:[(0,U.jsx)(Iv,{asChild:!0,children:i}),(0,U.jsx)(Lv,{children:r})]}):i}function hk({entry:e,fields:t}){let{timezone:n}=ya();if(e.status===`scheduled`)return(0,U.jsxs)(vw,{variant:`outline`,className:`border-blue-500 text-blue-600`,children:[(0,U.jsx)(Ia,{className:`size-3 mr-1`}),e.scheduled_for?Cy(e.scheduled_for,n):`Scheduled`]});if(e.status===`draft`)return(0,U.jsx)(vw,{variant:`outline`,children:`Draft`});if(e.status===`pending`)return e.review_rejected?(0,U.jsx)(vw,{variant:`destructive`,children:`Pending`}):(0,U.jsx)(vw,{className:`bg-amber-500 text-black hover:bg-amber-500`,children:`Pending`});if(e.status===`in_review`)return(0,U.jsx)(vw,{variant:`outline`,children:`In Review`});let r=(e,t)=>{if(t===`datetime`&&e&&typeof e==`string`){let t=/Z|[+-]\d{2}:\d{2}$/.test(e)?e:e+`Z`,n=new Date(t);return isNaN(n.getTime())?e:n.toISOString()}return e};return e.published_data!=null&&t.some(t=>t.name in e.published_data&&JSON.stringify(r(e[t.name],t.type))!==JSON.stringify(r(e.published_data[t.name],t.type)))?(0,U.jsx)(vw,{variant:`secondary`,children:`Published*`}):(0,U.jsx)(vw,{variant:`default`,children:`Published`})}function gk({open:e,onOpenChange:t,allFields:n,config:r,onApply:i}){let[a,o]=(0,v.useState)(r.visibleFields),[s,c]=(0,v.useState)(r.sort);(0,v.useEffect)(()=>{e&&(o(r.visibleFields),c(r.sort))},[e,r]);let l=n.filter(e=>!a.some(t=>t.split(`.`)[0]===e.name));function u({fieldName:e}){let t=e.split(`.`)[0],r=n.find(e=>e.name===t)?.relatedSlug,{data:i}=wa(r?`/cms/admin/content-types/${r}`:null),s=a.find(e=>e.split(`.`)[0]===t),c=s&&s.includes(`.`)?s.split(`.`)[1]:void 0;function l(e,t){o(n=>n.map(n=>n.split(`.`)[0]===e?t?`${e}.${t}`:e:n))}return(0,v.useEffect)(()=>{if(!i?.fields||c)return;let e=[`title`,`name`],n=i.fields.find(t=>e.includes(t.name))||i.fields[0];n&&l(t,n.name)},[i,c,t]),i?.fields?(0,U.jsxs)(Ow,{value:c,onValueChange:e=>l(t,e),children:[(0,U.jsx)(jw,{className:`h-8 text-sm w-32`,children:(0,U.jsx)(Aw,{})}),(0,U.jsx)(Pw,{children:i.fields.map(e=>(0,U.jsx)(Iw,{value:e.name,children:e.name},e.name))})]}):null}function d(e,t){o(n=>{let r=n.indexOf(e);if(r===-1)return n;let i=[...n],a=r+t;return a<0||a>=i.length?n:([i[r],i[a]]=[i[a],i[r]],i)})}function f(e){o(t=>[...t,e])}function p(e){o(t=>t.filter(t=>t!==e))}let m=[...rk,...n.filter(e=>![`media`,`text`,`richtext`,`relation`].includes(e.type)).map(e=>({name:e.name,label:ik(e.name)}))];return(0,U.jsx)(yw,{open:e,onOpenChange:t,children:(0,U.jsxs)(Cw,{className:`max-w-md h-[80vh] flex flex-col`,children:[(0,U.jsx)(ww,{className:`flex-none`,children:(0,U.jsx)(Ew,{children:`Configure the view`})}),(0,U.jsxs)(`div`,{className:`flex flex-col flex-1 min-h-0 gap-5 py-1`,children:[(0,U.jsxs)(`div`,{className:`flex flex-col flex-1 min-h-0`,children:[(0,U.jsx)(`p`,{className:`mb-2 text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:`Displayed fields`}),a.length===0?(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground py-2`,children:`No fields selected.`}):(0,U.jsx)(`ul`,{className:`space-y-1 overflow-y-auto flex-1 min-h-0`,children:a.map((e,t)=>{let r=String(e).split(`.`)[0],i=n.find(e=>e.name===r);return(0,U.jsxs)(`li`,{className:`flex items-center gap-2 rounded-md border px-3 py-2 text-sm`,children:[(0,U.jsx)(`span`,{className:`flex-1 font-medium`,children:ik(r)}),i&&(0,U.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:i.type}),i&&i.type===`relation`&&(0,U.jsx)(`div`,{className:`ml-2`,children:(0,U.jsx)(u,{fieldName:e})}),(0,U.jsx)(J,{size:`icon`,variant:`ghost`,disabled:t===0,onClick:()=>d(e,-1),className:`flex size-6 items-center justify-center rounded text-muted-foreground hover:bg-accent disabled:opacity-30`,children:(0,U.jsx)(Ua,{className:`size-3.5`})}),(0,U.jsx)(J,{size:`icon`,variant:`ghost`,disabled:t===a.length-1,onClick:()=>d(e,1),className:`flex size-6 items-center justify-center rounded text-muted-foreground hover:bg-accent disabled:opacity-30`,children:(0,U.jsx)(Ba,{className:`size-3.5`})}),(0,U.jsx)(J,{size:`icon`,variant:`ghost`,onClick:()=>p(e),className:`flex size-6 items-center justify-center rounded text-muted-foreground hover:bg-destructive/10 hover:text-destructive`,children:(0,U.jsx)(Ka,{className:`size-3.5`})})]},e)})})]}),l.length>0&&(0,U.jsxs)(`div`,{className:`flex flex-col flex-1 min-h-0`,children:[(0,U.jsx)(`p`,{className:`mb-2 text-xs font-medium text-muted-foreground uppercase tracking-wide flex-none`,children:`Available fields`}),(0,U.jsx)(`ul`,{className:`space-y-1 overflow-y-auto flex-1 min-h-0`,children:l.map(e=>(0,U.jsxs)(`li`,{className:`flex items-center gap-2 rounded-md border border-dashed px-3 py-2 text-sm text-muted-foreground`,children:[(0,U.jsx)(`span`,{className:`flex-1`,children:ik(e.name)}),(0,U.jsx)(`span`,{className:`text-xs`,children:e.type}),(0,U.jsx)(`button`,{type:`button`,onClick:()=>f(e.name),className:`flex size-6 items-center justify-center rounded text-muted-foreground hover:bg-accent hover:text-accent-foreground`,children:(0,U.jsx)(qa,{className:`size-3.5`})})]},e.name))})]}),(0,U.jsxs)(`div`,{className:`flex-none`,children:[(0,U.jsx)(`p`,{className:`mb-2 text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:`Sort entries`}),(0,U.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,U.jsxs)(Ow,{value:s.field,onValueChange:e=>c(t=>({...t,field:e})),children:[(0,U.jsx)(jw,{className:`h-8 text-sm`,children:(0,U.jsx)(Aw,{})}),(0,U.jsx)(Pw,{children:m.map(e=>(0,U.jsx)(Iw,{value:e.name,children:e.label},e.name))})]}),(0,U.jsxs)(Ow,{value:s.dir,onValueChange:e=>c(t=>({...t,dir:e})),children:[(0,U.jsx)(jw,{className:`h-8 text-sm`,children:(0,U.jsx)(Aw,{})}),(0,U.jsxs)(Pw,{children:[(0,U.jsx)(Iw,{value:`asc`,children:`Ascending`}),(0,U.jsx)(Iw,{value:`desc`,children:`Descending`})]})]})]})]})]}),(0,U.jsxs)(Tw,{className:`flex-none`,children:[(0,U.jsx)(J,{variant:`outline`,onClick:()=>t(!1),children:`Cancel`}),(0,U.jsx)(J,{onClick:()=>{i({visibleFields:a,sort:s}),t(!1)},children:`Apply`})]})]})})}function _k(){let{slug:e}=hr(),t=dr(),{timezone:n}=ya(),{user:r}=ga(),[i,a]=ea(),o=Math.max(1,Number(i.get(`page`)??1)),s=[10,30,50,70,100].includes(Number(i.get(`limit`)))?Number(i.get(`limit`)):10;function c(e){a(t=>(t.set(`page`,String(e)),t),{replace:!0})}function l(e){a(t=>(t.set(`limit`,String(e)),t.set(`page`,`1`),t),{replace:!0})}let[u,d]=(0,v.useState)(null),[f,p]=(0,v.useState)(!1),[m,h]=(0,v.useState)(null),[g,_]=(0,v.useState)(new Set),[y,b]=(0,v.useState)(!1),[x,S]=(0,v.useState)(!1),{loading:C,request:w}=Vv(),{data:T,loading:E}=wa(e?`/cms/admin/content-types/${e}`:null);(0,v.useEffect)(()=>{!T||!e||uk(e).then(e=>h(lk(e,T.fields))).catch(()=>h(ck(T.fields)))},[T?.slug]),(0,v.useEffect)(()=>{_(new Set)},[o,s]);let D=m??{visibleFields:T?.fields.slice(0,tk).map(e=>e.name)??[],sort:nk},{sort:O}=D,k=(D.visibleFields??[]).map(e=>{let t=String(e).split(`.`),n=t[0],r=t[1],i=T?.fields.find(e=>e.name===n);return i?{field:i,displayField:r}:null}).filter(Boolean),{data:A,loading:j,refetch:M}=wa(e&&m?`/cms/admin/content-types/${e}/entries?page=${o}&limit=${s}&sort=${O.field}&order=${O.dir}`:null);async function N(){!u||!e||(await w(`/cms/admin/entries/${e}/${u}`,`DELETE`),d(null),M())}let P=r?.permissions??[],F=P.includes(`*`)||P.includes(`entries:write`),I=P.includes(`*`)||P.includes(`entries:delete`),L=r?.role?.toLowerCase()===`viewer`,R=r?.role?.toLowerCase()===`contributor`,ee=r?.role?.toLowerCase()===`editor`,te=R||ee,z=e=>String(e.created_by??``)===String(r?.id??``),B=e=>!1,V=e=>F&&(!R||z(e))&&!B(e),ne=e=>I&&(!te||z(e)),H=[...g].filter(e=>{let t=(A?.data??[]).find(t=>t.id===e);return t?V(t):!1}),re=[...g].filter(e=>{let t=(A?.data??[]).find(t=>t.id===e);return t?ne(t):!1}),ie=(A?.data??[]).map(e=>e.id),ae=ie.length>0&&ie.every(e=>g.has(e)),oe=!ae&&ie.some(e=>g.has(e));function se(){_(e=>{let t=new Set(e);return ae?ie.forEach(e=>t.delete(e)):ie.forEach(e=>t.add(e)),t})}function ce(e){_(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}async function le(){if(!(!e||y)){b(!0);try{let t=localStorage.getItem(`plank_token`),n={"Content-Type":`application/json`,...t?{Authorization:`Bearer ${t}`}:{}};await Promise.all(H.map(t=>fetch(`/cms/admin/entries/${e}/${t}/status`,{method:`PATCH`,headers:n,body:JSON.stringify({status:`draft`})}))),_(new Set),M()}finally{b(!1)}}}async function ue(){if(!(!e||y)){b(!0);try{let t=localStorage.getItem(`plank_token`),n={...t?{Authorization:`Bearer ${t}`}:{}};await Promise.all(re.map(t=>fetch(`/cms/admin/entries/${e}/${t}`,{method:`DELETE`,headers:n}))),S(!1),_(new Set),M()}finally{b(!1)}}}function de(t){h(t),e&&dk(e,t).catch(()=>{}),c(1)}if(E||!m)return(0,U.jsxs)(`div`,{className:`flex items-center gap-2 py-12 text-muted-foreground`,children:[(0,U.jsx)(by,{className:`size-4`}),(0,U.jsx)(`span`,{className:`text-sm`,children:`Loading…`})]});if(!T)return null;let fe=Math.ceil((A?.total??0)/(A?.limit??20));return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(yy,{children:(0,U.jsxs)(`div`,{className:`mb-6 flex items-center justify-between gap-4`,children:[(0,U.jsx)(`h1`,{className:`text-2xl font-bold -mt-6`,children:T.name}),(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsxs)(J,{variant:`outline`,onClick:()=>p(!0),className:`gap-1.5`,children:[(0,U.jsx)(zo,{className:`size-3.5`}),`Configure the view`]}),F&&(0,U.jsxs)(J,{onClick:()=>t(`/content/${e}/new`),className:`gap-2`,children:[(0,U.jsx)(Po,{className:`size-4`}),`New entry`]})]})]})}),(0,U.jsxs)(`section`,{className:`mt-24`,children:[j&&(0,U.jsxs)(`div`,{className:`flex items-center gap-2 py-12 text-muted-foreground`,children:[(0,U.jsx)(by,{className:`size-4`}),(0,U.jsx)(`span`,{className:`text-sm`,children:`Loading entries…`})]}),!j&&(A?.data??[]).length===0&&(0,U.jsxs)(Xw,{className:`border`,children:[(0,U.jsxs)(Zw,{children:[(0,U.jsx)($w,{variant:`icon`,children:(0,U.jsx)(io,{})}),(0,U.jsx)(eT,{children:`No entries yet`}),(0,U.jsxs)(tT,{children:[`Create your first entry for `,T.name,`.`]})]}),(0,U.jsx)(nT,{children:F&&(0,U.jsx)(J,{onClick:()=>t(`/content/${e}/new`),children:`New entry`})})]}),!j&&(A?.data??[]).length>0&&(0,U.jsxs)(Pv,{children:[!L&&g.size>0&&(0,U.jsxs)(`div`,{className:`mb-3 flex items-center gap-3 rounded-lg border border-border bg-muted/50 px-4 py-2.5`,children:[(0,U.jsxs)(`span`,{className:`text-sm font-medium`,children:[g.size,` selected`]}),(0,U.jsxs)(`div`,{className:`flex items-center gap-2 ml-auto`,children:[(0,U.jsxs)(J,{variant:`outline`,size:`sm`,disabled:y||H.length===0,onClick:le,children:[y?(0,U.jsx)(by,{className:`size-3.5`}):null,`Unpublish`]}),I&&(0,U.jsxs)(J,{variant:`destructive`,size:`sm`,disabled:y||re.length===0,onClick:()=>S(!0),children:[(0,U.jsx)(qo,{className:`size-3.5`}),`Delete`]})]})]}),(0,U.jsx)(`div`,{className:`overflow-hidden rounded-lg border border-border`,children:(0,U.jsxs)(Rw,{className:`w-full`,children:[(0,U.jsx)(zw,{className:`border-b border-border font-bold uppercase`,children:(0,U.jsxs)(Vw,{className:`hover:bg-transparent`,children:[(0,U.jsx)(Hw,{className:`w-10 px-4 py-3`,children:!L&&(0,U.jsx)(EO,{checked:ae?!0:oe?`indeterminate`:!1,onCheckedChange:se,"aria-label":`Select all`})}),k.map(e=>(0,U.jsx)(Hw,{className:`px-4 py-3 text-left font-medium text-muted-foreground`,children:ik(e.field.name)},e.field.name)),(0,U.jsx)(Hw,{className:`px-4 py-3 text-left font-medium text-muted-foreground`,children:`Created`}),(0,U.jsx)(Hw,{className:`px-4 py-3 text-left font-medium text-muted-foreground`,children:`Updated`}),(0,U.jsx)(Hw,{className:`px-4 py-3 text-left font-medium text-muted-foreground`,children:`Pub / Sch`}),(0,U.jsx)(Hw,{className:`px-4 py-3 text-left font-medium text-muted-foreground`,children:`Status`}),(0,U.jsx)(Hw,{className:`px-4 py-3 text-left font-medium text-muted-foreground`,children:`Author`}),(0,U.jsx)(Hw,{className:`px-4 py-3`})]})}),(0,U.jsx)(Bw,{className:`divide-y divide-border`,children:(A?.data??[]).map(r=>(0,U.jsxs)(Vw,{className:`group transition-colors ${g.has(r.id)?`bg-muted/40`:`hover:bg-muted/30`} ${R&&!z(r)?`opacity-60`:``} ${B(r)?`opacity-60`:``}`,children:[(0,U.jsx)(Uw,{className:`w-10 px-4 py-3`,children:!L&&(0,U.jsx)(EO,{checked:g.has(r.id),onCheckedChange:()=>ce(r.id),"aria-label":`Select row`})}),k.map(e=>{let t=r[e.field.name],n=t;return e.field.type===`relation`?n=t:e.displayField&&(n=t&&typeof t==`object`?t[e.displayField]:t&&typeof t==`object`?t.title:t),(0,U.jsx)(Uw,{className:`px-4 py-3`,children:(0,U.jsx)(pk,{field:e.field,value:n,displayField:e.displayField})},e.field.name)}),(0,U.jsx)(Uw,{className:`px-4 py-3 text-muted-foreground whitespace-nowrap`,children:Cy(r.created_at,n)}),(0,U.jsx)(Uw,{className:`px-4 py-3 text-muted-foreground whitespace-nowrap`,children:Cy(r.updated_at,n)}),(0,U.jsx)(Uw,{className:`px-4 py-3 text-muted-foreground whitespace-nowrap`,children:r.status===`scheduled`&&r.scheduled_for?Cy(r.scheduled_for,n):r.published_at?Cy(r.published_at,n):`—`}),(0,U.jsx)(Uw,{className:`px-4 py-3`,children:(0,U.jsx)(hk,{entry:r,fields:T.fields})}),(0,U.jsx)(Uw,{className:`px-4 py-3`,children:(0,U.jsx)(mk,{entry:r})}),(0,U.jsx)(Uw,{className:`px-4 py-3`,children:(0,U.jsx)(`div`,{className:`flex items-center justify-end gap-1`,children:L?(0,U.jsx)(J,{size:`icon`,variant:`ghost`,onClick:()=>t(`/content/${e}/${r.id}`),className:`flex size-8 items-center justify-center rounded text-muted-foreground hover:bg-accent hover:text-accent-foreground`,children:(0,U.jsx)(to,{className:`size-3.5`})}):(0,U.jsxs)(U.Fragment,{children:[V(r)&&(0,U.jsx)(J,{size:`icon`,variant:`ghost`,onClick:()=>t(`/content/${e}/${r.id}`),className:`flex size-8 items-center justify-center rounded text-muted-foreground hover:bg-accent hover:text-accent-foreground`,children:(0,U.jsx)(No,{className:`size-3.5`})}),ne(r)&&(0,U.jsx)(J,{size:`icon`,variant:`ghost`,onClick:()=>d(r.id),className:`flex size-8 items-center justify-center rounded text-destructive hover:bg-destructive/10 hover:text-destructive`,children:(0,U.jsx)(qo,{className:`size-3.5`})})]})})})]},r.id))})]})}),(0,U.jsx)(`div`,{className:`mt-4`,children:(0,U.jsx)(ek,{page:o,totalPages:fe,limit:s,onPageChange:c,onLimitChange:l})})]}),m&&(0,U.jsx)(gk,{open:f,onOpenChange:p,allFields:T.fields,config:m,onApply:de}),(0,U.jsx)(yw,{open:!!u,onOpenChange:e=>{e||d(null)},children:(0,U.jsxs)(Cw,{className:`max-w-sm`,children:[(0,U.jsx)(ww,{children:(0,U.jsx)(Ew,{children:`Delete entry?`})}),(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`This action cannot be undone.`}),(0,U.jsxs)(Tw,{children:[(0,U.jsx)(J,{variant:`outline`,onClick:()=>d(null),children:`Cancel`}),(0,U.jsxs)(J,{variant:`destructive`,onClick:N,disabled:C,children:[C?(0,U.jsx)(by,{className:`size-4`}):null,`Delete`]})]})]})}),(0,U.jsx)(yw,{open:x,onOpenChange:e=>{e||S(!1)},children:(0,U.jsxs)(Cw,{className:`max-w-sm`,children:[(0,U.jsx)(ww,{children:(0,U.jsxs)(Ew,{children:[`Delete `,g.size,` `,g.size===1?`entry`:`entries`,`?`]})}),(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`This action cannot be undone.`}),(0,U.jsxs)(Tw,{children:[(0,U.jsx)(J,{variant:`outline`,onClick:()=>S(!1),children:`Cancel`}),(0,U.jsxs)(J,{variant:`destructive`,onClick:ue,disabled:y,children:[y?(0,U.jsx)(by,{className:`size-4`}):null,`Delete`]})]})]})})]})]})}function vk(){let{slug:e}=hr(),t=dr(),{user:n}=ga(),{data:r,loading:i}=wa(e?`/cms/admin/content-types/${e}`:null),a=r?.kind===`single`,{data:o,loading:s,error:c}=wa(a&&e?`/cms/admin/content-types/${e}/single`:null);return(0,v.useEffect)(()=>{if(!a||s)return;let r=n?.permissions??[],i=r.includes(`*`)||r.includes(`entries:write`);o?t(`/content/${e}/${o.id}`,{replace:!0}):c&&i&&t(`/content/${e}/new`,{replace:!0})},[a,s,o,c,e,t,n?.permissions]),i||a&&s?(0,U.jsxs)(`div`,{className:`flex items-center gap-2 py-12 text-muted-foreground`,children:[(0,U.jsx)(by,{className:`size-4`}),(0,U.jsx)(`span`,{className:`text-sm`,children:`Loading…`})]}):a?o?null:(0,U.jsx)(`div`,{className:`py-12 text-sm text-muted-foreground`,children:`No entry is available for this Single Type.`}):(0,U.jsx)(_k,{})}var yk=365.2425,bk=6048e5,xk=864e5,Sk=3600*24;Sk*7,Sk*yk/12*3;var Ck=Symbol.for(`constructDateFrom`);function wk(e,t){return typeof e==`function`?e(t):e&&typeof e==`object`&&Ck in e?e[Ck](t):e instanceof Date?new e.constructor(t):new Date(t)}function Tk(e,t){return wk(t||e,e)}function Ek(e,t,n){let r=Tk(e,n?.in);return isNaN(t)?wk(n?.in||e,NaN):(t&&r.setDate(r.getDate()+t),r)}function Dk(e,t,n){let r=Tk(e,n?.in);if(isNaN(t))return wk(n?.in||e,NaN);if(!t)return r;let i=r.getDate(),a=wk(n?.in||e,r.getTime());return a.setMonth(r.getMonth()+t+1,0),i>=a.getDate()?a:(r.setFullYear(a.getFullYear(),a.getMonth(),i),r)}var Ok={};function kk(){return Ok}function Ak(e,t){let n=kk(),r=t?.weekStartsOn??t?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,i=Tk(e,t?.in),a=i.getDay(),o=(a<r?7:0)+a-r;return i.setDate(i.getDate()-o),i.setHours(0,0,0,0),i}function jk(e,t){return Ak(e,{...t,weekStartsOn:1})}function Mk(e,t){let n=Tk(e,t?.in),r=n.getFullYear(),i=wk(n,0);i.setFullYear(r+1,0,4),i.setHours(0,0,0,0);let a=jk(i),o=wk(n,0);o.setFullYear(r,0,4),o.setHours(0,0,0,0);let s=jk(o);return n.getTime()>=a.getTime()?r+1:n.getTime()>=s.getTime()?r:r-1}function Nk(e){let t=Tk(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 Pk(e,...t){let n=wk.bind(null,e||t.find(e=>typeof e==`object`));return t.map(n)}function Fk(e,t){let n=Tk(e,t?.in);return n.setHours(0,0,0,0),n}function Ik(e,t,n){let[r,i]=Pk(n?.in,e,t),a=Fk(r),o=Fk(i),s=+a-Nk(a),c=+o-Nk(o);return Math.round((s-c)/xk)}function Lk(e,t){let n=Mk(e,t),r=wk(t?.in||e,0);return r.setFullYear(n,0,4),r.setHours(0,0,0,0),jk(r)}function Rk(e,t,n){return Ek(e,t*7,n)}function zk(e,t,n){return Dk(e,t*12,n)}function Bk(e,t){let n,r=t?.in;return e.forEach(e=>{!r&&typeof e==`object`&&(r=wk.bind(null,e));let t=Tk(e,r);(!n||n<t||isNaN(+t))&&(n=t)}),wk(r,n||NaN)}function Vk(e,t){let n,r=t?.in;return e.forEach(e=>{!r&&typeof e==`object`&&(r=wk.bind(null,e));let t=Tk(e,r);(!n||n>t||isNaN(+t))&&(n=t)}),wk(r,n||NaN)}function Hk(e,t,n){let[r,i]=Pk(n?.in,e,t);return+Fk(r)==+Fk(i)}function Uk(e){return e instanceof Date||typeof e==`object`&&Object.prototype.toString.call(e)===`[object Date]`}function Wk(e){return!(!Uk(e)&&typeof e!=`number`||isNaN(+Tk(e)))}function Gk(e,t,n){let[r,i]=Pk(n?.in,e,t),a=r.getFullYear()-i.getFullYear(),o=r.getMonth()-i.getMonth();return a*12+o}function Kk(e,t){let n=Tk(e,t?.in),r=n.getMonth();return n.setFullYear(n.getFullYear(),r+1,0),n.setHours(23,59,59,999),n}function qk(e,t){let[n,r]=Pk(e,t.start,t.end);return{start:n,end:r}}function Jk(e,t){let{start:n,end:r}=qk(t?.in,e),i=+n>+r,a=i?+n:+r,o=i?r:n;o.setHours(0,0,0,0),o.setDate(1);let s=t?.step??1;if(!s)return[];s<0&&(s=-s,i=!i);let c=[];for(;+o<=a;)c.push(wk(n,o)),o.setMonth(o.getMonth()+s);return i?c.reverse():c}function Yk(e,t){let n=Tk(e,t?.in);return n.setDate(1),n.setHours(0,0,0,0),n}function Xk(e,t){let n=Tk(e,t?.in),r=n.getFullYear();return n.setFullYear(r+1,0,0),n.setHours(23,59,59,999),n}function Zk(e,t){let n=Tk(e,t?.in);return n.setFullYear(n.getFullYear(),0,1),n.setHours(0,0,0,0),n}function Qk(e,t){let{start:n,end:r}=qk(t?.in,e),i=+n>+r,a=i?+n:+r,o=i?r:n;o.setHours(0,0,0,0),o.setMonth(0,1);let s=t?.step??1;if(!s)return[];s<0&&(s=-s,i=!i);let c=[];for(;+o<=a;)c.push(wk(n,o)),o.setFullYear(o.getFullYear()+s);return i?c.reverse():c}function $k(e,t){let n=kk(),r=t?.weekStartsOn??t?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,i=Tk(e,t?.in),a=i.getDay(),o=(a<r?-7:0)+6-(a-r);return i.setDate(i.getDate()+o),i.setHours(23,59,59,999),i}function eA(e,t){return $k(e,{...t,weekStartsOn:1})}var tA={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`}},nA=(e,t,n)=>{let r,i=tA[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 rA(e){return(t={})=>{let n=t.width?String(t.width):e.defaultWidth;return e.formats[n]||e.formats[e.defaultWidth]}}var iA={date:rA({formats:{full:`EEEE, MMMM do, y`,long:`MMMM do, y`,medium:`MMM d, y`,short:`MM/dd/yyyy`},defaultWidth:`full`}),time:rA({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:rA({formats:{full:`{{date}} 'at' {{time}}`,long:`{{date}} 'at' {{time}}`,medium:`{{date}}, {{time}}`,short:`{{date}}, {{time}}`},defaultWidth:`full`})},aA={lastWeek:`'last' eeee 'at' p`,yesterday:`'yesterday at' p`,today:`'today at' p`,tomorrow:`'tomorrow at' p`,nextWeek:`eeee 'at' p`,other:`P`},oA=(e,t,n,r)=>aA[e];function sA(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 cA={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:sA({values:{narrow:[`B`,`A`],abbreviated:[`BC`,`AD`],wide:[`Before Christ`,`Anno Domini`]},defaultWidth:`wide`}),quarter:sA({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:sA({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:sA({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:sA({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 lA(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)?dA(s,e=>e.test(o)):uA(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 uA(e,t){for(let n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&t(e[n]))return n}function dA(e,t){for(let n=0;n<e.length;n++)if(t(e[n]))return n}function fA(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 pA={code:`en-US`,formatDistance:nA,formatLong:iA,formatRelative:oA,localize:cA,match:{ordinalNumber:fA({matchPattern:/^(\d+)(th|st|nd|rd)?/i,parsePattern:/\d+/i,valueCallback:e=>parseInt(e,10)}),era:lA({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:lA({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:lA({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:lA({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:lA({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 mA(e,t){let n=Tk(e,t?.in);return Ik(n,Zk(n))+1}function hA(e,t){let n=Tk(e,t?.in),r=jk(n)-+Lk(n);return Math.round(r/bk)+1}function gA(e,t){let n=Tk(e,t?.in),r=n.getFullYear(),i=kk(),a=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??i.firstWeekContainsDate??i.locale?.options?.firstWeekContainsDate??1,o=wk(t?.in||e,0);o.setFullYear(r+1,0,a),o.setHours(0,0,0,0);let s=Ak(o,t),c=wk(t?.in||e,0);c.setFullYear(r,0,a),c.setHours(0,0,0,0);let l=Ak(c,t);return+n>=+s?r+1:+n>=+l?r:r-1}function _A(e,t){let n=kk(),r=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??n.firstWeekContainsDate??n.locale?.options?.firstWeekContainsDate??1,i=gA(e,t),a=wk(t?.in||e,0);return a.setFullYear(i,0,r),a.setHours(0,0,0,0),Ak(a,t)}function vA(e,t){let n=Tk(e,t?.in),r=Ak(n,t)-+_A(n,t);return Math.round(r/bk)+1}function yA(e,t){return(e<0?`-`:``)+Math.abs(e).toString().padStart(t,`0`)}var bA={y(e,t){let n=e.getFullYear(),r=n>0?n:1-n;return yA(t===`yy`?r%100:r,t.length)},M(e,t){let n=e.getMonth();return t===`M`?String(n+1):yA(n+1,2)},d(e,t){return yA(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 yA(e.getHours()%12||12,t.length)},H(e,t){return yA(e.getHours(),t.length)},m(e,t){return yA(e.getMinutes(),t.length)},s(e,t){return yA(e.getSeconds(),t.length)},S(e,t){let n=t.length,r=e.getMilliseconds();return yA(Math.trunc(r*10**(n-3)),t.length)}},xA={am:`am`,pm:`pm`,midnight:`midnight`,noon:`noon`,morning:`morning`,afternoon:`afternoon`,evening:`evening`,night:`night`},SA={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 bA.y(e,t)},Y:function(e,t,n,r){let i=gA(e,r),a=i>0?i:1-i;return t===`YY`?yA(a%100,2):t===`Yo`?n.ordinalNumber(a,{unit:`year`}):yA(a,t.length)},R:function(e,t){return yA(Mk(e),t.length)},u:function(e,t){return yA(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 yA(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 yA(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 bA.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 yA(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=vA(e,r);return t===`wo`?n.ordinalNumber(i,{unit:`week`}):yA(i,t.length)},I:function(e,t,n){let r=hA(e);return t===`Io`?n.ordinalNumber(r,{unit:`week`}):yA(r,t.length)},d:function(e,t,n){return t===`do`?n.ordinalNumber(e.getDate(),{unit:`date`}):bA.d(e,t)},D:function(e,t,n){let r=mA(e);return t===`Do`?n.ordinalNumber(r,{unit:`dayOfYear`}):yA(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 yA(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 yA(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 yA(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?xA.noon:r===0?xA.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?xA.evening:r>=12?xA.afternoon:r>=4?xA.morning:xA.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 bA.h(e,t)},H:function(e,t,n){return t===`Ho`?n.ordinalNumber(e.getHours(),{unit:`hour`}):bA.H(e,t)},K:function(e,t,n){let r=e.getHours()%12;return t===`Ko`?n.ordinalNumber(r,{unit:`hour`}):yA(r,t.length)},k:function(e,t,n){let r=e.getHours();return r===0&&(r=24),t===`ko`?n.ordinalNumber(r,{unit:`hour`}):yA(r,t.length)},m:function(e,t,n){return t===`mo`?n.ordinalNumber(e.getMinutes(),{unit:`minute`}):bA.m(e,t)},s:function(e,t,n){return t===`so`?n.ordinalNumber(e.getSeconds(),{unit:`second`}):bA.s(e,t)},S:function(e,t){return bA.S(e,t)},X:function(e,t,n){let r=e.getTimezoneOffset();if(r===0)return`Z`;switch(t){case`X`:return wA(r);case`XXXX`:case`XX`:return TA(r);default:return TA(r,`:`)}},x:function(e,t,n){let r=e.getTimezoneOffset();switch(t){case`x`:return wA(r);case`xxxx`:case`xx`:return TA(r);default:return TA(r,`:`)}},O:function(e,t,n){let r=e.getTimezoneOffset();switch(t){case`O`:case`OO`:case`OOO`:return`GMT`+CA(r,`:`);default:return`GMT`+TA(r,`:`)}},z:function(e,t,n){let r=e.getTimezoneOffset();switch(t){case`z`:case`zz`:case`zzz`:return`GMT`+CA(r,`:`);default:return`GMT`+TA(r,`:`)}},t:function(e,t,n){return yA(Math.trunc(e/1e3),t.length)},T:function(e,t,n){return yA(+e,t.length)}};function CA(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+yA(a,2)}function wA(e,t){return e%60==0?(e>0?`-`:`+`)+yA(Math.abs(e)/60,2):TA(e,t)}function TA(e,t=``){let n=e>0?`-`:`+`,r=Math.abs(e),i=yA(Math.trunc(r/60),2),a=yA(r%60,2);return n+i+t+a}var EA=(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`})}},DA=(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`})}},OA={p:DA,P:(e,t)=>{let n=e.match(/(P+)(p+)?/)||[],r=n[1],i=n[2];if(!i)return EA(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}}`,EA(r,t)).replace(`{{time}}`,DA(i,t))}},kA=/^D+$/,AA=/^Y+$/,jA=[`D`,`DD`,`YY`,`YYYY`];function MA(e){return kA.test(e)}function NA(e){return AA.test(e)}function PA(e,t,n){let r=FA(e,t,n);if(console.warn(r),jA.includes(e))throw RangeError(r)}function FA(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 IA=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,LA=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,RA=/^'([^]*?)'?$/,zA=/''/g,BA=/[a-zA-Z]/;function VA(e,t,n){let r=kk(),i=n?.locale??r.locale??pA,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=Tk(e,n?.in);if(!Wk(s))throw RangeError(`Invalid time value`);let c=t.match(LA).map(e=>{let t=e[0];if(t===`p`||t===`P`){let n=OA[t];return n(e,i.formatLong)}return e}).join(``).match(IA).map(e=>{if(e===`''`)return{isToken:!1,value:`'`};let t=e[0];if(t===`'`)return{isToken:!1,value:HA(e)};if(SA[t])return{isToken:!0,value:e};if(t.match(BA))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&&NA(a)||!n?.useAdditionalDayOfYearTokens&&MA(a))&&PA(a,t,String(e));let o=SA[a[0]];return o(s,a,i.localize,l)}).join(``)}function HA(e){let t=e.match(RA);return t?t[1].replace(zA,`'`):e}function UA(e,t){let n=Tk(e,t?.in),r=n.getFullYear(),i=n.getMonth(),a=wk(n,0);return a.setFullYear(r,i+1,0),a.setHours(0,0,0,0),a.getDate()}function WA(e,t){return Tk(e,t?.in).getMonth()}function GA(e,t){return Tk(e,t?.in).getFullYear()}function KA(e,t){return+Tk(e)>+Tk(t)}function qA(e,t){return+Tk(e)<+Tk(t)}function JA(e,t,n){let[r,i]=Pk(n?.in,e,t);return r.getFullYear()===i.getFullYear()&&r.getMonth()===i.getMonth()}function YA(e,t,n){let[r,i]=Pk(n?.in,e,t);return r.getFullYear()===i.getFullYear()}function XA(e,t,n){let r=Tk(e,n?.in),i=r.getFullYear(),a=r.getDate(),o=wk(n?.in||e,0);o.setFullYear(i,t,15),o.setHours(0,0,0,0);let s=UA(o);return r.setMonth(t,Math.min(a,s)),r}function ZA(e,t,n){let r=Tk(e,n?.in);return isNaN(+r)?wk(n?.in||e,NaN):(r.setFullYear(t),r)}function QA({className:e,...t}){return(0,U.jsx)(pw,{"data-slot":`tabs`,className:q(`flex flex-col gap-2`,e),...t})}function $A({className:e,...t}){return(0,U.jsx)(mw,{"data-slot":`tabs-list`,className:q(`inline-flex h-9 items-center justify-start rounded-lg bg-muted p-1 text-muted-foreground w-full`,e),...t})}function ej({className:e,...t}){return(0,U.jsx)(hw,{"data-slot":`tabs-trigger`,className:q(`inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow`,e),...t})}function tj({className:e,...t}){return(0,U.jsx)(gw,{"data-slot":`tabs-content`,className:q(`flex-1 outline-none`,e),...t})}function nj({className:e,...t}){return(0,U.jsx)(XC,{"data-slot":`switch`,className:q(`peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input`,e),...t,children:(0,U.jsx)(ZC,{className:q(`pointer-events-none block size-4 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0`)})})}function rj(e,t,n=`long`){return new Intl.DateTimeFormat(`en-US`,{hour:`numeric`,timeZone:e,timeZoneName:n}).format(t).split(/\s/g).slice(2).join(` `)}var ij={},aj={};function oj(e,t){try{let n=(ij[e]||=new Intl.DateTimeFormat(`en-US`,{timeZone:e,timeZoneName:`longOffset`}).format)(t).split(`GMT`)[1];return n in aj?aj[n]:cj(n,n.split(`:`))}catch{if(e in aj)return aj[e];let t=e?.match(sj);return t?cj(e,t.slice(1)):NaN}}var sj=/([+-]\d\d):?(\d\d)?/;function cj(e,t){let n=+(t[0]||0),r=+(t[1]||0),i=(t[2]||0)/60;return aj[e]=n*60+r>0?n*60+r+i:n*60-r-i}var lj=class e extends Date{constructor(...e){super(),e.length>1&&typeof e[e.length-1]==`string`&&(this.timeZone=e.pop()),this.internal=new Date,isNaN(oj(this.timeZone,this))?this.setTime(NaN):e.length?typeof e[0]==`number`&&(e.length===1||e.length===2&&typeof e[1]!=`number`)?this.setTime(e[0]):typeof e[0]==`string`?this.setTime(+new Date(e[0])):e[0]instanceof Date?this.setTime(+e[0]):(this.setTime(+new Date(...e)),pj(this,NaN),dj(this)):this.setTime(Date.now())}static tz(t,...n){return n.length?new e(...n,t):new e(Date.now(),t)}withTimeZone(t){return new e(+this,t)}getTimezoneOffset(){let e=-oj(this.timeZone,this);return e>0?Math.floor(e):Math.ceil(e)}setTime(e){return Date.prototype.setTime.apply(this,arguments),dj(this),+this}[Symbol.for(`constructDateFrom`)](t){return new e(+new Date(t),this.timeZone)}},uj=/^(get|set)(?!UTC)/;Object.getOwnPropertyNames(Date.prototype).forEach(e=>{if(!uj.test(e))return;let t=e.replace(uj,`$1UTC`);lj.prototype[t]&&(e.startsWith(`get`)?lj.prototype[e]=function(){return this.internal[t]()}:(lj.prototype[e]=function(){return Date.prototype[t].apply(this.internal,arguments),fj(this),+this},lj.prototype[t]=function(){return Date.prototype[t].apply(this,arguments),dj(this),+this}))});function dj(e){e.internal.setTime(+e),e.internal.setUTCSeconds(e.internal.getUTCSeconds()-Math.round(-oj(e.timeZone,e)*60))}function fj(e){Date.prototype.setFullYear.call(e,e.internal.getUTCFullYear(),e.internal.getUTCMonth(),e.internal.getUTCDate()),Date.prototype.setHours.call(e,e.internal.getUTCHours(),e.internal.getUTCMinutes(),e.internal.getUTCSeconds(),e.internal.getUTCMilliseconds()),pj(e)}function pj(e){let t=oj(e.timeZone,e),n=t>0?Math.floor(t):Math.ceil(t),r=new Date(+e);r.setUTCHours(r.getUTCHours()-1);let i=-new Date(+e).getTimezoneOffset(),a=i- -new Date(+r).getTimezoneOffset(),o=Date.prototype.getHours.apply(e)!==e.internal.getUTCHours();a&&o&&e.internal.setUTCMinutes(e.internal.getUTCMinutes()+a);let s=i-n;s&&Date.prototype.setUTCMinutes.call(e,Date.prototype.getUTCMinutes.call(e)+s);let c=new Date(+e);c.setUTCSeconds(0);let l=i>0?c.getSeconds():(c.getSeconds()-60)%60,u=Math.round(-(oj(e.timeZone,e)*60))%60;(u||l)&&(e.internal.setUTCSeconds(e.internal.getUTCSeconds()+u),Date.prototype.setUTCSeconds.call(e,Date.prototype.getUTCSeconds.call(e)+u+l));let d=oj(e.timeZone,e),f=d>0?Math.floor(d):Math.ceil(d),p=-new Date(+e).getTimezoneOffset()-f,m=f!==n,h=p-s;if(m&&h){Date.prototype.setUTCMinutes.call(e,Date.prototype.getUTCMinutes.call(e)+h);let t=oj(e.timeZone,e),n=f-(t>0?Math.floor(t):Math.ceil(t));n&&(e.internal.setUTCMinutes(e.internal.getUTCMinutes()+n),Date.prototype.setUTCMinutes.call(e,Date.prototype.getUTCMinutes.call(e)+n))}}var mj=class e extends lj{static tz(t,...n){return n.length?new e(...n,t):new e(Date.now(),t)}toISOString(){let[e,t,n]=this.tzComponents(),r=`${e}${t}:${n}`;return this.internal.toISOString().slice(0,-1)+r}toString(){return`${this.toDateString()} ${this.toTimeString()}`}toDateString(){let[e,t,n,r]=this.internal.toUTCString().split(` `);return`${e?.slice(0,-1)} ${n} ${t} ${r}`}toTimeString(){let e=this.internal.toUTCString().split(` `)[4],[t,n,r]=this.tzComponents();return`${e} GMT${t}${n}${r} (${rj(this.timeZone,this)})`}toLocaleString(e,t){return Date.prototype.toLocaleString.call(this,e,{...t,timeZone:t?.timeZone||this.timeZone})}toLocaleDateString(e,t){return Date.prototype.toLocaleDateString.call(this,e,{...t,timeZone:t?.timeZone||this.timeZone})}toLocaleTimeString(e,t){return Date.prototype.toLocaleTimeString.call(this,e,{...t,timeZone:t?.timeZone||this.timeZone})}tzComponents(){let e=this.getTimezoneOffset();return[e>0?`-`:`+`,String(Math.floor(Math.abs(e)/60)).padStart(2,`0`),String(Math.abs(e)%60).padStart(2,`0`)]}withTimeZone(t){return new e(+this,t)}[Symbol.for(`constructDateFrom`)](t){return new e(+new Date(t),this.timeZone)}},hj=5,gj=4;function _j(e,t){let n=t.startOfMonth(e),r=n.getDay()>0?n.getDay():7,i=t.addDays(e,-r+1),a=t.addDays(i,hj*7-1);return t.getMonth(e)===t.getMonth(a)?hj:gj}function vj(e,t){let n=t.startOfMonth(e),r=n.getDay();return r===1?n:r===0?t.addDays(n,-6):t.addDays(n,-1*(r-1))}function yj(e,t){let n=vj(e,t),r=_j(e,t);return t.addDays(n,r*7-1)}var bj={...pA,labels:{labelDayButton:(e,t,n,r)=>{let i;i=r&&typeof r.format==`function`?r.format.bind(r):(e,t)=>VA(e,t,{locale:pA,...n});let a=i(e,`PPPP`);return t.today&&(a=`Today, ${a}`),t.selected&&(a=`${a}, selected`),a},labelMonthDropdown:`Choose the Month`,labelNext:`Go to the Next Month`,labelPrevious:`Go to the Previous Month`,labelWeekNumber:e=>`Week ${e}`,labelYearDropdown:`Choose the Year`,labelGrid:(e,t,n)=>{let r;return r=n&&typeof n.format==`function`?n.format.bind(n):(e,n)=>VA(e,n,{locale:pA,...t}),r(e,`LLLL yyyy`)},labelGridcell:(e,t,n,r)=>{let i;i=r&&typeof r.format==`function`?r.format.bind(r):(e,t)=>VA(e,t,{locale:pA,...n});let a=i(e,`PPPP`);return t?.today&&(a=`Today, ${a}`),a},labelNav:`Navigation bar`,labelWeekNumberHeader:`Week Number`,labelWeekday:(e,t,n)=>{let r;return r=n&&typeof n.format==`function`?n.format.bind(n):(e,n)=>VA(e,n,{locale:pA,...t}),r(e,`cccc`)}}},xj=class e{constructor(e,t){this.Date=Date,this.today=()=>this.overrides?.today?this.overrides.today():this.options.timeZone?mj.tz(this.options.timeZone):new this.Date,this.newDate=(e,t,n)=>this.overrides?.newDate?this.overrides.newDate(e,t,n):this.options.timeZone?new mj(e,t,n,this.options.timeZone):new Date(e,t,n),this.addDays=(e,t)=>this.overrides?.addDays?this.overrides.addDays(e,t):Ek(e,t),this.addMonths=(e,t)=>this.overrides?.addMonths?this.overrides.addMonths(e,t):Dk(e,t),this.addWeeks=(e,t)=>this.overrides?.addWeeks?this.overrides.addWeeks(e,t):Rk(e,t),this.addYears=(e,t)=>this.overrides?.addYears?this.overrides.addYears(e,t):zk(e,t),this.differenceInCalendarDays=(e,t)=>this.overrides?.differenceInCalendarDays?this.overrides.differenceInCalendarDays(e,t):Ik(e,t),this.differenceInCalendarMonths=(e,t)=>this.overrides?.differenceInCalendarMonths?this.overrides.differenceInCalendarMonths(e,t):Gk(e,t),this.eachMonthOfInterval=e=>this.overrides?.eachMonthOfInterval?this.overrides.eachMonthOfInterval(e):Jk(e),this.eachYearOfInterval=e=>{let t=this.overrides?.eachYearOfInterval?this.overrides.eachYearOfInterval(e):Qk(e),n=new Set(t.map(e=>this.getYear(e)));if(n.size===t.length)return t;let r=[];return n.forEach(e=>{r.push(new Date(e,0,1))}),r},this.endOfBroadcastWeek=e=>this.overrides?.endOfBroadcastWeek?this.overrides.endOfBroadcastWeek(e):yj(e,this),this.endOfISOWeek=e=>this.overrides?.endOfISOWeek?this.overrides.endOfISOWeek(e):eA(e),this.endOfMonth=e=>this.overrides?.endOfMonth?this.overrides.endOfMonth(e):Kk(e),this.endOfWeek=(e,t)=>this.overrides?.endOfWeek?this.overrides.endOfWeek(e,t):$k(e,this.options),this.endOfYear=e=>this.overrides?.endOfYear?this.overrides.endOfYear(e):Xk(e),this.format=(e,t,n)=>{let r=this.overrides?.format?this.overrides.format(e,t,this.options):VA(e,t,this.options);return this.options.numerals&&this.options.numerals!==`latn`?this.replaceDigits(r):r},this.getISOWeek=e=>this.overrides?.getISOWeek?this.overrides.getISOWeek(e):hA(e),this.getMonth=(e,t)=>this.overrides?.getMonth?this.overrides.getMonth(e,this.options):WA(e,this.options),this.getYear=(e,t)=>this.overrides?.getYear?this.overrides.getYear(e,this.options):GA(e,this.options),this.getWeek=(e,t)=>this.overrides?.getWeek?this.overrides.getWeek(e,this.options):vA(e,this.options),this.isAfter=(e,t)=>this.overrides?.isAfter?this.overrides.isAfter(e,t):KA(e,t),this.isBefore=(e,t)=>this.overrides?.isBefore?this.overrides.isBefore(e,t):qA(e,t),this.isDate=e=>this.overrides?.isDate?this.overrides.isDate(e):Uk(e),this.isSameDay=(e,t)=>this.overrides?.isSameDay?this.overrides.isSameDay(e,t):Hk(e,t),this.isSameMonth=(e,t)=>this.overrides?.isSameMonth?this.overrides.isSameMonth(e,t):JA(e,t),this.isSameYear=(e,t)=>this.overrides?.isSameYear?this.overrides.isSameYear(e,t):YA(e,t),this.max=e=>this.overrides?.max?this.overrides.max(e):Bk(e),this.min=e=>this.overrides?.min?this.overrides.min(e):Vk(e),this.setMonth=(e,t)=>this.overrides?.setMonth?this.overrides.setMonth(e,t):XA(e,t),this.setYear=(e,t)=>this.overrides?.setYear?this.overrides.setYear(e,t):ZA(e,t),this.startOfBroadcastWeek=(e,t)=>this.overrides?.startOfBroadcastWeek?this.overrides.startOfBroadcastWeek(e,this):vj(e,this),this.startOfDay=e=>this.overrides?.startOfDay?this.overrides.startOfDay(e):Fk(e),this.startOfISOWeek=e=>this.overrides?.startOfISOWeek?this.overrides.startOfISOWeek(e):jk(e),this.startOfMonth=e=>this.overrides?.startOfMonth?this.overrides.startOfMonth(e):Yk(e),this.startOfWeek=(e,t)=>this.overrides?.startOfWeek?this.overrides.startOfWeek(e,this.options):Ak(e,this.options),this.startOfYear=e=>this.overrides?.startOfYear?this.overrides.startOfYear(e):Zk(e),this.options={locale:bj,...e},this.overrides=t}getDigitMap(){let{numerals:e=`latn`}=this.options,t=new Intl.NumberFormat(`en-US`,{numberingSystem:e}),n={};for(let e=0;e<10;e++)n[e.toString()]=t.format(e);return n}replaceDigits(e){let t=this.getDigitMap();return e.replace(/\d/g,e=>t[e]||e)}formatNumber(e){return this.replaceDigits(e.toString())}getMonthYearOrder(){let t=this.options.locale?.code;return t&&e.yearFirstLocales.has(t)?`year-first`:`month-first`}formatMonthYear(t){let{locale:n,timeZone:r,numerals:i}=this.options,a=n?.code;if(a&&e.yearFirstLocales.has(a))try{return new Intl.DateTimeFormat(a,{month:`long`,year:`numeric`,timeZone:r,numberingSystem:i}).format(t)}catch{}let o=this.getMonthYearOrder()===`year-first`?`y LLLL`:`LLLL y`;return this.format(t,o)}};xj.yearFirstLocales=new Set([`eu`,`hu`,`ja`,`ja-Hira`,`ja-JP`,`ko`,`ko-KR`,`lt`,`lt-LT`,`lv`,`lv-LV`,`mn`,`mn-MN`,`zh`,`zh-CN`,`zh-HK`,`zh-TW`]);var Sj=new xj,Cj=class{constructor(e,t,n=Sj){this.date=e,this.displayMonth=t,this.outside=!!(t&&!n.isSameMonth(e,t)),this.dateLib=n,this.isoDate=n.format(e,`yyyy-MM-dd`),this.displayMonthId=n.format(t,`yyyy-MM`),this.dateMonthId=n.format(e,`yyyy-MM`)}isEqualTo(e){return this.dateLib.isSameDay(e.date,this.date)&&this.dateLib.isSameMonth(e.displayMonth,this.displayMonth)}},wj=class{constructor(e,t){this.date=e,this.weeks=t}},Tj=class{constructor(e,t){this.days=t,this.weekNumber=e}};function Ej(e){return v.createElement(`button`,{...e})}function Dj(e){return v.createElement(`span`,{...e})}function Oj(e){let{size:t=24,orientation:n=`left`,className:r}=e;return v.createElement(`svg`,{className:r,width:t,height:t,viewBox:`0 0 24 24`},n===`up`&&v.createElement(`polygon`,{points:`6.77 17 12.5 11.43 18.24 17 20 15.28 12.5 8 5 15.28`}),n===`down`&&v.createElement(`polygon`,{points:`6.77 8 12.5 13.57 18.24 8 20 9.72 12.5 17 5 9.72`}),n===`left`&&v.createElement(`polygon`,{points:`16 18.112 9.81111111 12 16 5.87733333 14.0888889 4 6 12 14.0888889 20`}),n===`right`&&v.createElement(`polygon`,{points:`8 18.112 14.18888889 12 8 5.87733333 9.91111111 4 18 12 9.91111111 20`}))}function kj(e){let{day:t,modifiers:n,...r}=e;return v.createElement(`td`,{...r})}function Aj(e){let{day:t,modifiers:n,...r}=e,i=v.useRef(null);return v.useEffect(()=>{n.focused&&i.current?.focus()},[n.focused]),v.createElement(`button`,{ref:i,...r})}var jj;(function(e){e.Root=`root`,e.Chevron=`chevron`,e.Day=`day`,e.DayButton=`day_button`,e.CaptionLabel=`caption_label`,e.Dropdowns=`dropdowns`,e.Dropdown=`dropdown`,e.DropdownRoot=`dropdown_root`,e.Footer=`footer`,e.MonthGrid=`month_grid`,e.MonthCaption=`month_caption`,e.MonthsDropdown=`months_dropdown`,e.Month=`month`,e.Months=`months`,e.Nav=`nav`,e.NextMonthButton=`button_next`,e.PreviousMonthButton=`button_previous`,e.Week=`week`,e.Weeks=`weeks`,e.Weekday=`weekday`,e.Weekdays=`weekdays`,e.WeekNumber=`week_number`,e.WeekNumberHeader=`week_number_header`,e.YearsDropdown=`years_dropdown`})(jj||={});var Mj;(function(e){e.disabled=`disabled`,e.hidden=`hidden`,e.outside=`outside`,e.focused=`focused`,e.today=`today`})(Mj||={});var Nj;(function(e){e.range_end=`range_end`,e.range_middle=`range_middle`,e.range_start=`range_start`,e.selected=`selected`})(Nj||={});var Pj;(function(e){e.weeks_before_enter=`weeks_before_enter`,e.weeks_before_exit=`weeks_before_exit`,e.weeks_after_enter=`weeks_after_enter`,e.weeks_after_exit=`weeks_after_exit`,e.caption_after_enter=`caption_after_enter`,e.caption_after_exit=`caption_after_exit`,e.caption_before_enter=`caption_before_enter`,e.caption_before_exit=`caption_before_exit`})(Pj||={});function Fj(e){let{options:t,className:n,components:r,classNames:i,...a}=e,o=[i[jj.Dropdown],n].join(` `),s=t?.find(({value:e})=>e===a.value);return v.createElement(`span`,{"data-disabled":a.disabled,className:i[jj.DropdownRoot]},v.createElement(r.Select,{className:o,...a},t?.map(({value:e,label:t,disabled:n})=>v.createElement(r.Option,{key:e,value:e,disabled:n},t))),v.createElement(`span`,{className:i[jj.CaptionLabel],"aria-hidden":!0},s?.label,v.createElement(r.Chevron,{orientation:`down`,size:18,className:i[jj.Chevron]})))}function Ij(e){return v.createElement(`div`,{...e})}function Lj(e){return v.createElement(`div`,{...e})}function Rj(e){let{calendarMonth:t,displayIndex:n,...r}=e;return v.createElement(`div`,{...r},e.children)}function zj(e){let{calendarMonth:t,displayIndex:n,...r}=e;return v.createElement(`div`,{...r})}function Bj(e){return v.createElement(`table`,{...e})}function Vj(e){return v.createElement(`div`,{...e})}var Hj=(0,v.createContext)(void 0);function Uj(){let e=(0,v.useContext)(Hj);if(e===void 0)throw Error(`useDayPicker() must be used within a custom component.`);return e}function Wj(e){let{components:t}=Uj();return v.createElement(t.Dropdown,{...e})}function Gj(e){let{onPreviousClick:t,onNextClick:n,previousMonth:r,nextMonth:i,...a}=e,{components:o,classNames:s,labels:{labelPrevious:c,labelNext:l}}=Uj(),u=(0,v.useCallback)(e=>{i&&n?.(e)},[i,n]),d=(0,v.useCallback)(e=>{r&&t?.(e)},[r,t]);return v.createElement(`nav`,{...a},v.createElement(o.PreviousMonthButton,{type:`button`,className:s[jj.PreviousMonthButton],tabIndex:r?void 0:-1,"aria-disabled":r?void 0:!0,"aria-label":c(r),onClick:d},v.createElement(o.Chevron,{disabled:r?void 0:!0,className:s[jj.Chevron],orientation:`left`})),v.createElement(o.NextMonthButton,{type:`button`,className:s[jj.NextMonthButton],tabIndex:i?void 0:-1,"aria-disabled":i?void 0:!0,"aria-label":l(i),onClick:u},v.createElement(o.Chevron,{disabled:i?void 0:!0,orientation:`right`,className:s[jj.Chevron]})))}function Kj(e){let{components:t}=Uj();return v.createElement(t.Button,{...e})}function qj(e){return v.createElement(`option`,{...e})}function Jj(e){let{components:t}=Uj();return v.createElement(t.Button,{...e})}function Yj(e){let{rootRef:t,...n}=e;return v.createElement(`div`,{...n,ref:t})}function Xj(e){return v.createElement(`select`,{...e})}function Zj(e){let{week:t,...n}=e;return v.createElement(`tr`,{...n})}function Qj(e){return v.createElement(`th`,{...e})}function $j(e){return v.createElement(`thead`,{"aria-hidden":!0},v.createElement(`tr`,{...e}))}function eM(e){let{week:t,...n}=e;return v.createElement(`th`,{...n})}function tM(e){return v.createElement(`th`,{...e})}function nM(e){return v.createElement(`tbody`,{...e})}function rM(e){let{components:t}=Uj();return v.createElement(t.Dropdown,{...e})}var iM=s({Button:()=>Ej,CaptionLabel:()=>Dj,Chevron:()=>Oj,Day:()=>kj,DayButton:()=>Aj,Dropdown:()=>Fj,DropdownNav:()=>Ij,Footer:()=>Lj,Month:()=>Rj,MonthCaption:()=>zj,MonthGrid:()=>Bj,Months:()=>Vj,MonthsDropdown:()=>Wj,Nav:()=>Gj,NextMonthButton:()=>Kj,Option:()=>qj,PreviousMonthButton:()=>Jj,Root:()=>Yj,Select:()=>Xj,Week:()=>Zj,WeekNumber:()=>eM,WeekNumberHeader:()=>tM,Weekday:()=>Qj,Weekdays:()=>$j,Weeks:()=>nM,YearsDropdown:()=>rM});function aM(e,t,n=!1,r=Sj){let{from:i,to:a}=e,{differenceInCalendarDays:o,isSameDay:s}=r;return i&&a?(o(a,i)<0&&([i,a]=[a,i]),o(t,i)>=+!!n&&o(a,t)>=+!!n):!n&&a?s(a,t):!n&&i?s(i,t):!1}function oM(e){return!!(e&&typeof e==`object`&&`before`in e&&`after`in e)}function sM(e){return!!(e&&typeof e==`object`&&`from`in e)}function cM(e){return!!(e&&typeof e==`object`&&`after`in e)}function lM(e){return!!(e&&typeof e==`object`&&`before`in e)}function uM(e){return!!(e&&typeof e==`object`&&`dayOfWeek`in e)}function dM(e,t){return Array.isArray(e)&&e.every(t.isDate)}function fM(e,t,n=Sj){let r=Array.isArray(t)?t:[t],{isSameDay:i,differenceInCalendarDays:a,isAfter:o}=n;return r.some(t=>{if(typeof t==`boolean`)return t;if(n.isDate(t))return i(e,t);if(dM(t,n))return t.some(t=>i(e,t));if(sM(t))return aM(t,e,!1,n);if(uM(t))return Array.isArray(t.dayOfWeek)?t.dayOfWeek.includes(e.getDay()):t.dayOfWeek===e.getDay();if(oM(t)){let n=a(t.before,e),r=a(t.after,e),i=n>0,s=r<0;return o(t.before,t.after)?s&&i:i||s}return cM(t)?a(e,t.after)>0:lM(t)?a(t.before,e)>0:typeof t==`function`?t(e):!1})}function pM(e,t,n,r,i){let{disabled:a,hidden:o,modifiers:s,showOutsideDays:c,broadcastCalendar:l,today:u=i.today()}=t,{isSameDay:d,isSameMonth:f,startOfMonth:p,isBefore:m,endOfMonth:h,isAfter:g}=i,_=n&&p(n),v=r&&h(r),y={[Mj.focused]:[],[Mj.outside]:[],[Mj.disabled]:[],[Mj.hidden]:[],[Mj.today]:[]},b={};for(let t of e){let{date:e,displayMonth:n}=t,r=!!(n&&!f(e,n)),p=!!(_&&m(e,_)),h=!!(v&&g(e,v)),x=!!(a&&fM(e,a,i)),S=!!(o&&fM(e,o,i))||p||h||!l&&!c&&r||l&&c===!1&&r,C=d(e,u);r&&y.outside.push(t),x&&y.disabled.push(t),S&&y.hidden.push(t),C&&y.today.push(t),s&&Object.keys(s).forEach(n=>{let r=s?.[n];r&&fM(e,r,i)&&(b[n]?b[n].push(t):b[n]=[t])})}return e=>{let t={[Mj.focused]:!1,[Mj.disabled]:!1,[Mj.hidden]:!1,[Mj.outside]:!1,[Mj.today]:!1},n={};for(let n in y)t[n]=y[n].some(t=>t===e);for(let t in b)n[t]=b[t].some(t=>t===e);return{...t,...n}}}function mM(e,t,n={}){return Object.entries(e).filter(([,e])=>e===!0).reduce((e,[r])=>(n[r]?e.push(n[r]):t[Mj[r]]?e.push(t[Mj[r]]):t[Nj[r]]&&e.push(t[Nj[r]]),e),[t[jj.Day]])}function hM(e){return{...iM,...e}}function gM(e){let t={"data-mode":e.mode??void 0,"data-required":`required`in e?e.required:void 0,"data-multiple-months":e.numberOfMonths&&e.numberOfMonths>1||void 0,"data-week-numbers":e.showWeekNumber||void 0,"data-broadcast-calendar":e.broadcastCalendar||void 0,"data-nav-layout":e.navLayout||void 0};return Object.entries(e).forEach(([e,n])=>{e.startsWith(`data-`)&&(t[e]=n)}),t}function _M(){let e={};for(let t in jj)e[jj[t]]=`rdp-${jj[t]}`;for(let t in Mj)e[Mj[t]]=`rdp-${Mj[t]}`;for(let t in Nj)e[Nj[t]]=`rdp-${Nj[t]}`;for(let t in Pj)e[Pj[t]]=`rdp-${Pj[t]}`;return e}function vM(e,t,n){return(n??new xj(t)).formatMonthYear(e)}var yM=vM;function bM(e,t,n){return(n??new xj(t)).format(e,`d`)}function xM(e,t=Sj){return t.format(e,`LLLL`)}function SM(e,t,n){return(n??new xj(t)).format(e,`cccccc`)}function CM(e,t=Sj){return e<10?t.formatNumber(`0${e.toLocaleString()}`):t.formatNumber(`${e.toLocaleString()}`)}function wM(){return``}function TM(e,t=Sj){return t.format(e,`yyyy`)}var EM=TM,DM=s({formatCaption:()=>vM,formatDay:()=>bM,formatMonthCaption:()=>yM,formatMonthDropdown:()=>xM,formatWeekNumber:()=>CM,formatWeekNumberHeader:()=>wM,formatWeekdayName:()=>SM,formatYearCaption:()=>EM,formatYearDropdown:()=>TM});function OM(e){return e?.formatMonthCaption&&!e.formatCaption&&(e.formatCaption=e.formatMonthCaption),e?.formatYearCaption&&!e.formatYearDropdown&&(e.formatYearDropdown=e.formatYearCaption),{...DM,...e}}function kM(e,t,n,r){let i=(r??new xj(n)).format(e,`PPPP`);return t.today&&(i=`Today, ${i}`),t.selected&&(i=`${i}, selected`),i}var AM=kM;function jM(e,t,n){return(n??new xj(t)).formatMonthYear(e)}var MM=jM;function NM(e,t,n,r){let i=(r??new xj(n)).format(e,`PPPP`);return t?.today&&(i=`Today, ${i}`),i}function PM(e){return`Choose the Month`}function FM(){return``}var IM=`Go to the Next Month`;function LM(e,t){return IM}function RM(e){return`Go to the Previous Month`}function zM(e,t,n){return(n??new xj(t)).format(e,`cccc`)}function BM(e,t){return`Week ${e}`}function VM(e){return`Week Number`}function HM(e){return`Choose the Year`}var UM=s({labelCaption:()=>MM,labelDay:()=>AM,labelDayButton:()=>kM,labelGrid:()=>jM,labelGridcell:()=>NM,labelMonthDropdown:()=>PM,labelNav:()=>FM,labelNext:()=>LM,labelPrevious:()=>RM,labelWeekNumber:()=>BM,labelWeekNumberHeader:()=>VM,labelWeekday:()=>zM,labelYearDropdown:()=>HM}),WM=(e,t,n)=>t||(n?typeof n==`function`?n:(...e)=>n:e);function GM(e,t){let n=t.locale?.labels??{};return{...UM,...e??{},labelDayButton:WM(kM,e?.labelDayButton,n.labelDayButton),labelMonthDropdown:WM(PM,e?.labelMonthDropdown,n.labelMonthDropdown),labelNext:WM(LM,e?.labelNext,n.labelNext),labelPrevious:WM(RM,e?.labelPrevious,n.labelPrevious),labelWeekNumber:WM(BM,e?.labelWeekNumber,n.labelWeekNumber),labelYearDropdown:WM(HM,e?.labelYearDropdown,n.labelYearDropdown),labelGrid:WM(jM,e?.labelGrid,n.labelGrid),labelGridcell:WM(NM,e?.labelGridcell,n.labelGridcell),labelNav:WM(FM,e?.labelNav,n.labelNav),labelWeekNumberHeader:WM(VM,e?.labelWeekNumberHeader,n.labelWeekNumberHeader),labelWeekday:WM(zM,e?.labelWeekday,n.labelWeekday)}}function KM(e,t,n,r,i){let{startOfMonth:a,startOfYear:o,endOfYear:s,eachMonthOfInterval:c,getMonth:l}=i;return c({start:o(e),end:s(e)}).map(e=>{let o=r.formatMonthDropdown(e,i);return{value:l(e),label:o,disabled:t&&e<a(t)||n&&e>a(n)||!1}})}function qM(e,t={},n={}){let r={...t?.[jj.Day]};return Object.entries(e).filter(([,e])=>e===!0).forEach(([e])=>{r={...r,...n?.[e]}}),r}function JM(e,t,n,r){let i=r??e.today(),a=n?e.startOfBroadcastWeek(i,e):t?e.startOfISOWeek(i):e.startOfWeek(i),o=[];for(let t=0;t<7;t++){let n=e.addDays(a,t);o.push(n)}return o}function YM(e,t,n,r,i=!1){if(!e||!t)return;let{startOfYear:a,endOfYear:o,eachYearOfInterval:s,getYear:c}=r,l=s({start:a(e),end:o(t)});return i&&l.reverse(),l.map(e=>{let t=n.formatYearDropdown(e,r);return{value:c(e),label:t,disabled:!1}})}function XM(e,t={}){let{weekStartsOn:n,locale:r}=t,i=n??r?.options?.weekStartsOn??0,a=t=>{let n=typeof t==`number`||typeof t==`string`?new Date(t):t;return new mj(n.getFullYear(),n.getMonth(),n.getDate(),12,0,0,e)},o=e=>{let t=a(e);return new Date(t.getFullYear(),t.getMonth(),t.getDate(),0,0,0,0)};return{today:()=>a(mj.tz(e)),newDate:(t,n,r)=>new mj(t,n,r,12,0,0,e),startOfDay:e=>a(e),startOfWeek:(e,t)=>{let n=a(e),r=t?.weekStartsOn??i,o=(n.getDay()-r+7)%7;return n.setDate(n.getDate()-o),n},startOfISOWeek:e=>{let t=a(e),n=(t.getDay()-1+7)%7;return t.setDate(t.getDate()-n),t},startOfMonth:e=>{let t=a(e);return t.setDate(1),t},startOfYear:e=>{let t=a(e);return t.setMonth(0,1),t},endOfWeek:(e,t)=>{let n=a(e),r=(((t?.weekStartsOn??i)+6)%7-n.getDay()+7)%7;return n.setDate(n.getDate()+r),n},endOfISOWeek:e=>{let t=a(e),n=(7-t.getDay())%7;return t.setDate(t.getDate()+n),t},endOfMonth:e=>{let t=a(e);return t.setMonth(t.getMonth()+1,0),t},endOfYear:e=>{let t=a(e);return t.setMonth(11,31),t},eachMonthOfInterval:t=>{let n=a(t.start),r=a(t.end),i=[],o=new mj(n.getFullYear(),n.getMonth(),1,12,0,0,e),s=r.getFullYear()*12+r.getMonth();for(;o.getFullYear()*12+o.getMonth()<=s;)i.push(new mj(o,e)),o.setMonth(o.getMonth()+1,1);return i},addDays:(e,t)=>{let n=a(e);return n.setDate(n.getDate()+t),n},addWeeks:(e,t)=>{let n=a(e);return n.setDate(n.getDate()+t*7),n},addMonths:(e,t)=>{let n=a(e);return n.setMonth(n.getMonth()+t),n},addYears:(e,t)=>{let n=a(e);return n.setFullYear(n.getFullYear()+t),n},eachYearOfInterval:t=>{let n=a(t.start),r=a(t.end),i=[],o=new mj(n.getFullYear(),0,1,12,0,0,e);for(;o.getFullYear()<=r.getFullYear();)i.push(new mj(o,e)),o.setFullYear(o.getFullYear()+1,0,1);return i},getWeek:(e,t)=>vA(o(e),{weekStartsOn:t?.weekStartsOn??i,firstWeekContainsDate:t?.firstWeekContainsDate??r?.options?.firstWeekContainsDate??1}),getISOWeek:e=>hA(o(e)),differenceInCalendarDays:(e,t)=>Ik(o(e),o(t)),differenceInCalendarMonths:(e,t)=>Gk(o(e),o(t))}}var ZM=e=>e instanceof HTMLElement?e:null,QM=e=>[...e.querySelectorAll(`[data-animated-month]`)??[]],$M=e=>ZM(e.querySelector(`[data-animated-month]`)),eN=e=>ZM(e.querySelector(`[data-animated-caption]`)),tN=e=>ZM(e.querySelector(`[data-animated-weeks]`)),nN=e=>ZM(e.querySelector(`[data-animated-nav]`)),rN=e=>ZM(e.querySelector(`[data-animated-weekdays]`));function iN(e,t,{classNames:n,months:r,focused:i,dateLib:a}){let o=(0,v.useRef)(null),s=(0,v.useRef)(r),c=(0,v.useRef)(!1);(0,v.useLayoutEffect)(()=>{let l=s.current;if(s.current=r,!t||!e.current||!(e.current instanceof HTMLElement)||r.length===0||l.length===0||r.length!==l.length)return;let u=a.isSameMonth(r[0].date,l[0].date),d=a.isAfter(r[0].date,l[0].date),f=d?n[Pj.caption_after_enter]:n[Pj.caption_before_enter],p=d?n[Pj.weeks_after_enter]:n[Pj.weeks_before_enter],m=o.current,h=e.current.cloneNode(!0);if(h instanceof HTMLElement?(QM(h).forEach(e=>{if(!(e instanceof HTMLElement))return;let t=$M(e);t&&e.contains(t)&&e.removeChild(t);let n=eN(e);n&&n.classList.remove(f);let r=tN(e);r&&r.classList.remove(p)}),o.current=h):o.current=null,c.current||u||i)return;let g=m instanceof HTMLElement?QM(m):[],_=QM(e.current);if(_?.every(e=>e instanceof HTMLElement)&&g&&g.every(e=>e instanceof HTMLElement)){c.current=!0;let t=[];e.current.style.isolation=`isolate`;let r=nN(e.current);r&&(r.style.zIndex=`1`),_.forEach((i,a)=>{let o=g[a];if(!o)return;i.style.position=`relative`,i.style.overflow=`hidden`;let s=eN(i);s&&s.classList.add(f);let l=tN(i);l&&l.classList.add(p);let u=()=>{c.current=!1,e.current&&(e.current.style.isolation=``),r&&(r.style.zIndex=``),s&&s.classList.remove(f),l&&l.classList.remove(p),i.style.position=``,i.style.overflow=``,i.contains(o)&&i.removeChild(o)};t.push(u),o.style.pointerEvents=`none`,o.style.position=`absolute`,o.style.overflow=`hidden`,o.setAttribute(`aria-hidden`,`true`);let m=rN(o);m&&(m.style.opacity=`0`);let h=eN(o);h&&(h.classList.add(d?n[Pj.caption_before_exit]:n[Pj.caption_after_exit]),h.addEventListener(`animationend`,u));let _=tN(o);_&&_.classList.add(d?n[Pj.weeks_before_exit]:n[Pj.weeks_after_exit]),i.insertBefore(o,i.firstChild)})}})}function aN(e,t,n,r){let i=e[0],a=e[e.length-1],{ISOWeek:o,fixedWeeks:s,broadcastCalendar:c}=n??{},{addDays:l,differenceInCalendarDays:u,differenceInCalendarMonths:d,endOfBroadcastWeek:f,endOfISOWeek:p,endOfMonth:m,endOfWeek:h,isAfter:g,startOfBroadcastWeek:_,startOfISOWeek:v,startOfWeek:y}=r,b=c?_(i,r):o?v(i):y(i),x=c?f(a):o?p(m(a)):h(m(a)),S=t&&(c?f(t):o?p(t):h(t)),C=u(S&&g(x,S)?S:x,b),w=d(a,i)+1,T=[];for(let e=0;e<=C;e++){let t=l(b,e);T.push(t)}let E=(c?35:42)*w;if(s&&T.length<E){let e=E-T.length;for(let t=0;t<e;t++){let e=l(T[T.length-1],1);T.push(e)}}return T}function oN(e){let t=[];return e.reduce((e,n)=>{let r=n.weeks.reduce((e,t)=>e.concat(t.days.slice()),t.slice());return e.concat(r.slice())},t.slice())}function sN(e,t,n,r){let{numberOfMonths:i=1}=n,a=[];for(let n=0;n<i;n++){let i=r.addMonths(e,n);if(t&&i>t)break;a.push(i)}return a}function cN(e,t,n,r){let{month:i,defaultMonth:a,today:o=r.today(),numberOfMonths:s=1}=e,c=i||a||o,{differenceInCalendarMonths:l,addMonths:u,startOfMonth:d}=r;return n&&l(n,c)<s-1&&(c=u(n,-1*(s-1))),t&&l(c,t)<0&&(c=t),d(c)}function lN(e,t,n,r){let{addDays:i,endOfBroadcastWeek:a,endOfISOWeek:o,endOfMonth:s,endOfWeek:c,getISOWeek:l,getWeek:u,startOfBroadcastWeek:d,startOfISOWeek:f,startOfWeek:p}=r,m=e.reduce((e,m)=>{let h=n.broadcastCalendar?d(m,r):n.ISOWeek?f(m):p(m),g=n.broadcastCalendar?a(m):n.ISOWeek?o(s(m)):c(s(m)),_=t.filter(e=>e>=h&&e<=g),v=n.broadcastCalendar?35:42;if(n.fixedWeeks&&_.length<v){let e=t.filter(e=>{let t=v-_.length;return e>g&&e<=i(g,t)});_.push(...e)}let y=new wj(m,_.reduce((e,t)=>{let i=n.ISOWeek?l(t):u(t),a=e.find(e=>e.weekNumber===i),o=new Cj(t,m,r);return a?a.days.push(o):e.push(new Tj(i,[o])),e},[]));return e.push(y),e},[]);return n.reverseMonths?m.reverse():m}function uN(e,t){let{startMonth:n,endMonth:r}=e,{startOfYear:i,startOfDay:a,startOfMonth:o,endOfMonth:s,addYears:c,endOfYear:l,newDate:u,today:d}=t,{fromYear:f,toYear:p,fromMonth:m,toMonth:h}=e;!n&&m&&(n=m),!n&&f&&(n=t.newDate(f,0,1)),!r&&h&&(r=h),!r&&p&&(r=u(p,11,31));let g=e.captionLayout===`dropdown`||e.captionLayout===`dropdown-years`;return n?n=o(n):f?n=u(f,0,1):!n&&g&&(n=i(c(e.today??d(),-100))),r?r=s(r):p?r=u(p,11,31):!r&&g&&(r=l(e.today??d())),[n&&a(n),r&&a(r)]}function dN(e,t,n,r){if(n.disableNavigation)return;let{pagedNavigation:i,numberOfMonths:a=1}=n,{startOfMonth:o,addMonths:s,differenceInCalendarMonths:c}=r,l=i?a:1,u=o(e);if(!t||!(c(t,e)<a))return s(u,l)}function fN(e,t,n,r){if(n.disableNavigation)return;let{pagedNavigation:i,numberOfMonths:a}=n,{startOfMonth:o,addMonths:s,differenceInCalendarMonths:c}=r,l=i?a??1:1,u=o(e);if(!t||!(c(u,t)<=0))return s(u,-l)}function pN(e){return e.reduce((e,t)=>e.concat(t.weeks.slice()),[].slice())}function mN(e,t){let[n,r]=(0,v.useState)(e);return[t===void 0?n:t,r]}function hN(e,t){let[n,r]=uN(e,t),{startOfMonth:i,endOfMonth:a}=t,o=cN(e,n,r,t),[s,c]=mN(o,e.month?o:void 0);(0,v.useEffect)(()=>{c(cN(e,n,r,t))},[e.timeZone]);let{months:l,weeks:u,days:d,previousMonth:f,nextMonth:p}=(0,v.useMemo)(()=>{let i=sN(s,r,{numberOfMonths:e.numberOfMonths},t),o=lN(i,aN(i,e.endMonth?a(e.endMonth):void 0,{ISOWeek:e.ISOWeek,fixedWeeks:e.fixedWeeks,broadcastCalendar:e.broadcastCalendar},t),{broadcastCalendar:e.broadcastCalendar,fixedWeeks:e.fixedWeeks,ISOWeek:e.ISOWeek,reverseMonths:e.reverseMonths},t);return{months:o,weeks:pN(o),days:oN(o),previousMonth:fN(s,n,e,t),nextMonth:dN(s,r,e,t)}},[t,s.getTime(),r?.getTime(),n?.getTime(),e.disableNavigation,e.broadcastCalendar,e.endMonth?.getTime(),e.fixedWeeks,e.ISOWeek,e.numberOfMonths,e.pagedNavigation,e.reverseMonths]),{disableNavigation:m,onMonthChange:h}=e,g=e=>u.some(t=>t.days.some(t=>t.isEqualTo(e))),_=e=>{if(m)return;let t=i(e);n&&t<i(n)&&(t=i(n)),r&&t>i(r)&&(t=i(r)),c(t),h?.(t)};return{months:l,weeks:u,days:d,navStart:n,navEnd:r,previousMonth:f,nextMonth:p,goToMonth:_,goToDay:e=>{g(e)||_(e.date)}}}var gN;(function(e){e[e.Today=0]=`Today`,e[e.Selected=1]=`Selected`,e[e.LastFocused=2]=`LastFocused`,e[e.FocusedModifier=3]=`FocusedModifier`})(gN||={});function _N(e){return!e[Mj.disabled]&&!e[Mj.hidden]&&!e[Mj.outside]}function vN(e,t,n,r){let i,a=-1;for(let o of e){let e=t(o);_N(e)&&(e[Mj.focused]&&a<gN.FocusedModifier?(i=o,a=gN.FocusedModifier):r?.isEqualTo(o)&&a<gN.LastFocused?(i=o,a=gN.LastFocused):n(o.date)&&a<gN.Selected?(i=o,a=gN.Selected):e[Mj.today]&&a<gN.Today&&(i=o,a=gN.Today))}return i||=e.find(e=>_N(t(e))),i}function yN(e,t,n,r,i,a,o){let{ISOWeek:s,broadcastCalendar:c}=a,{addDays:l,addMonths:u,addWeeks:d,addYears:f,endOfBroadcastWeek:p,endOfISOWeek:m,endOfWeek:h,max:g,min:_,startOfBroadcastWeek:v,startOfISOWeek:y,startOfWeek:b}=o,x={day:l,week:d,month:u,year:f,startOfWeek:e=>c?v(e,o):s?y(e):b(e),endOfWeek:e=>c?p(e):s?m(e):h(e)}[e](n,t===`after`?1:-1);return t===`before`&&r?x=g([r,x]):t===`after`&&i&&(x=_([i,x])),x}function bN(e,t,n,r,i,a,o,s=0){if(s>365)return;let c=yN(e,t,n.date,r,i,a,o),l=!!(a.disabled&&fM(c,a.disabled,o)),u=!!(a.hidden&&fM(c,a.hidden,o)),d=new Cj(c,c,o);return!l&&!u?d:bN(e,t,d,r,i,a,o,s+1)}function xN(e,t,n,r,i){let{autoFocus:a}=e,[o,s]=(0,v.useState)(),c=vN(t.days,n,r||(()=>!1),o),[l,u]=(0,v.useState)(a?c:void 0);return{isFocusTarget:e=>!!c?.isEqualTo(e),setFocused:u,focused:l,blur:()=>{s(l),u(void 0)},moveFocus:(n,r)=>{if(!l)return;let a=bN(n,r,l,t.navStart,t.navEnd,e,i);a&&(e.disableNavigation&&!t.days.some(e=>e.isEqualTo(a))||(t.goToDay(a),u(a)))}}}function SN(e,t){let{selected:n,required:r,onSelect:i}=e,[a,o]=mN(n,i?n:void 0),s=i?n:a,{isSameDay:c}=t,l=e=>s?.some(t=>c(t,e))??!1,{min:u,max:d}=e;return{selected:s,select:(e,t,n)=>{let a=[...s??[]];if(l(e)){if(s?.length===u||r&&s?.length===1)return;a=s?.filter(t=>!c(t,e))}else a=s?.length===d?[e]:[...a,e];return i||o(a),i?.(a,e,t,n),a},isSelected:l}}function CN(e,t,n=0,r=0,i=!1,a=Sj){let{from:o,to:s}=t||{},{isSameDay:c,isAfter:l,isBefore:u}=a,d;if(!o&&!s)d={from:e,to:n>0?void 0:e};else if(o&&!s)d=c(o,e)?n===0?{from:o,to:e}:i?{from:o,to:void 0}:void 0:u(e,o)?{from:e,to:o}:{from:o,to:e};else if(o&&s)if(c(o,e)&&c(s,e))d=i?{from:o,to:s}:void 0;else if(c(o,e))d={from:o,to:n>0?void 0:e};else if(c(s,e))d={from:e,to:n>0?void 0:e};else if(u(e,o))d={from:e,to:s};else if(l(e,o))d={from:o,to:e};else if(l(e,s))d={from:o,to:e};else throw Error(`Invalid range`);if(d?.from&&d?.to){let t=a.differenceInCalendarDays(d.to,d.from);(r>0&&t>r||n>1&&t<n)&&(d={from:e,to:void 0})}return d}function wN(e,t,n=Sj){let r=Array.isArray(t)?t:[t],i=e.from,a=n.differenceInCalendarDays(e.to,e.from),o=Math.min(a,6);for(let e=0;e<=o;e++){if(r.includes(i.getDay()))return!0;i=n.addDays(i,1)}return!1}function TN(e,t,n=Sj){return aM(e,t.from,!1,n)||aM(e,t.to,!1,n)||aM(t,e.from,!1,n)||aM(t,e.to,!1,n)}function EN(e,t,n=Sj){let r=Array.isArray(t)?t:[t];if(r.filter(e=>typeof e!=`function`).some(t=>typeof t==`boolean`?t:n.isDate(t)?aM(e,t,!1,n):dM(t,n)?t.some(t=>aM(e,t,!1,n)):sM(t)?t.from&&t.to?TN(e,{from:t.from,to:t.to},n):!1:uM(t)?wN(e,t.dayOfWeek,n):oM(t)?n.isAfter(t.before,t.after)?TN(e,{from:n.addDays(t.after,1),to:n.addDays(t.before,-1)},n):fM(e.from,t,n)||fM(e.to,t,n):cM(t)||lM(t)?fM(e.from,t,n)||fM(e.to,t,n):!1))return!0;let i=r.filter(e=>typeof e==`function`);if(i.length){let t=e.from,r=n.differenceInCalendarDays(e.to,e.from);for(let e=0;e<=r;e++){if(i.some(e=>e(t)))return!0;t=n.addDays(t,1)}}return!1}function DN(e,t){let{disabled:n,excludeDisabled:r,resetOnSelect:i,selected:a,required:o,onSelect:s}=e,[c,l]=mN(a,s?a:void 0),u=s?a:c;return{selected:u,select:(a,c,d)=>{let{min:f,max:p}=e,m;if(a){let e=u?.from,n=u?.to,r=!!e&&!!n,s=!!e&&!!n&&t.isSameDay(e,n)&&t.isSameDay(a,e);m=i&&(r||!u?.from)?!o&&s?void 0:{from:a,to:void 0}:CN(a,u,f,p,o,t)}return r&&n&&m?.from&&m.to&&EN({from:m.from,to:m.to},n,t)&&(m.from=a,m.to=void 0),s||l(m),s?.(m,a,c,d),m},isSelected:e=>u&&aM(u,e,!1,t)}}function ON(e,t){let{selected:n,required:r,onSelect:i}=e,[a,o]=mN(n,i?n:void 0),s=i?n:a,{isSameDay:c}=t;return{selected:s,select:(e,t,n)=>{let a=e;return!r&&s&&s&&c(e,s)&&(a=void 0),i||o(a),i?.(a,e,t,n),a},isSelected:e=>s?c(s,e):!1}}function kN(e,t){let n=ON(e,t),r=SN(e,t),i=DN(e,t);switch(e.mode){case`single`:return n;case`multiple`:return r;case`range`:return i;default:return}}function AN(e,t){return e instanceof mj&&e.timeZone===t?e:new mj(e,t)}function jN(e,t,n){if(!n)return AN(e,t);let r=AN(e,t),i=new mj(r.getFullYear(),r.getMonth(),r.getDate(),12,0,0,t);return new Date(i.getTime())}function MN(e,t,n){return typeof e==`boolean`||typeof e==`function`?e:e instanceof Date?jN(e,t,n):Array.isArray(e)?e.map(e=>e instanceof Date?jN(e,t,n):e):sM(e)?{...e,from:e.from?AN(e.from,t):e.from,to:e.to?AN(e.to,t):e.to}:oM(e)?{before:jN(e.before,t,n),after:jN(e.after,t,n)}:cM(e)?{after:jN(e.after,t,n)}:lM(e)?{before:jN(e.before,t,n)}:e}function NN(e,t,n){return e&&(Array.isArray(e)?e.map(e=>MN(e,t,n)):MN(e,t,n))}function PN(e){let t=e,n=t.timeZone;if(n&&(t={...e,timeZone:n},t.today&&=AN(t.today,n),t.month&&=AN(t.month,n),t.defaultMonth&&=AN(t.defaultMonth,n),t.startMonth&&=AN(t.startMonth,n),t.endMonth&&=AN(t.endMonth,n),t.mode===`single`&&t.selected?t.selected=AN(t.selected,n):t.mode===`multiple`&&t.selected?t.selected=t.selected?.map(e=>AN(e,n)):t.mode===`range`&&t.selected&&(t.selected={from:t.selected.from?AN(t.selected.from,n):t.selected.from,to:t.selected.to?AN(t.selected.to,n):t.selected.to}),t.disabled!==void 0&&(t.disabled=NN(t.disabled,n)),t.hidden!==void 0&&(t.hidden=NN(t.hidden,n)),t.modifiers)){let e={};Object.keys(t.modifiers).forEach(r=>{e[r]=NN(t.modifiers?.[r],n)}),t.modifiers=e}let{components:r,formatters:i,labels:a,dateLib:o,locale:s,classNames:c}=(0,v.useMemo)(()=>{let e={...bj,...t.locale},n=t.broadcastCalendar?1:t.weekStartsOn,r=t.noonSafe&&t.timeZone?XM(t.timeZone,{weekStartsOn:n,locale:e}):void 0,i=t.dateLib&&r?{...r,...t.dateLib}:t.dateLib??r,a=new xj({locale:e,weekStartsOn:n,firstWeekContainsDate:t.firstWeekContainsDate,useAdditionalWeekYearTokens:t.useAdditionalWeekYearTokens,useAdditionalDayOfYearTokens:t.useAdditionalDayOfYearTokens,timeZone:t.timeZone,numerals:t.numerals},i);return{dateLib:a,components:hM(t.components),formatters:OM(t.formatters),labels:GM(t.labels,a.options),locale:e,classNames:{..._M(),...t.classNames}}},[t.locale,t.broadcastCalendar,t.weekStartsOn,t.firstWeekContainsDate,t.useAdditionalWeekYearTokens,t.useAdditionalDayOfYearTokens,t.timeZone,t.numerals,t.dateLib,t.noonSafe,t.components,t.formatters,t.labels,t.classNames]);t.today||(t={...t,today:o.today()});let{captionLayout:l,mode:u,navLayout:d,numberOfMonths:f=1,onDayBlur:p,onDayClick:m,onDayFocus:h,onDayKeyDown:g,onDayMouseEnter:_,onDayMouseLeave:y,onNextClick:b,onPrevClick:x,showWeekNumber:S,styles:C}=t,{formatCaption:w,formatDay:T,formatMonthDropdown:E,formatWeekNumber:D,formatWeekNumberHeader:O,formatWeekdayName:k,formatYearDropdown:A}=i,j=hN(t,o),{days:M,months:N,navStart:P,navEnd:F,previousMonth:I,nextMonth:L,goToMonth:R}=j,ee=pM(M,t,P,F,o),{isSelected:te,select:z,selected:B}=kN(t,o)??{},{blur:V,focused:ne,isFocusTarget:H,moveFocus:re,setFocused:ie}=xN(t,j,ee,te??(()=>!1),o),{labelDayButton:ae,labelGridcell:oe,labelGrid:se,labelMonthDropdown:ce,labelNav:le,labelPrevious:ue,labelNext:de,labelWeekday:fe,labelWeekNumber:pe,labelWeekNumberHeader:me,labelYearDropdown:he}=a,ge=(0,v.useMemo)(()=>JM(o,t.ISOWeek,t.broadcastCalendar,t.today),[o,t.ISOWeek,t.broadcastCalendar,t.today]),_e=u!==void 0||m!==void 0,ve=(0,v.useCallback)(()=>{I&&(R(I),x?.(I))},[I,R,x]),ye=(0,v.useCallback)(()=>{L&&(R(L),b?.(L))},[R,L,b]),be=(0,v.useCallback)((e,t)=>n=>{n.preventDefault(),n.stopPropagation(),ie(e),!t.disabled&&(z?.(e.date,t,n),m?.(e.date,t,n))},[z,m,ie]),xe=(0,v.useCallback)((e,t)=>n=>{ie(e),h?.(e.date,t,n)},[h,ie]),Se=(0,v.useCallback)((e,t)=>n=>{V(),p?.(e.date,t,n)},[V,p]),Ce=(0,v.useCallback)((e,n)=>r=>{let i={ArrowLeft:[r.shiftKey?`month`:`day`,t.dir===`rtl`?`after`:`before`],ArrowRight:[r.shiftKey?`month`:`day`,t.dir===`rtl`?`before`:`after`],ArrowDown:[r.shiftKey?`year`:`week`,`after`],ArrowUp:[r.shiftKey?`year`:`week`,`before`],PageUp:[r.shiftKey?`year`:`month`,`before`],PageDown:[r.shiftKey?`year`:`month`,`after`],Home:[`startOfWeek`,`before`],End:[`endOfWeek`,`after`]};if(i[r.key]){r.preventDefault(),r.stopPropagation();let[e,t]=i[r.key];re(e,t)}g?.(e.date,n,r)},[re,g,t.dir]),we=(0,v.useCallback)((e,t)=>n=>{_?.(e.date,t,n)},[_]),Te=(0,v.useCallback)((e,t)=>n=>{y?.(e.date,t,n)},[y]),Ee=(0,v.useCallback)(e=>t=>{let n=Number(t.target.value);R(o.setMonth(o.startOfMonth(e),n))},[o,R]),De=(0,v.useCallback)(e=>t=>{let n=Number(t.target.value);R(o.setYear(o.startOfMonth(e),n))},[o,R]),{className:Oe,style:ke}=(0,v.useMemo)(()=>({className:[c[jj.Root],t.className].filter(Boolean).join(` `),style:{...C?.[jj.Root],...t.style}}),[c,t.className,t.style,C]),Ae=gM(t),je=(0,v.useRef)(null);iN(je,!!t.animate,{classNames:c,months:N,focused:ne,dateLib:o});let Me={dayPickerProps:t,selected:B,select:z,isSelected:te,months:N,nextMonth:L,previousMonth:I,goToMonth:R,getModifiers:ee,components:r,classNames:c,styles:C,labels:a,formatters:i};return v.createElement(Hj.Provider,{value:Me},v.createElement(r.Root,{rootRef:t.animate?je:void 0,className:Oe,style:ke,dir:t.dir,id:t.id,lang:t.lang??s.code,nonce:t.nonce,title:t.title,role:t.role,"aria-label":t[`aria-label`],"aria-labelledby":t[`aria-labelledby`],...Ae},v.createElement(r.Months,{className:c[jj.Months],style:C?.[jj.Months]},!t.hideNavigation&&!d&&v.createElement(r.Nav,{"data-animated-nav":t.animate?`true`:void 0,className:c[jj.Nav],style:C?.[jj.Nav],"aria-label":le(),onPreviousClick:ve,onNextClick:ye,previousMonth:I,nextMonth:L}),N.map((e,n)=>v.createElement(r.Month,{"data-animated-month":t.animate?`true`:void 0,className:c[jj.Month],style:C?.[jj.Month],key:n,displayIndex:n,calendarMonth:e},d===`around`&&!t.hideNavigation&&n===0&&v.createElement(r.PreviousMonthButton,{type:`button`,className:c[jj.PreviousMonthButton],tabIndex:I?void 0:-1,"aria-disabled":I?void 0:!0,"aria-label":ue(I),onClick:ve,"data-animated-button":t.animate?`true`:void 0},v.createElement(r.Chevron,{disabled:I?void 0:!0,className:c[jj.Chevron],orientation:t.dir===`rtl`?`right`:`left`})),v.createElement(r.MonthCaption,{"data-animated-caption":t.animate?`true`:void 0,className:c[jj.MonthCaption],style:C?.[jj.MonthCaption],calendarMonth:e,displayIndex:n},l?.startsWith(`dropdown`)?v.createElement(r.DropdownNav,{className:c[jj.Dropdowns],style:C?.[jj.Dropdowns]},(()=>{let n=l===`dropdown`||l===`dropdown-months`?v.createElement(r.MonthsDropdown,{key:`month`,className:c[jj.MonthsDropdown],"aria-label":ce(),classNames:c,components:r,disabled:!!t.disableNavigation,onChange:Ee(e.date),options:KM(e.date,P,F,i,o),style:C?.[jj.Dropdown],value:o.getMonth(e.date)}):v.createElement(`span`,{key:`month`},E(e.date,o)),a=l===`dropdown`||l===`dropdown-years`?v.createElement(r.YearsDropdown,{key:`year`,className:c[jj.YearsDropdown],"aria-label":he(o.options),classNames:c,components:r,disabled:!!t.disableNavigation,onChange:De(e.date),options:YM(P,F,i,o,!!t.reverseYears),style:C?.[jj.Dropdown],value:o.getYear(e.date)}):v.createElement(`span`,{key:`year`},A(e.date,o));return o.getMonthYearOrder()===`year-first`?[a,n]:[n,a]})(),v.createElement(`span`,{role:`status`,"aria-live":`polite`,style:{border:0,clip:`rect(0 0 0 0)`,height:`1px`,margin:`-1px`,overflow:`hidden`,padding:0,position:`absolute`,width:`1px`,whiteSpace:`nowrap`,wordWrap:`normal`}},w(e.date,o.options,o))):v.createElement(r.CaptionLabel,{className:c[jj.CaptionLabel],role:`status`,"aria-live":`polite`},w(e.date,o.options,o))),d===`around`&&!t.hideNavigation&&n===f-1&&v.createElement(r.NextMonthButton,{type:`button`,className:c[jj.NextMonthButton],tabIndex:L?void 0:-1,"aria-disabled":L?void 0:!0,"aria-label":de(L),onClick:ye,"data-animated-button":t.animate?`true`:void 0},v.createElement(r.Chevron,{disabled:L?void 0:!0,className:c[jj.Chevron],orientation:t.dir===`rtl`?`left`:`right`})),n===f-1&&d===`after`&&!t.hideNavigation&&v.createElement(r.Nav,{"data-animated-nav":t.animate?`true`:void 0,className:c[jj.Nav],style:C?.[jj.Nav],"aria-label":le(),onPreviousClick:ve,onNextClick:ye,previousMonth:I,nextMonth:L}),v.createElement(r.MonthGrid,{role:`grid`,"aria-multiselectable":u===`multiple`||u===`range`,"aria-label":se(e.date,o.options,o)||void 0,className:c[jj.MonthGrid],style:C?.[jj.MonthGrid]},!t.hideWeekdays&&v.createElement(r.Weekdays,{"data-animated-weekdays":t.animate?`true`:void 0,className:c[jj.Weekdays],style:C?.[jj.Weekdays]},S&&v.createElement(r.WeekNumberHeader,{"aria-label":me(o.options),className:c[jj.WeekNumberHeader],style:C?.[jj.WeekNumberHeader],scope:`col`},O()),ge.map(e=>v.createElement(r.Weekday,{"aria-label":fe(e,o.options,o),className:c[jj.Weekday],key:String(e),style:C?.[jj.Weekday],scope:`col`},k(e,o.options,o)))),v.createElement(r.Weeks,{"data-animated-weeks":t.animate?`true`:void 0,className:c[jj.Weeks],style:C?.[jj.Weeks]},e.weeks.map(e=>v.createElement(r.Week,{className:c[jj.Week],key:e.weekNumber,style:C?.[jj.Week],week:e},S&&v.createElement(r.WeekNumber,{week:e,style:C?.[jj.WeekNumber],"aria-label":pe(e.weekNumber,{locale:s}),className:c[jj.WeekNumber],scope:`row`,role:`rowheader`},D(e.weekNumber,o)),e.days.map(e=>{let{date:n}=e,i=ee(e);if(i[Mj.focused]=!i.hidden&&!!ne?.isEqualTo(e),i[Nj.selected]=te?.(n)||i.selected,sM(B)){let{from:e,to:t}=B;i[Nj.range_start]=!!(e&&t&&o.isSameDay(n,e)),i[Nj.range_end]=!!(e&&t&&o.isSameDay(n,t)),i[Nj.range_middle]=aM(B,n,!0,o)}let a=qM(i,C,t.modifiersStyles),s=mM(i,c,t.modifiersClassNames),l=!_e&&!i.hidden?oe(n,i,o.options,o):void 0;return v.createElement(r.Day,{key:`${e.isoDate}_${e.displayMonthId}`,day:e,modifiers:i,className:s.join(` `),style:a,role:`gridcell`,"aria-selected":i.selected||void 0,"aria-label":l,"data-day":e.isoDate,"data-month":e.outside?e.dateMonthId:void 0,"data-selected":i.selected||void 0,"data-disabled":i.disabled||void 0,"data-hidden":i.hidden||void 0,"data-outside":e.outside||void 0,"data-focused":i.focused||void 0,"data-today":i.today||void 0},!i.hidden&&_e?v.createElement(r.DayButton,{className:c[jj.DayButton],style:C?.[jj.DayButton],type:`button`,day:e,modifiers:i,disabled:!i.focused&&i.disabled||void 0,"aria-disabled":i.focused&&i.disabled||void 0,tabIndex:H(e)?0:-1,"aria-label":ae(n,i,o.options,o),onClick:be(e,i),onBlur:Se(e,i),onFocus:xe(e,i),onKeyDown:Ce(e,i),onMouseEnter:we(e,i),onMouseLeave:Te(e,i)},T(n,o.options,o)):!i.hidden&&T(e.date,o.options,o))})))))))),t.footer&&v.createElement(r.Footer,{className:c[jj.Footer],style:C?.[jj.Footer],role:`status`,"aria-live":`polite`},t.footer)))}function FN({className:e,classNames:t,showOutsideDays:n=!0,captionLayout:r=`label`,buttonVariant:i=`ghost`,formatters:a,components:o,...s}){let c=_M();return(0,U.jsx)(PN,{showOutsideDays:n,className:q(`group/calendar bg-background p-3 [--cell-size:--spacing(8)] [[data-slot=card-content]_&]:bg-transparent [[data-slot=popover-content]_&]:bg-transparent`,String.raw`rtl:**:[.rdp-button\_next>svg]:rotate-180`,String.raw`rtl:**:[.rdp-button\_previous>svg]:rotate-180`,e),captionLayout:r,formatters:{formatMonthDropdown:e=>e.toLocaleString(`default`,{month:`short`}),...a},classNames:{root:q(`w-fit`,c.root),months:q(`relative flex flex-col gap-4 md:flex-row`,c.months),month:q(`flex w-full flex-col gap-4`,c.month),nav:q(`absolute inset-x-0 top-0 flex w-full items-center justify-between gap-1`,c.nav),button_previous:q(Xc({variant:i}),`size-(--cell-size) p-0 select-none aria-disabled:opacity-50`,c.button_previous),button_next:q(Xc({variant:i}),`size-(--cell-size) p-0 select-none aria-disabled:opacity-50`,c.button_next),month_caption:q(`flex h-(--cell-size) w-full items-center justify-center px-(--cell-size)`,c.month_caption),dropdowns:q(`flex h-(--cell-size) w-full items-center justify-center gap-1.5 text-sm font-medium`,c.dropdowns),dropdown_root:q(`relative rounded-md border border-input shadow-xs has-focus:border-ring has-focus:ring-[3px] has-focus:ring-ring/50`,c.dropdown_root),dropdown:q(`absolute inset-0 bg-popover opacity-0`,c.dropdown),caption_label:q(`font-medium select-none`,r===`label`?`text-sm`:`flex h-8 items-center gap-1 rounded-md pr-1 pl-2 text-sm [&>svg]:size-3.5 [&>svg]:text-muted-foreground`,c.caption_label),table:`w-full border-collapse`,weekdays:q(`flex`,c.weekdays),weekday:q(`flex-1 rounded-md text-[0.8rem] font-normal text-muted-foreground select-none`,c.weekday),week:q(`mt-2 flex w-full`,c.week),week_number_header:q(`w-(--cell-size) select-none`,c.week_number_header),week_number:q(`text-[0.8rem] text-muted-foreground select-none`,c.week_number),day:q(`group/day relative aspect-square h-full w-full p-0 text-center select-none [&:last-child[data-selected=true]_button]:rounded-r-md`,s.showWeekNumber?`[&:nth-child(2)[data-selected=true]_button]:rounded-l-md`:`[&:first-child[data-selected=true]_button]:rounded-l-md`,c.day),range_start:q(`rounded-l-md bg-accent`,c.range_start),range_middle:q(`rounded-none`,c.range_middle),range_end:q(`rounded-r-md bg-accent`,c.range_end),today:q(`rounded-md bg-accent text-accent-foreground data-[selected=true]:rounded-none`,c.today),outside:q(`text-muted-foreground aria-selected:text-muted-foreground`,c.outside),disabled:q(`text-muted-foreground opacity-50`,c.disabled),hidden:q(`invisible`,c.hidden),...t},components:{Root:({className:e,rootRef:t,...n})=>(0,U.jsx)(`div`,{"data-slot":`calendar`,ref:t,className:q(e),...n}),Chevron:({className:e,orientation:t,...n})=>t===`left`?(0,U.jsx)(Va,{className:q(`size-4`,e),...n}):t===`right`?(0,U.jsx)(Ha,{className:q(`size-4`,e),...n}):(0,U.jsx)(Ba,{className:q(`size-4`,e),...n}),DayButton:IN,WeekNumber:({children:e,...t})=>(0,U.jsx)(`td`,{...t,children:(0,U.jsx)(`div`,{className:`flex size-(--cell-size) items-center justify-center text-center`,children:e})}),...o},...s})}function IN({className:e,day:t,modifiers:n,...r}){let i=_M(),a=v.useRef(null);return v.useEffect(()=>{n.focused&&a.current?.focus()},[n.focused]),(0,U.jsx)(J,{ref:a,variant:`ghost`,size:`icon`,"data-day":t.date.toLocaleDateString(),"data-selected-single":n.selected&&!n.range_start&&!n.range_end&&!n.range_middle,"data-range-start":n.range_start,"data-range-end":n.range_end,"data-range-middle":n.range_middle,className:q(`flex aspect-square size-auto w-full min-w-(--cell-size) flex-col gap-1 leading-none font-normal`,`group-data-[focused=true]/day:relative group-data-[focused=true]/day:z-10`,`group-data-[focused=true]/day:border-ring group-data-[focused=true]/day:ring-[3px] group-data-[focused=true]/day:ring-ring/50`,`data-[range-end=true]:rounded-md data-[range-end=true]:bg-primary data-[range-end=true]:text-primary-foreground`,`data-[range-middle=true]:rounded-none data-[range-middle=true]:bg-accent data-[range-middle=true]:text-accent-foreground`,`data-[range-start=true]:rounded-md data-[range-start=true]:bg-primary data-[range-start=true]:text-primary-foreground`,`data-[selected-single=true]:bg-primary data-[selected-single=true]:text-primary-foreground`,`dark:hover:text-accent-foreground [&>span]:text-xs [&>span]:opacity-70`,i.day,e),...r})}function LN({...e}){return(0,U.jsx)(tS,{"data-slot":`popover`,...e})}function RN({...e}){return(0,U.jsx)(nS,{"data-slot":`popover-trigger`,...e})}function zN({className:e,align:t=`center`,sideOffset:n=4,...r}){return(0,U.jsx)(rS,{children:(0,U.jsx)(iS,{"data-slot":`popover-content`,align:t,sideOffset:n,className:q(`z-50 w-72 origin-(--radix-popover-content-transform-origin) rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-hidden`,`data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,`data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95`,`data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95`,e),...r})})}var BN=v.forwardRef(({className:e,...t},n)=>(0,U.jsx)(`textarea`,{className:q(`flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50`,e),ref:n,...t}));BN.displayName=`Textarea`;function VN({...e}){return(0,U.jsx)(yb,{"data-slot":`accordion`,...e})}function HN({className:e,...t}){return(0,U.jsx)(bb,{"data-slot":`accordion-item`,className:q(`border-b last:border-b-0`,e),...t})}function UN({className:e,children:t,...n}){return(0,U.jsx)(xb,{className:`flex`,children:(0,U.jsxs)(Sb,{"data-slot":`accordion-trigger`,className:q(`flex flex-1 items-start justify-between gap-4 rounded-md py-4 text-left text-sm font-medium transition-all outline-none hover:underline focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 [&[data-state=open]>svg]:rotate-180`,e),...n,children:[t,(0,U.jsx)(Ba,{className:`pointer-events-none size-4 shrink-0 translate-y-0.5 text-muted-foreground transition-transform duration-200`})]})})}function WN({className:e,children:t,...n}){return(0,U.jsx)(Cb,{"data-slot":`accordion-content`,className:`overflow-hidden text-sm data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down`,...n,children:(0,U.jsx)(`div`,{className:q(`pt-0 pb-4`,e),children:t})})}function GN(e){this.content=e}GN.prototype={constructor:GN,find:function(e){for(var t=0;t<this.content.length;t+=2)if(this.content[t]===e)return t;return-1},get:function(e){var t=this.find(e);return t==-1?void 0:this.content[t+1]},update:function(e,t,n){var r=n&&n!=e?this.remove(n):this,i=r.find(e),a=r.content.slice();return i==-1?a.push(n||e,t):(a[i+1]=t,n&&(a[i]=n)),new GN(a)},remove:function(e){var t=this.find(e);if(t==-1)return this;var n=this.content.slice();return n.splice(t,2),new GN(n)},addToStart:function(e,t){return new GN([e,t].concat(this.remove(e).content))},addToEnd:function(e,t){var n=this.remove(e).content.slice();return n.push(e,t),new GN(n)},addBefore:function(e,t,n){var r=this.remove(t),i=r.content.slice(),a=r.find(e);return i.splice(a==-1?i.length:a,0,t,n),new GN(i)},forEach:function(e){for(var t=0;t<this.content.length;t+=2)e(this.content[t],this.content[t+1])},prepend:function(e){return e=GN.from(e),e.size?new GN(e.content.concat(this.subtract(e).content)):this},append:function(e){return e=GN.from(e),e.size?new GN(this.subtract(e).content.concat(e.content)):this},subtract:function(e){var t=this;e=GN.from(e);for(var n=0;n<e.content.length;n+=2)t=t.remove(e.content[n]);return t},toObject:function(){var e={};return this.forEach(function(t,n){e[t]=n}),e},get size(){return this.content.length>>1}},GN.from=function(e){if(e instanceof GN)return e;var t=[];if(e)for(var n in e)t.push(n,e[n]);return new GN(t)};function KN(e,t,n){for(let r=0;;r++){if(r==e.childCount||r==t.childCount)return e.childCount==t.childCount?null:n;let i=e.child(r),a=t.child(r);if(i==a){n+=i.nodeSize;continue}if(!i.sameMarkup(a))return n;if(i.isText&&i.text!=a.text){for(let e=0;i.text[e]==a.text[e];e++)n++;return n}if(i.content.size||a.content.size){let e=KN(i.content,a.content,n+1);if(e!=null)return e}n+=i.nodeSize}}function qN(e,t,n,r){for(let i=e.childCount,a=t.childCount;;){if(i==0||a==0)return i==a?null:{a:n,b:r};let o=e.child(--i),s=t.child(--a),c=o.nodeSize;if(o==s){n-=c,r-=c;continue}if(!o.sameMarkup(s))return{a:n,b:r};if(o.isText&&o.text!=s.text){let e=0,t=Math.min(o.text.length,s.text.length);for(;e<t&&o.text[o.text.length-e-1]==s.text[s.text.length-e-1];)e++,n--,r--;return{a:n,b:r}}if(o.content.size||s.content.size){let e=qN(o.content,s.content,n-1,r-1);if(e)return e}n-=c,r-=c}}var Z=class e{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let t=0;t<e.length;t++)this.size+=e[t].nodeSize}nodesBetween(e,t,n,r=0,i){for(let a=0,o=0;o<t;a++){let s=this.content[a],c=o+s.nodeSize;if(c>e&&n(s,r+o,i||null,a)!==!1&&s.content.size){let i=o+1;s.nodesBetween(Math.max(0,e-i),Math.min(s.content.size,t-i),n,r+i)}o=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,n,r){let i=``,a=!0;return this.nodesBetween(e,t,(o,s)=>{let c=o.isText?o.text.slice(Math.max(e,s)-s,t-s):o.isLeaf?r?typeof r==`function`?r(o):r:o.type.spec.leafText?o.type.spec.leafText(o):``:``;o.isBlock&&(o.isLeaf&&c||o.isTextblock)&&n&&(a?a=!1:i+=n),i+=c},0),i}append(t){if(!t.size)return this;if(!this.size)return t;let n=this.lastChild,r=t.firstChild,i=this.content.slice(),a=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),a=1);a<t.content.length;a++)i.push(t.content[a]);return new e(i,this.size+t.size)}cut(t,n=this.size){if(t==0&&n==this.size)return this;let r=[],i=0;if(n>t)for(let e=0,a=0;a<n;e++){let o=this.content[e],s=a+o.nodeSize;s>t&&((a<t||s>n)&&(o=o.isText?o.cut(Math.max(0,t-a),Math.min(o.text.length,n-a)):o.cut(Math.max(0,t-a-1),Math.min(o.content.size,n-a-1))),r.push(o),i+=o.nodeSize),a=s}return new e(r,i)}cutByIndex(t,n){return t==n?e.empty:t==0&&n==this.content.length?this:new e(this.content.slice(t,n))}replaceChild(t,n){let r=this.content[t];if(r==n)return this;let i=this.content.slice(),a=this.size+n.nodeSize-r.nodeSize;return i[t]=n,new e(i,a)}addToStart(t){return new e([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new e(this.content.concat(t),this.size+t.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw RangeError(`Index `+e+` out of range for `+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,n=0;t<this.content.length;t++){let r=this.content[t];e(r,n,t),n+=r.nodeSize}}findDiffStart(e,t=0){return KN(this,e,t)}findDiffEnd(e,t=this.size,n=e.size){return qN(this,e,t,n)}findIndex(e){if(e==0)return YN(0,e);if(e==this.size)return YN(this.content.length,e);if(e>this.size||e<0)throw RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,n=0;;t++){let r=this.child(t),i=n+r.nodeSize;if(i>=e)return i==e?YN(t+1,i):YN(t,n);n=i}}toString(){return`<`+this.toStringInner()+`>`}toStringInner(){return this.content.join(`, `)}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(t,n){if(!n)return e.empty;if(!Array.isArray(n))throw RangeError(`Invalid input for Fragment.fromJSON`);return new e(n.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return e.empty;let n,r=0;for(let e=0;e<t.length;e++){let i=t[e];r+=i.nodeSize,e&&i.isText&&t[e-1].sameMarkup(i)?(n||=t.slice(0,e),n[n.length-1]=i.withText(n[n.length-1].text+i.text)):n&&n.push(i)}return new e(n||t,r)}static from(t){if(!t)return e.empty;if(t instanceof e)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new e([t],t.nodeSize);throw RangeError(`Can not convert `+t+` to a Fragment`+(t.nodesBetween?` (looks like multiple versions of prosemirror-model were loaded)`:``))}};Z.empty=new Z([],0);var JN={index:0,offset:0};function YN(e,t){return JN.index=e,JN.offset=t,JN}function XN(e,t){if(e===t)return!0;if(!(e&&typeof e==`object`)||!(t&&typeof t==`object`))return!1;let n=Array.isArray(e);if(Array.isArray(t)!=n)return!1;if(n){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!XN(e[n],t[n]))return!1}else{for(let n in e)if(!(n in t)||!XN(e[n],t[n]))return!1;for(let n in t)if(!(n in e))return!1}return!0}var ZN=class e{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,n=!1;for(let r=0;r<e.length;r++){let i=e[r];if(this.eq(i))return e;if(this.type.excludes(i.type))t||=e.slice(0,r);else if(i.type.excludes(this.type))return e;else !n&&i.type.rank>this.type.rank&&(t||=e.slice(0,r),t.push(this),n=!0),t&&t.push(i)}return t||=e.slice(),n||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&XN(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw RangeError(`Invalid input for Mark.fromJSON`);let n=e.marks[t.type];if(!n)throw RangeError(`There is no mark type ${t.type} in this schema`);let r=n.create(t.attrs);return n.checkAttrs(r.attrs),r}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].eq(t[n]))return!1;return!0}static setFrom(t){if(!t||Array.isArray(t)&&t.length==0)return e.none;if(t instanceof e)return[t];let n=t.slice();return n.sort((e,t)=>e.type.rank-t.type.rank),n}};ZN.none=[];var QN=class extends Error{},Q=class e{constructor(e,t,n){this.content=e,this.openStart=t,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,n){let r=eP(this.content,t+this.openStart,n);return r&&new e(r,this.openStart,this.openEnd)}removeBetween(t,n){return new e($N(this.content,t+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+`(`+this.openStart+`,`+this.openEnd+`)`}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(t,n){if(!n)return e.empty;let r=n.openStart||0,i=n.openEnd||0;if(typeof r!=`number`||typeof i!=`number`)throw RangeError(`Invalid input for Slice.fromJSON`);return new e(Z.fromJSON(t,n.content),r,i)}static maxOpen(t,n=!0){let r=0,i=0;for(let e=t.firstChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.firstChild)r++;for(let e=t.lastChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.lastChild)i++;return new e(t,r,i)}};Q.empty=new Q(Z.empty,0,0);function $N(e,t,n){let{index:r,offset:i}=e.findIndex(t),a=e.maybeChild(r),{index:o,offset:s}=e.findIndex(n);if(i==t||a.isText){if(s!=n&&!e.child(o).isText)throw RangeError(`Removing non-flat range`);return e.cut(0,t).append(e.cut(n))}if(r!=o)throw RangeError(`Removing non-flat range`);return e.replaceChild(r,a.copy($N(a.content,t-i-1,n-i-1)))}function eP(e,t,n,r){let{index:i,offset:a}=e.findIndex(t),o=e.maybeChild(i);if(a==t||o.isText)return r&&!r.canReplace(i,i,n)?null:e.cut(0,t).append(n).append(e.cut(t));let s=eP(o.content,t-a-1,n,o);return s&&e.replaceChild(i,o.copy(s))}function tP(e,t,n){if(n.openStart>e.depth)throw new QN(`Inserted content deeper than insertion position`);if(e.depth-n.openStart!=t.depth-n.openEnd)throw new QN(`Inconsistent open depths`);return nP(e,t,n,0)}function nP(e,t,n,r){let i=e.index(r),a=e.node(r);if(i==t.index(r)&&r<e.depth-n.openStart){let o=nP(e,t,n,r+1);return a.copy(a.content.replaceChild(i,o))}else if(!n.content.size)return sP(a,lP(e,t,r));else if(!n.openStart&&!n.openEnd&&e.depth==r&&t.depth==r){let r=e.parent,i=r.content;return sP(r,i.cut(0,e.parentOffset).append(n.content).append(i.cut(t.parentOffset)))}else{let{start:i,end:o}=uP(n,e);return sP(a,cP(e,i,o,t,r))}}function rP(e,t){if(!t.type.compatibleContent(e.type))throw new QN(`Cannot join `+t.type.name+` onto `+e.type.name)}function iP(e,t,n){let r=e.node(n);return rP(r,t.node(n)),r}function aP(e,t){let n=t.length-1;n>=0&&e.isText&&e.sameMarkup(t[n])?t[n]=e.withText(t[n].text+e.text):t.push(e)}function oP(e,t,n,r){let i=(t||e).node(n),a=0,o=t?t.index(n):i.childCount;e&&(a=e.index(n),e.depth>n?a++:e.textOffset&&(aP(e.nodeAfter,r),a++));for(let e=a;e<o;e++)aP(i.child(e),r);t&&t.depth==n&&t.textOffset&&aP(t.nodeBefore,r)}function sP(e,t){return e.type.checkContent(t),e.copy(t)}function cP(e,t,n,r,i){let a=e.depth>i&&iP(e,t,i+1),o=r.depth>i&&iP(n,r,i+1),s=[];return oP(null,e,i,s),a&&o&&t.index(i)==n.index(i)?(rP(a,o),aP(sP(a,cP(e,t,n,r,i+1)),s)):(a&&aP(sP(a,lP(e,t,i+1)),s),oP(t,n,i,s),o&&aP(sP(o,lP(n,r,i+1)),s)),oP(r,null,i,s),new Z(s)}function lP(e,t,n){let r=[];return oP(null,e,n,r),e.depth>n&&aP(sP(iP(e,t,n+1),lP(e,t,n+1)),r),oP(t,null,n,r),new Z(r)}function uP(e,t){let n=t.depth-e.openStart,r=t.node(n).copy(e.content);for(let e=n-1;e>=0;e--)r=t.node(e).copy(Z.from(r));return{start:r.resolveNoCache(e.openStart+n),end:r.resolveNoCache(r.content.size-e.openEnd-n)}}var dP=class e{constructor(e,t,n){this.pos=e,this.path=t,this.parentOffset=n,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw RangeError(`There is no position before the top-level node`);return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw RangeError(`There is no position after the top-level node`);return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let n=this.pos-this.path[this.path.length-1],r=e.child(t);return n?e.child(t).cut(n):r}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let n=this.path[t*3],r=t==0?0:this.path[t*3-1]+1;for(let t=0;t<e;t++)r+=n.child(t).nodeSize;return r}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return ZN.none;if(this.textOffset)return e.child(t).marks;let n=e.maybeChild(t-1),r=e.maybeChild(t);if(!n){let e=n;n=r,r=e}let i=n.marks;for(var a=0;a<i.length;a++)i[a].type.spec.inclusive===!1&&(!r||!i[a].isInSet(r.marks))&&(i=i[a--].removeFromSet(i));return i}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let n=t.marks,r=e.parent.maybeChild(e.index());for(var i=0;i<n.length;i++)n[i].type.spec.inclusive===!1&&(!r||!n[i].isInSet(r.marks))&&(n=n[i--].removeFromSet(n));return n}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let n=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);n>=0;n--)if(e.pos<=this.end(n)&&(!t||t(this.node(n))))return new hP(this,e,n);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e=``;for(let t=1;t<=this.depth;t++)e+=(e?`/`:``)+this.node(t).type.name+`_`+this.index(t-1);return e+`:`+this.parentOffset}static resolve(t,n){if(!(n>=0&&n<=t.content.size))throw RangeError(`Position `+n+` out of range`);let r=[],i=0,a=n;for(let e=t;;){let{index:t,offset:n}=e.content.findIndex(a),o=a-n;if(r.push(e,t,i+n),!o||(e=e.child(t),e.isText))break;a=o-1,i+=n+1}return new e(n,r,a)}static resolveCached(t,n){let r=mP.get(t);if(r)for(let e=0;e<r.elts.length;e++){let t=r.elts[e];if(t.pos==n)return t}else mP.set(t,r=new fP);let i=r.elts[r.i]=e.resolve(t,n);return r.i=(r.i+1)%pP,i}},fP=class{constructor(){this.elts=[],this.i=0}},pP=12,mP=new WeakMap,hP=class{constructor(e,t,n){this.$from=e,this.$to=t,this.depth=n}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}},gP=Object.create(null),_P=class e{constructor(e,t,n,r=ZN.none){this.type=e,this.attrs=t,this.marks=r,this.content=n||Z.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,n,r=0){this.content.nodesBetween(e,t,n,r,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,``)}textBetween(e,t,n,r){return this.content.textBetween(e,t,n,r)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,n){return this.type==e&&XN(this.attrs,t||e.defaultAttrs||gP)&&ZN.sameSet(this.marks,n||ZN.none)}copy(t=null){return t==this.content?this:new e(this.type,this.attrs,t,this.marks)}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.content,t)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,n=!1){if(e==t)return Q.empty;let r=this.resolve(e),i=this.resolve(t),a=n?0:r.sharedDepth(t),o=r.start(a);return new Q(r.node(a).content.cut(r.pos-o,i.pos-o),r.depth-a,i.depth-a)}replace(e,t,n){return tP(this.resolve(e),this.resolve(t),n)}nodeAt(e){for(let t=this;;){let{index:n,offset:r}=t.content.findIndex(e);if(t=t.maybeChild(n),!t)return null;if(r==e||t.isText)return t;e-=r+1}}childAfter(e){let{index:t,offset:n}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:n}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:n}=this.content.findIndex(e);if(n<e)return{node:this.content.child(t),index:t,offset:n};let r=this.content.child(t-1);return{node:r,index:t-1,offset:n-r.nodeSize}}resolve(e){return dP.resolveCached(this,e)}resolveNoCache(e){return dP.resolve(this,e)}rangeHasMark(e,t,n){let r=!1;return t>e&&this.nodesBetween(e,t,e=>(n.isInSet(e.marks)&&(r=!0),!r)),r}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+=`(`+this.content.toStringInner()+`)`),yP(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw Error(`Called contentMatchAt on a node with invalid content`);return t}canReplace(e,t,n=Z.empty,r=0,i=n.childCount){let a=this.contentMatchAt(e).matchFragment(n,r,i),o=a&&a.matchFragment(this.content,t);if(!o||!o.validEnd)return!1;for(let e=r;e<i;e++)if(!this.type.allowsMarks(n.child(e).marks))return!1;return!0}canReplaceWith(e,t,n,r){if(r&&!this.type.allowsMarks(r))return!1;let i=this.contentMatchAt(e).matchType(n),a=i&&i.matchFragment(this.content,t);return a?a.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=ZN.none;for(let t=0;t<this.marks.length;t++){let n=this.marks[t];n.type.checkAttrs(n.attrs),e=n.addToSet(e)}if(!ZN.sameSet(e,this.marks))throw RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(e=>e.type.name)}`);this.content.forEach(e=>e.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(e=>e.toJSON())),e}static fromJSON(e,t){if(!t)throw RangeError(`Invalid input for Node.fromJSON`);let n;if(t.marks){if(!Array.isArray(t.marks))throw RangeError(`Invalid mark data for Node.fromJSON`);n=t.marks.map(e.markFromJSON)}if(t.type==`text`){if(typeof t.text!=`string`)throw RangeError(`Invalid text node in JSON`);return e.text(t.text,n)}let r=Z.fromJSON(e,t.content),i=e.nodeType(t.type).create(t.attrs,r,n);return i.type.checkAttrs(i.attrs),i}};_P.prototype.text=void 0;var vP=class e extends _P{constructor(e,t,n,r){if(super(e,t,null,r),!n)throw RangeError(`Empty text nodes are not allowed`);this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):yP(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.text,t)}withText(t){return t==this.text?this:new e(this.type,this.attrs,t,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}};function yP(e,t){for(let n=e.length-1;n>=0;n--)t=e[n].type.name+`(`+t+`)`;return t}var bP=class e{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(t,n){let r=new xP(t,n);if(r.next==null)return e.empty;let i=SP(r);r.next&&r.err(`Unexpected trailing text`);let a=MP(kP(i));return NP(a,r),a}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,n=e.childCount){let r=this;for(let i=t;r&&i<n;i++)r=r.matchType(e.child(i).type);return r}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let n=0;n<e.next.length;n++)if(this.next[t].type==e.next[n].type)return!0;return!1}fillBefore(e,t=!1,n=0){let r=[this];function i(a,o){let s=a.matchFragment(e,n);if(s&&(!t||s.validEnd))return Z.from(o.map(e=>e.createAndFill()));for(let e=0;e<a.next.length;e++){let{type:t,next:n}=a.next[e];if(!(t.isText||t.hasRequiredAttrs())&&r.indexOf(n)==-1){r.push(n);let e=i(n,o.concat(t));if(e)return e}}return null}return i(this,[])}findWrapping(e){for(let t=0;t<this.wrapCache.length;t+=2)if(this.wrapCache[t]==e)return this.wrapCache[t+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),n=[{match:this,type:null,via:null}];for(;n.length;){let r=n.shift(),i=r.match;if(i.matchType(e)){let e=[];for(let t=r;t.type;t=t.via)e.push(t.type);return e.reverse()}for(let e=0;e<i.next.length;e++){let{type:a,next:o}=i.next[e];!a.isLeaf&&!a.hasRequiredAttrs()&&!(a.name in t)&&(!r.type||o.validEnd)&&(n.push({match:a.contentMatch,type:a,via:r}),t[a.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(n){e.push(n);for(let r=0;r<n.next.length;r++)e.indexOf(n.next[r].next)==-1&&t(n.next[r].next)}return t(this),e.map((t,n)=>{let r=n+(t.validEnd?`*`:` `)+` `;for(let n=0;n<t.next.length;n++)r+=(n?`, `:``)+t.next[n].type.name+`->`+e.indexOf(t.next[n].next);return r}).join(`
80
80
  `)}};bP.empty=new bP(!0);var xP=class{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==``&&this.tokens.pop(),this.tokens[0]==``&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw SyntaxError(e+` (in content expression '`+this.string+`')`)}};function SP(e){let t=[];do t.push(CP(e));while(e.eat(`|`));return t.length==1?t[0]:{type:`choice`,exprs:t}}function CP(e){let t=[];do t.push(wP(e));while(e.next&&e.next!=`)`&&e.next!=`|`);return t.length==1?t[0]:{type:`seq`,exprs:t}}function wP(e){let t=OP(e);for(;;)if(e.eat(`+`))t={type:`plus`,expr:t};else if(e.eat(`*`))t={type:`star`,expr:t};else if(e.eat(`?`))t={type:`opt`,expr:t};else if(e.eat(`{`))t=EP(e,t);else break;return t}function TP(e){/\D/.test(e.next)&&e.err(`Expected number, got '`+e.next+`'`);let t=Number(e.next);return e.pos++,t}function EP(e,t){let n=TP(e),r=n;return e.eat(`,`)&&(r=e.next==`}`?-1:TP(e)),e.eat(`}`)||e.err(`Unclosed braced range`),{type:`range`,min:n,max:r,expr:t}}function DP(e,t){let n=e.nodeTypes,r=n[t];if(r)return[r];let i=[];for(let e in n){let r=n[e];r.isInGroup(t)&&i.push(r)}return i.length==0&&e.err(`No node type or group '`+t+`' found`),i}function OP(e){if(e.eat(`(`)){let t=SP(e);return e.eat(`)`)||e.err(`Missing closing paren`),t}else if(/\W/.test(e.next))e.err(`Unexpected token '`+e.next+`'`);else{let t=DP(e,e.next).map(t=>(e.inline==null?e.inline=t.isInline:e.inline!=t.isInline&&e.err(`Mixing inline and block content`),{type:`name`,value:t}));return e.pos++,t.length==1?t[0]:{type:`choice`,exprs:t}}}function kP(e){let t=[[]];return i(a(e,0),n()),t;function n(){return t.push([])-1}function r(e,n,r){let i={term:r,to:n};return t[e].push(i),i}function i(e,t){e.forEach(e=>e.to=t)}function a(e,t){if(e.type==`choice`)return e.exprs.reduce((e,n)=>e.concat(a(n,t)),[]);if(e.type==`seq`)for(let r=0;;r++){let o=a(e.exprs[r],t);if(r==e.exprs.length-1)return o;i(o,t=n())}else if(e.type==`star`){let o=n();return r(t,o),i(a(e.expr,o),o),[r(o)]}else if(e.type==`plus`){let o=n();return i(a(e.expr,t),o),i(a(e.expr,o),o),[r(o)]}else if(e.type==`opt`)return[r(t)].concat(a(e.expr,t));else if(e.type==`range`){let o=t;for(let t=0;t<e.min;t++){let t=n();i(a(e.expr,o),t),o=t}if(e.max==-1)i(a(e.expr,o),o);else for(let t=e.min;t<e.max;t++){let t=n();r(o,t),i(a(e.expr,o),t),o=t}return[r(o)]}else if(e.type==`name`)return[r(t,void 0,e.value)];else throw Error(`Unknown expr type`)}}function AP(e,t){return t-e}function jP(e,t){let n=[];return r(t),n.sort(AP);function r(t){let i=e[t];if(i.length==1&&!i[0].term)return r(i[0].to);n.push(t);for(let e=0;e<i.length;e++){let{term:t,to:a}=i[e];!t&&n.indexOf(a)==-1&&r(a)}}}function MP(e){let t=Object.create(null);return n(jP(e,0));function n(r){let i=[];r.forEach(t=>{e[t].forEach(({term:t,to:n})=>{if(!t)return;let r;for(let e=0;e<i.length;e++)i[e][0]==t&&(r=i[e][1]);jP(e,n).forEach(e=>{r||i.push([t,r=[]]),r.indexOf(e)==-1&&r.push(e)})})});let a=t[r.join(`,`)]=new bP(r.indexOf(e.length-1)>-1);for(let e=0;e<i.length;e++){let r=i[e][1].sort(AP);a.next.push({type:i[e][0],next:t[r.join(`,`)]||n(r)})}return a}}function NP(e,t){for(let n=0,r=[e];n<r.length;n++){let e=r[n],i=!e.validEnd,a=[];for(let t=0;t<e.next.length;t++){let{type:n,next:o}=e.next[t];a.push(n.name),i&&!(n.isText||n.hasRequiredAttrs())&&(i=!1),r.indexOf(o)==-1&&r.push(o)}i&&t.err(`Only non-generatable nodes (`+a.join(`, `)+`) in a required position (see https://prosemirror.net/docs/guide/#generatable)`)}}function PP(e){let t=Object.create(null);for(let n in e){let r=e[n];if(!r.hasDefault)return null;t[n]=r.default}return t}function FP(e,t){let n=Object.create(null);for(let r in e){let i=t&&t[r];if(i===void 0){let t=e[r];if(t.hasDefault)i=t.default;else throw RangeError(`No value supplied for attribute `+r)}n[r]=i}return n}function IP(e,t,n,r){for(let r in t)if(!(r in e))throw RangeError(`Unsupported attribute ${r} for ${n} of type ${r}`);for(let n in e){let r=e[n];r.validate&&r.validate(t[n])}}function LP(e,t){let n=Object.create(null);if(t)for(let r in t)n[r]=new BP(e,r,t[r]);return n}var RP=class e{constructor(e,t,n){this.name=e,this.schema=t,this.spec=n,this.markSet=null,this.groups=n.group?n.group.split(` `):[],this.attrs=LP(e,n.attrs),this.defaultAttrs=PP(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(n.inline||e==`text`),this.isText=e==`text`}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==bP.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?`pre`:`normal`)}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:FP(this.attrs,e)}create(e=null,t,n){if(this.isText)throw Error(`NodeType.create can't construct text nodes`);return new _P(this,this.computeAttrs(e),Z.from(t),ZN.setFrom(n))}createChecked(e=null,t,n){return t=Z.from(t),this.checkContent(t),new _P(this,this.computeAttrs(e),t,ZN.setFrom(n))}createAndFill(e=null,t,n){if(e=this.computeAttrs(e),t=Z.from(t),t.size){let e=this.contentMatch.fillBefore(t);if(!e)return null;t=e.append(t)}let r=this.contentMatch.matchFragment(t),i=r&&r.fillBefore(Z.empty,!0);return i?new _P(this,e,t.append(i),ZN.setFrom(n)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let t=0;t<e.childCount;t++)if(!this.allowsMarks(e.child(t).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){IP(this.attrs,e,`node`,this.name)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let t;for(let n=0;n<e.length;n++)this.allowsMarkType(e[n].type)?t&&t.push(e[n]):t||=e.slice(0,n);return t?t.length?t:ZN.none:e}static compile(t,n){let r=Object.create(null);t.forEach((t,i)=>r[t]=new e(t,n,i));let i=n.spec.topNode||`doc`;if(!r[i])throw RangeError(`Schema is missing its top node type ('`+i+`')`);if(!r.text)throw RangeError(`Every schema needs a 'text' type`);for(let e in r.text.attrs)throw RangeError(`The text node type should not have attributes`);return r}};function zP(e,t,n){let r=n.split(`|`);return n=>{let i=n===null?`null`:typeof n;if(r.indexOf(i)<0)throw RangeError(`Expected value of type ${r} for attribute ${t} on type ${e}, got ${i}`)}}var BP=class{constructor(e,t,n){this.hasDefault=Object.prototype.hasOwnProperty.call(n,`default`),this.default=n.default,this.validate=typeof n.validate==`string`?zP(e,t,n.validate):n.validate}get isRequired(){return!this.hasDefault}},VP=class e{constructor(e,t,n,r){this.name=e,this.rank=t,this.schema=n,this.spec=r,this.attrs=LP(e,r.attrs),this.excluded=null;let i=PP(this.attrs);this.instance=i?new ZN(this,i):null}create(e=null){return!e&&this.instance?this.instance:new ZN(this,FP(this.attrs,e))}static compile(t,n){let r=Object.create(null),i=0;return t.forEach((t,a)=>r[t]=new e(t,i++,n,a)),r}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}checkAttrs(e){IP(this.attrs,e,`mark`,this.name)}excludes(e){return this.excluded.indexOf(e)>-1}},HP=class{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let n in e)t[n]=e[n];t.nodes=GN.from(e.nodes),t.marks=GN.from(e.marks||{}),this.nodes=RP.compile(this.spec.nodes,this),this.marks=VP.compile(this.spec.marks,this);let n=Object.create(null);for(let e in this.nodes){if(e in this.marks)throw RangeError(e+` can not be both a node and a mark`);let t=this.nodes[e],r=t.spec.content||``,i=t.spec.marks;if(t.contentMatch=n[r]||(n[r]=bP.parse(r,this.nodes)),t.inlineContent=t.contentMatch.inlineContent,t.spec.linebreakReplacement){if(this.linebreakReplacement)throw RangeError(`Multiple linebreak nodes defined`);if(!t.isInline||!t.isLeaf)throw RangeError(`Linebreak replacement nodes must be inline leaf nodes`);this.linebreakReplacement=t}t.markSet=i==`_`?null:i?UP(this,i.split(` `)):i==``||!t.inlineContent?[]:null}for(let e in this.marks){let t=this.marks[e],n=t.spec.excludes;t.excluded=n==null?[t]:n==``?[]:UP(this,n.split(` `))}this.nodeFromJSON=e=>_P.fromJSON(this,e),this.markFromJSON=e=>ZN.fromJSON(this,e),this.topNodeType=this.nodes[this.spec.topNode||`doc`],this.cached.wrappings=Object.create(null)}node(e,t=null,n,r){if(typeof e==`string`)e=this.nodeType(e);else if(!(e instanceof RP))throw RangeError(`Invalid node type: `+e);else if(e.schema!=this)throw RangeError(`Node type from different schema used (`+e.name+`)`);return e.createChecked(t,n,r)}text(e,t){let n=this.nodes.text;return new vP(n,n.defaultAttrs,e,ZN.setFrom(t))}mark(e,t){return typeof e==`string`&&(e=this.marks[e]),e.create(t)}nodeType(e){let t=this.nodes[e];if(!t)throw RangeError(`Unknown node type: `+e);return t}};function UP(e,t){let n=[];for(let r=0;r<t.length;r++){let i=t[r],a=e.marks[i],o=a;if(a)n.push(a);else for(let t in e.marks){let r=e.marks[t];(i==`_`||r.spec.group&&r.spec.group.split(` `).indexOf(i)>-1)&&n.push(o=r)}if(!o)throw SyntaxError(`Unknown mark type: '`+t[r]+`'`)}return n}function WP(e){return e.tag!=null}function GP(e){return e.style!=null}var KP=class e{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let n=this.matchedStyles=[];t.forEach(e=>{if(WP(e))this.tags.push(e);else if(GP(e)){let t=/[^=]*/.exec(e.style)[0];n.indexOf(t)<0&&n.push(t),this.styles.push(e)}}),this.normalizeLists=!this.tags.some(t=>{if(!/^(ul|ol)\b/.test(t.tag)||!t.node)return!1;let n=e.nodes[t.node];return n.contentMatch.matchType(n)})}parse(e,t={}){let n=new tF(this,t,!1);return n.addAll(e,ZN.none,t.from,t.to),n.finish()}parseSlice(e,t={}){let n=new tF(this,t,!0);return n.addAll(e,ZN.none,t.from,t.to),Q.maxOpen(n.finish())}matchTag(e,t,n){for(let r=n?this.tags.indexOf(n)+1:0;r<this.tags.length;r++){let n=this.tags[r];if(rF(e,n.tag)&&(n.namespace===void 0||e.namespaceURI==n.namespace)&&(!n.context||t.matchesContext(n.context))){if(n.getAttrs){let t=n.getAttrs(e);if(t===!1)continue;n.attrs=t||void 0}return n}}}matchStyle(e,t,n,r){for(let i=r?this.styles.indexOf(r)+1:0;i<this.styles.length;i++){let r=this.styles[i],a=r.style;if(!(a.indexOf(e)!=0||r.context&&!n.matchesContext(r.context)||a.length>e.length&&(a.charCodeAt(e.length)!=61||a.slice(e.length+1)!=t))){if(r.getAttrs){let e=r.getAttrs(t);if(e===!1)continue;r.attrs=e||void 0}return r}}}static schemaRules(e){let t=[];function n(e){let n=e.priority==null?50:e.priority,r=0;for(;r<t.length;r++){let e=t[r];if((e.priority==null?50:e.priority)<n)break}t.splice(r,0,e)}for(let t in e.marks){let r=e.marks[t].spec.parseDOM;r&&r.forEach(e=>{n(e=iF(e)),e.mark||e.ignore||e.clearMark||(e.mark=t)})}for(let t in e.nodes){let r=e.nodes[t].spec.parseDOM;r&&r.forEach(e=>{n(e=iF(e)),e.node||e.ignore||e.mark||(e.node=t)})}return t}static fromSchema(t){return t.cached.domParser||(t.cached.domParser=new e(t,e.schemaRules(t)))}},qP={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},JP={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},YP={ol:!0,ul:!0},XP=1,ZP=2,QP=4;function $P(e,t,n){return t==null?e&&e.whitespace==`pre`?XP|ZP:n&~QP:(t?XP:0)|(t===`full`?ZP:0)}var eF=class{constructor(e,t,n,r,i,a){this.type=e,this.attrs=t,this.marks=n,this.solid=r,this.options=a,this.content=[],this.activeMarks=ZN.none,this.match=i||(a&QP?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(Z.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let t=this.type.contentMatch,n;return(n=t.findWrapping(e.type))?(this.match=t,n):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&XP)){let e=this.content[this.content.length-1],t;if(e&&e.isText&&(t=/[ \t\r\n\u000c]+$/.exec(e.text))){let n=e;e.text.length==t[0].length?this.content.pop():this.content[this.content.length-1]=n.withText(n.text.slice(0,n.text.length-t[0].length))}}let t=Z.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(Z.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!qP.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}},tF=class{constructor(e,t,n){this.parser=e,this.options=t,this.isOpen=n,this.open=0,this.localPreserveWS=!1;let r=t.topNode,i,a=$P(null,t.preserveWhitespace,0)|(n?QP:0);i=r?new eF(r.type,r.attrs,ZN.none,!0,t.topMatch||r.type.contentMatch,a):n?new eF(null,null,ZN.none,!0,null,a):new eF(e.schema.topNodeType,null,ZN.none,!0,null,a),this.nodes=[i],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let n=e.nodeValue,r=this.top,i=r.options&ZP?`full`:this.localPreserveWS||(r.options&XP)>0,{schema:a}=this.parser;if(i===`full`||r.inlineContext(e)||/[^ \t\r\n\u000c]/.test(n)){if(!i){if(n=n.replace(/[ \t\r\n\u000c]+/g,` `),/^[ \t\r\n\u000c]/.test(n)&&this.open==this.nodes.length-1){let t=r.content[r.content.length-1],i=e.previousSibling;(!t||i&&i.nodeName==`BR`||t.isText&&/[ \t\r\n\u000c]$/.test(t.text))&&(n=n.slice(1))}}else if(i===`full`)n=n.replace(/\r\n?/g,`
81
81
  `);else if(a.linebreakReplacement&&/[\r\n]/.test(n)&&this.top.findWrapping(a.linebreakReplacement.create())){let e=n.split(/\r?\n|\r/);for(let n=0;n<e.length;n++)n&&this.insertNode(a.linebreakReplacement.create(),t,!0),e[n]&&this.insertNode(a.text(e[n]),t,!/\S/.test(e[n]));n=``}else n=n.replace(/\r?\n|\r/g,` `);n&&this.insertNode(a.text(n),t,!/\S/.test(n)),this.findInText(e)}else this.findInside(e)}addElement(e,t,n){let r=this.localPreserveWS,i=this.top;(e.tagName==`PRE`||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let a=e.nodeName.toLowerCase(),o;YP.hasOwnProperty(a)&&this.parser.normalizeLists&&nF(e);let s=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(o=this.parser.matchTag(e,this,n));out:if(s?s.ignore:JP.hasOwnProperty(a))this.findInside(e),this.ignoreFallback(e,t);else if(!s||s.skip||s.closeParent){s&&s.closeParent?this.open=Math.max(0,this.open-1):s&&s.skip.nodeType&&(e=s.skip);let n,r=this.needsBlock;if(qP.hasOwnProperty(a))i.content.length&&i.content[0].isInline&&this.open&&(this.open--,i=this.top),n=!0,i.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break out}let o=s&&s.skip?t:this.readStyles(e,t);o&&this.addAll(e,o),n&&this.sync(i),this.needsBlock=r}else{let n=this.readStyles(e,t);n&&this.addElementByRule(e,s,n,s.consuming===!1?o:void 0)}this.localPreserveWS=r}leafFallback(e,t){e.nodeName==`BR`&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
82
82
  `),t)}ignoreFallback(e,t){e.nodeName==`BR`&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text(`-`),t,!0)}readStyles(e,t){let n=e.style;if(n&&n.length)for(let e=0;e<this.parser.matchedStyles.length;e++){let r=this.parser.matchedStyles[e],i=n.getPropertyValue(r);if(i)for(let e;;){let n=this.parser.matchStyle(r,i,this,e);if(!n)break;if(n.ignore)return null;if(t=n.clearMark?t.filter(e=>!n.clearMark(e)):t.concat(this.parser.schema.marks[n.mark].create(n.attrs)),n.consuming===!1)e=n;else break}}return t}addElementByRule(e,t,n,r){let i,a;if(t.node)if(a=this.parser.schema.nodes[t.node],a.isLeaf)this.insertNode(a.create(t.attrs),n,e.nodeName==`BR`)||this.leafFallback(e,n);else{let e=this.enter(a,t.attrs||null,n,t.preserveWhitespace);e&&(i=!0,n=e)}else{let e=this.parser.schema.marks[t.mark];n=n.concat(e.create(t.attrs))}let o=this.top;if(a&&a.isLeaf)this.findInside(e);else if(r)this.addElement(e,n,r);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(e=>this.insertNode(e,n,!1));else{let r=e;typeof t.contentElement==`string`?r=e.querySelector(t.contentElement):typeof t.contentElement==`function`?r=t.contentElement(e):t.contentElement&&(r=t.contentElement),this.findAround(e,r,!0),this.addAll(r,n),this.findAround(e,r,!1)}i&&this.sync(o)&&this.open--}addAll(e,t,n,r){let i=n||0;for(let a=n?e.childNodes[n]:e.firstChild,o=r==null?null:e.childNodes[r];a!=o;a=a.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(a,t);this.findAtPoint(e,i)}findPlace(e,t,n){let r,i;for(let t=this.open,a=0;t>=0;t--){let o=this.nodes[t],s=o.findWrapping(e);if(s&&(!r||r.length>s.length+a)&&(r=s,i=o,!s.length))break;if(o.solid){if(n)break;a+=2}}if(!r)return null;this.sync(i);for(let e=0;e<r.length;e++)t=this.enterInner(r[e],null,t,!1);return t}insertNode(e,t,n){if(e.isInline&&this.needsBlock&&!this.top.type){let e=this.textblockFromContext();e&&(t=this.enterInner(e,null,t))}let r=this.findPlace(e,t,n);if(r){this.closeExtra();let t=this.top;t.match&&=t.match.matchType(e.type);let n=ZN.none;for(let i of r.concat(e.marks))(t.type?t.type.allowsMarkType(i.type):aF(i.type,e.type))&&(n=i.addToSet(n));return t.content.push(e.mark(n)),!0}return!1}enter(e,t,n,r){let i=this.findPlace(e.create(t),n,!1);return i&&=this.enterInner(e,t,n,!0,r),i}enterInner(e,t,n,r=!1,i){this.closeExtra();let a=this.top;a.match=a.match&&a.match.matchType(e);let o=$P(e,i,a.options);a.options&QP&&a.content.length==0&&(o|=QP);let s=ZN.none;return n=n.filter(t=>(a.type?a.type.allowsMarkType(t.type):aF(t.type,e))?(s=t.addToSet(s),!1):!0),this.nodes.push(new eF(e,t,s,r,null,o)),this.open++,n}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--)if(this.nodes[t]==e)return this.open=t,!0;else this.localPreserveWS&&(this.nodes[t].options|=XP);return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let n=this.nodes[t].content;for(let t=n.length-1;t>=0;t--)e+=n[t].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&this.find[n].offset==t&&(this.find[n].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].pos==null&&e.nodeType==1&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,n){if(e!=t&&this.find)for(let r=0;r<this.find.length;r++)this.find[r].pos==null&&e.nodeType==1&&e.contains(this.find[r].node)&&t.compareDocumentPosition(this.find[r].node)&(n?2:4)&&(this.find[r].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf(`|`)>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split(`/`),n=this.options.context,r=!this.isOpen&&(!n||n.parent.type==this.nodes[0].type),i=-(n?n.depth+1:0)+ +!r,a=(e,o)=>{for(;e>=0;e--){let s=t[e];if(s==``){if(e==t.length-1||e==0)continue;for(;o>=i;o--)if(a(e-1,o))return!0;return!1}else{let e=o>0||o==0&&r?this.nodes[o].type:n&&o>=i?n.node(o-i).type:null;if(!e||e.name!=s&&!e.isInGroup(s))return!1;o--}}return!0};return a(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let n=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(let e in this.parser.schema.nodes){let t=this.parser.schema.nodes[e];if(t.isTextblock&&t.defaultAttrs)return t}}};function nF(e){for(let t=e.firstChild,n=null;t;t=t.nextSibling){let e=t.nodeType==1?t.nodeName.toLowerCase():null;e&&YP.hasOwnProperty(e)&&n?(n.appendChild(t),t=n):e==`li`?n=t:e&&(n=null)}}function rF(e,t){return(e.matches||e.msMatchesSelector||e.webkitMatchesSelector||e.mozMatchesSelector).call(e,t)}function iF(e){let t={};for(let n in e)t[n]=e[n];return t}function aF(e,t){let n=t.schema.nodes;for(let r in n){let i=n[r];if(!i.allowsMarkType(e))continue;let a=[],o=e=>{a.push(e);for(let n=0;n<e.edgeCount;n++){let{type:r,next:i}=e.edge(n);if(r==t||a.indexOf(i)<0&&o(i))return!0}};if(o(i.contentMatch))return!0}}var oF=class e{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},n){n||=cF(t).createDocumentFragment();let r=n,i=[];return e.forEach(e=>{if(i.length||e.marks.length){let n=0,a=0;for(;n<i.length&&a<e.marks.length;){let t=e.marks[a];if(!this.marks[t.type.name]){a++;continue}if(!t.eq(i[n][0])||t.type.spec.spanning===!1)break;n++,a++}for(;n<i.length;)r=i.pop()[1];for(;a<e.marks.length;){let n=e.marks[a++],o=this.serializeMark(n,e.isInline,t);o&&(i.push([n,r]),r.appendChild(o.dom),r=o.contentDOM||o.dom)}}r.appendChild(this.serializeNodeInner(e,t))}),n}serializeNodeInner(e,t){let{dom:n,contentDOM:r}=fF(cF(t),this.nodes[e.type.name](e),null,e.attrs);if(r){if(e.isLeaf)throw RangeError(`Content hole not allowed in a leaf node spec`);this.serializeFragment(e.content,t,r)}return n}serializeNode(e,t={}){let n=this.serializeNodeInner(e,t);for(let r=e.marks.length-1;r>=0;r--){let i=this.serializeMark(e.marks[r],e.isInline,t);i&&((i.contentDOM||i.dom).appendChild(n),n=i.dom)}return n}serializeMark(e,t,n={}){let r=this.marks[e.type.name];return r&&fF(cF(n),r(e,t),null,e.attrs)}static renderSpec(e,t,n=null,r){return fF(e,t,n,r)}static fromSchema(t){return t.cached.domSerializer||(t.cached.domSerializer=new e(this.nodesFromSchema(t),this.marksFromSchema(t)))}static nodesFromSchema(e){let t=sF(e.nodes);return t.text||=e=>e.text,t}static marksFromSchema(e){return sF(e.marks)}};function sF(e){let t={};for(let n in e){let r=e[n].spec.toDOM;r&&(t[n]=r)}return t}function cF(e){return e.document||window.document}var lF=new WeakMap;function uF(e){let t=lF.get(e);return t===void 0&&lF.set(e,t=dF(e)),t}function dF(e){let t=null;function n(e){if(e&&typeof e==`object`)if(Array.isArray(e))if(typeof e[0]==`string`)t||=[],t.push(e);else for(let t=0;t<e.length;t++)n(e[t]);else for(let t in e)n(e[t])}return n(e),t}function fF(e,t,n,r){if(typeof t==`string`)return{dom:e.createTextNode(t)};if(t.nodeType!=null)return{dom:t};if(t.dom&&t.dom.nodeType!=null)return t;let i=t[0],a;if(typeof i!=`string`)throw RangeError(`Invalid array passed to renderSpec`);if(r&&(a=uF(r))&&a.indexOf(t)>-1)throw RangeError(`Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.`);let o=i.indexOf(` `);o>0&&(n=i.slice(0,o),i=i.slice(o+1));let s,c=n?e.createElementNS(n,i):e.createElement(i),l=t[1],u=1;if(l&&typeof l==`object`&&l.nodeType==null&&!Array.isArray(l)){u=2;for(let e in l)if(l[e]!=null){let t=e.indexOf(` `);t>0?c.setAttributeNS(e.slice(0,t),e.slice(t+1),l[e]):e==`style`&&c.style?c.style.cssText=l[e]:c.setAttribute(e,l[e])}}for(let i=u;i<t.length;i++){let a=t[i];if(a===0){if(i<t.length-1||i>u)throw RangeError(`Content hole must be the only child of its parent node`);return{dom:c,contentDOM:c}}else{let{dom:t,contentDOM:i}=fF(e,a,n,r);if(c.appendChild(t),i){if(s)throw RangeError(`Multiple content holes`);s=i}}}return{dom:c,contentDOM:s}}var pF=65535,mF=2**16;function hF(e,t){return e+t*mF}function gF(e){return e&pF}function _F(e){return(e-(e&pF))/mF}var vF=1,yF=2,bF=4,xF=8,SF=class{constructor(e,t,n){this.pos=e,this.delInfo=t,this.recover=n}get deleted(){return(this.delInfo&xF)>0}get deletedBefore(){return(this.delInfo&(vF|bF))>0}get deletedAfter(){return(this.delInfo&(yF|bF))>0}get deletedAcross(){return(this.delInfo&bF)>0}},CF=class e{constructor(t,n=!1){if(this.ranges=t,this.inverted=n,!t.length&&e.empty)return e.empty}recover(e){let t=0,n=gF(e);if(!this.inverted)for(let e=0;e<n;e++)t+=this.ranges[e*3+2]-this.ranges[e*3+1];return this.ranges[n*3]+t+_F(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,n){let r=0,i=this.inverted?2:1,a=this.inverted?1:2;for(let o=0;o<this.ranges.length;o+=3){let s=this.ranges[o]-(this.inverted?r:0);if(s>e)break;let c=this.ranges[o+i],l=this.ranges[o+a],u=s+c;if(e<=u){let i=c?e==s?-1:e==u?1:t:t,a=s+r+(i<0?0:l);if(n)return a;let d=e==(t<0?s:u)?null:hF(o/3,e-s),f=e==s?yF:e==u?vF:bF;return(t<0?e!=s:e!=u)&&(f|=xF),new SF(a,f,d)}r+=l-c}return n?e+r:new SF(e+r,0,null)}touches(e,t){let n=0,r=gF(t),i=this.inverted?2:1,a=this.inverted?1:2;for(let t=0;t<this.ranges.length;t+=3){let o=this.ranges[t]-(this.inverted?n:0);if(o>e)break;let s=this.ranges[t+i];if(e<=o+s&&t==r*3)return!0;n+=this.ranges[t+a]-s}return!1}forEach(e){let t=this.inverted?2:1,n=this.inverted?1:2;for(let r=0,i=0;r<this.ranges.length;r+=3){let a=this.ranges[r],o=a-(this.inverted?i:0),s=a+(this.inverted?0:i),c=this.ranges[r+t],l=this.ranges[r+n];e(o,o+c,s,s+l),i+=l-c}}invert(){return new e(this.ranges,!this.inverted)}toString(){return(this.inverted?`-`:``)+JSON.stringify(this.ranges)}static offset(t){return t==0?e.empty:new e(t<0?[0,-t,0]:[0,0,t])}};CF.empty=new CF([]);var wF=class e{constructor(e,t,n=0,r=e?e.length:0){this.mirror=t,this.from=n,this.to=r,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(t=0,n=this.maps.length){return new e(this._maps,this.mirror,t,n)}appendMap(e,t){this.ownData||=(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),!0),this.to=this._maps.push(e),t!=null&&this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=0,n=this._maps.length;t<e._maps.length;t++){let r=e.getMirror(t);this.appendMap(e._maps[t],r!=null&&r<t?n+r:void 0)}}getMirror(e){if(this.mirror){for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}}setMirror(e,t){this.mirror||=[],this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,n=this._maps.length+e._maps.length;t>=0;t--){let r=e.getMirror(t);this.appendMap(e._maps[t].invert(),r!=null&&r>t?n-r-1:void 0)}}invert(){let t=new e;return t.appendMappingInverted(this),t}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let n=this.from;n<this.to;n++)e=this._maps[n].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,n){let r=0;for(let n=this.from;n<this.to;n++){let i=this._maps[n].mapResult(e,t);if(i.recover!=null){let t=this.getMirror(n);if(t!=null&&t>n&&t<this.to){n=t,e=this._maps[t].recover(i.recover);continue}}r|=i.delInfo,e=i.pos}return n?e:new SF(e,r,null)}},TF=Object.create(null),EF=class{getMap(){return CF.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw RangeError(`Invalid input for Step.fromJSON`);let n=TF[t.stepType];if(!n)throw RangeError(`No step type ${t.stepType} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in TF)throw RangeError(`Duplicate use of step JSON ID `+e);return TF[e]=t,t.prototype.jsonID=e,t}},DF=class e{constructor(e,t){this.doc=e,this.failed=t}static ok(t){return new e(t,null)}static fail(t){return new e(null,t)}static fromReplace(t,n,r,i){try{return e.ok(t.replace(n,r,i))}catch(t){if(t instanceof QN)return e.fail(t.message);throw t}}};function OF(e,t,n){let r=[];for(let i=0;i<e.childCount;i++){let a=e.child(i);a.content.size&&(a=a.copy(OF(a.content,t,a))),a.isInline&&(a=t(a,n,i)),r.push(a)}return Z.fromArray(r)}var kF=class e extends EF{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=e.resolve(this.from),r=n.node(n.sharedDepth(this.to)),i=new Q(OF(t.content,(e,t)=>!e.isAtom||!t.type.allowsMarkType(this.mark.type)?e:e.mark(this.mark.addToSet(e.marks)),r),t.openStart,t.openEnd);return DF.fromReplace(e,this.from,this.to,i)}invert(){return new AF(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new e(n.pos,r.pos,this.mark)}merge(t){return t instanceof e&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new e(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:`addMark`,mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for AddMarkStep.fromJSON`);return new e(n.from,n.to,t.markFromJSON(n.mark))}};EF.jsonID(`addMark`,kF);var AF=class e extends EF{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=new Q(OF(t.content,e=>e.mark(this.mark.removeFromSet(e.marks)),e),t.openStart,t.openEnd);return DF.fromReplace(e,this.from,this.to,n)}invert(){return new kF(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new e(n.pos,r.pos,this.mark)}merge(t){return t instanceof e&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new e(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:`removeMark`,mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for RemoveMarkStep.fromJSON`);return new e(n.from,n.to,t.markFromJSON(n.mark))}};EF.jsonID(`removeMark`,AF);var jF=class e extends EF{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return DF.fail(`No node at mark step's position`);let n=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return DF.fromReplace(e,this.pos,this.pos+1,new Q(Z.from(n),0,+!t.isLeaf))}invert(t){let n=t.nodeAt(this.pos);if(n){let t=this.mark.addToSet(n.marks);if(t.length==n.marks.length){for(let r=0;r<n.marks.length;r++)if(!n.marks[r].isInSet(t))return new e(this.pos,n.marks[r]);return new e(this.pos,this.mark)}}return new MF(this.pos,this.mark)}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new e(n.pos,this.mark)}toJSON(){return{stepType:`addNodeMark`,pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,n){if(typeof n.pos!=`number`)throw RangeError(`Invalid input for AddNodeMarkStep.fromJSON`);return new e(n.pos,t.markFromJSON(n.mark))}};EF.jsonID(`addNodeMark`,jF);var MF=class e extends EF{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return DF.fail(`No node at mark step's position`);let n=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return DF.fromReplace(e,this.pos,this.pos+1,new Q(Z.from(n),0,+!t.isLeaf))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new jF(this.pos,this.mark)}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new e(n.pos,this.mark)}toJSON(){return{stepType:`removeNodeMark`,pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,n){if(typeof n.pos!=`number`)throw RangeError(`Invalid input for RemoveNodeMarkStep.fromJSON`);return new e(n.pos,t.markFromJSON(n.mark))}};EF.jsonID(`removeNodeMark`,MF);var NF=class e extends EF{constructor(e,t,n,r=!1){super(),this.from=e,this.to=t,this.slice=n,this.structure=r}apply(e){return this.structure&&FF(e,this.from,this.to)?DF.fail(`Structure replace would overwrite content`):DF.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new CF([this.from,this.to-this.from,this.slice.size])}invert(t){return new e(this.from,this.from+this.slice.size,t.slice(this.from,this.to))}map(t){let n=t.mapResult(this.to,-1),r=this.from==this.to&&e.MAP_BIAS<0?n:t.mapResult(this.from,1);return r.deletedAcross&&n.deletedAcross?null:new e(r.pos,Math.max(r.pos,n.pos),this.slice,this.structure)}merge(t){if(!(t instanceof e)||t.structure||this.structure)return null;if(this.from+this.slice.size==t.from&&!this.slice.openEnd&&!t.slice.openStart){let n=this.slice.size+t.slice.size==0?Q.empty:new Q(this.slice.content.append(t.slice.content),this.slice.openStart,t.slice.openEnd);return new e(this.from,this.to+(t.to-t.from),n,this.structure)}else if(t.to==this.from&&!this.slice.openStart&&!t.slice.openEnd){let n=this.slice.size+t.slice.size==0?Q.empty:new Q(t.slice.content.append(this.slice.content),t.slice.openStart,this.slice.openEnd);return new e(t.from,this.to,n,this.structure)}else return null}toJSON(){let e={stepType:`replace`,from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for ReplaceStep.fromJSON`);return new e(n.from,n.to,Q.fromJSON(t,n.slice),!!n.structure)}};NF.MAP_BIAS=1,EF.jsonID(`replace`,NF);var PF=class e extends EF{constructor(e,t,n,r,i,a,o=!1){super(),this.from=e,this.to=t,this.gapFrom=n,this.gapTo=r,this.slice=i,this.insert=a,this.structure=o}apply(e){if(this.structure&&(FF(e,this.from,this.gapFrom)||FF(e,this.gapTo,this.to)))return DF.fail(`Structure gap-replace would overwrite content`);let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return DF.fail(`Gap is not a flat range`);let n=this.slice.insertAt(this.insert,t.content);return n?DF.fromReplace(e,this.from,this.to,n):DF.fail(`Content does not fit in gap`)}getMap(){return new CF([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(t){let n=this.gapTo-this.gapFrom;return new e(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,t.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1),i=this.from==this.gapFrom?n.pos:t.map(this.gapFrom,-1),a=this.to==this.gapTo?r.pos:t.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||i<n.pos||a>r.pos?null:new e(n.pos,r.pos,i,a,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:`replaceAround`,from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`||typeof n.gapFrom!=`number`||typeof n.gapTo!=`number`||typeof n.insert!=`number`)throw RangeError(`Invalid input for ReplaceAroundStep.fromJSON`);return new e(n.from,n.to,n.gapFrom,n.gapTo,Q.fromJSON(t,n.slice),n.insert,!!n.structure)}};EF.jsonID(`replaceAround`,PF);function FF(e,t,n){let r=e.resolve(t),i=n-t,a=r.depth;for(;i>0&&a>0&&r.indexAfter(a)==r.node(a).childCount;)a--,i--;if(i>0){let e=r.node(a).maybeChild(r.indexAfter(a));for(;i>0;){if(!e||e.isLeaf)return!0;e=e.firstChild,i--}}return!1}function IF(e,t,n,r){let i=[],a=[],o,s;e.doc.nodesBetween(t,n,(e,c,l)=>{if(!e.isInline)return;let u=e.marks;if(!r.isInSet(u)&&l.type.allowsMarkType(r.type)){let l=Math.max(c,t),d=Math.min(c+e.nodeSize,n),f=r.addToSet(u);for(let e=0;e<u.length;e++)u[e].isInSet(f)||(o&&o.to==l&&o.mark.eq(u[e])?o.to=d:i.push(o=new AF(l,d,u[e])));s&&s.to==l?s.to=d:a.push(s=new kF(l,d,r))}}),i.forEach(t=>e.step(t)),a.forEach(t=>e.step(t))}function LF(e,t,n,r){let i=[],a=0;e.doc.nodesBetween(t,n,(e,o)=>{if(!e.isInline)return;a++;let s=null;if(r instanceof VP){let t=e.marks,n;for(;n=r.isInSet(t);)(s||=[]).push(n),t=n.removeFromSet(t)}else r?r.isInSet(e.marks)&&(s=[r]):s=e.marks;if(s&&s.length){let r=Math.min(o+e.nodeSize,n);for(let e=0;e<s.length;e++){let n=s[e],c;for(let e=0;e<i.length;e++){let t=i[e];t.step==a-1&&n.eq(i[e].style)&&(c=t)}c?(c.to=r,c.step=a):i.push({style:n,from:Math.max(o,t),to:r,step:a})}}}),i.forEach(t=>e.step(new AF(t.from,t.to,t.style)))}function RF(e,t,n,r=n.contentMatch,i=!0){let a=e.doc.nodeAt(t),o=[],s=t+1;for(let t=0;t<a.childCount;t++){let c=a.child(t),l=s+c.nodeSize,u=r.matchType(c.type);if(!u)o.push(new NF(s,l,Q.empty));else{r=u;for(let t=0;t<c.marks.length;t++)n.allowsMarkType(c.marks[t].type)||e.step(new AF(s,l,c.marks[t]));if(i&&c.isText&&n.whitespace!=`pre`){let e,t=/\r?\n|\r/g,r;for(;e=t.exec(c.text);)r||=new Q(Z.from(n.schema.text(` `,n.allowedMarks(c.marks))),0,0),o.push(new NF(s+e.index,s+e.index+e[0].length,r))}}s=l}if(!r.validEnd){let t=r.fillBefore(Z.empty,!0);e.replace(s,s,new Q(t,0,0))}for(let t=o.length-1;t>=0;t--)e.step(o[t])}function zF(e,t,n){return(t==0||e.canReplace(t,e.childCount))&&(n==e.childCount||e.canReplace(0,n))}function BF(e){let t=e.parent.content.cutByIndex(e.startIndex,e.endIndex);for(let n=e.depth,r=0,i=0;;--n){let a=e.$from.node(n),o=e.$from.index(n)+r,s=e.$to.indexAfter(n)-i;if(n<e.depth&&a.canReplace(o,s,t))return n;if(n==0||a.type.spec.isolating||!zF(a,o,s))break;o&&(r=1),s<a.childCount&&(i=1)}return null}function VF(e,t,n){let{$from:r,$to:i,depth:a}=t,o=r.before(a+1),s=i.after(a+1),c=o,l=s,u=Z.empty,d=0;for(let e=a,t=!1;e>n;e--)t||r.index(e)>0?(t=!0,u=Z.from(r.node(e).copy(u)),d++):c--;let f=Z.empty,p=0;for(let e=a,t=!1;e>n;e--)t||i.after(e+1)<i.end(e)?(t=!0,f=Z.from(i.node(e).copy(f)),p++):l++;e.step(new PF(c,l,o,s,new Q(u.append(f),d,p),u.size-d,!0))}function HF(e,t,n=null,r=e){let i=WF(e,t),a=i&&GF(r,t);return a?i.map(UF).concat({type:t,attrs:n}).concat(a.map(UF)):null}function UF(e){return{type:e,attrs:null}}function WF(e,t){let{parent:n,startIndex:r,endIndex:i}=e,a=n.contentMatchAt(r).findWrapping(t);if(!a)return null;let o=a.length?a[0]:t;return n.canReplaceWith(r,i,o)?a:null}function GF(e,t){let{parent:n,startIndex:r,endIndex:i}=e,a=n.child(r),o=t.contentMatch.findWrapping(a.type);if(!o)return null;let s=(o.length?o[o.length-1]:t).contentMatch;for(let e=r;s&&e<i;e++)s=s.matchType(n.child(e).type);return!s||!s.validEnd?null:o}function KF(e,t,n){let r=Z.empty;for(let e=n.length-1;e>=0;e--){if(r.size){let t=n[e].type.contentMatch.matchFragment(r);if(!t||!t.validEnd)throw RangeError(`Wrapper type given to Transform.wrap does not form valid content of its parent wrapper`)}r=Z.from(n[e].type.create(n[e].attrs,r))}let i=t.start,a=t.end;e.step(new PF(i,a,i,a,new Q(r,0,0),n.length,!0))}function qF(e,t,n,r,i){if(!r.isTextblock)throw RangeError(`Type given to setBlockType should be a textblock`);let a=e.steps.length;e.doc.nodesBetween(t,n,(t,n)=>{let o=typeof i==`function`?i(t):i;if(t.isTextblock&&!t.hasMarkup(r,o)&&XF(e.doc,e.mapping.slice(a).map(n),r)){let i=null;if(r.schema.linebreakReplacement){let e=r.whitespace==`pre`,t=!!r.contentMatch.matchType(r.schema.linebreakReplacement);e&&!t?i=!1:!e&&t&&(i=!0)}i===!1&&YF(e,t,n,a),RF(e,e.mapping.slice(a).map(n,1),r,void 0,i===null);let s=e.mapping.slice(a),c=s.map(n,1),l=s.map(n+t.nodeSize,1);return e.step(new PF(c,l,c+1,l-1,new Q(Z.from(r.create(o,null,t.marks)),0,0),1,!0)),i===!0&&JF(e,t,n,a),!1}})}function JF(e,t,n,r){t.forEach((i,a)=>{if(i.isText){let o,s=/\r?\n|\r/g;for(;o=s.exec(i.text);){let i=e.mapping.slice(r).map(n+1+a+o.index);e.replaceWith(i,i+1,t.type.schema.linebreakReplacement.create())}}})}function YF(e,t,n,r){t.forEach((i,a)=>{if(i.type==i.type.schema.linebreakReplacement){let i=e.mapping.slice(r).map(n+1+a);e.replaceWith(i,i+1,t.type.schema.text(`
@@ -216,8 +216,8 @@ ${n}`}}),s}function iK(e,t,n={}){let{state:r}=t,{doc:i,tr:a}=r,o=e;i.descendants
216
216
  `):``,markdownTokenizer:{name:`orderedList`,level:`block`,start:e=>{let t=e.match(/^(\s*)(\d+)\.\s+/)?.index;return t===void 0?-1:t},tokenize:(e,t,n)=>{let r=e.split(`
217
217
  `),[i,a]=PX(r);if(i.length===0)return;let o=FX(i,0,n);if(o.length!==0)return{type:`list`,ordered:!0,start:i[0]?.number||1,items:o,raw:r.slice(0,a).join(`
218
218
  `)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:e,chain:t})=>this.options.keepAttributes?t().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(LX,this.editor.getAttributes(RX)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let e=GG({find:zX,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(e=GG({find:zX,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(RX)}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1],editor:this.editor})),[e]}}),VX=/^\s*(\[([( |x])?\])\s$/,HX=aK.create({name:`taskItem`,addOptions(){return{nested:!1,HTMLAttributes:{},taskListTypeName:`taskList`,a11y:void 0}},content(){return this.options.nested?`paragraph block*`:`paragraph+`},defining:!0,addAttributes(){return{checked:{default:!1,keepOnSplit:!1,parseHTML:e=>{let t=e.getAttribute(`data-checked`);return t===``||t===`true`},renderHTML:e=>({"data-checked":e.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51}]},renderHTML({node:e,HTMLAttributes:t}){return[`li`,rW(this.options.HTMLAttributes,t,{"data-type":this.name}),[`label`,[`input`,{type:`checkbox`,checked:e.attrs.checked?`checked`:null}],[`span`]],[`div`,0]]},parseMarkdown:(e,t)=>{let n=[];if(e.tokens&&e.tokens.length>0?n.push(t.createNode(`paragraph`,{},t.parseInline(e.tokens))):e.text?n.push(t.createNode(`paragraph`,{},[t.createNode(`text`,{text:e.text})])):n.push(t.createNode(`paragraph`,{},[])),e.nestedTokens&&e.nestedTokens.length>0){let r=t.parseChildren(e.nestedTokens);n.push(...r)}return t.createNode(`taskItem`,{checked:e.checked||!1},n)},renderMarkdown:(e,t)=>rK(e,t,`- [${e.attrs?.checked?`x`:` `}] `),addKeyboardShortcuts(){let e={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...e,Tab:()=>this.editor.commands.sinkListItem(this.name)}:e},addNodeView(){return({node:e,HTMLAttributes:t,getPos:n,editor:r})=>{let i=document.createElement(`li`),a=document.createElement(`label`),o=document.createElement(`span`),s=document.createElement(`input`),c=document.createElement(`div`),l=e=>{var t;s.ariaLabel=((t=this.options.a11y)?.checkboxLabel)?.call(t,e,s.checked)||`Task item checkbox for ${e.textContent||`empty task item`}`};l(e),a.contentEditable=`false`,s.type=`checkbox`,s.addEventListener(`mousedown`,e=>e.preventDefault()),s.addEventListener(`change`,t=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){s.checked=!s.checked;return}let{checked:i}=t.target;r.isEditable&&typeof n==`function`&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:e})=>{let t=n();if(typeof t!=`number`)return!1;let r=e.doc.nodeAt(t);return e.setNodeMarkup(t,void 0,{...r?.attrs,checked:i}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(e,i)||(s.checked=!s.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([e,t])=>{i.setAttribute(e,t)}),i.dataset.checked=e.attrs.checked,s.checked=e.attrs.checked,a.append(s,o),i.append(a,c),Object.entries(t).forEach(([e,t])=>{i.setAttribute(e,t)});let u=new Set(Object.keys(t));return{dom:i,contentDOM:c,update:e=>{if(e.type!==this.type)return!1;i.dataset.checked=e.attrs.checked,s.checked=e.attrs.checked,l(e);let t=r.extensionManager.attributes,n=iW(e,t),a=new Set(Object.keys(n)),o=this.options.HTMLAttributes;return u.forEach(e=>{a.has(e)||(e in o?i.setAttribute(e,o[e]):i.removeAttribute(e))}),Object.entries(n).forEach(([e,t])=>{t==null?e in o?i.setAttribute(e,o[e]):i.removeAttribute(e):i.setAttribute(e,t)}),u=a,!0}}}},addInputRules(){return[GG({find:VX,type:this.type,getAttributes:e=>({checked:e[e.length-1]===`x`})})]}}),UX=aK.create({name:`taskList`,addOptions(){return{itemTypeName:`taskItem`,HTMLAttributes:{}}},group:`block list`,content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:e}){return[`ul`,rW(this.options.HTMLAttributes,e,{"data-type":this.name}),0]},parseMarkdown:(e,t)=>t.createNode(`taskList`,{},t.parseChildren(e.items||[])),renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,`
219
- `):``,markdownTokenizer:{name:`taskList`,level:`block`,start(e){let t=e.match(/^\s*[-+*]\s+\[([ xX])\]\s+/)?.index;return t===void 0?-1:t},tokenize(e,t,n){let r=e=>{let t=nK(e,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:e=>({indentLevel:e[1].length,mainContent:e[4],checked:e[3].toLowerCase()===`x`}),createToken:(e,t)=>({type:`taskItem`,raw:``,mainContent:e.mainContent,indentLevel:e.indentLevel,checked:e.checked,text:e.mainContent,tokens:n.inlineTokens(e.mainContent),nestedTokens:t}),customNestedParser:r},n);return t?[{type:`taskList`,raw:t.raw,items:t.items}]:n.blockTokens(e)},i=nK(e,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:e=>({indentLevel:e[1].length,mainContent:e[4],checked:e[3].toLowerCase()===`x`}),createToken:(e,t)=>({type:`taskItem`,raw:``,mainContent:e.mainContent,indentLevel:e.indentLevel,checked:e.checked,text:e.mainContent,tokens:n.inlineTokens(e.mainContent),nestedTokens:t}),customNestedParser:r},n);if(i)return{type:`taskList`,raw:i.raw,items:i.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:e})=>e.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});EG.create({name:`listKit`,addExtensions(){let e=[];return this.options.bulletList!==!1&&e.push(_X.configure(this.options.bulletList)),this.options.listItem!==!1&&e.push(vX.configure(this.options.listItem)),this.options.listKeymap!==!1&&e.push(kX.configure(this.options.listKeymap)),this.options.orderedList!==!1&&e.push(BX.configure(this.options.orderedList)),this.options.taskItem!==!1&&e.push(HX.configure(this.options.taskItem)),this.options.taskList!==!1&&e.push(UX.configure(this.options.taskList)),e}});var WX=`&nbsp;`,GX=`\xA0`,KX=aK.create({name:`paragraph`,priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:`block`,content:`inline*`,parseHTML(){return[{tag:`p`}]},renderHTML({HTMLAttributes:e}){return[`p`,rW(this.options.HTMLAttributes,e),0]},parseMarkdown:(e,t)=>{let n=e.tokens||[];if(n.length===1&&n[0].type===`image`)return t.parseChildren([n[0]]);let r=t.parseInline(n);return n.length===1&&n[0].type===`text`&&(n[0].raw===WX||n[0].text===WX||n[0].raw===GX||n[0].text===GX)&&r.length===1&&r[0].type===`text`&&(r[0].text===WX||r[0].text===GX)?t.createNode(`paragraph`,void 0,[]):t.createNode(`paragraph`,void 0,r)},renderMarkdown:(e,t,n)=>{if(!e)return``;let r=Array.isArray(e.content)?e.content:[];if(r.length===0){let e=Array.isArray(n?.previousNode?.content)?n.previousNode.content:[];return n?.previousNode?.type===`paragraph`&&e.length===0?WX:``}return t.renderChildren(r)},addCommands(){return{setParagraph:()=>({commands:e})=>e.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),qX=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,JX=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,YX=_G.create({name:`strike`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`s`},{tag:`del`},{tag:`strike`},{style:`text-decoration`,consuming:!1,getAttrs:e=>e.includes(`line-through`)?{}:!1}]},renderHTML({HTMLAttributes:e}){return[`s`,rW(this.options.HTMLAttributes,e),0]},markdownTokenName:`del`,parseMarkdown:(e,t)=>t.applyMark(`strike`,t.parseInline(e.tokens||[])),renderMarkdown:(e,t)=>`~~${t.renderChildren(e)}~~`,addCommands(){return{setStrike:()=>({commands:e})=>e.setMark(this.name),toggleStrike:()=>({commands:e})=>e.toggleMark(this.name),unsetStrike:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[HG({find:qX,type:this.type})]},addPasteRules(){return[oK({find:JX,type:this.type})]}}),XX=aK.create({name:`text`,group:`inline`,parseMarkdown:e=>({type:`text`,text:e.text||``}),renderMarkdown:e=>e.text||``}),ZX=_G.create({name:`underline`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`u`},{style:`text-decoration`,consuming:!1,getAttrs:e=>e.includes(`underline`)?{}:!1}]},renderHTML({HTMLAttributes:e}){return[`u`,rW(this.options.HTMLAttributes,e),0]},parseMarkdown(e,t){return t.applyMark(this.name||`underline`,t.parseInline(e.tokens||[]))},renderMarkdown(e,t){return`++${t.renderChildren(e)}++`},markdownTokenizer:{name:`underline`,level:`inline`,start(e){return e.indexOf(`++`)},tokenize(e,t,n){let r=/^(\+\+)([\s\S]+?)(\+\+)/.exec(e);if(!r)return;let i=r[2].trim();return{type:`underline`,raw:r[0],text:i,tokens:n.inlineTokens(i)}}},addCommands(){return{setUnderline:()=>({commands:e})=>e.setMark(this.name),toggleUnderline:()=>({commands:e})=>e.toggleMark(this.name),unsetUnderline:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}});function QX(e={}){return new YI({view(t){return new $X(t,e)}})}var $X=class{constructor(e,t){this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=t.width??1,this.color=t.color===!1?void 0:t.color||`black`,this.class=t.class,this.handlers=[`dragover`,`dragend`,`drop`,`dragleave`].map(t=>{let n=e=>{this[t](e)};return e.dom.addEventListener(t,n),{name:t,handler:n}})}destroy(){this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){this.cursorPos!=null&&t.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),t=!e.parent.inlineContent,n,r=this.editorView.dom,i=r.getBoundingClientRect(),a=i.width/r.offsetWidth,o=i.height/r.offsetHeight;if(t){let t=e.nodeBefore,r=e.nodeAfter;if(t||r){let e=this.editorView.nodeDOM(this.cursorPos-(t?t.nodeSize:0));if(e){let i=e.getBoundingClientRect(),a=t?i.bottom:i.top;t&&r&&(a=(a+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let s=this.width/2*o;n={left:i.left,right:i.right,top:a-s,bottom:a+s}}}}if(!n){let e=this.editorView.coordsAtPos(this.cursorPos),t=this.width/2*a;n={left:e.left-t,right:e.left+t,top:e.top,bottom:e.bottom}}let s=this.editorView.dom.offsetParent;this.element||(this.element=s.appendChild(document.createElement(`div`)),this.class&&(this.element.className=this.class),this.element.style.cssText=`position: absolute; z-index: 50; pointer-events: none;`,this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle(`prosemirror-dropcursor-block`,t),this.element.classList.toggle(`prosemirror-dropcursor-inline`,!t);let c,l;if(!s||s==document.body&&getComputedStyle(s).position==`static`)c=-pageXOffset,l=-pageYOffset;else{let e=s.getBoundingClientRect(),t=e.width/s.offsetWidth,n=e.height/s.offsetHeight;c=e.left-s.scrollLeft*t,l=e.top-s.scrollTop*n}this.element.style.left=(n.left-c)/a+`px`,this.element.style.top=(n.top-l)/o+`px`,this.element.style.width=(n.right-n.left)/a+`px`,this.element.style.height=(n.bottom-n.top)/o+`px`}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),n=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),r=n&&n.type.spec.disableDropCursor,i=typeof r==`function`?r(this.editorView,t,e):r;if(t&&!i){let e=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let t=oI(this.editorView.state.doc,e,this.editorView.dragging.slice);t!=null&&(e=t)}this.setCursor(e),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}},eZ=class e extends DI{constructor(e){super(e,e)}map(t,n){let r=t.resolve(n.map(this.head));return e.valid(r)?new e(r):DI.near(r)}content(){return Q.empty}eq(t){return t instanceof e&&t.head==this.head}toJSON(){return{type:`gapcursor`,pos:this.head}}static fromJSON(t,n){if(typeof n.pos!=`number`)throw RangeError(`Invalid input for GapCursor.fromJSON`);return new e(t.resolve(n.pos))}getBookmark(){return new tZ(this.anchor)}static valid(e){let t=e.parent;if(t.inlineContent||!rZ(e)||!iZ(e))return!1;let n=t.type.spec.allowGapCursor;if(n!=null)return n;let r=t.contentMatchAt(e.index()).defaultType;return r&&r.isTextblock}static findGapCursorFrom(t,n,r=!1){search:for(;;){if(!r&&e.valid(t))return t;let i=t.pos,a=null;for(let r=t.depth;;r--){let o=t.node(r);if(n>0?t.indexAfter(r)<o.childCount:t.index(r)>0){a=o.child(n>0?t.indexAfter(r):t.index(r)-1);break}else if(r==0)return null;i+=n;let s=t.doc.resolve(i);if(e.valid(s))return s}for(;;){let o=n>0?a.firstChild:a.lastChild;if(!o){if(a.isAtom&&!a.isText&&!NI.isSelectable(a)){t=t.doc.resolve(i+a.nodeSize*n),r=!1;continue search}break}a=o,i+=n;let s=t.doc.resolve(i);if(e.valid(s))return s}return null}}};eZ.prototype.visible=!1,eZ.findFrom=eZ.findGapCursorFrom,DI.jsonID(`gapcursor`,eZ);var tZ=class e{constructor(e){this.pos=e}map(t){return new e(t.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return eZ.valid(t)?new eZ(t):DI.near(t)}};function nZ(e){return e.isAtom||e.spec.isolating||e.spec.createGapCursor}function rZ(e){for(let t=e.depth;t>=0;t--){let n=e.index(t),r=e.node(t);if(n==0){if(r.type.spec.isolating)return!0;continue}for(let e=r.child(n-1);;e=e.lastChild){if(e.childCount==0&&!e.inlineContent||nZ(e.type))return!0;if(e.inlineContent)return!1}}return!0}function iZ(e){for(let t=e.depth;t>=0;t--){let n=e.indexAfter(t),r=e.node(t);if(n==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let e=r.child(n);;e=e.firstChild){if(e.childCount==0&&!e.inlineContent||nZ(e.type))return!0;if(e.inlineContent)return!1}}return!0}function aZ(){return new YI({props:{decorations:uZ,createSelectionBetween(e,t,n){return t.pos==n.pos&&eZ.valid(n)?new eZ(n):null},handleClick:cZ,handleKeyDown:oZ,handleDOMEvents:{beforeinput:lZ}}})}var oZ=TH({ArrowLeft:sZ(`horiz`,-1),ArrowRight:sZ(`horiz`,1),ArrowUp:sZ(`vert`,-1),ArrowDown:sZ(`vert`,1)});function sZ(e,t){let n=e==`vert`?t>0?`down`:`up`:t>0?`right`:`left`;return function(e,r,i){let a=e.selection,o=t>0?a.$to:a.$from,s=a.empty;if(a instanceof jI){if(!i.endOfTextblock(n)||o.depth==0)return!1;s=!1,o=e.doc.resolve(t>0?o.after():o.before())}let c=eZ.findGapCursorFrom(o,t,s);return c?(r&&r(e.tr.setSelection(new eZ(c))),!0):!1}}function cZ(e,t,n){if(!e||!e.editable)return!1;let r=e.state.doc.resolve(t);if(!eZ.valid(r))return!1;let i=e.posAtCoords({left:n.clientX,top:n.clientY});return i&&i.inside>-1&&NI.isSelectable(e.state.doc.nodeAt(i.inside))?!1:(e.dispatch(e.state.tr.setSelection(new eZ(r))),!0)}function lZ(e,t){if(t.inputType!=`insertCompositionText`||!(e.state.selection instanceof eZ))return!1;let{$from:n}=e.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(e.state.schema.nodes.text);if(!r)return!1;let i=Z.empty;for(let e=r.length-1;e>=0;e--)i=Z.from(r[e].createAndFill(null,i));let a=e.state.tr.replace(n.pos,n.pos,new Q(i,0,0));return a.setSelection(jI.near(a.doc.resolve(n.pos+1))),e.dispatch(a),!1}function uZ(e){if(!(e.selection instanceof eZ))return null;let t=document.createElement(`div`);return t.className=`ProseMirror-gapcursor`,wV.create(e.doc,[xV.widget(e.selection.head,t,{key:`gapcursor`})])}var dZ=200,fZ=function(){};fZ.prototype.append=function(e){return e.length?(e=fZ.from(e),!this.length&&e||e.length<dZ&&this.leafAppend(e)||this.length<dZ&&e.leafPrepend(this)||this.appendInner(e)):this},fZ.prototype.prepend=function(e){return e.length?fZ.from(e).append(this):this},fZ.prototype.appendInner=function(e){return new mZ(this,e)},fZ.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?fZ.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},fZ.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},fZ.prototype.forEach=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length),t<=n?this.forEachInner(e,t,n,0):this.forEachInvertedInner(e,t,n,0)},fZ.prototype.map=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length);var r=[];return this.forEach(function(t,n){return r.push(e(t,n))},t,n),r},fZ.from=function(e){return e instanceof fZ?e:e&&e.length?new pZ(e):fZ.empty};var pZ=function(e){function t(t){e.call(this),this.values=t}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var n={length:{configurable:!0},depth:{configurable:!0}};return t.prototype.flatten=function(){return this.values},t.prototype.sliceInner=function(e,n){return e==0&&n==this.length?this:new t(this.values.slice(e,n))},t.prototype.getInner=function(e){return this.values[e]},t.prototype.forEachInner=function(e,t,n,r){for(var i=t;i<n;i++)if(e(this.values[i],r+i)===!1)return!1},t.prototype.forEachInvertedInner=function(e,t,n,r){for(var i=t-1;i>=n;i--)if(e(this.values[i],r+i)===!1)return!1},t.prototype.leafAppend=function(e){if(this.length+e.length<=dZ)return new t(this.values.concat(e.flatten()))},t.prototype.leafPrepend=function(e){if(this.length+e.length<=dZ)return new t(e.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(t.prototype,n),t}(fZ);fZ.empty=new pZ([]);var mZ=function(e){function t(t,n){e.call(this),this.left=t,this.right=n,this.length=t.length+n.length,this.depth=Math.max(t.depth,n.depth)+1}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},t.prototype.getInner=function(e){return e<this.left.length?this.left.get(e):this.right.get(e-this.left.length)},t.prototype.forEachInner=function(e,t,n,r){var i=this.left.length;if(t<i&&this.left.forEachInner(e,t,Math.min(n,i),r)===!1||n>i&&this.right.forEachInner(e,Math.max(t-i,0),Math.min(this.length,n)-i,r+i)===!1)return!1},t.prototype.forEachInvertedInner=function(e,t,n,r){var i=this.left.length;if(t>i&&this.right.forEachInvertedInner(e,t-i,Math.max(n,i)-i,r+i)===!1||n<i&&this.left.forEachInvertedInner(e,Math.min(t,i),n,r)===!1)return!1},t.prototype.sliceInner=function(e,t){if(e==0&&t==this.length)return this;var n=this.left.length;return t<=n?this.left.slice(e,t):e>=n?this.right.slice(e-n,t-n):this.left.slice(e,n).append(this.right.slice(0,t-n))},t.prototype.leafAppend=function(e){var n=this.right.leafAppend(e);if(n)return new t(this.left,n)},t.prototype.leafPrepend=function(e){var n=this.left.leafPrepend(e);if(n)return new t(n,this.right)},t.prototype.appendInner=function(e){return this.left.depth>=Math.max(this.right.depth,e.depth)+1?new t(this.left,new t(this.right,e)):new t(this,e)},t}(fZ),hZ=500,gZ=class e{constructor(e,t){this.items=e,this.eventCount=t}popEvent(t,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let i,a;n&&(i=this.remapping(r,this.items.length),a=i.maps.length);let o=t.tr,s,c,l=[],u=[];return this.items.forEach((t,n)=>{if(!t.step){i||(i=this.remapping(r,n+1),a=i.maps.length),a--,u.push(t);return}if(i){u.push(new vZ(t.map));let e=t.step.map(i.slice(a)),n;e&&o.maybeStep(e).doc&&(n=o.mapping.maps[o.mapping.maps.length-1],l.push(new vZ(n,void 0,void 0,l.length+u.length))),a--,n&&i.appendMap(n,a)}else o.maybeStep(t.step);if(t.selection)return s=i?t.selection.map(i.slice(a)):t.selection,c=new e(this.items.slice(0,r).append(u.reverse().concat(l)),this.eventCount-1),!1},this.items.length,0),{remaining:c,transform:o,selection:s}}addTransform(t,n,r,i){let a=[],o=this.eventCount,s=this.items,c=!i&&s.length?s.get(s.length-1):null;for(let e=0;e<t.steps.length;e++){let r=t.steps[e].invert(t.docs[e]),l=new vZ(t.mapping.maps[e],r,n),u;(u=c&&c.merge(l))&&(l=u,e?a.pop():s=s.slice(0,s.length-1)),a.push(l),n&&=(o++,void 0),i||(c=l)}let l=o-r.depth;return l>bZ&&(s=_Z(s,l),o-=l),new e(s.append(a),o)}remapping(e,t){let n=new wF;return this.items.forEach((t,r)=>{let i=t.mirrorOffset!=null&&r-t.mirrorOffset>=e?n.maps.length-t.mirrorOffset:void 0;n.appendMap(t.map,i)},e,t),n}addMaps(t){return this.eventCount==0?this:new e(this.items.append(t.map(e=>new vZ(e))),this.eventCount)}rebased(t,n){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-n),a=t.mapping,o=t.steps.length,s=this.eventCount;this.items.forEach(e=>{e.selection&&s--},i);let c=n;this.items.forEach(e=>{let n=a.getMirror(--c);if(n==null)return;o=Math.min(o,n);let i=a.maps[n];if(e.step){let o=t.steps[n].invert(t.docs[n]),l=e.selection&&e.selection.map(a.slice(c+1,n));l&&s++,r.push(new vZ(i,o,l))}else r.push(new vZ(i))},i);let l=[];for(let e=n;e<o;e++)l.push(new vZ(a.maps[e]));let u=new e(this.items.slice(0,i).append(l).append(r),s);return u.emptyItemCount()>hZ&&(u=u.compress(this.items.length-r.length)),u}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(t=this.items.length){let n=this.remapping(0,t),r=n.maps.length,i=[],a=0;return this.items.forEach((e,o)=>{if(o>=t)i.push(e),e.selection&&a++;else if(e.step){let t=e.step.map(n.slice(r)),o=t&&t.getMap();if(r--,o&&n.appendMap(o,r),t){let s=e.selection&&e.selection.map(n.slice(r));s&&a++;let c=new vZ(o.invert(),t,s),l,u=i.length-1;(l=i.length&&i[u].merge(c))?i[u]=l:i.push(c)}}else e.map&&r--},this.items.length,0),new e(fZ.from(i.reverse()),a)}};gZ.empty=new gZ(fZ.empty,0);function _Z(e,t){let n;return e.forEach((e,r)=>{if(e.selection&&t--==0)return n=r,!1}),e.slice(n)}var vZ=class e{constructor(e,t,n,r){this.map=e,this.step=t,this.selection=n,this.mirrorOffset=r}merge(t){if(this.step&&t.step&&!t.selection){let n=t.step.merge(this.step);if(n)return new e(n.getMap().invert(),n,this.selection)}}},yZ=class{constructor(e,t,n,r,i){this.done=e,this.undone=t,this.prevRanges=n,this.prevTime=r,this.prevComposition=i}},bZ=20;function xZ(e,t,n,r){let i=n.getMeta(kZ),a;if(i)return i.historyState;n.getMeta(AZ)&&(e=new yZ(e.done,e.undone,null,0,-1));let o=n.getMeta(`appendedTransaction`);if(n.steps.length==0)return e;if(o&&o.getMeta(kZ))return o.getMeta(kZ).redo?new yZ(e.done.addTransform(n,void 0,r,OZ(t)),e.undone,CZ(n.mapping.maps),e.prevTime,e.prevComposition):new yZ(e.done,e.undone.addTransform(n,void 0,r,OZ(t)),null,e.prevTime,e.prevComposition);if(n.getMeta(`addToHistory`)!==!1&&!(o&&o.getMeta(`addToHistory`)===!1)){let i=n.getMeta(`composition`),a=e.prevTime==0||!o&&e.prevComposition!=i&&(e.prevTime<(n.time||0)-r.newGroupDelay||!SZ(n,e.prevRanges)),s=o?wZ(e.prevRanges,n.mapping):CZ(n.mapping.maps);return new yZ(e.done.addTransform(n,a?t.selection.getBookmark():void 0,r,OZ(t)),gZ.empty,s,n.time,i??e.prevComposition)}else if(a=n.getMeta(`rebased`))return new yZ(e.done.rebased(n,a),e.undone.rebased(n,a),wZ(e.prevRanges,n.mapping),e.prevTime,e.prevComposition);else return new yZ(e.done.addMaps(n.mapping.maps),e.undone.addMaps(n.mapping.maps),wZ(e.prevRanges,n.mapping),e.prevTime,e.prevComposition)}function SZ(e,t){if(!t)return!1;if(!e.docChanged)return!0;let n=!1;return e.mapping.maps[0].forEach((e,r)=>{for(let i=0;i<t.length;i+=2)e<=t[i+1]&&r>=t[i]&&(n=!0)}),n}function CZ(e){let t=[];for(let n=e.length-1;n>=0&&t.length==0;n--)e[n].forEach((e,n,r,i)=>t.push(r,i));return t}function wZ(e,t){if(!e)return null;let n=[];for(let r=0;r<e.length;r+=2){let i=t.map(e[r],1),a=t.map(e[r+1],-1);i<=a&&n.push(i,a)}return n}function TZ(e,t,n){let r=OZ(t),i=kZ.get(t).spec.config,a=(n?e.undone:e.done).popEvent(t,r);if(!a)return null;let o=a.selection.resolve(a.transform.doc),s=(n?e.done:e.undone).addTransform(a.transform,t.selection.getBookmark(),i,r),c=new yZ(n?s:a.remaining,n?a.remaining:s,null,0,-1);return a.transform.setSelection(o).setMeta(kZ,{redo:n,historyState:c})}var EZ=!1,DZ=null;function OZ(e){let t=e.plugins;if(DZ!=t){EZ=!1,DZ=t;for(let e=0;e<t.length;e++)if(t[e].spec.historyPreserveItems){EZ=!0;break}}return EZ}var kZ=new QI(`history`),AZ=new QI(`closeHistory`);function jZ(e={}){return e={depth:e.depth||100,newGroupDelay:e.newGroupDelay||500},new YI({key:kZ,state:{init(){return new yZ(gZ.empty,gZ.empty,null,0,-1)},apply(t,n,r){return xZ(n,r,t,e)}},config:e,props:{handleDOMEvents:{beforeinput(e,t){let n=t.inputType,r=n==`historyUndo`?NZ:n==`historyRedo`?PZ:null;return!r||!e.editable?!1:(t.preventDefault(),r(e.state,e.dispatch))}}}})}function MZ(e,t){return(n,r)=>{let i=kZ.getState(n);if(!i||(e?i.undone:i.done).eventCount==0)return!1;if(r){let a=TZ(i,n,e);a&&r(t?a.scrollIntoView():a)}return!0}}var NZ=MZ(!1,!0),PZ=MZ(!0,!0);EG.create({name:`characterCount`,addOptions(){return{limit:null,mode:`textSize`,textCounter:e=>e.length,wordCounter:e=>e.split(` `).filter(e=>e!==``).length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=e=>{let t=e?.node||this.editor.state.doc;if((e?.mode||this.options.mode)===`textSize`){let e=t.textBetween(0,t.content.size,void 0,` `);return this.options.textCounter(e)}return t.nodeSize},this.storage.words=e=>{let t=e?.node||this.editor.state.doc,n=t.textBetween(0,t.content.size,` `,` `);return this.options.wordCounter(n)}},addProseMirrorPlugins(){let e=!1;return[new YI({key:new QI(`characterCount`),appendTransaction:(t,n,r)=>{if(e)return;let i=this.options.limit;if(i==null||i===0){e=!0;return}let a=this.storage.characters({node:r.doc});if(a>i){let t=a-i;console.warn(`[CharacterCount] Initial content exceeded limit of ${i} characters. Content was automatically trimmed.`);let n=r.tr.deleteRange(0,t);return e=!0,n}e=!0},filterTransaction:(e,t)=>{let n=this.options.limit;if(!e.docChanged||n===0||n==null)return!0;let r=this.storage.characters({node:t.doc}),i=this.storage.characters({node:e.doc});if(i<=n||r>n&&i>n&&i<=r)return!0;if(r>n&&i>n&&i>r||!e.getMeta(`paste`))return!1;let a=e.selection.$head.pos,o=a-(i-n),s=a;return e.deleteRange(o,s),!(this.storage.characters({node:e.doc})>n)}})]}});var FZ=EG.create({name:`dropCursor`,addOptions(){return{color:`currentColor`,width:1,class:void 0}},addProseMirrorPlugins(){return[QX(this.options)]}});EG.create({name:`focus`,addOptions(){return{className:`has-focus`,mode:`all`}},addProseMirrorPlugins(){return[new YI({key:new QI(`focus`),props:{decorations:({doc:e,selection:t})=>{let{isEditable:n,isFocused:r}=this.editor,{anchor:i}=t,a=[];if(!n||!r)return wV.create(e,[]);let o=0;this.options.mode===`deepest`&&e.descendants((e,t)=>{if(!e.isText){if(!(i>=t&&i<=t+e.nodeSize-1))return!1;o+=1}});let s=0;return e.descendants((e,t)=>{if(e.isText||!(i>=t&&i<=t+e.nodeSize-1))return!1;if(s+=1,this.options.mode===`deepest`&&o-s>0||this.options.mode===`shallowest`&&s>1)return this.options.mode===`deepest`;a.push(xV.node(t,t+e.nodeSize,{class:this.options.className}))}),wV.create(e,a)}}})]}});var IZ=EG.create({name:`gapCursor`,addProseMirrorPlugins(){return[aZ()]},extendNodeSchema(e){return{allowGapCursor:ZU(qU(e,`allowGapCursor`,{name:e.name,options:e.options,storage:e.storage}))??null}}}),LZ=`placeholder`;function RZ(e){return e.replace(/\s+/g,`-`).replace(/[^a-zA-Z0-9-]/g,``).replace(/^[0-9-]+/,``).replace(/^-+/,``).toLowerCase()}EG.create({name:`placeholder`,addOptions(){return{emptyEditorClass:`is-editor-empty`,emptyNodeClass:`is-empty`,dataAttribute:LZ,placeholder:`Write something …`,showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){let e=this.options.dataAttribute?`data-${RZ(this.options.dataAttribute)}`:`data-${LZ}`;return[new YI({key:new QI(`placeholder`),props:{decorations:({doc:t,selection:n})=>{let r=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:i}=n,a=[];if(!r)return null;let o=this.editor.isEmpty;return t.descendants((t,n)=>{let r=i>=n&&i<=n+t.nodeSize,s=!t.isLeaf&&MW(t);if(!t.type.isTextblock)return this.options.includeChildren;if((r||!this.options.showOnlyCurrent)&&s){let i=[this.options.emptyNodeClass];o&&i.push(this.options.emptyEditorClass);let s=xV.node(n,n+t.nodeSize,{class:i.join(` `),[e]:typeof this.options.placeholder==`function`?this.options.placeholder({editor:this.editor,node:t,pos:n,hasAnchor:r}):this.options.placeholder});a.push(s)}return this.options.includeChildren}),wV.create(t,a)}}})]}}),EG.create({name:`selection`,addOptions(){return{className:`selection`}},addProseMirrorPlugins(){let{editor:e,options:t}=this;return[new YI({key:new QI(`selection`),props:{decorations(n){return n.selection.empty||e.isFocused||!e.isEditable||NW(n.selection)||e.view.dragging?null:wV.create(n.doc,[xV.inline(n.selection.from,n.selection.to,{class:t.className})])}}})]}});function zZ({types:e,node:t}){return t&&Array.isArray(e)&&e.includes(t.type)||t?.type===e}var BZ=EG.create({name:`trailingNode`,addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){let e=new QI(this.name),t=this.options.node||this.editor.schema.topNodeType.contentMatch.defaultType?.name||`paragraph`,n=Object.entries(this.editor.schema.nodes).map(([,e])=>e).filter(e=>(this.options.notAfter||[]).concat(t).includes(e.name));return[new YI({key:e,appendTransaction:(n,r,i)=>{let{doc:a,tr:o,schema:s}=i,c=e.getState(i),l=a.content.size,u=s.nodes[t];if(!n.some(e=>e.getMeta(`skipTrailingNode`))&&c)return o.insert(l,u.create())},state:{init:(e,t)=>{let r=t.tr.doc.lastChild;return!zZ({node:r,types:n})},apply:(e,t)=>{if(!e.docChanged||e.getMeta(`__uniqueIDTransaction`))return t;let r=e.doc.lastChild;return!zZ({node:r,types:n})}}})]}}),VZ=EG.create({name:`undoRedo`,addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:e,dispatch:t})=>NZ(e,t),redo:()=>({state:e,dispatch:t})=>PZ(e,t)}},addProseMirrorPlugins(){return[jZ(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}),HZ=EG.create({name:`starterKit`,addExtensions(){let e=[];return this.options.bold!==!1&&e.push(Pq.configure(this.options.bold)),this.options.blockquote!==!1&&e.push(kq.configure(this.options.blockquote)),this.options.bulletList!==!1&&e.push(_X.configure(this.options.bulletList)),this.options.code!==!1&&e.push(Lq.configure(this.options.code)),this.options.codeBlock!==!1&&e.push(Vq.configure(this.options.codeBlock)),this.options.document!==!1&&e.push(Hq.configure(this.options.document)),this.options.dropcursor!==!1&&e.push(FZ.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&e.push(IZ.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&e.push(Uq.configure(this.options.hardBreak)),this.options.heading!==!1&&e.push(Wq.configure(this.options.heading)),this.options.undoRedo!==!1&&e.push(VZ.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&e.push(Gq.configure(this.options.horizontalRule)),this.options.italic!==!1&&e.push(Xq.configure(this.options.italic)),this.options.listItem!==!1&&e.push(vX.configure(this.options.listItem)),this.options.listKeymap!==!1&&e.push(kX.configure(this.options?.listKeymap)),this.options.link!==!1&&e.push(dX.configure(this.options?.link)),this.options.orderedList!==!1&&e.push(BX.configure(this.options.orderedList)),this.options.paragraph!==!1&&e.push(KX.configure(this.options.paragraph)),this.options.strike!==!1&&e.push(YX.configure(this.options.strike)),this.options.text!==!1&&e.push(XX.configure(this.options.text)),this.options.underline!==!1&&e.push(ZX.configure(this.options?.underline)),this.options.trailingNode!==!1&&e.push(BZ.configure(this.options?.trailingNode)),e}}),UZ=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,WZ=aK.create({name:`image`,addOptions(){return{inline:!1,allowBase64:!1,HTMLAttributes:{},resize:!1}},inline(){return this.options.inline},group(){return this.options.inline?`inline`:`block`},draggable:!0,addAttributes(){return{src:{default:null},alt:{default:null},title:{default:null},width:{default:null},height:{default:null}}},parseHTML(){return[{tag:this.options.allowBase64?`img[src]`:`img[src]:not([src^="data:"])`}]},renderHTML({HTMLAttributes:e}){return[`img`,rW(this.options.HTMLAttributes,e)]},parseMarkdown:(e,t)=>t.createNode(`image`,{src:e.href,title:e.title,alt:e.text}),renderMarkdown:e=>{let t=e.attrs?.src??``,n=e.attrs?.alt??``,r=e.attrs?.title??``;return r?`![${n}](${t} "${r}")`:`![${n}](${t})`},addNodeView(){if(!this.options.resize||!this.options.resize.enabled||typeof document>`u`)return null;let{directions:e,minWidth:t,minHeight:n,alwaysPreserveAspectRatio:r}=this.options.resize;return({node:i,getPos:a,HTMLAttributes:o,editor:s})=>{let c=document.createElement(`img`);Object.entries(o).forEach(([e,t])=>{if(t!=null)switch(e){case`width`:case`height`:break;default:c.setAttribute(e,t);break}}),c.src=o.src;let l=new qG({element:c,editor:s,node:i,getPos:a,onResize:(e,t)=>{c.style.width=`${e}px`,c.style.height=`${t}px`},onCommit:(e,t)=>{let n=a();n!==void 0&&this.editor.chain().setNodeSelection(n).updateAttributes(this.name,{width:e,height:t}).run()},onUpdate:(e,t,n)=>e.type===i.type,options:{directions:e,min:{width:t,height:n},preserveAspectRatio:r===!0}}),u=l.dom;return u.style.visibility=`hidden`,u.style.pointerEvents=`none`,c.onload=()=>{u.style.visibility=``,u.style.pointerEvents=``},l}},addCommands(){return{setImage:e=>({commands:t})=>t.insertContent({type:this.name,attrs:e})}},addInputRules(){return[UG({find:UZ,type:this.type,getAttributes:e=>{let[,,t,n,r]=e;return{src:n,alt:t,title:r}}})]}});function GZ({onClick:e,active:t,disabled:n,title:r,children:i}){return(0,U.jsx)(`button`,{type:`button`,title:r,disabled:n,onMouseDown:t=>{t.preventDefault(),e()},className:q(`flex size-7 items-center justify-center rounded transition-colors`,t?`bg-foreground text-background`:`text-muted-foreground hover:bg-accent hover:text-accent-foreground`,n&&`pointer-events-none opacity-40`),children:i})}function KZ(){return(0,U.jsx)(`div`,{className:`mx-0.5 h-4 w-px bg-border`})}function qZ({value:e,onChange:t,placeholder:n,onInsertImage:r}){let[i,a]=(0,v.useState)(!e),o=yq({extensions:[HZ.configure({link:{openOnClick:!1,HTMLAttributes:{class:`text-primary underline`}}}),WZ.extend({addAttributes(){return{...this.parent?.(),width:{default:null},height:{default:null}}}}).configure({HTMLAttributes:{class:`max-w-full rounded`}})],content:(()=>{if(!e)return``;try{return JSON.parse(e)}catch{return e}})(),editorProps:{attributes:{class:`h-128 px-3 py-2.5 focus:outline-none`}},onUpdate({editor:e}){a(e.isEmpty),t(JSON.stringify(e.getJSON()))}});(0,v.useEffect)(()=>{if(!o)return;let t=e?(()=>{try{return JSON.parse(e)}catch{return e}})():``;JSON.stringify(o.getJSON())!==e&&o.commands.setContent(t,{emitUpdate:!1}),a(o.isEmpty)},[e]);async function s(){if(!o||!r)return;let e=await r();e&&o.chain().focus().setImage({src:e.src,alt:e.alt??void 0,width:e.width??void 0,height:e.height??void 0}).run()}function c(){if(!o)return;let e=o.getAttributes(`link`).href,t=window.prompt(`URL`,e??`https://`);if(t!==null){if(!t){o.chain().focus().unsetLink().run();return}o.chain().focus().setLink({href:t}).run()}}return o?(0,U.jsxs)(`div`,{className:`overflow-hidden rounded-md border border-input bg-background focus-within:border-ring focus-within:ring-[3px] focus-within:ring-ring/50`,children:[(0,U.jsxs)(`div`,{className:`sticky top-0 z-10 flex flex-wrap items-center gap-0.5 border-b border-border bg-background px-2 py-1.5`,children:[(0,U.jsx)(GZ,{title:`Bold`,active:o.isActive(`bold`),onClick:()=>o.chain().focus().toggleBold().run(),children:(0,U.jsx)(Fa,{className:`size-3.5`})}),(0,U.jsx)(GZ,{title:`Italic`,active:o.isActive(`italic`),onClick:()=>o.chain().focus().toggleItalic().run(),children:(0,U.jsx)(yo,{className:`size-3.5`})}),(0,U.jsx)(GZ,{title:`Underline`,active:o.isActive(`underline`),onClick:()=>o.chain().focus().toggleUnderline().run(),children:(0,U.jsx)(Xo,{className:`size-3.5`})}),(0,U.jsx)(GZ,{title:`Strikethrough`,active:o.isActive(`strike`),onClick:()=>o.chain().focus().toggleStrike().run(),children:(0,U.jsx)(Uo,{className:`size-3.5`})}),(0,U.jsx)(KZ,{}),(0,U.jsx)(GZ,{title:`Heading 1`,active:o.isActive(`heading`,{level:1}),onClick:()=>o.chain().focus().toggleHeading({level:1}).run(),children:(0,U.jsx)(po,{className:`size-3.5`})}),(0,U.jsx)(GZ,{title:`Heading 2`,active:o.isActive(`heading`,{level:2}),onClick:()=>o.chain().focus().toggleHeading({level:2}).run(),children:(0,U.jsx)(mo,{className:`size-3.5`})}),(0,U.jsx)(GZ,{title:`Heading 3`,active:o.isActive(`heading`,{level:3}),onClick:()=>o.chain().focus().toggleHeading({level:3}).run(),children:(0,U.jsx)(ho,{className:`size-3.5`})}),(0,U.jsx)(KZ,{}),(0,U.jsx)(GZ,{title:`Bullet list`,active:o.isActive(`bulletList`),onClick:()=>o.chain().focus().toggleBulletList().run(),children:(0,U.jsx)(Oo,{className:`size-3.5`})}),(0,U.jsx)(GZ,{title:`Ordered list`,active:o.isActive(`orderedList`),onClick:()=>o.chain().focus().toggleOrderedList().run(),children:(0,U.jsx)(Eo,{className:`size-3.5`})}),(0,U.jsx)(KZ,{}),(0,U.jsx)(GZ,{title:`Blockquote`,active:o.isActive(`blockquote`),onClick:()=>o.chain().focus().toggleBlockquote().run(),children:(0,U.jsx)(Fo,{className:`size-3.5`})}),(0,U.jsx)(GZ,{title:`Inline code`,active:o.isActive(`code`),onClick:()=>o.chain().focus().toggleCode().run(),children:(0,U.jsx)(Ya,{className:`size-3.5`})}),(0,U.jsx)(GZ,{title:`Code block`,active:o.isActive(`codeBlock`),onClick:()=>o.chain().focus().toggleCodeBlock().run(),children:(0,U.jsx)(Vo,{className:`size-3.5`})}),(0,U.jsx)(KZ,{}),(0,U.jsx)(GZ,{title:`Add link`,active:o.isActive(`link`),onClick:c,children:(0,U.jsx)(To,{className:`size-3.5`})}),(0,U.jsx)(GZ,{title:`Remove link`,disabled:!o.isActive(`link`),onClick:()=>o.chain().focus().unsetLink().run(),children:(0,U.jsx)(Zo,{className:`size-3.5`})}),(0,U.jsx)(KZ,{}),r&&(0,U.jsx)(GZ,{title:`Insert image`,onClick:s,children:(0,U.jsx)(_o,{className:`size-3.5`})}),(0,U.jsx)(GZ,{title:`Hard break (Shift + Enter)`,onClick:()=>o.chain().focus().setHardBreak().run(),children:(0,U.jsx)(Go,{className:`size-3.5`})})]}),(0,U.jsxs)(`div`,{className:`relative overflow-y-auto`,children:[i&&n&&(0,U.jsx)(`p`,{className:`pointer-events-none absolute left-3 top-2.5 text-muted-foreground select-none`,children:n}),(0,U.jsx)(dq,{editor:o})]})]}):null}function JZ(e){return{...e}}function YZ(e){return e.type.startsWith(`image/`)?new Promise(t=>{let n=new Image,r=URL.createObjectURL(e);n.onload=()=>{URL.revokeObjectURL(r),t({width:n.naturalWidth,height:n.naturalHeight})},n.onerror=()=>{URL.revokeObjectURL(r),t(null)},n.src=r}):Promise.resolve(null)}async function XZ(e,t){let n=await YZ(e),r=await fetch(`/cms/admin/media/presign`,{method:`POST`,credentials:`include`,headers:JZ({"Content-Type":`application/json`}),body:JSON.stringify({filename:e.name,mimeType:e.type,folderId:t?.folderId??null})});if(!r.ok)throw Error(`Upload failed.`);let i=await r.json();if(i.mode===`presigned`){if(!(await fetch(i.uploadUrl,{method:`PUT`,body:e,headers:{"Content-Type":e.type}})).ok)throw Error(`Upload failed.`);let r=await fetch(`/cms/admin/media/confirm`,{method:`POST`,credentials:`include`,headers:JZ({"Content-Type":`application/json`}),body:JSON.stringify({key:i.key,filename:e.name,mimeType:e.type,size:e.size,folderId:t?.folderId??null,width:n?.width??null,height:n?.height??null})});if(!r.ok)throw Error(`Upload failed.`);return r.json()}let a=new FormData;a.append(`files`,e,e.name),t?.folderId&&a.append(`folder_id`,t.folderId),n?.width&&a.append(`width`,String(n.width)),n?.height&&a.append(`height`,String(n.height));let o=await fetch(`/cms/admin/media`,{method:`POST`,credentials:`include`,headers:JZ(),body:a});if(!o.ok)throw Error(`Upload failed.`);return o.json()}async function ZZ(e){let t=await fetch(`/cms/admin/users/me/avatar/presign`,{method:`POST`,credentials:`include`,headers:JZ({"Content-Type":`application/json`}),body:JSON.stringify({filename:e.name,mimeType:e.type})});if(!t.ok)throw Error(`Upload failed.`);let n=await t.json();if(n.mode===`presigned`){if(!(await fetch(n.uploadUrl,{method:`PUT`,body:e,headers:{"Content-Type":e.type}})).ok)throw Error(`Upload failed.`);let t=await fetch(`/cms/admin/users/me/avatar/confirm`,{method:`POST`,credentials:`include`,headers:JZ({"Content-Type":`application/json`}),body:JSON.stringify({key:n.key})});if(!t.ok)throw Error(`Upload failed.`);return(await t.json()).avatarUrl}let r=new FormData;r.append(`file`,e);let i=await fetch(`/cms/admin/users/me/avatar`,{method:`POST`,credentials:`include`,headers:JZ(),body:r});if(!i.ok)throw Error(`Upload failed.`);return(await i.json()).avatarUrl}var QZ=1,$Z=.9,eQ=.8,tQ=.17,nQ=.1,rQ=.999,iQ=.9999,aQ=.99,oQ=/[\\\/_+.#"@\[\(\{&]/,sQ=/[\\\/_+.#"@\[\(\{&]/g,cQ=/[\s-]/,lQ=/[\s-]/g;function uQ(e,t,n,r,i,a,o){if(a===t.length)return i===e.length?QZ:aQ;var s=`${i},${a}`;if(o[s]!==void 0)return o[s];for(var c=r.charAt(a),l=n.indexOf(c,i),u=0,d,f,p,m;l>=0;)d=uQ(e,t,n,r,l+1,a+1,o),d>u&&(l===i?d*=QZ:oQ.test(e.charAt(l-1))?(d*=eQ,p=e.slice(i,l-1).match(sQ),p&&i>0&&(d*=rQ**+p.length)):cQ.test(e.charAt(l-1))?(d*=$Z,m=e.slice(i,l-1).match(lQ),m&&i>0&&(d*=rQ**+m.length)):(d*=tQ,i>0&&(d*=rQ**+(l-i))),e.charAt(l)!==t.charAt(a)&&(d*=iQ)),(d<nQ&&n.charAt(l-1)===r.charAt(a+1)||r.charAt(a+1)===r.charAt(a)&&n.charAt(l-1)!==r.charAt(a))&&(f=uQ(e,t,n,r,l+1,a+2,o),f*nQ>d&&(d=f*nQ)),d>u&&(u=d),l=n.indexOf(c,l+1);return o[s]=u,u}function dQ(e){return e.toLowerCase().replace(lQ,` `)}function fQ(e,t,n){return e=n&&n.length>0?`${e+` `+n.join(` `)}`:e,uQ(e,t,dQ(e),dQ(t),0,0,{})}var pQ=`[cmdk-group=""]`,mQ=`[cmdk-group-items=""]`,hQ=`[cmdk-group-heading=""]`,gQ=`[cmdk-item=""]`,_Q=`${gQ}:not([aria-disabled="true"])`,vQ=`cmdk-item-select`,yQ=`data-value`,bQ=(e,t,n)=>fQ(e,t,n),xQ=v.createContext(void 0),SQ=()=>v.useContext(xQ),CQ=v.createContext(void 0),wQ=()=>v.useContext(CQ),TQ=v.createContext(void 0),EQ=v.forwardRef((e,t)=>{let n=BQ(()=>({search:``,value:e.value??e.defaultValue??``,selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}})),r=BQ(()=>new Set),i=BQ(()=>new Map),a=BQ(()=>new Map),o=BQ(()=>new Set),s=RQ(e),{label:c,children:l,value:u,onValueChange:d,filter:f,shouldFilter:p,loop:m,disablePointerSelection:h=!1,vimBindings:g=!0,..._}=e,y=Ou(),b=Ou(),x=Ou(),S=v.useRef(null),C=UQ();zQ(()=>{if(u!==void 0){let e=u.trim();n.current.value=e,w.emit()}},[u]),zQ(()=>{C(6,A)},[]);let w=v.useMemo(()=>({subscribe:e=>(o.current.add(e),()=>o.current.delete(e)),snapshot:()=>n.current,setState:(e,t,r)=>{var i,a,o;if(!Object.is(n.current[e],t)){if(n.current[e]=t,e===`search`)k(),D(),C(1,O);else if(e===`value`){if(document.activeElement.hasAttribute(`cmdk-input`)||document.activeElement.hasAttribute(`cmdk-root`)){let e=document.getElementById(x);e?e.focus():(i=document.getElementById(y))==null||i.focus()}if(C(7,()=>{n.current.selectedItemId=j()?.id,w.emit()}),r||C(5,A),s.current?.value!==void 0){let e=t??``;(o=(a=s.current).onValueChange)==null||o.call(a,e);return}}w.emit()}},emit:()=>{o.current.forEach(e=>e())}}),[]),T=v.useMemo(()=>({value:(e,t,r)=>{t!==a.current.get(e)?.value&&(a.current.set(e,{value:t,keywords:r}),n.current.filtered.items.set(e,E(t,r)),C(2,()=>{D(),w.emit()}))},item:(e,t)=>(r.current.add(e),t&&(i.current.has(t)?i.current.get(t).add(e):i.current.set(t,new Set([e]))),C(3,()=>{k(),D(),n.current.value||O(),w.emit()}),()=>{a.current.delete(e),r.current.delete(e),n.current.filtered.items.delete(e);let t=j();C(4,()=>{k(),t?.getAttribute(`id`)===e&&O(),w.emit()})}),group:e=>(i.current.has(e)||i.current.set(e,new Set),()=>{a.current.delete(e),i.current.delete(e)}),filter:()=>s.current.shouldFilter,label:c||e[`aria-label`],getDisablePointerSelection:()=>s.current.disablePointerSelection,listId:y,inputId:x,labelId:b,listInnerRef:S}),[]);function E(e,t){let r=s.current?.filter??bQ;return e?r(e,n.current.search,t):0}function D(){if(!n.current.search||s.current.shouldFilter===!1)return;let e=n.current.filtered.items,t=[];n.current.filtered.groups.forEach(n=>{let r=i.current.get(n),a=0;r.forEach(t=>{let n=e.get(t);a=Math.max(n,a)}),t.push([n,a])});let r=S.current;M().sort((t,n)=>{let r=t.getAttribute(`id`),i=n.getAttribute(`id`);return(e.get(i)??0)-(e.get(r)??0)}).forEach(e=>{let t=e.closest(mQ);t?t.appendChild(e.parentElement===t?e:e.closest(`${mQ} > *`)):r.appendChild(e.parentElement===r?e:e.closest(`${mQ} > *`))}),t.sort((e,t)=>t[1]-e[1]).forEach(e=>{let t=S.current?.querySelector(`${pQ}[${yQ}="${encodeURIComponent(e[0])}"]`);t?.parentElement.appendChild(t)})}function O(){let e=M().find(e=>e.getAttribute(`aria-disabled`)!==`true`)?.getAttribute(yQ);w.setState(`value`,e||void 0)}function k(){if(!n.current.search||s.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let e=0;for(let t of r.current){let r=E(a.current.get(t)?.value??``,a.current.get(t)?.keywords??[]);n.current.filtered.items.set(t,r),r>0&&e++}for(let[e,t]of i.current)for(let r of t)if(n.current.filtered.items.get(r)>0){n.current.filtered.groups.add(e);break}n.current.filtered.count=e}function A(){var e;let t=j();t&&(t.parentElement?.firstChild===t&&((e=t.closest(pQ)?.querySelector(hQ))==null||e.scrollIntoView({block:`nearest`})),t.scrollIntoView({block:`nearest`}))}function j(){return S.current?.querySelector(`${gQ}[aria-selected="true"]`)}function M(){return Array.from(S.current?.querySelectorAll(_Q)||[])}function N(e){let t=M()[e];t&&w.setState(`value`,t.getAttribute(yQ))}function P(e){var t;let n=j(),r=M(),i=r.findIndex(e=>e===n),a=r[i+e];(t=s.current)!=null&&t.loop&&(a=i+e<0?r[r.length-1]:i+e===r.length?r[0]:r[i+e]),a&&w.setState(`value`,a.getAttribute(yQ))}function F(e){let t=j()?.closest(pQ),n;for(;t&&!n;)t=e>0?IQ(t,pQ):LQ(t,pQ),n=t?.querySelector(_Q);n?w.setState(`value`,n.getAttribute(yQ)):P(e)}let I=()=>N(M().length-1),L=e=>{e.preventDefault(),e.metaKey?I():e.altKey?F(1):P(1)},R=e=>{e.preventDefault(),e.metaKey?N(0):e.altKey?F(-1):P(-1)};return v.createElement(tl.div,{ref:t,tabIndex:-1,..._,"cmdk-root":``,onKeyDown:e=>{var t;(t=_.onKeyDown)==null||t.call(_,e);let n=e.nativeEvent.isComposing||e.keyCode===229;if(!(e.defaultPrevented||n))switch(e.key){case`n`:case`j`:g&&e.ctrlKey&&L(e);break;case`ArrowDown`:L(e);break;case`p`:case`k`:g&&e.ctrlKey&&R(e);break;case`ArrowUp`:R(e);break;case`Home`:e.preventDefault(),N(0);break;case`End`:e.preventDefault(),I();break;case`Enter`:{e.preventDefault();let t=j();if(t){let e=new Event(vQ);t.dispatchEvent(e)}}}}},v.createElement(`label`,{"cmdk-label":``,htmlFor:T.inputId,id:T.labelId,style:KQ},c),GQ(e,e=>v.createElement(CQ.Provider,{value:w},v.createElement(xQ.Provider,{value:T},e))))}),DQ=v.forwardRef((e,t)=>{let n=Ou(),r=v.useRef(null),i=v.useContext(TQ),a=SQ(),o=RQ(e),s=o.current?.forceMount??i?.forceMount;zQ(()=>{if(!s)return a.item(n,i?.id)},[s]);let c=HQ(n,r,[e.value,e.children,r],e.keywords),l=wQ(),u=VQ(e=>e.value&&e.value===c.current),d=VQ(e=>s||a.filter()===!1?!0:e.search?e.filtered.items.get(n)>0:!0);v.useEffect(()=>{let t=r.current;if(!(!t||e.disabled))return t.addEventListener(vQ,f),()=>t.removeEventListener(vQ,f)},[d,e.onSelect,e.disabled]);function f(){var e,t;p(),(t=(e=o.current).onSelect)==null||t.call(e,c.current)}function p(){l.setState(`value`,c.current,!0)}if(!d)return null;let{disabled:m,value:h,onSelect:g,forceMount:_,keywords:y,...b}=e;return v.createElement(tl.div,{ref:cs(r,t),...b,id:n,"cmdk-item":``,role:`option`,"aria-disabled":!!m,"aria-selected":!!u,"data-disabled":!!m,"data-selected":!!u,onPointerMove:m||a.getDisablePointerSelection()?void 0:p,onClick:m?void 0:f},e.children)}),OQ=v.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:i,...a}=e,o=Ou(),s=v.useRef(null),c=v.useRef(null),l=Ou(),u=SQ(),d=VQ(e=>i||u.filter()===!1?!0:e.search?e.filtered.groups.has(o):!0);zQ(()=>u.group(o),[]),HQ(o,s,[e.value,e.heading,c]);let f=v.useMemo(()=>({id:o,forceMount:i}),[i]);return v.createElement(tl.div,{ref:cs(s,t),...a,"cmdk-group":``,role:`presentation`,hidden:d?void 0:!0},n&&v.createElement(`div`,{ref:c,"cmdk-group-heading":``,"aria-hidden":!0,id:l},n),GQ(e,e=>v.createElement(`div`,{"cmdk-group-items":``,role:`group`,"aria-labelledby":n?l:void 0},v.createElement(TQ.Provider,{value:f},e))))}),kQ=v.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,i=v.useRef(null),a=VQ(e=>!e.search);return!n&&!a?null:v.createElement(tl.div,{ref:cs(i,t),...r,"cmdk-separator":``,role:`separator`})}),AQ=v.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,i=e.value!=null,a=wQ(),o=VQ(e=>e.search),s=VQ(e=>e.selectedItemId),c=SQ();return v.useEffect(()=>{e.value!=null&&a.setState(`search`,e.value)},[e.value]),v.createElement(tl.input,{ref:t,...r,"cmdk-input":``,autoComplete:`off`,autoCorrect:`off`,spellCheck:!1,"aria-autocomplete":`list`,role:`combobox`,"aria-expanded":!0,"aria-controls":c.listId,"aria-labelledby":c.labelId,"aria-activedescendant":s,id:c.inputId,type:`text`,value:i?e.value:o,onChange:e=>{i||a.setState(`search`,e.target.value),n?.(e.target.value)}})}),jQ=v.forwardRef((e,t)=>{let{children:n,label:r=`Suggestions`,...i}=e,a=v.useRef(null),o=v.useRef(null),s=VQ(e=>e.selectedItemId),c=SQ();return v.useEffect(()=>{if(o.current&&a.current){let e=o.current,t=a.current,n,r=new ResizeObserver(()=>{n=requestAnimationFrame(()=>{let n=e.offsetHeight;t.style.setProperty(`--cmdk-list-height`,n.toFixed(1)+`px`)})});return r.observe(e),()=>{cancelAnimationFrame(n),r.unobserve(e)}}},[]),v.createElement(tl.div,{ref:cs(a,t),...i,"cmdk-list":``,role:`listbox`,tabIndex:-1,"aria-activedescendant":s,"aria-label":r,id:c.listId},GQ(e,e=>v.createElement(`div`,{ref:cs(o,c.listInnerRef),"cmdk-list-sizer":``},e)))}),MQ=v.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:i,contentClassName:a,container:o,...s}=e;return v.createElement(ix,{open:n,onOpenChange:r},v.createElement(ax,{container:o},v.createElement(ox,{"cmdk-overlay":``,className:i}),v.createElement(sx,{"aria-label":e.label,"cmdk-dialog":``,className:a},v.createElement(EQ,{ref:t,...s}))))}),NQ=v.forwardRef((e,t)=>VQ(e=>e.filtered.count===0)?v.createElement(tl.div,{ref:t,...e,"cmdk-empty":``,role:`presentation`}):null),PQ=v.forwardRef((e,t)=>{let{progress:n,children:r,label:i=`Loading...`,...a}=e;return v.createElement(tl.div,{ref:t,...a,"cmdk-loading":``,role:`progressbar`,"aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":i},GQ(e,e=>v.createElement(`div`,{"aria-hidden":!0},e)))}),FQ=Object.assign(EQ,{List:jQ,Item:DQ,Input:AQ,Group:OQ,Separator:kQ,Dialog:MQ,Empty:NQ,Loading:PQ});function IQ(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function LQ(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function RQ(e){let t=v.useRef(e);return zQ(()=>{t.current=e}),t}var zQ=typeof window>`u`?v.useEffect:v.useLayoutEffect;function BQ(e){let t=v.useRef();return t.current===void 0&&(t.current=e()),t}function VQ(e){let t=wQ(),n=()=>e(t.snapshot());return v.useSyncExternalStore(t.subscribe,n,n)}function HQ(e,t,n,r=[]){let i=v.useRef(),a=SQ();return zQ(()=>{var o;let s=(()=>{for(let e of n){if(typeof e==`string`)return e.trim();if(typeof e==`object`&&`current`in e)return e.current?e.current.textContent?.trim():i.current}})(),c=r.map(e=>e.trim());a.value(e,s,c),(o=t.current)==null||o.setAttribute(yQ,s),i.current=s}),i}var UQ=()=>{let[e,t]=v.useState(),n=BQ(()=>new Map);return zQ(()=>{n.current.forEach(e=>e()),n.current=new Map},[e]),(e,r)=>{n.current.set(e,r),t({})}};function WQ(e){let t=e.type;return typeof t==`function`?t(e.props):`render`in t?t.render(e.props):e}function GQ({asChild:e,children:t},n){return e&&v.isValidElement(t)?v.cloneElement(WQ(t),{ref:t.ref},n(t.props.children)):n(t)}var KQ={position:`absolute`,width:`1px`,height:`1px`,padding:`0`,margin:`-1px`,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,borderWidth:`0`},qQ=v.forwardRef(({className:e,...t},n)=>(0,U.jsx)(FQ,{ref:n,className:q(`flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground`,e),...t}));qQ.displayName=FQ.displayName;var JQ=v.forwardRef(({className:e,...t},n)=>(0,U.jsxs)(`div`,{className:`flex items-center border-b px-3`,"cmdk-input-wrapper":``,children:[(0,U.jsx)(Ro,{className:`mr-2 h-4 w-4 shrink-0 opacity-50`}),(0,U.jsx)(FQ.Input,{ref:n,className:q(`flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50`,e),...t})]}));JQ.displayName=FQ.Input.displayName;var YQ=v.forwardRef(({className:e,...t},n)=>(0,U.jsx)(FQ.List,{ref:n,className:q(`max-h-[300px] overflow-y-auto overflow-x-hidden`,e),...t}));YQ.displayName=FQ.List.displayName;var XQ=v.forwardRef((e,t)=>(0,U.jsx)(FQ.Empty,{ref:t,className:`py-6 text-center text-sm`,...e}));XQ.displayName=FQ.Empty.displayName;var ZQ=v.forwardRef(({className:e,...t},n)=>(0,U.jsx)(FQ.Group,{ref:n,className:q(`overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground`,e),...t}));ZQ.displayName=FQ.Group.displayName;var QQ=v.forwardRef(({className:e,...t},n)=>(0,U.jsx)(FQ.Separator,{ref:n,className:q(`-mx-1 h-px bg-border`,e),...t}));QQ.displayName=FQ.Separator.displayName;var $Q=v.forwardRef(({className:e,...t},n)=>(0,U.jsx)(FQ.Item,{ref:n,className:q(`relative flex cursor-default gap-2 select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected='true']:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0`,e),...t}));$Q.displayName=FQ.Item.displayName;var e$=({className:e,...t})=>(0,U.jsx)(`span`,{className:q(`ml-auto text-xs tracking-widest text-muted-foreground`,e),...t});e$.displayName=`CommandShortcut`;var t$={image:`image/*`,video:`video/*`,audio:`audio/*`,document:`.pdf,.doc,.docx,.xls,.xlsx,.ppt,.pptx,.txt,.csv`};function n$(e){return!e||e.length===0?`*/*`:e.map(e=>t$[e]).join(`,`)}function r$(e){let t=e.replace(/_/g,` `).trim();return t?t.charAt(0).toUpperCase()+t.slice(1):`Value`}function i$(e){return e?e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`:`—`}function a$(e){return e?.startsWith(`image/`)??!1}async function o$(e,t){return XZ(e,{folderId:t})}function s$(e,t){if(!t||t.length===0)return!0;let n=e??``;return t.some(e=>e===`image`?n.startsWith(`image/`):e===`video`?n.startsWith(`video/`):e===`audio`?n.startsWith(`audio/`):e===`document`?n.startsWith(`application/`)||n.startsWith(`text/`):!1)}function c$({open:e,onOpenChange:t,allowedTypes:n,onSelect:r}){let[i,a]=(0,v.useState)([{id:null,name:`Media`}]),o=i[i.length-1].id,[s,c]=(0,v.useState)([]),[l,u]=(0,v.useState)([]),[d,f]=(0,v.useState)(!1);(0,v.useEffect)(()=>{if(!e)return;f(!0);let t=localStorage.getItem(`plank_token`),n=t?{Authorization:`Bearer ${t}`}:{},r=o??``;Promise.all([fetch(`/cms/admin/folders?parent_id=${r}`,{headers:n}).then(e=>e.ok?e.json():{folders:[]}).then(e=>e.folders),fetch(`/cms/admin/media?folder_id=${r}`,{headers:n}).then(e=>e.ok?e.json():{items:[]}).then(e=>e.items)]).then(([e,t])=>{c(e),u(t)}).catch(()=>{c([]),u([])}).finally(()=>f(!1))},[e,o]),(0,v.useEffect)(()=>{e||a([{id:null,name:`Media`}])},[e]);function p(e){a(t=>[...t,{id:e.id,name:e.name}])}function m(e){a(t=>t.slice(0,e+1))}let h=l.filter(e=>s$(e.mime_type,n)),g=s.length===0&&h.length===0;return(0,U.jsx)(yw,{open:e,onOpenChange:t,children:(0,U.jsxs)(Cw,{className:`max-w-3xl`,children:[(0,U.jsx)(ww,{children:(0,U.jsx)(Ew,{children:`Media Library`})}),i.length>1&&(0,U.jsx)(`div`,{className:`flex items-center gap-1 text-sm -mt-1`,children:i.map((e,t)=>(0,U.jsxs)(`span`,{className:`flex items-center gap-1 text-muted-foreground`,children:[t>0&&(0,U.jsx)(`span`,{children:`/`}),t===i.length-1?(0,U.jsx)(`span`,{className:`font-medium text-foreground`,children:t===0?(0,U.jsx)(go,{className:`size-3.5`}):e.name}):(0,U.jsx)(`button`,{onClick:()=>m(t),className:`hover:text-foreground transition-colors`,children:t===0?(0,U.jsx)(go,{className:`size-3.5`}):e.name})]},t))}),d?(0,U.jsx)(`div`,{className:`flex items-center justify-center py-16`,children:(0,U.jsx)(by,{className:`size-5`})}):g?(0,U.jsx)(`p`,{className:`py-16 text-center text-sm text-muted-foreground`,children:l.length===0&&s.length===0?`No media found.`:`No matching files in this folder.`}):(0,U.jsxs)(`div`,{className:`flex flex-col gap-4 max-h-[60vh] overflow-y-auto pr-1`,children:[s.length>0&&(0,U.jsx)(`div`,{className:`grid grid-cols-1 gap-1.5 sm:grid-cols-2`,children:s.map(e=>(0,U.jsxs)(`button`,{type:`button`,onClick:()=>p(e),className:`flex items-center gap-2.5 rounded-md border bg-card px-2.5 py-2 text-left transition-colors hover:bg-muted/50 hover:border-primary`,children:[(0,U.jsx)(lo,{className:`size-7 shrink-0 text-muted-foreground`}),(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsx)(`p`,{className:`truncate text-xs font-bold leading-tight`,title:e.name,children:e.name}),(0,U.jsxs)(`p`,{className:`text-[10px] text-muted-foreground`,children:[e.item_count,` `,e.item_count===1?`item`:`items`]})]})]},e.id))}),h.length>0&&(0,U.jsx)(`div`,{className:`grid grid-cols-3 gap-2 sm:grid-cols-4 md:grid-cols-5`,children:h.map(e=>(0,U.jsxs)(`button`,{type:`button`,onClick:()=>{r(e),t(!1)},className:`group relative overflow-hidden rounded-md border bg-card text-left transition-colors hover:border-primary`,children:[(0,U.jsx)(`div`,{className:`aspect-square bg-muted`,children:a$(e.mime_type)?(0,U.jsx)(`img`,{src:e.url,alt:e.filename,className:`h-full w-full object-cover`}):(0,U.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,U.jsx)(ao,{className:`size-6 text-muted-foreground`})})}),(0,U.jsxs)(`div`,{className:`p-1.5`,children:[(0,U.jsx)(`p`,{className:`truncate text-[11px] font-medium leading-tight`,title:e.filename,children:e.filename}),(0,U.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:i$(e.size)})]}),(0,U.jsx)(`div`,{className:`absolute inset-0 rounded-md ring-2 ring-primary ring-offset-1 opacity-0 group-hover:opacity-100 transition-opacity pointer-events-none`})]},e.id))})]})]})})}function l$({value:e,onChange:t,allowedTypes:n,disabled:r=!1}){let i=(0,v.useRef)(null),[a,o]=(0,v.useState)(!1),[s,c]=(0,v.useState)(null),[l,u]=(0,v.useState)(null),[d,f]=(0,v.useState)(!1),p=typeof e==`string`&&e.startsWith(`http`);(0,v.useEffect)(()=>{if(!e){u(null);return}if(p){u(e);return}let t=localStorage.getItem(`plank_token`);fetch(`/cms/admin/media/${e}/url`,{headers:t?{Authorization:`Bearer ${t}`}:{}}).then(e=>e.ok?e.json():null).then(e=>u(e?.url??null)).catch(()=>u(null))},[e,p]);async function m(e){o(!0),c(null);try{let n=await o$(e);u(n.url),t(n.id)}catch(e){c(e instanceof Error?e.message:`Upload failed.`)}finally{o(!1),i.current&&(i.current.value=``)}}let h=l&&/\.(jpe?g|png|gif|webp|avif|svg)(\?|$)/i.test(l);return e?(0,U.jsxs)(`div`,{className:`relative w-full rounded-md border bg-muted/30 overflow-hidden`,children:[l?h?(0,U.jsx)(`img`,{src:l,alt:`Media`,className:`max-h-72 w-full object-contain`}):(0,U.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2`,children:[(0,U.jsx)(_o,{className:`size-4 text-muted-foreground shrink-0`}),(0,U.jsx)(`span`,{className:`text-xs text-muted-foreground truncate`,children:l})]}):(0,U.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 text-muted-foreground`,children:[(0,U.jsx)(_o,{className:`size-4 shrink-0`}),(0,U.jsx)(`span`,{className:`text-xs`,children:`Loading…`})]}),(0,U.jsx)(J,{type:`button`,size:`icon`,variant:`secondary`,className:`absolute top-1.5 right-1.5 size-6`,onClick:()=>{t(null),u(null)},disabled:r,children:(0,U.jsx)(ns,{className:`size-3.5`})})]}):(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`input`,{ref:i,type:`file`,accept:n$(n),className:`hidden`,onChange:e=>{let t=e.target.files?.[0];t&&m(t)}}),(0,U.jsxs)(`div`,{onDragOver:e=>e.preventDefault(),onDrop:e=>{if(r)return;e.preventDefault();let t=e.dataTransfer.files[0];t&&m(t)},className:`flex w-full gap-2 rounded-md border border-dashed p-3`,children:[(0,U.jsxs)(`button`,{type:`button`,disabled:a||r,onClick:()=>i.current?.click(),className:`flex flex-1 items-center justify-center gap-2 rounded-md py-2 text-sm text-muted-foreground transition-colors hover:bg-muted/50 disabled:opacity-50`,children:[(0,U.jsx)(Qo,{className:`size-4`}),a?`Uploading…`:`Upload`]}),(0,U.jsx)(`div`,{className:`w-px bg-border`}),(0,U.jsxs)(`button`,{type:`button`,disabled:a||r,onClick:()=>f(!0),className:`flex flex-1 items-center justify-center gap-2 rounded-md py-2 text-sm text-muted-foreground transition-colors hover:bg-muted/50 disabled:opacity-50`,children:[(0,U.jsx)(so,{className:`size-4`}),`Library`]})]}),s&&(0,U.jsx)(`p`,{className:`mt-1 text-xs text-destructive`,children:s}),(0,U.jsx)(c$,{open:d,onOpenChange:f,allowedTypes:n,onSelect:e=>{u(e.url),t(e.id)}})]})}function u$({id:e,previewUrl:t,filename:n,onRemove:r,disabled:i=!1}){let{attributes:a,listeners:o,setNodeRef:s,transform:c,transition:l,isDragging:u}=gO({id:e});return(0,U.jsxs)(`div`,{ref:s,style:{transform:kT.Transform.toString(c),transition:l,opacity:u?.4:1},className:`relative aspect-square overflow-hidden rounded-md border bg-muted`,children:[t?(0,U.jsx)(`img`,{src:t,alt:n,className:`h-full w-full object-cover`}):(0,U.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,U.jsx)(_o,{className:`size-5 text-muted-foreground`})}),n&&(0,U.jsx)(`div`,{className:`absolute bottom-0 left-0 right-0 bg-background/75 backdrop-blur-sm px-1.5 py-1 pointer-events-none`,children:(0,U.jsx)(`p`,{className:`truncate text-[10px] leading-none text-foreground`,children:n})}),(0,U.jsx)(`button`,{type:`button`,onClick:r,disabled:i,className:`absolute right-1 top-1 flex size-5 items-center justify-center rounded-full bg-background/80 text-foreground shadow-sm hover:bg-background`,children:(0,U.jsx)(ns,{className:`size-3`})}),!i&&(0,U.jsx)(`button`,{type:`button`,className:`absolute bottom-6 left-1 flex size-5 cursor-grab items-center justify-center rounded-full bg-background/80 text-foreground shadow-sm active:cursor-grabbing`,...o,...a,children:(0,U.jsx)(uo,{className:`size-3`})})]})}function d$({value:e,onChange:t,disabled:n=!1}){let r=Array.isArray(e)?e:[],[i,a]=(0,v.useState)({}),[o,s]=(0,v.useState)({}),[c,l]=(0,v.useState)(!1),[u,d]=(0,v.useState)(null),[f,p]=(0,v.useState)(!1),m=(0,v.useRef)(null),h=GT(WT(GE,{activationConstraint:{distance:5}}));(0,v.useEffect)(()=>{let e=r.filter(e=>!e.startsWith(`http`)&&!(e in i));if(e.length===0)return;let t=localStorage.getItem(`plank_token`);Promise.all(e.map(e=>fetch(`/cms/admin/media/${e}/url`,{headers:t?{Authorization:`Bearer ${t}`}:{}}).then(e=>e.ok?e.json():null).then(t=>t?[e,t.url]:null).catch(()=>null))).then(e=>{let t={};for(let n of e)n&&(t[n[0]]=n[1]);Object.keys(t).length>0&&a(e=>({...e,...t}))})},[r.join(`,`)]),(0,v.useEffect)(()=>{let e=r.filter(e=>!e.startsWith(`http`)&&!(e in o));if(e.length===0)return;let t=localStorage.getItem(`plank_token`);fetch(`/cms/admin/media`,{headers:t?{Authorization:`Bearer ${t}`}:{}}).then(e=>e.ok?e.json():{items:[]}).then(t=>{let n={};for(let r of t.items)e.includes(r.id)&&(n[r.id]=r.filename);Object.keys(n).length>0&&s(e=>({...e,...n}))}).catch(()=>{})},[r.join(`,`)]);function g(e){return e.startsWith(`http`)?e:i[e]??null}function _(e){return o[e]??``}function y(e){if(n)return;let{active:i,over:a}=e;!a||i.id===a.id||t(ZD(r,r.indexOf(i.id),r.indexOf(a.id)))}async function b(e){if(e.length===0)return;l(!0),d(null);let n=r;try{for(let r of e){let e=await o$(r);a(t=>({...t,[e.id]:e.url})),s(t=>({...t,[e.id]:r.name})),n=[...n,e.id],t(n)}}catch(e){d(e instanceof Error?e.message:`Upload failed.`)}finally{l(!1),m.current&&(m.current.value=``)}}return(0,U.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,U.jsx)(`input`,{ref:m,type:`file`,accept:`image/*`,multiple:!0,className:`hidden`,onChange:e=>{b(Array.from(e.target.files??[]))}}),r.length>0&&(0,U.jsx)(HD,{sensors:h,collisionDetection:QT,onDragEnd:y,children:(0,U.jsx)(cO,{items:r,strategy:nO,children:(0,U.jsx)(`div`,{className:`grid grid-cols-3 gap-2 sm:grid-cols-4`,children:r.map(e=>(0,U.jsx)(u$,{id:e,previewUrl:g(e),filename:_(e),onRemove:()=>t(r.filter(t=>t!==e)),disabled:n},e))})})}),(0,U.jsxs)(`div`,{className:`flex w-full gap-2 rounded-md border border-dashed p-3`,children:[(0,U.jsxs)(`button`,{type:`button`,disabled:c||n,onClick:()=>m.current?.click(),className:`flex flex-1 items-center justify-center gap-2 rounded-md py-2 text-sm text-muted-foreground transition-colors hover:bg-muted/50 disabled:opacity-50`,children:[(0,U.jsx)(Qo,{className:`size-4`}),c?`Uploading…`:`Upload`]}),(0,U.jsx)(`div`,{className:`w-px bg-border`}),(0,U.jsxs)(`button`,{type:`button`,disabled:c||n,onClick:()=>p(!0),className:`flex flex-1 items-center justify-center gap-2 rounded-md py-2 text-sm text-muted-foreground transition-colors hover:bg-muted/50 disabled:opacity-50`,children:[(0,U.jsx)(so,{className:`size-4`}),`Library`]})]}),u&&(0,U.jsx)(`p`,{className:`text-xs text-destructive`,children:u}),(0,U.jsx)(c$,{open:f,onOpenChange:p,allowedTypes:[`image`],onSelect:e=>{r.includes(e.id)||(a(t=>({...t,[e.id]:e.url})),s(t=>({...t,[e.id]:e.filename})),t([...r,e.id]))}})]})}function f$({value:e,onChange:t,disabled:n=!1}){let[r,i]=(0,v.useState)(()=>e!=null&&e!==``?String(e):``);(0,v.useEffect)(()=>{if(e==null||e===``){i(``);return}let t=typeof e==`number`?e:parseFloat(String(e));!isNaN(t)&&t!==parseFloat(r)&&i(String(t))},[e]);function a(e){let n=e.target.value.replace(`,`,`.`);if(i(n),n===``||n===`-`){t(null);return}let r=parseFloat(n);isNaN(r)||t(r)}return(0,U.jsx)(Hv,{type:`text`,inputMode:`decimal`,className:q(`w-full`,`text-base!`),value:r,placeholder:`0.00`,onChange:a,disabled:n})}function p$(e){if(typeof e==`object`&&e){let t=e;if(t.kind===`string`&&typeof t.value==`string`)return{kind:`string`,value:t.value};if(t.kind===`number`&&typeof t.value==`number`&&!isNaN(t.value))return{kind:`number`,value:t.value};if(t.kind===`boolean`&&typeof t.value==`boolean`)return{kind:`boolean`,value:t.value}}return typeof e==`number`&&!isNaN(e)?{kind:`number`,value:e}:typeof e==`boolean`?{kind:`boolean`,value:e}:{kind:`string`,value:typeof e==`string`?e:``}}function m$({value:e,onChange:t,inputId:n,disabled:r=!1}){let i=p$(e);function a(e){e===`string`&&t({kind:e,value:``}),e===`number`&&t({kind:e,value:0}),e===`boolean`&&t({kind:e,value:!1})}return(0,U.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,U.jsx)(`div`,{className:`inline-flex items-center gap-1 rounded-md border border-border p-1`,children:[`string`,`number`,`boolean`].map(e=>(0,U.jsx)(`button`,{type:`button`,disabled:r,onClick:()=>a(e),className:q(`rounded px-2 py-1 text-xs transition-colors`,i.kind===e?`bg-accent text-accent-foreground`:`text-muted-foreground hover:bg-accent/60`),children:e===`string`?`Text`:e===`number`?`Number`:`Boolean`},e))}),i.kind===`string`&&(0,U.jsx)(Hv,{className:q(`w-full`,`text-base md:text-base`),value:String(i.value),placeholder:`Value`,onChange:e=>t({kind:`string`,value:e.target.value}),disabled:r}),i.kind===`number`&&(0,U.jsx)(f$,{value:i.value,onChange:e=>t({kind:`number`,value:typeof e==`number`&&!isNaN(e)?e:0}),disabled:r}),i.kind===`boolean`&&(0,U.jsxs)(`div`,{className:`flex items-center gap-2 pt-1`,children:[(0,U.jsx)(EO,{id:n,checked:!!i.value,onCheckedChange:e=>t({kind:`boolean`,value:!!e}),disabled:r}),(0,U.jsx)(X,{htmlFor:n,className:`cursor-pointer font-normal text-base`,children:i.value?`True`:`False`})]})]})}function h$({value:e,onChange:t,timezone:n,disabled:r=!1}){let[i,a]=(0,v.useState)(!1),[o,s]=(0,v.useState)(),[c,l]=(0,v.useState)(`00:00`);(0,v.useEffect)(()=>{if(!e){s(void 0),l(`00:00`);return}let t=new Date(e);isNaN(t.getTime())||(s(t),l(Ty(e,n)))},[e,n]);function u(e){s(e),a(!1),e&&t(Ey(e,c,n))}function d(e){l(e),o&&t(Ey(o,e,n))}return(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsxs)(LN,{open:i&&!r,onOpenChange:a,children:[(0,U.jsx)(RN,{asChild:!0,children:(0,U.jsxs)(J,{variant:`outline`,className:`w-40 justify-between font-normal text-base`,disabled:r,children:[o?VA(o,`MMM d, yyyy`):`Select date`,(0,U.jsx)(Ba,{className:`size-4 opacity-50`})]})}),(0,U.jsx)(zN,{className:`w-auto overflow-hidden p-0`,align:`start`,children:(0,U.jsx)(FN,{mode:`single`,selected:o,captionLayout:`dropdown`,defaultMonth:o??new Date,onSelect:u})})]}),(0,U.jsx)(Hv,{type:`time`,className:`w-32 appearance-none bg-background [&::-webkit-calendar-picker-indicator]:hidden [&::-webkit-calendar-picker-indicator]:appearance-none text-base!`,value:c,onChange:e=>d(e.target.value),disabled:r}),e&&(0,U.jsx)(J,{type:`button`,variant:`ghost`,size:`icon`,className:`size-8 text-muted-foreground hover:text-foreground`,onClick:()=>{s(void 0),l(`00:00`),t(null)},disabled:r,children:(0,U.jsx)(ns,{className:`size-3.5`})})]})}function g$(e){return e.find(e=>e.type===`uid`)?.name??e.find(e=>e.type===`string`)?.name??null}var _$={data:null,promise:null};function v$(e){return _$.data?Promise.resolve(_$.data):(_$.promise||=fetch(`/cms/admin/content-types`,{headers:e}).then(e=>e.ok?e.json():[]).then(e=>(_$.data=e,e)).catch(()=>[]),_$.promise)}function y$(e,t){return e.find(e=>e.tableName===t)??null}function b$(e,t){return fetch(`/cms/admin/content-types/${e}/entries?limit=200`,{headers:t}).then(e=>e.ok?e.json():{data:[]}).catch(()=>({data:[]}))}function x$(e){let[t,n]=(0,v.useState)([]),[r,i]=(0,v.useState)(!1);return(0,v.useEffect)(()=>{if(!e)return;i(!0);let t=localStorage.getItem(`plank_token`),r=t?{Authorization:`Bearer ${t}`}:{};v$(r).then(t=>{let n=y$(t,e);return n?b$(n.slug,r).then(e=>({ctDef:n,res:e})):Promise.resolve({ctDef:null,res:{data:[]}})}).then(({ctDef:e,res:t})=>{let r=e?g$(e.fields??[]):null;n(t.data.map(e=>({id:String(e.id),label:String(r?e[r]??e.id:e.id)})))}).catch(()=>n([])).finally(()=>i(!1))},[e]),{entries:t,loading:r}}function S$(e,t,n){let[r,i]=(0,v.useState)([]),[a,o]=(0,v.useState)(!1);return(0,v.useEffect)(()=>{if(!e||!n){i([]);return}o(!0);let r=localStorage.getItem(`plank_token`),a=r?{Authorization:`Bearer ${r}`}:{};v$(a).then(t=>{let n=y$(t,e);return n?b$(n.slug,a).then(e=>({ctDef:n,res:e})):Promise.resolve({ctDef:null,res:{data:[]}})}).then(({ctDef:e,res:r})=>{let a=e?g$(e.fields??[]):null;i(r.data.filter(e=>String(e[t]??``)===n).map(e=>({id:String(e.id),label:String(a?e[a]??e.id:e.id)})))}).catch(()=>i([])).finally(()=>o(!1))},[e,t,n]),{entries:r,loading:a}}function C$({relatedTable:e,relatedField:t,currentId:n}){let{entries:r,loading:i}=S$(e,t,n);return n?i?(0,U.jsxs)(`div`,{className:`flex items-center gap-2 py-1`,children:[(0,U.jsx)(by,{className:`size-3.5`}),(0,U.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Loading…`})]}):r.length===0?(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No linked entries.`}):(0,U.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:r.map(e=>(0,U.jsx)(`span`,{className:`inline-flex items-center rounded-md border bg-muted px-2 py-0.5 text-xs`,children:e.label},e.id))}):(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Save this entry first to see linked items.`})}function w$({relationType:e,relatedTable:t,relatedField:n,currentEntryId:r,value:i,onChange:a,disabled:o=!1}){let s=e===`many-to-many`,[c,l]=(0,v.useState)(!1),{entries:u,loading:d}=x$(t);if(e===`one-to-many`)return(0,U.jsx)(C$,{relatedTable:t,relatedField:n,currentId:r});let f=s?Array.isArray(i)?i:[]:i&&!Array.isArray(i)?[i]:[];function p(e){return u.find(t=>t.id===e)?.label??e}function m(e){if(s){let t=f.includes(e)?f.filter(t=>t!==e):[...f,e];a(t.length>0?t:null)}else a(f[0]===e?null:e),l(!1)}function h(e){if(s){let t=f.filter(t=>t!==e);a(t.length>0?t:null)}else a(null)}let g=s?f.length>0?`${f.length} selected`:`Select entries…`:f.length>0?p(f[0]):`Select entry…`;return(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsxs)(LN,{open:c&&!o,onOpenChange:l,children:[(0,U.jsx)(RN,{asChild:!0,children:(0,U.jsxs)(J,{variant:`outline`,role:`combobox`,"aria-expanded":c,className:`w-full justify-between font-normal text-base`,disabled:o,children:[(0,U.jsx)(`span`,{className:`truncate text-left`,children:g}),(0,U.jsx)(Wa,{className:`ml-2 size-4 shrink-0 opacity-50`})]})}),(0,U.jsx)(zN,{className:`w-(--radix-popover-trigger-width) p-0`,align:`start`,children:(0,U.jsxs)(qQ,{children:[(0,U.jsx)(JQ,{placeholder:`Search…`}),(0,U.jsx)(YQ,{children:d?(0,U.jsx)(`div`,{className:`flex items-center justify-center py-6`,children:(0,U.jsx)(by,{className:`size-4`})}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(XQ,{children:`No entries found.`}),(0,U.jsx)(ZQ,{children:u.map(e=>{let t=f.includes(e.id);return(0,U.jsxs)($Q,{value:e.label,onSelect:()=>{o||m(e.id)},children:[(0,U.jsx)(za,{className:`mr-2 size-4 ${t?`opacity-100`:`opacity-0`}`}),(0,U.jsx)(`span`,{className:`truncate`,children:e.label}),(0,U.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground opacity-60 shrink-0`,children:e.id.slice(0,8)})]},e.id)})})]})})]})})]}),f.length>0&&(0,U.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:f.map(e=>(0,U.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border bg-muted px-2 py-0.5 text-xs`,children:[p(e),(0,U.jsx)(`button`,{type:`button`,onClick:()=>h(e),disabled:o,className:`text-muted-foreground hover:text-foreground`,children:(0,U.jsx)(ns,{className:`size-3`})})]},e))})]})}var T$={full:`col-span-6`,"two-thirds":`col-span-4`,half:`col-span-3`,third:`col-span-2`};function E$({field:e,value:t,onChange:n,disabled:r=!1}){let i=Array.isArray(t)?t:[],a=e.arrayFields??[];function o(){return Object.fromEntries(a.map(e=>[e.name,e.type===`boolean`?!1:null]))}function s(){n([...i,o()])}function c(e){n(i.filter((t,n)=>n!==e))}function l(e,t){let r=e+t;if(r<0||r>=i.length)return;let a=[...i];[a[e],a[r]]=[a[r],a[e]],n(a)}function u(e,t,r){n(i.map((n,i)=>i===e?{...n,[t]:r}:n))}return a.length===0?(0,U.jsx)(`div`,{className:`flex w-full items-center justify-center rounded-md border border-dashed p-4 text-xs text-muted-foreground`,children:`No sub-fields defined for this array.`}):(0,U.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,U.jsx)(VN,{type:`single`,collapsible:!0,className:`w-full`,children:i.map((e,t)=>(0,U.jsxs)(HN,{value:`item-${t}`,className:`mb-2 rounded-md border border-dashed last:border-b transition-colors hover:bg-accent/50`,children:[(0,U.jsxs)(`div`,{className:`relative data-[state=open]:border-b data-[state=open]:border-border/50`,children:[(0,U.jsxs)(UN,{className:`w-full py-2 pl-3 pr-24 text-muted-foreground [&>svg]:hidden`,children:[`Item `,t+1]}),(0,U.jsxs)(`div`,{className:`absolute right-2 top-1/2 flex -translate-y-1/2 items-center gap-0.5`,children:[(0,U.jsx)(J,{size:`icon`,variant:`ghost`,disabled:r||t===0,onMouseDown:e=>e.stopPropagation(),onClick:()=>l(t,-1),className:`flex size-6 items-center justify-center rounded text-muted-foreground hover:bg-accent disabled:opacity-30`,children:(0,U.jsx)(Ua,{className:`size-3.5`})}),(0,U.jsx)(J,{size:`icon`,variant:`ghost`,disabled:r||t===i.length-1,onMouseDown:e=>e.stopPropagation(),onClick:()=>l(t,1),className:`flex size-6 items-center justify-center rounded text-muted-foreground hover:bg-accent disabled:opacity-30`,children:(0,U.jsx)(Ba,{className:`size-3.5`})}),(0,U.jsx)(`button`,{type:`button`,onMouseDown:e=>e.stopPropagation(),onClick:()=>c(t),disabled:r,className:`flex size-6 items-center justify-center rounded text-destructive transition-colors hover:bg-destructive/10 hover:text-destructive`,children:(0,U.jsx)(qo,{className:`size-3.5`})})]})]}),(0,U.jsx)(WN,{className:`px-3 pt-3`,children:(0,U.jsx)(`div`,{className:`grid grid-cols-6 gap-3`,children:a.map(n=>(0,U.jsxs)(`div`,{className:T$[n.width??`full`]??`col-span-6`,children:[(0,U.jsx)(`div`,{className:`mb-1 flex items-center gap-1`,children:(0,U.jsxs)(X,{className:`text-xs font-medium`,children:[n.name,n.required&&(0,U.jsx)(`span`,{className:`ml-0.5 text-destructive`,children:`*`})]})}),(0,U.jsx)(M$,{field:{...n,type:n.type},value:e[n.name]??null,onChange:e=>u(t,n.name,e),allValues:e,disabled:r})]},n.name))})})]},t))}),(0,U.jsxs)(`button`,{type:`button`,onClick:s,disabled:r,className:`flex w-full items-center justify-center gap-1.5 rounded-md border border-dashed py-2 text-xs text-muted-foreground transition-colors hover:bg-accent/50`,children:[(0,U.jsx)(Po,{className:`size-3.5`}),`Add item`]})]})}var D$=3,O$=20;function k$({value:e,onChange:t,disabled:n=!1,depth:r=0}){let i=Array.isArray(e)?e:[],a=r+1<D$,o=i.length<O$;function s(){return{label:``,href:``}}function c(e,n){let r=(t,i)=>{let a=e[i];return t.map((t,o)=>{if(o!==a)return t;if(i===e.length-1)return n(t);let s=Array.isArray(t.items)?t.items:[];return{...t,items:r(s,i+1)}})};t(r(i,0))}function l(e,n){let r=(t,i)=>{if(i===e.length-1){let r=e[i],a=r+n;if(a<0||a>=t.length)return t;let o=[...t];return[o[r],o[a]]=[o[a],o[r]],o}let a=e[i];return t.map((e,t)=>{if(t!==a)return e;let n=Array.isArray(e.items)?e.items:[];return{...e,items:r(n,i+1)}})};t(r(i,0))}function u(e){let n=(t,r)=>{let i=e[r];return r===e.length-1?t.filter((e,t)=>t!==i):t.map((e,t)=>{if(t!==i)return e;let a=Array.isArray(e.items)?e.items:[];return{...e,items:n(a,r+1)}})};t(n(i,0))}function d(){o&&t([...i,s()])}return i.length===0?(0,U.jsxs)(`button`,{type:`button`,onClick:d,disabled:n||!o,className:`flex w-full items-center justify-center gap-1.5 rounded-md border border-dashed py-2 text-xs text-muted-foreground transition-colors hover:bg-accent/20`,children:[(0,U.jsx)(Po,{className:`size-3.5`}),`Add item`]}):(0,U.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,U.jsx)(VN,{type:`single`,collapsible:!0,className:`w-full`,children:i.map((e,t)=>{let o=[t],s=e.label?.trim()?e.label:`Item ${t+1}`;return(0,U.jsxs)(HN,{value:`navigation-item-${r}-${t}`,className:`mb-2 rounded-md border border-dashed last:border-b transition-colors hover:bg-accent/50`,children:[(0,U.jsxs)(`div`,{className:`relative data-[state=open]:border-b data-[state=open]:border-border/50`,children:[(0,U.jsx)(UN,{className:`w-full py-2 pl-3 pr-24 text-muted-foreground [&>svg]:hidden`,children:s}),(0,U.jsxs)(`div`,{className:`absolute right-2 top-1/2 flex -translate-y-1/2 items-center gap-0.5`,children:[(0,U.jsx)(J,{size:`icon`,variant:`ghost`,disabled:n||t===0,onMouseDown:e=>e.stopPropagation(),onClick:()=>l(o,-1),className:`flex size-6 items-center justify-center rounded text-muted-foreground hover:bg-accent disabled:opacity-30`,children:(0,U.jsx)(Ua,{className:`size-3.5`})}),(0,U.jsx)(J,{size:`icon`,variant:`ghost`,disabled:n||t===i.length-1,onMouseDown:e=>e.stopPropagation(),onClick:()=>l(o,1),className:`flex size-6 items-center justify-center rounded text-muted-foreground hover:bg-accent disabled:opacity-30`,children:(0,U.jsx)(Ba,{className:`size-3.5`})}),(0,U.jsx)(`button`,{type:`button`,onMouseDown:e=>e.stopPropagation(),onClick:()=>u(o),disabled:n,className:`flex size-6 items-center justify-center rounded text-destructive transition-colors hover:bg-destructive/10 hover:text-destructive`,children:(0,U.jsx)(qo,{className:`size-3.5`})})]})]}),(0,U.jsxs)(WN,{className:`px-3 pt-3`,children:[(0,U.jsxs)(`div`,{className:`grid grid-cols-6 gap-3`,children:[(0,U.jsxs)(`div`,{className:`col-span-3`,children:[(0,U.jsx)(X,{className:`mb-1 block text-xs font-medium`,children:`label`}),(0,U.jsx)(Hv,{className:`text-base`,value:e.label??``,onChange:e=>c(o,t=>({...t,label:e.target.value})),disabled:n})]}),(0,U.jsxs)(`div`,{className:`col-span-3`,children:[(0,U.jsx)(X,{className:`mb-1 block text-xs font-medium`,children:`href`}),(0,U.jsx)(Hv,{className:`text-base`,value:e.href??``,onChange:e=>c(o,t=>({...t,href:e.target.value})),disabled:n})]})]}),a?(0,U.jsxs)(`div`,{className:`mt-3 border-l border-border pl-3`,children:[(0,U.jsx)(`p`,{className:`mb-2 text-[11px] uppercase tracking-wide text-muted-foreground`,children:`Child items`}),(0,U.jsx)(k$,{value:e.items??[],onChange:e=>c(o,t=>({...t,items:Array.isArray(e)&&e.length>0?e:void 0})),disabled:n,depth:r+1})]}):(0,U.jsxs)(`p`,{className:`mt-3 text-[11px] text-muted-foreground`,children:[`Maximum depth reached (`,D$,` levels).`]})]})]},t)})}),(0,U.jsxs)(`button`,{type:`button`,onClick:d,disabled:n,className:`flex w-full items-center justify-center gap-1.5 rounded-md border border-dashed py-2 text-xs text-muted-foreground transition-colors hover:bg-accent/50`,children:[(0,U.jsx)(Po,{className:`size-3.5`}),`Add item`]}),!o&&(0,U.jsxs)(`p`,{className:`text-[11px] text-muted-foreground`,children:[`Maximum `,O$,` items allowed per level.`]})]})}function A$(e){return e.toLowerCase().replace(/\s+/g,`-`).replace(/[^a-z0-9-]/g,``).replace(/^-+|-+$/g,``)}function j$({value:e,onChange:t,disabled:n=!1}){let r=(0,v.useRef)(null),i=(0,v.useRef)(null),[a,o]=(0,v.useState)(!1),[s,c]=(0,v.useState)(!1),[l,u]=(0,v.useState)(!1),[d,f]=(0,v.useState)(null);function p(){return o(!0),new Promise(e=>{i.current=e})}function m(e){i.current?.(e),i.current=null}function h(e){e||m(null),o(e)}async function g(e){u(!0),f(null);try{let t=await XZ(e);m({src:t.url,alt:t.alt,width:t.width,height:t.height}),o(!1)}catch(e){f(e instanceof Error?e.message:`Upload failed.`)}finally{u(!1),r.current&&(r.current.value=``)}}return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`div`,{className:n?`pointer-events-none opacity-70`:``,children:(0,U.jsx)(qZ,{value:String(e??``),onChange:t,placeholder:`Type or add your content here...`,onInsertImage:p})}),(0,U.jsx)(yw,{open:a,onOpenChange:h,children:(0,U.jsxs)(Cw,{className:`max-w-sm`,children:[(0,U.jsx)(ww,{children:(0,U.jsx)(Ew,{children:`Insert Image`})}),(0,U.jsx)(`input`,{ref:r,type:`file`,accept:`image/*`,className:`hidden`,onChange:e=>{let t=e.target.files?.[0];t&&g(t)}}),(0,U.jsxs)(`div`,{onDragOver:e=>e.preventDefault(),onDrop:e=>{e.preventDefault();let t=e.dataTransfer.files[0];t&&g(t)},className:`flex w-full gap-2 rounded-md border border-dashed p-3`,children:[(0,U.jsxs)(`button`,{type:`button`,disabled:l,onClick:()=>r.current?.click(),className:`flex flex-1 items-center justify-center gap-2 rounded-md py-2 text-sm text-muted-foreground transition-colors hover:bg-muted/50 disabled:opacity-50`,children:[(0,U.jsx)(Qo,{className:`size-4`}),l?`Uploading…`:`Upload`]}),(0,U.jsx)(`div`,{className:`w-px bg-border`}),(0,U.jsxs)(`button`,{type:`button`,disabled:l,onClick:()=>c(!0),className:`flex flex-1 items-center justify-center gap-2 rounded-md py-2 text-sm text-muted-foreground transition-colors hover:bg-muted/50 disabled:opacity-50`,children:[(0,U.jsx)(so,{className:`size-4`}),`Library`]})]}),d&&(0,U.jsx)(`p`,{className:`mt-1 text-xs text-destructive`,children:d})]})}),(0,U.jsx)(c$,{open:s,onOpenChange:e=>{!e&&!a&&m(null),c(e)},allowedTypes:[`image`],onSelect:e=>{m({src:e.url,alt:e.alt,width:e.width,height:e.height}),c(!1),o(!1)}})]})}function M$({field:e,value:t,onChange:n,allValues:r,disabled:i}){let a=(0,v.useRef)(!1),{timezone:o}=ya();(0,v.useEffect)(()=>{if(e.type!==`uid`||!e.targetField||a.current)return;let t=r,i=e.targetField,o=!!t.__localizationEnabled,s=t[i];if(s!=null&&String(s).trim()!==``){n(A$(String(s)));return}let c=t.localized&&typeof t.localized==`object`?t.localized:{};if(o){let e=typeof t.__defaultLocale==`string`?t.__defaultLocale:void 0,r=e&&c[e]&&typeof c[e]==`object`?c[e]:null;r&&r[i]!==void 0&&String(r[i]).trim()!==``&&n(A$(String(r[i])));return}let l=Object.keys(c).filter(e=>!e.startsWith(`_`));for(let e of l){let t=c[e]&&typeof c[e]==`object`?c[e]:null;if(t&&t[i]!==void 0&&String(t[i]).trim()!==``){n(A$(String(t[i])));return}}},[e.type,e.targetField,r[e.targetField??``],JSON.stringify(r.localized??{}),r.__localizationEnabled]);let s=`w-full`;return e.type===`boolean`?(0,U.jsxs)(`div`,{className:`flex items-center gap-2 pt-1`,children:[(0,U.jsx)(EO,{id:`field-${e.name}`,checked:!!t,onCheckedChange:e=>n(!!e),disabled:!!i}),(0,U.jsx)(X,{htmlFor:`field-${e.name}`,className:`cursor-pointer font-normal text-base`,children:t?`Yes`:`No`})]}):e.type===`richtext`?(0,U.jsx)(j$,{value:t,onChange:n,disabled:!!i}):e.type===`text`?(0,U.jsx)(BN,{className:q(s,`text-base`),value:String(t??``),placeholder:r$(e.name),onChange:e=>n(e.target.value),disabled:!!i}):e.type===`number`?e.subtype===`float`?(0,U.jsx)(f$,{value:t,onChange:n,disabled:!!i}):(0,U.jsx)(Hv,{type:`number`,className:q(s,`text-base!`),value:t==null?``:String(t),step:`1`,placeholder:`0`,onChange:e=>{let t=e.target.value;if(t===``){n(null);return}n(parseInt(t,10))},disabled:!!i}):e.type===`datetime`?(0,U.jsx)(h$,{value:t,onChange:n,timezone:o,disabled:!!i}):e.type===`uid`?(0,U.jsx)(Hv,{className:q(s,`text-base md:text-base`),value:String(t??``),placeholder:`auto-generated`,onChange:e=>{let t=e.target.value;a.current=!!(t&&t!==``),n(e.target.value)},disabled:!!i}):e.type===`media`?(0,U.jsx)(l$,{value:t,onChange:n,allowedTypes:e.allowedTypes,disabled:!!i}):e.type===`media-gallery`?(0,U.jsx)(d$,{value:t,onChange:n,disabled:!!i}):e.type===`relation`?(0,U.jsx)(w$,{relationType:e.relationType??`many-to-one`,relatedTable:e.relatedTable??``,relatedField:e.relatedField??``,currentEntryId:String(r.id??``),value:t,onChange:n,disabled:!!i}):e.type===`array`?(0,U.jsx)(E$,{field:e,value:t,onChange:n,disabled:!!i}):e.type===`mixed`?(0,U.jsx)(m$,{value:t,onChange:n,inputId:`field-${e.name}-mixed-boolean`,disabled:!!i}):e.type===`navigation`?(0,U.jsx)(k$,{value:t,onChange:n,disabled:!!i}):(0,U.jsx)(Hv,{className:q(s,`text-base md:text-base`),value:String(t??``),placeholder:r$(e.name),onChange:e=>n(e.target.value),disabled:!!i})}function N$(e){return Array.isArray(e)?e.map(N$):e&&typeof e==`object`?Object.fromEntries(Object.entries(e).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>[e,N$(t)])):e}function P$(e){return JSON.stringify(N$(e))}function F$(){let{slug:e,id:t}=hr(),n=dr(),r=!t,{timezone:i,locales:a,defaultLocale:o,editorialMode:s}=ya(),{user:c,status:l}=ga(),u=c?.role?.toLowerCase()??``,{data:d,loading:f}=wa(e?`/cms/admin/content-types/${e}`:null),{data:p,loading:m}=wa(e&&t?`/cms/admin/entries/${e}/${t}`:null),{data:h}=wa(s&&[`editor`,`admin`,`super admin`].includes(c?.role?.toLowerCase()??``)?`/cms/admin/users`:null),{loading:g,request:_}=Vv(),{loading:y,request:b}=Vv(),{loading:x,request:S}=Vv(),[C,w]=(0,v.useState)({}),[T,E]=(0,v.useState)([]),[D,O]=(0,v.useState)(``),[k,A]=(0,v.useState)(!1),[j,M]=(0,v.useState)(`draft`),[N,P]=(0,v.useState)(``),[F,I]=(0,v.useState)(!1),[L,R]=(0,v.useState)(!1),[ee,te]=(0,v.useState)(!1),[z,B]=(0,v.useState)(null),[V,ne]=(0,v.useState)(null),[H,re]=(0,v.useState)(null),[ie,ae]=(0,v.useState)(null),[oe,se]=(0,v.useState)(!1),[ce,le]=(0,v.useState)(!1),[ue,de]=(0,v.useState)(!1),[fe,pe]=(0,v.useState)(),[me,he]=(0,v.useState)(`09:00`),ge=(0,v.useRef)(`{}`),_e=(0,v.useRef)(!1);(0,v.useEffect)(()=>{if(r){let e={};d?.fields.forEach(t=>{e[t.name]=t.type===`boolean`?!1:``}),e.localized={};let t=a&&a.length>0?a:[`en`];E(t),O(o??t[0]),A(!1),w(e),M(`draft`),P(``),I(!1),te(!1),B(null),ne(null),re(null),ae(null),se(!1),ge.current=P$(e);return}if(!p||!d)return;let e={};d.fields.forEach(t=>{e[t.name]=p[t.name]??(t.type===`boolean`?!1:``)});let t=p.localized,n=t&&typeof t==`object`?t:{};e.localized=n;let s=Object.keys(n).filter(e=>!e.startsWith(`_`)),c=(n._meta||{}).enabled??s.length>0;if(s.length>0)E(s),O(s[0]);else{let e=a&&a.length>0?a:[`en`];E(e),O(o??e[0])}if(A(!!c),w(e),M(p.status??`draft`),te(!!p.review_rejected),B(p.editor_id??null),ne(p._editor_first_name??null),re(p._editor_last_name??null),ae(p._editor_avatar_url??null),se(!1),ge.current=P$(e),p.scheduled_for?(P(p.scheduled_for),pe(new Date(p.scheduled_for)),he(Ty(p.scheduled_for,i))):P(``),p.status===`published`&&p.published_data){let t=(e,t)=>{if(t===`datetime`&&e&&typeof e==`string`){let t=/Z|[+-]\d{2}:\d{2}$/.test(e)?e:e+`Z`,n=new Date(t);return isNaN(n.getTime())?e:n.toISOString()}return e},n={},r={};d.fields.forEach(i=>{i.name in p.published_data&&(n[i.name]=t(p.published_data[i.name]??(i.type===`boolean`?!1:``),i.type),r[i.name]=t(e[i.name],i.type))}),I(P$(r)!==P$(n))}else I(!1)},[p,d,r]);let ve=P$(C)!==ge.current,ye=Fr((0,v.useCallback)(()=>_e.current?!1:ve,[ve]));function be(e,t){w(n=>({...n,[e]:t}))}function xe(e,t,n){w(r=>{let i={...r},a=i.localized&&typeof i.localized==`object`?i.localized:{},o=a[e]&&typeof a[e]==`object`?a[e]:{};return o[t]=n,a[e]=o,i.localized=a,i})}function Se(e){A(e),w(t=>{let n={...t},r=n.localized&&typeof n.localized==`object`?n.localized:{};if(r._meta||={},e&&o){if(!(r[o]&&typeof r[o]==`object`&&r[o])&&(r[o]={},d&&d.fields)){let e=r[o];d.fields.forEach(t=>{if([`string`,`text`,`richtext`].includes(t.type)){let r=n[t.name];r!=null&&r!==``&&(e[t.name]=r)}})}r._meta.primary=o}else if(!e&&o){let e=r[o]&&typeof r[o]==`object`?r[o]:null;e&&d&&d.fields&&d.fields.forEach(t=>{if([`string`,`text`,`richtext`,`uid`].includes(t.type)){let r=e[t.name];r!==void 0&&(n[t.name]=r)}})}return r._meta.enabled=e,n.localized=r,n})}function Ce(){if(N)pe(new Date(N)),he(Ty(N,i));else{let e=new Date;e.setDate(e.getDate()+1),pe(e),he(`09:00`)}le(!0)}async function we(){if(!e||!d)return null;let n={},i=k&&C.localized&&typeof C.localized==`object`&&C.localized[o]&&typeof C.localized[o]==`object`?C.localized[o]:null;if(d.fields.forEach(e=>{let t=C[e.name];(t==null||t===``)&&i&&i[e.name]!==void 0&&(t=i[e.name]),e.type===`media`&&t===null?n[e.name]=null:t!==``&&t!=null&&(n[e.name]=t)}),C.localized&&Object.keys(C.localized).length>0){let e=C.localized;e._meta||={},e._meta.enabled=k,e._meta.primary=o,n.localized=e}try{let i=await _(r?`/cms/admin/content-types/${e}/entries`:`/cms/admin/entries/${e}/${t}`,r?`POST`:`PUT`,n);return ge.current=P$(C),i}catch{return null}}async function Te(){let i=await we();if(i){if(j===`scheduled`){let n=r?i.id:t;try{await b(`/cms/admin/entries/${e}/${n}/status`,`PATCH`,{status:`draft`}),M(`draft`),P(``),le(!1)}catch{}}else j===`published`&&I(!0);r&&(_e.current=!0,n(`/content/${e}/${i.id}`,{replace:!0}))}}async function Ee(){if(!e)return;let i=t;if(ve||r){let e=await we();if(!e)return;i=r?e.id:t,r&&(_e.current=!0)}let a=s&&(u===`contributor`||u===``||l!==`authenticated`);try{let t=await b(`/cms/admin/entries/${e}/${i}/status`,`PATCH`,{status:a?`pending`:`published`,review_rejected:!1});M(t?.status??(a?`pending`:`published`)),te(!!t?.review_rejected),B(t?.editor_id??z),ne(t?._editor_first_name??V),re(t?._editor_last_name??H),ae(t?._editor_avatar_url??ie),P(``),I(!1),le(!1),se(!1),r&&n(`/content/${e}/${i}`,{replace:!0})}catch{r&&i&&n(`/content/${e}/${i}`,{replace:!0})}}async function De(){if(!e||!fe||!me)return;let a=Ey(fe,me,i);if(new Date(a)<=new Date)return;let o=t;if(ve||r){let e=await we();if(!e)return;o=r?e.id:t,r&&(_e.current=!0)}try{await b(`/cms/admin/entries/${e}/${o}/status`,`PATCH`,{status:`scheduled`,scheduled_for:a}),M(`scheduled`),P(a),le(!1),r&&n(`/content/${e}/${o}`,{replace:!0})}catch{r&&o&&n(`/content/${e}/${o}`,{replace:!0})}}async function Oe(){if(!(!e||!t))try{await b(`/cms/admin/entries/${e}/${t}/status`,`PATCH`,{status:`draft`}),M(`draft`),P(``),I(!1)}catch{}}async function ke(){if(!(!e||!t))try{await S(`/cms/admin/entries/${e}/${t}`,`DELETE`),_e.current=!0,n(`/content/${e}`,{replace:!0})}catch{}}async function Ae(n){if(!e||!t)return;let r=n===`none`?null:n,i=await b(`/cms/admin/entries/${e}/${t}/status`,`PATCH`,{status:`in_review`,editor_id:r,review_locked_by_editor:p?.review_locked_by_editor??!1});M(i?.status??`in_review`),te(!!i?.review_rejected),B(i?.editor_id??r),ne(i?._editor_first_name??null),re(i?._editor_last_name??null),ae(i?._editor_avatar_url??null),se(!1)}async function je(){se(e=>!e)}async function Me(){if(!e||!t)return;let n=await b(`/cms/admin/entries/${e}/${t}/status`,`PATCH`,{status:`pending`,review_rejected:!0});M(n?.status??`pending`),te(!!n?.review_rejected),se(!1)}let Ne=f||!r&&m,Pe=g||y,Fe=c?.permissions??[],Ie=Fe.includes(`*`)||Fe.includes(`entries:write`),Le=Fe.includes(`*`)||Fe.includes(`entries:delete`),Re=u===`contributor`,ze=u===`editor`,Be=[`admin`,`super admin`].includes(u),Ve=u===`viewer`,He=Re||ze,Ue=Re&&d?.kind===`single`,We=r||String(p?.created_by??``)===String(c?.id??``),Ge=s&&Re&&j===`in_review`,Ke=s&&(ze||Be)&&!!z&&z===c?.id,qe=Ke&&(j===`pending`||j===`in_review`)&&!ee,Je=Ve||!Ie||Ue||Re&&!We||s&&Re&&j===`pending`&&!ee||Ge||s&&(ze||Be)&&(j===`pending`||j===`in_review`)&&(!Ke||!oe),Ye=Le&&(!He||We),Xe=s&&Re&&j===`pending`&&(ee?!0:ve)||ve||j===`draft`||j===`scheduled`||!s&&j===`pending`||s&&j===`pending`&&!Re||F,Ze=!!(fe&&me),Qe=s&&Re?`Review`:`Publish`;if(yO(`mod+s`,Te,{enabled:!Je&&!Pe&&(j===`scheduled`?!0:ve),label:`Save draft`}),yO(`mod+shift+p`,Ee,{enabled:Xe&&!Pe&&!Je,label:`Publish`}),Ne)return(0,U.jsxs)(`div`,{className:`flex items-center gap-2 py-12 text-muted-foreground`,children:[(0,U.jsx)(by,{className:`size-4`}),(0,U.jsx)(`span`,{className:`text-sm`,children:`Loading…`})]});if(!d)return null;let $e;$e=j===`scheduled`?(0,U.jsxs)(vw,{variant:`outline`,className:`border-blue-500 text-blue-600`,children:[(0,U.jsx)(Ia,{className:`size-3 mr-1`}),N?`Scheduled · ${wy(N,i)}`:`Scheduled`]}):j===`pending`?ee?(0,U.jsx)(vw,{variant:`destructive`,children:`Pending`}):(0,U.jsx)(vw,{className:`bg-amber-500 text-black hover:bg-amber-500`,children:`Pending`}):j===`in_review`?(0,U.jsx)(vw,{variant:`outline`,children:`In Review`}):j===`published`?(0,U.jsx)(vw,{variant:F?`secondary`:`default`,children:F?`Published (pending changes)`:`Published`}):(0,U.jsx)(vw,{variant:`secondary`,children:`Draft`});let et=(h??[]).filter(e=>ze?e.id===c?.id:Be?e.id===c?.id||(e.role_name??``).toLowerCase()===`editor`:!1),tt=!r&&s&&(ze||Be),nt=s&&!r&&tt,rt=s&&!r&&!!z,it=qe,at=qe,ot=V||H;return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(yy,{children:(0,U.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(`h1`,{className:`text-2xl font-bold -mt-2`,children:r?`New entry`:`Edit entry`}),$e]}),(0,U.jsx)(`p`,{className:`text-muted-foreground text-xs mt-1`,children:d.name})]}),(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[!s&&!r&&Ye&&!Ue&&(0,U.jsx)(J,{variant:`ghost`,size:`icon`,className:`text-muted-foreground hover:text-destructive`,onClick:()=>R(!0),disabled:x,children:(0,U.jsx)(qo,{className:`size-4`})}),!s&&!r&&j===`published`&&!Je&&(0,U.jsxs)(J,{variant:`outline`,onClick:Oe,disabled:Pe,children:[y?(0,U.jsx)(by,{className:`size-4`}):null,`Revert to draft`]}),!s&&!r&&j===`scheduled`&&!Je&&(0,U.jsxs)(J,{variant:`outline`,onClick:Oe,disabled:Pe,children:[y?(0,U.jsx)(by,{className:`size-4`}):null,`Cancel schedule`]}),nt&&(0,U.jsxs)(Ow,{value:z??`none`,onValueChange:Ae,disabled:!tt||Pe,children:[(0,U.jsx)(jw,{className:`h-10 min-h-10 max-h-10 w-42 py-0`,children:(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(El,{avatarUrl:ie??null,firstName:V??null,lastName:H??null,className:`size-5`,fallbackClassName:`text-[9px]`}),(0,U.jsx)(Aw,{placeholder:ot||`Assign editor`})]})}),(0,U.jsxs)(Pw,{children:[!ze&&(0,U.jsx)(Iw,{value:`none`,children:`Unassign`}),et.map(e=>(0,U.jsx)(Iw,{value:e.id,children:e.first_name||e.last_name||e.id},e.id))]})]}),!tt&&rt&&(0,U.jsxs)(`div`,{className:`inline-flex h-10 items-center gap-2 rounded-md border border-input px-3 text-sm`,children:[(0,U.jsx)(El,{avatarUrl:ie??null,firstName:V??null,lastName:H??null,className:`size-5`,fallbackClassName:`text-[9px]`}),(0,U.jsx)(`span`,{children:ot||`Assigned editor`})]}),it&&(0,U.jsx)(J,{variant:`outline`,size:`icon`,onClick:je,disabled:Pe,children:(0,U.jsx)(No,{className:`size-4`})}),at&&(0,U.jsx)(J,{variant:`outline`,size:`icon`,onClick:Me,disabled:Pe,children:(0,U.jsx)(ns,{className:`size-4`})}),(0,U.jsxs)(J,{variant:`outline`,onClick:Te,size:s?`icon`:`default`,disabled:Je||(j===`scheduled`?Pe:!ve||Pe),children:[g?(0,U.jsx)(by,{className:`size-4`}):s?(0,U.jsx)(Lo,{className:`size-4`}):null,!s&&(j===`scheduled`?`Save draft (cancel schedule)`:`Save draft`)]}),j!==`scheduled`&&!(s&&Re)&&(0,U.jsxs)(J,{variant:`outline`,onClick:Ce,size:s?`icon`:`default`,disabled:Je||Pe,children:[(0,U.jsx)(Ia,{className:`size-4`}),!s&&`Schedule`]}),(0,U.jsxs)(J,{onClick:Ee,disabled:Je||!Xe||Pe,children:[y?(0,U.jsx)(by,{className:`size-4`}):null,j===`scheduled`?s&&Re?`Review`:`Publish now`:j===`published`&&!F?`Republish`:Qe]})]})]})}),(0,U.jsxs)(`section`,{className:`mt-24`,children:[ce&&!Je&&(0,U.jsxs)(`div`,{className:`mb-6 flex items-end gap-2 rounded-lg border p-4 bg-muted/30`,children:[(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsx)(X,{children:`Date`}),(0,U.jsxs)(LN,{open:ue,onOpenChange:de,children:[(0,U.jsx)(RN,{asChild:!0,children:(0,U.jsxs)(J,{variant:`outline`,className:`w-40 justify-between font-normal`,children:[fe?VA(fe,`MMM d, yyyy`):`Select date`,(0,U.jsx)(Ba,{className:`size-4 opacity-50`})]})}),(0,U.jsx)(zN,{className:`w-auto overflow-hidden p-0`,align:`start`,children:(0,U.jsx)(FN,{mode:`single`,selected:fe,captionLayout:`dropdown`,defaultMonth:fe??new Date,disabled:{before:new Date},onSelect:e=>{pe(e),de(!1)}})})]})]}),(0,U.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,U.jsxs)(X,{children:[`Time `,(0,U.jsx)(`span`,{className:`text-muted-foreground font-normal`,children:`(24h)`})]}),(0,U.jsx)(Hv,{type:`time`,className:`w-32 appearance-none bg-background [&::-webkit-calendar-picker-indicator]:hidden [&::-webkit-calendar-picker-indicator]:appearance-none`,value:me,onChange:e=>he(e.target.value)})]}),(0,U.jsxs)(J,{onClick:De,disabled:!Ze||Pe,children:[y?(0,U.jsx)(by,{className:`size-4`}):null,`Confirm`]}),(0,U.jsx)(J,{variant:`ghost`,onClick:()=>le(!1),children:`Cancel`})]}),(0,U.jsxs)(`div`,{className:`mb-4 flex items-center justify-between`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(nj,{checked:k,onCheckedChange:Se,disabled:Je}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`p`,{className:`text-sm font-medium`,children:`Localization`}),(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Enable per-entry localization`})]})]}),(0,U.jsx)(`div`,{})]}),(0,U.jsx)(`div`,{children:k&&(0,U.jsx)(QA,{value:D,onValueChange:e=>O(e),children:(0,U.jsx)($A,{children:T.map(e=>(0,U.jsx)(ej,{value:e,disabled:Je,children:e.toUpperCase()},e))})})})]}),(0,U.jsx)(`div`,{className:`grid grid-cols-6 gap-4`,children:d.fields.map(e=>{let n=[`string`,`text`,`richtext`].includes(e.type),r=C.localized&&C.localized[D]?C.localized[D][e.name]:void 0,i=n&&k?r:C[e.name],a=e.type===`uid`&&e.targetField&&k&&[`string`,`text`,`richtext`].includes(d.fields.find(t=>t.name===e.targetField)?.type??``);return(0,U.jsx)(`div`,{className:xO[e.width??`full`],children:(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsxs)(X,{htmlFor:`entry-${e.name}`,className:`capitalize`,children:[e.name.replace(/_/g,` `),e.required&&(0,U.jsx)(`span`,{className:`ml-1 text-destructive`,children:`*`})]}),(0,U.jsx)(M$,{field:e,value:i,onChange:t=>{n&&k?xe(D,e.name,t):be(e.name,t)},allValues:{...C,id:t,__activeLocale:D,__localizationEnabled:k,__defaultLocale:o},disabled:!!a||Je})]})},e.name)})}),(0,U.jsx)(yw,{open:L,onOpenChange:R,children:(0,U.jsxs)(Cw,{className:`max-w-sm`,children:[(0,U.jsx)(ww,{children:(0,U.jsx)(Ew,{children:`Delete this entry?`})}),(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`This action cannot be undone.`}),(0,U.jsxs)(Tw,{children:[(0,U.jsx)(J,{variant:`outline`,onClick:()=>R(!1),children:`Cancel`}),(0,U.jsxs)(J,{variant:`destructive`,onClick:ke,disabled:x,children:[x?(0,U.jsx)(by,{className:`size-4`}):null,`Delete`]})]})]})}),(0,U.jsx)(yw,{open:ye.state===`blocked`,onOpenChange:()=>ye.reset?.(),children:(0,U.jsxs)(Cw,{className:`max-w-sm`,children:[(0,U.jsx)(ww,{children:(0,U.jsx)(Ew,{children:`Unsaved changes`})}),(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Leave without saving?`}),(0,U.jsxs)(Tw,{children:[(0,U.jsx)(J,{variant:`outline`,onClick:()=>ye.reset?.(),children:`Stay`}),(0,U.jsx)(J,{variant:`destructive`,onClick:()=>ye.proceed?.(),children:`Leave`})]})]})})]})]})}function I$({...e}){return(0,U.jsx)(`nav`,{"aria-label":`breadcrumb`,"data-slot":`breadcrumb`,...e})}function L$({className:e,...t}){return(0,U.jsx)(`ol`,{"data-slot":`breadcrumb-list`,className:q(`flex flex-wrap items-center gap-1.5 text-sm break-words text-muted-foreground sm:gap-2.5`,e),...t})}function R$({className:e,...t}){return(0,U.jsx)(`li`,{"data-slot":`breadcrumb-item`,className:q(`inline-flex items-center gap-1.5`,e),...t})}function z$({asChild:e,className:t,...n}){return(0,U.jsx)(e?Fl:`a`,{"data-slot":`breadcrumb-link`,className:q(`transition-colors hover:text-foreground`,t),...n})}function B$({className:e,...t}){return(0,U.jsx)(`span`,{"data-slot":`breadcrumb-page`,role:`link`,"aria-disabled":`true`,"aria-current":`page`,className:q(`font-normal text-foreground`,e),...t})}function V$({children:e,className:t,...n}){return(0,U.jsx)(`li`,{"data-slot":`breadcrumb-separator`,role:`presentation`,"aria-hidden":`true`,className:q(`[&>svg]:size-3.5`,t),...n,children:e??(0,U.jsx)(Ha,{})})}function H$(e){return e?e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`:`—`}function U$(e){return!!e?.startsWith(`image/`)}function W$(e){return!!e?.startsWith(`video/`)}function G$(e){return!!e?.startsWith(`audio/`)}function K$(e){return e===`application/pdf`}function q$(e,t){return e.split(`?`)[0].endsWith(`.m3u8`)||t===`application/x-mpegurl`||t===`application/vnd.apple.mpegurl`}async function J$(e){if(e.isFile)return new Promise(t=>{e.file(n=>t([{file:n,relativePath:e.fullPath.replace(/^\//,``)}]))});if(e.isDirectory){let t=e.createReader(),n=[];return await new Promise(e=>{let r=()=>{t.readEntries(async t=>{if(t.length===0){e();return}let i=await Promise.all(t.map(J$));n.push(...i.flat()),r()})};r()}),n}return[]}function Y$({url:e}){let t=(0,v.useRef)(null);return(0,v.useEffect)(()=>{let n=t.current;if(!n)return;if(n.canPlayType(`application/vnd.apple.mpegurl`)){n.src=e;return}let r=null;return L(async()=>{let{default:e}=await import(`./hls-0EiSYoTw.js`);return{default:e}},[]).then(({default:t})=>{if(!t.isSupported())return;let i=new t;r=i,i.loadSource(e),i.attachMedia(n)}),()=>{r?.destroy()}},[e]),(0,U.jsx)(`video`,{ref:t,controls:!0,className:`max-h-[70vh] w-full rounded-md bg-black`})}function X$({item:e}){let t=e.mime_type?.toLowerCase()??null;return U$(t)?(0,U.jsx)(`img`,{src:e.url,alt:e.filename,className:`max-h-full max-w-full rounded-md object-contain`}):q$(e.url,t)?(0,U.jsx)(Y$,{url:e.url}):W$(t)?(0,U.jsx)(`video`,{src:e.url,controls:!0,preload:`none`,className:`max-h-[70vh] w-full rounded-md bg-black`}):G$(t)?(0,U.jsxs)(`div`,{className:`flex flex-col items-center gap-4 py-6`,children:[(0,U.jsx)(no,{className:`size-14 text-muted-foreground`}),(0,U.jsx)(`audio`,{src:e.url,controls:!0,className:`w-full`})]}):K$(t)?(0,U.jsx)(`iframe`,{src:e.url,title:e.filename,className:`h-[70vh] w-full rounded-md border`}):(0,U.jsxs)(`div`,{className:`flex flex-col items-center gap-4 py-8 text-center`,children:[(0,U.jsx)(io,{className:`size-14 text-muted-foreground`}),(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e.mime_type??`Unknown type`}),(0,U.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,download:e.filename,children:(0,U.jsxs)(J,{variant:`outline`,size:`sm`,children:[(0,U.jsx)(Qa,{className:`size-4`}),`Download`]})})]})}function Z$({folder:e,onOpen:t,onDelete:n,onRename:r,canDelete:i,canRename:a,selected:o,onToggle:s}){return(0,U.jsxs)(`div`,{className:`group relative flex items-center gap-3 rounded-lg border bg-card px-3 py-2.5 transition-colors cursor-pointer hover:bg-muted/50 ${o?`ring-2 ring-primary`:``}`,onClick:()=>{o||t(e)},children:[(0,U.jsxs)(`div`,{className:`relative shrink-0 size-7 flex items-center justify-center`,children:[(0,U.jsx)(lo,{className:`size-7 text-muted-foreground transition-opacity ${o?`opacity-0`:`group-hover:opacity-0`}`}),(0,U.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center transition-opacity ${o?`opacity-100`:`opacity-0 group-hover:opacity-100`}`,onClick:e=>e.stopPropagation(),children:(0,U.jsx)(EO,{checked:o,onCheckedChange:()=>s(`folder:${e.id}`),"aria-label":`Select folder`})})]}),(0,U.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,U.jsx)(`p`,{className:`text-sm font-bold truncate`,title:e.name,children:e.name}),(0,U.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[e.item_count,` `,e.item_count===1?`item`:`items`]})]}),!o&&(a||i)&&(0,U.jsxs)(P_,{children:[(0,U.jsx)(F_,{asChild:!0,children:(0,U.jsx)(`button`,{className:`shrink-0 opacity-0 group-hover:opacity-100 transition-opacity flex size-6 items-center justify-center rounded-md text-muted-foreground hover:bg-muted hover:text-foreground`,onClick:e=>e.stopPropagation(),children:(0,U.jsx)($a,{className:`size-4`})})}),(0,U.jsxs)(R_,{align:`end`,onClick:e=>e.stopPropagation(),children:[a&&(0,U.jsxs)(z_,{onSelect:()=>r(e),children:[(0,U.jsx)(No,{className:`size-4`}),`Rename`]}),i&&(0,U.jsxs)(z_,{onSelect:()=>n(e),className:`text-destructive focus:text-destructive`,children:[(0,U.jsx)(qo,{className:`size-4`}),`Delete`]})]})]})]})}function Q$({item:e,onDelete:t,onPreview:n,canDelete:r,selected:i,onToggle:a}){let o=e.mime_type?.toLowerCase()??null;return(0,U.jsxs)(`div`,{className:`group relative rounded-lg border bg-card overflow-hidden transition-colors ${i?`ring-2 ring-primary`:``}`,children:[(0,U.jsx)(`div`,{className:`aspect-square bg-muted flex items-center justify-center cursor-pointer`,onClick:()=>{i||n(e)},children:U$(o)?(0,U.jsx)(`img`,{src:e.url,alt:e.filename,className:`h-full w-full object-cover`}):W$(o)||q$(e.url,o)?(0,U.jsx)(ro,{className:`size-10 text-muted-foreground`}):G$(o)?(0,U.jsx)(no,{className:`size-10 text-muted-foreground`}):K$(o)?(0,U.jsx)(io,{className:`size-10 text-muted-foreground`}):(0,U.jsx)(ao,{className:`size-10 text-muted-foreground`})}),(0,U.jsx)(`div`,{className:`absolute top-1.5 left-1.5 transition-opacity ${i?`opacity-100`:`opacity-0 group-hover:opacity-100`}`,children:(0,U.jsx)(EO,{checked:i,onCheckedChange:()=>a(e.id),"aria-label":`Select file`,className:`bg-background/80 backdrop-blur-sm`})}),!i&&r&&(0,U.jsx)(`button`,{onClick:()=>t(e),className:`absolute top-1.5 right-1.5 flex size-6 items-center justify-center rounded-md bg-background/80 text-muted-foreground opacity-0 backdrop-blur-sm transition-opacity hover:text-destructive group-hover:opacity-100`,children:(0,U.jsx)(qo,{className:`size-3.5`})}),(0,U.jsxs)(`div`,{className:`p-2`,children:[(0,U.jsx)(`p`,{className:`text-xs font-medium truncate`,title:e.filename,children:e.filename}),(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:H$(e.size)})]})]})}function $$(){let e=(0,v.useRef)(null),{user:t}=ga(),n=t?.permissions??[],r=n.includes(`*`)||n.includes(`media:write`),i=n.includes(`*`)||n.includes(`media:delete`),[a,o]=(0,v.useState)([{id:null,name:`Media`}]),s=a[a.length-1].id,{data:c,loading:l,refetch:u}=wa(`/cms/admin/folders?parent_id=${s??``}`),{data:d,loading:f,refetch:p}=wa(`/cms/admin/media?folder_id=${s??``}`),m=(0,v.useCallback)(()=>{u(),p()},[u,p]),[h,g]=(0,v.useState)(!1),[_,y]=(0,v.useState)(null),[b,x]=(0,v.useState)(new Set),[S,C]=(0,v.useState)(null),[w,T]=(0,v.useState)(``),[E,D]=(0,v.useState)(``),[O,k]=(0,v.useState)(!1),[A,j]=(0,v.useState)(null),[M,N]=(0,v.useState)(null),[P,F]=(0,v.useState)(null),[I,L]=(0,v.useState)(null),[R,ee]=(0,v.useState)(``),[te,z]=(0,v.useState)(!1),[B,V]=(0,v.useState)(``),[ne,H]=(0,v.useState)(!1),[re,ie]=(0,v.useState)(!1),{loading:ae,error:oe,request:se}=Vv(),{loading:ce,error:le,request:ue}=Vv();async function de(e){if(e.some(({relativePath:e})=>e.endsWith(`.m3u8`))){let t=localStorage.getItem(`plank_token`),n=t?{Authorization:`Bearer ${t}`}:{},r=new FormData;for(let{file:t,relativePath:n}of e)r.append(`files`,t,n);s&&r.append(`folder_id`,s),r.append(`bundle`,`true`);let i=await fetch(`/cms/admin/media`,{method:`POST`,headers:n,body:r});if(!i.ok){let e=await i.text(),t=`Upload failed.`;try{t=JSON.parse(e).error??t}catch{}throw Error(t)}}else await Promise.all(e.map(({file:e})=>XZ(e,{folderId:s})))}async function fe(t){if(r&&!(!t||t.length===0)){g(!0),y(null);try{await de(Array.from(t).map(e=>({file:e,relativePath:e.webkitRelativePath||e.name}))),m()}catch(e){y(e instanceof Error?e.message:`Upload failed.`)}finally{g(!1),e.current&&(e.current.value=``)}}}async function pe(e){if(!r)return;e.preventDefault();let t=Array.from(e.dataTransfer.items);if(!t.some(e=>typeof e.webkitGetAsEntry==`function`)){fe(e.dataTransfer.files);return}g(!0),y(null);try{let e=t.map(e=>e.webkitGetAsEntry()).filter(e=>e!==null);await de((await Promise.all(e.map(J$))).flat()),m()}catch(e){y(e instanceof Error?e.message:`Upload failed.`)}finally{g(!1)}}function me(e){o(t=>[...t,{id:e.id,name:e.name}]),x(new Set)}function he(e){o(t=>t.slice(0,e+1)),x(new Set)}async function ge(){if(r&&B.trim())try{await ue(`/cms/admin/folders`,`POST`,{name:B.trim(),parent_id:s}),z(!1),V(``),u()}catch{}}async function _e(){if(r&&!(!I||!R.trim()))try{await ue(`/cms/admin/folders/${I.id}`,`PATCH`,{name:R.trim()}),L(null),u()}catch{}}async function ve(){if(i&&P)try{await se(`/cms/admin/folders/${P.id}`,`DELETE`),F(null),u()}catch{}}async function ye(){if(i&&M)try{await se(`/cms/admin/media/${M.id}`,`DELETE`),N(null),p()}catch{}}function be(e){x(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}let xe=c?.folders??[],Se=d?.items??[],Ce=[...xe.map(e=>`folder:${e.id}`),...Se.map(e=>e.id)],we=Ce.length>0&&Ce.every(e=>b.has(e)),Te=!we&&Ce.some(e=>b.has(e));async function Ee(){if(!i||re)return;ie(!0);let e=localStorage.getItem(`plank_token`),t=e?{Authorization:`Bearer ${e}`}:{};try{await Promise.all([...[...b].filter(e=>e.startsWith(`folder:`)).map(e=>fetch(`/cms/admin/folders/${e.slice(7)}`,{method:`DELETE`,headers:t})),...[...b].filter(e=>!e.startsWith(`folder:`)).map(e=>fetch(`/cms/admin/media/${e}`,{method:`DELETE`,headers:t}))]),H(!1),x(new Set),m()}finally{ie(!1)}}let De=l||f,Oe=xe.length===0&&Se.length===0;return(0,U.jsxs)(`div`,{children:[(0,U.jsx)(yy,{children:(0,U.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`h1`,{className:`text-2xl font-bold -mt-2`,children:`Media Library`}),(0,U.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:d?`${d.total} file${d.total===1?``:`s`}`:``})]}),(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsxs)(J,{variant:`outline`,onClick:()=>{V(``),z(!0)},disabled:!r,children:[(0,U.jsx)(co,{className:`size-4`}),`New folder`]}),(0,U.jsxs)(J,{onClick:()=>e.current?.click(),disabled:h||!r,children:[h?(0,U.jsx)(by,{className:`size-4`}):(0,U.jsx)(Qo,{className:`size-4`}),h?`Uploading…`:`Upload`]})]})]})}),(0,U.jsxs)(`section`,{className:`mt-24`,children:[a.length>1&&(0,U.jsx)(I$,{className:`mb-4`,children:(0,U.jsx)(L$,{children:a.map((e,t)=>(0,U.jsxs)(v.Fragment,{children:[t>0&&(0,U.jsx)(V$,{}),(0,U.jsx)(R$,{children:t===a.length-1?(0,U.jsx)(B$,{children:t===0?(0,U.jsx)(go,{className:`size-3.5`}):e.name}):(0,U.jsx)(z$,{asChild:!0,children:(0,U.jsx)(`button`,{onClick:()=>he(t),children:t===0?(0,U.jsx)(go,{className:`size-3.5`}):e.name})})})]},t))})}),!Oe&&!De&&(0,U.jsxs)(`div`,{className:`mb-4 flex items-center gap-3 rounded-lg border border-border bg-muted/50 px-4 py-2.5`,children:[(0,U.jsx)(EO,{checked:we?!0:Te?`indeterminate`:!1,onCheckedChange:()=>{x(we?new Set:new Set(Ce))},"aria-label":`Select all`}),b.size>0?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`span`,{className:`text-sm font-medium`,children:[b.size,` selected`]}),(0,U.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,U.jsx)(J,{variant:`outline`,size:`sm`,onClick:()=>x(new Set),children:`Clear`}),i&&(0,U.jsxs)(J,{variant:`destructive`,size:`sm`,disabled:re,onClick:()=>H(!0),children:[(0,U.jsx)(qo,{className:`size-3.5`}),`Delete`]})]})]}):(0,U.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:`Select all`})]}),(0,U.jsx)(`input`,{ref:e,type:`file`,multiple:!0,className:`hidden`,onChange:e=>fe(e.target.files)}),_&&(0,U.jsx)(`p`,{className:`mb-4 text-sm text-destructive`,children:_}),De?(0,U.jsx)(`div`,{className:`flex items-center gap-2 py-16 justify-center text-muted-foreground`,children:(0,U.jsx)(by,{className:`size-5`})}):Oe?(0,U.jsxs)(`div`,{className:`flex flex-col items-center justify-center rounded-lg border border-dashed py-20 text-center cursor-pointer hover:bg-muted/50 transition-colors`,onClick:()=>r&&e.current?.click(),onDragOver:e=>e.preventDefault(),onDrop:pe,children:[(0,U.jsx)(Qo,{className:`size-8 text-muted-foreground mb-3`}),(0,U.jsx)(`p`,{className:`text-sm font-medium`,children:`Drop files or folders here, or click to upload`}),(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:`Images, videos, audio, documents and more`})]}):(0,U.jsxs)(`div`,{className:`flex flex-col gap-6`,onDragOver:e=>e.preventDefault(),onDrop:pe,children:[xe.length>0&&(0,U.jsx)(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4`,children:xe.map(e=>(0,U.jsx)(Z$,{folder:e,onOpen:me,onDelete:F,onRename:e=>{L(e),ee(e.name)},canDelete:i,canRename:r,selected:b.has(`folder:${e.id}`),onToggle:be},e.id))}),Se.length>0&&(0,U.jsx)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-6`,children:Se.map(e=>(0,U.jsx)(Q$,{item:e,onDelete:N,onPreview:e=>{C(e),T(e.filename),D(e.alt??``),j(null)},canDelete:i,selected:b.has(e.id),onToggle:be},e.id))})]}),(0,U.jsx)(yw,{open:!!S,onOpenChange:e=>{e||(C(null),j(null))},children:(0,U.jsxs)(Cw,{className:`sm:max-w-4xl h-[80vh] flex flex-col`,children:[(0,U.jsx)(ww,{children:(0,U.jsx)(Ew,{className:`truncate pr-6`,title:S?.filename,children:S?.filename})}),(0,U.jsx)(`div`,{className:`flex-1 min-h-0 flex items-center justify-center overflow-hidden`,children:S&&(0,U.jsx)(X$,{item:S})}),(0,U.jsxs)(`div`,{className:`flex items-center justify-between text-xs text-muted-foreground`,children:[(0,U.jsx)(`span`,{children:S?.mime_type??`—`}),(0,U.jsxs)(`div`,{className:`flex items-center gap-3`,children:[S?.width&&S?.height&&(0,U.jsxs)(`span`,{children:[S.width,` × `,S.height]}),(0,U.jsx)(`span`,{children:H$(S?.size??null)}),(0,U.jsx)(`a`,{href:S?.url,target:`_blank`,rel:`noreferrer`,download:S?.filename,children:(0,U.jsx)(J,{variant:`ghost`,size:`sm`,className:`h-7 px-2`,children:(0,U.jsx)(Qa,{className:`size-3.5`})})})]})]}),S&&U$(S.mime_type)&&(0,U.jsxs)(`form`,{className:`flex flex-col gap-3 border-t pt-3`,onSubmit:async e=>{e.preventDefault(),k(!0),j(null);let t=localStorage.getItem(`plank_token`);try{let e=await fetch(`/cms/admin/media/${S.id}`,{method:`PATCH`,headers:{"Content-Type":`application/json`,...t?{Authorization:`Bearer ${t}`}:{}},body:JSON.stringify({filename:w||S.filename,alt:E||null})});if(!e.ok)throw Error(`Save failed.`);C(await e.json()),p()}catch(e){j(e instanceof Error?e.message:`Save failed.`)}finally{k(!1)}},children:[(0,U.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsx)(X,{className:`text-xs`,children:`Filename`}),(0,U.jsx)(Hv,{value:w,onChange:e=>T(e.target.value),placeholder:S.filename,className:`h-8 text-sm`,disabled:!r})]}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsx)(X,{className:`text-xs`,children:`Alt text`}),(0,U.jsx)(Hv,{value:E,onChange:e=>D(e.target.value),placeholder:`Describe the image…`,className:`h-8 text-sm`,disabled:!r})]})]}),A&&(0,U.jsx)(`p`,{className:`text-xs text-destructive`,children:A}),(0,U.jsx)(`div`,{className:`flex justify-end`,children:(0,U.jsx)(J,{type:`submit`,size:`sm`,disabled:O||!r,children:O?`Saving…`:`Save`})})]})]})}),(0,U.jsx)(yw,{open:te,onOpenChange:e=>{e||z(!1)},children:(0,U.jsxs)(Cw,{className:`sm:max-w-sm`,children:[(0,U.jsx)(ww,{children:(0,U.jsx)(Ew,{children:`New folder`})}),(0,U.jsx)(Hv,{placeholder:`Folder name`,value:B,onChange:e=>V(e.target.value),onKeyDown:e=>{e.key===`Enter`&&ge()},autoFocus:!0}),le&&(0,U.jsx)(`p`,{className:`text-sm text-destructive`,children:le}),(0,U.jsxs)(Tw,{children:[(0,U.jsx)(J,{variant:`outline`,onClick:()=>z(!1),children:`Cancel`}),(0,U.jsx)(J,{onClick:ge,disabled:ce||!B.trim()||!r,children:ce?`Creating…`:`Create`})]})]})}),(0,U.jsx)(yw,{open:!!I,onOpenChange:e=>{e||L(null)},children:(0,U.jsxs)(Cw,{className:`sm:max-w-sm`,children:[(0,U.jsx)(ww,{children:(0,U.jsx)(Ew,{children:`Rename folder`})}),(0,U.jsx)(Hv,{value:R,onChange:e=>ee(e.target.value),onKeyDown:e=>{e.key===`Enter`&&_e()},autoFocus:!0}),le&&(0,U.jsx)(`p`,{className:`text-sm text-destructive`,children:le}),(0,U.jsxs)(Tw,{children:[(0,U.jsx)(J,{variant:`outline`,onClick:()=>L(null),children:`Cancel`}),(0,U.jsx)(J,{onClick:_e,disabled:ce||!R.trim()||!r,children:ce?`Saving…`:`Save`})]})]})}),(0,U.jsx)(yw,{open:!!M,onOpenChange:e=>{e||N(null)},children:(0,U.jsxs)(Cw,{className:`sm:max-w-sm`,children:[(0,U.jsx)(ww,{children:(0,U.jsx)(Ew,{children:`Delete file`})}),(0,U.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Are you sure you want to delete`,` `,(0,U.jsx)(`span`,{className:`font-medium text-foreground`,children:M?.filename}),`? This action cannot be undone.`]}),oe&&(0,U.jsx)(`p`,{className:`text-sm text-destructive`,children:oe}),(0,U.jsxs)(Tw,{children:[(0,U.jsx)(J,{variant:`outline`,onClick:()=>N(null),children:`Cancel`}),(0,U.jsx)(J,{variant:`destructive`,onClick:ye,disabled:ae||!i,children:ae?`Deleting…`:`Delete`})]})]})}),(0,U.jsx)(yw,{open:!!P,onOpenChange:e=>{e||F(null)},children:(0,U.jsxs)(Cw,{className:`sm:max-w-sm`,children:[(0,U.jsx)(ww,{children:(0,U.jsx)(Ew,{children:`Delete folder`})}),(0,U.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Are you sure you want to delete`,` `,(0,U.jsx)(`span`,{className:`font-medium text-foreground`,children:P?.name}),`? The folder must be empty.`]}),oe&&(0,U.jsx)(`p`,{className:`text-sm text-destructive`,children:oe}),(0,U.jsxs)(Tw,{children:[(0,U.jsx)(J,{variant:`outline`,onClick:()=>F(null),children:`Cancel`}),(0,U.jsx)(J,{variant:`destructive`,onClick:ve,disabled:ae||!i,children:ae?`Deleting…`:`Delete`})]})]})}),(0,U.jsx)(yw,{open:ne,onOpenChange:e=>{e||H(!1)},children:(0,U.jsxs)(Cw,{className:`sm:max-w-sm`,children:[(0,U.jsx)(ww,{children:(0,U.jsxs)(Ew,{children:[`Delete `,b.size,` `,b.size===1?`item`:`items`,`?`]})}),(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`This action cannot be undone. Non-empty folders will be skipped.`}),(0,U.jsxs)(Tw,{children:[(0,U.jsx)(J,{variant:`outline`,onClick:()=>H(!1),children:`Cancel`}),(0,U.jsxs)(J,{variant:`destructive`,onClick:Ee,disabled:re,children:[re?(0,U.jsx)(by,{className:`size-4`}):null,`Delete`]})]})]})})]})]})}function e1({items:e}){let{pathname:t}=cr();function n(e){return t===e||t.startsWith(e+`/`)}return(0,U.jsx)(`nav`,{className:`flex flex-col gap-0.5 p-2`,children:e.map(({label:e,to:t,icon:r})=>(0,U.jsxs)(qi,{to:t,className:[`flex items-center gap-2.5 rounded-md px-2.5 py-1.5 text-sm transition-colors`,n(t)?`bg-sidebar-accent text-sidebar-accent-foreground font-medium`:`text-sidebar-foreground hover:bg-sidebar-accent/50 hover:text-sidebar-accent-foreground`].join(` `),children:[r&&(0,U.jsx)(r,{className:`size-3.5 shrink-0`}),(0,U.jsx)(`span`,{className:`truncate`,children:e})]},t))})}function t1(e,t){return e?.permissions.includes(`*`)||e?.permissions.includes(t)||!1}function n1(){let{user:e}=ga(),t=[{label:`Overview`,to:`/settings/overview`,icon:zo,permission:`settings:overview:read`},{label:`Users`,to:`/settings/users`,icon:es,permission:`settings:users:read`},{label:`Roles`,to:`/settings/roles`,icon:Bo,permission:`settings:roles:read`},{label:`API Tokens`,to:`/settings/api-tokens`,icon:bo,permission:`settings:api-tokens:read`},{label:`Webhooks`,to:`/settings/webhooks`,icon:ts,permission:`settings:webhooks:read`}].filter(({permission:t})=>t1(e,t));return(0,U.jsxs)(`div`,{className:`flex flex-col`,children:[(0,U.jsx)(`div`,{className:`border-b border-sidebar-border px-4 py-3`,children:(0,U.jsx)(`p`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:`Settings`})}),(0,U.jsx)(e1,{items:t})]})}function r1(){return qw((0,U.jsx)(n1,{})),(0,U.jsx)(Qr,{})}var i1=`••••••••`;function a1({values:e,onChange:t,disabled:n=!1}){return(0,U.jsxs)(`div`,{className:`space-y-4`,children:[(0,U.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,U.jsx)(X,{htmlFor:`local-uploads-dir`,children:`Upload directory`}),(0,U.jsx)(Hv,{id:`local-uploads-dir`,placeholder:`public/uploads`,value:e[`local.uploads_dir`]??``,onChange:e=>t(`local.uploads_dir`,e.target.value),disabled:n}),(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Path on disk where files are stored. Relative to the server working directory.`})]}),(0,U.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,U.jsx)(X,{htmlFor:`local-public-url`,children:`Public URL`}),(0,U.jsx)(Hv,{id:`local-public-url`,placeholder:`http://localhost:1337`,value:e[`local.public_url`]??``,onChange:e=>t(`local.public_url`,e.target.value),disabled:n}),(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Base URL used to build file URLs. Should match the server's public address.`})]})]})}function o1({id:e,label:t,fieldKey:n,values:r,onChange:i,placeholder:a,disabled:o=!1}){let[s,c]=(0,v.useState)(!1),l=r[n]===i1,u=r[n]??``;return(0,U.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,U.jsx)(X,{htmlFor:e,children:t}),(0,U.jsxs)(`div`,{className:`relative`,children:[(0,U.jsx)(Hv,{id:e,type:s?`text`:`password`,placeholder:l?`Leave blank to keep current value`:a,value:l?``:u,onChange:e=>i(n,e.target.value),className:`pr-9`,disabled:o}),(0,U.jsx)(`button`,{type:`button`,className:`absolute right-2.5 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,onClick:()=>c(e=>!e),tabIndex:-1,disabled:o,children:s?(0,U.jsx)(eo,{className:`size-4`}):(0,U.jsx)(to,{className:`size-4`})})]}),l&&(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`A value is already saved. Enter a new one to replace it.`})]})}function s1({values:e,onChange:t,disabled:n=!1}){return(0,U.jsxs)(`div`,{className:`space-y-4`,children:[(0,U.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,U.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,U.jsx)(X,{htmlFor:`s3-access-key`,children:`Access key ID`}),(0,U.jsx)(Hv,{id:`s3-access-key`,placeholder:`AKIAIOSFODNN7EXAMPLE`,value:e[`s3.access_key_id`]??``,onChange:e=>t(`s3.access_key_id`,e.target.value),disabled:n})]}),(0,U.jsx)(o1,{id:`s3-secret-key`,label:`Secret access key`,fieldKey:`s3.secret_access_key`,values:e,onChange:t,disabled:n})]}),(0,U.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,U.jsx)(X,{htmlFor:`s3-region`,children:`Region`}),(0,U.jsx)(Hv,{id:`s3-region`,placeholder:`us-east-1`,value:e[`s3.region`]??``,onChange:e=>t(`s3.region`,e.target.value),disabled:n})]}),(0,U.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,U.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,U.jsx)(X,{htmlFor:`s3-bucket`,children:`Bucket`}),(0,U.jsx)(Hv,{id:`s3-bucket`,placeholder:`my-bucket`,value:e[`s3.bucket`]??``,onChange:e=>t(`s3.bucket`,e.target.value),disabled:n})]}),(0,U.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,U.jsx)(X,{htmlFor:`s3-path-prefix`,children:`Path prefix`}),(0,U.jsx)(Hv,{id:`s3-path-prefix`,placeholder:`cms/media`,value:e[`s3.path_prefix`]??``,onChange:e=>t(`s3.path_prefix`,e.target.value),disabled:n}),(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Optional. Shared bucket subfolder.`})]})]}),(0,U.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,U.jsx)(X,{htmlFor:`s3-public-url`,children:`Public URL`}),(0,U.jsx)(Hv,{id:`s3-public-url`,placeholder:`https://cdn.example.com`,value:e[`s3.public_url`]??``,onChange:e=>t(`s3.public_url`,e.target.value),disabled:n}),(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Optional. Leave blank to use the default S3 URL.`})]})]})}function c1({values:e,onChange:t,disabled:n=!1}){return(0,U.jsxs)(`div`,{className:`space-y-4`,children:[(0,U.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,U.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,U.jsx)(X,{htmlFor:`r2-access-key`,children:`Access key ID`}),(0,U.jsx)(Hv,{id:`r2-access-key`,placeholder:`R2 access key ID`,value:e[`r2.access_key_id`]??``,onChange:e=>t(`r2.access_key_id`,e.target.value),disabled:n})]}),(0,U.jsx)(o1,{id:`r2-secret-key`,label:`Secret access key`,fieldKey:`r2.secret_access_key`,values:e,onChange:t,disabled:n})]}),(0,U.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,U.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,U.jsx)(X,{htmlFor:`r2-bucket`,children:`Bucket`}),(0,U.jsx)(Hv,{id:`r2-bucket`,placeholder:`my-bucket`,value:e[`r2.bucket`]??``,onChange:e=>t(`r2.bucket`,e.target.value),disabled:n})]}),(0,U.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,U.jsx)(X,{htmlFor:`r2-path-prefix`,children:`Path prefix`}),(0,U.jsx)(Hv,{id:`r2-path-prefix`,placeholder:`cms/media`,value:e[`r2.path_prefix`]??``,onChange:e=>t(`r2.path_prefix`,e.target.value),disabled:n}),(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Optional. Shared bucket subfolder.`})]})]}),(0,U.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,U.jsxs)(X,{htmlFor:`r2-public-url`,children:[`Public URL `,(0,U.jsx)(`span`,{className:`text-destructive`,children:`*`})]}),(0,U.jsx)(Hv,{id:`r2-public-url`,placeholder:`https://assets.example.com`,value:e[`r2.public_url`]??``,onChange:e=>t(`r2.public_url`,e.target.value),disabled:n}),(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Required. R2 does not generate public URLs automatically.`})]})]})}function l1(){let{user:e}=ga(),{data:t,loading:n}=wa(`/cms/admin/settings/media`),{loading:r,error:i,request:a}=Vv(),[o,s]=(0,v.useState)(null),[c,l]=(0,v.useState)(!1),u=o??t??{provider:`local`},d=u.provider||`local`,f=e?.permissions??[],p=f.includes(`*`)||f.includes(`settings:overview:write`);function m(e,t){s({...u,[e]:t})}function h(e){s({...u,provider:e})}async function g(e){e.preventDefault();try{await a(`/cms/admin/settings/media`,`PUT`,u),l(!0),setTimeout(()=>l(!1),2500)}catch{}}return n?(0,U.jsxs)(`div`,{className:`flex items-center gap-2 py-8 text-muted-foreground`,children:[(0,U.jsx)(by,{className:`size-4`}),(0,U.jsx)(`span`,{className:`text-sm`,children:`Loading settings…`})]}):(0,U.jsxs)(`form`,{onSubmit:g,className:`space-y-8`,children:[(0,U.jsxs)(`div`,{className:`border-b pb-4`,children:[(0,U.jsx)(`h2`,{className:`text-2xl font-semibold`,children:`Storage`}),(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Configure where uploaded files are stored.`})]}),(0,U.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,U.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,U.jsx)(X,{htmlFor:`provider`,children:`Storage provider`}),(0,U.jsxs)(Ow,{value:d,onValueChange:e=>h(e),children:[(0,U.jsx)(jw,{id:`provider`,disabled:!p,children:(0,U.jsx)(Aw,{})}),(0,U.jsxs)(Pw,{children:[(0,U.jsx)(Iw,{value:`local`,children:`Local`}),(0,U.jsx)(Iw,{value:`s3`,children:`Amazon S3`}),(0,U.jsx)(Iw,{value:`r2`,children:`Cloudflare R2`})]})]})]}),d===`r2`&&(0,U.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,U.jsx)(X,{htmlFor:`r2-account-id`,children:`Account ID`}),(0,U.jsx)(Hv,{id:`r2-account-id`,placeholder:`023e105f4ecef8ad9ca31a8372d0c353`,value:u[`r2.account_id`]??``,onChange:e=>m(`r2.account_id`,e.target.value),disabled:!p}),(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Found in the Cloudflare dashboard under R2 > Overview.`})]})]}),(0,U.jsxs)(`div`,{className:`border-t pt-6`,children:[d===`local`&&(0,U.jsx)(a1,{values:u,onChange:m,disabled:!p}),d===`s3`&&(0,U.jsx)(s1,{values:u,onChange:m,disabled:!p}),d===`r2`&&(0,U.jsx)(c1,{values:u,onChange:m,disabled:!p})]}),(0,U.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,U.jsx)(J,{type:`submit`,disabled:r||!p,children:r?`Saving…`:`Save`}),c&&(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Changes saved.`}),i&&(0,U.jsx)(`p`,{className:`text-sm text-destructive`,children:i})]})]})}function u1({className:e,...t}){return(0,U.jsx)(`div`,{"data-slot":`card`,className:q(`flex flex-col gap-6 rounded-xl border bg-card py-6 text-card-foreground shadow-sm`,e),...t})}function d1({className:e,...t}){return(0,U.jsx)(`div`,{"data-slot":`card-header`,className:q(`@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-2 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6`,e),...t})}function f1({className:e,...t}){return(0,U.jsx)(`div`,{"data-slot":`card-title`,className:q(`leading-none font-semibold`,e),...t})}function p1({className:e,...t}){return(0,U.jsx)(`div`,{"data-slot":`card-action`,className:q(`col-start-2 row-span-2 row-start-1 self-start justify-self-end`,e),...t})}function m1({className:e,...t}){return(0,U.jsx)(`div`,{"data-slot":`card-content`,className:q(`px-6`,e),...t})}function h1(e){if(!e||typeof document>`u`)return;let t=document.head||document.getElementsByTagName(`head`)[0],n=document.createElement(`style`);n.type=`text/css`,t.appendChild(n),n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e))}var g1=e=>{switch(e){case`success`:return y1;case`info`:return x1;case`warning`:return b1;case`error`:return S1;default:return null}},_1=Array(12).fill(0),v1=({visible:e,className:t})=>v.createElement(`div`,{className:[`sonner-loading-wrapper`,t].filter(Boolean).join(` `),"data-visible":e},v.createElement(`div`,{className:`sonner-spinner`},_1.map((e,t)=>v.createElement(`div`,{className:`sonner-loading-bar`,key:`spinner-bar-${t}`})))),y1=v.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 20 20`,fill:`currentColor`,height:`20`,width:`20`},v.createElement(`path`,{fillRule:`evenodd`,d:`M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z`,clipRule:`evenodd`})),b1=v.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,fill:`currentColor`,height:`20`,width:`20`},v.createElement(`path`,{fillRule:`evenodd`,d:`M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z`,clipRule:`evenodd`})),x1=v.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 20 20`,fill:`currentColor`,height:`20`,width:`20`},v.createElement(`path`,{fillRule:`evenodd`,d:`M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z`,clipRule:`evenodd`})),S1=v.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 20 20`,fill:`currentColor`,height:`20`,width:`20`},v.createElement(`path`,{fillRule:`evenodd`,d:`M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z`,clipRule:`evenodd`})),C1=v.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`12`,height:`12`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`},v.createElement(`line`,{x1:`18`,y1:`6`,x2:`6`,y2:`18`}),v.createElement(`line`,{x1:`6`,y1:`6`,x2:`18`,y2:`18`})),w1=()=>{let[e,t]=v.useState(document.hidden);return v.useEffect(()=>{let e=()=>{t(document.hidden)};return document.addEventListener(`visibilitychange`,e),()=>window.removeEventListener(`visibilitychange`,e)},[]),e},T1=1,E1=new class{constructor(){this.subscribe=e=>(this.subscribers.push(e),()=>{let t=this.subscribers.indexOf(e);this.subscribers.splice(t,1)}),this.publish=e=>{this.subscribers.forEach(t=>t(e))},this.addToast=e=>{this.publish(e),this.toasts=[...this.toasts,e]},this.create=e=>{let{message:t,...n}=e,r=typeof e?.id==`number`||e.id?.length>0?e.id:T1++,i=this.toasts.find(e=>e.id===r),a=e.dismissible===void 0?!0:e.dismissible;return this.dismissedToasts.has(r)&&this.dismissedToasts.delete(r),i?this.toasts=this.toasts.map(n=>n.id===r?(this.publish({...n,...e,id:r,title:t}),{...n,...e,id:r,dismissible:a,title:t}):n):this.addToast({title:t,...n,dismissible:a,id:r}),r},this.dismiss=e=>(e?(this.dismissedToasts.add(e),requestAnimationFrame(()=>this.subscribers.forEach(t=>t({id:e,dismiss:!0})))):this.toasts.forEach(e=>{this.subscribers.forEach(t=>t({id:e.id,dismiss:!0}))}),e),this.message=(e,t)=>this.create({...t,message:e}),this.error=(e,t)=>this.create({...t,message:e,type:`error`}),this.success=(e,t)=>this.create({...t,type:`success`,message:e}),this.info=(e,t)=>this.create({...t,type:`info`,message:e}),this.warning=(e,t)=>this.create({...t,type:`warning`,message:e}),this.loading=(e,t)=>this.create({...t,type:`loading`,message:e}),this.promise=(e,t)=>{if(!t)return;let n;t.loading!==void 0&&(n=this.create({...t,promise:e,type:`loading`,message:t.loading,description:typeof t.description==`function`?void 0:t.description}));let r=Promise.resolve(e instanceof Function?e():e),i=n!==void 0,a,o=r.then(async e=>{if(a=[`resolve`,e],v.isValidElement(e))i=!1,this.create({id:n,type:`default`,message:e});else if(O1(e)&&!e.ok){i=!1;let r=typeof t.error==`function`?await t.error(`HTTP error! status: ${e.status}`):t.error,a=typeof t.description==`function`?await t.description(`HTTP error! status: ${e.status}`):t.description,o=typeof r==`object`&&!v.isValidElement(r)?r:{message:r};this.create({id:n,type:`error`,description:a,...o})}else if(e instanceof Error){i=!1;let r=typeof t.error==`function`?await t.error(e):t.error,a=typeof t.description==`function`?await t.description(e):t.description,o=typeof r==`object`&&!v.isValidElement(r)?r:{message:r};this.create({id:n,type:`error`,description:a,...o})}else if(t.success!==void 0){i=!1;let r=typeof t.success==`function`?await t.success(e):t.success,a=typeof t.description==`function`?await t.description(e):t.description,o=typeof r==`object`&&!v.isValidElement(r)?r:{message:r};this.create({id:n,type:`success`,description:a,...o})}}).catch(async e=>{if(a=[`reject`,e],t.error!==void 0){i=!1;let r=typeof t.error==`function`?await t.error(e):t.error,a=typeof t.description==`function`?await t.description(e):t.description,o=typeof r==`object`&&!v.isValidElement(r)?r:{message:r};this.create({id:n,type:`error`,description:a,...o})}}).finally(()=>{i&&(this.dismiss(n),n=void 0),t.finally==null||t.finally.call(t)}),s=()=>new Promise((e,t)=>o.then(()=>a[0]===`reject`?t(a[1]):e(a[1])).catch(t));return typeof n!=`string`&&typeof n!=`number`?{unwrap:s}:Object.assign(n,{unwrap:s})},this.custom=(e,t)=>{let n=t?.id||T1++;return this.create({jsx:e(n),id:n,...t}),n},this.getActiveToasts=()=>this.toasts.filter(e=>!this.dismissedToasts.has(e.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}},D1=(e,t)=>{let n=t?.id||T1++;return E1.addToast({title:e,...t,id:n}),n},O1=e=>e&&typeof e==`object`&&`ok`in e&&typeof e.ok==`boolean`&&`status`in e&&typeof e.status==`number`,k1=Object.assign(D1,{success:E1.success,info:E1.info,warning:E1.warning,error:E1.error,custom:E1.custom,message:E1.message,promise:E1.promise,dismiss:E1.dismiss,loading:E1.loading},{getHistory:()=>E1.toasts,getToasts:()=>E1.getActiveToasts()});h1(`[data-sonner-toaster][dir=ltr],html[dir=ltr]{--toast-icon-margin-start:-3px;--toast-icon-margin-end:4px;--toast-svg-margin-start:-1px;--toast-svg-margin-end:0px;--toast-button-margin-start:auto;--toast-button-margin-end:0;--toast-close-button-start:0;--toast-close-button-end:unset;--toast-close-button-transform:translate(-35%, -35%)}[data-sonner-toaster][dir=rtl],html[dir=rtl]{--toast-icon-margin-start:4px;--toast-icon-margin-end:-3px;--toast-svg-margin-start:0px;--toast-svg-margin-end:-1px;--toast-button-margin-start:0;--toast-button-margin-end:auto;--toast-close-button-start:unset;--toast-close-button-end:0;--toast-close-button-transform:translate(35%, -35%)}[data-sonner-toaster]{position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1:hsl(0, 0%, 99%);--gray2:hsl(0, 0%, 97.3%);--gray3:hsl(0, 0%, 95.1%);--gray4:hsl(0, 0%, 93%);--gray5:hsl(0, 0%, 90.9%);--gray6:hsl(0, 0%, 88.7%);--gray7:hsl(0, 0%, 85.8%);--gray8:hsl(0, 0%, 78%);--gray9:hsl(0, 0%, 56.1%);--gray10:hsl(0, 0%, 52.3%);--gray11:hsl(0, 0%, 43.5%);--gray12:hsl(0, 0%, 9%);--border-radius:8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:0;z-index:999999999;transition:transform .4s ease}@media (hover:none) and (pointer:coarse){[data-sonner-toaster][data-lifted=true]{transform:none}}[data-sonner-toaster][data-x-position=right]{right:var(--offset-right)}[data-sonner-toaster][data-x-position=left]{left:var(--offset-left)}[data-sonner-toaster][data-x-position=center]{left:50%;transform:translateX(-50%)}[data-sonner-toaster][data-y-position=top]{top:var(--offset-top)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--offset-bottom)}[data-sonner-toast]{--y:translateY(100%);--lift-amount:calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:0;overflow-wrap:anywhere}[data-sonner-toast][data-styled=true]{padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px rgba(0,0,0,.1);width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}[data-sonner-toast]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-y-position=top]{top:0;--y:translateY(-100%);--lift:1;--lift-amount:calc(1 * var(--gap))}[data-sonner-toast][data-y-position=bottom]{bottom:0;--y:translateY(100%);--lift:-1;--lift-amount:calc(var(--lift) * var(--gap))}[data-sonner-toast][data-styled=true] [data-description]{font-weight:400;line-height:1.4;color:#3f3f3f}[data-rich-colors=true][data-sonner-toast][data-styled=true] [data-description]{color:inherit}[data-sonner-toaster][data-sonner-theme=dark] [data-description]{color:#e8e8e8}[data-sonner-toast][data-styled=true] [data-title]{font-weight:500;line-height:1.5;color:inherit}[data-sonner-toast][data-styled=true] [data-icon]{display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}[data-sonner-toast][data-promise=true] [data-icon]>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}[data-sonner-toast][data-styled=true] [data-icon]>*{flex-shrink:0}[data-sonner-toast][data-styled=true] [data-icon] svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}[data-sonner-toast][data-styled=true] [data-content]{display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;font-weight:500;cursor:pointer;outline:0;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}[data-sonner-toast][data-styled=true] [data-button]:focus-visible{box-shadow:0 0 0 2px rgba(0,0,0,.4)}[data-sonner-toast][data-styled=true] [data-button]:first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}[data-sonner-toast][data-styled=true] [data-cancel]{color:var(--normal-text);background:rgba(0,0,0,.08)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-styled=true] [data-cancel]{background:rgba(255,255,255,.3)}[data-sonner-toast][data-styled=true] [data-close-button]{position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);background:var(--normal-bg);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast][data-styled=true] [data-close-button]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-styled=true] [data-disabled=true]{cursor:not-allowed}[data-sonner-toast][data-styled=true]:hover [data-close-button]:hover{background:var(--gray2);border-color:var(--gray5)}[data-sonner-toast][data-swiping=true]::before{content:'';position:absolute;left:-100%;right:-100%;height:100%;z-index:-1}[data-sonner-toast][data-y-position=top][data-swiping=true]::before{bottom:50%;transform:scaleY(3) translateY(50%)}[data-sonner-toast][data-y-position=bottom][data-swiping=true]::before{top:50%;transform:scaleY(3) translateY(-50%)}[data-sonner-toast][data-swiping=false][data-removed=true]::before{content:'';position:absolute;inset:0;transform:scaleY(2)}[data-sonner-toast][data-expanded=true]::after{content:'';position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}[data-sonner-toast][data-mounted=true]{--y:translateY(0);opacity:1}[data-sonner-toast][data-expanded=false][data-front=false]{--scale:var(--toasts-before) * 0.05 + 1;--y:translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}[data-sonner-toast]>*{transition:opacity .4s}[data-sonner-toast][data-x-position=right]{right:0}[data-sonner-toast][data-x-position=left]{left:0}[data-sonner-toast][data-expanded=false][data-front=false][data-styled=true]>*{opacity:0}[data-sonner-toast][data-visible=false]{opacity:0;pointer-events:none}[data-sonner-toast][data-mounted=true][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}[data-sonner-toast][data-removed=true][data-front=true][data-swipe-out=false]{--y:translateY(calc(var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=false]{--y:translateY(40%);opacity:0;transition:transform .5s,opacity .2s}[data-sonner-toast][data-removed=true][data-front=false]::before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y,0)) translateX(var(--swipe-amount-x,0));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width:600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-sonner-theme=light]{--normal-bg:#fff;--normal-border:var(--gray4);--normal-text:var(--gray12);--success-bg:hsl(143, 85%, 96%);--success-border:hsl(145, 92%, 87%);--success-text:hsl(140, 100%, 27%);--info-bg:hsl(208, 100%, 97%);--info-border:hsl(221, 91%, 93%);--info-text:hsl(210, 92%, 45%);--warning-bg:hsl(49, 100%, 97%);--warning-border:hsl(49, 91%, 84%);--warning-text:hsl(31, 92%, 45%);--error-bg:hsl(359, 100%, 97%);--error-border:hsl(359, 100%, 94%);--error-text:hsl(360, 100%, 45%)}[data-sonner-toaster][data-sonner-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg:#000;--normal-border:hsl(0, 0%, 20%);--normal-text:var(--gray1)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg:#fff;--normal-border:var(--gray3);--normal-text:var(--gray12)}[data-sonner-toaster][data-sonner-theme=dark]{--normal-bg:#000;--normal-bg-hover:hsl(0, 0%, 12%);--normal-border:hsl(0, 0%, 20%);--normal-border-hover:hsl(0, 0%, 25%);--normal-text:var(--gray1);--success-bg:hsl(150, 100%, 6%);--success-border:hsl(147, 100%, 12%);--success-text:hsl(150, 86%, 65%);--info-bg:hsl(215, 100%, 6%);--info-border:hsl(223, 43%, 17%);--info-text:hsl(216, 87%, 65%);--warning-bg:hsl(64, 100%, 6%);--warning-border:hsl(60, 100%, 9%);--warning-text:hsl(46, 87%, 65%);--error-bg:hsl(358, 76%, 10%);--error-border:hsl(357, 89%, 16%);--error-text:hsl(358, 100%, 81%)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size:16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:first-child{animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}100%{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}100%{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}100%{opacity:.15}}@media (prefers-reduced-motion){.sonner-loading-bar,[data-sonner-toast],[data-sonner-toast]>*{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}`);function A1(e){return e.label!==void 0}var j1=3,M1=`24px`,N1=`16px`,P1=4e3,F1=356,I1=14,L1=45,R1=200;function z1(...e){return e.filter(Boolean).join(` `)}function B1(e){let[t,n]=e.split(`-`),r=[];return t&&r.push(t),n&&r.push(n),r}var V1=e=>{let{invert:t,toast:n,unstyled:r,interacting:i,setHeights:a,visibleToasts:o,heights:s,index:c,toasts:l,expanded:u,removeToast:d,defaultRichColors:f,closeButton:p,style:m,cancelButtonStyle:h,actionButtonStyle:g,className:_=``,descriptionClassName:y=``,duration:b,position:x,gap:S,expandByDefault:C,classNames:w,icons:T,closeButtonAriaLabel:E=`Close toast`}=e,[D,O]=v.useState(null),[k,A]=v.useState(null),[j,M]=v.useState(!1),[N,P]=v.useState(!1),[F,I]=v.useState(!1),[L,R]=v.useState(!1),[ee,te]=v.useState(!1),[z,B]=v.useState(0),[V,ne]=v.useState(0),H=v.useRef(n.duration||b||P1),re=v.useRef(null),ie=v.useRef(null),ae=c===0,oe=c+1<=o,se=n.type,ce=n.dismissible!==!1,le=n.className||``,ue=n.descriptionClassName||``,de=v.useMemo(()=>s.findIndex(e=>e.toastId===n.id)||0,[s,n.id]),fe=v.useMemo(()=>n.closeButton??p,[n.closeButton,p]),pe=v.useMemo(()=>n.duration||b||P1,[n.duration,b]),me=v.useRef(0),he=v.useRef(0),ge=v.useRef(0),_e=v.useRef(null),[ve,ye]=x.split(`-`),be=v.useMemo(()=>s.reduce((e,t,n)=>n>=de?e:e+t.height,0),[s,de]),xe=w1(),Se=n.invert||t,Ce=se===`loading`;he.current=v.useMemo(()=>de*S+be,[de,be]),v.useEffect(()=>{H.current=pe},[pe]),v.useEffect(()=>{M(!0)},[]),v.useEffect(()=>{let e=ie.current;if(e){let t=e.getBoundingClientRect().height;return ne(t),a(e=>[{toastId:n.id,height:t,position:n.position},...e]),()=>a(e=>e.filter(e=>e.toastId!==n.id))}},[a,n.id]),v.useLayoutEffect(()=>{if(!j)return;let e=ie.current,t=e.style.height;e.style.height=`auto`;let r=e.getBoundingClientRect().height;e.style.height=t,ne(r),a(e=>e.find(e=>e.toastId===n.id)?e.map(e=>e.toastId===n.id?{...e,height:r}:e):[{toastId:n.id,height:r,position:n.position},...e])},[j,n.title,n.description,a,n.id,n.jsx,n.action,n.cancel]);let we=v.useCallback(()=>{P(!0),B(he.current),a(e=>e.filter(e=>e.toastId!==n.id)),setTimeout(()=>{d(n)},R1)},[n,d,a,he]);v.useEffect(()=>{if(n.promise&&se===`loading`||n.duration===1/0||n.type===`loading`)return;let e;return u||i||xe?(()=>{if(ge.current<me.current){let e=new Date().getTime()-me.current;H.current-=e}ge.current=new Date().getTime()})():H.current!==1/0&&(me.current=new Date().getTime(),e=setTimeout(()=>{n.onAutoClose==null||n.onAutoClose.call(n,n),we()},H.current)),()=>clearTimeout(e)},[u,i,n,se,xe,we]),v.useEffect(()=>{n.delete&&(we(),n.onDismiss==null||n.onDismiss.call(n,n))},[we,n.delete]);function Te(){return T?.loading?v.createElement(`div`,{className:z1(w?.loader,n?.classNames?.loader,`sonner-loader`),"data-visible":se===`loading`},T.loading):v.createElement(v1,{className:z1(w?.loader,n?.classNames?.loader),visible:se===`loading`})}let Ee=n.icon||T?.[se]||g1(se);return v.createElement(`li`,{tabIndex:0,ref:ie,className:z1(_,le,w?.toast,n?.classNames?.toast,w?.default,w?.[se],n?.classNames?.[se]),"data-sonner-toast":``,"data-rich-colors":n.richColors??f,"data-styled":!(n.jsx||n.unstyled||r),"data-mounted":j,"data-promise":!!n.promise,"data-swiped":ee,"data-removed":N,"data-visible":oe,"data-y-position":ve,"data-x-position":ye,"data-index":c,"data-front":ae,"data-swiping":F,"data-dismissible":ce,"data-type":se,"data-invert":Se,"data-swipe-out":L,"data-swipe-direction":k,"data-expanded":!!(u||C&&j),"data-testid":n.testId,style:{"--index":c,"--toasts-before":c,"--z-index":l.length-c,"--offset":`${N?z:he.current}px`,"--initial-height":C?`auto`:`${V}px`,...m,...n.style},onDragEnd:()=>{I(!1),O(null),_e.current=null},onPointerDown:e=>{e.button!==2&&(Ce||!ce||(re.current=new Date,B(he.current),e.target.setPointerCapture(e.pointerId),e.target.tagName!==`BUTTON`&&(I(!0),_e.current={x:e.clientX,y:e.clientY})))},onPointerUp:()=>{if(L||!ce)return;_e.current=null;let e=Number(ie.current?.style.getPropertyValue(`--swipe-amount-x`).replace(`px`,``)||0),t=Number(ie.current?.style.getPropertyValue(`--swipe-amount-y`).replace(`px`,``)||0),r=new Date().getTime()-re.current?.getTime(),i=D===`x`?e:t,a=Math.abs(i)/r;if(Math.abs(i)>=L1||a>.11){B(he.current),n.onDismiss==null||n.onDismiss.call(n,n),A(D===`x`?e>0?`right`:`left`:t>0?`down`:`up`),we(),R(!0);return}else{var o,s;(o=ie.current)==null||o.style.setProperty(`--swipe-amount-x`,`0px`),(s=ie.current)==null||s.style.setProperty(`--swipe-amount-y`,`0px`)}te(!1),I(!1),O(null)},onPointerMove:t=>{var n,r;if(!_e.current||!ce||window.getSelection()?.toString().length>0)return;let i=t.clientY-_e.current.y,a=t.clientX-_e.current.x,o=e.swipeDirections??B1(x);!D&&(Math.abs(a)>1||Math.abs(i)>1)&&O(Math.abs(a)>Math.abs(i)?`x`:`y`);let s={x:0,y:0},c=e=>1/(1.5+Math.abs(e)/20);if(D===`y`){if(o.includes(`top`)||o.includes(`bottom`))if(o.includes(`top`)&&i<0||o.includes(`bottom`)&&i>0)s.y=i;else{let e=i*c(i);s.y=Math.abs(e)<Math.abs(i)?e:i}}else if(D===`x`&&(o.includes(`left`)||o.includes(`right`)))if(o.includes(`left`)&&a<0||o.includes(`right`)&&a>0)s.x=a;else{let e=a*c(a);s.x=Math.abs(e)<Math.abs(a)?e:a}(Math.abs(s.x)>0||Math.abs(s.y)>0)&&te(!0),(n=ie.current)==null||n.style.setProperty(`--swipe-amount-x`,`${s.x}px`),(r=ie.current)==null||r.style.setProperty(`--swipe-amount-y`,`${s.y}px`)}},fe&&!n.jsx&&se!==`loading`?v.createElement(`button`,{"aria-label":E,"data-disabled":Ce,"data-close-button":!0,onClick:Ce||!ce?()=>{}:()=>{we(),n.onDismiss==null||n.onDismiss.call(n,n)},className:z1(w?.closeButton,n?.classNames?.closeButton)},T?.close??C1):null,(se||n.icon||n.promise)&&n.icon!==null&&(T?.[se]!==null||n.icon)?v.createElement(`div`,{"data-icon":``,className:z1(w?.icon,n?.classNames?.icon)},n.promise||n.type===`loading`&&!n.icon?n.icon||Te():null,n.type===`loading`?null:Ee):null,v.createElement(`div`,{"data-content":``,className:z1(w?.content,n?.classNames?.content)},v.createElement(`div`,{"data-title":``,className:z1(w?.title,n?.classNames?.title)},n.jsx?n.jsx:typeof n.title==`function`?n.title():n.title),n.description?v.createElement(`div`,{"data-description":``,className:z1(y,ue,w?.description,n?.classNames?.description)},typeof n.description==`function`?n.description():n.description):null),v.isValidElement(n.cancel)?n.cancel:n.cancel&&A1(n.cancel)?v.createElement(`button`,{"data-button":!0,"data-cancel":!0,style:n.cancelButtonStyle||h,onClick:e=>{A1(n.cancel)&&ce&&(n.cancel.onClick==null||n.cancel.onClick.call(n.cancel,e),we())},className:z1(w?.cancelButton,n?.classNames?.cancelButton)},n.cancel.label):null,v.isValidElement(n.action)?n.action:n.action&&A1(n.action)?v.createElement(`button`,{"data-button":!0,"data-action":!0,style:n.actionButtonStyle||g,onClick:e=>{A1(n.action)&&(n.action.onClick==null||n.action.onClick.call(n.action,e),!e.defaultPrevented&&we())},className:z1(w?.actionButton,n?.classNames?.actionButton)},n.action.label):null)};function H1(){if(typeof window>`u`||typeof document>`u`)return`ltr`;let e=document.documentElement.getAttribute(`dir`);return e===`auto`||!e?window.getComputedStyle(document.documentElement).direction:e}function U1(e,t){let n={};return[e,t].forEach((e,t)=>{let r=t===1,i=r?`--mobile-offset`:`--offset`,a=r?N1:M1;function o(e){[`top`,`right`,`bottom`,`left`].forEach(t=>{n[`${i}-${t}`]=typeof e==`number`?`${e}px`:e})}typeof e==`number`||typeof e==`string`?o(e):typeof e==`object`?[`top`,`right`,`bottom`,`left`].forEach(t=>{e[t]===void 0?n[`${i}-${t}`]=a:n[`${i}-${t}`]=typeof e[t]==`number`?`${e[t]}px`:e[t]}):o(a)}),n}var W1=v.forwardRef(function(e,t){let{id:n,invert:r,position:i=`bottom-right`,hotkey:a=[`altKey`,`KeyT`],expand:o,closeButton:s,className:c,offset:l,mobileOffset:u,theme:d=`light`,richColors:f,duration:p,style:m,visibleToasts:h=j1,toastOptions:g,dir:_=H1(),gap:y=I1,icons:b,containerAriaLabel:x=`Notifications`}=e,[S,C]=v.useState([]),w=v.useMemo(()=>n?S.filter(e=>e.toasterId===n):S.filter(e=>!e.toasterId),[S,n]),T=v.useMemo(()=>Array.from(new Set([i].concat(w.filter(e=>e.position).map(e=>e.position)))),[w,i]),[E,D]=v.useState([]),[O,k]=v.useState(!1),[A,j]=v.useState(!1),[M,P]=v.useState(d===`system`?typeof window<`u`&&window.matchMedia&&window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`:d),F=v.useRef(null),I=a.join(`+`).replace(/Key/g,``).replace(/Digit/g,``),L=v.useRef(null),R=v.useRef(!1),ee=v.useCallback(e=>{C(t=>(t.find(t=>t.id===e.id)?.delete||E1.dismiss(e.id),t.filter(({id:t})=>t!==e.id)))},[]);return v.useEffect(()=>E1.subscribe(e=>{if(e.dismiss){requestAnimationFrame(()=>{C(t=>t.map(t=>t.id===e.id?{...t,delete:!0}:t))});return}setTimeout(()=>{N.flushSync(()=>{C(t=>{let n=t.findIndex(t=>t.id===e.id);return n===-1?[e,...t]:[...t.slice(0,n),{...t[n],...e},...t.slice(n+1)]})})})}),[S]),v.useEffect(()=>{if(d!==`system`){P(d);return}if(d===`system`&&(window.matchMedia&&window.matchMedia(`(prefers-color-scheme: dark)`).matches?P(`dark`):P(`light`)),typeof window>`u`)return;let e=window.matchMedia(`(prefers-color-scheme: dark)`);try{e.addEventListener(`change`,({matches:e})=>{P(e?`dark`:`light`)})}catch{e.addListener(({matches:e})=>{try{P(e?`dark`:`light`)}catch(e){console.error(e)}})}},[d]),v.useEffect(()=>{S.length<=1&&k(!1)},[S]),v.useEffect(()=>{let e=e=>{if(a.every(t=>e[t]||e.code===t)){var t;k(!0),(t=F.current)==null||t.focus()}e.code===`Escape`&&(document.activeElement===F.current||F.current?.contains(document.activeElement))&&k(!1)};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[a]),v.useEffect(()=>{if(F.current)return()=>{L.current&&(L.current.focus({preventScroll:!0}),L.current=null,R.current=!1)}},[F.current]),v.createElement(`section`,{ref:t,"aria-label":`${x} ${I}`,tabIndex:-1,"aria-live":`polite`,"aria-relevant":`additions text`,"aria-atomic":`false`,suppressHydrationWarning:!0},T.map((t,n)=>{let[i,a]=t.split(`-`);return w.length?v.createElement(`ol`,{key:t,dir:_===`auto`?H1():_,tabIndex:-1,ref:F,className:c,"data-sonner-toaster":!0,"data-sonner-theme":M,"data-y-position":i,"data-x-position":a,style:{"--front-toast-height":`${E[0]?.height||0}px`,"--width":`${F1}px`,"--gap":`${y}px`,...m,...U1(l,u)},onBlur:e=>{R.current&&!e.currentTarget.contains(e.relatedTarget)&&(R.current=!1,L.current&&=(L.current.focus({preventScroll:!0}),null))},onFocus:e=>{e.target instanceof HTMLElement&&e.target.dataset.dismissible===`false`||R.current||(R.current=!0,L.current=e.relatedTarget)},onMouseEnter:()=>k(!0),onMouseMove:()=>k(!0),onMouseLeave:()=>{A||k(!1)},onDragEnd:()=>k(!1),onPointerDown:e=>{e.target instanceof HTMLElement&&e.target.dataset.dismissible===`false`||j(!0)},onPointerUp:()=>j(!1)},w.filter(e=>!e.position&&n===0||e.position===t).map((n,i)=>v.createElement(V1,{key:n.id,icons:b,index:i,toast:n,defaultRichColors:f,duration:g?.duration??p,className:g?.className,descriptionClassName:g?.descriptionClassName,invert:r,visibleToasts:h,closeButton:g?.closeButton??s,interacting:A,position:t,style:g?.style,unstyled:g?.unstyled,classNames:g?.classNames,cancelButtonStyle:g?.cancelButtonStyle,actionButtonStyle:g?.actionButtonStyle,closeButtonAriaLabel:g?.closeButtonAriaLabel,removeToast:ee,toasts:w.filter(e=>e.position==n.position),heights:E.filter(e=>e.position==n.position),setHeights:D,expandByDefault:o,gap:y,expanded:O,swipeDirections:e.swipeDirections}))):null}))}),G1={name:`@plank-cms/admin`,version:`0.17.1`,type:`module`,scripts:{build:`vite build`,dev:`vite`,lint:`eslint src/`},dependencies:{"@dnd-kit/core":`6.3.1`,"@dnd-kit/sortable":`10.0.0`,"@dnd-kit/utilities":`3.2.2`,"@radix-ui/react-avatar":`1.1.11`,"@radix-ui/react-checkbox":`1.3.3`,"@radix-ui/react-dialog":`1.1.15`,"@radix-ui/react-dropdown-menu":`2.1.16`,"@radix-ui/react-label":`2.1.8`,"@radix-ui/react-popover":`1.1.15`,"@radix-ui/react-select":`2.2.6`,"@radix-ui/react-separator":`1.1.8`,"@radix-ui/react-slot":`1.2.4`,"@radix-ui/react-switch":`1.2.6`,"@radix-ui/react-tabs":`1.1.13`,"@radix-ui/react-tooltip":`1.2.8`,"@tanstack/react-table":`8.21.3`,"@tiptap/extension-image":`3.22.4`,"@tiptap/pm":`3.22.4`,"@tiptap/react":`3.22.4`,"@tiptap/starter-kit":`3.22.4`,"class-variance-authority":`0.7.1`,clsx:`2.1.1`,cmdk:`1.1.1`,"date-fns":`4.1.0`,"hls.js":`1.6.16`,"input-otp":`1.4.2`,"lucide-react":`1.8.0`,"next-themes":`0.4.6`,"qrcode.react":`4.2.0`,"radix-ui":`1.4.3`,react:`19.2.5`,"react-day-picker":`9.14.0`,"react-dom":`19.2.5`,"react-router-dom":`7.14.1`,sonner:`2.0.7`,"tailwind-merge":`3.5.0`},devDependencies:{"@tailwindcss/vite":`4.2.3`,"@types/react":`19.2.14`,"@types/react-dom":`19.2.3`,"@types/react-router-dom":`5.3.3`,"@vitejs/plugin-react":`6.0.1`,tailwindcss:`4.2.3`,vite:`8.0.9`}},K1=[{value:`UTC`,label:`UTC — Coordinated Universal Time`},{value:`America/New_York`,label:`America/New_York — Eastern Time (UTC-5/4)`},{value:`America/Chicago`,label:`America/Chicago — Central Time (UTC-6/5)`},{value:`America/Denver`,label:`America/Denver — Mountain Time (UTC-7/6)`},{value:`America/Los_Angeles`,label:`America/Los_Angeles — Pacific Time (UTC-8/7)`},{value:`America/Anchorage`,label:`America/Anchorage — Alaska Time (UTC-9/8)`},{value:`America/Honolulu`,label:`America/Honolulu — Hawaii Time (UTC-10)`},{value:`America/Mexico_City`,label:`America/Mexico_City — Mexico City (UTC-6/5)`},{value:`America/El_Salvador`,label:`America/El_Salvador — El Salvador (UTC-6)`},{value:`America/Bogota`,label:`America/Bogota — Colombia Time (UTC-5)`},{value:`America/Lima`,label:`America/Lima — Peru Time (UTC-5)`},{value:`America/Santiago`,label:`America/Santiago — Chile Time (UTC-4/3)`},{value:`America/Argentina/Buenos_Aires`,label:`America/Buenos_Aires — Argentina (UTC-3)`},{value:`America/Sao_Paulo`,label:`America/Sao_Paulo — Brasília Time (UTC-3/2)`},{value:`Atlantic/Reykjavik`,label:`Atlantic/Reykjavik — Iceland (UTC+0)`},{value:`Europe/London`,label:`Europe/London — GMT/BST (UTC+0/1)`},{value:`Europe/Paris`,label:`Europe/Paris — Central European Time (UTC+1/2)`},{value:`Europe/Berlin`,label:`Europe/Berlin — Central European Time (UTC+1/2)`},{value:`Europe/Madrid`,label:`Europe/Madrid — Central European Time (UTC+1/2)`},{value:`Europe/Rome`,label:`Europe/Rome — Central European Time (UTC+1/2)`},{value:`Europe/Helsinki`,label:`Europe/Helsinki — Eastern European Time (UTC+2/3)`},{value:`Europe/Istanbul`,label:`Europe/Istanbul — Turkey Time (UTC+3)`},{value:`Europe/Moscow`,label:`Europe/Moscow — Moscow Standard Time (UTC+3)`},{value:`Asia/Dubai`,label:`Asia/Dubai — Gulf Standard Time (UTC+4)`},{value:`Asia/Karachi`,label:`Asia/Karachi — Pakistan Standard Time (UTC+5)`},{value:`Asia/Kolkata`,label:`Asia/Kolkata — India Standard Time (UTC+5:30)`},{value:`Asia/Dhaka`,label:`Asia/Dhaka — Bangladesh Standard Time (UTC+6)`},{value:`Asia/Bangkok`,label:`Asia/Bangkok — Indochina Time (UTC+7)`},{value:`Asia/Singapore`,label:`Asia/Singapore — Singapore Time (UTC+8)`},{value:`Asia/Shanghai`,label:`Asia/Shanghai — China Standard Time (UTC+8)`},{value:`Asia/Tokyo`,label:`Asia/Tokyo — Japan Standard Time (UTC+9)`},{value:`Asia/Seoul`,label:`Asia/Seoul — Korea Standard Time (UTC+9)`},{value:`Australia/Sydney`,label:`Australia/Sydney — AEST/AEDT (UTC+10/11)`},{value:`Australia/Melbourne`,label:`Australia/Melbourne — AEST/AEDT (UTC+10/11)`},{value:`Pacific/Auckland`,label:`Pacific/Auckland — New Zealand (UTC+12/13)`}];function q1(){let{user:e}=ga(),{data:t,loading:n}=wa(`/cms/admin/settings/general`),{request:r,loading:i}=Vv(),{request:a,loading:o}=Vv(),{request:s,loading:c}=Vv(),{refreshSettings:l}=ya(),[u,d]=(0,v.useState)(`UTC`),[f,p]=(0,v.useState)([]),[m,h]=(0,v.useState)(`en`),[g,_]=(0,v.useState)(``),[y,b]=(0,v.useState)(!1),x=e?.permissions??[],S=x.includes(`*`)||x.includes(`settings:overview:write`);(0,v.useEffect)(()=>{if(t?.timezone&&d(t.timezone),t?.locales)try{let e=JSON.parse(t.locales);Array.isArray(e)&&p(e)}catch{p((t.locales||``).split(`,`).map(e=>e.trim()).filter(Boolean))}t?.default_locale&&h(t.default_locale),b(String(t?.editorial_mode??`false`).toLowerCase()===`true`)},[t]);async function C(){try{await a(`/cms/admin/settings/general`,`PUT`,{locales:JSON.stringify(f),default_locale:m}),l(),k1.success(`Locales saved`)}catch{k1.error(`Could not save locales`)}}return n?(0,U.jsx)(by,{}):(0,U.jsxs)(`div`,{className:`space-y-6`,children:[(0,U.jsx)(u1,{children:(0,U.jsxs)(m1,{className:`flex items-center gap-4 py-2`,children:[(0,U.jsx)(`img`,{src:`/admin/plank-logo-w.svg`,alt:`Plank CMS`,className:`h-10 w-auto`}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`p`,{className:`font-bold`,children:`Plank CMS by AM25`}),(0,U.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Version `,G1.version]})]})]})}),(0,U.jsxs)(`div`,{className:`border-b pb-4`,children:[(0,U.jsx)(`h2`,{className:`text-2xl font-semibold`,children:`Commons`}),(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`General settings that apply across the CMS.`})]}),(0,U.jsxs)(`div`,{className:`space-y-2`,children:[(0,U.jsx)(X,{htmlFor:`timezone`,children:`Timezone`}),(0,U.jsxs)(Ow,{value:u,onValueChange:e=>{d(e),(async()=>{try{await r(`/cms/admin/settings/general`,`PUT`,{timezone:e}),l(),k1.success(`Timezone saved`)}catch{k1.error(`Could not save timezone`)}})()},children:[(0,U.jsx)(jw,{id:`timezone`,className:`w-full`,disabled:!S,children:(0,U.jsx)(Aw,{})}),(0,U.jsx)(Pw,{className:`max-h-72`,children:K1.map(e=>(0,U.jsx)(Iw,{value:e.value,children:e.label},e.value))})]}),(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Used to display dates and times across the admin panel.`}),i&&(0,U.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Saving…`})]})]}),(0,U.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 md:grid-cols-2`,children:[(0,U.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,U.jsx)(X,{children:`Locales`}),(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(Hv,{placeholder:`E.g. "en"`,value:g,onChange:e=>_(e.target.value),className:`h-9 w-full`,disabled:!S}),(0,U.jsx)(J,{variant:`outline`,className:`h-9`,disabled:!S,onClick:()=>{let e=g.trim().toLowerCase();e&&(f.includes(e)||p(t=>[...t,e]),_(``))},children:`Add`})]}),(0,U.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:f.map(e=>(0,U.jsx)(J,{variant:`ghost`,size:`sm`,onClick:()=>p(t=>t.filter(t=>t!==e)),disabled:!S,children:e.toUpperCase()},e))})]}),(0,U.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,U.jsx)(X,{htmlFor:`default-locale`,children:`Default locale`}),(0,U.jsxs)(Ow,{value:m,onValueChange:h,children:[(0,U.jsx)(jw,{id:`default-locale`,className:`w-full`,disabled:!S,children:(0,U.jsx)(Aw,{})}),(0,U.jsx)(Pw,{className:`max-h-72`,children:f.length===0?(0,U.jsx)(Iw,{value:m,children:m}):f.map(e=>(0,U.jsx)(Iw,{value:e,children:e.toUpperCase()},e))})]}),(0,U.jsx)(`div`,{className:`pt-2 flex justify-end`,children:(0,U.jsx)(J,{variant:`outline`,onClick:C,disabled:o||!S,children:o?`Saving…`:`Save`})})]})]}),(0,U.jsx)(WO,{}),(0,U.jsxs)(`div`,{className:`flex items-center justify-between rounded-md border p-3`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(X,{htmlFor:`editorial-mode`,children:`Editorial Mode`}),(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Enables Editor and Viewer workflows for editorial review.`})]}),(0,U.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,U.jsx)(nj,{id:`editorial-mode`,checked:y,onCheckedChange:e=>{b(e),(async()=>{try{await s(`/cms/admin/settings/general`,`PUT`,{editorial_mode:String(e)}),l(),k1.success(`Editorial Mode saved`)}catch{k1.error(`Could not save Editorial Mode`)}})()},disabled:!S}),c&&(0,U.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Saving…`})]})]})]})}function J1(){return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(yy,{children:[(0,U.jsx)(`h1`,{className:`text-2xl font-bold -mt-2`,children:`Overview`}),(0,U.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`General configuration for your CMS instance.`})]}),(0,U.jsxs)(QA,{defaultValue:`general`,className:`mt-24`,children:[(0,U.jsxs)($A,{className:`mb-6`,children:[(0,U.jsx)(ej,{value:`general`,children:`General`}),(0,U.jsx)(ej,{value:`media`,children:`Media Library`})]}),(0,U.jsx)(tj,{value:`general`,children:(0,U.jsx)(q1,{})}),(0,U.jsx)(tj,{value:`media`,children:(0,U.jsx)(l1,{})})]})]})}function Y1(e,t){return typeof e==`function`?e(t):e}function X1(e,t){return n=>{t.setState(t=>({...t,[e]:Y1(n,t[e])}))}}function Z1(e){return e instanceof Function}function Q1(e){return Array.isArray(e)&&e.every(e=>typeof e==`number`)}function $1(e,t){let n=[],r=e=>{e.forEach(e=>{n.push(e);let i=t(e);i!=null&&i.length&&r(i)})};return r(e),n}function e0(e,t,n){let r=[],i;return a=>{let o;n.key&&n.debug&&(o=Date.now());let s=e(a);if(!(s.length!==r.length||s.some((e,t)=>r[t]!==e)))return i;r=s;let c;if(n.key&&n.debug&&(c=Date.now()),i=t(...s),n==null||n.onChange==null||n.onChange(i),n.key&&n.debug&&n!=null&&n.debug()){let e=Math.round((Date.now()-o)*100)/100,t=Math.round((Date.now()-c)*100)/100,r=t/16,i=(e,t)=>{for(e=String(e);e.length<t;)e=` `+e;return e};console.info(`%c⏱ ${i(t,5)} /${i(e,5)} ms`,`
219
+ `):``,markdownTokenizer:{name:`taskList`,level:`block`,start(e){let t=e.match(/^\s*[-+*]\s+\[([ xX])\]\s+/)?.index;return t===void 0?-1:t},tokenize(e,t,n){let r=e=>{let t=nK(e,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:e=>({indentLevel:e[1].length,mainContent:e[4],checked:e[3].toLowerCase()===`x`}),createToken:(e,t)=>({type:`taskItem`,raw:``,mainContent:e.mainContent,indentLevel:e.indentLevel,checked:e.checked,text:e.mainContent,tokens:n.inlineTokens(e.mainContent),nestedTokens:t}),customNestedParser:r},n);return t?[{type:`taskList`,raw:t.raw,items:t.items}]:n.blockTokens(e)},i=nK(e,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:e=>({indentLevel:e[1].length,mainContent:e[4],checked:e[3].toLowerCase()===`x`}),createToken:(e,t)=>({type:`taskItem`,raw:``,mainContent:e.mainContent,indentLevel:e.indentLevel,checked:e.checked,text:e.mainContent,tokens:n.inlineTokens(e.mainContent),nestedTokens:t}),customNestedParser:r},n);if(i)return{type:`taskList`,raw:i.raw,items:i.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:e})=>e.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});EG.create({name:`listKit`,addExtensions(){let e=[];return this.options.bulletList!==!1&&e.push(_X.configure(this.options.bulletList)),this.options.listItem!==!1&&e.push(vX.configure(this.options.listItem)),this.options.listKeymap!==!1&&e.push(kX.configure(this.options.listKeymap)),this.options.orderedList!==!1&&e.push(BX.configure(this.options.orderedList)),this.options.taskItem!==!1&&e.push(HX.configure(this.options.taskItem)),this.options.taskList!==!1&&e.push(UX.configure(this.options.taskList)),e}});var WX=`&nbsp;`,GX=`\xA0`,KX=aK.create({name:`paragraph`,priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:`block`,content:`inline*`,parseHTML(){return[{tag:`p`}]},renderHTML({HTMLAttributes:e}){return[`p`,rW(this.options.HTMLAttributes,e),0]},parseMarkdown:(e,t)=>{let n=e.tokens||[];if(n.length===1&&n[0].type===`image`)return t.parseChildren([n[0]]);let r=t.parseInline(n);return n.length===1&&n[0].type===`text`&&(n[0].raw===WX||n[0].text===WX||n[0].raw===GX||n[0].text===GX)&&r.length===1&&r[0].type===`text`&&(r[0].text===WX||r[0].text===GX)?t.createNode(`paragraph`,void 0,[]):t.createNode(`paragraph`,void 0,r)},renderMarkdown:(e,t,n)=>{if(!e)return``;let r=Array.isArray(e.content)?e.content:[];if(r.length===0){let e=Array.isArray(n?.previousNode?.content)?n.previousNode.content:[];return n?.previousNode?.type===`paragraph`&&e.length===0?WX:``}return t.renderChildren(r)},addCommands(){return{setParagraph:()=>({commands:e})=>e.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),qX=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,JX=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,YX=_G.create({name:`strike`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`s`},{tag:`del`},{tag:`strike`},{style:`text-decoration`,consuming:!1,getAttrs:e=>e.includes(`line-through`)?{}:!1}]},renderHTML({HTMLAttributes:e}){return[`s`,rW(this.options.HTMLAttributes,e),0]},markdownTokenName:`del`,parseMarkdown:(e,t)=>t.applyMark(`strike`,t.parseInline(e.tokens||[])),renderMarkdown:(e,t)=>`~~${t.renderChildren(e)}~~`,addCommands(){return{setStrike:()=>({commands:e})=>e.setMark(this.name),toggleStrike:()=>({commands:e})=>e.toggleMark(this.name),unsetStrike:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[HG({find:qX,type:this.type})]},addPasteRules(){return[oK({find:JX,type:this.type})]}}),XX=aK.create({name:`text`,group:`inline`,parseMarkdown:e=>({type:`text`,text:e.text||``}),renderMarkdown:e=>e.text||``}),ZX=_G.create({name:`underline`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`u`},{style:`text-decoration`,consuming:!1,getAttrs:e=>e.includes(`underline`)?{}:!1}]},renderHTML({HTMLAttributes:e}){return[`u`,rW(this.options.HTMLAttributes,e),0]},parseMarkdown(e,t){return t.applyMark(this.name||`underline`,t.parseInline(e.tokens||[]))},renderMarkdown(e,t){return`++${t.renderChildren(e)}++`},markdownTokenizer:{name:`underline`,level:`inline`,start(e){return e.indexOf(`++`)},tokenize(e,t,n){let r=/^(\+\+)([\s\S]+?)(\+\+)/.exec(e);if(!r)return;let i=r[2].trim();return{type:`underline`,raw:r[0],text:i,tokens:n.inlineTokens(i)}}},addCommands(){return{setUnderline:()=>({commands:e})=>e.setMark(this.name),toggleUnderline:()=>({commands:e})=>e.toggleMark(this.name),unsetUnderline:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}});function QX(e={}){return new YI({view(t){return new $X(t,e)}})}var $X=class{constructor(e,t){this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=t.width??1,this.color=t.color===!1?void 0:t.color||`black`,this.class=t.class,this.handlers=[`dragover`,`dragend`,`drop`,`dragleave`].map(t=>{let n=e=>{this[t](e)};return e.dom.addEventListener(t,n),{name:t,handler:n}})}destroy(){this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){this.cursorPos!=null&&t.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),t=!e.parent.inlineContent,n,r=this.editorView.dom,i=r.getBoundingClientRect(),a=i.width/r.offsetWidth,o=i.height/r.offsetHeight;if(t){let t=e.nodeBefore,r=e.nodeAfter;if(t||r){let e=this.editorView.nodeDOM(this.cursorPos-(t?t.nodeSize:0));if(e){let i=e.getBoundingClientRect(),a=t?i.bottom:i.top;t&&r&&(a=(a+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let s=this.width/2*o;n={left:i.left,right:i.right,top:a-s,bottom:a+s}}}}if(!n){let e=this.editorView.coordsAtPos(this.cursorPos),t=this.width/2*a;n={left:e.left-t,right:e.left+t,top:e.top,bottom:e.bottom}}let s=this.editorView.dom.offsetParent;this.element||(this.element=s.appendChild(document.createElement(`div`)),this.class&&(this.element.className=this.class),this.element.style.cssText=`position: absolute; z-index: 50; pointer-events: none;`,this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle(`prosemirror-dropcursor-block`,t),this.element.classList.toggle(`prosemirror-dropcursor-inline`,!t);let c,l;if(!s||s==document.body&&getComputedStyle(s).position==`static`)c=-pageXOffset,l=-pageYOffset;else{let e=s.getBoundingClientRect(),t=e.width/s.offsetWidth,n=e.height/s.offsetHeight;c=e.left-s.scrollLeft*t,l=e.top-s.scrollTop*n}this.element.style.left=(n.left-c)/a+`px`,this.element.style.top=(n.top-l)/o+`px`,this.element.style.width=(n.right-n.left)/a+`px`,this.element.style.height=(n.bottom-n.top)/o+`px`}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),n=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),r=n&&n.type.spec.disableDropCursor,i=typeof r==`function`?r(this.editorView,t,e):r;if(t&&!i){let e=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let t=oI(this.editorView.state.doc,e,this.editorView.dragging.slice);t!=null&&(e=t)}this.setCursor(e),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}},eZ=class e extends DI{constructor(e){super(e,e)}map(t,n){let r=t.resolve(n.map(this.head));return e.valid(r)?new e(r):DI.near(r)}content(){return Q.empty}eq(t){return t instanceof e&&t.head==this.head}toJSON(){return{type:`gapcursor`,pos:this.head}}static fromJSON(t,n){if(typeof n.pos!=`number`)throw RangeError(`Invalid input for GapCursor.fromJSON`);return new e(t.resolve(n.pos))}getBookmark(){return new tZ(this.anchor)}static valid(e){let t=e.parent;if(t.inlineContent||!rZ(e)||!iZ(e))return!1;let n=t.type.spec.allowGapCursor;if(n!=null)return n;let r=t.contentMatchAt(e.index()).defaultType;return r&&r.isTextblock}static findGapCursorFrom(t,n,r=!1){search:for(;;){if(!r&&e.valid(t))return t;let i=t.pos,a=null;for(let r=t.depth;;r--){let o=t.node(r);if(n>0?t.indexAfter(r)<o.childCount:t.index(r)>0){a=o.child(n>0?t.indexAfter(r):t.index(r)-1);break}else if(r==0)return null;i+=n;let s=t.doc.resolve(i);if(e.valid(s))return s}for(;;){let o=n>0?a.firstChild:a.lastChild;if(!o){if(a.isAtom&&!a.isText&&!NI.isSelectable(a)){t=t.doc.resolve(i+a.nodeSize*n),r=!1;continue search}break}a=o,i+=n;let s=t.doc.resolve(i);if(e.valid(s))return s}return null}}};eZ.prototype.visible=!1,eZ.findFrom=eZ.findGapCursorFrom,DI.jsonID(`gapcursor`,eZ);var tZ=class e{constructor(e){this.pos=e}map(t){return new e(t.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return eZ.valid(t)?new eZ(t):DI.near(t)}};function nZ(e){return e.isAtom||e.spec.isolating||e.spec.createGapCursor}function rZ(e){for(let t=e.depth;t>=0;t--){let n=e.index(t),r=e.node(t);if(n==0){if(r.type.spec.isolating)return!0;continue}for(let e=r.child(n-1);;e=e.lastChild){if(e.childCount==0&&!e.inlineContent||nZ(e.type))return!0;if(e.inlineContent)return!1}}return!0}function iZ(e){for(let t=e.depth;t>=0;t--){let n=e.indexAfter(t),r=e.node(t);if(n==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let e=r.child(n);;e=e.firstChild){if(e.childCount==0&&!e.inlineContent||nZ(e.type))return!0;if(e.inlineContent)return!1}}return!0}function aZ(){return new YI({props:{decorations:uZ,createSelectionBetween(e,t,n){return t.pos==n.pos&&eZ.valid(n)?new eZ(n):null},handleClick:cZ,handleKeyDown:oZ,handleDOMEvents:{beforeinput:lZ}}})}var oZ=TH({ArrowLeft:sZ(`horiz`,-1),ArrowRight:sZ(`horiz`,1),ArrowUp:sZ(`vert`,-1),ArrowDown:sZ(`vert`,1)});function sZ(e,t){let n=e==`vert`?t>0?`down`:`up`:t>0?`right`:`left`;return function(e,r,i){let a=e.selection,o=t>0?a.$to:a.$from,s=a.empty;if(a instanceof jI){if(!i.endOfTextblock(n)||o.depth==0)return!1;s=!1,o=e.doc.resolve(t>0?o.after():o.before())}let c=eZ.findGapCursorFrom(o,t,s);return c?(r&&r(e.tr.setSelection(new eZ(c))),!0):!1}}function cZ(e,t,n){if(!e||!e.editable)return!1;let r=e.state.doc.resolve(t);if(!eZ.valid(r))return!1;let i=e.posAtCoords({left:n.clientX,top:n.clientY});return i&&i.inside>-1&&NI.isSelectable(e.state.doc.nodeAt(i.inside))?!1:(e.dispatch(e.state.tr.setSelection(new eZ(r))),!0)}function lZ(e,t){if(t.inputType!=`insertCompositionText`||!(e.state.selection instanceof eZ))return!1;let{$from:n}=e.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(e.state.schema.nodes.text);if(!r)return!1;let i=Z.empty;for(let e=r.length-1;e>=0;e--)i=Z.from(r[e].createAndFill(null,i));let a=e.state.tr.replace(n.pos,n.pos,new Q(i,0,0));return a.setSelection(jI.near(a.doc.resolve(n.pos+1))),e.dispatch(a),!1}function uZ(e){if(!(e.selection instanceof eZ))return null;let t=document.createElement(`div`);return t.className=`ProseMirror-gapcursor`,wV.create(e.doc,[xV.widget(e.selection.head,t,{key:`gapcursor`})])}var dZ=200,fZ=function(){};fZ.prototype.append=function(e){return e.length?(e=fZ.from(e),!this.length&&e||e.length<dZ&&this.leafAppend(e)||this.length<dZ&&e.leafPrepend(this)||this.appendInner(e)):this},fZ.prototype.prepend=function(e){return e.length?fZ.from(e).append(this):this},fZ.prototype.appendInner=function(e){return new mZ(this,e)},fZ.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?fZ.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},fZ.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},fZ.prototype.forEach=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length),t<=n?this.forEachInner(e,t,n,0):this.forEachInvertedInner(e,t,n,0)},fZ.prototype.map=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length);var r=[];return this.forEach(function(t,n){return r.push(e(t,n))},t,n),r},fZ.from=function(e){return e instanceof fZ?e:e&&e.length?new pZ(e):fZ.empty};var pZ=function(e){function t(t){e.call(this),this.values=t}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var n={length:{configurable:!0},depth:{configurable:!0}};return t.prototype.flatten=function(){return this.values},t.prototype.sliceInner=function(e,n){return e==0&&n==this.length?this:new t(this.values.slice(e,n))},t.prototype.getInner=function(e){return this.values[e]},t.prototype.forEachInner=function(e,t,n,r){for(var i=t;i<n;i++)if(e(this.values[i],r+i)===!1)return!1},t.prototype.forEachInvertedInner=function(e,t,n,r){for(var i=t-1;i>=n;i--)if(e(this.values[i],r+i)===!1)return!1},t.prototype.leafAppend=function(e){if(this.length+e.length<=dZ)return new t(this.values.concat(e.flatten()))},t.prototype.leafPrepend=function(e){if(this.length+e.length<=dZ)return new t(e.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(t.prototype,n),t}(fZ);fZ.empty=new pZ([]);var mZ=function(e){function t(t,n){e.call(this),this.left=t,this.right=n,this.length=t.length+n.length,this.depth=Math.max(t.depth,n.depth)+1}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},t.prototype.getInner=function(e){return e<this.left.length?this.left.get(e):this.right.get(e-this.left.length)},t.prototype.forEachInner=function(e,t,n,r){var i=this.left.length;if(t<i&&this.left.forEachInner(e,t,Math.min(n,i),r)===!1||n>i&&this.right.forEachInner(e,Math.max(t-i,0),Math.min(this.length,n)-i,r+i)===!1)return!1},t.prototype.forEachInvertedInner=function(e,t,n,r){var i=this.left.length;if(t>i&&this.right.forEachInvertedInner(e,t-i,Math.max(n,i)-i,r+i)===!1||n<i&&this.left.forEachInvertedInner(e,Math.min(t,i),n,r)===!1)return!1},t.prototype.sliceInner=function(e,t){if(e==0&&t==this.length)return this;var n=this.left.length;return t<=n?this.left.slice(e,t):e>=n?this.right.slice(e-n,t-n):this.left.slice(e,n).append(this.right.slice(0,t-n))},t.prototype.leafAppend=function(e){var n=this.right.leafAppend(e);if(n)return new t(this.left,n)},t.prototype.leafPrepend=function(e){var n=this.left.leafPrepend(e);if(n)return new t(n,this.right)},t.prototype.appendInner=function(e){return this.left.depth>=Math.max(this.right.depth,e.depth)+1?new t(this.left,new t(this.right,e)):new t(this,e)},t}(fZ),hZ=500,gZ=class e{constructor(e,t){this.items=e,this.eventCount=t}popEvent(t,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let i,a;n&&(i=this.remapping(r,this.items.length),a=i.maps.length);let o=t.tr,s,c,l=[],u=[];return this.items.forEach((t,n)=>{if(!t.step){i||(i=this.remapping(r,n+1),a=i.maps.length),a--,u.push(t);return}if(i){u.push(new vZ(t.map));let e=t.step.map(i.slice(a)),n;e&&o.maybeStep(e).doc&&(n=o.mapping.maps[o.mapping.maps.length-1],l.push(new vZ(n,void 0,void 0,l.length+u.length))),a--,n&&i.appendMap(n,a)}else o.maybeStep(t.step);if(t.selection)return s=i?t.selection.map(i.slice(a)):t.selection,c=new e(this.items.slice(0,r).append(u.reverse().concat(l)),this.eventCount-1),!1},this.items.length,0),{remaining:c,transform:o,selection:s}}addTransform(t,n,r,i){let a=[],o=this.eventCount,s=this.items,c=!i&&s.length?s.get(s.length-1):null;for(let e=0;e<t.steps.length;e++){let r=t.steps[e].invert(t.docs[e]),l=new vZ(t.mapping.maps[e],r,n),u;(u=c&&c.merge(l))&&(l=u,e?a.pop():s=s.slice(0,s.length-1)),a.push(l),n&&=(o++,void 0),i||(c=l)}let l=o-r.depth;return l>bZ&&(s=_Z(s,l),o-=l),new e(s.append(a),o)}remapping(e,t){let n=new wF;return this.items.forEach((t,r)=>{let i=t.mirrorOffset!=null&&r-t.mirrorOffset>=e?n.maps.length-t.mirrorOffset:void 0;n.appendMap(t.map,i)},e,t),n}addMaps(t){return this.eventCount==0?this:new e(this.items.append(t.map(e=>new vZ(e))),this.eventCount)}rebased(t,n){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-n),a=t.mapping,o=t.steps.length,s=this.eventCount;this.items.forEach(e=>{e.selection&&s--},i);let c=n;this.items.forEach(e=>{let n=a.getMirror(--c);if(n==null)return;o=Math.min(o,n);let i=a.maps[n];if(e.step){let o=t.steps[n].invert(t.docs[n]),l=e.selection&&e.selection.map(a.slice(c+1,n));l&&s++,r.push(new vZ(i,o,l))}else r.push(new vZ(i))},i);let l=[];for(let e=n;e<o;e++)l.push(new vZ(a.maps[e]));let u=new e(this.items.slice(0,i).append(l).append(r),s);return u.emptyItemCount()>hZ&&(u=u.compress(this.items.length-r.length)),u}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(t=this.items.length){let n=this.remapping(0,t),r=n.maps.length,i=[],a=0;return this.items.forEach((e,o)=>{if(o>=t)i.push(e),e.selection&&a++;else if(e.step){let t=e.step.map(n.slice(r)),o=t&&t.getMap();if(r--,o&&n.appendMap(o,r),t){let s=e.selection&&e.selection.map(n.slice(r));s&&a++;let c=new vZ(o.invert(),t,s),l,u=i.length-1;(l=i.length&&i[u].merge(c))?i[u]=l:i.push(c)}}else e.map&&r--},this.items.length,0),new e(fZ.from(i.reverse()),a)}};gZ.empty=new gZ(fZ.empty,0);function _Z(e,t){let n;return e.forEach((e,r)=>{if(e.selection&&t--==0)return n=r,!1}),e.slice(n)}var vZ=class e{constructor(e,t,n,r){this.map=e,this.step=t,this.selection=n,this.mirrorOffset=r}merge(t){if(this.step&&t.step&&!t.selection){let n=t.step.merge(this.step);if(n)return new e(n.getMap().invert(),n,this.selection)}}},yZ=class{constructor(e,t,n,r,i){this.done=e,this.undone=t,this.prevRanges=n,this.prevTime=r,this.prevComposition=i}},bZ=20;function xZ(e,t,n,r){let i=n.getMeta(kZ),a;if(i)return i.historyState;n.getMeta(AZ)&&(e=new yZ(e.done,e.undone,null,0,-1));let o=n.getMeta(`appendedTransaction`);if(n.steps.length==0)return e;if(o&&o.getMeta(kZ))return o.getMeta(kZ).redo?new yZ(e.done.addTransform(n,void 0,r,OZ(t)),e.undone,CZ(n.mapping.maps),e.prevTime,e.prevComposition):new yZ(e.done,e.undone.addTransform(n,void 0,r,OZ(t)),null,e.prevTime,e.prevComposition);if(n.getMeta(`addToHistory`)!==!1&&!(o&&o.getMeta(`addToHistory`)===!1)){let i=n.getMeta(`composition`),a=e.prevTime==0||!o&&e.prevComposition!=i&&(e.prevTime<(n.time||0)-r.newGroupDelay||!SZ(n,e.prevRanges)),s=o?wZ(e.prevRanges,n.mapping):CZ(n.mapping.maps);return new yZ(e.done.addTransform(n,a?t.selection.getBookmark():void 0,r,OZ(t)),gZ.empty,s,n.time,i??e.prevComposition)}else if(a=n.getMeta(`rebased`))return new yZ(e.done.rebased(n,a),e.undone.rebased(n,a),wZ(e.prevRanges,n.mapping),e.prevTime,e.prevComposition);else return new yZ(e.done.addMaps(n.mapping.maps),e.undone.addMaps(n.mapping.maps),wZ(e.prevRanges,n.mapping),e.prevTime,e.prevComposition)}function SZ(e,t){if(!t)return!1;if(!e.docChanged)return!0;let n=!1;return e.mapping.maps[0].forEach((e,r)=>{for(let i=0;i<t.length;i+=2)e<=t[i+1]&&r>=t[i]&&(n=!0)}),n}function CZ(e){let t=[];for(let n=e.length-1;n>=0&&t.length==0;n--)e[n].forEach((e,n,r,i)=>t.push(r,i));return t}function wZ(e,t){if(!e)return null;let n=[];for(let r=0;r<e.length;r+=2){let i=t.map(e[r],1),a=t.map(e[r+1],-1);i<=a&&n.push(i,a)}return n}function TZ(e,t,n){let r=OZ(t),i=kZ.get(t).spec.config,a=(n?e.undone:e.done).popEvent(t,r);if(!a)return null;let o=a.selection.resolve(a.transform.doc),s=(n?e.done:e.undone).addTransform(a.transform,t.selection.getBookmark(),i,r),c=new yZ(n?s:a.remaining,n?a.remaining:s,null,0,-1);return a.transform.setSelection(o).setMeta(kZ,{redo:n,historyState:c})}var EZ=!1,DZ=null;function OZ(e){let t=e.plugins;if(DZ!=t){EZ=!1,DZ=t;for(let e=0;e<t.length;e++)if(t[e].spec.historyPreserveItems){EZ=!0;break}}return EZ}var kZ=new QI(`history`),AZ=new QI(`closeHistory`);function jZ(e={}){return e={depth:e.depth||100,newGroupDelay:e.newGroupDelay||500},new YI({key:kZ,state:{init(){return new yZ(gZ.empty,gZ.empty,null,0,-1)},apply(t,n,r){return xZ(n,r,t,e)}},config:e,props:{handleDOMEvents:{beforeinput(e,t){let n=t.inputType,r=n==`historyUndo`?NZ:n==`historyRedo`?PZ:null;return!r||!e.editable?!1:(t.preventDefault(),r(e.state,e.dispatch))}}}})}function MZ(e,t){return(n,r)=>{let i=kZ.getState(n);if(!i||(e?i.undone:i.done).eventCount==0)return!1;if(r){let a=TZ(i,n,e);a&&r(t?a.scrollIntoView():a)}return!0}}var NZ=MZ(!1,!0),PZ=MZ(!0,!0);EG.create({name:`characterCount`,addOptions(){return{limit:null,mode:`textSize`,textCounter:e=>e.length,wordCounter:e=>e.split(` `).filter(e=>e!==``).length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=e=>{let t=e?.node||this.editor.state.doc;if((e?.mode||this.options.mode)===`textSize`){let e=t.textBetween(0,t.content.size,void 0,` `);return this.options.textCounter(e)}return t.nodeSize},this.storage.words=e=>{let t=e?.node||this.editor.state.doc,n=t.textBetween(0,t.content.size,` `,` `);return this.options.wordCounter(n)}},addProseMirrorPlugins(){let e=!1;return[new YI({key:new QI(`characterCount`),appendTransaction:(t,n,r)=>{if(e)return;let i=this.options.limit;if(i==null||i===0){e=!0;return}let a=this.storage.characters({node:r.doc});if(a>i){let t=a-i;console.warn(`[CharacterCount] Initial content exceeded limit of ${i} characters. Content was automatically trimmed.`);let n=r.tr.deleteRange(0,t);return e=!0,n}e=!0},filterTransaction:(e,t)=>{let n=this.options.limit;if(!e.docChanged||n===0||n==null)return!0;let r=this.storage.characters({node:t.doc}),i=this.storage.characters({node:e.doc});if(i<=n||r>n&&i>n&&i<=r)return!0;if(r>n&&i>n&&i>r||!e.getMeta(`paste`))return!1;let a=e.selection.$head.pos,o=a-(i-n),s=a;return e.deleteRange(o,s),!(this.storage.characters({node:e.doc})>n)}})]}});var FZ=EG.create({name:`dropCursor`,addOptions(){return{color:`currentColor`,width:1,class:void 0}},addProseMirrorPlugins(){return[QX(this.options)]}});EG.create({name:`focus`,addOptions(){return{className:`has-focus`,mode:`all`}},addProseMirrorPlugins(){return[new YI({key:new QI(`focus`),props:{decorations:({doc:e,selection:t})=>{let{isEditable:n,isFocused:r}=this.editor,{anchor:i}=t,a=[];if(!n||!r)return wV.create(e,[]);let o=0;this.options.mode===`deepest`&&e.descendants((e,t)=>{if(!e.isText){if(!(i>=t&&i<=t+e.nodeSize-1))return!1;o+=1}});let s=0;return e.descendants((e,t)=>{if(e.isText||!(i>=t&&i<=t+e.nodeSize-1))return!1;if(s+=1,this.options.mode===`deepest`&&o-s>0||this.options.mode===`shallowest`&&s>1)return this.options.mode===`deepest`;a.push(xV.node(t,t+e.nodeSize,{class:this.options.className}))}),wV.create(e,a)}}})]}});var IZ=EG.create({name:`gapCursor`,addProseMirrorPlugins(){return[aZ()]},extendNodeSchema(e){return{allowGapCursor:ZU(qU(e,`allowGapCursor`,{name:e.name,options:e.options,storage:e.storage}))??null}}}),LZ=`placeholder`;function RZ(e){return e.replace(/\s+/g,`-`).replace(/[^a-zA-Z0-9-]/g,``).replace(/^[0-9-]+/,``).replace(/^-+/,``).toLowerCase()}EG.create({name:`placeholder`,addOptions(){return{emptyEditorClass:`is-editor-empty`,emptyNodeClass:`is-empty`,dataAttribute:LZ,placeholder:`Write something …`,showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){let e=this.options.dataAttribute?`data-${RZ(this.options.dataAttribute)}`:`data-${LZ}`;return[new YI({key:new QI(`placeholder`),props:{decorations:({doc:t,selection:n})=>{let r=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:i}=n,a=[];if(!r)return null;let o=this.editor.isEmpty;return t.descendants((t,n)=>{let r=i>=n&&i<=n+t.nodeSize,s=!t.isLeaf&&MW(t);if(!t.type.isTextblock)return this.options.includeChildren;if((r||!this.options.showOnlyCurrent)&&s){let i=[this.options.emptyNodeClass];o&&i.push(this.options.emptyEditorClass);let s=xV.node(n,n+t.nodeSize,{class:i.join(` `),[e]:typeof this.options.placeholder==`function`?this.options.placeholder({editor:this.editor,node:t,pos:n,hasAnchor:r}):this.options.placeholder});a.push(s)}return this.options.includeChildren}),wV.create(t,a)}}})]}}),EG.create({name:`selection`,addOptions(){return{className:`selection`}},addProseMirrorPlugins(){let{editor:e,options:t}=this;return[new YI({key:new QI(`selection`),props:{decorations(n){return n.selection.empty||e.isFocused||!e.isEditable||NW(n.selection)||e.view.dragging?null:wV.create(n.doc,[xV.inline(n.selection.from,n.selection.to,{class:t.className})])}}})]}});function zZ({types:e,node:t}){return t&&Array.isArray(e)&&e.includes(t.type)||t?.type===e}var BZ=EG.create({name:`trailingNode`,addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){let e=new QI(this.name),t=this.options.node||this.editor.schema.topNodeType.contentMatch.defaultType?.name||`paragraph`,n=Object.entries(this.editor.schema.nodes).map(([,e])=>e).filter(e=>(this.options.notAfter||[]).concat(t).includes(e.name));return[new YI({key:e,appendTransaction:(n,r,i)=>{let{doc:a,tr:o,schema:s}=i,c=e.getState(i),l=a.content.size,u=s.nodes[t];if(!n.some(e=>e.getMeta(`skipTrailingNode`))&&c)return o.insert(l,u.create())},state:{init:(e,t)=>{let r=t.tr.doc.lastChild;return!zZ({node:r,types:n})},apply:(e,t)=>{if(!e.docChanged||e.getMeta(`__uniqueIDTransaction`))return t;let r=e.doc.lastChild;return!zZ({node:r,types:n})}}})]}}),VZ=EG.create({name:`undoRedo`,addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:e,dispatch:t})=>NZ(e,t),redo:()=>({state:e,dispatch:t})=>PZ(e,t)}},addProseMirrorPlugins(){return[jZ(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}),HZ=EG.create({name:`starterKit`,addExtensions(){let e=[];return this.options.bold!==!1&&e.push(Pq.configure(this.options.bold)),this.options.blockquote!==!1&&e.push(kq.configure(this.options.blockquote)),this.options.bulletList!==!1&&e.push(_X.configure(this.options.bulletList)),this.options.code!==!1&&e.push(Lq.configure(this.options.code)),this.options.codeBlock!==!1&&e.push(Vq.configure(this.options.codeBlock)),this.options.document!==!1&&e.push(Hq.configure(this.options.document)),this.options.dropcursor!==!1&&e.push(FZ.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&e.push(IZ.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&e.push(Uq.configure(this.options.hardBreak)),this.options.heading!==!1&&e.push(Wq.configure(this.options.heading)),this.options.undoRedo!==!1&&e.push(VZ.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&e.push(Gq.configure(this.options.horizontalRule)),this.options.italic!==!1&&e.push(Xq.configure(this.options.italic)),this.options.listItem!==!1&&e.push(vX.configure(this.options.listItem)),this.options.listKeymap!==!1&&e.push(kX.configure(this.options?.listKeymap)),this.options.link!==!1&&e.push(dX.configure(this.options?.link)),this.options.orderedList!==!1&&e.push(BX.configure(this.options.orderedList)),this.options.paragraph!==!1&&e.push(KX.configure(this.options.paragraph)),this.options.strike!==!1&&e.push(YX.configure(this.options.strike)),this.options.text!==!1&&e.push(XX.configure(this.options.text)),this.options.underline!==!1&&e.push(ZX.configure(this.options?.underline)),this.options.trailingNode!==!1&&e.push(BZ.configure(this.options?.trailingNode)),e}}),UZ=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,WZ=aK.create({name:`image`,addOptions(){return{inline:!1,allowBase64:!1,HTMLAttributes:{},resize:!1}},inline(){return this.options.inline},group(){return this.options.inline?`inline`:`block`},draggable:!0,addAttributes(){return{src:{default:null},alt:{default:null},title:{default:null},width:{default:null},height:{default:null}}},parseHTML(){return[{tag:this.options.allowBase64?`img[src]`:`img[src]:not([src^="data:"])`}]},renderHTML({HTMLAttributes:e}){return[`img`,rW(this.options.HTMLAttributes,e)]},parseMarkdown:(e,t)=>t.createNode(`image`,{src:e.href,title:e.title,alt:e.text}),renderMarkdown:e=>{let t=e.attrs?.src??``,n=e.attrs?.alt??``,r=e.attrs?.title??``;return r?`![${n}](${t} "${r}")`:`![${n}](${t})`},addNodeView(){if(!this.options.resize||!this.options.resize.enabled||typeof document>`u`)return null;let{directions:e,minWidth:t,minHeight:n,alwaysPreserveAspectRatio:r}=this.options.resize;return({node:i,getPos:a,HTMLAttributes:o,editor:s})=>{let c=document.createElement(`img`);Object.entries(o).forEach(([e,t])=>{if(t!=null)switch(e){case`width`:case`height`:break;default:c.setAttribute(e,t);break}}),c.src=o.src;let l=new qG({element:c,editor:s,node:i,getPos:a,onResize:(e,t)=>{c.style.width=`${e}px`,c.style.height=`${t}px`},onCommit:(e,t)=>{let n=a();n!==void 0&&this.editor.chain().setNodeSelection(n).updateAttributes(this.name,{width:e,height:t}).run()},onUpdate:(e,t,n)=>e.type===i.type,options:{directions:e,min:{width:t,height:n},preserveAspectRatio:r===!0}}),u=l.dom;return u.style.visibility=`hidden`,u.style.pointerEvents=`none`,c.onload=()=>{u.style.visibility=``,u.style.pointerEvents=``},l}},addCommands(){return{setImage:e=>({commands:t})=>t.insertContent({type:this.name,attrs:e})}},addInputRules(){return[UG({find:UZ,type:this.type,getAttributes:e=>{let[,,t,n,r]=e;return{src:n,alt:t,title:r}}})]}});function GZ({onClick:e,active:t,disabled:n,title:r,children:i}){return(0,U.jsx)(`button`,{type:`button`,title:r,disabled:n,onMouseDown:t=>{t.preventDefault(),e()},className:q(`flex size-7 items-center justify-center rounded transition-colors`,t?`bg-foreground text-background`:`text-muted-foreground hover:bg-accent hover:text-accent-foreground`,n&&`pointer-events-none opacity-40`),children:i})}function KZ(){return(0,U.jsx)(`div`,{className:`mx-0.5 h-4 w-px bg-border`})}function qZ({value:e,onChange:t,placeholder:n,onInsertImage:r}){let[i,a]=(0,v.useState)(!e),o=yq({extensions:[HZ.configure({link:{openOnClick:!1,HTMLAttributes:{class:`text-primary underline`}}}),WZ.extend({addAttributes(){return{...this.parent?.(),width:{default:null},height:{default:null}}}}).configure({HTMLAttributes:{class:`max-w-full rounded`}})],content:(()=>{if(!e)return``;try{return JSON.parse(e)}catch{return e}})(),editorProps:{attributes:{class:`h-128 px-3 py-2.5 focus:outline-none`}},onUpdate({editor:e}){a(e.isEmpty),t(JSON.stringify(e.getJSON()))}});(0,v.useEffect)(()=>{if(!o)return;let t=e?(()=>{try{return JSON.parse(e)}catch{return e}})():``;JSON.stringify(o.getJSON())!==e&&o.commands.setContent(t,{emitUpdate:!1}),a(o.isEmpty)},[e]);async function s(){if(!o||!r)return;let e=await r();e&&o.chain().focus().setImage({src:e.src,alt:e.alt??void 0,width:e.width??void 0,height:e.height??void 0}).run()}function c(){if(!o)return;let e=o.getAttributes(`link`).href,t=window.prompt(`URL`,e??`https://`);if(t!==null){if(!t){o.chain().focus().unsetLink().run();return}o.chain().focus().setLink({href:t}).run()}}return o?(0,U.jsxs)(`div`,{className:`overflow-hidden rounded-md border border-input bg-background focus-within:border-ring focus-within:ring-[3px] focus-within:ring-ring/50`,children:[(0,U.jsxs)(`div`,{className:`sticky top-0 z-10 flex flex-wrap items-center gap-0.5 border-b border-border bg-background px-2 py-1.5`,children:[(0,U.jsx)(GZ,{title:`Bold`,active:o.isActive(`bold`),onClick:()=>o.chain().focus().toggleBold().run(),children:(0,U.jsx)(Fa,{className:`size-3.5`})}),(0,U.jsx)(GZ,{title:`Italic`,active:o.isActive(`italic`),onClick:()=>o.chain().focus().toggleItalic().run(),children:(0,U.jsx)(yo,{className:`size-3.5`})}),(0,U.jsx)(GZ,{title:`Underline`,active:o.isActive(`underline`),onClick:()=>o.chain().focus().toggleUnderline().run(),children:(0,U.jsx)(Xo,{className:`size-3.5`})}),(0,U.jsx)(GZ,{title:`Strikethrough`,active:o.isActive(`strike`),onClick:()=>o.chain().focus().toggleStrike().run(),children:(0,U.jsx)(Uo,{className:`size-3.5`})}),(0,U.jsx)(KZ,{}),(0,U.jsx)(GZ,{title:`Heading 1`,active:o.isActive(`heading`,{level:1}),onClick:()=>o.chain().focus().toggleHeading({level:1}).run(),children:(0,U.jsx)(po,{className:`size-3.5`})}),(0,U.jsx)(GZ,{title:`Heading 2`,active:o.isActive(`heading`,{level:2}),onClick:()=>o.chain().focus().toggleHeading({level:2}).run(),children:(0,U.jsx)(mo,{className:`size-3.5`})}),(0,U.jsx)(GZ,{title:`Heading 3`,active:o.isActive(`heading`,{level:3}),onClick:()=>o.chain().focus().toggleHeading({level:3}).run(),children:(0,U.jsx)(ho,{className:`size-3.5`})}),(0,U.jsx)(KZ,{}),(0,U.jsx)(GZ,{title:`Bullet list`,active:o.isActive(`bulletList`),onClick:()=>o.chain().focus().toggleBulletList().run(),children:(0,U.jsx)(Oo,{className:`size-3.5`})}),(0,U.jsx)(GZ,{title:`Ordered list`,active:o.isActive(`orderedList`),onClick:()=>o.chain().focus().toggleOrderedList().run(),children:(0,U.jsx)(Eo,{className:`size-3.5`})}),(0,U.jsx)(KZ,{}),(0,U.jsx)(GZ,{title:`Blockquote`,active:o.isActive(`blockquote`),onClick:()=>o.chain().focus().toggleBlockquote().run(),children:(0,U.jsx)(Fo,{className:`size-3.5`})}),(0,U.jsx)(GZ,{title:`Inline code`,active:o.isActive(`code`),onClick:()=>o.chain().focus().toggleCode().run(),children:(0,U.jsx)(Ya,{className:`size-3.5`})}),(0,U.jsx)(GZ,{title:`Code block`,active:o.isActive(`codeBlock`),onClick:()=>o.chain().focus().toggleCodeBlock().run(),children:(0,U.jsx)(Vo,{className:`size-3.5`})}),(0,U.jsx)(KZ,{}),(0,U.jsx)(GZ,{title:`Add link`,active:o.isActive(`link`),onClick:c,children:(0,U.jsx)(To,{className:`size-3.5`})}),(0,U.jsx)(GZ,{title:`Remove link`,disabled:!o.isActive(`link`),onClick:()=>o.chain().focus().unsetLink().run(),children:(0,U.jsx)(Zo,{className:`size-3.5`})}),(0,U.jsx)(KZ,{}),r&&(0,U.jsx)(GZ,{title:`Insert image`,onClick:s,children:(0,U.jsx)(_o,{className:`size-3.5`})}),(0,U.jsx)(GZ,{title:`Hard break (Shift + Enter)`,onClick:()=>o.chain().focus().setHardBreak().run(),children:(0,U.jsx)(Go,{className:`size-3.5`})})]}),(0,U.jsxs)(`div`,{className:`relative overflow-y-auto`,children:[i&&n&&(0,U.jsx)(`p`,{className:`pointer-events-none absolute left-3 top-2.5 text-muted-foreground select-none`,children:n}),(0,U.jsx)(dq,{editor:o})]})]}):null}function JZ(e){return{...e}}function YZ(e){return e.type.startsWith(`image/`)?new Promise(t=>{let n=new Image,r=URL.createObjectURL(e);n.onload=()=>{URL.revokeObjectURL(r),t({width:n.naturalWidth,height:n.naturalHeight})},n.onerror=()=>{URL.revokeObjectURL(r),t(null)},n.src=r}):Promise.resolve(null)}async function XZ(e,t){let n=await YZ(e),r=await fetch(`/cms/admin/media/presign`,{method:`POST`,credentials:`include`,headers:JZ({"Content-Type":`application/json`}),body:JSON.stringify({filename:e.name,mimeType:e.type,folderId:t?.folderId??null})});if(!r.ok)throw Error(`Upload failed.`);let i=await r.json();if(i.mode===`presigned`){if(!(await fetch(i.uploadUrl,{method:`PUT`,body:e,headers:{"Content-Type":e.type}})).ok)throw Error(`Upload failed.`);let r=await fetch(`/cms/admin/media/confirm`,{method:`POST`,credentials:`include`,headers:JZ({"Content-Type":`application/json`}),body:JSON.stringify({key:i.key,filename:e.name,mimeType:e.type,size:e.size,folderId:t?.folderId??null,width:n?.width??null,height:n?.height??null})});if(!r.ok)throw Error(`Upload failed.`);return r.json()}let a=new FormData;a.append(`files`,e,e.name),t?.folderId&&a.append(`folder_id`,t.folderId),n?.width&&a.append(`width`,String(n.width)),n?.height&&a.append(`height`,String(n.height));let o=await fetch(`/cms/admin/media`,{method:`POST`,credentials:`include`,headers:JZ(),body:a});if(!o.ok)throw Error(`Upload failed.`);return o.json()}async function ZZ(e){let t=await fetch(`/cms/admin/users/me/avatar/presign`,{method:`POST`,credentials:`include`,headers:JZ({"Content-Type":`application/json`}),body:JSON.stringify({filename:e.name,mimeType:e.type})});if(!t.ok)throw Error(`Upload failed.`);let n=await t.json();if(n.mode===`presigned`){if(!(await fetch(n.uploadUrl,{method:`PUT`,body:e,headers:{"Content-Type":e.type}})).ok)throw Error(`Upload failed.`);let t=await fetch(`/cms/admin/users/me/avatar/confirm`,{method:`POST`,credentials:`include`,headers:JZ({"Content-Type":`application/json`}),body:JSON.stringify({key:n.key})});if(!t.ok)throw Error(`Upload failed.`);return(await t.json()).avatarUrl}let r=new FormData;r.append(`file`,e);let i=await fetch(`/cms/admin/users/me/avatar`,{method:`POST`,credentials:`include`,headers:JZ(),body:r});if(!i.ok)throw Error(`Upload failed.`);return(await i.json()).avatarUrl}var QZ=1,$Z=.9,eQ=.8,tQ=.17,nQ=.1,rQ=.999,iQ=.9999,aQ=.99,oQ=/[\\\/_+.#"@\[\(\{&]/,sQ=/[\\\/_+.#"@\[\(\{&]/g,cQ=/[\s-]/,lQ=/[\s-]/g;function uQ(e,t,n,r,i,a,o){if(a===t.length)return i===e.length?QZ:aQ;var s=`${i},${a}`;if(o[s]!==void 0)return o[s];for(var c=r.charAt(a),l=n.indexOf(c,i),u=0,d,f,p,m;l>=0;)d=uQ(e,t,n,r,l+1,a+1,o),d>u&&(l===i?d*=QZ:oQ.test(e.charAt(l-1))?(d*=eQ,p=e.slice(i,l-1).match(sQ),p&&i>0&&(d*=rQ**+p.length)):cQ.test(e.charAt(l-1))?(d*=$Z,m=e.slice(i,l-1).match(lQ),m&&i>0&&(d*=rQ**+m.length)):(d*=tQ,i>0&&(d*=rQ**+(l-i))),e.charAt(l)!==t.charAt(a)&&(d*=iQ)),(d<nQ&&n.charAt(l-1)===r.charAt(a+1)||r.charAt(a+1)===r.charAt(a)&&n.charAt(l-1)!==r.charAt(a))&&(f=uQ(e,t,n,r,l+1,a+2,o),f*nQ>d&&(d=f*nQ)),d>u&&(u=d),l=n.indexOf(c,l+1);return o[s]=u,u}function dQ(e){return e.toLowerCase().replace(lQ,` `)}function fQ(e,t,n){return e=n&&n.length>0?`${e+` `+n.join(` `)}`:e,uQ(e,t,dQ(e),dQ(t),0,0,{})}var pQ=`[cmdk-group=""]`,mQ=`[cmdk-group-items=""]`,hQ=`[cmdk-group-heading=""]`,gQ=`[cmdk-item=""]`,_Q=`${gQ}:not([aria-disabled="true"])`,vQ=`cmdk-item-select`,yQ=`data-value`,bQ=(e,t,n)=>fQ(e,t,n),xQ=v.createContext(void 0),SQ=()=>v.useContext(xQ),CQ=v.createContext(void 0),wQ=()=>v.useContext(CQ),TQ=v.createContext(void 0),EQ=v.forwardRef((e,t)=>{let n=BQ(()=>({search:``,value:e.value??e.defaultValue??``,selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}})),r=BQ(()=>new Set),i=BQ(()=>new Map),a=BQ(()=>new Map),o=BQ(()=>new Set),s=RQ(e),{label:c,children:l,value:u,onValueChange:d,filter:f,shouldFilter:p,loop:m,disablePointerSelection:h=!1,vimBindings:g=!0,..._}=e,y=Ou(),b=Ou(),x=Ou(),S=v.useRef(null),C=UQ();zQ(()=>{if(u!==void 0){let e=u.trim();n.current.value=e,w.emit()}},[u]),zQ(()=>{C(6,A)},[]);let w=v.useMemo(()=>({subscribe:e=>(o.current.add(e),()=>o.current.delete(e)),snapshot:()=>n.current,setState:(e,t,r)=>{var i,a,o;if(!Object.is(n.current[e],t)){if(n.current[e]=t,e===`search`)k(),D(),C(1,O);else if(e===`value`){if(document.activeElement.hasAttribute(`cmdk-input`)||document.activeElement.hasAttribute(`cmdk-root`)){let e=document.getElementById(x);e?e.focus():(i=document.getElementById(y))==null||i.focus()}if(C(7,()=>{n.current.selectedItemId=j()?.id,w.emit()}),r||C(5,A),s.current?.value!==void 0){let e=t??``;(o=(a=s.current).onValueChange)==null||o.call(a,e);return}}w.emit()}},emit:()=>{o.current.forEach(e=>e())}}),[]),T=v.useMemo(()=>({value:(e,t,r)=>{t!==a.current.get(e)?.value&&(a.current.set(e,{value:t,keywords:r}),n.current.filtered.items.set(e,E(t,r)),C(2,()=>{D(),w.emit()}))},item:(e,t)=>(r.current.add(e),t&&(i.current.has(t)?i.current.get(t).add(e):i.current.set(t,new Set([e]))),C(3,()=>{k(),D(),n.current.value||O(),w.emit()}),()=>{a.current.delete(e),r.current.delete(e),n.current.filtered.items.delete(e);let t=j();C(4,()=>{k(),t?.getAttribute(`id`)===e&&O(),w.emit()})}),group:e=>(i.current.has(e)||i.current.set(e,new Set),()=>{a.current.delete(e),i.current.delete(e)}),filter:()=>s.current.shouldFilter,label:c||e[`aria-label`],getDisablePointerSelection:()=>s.current.disablePointerSelection,listId:y,inputId:x,labelId:b,listInnerRef:S}),[]);function E(e,t){let r=s.current?.filter??bQ;return e?r(e,n.current.search,t):0}function D(){if(!n.current.search||s.current.shouldFilter===!1)return;let e=n.current.filtered.items,t=[];n.current.filtered.groups.forEach(n=>{let r=i.current.get(n),a=0;r.forEach(t=>{let n=e.get(t);a=Math.max(n,a)}),t.push([n,a])});let r=S.current;M().sort((t,n)=>{let r=t.getAttribute(`id`),i=n.getAttribute(`id`);return(e.get(i)??0)-(e.get(r)??0)}).forEach(e=>{let t=e.closest(mQ);t?t.appendChild(e.parentElement===t?e:e.closest(`${mQ} > *`)):r.appendChild(e.parentElement===r?e:e.closest(`${mQ} > *`))}),t.sort((e,t)=>t[1]-e[1]).forEach(e=>{let t=S.current?.querySelector(`${pQ}[${yQ}="${encodeURIComponent(e[0])}"]`);t?.parentElement.appendChild(t)})}function O(){let e=M().find(e=>e.getAttribute(`aria-disabled`)!==`true`)?.getAttribute(yQ);w.setState(`value`,e||void 0)}function k(){if(!n.current.search||s.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let e=0;for(let t of r.current){let r=E(a.current.get(t)?.value??``,a.current.get(t)?.keywords??[]);n.current.filtered.items.set(t,r),r>0&&e++}for(let[e,t]of i.current)for(let r of t)if(n.current.filtered.items.get(r)>0){n.current.filtered.groups.add(e);break}n.current.filtered.count=e}function A(){var e;let t=j();t&&(t.parentElement?.firstChild===t&&((e=t.closest(pQ)?.querySelector(hQ))==null||e.scrollIntoView({block:`nearest`})),t.scrollIntoView({block:`nearest`}))}function j(){return S.current?.querySelector(`${gQ}[aria-selected="true"]`)}function M(){return Array.from(S.current?.querySelectorAll(_Q)||[])}function N(e){let t=M()[e];t&&w.setState(`value`,t.getAttribute(yQ))}function P(e){var t;let n=j(),r=M(),i=r.findIndex(e=>e===n),a=r[i+e];(t=s.current)!=null&&t.loop&&(a=i+e<0?r[r.length-1]:i+e===r.length?r[0]:r[i+e]),a&&w.setState(`value`,a.getAttribute(yQ))}function F(e){let t=j()?.closest(pQ),n;for(;t&&!n;)t=e>0?IQ(t,pQ):LQ(t,pQ),n=t?.querySelector(_Q);n?w.setState(`value`,n.getAttribute(yQ)):P(e)}let I=()=>N(M().length-1),L=e=>{e.preventDefault(),e.metaKey?I():e.altKey?F(1):P(1)},R=e=>{e.preventDefault(),e.metaKey?N(0):e.altKey?F(-1):P(-1)};return v.createElement(tl.div,{ref:t,tabIndex:-1,..._,"cmdk-root":``,onKeyDown:e=>{var t;(t=_.onKeyDown)==null||t.call(_,e);let n=e.nativeEvent.isComposing||e.keyCode===229;if(!(e.defaultPrevented||n))switch(e.key){case`n`:case`j`:g&&e.ctrlKey&&L(e);break;case`ArrowDown`:L(e);break;case`p`:case`k`:g&&e.ctrlKey&&R(e);break;case`ArrowUp`:R(e);break;case`Home`:e.preventDefault(),N(0);break;case`End`:e.preventDefault(),I();break;case`Enter`:{e.preventDefault();let t=j();if(t){let e=new Event(vQ);t.dispatchEvent(e)}}}}},v.createElement(`label`,{"cmdk-label":``,htmlFor:T.inputId,id:T.labelId,style:KQ},c),GQ(e,e=>v.createElement(CQ.Provider,{value:w},v.createElement(xQ.Provider,{value:T},e))))}),DQ=v.forwardRef((e,t)=>{let n=Ou(),r=v.useRef(null),i=v.useContext(TQ),a=SQ(),o=RQ(e),s=o.current?.forceMount??i?.forceMount;zQ(()=>{if(!s)return a.item(n,i?.id)},[s]);let c=HQ(n,r,[e.value,e.children,r],e.keywords),l=wQ(),u=VQ(e=>e.value&&e.value===c.current),d=VQ(e=>s||a.filter()===!1?!0:e.search?e.filtered.items.get(n)>0:!0);v.useEffect(()=>{let t=r.current;if(!(!t||e.disabled))return t.addEventListener(vQ,f),()=>t.removeEventListener(vQ,f)},[d,e.onSelect,e.disabled]);function f(){var e,t;p(),(t=(e=o.current).onSelect)==null||t.call(e,c.current)}function p(){l.setState(`value`,c.current,!0)}if(!d)return null;let{disabled:m,value:h,onSelect:g,forceMount:_,keywords:y,...b}=e;return v.createElement(tl.div,{ref:cs(r,t),...b,id:n,"cmdk-item":``,role:`option`,"aria-disabled":!!m,"aria-selected":!!u,"data-disabled":!!m,"data-selected":!!u,onPointerMove:m||a.getDisablePointerSelection()?void 0:p,onClick:m?void 0:f},e.children)}),OQ=v.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:i,...a}=e,o=Ou(),s=v.useRef(null),c=v.useRef(null),l=Ou(),u=SQ(),d=VQ(e=>i||u.filter()===!1?!0:e.search?e.filtered.groups.has(o):!0);zQ(()=>u.group(o),[]),HQ(o,s,[e.value,e.heading,c]);let f=v.useMemo(()=>({id:o,forceMount:i}),[i]);return v.createElement(tl.div,{ref:cs(s,t),...a,"cmdk-group":``,role:`presentation`,hidden:d?void 0:!0},n&&v.createElement(`div`,{ref:c,"cmdk-group-heading":``,"aria-hidden":!0,id:l},n),GQ(e,e=>v.createElement(`div`,{"cmdk-group-items":``,role:`group`,"aria-labelledby":n?l:void 0},v.createElement(TQ.Provider,{value:f},e))))}),kQ=v.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,i=v.useRef(null),a=VQ(e=>!e.search);return!n&&!a?null:v.createElement(tl.div,{ref:cs(i,t),...r,"cmdk-separator":``,role:`separator`})}),AQ=v.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,i=e.value!=null,a=wQ(),o=VQ(e=>e.search),s=VQ(e=>e.selectedItemId),c=SQ();return v.useEffect(()=>{e.value!=null&&a.setState(`search`,e.value)},[e.value]),v.createElement(tl.input,{ref:t,...r,"cmdk-input":``,autoComplete:`off`,autoCorrect:`off`,spellCheck:!1,"aria-autocomplete":`list`,role:`combobox`,"aria-expanded":!0,"aria-controls":c.listId,"aria-labelledby":c.labelId,"aria-activedescendant":s,id:c.inputId,type:`text`,value:i?e.value:o,onChange:e=>{i||a.setState(`search`,e.target.value),n?.(e.target.value)}})}),jQ=v.forwardRef((e,t)=>{let{children:n,label:r=`Suggestions`,...i}=e,a=v.useRef(null),o=v.useRef(null),s=VQ(e=>e.selectedItemId),c=SQ();return v.useEffect(()=>{if(o.current&&a.current){let e=o.current,t=a.current,n,r=new ResizeObserver(()=>{n=requestAnimationFrame(()=>{let n=e.offsetHeight;t.style.setProperty(`--cmdk-list-height`,n.toFixed(1)+`px`)})});return r.observe(e),()=>{cancelAnimationFrame(n),r.unobserve(e)}}},[]),v.createElement(tl.div,{ref:cs(a,t),...i,"cmdk-list":``,role:`listbox`,tabIndex:-1,"aria-activedescendant":s,"aria-label":r,id:c.listId},GQ(e,e=>v.createElement(`div`,{ref:cs(o,c.listInnerRef),"cmdk-list-sizer":``},e)))}),MQ=v.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:i,contentClassName:a,container:o,...s}=e;return v.createElement(ix,{open:n,onOpenChange:r},v.createElement(ax,{container:o},v.createElement(ox,{"cmdk-overlay":``,className:i}),v.createElement(sx,{"aria-label":e.label,"cmdk-dialog":``,className:a},v.createElement(EQ,{ref:t,...s}))))}),NQ=v.forwardRef((e,t)=>VQ(e=>e.filtered.count===0)?v.createElement(tl.div,{ref:t,...e,"cmdk-empty":``,role:`presentation`}):null),PQ=v.forwardRef((e,t)=>{let{progress:n,children:r,label:i=`Loading...`,...a}=e;return v.createElement(tl.div,{ref:t,...a,"cmdk-loading":``,role:`progressbar`,"aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":i},GQ(e,e=>v.createElement(`div`,{"aria-hidden":!0},e)))}),FQ=Object.assign(EQ,{List:jQ,Item:DQ,Input:AQ,Group:OQ,Separator:kQ,Dialog:MQ,Empty:NQ,Loading:PQ});function IQ(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function LQ(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function RQ(e){let t=v.useRef(e);return zQ(()=>{t.current=e}),t}var zQ=typeof window>`u`?v.useEffect:v.useLayoutEffect;function BQ(e){let t=v.useRef();return t.current===void 0&&(t.current=e()),t}function VQ(e){let t=wQ(),n=()=>e(t.snapshot());return v.useSyncExternalStore(t.subscribe,n,n)}function HQ(e,t,n,r=[]){let i=v.useRef(),a=SQ();return zQ(()=>{var o;let s=(()=>{for(let e of n){if(typeof e==`string`)return e.trim();if(typeof e==`object`&&`current`in e)return e.current?e.current.textContent?.trim():i.current}})(),c=r.map(e=>e.trim());a.value(e,s,c),(o=t.current)==null||o.setAttribute(yQ,s),i.current=s}),i}var UQ=()=>{let[e,t]=v.useState(),n=BQ(()=>new Map);return zQ(()=>{n.current.forEach(e=>e()),n.current=new Map},[e]),(e,r)=>{n.current.set(e,r),t({})}};function WQ(e){let t=e.type;return typeof t==`function`?t(e.props):`render`in t?t.render(e.props):e}function GQ({asChild:e,children:t},n){return e&&v.isValidElement(t)?v.cloneElement(WQ(t),{ref:t.ref},n(t.props.children)):n(t)}var KQ={position:`absolute`,width:`1px`,height:`1px`,padding:`0`,margin:`-1px`,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,borderWidth:`0`},qQ=v.forwardRef(({className:e,...t},n)=>(0,U.jsx)(FQ,{ref:n,className:q(`flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground`,e),...t}));qQ.displayName=FQ.displayName;var JQ=v.forwardRef(({className:e,...t},n)=>(0,U.jsxs)(`div`,{className:`flex items-center border-b px-3`,"cmdk-input-wrapper":``,children:[(0,U.jsx)(Ro,{className:`mr-2 h-4 w-4 shrink-0 opacity-50`}),(0,U.jsx)(FQ.Input,{ref:n,className:q(`flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50`,e),...t})]}));JQ.displayName=FQ.Input.displayName;var YQ=v.forwardRef(({className:e,...t},n)=>(0,U.jsx)(FQ.List,{ref:n,className:q(`max-h-[300px] overflow-y-auto overflow-x-hidden`,e),...t}));YQ.displayName=FQ.List.displayName;var XQ=v.forwardRef((e,t)=>(0,U.jsx)(FQ.Empty,{ref:t,className:`py-6 text-center text-sm`,...e}));XQ.displayName=FQ.Empty.displayName;var ZQ=v.forwardRef(({className:e,...t},n)=>(0,U.jsx)(FQ.Group,{ref:n,className:q(`overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground`,e),...t}));ZQ.displayName=FQ.Group.displayName;var QQ=v.forwardRef(({className:e,...t},n)=>(0,U.jsx)(FQ.Separator,{ref:n,className:q(`-mx-1 h-px bg-border`,e),...t}));QQ.displayName=FQ.Separator.displayName;var $Q=v.forwardRef(({className:e,...t},n)=>(0,U.jsx)(FQ.Item,{ref:n,className:q(`relative flex cursor-default gap-2 select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected='true']:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0`,e),...t}));$Q.displayName=FQ.Item.displayName;var e$=({className:e,...t})=>(0,U.jsx)(`span`,{className:q(`ml-auto text-xs tracking-widest text-muted-foreground`,e),...t});e$.displayName=`CommandShortcut`;var t$={image:`image/*`,video:`video/*`,audio:`audio/*`,document:`.pdf,.doc,.docx,.xls,.xlsx,.ppt,.pptx,.txt,.csv`};function n$(e){return!e||e.length===0?`*/*`:e.map(e=>t$[e]).join(`,`)}function r$(e){let t=e.replace(/_/g,` `).trim();return t?t.charAt(0).toUpperCase()+t.slice(1):`Value`}function i$(e){return e?e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`:`—`}function a$(e){return e?.startsWith(`image/`)??!1}async function o$(e,t){return XZ(e,{folderId:t})}function s$(e,t){if(!t||t.length===0)return!0;let n=e??``;return t.some(e=>e===`image`?n.startsWith(`image/`):e===`video`?n.startsWith(`video/`):e===`audio`?n.startsWith(`audio/`):e===`document`?n.startsWith(`application/`)||n.startsWith(`text/`):!1)}function c$({open:e,onOpenChange:t,allowedTypes:n,onSelect:r}){let[i,a]=(0,v.useState)([{id:null,name:`Media`}]),o=i[i.length-1].id,[s,c]=(0,v.useState)([]),[l,u]=(0,v.useState)([]),[d,f]=(0,v.useState)(!1);(0,v.useEffect)(()=>{if(!e)return;f(!0);let t=localStorage.getItem(`plank_token`),n=t?{Authorization:`Bearer ${t}`}:{},r=o??``;Promise.all([fetch(`/cms/admin/folders?parent_id=${r}`,{headers:n}).then(e=>e.ok?e.json():{folders:[]}).then(e=>e.folders),fetch(`/cms/admin/media?folder_id=${r}`,{headers:n}).then(e=>e.ok?e.json():{items:[]}).then(e=>e.items)]).then(([e,t])=>{c(e),u(t)}).catch(()=>{c([]),u([])}).finally(()=>f(!1))},[e,o]),(0,v.useEffect)(()=>{e||a([{id:null,name:`Media`}])},[e]);function p(e){a(t=>[...t,{id:e.id,name:e.name}])}function m(e){a(t=>t.slice(0,e+1))}let h=l.filter(e=>s$(e.mime_type,n)),g=s.length===0&&h.length===0;return(0,U.jsx)(yw,{open:e,onOpenChange:t,children:(0,U.jsxs)(Cw,{className:`max-w-3xl`,children:[(0,U.jsx)(ww,{children:(0,U.jsx)(Ew,{children:`Media Library`})}),i.length>1&&(0,U.jsx)(`div`,{className:`flex items-center gap-1 text-sm -mt-1`,children:i.map((e,t)=>(0,U.jsxs)(`span`,{className:`flex items-center gap-1 text-muted-foreground`,children:[t>0&&(0,U.jsx)(`span`,{children:`/`}),t===i.length-1?(0,U.jsx)(`span`,{className:`font-medium text-foreground`,children:t===0?(0,U.jsx)(go,{className:`size-3.5`}):e.name}):(0,U.jsx)(`button`,{onClick:()=>m(t),className:`hover:text-foreground transition-colors`,children:t===0?(0,U.jsx)(go,{className:`size-3.5`}):e.name})]},t))}),d?(0,U.jsx)(`div`,{className:`flex items-center justify-center py-16`,children:(0,U.jsx)(by,{className:`size-5`})}):g?(0,U.jsx)(`p`,{className:`py-16 text-center text-sm text-muted-foreground`,children:l.length===0&&s.length===0?`No media found.`:`No matching files in this folder.`}):(0,U.jsxs)(`div`,{className:`flex flex-col gap-4 max-h-[60vh] overflow-y-auto pr-1`,children:[s.length>0&&(0,U.jsx)(`div`,{className:`grid grid-cols-1 gap-1.5 sm:grid-cols-2`,children:s.map(e=>(0,U.jsxs)(`button`,{type:`button`,onClick:()=>p(e),className:`flex items-center gap-2.5 rounded-md border bg-card px-2.5 py-2 text-left transition-colors hover:bg-muted/50 hover:border-primary`,children:[(0,U.jsx)(lo,{className:`size-7 shrink-0 text-muted-foreground`}),(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsx)(`p`,{className:`truncate text-xs font-bold leading-tight`,title:e.name,children:e.name}),(0,U.jsxs)(`p`,{className:`text-[10px] text-muted-foreground`,children:[e.item_count,` `,e.item_count===1?`item`:`items`]})]})]},e.id))}),h.length>0&&(0,U.jsx)(`div`,{className:`grid grid-cols-3 gap-2 sm:grid-cols-4 md:grid-cols-5`,children:h.map(e=>(0,U.jsxs)(`button`,{type:`button`,onClick:()=>{r(e),t(!1)},className:`group relative overflow-hidden rounded-md border bg-card text-left transition-colors hover:border-primary`,children:[(0,U.jsx)(`div`,{className:`aspect-square bg-muted`,children:a$(e.mime_type)?(0,U.jsx)(`img`,{src:e.url,alt:e.filename,className:`h-full w-full object-cover`}):(0,U.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,U.jsx)(ao,{className:`size-6 text-muted-foreground`})})}),(0,U.jsxs)(`div`,{className:`p-1.5`,children:[(0,U.jsx)(`p`,{className:`truncate text-[11px] font-medium leading-tight`,title:e.filename,children:e.filename}),(0,U.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:i$(e.size)})]}),(0,U.jsx)(`div`,{className:`absolute inset-0 rounded-md ring-2 ring-primary ring-offset-1 opacity-0 group-hover:opacity-100 transition-opacity pointer-events-none`})]},e.id))})]})]})})}function l$({value:e,onChange:t,allowedTypes:n,disabled:r=!1}){let i=(0,v.useRef)(null),[a,o]=(0,v.useState)(!1),[s,c]=(0,v.useState)(null),[l,u]=(0,v.useState)(null),[d,f]=(0,v.useState)(!1),p=typeof e==`string`&&e.startsWith(`http`);(0,v.useEffect)(()=>{if(!e){u(null);return}if(p){u(e);return}let t=localStorage.getItem(`plank_token`);fetch(`/cms/admin/media/${e}/url`,{headers:t?{Authorization:`Bearer ${t}`}:{}}).then(e=>e.ok?e.json():null).then(e=>u(e?.url??null)).catch(()=>u(null))},[e,p]);async function m(e){o(!0),c(null);try{let n=await o$(e);u(n.url),t(n.id)}catch(e){c(e instanceof Error?e.message:`Upload failed.`)}finally{o(!1),i.current&&(i.current.value=``)}}let h=l&&/\.(jpe?g|png|gif|webp|avif|svg)(\?|$)/i.test(l);return e?(0,U.jsxs)(`div`,{className:`relative w-full rounded-md border bg-muted/30 overflow-hidden`,children:[l?h?(0,U.jsx)(`img`,{src:l,alt:`Media`,className:`max-h-72 w-full object-contain`}):(0,U.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2`,children:[(0,U.jsx)(_o,{className:`size-4 text-muted-foreground shrink-0`}),(0,U.jsx)(`span`,{className:`text-xs text-muted-foreground truncate`,children:l})]}):(0,U.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 text-muted-foreground`,children:[(0,U.jsx)(_o,{className:`size-4 shrink-0`}),(0,U.jsx)(`span`,{className:`text-xs`,children:`Loading…`})]}),(0,U.jsx)(J,{type:`button`,size:`icon`,variant:`secondary`,className:`absolute top-1.5 right-1.5 size-6`,onClick:()=>{t(null),u(null)},disabled:r,children:(0,U.jsx)(ns,{className:`size-3.5`})})]}):(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`input`,{ref:i,type:`file`,accept:n$(n),className:`hidden`,onChange:e=>{let t=e.target.files?.[0];t&&m(t)}}),(0,U.jsxs)(`div`,{onDragOver:e=>e.preventDefault(),onDrop:e=>{if(r)return;e.preventDefault();let t=e.dataTransfer.files[0];t&&m(t)},className:`flex w-full gap-2 rounded-md border border-dashed p-3`,children:[(0,U.jsxs)(`button`,{type:`button`,disabled:a||r,onClick:()=>i.current?.click(),className:`flex flex-1 items-center justify-center gap-2 rounded-md py-2 text-sm text-muted-foreground transition-colors hover:bg-muted/50 disabled:opacity-50`,children:[(0,U.jsx)(Qo,{className:`size-4`}),a?`Uploading…`:`Upload`]}),(0,U.jsx)(`div`,{className:`w-px bg-border`}),(0,U.jsxs)(`button`,{type:`button`,disabled:a||r,onClick:()=>f(!0),className:`flex flex-1 items-center justify-center gap-2 rounded-md py-2 text-sm text-muted-foreground transition-colors hover:bg-muted/50 disabled:opacity-50`,children:[(0,U.jsx)(so,{className:`size-4`}),`Library`]})]}),s&&(0,U.jsx)(`p`,{className:`mt-1 text-xs text-destructive`,children:s}),(0,U.jsx)(c$,{open:d,onOpenChange:f,allowedTypes:n,onSelect:e=>{u(e.url),t(e.id)}})]})}function u$({id:e,previewUrl:t,filename:n,onRemove:r,disabled:i=!1}){let{attributes:a,listeners:o,setNodeRef:s,transform:c,transition:l,isDragging:u}=gO({id:e});return(0,U.jsxs)(`div`,{ref:s,style:{transform:kT.Transform.toString(c),transition:l,opacity:u?.4:1},className:`relative aspect-square overflow-hidden rounded-md border bg-muted`,children:[t?(0,U.jsx)(`img`,{src:t,alt:n,className:`h-full w-full object-cover`}):(0,U.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,U.jsx)(_o,{className:`size-5 text-muted-foreground`})}),n&&(0,U.jsx)(`div`,{className:`absolute bottom-0 left-0 right-0 bg-background/75 backdrop-blur-sm px-1.5 py-1 pointer-events-none`,children:(0,U.jsx)(`p`,{className:`truncate text-[10px] leading-none text-foreground`,children:n})}),(0,U.jsx)(`button`,{type:`button`,onClick:r,disabled:i,className:`absolute right-1 top-1 flex size-5 items-center justify-center rounded-full bg-background/80 text-foreground shadow-sm hover:bg-background`,children:(0,U.jsx)(ns,{className:`size-3`})}),!i&&(0,U.jsx)(`button`,{type:`button`,className:`absolute bottom-6 left-1 flex size-5 cursor-grab items-center justify-center rounded-full bg-background/80 text-foreground shadow-sm active:cursor-grabbing`,...o,...a,children:(0,U.jsx)(uo,{className:`size-3`})})]})}function d$({value:e,onChange:t,disabled:n=!1}){let r=Array.isArray(e)?e:[],[i,a]=(0,v.useState)({}),[o,s]=(0,v.useState)({}),[c,l]=(0,v.useState)(!1),[u,d]=(0,v.useState)(null),[f,p]=(0,v.useState)(!1),m=(0,v.useRef)(null),h=GT(WT(GE,{activationConstraint:{distance:5}}));(0,v.useEffect)(()=>{let e=r.filter(e=>!e.startsWith(`http`)&&!(e in i));if(e.length===0)return;let t=localStorage.getItem(`plank_token`);Promise.all(e.map(e=>fetch(`/cms/admin/media/${e}/url`,{headers:t?{Authorization:`Bearer ${t}`}:{}}).then(e=>e.ok?e.json():null).then(t=>t?[e,t.url]:null).catch(()=>null))).then(e=>{let t={};for(let n of e)n&&(t[n[0]]=n[1]);Object.keys(t).length>0&&a(e=>({...e,...t}))})},[r.join(`,`)]),(0,v.useEffect)(()=>{let e=r.filter(e=>!e.startsWith(`http`)&&!(e in o));if(e.length===0)return;let t=localStorage.getItem(`plank_token`);fetch(`/cms/admin/media`,{headers:t?{Authorization:`Bearer ${t}`}:{}}).then(e=>e.ok?e.json():{items:[]}).then(t=>{let n={};for(let r of t.items)e.includes(r.id)&&(n[r.id]=r.filename);Object.keys(n).length>0&&s(e=>({...e,...n}))}).catch(()=>{})},[r.join(`,`)]);function g(e){return e.startsWith(`http`)?e:i[e]??null}function _(e){return o[e]??``}function y(e){if(n)return;let{active:i,over:a}=e;!a||i.id===a.id||t(ZD(r,r.indexOf(i.id),r.indexOf(a.id)))}async function b(e){if(e.length===0)return;l(!0),d(null);let n=r;try{for(let r of e){let e=await o$(r);a(t=>({...t,[e.id]:e.url})),s(t=>({...t,[e.id]:r.name})),n=[...n,e.id],t(n)}}catch(e){d(e instanceof Error?e.message:`Upload failed.`)}finally{l(!1),m.current&&(m.current.value=``)}}return(0,U.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,U.jsx)(`input`,{ref:m,type:`file`,accept:`image/*`,multiple:!0,className:`hidden`,onChange:e=>{b(Array.from(e.target.files??[]))}}),r.length>0&&(0,U.jsx)(HD,{sensors:h,collisionDetection:QT,onDragEnd:y,children:(0,U.jsx)(cO,{items:r,strategy:nO,children:(0,U.jsx)(`div`,{className:`grid grid-cols-3 gap-2 sm:grid-cols-4`,children:r.map(e=>(0,U.jsx)(u$,{id:e,previewUrl:g(e),filename:_(e),onRemove:()=>t(r.filter(t=>t!==e)),disabled:n},e))})})}),(0,U.jsxs)(`div`,{className:`flex w-full gap-2 rounded-md border border-dashed p-3`,children:[(0,U.jsxs)(`button`,{type:`button`,disabled:c||n,onClick:()=>m.current?.click(),className:`flex flex-1 items-center justify-center gap-2 rounded-md py-2 text-sm text-muted-foreground transition-colors hover:bg-muted/50 disabled:opacity-50`,children:[(0,U.jsx)(Qo,{className:`size-4`}),c?`Uploading…`:`Upload`]}),(0,U.jsx)(`div`,{className:`w-px bg-border`}),(0,U.jsxs)(`button`,{type:`button`,disabled:c||n,onClick:()=>p(!0),className:`flex flex-1 items-center justify-center gap-2 rounded-md py-2 text-sm text-muted-foreground transition-colors hover:bg-muted/50 disabled:opacity-50`,children:[(0,U.jsx)(so,{className:`size-4`}),`Library`]})]}),u&&(0,U.jsx)(`p`,{className:`text-xs text-destructive`,children:u}),(0,U.jsx)(c$,{open:f,onOpenChange:p,allowedTypes:[`image`],onSelect:e=>{r.includes(e.id)||(a(t=>({...t,[e.id]:e.url})),s(t=>({...t,[e.id]:e.filename})),t([...r,e.id]))}})]})}function f$({value:e,onChange:t,disabled:n=!1}){let[r,i]=(0,v.useState)(()=>e!=null&&e!==``?String(e):``);(0,v.useEffect)(()=>{if(e==null||e===``){i(``);return}let t=typeof e==`number`?e:parseFloat(String(e));!isNaN(t)&&t!==parseFloat(r)&&i(String(t))},[e]);function a(e){let n=e.target.value.replace(`,`,`.`);if(i(n),n===``||n===`-`){t(null);return}let r=parseFloat(n);isNaN(r)||t(r)}return(0,U.jsx)(Hv,{type:`text`,inputMode:`decimal`,className:q(`w-full`,`text-base!`),value:r,placeholder:`0.00`,onChange:a,disabled:n})}function p$(e){if(typeof e==`object`&&e){let t=e;if(t.kind===`string`&&typeof t.value==`string`)return{kind:`string`,value:t.value};if(t.kind===`number`&&typeof t.value==`number`&&!isNaN(t.value))return{kind:`number`,value:t.value};if(t.kind===`boolean`&&typeof t.value==`boolean`)return{kind:`boolean`,value:t.value}}return typeof e==`number`&&!isNaN(e)?{kind:`number`,value:e}:typeof e==`boolean`?{kind:`boolean`,value:e}:{kind:`string`,value:typeof e==`string`?e:``}}function m$({value:e,onChange:t,inputId:n,disabled:r=!1}){let i=p$(e);function a(e){e===`string`&&t({kind:e,value:``}),e===`number`&&t({kind:e,value:0}),e===`boolean`&&t({kind:e,value:!1})}return(0,U.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,U.jsx)(`div`,{className:`inline-flex items-center gap-1 rounded-md border border-border p-1`,children:[`string`,`number`,`boolean`].map(e=>(0,U.jsx)(`button`,{type:`button`,disabled:r,onClick:()=>a(e),className:q(`rounded px-2 py-1 text-xs transition-colors`,i.kind===e?`bg-accent text-accent-foreground`:`text-muted-foreground hover:bg-accent/60`),children:e===`string`?`Text`:e===`number`?`Number`:`Boolean`},e))}),i.kind===`string`&&(0,U.jsx)(Hv,{className:q(`w-full`,`text-base md:text-base`),value:String(i.value),placeholder:`Value`,onChange:e=>t({kind:`string`,value:e.target.value}),disabled:r}),i.kind===`number`&&(0,U.jsx)(f$,{value:i.value,onChange:e=>t({kind:`number`,value:typeof e==`number`&&!isNaN(e)?e:0}),disabled:r}),i.kind===`boolean`&&(0,U.jsxs)(`div`,{className:`flex items-center gap-2 pt-1`,children:[(0,U.jsx)(EO,{id:n,checked:!!i.value,onCheckedChange:e=>t({kind:`boolean`,value:!!e}),disabled:r}),(0,U.jsx)(X,{htmlFor:n,className:`cursor-pointer font-normal text-base`,children:i.value?`True`:`False`})]})]})}function h$({value:e,onChange:t,timezone:n,disabled:r=!1}){let[i,a]=(0,v.useState)(!1),[o,s]=(0,v.useState)(),[c,l]=(0,v.useState)(`00:00`);(0,v.useEffect)(()=>{if(!e){s(void 0),l(`00:00`);return}let t=new Date(e);isNaN(t.getTime())||(s(t),l(Ty(e,n)))},[e,n]);function u(e){s(e),a(!1),e&&t(Ey(e,c,n))}function d(e){l(e),o&&t(Ey(o,e,n))}return(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsxs)(LN,{open:i&&!r,onOpenChange:a,children:[(0,U.jsx)(RN,{asChild:!0,children:(0,U.jsxs)(J,{variant:`outline`,className:`w-40 justify-between font-normal text-base`,disabled:r,children:[o?VA(o,`MMM d, yyyy`):`Select date`,(0,U.jsx)(Ba,{className:`size-4 opacity-50`})]})}),(0,U.jsx)(zN,{className:`w-auto overflow-hidden p-0`,align:`start`,children:(0,U.jsx)(FN,{mode:`single`,selected:o,captionLayout:`dropdown`,defaultMonth:o??new Date,onSelect:u})})]}),(0,U.jsx)(Hv,{type:`time`,className:`w-32 appearance-none bg-background [&::-webkit-calendar-picker-indicator]:hidden [&::-webkit-calendar-picker-indicator]:appearance-none text-base!`,value:c,onChange:e=>d(e.target.value),disabled:r}),e&&(0,U.jsx)(J,{type:`button`,variant:`ghost`,size:`icon`,className:`size-8 text-muted-foreground hover:text-foreground`,onClick:()=>{s(void 0),l(`00:00`),t(null)},disabled:r,children:(0,U.jsx)(ns,{className:`size-3.5`})})]})}function g$(e){return e.find(e=>e.type===`uid`)?.name??e.find(e=>e.type===`string`)?.name??null}var _$={data:null,promise:null};function v$(e){return _$.data?Promise.resolve(_$.data):(_$.promise||=fetch(`/cms/admin/content-types`,{headers:e}).then(e=>e.ok?e.json():[]).then(e=>(_$.data=e,e)).catch(()=>[]),_$.promise)}function y$(e,t){return e.find(e=>e.tableName===t)??null}function b$(e,t){return fetch(`/cms/admin/content-types/${e}/entries?limit=200`,{headers:t}).then(e=>e.ok?e.json():{data:[]}).catch(()=>({data:[]}))}function x$(e){let[t,n]=(0,v.useState)([]),[r,i]=(0,v.useState)(!1);return(0,v.useEffect)(()=>{if(!e)return;i(!0);let t=localStorage.getItem(`plank_token`),r=t?{Authorization:`Bearer ${t}`}:{};v$(r).then(t=>{let n=y$(t,e);return n?b$(n.slug,r).then(e=>({ctDef:n,res:e})):Promise.resolve({ctDef:null,res:{data:[]}})}).then(({ctDef:e,res:t})=>{let r=e?g$(e.fields??[]):null;n(t.data.map(e=>({id:String(e.id),label:String(r?e[r]??e.id:e.id)})))}).catch(()=>n([])).finally(()=>i(!1))},[e]),{entries:t,loading:r}}function S$(e,t,n){let[r,i]=(0,v.useState)([]),[a,o]=(0,v.useState)(!1);return(0,v.useEffect)(()=>{if(!e||!n){i([]);return}o(!0);let r=localStorage.getItem(`plank_token`),a=r?{Authorization:`Bearer ${r}`}:{};v$(a).then(t=>{let n=y$(t,e);return n?b$(n.slug,a).then(e=>({ctDef:n,res:e})):Promise.resolve({ctDef:null,res:{data:[]}})}).then(({ctDef:e,res:r})=>{let a=e?g$(e.fields??[]):null;i(r.data.filter(e=>String(e[t]??``)===n).map(e=>({id:String(e.id),label:String(a?e[a]??e.id:e.id)})))}).catch(()=>i([])).finally(()=>o(!1))},[e,t,n]),{entries:r,loading:a}}function C$({relatedTable:e,relatedField:t,currentId:n}){let{entries:r,loading:i}=S$(e,t,n);return n?i?(0,U.jsxs)(`div`,{className:`flex items-center gap-2 py-1`,children:[(0,U.jsx)(by,{className:`size-3.5`}),(0,U.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Loading…`})]}):r.length===0?(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No linked entries.`}):(0,U.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:r.map(e=>(0,U.jsx)(`span`,{className:`inline-flex items-center rounded-md border bg-muted px-2 py-0.5 text-xs`,children:e.label},e.id))}):(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Save this entry first to see linked items.`})}function w$({relationType:e,relatedTable:t,relatedField:n,currentEntryId:r,value:i,onChange:a,disabled:o=!1}){let s=e===`many-to-many`,[c,l]=(0,v.useState)(!1),{entries:u,loading:d}=x$(t);if(e===`one-to-many`)return(0,U.jsx)(C$,{relatedTable:t,relatedField:n,currentId:r});let f=s?Array.isArray(i)?i:[]:i&&!Array.isArray(i)?[i]:[];function p(e){return u.find(t=>t.id===e)?.label??e}function m(e){if(s){let t=f.includes(e)?f.filter(t=>t!==e):[...f,e];a(t.length>0?t:null)}else a(f[0]===e?null:e),l(!1)}function h(e){if(s){let t=f.filter(t=>t!==e);a(t.length>0?t:null)}else a(null)}let g=s?f.length>0?`${f.length} selected`:`Select entries…`:f.length>0?p(f[0]):`Select entry…`;return(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsxs)(LN,{open:c&&!o,onOpenChange:l,children:[(0,U.jsx)(RN,{asChild:!0,children:(0,U.jsxs)(J,{variant:`outline`,role:`combobox`,"aria-expanded":c,className:`w-full justify-between font-normal text-base`,disabled:o,children:[(0,U.jsx)(`span`,{className:`truncate text-left`,children:g}),(0,U.jsx)(Wa,{className:`ml-2 size-4 shrink-0 opacity-50`})]})}),(0,U.jsx)(zN,{className:`w-(--radix-popover-trigger-width) p-0`,align:`start`,children:(0,U.jsxs)(qQ,{children:[(0,U.jsx)(JQ,{placeholder:`Search…`}),(0,U.jsx)(YQ,{children:d?(0,U.jsx)(`div`,{className:`flex items-center justify-center py-6`,children:(0,U.jsx)(by,{className:`size-4`})}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(XQ,{children:`No entries found.`}),(0,U.jsx)(ZQ,{children:u.map(e=>{let t=f.includes(e.id);return(0,U.jsxs)($Q,{value:e.label,onSelect:()=>{o||m(e.id)},children:[(0,U.jsx)(za,{className:`mr-2 size-4 ${t?`opacity-100`:`opacity-0`}`}),(0,U.jsx)(`span`,{className:`truncate`,children:e.label}),(0,U.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground opacity-60 shrink-0`,children:e.id.slice(0,8)})]},e.id)})})]})})]})})]}),f.length>0&&(0,U.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:f.map(e=>(0,U.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border bg-muted px-2 py-0.5 text-xs`,children:[p(e),(0,U.jsx)(`button`,{type:`button`,onClick:()=>h(e),disabled:o,className:`text-muted-foreground hover:text-foreground`,children:(0,U.jsx)(ns,{className:`size-3`})})]},e))})]})}var T$={full:`col-span-6`,"two-thirds":`col-span-4`,half:`col-span-3`,third:`col-span-2`};function E$({field:e,value:t,onChange:n,disabled:r=!1}){let i=Array.isArray(t)?t:[],a=e.arrayFields??[];function o(){return Object.fromEntries(a.map(e=>[e.name,e.type===`boolean`?!1:null]))}function s(){n([...i,o()])}function c(e){n(i.filter((t,n)=>n!==e))}function l(e,t){let r=e+t;if(r<0||r>=i.length)return;let a=[...i];[a[e],a[r]]=[a[r],a[e]],n(a)}function u(e,t,r){n(i.map((n,i)=>i===e?{...n,[t]:r}:n))}return a.length===0?(0,U.jsx)(`div`,{className:`flex w-full items-center justify-center rounded-md border border-dashed p-4 text-xs text-muted-foreground`,children:`No sub-fields defined for this array.`}):(0,U.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,U.jsx)(VN,{type:`single`,collapsible:!0,className:`w-full`,children:i.map((e,t)=>(0,U.jsxs)(HN,{value:`item-${t}`,className:`mb-2 rounded-md border border-dashed last:border-b transition-colors hover:bg-accent/50`,children:[(0,U.jsxs)(`div`,{className:`relative data-[state=open]:border-b data-[state=open]:border-border/50`,children:[(0,U.jsxs)(UN,{className:`w-full py-2 pl-3 pr-24 text-muted-foreground [&>svg]:hidden`,children:[`Item `,t+1]}),(0,U.jsxs)(`div`,{className:`absolute right-2 top-1/2 flex -translate-y-1/2 items-center gap-0.5`,children:[(0,U.jsx)(J,{size:`icon`,variant:`ghost`,disabled:r||t===0,onMouseDown:e=>e.stopPropagation(),onClick:()=>l(t,-1),className:`flex size-6 items-center justify-center rounded text-muted-foreground hover:bg-accent disabled:opacity-30`,children:(0,U.jsx)(Ua,{className:`size-3.5`})}),(0,U.jsx)(J,{size:`icon`,variant:`ghost`,disabled:r||t===i.length-1,onMouseDown:e=>e.stopPropagation(),onClick:()=>l(t,1),className:`flex size-6 items-center justify-center rounded text-muted-foreground hover:bg-accent disabled:opacity-30`,children:(0,U.jsx)(Ba,{className:`size-3.5`})}),(0,U.jsx)(`button`,{type:`button`,onMouseDown:e=>e.stopPropagation(),onClick:()=>c(t),disabled:r,className:`flex size-6 items-center justify-center rounded text-destructive transition-colors hover:bg-destructive/10 hover:text-destructive`,children:(0,U.jsx)(qo,{className:`size-3.5`})})]})]}),(0,U.jsx)(WN,{className:`px-3 pt-3`,children:(0,U.jsx)(`div`,{className:`grid grid-cols-6 gap-3`,children:a.map(n=>(0,U.jsxs)(`div`,{className:T$[n.width??`full`]??`col-span-6`,children:[(0,U.jsx)(`div`,{className:`mb-1 flex items-center gap-1`,children:(0,U.jsxs)(X,{className:`text-xs font-medium`,children:[n.name,n.required&&(0,U.jsx)(`span`,{className:`ml-0.5 text-destructive`,children:`*`})]})}),(0,U.jsx)(M$,{field:{...n,type:n.type},value:e[n.name]??null,onChange:e=>u(t,n.name,e),allValues:e,disabled:r})]},n.name))})})]},t))}),(0,U.jsxs)(`button`,{type:`button`,onClick:s,disabled:r,className:`flex w-full items-center justify-center gap-1.5 rounded-md border border-dashed py-2 text-xs text-muted-foreground transition-colors hover:bg-accent/50`,children:[(0,U.jsx)(Po,{className:`size-3.5`}),`Add item`]})]})}var D$=3,O$=20;function k$({value:e,onChange:t,disabled:n=!1,depth:r=0}){let i=Array.isArray(e)?e:[],a=r+1<D$,o=i.length<O$;function s(){return{label:``,href:``}}function c(e,n){let r=(t,i)=>{let a=e[i];return t.map((t,o)=>{if(o!==a)return t;if(i===e.length-1)return n(t);let s=Array.isArray(t.items)?t.items:[];return{...t,items:r(s,i+1)}})};t(r(i,0))}function l(e,n){let r=(t,i)=>{if(i===e.length-1){let r=e[i],a=r+n;if(a<0||a>=t.length)return t;let o=[...t];return[o[r],o[a]]=[o[a],o[r]],o}let a=e[i];return t.map((e,t)=>{if(t!==a)return e;let n=Array.isArray(e.items)?e.items:[];return{...e,items:r(n,i+1)}})};t(r(i,0))}function u(e){let n=(t,r)=>{let i=e[r];return r===e.length-1?t.filter((e,t)=>t!==i):t.map((e,t)=>{if(t!==i)return e;let a=Array.isArray(e.items)?e.items:[];return{...e,items:n(a,r+1)}})};t(n(i,0))}function d(){o&&t([...i,s()])}return i.length===0?(0,U.jsxs)(`button`,{type:`button`,onClick:d,disabled:n||!o,className:`flex w-full items-center justify-center gap-1.5 rounded-md border border-dashed py-2 text-xs text-muted-foreground transition-colors hover:bg-accent/20`,children:[(0,U.jsx)(Po,{className:`size-3.5`}),`Add item`]}):(0,U.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,U.jsx)(VN,{type:`single`,collapsible:!0,className:`w-full`,children:i.map((e,t)=>{let o=[t],s=e.label?.trim()?e.label:`Item ${t+1}`;return(0,U.jsxs)(HN,{value:`navigation-item-${r}-${t}`,className:`mb-2 rounded-md border border-dashed last:border-b transition-colors hover:bg-accent/50`,children:[(0,U.jsxs)(`div`,{className:`relative data-[state=open]:border-b data-[state=open]:border-border/50`,children:[(0,U.jsx)(UN,{className:`w-full py-2 pl-3 pr-24 text-muted-foreground [&>svg]:hidden`,children:s}),(0,U.jsxs)(`div`,{className:`absolute right-2 top-1/2 flex -translate-y-1/2 items-center gap-0.5`,children:[(0,U.jsx)(J,{size:`icon`,variant:`ghost`,disabled:n||t===0,onMouseDown:e=>e.stopPropagation(),onClick:()=>l(o,-1),className:`flex size-6 items-center justify-center rounded text-muted-foreground hover:bg-accent disabled:opacity-30`,children:(0,U.jsx)(Ua,{className:`size-3.5`})}),(0,U.jsx)(J,{size:`icon`,variant:`ghost`,disabled:n||t===i.length-1,onMouseDown:e=>e.stopPropagation(),onClick:()=>l(o,1),className:`flex size-6 items-center justify-center rounded text-muted-foreground hover:bg-accent disabled:opacity-30`,children:(0,U.jsx)(Ba,{className:`size-3.5`})}),(0,U.jsx)(`button`,{type:`button`,onMouseDown:e=>e.stopPropagation(),onClick:()=>u(o),disabled:n,className:`flex size-6 items-center justify-center rounded text-destructive transition-colors hover:bg-destructive/10 hover:text-destructive`,children:(0,U.jsx)(qo,{className:`size-3.5`})})]})]}),(0,U.jsxs)(WN,{className:`px-3 pt-3`,children:[(0,U.jsxs)(`div`,{className:`grid grid-cols-6 gap-3`,children:[(0,U.jsxs)(`div`,{className:`col-span-3`,children:[(0,U.jsx)(X,{className:`mb-1 block text-xs font-medium`,children:`label`}),(0,U.jsx)(Hv,{className:`text-base`,value:e.label??``,onChange:e=>c(o,t=>({...t,label:e.target.value})),disabled:n})]}),(0,U.jsxs)(`div`,{className:`col-span-3`,children:[(0,U.jsx)(X,{className:`mb-1 block text-xs font-medium`,children:`href`}),(0,U.jsx)(Hv,{className:`text-base`,value:e.href??``,onChange:e=>c(o,t=>({...t,href:e.target.value})),disabled:n})]})]}),a?(0,U.jsxs)(`div`,{className:`mt-3 border-l border-border pl-3`,children:[(0,U.jsx)(`p`,{className:`mb-2 text-[11px] uppercase tracking-wide text-muted-foreground`,children:`Child items`}),(0,U.jsx)(k$,{value:e.items??[],onChange:e=>c(o,t=>({...t,items:Array.isArray(e)&&e.length>0?e:void 0})),disabled:n,depth:r+1})]}):(0,U.jsxs)(`p`,{className:`mt-3 text-[11px] text-muted-foreground`,children:[`Maximum depth reached (`,D$,` levels).`]})]})]},t)})}),(0,U.jsxs)(`button`,{type:`button`,onClick:d,disabled:n,className:`flex w-full items-center justify-center gap-1.5 rounded-md border border-dashed py-2 text-xs text-muted-foreground transition-colors hover:bg-accent/50`,children:[(0,U.jsx)(Po,{className:`size-3.5`}),`Add item`]}),!o&&(0,U.jsxs)(`p`,{className:`text-[11px] text-muted-foreground`,children:[`Maximum `,O$,` items allowed per level.`]})]})}function A$(e){return e.normalize(`NFD`).replace(/[\u0300-\u036f]/g,``).toLowerCase().replace(/\s+/g,`-`).replace(/[^a-z0-9-]/g,``).replace(/^-+|-+$/g,``)}function j$({value:e,onChange:t,disabled:n=!1}){let r=(0,v.useRef)(null),i=(0,v.useRef)(null),[a,o]=(0,v.useState)(!1),[s,c]=(0,v.useState)(!1),[l,u]=(0,v.useState)(!1),[d,f]=(0,v.useState)(null);function p(){return o(!0),new Promise(e=>{i.current=e})}function m(e){i.current?.(e),i.current=null}function h(e){e||m(null),o(e)}async function g(e){u(!0),f(null);try{let t=await XZ(e);m({src:t.url,alt:t.alt,width:t.width,height:t.height}),o(!1)}catch(e){f(e instanceof Error?e.message:`Upload failed.`)}finally{u(!1),r.current&&(r.current.value=``)}}return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`div`,{className:n?`pointer-events-none opacity-70`:``,children:(0,U.jsx)(qZ,{value:String(e??``),onChange:t,placeholder:`Type or add your content here...`,onInsertImage:p})}),(0,U.jsx)(yw,{open:a,onOpenChange:h,children:(0,U.jsxs)(Cw,{className:`max-w-sm`,children:[(0,U.jsx)(ww,{children:(0,U.jsx)(Ew,{children:`Insert Image`})}),(0,U.jsx)(`input`,{ref:r,type:`file`,accept:`image/*`,className:`hidden`,onChange:e=>{let t=e.target.files?.[0];t&&g(t)}}),(0,U.jsxs)(`div`,{onDragOver:e=>e.preventDefault(),onDrop:e=>{e.preventDefault();let t=e.dataTransfer.files[0];t&&g(t)},className:`flex w-full gap-2 rounded-md border border-dashed p-3`,children:[(0,U.jsxs)(`button`,{type:`button`,disabled:l,onClick:()=>r.current?.click(),className:`flex flex-1 items-center justify-center gap-2 rounded-md py-2 text-sm text-muted-foreground transition-colors hover:bg-muted/50 disabled:opacity-50`,children:[(0,U.jsx)(Qo,{className:`size-4`}),l?`Uploading…`:`Upload`]}),(0,U.jsx)(`div`,{className:`w-px bg-border`}),(0,U.jsxs)(`button`,{type:`button`,disabled:l,onClick:()=>c(!0),className:`flex flex-1 items-center justify-center gap-2 rounded-md py-2 text-sm text-muted-foreground transition-colors hover:bg-muted/50 disabled:opacity-50`,children:[(0,U.jsx)(so,{className:`size-4`}),`Library`]})]}),d&&(0,U.jsx)(`p`,{className:`mt-1 text-xs text-destructive`,children:d})]})}),(0,U.jsx)(c$,{open:s,onOpenChange:e=>{!e&&!a&&m(null),c(e)},allowedTypes:[`image`],onSelect:e=>{m({src:e.url,alt:e.alt,width:e.width,height:e.height}),c(!1),o(!1)}})]})}function M$({field:e,value:t,onChange:n,allValues:r,disabled:i,errorMessage:a}){let o=(0,v.useRef)(null),{timezone:s}=ya();(0,v.useEffect)(()=>{if(e.type!==`uid`||!e.targetField)return;let i=String(t??``).trim(),a=i===``||i===o.current,s=r,c=e.targetField,l=!!s.__localizationEnabled,u=s[c];if(u!=null&&String(u).trim()!==``){if(!a)return;let e=A$(String(u));e!==i&&(o.current=e,n(e));return}let d=s.localized&&typeof s.localized==`object`?s.localized:{};if(l){let e=typeof s.__defaultLocale==`string`?s.__defaultLocale:void 0,t=e&&d[e]&&typeof d[e]==`object`?d[e]:null;if(t&&t[c]!==void 0&&String(t[c]).trim()!==``){if(!a)return;let e=A$(String(t[c]));e!==i&&(o.current=e,n(e))}return}let f=Object.keys(d).filter(e=>!e.startsWith(`_`));for(let e of f){let t=d[e]&&typeof d[e]==`object`?d[e]:null;if(t&&t[c]!==void 0&&String(t[c]).trim()!==``){if(!a)return;let e=A$(String(t[c]));e!==i&&(o.current=e,n(e));return}}},[t,e.type,e.targetField,r[e.targetField??``],JSON.stringify(r.localized??{}),r.__localizationEnabled]);let c=`w-full`;return e.type===`boolean`?(0,U.jsxs)(`div`,{className:`flex items-center gap-2 pt-1`,children:[(0,U.jsx)(EO,{id:`field-${e.name}`,checked:!!t,onCheckedChange:e=>n(!!e),disabled:!!i}),(0,U.jsx)(X,{htmlFor:`field-${e.name}`,className:`cursor-pointer font-normal text-base`,children:t?`Yes`:`No`})]}):e.type===`richtext`?(0,U.jsx)(j$,{value:t,onChange:n,disabled:!!i}):e.type===`text`?(0,U.jsx)(BN,{className:q(c,`text-base`),value:String(t??``),placeholder:r$(e.name),onChange:e=>n(e.target.value),disabled:!!i}):e.type===`number`?e.subtype===`float`?(0,U.jsx)(f$,{value:t,onChange:n,disabled:!!i}):(0,U.jsx)(Hv,{type:`number`,className:q(c,`text-base!`),value:t==null?``:String(t),step:`1`,placeholder:`0`,onChange:e=>{let t=e.target.value;if(t===``){n(null);return}n(parseInt(t,10))},disabled:!!i}):e.type===`datetime`?(0,U.jsx)(h$,{value:t,onChange:n,timezone:s,disabled:!!i}):e.type===`uid`?(0,U.jsxs)(`div`,{children:[(0,U.jsx)(Hv,{className:q(c,`text-base md:text-base`,a?`border-destructive focus-visible:ring-destructive/20`:``),value:String(t??``),placeholder:`auto-generated`,onChange:e=>{n(e.target.value)},disabled:!!i}),a&&(0,U.jsx)(`p`,{className:`mt-1 text-xs text-destructive`,children:a})]}):e.type===`media`?(0,U.jsx)(l$,{value:t,onChange:n,allowedTypes:e.allowedTypes,disabled:!!i}):e.type===`media-gallery`?(0,U.jsx)(d$,{value:t,onChange:n,disabled:!!i}):e.type===`relation`?(0,U.jsx)(w$,{relationType:e.relationType??`many-to-one`,relatedTable:e.relatedTable??``,relatedField:e.relatedField??``,currentEntryId:String(r.id??``),value:t,onChange:n,disabled:!!i}):e.type===`array`?(0,U.jsx)(E$,{field:e,value:t,onChange:n,disabled:!!i}):e.type===`mixed`?(0,U.jsx)(m$,{value:t,onChange:n,inputId:`field-${e.name}-mixed-boolean`,disabled:!!i}):e.type===`navigation`?(0,U.jsx)(k$,{value:t,onChange:n,disabled:!!i}):(0,U.jsx)(Hv,{className:q(c,`text-base md:text-base`),value:String(t??``),placeholder:r$(e.name),onChange:e=>n(e.target.value),disabled:!!i})}function N$(e){return Array.isArray(e)?e.map(N$):e&&typeof e==`object`?Object.fromEntries(Object.entries(e).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>[e,N$(t)])):e}function P$(e){return JSON.stringify(N$(e))}function F$(e){let t=e.match(/Field "([^"]+)" already exists\.?/);return t?t[1]??null:null}function I$(){let{slug:e,id:t}=hr(),n=dr(),r=!t,{timezone:i,locales:a,defaultLocale:o,editorialMode:s}=ya(),{user:c,status:l}=ga(),u=c?.role?.toLowerCase()??``,{data:d,loading:f}=wa(e?`/cms/admin/content-types/${e}`:null),{data:p,loading:m}=wa(e&&t?`/cms/admin/entries/${e}/${t}`:null),{data:h}=wa(s&&[`editor`,`admin`,`super admin`].includes(c?.role?.toLowerCase()??``)?`/cms/admin/users`:null),{loading:g,request:_}=Vv(),{loading:y,request:b}=Vv(),{loading:x,request:S}=Vv(),[C,w]=(0,v.useState)({}),[T,E]=(0,v.useState)([]),[D,O]=(0,v.useState)(``),[k,A]=(0,v.useState)(!1),[j,M]=(0,v.useState)(`draft`),[N,P]=(0,v.useState)(``),[F,I]=(0,v.useState)(!1),[L,R]=(0,v.useState)(!1),[ee,te]=(0,v.useState)(!1),[z,B]=(0,v.useState)(null),[V,ne]=(0,v.useState)(null),[H,re]=(0,v.useState)(null),[ie,ae]=(0,v.useState)(null),[oe,se]=(0,v.useState)(!1),[ce,le]=(0,v.useState)(null),[ue,de]=(0,v.useState)(!1),[fe,pe]=(0,v.useState)(!1),[me,he]=(0,v.useState)(),[ge,_e]=(0,v.useState)(`09:00`),ve=(0,v.useRef)(`{}`),ye=(0,v.useRef)(!1);(0,v.useEffect)(()=>{if(r){let e={};d?.fields.forEach(t=>{e[t.name]=t.type===`boolean`?!1:``}),e.localized={};let t=a&&a.length>0?a:[`en`];E(t),O(o??t[0]),A(!1),w(e),M(`draft`),P(``),I(!1),te(!1),B(null),ne(null),re(null),ae(null),se(!1),le(null),ve.current=P$(e);return}if(!p||!d)return;let e={};d.fields.forEach(t=>{e[t.name]=p[t.name]??(t.type===`boolean`?!1:``)});let t=p.localized,n=t&&typeof t==`object`?t:{};e.localized=n;let s=Object.keys(n).filter(e=>!e.startsWith(`_`)),c=(n._meta||{}).enabled??s.length>0;if(s.length>0)E(s),O(s[0]);else{let e=a&&a.length>0?a:[`en`];E(e),O(o??e[0])}if(A(!!c),w(e),M(p.status??`draft`),te(!!p.review_rejected),B(p.editor_id??null),ne(p._editor_first_name??null),re(p._editor_last_name??null),ae(p._editor_avatar_url??null),se(!1),le(null),ve.current=P$(e),p.scheduled_for?(P(p.scheduled_for),he(new Date(p.scheduled_for)),_e(Ty(p.scheduled_for,i))):P(``),p.status===`published`&&p.published_data){let t=(e,t)=>{if(t===`datetime`&&e&&typeof e==`string`){let t=/Z|[+-]\d{2}:\d{2}$/.test(e)?e:e+`Z`,n=new Date(t);return isNaN(n.getTime())?e:n.toISOString()}return e},n={},r={};d.fields.forEach(i=>{i.name in p.published_data&&(n[i.name]=t(p.published_data[i.name]??(i.type===`boolean`?!1:``),i.type),r[i.name]=t(e[i.name],i.type))}),I(P$(r)!==P$(n))}else I(!1)},[p,d,r]);let be=P$(C)!==ve.current,xe=Fr((0,v.useCallback)(()=>ye.current?!1:be,[be]));function Se(e,t){w(n=>({...n,[e]:t}))}function Ce(e,t,n){w(r=>{let i={...r},a=i.localized&&typeof i.localized==`object`?i.localized:{},o=a[e]&&typeof a[e]==`object`?a[e]:{};return o[t]=n,a[e]=o,i.localized=a,i})}function we(e){A(e),w(t=>{let n={...t},r=n.localized&&typeof n.localized==`object`?n.localized:{};if(r._meta||={},e&&o){if(!(r[o]&&typeof r[o]==`object`&&r[o])&&(r[o]={},d&&d.fields)){let e=r[o];d.fields.forEach(t=>{if([`string`,`text`,`richtext`].includes(t.type)){let r=n[t.name];r!=null&&r!==``&&(e[t.name]=r)}})}r._meta.primary=o}else if(!e&&o){let e=r[o]&&typeof r[o]==`object`?r[o]:null;e&&d&&d.fields&&d.fields.forEach(t=>{if([`string`,`text`,`richtext`,`uid`].includes(t.type)){let r=e[t.name];r!==void 0&&(n[t.name]=r)}})}return r._meta.enabled=e,n.localized=r,n})}function Te(){if(N)he(new Date(N)),_e(Ty(N,i));else{let e=new Date;e.setDate(e.getDate()+1),he(e),_e(`09:00`)}de(!0)}async function Ee(){if(!e||!d)return null;le(null);let n={},i=k&&C.localized&&typeof C.localized==`object`&&C.localized[o]&&typeof C.localized[o]==`object`?C.localized[o]:null;if(d.fields.forEach(e=>{let t=C[e.name];(t==null||t===``)&&i&&i[e.name]!==void 0&&(t=i[e.name]),e.type===`media`&&t===null?n[e.name]=null:t!==``&&t!=null&&(n[e.name]=t)}),C.localized&&Object.keys(C.localized).length>0){let e=C.localized;e._meta||={},e._meta.enabled=k,e._meta.primary=o,n.localized=e}try{let i=await _(r?`/cms/admin/content-types/${e}/entries`:`/cms/admin/entries/${e}/${t}`,r?`POST`:`PUT`,n);return ve.current=P$(C),i}catch(e){let t=F$(e instanceof Error?e.message:``);return t&&d.fields.some(e=>e.type===`uid`&&e.name===t)&&le(t),null}}async function De(){let i=await Ee();if(i){if(j===`scheduled`){let n=r?i.id:t;try{await b(`/cms/admin/entries/${e}/${n}/status`,`PATCH`,{status:`draft`}),M(`draft`),P(``),de(!1)}catch{}}else j===`published`&&I(!0);r&&(ye.current=!0,n(`/content/${e}/${i.id}`,{replace:!0}))}}async function Oe(){if(!e)return;let i=t;if(be||r){let e=await Ee();if(!e)return;i=r?e.id:t,r&&(ye.current=!0)}let a=s&&(u===`contributor`||u===``||l!==`authenticated`);try{let t=await b(`/cms/admin/entries/${e}/${i}/status`,`PATCH`,{status:a?`pending`:`published`,review_rejected:!1});M(t?.status??(a?`pending`:`published`)),te(!!t?.review_rejected),B(t?.editor_id??z),ne(t?._editor_first_name??V),re(t?._editor_last_name??H),ae(t?._editor_avatar_url??ie),P(``),I(!1),de(!1),se(!1),r&&n(`/content/${e}/${i}`,{replace:!0})}catch{r&&i&&n(`/content/${e}/${i}`,{replace:!0})}}async function ke(){if(!e||!me||!ge)return;let a=Ey(me,ge,i);if(new Date(a)<=new Date)return;let o=t;if(be||r){let e=await Ee();if(!e)return;o=r?e.id:t,r&&(ye.current=!0)}try{await b(`/cms/admin/entries/${e}/${o}/status`,`PATCH`,{status:`scheduled`,scheduled_for:a}),M(`scheduled`),P(a),de(!1),r&&n(`/content/${e}/${o}`,{replace:!0})}catch{r&&o&&n(`/content/${e}/${o}`,{replace:!0})}}async function Ae(){if(!(!e||!t))try{await b(`/cms/admin/entries/${e}/${t}/status`,`PATCH`,{status:`draft`}),M(`draft`),P(``),I(!1)}catch{}}async function je(){if(!(!e||!t))try{await S(`/cms/admin/entries/${e}/${t}`,`DELETE`),ye.current=!0,n(`/content/${e}`,{replace:!0})}catch{}}async function Me(n){if(!e||!t)return;let r=n===`none`?null:n,i=await b(`/cms/admin/entries/${e}/${t}/status`,`PATCH`,{status:`in_review`,editor_id:r,review_locked_by_editor:p?.review_locked_by_editor??!1});M(i?.status??`in_review`),te(!!i?.review_rejected),B(i?.editor_id??r),ne(i?._editor_first_name??null),re(i?._editor_last_name??null),ae(i?._editor_avatar_url??null),se(!1)}async function Ne(){se(e=>!e)}async function Pe(){if(!e||!t)return;let n=await b(`/cms/admin/entries/${e}/${t}/status`,`PATCH`,{status:`pending`,review_rejected:!0});M(n?.status??`pending`),te(!!n?.review_rejected),se(!1)}let Fe=f||!r&&m,Ie=g||y,Le=c?.permissions??[],Re=Le.includes(`*`)||Le.includes(`entries:write`),ze=Le.includes(`*`)||Le.includes(`entries:delete`),Be=u===`contributor`,Ve=u===`editor`,He=[`admin`,`super admin`].includes(u),Ue=u===`viewer`,We=Be||Ve,Ge=Be&&d?.kind===`single`,Ke=r||String(p?.created_by??``)===String(c?.id??``),qe=s&&Be&&j===`in_review`,Je=s&&(Ve||He)&&!!z&&z===c?.id,Ye=Je&&(j===`pending`||j===`in_review`)&&!ee,Xe=Ue||!Re||Ge||Be&&!Ke||s&&Be&&j===`pending`&&!ee||qe||s&&(Ve||He)&&(j===`pending`||j===`in_review`)&&(!Je||!oe),Ze=ze&&(!We||Ke),Qe=s&&Be&&j===`pending`&&(ee?!0:be)||be||j===`draft`||j===`scheduled`||!s&&j===`pending`||s&&j===`pending`&&!Be||s&&j===`in_review`&&!Be||F,$e=!!(me&&ge),et=s&&Be?`Review`:`Publish`;if(yO(`mod+s`,De,{enabled:!Xe&&!Ie&&(j===`scheduled`?!0:be),label:`Save draft`}),yO(`mod+shift+p`,Oe,{enabled:Qe&&!Ie&&!Xe,label:`Publish`}),Fe)return(0,U.jsxs)(`div`,{className:`flex items-center gap-2 py-12 text-muted-foreground`,children:[(0,U.jsx)(by,{className:`size-4`}),(0,U.jsx)(`span`,{className:`text-sm`,children:`Loading…`})]});if(!d)return null;let tt;tt=j===`scheduled`?(0,U.jsxs)(vw,{variant:`outline`,className:`border-blue-500 text-blue-600`,children:[(0,U.jsx)(Ia,{className:`size-3 mr-1`}),N?`Scheduled · ${wy(N,i)}`:`Scheduled`]}):j===`pending`?ee?(0,U.jsx)(vw,{variant:`destructive`,children:`Pending`}):(0,U.jsx)(vw,{className:`bg-amber-500 text-black hover:bg-amber-500`,children:`Pending`}):j===`in_review`?(0,U.jsx)(vw,{variant:`outline`,children:`In Review`}):j===`published`?(0,U.jsx)(vw,{variant:F?`secondary`:`default`,children:F?`Published (pending changes)`:`Published`}):(0,U.jsx)(vw,{variant:`secondary`,children:`Draft`});let nt=(h??[]).filter(e=>Ve?e.id===c?.id:He?e.id===c?.id||(e.role_name??``).toLowerCase()===`editor`:!1),rt=!r&&s&&(Ve||He)&&(j===`pending`||j===`in_review`),it=s&&!r&&rt,at=s&&!r&&!!z,ot=Ye,st=Ye,ct=V||H;return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(yy,{children:(0,U.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(`h1`,{className:`text-2xl font-bold -mt-2`,children:r?`New entry`:`Edit entry`}),tt]}),(0,U.jsx)(`p`,{className:`text-muted-foreground text-xs mt-1`,children:d.name})]}),(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[!s&&!r&&Ze&&!Ge&&(0,U.jsx)(J,{variant:`ghost`,size:`icon`,className:`text-muted-foreground hover:text-destructive`,onClick:()=>R(!0),disabled:x,children:(0,U.jsx)(qo,{className:`size-4`})}),!s&&!r&&j===`published`&&!Xe&&(0,U.jsxs)(J,{variant:`outline`,onClick:Ae,disabled:Ie,children:[y?(0,U.jsx)(by,{className:`size-4`}):null,`Revert to draft`]}),!s&&!r&&j===`scheduled`&&!Xe&&(0,U.jsxs)(J,{variant:`outline`,onClick:Ae,disabled:Ie,children:[y?(0,U.jsx)(by,{className:`size-4`}):null,`Cancel schedule`]}),it&&(0,U.jsxs)(Ow,{value:z??`none`,onValueChange:Me,disabled:!rt||Ie,children:[(0,U.jsx)(jw,{className:`h-10 min-h-10 max-h-10 w-42 py-0`,children:(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(El,{avatarUrl:ie??null,firstName:V??null,lastName:H??null,className:`size-5`,fallbackClassName:`text-[9px]`}),(0,U.jsx)(Aw,{placeholder:ct||`Assign editor`})]})}),(0,U.jsxs)(Pw,{children:[!Ve&&(0,U.jsx)(Iw,{value:`none`,children:`Unassign`}),nt.map(e=>(0,U.jsx)(Iw,{value:e.id,children:e.first_name||e.last_name||e.id},e.id))]})]}),!rt&&at&&(0,U.jsxs)(`div`,{className:`inline-flex h-10 items-center gap-2 rounded-md border border-input px-3 text-sm`,children:[(0,U.jsx)(El,{avatarUrl:ie??null,firstName:V??null,lastName:H??null,className:`size-5`,fallbackClassName:`text-[9px]`}),(0,U.jsx)(`span`,{children:ct||`Assigned editor`})]}),ot&&(0,U.jsx)(J,{variant:`outline`,size:`icon`,onClick:Ne,disabled:Ie,children:(0,U.jsx)(No,{className:`size-4`})}),st&&(0,U.jsx)(J,{variant:`outline`,size:`icon`,onClick:Pe,disabled:Ie,children:(0,U.jsx)(ns,{className:`size-4`})}),(0,U.jsxs)(J,{variant:`outline`,onClick:De,size:s?`icon`:`default`,disabled:Xe||(j===`scheduled`?Ie:!be||Ie),children:[g?(0,U.jsx)(by,{className:`size-4`}):s?(0,U.jsx)(Lo,{className:`size-4`}):null,!s&&(j===`scheduled`?`Save draft (cancel schedule)`:`Save draft`)]}),j!==`scheduled`&&!(s&&Be)&&(0,U.jsxs)(J,{variant:`outline`,onClick:Te,size:s?`icon`:`default`,disabled:Xe||Ie,children:[(0,U.jsx)(Ia,{className:`size-4`}),!s&&`Schedule`]}),(0,U.jsxs)(J,{onClick:Oe,disabled:Xe||!Qe||Ie,children:[y?(0,U.jsx)(by,{className:`size-4`}):null,j===`scheduled`?s&&Be?`Review`:`Publish now`:j===`published`&&!F?`Republish`:et]})]})]})}),(0,U.jsxs)(`section`,{className:`mt-24`,children:[ue&&!Xe&&(0,U.jsxs)(`div`,{className:`mb-6 flex items-end gap-2 rounded-lg border p-4 bg-muted/30`,children:[(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsx)(X,{children:`Date`}),(0,U.jsxs)(LN,{open:fe,onOpenChange:pe,children:[(0,U.jsx)(RN,{asChild:!0,children:(0,U.jsxs)(J,{variant:`outline`,className:`w-40 justify-between font-normal`,children:[me?VA(me,`MMM d, yyyy`):`Select date`,(0,U.jsx)(Ba,{className:`size-4 opacity-50`})]})}),(0,U.jsx)(zN,{className:`w-auto overflow-hidden p-0`,align:`start`,children:(0,U.jsx)(FN,{mode:`single`,selected:me,captionLayout:`dropdown`,defaultMonth:me??new Date,disabled:{before:new Date},onSelect:e=>{he(e),pe(!1)}})})]})]}),(0,U.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,U.jsxs)(X,{children:[`Time `,(0,U.jsx)(`span`,{className:`text-muted-foreground font-normal`,children:`(24h)`})]}),(0,U.jsx)(Hv,{type:`time`,className:`w-32 appearance-none bg-background [&::-webkit-calendar-picker-indicator]:hidden [&::-webkit-calendar-picker-indicator]:appearance-none`,value:ge,onChange:e=>_e(e.target.value)})]}),(0,U.jsxs)(J,{onClick:ke,disabled:!$e||Ie,children:[y?(0,U.jsx)(by,{className:`size-4`}):null,`Confirm`]}),(0,U.jsx)(J,{variant:`ghost`,onClick:()=>de(!1),children:`Cancel`})]}),(0,U.jsxs)(`div`,{className:`mb-4 flex items-center justify-between`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(nj,{checked:k,onCheckedChange:we,disabled:Xe}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`p`,{className:`text-sm font-medium`,children:`Localization`}),(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Enable per-entry localization`})]})]}),(0,U.jsx)(`div`,{})]}),(0,U.jsx)(`div`,{children:k&&(0,U.jsx)(QA,{value:D,onValueChange:e=>O(e),children:(0,U.jsx)($A,{children:T.map(e=>(0,U.jsx)(ej,{value:e,disabled:Xe,children:e.toUpperCase()},e))})})})]}),(0,U.jsx)(`div`,{className:`grid grid-cols-6 gap-4`,children:d.fields.map(e=>{let n=[`string`,`text`,`richtext`].includes(e.type),r=C.localized&&C.localized[D]?C.localized[D][e.name]:void 0,i=n&&k?r:C[e.name],a=e.type===`uid`&&e.targetField&&k&&[`string`,`text`,`richtext`].includes(d.fields.find(t=>t.name===e.targetField)?.type??``);return(0,U.jsx)(`div`,{className:xO[e.width??`full`],children:(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsxs)(X,{htmlFor:`entry-${e.name}`,className:`capitalize`,children:[e.name.replace(/_/g,` `),e.required&&(0,U.jsx)(`span`,{className:`ml-1 text-destructive`,children:`*`})]}),(0,U.jsx)(M$,{field:e,value:i,onChange:t=>{e.type===`uid`&&ce===e.name&&le(null),n&&k?Ce(D,e.name,t):Se(e.name,t)},allValues:{...C,id:t,__activeLocale:D,__localizationEnabled:k,__defaultLocale:o},disabled:!!a||Xe,errorMessage:e.type===`uid`&&ce===e.name?`${e.name} already exists.`:void 0})]})},e.name)})}),(0,U.jsx)(yw,{open:L,onOpenChange:R,children:(0,U.jsxs)(Cw,{className:`max-w-sm`,children:[(0,U.jsx)(ww,{children:(0,U.jsx)(Ew,{children:`Delete this entry?`})}),(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`This action cannot be undone.`}),(0,U.jsxs)(Tw,{children:[(0,U.jsx)(J,{variant:`outline`,onClick:()=>R(!1),children:`Cancel`}),(0,U.jsxs)(J,{variant:`destructive`,onClick:je,disabled:x,children:[x?(0,U.jsx)(by,{className:`size-4`}):null,`Delete`]})]})]})}),(0,U.jsx)(yw,{open:xe.state===`blocked`,onOpenChange:()=>xe.reset?.(),children:(0,U.jsxs)(Cw,{className:`max-w-sm`,children:[(0,U.jsx)(ww,{children:(0,U.jsx)(Ew,{children:`Unsaved changes`})}),(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Leave without saving?`}),(0,U.jsxs)(Tw,{children:[(0,U.jsx)(J,{variant:`outline`,onClick:()=>xe.reset?.(),children:`Stay`}),(0,U.jsx)(J,{variant:`destructive`,onClick:()=>xe.proceed?.(),children:`Leave`})]})]})})]})]})}function L$({...e}){return(0,U.jsx)(`nav`,{"aria-label":`breadcrumb`,"data-slot":`breadcrumb`,...e})}function R$({className:e,...t}){return(0,U.jsx)(`ol`,{"data-slot":`breadcrumb-list`,className:q(`flex flex-wrap items-center gap-1.5 text-sm break-words text-muted-foreground sm:gap-2.5`,e),...t})}function z$({className:e,...t}){return(0,U.jsx)(`li`,{"data-slot":`breadcrumb-item`,className:q(`inline-flex items-center gap-1.5`,e),...t})}function B$({asChild:e,className:t,...n}){return(0,U.jsx)(e?Fl:`a`,{"data-slot":`breadcrumb-link`,className:q(`transition-colors hover:text-foreground`,t),...n})}function V$({className:e,...t}){return(0,U.jsx)(`span`,{"data-slot":`breadcrumb-page`,role:`link`,"aria-disabled":`true`,"aria-current":`page`,className:q(`font-normal text-foreground`,e),...t})}function H$({children:e,className:t,...n}){return(0,U.jsx)(`li`,{"data-slot":`breadcrumb-separator`,role:`presentation`,"aria-hidden":`true`,className:q(`[&>svg]:size-3.5`,t),...n,children:e??(0,U.jsx)(Ha,{})})}function U$(e){return e?e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`:`—`}function W$(e){return!!e?.startsWith(`image/`)}function G$(e){return!!e?.startsWith(`video/`)}function K$(e){return!!e?.startsWith(`audio/`)}function q$(e){return e===`application/pdf`}function J$(e,t){return e.split(`?`)[0].endsWith(`.m3u8`)||t===`application/x-mpegurl`||t===`application/vnd.apple.mpegurl`}async function Y$(e){if(e.isFile)return new Promise(t=>{e.file(n=>t([{file:n,relativePath:e.fullPath.replace(/^\//,``)}]))});if(e.isDirectory){let t=e.createReader(),n=[];return await new Promise(e=>{let r=()=>{t.readEntries(async t=>{if(t.length===0){e();return}let i=await Promise.all(t.map(Y$));n.push(...i.flat()),r()})};r()}),n}return[]}function X$({url:e}){let t=(0,v.useRef)(null);return(0,v.useEffect)(()=>{let n=t.current;if(!n)return;if(n.canPlayType(`application/vnd.apple.mpegurl`)){n.src=e;return}let r=null;return L(async()=>{let{default:e}=await import(`./hls-0EiSYoTw.js`);return{default:e}},[]).then(({default:t})=>{if(!t.isSupported())return;let i=new t;r=i,i.loadSource(e),i.attachMedia(n)}),()=>{r?.destroy()}},[e]),(0,U.jsx)(`video`,{ref:t,controls:!0,className:`max-h-[70vh] w-full rounded-md bg-black`})}function Z$({item:e}){let t=e.mime_type?.toLowerCase()??null;return W$(t)?(0,U.jsx)(`img`,{src:e.url,alt:e.filename,className:`max-h-full max-w-full rounded-md object-contain`}):J$(e.url,t)?(0,U.jsx)(X$,{url:e.url}):G$(t)?(0,U.jsx)(`video`,{src:e.url,controls:!0,preload:`none`,className:`max-h-[70vh] w-full rounded-md bg-black`}):K$(t)?(0,U.jsxs)(`div`,{className:`flex flex-col items-center gap-4 py-6`,children:[(0,U.jsx)(no,{className:`size-14 text-muted-foreground`}),(0,U.jsx)(`audio`,{src:e.url,controls:!0,className:`w-full`})]}):q$(t)?(0,U.jsx)(`iframe`,{src:e.url,title:e.filename,className:`h-[70vh] w-full rounded-md border`}):(0,U.jsxs)(`div`,{className:`flex flex-col items-center gap-4 py-8 text-center`,children:[(0,U.jsx)(io,{className:`size-14 text-muted-foreground`}),(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e.mime_type??`Unknown type`}),(0,U.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,download:e.filename,children:(0,U.jsxs)(J,{variant:`outline`,size:`sm`,children:[(0,U.jsx)(Qa,{className:`size-4`}),`Download`]})})]})}function Q$({folder:e,onOpen:t,onDelete:n,onRename:r,canDelete:i,canRename:a,selected:o,onToggle:s}){return(0,U.jsxs)(`div`,{className:`group relative flex items-center gap-3 rounded-lg border bg-card px-3 py-2.5 transition-colors cursor-pointer hover:bg-muted/50 ${o?`ring-2 ring-primary`:``}`,onClick:()=>{o||t(e)},children:[(0,U.jsxs)(`div`,{className:`relative shrink-0 size-7 flex items-center justify-center`,children:[(0,U.jsx)(lo,{className:`size-7 text-muted-foreground transition-opacity ${o?`opacity-0`:`group-hover:opacity-0`}`}),(0,U.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center transition-opacity ${o?`opacity-100`:`opacity-0 group-hover:opacity-100`}`,onClick:e=>e.stopPropagation(),children:(0,U.jsx)(EO,{checked:o,onCheckedChange:()=>s(`folder:${e.id}`),"aria-label":`Select folder`})})]}),(0,U.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,U.jsx)(`p`,{className:`text-sm font-bold truncate`,title:e.name,children:e.name}),(0,U.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[e.item_count,` `,e.item_count===1?`item`:`items`]})]}),!o&&(a||i)&&(0,U.jsxs)(P_,{children:[(0,U.jsx)(F_,{asChild:!0,children:(0,U.jsx)(`button`,{className:`shrink-0 opacity-0 group-hover:opacity-100 transition-opacity flex size-6 items-center justify-center rounded-md text-muted-foreground hover:bg-muted hover:text-foreground`,onClick:e=>e.stopPropagation(),children:(0,U.jsx)($a,{className:`size-4`})})}),(0,U.jsxs)(R_,{align:`end`,onClick:e=>e.stopPropagation(),children:[a&&(0,U.jsxs)(z_,{onSelect:()=>r(e),children:[(0,U.jsx)(No,{className:`size-4`}),`Rename`]}),i&&(0,U.jsxs)(z_,{onSelect:()=>n(e),className:`text-destructive focus:text-destructive`,children:[(0,U.jsx)(qo,{className:`size-4`}),`Delete`]})]})]})]})}function $$({item:e,onDelete:t,onPreview:n,canDelete:r,selected:i,onToggle:a}){let o=e.mime_type?.toLowerCase()??null;return(0,U.jsxs)(`div`,{className:`group relative rounded-lg border bg-card overflow-hidden transition-colors ${i?`ring-2 ring-primary`:``}`,children:[(0,U.jsx)(`div`,{className:`aspect-square bg-muted flex items-center justify-center cursor-pointer`,onClick:()=>{i||n(e)},children:W$(o)?(0,U.jsx)(`img`,{src:e.url,alt:e.filename,className:`h-full w-full object-cover`}):G$(o)||J$(e.url,o)?(0,U.jsx)(ro,{className:`size-10 text-muted-foreground`}):K$(o)?(0,U.jsx)(no,{className:`size-10 text-muted-foreground`}):q$(o)?(0,U.jsx)(io,{className:`size-10 text-muted-foreground`}):(0,U.jsx)(ao,{className:`size-10 text-muted-foreground`})}),(0,U.jsx)(`div`,{className:`absolute top-1.5 left-1.5 transition-opacity ${i?`opacity-100`:`opacity-0 group-hover:opacity-100`}`,children:(0,U.jsx)(EO,{checked:i,onCheckedChange:()=>a(e.id),"aria-label":`Select file`,className:`bg-background/80 backdrop-blur-sm`})}),!i&&r&&(0,U.jsx)(`button`,{onClick:()=>t(e),className:`absolute top-1.5 right-1.5 flex size-6 items-center justify-center rounded-md bg-background/80 text-muted-foreground opacity-0 backdrop-blur-sm transition-opacity hover:text-destructive group-hover:opacity-100`,children:(0,U.jsx)(qo,{className:`size-3.5`})}),(0,U.jsxs)(`div`,{className:`p-2`,children:[(0,U.jsx)(`p`,{className:`text-xs font-medium truncate`,title:e.filename,children:e.filename}),(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:U$(e.size)})]})]})}function e1(){let e=(0,v.useRef)(null),{user:t}=ga(),n=t?.permissions??[],r=n.includes(`*`)||n.includes(`media:write`),i=n.includes(`*`)||n.includes(`media:delete`),[a,o]=(0,v.useState)([{id:null,name:`Media`}]),s=a[a.length-1].id,{data:c,loading:l,refetch:u}=wa(`/cms/admin/folders?parent_id=${s??``}`),{data:d,loading:f,refetch:p}=wa(`/cms/admin/media?folder_id=${s??``}`),m=(0,v.useCallback)(()=>{u(),p()},[u,p]),[h,g]=(0,v.useState)(!1),[_,y]=(0,v.useState)(null),[b,x]=(0,v.useState)(new Set),[S,C]=(0,v.useState)(null),[w,T]=(0,v.useState)(``),[E,D]=(0,v.useState)(``),[O,k]=(0,v.useState)(!1),[A,j]=(0,v.useState)(null),[M,N]=(0,v.useState)(null),[P,F]=(0,v.useState)(null),[I,L]=(0,v.useState)(null),[R,ee]=(0,v.useState)(``),[te,z]=(0,v.useState)(!1),[B,V]=(0,v.useState)(``),[ne,H]=(0,v.useState)(!1),[re,ie]=(0,v.useState)(!1),{loading:ae,error:oe,request:se}=Vv(),{loading:ce,error:le,request:ue}=Vv();async function de(e){if(e.some(({relativePath:e})=>e.endsWith(`.m3u8`))){let t=localStorage.getItem(`plank_token`),n=t?{Authorization:`Bearer ${t}`}:{},r=new FormData;for(let{file:t,relativePath:n}of e)r.append(`files`,t,n);s&&r.append(`folder_id`,s),r.append(`bundle`,`true`);let i=await fetch(`/cms/admin/media`,{method:`POST`,headers:n,body:r});if(!i.ok){let e=await i.text(),t=`Upload failed.`;try{t=JSON.parse(e).error??t}catch{}throw Error(t)}}else await Promise.all(e.map(({file:e})=>XZ(e,{folderId:s})))}async function fe(t){if(r&&!(!t||t.length===0)){g(!0),y(null);try{await de(Array.from(t).map(e=>({file:e,relativePath:e.webkitRelativePath||e.name}))),m()}catch(e){y(e instanceof Error?e.message:`Upload failed.`)}finally{g(!1),e.current&&(e.current.value=``)}}}async function pe(e){if(!r)return;e.preventDefault();let t=Array.from(e.dataTransfer.items);if(!t.some(e=>typeof e.webkitGetAsEntry==`function`)){fe(e.dataTransfer.files);return}g(!0),y(null);try{let e=t.map(e=>e.webkitGetAsEntry()).filter(e=>e!==null);await de((await Promise.all(e.map(Y$))).flat()),m()}catch(e){y(e instanceof Error?e.message:`Upload failed.`)}finally{g(!1)}}function me(e){o(t=>[...t,{id:e.id,name:e.name}]),x(new Set)}function he(e){o(t=>t.slice(0,e+1)),x(new Set)}async function ge(){if(r&&B.trim())try{await ue(`/cms/admin/folders`,`POST`,{name:B.trim(),parent_id:s}),z(!1),V(``),u()}catch{}}async function _e(){if(r&&!(!I||!R.trim()))try{await ue(`/cms/admin/folders/${I.id}`,`PATCH`,{name:R.trim()}),L(null),u()}catch{}}async function ve(){if(i&&P)try{await se(`/cms/admin/folders/${P.id}`,`DELETE`),F(null),u()}catch{}}async function ye(){if(i&&M)try{await se(`/cms/admin/media/${M.id}`,`DELETE`),N(null),p()}catch{}}function be(e){x(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}let xe=c?.folders??[],Se=d?.items??[],Ce=[...xe.map(e=>`folder:${e.id}`),...Se.map(e=>e.id)],we=Ce.length>0&&Ce.every(e=>b.has(e)),Te=!we&&Ce.some(e=>b.has(e));async function Ee(){if(!i||re)return;ie(!0);let e=localStorage.getItem(`plank_token`),t=e?{Authorization:`Bearer ${e}`}:{};try{await Promise.all([...[...b].filter(e=>e.startsWith(`folder:`)).map(e=>fetch(`/cms/admin/folders/${e.slice(7)}`,{method:`DELETE`,headers:t})),...[...b].filter(e=>!e.startsWith(`folder:`)).map(e=>fetch(`/cms/admin/media/${e}`,{method:`DELETE`,headers:t}))]),H(!1),x(new Set),m()}finally{ie(!1)}}let De=l||f,Oe=xe.length===0&&Se.length===0;return(0,U.jsxs)(`div`,{children:[(0,U.jsx)(yy,{children:(0,U.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`h1`,{className:`text-2xl font-bold -mt-2`,children:`Media Library`}),(0,U.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:d?`${d.total} file${d.total===1?``:`s`}`:``})]}),(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsxs)(J,{variant:`outline`,onClick:()=>{V(``),z(!0)},disabled:!r,children:[(0,U.jsx)(co,{className:`size-4`}),`New folder`]}),(0,U.jsxs)(J,{onClick:()=>e.current?.click(),disabled:h||!r,children:[h?(0,U.jsx)(by,{className:`size-4`}):(0,U.jsx)(Qo,{className:`size-4`}),h?`Uploading…`:`Upload`]})]})]})}),(0,U.jsxs)(`section`,{className:`mt-24`,children:[a.length>1&&(0,U.jsx)(L$,{className:`mb-4`,children:(0,U.jsx)(R$,{children:a.map((e,t)=>(0,U.jsxs)(v.Fragment,{children:[t>0&&(0,U.jsx)(H$,{}),(0,U.jsx)(z$,{children:t===a.length-1?(0,U.jsx)(V$,{children:t===0?(0,U.jsx)(go,{className:`size-3.5`}):e.name}):(0,U.jsx)(B$,{asChild:!0,children:(0,U.jsx)(`button`,{onClick:()=>he(t),children:t===0?(0,U.jsx)(go,{className:`size-3.5`}):e.name})})})]},t))})}),!Oe&&!De&&(0,U.jsxs)(`div`,{className:`mb-4 flex items-center gap-3 rounded-lg border border-border bg-muted/50 px-4 py-2.5`,children:[(0,U.jsx)(EO,{checked:we?!0:Te?`indeterminate`:!1,onCheckedChange:()=>{x(we?new Set:new Set(Ce))},"aria-label":`Select all`}),b.size>0?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`span`,{className:`text-sm font-medium`,children:[b.size,` selected`]}),(0,U.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,U.jsx)(J,{variant:`outline`,size:`sm`,onClick:()=>x(new Set),children:`Clear`}),i&&(0,U.jsxs)(J,{variant:`destructive`,size:`sm`,disabled:re,onClick:()=>H(!0),children:[(0,U.jsx)(qo,{className:`size-3.5`}),`Delete`]})]})]}):(0,U.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:`Select all`})]}),(0,U.jsx)(`input`,{ref:e,type:`file`,multiple:!0,className:`hidden`,onChange:e=>fe(e.target.files)}),_&&(0,U.jsx)(`p`,{className:`mb-4 text-sm text-destructive`,children:_}),De?(0,U.jsx)(`div`,{className:`flex items-center gap-2 py-16 justify-center text-muted-foreground`,children:(0,U.jsx)(by,{className:`size-5`})}):Oe?(0,U.jsxs)(`div`,{className:`flex flex-col items-center justify-center rounded-lg border border-dashed py-20 text-center cursor-pointer hover:bg-muted/50 transition-colors`,onClick:()=>r&&e.current?.click(),onDragOver:e=>e.preventDefault(),onDrop:pe,children:[(0,U.jsx)(Qo,{className:`size-8 text-muted-foreground mb-3`}),(0,U.jsx)(`p`,{className:`text-sm font-medium`,children:`Drop files or folders here, or click to upload`}),(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:`Images, videos, audio, documents and more`})]}):(0,U.jsxs)(`div`,{className:`flex flex-col gap-6`,onDragOver:e=>e.preventDefault(),onDrop:pe,children:[xe.length>0&&(0,U.jsx)(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4`,children:xe.map(e=>(0,U.jsx)(Q$,{folder:e,onOpen:me,onDelete:F,onRename:e=>{L(e),ee(e.name)},canDelete:i,canRename:r,selected:b.has(`folder:${e.id}`),onToggle:be},e.id))}),Se.length>0&&(0,U.jsx)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-6`,children:Se.map(e=>(0,U.jsx)($$,{item:e,onDelete:N,onPreview:e=>{C(e),T(e.filename),D(e.alt??``),j(null)},canDelete:i,selected:b.has(e.id),onToggle:be},e.id))})]}),(0,U.jsx)(yw,{open:!!S,onOpenChange:e=>{e||(C(null),j(null))},children:(0,U.jsxs)(Cw,{className:`sm:max-w-4xl h-[80vh] flex flex-col`,children:[(0,U.jsx)(ww,{children:(0,U.jsx)(Ew,{className:`truncate pr-6`,title:S?.filename,children:S?.filename})}),(0,U.jsx)(`div`,{className:`flex-1 min-h-0 flex items-center justify-center overflow-hidden`,children:S&&(0,U.jsx)(Z$,{item:S})}),(0,U.jsxs)(`div`,{className:`flex items-center justify-between text-xs text-muted-foreground`,children:[(0,U.jsx)(`span`,{children:S?.mime_type??`—`}),(0,U.jsxs)(`div`,{className:`flex items-center gap-3`,children:[S?.width&&S?.height&&(0,U.jsxs)(`span`,{children:[S.width,` × `,S.height]}),(0,U.jsx)(`span`,{children:U$(S?.size??null)}),(0,U.jsx)(`a`,{href:S?.url,target:`_blank`,rel:`noreferrer`,download:S?.filename,children:(0,U.jsx)(J,{variant:`ghost`,size:`sm`,className:`h-7 px-2`,children:(0,U.jsx)(Qa,{className:`size-3.5`})})})]})]}),S&&W$(S.mime_type)&&(0,U.jsxs)(`form`,{className:`flex flex-col gap-3 border-t pt-3`,onSubmit:async e=>{e.preventDefault(),k(!0),j(null);let t=localStorage.getItem(`plank_token`);try{let e=await fetch(`/cms/admin/media/${S.id}`,{method:`PATCH`,headers:{"Content-Type":`application/json`,...t?{Authorization:`Bearer ${t}`}:{}},body:JSON.stringify({filename:w||S.filename,alt:E||null})});if(!e.ok)throw Error(`Save failed.`);C(await e.json()),p()}catch(e){j(e instanceof Error?e.message:`Save failed.`)}finally{k(!1)}},children:[(0,U.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsx)(X,{className:`text-xs`,children:`Filename`}),(0,U.jsx)(Hv,{value:w,onChange:e=>T(e.target.value),placeholder:S.filename,className:`h-8 text-sm`,disabled:!r})]}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsx)(X,{className:`text-xs`,children:`Alt text`}),(0,U.jsx)(Hv,{value:E,onChange:e=>D(e.target.value),placeholder:`Describe the image…`,className:`h-8 text-sm`,disabled:!r})]})]}),A&&(0,U.jsx)(`p`,{className:`text-xs text-destructive`,children:A}),(0,U.jsx)(`div`,{className:`flex justify-end`,children:(0,U.jsx)(J,{type:`submit`,size:`sm`,disabled:O||!r,children:O?`Saving…`:`Save`})})]})]})}),(0,U.jsx)(yw,{open:te,onOpenChange:e=>{e||z(!1)},children:(0,U.jsxs)(Cw,{className:`sm:max-w-sm`,children:[(0,U.jsx)(ww,{children:(0,U.jsx)(Ew,{children:`New folder`})}),(0,U.jsx)(Hv,{placeholder:`Folder name`,value:B,onChange:e=>V(e.target.value),onKeyDown:e=>{e.key===`Enter`&&ge()},autoFocus:!0}),le&&(0,U.jsx)(`p`,{className:`text-sm text-destructive`,children:le}),(0,U.jsxs)(Tw,{children:[(0,U.jsx)(J,{variant:`outline`,onClick:()=>z(!1),children:`Cancel`}),(0,U.jsx)(J,{onClick:ge,disabled:ce||!B.trim()||!r,children:ce?`Creating…`:`Create`})]})]})}),(0,U.jsx)(yw,{open:!!I,onOpenChange:e=>{e||L(null)},children:(0,U.jsxs)(Cw,{className:`sm:max-w-sm`,children:[(0,U.jsx)(ww,{children:(0,U.jsx)(Ew,{children:`Rename folder`})}),(0,U.jsx)(Hv,{value:R,onChange:e=>ee(e.target.value),onKeyDown:e=>{e.key===`Enter`&&_e()},autoFocus:!0}),le&&(0,U.jsx)(`p`,{className:`text-sm text-destructive`,children:le}),(0,U.jsxs)(Tw,{children:[(0,U.jsx)(J,{variant:`outline`,onClick:()=>L(null),children:`Cancel`}),(0,U.jsx)(J,{onClick:_e,disabled:ce||!R.trim()||!r,children:ce?`Saving…`:`Save`})]})]})}),(0,U.jsx)(yw,{open:!!M,onOpenChange:e=>{e||N(null)},children:(0,U.jsxs)(Cw,{className:`sm:max-w-sm`,children:[(0,U.jsx)(ww,{children:(0,U.jsx)(Ew,{children:`Delete file`})}),(0,U.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Are you sure you want to delete`,` `,(0,U.jsx)(`span`,{className:`font-medium text-foreground`,children:M?.filename}),`? This action cannot be undone.`]}),oe&&(0,U.jsx)(`p`,{className:`text-sm text-destructive`,children:oe}),(0,U.jsxs)(Tw,{children:[(0,U.jsx)(J,{variant:`outline`,onClick:()=>N(null),children:`Cancel`}),(0,U.jsx)(J,{variant:`destructive`,onClick:ye,disabled:ae||!i,children:ae?`Deleting…`:`Delete`})]})]})}),(0,U.jsx)(yw,{open:!!P,onOpenChange:e=>{e||F(null)},children:(0,U.jsxs)(Cw,{className:`sm:max-w-sm`,children:[(0,U.jsx)(ww,{children:(0,U.jsx)(Ew,{children:`Delete folder`})}),(0,U.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Are you sure you want to delete`,` `,(0,U.jsx)(`span`,{className:`font-medium text-foreground`,children:P?.name}),`? The folder must be empty.`]}),oe&&(0,U.jsx)(`p`,{className:`text-sm text-destructive`,children:oe}),(0,U.jsxs)(Tw,{children:[(0,U.jsx)(J,{variant:`outline`,onClick:()=>F(null),children:`Cancel`}),(0,U.jsx)(J,{variant:`destructive`,onClick:ve,disabled:ae||!i,children:ae?`Deleting…`:`Delete`})]})]})}),(0,U.jsx)(yw,{open:ne,onOpenChange:e=>{e||H(!1)},children:(0,U.jsxs)(Cw,{className:`sm:max-w-sm`,children:[(0,U.jsx)(ww,{children:(0,U.jsxs)(Ew,{children:[`Delete `,b.size,` `,b.size===1?`item`:`items`,`?`]})}),(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`This action cannot be undone. Non-empty folders will be skipped.`}),(0,U.jsxs)(Tw,{children:[(0,U.jsx)(J,{variant:`outline`,onClick:()=>H(!1),children:`Cancel`}),(0,U.jsxs)(J,{variant:`destructive`,onClick:Ee,disabled:re,children:[re?(0,U.jsx)(by,{className:`size-4`}):null,`Delete`]})]})]})})]})]})}function t1({items:e}){let{pathname:t}=cr();function n(e){return t===e||t.startsWith(e+`/`)}return(0,U.jsx)(`nav`,{className:`flex flex-col gap-0.5 p-2`,children:e.map(({label:e,to:t,icon:r})=>(0,U.jsxs)(qi,{to:t,className:[`flex items-center gap-2.5 rounded-md px-2.5 py-1.5 text-sm transition-colors`,n(t)?`bg-sidebar-accent text-sidebar-accent-foreground font-medium`:`text-sidebar-foreground hover:bg-sidebar-accent/50 hover:text-sidebar-accent-foreground`].join(` `),children:[r&&(0,U.jsx)(r,{className:`size-3.5 shrink-0`}),(0,U.jsx)(`span`,{className:`truncate`,children:e})]},t))})}function n1(e,t){return e?.permissions.includes(`*`)||e?.permissions.includes(t)||!1}function r1(){let{user:e}=ga(),t=[{label:`Overview`,to:`/settings/overview`,icon:zo,permission:`settings:overview:read`},{label:`Users`,to:`/settings/users`,icon:es,permission:`settings:users:read`},{label:`Roles`,to:`/settings/roles`,icon:Bo,permission:`settings:roles:read`},{label:`API Tokens`,to:`/settings/api-tokens`,icon:bo,permission:`settings:api-tokens:read`},{label:`Webhooks`,to:`/settings/webhooks`,icon:ts,permission:`settings:webhooks:read`}].filter(({permission:t})=>n1(e,t));return(0,U.jsxs)(`div`,{className:`flex flex-col`,children:[(0,U.jsx)(`div`,{className:`border-b border-sidebar-border px-4 py-3`,children:(0,U.jsx)(`p`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:`Settings`})}),(0,U.jsx)(t1,{items:t})]})}function i1(){return qw((0,U.jsx)(r1,{})),(0,U.jsx)(Qr,{})}var a1=`••••••••`;function o1({values:e,onChange:t,disabled:n=!1}){return(0,U.jsxs)(`div`,{className:`space-y-4`,children:[(0,U.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,U.jsx)(X,{htmlFor:`local-uploads-dir`,children:`Upload directory`}),(0,U.jsx)(Hv,{id:`local-uploads-dir`,placeholder:`public/uploads`,value:e[`local.uploads_dir`]??``,onChange:e=>t(`local.uploads_dir`,e.target.value),disabled:n}),(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Path on disk where files are stored. Relative to the server working directory.`})]}),(0,U.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,U.jsx)(X,{htmlFor:`local-public-url`,children:`Public URL`}),(0,U.jsx)(Hv,{id:`local-public-url`,placeholder:`http://localhost:1337`,value:e[`local.public_url`]??``,onChange:e=>t(`local.public_url`,e.target.value),disabled:n}),(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Base URL used to build file URLs. Should match the server's public address.`})]})]})}function s1({id:e,label:t,fieldKey:n,values:r,onChange:i,placeholder:a,disabled:o=!1}){let[s,c]=(0,v.useState)(!1),l=r[n]===a1,u=r[n]??``;return(0,U.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,U.jsx)(X,{htmlFor:e,children:t}),(0,U.jsxs)(`div`,{className:`relative`,children:[(0,U.jsx)(Hv,{id:e,type:s?`text`:`password`,placeholder:l?`Leave blank to keep current value`:a,value:l?``:u,onChange:e=>i(n,e.target.value),className:`pr-9`,disabled:o}),(0,U.jsx)(`button`,{type:`button`,className:`absolute right-2.5 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,onClick:()=>c(e=>!e),tabIndex:-1,disabled:o,children:s?(0,U.jsx)(eo,{className:`size-4`}):(0,U.jsx)(to,{className:`size-4`})})]}),l&&(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`A value is already saved. Enter a new one to replace it.`})]})}function c1({values:e,onChange:t,disabled:n=!1}){return(0,U.jsxs)(`div`,{className:`space-y-4`,children:[(0,U.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,U.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,U.jsx)(X,{htmlFor:`s3-access-key`,children:`Access key ID`}),(0,U.jsx)(Hv,{id:`s3-access-key`,placeholder:`AKIAIOSFODNN7EXAMPLE`,value:e[`s3.access_key_id`]??``,onChange:e=>t(`s3.access_key_id`,e.target.value),disabled:n})]}),(0,U.jsx)(s1,{id:`s3-secret-key`,label:`Secret access key`,fieldKey:`s3.secret_access_key`,values:e,onChange:t,disabled:n})]}),(0,U.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,U.jsx)(X,{htmlFor:`s3-region`,children:`Region`}),(0,U.jsx)(Hv,{id:`s3-region`,placeholder:`us-east-1`,value:e[`s3.region`]??``,onChange:e=>t(`s3.region`,e.target.value),disabled:n})]}),(0,U.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,U.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,U.jsx)(X,{htmlFor:`s3-bucket`,children:`Bucket`}),(0,U.jsx)(Hv,{id:`s3-bucket`,placeholder:`my-bucket`,value:e[`s3.bucket`]??``,onChange:e=>t(`s3.bucket`,e.target.value),disabled:n})]}),(0,U.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,U.jsx)(X,{htmlFor:`s3-path-prefix`,children:`Path prefix`}),(0,U.jsx)(Hv,{id:`s3-path-prefix`,placeholder:`cms/media`,value:e[`s3.path_prefix`]??``,onChange:e=>t(`s3.path_prefix`,e.target.value),disabled:n}),(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Optional. Shared bucket subfolder.`})]})]}),(0,U.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,U.jsx)(X,{htmlFor:`s3-public-url`,children:`Public URL`}),(0,U.jsx)(Hv,{id:`s3-public-url`,placeholder:`https://cdn.example.com`,value:e[`s3.public_url`]??``,onChange:e=>t(`s3.public_url`,e.target.value),disabled:n}),(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Optional. Leave blank to use the default S3 URL.`})]})]})}function l1({values:e,onChange:t,disabled:n=!1}){return(0,U.jsxs)(`div`,{className:`space-y-4`,children:[(0,U.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,U.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,U.jsx)(X,{htmlFor:`r2-access-key`,children:`Access key ID`}),(0,U.jsx)(Hv,{id:`r2-access-key`,placeholder:`R2 access key ID`,value:e[`r2.access_key_id`]??``,onChange:e=>t(`r2.access_key_id`,e.target.value),disabled:n})]}),(0,U.jsx)(s1,{id:`r2-secret-key`,label:`Secret access key`,fieldKey:`r2.secret_access_key`,values:e,onChange:t,disabled:n})]}),(0,U.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,U.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,U.jsx)(X,{htmlFor:`r2-bucket`,children:`Bucket`}),(0,U.jsx)(Hv,{id:`r2-bucket`,placeholder:`my-bucket`,value:e[`r2.bucket`]??``,onChange:e=>t(`r2.bucket`,e.target.value),disabled:n})]}),(0,U.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,U.jsx)(X,{htmlFor:`r2-path-prefix`,children:`Path prefix`}),(0,U.jsx)(Hv,{id:`r2-path-prefix`,placeholder:`cms/media`,value:e[`r2.path_prefix`]??``,onChange:e=>t(`r2.path_prefix`,e.target.value),disabled:n}),(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Optional. Shared bucket subfolder.`})]})]}),(0,U.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,U.jsxs)(X,{htmlFor:`r2-public-url`,children:[`Public URL `,(0,U.jsx)(`span`,{className:`text-destructive`,children:`*`})]}),(0,U.jsx)(Hv,{id:`r2-public-url`,placeholder:`https://assets.example.com`,value:e[`r2.public_url`]??``,onChange:e=>t(`r2.public_url`,e.target.value),disabled:n}),(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Required. R2 does not generate public URLs automatically.`})]})]})}function u1(){let{user:e}=ga(),{data:t,loading:n}=wa(`/cms/admin/settings/media`),{loading:r,error:i,request:a}=Vv(),[o,s]=(0,v.useState)(null),[c,l]=(0,v.useState)(!1),u=o??t??{provider:`local`},d=u.provider||`local`,f=e?.permissions??[],p=f.includes(`*`)||f.includes(`settings:overview:write`);function m(e,t){s({...u,[e]:t})}function h(e){s({...u,provider:e})}async function g(e){e.preventDefault();try{await a(`/cms/admin/settings/media`,`PUT`,u),l(!0),setTimeout(()=>l(!1),2500)}catch{}}return n?(0,U.jsxs)(`div`,{className:`flex items-center gap-2 py-8 text-muted-foreground`,children:[(0,U.jsx)(by,{className:`size-4`}),(0,U.jsx)(`span`,{className:`text-sm`,children:`Loading settings…`})]}):(0,U.jsxs)(`form`,{onSubmit:g,className:`space-y-8`,children:[(0,U.jsxs)(`div`,{className:`border-b pb-4`,children:[(0,U.jsx)(`h2`,{className:`text-2xl font-semibold`,children:`Storage`}),(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Configure where uploaded files are stored.`})]}),(0,U.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,U.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,U.jsx)(X,{htmlFor:`provider`,children:`Storage provider`}),(0,U.jsxs)(Ow,{value:d,onValueChange:e=>h(e),children:[(0,U.jsx)(jw,{id:`provider`,disabled:!p,children:(0,U.jsx)(Aw,{})}),(0,U.jsxs)(Pw,{children:[(0,U.jsx)(Iw,{value:`local`,children:`Local`}),(0,U.jsx)(Iw,{value:`s3`,children:`Amazon S3`}),(0,U.jsx)(Iw,{value:`r2`,children:`Cloudflare R2`})]})]})]}),d===`r2`&&(0,U.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,U.jsx)(X,{htmlFor:`r2-account-id`,children:`Account ID`}),(0,U.jsx)(Hv,{id:`r2-account-id`,placeholder:`023e105f4ecef8ad9ca31a8372d0c353`,value:u[`r2.account_id`]??``,onChange:e=>m(`r2.account_id`,e.target.value),disabled:!p}),(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Found in the Cloudflare dashboard under R2 > Overview.`})]})]}),(0,U.jsxs)(`div`,{className:`border-t pt-6`,children:[d===`local`&&(0,U.jsx)(o1,{values:u,onChange:m,disabled:!p}),d===`s3`&&(0,U.jsx)(c1,{values:u,onChange:m,disabled:!p}),d===`r2`&&(0,U.jsx)(l1,{values:u,onChange:m,disabled:!p})]}),(0,U.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,U.jsx)(J,{type:`submit`,disabled:r||!p,children:r?`Saving…`:`Save`}),c&&(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Changes saved.`}),i&&(0,U.jsx)(`p`,{className:`text-sm text-destructive`,children:i})]})]})}function d1({className:e,...t}){return(0,U.jsx)(`div`,{"data-slot":`card`,className:q(`flex flex-col gap-6 rounded-xl border bg-card py-6 text-card-foreground shadow-sm`,e),...t})}function f1({className:e,...t}){return(0,U.jsx)(`div`,{"data-slot":`card-header`,className:q(`@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-2 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6`,e),...t})}function p1({className:e,...t}){return(0,U.jsx)(`div`,{"data-slot":`card-title`,className:q(`leading-none font-semibold`,e),...t})}function m1({className:e,...t}){return(0,U.jsx)(`div`,{"data-slot":`card-action`,className:q(`col-start-2 row-span-2 row-start-1 self-start justify-self-end`,e),...t})}function h1({className:e,...t}){return(0,U.jsx)(`div`,{"data-slot":`card-content`,className:q(`px-6`,e),...t})}function g1(e){if(!e||typeof document>`u`)return;let t=document.head||document.getElementsByTagName(`head`)[0],n=document.createElement(`style`);n.type=`text/css`,t.appendChild(n),n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e))}var _1=e=>{switch(e){case`success`:return b1;case`info`:return S1;case`warning`:return x1;case`error`:return C1;default:return null}},v1=Array(12).fill(0),y1=({visible:e,className:t})=>v.createElement(`div`,{className:[`sonner-loading-wrapper`,t].filter(Boolean).join(` `),"data-visible":e},v.createElement(`div`,{className:`sonner-spinner`},v1.map((e,t)=>v.createElement(`div`,{className:`sonner-loading-bar`,key:`spinner-bar-${t}`})))),b1=v.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 20 20`,fill:`currentColor`,height:`20`,width:`20`},v.createElement(`path`,{fillRule:`evenodd`,d:`M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z`,clipRule:`evenodd`})),x1=v.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,fill:`currentColor`,height:`20`,width:`20`},v.createElement(`path`,{fillRule:`evenodd`,d:`M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z`,clipRule:`evenodd`})),S1=v.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 20 20`,fill:`currentColor`,height:`20`,width:`20`},v.createElement(`path`,{fillRule:`evenodd`,d:`M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z`,clipRule:`evenodd`})),C1=v.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 20 20`,fill:`currentColor`,height:`20`,width:`20`},v.createElement(`path`,{fillRule:`evenodd`,d:`M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z`,clipRule:`evenodd`})),w1=v.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`12`,height:`12`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`},v.createElement(`line`,{x1:`18`,y1:`6`,x2:`6`,y2:`18`}),v.createElement(`line`,{x1:`6`,y1:`6`,x2:`18`,y2:`18`})),T1=()=>{let[e,t]=v.useState(document.hidden);return v.useEffect(()=>{let e=()=>{t(document.hidden)};return document.addEventListener(`visibilitychange`,e),()=>window.removeEventListener(`visibilitychange`,e)},[]),e},E1=1,D1=new class{constructor(){this.subscribe=e=>(this.subscribers.push(e),()=>{let t=this.subscribers.indexOf(e);this.subscribers.splice(t,1)}),this.publish=e=>{this.subscribers.forEach(t=>t(e))},this.addToast=e=>{this.publish(e),this.toasts=[...this.toasts,e]},this.create=e=>{let{message:t,...n}=e,r=typeof e?.id==`number`||e.id?.length>0?e.id:E1++,i=this.toasts.find(e=>e.id===r),a=e.dismissible===void 0?!0:e.dismissible;return this.dismissedToasts.has(r)&&this.dismissedToasts.delete(r),i?this.toasts=this.toasts.map(n=>n.id===r?(this.publish({...n,...e,id:r,title:t}),{...n,...e,id:r,dismissible:a,title:t}):n):this.addToast({title:t,...n,dismissible:a,id:r}),r},this.dismiss=e=>(e?(this.dismissedToasts.add(e),requestAnimationFrame(()=>this.subscribers.forEach(t=>t({id:e,dismiss:!0})))):this.toasts.forEach(e=>{this.subscribers.forEach(t=>t({id:e.id,dismiss:!0}))}),e),this.message=(e,t)=>this.create({...t,message:e}),this.error=(e,t)=>this.create({...t,message:e,type:`error`}),this.success=(e,t)=>this.create({...t,type:`success`,message:e}),this.info=(e,t)=>this.create({...t,type:`info`,message:e}),this.warning=(e,t)=>this.create({...t,type:`warning`,message:e}),this.loading=(e,t)=>this.create({...t,type:`loading`,message:e}),this.promise=(e,t)=>{if(!t)return;let n;t.loading!==void 0&&(n=this.create({...t,promise:e,type:`loading`,message:t.loading,description:typeof t.description==`function`?void 0:t.description}));let r=Promise.resolve(e instanceof Function?e():e),i=n!==void 0,a,o=r.then(async e=>{if(a=[`resolve`,e],v.isValidElement(e))i=!1,this.create({id:n,type:`default`,message:e});else if(k1(e)&&!e.ok){i=!1;let r=typeof t.error==`function`?await t.error(`HTTP error! status: ${e.status}`):t.error,a=typeof t.description==`function`?await t.description(`HTTP error! status: ${e.status}`):t.description,o=typeof r==`object`&&!v.isValidElement(r)?r:{message:r};this.create({id:n,type:`error`,description:a,...o})}else if(e instanceof Error){i=!1;let r=typeof t.error==`function`?await t.error(e):t.error,a=typeof t.description==`function`?await t.description(e):t.description,o=typeof r==`object`&&!v.isValidElement(r)?r:{message:r};this.create({id:n,type:`error`,description:a,...o})}else if(t.success!==void 0){i=!1;let r=typeof t.success==`function`?await t.success(e):t.success,a=typeof t.description==`function`?await t.description(e):t.description,o=typeof r==`object`&&!v.isValidElement(r)?r:{message:r};this.create({id:n,type:`success`,description:a,...o})}}).catch(async e=>{if(a=[`reject`,e],t.error!==void 0){i=!1;let r=typeof t.error==`function`?await t.error(e):t.error,a=typeof t.description==`function`?await t.description(e):t.description,o=typeof r==`object`&&!v.isValidElement(r)?r:{message:r};this.create({id:n,type:`error`,description:a,...o})}}).finally(()=>{i&&(this.dismiss(n),n=void 0),t.finally==null||t.finally.call(t)}),s=()=>new Promise((e,t)=>o.then(()=>a[0]===`reject`?t(a[1]):e(a[1])).catch(t));return typeof n!=`string`&&typeof n!=`number`?{unwrap:s}:Object.assign(n,{unwrap:s})},this.custom=(e,t)=>{let n=t?.id||E1++;return this.create({jsx:e(n),id:n,...t}),n},this.getActiveToasts=()=>this.toasts.filter(e=>!this.dismissedToasts.has(e.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}},O1=(e,t)=>{let n=t?.id||E1++;return D1.addToast({title:e,...t,id:n}),n},k1=e=>e&&typeof e==`object`&&`ok`in e&&typeof e.ok==`boolean`&&`status`in e&&typeof e.status==`number`,A1=Object.assign(O1,{success:D1.success,info:D1.info,warning:D1.warning,error:D1.error,custom:D1.custom,message:D1.message,promise:D1.promise,dismiss:D1.dismiss,loading:D1.loading},{getHistory:()=>D1.toasts,getToasts:()=>D1.getActiveToasts()});g1(`[data-sonner-toaster][dir=ltr],html[dir=ltr]{--toast-icon-margin-start:-3px;--toast-icon-margin-end:4px;--toast-svg-margin-start:-1px;--toast-svg-margin-end:0px;--toast-button-margin-start:auto;--toast-button-margin-end:0;--toast-close-button-start:0;--toast-close-button-end:unset;--toast-close-button-transform:translate(-35%, -35%)}[data-sonner-toaster][dir=rtl],html[dir=rtl]{--toast-icon-margin-start:4px;--toast-icon-margin-end:-3px;--toast-svg-margin-start:0px;--toast-svg-margin-end:-1px;--toast-button-margin-start:0;--toast-button-margin-end:auto;--toast-close-button-start:unset;--toast-close-button-end:0;--toast-close-button-transform:translate(35%, -35%)}[data-sonner-toaster]{position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1:hsl(0, 0%, 99%);--gray2:hsl(0, 0%, 97.3%);--gray3:hsl(0, 0%, 95.1%);--gray4:hsl(0, 0%, 93%);--gray5:hsl(0, 0%, 90.9%);--gray6:hsl(0, 0%, 88.7%);--gray7:hsl(0, 0%, 85.8%);--gray8:hsl(0, 0%, 78%);--gray9:hsl(0, 0%, 56.1%);--gray10:hsl(0, 0%, 52.3%);--gray11:hsl(0, 0%, 43.5%);--gray12:hsl(0, 0%, 9%);--border-radius:8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:0;z-index:999999999;transition:transform .4s ease}@media (hover:none) and (pointer:coarse){[data-sonner-toaster][data-lifted=true]{transform:none}}[data-sonner-toaster][data-x-position=right]{right:var(--offset-right)}[data-sonner-toaster][data-x-position=left]{left:var(--offset-left)}[data-sonner-toaster][data-x-position=center]{left:50%;transform:translateX(-50%)}[data-sonner-toaster][data-y-position=top]{top:var(--offset-top)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--offset-bottom)}[data-sonner-toast]{--y:translateY(100%);--lift-amount:calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:0;overflow-wrap:anywhere}[data-sonner-toast][data-styled=true]{padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px rgba(0,0,0,.1);width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}[data-sonner-toast]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-y-position=top]{top:0;--y:translateY(-100%);--lift:1;--lift-amount:calc(1 * var(--gap))}[data-sonner-toast][data-y-position=bottom]{bottom:0;--y:translateY(100%);--lift:-1;--lift-amount:calc(var(--lift) * var(--gap))}[data-sonner-toast][data-styled=true] [data-description]{font-weight:400;line-height:1.4;color:#3f3f3f}[data-rich-colors=true][data-sonner-toast][data-styled=true] [data-description]{color:inherit}[data-sonner-toaster][data-sonner-theme=dark] [data-description]{color:#e8e8e8}[data-sonner-toast][data-styled=true] [data-title]{font-weight:500;line-height:1.5;color:inherit}[data-sonner-toast][data-styled=true] [data-icon]{display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}[data-sonner-toast][data-promise=true] [data-icon]>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}[data-sonner-toast][data-styled=true] [data-icon]>*{flex-shrink:0}[data-sonner-toast][data-styled=true] [data-icon] svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}[data-sonner-toast][data-styled=true] [data-content]{display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;font-weight:500;cursor:pointer;outline:0;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}[data-sonner-toast][data-styled=true] [data-button]:focus-visible{box-shadow:0 0 0 2px rgba(0,0,0,.4)}[data-sonner-toast][data-styled=true] [data-button]:first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}[data-sonner-toast][data-styled=true] [data-cancel]{color:var(--normal-text);background:rgba(0,0,0,.08)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-styled=true] [data-cancel]{background:rgba(255,255,255,.3)}[data-sonner-toast][data-styled=true] [data-close-button]{position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);background:var(--normal-bg);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast][data-styled=true] [data-close-button]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-styled=true] [data-disabled=true]{cursor:not-allowed}[data-sonner-toast][data-styled=true]:hover [data-close-button]:hover{background:var(--gray2);border-color:var(--gray5)}[data-sonner-toast][data-swiping=true]::before{content:'';position:absolute;left:-100%;right:-100%;height:100%;z-index:-1}[data-sonner-toast][data-y-position=top][data-swiping=true]::before{bottom:50%;transform:scaleY(3) translateY(50%)}[data-sonner-toast][data-y-position=bottom][data-swiping=true]::before{top:50%;transform:scaleY(3) translateY(-50%)}[data-sonner-toast][data-swiping=false][data-removed=true]::before{content:'';position:absolute;inset:0;transform:scaleY(2)}[data-sonner-toast][data-expanded=true]::after{content:'';position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}[data-sonner-toast][data-mounted=true]{--y:translateY(0);opacity:1}[data-sonner-toast][data-expanded=false][data-front=false]{--scale:var(--toasts-before) * 0.05 + 1;--y:translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}[data-sonner-toast]>*{transition:opacity .4s}[data-sonner-toast][data-x-position=right]{right:0}[data-sonner-toast][data-x-position=left]{left:0}[data-sonner-toast][data-expanded=false][data-front=false][data-styled=true]>*{opacity:0}[data-sonner-toast][data-visible=false]{opacity:0;pointer-events:none}[data-sonner-toast][data-mounted=true][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}[data-sonner-toast][data-removed=true][data-front=true][data-swipe-out=false]{--y:translateY(calc(var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=false]{--y:translateY(40%);opacity:0;transition:transform .5s,opacity .2s}[data-sonner-toast][data-removed=true][data-front=false]::before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y,0)) translateX(var(--swipe-amount-x,0));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width:600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-sonner-theme=light]{--normal-bg:#fff;--normal-border:var(--gray4);--normal-text:var(--gray12);--success-bg:hsl(143, 85%, 96%);--success-border:hsl(145, 92%, 87%);--success-text:hsl(140, 100%, 27%);--info-bg:hsl(208, 100%, 97%);--info-border:hsl(221, 91%, 93%);--info-text:hsl(210, 92%, 45%);--warning-bg:hsl(49, 100%, 97%);--warning-border:hsl(49, 91%, 84%);--warning-text:hsl(31, 92%, 45%);--error-bg:hsl(359, 100%, 97%);--error-border:hsl(359, 100%, 94%);--error-text:hsl(360, 100%, 45%)}[data-sonner-toaster][data-sonner-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg:#000;--normal-border:hsl(0, 0%, 20%);--normal-text:var(--gray1)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg:#fff;--normal-border:var(--gray3);--normal-text:var(--gray12)}[data-sonner-toaster][data-sonner-theme=dark]{--normal-bg:#000;--normal-bg-hover:hsl(0, 0%, 12%);--normal-border:hsl(0, 0%, 20%);--normal-border-hover:hsl(0, 0%, 25%);--normal-text:var(--gray1);--success-bg:hsl(150, 100%, 6%);--success-border:hsl(147, 100%, 12%);--success-text:hsl(150, 86%, 65%);--info-bg:hsl(215, 100%, 6%);--info-border:hsl(223, 43%, 17%);--info-text:hsl(216, 87%, 65%);--warning-bg:hsl(64, 100%, 6%);--warning-border:hsl(60, 100%, 9%);--warning-text:hsl(46, 87%, 65%);--error-bg:hsl(358, 76%, 10%);--error-border:hsl(357, 89%, 16%);--error-text:hsl(358, 100%, 81%)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size:16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:first-child{animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}100%{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}100%{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}100%{opacity:.15}}@media (prefers-reduced-motion){.sonner-loading-bar,[data-sonner-toast],[data-sonner-toast]>*{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}`);function j1(e){return e.label!==void 0}var M1=3,N1=`24px`,P1=`16px`,F1=4e3,I1=356,L1=14,R1=45,z1=200;function B1(...e){return e.filter(Boolean).join(` `)}function V1(e){let[t,n]=e.split(`-`),r=[];return t&&r.push(t),n&&r.push(n),r}var H1=e=>{let{invert:t,toast:n,unstyled:r,interacting:i,setHeights:a,visibleToasts:o,heights:s,index:c,toasts:l,expanded:u,removeToast:d,defaultRichColors:f,closeButton:p,style:m,cancelButtonStyle:h,actionButtonStyle:g,className:_=``,descriptionClassName:y=``,duration:b,position:x,gap:S,expandByDefault:C,classNames:w,icons:T,closeButtonAriaLabel:E=`Close toast`}=e,[D,O]=v.useState(null),[k,A]=v.useState(null),[j,M]=v.useState(!1),[N,P]=v.useState(!1),[F,I]=v.useState(!1),[L,R]=v.useState(!1),[ee,te]=v.useState(!1),[z,B]=v.useState(0),[V,ne]=v.useState(0),H=v.useRef(n.duration||b||F1),re=v.useRef(null),ie=v.useRef(null),ae=c===0,oe=c+1<=o,se=n.type,ce=n.dismissible!==!1,le=n.className||``,ue=n.descriptionClassName||``,de=v.useMemo(()=>s.findIndex(e=>e.toastId===n.id)||0,[s,n.id]),fe=v.useMemo(()=>n.closeButton??p,[n.closeButton,p]),pe=v.useMemo(()=>n.duration||b||F1,[n.duration,b]),me=v.useRef(0),he=v.useRef(0),ge=v.useRef(0),_e=v.useRef(null),[ve,ye]=x.split(`-`),be=v.useMemo(()=>s.reduce((e,t,n)=>n>=de?e:e+t.height,0),[s,de]),xe=T1(),Se=n.invert||t,Ce=se===`loading`;he.current=v.useMemo(()=>de*S+be,[de,be]),v.useEffect(()=>{H.current=pe},[pe]),v.useEffect(()=>{M(!0)},[]),v.useEffect(()=>{let e=ie.current;if(e){let t=e.getBoundingClientRect().height;return ne(t),a(e=>[{toastId:n.id,height:t,position:n.position},...e]),()=>a(e=>e.filter(e=>e.toastId!==n.id))}},[a,n.id]),v.useLayoutEffect(()=>{if(!j)return;let e=ie.current,t=e.style.height;e.style.height=`auto`;let r=e.getBoundingClientRect().height;e.style.height=t,ne(r),a(e=>e.find(e=>e.toastId===n.id)?e.map(e=>e.toastId===n.id?{...e,height:r}:e):[{toastId:n.id,height:r,position:n.position},...e])},[j,n.title,n.description,a,n.id,n.jsx,n.action,n.cancel]);let we=v.useCallback(()=>{P(!0),B(he.current),a(e=>e.filter(e=>e.toastId!==n.id)),setTimeout(()=>{d(n)},z1)},[n,d,a,he]);v.useEffect(()=>{if(n.promise&&se===`loading`||n.duration===1/0||n.type===`loading`)return;let e;return u||i||xe?(()=>{if(ge.current<me.current){let e=new Date().getTime()-me.current;H.current-=e}ge.current=new Date().getTime()})():H.current!==1/0&&(me.current=new Date().getTime(),e=setTimeout(()=>{n.onAutoClose==null||n.onAutoClose.call(n,n),we()},H.current)),()=>clearTimeout(e)},[u,i,n,se,xe,we]),v.useEffect(()=>{n.delete&&(we(),n.onDismiss==null||n.onDismiss.call(n,n))},[we,n.delete]);function Te(){return T?.loading?v.createElement(`div`,{className:B1(w?.loader,n?.classNames?.loader,`sonner-loader`),"data-visible":se===`loading`},T.loading):v.createElement(y1,{className:B1(w?.loader,n?.classNames?.loader),visible:se===`loading`})}let Ee=n.icon||T?.[se]||_1(se);return v.createElement(`li`,{tabIndex:0,ref:ie,className:B1(_,le,w?.toast,n?.classNames?.toast,w?.default,w?.[se],n?.classNames?.[se]),"data-sonner-toast":``,"data-rich-colors":n.richColors??f,"data-styled":!(n.jsx||n.unstyled||r),"data-mounted":j,"data-promise":!!n.promise,"data-swiped":ee,"data-removed":N,"data-visible":oe,"data-y-position":ve,"data-x-position":ye,"data-index":c,"data-front":ae,"data-swiping":F,"data-dismissible":ce,"data-type":se,"data-invert":Se,"data-swipe-out":L,"data-swipe-direction":k,"data-expanded":!!(u||C&&j),"data-testid":n.testId,style:{"--index":c,"--toasts-before":c,"--z-index":l.length-c,"--offset":`${N?z:he.current}px`,"--initial-height":C?`auto`:`${V}px`,...m,...n.style},onDragEnd:()=>{I(!1),O(null),_e.current=null},onPointerDown:e=>{e.button!==2&&(Ce||!ce||(re.current=new Date,B(he.current),e.target.setPointerCapture(e.pointerId),e.target.tagName!==`BUTTON`&&(I(!0),_e.current={x:e.clientX,y:e.clientY})))},onPointerUp:()=>{if(L||!ce)return;_e.current=null;let e=Number(ie.current?.style.getPropertyValue(`--swipe-amount-x`).replace(`px`,``)||0),t=Number(ie.current?.style.getPropertyValue(`--swipe-amount-y`).replace(`px`,``)||0),r=new Date().getTime()-re.current?.getTime(),i=D===`x`?e:t,a=Math.abs(i)/r;if(Math.abs(i)>=R1||a>.11){B(he.current),n.onDismiss==null||n.onDismiss.call(n,n),A(D===`x`?e>0?`right`:`left`:t>0?`down`:`up`),we(),R(!0);return}else{var o,s;(o=ie.current)==null||o.style.setProperty(`--swipe-amount-x`,`0px`),(s=ie.current)==null||s.style.setProperty(`--swipe-amount-y`,`0px`)}te(!1),I(!1),O(null)},onPointerMove:t=>{var n,r;if(!_e.current||!ce||window.getSelection()?.toString().length>0)return;let i=t.clientY-_e.current.y,a=t.clientX-_e.current.x,o=e.swipeDirections??V1(x);!D&&(Math.abs(a)>1||Math.abs(i)>1)&&O(Math.abs(a)>Math.abs(i)?`x`:`y`);let s={x:0,y:0},c=e=>1/(1.5+Math.abs(e)/20);if(D===`y`){if(o.includes(`top`)||o.includes(`bottom`))if(o.includes(`top`)&&i<0||o.includes(`bottom`)&&i>0)s.y=i;else{let e=i*c(i);s.y=Math.abs(e)<Math.abs(i)?e:i}}else if(D===`x`&&(o.includes(`left`)||o.includes(`right`)))if(o.includes(`left`)&&a<0||o.includes(`right`)&&a>0)s.x=a;else{let e=a*c(a);s.x=Math.abs(e)<Math.abs(a)?e:a}(Math.abs(s.x)>0||Math.abs(s.y)>0)&&te(!0),(n=ie.current)==null||n.style.setProperty(`--swipe-amount-x`,`${s.x}px`),(r=ie.current)==null||r.style.setProperty(`--swipe-amount-y`,`${s.y}px`)}},fe&&!n.jsx&&se!==`loading`?v.createElement(`button`,{"aria-label":E,"data-disabled":Ce,"data-close-button":!0,onClick:Ce||!ce?()=>{}:()=>{we(),n.onDismiss==null||n.onDismiss.call(n,n)},className:B1(w?.closeButton,n?.classNames?.closeButton)},T?.close??w1):null,(se||n.icon||n.promise)&&n.icon!==null&&(T?.[se]!==null||n.icon)?v.createElement(`div`,{"data-icon":``,className:B1(w?.icon,n?.classNames?.icon)},n.promise||n.type===`loading`&&!n.icon?n.icon||Te():null,n.type===`loading`?null:Ee):null,v.createElement(`div`,{"data-content":``,className:B1(w?.content,n?.classNames?.content)},v.createElement(`div`,{"data-title":``,className:B1(w?.title,n?.classNames?.title)},n.jsx?n.jsx:typeof n.title==`function`?n.title():n.title),n.description?v.createElement(`div`,{"data-description":``,className:B1(y,ue,w?.description,n?.classNames?.description)},typeof n.description==`function`?n.description():n.description):null),v.isValidElement(n.cancel)?n.cancel:n.cancel&&j1(n.cancel)?v.createElement(`button`,{"data-button":!0,"data-cancel":!0,style:n.cancelButtonStyle||h,onClick:e=>{j1(n.cancel)&&ce&&(n.cancel.onClick==null||n.cancel.onClick.call(n.cancel,e),we())},className:B1(w?.cancelButton,n?.classNames?.cancelButton)},n.cancel.label):null,v.isValidElement(n.action)?n.action:n.action&&j1(n.action)?v.createElement(`button`,{"data-button":!0,"data-action":!0,style:n.actionButtonStyle||g,onClick:e=>{j1(n.action)&&(n.action.onClick==null||n.action.onClick.call(n.action,e),!e.defaultPrevented&&we())},className:B1(w?.actionButton,n?.classNames?.actionButton)},n.action.label):null)};function U1(){if(typeof window>`u`||typeof document>`u`)return`ltr`;let e=document.documentElement.getAttribute(`dir`);return e===`auto`||!e?window.getComputedStyle(document.documentElement).direction:e}function W1(e,t){let n={};return[e,t].forEach((e,t)=>{let r=t===1,i=r?`--mobile-offset`:`--offset`,a=r?P1:N1;function o(e){[`top`,`right`,`bottom`,`left`].forEach(t=>{n[`${i}-${t}`]=typeof e==`number`?`${e}px`:e})}typeof e==`number`||typeof e==`string`?o(e):typeof e==`object`?[`top`,`right`,`bottom`,`left`].forEach(t=>{e[t]===void 0?n[`${i}-${t}`]=a:n[`${i}-${t}`]=typeof e[t]==`number`?`${e[t]}px`:e[t]}):o(a)}),n}var G1=v.forwardRef(function(e,t){let{id:n,invert:r,position:i=`bottom-right`,hotkey:a=[`altKey`,`KeyT`],expand:o,closeButton:s,className:c,offset:l,mobileOffset:u,theme:d=`light`,richColors:f,duration:p,style:m,visibleToasts:h=M1,toastOptions:g,dir:_=U1(),gap:y=L1,icons:b,containerAriaLabel:x=`Notifications`}=e,[S,C]=v.useState([]),w=v.useMemo(()=>n?S.filter(e=>e.toasterId===n):S.filter(e=>!e.toasterId),[S,n]),T=v.useMemo(()=>Array.from(new Set([i].concat(w.filter(e=>e.position).map(e=>e.position)))),[w,i]),[E,D]=v.useState([]),[O,k]=v.useState(!1),[A,j]=v.useState(!1),[M,P]=v.useState(d===`system`?typeof window<`u`&&window.matchMedia&&window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`:d),F=v.useRef(null),I=a.join(`+`).replace(/Key/g,``).replace(/Digit/g,``),L=v.useRef(null),R=v.useRef(!1),ee=v.useCallback(e=>{C(t=>(t.find(t=>t.id===e.id)?.delete||D1.dismiss(e.id),t.filter(({id:t})=>t!==e.id)))},[]);return v.useEffect(()=>D1.subscribe(e=>{if(e.dismiss){requestAnimationFrame(()=>{C(t=>t.map(t=>t.id===e.id?{...t,delete:!0}:t))});return}setTimeout(()=>{N.flushSync(()=>{C(t=>{let n=t.findIndex(t=>t.id===e.id);return n===-1?[e,...t]:[...t.slice(0,n),{...t[n],...e},...t.slice(n+1)]})})})}),[S]),v.useEffect(()=>{if(d!==`system`){P(d);return}if(d===`system`&&(window.matchMedia&&window.matchMedia(`(prefers-color-scheme: dark)`).matches?P(`dark`):P(`light`)),typeof window>`u`)return;let e=window.matchMedia(`(prefers-color-scheme: dark)`);try{e.addEventListener(`change`,({matches:e})=>{P(e?`dark`:`light`)})}catch{e.addListener(({matches:e})=>{try{P(e?`dark`:`light`)}catch(e){console.error(e)}})}},[d]),v.useEffect(()=>{S.length<=1&&k(!1)},[S]),v.useEffect(()=>{let e=e=>{if(a.every(t=>e[t]||e.code===t)){var t;k(!0),(t=F.current)==null||t.focus()}e.code===`Escape`&&(document.activeElement===F.current||F.current?.contains(document.activeElement))&&k(!1)};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[a]),v.useEffect(()=>{if(F.current)return()=>{L.current&&(L.current.focus({preventScroll:!0}),L.current=null,R.current=!1)}},[F.current]),v.createElement(`section`,{ref:t,"aria-label":`${x} ${I}`,tabIndex:-1,"aria-live":`polite`,"aria-relevant":`additions text`,"aria-atomic":`false`,suppressHydrationWarning:!0},T.map((t,n)=>{let[i,a]=t.split(`-`);return w.length?v.createElement(`ol`,{key:t,dir:_===`auto`?U1():_,tabIndex:-1,ref:F,className:c,"data-sonner-toaster":!0,"data-sonner-theme":M,"data-y-position":i,"data-x-position":a,style:{"--front-toast-height":`${E[0]?.height||0}px`,"--width":`${I1}px`,"--gap":`${y}px`,...m,...W1(l,u)},onBlur:e=>{R.current&&!e.currentTarget.contains(e.relatedTarget)&&(R.current=!1,L.current&&=(L.current.focus({preventScroll:!0}),null))},onFocus:e=>{e.target instanceof HTMLElement&&e.target.dataset.dismissible===`false`||R.current||(R.current=!0,L.current=e.relatedTarget)},onMouseEnter:()=>k(!0),onMouseMove:()=>k(!0),onMouseLeave:()=>{A||k(!1)},onDragEnd:()=>k(!1),onPointerDown:e=>{e.target instanceof HTMLElement&&e.target.dataset.dismissible===`false`||j(!0)},onPointerUp:()=>j(!1)},w.filter(e=>!e.position&&n===0||e.position===t).map((n,i)=>v.createElement(H1,{key:n.id,icons:b,index:i,toast:n,defaultRichColors:f,duration:g?.duration??p,className:g?.className,descriptionClassName:g?.descriptionClassName,invert:r,visibleToasts:h,closeButton:g?.closeButton??s,interacting:A,position:t,style:g?.style,unstyled:g?.unstyled,classNames:g?.classNames,cancelButtonStyle:g?.cancelButtonStyle,actionButtonStyle:g?.actionButtonStyle,closeButtonAriaLabel:g?.closeButtonAriaLabel,removeToast:ee,toasts:w.filter(e=>e.position==n.position),heights:E.filter(e=>e.position==n.position),setHeights:D,expandByDefault:o,gap:y,expanded:O,swipeDirections:e.swipeDirections}))):null}))}),K1={name:`@plank-cms/admin`,version:`0.17.3`,type:`module`,scripts:{build:`vite build`,dev:`vite`,lint:`eslint src/`},dependencies:{"@dnd-kit/core":`6.3.1`,"@dnd-kit/sortable":`10.0.0`,"@dnd-kit/utilities":`3.2.2`,"@radix-ui/react-avatar":`1.1.11`,"@radix-ui/react-checkbox":`1.3.3`,"@radix-ui/react-dialog":`1.1.15`,"@radix-ui/react-dropdown-menu":`2.1.16`,"@radix-ui/react-label":`2.1.8`,"@radix-ui/react-popover":`1.1.15`,"@radix-ui/react-select":`2.2.6`,"@radix-ui/react-separator":`1.1.8`,"@radix-ui/react-slot":`1.2.4`,"@radix-ui/react-switch":`1.2.6`,"@radix-ui/react-tabs":`1.1.13`,"@radix-ui/react-tooltip":`1.2.8`,"@tanstack/react-table":`8.21.3`,"@tiptap/extension-image":`3.22.4`,"@tiptap/pm":`3.22.4`,"@tiptap/react":`3.22.4`,"@tiptap/starter-kit":`3.22.4`,"class-variance-authority":`0.7.1`,clsx:`2.1.1`,cmdk:`1.1.1`,"date-fns":`4.1.0`,"hls.js":`1.6.16`,"input-otp":`1.4.2`,"lucide-react":`1.8.0`,"next-themes":`0.4.6`,"qrcode.react":`4.2.0`,"radix-ui":`1.4.3`,react:`19.2.5`,"react-day-picker":`9.14.0`,"react-dom":`19.2.5`,"react-router-dom":`7.14.1`,sonner:`2.0.7`,"tailwind-merge":`3.5.0`},devDependencies:{"@tailwindcss/vite":`4.2.3`,"@types/react":`19.2.14`,"@types/react-dom":`19.2.3`,"@types/react-router-dom":`5.3.3`,"@vitejs/plugin-react":`6.0.1`,tailwindcss:`4.2.3`,vite:`8.0.9`}},q1=[{value:`UTC`,label:`UTC — Coordinated Universal Time`},{value:`America/New_York`,label:`America/New_York — Eastern Time (UTC-5/4)`},{value:`America/Chicago`,label:`America/Chicago — Central Time (UTC-6/5)`},{value:`America/Denver`,label:`America/Denver — Mountain Time (UTC-7/6)`},{value:`America/Los_Angeles`,label:`America/Los_Angeles — Pacific Time (UTC-8/7)`},{value:`America/Anchorage`,label:`America/Anchorage — Alaska Time (UTC-9/8)`},{value:`America/Honolulu`,label:`America/Honolulu — Hawaii Time (UTC-10)`},{value:`America/Mexico_City`,label:`America/Mexico_City — Mexico City (UTC-6/5)`},{value:`America/El_Salvador`,label:`America/El_Salvador — El Salvador (UTC-6)`},{value:`America/Bogota`,label:`America/Bogota — Colombia Time (UTC-5)`},{value:`America/Lima`,label:`America/Lima — Peru Time (UTC-5)`},{value:`America/Santiago`,label:`America/Santiago — Chile Time (UTC-4/3)`},{value:`America/Argentina/Buenos_Aires`,label:`America/Buenos_Aires — Argentina (UTC-3)`},{value:`America/Sao_Paulo`,label:`America/Sao_Paulo — Brasília Time (UTC-3/2)`},{value:`Atlantic/Reykjavik`,label:`Atlantic/Reykjavik — Iceland (UTC+0)`},{value:`Europe/London`,label:`Europe/London — GMT/BST (UTC+0/1)`},{value:`Europe/Paris`,label:`Europe/Paris — Central European Time (UTC+1/2)`},{value:`Europe/Berlin`,label:`Europe/Berlin — Central European Time (UTC+1/2)`},{value:`Europe/Madrid`,label:`Europe/Madrid — Central European Time (UTC+1/2)`},{value:`Europe/Rome`,label:`Europe/Rome — Central European Time (UTC+1/2)`},{value:`Europe/Helsinki`,label:`Europe/Helsinki — Eastern European Time (UTC+2/3)`},{value:`Europe/Istanbul`,label:`Europe/Istanbul — Turkey Time (UTC+3)`},{value:`Europe/Moscow`,label:`Europe/Moscow — Moscow Standard Time (UTC+3)`},{value:`Asia/Dubai`,label:`Asia/Dubai — Gulf Standard Time (UTC+4)`},{value:`Asia/Karachi`,label:`Asia/Karachi — Pakistan Standard Time (UTC+5)`},{value:`Asia/Kolkata`,label:`Asia/Kolkata — India Standard Time (UTC+5:30)`},{value:`Asia/Dhaka`,label:`Asia/Dhaka — Bangladesh Standard Time (UTC+6)`},{value:`Asia/Bangkok`,label:`Asia/Bangkok — Indochina Time (UTC+7)`},{value:`Asia/Singapore`,label:`Asia/Singapore — Singapore Time (UTC+8)`},{value:`Asia/Shanghai`,label:`Asia/Shanghai — China Standard Time (UTC+8)`},{value:`Asia/Tokyo`,label:`Asia/Tokyo — Japan Standard Time (UTC+9)`},{value:`Asia/Seoul`,label:`Asia/Seoul — Korea Standard Time (UTC+9)`},{value:`Australia/Sydney`,label:`Australia/Sydney — AEST/AEDT (UTC+10/11)`},{value:`Australia/Melbourne`,label:`Australia/Melbourne — AEST/AEDT (UTC+10/11)`},{value:`Pacific/Auckland`,label:`Pacific/Auckland — New Zealand (UTC+12/13)`}];function J1(){let{user:e}=ga(),{data:t,loading:n}=wa(`/cms/admin/settings/general`),{request:r,loading:i}=Vv(),{request:a,loading:o}=Vv(),{request:s,loading:c}=Vv(),{refreshSettings:l}=ya(),[u,d]=(0,v.useState)(`UTC`),[f,p]=(0,v.useState)([]),[m,h]=(0,v.useState)(`en`),[g,_]=(0,v.useState)(``),[y,b]=(0,v.useState)(!1),x=e?.permissions??[],S=x.includes(`*`)||x.includes(`settings:overview:write`);(0,v.useEffect)(()=>{if(t?.timezone&&d(t.timezone),t?.locales)try{let e=JSON.parse(t.locales);Array.isArray(e)&&p(e)}catch{p((t.locales||``).split(`,`).map(e=>e.trim()).filter(Boolean))}t?.default_locale&&h(t.default_locale),b(String(t?.editorial_mode??`false`).toLowerCase()===`true`)},[t]);async function C(){try{await a(`/cms/admin/settings/general`,`PUT`,{locales:JSON.stringify(f),default_locale:m}),l(),A1.success(`Locales saved`)}catch{A1.error(`Could not save locales`)}}return n?(0,U.jsx)(by,{}):(0,U.jsxs)(`div`,{className:`space-y-6`,children:[(0,U.jsx)(d1,{children:(0,U.jsxs)(h1,{className:`flex items-center gap-4 py-2`,children:[(0,U.jsx)(`img`,{src:`/admin/plank-logo-w.svg`,alt:`Plank CMS`,className:`h-10 w-auto`}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`p`,{className:`font-bold`,children:`Plank CMS by AM25`}),(0,U.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Version `,K1.version]})]})]})}),(0,U.jsxs)(`div`,{className:`border-b pb-4`,children:[(0,U.jsx)(`h2`,{className:`text-2xl font-semibold`,children:`Commons`}),(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`General settings that apply across the CMS.`})]}),(0,U.jsxs)(`div`,{className:`space-y-2`,children:[(0,U.jsx)(X,{htmlFor:`timezone`,children:`Timezone`}),(0,U.jsxs)(Ow,{value:u,onValueChange:e=>{d(e),(async()=>{try{await r(`/cms/admin/settings/general`,`PUT`,{timezone:e}),l(),A1.success(`Timezone saved`)}catch{A1.error(`Could not save timezone`)}})()},children:[(0,U.jsx)(jw,{id:`timezone`,className:`w-full`,disabled:!S,children:(0,U.jsx)(Aw,{})}),(0,U.jsx)(Pw,{className:`max-h-72`,children:q1.map(e=>(0,U.jsx)(Iw,{value:e.value,children:e.label},e.value))})]}),(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Used to display dates and times across the admin panel.`}),i&&(0,U.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Saving…`})]})]}),(0,U.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 md:grid-cols-2`,children:[(0,U.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,U.jsx)(X,{children:`Locales`}),(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(Hv,{placeholder:`E.g. "en"`,value:g,onChange:e=>_(e.target.value),className:`h-9 w-full`,disabled:!S}),(0,U.jsx)(J,{variant:`outline`,className:`h-9`,disabled:!S,onClick:()=>{let e=g.trim().toLowerCase();e&&(f.includes(e)||p(t=>[...t,e]),_(``))},children:`Add`})]}),(0,U.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:f.map(e=>(0,U.jsx)(J,{variant:`ghost`,size:`sm`,onClick:()=>p(t=>t.filter(t=>t!==e)),disabled:!S,children:e.toUpperCase()},e))})]}),(0,U.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,U.jsx)(X,{htmlFor:`default-locale`,children:`Default locale`}),(0,U.jsxs)(Ow,{value:m,onValueChange:h,children:[(0,U.jsx)(jw,{id:`default-locale`,className:`w-full`,disabled:!S,children:(0,U.jsx)(Aw,{})}),(0,U.jsx)(Pw,{className:`max-h-72`,children:f.length===0?(0,U.jsx)(Iw,{value:m,children:m}):f.map(e=>(0,U.jsx)(Iw,{value:e,children:e.toUpperCase()},e))})]}),(0,U.jsx)(`div`,{className:`pt-2 flex justify-end`,children:(0,U.jsx)(J,{variant:`outline`,onClick:C,disabled:o||!S,children:o?`Saving…`:`Save`})})]})]}),(0,U.jsx)(WO,{}),(0,U.jsxs)(`div`,{className:`flex items-center justify-between rounded-md border p-3`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(X,{htmlFor:`editorial-mode`,children:`Editorial Mode`}),(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Enables Editor and Viewer workflows for editorial review.`})]}),(0,U.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,U.jsx)(nj,{id:`editorial-mode`,checked:y,onCheckedChange:e=>{b(e),(async()=>{try{await s(`/cms/admin/settings/general`,`PUT`,{editorial_mode:String(e)}),l(),A1.success(`Editorial Mode saved`)}catch{A1.error(`Could not save Editorial Mode`)}})()},disabled:!S}),c&&(0,U.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Saving…`})]})]})]})}function Y1(){return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(yy,{children:[(0,U.jsx)(`h1`,{className:`text-2xl font-bold -mt-2`,children:`Overview`}),(0,U.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`General configuration for your CMS instance.`})]}),(0,U.jsxs)(QA,{defaultValue:`general`,className:`mt-24`,children:[(0,U.jsxs)($A,{className:`mb-6`,children:[(0,U.jsx)(ej,{value:`general`,children:`General`}),(0,U.jsx)(ej,{value:`media`,children:`Media Library`})]}),(0,U.jsx)(tj,{value:`general`,children:(0,U.jsx)(J1,{})}),(0,U.jsx)(tj,{value:`media`,children:(0,U.jsx)(u1,{})})]})]})}function X1(e,t){return typeof e==`function`?e(t):e}function Z1(e,t){return n=>{t.setState(t=>({...t,[e]:X1(n,t[e])}))}}function Q1(e){return e instanceof Function}function $1(e){return Array.isArray(e)&&e.every(e=>typeof e==`number`)}function e0(e,t){let n=[],r=e=>{e.forEach(e=>{n.push(e);let i=t(e);i!=null&&i.length&&r(i)})};return r(e),n}function t0(e,t,n){let r=[],i;return a=>{let o;n.key&&n.debug&&(o=Date.now());let s=e(a);if(!(s.length!==r.length||s.some((e,t)=>r[t]!==e)))return i;r=s;let c;if(n.key&&n.debug&&(c=Date.now()),i=t(...s),n==null||n.onChange==null||n.onChange(i),n.key&&n.debug&&n!=null&&n.debug()){let e=Math.round((Date.now()-o)*100)/100,t=Math.round((Date.now()-c)*100)/100,r=t/16,i=(e,t)=>{for(e=String(e);e.length<t;)e=` `+e;return e};console.info(`%c⏱ ${i(t,5)} /${i(e,5)} ms`,`
220
220
  font-size: .6rem;
221
221
  font-weight: bold;
222
- color: hsl(${Math.max(0,Math.min(120-120*r,120))}deg 100% 31%);`,n?.key)}return i}}function t0(e,t,n,r){return{debug:()=>e?.debugAll??e[t],key:!1,onChange:r}}function n0(e,t,n,r){let i={id:`${t.id}_${n.id}`,row:t,column:n,getValue:()=>t.getValue(r),renderValue:()=>i.getValue()??e.options.renderFallbackValue,getContext:e0(()=>[e,n,t,i],(e,t,n,r)=>({table:e,column:t,row:n,cell:r,getValue:r.getValue,renderValue:r.renderValue}),t0(e.options,`debugCells`,`cell.getContext`))};return e._features.forEach(r=>{r.createCell==null||r.createCell(i,n,t,e)},{}),i}function r0(e,t,n,r){let i={...e._getDefaultColumnDef(),...t},a=i.accessorKey,o=i.id??(a?typeof String.prototype.replaceAll==`function`?a.replaceAll(`.`,`_`):a.replace(/\./g,`_`):void 0)??(typeof i.header==`string`?i.header:void 0),s;if(i.accessorFn?s=i.accessorFn:a&&(s=a.includes(`.`)?e=>{let t=e;for(let e of a.split(`.`))t=t?.[e];return t}:e=>e[i.accessorKey]),!o)throw Error();let c={id:`${String(o)}`,accessorFn:s,parent:r,depth:n,columnDef:i,columns:[],getFlatColumns:e0(()=>[!0],()=>[c,...c.columns?.flatMap(e=>e.getFlatColumns())],t0(e.options,`debugColumns`,`column.getFlatColumns`)),getLeafColumns:e0(()=>[e._getOrderColumnsFn()],e=>{var t;return(t=c.columns)!=null&&t.length?e(c.columns.flatMap(e=>e.getLeafColumns())):[c]},t0(e.options,`debugColumns`,`column.getLeafColumns`))};for(let t of e._features)t.createColumn==null||t.createColumn(c,e);return c}var i0=`debugHeaders`;function a0(e,t,n){let r={id:n.id??t.id,column:t,index:n.index,isPlaceholder:!!n.isPlaceholder,placeholderId:n.placeholderId,depth:n.depth,subHeaders:[],colSpan:0,rowSpan:0,headerGroup:null,getLeafHeaders:()=>{let e=[],t=n=>{n.subHeaders&&n.subHeaders.length&&n.subHeaders.map(t),e.push(n)};return t(r),e},getContext:()=>({table:e,header:r,column:t})};return e._features.forEach(t=>{t.createHeader==null||t.createHeader(r,e)}),r}var o0={createTable:e=>{e.getHeaderGroups=e0(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.left,e.getState().columnPinning.right],(t,n,r,i)=>{let a=r?.map(e=>n.find(t=>t.id===e)).filter(Boolean)??[],o=i?.map(e=>n.find(t=>t.id===e)).filter(Boolean)??[],s=n.filter(e=>!(r!=null&&r.includes(e.id))&&!(i!=null&&i.includes(e.id)));return s0(t,[...a,...s,...o],e)},t0(e.options,i0,`getHeaderGroups`)),e.getCenterHeaderGroups=e0(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.left,e.getState().columnPinning.right],(t,n,r,i)=>(n=n.filter(e=>!(r!=null&&r.includes(e.id))&&!(i!=null&&i.includes(e.id))),s0(t,n,e,`center`)),t0(e.options,i0,`getCenterHeaderGroups`)),e.getLeftHeaderGroups=e0(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.left],(t,n,r)=>s0(t,r?.map(e=>n.find(t=>t.id===e)).filter(Boolean)??[],e,`left`),t0(e.options,i0,`getLeftHeaderGroups`)),e.getRightHeaderGroups=e0(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.right],(t,n,r)=>s0(t,r?.map(e=>n.find(t=>t.id===e)).filter(Boolean)??[],e,`right`),t0(e.options,i0,`getRightHeaderGroups`)),e.getFooterGroups=e0(()=>[e.getHeaderGroups()],e=>[...e].reverse(),t0(e.options,i0,`getFooterGroups`)),e.getLeftFooterGroups=e0(()=>[e.getLeftHeaderGroups()],e=>[...e].reverse(),t0(e.options,i0,`getLeftFooterGroups`)),e.getCenterFooterGroups=e0(()=>[e.getCenterHeaderGroups()],e=>[...e].reverse(),t0(e.options,i0,`getCenterFooterGroups`)),e.getRightFooterGroups=e0(()=>[e.getRightHeaderGroups()],e=>[...e].reverse(),t0(e.options,i0,`getRightFooterGroups`)),e.getFlatHeaders=e0(()=>[e.getHeaderGroups()],e=>e.map(e=>e.headers).flat(),t0(e.options,i0,`getFlatHeaders`)),e.getLeftFlatHeaders=e0(()=>[e.getLeftHeaderGroups()],e=>e.map(e=>e.headers).flat(),t0(e.options,i0,`getLeftFlatHeaders`)),e.getCenterFlatHeaders=e0(()=>[e.getCenterHeaderGroups()],e=>e.map(e=>e.headers).flat(),t0(e.options,i0,`getCenterFlatHeaders`)),e.getRightFlatHeaders=e0(()=>[e.getRightHeaderGroups()],e=>e.map(e=>e.headers).flat(),t0(e.options,i0,`getRightFlatHeaders`)),e.getCenterLeafHeaders=e0(()=>[e.getCenterFlatHeaders()],e=>e.filter(e=>{var t;return!((t=e.subHeaders)!=null&&t.length)}),t0(e.options,i0,`getCenterLeafHeaders`)),e.getLeftLeafHeaders=e0(()=>[e.getLeftFlatHeaders()],e=>e.filter(e=>{var t;return!((t=e.subHeaders)!=null&&t.length)}),t0(e.options,i0,`getLeftLeafHeaders`)),e.getRightLeafHeaders=e0(()=>[e.getRightFlatHeaders()],e=>e.filter(e=>{var t;return!((t=e.subHeaders)!=null&&t.length)}),t0(e.options,i0,`getRightLeafHeaders`)),e.getLeafHeaders=e0(()=>[e.getLeftHeaderGroups(),e.getCenterHeaderGroups(),e.getRightHeaderGroups()],(e,t,n)=>[...e[0]?.headers??[],...t[0]?.headers??[],...n[0]?.headers??[]].map(e=>e.getLeafHeaders()).flat(),t0(e.options,i0,`getLeafHeaders`))}};function s0(e,t,n,r){let i=0,a=function(e,t){t===void 0&&(t=1),i=Math.max(i,t),e.filter(e=>e.getIsVisible()).forEach(e=>{var n;(n=e.columns)!=null&&n.length&&a(e.columns,t+1)},0)};a(e);let o=[],s=(e,t)=>{let i={depth:t,id:[r,`${t}`].filter(Boolean).join(`_`),headers:[]},a=[];e.forEach(e=>{let o=[...a].reverse()[0],s=e.column.depth===i.depth,c,l=!1;if(s&&e.column.parent?c=e.column.parent:(c=e.column,l=!0),o&&o?.column===c)o.subHeaders.push(e);else{let i=a0(n,c,{id:[r,t,c.id,e?.id].filter(Boolean).join(`_`),isPlaceholder:l,placeholderId:l?`${a.filter(e=>e.column===c).length}`:void 0,depth:t,index:a.length});i.subHeaders.push(e),a.push(i)}i.headers.push(e),e.headerGroup=i}),o.push(i),t>0&&s(a,t-1)};s(t.map((e,t)=>a0(n,e,{depth:i,index:t})),i-1),o.reverse();let c=e=>e.filter(e=>e.column.getIsVisible()).map(e=>{let t=0,n=0,r=[0];e.subHeaders&&e.subHeaders.length?(r=[],c(e.subHeaders).forEach(e=>{let{colSpan:n,rowSpan:i}=e;t+=n,r.push(i)})):t=1;let i=Math.min(...r);return n+=i,e.colSpan=t,e.rowSpan=n,{colSpan:t,rowSpan:n}});return c(o[0]?.headers??[]),o}var c0=(e,t,n,r,i,a,o)=>{let s={id:t,index:r,original:n,depth:i,parentId:o,_valuesCache:{},_uniqueValuesCache:{},getValue:t=>{if(s._valuesCache.hasOwnProperty(t))return s._valuesCache[t];let n=e.getColumn(t);if(n!=null&&n.accessorFn)return s._valuesCache[t]=n.accessorFn(s.original,r),s._valuesCache[t]},getUniqueValues:t=>{if(s._uniqueValuesCache.hasOwnProperty(t))return s._uniqueValuesCache[t];let n=e.getColumn(t);if(n!=null&&n.accessorFn)return n.columnDef.getUniqueValues?(s._uniqueValuesCache[t]=n.columnDef.getUniqueValues(s.original,r),s._uniqueValuesCache[t]):(s._uniqueValuesCache[t]=[s.getValue(t)],s._uniqueValuesCache[t])},renderValue:t=>s.getValue(t)??e.options.renderFallbackValue,subRows:a??[],getLeafRows:()=>$1(s.subRows,e=>e.subRows),getParentRow:()=>s.parentId?e.getRow(s.parentId,!0):void 0,getParentRows:()=>{let e=[],t=s;for(;;){let n=t.getParentRow();if(!n)break;e.push(n),t=n}return e.reverse()},getAllCells:e0(()=>[e.getAllLeafColumns()],t=>t.map(t=>n0(e,s,t,t.id)),t0(e.options,`debugRows`,`getAllCells`)),_getAllCellsByColumnId:e0(()=>[s.getAllCells()],e=>e.reduce((e,t)=>(e[t.column.id]=t,e),{}),t0(e.options,`debugRows`,`getAllCellsByColumnId`))};for(let t=0;t<e._features.length;t++){let n=e._features[t];n==null||n.createRow==null||n.createRow(s,e)}return s},l0={createColumn:(e,t)=>{e._getFacetedRowModel=t.options.getFacetedRowModel&&t.options.getFacetedRowModel(t,e.id),e.getFacetedRowModel=()=>e._getFacetedRowModel?e._getFacetedRowModel():t.getPreFilteredRowModel(),e._getFacetedUniqueValues=t.options.getFacetedUniqueValues&&t.options.getFacetedUniqueValues(t,e.id),e.getFacetedUniqueValues=()=>e._getFacetedUniqueValues?e._getFacetedUniqueValues():new Map,e._getFacetedMinMaxValues=t.options.getFacetedMinMaxValues&&t.options.getFacetedMinMaxValues(t,e.id),e.getFacetedMinMaxValues=()=>{if(e._getFacetedMinMaxValues)return e._getFacetedMinMaxValues()}}},u0=(e,t,n)=>{var r,i;let a=n==null||(r=n.toString())==null?void 0:r.toLowerCase();return!!(!((i=e.getValue(t))==null||(i=i.toString())==null||(i=i.toLowerCase())==null)&&i.includes(a))};u0.autoRemove=e=>b0(e);var d0=(e,t,n)=>{var r;return!!(!((r=e.getValue(t))==null||(r=r.toString())==null)&&r.includes(n))};d0.autoRemove=e=>b0(e);var f0=(e,t,n)=>{var r;return((r=e.getValue(t))==null||(r=r.toString())==null?void 0:r.toLowerCase())===n?.toLowerCase()};f0.autoRemove=e=>b0(e);var p0=(e,t,n)=>e.getValue(t)?.includes(n);p0.autoRemove=e=>b0(e);var m0=(e,t,n)=>!n.some(n=>{var r;return!((r=e.getValue(t))!=null&&r.includes(n))});m0.autoRemove=e=>b0(e)||!(e!=null&&e.length);var h0=(e,t,n)=>n.some(n=>e.getValue(t)?.includes(n));h0.autoRemove=e=>b0(e)||!(e!=null&&e.length);var g0=(e,t,n)=>e.getValue(t)===n;g0.autoRemove=e=>b0(e);var _0=(e,t,n)=>e.getValue(t)==n;_0.autoRemove=e=>b0(e);var v0=(e,t,n)=>{let[r,i]=n,a=e.getValue(t);return a>=r&&a<=i};v0.resolveFilterValue=e=>{let[t,n]=e,r=typeof t==`number`?t:parseFloat(t),i=typeof n==`number`?n:parseFloat(n),a=t===null||Number.isNaN(r)?-1/0:r,o=n===null||Number.isNaN(i)?1/0:i;if(a>o){let e=a;a=o,o=e}return[a,o]},v0.autoRemove=e=>b0(e)||b0(e[0])&&b0(e[1]);var y0={includesString:u0,includesStringSensitive:d0,equalsString:f0,arrIncludes:p0,arrIncludesAll:m0,arrIncludesSome:h0,equals:g0,weakEquals:_0,inNumberRange:v0};function b0(e){return e==null||e===``}var x0={getDefaultColumnDef:()=>({filterFn:`auto`}),getInitialState:e=>({columnFilters:[],...e}),getDefaultOptions:e=>({onColumnFiltersChange:X1(`columnFilters`,e),filterFromLeafRows:!1,maxLeafRowFilterDepth:100}),createColumn:(e,t)=>{e.getAutoFilterFn=()=>{let n=t.getCoreRowModel().flatRows[0]?.getValue(e.id);return typeof n==`string`?y0.includesString:typeof n==`number`?y0.inNumberRange:typeof n==`boolean`||typeof n==`object`&&n?y0.equals:Array.isArray(n)?y0.arrIncludes:y0.weakEquals},e.getFilterFn=()=>Z1(e.columnDef.filterFn)?e.columnDef.filterFn:e.columnDef.filterFn===`auto`?e.getAutoFilterFn():t.options.filterFns?.[e.columnDef.filterFn]??y0[e.columnDef.filterFn],e.getCanFilter=()=>(e.columnDef.enableColumnFilter??!0)&&(t.options.enableColumnFilters??!0)&&(t.options.enableFilters??!0)&&!!e.accessorFn,e.getIsFiltered=()=>e.getFilterIndex()>-1,e.getFilterValue=()=>{var n;return(n=t.getState().columnFilters)==null||(n=n.find(t=>t.id===e.id))==null?void 0:n.value},e.getFilterIndex=()=>t.getState().columnFilters?.findIndex(t=>t.id===e.id)??-1,e.setFilterValue=n=>{t.setColumnFilters(t=>{let r=e.getFilterFn(),i=t?.find(t=>t.id===e.id),a=Y1(n,i?i.value:void 0);if(S0(r,a,e))return t?.filter(t=>t.id!==e.id)??[];let o={id:e.id,value:a};return i?t?.map(t=>t.id===e.id?o:t)??[]:t!=null&&t.length?[...t,o]:[o]})}},createRow:(e,t)=>{e.columnFilters={},e.columnFiltersMeta={}},createTable:e=>{e.setColumnFilters=t=>{let n=e.getAllLeafColumns();e.options.onColumnFiltersChange==null||e.options.onColumnFiltersChange(e=>Y1(t,e)?.filter(e=>{let t=n.find(t=>t.id===e.id);return!(t&&S0(t.getFilterFn(),e.value,t))}))},e.resetColumnFilters=t=>{e.setColumnFilters(t?[]:e.initialState?.columnFilters??[])},e.getPreFilteredRowModel=()=>e.getCoreRowModel(),e.getFilteredRowModel=()=>(!e._getFilteredRowModel&&e.options.getFilteredRowModel&&(e._getFilteredRowModel=e.options.getFilteredRowModel(e)),e.options.manualFiltering||!e._getFilteredRowModel?e.getPreFilteredRowModel():e._getFilteredRowModel())}};function S0(e,t,n){return(e&&e.autoRemove?e.autoRemove(t,n):!1)||t===void 0||typeof t==`string`&&!t}var C0={sum:(e,t,n)=>n.reduce((t,n)=>{let r=n.getValue(e);return t+(typeof r==`number`?r:0)},0),min:(e,t,n)=>{let r;return n.forEach(t=>{let n=t.getValue(e);n!=null&&(r>n||r===void 0&&n>=n)&&(r=n)}),r},max:(e,t,n)=>{let r;return n.forEach(t=>{let n=t.getValue(e);n!=null&&(r<n||r===void 0&&n>=n)&&(r=n)}),r},extent:(e,t,n)=>{let r,i;return n.forEach(t=>{let n=t.getValue(e);n!=null&&(r===void 0?n>=n&&(r=i=n):(r>n&&(r=n),i<n&&(i=n)))}),[r,i]},mean:(e,t)=>{let n=0,r=0;if(t.forEach(t=>{let i=t.getValue(e);i!=null&&(i=+i)>=i&&(++n,r+=i)}),n)return r/n},median:(e,t)=>{if(!t.length)return;let n=t.map(t=>t.getValue(e));if(!Q1(n))return;if(n.length===1)return n[0];let r=Math.floor(n.length/2),i=n.sort((e,t)=>e-t);return n.length%2==0?(i[r-1]+i[r])/2:i[r]},unique:(e,t)=>Array.from(new Set(t.map(t=>t.getValue(e))).values()),uniqueCount:(e,t)=>new Set(t.map(t=>t.getValue(e))).size,count:(e,t)=>t.length},w0={getDefaultColumnDef:()=>({aggregatedCell:e=>{var t;return((t=e.getValue())==null||t.toString==null?void 0:t.toString())??null},aggregationFn:`auto`}),getInitialState:e=>({grouping:[],...e}),getDefaultOptions:e=>({onGroupingChange:X1(`grouping`,e),groupedColumnMode:`reorder`}),createColumn:(e,t)=>{e.toggleGrouping=()=>{t.setGrouping(t=>t!=null&&t.includes(e.id)?t.filter(t=>t!==e.id):[...t??[],e.id])},e.getCanGroup=()=>(e.columnDef.enableGrouping??!0)&&(t.options.enableGrouping??!0)&&(!!e.accessorFn||!!e.columnDef.getGroupingValue),e.getIsGrouped=()=>t.getState().grouping?.includes(e.id),e.getGroupedIndex=()=>t.getState().grouping?.indexOf(e.id),e.getToggleGroupingHandler=()=>{let t=e.getCanGroup();return()=>{t&&e.toggleGrouping()}},e.getAutoAggregationFn=()=>{let n=t.getCoreRowModel().flatRows[0]?.getValue(e.id);if(typeof n==`number`)return C0.sum;if(Object.prototype.toString.call(n)===`[object Date]`)return C0.extent},e.getAggregationFn=()=>{if(!e)throw Error();return Z1(e.columnDef.aggregationFn)?e.columnDef.aggregationFn:e.columnDef.aggregationFn===`auto`?e.getAutoAggregationFn():t.options.aggregationFns?.[e.columnDef.aggregationFn]??C0[e.columnDef.aggregationFn]}},createTable:e=>{e.setGrouping=t=>e.options.onGroupingChange==null?void 0:e.options.onGroupingChange(t),e.resetGrouping=t=>{e.setGrouping(t?[]:e.initialState?.grouping??[])},e.getPreGroupedRowModel=()=>e.getFilteredRowModel(),e.getGroupedRowModel=()=>(!e._getGroupedRowModel&&e.options.getGroupedRowModel&&(e._getGroupedRowModel=e.options.getGroupedRowModel(e)),e.options.manualGrouping||!e._getGroupedRowModel?e.getPreGroupedRowModel():e._getGroupedRowModel())},createRow:(e,t)=>{e.getIsGrouped=()=>!!e.groupingColumnId,e.getGroupingValue=n=>{if(e._groupingValuesCache.hasOwnProperty(n))return e._groupingValuesCache[n];let r=t.getColumn(n);return r!=null&&r.columnDef.getGroupingValue?(e._groupingValuesCache[n]=r.columnDef.getGroupingValue(e.original),e._groupingValuesCache[n]):e.getValue(n)},e._groupingValuesCache={}},createCell:(e,t,n,r)=>{e.getIsGrouped=()=>t.getIsGrouped()&&t.id===n.groupingColumnId,e.getIsPlaceholder=()=>!e.getIsGrouped()&&t.getIsGrouped(),e.getIsAggregated=()=>{var t;return!e.getIsGrouped()&&!e.getIsPlaceholder()&&!!((t=n.subRows)!=null&&t.length)}}};function T0(e,t,n){if(!(t!=null&&t.length)||!n)return e;let r=e.filter(e=>!t.includes(e.id));return n===`remove`?r:[...t.map(t=>e.find(e=>e.id===t)).filter(Boolean),...r]}var E0={getInitialState:e=>({columnOrder:[],...e}),getDefaultOptions:e=>({onColumnOrderChange:X1(`columnOrder`,e)}),createColumn:(e,t)=>{e.getIndex=e0(e=>[L0(t,e)],t=>t.findIndex(t=>t.id===e.id),t0(t.options,`debugColumns`,`getIndex`)),e.getIsFirstColumn=n=>L0(t,n)[0]?.id===e.id,e.getIsLastColumn=n=>{let r=L0(t,n);return r[r.length-1]?.id===e.id}},createTable:e=>{e.setColumnOrder=t=>e.options.onColumnOrderChange==null?void 0:e.options.onColumnOrderChange(t),e.resetColumnOrder=t=>{e.setColumnOrder(t?[]:e.initialState.columnOrder??[])},e._getOrderColumnsFn=e0(()=>[e.getState().columnOrder,e.getState().grouping,e.options.groupedColumnMode],(e,t,n)=>r=>{let i=[];if(!(e!=null&&e.length))i=r;else{let t=[...e],n=[...r];for(;n.length&&t.length;){let e=t.shift(),r=n.findIndex(t=>t.id===e);r>-1&&i.push(n.splice(r,1)[0])}i=[...i,...n]}return T0(i,t,n)},t0(e.options,`debugTable`,`_getOrderColumnsFn`))}},D0=()=>({left:[],right:[]}),O0={getInitialState:e=>({columnPinning:D0(),...e}),getDefaultOptions:e=>({onColumnPinningChange:X1(`columnPinning`,e)}),createColumn:(e,t)=>{e.pin=n=>{let r=e.getLeafColumns().map(e=>e.id).filter(Boolean);t.setColumnPinning(e=>n===`right`?{left:(e?.left??[]).filter(e=>!(r!=null&&r.includes(e))),right:[...(e?.right??[]).filter(e=>!(r!=null&&r.includes(e))),...r]}:n===`left`?{left:[...(e?.left??[]).filter(e=>!(r!=null&&r.includes(e))),...r],right:(e?.right??[]).filter(e=>!(r!=null&&r.includes(e)))}:{left:(e?.left??[]).filter(e=>!(r!=null&&r.includes(e))),right:(e?.right??[]).filter(e=>!(r!=null&&r.includes(e)))})},e.getCanPin=()=>e.getLeafColumns().some(e=>(e.columnDef.enablePinning??!0)&&(t.options.enableColumnPinning??t.options.enablePinning??!0)),e.getIsPinned=()=>{let n=e.getLeafColumns().map(e=>e.id),{left:r,right:i}=t.getState().columnPinning,a=n.some(e=>r?.includes(e)),o=n.some(e=>i?.includes(e));return a?`left`:o?`right`:!1},e.getPinnedIndex=()=>{var n;let r=e.getIsPinned();return r?((n=t.getState().columnPinning)==null||(n=n[r])==null?void 0:n.indexOf(e.id))??-1:0}},createRow:(e,t)=>{e.getCenterVisibleCells=e0(()=>[e._getAllVisibleCells(),t.getState().columnPinning.left,t.getState().columnPinning.right],(e,t,n)=>{let r=[...t??[],...n??[]];return e.filter(e=>!r.includes(e.column.id))},t0(t.options,`debugRows`,`getCenterVisibleCells`)),e.getLeftVisibleCells=e0(()=>[e._getAllVisibleCells(),t.getState().columnPinning.left],(e,t)=>(t??[]).map(t=>e.find(e=>e.column.id===t)).filter(Boolean).map(e=>({...e,position:`left`})),t0(t.options,`debugRows`,`getLeftVisibleCells`)),e.getRightVisibleCells=e0(()=>[e._getAllVisibleCells(),t.getState().columnPinning.right],(e,t)=>(t??[]).map(t=>e.find(e=>e.column.id===t)).filter(Boolean).map(e=>({...e,position:`right`})),t0(t.options,`debugRows`,`getRightVisibleCells`))},createTable:e=>{e.setColumnPinning=t=>e.options.onColumnPinningChange==null?void 0:e.options.onColumnPinningChange(t),e.resetColumnPinning=t=>e.setColumnPinning(t?D0():e.initialState?.columnPinning??D0()),e.getIsSomeColumnsPinned=t=>{let n=e.getState().columnPinning;return t?!!n[t]?.length:!!(n.left?.length||n.right?.length)},e.getLeftLeafColumns=e0(()=>[e.getAllLeafColumns(),e.getState().columnPinning.left],(e,t)=>(t??[]).map(t=>e.find(e=>e.id===t)).filter(Boolean),t0(e.options,`debugColumns`,`getLeftLeafColumns`)),e.getRightLeafColumns=e0(()=>[e.getAllLeafColumns(),e.getState().columnPinning.right],(e,t)=>(t??[]).map(t=>e.find(e=>e.id===t)).filter(Boolean),t0(e.options,`debugColumns`,`getRightLeafColumns`)),e.getCenterLeafColumns=e0(()=>[e.getAllLeafColumns(),e.getState().columnPinning.left,e.getState().columnPinning.right],(e,t,n)=>{let r=[...t??[],...n??[]];return e.filter(e=>!r.includes(e.id))},t0(e.options,`debugColumns`,`getCenterLeafColumns`))}};function k0(e){return e||(typeof document<`u`?document:null)}var A0={size:150,minSize:20,maxSize:2**53-1},j0=()=>({startOffset:null,startSize:null,deltaOffset:null,deltaPercentage:null,isResizingColumn:!1,columnSizingStart:[]}),M0={getDefaultColumnDef:()=>A0,getInitialState:e=>({columnSizing:{},columnSizingInfo:j0(),...e}),getDefaultOptions:e=>({columnResizeMode:`onEnd`,columnResizeDirection:`ltr`,onColumnSizingChange:X1(`columnSizing`,e),onColumnSizingInfoChange:X1(`columnSizingInfo`,e)}),createColumn:(e,t)=>{e.getSize=()=>{let n=t.getState().columnSizing[e.id];return Math.min(Math.max(e.columnDef.minSize??A0.minSize,n??e.columnDef.size??A0.size),e.columnDef.maxSize??A0.maxSize)},e.getStart=e0(e=>[e,L0(t,e),t.getState().columnSizing],(t,n)=>n.slice(0,e.getIndex(t)).reduce((e,t)=>e+t.getSize(),0),t0(t.options,`debugColumns`,`getStart`)),e.getAfter=e0(e=>[e,L0(t,e),t.getState().columnSizing],(t,n)=>n.slice(e.getIndex(t)+1).reduce((e,t)=>e+t.getSize(),0),t0(t.options,`debugColumns`,`getAfter`)),e.resetSize=()=>{t.setColumnSizing(t=>{let{[e.id]:n,...r}=t;return r})},e.getCanResize=()=>(e.columnDef.enableResizing??!0)&&(t.options.enableColumnResizing??!0),e.getIsResizing=()=>t.getState().columnSizingInfo.isResizingColumn===e.id},createHeader:(e,t)=>{e.getSize=()=>{let t=0,n=e=>{e.subHeaders.length?e.subHeaders.forEach(n):t+=e.column.getSize()??0};return n(e),t},e.getStart=()=>{if(e.index>0){let t=e.headerGroup.headers[e.index-1];return t.getStart()+t.getSize()}return 0},e.getResizeHandler=n=>{let r=t.getColumn(e.column.id),i=r?.getCanResize();return a=>{if(!r||!i||(a.persist==null||a.persist(),F0(a)&&a.touches&&a.touches.length>1))return;let o=e.getSize(),s=e?e.getLeafHeaders().map(e=>[e.column.id,e.column.getSize()]):[[r.id,r.getSize()]],c=F0(a)?Math.round(a.touches[0].clientX):a.clientX,l={},u=(e,n)=>{typeof n==`number`&&(t.setColumnSizingInfo(e=>{let r=t.options.columnResizeDirection===`rtl`?-1:1,i=(n-(e?.startOffset??0))*r,a=Math.max(i/(e?.startSize??0),-.999999);return e.columnSizingStart.forEach(e=>{let[t,n]=e;l[t]=Math.round(Math.max(n+n*a,0)*100)/100}),{...e,deltaOffset:i,deltaPercentage:a}}),(t.options.columnResizeMode===`onChange`||e===`end`)&&t.setColumnSizing(e=>({...e,...l})))},d=e=>u(`move`,e),f=e=>{u(`end`,e),t.setColumnSizingInfo(e=>({...e,isResizingColumn:!1,startOffset:null,startSize:null,deltaOffset:null,deltaPercentage:null,columnSizingStart:[]}))},p=k0(n),m={moveHandler:e=>d(e.clientX),upHandler:e=>{p?.removeEventListener(`mousemove`,m.moveHandler),p?.removeEventListener(`mouseup`,m.upHandler),f(e.clientX)}},h={moveHandler:e=>(e.cancelable&&(e.preventDefault(),e.stopPropagation()),d(e.touches[0].clientX),!1),upHandler:e=>{p?.removeEventListener(`touchmove`,h.moveHandler),p?.removeEventListener(`touchend`,h.upHandler),e.cancelable&&(e.preventDefault(),e.stopPropagation()),f(e.touches[0]?.clientX)}},g=P0()?{passive:!1}:!1;F0(a)?(p?.addEventListener(`touchmove`,h.moveHandler,g),p?.addEventListener(`touchend`,h.upHandler,g)):(p?.addEventListener(`mousemove`,m.moveHandler,g),p?.addEventListener(`mouseup`,m.upHandler,g)),t.setColumnSizingInfo(e=>({...e,startOffset:c,startSize:o,deltaOffset:0,deltaPercentage:0,columnSizingStart:s,isResizingColumn:r.id}))}}},createTable:e=>{e.setColumnSizing=t=>e.options.onColumnSizingChange==null?void 0:e.options.onColumnSizingChange(t),e.setColumnSizingInfo=t=>e.options.onColumnSizingInfoChange==null?void 0:e.options.onColumnSizingInfoChange(t),e.resetColumnSizing=t=>{e.setColumnSizing(t?{}:e.initialState.columnSizing??{})},e.resetHeaderSizeInfo=t=>{e.setColumnSizingInfo(t?j0():e.initialState.columnSizingInfo??j0())},e.getTotalSize=()=>e.getHeaderGroups()[0]?.headers.reduce((e,t)=>e+t.getSize(),0)??0,e.getLeftTotalSize=()=>e.getLeftHeaderGroups()[0]?.headers.reduce((e,t)=>e+t.getSize(),0)??0,e.getCenterTotalSize=()=>e.getCenterHeaderGroups()[0]?.headers.reduce((e,t)=>e+t.getSize(),0)??0,e.getRightTotalSize=()=>e.getRightHeaderGroups()[0]?.headers.reduce((e,t)=>e+t.getSize(),0)??0}},N0=null;function P0(){if(typeof N0==`boolean`)return N0;let e=!1;try{let t={get passive(){return e=!0,!1}},n=()=>{};window.addEventListener(`test`,n,t),window.removeEventListener(`test`,n)}catch{e=!1}return N0=e,N0}function F0(e){return e.type===`touchstart`}var I0={getInitialState:e=>({columnVisibility:{},...e}),getDefaultOptions:e=>({onColumnVisibilityChange:X1(`columnVisibility`,e)}),createColumn:(e,t)=>{e.toggleVisibility=n=>{e.getCanHide()&&t.setColumnVisibility(t=>({...t,[e.id]:n??!e.getIsVisible()}))},e.getIsVisible=()=>{let n=e.columns;return(n.length?n.some(e=>e.getIsVisible()):t.getState().columnVisibility?.[e.id])??!0},e.getCanHide=()=>(e.columnDef.enableHiding??!0)&&(t.options.enableHiding??!0),e.getToggleVisibilityHandler=()=>t=>{e.toggleVisibility==null||e.toggleVisibility(t.target.checked)}},createRow:(e,t)=>{e._getAllVisibleCells=e0(()=>[e.getAllCells(),t.getState().columnVisibility],e=>e.filter(e=>e.column.getIsVisible()),t0(t.options,`debugRows`,`_getAllVisibleCells`)),e.getVisibleCells=e0(()=>[e.getLeftVisibleCells(),e.getCenterVisibleCells(),e.getRightVisibleCells()],(e,t,n)=>[...e,...t,...n],t0(t.options,`debugRows`,`getVisibleCells`))},createTable:e=>{let t=(t,n)=>e0(()=>[n(),n().filter(e=>e.getIsVisible()).map(e=>e.id).join(`_`)],e=>e.filter(e=>e.getIsVisible==null?void 0:e.getIsVisible()),t0(e.options,`debugColumns`,t));e.getVisibleFlatColumns=t(`getVisibleFlatColumns`,()=>e.getAllFlatColumns()),e.getVisibleLeafColumns=t(`getVisibleLeafColumns`,()=>e.getAllLeafColumns()),e.getLeftVisibleLeafColumns=t(`getLeftVisibleLeafColumns`,()=>e.getLeftLeafColumns()),e.getRightVisibleLeafColumns=t(`getRightVisibleLeafColumns`,()=>e.getRightLeafColumns()),e.getCenterVisibleLeafColumns=t(`getCenterVisibleLeafColumns`,()=>e.getCenterLeafColumns()),e.setColumnVisibility=t=>e.options.onColumnVisibilityChange==null?void 0:e.options.onColumnVisibilityChange(t),e.resetColumnVisibility=t=>{e.setColumnVisibility(t?{}:e.initialState.columnVisibility??{})},e.toggleAllColumnsVisible=t=>{t??=!e.getIsAllColumnsVisible(),e.setColumnVisibility(e.getAllLeafColumns().reduce((e,n)=>({...e,[n.id]:t||!(n.getCanHide!=null&&n.getCanHide())}),{}))},e.getIsAllColumnsVisible=()=>!e.getAllLeafColumns().some(e=>!(e.getIsVisible!=null&&e.getIsVisible())),e.getIsSomeColumnsVisible=()=>e.getAllLeafColumns().some(e=>e.getIsVisible==null?void 0:e.getIsVisible()),e.getToggleAllColumnsVisibilityHandler=()=>t=>{e.toggleAllColumnsVisible(t.target?.checked)}}};function L0(e,t){return t?t===`center`?e.getCenterVisibleLeafColumns():t===`left`?e.getLeftVisibleLeafColumns():e.getRightVisibleLeafColumns():e.getVisibleLeafColumns()}var R0={createTable:e=>{e._getGlobalFacetedRowModel=e.options.getFacetedRowModel&&e.options.getFacetedRowModel(e,`__global__`),e.getGlobalFacetedRowModel=()=>e.options.manualFiltering||!e._getGlobalFacetedRowModel?e.getPreFilteredRowModel():e._getGlobalFacetedRowModel(),e._getGlobalFacetedUniqueValues=e.options.getFacetedUniqueValues&&e.options.getFacetedUniqueValues(e,`__global__`),e.getGlobalFacetedUniqueValues=()=>e._getGlobalFacetedUniqueValues?e._getGlobalFacetedUniqueValues():new Map,e._getGlobalFacetedMinMaxValues=e.options.getFacetedMinMaxValues&&e.options.getFacetedMinMaxValues(e,`__global__`),e.getGlobalFacetedMinMaxValues=()=>{if(e._getGlobalFacetedMinMaxValues)return e._getGlobalFacetedMinMaxValues()}}},z0={getInitialState:e=>({globalFilter:void 0,...e}),getDefaultOptions:e=>({onGlobalFilterChange:X1(`globalFilter`,e),globalFilterFn:`auto`,getColumnCanGlobalFilter:t=>{var n;let r=(n=e.getCoreRowModel().flatRows[0])==null||(n=n._getAllCellsByColumnId()[t.id])==null?void 0:n.getValue();return typeof r==`string`||typeof r==`number`}}),createColumn:(e,t)=>{e.getCanGlobalFilter=()=>(e.columnDef.enableGlobalFilter??!0)&&(t.options.enableGlobalFilter??!0)&&(t.options.enableFilters??!0)&&((t.options.getColumnCanGlobalFilter==null?void 0:t.options.getColumnCanGlobalFilter(e))??!0)&&!!e.accessorFn},createTable:e=>{e.getGlobalAutoFilterFn=()=>y0.includesString,e.getGlobalFilterFn=()=>{let{globalFilterFn:t}=e.options;return Z1(t)?t:t===`auto`?e.getGlobalAutoFilterFn():e.options.filterFns?.[t]??y0[t]},e.setGlobalFilter=t=>{e.options.onGlobalFilterChange==null||e.options.onGlobalFilterChange(t)},e.resetGlobalFilter=t=>{e.setGlobalFilter(t?void 0:e.initialState.globalFilter)}}},B0={getInitialState:e=>({expanded:{},...e}),getDefaultOptions:e=>({onExpandedChange:X1(`expanded`,e),paginateExpandedRows:!0}),createTable:e=>{let t=!1,n=!1;e._autoResetExpanded=()=>{if(!t){e._queue(()=>{t=!0});return}if(e.options.autoResetAll??e.options.autoResetExpanded??!e.options.manualExpanding){if(n)return;n=!0,e._queue(()=>{e.resetExpanded(),n=!1})}},e.setExpanded=t=>e.options.onExpandedChange==null?void 0:e.options.onExpandedChange(t),e.toggleAllRowsExpanded=t=>{t??!e.getIsAllRowsExpanded()?e.setExpanded(!0):e.setExpanded({})},e.resetExpanded=t=>{e.setExpanded(t?{}:e.initialState?.expanded??{})},e.getCanSomeRowsExpand=()=>e.getPrePaginationRowModel().flatRows.some(e=>e.getCanExpand()),e.getToggleAllRowsExpandedHandler=()=>t=>{t.persist==null||t.persist(),e.toggleAllRowsExpanded()},e.getIsSomeRowsExpanded=()=>{let t=e.getState().expanded;return t===!0||Object.values(t).some(Boolean)},e.getIsAllRowsExpanded=()=>{let t=e.getState().expanded;return typeof t==`boolean`?t===!0:!(!Object.keys(t).length||e.getRowModel().flatRows.some(e=>!e.getIsExpanded()))},e.getExpandedDepth=()=>{let t=0;return(e.getState().expanded===!0?Object.keys(e.getRowModel().rowsById):Object.keys(e.getState().expanded)).forEach(e=>{let n=e.split(`.`);t=Math.max(t,n.length)}),t},e.getPreExpandedRowModel=()=>e.getSortedRowModel(),e.getExpandedRowModel=()=>(!e._getExpandedRowModel&&e.options.getExpandedRowModel&&(e._getExpandedRowModel=e.options.getExpandedRowModel(e)),e.options.manualExpanding||!e._getExpandedRowModel?e.getPreExpandedRowModel():e._getExpandedRowModel())},createRow:(e,t)=>{e.toggleExpanded=n=>{t.setExpanded(r=>{let i=r===!0?!0:!!(r!=null&&r[e.id]),a={};if(r===!0?Object.keys(t.getRowModel().rowsById).forEach(e=>{a[e]=!0}):a=r,n??=!i,!i&&n)return{...a,[e.id]:!0};if(i&&!n){let{[e.id]:t,...n}=a;return n}return r})},e.getIsExpanded=()=>{let n=t.getState().expanded;return!!((t.options.getIsRowExpanded==null?void 0:t.options.getIsRowExpanded(e))??(n===!0||n?.[e.id]))},e.getCanExpand=()=>{var n;return(t.options.getRowCanExpand==null?void 0:t.options.getRowCanExpand(e))??((t.options.enableExpanding??!0)&&!!((n=e.subRows)!=null&&n.length))},e.getIsAllParentsExpanded=()=>{let n=!0,r=e;for(;n&&r.parentId;)r=t.getRow(r.parentId,!0),n=r.getIsExpanded();return n},e.getToggleExpandedHandler=()=>{let t=e.getCanExpand();return()=>{t&&e.toggleExpanded()}}}},V0=0,H0=10,U0=()=>({pageIndex:V0,pageSize:H0}),W0={getInitialState:e=>({...e,pagination:{...U0(),...e?.pagination}}),getDefaultOptions:e=>({onPaginationChange:X1(`pagination`,e)}),createTable:e=>{let t=!1,n=!1;e._autoResetPageIndex=()=>{if(!t){e._queue(()=>{t=!0});return}if(e.options.autoResetAll??e.options.autoResetPageIndex??!e.options.manualPagination){if(n)return;n=!0,e._queue(()=>{e.resetPageIndex(),n=!1})}},e.setPagination=t=>e.options.onPaginationChange==null?void 0:e.options.onPaginationChange(e=>Y1(t,e)),e.resetPagination=t=>{e.setPagination(t?U0():e.initialState.pagination??U0())},e.setPageIndex=t=>{e.setPagination(n=>{let r=Y1(t,n.pageIndex),i=e.options.pageCount===void 0||e.options.pageCount===-1?2**53-1:e.options.pageCount-1;return r=Math.max(0,Math.min(r,i)),{...n,pageIndex:r}})},e.resetPageIndex=t=>{var n;e.setPageIndex(t?V0:((n=e.initialState)==null||(n=n.pagination)==null?void 0:n.pageIndex)??V0)},e.resetPageSize=t=>{var n;e.setPageSize(t?H0:((n=e.initialState)==null||(n=n.pagination)==null?void 0:n.pageSize)??H0)},e.setPageSize=t=>{e.setPagination(e=>{let n=Math.max(1,Y1(t,e.pageSize)),r=e.pageSize*e.pageIndex,i=Math.floor(r/n);return{...e,pageIndex:i,pageSize:n}})},e.setPageCount=t=>e.setPagination(n=>{let r=Y1(t,e.options.pageCount??-1);return typeof r==`number`&&(r=Math.max(-1,r)),{...n,pageCount:r}}),e.getPageOptions=e0(()=>[e.getPageCount()],e=>{let t=[];return e&&e>0&&(t=[...Array(e)].fill(null).map((e,t)=>t)),t},t0(e.options,`debugTable`,`getPageOptions`)),e.getCanPreviousPage=()=>e.getState().pagination.pageIndex>0,e.getCanNextPage=()=>{let{pageIndex:t}=e.getState().pagination,n=e.getPageCount();return n===-1?!0:n===0?!1:t<n-1},e.previousPage=()=>e.setPageIndex(e=>e-1),e.nextPage=()=>e.setPageIndex(e=>e+1),e.firstPage=()=>e.setPageIndex(0),e.lastPage=()=>e.setPageIndex(e.getPageCount()-1),e.getPrePaginationRowModel=()=>e.getExpandedRowModel(),e.getPaginationRowModel=()=>(!e._getPaginationRowModel&&e.options.getPaginationRowModel&&(e._getPaginationRowModel=e.options.getPaginationRowModel(e)),e.options.manualPagination||!e._getPaginationRowModel?e.getPrePaginationRowModel():e._getPaginationRowModel()),e.getPageCount=()=>e.options.pageCount??Math.ceil(e.getRowCount()/e.getState().pagination.pageSize),e.getRowCount=()=>e.options.rowCount??e.getPrePaginationRowModel().rows.length}},G0=()=>({top:[],bottom:[]}),K0={getInitialState:e=>({rowPinning:G0(),...e}),getDefaultOptions:e=>({onRowPinningChange:X1(`rowPinning`,e)}),createRow:(e,t)=>{e.pin=(n,r,i)=>{let a=r?e.getLeafRows().map(e=>{let{id:t}=e;return t}):[],o=i?e.getParentRows().map(e=>{let{id:t}=e;return t}):[],s=new Set([...o,e.id,...a]);t.setRowPinning(e=>n===`bottom`?{top:(e?.top??[]).filter(e=>!(s!=null&&s.has(e))),bottom:[...(e?.bottom??[]).filter(e=>!(s!=null&&s.has(e))),...Array.from(s)]}:n===`top`?{top:[...(e?.top??[]).filter(e=>!(s!=null&&s.has(e))),...Array.from(s)],bottom:(e?.bottom??[]).filter(e=>!(s!=null&&s.has(e)))}:{top:(e?.top??[]).filter(e=>!(s!=null&&s.has(e))),bottom:(e?.bottom??[]).filter(e=>!(s!=null&&s.has(e)))})},e.getCanPin=()=>{let{enableRowPinning:n,enablePinning:r}=t.options;return typeof n==`function`?n(e):n??r??!0},e.getIsPinned=()=>{let n=[e.id],{top:r,bottom:i}=t.getState().rowPinning,a=n.some(e=>r?.includes(e)),o=n.some(e=>i?.includes(e));return a?`top`:o?`bottom`:!1},e.getPinnedIndex=()=>{let n=e.getIsPinned();return n?((n===`top`?t.getTopRows():t.getBottomRows())?.map(e=>{let{id:t}=e;return t}))?.indexOf(e.id)??-1:-1}},createTable:e=>{e.setRowPinning=t=>e.options.onRowPinningChange==null?void 0:e.options.onRowPinningChange(t),e.resetRowPinning=t=>e.setRowPinning(t?G0():e.initialState?.rowPinning??G0()),e.getIsSomeRowsPinned=t=>{let n=e.getState().rowPinning;return t?!!n[t]?.length:!!(n.top?.length||n.bottom?.length)},e._getPinnedRows=(t,n,r)=>(e.options.keepPinnedRows??!0?(n??[]).map(t=>{let n=e.getRow(t,!0);return n.getIsAllParentsExpanded()?n:null}):(n??[]).map(e=>t.find(t=>t.id===e))).filter(Boolean).map(e=>({...e,position:r})),e.getTopRows=e0(()=>[e.getRowModel().rows,e.getState().rowPinning.top],(t,n)=>e._getPinnedRows(t,n,`top`),t0(e.options,`debugRows`,`getTopRows`)),e.getBottomRows=e0(()=>[e.getRowModel().rows,e.getState().rowPinning.bottom],(t,n)=>e._getPinnedRows(t,n,`bottom`),t0(e.options,`debugRows`,`getBottomRows`)),e.getCenterRows=e0(()=>[e.getRowModel().rows,e.getState().rowPinning.top,e.getState().rowPinning.bottom],(e,t,n)=>{let r=new Set([...t??[],...n??[]]);return e.filter(e=>!r.has(e.id))},t0(e.options,`debugRows`,`getCenterRows`))}},q0={getInitialState:e=>({rowSelection:{},...e}),getDefaultOptions:e=>({onRowSelectionChange:X1(`rowSelection`,e),enableRowSelection:!0,enableMultiRowSelection:!0,enableSubRowSelection:!0}),createTable:e=>{e.setRowSelection=t=>e.options.onRowSelectionChange==null?void 0:e.options.onRowSelectionChange(t),e.resetRowSelection=t=>e.setRowSelection(t?{}:e.initialState.rowSelection??{}),e.toggleAllRowsSelected=t=>{e.setRowSelection(n=>{t=t===void 0?!e.getIsAllRowsSelected():t;let r={...n},i=e.getPreGroupedRowModel().flatRows;return t?i.forEach(e=>{e.getCanSelect()&&(r[e.id]=!0)}):i.forEach(e=>{delete r[e.id]}),r})},e.toggleAllPageRowsSelected=t=>e.setRowSelection(n=>{let r=t===void 0?!e.getIsAllPageRowsSelected():t,i={...n};return e.getRowModel().rows.forEach(t=>{J0(i,t.id,r,!0,e)}),i}),e.getPreSelectedRowModel=()=>e.getCoreRowModel(),e.getSelectedRowModel=e0(()=>[e.getState().rowSelection,e.getCoreRowModel()],(t,n)=>Object.keys(t).length?Y0(e,n):{rows:[],flatRows:[],rowsById:{}},t0(e.options,`debugTable`,`getSelectedRowModel`)),e.getFilteredSelectedRowModel=e0(()=>[e.getState().rowSelection,e.getFilteredRowModel()],(t,n)=>Object.keys(t).length?Y0(e,n):{rows:[],flatRows:[],rowsById:{}},t0(e.options,`debugTable`,`getFilteredSelectedRowModel`)),e.getGroupedSelectedRowModel=e0(()=>[e.getState().rowSelection,e.getSortedRowModel()],(t,n)=>Object.keys(t).length?Y0(e,n):{rows:[],flatRows:[],rowsById:{}},t0(e.options,`debugTable`,`getGroupedSelectedRowModel`)),e.getIsAllRowsSelected=()=>{let t=e.getFilteredRowModel().flatRows,{rowSelection:n}=e.getState(),r=!!(t.length&&Object.keys(n).length);return r&&t.some(e=>e.getCanSelect()&&!n[e.id])&&(r=!1),r},e.getIsAllPageRowsSelected=()=>{let t=e.getPaginationRowModel().flatRows.filter(e=>e.getCanSelect()),{rowSelection:n}=e.getState(),r=!!t.length;return r&&t.some(e=>!n[e.id])&&(r=!1),r},e.getIsSomeRowsSelected=()=>{let t=Object.keys(e.getState().rowSelection??{}).length;return t>0&&t<e.getFilteredRowModel().flatRows.length},e.getIsSomePageRowsSelected=()=>{let t=e.getPaginationRowModel().flatRows;return e.getIsAllPageRowsSelected()?!1:t.filter(e=>e.getCanSelect()).some(e=>e.getIsSelected()||e.getIsSomeSelected())},e.getToggleAllRowsSelectedHandler=()=>t=>{e.toggleAllRowsSelected(t.target.checked)},e.getToggleAllPageRowsSelectedHandler=()=>t=>{e.toggleAllPageRowsSelected(t.target.checked)}},createRow:(e,t)=>{e.toggleSelected=(n,r)=>{let i=e.getIsSelected();t.setRowSelection(a=>{if(n=n===void 0?!i:n,e.getCanSelect()&&i===n)return a;let o={...a};return J0(o,e.id,n,r?.selectChildren??!0,t),o})},e.getIsSelected=()=>{let{rowSelection:n}=t.getState();return X0(e,n)},e.getIsSomeSelected=()=>{let{rowSelection:n}=t.getState();return Z0(e,n)===`some`},e.getIsAllSubRowsSelected=()=>{let{rowSelection:n}=t.getState();return Z0(e,n)===`all`},e.getCanSelect=()=>typeof t.options.enableRowSelection==`function`?t.options.enableRowSelection(e):t.options.enableRowSelection??!0,e.getCanSelectSubRows=()=>typeof t.options.enableSubRowSelection==`function`?t.options.enableSubRowSelection(e):t.options.enableSubRowSelection??!0,e.getCanMultiSelect=()=>typeof t.options.enableMultiRowSelection==`function`?t.options.enableMultiRowSelection(e):t.options.enableMultiRowSelection??!0,e.getToggleSelectedHandler=()=>{let t=e.getCanSelect();return n=>{t&&e.toggleSelected(n.target?.checked)}}}},J0=(e,t,n,r,i)=>{var a;let o=i.getRow(t,!0);n?(o.getCanMultiSelect()||Object.keys(e).forEach(t=>delete e[t]),o.getCanSelect()&&(e[t]=!0)):delete e[t],r&&(a=o.subRows)!=null&&a.length&&o.getCanSelectSubRows()&&o.subRows.forEach(t=>J0(e,t.id,n,r,i))};function Y0(e,t){let n=e.getState().rowSelection,r=[],i={},a=function(e,t){return e.map(e=>{var t;let o=X0(e,n);if(o&&(r.push(e),i[e.id]=e),(t=e.subRows)!=null&&t.length&&(e={...e,subRows:a(e.subRows)}),o)return e}).filter(Boolean)};return{rows:a(t.rows),flatRows:r,rowsById:i}}function X0(e,t){return t[e.id]??!1}function Z0(e,t,n){var r;if(!((r=e.subRows)!=null&&r.length))return!1;let i=!0,a=!1;return e.subRows.forEach(e=>{if(!(a&&!i)&&(e.getCanSelect()&&(X0(e,t)?a=!0:i=!1),e.subRows&&e.subRows.length)){let n=Z0(e,t);n===`all`?a=!0:(n===`some`&&(a=!0),i=!1)}}),i?`all`:a?`some`:!1}var Q0=/([0-9]+)/gm,$0=(e,t,n)=>s2(o2(e.getValue(n)).toLowerCase(),o2(t.getValue(n)).toLowerCase()),e2=(e,t,n)=>s2(o2(e.getValue(n)),o2(t.getValue(n))),t2=(e,t,n)=>a2(o2(e.getValue(n)).toLowerCase(),o2(t.getValue(n)).toLowerCase()),n2=(e,t,n)=>a2(o2(e.getValue(n)),o2(t.getValue(n))),r2=(e,t,n)=>{let r=e.getValue(n),i=t.getValue(n);return r>i?1:r<i?-1:0},i2=(e,t,n)=>a2(e.getValue(n),t.getValue(n));function a2(e,t){return e===t?0:e>t?1:-1}function o2(e){return typeof e==`number`?isNaN(e)||e===1/0||e===-1/0?``:String(e):typeof e==`string`?e:``}function s2(e,t){let n=e.split(Q0).filter(Boolean),r=t.split(Q0).filter(Boolean);for(;n.length&&r.length;){let e=n.shift(),t=r.shift(),i=parseInt(e,10),a=parseInt(t,10),o=[i,a].sort();if(isNaN(o[0])){if(e>t)return 1;if(t>e)return-1;continue}if(isNaN(o[1]))return isNaN(i)?-1:1;if(i>a)return 1;if(a>i)return-1}return n.length-r.length}var c2={alphanumeric:$0,alphanumericCaseSensitive:e2,text:t2,textCaseSensitive:n2,datetime:r2,basic:i2},l2=[o0,I0,E0,O0,l0,x0,R0,z0,{getInitialState:e=>({sorting:[],...e}),getDefaultColumnDef:()=>({sortingFn:`auto`,sortUndefined:1}),getDefaultOptions:e=>({onSortingChange:X1(`sorting`,e),isMultiSortEvent:e=>e.shiftKey}),createColumn:(e,t)=>{e.getAutoSortingFn=()=>{let n=t.getFilteredRowModel().flatRows.slice(10),r=!1;for(let t of n){let n=t?.getValue(e.id);if(Object.prototype.toString.call(n)===`[object Date]`)return c2.datetime;if(typeof n==`string`&&(r=!0,n.split(Q0).length>1))return c2.alphanumeric}return r?c2.text:c2.basic},e.getAutoSortDir=()=>typeof t.getFilteredRowModel().flatRows[0]?.getValue(e.id)==`string`?`asc`:`desc`,e.getSortingFn=()=>{if(!e)throw Error();return Z1(e.columnDef.sortingFn)?e.columnDef.sortingFn:e.columnDef.sortingFn===`auto`?e.getAutoSortingFn():t.options.sortingFns?.[e.columnDef.sortingFn]??c2[e.columnDef.sortingFn]},e.toggleSorting=(n,r)=>{let i=e.getNextSortingOrder(),a=n!=null;t.setSorting(o=>{let s=o?.find(t=>t.id===e.id),c=o?.findIndex(t=>t.id===e.id),l=[],u,d=a?n:i===`desc`;return u=o!=null&&o.length&&e.getCanMultiSort()&&r?s?`toggle`:`add`:o!=null&&o.length&&c!==o.length-1?`replace`:s?`toggle`:`replace`,u===`toggle`&&(a||i||(u=`remove`)),u===`add`?(l=[...o,{id:e.id,desc:d}],l.splice(0,l.length-(t.options.maxMultiSortColCount??2**53-1))):l=u===`toggle`?o.map(t=>t.id===e.id?{...t,desc:d}:t):u===`remove`?o.filter(t=>t.id!==e.id):[{id:e.id,desc:d}],l})},e.getFirstSortDir=()=>e.columnDef.sortDescFirst??t.options.sortDescFirst??e.getAutoSortDir()===`desc`?`desc`:`asc`,e.getNextSortingOrder=n=>{let r=e.getFirstSortDir(),i=e.getIsSorted();return i?i!==r&&(t.options.enableSortingRemoval??!0)&&(!n||(t.options.enableMultiRemove??!0))?!1:i===`desc`?`asc`:`desc`:r},e.getCanSort=()=>(e.columnDef.enableSorting??!0)&&(t.options.enableSorting??!0)&&!!e.accessorFn,e.getCanMultiSort=()=>e.columnDef.enableMultiSort??t.options.enableMultiSort??!!e.accessorFn,e.getIsSorted=()=>{let n=t.getState().sorting?.find(t=>t.id===e.id);return n?n.desc?`desc`:`asc`:!1},e.getSortIndex=()=>t.getState().sorting?.findIndex(t=>t.id===e.id)??-1,e.clearSorting=()=>{t.setSorting(t=>t!=null&&t.length?t.filter(t=>t.id!==e.id):[])},e.getToggleSortingHandler=()=>{let n=e.getCanSort();return r=>{n&&(r.persist==null||r.persist(),e.toggleSorting==null||e.toggleSorting(void 0,e.getCanMultiSort()?t.options.isMultiSortEvent==null?void 0:t.options.isMultiSortEvent(r):!1))}}},createTable:e=>{e.setSorting=t=>e.options.onSortingChange==null?void 0:e.options.onSortingChange(t),e.resetSorting=t=>{e.setSorting(t?[]:e.initialState?.sorting??[])},e.getPreSortedRowModel=()=>e.getGroupedRowModel(),e.getSortedRowModel=()=>(!e._getSortedRowModel&&e.options.getSortedRowModel&&(e._getSortedRowModel=e.options.getSortedRowModel(e)),e.options.manualSorting||!e._getSortedRowModel?e.getPreSortedRowModel():e._getSortedRowModel())}},w0,B0,W0,K0,q0,M0];function u2(e){let t=[...l2,...e._features??[]],n={_features:t},r=n._features.reduce((e,t)=>Object.assign(e,t.getDefaultOptions==null?void 0:t.getDefaultOptions(n)),{}),i=e=>n.options.mergeOptions?n.options.mergeOptions(r,e):{...r,...e},a={...e.initialState??{}};n._features.forEach(e=>{a=(e.getInitialState==null?void 0:e.getInitialState(a))??a});let o=[],s=!1,c={_features:t,options:{...r,...e},initialState:a,_queue:e=>{o.push(e),s||(s=!0,Promise.resolve().then(()=>{for(;o.length;)o.shift()();s=!1}).catch(e=>setTimeout(()=>{throw e})))},reset:()=>{n.setState(n.initialState)},setOptions:e=>{n.options=i(Y1(e,n.options))},getState:()=>n.options.state,setState:e=>{n.options.onStateChange==null||n.options.onStateChange(e)},_getRowId:(e,t,r)=>(n.options.getRowId==null?void 0:n.options.getRowId(e,t,r))??`${r?[r.id,t].join(`.`):t}`,getCoreRowModel:()=>(n._getCoreRowModel||=n.options.getCoreRowModel(n),n._getCoreRowModel()),getRowModel:()=>n.getPaginationRowModel(),getRow:(e,t)=>{let r=(t?n.getPrePaginationRowModel():n.getRowModel()).rowsById[e];if(!r&&(r=n.getCoreRowModel().rowsById[e],!r))throw Error();return r},_getDefaultColumnDef:e0(()=>[n.options.defaultColumn],e=>(e??={},{header:e=>{let t=e.header.column.columnDef;return t.accessorKey?t.accessorKey:t.accessorFn?t.id:null},cell:e=>{var t;return((t=e.renderValue())==null||t.toString==null?void 0:t.toString())??null},...n._features.reduce((e,t)=>Object.assign(e,t.getDefaultColumnDef==null?void 0:t.getDefaultColumnDef()),{}),...e}),t0(e,`debugColumns`,`_getDefaultColumnDef`)),_getColumnDefs:()=>n.options.columns,getAllColumns:e0(()=>[n._getColumnDefs()],e=>{let t=function(e,r,i){return i===void 0&&(i=0),e.map(e=>{let a=r0(n,e,i,r),o=e;return a.columns=o.columns?t(o.columns,a,i+1):[],a})};return t(e)},t0(e,`debugColumns`,`getAllColumns`)),getAllFlatColumns:e0(()=>[n.getAllColumns()],e=>e.flatMap(e=>e.getFlatColumns()),t0(e,`debugColumns`,`getAllFlatColumns`)),_getAllFlatColumnsById:e0(()=>[n.getAllFlatColumns()],e=>e.reduce((e,t)=>(e[t.id]=t,e),{}),t0(e,`debugColumns`,`getAllFlatColumnsById`)),getAllLeafColumns:e0(()=>[n.getAllColumns(),n._getOrderColumnsFn()],(e,t)=>t(e.flatMap(e=>e.getLeafColumns())),t0(e,`debugColumns`,`getAllLeafColumns`)),getColumn:e=>n._getAllFlatColumnsById()[e]};Object.assign(n,c);for(let e=0;e<n._features.length;e++){let t=n._features[e];t==null||t.createTable==null||t.createTable(n)}return n}function d2(){return e=>e0(()=>[e.options.data],t=>{let n={rows:[],flatRows:[],rowsById:{}},r=function(t,i,a){i===void 0&&(i=0);let o=[];for(let c=0;c<t.length;c++){let l=c0(e,e._getRowId(t[c],c,a),t[c],c,i,void 0,a?.id);if(n.flatRows.push(l),n.rowsById[l.id]=l,o.push(l),e.options.getSubRows){var s;l.originalSubRows=e.options.getSubRows(t[c],c),(s=l.originalSubRows)!=null&&s.length&&(l.subRows=r(l.originalSubRows,i+1,l))}}return o};return n.rows=r(t),n},t0(e.options,`debugTable`,`getRowModel`,()=>e._autoResetPageIndex()))}function f2(e,t){return e?p2(e)?v.createElement(e,t):e:null}function p2(e){return m2(e)||typeof e==`function`||h2(e)}function m2(e){return typeof e==`function`&&(()=>{let t=Object.getPrototypeOf(e);return t.prototype&&t.prototype.isReactComponent})()}function h2(e){return typeof e==`object`&&typeof e.$$typeof==`symbol`&&[`react.memo`,`react.forward_ref`].includes(e.$$typeof.description)}function g2(e){let t={state:{},onStateChange:()=>{},renderFallbackValue:null,...e},[n]=v.useState(()=>({current:u2(t)})),[r,i]=v.useState(()=>n.current.initialState);return n.current.setOptions(t=>({...t,...e,state:{...r,...e.state},onStateChange:t=>{i(t),e.onStateChange==null||e.onStateChange(t)}})),n.current}var _2={"super admin":`default`,admin:`secondary`,contributor:`outline`,editor:`secondary`,viewer:`outline`};function v2({roleId:e,roleName:t,roles:n}){let r=n.find(t=>t.id===e),i=t??r?.name??e;return(0,U.jsx)(vw,{variant:_2[i.toLowerCase()]??`secondary`,children:i})}function y2({user:e,currentUserId:t,currentUserRole:n,onEdit:r,onDelete:i}){let a=e.id===t,o=(e.role_name??``).toLowerCase()===`super admin`,s=n.toLowerCase()===`super admin`;return(0,U.jsxs)(`div`,{className:`flex items-center justify-end gap-1`,children:[(0,U.jsx)(J,{size:`icon`,variant:`ghost`,className:`flex size-7 items-center justify-center rounded text-muted-foreground hover:bg-accent hover:text-accent-foreground`,disabled:o&&!a&&!s,onClick:()=>r(e),children:(0,U.jsx)(No,{className:`size-3.5`})}),(0,U.jsx)(J,{size:`icon`,variant:`ghost`,className:`flex size-8 items-center justify-center rounded text-destructive hover:bg-destructive/10 hover:text-destructive`,disabled:a||o,onClick:()=>i(e),children:(0,U.jsx)(qo,{className:`size-3.5`})})]})}var b2={email:``,password:``,roleId:``,enabled:!0};function x2(){let{user:e,updateUser:t}=ga(),{editorialMode:n}=ya(),{data:r,loading:i,refetch:a}=wa(`/cms/admin/users`),{data:o,loading:s}=wa(`/cms/admin/roles`),c=i||s,{request:l,loading:u,error:d}=Vv(),[f,p]=(0,v.useState)(!1),[m,h]=(0,v.useState)(b2),[g,_]=(0,v.useState)(null),[y,b]=(0,v.useState)({email:``,roleId:``,firstName:``,lastName:``,enabled:!0}),[x,S]=(0,v.useState)(null),C=o??[],w=e?.role?.toLowerCase()===`super admin`,T=C.filter(e=>n||![`Editor`,`Viewer`].includes(e.name)),E=w?T:T.filter(e=>e.name.toLowerCase()!==`super admin`),D=(0,v.useMemo)(()=>[{id:`name`,header:`Name`,cell:({row:e})=>{let{first_name:t,last_name:n}=e.original;return!t&&!n?(0,U.jsx)(`span`,{className:`text-muted-foreground`,children:`—`}):(0,U.jsx)(`span`,{className:`font-bold`,children:[t,n].filter(Boolean).join(` `)})}},{accessorKey:`email`,header:`Email`},{accessorKey:`role_id`,header:`Role`,cell:({row:e,getValue:t})=>(0,U.jsx)(v2,{roleId:t(),roleName:e.original.role_name,roles:C})},{accessorKey:`enabled`,header:`Enabled`,cell:({row:t,getValue:n})=>(0,U.jsx)(nj,{checked:!!(n()??!0),onCheckedChange:async e=>{try{await l(`/cms/admin/users/${t.original.id}`,`PUT`,{enabled:e}),a()}catch{}},disabled:t.original.id===e?.id||u})},{id:`actions`,header:``,cell:({row:t})=>(0,U.jsx)(y2,{user:t.original,currentUserId:e?.id??``,currentUserRole:e?.role??``,onEdit:e=>{_(e),b({email:e.email,roleId:e.role_id,firstName:e.first_name??``,lastName:e.last_name??``,enabled:e.enabled??!0})},onDelete:S})}],[C,e?.id,e?.role,l,a,u]),O=g2({data:(0,v.useMemo)(()=>[...r??[]].sort((e,t)=>{let n=[e.first_name,e.last_name].filter(Boolean).join(` `)||e.email,r=[t.first_name,t.last_name].filter(Boolean).join(` `)||t.email;return n.localeCompare(r)}),[r]),columns:D,getCoreRowModel:d2()});async function k(e){e.preventDefault();try{await l(`/cms/admin/users`,`POST`,m),p(!1),h(b2),a()}catch{}}async function A(n){n.preventDefault();try{await l(`/cms/admin/users/${g.id}`,`PUT`,y),g.id===e?.id&&t({email:y.email,firstName:y.firstName||null,lastName:y.lastName||null}),_(null),a()}catch{}}async function j(){try{await l(`/cms/admin/users/${x.id}`,`DELETE`),S(null),a()}catch{}}return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(yy,{children:(0,U.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`h1`,{className:`text-2xl font-bold -mt-2`,children:`Users`}),(0,U.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`Manage who has access to the admin panel.`})]}),(0,U.jsxs)(J,{onClick:()=>p(!0),children:[(0,U.jsx)(Po,{className:`size-4`}),`New user`]})]})}),(0,U.jsxs)(`section`,{className:`mt-24`,children:[(0,U.jsx)(`div`,{className:`rounded-md border`,children:(0,U.jsxs)(Rw,{children:[(0,U.jsx)(zw,{className:`font-bold uppercase`,children:O.getHeaderGroups().map(e=>(0,U.jsx)(Vw,{className:`hover:bg-transparent`,children:e.headers.map(e=>(0,U.jsx)(Hw,{className:`px-4 py-3 text-left font-medium text-muted-foreground`,children:f2(e.column.columnDef.header,e.getContext())},e.id))},e.id))}),(0,U.jsx)(Bw,{children:c?(0,U.jsx)(Vw,{children:(0,U.jsx)(Uw,{colSpan:D.length,className:`h-24`,children:(0,U.jsx)(by,{className:`mx-auto size-5`})})}):O.getRowModel().rows.length===0?(0,U.jsx)(Vw,{children:(0,U.jsx)(Uw,{colSpan:D.length,className:`h-24 text-center text-muted-foreground`,children:`No users found.`})}):O.getRowModel().rows.map(e=>(0,U.jsx)(Vw,{children:e.getVisibleCells().map(e=>(0,U.jsx)(Uw,{className:`px-4 py-3`,children:f2(e.column.columnDef.cell,e.getContext())},e.id))},e.id))})]})}),(0,U.jsx)(yw,{open:f,onOpenChange:p,children:(0,U.jsxs)(Cw,{className:`sm:max-w-md`,children:[(0,U.jsx)(ww,{children:(0,U.jsx)(Ew,{children:`New user`})}),(0,U.jsxs)(`form`,{id:`create-user-form`,onSubmit:k,className:`flex flex-col gap-4`,children:[(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsx)(X,{htmlFor:`c-email`,children:`Email`}),(0,U.jsx)(Hv,{id:`c-email`,type:`email`,placeholder:`user@example.com`,value:m.email,onChange:e=>h(t=>({...t,email:e.target.value})),required:!0})]}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsx)(X,{htmlFor:`c-password`,children:`Password`}),(0,U.jsx)(Hv,{id:`c-password`,type:`password`,placeholder:`Min. 8 characters`,value:m.password,onChange:e=>h(t=>({...t,password:e.target.value})),required:!0})]}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsx)(X,{htmlFor:`c-role`,children:`Role`}),(0,U.jsxs)(Ow,{value:m.roleId,onValueChange:e=>h(t=>({...t,roleId:e})),children:[(0,U.jsx)(jw,{id:`c-role`,children:(0,U.jsx)(Aw,{placeholder:`Select a role`})}),(0,U.jsx)(Pw,{children:E.map(e=>(0,U.jsx)(Iw,{value:e.id,children:e.name.charAt(0).toUpperCase()+e.name.slice(1)},e.id))})]})]}),(0,U.jsxs)(`div`,{className:`flex items-center justify-between rounded-md border p-3`,children:[(0,U.jsx)(X,{htmlFor:`c-enabled`,children:`Enabled`}),(0,U.jsx)(nj,{id:`c-enabled`,checked:m.enabled,onCheckedChange:e=>h(t=>({...t,enabled:e}))})]}),d&&(0,U.jsx)(`p`,{className:`text-sm text-destructive`,children:d})]}),(0,U.jsxs)(Tw,{children:[(0,U.jsx)(J,{variant:`outline`,type:`button`,onClick:()=>p(!1),children:`Cancel`}),(0,U.jsx)(J,{type:`submit`,form:`create-user-form`,disabled:u,children:u?`Creating…`:`Create user`})]})]})}),(0,U.jsx)(yw,{open:!!g,onOpenChange:e=>{e||_(null)},children:(0,U.jsxs)(Cw,{className:`sm:max-w-md`,children:[(0,U.jsx)(ww,{children:(0,U.jsx)(Ew,{children:`Edit user`})}),(0,U.jsxs)(`form`,{id:`edit-user-form`,onSubmit:A,className:`flex flex-col gap-4`,children:[(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsx)(X,{htmlFor:`e-email`,children:`Email`}),(0,U.jsx)(Hv,{id:`e-email`,type:`email`,value:y.email,onChange:e=>b(t=>({...t,email:e.target.value})),required:!0})]}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsx)(X,{htmlFor:`e-fname`,children:`First name`}),(0,U.jsx)(Hv,{id:`e-fname`,value:y.firstName,onChange:e=>b(t=>({...t,firstName:e.target.value}))})]}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsx)(X,{htmlFor:`e-lname`,children:`Last name`}),(0,U.jsx)(Hv,{id:`e-lname`,value:y.lastName,onChange:e=>b(t=>({...t,lastName:e.target.value}))})]}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsx)(X,{htmlFor:`e-role`,children:`Role`}),(0,U.jsxs)(Ow,{value:y.roleId,onValueChange:e=>b(t=>({...t,roleId:e})),children:[(0,U.jsx)(jw,{id:`e-role`,children:(0,U.jsx)(Aw,{placeholder:`Select a role`})}),(0,U.jsx)(Pw,{children:E.map(e=>(0,U.jsx)(Iw,{value:e.id,children:e.name.charAt(0).toUpperCase()+e.name.slice(1)},e.id))})]})]}),(0,U.jsxs)(`div`,{className:`flex items-center justify-between rounded-md border p-3`,children:[(0,U.jsx)(X,{htmlFor:`e-enabled`,children:`Enabled`}),(0,U.jsx)(nj,{id:`e-enabled`,checked:y.enabled,onCheckedChange:e=>b(t=>({...t,enabled:e}))})]}),d&&(0,U.jsx)(`p`,{className:`text-sm text-destructive`,children:d})]}),(0,U.jsxs)(Tw,{children:[(0,U.jsx)(J,{variant:`outline`,type:`button`,onClick:()=>_(null),children:`Cancel`}),(0,U.jsx)(J,{type:`submit`,form:`edit-user-form`,disabled:u,children:u?`Saving…`:`Save changes`})]})]})}),(0,U.jsx)(yw,{open:!!x,onOpenChange:e=>{e||S(null)},children:(0,U.jsxs)(Cw,{className:`sm:max-w-sm`,children:[(0,U.jsx)(ww,{children:(0,U.jsx)(Ew,{children:`Delete user`})}),(0,U.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Are you sure you want to delete`,` `,(0,U.jsx)(`span`,{className:`font-medium text-foreground`,children:x?.email}),`? This action cannot be undone.`]}),d&&(0,U.jsx)(`p`,{className:`text-sm text-destructive`,children:d}),(0,U.jsxs)(Tw,{children:[(0,U.jsx)(J,{variant:`outline`,onClick:()=>S(null),children:`Cancel`}),(0,U.jsx)(J,{variant:`destructive`,onClick:j,disabled:u,children:u?`Deleting…`:`Delete`})]})]})})]})]})}var S2=[{key:`content-types`,label:`Content Types`,actions:[`read`,`write`,`delete`]},{key:`entries`,label:`Entries`,actions:[`read`,`write`,`delete`]},{key:`media`,label:`Media`,actions:[`read`,`write`,`delete`]},{key:`settings:overview`,label:`Settings / Overview`,actions:[`read`,`write`]},{key:`settings:users`,label:`Settings / Users`,actions:[`read`,`write`,`delete`]},{key:`settings:roles`,label:`Settings / Roles`,actions:[`read`,`write`]},{key:`settings:api-tokens`,label:`Settings / API Tokens`,actions:[`read`,`write`,`delete`]},{key:`settings:webhooks`,label:`Settings / Webhooks`,actions:[`read`,`write`,`delete`]}],C2=[{key:`read`,label:`R`},{key:`write`,label:`W`},{key:`delete`,label:`D`}],w2=[`Super Admin`,`Admin`,`Editor`,`Contributor`],T2=`w-44 min-w-44 max-w-44`;function E2(e){return Object.fromEntries(e.map(e=>[e.id,new Set(e.permissions)]))}function D2(e,t){return e.includes(t)}function O2(){let{user:e}=ga(),{editorialMode:t}=ya(),{data:n,loading:r,refetch:i}=wa(`/cms/admin/roles`),{request:a,loading:o}=Vv(),[s,c]=(0,v.useState)({}),[l,u]=(0,v.useState)(new Set),[d,f]=(0,v.useState)(!1);(0,v.useEffect)(()=>{n&&c(E2(n))},[n]);function p(e,t){c(n=>{let r=new Set(n[e]);return r.has(t)?r.delete(t):r.add(t),{...n,[e]:r}}),u(t=>new Set(t).add(e))}async function m(e){await a(`/cms/admin/roles/${e.id}`,`PUT`,{permissions:Array.from(s[e.id]??[])}),u(t=>{let n=new Set(t);return n.delete(e.id),n})}async function h(){await a(`/cms/admin/roles/reset`,`POST`),f(!1),u(new Set),i()}let g=e?.role===`Super Admin`,_=(n??[]).filter(e=>e.name!==`Super Admin`).filter(e=>e.name!==`Viewer`).filter(e=>t||![`Editor`,`Viewer`].includes(e.name)).sort((e,t)=>{let n=w2.indexOf(e.name),r=w2.indexOf(t.name),i=n===-1?2**53-1:n,a=r===-1?2**53-1:r;return i===a?e.name.localeCompare(t.name):i-a}),y=(n??[]).find(e=>e.name===`Super Admin`);return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(yy,{children:(0,U.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`h1`,{className:`text-2xl font-bold -mt-2`,children:`Roles`}),(0,U.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`Configure what each role can do across the CMS.`})]}),g&&(0,U.jsxs)(J,{variant:`outline`,onClick:()=>f(!0),children:[(0,U.jsx)(Io,{className:`size-4`}),`Reset defaults`]})]})}),(0,U.jsxs)(`section`,{className:`mt-24`,children:[(0,U.jsx)(`div`,{className:`rounded-md border`,children:(0,U.jsxs)(Rw,{children:[(0,U.jsxs)(zw,{children:[(0,U.jsxs)(Vw,{className:`hover:bg-transparent`,children:[(0,U.jsx)(Hw,{className:`w-40`,rowSpan:2}),y&&(0,U.jsx)(Hw,{colSpan:3,className:`border-l text-center ${T2}`,children:y.name}),_.map(e=>(0,U.jsx)(Hw,{colSpan:3,className:`border-l ${T2}`,children:(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,U.jsx)(`span`,{children:e.name}),(0,U.jsxs)(J,{size:`sm`,variant:l.has(e.id)?`default`:`ghost`,className:`h-6 px-2 text-xs`,disabled:!l.has(e.id)||o,onClick:()=>m(e),children:[(0,U.jsx)(Lo,{className:`size-3`}),`Save`]})]})},e.id))]}),(0,U.jsxs)(Vw,{className:`hover:bg-transparent`,children:[y&&C2.map((e,t)=>(0,U.jsx)(Hw,{className:`w-12 text-center font-normal ${t===0?`border-l`:``}`,children:e.label},e.key)),_.map(e=>C2.map((t,n)=>(0,U.jsx)(Hw,{className:`w-12 text-center font-normal ${n===0?`border-l`:``}`,children:t.label},`${e.id}-${t.key}`)))]})]}),(0,U.jsx)(Bw,{children:r?(0,U.jsx)(Vw,{children:(0,U.jsx)(Uw,{colSpan:99,className:`h-24`,children:(0,U.jsx)(by,{className:`mx-auto size-5`})})}):S2.map(({key:e,label:t,actions:n})=>(0,U.jsxs)(Vw,{children:[(0,U.jsx)(Uw,{className:`font-medium`,children:t}),y&&C2.map((e,t)=>(0,U.jsx)(Uw,{className:`text-center ${t===0?`border-l`:``}`,children:D2(n,e.key)?(0,U.jsx)(EO,{checked:!0,disabled:!0}):(0,U.jsx)(`span`,{className:`text-muted-foreground`,children:`—`})},e.key)),_.map(t=>C2.map((r,i)=>{let a=D2(n,r.key),o=`${e}:${r.key}`;return(0,U.jsx)(Uw,{className:`text-center ${i===0?`border-l`:``}`,children:a?(0,U.jsx)(EO,{checked:s[t.id]?.has(o)??!1,onCheckedChange:()=>p(t.id,o)}):(0,U.jsx)(`span`,{className:`text-muted-foreground`,children:`—`})},`${t.id}-${r.key}`)}))]},e))})]})}),t&&(0,U.jsxs)(`div`,{className:`mt-3 rounded-md border bg-muted/30 p-3`,children:[(0,U.jsx)(`p`,{className:`text-sm font-medium`,children:`Viewer`}),(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Read-only role intended for external reviewers (for example, clients validating content before approval).`})]}),t&&(0,U.jsx)(`p`,{className:`mt-3 text-sm text-muted-foreground`,children:`Note: Editor and Contributor can share the same base permissions, but their effective scope is different in the content layer. Contributors are restricted to their own entries for certain actions, while Editors can operate on entries more broadly depending on the configured rules.`}),(0,U.jsx)(yw,{open:d,onOpenChange:f,children:(0,U.jsxs)(Cw,{className:`sm:max-w-sm`,children:[(0,U.jsx)(ww,{children:(0,U.jsx)(Ew,{children:`Reset to defaults`})}),(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`This will restore all role permissions to their original configuration. Any custom changes will be lost.`}),(0,U.jsxs)(Tw,{children:[(0,U.jsx)(J,{variant:`outline`,onClick:()=>f(!1),children:`Cancel`}),(0,U.jsx)(J,{variant:`destructive`,onClick:h,disabled:o,children:o?`Resetting…`:`Reset`})]})]})})]})]})}var k2={"full-access":`default`,"read-only":`secondary`},A2={"full-access":`Full access`,"read-only":`Read only`};function j2({value:e}){let[t,n]=(0,v.useState)(!1);function r(){navigator.clipboard.writeText(e),n(!0),setTimeout(()=>n(!1),2e3)}return(0,U.jsx)(J,{type:`button`,size:`icon`,variant:`outline`,className:`shrink-0`,onClick:r,children:t?(0,U.jsx)(za,{className:`size-4 text-green-500`}):(0,U.jsx)(Za,{className:`size-4`})})}var M2={name:``,accessType:``};function N2(){let{user:e}=ga(),{data:t,loading:n,refetch:r}=wa(`/cms/admin/api-tokens`),{request:i,loading:a,error:o}=Vv(),s=e?.permissions??[],c=s.includes(`*`)||s.includes(`settings:api-tokens:write`),l=s.includes(`*`)||s.includes(`settings:api-tokens:delete`),[u,d]=(0,v.useState)(!1),[f,p]=(0,v.useState)(M2),[m,h]=(0,v.useState)(null),[g,_]=(0,v.useState)(null),y=[{accessorKey:`name`,header:`Name`},{accessorKey:`access_type`,header:`Access`,cell:({getValue:e})=>{let t=e();return(0,U.jsx)(vw,{variant:k2[t]??`secondary`,children:A2[t]??t})}},{accessorKey:`created_at`,header:`Created`,cell:({getValue:e})=>new Date(e()).toLocaleDateString(`en-US`,{year:`numeric`,month:`short`,day:`numeric`})},{id:`actions`,header:``,cell:({row:e})=>l?(0,U.jsx)(J,{size:`icon`,variant:`ghost`,className:`flex size-8 items-center justify-center rounded text-destructive hover:bg-destructive/10 hover:text-destructive`,onClick:()=>_(e.original),children:(0,U.jsx)(qo,{className:`size-3.5`})}):null}],b=g2({data:t??[],columns:y,getCoreRowModel:d2()});async function x(e){e.preventDefault();try{h(await i(`/cms/admin/api-tokens`,`POST`,{name:f.name,accessType:f.accessType})),r()}catch{}}function S(){d(!1),h(null),p(M2)}async function C(){try{await i(`/cms/admin/api-tokens/${g.id}`,`DELETE`),_(null),r()}catch{}}return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(yy,{children:(0,U.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`h1`,{className:`text-2xl font-bold -mt-2`,children:`API Tokens`}),(0,U.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`Manage tokens for consuming the public API.`})]}),(0,U.jsxs)(J,{onClick:()=>d(!0),disabled:!c,children:[(0,U.jsx)(Po,{className:`size-4`}),`New token`]})]})}),(0,U.jsxs)(`section`,{className:`mt-24`,children:[(0,U.jsx)(`div`,{className:`rounded-md border`,children:(0,U.jsxs)(Rw,{children:[(0,U.jsx)(zw,{className:`font-bold uppercase`,children:b.getHeaderGroups().map(e=>(0,U.jsx)(Vw,{className:`hover:bg-transparent`,children:e.headers.map(e=>(0,U.jsx)(Hw,{className:`px-4 py-3 text-left font-medium text-muted-foreground`,children:f2(e.column.columnDef.header,e.getContext())},e.id))},e.id))}),(0,U.jsx)(Bw,{children:n?(0,U.jsx)(Vw,{children:(0,U.jsx)(Uw,{colSpan:y.length,className:`h-24`,children:(0,U.jsx)(by,{className:`mx-auto size-5`})})}):b.getRowModel().rows.length===0?(0,U.jsx)(Vw,{children:(0,U.jsx)(Uw,{colSpan:y.length,className:`h-24 text-center text-muted-foreground`,children:`No tokens yet.`})}):b.getRowModel().rows.map(e=>(0,U.jsx)(Vw,{children:e.getVisibleCells().map(e=>(0,U.jsx)(Uw,{className:`px-4 py-3`,children:f2(e.column.columnDef.cell,e.getContext())},e.id))},e.id))})]})}),(0,U.jsx)(yw,{open:u,onOpenChange:e=>{e||S()},children:(0,U.jsx)(Cw,{className:`sm:max-w-md`,children:m?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(ww,{children:(0,U.jsx)(Ew,{children:`Token generated`})}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,U.jsx)(`div`,{className:`rounded-md border border-amber-200 bg-amber-50 px-4 py-3 text-sm text-amber-800 dark:border-amber-900 dark:bg-amber-950 dark:text-amber-200`,children:`Make sure to copy your token now. You won't be able to see it again.`}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsx)(X,{children:`Token`}),(0,U.jsxs)(`div`,{className:`flex gap-2`,children:[(0,U.jsx)(Hv,{readOnly:!0,value:m.token,className:`font-mono text-xs`}),(0,U.jsx)(j2,{value:m.token})]})]})]}),(0,U.jsx)(Tw,{children:(0,U.jsx)(J,{onClick:S,children:`Done`})})]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(ww,{children:(0,U.jsx)(Ew,{children:`New API token`})}),(0,U.jsxs)(`form`,{id:`create-token-form`,onSubmit:x,className:`flex flex-col gap-4`,children:[(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsx)(X,{htmlFor:`token-name`,children:`Name`}),(0,U.jsx)(Hv,{id:`token-name`,placeholder:`e.g. Production frontend`,value:f.name,onChange:e=>p(t=>({...t,name:e.target.value})),required:!0})]}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsx)(X,{htmlFor:`token-access`,children:`Access type`}),(0,U.jsxs)(Ow,{value:f.accessType,onValueChange:e=>p(t=>({...t,accessType:e})),children:[(0,U.jsx)(jw,{id:`token-access`,children:(0,U.jsx)(Aw,{placeholder:`Select access type`})}),(0,U.jsxs)(Pw,{children:[(0,U.jsx)(Iw,{value:`read-only`,children:`Read only`}),(0,U.jsx)(Iw,{value:`full-access`,children:`Full access`})]})]})]}),o&&(0,U.jsx)(`p`,{className:`text-sm text-destructive`,children:o})]}),(0,U.jsxs)(Tw,{children:[(0,U.jsx)(J,{variant:`outline`,type:`button`,onClick:S,children:`Cancel`}),(0,U.jsx)(J,{type:`submit`,form:`create-token-form`,disabled:a||!f.accessType||!c,children:a?`Generating…`:`Generate token`})]})]})})}),(0,U.jsx)(yw,{open:!!g,onOpenChange:e=>{e||_(null)},children:(0,U.jsxs)(Cw,{className:`sm:max-w-sm`,children:[(0,U.jsx)(ww,{children:(0,U.jsx)(Ew,{children:`Revoke token`})}),(0,U.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Are you sure you want to revoke`,` `,(0,U.jsx)(`span`,{className:`font-medium text-foreground`,children:g?.name}),`? Any frontend using it will immediately lose access.`]}),(0,U.jsxs)(Tw,{children:[(0,U.jsx)(J,{variant:`outline`,onClick:()=>_(null),children:`Cancel`}),(0,U.jsx)(J,{variant:`destructive`,onClick:C,disabled:a||!l,children:a?`Revoking…`:`Revoke`})]})]})})]})]})}var P2=[{value:`entry.published`,label:`Entry published`},{value:`entry.unpublished`,label:`Entry unpublished`},{value:`entry.created`,label:`Entry created`},{value:`entry.updated`,label:`Entry updated`},{value:`entry.deleted`,label:`Entry deleted`}],F2={name:``,url:``,events:[]};function I2(){let{user:e}=ga(),{data:t,loading:n,refetch:r}=wa(`/cms/admin/webhooks`),{request:i,loading:a,error:o}=Vv(),s=e?.permissions??[],c=s.includes(`*`)||s.includes(`settings:webhooks:write`),l=s.includes(`*`)||s.includes(`settings:webhooks:delete`),[u,d]=(0,v.useState)(!1),[f,p]=(0,v.useState)(F2),[m,h]=(0,v.useState)(null),g=[{accessorKey:`name`,header:`Name`},{accessorKey:`url`,header:`URL`,cell:({getValue:e})=>(0,U.jsx)(`span`,{className:`font-mono text-xs text-muted-foreground truncate max-w-xs block`,children:e()})},{accessorKey:`events`,header:`Events`,cell:({getValue:e})=>(0,U.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:e().map(e=>(0,U.jsx)(vw,{variant:`secondary`,className:`text-xs font-mono`,children:e},e))})},{accessorKey:`created_at`,header:`Created`,cell:({getValue:e})=>new Date(e()).toLocaleDateString(`en-US`,{year:`numeric`,month:`short`,day:`numeric`})},{id:`actions`,header:``,cell:({row:e})=>l?(0,U.jsx)(J,{size:`icon`,variant:`ghost`,className:`size-8 text-destructive hover:text-destructive`,onClick:()=>h(e.original),children:(0,U.jsx)(qo,{className:`size-3.5`})}):null}],_=g2({data:t??[],columns:g,getCoreRowModel:d2()});function y(e){p(t=>({...t,events:t.events.includes(e)?t.events.filter(t=>t!==e):[...t.events,e]}))}async function b(e){e.preventDefault();try{await i(`/cms/admin/webhooks`,`POST`,f),d(!1),p(F2),r()}catch{}}async function x(){try{await i(`/cms/admin/webhooks/${m.id}`,`DELETE`),h(null),r()}catch{}}return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(yy,{children:(0,U.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`h1`,{className:`text-2xl font-bold -mt-2`,children:`Webhooks`}),(0,U.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`Notify external services when content events occur.`})]}),(0,U.jsxs)(J,{onClick:()=>d(!0),disabled:!c,children:[(0,U.jsx)(Po,{className:`size-4`}),`New webhook`]})]})}),(0,U.jsxs)(`section`,{className:`mt-24`,children:[(0,U.jsx)(`div`,{className:`rounded-md border`,children:(0,U.jsxs)(Rw,{children:[(0,U.jsx)(zw,{className:`font-bold uppercase`,children:_.getHeaderGroups().map(e=>(0,U.jsx)(Vw,{className:`hover:bg-transparent`,children:e.headers.map(e=>(0,U.jsx)(Hw,{className:`px-4 py-3 text-left font-medium text-muted-foreground`,children:f2(e.column.columnDef.header,e.getContext())},e.id))},e.id))}),(0,U.jsx)(Bw,{children:n?(0,U.jsx)(Vw,{children:(0,U.jsx)(Uw,{colSpan:g.length,className:`h-24`,children:(0,U.jsx)(by,{className:`mx-auto size-5`})})}):_.getRowModel().rows.length===0?(0,U.jsx)(Vw,{children:(0,U.jsx)(Uw,{colSpan:g.length,className:`h-24 text-center text-muted-foreground`,children:`No webhooks yet.`})}):_.getRowModel().rows.map(e=>(0,U.jsx)(Vw,{children:e.getVisibleCells().map(e=>(0,U.jsx)(Uw,{className:`px-4 py-3`,children:f2(e.column.columnDef.cell,e.getContext())},e.id))},e.id))})]})}),(0,U.jsx)(yw,{open:u,onOpenChange:e=>{e||(d(!1),p(F2))},children:(0,U.jsxs)(Cw,{className:`sm:max-w-md`,children:[(0,U.jsx)(ww,{children:(0,U.jsx)(Ew,{children:`New webhook`})}),(0,U.jsxs)(`form`,{id:`create-webhook-form`,onSubmit:b,className:`flex flex-col gap-4`,children:[(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsx)(X,{htmlFor:`webhook-name`,children:`Name`}),(0,U.jsx)(Hv,{id:`webhook-name`,placeholder:`e.g. Dokploy deploy`,value:f.name,onChange:e=>p(t=>({...t,name:e.target.value})),required:!0})]}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsx)(X,{htmlFor:`webhook-url`,children:`URL`}),(0,U.jsx)(Hv,{id:`webhook-url`,type:`url`,placeholder:`https://...`,value:f.url,onChange:e=>p(t=>({...t,url:e.target.value})),required:!0})]}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,U.jsx)(X,{children:`Events`}),P2.map(({value:e,label:t})=>(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(EO,{id:`event-${e}`,checked:f.events.includes(e),onCheckedChange:()=>y(e)}),(0,U.jsxs)(`label`,{htmlFor:`event-${e}`,className:`text-sm cursor-pointer`,children:[t,(0,U.jsx)(`span`,{className:`ml-2 font-mono text-xs text-muted-foreground`,children:e})]})]},e))]}),o&&(0,U.jsx)(`p`,{className:`text-sm text-destructive`,children:o})]}),(0,U.jsxs)(Tw,{children:[(0,U.jsx)(J,{variant:`outline`,type:`button`,onClick:()=>{d(!1),p(F2)},children:`Cancel`}),(0,U.jsx)(J,{type:`submit`,form:`create-webhook-form`,disabled:a||f.events.length===0||!c,children:a?`Creating…`:`Create webhook`})]})]})}),(0,U.jsx)(yw,{open:!!m,onOpenChange:e=>{e||h(null)},children:(0,U.jsxs)(Cw,{className:`sm:max-w-sm`,children:[(0,U.jsx)(ww,{children:(0,U.jsx)(Ew,{children:`Delete webhook`})}),(0,U.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Are you sure you want to delete`,` `,(0,U.jsx)(`span`,{className:`font-medium text-foreground`,children:m?.name}),`? It will stop receiving events immediately.`]}),(0,U.jsxs)(Tw,{children:[(0,U.jsx)(J,{variant:`outline`,onClick:()=>h(null),children:`Cancel`}),(0,U.jsx)(J,{variant:`destructive`,onClick:x,disabled:a||!l,children:a?`Deleting…`:`Delete`})]})]})})]})]})}function L2({...e}){return(0,U.jsx)(Vy,{"data-slot":`collapsible`,...e})}function R2({...e}){return(0,U.jsx)(Ry,{"data-slot":`collapsible-content`,...e})}function z2(){let{user:e,updateUser:t}=ga(),{loading:n,error:r,request:i}=Vv(),{request:a}=Vv(),o=(0,v.useRef)(null),[s,c]=(0,v.useState)(!1),[l,u]=(0,v.useState)(!1),[d,f]=(0,v.useState)(null),[p,m]=(0,v.useState)(!1),[h,g]=(0,v.useState)(e?.firstName??``),[_,y]=(0,v.useState)(e?.lastName??``),[b,x]=(0,v.useState)(e?.jobTitle??``),[S,C]=(0,v.useState)(e?.organization??``),[w,T]=(0,v.useState)(e?.country??``);function E(){p&&(g(e?.firstName??``),y(e?.lastName??``),x(e?.jobTitle??``),C(e?.organization??``),T(e?.country??``)),m(!p)}async function D(e){let n=e.target.files?.[0];if(n){c(!0),f(null);try{t({avatarUrl:await ZZ(n)})}catch(e){f(e instanceof Error?e.message:`Upload failed.`)}finally{c(!1),o.current&&(o.current.value=``)}}}async function O(){u(!0),f(null);try{await a(`/cms/admin/users/me/avatar`,`DELETE`),t({avatarUrl:null})}catch(e){f(e instanceof Error?e.message:`Delete failed.`)}finally{u(!1)}}async function k(e){e.preventDefault();try{let e=await i(`/cms/admin/users/me`,`PATCH`,{firstName:h,lastName:_,jobTitle:b,organization:S,country:w});t({firstName:e.first_name,lastName:e.last_name,jobTitle:e.job_title,organization:e.organization,country:e.country}),m(!1)}catch{}}return(0,U.jsx)(L2,{open:p,onOpenChange:m,children:(0,U.jsxs)(u1,{children:[(0,U.jsxs)(d1,{children:[(0,U.jsx)(f1,{className:`uppercase`,children:`Account`}),(0,U.jsx)(p1,{children:(0,U.jsx)(J,{variant:`ghost`,size:`icon`,onClick:E,children:p?(0,U.jsx)(ns,{className:`size-4`}):(0,U.jsx)(No,{className:`size-4`})})})]}),(0,U.jsxs)(m1,{children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-4 -mt-4`,children:[(0,U.jsxs)(`div`,{className:`group relative shrink-0`,children:[(0,U.jsxs)(`button`,{type:`button`,className:`block`,onClick:()=>o.current?.click(),disabled:s||l,title:`Change avatar`,children:[(0,U.jsx)(El,{avatarUrl:e?.avatarUrl,firstName:e?.firstName,lastName:e?.lastName,email:e?.email,className:`size-20`,fallbackClassName:`text-xl`}),(0,U.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center rounded-full bg-black/40 opacity-0 transition-opacity group-hover:opacity-100`,children:s||l?(0,U.jsx)(`div`,{className:`size-4 animate-spin rounded-full border-2 border-white border-t-transparent`}):(0,U.jsx)(Ra,{className:`size-5 text-white`})})]}),e?.avatarUrl&&!s&&!l&&(0,U.jsx)(`button`,{type:`button`,onClick:O,title:`Remove avatar`,className:`absolute -top-1 -right-1 flex size-5 items-center justify-center rounded-full bg-destructive text-destructive-foreground opacity-0 transition-opacity group-hover:opacity-100`,children:(0,U.jsx)(qo,{className:`size-3`})})]}),(0,U.jsx)(`input`,{ref:o,type:`file`,accept:`image/*`,className:`hidden`,onChange:D}),(0,U.jsxs)(`div`,{children:[d&&(0,U.jsx)(`p`,{className:`text-xs text-destructive mb-1`,children:d}),(0,U.jsx)(`p`,{className:`font-bold text-xl`,children:e?.firstName||e?.lastName?`${e.firstName??``} ${e.lastName??``}`.trim():e?.email}),(e?.jobTitle||e?.organization)&&(0,U.jsx)(`p`,{className:`text-sm`,children:[e.jobTitle,e.organization].filter(Boolean).join(` · `)}),(0,U.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:e?.email}),(0,U.jsxs)(`div`,{className:`flex flex-wrap gap-2 mt-2`,children:[(0,U.jsx)(vw,{className:`capitalize`,children:e?.role}),e?.country&&(0,U.jsx)(vw,{variant:`outline`,children:e.country})]})]})]}),(0,U.jsx)(R2,{children:(0,U.jsxs)(`form`,{onSubmit:k,className:`space-y-4 mt-8`,children:[(0,U.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,U.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,U.jsx)(X,{htmlFor:`firstName`,children:`First name`}),(0,U.jsx)(Hv,{id:`firstName`,value:h,onChange:e=>g(e.target.value)})]}),(0,U.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,U.jsx)(X,{htmlFor:`lastName`,children:`Last name`}),(0,U.jsx)(Hv,{id:`lastName`,value:_,onChange:e=>y(e.target.value)})]}),(0,U.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,U.jsx)(X,{htmlFor:`jobTitle`,children:`Job title`}),(0,U.jsx)(Hv,{id:`jobTitle`,value:b,onChange:e=>x(e.target.value)})]}),(0,U.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,U.jsx)(X,{htmlFor:`organization`,children:`Organization`}),(0,U.jsx)(Hv,{id:`organization`,value:S,onChange:e=>C(e.target.value)})]}),(0,U.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,U.jsx)(X,{htmlFor:`country`,children:`Country`}),(0,U.jsx)(Hv,{id:`country`,value:w,onChange:e=>T(e.target.value)})]})]}),r&&(0,U.jsx)(`p`,{className:`text-destructive text-sm`,children:r}),(0,U.jsx)(J,{type:`submit`,disabled:n,children:n?`Saving…`:`Save changes`})]})})]})]})})}var B2=Object.defineProperty,V2=Object.getOwnPropertySymbols,H2=Object.prototype.hasOwnProperty,U2=Object.prototype.propertyIsEnumerable,W2=(e,t,n)=>t in e?B2(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,G2=(e,t)=>{for(var n in t||={})H2.call(t,n)&&W2(e,n,t[n]);if(V2)for(var n of V2(t))U2.call(t,n)&&W2(e,n,t[n]);return e},K2=(e,t)=>{var n={};for(var r in e)H2.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&V2)for(var r of V2(e))t.indexOf(r)<0&&U2.call(e,r)&&(n[r]=e[r]);return n},q2;(e=>{let t=class t{constructor(e,n,r,a){if(this.version=e,this.errorCorrectionLevel=n,this.modules=[],this.isFunction=[],e<t.MIN_VERSION||e>t.MAX_VERSION)throw RangeError(`Version value out of range`);if(a<-1||a>7)throw RangeError(`Mask value out of range`);this.size=e*4+17;let o=[];for(let e=0;e<this.size;e++)o.push(!1);for(let e=0;e<this.size;e++)this.modules.push(o.slice()),this.isFunction.push(o.slice());this.drawFunctionPatterns();let s=this.addEccAndInterleave(r);if(this.drawCodewords(s),a==-1){let e=1e9;for(let t=0;t<8;t++){this.applyMask(t),this.drawFormatBits(t);let n=this.getPenaltyScore();n<e&&(a=t,e=n),this.applyMask(t)}}i(0<=a&&a<=7),this.mask=a,this.applyMask(a),this.drawFormatBits(a),this.isFunction=[]}static encodeText(n,r){let i=e.QrSegment.makeSegments(n);return t.encodeSegments(i,r)}static encodeBinary(n,r){let i=e.QrSegment.makeBytes(n);return t.encodeSegments([i],r)}static encodeSegments(e,r,a=1,s=40,c=-1,l=!0){if(!(t.MIN_VERSION<=a&&a<=s&&s<=t.MAX_VERSION)||c<-1||c>7)throw RangeError(`Invalid value`);let u,d;for(u=a;;u++){let n=t.getNumDataCodewords(u,r)*8,i=o.getTotalBits(e,u);if(i<=n){d=i;break}if(u>=s)throw RangeError(`Data too long`)}for(let e of[t.Ecc.MEDIUM,t.Ecc.QUARTILE,t.Ecc.HIGH])l&&d<=t.getNumDataCodewords(u,e)*8&&(r=e);let f=[];for(let t of e){n(t.mode.modeBits,4,f),n(t.numChars,t.mode.numCharCountBits(u),f);for(let e of t.getData())f.push(e)}i(f.length==d);let p=t.getNumDataCodewords(u,r)*8;i(f.length<=p),n(0,Math.min(4,p-f.length),f),n(0,(8-f.length%8)%8,f),i(f.length%8==0);for(let e=236;f.length<p;e^=253)n(e,8,f);let m=[];for(;m.length*8<f.length;)m.push(0);return f.forEach((e,t)=>m[t>>>3]|=e<<7-(t&7)),new t(u,r,m,c)}getModule(e,t){return 0<=e&&e<this.size&&0<=t&&t<this.size&&this.modules[t][e]}getModules(){return this.modules}drawFunctionPatterns(){for(let e=0;e<this.size;e++)this.setFunctionModule(6,e,e%2==0),this.setFunctionModule(e,6,e%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);let e=this.getAlignmentPatternPositions(),t=e.length;for(let n=0;n<t;n++)for(let r=0;r<t;r++)n==0&&r==0||n==0&&r==t-1||n==t-1&&r==0||this.drawAlignmentPattern(e[n],e[r]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(e){let t=this.errorCorrectionLevel.formatBits<<3|e,n=t;for(let e=0;e<10;e++)n=n<<1^(n>>>9)*1335;let a=(t<<10|n)^21522;i(a>>>15==0);for(let e=0;e<=5;e++)this.setFunctionModule(8,e,r(a,e));this.setFunctionModule(8,7,r(a,6)),this.setFunctionModule(8,8,r(a,7)),this.setFunctionModule(7,8,r(a,8));for(let e=9;e<15;e++)this.setFunctionModule(14-e,8,r(a,e));for(let e=0;e<8;e++)this.setFunctionModule(this.size-1-e,8,r(a,e));for(let e=8;e<15;e++)this.setFunctionModule(8,this.size-15+e,r(a,e));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let e=this.version;for(let t=0;t<12;t++)e=e<<1^(e>>>11)*7973;let t=this.version<<12|e;i(t>>>18==0);for(let e=0;e<18;e++){let n=r(t,e),i=this.size-11+e%3,a=Math.floor(e/3);this.setFunctionModule(i,a,n),this.setFunctionModule(a,i,n)}}drawFinderPattern(e,t){for(let n=-4;n<=4;n++)for(let r=-4;r<=4;r++){let i=Math.max(Math.abs(r),Math.abs(n)),a=e+r,o=t+n;0<=a&&a<this.size&&0<=o&&o<this.size&&this.setFunctionModule(a,o,i!=2&&i!=4)}}drawAlignmentPattern(e,t){for(let n=-2;n<=2;n++)for(let r=-2;r<=2;r++)this.setFunctionModule(e+r,t+n,Math.max(Math.abs(r),Math.abs(n))!=1)}setFunctionModule(e,t,n){this.modules[t][e]=n,this.isFunction[t][e]=!0}addEccAndInterleave(e){let n=this.version,r=this.errorCorrectionLevel;if(e.length!=t.getNumDataCodewords(n,r))throw RangeError(`Invalid argument`);let a=t.NUM_ERROR_CORRECTION_BLOCKS[r.ordinal][n],o=t.ECC_CODEWORDS_PER_BLOCK[r.ordinal][n],s=Math.floor(t.getNumRawDataModules(n)/8),c=a-s%a,l=Math.floor(s/a),u=[],d=t.reedSolomonComputeDivisor(o);for(let n=0,r=0;n<a;n++){let i=e.slice(r,r+l-o+(n<c?0:1));r+=i.length;let a=t.reedSolomonComputeRemainder(i,d);n<c&&i.push(0),u.push(i.concat(a))}let f=[];for(let e=0;e<u[0].length;e++)u.forEach((t,n)=>{(e!=l-o||n>=c)&&f.push(t[e])});return i(f.length==s),f}drawCodewords(e){if(e.length!=Math.floor(t.getNumRawDataModules(this.version)/8))throw RangeError(`Invalid argument`);let n=0;for(let t=this.size-1;t>=1;t-=2){t==6&&(t=5);for(let i=0;i<this.size;i++)for(let a=0;a<2;a++){let o=t-a,s=t+1&2?i:this.size-1-i;!this.isFunction[s][o]&&n<e.length*8&&(this.modules[s][o]=r(e[n>>>3],7-(n&7)),n++)}}i(n==e.length*8)}applyMask(e){if(e<0||e>7)throw RangeError(`Mask value out of range`);for(let t=0;t<this.size;t++)for(let n=0;n<this.size;n++){let r;switch(e){case 0:r=(n+t)%2==0;break;case 1:r=t%2==0;break;case 2:r=n%3==0;break;case 3:r=(n+t)%3==0;break;case 4:r=(Math.floor(n/3)+Math.floor(t/2))%2==0;break;case 5:r=n*t%2+n*t%3==0;break;case 6:r=(n*t%2+n*t%3)%2==0;break;case 7:r=((n+t)%2+n*t%3)%2==0;break;default:throw Error(`Unreachable`)}!this.isFunction[t][n]&&r&&(this.modules[t][n]=!this.modules[t][n])}}getPenaltyScore(){let e=0;for(let n=0;n<this.size;n++){let r=!1,i=0,a=[0,0,0,0,0,0,0];for(let o=0;o<this.size;o++)this.modules[n][o]==r?(i++,i==5?e+=t.PENALTY_N1:i>5&&e++):(this.finderPenaltyAddHistory(i,a),r||(e+=this.finderPenaltyCountPatterns(a)*t.PENALTY_N3),r=this.modules[n][o],i=1);e+=this.finderPenaltyTerminateAndCount(r,i,a)*t.PENALTY_N3}for(let n=0;n<this.size;n++){let r=!1,i=0,a=[0,0,0,0,0,0,0];for(let o=0;o<this.size;o++)this.modules[o][n]==r?(i++,i==5?e+=t.PENALTY_N1:i>5&&e++):(this.finderPenaltyAddHistory(i,a),r||(e+=this.finderPenaltyCountPatterns(a)*t.PENALTY_N3),r=this.modules[o][n],i=1);e+=this.finderPenaltyTerminateAndCount(r,i,a)*t.PENALTY_N3}for(let n=0;n<this.size-1;n++)for(let r=0;r<this.size-1;r++){let i=this.modules[n][r];i==this.modules[n][r+1]&&i==this.modules[n+1][r]&&i==this.modules[n+1][r+1]&&(e+=t.PENALTY_N2)}let n=0;for(let e of this.modules)n=e.reduce((e,t)=>e+ +!!t,n);let r=this.size*this.size,a=Math.ceil(Math.abs(n*20-r*10)/r)-1;return i(0<=a&&a<=9),e+=a*t.PENALTY_N4,i(0<=e&&e<=2568888),e}getAlignmentPatternPositions(){if(this.version==1)return[];{let e=Math.floor(this.version/7)+2,t=this.version==32?26:Math.ceil((this.version*4+4)/(e*2-2))*2,n=[6];for(let r=this.size-7;n.length<e;r-=t)n.splice(1,0,r);return n}}static getNumRawDataModules(e){if(e<t.MIN_VERSION||e>t.MAX_VERSION)throw RangeError(`Version number out of range`);let n=(16*e+128)*e+64;if(e>=2){let t=Math.floor(e/7)+2;n-=(25*t-10)*t-55,e>=7&&(n-=36)}return i(208<=n&&n<=29648),n}static getNumDataCodewords(e,n){return Math.floor(t.getNumRawDataModules(e)/8)-t.ECC_CODEWORDS_PER_BLOCK[n.ordinal][e]*t.NUM_ERROR_CORRECTION_BLOCKS[n.ordinal][e]}static reedSolomonComputeDivisor(e){if(e<1||e>255)throw RangeError(`Degree out of range`);let n=[];for(let t=0;t<e-1;t++)n.push(0);n.push(1);let r=1;for(let i=0;i<e;i++){for(let e=0;e<n.length;e++)n[e]=t.reedSolomonMultiply(n[e],r),e+1<n.length&&(n[e]^=n[e+1]);r=t.reedSolomonMultiply(r,2)}return n}static reedSolomonComputeRemainder(e,n){let r=n.map(e=>0);for(let i of e){let e=i^r.shift();r.push(0),n.forEach((n,i)=>r[i]^=t.reedSolomonMultiply(n,e))}return r}static reedSolomonMultiply(e,t){if(e>>>8||t>>>8)throw RangeError(`Byte out of range`);let n=0;for(let r=7;r>=0;r--)n=n<<1^(n>>>7)*285,n^=(t>>>r&1)*e;return i(n>>>8==0),n}finderPenaltyCountPatterns(e){let t=e[1];i(t<=this.size*3);let n=t>0&&e[2]==t&&e[3]==t*3&&e[4]==t&&e[5]==t;return(n&&e[0]>=t*4&&e[6]>=t?1:0)+(n&&e[6]>=t*4&&e[0]>=t?1:0)}finderPenaltyTerminateAndCount(e,t,n){return e&&(this.finderPenaltyAddHistory(t,n),t=0),t+=this.size,this.finderPenaltyAddHistory(t,n),this.finderPenaltyCountPatterns(n)}finderPenaltyAddHistory(e,t){t[0]==0&&(e+=this.size),t.pop(),t.unshift(e)}};t.MIN_VERSION=1,t.MAX_VERSION=40,t.PENALTY_N1=3,t.PENALTY_N2=3,t.PENALTY_N3=40,t.PENALTY_N4=10,t.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],t.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],e.QrCode=t;function n(e,t,n){if(t<0||t>31||e>>>t)throw RangeError(`Value out of range`);for(let r=t-1;r>=0;r--)n.push(e>>>r&1)}function r(e,t){return(e>>>t&1)!=0}function i(e){if(!e)throw Error(`Assertion error`)}let a=class e{constructor(e,t,n){if(this.mode=e,this.numChars=t,this.bitData=n,t<0)throw RangeError(`Invalid argument`);this.bitData=n.slice()}static makeBytes(t){let r=[];for(let e of t)n(e,8,r);return new e(e.Mode.BYTE,t.length,r)}static makeNumeric(t){if(!e.isNumeric(t))throw RangeError(`String contains non-numeric characters`);let r=[];for(let e=0;e<t.length;){let i=Math.min(t.length-e,3);n(parseInt(t.substring(e,e+i),10),i*3+1,r),e+=i}return new e(e.Mode.NUMERIC,t.length,r)}static makeAlphanumeric(t){if(!e.isAlphanumeric(t))throw RangeError(`String contains unencodable characters in alphanumeric mode`);let r=[],i;for(i=0;i+2<=t.length;i+=2){let a=e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(i))*45;a+=e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(i+1)),n(a,11,r)}return i<t.length&&n(e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(i)),6,r),new e(e.Mode.ALPHANUMERIC,t.length,r)}static makeSegments(t){return t==``?[]:e.isNumeric(t)?[e.makeNumeric(t)]:e.isAlphanumeric(t)?[e.makeAlphanumeric(t)]:[e.makeBytes(e.toUtf8ByteArray(t))]}static makeEci(t){let r=[];if(t<0)throw RangeError(`ECI assignment value out of range`);if(t<128)n(t,8,r);else if(t<16384)n(2,2,r),n(t,14,r);else if(t<1e6)n(6,3,r),n(t,21,r);else throw RangeError(`ECI assignment value out of range`);return new e(e.Mode.ECI,0,r)}static isNumeric(t){return e.NUMERIC_REGEX.test(t)}static isAlphanumeric(t){return e.ALPHANUMERIC_REGEX.test(t)}getData(){return this.bitData.slice()}static getTotalBits(e,t){let n=0;for(let r of e){let e=r.mode.numCharCountBits(t);if(r.numChars>=1<<e)return 1/0;n+=4+e+r.bitData.length}return n}static toUtf8ByteArray(e){e=encodeURI(e);let t=[];for(let n=0;n<e.length;n++)e.charAt(n)==`%`?(t.push(parseInt(e.substring(n+1,n+3),16)),n+=2):t.push(e.charCodeAt(n));return t}};a.NUMERIC_REGEX=/^[0-9]*$/,a.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,a.ALPHANUMERIC_CHARSET=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:`;let o=a;e.QrSegment=a})(q2||={}),(e=>{(e=>{let t=class{constructor(e,t){this.ordinal=e,this.formatBits=t}};t.LOW=new t(0,1),t.MEDIUM=new t(1,0),t.QUARTILE=new t(2,3),t.HIGH=new t(3,2),e.Ecc=t})(e.QrCode||={})})(q2||={}),(e=>{(e=>{let t=class{constructor(e,t){this.modeBits=e,this.numBitsCharCount=t}numCharCountBits(e){return this.numBitsCharCount[Math.floor((e+7)/17)]}};t.NUMERIC=new t(1,[10,12,14]),t.ALPHANUMERIC=new t(2,[9,11,13]),t.BYTE=new t(4,[8,16,16]),t.KANJI=new t(8,[8,10,12]),t.ECI=new t(7,[0,0,0]),e.Mode=t})(e.QrSegment||={})})(q2||={});var J2=q2,Y2={L:J2.QrCode.Ecc.LOW,M:J2.QrCode.Ecc.MEDIUM,Q:J2.QrCode.Ecc.QUARTILE,H:J2.QrCode.Ecc.HIGH},X2=128,Z2=`L`,Q2=`#FFFFFF`,$2=`#000000`,e4=!1,t4=1,n4=4,r4=0,i4=.1;function a4(e,t=0){let n=[];return e.forEach(function(e,r){let i=null;e.forEach(function(a,o){if(!a&&i!==null){n.push(`M${i+t} ${r+t}h${o-i}v1H${i+t}z`),i=null;return}if(o===e.length-1){if(!a)return;i===null?n.push(`M${o+t},${r+t} h1v1H${o+t}z`):n.push(`M${i+t},${r+t} h${o+1-i}v1H${i+t}z`);return}a&&i===null&&(i=o)})}),n.join(``)}function o4(e,t){return e.slice().map((e,n)=>n<t.y||n>=t.y+t.h?e:e.map((e,n)=>n<t.x||n>=t.x+t.w?e:!1))}function s4(e,t,n,r){if(r==null)return null;let i=e.length+n*2,a=Math.floor(t*i4),o=i/t,s=(r.width||a)*o,c=(r.height||a)*o,l=r.x==null?e.length/2-s/2:r.x*o,u=r.y==null?e.length/2-c/2:r.y*o,d=r.opacity==null?1:r.opacity,f=null;if(r.excavate){let e=Math.floor(l),t=Math.floor(u);f={x:e,y:t,w:Math.ceil(s+l-e),h:Math.ceil(c+u-t)}}let p=r.crossOrigin;return{x:l,y:u,h:c,w:s,excavation:f,opacity:d,crossOrigin:p}}function c4(e,t){return t==null?e?n4:r4:Math.max(Math.floor(t),0)}function l4({value:e,level:t,minVersion:n,includeMargin:r,marginSize:i,imageSettings:a,size:o,boostLevel:s}){let c=v.useMemo(()=>{let r=(Array.isArray(e)?e:[e]).reduce((e,t)=>(e.push(...J2.QrSegment.makeSegments(t)),e),[]);return J2.QrCode.encodeSegments(r,Y2[t],n,void 0,void 0,s)},[e,t,n,s]),{cells:l,margin:u,numCells:d,calculatedImageSettings:f}=v.useMemo(()=>{let e=c.getModules(),t=c4(r,i);return{cells:e,margin:t,numCells:e.length+t*2,calculatedImageSettings:s4(e,o,t,a)}},[c,o,a,r,i]);return{qrcode:c,margin:u,cells:l,numCells:d,calculatedImageSettings:f}}var u4=function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0}(),d4=v.forwardRef(function(e,t){let n=e,{value:r,size:i=X2,level:a=Z2,bgColor:o=Q2,fgColor:s=$2,includeMargin:c=e4,minVersion:l=t4,boostLevel:u,marginSize:d,imageSettings:f}=n,p=K2(n,[`value`,`size`,`level`,`bgColor`,`fgColor`,`includeMargin`,`minVersion`,`boostLevel`,`marginSize`,`imageSettings`]),{style:m}=p,h=K2(p,[`style`]),g=f?.src,_=v.useRef(null),y=v.useRef(null),b=v.useCallback(e=>{_.current=e,typeof t==`function`?t(e):t&&(t.current=e)},[t]),[x,S]=v.useState(!1),{margin:C,cells:w,numCells:T,calculatedImageSettings:E}=l4({value:r,level:a,minVersion:l,boostLevel:u,includeMargin:c,marginSize:d,imageSettings:f,size:i});v.useEffect(()=>{if(_.current!=null){let e=_.current,t=e.getContext(`2d`);if(!t)return;let n=w,r=y.current,a=E!=null&&r!==null&&r.complete&&r.naturalHeight!==0&&r.naturalWidth!==0;a&&E.excavation!=null&&(n=o4(w,E.excavation));let c=window.devicePixelRatio||1;e.height=e.width=i*c;let l=i/T*c;t.scale(l,l),t.fillStyle=o,t.fillRect(0,0,T,T),t.fillStyle=s,u4?t.fill(new Path2D(a4(n,C))):w.forEach(function(e,n){e.forEach(function(e,r){e&&t.fillRect(r+C,n+C,1,1)})}),E&&(t.globalAlpha=E.opacity),a&&t.drawImage(r,E.x+C,E.y+C,E.w,E.h)}}),v.useEffect(()=>{S(!1)},[g]);let D=G2({height:i,width:i},m),O=null;return g!=null&&(O=v.createElement(`img`,{src:g,key:g,style:{display:`none`},onLoad:()=>{S(!0)},ref:y,crossOrigin:E?.crossOrigin})),v.createElement(v.Fragment,null,v.createElement(`canvas`,G2({style:D,height:i,width:i,ref:b,role:`img`},h)),O)});d4.displayName=`QRCodeCanvas`;var f4=v.forwardRef(function(e,t){let n=e,{value:r,size:i=X2,level:a=Z2,bgColor:o=Q2,fgColor:s=$2,includeMargin:c=e4,minVersion:l=t4,boostLevel:u,title:d,marginSize:f,imageSettings:p}=n,m=K2(n,[`value`,`size`,`level`,`bgColor`,`fgColor`,`includeMargin`,`minVersion`,`boostLevel`,`title`,`marginSize`,`imageSettings`]),{margin:h,cells:g,numCells:_,calculatedImageSettings:y}=l4({value:r,level:a,minVersion:l,boostLevel:u,includeMargin:c,marginSize:f,imageSettings:p,size:i}),b=g,x=null;p!=null&&y!=null&&(y.excavation!=null&&(b=o4(g,y.excavation)),x=v.createElement(`image`,{href:p.src,height:y.h,width:y.w,x:y.x+h,y:y.y+h,preserveAspectRatio:`none`,opacity:y.opacity,crossOrigin:y.crossOrigin}));let S=a4(b,h);return v.createElement(`svg`,G2({height:i,width:i,viewBox:`0 0 ${_} ${_}`,ref:t,role:`img`},m),!!d&&v.createElement(`title`,null,d),v.createElement(`path`,{fill:o,d:`M0,0 h${_}v${_}H0z`,shapeRendering:`crispEdges`}),v.createElement(`path`,{fill:s,d:S,shapeRendering:`crispEdges`}),x)});f4.displayName=`QRCodeSVG`;function p4(){let{user:e,updateUser:t,logout:n}=ga(),{loading:r,error:i,request:a}=Vv(),{loading:o,error:s,request:c}=Vv(),[l,u]=(0,v.useState)(``),[d,f]=(0,v.useState)(``),[p,m]=(0,v.useState)(``),[h,g]=(0,v.useState)(``),[_,y]=(0,v.useState)(null),[b,x]=(0,v.useState)(!1),[S,C]=(0,v.useState)(null),[w,T]=(0,v.useState)(``),[E,D]=(0,v.useState)(``),[O,k]=(0,v.useState)(!1),[A,j]=(0,v.useState)([]),[M,N]=(0,v.useState)(!1);(0,v.useEffect)(()=>{typeof e?.twoFactorEnabled==`boolean`&&x(e.twoFactorEnabled)},[e?.twoFactorEnabled]);function P(){u(``),f(``),m(``),g(``),y(null),C(null),T(``)}function F(){C(null),T(``),D(``),k(!1),N(!1)}async function I(e){if(e.preventDefault(),y(null),p!==h){y(`New passwords do not match`);return}try{await a(`/cms/admin/users/me/password`,`PATCH`,{currentPassword:d,newPassword:p}),P()}catch{}}async function L(){C(await c(`/cms/admin/users/me/2fa/setup`,`POST`))}async function R(){let e=await c(`/cms/admin/users/me/2fa/verify`,`POST`,{code:w});x(!0),t({twoFactorEnabled:!0}),C(null),T(``),k(!0),j(e.backupCodes??[])}async function ee(){await c(`/cms/admin/users/me/2fa/disable`,`POST`,{code:w,password:E}),x(!1),t({twoFactorEnabled:!1}),T(``),D(``),j([]),N(!1)}return(0,U.jsxs)(u1,{children:[(0,U.jsxs)(d1,{children:[(0,U.jsx)(f1,{className:`uppercase`,children:`Security`}),(0,U.jsx)(p1,{})]}),(0,U.jsx)(m1,{className:`space-y-6`,children:(0,U.jsxs)(QA,{value:l,children:[(0,U.jsxs)($A,{children:[(0,U.jsx)(ej,{value:`password`,onClick:()=>u(e=>e===`password`?``:`password`),children:`Password`}),(0,U.jsx)(ej,{value:`two-factor`,onClick:()=>u(e=>e===`two-factor`?``:`two-factor`),children:`2FA`})]}),(0,U.jsx)(tj,{value:`password`,className:`mt-4`,children:(0,U.jsxs)(`div`,{className:`space-y-4 rounded-md border border-border p-4`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Update your account password.`}),(0,U.jsx)(J,{variant:`ghost`,size:`icon`,onClick:P,children:(0,U.jsx)(ns,{className:`size-4`})})]}),(0,U.jsxs)(`form`,{onSubmit:I,className:`space-y-4`,children:[(0,U.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,U.jsx)(X,{htmlFor:`current`,children:`Current password`}),(0,U.jsx)(Hv,{id:`current`,type:`password`,value:d,onChange:e=>f(e.target.value),required:!0})]}),(0,U.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,U.jsx)(X,{htmlFor:`new`,children:`New password`}),(0,U.jsx)(Hv,{id:`new`,type:`password`,value:p,onChange:e=>m(e.target.value),required:!0,minLength:8})]}),(0,U.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,U.jsx)(X,{htmlFor:`confirm`,children:`Confirm new password`}),(0,U.jsx)(Hv,{id:`confirm`,type:`password`,value:h,onChange:e=>g(e.target.value),required:!0})]}),(_??i)&&(0,U.jsx)(`p`,{className:`text-destructive text-sm`,children:_??i}),(0,U.jsx)(J,{type:`submit`,disabled:r,children:r?`Saving…`:`Update password`})]})]})}),(0,U.jsx)(tj,{value:`two-factor`,className:`mt-4`,children:(0,U.jsxs)(`div`,{className:`space-y-4`,children:[!b&&!S&&(0,U.jsx)(J,{variant:`secondary`,onClick:L,disabled:o,children:`Enable 2FA`}),S&&!b&&(0,U.jsxs)(`div`,{className:`space-y-3 rounded-md border border-border p-4`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Scan this QR code with your authenticator app and enter the 6-digit code.`}),(0,U.jsx)(J,{variant:`ghost`,size:`icon`,onClick:F,children:(0,U.jsx)(ns,{className:`size-4`})})]}),(0,U.jsx)(`div`,{className:`inline-flex rounded-md bg-white p-2`,children:(0,U.jsx)(f4,{value:S.otpauthUri,size:176})}),(0,U.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Manual code: `,S.secret]}),(0,U.jsx)(my,{maxLength:6,value:w,onChange:T,containerClassName:`w-fit`,className:`w-fit`,children:(0,U.jsxs)(hy,{className:`w-fit`,children:[(0,U.jsx)(gy,{index:0}),(0,U.jsx)(gy,{index:1}),(0,U.jsx)(gy,{index:2}),(0,U.jsx)(gy,{index:3}),(0,U.jsx)(gy,{index:4}),(0,U.jsx)(gy,{index:5})]})}),(0,U.jsx)(J,{onClick:R,disabled:o||w.length!==6,children:`Confirm and enable 2FA`}),s&&(0,U.jsx)(`p`,{className:`text-sm text-destructive`,children:s})]}),b&&(0,U.jsxs)(`div`,{className:`space-y-3 rounded-md border border-border p-4`,children:[O&&(0,U.jsxs)(`div`,{className:`space-y-3 rounded-md border border-emerald-500/40 bg-emerald-500/10 p-3`,children:[(0,U.jsx)(`p`,{className:`text-sm font-medium text-emerald-300`,children:`2FA is now enabled.`}),(0,U.jsx)(`p`,{className:`text-xs text-emerald-200/90`,children:`For security, re-login is recommended now. This prevents accidental changes and confirms your new security state.`}),(0,U.jsx)(J,{variant:`default`,onClick:()=>{n()},children:`Re-login now`}),A.length>0&&(0,U.jsxs)(`div`,{className:`space-y-2 rounded-md border border-emerald-400/30 bg-background/40 p-3`,children:[(0,U.jsx)(`p`,{className:`text-xs font-medium text-emerald-200`,children:`Save these backup codes now. Each code can be used once if you lose access to your authenticator.`}),(0,U.jsx)(`div`,{className:`grid grid-cols-2 gap-2`,children:A.map(e=>(0,U.jsx)(`code`,{className:`rounded bg-black/20 px-2 py-1 text-xs text-emerald-100`,children:e},e))}),(0,U.jsx)(J,{variant:`outline`,onClick:async()=>{try{await navigator.clipboard.writeText(A.join(`
223
- `)),N(!0),setTimeout(()=>N(!1),2e3)}catch{N(!1)}},children:M?`Copied`:`Copy backup codes`})]})]}),(0,U.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Enter a verification code from your authenticator app to disable 2FA.`}),(0,U.jsx)(J,{variant:`ghost`,size:`icon`,onClick:()=>{T(``),D(``)},children:(0,U.jsx)(ns,{className:`size-4`})})]}),(0,U.jsx)(my,{maxLength:6,value:w,onChange:T,containerClassName:`w-fit`,className:`w-fit`,children:(0,U.jsxs)(hy,{className:`w-fit`,children:[(0,U.jsx)(gy,{index:0}),(0,U.jsx)(gy,{index:1}),(0,U.jsx)(gy,{index:2}),(0,U.jsx)(gy,{index:3}),(0,U.jsx)(gy,{index:4}),(0,U.jsx)(gy,{index:5})]})}),(0,U.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,U.jsx)(X,{htmlFor:`disable-2fa-password`,children:`Current password`}),(0,U.jsx)(Hv,{id:`disable-2fa-password`,type:`password`,value:E,onChange:e=>D(e.target.value),required:!0})]}),(0,U.jsx)(J,{variant:`destructive`,onClick:ee,disabled:O||o||w.length!==6||!E,children:`Disable 2FA`}),s&&(0,U.jsx)(`p`,{className:`text-sm text-destructive`,children:s})]})]})})]})})]})}function m4(){return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(yy,{children:(0,U.jsx)(`h1`,{className:`text-2xl font-bold -mt-2`,children:`Profile`})}),(0,U.jsx)(`section`,{className:`mt-18`,children:(0,U.jsx)(`div`,{className:`grid grid-cols-2 gap-4 items-start`,children:(0,U.jsxs)(`div`,{className:`space-y-4`,children:[(0,U.jsx)(z2,{}),(0,U.jsx)(p4,{})]})})})]})}var h4=[`Super Admin`,`Admin`,`Editor`,`Contributor`],g4=Vi([{path:`/login`,element:(0,U.jsx)(vy,{})},{element:(0,U.jsx)(Ca,{children:(0,U.jsx)(Bv,{})}),children:[{index:!0,element:(0,U.jsx)(Ca,{roles:h4,redirectTo:`/content`,children:(0,U.jsx)(Kw,{})})},{path:`content`,element:(0,U.jsx)(HO,{}),children:[{index:!0,element:(0,U.jsx)(UO,{})},{path:`:slug`,element:(0,U.jsx)(vk,{})},{path:`:slug/new`,element:(0,U.jsx)(Ca,{permission:`entries:write`,redirectTo:`/content`,children:(0,U.jsx)(F$,{})})},{path:`:slug/:id`,element:(0,U.jsx)(F$,{})}]},{path:`media`,element:(0,U.jsx)(Ca,{roles:h4,redirectTo:`/content`,children:(0,U.jsx)($$,{})})},{path:`content-types`,element:(0,U.jsx)(Ca,{permission:`content-types:write`,roles:h4,redirectTo:`/content`,children:(0,U.jsx)(Yw,{})}),children:[{index:!0,element:(0,U.jsx)(rT,{})},{path:`new`,element:(0,U.jsx)(BO,{})},{path:`:slug`,element:(0,U.jsx)(BO,{})}]},{path:`settings`,element:(0,U.jsx)(Ca,{permission:`settings:overview:read`,roles:h4,redirectTo:`/content`,children:(0,U.jsx)(r1,{})}),children:[{index:!0,element:(0,U.jsx)(Zr,{to:`overview`,replace:!0})},{path:`overview`,element:(0,U.jsx)(Ca,{permission:`settings:overview:read`,children:(0,U.jsx)(J1,{})})},{path:`users`,element:(0,U.jsx)(Ca,{permission:`settings:users:read`,children:(0,U.jsx)(x2,{})})},{path:`roles`,element:(0,U.jsx)(Ca,{permission:`settings:roles:read`,children:(0,U.jsx)(O2,{})})},{path:`api-tokens`,element:(0,U.jsx)(Ca,{permission:`settings:api-tokens:read`,children:(0,U.jsx)(N2,{})})},{path:`webhooks`,element:(0,U.jsx)(Ca,{permission:`settings:webhooks:read`,children:(0,U.jsx)(I2,{})})}]},{path:`profile`,element:(0,U.jsx)(m4,{})}]},{path:`*`,element:(0,U.jsx)(Zr,{to:`/`,replace:!0})}],{basename:`/admin/`.replace(/\/$/,``)||`/`});function _4(){return(0,U.jsx)(ha,{children:(0,U.jsx)(va,{children:(0,U.jsx)(xa,{children:(0,U.jsx)(da,{router:g4})})})})}(0,_.createRoot)(document.getElementById(`root`)).render((0,U.jsx)(v.StrictMode,{children:(0,U.jsxs)(E,{attribute:`class`,defaultTheme:`dark`,enableSystem:!0,disableTransitionOnChange:!0,children:[(0,U.jsx)(_4,{}),(0,U.jsx)(({...e})=>{let{theme:t=`system`}=T();return(0,U.jsx)(W1,{theme:t,className:`toaster group`,icons:{success:(0,U.jsx)(Ga,{className:`size-4`}),info:(0,U.jsx)(vo,{className:`size-4`}),warning:(0,U.jsx)(Jo,{className:`size-4`}),error:(0,U.jsx)(Mo,{className:`size-4`}),loading:(0,U.jsx)(ko,{className:`size-4 animate-spin`})},style:{"--normal-bg":`var(--popover)`,"--normal-text":`var(--popover-foreground)`,"--normal-border":`var(--border)`,"--border-radius":`var(--radius)`},...e})},{})]})}));
222
+ color: hsl(${Math.max(0,Math.min(120-120*r,120))}deg 100% 31%);`,n?.key)}return i}}function n0(e,t,n,r){return{debug:()=>e?.debugAll??e[t],key:!1,onChange:r}}function r0(e,t,n,r){let i={id:`${t.id}_${n.id}`,row:t,column:n,getValue:()=>t.getValue(r),renderValue:()=>i.getValue()??e.options.renderFallbackValue,getContext:t0(()=>[e,n,t,i],(e,t,n,r)=>({table:e,column:t,row:n,cell:r,getValue:r.getValue,renderValue:r.renderValue}),n0(e.options,`debugCells`,`cell.getContext`))};return e._features.forEach(r=>{r.createCell==null||r.createCell(i,n,t,e)},{}),i}function i0(e,t,n,r){let i={...e._getDefaultColumnDef(),...t},a=i.accessorKey,o=i.id??(a?typeof String.prototype.replaceAll==`function`?a.replaceAll(`.`,`_`):a.replace(/\./g,`_`):void 0)??(typeof i.header==`string`?i.header:void 0),s;if(i.accessorFn?s=i.accessorFn:a&&(s=a.includes(`.`)?e=>{let t=e;for(let e of a.split(`.`))t=t?.[e];return t}:e=>e[i.accessorKey]),!o)throw Error();let c={id:`${String(o)}`,accessorFn:s,parent:r,depth:n,columnDef:i,columns:[],getFlatColumns:t0(()=>[!0],()=>[c,...c.columns?.flatMap(e=>e.getFlatColumns())],n0(e.options,`debugColumns`,`column.getFlatColumns`)),getLeafColumns:t0(()=>[e._getOrderColumnsFn()],e=>{var t;return(t=c.columns)!=null&&t.length?e(c.columns.flatMap(e=>e.getLeafColumns())):[c]},n0(e.options,`debugColumns`,`column.getLeafColumns`))};for(let t of e._features)t.createColumn==null||t.createColumn(c,e);return c}var a0=`debugHeaders`;function o0(e,t,n){let r={id:n.id??t.id,column:t,index:n.index,isPlaceholder:!!n.isPlaceholder,placeholderId:n.placeholderId,depth:n.depth,subHeaders:[],colSpan:0,rowSpan:0,headerGroup:null,getLeafHeaders:()=>{let e=[],t=n=>{n.subHeaders&&n.subHeaders.length&&n.subHeaders.map(t),e.push(n)};return t(r),e},getContext:()=>({table:e,header:r,column:t})};return e._features.forEach(t=>{t.createHeader==null||t.createHeader(r,e)}),r}var s0={createTable:e=>{e.getHeaderGroups=t0(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.left,e.getState().columnPinning.right],(t,n,r,i)=>{let a=r?.map(e=>n.find(t=>t.id===e)).filter(Boolean)??[],o=i?.map(e=>n.find(t=>t.id===e)).filter(Boolean)??[],s=n.filter(e=>!(r!=null&&r.includes(e.id))&&!(i!=null&&i.includes(e.id)));return c0(t,[...a,...s,...o],e)},n0(e.options,a0,`getHeaderGroups`)),e.getCenterHeaderGroups=t0(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.left,e.getState().columnPinning.right],(t,n,r,i)=>(n=n.filter(e=>!(r!=null&&r.includes(e.id))&&!(i!=null&&i.includes(e.id))),c0(t,n,e,`center`)),n0(e.options,a0,`getCenterHeaderGroups`)),e.getLeftHeaderGroups=t0(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.left],(t,n,r)=>c0(t,r?.map(e=>n.find(t=>t.id===e)).filter(Boolean)??[],e,`left`),n0(e.options,a0,`getLeftHeaderGroups`)),e.getRightHeaderGroups=t0(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.right],(t,n,r)=>c0(t,r?.map(e=>n.find(t=>t.id===e)).filter(Boolean)??[],e,`right`),n0(e.options,a0,`getRightHeaderGroups`)),e.getFooterGroups=t0(()=>[e.getHeaderGroups()],e=>[...e].reverse(),n0(e.options,a0,`getFooterGroups`)),e.getLeftFooterGroups=t0(()=>[e.getLeftHeaderGroups()],e=>[...e].reverse(),n0(e.options,a0,`getLeftFooterGroups`)),e.getCenterFooterGroups=t0(()=>[e.getCenterHeaderGroups()],e=>[...e].reverse(),n0(e.options,a0,`getCenterFooterGroups`)),e.getRightFooterGroups=t0(()=>[e.getRightHeaderGroups()],e=>[...e].reverse(),n0(e.options,a0,`getRightFooterGroups`)),e.getFlatHeaders=t0(()=>[e.getHeaderGroups()],e=>e.map(e=>e.headers).flat(),n0(e.options,a0,`getFlatHeaders`)),e.getLeftFlatHeaders=t0(()=>[e.getLeftHeaderGroups()],e=>e.map(e=>e.headers).flat(),n0(e.options,a0,`getLeftFlatHeaders`)),e.getCenterFlatHeaders=t0(()=>[e.getCenterHeaderGroups()],e=>e.map(e=>e.headers).flat(),n0(e.options,a0,`getCenterFlatHeaders`)),e.getRightFlatHeaders=t0(()=>[e.getRightHeaderGroups()],e=>e.map(e=>e.headers).flat(),n0(e.options,a0,`getRightFlatHeaders`)),e.getCenterLeafHeaders=t0(()=>[e.getCenterFlatHeaders()],e=>e.filter(e=>{var t;return!((t=e.subHeaders)!=null&&t.length)}),n0(e.options,a0,`getCenterLeafHeaders`)),e.getLeftLeafHeaders=t0(()=>[e.getLeftFlatHeaders()],e=>e.filter(e=>{var t;return!((t=e.subHeaders)!=null&&t.length)}),n0(e.options,a0,`getLeftLeafHeaders`)),e.getRightLeafHeaders=t0(()=>[e.getRightFlatHeaders()],e=>e.filter(e=>{var t;return!((t=e.subHeaders)!=null&&t.length)}),n0(e.options,a0,`getRightLeafHeaders`)),e.getLeafHeaders=t0(()=>[e.getLeftHeaderGroups(),e.getCenterHeaderGroups(),e.getRightHeaderGroups()],(e,t,n)=>[...e[0]?.headers??[],...t[0]?.headers??[],...n[0]?.headers??[]].map(e=>e.getLeafHeaders()).flat(),n0(e.options,a0,`getLeafHeaders`))}};function c0(e,t,n,r){let i=0,a=function(e,t){t===void 0&&(t=1),i=Math.max(i,t),e.filter(e=>e.getIsVisible()).forEach(e=>{var n;(n=e.columns)!=null&&n.length&&a(e.columns,t+1)},0)};a(e);let o=[],s=(e,t)=>{let i={depth:t,id:[r,`${t}`].filter(Boolean).join(`_`),headers:[]},a=[];e.forEach(e=>{let o=[...a].reverse()[0],s=e.column.depth===i.depth,c,l=!1;if(s&&e.column.parent?c=e.column.parent:(c=e.column,l=!0),o&&o?.column===c)o.subHeaders.push(e);else{let i=o0(n,c,{id:[r,t,c.id,e?.id].filter(Boolean).join(`_`),isPlaceholder:l,placeholderId:l?`${a.filter(e=>e.column===c).length}`:void 0,depth:t,index:a.length});i.subHeaders.push(e),a.push(i)}i.headers.push(e),e.headerGroup=i}),o.push(i),t>0&&s(a,t-1)};s(t.map((e,t)=>o0(n,e,{depth:i,index:t})),i-1),o.reverse();let c=e=>e.filter(e=>e.column.getIsVisible()).map(e=>{let t=0,n=0,r=[0];e.subHeaders&&e.subHeaders.length?(r=[],c(e.subHeaders).forEach(e=>{let{colSpan:n,rowSpan:i}=e;t+=n,r.push(i)})):t=1;let i=Math.min(...r);return n+=i,e.colSpan=t,e.rowSpan=n,{colSpan:t,rowSpan:n}});return c(o[0]?.headers??[]),o}var l0=(e,t,n,r,i,a,o)=>{let s={id:t,index:r,original:n,depth:i,parentId:o,_valuesCache:{},_uniqueValuesCache:{},getValue:t=>{if(s._valuesCache.hasOwnProperty(t))return s._valuesCache[t];let n=e.getColumn(t);if(n!=null&&n.accessorFn)return s._valuesCache[t]=n.accessorFn(s.original,r),s._valuesCache[t]},getUniqueValues:t=>{if(s._uniqueValuesCache.hasOwnProperty(t))return s._uniqueValuesCache[t];let n=e.getColumn(t);if(n!=null&&n.accessorFn)return n.columnDef.getUniqueValues?(s._uniqueValuesCache[t]=n.columnDef.getUniqueValues(s.original,r),s._uniqueValuesCache[t]):(s._uniqueValuesCache[t]=[s.getValue(t)],s._uniqueValuesCache[t])},renderValue:t=>s.getValue(t)??e.options.renderFallbackValue,subRows:a??[],getLeafRows:()=>e0(s.subRows,e=>e.subRows),getParentRow:()=>s.parentId?e.getRow(s.parentId,!0):void 0,getParentRows:()=>{let e=[],t=s;for(;;){let n=t.getParentRow();if(!n)break;e.push(n),t=n}return e.reverse()},getAllCells:t0(()=>[e.getAllLeafColumns()],t=>t.map(t=>r0(e,s,t,t.id)),n0(e.options,`debugRows`,`getAllCells`)),_getAllCellsByColumnId:t0(()=>[s.getAllCells()],e=>e.reduce((e,t)=>(e[t.column.id]=t,e),{}),n0(e.options,`debugRows`,`getAllCellsByColumnId`))};for(let t=0;t<e._features.length;t++){let n=e._features[t];n==null||n.createRow==null||n.createRow(s,e)}return s},u0={createColumn:(e,t)=>{e._getFacetedRowModel=t.options.getFacetedRowModel&&t.options.getFacetedRowModel(t,e.id),e.getFacetedRowModel=()=>e._getFacetedRowModel?e._getFacetedRowModel():t.getPreFilteredRowModel(),e._getFacetedUniqueValues=t.options.getFacetedUniqueValues&&t.options.getFacetedUniqueValues(t,e.id),e.getFacetedUniqueValues=()=>e._getFacetedUniqueValues?e._getFacetedUniqueValues():new Map,e._getFacetedMinMaxValues=t.options.getFacetedMinMaxValues&&t.options.getFacetedMinMaxValues(t,e.id),e.getFacetedMinMaxValues=()=>{if(e._getFacetedMinMaxValues)return e._getFacetedMinMaxValues()}}},d0=(e,t,n)=>{var r,i;let a=n==null||(r=n.toString())==null?void 0:r.toLowerCase();return!!(!((i=e.getValue(t))==null||(i=i.toString())==null||(i=i.toLowerCase())==null)&&i.includes(a))};d0.autoRemove=e=>x0(e);var f0=(e,t,n)=>{var r;return!!(!((r=e.getValue(t))==null||(r=r.toString())==null)&&r.includes(n))};f0.autoRemove=e=>x0(e);var p0=(e,t,n)=>{var r;return((r=e.getValue(t))==null||(r=r.toString())==null?void 0:r.toLowerCase())===n?.toLowerCase()};p0.autoRemove=e=>x0(e);var m0=(e,t,n)=>e.getValue(t)?.includes(n);m0.autoRemove=e=>x0(e);var h0=(e,t,n)=>!n.some(n=>{var r;return!((r=e.getValue(t))!=null&&r.includes(n))});h0.autoRemove=e=>x0(e)||!(e!=null&&e.length);var g0=(e,t,n)=>n.some(n=>e.getValue(t)?.includes(n));g0.autoRemove=e=>x0(e)||!(e!=null&&e.length);var _0=(e,t,n)=>e.getValue(t)===n;_0.autoRemove=e=>x0(e);var v0=(e,t,n)=>e.getValue(t)==n;v0.autoRemove=e=>x0(e);var y0=(e,t,n)=>{let[r,i]=n,a=e.getValue(t);return a>=r&&a<=i};y0.resolveFilterValue=e=>{let[t,n]=e,r=typeof t==`number`?t:parseFloat(t),i=typeof n==`number`?n:parseFloat(n),a=t===null||Number.isNaN(r)?-1/0:r,o=n===null||Number.isNaN(i)?1/0:i;if(a>o){let e=a;a=o,o=e}return[a,o]},y0.autoRemove=e=>x0(e)||x0(e[0])&&x0(e[1]);var b0={includesString:d0,includesStringSensitive:f0,equalsString:p0,arrIncludes:m0,arrIncludesAll:h0,arrIncludesSome:g0,equals:_0,weakEquals:v0,inNumberRange:y0};function x0(e){return e==null||e===``}var S0={getDefaultColumnDef:()=>({filterFn:`auto`}),getInitialState:e=>({columnFilters:[],...e}),getDefaultOptions:e=>({onColumnFiltersChange:Z1(`columnFilters`,e),filterFromLeafRows:!1,maxLeafRowFilterDepth:100}),createColumn:(e,t)=>{e.getAutoFilterFn=()=>{let n=t.getCoreRowModel().flatRows[0]?.getValue(e.id);return typeof n==`string`?b0.includesString:typeof n==`number`?b0.inNumberRange:typeof n==`boolean`||typeof n==`object`&&n?b0.equals:Array.isArray(n)?b0.arrIncludes:b0.weakEquals},e.getFilterFn=()=>Q1(e.columnDef.filterFn)?e.columnDef.filterFn:e.columnDef.filterFn===`auto`?e.getAutoFilterFn():t.options.filterFns?.[e.columnDef.filterFn]??b0[e.columnDef.filterFn],e.getCanFilter=()=>(e.columnDef.enableColumnFilter??!0)&&(t.options.enableColumnFilters??!0)&&(t.options.enableFilters??!0)&&!!e.accessorFn,e.getIsFiltered=()=>e.getFilterIndex()>-1,e.getFilterValue=()=>{var n;return(n=t.getState().columnFilters)==null||(n=n.find(t=>t.id===e.id))==null?void 0:n.value},e.getFilterIndex=()=>t.getState().columnFilters?.findIndex(t=>t.id===e.id)??-1,e.setFilterValue=n=>{t.setColumnFilters(t=>{let r=e.getFilterFn(),i=t?.find(t=>t.id===e.id),a=X1(n,i?i.value:void 0);if(C0(r,a,e))return t?.filter(t=>t.id!==e.id)??[];let o={id:e.id,value:a};return i?t?.map(t=>t.id===e.id?o:t)??[]:t!=null&&t.length?[...t,o]:[o]})}},createRow:(e,t)=>{e.columnFilters={},e.columnFiltersMeta={}},createTable:e=>{e.setColumnFilters=t=>{let n=e.getAllLeafColumns();e.options.onColumnFiltersChange==null||e.options.onColumnFiltersChange(e=>X1(t,e)?.filter(e=>{let t=n.find(t=>t.id===e.id);return!(t&&C0(t.getFilterFn(),e.value,t))}))},e.resetColumnFilters=t=>{e.setColumnFilters(t?[]:e.initialState?.columnFilters??[])},e.getPreFilteredRowModel=()=>e.getCoreRowModel(),e.getFilteredRowModel=()=>(!e._getFilteredRowModel&&e.options.getFilteredRowModel&&(e._getFilteredRowModel=e.options.getFilteredRowModel(e)),e.options.manualFiltering||!e._getFilteredRowModel?e.getPreFilteredRowModel():e._getFilteredRowModel())}};function C0(e,t,n){return(e&&e.autoRemove?e.autoRemove(t,n):!1)||t===void 0||typeof t==`string`&&!t}var w0={sum:(e,t,n)=>n.reduce((t,n)=>{let r=n.getValue(e);return t+(typeof r==`number`?r:0)},0),min:(e,t,n)=>{let r;return n.forEach(t=>{let n=t.getValue(e);n!=null&&(r>n||r===void 0&&n>=n)&&(r=n)}),r},max:(e,t,n)=>{let r;return n.forEach(t=>{let n=t.getValue(e);n!=null&&(r<n||r===void 0&&n>=n)&&(r=n)}),r},extent:(e,t,n)=>{let r,i;return n.forEach(t=>{let n=t.getValue(e);n!=null&&(r===void 0?n>=n&&(r=i=n):(r>n&&(r=n),i<n&&(i=n)))}),[r,i]},mean:(e,t)=>{let n=0,r=0;if(t.forEach(t=>{let i=t.getValue(e);i!=null&&(i=+i)>=i&&(++n,r+=i)}),n)return r/n},median:(e,t)=>{if(!t.length)return;let n=t.map(t=>t.getValue(e));if(!$1(n))return;if(n.length===1)return n[0];let r=Math.floor(n.length/2),i=n.sort((e,t)=>e-t);return n.length%2==0?(i[r-1]+i[r])/2:i[r]},unique:(e,t)=>Array.from(new Set(t.map(t=>t.getValue(e))).values()),uniqueCount:(e,t)=>new Set(t.map(t=>t.getValue(e))).size,count:(e,t)=>t.length},T0={getDefaultColumnDef:()=>({aggregatedCell:e=>{var t;return((t=e.getValue())==null||t.toString==null?void 0:t.toString())??null},aggregationFn:`auto`}),getInitialState:e=>({grouping:[],...e}),getDefaultOptions:e=>({onGroupingChange:Z1(`grouping`,e),groupedColumnMode:`reorder`}),createColumn:(e,t)=>{e.toggleGrouping=()=>{t.setGrouping(t=>t!=null&&t.includes(e.id)?t.filter(t=>t!==e.id):[...t??[],e.id])},e.getCanGroup=()=>(e.columnDef.enableGrouping??!0)&&(t.options.enableGrouping??!0)&&(!!e.accessorFn||!!e.columnDef.getGroupingValue),e.getIsGrouped=()=>t.getState().grouping?.includes(e.id),e.getGroupedIndex=()=>t.getState().grouping?.indexOf(e.id),e.getToggleGroupingHandler=()=>{let t=e.getCanGroup();return()=>{t&&e.toggleGrouping()}},e.getAutoAggregationFn=()=>{let n=t.getCoreRowModel().flatRows[0]?.getValue(e.id);if(typeof n==`number`)return w0.sum;if(Object.prototype.toString.call(n)===`[object Date]`)return w0.extent},e.getAggregationFn=()=>{if(!e)throw Error();return Q1(e.columnDef.aggregationFn)?e.columnDef.aggregationFn:e.columnDef.aggregationFn===`auto`?e.getAutoAggregationFn():t.options.aggregationFns?.[e.columnDef.aggregationFn]??w0[e.columnDef.aggregationFn]}},createTable:e=>{e.setGrouping=t=>e.options.onGroupingChange==null?void 0:e.options.onGroupingChange(t),e.resetGrouping=t=>{e.setGrouping(t?[]:e.initialState?.grouping??[])},e.getPreGroupedRowModel=()=>e.getFilteredRowModel(),e.getGroupedRowModel=()=>(!e._getGroupedRowModel&&e.options.getGroupedRowModel&&(e._getGroupedRowModel=e.options.getGroupedRowModel(e)),e.options.manualGrouping||!e._getGroupedRowModel?e.getPreGroupedRowModel():e._getGroupedRowModel())},createRow:(e,t)=>{e.getIsGrouped=()=>!!e.groupingColumnId,e.getGroupingValue=n=>{if(e._groupingValuesCache.hasOwnProperty(n))return e._groupingValuesCache[n];let r=t.getColumn(n);return r!=null&&r.columnDef.getGroupingValue?(e._groupingValuesCache[n]=r.columnDef.getGroupingValue(e.original),e._groupingValuesCache[n]):e.getValue(n)},e._groupingValuesCache={}},createCell:(e,t,n,r)=>{e.getIsGrouped=()=>t.getIsGrouped()&&t.id===n.groupingColumnId,e.getIsPlaceholder=()=>!e.getIsGrouped()&&t.getIsGrouped(),e.getIsAggregated=()=>{var t;return!e.getIsGrouped()&&!e.getIsPlaceholder()&&!!((t=n.subRows)!=null&&t.length)}}};function E0(e,t,n){if(!(t!=null&&t.length)||!n)return e;let r=e.filter(e=>!t.includes(e.id));return n===`remove`?r:[...t.map(t=>e.find(e=>e.id===t)).filter(Boolean),...r]}var D0={getInitialState:e=>({columnOrder:[],...e}),getDefaultOptions:e=>({onColumnOrderChange:Z1(`columnOrder`,e)}),createColumn:(e,t)=>{e.getIndex=t0(e=>[R0(t,e)],t=>t.findIndex(t=>t.id===e.id),n0(t.options,`debugColumns`,`getIndex`)),e.getIsFirstColumn=n=>R0(t,n)[0]?.id===e.id,e.getIsLastColumn=n=>{let r=R0(t,n);return r[r.length-1]?.id===e.id}},createTable:e=>{e.setColumnOrder=t=>e.options.onColumnOrderChange==null?void 0:e.options.onColumnOrderChange(t),e.resetColumnOrder=t=>{e.setColumnOrder(t?[]:e.initialState.columnOrder??[])},e._getOrderColumnsFn=t0(()=>[e.getState().columnOrder,e.getState().grouping,e.options.groupedColumnMode],(e,t,n)=>r=>{let i=[];if(!(e!=null&&e.length))i=r;else{let t=[...e],n=[...r];for(;n.length&&t.length;){let e=t.shift(),r=n.findIndex(t=>t.id===e);r>-1&&i.push(n.splice(r,1)[0])}i=[...i,...n]}return E0(i,t,n)},n0(e.options,`debugTable`,`_getOrderColumnsFn`))}},O0=()=>({left:[],right:[]}),k0={getInitialState:e=>({columnPinning:O0(),...e}),getDefaultOptions:e=>({onColumnPinningChange:Z1(`columnPinning`,e)}),createColumn:(e,t)=>{e.pin=n=>{let r=e.getLeafColumns().map(e=>e.id).filter(Boolean);t.setColumnPinning(e=>n===`right`?{left:(e?.left??[]).filter(e=>!(r!=null&&r.includes(e))),right:[...(e?.right??[]).filter(e=>!(r!=null&&r.includes(e))),...r]}:n===`left`?{left:[...(e?.left??[]).filter(e=>!(r!=null&&r.includes(e))),...r],right:(e?.right??[]).filter(e=>!(r!=null&&r.includes(e)))}:{left:(e?.left??[]).filter(e=>!(r!=null&&r.includes(e))),right:(e?.right??[]).filter(e=>!(r!=null&&r.includes(e)))})},e.getCanPin=()=>e.getLeafColumns().some(e=>(e.columnDef.enablePinning??!0)&&(t.options.enableColumnPinning??t.options.enablePinning??!0)),e.getIsPinned=()=>{let n=e.getLeafColumns().map(e=>e.id),{left:r,right:i}=t.getState().columnPinning,a=n.some(e=>r?.includes(e)),o=n.some(e=>i?.includes(e));return a?`left`:o?`right`:!1},e.getPinnedIndex=()=>{var n;let r=e.getIsPinned();return r?((n=t.getState().columnPinning)==null||(n=n[r])==null?void 0:n.indexOf(e.id))??-1:0}},createRow:(e,t)=>{e.getCenterVisibleCells=t0(()=>[e._getAllVisibleCells(),t.getState().columnPinning.left,t.getState().columnPinning.right],(e,t,n)=>{let r=[...t??[],...n??[]];return e.filter(e=>!r.includes(e.column.id))},n0(t.options,`debugRows`,`getCenterVisibleCells`)),e.getLeftVisibleCells=t0(()=>[e._getAllVisibleCells(),t.getState().columnPinning.left],(e,t)=>(t??[]).map(t=>e.find(e=>e.column.id===t)).filter(Boolean).map(e=>({...e,position:`left`})),n0(t.options,`debugRows`,`getLeftVisibleCells`)),e.getRightVisibleCells=t0(()=>[e._getAllVisibleCells(),t.getState().columnPinning.right],(e,t)=>(t??[]).map(t=>e.find(e=>e.column.id===t)).filter(Boolean).map(e=>({...e,position:`right`})),n0(t.options,`debugRows`,`getRightVisibleCells`))},createTable:e=>{e.setColumnPinning=t=>e.options.onColumnPinningChange==null?void 0:e.options.onColumnPinningChange(t),e.resetColumnPinning=t=>e.setColumnPinning(t?O0():e.initialState?.columnPinning??O0()),e.getIsSomeColumnsPinned=t=>{let n=e.getState().columnPinning;return t?!!n[t]?.length:!!(n.left?.length||n.right?.length)},e.getLeftLeafColumns=t0(()=>[e.getAllLeafColumns(),e.getState().columnPinning.left],(e,t)=>(t??[]).map(t=>e.find(e=>e.id===t)).filter(Boolean),n0(e.options,`debugColumns`,`getLeftLeafColumns`)),e.getRightLeafColumns=t0(()=>[e.getAllLeafColumns(),e.getState().columnPinning.right],(e,t)=>(t??[]).map(t=>e.find(e=>e.id===t)).filter(Boolean),n0(e.options,`debugColumns`,`getRightLeafColumns`)),e.getCenterLeafColumns=t0(()=>[e.getAllLeafColumns(),e.getState().columnPinning.left,e.getState().columnPinning.right],(e,t,n)=>{let r=[...t??[],...n??[]];return e.filter(e=>!r.includes(e.id))},n0(e.options,`debugColumns`,`getCenterLeafColumns`))}};function A0(e){return e||(typeof document<`u`?document:null)}var j0={size:150,minSize:20,maxSize:2**53-1},M0=()=>({startOffset:null,startSize:null,deltaOffset:null,deltaPercentage:null,isResizingColumn:!1,columnSizingStart:[]}),N0={getDefaultColumnDef:()=>j0,getInitialState:e=>({columnSizing:{},columnSizingInfo:M0(),...e}),getDefaultOptions:e=>({columnResizeMode:`onEnd`,columnResizeDirection:`ltr`,onColumnSizingChange:Z1(`columnSizing`,e),onColumnSizingInfoChange:Z1(`columnSizingInfo`,e)}),createColumn:(e,t)=>{e.getSize=()=>{let n=t.getState().columnSizing[e.id];return Math.min(Math.max(e.columnDef.minSize??j0.minSize,n??e.columnDef.size??j0.size),e.columnDef.maxSize??j0.maxSize)},e.getStart=t0(e=>[e,R0(t,e),t.getState().columnSizing],(t,n)=>n.slice(0,e.getIndex(t)).reduce((e,t)=>e+t.getSize(),0),n0(t.options,`debugColumns`,`getStart`)),e.getAfter=t0(e=>[e,R0(t,e),t.getState().columnSizing],(t,n)=>n.slice(e.getIndex(t)+1).reduce((e,t)=>e+t.getSize(),0),n0(t.options,`debugColumns`,`getAfter`)),e.resetSize=()=>{t.setColumnSizing(t=>{let{[e.id]:n,...r}=t;return r})},e.getCanResize=()=>(e.columnDef.enableResizing??!0)&&(t.options.enableColumnResizing??!0),e.getIsResizing=()=>t.getState().columnSizingInfo.isResizingColumn===e.id},createHeader:(e,t)=>{e.getSize=()=>{let t=0,n=e=>{e.subHeaders.length?e.subHeaders.forEach(n):t+=e.column.getSize()??0};return n(e),t},e.getStart=()=>{if(e.index>0){let t=e.headerGroup.headers[e.index-1];return t.getStart()+t.getSize()}return 0},e.getResizeHandler=n=>{let r=t.getColumn(e.column.id),i=r?.getCanResize();return a=>{if(!r||!i||(a.persist==null||a.persist(),I0(a)&&a.touches&&a.touches.length>1))return;let o=e.getSize(),s=e?e.getLeafHeaders().map(e=>[e.column.id,e.column.getSize()]):[[r.id,r.getSize()]],c=I0(a)?Math.round(a.touches[0].clientX):a.clientX,l={},u=(e,n)=>{typeof n==`number`&&(t.setColumnSizingInfo(e=>{let r=t.options.columnResizeDirection===`rtl`?-1:1,i=(n-(e?.startOffset??0))*r,a=Math.max(i/(e?.startSize??0),-.999999);return e.columnSizingStart.forEach(e=>{let[t,n]=e;l[t]=Math.round(Math.max(n+n*a,0)*100)/100}),{...e,deltaOffset:i,deltaPercentage:a}}),(t.options.columnResizeMode===`onChange`||e===`end`)&&t.setColumnSizing(e=>({...e,...l})))},d=e=>u(`move`,e),f=e=>{u(`end`,e),t.setColumnSizingInfo(e=>({...e,isResizingColumn:!1,startOffset:null,startSize:null,deltaOffset:null,deltaPercentage:null,columnSizingStart:[]}))},p=A0(n),m={moveHandler:e=>d(e.clientX),upHandler:e=>{p?.removeEventListener(`mousemove`,m.moveHandler),p?.removeEventListener(`mouseup`,m.upHandler),f(e.clientX)}},h={moveHandler:e=>(e.cancelable&&(e.preventDefault(),e.stopPropagation()),d(e.touches[0].clientX),!1),upHandler:e=>{p?.removeEventListener(`touchmove`,h.moveHandler),p?.removeEventListener(`touchend`,h.upHandler),e.cancelable&&(e.preventDefault(),e.stopPropagation()),f(e.touches[0]?.clientX)}},g=F0()?{passive:!1}:!1;I0(a)?(p?.addEventListener(`touchmove`,h.moveHandler,g),p?.addEventListener(`touchend`,h.upHandler,g)):(p?.addEventListener(`mousemove`,m.moveHandler,g),p?.addEventListener(`mouseup`,m.upHandler,g)),t.setColumnSizingInfo(e=>({...e,startOffset:c,startSize:o,deltaOffset:0,deltaPercentage:0,columnSizingStart:s,isResizingColumn:r.id}))}}},createTable:e=>{e.setColumnSizing=t=>e.options.onColumnSizingChange==null?void 0:e.options.onColumnSizingChange(t),e.setColumnSizingInfo=t=>e.options.onColumnSizingInfoChange==null?void 0:e.options.onColumnSizingInfoChange(t),e.resetColumnSizing=t=>{e.setColumnSizing(t?{}:e.initialState.columnSizing??{})},e.resetHeaderSizeInfo=t=>{e.setColumnSizingInfo(t?M0():e.initialState.columnSizingInfo??M0())},e.getTotalSize=()=>e.getHeaderGroups()[0]?.headers.reduce((e,t)=>e+t.getSize(),0)??0,e.getLeftTotalSize=()=>e.getLeftHeaderGroups()[0]?.headers.reduce((e,t)=>e+t.getSize(),0)??0,e.getCenterTotalSize=()=>e.getCenterHeaderGroups()[0]?.headers.reduce((e,t)=>e+t.getSize(),0)??0,e.getRightTotalSize=()=>e.getRightHeaderGroups()[0]?.headers.reduce((e,t)=>e+t.getSize(),0)??0}},P0=null;function F0(){if(typeof P0==`boolean`)return P0;let e=!1;try{let t={get passive(){return e=!0,!1}},n=()=>{};window.addEventListener(`test`,n,t),window.removeEventListener(`test`,n)}catch{e=!1}return P0=e,P0}function I0(e){return e.type===`touchstart`}var L0={getInitialState:e=>({columnVisibility:{},...e}),getDefaultOptions:e=>({onColumnVisibilityChange:Z1(`columnVisibility`,e)}),createColumn:(e,t)=>{e.toggleVisibility=n=>{e.getCanHide()&&t.setColumnVisibility(t=>({...t,[e.id]:n??!e.getIsVisible()}))},e.getIsVisible=()=>{let n=e.columns;return(n.length?n.some(e=>e.getIsVisible()):t.getState().columnVisibility?.[e.id])??!0},e.getCanHide=()=>(e.columnDef.enableHiding??!0)&&(t.options.enableHiding??!0),e.getToggleVisibilityHandler=()=>t=>{e.toggleVisibility==null||e.toggleVisibility(t.target.checked)}},createRow:(e,t)=>{e._getAllVisibleCells=t0(()=>[e.getAllCells(),t.getState().columnVisibility],e=>e.filter(e=>e.column.getIsVisible()),n0(t.options,`debugRows`,`_getAllVisibleCells`)),e.getVisibleCells=t0(()=>[e.getLeftVisibleCells(),e.getCenterVisibleCells(),e.getRightVisibleCells()],(e,t,n)=>[...e,...t,...n],n0(t.options,`debugRows`,`getVisibleCells`))},createTable:e=>{let t=(t,n)=>t0(()=>[n(),n().filter(e=>e.getIsVisible()).map(e=>e.id).join(`_`)],e=>e.filter(e=>e.getIsVisible==null?void 0:e.getIsVisible()),n0(e.options,`debugColumns`,t));e.getVisibleFlatColumns=t(`getVisibleFlatColumns`,()=>e.getAllFlatColumns()),e.getVisibleLeafColumns=t(`getVisibleLeafColumns`,()=>e.getAllLeafColumns()),e.getLeftVisibleLeafColumns=t(`getLeftVisibleLeafColumns`,()=>e.getLeftLeafColumns()),e.getRightVisibleLeafColumns=t(`getRightVisibleLeafColumns`,()=>e.getRightLeafColumns()),e.getCenterVisibleLeafColumns=t(`getCenterVisibleLeafColumns`,()=>e.getCenterLeafColumns()),e.setColumnVisibility=t=>e.options.onColumnVisibilityChange==null?void 0:e.options.onColumnVisibilityChange(t),e.resetColumnVisibility=t=>{e.setColumnVisibility(t?{}:e.initialState.columnVisibility??{})},e.toggleAllColumnsVisible=t=>{t??=!e.getIsAllColumnsVisible(),e.setColumnVisibility(e.getAllLeafColumns().reduce((e,n)=>({...e,[n.id]:t||!(n.getCanHide!=null&&n.getCanHide())}),{}))},e.getIsAllColumnsVisible=()=>!e.getAllLeafColumns().some(e=>!(e.getIsVisible!=null&&e.getIsVisible())),e.getIsSomeColumnsVisible=()=>e.getAllLeafColumns().some(e=>e.getIsVisible==null?void 0:e.getIsVisible()),e.getToggleAllColumnsVisibilityHandler=()=>t=>{e.toggleAllColumnsVisible(t.target?.checked)}}};function R0(e,t){return t?t===`center`?e.getCenterVisibleLeafColumns():t===`left`?e.getLeftVisibleLeafColumns():e.getRightVisibleLeafColumns():e.getVisibleLeafColumns()}var z0={createTable:e=>{e._getGlobalFacetedRowModel=e.options.getFacetedRowModel&&e.options.getFacetedRowModel(e,`__global__`),e.getGlobalFacetedRowModel=()=>e.options.manualFiltering||!e._getGlobalFacetedRowModel?e.getPreFilteredRowModel():e._getGlobalFacetedRowModel(),e._getGlobalFacetedUniqueValues=e.options.getFacetedUniqueValues&&e.options.getFacetedUniqueValues(e,`__global__`),e.getGlobalFacetedUniqueValues=()=>e._getGlobalFacetedUniqueValues?e._getGlobalFacetedUniqueValues():new Map,e._getGlobalFacetedMinMaxValues=e.options.getFacetedMinMaxValues&&e.options.getFacetedMinMaxValues(e,`__global__`),e.getGlobalFacetedMinMaxValues=()=>{if(e._getGlobalFacetedMinMaxValues)return e._getGlobalFacetedMinMaxValues()}}},B0={getInitialState:e=>({globalFilter:void 0,...e}),getDefaultOptions:e=>({onGlobalFilterChange:Z1(`globalFilter`,e),globalFilterFn:`auto`,getColumnCanGlobalFilter:t=>{var n;let r=(n=e.getCoreRowModel().flatRows[0])==null||(n=n._getAllCellsByColumnId()[t.id])==null?void 0:n.getValue();return typeof r==`string`||typeof r==`number`}}),createColumn:(e,t)=>{e.getCanGlobalFilter=()=>(e.columnDef.enableGlobalFilter??!0)&&(t.options.enableGlobalFilter??!0)&&(t.options.enableFilters??!0)&&((t.options.getColumnCanGlobalFilter==null?void 0:t.options.getColumnCanGlobalFilter(e))??!0)&&!!e.accessorFn},createTable:e=>{e.getGlobalAutoFilterFn=()=>b0.includesString,e.getGlobalFilterFn=()=>{let{globalFilterFn:t}=e.options;return Q1(t)?t:t===`auto`?e.getGlobalAutoFilterFn():e.options.filterFns?.[t]??b0[t]},e.setGlobalFilter=t=>{e.options.onGlobalFilterChange==null||e.options.onGlobalFilterChange(t)},e.resetGlobalFilter=t=>{e.setGlobalFilter(t?void 0:e.initialState.globalFilter)}}},V0={getInitialState:e=>({expanded:{},...e}),getDefaultOptions:e=>({onExpandedChange:Z1(`expanded`,e),paginateExpandedRows:!0}),createTable:e=>{let t=!1,n=!1;e._autoResetExpanded=()=>{if(!t){e._queue(()=>{t=!0});return}if(e.options.autoResetAll??e.options.autoResetExpanded??!e.options.manualExpanding){if(n)return;n=!0,e._queue(()=>{e.resetExpanded(),n=!1})}},e.setExpanded=t=>e.options.onExpandedChange==null?void 0:e.options.onExpandedChange(t),e.toggleAllRowsExpanded=t=>{t??!e.getIsAllRowsExpanded()?e.setExpanded(!0):e.setExpanded({})},e.resetExpanded=t=>{e.setExpanded(t?{}:e.initialState?.expanded??{})},e.getCanSomeRowsExpand=()=>e.getPrePaginationRowModel().flatRows.some(e=>e.getCanExpand()),e.getToggleAllRowsExpandedHandler=()=>t=>{t.persist==null||t.persist(),e.toggleAllRowsExpanded()},e.getIsSomeRowsExpanded=()=>{let t=e.getState().expanded;return t===!0||Object.values(t).some(Boolean)},e.getIsAllRowsExpanded=()=>{let t=e.getState().expanded;return typeof t==`boolean`?t===!0:!(!Object.keys(t).length||e.getRowModel().flatRows.some(e=>!e.getIsExpanded()))},e.getExpandedDepth=()=>{let t=0;return(e.getState().expanded===!0?Object.keys(e.getRowModel().rowsById):Object.keys(e.getState().expanded)).forEach(e=>{let n=e.split(`.`);t=Math.max(t,n.length)}),t},e.getPreExpandedRowModel=()=>e.getSortedRowModel(),e.getExpandedRowModel=()=>(!e._getExpandedRowModel&&e.options.getExpandedRowModel&&(e._getExpandedRowModel=e.options.getExpandedRowModel(e)),e.options.manualExpanding||!e._getExpandedRowModel?e.getPreExpandedRowModel():e._getExpandedRowModel())},createRow:(e,t)=>{e.toggleExpanded=n=>{t.setExpanded(r=>{let i=r===!0?!0:!!(r!=null&&r[e.id]),a={};if(r===!0?Object.keys(t.getRowModel().rowsById).forEach(e=>{a[e]=!0}):a=r,n??=!i,!i&&n)return{...a,[e.id]:!0};if(i&&!n){let{[e.id]:t,...n}=a;return n}return r})},e.getIsExpanded=()=>{let n=t.getState().expanded;return!!((t.options.getIsRowExpanded==null?void 0:t.options.getIsRowExpanded(e))??(n===!0||n?.[e.id]))},e.getCanExpand=()=>{var n;return(t.options.getRowCanExpand==null?void 0:t.options.getRowCanExpand(e))??((t.options.enableExpanding??!0)&&!!((n=e.subRows)!=null&&n.length))},e.getIsAllParentsExpanded=()=>{let n=!0,r=e;for(;n&&r.parentId;)r=t.getRow(r.parentId,!0),n=r.getIsExpanded();return n},e.getToggleExpandedHandler=()=>{let t=e.getCanExpand();return()=>{t&&e.toggleExpanded()}}}},H0=0,U0=10,W0=()=>({pageIndex:H0,pageSize:U0}),G0={getInitialState:e=>({...e,pagination:{...W0(),...e?.pagination}}),getDefaultOptions:e=>({onPaginationChange:Z1(`pagination`,e)}),createTable:e=>{let t=!1,n=!1;e._autoResetPageIndex=()=>{if(!t){e._queue(()=>{t=!0});return}if(e.options.autoResetAll??e.options.autoResetPageIndex??!e.options.manualPagination){if(n)return;n=!0,e._queue(()=>{e.resetPageIndex(),n=!1})}},e.setPagination=t=>e.options.onPaginationChange==null?void 0:e.options.onPaginationChange(e=>X1(t,e)),e.resetPagination=t=>{e.setPagination(t?W0():e.initialState.pagination??W0())},e.setPageIndex=t=>{e.setPagination(n=>{let r=X1(t,n.pageIndex),i=e.options.pageCount===void 0||e.options.pageCount===-1?2**53-1:e.options.pageCount-1;return r=Math.max(0,Math.min(r,i)),{...n,pageIndex:r}})},e.resetPageIndex=t=>{var n;e.setPageIndex(t?H0:((n=e.initialState)==null||(n=n.pagination)==null?void 0:n.pageIndex)??H0)},e.resetPageSize=t=>{var n;e.setPageSize(t?U0:((n=e.initialState)==null||(n=n.pagination)==null?void 0:n.pageSize)??U0)},e.setPageSize=t=>{e.setPagination(e=>{let n=Math.max(1,X1(t,e.pageSize)),r=e.pageSize*e.pageIndex,i=Math.floor(r/n);return{...e,pageIndex:i,pageSize:n}})},e.setPageCount=t=>e.setPagination(n=>{let r=X1(t,e.options.pageCount??-1);return typeof r==`number`&&(r=Math.max(-1,r)),{...n,pageCount:r}}),e.getPageOptions=t0(()=>[e.getPageCount()],e=>{let t=[];return e&&e>0&&(t=[...Array(e)].fill(null).map((e,t)=>t)),t},n0(e.options,`debugTable`,`getPageOptions`)),e.getCanPreviousPage=()=>e.getState().pagination.pageIndex>0,e.getCanNextPage=()=>{let{pageIndex:t}=e.getState().pagination,n=e.getPageCount();return n===-1?!0:n===0?!1:t<n-1},e.previousPage=()=>e.setPageIndex(e=>e-1),e.nextPage=()=>e.setPageIndex(e=>e+1),e.firstPage=()=>e.setPageIndex(0),e.lastPage=()=>e.setPageIndex(e.getPageCount()-1),e.getPrePaginationRowModel=()=>e.getExpandedRowModel(),e.getPaginationRowModel=()=>(!e._getPaginationRowModel&&e.options.getPaginationRowModel&&(e._getPaginationRowModel=e.options.getPaginationRowModel(e)),e.options.manualPagination||!e._getPaginationRowModel?e.getPrePaginationRowModel():e._getPaginationRowModel()),e.getPageCount=()=>e.options.pageCount??Math.ceil(e.getRowCount()/e.getState().pagination.pageSize),e.getRowCount=()=>e.options.rowCount??e.getPrePaginationRowModel().rows.length}},K0=()=>({top:[],bottom:[]}),q0={getInitialState:e=>({rowPinning:K0(),...e}),getDefaultOptions:e=>({onRowPinningChange:Z1(`rowPinning`,e)}),createRow:(e,t)=>{e.pin=(n,r,i)=>{let a=r?e.getLeafRows().map(e=>{let{id:t}=e;return t}):[],o=i?e.getParentRows().map(e=>{let{id:t}=e;return t}):[],s=new Set([...o,e.id,...a]);t.setRowPinning(e=>n===`bottom`?{top:(e?.top??[]).filter(e=>!(s!=null&&s.has(e))),bottom:[...(e?.bottom??[]).filter(e=>!(s!=null&&s.has(e))),...Array.from(s)]}:n===`top`?{top:[...(e?.top??[]).filter(e=>!(s!=null&&s.has(e))),...Array.from(s)],bottom:(e?.bottom??[]).filter(e=>!(s!=null&&s.has(e)))}:{top:(e?.top??[]).filter(e=>!(s!=null&&s.has(e))),bottom:(e?.bottom??[]).filter(e=>!(s!=null&&s.has(e)))})},e.getCanPin=()=>{let{enableRowPinning:n,enablePinning:r}=t.options;return typeof n==`function`?n(e):n??r??!0},e.getIsPinned=()=>{let n=[e.id],{top:r,bottom:i}=t.getState().rowPinning,a=n.some(e=>r?.includes(e)),o=n.some(e=>i?.includes(e));return a?`top`:o?`bottom`:!1},e.getPinnedIndex=()=>{let n=e.getIsPinned();return n?((n===`top`?t.getTopRows():t.getBottomRows())?.map(e=>{let{id:t}=e;return t}))?.indexOf(e.id)??-1:-1}},createTable:e=>{e.setRowPinning=t=>e.options.onRowPinningChange==null?void 0:e.options.onRowPinningChange(t),e.resetRowPinning=t=>e.setRowPinning(t?K0():e.initialState?.rowPinning??K0()),e.getIsSomeRowsPinned=t=>{let n=e.getState().rowPinning;return t?!!n[t]?.length:!!(n.top?.length||n.bottom?.length)},e._getPinnedRows=(t,n,r)=>(e.options.keepPinnedRows??!0?(n??[]).map(t=>{let n=e.getRow(t,!0);return n.getIsAllParentsExpanded()?n:null}):(n??[]).map(e=>t.find(t=>t.id===e))).filter(Boolean).map(e=>({...e,position:r})),e.getTopRows=t0(()=>[e.getRowModel().rows,e.getState().rowPinning.top],(t,n)=>e._getPinnedRows(t,n,`top`),n0(e.options,`debugRows`,`getTopRows`)),e.getBottomRows=t0(()=>[e.getRowModel().rows,e.getState().rowPinning.bottom],(t,n)=>e._getPinnedRows(t,n,`bottom`),n0(e.options,`debugRows`,`getBottomRows`)),e.getCenterRows=t0(()=>[e.getRowModel().rows,e.getState().rowPinning.top,e.getState().rowPinning.bottom],(e,t,n)=>{let r=new Set([...t??[],...n??[]]);return e.filter(e=>!r.has(e.id))},n0(e.options,`debugRows`,`getCenterRows`))}},J0={getInitialState:e=>({rowSelection:{},...e}),getDefaultOptions:e=>({onRowSelectionChange:Z1(`rowSelection`,e),enableRowSelection:!0,enableMultiRowSelection:!0,enableSubRowSelection:!0}),createTable:e=>{e.setRowSelection=t=>e.options.onRowSelectionChange==null?void 0:e.options.onRowSelectionChange(t),e.resetRowSelection=t=>e.setRowSelection(t?{}:e.initialState.rowSelection??{}),e.toggleAllRowsSelected=t=>{e.setRowSelection(n=>{t=t===void 0?!e.getIsAllRowsSelected():t;let r={...n},i=e.getPreGroupedRowModel().flatRows;return t?i.forEach(e=>{e.getCanSelect()&&(r[e.id]=!0)}):i.forEach(e=>{delete r[e.id]}),r})},e.toggleAllPageRowsSelected=t=>e.setRowSelection(n=>{let r=t===void 0?!e.getIsAllPageRowsSelected():t,i={...n};return e.getRowModel().rows.forEach(t=>{Y0(i,t.id,r,!0,e)}),i}),e.getPreSelectedRowModel=()=>e.getCoreRowModel(),e.getSelectedRowModel=t0(()=>[e.getState().rowSelection,e.getCoreRowModel()],(t,n)=>Object.keys(t).length?X0(e,n):{rows:[],flatRows:[],rowsById:{}},n0(e.options,`debugTable`,`getSelectedRowModel`)),e.getFilteredSelectedRowModel=t0(()=>[e.getState().rowSelection,e.getFilteredRowModel()],(t,n)=>Object.keys(t).length?X0(e,n):{rows:[],flatRows:[],rowsById:{}},n0(e.options,`debugTable`,`getFilteredSelectedRowModel`)),e.getGroupedSelectedRowModel=t0(()=>[e.getState().rowSelection,e.getSortedRowModel()],(t,n)=>Object.keys(t).length?X0(e,n):{rows:[],flatRows:[],rowsById:{}},n0(e.options,`debugTable`,`getGroupedSelectedRowModel`)),e.getIsAllRowsSelected=()=>{let t=e.getFilteredRowModel().flatRows,{rowSelection:n}=e.getState(),r=!!(t.length&&Object.keys(n).length);return r&&t.some(e=>e.getCanSelect()&&!n[e.id])&&(r=!1),r},e.getIsAllPageRowsSelected=()=>{let t=e.getPaginationRowModel().flatRows.filter(e=>e.getCanSelect()),{rowSelection:n}=e.getState(),r=!!t.length;return r&&t.some(e=>!n[e.id])&&(r=!1),r},e.getIsSomeRowsSelected=()=>{let t=Object.keys(e.getState().rowSelection??{}).length;return t>0&&t<e.getFilteredRowModel().flatRows.length},e.getIsSomePageRowsSelected=()=>{let t=e.getPaginationRowModel().flatRows;return e.getIsAllPageRowsSelected()?!1:t.filter(e=>e.getCanSelect()).some(e=>e.getIsSelected()||e.getIsSomeSelected())},e.getToggleAllRowsSelectedHandler=()=>t=>{e.toggleAllRowsSelected(t.target.checked)},e.getToggleAllPageRowsSelectedHandler=()=>t=>{e.toggleAllPageRowsSelected(t.target.checked)}},createRow:(e,t)=>{e.toggleSelected=(n,r)=>{let i=e.getIsSelected();t.setRowSelection(a=>{if(n=n===void 0?!i:n,e.getCanSelect()&&i===n)return a;let o={...a};return Y0(o,e.id,n,r?.selectChildren??!0,t),o})},e.getIsSelected=()=>{let{rowSelection:n}=t.getState();return Z0(e,n)},e.getIsSomeSelected=()=>{let{rowSelection:n}=t.getState();return Q0(e,n)===`some`},e.getIsAllSubRowsSelected=()=>{let{rowSelection:n}=t.getState();return Q0(e,n)===`all`},e.getCanSelect=()=>typeof t.options.enableRowSelection==`function`?t.options.enableRowSelection(e):t.options.enableRowSelection??!0,e.getCanSelectSubRows=()=>typeof t.options.enableSubRowSelection==`function`?t.options.enableSubRowSelection(e):t.options.enableSubRowSelection??!0,e.getCanMultiSelect=()=>typeof t.options.enableMultiRowSelection==`function`?t.options.enableMultiRowSelection(e):t.options.enableMultiRowSelection??!0,e.getToggleSelectedHandler=()=>{let t=e.getCanSelect();return n=>{t&&e.toggleSelected(n.target?.checked)}}}},Y0=(e,t,n,r,i)=>{var a;let o=i.getRow(t,!0);n?(o.getCanMultiSelect()||Object.keys(e).forEach(t=>delete e[t]),o.getCanSelect()&&(e[t]=!0)):delete e[t],r&&(a=o.subRows)!=null&&a.length&&o.getCanSelectSubRows()&&o.subRows.forEach(t=>Y0(e,t.id,n,r,i))};function X0(e,t){let n=e.getState().rowSelection,r=[],i={},a=function(e,t){return e.map(e=>{var t;let o=Z0(e,n);if(o&&(r.push(e),i[e.id]=e),(t=e.subRows)!=null&&t.length&&(e={...e,subRows:a(e.subRows)}),o)return e}).filter(Boolean)};return{rows:a(t.rows),flatRows:r,rowsById:i}}function Z0(e,t){return t[e.id]??!1}function Q0(e,t,n){var r;if(!((r=e.subRows)!=null&&r.length))return!1;let i=!0,a=!1;return e.subRows.forEach(e=>{if(!(a&&!i)&&(e.getCanSelect()&&(Z0(e,t)?a=!0:i=!1),e.subRows&&e.subRows.length)){let n=Q0(e,t);n===`all`?a=!0:(n===`some`&&(a=!0),i=!1)}}),i?`all`:a?`some`:!1}var $0=/([0-9]+)/gm,e2=(e,t,n)=>c2(s2(e.getValue(n)).toLowerCase(),s2(t.getValue(n)).toLowerCase()),t2=(e,t,n)=>c2(s2(e.getValue(n)),s2(t.getValue(n))),n2=(e,t,n)=>o2(s2(e.getValue(n)).toLowerCase(),s2(t.getValue(n)).toLowerCase()),r2=(e,t,n)=>o2(s2(e.getValue(n)),s2(t.getValue(n))),i2=(e,t,n)=>{let r=e.getValue(n),i=t.getValue(n);return r>i?1:r<i?-1:0},a2=(e,t,n)=>o2(e.getValue(n),t.getValue(n));function o2(e,t){return e===t?0:e>t?1:-1}function s2(e){return typeof e==`number`?isNaN(e)||e===1/0||e===-1/0?``:String(e):typeof e==`string`?e:``}function c2(e,t){let n=e.split($0).filter(Boolean),r=t.split($0).filter(Boolean);for(;n.length&&r.length;){let e=n.shift(),t=r.shift(),i=parseInt(e,10),a=parseInt(t,10),o=[i,a].sort();if(isNaN(o[0])){if(e>t)return 1;if(t>e)return-1;continue}if(isNaN(o[1]))return isNaN(i)?-1:1;if(i>a)return 1;if(a>i)return-1}return n.length-r.length}var l2={alphanumeric:e2,alphanumericCaseSensitive:t2,text:n2,textCaseSensitive:r2,datetime:i2,basic:a2},u2=[s0,L0,D0,k0,u0,S0,z0,B0,{getInitialState:e=>({sorting:[],...e}),getDefaultColumnDef:()=>({sortingFn:`auto`,sortUndefined:1}),getDefaultOptions:e=>({onSortingChange:Z1(`sorting`,e),isMultiSortEvent:e=>e.shiftKey}),createColumn:(e,t)=>{e.getAutoSortingFn=()=>{let n=t.getFilteredRowModel().flatRows.slice(10),r=!1;for(let t of n){let n=t?.getValue(e.id);if(Object.prototype.toString.call(n)===`[object Date]`)return l2.datetime;if(typeof n==`string`&&(r=!0,n.split($0).length>1))return l2.alphanumeric}return r?l2.text:l2.basic},e.getAutoSortDir=()=>typeof t.getFilteredRowModel().flatRows[0]?.getValue(e.id)==`string`?`asc`:`desc`,e.getSortingFn=()=>{if(!e)throw Error();return Q1(e.columnDef.sortingFn)?e.columnDef.sortingFn:e.columnDef.sortingFn===`auto`?e.getAutoSortingFn():t.options.sortingFns?.[e.columnDef.sortingFn]??l2[e.columnDef.sortingFn]},e.toggleSorting=(n,r)=>{let i=e.getNextSortingOrder(),a=n!=null;t.setSorting(o=>{let s=o?.find(t=>t.id===e.id),c=o?.findIndex(t=>t.id===e.id),l=[],u,d=a?n:i===`desc`;return u=o!=null&&o.length&&e.getCanMultiSort()&&r?s?`toggle`:`add`:o!=null&&o.length&&c!==o.length-1?`replace`:s?`toggle`:`replace`,u===`toggle`&&(a||i||(u=`remove`)),u===`add`?(l=[...o,{id:e.id,desc:d}],l.splice(0,l.length-(t.options.maxMultiSortColCount??2**53-1))):l=u===`toggle`?o.map(t=>t.id===e.id?{...t,desc:d}:t):u===`remove`?o.filter(t=>t.id!==e.id):[{id:e.id,desc:d}],l})},e.getFirstSortDir=()=>e.columnDef.sortDescFirst??t.options.sortDescFirst??e.getAutoSortDir()===`desc`?`desc`:`asc`,e.getNextSortingOrder=n=>{let r=e.getFirstSortDir(),i=e.getIsSorted();return i?i!==r&&(t.options.enableSortingRemoval??!0)&&(!n||(t.options.enableMultiRemove??!0))?!1:i===`desc`?`asc`:`desc`:r},e.getCanSort=()=>(e.columnDef.enableSorting??!0)&&(t.options.enableSorting??!0)&&!!e.accessorFn,e.getCanMultiSort=()=>e.columnDef.enableMultiSort??t.options.enableMultiSort??!!e.accessorFn,e.getIsSorted=()=>{let n=t.getState().sorting?.find(t=>t.id===e.id);return n?n.desc?`desc`:`asc`:!1},e.getSortIndex=()=>t.getState().sorting?.findIndex(t=>t.id===e.id)??-1,e.clearSorting=()=>{t.setSorting(t=>t!=null&&t.length?t.filter(t=>t.id!==e.id):[])},e.getToggleSortingHandler=()=>{let n=e.getCanSort();return r=>{n&&(r.persist==null||r.persist(),e.toggleSorting==null||e.toggleSorting(void 0,e.getCanMultiSort()?t.options.isMultiSortEvent==null?void 0:t.options.isMultiSortEvent(r):!1))}}},createTable:e=>{e.setSorting=t=>e.options.onSortingChange==null?void 0:e.options.onSortingChange(t),e.resetSorting=t=>{e.setSorting(t?[]:e.initialState?.sorting??[])},e.getPreSortedRowModel=()=>e.getGroupedRowModel(),e.getSortedRowModel=()=>(!e._getSortedRowModel&&e.options.getSortedRowModel&&(e._getSortedRowModel=e.options.getSortedRowModel(e)),e.options.manualSorting||!e._getSortedRowModel?e.getPreSortedRowModel():e._getSortedRowModel())}},T0,V0,G0,q0,J0,N0];function d2(e){let t=[...u2,...e._features??[]],n={_features:t},r=n._features.reduce((e,t)=>Object.assign(e,t.getDefaultOptions==null?void 0:t.getDefaultOptions(n)),{}),i=e=>n.options.mergeOptions?n.options.mergeOptions(r,e):{...r,...e},a={...e.initialState??{}};n._features.forEach(e=>{a=(e.getInitialState==null?void 0:e.getInitialState(a))??a});let o=[],s=!1,c={_features:t,options:{...r,...e},initialState:a,_queue:e=>{o.push(e),s||(s=!0,Promise.resolve().then(()=>{for(;o.length;)o.shift()();s=!1}).catch(e=>setTimeout(()=>{throw e})))},reset:()=>{n.setState(n.initialState)},setOptions:e=>{n.options=i(X1(e,n.options))},getState:()=>n.options.state,setState:e=>{n.options.onStateChange==null||n.options.onStateChange(e)},_getRowId:(e,t,r)=>(n.options.getRowId==null?void 0:n.options.getRowId(e,t,r))??`${r?[r.id,t].join(`.`):t}`,getCoreRowModel:()=>(n._getCoreRowModel||=n.options.getCoreRowModel(n),n._getCoreRowModel()),getRowModel:()=>n.getPaginationRowModel(),getRow:(e,t)=>{let r=(t?n.getPrePaginationRowModel():n.getRowModel()).rowsById[e];if(!r&&(r=n.getCoreRowModel().rowsById[e],!r))throw Error();return r},_getDefaultColumnDef:t0(()=>[n.options.defaultColumn],e=>(e??={},{header:e=>{let t=e.header.column.columnDef;return t.accessorKey?t.accessorKey:t.accessorFn?t.id:null},cell:e=>{var t;return((t=e.renderValue())==null||t.toString==null?void 0:t.toString())??null},...n._features.reduce((e,t)=>Object.assign(e,t.getDefaultColumnDef==null?void 0:t.getDefaultColumnDef()),{}),...e}),n0(e,`debugColumns`,`_getDefaultColumnDef`)),_getColumnDefs:()=>n.options.columns,getAllColumns:t0(()=>[n._getColumnDefs()],e=>{let t=function(e,r,i){return i===void 0&&(i=0),e.map(e=>{let a=i0(n,e,i,r),o=e;return a.columns=o.columns?t(o.columns,a,i+1):[],a})};return t(e)},n0(e,`debugColumns`,`getAllColumns`)),getAllFlatColumns:t0(()=>[n.getAllColumns()],e=>e.flatMap(e=>e.getFlatColumns()),n0(e,`debugColumns`,`getAllFlatColumns`)),_getAllFlatColumnsById:t0(()=>[n.getAllFlatColumns()],e=>e.reduce((e,t)=>(e[t.id]=t,e),{}),n0(e,`debugColumns`,`getAllFlatColumnsById`)),getAllLeafColumns:t0(()=>[n.getAllColumns(),n._getOrderColumnsFn()],(e,t)=>t(e.flatMap(e=>e.getLeafColumns())),n0(e,`debugColumns`,`getAllLeafColumns`)),getColumn:e=>n._getAllFlatColumnsById()[e]};Object.assign(n,c);for(let e=0;e<n._features.length;e++){let t=n._features[e];t==null||t.createTable==null||t.createTable(n)}return n}function f2(){return e=>t0(()=>[e.options.data],t=>{let n={rows:[],flatRows:[],rowsById:{}},r=function(t,i,a){i===void 0&&(i=0);let o=[];for(let c=0;c<t.length;c++){let l=l0(e,e._getRowId(t[c],c,a),t[c],c,i,void 0,a?.id);if(n.flatRows.push(l),n.rowsById[l.id]=l,o.push(l),e.options.getSubRows){var s;l.originalSubRows=e.options.getSubRows(t[c],c),(s=l.originalSubRows)!=null&&s.length&&(l.subRows=r(l.originalSubRows,i+1,l))}}return o};return n.rows=r(t),n},n0(e.options,`debugTable`,`getRowModel`,()=>e._autoResetPageIndex()))}function p2(e,t){return e?m2(e)?v.createElement(e,t):e:null}function m2(e){return h2(e)||typeof e==`function`||g2(e)}function h2(e){return typeof e==`function`&&(()=>{let t=Object.getPrototypeOf(e);return t.prototype&&t.prototype.isReactComponent})()}function g2(e){return typeof e==`object`&&typeof e.$$typeof==`symbol`&&[`react.memo`,`react.forward_ref`].includes(e.$$typeof.description)}function _2(e){let t={state:{},onStateChange:()=>{},renderFallbackValue:null,...e},[n]=v.useState(()=>({current:d2(t)})),[r,i]=v.useState(()=>n.current.initialState);return n.current.setOptions(t=>({...t,...e,state:{...r,...e.state},onStateChange:t=>{i(t),e.onStateChange==null||e.onStateChange(t)}})),n.current}var v2={"super admin":`default`,admin:`secondary`,contributor:`outline`,editor:`secondary`,viewer:`outline`};function y2({roleId:e,roleName:t,roles:n}){let r=n.find(t=>t.id===e),i=t??r?.name??e;return(0,U.jsx)(vw,{variant:v2[i.toLowerCase()]??`secondary`,children:i})}function b2({user:e,currentUserId:t,currentUserRole:n,onEdit:r,onDelete:i}){let a=e.id===t,o=(e.role_name??``).toLowerCase()===`super admin`,s=n.toLowerCase()===`super admin`;return(0,U.jsxs)(`div`,{className:`flex items-center justify-end gap-1`,children:[(0,U.jsx)(J,{size:`icon`,variant:`ghost`,className:`flex size-7 items-center justify-center rounded text-muted-foreground hover:bg-accent hover:text-accent-foreground`,disabled:o&&!a&&!s,onClick:()=>r(e),children:(0,U.jsx)(No,{className:`size-3.5`})}),(0,U.jsx)(J,{size:`icon`,variant:`ghost`,className:`flex size-8 items-center justify-center rounded text-destructive hover:bg-destructive/10 hover:text-destructive`,disabled:a||o,onClick:()=>i(e),children:(0,U.jsx)(qo,{className:`size-3.5`})})]})}var x2={email:``,password:``,roleId:``,enabled:!0};function S2(){let{user:e,updateUser:t}=ga(),{editorialMode:n}=ya(),{data:r,loading:i,refetch:a}=wa(`/cms/admin/users`),{data:o,loading:s}=wa(`/cms/admin/roles`),c=i||s,{request:l,loading:u,error:d}=Vv(),[f,p]=(0,v.useState)(!1),[m,h]=(0,v.useState)(x2),[g,_]=(0,v.useState)(null),[y,b]=(0,v.useState)({email:``,roleId:``,firstName:``,lastName:``,enabled:!0}),[x,S]=(0,v.useState)(null),C=o??[],w=e?.role?.toLowerCase()===`super admin`,T=C.filter(e=>n||![`Editor`,`Viewer`].includes(e.name)),E=w?T:T.filter(e=>e.name.toLowerCase()!==`super admin`),D=(0,v.useMemo)(()=>[{id:`name`,header:`Name`,cell:({row:e})=>{let{first_name:t,last_name:n}=e.original;return!t&&!n?(0,U.jsx)(`span`,{className:`text-muted-foreground`,children:`—`}):(0,U.jsx)(`span`,{className:`font-bold`,children:[t,n].filter(Boolean).join(` `)})}},{accessorKey:`email`,header:`Email`},{accessorKey:`role_id`,header:`Role`,cell:({row:e,getValue:t})=>(0,U.jsx)(y2,{roleId:t(),roleName:e.original.role_name,roles:C})},{accessorKey:`enabled`,header:`Enabled`,cell:({row:t,getValue:n})=>(0,U.jsx)(nj,{checked:!!(n()??!0),onCheckedChange:async e=>{try{await l(`/cms/admin/users/${t.original.id}`,`PUT`,{enabled:e}),a()}catch{}},disabled:t.original.id===e?.id||u})},{id:`actions`,header:``,cell:({row:t})=>(0,U.jsx)(b2,{user:t.original,currentUserId:e?.id??``,currentUserRole:e?.role??``,onEdit:e=>{_(e),b({email:e.email,roleId:e.role_id,firstName:e.first_name??``,lastName:e.last_name??``,enabled:e.enabled??!0})},onDelete:S})}],[C,e?.id,e?.role,l,a,u]),O=_2({data:(0,v.useMemo)(()=>[...r??[]].sort((e,t)=>{let n=[e.first_name,e.last_name].filter(Boolean).join(` `)||e.email,r=[t.first_name,t.last_name].filter(Boolean).join(` `)||t.email;return n.localeCompare(r)}),[r]),columns:D,getCoreRowModel:f2()});async function k(e){e.preventDefault();try{await l(`/cms/admin/users`,`POST`,m),p(!1),h(x2),a()}catch{}}async function A(n){n.preventDefault();try{await l(`/cms/admin/users/${g.id}`,`PUT`,y),g.id===e?.id&&t({email:y.email,firstName:y.firstName||null,lastName:y.lastName||null}),_(null),a()}catch{}}async function j(){try{await l(`/cms/admin/users/${x.id}`,`DELETE`),S(null),a()}catch{}}return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(yy,{children:(0,U.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`h1`,{className:`text-2xl font-bold -mt-2`,children:`Users`}),(0,U.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`Manage who has access to the admin panel.`})]}),(0,U.jsxs)(J,{onClick:()=>p(!0),children:[(0,U.jsx)(Po,{className:`size-4`}),`New user`]})]})}),(0,U.jsxs)(`section`,{className:`mt-24`,children:[(0,U.jsx)(`div`,{className:`rounded-md border`,children:(0,U.jsxs)(Rw,{children:[(0,U.jsx)(zw,{className:`font-bold uppercase`,children:O.getHeaderGroups().map(e=>(0,U.jsx)(Vw,{className:`hover:bg-transparent`,children:e.headers.map(e=>(0,U.jsx)(Hw,{className:`px-4 py-3 text-left font-medium text-muted-foreground`,children:p2(e.column.columnDef.header,e.getContext())},e.id))},e.id))}),(0,U.jsx)(Bw,{children:c?(0,U.jsx)(Vw,{children:(0,U.jsx)(Uw,{colSpan:D.length,className:`h-24`,children:(0,U.jsx)(by,{className:`mx-auto size-5`})})}):O.getRowModel().rows.length===0?(0,U.jsx)(Vw,{children:(0,U.jsx)(Uw,{colSpan:D.length,className:`h-24 text-center text-muted-foreground`,children:`No users found.`})}):O.getRowModel().rows.map(e=>(0,U.jsx)(Vw,{children:e.getVisibleCells().map(e=>(0,U.jsx)(Uw,{className:`px-4 py-3`,children:p2(e.column.columnDef.cell,e.getContext())},e.id))},e.id))})]})}),(0,U.jsx)(yw,{open:f,onOpenChange:p,children:(0,U.jsxs)(Cw,{className:`sm:max-w-md`,children:[(0,U.jsx)(ww,{children:(0,U.jsx)(Ew,{children:`New user`})}),(0,U.jsxs)(`form`,{id:`create-user-form`,onSubmit:k,className:`flex flex-col gap-4`,children:[(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsx)(X,{htmlFor:`c-email`,children:`Email`}),(0,U.jsx)(Hv,{id:`c-email`,type:`email`,placeholder:`user@example.com`,value:m.email,onChange:e=>h(t=>({...t,email:e.target.value})),required:!0})]}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsx)(X,{htmlFor:`c-password`,children:`Password`}),(0,U.jsx)(Hv,{id:`c-password`,type:`password`,placeholder:`Min. 8 characters`,value:m.password,onChange:e=>h(t=>({...t,password:e.target.value})),required:!0})]}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsx)(X,{htmlFor:`c-role`,children:`Role`}),(0,U.jsxs)(Ow,{value:m.roleId,onValueChange:e=>h(t=>({...t,roleId:e})),children:[(0,U.jsx)(jw,{id:`c-role`,children:(0,U.jsx)(Aw,{placeholder:`Select a role`})}),(0,U.jsx)(Pw,{children:E.map(e=>(0,U.jsx)(Iw,{value:e.id,children:e.name.charAt(0).toUpperCase()+e.name.slice(1)},e.id))})]})]}),(0,U.jsxs)(`div`,{className:`flex items-center justify-between rounded-md border p-3`,children:[(0,U.jsx)(X,{htmlFor:`c-enabled`,children:`Enabled`}),(0,U.jsx)(nj,{id:`c-enabled`,checked:m.enabled,onCheckedChange:e=>h(t=>({...t,enabled:e}))})]}),d&&(0,U.jsx)(`p`,{className:`text-sm text-destructive`,children:d})]}),(0,U.jsxs)(Tw,{children:[(0,U.jsx)(J,{variant:`outline`,type:`button`,onClick:()=>p(!1),children:`Cancel`}),(0,U.jsx)(J,{type:`submit`,form:`create-user-form`,disabled:u,children:u?`Creating…`:`Create user`})]})]})}),(0,U.jsx)(yw,{open:!!g,onOpenChange:e=>{e||_(null)},children:(0,U.jsxs)(Cw,{className:`sm:max-w-md`,children:[(0,U.jsx)(ww,{children:(0,U.jsx)(Ew,{children:`Edit user`})}),(0,U.jsxs)(`form`,{id:`edit-user-form`,onSubmit:A,className:`flex flex-col gap-4`,children:[(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsx)(X,{htmlFor:`e-email`,children:`Email`}),(0,U.jsx)(Hv,{id:`e-email`,type:`email`,value:y.email,onChange:e=>b(t=>({...t,email:e.target.value})),required:!0})]}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsx)(X,{htmlFor:`e-fname`,children:`First name`}),(0,U.jsx)(Hv,{id:`e-fname`,value:y.firstName,onChange:e=>b(t=>({...t,firstName:e.target.value}))})]}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsx)(X,{htmlFor:`e-lname`,children:`Last name`}),(0,U.jsx)(Hv,{id:`e-lname`,value:y.lastName,onChange:e=>b(t=>({...t,lastName:e.target.value}))})]}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsx)(X,{htmlFor:`e-role`,children:`Role`}),(0,U.jsxs)(Ow,{value:y.roleId,onValueChange:e=>b(t=>({...t,roleId:e})),children:[(0,U.jsx)(jw,{id:`e-role`,children:(0,U.jsx)(Aw,{placeholder:`Select a role`})}),(0,U.jsx)(Pw,{children:E.map(e=>(0,U.jsx)(Iw,{value:e.id,children:e.name.charAt(0).toUpperCase()+e.name.slice(1)},e.id))})]})]}),(0,U.jsxs)(`div`,{className:`flex items-center justify-between rounded-md border p-3`,children:[(0,U.jsx)(X,{htmlFor:`e-enabled`,children:`Enabled`}),(0,U.jsx)(nj,{id:`e-enabled`,checked:y.enabled,onCheckedChange:e=>b(t=>({...t,enabled:e}))})]}),d&&(0,U.jsx)(`p`,{className:`text-sm text-destructive`,children:d})]}),(0,U.jsxs)(Tw,{children:[(0,U.jsx)(J,{variant:`outline`,type:`button`,onClick:()=>_(null),children:`Cancel`}),(0,U.jsx)(J,{type:`submit`,form:`edit-user-form`,disabled:u,children:u?`Saving…`:`Save changes`})]})]})}),(0,U.jsx)(yw,{open:!!x,onOpenChange:e=>{e||S(null)},children:(0,U.jsxs)(Cw,{className:`sm:max-w-sm`,children:[(0,U.jsx)(ww,{children:(0,U.jsx)(Ew,{children:`Delete user`})}),(0,U.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Are you sure you want to delete`,` `,(0,U.jsx)(`span`,{className:`font-medium text-foreground`,children:x?.email}),`? This action cannot be undone.`]}),d&&(0,U.jsx)(`p`,{className:`text-sm text-destructive`,children:d}),(0,U.jsxs)(Tw,{children:[(0,U.jsx)(J,{variant:`outline`,onClick:()=>S(null),children:`Cancel`}),(0,U.jsx)(J,{variant:`destructive`,onClick:j,disabled:u,children:u?`Deleting…`:`Delete`})]})]})})]})]})}var C2=[{key:`content-types`,label:`Content Types`,actions:[`read`,`write`,`delete`]},{key:`entries`,label:`Entries`,actions:[`read`,`write`,`delete`]},{key:`media`,label:`Media`,actions:[`read`,`write`,`delete`]},{key:`settings:overview`,label:`Settings / Overview`,actions:[`read`,`write`]},{key:`settings:users`,label:`Settings / Users`,actions:[`read`,`write`,`delete`]},{key:`settings:roles`,label:`Settings / Roles`,actions:[`read`,`write`]},{key:`settings:api-tokens`,label:`Settings / API Tokens`,actions:[`read`,`write`,`delete`]},{key:`settings:webhooks`,label:`Settings / Webhooks`,actions:[`read`,`write`,`delete`]}],w2=[{key:`read`,label:`R`},{key:`write`,label:`W`},{key:`delete`,label:`D`}],T2=[`Super Admin`,`Admin`,`Editor`,`Contributor`],E2=`w-44 min-w-44 max-w-44`;function D2(e){return Object.fromEntries(e.map(e=>[e.id,new Set(e.permissions)]))}function O2(e,t){return e.includes(t)}function k2(){let{user:e}=ga(),{editorialMode:t}=ya(),{data:n,loading:r,refetch:i}=wa(`/cms/admin/roles`),{request:a,loading:o}=Vv(),[s,c]=(0,v.useState)({}),[l,u]=(0,v.useState)(new Set),[d,f]=(0,v.useState)(!1);(0,v.useEffect)(()=>{n&&c(D2(n))},[n]);function p(e,t){c(n=>{let r=new Set(n[e]);return r.has(t)?r.delete(t):r.add(t),{...n,[e]:r}}),u(t=>new Set(t).add(e))}async function m(e){await a(`/cms/admin/roles/${e.id}`,`PUT`,{permissions:Array.from(s[e.id]??[])}),u(t=>{let n=new Set(t);return n.delete(e.id),n})}async function h(){await a(`/cms/admin/roles/reset`,`POST`),f(!1),u(new Set),i()}let g=e?.role===`Super Admin`,_=(n??[]).filter(e=>e.name!==`Super Admin`).filter(e=>e.name!==`Viewer`).filter(e=>t||![`Editor`,`Viewer`].includes(e.name)).sort((e,t)=>{let n=T2.indexOf(e.name),r=T2.indexOf(t.name),i=n===-1?2**53-1:n,a=r===-1?2**53-1:r;return i===a?e.name.localeCompare(t.name):i-a}),y=(n??[]).find(e=>e.name===`Super Admin`);return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(yy,{children:(0,U.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`h1`,{className:`text-2xl font-bold -mt-2`,children:`Roles`}),(0,U.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`Configure what each role can do across the CMS.`})]}),g&&(0,U.jsxs)(J,{variant:`outline`,onClick:()=>f(!0),children:[(0,U.jsx)(Io,{className:`size-4`}),`Reset defaults`]})]})}),(0,U.jsxs)(`section`,{className:`mt-24`,children:[(0,U.jsx)(`div`,{className:`rounded-md border`,children:(0,U.jsxs)(Rw,{children:[(0,U.jsxs)(zw,{children:[(0,U.jsxs)(Vw,{className:`hover:bg-transparent`,children:[(0,U.jsx)(Hw,{className:`w-40`,rowSpan:2}),y&&(0,U.jsx)(Hw,{colSpan:3,className:`border-l text-center ${E2}`,children:y.name}),_.map(e=>(0,U.jsx)(Hw,{colSpan:3,className:`border-l ${E2}`,children:(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,U.jsx)(`span`,{children:e.name}),(0,U.jsxs)(J,{size:`sm`,variant:l.has(e.id)?`default`:`ghost`,className:`h-6 px-2 text-xs`,disabled:!l.has(e.id)||o,onClick:()=>m(e),children:[(0,U.jsx)(Lo,{className:`size-3`}),`Save`]})]})},e.id))]}),(0,U.jsxs)(Vw,{className:`hover:bg-transparent`,children:[y&&w2.map((e,t)=>(0,U.jsx)(Hw,{className:`w-12 text-center font-normal ${t===0?`border-l`:``}`,children:e.label},e.key)),_.map(e=>w2.map((t,n)=>(0,U.jsx)(Hw,{className:`w-12 text-center font-normal ${n===0?`border-l`:``}`,children:t.label},`${e.id}-${t.key}`)))]})]}),(0,U.jsx)(Bw,{children:r?(0,U.jsx)(Vw,{children:(0,U.jsx)(Uw,{colSpan:99,className:`h-24`,children:(0,U.jsx)(by,{className:`mx-auto size-5`})})}):C2.map(({key:e,label:t,actions:n})=>(0,U.jsxs)(Vw,{children:[(0,U.jsx)(Uw,{className:`font-medium`,children:t}),y&&w2.map((e,t)=>(0,U.jsx)(Uw,{className:`text-center ${t===0?`border-l`:``}`,children:O2(n,e.key)?(0,U.jsx)(EO,{checked:!0,disabled:!0}):(0,U.jsx)(`span`,{className:`text-muted-foreground`,children:`—`})},e.key)),_.map(t=>w2.map((r,i)=>{let a=O2(n,r.key),o=`${e}:${r.key}`;return(0,U.jsx)(Uw,{className:`text-center ${i===0?`border-l`:``}`,children:a?(0,U.jsx)(EO,{checked:s[t.id]?.has(o)??!1,onCheckedChange:()=>p(t.id,o)}):(0,U.jsx)(`span`,{className:`text-muted-foreground`,children:`—`})},`${t.id}-${r.key}`)}))]},e))})]})}),t&&(0,U.jsxs)(`div`,{className:`mt-3 rounded-md border bg-muted/30 p-3`,children:[(0,U.jsx)(`p`,{className:`text-sm font-medium`,children:`Viewer`}),(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Read-only role intended for external reviewers (for example, clients validating content before approval).`})]}),t&&(0,U.jsx)(`p`,{className:`mt-3 text-sm text-muted-foreground`,children:`Note: Editor and Contributor can share the same base permissions, but their effective scope is different in the content layer. Contributors are restricted to their own entries for certain actions, while Editors can operate on entries more broadly depending on the configured rules.`}),(0,U.jsx)(yw,{open:d,onOpenChange:f,children:(0,U.jsxs)(Cw,{className:`sm:max-w-sm`,children:[(0,U.jsx)(ww,{children:(0,U.jsx)(Ew,{children:`Reset to defaults`})}),(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`This will restore all role permissions to their original configuration. Any custom changes will be lost.`}),(0,U.jsxs)(Tw,{children:[(0,U.jsx)(J,{variant:`outline`,onClick:()=>f(!1),children:`Cancel`}),(0,U.jsx)(J,{variant:`destructive`,onClick:h,disabled:o,children:o?`Resetting…`:`Reset`})]})]})})]})]})}var A2={"full-access":`default`,"read-only":`secondary`},j2={"full-access":`Full access`,"read-only":`Read only`};function M2({value:e}){let[t,n]=(0,v.useState)(!1);function r(){navigator.clipboard.writeText(e),n(!0),setTimeout(()=>n(!1),2e3)}return(0,U.jsx)(J,{type:`button`,size:`icon`,variant:`outline`,className:`shrink-0`,onClick:r,children:t?(0,U.jsx)(za,{className:`size-4 text-green-500`}):(0,U.jsx)(Za,{className:`size-4`})})}var N2={name:``,accessType:``};function P2(){let{user:e}=ga(),{data:t,loading:n,refetch:r}=wa(`/cms/admin/api-tokens`),{request:i,loading:a,error:o}=Vv(),s=e?.permissions??[],c=s.includes(`*`)||s.includes(`settings:api-tokens:write`),l=s.includes(`*`)||s.includes(`settings:api-tokens:delete`),[u,d]=(0,v.useState)(!1),[f,p]=(0,v.useState)(N2),[m,h]=(0,v.useState)(null),[g,_]=(0,v.useState)(null),y=[{accessorKey:`name`,header:`Name`},{accessorKey:`access_type`,header:`Access`,cell:({getValue:e})=>{let t=e();return(0,U.jsx)(vw,{variant:A2[t]??`secondary`,children:j2[t]??t})}},{accessorKey:`created_at`,header:`Created`,cell:({getValue:e})=>new Date(e()).toLocaleDateString(`en-US`,{year:`numeric`,month:`short`,day:`numeric`})},{id:`actions`,header:``,cell:({row:e})=>l?(0,U.jsx)(J,{size:`icon`,variant:`ghost`,className:`flex size-8 items-center justify-center rounded text-destructive hover:bg-destructive/10 hover:text-destructive`,onClick:()=>_(e.original),children:(0,U.jsx)(qo,{className:`size-3.5`})}):null}],b=_2({data:t??[],columns:y,getCoreRowModel:f2()});async function x(e){e.preventDefault();try{h(await i(`/cms/admin/api-tokens`,`POST`,{name:f.name,accessType:f.accessType})),r()}catch{}}function S(){d(!1),h(null),p(N2)}async function C(){try{await i(`/cms/admin/api-tokens/${g.id}`,`DELETE`),_(null),r()}catch{}}return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(yy,{children:(0,U.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`h1`,{className:`text-2xl font-bold -mt-2`,children:`API Tokens`}),(0,U.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`Manage tokens for consuming the public API.`})]}),(0,U.jsxs)(J,{onClick:()=>d(!0),disabled:!c,children:[(0,U.jsx)(Po,{className:`size-4`}),`New token`]})]})}),(0,U.jsxs)(`section`,{className:`mt-24`,children:[(0,U.jsx)(`div`,{className:`rounded-md border`,children:(0,U.jsxs)(Rw,{children:[(0,U.jsx)(zw,{className:`font-bold uppercase`,children:b.getHeaderGroups().map(e=>(0,U.jsx)(Vw,{className:`hover:bg-transparent`,children:e.headers.map(e=>(0,U.jsx)(Hw,{className:`px-4 py-3 text-left font-medium text-muted-foreground`,children:p2(e.column.columnDef.header,e.getContext())},e.id))},e.id))}),(0,U.jsx)(Bw,{children:n?(0,U.jsx)(Vw,{children:(0,U.jsx)(Uw,{colSpan:y.length,className:`h-24`,children:(0,U.jsx)(by,{className:`mx-auto size-5`})})}):b.getRowModel().rows.length===0?(0,U.jsx)(Vw,{children:(0,U.jsx)(Uw,{colSpan:y.length,className:`h-24 text-center text-muted-foreground`,children:`No tokens yet.`})}):b.getRowModel().rows.map(e=>(0,U.jsx)(Vw,{children:e.getVisibleCells().map(e=>(0,U.jsx)(Uw,{className:`px-4 py-3`,children:p2(e.column.columnDef.cell,e.getContext())},e.id))},e.id))})]})}),(0,U.jsx)(yw,{open:u,onOpenChange:e=>{e||S()},children:(0,U.jsx)(Cw,{className:`sm:max-w-md`,children:m?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(ww,{children:(0,U.jsx)(Ew,{children:`Token generated`})}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,U.jsx)(`div`,{className:`rounded-md border border-amber-200 bg-amber-50 px-4 py-3 text-sm text-amber-800 dark:border-amber-900 dark:bg-amber-950 dark:text-amber-200`,children:`Make sure to copy your token now. You won't be able to see it again.`}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsx)(X,{children:`Token`}),(0,U.jsxs)(`div`,{className:`flex gap-2`,children:[(0,U.jsx)(Hv,{readOnly:!0,value:m.token,className:`font-mono text-xs`}),(0,U.jsx)(M2,{value:m.token})]})]})]}),(0,U.jsx)(Tw,{children:(0,U.jsx)(J,{onClick:S,children:`Done`})})]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(ww,{children:(0,U.jsx)(Ew,{children:`New API token`})}),(0,U.jsxs)(`form`,{id:`create-token-form`,onSubmit:x,className:`flex flex-col gap-4`,children:[(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsx)(X,{htmlFor:`token-name`,children:`Name`}),(0,U.jsx)(Hv,{id:`token-name`,placeholder:`e.g. Production frontend`,value:f.name,onChange:e=>p(t=>({...t,name:e.target.value})),required:!0})]}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsx)(X,{htmlFor:`token-access`,children:`Access type`}),(0,U.jsxs)(Ow,{value:f.accessType,onValueChange:e=>p(t=>({...t,accessType:e})),children:[(0,U.jsx)(jw,{id:`token-access`,children:(0,U.jsx)(Aw,{placeholder:`Select access type`})}),(0,U.jsxs)(Pw,{children:[(0,U.jsx)(Iw,{value:`read-only`,children:`Read only`}),(0,U.jsx)(Iw,{value:`full-access`,children:`Full access`})]})]})]}),o&&(0,U.jsx)(`p`,{className:`text-sm text-destructive`,children:o})]}),(0,U.jsxs)(Tw,{children:[(0,U.jsx)(J,{variant:`outline`,type:`button`,onClick:S,children:`Cancel`}),(0,U.jsx)(J,{type:`submit`,form:`create-token-form`,disabled:a||!f.accessType||!c,children:a?`Generating…`:`Generate token`})]})]})})}),(0,U.jsx)(yw,{open:!!g,onOpenChange:e=>{e||_(null)},children:(0,U.jsxs)(Cw,{className:`sm:max-w-sm`,children:[(0,U.jsx)(ww,{children:(0,U.jsx)(Ew,{children:`Revoke token`})}),(0,U.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Are you sure you want to revoke`,` `,(0,U.jsx)(`span`,{className:`font-medium text-foreground`,children:g?.name}),`? Any frontend using it will immediately lose access.`]}),(0,U.jsxs)(Tw,{children:[(0,U.jsx)(J,{variant:`outline`,onClick:()=>_(null),children:`Cancel`}),(0,U.jsx)(J,{variant:`destructive`,onClick:C,disabled:a||!l,children:a?`Revoking…`:`Revoke`})]})]})})]})]})}var F2=[{value:`entry.published`,label:`Entry published`},{value:`entry.unpublished`,label:`Entry unpublished`},{value:`entry.created`,label:`Entry created`},{value:`entry.updated`,label:`Entry updated`},{value:`entry.deleted`,label:`Entry deleted`}],I2={name:``,url:``,events:[]};function L2(){let{user:e}=ga(),{data:t,loading:n,refetch:r}=wa(`/cms/admin/webhooks`),{request:i,loading:a,error:o}=Vv(),s=e?.permissions??[],c=s.includes(`*`)||s.includes(`settings:webhooks:write`),l=s.includes(`*`)||s.includes(`settings:webhooks:delete`),[u,d]=(0,v.useState)(!1),[f,p]=(0,v.useState)(I2),[m,h]=(0,v.useState)(null),g=[{accessorKey:`name`,header:`Name`},{accessorKey:`url`,header:`URL`,cell:({getValue:e})=>(0,U.jsx)(`span`,{className:`font-mono text-xs text-muted-foreground truncate max-w-xs block`,children:e()})},{accessorKey:`events`,header:`Events`,cell:({getValue:e})=>(0,U.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:e().map(e=>(0,U.jsx)(vw,{variant:`secondary`,className:`text-xs font-mono`,children:e},e))})},{accessorKey:`created_at`,header:`Created`,cell:({getValue:e})=>new Date(e()).toLocaleDateString(`en-US`,{year:`numeric`,month:`short`,day:`numeric`})},{id:`actions`,header:``,cell:({row:e})=>l?(0,U.jsx)(J,{size:`icon`,variant:`ghost`,className:`size-8 text-destructive hover:text-destructive`,onClick:()=>h(e.original),children:(0,U.jsx)(qo,{className:`size-3.5`})}):null}],_=_2({data:t??[],columns:g,getCoreRowModel:f2()});function y(e){p(t=>({...t,events:t.events.includes(e)?t.events.filter(t=>t!==e):[...t.events,e]}))}async function b(e){e.preventDefault();try{await i(`/cms/admin/webhooks`,`POST`,f),d(!1),p(I2),r()}catch{}}async function x(){try{await i(`/cms/admin/webhooks/${m.id}`,`DELETE`),h(null),r()}catch{}}return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(yy,{children:(0,U.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`h1`,{className:`text-2xl font-bold -mt-2`,children:`Webhooks`}),(0,U.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`Notify external services when content events occur.`})]}),(0,U.jsxs)(J,{onClick:()=>d(!0),disabled:!c,children:[(0,U.jsx)(Po,{className:`size-4`}),`New webhook`]})]})}),(0,U.jsxs)(`section`,{className:`mt-24`,children:[(0,U.jsx)(`div`,{className:`rounded-md border`,children:(0,U.jsxs)(Rw,{children:[(0,U.jsx)(zw,{className:`font-bold uppercase`,children:_.getHeaderGroups().map(e=>(0,U.jsx)(Vw,{className:`hover:bg-transparent`,children:e.headers.map(e=>(0,U.jsx)(Hw,{className:`px-4 py-3 text-left font-medium text-muted-foreground`,children:p2(e.column.columnDef.header,e.getContext())},e.id))},e.id))}),(0,U.jsx)(Bw,{children:n?(0,U.jsx)(Vw,{children:(0,U.jsx)(Uw,{colSpan:g.length,className:`h-24`,children:(0,U.jsx)(by,{className:`mx-auto size-5`})})}):_.getRowModel().rows.length===0?(0,U.jsx)(Vw,{children:(0,U.jsx)(Uw,{colSpan:g.length,className:`h-24 text-center text-muted-foreground`,children:`No webhooks yet.`})}):_.getRowModel().rows.map(e=>(0,U.jsx)(Vw,{children:e.getVisibleCells().map(e=>(0,U.jsx)(Uw,{className:`px-4 py-3`,children:p2(e.column.columnDef.cell,e.getContext())},e.id))},e.id))})]})}),(0,U.jsx)(yw,{open:u,onOpenChange:e=>{e||(d(!1),p(I2))},children:(0,U.jsxs)(Cw,{className:`sm:max-w-md`,children:[(0,U.jsx)(ww,{children:(0,U.jsx)(Ew,{children:`New webhook`})}),(0,U.jsxs)(`form`,{id:`create-webhook-form`,onSubmit:b,className:`flex flex-col gap-4`,children:[(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsx)(X,{htmlFor:`webhook-name`,children:`Name`}),(0,U.jsx)(Hv,{id:`webhook-name`,placeholder:`e.g. Dokploy deploy`,value:f.name,onChange:e=>p(t=>({...t,name:e.target.value})),required:!0})]}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,U.jsx)(X,{htmlFor:`webhook-url`,children:`URL`}),(0,U.jsx)(Hv,{id:`webhook-url`,type:`url`,placeholder:`https://...`,value:f.url,onChange:e=>p(t=>({...t,url:e.target.value})),required:!0})]}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,U.jsx)(X,{children:`Events`}),F2.map(({value:e,label:t})=>(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(EO,{id:`event-${e}`,checked:f.events.includes(e),onCheckedChange:()=>y(e)}),(0,U.jsxs)(`label`,{htmlFor:`event-${e}`,className:`text-sm cursor-pointer`,children:[t,(0,U.jsx)(`span`,{className:`ml-2 font-mono text-xs text-muted-foreground`,children:e})]})]},e))]}),o&&(0,U.jsx)(`p`,{className:`text-sm text-destructive`,children:o})]}),(0,U.jsxs)(Tw,{children:[(0,U.jsx)(J,{variant:`outline`,type:`button`,onClick:()=>{d(!1),p(I2)},children:`Cancel`}),(0,U.jsx)(J,{type:`submit`,form:`create-webhook-form`,disabled:a||f.events.length===0||!c,children:a?`Creating…`:`Create webhook`})]})]})}),(0,U.jsx)(yw,{open:!!m,onOpenChange:e=>{e||h(null)},children:(0,U.jsxs)(Cw,{className:`sm:max-w-sm`,children:[(0,U.jsx)(ww,{children:(0,U.jsx)(Ew,{children:`Delete webhook`})}),(0,U.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Are you sure you want to delete`,` `,(0,U.jsx)(`span`,{className:`font-medium text-foreground`,children:m?.name}),`? It will stop receiving events immediately.`]}),(0,U.jsxs)(Tw,{children:[(0,U.jsx)(J,{variant:`outline`,onClick:()=>h(null),children:`Cancel`}),(0,U.jsx)(J,{variant:`destructive`,onClick:x,disabled:a||!l,children:a?`Deleting…`:`Delete`})]})]})})]})]})}function R2({...e}){return(0,U.jsx)(Vy,{"data-slot":`collapsible`,...e})}function z2({...e}){return(0,U.jsx)(Ry,{"data-slot":`collapsible-content`,...e})}function B2(){let{user:e,updateUser:t}=ga(),{loading:n,error:r,request:i}=Vv(),{request:a}=Vv(),o=(0,v.useRef)(null),[s,c]=(0,v.useState)(!1),[l,u]=(0,v.useState)(!1),[d,f]=(0,v.useState)(null),[p,m]=(0,v.useState)(!1),[h,g]=(0,v.useState)(e?.firstName??``),[_,y]=(0,v.useState)(e?.lastName??``),[b,x]=(0,v.useState)(e?.jobTitle??``),[S,C]=(0,v.useState)(e?.organization??``),[w,T]=(0,v.useState)(e?.country??``);function E(){p&&(g(e?.firstName??``),y(e?.lastName??``),x(e?.jobTitle??``),C(e?.organization??``),T(e?.country??``)),m(!p)}async function D(e){let n=e.target.files?.[0];if(n){c(!0),f(null);try{t({avatarUrl:await ZZ(n)})}catch(e){f(e instanceof Error?e.message:`Upload failed.`)}finally{c(!1),o.current&&(o.current.value=``)}}}async function O(){u(!0),f(null);try{await a(`/cms/admin/users/me/avatar`,`DELETE`),t({avatarUrl:null})}catch(e){f(e instanceof Error?e.message:`Delete failed.`)}finally{u(!1)}}async function k(e){e.preventDefault();try{let e=await i(`/cms/admin/users/me`,`PATCH`,{firstName:h,lastName:_,jobTitle:b,organization:S,country:w});t({firstName:e.first_name,lastName:e.last_name,jobTitle:e.job_title,organization:e.organization,country:e.country}),m(!1)}catch{}}return(0,U.jsx)(R2,{open:p,onOpenChange:m,children:(0,U.jsxs)(d1,{children:[(0,U.jsxs)(f1,{children:[(0,U.jsx)(p1,{className:`uppercase`,children:`Account`}),(0,U.jsx)(m1,{children:(0,U.jsx)(J,{variant:`ghost`,size:`icon`,onClick:E,children:p?(0,U.jsx)(ns,{className:`size-4`}):(0,U.jsx)(No,{className:`size-4`})})})]}),(0,U.jsxs)(h1,{children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-4 -mt-4`,children:[(0,U.jsxs)(`div`,{className:`group relative shrink-0`,children:[(0,U.jsxs)(`button`,{type:`button`,className:`block`,onClick:()=>o.current?.click(),disabled:s||l,title:`Change avatar`,children:[(0,U.jsx)(El,{avatarUrl:e?.avatarUrl,firstName:e?.firstName,lastName:e?.lastName,email:e?.email,className:`size-20`,fallbackClassName:`text-xl`}),(0,U.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center rounded-full bg-black/40 opacity-0 transition-opacity group-hover:opacity-100`,children:s||l?(0,U.jsx)(`div`,{className:`size-4 animate-spin rounded-full border-2 border-white border-t-transparent`}):(0,U.jsx)(Ra,{className:`size-5 text-white`})})]}),e?.avatarUrl&&!s&&!l&&(0,U.jsx)(`button`,{type:`button`,onClick:O,title:`Remove avatar`,className:`absolute -top-1 -right-1 flex size-5 items-center justify-center rounded-full bg-destructive text-destructive-foreground opacity-0 transition-opacity group-hover:opacity-100`,children:(0,U.jsx)(qo,{className:`size-3`})})]}),(0,U.jsx)(`input`,{ref:o,type:`file`,accept:`image/*`,className:`hidden`,onChange:D}),(0,U.jsxs)(`div`,{children:[d&&(0,U.jsx)(`p`,{className:`text-xs text-destructive mb-1`,children:d}),(0,U.jsx)(`p`,{className:`font-bold text-xl`,children:e?.firstName||e?.lastName?`${e.firstName??``} ${e.lastName??``}`.trim():e?.email}),(e?.jobTitle||e?.organization)&&(0,U.jsx)(`p`,{className:`text-sm`,children:[e.jobTitle,e.organization].filter(Boolean).join(` · `)}),(0,U.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:e?.email}),(0,U.jsxs)(`div`,{className:`flex flex-wrap gap-2 mt-2`,children:[(0,U.jsx)(vw,{className:`capitalize`,children:e?.role}),e?.country&&(0,U.jsx)(vw,{variant:`outline`,children:e.country})]})]})]}),(0,U.jsx)(z2,{children:(0,U.jsxs)(`form`,{onSubmit:k,className:`space-y-4 mt-8`,children:[(0,U.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,U.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,U.jsx)(X,{htmlFor:`firstName`,children:`First name`}),(0,U.jsx)(Hv,{id:`firstName`,value:h,onChange:e=>g(e.target.value)})]}),(0,U.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,U.jsx)(X,{htmlFor:`lastName`,children:`Last name`}),(0,U.jsx)(Hv,{id:`lastName`,value:_,onChange:e=>y(e.target.value)})]}),(0,U.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,U.jsx)(X,{htmlFor:`jobTitle`,children:`Job title`}),(0,U.jsx)(Hv,{id:`jobTitle`,value:b,onChange:e=>x(e.target.value)})]}),(0,U.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,U.jsx)(X,{htmlFor:`organization`,children:`Organization`}),(0,U.jsx)(Hv,{id:`organization`,value:S,onChange:e=>C(e.target.value)})]}),(0,U.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,U.jsx)(X,{htmlFor:`country`,children:`Country`}),(0,U.jsx)(Hv,{id:`country`,value:w,onChange:e=>T(e.target.value)})]})]}),r&&(0,U.jsx)(`p`,{className:`text-destructive text-sm`,children:r}),(0,U.jsx)(J,{type:`submit`,disabled:n,children:n?`Saving…`:`Save changes`})]})})]})]})})}var V2=Object.defineProperty,H2=Object.getOwnPropertySymbols,U2=Object.prototype.hasOwnProperty,W2=Object.prototype.propertyIsEnumerable,G2=(e,t,n)=>t in e?V2(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,K2=(e,t)=>{for(var n in t||={})U2.call(t,n)&&G2(e,n,t[n]);if(H2)for(var n of H2(t))W2.call(t,n)&&G2(e,n,t[n]);return e},q2=(e,t)=>{var n={};for(var r in e)U2.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&H2)for(var r of H2(e))t.indexOf(r)<0&&W2.call(e,r)&&(n[r]=e[r]);return n},J2;(e=>{let t=class t{constructor(e,n,r,a){if(this.version=e,this.errorCorrectionLevel=n,this.modules=[],this.isFunction=[],e<t.MIN_VERSION||e>t.MAX_VERSION)throw RangeError(`Version value out of range`);if(a<-1||a>7)throw RangeError(`Mask value out of range`);this.size=e*4+17;let o=[];for(let e=0;e<this.size;e++)o.push(!1);for(let e=0;e<this.size;e++)this.modules.push(o.slice()),this.isFunction.push(o.slice());this.drawFunctionPatterns();let s=this.addEccAndInterleave(r);if(this.drawCodewords(s),a==-1){let e=1e9;for(let t=0;t<8;t++){this.applyMask(t),this.drawFormatBits(t);let n=this.getPenaltyScore();n<e&&(a=t,e=n),this.applyMask(t)}}i(0<=a&&a<=7),this.mask=a,this.applyMask(a),this.drawFormatBits(a),this.isFunction=[]}static encodeText(n,r){let i=e.QrSegment.makeSegments(n);return t.encodeSegments(i,r)}static encodeBinary(n,r){let i=e.QrSegment.makeBytes(n);return t.encodeSegments([i],r)}static encodeSegments(e,r,a=1,s=40,c=-1,l=!0){if(!(t.MIN_VERSION<=a&&a<=s&&s<=t.MAX_VERSION)||c<-1||c>7)throw RangeError(`Invalid value`);let u,d;for(u=a;;u++){let n=t.getNumDataCodewords(u,r)*8,i=o.getTotalBits(e,u);if(i<=n){d=i;break}if(u>=s)throw RangeError(`Data too long`)}for(let e of[t.Ecc.MEDIUM,t.Ecc.QUARTILE,t.Ecc.HIGH])l&&d<=t.getNumDataCodewords(u,e)*8&&(r=e);let f=[];for(let t of e){n(t.mode.modeBits,4,f),n(t.numChars,t.mode.numCharCountBits(u),f);for(let e of t.getData())f.push(e)}i(f.length==d);let p=t.getNumDataCodewords(u,r)*8;i(f.length<=p),n(0,Math.min(4,p-f.length),f),n(0,(8-f.length%8)%8,f),i(f.length%8==0);for(let e=236;f.length<p;e^=253)n(e,8,f);let m=[];for(;m.length*8<f.length;)m.push(0);return f.forEach((e,t)=>m[t>>>3]|=e<<7-(t&7)),new t(u,r,m,c)}getModule(e,t){return 0<=e&&e<this.size&&0<=t&&t<this.size&&this.modules[t][e]}getModules(){return this.modules}drawFunctionPatterns(){for(let e=0;e<this.size;e++)this.setFunctionModule(6,e,e%2==0),this.setFunctionModule(e,6,e%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);let e=this.getAlignmentPatternPositions(),t=e.length;for(let n=0;n<t;n++)for(let r=0;r<t;r++)n==0&&r==0||n==0&&r==t-1||n==t-1&&r==0||this.drawAlignmentPattern(e[n],e[r]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(e){let t=this.errorCorrectionLevel.formatBits<<3|e,n=t;for(let e=0;e<10;e++)n=n<<1^(n>>>9)*1335;let a=(t<<10|n)^21522;i(a>>>15==0);for(let e=0;e<=5;e++)this.setFunctionModule(8,e,r(a,e));this.setFunctionModule(8,7,r(a,6)),this.setFunctionModule(8,8,r(a,7)),this.setFunctionModule(7,8,r(a,8));for(let e=9;e<15;e++)this.setFunctionModule(14-e,8,r(a,e));for(let e=0;e<8;e++)this.setFunctionModule(this.size-1-e,8,r(a,e));for(let e=8;e<15;e++)this.setFunctionModule(8,this.size-15+e,r(a,e));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let e=this.version;for(let t=0;t<12;t++)e=e<<1^(e>>>11)*7973;let t=this.version<<12|e;i(t>>>18==0);for(let e=0;e<18;e++){let n=r(t,e),i=this.size-11+e%3,a=Math.floor(e/3);this.setFunctionModule(i,a,n),this.setFunctionModule(a,i,n)}}drawFinderPattern(e,t){for(let n=-4;n<=4;n++)for(let r=-4;r<=4;r++){let i=Math.max(Math.abs(r),Math.abs(n)),a=e+r,o=t+n;0<=a&&a<this.size&&0<=o&&o<this.size&&this.setFunctionModule(a,o,i!=2&&i!=4)}}drawAlignmentPattern(e,t){for(let n=-2;n<=2;n++)for(let r=-2;r<=2;r++)this.setFunctionModule(e+r,t+n,Math.max(Math.abs(r),Math.abs(n))!=1)}setFunctionModule(e,t,n){this.modules[t][e]=n,this.isFunction[t][e]=!0}addEccAndInterleave(e){let n=this.version,r=this.errorCorrectionLevel;if(e.length!=t.getNumDataCodewords(n,r))throw RangeError(`Invalid argument`);let a=t.NUM_ERROR_CORRECTION_BLOCKS[r.ordinal][n],o=t.ECC_CODEWORDS_PER_BLOCK[r.ordinal][n],s=Math.floor(t.getNumRawDataModules(n)/8),c=a-s%a,l=Math.floor(s/a),u=[],d=t.reedSolomonComputeDivisor(o);for(let n=0,r=0;n<a;n++){let i=e.slice(r,r+l-o+(n<c?0:1));r+=i.length;let a=t.reedSolomonComputeRemainder(i,d);n<c&&i.push(0),u.push(i.concat(a))}let f=[];for(let e=0;e<u[0].length;e++)u.forEach((t,n)=>{(e!=l-o||n>=c)&&f.push(t[e])});return i(f.length==s),f}drawCodewords(e){if(e.length!=Math.floor(t.getNumRawDataModules(this.version)/8))throw RangeError(`Invalid argument`);let n=0;for(let t=this.size-1;t>=1;t-=2){t==6&&(t=5);for(let i=0;i<this.size;i++)for(let a=0;a<2;a++){let o=t-a,s=t+1&2?i:this.size-1-i;!this.isFunction[s][o]&&n<e.length*8&&(this.modules[s][o]=r(e[n>>>3],7-(n&7)),n++)}}i(n==e.length*8)}applyMask(e){if(e<0||e>7)throw RangeError(`Mask value out of range`);for(let t=0;t<this.size;t++)for(let n=0;n<this.size;n++){let r;switch(e){case 0:r=(n+t)%2==0;break;case 1:r=t%2==0;break;case 2:r=n%3==0;break;case 3:r=(n+t)%3==0;break;case 4:r=(Math.floor(n/3)+Math.floor(t/2))%2==0;break;case 5:r=n*t%2+n*t%3==0;break;case 6:r=(n*t%2+n*t%3)%2==0;break;case 7:r=((n+t)%2+n*t%3)%2==0;break;default:throw Error(`Unreachable`)}!this.isFunction[t][n]&&r&&(this.modules[t][n]=!this.modules[t][n])}}getPenaltyScore(){let e=0;for(let n=0;n<this.size;n++){let r=!1,i=0,a=[0,0,0,0,0,0,0];for(let o=0;o<this.size;o++)this.modules[n][o]==r?(i++,i==5?e+=t.PENALTY_N1:i>5&&e++):(this.finderPenaltyAddHistory(i,a),r||(e+=this.finderPenaltyCountPatterns(a)*t.PENALTY_N3),r=this.modules[n][o],i=1);e+=this.finderPenaltyTerminateAndCount(r,i,a)*t.PENALTY_N3}for(let n=0;n<this.size;n++){let r=!1,i=0,a=[0,0,0,0,0,0,0];for(let o=0;o<this.size;o++)this.modules[o][n]==r?(i++,i==5?e+=t.PENALTY_N1:i>5&&e++):(this.finderPenaltyAddHistory(i,a),r||(e+=this.finderPenaltyCountPatterns(a)*t.PENALTY_N3),r=this.modules[o][n],i=1);e+=this.finderPenaltyTerminateAndCount(r,i,a)*t.PENALTY_N3}for(let n=0;n<this.size-1;n++)for(let r=0;r<this.size-1;r++){let i=this.modules[n][r];i==this.modules[n][r+1]&&i==this.modules[n+1][r]&&i==this.modules[n+1][r+1]&&(e+=t.PENALTY_N2)}let n=0;for(let e of this.modules)n=e.reduce((e,t)=>e+ +!!t,n);let r=this.size*this.size,a=Math.ceil(Math.abs(n*20-r*10)/r)-1;return i(0<=a&&a<=9),e+=a*t.PENALTY_N4,i(0<=e&&e<=2568888),e}getAlignmentPatternPositions(){if(this.version==1)return[];{let e=Math.floor(this.version/7)+2,t=this.version==32?26:Math.ceil((this.version*4+4)/(e*2-2))*2,n=[6];for(let r=this.size-7;n.length<e;r-=t)n.splice(1,0,r);return n}}static getNumRawDataModules(e){if(e<t.MIN_VERSION||e>t.MAX_VERSION)throw RangeError(`Version number out of range`);let n=(16*e+128)*e+64;if(e>=2){let t=Math.floor(e/7)+2;n-=(25*t-10)*t-55,e>=7&&(n-=36)}return i(208<=n&&n<=29648),n}static getNumDataCodewords(e,n){return Math.floor(t.getNumRawDataModules(e)/8)-t.ECC_CODEWORDS_PER_BLOCK[n.ordinal][e]*t.NUM_ERROR_CORRECTION_BLOCKS[n.ordinal][e]}static reedSolomonComputeDivisor(e){if(e<1||e>255)throw RangeError(`Degree out of range`);let n=[];for(let t=0;t<e-1;t++)n.push(0);n.push(1);let r=1;for(let i=0;i<e;i++){for(let e=0;e<n.length;e++)n[e]=t.reedSolomonMultiply(n[e],r),e+1<n.length&&(n[e]^=n[e+1]);r=t.reedSolomonMultiply(r,2)}return n}static reedSolomonComputeRemainder(e,n){let r=n.map(e=>0);for(let i of e){let e=i^r.shift();r.push(0),n.forEach((n,i)=>r[i]^=t.reedSolomonMultiply(n,e))}return r}static reedSolomonMultiply(e,t){if(e>>>8||t>>>8)throw RangeError(`Byte out of range`);let n=0;for(let r=7;r>=0;r--)n=n<<1^(n>>>7)*285,n^=(t>>>r&1)*e;return i(n>>>8==0),n}finderPenaltyCountPatterns(e){let t=e[1];i(t<=this.size*3);let n=t>0&&e[2]==t&&e[3]==t*3&&e[4]==t&&e[5]==t;return(n&&e[0]>=t*4&&e[6]>=t?1:0)+(n&&e[6]>=t*4&&e[0]>=t?1:0)}finderPenaltyTerminateAndCount(e,t,n){return e&&(this.finderPenaltyAddHistory(t,n),t=0),t+=this.size,this.finderPenaltyAddHistory(t,n),this.finderPenaltyCountPatterns(n)}finderPenaltyAddHistory(e,t){t[0]==0&&(e+=this.size),t.pop(),t.unshift(e)}};t.MIN_VERSION=1,t.MAX_VERSION=40,t.PENALTY_N1=3,t.PENALTY_N2=3,t.PENALTY_N3=40,t.PENALTY_N4=10,t.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],t.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],e.QrCode=t;function n(e,t,n){if(t<0||t>31||e>>>t)throw RangeError(`Value out of range`);for(let r=t-1;r>=0;r--)n.push(e>>>r&1)}function r(e,t){return(e>>>t&1)!=0}function i(e){if(!e)throw Error(`Assertion error`)}let a=class e{constructor(e,t,n){if(this.mode=e,this.numChars=t,this.bitData=n,t<0)throw RangeError(`Invalid argument`);this.bitData=n.slice()}static makeBytes(t){let r=[];for(let e of t)n(e,8,r);return new e(e.Mode.BYTE,t.length,r)}static makeNumeric(t){if(!e.isNumeric(t))throw RangeError(`String contains non-numeric characters`);let r=[];for(let e=0;e<t.length;){let i=Math.min(t.length-e,3);n(parseInt(t.substring(e,e+i),10),i*3+1,r),e+=i}return new e(e.Mode.NUMERIC,t.length,r)}static makeAlphanumeric(t){if(!e.isAlphanumeric(t))throw RangeError(`String contains unencodable characters in alphanumeric mode`);let r=[],i;for(i=0;i+2<=t.length;i+=2){let a=e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(i))*45;a+=e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(i+1)),n(a,11,r)}return i<t.length&&n(e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(i)),6,r),new e(e.Mode.ALPHANUMERIC,t.length,r)}static makeSegments(t){return t==``?[]:e.isNumeric(t)?[e.makeNumeric(t)]:e.isAlphanumeric(t)?[e.makeAlphanumeric(t)]:[e.makeBytes(e.toUtf8ByteArray(t))]}static makeEci(t){let r=[];if(t<0)throw RangeError(`ECI assignment value out of range`);if(t<128)n(t,8,r);else if(t<16384)n(2,2,r),n(t,14,r);else if(t<1e6)n(6,3,r),n(t,21,r);else throw RangeError(`ECI assignment value out of range`);return new e(e.Mode.ECI,0,r)}static isNumeric(t){return e.NUMERIC_REGEX.test(t)}static isAlphanumeric(t){return e.ALPHANUMERIC_REGEX.test(t)}getData(){return this.bitData.slice()}static getTotalBits(e,t){let n=0;for(let r of e){let e=r.mode.numCharCountBits(t);if(r.numChars>=1<<e)return 1/0;n+=4+e+r.bitData.length}return n}static toUtf8ByteArray(e){e=encodeURI(e);let t=[];for(let n=0;n<e.length;n++)e.charAt(n)==`%`?(t.push(parseInt(e.substring(n+1,n+3),16)),n+=2):t.push(e.charCodeAt(n));return t}};a.NUMERIC_REGEX=/^[0-9]*$/,a.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,a.ALPHANUMERIC_CHARSET=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:`;let o=a;e.QrSegment=a})(J2||={}),(e=>{(e=>{let t=class{constructor(e,t){this.ordinal=e,this.formatBits=t}};t.LOW=new t(0,1),t.MEDIUM=new t(1,0),t.QUARTILE=new t(2,3),t.HIGH=new t(3,2),e.Ecc=t})(e.QrCode||={})})(J2||={}),(e=>{(e=>{let t=class{constructor(e,t){this.modeBits=e,this.numBitsCharCount=t}numCharCountBits(e){return this.numBitsCharCount[Math.floor((e+7)/17)]}};t.NUMERIC=new t(1,[10,12,14]),t.ALPHANUMERIC=new t(2,[9,11,13]),t.BYTE=new t(4,[8,16,16]),t.KANJI=new t(8,[8,10,12]),t.ECI=new t(7,[0,0,0]),e.Mode=t})(e.QrSegment||={})})(J2||={});var Y2=J2,X2={L:Y2.QrCode.Ecc.LOW,M:Y2.QrCode.Ecc.MEDIUM,Q:Y2.QrCode.Ecc.QUARTILE,H:Y2.QrCode.Ecc.HIGH},Z2=128,Q2=`L`,$2=`#FFFFFF`,e4=`#000000`,t4=!1,n4=1,r4=4,i4=0,a4=.1;function o4(e,t=0){let n=[];return e.forEach(function(e,r){let i=null;e.forEach(function(a,o){if(!a&&i!==null){n.push(`M${i+t} ${r+t}h${o-i}v1H${i+t}z`),i=null;return}if(o===e.length-1){if(!a)return;i===null?n.push(`M${o+t},${r+t} h1v1H${o+t}z`):n.push(`M${i+t},${r+t} h${o+1-i}v1H${i+t}z`);return}a&&i===null&&(i=o)})}),n.join(``)}function s4(e,t){return e.slice().map((e,n)=>n<t.y||n>=t.y+t.h?e:e.map((e,n)=>n<t.x||n>=t.x+t.w?e:!1))}function c4(e,t,n,r){if(r==null)return null;let i=e.length+n*2,a=Math.floor(t*a4),o=i/t,s=(r.width||a)*o,c=(r.height||a)*o,l=r.x==null?e.length/2-s/2:r.x*o,u=r.y==null?e.length/2-c/2:r.y*o,d=r.opacity==null?1:r.opacity,f=null;if(r.excavate){let e=Math.floor(l),t=Math.floor(u);f={x:e,y:t,w:Math.ceil(s+l-e),h:Math.ceil(c+u-t)}}let p=r.crossOrigin;return{x:l,y:u,h:c,w:s,excavation:f,opacity:d,crossOrigin:p}}function l4(e,t){return t==null?e?r4:i4:Math.max(Math.floor(t),0)}function u4({value:e,level:t,minVersion:n,includeMargin:r,marginSize:i,imageSettings:a,size:o,boostLevel:s}){let c=v.useMemo(()=>{let r=(Array.isArray(e)?e:[e]).reduce((e,t)=>(e.push(...Y2.QrSegment.makeSegments(t)),e),[]);return Y2.QrCode.encodeSegments(r,X2[t],n,void 0,void 0,s)},[e,t,n,s]),{cells:l,margin:u,numCells:d,calculatedImageSettings:f}=v.useMemo(()=>{let e=c.getModules(),t=l4(r,i);return{cells:e,margin:t,numCells:e.length+t*2,calculatedImageSettings:c4(e,o,t,a)}},[c,o,a,r,i]);return{qrcode:c,margin:u,cells:l,numCells:d,calculatedImageSettings:f}}var d4=function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0}(),f4=v.forwardRef(function(e,t){let n=e,{value:r,size:i=Z2,level:a=Q2,bgColor:o=$2,fgColor:s=e4,includeMargin:c=t4,minVersion:l=n4,boostLevel:u,marginSize:d,imageSettings:f}=n,p=q2(n,[`value`,`size`,`level`,`bgColor`,`fgColor`,`includeMargin`,`minVersion`,`boostLevel`,`marginSize`,`imageSettings`]),{style:m}=p,h=q2(p,[`style`]),g=f?.src,_=v.useRef(null),y=v.useRef(null),b=v.useCallback(e=>{_.current=e,typeof t==`function`?t(e):t&&(t.current=e)},[t]),[x,S]=v.useState(!1),{margin:C,cells:w,numCells:T,calculatedImageSettings:E}=u4({value:r,level:a,minVersion:l,boostLevel:u,includeMargin:c,marginSize:d,imageSettings:f,size:i});v.useEffect(()=>{if(_.current!=null){let e=_.current,t=e.getContext(`2d`);if(!t)return;let n=w,r=y.current,a=E!=null&&r!==null&&r.complete&&r.naturalHeight!==0&&r.naturalWidth!==0;a&&E.excavation!=null&&(n=s4(w,E.excavation));let c=window.devicePixelRatio||1;e.height=e.width=i*c;let l=i/T*c;t.scale(l,l),t.fillStyle=o,t.fillRect(0,0,T,T),t.fillStyle=s,d4?t.fill(new Path2D(o4(n,C))):w.forEach(function(e,n){e.forEach(function(e,r){e&&t.fillRect(r+C,n+C,1,1)})}),E&&(t.globalAlpha=E.opacity),a&&t.drawImage(r,E.x+C,E.y+C,E.w,E.h)}}),v.useEffect(()=>{S(!1)},[g]);let D=K2({height:i,width:i},m),O=null;return g!=null&&(O=v.createElement(`img`,{src:g,key:g,style:{display:`none`},onLoad:()=>{S(!0)},ref:y,crossOrigin:E?.crossOrigin})),v.createElement(v.Fragment,null,v.createElement(`canvas`,K2({style:D,height:i,width:i,ref:b,role:`img`},h)),O)});f4.displayName=`QRCodeCanvas`;var p4=v.forwardRef(function(e,t){let n=e,{value:r,size:i=Z2,level:a=Q2,bgColor:o=$2,fgColor:s=e4,includeMargin:c=t4,minVersion:l=n4,boostLevel:u,title:d,marginSize:f,imageSettings:p}=n,m=q2(n,[`value`,`size`,`level`,`bgColor`,`fgColor`,`includeMargin`,`minVersion`,`boostLevel`,`title`,`marginSize`,`imageSettings`]),{margin:h,cells:g,numCells:_,calculatedImageSettings:y}=u4({value:r,level:a,minVersion:l,boostLevel:u,includeMargin:c,marginSize:f,imageSettings:p,size:i}),b=g,x=null;p!=null&&y!=null&&(y.excavation!=null&&(b=s4(g,y.excavation)),x=v.createElement(`image`,{href:p.src,height:y.h,width:y.w,x:y.x+h,y:y.y+h,preserveAspectRatio:`none`,opacity:y.opacity,crossOrigin:y.crossOrigin}));let S=o4(b,h);return v.createElement(`svg`,K2({height:i,width:i,viewBox:`0 0 ${_} ${_}`,ref:t,role:`img`},m),!!d&&v.createElement(`title`,null,d),v.createElement(`path`,{fill:o,d:`M0,0 h${_}v${_}H0z`,shapeRendering:`crispEdges`}),v.createElement(`path`,{fill:s,d:S,shapeRendering:`crispEdges`}),x)});p4.displayName=`QRCodeSVG`;function m4(){let{user:e,updateUser:t,logout:n}=ga(),{loading:r,error:i,request:a}=Vv(),{loading:o,error:s,request:c}=Vv(),[l,u]=(0,v.useState)(``),[d,f]=(0,v.useState)(``),[p,m]=(0,v.useState)(``),[h,g]=(0,v.useState)(``),[_,y]=(0,v.useState)(null),[b,x]=(0,v.useState)(!1),[S,C]=(0,v.useState)(null),[w,T]=(0,v.useState)(``),[E,D]=(0,v.useState)(``),[O,k]=(0,v.useState)(!1),[A,j]=(0,v.useState)([]),[M,N]=(0,v.useState)(!1);(0,v.useEffect)(()=>{typeof e?.twoFactorEnabled==`boolean`&&x(e.twoFactorEnabled)},[e?.twoFactorEnabled]);function P(){u(``),f(``),m(``),g(``),y(null),C(null),T(``)}function F(){C(null),T(``),D(``),k(!1),N(!1)}async function I(e){if(e.preventDefault(),y(null),p!==h){y(`New passwords do not match`);return}try{await a(`/cms/admin/users/me/password`,`PATCH`,{currentPassword:d,newPassword:p}),P()}catch{}}async function L(){C(await c(`/cms/admin/users/me/2fa/setup`,`POST`))}async function R(){let e=await c(`/cms/admin/users/me/2fa/verify`,`POST`,{code:w});x(!0),t({twoFactorEnabled:!0}),C(null),T(``),k(!0),j(e.backupCodes??[])}async function ee(){await c(`/cms/admin/users/me/2fa/disable`,`POST`,{code:w,password:E}),x(!1),t({twoFactorEnabled:!1}),T(``),D(``),j([]),N(!1)}return(0,U.jsxs)(d1,{children:[(0,U.jsxs)(f1,{children:[(0,U.jsx)(p1,{className:`uppercase`,children:`Security`}),(0,U.jsx)(m1,{})]}),(0,U.jsx)(h1,{className:`space-y-6`,children:(0,U.jsxs)(QA,{value:l,children:[(0,U.jsxs)($A,{children:[(0,U.jsx)(ej,{value:`password`,onClick:()=>u(e=>e===`password`?``:`password`),children:`Password`}),(0,U.jsx)(ej,{value:`two-factor`,onClick:()=>u(e=>e===`two-factor`?``:`two-factor`),children:`2FA`})]}),(0,U.jsx)(tj,{value:`password`,className:`mt-4`,children:(0,U.jsxs)(`div`,{className:`space-y-4 rounded-md border border-border p-4`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Update your account password.`}),(0,U.jsx)(J,{variant:`ghost`,size:`icon`,onClick:P,children:(0,U.jsx)(ns,{className:`size-4`})})]}),(0,U.jsxs)(`form`,{onSubmit:I,className:`space-y-4`,children:[(0,U.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,U.jsx)(X,{htmlFor:`current`,children:`Current password`}),(0,U.jsx)(Hv,{id:`current`,type:`password`,value:d,onChange:e=>f(e.target.value),required:!0})]}),(0,U.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,U.jsx)(X,{htmlFor:`new`,children:`New password`}),(0,U.jsx)(Hv,{id:`new`,type:`password`,value:p,onChange:e=>m(e.target.value),required:!0,minLength:8})]}),(0,U.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,U.jsx)(X,{htmlFor:`confirm`,children:`Confirm new password`}),(0,U.jsx)(Hv,{id:`confirm`,type:`password`,value:h,onChange:e=>g(e.target.value),required:!0})]}),(_??i)&&(0,U.jsx)(`p`,{className:`text-destructive text-sm`,children:_??i}),(0,U.jsx)(J,{type:`submit`,disabled:r,children:r?`Saving…`:`Update password`})]})]})}),(0,U.jsx)(tj,{value:`two-factor`,className:`mt-4`,children:(0,U.jsxs)(`div`,{className:`space-y-4`,children:[!b&&!S&&(0,U.jsx)(J,{variant:`secondary`,onClick:L,disabled:o,children:`Enable 2FA`}),S&&!b&&(0,U.jsxs)(`div`,{className:`space-y-3 rounded-md border border-border p-4`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Scan this QR code with your authenticator app and enter the 6-digit code.`}),(0,U.jsx)(J,{variant:`ghost`,size:`icon`,onClick:F,children:(0,U.jsx)(ns,{className:`size-4`})})]}),(0,U.jsx)(`div`,{className:`inline-flex rounded-md bg-white p-2`,children:(0,U.jsx)(p4,{value:S.otpauthUri,size:176})}),(0,U.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Manual code: `,S.secret]}),(0,U.jsx)(my,{maxLength:6,value:w,onChange:T,containerClassName:`w-fit`,className:`w-fit`,children:(0,U.jsxs)(hy,{className:`w-fit`,children:[(0,U.jsx)(gy,{index:0}),(0,U.jsx)(gy,{index:1}),(0,U.jsx)(gy,{index:2}),(0,U.jsx)(gy,{index:3}),(0,U.jsx)(gy,{index:4}),(0,U.jsx)(gy,{index:5})]})}),(0,U.jsx)(J,{onClick:R,disabled:o||w.length!==6,children:`Confirm and enable 2FA`}),s&&(0,U.jsx)(`p`,{className:`text-sm text-destructive`,children:s})]}),b&&(0,U.jsxs)(`div`,{className:`space-y-3 rounded-md border border-border p-4`,children:[O&&(0,U.jsxs)(`div`,{className:`space-y-3 rounded-md border border-emerald-500/40 bg-emerald-500/10 p-3`,children:[(0,U.jsx)(`p`,{className:`text-sm font-medium text-emerald-300`,children:`2FA is now enabled.`}),(0,U.jsx)(`p`,{className:`text-xs text-emerald-200/90`,children:`For security, re-login is recommended now. This prevents accidental changes and confirms your new security state.`}),(0,U.jsx)(J,{variant:`default`,onClick:()=>{n()},children:`Re-login now`}),A.length>0&&(0,U.jsxs)(`div`,{className:`space-y-2 rounded-md border border-emerald-400/30 bg-background/40 p-3`,children:[(0,U.jsx)(`p`,{className:`text-xs font-medium text-emerald-200`,children:`Save these backup codes now. Each code can be used once if you lose access to your authenticator.`}),(0,U.jsx)(`div`,{className:`grid grid-cols-2 gap-2`,children:A.map(e=>(0,U.jsx)(`code`,{className:`rounded bg-black/20 px-2 py-1 text-xs text-emerald-100`,children:e},e))}),(0,U.jsx)(J,{variant:`outline`,onClick:async()=>{try{await navigator.clipboard.writeText(A.join(`
223
+ `)),N(!0),setTimeout(()=>N(!1),2e3)}catch{N(!1)}},children:M?`Copied`:`Copy backup codes`})]})]}),(0,U.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,U.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Enter a verification code from your authenticator app to disable 2FA.`}),(0,U.jsx)(J,{variant:`ghost`,size:`icon`,onClick:()=>{T(``),D(``)},children:(0,U.jsx)(ns,{className:`size-4`})})]}),(0,U.jsx)(my,{maxLength:6,value:w,onChange:T,containerClassName:`w-fit`,className:`w-fit`,children:(0,U.jsxs)(hy,{className:`w-fit`,children:[(0,U.jsx)(gy,{index:0}),(0,U.jsx)(gy,{index:1}),(0,U.jsx)(gy,{index:2}),(0,U.jsx)(gy,{index:3}),(0,U.jsx)(gy,{index:4}),(0,U.jsx)(gy,{index:5})]})}),(0,U.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,U.jsx)(X,{htmlFor:`disable-2fa-password`,children:`Current password`}),(0,U.jsx)(Hv,{id:`disable-2fa-password`,type:`password`,value:E,onChange:e=>D(e.target.value),required:!0})]}),(0,U.jsx)(J,{variant:`destructive`,onClick:ee,disabled:O||o||w.length!==6||!E,children:`Disable 2FA`}),s&&(0,U.jsx)(`p`,{className:`text-sm text-destructive`,children:s})]})]})})]})})]})}function h4(){return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(yy,{children:(0,U.jsx)(`h1`,{className:`text-2xl font-bold -mt-2`,children:`Profile`})}),(0,U.jsx)(`section`,{className:`mt-18`,children:(0,U.jsx)(`div`,{className:`grid grid-cols-2 gap-4 items-start`,children:(0,U.jsxs)(`div`,{className:`space-y-4`,children:[(0,U.jsx)(B2,{}),(0,U.jsx)(m4,{})]})})})]})}var g4=[`Super Admin`,`Admin`,`Editor`,`Contributor`],_4=Vi([{path:`/login`,element:(0,U.jsx)(vy,{})},{element:(0,U.jsx)(Ca,{children:(0,U.jsx)(Bv,{})}),children:[{index:!0,element:(0,U.jsx)(Ca,{roles:g4,redirectTo:`/content`,children:(0,U.jsx)(Kw,{})})},{path:`content`,element:(0,U.jsx)(HO,{}),children:[{index:!0,element:(0,U.jsx)(UO,{})},{path:`:slug`,element:(0,U.jsx)(vk,{})},{path:`:slug/new`,element:(0,U.jsx)(Ca,{permission:`entries:write`,redirectTo:`/content`,children:(0,U.jsx)(I$,{})})},{path:`:slug/:id`,element:(0,U.jsx)(I$,{})}]},{path:`media`,element:(0,U.jsx)(Ca,{roles:g4,redirectTo:`/content`,children:(0,U.jsx)(e1,{})})},{path:`content-types`,element:(0,U.jsx)(Ca,{permission:`content-types:write`,roles:g4,redirectTo:`/content`,children:(0,U.jsx)(Yw,{})}),children:[{index:!0,element:(0,U.jsx)(rT,{})},{path:`new`,element:(0,U.jsx)(BO,{})},{path:`:slug`,element:(0,U.jsx)(BO,{})}]},{path:`settings`,element:(0,U.jsx)(Ca,{permission:`settings:overview:read`,roles:g4,redirectTo:`/content`,children:(0,U.jsx)(i1,{})}),children:[{index:!0,element:(0,U.jsx)(Zr,{to:`overview`,replace:!0})},{path:`overview`,element:(0,U.jsx)(Ca,{permission:`settings:overview:read`,children:(0,U.jsx)(Y1,{})})},{path:`users`,element:(0,U.jsx)(Ca,{permission:`settings:users:read`,children:(0,U.jsx)(S2,{})})},{path:`roles`,element:(0,U.jsx)(Ca,{permission:`settings:roles:read`,children:(0,U.jsx)(k2,{})})},{path:`api-tokens`,element:(0,U.jsx)(Ca,{permission:`settings:api-tokens:read`,children:(0,U.jsx)(P2,{})})},{path:`webhooks`,element:(0,U.jsx)(Ca,{permission:`settings:webhooks:read`,children:(0,U.jsx)(L2,{})})}]},{path:`profile`,element:(0,U.jsx)(h4,{})}]},{path:`*`,element:(0,U.jsx)(Zr,{to:`/`,replace:!0})}],{basename:`/admin/`.replace(/\/$/,``)||`/`});function v4(){return(0,U.jsx)(ha,{children:(0,U.jsx)(va,{children:(0,U.jsx)(xa,{children:(0,U.jsx)(da,{router:_4})})})})}(0,_.createRoot)(document.getElementById(`root`)).render((0,U.jsx)(v.StrictMode,{children:(0,U.jsxs)(E,{attribute:`class`,defaultTheme:`dark`,enableSystem:!0,disableTransitionOnChange:!0,children:[(0,U.jsx)(v4,{}),(0,U.jsx)(({...e})=>{let{theme:t=`system`}=T();return(0,U.jsx)(G1,{theme:t,className:`toaster group`,icons:{success:(0,U.jsx)(Ga,{className:`size-4`}),info:(0,U.jsx)(vo,{className:`size-4`}),warning:(0,U.jsx)(Jo,{className:`size-4`}),error:(0,U.jsx)(Mo,{className:`size-4`}),loading:(0,U.jsx)(ko,{className:`size-4 animate-spin`})},style:{"--normal-bg":`var(--popover)`,"--normal-text":`var(--popover-foreground)`,"--normal-border":`var(--border)`,"--border-radius":`var(--radius)`},...e})},{})]})}));