diff --git a/client/dist/js/bundle.js b/client/dist/js/bundle.js index a5818ca9..b42ae0de 100644 --- a/client/dist/js/bundle.js +++ b/client/dist/js/bundle.js @@ -1 +1 @@ -!function(){"use strict";var e={733:function(e,t,n){n.r(t),n.d(t,{AutoScrollActivator:function(){return xe},DndContext:function(){return Ge},DragOverlay:function(){return bt},KeyboardCode:function(){return ie},KeyboardSensor:function(){return ce},MeasuringFrequency:function(){return De},MeasuringStrategy:function(){return ke},MouseSensor:function(){return me},PointerSensor:function(){return ve},TouchSensor:function(){return we},TraversalOrder:function(){return Ce},applyModifiers:function(){return Ye},closestCenter:function(){return S},closestCorners:function(){return _},defaultAnnouncements:function(){return p},defaultCoordinates:function(){return y},defaultDropAnimation:function(){return pt},defaultDropAnimationSideEffects:function(){return ft},defaultScreenReaderInstructions:function(){return f},getClientRect:function(){return j},getFirstCollision:function(){return k},getScrollableAncestors:function(){return q},pointerWithin:function(){return L},rectIntersection:function(){return M},useDndContext:function(){return nt},useDndMonitor:function(){return d},useDraggable:function(){return tt},useDroppable:function(){return it},useSensor:function(){return b},useSensors:function(){return m}});var r=n(594),o=n.n(r),i=ReactDom,a=n(979);const l={display:"none"};function s(e){let{id:t,value:n}=e;return o().createElement("div",{id:t,style:l},n)}function u(e){let{id:t,announcement:n,ariaLiveType:r="assertive"}=e;return o().createElement("div",{id:t,style:{position:"fixed",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"},role:"status","aria-live":r,"aria-atomic":!0},n)}const c=(0,r.createContext)(null);function d(e){const t=(0,r.useContext)(c);(0,r.useEffect)((()=>{if(!t)throw new Error("useDndMonitor must be used within a children of ");return t(e)}),[e,t])}const f={draggable:"\n To pick up a draggable item, press the space bar.\n While dragging, use the arrow keys to move the item.\n Press space again to drop the item in its new position, or press escape to cancel.\n "},p={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 g(e){let{announcements:t=p,container:n,hiddenTextDescribedById:l,screenReaderInstructions:c=f}=e;const{announce:g,announcement:v}=function(){const[e,t]=(0,r.useState)("");return{announce:(0,r.useCallback)((e=>{null!=e&&t(e)}),[]),announcement:e}}(),h=(0,a.useUniqueId)("DndLiveRegion"),[b,m]=(0,r.useState)(!1);if((0,r.useEffect)((()=>{m(!0)}),[]),d((0,r.useMemo)((()=>({onDragStart(e){let{active:n}=e;g(t.onDragStart({active:n}))},onDragMove(e){let{active:n,over:r}=e;t.onDragMove&&g(t.onDragMove({active:n,over:r}))},onDragOver(e){let{active:n,over:r}=e;g(t.onDragOver({active:n,over:r}))},onDragEnd(e){let{active:n,over:r}=e;g(t.onDragEnd({active:n,over:r}))},onDragCancel(e){let{active:n,over:r}=e;g(t.onDragCancel({active:n,over:r}))}})),[g,t])),!b)return null;const y=o().createElement(o().Fragment,null,o().createElement(s,{id:l,value:c.draggable}),o().createElement(u,{id:h,announcement:v}));return n?(0,i.createPortal)(y,n):y}var v;function h(){}function b(e,t){return(0,r.useMemo)((()=>({sensor:e,options:null!=t?t:{}})),[e,t])}function m(){for(var e=arguments.length,t=new Array(e),n=0;n[...t].filter((e=>null!=e))),[...t])}!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"}(v||(v={}));const y=Object.freeze({x:0,y:0});function w(e,t){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}function x(e,t){const n=(0,a.getEventCoordinates)(e);if(!n)return"0 0";return(n.x-t.left)/t.width*100+"% "+(n.y-t.top)/t.height*100+"%"}function C(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return n-r}function E(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return r-n}function R(e){let{left:t,top:n,height:r,width:o}=e;return[{x:t,y:n},{x:t+o,y:n},{x:t,y:n+r},{x:t+o,y:n+r}]}function k(e,t){if(!e||0===e.length)return null;const[n]=e;return t?n[t]:n}function D(e,t,n){return void 0===t&&(t=e.left),void 0===n&&(n=e.top),{x:t+.5*e.width,y:n+.5*e.height}}const S=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const o=D(t,t.left,t.top),i=[];for(const e of r){const{id:t}=e,r=n.get(t);if(r){const n=w(D(r),o);i.push({id:t,data:{droppableContainer:e,value:n}})}}return i.sort(C)},_=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const o=R(t),i=[];for(const e of r){const{id:t}=e,r=n.get(t);if(r){const n=R(r),a=o.reduce(((e,t,r)=>e+w(n[r],t)),0),l=Number((a/4).toFixed(4));i.push({id:t,data:{droppableContainer:e,value:l}})}}return i.sort(C)};function O(e,t){const n=Math.max(t.top,e.top),r=Math.max(t.left,e.left),o=Math.min(t.left+t.width,e.left+e.width),i=Math.min(t.top+t.height,e.top+e.height),a=o-r,l=i-n;if(r{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const o=[];for(const e of r){const{id:r}=e,i=n.get(r);if(i){const n=O(i,t);n>0&&o.push({id:r,data:{droppableContainer:e,value:n}})}}return o.sort(E)};function I(e,t){const{top:n,left:r,bottom:o,right:i}=t;return n<=e.y&&e.y<=o&&r<=e.x&&e.x<=i}const L=e=>{let{droppableContainers:t,droppableRects:n,pointerCoordinates:r}=e;if(!r)return[];const o=[];for(const e of t){const{id:t}=e,i=n.get(t);if(i&&I(r,i)){const n=R(i).reduce(((e,t)=>e+w(r,t)),0),a=Number((n/4).toFixed(4));o.push({id:t,data:{droppableContainer:e,value:a}})}}return o.sort(C)};function N(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:y}function T(e){return function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o({...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})}}const F=T(1);function A(e){if(e.startsWith("matrix3d(")){const t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}if(e.startsWith("matrix(")){const t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}const P={ignoreTransform:!1};function j(e,t){void 0===t&&(t=P);let n=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:t,transformOrigin:r}=(0,a.getWindow)(e).getComputedStyle(e);t&&(n=function(e,t,n){const r=A(t);if(!r)return e;const{scaleX:o,scaleY:i,x:a,y:l}=r,s=e.left-a-(1-o)*parseFloat(n),u=e.top-l-(1-i)*parseFloat(n.slice(n.indexOf(" ")+1)),c=o?e.width/o:e.width,d=i?e.height/i:e.height;return{width:c,height:d,top:u,right:s+c,bottom:u+d,left:s}}(n,t,r))}const{top:r,left:o,width:i,height:l,bottom:s,right:u}=n;return{top:r,left:o,width:i,height:l,bottom:s,right:u}}function K(e){return j(e,{ignoreTransform:!0})}function q(e,t){const n=[];return e?function r(o){if(null!=t&&n.length>=t)return n;if(!o)return n;if((0,a.isDocument)(o)&&null!=o.scrollingElement&&!n.includes(o.scrollingElement))return n.push(o.scrollingElement),n;if(!(0,a.isHTMLElement)(o)||(0,a.isSVGElement)(o))return n;if(n.includes(o))return n;const i=(0,a.getWindow)(e).getComputedStyle(o);return o!==e&&function(e,t){void 0===t&&(t=(0,a.getWindow)(e).getComputedStyle(e));const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some((e=>{const r=t[e];return"string"==typeof r&&n.test(r)}))}(o,i)&&n.push(o),function(e,t){return void 0===t&&(t=(0,a.getWindow)(e).getComputedStyle(e)),"fixed"===t.position}(o,i)?n:r(o.parentNode)}(e):n}function B(e){const[t]=q(e,1);return null!=t?t:null}function W(e){return a.canUseDOM&&e?(0,a.isWindow)(e)?e:(0,a.isNode)(e)?(0,a.isDocument)(e)||e===(0,a.getOwnerDocument)(e).scrollingElement?window:(0,a.isHTMLElement)(e)?e:null:null:null}function U(e){return(0,a.isWindow)(e)?e.scrollX:e.scrollLeft}function z(e){return(0,a.isWindow)(e)?e.scrollY:e.scrollTop}function V(e){return{x:U(e),y:z(e)}}var H;function X(e){return!(!a.canUseDOM||!e)&&e===document.scrollingElement}function Y(e){const t={x:0,y:0},n=X(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}}!function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"}(H||(H={}));const $={x:.2,y:.2};function J(e,t,n,r,o){let{top:i,left:a,right:l,bottom:s}=n;void 0===r&&(r=10),void 0===o&&(o=$);const{isTop:u,isBottom:c,isLeft:d,isRight:f}=Y(e),p={x:0,y:0},g={x:0,y:0},v=t.height*o.y,h=t.width*o.x;return!u&&i<=t.top+v?(p.y=H.Backward,g.y=r*Math.abs((t.top+v-i)/v)):!c&&s>=t.bottom-v&&(p.y=H.Forward,g.y=r*Math.abs((t.bottom-v-s)/v)),!f&&l>=t.right-h?(p.x=H.Forward,g.x=r*Math.abs((t.right-h-l)/h)):!d&&a<=t.left+h&&(p.x=H.Backward,g.x=r*Math.abs((t.left+h-a)/h)),{direction:p,speed:g}}function G(e){if(e===document.scrollingElement){const{innerWidth:e,innerHeight:t}=window;return{top:0,left:0,right:e,bottom:t,width:e,height:t}}const{top:t,left:n,right:r,bottom:o}=e.getBoundingClientRect();return{top:t,left:n,right:r,bottom:o,width:e.clientWidth,height:e.clientHeight}}function Q(e){return e.reduce(((e,t)=>(0,a.add)(e,V(t))),y)}function Z(e,t){if(void 0===t&&(t=j),!e)return;const{top:n,left:r,bottom:o,right:i}=t(e);B(e)&&(o<=0||i<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const ee=[["x",["left","right"],function(e){return e.reduce(((e,t)=>e+U(t)),0)}],["y",["top","bottom"],function(e){return e.reduce(((e,t)=>e+z(t)),0)}]];class te{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;const n=q(t),r=Q(n);this.rect={...e},this.width=e.width,this.height=e.height;for(const[e,t,o]of ee)for(const i of t)Object.defineProperty(this,i,{get:()=>{const t=o(n),a=r[e]-t;return this.rect[i]+a},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class ne{constructor(e){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach((e=>{var t;return null==(t=this.target)?void 0:t.removeEventListener(...e)}))},this.target=e}add(e,t,n){var r;null==(r=this.target)||r.addEventListener(e,t,n),this.listeners.push([e,t,n])}}function re(e,t){const n=Math.abs(e.x),r=Math.abs(e.y);return"number"==typeof t?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}var oe,ie;function ae(e){e.preventDefault()}function le(e){e.stopPropagation()}!function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"}(oe||(oe={})),function(e){e.Space="Space",e.Down="ArrowDown",e.Right="ArrowRight",e.Left="ArrowLeft",e.Up="ArrowUp",e.Esc="Escape",e.Enter="Enter"}(ie||(ie={}));const se={start:[ie.Space,ie.Enter],cancel:[ie.Esc],end:[ie.Space,ie.Enter]},ue=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case ie.Right:return{...n,x:n.x+25};case ie.Left:return{...n,x:n.x-25};case ie.Down:return{...n,y:n.y+25};case ie.Up:return{...n,y:n.y-25}}};class ce{constructor(e){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=e;const{event:{target:t}}=e;this.props=e,this.listeners=new ne((0,a.getOwnerDocument)(t)),this.windowListeners=new ne((0,a.getWindow)(t)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(oe.Resize,this.handleCancel),this.windowListeners.add(oe.VisibilityChange,this.handleCancel),setTimeout((()=>this.listeners.add(oe.Keydown,this.handleKeyDown)))}handleStart(){const{activeNode:e,onStart:t}=this.props,n=e.node.current;n&&Z(n),t(y)}handleKeyDown(e){if((0,a.isKeyboardEvent)(e)){const{active:t,context:n,options:r}=this.props,{keyboardCodes:o=se,coordinateGetter:i=ue,scrollBehavior:l="smooth"}=r,{code:s}=e;if(o.end.includes(s))return void this.handleEnd(e);if(o.cancel.includes(s))return void this.handleCancel(e);const{collisionRect:u}=n.current,c=u?{x:u.left,y:u.top}:y;this.referenceCoordinates||(this.referenceCoordinates=c);const d=i(e,{active:t,context:n.current,currentCoordinates:c});if(d){const t=(0,a.subtract)(d,c),r={x:0,y:0},{scrollableAncestors:o}=n.current;for(const n of o){const o=e.code,{isTop:i,isRight:a,isLeft:s,isBottom:u,maxScroll:c,minScroll:f}=Y(n),p=G(n),g={x:Math.min(o===ie.Right?p.right-p.width/2:p.right,Math.max(o===ie.Right?p.left:p.left+p.width/2,d.x)),y:Math.min(o===ie.Down?p.bottom-p.height/2:p.bottom,Math.max(o===ie.Down?p.top:p.top+p.height/2,d.y))},v=o===ie.Right&&!a||o===ie.Left&&!s,h=o===ie.Down&&!u||o===ie.Up&&!i;if(v&&g.x!==d.x){const e=n.scrollLeft+t.x,i=o===ie.Right&&e<=c.x||o===ie.Left&&e>=f.x;if(i&&!t.y)return void n.scrollTo({left:e,behavior:l});r.x=i?n.scrollLeft-e:o===ie.Right?n.scrollLeft-c.x:n.scrollLeft-f.x,r.x&&n.scrollBy({left:-r.x,behavior:l});break}if(h&&g.y!==d.y){const e=n.scrollTop+t.y,i=o===ie.Down&&e<=c.y||o===ie.Up&&e>=f.y;if(i&&!t.x)return void n.scrollTo({top:e,behavior:l});r.y=i?n.scrollTop-e:o===ie.Down?n.scrollTop-c.y:n.scrollTop-f.y,r.y&&n.scrollBy({top:-r.y,behavior:l});break}}this.handleMove(e,(0,a.add)((0,a.subtract)(d,this.referenceCoordinates),r))}}}handleMove(e,t){const{onMove:n}=this.props;e.preventDefault(),n(t)}handleEnd(e){const{onEnd:t}=this.props;e.preventDefault(),this.detach(),t()}handleCancel(e){const{onCancel:t}=this.props;e.preventDefault(),this.detach(),t()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}function de(e){return Boolean(e&&"distance"in e)}function fe(e){return Boolean(e&&"delay"in e)}ce.activators=[{eventName:"onKeyDown",handler:(e,t,n)=>{let{keyboardCodes:r=se,onActivation:o}=t,{active:i}=n;const{code:a}=e.nativeEvent;if(r.start.includes(a)){const t=i.activatorNode.current;return(!t||e.target===t)&&(e.preventDefault(),null==o||o({event:e.nativeEvent}),!0)}return!1}}];class pe{constructor(e,t,n){var r;void 0===n&&(n=function(e){const{EventTarget:t}=(0,a.getWindow)(e);return e instanceof t?e:(0,a.getOwnerDocument)(e)}(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;const{event:o}=e,{target:i}=o;this.props=e,this.events=t,this.document=(0,a.getOwnerDocument)(i),this.documentListeners=new ne(this.document),this.listeners=new ne(n),this.windowListeners=new ne((0,a.getWindow)(i)),this.initialCoordinates=null!=(r=(0,a.getEventCoordinates)(o))?r:y,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(){const{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),this.windowListeners.add(oe.Resize,this.handleCancel),this.windowListeners.add(oe.DragStart,ae),this.windowListeners.add(oe.VisibilityChange,this.handleCancel),this.windowListeners.add(oe.ContextMenu,ae),this.documentListeners.add(oe.Keydown,this.handleKeydown),t){if(null!=n&&n({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(fe(t))return void(this.timeoutId=setTimeout(this.handleStart,t.delay));if(de(t))return}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),null!==this.timeoutId&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handleStart(){const{initialCoordinates:e}=this,{onStart:t}=this.props;e&&(this.activated=!0,this.documentListeners.add(oe.Click,le,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(oe.SelectionChange,this.removeTextSelection),t(e))}handleMove(e){var t;const{activated:n,initialCoordinates:r,props:o}=this,{onMove:i,options:{activationConstraint:l}}=o;if(!r)return;const s=null!=(t=(0,a.getEventCoordinates)(e))?t:y,u=(0,a.subtract)(r,s);if(!n&&l){if(de(l)){if(null!=l.tolerance&&re(u,l.tolerance))return this.handleCancel();if(re(u,l.distance))return this.handleStart()}return fe(l)&&re(u,l.tolerance)?this.handleCancel():void 0}e.cancelable&&e.preventDefault(),i(s)}handleEnd(){const{onEnd:e}=this.props;this.detach(),e()}handleCancel(){const{onCancel:e}=this.props;this.detach(),e()}handleKeydown(e){e.code===ie.Esc&&this.handleCancel()}removeTextSelection(){var e;null==(e=this.document.getSelection())||e.removeAllRanges()}}const ge={move:{name:"pointermove"},end:{name:"pointerup"}};class ve extends pe{constructor(e){const{event:t}=e,n=(0,a.getOwnerDocument)(t.target);super(e,ge,n)}}ve.activators=[{eventName:"onPointerDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return!(!n.isPrimary||0!==n.button)&&(null==r||r({event:n}),!0)}}];const he={move:{name:"mousemove"},end:{name:"mouseup"}};var be;!function(e){e[e.RightClick=2]="RightClick"}(be||(be={}));class me extends pe{constructor(e){super(e,he,(0,a.getOwnerDocument)(e.event.target))}}me.activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button!==be.RightClick&&(null==r||r({event:n}),!0)}}];const ye={move:{name:"touchmove"},end:{name:"touchend"}};class we extends pe{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(){}}}var xe,Ce;function Ee(e){let{acceleration:t,activator:n=xe.Pointer,canScroll:o,draggingRect:i,enabled:l,interval:s=5,order:u=Ce.TreeOrder,pointerCoordinates:c,scrollableAncestors:d,scrollableAncestorRects:f,delta:p,threshold:g}=e;const v=function(e){let{delta:t,disabled:n}=e;const r=(0,a.usePrevious)(t);return(0,a.useLazyMemo)((e=>{if(n||!r||!e)return Re;const o={x:Math.sign(t.x-r.x),y:Math.sign(t.y-r.y)};return{x:{[H.Backward]:e.x[H.Backward]||-1===o.x,[H.Forward]:e.x[H.Forward]||1===o.x},y:{[H.Backward]:e.y[H.Backward]||-1===o.y,[H.Forward]:e.y[H.Forward]||1===o.y}}}),[n,t,r])}({delta:p,disabled:!l}),[h,b]=(0,a.useInterval)(),m=(0,r.useRef)({x:0,y:0}),y=(0,r.useRef)({x:0,y:0}),w=(0,r.useMemo)((()=>{switch(n){case xe.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case xe.DraggableRect:return i}}),[n,i,c]),x=(0,r.useRef)(null),C=(0,r.useCallback)((()=>{const e=x.current;if(!e)return;const t=m.current.x*y.current.x,n=m.current.y*y.current.y;e.scrollBy(t,n)}),[]),E=(0,r.useMemo)((()=>u===Ce.TreeOrder?[...d].reverse():d),[u,d]);(0,r.useEffect)((()=>{if(l&&d.length&&w){for(const e of E){if(!1===(null==o?void 0:o(e)))continue;const n=d.indexOf(e),r=f[n];if(!r)continue;const{direction:i,speed:a}=J(e,r,w,t,g);for(const e of["x","y"])v[e][i[e]]||(a[e]=0,i[e]=0);if(a.x>0||a.y>0)return b(),x.current=e,h(C,s),m.current=a,void(y.current=i)}m.current={x:0,y:0},y.current={x:0,y:0},b()}else b()}),[t,C,o,b,l,s,JSON.stringify(w),JSON.stringify(v),h,d,E,f,JSON.stringify(g)])}we.activators=[{eventName:"onTouchStart",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;const{touches:o}=n;return!(o.length>1)&&(null==r||r({event:n}),!0)}}],function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"}(xe||(xe={})),function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"}(Ce||(Ce={}));const Re={x:{[H.Backward]:!1,[H.Forward]:!1},y:{[H.Backward]:!1,[H.Forward]:!1}};var ke,De;!function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"}(ke||(ke={})),function(e){e.Optimized="optimized"}(De||(De={}));const Se=new Map;function _e(e,t){return(0,a.useLazyMemo)((n=>e?n||("function"==typeof t?t(e):e):null),[t,e])}function Oe(e){let{callback:t,disabled:n}=e;const o=(0,a.useEvent)(t),i=(0,r.useMemo)((()=>{if(n||"undefined"==typeof window||void 0===window.ResizeObserver)return;const{ResizeObserver:e}=window;return new e(o)}),[n]);return(0,r.useEffect)((()=>()=>null==i?void 0:i.disconnect()),[i]),i}function Me(e){return new te(j(e),e)}function Ie(e,t,n){void 0===t&&(t=Me);const[o,i]=(0,r.useReducer)((function(r){if(!e)return null;var o;if(!1===e.isConnected)return null!=(o=null!=r?r:n)?o:null;const i=t(e);if(JSON.stringify(r)===JSON.stringify(i))return r;return i}),null),l=function(e){let{callback:t,disabled:n}=e;const o=(0,a.useEvent)(t),i=(0,r.useMemo)((()=>{if(n||"undefined"==typeof window||void 0===window.MutationObserver)return;const{MutationObserver:e}=window;return new e(o)}),[o,n]);return(0,r.useEffect)((()=>()=>null==i?void 0:i.disconnect()),[i]),i}({callback(t){if(e)for(const n of t){const{type:t,target:r}=n;if("childList"===t&&r instanceof HTMLElement&&r.contains(e)){i();break}}}}),s=Oe({callback:i});return(0,a.useIsomorphicLayoutEffect)((()=>{i(),e?(null==s||s.observe(e),null==l||l.observe(document.body,{childList:!0,subtree:!0})):(null==s||s.disconnect(),null==l||l.disconnect())}),[e]),o}const Le=[];function Ne(e,t){void 0===t&&(t=[]);const n=(0,r.useRef)(null);return(0,r.useEffect)((()=>{n.current=null}),t),(0,r.useEffect)((()=>{const t=e!==y;t&&!n.current&&(n.current=e),!t&&n.current&&(n.current=null)}),[e]),n.current?(0,a.subtract)(e,n.current):y}function Te(e){return(0,r.useMemo)((()=>e?function(e){const t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}(e):null),[e])}const Fe=[];function Ae(e){if(!e)return null;if(e.children.length>1)return e;const t=e.children[0];return(0,a.isHTMLElement)(t)?t:e}const Pe=[{sensor:ve,options:{}},{sensor:ce,options:{}}],je={current:{}},Ke={draggable:{measure:K},droppable:{measure:K,strategy:ke.WhileDragging,frequency:De.Optimized},dragOverlay:{measure:j}};class qe extends Map{get(e){var t;return null!=e&&null!=(t=super.get(e))?t:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter((e=>{let{disabled:t}=e;return!t}))}getNodeFor(e){var t,n;return null!=(t=null==(n=this.get(e))?void 0:n.node.current)?t:void 0}}const Be={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new qe,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:h},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:Ke,measureDroppableContainers:h,windowRect:null,measuringScheduled:!1},We={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:h,draggableNodes:new Map,over:null,measureDroppableContainers:h},Ue=(0,r.createContext)(We),ze=(0,r.createContext)(Be);function Ve(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new qe}}}function He(e,t){switch(t.type){case v.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case v.DragMove:return e.draggable.active?{...e,draggable:{...e.draggable,translate:{x:t.coordinates.x-e.draggable.initialCoordinates.x,y:t.coordinates.y-e.draggable.initialCoordinates.y}}}:e;case v.DragEnd:case v.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case v.RegisterDroppable:{const{element:n}=t,{id:r}=n,o=new qe(e.droppable.containers);return o.set(r,n),{...e,droppable:{...e.droppable,containers:o}}}case v.SetDroppableDisabled:{const{id:n,key:r,disabled:o}=t,i=e.droppable.containers.get(n);if(!i||r!==i.key)return e;const a=new qe(e.droppable.containers);return a.set(n,{...i,disabled:o}),{...e,droppable:{...e.droppable,containers:a}}}case v.UnregisterDroppable:{const{id:n,key:r}=t,o=e.droppable.containers.get(n);if(!o||r!==o.key)return e;const i=new qe(e.droppable.containers);return i.delete(n),{...e,droppable:{...e.droppable,containers:i}}}default:return e}}function Xe(e){let{disabled:t}=e;const{active:n,activatorEvent:o,draggableNodes:i}=(0,r.useContext)(Ue),l=(0,a.usePrevious)(o),s=(0,a.usePrevious)(null==n?void 0:n.id);return(0,r.useEffect)((()=>{if(!t&&!o&&l&&null!=s){if(!(0,a.isKeyboardEvent)(l))return;if(document.activeElement===l.target)return;const e=i.get(s);if(!e)return;const{activatorNode:t,node:n}=e;if(!t.current&&!n.current)return;requestAnimationFrame((()=>{for(const e of[t.current,n.current]){if(!e)continue;const t=(0,a.findFirstFocusableNode)(e);if(t){t.focus();break}}}))}}),[o,t,i,s,l]),null}function Ye(e,t){let{transform:n,...r}=t;return null!=e&&e.length?e.reduce(((e,t)=>t({transform:e,...r})),n):n}const $e=(0,r.createContext)({...y,scaleX:1,scaleY:1});var Je;!function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"}(Je||(Je={}));const Ge=(0,r.memo)((function(e){var t,n,l,s;let{id:u,accessibility:d,autoScroll:f=!0,children:p,sensors:h=Pe,collisionDetection:b=M,measuring:m,modifiers:w,...x}=e;const C=(0,r.useReducer)(He,void 0,Ve),[E,R]=C,[D,S]=function(){const[e]=(0,r.useState)((()=>new Set)),t=(0,r.useCallback)((t=>(e.add(t),()=>e.delete(t))),[e]);return[(0,r.useCallback)((t=>{let{type:n,event:r}=t;e.forEach((e=>{var t;return null==(t=e[n])?void 0:t.call(e,r)}))}),[e]),t]}(),[_,O]=(0,r.useState)(Je.Uninitialized),I=_===Je.Initialized,{draggable:{active:L,nodes:T,translate:A},droppable:{containers:P}}=E,K=L?T.get(L):null,U=(0,r.useRef)({initial:null,translated:null}),z=(0,r.useMemo)((()=>{var e;return null!=L?{id:L,data:null!=(e=null==K?void 0:K.data)?e:je,rect:U}:null}),[L,K]),H=(0,r.useRef)(null),[Y,$]=(0,r.useState)(null),[J,G]=(0,r.useState)(null),Z=(0,a.useLatestValue)(x,Object.values(x)),ee=(0,a.useUniqueId)("DndDescribedBy",u),ne=(0,r.useMemo)((()=>P.getEnabled()),[P]),re=(oe=m,(0,r.useMemo)((()=>({draggable:{...Ke.draggable,...null==oe?void 0:oe.draggable},droppable:{...Ke.droppable,...null==oe?void 0:oe.droppable},dragOverlay:{...Ke.dragOverlay,...null==oe?void 0:oe.dragOverlay}})),[null==oe?void 0:oe.draggable,null==oe?void 0:oe.droppable,null==oe?void 0:oe.dragOverlay]));var oe;const{droppableRects:ie,measureDroppableContainers:ae,measuringScheduled:le}=function(e,t){let{dragging:n,dependencies:o,config:i}=t;const[l,s]=(0,r.useState)(null),{frequency:u,measure:c,strategy:d}=i,f=(0,r.useRef)(e),p=function(){switch(d){case ke.Always:return!1;case ke.BeforeDragging:return n;default:return!n}}(),g=(0,a.useLatestValue)(p),v=(0,r.useCallback)((function(e){void 0===e&&(e=[]),g.current||s((t=>null===t?e:t.concat(e.filter((e=>!t.includes(e))))))}),[g]),h=(0,r.useRef)(null),b=(0,a.useLazyMemo)((t=>{if(p&&!n)return Se;if(!t||t===Se||f.current!==e||null!=l){const t=new Map;for(let n of e){if(!n)continue;if(l&&l.length>0&&!l.includes(n.id)&&n.rect.current){t.set(n.id,n.rect.current);continue}const e=n.node.current,r=e?new te(c(e),e):null;n.rect.current=r,r&&t.set(n.id,r)}return t}return t}),[e,l,n,p,c]);return(0,r.useEffect)((()=>{f.current=e}),[e]),(0,r.useEffect)((()=>{p||v()}),[n,p]),(0,r.useEffect)((()=>{l&&l.length>0&&s(null)}),[JSON.stringify(l)]),(0,r.useEffect)((()=>{p||"number"!=typeof u||null!==h.current||(h.current=setTimeout((()=>{v(),h.current=null}),u))}),[u,p,v,...o]),{droppableRects:b,measureDroppableContainers:v,measuringScheduled:null!=l}}(ne,{dragging:I,dependencies:[A.x,A.y],config:re.droppable}),se=function(e,t){const n=null!==t?e.get(t):void 0,r=n?n.node.current:null;return(0,a.useLazyMemo)((e=>{var n;return null===t?null:null!=(n=null!=r?r:e)?n:null}),[r,t])}(T,L),ue=(0,r.useMemo)((()=>J?(0,a.getEventCoordinates)(J):null),[J]),ce=function(){const e=!1===(null==Y?void 0:Y.autoScrollEnabled),t="object"==typeof f?!1===f.enabled:!1===f,n=I&&!e&&!t;if("object"==typeof f)return{...f,enabled:n};return{enabled:n}}(),de=function(e,t){return _e(e,t)}(se,re.draggable.measure);!function(e){let{activeNode:t,measure:n,initialRect:o,config:i=!0}=e;const l=(0,r.useRef)(!1),{x:s,y:u}="boolean"==typeof i?{x:i,y:i}:i;(0,a.useIsomorphicLayoutEffect)((()=>{if(!s&&!u||!t)return void(l.current=!1);if(l.current||!o)return;const e=null==t?void 0:t.node.current;if(!e||!1===e.isConnected)return;const r=N(n(e),o);if(s||(r.x=0),u||(r.y=0),l.current=!0,Math.abs(r.x)>0||Math.abs(r.y)>0){const t=B(e);t&&t.scrollBy({top:r.y,left:r.x})}}),[t,s,u,o,n])}({activeNode:L?T.get(L):null,config:ce.layoutShiftCompensation,initialRect:de,measure:re.draggable.measure});const fe=Ie(se,re.draggable.measure,de),pe=Ie(se?se.parentElement:null),ge=(0,r.useRef)({activatorEvent:null,active:null,activeNode:se,collisionRect:null,collisions:null,droppableRects:ie,draggableNodes:T,draggingNode:null,draggingNodeRect:null,droppableContainers:P,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),ve=P.getNodeFor(null==(t=ge.current.over)?void 0:t.id),he=function(e){let{measure:t}=e;const[n,o]=(0,r.useState)(null),i=Oe({callback:(0,r.useCallback)((e=>{for(const{target:n}of e)if((0,a.isHTMLElement)(n)){o((e=>{const r=t(n);return e?{...e,width:r.width,height:r.height}:r}));break}}),[t])}),l=(0,r.useCallback)((e=>{const n=Ae(e);null==i||i.disconnect(),n&&(null==i||i.observe(n)),o(n?t(n):null)}),[t,i]),[s,u]=(0,a.useNodeRef)(l);return(0,r.useMemo)((()=>({nodeRef:s,rect:n,setRef:u})),[n,s,u])}({measure:re.dragOverlay.measure}),be=null!=(n=he.nodeRef.current)?n:se,me=I?null!=(l=he.rect)?l:fe:null,ye=Boolean(he.nodeRef.current&&he.rect),we=N(xe=ye?null:fe,_e(xe));var xe;const Ce=Te(be?(0,a.getWindow)(be):null),Re=function(e){const t=(0,r.useRef)(e),n=(0,a.useLazyMemo)((n=>e?n&&n!==Le&&e&&t.current&&e.parentNode===t.current.parentNode?n:q(e):Le),[e]);return(0,r.useEffect)((()=>{t.current=e}),[e]),n}(I?null!=ve?ve:se:null),De=function(e,t){void 0===t&&(t=j);const[n]=e,o=Te(n?(0,a.getWindow)(n):null),[i,l]=(0,r.useReducer)((function(){return e.length?e.map((e=>X(e)?o:new te(t(e),e))):Fe}),Fe),s=Oe({callback:l});return e.length>0&&i===Fe&&l(),(0,a.useIsomorphicLayoutEffect)((()=>{e.length?e.forEach((e=>null==s?void 0:s.observe(e))):(null==s||s.disconnect(),l())}),[e]),i}(Re),Me=Ye(w,{transform:{x:A.x-we.x,y:A.y-we.y,scaleX:1,scaleY:1},activatorEvent:J,active:z,activeNodeRect:fe,containerNodeRect:pe,draggingNodeRect:me,over:ge.current.over,overlayNodeRect:he.rect,scrollableAncestors:Re,scrollableAncestorRects:De,windowRect:Ce}),qe=ue?(0,a.add)(ue,A):null,Be=function(e){const[t,n]=(0,r.useState)(null),o=(0,r.useRef)(e),i=(0,r.useCallback)((e=>{const t=W(e.target);t&&n((e=>e?(e.set(t,V(t)),new Map(e)):null))}),[]);return(0,r.useEffect)((()=>{const t=o.current;if(e!==t){r(t);const a=e.map((e=>{const t=W(e);return t?(t.addEventListener("scroll",i,{passive:!0}),[t,V(t)]):null})).filter((e=>null!=e));n(a.length?new Map(a):null),o.current=e}return()=>{r(e),r(t)};function r(e){e.forEach((e=>{const t=W(e);null==t||t.removeEventListener("scroll",i)}))}}),[i,e]),(0,r.useMemo)((()=>e.length?t?Array.from(t.values()).reduce(((e,t)=>(0,a.add)(e,t)),y):Q(e):y),[e,t])}(Re),We=Ne(Be),Ge=Ne(Be,[fe]),Qe=(0,a.add)(Me,We),Ze=me?F(me,Me):null,et=z&&Ze?b({active:z,collisionRect:Ze,droppableRects:ie,droppableContainers:ne,pointerCoordinates:qe}):null,tt=k(et,"id"),[nt,rt]=(0,r.useState)(null),ot=function(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}(ye?Me:(0,a.add)(Me,Ge),null!=(s=null==nt?void 0:nt.rect)?s:null,fe),it=(0,r.useCallback)(((e,t)=>{let{sensor:n,options:r}=t;if(null==H.current)return;const o=T.get(H.current);if(!o)return;const a=e.nativeEvent,l=new n({active:H.current,activeNode:o,event:a,options:r,context:ge,onStart(e){const t=H.current;if(null==t)return;const n=T.get(t);if(!n)return;const{onDragStart:r}=Z.current,o={active:{id:t,data:n.data,rect:U}};(0,i.unstable_batchedUpdates)((()=>{null==r||r(o),O(Je.Initializing),R({type:v.DragStart,initialCoordinates:e,active:t}),D({type:"onDragStart",event:o})}))},onMove(e){R({type:v.DragMove,coordinates:e})},onEnd:s(v.DragEnd),onCancel:s(v.DragCancel)});function s(e){return async function(){const{active:t,collisions:n,over:r,scrollAdjustedTranslate:o}=ge.current;let l=null;if(t&&o){const{cancelDrop:i}=Z.current;if(l={activatorEvent:a,active:t,collisions:n,delta:o,over:r},e===v.DragEnd&&"function"==typeof i){await Promise.resolve(i(l))&&(e=v.DragCancel)}}H.current=null,(0,i.unstable_batchedUpdates)((()=>{R({type:e}),O(Je.Uninitialized),rt(null),$(null),G(null);const t=e===v.DragEnd?"onDragEnd":"onDragCancel";if(l){const e=Z.current[t];null==e||e(l),D({type:t,event:l})}}))}}(0,i.unstable_batchedUpdates)((()=>{$(l),G(e.nativeEvent)}))}),[T]),at=(0,r.useCallback)(((e,t)=>(n,r)=>{const o=n.nativeEvent,i=T.get(r);if(null!==H.current||!i||o.dndKit||o.defaultPrevented)return;const a={active:i};!0===e(n,t.options,a)&&(o.dndKit={capturedBy:t.sensor},H.current=r,it(n,t))}),[T,it]),lt=function(e,t){return(0,r.useMemo)((()=>e.reduce(((e,n)=>{const{sensor:r}=n;return[...e,...r.activators.map((e=>({eventName:e.eventName,handler:t(e.handler,n)})))]}),[])),[e,t])}(h,at);!function(e){(0,r.useEffect)((()=>{if(!a.canUseDOM)return;const t=e.map((e=>{let{sensor:t}=e;return null==t.setup?void 0:t.setup()}));return()=>{for(const e of t)null==e||e()}}),e.map((e=>{let{sensor:t}=e;return t})))}(h),(0,a.useIsomorphicLayoutEffect)((()=>{fe&&_===Je.Initializing&&O(Je.Initialized)}),[fe,_]),(0,r.useEffect)((()=>{const{onDragMove:e}=Z.current,{active:t,activatorEvent:n,collisions:r,over:o}=ge.current;if(!t||!n)return;const a={active:t,activatorEvent:n,collisions:r,delta:{x:Qe.x,y:Qe.y},over:o};(0,i.unstable_batchedUpdates)((()=>{null==e||e(a),D({type:"onDragMove",event:a})}))}),[Qe.x,Qe.y]),(0,r.useEffect)((()=>{const{active:e,activatorEvent:t,collisions:n,droppableContainers:r,scrollAdjustedTranslate:o}=ge.current;if(!e||null==H.current||!t||!o)return;const{onDragOver:a}=Z.current,l=r.get(tt),s=l&&l.rect.current?{id:l.id,rect:l.rect.current,data:l.data,disabled:l.disabled}:null,u={active:e,activatorEvent:t,collisions:n,delta:{x:o.x,y:o.y},over:s};(0,i.unstable_batchedUpdates)((()=>{rt(s),null==a||a(u),D({type:"onDragOver",event:u})}))}),[tt]),(0,a.useIsomorphicLayoutEffect)((()=>{ge.current={activatorEvent:J,active:z,activeNode:se,collisionRect:Ze,collisions:et,droppableRects:ie,draggableNodes:T,draggingNode:be,draggingNodeRect:me,droppableContainers:P,over:nt,scrollableAncestors:Re,scrollAdjustedTranslate:Qe},U.current={initial:me,translated:Ze}}),[z,se,et,Ze,T,be,me,ie,P,nt,Re,Qe]),Ee({...ce,delta:A,draggingRect:Ze,pointerCoordinates:qe,scrollableAncestors:Re,scrollableAncestorRects:De});const st=(0,r.useMemo)((()=>({active:z,activeNode:se,activeNodeRect:fe,activatorEvent:J,collisions:et,containerNodeRect:pe,dragOverlay:he,draggableNodes:T,droppableContainers:P,droppableRects:ie,over:nt,measureDroppableContainers:ae,scrollableAncestors:Re,scrollableAncestorRects:De,measuringConfiguration:re,measuringScheduled:le,windowRect:Ce})),[z,se,fe,J,et,pe,he,T,P,ie,nt,ae,Re,De,re,le,Ce]),ut=(0,r.useMemo)((()=>({activatorEvent:J,activators:lt,active:z,activeNodeRect:fe,ariaDescribedById:{draggable:ee},dispatch:R,draggableNodes:T,over:nt,measureDroppableContainers:ae})),[J,lt,z,fe,R,ee,T,nt,ae]);return o().createElement(c.Provider,{value:S},o().createElement(Ue.Provider,{value:ut},o().createElement(ze.Provider,{value:st},o().createElement($e.Provider,{value:ot},p)),o().createElement(Xe,{disabled:!1===(null==d?void 0:d.restoreFocus)})),o().createElement(g,{...d,hiddenTextDescribedById:ee}))})),Qe=(0,r.createContext)(null),Ze="button",et="Droppable";function tt(e){let{id:t,data:n,disabled:o=!1,attributes:i}=e;const l=(0,a.useUniqueId)(et),{activators:s,activatorEvent:u,active:c,activeNodeRect:d,ariaDescribedById:f,draggableNodes:p,over:g}=(0,r.useContext)(Ue),{role:v=Ze,roleDescription:h="draggable",tabIndex:b=0}=null!=i?i:{},m=(null==c?void 0:c.id)===t,y=(0,r.useContext)(m?$e:Qe),[w,x]=(0,a.useNodeRef)(),[C,E]=(0,a.useNodeRef)(),R=function(e,t){return(0,r.useMemo)((()=>e.reduce(((e,n)=>{let{eventName:r,handler:o}=n;return e[r]=e=>{o(e,t)},e}),{})),[e,t])}(s,t),k=(0,a.useLatestValue)(n);(0,a.useIsomorphicLayoutEffect)((()=>(p.set(t,{id:t,key:l,node:w,activatorNode:C,data:k}),()=>{const e=p.get(t);e&&e.key===l&&p.delete(t)})),[p,t]);return{active:c,activatorEvent:u,activeNodeRect:d,attributes:(0,r.useMemo)((()=>({role:v,tabIndex:b,"aria-disabled":o,"aria-pressed":!(!m||v!==Ze)||void 0,"aria-roledescription":h,"aria-describedby":f.draggable})),[o,v,b,m,h,f.draggable]),isDragging:m,listeners:o?void 0:R,node:w,over:g,setNodeRef:x,setActivatorNodeRef:E,transform:y}}function nt(){return(0,r.useContext)(ze)}const rt="Droppable",ot={timeout:25};function it(e){let{data:t,disabled:n=!1,id:o,resizeObserverConfig:i}=e;const l=(0,a.useUniqueId)(rt),{active:s,dispatch:u,over:c,measureDroppableContainers:d}=(0,r.useContext)(Ue),f=(0,r.useRef)({disabled:n}),p=(0,r.useRef)(!1),g=(0,r.useRef)(null),h=(0,r.useRef)(null),{disabled:b,updateMeasurementsFor:m,timeout:y}={...ot,...i},w=(0,a.useLatestValue)(null!=m?m:o),x=Oe({callback:(0,r.useCallback)((()=>{p.current?(null!=h.current&&clearTimeout(h.current),h.current=setTimeout((()=>{d(Array.isArray(w.current)?w.current:[w.current]),h.current=null}),y)):p.current=!0}),[y]),disabled:b||!s}),C=(0,r.useCallback)(((e,t)=>{x&&(t&&(x.unobserve(t),p.current=!1),e&&x.observe(e))}),[x]),[E,R]=(0,a.useNodeRef)(C),k=(0,a.useLatestValue)(t);return(0,r.useEffect)((()=>{x&&E.current&&(x.disconnect(),p.current=!1,x.observe(E.current))}),[E,x]),(0,a.useIsomorphicLayoutEffect)((()=>(u({type:v.RegisterDroppable,element:{id:o,key:l,disabled:n,node:E,rect:g,data:k}}),()=>u({type:v.UnregisterDroppable,key:l,id:o}))),[o]),(0,r.useEffect)((()=>{n!==f.current.disabled&&(u({type:v.SetDroppableDisabled,id:o,key:l,disabled:n}),f.current.disabled=n)}),[o,l,n,u]),{active:s,rect:g,isOver:(null==c?void 0:c.id)===o,node:E,over:c,setNodeRef:R}}function at(e){let{animation:t,children:n}=e;const[i,l]=(0,r.useState)(null),[s,u]=(0,r.useState)(null),c=(0,a.usePrevious)(n);return n||i||!c||l(c),(0,a.useIsomorphicLayoutEffect)((()=>{if(!s)return;const e=null==i?void 0:i.key,n=null==i?void 0:i.props.id;null!=e&&null!=n?Promise.resolve(t(n,s)).then((()=>{l(null)})):l(null)}),[t,i,s]),o().createElement(o().Fragment,null,n,i?(0,r.cloneElement)(i,{ref:u}):null)}const lt={x:0,y:0,scaleX:1,scaleY:1};function st(e){let{children:t}=e;return o().createElement(Ue.Provider,{value:We},o().createElement($e.Provider,{value:lt},t))}const ut={position:"fixed",touchAction:"none"},ct=e=>(0,a.isKeyboardEvent)(e)?"transform 250ms ease":void 0,dt=(0,r.forwardRef)(((e,t)=>{let{as:n,activatorEvent:r,adjustScale:i,children:l,className:s,rect:u,style:c,transform:d,transition:f=ct}=e;if(!u)return null;const p=i?d:{...d,scaleX:1,scaleY:1},g={...ut,width:u.width,height:u.height,top:u.top,left:u.left,transform:a.CSS.Transform.toString(p),transformOrigin:i&&r?x(r,u):void 0,transition:"function"==typeof f?f(r):f,...c};return o().createElement(n,{className:s,style:g,ref:t},l)})),ft=e=>t=>{let{active:n,dragOverlay:r}=t;const o={},{styles:i,className:a}=e;if(null!=i&&i.active)for(const[e,t]of Object.entries(i.active))void 0!==t&&(o[e]=n.node.style.getPropertyValue(e),n.node.style.setProperty(e,t));if(null!=i&&i.dragOverlay)for(const[e,t]of Object.entries(i.dragOverlay))void 0!==t&&r.node.style.setProperty(e,t);return null!=a&&a.active&&n.node.classList.add(a.active),null!=a&&a.dragOverlay&&r.node.classList.add(a.dragOverlay),function(){for(const[e,t]of Object.entries(o))n.node.style.setProperty(e,t);null!=a&&a.active&&n.node.classList.remove(a.active)}},pt={duration:250,easing:"ease",keyframes:e=>{let{transform:{initial:t,final:n}}=e;return[{transform:a.CSS.Transform.toString(t)},{transform:a.CSS.Transform.toString(n)}]},sideEffects:ft({styles:{active:{opacity:"0"}}})};function gt(e){let{config:t,draggableNodes:n,droppableContainers:r,measuringConfiguration:o}=e;return(0,a.useEvent)(((e,i)=>{if(null===t)return;const l=n.get(e);if(!l)return;const s=l.node.current;if(!s)return;const u=Ae(i);if(!u)return;const{transform:c}=(0,a.getWindow)(i).getComputedStyle(i),d=A(c);if(!d)return;const f="function"==typeof t?t:function(e){const{duration:t,easing:n,sideEffects:r,keyframes:o}={...pt,...e};return e=>{let{active:i,dragOverlay:a,transform:l,...s}=e;if(!t)return;const u={x:a.rect.left-i.rect.left,y:a.rect.top-i.rect.top},c={scaleX:1!==l.scaleX?i.rect.width*l.scaleX/a.rect.width:1,scaleY:1!==l.scaleY?i.rect.height*l.scaleY/a.rect.height:1},d={x:l.x-u.x,y:l.y-u.y,...c},f=o({...s,active:i,dragOverlay:a,transform:{initial:l,final:d}}),[p]=f,g=f[f.length-1];if(JSON.stringify(p)===JSON.stringify(g))return;const v=null==r?void 0:r({active:i,dragOverlay:a,...s}),h=a.node.animate(f,{duration:t,easing:n,fill:"forwards"});return new Promise((e=>{h.onfinish=()=>{null==v||v(),e()}}))}}(t);return Z(s,o.draggable.measure),f({active:{id:e,data:l.data,node:s,rect:o.draggable.measure(s)},draggableNodes:n,dragOverlay:{node:i,rect:o.dragOverlay.measure(u)},droppableContainers:r,measuringConfiguration:o,transform:d})}))}let vt=0;function ht(e){return(0,r.useMemo)((()=>{if(null!=e)return vt++,vt}),[e])}const bt=o().memo((e=>{let{adjustScale:t=!1,children:n,dropAnimation:i,style:a,transition:l,modifiers:s,wrapperElement:u="div",className:c,zIndex:d=999}=e;const{activatorEvent:f,active:p,activeNodeRect:g,containerNodeRect:v,draggableNodes:h,droppableContainers:b,dragOverlay:m,over:y,measuringConfiguration:w,scrollableAncestors:x,scrollableAncestorRects:C,windowRect:E}=nt(),R=(0,r.useContext)($e),k=ht(null==p?void 0:p.id),D=Ye(s,{activatorEvent:f,active:p,activeNodeRect:g,containerNodeRect:v,draggingNodeRect:m.rect,over:y,overlayNodeRect:m.rect,scrollableAncestors:x,scrollableAncestorRects:C,transform:R,windowRect:E}),S=_e(g),_=gt({config:i,draggableNodes:h,droppableContainers:b,measuringConfiguration:w}),O=S?m.setRef:void 0;return o().createElement(st,null,o().createElement(at,{animation:_},p&&k?o().createElement(dt,{key:k,id:p.id,ref:O,as:u,activatorEvent:f,adjustScale:t,className:c,transition:l,rect:S,style:{zIndex:d,...a},transform:D},n):null))}))},831:function(e,t,n){n.r(t),n.d(t,{createSnapModifier:function(){return o},restrictToFirstScrollableAncestor:function(){return s},restrictToHorizontalAxis:function(){return i},restrictToParentElement:function(){return l},restrictToVerticalAxis:function(){return u},restrictToWindowEdges:function(){return c},snapCenterToCursor:function(){return d}});var r=n(979);function o(e){return t=>{let{transform:n}=t;return{...n,x:Math.ceil(n.x/e)*e,y:Math.ceil(n.y/e)*e}}}const i=e=>{let{transform:t}=e;return{...t,y:0}};function a(e,t,n){const r={...e};return t.top+e.y<=n.top?r.y=n.top-t.top:t.bottom+e.y>=n.top+n.height&&(r.y=n.top+n.height-t.bottom),t.left+e.x<=n.left?r.x=n.left-t.left:t.right+e.x>=n.left+n.width&&(r.x=n.left+n.width-t.right),r}const l=e=>{let{containerNodeRect:t,draggingNodeRect:n,transform:r}=e;return n&&t?a(r,n,t):r},s=e=>{let{draggingNodeRect:t,transform:n,scrollableAncestorRects:r}=e;const o=r[0];return t&&o?a(n,t,o):n},u=e=>{let{transform:t}=e;return{...t,x:0}},c=e=>{let{transform:t,draggingNodeRect:n,windowRect:r}=e;return n&&r?a(t,n,r):t},d=e=>{let{activatorEvent:t,draggingNodeRect:n,transform:o}=e;if(n&&t){const e=(0,r.getEventCoordinates)(t);if(!e)return o;const i=e.x-n.left,a=e.y-n.top;return{...o,x:o.x+i-n.width/2,y:o.y+a-n.height/2}}return o}},627:function(e,t,n){n.r(t),n.d(t,{SortableContext:function(){return y},arrayMove:function(){return l},arraySwap:function(){return s},defaultAnimateLayoutChanges:function(){return x},defaultNewIndexGetter:function(){return w},hasSortableData:function(){return S},horizontalListSortingStrategy:function(){return f},rectSortingStrategy:function(){return p},rectSwappingStrategy:function(){return g},sortableKeyboardCoordinates:function(){return O},useSortable:function(){return D},verticalListSortingStrategy:function(){return h}});var r=n(594),o=n.n(r),i=n(733),a=n(979);function l(e,t,n){const r=e.slice();return r.splice(n<0?r.length+n:n,0,r.splice(t,1)[0]),r}function s(e,t,n){const r=e.slice();return r[t]=e[n],r[n]=e[t],r}function u(e,t){return e.reduce(((e,n,r)=>{const o=t.get(n);return o&&(e[r]=o),e}),Array(e.length))}function c(e){return null!==e&&e>=0}const d={scaleX:1,scaleY:1},f=e=>{var t;let{rects:n,activeNodeRect:r,activeIndex:o,overIndex:i,index:a}=e;const l=null!=(t=n[o])?t:r;if(!l)return null;const s=function(e,t,n){const r=e[t],o=e[t-1],i=e[t+1];if(!r||!o&&!i)return 0;if(no&&a<=i?{x:-l.width-s,y:0,...d}:a=i?{x:l.width+s,y:0,...d}:{x:0,y:0,...d}};const p=e=>{let{rects:t,activeIndex:n,overIndex:r,index:o}=e;const i=l(t,r,n),a=t[o],s=i[o];return s&&a?{x:s.left-a.left,y:s.top-a.top,scaleX:s.width/a.width,scaleY:s.height/a.height}:null},g=e=>{let t,n,{activeIndex:r,index:o,rects:i,overIndex:a}=e;return o===r&&(t=i[o],n=i[a]),o===a&&(t=i[o],n=i[r]),n&&t?{x:n.left-t.left,y:n.top-t.top,scaleX:n.width/t.width,scaleY:n.height/t.height}:null},v={scaleX:1,scaleY:1},h=e=>{var t;let{activeIndex:n,activeNodeRect:r,index:o,rects:i,overIndex:a}=e;const l=null!=(t=i[n])?t:r;if(!l)return null;if(o===n){const e=i[a];return e?{x:0,y:nn&&o<=a?{x:0,y:-l.height-s,...v}:o=a?{x:0,y:l.height+s,...v}:{x:0,y:0,...v}};const b="Sortable",m=o().createContext({activeIndex:-1,containerId:b,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:p,disabled:{draggable:!1,droppable:!1}});function y(e){let{children:t,id:n,items:l,strategy:s=p,disabled:c=!1}=e;const{active:d,dragOverlay:f,droppableRects:g,over:v,measureDroppableContainers:h}=(0,i.useDndContext)(),y=(0,a.useUniqueId)(b,n),w=Boolean(null!==f.rect),x=(0,r.useMemo)((()=>l.map((e=>"object"==typeof e&&"id"in e?e.id:e))),[l]),C=null!=d,E=d?x.indexOf(d.id):-1,R=v?x.indexOf(v.id):-1,k=(0,r.useRef)(x),D=!function(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n{D&&C&&h(x)}),[D,x,C,h]),(0,r.useEffect)((()=>{k.current=x}),[x]);const O=(0,r.useMemo)((()=>({activeIndex:E,containerId:y,disabled:_,disableTransforms:S,items:x,overIndex:R,useDragOverlay:w,sortedRects:u(x,g),strategy:s})),[E,y,_.draggable,_.droppable,S,x,R,g,w,s]);return o().createElement(m.Provider,{value:O},t)}const w=e=>{let{id:t,items:n,activeIndex:r,overIndex:o}=e;return l(n,r,o).indexOf(t)},x=e=>{let{containerId:t,isSorting:n,wasDragging:r,index:o,items:i,newIndex:a,previousItems:l,previousContainerId:s,transition:u}=e;return!(!u||!r)&&((l===i||o!==a)&&(!!n||a!==o&&t===s))},C={duration:200,easing:"ease"},E="transform",R=a.CSS.Transition.toString({property:E,duration:0,easing:"linear"}),k={roleDescription:"sortable"};function D(e){let{animateLayoutChanges:t=x,attributes:n,disabled:o,data:l,getNewIndex:s=w,id:u,strategy:d,resizeObserverConfig:f,transition:p=C}=e;const{items:g,containerId:v,activeIndex:h,disabled:b,disableTransforms:y,sortedRects:D,overIndex:S,useDragOverlay:_,strategy:O}=(0,r.useContext)(m),M=function(e,t){var n,r;if("boolean"==typeof e)return{draggable:e,droppable:!1};return{draggable:null!=(n=null==e?void 0:e.draggable)?n:t.draggable,droppable:null!=(r=null==e?void 0:e.droppable)?r:t.droppable}}(o,b),I=g.indexOf(u),L=(0,r.useMemo)((()=>({sortable:{containerId:v,index:I,items:g},...l})),[v,l,I,g]),N=(0,r.useMemo)((()=>g.slice(g.indexOf(u))),[g,u]),{rect:T,node:F,isOver:A,setNodeRef:P}=(0,i.useDroppable)({id:u,data:L,disabled:M.droppable,resizeObserverConfig:{updateMeasurementsFor:N,...f}}),{active:j,activatorEvent:K,activeNodeRect:q,attributes:B,setNodeRef:W,listeners:U,isDragging:z,over:V,setActivatorNodeRef:H,transform:X}=(0,i.useDraggable)({id:u,data:L,attributes:{...k,...n},disabled:M.draggable}),Y=(0,a.useCombinedRefs)(P,W),$=Boolean(j),J=$&&!y&&c(h)&&c(S),G=!_&&z,Q=G&&J?X:null,Z=J?null!=Q?Q:(null!=d?d:O)({rects:D,activeNodeRect:q,activeIndex:h,overIndex:S,index:I}):null,ee=c(h)&&c(S)?s({id:u,items:g,activeIndex:h,overIndex:S}):I,te=null==j?void 0:j.id,ne=(0,r.useRef)({activeId:te,items:g,newIndex:ee,containerId:v}),re=g!==ne.current.items,oe=t({active:j,containerId:v,isDragging:z,isSorting:$,id:u,index:I,items:g,newIndex:ne.current.newIndex,previousItems:ne.current.items,previousContainerId:ne.current.containerId,transition:p,wasDragging:null!=ne.current.activeId}),ie=function(e){let{disabled:t,index:n,node:o,rect:l}=e;const[s,u]=(0,r.useState)(null),c=(0,r.useRef)(n);return(0,a.useIsomorphicLayoutEffect)((()=>{if(!t&&n!==c.current&&o.current){const e=l.current;if(e){const t=(0,i.getClientRect)(o.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)&&u(n)}}n!==c.current&&(c.current=n)}),[t,n,o,l]),(0,r.useEffect)((()=>{s&&u(null)}),[s]),s}({disabled:!oe,index:I,node:F,rect:T});return(0,r.useEffect)((()=>{$&&ne.current.newIndex!==ee&&(ne.current.newIndex=ee),v!==ne.current.containerId&&(ne.current.containerId=v),g!==ne.current.items&&(ne.current.items=g)}),[$,ee,v,g]),(0,r.useEffect)((()=>{if(te===ne.current.activeId)return;if(te&&!ne.current.activeId)return void(ne.current.activeId=te);const e=setTimeout((()=>{ne.current.activeId=te}),50);return()=>clearTimeout(e)}),[te]),{active:j,activeIndex:h,attributes:B,data:L,rect:T,index:I,newIndex:ee,items:g,isOver:A,isSorting:$,isDragging:z,listeners:U,node:F,overIndex:S,over:V,setNodeRef:Y,setActivatorNodeRef:H,setDroppableNodeRef:P,setDraggableNodeRef:W,transform:null!=ie?ie:Z,transition:function(){if(ie||re&&ne.current.newIndex===I)return R;if(G&&!(0,a.isKeyboardEvent)(K)||!p)return;if($||oe)return a.CSS.Transition.toString({...p,property:E});return}()}}function S(e){if(!e)return!1;const t=e.data.current;return!!(t&&"sortable"in t&&"object"==typeof t.sortable&&"containerId"in t.sortable&&"items"in t.sortable&&"index"in t.sortable)}const _=[i.KeyboardCode.Down,i.KeyboardCode.Right,i.KeyboardCode.Up,i.KeyboardCode.Left],O=(e,t)=>{let{context:{active:n,collisionRect:r,droppableRects:o,droppableContainers:l,over:s,scrollableAncestors:u}}=t;if(_.includes(e.code)){if(e.preventDefault(),!n||!r)return;const t=[];l.getEnabled().forEach((n=>{if(!n||null!=n&&n.disabled)return;const a=o.get(n.id);if(a)switch(e.code){case i.KeyboardCode.Down:r.topa.top&&t.push(n);break;case i.KeyboardCode.Left:r.left>a.left&&t.push(n);break;case i.KeyboardCode.Right:r.left1&&(d=c[1].id),null!=d){const e=l.get(n.id),t=l.get(d),s=t?o.get(t.id):null,c=null==t?void 0:t.node.current;if(c&&s&&e&&t){const n=(0,i.getScrollableAncestors)(c).some(((e,t)=>u[t]!==e)),o=M(e,t),l=function(e,t){if(!S(e)||!S(t))return!1;if(!M(e,t))return!1;return e.data.current.sortable.indexe=>{t.forEach((t=>t(e)))}),t)}const i="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement;function a(e){const t=Object.prototype.toString.call(e);return"[object Window]"===t||"[object global]"===t}function l(e){return"nodeType"in e}function s(e){var t,n;return e?a(e)?e:l(e)&&null!=(t=null==(n=e.ownerDocument)?void 0:n.defaultView)?t:window:window}function u(e){const{Document:t}=s(e);return e instanceof t}function c(e){return!a(e)&&e instanceof s(e).HTMLElement}function d(e){return e instanceof s(e).SVGElement}function f(e){return e?a(e)?e.document:l(e)?u(e)?e:c(e)||d(e)?e.ownerDocument:document:document:document}const p=i?r.useLayoutEffect:r.useEffect;function g(e){const t=(0,r.useRef)(e);return p((()=>{t.current=e})),(0,r.useCallback)((function(){for(var e=arguments.length,n=new Array(e),r=0;r{e.current=setInterval(t,n)}),[]),(0,r.useCallback)((()=>{null!==e.current&&(clearInterval(e.current),e.current=null)}),[])]}function h(e,t){void 0===t&&(t=[e]);const n=(0,r.useRef)(e);return p((()=>{n.current!==e&&(n.current=e)}),t),n}function b(e,t){const n=(0,r.useRef)();return(0,r.useMemo)((()=>{const t=e(n.current);return n.current=t,t}),[...t])}function m(e){const t=g(e),n=(0,r.useRef)(null),o=(0,r.useCallback)((e=>{e!==n.current&&(null==t||t(e,n.current)),n.current=e}),[]);return[n,o]}function y(e){const t=(0,r.useRef)();return(0,r.useEffect)((()=>{t.current=e}),[e]),t.current}let w={};function x(e,t){return(0,r.useMemo)((()=>{if(t)return t;const n=null==w[e]?0:w[e]+1;return w[e]=n,e+"-"+n}),[e,t])}function C(e){return function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o{const r=Object.entries(n);for(const[n,o]of r){const r=t[n];null!=r&&(t[n]=r+e*o)}return t}),{...t})}}const E=C(1),R=C(-1);function k(e){return"clientX"in e&&"clientY"in e}function D(e){if(!e)return!1;const{KeyboardEvent:t}=s(e.target);return t&&e instanceof t}function S(e){if(!e)return!1;const{TouchEvent:t}=s(e.target);return t&&e instanceof t}function _(e){if(S(e)){if(e.touches&&e.touches.length){const{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}if(e.changedTouches&&e.changedTouches.length){const{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return k(e)?{x:e.clientX,y:e.clientY}:null}const O=Object.freeze({Translate:{toString(e){if(!e)return;const{x:t,y:n}=e;return"translate3d("+(t?Math.round(t):0)+"px, "+(n?Math.round(n):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:t,scaleY:n}=e;return"scaleX("+t+") scaleY("+n+")"}},Transform:{toString(e){if(e)return[O.Translate.toString(e),O.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+" "+n+"ms "+r}}}),M="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function I(e){return e.matches(M)?e:e.querySelector(M)}},38:function(e,t,n){var r,o=(r=n(121))&&r.__esModule?r:{default:r};document.addEventListener("DOMContentLoaded",(()=>{(0,o.default)()}))},121:function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var r=l(n(207)),o=l(n(135)),i=l(n(853)),a=l(n(985));function l(e){return e&&e.__esModule?e:{default:e}}t.default=()=>{r.default.component.registerMany({LinkPicker:o.default,LinkField:i.default,"LinkModal.FormBuilderModal":a.default})}},853:function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.default=t.LinkFieldContext=t.Component=void 0;var r=D(n(594)),o=n(367),i=n(40),a=n(733),l=n(627),s=n(831),u=R(n(623)),c=R(n(135)),d=R(n(137)),f=R(n(89)),p=R(n(864)),g=D(n(918)),v=R(n(609)),h=R(n(177)),b=n(125),m=R(n(935)),y=R(n(815)),w=R(n(8)),x=R(n(675)),C=R(n(923)),E=R(n(489));function R(e){return e&&e.__esModule?e:{default:e}}function k(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,n=new WeakMap;return(k=function(e){return e?n:t})(e)}function D(e,t){if(!t&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var n=k(t);if(n&&n.has(e))return n.get(e);var r={__proto__:null},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var i in e)if("default"!==i&&{}.hasOwnProperty.call(e,i)){var a=o?Object.getOwnPropertyDescriptor(e,i):null;a&&(a.get||a.set)?Object.defineProperty(r,i,a):r[i]=e[i]}return r.default=e,n&&n.set(e,r),r}const S=t.LinkFieldContext=(0,r.createContext)(null),_="SilverStripe\\LinkField\\Controllers\\LinkFieldController",O=e=>{let{value:t=null,onChange:n=(()=>{}),types:o={},actions:i,isMulti:u=!1,canCreate:g,readonly:m,disabled:R,ownerID:k,ownerClass:D,ownerRelation:O,excludeLinkTextField:M=!1,inHistoryViewer:I}=e;const[L,N]=(0,r.useState)({}),[T,F]=(0,r.useState)(0),[A,P]=(0,r.useState)(!1),[j,K]=(0,r.useState)(0),[q,B]=(0,r.useState)(!1),[W,U]=(0,r.useState)(!1),[z,V]=(0,r.useState)(!1),[H,X]=(0,r.useState)(!1),[Y,$]=(0,r.useState)(0),[J,G]=(0,r.useState)(!1),[Q,Z]=(0,r.useState)((0,C.default)({"link-picker-links":!0})),ee=(0,a.useSensors)((0,a.useSensor)(a.PointerSensor,{activationConstraint:{distance:10}}),(0,a.useSensor)(a.KeyboardSensor,{coordinateGetter:(e,t)=>{e.preventDefault();const{active:n,over:r,droppableContainers:o}=t.context;if(!n||!n.data||!n.data.current)return;const i=n.data.current.sortable.items,s=r?r.id:n.id,u=i.indexOf(s),c=i.indexOf(n.id);let d=u,f=1;switch(e.code){case a.KeyboardCode.Down:case a.KeyboardCode.Right:d=Math.min(u+1,i.length-1);break;case a.KeyboardCode.Up:case a.KeyboardCode.Left:d=Math.max(0,u-1),f=-1;break;default:return}if(u===d)return;const p=(0,l.arrayMove)(i,c,u)[d];if(!o.has(p))return;const g=o.get(n.id).node.current;if(!o.has(n.id))return;const v=o.get(p).node.current,h=g.getBoundingClientRect(),b=v.getBoundingClientRect(),m=1===f?b.top-h.bottom:h.top-b.bottom;return{x:0,y:h.top+f*(b.height+m)}}}));let te=t;Array.isArray(te)||("number"==typeof te&&0!=te&&(te=[te]),te||(te=[])),(0,r.useEffect)((()=>{if(!T&&te.length>0){V(!0);const e=[];for(const t of te)e.push(`itemIDs[]=${t}`);const t=`${h.default.getSection(_).form.linkForm.dataUrl}?${e.join("&")}`;v.default.get(t).then((e=>e.json())).then((e=>{N(e)})).catch((()=>{X(!0)})).finally((()=>{V(!1),G(!1)}))}}),[T,t&&t.length,Y]);let ne=0;const re=[];for(const e of te)re[e]=(0,r.useRef)(null),ne++;for(;ne<256;)(0,r.useRef)(null),ne++;(0,r.useEffect)((()=>{if(!j&&!W||z)return;let e=0;const t=setInterval((()=>{if(j&&re[j].current)re[j].current.focus(),clearInterval(t);else if(W)if(0===te.length)clearInterval(t);else{const e=te[0];re[e].current&&(re[e].current.focus(),clearInterval(t))}++e>=50&&clearInterval(t)}),50);K(0),U(!1)}),[j,W,z]);const oe=()=>{A&&(P(!1),T?K(T):q&&U(!0)),F(0),B(!1)},ie=e=>{oe();const t=[...te];t.includes(e)||t.push(e),n(u?t:t[0]),i.toasts.success(y.default._t("LinkField.SAVE_SUCCESS","Saved link"))},ae=(e,t)=>{const r=L[e]?.versionState||"",o=[E.default.draft,E.default.modified,E.default.published].includes(r),a=o?y.default._t("LinkField.ARCHIVE_CONFIRM","Are you sure you want to archive this link?"):y.default._t("LinkField.DELETE_CONFIRM","Are you sure you want to delete this link?");if(!window.confirm(a))return!1;let l=(0,b.joinUrlPaths)(h.default.getSection(_).form.linkForm.deleteUrl,e.toString());const s=w.default.parse(l),c=x.default.parse(s.query);c.ownerID=k,c.ownerClass=D,c.ownerRelation=O,l=w.default.format({...s,search:x.default.stringify(c)});const d=o?y.default._t("LinkField.ARCHIVE_SUCCESS","Archived link"):y.default._t("LinkField.DELETE_SUCCESS","Deleted link"),f=o?y.default._t("LinkField.ARCHIVE_ERROR","Failed to archive link"):y.default._t("LinkField.DELETE_ERROR","Failed to delete link");v.default.delete(l,{},{"X-SecurityID":h.default.get("SecurityID")}).then((()=>i.toasts.success(d))).catch((()=>i.toasts.error(f)));const p={...L};delete p[e],N(p),n(u?Object.keys(p):0)},le=()=>{const e=[".cms-edit-form button[data-text-alternate]#Form_EditForm_action_publish",".cms-edit-form button[data-text-alternate]#Form_ItemEditForm_action_doPublish"].join(","),t=document.querySelector(e);if(!t)return;(t.getAttribute("data-btn-alternate-remove")||"").split(" ").forEach((e=>{e&&t.classList.remove(e)}));(t.getAttribute("data-btn-alternate-add")||"").split(" ").forEach((e=>{e&&t.classList.add(e)}));const n=t.getAttribute("data-text-alternate");n&&(t.innerHTML=n)},se=e=>{Z((0,C.default)({"link-picker__links":!0,"link-picker__links--dragging":!0})),G(!0)},ue=e=>{const{active:t,over:r}=e;if(Z((0,C.default)({"link-picker__links":!0,"link-picker__links--dragging":!1})),t.id===r.id)return void G(!1);const o=te.indexOf(t.id),a=te.indexOf(r.id),s=(0,l.arrayMove)(te,o,a);n(s);let u=`${h.default.getSection(_).form.linkForm.sortUrl}`;v.default.post(u,{newLinkIDs:s},{"X-SecurityID":h.default.get("SecurityID")}).then((async()=>{n(s),i.toasts.success(y.default._t("LinkField.SORT_SUCCESS","Updated link sort order")),$(Y+1)})).catch((()=>{i.toasts.error(y.default._t("LinkField.SORT_ERROR","Failed to sort links"))}))},ce=!H&&0===k,de=H,fe=!H&&!I&&!ce&&(u||0===te.length),pe=!H&&!ce&&Boolean(T),ge=y.default._t("LinkField.FAILED_TO_LOAD_LINKS","Failed to load link(s)"),ve=y.default._t("LinkField.SAVE_RECORD_FIRST","Cannot add links until the record has been saved"),he=(()=>{const e=[];for(let t=0;t{F(n)},onButtonKeyDownEdit:()=>P(!0),onUnpublishedVersionedState:le,canDelete:!!i.canDelete,isMulti:u,isFirst:0===t,isLast:t===te.length-1,isSorting:J,canCreate:g,readonly:m,disabled:R,buttonRef:re[n]}))}return e})();return r.default.createElement(S.Provider,{value:{ownerID:k,ownerClass:D,ownerRelation:O,actions:i,loading:z,excludeLinkTextField:M,inHistoryViewer:I}},r.default.createElement("div",{className:"link-field__container"},de&&r.default.createElement("div",{className:"link-field__loading-error"},ge),ce&&r.default.createElement("div",{className:"link-field__save-record-first"},ve),z&&!J&&!ce&&r.default.createElement(f.default,{containerClass:"link-field__loading"}),fe&&r.default.createElement(c.default,{onModalSuccess:ie,onModalClosed:oe,types:o,canCreate:g,readonly:m,disabled:R,onKeyDownEdit:()=>{u||B(!0),P(!0)},isKeyboardEditing:A}),!u||m||R?r.default.createElement("div",null,he):r.default.createElement("div",{className:Q,onBlur:()=>G(!1)},r.default.createElement(a.DndContext,{modifiers:[s.restrictToVerticalAxis,s.restrictToParentElement],sensors:ee,collisionDetection:a.closestCenter,onDragStart:se,onDragEnd:ue},r.default.createElement("ol",{className:"link-picker__list"},r.default.createElement(l.SortableContext,{items:te,strategy:l.verticalListSortingStrategy},he)))),pe&&r.default.createElement(p.default,{types:o,typeKey:L[T]?.typeKey,isOpen:Boolean(T),onSuccess:ie,onClosed:oe,linkID:T,autoFocus:A})))};t.Component=O,O.propTypes={value:m.default.oneOfType([m.default.arrayOf(m.default.number),m.default.number]),onChange:m.default.func,types:m.default.object.isRequired,actions:m.default.object.isRequired,isMulti:m.default.bool,canCreate:m.default.bool.isRequired,readonly:m.default.bool.isRequired,disabled:m.default.bool.isRequired,ownerID:m.default.number.isRequired,ownerClass:m.default.string.isRequired,ownerRelation:m.default.string.isRequired,excludeLinkTextField:m.default.bool,inHistoryViewer:m.default.bool};t.default=(0,o.compose)(u.default,(0,i.connect)(null,(e=>({actions:{toasts:(0,o.bindActionCreators)(g,e)}}))))(O)},985:function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var r=function(e,t){if(!t&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var n=f(t);if(n&&n.has(e))return n.get(e);var r={__proto__:null},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var i in e)if("default"!==i&&{}.hasOwnProperty.call(e,i)){var a=o?Object.getOwnPropertyDescriptor(e,i):null;a&&(a.get||a.set)?Object.defineProperty(r,i,a):r[i]=e[i]}return r.default=e,n&&n.set(e,r),r}(n(594)),o=d(n(737)),i=n(853),a=d(n(8)),l=d(n(675)),s=d(n(177)),u=n(125),c=d(n(935));function d(e){return e&&e.__esModule?e:{default:e}}function f(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,n=new WeakMap;return(f=function(e){return e?n:t})(e)}const p=(e,t)=>{const{schemaUrl:n}=s.default.getSection("SilverStripe\\LinkField\\Controllers\\LinkFieldController").form.linkForm,o=a.default.parse(n),c=l.default.parse(o.query);c.typeKey=e;const{ownerID:d,ownerClass:f,ownerRelation:p,excludeLinkTextField:g,inHistoryViewer:v}=(0,r.useContext)(i.LinkFieldContext);c.ownerID=d,c.ownerClass=f,c.ownerRelation=p,g&&(c.excludeLinkTextField=!0),v&&(c.inHistoryViewer="1");for(const e of["href","path","pathname"])o[e]=(0,u.joinUrlPaths)(o[e],t.toString());return a.default.format({...o,search:l.default.stringify(c)})},g=e=>{let{typeTitle:t,typeKey:n,linkID:a=0,isOpen:l,onSuccess:s,onClosed:u,autoFocus:c}=e;const{actions:d}=(0,r.useContext)(i.LinkFieldContext);if(!n)return!1;return r.default.createElement(o.default,{title:t,isOpen:l,schemaUrl:p(n,a),identifier:"Link.EditingLinkInfo",onSubmit:async(e,t,n)=>{let r=null;try{r=await n()}catch(e){return d.toasts.error(i18n._t("LinkField.FAILED_TO_SAVE_LINK","Failed to save link")),Promise.resolve()}if(!r.id.match(/\/schema\/linkfield\/([0-9]+)/)){const e=r.id.match(/\/linkForm\/([0-9]+)/),t=parseInt(e[1],10);s(t)}return Promise.resolve()},onClosed:u,autoFocus:c})};g.propTypes={typeTitle:c.default.string.isRequired,typeKey:c.default.string.isRequired,linkID:c.default.number,isOpen:c.default.bool.isRequired,onSuccess:c.default.func.isRequired,onClosed:c.default.func.isRequired,autoFocus:c.default.bool};t.default=g},135:function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.default=t.Component=void 0;var r=c(n(815)),o=function(e,t){if(!t&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var n=u(t);if(n&&n.has(e))return n.get(e);var r={__proto__:null},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var i in e)if("default"!==i&&{}.hasOwnProperty.call(e,i)){var a=o?Object.getOwnPropertyDescriptor(e,i):null;a&&(a.get||a.set)?Object.defineProperty(r,i,a):r[i]=e[i]}return r.default=e,n&&n.set(e,r),r}(n(594)),i=c(n(935)),a=c(n(923)),l=c(n(164)),s=c(n(864));function u(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,n=new WeakMap;return(u=function(e){return e?n:t})(e)}function c(e){return e&&e.__esModule?e:{default:e}}const d=e=>{let{types:t,onModalSuccess:n,onModalClosed:i,canCreate:u,readonly:c,disabled:d,onKeyDownEdit:f,isKeyboardEditing:p}=e;const[g,v]=(0,o.useState)(""),h=""!==g,b=(0,a.default)("link-picker","form-control"),m=Object.values(t),y=m.filter((e=>e.allowed)),w=r.default._t("LinkField.CANNOT_CREATE_LINK","Cannot create link");return!u||0===y.length||c||d?o.default.createElement("div",{className:b},o.default.createElement("div",{className:"link-picker__cannot-create"},w)):o.default.createElement("div",{className:b},o.default.createElement(l.default,{types:m,onSelect:e=>{v(e)},onKeyDownEdit:f}),h&&o.default.createElement(s.default,{types:t,typeKey:g,isOpen:h,onSuccess:e=>{v(""),n(e)},onClosed:()=>{"function"==typeof i&&i(),v("")},autoFocus:p}))};t.Component=d,d.propTypes={types:i.default.object.isRequired,onModalSuccess:i.default.func.isRequired,onModalClosed:i.default.func,canCreate:i.default.bool.isRequired,readonly:i.default.bool.isRequired,disabled:i.default.bool.isRequired,onKeyDownEdit:i.default.func.isRequired,isKeyboardEditing:i.default.bool};t.default=d},164:function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var r=c(n(815)),o=function(e,t){if(!t&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var n=u(t);if(n&&n.has(e))return n.get(e);var r={__proto__:null},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var i in e)if("default"!==i&&{}.hasOwnProperty.call(e,i)){var a=o?Object.getOwnPropertyDescriptor(e,i):null;a&&(a.get||a.set)?Object.defineProperty(r,i,a):r[i]=e[i]}return r.default=e,n&&n.set(e,r),r}(n(594)),i=c(n(935)),a=n(556),l=n(853),s=c(n(159));function u(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,n=new WeakMap;return(u=function(e){return e?n:t})(e)}function c(e){return e&&e.__esModule?e:{default:e}}const d=e=>{let{types:t,onSelect:n,onKeyDownEdit:i}=e;const[s,u]=(0,o.useState)(!1),{loading:c}=(0,o.useContext)(l.LinkFieldContext),d=e=>{["Enter","Space"].includes(e.code)&&i()},f=r.default._t("LinkField.ADD_LINK","Add link");return o.default.createElement(a.Dropdown,{disabled:c,isOpen:s,toggle:()=>u((e=>!e)),className:"link-picker__menu"},o.default.createElement(a.DropdownToggle,{className:"link-picker__menu-toggle font-icon-plus-1",caret:!0,color:"secondary","aria-label":f},r.default._t("LinkField.ADD_LINK","Add Link")),o.default.createElement(a.DropdownMenu,null,t.map((e=>{let{key:t,title:r,icon:i,allowed:l}=e;return l&&o.default.createElement(a.DropdownItem,{key:t,onClick:()=>{n(t)},onKeyDown:d},o.default.createElement("span",{className:`link-picker__menu-icon ${i}`}),o.default.createElement("span",{className:"link-picker__menu-title"},r))}))))};d.propTypes={types:i.default.arrayOf(s.default).isRequired,onSelect:i.default.func.isRequired,onKeyDownEdit:i.default.func.isRequired};t.default=d},137:function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var r=p(n(923)),o=p(n(815)),i=function(e,t){if(!t&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var n=f(t);if(n&&n.has(e))return n.get(e);var r={__proto__:null},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var i in e)if("default"!==i&&{}.hasOwnProperty.call(e,i)){var a=o?Object.getOwnPropertyDescriptor(e,i):null;a&&(a.get||a.set)?Object.defineProperty(r,i,a):r[i]=e[i]}return r.default=e,n&&n.set(e,r),r}(n(594)),a=p(n(935)),l=n(853),s=n(556),u=n(627),c=n(979),d=p(n(489));function f(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,n=new WeakMap;return(f=function(e){return e?n:t})(e)}function p(e){return e&&e.__esModule?e:{default:e}}function g(){return g=Object.assign?Object.assign.bind():function(e){for(var t=1;tt=>{t.nativeEvent.stopImmediatePropagation(),t.preventDefault(),t.nativeEvent.preventDefault(),t.stopPropagation(),e&&e()},h=e=>{let{id:t,title:n,description:a,versionState:f,typeTitle:p,typeIcon:h,onDelete:b,onClick:m,onButtonKeyDownEdit:y,onUnpublishedVersionedState:w,canDelete:x,isMulti:C,isFirst:E,isLast:R,isSorting:k,canCreate:D,readonly:S,disabled:_,buttonRef:O}=e;const{loading:M}=(0,i.useContext)(l.LinkFieldContext),{attributes:I,listeners:L,setNodeRef:N,transform:T,transition:F}=(0,u.useSortable)({id:t}),A={transform:c.CSS.Transform.toString(T),transition:F},P={"link-picker__link":!0,"link-picker__link--is-first":E,"link-picker__link--is-last":R,"link-picker__link--is-sorting":k,"form-control":!0,"link-picker__link--readonly":S||!D,"link-picker__link--disabled":_};f&&(P[`link-picker__link--${f}`]=!0);const j=(0,r.default)(P),K=[d.default.unversioned,d.default.unsaved].includes(f)?o.default._t("LinkField.DELETE","Delete"):o.default._t("LinkField.ARCHIVE","Archive"),q=o.default._t("LinkField.EDIT_LINK","Edit link");[d.default.draft,d.default.modified].includes(f)&&w(),delete I.tabIndex;const B=`link-picker__link-${t}`,W=C?"li":"div";return i.default.createElement(W,g({className:j,ref:N,style:A},I,L,{id:B}),C&&!S&&!_&&i.default.createElement("div",{className:"link-picker__drag-handle",tabIndex:"0",role:"button","aria-pressed":"false","aria-controls":B,"aria-label":"Sort Links",onKeyDown:e=>{if(!["Enter","Space"].includes(e.code))return;const t=e.target,n="true"===t.getAttribute("aria-pressed")?"false":"true";t.setAttribute("aria-pressed",n)}},i.default.createElement("i",{className:"font-icon-drag-handle","aria-hidden":"true",focusable:"false"})),i.default.createElement(s.Button,{"aria-label":q,disabled:M,className:`link-picker__button ${h}`,color:"secondary",onClick:v(m),innerRef:O,onKeyDown:e=>{e.nativeEvent.stopImmediatePropagation(),e.stopPropagation(),["Enter","Space"].includes(e.code)&&!M&&y(e)}},i.default.createElement("div",{className:"link-picker__link-detail"},i.default.createElement("div",{className:"link-picker__title"},i.default.createElement("span",{className:"link-picker__title-text"},n),(e=>{let t="",n="";if(e===d.default.draft)t=o.default._t("LinkField.LINK_DRAFT_TITLE","Link has draft changes"),n=o.default._t("LinkField.LINK_DRAFT_LABEL","Draft");else{if(e!==d.default.modified)return null;t=o.default._t("LinkField.LINK_MODIFIED_TITLE","Link has unpublished changes"),n=o.default._t("LinkField.LINK_MODIFIED_LABEL","Modified")}const a=(0,r.default)("badge",`status-${e}`);return i.default.createElement("span",{className:a,title:t},n)})(f)),p&&i.default.createElement("small",{className:"link-picker__type"},p,": ",i.default.createElement("span",{className:"link-picker__url"},a))),x&&!S&&!_&&i.default.createElement("span",{"aria-label":K,role:"button",tabIndex:"0",className:"link-picker__delete btn btn-link",onKeyDown:e=>{["Enter","Space"].includes(e.code)&&!M&&(e.nativeEvent.stopImmediatePropagation(),e.stopPropagation(),b(t),e.nativeEvent.preventDefault(),e.preventDefault())},onClick:v((()=>M?null:b(t)))},K)))};h.propTypes={id:a.default.number.isRequired,title:a.default.string,description:a.default.string,versionState:a.default.oneOf(Object.values(d.default)),typeTitle:a.default.string.isRequired,typeIcon:a.default.string.isRequired,onDelete:a.default.func.isRequired,onClick:a.default.func.isRequired,onButtonKeyDownEdit:a.default.func.isRequired,onUnpublishedVersionedState:a.default.func.isRequired,canDelete:a.default.bool.isRequired,isMulti:a.default.bool.isRequired,isFirst:a.default.bool.isRequired,isLast:a.default.bool.isRequired,isSorting:a.default.bool.isRequired,canCreate:a.default.bool.isRequired,readonly:a.default.bool.isRequired,disabled:a.default.bool.isRequired,buttonRef:a.default.object.isRequired},h.defaultProps={versionState:d.default.unversioned};t.default=h},489:function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;t.default={draft:"draft",modified:"modified",unversioned:"unversioned",unsaved:"unsaved",published:"published"}},864:function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var r,o=function(e,t){if(!t&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var n=l(t);if(n&&n.has(e))return n.get(e);var r={__proto__:null},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var i in e)if("default"!==i&&{}.hasOwnProperty.call(e,i)){var a=o?Object.getOwnPropertyDescriptor(e,i):null;a&&(a.get||a.set)?Object.defineProperty(r,i,a):r[i]=e[i]}return r.default=e,n&&n.set(e,r),r}(n(594)),i=n(207),a=(r=n(935))&&r.__esModule?r:{default:r};function l(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,n=new WeakMap;return(l=function(e){return e?n:t})(e)}const s=e=>{let{types:t,typeKey:n,linkID:r=0,isOpen:a,onSuccess:l,onClosed:s,autoFocus:u}=e;const[c,d]=(0,o.useState)(null);if(!n)return!1;const f=t.hasOwnProperty(n)?t[n]:{},p=f&&f.hasOwnProperty("handlerName")?f.handlerName:"FormBuilderModal";if(c)return o.default.createElement(c,{typeTitle:f.title||"",typeKey:n,linkID:r,isOpen:a,onSuccess:l,onClosed:s,autoFocus:u});d((()=>(0,i.loadComponent)(`LinkModal.${p}`)))};s.propTypes={types:a.default.object.isRequired,typeKey:a.default.string.isRequired,linkID:a.default.number,isOpen:a.default.bool.isRequired,onSuccess:a.default.func.isRequired,onClosed:a.default.func.isRequired,autoFocus:a.default.bool};t.default=s},406:function(e,t,n){var r=l(n(669)),o=l(n(594)),i=l(n(145)),a=n(207);function l(e){return e&&e.__esModule?e:{default:e}}function s(){return s=Object.assign?Object.assign.bind():function(e){for(var t=1;t{e(".js-injector-boot .entwine-linkfield").entwine({Component:null,Root:null,onmatch(){const e=this.closest(".cms-content").attr("id"),t=e?{context:e}:{},n=this.data("schema-component"),r=(0,a.loadComponent)(n,t);this.setComponent(r),this.setRoot(i.default.createRoot(this[0])),this._super(),this.refresh()},refresh(){const e=this.getProps();this.getInputField().val(e.value);const t=this.getComponent();this.getRoot().render(o.default.createElement(t,s({},e,{noHolder:!0})))},handleChange(e){this.getInputField().data("value",e),this.refresh()},getProps(){const e=this.getInputField();return{value:e.data("value"),ownerID:e.data("owner-id"),ownerClass:e.data("owner-class"),ownerRelation:e.data("owner-relation"),excludeLinkTextField:e.data("exclude-linktext-field"),onChange:this.handleChange.bind(this),isMulti:this.data("is-multi")??!1,types:this.data("types")??{},canCreate:!!e.data("can-create"),readonly:!!e.data("readonly"),disabled:!!e.data("disabled"),inHistoryViewer:!!e.data("in-history-viewer")}},getInputField(){const t=this.data("field-id");return e(`#${t}`)},onunmatch(){const e=this.getRoot();e&&e.unmount()}})}))},159:function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var r,o=(r=n(935))&&r.__esModule?r:{default:r};const i=o.default.shape({key:o.default.string.isRequired,title:o.default.string.isRequired,icon:o.default.string.isRequired});t.default=i},609:function(e){e.exports=Backend},177:function(e){e.exports=Config},623:function(e){e.exports=FieldHolder},737:function(e){e.exports=FormBuilderModal},207:function(e){e.exports=Injector},89:function(e){e.exports=Loading},8:function(e){e.exports=NodeUrl},935:function(e){e.exports=PropTypes},594:function(e){e.exports=React},145:function(e){e.exports=ReactDomClient},40:function(e){e.exports=ReactRedux},556:function(e){e.exports=Reactstrap},367:function(e){e.exports=Redux},918:function(e){e.exports=ToastsActions},923:function(e){e.exports=classnames},815:function(e){e.exports=i18n},669:function(e){e.exports=jQuery},675:function(e){e.exports=qs},125:function(e){e.exports=ssUrlLib}},t={};function n(r){var o=t[r];if(void 0!==o)return o.exports;var i=t[r]={exports:{}};return e[r](i,i.exports,n),i.exports}n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,{a:t}),t},n.d=function(e,t){for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n(38),n(406)}(); \ No newline at end of file +!function(){"use strict";var e={733:function(e,t,n){n.r(t),n.d(t,{AutoScrollActivator:function(){return xe},DndContext:function(){return Ge},DragOverlay:function(){return bt},KeyboardCode:function(){return ie},KeyboardSensor:function(){return ce},MeasuringFrequency:function(){return Se},MeasuringStrategy:function(){return ke},MouseSensor:function(){return me},PointerSensor:function(){return ve},TouchSensor:function(){return we},TraversalOrder:function(){return Ce},applyModifiers:function(){return Ye},closestCenter:function(){return D},closestCorners:function(){return _},defaultAnnouncements:function(){return p},defaultCoordinates:function(){return y},defaultDropAnimation:function(){return pt},defaultDropAnimationSideEffects:function(){return ft},defaultScreenReaderInstructions:function(){return f},getClientRect:function(){return j},getFirstCollision:function(){return k},getScrollableAncestors:function(){return K},pointerWithin:function(){return I},rectIntersection:function(){return M},useDndContext:function(){return nt},useDndMonitor:function(){return d},useDraggable:function(){return tt},useDroppable:function(){return it},useSensor:function(){return b},useSensors:function(){return m}});var r=n(594),o=n.n(r),i=ReactDom,a=n(979);const l={display:"none"};function s(e){let{id:t,value:n}=e;return o().createElement("div",{id:t,style:l},n)}function u(e){let{id:t,announcement:n,ariaLiveType:r="assertive"}=e;return o().createElement("div",{id:t,style:{position:"fixed",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"},role:"status","aria-live":r,"aria-atomic":!0},n)}const c=(0,r.createContext)(null);function d(e){const t=(0,r.useContext)(c);(0,r.useEffect)((()=>{if(!t)throw new Error("useDndMonitor must be used within a children of ");return t(e)}),[e,t])}const f={draggable:"\n To pick up a draggable item, press the space bar.\n While dragging, use the arrow keys to move the item.\n Press space again to drop the item in its new position, or press escape to cancel.\n "},p={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 g(e){let{announcements:t=p,container:n,hiddenTextDescribedById:l,screenReaderInstructions:c=f}=e;const{announce:g,announcement:v}=function(){const[e,t]=(0,r.useState)("");return{announce:(0,r.useCallback)((e=>{null!=e&&t(e)}),[]),announcement:e}}(),h=(0,a.useUniqueId)("DndLiveRegion"),[b,m]=(0,r.useState)(!1);if((0,r.useEffect)((()=>{m(!0)}),[]),d((0,r.useMemo)((()=>({onDragStart(e){let{active:n}=e;g(t.onDragStart({active:n}))},onDragMove(e){let{active:n,over:r}=e;t.onDragMove&&g(t.onDragMove({active:n,over:r}))},onDragOver(e){let{active:n,over:r}=e;g(t.onDragOver({active:n,over:r}))},onDragEnd(e){let{active:n,over:r}=e;g(t.onDragEnd({active:n,over:r}))},onDragCancel(e){let{active:n,over:r}=e;g(t.onDragCancel({active:n,over:r}))}})),[g,t])),!b)return null;const y=o().createElement(o().Fragment,null,o().createElement(s,{id:l,value:c.draggable}),o().createElement(u,{id:h,announcement:v}));return n?(0,i.createPortal)(y,n):y}var v;function h(){}function b(e,t){return(0,r.useMemo)((()=>({sensor:e,options:null!=t?t:{}})),[e,t])}function m(){for(var e=arguments.length,t=new Array(e),n=0;n[...t].filter((e=>null!=e))),[...t])}!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"}(v||(v={}));const y=Object.freeze({x:0,y:0});function w(e,t){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}function x(e,t){const n=(0,a.getEventCoordinates)(e);if(!n)return"0 0";return(n.x-t.left)/t.width*100+"% "+(n.y-t.top)/t.height*100+"%"}function C(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return n-r}function E(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return r-n}function R(e){let{left:t,top:n,height:r,width:o}=e;return[{x:t,y:n},{x:t+o,y:n},{x:t,y:n+r},{x:t+o,y:n+r}]}function k(e,t){if(!e||0===e.length)return null;const[n]=e;return t?n[t]:n}function S(e,t,n){return void 0===t&&(t=e.left),void 0===n&&(n=e.top),{x:t+.5*e.width,y:n+.5*e.height}}const D=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const o=S(t,t.left,t.top),i=[];for(const e of r){const{id:t}=e,r=n.get(t);if(r){const n=w(S(r),o);i.push({id:t,data:{droppableContainer:e,value:n}})}}return i.sort(C)},_=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const o=R(t),i=[];for(const e of r){const{id:t}=e,r=n.get(t);if(r){const n=R(r),a=o.reduce(((e,t,r)=>e+w(n[r],t)),0),l=Number((a/4).toFixed(4));i.push({id:t,data:{droppableContainer:e,value:l}})}}return i.sort(C)};function O(e,t){const n=Math.max(t.top,e.top),r=Math.max(t.left,e.left),o=Math.min(t.left+t.width,e.left+e.width),i=Math.min(t.top+t.height,e.top+e.height),a=o-r,l=i-n;if(r{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const o=[];for(const e of r){const{id:r}=e,i=n.get(r);if(i){const n=O(i,t);n>0&&o.push({id:r,data:{droppableContainer:e,value:n}})}}return o.sort(E)};function L(e,t){const{top:n,left:r,bottom:o,right:i}=t;return n<=e.y&&e.y<=o&&r<=e.x&&e.x<=i}const I=e=>{let{droppableContainers:t,droppableRects:n,pointerCoordinates:r}=e;if(!r)return[];const o=[];for(const e of t){const{id:t}=e,i=n.get(t);if(i&&L(r,i)){const n=R(i).reduce(((e,t)=>e+w(r,t)),0),a=Number((n/4).toFixed(4));o.push({id:t,data:{droppableContainer:e,value:a}})}}return o.sort(C)};function N(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:y}function T(e){return function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o({...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})}}const A=T(1);function F(e){if(e.startsWith("matrix3d(")){const t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}if(e.startsWith("matrix(")){const t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}const P={ignoreTransform:!1};function j(e,t){void 0===t&&(t=P);let n=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:t,transformOrigin:r}=(0,a.getWindow)(e).getComputedStyle(e);t&&(n=function(e,t,n){const r=F(t);if(!r)return e;const{scaleX:o,scaleY:i,x:a,y:l}=r,s=e.left-a-(1-o)*parseFloat(n),u=e.top-l-(1-i)*parseFloat(n.slice(n.indexOf(" ")+1)),c=o?e.width/o:e.width,d=i?e.height/i:e.height;return{width:c,height:d,top:u,right:s+c,bottom:u+d,left:s}}(n,t,r))}const{top:r,left:o,width:i,height:l,bottom:s,right:u}=n;return{top:r,left:o,width:i,height:l,bottom:s,right:u}}function q(e){return j(e,{ignoreTransform:!0})}function K(e,t){const n=[];return e?function r(o){if(null!=t&&n.length>=t)return n;if(!o)return n;if((0,a.isDocument)(o)&&null!=o.scrollingElement&&!n.includes(o.scrollingElement))return n.push(o.scrollingElement),n;if(!(0,a.isHTMLElement)(o)||(0,a.isSVGElement)(o))return n;if(n.includes(o))return n;const i=(0,a.getWindow)(e).getComputedStyle(o);return o!==e&&function(e,t){void 0===t&&(t=(0,a.getWindow)(e).getComputedStyle(e));const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some((e=>{const r=t[e];return"string"==typeof r&&n.test(r)}))}(o,i)&&n.push(o),function(e,t){return void 0===t&&(t=(0,a.getWindow)(e).getComputedStyle(e)),"fixed"===t.position}(o,i)?n:r(o.parentNode)}(e):n}function W(e){const[t]=K(e,1);return null!=t?t:null}function B(e){return a.canUseDOM&&e?(0,a.isWindow)(e)?e:(0,a.isNode)(e)?(0,a.isDocument)(e)||e===(0,a.getOwnerDocument)(e).scrollingElement?window:(0,a.isHTMLElement)(e)?e:null:null:null}function U(e){return(0,a.isWindow)(e)?e.scrollX:e.scrollLeft}function z(e){return(0,a.isWindow)(e)?e.scrollY:e.scrollTop}function V(e){return{x:U(e),y:z(e)}}var H;function X(e){return!(!a.canUseDOM||!e)&&e===document.scrollingElement}function Y(e){const t={x:0,y:0},n=X(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}}!function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"}(H||(H={}));const $={x:.2,y:.2};function J(e,t,n,r,o){let{top:i,left:a,right:l,bottom:s}=n;void 0===r&&(r=10),void 0===o&&(o=$);const{isTop:u,isBottom:c,isLeft:d,isRight:f}=Y(e),p={x:0,y:0},g={x:0,y:0},v=t.height*o.y,h=t.width*o.x;return!u&&i<=t.top+v?(p.y=H.Backward,g.y=r*Math.abs((t.top+v-i)/v)):!c&&s>=t.bottom-v&&(p.y=H.Forward,g.y=r*Math.abs((t.bottom-v-s)/v)),!f&&l>=t.right-h?(p.x=H.Forward,g.x=r*Math.abs((t.right-h-l)/h)):!d&&a<=t.left+h&&(p.x=H.Backward,g.x=r*Math.abs((t.left+h-a)/h)),{direction:p,speed:g}}function G(e){if(e===document.scrollingElement){const{innerWidth:e,innerHeight:t}=window;return{top:0,left:0,right:e,bottom:t,width:e,height:t}}const{top:t,left:n,right:r,bottom:o}=e.getBoundingClientRect();return{top:t,left:n,right:r,bottom:o,width:e.clientWidth,height:e.clientHeight}}function Q(e){return e.reduce(((e,t)=>(0,a.add)(e,V(t))),y)}function Z(e,t){if(void 0===t&&(t=j),!e)return;const{top:n,left:r,bottom:o,right:i}=t(e);W(e)&&(o<=0||i<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const ee=[["x",["left","right"],function(e){return e.reduce(((e,t)=>e+U(t)),0)}],["y",["top","bottom"],function(e){return e.reduce(((e,t)=>e+z(t)),0)}]];class te{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;const n=K(t),r=Q(n);this.rect={...e},this.width=e.width,this.height=e.height;for(const[e,t,o]of ee)for(const i of t)Object.defineProperty(this,i,{get:()=>{const t=o(n),a=r[e]-t;return this.rect[i]+a},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class ne{constructor(e){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach((e=>{var t;return null==(t=this.target)?void 0:t.removeEventListener(...e)}))},this.target=e}add(e,t,n){var r;null==(r=this.target)||r.addEventListener(e,t,n),this.listeners.push([e,t,n])}}function re(e,t){const n=Math.abs(e.x),r=Math.abs(e.y);return"number"==typeof t?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}var oe,ie;function ae(e){e.preventDefault()}function le(e){e.stopPropagation()}!function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"}(oe||(oe={})),function(e){e.Space="Space",e.Down="ArrowDown",e.Right="ArrowRight",e.Left="ArrowLeft",e.Up="ArrowUp",e.Esc="Escape",e.Enter="Enter"}(ie||(ie={}));const se={start:[ie.Space,ie.Enter],cancel:[ie.Esc],end:[ie.Space,ie.Enter]},ue=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case ie.Right:return{...n,x:n.x+25};case ie.Left:return{...n,x:n.x-25};case ie.Down:return{...n,y:n.y+25};case ie.Up:return{...n,y:n.y-25}}};class ce{constructor(e){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=e;const{event:{target:t}}=e;this.props=e,this.listeners=new ne((0,a.getOwnerDocument)(t)),this.windowListeners=new ne((0,a.getWindow)(t)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(oe.Resize,this.handleCancel),this.windowListeners.add(oe.VisibilityChange,this.handleCancel),setTimeout((()=>this.listeners.add(oe.Keydown,this.handleKeyDown)))}handleStart(){const{activeNode:e,onStart:t}=this.props,n=e.node.current;n&&Z(n),t(y)}handleKeyDown(e){if((0,a.isKeyboardEvent)(e)){const{active:t,context:n,options:r}=this.props,{keyboardCodes:o=se,coordinateGetter:i=ue,scrollBehavior:l="smooth"}=r,{code:s}=e;if(o.end.includes(s))return void this.handleEnd(e);if(o.cancel.includes(s))return void this.handleCancel(e);const{collisionRect:u}=n.current,c=u?{x:u.left,y:u.top}:y;this.referenceCoordinates||(this.referenceCoordinates=c);const d=i(e,{active:t,context:n.current,currentCoordinates:c});if(d){const t=(0,a.subtract)(d,c),r={x:0,y:0},{scrollableAncestors:o}=n.current;for(const n of o){const o=e.code,{isTop:i,isRight:a,isLeft:s,isBottom:u,maxScroll:c,minScroll:f}=Y(n),p=G(n),g={x:Math.min(o===ie.Right?p.right-p.width/2:p.right,Math.max(o===ie.Right?p.left:p.left+p.width/2,d.x)),y:Math.min(o===ie.Down?p.bottom-p.height/2:p.bottom,Math.max(o===ie.Down?p.top:p.top+p.height/2,d.y))},v=o===ie.Right&&!a||o===ie.Left&&!s,h=o===ie.Down&&!u||o===ie.Up&&!i;if(v&&g.x!==d.x){const e=n.scrollLeft+t.x,i=o===ie.Right&&e<=c.x||o===ie.Left&&e>=f.x;if(i&&!t.y)return void n.scrollTo({left:e,behavior:l});r.x=i?n.scrollLeft-e:o===ie.Right?n.scrollLeft-c.x:n.scrollLeft-f.x,r.x&&n.scrollBy({left:-r.x,behavior:l});break}if(h&&g.y!==d.y){const e=n.scrollTop+t.y,i=o===ie.Down&&e<=c.y||o===ie.Up&&e>=f.y;if(i&&!t.x)return void n.scrollTo({top:e,behavior:l});r.y=i?n.scrollTop-e:o===ie.Down?n.scrollTop-c.y:n.scrollTop-f.y,r.y&&n.scrollBy({top:-r.y,behavior:l});break}}this.handleMove(e,(0,a.add)((0,a.subtract)(d,this.referenceCoordinates),r))}}}handleMove(e,t){const{onMove:n}=this.props;e.preventDefault(),n(t)}handleEnd(e){const{onEnd:t}=this.props;e.preventDefault(),this.detach(),t()}handleCancel(e){const{onCancel:t}=this.props;e.preventDefault(),this.detach(),t()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}function de(e){return Boolean(e&&"distance"in e)}function fe(e){return Boolean(e&&"delay"in e)}ce.activators=[{eventName:"onKeyDown",handler:(e,t,n)=>{let{keyboardCodes:r=se,onActivation:o}=t,{active:i}=n;const{code:a}=e.nativeEvent;if(r.start.includes(a)){const t=i.activatorNode.current;return(!t||e.target===t)&&(e.preventDefault(),null==o||o({event:e.nativeEvent}),!0)}return!1}}];class pe{constructor(e,t,n){var r;void 0===n&&(n=function(e){const{EventTarget:t}=(0,a.getWindow)(e);return e instanceof t?e:(0,a.getOwnerDocument)(e)}(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;const{event:o}=e,{target:i}=o;this.props=e,this.events=t,this.document=(0,a.getOwnerDocument)(i),this.documentListeners=new ne(this.document),this.listeners=new ne(n),this.windowListeners=new ne((0,a.getWindow)(i)),this.initialCoordinates=null!=(r=(0,a.getEventCoordinates)(o))?r:y,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(){const{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),this.windowListeners.add(oe.Resize,this.handleCancel),this.windowListeners.add(oe.DragStart,ae),this.windowListeners.add(oe.VisibilityChange,this.handleCancel),this.windowListeners.add(oe.ContextMenu,ae),this.documentListeners.add(oe.Keydown,this.handleKeydown),t){if(null!=n&&n({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(fe(t))return void(this.timeoutId=setTimeout(this.handleStart,t.delay));if(de(t))return}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),null!==this.timeoutId&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handleStart(){const{initialCoordinates:e}=this,{onStart:t}=this.props;e&&(this.activated=!0,this.documentListeners.add(oe.Click,le,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(oe.SelectionChange,this.removeTextSelection),t(e))}handleMove(e){var t;const{activated:n,initialCoordinates:r,props:o}=this,{onMove:i,options:{activationConstraint:l}}=o;if(!r)return;const s=null!=(t=(0,a.getEventCoordinates)(e))?t:y,u=(0,a.subtract)(r,s);if(!n&&l){if(de(l)){if(null!=l.tolerance&&re(u,l.tolerance))return this.handleCancel();if(re(u,l.distance))return this.handleStart()}return fe(l)&&re(u,l.tolerance)?this.handleCancel():void 0}e.cancelable&&e.preventDefault(),i(s)}handleEnd(){const{onEnd:e}=this.props;this.detach(),e()}handleCancel(){const{onCancel:e}=this.props;this.detach(),e()}handleKeydown(e){e.code===ie.Esc&&this.handleCancel()}removeTextSelection(){var e;null==(e=this.document.getSelection())||e.removeAllRanges()}}const ge={move:{name:"pointermove"},end:{name:"pointerup"}};class ve extends pe{constructor(e){const{event:t}=e,n=(0,a.getOwnerDocument)(t.target);super(e,ge,n)}}ve.activators=[{eventName:"onPointerDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return!(!n.isPrimary||0!==n.button)&&(null==r||r({event:n}),!0)}}];const he={move:{name:"mousemove"},end:{name:"mouseup"}};var be;!function(e){e[e.RightClick=2]="RightClick"}(be||(be={}));class me extends pe{constructor(e){super(e,he,(0,a.getOwnerDocument)(e.event.target))}}me.activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button!==be.RightClick&&(null==r||r({event:n}),!0)}}];const ye={move:{name:"touchmove"},end:{name:"touchend"}};class we extends pe{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(){}}}var xe,Ce;function Ee(e){let{acceleration:t,activator:n=xe.Pointer,canScroll:o,draggingRect:i,enabled:l,interval:s=5,order:u=Ce.TreeOrder,pointerCoordinates:c,scrollableAncestors:d,scrollableAncestorRects:f,delta:p,threshold:g}=e;const v=function(e){let{delta:t,disabled:n}=e;const r=(0,a.usePrevious)(t);return(0,a.useLazyMemo)((e=>{if(n||!r||!e)return Re;const o={x:Math.sign(t.x-r.x),y:Math.sign(t.y-r.y)};return{x:{[H.Backward]:e.x[H.Backward]||-1===o.x,[H.Forward]:e.x[H.Forward]||1===o.x},y:{[H.Backward]:e.y[H.Backward]||-1===o.y,[H.Forward]:e.y[H.Forward]||1===o.y}}}),[n,t,r])}({delta:p,disabled:!l}),[h,b]=(0,a.useInterval)(),m=(0,r.useRef)({x:0,y:0}),y=(0,r.useRef)({x:0,y:0}),w=(0,r.useMemo)((()=>{switch(n){case xe.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case xe.DraggableRect:return i}}),[n,i,c]),x=(0,r.useRef)(null),C=(0,r.useCallback)((()=>{const e=x.current;if(!e)return;const t=m.current.x*y.current.x,n=m.current.y*y.current.y;e.scrollBy(t,n)}),[]),E=(0,r.useMemo)((()=>u===Ce.TreeOrder?[...d].reverse():d),[u,d]);(0,r.useEffect)((()=>{if(l&&d.length&&w){for(const e of E){if(!1===(null==o?void 0:o(e)))continue;const n=d.indexOf(e),r=f[n];if(!r)continue;const{direction:i,speed:a}=J(e,r,w,t,g);for(const e of["x","y"])v[e][i[e]]||(a[e]=0,i[e]=0);if(a.x>0||a.y>0)return b(),x.current=e,h(C,s),m.current=a,void(y.current=i)}m.current={x:0,y:0},y.current={x:0,y:0},b()}else b()}),[t,C,o,b,l,s,JSON.stringify(w),JSON.stringify(v),h,d,E,f,JSON.stringify(g)])}we.activators=[{eventName:"onTouchStart",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;const{touches:o}=n;return!(o.length>1)&&(null==r||r({event:n}),!0)}}],function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"}(xe||(xe={})),function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"}(Ce||(Ce={}));const Re={x:{[H.Backward]:!1,[H.Forward]:!1},y:{[H.Backward]:!1,[H.Forward]:!1}};var ke,Se;!function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"}(ke||(ke={})),function(e){e.Optimized="optimized"}(Se||(Se={}));const De=new Map;function _e(e,t){return(0,a.useLazyMemo)((n=>e?n||("function"==typeof t?t(e):e):null),[t,e])}function Oe(e){let{callback:t,disabled:n}=e;const o=(0,a.useEvent)(t),i=(0,r.useMemo)((()=>{if(n||"undefined"==typeof window||void 0===window.ResizeObserver)return;const{ResizeObserver:e}=window;return new e(o)}),[n]);return(0,r.useEffect)((()=>()=>null==i?void 0:i.disconnect()),[i]),i}function Me(e){return new te(j(e),e)}function Le(e,t,n){void 0===t&&(t=Me);const[o,i]=(0,r.useReducer)((function(r){if(!e)return null;var o;if(!1===e.isConnected)return null!=(o=null!=r?r:n)?o:null;const i=t(e);if(JSON.stringify(r)===JSON.stringify(i))return r;return i}),null),l=function(e){let{callback:t,disabled:n}=e;const o=(0,a.useEvent)(t),i=(0,r.useMemo)((()=>{if(n||"undefined"==typeof window||void 0===window.MutationObserver)return;const{MutationObserver:e}=window;return new e(o)}),[o,n]);return(0,r.useEffect)((()=>()=>null==i?void 0:i.disconnect()),[i]),i}({callback(t){if(e)for(const n of t){const{type:t,target:r}=n;if("childList"===t&&r instanceof HTMLElement&&r.contains(e)){i();break}}}}),s=Oe({callback:i});return(0,a.useIsomorphicLayoutEffect)((()=>{i(),e?(null==s||s.observe(e),null==l||l.observe(document.body,{childList:!0,subtree:!0})):(null==s||s.disconnect(),null==l||l.disconnect())}),[e]),o}const Ie=[];function Ne(e,t){void 0===t&&(t=[]);const n=(0,r.useRef)(null);return(0,r.useEffect)((()=>{n.current=null}),t),(0,r.useEffect)((()=>{const t=e!==y;t&&!n.current&&(n.current=e),!t&&n.current&&(n.current=null)}),[e]),n.current?(0,a.subtract)(e,n.current):y}function Te(e){return(0,r.useMemo)((()=>e?function(e){const t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}(e):null),[e])}const Ae=[];function Fe(e){if(!e)return null;if(e.children.length>1)return e;const t=e.children[0];return(0,a.isHTMLElement)(t)?t:e}const Pe=[{sensor:ve,options:{}},{sensor:ce,options:{}}],je={current:{}},qe={draggable:{measure:q},droppable:{measure:q,strategy:ke.WhileDragging,frequency:Se.Optimized},dragOverlay:{measure:j}};class Ke extends Map{get(e){var t;return null!=e&&null!=(t=super.get(e))?t:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter((e=>{let{disabled:t}=e;return!t}))}getNodeFor(e){var t,n;return null!=(t=null==(n=this.get(e))?void 0:n.node.current)?t:void 0}}const We={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new Ke,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:h},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:qe,measureDroppableContainers:h,windowRect:null,measuringScheduled:!1},Be={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:h,draggableNodes:new Map,over:null,measureDroppableContainers:h},Ue=(0,r.createContext)(Be),ze=(0,r.createContext)(We);function Ve(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new Ke}}}function He(e,t){switch(t.type){case v.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case v.DragMove:return e.draggable.active?{...e,draggable:{...e.draggable,translate:{x:t.coordinates.x-e.draggable.initialCoordinates.x,y:t.coordinates.y-e.draggable.initialCoordinates.y}}}:e;case v.DragEnd:case v.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case v.RegisterDroppable:{const{element:n}=t,{id:r}=n,o=new Ke(e.droppable.containers);return o.set(r,n),{...e,droppable:{...e.droppable,containers:o}}}case v.SetDroppableDisabled:{const{id:n,key:r,disabled:o}=t,i=e.droppable.containers.get(n);if(!i||r!==i.key)return e;const a=new Ke(e.droppable.containers);return a.set(n,{...i,disabled:o}),{...e,droppable:{...e.droppable,containers:a}}}case v.UnregisterDroppable:{const{id:n,key:r}=t,o=e.droppable.containers.get(n);if(!o||r!==o.key)return e;const i=new Ke(e.droppable.containers);return i.delete(n),{...e,droppable:{...e.droppable,containers:i}}}default:return e}}function Xe(e){let{disabled:t}=e;const{active:n,activatorEvent:o,draggableNodes:i}=(0,r.useContext)(Ue),l=(0,a.usePrevious)(o),s=(0,a.usePrevious)(null==n?void 0:n.id);return(0,r.useEffect)((()=>{if(!t&&!o&&l&&null!=s){if(!(0,a.isKeyboardEvent)(l))return;if(document.activeElement===l.target)return;const e=i.get(s);if(!e)return;const{activatorNode:t,node:n}=e;if(!t.current&&!n.current)return;requestAnimationFrame((()=>{for(const e of[t.current,n.current]){if(!e)continue;const t=(0,a.findFirstFocusableNode)(e);if(t){t.focus();break}}}))}}),[o,t,i,s,l]),null}function Ye(e,t){let{transform:n,...r}=t;return null!=e&&e.length?e.reduce(((e,t)=>t({transform:e,...r})),n):n}const $e=(0,r.createContext)({...y,scaleX:1,scaleY:1});var Je;!function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"}(Je||(Je={}));const Ge=(0,r.memo)((function(e){var t,n,l,s;let{id:u,accessibility:d,autoScroll:f=!0,children:p,sensors:h=Pe,collisionDetection:b=M,measuring:m,modifiers:w,...x}=e;const C=(0,r.useReducer)(He,void 0,Ve),[E,R]=C,[S,D]=function(){const[e]=(0,r.useState)((()=>new Set)),t=(0,r.useCallback)((t=>(e.add(t),()=>e.delete(t))),[e]);return[(0,r.useCallback)((t=>{let{type:n,event:r}=t;e.forEach((e=>{var t;return null==(t=e[n])?void 0:t.call(e,r)}))}),[e]),t]}(),[_,O]=(0,r.useState)(Je.Uninitialized),L=_===Je.Initialized,{draggable:{active:I,nodes:T,translate:F},droppable:{containers:P}}=E,q=I?T.get(I):null,U=(0,r.useRef)({initial:null,translated:null}),z=(0,r.useMemo)((()=>{var e;return null!=I?{id:I,data:null!=(e=null==q?void 0:q.data)?e:je,rect:U}:null}),[I,q]),H=(0,r.useRef)(null),[Y,$]=(0,r.useState)(null),[J,G]=(0,r.useState)(null),Z=(0,a.useLatestValue)(x,Object.values(x)),ee=(0,a.useUniqueId)("DndDescribedBy",u),ne=(0,r.useMemo)((()=>P.getEnabled()),[P]),re=(oe=m,(0,r.useMemo)((()=>({draggable:{...qe.draggable,...null==oe?void 0:oe.draggable},droppable:{...qe.droppable,...null==oe?void 0:oe.droppable},dragOverlay:{...qe.dragOverlay,...null==oe?void 0:oe.dragOverlay}})),[null==oe?void 0:oe.draggable,null==oe?void 0:oe.droppable,null==oe?void 0:oe.dragOverlay]));var oe;const{droppableRects:ie,measureDroppableContainers:ae,measuringScheduled:le}=function(e,t){let{dragging:n,dependencies:o,config:i}=t;const[l,s]=(0,r.useState)(null),{frequency:u,measure:c,strategy:d}=i,f=(0,r.useRef)(e),p=function(){switch(d){case ke.Always:return!1;case ke.BeforeDragging:return n;default:return!n}}(),g=(0,a.useLatestValue)(p),v=(0,r.useCallback)((function(e){void 0===e&&(e=[]),g.current||s((t=>null===t?e:t.concat(e.filter((e=>!t.includes(e))))))}),[g]),h=(0,r.useRef)(null),b=(0,a.useLazyMemo)((t=>{if(p&&!n)return De;if(!t||t===De||f.current!==e||null!=l){const t=new Map;for(let n of e){if(!n)continue;if(l&&l.length>0&&!l.includes(n.id)&&n.rect.current){t.set(n.id,n.rect.current);continue}const e=n.node.current,r=e?new te(c(e),e):null;n.rect.current=r,r&&t.set(n.id,r)}return t}return t}),[e,l,n,p,c]);return(0,r.useEffect)((()=>{f.current=e}),[e]),(0,r.useEffect)((()=>{p||v()}),[n,p]),(0,r.useEffect)((()=>{l&&l.length>0&&s(null)}),[JSON.stringify(l)]),(0,r.useEffect)((()=>{p||"number"!=typeof u||null!==h.current||(h.current=setTimeout((()=>{v(),h.current=null}),u))}),[u,p,v,...o]),{droppableRects:b,measureDroppableContainers:v,measuringScheduled:null!=l}}(ne,{dragging:L,dependencies:[F.x,F.y],config:re.droppable}),se=function(e,t){const n=null!==t?e.get(t):void 0,r=n?n.node.current:null;return(0,a.useLazyMemo)((e=>{var n;return null===t?null:null!=(n=null!=r?r:e)?n:null}),[r,t])}(T,I),ue=(0,r.useMemo)((()=>J?(0,a.getEventCoordinates)(J):null),[J]),ce=function(){const e=!1===(null==Y?void 0:Y.autoScrollEnabled),t="object"==typeof f?!1===f.enabled:!1===f,n=L&&!e&&!t;if("object"==typeof f)return{...f,enabled:n};return{enabled:n}}(),de=function(e,t){return _e(e,t)}(se,re.draggable.measure);!function(e){let{activeNode:t,measure:n,initialRect:o,config:i=!0}=e;const l=(0,r.useRef)(!1),{x:s,y:u}="boolean"==typeof i?{x:i,y:i}:i;(0,a.useIsomorphicLayoutEffect)((()=>{if(!s&&!u||!t)return void(l.current=!1);if(l.current||!o)return;const e=null==t?void 0:t.node.current;if(!e||!1===e.isConnected)return;const r=N(n(e),o);if(s||(r.x=0),u||(r.y=0),l.current=!0,Math.abs(r.x)>0||Math.abs(r.y)>0){const t=W(e);t&&t.scrollBy({top:r.y,left:r.x})}}),[t,s,u,o,n])}({activeNode:I?T.get(I):null,config:ce.layoutShiftCompensation,initialRect:de,measure:re.draggable.measure});const fe=Le(se,re.draggable.measure,de),pe=Le(se?se.parentElement:null),ge=(0,r.useRef)({activatorEvent:null,active:null,activeNode:se,collisionRect:null,collisions:null,droppableRects:ie,draggableNodes:T,draggingNode:null,draggingNodeRect:null,droppableContainers:P,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),ve=P.getNodeFor(null==(t=ge.current.over)?void 0:t.id),he=function(e){let{measure:t}=e;const[n,o]=(0,r.useState)(null),i=Oe({callback:(0,r.useCallback)((e=>{for(const{target:n}of e)if((0,a.isHTMLElement)(n)){o((e=>{const r=t(n);return e?{...e,width:r.width,height:r.height}:r}));break}}),[t])}),l=(0,r.useCallback)((e=>{const n=Fe(e);null==i||i.disconnect(),n&&(null==i||i.observe(n)),o(n?t(n):null)}),[t,i]),[s,u]=(0,a.useNodeRef)(l);return(0,r.useMemo)((()=>({nodeRef:s,rect:n,setRef:u})),[n,s,u])}({measure:re.dragOverlay.measure}),be=null!=(n=he.nodeRef.current)?n:se,me=L?null!=(l=he.rect)?l:fe:null,ye=Boolean(he.nodeRef.current&&he.rect),we=N(xe=ye?null:fe,_e(xe));var xe;const Ce=Te(be?(0,a.getWindow)(be):null),Re=function(e){const t=(0,r.useRef)(e),n=(0,a.useLazyMemo)((n=>e?n&&n!==Ie&&e&&t.current&&e.parentNode===t.current.parentNode?n:K(e):Ie),[e]);return(0,r.useEffect)((()=>{t.current=e}),[e]),n}(L?null!=ve?ve:se:null),Se=function(e,t){void 0===t&&(t=j);const[n]=e,o=Te(n?(0,a.getWindow)(n):null),[i,l]=(0,r.useReducer)((function(){return e.length?e.map((e=>X(e)?o:new te(t(e),e))):Ae}),Ae),s=Oe({callback:l});return e.length>0&&i===Ae&&l(),(0,a.useIsomorphicLayoutEffect)((()=>{e.length?e.forEach((e=>null==s?void 0:s.observe(e))):(null==s||s.disconnect(),l())}),[e]),i}(Re),Me=Ye(w,{transform:{x:F.x-we.x,y:F.y-we.y,scaleX:1,scaleY:1},activatorEvent:J,active:z,activeNodeRect:fe,containerNodeRect:pe,draggingNodeRect:me,over:ge.current.over,overlayNodeRect:he.rect,scrollableAncestors:Re,scrollableAncestorRects:Se,windowRect:Ce}),Ke=ue?(0,a.add)(ue,F):null,We=function(e){const[t,n]=(0,r.useState)(null),o=(0,r.useRef)(e),i=(0,r.useCallback)((e=>{const t=B(e.target);t&&n((e=>e?(e.set(t,V(t)),new Map(e)):null))}),[]);return(0,r.useEffect)((()=>{const t=o.current;if(e!==t){r(t);const a=e.map((e=>{const t=B(e);return t?(t.addEventListener("scroll",i,{passive:!0}),[t,V(t)]):null})).filter((e=>null!=e));n(a.length?new Map(a):null),o.current=e}return()=>{r(e),r(t)};function r(e){e.forEach((e=>{const t=B(e);null==t||t.removeEventListener("scroll",i)}))}}),[i,e]),(0,r.useMemo)((()=>e.length?t?Array.from(t.values()).reduce(((e,t)=>(0,a.add)(e,t)),y):Q(e):y),[e,t])}(Re),Be=Ne(We),Ge=Ne(We,[fe]),Qe=(0,a.add)(Me,Be),Ze=me?A(me,Me):null,et=z&&Ze?b({active:z,collisionRect:Ze,droppableRects:ie,droppableContainers:ne,pointerCoordinates:Ke}):null,tt=k(et,"id"),[nt,rt]=(0,r.useState)(null),ot=function(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}(ye?Me:(0,a.add)(Me,Ge),null!=(s=null==nt?void 0:nt.rect)?s:null,fe),it=(0,r.useCallback)(((e,t)=>{let{sensor:n,options:r}=t;if(null==H.current)return;const o=T.get(H.current);if(!o)return;const a=e.nativeEvent,l=new n({active:H.current,activeNode:o,event:a,options:r,context:ge,onStart(e){const t=H.current;if(null==t)return;const n=T.get(t);if(!n)return;const{onDragStart:r}=Z.current,o={active:{id:t,data:n.data,rect:U}};(0,i.unstable_batchedUpdates)((()=>{null==r||r(o),O(Je.Initializing),R({type:v.DragStart,initialCoordinates:e,active:t}),S({type:"onDragStart",event:o})}))},onMove(e){R({type:v.DragMove,coordinates:e})},onEnd:s(v.DragEnd),onCancel:s(v.DragCancel)});function s(e){return async function(){const{active:t,collisions:n,over:r,scrollAdjustedTranslate:o}=ge.current;let l=null;if(t&&o){const{cancelDrop:i}=Z.current;if(l={activatorEvent:a,active:t,collisions:n,delta:o,over:r},e===v.DragEnd&&"function"==typeof i){await Promise.resolve(i(l))&&(e=v.DragCancel)}}H.current=null,(0,i.unstable_batchedUpdates)((()=>{R({type:e}),O(Je.Uninitialized),rt(null),$(null),G(null);const t=e===v.DragEnd?"onDragEnd":"onDragCancel";if(l){const e=Z.current[t];null==e||e(l),S({type:t,event:l})}}))}}(0,i.unstable_batchedUpdates)((()=>{$(l),G(e.nativeEvent)}))}),[T]),at=(0,r.useCallback)(((e,t)=>(n,r)=>{const o=n.nativeEvent,i=T.get(r);if(null!==H.current||!i||o.dndKit||o.defaultPrevented)return;const a={active:i};!0===e(n,t.options,a)&&(o.dndKit={capturedBy:t.sensor},H.current=r,it(n,t))}),[T,it]),lt=function(e,t){return(0,r.useMemo)((()=>e.reduce(((e,n)=>{const{sensor:r}=n;return[...e,...r.activators.map((e=>({eventName:e.eventName,handler:t(e.handler,n)})))]}),[])),[e,t])}(h,at);!function(e){(0,r.useEffect)((()=>{if(!a.canUseDOM)return;const t=e.map((e=>{let{sensor:t}=e;return null==t.setup?void 0:t.setup()}));return()=>{for(const e of t)null==e||e()}}),e.map((e=>{let{sensor:t}=e;return t})))}(h),(0,a.useIsomorphicLayoutEffect)((()=>{fe&&_===Je.Initializing&&O(Je.Initialized)}),[fe,_]),(0,r.useEffect)((()=>{const{onDragMove:e}=Z.current,{active:t,activatorEvent:n,collisions:r,over:o}=ge.current;if(!t||!n)return;const a={active:t,activatorEvent:n,collisions:r,delta:{x:Qe.x,y:Qe.y},over:o};(0,i.unstable_batchedUpdates)((()=>{null==e||e(a),S({type:"onDragMove",event:a})}))}),[Qe.x,Qe.y]),(0,r.useEffect)((()=>{const{active:e,activatorEvent:t,collisions:n,droppableContainers:r,scrollAdjustedTranslate:o}=ge.current;if(!e||null==H.current||!t||!o)return;const{onDragOver:a}=Z.current,l=r.get(tt),s=l&&l.rect.current?{id:l.id,rect:l.rect.current,data:l.data,disabled:l.disabled}:null,u={active:e,activatorEvent:t,collisions:n,delta:{x:o.x,y:o.y},over:s};(0,i.unstable_batchedUpdates)((()=>{rt(s),null==a||a(u),S({type:"onDragOver",event:u})}))}),[tt]),(0,a.useIsomorphicLayoutEffect)((()=>{ge.current={activatorEvent:J,active:z,activeNode:se,collisionRect:Ze,collisions:et,droppableRects:ie,draggableNodes:T,draggingNode:be,draggingNodeRect:me,droppableContainers:P,over:nt,scrollableAncestors:Re,scrollAdjustedTranslate:Qe},U.current={initial:me,translated:Ze}}),[z,se,et,Ze,T,be,me,ie,P,nt,Re,Qe]),Ee({...ce,delta:F,draggingRect:Ze,pointerCoordinates:Ke,scrollableAncestors:Re,scrollableAncestorRects:Se});const st=(0,r.useMemo)((()=>({active:z,activeNode:se,activeNodeRect:fe,activatorEvent:J,collisions:et,containerNodeRect:pe,dragOverlay:he,draggableNodes:T,droppableContainers:P,droppableRects:ie,over:nt,measureDroppableContainers:ae,scrollableAncestors:Re,scrollableAncestorRects:Se,measuringConfiguration:re,measuringScheduled:le,windowRect:Ce})),[z,se,fe,J,et,pe,he,T,P,ie,nt,ae,Re,Se,re,le,Ce]),ut=(0,r.useMemo)((()=>({activatorEvent:J,activators:lt,active:z,activeNodeRect:fe,ariaDescribedById:{draggable:ee},dispatch:R,draggableNodes:T,over:nt,measureDroppableContainers:ae})),[J,lt,z,fe,R,ee,T,nt,ae]);return o().createElement(c.Provider,{value:D},o().createElement(Ue.Provider,{value:ut},o().createElement(ze.Provider,{value:st},o().createElement($e.Provider,{value:ot},p)),o().createElement(Xe,{disabled:!1===(null==d?void 0:d.restoreFocus)})),o().createElement(g,{...d,hiddenTextDescribedById:ee}))})),Qe=(0,r.createContext)(null),Ze="button",et="Droppable";function tt(e){let{id:t,data:n,disabled:o=!1,attributes:i}=e;const l=(0,a.useUniqueId)(et),{activators:s,activatorEvent:u,active:c,activeNodeRect:d,ariaDescribedById:f,draggableNodes:p,over:g}=(0,r.useContext)(Ue),{role:v=Ze,roleDescription:h="draggable",tabIndex:b=0}=null!=i?i:{},m=(null==c?void 0:c.id)===t,y=(0,r.useContext)(m?$e:Qe),[w,x]=(0,a.useNodeRef)(),[C,E]=(0,a.useNodeRef)(),R=function(e,t){return(0,r.useMemo)((()=>e.reduce(((e,n)=>{let{eventName:r,handler:o}=n;return e[r]=e=>{o(e,t)},e}),{})),[e,t])}(s,t),k=(0,a.useLatestValue)(n);(0,a.useIsomorphicLayoutEffect)((()=>(p.set(t,{id:t,key:l,node:w,activatorNode:C,data:k}),()=>{const e=p.get(t);e&&e.key===l&&p.delete(t)})),[p,t]);return{active:c,activatorEvent:u,activeNodeRect:d,attributes:(0,r.useMemo)((()=>({role:v,tabIndex:b,"aria-disabled":o,"aria-pressed":!(!m||v!==Ze)||void 0,"aria-roledescription":h,"aria-describedby":f.draggable})),[o,v,b,m,h,f.draggable]),isDragging:m,listeners:o?void 0:R,node:w,over:g,setNodeRef:x,setActivatorNodeRef:E,transform:y}}function nt(){return(0,r.useContext)(ze)}const rt="Droppable",ot={timeout:25};function it(e){let{data:t,disabled:n=!1,id:o,resizeObserverConfig:i}=e;const l=(0,a.useUniqueId)(rt),{active:s,dispatch:u,over:c,measureDroppableContainers:d}=(0,r.useContext)(Ue),f=(0,r.useRef)({disabled:n}),p=(0,r.useRef)(!1),g=(0,r.useRef)(null),h=(0,r.useRef)(null),{disabled:b,updateMeasurementsFor:m,timeout:y}={...ot,...i},w=(0,a.useLatestValue)(null!=m?m:o),x=Oe({callback:(0,r.useCallback)((()=>{p.current?(null!=h.current&&clearTimeout(h.current),h.current=setTimeout((()=>{d(Array.isArray(w.current)?w.current:[w.current]),h.current=null}),y)):p.current=!0}),[y]),disabled:b||!s}),C=(0,r.useCallback)(((e,t)=>{x&&(t&&(x.unobserve(t),p.current=!1),e&&x.observe(e))}),[x]),[E,R]=(0,a.useNodeRef)(C),k=(0,a.useLatestValue)(t);return(0,r.useEffect)((()=>{x&&E.current&&(x.disconnect(),p.current=!1,x.observe(E.current))}),[E,x]),(0,a.useIsomorphicLayoutEffect)((()=>(u({type:v.RegisterDroppable,element:{id:o,key:l,disabled:n,node:E,rect:g,data:k}}),()=>u({type:v.UnregisterDroppable,key:l,id:o}))),[o]),(0,r.useEffect)((()=>{n!==f.current.disabled&&(u({type:v.SetDroppableDisabled,id:o,key:l,disabled:n}),f.current.disabled=n)}),[o,l,n,u]),{active:s,rect:g,isOver:(null==c?void 0:c.id)===o,node:E,over:c,setNodeRef:R}}function at(e){let{animation:t,children:n}=e;const[i,l]=(0,r.useState)(null),[s,u]=(0,r.useState)(null),c=(0,a.usePrevious)(n);return n||i||!c||l(c),(0,a.useIsomorphicLayoutEffect)((()=>{if(!s)return;const e=null==i?void 0:i.key,n=null==i?void 0:i.props.id;null!=e&&null!=n?Promise.resolve(t(n,s)).then((()=>{l(null)})):l(null)}),[t,i,s]),o().createElement(o().Fragment,null,n,i?(0,r.cloneElement)(i,{ref:u}):null)}const lt={x:0,y:0,scaleX:1,scaleY:1};function st(e){let{children:t}=e;return o().createElement(Ue.Provider,{value:Be},o().createElement($e.Provider,{value:lt},t))}const ut={position:"fixed",touchAction:"none"},ct=e=>(0,a.isKeyboardEvent)(e)?"transform 250ms ease":void 0,dt=(0,r.forwardRef)(((e,t)=>{let{as:n,activatorEvent:r,adjustScale:i,children:l,className:s,rect:u,style:c,transform:d,transition:f=ct}=e;if(!u)return null;const p=i?d:{...d,scaleX:1,scaleY:1},g={...ut,width:u.width,height:u.height,top:u.top,left:u.left,transform:a.CSS.Transform.toString(p),transformOrigin:i&&r?x(r,u):void 0,transition:"function"==typeof f?f(r):f,...c};return o().createElement(n,{className:s,style:g,ref:t},l)})),ft=e=>t=>{let{active:n,dragOverlay:r}=t;const o={},{styles:i,className:a}=e;if(null!=i&&i.active)for(const[e,t]of Object.entries(i.active))void 0!==t&&(o[e]=n.node.style.getPropertyValue(e),n.node.style.setProperty(e,t));if(null!=i&&i.dragOverlay)for(const[e,t]of Object.entries(i.dragOverlay))void 0!==t&&r.node.style.setProperty(e,t);return null!=a&&a.active&&n.node.classList.add(a.active),null!=a&&a.dragOverlay&&r.node.classList.add(a.dragOverlay),function(){for(const[e,t]of Object.entries(o))n.node.style.setProperty(e,t);null!=a&&a.active&&n.node.classList.remove(a.active)}},pt={duration:250,easing:"ease",keyframes:e=>{let{transform:{initial:t,final:n}}=e;return[{transform:a.CSS.Transform.toString(t)},{transform:a.CSS.Transform.toString(n)}]},sideEffects:ft({styles:{active:{opacity:"0"}}})};function gt(e){let{config:t,draggableNodes:n,droppableContainers:r,measuringConfiguration:o}=e;return(0,a.useEvent)(((e,i)=>{if(null===t)return;const l=n.get(e);if(!l)return;const s=l.node.current;if(!s)return;const u=Fe(i);if(!u)return;const{transform:c}=(0,a.getWindow)(i).getComputedStyle(i),d=F(c);if(!d)return;const f="function"==typeof t?t:function(e){const{duration:t,easing:n,sideEffects:r,keyframes:o}={...pt,...e};return e=>{let{active:i,dragOverlay:a,transform:l,...s}=e;if(!t)return;const u={x:a.rect.left-i.rect.left,y:a.rect.top-i.rect.top},c={scaleX:1!==l.scaleX?i.rect.width*l.scaleX/a.rect.width:1,scaleY:1!==l.scaleY?i.rect.height*l.scaleY/a.rect.height:1},d={x:l.x-u.x,y:l.y-u.y,...c},f=o({...s,active:i,dragOverlay:a,transform:{initial:l,final:d}}),[p]=f,g=f[f.length-1];if(JSON.stringify(p)===JSON.stringify(g))return;const v=null==r?void 0:r({active:i,dragOverlay:a,...s}),h=a.node.animate(f,{duration:t,easing:n,fill:"forwards"});return new Promise((e=>{h.onfinish=()=>{null==v||v(),e()}}))}}(t);return Z(s,o.draggable.measure),f({active:{id:e,data:l.data,node:s,rect:o.draggable.measure(s)},draggableNodes:n,dragOverlay:{node:i,rect:o.dragOverlay.measure(u)},droppableContainers:r,measuringConfiguration:o,transform:d})}))}let vt=0;function ht(e){return(0,r.useMemo)((()=>{if(null!=e)return vt++,vt}),[e])}const bt=o().memo((e=>{let{adjustScale:t=!1,children:n,dropAnimation:i,style:a,transition:l,modifiers:s,wrapperElement:u="div",className:c,zIndex:d=999}=e;const{activatorEvent:f,active:p,activeNodeRect:g,containerNodeRect:v,draggableNodes:h,droppableContainers:b,dragOverlay:m,over:y,measuringConfiguration:w,scrollableAncestors:x,scrollableAncestorRects:C,windowRect:E}=nt(),R=(0,r.useContext)($e),k=ht(null==p?void 0:p.id),S=Ye(s,{activatorEvent:f,active:p,activeNodeRect:g,containerNodeRect:v,draggingNodeRect:m.rect,over:y,overlayNodeRect:m.rect,scrollableAncestors:x,scrollableAncestorRects:C,transform:R,windowRect:E}),D=_e(g),_=gt({config:i,draggableNodes:h,droppableContainers:b,measuringConfiguration:w}),O=D?m.setRef:void 0;return o().createElement(st,null,o().createElement(at,{animation:_},p&&k?o().createElement(dt,{key:k,id:p.id,ref:O,as:u,activatorEvent:f,adjustScale:t,className:c,transition:l,rect:D,style:{zIndex:d,...a},transform:S},n):null))}))},831:function(e,t,n){n.r(t),n.d(t,{createSnapModifier:function(){return o},restrictToFirstScrollableAncestor:function(){return s},restrictToHorizontalAxis:function(){return i},restrictToParentElement:function(){return l},restrictToVerticalAxis:function(){return u},restrictToWindowEdges:function(){return c},snapCenterToCursor:function(){return d}});var r=n(979);function o(e){return t=>{let{transform:n}=t;return{...n,x:Math.ceil(n.x/e)*e,y:Math.ceil(n.y/e)*e}}}const i=e=>{let{transform:t}=e;return{...t,y:0}};function a(e,t,n){const r={...e};return t.top+e.y<=n.top?r.y=n.top-t.top:t.bottom+e.y>=n.top+n.height&&(r.y=n.top+n.height-t.bottom),t.left+e.x<=n.left?r.x=n.left-t.left:t.right+e.x>=n.left+n.width&&(r.x=n.left+n.width-t.right),r}const l=e=>{let{containerNodeRect:t,draggingNodeRect:n,transform:r}=e;return n&&t?a(r,n,t):r},s=e=>{let{draggingNodeRect:t,transform:n,scrollableAncestorRects:r}=e;const o=r[0];return t&&o?a(n,t,o):n},u=e=>{let{transform:t}=e;return{...t,x:0}},c=e=>{let{transform:t,draggingNodeRect:n,windowRect:r}=e;return n&&r?a(t,n,r):t},d=e=>{let{activatorEvent:t,draggingNodeRect:n,transform:o}=e;if(n&&t){const e=(0,r.getEventCoordinates)(t);if(!e)return o;const i=e.x-n.left,a=e.y-n.top;return{...o,x:o.x+i-n.width/2,y:o.y+a-n.height/2}}return o}},627:function(e,t,n){n.r(t),n.d(t,{SortableContext:function(){return y},arrayMove:function(){return l},arraySwap:function(){return s},defaultAnimateLayoutChanges:function(){return x},defaultNewIndexGetter:function(){return w},hasSortableData:function(){return D},horizontalListSortingStrategy:function(){return f},rectSortingStrategy:function(){return p},rectSwappingStrategy:function(){return g},sortableKeyboardCoordinates:function(){return O},useSortable:function(){return S},verticalListSortingStrategy:function(){return h}});var r=n(594),o=n.n(r),i=n(733),a=n(979);function l(e,t,n){const r=e.slice();return r.splice(n<0?r.length+n:n,0,r.splice(t,1)[0]),r}function s(e,t,n){const r=e.slice();return r[t]=e[n],r[n]=e[t],r}function u(e,t){return e.reduce(((e,n,r)=>{const o=t.get(n);return o&&(e[r]=o),e}),Array(e.length))}function c(e){return null!==e&&e>=0}const d={scaleX:1,scaleY:1},f=e=>{var t;let{rects:n,activeNodeRect:r,activeIndex:o,overIndex:i,index:a}=e;const l=null!=(t=n[o])?t:r;if(!l)return null;const s=function(e,t,n){const r=e[t],o=e[t-1],i=e[t+1];if(!r||!o&&!i)return 0;if(no&&a<=i?{x:-l.width-s,y:0,...d}:a=i?{x:l.width+s,y:0,...d}:{x:0,y:0,...d}};const p=e=>{let{rects:t,activeIndex:n,overIndex:r,index:o}=e;const i=l(t,r,n),a=t[o],s=i[o];return s&&a?{x:s.left-a.left,y:s.top-a.top,scaleX:s.width/a.width,scaleY:s.height/a.height}:null},g=e=>{let t,n,{activeIndex:r,index:o,rects:i,overIndex:a}=e;return o===r&&(t=i[o],n=i[a]),o===a&&(t=i[o],n=i[r]),n&&t?{x:n.left-t.left,y:n.top-t.top,scaleX:n.width/t.width,scaleY:n.height/t.height}:null},v={scaleX:1,scaleY:1},h=e=>{var t;let{activeIndex:n,activeNodeRect:r,index:o,rects:i,overIndex:a}=e;const l=null!=(t=i[n])?t:r;if(!l)return null;if(o===n){const e=i[a];return e?{x:0,y:nn&&o<=a?{x:0,y:-l.height-s,...v}:o=a?{x:0,y:l.height+s,...v}:{x:0,y:0,...v}};const b="Sortable",m=o().createContext({activeIndex:-1,containerId:b,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:p,disabled:{draggable:!1,droppable:!1}});function y(e){let{children:t,id:n,items:l,strategy:s=p,disabled:c=!1}=e;const{active:d,dragOverlay:f,droppableRects:g,over:v,measureDroppableContainers:h}=(0,i.useDndContext)(),y=(0,a.useUniqueId)(b,n),w=Boolean(null!==f.rect),x=(0,r.useMemo)((()=>l.map((e=>"object"==typeof e&&"id"in e?e.id:e))),[l]),C=null!=d,E=d?x.indexOf(d.id):-1,R=v?x.indexOf(v.id):-1,k=(0,r.useRef)(x),S=!function(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n{S&&C&&h(x)}),[S,x,C,h]),(0,r.useEffect)((()=>{k.current=x}),[x]);const O=(0,r.useMemo)((()=>({activeIndex:E,containerId:y,disabled:_,disableTransforms:D,items:x,overIndex:R,useDragOverlay:w,sortedRects:u(x,g),strategy:s})),[E,y,_.draggable,_.droppable,D,x,R,g,w,s]);return o().createElement(m.Provider,{value:O},t)}const w=e=>{let{id:t,items:n,activeIndex:r,overIndex:o}=e;return l(n,r,o).indexOf(t)},x=e=>{let{containerId:t,isSorting:n,wasDragging:r,index:o,items:i,newIndex:a,previousItems:l,previousContainerId:s,transition:u}=e;return!(!u||!r)&&((l===i||o!==a)&&(!!n||a!==o&&t===s))},C={duration:200,easing:"ease"},E="transform",R=a.CSS.Transition.toString({property:E,duration:0,easing:"linear"}),k={roleDescription:"sortable"};function S(e){let{animateLayoutChanges:t=x,attributes:n,disabled:o,data:l,getNewIndex:s=w,id:u,strategy:d,resizeObserverConfig:f,transition:p=C}=e;const{items:g,containerId:v,activeIndex:h,disabled:b,disableTransforms:y,sortedRects:S,overIndex:D,useDragOverlay:_,strategy:O}=(0,r.useContext)(m),M=function(e,t){var n,r;if("boolean"==typeof e)return{draggable:e,droppable:!1};return{draggable:null!=(n=null==e?void 0:e.draggable)?n:t.draggable,droppable:null!=(r=null==e?void 0:e.droppable)?r:t.droppable}}(o,b),L=g.indexOf(u),I=(0,r.useMemo)((()=>({sortable:{containerId:v,index:L,items:g},...l})),[v,l,L,g]),N=(0,r.useMemo)((()=>g.slice(g.indexOf(u))),[g,u]),{rect:T,node:A,isOver:F,setNodeRef:P}=(0,i.useDroppable)({id:u,data:I,disabled:M.droppable,resizeObserverConfig:{updateMeasurementsFor:N,...f}}),{active:j,activatorEvent:q,activeNodeRect:K,attributes:W,setNodeRef:B,listeners:U,isDragging:z,over:V,setActivatorNodeRef:H,transform:X}=(0,i.useDraggable)({id:u,data:I,attributes:{...k,...n},disabled:M.draggable}),Y=(0,a.useCombinedRefs)(P,B),$=Boolean(j),J=$&&!y&&c(h)&&c(D),G=!_&&z,Q=G&&J?X:null,Z=J?null!=Q?Q:(null!=d?d:O)({rects:S,activeNodeRect:K,activeIndex:h,overIndex:D,index:L}):null,ee=c(h)&&c(D)?s({id:u,items:g,activeIndex:h,overIndex:D}):L,te=null==j?void 0:j.id,ne=(0,r.useRef)({activeId:te,items:g,newIndex:ee,containerId:v}),re=g!==ne.current.items,oe=t({active:j,containerId:v,isDragging:z,isSorting:$,id:u,index:L,items:g,newIndex:ne.current.newIndex,previousItems:ne.current.items,previousContainerId:ne.current.containerId,transition:p,wasDragging:null!=ne.current.activeId}),ie=function(e){let{disabled:t,index:n,node:o,rect:l}=e;const[s,u]=(0,r.useState)(null),c=(0,r.useRef)(n);return(0,a.useIsomorphicLayoutEffect)((()=>{if(!t&&n!==c.current&&o.current){const e=l.current;if(e){const t=(0,i.getClientRect)(o.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)&&u(n)}}n!==c.current&&(c.current=n)}),[t,n,o,l]),(0,r.useEffect)((()=>{s&&u(null)}),[s]),s}({disabled:!oe,index:L,node:A,rect:T});return(0,r.useEffect)((()=>{$&&ne.current.newIndex!==ee&&(ne.current.newIndex=ee),v!==ne.current.containerId&&(ne.current.containerId=v),g!==ne.current.items&&(ne.current.items=g)}),[$,ee,v,g]),(0,r.useEffect)((()=>{if(te===ne.current.activeId)return;if(te&&!ne.current.activeId)return void(ne.current.activeId=te);const e=setTimeout((()=>{ne.current.activeId=te}),50);return()=>clearTimeout(e)}),[te]),{active:j,activeIndex:h,attributes:W,data:I,rect:T,index:L,newIndex:ee,items:g,isOver:F,isSorting:$,isDragging:z,listeners:U,node:A,overIndex:D,over:V,setNodeRef:Y,setActivatorNodeRef:H,setDroppableNodeRef:P,setDraggableNodeRef:B,transform:null!=ie?ie:Z,transition:function(){if(ie||re&&ne.current.newIndex===L)return R;if(G&&!(0,a.isKeyboardEvent)(q)||!p)return;if($||oe)return a.CSS.Transition.toString({...p,property:E});return}()}}function D(e){if(!e)return!1;const t=e.data.current;return!!(t&&"sortable"in t&&"object"==typeof t.sortable&&"containerId"in t.sortable&&"items"in t.sortable&&"index"in t.sortable)}const _=[i.KeyboardCode.Down,i.KeyboardCode.Right,i.KeyboardCode.Up,i.KeyboardCode.Left],O=(e,t)=>{let{context:{active:n,collisionRect:r,droppableRects:o,droppableContainers:l,over:s,scrollableAncestors:u}}=t;if(_.includes(e.code)){if(e.preventDefault(),!n||!r)return;const t=[];l.getEnabled().forEach((n=>{if(!n||null!=n&&n.disabled)return;const a=o.get(n.id);if(a)switch(e.code){case i.KeyboardCode.Down:r.topa.top&&t.push(n);break;case i.KeyboardCode.Left:r.left>a.left&&t.push(n);break;case i.KeyboardCode.Right:r.left1&&(d=c[1].id),null!=d){const e=l.get(n.id),t=l.get(d),s=t?o.get(t.id):null,c=null==t?void 0:t.node.current;if(c&&s&&e&&t){const n=(0,i.getScrollableAncestors)(c).some(((e,t)=>u[t]!==e)),o=M(e,t),l=function(e,t){if(!D(e)||!D(t))return!1;if(!M(e,t))return!1;return e.data.current.sortable.indexe=>{t.forEach((t=>t(e)))}),t)}const i="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement;function a(e){const t=Object.prototype.toString.call(e);return"[object Window]"===t||"[object global]"===t}function l(e){return"nodeType"in e}function s(e){var t,n;return e?a(e)?e:l(e)&&null!=(t=null==(n=e.ownerDocument)?void 0:n.defaultView)?t:window:window}function u(e){const{Document:t}=s(e);return e instanceof t}function c(e){return!a(e)&&e instanceof s(e).HTMLElement}function d(e){return e instanceof s(e).SVGElement}function f(e){return e?a(e)?e.document:l(e)?u(e)?e:c(e)||d(e)?e.ownerDocument:document:document:document}const p=i?r.useLayoutEffect:r.useEffect;function g(e){const t=(0,r.useRef)(e);return p((()=>{t.current=e})),(0,r.useCallback)((function(){for(var e=arguments.length,n=new Array(e),r=0;r{e.current=setInterval(t,n)}),[]),(0,r.useCallback)((()=>{null!==e.current&&(clearInterval(e.current),e.current=null)}),[])]}function h(e,t){void 0===t&&(t=[e]);const n=(0,r.useRef)(e);return p((()=>{n.current!==e&&(n.current=e)}),t),n}function b(e,t){const n=(0,r.useRef)();return(0,r.useMemo)((()=>{const t=e(n.current);return n.current=t,t}),[...t])}function m(e){const t=g(e),n=(0,r.useRef)(null),o=(0,r.useCallback)((e=>{e!==n.current&&(null==t||t(e,n.current)),n.current=e}),[]);return[n,o]}function y(e){const t=(0,r.useRef)();return(0,r.useEffect)((()=>{t.current=e}),[e]),t.current}let w={};function x(e,t){return(0,r.useMemo)((()=>{if(t)return t;const n=null==w[e]?0:w[e]+1;return w[e]=n,e+"-"+n}),[e,t])}function C(e){return function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o{const r=Object.entries(n);for(const[n,o]of r){const r=t[n];null!=r&&(t[n]=r+e*o)}return t}),{...t})}}const E=C(1),R=C(-1);function k(e){return"clientX"in e&&"clientY"in e}function S(e){if(!e)return!1;const{KeyboardEvent:t}=s(e.target);return t&&e instanceof t}function D(e){if(!e)return!1;const{TouchEvent:t}=s(e.target);return t&&e instanceof t}function _(e){if(D(e)){if(e.touches&&e.touches.length){const{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}if(e.changedTouches&&e.changedTouches.length){const{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return k(e)?{x:e.clientX,y:e.clientY}:null}const O=Object.freeze({Translate:{toString(e){if(!e)return;const{x:t,y:n}=e;return"translate3d("+(t?Math.round(t):0)+"px, "+(n?Math.round(n):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:t,scaleY:n}=e;return"scaleX("+t+") scaleY("+n+")"}},Transform:{toString(e){if(e)return[O.Translate.toString(e),O.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+" "+n+"ms "+r}}}),M="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function L(e){return e.matches(M)?e:e.querySelector(M)}},38:function(e,t,n){var r,o=(r=n(121))&&r.__esModule?r:{default:r};document.addEventListener("DOMContentLoaded",(()=>{(0,o.default)()}))},121:function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var r=l(n(207)),o=l(n(135)),i=l(n(853)),a=l(n(985));function l(e){return e&&e.__esModule?e:{default:e}}t.default=()=>{r.default.component.registerMany({LinkPicker:o.default,LinkField:i.default,"LinkModal.FormBuilderModal":a.default})}},853:function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.default=t.LinkFieldContext=t.Component=void 0;var r=S(n(594)),o=n(367),i=n(40),a=n(733),l=n(627),s=n(831),u=R(n(623)),c=R(n(135)),d=R(n(137)),f=R(n(89)),p=R(n(864)),g=S(n(918)),v=R(n(609)),h=R(n(177)),b=n(125),m=R(n(935)),y=R(n(815)),w=R(n(8)),x=R(n(675)),C=R(n(923)),E=R(n(489));function R(e){return e&&e.__esModule?e:{default:e}}function k(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,n=new WeakMap;return(k=function(e){return e?n:t})(e)}function S(e,t){if(!t&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var n=k(t);if(n&&n.has(e))return n.get(e);var r={__proto__:null},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var i in e)if("default"!==i&&{}.hasOwnProperty.call(e,i)){var a=o?Object.getOwnPropertyDescriptor(e,i):null;a&&(a.get||a.set)?Object.defineProperty(r,i,a):r[i]=e[i]}return r.default=e,n&&n.set(e,r),r}const D=t.LinkFieldContext=(0,r.createContext)(null),_="SilverStripe\\LinkField\\Controllers\\LinkFieldController",O=e=>{let{value:t=null,onChange:n=(()=>{}),types:o={},actions:i,isMulti:u=!1,canCreate:g,readonly:m,disabled:R,ownerID:k,ownerClass:S,ownerRelation:O,excludeLinkTextField:M=!1,inHistoryViewer:L}=e;const[I,N]=(0,r.useState)({}),[T,A]=(0,r.useState)(0),[F,P]=(0,r.useState)(0),[j,q]=(0,r.useState)(!1),[K,W]=(0,r.useState)(!1),[B,U]=(0,r.useState)(0),[z,V]=(0,r.useState)(!1),[H,X]=(0,r.useState)(!1),[Y,$]=(0,r.useState)(!1),[J,G]=(0,r.useState)(0),[Q,Z]=(0,r.useState)(!1),[ee,te]=(0,r.useState)((0,C.default)({"link-picker-links":!0})),ne=(0,a.useSensors)((0,a.useSensor)(a.PointerSensor,{activationConstraint:{distance:10}}),(0,a.useSensor)(a.KeyboardSensor,{coordinateGetter:(e,t)=>{e.preventDefault();const{active:n,over:r,droppableContainers:o}=t.context;if(!n||!n.data||!n.data.current)return;const i=n.data.current.sortable.items,s=r?r.id:n.id,u=i.indexOf(s),c=i.indexOf(n.id);let d=u,f=1;switch(e.code){case a.KeyboardCode.Down:case a.KeyboardCode.Right:d=Math.min(u+1,i.length-1);break;case a.KeyboardCode.Up:case a.KeyboardCode.Left:d=Math.max(0,u-1),f=-1;break;default:return}if(u===d)return;const p=(0,l.arrayMove)(i,c,u)[d];if(!o.has(p))return;const g=o.get(n.id).node.current;if(!o.has(n.id))return;const v=o.get(p).node.current,h=g.getBoundingClientRect(),b=v.getBoundingClientRect(),m=1===f?b.top-h.bottom:h.top-b.bottom;return{x:0,y:h.top+f*(b.height+m)}}}));let re=t;Array.isArray(re)||("number"==typeof re&&0!=re&&(re=[re]),re||(re=[])),(0,r.useEffect)((()=>{if(!T&&re.length>0){X(!0);const e=[];for(const t of re)e.push(`itemIDs[]=${t}`);const t=`${h.default.getSection(_).form.linkForm.dataUrl}?${e.join("&")}`;v.default.get(t).then((e=>e.json())).then((e=>{N(e)})).catch((()=>{$(!0)})).finally((()=>{X(!1),Z(!1)}))}}),[T,t&&t.length,J]);const oe=(0,r.useRef)(null);let ie=0;const ae=[];for(const e of re)ae[e]=(0,r.useRef)(null),ie++;for(;ie<256;)(0,r.useRef)(null),ie++;(0,r.useEffect)((()=>{if(K&&!H)if(0===re.length)V(!0);else{const e=re[0];ae[e].current&&U(e),W(!1)}}),[K,H,re]),(0,r.useEffect)((()=>{F&&!H&&(U(F),P(0))}),[F,H]),(0,r.useEffect)((()=>{0===B||H||(ae[B].current.focus(),U(0))}),[B,H]),(0,r.useEffect)((()=>{z&&oe.current&&!H&&(oe.current.focus(),V(!1))}),[z,H,oe]);const le=()=>{T?P(T):j?W(!0):V(!0),A(0),q(!1)},se=e=>{le();const t=[...re];t.includes(e)||t.push(e),n(u?t:t[0]),i.toasts.success(y.default._t("LinkField.SAVE_SUCCESS","Saved link"))},ue=(e,t)=>{const r=I[e]?.versionState||"",o=[E.default.draft,E.default.modified,E.default.published].includes(r),a=o?y.default._t("LinkField.ARCHIVE_CONFIRM","Are you sure you want to archive this link?"):y.default._t("LinkField.DELETE_CONFIRM","Are you sure you want to delete this link?");if(!window.confirm(a))return!1;let l=(0,b.joinUrlPaths)(h.default.getSection(_).form.linkForm.deleteUrl,e.toString());const s=w.default.parse(l),c=x.default.parse(s.query);c.ownerID=k,c.ownerClass=S,c.ownerRelation=O,l=w.default.format({...s,search:x.default.stringify(c)});const d=o?y.default._t("LinkField.ARCHIVE_SUCCESS","Archived link"):y.default._t("LinkField.DELETE_SUCCESS","Deleted link"),f=o?y.default._t("LinkField.ARCHIVE_ERROR","Failed to archive link"):y.default._t("LinkField.DELETE_ERROR","Failed to delete link");v.default.delete(l,{},{"X-SecurityID":h.default.get("SecurityID")}).then((()=>i.toasts.success(d))).catch((()=>i.toasts.error(f)));const p={},g=[];for(const e in I){p[Number(I[e].sort)]=e}const m=Object.keys(p).sort(((e,t)=>e-t));for(const e of m)g[g.length]=Number(p[e]);const C=g.indexOf(e),R=1===g.length,D=C===g.length-1;R?V(!0):P(D?g[C-1]:g[C+1]);const M={...I};delete M[e],N(M);const L=[];for(const t of re)t!==e&&L.push(t);n(u?L:0)},ce=()=>{const e=[".cms-edit-form button[data-text-alternate]#Form_EditForm_action_publish",".cms-edit-form button[data-text-alternate]#Form_ItemEditForm_action_doPublish"].join(","),t=document.querySelector(e);if(!t)return;(t.getAttribute("data-btn-alternate-remove")||"").split(" ").forEach((e=>{e&&t.classList.remove(e)}));(t.getAttribute("data-btn-alternate-add")||"").split(" ").forEach((e=>{e&&t.classList.add(e)}));const n=t.getAttribute("data-text-alternate");n&&(t.innerHTML=n)},de=e=>{te((0,C.default)({"link-picker__links":!0,"link-picker__links--dragging":!0})),Z(!0)},fe=e=>{const{active:t,over:r}=e;if(te((0,C.default)({"link-picker__links":!0,"link-picker__links--dragging":!1})),t.id===r.id)return void Z(!1);const o=re.indexOf(t.id),a=re.indexOf(r.id),s=(0,l.arrayMove)(re,o,a);n(s);let u=`${h.default.getSection(_).form.linkForm.sortUrl}`;v.default.post(u,{newLinkIDs:s},{"X-SecurityID":h.default.get("SecurityID")}).then((async()=>{n(s),i.toasts.success(y.default._t("LinkField.SORT_SUCCESS","Updated link sort order")),G(J+1)})).catch((()=>{i.toasts.error(y.default._t("LinkField.SORT_ERROR","Failed to sort links"))}))},pe=!Y&&0===k,ge=Y,ve=!Y&&!L&&!pe&&(u||0===re.length),he=!Y&&!pe&&Boolean(T),be=y.default._t("LinkField.FAILED_TO_LOAD_LINKS","Failed to load link(s)"),me=y.default._t("LinkField.SAVE_RECORD_FIRST","Cannot add links until the record has been saved"),ye=(()=>{const e=[];for(let t=0;t{A(n)},onUnpublishedVersionedState:ce,canDelete:!!i.canDelete,isMulti:u,isFirst:0===t,isLast:t===re.length-1,isSorting:Q,canCreate:g,readonly:m,disabled:R,buttonRef:ae[n]}))}return e})();return r.default.createElement(D.Provider,{value:{ownerID:k,ownerClass:S,ownerRelation:O,actions:i,loading:H,excludeLinkTextField:M,inHistoryViewer:L}},r.default.createElement("div",{className:"link-field__container"},ge&&r.default.createElement("div",{className:"link-field__loading-error"},be),pe&&r.default.createElement("div",{className:"link-field__save-record-first"},me),H&&!Q&&!pe&&r.default.createElement(f.default,{containerClass:"link-field__loading"}),ve&&r.default.createElement(c.default,{onModalSuccess:se,onModalClosed:le,types:o,canCreate:g,readonly:m,disabled:R,onSelectType:()=>{u||q(!0)},dropdownToggleRef:oe}),!u||m||R?r.default.createElement("div",null,ye):r.default.createElement("div",{className:ee,onBlur:()=>Z(!1)},r.default.createElement(a.DndContext,{modifiers:[s.restrictToVerticalAxis,s.restrictToParentElement],sensors:ne,collisionDetection:a.closestCenter,onDragStart:de,onDragEnd:fe},r.default.createElement("ol",{className:"link-picker__list"},r.default.createElement(l.SortableContext,{items:re,strategy:l.verticalListSortingStrategy},ye)))),he&&r.default.createElement(p.default,{types:o,typeKey:I[T]?.typeKey,isOpen:Boolean(T),onSuccess:se,onClosed:le,linkID:T})))};t.Component=O,O.propTypes={value:m.default.oneOfType([m.default.arrayOf(m.default.number),m.default.number]),onChange:m.default.func,types:m.default.object.isRequired,actions:m.default.object.isRequired,isMulti:m.default.bool,canCreate:m.default.bool.isRequired,readonly:m.default.bool.isRequired,disabled:m.default.bool.isRequired,ownerID:m.default.number.isRequired,ownerClass:m.default.string.isRequired,ownerRelation:m.default.string.isRequired,excludeLinkTextField:m.default.bool,inHistoryViewer:m.default.bool};t.default=(0,o.compose)(u.default,(0,i.connect)(null,(e=>({actions:{toasts:(0,o.bindActionCreators)(g,e)}}))))(O)},985:function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var r=function(e,t){if(!t&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var n=f(t);if(n&&n.has(e))return n.get(e);var r={__proto__:null},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var i in e)if("default"!==i&&{}.hasOwnProperty.call(e,i)){var a=o?Object.getOwnPropertyDescriptor(e,i):null;a&&(a.get||a.set)?Object.defineProperty(r,i,a):r[i]=e[i]}return r.default=e,n&&n.set(e,r),r}(n(594)),o=d(n(737)),i=n(853),a=d(n(8)),l=d(n(675)),s=d(n(177)),u=n(125),c=d(n(935));function d(e){return e&&e.__esModule?e:{default:e}}function f(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,n=new WeakMap;return(f=function(e){return e?n:t})(e)}const p=(e,t)=>{const{schemaUrl:n}=s.default.getSection("SilverStripe\\LinkField\\Controllers\\LinkFieldController").form.linkForm,o=a.default.parse(n),c=l.default.parse(o.query);c.typeKey=e;const{ownerID:d,ownerClass:f,ownerRelation:p,excludeLinkTextField:g,inHistoryViewer:v}=(0,r.useContext)(i.LinkFieldContext);c.ownerID=d,c.ownerClass=f,c.ownerRelation=p,g&&(c.excludeLinkTextField=!0),v&&(c.inHistoryViewer="1");for(const e of["href","path","pathname"])o[e]=(0,u.joinUrlPaths)(o[e],t.toString());return a.default.format({...o,search:l.default.stringify(c)})},g=e=>{let{typeTitle:t,typeKey:n,linkID:a=0,isOpen:l,onSuccess:s,onClosed:u}=e;const{actions:c}=(0,r.useContext)(i.LinkFieldContext);if(!n)return!1;return r.default.createElement(o.default,{title:t,isOpen:l,schemaUrl:p(n,a),identifier:"Link.EditingLinkInfo",onSubmit:async(e,t,n)=>{let r=null;try{r=await n()}catch(e){return c.toasts.error(i18n._t("LinkField.FAILED_TO_SAVE_LINK","Failed to save link")),Promise.resolve()}if(!r.id.match(/\/schema\/linkfield\/([0-9]+)/)){const e=r.id.match(/\/linkForm\/([0-9]+)/),t=parseInt(e[1],10);s(t)}return Promise.resolve()},onClosed:u,autoFocus:!0})};g.propTypes={typeTitle:c.default.string.isRequired,typeKey:c.default.string.isRequired,linkID:c.default.number,isOpen:c.default.bool.isRequired,onSuccess:c.default.func.isRequired,onClosed:c.default.func.isRequired};t.default=g},135:function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.default=t.Component=void 0;var r=c(n(815)),o=function(e,t){if(!t&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var n=u(t);if(n&&n.has(e))return n.get(e);var r={__proto__:null},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var i in e)if("default"!==i&&{}.hasOwnProperty.call(e,i)){var a=o?Object.getOwnPropertyDescriptor(e,i):null;a&&(a.get||a.set)?Object.defineProperty(r,i,a):r[i]=e[i]}return r.default=e,n&&n.set(e,r),r}(n(594)),i=c(n(935)),a=c(n(923)),l=c(n(164)),s=c(n(864));function u(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,n=new WeakMap;return(u=function(e){return e?n:t})(e)}function c(e){return e&&e.__esModule?e:{default:e}}const d=e=>{let{types:t,onModalSuccess:n,onModalClosed:i,canCreate:u,readonly:c,disabled:d,onSelectType:f,dropdownToggleRef:p}=e;const[g,v]=(0,o.useState)(""),h=""!==g,b=(0,a.default)("link-picker","form-control"),m=Object.values(t),y=m.filter((e=>e.allowed)),w=r.default._t("LinkField.CANNOT_CREATE_LINK","Cannot create link");return!u||0===y.length||c||d?o.default.createElement("div",{className:b},o.default.createElement("div",{className:"link-picker__cannot-create"},w)):o.default.createElement("div",{className:b},o.default.createElement(l.default,{types:m,onSelect:e=>{v(e),f()},dropdownToggleRef:p}),h&&o.default.createElement(s.default,{types:t,typeKey:g,isOpen:h,onSuccess:e=>{v(""),n(e)},onClosed:()=>{"function"==typeof i&&i(),v("")}}))};t.Component=d,d.propTypes={types:i.default.object.isRequired,onModalSuccess:i.default.func.isRequired,onModalClosed:i.default.func,canCreate:i.default.bool.isRequired,readonly:i.default.bool.isRequired,disabled:i.default.bool.isRequired,onSelectType:i.default.func.isRequired,dropdownToggleRef:i.default.object.isRequired};t.default=d},164:function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var r=c(n(815)),o=function(e,t){if(!t&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var n=u(t);if(n&&n.has(e))return n.get(e);var r={__proto__:null},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var i in e)if("default"!==i&&{}.hasOwnProperty.call(e,i)){var a=o?Object.getOwnPropertyDescriptor(e,i):null;a&&(a.get||a.set)?Object.defineProperty(r,i,a):r[i]=e[i]}return r.default=e,n&&n.set(e,r),r}(n(594)),i=c(n(935)),a=n(556),l=n(853),s=c(n(159));function u(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,n=new WeakMap;return(u=function(e){return e?n:t})(e)}function c(e){return e&&e.__esModule?e:{default:e}}const d=e=>{let{types:t,onSelect:n,dropdownToggleRef:i}=e;const[s,u]=(0,o.useState)(!1),{loading:c}=(0,o.useContext)(l.LinkFieldContext),d=r.default._t("LinkField.ADD_LINK","Add link");return o.default.createElement(a.Dropdown,{disabled:c,isOpen:s,toggle:()=>u((e=>!e)),className:"link-picker__menu"},o.default.createElement(a.DropdownToggle,{className:"link-picker__menu-toggle font-icon-plus-1",caret:!0,color:"secondary","aria-label":d,innerRef:i},r.default._t("LinkField.ADD_LINK","Add Link")),o.default.createElement(a.DropdownMenu,null,t.map((e=>{let{key:t,title:r,icon:i,allowed:l}=e;return l&&o.default.createElement(a.DropdownItem,{key:t,onClick:()=>{n(t)}},o.default.createElement("span",{className:`link-picker__menu-icon ${i}`}),o.default.createElement("span",{className:"link-picker__menu-title"},r))}))))};d.propTypes={types:i.default.arrayOf(s.default).isRequired,onSelect:i.default.func.isRequired,dropdownToggleRef:i.default.object.isRequired};t.default=d},137:function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var r=p(n(923)),o=p(n(815)),i=function(e,t){if(!t&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var n=f(t);if(n&&n.has(e))return n.get(e);var r={__proto__:null},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var i in e)if("default"!==i&&{}.hasOwnProperty.call(e,i)){var a=o?Object.getOwnPropertyDescriptor(e,i):null;a&&(a.get||a.set)?Object.defineProperty(r,i,a):r[i]=e[i]}return r.default=e,n&&n.set(e,r),r}(n(594)),a=p(n(935)),l=n(853),s=n(556),u=n(627),c=n(979),d=p(n(489));function f(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,n=new WeakMap;return(f=function(e){return e?n:t})(e)}function p(e){return e&&e.__esModule?e:{default:e}}function g(){return g=Object.assign?Object.assign.bind():function(e){for(var t=1;tt=>{t.nativeEvent.stopImmediatePropagation(),t.preventDefault(),t.nativeEvent.preventDefault(),t.stopPropagation(),e&&e()},h=e=>{let{id:t,title:n,description:a,versionState:f,typeTitle:p,typeIcon:h,onDelete:b,onClick:m,onUnpublishedVersionedState:y,canDelete:w,isMulti:x,isFirst:C,isLast:E,isSorting:R,canCreate:k,readonly:S,disabled:D,buttonRef:_}=e;const{loading:O}=(0,i.useContext)(l.LinkFieldContext),{attributes:M,listeners:L,setNodeRef:I,transform:N,transition:T}=(0,u.useSortable)({id:t}),A={transform:c.CSS.Transform.toString(N),transition:T},F={"link-picker__link":!0,"link-picker__link--is-first":C,"link-picker__link--is-last":E,"link-picker__link--is-sorting":R,"form-control":!0,"link-picker__link--readonly":S||!k,"link-picker__link--disabled":D};f&&(F[`link-picker__link--${f}`]=!0);const P=(0,r.default)(F),j=[d.default.unversioned,d.default.unsaved].includes(f)?o.default._t("LinkField.DELETE","Delete"):o.default._t("LinkField.ARCHIVE","Archive"),q=o.default._t("LinkField.EDIT_LINK","Edit link");[d.default.draft,d.default.modified].includes(f)&&y(),delete M.tabIndex;const K=`link-picker__link-${t}`,W=x?"li":"div";return i.default.createElement(W,g({className:P,ref:I,style:A},M,L,{id:K}),i.default.createElement(s.Button,{"aria-label":q,disabled:O,className:`link-picker__button ${h}`,color:"secondary",onClick:v(m),innerRef:_,onKeyDown:e=>{e.nativeEvent.stopImmediatePropagation(),e.stopPropagation()}},i.default.createElement("div",{className:"link-picker__link-detail"},i.default.createElement("div",{className:"link-picker__title"},i.default.createElement("span",{className:"link-picker__title-text"},n),(e=>{let t="",n="";if(e===d.default.draft)t=o.default._t("LinkField.LINK_DRAFT_TITLE","Link has draft changes"),n=o.default._t("LinkField.LINK_DRAFT_LABEL","Draft");else{if(e!==d.default.modified)return null;t=o.default._t("LinkField.LINK_MODIFIED_TITLE","Link has unpublished changes"),n=o.default._t("LinkField.LINK_MODIFIED_LABEL","Modified")}const a=(0,r.default)("badge",`status-${e}`);return i.default.createElement("span",{className:a,title:t},n)})(f)),p&&i.default.createElement("small",{className:"link-picker__type"},p,": ",i.default.createElement("span",{className:"link-picker__url"},a))),w&&!S&&!D&&i.default.createElement("span",{"aria-label":j,role:"button",tabIndex:"0",className:"link-picker__delete btn btn-link",onKeyDown:e=>{["Enter","Space"].includes(e.code)&&!O&&(e.nativeEvent.stopImmediatePropagation(),e.stopPropagation(),b(t),e.nativeEvent.preventDefault(),e.preventDefault())},onClick:v((()=>O?null:b(t)))},j)),x&&!S&&!D&&i.default.createElement("div",{className:"link-picker__drag-handle",tabIndex:"0",role:"button","aria-pressed":"false","aria-controls":K,"aria-label":"Sort Links",onKeyDown:e=>{if(!["Enter","Space"].includes(e.code))return;const t=e.target,n="true"===t.getAttribute("aria-pressed")?"false":"true";t.setAttribute("aria-pressed",n)}},i.default.createElement("i",{className:"font-icon-drag-handle","aria-hidden":"true",focusable:"false"})))};h.propTypes={id:a.default.number.isRequired,title:a.default.string,description:a.default.string,versionState:a.default.oneOf(Object.values(d.default)),typeTitle:a.default.string.isRequired,typeIcon:a.default.string.isRequired,onDelete:a.default.func.isRequired,onClick:a.default.func.isRequired,onUnpublishedVersionedState:a.default.func.isRequired,canDelete:a.default.bool.isRequired,isMulti:a.default.bool.isRequired,isFirst:a.default.bool.isRequired,isLast:a.default.bool.isRequired,isSorting:a.default.bool.isRequired,canCreate:a.default.bool.isRequired,readonly:a.default.bool.isRequired,disabled:a.default.bool.isRequired,buttonRef:a.default.object.isRequired},h.defaultProps={versionState:d.default.unversioned};t.default=h},489:function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;t.default={draft:"draft",modified:"modified",unversioned:"unversioned",unsaved:"unsaved",published:"published"}},864:function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var r,o=function(e,t){if(!t&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var n=l(t);if(n&&n.has(e))return n.get(e);var r={__proto__:null},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var i in e)if("default"!==i&&{}.hasOwnProperty.call(e,i)){var a=o?Object.getOwnPropertyDescriptor(e,i):null;a&&(a.get||a.set)?Object.defineProperty(r,i,a):r[i]=e[i]}return r.default=e,n&&n.set(e,r),r}(n(594)),i=n(207),a=(r=n(935))&&r.__esModule?r:{default:r};function l(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,n=new WeakMap;return(l=function(e){return e?n:t})(e)}const s=e=>{let{types:t,typeKey:n,linkID:r=0,isOpen:a,onSuccess:l,onClosed:s}=e;const[u,c]=(0,o.useState)(null);if(!n)return!1;const d=t.hasOwnProperty(n)?t[n]:{},f=d&&d.hasOwnProperty("handlerName")?d.handlerName:"FormBuilderModal";if(u)return o.default.createElement(u,{typeTitle:d.title||"",typeKey:n,linkID:r,isOpen:a,onSuccess:l,onClosed:s});c((()=>(0,i.loadComponent)(`LinkModal.${f}`)))};s.propTypes={types:a.default.object.isRequired,typeKey:a.default.string.isRequired,linkID:a.default.number,isOpen:a.default.bool.isRequired,onSuccess:a.default.func.isRequired,onClosed:a.default.func.isRequired};t.default=s},406:function(e,t,n){var r=l(n(669)),o=l(n(594)),i=l(n(145)),a=n(207);function l(e){return e&&e.__esModule?e:{default:e}}function s(){return s=Object.assign?Object.assign.bind():function(e){for(var t=1;t{e(".js-injector-boot .entwine-linkfield").entwine({Component:null,Root:null,onmatch(){const e=this.closest(".cms-content").attr("id"),t=e?{context:e}:{},n=this.data("schema-component"),r=(0,a.loadComponent)(n,t);this.setComponent(r),this.setRoot(i.default.createRoot(this[0])),this._super(),this.refresh()},refresh(){const e=this.getProps();this.getInputField().val(e.value);const t=this.getComponent();this.getRoot().render(o.default.createElement(t,s({},e,{noHolder:!0})))},handleChange(e){this.getInputField().data("value",e),this.refresh()},getProps(){const e=this.getInputField();return{value:e.data("value"),ownerID:e.data("owner-id"),ownerClass:e.data("owner-class"),ownerRelation:e.data("owner-relation"),excludeLinkTextField:e.data("exclude-linktext-field"),onChange:this.handleChange.bind(this),isMulti:this.data("is-multi")??!1,types:this.data("types")??{},canCreate:!!e.data("can-create"),readonly:!!e.data("readonly"),disabled:!!e.data("disabled"),inHistoryViewer:!!e.data("in-history-viewer")}},getInputField(){const t=this.data("field-id");return e(`#${t}`)},onunmatch(){const e=this.getRoot();e&&e.unmount()}})}))},159:function(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var r,o=(r=n(935))&&r.__esModule?r:{default:r};const i=o.default.shape({key:o.default.string.isRequired,title:o.default.string.isRequired,icon:o.default.string.isRequired});t.default=i},609:function(e){e.exports=Backend},177:function(e){e.exports=Config},623:function(e){e.exports=FieldHolder},737:function(e){e.exports=FormBuilderModal},207:function(e){e.exports=Injector},89:function(e){e.exports=Loading},8:function(e){e.exports=NodeUrl},935:function(e){e.exports=PropTypes},594:function(e){e.exports=React},145:function(e){e.exports=ReactDomClient},40:function(e){e.exports=ReactRedux},556:function(e){e.exports=Reactstrap},367:function(e){e.exports=Redux},918:function(e){e.exports=ToastsActions},923:function(e){e.exports=classnames},815:function(e){e.exports=i18n},669:function(e){e.exports=jQuery},675:function(e){e.exports=qs},125:function(e){e.exports=ssUrlLib}},t={};function n(r){var o=t[r];if(void 0!==o)return o.exports;var i=t[r]={exports:{}};return e[r](i,i.exports,n),i.exports}n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,{a:t}),t},n.d=function(e,t){for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n(38),n(406)}(); \ No newline at end of file diff --git a/client/src/components/LinkField/LinkField.js b/client/src/components/LinkField/LinkField.js index fecfbdd4..1c9c3fb6 100644 --- a/client/src/components/LinkField/LinkField.js +++ b/client/src/components/LinkField/LinkField.js @@ -65,10 +65,11 @@ const LinkField = ({ }) => { const [data, setData] = useState({}); const [editingID, setEditingID] = useState(0); - const [isKeyboardEditing, setIsKeyboardEditing] = useState(false); const [focusOnID, setFocusOnID] = useState(0); const [focusOnNewLinkWhenClosed, setFocusOnNewLinkWhenClosed] = useState(false); const [focusOnNewLink, setFocusOnNewLink] = useState(false); + const [focusOnIDWhenAvailable, setFocusOnIDWhenAvailable] = useState(0); + const [focusOnLinkPicker, setFocusOnLinkPicker] = useState(false); const [loading, setLoading] = useState(false); const [loadingError, setLoadingError] = useState(false); const [forceFetch, setForceFetch] = useState(0); @@ -173,7 +174,10 @@ const LinkField = ({ } }, [editingID, value && value.length, forceFetch]); - // Create refs for each LinkPickerTitle button so they can be focused when the editing modal is closed via keyboard + // Create a ref for the LinkPicker so it can be focused + const linkPickerRef = useRef(null); + + // Create refs for each LinkPickerTitle button so they can be focused let refCount = 0; const linkButtonRefs = [] for (const linkID of linkIDs) { @@ -187,53 +191,73 @@ const LinkField = ({ refCount++; } - // Focus on the LinkPickerTitle edit button when the editing modal is closed via keyboard - // or focus on newly created link for single (has_one) linkfield + // This sets focus after closed the modal when creating a new link with the single-linkfield useEffect(() => { - if ((!focusOnID && !focusOnNewLink) || loading) { + if (!focusOnNewLink || loading) { return; } - let c = 0; - const interval = setInterval(() => { - if (focusOnID && linkButtonRefs[focusOnID].current) { - // Multi linkfield - linkButtonRefs[focusOnID].current.focus(); - clearInterval(interval); - } else if (focusOnNewLink) { - // Non-multi linkfield - if (linkIDs.length === 0) { - // User opened modal but did exited instead of saving - clearInterval(interval); - } else { - // User opened modal and created a new link - const linkID = linkIDs[0]; - if (linkButtonRefs[linkID].current) { - linkButtonRefs[linkID].current.focus(); - clearInterval(interval); - } - } + if (linkIDs.length === 0) { + // User opened modal but exited without of saving + setFocusOnLinkPicker(true); + } else { + // User opened modal and created a new link + const linkID = linkIDs[0]; + if (linkButtonRefs[linkID].current) { + setFocusOnIDWhenAvailable(linkID); } - // Safety check - if (++c >= 50) { - clearInterval(interval); - } - }, 50); + setFocusOnNewLink(false); + } + }, [focusOnNewLink, loading, linkIDs]); + + // This sets focus after closing a modal for both single-linkfield and multi-linkfield + // when editing an existing link + // Note setFocusOnIDWhenAvailable is used because the .focus() must not be called immediately + // if we try to focus on the link at this point then it will immediately lose focus + useEffect(() => { + if (!focusOnID || loading) { + return; + } + setFocusOnIDWhenAvailable(focusOnID); setFocusOnID(0); - setFocusOnNewLink(false); - }, [focusOnID, focusOnNewLink, loading]); + }, [focusOnID, loading]); + + // Focus on the a link when it's ready for focus + useEffect(() => { + if (focusOnIDWhenAvailable === 0 || loading) { + return; + } + linkButtonRefs[focusOnIDWhenAvailable].current.focus(); + setFocusOnIDWhenAvailable(0); + }, [focusOnIDWhenAvailable, loading]); + + // Focus on the link picker when it's available for focus + // The use of a useEffect block isn't strictly needed in all scenarios when focusing on the + // link picker, however it is needed when archiving a single-linkfield.link + // For the sake of consistency, only use `focusOnLinkPicker(true)` to focus on the link picker + useEffect(() => { + if (!focusOnLinkPicker || !linkPickerRef.current || loading) { + return; + } + linkPickerRef.current.focus(); + setFocusOnLinkPicker(false); + }, [focusOnLinkPicker, loading, linkPickerRef]); /** * Unset the editing ID when the editing modal is closed - * If using keyboard, focus on button used to open the modal + * Focus on button used to open the modal */ const handleModalClosed = () => { - if (isKeyboardEditing) { - setIsKeyboardEditing(false); - if (editingID) { - setFocusOnID(editingID); - } else if (focusOnNewLinkWhenClosed) { - setFocusOnNewLink(true); - } + if (editingID) { + setFocusOnID(editingID); + } else if (focusOnNewLinkWhenClosed) { + // This is called when a user uses single-linkfield to create a new link and then + // successfully saves the link + // Closing the a single-linkfield modal without saving is handled elsewhere + setFocusOnNewLink(true); + } else { + // This is called when a user uses multi-linkfield and either sucessfully save a new link + // or closes the modal without saving + setFocusOnLinkPicker(true); } setEditingID(0); setFocusOnNewLinkWhenClosed(false); @@ -256,11 +280,10 @@ const LinkField = ({ actions.toasts.success(i18n._t('LinkField.SAVE_SUCCESS', 'Saved link')); } - const handleLinkPickerKeyDownEdit = () => { + const handleSelectType = () => { if (!isMulti) { setFocusOnNewLinkWhenClosed(true); } - setIsKeyboardEditing(true); } /** @@ -297,13 +320,51 @@ const LinkField = ({ .then(() => actions.toasts.success(successText)) .catch(() => actions.toasts.error(failedText)); - // update component state + // Work out where to put focus after delete + // First create an array of linkIDs sorted by sort order + // Note - key is a linkID + const keysObj = {}; + const keys = []; + for (const key in data) { + const sort = Number(data[key].sort); + keysObj[sort] = key; + } + const sorts = Object.keys(keysObj).sort((a, b) => a - b); + for (const sort of sorts) { + keys[keys.length] = Number(keysObj[sort]); + } + + const index = keys.indexOf(linkID); + const isOnlyLink = keys.length === 1; + const isLastLink = index === keys.length - 1; + if (isOnlyLink) { + // If link was the only one then put focus on the picker + setFocusOnLinkPicker(true); + } else { + // If more than one link ... + if (isLastLink) { + // and link was last then focus on previous link + setFocusOnID(keys[index - 1]); + } else { + // and link was not last link then focus on next link + setFocusOnID(keys[index + 1]); + } + } + + // Update component state const newData = {...data}; delete newData[linkID]; setData(newData); - // update parent JsonField data IDs used to update the underlying form field - onChange(isMulti ? Object.keys(newData) : 0); + // Update parent JsonField data IDs used to update the underlying form field + // Not using Object.keys() to ensure that int key sort order is retained + const newLinkIDs = []; + for (const id of linkIDs) { + if (id !== linkID) { + newLinkIDs.push(id); + } + } + onChange(isMulti ? newLinkIDs : 0); }; /** @@ -371,7 +432,6 @@ const LinkField = ({ typeIcon={type.icon} onDelete={handleDelete} onClick={() => { setEditingID(linkID); }} - onButtonKeyDownEdit={() => setIsKeyboardEditing(true)} onUnpublishedVersionedState={handleUnpublishedVersionedState} canDelete={linkData.canDelete ? true : false} isMulti={isMulti} @@ -481,8 +541,8 @@ const LinkField = ({ canCreate={canCreate} readonly={readonly} disabled={disabled} - onKeyDownEdit={handleLinkPickerKeyDownEdit} - isKeyboardEditing={isKeyboardEditing} + onSelectType={handleSelectType} + dropdownToggleRef={linkPickerRef} /> } {sortableLinks()} { /* This is only used for editing EXISTING links */ } @@ -493,7 +553,6 @@ const LinkField = ({ onSuccess={handleModalSuccess} onClosed={handleModalClosed} linkID={editingID} - autoFocus={isKeyboardEditing} /> } diff --git a/client/src/components/LinkField/tests/LinkField-test.js b/client/src/components/LinkField/tests/LinkField-test.js index 6b9b337e..411caba1 100644 --- a/client/src/components/LinkField/tests/LinkField-test.js +++ b/client/src/components/LinkField/tests/LinkField-test.js @@ -165,13 +165,13 @@ test('LinkField tab order', async () => { // this doesn't happen because it will have a display of none at this point await user.tab(); await user.tab(); - expect(dragHandle123).toHaveFocus(); - await user.tab(); expect(button123).toHaveFocus(); await user.tab(); - expect(dragHandle456).toHaveFocus(); + expect(dragHandle123).toHaveFocus(); await user.tab(); expect(button456).toHaveFocus(); + await user.tab(); + expect(dragHandle456).toHaveFocus(); // Note that we cannot test keyboard sorting with up + down keys in jest because jsdom does not have a layout engine // e.g. el.getBoundingClientRect() will always return 0,0,0,0 diff --git a/client/src/components/LinkModal/LinkModal.js b/client/src/components/LinkModal/LinkModal.js index bba166a4..1294883b 100644 --- a/client/src/components/LinkModal/LinkModal.js +++ b/client/src/components/LinkModal/LinkModal.js @@ -29,7 +29,7 @@ const buildSchemaUrl = (typeKey, linkID) => { return url.format({ ...parsedURL, search: qs.stringify(parsedQs)}); } -const LinkModal = ({ typeTitle, typeKey, linkID = 0, isOpen, onSuccess, onClosed, autoFocus }) => { +const LinkModal = ({ typeTitle, typeKey, linkID = 0, isOpen, onSuccess, onClosed }) => { const { actions } = useContext(LinkFieldContext); if (!typeKey) { @@ -75,7 +75,7 @@ const LinkModal = ({ typeTitle, typeKey, linkID = 0, isOpen, onSuccess, onClosed identifier='Link.EditingLinkInfo' onSubmit={onSubmit} onClosed={onClosed} - autoFocus={autoFocus} + autoFocus={true} />; } @@ -86,7 +86,6 @@ LinkModal.propTypes = { isOpen: PropTypes.bool.isRequired, onSuccess: PropTypes.func.isRequired, onClosed: PropTypes.func.isRequired, - autoFocus: PropTypes.bool, }; LinkModal.defaultProps diff --git a/client/src/components/LinkPicker/LinkPicker.js b/client/src/components/LinkPicker/LinkPicker.js index df33cb08..a3f47a4b 100644 --- a/client/src/components/LinkPicker/LinkPicker.js +++ b/client/src/components/LinkPicker/LinkPicker.js @@ -16,8 +16,8 @@ const LinkPicker = ({ canCreate, readonly, disabled, - onKeyDownEdit, - isKeyboardEditing + onSelectType, + dropdownToggleRef, }) => { const [typeKey, setTypeKey] = useState(''); @@ -26,6 +26,7 @@ const LinkPicker = ({ */ const handleSelect = (key) => { setTypeKey(key); + onSelectType(); } /** @@ -67,7 +68,7 @@ const LinkPicker = ({ { /* This is only used for editing NEW links */ } { shouldOpenModal && } @@ -90,8 +90,8 @@ LinkPicker.propTypes = { canCreate: PropTypes.bool.isRequired, readonly: PropTypes.bool.isRequired, disabled: PropTypes.bool.isRequired, - onKeyDownEdit: PropTypes.func.isRequired, - isKeyboardEditing: PropTypes.bool, + onSelectType: PropTypes.func.isRequired, + dropdownToggleRef: PropTypes.object.isRequired, }; export {LinkPicker as Component}; diff --git a/client/src/components/LinkPicker/LinkPickerMenu.js b/client/src/components/LinkPicker/LinkPickerMenu.js index 4c828587..b0f15467 100644 --- a/client/src/components/LinkPicker/LinkPickerMenu.js +++ b/client/src/components/LinkPicker/LinkPickerMenu.js @@ -6,17 +6,10 @@ import { Dropdown, DropdownToggle, DropdownMenu, DropdownItem } from 'reactstrap import { LinkFieldContext } from 'components/LinkField/LinkField'; import LinkType from 'types/LinkType'; -const LinkPickerMenu = ({ types, onSelect, onKeyDownEdit }) => { +const LinkPickerMenu = ({ types, onSelect, dropdownToggleRef }) => { const [isOpen, setIsOpen] = useState(false); const toggle = () => setIsOpen(prevState => !prevState); const { loading } = useContext(LinkFieldContext); - - const handleKeyDown = (event) => { - if (['Enter', 'Space'].includes(event.code)) { - onKeyDownEdit(); - } - } - const ariaLabel = i18n._t('LinkField.ADD_LINK', 'Add link'); return { caret color="secondary" aria-label={ariaLabel} + innerRef={dropdownToggleRef} > {i18n._t('LinkField.ADD_LINK', 'Add Link')} @@ -39,7 +33,6 @@ const LinkPickerMenu = ({ types, onSelect, onKeyDownEdit }) => { {onSelect(key)}} - onKeyDown={handleKeyDown} > {title} @@ -53,7 +46,7 @@ const LinkPickerMenu = ({ types, onSelect, onKeyDownEdit }) => { LinkPickerMenu.propTypes = { types: PropTypes.arrayOf(LinkType).isRequired, onSelect: PropTypes.func.isRequired, - onKeyDownEdit: PropTypes.func.isRequired, + dropdownToggleRef: PropTypes.object.isRequired, }; export default LinkPickerMenu; diff --git a/client/src/components/LinkPicker/LinkPickerTitle.js b/client/src/components/LinkPicker/LinkPickerTitle.js index c3289ce6..b0caf0a3 100644 --- a/client/src/components/LinkPicker/LinkPickerTitle.js +++ b/client/src/components/LinkPicker/LinkPickerTitle.js @@ -42,7 +42,6 @@ const LinkPickerTitle = ({ typeIcon, onDelete, onClick, - onButtonKeyDownEdit, onUnpublishedVersionedState, canDelete, isMulti, @@ -67,9 +66,6 @@ const LinkPickerTitle = ({ // Prevent the triggering the parent's keyboard sorting handler event.nativeEvent.stopImmediatePropagation(); event.stopPropagation(); - if (['Enter', 'Space'].includes(event.code) && !loading) { - onButtonKeyDownEdit(event); - } }; const handleDeleteKeyDown = (event) => { @@ -129,20 +125,6 @@ const LinkPickerTitle = ({ {...listeners} id={idAttr} > - { (isMulti && !readonly && !disabled) &&
- -
} + { (isMulti && !readonly && !disabled) &&
+ +
} }; @@ -189,7 +185,6 @@ LinkPickerTitle.propTypes = { typeIcon: PropTypes.string.isRequired, onDelete: PropTypes.func.isRequired, onClick: PropTypes.func.isRequired, - onButtonKeyDownEdit: PropTypes.func.isRequired, onUnpublishedVersionedState: PropTypes.func.isRequired, canDelete: PropTypes.bool.isRequired, isMulti: PropTypes.bool.isRequired, diff --git a/client/src/components/LinkPicker/tests/LinkPicker-test.js b/client/src/components/LinkPicker/tests/LinkPicker-test.js index 390c6a27..1acfe82d 100644 --- a/client/src/components/LinkPicker/tests/LinkPicker-test.js +++ b/client/src/components/LinkPicker/tests/LinkPicker-test.js @@ -8,13 +8,14 @@ import LinkPicker from '../LinkPicker'; function makeProps(obj = {}) { return { + dropdownToggleRef: {}, types: { phone: { key: 'phone', title: 'Phone', icon: 'font-icon-phone', allowed: true } }, canCreate: true, readonly: false, disabled: false, onModalSuccess: () => {}, onModalClosed: () => {}, - onKeyDownEdit: () => {}, + onSelectType: () => {}, ...obj }; } diff --git a/client/src/components/LinkPicker/tests/LinkPickerMenu-test.js b/client/src/components/LinkPicker/tests/LinkPickerMenu-test.js index 958af61b..779b92f1 100644 --- a/client/src/components/LinkPicker/tests/LinkPickerMenu-test.js +++ b/client/src/components/LinkPicker/tests/LinkPickerMenu-test.js @@ -9,6 +9,7 @@ import LinkPickerMenu from '../LinkPickerMenu'; function makeProps(obj = {}) { return { + dropdownToggleRef: {}, types: [ { key: 'sitetree', title: 'Page', icon: 'font-icon-page', allowed: true }, { key: 'external', title: 'External URL', icon: 'font-icon-link', allowed: true }, @@ -16,7 +17,6 @@ function makeProps(obj = {}) { { key: 'phone', title: 'Phone', icon: 'font-icon-phone', allowed: true }, ], onSelect: jest.fn(), - onKeyDownEdit: jest.fn(), ...obj }; } @@ -61,13 +61,3 @@ test('LinkPickerMenu onSelect() should call onSelect with selected type', async expect(onSelect).toHaveBeenCalledWith('external'); }); }); - -test('LinkPickerMenu onKeyDownEdit() should call onKeyDownEdit with selected type', async () => { - const onKeyDownEdit = jest.fn(); - const { container } = render( - - ); - container.querySelector('.dropdown-item').focus(); - userEvent.keyboard('{enter}'); - await waitFor(() => expect(onKeyDownEdit).toHaveBeenCalledTimes(1)); -}); diff --git a/client/src/components/LinkPicker/tests/LinkPickerTitle-test.js b/client/src/components/LinkPicker/tests/LinkPickerTitle-test.js index f7083e9f..4b8590c4 100644 --- a/client/src/components/LinkPicker/tests/LinkPickerTitle-test.js +++ b/client/src/components/LinkPicker/tests/LinkPickerTitle-test.js @@ -21,7 +21,6 @@ function makeProps(obj = {}) { disabled: false, onDelete: () => {}, onClick: () => {}, - onButtonKeyDownEdit: () => {}, onUnpublishedVersionedState: () => {}, isMulti: false, isFirst: false, diff --git a/client/src/containers/LinkModalContainer.js b/client/src/containers/LinkModalContainer.js index febcec0f..b3b18763 100644 --- a/client/src/containers/LinkModalContainer.js +++ b/client/src/containers/LinkModalContainer.js @@ -7,7 +7,7 @@ import PropTypes from 'prop-types'; * Contains the LinkModal and determines which modal component to render based on the link type. */ -const LinkModalContainer = ({ types, typeKey, linkID = 0, isOpen, onSuccess, onClosed, autoFocus }) => { +const LinkModalContainer = ({ types, typeKey, linkID = 0, isOpen, onSuccess, onClosed }) => { const [LinkModal, setLinkModal] = useState(null); if (!typeKey) { return false; @@ -33,7 +33,6 @@ const LinkModalContainer = ({ types, typeKey, linkID = 0, isOpen, onSuccess, onC isOpen={isOpen} onSuccess={onSuccess} onClosed={onClosed} - autoFocus={autoFocus} />; } @@ -44,7 +43,6 @@ LinkModalContainer.propTypes = { isOpen: PropTypes.bool.isRequired, onSuccess: PropTypes.func.isRequired, onClosed: PropTypes.func.isRequired, - autoFocus: PropTypes.bool, }; export default LinkModalContainer; diff --git a/src/Models/Link.php b/src/Models/Link.php index 616c8909..6f573c3c 100644 --- a/src/Models/Link.php +++ b/src/Models/Link.php @@ -217,6 +217,7 @@ public function getData(): array 'canDelete' => $this->canDelete(), 'versionState' => $this->getVersionedState(), 'typeKey' => $typeKey, + 'sort' => $this->Sort, ]; } diff --git a/tests/behat/features/accessibility-linkfield.feature b/tests/behat/features/accessibility-linkfield.feature index ede0ad7a..2dddc2cf 100644 --- a/tests/behat/features/accessibility-linkfield.feature +++ b/tests/behat/features/accessibility-linkfield.feature @@ -51,6 +51,7 @@ Feature: Accessibility Tests And I click on "Link Page" in the tree Scenario: I can create and edit a LinkField using the keyboard + Given I should see the "#Form_EditForm_HasManyLinks" element And I should see the "#Form_EditForm_HasOneLink" element @@ -96,7 +97,6 @@ Feature: Accessibility Tests Then I press the "Tab" key globally And I press the "Tab" key globally - And I press the "Tab" key globally And I press the "Enter" key globally And I should see "Page on this site" in the "[data-field-id='Form_EditForm_HasManyLinks'] .dropdown-menu.show" element And I press the "Down" key globally @@ -119,6 +119,8 @@ Feature: Accessibility Tests Then I should see "Page Link 1" in the "[data-field-id='Form_EditForm_HasManyLinks'] .link-picker__link--is-first" element And I should see "External Link" in the "[data-field-id='Form_EditForm_HasManyLinks'] .link-picker__link--is-last" element When I press the "Tab" key globally + When I press the "Tab" key globally + When I press the "Tab" key globally Then the active element should be "[data-field-id='Form_EditForm_HasManyLinks'] .link-picker__drag-handle" Then I press the "Enter" key globally And I press the "Down" key globally @@ -130,8 +132,7 @@ Feature: Accessibility Tests # Test user can delete the link - Then I press the "Tab" key globally - And I press the "Tab" key globally + Then I press the "Shift-Tab" key globally Then the active element should be "[data-field-id='Form_EditForm_HasManyLinks'] .link-picker__link:nth-of-type(3) .link-picker__delete" And I press the "Enter" key and confirm the dialog And I wait for 3 seconds diff --git a/tests/behat/features/linkfield-focus.feature b/tests/behat/features/linkfield-focus.feature new file mode 100644 index 00000000..4bf8cfc7 --- /dev/null +++ b/tests/behat/features/linkfield-focus.feature @@ -0,0 +1,103 @@ +@retry +Feature: Browser focus in linkfield +As a content editor +I want to focus to be in the correct place + + Background: + Given I add an extension "SilverStripe\FrameworkTest\LinkField\Extensions\LinkPageExtension" to the "Page" class + And I go to "/dev/build?flush" + And a "page" "Link Page" + And the "group" "EDITOR" has permissions "Access to 'Pages' section" + And I am logged in as a member of "EDITOR" group + And I go to "/admin/pages" + And I should see "Link Page" + And I click on "Link Page" in the tree + + Scenario: Single-linkfield focus + + # Clicking on the linkfield sets focus + When I click on the "[data-field-id='Form_EditForm_HasOneLink'] .link-picker__menu-toggle" element + Then the active element should be "[data-field-id='Form_EditForm_HasOneLink'] .link-picker__menu-toggle" + + # Create a new link with submit sets focus on the newly created link + When I click on the "[data-field-id='Form_EditForm_HasOneLink'] .dropdown-item:nth-of-type(3)" element + # Focus should now be on the first input of the modal form + Then the active element should be "#Form_LinkForm_0_Phone" + When I type "123456789" in the field + And I click on the ".form-builder-modal .btn-primary" element + Then the active element should be "[data-field-id='Form_EditForm_HasOneLink'] .link-picker__button" + + # Editing existing link without submit sets focus on the existing link + When I click on the "[data-field-id='Form_EditForm_HasOneLink'] .link-picker__button" element + And I click on the ".form-builder-modal .close" element + Then the active element should be "[data-field-id='Form_EditForm_HasOneLink'] .link-picker__button" + + # Editing existing link with submit sets focus on the existing link + When I click on the "[data-field-id='Form_EditForm_HasOneLink'] .link-picker__button" element + And I type "987654321" in the field + And I click on the ".form-builder-modal .btn-primary" element + Then the active element should be "[data-field-id='Form_EditForm_HasOneLink'] .link-picker__button" + + # Deleting the link sets focus on the link picker + When I click on the "[data-field-id='Form_EditForm_HasOneLink'] .link-picker__delete" element, confirming the dialog + Then the active element should be "[data-field-id='Form_EditForm_HasOneLink'] .link-picker__menu-toggle" + + # Create a new link without submit sets focus on the link picker + When I click on the "[data-field-id='Form_EditForm_HasOneLink'] .link-picker__menu-toggle" element + And I click on the "[data-field-id='Form_EditForm_HasOneLink'] .dropdown-item:nth-of-type(3)" element + And I click on the ".form-builder-modal .close" element + Then the active element should be "[data-field-id='Form_EditForm_HasOneLink'] .link-picker__menu-toggle" + + Scenario: Multi-linkfield focus + + # Clicking on the linkfield sets focus + When I click on the "[data-field-id='Form_EditForm_HasManyLinks'] .link-picker__menu-toggle" element + Then the active element should be "[data-field-id='Form_EditForm_HasManyLinks'] .link-picker__menu-toggle" + + # Create a new link with submit sets focus on the link-picker + And I click on the "[data-field-id='Form_EditForm_HasManyLinks'] .dropdown-item:nth-of-type(5)" element + And I type "111111111" in the field + And I click on the ".form-builder-modal .btn-primary" element + Then the active element should be "[data-field-id='Form_EditForm_HasManyLinks'] .link-picker__menu-toggle" + + # Editing existing link without submit sets focus on the existing link + When I click on the "[data-field-id='Form_EditForm_HasManyLinks'] .link-picker__button" element + And I click on the ".form-builder-modal .close" element + Then the active element should be "[data-field-id='Form_EditForm_HasManyLinks'] .link-picker__button" + + # Editing existing link with submit sets focus on the existing link + When I click on the "[data-field-id='Form_EditForm_HasManyLinks'] .link-picker__button" element + And I type "111111111b" in the field + And I click on the ".form-builder-modal .btn-primary" element + Then the active element should be "[data-field-id='Form_EditForm_HasManyLinks'] .link-picker__button" + + # Creating a new link without submit sets focus on the link-picker + When I click on the "[data-field-id='Form_EditForm_HasManyLinks'] .link-picker__menu-toggle" element + And I click on the "[data-field-id='Form_EditForm_HasManyLinks'] .dropdown-item:nth-of-type(5)" element + And I click on the ".form-builder-modal .close" element + Then the active element should be "[data-field-id='Form_EditForm_HasManyLinks'] .link-picker__menu-toggle" + + # Creating a second link with submit sets focus on the link-picker + When I click on the "[data-field-id='Form_EditForm_HasManyLinks'] .link-picker__menu-toggle" element + And I click on the "[data-field-id='Form_EditForm_HasManyLinks'] .dropdown-item:nth-of-type(5)" element + And I type "222222222" in the field + And I click on the ".form-builder-modal .btn-primary" element + Then the active element should be "[data-field-id='Form_EditForm_HasManyLinks'] .link-picker__menu-toggle" + + # Create a third link + When I click on the "[data-field-id='Form_EditForm_HasManyLinks'] .link-picker__menu-toggle" element + And I click on the "[data-field-id='Form_EditForm_HasManyLinks'] .dropdown-item:nth-of-type(5)" element + And I type "333333333" in the field + And I click on the ".form-builder-modal .btn-primary" element + + # Archiving the non-last link focuses on what was the next link + When I click on the "[data-field-id='Form_EditForm_HasManyLinks'] .link-picker__link:nth-of-type(1) .link-picker__delete" element, confirming the dialog + Then the active element should be "[data-field-id='Form_EditForm_HasManyLinks'] .link-picker__link:nth-of-type(1) .link-picker__button" + + # Archiving the last link focuses on what was the previous link + When I click on the "[data-field-id='Form_EditForm_HasManyLinks'] .link-picker__link:nth-of-type(2) .link-picker__delete" element, confirming the dialog + Then the active element should be "[data-field-id='Form_EditForm_HasManyLinks'] .link-picker__link:nth-of-type(1) .link-picker__button" + + # Archiving the only link focuses on the link-picker + When I click on the "[data-field-id='Form_EditForm_HasManyLinks'] .link-picker__link:nth-of-type(1) .link-picker__delete" element, confirming the dialog + Then the active element should be "[data-field-id='Form_EditForm_HasManyLinks'] .link-picker__menu-toggle" diff --git a/tests/php/Controllers/LinkFieldControllerTest.php b/tests/php/Controllers/LinkFieldControllerTest.php index 4b33e003..57055d42 100644 --- a/tests/php/Controllers/LinkFieldControllerTest.php +++ b/tests/php/Controllers/LinkFieldControllerTest.php @@ -506,6 +506,7 @@ public function provideLinkData(): array 'canDelete' => true, 'versionState' => 'draft', 'typeKey' => 'testphone', + 'sort' => 1, ], ], 'Reject invalid ID' => [