@gouvfr-lasuite/ui-kit 0.4.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -98,5 +98,5 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
98
98
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function r8(t,e){if(t){if(typeof t=="string")return jc(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);if(n==="Object"&&t.constructor&&(n=t.constructor.name),n==="Map"||n==="Set")return Array.from(t);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return jc(t,e)}}function jc(t,e){(e==null||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function i8(t,e){var n=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(n!=null){var r=[],i=!0,o=!1,l,a;try{for(n=n.call(t);!(i=(l=n.next()).done)&&(r.push(l.value),!(e&&r.length===e));i=!0);}catch(s){o=!0,a=s}finally{try{!i&&n.return!=null&&n.return()}finally{if(o)throw a}}return r}}function o8(t){if(Array.isArray(t))return t}function l8(t,e,n){var r=pn(),i=e8(t,e),o=Y$(t);sn(function(){var a=d$(o,i,r),s=t8(a,2),u=s[0],d=s[1];return e.receiveHandlerId(u),n.receiveHandlerId(u),d},[r,e,i,n,o.map(function(l){return l.toString()}).join("|")])}function a8(){var t=pn();return c.useMemo(function(){return new Q3(t)},[t])}function s8(t){var e=pn(),n=c.useMemo(function(){return new c$(e.getBackend())},[e]);return sn(function(){return n.dropTargetOptions=t||null,n.reconnect(),function(){return n.disconnectDropTarget()}},[t]),n}function u8(t){return c.useMemo(function(){return t.hooks.dropTarget()},[t])}function ap(t,e){var n=ip(t,e),r=a8(),i=s8(n.options);return l8(n,r,i),[lp(n.collect,r,i),u8(i)]}function c8(t,e){return p8(t)||h8(t,e)||f8(t,e)||d8()}function d8(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
99
99
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function f8(t,e){if(t){if(typeof t=="string")return Hc(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);if(n==="Object"&&t.constructor&&(n=t.constructor.name),n==="Map"||n==="Set")return Array.from(t);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Hc(t,e)}}function Hc(t,e){(e==null||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function h8(t,e){var n=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(n!=null){var r=[],i=!0,o=!1,l,a;try{for(n=n.call(t);!(i=(l=n.next()).done)&&(r.push(l.value),!(e&&r.length===e));i=!0);}catch(s){o=!0,a=s}finally{try{!i&&n.return!=null&&n.return()}finally{if(o)throw a}}return r}}function p8(t){if(Array.isArray(t))return t}function g8(t){var e=pn(),n=e.getMonitor(),r=op(n,t),i=c8(r,2),o=i[0],l=i[1];return c.useEffect(function(){return n.subscribeToOffsetChange(l)}),c.useEffect(function(){return n.subscribeToStateChange(l)}),o}function sp(t){var e=null,n=function(){return e==null&&(e=t()),e};return n}function v8(t,e){return t.filter(function(n){return n!==e})}function m8(t,e){var n=new Set,r=function(l){return n.add(l)};t.forEach(r),e.forEach(r);var i=[];return n.forEach(function(o){return i.push(o)}),i}function b8(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function y8(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function $8(t,e,n){return y8(t.prototype,e),t}function zc(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}var S8=function(){function t(e){b8(this,t),zc(this,"entered",[]),zc(this,"isNodeInDocument",void 0),this.isNodeInDocument=e}return $8(t,[{key:"enter",value:function(n){var r=this,i=this.entered.length,o=function(a){return r.isNodeInDocument(a)&&(!a.contains||a.contains(n))};return this.entered=m8(this.entered.filter(o),[n]),i===0&&this.entered.length>0}},{key:"leave",value:function(n){var r=this.entered.length;return this.entered=v8(this.entered.filter(this.isNodeInDocument),n),r>0&&this.entered.length===0}},{key:"reset",value:function(){this.entered=[]}}]),t}(),w8=sp(function(){return/firefox/i.test(navigator.userAgent)}),up=sp(function(){return!!window.safari});function C8(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function E8(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function x8(t,e,n){return E8(t.prototype,e),t}function hr(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}var Bc=function(){function t(e,n){C8(this,t),hr(this,"xs",void 0),hr(this,"ys",void 0),hr(this,"c1s",void 0),hr(this,"c2s",void 0),hr(this,"c3s",void 0);for(var r=e.length,i=[],o=0;o<r;o++)i.push(o);i.sort(function(h,L){return e[h]<e[L]?-1:1});for(var l=[],a=[],s,u,d=0;d<r-1;d++)s=e[d+1]-e[d],u=n[d+1]-n[d],l.push(s),a.push(u/s);for(var f=[a[0]],v=0;v<l.length-1;v++){var g=a[v],$=a[v+1];if(g*$<=0)f.push(0);else{s=l[v];var p=l[v+1],b=s+p;f.push(3*b/((b+p)/g+(b+s)/$))}}f.push(a[a.length-1]);for(var m=[],C=[],S,D=0;D<f.length-1;D++){S=a[D];var x=f[D],T=1/l[D],I=x+f[D+1]-S-S;m.push((S-x-I)*T),C.push(I*T*T)}this.xs=e,this.ys=n,this.c1s=f,this.c2s=m,this.c3s=C}return x8(t,[{key:"interpolate",value:function(n){var r=this.xs,i=this.ys,o=this.c1s,l=this.c2s,a=this.c3s,s=r.length-1;if(n===r[s])return i[s];for(var u=0,d=a.length-1,f;u<=d;){f=Math.floor(.5*(u+d));var v=r[f];if(v<n)u=f+1;else if(v>n)d=f-1;else return i[f]}s=Math.max(0,d);var g=n-r[s],$=g*g;return i[s]+o[s]*g+l[s]*$+a[s]*g*$}}]),t}(),P8=1;function cp(t){var e=t.nodeType===P8?t:t.parentElement;if(!e)return null;var n=e.getBoundingClientRect(),r=n.top,i=n.left;return{x:i,y:r}}function ci(t){return{x:t.clientX,y:t.clientY}}function T8(t){var e;return t.nodeName==="IMG"&&(w8()||!((e=document.documentElement)!==null&&e!==void 0&&e.contains(t)))}function D8(t,e,n,r){var i=t?e.width:n,o=t?e.height:r;return up()&&t&&(o/=window.devicePixelRatio,i/=window.devicePixelRatio),{dragPreviewWidth:i,dragPreviewHeight:o}}function I8(t,e,n,r,i){var o=T8(e),l=o?t:e,a=cp(l),s={x:n.x-a.x,y:n.y-a.y},u=t.offsetWidth,d=t.offsetHeight,f=r.anchorX,v=r.anchorY,g=D8(o,e,u,d),$=g.dragPreviewWidth,p=g.dragPreviewHeight,b=function(){var I=new Bc([0,.5,1],[s.y,s.y/d*p,s.y+p-d]),h=I.interpolate(v);return up()&&o&&(h+=(window.devicePixelRatio-1)*p),h},m=function(){var I=new Bc([0,.5,1],[s.x,s.x/u*$,s.x+$-u]);return I.interpolate(f)},C=i.offsetX,S=i.offsetY,D=C===0||C,x=S===0||S;return{x:D?C:m(),y:x?S:b()}}var dp="__NATIVE_FILE__",fp="__NATIVE_URL__",hp="__NATIVE_TEXT__",pp="__NATIVE_HTML__";const Vc=Object.freeze(Object.defineProperty({__proto__:null,FILE:dp,HTML:pp,TEXT:hp,URL:fp},Symbol.toStringTag,{value:"Module"}));function pl(t,e,n){var r=e.reduce(function(i,o){return i||t.getData(o)},"");return r??n}var Pn;function di(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}var ha=(Pn={},di(Pn,dp,{exposeProperties:{files:function(e){return Array.prototype.slice.call(e.files)},items:function(e){return e.items},dataTransfer:function(e){return e}},matchesTypes:["Files"]}),di(Pn,pp,{exposeProperties:{html:function(e,n){return pl(e,n,"")},dataTransfer:function(e){return e}},matchesTypes:["Html","text/html"]}),di(Pn,fp,{exposeProperties:{urls:function(e,n){return pl(e,n,"").split(`
100
100
  `)},dataTransfer:function(e){return e}},matchesTypes:["Url","text/uri-list"]}),di(Pn,hp,{exposeProperties:{text:function(e,n){return pl(e,n,"")},dataTransfer:function(e){return e}},matchesTypes:["Text","text/plain"]}),Pn);function O8(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function _8(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function k8(t,e,n){return _8(t.prototype,e),t}function Uc(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}var L8=function(){function t(e){O8(this,t),Uc(this,"item",void 0),Uc(this,"config",void 0),this.config=e,this.item={},this.initializeExposedProperties()}return k8(t,[{key:"initializeExposedProperties",value:function(){var n=this;Object.keys(this.config.exposeProperties).forEach(function(r){Object.defineProperty(n.item,r,{configurable:!0,enumerable:!0,get:function(){return console.warn(`Browser doesn't allow reading "`.concat(r,'" until the drop event.')),null}})})}},{key:"loadDataTransfer",value:function(n){var r=this;if(n){var i={};Object.keys(this.config.exposeProperties).forEach(function(o){i[o]={value:r.config.exposeProperties[o](n,r.config.matchesTypes),configurable:!0,enumerable:!0}}),Object.defineProperties(this.item,i)}}},{key:"canDrag",value:function(){return!0}},{key:"beginDrag",value:function(){return this.item}},{key:"isDragging",value:function(n,r){return r===n.getSourceId()}},{key:"endDrag",value:function(){}}]),t}();function M8(t,e){var n=new L8(ha[t]);return n.loadDataTransfer(e),n}function gl(t){if(!t)return null;var e=Array.prototype.slice.call(t.types||[]);return Object.keys(ha).filter(function(n){var r=ha[n].matchesTypes;return r.some(function(i){return e.indexOf(i)>-1})})[0]||null}function N8(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function R8(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function A8(t,e,n){return R8(t.prototype,e),t}function vl(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}var K8=function(){function t(e,n){N8(this,t),vl(this,"ownerDocument",null),vl(this,"globalContext",void 0),vl(this,"optionsArgs",void 0),this.globalContext=e,this.optionsArgs=n}return A8(t,[{key:"window",get:function(){if(this.globalContext)return this.globalContext;if(typeof window<"u")return window}},{key:"document",get:function(){var n;return(n=this.globalContext)!==null&&n!==void 0&&n.document?this.globalContext.document:this.window?this.window.document:void 0}},{key:"rootElement",get:function(){var n;return((n=this.optionsArgs)===null||n===void 0?void 0:n.rootElement)||this.window}}]),t}();function Wc(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Gc(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Wc(Object(n),!0).forEach(function(r){ne(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Wc(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function F8(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function j8(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function H8(t,e,n){return j8(t.prototype,e),t}function ne(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}var z8=function(){function t(e,n,r){var i=this;F8(this,t),ne(this,"options",void 0),ne(this,"actions",void 0),ne(this,"monitor",void 0),ne(this,"registry",void 0),ne(this,"enterLeaveCounter",void 0),ne(this,"sourcePreviewNodes",new Map),ne(this,"sourcePreviewNodeOptions",new Map),ne(this,"sourceNodes",new Map),ne(this,"sourceNodeOptions",new Map),ne(this,"dragStartSourceIds",null),ne(this,"dropTargetIds",[]),ne(this,"dragEnterTargetIds",[]),ne(this,"currentNativeSource",null),ne(this,"currentNativeHandle",null),ne(this,"currentDragSourceNode",null),ne(this,"altKeyPressed",!1),ne(this,"mouseMoveTimeoutTimer",null),ne(this,"asyncEndDragFrameId",null),ne(this,"dragOverTargetIds",null),ne(this,"lastClientOffset",null),ne(this,"hoverRafId",null),ne(this,"getSourceClientOffset",function(o){var l=i.sourceNodes.get(o);return l&&cp(l)||null}),ne(this,"endDragNativeItem",function(){i.isDraggingNativeItem()&&(i.actions.endDrag(),i.currentNativeHandle&&i.registry.removeSource(i.currentNativeHandle),i.currentNativeHandle=null,i.currentNativeSource=null)}),ne(this,"isNodeInDocument",function(o){return!!(o&&i.document&&i.document.body&&i.document.body.contains(o))}),ne(this,"endDragIfSourceWasRemovedFromDOM",function(){var o=i.currentDragSourceNode;o==null||i.isNodeInDocument(o)||i.clearCurrentDragSourceNode()&&i.monitor.isDragging()&&i.actions.endDrag()}),ne(this,"handleTopDragStartCapture",function(){i.clearCurrentDragSourceNode(),i.dragStartSourceIds=[]}),ne(this,"handleTopDragStart",function(o){if(!o.defaultPrevented){var l=i.dragStartSourceIds;i.dragStartSourceIds=null;var a=ci(o);i.monitor.isDragging()&&i.actions.endDrag(),i.actions.beginDrag(l||[],{publishSource:!1,getSourceClientOffset:i.getSourceClientOffset,clientOffset:a});var s=o.dataTransfer,u=gl(s);if(i.monitor.isDragging()){if(s&&typeof s.setDragImage=="function"){var d=i.monitor.getSourceId(),f=i.sourceNodes.get(d),v=i.sourcePreviewNodes.get(d)||f;if(v){var g=i.getCurrentSourcePreviewNodeOptions(),$=g.anchorX,p=g.anchorY,b=g.offsetX,m=g.offsetY,C={anchorX:$,anchorY:p},S={offsetX:b,offsetY:m},D=I8(f,v,a,C,S);s.setDragImage(v,D.x,D.y)}}try{s==null||s.setData("application/json",{})}catch{}i.setCurrentDragSourceNode(o.target);var x=i.getCurrentSourcePreviewNodeOptions(),T=x.captureDraggingState;T?i.actions.publishDragSource():setTimeout(function(){return i.actions.publishDragSource()},0)}else if(u)i.beginDragNativeItem(u);else{if(s&&!s.types&&(o.target&&!o.target.hasAttribute||!o.target.hasAttribute("draggable")))return;o.preventDefault()}}}),ne(this,"handleTopDragEndCapture",function(){i.clearCurrentDragSourceNode()&&i.monitor.isDragging()&&i.actions.endDrag()}),ne(this,"handleTopDragEnterCapture",function(o){i.dragEnterTargetIds=[];var l=i.enterLeaveCounter.enter(o.target);if(!(!l||i.monitor.isDragging())){var a=o.dataTransfer,s=gl(a);s&&i.beginDragNativeItem(s,a)}}),ne(this,"handleTopDragEnter",function(o){var l=i.dragEnterTargetIds;if(i.dragEnterTargetIds=[],!!i.monitor.isDragging()){i.altKeyPressed=o.altKey,l.length>0&&i.actions.hover(l,{clientOffset:ci(o)});var a=l.some(function(s){return i.monitor.canDropOnTarget(s)});a&&(o.preventDefault(),o.dataTransfer&&(o.dataTransfer.dropEffect=i.getCurrentDropEffect()))}}),ne(this,"handleTopDragOverCapture",function(){i.dragOverTargetIds=[]}),ne(this,"handleTopDragOver",function(o){var l=i.dragOverTargetIds;if(i.dragOverTargetIds=[],!i.monitor.isDragging()){o.preventDefault(),o.dataTransfer&&(o.dataTransfer.dropEffect="none");return}i.altKeyPressed=o.altKey,i.lastClientOffset=ci(o),i.hoverRafId===null&&typeof requestAnimationFrame<"u"&&(i.hoverRafId=requestAnimationFrame(function(){i.monitor.isDragging()&&i.actions.hover(l||[],{clientOffset:i.lastClientOffset}),i.hoverRafId=null}));var a=(l||[]).some(function(s){return i.monitor.canDropOnTarget(s)});a?(o.preventDefault(),o.dataTransfer&&(o.dataTransfer.dropEffect=i.getCurrentDropEffect())):i.isDraggingNativeItem()?o.preventDefault():(o.preventDefault(),o.dataTransfer&&(o.dataTransfer.dropEffect="none"))}),ne(this,"handleTopDragLeaveCapture",function(o){i.isDraggingNativeItem()&&o.preventDefault();var l=i.enterLeaveCounter.leave(o.target);l&&i.isDraggingNativeItem()&&setTimeout(function(){return i.endDragNativeItem()},0)}),ne(this,"handleTopDropCapture",function(o){if(i.dropTargetIds=[],i.isDraggingNativeItem()){var l;o.preventDefault(),(l=i.currentNativeSource)===null||l===void 0||l.loadDataTransfer(o.dataTransfer)}else gl(o.dataTransfer)&&o.preventDefault();i.enterLeaveCounter.reset()}),ne(this,"handleTopDrop",function(o){var l=i.dropTargetIds;i.dropTargetIds=[],i.actions.hover(l,{clientOffset:ci(o)}),i.actions.drop({dropEffect:i.getCurrentDropEffect()}),i.isDraggingNativeItem()?i.endDragNativeItem():i.monitor.isDragging()&&i.actions.endDrag()}),ne(this,"handleSelectStart",function(o){var l=o.target;typeof l.dragDrop=="function"&&(l.tagName==="INPUT"||l.tagName==="SELECT"||l.tagName==="TEXTAREA"||l.isContentEditable||(o.preventDefault(),l.dragDrop()))}),this.options=new K8(n,r),this.actions=e.getActions(),this.monitor=e.getMonitor(),this.registry=e.getRegistry(),this.enterLeaveCounter=new S8(this.isNodeInDocument)}return H8(t,[{key:"profile",value:function(){var n,r;return{sourcePreviewNodes:this.sourcePreviewNodes.size,sourcePreviewNodeOptions:this.sourcePreviewNodeOptions.size,sourceNodeOptions:this.sourceNodeOptions.size,sourceNodes:this.sourceNodes.size,dragStartSourceIds:((n=this.dragStartSourceIds)===null||n===void 0?void 0:n.length)||0,dropTargetIds:this.dropTargetIds.length,dragEnterTargetIds:this.dragEnterTargetIds.length,dragOverTargetIds:((r=this.dragOverTargetIds)===null||r===void 0?void 0:r.length)||0}}},{key:"window",get:function(){return this.options.window}},{key:"document",get:function(){return this.options.document}},{key:"rootElement",get:function(){return this.options.rootElement}},{key:"setup",value:function(){var n=this.rootElement;if(n!==void 0){if(n.__isReactDndBackendSetUp)throw new Error("Cannot have two HTML5 backends at the same time.");n.__isReactDndBackendSetUp=!0,this.addEventListeners(n)}}},{key:"teardown",value:function(){var n=this.rootElement;if(n!==void 0&&(n.__isReactDndBackendSetUp=!1,this.removeEventListeners(this.rootElement),this.clearCurrentDragSourceNode(),this.asyncEndDragFrameId)){var r;(r=this.window)===null||r===void 0||r.cancelAnimationFrame(this.asyncEndDragFrameId)}}},{key:"connectDragPreview",value:function(n,r,i){var o=this;return this.sourcePreviewNodeOptions.set(n,i),this.sourcePreviewNodes.set(n,r),function(){o.sourcePreviewNodes.delete(n),o.sourcePreviewNodeOptions.delete(n)}}},{key:"connectDragSource",value:function(n,r,i){var o=this;this.sourceNodes.set(n,r),this.sourceNodeOptions.set(n,i);var l=function(u){return o.handleDragStart(u,n)},a=function(u){return o.handleSelectStart(u)};return r.setAttribute("draggable","true"),r.addEventListener("dragstart",l),r.addEventListener("selectstart",a),function(){o.sourceNodes.delete(n),o.sourceNodeOptions.delete(n),r.removeEventListener("dragstart",l),r.removeEventListener("selectstart",a),r.setAttribute("draggable","false")}}},{key:"connectDropTarget",value:function(n,r){var i=this,o=function(u){return i.handleDragEnter(u,n)},l=function(u){return i.handleDragOver(u,n)},a=function(u){return i.handleDrop(u,n)};return r.addEventListener("dragenter",o),r.addEventListener("dragover",l),r.addEventListener("drop",a),function(){r.removeEventListener("dragenter",o),r.removeEventListener("dragover",l),r.removeEventListener("drop",a)}}},{key:"addEventListeners",value:function(n){n.addEventListener&&(n.addEventListener("dragstart",this.handleTopDragStart),n.addEventListener("dragstart",this.handleTopDragStartCapture,!0),n.addEventListener("dragend",this.handleTopDragEndCapture,!0),n.addEventListener("dragenter",this.handleTopDragEnter),n.addEventListener("dragenter",this.handleTopDragEnterCapture,!0),n.addEventListener("dragleave",this.handleTopDragLeaveCapture,!0),n.addEventListener("dragover",this.handleTopDragOver),n.addEventListener("dragover",this.handleTopDragOverCapture,!0),n.addEventListener("drop",this.handleTopDrop),n.addEventListener("drop",this.handleTopDropCapture,!0))}},{key:"removeEventListeners",value:function(n){n.removeEventListener&&(n.removeEventListener("dragstart",this.handleTopDragStart),n.removeEventListener("dragstart",this.handleTopDragStartCapture,!0),n.removeEventListener("dragend",this.handleTopDragEndCapture,!0),n.removeEventListener("dragenter",this.handleTopDragEnter),n.removeEventListener("dragenter",this.handleTopDragEnterCapture,!0),n.removeEventListener("dragleave",this.handleTopDragLeaveCapture,!0),n.removeEventListener("dragover",this.handleTopDragOver),n.removeEventListener("dragover",this.handleTopDragOverCapture,!0),n.removeEventListener("drop",this.handleTopDrop),n.removeEventListener("drop",this.handleTopDropCapture,!0))}},{key:"getCurrentSourceNodeOptions",value:function(){var n=this.monitor.getSourceId(),r=this.sourceNodeOptions.get(n);return Gc({dropEffect:this.altKeyPressed?"copy":"move"},r||{})}},{key:"getCurrentDropEffect",value:function(){return this.isDraggingNativeItem()?"copy":this.getCurrentSourceNodeOptions().dropEffect}},{key:"getCurrentSourcePreviewNodeOptions",value:function(){var n=this.monitor.getSourceId(),r=this.sourcePreviewNodeOptions.get(n);return Gc({anchorX:.5,anchorY:.5,captureDraggingState:!1},r||{})}},{key:"isDraggingNativeItem",value:function(){var n=this.monitor.getItemType();return Object.keys(Vc).some(function(r){return Vc[r]===n})}},{key:"beginDragNativeItem",value:function(n,r){this.clearCurrentDragSourceNode(),this.currentNativeSource=M8(n,r),this.currentNativeHandle=this.registry.addSource(n,this.currentNativeSource),this.actions.beginDrag([this.currentNativeHandle])}},{key:"setCurrentDragSourceNode",value:function(n){var r=this;this.clearCurrentDragSourceNode(),this.currentDragSourceNode=n;var i=1e3;this.mouseMoveTimeoutTimer=setTimeout(function(){var o;return(o=r.rootElement)===null||o===void 0?void 0:o.addEventListener("mousemove",r.endDragIfSourceWasRemovedFromDOM,!0)},i)}},{key:"clearCurrentDragSourceNode",value:function(){if(this.currentDragSourceNode){if(this.currentDragSourceNode=null,this.rootElement){var n;(n=this.window)===null||n===void 0||n.clearTimeout(this.mouseMoveTimeoutTimer||void 0),this.rootElement.removeEventListener("mousemove",this.endDragIfSourceWasRemovedFromDOM,!0)}return this.mouseMoveTimeoutTimer=null,!0}return!1}},{key:"handleDragStart",value:function(n,r){n.defaultPrevented||(this.dragStartSourceIds||(this.dragStartSourceIds=[]),this.dragStartSourceIds.unshift(r))}},{key:"handleDragEnter",value:function(n,r){this.dragEnterTargetIds.unshift(r)}},{key:"handleDragOver",value:function(n,r){this.dragOverTargetIds===null&&(this.dragOverTargetIds=[]),this.dragOverTargetIds.unshift(r)}},{key:"handleDrop",value:function(n,r){this.dropTargetIds.unshift(r)}}]),t}(),fi;function B8(){return fi||(fi=new Image,fi.src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="),fi}var V8=function(e,n,r){return new z8(e,n,r)};function U8(t){const e=Le(),n=e.selectedIds,[r,i,o]=q$(()=>({canDrag:()=>t.isDraggable,type:"NODE",item:()=>{const l=e.isSelected(t.id)?Array.from(n):[t.id];return e.dispatch(Jn.dragStart(t.id,l)),{id:t.id,dragIds:l}},end:()=>{e.hideCursor(),e.dispatch(Jn.dragEnd())}}),[n,t]);return c.useEffect(()=>{o(B8())},[o]),i}function W8(t,e){const n=t.getBoundingClientRect(),r=e.x-Math.round(n.x),i=e.y-Math.round(n.y),o=n.height,l=i<o/2,a=!l,s=o/4,u=i>s&&i<o-s;return{x:r,inTopHalf:l,inBottomHalf:a,inMiddle:u,atTop:!u&&l,atBottom:!u&&a}}function G8(t,e,n,r){return t?t.isInternal?r.atTop?[e,t]:r.inMiddle?[t,t]:[t,n]:r.inTopHalf?[e,t]:[t,n]:[e,null]}function hi(t,e){return{parentId:t||null,index:e}}function Tn(t,e){return{type:"line",index:t,level:e}}function q8(t){return{type:"highlight",id:t}}function ml(t,e){var n;let r=t;for(;r.parent&&r.level>e;)r=r.parent;const i=((n=r.parent)===null||n===void 0?void 0:n.id)||null,o=Fh(r)+1;return{parentId:i,index:o}}function gp(t){var e;const n=W8(t.element,t.offset),r=t.indent,i=Math.round(Math.max(0,n.x-r)/r),{node:o,nextNode:l,prevNode:a}=t,[s,u]=G8(o,a,l,n);if(o&&o.isInternal&&n.inMiddle)return{drop:hi(o.id,null),cursor:q8(o.id)};if(!s)return{drop:hi((e=u==null?void 0:u.parent)===null||e===void 0?void 0:e.id,0),cursor:Tn(0,0)};if(Nh(s)){const d=yi(i,(u==null?void 0:u.level)||0,s.level);return{drop:ml(s,d),cursor:Tn(s.rowIndex+1,d)}}if(Rh(s)){const d=yi(i,(u==null?void 0:u.level)||0,s.level);return{drop:ml(s,d),cursor:Tn(s.rowIndex+1,d)}}if(Ah(s)){const d=yi(i,0,s.level+1);return d>s.level?{drop:hi(s.id,0),cursor:Tn(s.rowIndex+1,d)}:{drop:ml(s,d),cursor:Tn(s.rowIndex+1,d)}}return{drop:hi(s==null?void 0:s.id,0),cursor:Tn(s.rowIndex+1,s.level+1)}}function Y8(t,e){const n=Le(),[r,i]=ap(()=>({accept:"NODE",canDrop:()=>n.canDrop(),hover:(o,l)=>{const a=l.getClientOffset();if(!t.current||!a)return;const{cursor:s,drop:u}=gp({element:t.current,offset:a,indent:n.indent,node:e,prevNode:e.prev,nextNode:e.next});u&&n.dispatch(Jn.hovering(u.parentId,u.index)),l.canDrop()?s&&n.showCursor(s):n.hideCursor()},drop:(o,l)=>{if(!l.canDrop())return null;let{parentId:a,index:s,dragIds:u}=n.state.dnd;Vh(n.props.onMove,{dragIds:u,parentId:a===Lr?null:a,index:s===null?0:s,dragNodes:n.dragNodes,parentNode:n.get(a)}),n.open(a)}}),[e,t.current,n.props]);return i}function X8(t){const e=Le(),n=e.at(t);if(!n)throw new Error(`Could not find node for index: ${t}`);return c.useMemo(()=>{const r=n.clone();return e.visibleNodes[t]=r,r},[...Object.values(n.state),n])}const Z8=c.memo(function({index:e,style:n}){Mh(),m4();const r=Le(),i=X8(e),o=c.useRef(null),l=U8(i),a=Y8(o,i),s=c.useCallback(p=>{o.current=p,a(p)},[a]),u=r.indent*i.level,d=c.useMemo(()=>({paddingLeft:u}),[u]),f=c.useMemo(()=>{var p,b;return Object.assign(Object.assign({},n),{top:parseFloat(n.top)+((b=(p=r.props.padding)!==null&&p!==void 0?p:r.props.paddingTop)!==null&&b!==void 0?b:0)})},[n,r.props.padding,r.props.paddingTop]),v={role:"treeitem","aria-level":i.level+1,"aria-selected":i.isSelected,"aria-expanded":i.isOpen,style:f,tabIndex:-1,className:r.props.rowClassName};c.useEffect(()=>{var p;!i.isEditing&&i.isFocused&&((p=o.current)===null||p===void 0||p.focus({preventScroll:!0}))},[i.isEditing,i.isFocused,o.current]);const g=r.renderNode,$=r.renderRow;return w.jsx($,{node:i,innerRef:s,attrs:v,children:w.jsx(g,{node:i,tree:r,style:d,dragHandle:l})})});let bl="",qc=null;function vp(){Mh();const t=Le();return w.jsx("div",{role:"tree",style:{height:t.height,width:t.width,minHeight:0,minWidth:0},onContextMenu:t.props.onContextMenu,onClick:t.props.onClick,tabIndex:0,onFocus:e=>{e.currentTarget.contains(e.relatedTarget)||t.onFocus()},onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||t.onBlur()},onKeyDown:e=>{var n;if(t.isEditing)return;if(e.key==="Backspace"){if(!t.props.onDelete)return;const i=Array.from(t.selectedIds);if(i.length>1){let o=t.mostRecentNode;for(;o&&o.isSelected;)o=o.nextSibling;o||(o=t.lastNode),t.focus(o,{scroll:!1}),t.delete(Array.from(i))}else{const o=t.focusedNode;if(o){const l=o.nextSibling,a=o.parent;t.focus(l||a,{scroll:!1}),t.delete(o)}}return}if(e.key==="Tab"&&!e.shiftKey){e.preventDefault(),jh(e.currentTarget);return}if(e.key==="Tab"&&e.shiftKey){e.preventDefault(),Hh(e.currentTarget);return}if(e.key==="ArrowDown"){e.preventDefault();const i=t.nextNode;if(e.metaKey){t.select(t.focusedNode),t.activate(t.focusedNode);return}else if(!e.shiftKey||t.props.disableMultiSelection){t.focus(i);return}else{if(!i)return;const o=t.focusedNode;o?o.isSelected?t.selectContiguous(i):t.selectMulti(i):t.focus(t.firstNode);return}}if(e.key==="ArrowUp"){e.preventDefault();const i=t.prevNode;if(!e.shiftKey||t.props.disableMultiSelection){t.focus(i);return}else{if(!i)return;const o=t.focusedNode;o?o.isSelected?t.selectContiguous(i):t.selectMulti(i):t.focus(t.lastNode);return}}if(e.key==="ArrowRight"){const i=t.focusedNode;if(!i)return;i.isInternal&&i.isOpen?t.focus(t.nextNode):i.isInternal&&t.open(i.id);return}if(e.key==="ArrowLeft"){const i=t.focusedNode;if(!i||i.isRoot)return;i.isInternal&&i.isOpen?t.close(i.id):!((n=i.parent)===null||n===void 0)&&n.isRoot||t.focus(i.parent);return}if(e.key==="a"&&e.metaKey&&!t.props.disableMultiSelection){e.preventDefault(),t.selectAll();return}if(e.key==="a"&&!e.metaKey&&t.props.onCreate){t.createLeaf();return}if(e.key==="A"&&!e.metaKey){if(!t.props.onCreate)return;t.createInternal();return}if(e.key==="Home"){e.preventDefault(),t.focus(t.firstNode);return}if(e.key==="End"){e.preventDefault(),t.focus(t.lastNode);return}if(e.key==="Enter"){const i=t.focusedNode;if(!i||!i.isEditable||!t.props.onRename)return;setTimeout(()=>{i&&t.edit(i)});return}if(e.key===" "){e.preventDefault();const i=t.focusedNode;if(!i)return;i.isLeaf?(i.select(),i.activate()):i.toggle();return}if(e.key==="*"){const i=t.focusedNode;if(!i)return;t.openSiblings(i);return}if(e.key==="PageUp"){e.preventDefault(),t.pageUp();return}e.key==="PageDown"&&(e.preventDefault(),t.pageDown()),clearTimeout(qc),bl+=e.key,qc=setTimeout(()=>{bl=""},600);const r=t.visibleNodes.find(i=>{const o=i.data.name;return typeof o=="string"?o.toLowerCase().startsWith(bl):!1});r&&t.focus(r.id)},children:w.jsx(e7,{className:t.props.className,outerRef:t.listEl,itemCount:t.visibleNodes.length,height:t.height,width:t.width,itemSize:t.rowHeight,overscanCount:t.overscanCount,itemKey:e=>{var n;return((n=t.visibleNodes[e])===null||n===void 0?void 0:n.id)||e},outerElementType:r7,innerElementType:l7,onScroll:t.props.onScroll,onItemsRendered:t.onItemsRendered.bind(t),ref:t.list,children:Z8})})}function Yc(t){return t.isFiltered?Q8(t.root,t.isMatch.bind(t)):J8(t.root)}function J8(t){const e=[];function n(r){var i;r.level>=0&&e.push(r),r.isOpen&&((i=r.children)===null||i===void 0||i.forEach(n))}return n(t),e.forEach(mp),e}function Q8(t,e){const n={},r=[];function i(l){if(!l.isRoot&&e(l)){n[l.id]=!0;let s=l.parent;for(;s;)n[s.id]=!0,s=s.parent}if(l.children)for(let s of l.children)i(s)}function o(l){var a;l.level>=0&&n[l.id]&&r.push(l),l.isOpen&&((a=l.children)===null||a===void 0||a.forEach(o))}return i(t),o(t),r.forEach(mp),r}function mp(t,e){t.rowIndex=e}const Xc=t=>t.reduce((e,n,r)=>(e[n.id]=r,e),{});var yl=function(t,e,n,r){function i(o){return o instanceof n?o:new n(function(l){l(o)})}return new(n||(n=Promise))(function(o,l){function a(d){try{u(r.next(d))}catch(f){l(f)}}function s(d){try{u(r.throw(d))}catch(f){l(f)}}function u(d){d.done?o(d.value):i(d.value).then(a,s)}u((r=r.apply(t,e||[])).next())})};const{safeRun:ve,identify:ut,identifyNull:We}=C4;class Vn{constructor(e,n,r,i){this.store=e,this.props=n,this.list=r,this.listEl=i,this.visibleStartIndex=0,this.visibleStopIndex=0,this.root=lc(this),this.visibleNodes=Yc(this),this.idToIndex=Xc(this.visibleNodes)}update(e){this.props=e,this.root=lc(this),this.visibleNodes=Yc(this),this.idToIndex=Xc(this.visibleNodes)}dispatch(e){return this.store.dispatch(e)}get state(){return this.store.getState()}get openState(){return this.state.nodes.open.unfiltered}get width(){var e;return(e=this.props.width)!==null&&e!==void 0?e:300}get height(){var e;return(e=this.props.height)!==null&&e!==void 0?e:500}get indent(){var e;return(e=this.props.indent)!==null&&e!==void 0?e:24}get rowHeight(){var e;return(e=this.props.rowHeight)!==null&&e!==void 0?e:24}get overscanCount(){var e;return(e=this.props.overscanCount)!==null&&e!==void 0?e:1}get searchTerm(){return(this.props.searchTerm||"").trim()}get matchFn(){var e;const n=(e=this.props.searchMatch)!==null&&e!==void 0?e:(r,i)=>JSON.stringify(Object.values(r.data)).toLocaleLowerCase().includes(i.toLocaleLowerCase());return r=>n(r,this.searchTerm)}accessChildren(e){var n;const r=this.props.childrenAccessor||"children";return(n=yr(e,r))!==null&&n!==void 0?n:null}accessId(e){const n=this.props.idAccessor||"id",r=yr(e,n);if(!r)throw new Error("Data must contain an 'id' property or props.idAccessor must return a string");return r}get firstNode(){var e;return(e=this.visibleNodes[0])!==null&&e!==void 0?e:null}get lastNode(){var e;return(e=this.visibleNodes[this.visibleNodes.length-1])!==null&&e!==void 0?e:null}get focusedNode(){var e;return(e=this.get(this.state.nodes.focus.id))!==null&&e!==void 0?e:null}get mostRecentNode(){var e;return(e=this.get(this.state.nodes.selection.mostRecent))!==null&&e!==void 0?e:null}get nextNode(){const e=this.indexOf(this.focusedNode);return e===null?null:this.at(e+1)}get prevNode(){const e=this.indexOf(this.focusedNode);return e===null?null:this.at(e-1)}get(e){return e&&e in this.idToIndex&&this.visibleNodes[this.idToIndex[e]]||null}at(e){return this.visibleNodes[e]||null}nodesBetween(e,n){var r;if(e===null||n===null)return[];const i=(r=this.indexOf(e))!==null&&r!==void 0?r:0,o=this.indexOf(n);if(o===null)return[];const l=Math.min(i,o),a=Math.max(i,o);return this.visibleNodes.slice(l,a+1)}indexOf(e){const n=Bh(e);return n?this.idToIndex[n]:null}get editingId(){return this.state.nodes.edit.id}createInternal(){return this.create({type:"internal"})}createLeaf(){return this.create({type:"leaf"})}create(){return yl(this,arguments,void 0,function*(e={}){var n,r;const i=e.parentId===void 0?Gh(this):e.parentId,o=(n=e.index)!==null&&n!==void 0?n:Wh(this),l=(r=e.type)!==null&&r!==void 0?r:"leaf",a=yield ve(this.props.onCreate,{type:l,parentId:i,index:o,parentNode:this.get(i)});a&&(this.focus(a),setTimeout(()=>{this.edit(a).then(()=>{this.select(a),this.activate(a)})}))})}delete(e){return yl(this,void 0,void 0,function*(){if(!e)return;const r=(Array.isArray(e)?e:[e]).map(ut),i=r.map(o=>this.get(o)).filter(o=>!!o);yield ve(this.props.onDelete,{nodes:i,ids:r})})}edit(e){const n=ut(e);return this.resolveEdit({cancelled:!0}),this.scrollTo(n),this.dispatch(ol(n)),new Promise(r=>{Vn.editPromise=r})}submit(e,n){return yl(this,void 0,void 0,function*(){if(!e)return;const r=ut(e);yield ve(this.props.onRename,{id:r,name:n,node:this.get(r)}),this.dispatch(ol(null)),this.resolveEdit({cancelled:!1,value:n}),setTimeout(()=>this.onFocus())})}reset(){this.dispatch(ol(null)),this.resolveEdit({cancelled:!0}),setTimeout(()=>this.onFocus())}activate(e){const n=this.get(We(e));n&&ve(this.props.onActivate,n)}resolveEdit(e){const n=Vn.editPromise;n&&n(e),Vn.editPromise=null}get selectedIds(){return this.state.nodes.selection.ids}get selectedNodes(){let e=[];for(let n of Array.from(this.selectedIds)){const r=this.get(n);r&&e.push(r)}return e}focus(e,n={}){e&&(this.props.selectionFollowsFocus?this.select(e):(this.dispatch(wn(ut(e))),n.scroll!==!1&&this.scrollTo(e),this.focusedNode&&ve(this.props.onFocus,this.focusedNode)))}pageUp(){var e,n;const r=this.visibleStartIndex,o=this.visibleStopIndex-r;let l=(n=(e=this.focusedNode)===null||e===void 0?void 0:e.rowIndex)!==null&&n!==void 0?n:0;l>r?l=r:l=Math.max(r-o,0),this.focus(this.at(l))}pageDown(){var e,n;const r=this.visibleStartIndex,i=this.visibleStopIndex,o=i-r;let l=(n=(e=this.focusedNode)===null||e===void 0?void 0:e.rowIndex)!==null&&n!==void 0?n:0;l<i?l=i:l=Math.min(l+o,this.visibleNodes.length-1),this.focus(this.at(l))}select(e,n={}){if(!e)return;const r=n.focus!==!1,i=ut(e);r&&this.dispatch(wn(i)),this.dispatch(Ue.only(i)),this.dispatch(Ue.anchor(i)),this.dispatch(Ue.mostRecent(i)),this.scrollTo(i,n.align),this.focusedNode&&r&&ve(this.props.onFocus,this.focusedNode),ve(this.props.onSelect,this.selectedNodes)}deselect(e){if(!e)return;const n=ut(e);this.dispatch(Ue.remove(n)),ve(this.props.onSelect,this.selectedNodes)}selectMulti(e){const n=this.get(We(e));n&&(this.dispatch(wn(n.id)),this.dispatch(Ue.add(n.id)),this.dispatch(Ue.anchor(n.id)),this.dispatch(Ue.mostRecent(n.id)),this.scrollTo(n),this.focusedNode&&ve(this.props.onFocus,this.focusedNode),ve(this.props.onSelect,this.selectedNodes))}selectContiguous(e){if(!e)return;const n=ut(e),{anchor:r,mostRecent:i}=this.state.nodes.selection;this.dispatch(wn(n)),this.dispatch(Ue.remove(this.nodesBetween(r,i))),this.dispatch(Ue.add(this.nodesBetween(r,We(n)))),this.dispatch(Ue.mostRecent(n)),this.scrollTo(n),this.focusedNode&&ve(this.props.onFocus,this.focusedNode),ve(this.props.onSelect,this.selectedNodes)}deselectAll(){this.setSelection({ids:[],anchor:null,mostRecent:null}),ve(this.props.onSelect,this.selectedNodes)}selectAll(){var e;this.setSelection({ids:Object.keys(this.idToIndex),anchor:this.firstNode,mostRecent:this.lastNode}),this.dispatch(wn((e=this.lastNode)===null||e===void 0?void 0:e.id)),this.focusedNode&&ve(this.props.onFocus,this.focusedNode),ve(this.props.onSelect,this.selectedNodes)}setSelection(e){var n;const r=new Set((n=e.ids)===null||n===void 0?void 0:n.map(ut)),i=We(e.anchor),o=We(e.mostRecent);this.dispatch(Ue.set({ids:r,anchor:i,mostRecent:o})),ve(this.props.onSelect,this.selectedNodes)}get cursorParentId(){const{cursor:e}=this.state.dnd;switch(e.type){case"highlight":return e.id;default:return null}}get cursorOverFolder(){return this.state.dnd.cursor.type==="highlight"}get dragNodes(){return this.state.dnd.dragIds.map(e=>this.get(e)).filter(e=>!!e)}get dragNode(){return this.get(this.state.nodes.drag.id)}get dragDestinationParent(){return this.get(this.state.nodes.drag.destinationParentId)}get dragDestinationIndex(){return this.state.nodes.drag.destinationIndex}canDrop(){var e;if(this.isFiltered)return!1;const n=(e=this.get(this.state.dnd.parentId))!==null&&e!==void 0?e:this.root,r=this.dragNodes,i=this.props.disableDrop;for(const o of r)if(!o||!n||o.isInternal&&Kh(n,o))return!1;return typeof i=="function"?!i({parentNode:n,dragNodes:this.dragNodes,index:this.state.dnd.index||0}):typeof i=="string"?!n.data[i]:typeof i=="boolean"?!i:!0}hideCursor(){this.dispatch(Jn.cursor({type:"none"}))}showCursor(e){this.dispatch(Jn.cursor(e))}open(e){const n=We(e);n&&(this.isOpen(n)||(this.dispatch(oa.open(n,this.isFiltered)),ve(this.props.onToggle,n)))}close(e){const n=We(e);n&&this.isOpen(n)&&(this.dispatch(oa.close(n,this.isFiltered)),ve(this.props.onToggle,n))}toggle(e){const n=We(e);if(n)return this.isOpen(n)?this.close(n):this.open(n)}openParents(e){const n=We(e);if(!n)return;const r=rs(this.root,n);let i=r==null?void 0:r.parent;for(;i;)this.open(i.id),i=i.parent}openSiblings(e){const n=e.parent;if(!n)this.toggle(e.id);else if(n.children){const r=e.isOpen;for(let i of n.children)i.isInternal&&(r?this.close(i.id):this.open(i.id));this.scrollTo(this.focusedNode)}}openAll(){Vi(this.root,e=>{e.isInternal&&e.open()})}closeAll(){Vi(this.root,e=>{e.isInternal&&e.close()})}scrollTo(e,n="smart"){if(!e)return;const r=ut(e);return this.openParents(r),Uh(()=>r in this.idToIndex).then(()=>{var i;const o=this.idToIndex[r];o!==void 0&&((i=this.list.current)===null||i===void 0||i.scrollToItem(o,n))}).catch(()=>{})}get isEditing(){return this.state.nodes.edit.id!==null}get isFiltered(){var e;return!!(!((e=this.props.searchTerm)===null||e===void 0)&&e.trim())}get hasFocus(){return this.state.nodes.focus.treeFocused}get hasNoSelection(){return this.state.nodes.selection.ids.size===0}get hasOneSelection(){return this.state.nodes.selection.ids.size===1}get hasMultipleSelections(){return this.state.nodes.selection.ids.size>1}isSelected(e){return e?this.state.nodes.selection.ids.has(e):!1}isOpen(e){var n,r,i;if(!e)return!1;if(e===Lr)return!0;const o=(n=this.props.openByDefault)!==null&&n!==void 0?n:!0;return this.isFiltered?(r=this.state.nodes.open.filtered[e])!==null&&r!==void 0?r:!0:(i=this.state.nodes.open.unfiltered[e])!==null&&i!==void 0?i:o}isEditable(e){const n=this.props.disableEdit||(()=>!1);return!yr(e,n)}isDraggable(e){const n=this.props.disableDrag||(()=>!1);return!yr(e,n)}isDragging(e){const n=We(e);return n?this.state.nodes.drag.id===n:!1}isFocused(e){return this.hasFocus&&this.state.nodes.focus.id===e}isMatch(e){return this.matchFn(e)}willReceiveDrop(e){const n=We(e);if(!n)return!1;const{destinationParentId:r,destinationIndex:i}=this.state.nodes.drag;return n===r&&i===null}onFocus(){const e=this.focusedNode||this.firstNode;e&&this.dispatch(wn(e.id))}onBlur(){this.dispatch(L4())}onItemsRendered(e){this.visibleStartIndex=e.visibleStartIndex,this.visibleStopIndex=e.visibleStopIndex}get renderContainer(){return this.props.renderContainer||vp}get renderRow(){return this.props.renderRow||D4}get renderNode(){return this.props.children||I4}get renderDragPreview(){return this.props.renderDragPreview||qh}get renderCursor(){return this.props.renderCursor||T4}}function xe(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 eS=typeof Symbol=="function"&&Symbol.observable||"@@observable",Zc=eS,$l=()=>Math.random().toString(36).substring(7).split("").join("."),tS={INIT:`@@redux/INIT${$l()}`,REPLACE:`@@redux/REPLACE${$l()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${$l()}`},qt=tS;function bp(t){if(typeof t!="object"||t===null)return!1;let e=t;for(;Object.getPrototypeOf(e)!==null;)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e||Object.getPrototypeOf(t)===null}function nS(t){if(t===void 0)return"undefined";if(t===null)return"null";const e=typeof t;switch(e){case"boolean":case"string":case"number":case"symbol":case"function":return e}if(Array.isArray(t))return"array";if(oS(t))return"date";if(iS(t))return"error";const n=rS(t);switch(n){case"Symbol":case"Promise":case"WeakMap":case"WeakSet":case"Map":case"Set":return n}return Object.prototype.toString.call(t).slice(8,-1).toLowerCase().replace(/\s/g,"")}function rS(t){return typeof t.constructor=="function"?t.constructor.name:null}function iS(t){return t instanceof Error||typeof t.message=="string"&&t.constructor&&typeof t.constructor.stackTraceLimit=="number"}function oS(t){return t instanceof Date?!0:typeof t.toDateString=="function"&&typeof t.getDate=="function"&&typeof t.setDate=="function"}function Et(t){let e=typeof t;return process.env.NODE_ENV!=="production"&&(e=nS(t)),e}function yp(t,e,n){if(typeof t!="function")throw new Error(process.env.NODE_ENV==="production"?xe(2):`Expected the root reducer to be a function. Instead, received: '${Et(t)}'`);if(typeof e=="function"&&typeof n=="function"||typeof n=="function"&&typeof arguments[3]=="function")throw new Error(process.env.NODE_ENV==="production"?xe(0):"It looks like you are passing several store enhancers to createStore(). This is not supported. Instead, compose them together to a single function. See https://redux.js.org/tutorials/fundamentals/part-4-store#creating-a-store-with-enhancers for an example.");if(typeof e=="function"&&typeof n>"u"&&(n=e,e=void 0),typeof n<"u"){if(typeof n!="function")throw new Error(process.env.NODE_ENV==="production"?xe(1):`Expected the enhancer to be a function. Instead, received: '${Et(n)}'`);return n(yp)(t,e)}let r=t,i=e,o=new Map,l=o,a=0,s=!1;function u(){l===o&&(l=new Map,o.forEach((b,m)=>{l.set(m,b)}))}function d(){if(s)throw new Error(process.env.NODE_ENV==="production"?xe(3):"You may not call store.getState() while the reducer is executing. The reducer has already received the state as an argument. Pass it down from the top reducer instead of reading it from the store.");return i}function f(b){if(typeof b!="function")throw new Error(process.env.NODE_ENV==="production"?xe(4):`Expected the listener to be a function. Instead, received: '${Et(b)}'`);if(s)throw new Error(process.env.NODE_ENV==="production"?xe(5):"You may not call store.subscribe() while the reducer is executing. If you would like to be notified after the store has been updated, subscribe from a component and invoke store.getState() in the callback to access the latest state. See https://redux.js.org/api/store#subscribelistener for more details.");let m=!0;u();const C=a++;return l.set(C,b),function(){if(m){if(s)throw new Error(process.env.NODE_ENV==="production"?xe(6):"You may not unsubscribe from a store listener while the reducer is executing. See https://redux.js.org/api/store#subscribelistener for more details.");m=!1,u(),l.delete(C),o=null}}}function v(b){if(!bp(b))throw new Error(process.env.NODE_ENV==="production"?xe(7):`Actions must be plain objects. Instead, the actual type was: '${Et(b)}'. You may need to add middleware to your store setup to handle dispatching other values, such as 'redux-thunk' to handle dispatching functions. See https://redux.js.org/tutorials/fundamentals/part-4-store#middleware and https://redux.js.org/tutorials/fundamentals/part-6-async-logic#using-the-redux-thunk-middleware for examples.`);if(typeof b.type>"u")throw new Error(process.env.NODE_ENV==="production"?xe(8):'Actions may not have an undefined "type" property. You may have misspelled an action type string constant.');if(typeof b.type!="string")throw new Error(process.env.NODE_ENV==="production"?xe(17):`Action "type" property must be a string. Instead, the actual type was: '${Et(b.type)}'. Value was: '${b.type}' (stringified)`);if(s)throw new Error(process.env.NODE_ENV==="production"?xe(9):"Reducers may not dispatch actions.");try{s=!0,i=r(i,b)}finally{s=!1}return(o=l).forEach(C=>{C()}),b}function g(b){if(typeof b!="function")throw new Error(process.env.NODE_ENV==="production"?xe(10):`Expected the nextReducer to be a function. Instead, received: '${Et(b)}`);r=b,v({type:qt.REPLACE})}function $(){const b=f;return{subscribe(m){if(typeof m!="object"||m===null)throw new Error(process.env.NODE_ENV==="production"?xe(11):`Expected the observer to be an object. Instead, received: '${Et(m)}'`);function C(){const D=m;D.next&&D.next(d())}return C(),{unsubscribe:b(C)}},[Zc](){return this}}}return v({type:qt.INIT}),{dispatch:v,subscribe:f,getState:d,replaceReducer:g,[Zc]:$}}function Jc(t){typeof console<"u"&&typeof console.error=="function"&&console.error(t);try{throw new Error(t)}catch{}}function lS(t,e,n,r){const i=Object.keys(e),o=n&&n.type===qt.INIT?"preloadedState argument passed to createStore":"previous state received by the reducer";if(i.length===0)return"Store does not have a valid reducer. Make sure the argument passed to combineReducers is an object whose values are reducers.";if(!bp(t))return`The ${o} has unexpected type of "${Et(t)}". Expected argument to be an object with the following keys: "${i.join('", "')}"`;const l=Object.keys(t).filter(a=>!e.hasOwnProperty(a)&&!r[a]);if(l.forEach(a=>{r[a]=!0}),!(n&&n.type===qt.REPLACE)&&l.length>0)return`Unexpected ${l.length>1?"keys":"key"} "${l.join('", "')}" found in ${o}. Expected to find one of the known reducer keys instead: "${i.join('", "')}". Unexpected keys will be ignored.`}function aS(t){Object.keys(t).forEach(e=>{const n=t[e];if(typeof n(void 0,{type:qt.INIT})>"u")throw new Error(process.env.NODE_ENV==="production"?xe(12):`The slice reducer for key "${e}" returned undefined during initialization. If the state passed to the reducer is undefined, you must explicitly return the initial state. The initial state may not be undefined. If you don't want to set a value for this reducer, you can use null instead of undefined.`);if(typeof n(void 0,{type:qt.PROBE_UNKNOWN_ACTION()})>"u")throw new Error(process.env.NODE_ENV==="production"?xe(13):`The slice reducer for key "${e}" returned undefined when probed with a random type. Don't try to handle '${qt.INIT}' or other actions in "redux/*" namespace. They are considered private. Instead, you must return the current state for any unknown actions, unless it is undefined, in which case you must return the initial state, regardless of the action type. The initial state may not be undefined, but can be null.`)})}function Qc(t){const e=Object.keys(t),n={};for(let l=0;l<e.length;l++){const a=e[l];process.env.NODE_ENV!=="production"&&typeof t[a]>"u"&&Jc(`No reducer provided for key "${a}"`),typeof t[a]=="function"&&(n[a]=t[a])}const r=Object.keys(n);let i;process.env.NODE_ENV!=="production"&&(i={});let o;try{aS(n)}catch(l){o=l}return function(a={},s){if(o)throw o;if(process.env.NODE_ENV!=="production"){const f=lS(a,n,s,i);f&&Jc(f)}let u=!1;const d={};for(let f=0;f<r.length;f++){const v=r[f],g=n[v],$=a[v],p=g($,s);if(typeof p>"u"){const b=s&&s.type;throw new Error(process.env.NODE_ENV==="production"?xe(14):`When called with an action of type ${b?`"${String(b)}"`:"(unknown type)"}, the slice reducer for key "${v}" returned undefined. To ignore an action, you must explicitly return the previous state. If you want this reducer to hold no value, you can return null instead of undefined.`)}d[v]=p,u=u||p!==$}return u=u||r.length!==Object.keys(a).length,u?d:a}}function sS(t=Zn().nodes.drag,e){switch(e.type){case"DND_DRAG_START":return Object.assign(Object.assign({},t),{id:e.id,selectedIds:e.dragIds});case"DND_DRAG_END":return Object.assign(Object.assign({},t),{id:null,destinationParentId:null,destinationIndex:null,selectedIds:[]});case"DND_HOVERING":return e.parentId!==t.destinationParentId||e.index!=t.destinationIndex?Object.assign(Object.assign({},t),{destinationParentId:e.parentId,destinationIndex:e.index}):t;default:return t}}const uS=Qc({nodes:Qc({focus:M4,edit:k4,open:N4,selection:R4,drag:sS}),dnd:A4}),cS=Zn();function dS({treeProps:t,imperativeHandle:e,children:n}){const r=c.useRef(null),i=c.useRef(null),o=c.useRef(yp(uS,Zn(t))),l=Ca.useSyncExternalStore(o.current.subscribe,o.current.getState,()=>cS),a=c.useMemo(()=>new Vn(o.current,t,r,i),[]),s=c.useRef(0);return c.useMemo(()=>{s.current+=1,a.update(t)},[...Object.values(t),l.nodes.open]),c.useImperativeHandle(e,()=>a),c.useEffect(()=>{a.props.selection?a.select(a.props.selection,{focus:!1}):a.deselectAll()},[a.props.selection]),c.useEffect(()=>{a.props.searchTerm||o.current.dispatch(oa.clear(!0))},[a.props.searchTerm]),w.jsx(Oh.Provider,{value:a,children:w.jsx(Lh.Provider,{value:s.current,children:w.jsx(_h.Provider,{value:l.nodes,children:w.jsx(kh.Provider,{value:l.dnd,children:w.jsx(B3,Object.assign({backend:V8,options:{rootElement:a.props.dndRootElement||void 0}},t.dndManager&&{manager:t.dndManager},{children:n}))})})})})}function fS(){const t=Le(),[,e]=ap(()=>({accept:"NODE",canDrop:(n,r)=>r.isOver({shallow:!0})?t.canDrop():!1,hover:(n,r)=>{if(!r.isOver({shallow:!0}))return;const i=r.getClientOffset();if(!t.listEl.current||!i)return;const{cursor:o,drop:l}=gp({element:t.listEl.current,offset:i,indent:t.indent,node:null,prevNode:t.visibleNodes[t.visibleNodes.length-1],nextNode:null});l&&t.dispatch(Jn.hovering(l.parentId,l.index)),r.canDrop()?o&&t.showCursor(o):t.hideCursor()}}),[t]);e(t.listEl)}function hS(t){return fS(),t.children}function pS(){const e=Le().props.renderContainer||vp;return w.jsx(w.Fragment,{children:w.jsx(e,{})})}function gS(){const t=Le(),{offset:e,mouse:n,item:r,isDragging:i}=g8(l=>({offset:l.getSourceClientOffset(),mouse:l.getClientOffset(),item:l.getItem(),isDragging:l.isDragging()})),o=t.props.renderDragPreview||qh;return w.jsx(o,{offset:e,mouse:n,id:(r==null?void 0:r.id)||null,dragIds:(r==null?void 0:r.dragIds)||[],isDragging:i})}class vS{constructor(e){this.root=mS(e)}get data(){var e,n;return(n=(e=this.root.children)===null||e===void 0?void 0:e.map(r=>r.data))!==null&&n!==void 0?n:[]}create(e){const n=e.parentId?this.find(e.parentId):this.root;if(!n)return null;n.addChild(e.data,e.index)}move(e){const n=this.find(e.id),r=e.parentId?this.find(e.parentId):this.root;!n||!r||(r.addChild(n.data,e.index),n.drop())}update(e){const n=this.find(e.id);n&&n.update(e.changes)}drop(e){const n=this.find(e.id);n&&n.drop()}find(e,n=this.root){if(!n)return null;if(n.id===e)return n;if(n.children){for(let r of n.children){const i=this.find(e,r);if(i)return i}return null}return null}}function mS(t){const e=new $p({id:"ROOT"},null);return e.children=t.map(n=>cs(n,e)),e}function cs(t,e){const n=new $p(t,e);return t.children&&(n.children=t.children.map(r=>cs(r,n))),n}class $p{constructor(e,n){this.data=e,this.parent=n,this.id=e.id}hasParent(){return!!this.parent}get childIndex(){return this.hasParent()?this.parent.children.indexOf(this):-1}addChild(e,n){var r,i;const o=cs(e,this);this.children=(r=this.children)!==null&&r!==void 0?r:[],this.children.splice(n,0,o),this.data.children=(i=this.data.children)!==null&&i!==void 0?i:[],this.data.children.splice(n,0,e)}removeChild(e){var n,r;(n=this.children)===null||n===void 0||n.splice(e,1),(r=this.data.children)===null||r===void 0||r.splice(e,1)}update(e){if(this.hasParent()){const n=this.childIndex;this.parent.addChild(Object.assign(Object.assign({},this.data),e),n),this.drop()}}drop(){this.hasParent()&&this.parent.removeChild(this.childIndex)}}let bS=0;function yS(t){const[e,n]=c.useState(t),r=c.useMemo(()=>new vS(e),[e]);return[e,{onMove:u=>{for(const d of u.dragIds)r.move({id:d,parentId:u.parentId,index:u.index});n(r.data)},onRename:({name:u,id:d})=>{r.update({id:d,changes:{name:u}}),n(r.data)},onCreate:({parentId:u,index:d,type:f})=>{const v={id:`simple-tree-id-${bS++}`,name:""};return f==="internal"&&(v.children=[]),r.create({parentId:u,index:d,data:v}),n(r.data),v},onDelete:u=>{u.ids.forEach(d=>r.drop({id:d})),n(r.data)}}]}function $S(t){if(t.initialData&&t.data)throw new Error("React Arborist Tree => Provide either a data or initialData prop, but not both.");if(t.initialData&&(t.onCreate||t.onDelete||t.onMove||t.onRename))throw new Error(`React Arborist Tree => You passed the initialData prop along with a data handler.
101
- Use the data prop if you want to provide your own handlers.`);if(t.initialData){const[e,n]=yS(t.initialData);return Object.assign(Object.assign(Object.assign({},t),n),{data:e})}else return t}function SS(t,e){const n=$S(t);return w.jsxs(dS,{treeProps:n,imperativeHandle:e,children:[w.jsx(hS,{children:w.jsx(pS,{})}),w.jsx(gS,{})]})}const wS=c.forwardRef(SS),Sp=({top:t,left:e})=>w.jsx("div",{className:"c__tree-view__cursor",style:{top:t-2,left:e+10,width:`calc(100% - ${24+e}px)`}});function CS(t,e){var n=c.useRef(null),r=c.useRef(null);r.current=e;var i=c.useRef(null);c.useEffect(function(){o()});var o=c.useCallback(function(){var l=i.current,a=r.current,s=l||(a?a instanceof Element?a:a.current:null);n.current&&n.current.element===s&&n.current.subscriber===t||(n.current&&n.current.cleanup&&n.current.cleanup(),n.current={element:s,subscriber:t,cleanup:s?t(s):void 0})},[t]);return c.useEffect(function(){return function(){n.current&&n.current.cleanup&&(n.current.cleanup(),n.current=null)}},[]),c.useCallback(function(l){i.current=l,o()},[o])}function ed(t,e,n){return t[e]?t[e][0]?t[e][0][n]:t[e][n]:e==="contentBoxSize"?t.contentRect[n==="inlineSize"?"width":"height"]:void 0}function ES(t){t===void 0&&(t={});var e=t.onResize,n=c.useRef(void 0);n.current=e;var r=t.round||Math.round,i=c.useRef(),o=c.useState({width:void 0,height:void 0}),l=o[0],a=o[1],s=c.useRef(!1);c.useEffect(function(){return s.current=!1,function(){s.current=!0}},[]);var u=c.useRef({width:void 0,height:void 0}),d=CS(c.useCallback(function(f){return(!i.current||i.current.box!==t.box||i.current.round!==r)&&(i.current={box:t.box,round:r,instance:new ResizeObserver(function(v){var g=v[0],$=t.box==="border-box"?"borderBoxSize":t.box==="device-pixel-content-box"?"devicePixelContentBoxSize":"contentBoxSize",p=ed(g,$,"inlineSize"),b=ed(g,$,"blockSize"),m=p?r(p):void 0,C=b?r(b):void 0;if(u.current.width!==m||u.current.height!==C){var S={width:m,height:C};u.current.width=m,u.current.height=C,n.current?n.current(S):s.current||a(S)}})}),i.current.instance.observe(f,{box:t.box}),function(){i.current&&i.current.instance.unobserve(f)}},[t.box,r]),t.ref);return c.useMemo(function(){return{ref:d,width:l.width,height:l.height}},[d,l.width,l.height])}var ze=(t=>(t.NODE="node",t.SEPARATOR="separator",t.TITLE="title",t))(ze||{}),Ht=(t=>(t.FIRST_CHILD="first-child",t.LAST_CHILD="last-child",t.LEFT="left",t.RIGHT="right",t))(Ht||{});const Gi=t=>t?t.nodeType===ze.SEPARATOR:!1,qi=t=>t?t.nodeType===ze.TITLE:!1,$r=t=>!Gi(t)&&!qi(t),wp=(t,e,n)=>{const{remove:r,update:i,insert:o,insertBefore:l,insertAfter:a,append:s,prepend:u,getItem:d,move:f,items:v}=D1({initialItems:JSON.parse(JSON.stringify(t)),getKey:V=>V.id,getChildren:V=>V.children||[]}),[g,$]=c.useState(),p=(V=[])=>{const U=v.map(M=>M.key);r(...U);const N=JSON.parse(JSON.stringify(V));N.length>0&&o(null,0,...N),$(void 0)},b=V=>{const U=d(V);U&&$(U.value)},m=(V,U,N)=>{var M;if(V){const z=d(V);z&&o(V,N??((M=z.children)==null?void 0:M.length)??0,U)}else o(null,N??v.length,U)},C=V=>{var U;return(U=d(V))==null?void 0:U.value},S=(V,U)=>{var W;const N=d(V);if(!N){console.error("No item found");return}let M=((W=N.children)==null?void 0:W.map(G=>G.value))??null;const z=U.childrenCount??N.value.childrenCount??0;if((M==null?void 0:M.length)===0&&z>0&&(M=null),U.children&&(M=[...M??[],...U.children]),U.children){const G=new Set(U.children.map(R=>R.id));M=U.children.filter(R=>!G.has(R.id)),M=[...M??[],...U.children]}const j={...N.value,...U,children:M,childrenCount:(M==null?void 0:M.length)??z};i(V,j)},D=V=>{r(V)},x=V=>{r(...V)},T=async V=>{if(!e){console.error("No refresh callback provided");return}try{const U=await e(V);S(V,U)}catch(U){console.error("error while refreshing node:",U)}},I=(V,U)=>{o(null,U??v.length,V)},h=(V,U)=>{o(null,U??v.length,...V)},L=(V,U)=>{const N=d(V);if(!N){console.error("No item found");return}const M={...N.value,children:U,childrenCount:U.length,hasLoadedChildren:U.length>0};i(V,M)},A=V=>{const U=[],N=d(V);if(!N)return[];U.push(N.value);const M=z=>{const j=P(z);if(!j)return;const W=d(j);W&&(U.push(W.value),M(j))};return M(V),U.reverse()},P=V=>{var U;return((U=d(V))==null?void 0:U.parentKey)??null},F=V=>{const U=P(V);if(!U)return null;const N=d(U);return N?N.value:null},y=(V,U)=>{l(V,U)},E=(V,U)=>{a(V,U)},K=(V,U)=>{s(V,U)},B=(V,U)=>{u(V,U)},H=(V,U,N)=>{f(V,U,N)},O=V=>{H(V.sourceId,V.newParentId,V.index)},q=async V=>{if(!n)return[];const U=await n(V);return S(V,{children:U,hasLoadedChildren:!0,childrenCount:U.length}),U};return c.useEffect(()=>{const V=U=>{U.forEach(N=>{var M;if(N.children&&N.children.length>0){const z=N.value.hasLoadedChildren||((M=N.children)==null?void 0:M.length)>0||N.value.children&&N.value.children.length>0;N.value.children=N.children.map(W=>W.value);const j=z?N.children.length:N.value.childrenCount??0;N.value.childrenCount=j,z&&!N.value.hasLoadedChildren&&(N.value.hasLoadedChildren=!0),V(N.children)}else{const j=N.value.hasLoadedChildren||N.value.children&&N.value.children.length>0?0:N.value.childrenCount;N.value.children=[],N.value.childrenCount=j}})};V(v)},[v]),{nodes:v,addChild:m,updateNode:S,deleteNode:D,deleteNodes:x,addRootNode:I,addRootNodes:h,selectedNode:g,setSelectedNode:$,refreshNode:T,setChildren:L,insertBeforeNode:y,insertAfterNode:E,handleMove:O,prependToNode:B,moveNode:H,appendToNode:K,move:f,resetTree:p,handleLoadChildren:q,selectNodeById:b,getParent:F,getNode:C,getParentId:P,getAncestors:A}},ds=c.createContext(null),xS=({children:t,onRefresh:e,initialNodeId:n,onLoadChildren:r,initialTreeData:i})=>{const o=c.useRef(null),[l,a]=c.useState(null),[s,u]=c.useState(n??null),d=wp(i??[],e,r);return w.jsx(ds.Provider,{value:{treeApiRef:o,treeData:d,root:l,initialTargetId:s,setInitialTargetId:u,setRoot:a},children:t})},fs=()=>{const t=c.useContext(ds);if(!t)throw new Error("TreeContext not found");return t},PS=({initialOpenState:t,selectedNodeId:e,rootNodeId:n,renderNode:r,canDrop:i,canDrag:o,afterMove:l,beforeMove:a})=>{const[s,u]=c.useState(400),{ref:d,width:f}=ES(),v=fs(),g=(v==null?void 0:v.treeData.nodes)??[];c.useEffect(()=>{const m=document.querySelector(".c__tree-view"),C=m==null?void 0:m.firstElementChild;let S=null;return m&&C&&(S=new ResizeObserver(()=>{if(C&&C instanceof HTMLElement){const D=C.style.height;u(parseInt(D,10)+20)}}),S.observe(C)),()=>S==null?void 0:S.disconnect()},[]);const $=m=>{var O,q,V,U;const C=JSON.parse(JSON.stringify(g)),S=m.dragNodes[0],D=m.parentId?((O=m.parentNode)==null?void 0:O.data.children)??[]:C,x=m.dragNodes[0].data.value.id,T=m.dragNodes[0].data,I=(q=m.parentNode)==null?void 0:q.data;if((I==null?void 0:I.value.nodeType)===ze.TITLE||(I==null?void 0:I.value.nodeType)===ze.SEPARATOR)return null;const h=T.parentKey??n,L=m.parentId??n;let A=m.index+0,P=null,F=L;const y=((U=(V=S.parent)==null?void 0:V.children)==null?void 0:U.findIndex(N=>N.data.value.id===x))??0;if(h===L){if(y===A)return null;A=A<y?A:A-1}const E=m.index-1,K=D[E],B=m.index,H=D[B];return m.index===0?(F=m.parentId??n,P=Ht.FIRST_CHILD):!I&&m.index===1&&!$r(K.value)?(F=n,A=1,P=Ht.FIRST_CHILD):m.index===D.length?(F=F??n,P=Ht.LAST_CHILD):K&&$r(K.value)?(F=K.value.id,P=Ht.RIGHT):H&&$r(H.value)&&(P=Ht.LEFT,F=H.value.id),P&&F?{targetModeId:F,mode:P,oldParentId:h,index:A,newParentId:m.parentId,sourceId:x}:null},p=m=>{const C=$(m);C&&(a?a(C,()=>{v==null||v.treeData.handleMove(C),l==null||l(C)}):(v==null||v.treeData.handleMove(C),l==null||l(C)))},b=c.useCallback(m=>o?!o(m):!1,[o]);if(v)return w.jsx("div",{ref:d,style:{height:s},className:"c__tree-view--container",children:w.jsx(wS,{data:g,ref:v.treeApiRef,openByDefault:!1,selectionFollowsFocus:!1,disableMultiSelection:!0,disableEdit:!0,className:"c__tree-view",idAccessor:"key",onMove:p,height:s,width:f,paddingTop:10,paddingBottom:10,rowHeight:35,disableDrag:b,disableDrop:({parentNode:m,dragNodes:C,index:S})=>{var h,L;if(i&&!i({parentNode:m,dragNodes:C,index:S}))return m.id!=="__REACT_ARBORIST_INTERNAL_ROOT__"&&(m.data.value.canDrop=!1),!0;const D=C[0];if(D&&D.isDragging&&D.willReceiveDrop||((h=m.data.value)==null?void 0:h.nodeType)===ze.TITLE||((L=m.data.value)==null?void 0:L.nodeType)===ze.SEPARATOR)return!0;if(m.id==="__REACT_ARBORIST_INTERNAL_ROOT__"){const A=g[S-1],P=g[S],F=g[S+1],y=Gi(A==null?void 0:A.value),E=Gi(P==null?void 0:P.value),K=qi(A==null?void 0:A.value),B=qi(P==null?void 0:P.value),H=$r(F==null?void 0:F.value);return!!(S===0&&(E||B)||y&&B&&H||K&&E&&H)}const x=m==null?void 0:m.isOpen,T=(m==null?void 0:m.data.value.childrenCount)&&m.data.value.childrenCount>0||(m==null?void 0:m.data.children)&&m.data.children.length>0;if(!T)return m.data.value.canDrop=!0,!1;let I=m.data.value.childrenCount&&m.data.value.childrenCount>0&&(m==null?void 0:m.data.children)&&m.data.children.length>0;return I=I??!0,!x&&!I&&T?(m.data.value.canDrop=!0,!0):(m.data.value.canDrop=!0,!1)},initialOpenState:t,overscanCount:20,selection:e,renderCursor:Sp,renderRow:TS,rowClassName:"c__tree-view--row",children:r})})},TS=({children:t,...e})=>{const n=e.node.data.value.nodeType===ze.TITLE,r=e.node.data.value.nodeType===ze.SEPARATOR,{style:i}=e.attrs,o={...i};return n||r?c.createElement("div",{...e.attrs,key:e.node.id,style:o,ref:e.innerRef,onFocus:l=>l.stopPropagation(),onClick:e.node.handleClick},t):c.createElement("div",{...e.attrs,style:o,key:e.node.id,ref:e.innerRef,onFocus:l=>l.stopPropagation(),onClick:e.node.handleClick},w.jsx("div",{className:"c__tree-view--row-content",children:t}))},DS=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function IS(t){const e=Object.prototype.toString.call(t);return e==="[object Window]"||e==="[object global]"}function OS(t){return"nodeType"in t}function _S(t){var e,n;return t?IS(t)?t:OS(t)&&(e=(n=t.ownerDocument)==null?void 0:n.defaultView)!=null?e:window:window}const Cp=DS?c.useLayoutEffect:c.useEffect;function Ep(t){const e=c.useRef(t);return Cp(()=>{e.current=t}),c.useCallback(function(){for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return e.current==null?void 0:e.current(...r)},[])}function td(t,e){e===void 0&&(e=[t]);const n=c.useRef(t);return Cp(()=>{n.current!==t&&(n.current=t)},e),n}function kS(t){const e=Ep(t),n=c.useRef(null),r=c.useCallback(i=>{i!==n.current&&(e==null||e(i,n.current)),n.current=i},[]);return[n,r]}let Sl={};function LS(t,e){return c.useMemo(()=>{const n=Sl[t]==null?0:Sl[t]+1;return Sl[t]=n,t+"-"+n},[t,e])}var xr;(function(t){t.DragStart="dragStart",t.DragMove="dragMove",t.DragEnd="dragEnd",t.DragCancel="dragCancel",t.DragOver="dragOver",t.RegisterDroppable="registerDroppable",t.SetDroppableDisabled="setDroppableDisabled",t.UnregisterDroppable="unregisterDroppable"})(xr||(xr={}));function nd(){}const MS=Object.freeze({x:0,y:0});function NS(t){if(t.startsWith("matrix3d(")){const e=t.slice(9,-1).split(/, /);return{x:+e[12],y:+e[13],scaleX:+e[0],scaleY:+e[5]}}else if(t.startsWith("matrix(")){const e=t.slice(7,-1).split(/, /);return{x:+e[4],y:+e[5],scaleX:+e[0],scaleY:+e[3]}}return null}function RS(t,e,n){const r=NS(e);if(!r)return t;const{scaleX:i,scaleY:o,x:l,y:a}=r,s=t.left-l-(1-i)*parseFloat(n),u=t.top-a-(1-o)*parseFloat(n.slice(n.indexOf(" ")+1)),d=i?t.width/i:t.width,f=o?t.height/o:t.height;return{width:d,height:f,top:u,right:s+d,bottom:u+f,left:s}}const AS={ignoreTransform:!1};function xp(t,e){e===void 0&&(e=AS);let n=t.getBoundingClientRect();if(e.ignoreTransform){const{transform:u,transformOrigin:d}=_S(t).getComputedStyle(t);u&&(n=RS(n,u,d))}const{top:r,left:i,width:o,height:l,bottom:a,right:s}=n;return{top:r,left:i,width:o,height:l,bottom:a,right:s}}function rd(t){return xp(t,{ignoreTransform:!0})}var Fn;(function(t){t[t.Forward=1]="Forward",t[t.Backward=-1]="Backward"})(Fn||(Fn={}));var id;(function(t){t.Click="click",t.DragStart="dragstart",t.Keydown="keydown",t.ContextMenu="contextmenu",t.Resize="resize",t.SelectionChange="selectionchange",t.VisibilityChange="visibilitychange"})(id||(id={}));var Tt;(function(t){t.Space="Space",t.Down="ArrowDown",t.Right="ArrowRight",t.Left="ArrowLeft",t.Up="ArrowUp",t.Esc="Escape",t.Enter="Enter",t.Tab="Tab"})(Tt||(Tt={}));Tt.Space,Tt.Enter,Tt.Esc,Tt.Space,Tt.Enter,Tt.Tab;var od;(function(t){t[t.RightClick=2]="RightClick"})(od||(od={}));var ld;(function(t){t[t.Pointer=0]="Pointer",t[t.DraggableRect=1]="DraggableRect"})(ld||(ld={}));var ad;(function(t){t[t.TreeOrder=0]="TreeOrder",t[t.ReversedTreeOrder=1]="ReversedTreeOrder"})(ad||(ad={}));Fn.Backward+"",Fn.Forward+"",Fn.Backward+"",Fn.Forward+"";var pa;(function(t){t[t.Always=0]="Always",t[t.BeforeDragging=1]="BeforeDragging",t[t.WhileDragging=2]="WhileDragging"})(pa||(pa={}));var ga;(function(t){t.Optimized="optimized"})(ga||(ga={}));function KS(t){let{callback:e,disabled:n}=t;const r=Ep(e),i=c.useMemo(()=>{if(n||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:o}=window;return new o(r)},[n]);return c.useEffect(()=>()=>i==null?void 0:i.disconnect(),[i]),i}pa.WhileDragging,ga.Optimized;const FS={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:nd,draggableNodes:new Map,over:null,measureDroppableContainers:nd},jS=c.createContext(FS);({...MS});var sd;(function(t){t[t.Uninitialized=0]="Uninitialized",t[t.Initializing=1]="Initializing",t[t.Initialized=2]="Initialized"})(sd||(sd={}));const HS="Droppable",zS={timeout:25};function BS(t){let{data:e,disabled:n=!1,id:r,resizeObserverConfig:i}=t;const o=LS(HS),{active:l,dispatch:a,over:s,measureDroppableContainers:u}=c.useContext(jS),d=c.useRef({disabled:n}),f=c.useRef(!1),v=c.useRef(null),g=c.useRef(null),{disabled:$,updateMeasurementsFor:p,timeout:b}={...zS,...i},m=td(p??r),C=c.useCallback(()=>{if(!f.current){f.current=!0;return}g.current!=null&&clearTimeout(g.current),g.current=setTimeout(()=>{u(Array.isArray(m.current)?m.current:[m.current]),g.current=null},b)},[b]),S=KS({callback:C,disabled:$||!l}),D=c.useCallback((h,L)=>{S&&(L&&(S.unobserve(L),f.current=!1),h&&S.observe(h))},[S]),[x,T]=kS(D),I=td(e);return c.useEffect(()=>{!S||!x.current||(S.disconnect(),f.current=!1,S.observe(x.current))},[x,S]),c.useEffect(()=>(a({type:xr.RegisterDroppable,element:{id:r,key:o,disabled:n,node:x,rect:v,data:I}}),()=>a({type:xr.UnregisterDroppable,key:o,id:r})),[r]),c.useEffect(()=>{n!==d.current.disabled&&(a({type:xr.SetDroppableDisabled,id:r,key:o,disabled:n}),d.current.disabled=n)},[r,o,n,a]),{active:l,rect:v,isOver:(s==null?void 0:s.id)===r,node:x,over:s,setNodeRef:T}}const VS=t=>{const{isOver:e,setNodeRef:n}=BS({id:t.id,data:t.data});return c.useEffect(()=>{var r;(r=t.onOver)==null||r.call(t,e,t.data)},[e,t.data,t.onOver]),w.jsx("div",{className:"c__dnd--droppable",ref:n,children:t.children})},US=({children:t,onClick:e,node:n,dragHandle:r,style:i,forceLoading:o})=>{var S,D;const l=fs(),a=c.useRef(null),[s,u]=c.useState(!1),[d,f]=c.useState(!1),v=o??s,g=n.willReceiveDrop||d,$=n.data.value.childrenCount!==void 0&&n.data.value.childrenCount>0||(((S=n.data.children)==null?void 0:S.length)??0)>0,p=((D=n.children)==null?void 0:D.length)??!1,b=n.isLeaf||!$,m=c.useCallback(async()=>{if(!b){if(p||n.data.value.hasLoadedChildren){n.toggle();return}u(!0),await(l==null?void 0:l.treeData.handleLoadChildren(n.data.value.id)),u(!1),n.open()}},[b,p,n,l==null?void 0:l.treeData]),C=c.useCallback(x=>{x&&!n.isOpen&&!n.isDragging&&(a.current=setTimeout(()=>{m()},500)),a.current&&!x&&clearTimeout(a.current)},[m,n.isOpen,n.isDragging]);return c.useEffect(()=>{C(g)},[g,C]),n.data.value.nodeType===ze.SEPARATOR?w.jsx("div",{className:"c__tree-view--node__separator"}):n.data.value.nodeType===ze.TITLE?w.jsx("div",{className:"c__tree-view--node__title",children:n.data.value.headerTitle}):w.jsx(VS,{id:n.id,data:{data:n.data,nodeApi:n},onOver:f,children:w.jsxs("div",{onClick:x=>{x.target.closest(".c__tree-view--node")||x.stopPropagation(),e==null||e()},onKeyDown:x=>{x.stopPropagation()},ref:r,style:i,className:Te("c__tree-view--node",{...n.state,canDrop:n.data.value.canDrop??!0,externalDrop:d}),children:[b&&w.jsx("div",{className:"c__tree-view--node__leaf"}),!b&&w.jsxs(w.Fragment,{children:[v&&w.jsx("div",{className:"c__tree-view--node__loading",children:w.jsx(Ya,{})}),!v&&w.jsx("span",{onClick:x=>{x.stopPropagation(),m()},className:"c__tree-view--node__arrow material-icons",children:n.isOpen?"keyboard_arrow_down":"keyboard_arrow_right"})]}),t]})})},wo=({roles:t,onSelect:e,canUpdate:n=!0,selectedRole:r,isOpen:i,onOpenChange:o,roleTopMessage:l})=>{const a=t.find(s=>s.value===r);return n?w.jsx(Ar,{isOpen:i,shouldCloseOnInteractOutside:s=>!s.closest(".c__access-role-dropdown"),onOpenChange:o,options:t,selectedValues:[r],onSelectValue:e,topMessage:l,children:w.jsxs("div",{role:"button",className:"c__access-role-dropdown",onClick:()=>{o==null||o(!i)},children:[w.jsx("span",{className:"fs-s clr-greyscale-600",children:a==null?void 0:a.label}),w.jsx("span",{className:"material-icons",children:i?"arrow_drop_up":"arrow_drop_down"})]})}):w.jsx("span",{className:"fs-s clr-greyscale-600",children:a==null?void 0:a.label})},Pp=({users:t,onRemoveUser:e,rightActions:n,onShare:r,shareButtonLabel:i,roles:o,selectedRole:l,onSelectRole:a})=>{const{t:s}=se.useCunningham(),[u,d]=c.useState(!1);return w.jsxs("div",{className:"c__add-share-user-list",children:[w.jsx("div",{className:"c__add-share-user-list__items",children:t.map(f=>w.jsx(Tp,{user:f,onRemoveUser:e},f.id))}),w.jsxs("div",{className:"c__add-share-user-list__right-actions",children:[n,w.jsx(wo,{roles:o,selectedRole:l,onSelect:a,isOpen:u,onOpenChange:d}),w.jsx(se.Button,{onClick:r,children:i??s("components.share.shareButton")})]})]})},Tp=({user:t,onRemoveUser:e})=>w.jsxs("div",{className:"c__add-share-user-item",children:[w.jsx("span",{children:t.full_name||t.email}),w.jsx(se.Button,{color:"tertiary-text",size:"nano",onClick:()=>e==null?void 0:e(t),icon:w.jsx("span",{className:"material-icons",children:"close"})})]}),ud=["purple","blue","green","yellow","orange","red","brown","cyan","gold","olive","rose"],WS=t=>{const e=t.split(" ");return e.length>2?e.slice(0,2).map(n=>n[0]).join(""):e.map(n=>n[0]).join("")},GS=t=>ud[t.charCodeAt(0)%ud.length],Dp=({fullName:t,size:e="medium",forceColor:n})=>{const r=WS(t),i=GS(t);return w.jsx("div",{style:{backgroundColor:n||void 0},className:Te(`c__avatar ${e}`,{[i]:!n&&i}),children:w.jsx("div",{className:"c__avatar__initials",children:r})})},Co=({fullName:t,email:e,showEmail:n=!0})=>{const r=t&&t!==""?t:e??"";return w.jsxs("div",{className:"c__user-row",children:[w.jsx(Dp,{fullName:r,size:"small"}),w.jsxs("div",{className:"c__user-row__info",children:[w.jsx("span",{className:"c__user-row__name",children:t}),n&&e&&w.jsx("span",{className:Te("c__user-row__email",{"has-only-email":e&&(t===""||!t)}),children:e})]})]})},va=({user:t})=>{const{t:e}=se.useCunningham();return w.jsx(vo,{left:w.jsx(Co,{fullName:t.full_name,email:t.email}),alwaysShowRight:!1,right:w.jsxs("div",{className:"c__search-user-item-right",children:[w.jsx("span",{children:e("components.share.item.add")}),w.jsx("span",{className:"material-icons",children:"add"})]})})},Ip=({accessData:t,roles:e,updateRole:n,deleteAccess:r,canUpdate:i=!0,roleTopMessage:o})=>{const{t:l}=se.useCunningham(),a=Yn(),s=Yn(),u=[{label:l("components.share.access.delete"),icon:w.jsx("span",{className:"material-icons",children:"back_hand"}),isDisabled:!i,callback:()=>{r==null||r(t)}}],d=()=>{const f=s.isOpen;s.setIsOpen(!f)};return w.jsx("div",{className:"c__share-member-item",children:w.jsx(vo,{left:w.jsx(Co,{fullName:t.user.full_name,email:t.user.email,showEmail:!0}),alwaysShowRight:!0,right:w.jsxs("div",{className:"c__share-member-item__right",children:[w.jsx(wo,{roles:e,selectedRole:t.role,onSelect:f=>n==null?void 0:n(t,f),isOpen:a.isOpen,onOpenChange:a.setIsOpen,canUpdate:i,roleTopMessage:o}),i&&w.jsx(Ar,{options:u,isOpen:s.isOpen,onOpenChange:s.setIsOpen,children:w.jsx(se.Button,{color:"primary-text",onClick:d,size:"small",icon:w.jsx("span",{className:"material-icons toto",children:"more_horiz"})})})]})})})},Op=({invitation:t,roles:e,updateRole:n,deleteInvitation:r,canUpdate:i=!0,roleTopMessage:o})=>{const{t:l}=se.useCunningham(),a=Yn(),s=Yn(),u=[{label:l("components.share.access.delete"),callback:()=>r==null?void 0:r(t),isDisabled:!i,icon:w.jsx("span",{className:"material-icons",children:"back_hand"})}],d=()=>{const f=s.isOpen;s.setIsOpen(!f)};return w.jsx("div",{className:"c__share-member-item",children:w.jsx(vo,{left:w.jsx(Co,{fullName:"",email:t.email,showEmail:!0}),alwaysShowRight:!0,right:w.jsxs("div",{className:"c__share-member-item__right",children:[w.jsx(wo,{roles:e,selectedRole:t.role,onSelect:f=>n==null?void 0:n(t,f),isOpen:a.isOpen,canUpdate:i,onOpenChange:a.setIsOpen,roleTopMessage:o}),i&&w.jsx(Ar,{options:u,isOpen:s.isOpen,onOpenChange:s.setIsOpen,children:w.jsx(se.Button,{color:"primary-text",onClick:d,size:"small",icon:w.jsx("span",{className:"material-icons toto",children:"more_horiz"})})})]})})})},qS=({searchUsersResult:t,children:e,outsideSearchContent:n,accesses:r=[],invitations:i=[],hasNextMembers:o=!1,canUpdate:l=!0,hasNextInvitations:a=!1,...s})=>{const{t:u}=se.useCunningham(),{isMobile:d}=nr(),f=c.useRef(null),[v,g]=c.useState("400px"),$=c.useRef(null),[p,b]=c.useState(""),[m,C]=c.useState(""),[S,D]=c.useState([]),[x,T]=c.useState(s.invitationRoles[0].value??""),I=d?"calc(100dvh - 32px)":"min(690px, calc(100dvh - 2em - 12px - 32px))",h=H=>{if(f.current&&clearTimeout(f.current),H===""){C(""),s.onSearchUsers("");return}f.current=setTimeout(()=>{s.onSearchUsers(H),C(H)},300)},L=H=>{b(H),h(H)},A=(m!==""||S.length>0)&&!s.loading,P=c.useCallback(H=>{D(O=>[...O,H]),b(""),C(""),s.onSearchUsers("")},[s]),F=H=>{D(O=>O.filter(q=>q.id!==H.id))},y=c.useMemo(()=>{const H=t==null?void 0:t.filter(M=>!S.includes(M));let O=u(m!==""?"components.share.user.no_result":"components.share.user.placeholder");const V=(M=>!!M.match(/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z\-0-9]{2,}))$/))(m??"")&&!(H!=null&&H.some(M=>M.email===m)),U={id:m,full_name:"",email:m};return V&&(O=void 0),{groupName:u("components.share.search.group_name"),elements:H??[],showWhenEmpty:!0,emptyString:O,endActions:V?[{content:w.jsx(va,{user:U}),onSelect:()=>void P(U)}]:void 0}},[t,m,u,S,P]),E=H=>{var N;const q=(H==null?void 0:H.clientHeight)??0,V=((N=$.current)==null?void 0:N.clientHeight)??0,U=`calc(${I} - ${q}px - ${V}px - 70px - 10px)`;g(U)},K=!A&&!s.loading&&i.length>0,B=!A&&!s.loading&&r.length>0;return w.jsx(se.Modal,{title:s.modalTitle??u("components.share.modalTitle"),isOpen:s.isOpen,onClose:s.onClose,closeOnClickOutside:!0,size:d?se.ModalSize.FULL:se.ModalSize.LARGE,children:w.jsxs("div",{children:[S.length>0&&w.jsx("div",{className:"c__share-modal__selected-users",ref:$,children:w.jsx(Pp,{users:S,onRemoveUser:F,roles:s.invitationRoles,selectedRole:x,onSelectRole:T,onShare:()=>{s.onInviteUser(S,x),D([])}})}),w.jsx(Dh,{onFilter:L,inputValue:p,loading:s.loading,placeholder:u("components.share.user.placeholder"),children:w.jsxs("div",{style:{height:v,overflowY:"auto"},children:[A&&!s.loading&&w.jsx("div",{className:"c__share-modal__search-users",children:w.jsx(Ih,{group:y,onSelect:H=>{P(H)},renderElement:H=>w.jsx(va,{user:H})})}),!A&&e,K&&w.jsxs("div",{className:"c__share-modal__invitations",children:[w.jsx("span",{className:"c__share-modal__invitations-title",children:u("components.share.invitations.title")}),i.map(H=>{var O;return w.jsx(Op,{invitation:H,roles:s.invitationRoles,updateRole:s.onUpdateInvitation,deleteInvitation:s.onDeleteInvitation,canUpdate:l,roleTopMessage:(O=s.invitationRoleTopMessage)==null?void 0:O.call(s,H)},H.id)}),w.jsx(cd,{show:a,onShowMore:s.onLoadNextInvitations})]}),B&&w.jsxs("div",{className:"c__share-modal__members",children:[w.jsx("span",{className:"c__share-modal__members-title",children:u(r.length>1?"components.share.members.title_plural":"components.share.members.title_singular",{count:r.length})}),r.map(H=>{var O,q;return w.jsx(Ip,{accessData:H,canUpdate:l,roleTopMessage:(O=s.accessRoleTopMessage)==null?void 0:O.call(s,H),roles:((q=s.getAccessRoles)==null?void 0:q.call(s,H))??s.invitationRoles,updateRole:s.onUpdateAccess,deleteAccess:s.onDeleteAccess},H.id)}),w.jsx(cd,{show:o,onShowMore:s.onLoadNextMembers})]})]})}),w.jsx("div",{ref:E,children:!A&&w.jsx(w.Fragment,{children:n})})]})})},cd=({show:t,onShowMore:e})=>{const{t:n}=se.useCunningham();return t?w.jsx("div",{className:"c__share-modal__show-more-button",children:w.jsx(se.Button,{color:"primary-text",size:"small",icon:w.jsx("span",{className:"material-icons",children:"arrow_downward"}),onClick:e,children:n("components.share.members.load_more")})}):null},YS=({onCopyLink:t,onOk:e})=>{const{t:n}=se.useCunningham();return w.jsxs("div",{className:"c__share-modal__copy-link-footer",children:[w.jsx(se.Button,{color:"tertiary",icon:w.jsx("span",{className:"material-icons",children:"link"}),onClick:t,children:n("components.share.copyLink")}),w.jsx(se.Button,{color:"primary",onClick:e,children:n("components.share.ok")})]})};exports.AccessRoleDropdown=wo;exports.CunninghamProvider=Vp;exports.CustomTabs=v4;exports.DropdownMenu=Ar;exports.Filter=vb;exports.Footer=gb;exports.Header=w2;exports.Hero=bb;exports.HomeGutter=yb;exports.HorizontalSeparator=ia;exports.InvitationUserSelectorItem=Tp;exports.InvitationUserSelectorList=Pp;exports.LaGaufre=Ob;exports.Label=W2;exports.LanguagePicker=S2;exports.LeftPanel=C2;exports.MainLayout=sy;exports.ProConnectButton=hd;exports.QuickSearch=Dh;exports.QuickSearchGroup=Ih;exports.QuickSearchInput=Th;exports.QuickSearchItem=bi;exports.QuickSearchItemTemplate=vo;exports.SearchUserItem=va;exports.ShareInvitationItem=Op;exports.ShareMemberItem=Ip;exports.ShareModal=qS;exports.ShareModalCopyLinkFooter=YS;exports.Spinner=Ya;exports.TreeApi=Vn;exports.TreeContext=ds;exports.TreeProvider=xS;exports.TreeView=PS;exports.TreeViewItem=US;exports.TreeViewMoveModeEnum=Ht;exports.TreeViewNodeTypeEnum=ze;exports.TreeViewSeparator=Sp;exports.UserAvatar=Dp;exports.UserRow=Co;exports.WithLabel=cy;exports.cunninghamConfig=Xl;exports.getLocales=fd;exports.headerHeight=uy;exports.isNode=$r;exports.isSeparator=Gi;exports.isTitle=qi;exports.useDropdownMenu=Yn;exports.useResponsive=nr;exports.useTree=wp;exports.useTreeContext=fs;
101
+ Use the data prop if you want to provide your own handlers.`);if(t.initialData){const[e,n]=yS(t.initialData);return Object.assign(Object.assign(Object.assign({},t),n),{data:e})}else return t}function SS(t,e){const n=$S(t);return w.jsxs(dS,{treeProps:n,imperativeHandle:e,children:[w.jsx(hS,{children:w.jsx(pS,{})}),w.jsx(gS,{})]})}const wS=c.forwardRef(SS),Sp=({top:t,left:e})=>w.jsx("div",{className:"c__tree-view__cursor",style:{top:t-2,left:e+10,width:`calc(100% - ${24+e}px)`}});function CS(t,e){var n=c.useRef(null),r=c.useRef(null);r.current=e;var i=c.useRef(null);c.useEffect(function(){o()});var o=c.useCallback(function(){var l=i.current,a=r.current,s=l||(a?a instanceof Element?a:a.current:null);n.current&&n.current.element===s&&n.current.subscriber===t||(n.current&&n.current.cleanup&&n.current.cleanup(),n.current={element:s,subscriber:t,cleanup:s?t(s):void 0})},[t]);return c.useEffect(function(){return function(){n.current&&n.current.cleanup&&(n.current.cleanup(),n.current=null)}},[]),c.useCallback(function(l){i.current=l,o()},[o])}function ed(t,e,n){return t[e]?t[e][0]?t[e][0][n]:t[e][n]:e==="contentBoxSize"?t.contentRect[n==="inlineSize"?"width":"height"]:void 0}function ES(t){t===void 0&&(t={});var e=t.onResize,n=c.useRef(void 0);n.current=e;var r=t.round||Math.round,i=c.useRef(),o=c.useState({width:void 0,height:void 0}),l=o[0],a=o[1],s=c.useRef(!1);c.useEffect(function(){return s.current=!1,function(){s.current=!0}},[]);var u=c.useRef({width:void 0,height:void 0}),d=CS(c.useCallback(function(f){return(!i.current||i.current.box!==t.box||i.current.round!==r)&&(i.current={box:t.box,round:r,instance:new ResizeObserver(function(v){var g=v[0],$=t.box==="border-box"?"borderBoxSize":t.box==="device-pixel-content-box"?"devicePixelContentBoxSize":"contentBoxSize",p=ed(g,$,"inlineSize"),b=ed(g,$,"blockSize"),m=p?r(p):void 0,C=b?r(b):void 0;if(u.current.width!==m||u.current.height!==C){var S={width:m,height:C};u.current.width=m,u.current.height=C,n.current?n.current(S):s.current||a(S)}})}),i.current.instance.observe(f,{box:t.box}),function(){i.current&&i.current.instance.unobserve(f)}},[t.box,r]),t.ref);return c.useMemo(function(){return{ref:d,width:l.width,height:l.height}},[d,l.width,l.height])}var ze=(t=>(t.NODE="node",t.SEPARATOR="separator",t.TITLE="title",t))(ze||{}),Ht=(t=>(t.FIRST_CHILD="first-child",t.LAST_CHILD="last-child",t.LEFT="left",t.RIGHT="right",t))(Ht||{});const Gi=t=>t?t.nodeType===ze.SEPARATOR:!1,qi=t=>t?t.nodeType===ze.TITLE:!1,$r=t=>!Gi(t)&&!qi(t),wp=(t,e,n)=>{const{remove:r,update:i,insert:o,insertBefore:l,insertAfter:a,append:s,prepend:u,getItem:d,move:f,items:v}=D1({initialItems:JSON.parse(JSON.stringify(t)),getKey:V=>V.id,getChildren:V=>V.children||[]}),[g,$]=c.useState(),p=(V=[])=>{const U=v.map(M=>M.key);r(...U);const N=JSON.parse(JSON.stringify(V));N.length>0&&o(null,0,...N),$(void 0)},b=V=>{const U=d(V);U&&$(U.value)},m=(V,U,N)=>{var M;if(V){const z=d(V);z&&o(V,N??((M=z.children)==null?void 0:M.length)??0,U)}else o(null,N??v.length,U)},C=V=>{var U;return(U=d(V))==null?void 0:U.value},S=(V,U)=>{var W;const N=d(V);if(!N){console.error("No item found");return}let M=((W=N.children)==null?void 0:W.map(G=>G.value))??null;const z=U.childrenCount??N.value.childrenCount??0;if((M==null?void 0:M.length)===0&&z>0&&(M=null),U.children&&(M=[...M??[],...U.children]),U.children){const G=new Set(U.children.map(R=>R.id));M=U.children.filter(R=>!G.has(R.id)),M=[...M??[],...U.children]}const j={...N.value,...U,children:M,childrenCount:(M==null?void 0:M.length)??z};i(V,j)},D=V=>{r(V)},x=V=>{r(...V)},T=async V=>{if(!e){console.error("No refresh callback provided");return}try{const U=await e(V);S(V,U)}catch(U){console.error("error while refreshing node:",U)}},I=(V,U)=>{o(null,U??v.length,V)},h=(V,U)=>{o(null,U??v.length,...V)},L=(V,U)=>{const N=d(V);if(!N){console.error("No item found");return}const M={...N.value,children:U,childrenCount:U.length,hasLoadedChildren:U.length>0};i(V,M)},A=V=>{const U=[],N=d(V);if(!N)return[];U.push(N.value);const M=z=>{const j=P(z);if(!j)return;const W=d(j);W&&(U.push(W.value),M(j))};return M(V),U.reverse()},P=V=>{var U;return((U=d(V))==null?void 0:U.parentKey)??null},F=V=>{const U=P(V);if(!U)return null;const N=d(U);return N?N.value:null},y=(V,U)=>{l(V,U)},E=(V,U)=>{a(V,U)},K=(V,U)=>{s(V,U)},B=(V,U)=>{u(V,U)},H=(V,U,N)=>{f(V,U,N)},O=V=>{H(V.sourceId,V.newParentId,V.index)},q=async V=>{if(!n)return[];const U=await n(V);return S(V,{children:U,hasLoadedChildren:!0,childrenCount:U.length}),U};return c.useEffect(()=>{const V=U=>{U.forEach(N=>{var M;if(N.children&&N.children.length>0){const z=N.value.hasLoadedChildren||((M=N.children)==null?void 0:M.length)>0||N.value.children&&N.value.children.length>0;N.value.children=N.children.map(W=>W.value);const j=z?N.children.length:N.value.childrenCount??0;N.value.childrenCount=j,z&&!N.value.hasLoadedChildren&&(N.value.hasLoadedChildren=!0),V(N.children)}else{const j=N.value.hasLoadedChildren||N.value.children&&N.value.children.length>0?0:N.value.childrenCount;N.value.children=[],N.value.childrenCount=j}})};V(v)},[v]),{nodes:v,addChild:m,updateNode:S,deleteNode:D,deleteNodes:x,addRootNode:I,addRootNodes:h,selectedNode:g,setSelectedNode:$,refreshNode:T,setChildren:L,insertBeforeNode:y,insertAfterNode:E,handleMove:O,prependToNode:B,moveNode:H,appendToNode:K,move:f,resetTree:p,handleLoadChildren:q,selectNodeById:b,getParent:F,getNode:C,getParentId:P,getAncestors:A}},ds=c.createContext(null),xS=({children:t,onRefresh:e,initialNodeId:n,onLoadChildren:r,initialTreeData:i})=>{const o=c.useRef(null),[l,a]=c.useState(null),[s,u]=c.useState(n??null),d=wp(i??[],e,r);return w.jsx(ds.Provider,{value:{treeApiRef:o,treeData:d,root:l,initialTargetId:s,setInitialTargetId:u,setRoot:a},children:t})},fs=()=>{const t=c.useContext(ds);if(!t)throw new Error("TreeContext not found");return t},PS=({initialOpenState:t,selectedNodeId:e,rootNodeId:n,renderNode:r,canDrop:i,canDrag:o,afterMove:l,beforeMove:a})=>{const[s,u]=c.useState(400),{ref:d,width:f}=ES(),v=fs(),g=(v==null?void 0:v.treeData.nodes)??[];c.useEffect(()=>{const m=document.querySelector(".c__tree-view"),C=m==null?void 0:m.firstElementChild;let S=null;return m&&C&&(S=new ResizeObserver(()=>{if(C&&C instanceof HTMLElement){const D=C.style.height;u(parseInt(D,10)+20)}}),S.observe(C)),()=>S==null?void 0:S.disconnect()},[]);const $=m=>{var O,q,V,U;const C=JSON.parse(JSON.stringify(g)),S=m.dragNodes[0],D=m.parentId?((O=m.parentNode)==null?void 0:O.data.children)??[]:C,x=m.dragNodes[0].data.value.id,T=m.dragNodes[0].data,I=(q=m.parentNode)==null?void 0:q.data;if((I==null?void 0:I.value.nodeType)===ze.TITLE||(I==null?void 0:I.value.nodeType)===ze.SEPARATOR)return null;const h=T.parentKey??n,L=m.parentId??n;let A=m.index+0,P=null,F=L;const y=((U=(V=S.parent)==null?void 0:V.children)==null?void 0:U.findIndex(N=>N.data.value.id===x))??0;if(h===L){if(y===A)return null;A=A<y?A:A-1}const E=m.index-1,K=D[E],B=m.index,H=D[B];return m.index===0?(F=m.parentId??n,P=Ht.FIRST_CHILD):!I&&m.index===1&&!$r(K.value)?(F=n,A=1,P=Ht.FIRST_CHILD):m.index===D.length?(F=F??n,P=Ht.LAST_CHILD):K&&$r(K.value)?(F=K.value.id,P=Ht.RIGHT):H&&$r(H.value)&&(P=Ht.LEFT,F=H.value.id),P&&F?{targetModeId:F,mode:P,oldParentId:h,index:A,newParentId:m.parentId,sourceId:x}:null},p=m=>{const C=$(m);C&&(a?a(C,()=>{v==null||v.treeData.handleMove(C),l==null||l(C)}):(v==null||v.treeData.handleMove(C),l==null||l(C)))},b=c.useCallback(m=>o?!o(m):!1,[o]);if(v)return w.jsx("div",{ref:d,style:{height:s},className:"c__tree-view--container",children:w.jsx(wS,{data:g,ref:v.treeApiRef,openByDefault:!1,selectionFollowsFocus:!1,disableMultiSelection:!0,disableEdit:!0,className:"c__tree-view",idAccessor:"key",onMove:p,height:s,width:f,paddingTop:10,paddingBottom:10,rowHeight:35,disableDrag:b,disableDrop:({parentNode:m,dragNodes:C,index:S})=>{var h,L;if(i&&!i({parentNode:m,dragNodes:C,index:S}))return m.id!=="__REACT_ARBORIST_INTERNAL_ROOT__"&&(m.data.value.canDrop=!1),!0;const D=C[0];if(D&&D.isDragging&&D.willReceiveDrop||((h=m.data.value)==null?void 0:h.nodeType)===ze.TITLE||((L=m.data.value)==null?void 0:L.nodeType)===ze.SEPARATOR)return!0;if(m.id==="__REACT_ARBORIST_INTERNAL_ROOT__"){const A=g[S-1],P=g[S],F=g[S+1],y=Gi(A==null?void 0:A.value),E=Gi(P==null?void 0:P.value),K=qi(A==null?void 0:A.value),B=qi(P==null?void 0:P.value),H=$r(F==null?void 0:F.value);return!!(S===0&&(E||B)||y&&B&&H||K&&E&&H)}const x=m==null?void 0:m.isOpen,T=(m==null?void 0:m.data.value.childrenCount)&&m.data.value.childrenCount>0||(m==null?void 0:m.data.children)&&m.data.children.length>0;if(!T)return m.data.value.canDrop=!0,!1;let I=m.data.value.childrenCount&&m.data.value.childrenCount>0&&(m==null?void 0:m.data.children)&&m.data.children.length>0;return I=I??!0,!x&&!I&&T?(m.data.value.canDrop=!0,!0):(m.data.value.canDrop=!0,!1)},initialOpenState:t,overscanCount:20,selection:e,renderCursor:Sp,renderRow:TS,rowClassName:"c__tree-view--row",children:r})})},TS=({children:t,...e})=>{const n=e.node.data.value.nodeType===ze.TITLE,r=e.node.data.value.nodeType===ze.SEPARATOR,{style:i}=e.attrs,o={...i};return n||r?c.createElement("div",{...e.attrs,key:e.node.id,style:o,ref:e.innerRef,onFocus:l=>l.stopPropagation(),onClick:e.node.handleClick},t):c.createElement("div",{...e.attrs,style:o,key:e.node.id,ref:e.innerRef,onFocus:l=>l.stopPropagation(),onClick:e.node.handleClick},w.jsx("div",{className:"c__tree-view--row-content",children:t}))},DS=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function IS(t){const e=Object.prototype.toString.call(t);return e==="[object Window]"||e==="[object global]"}function OS(t){return"nodeType"in t}function _S(t){var e,n;return t?IS(t)?t:OS(t)&&(e=(n=t.ownerDocument)==null?void 0:n.defaultView)!=null?e:window:window}const Cp=DS?c.useLayoutEffect:c.useEffect;function Ep(t){const e=c.useRef(t);return Cp(()=>{e.current=t}),c.useCallback(function(){for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return e.current==null?void 0:e.current(...r)},[])}function td(t,e){e===void 0&&(e=[t]);const n=c.useRef(t);return Cp(()=>{n.current!==t&&(n.current=t)},e),n}function kS(t){const e=Ep(t),n=c.useRef(null),r=c.useCallback(i=>{i!==n.current&&(e==null||e(i,n.current)),n.current=i},[]);return[n,r]}let Sl={};function LS(t,e){return c.useMemo(()=>{const n=Sl[t]==null?0:Sl[t]+1;return Sl[t]=n,t+"-"+n},[t,e])}var xr;(function(t){t.DragStart="dragStart",t.DragMove="dragMove",t.DragEnd="dragEnd",t.DragCancel="dragCancel",t.DragOver="dragOver",t.RegisterDroppable="registerDroppable",t.SetDroppableDisabled="setDroppableDisabled",t.UnregisterDroppable="unregisterDroppable"})(xr||(xr={}));function nd(){}const MS=Object.freeze({x:0,y:0});function NS(t){if(t.startsWith("matrix3d(")){const e=t.slice(9,-1).split(/, /);return{x:+e[12],y:+e[13],scaleX:+e[0],scaleY:+e[5]}}else if(t.startsWith("matrix(")){const e=t.slice(7,-1).split(/, /);return{x:+e[4],y:+e[5],scaleX:+e[0],scaleY:+e[3]}}return null}function RS(t,e,n){const r=NS(e);if(!r)return t;const{scaleX:i,scaleY:o,x:l,y:a}=r,s=t.left-l-(1-i)*parseFloat(n),u=t.top-a-(1-o)*parseFloat(n.slice(n.indexOf(" ")+1)),d=i?t.width/i:t.width,f=o?t.height/o:t.height;return{width:d,height:f,top:u,right:s+d,bottom:u+f,left:s}}const AS={ignoreTransform:!1};function xp(t,e){e===void 0&&(e=AS);let n=t.getBoundingClientRect();if(e.ignoreTransform){const{transform:u,transformOrigin:d}=_S(t).getComputedStyle(t);u&&(n=RS(n,u,d))}const{top:r,left:i,width:o,height:l,bottom:a,right:s}=n;return{top:r,left:i,width:o,height:l,bottom:a,right:s}}function rd(t){return xp(t,{ignoreTransform:!0})}var Fn;(function(t){t[t.Forward=1]="Forward",t[t.Backward=-1]="Backward"})(Fn||(Fn={}));var id;(function(t){t.Click="click",t.DragStart="dragstart",t.Keydown="keydown",t.ContextMenu="contextmenu",t.Resize="resize",t.SelectionChange="selectionchange",t.VisibilityChange="visibilitychange"})(id||(id={}));var Tt;(function(t){t.Space="Space",t.Down="ArrowDown",t.Right="ArrowRight",t.Left="ArrowLeft",t.Up="ArrowUp",t.Esc="Escape",t.Enter="Enter",t.Tab="Tab"})(Tt||(Tt={}));Tt.Space,Tt.Enter,Tt.Esc,Tt.Space,Tt.Enter,Tt.Tab;var od;(function(t){t[t.RightClick=2]="RightClick"})(od||(od={}));var ld;(function(t){t[t.Pointer=0]="Pointer",t[t.DraggableRect=1]="DraggableRect"})(ld||(ld={}));var ad;(function(t){t[t.TreeOrder=0]="TreeOrder",t[t.ReversedTreeOrder=1]="ReversedTreeOrder"})(ad||(ad={}));Fn.Backward+"",Fn.Forward+"",Fn.Backward+"",Fn.Forward+"";var pa;(function(t){t[t.Always=0]="Always",t[t.BeforeDragging=1]="BeforeDragging",t[t.WhileDragging=2]="WhileDragging"})(pa||(pa={}));var ga;(function(t){t.Optimized="optimized"})(ga||(ga={}));function KS(t){let{callback:e,disabled:n}=t;const r=Ep(e),i=c.useMemo(()=>{if(n||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:o}=window;return new o(r)},[n]);return c.useEffect(()=>()=>i==null?void 0:i.disconnect(),[i]),i}pa.WhileDragging,ga.Optimized;const FS={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:nd,draggableNodes:new Map,over:null,measureDroppableContainers:nd},jS=c.createContext(FS);({...MS});var sd;(function(t){t[t.Uninitialized=0]="Uninitialized",t[t.Initializing=1]="Initializing",t[t.Initialized=2]="Initialized"})(sd||(sd={}));const HS="Droppable",zS={timeout:25};function BS(t){let{data:e,disabled:n=!1,id:r,resizeObserverConfig:i}=t;const o=LS(HS),{active:l,dispatch:a,over:s,measureDroppableContainers:u}=c.useContext(jS),d=c.useRef({disabled:n}),f=c.useRef(!1),v=c.useRef(null),g=c.useRef(null),{disabled:$,updateMeasurementsFor:p,timeout:b}={...zS,...i},m=td(p??r),C=c.useCallback(()=>{if(!f.current){f.current=!0;return}g.current!=null&&clearTimeout(g.current),g.current=setTimeout(()=>{u(Array.isArray(m.current)?m.current:[m.current]),g.current=null},b)},[b]),S=KS({callback:C,disabled:$||!l}),D=c.useCallback((h,L)=>{S&&(L&&(S.unobserve(L),f.current=!1),h&&S.observe(h))},[S]),[x,T]=kS(D),I=td(e);return c.useEffect(()=>{!S||!x.current||(S.disconnect(),f.current=!1,S.observe(x.current))},[x,S]),c.useEffect(()=>(a({type:xr.RegisterDroppable,element:{id:r,key:o,disabled:n,node:x,rect:v,data:I}}),()=>a({type:xr.UnregisterDroppable,key:o,id:r})),[r]),c.useEffect(()=>{n!==d.current.disabled&&(a({type:xr.SetDroppableDisabled,id:r,key:o,disabled:n}),d.current.disabled=n)},[r,o,n,a]),{active:l,rect:v,isOver:(s==null?void 0:s.id)===r,node:x,over:s,setNodeRef:T}}const VS=t=>{const{isOver:e,setNodeRef:n}=BS({id:t.id,data:t.data});return c.useEffect(()=>{var r;(r=t.onOver)==null||r.call(t,e,t.data)},[e,t.data,t.onOver]),w.jsx("div",{className:"c__dnd--droppable",ref:n,children:t.children})},US=({children:t,onClick:e,node:n,dragHandle:r,style:i,forceLoading:o})=>{var S,D;const l=fs(),a=c.useRef(null),[s,u]=c.useState(!1),[d,f]=c.useState(!1),v=o??s,g=n.willReceiveDrop||d,$=n.data.value.childrenCount!==void 0&&n.data.value.childrenCount>0||(((S=n.data.children)==null?void 0:S.length)??0)>0,p=((D=n.children)==null?void 0:D.length)??!1,b=n.isLeaf||!$,m=c.useCallback(async()=>{if(!b){if(p||n.data.value.hasLoadedChildren){n.toggle();return}u(!0),await(l==null?void 0:l.treeData.handleLoadChildren(n.data.value.id)),u(!1),n.open()}},[b,p,n,l==null?void 0:l.treeData]),C=c.useCallback(x=>{x&&!n.isOpen&&!n.isDragging&&(a.current=setTimeout(()=>{m()},500)),a.current&&!x&&clearTimeout(a.current)},[m,n.isOpen,n.isDragging]);return c.useEffect(()=>{C(g)},[g,C]),n.data.value.nodeType===ze.SEPARATOR?w.jsx("div",{className:"c__tree-view--node__separator"}):n.data.value.nodeType===ze.TITLE?w.jsx("div",{className:"c__tree-view--node__title",children:n.data.value.headerTitle}):w.jsx(VS,{id:n.id,data:{data:n.data,nodeApi:n},onOver:f,children:w.jsxs("div",{onClick:x=>{x.target.closest(".c__tree-view--node")||x.stopPropagation(),e==null||e()},onKeyDown:x=>{x.stopPropagation()},ref:r,style:i,className:Te("c__tree-view--node",{...n.state,canDrop:n.data.value.canDrop??!0,externalDrop:d}),children:[b&&w.jsx("div",{className:"c__tree-view--node__leaf"}),!b&&w.jsxs(w.Fragment,{children:[v&&w.jsx("div",{className:"c__tree-view--node__loading",children:w.jsx(Ya,{})}),!v&&w.jsx("span",{onClick:x=>{x.stopPropagation(),m()},className:"c__tree-view--node__arrow material-icons",children:n.isOpen?"keyboard_arrow_down":"keyboard_arrow_right"})]}),t]})})},wo=({roles:t,onSelect:e,canUpdate:n=!0,selectedRole:r,isOpen:i,onOpenChange:o,roleTopMessage:l})=>{const a=t.find(s=>s.value===r);return n?w.jsx(Ar,{isOpen:i,shouldCloseOnInteractOutside:s=>!s.closest(".c__access-role-dropdown"),onOpenChange:o,options:t,selectedValues:[r],onSelectValue:e,topMessage:l,children:w.jsxs("div",{role:"button",className:"c__access-role-dropdown",onClick:()=>{o==null||o(!i)},children:[w.jsx("span",{className:"fs-s clr-greyscale-600",children:a==null?void 0:a.label}),w.jsx("span",{className:"material-icons",children:i?"arrow_drop_up":"arrow_drop_down"})]})}):w.jsx("span",{className:"fs-s clr-greyscale-600",children:a==null?void 0:a.label})},Pp=({users:t,onRemoveUser:e,rightActions:n,onShare:r,shareButtonLabel:i,roles:o,selectedRole:l,onSelectRole:a})=>{const{t:s}=se.useCunningham(),[u,d]=c.useState(!1);return w.jsxs("div",{className:"c__add-share-user-list",children:[w.jsx("div",{className:"c__add-share-user-list__items",children:t.map(f=>w.jsx(Tp,{user:f,onRemoveUser:e},f.id))}),w.jsxs("div",{className:"c__add-share-user-list__right-actions",children:[n,w.jsx(wo,{roles:o,selectedRole:l,onSelect:a,isOpen:u,onOpenChange:d}),w.jsx(se.Button,{onClick:r,children:i??s("components.share.shareButton")})]})]})},Tp=({user:t,onRemoveUser:e})=>w.jsxs("div",{className:"c__add-share-user-item",children:[w.jsx("span",{children:t.full_name||t.email}),w.jsx(se.Button,{color:"tertiary-text",size:"nano",onClick:()=>e==null?void 0:e(t),icon:w.jsx("span",{className:"material-icons",children:"close"})})]}),ud=["purple","blue","green","yellow","orange","red","brown","cyan","gold","olive","rose"],WS=t=>{const e=t.split(" ");return e.length>2?e.slice(0,2).map(n=>n[0]).join(""):e.map(n=>n[0]).join("")},GS=t=>ud[t.charCodeAt(0)%ud.length],Dp=({fullName:t,size:e="medium",forceColor:n})=>{const r=WS(t),i=GS(t);return w.jsx("div",{style:{backgroundColor:n||void 0},className:Te(`c__avatar ${e}`,{[i]:!n&&i}),children:w.jsx("div",{className:"c__avatar__initials",children:r})})},Co=({fullName:t,email:e,showEmail:n=!0})=>{const r=t&&t!==""?t:e??"";return w.jsxs("div",{className:"c__user-row",children:[w.jsx(Dp,{fullName:r,size:"small"}),w.jsxs("div",{className:"c__user-row__info",children:[w.jsx("span",{className:"c__user-row__name",children:t}),n&&e&&w.jsx("span",{className:Te("c__user-row__email",{"has-only-email":e&&(t===""||!t)}),children:e})]})]})},va=({user:t})=>{const{t:e}=se.useCunningham();return w.jsx(vo,{left:w.jsx(Co,{fullName:t.full_name,email:t.email}),alwaysShowRight:!1,right:w.jsxs("div",{className:"c__search-user-item-right",children:[w.jsx("span",{children:e("components.share.item.add")}),w.jsx("span",{className:"material-icons",children:"add"})]})})},Ip=({accessData:t,roles:e,updateRole:n,deleteAccess:r,canUpdate:i=!0,roleTopMessage:o})=>{const{t:l}=se.useCunningham(),a=Yn(),s=Yn(),u=[{label:l("components.share.access.delete"),icon:w.jsx("span",{className:"material-icons",children:"back_hand"}),isDisabled:!i,callback:()=>{r==null||r(t)}}],d=()=>{const f=s.isOpen;s.setIsOpen(!f)};return w.jsx("div",{className:"c__share-member-item",children:w.jsx(vo,{left:w.jsx(Co,{fullName:t.user.full_name,email:t.user.email,showEmail:!0}),alwaysShowRight:!0,right:w.jsxs("div",{className:"c__share-member-item__right",children:[w.jsx(wo,{roles:e,selectedRole:t.role,onSelect:f=>n==null?void 0:n(t,f),isOpen:a.isOpen,onOpenChange:a.setIsOpen,canUpdate:i,roleTopMessage:o}),i&&w.jsx(Ar,{options:u,isOpen:s.isOpen,onOpenChange:s.setIsOpen,children:w.jsx(se.Button,{color:"primary-text",onClick:d,size:"small",icon:w.jsx("span",{className:"material-icons toto",children:"more_horiz"})})})]})})})},Op=({invitation:t,roles:e,updateRole:n,deleteInvitation:r,canUpdate:i=!0,roleTopMessage:o})=>{const{t:l}=se.useCunningham(),a=Yn(),s=Yn(),u=[{label:l("components.share.access.delete"),callback:()=>r==null?void 0:r(t),isDisabled:!i,icon:w.jsx("span",{className:"material-icons",children:"back_hand"})}],d=()=>{const f=s.isOpen;s.setIsOpen(!f)};return w.jsx("div",{className:"c__share-member-item",children:w.jsx(vo,{left:w.jsx(Co,{fullName:"",email:t.email,showEmail:!0}),alwaysShowRight:!0,right:w.jsxs("div",{className:"c__share-member-item__right",children:[w.jsx(wo,{roles:e,selectedRole:t.role,onSelect:f=>n==null?void 0:n(t,f),isOpen:a.isOpen,canUpdate:i,onOpenChange:a.setIsOpen,roleTopMessage:o}),i&&w.jsx(Ar,{options:u,isOpen:s.isOpen,onOpenChange:s.setIsOpen,children:w.jsx(se.Button,{color:"primary-text",onClick:d,size:"small",icon:w.jsx("span",{className:"material-icons toto",children:"more_horiz"})})})]})})})},qS=({searchUsersResult:t,children:e,outsideSearchContent:n,accesses:r=[],invitations:i=[],hasNextMembers:o=!1,canUpdate:l=!0,hasNextInvitations:a=!1,...s})=>{const{t:u}=se.useCunningham(),{isMobile:d}=nr(),f=c.useRef(null),[v,g]=c.useState("400px"),$=c.useRef(null),[p,b]=c.useState(""),[m,C]=c.useState(""),[S,D]=c.useState([]),[x,T]=c.useState(s.invitationRoles[0].value??""),I=d?"calc(100dvh - 32px)":"min(690px, calc(100dvh - 2em - 12px - 32px))",h=H=>{if(f.current&&clearTimeout(f.current),H===""){C(""),s.onSearchUsers("");return}f.current=setTimeout(()=>{s.onSearchUsers(H),C(H)},300)},L=H=>{b(H),h(H)},A=(m!==""||S.length>0)&&!s.loading,P=c.useCallback(H=>{D(O=>[...O,H]),b(""),C(""),s.onSearchUsers("")},[s]),F=H=>{D(O=>O.filter(q=>q.id!==H.id))},y=c.useMemo(()=>{const H=t==null?void 0:t.filter(M=>!S.includes(M));let O=u(m!==""?"components.share.user.no_result":"components.share.user.placeholder");const V=(M=>!!M.match(/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z\-0-9]{2,}))$/))(m??"")&&!(H!=null&&H.some(M=>M.email===m)),U={id:m,full_name:"",email:m};return V&&(O=void 0),{groupName:u("components.share.search.group_name"),elements:H??[],showWhenEmpty:!0,emptyString:O,endActions:V?[{content:w.jsx(va,{user:U}),onSelect:()=>void P(U)}]:void 0}},[t,m,u,S,P]),E=H=>{var N;const q=(H==null?void 0:H.clientHeight)??0,V=((N=$.current)==null?void 0:N.clientHeight)??0,U=`calc(${I} - ${q}px - ${V}px - 70px - 10px)`;g(U)},K=!A&&!s.loading&&i.length>0,B=!A&&!s.loading&&r.length>0;return w.jsx(se.Modal,{title:s.modalTitle??u("components.share.modalTitle"),isOpen:s.isOpen,onClose:s.onClose,closeOnClickOutside:!0,size:d?se.ModalSize.FULL:se.ModalSize.LARGE,children:w.jsxs("div",{children:[l&&S.length>0&&w.jsx("div",{className:"c__share-modal__selected-users",ref:$,children:w.jsx(Pp,{users:S,onRemoveUser:F,roles:s.invitationRoles,selectedRole:x,onSelectRole:T,onShare:()=>{s.onInviteUser(S,x),D([])}})}),w.jsx(Dh,{onFilter:L,inputValue:p,showInput:l,loading:s.loading,placeholder:u("components.share.user.placeholder"),children:w.jsxs("div",{style:{height:v,overflowY:"auto"},children:[A&&!s.loading&&w.jsx("div",{className:"c__share-modal__search-users",children:w.jsx(Ih,{group:y,onSelect:H=>{P(H)},renderElement:H=>w.jsx(va,{user:H})})}),!A&&e,K&&w.jsxs("div",{className:"c__share-modal__invitations",children:[w.jsx("span",{className:"c__share-modal__invitations-title",children:u("components.share.invitations.title")}),i.map(H=>{var O;return w.jsx(Op,{invitation:H,roles:s.invitationRoles,updateRole:s.onUpdateInvitation,deleteInvitation:s.onDeleteInvitation,canUpdate:l,roleTopMessage:(O=s.invitationRoleTopMessage)==null?void 0:O.call(s,H)},H.id)}),w.jsx(cd,{show:a,onShowMore:s.onLoadNextInvitations})]}),B&&w.jsxs("div",{className:"c__share-modal__members",children:[w.jsx("span",{className:"c__share-modal__members-title",children:u(r.length>1?"components.share.members.title_plural":"components.share.members.title_singular",{count:r.length})}),r.map(H=>{var O,q;return w.jsx(Ip,{accessData:H,canUpdate:l,roleTopMessage:(O=s.accessRoleTopMessage)==null?void 0:O.call(s,H),roles:((q=s.getAccessRoles)==null?void 0:q.call(s,H))??s.invitationRoles,updateRole:s.onUpdateAccess,deleteAccess:s.onDeleteAccess},H.id)}),w.jsx(cd,{show:o,onShowMore:s.onLoadNextMembers})]})]})}),w.jsx("div",{ref:E,children:!A&&w.jsx(w.Fragment,{children:n})})]})})},cd=({show:t,onShowMore:e})=>{const{t:n}=se.useCunningham();return t?w.jsx("div",{className:"c__share-modal__show-more-button",children:w.jsx(se.Button,{color:"primary-text",size:"small",icon:w.jsx("span",{className:"material-icons",children:"arrow_downward"}),onClick:e,children:n("components.share.members.load_more")})}):null},YS=({onCopyLink:t,onOk:e})=>{const{t:n}=se.useCunningham();return w.jsxs("div",{className:"c__share-modal__copy-link-footer",children:[w.jsx(se.Button,{color:"tertiary",icon:w.jsx("span",{className:"material-icons",children:"link"}),onClick:t,children:n("components.share.copyLink")}),w.jsx(se.Button,{color:"primary",onClick:e,children:n("components.share.ok")})]})};exports.AccessRoleDropdown=wo;exports.CunninghamProvider=Vp;exports.CustomTabs=v4;exports.DropdownMenu=Ar;exports.Filter=vb;exports.Footer=gb;exports.Header=w2;exports.Hero=bb;exports.HomeGutter=yb;exports.HorizontalSeparator=ia;exports.InvitationUserSelectorItem=Tp;exports.InvitationUserSelectorList=Pp;exports.LaGaufre=Ob;exports.Label=W2;exports.LanguagePicker=S2;exports.LeftPanel=C2;exports.MainLayout=sy;exports.ProConnectButton=hd;exports.QuickSearch=Dh;exports.QuickSearchGroup=Ih;exports.QuickSearchInput=Th;exports.QuickSearchItem=bi;exports.QuickSearchItemTemplate=vo;exports.SearchUserItem=va;exports.ShareInvitationItem=Op;exports.ShareMemberItem=Ip;exports.ShareModal=qS;exports.ShareModalCopyLinkFooter=YS;exports.Spinner=Ya;exports.TreeApi=Vn;exports.TreeContext=ds;exports.TreeProvider=xS;exports.TreeView=PS;exports.TreeViewItem=US;exports.TreeViewMoveModeEnum=Ht;exports.TreeViewNodeTypeEnum=ze;exports.TreeViewSeparator=Sp;exports.UserAvatar=Dp;exports.UserRow=Co;exports.WithLabel=cy;exports.cunninghamConfig=Xl;exports.getLocales=fd;exports.headerHeight=uy;exports.isNode=$r;exports.isSeparator=Gi;exports.isTitle=qi;exports.useDropdownMenu=Yn;exports.useResponsive=nr;exports.useTree=wp;exports.useTreeContext=fs;
102
102
  //# sourceMappingURL=index.cjs.map