gutengood-js 2.1.0 → 2.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- (()=>{"use strict";var e={n:t=>{var n=t&&t.__esModule?()=>t.default:()=>t;return e.d(n,{a:n}),n},d:(t,n)=>{for(var r in n)e.o(n,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:n[r]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)};const t=window.wp.blocks,n=window.wp.plugins,r=window.wp.editor,o=window.wp.element,i=window.wp.data,a=window.wp.components,l=window.wp.apiFetch;var s=e.n(l);const c=window.wp.blockEditor,d=window.ReactJSXRuntime,u=({open:e,remove:t,mediaId:n})=>{const r=(0,i.useSelect)((e=>e("core").getMedia(n)),[n]),o=r?.media_details?.sizes?.thumbnail?.source_url||r?.source_url||null;return(0,d.jsx)("div",{className:"image-component",children:o?(0,d.jsx)("div",{children:(0,d.jsxs)("div",{children:[(0,d.jsx)("img",{className:"image-component-image",src:o,alt:""}),(0,d.jsxs)("div",{className:"image-component-buttons",children:[(0,d.jsx)(a.Button,{onClick:e,icon:"edit"}),(0,d.jsx)(a.Button,{icon:"trash",onClick:t})]})]})}):(0,d.jsx)(a.Button,{className:"is-primary",onClick:e,children:"Choose Image"})})},h=()=>(0,d.jsx)(a.Icon,{icon:()=>(0,d.jsx)("svg",{className:"file-component-icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 448 512",children:(0,d.jsx)("path",{d:"M380.7 67.3c-29.1-29.1-76.3-29.1-105.4 0l-192 192c-46.8 46.8-46.8 122.6 0 169.4s122.6 46.8 169.4 0l152-152c6.2-6.2 16.4-6.2 22.6 0s6.2 16.4 0 22.6l-152 152c-59.3 59.3-155.4 59.3-214.6 0S1.4 296 60.7 236.7l192-192c41.6-41.6 109-41.6 150.6 0s41.6 109 0 150.6L219.5 379.1c-28.2 28.2-74.6 25.6-99.6-5.5c-21.3-26.6-19.2-65 4.9-89.1L276.7 132.7c6.2-6.2 16.4-6.2 22.6 0s6.2 16.4 0 22.6L147.5 307.1c-12.6 12.6-13.7 32.6-2.6 46.5c13 16.2 37.2 17.6 51.9 2.9L380.7 172.7c29.1-29.1 29.1-76.3 0-105.4z"})})}),p=({open:e,remove:t,file:n})=>(0,d.jsxs)("div",{className:"file-component",children:[(0,d.jsx)(h,{}),n&&n.id?(0,d.jsxs)("div",{className:"file-component-info",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("span",{className:"file-component-info-name",children:n.name}),(0,d.jsx)("span",{className:"file-component-info-size",children:n.size})]}),(0,d.jsx)(a.Button,{className:"delete-file-button",icon:"trash",onClick:t})]}):(0,d.jsx)(a.Button,{onClick:e,children:"Select File"})]}),f=window.React;var g=e.n(f);const v=window.ReactDOM,m="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement;function b(e){const t=Object.prototype.toString.call(e);return"[object Window]"===t||"[object global]"===t}function x(e){return"nodeType"in e}function w(e){var t,n;return e?b(e)?e:x(e)&&null!=(t=null==(n=e.ownerDocument)?void 0:n.defaultView)?t:window:window}function y(e){const{Document:t}=w(e);return e instanceof t}function C(e){return!b(e)&&e instanceof w(e).HTMLElement}function D(e){return e instanceof w(e).SVGElement}function R(e){return e?b(e)?e.document:x(e)?y(e)?e:C(e)||D(e)?e.ownerDocument:document:document:document}const E=m?f.useLayoutEffect:f.useEffect;function S(e){const t=(0,f.useRef)(e);return E((()=>{t.current=e})),(0,f.useCallback)((function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return null==t.current?void 0:t.current(...n)}),[])}function j(e,t){void 0===t&&(t=[e]);const n=(0,f.useRef)(e);return E((()=>{n.current!==e&&(n.current=e)}),t),n}function N(e,t){const n=(0,f.useRef)();return(0,f.useMemo)((()=>{const t=e(n.current);return n.current=t,t}),[...t])}function M(e){const t=S(e),n=(0,f.useRef)(null),r=(0,f.useCallback)((e=>{e!==n.current&&(null==t||t(e,n.current)),n.current=e}),[]);return[n,r]}function k(e){const t=(0,f.useRef)();return(0,f.useEffect)((()=>{t.current=e}),[e]),t.current}let I={};function T(e,t){return(0,f.useMemo)((()=>{if(t)return t;const n=null==I[e]?0:I[e]+1;return I[e]=n,e+"-"+n}),[e,t])}function L(e){return function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return r.reduce(((t,n)=>{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 A=L(1),B=L(-1);function O(e){if(!e)return!1;const{KeyboardEvent:t}=w(e.target);return t&&e instanceof t}function P(e){if(function(e){if(!e)return!1;const{TouchEvent:t}=w(e.target);return t&&e instanceof t}(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 function(e){return"clientX"in e&&"clientY"in e}(e)?{x:e.clientX,y:e.clientY}:null}const z=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[z.Translate.toString(e),z.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+" "+n+"ms "+r}}}),F="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function U(e){return e.matches(F)?e:e.querySelector(F)}const H={display:"none"};function V(e){let{id:t,value:n}=e;return g().createElement("div",{id:t,style:H},n)}function X(e){let{id:t,announcement:n,ariaLiveType:r="assertive"}=e;return g().createElement("div",{id:t,style:{position:"fixed",top:0,left:0,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 Y=(0,f.createContext)(null),K={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 "},W={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 _(e){let{announcements:t=W,container:n,hiddenTextDescribedById:r,screenReaderInstructions:o=K}=e;const{announce:i,announcement:a}=function(){const[e,t]=(0,f.useState)("");return{announce:(0,f.useCallback)((e=>{null!=e&&t(e)}),[]),announcement:e}}(),l=T("DndLiveRegion"),[s,c]=(0,f.useState)(!1);if((0,f.useEffect)((()=>{c(!0)}),[]),function(e){const t=(0,f.useContext)(Y);(0,f.useEffect)((()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)}),[e,t])}((0,f.useMemo)((()=>({onDragStart(e){let{active:n}=e;i(t.onDragStart({active:n}))},onDragMove(e){let{active:n,over:r}=e;t.onDragMove&&i(t.onDragMove({active:n,over:r}))},onDragOver(e){let{active:n,over:r}=e;i(t.onDragOver({active:n,over:r}))},onDragEnd(e){let{active:n,over:r}=e;i(t.onDragEnd({active:n,over:r}))},onDragCancel(e){let{active:n,over:r}=e;i(t.onDragCancel({active:n,over:r}))}})),[i,t])),!s)return null;const d=g().createElement(g().Fragment,null,g().createElement(V,{id:r,value:o.draggable}),g().createElement(X,{id:l,announcement:a}));return n?(0,v.createPortal)(d,n):d}var G;function J(){}function q(e,t){return(0,f.useMemo)((()=>({sensor:e,options:null!=t?t:{}})),[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"}(G||(G={}));const $=Object.freeze({x:0,y:0});function Z(e,t){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}function Q(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return n-r}function ee(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return r-n}function te(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 ne(e,t){if(!e||0===e.length)return null;const[n]=e;return t?n[t]:n}function re(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 oe=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const o=re(t,t.left,t.top),i=[];for(const e of r){const{id:t}=e,r=n.get(t);if(r){const n=Z(re(r),o);i.push({id:t,data:{droppableContainer:e,value:n}})}}return i.sort(Q)};function ie(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<o&&n<i){const n=t.width*t.height,r=e.width*e.height,o=a*l;return Number((o/(n+r-o)).toFixed(4))}return 0}const ae=e=>{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=ie(i,t);n>0&&o.push({id:r,data:{droppableContainer:e,value:n}})}}return o.sort(ee)};function le(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:$}function se(e){return function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return r.reduce(((t,n)=>({...t,top:t.top+e*n.y,bottom:t.bottom+e*n.y,left:t.left+e*n.x,right:t.right+e*n.x})),{...t})}}const ce=se(1);const de={ignoreTransform:!1};function ue(e,t){void 0===t&&(t=de);let n=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:t,transformOrigin:r}=w(e).getComputedStyle(e);t&&(n=function(e,t,n){const r=function(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}(t);if(!r)return e;const{scaleX:o,scaleY:i,x:a,y:l}=r,s=e.left-a-(1-o)*parseFloat(n),c=e.top-l-(1-i)*parseFloat(n.slice(n.indexOf(" ")+1)),d=o?e.width/o:e.width,u=i?e.height/i:e.height;return{width:d,height:u,top:c,right:s+d,bottom:c+u,left:s}}(n,t,r))}const{top:r,left:o,width:i,height:a,bottom:l,right:s}=n;return{top:r,left:o,width:i,height:a,bottom:l,right:s}}function he(e){return ue(e,{ignoreTransform:!0})}function pe(e,t){const n=[];return e?function r(o){if(null!=t&&n.length>=t)return n;if(!o)return n;if(y(o)&&null!=o.scrollingElement&&!n.includes(o.scrollingElement))return n.push(o.scrollingElement),n;if(!C(o)||D(o))return n;if(n.includes(o))return n;const i=w(e).getComputedStyle(o);return o!==e&&function(e,t){void 0===t&&(t=w(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=w(e).getComputedStyle(e)),"fixed"===t.position}(o,i)?n:r(o.parentNode)}(e):n}function fe(e){const[t]=pe(e,1);return null!=t?t:null}function ge(e){return m&&e?b(e)?e:x(e)?y(e)||e===R(e).scrollingElement?window:C(e)?e:null:null:null}function ve(e){return b(e)?e.scrollX:e.scrollLeft}function me(e){return b(e)?e.scrollY:e.scrollTop}function be(e){return{x:ve(e),y:me(e)}}var xe;function we(e){return!(!m||!e)&&e===document.scrollingElement}function ye(e){const t={x:0,y:0},n=we(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"}(xe||(xe={}));const Ce={x:.2,y:.2};function De(e,t,n,r,o){let{top:i,left:a,right:l,bottom:s}=n;void 0===r&&(r=10),void 0===o&&(o=Ce);const{isTop:c,isBottom:d,isLeft:u,isRight:h}=ye(e),p={x:0,y:0},f={x:0,y:0},g=t.height*o.y,v=t.width*o.x;return!c&&i<=t.top+g?(p.y=xe.Backward,f.y=r*Math.abs((t.top+g-i)/g)):!d&&s>=t.bottom-g&&(p.y=xe.Forward,f.y=r*Math.abs((t.bottom-g-s)/g)),!h&&l>=t.right-v?(p.x=xe.Forward,f.x=r*Math.abs((t.right-v-l)/v)):!u&&a<=t.left+v&&(p.x=xe.Backward,f.x=r*Math.abs((t.left+v-a)/v)),{direction:p,speed:f}}function Re(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 Ee(e){return e.reduce(((e,t)=>A(e,be(t))),$)}const Se=[["x",["left","right"],function(e){return e.reduce(((e,t)=>e+ve(t)),0)}],["y",["top","bottom"],function(e){return e.reduce(((e,t)=>e+me(t)),0)}]];class je{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=pe(t),r=Ee(n);this.rect={...e},this.width=e.width,this.height=e.height;for(const[e,t,o]of Se)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 Me(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 ke,Ie;function Te(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"}(ke||(ke={})),function(e){e.Space="Space",e.Down="ArrowDown",e.Right="ArrowRight",e.Left="ArrowLeft",e.Up="ArrowUp",e.Esc="Escape",e.Enter="Enter",e.Tab="Tab"}(Ie||(Ie={}));const Ae={start:[Ie.Space,Ie.Enter],cancel:[Ie.Esc],end:[Ie.Space,Ie.Enter,Ie.Tab]},Be=(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 Oe{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(R(t)),this.windowListeners=new Ne(w(t)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(ke.Resize,this.handleCancel),this.windowListeners.add(ke.VisibilityChange,this.handleCancel),setTimeout((()=>this.listeners.add(ke.Keydown,this.handleKeyDown)))}handleStart(){const{activeNode:e,onStart:t}=this.props,n=e.node.current;n&&function(e,t){if(void 0===t&&(t=ue),!e)return;const{top:n,left:r,bottom:o,right:i}=t(e);fe(e)&&(o<=0||i<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}(n),t($)}handleKeyDown(e){if(O(e)){const{active:t,context:n,options:r}=this.props,{keyboardCodes:o=Ae,coordinateGetter:i=Be,scrollBehavior:a="smooth"}=r,{code:l}=e;if(o.end.includes(l))return void this.handleEnd(e);if(o.cancel.includes(l))return void this.handleCancel(e);const{collisionRect:s}=n.current,c=s?{x:s.left,y:s.top}:$;this.referenceCoordinates||(this.referenceCoordinates=c);const d=i(e,{active:t,context:n.current,currentCoordinates:c});if(d){const t=B(d,c),r={x:0,y:0},{scrollableAncestors:o}=n.current;for(const n of o){const o=e.code,{isTop:i,isRight:l,isLeft:s,isBottom:c,maxScroll:u,minScroll:h}=ye(n),p=Re(n),f={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))},g=o===Ie.Right&&!l||o===Ie.Left&&!s,v=o===Ie.Down&&!c||o===Ie.Up&&!i;if(g&&f.x!==d.x){const e=n.scrollLeft+t.x,i=o===Ie.Right&&e<=u.x||o===Ie.Left&&e>=h.x;if(i&&!t.y)return void n.scrollTo({left:e,behavior:a});r.x=i?n.scrollLeft-e:o===Ie.Right?n.scrollLeft-u.x:n.scrollLeft-h.x,r.x&&n.scrollBy({left:-r.x,behavior:a});break}if(v&&f.y!==d.y){const e=n.scrollTop+t.y,i=o===Ie.Down&&e<=u.y||o===Ie.Up&&e>=h.y;if(i&&!t.x)return void n.scrollTo({top:e,behavior:a});r.y=i?n.scrollTop-e:o===Ie.Down?n.scrollTop-u.y:n.scrollTop-h.y,r.y&&n.scrollBy({top:-r.y,behavior:a});break}}this.handleMove(e,A(B(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 Pe(e){return Boolean(e&&"distance"in e)}function ze(e){return Boolean(e&&"delay"in e)}Oe.activators=[{eventName:"onKeyDown",handler:(e,t,n)=>{let{keyboardCodes:r=Ae,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 Fe{constructor(e,t,n){var r;void 0===n&&(n=function(e){const{EventTarget:t}=w(e);return e instanceof t?e:R(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=R(i),this.documentListeners=new Ne(this.document),this.listeners=new Ne(n),this.windowListeners=new Ne(w(i)),this.initialCoordinates=null!=(r=P(o))?r:$,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),e.cancel&&this.listeners.add(e.cancel.name,this.handleCancel),this.windowListeners.add(ke.Resize,this.handleCancel),this.windowListeners.add(ke.DragStart,Te),this.windowListeners.add(ke.VisibilityChange,this.handleCancel),this.windowListeners.add(ke.ContextMenu,Te),this.documentListeners.add(ke.Keydown,this.handleKeydown),t){if(null!=n&&n({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(ze(t))return this.timeoutId=setTimeout(this.handleStart,t.delay),void this.handlePending(t);if(Pe(t))return void this.handlePending(t)}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),null!==this.timeoutId&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(e,t){const{active:n,onPending:r}=this.props;r(n,e,this.initialCoordinates,t)}handleStart(){const{initialCoordinates:e}=this,{onStart:t}=this.props;e&&(this.activated=!0,this.documentListeners.add(ke.Click,Le,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(ke.SelectionChange,this.removeTextSelection),t(e))}handleMove(e){var t;const{activated:n,initialCoordinates:r,props:o}=this,{onMove:i,options:{activationConstraint:a}}=o;if(!r)return;const l=null!=(t=P(e))?t:$,s=B(r,l);if(!n&&a){if(Pe(a)){if(null!=a.tolerance&&Me(s,a.tolerance))return this.handleCancel();if(Me(s,a.distance))return this.handleStart()}return ze(a)&&Me(s,a.tolerance)?this.handleCancel():void this.handlePending(a,s)}e.cancelable&&e.preventDefault(),i(l)}handleEnd(){const{onAbort:e,onEnd:t}=this.props;this.detach(),this.activated||e(this.props.active),t()}handleCancel(){const{onAbort:e,onCancel:t}=this.props;this.detach(),this.activated||e(this.props.active),t()}handleKeydown(e){e.code===Ie.Esc&&this.handleCancel()}removeTextSelection(){var e;null==(e=this.document.getSelection())||e.removeAllRanges()}}const Ue={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class He extends Fe{constructor(e){const{event:t}=e,n=R(t.target);super(e,Ue,n)}}He.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 Ve={move:{name:"mousemove"},end:{name:"mouseup"}};var Xe;!function(e){e[e.RightClick=2]="RightClick"}(Xe||(Xe={})),class extends Fe{constructor(e){super(e,Ve,R(e.event.target))}}.activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button!==Xe.RightClick&&(null==r||r({event:n}),!0)}}];const Ye={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};var Ke,We;(class extends Fe{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(){}}}).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"}(Ke||(Ke={})),function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"}(We||(We={}));const _e={x:{[xe.Backward]:!1,[xe.Forward]:!1},y:{[xe.Backward]:!1,[xe.Forward]:!1}};var Ge,Je;!function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"}(Ge||(Ge={})),function(e){e.Optimized="optimized"}(Je||(Je={}));const qe=new Map;function $e(e,t){return N((n=>e?n||("function"==typeof t?t(e):e):null),[t,e])}function Ze(e){let{callback:t,disabled:n}=e;const r=S(t),o=(0,f.useMemo)((()=>{if(n||"undefined"==typeof window||void 0===window.ResizeObserver)return;const{ResizeObserver:e}=window;return new e(r)}),[n]);return(0,f.useEffect)((()=>()=>null==o?void 0:o.disconnect()),[o]),o}function Qe(e){return new je(ue(e),e)}function et(e,t,n){void 0===t&&(t=Qe);const[r,o]=(0,f.useState)(null);function i(){o((r=>{if(!e)return null;var o;if(!1===e.isConnected)return null!=(o=null!=r?r:n)?o:null;const i=t(e);return JSON.stringify(r)===JSON.stringify(i)?r:i}))}const a=function(e){let{callback:t,disabled:n}=e;const r=S(t),o=(0,f.useMemo)((()=>{if(n||"undefined"==typeof window||void 0===window.MutationObserver)return;const{MutationObserver:e}=window;return new e(r)}),[r,n]);return(0,f.useEffect)((()=>()=>null==o?void 0:o.disconnect()),[o]),o}({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}}}}),l=Ze({callback:i});return E((()=>{i(),e?(null==l||l.observe(e),null==a||a.observe(document.body,{childList:!0,subtree:!0})):(null==l||l.disconnect(),null==a||a.disconnect())}),[e]),r}const tt=[];function nt(e,t){void 0===t&&(t=[]);const n=(0,f.useRef)(null);return(0,f.useEffect)((()=>{n.current=null}),t),(0,f.useEffect)((()=>{const t=e!==$;t&&!n.current&&(n.current=e),!t&&n.current&&(n.current=null)}),[e]),n.current?B(e,n.current):$}function rt(e){return(0,f.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 ot=[];const it=[{sensor:He,options:{}},{sensor:Oe,options:{}}],at={current:{}},lt={draggable:{measure:he},droppable:{measure:he,strategy:Ge.WhileDragging,frequency:Je.Optimized},dragOverlay:{measure:ue}};class st 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 ct={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new st,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:J},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:lt,measureDroppableContainers:J,windowRect:null,measuringScheduled:!1},dt={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:J,draggableNodes:new Map,over:null,measureDroppableContainers:J},ut=(0,f.createContext)(dt),ht=(0,f.createContext)(ct);function pt(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new st}}}function ft(e,t){switch(t.type){case G.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case G.DragMove:return null==e.draggable.active?e:{...e,draggable:{...e.draggable,translate:{x:t.coordinates.x-e.draggable.initialCoordinates.x,y:t.coordinates.y-e.draggable.initialCoordinates.y}}};case G.DragEnd:case G.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case G.RegisterDroppable:{const{element:n}=t,{id:r}=n,o=new st(e.droppable.containers);return o.set(r,n),{...e,droppable:{...e.droppable,containers:o}}}case G.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 st(e.droppable.containers);return a.set(n,{...i,disabled:o}),{...e,droppable:{...e.droppable,containers:a}}}case G.UnregisterDroppable:{const{id:n,key:r}=t,o=e.droppable.containers.get(n);if(!o||r!==o.key)return e;const i=new st(e.droppable.containers);return i.delete(n),{...e,droppable:{...e.droppable,containers:i}}}default:return e}}function gt(e){let{disabled:t}=e;const{active:n,activatorEvent:r,draggableNodes:o}=(0,f.useContext)(ut),i=k(r),a=k(null==n?void 0:n.id);return(0,f.useEffect)((()=>{if(!t&&!r&&i&&null!=a){if(!O(i))return;if(document.activeElement===i.target)return;const e=o.get(a);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=U(e);if(t){t.focus();break}}}))}}),[r,t,o,a,i]),null}const vt=(0,f.createContext)({...$,scaleX:1,scaleY:1});var mt;!function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"}(mt||(mt={}));const bt=(0,f.memo)((function(e){var t,n,r,o;let{id:i,accessibility:a,autoScroll:l=!0,children:s,sensors:c=it,collisionDetection:d=ae,measuring:u,modifiers:h,...p}=e;const b=(0,f.useReducer)(ft,void 0,pt),[x,y]=b,[D,R]=function(){const[e]=(0,f.useState)((()=>new Set)),t=(0,f.useCallback)((t=>(e.add(t),()=>e.delete(t))),[e]);return[(0,f.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]}(),[S,I]=(0,f.useState)(mt.Uninitialized),L=S===mt.Initialized,{draggable:{active:B,nodes:O,translate:z},droppable:{containers:F}}=x,U=null!=B?O.get(B):null,H=(0,f.useRef)({initial:null,translated:null}),V=(0,f.useMemo)((()=>{var e;return null!=B?{id:B,data:null!=(e=null==U?void 0:U.data)?e:at,rect:H}:null}),[B,U]),X=(0,f.useRef)(null),[K,W]=(0,f.useState)(null),[J,q]=(0,f.useState)(null),Z=j(p,Object.values(p)),Q=T("DndDescribedBy",i),ee=(0,f.useMemo)((()=>F.getEnabled()),[F]),te=(re=u,(0,f.useMemo)((()=>({draggable:{...lt.draggable,...null==re?void 0:re.draggable},droppable:{...lt.droppable,...null==re?void 0:re.droppable},dragOverlay:{...lt.dragOverlay,...null==re?void 0:re.dragOverlay}})),[null==re?void 0:re.draggable,null==re?void 0:re.droppable,null==re?void 0:re.dragOverlay]));var re;const{droppableRects:oe,measureDroppableContainers:ie,measuringScheduled:se}=function(e,t){let{dragging:n,dependencies:r,config:o}=t;const[i,a]=(0,f.useState)(null),{frequency:l,measure:s,strategy:c}=o,d=(0,f.useRef)(e),u=function(){switch(c){case Ge.Always:return!1;case Ge.BeforeDragging:return n;default:return!n}}(),h=j(u),p=(0,f.useCallback)((function(e){void 0===e&&(e=[]),h.current||a((t=>null===t?e:t.concat(e.filter((e=>!t.includes(e))))))}),[h]),g=(0,f.useRef)(null),v=N((t=>{if(u&&!n)return qe;if(!t||t===qe||d.current!==e||null!=i){const t=new Map;for(let n of e){if(!n)continue;if(i&&i.length>0&&!i.includes(n.id)&&n.rect.current){t.set(n.id,n.rect.current);continue}const e=n.node.current,r=e?new je(s(e),e):null;n.rect.current=r,r&&t.set(n.id,r)}return t}return t}),[e,i,n,u,s]);return(0,f.useEffect)((()=>{d.current=e}),[e]),(0,f.useEffect)((()=>{u||p()}),[n,u]),(0,f.useEffect)((()=>{i&&i.length>0&&a(null)}),[JSON.stringify(i)]),(0,f.useEffect)((()=>{u||"number"!=typeof l||null!==g.current||(g.current=setTimeout((()=>{p(),g.current=null}),l))}),[l,u,p,...r]),{droppableRects:v,measureDroppableContainers:p,measuringScheduled:null!=i}}(ee,{dragging:L,dependencies:[z.x,z.y],config:te.droppable}),de=function(e,t){const n=null!=t?e.get(t):void 0,r=n?n.node.current:null;return N((e=>{var n;return null==t?null:null!=(n=null!=r?r:e)?n:null}),[r,t])}(O,B),he=(0,f.useMemo)((()=>J?P(J):null),[J]),ve=function(){const e=!1===(null==K?void 0:K.autoScrollEnabled),t="object"==typeof l?!1===l.enabled:!1===l,n=L&&!e&&!t;return"object"==typeof l?{...l,enabled:n}:{enabled:n}}(),me=function(e,t){return $e(e,t)}(de,te.draggable.measure);!function(e){let{activeNode:t,measure:n,initialRect:r,config:o=!0}=e;const i=(0,f.useRef)(!1),{x:a,y:l}="boolean"==typeof o?{x:o,y:o}:o;E((()=>{if(!a&&!l||!t)return void(i.current=!1);if(i.current||!r)return;const e=null==t?void 0:t.node.current;if(!e||!1===e.isConnected)return;const o=le(n(e),r);if(a||(o.x=0),l||(o.y=0),i.current=!0,Math.abs(o.x)>0||Math.abs(o.y)>0){const t=fe(e);t&&t.scrollBy({top:o.y,left:o.x})}}),[t,a,l,r,n])}({activeNode:null!=B?O.get(B):null,config:ve.layoutShiftCompensation,initialRect:me,measure:te.draggable.measure});const ye=et(de,te.draggable.measure,me),Ce=et(de?de.parentElement:null),Re=(0,f.useRef)({activatorEvent:null,active:null,activeNode:de,collisionRect:null,collisions:null,droppableRects:oe,draggableNodes:O,draggingNode:null,draggingNodeRect:null,droppableContainers:F,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),Se=F.getNodeFor(null==(t=Re.current.over)?void 0:t.id),Ne=function(e){let{measure:t}=e;const[n,r]=(0,f.useState)(null),o=Ze({callback:(0,f.useCallback)((e=>{for(const{target:n}of e)if(C(n)){r((e=>{const r=t(n);return e?{...e,width:r.width,height:r.height}:r}));break}}),[t])}),i=(0,f.useCallback)((e=>{const n=function(e){if(!e)return null;if(e.children.length>1)return e;const t=e.children[0];return C(t)?t:e}(e);null==o||o.disconnect(),n&&(null==o||o.observe(n)),r(n?t(n):null)}),[t,o]),[a,l]=M(i);return(0,f.useMemo)((()=>({nodeRef:a,rect:n,setRef:l})),[n,a,l])}({measure:te.dragOverlay.measure}),Me=null!=(n=Ne.nodeRef.current)?n:de,ke=L?null!=(r=Ne.rect)?r:ye:null,Ie=Boolean(Ne.nodeRef.current&&Ne.rect),Te=le(Le=Ie?null:ye,$e(Le));var Le;const Ae=rt(Me?w(Me):null),Be=function(e){const t=(0,f.useRef)(e),n=N((n=>e?n&&n!==tt&&e&&t.current&&e.parentNode===t.current.parentNode?n:pe(e):tt),[e]);return(0,f.useEffect)((()=>{t.current=e}),[e]),n}(L?null!=Se?Se:de:null),Oe=function(e,t){void 0===t&&(t=ue);const[n]=e,r=rt(n?w(n):null),[o,i]=(0,f.useState)(ot);function a(){i((()=>e.length?e.map((e=>we(e)?r:new je(t(e),e))):ot))}const l=Ze({callback:a});return E((()=>{null==l||l.disconnect(),a(),e.forEach((e=>null==l?void 0:l.observe(e)))}),[e]),o}(Be),Pe=function(e,t){let{transform:n,...r}=t;return null!=e&&e.length?e.reduce(((e,t)=>t({transform:e,...r})),n):n}(h,{transform:{x:z.x-Te.x,y:z.y-Te.y,scaleX:1,scaleY:1},activatorEvent:J,active:V,activeNodeRect:ye,containerNodeRect:Ce,draggingNodeRect:ke,over:Re.current.over,overlayNodeRect:Ne.rect,scrollableAncestors:Be,scrollableAncestorRects:Oe,windowRect:Ae}),ze=he?A(he,z):null,Fe=function(e){const[t,n]=(0,f.useState)(null),r=(0,f.useRef)(e),o=(0,f.useCallback)((e=>{const t=ge(e.target);t&&n((e=>e?(e.set(t,be(t)),new Map(e)):null))}),[]);return(0,f.useEffect)((()=>{const t=r.current;if(e!==t){i(t);const a=e.map((e=>{const t=ge(e);return t?(t.addEventListener("scroll",o,{passive:!0}),[t,be(t)]):null})).filter((e=>null!=e));n(a.length?new Map(a):null),r.current=e}return()=>{i(e),i(t)};function i(e){e.forEach((e=>{const t=ge(e);null==t||t.removeEventListener("scroll",o)}))}}),[o,e]),(0,f.useMemo)((()=>e.length?t?Array.from(t.values()).reduce(((e,t)=>A(e,t)),$):Ee(e):$),[e,t])}(Be),Ue=nt(Fe),He=nt(Fe,[ye]),Ve=A(Pe,Ue),Xe=ke?ce(ke,Pe):null,Ye=V&&Xe?d({active:V,collisionRect:Xe,droppableRects:oe,droppableContainers:ee,pointerCoordinates:ze}):null,Je=ne(Ye,"id"),[Qe,st]=(0,f.useState)(null),ct=function(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}(Ie?Pe:A(Pe,He),null!=(o=null==Qe?void 0:Qe.rect)?o:null,ye),dt=(0,f.useRef)(null),bt=(0,f.useCallback)(((e,t)=>{let{sensor:n,options:r}=t;if(null==X.current)return;const o=O.get(X.current);if(!o)return;const i=e.nativeEvent,a=new n({active:X.current,activeNode:o,event:i,options:r,context:Re,onAbort(e){if(!O.get(e))return;const{onDragAbort:t}=Z.current,n={id:e};null==t||t(n),D({type:"onDragAbort",event:n})},onPending(e,t,n,r){if(!O.get(e))return;const{onDragPending:o}=Z.current,i={id:e,constraint:t,initialCoordinates:n,offset:r};null==o||o(i),D({type:"onDragPending",event:i})},onStart(e){const t=X.current;if(null==t)return;const n=O.get(t);if(!n)return;const{onDragStart:r}=Z.current,o={activatorEvent:i,active:{id:t,data:n.data,rect:H}};(0,v.unstable_batchedUpdates)((()=>{null==r||r(o),I(mt.Initializing),y({type:G.DragStart,initialCoordinates:e,active:t}),D({type:"onDragStart",event:o}),W(dt.current),q(i)}))},onMove(e){y({type:G.DragMove,coordinates:e})},onEnd:l(G.DragEnd),onCancel:l(G.DragCancel)});function l(e){return async function(){const{active:t,collisions:n,over:r,scrollAdjustedTranslate:o}=Re.current;let a=null;if(t&&o){const{cancelDrop:l}=Z.current;a={activatorEvent:i,active:t,collisions:n,delta:o,over:r},e===G.DragEnd&&"function"==typeof l&&await Promise.resolve(l(a))&&(e=G.DragCancel)}X.current=null,(0,v.unstable_batchedUpdates)((()=>{y({type:e}),I(mt.Uninitialized),st(null),W(null),q(null),dt.current=null;const t=e===G.DragEnd?"onDragEnd":"onDragCancel";if(a){const e=Z.current[t];null==e||e(a),D({type:t,event:a})}}))}}dt.current=a}),[O]),xt=(0,f.useCallback)(((e,t)=>(n,r)=>{const o=n.nativeEvent,i=O.get(r);if(null!==X.current||!i||o.dndKit||o.defaultPrevented)return;const a={active:i};!0===e(n,t.options,a)&&(o.dndKit={capturedBy:t.sensor},X.current=r,bt(n,t))}),[O,bt]),wt=function(e,t){return(0,f.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])}(c,xt);!function(e){(0,f.useEffect)((()=>{if(!m)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})))}(c),E((()=>{ye&&S===mt.Initializing&&I(mt.Initialized)}),[ye,S]),(0,f.useEffect)((()=>{const{onDragMove:e}=Z.current,{active:t,activatorEvent:n,collisions:r,over:o}=Re.current;if(!t||!n)return;const i={active:t,activatorEvent:n,collisions:r,delta:{x:Ve.x,y:Ve.y},over:o};(0,v.unstable_batchedUpdates)((()=>{null==e||e(i),D({type:"onDragMove",event:i})}))}),[Ve.x,Ve.y]),(0,f.useEffect)((()=>{const{active:e,activatorEvent:t,collisions:n,droppableContainers:r,scrollAdjustedTranslate:o}=Re.current;if(!e||null==X.current||!t||!o)return;const{onDragOver:i}=Z.current,a=r.get(Je),l=a&&a.rect.current?{id:a.id,rect:a.rect.current,data:a.data,disabled:a.disabled}:null,s={active:e,activatorEvent:t,collisions:n,delta:{x:o.x,y:o.y},over:l};(0,v.unstable_batchedUpdates)((()=>{st(l),null==i||i(s),D({type:"onDragOver",event:s})}))}),[Je]),E((()=>{Re.current={activatorEvent:J,active:V,activeNode:de,collisionRect:Xe,collisions:Ye,droppableRects:oe,draggableNodes:O,draggingNode:Me,draggingNodeRect:ke,droppableContainers:F,over:Qe,scrollableAncestors:Be,scrollAdjustedTranslate:Ve},H.current={initial:ke,translated:Xe}}),[V,de,Ye,Xe,O,Me,ke,oe,F,Qe,Be,Ve]),function(e){let{acceleration:t,activator:n=Ke.Pointer,canScroll:r,draggingRect:o,enabled:i,interval:a=5,order:l=We.TreeOrder,pointerCoordinates:s,scrollableAncestors:c,scrollableAncestorRects:d,delta:u,threshold:h}=e;const p=function(e){let{delta:t,disabled:n}=e;const r=k(t);return N((e=>{if(n||!r||!e)return _e;const o=Math.sign(t.x-r.x),i=Math.sign(t.y-r.y);return{x:{[xe.Backward]:e.x[xe.Backward]||-1===o,[xe.Forward]:e.x[xe.Forward]||1===o},y:{[xe.Backward]:e.y[xe.Backward]||-1===i,[xe.Forward]:e.y[xe.Forward]||1===i}}}),[n,t,r])}({delta:u,disabled:!i}),[g,v]=function(){const e=(0,f.useRef)(null);return[(0,f.useCallback)(((t,n)=>{e.current=setInterval(t,n)}),[]),(0,f.useCallback)((()=>{null!==e.current&&(clearInterval(e.current),e.current=null)}),[])]}(),m=(0,f.useRef)({x:0,y:0}),b=(0,f.useRef)({x:0,y:0}),x=(0,f.useMemo)((()=>{switch(n){case Ke.Pointer:return s?{top:s.y,bottom:s.y,left:s.x,right:s.x}:null;case Ke.DraggableRect:return o}}),[n,o,s]),w=(0,f.useRef)(null),y=(0,f.useCallback)((()=>{const e=w.current;if(!e)return;const t=m.current.x*b.current.x,n=m.current.y*b.current.y;e.scrollBy(t,n)}),[]),C=(0,f.useMemo)((()=>l===We.TreeOrder?[...c].reverse():c),[l,c]);(0,f.useEffect)((()=>{if(i&&c.length&&x){for(const e of C){if(!1===(null==r?void 0:r(e)))continue;const n=c.indexOf(e),o=d[n];if(!o)continue;const{direction:i,speed:l}=De(e,o,x,t,h);for(const e of["x","y"])p[e][i[e]]||(l[e]=0,i[e]=0);if(l.x>0||l.y>0)return v(),w.current=e,g(y,a),m.current=l,void(b.current=i)}m.current={x:0,y:0},b.current={x:0,y:0},v()}else v()}),[t,y,r,v,i,a,JSON.stringify(x),JSON.stringify(p),g,c,C,d,JSON.stringify(h)])}({...ve,delta:z,draggingRect:Xe,pointerCoordinates:ze,scrollableAncestors:Be,scrollableAncestorRects:Oe});const yt=(0,f.useMemo)((()=>({active:V,activeNode:de,activeNodeRect:ye,activatorEvent:J,collisions:Ye,containerNodeRect:Ce,dragOverlay:Ne,draggableNodes:O,droppableContainers:F,droppableRects:oe,over:Qe,measureDroppableContainers:ie,scrollableAncestors:Be,scrollableAncestorRects:Oe,measuringConfiguration:te,measuringScheduled:se,windowRect:Ae})),[V,de,ye,J,Ye,Ce,Ne,O,F,oe,Qe,ie,Be,Oe,te,se,Ae]),Ct=(0,f.useMemo)((()=>({activatorEvent:J,activators:wt,active:V,activeNodeRect:ye,ariaDescribedById:{draggable:Q},dispatch:y,draggableNodes:O,over:Qe,measureDroppableContainers:ie})),[J,wt,V,ye,y,Q,O,Qe,ie]);return g().createElement(Y.Provider,{value:R},g().createElement(ut.Provider,{value:Ct},g().createElement(ht.Provider,{value:yt},g().createElement(vt.Provider,{value:ct},s)),g().createElement(gt,{disabled:!1===(null==a?void 0:a.restoreFocus)})),g().createElement(_,{...a,hiddenTextDescribedById:Q}))})),xt=(0,f.createContext)(null),wt="button";const yt={timeout:25};function Ct(e,t,n){const r=e.slice();return r.splice(n<0?r.length+n:n,0,r.splice(t,1)[0]),r}function Dt(e,t){return e.reduce(((e,n,r)=>{const o=t.get(n);return o&&(e[r]=o),e}),Array(e.length))}function Rt(e){return null!==e&&e>=0}const Et=e=>{let{rects:t,activeIndex:n,overIndex:r,index:o}=e;const i=Ct(t,r,n),a=t[o],l=i[o];return l&&a?{x:l.left-a.left,y:l.top-a.top,scaleX:l.width/a.width,scaleY:l.height/a.height}:null},St={scaleX:1,scaleY:1},jt=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:n<a?e.top+e.height-(l.top+l.height):e.top-l.top,...St}:null}const s=function(e,t,n){const r=e[t],o=e[t-1],i=e[t+1];return r?n<t?o?r.top-(o.top+o.height):i?i.top-(r.top+r.height):0:i?i.top-(r.top+r.height):o?r.top-(o.top+o.height):0:0}(i,o,n);return o>n&&o<=a?{x:0,y:-l.height-s,...St}:o<n&&o>=a?{x:0,y:l.height+s,...St}:{x:0,y:0,...St}},Nt="Sortable",Mt=g().createContext({activeIndex:-1,containerId:Nt,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:Et,disabled:{draggable:!1,droppable:!1}});function kt(e){let{children:t,id:n,items:r,strategy:o=Et,disabled:i=!1}=e;const{active:a,dragOverlay:l,droppableRects:s,over:c,measureDroppableContainers:d}=(0,f.useContext)(ht),u=T(Nt,n),h=Boolean(null!==l.rect),p=(0,f.useMemo)((()=>r.map((e=>"object"==typeof e&&"id"in e?e.id:e))),[r]),v=null!=a,m=a?p.indexOf(a.id):-1,b=c?p.indexOf(c.id):-1,x=(0,f.useRef)(p),w=!function(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}(p,x.current),y=-1!==b&&-1===m||w,C=function(e){return"boolean"==typeof e?{draggable:e,droppable:e}:e}(i);E((()=>{w&&v&&d(p)}),[w,p,v,d]),(0,f.useEffect)((()=>{x.current=p}),[p]);const D=(0,f.useMemo)((()=>({activeIndex:m,containerId:u,disabled:C,disableTransforms:y,items:p,overIndex:b,useDragOverlay:h,sortedRects:Dt(p,s),strategy:o})),[m,u,C.draggable,C.droppable,y,p,b,s,h,o]);return g().createElement(Mt.Provider,{value:D},t)}const It=e=>{let{id:t,items:n,activeIndex:r,overIndex:o}=e;return Ct(n,r,o).indexOf(t)},Tt=e=>{let{containerId:t,isSorting:n,wasDragging:r,index:o,items:i,newIndex:a,previousItems:l,previousContainerId:s,transition:c}=e;return!(!c||!r||l!==i&&o===a||!n&&(a===o||t!==s))},Lt={duration:200,easing:"ease"},At="transform",Bt=z.Transition.toString({property:At,duration:0,easing:"linear"}),Ot={roleDescription:"sortable"};function Pt(e){let{animateLayoutChanges:t=Tt,attributes:n,disabled:r,data:o,getNewIndex:i=It,id:a,strategy:l,resizeObserverConfig:s,transition:c=Lt}=e;const{items:d,containerId:u,activeIndex:h,disabled:p,disableTransforms:g,sortedRects:v,overIndex:m,useDragOverlay:b,strategy:x}=(0,f.useContext)(Mt),w=function(e,t){var n,r;return"boolean"==typeof e?{draggable:e,droppable:!1}:{draggable:null!=(n=null==e?void 0:e.draggable)?n:t.draggable,droppable:null!=(r=null==e?void 0:e.droppable)?r:t.droppable}}(r,p),y=d.indexOf(a),C=(0,f.useMemo)((()=>({sortable:{containerId:u,index:y,items:d},...o})),[u,o,y,d]),D=(0,f.useMemo)((()=>d.slice(d.indexOf(a))),[d,a]),{rect:R,node:S,isOver:N,setNodeRef:k}=function(e){let{data:t,disabled:n=!1,id:r,resizeObserverConfig:o}=e;const i=T("Droppable"),{active:a,dispatch:l,over:s,measureDroppableContainers:c}=(0,f.useContext)(ut),d=(0,f.useRef)({disabled:n}),u=(0,f.useRef)(!1),h=(0,f.useRef)(null),p=(0,f.useRef)(null),{disabled:g,updateMeasurementsFor:v,timeout:m}={...yt,...o},b=j(null!=v?v:r),x=Ze({callback:(0,f.useCallback)((()=>{u.current?(null!=p.current&&clearTimeout(p.current),p.current=setTimeout((()=>{c(Array.isArray(b.current)?b.current:[b.current]),p.current=null}),m)):u.current=!0}),[m]),disabled:g||!a}),w=(0,f.useCallback)(((e,t)=>{x&&(t&&(x.unobserve(t),u.current=!1),e&&x.observe(e))}),[x]),[y,C]=M(w),D=j(t);return(0,f.useEffect)((()=>{x&&y.current&&(x.disconnect(),u.current=!1,x.observe(y.current))}),[y,x]),(0,f.useEffect)((()=>(l({type:G.RegisterDroppable,element:{id:r,key:i,disabled:n,node:y,rect:h,data:D}}),()=>l({type:G.UnregisterDroppable,key:i,id:r}))),[r]),(0,f.useEffect)((()=>{n!==d.current.disabled&&(l({type:G.SetDroppableDisabled,id:r,key:i,disabled:n}),d.current.disabled=n)}),[r,i,n,l]),{active:a,rect:h,isOver:(null==s?void 0:s.id)===r,node:y,over:s,setNodeRef:C}}({id:a,data:C,disabled:w.droppable,resizeObserverConfig:{updateMeasurementsFor:D,...s}}),{active:I,activatorEvent:L,activeNodeRect:A,attributes:B,setNodeRef:P,listeners:F,isDragging:U,over:H,setActivatorNodeRef:V,transform:X}=function(e){let{id:t,data:n,disabled:r=!1,attributes:o}=e;const i=T("Draggable"),{activators:a,activatorEvent:l,active:s,activeNodeRect:c,ariaDescribedById:d,draggableNodes:u,over:h}=(0,f.useContext)(ut),{role:p=wt,roleDescription:g="draggable",tabIndex:v=0}=null!=o?o:{},m=(null==s?void 0:s.id)===t,b=(0,f.useContext)(m?vt:xt),[x,w]=M(),[y,C]=M(),D=function(e,t){return(0,f.useMemo)((()=>e.reduce(((e,n)=>{let{eventName:r,handler:o}=n;return e[r]=e=>{o(e,t)},e}),{})),[e,t])}(a,t),R=j(n);return E((()=>(u.set(t,{id:t,key:i,node:x,activatorNode:y,data:R}),()=>{const e=u.get(t);e&&e.key===i&&u.delete(t)})),[u,t]),{active:s,activatorEvent:l,activeNodeRect:c,attributes:(0,f.useMemo)((()=>({role:p,tabIndex:v,"aria-disabled":r,"aria-pressed":!(!m||p!==wt)||void 0,"aria-roledescription":g,"aria-describedby":d.draggable})),[r,p,v,m,g,d.draggable]),isDragging:m,listeners:r?void 0:D,node:x,over:h,setNodeRef:w,setActivatorNodeRef:C,transform:b}}({id:a,data:C,attributes:{...Ot,...n},disabled:w.draggable}),Y=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return(0,f.useMemo)((()=>e=>{t.forEach((t=>t(e)))}),t)}(k,P),K=Boolean(I),W=K&&!g&&Rt(h)&&Rt(m),_=!b&&U,J=_&&W?X:null,q=W?null!=J?J:(null!=l?l:x)({rects:v,activeNodeRect:A,activeIndex:h,overIndex:m,index:y}):null,$=Rt(h)&&Rt(m)?i({id:a,items:d,activeIndex:h,overIndex:m}):y,Z=null==I?void 0:I.id,Q=(0,f.useRef)({activeId:Z,items:d,newIndex:$,containerId:u}),ee=d!==Q.current.items,te=t({active:I,containerId:u,isDragging:U,isSorting:K,id:a,index:y,items:d,newIndex:Q.current.newIndex,previousItems:Q.current.items,previousContainerId:Q.current.containerId,transition:c,wasDragging:null!=Q.current.activeId}),ne=function(e){let{disabled:t,index:n,node:r,rect:o}=e;const[i,a]=(0,f.useState)(null),l=(0,f.useRef)(n);return E((()=>{if(!t&&n!==l.current&&r.current){const e=o.current;if(e){const t=ue(r.current,{ignoreTransform:!0}),n={x:e.left-t.left,y:e.top-t.top,scaleX:e.width/t.width,scaleY:e.height/t.height};(n.x||n.y)&&a(n)}}n!==l.current&&(l.current=n)}),[t,n,r,o]),(0,f.useEffect)((()=>{i&&a(null)}),[i]),i}({disabled:!te,index:y,node:S,rect:R});return(0,f.useEffect)((()=>{K&&Q.current.newIndex!==$&&(Q.current.newIndex=$),u!==Q.current.containerId&&(Q.current.containerId=u),d!==Q.current.items&&(Q.current.items=d)}),[K,$,u,d]),(0,f.useEffect)((()=>{if(Z===Q.current.activeId)return;if(null!=Z&&null==Q.current.activeId)return void(Q.current.activeId=Z);const e=setTimeout((()=>{Q.current.activeId=Z}),50);return()=>clearTimeout(e)}),[Z]),{active:I,activeIndex:h,attributes:B,data:C,rect:R,index:y,newIndex:$,items:d,isOver:N,isSorting:K,isDragging:U,listeners:F,node:S,overIndex:m,over:H,setNodeRef:Y,setActivatorNodeRef:V,setDroppableNodeRef:k,setDraggableNodeRef:P,transform:null!=ne?ne:q,transition:ne||ee&&Q.current.newIndex===y?Bt:_&&!O(L)||!c?void 0:K||te?z.Transition.toString({...c,property:At}):void 0}}function zt(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 Ft=[Ie.Down,Ie.Right,Ie.Up,Ie.Left],Ut=(e,t)=>{let{context:{active:n,collisionRect:r,droppableRects:o,droppableContainers:i,over:a,scrollableAncestors:l}}=t;if(Ft.includes(e.code)){if(e.preventDefault(),!n||!r)return;const t=[];i.getEnabled().forEach((n=>{if(!n||null!=n&&n.disabled)return;const i=o.get(n.id);if(i)switch(e.code){case Ie.Down:r.top<i.top&&t.push(n);break;case Ie.Up:r.top>i.top&&t.push(n);break;case Ie.Left:r.left>i.left&&t.push(n);break;case Ie.Right:r.left<i.left&&t.push(n)}}));const d=(e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const o=te(t),i=[];for(const e of r){const{id:t}=e,r=n.get(t);if(r){const n=te(r),a=o.reduce(((e,t,r)=>e+Z(n[r],t)),0),l=Number((a/4).toFixed(4));i.push({id:t,data:{droppableContainer:e,value:l}})}}return i.sort(Q)})({active:n,collisionRect:r,droppableRects:o,droppableContainers:t,pointerCoordinates:null});let u=ne(d,"id");if(u===(null==a?void 0:a.id)&&d.length>1&&(u=d[1].id),null!=u){const e=i.get(n.id),t=i.get(u),a=t?o.get(t.id):null,d=null==t?void 0:t.node.current;if(d&&a&&e&&t){const n=pe(d).some(((e,t)=>l[t]!==e)),o=Ht(e,t),i=(c=t,!(!zt(s=e)||!zt(c))&&!!Ht(s,c)&&s.data.current.sortable.index<c.data.current.sortable.index),u=n||!o?{x:0,y:0}:{x:i?r.width-a.width:0,y:i?r.height-a.height:0},h={x:a.left,y:a.top};return u.x&&u.y?h:B(h,u)}}}var s,c};function Ht(e,t){return!(!zt(e)||!zt(t))&&e.data.current.sortable.containerId===t.data.current.sortable.containerId}const Vt=window.wp.primitives,Xt=(0,d.jsx)(Vt.SVG,{width:"24",height:"24",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,d.jsx)(Vt.Path,{d:"M8 7h2V5H8v2zm0 6h2v-2H8v2zm0 6h2v-2H8v2zm6-14v2h2V5h-2zm0 8h2v-2h-2v2zm0 6h2v-2h-2v2z"})}),Yt=(0,d.jsx)(Vt.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,d.jsx)(Vt.Path,{d:"M11 12.5V17.5H12.5V12.5H17.5V11H12.5V6H11V11H6V12.5H11Z"})}),Kt=(0,d.jsx)(Vt.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,d.jsx)(Vt.Path,{d:"M12 13.06l3.712 3.713 1.061-1.06L13.061 12l3.712-3.712-1.06-1.06L12 10.938 8.288 7.227l-1.061 1.06L10.939 12l-3.712 3.712 1.06 1.061L12 13.061z"})}),Wt=({id:e,item:t,fields:n,updateItemContent:r,deleteItem:i})=>{const[l,s]=(0,o.useState)(!1),{attributes:c,listeners:u,setNodeRef:h,transform:p,transition:f,isDragging:g}=Pt({id:e}),v={transform:z.Transform.toString(p&&{...p,scaleY:1}),transition:f,opacity:g?.5:1};return(0,d.jsxs)("div",{ref:h,style:v,className:"repeater-component-item",children:[(0,d.jsxs)("div",{className:"repeater-component-item-buttons",children:[(0,d.jsx)(a.Button,{...c,...u,icon:Xt}),(0,d.jsx)(a.Button,{icon:l?Yt:"minus",onClick:()=>s(!l)}),(0,d.jsx)(a.Button,{isDestructive:!0,onClick:()=>i(e),icon:Kt})]}),(0,d.jsx)("div",{className:(l?"is-collapsed ":"")+"repeater-component-item-components",children:(0,d.jsx)(Gt,{attributes:c,components:n,onChange:r,item:t,id:e})})]})},_t=({componentName:e,fields:t,meta:n,props:r})=>{const{attributes:l,setAttributes:s}=r,c=(0,i.useSelect)((e=>n?e("core/editor").getEditedPostAttribute("meta"):null)),u=n?c[e]:l[e],[h,p]=(0,o.useState)([]),{editPost:g}=(0,i.useDispatch)("core/editor");(0,o.useEffect)((()=>{const e=new Set(t.map((e=>e.name))),n=u.map((t=>{const n={id:t.id};return Object.keys(t).forEach((r=>{(e.has(r)||"id"===r)&&(n[r]=t[r])})),e.forEach((e=>{e in n||(n[e]="")})),n}));p(n)}),[u,t]);const v=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return(0,f.useMemo)((()=>[...t].filter((e=>null!=e))),[...t])}(q(He),q(Oe,{coordinateGetter:Ut})),m=t=>{const r=h.filter((e=>e.id!==t));p(r),!1!==n?g({meta:{[n]:r}}):s({[e]:r})},b=(t,r,o)=>{const i=h.map((e=>e.id===t?{...e,[r]:o}:e));p(i),!1!==n?g({meta:{[n]:i}}):s({[e]:i})};return(0,d.jsxs)(a.BaseControl,{children:[(0,d.jsx)(bt,{sensors:v,collisionDetection:oe,onDragEnd:t=>{const{active:r,over:o}=t;r&&o&&((t,r)=>{const o=h.findIndex((e=>e.id===t)),i=h.findIndex((e=>e.id===r));if(o!==i){const t=Ct(h,o,i);p(t),!1!==n?g({meta:{[n]:t}}):s({[e]:t})}})(r.id,o.id)},children:(0,d.jsx)(kt,{items:h,strategy:jt,children:(0,d.jsx)("div",{className:"repeater-component",children:h.map((e=>(0,d.jsx)(Wt,{id:e.id,item:e,fields:t,updateItemContent:b,deleteItem:m},e.id)))})})}),(0,d.jsx)(a.Button,{isPrimary:!0,onClick:()=>(t=>{const r={id:`${Date.now()}`};t.forEach((e=>{r[e.name]=e.value}));const o=[...h,r];p(o),!1!==n?g({meta:{[n]:o}}):s({[e]:o})})(t),className:"repeater-component-add-item-button",children:r.buttonLabel})]})};function Gt({attributes:e,components:t,onChange:n,props:r,item:l=null,id:s=null}){const h=t.some((e=>e.meta)),f=(0,i.useSelect)((e=>h?e("core/editor").getEditedPostAttribute("meta"):null)),[g,v]=(0,o.useState)({});(0,o.useEffect)((()=>{const n={};t.forEach((t=>{n[t.name]=l?l[t.name]:e[t.name]})),v(n)}),[t,l,e]);const m=(e,t,r,o)=>{v((e=>({...e,[t]:r}))),n(e,t,r,o)};return(0,d.jsx)(d.Fragment,{children:t.map((t=>(e=>!e.condition||(Array.isArray(e.condition)?e.condition:[e.condition]).every((e=>g[e.name]===e.value)))(t)?(t=>{var o,i,h,g,v;const b=t.meta?"is-meta":"",x=t.meta?f[t.name]:l?l[t.name]:e[t.name],w=!!t.meta&&t.name;switch(t.type){case"TimePicker":return(0,d.jsx)(a.BaseControl,{className:b,label:t.label,help:t.help,children:(0,d.jsx)(a.TimePicker,{currentDate:x,onChange:e=>n(s,t.name,e,w),...t.is12hour?{is12Hour:!0}:{}},t.name)},t.name);case"Text":return(0,d.jsx)(a.TextControl,{className:b,label:t.label,help:t.help,placeholder:t.placeholder,value:x,onChange:e=>n(s,t.name,e,w)},t.name);case"Textarea":return(0,d.jsx)(a.TextareaControl,{className:b,label:t.label,help:t.help,placeholder:t.placeholder,value:x,onChange:e=>n(s,t.name,e,w)},t.name);case"Toggle":return(0,d.jsx)(a.ToggleControl,{className:b,label:t.label,help:t.help,checked:x,onChange:e=>m(s,t.name,e,w)},t.name);case"Select":return(0,d.jsx)(a.SelectControl,{className:b,label:t.label,help:t.help,value:x,onChange:e=>m(s,t.name,e,w),options:[...t.choices]},t.name);case"ColorPalette":return(0,d.jsx)(a.BaseControl,{className:b,label:t.label,help:t.help,children:(0,d.jsx)(a.ColorPalette,{value:x,onChange:e=>n(s,t.name,e,w),colors:[...t.colors],disableCustomColors:!0,clearable:!1})},t.name);case"ColorPicker":return(0,d.jsx)(a.BaseControl,{className:b,label:t.label,help:t.help,children:(0,d.jsx)(a.ColorPicker,{color:x,defaultValue:x,onChange:e=>m(s,t.name,e,w),...t.alfa?{enableAlpha:!0}:{}},t.name)},t.name);case"Image":return(0,d.jsx)(a.BaseControl,{className:b,label:t.label,help:t.help,children:(0,d.jsx)(c.MediaUploadCheck,{children:(0,d.jsx)(c.MediaUpload,{onSelect:e=>n(s,t.name,e.id,w),allowedTypes:["image"],value:x,render:({open:e})=>(0,d.jsx)(u,{open:e,remove:()=>n(s,t.name,0,w),componentName:t.name,mediaId:x})})})},t.name);case"File":return(0,d.jsx)(a.BaseControl,{className:b,label:t.label,help:t.help,children:(0,d.jsx)(c.MediaUploadCheck,{children:(0,d.jsx)(c.MediaUpload,{onSelect:e=>{var r,o,i,a;n(s,t.name,{id:null!==(r=e.id)&&void 0!==r?r:"",name:null!==(o=e.filename)&&void 0!==o?o:"",url:null!==(i=e.url)&&void 0!==i?i:"",size:null!==(a=e.filesizeHumanReadable)&&void 0!==a?a:""},w)},value:x,render:({open:e})=>(0,d.jsx)(p,{open:e,remove:()=>n(s,t.name,{},w),componentName:t.name,file:x})})})},t.name);case"Link":return(0,d.jsx)(a.BaseControl,{className:b,label:t.label,help:t.help,children:(0,d.jsx)(c.__experimentalLinkControl,{searchInputPlaceholder:null!==(o=t.placeholder)&&void 0!==o?o:"Search...",value:x,onChange:e=>n(s,t.name,e,w),hasTextControl:!0,onRemove:()=>n(s,t.name,{},w)})},t.name);case"Range":return(0,d.jsx)(a.RangeControl,{className:b,label:t.label,help:t.help,value:x,onChange:e=>n(s,t.name,e,w),min:null!==(i=t.min)&&void 0!==i?i:300,max:null!==(h=t.max)&&void 0!==h?h:1536,step:null!==(g=t.step)&&void 0!==g?g:10},t.name);case"RichText":return(0,d.jsx)(a.BaseControl,{className:b,label:t.label,help:t.help,children:(0,d.jsx)(c.RichText,{label:t.label,value:x,onChange:e=>n(s,t.name,e,w),placeholder:null!==(v=t.placeholder)&&void 0!==v?v:"..."},t.name)},t.name);case"Message":return(0,d.jsx)(a.BaseControl,{className:b,label:t.label,help:t.help},t.name);case"Repeater":return(0,d.jsx)(a.BaseControl,{className:b,label:t.label,help:t.help,children:(0,d.jsx)(_t,{componentName:t.name,fields:t.fields,meta:w,props:{...r,buttonLabel:t.button_label||"Add"}},t.name)},t.name);default:return null}})(t):null))})}function Jt({name:e,props:t}){const{attributes:n,setAttributes:r}=t,[l,u]=(0,o.useState)([]),{editPost:h}=(0,i.useDispatch)("core/editor"),p=(e=null,t,n,o=!1)=>{r({[t]:n}),!1!==o&&h({meta:{[o]:n}})};return(0,o.useEffect)((()=>{s()({path:`/${e}/v1/data`}).then((e=>{u(e),e.options.map((e=>{[e.name]in e&&p([e.name],e.value)}))})).catch((e=>console.error(e?.message)))}),[]),(0,d.jsxs)(c.InspectorControls,{children:[!l&&(0,d.jsx)(a.Spinner,{}),l&&l.options&&l.options.length>0&&l.options.map(((e,r)=>{var o,i;return(0,d.jsx)(a.PanelBody,{title:null!==(o=e.label)&&void 0!==o?o:e.name,initialOpen:null!==(i=e.open)&&void 0!==i&&i,children:(0,d.jsx)("div",{className:"gutengood gutengood-options",children:(0,d.jsx)(Gt,{attributes:n,components:e.fields,onChange:p,props:t})})},r)}))]})}const qt=window.wp.serverSideRender;var $t=e.n(qt);const Zt=(0,d.jsx)(Vt.SVG,{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,d.jsx)(Vt.Path,{d:"M3.99961 13C4.67043 13.3354 4.6703 13.3357 4.67017 13.3359L4.67298 13.3305C4.67621 13.3242 4.68184 13.3135 4.68988 13.2985C4.70595 13.2686 4.7316 13.2218 4.76695 13.1608C4.8377 13.0385 4.94692 12.8592 5.09541 12.6419C5.39312 12.2062 5.84436 11.624 6.45435 11.0431C7.67308 9.88241 9.49719 8.75 11.9996 8.75C14.502 8.75 16.3261 9.88241 17.5449 11.0431C18.1549 11.624 18.6061 12.2062 18.9038 12.6419C19.0523 12.8592 19.1615 13.0385 19.2323 13.1608C19.2676 13.2218 19.2933 13.2686 19.3093 13.2985C19.3174 13.3135 19.323 13.3242 19.3262 13.3305L19.3291 13.3359C19.3289 13.3357 19.3288 13.3354 19.9996 13C20.6704 12.6646 20.6703 12.6643 20.6701 12.664L20.6697 12.6632L20.6688 12.6614L20.6662 12.6563L20.6583 12.6408C20.6517 12.6282 20.6427 12.6108 20.631 12.5892C20.6078 12.5459 20.5744 12.4852 20.5306 12.4096C20.4432 12.2584 20.3141 12.0471 20.1423 11.7956C19.7994 11.2938 19.2819 10.626 18.5794 9.9569C17.1731 8.61759 14.9972 7.25 11.9996 7.25C9.00203 7.25 6.82614 8.61759 5.41987 9.9569C4.71736 10.626 4.19984 11.2938 3.85694 11.7956C3.68511 12.0471 3.55605 12.2584 3.4686 12.4096C3.42484 12.4852 3.39142 12.5459 3.36818 12.5892C3.35656 12.6108 3.34748 12.6282 3.34092 12.6408L3.33297 12.6563L3.33041 12.6614L3.32948 12.6632L3.32911 12.664C3.32894 12.6643 3.32879 12.6646 3.99961 13ZM11.9996 16C13.9326 16 15.4996 14.433 15.4996 12.5C15.4996 10.567 13.9326 9 11.9996 9C10.0666 9 8.49961 10.567 8.49961 12.5C8.49961 14.433 10.0666 16 11.9996 16Z"})});function Qt({name:e,props:t}){const{attributes:n,setAttributes:r}=t,[l,u]=(0,o.useState)([]),[h,p]=(0,o.useState)(!1),{editPost:f}=(0,i.useDispatch)("core/editor"),g=(e=null,t,n,o=!1)=>{r({[t]:n}),!1!==o&&f({meta:{[o]:n}})};return(0,o.useEffect)((()=>{s()({path:`/${e}/v1/data`}).then((e=>{u(e),p(e.edit_mode),e.fields.map((e=>{[e.name]in e&&g([e.name],e.value)}))})).catch((e=>console.error(e?.message)))}),[]),(0,d.jsxs)(d.Fragment,{children:[!l&&(0,d.jsx)(a.Spinner,{}),l&&l.fields&&l.fields.length>0&&(0,d.jsx)(c.BlockControls,{children:(0,d.jsx)(a.ToolbarGroup,{children:(0,d.jsx)(a.ToolbarButton,{icon:h?Zt:"edit",onClick:()=>{p(!h)}})})}),l&&l.fields&&h&&(0,d.jsx)("div",{className:"gutengood gutengood-fields",children:(0,d.jsx)(Gt,{attributes:n,components:l.fields,onChange:g,props:t})}),!h&&(0,d.jsx)($t(),{httpMethod:"POST",block:e,props:t,attributes:t.attributes})]})}function en({name:e}){const[t,n]=(0,o.useState)([]),{editPost:r}=(0,i.useDispatch)("core/editor"),l=(e=null,t,n,o=!0)=>{r({meta:{[o]:n}})};return(0,o.useEffect)((()=>{s()({path:`/${e}/v1/data`}).then((e=>{n(e),e.options.map((e=>{[e.name]in e&&l([e.name],e.value)}))})).catch((e=>console.error(e?.message)))}),[]),(0,d.jsxs)(d.Fragment,{children:[!t&&(0,d.jsx)(a.Spinner,{}),t&&t.options&&t.options.length>0&&t.options.map(((e,t)=>(0,d.jsx)("div",{className:"gutengood gutengood-panel gutengood-options",children:(0,d.jsx)(Gt,{attributes:e.fields,components:e.fields,onChange:l})},t)))]})}if(void 0!==window.gutengoodBlocks&&window.gutengoodBlocks.forEach((e=>{const n=e.name;(0,t.registerBlockType)(n,{title:e.title,icon:tn(e.icon),description:e.description,category:e.category,edit:e=>(0,d.jsxs)(o.Fragment,{children:[(0,d.jsx)(Jt,{name:n,props:e}),(0,d.jsx)(Qt,{name:n,props:e})]}),save:()=>null})})),void 0!==window.gutengoodPanels){const e=e=>{const t=(0,i.useSelect)((e=>e("core/editor").getCurrentPostType()));return e.post_types.includes(t)?(0,d.jsx)(r.PluginDocumentSettingPanel,{name:e.name,title:e.title,icon:tn(e.icon),children:(0,d.jsx)(en,{name:e.name})}):null};window.gutengoodPanels.forEach((t=>{(0,n.registerPlugin)(t.name,{render:()=>e(t),icon:tn(t.icon)})}))}function tn(e){if(!e||"string"!=typeof e||!e.includes('"svg"'))return e;const t=JSON.parse(e),{svg:n}=t,r=n.paths?n.paths.map(((e,t)=>(0,d.jsx)("path",{fill:e["@attributes"].fill,d:e["@attributes"].d},t))):(0,d.jsx)("path",{fill:n.path["@attributes"].fill,d:n.path["@attributes"].d});return(0,d.jsx)("svg",{width:n["@attributes"].width,height:n["@attributes"].height,viewBox:n["@attributes"].viewBox,children:r})}})();
1
+ (()=>{"use strict";var e={n:t=>{var n=t&&t.__esModule?()=>t.default:()=>t;return e.d(n,{a:n}),n},d:(t,n)=>{for(var r in n)e.o(n,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:n[r]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)};const t=window.wp.blocks,n=window.wp.plugins,r=window.wp.editor,o=window.wp.element,i=window.wp.data,a=window.wp.components,l=window.wp.apiFetch;var s=e.n(l);const c=window.wp.blockEditor,d=window.ReactJSXRuntime,u=({open:e,remove:t,mediaId:n})=>{const r=(0,i.useSelect)((e=>e("core").getMedia(n)),[n]),o=r?.media_details?.sizes?.thumbnail?.source_url||r?.source_url||null;return(0,d.jsx)("div",{className:"image-component",children:o?(0,d.jsx)("div",{children:(0,d.jsxs)("div",{children:[(0,d.jsx)("img",{className:"image-component-image",src:o,alt:""}),(0,d.jsxs)("div",{className:"image-component-buttons",children:[(0,d.jsx)(a.Button,{onClick:e,icon:"edit"}),(0,d.jsx)(a.Button,{icon:"trash",onClick:t})]})]})}):(0,d.jsx)(a.Button,{className:"is-primary",onClick:e,children:"Choose Image"})})},h=()=>(0,d.jsx)(a.Icon,{icon:()=>(0,d.jsx)("svg",{className:"file-component-icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 448 512",children:(0,d.jsx)("path",{d:"M380.7 67.3c-29.1-29.1-76.3-29.1-105.4 0l-192 192c-46.8 46.8-46.8 122.6 0 169.4s122.6 46.8 169.4 0l152-152c6.2-6.2 16.4-6.2 22.6 0s6.2 16.4 0 22.6l-152 152c-59.3 59.3-155.4 59.3-214.6 0S1.4 296 60.7 236.7l192-192c41.6-41.6 109-41.6 150.6 0s41.6 109 0 150.6L219.5 379.1c-28.2 28.2-74.6 25.6-99.6-5.5c-21.3-26.6-19.2-65 4.9-89.1L276.7 132.7c6.2-6.2 16.4-6.2 22.6 0s6.2 16.4 0 22.6L147.5 307.1c-12.6 12.6-13.7 32.6-2.6 46.5c13 16.2 37.2 17.6 51.9 2.9L380.7 172.7c29.1-29.1 29.1-76.3 0-105.4z"})})}),p=({open:e,remove:t,file:n})=>(0,d.jsxs)("div",{className:"file-component",children:[(0,d.jsx)(h,{}),n&&n.id?(0,d.jsxs)("div",{className:"file-component-info",children:[(0,d.jsxs)("div",{children:[(0,d.jsx)("span",{className:"file-component-info-name",children:n.name}),(0,d.jsx)("span",{className:"file-component-info-size",children:n.size})]}),(0,d.jsx)(a.Button,{className:"delete-file-button",icon:"trash",onClick:t})]}):(0,d.jsx)(a.Button,{onClick:e,children:"Select File"})]}),f=window.React;var v=e.n(f);const g=window.ReactDOM,m="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement;function b(e){const t=Object.prototype.toString.call(e);return"[object Window]"===t||"[object global]"===t}function x(e){return"nodeType"in e}function w(e){var t,n;return e?b(e)?e:x(e)&&null!=(t=null==(n=e.ownerDocument)?void 0:n.defaultView)?t:window:window}function y(e){const{Document:t}=w(e);return e instanceof t}function C(e){return!b(e)&&e instanceof w(e).HTMLElement}function D(e){return e instanceof w(e).SVGElement}function R(e){return e?b(e)?e.document:x(e)?y(e)?e:C(e)||D(e)?e.ownerDocument:document:document:document}const E=m?f.useLayoutEffect:f.useEffect;function S(e){const t=(0,f.useRef)(e);return E((()=>{t.current=e})),(0,f.useCallback)((function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return null==t.current?void 0:t.current(...n)}),[])}function j(e,t){void 0===t&&(t=[e]);const n=(0,f.useRef)(e);return E((()=>{n.current!==e&&(n.current=e)}),t),n}function N(e,t){const n=(0,f.useRef)();return(0,f.useMemo)((()=>{const t=e(n.current);return n.current=t,t}),[...t])}function M(e){const t=S(e),n=(0,f.useRef)(null),r=(0,f.useCallback)((e=>{e!==n.current&&(null==t||t(e,n.current)),n.current=e}),[]);return[n,r]}function k(e){const t=(0,f.useRef)();return(0,f.useEffect)((()=>{t.current=e}),[e]),t.current}let I={};function T(e,t){return(0,f.useMemo)((()=>{if(t)return t;const n=null==I[e]?0:I[e]+1;return I[e]=n,e+"-"+n}),[e,t])}function L(e){return function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return r.reduce(((t,n)=>{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 A=L(1),B=L(-1);function O(e){if(!e)return!1;const{KeyboardEvent:t}=w(e.target);return t&&e instanceof t}function P(e){if(function(e){if(!e)return!1;const{TouchEvent:t}=w(e.target);return t&&e instanceof t}(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 function(e){return"clientX"in e&&"clientY"in e}(e)?{x:e.clientX,y:e.clientY}:null}const z=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[z.Translate.toString(e),z.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+" "+n+"ms "+r}}}),F="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function U(e){return e.matches(F)?e:e.querySelector(F)}const H={display:"none"};function V(e){let{id:t,value:n}=e;return v().createElement("div",{id:t,style:H},n)}function X(e){let{id:t,announcement:n,ariaLiveType:r="assertive"}=e;return v().createElement("div",{id:t,style:{position:"fixed",top:0,left:0,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 Y=(0,f.createContext)(null),K={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 "},W={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 _(e){let{announcements:t=W,container:n,hiddenTextDescribedById:r,screenReaderInstructions:o=K}=e;const{announce:i,announcement:a}=function(){const[e,t]=(0,f.useState)("");return{announce:(0,f.useCallback)((e=>{null!=e&&t(e)}),[]),announcement:e}}(),l=T("DndLiveRegion"),[s,c]=(0,f.useState)(!1);if((0,f.useEffect)((()=>{c(!0)}),[]),function(e){const t=(0,f.useContext)(Y);(0,f.useEffect)((()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)}),[e,t])}((0,f.useMemo)((()=>({onDragStart(e){let{active:n}=e;i(t.onDragStart({active:n}))},onDragMove(e){let{active:n,over:r}=e;t.onDragMove&&i(t.onDragMove({active:n,over:r}))},onDragOver(e){let{active:n,over:r}=e;i(t.onDragOver({active:n,over:r}))},onDragEnd(e){let{active:n,over:r}=e;i(t.onDragEnd({active:n,over:r}))},onDragCancel(e){let{active:n,over:r}=e;i(t.onDragCancel({active:n,over:r}))}})),[i,t])),!s)return null;const d=v().createElement(v().Fragment,null,v().createElement(V,{id:r,value:o.draggable}),v().createElement(X,{id:l,announcement:a}));return n?(0,g.createPortal)(d,n):d}var G;function J(){}function q(e,t){return(0,f.useMemo)((()=>({sensor:e,options:null!=t?t:{}})),[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"}(G||(G={}));const $=Object.freeze({x:0,y:0});function Z(e,t){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}function Q(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return n-r}function ee(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return r-n}function te(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 ne(e,t){if(!e||0===e.length)return null;const[n]=e;return t?n[t]:n}function re(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 oe=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const o=re(t,t.left,t.top),i=[];for(const e of r){const{id:t}=e,r=n.get(t);if(r){const n=Z(re(r),o);i.push({id:t,data:{droppableContainer:e,value:n}})}}return i.sort(Q)};function ie(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<o&&n<i){const n=t.width*t.height,r=e.width*e.height,o=a*l;return Number((o/(n+r-o)).toFixed(4))}return 0}const ae=e=>{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=ie(i,t);n>0&&o.push({id:r,data:{droppableContainer:e,value:n}})}}return o.sort(ee)};function le(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:$}function se(e){return function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return r.reduce(((t,n)=>({...t,top:t.top+e*n.y,bottom:t.bottom+e*n.y,left:t.left+e*n.x,right:t.right+e*n.x})),{...t})}}const ce=se(1);const de={ignoreTransform:!1};function ue(e,t){void 0===t&&(t=de);let n=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:t,transformOrigin:r}=w(e).getComputedStyle(e);t&&(n=function(e,t,n){const r=function(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}(t);if(!r)return e;const{scaleX:o,scaleY:i,x:a,y:l}=r,s=e.left-a-(1-o)*parseFloat(n),c=e.top-l-(1-i)*parseFloat(n.slice(n.indexOf(" ")+1)),d=o?e.width/o:e.width,u=i?e.height/i:e.height;return{width:d,height:u,top:c,right:s+d,bottom:c+u,left:s}}(n,t,r))}const{top:r,left:o,width:i,height:a,bottom:l,right:s}=n;return{top:r,left:o,width:i,height:a,bottom:l,right:s}}function he(e){return ue(e,{ignoreTransform:!0})}function pe(e,t){const n=[];return e?function r(o){if(null!=t&&n.length>=t)return n;if(!o)return n;if(y(o)&&null!=o.scrollingElement&&!n.includes(o.scrollingElement))return n.push(o.scrollingElement),n;if(!C(o)||D(o))return n;if(n.includes(o))return n;const i=w(e).getComputedStyle(o);return o!==e&&function(e,t){void 0===t&&(t=w(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=w(e).getComputedStyle(e)),"fixed"===t.position}(o,i)?n:r(o.parentNode)}(e):n}function fe(e){const[t]=pe(e,1);return null!=t?t:null}function ve(e){return m&&e?b(e)?e:x(e)?y(e)||e===R(e).scrollingElement?window:C(e)?e:null:null:null}function ge(e){return b(e)?e.scrollX:e.scrollLeft}function me(e){return b(e)?e.scrollY:e.scrollTop}function be(e){return{x:ge(e),y:me(e)}}var xe;function we(e){return!(!m||!e)&&e===document.scrollingElement}function ye(e){const t={x:0,y:0},n=we(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"}(xe||(xe={}));const Ce={x:.2,y:.2};function De(e,t,n,r,o){let{top:i,left:a,right:l,bottom:s}=n;void 0===r&&(r=10),void 0===o&&(o=Ce);const{isTop:c,isBottom:d,isLeft:u,isRight:h}=ye(e),p={x:0,y:0},f={x:0,y:0},v=t.height*o.y,g=t.width*o.x;return!c&&i<=t.top+v?(p.y=xe.Backward,f.y=r*Math.abs((t.top+v-i)/v)):!d&&s>=t.bottom-v&&(p.y=xe.Forward,f.y=r*Math.abs((t.bottom-v-s)/v)),!h&&l>=t.right-g?(p.x=xe.Forward,f.x=r*Math.abs((t.right-g-l)/g)):!u&&a<=t.left+g&&(p.x=xe.Backward,f.x=r*Math.abs((t.left+g-a)/g)),{direction:p,speed:f}}function Re(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 Ee(e){return e.reduce(((e,t)=>A(e,be(t))),$)}const Se=[["x",["left","right"],function(e){return e.reduce(((e,t)=>e+ge(t)),0)}],["y",["top","bottom"],function(e){return e.reduce(((e,t)=>e+me(t)),0)}]];class je{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=pe(t),r=Ee(n);this.rect={...e},this.width=e.width,this.height=e.height;for(const[e,t,o]of Se)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 Me(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 ke,Ie;function Te(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"}(ke||(ke={})),function(e){e.Space="Space",e.Down="ArrowDown",e.Right="ArrowRight",e.Left="ArrowLeft",e.Up="ArrowUp",e.Esc="Escape",e.Enter="Enter",e.Tab="Tab"}(Ie||(Ie={}));const Ae={start:[Ie.Space,Ie.Enter],cancel:[Ie.Esc],end:[Ie.Space,Ie.Enter,Ie.Tab]},Be=(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 Oe{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(R(t)),this.windowListeners=new Ne(w(t)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(ke.Resize,this.handleCancel),this.windowListeners.add(ke.VisibilityChange,this.handleCancel),setTimeout((()=>this.listeners.add(ke.Keydown,this.handleKeyDown)))}handleStart(){const{activeNode:e,onStart:t}=this.props,n=e.node.current;n&&function(e,t){if(void 0===t&&(t=ue),!e)return;const{top:n,left:r,bottom:o,right:i}=t(e);fe(e)&&(o<=0||i<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}(n),t($)}handleKeyDown(e){if(O(e)){const{active:t,context:n,options:r}=this.props,{keyboardCodes:o=Ae,coordinateGetter:i=Be,scrollBehavior:a="smooth"}=r,{code:l}=e;if(o.end.includes(l))return void this.handleEnd(e);if(o.cancel.includes(l))return void this.handleCancel(e);const{collisionRect:s}=n.current,c=s?{x:s.left,y:s.top}:$;this.referenceCoordinates||(this.referenceCoordinates=c);const d=i(e,{active:t,context:n.current,currentCoordinates:c});if(d){const t=B(d,c),r={x:0,y:0},{scrollableAncestors:o}=n.current;for(const n of o){const o=e.code,{isTop:i,isRight:l,isLeft:s,isBottom:c,maxScroll:u,minScroll:h}=ye(n),p=Re(n),f={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&&!l||o===Ie.Left&&!s,g=o===Ie.Down&&!c||o===Ie.Up&&!i;if(v&&f.x!==d.x){const e=n.scrollLeft+t.x,i=o===Ie.Right&&e<=u.x||o===Ie.Left&&e>=h.x;if(i&&!t.y)return void n.scrollTo({left:e,behavior:a});r.x=i?n.scrollLeft-e:o===Ie.Right?n.scrollLeft-u.x:n.scrollLeft-h.x,r.x&&n.scrollBy({left:-r.x,behavior:a});break}if(g&&f.y!==d.y){const e=n.scrollTop+t.y,i=o===Ie.Down&&e<=u.y||o===Ie.Up&&e>=h.y;if(i&&!t.x)return void n.scrollTo({top:e,behavior:a});r.y=i?n.scrollTop-e:o===Ie.Down?n.scrollTop-u.y:n.scrollTop-h.y,r.y&&n.scrollBy({top:-r.y,behavior:a});break}}this.handleMove(e,A(B(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 Pe(e){return Boolean(e&&"distance"in e)}function ze(e){return Boolean(e&&"delay"in e)}Oe.activators=[{eventName:"onKeyDown",handler:(e,t,n)=>{let{keyboardCodes:r=Ae,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 Fe{constructor(e,t,n){var r;void 0===n&&(n=function(e){const{EventTarget:t}=w(e);return e instanceof t?e:R(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=R(i),this.documentListeners=new Ne(this.document),this.listeners=new Ne(n),this.windowListeners=new Ne(w(i)),this.initialCoordinates=null!=(r=P(o))?r:$,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),e.cancel&&this.listeners.add(e.cancel.name,this.handleCancel),this.windowListeners.add(ke.Resize,this.handleCancel),this.windowListeners.add(ke.DragStart,Te),this.windowListeners.add(ke.VisibilityChange,this.handleCancel),this.windowListeners.add(ke.ContextMenu,Te),this.documentListeners.add(ke.Keydown,this.handleKeydown),t){if(null!=n&&n({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(ze(t))return this.timeoutId=setTimeout(this.handleStart,t.delay),void this.handlePending(t);if(Pe(t))return void this.handlePending(t)}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),null!==this.timeoutId&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(e,t){const{active:n,onPending:r}=this.props;r(n,e,this.initialCoordinates,t)}handleStart(){const{initialCoordinates:e}=this,{onStart:t}=this.props;e&&(this.activated=!0,this.documentListeners.add(ke.Click,Le,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(ke.SelectionChange,this.removeTextSelection),t(e))}handleMove(e){var t;const{activated:n,initialCoordinates:r,props:o}=this,{onMove:i,options:{activationConstraint:a}}=o;if(!r)return;const l=null!=(t=P(e))?t:$,s=B(r,l);if(!n&&a){if(Pe(a)){if(null!=a.tolerance&&Me(s,a.tolerance))return this.handleCancel();if(Me(s,a.distance))return this.handleStart()}return ze(a)&&Me(s,a.tolerance)?this.handleCancel():void this.handlePending(a,s)}e.cancelable&&e.preventDefault(),i(l)}handleEnd(){const{onAbort:e,onEnd:t}=this.props;this.detach(),this.activated||e(this.props.active),t()}handleCancel(){const{onAbort:e,onCancel:t}=this.props;this.detach(),this.activated||e(this.props.active),t()}handleKeydown(e){e.code===Ie.Esc&&this.handleCancel()}removeTextSelection(){var e;null==(e=this.document.getSelection())||e.removeAllRanges()}}const Ue={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class He extends Fe{constructor(e){const{event:t}=e,n=R(t.target);super(e,Ue,n)}}He.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 Ve={move:{name:"mousemove"},end:{name:"mouseup"}};var Xe;!function(e){e[e.RightClick=2]="RightClick"}(Xe||(Xe={})),class extends Fe{constructor(e){super(e,Ve,R(e.event.target))}}.activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button!==Xe.RightClick&&(null==r||r({event:n}),!0)}}];const Ye={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};var Ke,We;(class extends Fe{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(){}}}).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"}(Ke||(Ke={})),function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"}(We||(We={}));const _e={x:{[xe.Backward]:!1,[xe.Forward]:!1},y:{[xe.Backward]:!1,[xe.Forward]:!1}};var Ge,Je;!function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"}(Ge||(Ge={})),function(e){e.Optimized="optimized"}(Je||(Je={}));const qe=new Map;function $e(e,t){return N((n=>e?n||("function"==typeof t?t(e):e):null),[t,e])}function Ze(e){let{callback:t,disabled:n}=e;const r=S(t),o=(0,f.useMemo)((()=>{if(n||"undefined"==typeof window||void 0===window.ResizeObserver)return;const{ResizeObserver:e}=window;return new e(r)}),[n]);return(0,f.useEffect)((()=>()=>null==o?void 0:o.disconnect()),[o]),o}function Qe(e){return new je(ue(e),e)}function et(e,t,n){void 0===t&&(t=Qe);const[r,o]=(0,f.useState)(null);function i(){o((r=>{if(!e)return null;var o;if(!1===e.isConnected)return null!=(o=null!=r?r:n)?o:null;const i=t(e);return JSON.stringify(r)===JSON.stringify(i)?r:i}))}const a=function(e){let{callback:t,disabled:n}=e;const r=S(t),o=(0,f.useMemo)((()=>{if(n||"undefined"==typeof window||void 0===window.MutationObserver)return;const{MutationObserver:e}=window;return new e(r)}),[r,n]);return(0,f.useEffect)((()=>()=>null==o?void 0:o.disconnect()),[o]),o}({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}}}}),l=Ze({callback:i});return E((()=>{i(),e?(null==l||l.observe(e),null==a||a.observe(document.body,{childList:!0,subtree:!0})):(null==l||l.disconnect(),null==a||a.disconnect())}),[e]),r}const tt=[];function nt(e,t){void 0===t&&(t=[]);const n=(0,f.useRef)(null);return(0,f.useEffect)((()=>{n.current=null}),t),(0,f.useEffect)((()=>{const t=e!==$;t&&!n.current&&(n.current=e),!t&&n.current&&(n.current=null)}),[e]),n.current?B(e,n.current):$}function rt(e){return(0,f.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 ot=[];const it=[{sensor:He,options:{}},{sensor:Oe,options:{}}],at={current:{}},lt={draggable:{measure:he},droppable:{measure:he,strategy:Ge.WhileDragging,frequency:Je.Optimized},dragOverlay:{measure:ue}};class st 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 ct={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new st,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:J},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:lt,measureDroppableContainers:J,windowRect:null,measuringScheduled:!1},dt={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:J,draggableNodes:new Map,over:null,measureDroppableContainers:J},ut=(0,f.createContext)(dt),ht=(0,f.createContext)(ct);function pt(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new st}}}function ft(e,t){switch(t.type){case G.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case G.DragMove:return null==e.draggable.active?e:{...e,draggable:{...e.draggable,translate:{x:t.coordinates.x-e.draggable.initialCoordinates.x,y:t.coordinates.y-e.draggable.initialCoordinates.y}}};case G.DragEnd:case G.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case G.RegisterDroppable:{const{element:n}=t,{id:r}=n,o=new st(e.droppable.containers);return o.set(r,n),{...e,droppable:{...e.droppable,containers:o}}}case G.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 st(e.droppable.containers);return a.set(n,{...i,disabled:o}),{...e,droppable:{...e.droppable,containers:a}}}case G.UnregisterDroppable:{const{id:n,key:r}=t,o=e.droppable.containers.get(n);if(!o||r!==o.key)return e;const i=new st(e.droppable.containers);return i.delete(n),{...e,droppable:{...e.droppable,containers:i}}}default:return e}}function vt(e){let{disabled:t}=e;const{active:n,activatorEvent:r,draggableNodes:o}=(0,f.useContext)(ut),i=k(r),a=k(null==n?void 0:n.id);return(0,f.useEffect)((()=>{if(!t&&!r&&i&&null!=a){if(!O(i))return;if(document.activeElement===i.target)return;const e=o.get(a);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=U(e);if(t){t.focus();break}}}))}}),[r,t,o,a,i]),null}const gt=(0,f.createContext)({...$,scaleX:1,scaleY:1});var mt;!function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"}(mt||(mt={}));const bt=(0,f.memo)((function(e){var t,n,r,o;let{id:i,accessibility:a,autoScroll:l=!0,children:s,sensors:c=it,collisionDetection:d=ae,measuring:u,modifiers:h,...p}=e;const b=(0,f.useReducer)(ft,void 0,pt),[x,y]=b,[D,R]=function(){const[e]=(0,f.useState)((()=>new Set)),t=(0,f.useCallback)((t=>(e.add(t),()=>e.delete(t))),[e]);return[(0,f.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]}(),[S,I]=(0,f.useState)(mt.Uninitialized),L=S===mt.Initialized,{draggable:{active:B,nodes:O,translate:z},droppable:{containers:F}}=x,U=null!=B?O.get(B):null,H=(0,f.useRef)({initial:null,translated:null}),V=(0,f.useMemo)((()=>{var e;return null!=B?{id:B,data:null!=(e=null==U?void 0:U.data)?e:at,rect:H}:null}),[B,U]),X=(0,f.useRef)(null),[K,W]=(0,f.useState)(null),[J,q]=(0,f.useState)(null),Z=j(p,Object.values(p)),Q=T("DndDescribedBy",i),ee=(0,f.useMemo)((()=>F.getEnabled()),[F]),te=(re=u,(0,f.useMemo)((()=>({draggable:{...lt.draggable,...null==re?void 0:re.draggable},droppable:{...lt.droppable,...null==re?void 0:re.droppable},dragOverlay:{...lt.dragOverlay,...null==re?void 0:re.dragOverlay}})),[null==re?void 0:re.draggable,null==re?void 0:re.droppable,null==re?void 0:re.dragOverlay]));var re;const{droppableRects:oe,measureDroppableContainers:ie,measuringScheduled:se}=function(e,t){let{dragging:n,dependencies:r,config:o}=t;const[i,a]=(0,f.useState)(null),{frequency:l,measure:s,strategy:c}=o,d=(0,f.useRef)(e),u=function(){switch(c){case Ge.Always:return!1;case Ge.BeforeDragging:return n;default:return!n}}(),h=j(u),p=(0,f.useCallback)((function(e){void 0===e&&(e=[]),h.current||a((t=>null===t?e:t.concat(e.filter((e=>!t.includes(e))))))}),[h]),v=(0,f.useRef)(null),g=N((t=>{if(u&&!n)return qe;if(!t||t===qe||d.current!==e||null!=i){const t=new Map;for(let n of e){if(!n)continue;if(i&&i.length>0&&!i.includes(n.id)&&n.rect.current){t.set(n.id,n.rect.current);continue}const e=n.node.current,r=e?new je(s(e),e):null;n.rect.current=r,r&&t.set(n.id,r)}return t}return t}),[e,i,n,u,s]);return(0,f.useEffect)((()=>{d.current=e}),[e]),(0,f.useEffect)((()=>{u||p()}),[n,u]),(0,f.useEffect)((()=>{i&&i.length>0&&a(null)}),[JSON.stringify(i)]),(0,f.useEffect)((()=>{u||"number"!=typeof l||null!==v.current||(v.current=setTimeout((()=>{p(),v.current=null}),l))}),[l,u,p,...r]),{droppableRects:g,measureDroppableContainers:p,measuringScheduled:null!=i}}(ee,{dragging:L,dependencies:[z.x,z.y],config:te.droppable}),de=function(e,t){const n=null!=t?e.get(t):void 0,r=n?n.node.current:null;return N((e=>{var n;return null==t?null:null!=(n=null!=r?r:e)?n:null}),[r,t])}(O,B),he=(0,f.useMemo)((()=>J?P(J):null),[J]),ge=function(){const e=!1===(null==K?void 0:K.autoScrollEnabled),t="object"==typeof l?!1===l.enabled:!1===l,n=L&&!e&&!t;return"object"==typeof l?{...l,enabled:n}:{enabled:n}}(),me=function(e,t){return $e(e,t)}(de,te.draggable.measure);!function(e){let{activeNode:t,measure:n,initialRect:r,config:o=!0}=e;const i=(0,f.useRef)(!1),{x:a,y:l}="boolean"==typeof o?{x:o,y:o}:o;E((()=>{if(!a&&!l||!t)return void(i.current=!1);if(i.current||!r)return;const e=null==t?void 0:t.node.current;if(!e||!1===e.isConnected)return;const o=le(n(e),r);if(a||(o.x=0),l||(o.y=0),i.current=!0,Math.abs(o.x)>0||Math.abs(o.y)>0){const t=fe(e);t&&t.scrollBy({top:o.y,left:o.x})}}),[t,a,l,r,n])}({activeNode:null!=B?O.get(B):null,config:ge.layoutShiftCompensation,initialRect:me,measure:te.draggable.measure});const ye=et(de,te.draggable.measure,me),Ce=et(de?de.parentElement:null),Re=(0,f.useRef)({activatorEvent:null,active:null,activeNode:de,collisionRect:null,collisions:null,droppableRects:oe,draggableNodes:O,draggingNode:null,draggingNodeRect:null,droppableContainers:F,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),Se=F.getNodeFor(null==(t=Re.current.over)?void 0:t.id),Ne=function(e){let{measure:t}=e;const[n,r]=(0,f.useState)(null),o=Ze({callback:(0,f.useCallback)((e=>{for(const{target:n}of e)if(C(n)){r((e=>{const r=t(n);return e?{...e,width:r.width,height:r.height}:r}));break}}),[t])}),i=(0,f.useCallback)((e=>{const n=function(e){if(!e)return null;if(e.children.length>1)return e;const t=e.children[0];return C(t)?t:e}(e);null==o||o.disconnect(),n&&(null==o||o.observe(n)),r(n?t(n):null)}),[t,o]),[a,l]=M(i);return(0,f.useMemo)((()=>({nodeRef:a,rect:n,setRef:l})),[n,a,l])}({measure:te.dragOverlay.measure}),Me=null!=(n=Ne.nodeRef.current)?n:de,ke=L?null!=(r=Ne.rect)?r:ye:null,Ie=Boolean(Ne.nodeRef.current&&Ne.rect),Te=le(Le=Ie?null:ye,$e(Le));var Le;const Ae=rt(Me?w(Me):null),Be=function(e){const t=(0,f.useRef)(e),n=N((n=>e?n&&n!==tt&&e&&t.current&&e.parentNode===t.current.parentNode?n:pe(e):tt),[e]);return(0,f.useEffect)((()=>{t.current=e}),[e]),n}(L?null!=Se?Se:de:null),Oe=function(e,t){void 0===t&&(t=ue);const[n]=e,r=rt(n?w(n):null),[o,i]=(0,f.useState)(ot);function a(){i((()=>e.length?e.map((e=>we(e)?r:new je(t(e),e))):ot))}const l=Ze({callback:a});return E((()=>{null==l||l.disconnect(),a(),e.forEach((e=>null==l?void 0:l.observe(e)))}),[e]),o}(Be),Pe=function(e,t){let{transform:n,...r}=t;return null!=e&&e.length?e.reduce(((e,t)=>t({transform:e,...r})),n):n}(h,{transform:{x:z.x-Te.x,y:z.y-Te.y,scaleX:1,scaleY:1},activatorEvent:J,active:V,activeNodeRect:ye,containerNodeRect:Ce,draggingNodeRect:ke,over:Re.current.over,overlayNodeRect:Ne.rect,scrollableAncestors:Be,scrollableAncestorRects:Oe,windowRect:Ae}),ze=he?A(he,z):null,Fe=function(e){const[t,n]=(0,f.useState)(null),r=(0,f.useRef)(e),o=(0,f.useCallback)((e=>{const t=ve(e.target);t&&n((e=>e?(e.set(t,be(t)),new Map(e)):null))}),[]);return(0,f.useEffect)((()=>{const t=r.current;if(e!==t){i(t);const a=e.map((e=>{const t=ve(e);return t?(t.addEventListener("scroll",o,{passive:!0}),[t,be(t)]):null})).filter((e=>null!=e));n(a.length?new Map(a):null),r.current=e}return()=>{i(e),i(t)};function i(e){e.forEach((e=>{const t=ve(e);null==t||t.removeEventListener("scroll",o)}))}}),[o,e]),(0,f.useMemo)((()=>e.length?t?Array.from(t.values()).reduce(((e,t)=>A(e,t)),$):Ee(e):$),[e,t])}(Be),Ue=nt(Fe),He=nt(Fe,[ye]),Ve=A(Pe,Ue),Xe=ke?ce(ke,Pe):null,Ye=V&&Xe?d({active:V,collisionRect:Xe,droppableRects:oe,droppableContainers:ee,pointerCoordinates:ze}):null,Je=ne(Ye,"id"),[Qe,st]=(0,f.useState)(null),ct=function(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}(Ie?Pe:A(Pe,He),null!=(o=null==Qe?void 0:Qe.rect)?o:null,ye),dt=(0,f.useRef)(null),bt=(0,f.useCallback)(((e,t)=>{let{sensor:n,options:r}=t;if(null==X.current)return;const o=O.get(X.current);if(!o)return;const i=e.nativeEvent,a=new n({active:X.current,activeNode:o,event:i,options:r,context:Re,onAbort(e){if(!O.get(e))return;const{onDragAbort:t}=Z.current,n={id:e};null==t||t(n),D({type:"onDragAbort",event:n})},onPending(e,t,n,r){if(!O.get(e))return;const{onDragPending:o}=Z.current,i={id:e,constraint:t,initialCoordinates:n,offset:r};null==o||o(i),D({type:"onDragPending",event:i})},onStart(e){const t=X.current;if(null==t)return;const n=O.get(t);if(!n)return;const{onDragStart:r}=Z.current,o={activatorEvent:i,active:{id:t,data:n.data,rect:H}};(0,g.unstable_batchedUpdates)((()=>{null==r||r(o),I(mt.Initializing),y({type:G.DragStart,initialCoordinates:e,active:t}),D({type:"onDragStart",event:o}),W(dt.current),q(i)}))},onMove(e){y({type:G.DragMove,coordinates:e})},onEnd:l(G.DragEnd),onCancel:l(G.DragCancel)});function l(e){return async function(){const{active:t,collisions:n,over:r,scrollAdjustedTranslate:o}=Re.current;let a=null;if(t&&o){const{cancelDrop:l}=Z.current;a={activatorEvent:i,active:t,collisions:n,delta:o,over:r},e===G.DragEnd&&"function"==typeof l&&await Promise.resolve(l(a))&&(e=G.DragCancel)}X.current=null,(0,g.unstable_batchedUpdates)((()=>{y({type:e}),I(mt.Uninitialized),st(null),W(null),q(null),dt.current=null;const t=e===G.DragEnd?"onDragEnd":"onDragCancel";if(a){const e=Z.current[t];null==e||e(a),D({type:t,event:a})}}))}}dt.current=a}),[O]),xt=(0,f.useCallback)(((e,t)=>(n,r)=>{const o=n.nativeEvent,i=O.get(r);if(null!==X.current||!i||o.dndKit||o.defaultPrevented)return;const a={active:i};!0===e(n,t.options,a)&&(o.dndKit={capturedBy:t.sensor},X.current=r,bt(n,t))}),[O,bt]),wt=function(e,t){return(0,f.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])}(c,xt);!function(e){(0,f.useEffect)((()=>{if(!m)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})))}(c),E((()=>{ye&&S===mt.Initializing&&I(mt.Initialized)}),[ye,S]),(0,f.useEffect)((()=>{const{onDragMove:e}=Z.current,{active:t,activatorEvent:n,collisions:r,over:o}=Re.current;if(!t||!n)return;const i={active:t,activatorEvent:n,collisions:r,delta:{x:Ve.x,y:Ve.y},over:o};(0,g.unstable_batchedUpdates)((()=>{null==e||e(i),D({type:"onDragMove",event:i})}))}),[Ve.x,Ve.y]),(0,f.useEffect)((()=>{const{active:e,activatorEvent:t,collisions:n,droppableContainers:r,scrollAdjustedTranslate:o}=Re.current;if(!e||null==X.current||!t||!o)return;const{onDragOver:i}=Z.current,a=r.get(Je),l=a&&a.rect.current?{id:a.id,rect:a.rect.current,data:a.data,disabled:a.disabled}:null,s={active:e,activatorEvent:t,collisions:n,delta:{x:o.x,y:o.y},over:l};(0,g.unstable_batchedUpdates)((()=>{st(l),null==i||i(s),D({type:"onDragOver",event:s})}))}),[Je]),E((()=>{Re.current={activatorEvent:J,active:V,activeNode:de,collisionRect:Xe,collisions:Ye,droppableRects:oe,draggableNodes:O,draggingNode:Me,draggingNodeRect:ke,droppableContainers:F,over:Qe,scrollableAncestors:Be,scrollAdjustedTranslate:Ve},H.current={initial:ke,translated:Xe}}),[V,de,Ye,Xe,O,Me,ke,oe,F,Qe,Be,Ve]),function(e){let{acceleration:t,activator:n=Ke.Pointer,canScroll:r,draggingRect:o,enabled:i,interval:a=5,order:l=We.TreeOrder,pointerCoordinates:s,scrollableAncestors:c,scrollableAncestorRects:d,delta:u,threshold:h}=e;const p=function(e){let{delta:t,disabled:n}=e;const r=k(t);return N((e=>{if(n||!r||!e)return _e;const o=Math.sign(t.x-r.x),i=Math.sign(t.y-r.y);return{x:{[xe.Backward]:e.x[xe.Backward]||-1===o,[xe.Forward]:e.x[xe.Forward]||1===o},y:{[xe.Backward]:e.y[xe.Backward]||-1===i,[xe.Forward]:e.y[xe.Forward]||1===i}}}),[n,t,r])}({delta:u,disabled:!i}),[v,g]=function(){const e=(0,f.useRef)(null);return[(0,f.useCallback)(((t,n)=>{e.current=setInterval(t,n)}),[]),(0,f.useCallback)((()=>{null!==e.current&&(clearInterval(e.current),e.current=null)}),[])]}(),m=(0,f.useRef)({x:0,y:0}),b=(0,f.useRef)({x:0,y:0}),x=(0,f.useMemo)((()=>{switch(n){case Ke.Pointer:return s?{top:s.y,bottom:s.y,left:s.x,right:s.x}:null;case Ke.DraggableRect:return o}}),[n,o,s]),w=(0,f.useRef)(null),y=(0,f.useCallback)((()=>{const e=w.current;if(!e)return;const t=m.current.x*b.current.x,n=m.current.y*b.current.y;e.scrollBy(t,n)}),[]),C=(0,f.useMemo)((()=>l===We.TreeOrder?[...c].reverse():c),[l,c]);(0,f.useEffect)((()=>{if(i&&c.length&&x){for(const e of C){if(!1===(null==r?void 0:r(e)))continue;const n=c.indexOf(e),o=d[n];if(!o)continue;const{direction:i,speed:l}=De(e,o,x,t,h);for(const e of["x","y"])p[e][i[e]]||(l[e]=0,i[e]=0);if(l.x>0||l.y>0)return g(),w.current=e,v(y,a),m.current=l,void(b.current=i)}m.current={x:0,y:0},b.current={x:0,y:0},g()}else g()}),[t,y,r,g,i,a,JSON.stringify(x),JSON.stringify(p),v,c,C,d,JSON.stringify(h)])}({...ge,delta:z,draggingRect:Xe,pointerCoordinates:ze,scrollableAncestors:Be,scrollableAncestorRects:Oe});const yt=(0,f.useMemo)((()=>({active:V,activeNode:de,activeNodeRect:ye,activatorEvent:J,collisions:Ye,containerNodeRect:Ce,dragOverlay:Ne,draggableNodes:O,droppableContainers:F,droppableRects:oe,over:Qe,measureDroppableContainers:ie,scrollableAncestors:Be,scrollableAncestorRects:Oe,measuringConfiguration:te,measuringScheduled:se,windowRect:Ae})),[V,de,ye,J,Ye,Ce,Ne,O,F,oe,Qe,ie,Be,Oe,te,se,Ae]),Ct=(0,f.useMemo)((()=>({activatorEvent:J,activators:wt,active:V,activeNodeRect:ye,ariaDescribedById:{draggable:Q},dispatch:y,draggableNodes:O,over:Qe,measureDroppableContainers:ie})),[J,wt,V,ye,y,Q,O,Qe,ie]);return v().createElement(Y.Provider,{value:R},v().createElement(ut.Provider,{value:Ct},v().createElement(ht.Provider,{value:yt},v().createElement(gt.Provider,{value:ct},s)),v().createElement(vt,{disabled:!1===(null==a?void 0:a.restoreFocus)})),v().createElement(_,{...a,hiddenTextDescribedById:Q}))})),xt=(0,f.createContext)(null),wt="button";const yt={timeout:25};function Ct(e,t,n){const r=e.slice();return r.splice(n<0?r.length+n:n,0,r.splice(t,1)[0]),r}function Dt(e,t){return e.reduce(((e,n,r)=>{const o=t.get(n);return o&&(e[r]=o),e}),Array(e.length))}function Rt(e){return null!==e&&e>=0}const Et=e=>{let{rects:t,activeIndex:n,overIndex:r,index:o}=e;const i=Ct(t,r,n),a=t[o],l=i[o];return l&&a?{x:l.left-a.left,y:l.top-a.top,scaleX:l.width/a.width,scaleY:l.height/a.height}:null},St={scaleX:1,scaleY:1},jt=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:n<a?e.top+e.height-(l.top+l.height):e.top-l.top,...St}:null}const s=function(e,t,n){const r=e[t],o=e[t-1],i=e[t+1];return r?n<t?o?r.top-(o.top+o.height):i?i.top-(r.top+r.height):0:i?i.top-(r.top+r.height):o?r.top-(o.top+o.height):0:0}(i,o,n);return o>n&&o<=a?{x:0,y:-l.height-s,...St}:o<n&&o>=a?{x:0,y:l.height+s,...St}:{x:0,y:0,...St}},Nt="Sortable",Mt=v().createContext({activeIndex:-1,containerId:Nt,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:Et,disabled:{draggable:!1,droppable:!1}});function kt(e){let{children:t,id:n,items:r,strategy:o=Et,disabled:i=!1}=e;const{active:a,dragOverlay:l,droppableRects:s,over:c,measureDroppableContainers:d}=(0,f.useContext)(ht),u=T(Nt,n),h=Boolean(null!==l.rect),p=(0,f.useMemo)((()=>r.map((e=>"object"==typeof e&&"id"in e?e.id:e))),[r]),g=null!=a,m=a?p.indexOf(a.id):-1,b=c?p.indexOf(c.id):-1,x=(0,f.useRef)(p),w=!function(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}(p,x.current),y=-1!==b&&-1===m||w,C=function(e){return"boolean"==typeof e?{draggable:e,droppable:e}:e}(i);E((()=>{w&&g&&d(p)}),[w,p,g,d]),(0,f.useEffect)((()=>{x.current=p}),[p]);const D=(0,f.useMemo)((()=>({activeIndex:m,containerId:u,disabled:C,disableTransforms:y,items:p,overIndex:b,useDragOverlay:h,sortedRects:Dt(p,s),strategy:o})),[m,u,C.draggable,C.droppable,y,p,b,s,h,o]);return v().createElement(Mt.Provider,{value:D},t)}const It=e=>{let{id:t,items:n,activeIndex:r,overIndex:o}=e;return Ct(n,r,o).indexOf(t)},Tt=e=>{let{containerId:t,isSorting:n,wasDragging:r,index:o,items:i,newIndex:a,previousItems:l,previousContainerId:s,transition:c}=e;return!(!c||!r||l!==i&&o===a||!n&&(a===o||t!==s))},Lt={duration:200,easing:"ease"},At="transform",Bt=z.Transition.toString({property:At,duration:0,easing:"linear"}),Ot={roleDescription:"sortable"};function Pt(e){let{animateLayoutChanges:t=Tt,attributes:n,disabled:r,data:o,getNewIndex:i=It,id:a,strategy:l,resizeObserverConfig:s,transition:c=Lt}=e;const{items:d,containerId:u,activeIndex:h,disabled:p,disableTransforms:v,sortedRects:g,overIndex:m,useDragOverlay:b,strategy:x}=(0,f.useContext)(Mt),w=function(e,t){var n,r;return"boolean"==typeof e?{draggable:e,droppable:!1}:{draggable:null!=(n=null==e?void 0:e.draggable)?n:t.draggable,droppable:null!=(r=null==e?void 0:e.droppable)?r:t.droppable}}(r,p),y=d.indexOf(a),C=(0,f.useMemo)((()=>({sortable:{containerId:u,index:y,items:d},...o})),[u,o,y,d]),D=(0,f.useMemo)((()=>d.slice(d.indexOf(a))),[d,a]),{rect:R,node:S,isOver:N,setNodeRef:k}=function(e){let{data:t,disabled:n=!1,id:r,resizeObserverConfig:o}=e;const i=T("Droppable"),{active:a,dispatch:l,over:s,measureDroppableContainers:c}=(0,f.useContext)(ut),d=(0,f.useRef)({disabled:n}),u=(0,f.useRef)(!1),h=(0,f.useRef)(null),p=(0,f.useRef)(null),{disabled:v,updateMeasurementsFor:g,timeout:m}={...yt,...o},b=j(null!=g?g:r),x=Ze({callback:(0,f.useCallback)((()=>{u.current?(null!=p.current&&clearTimeout(p.current),p.current=setTimeout((()=>{c(Array.isArray(b.current)?b.current:[b.current]),p.current=null}),m)):u.current=!0}),[m]),disabled:v||!a}),w=(0,f.useCallback)(((e,t)=>{x&&(t&&(x.unobserve(t),u.current=!1),e&&x.observe(e))}),[x]),[y,C]=M(w),D=j(t);return(0,f.useEffect)((()=>{x&&y.current&&(x.disconnect(),u.current=!1,x.observe(y.current))}),[y,x]),(0,f.useEffect)((()=>(l({type:G.RegisterDroppable,element:{id:r,key:i,disabled:n,node:y,rect:h,data:D}}),()=>l({type:G.UnregisterDroppable,key:i,id:r}))),[r]),(0,f.useEffect)((()=>{n!==d.current.disabled&&(l({type:G.SetDroppableDisabled,id:r,key:i,disabled:n}),d.current.disabled=n)}),[r,i,n,l]),{active:a,rect:h,isOver:(null==s?void 0:s.id)===r,node:y,over:s,setNodeRef:C}}({id:a,data:C,disabled:w.droppable,resizeObserverConfig:{updateMeasurementsFor:D,...s}}),{active:I,activatorEvent:L,activeNodeRect:A,attributes:B,setNodeRef:P,listeners:F,isDragging:U,over:H,setActivatorNodeRef:V,transform:X}=function(e){let{id:t,data:n,disabled:r=!1,attributes:o}=e;const i=T("Draggable"),{activators:a,activatorEvent:l,active:s,activeNodeRect:c,ariaDescribedById:d,draggableNodes:u,over:h}=(0,f.useContext)(ut),{role:p=wt,roleDescription:v="draggable",tabIndex:g=0}=null!=o?o:{},m=(null==s?void 0:s.id)===t,b=(0,f.useContext)(m?gt:xt),[x,w]=M(),[y,C]=M(),D=function(e,t){return(0,f.useMemo)((()=>e.reduce(((e,n)=>{let{eventName:r,handler:o}=n;return e[r]=e=>{o(e,t)},e}),{})),[e,t])}(a,t),R=j(n);return E((()=>(u.set(t,{id:t,key:i,node:x,activatorNode:y,data:R}),()=>{const e=u.get(t);e&&e.key===i&&u.delete(t)})),[u,t]),{active:s,activatorEvent:l,activeNodeRect:c,attributes:(0,f.useMemo)((()=>({role:p,tabIndex:g,"aria-disabled":r,"aria-pressed":!(!m||p!==wt)||void 0,"aria-roledescription":v,"aria-describedby":d.draggable})),[r,p,g,m,v,d.draggable]),isDragging:m,listeners:r?void 0:D,node:x,over:h,setNodeRef:w,setActivatorNodeRef:C,transform:b}}({id:a,data:C,attributes:{...Ot,...n},disabled:w.draggable}),Y=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return(0,f.useMemo)((()=>e=>{t.forEach((t=>t(e)))}),t)}(k,P),K=Boolean(I),W=K&&!v&&Rt(h)&&Rt(m),_=!b&&U,J=_&&W?X:null,q=W?null!=J?J:(null!=l?l:x)({rects:g,activeNodeRect:A,activeIndex:h,overIndex:m,index:y}):null,$=Rt(h)&&Rt(m)?i({id:a,items:d,activeIndex:h,overIndex:m}):y,Z=null==I?void 0:I.id,Q=(0,f.useRef)({activeId:Z,items:d,newIndex:$,containerId:u}),ee=d!==Q.current.items,te=t({active:I,containerId:u,isDragging:U,isSorting:K,id:a,index:y,items:d,newIndex:Q.current.newIndex,previousItems:Q.current.items,previousContainerId:Q.current.containerId,transition:c,wasDragging:null!=Q.current.activeId}),ne=function(e){let{disabled:t,index:n,node:r,rect:o}=e;const[i,a]=(0,f.useState)(null),l=(0,f.useRef)(n);return E((()=>{if(!t&&n!==l.current&&r.current){const e=o.current;if(e){const t=ue(r.current,{ignoreTransform:!0}),n={x:e.left-t.left,y:e.top-t.top,scaleX:e.width/t.width,scaleY:e.height/t.height};(n.x||n.y)&&a(n)}}n!==l.current&&(l.current=n)}),[t,n,r,o]),(0,f.useEffect)((()=>{i&&a(null)}),[i]),i}({disabled:!te,index:y,node:S,rect:R});return(0,f.useEffect)((()=>{K&&Q.current.newIndex!==$&&(Q.current.newIndex=$),u!==Q.current.containerId&&(Q.current.containerId=u),d!==Q.current.items&&(Q.current.items=d)}),[K,$,u,d]),(0,f.useEffect)((()=>{if(Z===Q.current.activeId)return;if(null!=Z&&null==Q.current.activeId)return void(Q.current.activeId=Z);const e=setTimeout((()=>{Q.current.activeId=Z}),50);return()=>clearTimeout(e)}),[Z]),{active:I,activeIndex:h,attributes:B,data:C,rect:R,index:y,newIndex:$,items:d,isOver:N,isSorting:K,isDragging:U,listeners:F,node:S,overIndex:m,over:H,setNodeRef:Y,setActivatorNodeRef:V,setDroppableNodeRef:k,setDraggableNodeRef:P,transform:null!=ne?ne:q,transition:ne||ee&&Q.current.newIndex===y?Bt:_&&!O(L)||!c?void 0:K||te?z.Transition.toString({...c,property:At}):void 0}}function zt(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 Ft=[Ie.Down,Ie.Right,Ie.Up,Ie.Left],Ut=(e,t)=>{let{context:{active:n,collisionRect:r,droppableRects:o,droppableContainers:i,over:a,scrollableAncestors:l}}=t;if(Ft.includes(e.code)){if(e.preventDefault(),!n||!r)return;const t=[];i.getEnabled().forEach((n=>{if(!n||null!=n&&n.disabled)return;const i=o.get(n.id);if(i)switch(e.code){case Ie.Down:r.top<i.top&&t.push(n);break;case Ie.Up:r.top>i.top&&t.push(n);break;case Ie.Left:r.left>i.left&&t.push(n);break;case Ie.Right:r.left<i.left&&t.push(n)}}));const d=(e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const o=te(t),i=[];for(const e of r){const{id:t}=e,r=n.get(t);if(r){const n=te(r),a=o.reduce(((e,t,r)=>e+Z(n[r],t)),0),l=Number((a/4).toFixed(4));i.push({id:t,data:{droppableContainer:e,value:l}})}}return i.sort(Q)})({active:n,collisionRect:r,droppableRects:o,droppableContainers:t,pointerCoordinates:null});let u=ne(d,"id");if(u===(null==a?void 0:a.id)&&d.length>1&&(u=d[1].id),null!=u){const e=i.get(n.id),t=i.get(u),a=t?o.get(t.id):null,d=null==t?void 0:t.node.current;if(d&&a&&e&&t){const n=pe(d).some(((e,t)=>l[t]!==e)),o=Ht(e,t),i=(c=t,!(!zt(s=e)||!zt(c))&&!!Ht(s,c)&&s.data.current.sortable.index<c.data.current.sortable.index),u=n||!o?{x:0,y:0}:{x:i?r.width-a.width:0,y:i?r.height-a.height:0},h={x:a.left,y:a.top};return u.x&&u.y?h:B(h,u)}}}var s,c};function Ht(e,t){return!(!zt(e)||!zt(t))&&e.data.current.sortable.containerId===t.data.current.sortable.containerId}const Vt=window.wp.primitives,Xt=(0,d.jsx)(Vt.SVG,{width:"24",height:"24",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,d.jsx)(Vt.Path,{d:"M8 7h2V5H8v2zm0 6h2v-2H8v2zm0 6h2v-2H8v2zm6-14v2h2V5h-2zm0 8h2v-2h-2v2zm0 6h2v-2h-2v2z"})}),Yt=(0,d.jsx)(Vt.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,d.jsx)(Vt.Path,{d:"M11 12.5V17.5H12.5V12.5H17.5V11H12.5V6H11V11H6V12.5H11Z"})}),Kt=(0,d.jsx)(Vt.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,d.jsx)(Vt.Path,{d:"M12 13.06l3.712 3.713 1.061-1.06L13.061 12l3.712-3.712-1.06-1.06L12 10.938 8.288 7.227l-1.061 1.06L10.939 12l-3.712 3.712 1.06 1.061L12 13.061z"})}),Wt=({id:e,item:t,fields:n,updateItemContent:r,deleteItem:i})=>{const[l,s]=(0,o.useState)(!1),{attributes:c,listeners:u,setNodeRef:h,transform:p,transition:f,isDragging:v}=Pt({id:e}),g={transform:z.Transform.toString(p&&{...p,scaleY:1}),transition:f,opacity:v?.5:1};return(0,d.jsxs)("div",{ref:h,style:g,className:"repeater-component-item",children:[(0,d.jsxs)("div",{className:"repeater-component-item-buttons",children:[(0,d.jsx)(a.Button,{...c,...u,icon:Xt}),(0,d.jsx)(a.Button,{icon:l?Yt:"minus",onClick:()=>s(!l)}),(0,d.jsx)(a.Button,{isDestructive:!0,onClick:()=>i(e),icon:Kt})]}),(0,d.jsx)("div",{className:(l?"is-collapsed ":"")+"repeater-component-item-components",children:(0,d.jsx)(Gt,{attributes:c,components:n,onChange:r,item:t,id:e})})]})},_t=({componentName:e,fields:t,meta:n,props:r})=>{const{attributes:l,setAttributes:s}=r,c=(0,i.useSelect)((e=>n?e("core/editor").getEditedPostAttribute("meta"):null)),u=n?c[e]:l[e],[h,p]=(0,o.useState)([]),{editPost:v}=(0,i.useDispatch)("core/editor");(0,o.useEffect)((()=>{const e=new Set(t.map((e=>e.name))),n=u.map((t=>{const n={id:t.id};return Object.keys(t).forEach((r=>{(e.has(r)||"id"===r)&&(n[r]=t[r])})),e.forEach((e=>{e in n||(n[e]="")})),n}));p(n)}),[u,t]);const g=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return(0,f.useMemo)((()=>[...t].filter((e=>null!=e))),[...t])}(q(He),q(Oe,{coordinateGetter:Ut})),m=t=>{const r=h.filter((e=>e.id!==t));p(r),!1!==n?v({meta:{[n]:r}}):s({[e]:r})},b=(t,r,o)=>{const i=h.map((e=>e.id===t?{...e,[r]:o}:e));p(i),!1!==n?v({meta:{[n]:i}}):s({[e]:i})};return(0,d.jsxs)(a.BaseControl,{children:[(0,d.jsx)(bt,{sensors:g,collisionDetection:oe,onDragEnd:t=>{const{active:r,over:o}=t;r&&o&&((t,r)=>{const o=h.findIndex((e=>e.id===t)),i=h.findIndex((e=>e.id===r));if(o!==i){const t=Ct(h,o,i);p(t),!1!==n?v({meta:{[n]:t}}):s({[e]:t})}})(r.id,o.id)},children:(0,d.jsx)(kt,{items:h,strategy:jt,children:(0,d.jsx)("div",{className:"repeater-component",children:h.map((e=>(0,d.jsx)(Wt,{id:e.id,item:e,fields:t,updateItemContent:b,deleteItem:m},e.id)))})})}),(0,d.jsx)(a.Button,{isPrimary:!0,onClick:()=>(t=>{const r={id:`${Date.now()}`};t.forEach((e=>{r[e.name]=e.value}));const o=[...h,r];p(o),!1!==n?v({meta:{[n]:o}}):s({[e]:o})})(t),className:"repeater-component-add-item-button",children:r.buttonLabel})]})};function Gt({attributes:e,components:t,onChange:n,props:r,item:l=null,id:s=null}){const h=t.some((e=>e.meta)),f=(0,i.useSelect)((e=>h?e("core/editor").getEditedPostAttribute("meta"):null)),[v,g]=(0,o.useState)({});(0,o.useEffect)((()=>{const n={};t.forEach((t=>{n[t.name]=l?l[t.name]:e[t.name]})),g(n)}),[t,l,e]);const m=(e,t,r,o)=>{g((e=>({...e,[t]:r}))),n(e,t,r,o)};return(0,d.jsx)(d.Fragment,{children:t.map((t=>(e=>!e.condition||(Array.isArray(e.condition)?e.condition:[e.condition]).every((e=>v[e.name]===e.value)))(t)?(t=>{var o,i,h,v,g;const b=t.meta?"is-meta":"",x=t.meta?f[t.name]:l?l[t.name]:e[t.name],w=!!t.meta&&t.name;switch(t.type){case"TimePicker":return(0,d.jsx)(a.BaseControl,{className:b,label:t.label,help:t.help,children:(0,d.jsx)(a.TimePicker,{currentDate:x,onChange:e=>n(s,t.name,e,w),...t.is12hour?{is12Hour:!0}:{}},t.name)},t.name);case"Text":return(0,d.jsx)(a.TextControl,{className:b,label:t.label,help:t.help,placeholder:t.placeholder,value:x,onChange:e=>n(s,t.name,e,w)},t.name);case"Textarea":return(0,d.jsx)(a.TextareaControl,{className:b,label:t.label,help:t.help,placeholder:t.placeholder,value:x,onChange:e=>n(s,t.name,e,w)},t.name);case"Toggle":return(0,d.jsx)(a.ToggleControl,{className:b,label:t.label,help:t.help,checked:x,onChange:e=>m(s,t.name,e,w)},t.name);case"Select":return(0,d.jsx)(a.SelectControl,{className:b,label:t.label,help:t.help,value:x,onChange:e=>m(s,t.name,e,w),options:[...t.choices]},t.name);case"ColorPalette":return(0,d.jsx)(a.BaseControl,{className:b,label:t.label,help:t.help,children:(0,d.jsx)(a.ColorPalette,{value:x,onChange:e=>n(s,t.name,e,w),colors:[...t.colors],disableCustomColors:!0,clearable:!1})},t.name);case"ColorPicker":return(0,d.jsx)(a.BaseControl,{className:b,label:t.label,help:t.help,children:(0,d.jsx)(a.ColorPicker,{color:x,defaultValue:x,onChange:e=>m(s,t.name,e,w),...t.alfa?{enableAlpha:!0}:{}},t.name)},t.name);case"Image":return(0,d.jsx)(a.BaseControl,{className:b,label:t.label,help:t.help,children:(0,d.jsx)(c.MediaUploadCheck,{children:(0,d.jsx)(c.MediaUpload,{onSelect:e=>n(s,t.name,e.id,w),allowedTypes:["image"],value:x,render:({open:e})=>(0,d.jsx)(u,{open:e,remove:()=>n(s,t.name,0,w),componentName:t.name,mediaId:x})})})},t.name);case"File":return(0,d.jsx)(a.BaseControl,{className:b,label:t.label,help:t.help,children:(0,d.jsx)(c.MediaUploadCheck,{children:(0,d.jsx)(c.MediaUpload,{onSelect:e=>{var r,o,i,a;n(s,t.name,{id:null!==(r=e.id)&&void 0!==r?r:"",name:null!==(o=e.filename)&&void 0!==o?o:"",url:null!==(i=e.url)&&void 0!==i?i:"",size:null!==(a=e.filesizeHumanReadable)&&void 0!==a?a:""},w)},value:x,render:({open:e})=>(0,d.jsx)(p,{open:e,remove:()=>n(s,t.name,{},w),componentName:t.name,file:x})})})},t.name);case"Link":return(0,d.jsx)(a.BaseControl,{className:b,label:t.label,help:t.help,children:(0,d.jsx)(c.__experimentalLinkControl,{searchInputPlaceholder:null!==(o=t.placeholder)&&void 0!==o?o:"Search...",value:x,onChange:e=>n(s,t.name,e,w),hasTextControl:!0,onRemove:()=>n(s,t.name,{},w)})},t.name);case"Range":return(0,d.jsx)(a.RangeControl,{className:b,label:t.label,help:t.help,value:x,onChange:e=>n(s,t.name,e,w),min:null!==(i=t.min)&&void 0!==i?i:300,max:null!==(h=t.max)&&void 0!==h?h:1536,step:null!==(v=t.step)&&void 0!==v?v:10},t.name);case"RichText":return(0,d.jsx)(a.BaseControl,{className:b,label:t.label,help:t.help,children:(0,d.jsx)(c.RichText,{label:t.label,value:x,onChange:e=>n(s,t.name,e,w),placeholder:null!==(g=t.placeholder)&&void 0!==g?g:"..."},t.name)},t.name);case"Message":return(0,d.jsx)(a.BaseControl,{className:b,label:t.label,help:t.help},t.name);case"Repeater":return(0,d.jsx)(a.BaseControl,{className:b,label:t.label,help:t.help,children:(0,d.jsx)(_t,{componentName:t.name,fields:t.fields,meta:w,props:{...r,buttonLabel:t.button_label||"Add"}},t.name)},t.name);default:return null}})(t):null))})}function Jt({name:e,props:t}){const{attributes:n,setAttributes:r}=t,[l,u]=(0,o.useState)([]),h=void 0!==(0,i.select)("core/editor"),{editPost:p}=h?(0,i.useDispatch)("core/editor"):{},f=(e=null,t,n,o=!1)=>{r({[t]:n}),p&&!1!==o&&p({meta:{[o]:n}})};return(0,o.useEffect)((()=>{s()({path:`/${e}/v1/data`}).then((e=>{u(e),e.options.map((e=>{[e.name]in e&&f([e.name],e.value)}))})).catch((e=>console.error(e?.message)))}),[]),(0,d.jsxs)(c.InspectorControls,{children:[!l&&(0,d.jsx)(a.Spinner,{}),l&&l.options&&l.options.length>0&&l.options.map(((e,r)=>{var o,i;return(0,d.jsx)(a.PanelBody,{title:null!==(o=e.label)&&void 0!==o?o:e.name,initialOpen:null!==(i=e.open)&&void 0!==i&&i,children:(0,d.jsx)("div",{className:"gutengood gutengood-options",children:(0,d.jsx)(Gt,{attributes:n,components:e.fields,onChange:f,props:t})})},r)}))]})}const qt=window.wp.serverSideRender;var $t=e.n(qt);const Zt=(0,d.jsx)(Vt.SVG,{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,d.jsx)(Vt.Path,{d:"M3.99961 13C4.67043 13.3354 4.6703 13.3357 4.67017 13.3359L4.67298 13.3305C4.67621 13.3242 4.68184 13.3135 4.68988 13.2985C4.70595 13.2686 4.7316 13.2218 4.76695 13.1608C4.8377 13.0385 4.94692 12.8592 5.09541 12.6419C5.39312 12.2062 5.84436 11.624 6.45435 11.0431C7.67308 9.88241 9.49719 8.75 11.9996 8.75C14.502 8.75 16.3261 9.88241 17.5449 11.0431C18.1549 11.624 18.6061 12.2062 18.9038 12.6419C19.0523 12.8592 19.1615 13.0385 19.2323 13.1608C19.2676 13.2218 19.2933 13.2686 19.3093 13.2985C19.3174 13.3135 19.323 13.3242 19.3262 13.3305L19.3291 13.3359C19.3289 13.3357 19.3288 13.3354 19.9996 13C20.6704 12.6646 20.6703 12.6643 20.6701 12.664L20.6697 12.6632L20.6688 12.6614L20.6662 12.6563L20.6583 12.6408C20.6517 12.6282 20.6427 12.6108 20.631 12.5892C20.6078 12.5459 20.5744 12.4852 20.5306 12.4096C20.4432 12.2584 20.3141 12.0471 20.1423 11.7956C19.7994 11.2938 19.2819 10.626 18.5794 9.9569C17.1731 8.61759 14.9972 7.25 11.9996 7.25C9.00203 7.25 6.82614 8.61759 5.41987 9.9569C4.71736 10.626 4.19984 11.2938 3.85694 11.7956C3.68511 12.0471 3.55605 12.2584 3.4686 12.4096C3.42484 12.4852 3.39142 12.5459 3.36818 12.5892C3.35656 12.6108 3.34748 12.6282 3.34092 12.6408L3.33297 12.6563L3.33041 12.6614L3.32948 12.6632L3.32911 12.664C3.32894 12.6643 3.32879 12.6646 3.99961 13ZM11.9996 16C13.9326 16 15.4996 14.433 15.4996 12.5C15.4996 10.567 13.9326 9 11.9996 9C10.0666 9 8.49961 10.567 8.49961 12.5C8.49961 14.433 10.0666 16 11.9996 16Z"})});function Qt({name:e,props:t}){const{attributes:n,setAttributes:r}=t,[l,u]=(0,o.useState)([]),[h,p]=(0,o.useState)(!1),f=void 0!==(0,i.select)("core/editor"),{editPost:v}=f?(0,i.useDispatch)("core/editor"):{},g=(e=null,t,n,o=!1)=>{r({[t]:n}),v&&!1!==o&&v({meta:{[o]:n}})};return(0,o.useEffect)((()=>{s()({path:`/${e}/v1/data`}).then((e=>{u(e),p(e.edit_mode),e.fields.map((e=>{[e.name]in e&&g([e.name],e.value)}))})).catch((e=>console.error(e?.message)))}),[]),(0,d.jsxs)(d.Fragment,{children:[!l&&(0,d.jsx)(a.Spinner,{}),l&&l.fields&&l.fields.length>0&&(0,d.jsx)(c.BlockControls,{children:(0,d.jsx)(a.ToolbarGroup,{children:(0,d.jsx)(a.ToolbarButton,{icon:h?Zt:"edit",onClick:()=>{p(!h)}})})}),l&&l.fields&&h&&(0,d.jsx)("div",{className:"gutengood gutengood-fields",children:(0,d.jsx)(Gt,{attributes:n,components:l.fields,onChange:g,props:t})}),!h&&(0,d.jsx)($t(),{httpMethod:"POST",block:e,props:t,attributes:t.attributes})]})}function en({name:e}){const[t,n]=(0,o.useState)([]),r=void 0!==(0,i.select)("core/editor"),{editPost:l}=r?(0,i.useDispatch)("core/editor"):{},c=(e=null,t,n,r=!0)=>{l&&l({meta:{[r]:n}})};return(0,o.useEffect)((()=>{s()({path:`/${e}/v1/data`}).then((e=>{n(e),e.options.map((e=>{[e.name]in e&&c([e.name],e.value)}))})).catch((e=>console.error(e?.message)))}),[]),(0,d.jsxs)(d.Fragment,{children:[!t&&(0,d.jsx)(a.Spinner,{}),t&&t.options&&t.options.length>0&&t.options.map(((e,t)=>(0,d.jsx)("div",{className:"gutengood gutengood-panel gutengood-options",children:(0,d.jsx)(Gt,{attributes:e.fields,components:e.fields,onChange:c})},t)))]})}if(void 0!==window.gutengoodBlocks&&window.gutengoodBlocks.forEach((e=>{const n=e.name;(0,t.registerBlockType)(n,{title:e.title,icon:tn(e.icon),description:e.description,category:e.category,edit:e=>(0,d.jsxs)(o.Fragment,{children:[(0,d.jsx)(Jt,{name:n,props:e}),(0,d.jsx)(Qt,{name:n,props:e})]}),save:()=>null})})),void 0!==window.gutengoodPanels){const e=e=>{const t=(0,i.useSelect)((e=>{var t;return null!==(t=e("core/editor")?.getCurrentPostType())&&void 0!==t?t:null}));return e.post_types.includes(t)?(0,d.jsx)(r.PluginDocumentSettingPanel,{name:e.name,title:e.title,icon:tn(e.icon),children:(0,d.jsx)(en,{name:e.name})}):null};window.gutengoodPanels.forEach((t=>{(0,n.registerPlugin)(t.name,{render:()=>e(t),icon:tn(t.icon)})}))}function tn(e){if(!e||"string"!=typeof e||!e.includes('"svg"'))return e;const t=JSON.parse(e),{svg:n}=t,r=n.paths?n.paths.map(((e,t)=>(0,d.jsx)("path",{fill:e["@attributes"].fill,d:e["@attributes"].d},t))):(0,d.jsx)("path",{fill:n.path["@attributes"].fill,d:n.path["@attributes"].d});return(0,d.jsx)("svg",{width:n["@attributes"].width,height:n["@attributes"].height,viewBox:n["@attributes"].viewBox,children:r})}})();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gutengood-js",
3
- "version": "2.1.0",
3
+ "version": "2.1.1",
4
4
  "main": "index.js",
5
5
  "repository": "https://github.com/yarovikov/gutengood-js",
6
6
  "author": "yarovikov <alex.yarovikov@gmail.com>",
@@ -13,8 +13,8 @@
13
13
  "@dnd-kit/core": "^6.3.1",
14
14
  "@dnd-kit/sortable": "^10.0.0",
15
15
  "@dnd-kit/utilities": "^3.2.2",
16
- "@wordpress/icons": "^10.15.1",
17
- "@wordpress/scripts": "^30.8.1",
16
+ "@wordpress/icons": "^10.17.0",
17
+ "@wordpress/scripts": "^30.10.0",
18
18
  "immutability-helper": "^3.1.1"
19
19
  }
20
20
  }
@@ -4,7 +4,7 @@ import {useState, useEffect} from '@wordpress/element';
4
4
  import {BlockControls} from '@wordpress/block-editor';
5
5
  import ServerSideRender from '@wordpress/server-side-render';
6
6
  import {seen} from '@wordpress/icons';
7
- import {useDispatch} from '@wordpress/data';
7
+ import {useDispatch, select} from '@wordpress/data';
8
8
  import BlockComponents from "./block-components";
9
9
 
10
10
  export default function BlockFields({name, props}) {
@@ -12,11 +12,13 @@ export default function BlockFields({name, props}) {
12
12
  const {attributes, setAttributes} = props;
13
13
  const [data, setData] = useState([]);
14
14
  const [editMode, setEditMode] = useState(false);
15
- const {editPost} = useDispatch('core/editor');
15
+
16
+ const isPostEditor = select('core/editor') !== undefined;
17
+ const {editPost} = isPostEditor ? useDispatch('core/editor') : {};
16
18
 
17
19
  const onChangeAttribute = (id = null, key, value, metaName = false) => {
18
20
  setAttributes({[key]: value})
19
- if (false !== metaName) {
21
+ if (editPost && false !== metaName) {
20
22
  editPost({meta: {[metaName]: value}})
21
23
  }
22
24
  };
@@ -2,18 +2,20 @@ import {Spinner, PanelBody} from '@wordpress/components';
2
2
  import apiFetch from '@wordpress/api-fetch';
3
3
  import {useState, useEffect} from '@wordpress/element';
4
4
  import {InspectorControls} from '@wordpress/block-editor';
5
- import {useDispatch} from '@wordpress/data';
5
+ import {useDispatch, select} from '@wordpress/data';
6
6
  import BlockComponents from "./block-components";
7
7
 
8
8
  export default function BlockOptions({name, props}) {
9
9
 
10
10
  const {attributes, setAttributes} = props;
11
11
  const [data, setData] = useState([]);
12
- const {editPost} = useDispatch('core/editor');
12
+
13
+ const isPostEditor = select('core/editor') !== undefined;
14
+ const {editPost} = isPostEditor ? useDispatch('core/editor') : {};
13
15
 
14
16
  const onChangeAttribute = (id = null, key, value, metaName = false) => {
15
17
  setAttributes({[key]: value})
16
- if (false !== metaName) {
18
+ if (editPost && false !== metaName) {
17
19
  editPost({meta: {[metaName]: value}})
18
20
  }
19
21
  };
@@ -1,16 +1,20 @@
1
1
  import {Spinner} from '@wordpress/components';
2
2
  import apiFetch from '@wordpress/api-fetch';
3
3
  import {useState, useEffect} from '@wordpress/element';
4
- import {useDispatch} from '@wordpress/data';
4
+ import {useDispatch, select} from '@wordpress/data';
5
5
  import BlockComponents from "./block-components";
6
6
 
7
7
  export default function PanelOptions({name}) {
8
8
 
9
9
  const [data, setData] = useState([]);
10
- const {editPost} = useDispatch('core/editor');
10
+
11
+ const isPostEditor = select('core/editor') !== undefined;
12
+ const {editPost} = isPostEditor ? useDispatch('core/editor') : {};
11
13
 
12
14
  const onChangeAttribute = (id = null, key, value, metaName = true) => {
13
- editPost({meta: {[metaName]: value}})
15
+ if (editPost) {
16
+ editPost({meta: {[metaName]: value}})
17
+ }
14
18
  };
15
19
 
16
20
  useEffect(() => {
package/src/index.js CHANGED
@@ -29,7 +29,7 @@ if ('undefined' !== typeof window.gutengoodBlocks) {
29
29
 
30
30
  if ('undefined' !== typeof window.gutengoodPanels) {
31
31
  const GutengoodPluginDocumentSettingPanel = (panel) => {
32
- const postType = useSelect(select => select('core/editor').getCurrentPostType());
32
+ const postType = useSelect(select => select('core/editor')?.getCurrentPostType() ?? null);
33
33
  if (!panel.post_types.includes(postType)) {
34
34
  return null;
35
35
  }