(()=>{"use strict";var t,e={845:(t,e,n)=>{var r={};n.r(r),n.d(r,{FILE:()=>Yt,HTML:()=>Jt,TEXT:()=>Kt,URL:()=>Wt});const i=window.wp.blocks,o=window.wp.i18n,a=window.wp.blockEditor,s=window.wp.components,l=window.wp.element;function c(t,e,...n){if("undefined"!=typeof process&&void 0===e)throw new Error("invariant requires an error message argument");if(!t){let t;if(void 0===e)t=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{let r=0;t=new Error(e.replace(/%s/g,(function(){return n[r++]}))),t.name="Invariant Violation"}throw t.framesToPop=1,t}}var u=n(792);const h=window.React,d="undefined"!=typeof window?h.useLayoutEffect:h.useEffect;function f(t,e,n){return function(t,e,n){const[r,i]=function(t,e,n){const[r,i]=(0,h.useState)((()=>e(t))),o=(0,h.useCallback)((()=>{const o=e(t);u(r,o)||(i(o),n&&n())}),[r,t,n]);return d(o),[r,o]}(t,e,n);return d((function(){const e=t.getHandlerId();if(null!=e)return t.subscribeToStateChange(i,{handlerIds:[e]})}),[t,i]),r}(e,t||(()=>({})),(()=>n.reconnect()))}function p(t,e){const n=[...e||[]];return null==e&&"function"!=typeof t&&n.push(t),(0,h.useMemo)((()=>"function"==typeof t?t():t),n)}function g(t){return(0,h.useMemo)((()=>t.hooks.dragSource()),[t])}function v(t){return(0,h.useMemo)((()=>t.hooks.dragPreview()),[t])}function m(t,e,n,r){let i=n?n.call(r,t,e):void 0;if(void 0!==i)return!!i;if(t===e)return!0;if("object"!=typeof t||!t||"object"!=typeof e||!e)return!1;const o=Object.keys(t),a=Object.keys(e);if(o.length!==a.length)return!1;const s=Object.prototype.hasOwnProperty.bind(e);for(let a=0;a{const r=t[n];if(n.endsWith("Ref"))e[n]=t[n];else{const t=function(t){return(e=null,n=null)=>{if(!(0,h.isValidElement)(e)){const r=e;return t(r,n),r}const r=e;return function(t){if("string"==typeof t.type)return;const e=t.type.displayName||t.type.name||"the component";throw new Error(`Only native element nodes can now be passed to React DnD connectors.You can either wrap ${e} into a
, or turn it into a drag source or a drop target itself.`)}(r),function(t,e){const n=t.ref;return c("string"!=typeof n,"Cannot connect React DnD to an element with an existing string ref. Please convert it to use a callback ref instead, or wrap it into a or
. Read more: https://reactjs.org/docs/refs-and-the-dom.html#callback-refs"),n?(0,h.cloneElement)(t,{ref:t=>{w(n,t),w(e,t)}}):(0,h.cloneElement)(t,{ref:e})}(r,n?e=>t(e,n):t)}}(r);e[n]=()=>t}})),e}function w(t,e){"function"==typeof t?t(e):t.current=e}class x{receiveHandlerId(t){this.handlerId!==t&&(this.handlerId=t,this.reconnect())}get connectTarget(){return this.dragSource}get dragSourceOptions(){return this.dragSourceOptionsInternal}set dragSourceOptions(t){this.dragSourceOptionsInternal=t}get dragPreviewOptions(){return this.dragPreviewOptionsInternal}set dragPreviewOptions(t){this.dragPreviewOptionsInternal=t}reconnect(){const t=this.reconnectDragSource();this.reconnectDragPreview(t)}reconnectDragSource(){const t=this.dragSource,e=this.didHandlerIdChange()||this.didConnectedDragSourceChange()||this.didDragSourceOptionsChange();return e&&this.disconnectDragSource(),this.handlerId?t?(e&&(this.lastConnectedHandlerId=this.handlerId,this.lastConnectedDragSource=t,this.lastConnectedDragSourceOptions=this.dragSourceOptions,this.dragSourceUnsubscribe=this.backend.connectDragSource(this.handlerId,t,this.dragSourceOptions)),e):(this.lastConnectedDragSource=t,e):e}reconnectDragPreview(t=!1){const e=this.dragPreview,n=t||this.didHandlerIdChange()||this.didConnectedDragPreviewChange()||this.didDragPreviewOptionsChange();n&&this.disconnectDragPreview(),this.handlerId&&(e?n&&(this.lastConnectedHandlerId=this.handlerId,this.lastConnectedDragPreview=e,this.lastConnectedDragPreviewOptions=this.dragPreviewOptions,this.dragPreviewUnsubscribe=this.backend.connectDragPreview(this.handlerId,e,this.dragPreviewOptions)):this.lastConnectedDragPreview=e)}didHandlerIdChange(){return this.lastConnectedHandlerId!==this.handlerId}didConnectedDragSourceChange(){return this.lastConnectedDragSource!==this.dragSource}didConnectedDragPreviewChange(){return this.lastConnectedDragPreview!==this.dragPreview}didDragSourceOptionsChange(){return!m(this.lastConnectedDragSourceOptions,this.dragSourceOptions)}didDragPreviewOptionsChange(){return!m(this.lastConnectedDragPreviewOptions,this.dragPreviewOptions)}disconnectDragSource(){this.dragSourceUnsubscribe&&(this.dragSourceUnsubscribe(),this.dragSourceUnsubscribe=void 0)}disconnectDragPreview(){this.dragPreviewUnsubscribe&&(this.dragPreviewUnsubscribe(),this.dragPreviewUnsubscribe=void 0,this.dragPreviewNode=null,this.dragPreviewRef=null)}get dragSource(){return this.dragSourceNode||this.dragSourceRef&&this.dragSourceRef.current}get dragPreview(){return this.dragPreviewNode||this.dragPreviewRef&&this.dragPreviewRef.current}clearDragSource(){this.dragSourceNode=null,this.dragSourceRef=null}clearDragPreview(){this.dragPreviewNode=null,this.dragPreviewRef=null}constructor(t){this.hooks=b({dragSource:(t,e)=>{this.clearDragSource(),this.dragSourceOptions=e||null,y(t)?this.dragSourceRef=t:this.dragSourceNode=t,this.reconnectDragSource()},dragPreview:(t,e)=>{this.clearDragPreview(),this.dragPreviewOptions=e||null,y(t)?this.dragPreviewRef=t:this.dragPreviewNode=t,this.reconnectDragPreview()}}),this.handlerId=null,this.dragSourceRef=null,this.dragSourceOptionsInternal=null,this.dragPreviewRef=null,this.dragPreviewOptionsInternal=null,this.lastConnectedHandlerId=null,this.lastConnectedDragSource=null,this.lastConnectedDragSourceOptions=null,this.lastConnectedDragPreview=null,this.lastConnectedDragPreviewOptions=null,this.backend=t}}const _=(0,h.createContext)({dragDropManager:void 0});function C(){const{dragDropManager:t}=(0,h.useContext)(_);return c(null!=t,"Expected drag drop context"),t}let S=!1,D=!1;class O{receiveHandlerId(t){this.sourceId=t}getHandlerId(){return this.sourceId}canDrag(){c(!S,"You may not call monitor.canDrag() inside your canDrag() implementation. Read more: http://react-dnd.github.io/react-dnd/docs/api/drag-source-monitor");try{return S=!0,this.internalMonitor.canDragSource(this.sourceId)}finally{S=!1}}isDragging(){if(!this.sourceId)return!1;c(!D,"You may not call monitor.isDragging() inside your isDragging() implementation. Read more: http://react-dnd.github.io/react-dnd/docs/api/drag-source-monitor");try{return D=!0,this.internalMonitor.isDraggingSource(this.sourceId)}finally{D=!1}}subscribeToStateChange(t,e){return this.internalMonitor.subscribeToStateChange(t,e)}isDraggingSource(t){return this.internalMonitor.isDraggingSource(t)}isOverTarget(t,e){return this.internalMonitor.isOverTarget(t,e)}getTargetIds(){return this.internalMonitor.getTargetIds()}isSourcePublic(){return this.internalMonitor.isSourcePublic()}getSourceId(){return this.internalMonitor.getSourceId()}subscribeToOffsetChange(t){return this.internalMonitor.subscribeToOffsetChange(t)}canDragSource(t){return this.internalMonitor.canDragSource(t)}canDropOnTarget(t){return this.internalMonitor.canDropOnTarget(t)}getItemType(){return this.internalMonitor.getItemType()}getItem(){return this.internalMonitor.getItem()}getDropResult(){return this.internalMonitor.getDropResult()}didDrop(){return this.internalMonitor.didDrop()}getInitialClientOffset(){return this.internalMonitor.getInitialClientOffset()}getInitialSourceClientOffset(){return this.internalMonitor.getInitialSourceClientOffset()}getSourceClientOffset(){return this.internalMonitor.getSourceClientOffset()}getClientOffset(){return this.internalMonitor.getClientOffset()}getDifferenceFromInitialOffset(){return this.internalMonitor.getDifferenceFromInitialOffset()}constructor(t){this.sourceId=null,this.internalMonitor=t.getMonitor()}}class T{beginDrag(){const t=this.spec,e=this.monitor;let n=null;return n="object"==typeof t.item?t.item:"function"==typeof t.item?t.item(e):{},null!=n?n:null}canDrag(){const t=this.spec,e=this.monitor;return"boolean"==typeof t.canDrag?t.canDrag:"function"!=typeof t.canDrag||t.canDrag(e)}isDragging(t,e){const n=this.spec,r=this.monitor,{isDragging:i}=n;return i?i(r):e===t.getSourceId()}endDrag(){const t=this.spec,e=this.monitor,n=this.connector,{end:r}=t;r&&r(e.getItem(),e),n.reconnect()}constructor(t,e,n){this.spec=t,this.monitor=e,this.connector=n}}function E(t,e){const n=p(t,e);c(!n.begin,"useDrag::spec.begin was deprecated in v14. Replace spec.begin() with spec.item(). (see more here - https://react-dnd.github.io/react-dnd/docs/api/use-drag)");const r=function(){const t=C();return(0,h.useMemo)((()=>new O(t)),[t])}(),i=function(t,e){const n=C(),r=(0,h.useMemo)((()=>new x(n.getBackend())),[n]);return d((()=>(r.dragSourceOptions=t||null,r.reconnect(),()=>r.disconnectDragSource())),[r,t]),d((()=>(r.dragPreviewOptions=e||null,r.reconnect(),()=>r.disconnectDragPreview())),[r,e]),r}(n.options,n.previewOptions);return function(t,e,n){const r=C(),i=function(t,e,n){const r=(0,h.useMemo)((()=>new T(t,e,n)),[e,n]);return(0,h.useEffect)((()=>{r.spec=t}),[t]),r}(t,e,n),o=function(t){return(0,h.useMemo)((()=>{const e=t.type;return c(null!=e,"spec.type must be defined"),e}),[t])}(t);d((function(){if(null!=o){const[t,a]=function(t,e,n){const r=n.getRegistry(),i=r.addSource(t,e);return[i,()=>r.removeSource(i)]}(o,i,r);return e.receiveHandlerId(t),n.receiveHandlerId(t),a}}),[r,e,n,i,o])}(n,r,i),[f(n.collect,r,i),g(i),v(i)]}function I(t){return(0,h.useMemo)((()=>t.hooks.dropTarget()),[t])}class k{get connectTarget(){return this.dropTarget}reconnect(){const t=this.didHandlerIdChange()||this.didDropTargetChange()||this.didOptionsChange();t&&this.disconnectDropTarget();const e=this.dropTarget;this.handlerId&&(e?t&&(this.lastConnectedHandlerId=this.handlerId,this.lastConnectedDropTarget=e,this.lastConnectedDropTargetOptions=this.dropTargetOptions,this.unsubscribeDropTarget=this.backend.connectDropTarget(this.handlerId,e,this.dropTargetOptions)):this.lastConnectedDropTarget=e)}receiveHandlerId(t){t!==this.handlerId&&(this.handlerId=t,this.reconnect())}get dropTargetOptions(){return this.dropTargetOptionsInternal}set dropTargetOptions(t){this.dropTargetOptionsInternal=t}didHandlerIdChange(){return this.lastConnectedHandlerId!==this.handlerId}didDropTargetChange(){return this.lastConnectedDropTarget!==this.dropTarget}didOptionsChange(){return!m(this.lastConnectedDropTargetOptions,this.dropTargetOptions)}disconnectDropTarget(){this.unsubscribeDropTarget&&(this.unsubscribeDropTarget(),this.unsubscribeDropTarget=void 0)}get dropTarget(){return this.dropTargetNode||this.dropTargetRef&&this.dropTargetRef.current}clearDropTarget(){this.dropTargetRef=null,this.dropTargetNode=null}constructor(t){this.hooks=b({dropTarget:(t,e)=>{this.clearDropTarget(),this.dropTargetOptions=e,y(t)?this.dropTargetRef=t:this.dropTargetNode=t,this.reconnect()}}),this.handlerId=null,this.dropTargetRef=null,this.dropTargetOptionsInternal=null,this.lastConnectedHandlerId=null,this.lastConnectedDropTarget=null,this.lastConnectedDropTargetOptions=null,this.backend=t}}let M=!1;class j{receiveHandlerId(t){this.targetId=t}getHandlerId(){return this.targetId}subscribeToStateChange(t,e){return this.internalMonitor.subscribeToStateChange(t,e)}canDrop(){if(!this.targetId)return!1;c(!M,"You may not call monitor.canDrop() inside your canDrop() implementation. Read more: http://react-dnd.github.io/react-dnd/docs/api/drop-target-monitor");try{return M=!0,this.internalMonitor.canDropOnTarget(this.targetId)}finally{M=!1}}isOver(t){return!!this.targetId&&this.internalMonitor.isOverTarget(this.targetId,t)}getItemType(){return this.internalMonitor.getItemType()}getItem(){return this.internalMonitor.getItem()}getDropResult(){return this.internalMonitor.getDropResult()}didDrop(){return this.internalMonitor.didDrop()}getInitialClientOffset(){return this.internalMonitor.getInitialClientOffset()}getInitialSourceClientOffset(){return this.internalMonitor.getInitialSourceClientOffset()}getSourceClientOffset(){return this.internalMonitor.getSourceClientOffset()}getClientOffset(){return this.internalMonitor.getClientOffset()}getDifferenceFromInitialOffset(){return this.internalMonitor.getDifferenceFromInitialOffset()}constructor(t){this.targetId=null,this.internalMonitor=t.getMonitor()}}class N{canDrop(){const t=this.spec,e=this.monitor;return!t.canDrop||t.canDrop(e.getItem(),e)}hover(){const t=this.spec,e=this.monitor;t.hover&&t.hover(e.getItem(),e)}drop(){const t=this.spec,e=this.monitor;if(t.drop)return t.drop(e.getItem(),e)}constructor(t,e){this.spec=t,this.monitor=e}}function P(t,e){const n=p(t,e),r=function(){const t=C();return(0,h.useMemo)((()=>new j(t)),[t])}(),i=function(t){const e=C(),n=(0,h.useMemo)((()=>new k(e.getBackend())),[e]);return d((()=>(n.dropTargetOptions=t||null,n.reconnect(),()=>n.disconnectDropTarget())),[t]),n}(n.options);return function(t,e,n){const r=C(),i=function(t,e){const n=(0,h.useMemo)((()=>new N(t,e)),[e]);return(0,h.useEffect)((()=>{n.spec=t}),[t]),n}(t,e),o=function(t){const{accept:e}=t;return(0,h.useMemo)((()=>(c(null!=t.accept,"accept must be defined"),Array.isArray(e)?e:[e])),[e])}(t);d((function(){const[t,a]=function(t,e,n){const r=n.getRegistry(),i=r.addTarget(t,e);return[i,()=>r.removeTarget(i)]}(o,i,r);return e.receiveHandlerId(t),n.receiveHandlerId(t),a}),[r,e,i,n,o.map((t=>t.toString())).join("|")])}(n,r,i),[f(n.collect,r,i),I(i)]}const A=window.ReactJSXRuntime;function R(t){return"Minified Redux error #"+t+"; visit https://redux.js.org/Errors?code="+t+" for the full message or use the non-minified dev environment for full errors. "}var L="function"==typeof Symbol&&Symbol.observable||"@@observable",B=function(){return Math.random().toString(36).substring(7).split("").join(".")},H={INIT:"@@redux/INIT"+B(),REPLACE:"@@redux/REPLACE"+B(),PROBE_UNKNOWN_ACTION:function(){return"@@redux/PROBE_UNKNOWN_ACTION"+B()}};function $(t,e,n){var r;if("function"==typeof e&&"function"==typeof n||"function"==typeof n&&"function"==typeof arguments[3])throw new Error(R(0));if("function"==typeof e&&void 0===n&&(n=e,e=void 0),void 0!==n){if("function"!=typeof n)throw new Error(R(1));return n($)(t,e)}if("function"!=typeof t)throw new Error(R(2));var i=t,o=e,a=[],s=a,l=!1;function c(){s===a&&(s=a.slice())}function u(){if(l)throw new Error(R(3));return o}function h(t){if("function"!=typeof t)throw new Error(R(4));if(l)throw new Error(R(5));var e=!0;return c(),s.push(t),function(){if(e){if(l)throw new Error(R(6));e=!1,c();var n=s.indexOf(t);s.splice(n,1),a=null}}}function d(t){if(!function(t){if("object"!=typeof t||null===t)return!1;for(var e=t;null!==Object.getPrototypeOf(e);)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e}(t))throw new Error(R(7));if(void 0===t.type)throw new Error(R(8));if(l)throw new Error(R(9));try{l=!0,o=i(o,t)}finally{l=!1}for(var e=a=s,n=0;n=0;r--)if(e.canDragSource(t[r])){n=t[r];break}return n}(e,a);if(null==l)return void t.dispatch(W);let u=null;if(i){if(!o)throw new Error("getSourceClientOffset must be defined");!function(t){c("function"==typeof t,"When clientOffset is provided, getSourceClientOffset must be a function.")}(o),u=o(l)}t.dispatch(Y(i,u));const h=s.getSource(l).beginDrag(a,l);if(null==h)return;!function(t){c(z(t),"Item must be an object.")}(h),s.pinSource(l);const d=s.getSourceType(l);return{type:U,payload:{itemType:d,item:h,sourceId:l,clientOffset:i||null,sourceClientOffset:u||null,isSourcePublic:!!r}}}}function J(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Z(t){for(var e=1;e{const a=function(t,e,n,r){const i=n.getTarget(t);let o=i?i.drop(r,t):void 0;return function(t){c(void 0===t||z(t),"Drop result must either be an object or undefined.")}(o),void 0===o&&(o=0===e?{}:r.getDropResult()),o}(i,o,r,n),s={type:G,payload:{dropResult:Z({},e,a)}};t.dispatch(s)}))}}function tt(t){return function(){const e=t.getMonitor(),n=t.getRegistry();!function(t){c(t.isDragging(),"Cannot call endDrag while not dragging.")}(e);const r=e.getSourceId();return null!=r&&(n.getSource(r,!0).endDrag(e,r),n.unpinSource()),{type:q}}}function et(t,e){return null===e?null===t:Array.isArray(t)?t.some((t=>t===e)):t===e}function nt(t){return function(e,{clientOffset:n}={}){!function(t){c(Array.isArray(t),"Expected targetIds to be an array.")}(e);const r=e.slice(0),i=t.getMonitor(),o=t.getRegistry();return function(t,e,n){for(let r=t.length-1;r>=0;r--){const i=t[r];et(e.getTargetType(i),n)||t.splice(r,1)}}(r,o,i.getItemType()),function(t,e,n){c(e.isDragging(),"Cannot call hover while not dragging."),c(!e.didDrop(),"Cannot call hover after drop.");for(let e=0;e{const o=n[i];var a;return r[i]=(a=o,(...n)=>{const r=a.apply(t,n);void 0!==r&&e(r)}),r}),{})}dispatch(t){this.store.dispatch(t)}constructor(t,e){this.isSetUp=!1,this.handleRefCountChange=()=>{const t=this.store.getState().refCount>0;this.backend&&(t&&!this.isSetUp?(this.backend.setup(),this.isSetUp=!0):!t&&this.isSetUp&&(this.backend.teardown(),this.isSetUp=!1))},this.store=t,this.monitor=e,t.subscribe(this.handleRefCountChange)}}function ot(t,e){return{x:t.x-e.x,y:t.y-e.y}}const at=[],st=[];at.__IS_NONE__=!0,st.__IS_ALL__=!0;class lt{subscribeToStateChange(t,e={}){const{handlerIds:n}=e;c("function"==typeof t,"listener must be a function."),c(void 0===n||Array.isArray(n),"handlerIds, when specified, must be an array of strings.");let r=this.store.getState().stateId;return this.store.subscribe((()=>{const e=this.store.getState(),i=e.stateId;try{const o=i===r||i===r+1&&!function(t,e){return t!==at&&(t===st||void 0===e||(n=t,e.filter((t=>n.indexOf(t)>-1))).length>0);var n}(e.dirtyHandlerIds,n);o||t()}finally{r=i}}))}subscribeToOffsetChange(t){c("function"==typeof t,"listener must be a function.");let e=this.store.getState().dragOffset;return this.store.subscribe((()=>{const n=this.store.getState().dragOffset;n!==e&&(e=n,t())}))}canDragSource(t){if(!t)return!1;const e=this.registry.getSource(t);return c(e,`Expected to find a valid source. sourceId=${t}`),!this.isDragging()&&e.canDrag(this,t)}canDropOnTarget(t){if(!t)return!1;const e=this.registry.getTarget(t);return c(e,`Expected to find a valid target. targetId=${t}`),!(!this.isDragging()||this.didDrop())&&(et(this.registry.getTargetType(t),this.getItemType())&&e.canDrop(this,t))}isDragging(){return Boolean(this.getItemType())}isDraggingSource(t){if(!t)return!1;const e=this.registry.getSource(t,!0);return c(e,`Expected to find a valid source. sourceId=${t}`),!(!this.isDragging()||!this.isSourcePublic())&&(this.registry.getSourceType(t)===this.getItemType()&&e.isDragging(this,t))}isOverTarget(t,e={shallow:!1}){if(!t)return!1;const{shallow:n}=e;if(!this.isDragging())return!1;const r=this.registry.getTargetType(t),i=this.getItemType();if(i&&!et(r,i))return!1;const o=this.getTargetIds();if(!o.length)return!1;const a=o.indexOf(t);return n?a===o.length-1:a>-1}getItemType(){return this.store.getState().dragOperation.itemType}getItem(){return this.store.getState().dragOperation.item}getSourceId(){return this.store.getState().dragOperation.sourceId}getTargetIds(){return this.store.getState().dragOperation.targetIds}getDropResult(){return this.store.getState().dragOperation.dropResult}didDrop(){return this.store.getState().dragOperation.didDrop}isSourcePublic(){return Boolean(this.store.getState().dragOperation.isSourcePublic)}getInitialClientOffset(){return this.store.getState().dragOffset.initialClientOffset}getInitialSourceClientOffset(){return this.store.getState().dragOffset.initialSourceClientOffset}getClientOffset(){return this.store.getState().dragOffset.clientOffset}getSourceClientOffset(){return function(t){const{clientOffset:e,initialClientOffset:n,initialSourceClientOffset:r}=t;return e&&n&&r?ot((o=r,{x:(i=e).x+o.x,y:i.y+o.y}),n):null;var i,o}(this.store.getState().dragOffset)}getDifferenceFromInitialOffset(){return function(t){const{clientOffset:e,initialClientOffset:n}=t;return e&&n?ot(e,n):null}(this.store.getState().dragOffset)}constructor(t,e){this.store=t,this.registry=e}}const ct="undefined"!=typeof global?global:self,ut=ct.MutationObserver||ct.WebKitMutationObserver;function ht(t){return function(){const e=setTimeout(r,0),n=setInterval(r,50);function r(){clearTimeout(e),clearInterval(n),t()}}}const dt="function"==typeof ut?function(t){let e=1;const n=new ut(t),r=document.createTextNode("");return n.observe(r,{characterData:!0}),function(){e=-e,r.data=e}}:ht;class ft{call(){try{this.task&&this.task()}catch(t){this.onError(t)}finally{this.task=null,this.release(this)}}constructor(t,e){this.onError=t,this.release=e,this.task=null}}const pt=new class{enqueueTask(t){const{queue:e,requestFlush:n}=this;e.length||(n(),this.flushing=!0),e[e.length]=t}constructor(){this.queue=[],this.pendingErrors=[],this.flushing=!1,this.index=0,this.capacity=1024,this.flush=()=>{const{queue:t}=this;for(;this.indexthis.capacity){for(let e=0,n=t.length-this.index;e{this.pendingErrors.push(t),this.requestErrorThrow()},this.requestFlush=dt(this.flush),this.requestErrorThrow=ht((()=>{if(this.pendingErrors.length)throw this.pendingErrors.shift()}))}},gt=new class{create(t){const e=this.freeTasks,n=e.length?e.pop():new ft(this.onError,(t=>e[e.length]=t));return n.task=t,n}constructor(t){this.onError=t,this.freeTasks=[]}}(pt.registerPendingError),vt="dnd-core/ADD_SOURCE",mt="dnd-core/ADD_TARGET",yt="dnd-core/REMOVE_SOURCE",bt="dnd-core/REMOVE_TARGET";function wt(t,e){e&&Array.isArray(t)?t.forEach((t=>wt(t,!1))):c("string"==typeof t||"symbol"==typeof t,e?"Type can only be a string, a symbol, or an array of either.":"Type can only be a string or a symbol.")}var xt;!function(t){t.SOURCE="SOURCE",t.TARGET="TARGET"}(xt||(xt={}));let _t=0;function Ct(t){switch(t[0]){case"S":return xt.SOURCE;case"T":return xt.TARGET;default:throw new Error(`Cannot parse handler ID: ${t}`)}}function St(t,e){const n=t.entries();let r=!1;do{const{done:t,value:[,i]}=n.next();if(i===e)return!0;r=!!t}while(!r);return!1}class Dt{addSource(t,e){wt(t),function(t){c("function"==typeof t.canDrag,"Expected canDrag to be a function."),c("function"==typeof t.beginDrag,"Expected beginDrag to be a function."),c("function"==typeof t.endDrag,"Expected endDrag to be a function.")}(e);const n=this.addHandler(xt.SOURCE,t,e);return this.store.dispatch(function(t){return{type:vt,payload:{sourceId:t}}}(n)),n}addTarget(t,e){wt(t,!0),function(t){c("function"==typeof t.canDrop,"Expected canDrop to be a function."),c("function"==typeof t.hover,"Expected hover to be a function."),c("function"==typeof t.drop,"Expected beginDrag to be a function.")}(e);const n=this.addHandler(xt.TARGET,t,e);return this.store.dispatch(function(t){return{type:mt,payload:{targetId:t}}}(n)),n}containsHandler(t){return St(this.dragSources,t)||St(this.dropTargets,t)}getSource(t,e=!1){return c(this.isSourceId(t),"Expected a valid source ID."),e&&t===this.pinnedSourceId?this.pinnedSource:this.dragSources.get(t)}getTarget(t){return c(this.isTargetId(t),"Expected a valid target ID."),this.dropTargets.get(t)}getSourceType(t){return c(this.isSourceId(t),"Expected a valid source ID."),this.types.get(t)}getTargetType(t){return c(this.isTargetId(t),"Expected a valid target ID."),this.types.get(t)}isSourceId(t){return Ct(t)===xt.SOURCE}isTargetId(t){return Ct(t)===xt.TARGET}removeSource(t){var e;c(this.getSource(t),"Expected an existing source."),this.store.dispatch(function(t){return{type:yt,payload:{sourceId:t}}}(t)),e=()=>{this.dragSources.delete(t),this.types.delete(t)},pt.enqueueTask(gt.create(e))}removeTarget(t){c(this.getTarget(t),"Expected an existing target."),this.store.dispatch(function(t){return{type:bt,payload:{targetId:t}}}(t)),this.dropTargets.delete(t),this.types.delete(t)}pinSource(t){const e=this.getSource(t);c(e,"Expected an existing source."),this.pinnedSourceId=t,this.pinnedSource=e}unpinSource(){c(this.pinnedSource,"No source is pinned at the time."),this.pinnedSourceId=null,this.pinnedSource=null}addHandler(t,e,n){const r=function(t){const e=(_t++).toString();switch(t){case xt.SOURCE:return`S${e}`;case xt.TARGET:return`T${e}`;default:throw new Error(`Unknown Handler Role: ${t}`)}}(t);return this.types.set(r,e),t===xt.SOURCE?this.dragSources.set(r,n):t===xt.TARGET&&this.dropTargets.set(r,n),r}constructor(t){this.types=new Map,this.dragSources=new Map,this.dropTargets=new Map,this.pinnedSourceId=null,this.pinnedSource=null,this.store=t}}const Ot=(t,e)=>t===e;function Tt(t=at,e){switch(e.type){case V:break;case vt:case mt:case bt:case yt:return at;default:return st}const{targetIds:n=[],prevTargetIds:r=[]}=e.payload,i=function(t,e){const n=new Map,r=t=>{n.set(t,n.has(t)?n.get(t)+1:1)};t.forEach(r),e.forEach(r);const i=[];return n.forEach(((t,e)=>{1===t&&i.push(e)})),i}(n,r);if(!(i.length>0)&&function(t,e,n=Ot){if(t.length!==e.length)return!1;for(let r=0;rt!==i)))});case G:return jt({},t,{dropResult:n.dropResult,didDrop:!0,targetIds:[]});case q:return jt({},t,{itemType:null,item:null,sourceId:null,dropResult:null,didDrop:!1,isSourcePublic:null,targetIds:[]});default:return t}var r,i}function At(t=0,e){switch(e.type){case vt:case mt:return t+1;case yt:case bt:return t-1;default:return t}}function Rt(t=0){return t+1}function Lt(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Bt(t){for(var e=1;et&&t[e]?t[e]:r||null),n))})}),dragOffset:kt(t.dragOffset,e),refCount:At(t.refCount,e),dragOperation:Pt(t.dragOperation,e),stateId:Rt(t.stateId)};var n,r}function $t(t,e=void 0,n={},r=!1){const i=function(t){const e="undefined"!=typeof window&&window.__REDUX_DEVTOOLS_EXTENSION__;return $(Ht,t&&e&&e({name:"dnd-core",instanceId:"dnd-core"}))}(r),o=new lt(i,new Dt(i)),a=new it(i,o),s=t(a,e,n);return a.receiveBackend(s),a}let zt=0;const Ft=Symbol.for("__REACT_DND_CONTEXT_INSTANCE__");var Ut=(0,h.memo)((function(t){var{children:e}=t,n=function(t,e){if(null==t)return{};var n,r,i=function(t,e){if(null==t)return{};var n,r,i={},o=Object.keys(t);for(r=0;r=0||(i[n]=t[n]);return i}(t,e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}(t,["children"]);const[r,i]=function(t){if("manager"in t)return[{dragDropManager:t.manager},!1];return[function(t,e=Xt(),n,r){const i=e;return i[Ft]||(i[Ft]={dragDropManager:$t(t,e,n,r)}),i[Ft]}(t.backend,t.context,t.options,t.debugMode),!t.context]}(n);return(0,h.useEffect)((()=>{if(i){const t=Xt();return++zt,()=>{0==--zt&&(t[Ft]=null)}}}),[]),(0,A.jsx)(_.Provider,{value:r,children:e})}));function Xt(){return"undefined"!=typeof global?global:window}function Vt(t){let e=null;return()=>(null==e&&(e=t()),e)}class Gt{enter(t){const e=this.entered.length;return this.entered=function(t,e){const n=new Set,r=t=>n.add(t);t.forEach(r),e.forEach(r);const i=[];return n.forEach((t=>i.push(t))),i}(this.entered.filter((e=>this.isNodeInDocument(e)&&(!e.contains||e.contains(t)))),[t]),0===e&&this.entered.length>0}leave(t){const e=this.entered.length;var n,r;return this.entered=(n=this.entered.filter(this.isNodeInDocument),r=t,n.filter((t=>t!==r))),e>0&&0===this.entered.length}reset(){this.entered=[]}constructor(t){this.entered=[],this.isNodeInDocument=t}}class qt{initializeExposedProperties(){Object.keys(this.config.exposeProperties).forEach((t=>{Object.defineProperty(this.item,t,{configurable:!0,enumerable:!0,get:()=>(console.warn(`Browser doesn't allow reading "${t}" until the drop event.`),null)})}))}loadDataTransfer(t){if(t){const e={};Object.keys(this.config.exposeProperties).forEach((n=>{const r=this.config.exposeProperties[n];null!=r&&(e[n]={value:r(t,this.config.matchesTypes),configurable:!0,enumerable:!0})})),Object.defineProperties(this.item,e)}}canDrag(){return!0}beginDrag(){return this.item}isDragging(t,e){return e===t.getSourceId()}endDrag(){}constructor(t){this.config=t,this.item={},this.initializeExposedProperties()}}const Yt="__NATIVE_FILE__",Wt="__NATIVE_URL__",Kt="__NATIVE_TEXT__",Jt="__NATIVE_HTML__";function Zt(t,e,n){const r=e.reduce(((e,n)=>e||t.getData(n)),"");return null!=r?r:n}const Qt={[Yt]:{exposeProperties:{files:t=>Array.prototype.slice.call(t.files),items:t=>t.items,dataTransfer:t=>t},matchesTypes:["Files"]},[Jt]:{exposeProperties:{html:(t,e)=>Zt(t,e,""),dataTransfer:t=>t},matchesTypes:["Html","text/html"]},[Wt]:{exposeProperties:{urls:(t,e)=>Zt(t,e,"").split("\n"),dataTransfer:t=>t},matchesTypes:["Url","text/uri-list"]},[Kt]:{exposeProperties:{text:(t,e)=>Zt(t,e,""),dataTransfer:t=>t},matchesTypes:["Text","text/plain"]}};function te(t){if(!t)return null;const e=Array.prototype.slice.call(t.types||[]);return Object.keys(Qt).filter((t=>{const n=Qt[t];return!!(null==n?void 0:n.matchesTypes)&&n.matchesTypes.some((t=>e.indexOf(t)>-1))}))[0]||null}const ee=Vt((()=>/firefox/i.test(navigator.userAgent))),ne=Vt((()=>Boolean(window.safari)));class re{interpolate(t){const{xs:e,ys:n,c1s:r,c2s:i,c3s:o}=this;let a=e.length-1;if(t===e[a])return n[a];let s,l=0,c=o.length-1;for(;l<=c;){s=Math.floor(.5*(l+c));const r=e[s];if(rt))return n[s];c=s-1}}a=Math.max(0,c);const u=t-e[a],h=u*u;return n[a]+r[a]*u+i[a]*h+o[a]*u*h}constructor(t,e){const{length:n}=t,r=[];for(let t=0;tt[e]{this.sourcePreviewNodes.delete(t),this.sourcePreviewNodeOptions.delete(t)}}connectDragSource(t,e,n){this.sourceNodes.set(t,e),this.sourceNodeOptions.set(t,n);const r=e=>this.handleDragStart(e,t),i=t=>this.handleSelectStart(t);return e.setAttribute("draggable","true"),e.addEventListener("dragstart",r),e.addEventListener("selectstart",i),()=>{this.sourceNodes.delete(t),this.sourceNodeOptions.delete(t),e.removeEventListener("dragstart",r),e.removeEventListener("selectstart",i),e.setAttribute("draggable","false")}}connectDropTarget(t,e){const n=e=>this.handleDragEnter(e,t),r=e=>this.handleDragOver(e,t),i=e=>this.handleDrop(e,t);return e.addEventListener("dragenter",n),e.addEventListener("dragover",r),e.addEventListener("drop",i),()=>{e.removeEventListener("dragenter",n),e.removeEventListener("dragover",r),e.removeEventListener("drop",i)}}addEventListeners(t){t.addEventListener&&(t.addEventListener("dragstart",this.handleTopDragStart),t.addEventListener("dragstart",this.handleTopDragStartCapture,!0),t.addEventListener("dragend",this.handleTopDragEndCapture,!0),t.addEventListener("dragenter",this.handleTopDragEnter),t.addEventListener("dragenter",this.handleTopDragEnterCapture,!0),t.addEventListener("dragleave",this.handleTopDragLeaveCapture,!0),t.addEventListener("dragover",this.handleTopDragOver),t.addEventListener("dragover",this.handleTopDragOverCapture,!0),t.addEventListener("drop",this.handleTopDrop),t.addEventListener("drop",this.handleTopDropCapture,!0))}removeEventListeners(t){t.removeEventListener&&(t.removeEventListener("dragstart",this.handleTopDragStart),t.removeEventListener("dragstart",this.handleTopDragStartCapture,!0),t.removeEventListener("dragend",this.handleTopDragEndCapture,!0),t.removeEventListener("dragenter",this.handleTopDragEnter),t.removeEventListener("dragenter",this.handleTopDragEnterCapture,!0),t.removeEventListener("dragleave",this.handleTopDragLeaveCapture,!0),t.removeEventListener("dragover",this.handleTopDragOver),t.removeEventListener("dragover",this.handleTopDragOverCapture,!0),t.removeEventListener("drop",this.handleTopDrop),t.removeEventListener("drop",this.handleTopDropCapture,!0))}getCurrentSourceNodeOptions(){const t=this.monitor.getSourceId(),e=this.sourceNodeOptions.get(t);return le({dropEffect:this.altKeyPressed?"copy":"move"},e||{})}getCurrentDropEffect(){return this.isDraggingNativeItem()?"copy":this.getCurrentSourceNodeOptions().dropEffect}getCurrentSourcePreviewNodeOptions(){const t=this.monitor.getSourceId();return le({anchorX:.5,anchorY:.5,captureDraggingState:!1},this.sourcePreviewNodeOptions.get(t)||{})}isDraggingNativeItem(){const t=this.monitor.getItemType();return Object.keys(r).some((e=>r[e]===t))}beginDragNativeItem(t,e){this.clearCurrentDragSourceNode(),this.currentNativeSource=function(t,e){const n=Qt[t];if(!n)throw new Error(`native type ${t} has no configuration`);const r=new qt(n);return r.loadDataTransfer(e),r}(t,e),this.currentNativeHandle=this.registry.addSource(t,this.currentNativeSource),this.actions.beginDrag([this.currentNativeHandle])}setCurrentDragSourceNode(t){this.clearCurrentDragSourceNode(),this.currentDragSourceNode=t,this.mouseMoveTimeoutTimer=setTimeout((()=>{var t;return null===(t=this.rootElement)||void 0===t?void 0:t.addEventListener("mousemove",this.endDragIfSourceWasRemovedFromDOM,!0)}),1e3)}clearCurrentDragSourceNode(){var t;return!!this.currentDragSourceNode&&(this.currentDragSourceNode=null,this.rootElement&&(null===(t=this.window)||void 0===t||t.clearTimeout(this.mouseMoveTimeoutTimer||void 0),this.rootElement.removeEventListener("mousemove",this.endDragIfSourceWasRemovedFromDOM,!0)),this.mouseMoveTimeoutTimer=null,!0)}handleDragStart(t,e){t.defaultPrevented||(this.dragStartSourceIds||(this.dragStartSourceIds=[]),this.dragStartSourceIds.unshift(e))}handleDragEnter(t,e){this.dragEnterTargetIds.unshift(e)}handleDragOver(t,e){null===this.dragOverTargetIds&&(this.dragOverTargetIds=[]),this.dragOverTargetIds.unshift(e)}handleDrop(t,e){this.dropTargetIds.unshift(e)}constructor(t,e,n){this.sourcePreviewNodes=new Map,this.sourcePreviewNodeOptions=new Map,this.sourceNodes=new Map,this.sourceNodeOptions=new Map,this.dragStartSourceIds=null,this.dropTargetIds=[],this.dragEnterTargetIds=[],this.currentNativeSource=null,this.currentNativeHandle=null,this.currentDragSourceNode=null,this.altKeyPressed=!1,this.mouseMoveTimeoutTimer=null,this.asyncEndDragFrameId=null,this.dragOverTargetIds=null,this.lastClientOffset=null,this.hoverRafId=null,this.getSourceClientOffset=t=>{const e=this.sourceNodes.get(t);return e&&ie(e)||null},this.endDragNativeItem=()=>{this.isDraggingNativeItem()&&(this.actions.endDrag(),this.currentNativeHandle&&this.registry.removeSource(this.currentNativeHandle),this.currentNativeHandle=null,this.currentNativeSource=null)},this.isNodeInDocument=t=>Boolean(t&&this.document&&this.document.body&&this.document.body.contains(t)),this.endDragIfSourceWasRemovedFromDOM=()=>{const t=this.currentDragSourceNode;null==t||this.isNodeInDocument(t)||(this.clearCurrentDragSourceNode()&&this.monitor.isDragging()&&this.actions.endDrag(),this.cancelHover())},this.scheduleHover=t=>{null===this.hoverRafId&&"undefined"!=typeof requestAnimationFrame&&(this.hoverRafId=requestAnimationFrame((()=>{this.monitor.isDragging()&&this.actions.hover(t||[],{clientOffset:this.lastClientOffset}),this.hoverRafId=null})))},this.cancelHover=()=>{null!==this.hoverRafId&&"undefined"!=typeof cancelAnimationFrame&&(cancelAnimationFrame(this.hoverRafId),this.hoverRafId=null)},this.handleTopDragStartCapture=()=>{this.clearCurrentDragSourceNode(),this.dragStartSourceIds=[]},this.handleTopDragStart=t=>{if(t.defaultPrevented)return;const{dragStartSourceIds:e}=this;this.dragStartSourceIds=null;const n=oe(t);this.monitor.isDragging()&&(this.actions.endDrag(),this.cancelHover()),this.actions.beginDrag(e||[],{publishSource:!1,getSourceClientOffset:this.getSourceClientOffset,clientOffset:n});const{dataTransfer:r}=t,i=te(r);if(this.monitor.isDragging()){if(r&&"function"==typeof r.setDragImage){const t=this.monitor.getSourceId(),e=this.sourceNodes.get(t),i=this.sourcePreviewNodes.get(t)||e;if(i){const{anchorX:t,anchorY:o,offsetX:a,offsetY:s}=this.getCurrentSourcePreviewNodeOptions(),l=function(t,e,n,r,i){const o="IMG"===(m=e).nodeName&&(ee()||!(null===(y=document.documentElement)||void 0===y?void 0:y.contains(m))),a=ie(o?t:e),s={x:n.x-a.x,y:n.y-a.y},{offsetWidth:l,offsetHeight:c}=t,{anchorX:u,anchorY:h}=r,{dragPreviewWidth:d,dragPreviewHeight:f}=function(t,e,n,r){let i=t?e.width:n,o=t?e.height:r;return ne()&&t&&(o/=window.devicePixelRatio,i/=window.devicePixelRatio),{dragPreviewWidth:i,dragPreviewHeight:o}}(o,e,l,c),{offsetX:p,offsetY:g}=i,v=0===g||g;var m,y;return{x:0===p||p?p:new re([0,.5,1],[s.x,s.x/l*d,s.x+d-l]).interpolate(u),y:v?g:(()=>{let t=new re([0,.5,1],[s.y,s.y/c*f,s.y+f-c]).interpolate(h);return ne()&&o&&(t+=(window.devicePixelRatio-1)*f),t})()}}(e,i,n,{anchorX:t,anchorY:o},{offsetX:a,offsetY:s});r.setDragImage(i,l.x,l.y)}}try{null==r||r.setData("application/json",{})}catch(t){}this.setCurrentDragSourceNode(t.target);const{captureDraggingState:e}=this.getCurrentSourcePreviewNodeOptions();e?this.actions.publishDragSource():setTimeout((()=>this.actions.publishDragSource()),0)}else if(i)this.beginDragNativeItem(i);else{if(r&&!r.types&&(t.target&&!t.target.hasAttribute||!t.target.hasAttribute("draggable")))return;t.preventDefault()}},this.handleTopDragEndCapture=()=>{this.clearCurrentDragSourceNode()&&this.monitor.isDragging()&&this.actions.endDrag(),this.cancelHover()},this.handleTopDragEnterCapture=t=>{var e;if(this.dragEnterTargetIds=[],this.isDraggingNativeItem()&&(null===(e=this.currentNativeSource)||void 0===e||e.loadDataTransfer(t.dataTransfer)),!this.enterLeaveCounter.enter(t.target)||this.monitor.isDragging())return;const{dataTransfer:n}=t,r=te(n);r&&this.beginDragNativeItem(r,n)},this.handleTopDragEnter=t=>{const{dragEnterTargetIds:e}=this;this.dragEnterTargetIds=[],this.monitor.isDragging()&&(this.altKeyPressed=t.altKey,e.length>0&&this.actions.hover(e,{clientOffset:oe(t)}),e.some((t=>this.monitor.canDropOnTarget(t)))&&(t.preventDefault(),t.dataTransfer&&(t.dataTransfer.dropEffect=this.getCurrentDropEffect())))},this.handleTopDragOverCapture=t=>{var e;this.dragOverTargetIds=[],this.isDraggingNativeItem()&&(null===(e=this.currentNativeSource)||void 0===e||e.loadDataTransfer(t.dataTransfer))},this.handleTopDragOver=t=>{const{dragOverTargetIds:e}=this;if(this.dragOverTargetIds=[],!this.monitor.isDragging())return t.preventDefault(),void(t.dataTransfer&&(t.dataTransfer.dropEffect="none"));this.altKeyPressed=t.altKey,this.lastClientOffset=oe(t),this.scheduleHover(e),(e||[]).some((t=>this.monitor.canDropOnTarget(t)))?(t.preventDefault(),t.dataTransfer&&(t.dataTransfer.dropEffect=this.getCurrentDropEffect())):this.isDraggingNativeItem()?t.preventDefault():(t.preventDefault(),t.dataTransfer&&(t.dataTransfer.dropEffect="none"))},this.handleTopDragLeaveCapture=t=>{this.isDraggingNativeItem()&&t.preventDefault(),this.enterLeaveCounter.leave(t.target)&&(this.isDraggingNativeItem()&&setTimeout((()=>this.endDragNativeItem()),0),this.cancelHover())},this.handleTopDropCapture=t=>{var e;this.dropTargetIds=[],this.isDraggingNativeItem()?(t.preventDefault(),null===(e=this.currentNativeSource)||void 0===e||e.loadDataTransfer(t.dataTransfer)):te(t.dataTransfer)&&t.preventDefault(),this.enterLeaveCounter.reset()},this.handleTopDrop=t=>{const{dropTargetIds:e}=this;this.dropTargetIds=[],this.actions.hover(e,{clientOffset:oe(t)}),this.actions.drop({dropEffect:this.getCurrentDropEffect()}),this.isDraggingNativeItem()?this.endDragNativeItem():this.monitor.isDragging()&&this.actions.endDrag(),this.cancelHover()},this.handleSelectStart=t=>{const e=t.target;"function"==typeof e.dragDrop&&("INPUT"===e.tagName||"SELECT"===e.tagName||"TEXTAREA"===e.tagName||e.isContentEditable||(t.preventDefault(),e.dragDrop()))},this.options=new ae(e,n),this.actions=t.getActions(),this.monitor=t.getMonitor(),this.registry=t.getRegistry(),this.enterLeaveCounter=new Gt(this.isNodeInDocument)}}const ue=function(t,e,n){return new ce(t,e,n)},he=window.wp.apiFetch;var de=n.n(he);const fe="dataset_item",pe=({item:t,datasetKey:e,moveItem:n,updateItem:r,items:i,onDelete:a})=>{const[c,u]=(0,l.useState)(!1),[h,d]=(0,l.useState)(!1),f=(0,l.useRef)(null),[{isDragging:p},g]=E({type:fe,item:{id:t.id,datasetKey:e},collect:t=>({isDragging:t.isDragging()})}),[{isOver:v},m]=P({accept:fe,hover(e,r){if(!f.current)return;if(e.id===t.id)return;const i=f.current.getBoundingClientRect(),o=(i.bottom-i.top)/2,a=(i.right-i.left)/2,s=r.getClientOffset();if(!s)return;const l=s.y-i.top,c=s.x-i.left>a&&l>o;n(e.id,t.id,c)},collect:t=>({isOver:t.isOver()})});g(m(f));const y=i.filter((e=>e.parent===t.id)),b={marginLeft:20*(t=>{let e=0,n=i.find((e=>e.id===t));for(;n&&n.parent;)e++,n=i.find((t=>t.id===n.parent));return e})(t.id)+"px",opacity:p?.5:1,cursor:"move",background:v?"#f0f0f0":"white",border:v?"2px dashed #0073aa":"1px solid #e2e4e7",marginBottom:"8px",transition:"all 0.2s ease"};return(0,A.jsxs)("div",{children:[(0,A.jsx)("div",{ref:f,style:b,children:(0,A.jsx)(s.Card,{children:(0,A.jsx)(s.CardBody,{children:(0,A.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"10px"},children:[(0,A.jsx)(s.TextControl,{placeholder:(0,o.__)("Label","lcp"),value:t.label,onChange:n=>r(e,t.id,"label",n),style:{flex:2}}),(0,A.jsx)(s.TextControl,{type:"number",placeholder:(0,o.__)("Value","lcp"),value:t.value,onChange:n=>r(e,t.id,"value",parseFloat(n)),style:{flex:1}}),(0,A.jsxs)("div",{style:{position:"relative"},children:[(0,A.jsx)(s.Button,{onClick:()=>u(!0),style:{backgroundColor:t.color,width:"30px",height:"30px",borderRadius:"50%",padding:0,border:"1px solid #ddd"}}),c&&(0,A.jsx)(s.Popover,{onClose:()=>u(!1),position:"bottom center",children:(0,A.jsx)("div",{style:{padding:"10px"},children:(0,A.jsx)(s.ColorPicker,{color:t.color,onChange:n=>r(e,t.id,"color",n),enableAlpha:!1})})})]}),(0,A.jsx)(s.Button,{variant:"secondary",isSmall:!0,onClick:()=>d(!0),children:(0,o.__)("HTML","lcp-data-blocks")}),(0,A.jsx)(s.Button,{variant:"secondary",isDestructive:!0,isSmall:!0,onClick:()=>{window.confirm((0,o.__)("Are you sure you want to delete this item?","lcp"))&&a(t.id)},children:(0,o.__)("Delete","lcp")})]})})})}),h&&(0,A.jsx)(s.Modal,{title:(0,o.__)("Edit HTML Content","lcp-data-blocks"),onRequestClose:()=>d(!1),children:(0,A.jsx)("div",{style:{padding:"20px"},children:(0,A.jsx)(s.TextareaControl,{value:t.popoverHtml||"",onChange:n=>{r(e,t.id,"popoverHtml",n)},rows:10,style:{width:"100%",minHeight:"200px",fontFamily:"monospace"}})})}),y.map((t=>(0,A.jsx)(pe,{item:t,datasetKey:e,moveItem:n,updateItem:r,items:i,onDelete:a},t.id)))]})},ge=({value:t,onChange:e})=>{const[n,r]=(0,l.useState)(!1),[i,a]=(0,l.useState)(t||{}),[c,u]=(0,l.useState)(!1),[h,d]=(0,l.useState)(null),f=(t,n)=>{if(t===n||!n.trim()||i[n])return void d(null);const r={...i};r[n]=r[t],delete r[t],a(r),e(r),d(null)},p=(t,n,r,o)=>{const s={...i,[t]:i[t].map((t=>t.id===n?{...t,[r]:o}:t))};a(s),e(s)},g=(t,n,r)=>{const o=Object.keys(i).find((e=>i[e].some((e=>e.id===t))));if(!o)return;const s=[...i[o]],l=s.find((e=>e.id===t)),c=s.find((t=>t.id===n));if(!l||!c)return;let u=c;for(;u.parent;){if(u.parent===t)return;u=s.find((t=>t.id===u.parent))}l.parent=r?n:c.parent;const h={...i,[o]:s};a(h),e(h)};return(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(s.Button,{variant:"primary",onClick:()=>r(!0),children:(0,o.__)("Open Dataset Builder","lcp")}),n&&(0,A.jsx)(s.Modal,{title:(0,o.__)("Dataset Builder","lcp"),onRequestClose:()=>r(!1),style:{width:"100%",maxWidth:"800px"},children:(0,A.jsx)(Ut,{backend:ue,children:(0,A.jsxs)("div",{style:{padding:"20px"},children:[Object.entries(i).map((([t,n])=>(0,A.jsxs)("div",{style:{marginBottom:"20px"},children:[(0,A.jsx)("div",{style:{display:"flex",alignItems:"center",gap:"10px",marginBottom:"10px"},children:h===t?(0,A.jsx)(s.TextControl,{value:t,onChange:e=>f(t,e),onKeyDown:e=>{"Enter"===e.key?f(t,e.target.value):"Escape"===e.key&&d(null)},autoFocus:!0}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)("h3",{style:{margin:0},children:t}),(0,A.jsx)(s.Button,{variant:"secondary",isSmall:!0,onClick:()=>d(t),children:(0,o.__)("Rename","lcp")}),(0,A.jsx)(s.Button,{variant:"secondary",isDestructive:!0,isSmall:!0,onClick:()=>{window.confirm((0,o.__)("Are you sure you want to delete this dataset?","lcp"))&&(t=>{const n={...i};delete n[t],a(n),e(n)})(t)},children:(0,o.__)("Delete","lcp")})]})}),(0,A.jsx)("div",{children:n.filter((t=>!t.parent)).map((r=>(0,A.jsx)(pe,{datasetKey:t,item:r,items:n,moveItem:g,updateItem:p,onDelete:n=>((t,n)=>{const r={...i};var o,s;r[t]=(o=r[t],s=n,o.filter((t=>t.id!==s&&t.parent!==s))),a(r),e(r)})(t,n)},r.id)))}),(0,A.jsx)(s.Button,{variant:"secondary",onClick:()=>(t=>{const n={id:`item-${Date.now()}`,label:"New Item",parent:null,value:0,color:"#000000"},r={...i,[t]:[...i[t],n]};a(r),e(r)})(t),style:{marginTop:"10px"},children:(0,o.__)("Add Item","lcp")})]},t))),(0,A.jsxs)("div",{style:{display:"flex",gap:"10px",marginTop:"20px"},children:[(0,A.jsx)(s.Button,{variant:"primary",onClick:()=>{const t="New Dataset";let n=t,r=1;for(;i[n];)n=`${t} ${r}`,r++;const o={...i,[n]:[{id:`dataset-${Date.now()}`,label:"New Item",parent:null,value:0,color:"#000000"}]};a(o),e(o),d(n)},children:(0,o.__)("Add New Dataset","lcp")}),(0,A.jsx)(s.Button,{variant:"secondary",onClick:async()=>{try{u(!0),console.log("Chart data:",i);const t=Object.entries(i).map((([t,e])=>({dataset_name:t,dataset_source:"json",dataset_json:e})));console.log("Formatted datasets:",t);const e=await de()({path:"/wp/v2/lcp-data-collection",method:"POST",data:{title:Object.keys(i)[0]||"Dataset Collection",status:"publish",meta:{lcp_datasets:t}}});console.log("Post created:",e),console.log("Meta data in response:",e.meta);const n=await de()({path:`/wp/v2/lcp-data-collection/${e.id}`,method:"GET"});console.log("Saved post data:",n),console.log("Saved meta data:",n.meta?.lcp_datasets)}catch(t){console.error("Error saving dataset:",t),console.log("Error details:",{message:t.message,code:t.code,data:t.data})}finally{u(!1)}},disabled:c,children:c?(0,o.__)("Saving...","lcp"):(0,o.__)("Save to Collection","lcp")})]})]})})})]})},ve=["#FF6384","#36A2EB","#FFCE56","#4BC0C0","#9966FF","#FF9F40","#FF6384","#C9CBCF","#4BC0C0","#FF9F40"],me=({value:t,onChange:e,dataSource:n,onDataSourceChange:r})=>{const[i,c]=(0,l.useState)(""),[u,h]=(0,l.useState)(""),[d,f]=(0,l.useState)("");(0,l.useEffect)((()=>{if(t&&Object.keys(t).length>0)if("manual_json"===n)h(JSON.stringify(t,null,2));else if("csv_url"===n){const e=t[Object.keys(t)[0]]?.[0]?.sourceUrl;e&&c(e)}}),[]);const p=[{label:(0,o.__)("Manual JSON","lcp"),value:"manual_json"},{label:(0,o.__)("CSV Upload","lcp"),value:"csv_upload"},{label:(0,o.__)("CSV URL","lcp"),value:"csv_url"},{label:(0,o.__)("Dataset Builder","lcp"),value:"dataset_builder"}],g=(t,e="")=>{try{const n=t.split("\n");if(n.length<2)throw new Error("CSV must have at least a header row and one data row");const r=n[0].split(",").map((t=>t.trim()));if(!r.includes("label")||!r.includes("value"))throw new Error('CSV must have "label" and "value" columns');const i={"Dataset 1":n.slice(1).filter((t=>t.trim())).map(((t,n)=>{const i=t.split(",").map((t=>t.trim())),o={};return r.forEach(((t,e)=>{"color"!==t||i[e]?o[t]=i[e]:o[t]=ve[n%ve.length]})),e&&(o.sourceUrl=e),o}))};return f(""),i}catch(t){return f("Error parsing CSV: "+t.message),null}};return(0,A.jsxs)("div",{className:"lcp-data-selector",children:[(0,A.jsx)(s.SelectControl,{label:(0,o.__)("Data Source","lcp"),value:n,options:p,onChange:r}),"dataset_builder"===n&&(0,A.jsx)(ge,{value:t,onChange:t=>{e(t)}}),"manual_json"===n&&(0,A.jsx)(s.TextareaControl,{label:(0,o.__)("JSON Data","lcp"),help:(0,o.__)("Enter datasets with arrays containing objects with label and value properties. Color is optional.","lcp"),value:u,onChange:t=>{h(t);const n=(t=>{try{const e=JSON.parse(t);if("object"!=typeof e||Array.isArray(e))throw new Error("Data must be an object with dataset names as keys");return Object.entries(e).forEach((([t,e])=>{if(!Array.isArray(e))throw new Error(`Dataset "${t}" must be an array`);e.forEach(((e,n)=>{if(!e.label||!e.value)throw new Error(`Item at index ${n} in dataset "${t}" is missing required fields (label or value)`);e.color||(e.color=ve[n%ve.length])}))})),f(""),e}catch(t){return f(t.message),null}})(t);n&&e(n)},placeholder:'{\n "Dataset 1": [\n {\n "label": "Label 1",\n "value": 100,\n "color": "red"\n },\n {\n "label": "Label 2",\n "value": 200\n }\n ],\n "Dataset 2": [\n {\n "label": "Label 3",\n "value": 300,\n "color": "green"\n }\n ]\n}'}),"csv_upload"===n&&(0,A.jsx)(a.MediaUploadCheck,{children:(0,A.jsx)(a.MediaUpload,{onSelect:t=>{const n=t.url;fetch(t.url).then((t=>t.text())).then((t=>{const r=g(t,n);r&&e(r)})).catch((t=>{f("Error reading CSV file: "+t.message)}))},allowedTypes:["text/csv"],render:({open:e})=>(0,A.jsxs)("div",{children:[(0,A.jsx)(s.Button,{onClick:e,isPrimary:!0,children:(0,o.__)("Upload CSV File","lcp")}),t&&Object.keys(t).length>0&&t[Object.keys(t)[0]]?.[0]?.sourceUrl&&(0,A.jsxs)("div",{className:"current-file",style:{marginTop:"10px"},children:[(0,o.__)("Current file:","lcp")," ",t[Object.keys(t)[0]][0].sourceUrl.split("/").pop()]})]})})}),"csv_url"===n&&(0,A.jsx)(s.TextControl,{label:(0,o.__)("CSV URL","lcp"),value:i,onChange:t=>{c(t),t&&fetch(t).then((t=>t.text())).then((n=>{const r=g(n,t);r&&e(r)})).catch((t=>{f("Error fetching CSV file: "+t.message)}))},help:(0,o.__)("Enter URL of a CSV file with label and value columns. Color column is optional.","lcp")}),d&&(0,A.jsx)("div",{className:"lcp-data-selector-error",style:{color:"red",marginTop:"10px"},children:d}),t&&Object.keys(t).length>0&&(0,A.jsxs)("div",{className:"data-preview",style:{marginTop:"15px"},children:[(0,A.jsx)("h4",{children:(0,o.__)("Current Data Preview:","lcp")}),(0,A.jsx)("div",{style:{fontSize:"12px",color:"#666"},children:Object.entries(t).map((([t,e])=>(0,A.jsxs)("div",{children:[t,": ",e.length," ",(0,o.__)("data points","lcp")]},t)))})]})]})};function ye(t){return t}var be=1e-6;function we(t){return"translate("+t+",0)"}function xe(t){return"translate(0,"+t+")"}function _e(t){return e=>+t(e)}function Ce(t,e){return e=Math.max(0,t.bandwidth()-2*e)/2,t.round()&&(e=Math.round(e)),n=>+t(n)+e}function Se(){return!this.__axis}function De(t,e){var n=[],r=null,i=null,o=6,a=6,s=3,l="undefined"!=typeof window&&window.devicePixelRatio>1?0:.5,c=1===t||4===t?-1:1,u=4===t||2===t?"x":"y",h=1===t||3===t?we:xe;function d(d){var f=null==r?e.ticks?e.ticks.apply(e,n):e.domain():r,p=null==i?e.tickFormat?e.tickFormat.apply(e,n):ye:i,g=Math.max(o,0)+s,v=e.range(),m=+v[0]+l,y=+v[v.length-1]+l,b=(e.bandwidth?Ce:_e)(e.copy(),l),w=d.selection?d.selection():d,x=w.selectAll(".domain").data([null]),_=w.selectAll(".tick").data(f,e).order(),C=_.exit(),S=_.enter().append("g").attr("class","tick"),D=_.select("line"),O=_.select("text");x=x.merge(x.enter().insert("path",".tick").attr("class","domain").attr("stroke","currentColor")),_=_.merge(S),D=D.merge(S.append("line").attr("stroke","currentColor").attr(u+"2",c*o)),O=O.merge(S.append("text").attr("fill","currentColor").attr(u,c*g).attr("dy",1===t?"0em":3===t?"0.71em":"0.32em")),d!==w&&(x=x.transition(d),_=_.transition(d),D=D.transition(d),O=O.transition(d),C=C.transition(d).attr("opacity",be).attr("transform",(function(t){return isFinite(t=b(t))?h(t+l):this.getAttribute("transform")})),S.attr("opacity",be).attr("transform",(function(t){var e=this.parentNode.__axis;return h((e&&isFinite(e=e(t))?e:b(t))+l)}))),C.remove(),x.attr("d",4===t||2===t?a?"M"+c*a+","+m+"H"+l+"V"+y+"H"+c*a:"M"+l+","+m+"V"+y:a?"M"+m+","+c*a+"V"+l+"H"+y+"V"+c*a:"M"+m+","+l+"H"+y),_.attr("opacity",1).attr("transform",(function(t){return h(b(t)+l)})),D.attr(u+"2",c*o),O.attr(u,c*g).text(p),w.filter(Se).attr("fill","none").attr("font-size",10).attr("font-family","sans-serif").attr("text-anchor",2===t?"start":4===t?"end":"middle"),w.each((function(){this.__axis=b}))}return d.scale=function(t){return arguments.length?(e=t,d):e},d.ticks=function(){return n=Array.from(arguments),d},d.tickArguments=function(t){return arguments.length?(n=null==t?[]:Array.from(t),d):n.slice()},d.tickValues=function(t){return arguments.length?(r=null==t?null:Array.from(t),d):r&&r.slice()},d.tickFormat=function(t){return arguments.length?(i=t,d):i},d.tickSize=function(t){return arguments.length?(o=a=+t,d):o},d.tickSizeInner=function(t){return arguments.length?(o=+t,d):o},d.tickSizeOuter=function(t){return arguments.length?(a=+t,d):a},d.tickPadding=function(t){return arguments.length?(s=+t,d):s},d.offset=function(t){return arguments.length?(l=+t,d):l},d}function Oe(t){return De(3,t)}function Te(t){return De(4,t)}function Ee(){}function Ie(t){return null==t?Ee:function(){return this.querySelector(t)}}function ke(){return[]}function Me(t){return null==t?ke:function(){return this.querySelectorAll(t)}}function je(t){return function(){return this.matches(t)}}function Ne(t){return function(e){return e.matches(t)}}var Pe=Array.prototype.find;function Ae(){return this.firstElementChild}var Re=Array.prototype.filter;function Le(){return Array.from(this.children)}function Be(t){return new Array(t.length)}function He(t,e){this.ownerDocument=t.ownerDocument,this.namespaceURI=t.namespaceURI,this._next=null,this._parent=t,this.__data__=e}function $e(t,e,n,r,i,o){for(var a,s=0,l=e.length,c=o.length;se?1:t>=e?0:NaN}He.prototype={constructor:He,appendChild:function(t){return this._parent.insertBefore(t,this._next)},insertBefore:function(t,e){return this._parent.insertBefore(t,e)},querySelector:function(t){return this._parent.querySelector(t)},querySelectorAll:function(t){return this._parent.querySelectorAll(t)}};var Ve="http://www.w3.org/1999/xhtml";const Ge={svg:"http://www.w3.org/2000/svg",xhtml:Ve,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function qe(t){var e=t+="",n=e.indexOf(":");return n>=0&&"xmlns"!==(e=t.slice(0,n))&&(t=t.slice(n+1)),Ge.hasOwnProperty(e)?{space:Ge[e],local:t}:t}function Ye(t){return function(){this.removeAttribute(t)}}function We(t){return function(){this.removeAttributeNS(t.space,t.local)}}function Ke(t,e){return function(){this.setAttribute(t,e)}}function Je(t,e){return function(){this.setAttributeNS(t.space,t.local,e)}}function Ze(t,e){return function(){var n=e.apply(this,arguments);null==n?this.removeAttribute(t):this.setAttribute(t,n)}}function Qe(t,e){return function(){var n=e.apply(this,arguments);null==n?this.removeAttributeNS(t.space,t.local):this.setAttributeNS(t.space,t.local,n)}}function tn(t){return t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView}function en(t){return function(){this.style.removeProperty(t)}}function nn(t,e,n){return function(){this.style.setProperty(t,e,n)}}function rn(t,e,n){return function(){var r=e.apply(this,arguments);null==r?this.style.removeProperty(t):this.style.setProperty(t,r,n)}}function on(t,e){return t.style.getPropertyValue(e)||tn(t).getComputedStyle(t,null).getPropertyValue(e)}function an(t){return function(){delete this[t]}}function sn(t,e){return function(){this[t]=e}}function ln(t,e){return function(){var n=e.apply(this,arguments);null==n?delete this[t]:this[t]=n}}function cn(t){return t.trim().split(/^|\s+/)}function un(t){return t.classList||new hn(t)}function hn(t){this._node=t,this._names=cn(t.getAttribute("class")||"")}function dn(t,e){for(var n=un(t),r=-1,i=e.length;++r=0&&(this._names.splice(e,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(t){return this._names.indexOf(t)>=0}};var Bn=[null];function Hn(t,e){this._groups=t,this._parents=e}function $n(){return new Hn([[document.documentElement]],Bn)}Hn.prototype=$n.prototype={constructor:Hn,select:function(t){"function"!=typeof t&&(t=Ie(t));for(var e=this._groups,n=e.length,r=new Array(n),i=0;i=x&&(x=w+1);!(b=m[x])&&++x=0;)(r=i[o])&&(a&&4^r.compareDocumentPosition(a)&&a.parentNode.insertBefore(r,a),a=r);return this},sort:function(t){function e(e,n){return e&&n?t(e.__data__,n.__data__):!e-!n}t||(t=Xe);for(var n=this._groups,r=n.length,i=new Array(r),o=0;o1?this.each((null==e?en:"function"==typeof e?rn:nn)(t,e,null==n?"":n)):on(this.node(),t)},property:function(t,e){return arguments.length>1?this.each((null==e?an:"function"==typeof e?ln:sn)(t,e)):this.node()[t]},classed:function(t,e){var n=cn(t+"");if(arguments.length<2){for(var r=un(this.node()),i=-1,o=n.length;++i=0&&(e=t.slice(n+1),t=t.slice(0,n)),{type:t,name:e}}))}(t+""),a=o.length;if(!(arguments.length<2)){for(s=e?Pn:Nn,r=0;r{}};function Un(){for(var t,e=0,n=arguments.length,r={};e=0&&(e=t.slice(n+1),t=t.slice(0,n)),t&&!r.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:e}}))),a=-1,s=o.length;if(!(arguments.length<2)){if(null!=e&&"function"!=typeof e)throw new Error("invalid callback: "+e);for(;++a0)for(var n,r,i=new Array(n),o=0;o=0&&e._call.call(void 0,t),e=e._next;--Kn}()}finally{Kn=0,function(){for(var t,e,n=Yn,r=1/0;n;)n._call?(r>n._time&&(r=n._time),t=n,n=n._next):(e=n._next,n._next=null,n=t?t._next=e:Yn=e);Wn=t,ur(r)}(),tr=0}}function cr(){var t=nr.now(),e=t-Qn;e>1e3&&(er-=e,Qn=t)}function ur(t){Kn||(Jn&&(Jn=clearTimeout(Jn)),t-tr>24?(t<1/0&&(Jn=setTimeout(lr,t-nr.now()-er)),Zn&&(Zn=clearInterval(Zn))):(Zn||(Qn=nr.now(),Zn=setInterval(cr,1e3)),Kn=1,rr(lr)))}function hr(t,e,n){var r=new ar;return e=null==e?0:+e,r.restart((n=>{r.stop(),t(n+e)}),e,n),r}ar.prototype=sr.prototype={constructor:ar,restart:function(t,e,n){if("function"!=typeof t)throw new TypeError("callback is not a function");n=(null==n?ir():+n)+(null==e?0:+e),this._next||Wn===this||(Wn?Wn._next=this:Yn=this,Wn=this),this._call=t,this._time=n,ur()},stop:function(){this._call&&(this._call=null,this._time=1/0,ur())}};var dr=qn("start","end","cancel","interrupt"),fr=[];function pr(t,e,n,r,i,o){var a=t.__transition;if(a){if(n in a)return}else t.__transition={};!function(t,e,n){var r,i=t.__transition;function o(l){var c,u,h,d;if(1!==n.state)return s();for(c in i)if((d=i[c]).name===n.name){if(3===d.state)return hr(o);4===d.state?(d.state=6,d.timer.stop(),d.on.call("interrupt",t,t.__data__,d.index,d.group),delete i[c]):+c0)throw new Error("too late; already scheduled");return n}function vr(t,e){var n=mr(t,e);if(n.state>3)throw new Error("too late; already running");return n}function mr(t,e){var n=t.__transition;if(!n||!(n=n[e]))throw new Error("transition not found");return n}function yr(t,e){var n,r,i,o=t.__transition,a=!0;if(o){for(i in e=null==e?null:e+"",o)(n=o[i]).name===e?(r=n.state>2&&n.state<5,n.state=6,n.timer.stop(),n.on.call(r?"interrupt":"cancel",t,t.__data__,n.index,n.group),delete o[i]):a=!1;a&&delete t.__transition}}function br(t,e){return t=+t,e=+e,function(n){return t*(1-n)+e*n}}var wr,xr=180/Math.PI,_r={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Cr(t,e,n,r,i,o){var a,s,l;return(a=Math.sqrt(t*t+e*e))&&(t/=a,e/=a),(l=t*n+e*r)&&(n-=t*l,r-=e*l),(s=Math.sqrt(n*n+r*r))&&(n/=s,r/=s,l/=s),t*r180?e+=360:e-t>180&&(t+=360),o.push({i:n.push(i(n)+"rotate(",null,r)-2,x:br(t,e)})):e&&n.push(i(n)+"rotate("+e+r)}(o.rotate,a.rotate,s,l),function(t,e,n,o){t!==e?o.push({i:n.push(i(n)+"skewX(",null,r)-2,x:br(t,e)}):e&&n.push(i(n)+"skewX("+e+r)}(o.skewX,a.skewX,s,l),function(t,e,n,r,o,a){if(t!==n||e!==r){var s=o.push(i(o)+"scale(",null,",",null,")");a.push({i:s-4,x:br(t,n)},{i:s-2,x:br(e,r)})}else 1===n&&1===r||o.push(i(o)+"scale("+n+","+r+")")}(o.scaleX,o.scaleY,a.scaleX,a.scaleY,s,l),o=a=null,function(t){for(var e,n=-1,r=l.length;++n>8&15|e>>4&240,e>>4&15|240&e,(15&e)<<4|15&e,1):8===n?Kr(e>>24&255,e>>16&255,e>>8&255,(255&e)/255):4===n?Kr(e>>12&15|e>>8&240,e>>8&15|e>>4&240,e>>4&15|240&e,((15&e)<<4|15&e)/255):null):(e=Hr.exec(t))?new Zr(e[1],e[2],e[3],1):(e=$r.exec(t))?new Zr(255*e[1]/100,255*e[2]/100,255*e[3]/100,1):(e=zr.exec(t))?Kr(e[1],e[2],e[3],e[4]):(e=Fr.exec(t))?Kr(255*e[1]/100,255*e[2]/100,255*e[3]/100,e[4]):(e=Ur.exec(t))?ii(e[1],e[2]/100,e[3]/100,1):(e=Xr.exec(t))?ii(e[1],e[2]/100,e[3]/100,e[4]):Vr.hasOwnProperty(t)?Wr(Vr[t]):"transparent"===t?new Zr(NaN,NaN,NaN,0):null}function Wr(t){return new Zr(t>>16&255,t>>8&255,255&t,1)}function Kr(t,e,n,r){return r<=0&&(t=e=n=NaN),new Zr(t,e,n,r)}function Jr(t,e,n,r){return 1===arguments.length?((i=t)instanceof jr||(i=Yr(i)),i?new Zr((i=i.rgb()).r,i.g,i.b,i.opacity):new Zr):new Zr(t,e,n,null==r?1:r);var i}function Zr(t,e,n,r){this.r=+t,this.g=+e,this.b=+n,this.opacity=+r}function Qr(){return`#${ri(this.r)}${ri(this.g)}${ri(this.b)}`}function ti(){const t=ei(this.opacity);return`${1===t?"rgb(":"rgba("}${ni(this.r)}, ${ni(this.g)}, ${ni(this.b)}${1===t?")":`, ${t})`}`}function ei(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function ni(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function ri(t){return((t=ni(t))<16?"0":"")+t.toString(16)}function ii(t,e,n,r){return r<=0?t=e=n=NaN:n<=0||n>=1?t=e=NaN:e<=0&&(t=NaN),new ai(t,e,n,r)}function oi(t){if(t instanceof ai)return new ai(t.h,t.s,t.l,t.opacity);if(t instanceof jr||(t=Yr(t)),!t)return new ai;if(t instanceof ai)return t;var e=(t=t.rgb()).r/255,n=t.g/255,r=t.b/255,i=Math.min(e,n,r),o=Math.max(e,n,r),a=NaN,s=o-i,l=(o+i)/2;return s?(a=e===o?(n-r)/s+6*(n0&&l<1?0:a,new ai(a,s,l,t.opacity)}function ai(t,e,n,r){this.h=+t,this.s=+e,this.l=+n,this.opacity=+r}function si(t){return(t=(t||0)%360)<0?t+360:t}function li(t){return Math.max(0,Math.min(1,t||0))}function ci(t,e,n){return 255*(t<60?e+(n-e)*t/60:t<180?n:t<240?e+(n-e)*(240-t)/60:e)}function ui(t,e,n,r,i){var o=t*t,a=o*t;return((1-3*t+3*o-a)*e+(4-6*o+3*a)*n+(1+3*t+3*o-3*a)*r+a*i)/6}kr(jr,Yr,{copy(t){return Object.assign(new this.constructor,this,t)},displayable(){return this.rgb().displayable()},hex:Gr,formatHex:Gr,formatHex8:function(){return this.rgb().formatHex8()},formatHsl:function(){return oi(this).formatHsl()},formatRgb:qr,toString:qr}),kr(Zr,Jr,Mr(jr,{brighter(t){return t=null==t?Pr:Math.pow(Pr,t),new Zr(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=null==t?Nr:Math.pow(Nr,t),new Zr(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new Zr(ni(this.r),ni(this.g),ni(this.b),ei(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:Qr,formatHex:Qr,formatHex8:function(){return`#${ri(this.r)}${ri(this.g)}${ri(this.b)}${ri(255*(isNaN(this.opacity)?1:this.opacity))}`},formatRgb:ti,toString:ti})),kr(ai,(function(t,e,n,r){return 1===arguments.length?oi(t):new ai(t,e,n,null==r?1:r)}),Mr(jr,{brighter(t){return t=null==t?Pr:Math.pow(Pr,t),new ai(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=null==t?Nr:Math.pow(Nr,t),new ai(this.h,this.s,this.l*t,this.opacity)},rgb(){var t=this.h%360+360*(this.h<0),e=isNaN(t)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*e,i=2*n-r;return new Zr(ci(t>=240?t-240:t+120,i,r),ci(t,i,r),ci(t<120?t+240:t-120,i,r),this.opacity)},clamp(){return new ai(si(this.h),li(this.s),li(this.l),ei(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const t=ei(this.opacity);return`${1===t?"hsl(":"hsla("}${si(this.h)}, ${100*li(this.s)}%, ${100*li(this.l)}%${1===t?")":`, ${t})`}`}}));const hi=t=>()=>t;function di(t,e){var n=e-t;return n?function(t,e){return function(n){return t+n*e}}(t,n):hi(isNaN(t)?e:t)}const fi=function t(e){var n=function(t){return 1==(t=+t)?di:function(e,n){return n-e?function(t,e,n){return t=Math.pow(t,n),e=Math.pow(e,n)-t,n=1/n,function(r){return Math.pow(t+r*e,n)}}(e,n,t):hi(isNaN(e)?n:e)}}(e);function r(t,e){var r=n((t=Jr(t)).r,(e=Jr(e)).r),i=n(t.g,e.g),o=n(t.b,e.b),a=di(t.opacity,e.opacity);return function(e){return t.r=r(e),t.g=i(e),t.b=o(e),t.opacity=a(e),t+""}}return r.gamma=t,r}(1);function pi(t){return function(e){var n,r,i=e.length,o=new Array(i),a=new Array(i),s=new Array(i);for(n=0;n=1?(n=1,e-1):Math.floor(n*e),i=t[r],o=t[r+1],a=r>0?t[r-1]:2*i-o,s=ro&&(i=e.slice(o,i),s[a]?s[a]+=i:s[++a]=i),(n=n[0])===(r=r[0])?s[a]?s[a]+=r:s[++a]=r:(s[++a]=null,l.push({i:a,x:br(n,r)})),o=vi.lastIndex;return o=0&&(t=t.slice(0,e)),!t||"start"===t}))}(e)?gr:vr;return function(){var a=o(this,t),s=a.on;s!==r&&(i=(r=s).copy()).on(e,n),a.on=i}}(n,t,e))},attr:function(t,e){var n=qe(t),r="transform"===n?Or:yi;return this.attrTween(t,"function"==typeof e?(n.local?Si:Ci)(n,r,Ir(this,"attr."+t,e)):null==e?(n.local?wi:bi)(n):(n.local?_i:xi)(n,r,e))},attrTween:function(t,e){var n="attr."+t;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(null==e)return this.tween(n,null);if("function"!=typeof e)throw new Error;var r=qe(t);return this.tween(n,(r.local?Di:Oi)(r,e))},style:function(t,e,n){var r="transform"==(t+="")?Dr:yi;return null==e?this.styleTween(t,function(t,e){var n,r,i;return function(){var o=on(this,t),a=(this.style.removeProperty(t),on(this,t));return o===a?null:o===n&&a===r?i:i=e(n=o,r=a)}}(t,r)).on("end.style."+t,ji(t)):"function"==typeof e?this.styleTween(t,function(t,e,n){var r,i,o;return function(){var a=on(this,t),s=n(this),l=s+"";return null==s&&(this.style.removeProperty(t),l=s=on(this,t)),a===l?null:a===r&&l===i?o:(i=l,o=e(r=a,s))}}(t,r,Ir(this,"style."+t,e))).each(function(t,e){var n,r,i,o,a="style."+e,s="end."+a;return function(){var l=vr(this,t),c=l.on,u=null==l.value[a]?o||(o=ji(e)):void 0;c===n&&i===u||(r=(n=c).copy()).on(s,i=u),l.on=r}}(this._id,t)):this.styleTween(t,function(t,e,n){var r,i,o=n+"";return function(){var a=on(this,t);return a===o?null:a===r?i:i=e(r=a,n)}}(t,r,e),n).on("end.style."+t,null)},styleTween:function(t,e,n){var r="style."+(t+="");if(arguments.length<2)return(r=this.tween(r))&&r._value;if(null==e)return this.tween(r,null);if("function"!=typeof e)throw new Error;return this.tween(r,function(t,e,n){var r,i;function o(){var o=e.apply(this,arguments);return o!==i&&(r=(i=o)&&function(t,e,n){return function(r){this.style.setProperty(t,e.call(this,r),n)}}(t,o,n)),r}return o._value=e,o}(t,e,null==n?"":n))},text:function(t){return this.tween("text","function"==typeof t?function(t){return function(){var e=t(this);this.textContent=null==e?"":e}}(Ir(this,"text",t)):function(t){return function(){this.textContent=t}}(null==t?"":t+""))},textTween:function(t){var e="text";if(arguments.length<1)return(e=this.tween(e))&&e._value;if(null==t)return this.tween(e,null);if("function"!=typeof t)throw new Error;return this.tween(e,function(t){var e,n;function r(){var r=t.apply(this,arguments);return r!==n&&(e=(n=r)&&function(t){return function(e){this.textContent=t.call(this,e)}}(r)),e}return r._value=t,r}(t))},remove:function(){return this.on("end.remove",function(t){return function(){var e=this.parentNode;for(var n in this.__transition)if(+n!==t)return;e&&e.removeChild(this)}}(this._id))},tween:function(t,e){var n=this._id;if(t+="",arguments.length<2){for(var r,i=mr(this.node(),n).tween,o=0,a=i.length;o1?r[0]+r.slice(2):r,+t.slice(n+1)]}function Xi(t){return(t=Ui(Math.abs(t)))?t[1]:NaN}["w","e"].map(Fi),["n","s"].map(Fi),["n","w","e","s","nw","ne","sw","se"].map(Fi);var Vi,Gi=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function qi(t){if(!(e=Gi.exec(t)))throw new Error("invalid format: "+t);var e;return new Yi({fill:e[1],align:e[2],sign:e[3],symbol:e[4],zero:e[5],width:e[6],comma:e[7],precision:e[8]&&e[8].slice(1),trim:e[9],type:e[10]})}function Yi(t){this.fill=void 0===t.fill?" ":t.fill+"",this.align=void 0===t.align?">":t.align+"",this.sign=void 0===t.sign?"-":t.sign+"",this.symbol=void 0===t.symbol?"":t.symbol+"",this.zero=!!t.zero,this.width=void 0===t.width?void 0:+t.width,this.comma=!!t.comma,this.precision=void 0===t.precision?void 0:+t.precision,this.trim=!!t.trim,this.type=void 0===t.type?"":t.type+""}function Wi(t,e){var n=Ui(t,e);if(!n)return t+"";var r=n[0],i=n[1];return i<0?"0."+new Array(-i).join("0")+r:r.length>i+1?r.slice(0,i+1)+"."+r.slice(i+1):r+new Array(i-r.length+2).join("0")}qi.prototype=Yi.prototype,Yi.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(void 0===this.width?"":Math.max(1,0|this.width))+(this.comma?",":"")+(void 0===this.precision?"":"."+Math.max(0,0|this.precision))+(this.trim?"~":"")+this.type};const Ki={"%":(t,e)=>(100*t).toFixed(e),b:t=>Math.round(t).toString(2),c:t=>t+"",d:function(t){return Math.abs(t=Math.round(t))>=1e21?t.toLocaleString("en").replace(/,/g,""):t.toString(10)},e:(t,e)=>t.toExponential(e),f:(t,e)=>t.toFixed(e),g:(t,e)=>t.toPrecision(e),o:t=>Math.round(t).toString(8),p:(t,e)=>Wi(100*t,e),r:Wi,s:function(t,e){var n=Ui(t,e);if(!n)return t+"";var r=n[0],i=n[1],o=i-(Vi=3*Math.max(-8,Math.min(8,Math.floor(i/3))))+1,a=r.length;return o===a?r:o>a?r+new Array(o-a+1).join("0"):o>0?r.slice(0,o)+"."+r.slice(o):"0."+new Array(1-o).join("0")+Ui(t,Math.max(0,e+o-1))[0]},X:t=>Math.round(t).toString(16).toUpperCase(),x:t=>Math.round(t).toString(16)};function Ji(t){return t}var Zi,Qi,to,eo=Array.prototype.map,no=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function ro(t,e){switch(arguments.length){case 0:break;case 1:this.range(t);break;default:this.range(e).domain(t)}return this}Zi=function(t){var e,n,r=void 0===t.grouping||void 0===t.thousands?Ji:(e=eo.call(t.grouping,Number),n=t.thousands+"",function(t,r){for(var i=t.length,o=[],a=0,s=e[0],l=0;i>0&&s>0&&(l+s+1>r&&(s=Math.max(1,r-l)),o.push(t.substring(i-=s,i+s)),!((l+=s+1)>r));)s=e[a=(a+1)%e.length];return o.reverse().join(n)}),i=void 0===t.currency?"":t.currency[0]+"",o=void 0===t.currency?"":t.currency[1]+"",a=void 0===t.decimal?".":t.decimal+"",s=void 0===t.numerals?Ji:function(t){return function(e){return e.replace(/[0-9]/g,(function(e){return t[+e]}))}}(eo.call(t.numerals,String)),l=void 0===t.percent?"%":t.percent+"",c=void 0===t.minus?"−":t.minus+"",u=void 0===t.nan?"NaN":t.nan+"";function h(t){var e=(t=qi(t)).fill,n=t.align,h=t.sign,d=t.symbol,f=t.zero,p=t.width,g=t.comma,v=t.precision,m=t.trim,y=t.type;"n"===y?(g=!0,y="g"):Ki[y]||(void 0===v&&(v=12),m=!0,y="g"),(f||"0"===e&&"="===n)&&(f=!0,e="0",n="=");var b="$"===d?i:"#"===d&&/[boxX]/.test(y)?"0"+y.toLowerCase():"",w="$"===d?o:/[%p]/.test(y)?l:"",x=Ki[y],_=/[defgprs%]/.test(y);function C(t){var i,o,l,d=b,C=w;if("c"===y)C=x(t)+C,t="";else{var S=(t=+t)<0||1/t<0;if(t=isNaN(t)?u:x(Math.abs(t),v),m&&(t=function(t){t:for(var e,n=t.length,r=1,i=-1;r0&&(i=0)}return i>0?t.slice(0,i)+t.slice(e+1):t}(t)),S&&0==+t&&"+"!==h&&(S=!1),d=(S?"("===h?h:c:"-"===h||"("===h?"":h)+d,C=("s"===y?no[8+Vi/3]:"")+C+(S&&"("===h?")":""),_)for(i=-1,o=t.length;++i(l=t.charCodeAt(i))||l>57){C=(46===l?a+t.slice(i+1):t.slice(i))+C,t=t.slice(0,i);break}}g&&!f&&(t=r(t,1/0));var D=d.length+t.length+C.length,O=D>1)+d+t+C+O.slice(D);break;default:t=O+d+t+C}return s(t)}return v=void 0===v?6:/[gprs]/.test(y)?Math.max(1,Math.min(21,v)):Math.max(0,Math.min(20,v)),C.toString=function(){return t+""},C}return{format:h,formatPrefix:function(t,e){var n=h(((t=qi(t)).type="f",t)),r=3*Math.max(-8,Math.min(8,Math.floor(Xi(e)/3))),i=Math.pow(10,-r),o=no[8+r/3];return function(t){return n(i*t)+o}}}}({thousands:",",grouping:[3],currency:["$",""]}),Qi=Zi.format,to=Zi.formatPrefix;class io extends Map{constructor(t,e=ao){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:e}}),null!=t)for(const[e,n]of t)this.set(e,n)}get(t){return super.get(oo(this,t))}has(t){return super.has(oo(this,t))}set(t,e){return super.set(function({_intern:t,_key:e},n){const r=e(n);return t.has(r)?t.get(r):(t.set(r,n),n)}(this,t),e)}delete(t){return super.delete(function({_intern:t,_key:e},n){const r=e(n);return t.has(r)&&(n=t.get(r),t.delete(r)),n}(this,t))}}function oo({_intern:t,_key:e},n){const r=e(n);return t.has(r)?t.get(r):n}function ao(t){return null!==t&&"object"==typeof t?t.valueOf():t}Set;const so=Symbol("implicit");function lo(){var t=new io,e=[],n=[],r=so;function i(i){let o=t.get(i);if(void 0===o){if(r!==so)return r;t.set(i,o=e.push(i)-1)}return n[o%n.length]}return i.domain=function(n){if(!arguments.length)return e.slice();e=[],t=new io;for(const r of n)t.has(r)||t.set(r,e.push(r)-1);return i},i.range=function(t){return arguments.length?(n=Array.from(t),i):n.slice()},i.unknown=function(t){return arguments.length?(r=t,i):r},i.copy=function(){return lo(e,n).unknown(r)},ro.apply(i,arguments),i}function co(){var t,e,n=lo().unknown(void 0),r=n.domain,i=n.range,o=0,a=1,s=!1,l=0,c=0,u=.5;function h(){var n=r().length,h=a=uo?10:o>=ho?5:o>=fo?2:1;let s,l,c;return i<0?(c=Math.pow(10,-i)/a,s=Math.round(t*c),l=Math.round(e*c),s/ce&&--l,c=-c):(c=Math.pow(10,i)*a,s=Math.round(t/c),l=Math.round(e/c),s*ce&&--l),le?1:t>=e?0:NaN}function mo(t,e){return null==t||null==e?NaN:et?1:e>=t?0:NaN}function yo(t){let e,n,r;function i(t,r,i=0,o=t.length){if(i>>1;n(t[e],r)<0?i=e+1:o=e}while(ivo(t(e),n),r=(e,n)=>t(e)-n):(e=t===vo||t===mo?t:bo,n=t,r=t),{left:i,center:function(t,e,n=0,o=t.length){const a=i(t,e,n,o-1);return a>n&&r(t[a-1],e)>-r(t[a],e)?a-1:a},right:function(t,r,i=0,o=t.length){if(i>>1;n(t[e],r)<=0?i=e+1:o=e}while(i0))return[];if((t=+t)==(e=+e))return[t];const r=e=i))return[];const s=o-i+1,l=new Array(s);if(r)if(a<0)for(let t=0;t0;){if((i=go(l,c,n))===r)return o[a]=l,o[s]=c,e(o);if(i>0)l=Math.floor(l/i)*i,c=Math.ceil(c/i)*i;else{if(!(i<0))break;l=Math.ceil(l*i)/i,c=Math.floor(c*i)/i}r=i}return t},t}function Ro(){var t=function(){var t,e,n,r,i,o,a=ko,s=ko,l=To,c=Mo;function u(){var t,e,n,l=Math.min(a.length,s.length);return c!==Mo&&(t=a[0],e=a[l-1],t>e&&(n=t,t=e,e=n),c=function(n){return Math.max(t,Math.min(e,n))}),r=l>2?Po:No,i=o=null,h}function h(e){return null==e||isNaN(e=+e)?n:(i||(i=r(a.map(t),s,l)))(t(c(e)))}return h.invert=function(n){return c(e((o||(o=r(s,a.map(t),br)))(n)))},h.domain=function(t){return arguments.length?(a=Array.from(t,Io),u()):a.slice()},h.range=function(t){return arguments.length?(s=Array.from(t),u()):s.slice()},h.rangeRound=function(t){return s=Array.from(t),l=Eo,u()},h.clamp=function(t){return arguments.length?(c=!!t||Mo,u()):c!==Mo},h.interpolate=function(t){return arguments.length?(l=t,u()):l},h.unknown=function(t){return arguments.length?(n=t,h):n},function(n,r){return t=n,e=r,u()}}()(Mo,Mo);return t.copy=function(){return e=t,Ro().domain(e.domain()).range(e.range()).interpolate(e.interpolate()).clamp(e.clamp()).unknown(e.unknown());var e},ro.apply(t,arguments),Ao(t)}function Lo(t){return"string"==typeof t?new Hn([[document.querySelector(t)]],[document.documentElement]):new Hn([[t]],Bn)}const Bo={capture:!0,passive:!1};function Ho(t){t.preventDefault(),t.stopImmediatePropagation()}function $o(t){return((t=Math.exp(t))+1/t)/2}const zo=function t(e,n,r){function i(t,i){var o,a,s=t[0],l=t[1],c=t[2],u=i[0],h=i[1],d=i[2],f=u-s,p=h-l,g=f*f+p*p;if(g<1e-12)a=Math.log(d/c)/e,o=function(t){return[s+t*f,l+t*p,c*Math.exp(e*t*a)]};else{var v=Math.sqrt(g),m=(d*d-c*c+r*g)/(2*c*n*v),y=(d*d-c*c-r*g)/(2*d*n*v),b=Math.log(Math.sqrt(m*m+1)-m),w=Math.log(Math.sqrt(y*y+1)-y);a=(w-b)/e,o=function(t){var r,i=t*a,o=$o(b),u=c/(n*v)*(o*(r=e*i+b,((r=Math.exp(2*r))-1)/(r+1))-function(t){return((t=Math.exp(t))-1/t)/2}(b));return[s+u*f,l+u*p,c*o/$o(e*i+b)]}}return o.duration=1e3*a*e/Math.SQRT2,o}return i.rho=function(e){var n=Math.max(.001,+e),r=n*n;return t(n,r,r*r)},i}(Math.SQRT2,2,4);function Fo(t,e){if(t=function(t){let e;for(;e=t.sourceEvent;)t=e;return t}(t),void 0===e&&(e=t.currentTarget),e){var n=e.ownerSVGElement||e;if(n.createSVGPoint){var r=n.createSVGPoint();return r.x=t.clientX,r.y=t.clientY,[(r=r.matrixTransform(e.getScreenCTM().inverse())).x,r.y]}if(e.getBoundingClientRect){var i=e.getBoundingClientRect();return[t.clientX-i.left-e.clientLeft,t.clientY-i.top-e.clientTop]}}return[t.pageX,t.pageY]}const Uo=t=>()=>t;function Xo(t,{sourceEvent:e,target:n,transform:r,dispatch:i}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:e,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:i}})}function Vo(t,e,n){this.k=t,this.x=e,this.y=n}Vo.prototype={constructor:Vo,scale:function(t){return 1===t?this:new Vo(this.k*t,this.x,this.y)},translate:function(t,e){return 0===t&0===e?this:new Vo(this.k,this.x+this.k*t,this.y+this.k*e)},apply:function(t){return[t[0]*this.k+this.x,t[1]*this.k+this.y]},applyX:function(t){return t*this.k+this.x},applyY:function(t){return t*this.k+this.y},invert:function(t){return[(t[0]-this.x)/this.k,(t[1]-this.y)/this.k]},invertX:function(t){return(t-this.x)/this.k},invertY:function(t){return(t-this.y)/this.k},rescaleX:function(t){return t.copy().domain(t.range().map(this.invertX,this).map(t.invert,t))},rescaleY:function(t){return t.copy().domain(t.range().map(this.invertY,this).map(t.invert,t))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var Go=new Vo(1,0,0);function qo(t){t.stopImmediatePropagation()}function Yo(t){t.preventDefault(),t.stopImmediatePropagation()}function Wo(t){return!(t.ctrlKey&&"wheel"!==t.type||t.button)}function Ko(){var t=this;return t instanceof SVGElement?(t=t.ownerSVGElement||t).hasAttribute("viewBox")?[[(t=t.viewBox.baseVal).x,t.y],[t.x+t.width,t.y+t.height]]:[[0,0],[t.width.baseVal.value,t.height.baseVal.value]]:[[0,0],[t.clientWidth,t.clientHeight]]}function Jo(){return this.__zoom||Go}function Zo(t){return-t.deltaY*(1===t.deltaMode?.05:t.deltaMode?1:.002)*(t.ctrlKey?10:1)}function Qo(){return navigator.maxTouchPoints||"ontouchstart"in this}function ta(t,e,n){var r=t.invertX(e[0][0])-n[0][0],i=t.invertX(e[1][0])-n[1][0],o=t.invertY(e[0][1])-n[0][1],a=t.invertY(e[1][1])-n[1][1];return t.translate(i>r?(r+i)/2:Math.min(0,r)||Math.max(0,i),a>o?(o+a)/2:Math.min(0,o)||Math.max(0,a))}Vo.prototype;const ea=({data:t,width:e="100%",height:n="400px",enableXZoom:r=!1,backgroundColor:i="#ffffff",defaultBarColor:o="#007cba",barOpacity:a=1,title:s,showBarValues:c=!1,showGridX:u=!1,showGridY:h=!1,xGridColor:d="#e0e0e0",yGridColor:f="#e0e0e0",xGridWidth:p=1,yGridWidth:g=1,xAxisLabel:v,yAxisLabel:m,colorSource:y="default",customColors:b=[],enableHierarchicalView:w,enableStackedBars:x,selectedParentId:_,enableBarPopovers:C,setAttributes:S})=>{const D=(0,l.useRef)(null),O=(0,l.useRef)(null),[T,E]=(0,l.useState)(null),[I,k]=(0,l.useState)(null);return(0,l.useEffect)((()=>{I||E(null)}),[I]),(0,l.useEffect)((()=>{if(!I)return;const t=setTimeout((()=>{E(I)}),100);return()=>clearTimeout(t)}),[I]),(0,l.useEffect)((()=>{if(!t||!D.current||!O.current)return;Lo(D.current).selectAll("*").remove();let e=[];Object.entries(t).forEach((([n,r])=>{Array.isArray(r)&&r.forEach((r=>{if(w?r.parent===_:!r.parent||null===r.parent){const i=parseFloat(r.value);isNaN(i)||e.push({dataset:n,label:r.label||"",value:i,color:r.color||o,id:r.id,popoverHtml:r.popoverHtml||"",hasChildren:Array.isArray(t[n])&&t[n].some((t=>t.parent===r.id))})}}))})),0===e.length&&(e=[{label:"No Data",value:0,color:o}]);const n=O.current.clientWidth,l=O.current.clientHeight,y=s?40:20,b=Math.max(n-60-20,0),T=Math.max(l-y-60,0),M=Lo(D.current).attr("width","100%").attr("height","100%").attr("viewBox",`0 0 ${n} ${l}`).attr("preserveAspectRatio","xMidYMid meet").style("background-color",i),j=M.append("g").attr("transform",`translate(60,${y})`),N=co().domain(e.map((t=>t.label))).range([0,b]).padding(.1),P=Math.max(function(t,e){let n;if(void 0===e)for(const e of t)null!=e&&(n=e)&&(n=e);else{let r=-1;for(let i of t)null!=(i=e(i,++r))&&(n=i)&&(n=i)}return n}(e,(t=>t.value))||0,1),A=(()=>{const t=Math.pow(10,Math.floor(Math.log10(P))),e=P/t;return Math.ceil(e)*t||100})(),R=Ro().domain([0,A]).range([T,0]),L=Te(R).tickSize(6).ticks(10).tickFormat(Qi(",d")),B=(M.append("defs").append("clipPath").attr("id","clip").append("rect").attr("x",0).attr("y",0).attr("width",b).attr("height",T),j.append("g").attr("class","zoom-group").attr("clip-path","url(#clip)"));h&&B.append("g").attr("class","grid y-grid").style("color",f).style("stroke-width",g).style("pointer-events","none").call(Te(R).tickSize(-b).ticks(L.ticks()[0]).tickFormat("")),u&&B.append("g").attr("class","grid x-grid").attr("transform",`translate(0,${T})`).style("color",d).style("stroke-width",p).style("pointer-events","none").call(Oe(N).tickSize(-T).tickFormat(""));const H=B.selectAll(".bar-group").data(e).join("g").attr("class","bar-group").attr("transform",(t=>`translate(${N(t.label)},0)`));H.append("rect").attr("class","bar").attr("x",0).attr("y",(t=>isNaN(R(t.value))?R(0):R(t.value))).attr("width",N.bandwidth()).attr("height",(t=>{const e=T-(isNaN(R(t.value))?R(0):R(t.value));return Math.max(0,e)})).attr("fill",(t=>t.color||o)).style("opacity",a).style("cursor",(t=>C||t.hasChildren&&w?"pointer":"default")).on("mouseenter",(function(t,e){if(C){const n=this.getBoundingClientRect(),r=n.left+n.width/2;k({data:e,position:{x:r,y:t.clientY}})}})).on("mousemove",(function(t,e){if(C&&I){const n=this.getBoundingClientRect(),r=n.left+n.width/2;k({data:e,position:{x:r,y:t.clientY}})}})).on("mouseleave",(()=>{k(null)})).on("click",(function(t,e){k(null),E(null),e.hasChildren&&w&&(t.stopPropagation(),S({selectedParentId:e.id}))})),x&&H.each((function(t){let e=t.value;t.children.forEach((t=>{Lo(this).append("rect").attr("class","child-bar").attr("y",(()=>R(e+t.value))).attr("width",N.bandwidth()).attr("height",(()=>T-R(t.value))).attr("fill",t.color).style("opacity",a),e+=t.value}))})),c&&H.append("text").attr("class","bar-value").attr("x",N.bandwidth()/2).attr("y",(t=>{const e=R(t.value);return isNaN(e)?R(0)-5:e-5})).attr("text-anchor","middle").style("fill","#000").style("font-size","12px").text((t=>Qi(",d")(t.value||0)));const $=j.append("g").attr("class","x-axis").attr("transform",`translate(0,${T})`).call(Oe(N));$.selectAll("text").style("text-anchor","end").attr("dx","-.8em").attr("dy",".15em").attr("transform","rotate(-45)"),j.append("g").attr("class","y-axis").call(L);const z=function(){var t,e,n,r=Wo,i=Ko,o=ta,a=Zo,s=Qo,l=[0,1/0],c=[[-1/0,-1/0],[1/0,1/0]],u=250,h=zo,d=qn("start","zoom","end"),f=0,p=10;function g(t){t.property("__zoom",Jo).on("wheel.zoom",_,{passive:!1}).on("mousedown.zoom",C).on("dblclick.zoom",S).filter(s).on("touchstart.zoom",D).on("touchmove.zoom",O).on("touchend.zoom touchcancel.zoom",T).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function v(t,e){return(e=Math.max(l[0],Math.min(l[1],e)))===t.k?t:new Vo(e,t.x,t.y)}function m(t,e,n){var r=e[0]-n[0]*t.k,i=e[1]-n[1]*t.k;return r===t.x&&i===t.y?t:new Vo(t.k,r,i)}function y(t){return[(+t[0][0]+ +t[1][0])/2,(+t[0][1]+ +t[1][1])/2]}function b(t,e,n,r){t.on("start.zoom",(function(){w(this,arguments).event(r).start()})).on("interrupt.zoom end.zoom",(function(){w(this,arguments).event(r).end()})).tween("zoom",(function(){var t=this,o=arguments,a=w(t,o).event(r),s=i.apply(t,o),l=null==n?y(s):"function"==typeof n?n.apply(t,o):n,c=Math.max(s[1][0]-s[0][0],s[1][1]-s[0][1]),u=t.__zoom,d="function"==typeof e?e.apply(t,o):e,f=h(u.invert(l).concat(c/u.k),d.invert(l).concat(c/d.k));return function(t){if(1===t)t=d;else{var e=f(t),n=c/e[2];t=new Vo(n,l[0]-e[0]*n,l[1]-e[1]*n)}a.zoom(null,t)}}))}function w(t,e,n){return!n&&t.__zooming||new x(t,e)}function x(t,e){this.that=t,this.args=e,this.active=0,this.sourceEvent=null,this.extent=i.apply(t,e),this.taps=0}function _(t,...e){if(r.apply(this,arguments)){var n=w(this,e).event(t),i=this.__zoom,s=Math.max(l[0],Math.min(l[1],i.k*Math.pow(2,a.apply(this,arguments)))),u=Fo(t);if(n.wheel)n.mouse[0][0]===u[0]&&n.mouse[0][1]===u[1]||(n.mouse[1]=i.invert(n.mouse[0]=u)),clearTimeout(n.wheel);else{if(i.k===s)return;n.mouse=[u,i.invert(u)],yr(this),n.start()}Yo(t),n.wheel=setTimeout((function(){n.wheel=null,n.end()}),150),n.zoom("mouse",o(m(v(i,s),n.mouse[0],n.mouse[1]),n.extent,c))}}function C(t,...e){if(!n&&r.apply(this,arguments)){var i=t.currentTarget,a=w(this,e,!0).event(t),s=Lo(t.view).on("mousemove.zoom",(function(t){if(Yo(t),!a.moved){var e=t.clientX-u,n=t.clientY-h;a.moved=e*e+n*n>f}a.event(t).zoom("mouse",o(m(a.that.__zoom,a.mouse[0]=Fo(t,i),a.mouse[1]),a.extent,c))}),!0).on("mouseup.zoom",(function(t){s.on("mousemove.zoom mouseup.zoom",null),function(t,e){var n=t.document.documentElement,r=Lo(t).on("dragstart.drag",null);e&&(r.on("click.drag",Ho,Bo),setTimeout((function(){r.on("click.drag",null)}),0)),"onselectstart"in n?r.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}(t.view,a.moved),Yo(t),a.event(t).end()}),!0),l=Fo(t,i),u=t.clientX,h=t.clientY;!function(t){var e=t.document.documentElement,n=Lo(t).on("dragstart.drag",Ho,Bo);"onselectstart"in e?n.on("selectstart.drag",Ho,Bo):(e.__noselect=e.style.MozUserSelect,e.style.MozUserSelect="none")}(t.view),qo(t),a.mouse=[l,this.__zoom.invert(l)],yr(this),a.start()}}function S(t,...e){if(r.apply(this,arguments)){var n=this.__zoom,a=Fo(t.changedTouches?t.changedTouches[0]:t,this),s=n.invert(a),l=n.k*(t.shiftKey?.5:2),h=o(m(v(n,l),a,s),i.apply(this,e),c);Yo(t),u>0?Lo(this).transition().duration(u).call(b,h,a,t):Lo(this).call(g.transform,h,a,t)}}function D(n,...i){if(r.apply(this,arguments)){var o,a,s,l,c=n.touches,u=c.length,h=w(this,i,n.changedTouches.length===u).event(n);for(qo(n),a=0;a{const n=t.transform,r=N.bandwidth()*n.k,i=[n.x,n.x+b*n.k];H.attr("transform",(t=>`translate(${n.x+N(t.label)*n.k},0)`)),H.selectAll("rect").attr("width",Math.max(r,1)),c&&H.selectAll(".bar-value").attr("x",r/2).style("font-size",`${Math.min(12*n.k,24)}px`),$.call(Oe(N).scale(co().domain(e.map((t=>t.label))).range(i).padding(.1))),u&&B.select(".x-grid").attr("transform",`translate(0,${T})`).call(Oe(N).scale(co().domain(e.map((t=>t.label))).range(i).padding(.1)).tickSize(-T).tickFormat(""))}));if(r&&M.call(z).call(z.transform,Go),v&&j.append("text").attr("class","x-axis-label").attr("x",b/2).attr("y",T+25).attr("text-anchor","middle").style("font-size","12px").text(v),m&&j.append("text").attr("class","y-axis-label").attr("transform","rotate(-90)").attr("x",-T/2).attr("y",-45).attr("text-anchor","middle").style("font-size","12px").text(m),w&&_){const e=M.append("g").attr("class","back-button").style("cursor","pointer").on("click",(()=>{let e=null;Object.values(t).forEach((t=>{if(Array.isArray(t)){const n=t.find((t=>t.id===_));n&&(e=n.parent)}})),S({selectedParentId:e})}));e.append("rect").attr("x",10).attr("y",10).attr("width",60).attr("height",24).attr("rx",4).attr("fill","#f0f0f0").attr("stroke","#ccc"),e.append("text").attr("x",40).attr("y",26).attr("text-anchor","middle").style("font-size","12px").text("← Back")}}),[t,e,n,s,u,h,d,f,p,g,c,v,m,y,o,b,a,w,x,_,C,r]),(0,A.jsxs)("div",{ref:O,className:"bar-graph",style:{width:e,height:n,position:"relative"},children:[(0,A.jsx)("svg",{ref:D,style:{width:"100%",height:"100%"}}),T&&(0,A.jsxs)("div",{className:"bar-popover",style:{position:"fixed",left:T.position.x,top:T.position.y,transform:"translate(-50%, -100%)",backgroundColor:"white",padding:"8px",borderRadius:"4px",boxShadow:"0 2px 4px rgba(0,0,0,0.2)",zIndex:1e3,pointerEvents:"none",marginTop:"-8px",maxWidth:"200px"},children:[(0,A.jsx)("div",{style:{marginBottom:"4px"},children:(0,A.jsx)("strong",{children:T.data.label})}),(0,A.jsxs)("div",{style:{marginBottom:"8px"},children:["Value: ",T.data.value]}),T.data.popoverHtml&&(0,A.jsx)("div",{dangerouslySetInnerHTML:{__html:T.data.popoverHtml}}),(0,A.jsx)("div",{style:{position:"absolute",left:"50%",bottom:"-6px",transform:"translateX(-50%)",width:0,height:0,borderLeft:"6px solid transparent",borderRight:"6px solid transparent",borderTop:"6px solid white",filter:"drop-shadow(0 2px 2px rgba(0,0,0,0.1))"}})]})]})},na=({label:t,value:e,onChange:n})=>{const{number:r,unit:i}=(t=>{const e=t?.match(/^(\d+)(.*)$/);return e?{number:parseInt(e[1],10),unit:e[2]||"px"}:{number:300,unit:"px"}})(e);return(0,A.jsxs)("div",{className:"lcp-dimension-control",children:[(0,A.jsx)("label",{className:"components-base-control__label",children:t}),(0,A.jsxs)("div",{style:{display:"flex",gap:"8px",alignItems:"flex-start"},children:[(0,A.jsx)(s.TextControl,{type:"number",value:r,onChange:t=>{n(`${t}${i}`)},min:0,style:{width:"80px"}}),(0,A.jsx)(s.SelectControl,{value:i,options:[{label:"Pixels (px)",value:"px"},{label:"Percentage (%)",value:"%"},{label:"Viewport Width (vw)",value:"vw"},{label:"Viewport Height (vh)",value:"vh"}],onChange:t=>{n(`${r}${t}`)},style:{minWidth:"100px"}})]})]})},ra=({data:t,colorSource:e,singleColor:n,customColors:r,onColorSourceChange:i,onSingleColorChange:a,onCustomColorChange:c})=>{const[u,h]=(0,l.useState)(null),d=(t,e)=>{const n=r.find((n=>n.dataset===t&&n.label===e));return n?n.color:"#FF6384"};return(0,A.jsxs)("div",{className:"lcp-color-controls",children:[(0,A.jsx)(s.SelectControl,{label:(0,o.__)("Color Source","lcp"),value:e,options:[{label:(0,o.__)("Default Colors","lcp"),value:"default"},{label:(0,o.__)("Single Color","lcp"),value:"singleColor"},{label:(0,o.__)("Custom Colors","lcp"),value:"customColors"}],onChange:i}),"singleColor"===e&&(0,A.jsxs)("div",{className:"components-base-control",children:[(0,A.jsx)("label",{className:"components-base-control__label",children:(0,o.__)("Bar Color","lcp")}),(0,A.jsx)(s.ColorPicker,{color:n,onChangeComplete:t=>a(t.hex)})]}),"customColors"===e&&(0,A.jsx)("div",{className:"custom-colors-grid",style:{marginTop:"10px"},children:(()=>{const e=[];return Object.entries(t).forEach((([t,n])=>{n.forEach((n=>{e.push({dataset:t,label:n.label,value:n.value})}))})),e})().map(((t,e)=>(0,A.jsxs)("div",{style:{display:"flex",alignItems:"center",marginBottom:"8px",gap:"8px"},children:[(0,A.jsx)("span",{style:{flex:1},children:t.label}),(0,A.jsx)(s.Button,{onClick:()=>h(e),style:{backgroundColor:d(t.dataset,t.label),width:"24px",height:"24px",borderRadius:"50%",padding:0,border:"1px solid #ddd"}}),u===e&&(0,A.jsx)(s.Popover,{onClose:()=>h(null),children:(0,A.jsx)("div",{style:{padding:"12px"},children:(0,A.jsx)(s.ColorPicker,{color:d(t.dataset,t.label),onChangeComplete:e=>{c(t.dataset,t.label,e.hex)}})})})]},`${t.dataset}-${t.label}`)))})]})},ia=JSON.parse('{"UU":"lcp/bar-graph"}');(0,i.registerBlockType)(ia.UU,{edit:function({attributes:t,setAttributes:e}){const{chartHeight:n,chartWidth:r,barColor:i,barOpacity:c,backgroundColor:u,showGridY:h,yGridColor:d,xGridColor:f,xGridWidth:p,yGridWidth:g,chartData:v,dataSource:m,displayChartTitle:y,chartTitle:b,allowDownload:w,downloadMaxWidth:x,showSorting:_,showFiltering:C,showBarValues:S,showGridX:D,xAxisLabel:O,yAxisLabel:T,chartColorSource:E,chartCustomColors:I,enableHierarchicalView:k,enableStackedBars:M,selectedParentId:j,enableBarPopovers:N,enableXZoom:P}=t,R=(0,a.useBlockProps)(),L=t=>{console.log("New data:",t),e({chartData:t})},B=t=>{e({dataSource:t,chartData:{}})},H=(t,n,r)=>{const i=[...I],o=i.findIndex((e=>e.dataset===t&&e.label===n));o>=0?i[o].color=r:i.push({dataset:t,label:n,color:r}),e({chartCustomColors:i})},[$,z]=(0,l.useState)(!1),[F,U]=(0,l.useState)(!1),X=()=>{z(!$)},V=()=>{U(!F)},[G,q]=(0,l.useState)(!1),Y=()=>{q(!G)};return console.log("Chart data:",v),t.chartData&&"object"==typeof t.chartData||e({chartData:{}}),(0,A.jsxs)("div",{...R,children:[(0,A.jsx)(a.InspectorControls,{children:(0,A.jsx)(s.TabPanel,{className:"lcp-tab-panel",activeClass:"active-tab",tabs:[{name:"data",title:(0,o.__)("Data Settings","lcp"),className:"tab-data"},{name:"appearance",title:(0,o.__)("Appearance","lcp"),className:"tab-appearance"},{name:"tools",title:(0,o.__)("Tools Settings","lcp"),className:"tab-tools"}],children:t=>"data"===t.name?(0,A.jsxs)(s.Panel,{children:[(0,A.jsx)(s.PanelBody,{title:"Data Settings",children:(0,A.jsx)(me,{value:v,onChange:L,dataSource:m,onDataSourceChange:B})}),(0,A.jsxs)(s.PanelBody,{title:(0,o.__)("Chart Settings","lcp"),initialOpen:!0,children:[(0,A.jsx)(s.ToggleControl,{label:(0,o.__)("Enable Bar Popovers","lcp-data-blocks"),checked:N,onChange:t=>e({enableBarPopovers:t}),help:(0,o.__)("Show HTML content when hovering over bars","lcp-data-blocks")}),(0,A.jsx)(s.ToggleControl,{label:(0,o.__)("Enable Hierarchical View","lcp"),checked:k,onChange:t=>e({enableHierarchicalView:t})}),(0,A.jsx)(s.ToggleControl,{label:(0,o.__)("Enable Stacked Bars","lcp"),checked:M,onChange:t=>e({enableStackedBars:t})}),(0,A.jsx)(s.ToggleControl,{label:(0,o.__)("Display Chart Title","lcp"),checked:y,onChange:t=>e({displayChartTitle:t})}),y&&(0,A.jsx)(s.TextControl,{label:(0,o.__)("Chart Title","lcp"),value:b,onChange:t=>e({chartTitle:t})}),(0,A.jsx)(na,{label:(0,o.__)("Chart Width","lcp"),value:r,onChange:t=>e({chartWidth:t})}),(0,A.jsx)(na,{label:(0,o.__)("Chart Height","lcp"),value:n,onChange:t=>e({chartHeight:t})}),(0,A.jsx)(s.ToggleControl,{label:(0,o.__)("Enable X-Axis Zoom","lcp-data-blocks"),checked:P,onChange:t=>e({enableXZoom:t}),help:(0,o.__)("Allow zooming and panning along the X-axis","lcp-data-blocks")})]}),(0,A.jsxs)(s.PanelBody,{title:"Appearance",children:[(0,A.jsxs)("div",{className:"background-color-row",style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"10px"},children:[(0,A.jsx)("span",{children:"Background Color"}),(0,A.jsx)(s.Button,{className:"background-color-button",onClick:Y,style:{backgroundColor:u,width:"26px",height:"26px",borderRadius:"50%",border:"1px solid #ccc"}}),G&&(0,A.jsx)(s.Popover,{position:"bottom center",onClose:Y,children:(0,A.jsx)(s.ColorPicker,{color:u,onChangeComplete:t=>{return n=t.hex,void e({backgroundColor:n});var n}})})]}),(0,A.jsx)(ra,{data:v,colorSource:E,singleColor:i,customColors:I,onColorSourceChange:t=>e({chartColorSource:t}),onSingleColorChange:t=>e({barColor:t}),onCustomColorChange:H}),(0,A.jsx)(s.RangeControl,{label:(0,o.__)("Bar Opacity","lcp"),value:c,onChange:t=>e({barOpacity:t}),min:0,max:1,step:.1}),(0,A.jsx)(s.ToggleControl,{label:(0,o.__)("Show Bar Values","lcp"),checked:S,onChange:t=>e({showBarValues:t})})]}),(0,A.jsxs)(s.PanelBody,{title:"Grid Settings",children:[(0,A.jsx)(s.TextControl,{label:(0,o.__)("X-Axis Label","lcp"),value:O,onChange:t=>e({xAxisLabel:t})}),(0,A.jsx)(s.TextControl,{label:(0,o.__)("Y-Axis Label","lcp"),value:T,onChange:t=>e({yAxisLabel:t})}),(0,A.jsx)(s.ToggleControl,{label:(0,o.__)("Show X-Axis Grid","lcp"),checked:D,onChange:t=>e({showGridX:t})}),(0,A.jsx)(s.ToggleControl,{label:(0,o.__)("Show Y-Axis Grid","lcp"),checked:h,onChange:t=>e({showGridY:t})}),h&&(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)("div",{className:"y-grid-color-row",style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"8px"},children:[(0,A.jsx)("span",{children:"Y-Axis Grid Color"}),(0,A.jsx)(s.Button,{className:"grid-color-button",onClick:X,style:{backgroundColor:d,width:"26px",height:"26px",borderRadius:"50%",border:"1px solid #ccc"}}),$&&(0,A.jsx)(s.Popover,{position:"bottom center",onClose:X,children:(0,A.jsx)(s.ColorPicker,{color:d,onChangeComplete:t=>{return n=t.hex,void e({yGridColor:n});var n}})})]}),(0,A.jsx)(s.RangeControl,{label:(0,o.__)("Y-Axis Grid Width","lcp"),value:g,onChange:t=>e({yGridWidth:t}),min:1,max:5,step:1})]}),D&&(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)("div",{className:"x-grid-color-row",style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"8px"},children:[(0,A.jsx)("span",{children:"X-Axis Grid Color"}),(0,A.jsx)(s.Button,{className:"grid-color-button",onClick:V,style:{backgroundColor:f,width:"26px",height:"26px",borderRadius:"50%",border:"1px solid #ccc"}}),F&&(0,A.jsx)(s.Popover,{position:"bottom center",onClose:V,children:(0,A.jsx)(s.ColorPicker,{color:f,onChangeComplete:t=>{return n=t.hex,void e({xGridColor:n});var n}})})]}),(0,A.jsx)(s.RangeControl,{label:(0,o.__)("X-Axis Grid Width","lcp"),value:p,onChange:t=>e({xGridWidth:t}),min:1,max:5,step:1})]})]})]}):"tools"===t.name?(0,A.jsxs)(s.PanelBody,{children:[(0,A.jsx)(s.ToggleControl,{label:(0,o.__)("Allow Download","lcp"),checked:w,onChange:t=>e({allowDownload:t})}),w&&(0,A.jsx)(s.TextControl,{type:"number",label:(0,o.__)("Max Download Width (px)","lcp"),value:parseInt(x),onChange:t=>e({downloadMaxWidth:`${t}px`}),min:100,max:5e3}),(0,A.jsx)(s.ToggleControl,{label:(0,o.__)("Show Sorting Options","lcp"),checked:_,onChange:t=>e({showSorting:t})}),(0,A.jsx)(s.ToggleControl,{label:(0,o.__)("Show Filtering Options","lcp"),checked:C,onChange:t=>e({showFiltering:t})})]}):void 0})}),w&&(0,A.jsx)("div",{className:"lcp-bar-graph-toolbar",children:(0,A.jsx)(s.Button,{isPrimary:!0,onClick:()=>{const t=document.querySelector(".bar-graph svg");if(!t)return;const e=document.createElement("canvas"),n=(new XMLSerializer).serializeToString(t),r=new Blob([n],{type:"image/svg+xml;charset=utf-8"}),i=window.URL||window.webkitURL||window,o=i.createObjectURL(r),a=new Image;a.onload=()=>{e.width=t.width.baseVal.value,e.height=t.height.baseVal.value;const n=e.getContext("2d");n.fillStyle=u,n.fillRect(0,0,e.width,e.height),n.drawImage(a,0,0),e.toBlob((t=>{const e=URL.createObjectURL(t),n=document.createElement("a");n.href=e,n.download="bar-graph.png",document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(e),i.revokeObjectURL(o)}),"image/png")},a.src=o},icon:"download",children:(0,o.__)("Download Graph","lcp")})}),v&&Object.keys(v).length>0?(0,A.jsx)(A.Fragment,{children:(0,A.jsx)(ea,{data:v,width:r,height:n,enableXZoom:P,backgroundColor:u,defaultBarColor:i,barOpacity:c,showGridX:D,showGridY:h,yGridColor:d,xGridColor:f,xGridWidth:p,yGridWidth:g,title:y?b:"",showBarValues:S,xAxisLabel:O,yAxisLabel:T,colorSource:E,customColors:I,enableHierarchicalView:k,enableStackedBars:M,selectedParentId:j,enableBarPopovers:N,setAttributes:e})}):(0,A.jsx)("div",{className:"lcp-bar-graph-placeholder",style:{height:n,width:r,backgroundColor:u,display:"flex",alignItems:"center",justifyContent:"center",border:"2px dashed #ccc",borderRadius:"4px",color:"#666"},children:(0,o.__)("Please add data using the Data Settings panel","lcp")})]})},save:function({attributes:t}){const{chartHeight:e,backgroundColor:n}=t;return(0,A.jsx)("div",{...a.useBlockProps.save(),children:(0,A.jsx)("div",{className:"lcp-bar-graph",style:{height:e,backgroundColor:n}})})}})},792:t=>{t.exports=function t(e,n){if(e===n)return!0;if(e&&n&&"object"==typeof e&&"object"==typeof n){if(e.constructor!==n.constructor)return!1;var r,i,o;if(Array.isArray(e)){if((r=e.length)!=n.length)return!1;for(i=r;0!=i--;)if(!t(e[i],n[i]))return!1;return!0}if(e.constructor===RegExp)return e.source===n.source&&e.flags===n.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===n.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===n.toString();if((r=(o=Object.keys(e)).length)!==Object.keys(n).length)return!1;for(i=r;0!=i--;)if(!Object.prototype.hasOwnProperty.call(n,o[i]))return!1;for(i=r;0!=i--;){var a=o[i];if(!t(e[a],n[a]))return!1}return!0}return e!=e&&n!=n}}},n={};function r(t){var i=n[t];if(void 0!==i)return i.exports;var o=n[t]={exports:{}};return e[t](o,o.exports,r),o.exports}r.m=e,t=[],r.O=(e,n,i,o)=>{if(!n){var a=1/0;for(u=0;u=o)&&Object.keys(r.O).every((t=>r.O[t](n[l])))?n.splice(l--,1):(s=!1,o0&&t[u-1][2]>o;u--)t[u]=t[u-1];t[u]=[n,i,o]},r.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return r.d(e,{a:e}),e},r.d=(t,e)=>{for(var n in e)r.o(e,n)&&!r.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},(()=>{var t={57:0,350:0};r.O.j=e=>0===t[e];var e=(e,n)=>{var i,o,[a,s,l]=n,c=0;if(a.some((e=>0!==t[e]))){for(i in s)r.o(s,i)&&(r.m[i]=s[i]);if(l)var u=l(r)}for(e&&e(n);cr(845)));i=r.O(i)})();