@emailmaker/filemanager 0.10.17 → 0.10.18

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.
@@ -73,5 +73,5 @@ MERCHANTABLITY OR NON-INFRINGEMENT.
73
73
  See the Apache Version 2.0 License for specific language governing permissions
74
74
  and limitations under the License.
75
75
  ***************************************************************************** */
76
- var qF=function(e,t){return qF=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},qF(e,t)};var XF=function(){return XF=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},XF.apply(this,arguments)};var KF="Pixel",ZF="Percent",JF={unit:ZF,value:.8};function QF(e){return"number"==typeof e?{unit:ZF,value:100*e}:"string"==typeof e?e.match(/^(\d*(\.\d+)?)px$/)?{unit:KF,value:parseFloat(e)}:e.match(/^(\d*(\.\d+)?)%$/)?{unit:ZF,value:parseFloat(e)}:(console.warn('scrollThreshold format is invalid. Valid formats: "120px", "50%"...'),JF):(console.warn("scrollThreshold should be string or number"),JF)}var eP=function(e){function t(t){var n=e.call(this,t)||this;return n.lastScrollTop=0,n.actionTriggered=!1,n.startY=0,n.currentY=0,n.dragging=!1,n.maxPullDownDistance=0,n.getScrollableTarget=function(){return n.props.scrollableTarget instanceof HTMLElement?n.props.scrollableTarget:"string"==typeof n.props.scrollableTarget?document.getElementById(n.props.scrollableTarget):(null===n.props.scrollableTarget&&console.warn("You are trying to pass scrollableTarget but it is null. This might\n happen because the element may not have been added to DOM yet.\n See https://github.com/ankeetmaini/react-infinite-scroll-component/issues/59 for more info.\n "),null)},n.onStart=function(e){n.lastScrollTop||(n.dragging=!0,e instanceof MouseEvent?n.startY=e.pageY:e instanceof TouchEvent&&(n.startY=e.touches[0].pageY),n.currentY=n.startY,n._infScroll&&(n._infScroll.style.willChange="transform",n._infScroll.style.transition="transform 0.2s cubic-bezier(0,0,0.31,1)"))},n.onMove=function(e){n.dragging&&(e instanceof MouseEvent?n.currentY=e.pageY:e instanceof TouchEvent&&(n.currentY=e.touches[0].pageY),n.currentY<n.startY||(n.currentY-n.startY>=Number(n.props.pullDownToRefreshThreshold)&&n.setState({pullToRefreshThresholdBreached:!0}),n.currentY-n.startY>1.5*n.maxPullDownDistance||n._infScroll&&(n._infScroll.style.overflow="visible",n._infScroll.style.transform="translate3d(0px, "+(n.currentY-n.startY)+"px, 0px)")))},n.onEnd=function(){n.startY=0,n.currentY=0,n.dragging=!1,n.state.pullToRefreshThresholdBreached&&(n.props.refreshFunction&&n.props.refreshFunction(),n.setState({pullToRefreshThresholdBreached:!1})),requestAnimationFrame(function(){n._infScroll&&(n._infScroll.style.overflow="auto",n._infScroll.style.transform="none",n._infScroll.style.willChange="unset")})},n.onScrollListener=function(e){"function"==typeof n.props.onScroll&&setTimeout(function(){return n.props.onScroll&&n.props.onScroll(e)},0);var t=n.props.height||n._scrollableNode?e.target:document.documentElement.scrollTop?document.documentElement:document.body;n.actionTriggered||((n.props.inverse?n.isElementAtTop(t,n.props.scrollThreshold):n.isElementAtBottom(t,n.props.scrollThreshold))&&n.props.hasMore&&(n.actionTriggered=!0,n.setState({showLoader:!0}),n.props.next&&n.props.next()),n.lastScrollTop=t.scrollTop)},n.state={showLoader:!1,pullToRefreshThresholdBreached:!1,prevDataLength:t.dataLength},n.throttledOnScrollListener=function(e,t,n,r){var i,o=!1,a=0;function s(){i&&clearTimeout(i)}function l(){var l=this,c=Date.now()-a,u=arguments;function d(){a=Date.now(),n.apply(l,u)}o||(r&&!i&&d(),s(),void 0===r&&c>e?d():!0!==t&&(i=setTimeout(r?function(){i=void 0}:d,void 0===r?e-c:e)))}return"boolean"!=typeof t&&(r=n,n=t,t=void 0),l.cancel=function(){s(),o=!0},l}(150,n.onScrollListener).bind(n),n.onStart=n.onStart.bind(n),n.onMove=n.onMove.bind(n),n.onEnd=n.onEnd.bind(n),n}return function(e,t){function n(){this.constructor=e}qF(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}(t,e),t.prototype.componentDidMount=function(){if(void 0===this.props.dataLength)throw new Error('mandatory prop "dataLength" is missing. The prop is needed when loading more content. Check README.md for usage');if(this._scrollableNode=this.getScrollableTarget(),this.el=this.props.height?this._infScroll:this._scrollableNode||window,this.el&&this.el.addEventListener("scroll",this.throttledOnScrollListener),"number"==typeof this.props.initialScrollY&&this.el&&this.el instanceof HTMLElement&&this.el.scrollHeight>this.props.initialScrollY&&this.el.scrollTo(0,this.props.initialScrollY),this.props.pullDownToRefresh&&this.el&&(this.el.addEventListener("touchstart",this.onStart),this.el.addEventListener("touchmove",this.onMove),this.el.addEventListener("touchend",this.onEnd),this.el.addEventListener("mousedown",this.onStart),this.el.addEventListener("mousemove",this.onMove),this.el.addEventListener("mouseup",this.onEnd),this.maxPullDownDistance=this._pullDown&&this._pullDown.firstChild&&this._pullDown.firstChild.getBoundingClientRect().height||0,this.forceUpdate(),"function"!=typeof this.props.refreshFunction))throw new Error('Mandatory prop "refreshFunction" missing.\n Pull Down To Refresh functionality will not work\n as expected. Check README.md for usage\'')},t.prototype.componentWillUnmount=function(){this.el&&(this.el.removeEventListener("scroll",this.throttledOnScrollListener),this.props.pullDownToRefresh&&(this.el.removeEventListener("touchstart",this.onStart),this.el.removeEventListener("touchmove",this.onMove),this.el.removeEventListener("touchend",this.onEnd),this.el.removeEventListener("mousedown",this.onStart),this.el.removeEventListener("mousemove",this.onMove),this.el.removeEventListener("mouseup",this.onEnd)))},t.prototype.componentDidUpdate=function(e){this.props.dataLength!==e.dataLength&&(this.actionTriggered=!1,this.setState({showLoader:!1}))},t.getDerivedStateFromProps=function(e,t){return e.dataLength!==t.prevDataLength?XF(XF({},t),{prevDataLength:e.dataLength}):null},t.prototype.isElementAtTop=function(e,t){void 0===t&&(t=.8);var n=e===document.body||e===document.documentElement?window.screen.availHeight:e.clientHeight,r=QF(t);return r.unit===KF?e.scrollTop<=r.value+n-e.scrollHeight+1:e.scrollTop<=r.value/100+n-e.scrollHeight+1},t.prototype.isElementAtBottom=function(e,t){void 0===t&&(t=.8);var n=e===document.body||e===document.documentElement?window.screen.availHeight:e.clientHeight,r=QF(t);return r.unit===KF?e.scrollTop+n>=e.scrollHeight-r.value:e.scrollTop+n>=r.value/100*e.scrollHeight},t.prototype.render=function(){var e=this,t=XF({height:this.props.height||"auto",overflow:"auto",WebkitOverflowScrolling:"touch"},this.props.style),n=this.props.hasChildren||!!(this.props.children&&this.props.children instanceof Array&&this.props.children.length),r=this.props.pullDownToRefresh&&this.props.height?{overflow:"auto"}:{};return i.createElement("div",{style:r,className:"infinite-scroll-component__outerdiv"},i.createElement("div",{className:"infinite-scroll-component "+(this.props.className||""),ref:function(t){return e._infScroll=t},style:t},this.props.pullDownToRefresh&&i.createElement("div",{style:{position:"relative"},ref:function(t){return e._pullDown=t}},i.createElement("div",{style:{position:"absolute",left:0,right:0,top:-1*this.maxPullDownDistance}},this.state.pullToRefreshThresholdBreached?this.props.releaseToRefreshContent:this.props.pullDownToRefreshContent)),this.props.children,!this.state.showLoader&&!n&&this.props.hasMore&&this.props.loader,this.state.showLoader&&this.props.hasMore&&this.props.loader,!this.props.hasMore&&this.props.endMessage))},t}(_);function tP(e,t){if(null==e)return{};var n,r,i=function(e,t){if(null==e)return{};var n,r,i={},o=Object.keys(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||(i[n]=e[n]);return i}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function nP(){return nP=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},nP.apply(this,arguments)}function rP(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function iP(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?rP(Object(n),!0).forEach(function(t){oP(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):rP(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function oP(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}const aP={breakpointCols:void 0,className:void 0,columnClassName:void 0,children:void 0,columnAttrs:void 0,column:void 0};class sP extends i.Component{constructor(e){let t;super(e),this.reCalculateColumnCount=this.reCalculateColumnCount.bind(this),this.reCalculateColumnCountDebounce=this.reCalculateColumnCountDebounce.bind(this),t=this.props.breakpointCols&&this.props.breakpointCols.default?this.props.breakpointCols.default:parseInt(this.props.breakpointCols)||2,this.state={columnCount:t}}componentDidMount(){this.reCalculateColumnCount(),window&&window.addEventListener("resize",this.reCalculateColumnCountDebounce)}componentDidUpdate(){this.reCalculateColumnCount()}componentWillUnmount(){window&&window.removeEventListener("resize",this.reCalculateColumnCountDebounce)}reCalculateColumnCountDebounce(){window&&window.requestAnimationFrame?(window.cancelAnimationFrame&&window.cancelAnimationFrame(this._lastRecalculateAnimationFrame),this._lastRecalculateAnimationFrame=window.requestAnimationFrame(()=>{this.reCalculateColumnCount()})):this.reCalculateColumnCount()}reCalculateColumnCount(){const e=window&&window.innerWidth||1/0;let t=this.props.breakpointCols;"object"!=typeof t&&(t={default:parseInt(t)||2});let n=1/0,r=t.default||2;for(let i in t){const o=parseInt(i);o>0&&e<=o&&o<n&&(n=o,r=t[i])}r=Math.max(1,parseInt(r)||1),this.state.columnCount!==r&&this.setState({columnCount:r})}itemsInColumns(){const e=this.state.columnCount,t=new Array(e),n=i.Children.toArray(this.props.children);for(let r=0;r<n.length;r++){const i=r%e;t[i]||(t[i]=[]),t[i].push(n[r])}return t}renderColumns(){const{column:e,columnAttrs:t={},columnClassName:n}=this.props,r=this.itemsInColumns(),o=100/r.length+"%";let a=n;a&&"string"!=typeof a&&(this.logDeprecated('The property "columnClassName" requires a string'),void 0===a&&(a="my-masonry-grid_column"));const s=iP(iP(iP({},e),t),{},{style:iP(iP({},t.style),{},{width:o}),className:a});return r.map((e,t)=>i.createElement("div",nP({},s,{key:t}),e))}logDeprecated(e){console.error("[Masonry]",e)}render(){const e=this.props,{children:t,breakpointCols:n,columnClassName:r,columnAttrs:o,column:a,className:s}=e,l=tP(e,["children","breakpointCols","columnClassName","columnAttrs","column","className"]);let c=s;return"string"!=typeof s&&(this.logDeprecated('The property "className" requires a string'),void 0===s&&(c="my-masonry-grid")),i.createElement("div",nP({},l,{className:c}),this.renderColumns())}}sP.defaultProps=aP;var lP={gifTab:"gifTab",scrollableDiv:"scrollableDiv",gifSearchInput:"gifSearchInput",search:"search",searchResults:"searchResults",myMasonryGrid:"myMasonryGrid",myMasonryGridColumn:"myMasonryGridColumn",listItem:"listItem",loaded:"loaded",loadedImage:"loadedImage",searchOutputWrapper:"searchOutputWrapper",divider:"divider",resultsContainer:"resultsContainer",playButton:"playButton",title:"title",subtitle:"subtitle",noFiles:"noFiles"};const cP={default:4,1600:3,1100:2,700:1},uP=({setImageGifList:r,imageGifList:i=[],currentReqGif:s,setCurrentReqGif:l,inputRef:c,customRequest:u})=>{const{t:d}=Nn(),{GifPlayIcon:h}=ro(),{options:f}=ui(),{config:p}=f,[g,m]=o(null),[v,y]=o(!1),[b,w]=o(25),[x,C]=o(null),_=async function({query:e,page:t}){const n=e.keywords.replace(/[^\w\sа-яёА-ЯЁ]|_/g,"").replace(/[\s_-]+/g," ");try{const e=`https://api.giphy.com/v1/gifs/search?api_key=${null==p?void 0:p.REACT_APP_GIPHY_KEY}&q=${n}&limit=25&offset=${t}&lang=en`,r=await fetch(e);return{data:await r.json()}}catch(e){console.warn(e)}},S=async()=>{var e,t;const n=await _({query:s,page:0});(null===(t=null===(e=null==n?void 0:n.data)||void 0===e?void 0:e.data)||void 0===t?void 0:t.length)&&n.data.data.length>0&&r(n.data.data)};return a(()=>()=>{x&&clearTimeout(x)},[x]),e("div",{className:lP.gifTab,children:e("div",{className:lP.searchOutputWrapper,children:t("div",{id:"scrollableDiv",className:lP.scrollableDiv,children:[t(T,{onValuesChange:e=>{if(void 0!==e.keywords){l(t=>Object.assign(Object.assign({},t),{keywords:e.keywords})),x&&clearTimeout(x);const t=setTimeout(S,800);C(t)}},className:i.length>0?lP.searchResults:lP.search,children:[e(T.Item,{name:"keywords",className:lP.gifSearchInput,children:e(O,{onKeyDown:e=>"Space"===e.code&&S(),onPressEnter:e=>S(),allowClear:!0,placeholder:d("Search GIFs"),ref:c,spellCheck:"false",prefix:e(ti,{size:16,strokeWidth:null==p?void 0:p.iconStrokeWidth,onClick:S})})}),i.length>0&&!v&&e("div",{className:`ant-divider ${lP.divider}`,role:"separator"})]}),!i.length&&!v&&e(n,{children:s.keywords?e("div",{className:lP.noFiles,children:d("There are no files for your request.")}):t("div",{className:lP.resultsContainer,children:[e("div",{className:lP.videoIcon,children:e(h,{className:lP.playButton})}),e("h1",{className:lP.title,children:d("Over 350,000 live images")}),e("p",{className:lP.subtitle,children:d("Enter a search query and we'll find the perfect image for you")})]})}),!i.length&&v&&e(NF,{}),i.length>0&&e(eP,{dataLength:i&&i.length,next:async()=>{v||(y(!0),_({query:s,page:b}).then(e=>{e&&e.data&&e.data.data&&r(t=>[...t,...e.data.data]),y(!1),w(e=>e+25)}).catch(()=>{y(!1)}))},hasMore:!!i,endMessage:t(X,{plain:!0,children:[d("That`s all we could find.")," 🤐"]}),scrollableTarget:"scrollableDiv",style:{overflow:"visible"},loader:e(NF,{}),children:e(sP,{breakpointCols:cP,className:lP.myMasonryGrid,columnClassName:lP.myMasonryGridColumn,children:i.map((n,r)=>t("div",{className:lP.listItem,onClick:()=>((e,t)=>{m(t),setTimeout(()=>{m(null)},2e3),u(e)})(n.images.downsized.url,n.id),children:[e("img",{className:g===n.id?lP.loadedImage:"",width:"100%",src:`${n.images.downsized.url}`,alt:n.title,onLoad:e=>{const t=e.target.parentNode;t&&t instanceof HTMLElement&&t.classList.add(lP.loaded)}}),e("a",{rel:"noreferrer",href:"https://giphy.com/",target:"_blank",onClick:e=>e.stopPropagation()}),g===n.id&&e(k,{className:lP.antSpin})]},n.id+r))})})]})})})};var dP={stockTab:"stockTab",stockSearchInput:"stockSearchInput",searchOutputWrapper:"searchOutputWrapper",divider:"divider",search:"search",searchResults:"searchResults",scrollableDiv:"scrollableDiv",myMasonryGrid:"myMasonryGrid",myMasonryGridColumn:"myMasonryGridColumn",listItem:"listItem",loaded:"loaded",loadedImage:"loadedImage",creatorInfo:"creatorInfo",stockColorFilter:"stockColorFilter",allColors:"allColors",blackColor:"blackColor",bwColor:"bwColor",whiteColor:"whiteColor",orangeColor:"orangeColor",redColor:"redColor",purpleColor:"purpleColor",magentaColor:"magentaColor",greenColor:"greenColor",tealColor:"tealColor",blueColor:"blueColor",resultsContainer:"resultsContainer",playButton:"playButton",title:"title",subtitle:"subtitle",noFiles:"noFiles"};const hP={default:4,1600:3,1100:2,700:1},fP=({imageStockList:r,setImageStockList:i,currentReq:s,setCurrentReq:l,inputRef:c,customRequest:d})=>{var h;const{t:f}=Nn(),{StockBigIcon:p,MixedViewIcon:g,LandscapeViewIcon:m,PortraitViewIcon:v,SquareViewIcon:y}=ro(),{options:b}=ui(),{config:w}=b,[x,C]=o(!1),[_,S]=o(2),[A,E]=o(null),[I,F]=o(null),[P,M]=o(!0),[R]=T.useForm(),j=u(s);a(()=>{j.current=s},[s]),a(()=>{0===r.length&&R.setFieldsValue({color:"",orientation:""})},[r,R]);const D=async function({query:e,page:t}){const n=e.keywords.replace(/[^\w\sа-яёА-ЯЁ]|_/g,"").replace(/[\s_-]+/g," ");try{let r=`https://api.unsplash.com/search/photos?client_id=${null==w?void 0:w.UNSPLASH_KEY}&lang=ru&per_page=18&query=${n}&page=${t}`;""!==e.color&&(r+=`&color=${e.color}`),""!==e.orientation&&(r+=`&orientation=${e.orientation}`);const i=await fetch(r);return{data:await i.json()}}catch(e){console.warn(e)}finally{C(!1)}},N=async()=>{var e,t,n;C(!0);const r=await D({query:j.current,page:1});(null===(e=null==r?void 0:r.data)||void 0===e?void 0:e.results)&&(i(r.data.results),M(18===r.data.results.length),(null===(n=null===(t=null==r?void 0:r.data)||void 0===t?void 0:t.results)||void 0===n?void 0:n.length)&&r.data.results.length>0&&S(2))};a(()=>()=>{I&&clearTimeout(I)},[I]);const z=(e,t,n)=>{!async function(e){try{const t=await fetch(`${e}&client_id=${null==w?void 0:w.UNSPLASH_KEY}`);return{data:await t.json()}}catch(e){console.warn(e)}}(t.download_location),E(n),setTimeout(()=>E(null),2e3),d(`${e.raw}&w=1200&q=96`)};return e("div",{className:dP.stockTab,children:e("div",{className:dP.searchOutputWrapper,children:t("div",{className:dP.scrollableDiv,id:"scrollableDiv",children:[t(T,{form:R,initialValues:sn,onValuesChange:(e,t)=>{if(l(Object.assign(Object.assign({},sn),t)),I&&clearTimeout(I),""!==t.keywords){const e=setTimeout(N,800);F(e)}else r.length||(l(Object.assign({},sn)),R.resetFields())},className:r.length>0?dP.searchResults:dP.search,children:[t($,{gutter:24,children:[e(W,{span:r.length>0?void 0:24,children:e(T.Item,{name:"keywords",className:dP.stockSearchInput,children:e(O,{allowClear:!0,placeholder:f("Search image"),ref:c,spellCheck:"false",prefix:e(ti,{size:16,strokeWidth:null==w?void 0:w.iconStrokeWidth})})})}),!!r.length&&t(n,{children:[e(W,{children:e(T.Item,{name:"orientation",children:t(Z.Group,{onChange:e=>l(t=>Object.assign(Object.assign({},t),{orientation:e.target.value})),children:[e(L,{title:f("All"),placement:"top",children:e(Z.Button,{value:"",children:e(g,{})})}),e(L,{title:f("Landscape"),placement:"top",children:e(Z.Button,{value:"landscape",children:e(m,{})})}),e(L,{title:f("Portrait"),placement:"top",children:e(Z.Button,{value:"portrait",children:e(v,{})})}),e(L,{title:f("Squarish"),placement:"top",children:e(Z.Button,{value:"squarish",children:e(y,{})})})]})})}),e(W,{children:e(T.Item,{name:"color",children:t(Z.Group,{className:dP.stockColorFilter,onChange:e=>l(t=>Object.assign(Object.assign({},t),{color:e.target.value})),children:[e(L,{title:f("All"),placement:"top",children:e(Z.Button,{className:dP.allColors,value:"",children:"All"})}),e(L,{title:f("Black"),placement:"top",children:e(Z.Button,{className:dP.blackColor,value:"black",children:"B"})}),e(L,{title:f("Black and White"),placement:"top",children:e(Z.Button,{className:dP.bwColor,value:"black_and_white",children:"B&W"})}),e(L,{title:f("White"),placement:"top",children:e(Z.Button,{className:dP.whiteColor,value:"white",children:"W"})}),e(L,{title:f("Orange"),placement:"top",children:e(Z.Button,{className:dP.orangeColor,value:"orange",children:"O"})}),e(L,{title:f("Red"),placement:"top",children:e(Z.Button,{className:dP.redColor,value:"red",children:"R"})}),e(L,{title:f("Purple"),placement:"top",children:e(Z.Button,{className:dP.purpleColor,value:"purple",children:"P"})}),e(L,{title:f("Magenta"),placement:"top",children:e(Z.Button,{className:dP.magentaColor,value:"magenta",children:"M"})}),e(L,{title:f("Green"),placement:"top",children:e(Z.Button,{className:dP.greenColor,value:"green",children:"G"})}),e(L,{title:f("Teal"),placement:"top",children:e(Z.Button,{className:dP.tealColor,value:"teal",children:"T"})}),e(L,{title:f("Blue"),placement:"top",children:e(Z.Button,{className:dP.blueColor,value:"blue",children:"B"})})]})})})]})]}),r.length>0&&!x&&e("div",{className:`ant-divider ${dP.divider}`,role:"separator"})]}),!r.length&&!x&&e(n,{children:s.keywords?e("div",{className:dP.noFiles,children:f("There are no files for your request.")}):t("div",{className:dP.resultsContainer,children:[e("div",{className:dP.videoIcon,children:e(p,{className:dP.playButton})}),e("h1",{className:dP.title,children:f("Millions of free stock images")}),e("p",{className:dP.subtitle,children:f("Enter a search query and we'll find the perfect image for you")})]})}),!r.length&&x&&e(NF,{}),r.length>0&&e(eP,{dataLength:r&&r.length,next:async()=>{if(x||""===j.current.keywords)return C(!1),void(""===j.current.keywords&&M(!1));C(!0),D({query:j.current,page:_}).then(e=>{e&&e.data&&e.data.results&&(i(t=>[...t,...e.data.results]),M(18===e.data.results.length)),S(e=>e+1)}).catch(e=>{console.warn("catch",e)}).finally(()=>{C(!1)})},hasMore:P&&""!==(null===(h=j.current)||void 0===h?void 0:h.keywords),endMessage:t(X,{plain:!0,children:[f("That`s all we could find.")," 🤐"]}),scrollableTarget:"scrollableDiv",style:{overflow:"visible"},loader:e(NF,{}),children:e(sP,{breakpointCols:hP,className:dP.myMasonryGrid,columnClassName:dP.myMasonryGridColumn,children:r.map((n,r)=>t("div",{className:dP.listItem,onClick:()=>z(n.urls,n.links,n.id),children:[e("img",{className:A===n.id?dP.loadedImage:"",width:"100%",src:`${n.urls.raw}&w=644&q=96`,alt:n.description,onLoad:e=>{const t=e.target.parentNode;t&&t instanceof HTMLElement&&t.classList.add(dP.loaded)}}),t("p",{className:dP.creatorInfo,onClick:e=>e.stopPropagation(),children:[f("Photo by")," ",e("a",{target:"_blank",href:`${n.user.links.html}?utm_source=${null==w?void 0:w.APP_NAME_UNSPLASH}&utm_medium=referral`,rel:"noreferrer",children:n.user.name})," ",f("on")," ",e("a",{target:"_blank",href:`https://unsplash.com/?utm_source=${null==w?void 0:w.APP_NAME_UNSPLASH}&utm_medium=referral`,rel:"noreferrer",children:"Unsplash"})]}),A===n.id&&e(k,{className:dP.antSpin})]},n.id+r))})})]})})})},pP=()=>{const{options:e}=ui(),t=e.config;return c((e,n)=>{!1!==(null==t?void 0:t.pushToGTM)&&((e,t)=>{const n=()=>{try{const t=Object.assign(Object.assign({},e),{appLabel:"blocks_app"});window.dataLayer&&"function"==typeof window.dataLayer.push?window.dataLayer.push(t):console.log("Attempting to add to the dataLayer:",e)}catch(e){console.error("Ошибка при вызове GTM:",e)}};t?setTimeout(n,t):n()})(e,n)},[null==t?void 0:t.pushToGTM])};var gP="slideshowContainer",mP="slideshowImage";const vP=({images:t,transitionDuration:n=1e3,frameHeight:r})=>{const[i,s]=o([]),l=()=>{s(e=>e.map((t,n)=>n===e.length-1?Object.assign(Object.assign({},t),{opacity:1}):t))};return a(()=>{if(t.length>0){const e=t[t.length-1];s(t=>[...t,{src:e,opacity:0}]),setTimeout(l,1e3)}else s([])},[t]),e("div",{className:gP,style:{height:600,minHeight:130},children:i.map((t,r)=>e("img",{src:`data:image/jpeg;base64, ${t.src}`,alt:`Slide ${r+1}`,className:mP,style:{opacity:t.opacity,transition:`opacity ${n}ms linear`,display:"block"}},r))})};"function"==typeof SuppressedError&&SuppressedError;const yP=t=>{var{className:n,style:r,color:i,text:o,bordered:a}=t,s=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]])}return n}(t,["className","style","color","text","bordered"]);const l=o||"";return e(J,Object.assign({style:r,color:i,bordered:a,className:n},s,{children:l}))},bP=({text:n,counter:r,limits:i,wrapperStyles:o})=>{const{t:a}=Nn(),{options:s}=ui(),l=s.config,{token:c}=A.useToken(),u=+i>0,d=!u||r<+i,h=(null==l?void 0:l.billingPageUrl)||"/billing",f=r+" "+a("of")+" "+(u?i:"∞")+" "+(n||a("tests",{count:i}))+" "+a("was used",{count:r});return t("div",{className:"limits-couter-wrapper",style:o,children:[e(yP,{bordered:!1,text:f,className:"limit-counter",style:{color:d?c.colorText:"white"},color:d?c.colorFillSecondary:"rgb(255, 77, 79)"}),u&&e("div",{style:{fontSize:14,textDecoration:"underline",cursor:"pointer"},onClick:()=>window.location.assign(h),children:a("Need more?")})]})};var wP={imageAi:"imageAi",imageItem:"imageItem",textAreaInputHybrid:"textAreaInputHybrid",loading:"loading",carousel:"carousel",arrow:"arrow",arrowNext:"arrowNext",arrowPrev:"arrowPrev",arrowBtn:"arrowBtn",arrowBtnNext:"arrowBtnNext",arrowBtnPrev:"arrowBtnPrev",row:"row",inputAffixWrapper:"inputAffixWrapper",textarea:"textarea",inputIcon:"inputIcon"};const xP=f(({className:t,onClick:n})=>e("div",{className:`${wP.arrow} ${wP.arrowNext} ${t||""}`,onClick:n,children:e(D,{className:`${wP.arrowBtn} ${wP.arrowBtnNext}`,size:"large",icon:e(ve,{})})}));xP.displayName="SampleNextArrow";const CP=f(({className:t,onClick:n})=>e("div",{className:`${wP.arrow} ${wP.arrowPrev} ${t||""}`,onClick:n,children:e(D,{className:`${wP.arrowBtn} ${wP.arrowBtnPrev}`,size:"large",icon:e(ye,{})})}));CP.displayName="SamplePrevArrow";const _P=({customRequest:n,aiTabRef:r,inputAiRef:i,isImageUploaded:s,setIsImageUploaded:l,aiImageRequest:u,setAiImageRequest:h,imageAiList:f,setImageAiList:p,isLoadingAi:g,setIsLoadingAi:m})=>{const{t:v}=Nn(),{AiIcon_2:y}=ro(),[b,w]=o("auto"),{aiImageCounter:x,currentAiImgLimits:C,loadingDuringGeneration:_,requestStatus:S,handleGenerate:k,convertBase64ToFile:A,isShiftPressed:E,setIsShiftPressed:I,limitsInPlugin:F}=function({setFrameHeight:e,customRequest:t,aiTabRef:n,isImageUploaded:r,setIsImageUploaded:i,aiImageRequest:s,imageAiList:l,setImageAiList:u,isLoadingAi:h,setIsLoadingAi:f}){const{t:p}=Nn(),{options:g}=ui(),m=g.config,v=gi(),y=pP(),{messages:b}=g.config,[w,x]=o([]),[C,_]=o(0),[S,k]=o(null),[A,E]=o(!1),[I,T]=o(p("Evaluating the task")),[O,F]=o(!1);a(()=>{x(b)},[b]),a(()=>{l.length||S||x([])},[l,S]);const P=d(()=>m&&"function"==typeof(null==m?void 0:m.sendAIImageRequest)?null==m?void 0:m.sendAIImageRequest:()=>Promise.resolve({}),[m]),M=c(e=>{if("error"!==e.status&&"Canceled"!==e.status){if(e.images){if(T(String(e.status)),100===e.progress){f(!1),u(e.images);const t=S,n=Array.isArray(e.images)?e.images:[];n.length>0&&v.success({id:"AI_IMAGE_GENERERATION_SUCCESS",message:p("Images generated successfully"),placement:"bottomRight",data:{request:s,taskId:t,images:n}}),k(null),F(!1)}}else if(u([String(e.data)]),100===e.progress){f(!1);const t=S,n=e.data?[String(e.data)]:[];n.length>0&&v.success({id:"AI_IMAGE_GENERERATION_SUCCESS",message:p("Images generated successfully"),placement:"bottomRight",data:{request:s,taskId:t,images:n}}),k(null),F(!1)}}else f(!1),F(!1),v.error({id:"AI_RESPONSE_INVALID",message:p("Something went wrong, please try again"),placement:"bottomRight",description:String(S)||void 0,data:{requestId:S,request:s,response:e},innerException:e})},[s,u,T,p,f,S,v,F]);a(()=>{w.length>1&&M(w[w.length-1])},[M,w]);const R=d(()=>{if(m&&"function"==typeof(null==m?void 0:m.sseQuery)){const e=null==m?void 0:m.sseQuery;return t=>e(t)}return e=>{}},[m]),L=d(()=>m&&"object"==typeof(null==m?void 0:m.handleLimitUsageEmitter)?null==m?void 0:m.handleLimitUsageEmitter:{fire:()=>{}},[m]),j=null==m?void 0:m.elementId,{projectId:D}=m,{limits:N}=(null==m?void 0:m.limits)?m:{limits:{ai_img_limit:0}},{ai_img_limit:z}=N,B=z>0&&C>=z,V=!(!(null==m?void 0:m.limits)||!m.counters)&&rn,U=c(()=>{L.fire({name:"AiImgCount",count:C+1})},[L,C]),$=d(()=>!B&&!V,[B,V,C,z]),W=c(async()=>{T(p("Evaluating the task")),""===s||h||(f(!0),F(!0),u([]),y({event:"submit_form",action:"ai_image_generation",entity_id:j,project_id:D}),P({body:{project_id:D,request:"create-image",connection:"midjourney",message:s}}).then(e=>{var t,n,r,i,o;const{data:a,error:l}=e||{};if(l)throw l;const c=a;if(401===(null==c?void 0:c.status)||401===(null===(t=null==c?void 0:c.data)||void 0===t?void 0:t.status))throw new Error("ERROR");const u=(null==c?void 0:c.task)||(null===(n=null==c?void 0:c.data)||void 0===n?void 0:n.task),d=null!==(i=null!==(r=null==u?void 0:u.id)&&void 0!==r?r:S)&&void 0!==i?i:void 0;200===(null==c?void 0:c.status)||200===(null===(o=null==c?void 0:c.data)||void 0===o?void 0:o.status)?((null==u?void 0:u.id)&&(T(u.message),k(u.id)),(null==c?void 0:c.message)&&v.success({id:"AI_IMAGE_GENERATION_STARTED",message:c.message,placement:"bottomRight",description:s,data:{request:s,taskId:d,response:null==c?void 0:c.data}}),R({task_id:null==u?void 0:u.id,entity_id:j})):(f(!1),F(!1),v.error({id:"AI_IMAGE_GENERATION_FAILED",message:(null==c?void 0:c.message)||p("Something went wrong, please try again"),placement:"bottomRight",description:s,data:{request:s,taskId:d,response:c},innerException:c}))}).catch(e=>{f(!1),F(!1);const t=e;return((null==t?void 0:t.error)||(null==t?void 0:t.data))&&(null==v||v.error({id:"AI_IMAGE_GENERATION_FAILED",message:p("Something went wrong, please try again"),placement:"bottomRight",description:s,innerException:e,data:{request:s,taskId:S,response:null==t?void 0:t.data,error:null==t?void 0:t.error}})),t}))},[s,h,f,F,u,y,j,D,P,v,R,p,S]),H=c(()=>{$&&W()},[$,V,_,U,W,v,p]);a(()=>{},[m,V]);const G=c(e=>{if(!r){i(!0);const n=e.match(/^data:image\/([A-Za-z-+/]+);base64,(.+)$/);if(!n)return;const r=n[1],o=n[2],a=atob(o),s=new Array(a.length);for(let e=0;e<a.length;e++)s[e]=a.charCodeAt(e);const l=new Uint8Array(s),c=new Blob([l],{type:`image/${r}`}),u=new File([c],"image.jpeg",{type:c.type,lastModified:Date.now()});t({file:u})}},[r,i,t]);return a(()=>{(h||l.length>0)&&setTimeout(()=>{let t=350;n.current&&(t=n.current.offsetHeight-120),e(t)},0)},[n,l.length,h,e]),{aiImageCounter:C,setAiImageCounter:_,currentAiImgLimits:z,isFieldsDisabled:B,canGenerateImage:$,aiImageRequest:s,imageAiList:l,setImageAiList:u,isLoadingAi:h,setIsLoadingAi:f,loadingDuringGeneration:O,setLoadingDuringGeneration:F,requestStatus:I,setRequestStatus:T,handleGenerate:H,handleLimitAiImgCount:U,convertBase64ToFile:G,isShiftPressed:A,setIsShiftPressed:E,currentReqId:S,setCurrentReqId:k,limitsInPlugin:V}}({setFrameHeight:w,customRequest:n,aiTabRef:r,isImageUploaded:s,setIsImageUploaded:l,aiImageRequest:u,imageAiList:f,setImageAiList:p,isLoadingAi:g,setIsLoadingAi:m}),[P,M]=o(!1),R=c(()=>M(!0),[]),L=c(()=>M(!1),[]),j=c(e=>h(e.target.value),[h]),N=c(e=>{"Shift"===e.key?I(!0):"Enter"!==e.key||E||(e.preventDefault(),k())},[E,k,I]),z=c(e=>{"Shift"===e.key&&I(!1)},[I]);return t("div",{className:wP.imageAi,children:[F&&e(bP,{text:"images",counter:x,limits:C,wrapperStyles:{marginTop:-25}}),e($,{gutter:24,className:wP.row,children:e(W,{span:24,children:e(T.Item,{children:t("span",{className:`ant-input-affix-wrapper ant-input-affix-wrapper-lg ${wP.inputAffixWrapper}${P?" ant-input-affix-wrapper-focused":""}`,children:[e(O.TextArea,{ref:i,onKeyDown:N,onKeyUp:z,onFocus:R,onBlur:L,autoSize:!0,allowClear:!0,className:`${wP.textAreaInputHybrid} ${wP.textarea}`,placeholder:"Generate image",value:u,onChange:j,spellCheck:"false"}),e("span",{className:`ant-input-suffix ${wP.inputSuffix}`,children:g||_?e(re,{className:`${wP.inputIcon} input-icon`,spin:!0}):e(y,{className:`${wP.inputIcon} input-icon`,onClick:k})})]})})})}),(g||f.length>0)&&t(Q,{dotPosition:"top",arrows:!0,nextArrow:e(xP,{}),prevArrow:e(CP,{}),className:wP.carousel,infinite:!1,children:[g&&!f.length&&e("div",{className:wP.loading,children:t("div",{className:"spin",children:[e(re,{style:{fontSize:48},spin:!0}),e("p",{className:"status",children:S})]})}),f.length>0&&f.map((n,r)=>t("div",{className:wP.imageItem,children:[e(vP,{images:f,frameHeight:b}),e("div",{className:"buttons",children:f.length>0&&!g&&e(D,{onClick:()=>A(`data:image/jpeg;base64, ${n}`),icon:e(be,{}),children:v("Use this variant")})})]},r))]})]})},SP=e=>{(null==e?void 0:e.customTheme)&&((e={})=>{const t=document.querySelector("head");if(!t)return;const n=document.createElement("style");if(n.type="text/css",n.dataset.themeVariablesFm="true",n.setAttribute("data-file-manager","true"),Object.entries(e).length){let r="";Object.entries(e).forEach(([e,t])=>{"object"!=typeof t&&(r+=`\t--${e}: ${t};\n`)}),r=`.em-filemanager {\n${r}}`,n.appendChild(document.createTextNode(r));const i=t.querySelector('[data-theme-variables-fm="true"]');i?t.replaceChild(n,i):t.insertBefore(n,t.firstChild)}})(null==e?void 0:e.customTheme)},{Sider:kP,Content:AP}=K,EP=({itemIds:t,onUndo:n,onClose:r})=>{const{t:i}=Nn();return a(()=>{const e=setTimeout(()=>r(),5e3);return()=>clearTimeout(e)},[r]),e("div",{style:{position:"fixed",bottom:24,right:24,maxWidth:420,zIndex:1e3},children:e(ee,{message:i("moved_to_trash",{count:t.length}),type:"success",showIcon:!0,action:e(D,{size:"small",type:"text",onClick:()=>n(),children:i("undo")}),closable:!0,onClose:r})})},IP={keywords:""},TP=()=>{var s;const l=bi(),d=xi(),h=(()=>{var e,t;const{state:n,actions:r,options:i}=ui(),{selectedFolder:o,pathHistory:a,folders:s}=n,{t:l}=Nn(),{setSelectedFolder:u,setPathHistory:d}=r,h=c(()=>{var e;return`em_fm:lastFolder:${(null===(e=null==i?void 0:i.config)||void 0===e?void 0:e.projectId)||"default"}`},[null===(e=null==i?void 0:i.config)||void 0===e?void 0:e.projectId]),f=c((e,t=new Set)=>{if(t.has(e))return console.warn(`Обнаружен цикл в пути к папке с id=${e}`),[];const n=(Array.isArray(s)?s:[]).find(t=>t.id===e);if(!n)return[];const r=new Set(t);return r.add(e),n.parentId?n.parentId===n.id?(console.warn(`Обнаружена циклическая зависимость: папка ${n.id} является родителем самой себя`),[{id:n.id,name:n.name+" (ошибка)"}]):[...f(n.parentId,r),{id:n.id,name:n.name}]:[{id:n.id,name:n.name}]},[s]),p=c(e=>{var t;if("undefined"==typeof window)return;const n=!1!==(null===(t=null==i?void 0:i.config)||void 0===t?void 0:t.rememberLastFolder),r=h();try{if(!n)return void localStorage.removeItem(r);e?localStorage.setItem(r,e):localStorage.removeItem(r)}catch(e){console.warn("localStorage недоступен для сохранения последней папки")}},[h,null===(t=null==i?void 0:i.config)||void 0===t?void 0:t.rememberLastFolder]),g=c(e=>{if("folders"===e){const e=[{id:"folders",name:l("Folders")}];return null==d||d(e),void(i.onPathChange&&i.onPathChange([]))}if(!(Array.isArray(s)?s:[]).find(t=>t.id===e))return void console.warn("⚠️ Папка не найдена:",e);const t=f(e),n=[{id:"folders",name:l("Folders")},...t];null==d||d(n),i.onPathChange&&i.onPathChange(n.map(e=>e.name))},[s,f,d,i,l]),m=c(e=>{const t="folders"===e?null:e;t!==o&&(null==u||u(t),p(t),g(e))},[p,o,u,g]),v=c(e=>{if(-1===e)null==u||u(null),null==d||d([{id:"folders",name:l("Folders")}]),i.onPathChange&&i.onPathChange([]);else{const t=a.slice(0,e+1),n=t[t.length-1],r="folders"===n.id?void 0:n.id;null==u||u(r||null),null==d||d(t),i.onPathChange&&i.onPathChange(t.map(e=>e.name))}},[i,a,d,u,l]),y=c(e=>{if(!e.isFolder)return;null==u||u(e.id);const t={id:e.id,name:e.name};if(d){const e=[...a,t];d(e)}if(i.onPathChange){const t=[...a.map(e=>e.name),e.name];i.onPathChange(t)}},[i,a,d,u]);return{state:{selectedFolder:o,pathHistory:a},actions:{handleFolderSelect:m,handleBreadcrumbClick:v,handleItemClick:y},selectedFolder:o,pathHistory:a,handleFolderSelect:m,handleBreadcrumbClick:v,handleItemClick:y}})(),f=(()=>{const{state:e,actions:t}=ui(),{pagination:n}=e,{setPagination:r}=t,i=c((e,t)=>{const i=t||n.pageSize;null==r||r({current:e,pageSize:i,total:n.total})},[n.pageSize,n.total,r]);return{state:{pagination:n},actions:{handlePaginationChange:i}}})(),p=(()=>{const[e,t]=r.useState(()=>{const e=localStorage.getItem(Ci);return e?Math.max(290,parseInt(e,10)):298}),[n,i]=r.useState(!1),[o,a]=r.useState(!1),[s,l]=r.useState(0),c=r.useCallback(()=>{console.log("Double click: Resetting to default width"),t(298),localStorage.setItem(Ci,298..toString())},[]),u=r.useCallback(n=>{n.preventDefault(),n.stopPropagation(),i(!0),document.body.classList.add("resizing");const r=n.clientX,o=e;let s=o;const c=e=>{e.preventDefault();const n=Math.max(Math.min(o+e.clientX-r,600),290);s=n,t(n),l(e.clientX),a(!0)},u=()=>{i(!1),document.body.classList.remove("resizing"),a(!1),localStorage.setItem(Ci,s.toString()),document.removeEventListener("mousemove",c),document.removeEventListener("mouseup",u)};document.addEventListener("mousemove",c),document.addEventListener("mouseup",u)},[e]);return r.useEffect(()=>()=>{document.body.classList.remove("resizing")},[]),{sidebarWidth:e,isResizing:n,showResizeGuide:o,resizeGuidePosition:s,handleResizeStart:u,handleDoubleClick:c}})(),g=(()=>{const[e,t]=o([]),[n,r]=o(!1),[i,a]=o(!1),s=u(0),l=c(()=>(s.current+=1,`upload_${s.current}_${Date.now()}`),[]),d=c(e=>`${(e.size/1024).toFixed(2)} КБ`,[]),h=c(e=>{const n=e.map(e=>({id:l(),name:e.name,size:d(e),status:"uploading",progress:0}));return t(n),r(!0),a(!1),n.map(e=>e.id)},[l,d]),f=c((e,n)=>{t(t=>t.map(t=>t.id===e?Object.assign(Object.assign({},t),{progress:Math.min(100,Math.max(0,n))}):t))},[]),p=c(e=>{t(t=>t.map(t=>t.id===e?Object.assign(Object.assign({},t),{status:"success",progress:100}):t))},[]),g=c((e,n)=>{t(t=>t.map(t=>t.id===e?Object.assign(Object.assign({},t),{status:"error",error:n}):t))},[]),m=c(()=>{r(!1),a(!1),setTimeout(()=>{t([])},300)},[]),v=c(()=>{a(e=>!e)},[]),y=c(e=>{t(t=>{const n=t.filter(t=>t.id!==e);return 0===n.length&&setTimeout(()=>{r(!1),a(!1)},100),n})},[]),b=e.length,w=e.filter(e=>"success"===e.status||"error"===e.status).length;return{uploadFiles:e,isUploadVisible:n,isUploadMinimized:i,totalFiles:b,completedFiles:w,startUpload:h,updateProgress:f,markAsSuccess:p,markAsError:g,closeUpload:m,minimizeUpload:v,insertFile:y}})(),m=wi(),{t:v}=Nn(),y=i.useRef(null),{folders:b,loading:w}=l.state,{fetchFolders:x,fetchChildFolders:C,handleCreateFolder:_,handleModalOk:S,handleModalCancel:k,generateMenuItems:A}=l.actions,E=(e=>{var t;const{state:n,actions:r,options:i}=ui(),{t:o}=Nn(),a=gi(),{folders:s,folderToRename:l,renameFolderForm:u,isRenameFolderModalVisible:d}=n,{setFolderToRename:h,setIsRenameFolderModalVisible:f}=r,{apiEndpoints:p,dataProviders:g,config:m}=i,v=c(e=>{null==h||h(e),null==f||f(!0);const t=null==s?void 0:s.find(t=>t.id===e);t&&u&&u.setFieldsValue({newFolderName:t.name})},[h,f,s,u]),y=c(()=>{null==f||f(!1),null==h||h(null),null==u||u.resetFields()},[f,h,u]),b=c(async()=>{var t,n;if(l&&u)try{const i=await u.validateFields();if(!(null==i?void 0:i.newFolderName))return void a.warning({id:"FOLDER_OPERATION_VALIDATION_FAILED",message:o("Folder name cannot be empty"),placement:"bottomRight",data:{folderId:l,folderName:null==i?void 0:i.newFolderName,reason:"emptyName"}});if(!1===(null===(t=null==m?void 0:m.features)||void 0===t?void 0:t.enableRenameFolder))return void a.error({id:"FOLDER_RENAME_DISABLED_BY_CONFIG",message:o("Folder rename is disabled by config"),placement:"bottomRight",data:{itemId:null!=l?l:void 0,itemName:null==i?void 0:i.newFolderName}});if(!(null==g?void 0:g.renameFolder))throw new Error("renameFolder не реализован в dataProviders");const s=await g.renameFolder(l,i.newFolderName.trim());if(!(null==s?void 0:s.id))return void a.error({id:"FOLDER_RENAME_FAILED",message:o("Unexpected response when renaming folder"),placement:"bottomRight",data:{itemId:null!=l?l:void 0,itemName:i.newFolderName,reason:"invalidResponse"}});a.success({id:"FOLDER_RENAME_SUCCESS",message:o("Folder renamed"),placement:"bottomRight",data:{itemId:s.id,itemName:s.name,folderId:null!==(n=s.parentId)&&void 0!==n?n:null}}),y(),await e(),l!==s.id&&r.setSelectedFolder&&r.setSelectedFolder(s.id)}catch(e){console.error("Ошибка при переименовании папки:",e),a.error({id:"FOLDER_RENAME_FAILED",message:o("Failed to rename folder"),placement:"bottomRight",innerException:e,data:{itemId:null!=l?l:void 0,itemName:null==u?void 0:u.getFieldValue("newFolderName"),reason:e instanceof Error?e.message:String(e)}})}},[l,u,p,y,e,o,null===(t=null==m?void 0:m.features)||void 0===t?void 0:t.enableRenameFolder,a]);return{state:{isRenamingFolder:d||!1,folderToRename:l},actions:{showRenameFolderModal:v,handleRenameFolderCancel:y,handleRenameFolderOk:b}}})(x),{files:I,selectedFiles:T,loading:O,isRenamingFile:F,fileToRename:P}=d.state,{fetchFiles:M,handleDeleteFile:R,handleDeleteFolder:L,handleAddFile:j,handleAddFileByUrl:N,uploadFileWithProvider:z,toggleFileSelection:B,showRenameModal:V,handleRenameCancel:U,handleRenameOk:$,handleDroppedFiles:W,showMoveModal:H,handleMoveCancel:G,handleMoveOk:Y,handleCopyOk:q,handleCopyCancel:Z,showDeleteConfirm:J,handleDeleteConfirmCancel:Q,handleDeleteConfirmOk:ee}=d.actions,{selectedFolder:te,pathHistory:ne}=h.state,{handleFolderSelect:re,handleBreadcrumbClick:ie,handleItemClick:oe}=h.actions,{pagination:ae}=f.state,se=pi(M),{searchTerm:le,sortBy:ce,sortOrder:ue}=se.state,{handleSearch:de,handleSort:he,handlePaginationChange:fe}=se.actions,pe=(({files:e,selectedFiles:t,fetchFiles:n,selectedFolder:i})=>{const o=gi(),{options:a,actions:s,state:l}=r.useContext(ci),{setActiveLibraryItem:c}=s,{activeLibraryItem:u}=l,[d,h]=r.useState(!1),[f,p]=r.useState(null),g=r.useCallback(e=>{var t;if(e.type&&e.type.startsWith("image/"))return!0;if(e.extension){const t=e.extension.toLowerCase();return on.includes(t)}const n=null===(t=e.name.split(".").pop())||void 0===t?void 0:t.toLowerCase();return!!n&&on.includes(n)},[]),m=r.useCallback(async e=>{var t,n,r,i;const{dataProviders:o}=a;if(console.log("🔧 saveFileToServer: dataProviders доступны:",{hasUpdateFile:!!(null==o?void 0:o.updateFile),hasUploadFile:!!(null==o?void 0:o.uploadFile),hasThumbnail:!!e.thumbnail,fileId:e.id}),!1!==(null===(n=null===(t=a.config)||void 0===t?void 0:t.features)||void 0===n?void 0:n.enableUpdateFile)&&(null==o?void 0:o.updateFile)&&e.thumbnail)try{const t=mn(e.thumbnail,e.type),n=vn(t),r=e.name.substring(0,e.name.lastIndexOf("."))+"."+n,i=xn(e.thumbnail,t);return await o.updateFile(e.id,{name:r,type:t,data:i})}catch(e){return console.error("Ошибка при обновлении файла через updateFile:",e),null}else if((null==o?void 0:o.uploadFile)&&e.thumbnail)try{const t=mn(e.thumbnail,e.type),n=xn(e.thumbnail,t);await o.uploadFile(Object.assign(Object.assign({},e),{type:t,data:n,size:n.size||e.size||0}))}catch(e){return console.error("Ошибка при сохранении файла через uploadFile:",e),null}else if(!1!==(null===(i=null===(r=a.config)||void 0===r?void 0:r.features)||void 0===i?void 0:i.enableRenameFile)&&(null==o?void 0:o.renameFile))try{return await o.renameFile(e.id,e.name)}catch(e){return console.error("Ошибка при переименовании файла:",e),null}return console.warn("DataProvider для обновления файлов не настроен"),null},[a]),v=r.useCallback(n=>{let r;if(console.log("🎨 handleEdit ВЫЗВАНА!",{fileForEdit:n,selectedFilesSize:t.size}),n)console.log("fileForEdit",n),r=n;else{if(1!==t.size)return;const n=Array.from(t)[0];if(r=e.find(e=>e.id===n),!r||r.isFolder||!g(r))return}console.log("🎨 usePixieEditor: Открываем редактор для файла:",r),c&&c(Jt),console.log("🎨 usePixieEditor: Устанавливаем editingFile"),p(r),console.log("🎨 usePixieEditor: Устанавливаем isPixieEditorVisible = true"),h(!0),console.log("🎨 usePixieEditor: Редактор должен открыться")},[t,e,g,h,c]),y=r.useCallback(()=>{console.log("🎨 usePixieEditor: Закрываем редактор"),c&&u===Jt&&c(qt),h(!1),p(null),console.log("🎨 usePixieEditor: Редактор закрыт")},[u,c]),b=r.useCallback(async e=>{var t,r,s,l;console.log("Файл обновлен:",e);try{const s=await m(e);if(s)return o.success({id:"IMAGE_UPDATE_SUCCESS",message:"Успех",description:"Изображение успешно обновлено",placement:"bottomRight",data:{itemId:null!==(t=s.id)&&void 0!==t?t:void 0,itemName:s.name,folderId:null!==(r=s.folderId)&&void 0!==r?r:null,thumbnail:s.thumbnail}}),a.onEditorOk&&a.onEditorOk(s),await n({folderId:i||""}),y(),s}catch(t){console.error("Ошибка при сохранении файла:",t),o.error({id:"IMAGE_SAVE_FAILED",message:"Ошибка",description:`Не удалось сохранить изменения: ${t instanceof Error?t.message:"Неизвестная ошибка"}`,innerException:t,placement:"bottomRight",data:{itemId:null!==(s=e.id)&&void 0!==s?s:void 0,itemName:e.name,folderId:null!==(l=e.folderId)&&void 0!==l?l:null,thumbnail:e.thumbnail}})}},[m,a,n,i,o,y]);return{isPixieEditorVisible:d,editingFile:f,handleEdit:v,handlePixieEditorSave:b,handlePixieEditorClose:y}})({files:I||[],selectedFiles:T||new Set,fetchFiles:M,selectedFolder:te||null}),ge=i.useCallback(async()=>{var e;await ee(),await x(),await(null===(e=y.current)||void 0===e?void 0:e.refreshFileCounts())},[x,ee]),me=i.useCallback(async e=>{var t;await Y(e),await(null===(t=y.current)||void 0===t?void 0:t.refreshFileCounts())},[Y]),ve=i.useCallback(async e=>{var t;await q(e),await(null===(t=y.current)||void 0===t?void 0:t.refreshFileCounts())},[q]),ye=i.useCallback(async()=>{let e=[],t=new Map;await j({onStartBatch:n=>{e=g.startUpload(n),t=new Map(n.map((t,n)=>[t.name,e[n]])),console.warn("🚀 onStartBatch: файлы запущены",{count:n.length,currentIds:e})},onStart:n=>{0===e.length&&(e=g.startUpload([n]),t.set(n.name,e[0]))},onProgress:(e,n)=>{const r=t.get(e);r&&g.updateProgress(r,n)},onComplete:async e=>{var n;const r=t.get(e);r&&g.markAsSuccess(r),await(null===(n=y.current)||void 0===n?void 0:n.refreshFileCounts())},onError:(e,n)=>{const r=t.get(e);r&&g.markAsError(r,n)}})},[j,g]),be=i.useCallback(async()=>{var e;await N(),await(null===(e=y.current)||void 0===e?void 0:e.refreshFileCounts())},[N]),we=i.useCallback(async e=>{var t;await R(e),await(null===(t=y.current)||void 0===t?void 0:t.refreshFileCounts())},[R]),xe=i.useCallback(async e=>{var t;if(W){const n=g.startUpload(e);console.warn("🚀 Drag&Drop: файлы запущены",{fileCount:e.length,fileIds:n}),e.forEach(async(e,t)=>{const r=n[t];if(!r)return;let i=0;const o=setInterval(()=>{i=Math.min(i+10+Math.floor(Date.now()%10),85),g.updateProgress(r,i)},200);setTimeout(()=>{clearInterval(o)},2e3)}),await W(e),n.forEach(e=>{g.updateProgress(e,100),g.markAsSuccess(e)}),await(null===(t=y.current)||void 0===t?void 0:t.refreshFileCounts())}},[W,g]),Ce=i.useCallback(async e=>{var t;await L(e),await x(),await(null===(t=y.current)||void 0===t?void 0:t.refreshFileCounts())},[L,x]),_e=(({files:e,selectedFiles:t,toggleFileSelection:n,showRenameModal:i,showMoveModal:o,showCopyModal:a,handleDeleteFile:s,handleDeleteFolder:l,showDeleteConfirm:c,onEdit:u})=>{const d=r.useCallback(()=>{t&&t.size>0&&t.forEach(e=>{n(e)})},[t,n]),h=r.useCallback(e=>{if(t&&1===t.size||e){const n=e||Array.from(t)[0];i(n)}},[t,i]),f=r.useCallback(n=>{if(t&&t.size>0||(null==n?void 0:n.id)){if(c)return void c();(n?[n.id]:t).forEach(t=>{const n=e.find(e=>e.id===t);console.log("item",n),n?n.isFolder?l(t):s(t):console.warn(`Объект с ID ${t} не найден в списке файлов`)})}},[t,e,s,l,c]);return{handleClearSelection:d,handleRename:h,handleDeleteSelected:f,handleCopy:r.useCallback(()=>{a()},[a]),handleMove:r.useCallback(()=>{o()},[o]),handleEdit:r.useCallback(()=>{console.log("onEdit"),u()},[u])}})({files:I||[],selectedFiles:T||new Set,toggleFileSelection:B,showRenameModal:V,showMoveModal:H,showCopyModal:d.actions.showCopyModal||(()=>{}),handleDeleteFile:R,handleDeleteFolder:Ce,showDeleteConfirm:J,onEdit:pe.handleEdit}),Se=w||O,{options:ke}=i.useContext(ci),Ae=null==ke?void 0:ke.config;a(()=>{pn(),x()},[x]),i.useEffect(()=>{if(!re||0===b.length)return;const e=!!(null==Ae?void 0:Ae.rememberLastFolder),t=`em_fm:lastFolder:${(null==Ae?void 0:Ae.projectId)||"default"}`;if(e&&"undefined"!=typeof window)try{const e=localStorage.getItem(t);if(e&&b.some(t=>t.id===e))return void re(e)}catch(e){}te||re("folders")},[te,re,b,null==Ae?void 0:Ae.rememberLastFolder,null==Ae?void 0:Ae.projectId]);const{state:Ee,actions:Ie,options:Te}=i.useContext(ci),{form:Oe,urlForm:Fe,renameForm:Pe,moveForm:Me,renameFolderForm:Re,copyForm:Le,isModalVisible:je,isUrlModalVisible:De,isMoveModalVisible:Ne,isRenameFolderModalVisible:ze,isCopyModalVisible:Be,isDeleteConfirmVisible:Ve,folderToRename:Ue,activeLibraryItem:$e}=Ee,{setIsUrlModalVisible:We,setSortField:He,setActiveLibraryItem:Ge,setUndoDeletion:Ye}=Ie,{config:qe}=Te,Xe=gi(),{handleRenameFolderCancel:Ke,handleRenameFolderOk:Ze}=E.actions,Je=c(e=>{fe(e.current||ae.current,e.pageSize||ae.pageSize)},[fe,ae]),Qe=i.useCallback(e=>{const{sortBy:t,sortOrder:n}=(e=>{const[t,n]=e.split("-");return{sortBy:t,sortOrder:n}})(e);he(t,n)},[he]),[et,tt]=o(IP),[nt,rt]=o([]),it=u(null),[ot,at]=o(sn),[st,lt]=o([]),ct=u(null),[ut,dt]=o(""),[ht,ft]=o([]),pt=i.useRef(void 0),[gt,mt]=o(!1),[vt,yt]=o(!1),bt=i.useRef(null),wt=i.useRef(null),xt=c(async()=>{const e=null==qe?void 0:qe.fileForEdit;if(pt.current!==e){pt.current=e;try{if(!($e===Jt&&e&&!pe.editingFile))return;if("string"==typeof e){if(e.startsWith("data:"))return void(null==pe||pe.handleEdit({thumbnail:e}));const t=await m.handleAddFileByUrl(e,!0);if(!t)throw new Error("Не удалось загрузить файл");pt.current===e&&(null==pe||pe.handleEdit(t))}}finally{pt.current===e&&(pt.current=null)}}},[null==qe?void 0:qe.fileForEdit,$e,pe,m]);a(()=>{xt()},[xt]),a(()=>{var e,t,n;$e===qt?(console.warn("reset requests"),rt([]),tt(IP),lt([]),at(sn),ft([]),dt(""),yt(!1),mt(!1)):$e===Zt?null===(e=wt.current)||void 0===e||e.focus():$e===Xt?null===(t=it.current)||void 0===t||t.focus():$e===Kt&&(null===(n=ct.current)||void 0===n||n.focus())},[$e]);const Ct=i.useCallback(async()=>{var e;await Ze(),await(null===(e=y.current)||void 0===e?void 0:e.refreshFileCounts())},[Ze]),_t=T.size,St=i.useMemo(()=>{var e,t;if(1!==_t)return!1;const n=Array.from(T)[0],r=I.find(e=>e.id===n);if(!r||r.isFolder)return!1;let i=!1;if(r.type&&r.type.startsWith("image/"))i=!0;else if(r.extension){const e=r.extension.toLowerCase();i=on.includes(e)}else{const t=null===(e=r.name.split(".").pop())||void 0===e?void 0:e.toLowerCase();i=!!t&&on.includes(t)}return console.log("isImageSelected проверка:",{fileName:r.name,fileType:r.type,fileExtension:r.extension,nameExtension:null===(t=r.name.split(".").pop())||void 0===t?void 0:t.toLowerCase(),isImage:i,IMAGE_EXTENSIONS:on}),i},[_t,T,I]);return t(K,{className:"file-manager__layout",children:[p.showResizeGuide&&e("div",{className:"resize-guide",style:{left:`${p.resizeGuidePosition}px`}}),t(K,{className:"file-manager__content",children:[t(kP,{width:320,theme:"light",className:"file-manager-sider",children:[e(go,{ref:y,selectedFolder:te||"folders",generateMenuItems:A,onFolderSelect:e=>null==re?void 0:re(e),folders:b||[],fetchFolders:x,fetchChildFolders:C,handleAddFile:ye,setIsUrlModalVisible:e=>null==We?void 0:We(e),handleDeleteFolder:Ce,handleCreateFolder:_,activeLibraryItem:$e,setActiveLibraryItem:e=>null==Ge?void 0:Ge(e)}),e("div",{className:"sidebar-resizer "+(p.isResizing?"resizing":""),onMouseDown:p.handleResizeStart,onDoubleClick:p.handleDoubleClick,children:e("div",{className:"sidebar-resizer-indicator"})})]}),e(K,{className:"file-manager__main-content",children:t(AP,{className:"main-content",ref:bt,children:[e(YF,{activeLibraryItem:$e,selectedFolder:(null===(s=null==b?void 0:b.find(e=>(null==e?void 0:e.id)===te))||void 0===s?void 0:s.name)||v("Folders")}),e(X,{className:"zero-divider"}),$e===qt&&e(so,{searchTerm:le,sortField:Ee.sortField||"name",setSortField:e=>null==He?void 0:He(e),pathHistory:ne||[],handleBreadcrumbClick:e=>null==ie?void 0:ie(e),handleAddFile:ye,setIsUrlModalVisible:e=>null==We?void 0:We(e),files:I||[],handleSearch:de,handleSort:he,sortBy:ce,sortOrder:ue,handleSortOptionChange:Qe,pagination:ae,setPagination:Je,loading:Se,handleItemClick:e=>null==oe?void 0:oe(e),handleDeleteFile:we,selectedFiles:T||new Set,toggleFileSelection:e=>null==B?void 0:B(e),handleDroppedFiles:xe,fileUpload:g,onClearSelection:_e.handleClearSelection,onRename:_e.handleRename,onCopy:_e.handleCopy,onMove:_e.handleMove,onDelete:_e.handleDeleteSelected,onEdit:pe.handleEdit}),$e===Xt&&e(uP,{imageGifList:nt,setImageGifList:rt,currentReqGif:et,setCurrentReqGif:tt,inputRef:it,customRequest:N}),$e===Kt&&e(fP,{imageStockList:st,setImageStockList:lt,currentReq:ot,setCurrentReq:at,inputRef:ct,customRequest:N}),$e===Zt&&!!(null==qe?void 0:qe.sseQuery)&&e(_P,{imageAiList:ht,setImageAiList:ft,aiImageRequest:ut,setAiImageRequest:dt,inputAiRef:wt,customRequest:e=>z(e.file),isLoadingAi:gt,setIsLoadingAi:mt,isImageUploaded:vt,setIsImageUploaded:yt,aiTabRef:bt}),$e===Jt&&e(n,{}),e("div",{children:St&&t(n,{children:[e(X,{className:"zero-divider"}),e("div",{style:{display:"flex",justifyContent:"right",padding:"17px 24px",alignItems:"center"},children:e(D,{size:"large",type:"primary",style:{height:40},onClick:()=>{if(Te.onEditorOk){const e=Array.from(T)[0],t=I.find(t=>t.id===e);t&&Te.onEditorOk(t)}},children:v("Choose")})})]})})]})})]}),e(fo,{isModalVisible:je,handleModalOk:S,handleModalCancel:k,form:Oe,selectedFolder:te||null,folders:b||[],isUrlModalVisible:De,setIsUrlModalVisible:e=>null==We?void 0:We(e),handleAddFileByUrl:be,urlForm:Fe,isRenameModalVisible:F,handleRenameOk:()=>null==$?void 0:$(),handleRenameCancel:()=>null==U?void 0:U(),renameForm:Pe,fileToRename:P,files:I||[],isMoveModalVisible:Ne,handleMoveOk:me,handleMoveCancel:G,moveForm:Me,selectedFiles:T||new Set,isRenameFolderModalVisible:ze,handleRenameFolderOk:Ct,handleRenameFolderCancel:Ke,renameFolderForm:Re,folderToRename:Ue,isCopyModalVisible:Be,handleCopyOk:ve,handleCopyCancel:Z,copyForm:Le,isDeleteConfirmVisible:Ve,handleDeleteConfirmOk:ge,handleDeleteConfirmCancel:()=>null==Q?void 0:Q(),fetchChildFolders:C}),Ee.undoDeletion&&e(EP,{itemIds:Ee.undoDeletion.itemIds,sourceFolderId:Ee.undoDeletion.sourceFolderId||"folders",onClose:()=>null==Ye?void 0:Ye(null),onUndo:async()=>{var e,t,n,r,i,o,a,s,l,c,u,d,h;try{const o=null!==(t=null===(e=Ee.undoDeletion)||void 0===e?void 0:e.itemIds)&&void 0!==t?t:[],a=(null===(n=Ee.undoDeletion)||void 0===n?void 0:n.sourceFolderId)||"folders";if(null===(r=Te.dataProviders)||void 0===r?void 0:r.moveItems)await Te.dataProviders.moveItems("folders"===a?"":a,o);else if(null===(i=Te.dataProviders)||void 0===i?void 0:i.moveItem)for(const e of o){const t=e.startsWith("folder_");await Te.dataProviders.moveItem({itemId:e,targetFolderId:"folders"===a?"":a,isFolder:t})}Xe.success({id:"FILES_MOVE_SUCCESS",message:v("restored_items",{count:o.length}),placement:"bottomRight",data:{successCount:o.length,totalCount:o.length,itemIds:o}}),null==Ye||Ye(null),await x(),await M({folderId:te||"",page:ae.current,limit:ae.pageSize})}catch(e){Xe.error({id:"FILES_MOVE_ERROR",message:v("Error when moving a file"),placement:"bottomRight",data:{failCount:null!==(s=null===(a=null===(o=Ee.undoDeletion)||void 0===o?void 0:o.itemIds)||void 0===a?void 0:a.length)&&void 0!==s?s:0,totalCount:null!==(u=null===(c=null===(l=Ee.undoDeletion)||void 0===l?void 0:l.itemIds)||void 0===c?void 0:c.length)&&void 0!==u?u:0,itemIds:null!==(h=null===(d=Ee.undoDeletion)||void 0===d?void 0:d.itemIds)&&void 0!==h?h:[]},innerException:e})}}}),e(WF,{visible:pe.isPixieEditorVisible,onClose:pe.handlePixieEditorClose,file:pe.editingFile,onSave:pe.handlePixieEditorSave})]})},OP=f(({config:r={},onPathChange:o,onChangeSelection:s,onEditorOk:l,searchQuery:c="",sortBySize:d="name",apiEndpoints:h={},customIcons:f,dragDropIcon:p,dataProviders:g,handleNotify:m,handleError:v,handleSuccess:y})=>{const b=i.useMemo(()=>Object.assign({folderTreeLoading:"lazy",expandAllFoldersOnInit:!1,expandRootFolderOnInit:!1,iconStrokeWidth:1.4},r),[r]);i.useEffect(()=>{b.theme&&(e=>{if("system"===e){const t=matchMedia(nn).matches?en:Qt;e=e===tn?t:e}document.documentElement.setAttribute("data-theme",e)})(b.theme),SP(b)},[b]),a(()=>{b.locale&&b.locale!==Tr.language&&(console.warn("FileManagerApp: меняем локаль с",Tr.language,"на",b.locale),Tr.changeLanguage(b.locale)),b.customLocale&&b.locale&&Tr.addResourceBundle(b.locale,"translation",b.customLocale,!0,!0)},[b.locale,b.customLocale]);const w=u(null);return e(I,{className:"em-filemanager",children:t(n,{children:[e(E,{getPopupContainer:()=>w.current||document.body,children:e(di,{options:{apiEndpoints:h,searchQuery:c,sortBySize:d,onPathChange:o,onChangeSelection:s,onEditorOk:l,config:b,customIcons:f,dragDropIcon:p,dataProviders:g,handleNotify:m,handleError:v,handleSuccess:y},children:e(TP,{})})}),e("div",{ref:w,className:"file-manager-modal-root"})]})})});OP.displayName="FileManagerApp";const FP=t=>{var n,r,i;return e(zn,{i18n:Tr,children:e(un,{externalTheme:null!==(r=null===(n=t.config)||void 0===n?void 0:n.theme)&&void 0!==r?r:"light",customThemeToken:null===(i=t.config)||void 0===i?void 0:i.customTheme,children:e(te,{children:e(OP,Object.assign({},t))})})})},PP=new Map,MP=(t,n)=>{var r;let i;pn();let o={};const a=e=>{const t=!e||"fileManager"!==e.mode&&"imageCenter"!==e.mode&&"plugin"!==e.mode?void 0:e.mode;return"imageCenter"===t?hn("imageCenter",e):hn(t)};if(t instanceof HTMLElement){i=t;o={config:a(n),apiEndpoints:null==n?void 0:n.apiEndpoints}}else{i=t.element;const e=a(t.config),n=Object.assign(Object.assign({},null===(r=t.config)||void 0===r?void 0:r.apiEndpoints),t.apiEndpoints);o={config:e,currentPath:t.currentPath,onPathChange:t.onPathChange,onChangeSelection:t.onChangeSelection,searchQuery:t.searchQuery,sortBySize:t.sortBySize,apiEndpoints:n,dataProviders:t.dataProviders,customIcons:t.customIcons,dragDropIcon:t.dragDropIcon,handleNotify:t.handleNotify,handleError:t.handleError,handleSuccess:t.handleSuccess}}const s=S(i);s.render(e(FP,Object.assign({},o))),PP.set(i.id||`container_${Date.now()}`,s)},RP=e=>{const t=e.id||Object.keys(PP).find(e=>e.startsWith("container_"));if(t&&PP.has(t)){const e=PP.get(t);null==e||e.unmount(),PP.delete(t)}else{console.warn("Не удалось найти корень для размонтирования");try{S(e).unmount()}catch(e){console.error("Ошибка при размонтировании компонента:",e)}}},LP=new Map,jP=r=>{const{onClose:o,onSave:a,dataProviders:s,theme:l}=r,c=i.useMemo(()=>{if(r.file)return r.file;const e=r.name||"edited-image",t=r.extension||(r.type?r.type.split("/")[1]:"png"),n=r.type||`image/${t}`;return{thumbnail:r.imageDataUrl||"",name:e,id:void 0,type:n,extension:t}},[r.file,r.imageDataUrl,r.name,r.extension,r.type]),d=i.useCallback(async e=>{if(console.log("🔧 saveFileToServer: dataProviders доступны:",{hasUpdateFile:!!(null==s?void 0:s.updateFile),hasThumbnail:!!e.thumbnail,fileId:e.id}),(null==s?void 0:s.updateFile)&&e.thumbnail)try{const t=mn(e.thumbnail,e.type),n=vn(t),r=e.name.substring(0,e.name.lastIndexOf("."))+"."+n,i=xn(e.thumbnail,t);return await s.updateFile(e.id,{name:r,type:t,data:i})}catch(e){return console.error("Ошибка при обновлении файла через updateFile:",e),null}return console.warn("DataProvider для обновления файлов не настроен"),null},[s]),h=i.useCallback(async e=>{if((null==s?void 0:s.updateFile)&&e.id&&e.thumbnail)try{const t=await d(e);t&&(e=t)}catch(e){console.error("Standalone Pixie: saveFileToServer error",e)}return a&&await a(e),o&&o(),e},[s,a,o,d]),f=u(null);return e(I,{className:"em-filemanager",children:t(n,{children:[e(E,{getPopupContainer:()=>f.current||document.body,children:e(zn,{i18n:Tr,children:e(un,{externalTheme:null!=l?l:"light",children:e(te,{children:e(di,{options:{dataProviders:s,handleNotify:r.handleNotify,handleError:r.handleError,handleSuccess:r.handleSuccess,config:{theme:null!=l?l:"light",locale:r.locale,baseUrl:r.baseUrl,assetsUrl:r.assetsUrl,showNotifications:r.showNotifications}},children:e(WF,{visible:!0,onClose:o,file:c,onSave:h})})})})})}),e("div",{ref:f,className:"file-manager-modal-root"})]})})},DP=t=>{pn();const n=t.element,r=S(n);r.render(e(jP,Object.assign({},t))),LP.set(n.id||`pixie_container_${Date.now()}`,r)},NP=e=>{const t=Array.from(LP.keys()).find(e=>e.startsWith("pixie_container_")),n=e.id||t;if(n&&LP.has(n)){const e=LP.get(n);null==e||e.unmount(),LP.delete(n)}else{console.warn("Не удалось найти корень Pixie для размонтирования");try{S(e).unmount()}catch(e){console.error("Ошибка при размонтировании Pixie:",e)}}},zP=e=>{var t,n;const{mode:r,element:i,fileManager:o,pixieEditor:a,theme:s,dataProviders:l}=e;let c,u;const d={unmount:()=>{c&&RP(c),u&&NP(u)},unmountFileManager:void 0,unmountPixieEditor:void 0};switch(r){case"fileManager":c=i,MP(i,Object.assign(Object.assign({},null==o?void 0:o.config),{theme:s||(null===(t=null==o?void 0:o.config)||void 0===t?void 0:t.theme),apiEndpoints:null==o?void 0:o.apiEndpoints})),d.unmountFileManager=()=>RP(c);break;case"pixieEditor":u=i,DP(Object.assign({element:i,theme:s||(null==a?void 0:a.theme),dataProviders:l||(null==a?void 0:a.dataProviders)},a)),d.unmountPixieEditor=()=>NP(u);break;case"both":{const e=document.createElement("div");e.id="file-manager-container",e.style.cssText="height: 50%; border-bottom: 1px solid #d9d9d9;";const t=document.createElement("div");t.id="pixie-editor-container",t.style.cssText="height: 50%;",i.appendChild(e),i.appendChild(t),c=e,u=t,MP(c,Object.assign(Object.assign({},null==o?void 0:o.config),{theme:s||(null===(n=null==o?void 0:o.config)||void 0===n?void 0:n.theme),apiEndpoints:null==o?void 0:o.apiEndpoints})),DP(Object.assign({element:u,theme:s||(null==a?void 0:a.theme),dataProviders:l||(null==a?void 0:a.dataProviders)},a)),d.unmountFileManager=()=>RP(c),d.unmountPixieEditor=()=>NP(u);break}}return d};class BP extends Error{constructor(e,t,n,r){super(e),this.name="FileManagerApiError",this.code=t,this.httpStatus=n,this.details=r,Error.captureStackTrace&&Error.captureStackTrace(this,BP)}}var VP={init:MP,unmount:RP,initPixieEditor:DP,unmountPixieEditor:NP,initFileManager:zP};export{so as FileContent,BP as FileManagerApiError,OP as FileManagerApp,FP as FileManagerAppWithContext,fo as FileModals,go as FolderSidebar,jP as PixieOnlyApp,VP as default,MP as init,zP as initFileManager,DP as initPixieEditor,pn as installResizeObserverErrorHandler,gn as uninstallResizeObserverErrorHandler,RP as unmount,NP as unmountPixieEditor};
76
+ var qF=function(e,t){return qF=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},qF(e,t)};var XF=function(){return XF=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},XF.apply(this,arguments)};var KF="Pixel",ZF="Percent",JF={unit:ZF,value:.8};function QF(e){return"number"==typeof e?{unit:ZF,value:100*e}:"string"==typeof e?e.match(/^(\d*(\.\d+)?)px$/)?{unit:KF,value:parseFloat(e)}:e.match(/^(\d*(\.\d+)?)%$/)?{unit:ZF,value:parseFloat(e)}:(console.warn('scrollThreshold format is invalid. Valid formats: "120px", "50%"...'),JF):(console.warn("scrollThreshold should be string or number"),JF)}var eP=function(e){function t(t){var n=e.call(this,t)||this;return n.lastScrollTop=0,n.actionTriggered=!1,n.startY=0,n.currentY=0,n.dragging=!1,n.maxPullDownDistance=0,n.getScrollableTarget=function(){return n.props.scrollableTarget instanceof HTMLElement?n.props.scrollableTarget:"string"==typeof n.props.scrollableTarget?document.getElementById(n.props.scrollableTarget):(null===n.props.scrollableTarget&&console.warn("You are trying to pass scrollableTarget but it is null. This might\n happen because the element may not have been added to DOM yet.\n See https://github.com/ankeetmaini/react-infinite-scroll-component/issues/59 for more info.\n "),null)},n.onStart=function(e){n.lastScrollTop||(n.dragging=!0,e instanceof MouseEvent?n.startY=e.pageY:e instanceof TouchEvent&&(n.startY=e.touches[0].pageY),n.currentY=n.startY,n._infScroll&&(n._infScroll.style.willChange="transform",n._infScroll.style.transition="transform 0.2s cubic-bezier(0,0,0.31,1)"))},n.onMove=function(e){n.dragging&&(e instanceof MouseEvent?n.currentY=e.pageY:e instanceof TouchEvent&&(n.currentY=e.touches[0].pageY),n.currentY<n.startY||(n.currentY-n.startY>=Number(n.props.pullDownToRefreshThreshold)&&n.setState({pullToRefreshThresholdBreached:!0}),n.currentY-n.startY>1.5*n.maxPullDownDistance||n._infScroll&&(n._infScroll.style.overflow="visible",n._infScroll.style.transform="translate3d(0px, "+(n.currentY-n.startY)+"px, 0px)")))},n.onEnd=function(){n.startY=0,n.currentY=0,n.dragging=!1,n.state.pullToRefreshThresholdBreached&&(n.props.refreshFunction&&n.props.refreshFunction(),n.setState({pullToRefreshThresholdBreached:!1})),requestAnimationFrame(function(){n._infScroll&&(n._infScroll.style.overflow="auto",n._infScroll.style.transform="none",n._infScroll.style.willChange="unset")})},n.onScrollListener=function(e){"function"==typeof n.props.onScroll&&setTimeout(function(){return n.props.onScroll&&n.props.onScroll(e)},0);var t=n.props.height||n._scrollableNode?e.target:document.documentElement.scrollTop?document.documentElement:document.body;n.actionTriggered||((n.props.inverse?n.isElementAtTop(t,n.props.scrollThreshold):n.isElementAtBottom(t,n.props.scrollThreshold))&&n.props.hasMore&&(n.actionTriggered=!0,n.setState({showLoader:!0}),n.props.next&&n.props.next()),n.lastScrollTop=t.scrollTop)},n.state={showLoader:!1,pullToRefreshThresholdBreached:!1,prevDataLength:t.dataLength},n.throttledOnScrollListener=function(e,t,n,r){var i,o=!1,a=0;function s(){i&&clearTimeout(i)}function l(){var l=this,c=Date.now()-a,u=arguments;function d(){a=Date.now(),n.apply(l,u)}o||(r&&!i&&d(),s(),void 0===r&&c>e?d():!0!==t&&(i=setTimeout(r?function(){i=void 0}:d,void 0===r?e-c:e)))}return"boolean"!=typeof t&&(r=n,n=t,t=void 0),l.cancel=function(){s(),o=!0},l}(150,n.onScrollListener).bind(n),n.onStart=n.onStart.bind(n),n.onMove=n.onMove.bind(n),n.onEnd=n.onEnd.bind(n),n}return function(e,t){function n(){this.constructor=e}qF(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}(t,e),t.prototype.componentDidMount=function(){if(void 0===this.props.dataLength)throw new Error('mandatory prop "dataLength" is missing. The prop is needed when loading more content. Check README.md for usage');if(this._scrollableNode=this.getScrollableTarget(),this.el=this.props.height?this._infScroll:this._scrollableNode||window,this.el&&this.el.addEventListener("scroll",this.throttledOnScrollListener),"number"==typeof this.props.initialScrollY&&this.el&&this.el instanceof HTMLElement&&this.el.scrollHeight>this.props.initialScrollY&&this.el.scrollTo(0,this.props.initialScrollY),this.props.pullDownToRefresh&&this.el&&(this.el.addEventListener("touchstart",this.onStart),this.el.addEventListener("touchmove",this.onMove),this.el.addEventListener("touchend",this.onEnd),this.el.addEventListener("mousedown",this.onStart),this.el.addEventListener("mousemove",this.onMove),this.el.addEventListener("mouseup",this.onEnd),this.maxPullDownDistance=this._pullDown&&this._pullDown.firstChild&&this._pullDown.firstChild.getBoundingClientRect().height||0,this.forceUpdate(),"function"!=typeof this.props.refreshFunction))throw new Error('Mandatory prop "refreshFunction" missing.\n Pull Down To Refresh functionality will not work\n as expected. Check README.md for usage\'')},t.prototype.componentWillUnmount=function(){this.el&&(this.el.removeEventListener("scroll",this.throttledOnScrollListener),this.props.pullDownToRefresh&&(this.el.removeEventListener("touchstart",this.onStart),this.el.removeEventListener("touchmove",this.onMove),this.el.removeEventListener("touchend",this.onEnd),this.el.removeEventListener("mousedown",this.onStart),this.el.removeEventListener("mousemove",this.onMove),this.el.removeEventListener("mouseup",this.onEnd)))},t.prototype.componentDidUpdate=function(e){this.props.dataLength!==e.dataLength&&(this.actionTriggered=!1,this.setState({showLoader:!1}))},t.getDerivedStateFromProps=function(e,t){return e.dataLength!==t.prevDataLength?XF(XF({},t),{prevDataLength:e.dataLength}):null},t.prototype.isElementAtTop=function(e,t){void 0===t&&(t=.8);var n=e===document.body||e===document.documentElement?window.screen.availHeight:e.clientHeight,r=QF(t);return r.unit===KF?e.scrollTop<=r.value+n-e.scrollHeight+1:e.scrollTop<=r.value/100+n-e.scrollHeight+1},t.prototype.isElementAtBottom=function(e,t){void 0===t&&(t=.8);var n=e===document.body||e===document.documentElement?window.screen.availHeight:e.clientHeight,r=QF(t);return r.unit===KF?e.scrollTop+n>=e.scrollHeight-r.value:e.scrollTop+n>=r.value/100*e.scrollHeight},t.prototype.render=function(){var e=this,t=XF({height:this.props.height||"auto",overflow:"auto",WebkitOverflowScrolling:"touch"},this.props.style),n=this.props.hasChildren||!!(this.props.children&&this.props.children instanceof Array&&this.props.children.length),r=this.props.pullDownToRefresh&&this.props.height?{overflow:"auto"}:{};return i.createElement("div",{style:r,className:"infinite-scroll-component__outerdiv"},i.createElement("div",{className:"infinite-scroll-component "+(this.props.className||""),ref:function(t){return e._infScroll=t},style:t},this.props.pullDownToRefresh&&i.createElement("div",{style:{position:"relative"},ref:function(t){return e._pullDown=t}},i.createElement("div",{style:{position:"absolute",left:0,right:0,top:-1*this.maxPullDownDistance}},this.state.pullToRefreshThresholdBreached?this.props.releaseToRefreshContent:this.props.pullDownToRefreshContent)),this.props.children,!this.state.showLoader&&!n&&this.props.hasMore&&this.props.loader,this.state.showLoader&&this.props.hasMore&&this.props.loader,!this.props.hasMore&&this.props.endMessage))},t}(_);function tP(e,t){if(null==e)return{};var n,r,i=function(e,t){if(null==e)return{};var n,r,i={},o=Object.keys(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||(i[n]=e[n]);return i}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function nP(){return nP=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},nP.apply(this,arguments)}function rP(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function iP(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?rP(Object(n),!0).forEach(function(t){oP(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):rP(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function oP(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}const aP={breakpointCols:void 0,className:void 0,columnClassName:void 0,children:void 0,columnAttrs:void 0,column:void 0};class sP extends i.Component{constructor(e){let t;super(e),this.reCalculateColumnCount=this.reCalculateColumnCount.bind(this),this.reCalculateColumnCountDebounce=this.reCalculateColumnCountDebounce.bind(this),t=this.props.breakpointCols&&this.props.breakpointCols.default?this.props.breakpointCols.default:parseInt(this.props.breakpointCols)||2,this.state={columnCount:t}}componentDidMount(){this.reCalculateColumnCount(),window&&window.addEventListener("resize",this.reCalculateColumnCountDebounce)}componentDidUpdate(){this.reCalculateColumnCount()}componentWillUnmount(){window&&window.removeEventListener("resize",this.reCalculateColumnCountDebounce)}reCalculateColumnCountDebounce(){window&&window.requestAnimationFrame?(window.cancelAnimationFrame&&window.cancelAnimationFrame(this._lastRecalculateAnimationFrame),this._lastRecalculateAnimationFrame=window.requestAnimationFrame(()=>{this.reCalculateColumnCount()})):this.reCalculateColumnCount()}reCalculateColumnCount(){const e=window&&window.innerWidth||1/0;let t=this.props.breakpointCols;"object"!=typeof t&&(t={default:parseInt(t)||2});let n=1/0,r=t.default||2;for(let i in t){const o=parseInt(i);o>0&&e<=o&&o<n&&(n=o,r=t[i])}r=Math.max(1,parseInt(r)||1),this.state.columnCount!==r&&this.setState({columnCount:r})}itemsInColumns(){const e=this.state.columnCount,t=new Array(e),n=i.Children.toArray(this.props.children);for(let r=0;r<n.length;r++){const i=r%e;t[i]||(t[i]=[]),t[i].push(n[r])}return t}renderColumns(){const{column:e,columnAttrs:t={},columnClassName:n}=this.props,r=this.itemsInColumns(),o=100/r.length+"%";let a=n;a&&"string"!=typeof a&&(this.logDeprecated('The property "columnClassName" requires a string'),void 0===a&&(a="my-masonry-grid_column"));const s=iP(iP(iP({},e),t),{},{style:iP(iP({},t.style),{},{width:o}),className:a});return r.map((e,t)=>i.createElement("div",nP({},s,{key:t}),e))}logDeprecated(e){console.error("[Masonry]",e)}render(){const e=this.props,{children:t,breakpointCols:n,columnClassName:r,columnAttrs:o,column:a,className:s}=e,l=tP(e,["children","breakpointCols","columnClassName","columnAttrs","column","className"]);let c=s;return"string"!=typeof s&&(this.logDeprecated('The property "className" requires a string'),void 0===s&&(c="my-masonry-grid")),i.createElement("div",nP({},l,{className:c}),this.renderColumns())}}sP.defaultProps=aP;var lP={gifTab:"gifTab",scrollableDiv:"scrollableDiv",gifSearchInput:"gifSearchInput",search:"search",searchResults:"searchResults",myMasonryGrid:"myMasonryGrid",myMasonryGridColumn:"myMasonryGridColumn",listItem:"listItem",loaded:"loaded",loadedImage:"loadedImage",searchOutputWrapper:"searchOutputWrapper",divider:"divider",resultsContainer:"resultsContainer",playButton:"playButton",title:"title",subtitle:"subtitle",noFiles:"noFiles"};const cP={default:4,1600:3,1100:2,700:1},uP=({setImageGifList:r,imageGifList:i=[],currentReqGif:s,setCurrentReqGif:l,inputRef:c,customRequest:u})=>{const{t:d}=Nn(),{GifPlayIcon:h}=ro(),{options:f}=ui(),{config:p}=f,[g,m]=o(null),[v,y]=o(!1),[b,w]=o(25),[x,C]=o(null),_=async function({query:e,page:t}){const n=e.keywords.replace(/[^\w\sа-яёА-ЯЁ]|_/g,"").replace(/[\s_-]+/g," ");try{const e=`https://api.giphy.com/v1/gifs/search?api_key=${null==p?void 0:p.REACT_APP_GIPHY_KEY}&q=${n}&limit=25&offset=${t}&lang=en`,r=await fetch(e);return{data:await r.json()}}catch(e){console.warn(e)}},S=async()=>{var e,t;const n=await _({query:s,page:0});(null===(t=null===(e=null==n?void 0:n.data)||void 0===e?void 0:e.data)||void 0===t?void 0:t.length)&&n.data.data.length>0&&r(n.data.data)};return a(()=>()=>{x&&clearTimeout(x)},[x]),e("div",{className:lP.gifTab,children:e("div",{className:lP.searchOutputWrapper,children:t("div",{id:"scrollableDiv",className:lP.scrollableDiv,children:[t(T,{onValuesChange:e=>{if(void 0!==e.keywords){l(t=>Object.assign(Object.assign({},t),{keywords:e.keywords})),x&&clearTimeout(x);const t=setTimeout(S,800);C(t)}},className:i.length>0?lP.searchResults:lP.search,children:[e(T.Item,{name:"keywords",className:lP.gifSearchInput,children:e(O,{onKeyDown:e=>"Space"===e.code&&S(),onPressEnter:e=>S(),allowClear:!0,placeholder:d("Search GIFs"),ref:c,spellCheck:"false",prefix:e(ti,{size:16,strokeWidth:null==p?void 0:p.iconStrokeWidth,onClick:S})})}),i.length>0&&!v&&e("div",{className:`ant-divider ${lP.divider}`,role:"separator"})]}),!i.length&&!v&&e(n,{children:s.keywords?e("div",{className:lP.noFiles,children:d("There are no files for your request.")}):t("div",{className:lP.resultsContainer,children:[e("div",{className:lP.videoIcon,children:e(h,{className:lP.playButton})}),e("h1",{className:lP.title,children:d("Over 350,000 live images")}),e("p",{className:lP.subtitle,children:d("Enter a search query and we'll find the perfect image for you")})]})}),!i.length&&v&&e(NF,{}),i.length>0&&e(eP,{dataLength:i&&i.length,next:async()=>{v||(y(!0),_({query:s,page:b}).then(e=>{e&&e.data&&e.data.data&&r(t=>[...t,...e.data.data]),y(!1),w(e=>e+25)}).catch(()=>{y(!1)}))},hasMore:!!i,endMessage:t(X,{plain:!0,children:[d("That`s all we could find.")," 🤐"]}),scrollableTarget:"scrollableDiv",style:{overflow:"visible"},loader:e(NF,{}),children:e(sP,{breakpointCols:cP,className:lP.myMasonryGrid,columnClassName:lP.myMasonryGridColumn,children:i.map((n,r)=>t("div",{className:lP.listItem,onClick:()=>((e,t)=>{m(t),setTimeout(()=>{m(null)},2e3),u(e)})(n.images.downsized.url,n.id),children:[e("img",{className:g===n.id?lP.loadedImage:"",width:"100%",src:`${n.images.downsized.url}`,alt:n.title,onLoad:e=>{const t=e.target.parentNode;t&&t instanceof HTMLElement&&t.classList.add(lP.loaded)}}),e("a",{rel:"noreferrer",href:"https://giphy.com/",target:"_blank",onClick:e=>e.stopPropagation()}),g===n.id&&e(k,{className:lP.antSpin})]},n.id+r))})})]})})})};var dP={stockTab:"stockTab",stockSearchInput:"stockSearchInput",searchOutputWrapper:"searchOutputWrapper",divider:"divider",search:"search",searchResults:"searchResults",scrollableDiv:"scrollableDiv",myMasonryGrid:"myMasonryGrid",myMasonryGridColumn:"myMasonryGridColumn",listItem:"listItem",loaded:"loaded",loadedImage:"loadedImage",creatorInfo:"creatorInfo",stockColorFilter:"stockColorFilter",allColors:"allColors",blackColor:"blackColor",bwColor:"bwColor",whiteColor:"whiteColor",orangeColor:"orangeColor",redColor:"redColor",purpleColor:"purpleColor",magentaColor:"magentaColor",greenColor:"greenColor",tealColor:"tealColor",blueColor:"blueColor",resultsContainer:"resultsContainer",playButton:"playButton",title:"title",subtitle:"subtitle",noFiles:"noFiles"};const hP={default:4,1600:3,1100:2,700:1},fP=({imageStockList:r,setImageStockList:i,currentReq:s,setCurrentReq:l,inputRef:c,customRequest:d})=>{var h;const{t:f}=Nn(),{StockBigIcon:p,MixedViewIcon:g,LandscapeViewIcon:m,PortraitViewIcon:v,SquareViewIcon:y}=ro(),{options:b}=ui(),{config:w}=b,[x,C]=o(!1),[_,S]=o(2),[A,E]=o(null),[I,F]=o(null),[P,M]=o(!0),[R]=T.useForm(),j=u(s);a(()=>{j.current=s},[s]),a(()=>{0===r.length&&R.setFieldsValue({color:"",orientation:""})},[r,R]);const D=async function({query:e,page:t}){const n=e.keywords.replace(/[^\w\sа-яёА-ЯЁ]|_/g,"").replace(/[\s_-]+/g," ");try{let r=`https://api.unsplash.com/search/photos?client_id=${null==w?void 0:w.UNSPLASH_KEY}&lang=ru&per_page=18&query=${n}&page=${t}`;""!==e.color&&(r+=`&color=${e.color}`),""!==e.orientation&&(r+=`&orientation=${e.orientation}`);const i=await fetch(r);return{data:await i.json()}}catch(e){console.warn(e)}finally{C(!1)}},N=async()=>{var e,t,n;C(!0);const r=await D({query:j.current,page:1});(null===(e=null==r?void 0:r.data)||void 0===e?void 0:e.results)&&(i(r.data.results),M(18===r.data.results.length),(null===(n=null===(t=null==r?void 0:r.data)||void 0===t?void 0:t.results)||void 0===n?void 0:n.length)&&r.data.results.length>0&&S(2))};a(()=>()=>{I&&clearTimeout(I)},[I]);const z=(e,t,n)=>{!async function(e){try{const t=await fetch(`${e}&client_id=${null==w?void 0:w.UNSPLASH_KEY}`);return{data:await t.json()}}catch(e){console.warn(e)}}(t.download_location),E(n),setTimeout(()=>E(null),2e3),d(`${e.raw}&w=1200&q=96`)};return e("div",{className:dP.stockTab,children:e("div",{className:dP.searchOutputWrapper,children:t("div",{className:dP.scrollableDiv,id:"scrollableDiv",children:[t(T,{form:R,initialValues:sn,onValuesChange:(e,t)=>{if(l(Object.assign(Object.assign({},sn),t)),I&&clearTimeout(I),""!==t.keywords){const e=setTimeout(N,800);F(e)}else r.length||(l(Object.assign({},sn)),R.resetFields())},className:r.length>0?dP.searchResults:dP.search,children:[t($,{gutter:24,children:[e(W,{span:r.length>0?void 0:24,children:e(T.Item,{name:"keywords",className:dP.stockSearchInput,children:e(O,{allowClear:!0,placeholder:f("Search image"),ref:c,spellCheck:"false",prefix:e(ti,{size:16,strokeWidth:null==w?void 0:w.iconStrokeWidth})})})}),!!r.length&&t(n,{children:[e(W,{children:e(T.Item,{name:"orientation",children:t(Z.Group,{onChange:e=>l(t=>Object.assign(Object.assign({},t),{orientation:e.target.value})),children:[e(L,{title:f("All"),placement:"top",children:e(Z.Button,{value:"",children:e(g,{})})}),e(L,{title:f("Landscape"),placement:"top",children:e(Z.Button,{value:"landscape",children:e(m,{})})}),e(L,{title:f("Portrait"),placement:"top",children:e(Z.Button,{value:"portrait",children:e(v,{})})}),e(L,{title:f("Squarish"),placement:"top",children:e(Z.Button,{value:"squarish",children:e(y,{})})})]})})}),e(W,{children:e(T.Item,{name:"color",children:t(Z.Group,{className:dP.stockColorFilter,onChange:e=>l(t=>Object.assign(Object.assign({},t),{color:e.target.value})),children:[e(L,{title:f("All"),placement:"top",children:e(Z.Button,{className:dP.allColors,value:"",children:"All"})}),e(L,{title:f("Black"),placement:"top",children:e(Z.Button,{className:dP.blackColor,value:"black",children:"B"})}),e(L,{title:f("Black and White"),placement:"top",children:e(Z.Button,{className:dP.bwColor,value:"black_and_white",children:"B&W"})}),e(L,{title:f("White"),placement:"top",children:e(Z.Button,{className:dP.whiteColor,value:"white",children:"W"})}),e(L,{title:f("Orange"),placement:"top",children:e(Z.Button,{className:dP.orangeColor,value:"orange",children:"O"})}),e(L,{title:f("Red"),placement:"top",children:e(Z.Button,{className:dP.redColor,value:"red",children:"R"})}),e(L,{title:f("Purple"),placement:"top",children:e(Z.Button,{className:dP.purpleColor,value:"purple",children:"P"})}),e(L,{title:f("Magenta"),placement:"top",children:e(Z.Button,{className:dP.magentaColor,value:"magenta",children:"M"})}),e(L,{title:f("Green"),placement:"top",children:e(Z.Button,{className:dP.greenColor,value:"green",children:"G"})}),e(L,{title:f("Teal"),placement:"top",children:e(Z.Button,{className:dP.tealColor,value:"teal",children:"T"})}),e(L,{title:f("Blue"),placement:"top",children:e(Z.Button,{className:dP.blueColor,value:"blue",children:"B"})})]})})})]})]}),r.length>0&&!x&&e("div",{className:`ant-divider ${dP.divider}`,role:"separator"})]}),!r.length&&!x&&e(n,{children:s.keywords?e("div",{className:dP.noFiles,children:f("There are no files for your request.")}):t("div",{className:dP.resultsContainer,children:[e("div",{className:dP.videoIcon,children:e(p,{className:dP.playButton})}),e("h1",{className:dP.title,children:f("Millions of free stock images")}),e("p",{className:dP.subtitle,children:f("Enter a search query and we'll find the perfect image for you")})]})}),!r.length&&x&&e(NF,{}),r.length>0&&e(eP,{dataLength:r&&r.length,next:async()=>{if(x||""===j.current.keywords)return C(!1),void(""===j.current.keywords&&M(!1));C(!0),D({query:j.current,page:_}).then(e=>{e&&e.data&&e.data.results&&(i(t=>[...t,...e.data.results]),M(18===e.data.results.length)),S(e=>e+1)}).catch(e=>{console.warn("catch",e)}).finally(()=>{C(!1)})},hasMore:P&&""!==(null===(h=j.current)||void 0===h?void 0:h.keywords),endMessage:t(X,{plain:!0,children:[f("That`s all we could find.")," 🤐"]}),scrollableTarget:"scrollableDiv",style:{overflow:"visible"},loader:e(NF,{}),children:e(sP,{breakpointCols:hP,className:dP.myMasonryGrid,columnClassName:dP.myMasonryGridColumn,children:r.map((n,r)=>t("div",{className:dP.listItem,onClick:()=>z(n.urls,n.links,n.id),children:[e("img",{className:A===n.id?dP.loadedImage:"",width:"100%",src:`${n.urls.raw}&w=644&q=96`,alt:n.description,onLoad:e=>{const t=e.target.parentNode;t&&t instanceof HTMLElement&&t.classList.add(dP.loaded)}}),t("p",{className:dP.creatorInfo,onClick:e=>e.stopPropagation(),children:[f("Photo by")," ",e("a",{target:"_blank",href:`${n.user.links.html}?utm_source=${null==w?void 0:w.APP_NAME_UNSPLASH}&utm_medium=referral`,rel:"noreferrer",children:n.user.name})," ",f("on")," ",e("a",{target:"_blank",href:`https://unsplash.com/?utm_source=${null==w?void 0:w.APP_NAME_UNSPLASH}&utm_medium=referral`,rel:"noreferrer",children:"Unsplash"})]}),A===n.id&&e(k,{className:dP.antSpin})]},n.id+r))})})]})})})},pP=()=>{const{options:e}=ui(),t=e.config;return c((e,n)=>{!1!==(null==t?void 0:t.pushToGTM)&&((e,t)=>{const n=()=>{try{const t=Object.assign(Object.assign({},e),{appLabel:"blocks_app"});window.dataLayer&&"function"==typeof window.dataLayer.push?window.dataLayer.push(t):console.log("Attempting to add to the dataLayer:",e)}catch(e){console.error("Ошибка при вызове GTM:",e)}};t?setTimeout(n,t):n()})(e,n)},[null==t?void 0:t.pushToGTM])};var gP="slideshowContainer",mP="slideshowImage";const vP=({images:t,transitionDuration:n=1e3,frameHeight:r})=>{const[i,s]=o([]),l=()=>{s(e=>e.map((t,n)=>n===e.length-1?Object.assign(Object.assign({},t),{opacity:1}):t))};return a(()=>{if(t.length>0){const e=t[t.length-1];s(t=>[...t,{src:e,opacity:0}]),setTimeout(l,1e3)}else s([])},[t]),e("div",{className:gP,style:{height:600,minHeight:130},children:i.map((t,r)=>e("img",{src:`data:image/jpeg;base64, ${t.src}`,alt:`Slide ${r+1}`,className:mP,style:{opacity:t.opacity,transition:`opacity ${n}ms linear`,display:"block"}},r))})};"function"==typeof SuppressedError&&SuppressedError;const yP=t=>{var{className:n,style:r,color:i,text:o,bordered:a}=t,s=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]])}return n}(t,["className","style","color","text","bordered"]);const l=o||"";return e(J,Object.assign({style:r,color:i,bordered:a,className:n},s,{children:l}))},bP=({text:n,counter:r,limits:i,wrapperStyles:o})=>{const{t:a}=Nn(),{options:s}=ui(),l=s.config,{token:c}=A.useToken(),u=+i>0,d=!u||r<+i,h=(null==l?void 0:l.billingPageUrl)||"/billing",f=r+" "+a("of")+" "+(u?i:"∞")+" "+(n||a("tests",{count:i}))+" "+a("was used",{count:r});return t("div",{className:"limits-couter-wrapper",style:o,children:[e(yP,{bordered:!1,text:f,className:"limit-counter",style:{color:d?c.colorText:"white"},color:d?c.colorFillSecondary:"rgb(255, 77, 79)"}),u&&e("div",{style:{fontSize:14,textDecoration:"underline",cursor:"pointer"},onClick:()=>window.location.assign(h),children:a("Need more?")})]})};var wP={imageAi:"imageAi",imageItem:"imageItem",textAreaInputHybrid:"textAreaInputHybrid",loading:"loading",carousel:"carousel",arrow:"arrow",arrowNext:"arrowNext",arrowPrev:"arrowPrev",arrowBtn:"arrowBtn",arrowBtnNext:"arrowBtnNext",arrowBtnPrev:"arrowBtnPrev",row:"row",inputAffixWrapper:"inputAffixWrapper",textarea:"textarea",inputIcon:"inputIcon"};const xP=f(({className:t,onClick:n})=>e("div",{className:`${wP.arrow} ${wP.arrowNext} ${t||""}`,onClick:n,children:e(D,{className:`${wP.arrowBtn} ${wP.arrowBtnNext}`,size:"large",icon:e(ve,{})})}));xP.displayName="SampleNextArrow";const CP=f(({className:t,onClick:n})=>e("div",{className:`${wP.arrow} ${wP.arrowPrev} ${t||""}`,onClick:n,children:e(D,{className:`${wP.arrowBtn} ${wP.arrowBtnPrev}`,size:"large",icon:e(ye,{})})}));CP.displayName="SamplePrevArrow";const _P=({customRequest:n,aiTabRef:r,inputAiRef:i,isImageUploaded:s,setIsImageUploaded:l,aiImageRequest:u,setAiImageRequest:h,imageAiList:f,setImageAiList:p,isLoadingAi:g,setIsLoadingAi:m})=>{const{t:v}=Nn(),{AiIcon_2:y}=ro(),[b,w]=o("auto"),{aiImageCounter:x,currentAiImgLimits:C,loadingDuringGeneration:_,requestStatus:S,handleGenerate:k,convertBase64ToFile:A,isShiftPressed:E,setIsShiftPressed:I,limitsInPlugin:F}=function({setFrameHeight:e,customRequest:t,aiTabRef:n,isImageUploaded:r,setIsImageUploaded:i,aiImageRequest:s,imageAiList:l,setImageAiList:u,isLoadingAi:h,setIsLoadingAi:f}){const{t:p}=Nn(),{options:g}=ui(),m=g.config,v=gi(),y=pP(),{messages:b}=g.config,[w,x]=o([]),[C,_]=o(0),[S,k]=o(null),[A,E]=o(!1),[I,T]=o(p("Evaluating the task")),[O,F]=o(!1);a(()=>{x(b)},[b]),a(()=>{l.length||S||x([])},[l,S]);const P=d(()=>m&&"function"==typeof(null==m?void 0:m.sendAIImageRequest)?null==m?void 0:m.sendAIImageRequest:()=>Promise.resolve({}),[m]),M=c(e=>{if("error"!==e.status&&"Canceled"!==e.status){if(e.images){if(T(String(e.status)),100===e.progress){f(!1),u(e.images);const t=S,n=Array.isArray(e.images)?e.images:[];n.length>0&&v.success({id:"AI_IMAGE_GENERERATION_SUCCESS",message:p("Images generated successfully"),placement:"bottomRight",data:{request:s,taskId:t,images:n}}),k(null),F(!1)}}else if(u([String(e.data)]),100===e.progress){f(!1);const t=S,n=e.data?[String(e.data)]:[];n.length>0&&v.success({id:"AI_IMAGE_GENERERATION_SUCCESS",message:p("Images generated successfully"),placement:"bottomRight",data:{request:s,taskId:t,images:n}}),k(null),F(!1)}}else f(!1),F(!1),v.error({id:"AI_RESPONSE_INVALID",message:p("Something went wrong, please try again"),placement:"bottomRight",description:String(S)||void 0,data:{requestId:S,request:s,response:e},innerException:e})},[s,u,T,p,f,S,v,F]);a(()=>{w.length>1&&M(w[w.length-1])},[M,w]);const R=d(()=>{if(m&&"function"==typeof(null==m?void 0:m.sseQuery)){const e=null==m?void 0:m.sseQuery;return t=>e(t)}return e=>{}},[m]),L=d(()=>m&&"object"==typeof(null==m?void 0:m.handleLimitUsageEmitter)?null==m?void 0:m.handleLimitUsageEmitter:{fire:()=>{}},[m]),j=null==m?void 0:m.elementId,{projectId:D}=m,{limits:N}=(null==m?void 0:m.limits)?m:{limits:{ai_img_limit:0}},{ai_img_limit:z}=N,B=z>0&&C>=z,V=!(!(null==m?void 0:m.limits)||!m.counters)&&rn,U=c(()=>{L.fire({name:"AiImgCount",count:C+1})},[L,C]),$=d(()=>!B&&!V,[B,V,C,z]),W=c(async()=>{T(p("Evaluating the task")),""===s||h||(f(!0),F(!0),u([]),y({event:"submit_form",action:"ai_image_generation",entity_id:j,project_id:D}),P({body:{project_id:D,request:"create-image",connection:"midjourney",message:s}}).then(e=>{var t,n,r,i,o;const{data:a,error:l}=e||{};if(l)throw l;const c=a;if(401===(null==c?void 0:c.status)||401===(null===(t=null==c?void 0:c.data)||void 0===t?void 0:t.status))throw new Error("ERROR");const u=(null==c?void 0:c.task)||(null===(n=null==c?void 0:c.data)||void 0===n?void 0:n.task),d=null!==(i=null!==(r=null==u?void 0:u.id)&&void 0!==r?r:S)&&void 0!==i?i:void 0;200===(null==c?void 0:c.status)||200===(null===(o=null==c?void 0:c.data)||void 0===o?void 0:o.status)?((null==u?void 0:u.id)&&(T(u.message),k(u.id)),(null==c?void 0:c.message)&&v.success({id:"AI_IMAGE_GENERATION_STARTED",message:c.message,placement:"bottomRight",description:s,data:{request:s,taskId:d,response:null==c?void 0:c.data}}),R({task_id:null==u?void 0:u.id,entity_id:j})):(f(!1),F(!1),v.error({id:"AI_IMAGE_GENERATION_FAILED",message:(null==c?void 0:c.message)||p("Something went wrong, please try again"),placement:"bottomRight",description:s,data:{request:s,taskId:d,response:c},innerException:c}))}).catch(e=>{f(!1),F(!1);const t=e;return((null==t?void 0:t.error)||(null==t?void 0:t.data))&&(null==v||v.error({id:"AI_IMAGE_GENERATION_FAILED",message:p("Something went wrong, please try again"),placement:"bottomRight",description:s,innerException:e,data:{request:s,taskId:S,response:null==t?void 0:t.data,error:null==t?void 0:t.error}})),t}))},[s,h,f,F,u,y,j,D,P,v,R,p,S]),H=c(()=>{$&&W()},[$,V,_,U,W,v,p]);a(()=>{},[m,V]);const G=c(e=>{if(!r){i(!0);const n=e.match(/^data:image\/([A-Za-z-+/]+);base64,(.+)$/);if(!n)return;const r=n[1],o=n[2],a=atob(o),s=new Array(a.length);for(let e=0;e<a.length;e++)s[e]=a.charCodeAt(e);const l=new Uint8Array(s),c=new Blob([l],{type:`image/${r}`}),u=new File([c],"image.jpeg",{type:c.type,lastModified:Date.now()});t({file:u})}},[r,i,t]);return a(()=>{(h||l.length>0)&&setTimeout(()=>{let t=350;n.current&&(t=n.current.offsetHeight-120),e(t)},0)},[n,l.length,h,e]),{aiImageCounter:C,setAiImageCounter:_,currentAiImgLimits:z,isFieldsDisabled:B,canGenerateImage:$,aiImageRequest:s,imageAiList:l,setImageAiList:u,isLoadingAi:h,setIsLoadingAi:f,loadingDuringGeneration:O,setLoadingDuringGeneration:F,requestStatus:I,setRequestStatus:T,handleGenerate:H,handleLimitAiImgCount:U,convertBase64ToFile:G,isShiftPressed:A,setIsShiftPressed:E,currentReqId:S,setCurrentReqId:k,limitsInPlugin:V}}({setFrameHeight:w,customRequest:n,aiTabRef:r,isImageUploaded:s,setIsImageUploaded:l,aiImageRequest:u,imageAiList:f,setImageAiList:p,isLoadingAi:g,setIsLoadingAi:m}),[P,M]=o(!1),R=c(()=>M(!0),[]),L=c(()=>M(!1),[]),j=c(e=>h(e.target.value),[h]),N=c(e=>{"Shift"===e.key?I(!0):"Enter"!==e.key||E||(e.preventDefault(),k())},[E,k,I]),z=c(e=>{"Shift"===e.key&&I(!1)},[I]);return t("div",{className:wP.imageAi,children:[F&&e(bP,{text:"images",counter:x,limits:C,wrapperStyles:{marginTop:-25}}),e($,{gutter:24,className:wP.row,children:e(W,{span:24,children:e(T.Item,{children:t("span",{className:`ant-input-affix-wrapper ant-input-affix-wrapper-lg ${wP.inputAffixWrapper}${P?" ant-input-affix-wrapper-focused":""}`,children:[e(O.TextArea,{ref:i,onKeyDown:N,onKeyUp:z,onFocus:R,onBlur:L,autoSize:!0,allowClear:!0,className:`${wP.textAreaInputHybrid} ${wP.textarea}`,placeholder:"Generate image",value:u,onChange:j,spellCheck:"false"}),e("span",{className:`ant-input-suffix ${wP.inputSuffix}`,children:g||_?e(re,{className:`${wP.inputIcon} input-icon`,spin:!0}):e(y,{className:`${wP.inputIcon} input-icon`,onClick:k})})]})})})}),(g||f.length>0)&&t(Q,{dotPosition:"top",arrows:!0,nextArrow:e(xP,{}),prevArrow:e(CP,{}),className:wP.carousel,infinite:!1,children:[g&&!f.length&&e("div",{className:wP.loading,children:t("div",{className:"spin",children:[e(re,{style:{fontSize:48},spin:!0}),e("p",{className:"status",children:S})]})}),f.length>0&&f.map((n,r)=>t("div",{className:wP.imageItem,children:[e(vP,{images:f,frameHeight:b}),e("div",{className:"buttons",children:f.length>0&&!g&&e(D,{onClick:()=>A(`data:image/jpeg;base64, ${n}`),icon:e(be,{}),children:v("Use this variant")})})]},r))]})]})},SP=e=>{(null==e?void 0:e.customTheme)&&((e={})=>{const t=document.querySelector("head");if(!t)return;const n=document.createElement("style");if(n.type="text/css",n.dataset.themeVariablesFm="true",n.setAttribute("data-file-manager","true"),Object.entries(e).length){let r="";Object.entries(e).forEach(([e,t])=>{"object"!=typeof t&&(r+=`\t--${e}: ${t};\n`)}),r=`.em-filemanager {\n${r}}`,n.appendChild(document.createTextNode(r));const i=t.querySelector('[data-theme-variables-fm="true"]');i?t.replaceChild(n,i):t.insertBefore(n,t.firstChild)}})(null==e?void 0:e.customTheme)},{Sider:kP,Content:AP}=K,EP=({itemIds:t,onUndo:n,onClose:r})=>{const{t:i}=Nn();return a(()=>{const e=setTimeout(()=>r(),5e3);return()=>clearTimeout(e)},[r]),e("div",{style:{position:"fixed",bottom:24,right:24,maxWidth:420,zIndex:1e3},children:e(ee,{message:i("moved_to_trash",{count:t.length}),type:"success",showIcon:!0,action:e(D,{size:"small",type:"text",onClick:()=>n(),children:i("undo")}),closable:!0,onClose:r})})},IP={keywords:""},TP=()=>{var s;const l=bi(),d=xi(),h=(()=>{var e,t;const{state:n,actions:r,options:i}=ui(),{selectedFolder:o,pathHistory:a,folders:s}=n,{t:l}=Nn(),{setSelectedFolder:u,setPathHistory:d}=r,h=c(()=>{var e;return`em_fm:lastFolder:${(null===(e=null==i?void 0:i.config)||void 0===e?void 0:e.projectId)||"default"}`},[null===(e=null==i?void 0:i.config)||void 0===e?void 0:e.projectId]),f=c((e,t=new Set)=>{if(t.has(e))return console.warn(`Обнаружен цикл в пути к папке с id=${e}`),[];const n=(Array.isArray(s)?s:[]).find(t=>t.id===e);if(!n)return[];const r=new Set(t);return r.add(e),n.parentId?n.parentId===n.id?(console.warn(`Обнаружена циклическая зависимость: папка ${n.id} является родителем самой себя`),[{id:n.id,name:n.name+" (ошибка)"}]):[...f(n.parentId,r),{id:n.id,name:n.name}]:[{id:n.id,name:n.name}]},[s]),p=c(e=>{var t;if("undefined"==typeof window)return;const n=!1!==(null===(t=null==i?void 0:i.config)||void 0===t?void 0:t.rememberLastFolder),r=h();try{if(!n)return void localStorage.removeItem(r);e?localStorage.setItem(r,e):localStorage.removeItem(r)}catch(e){console.warn("localStorage недоступен для сохранения последней папки")}},[h,null===(t=null==i?void 0:i.config)||void 0===t?void 0:t.rememberLastFolder]),g=c(e=>{if("folders"===e){const e=[{id:"folders",name:l("Folders")}];return null==d||d(e),void(i.onPathChange&&i.onPathChange([]))}if(!(Array.isArray(s)?s:[]).find(t=>t.id===e))return void console.warn("⚠️ Папка не найдена:",e);const t=f(e),n=[{id:"folders",name:l("Folders")},...t];null==d||d(n),i.onPathChange&&i.onPathChange(n.map(e=>e.name))},[s,f,d,i,l]),m=c(e=>{const t="folders"===e?null:e;t!==o&&(null==u||u(t),p(t),g(e))},[p,o,u,g]),v=c(e=>{if(-1===e)null==u||u(null),null==d||d([{id:"folders",name:l("Folders")}]),i.onPathChange&&i.onPathChange([]);else{const t=a.slice(0,e+1),n=t[t.length-1],r="folders"===n.id?void 0:n.id;null==u||u(r||null),null==d||d(t),i.onPathChange&&i.onPathChange(t.map(e=>e.name))}},[i,a,d,u,l]),y=c(e=>{if(!e.isFolder)return;null==u||u(e.id);const t={id:e.id,name:e.name};if(d){const e=[...a,t];d(e)}if(i.onPathChange){const t=[...a.map(e=>e.name),e.name];i.onPathChange(t)}},[i,a,d,u]);return{state:{selectedFolder:o,pathHistory:a},actions:{handleFolderSelect:m,handleBreadcrumbClick:v,handleItemClick:y},selectedFolder:o,pathHistory:a,handleFolderSelect:m,handleBreadcrumbClick:v,handleItemClick:y}})(),f=(()=>{const{state:e,actions:t}=ui(),{pagination:n}=e,{setPagination:r}=t,i=c((e,t)=>{const i=t||n.pageSize;null==r||r({current:e,pageSize:i,total:n.total})},[n.pageSize,n.total,r]);return{state:{pagination:n},actions:{handlePaginationChange:i}}})(),p=(()=>{const[e,t]=r.useState(()=>{const e=localStorage.getItem(Ci);return e?Math.max(290,parseInt(e,10)):298}),[n,i]=r.useState(!1),[o,a]=r.useState(!1),[s,l]=r.useState(0),c=r.useCallback(()=>{console.log("Double click: Resetting to default width"),t(298),localStorage.setItem(Ci,298..toString())},[]),u=r.useCallback(n=>{n.preventDefault(),n.stopPropagation(),i(!0),document.body.classList.add("resizing");const r=n.clientX,o=e;let s=o;const c=e=>{e.preventDefault();const n=Math.max(Math.min(o+e.clientX-r,600),290);s=n,t(n),l(e.clientX),a(!0)},u=()=>{i(!1),document.body.classList.remove("resizing"),a(!1),localStorage.setItem(Ci,s.toString()),document.removeEventListener("mousemove",c),document.removeEventListener("mouseup",u)};document.addEventListener("mousemove",c),document.addEventListener("mouseup",u)},[e]);return r.useEffect(()=>()=>{document.body.classList.remove("resizing")},[]),{sidebarWidth:e,isResizing:n,showResizeGuide:o,resizeGuidePosition:s,handleResizeStart:u,handleDoubleClick:c}})(),g=(()=>{const[e,t]=o([]),[n,r]=o(!1),[i,a]=o(!1),s=u(0),l=c(()=>(s.current+=1,`upload_${s.current}_${Date.now()}`),[]),d=c(e=>`${(e.size/1024).toFixed(2)} КБ`,[]),h=c(e=>{const n=e.map(e=>({id:l(),name:e.name,size:d(e),status:"uploading",progress:0}));return t(n),r(!0),a(!1),n.map(e=>e.id)},[l,d]),f=c((e,n)=>{t(t=>t.map(t=>t.id===e?Object.assign(Object.assign({},t),{progress:Math.min(100,Math.max(0,n))}):t))},[]),p=c(e=>{t(t=>t.map(t=>t.id===e?Object.assign(Object.assign({},t),{status:"success",progress:100}):t))},[]),g=c((e,n)=>{t(t=>t.map(t=>t.id===e?Object.assign(Object.assign({},t),{status:"error",error:n}):t))},[]),m=c(()=>{r(!1),a(!1),setTimeout(()=>{t([])},300)},[]),v=c(()=>{a(e=>!e)},[]),y=c(e=>{t(t=>{const n=t.filter(t=>t.id!==e);return 0===n.length&&setTimeout(()=>{r(!1),a(!1)},100),n})},[]),b=e.length,w=e.filter(e=>"success"===e.status||"error"===e.status).length;return{uploadFiles:e,isUploadVisible:n,isUploadMinimized:i,totalFiles:b,completedFiles:w,startUpload:h,updateProgress:f,markAsSuccess:p,markAsError:g,closeUpload:m,minimizeUpload:v,insertFile:y}})(),m=wi(),{t:v}=Nn(),y=i.useRef(null),{folders:b,loading:w}=l.state,{fetchFolders:x,fetchChildFolders:C,handleCreateFolder:_,handleModalOk:S,handleModalCancel:k,generateMenuItems:A}=l.actions,E=(e=>{var t;const{state:n,actions:r,options:i}=ui(),{t:o}=Nn(),a=gi(),{folders:s,folderToRename:l,renameFolderForm:u,isRenameFolderModalVisible:d}=n,{setFolderToRename:h,setIsRenameFolderModalVisible:f}=r,{apiEndpoints:p,dataProviders:g,config:m}=i,v=c(e=>{null==h||h(e),null==f||f(!0);const t=null==s?void 0:s.find(t=>t.id===e);t&&u&&u.setFieldsValue({newFolderName:t.name})},[h,f,s,u]),y=c(()=>{null==f||f(!1),null==h||h(null),null==u||u.resetFields()},[f,h,u]),b=c(async()=>{var t,n;if(l&&u)try{const i=await u.validateFields();if(!(null==i?void 0:i.newFolderName))return void a.warning({id:"FOLDER_OPERATION_VALIDATION_FAILED",message:o("Folder name cannot be empty"),placement:"bottomRight",data:{folderId:l,folderName:null==i?void 0:i.newFolderName,reason:"emptyName"}});if(!1===(null===(t=null==m?void 0:m.features)||void 0===t?void 0:t.enableRenameFolder))return void a.error({id:"FOLDER_RENAME_DISABLED_BY_CONFIG",message:o("Folder rename is disabled by config"),placement:"bottomRight",data:{itemId:null!=l?l:void 0,itemName:null==i?void 0:i.newFolderName}});if(!(null==g?void 0:g.renameFolder))throw new Error("renameFolder не реализован в dataProviders");const s=await g.renameFolder(l,i.newFolderName.trim());if(!(null==s?void 0:s.id))return void a.error({id:"FOLDER_RENAME_FAILED",message:o("Unexpected response when renaming folder"),placement:"bottomRight",data:{itemId:null!=l?l:void 0,itemName:i.newFolderName,reason:"invalidResponse"}});a.success({id:"FOLDER_RENAME_SUCCESS",message:o("Folder renamed"),placement:"bottomRight",data:{itemId:s.id,itemName:s.name,folderId:null!==(n=s.parentId)&&void 0!==n?n:null}}),y(),await e(),l!==s.id&&r.setSelectedFolder&&r.setSelectedFolder(s.id)}catch(e){console.error("Ошибка при переименовании папки:",e),a.error({id:"FOLDER_RENAME_FAILED",message:o("Failed to rename folder"),placement:"bottomRight",innerException:e,data:{itemId:null!=l?l:void 0,itemName:null==u?void 0:u.getFieldValue("newFolderName"),reason:e instanceof Error?e.message:String(e)}})}},[l,u,p,y,e,o,null===(t=null==m?void 0:m.features)||void 0===t?void 0:t.enableRenameFolder,a]);return{state:{isRenamingFolder:d||!1,folderToRename:l},actions:{showRenameFolderModal:v,handleRenameFolderCancel:y,handleRenameFolderOk:b}}})(x),{files:I,selectedFiles:T,loading:O,isRenamingFile:F,fileToRename:P}=d.state,{fetchFiles:M,handleDeleteFile:R,handleDeleteFolder:L,handleAddFile:j,handleAddFileByUrl:N,uploadFileWithProvider:z,toggleFileSelection:B,showRenameModal:V,handleRenameCancel:U,handleRenameOk:$,handleDroppedFiles:W,showMoveModal:H,handleMoveCancel:G,handleMoveOk:Y,handleCopyOk:q,handleCopyCancel:Z,showDeleteConfirm:J,handleDeleteConfirmCancel:Q,handleDeleteConfirmOk:ee}=d.actions,{selectedFolder:te,pathHistory:ne}=h.state,{handleFolderSelect:re,handleBreadcrumbClick:ie,handleItemClick:oe}=h.actions,{pagination:ae}=f.state,se=pi(M),{searchTerm:le,sortBy:ce,sortOrder:ue}=se.state,{handleSearch:de,handleSort:he,handlePaginationChange:fe}=se.actions,pe=(({files:e,selectedFiles:t,fetchFiles:n,selectedFolder:i})=>{const o=gi(),{options:a,actions:s,state:l}=r.useContext(ci),{setActiveLibraryItem:c}=s,{activeLibraryItem:u}=l,[d,h]=r.useState(!1),[f,p]=r.useState(null),g=r.useCallback(e=>{var t;if(e.type&&e.type.startsWith("image/"))return!0;if(e.extension){const t=e.extension.toLowerCase();return on.includes(t)}const n=null===(t=e.name.split(".").pop())||void 0===t?void 0:t.toLowerCase();return!!n&&on.includes(n)},[]),m=r.useCallback(async e=>{var t,n,r,i;const{dataProviders:o}=a;if(console.log("🔧 saveFileToServer: dataProviders доступны:",{hasUpdateFile:!!(null==o?void 0:o.updateFile),hasUploadFile:!!(null==o?void 0:o.uploadFile),hasThumbnail:!!e.thumbnail,fileId:e.id}),!1!==(null===(n=null===(t=a.config)||void 0===t?void 0:t.features)||void 0===n?void 0:n.enableUpdateFile)&&(null==o?void 0:o.updateFile)&&e.thumbnail)try{const t=mn(e.thumbnail,e.type),n=vn(t),r=e.name.substring(0,e.name.lastIndexOf("."))+"."+n,i=xn(e.thumbnail,t);return await o.updateFile(e.id,{name:r,type:t,data:i})}catch(e){return console.error("Ошибка при обновлении файла через updateFile:",e),null}else if((null==o?void 0:o.uploadFile)&&e.thumbnail)try{const t=mn(e.thumbnail,e.type),n=xn(e.thumbnail,t);await o.uploadFile(Object.assign(Object.assign({},e),{type:t,data:n,size:n.size||e.size||0}))}catch(e){return console.error("Ошибка при сохранении файла через uploadFile:",e),null}else if(!1!==(null===(i=null===(r=a.config)||void 0===r?void 0:r.features)||void 0===i?void 0:i.enableRenameFile)&&(null==o?void 0:o.renameFile))try{return await o.renameFile(e.id,e.name)}catch(e){return console.error("Ошибка при переименовании файла:",e),null}return console.warn("DataProvider для обновления файлов не настроен"),null},[a]),v=r.useCallback(n=>{let r;if(console.log("🎨 handleEdit ВЫЗВАНА!",{fileForEdit:n,selectedFilesSize:t.size}),n)console.log("fileForEdit",n),r=n;else{if(1!==t.size)return;const n=Array.from(t)[0];if(r=e.find(e=>e.id===n),!r||r.isFolder||!g(r))return}console.log("🎨 usePixieEditor: Открываем редактор для файла:",r),c&&c(Jt),console.log("🎨 usePixieEditor: Устанавливаем editingFile"),p(r),console.log("🎨 usePixieEditor: Устанавливаем isPixieEditorVisible = true"),h(!0),console.log("🎨 usePixieEditor: Редактор должен открыться")},[t,e,g,h,c]),y=r.useCallback(()=>{console.log("🎨 usePixieEditor: Закрываем редактор"),c&&u===Jt&&c(qt),h(!1),p(null),console.log("🎨 usePixieEditor: Редактор закрыт")},[u,c]),b=r.useCallback(async e=>{var t,r,s,l;console.log("Файл обновлен:",e);try{const s=await m(e);if(s)return o.success({id:"IMAGE_UPDATE_SUCCESS",message:"Успех",description:"Изображение успешно обновлено",placement:"bottomRight",data:{itemId:null!==(t=s.id)&&void 0!==t?t:void 0,itemName:s.name,folderId:null!==(r=s.folderId)&&void 0!==r?r:null,thumbnail:s.thumbnail}}),a.onEditorOk&&a.onEditorOk(s),await n({folderId:i||""}),y(),s}catch(t){console.error("Ошибка при сохранении файла:",t),o.error({id:"IMAGE_SAVE_FAILED",message:"Ошибка",description:`Не удалось сохранить изменения: ${t instanceof Error?t.message:"Неизвестная ошибка"}`,innerException:t,placement:"bottomRight",data:{itemId:null!==(s=e.id)&&void 0!==s?s:void 0,itemName:e.name,folderId:null!==(l=e.folderId)&&void 0!==l?l:null,thumbnail:e.thumbnail}})}},[m,a,n,i,o,y]);return{isPixieEditorVisible:d,editingFile:f,handleEdit:v,handlePixieEditorSave:b,handlePixieEditorClose:y}})({files:I||[],selectedFiles:T||new Set,fetchFiles:M,selectedFolder:te||null}),ge=i.useCallback(async()=>{var e;await ee(),await x(),await(null===(e=y.current)||void 0===e?void 0:e.refreshFileCounts())},[x,ee]),me=i.useCallback(async e=>{var t;await Y(e),await(null===(t=y.current)||void 0===t?void 0:t.refreshFileCounts())},[Y]),ve=i.useCallback(async e=>{var t;await q(e),await(null===(t=y.current)||void 0===t?void 0:t.refreshFileCounts())},[q]),ye=i.useCallback(async()=>{let e=[],t=new Map;await j({onStartBatch:n=>{e=g.startUpload(n),t=new Map(n.map((t,n)=>[t.name,e[n]])),console.warn("🚀 onStartBatch: файлы запущены",{count:n.length,currentIds:e})},onStart:n=>{0===e.length&&(e=g.startUpload([n]),t.set(n.name,e[0]))},onProgress:(e,n)=>{const r=t.get(e);r&&g.updateProgress(r,n)},onComplete:async e=>{var n;const r=t.get(e);r&&g.markAsSuccess(r),await(null===(n=y.current)||void 0===n?void 0:n.refreshFileCounts())},onError:(e,n)=>{const r=t.get(e);r&&g.markAsError(r,n)}})},[j,g]),be=i.useCallback(async(e,t)=>{var n;await N(e,t),await(null===(n=y.current)||void 0===n?void 0:n.refreshFileCounts())},[N]),we=i.useCallback(async({file:e})=>{var t;const n=await z(e);return await(null===(t=y.current)||void 0===t?void 0:t.refreshFileCounts()),n},[z]),xe=i.useCallback(async e=>{var t;await R(e),await(null===(t=y.current)||void 0===t?void 0:t.refreshFileCounts())},[R]),Ce=i.useCallback(async e=>{var t;if(W){const n=g.startUpload(e);console.warn("🚀 Drag&Drop: файлы запущены",{fileCount:e.length,fileIds:n}),e.forEach(async(e,t)=>{const r=n[t];if(!r)return;let i=0;const o=setInterval(()=>{i=Math.min(i+10+Math.floor(Date.now()%10),85),g.updateProgress(r,i)},200);setTimeout(()=>{clearInterval(o)},2e3)}),await W(e),n.forEach(e=>{g.updateProgress(e,100),g.markAsSuccess(e)}),await(null===(t=y.current)||void 0===t?void 0:t.refreshFileCounts())}},[W,g]),_e=i.useCallback(async e=>{var t;await L(e),await x(),await(null===(t=y.current)||void 0===t?void 0:t.refreshFileCounts())},[L,x]),Se=(({files:e,selectedFiles:t,toggleFileSelection:n,showRenameModal:i,showMoveModal:o,showCopyModal:a,handleDeleteFile:s,handleDeleteFolder:l,showDeleteConfirm:c,onEdit:u})=>{const d=r.useCallback(()=>{t&&t.size>0&&t.forEach(e=>{n(e)})},[t,n]),h=r.useCallback(e=>{if(t&&1===t.size||e){const n=e||Array.from(t)[0];i(n)}},[t,i]),f=r.useCallback(n=>{if(t&&t.size>0||(null==n?void 0:n.id)){if(c)return void c();(n?[n.id]:t).forEach(t=>{const n=e.find(e=>e.id===t);console.log("item",n),n?n.isFolder?l(t):s(t):console.warn(`Объект с ID ${t} не найден в списке файлов`)})}},[t,e,s,l,c]);return{handleClearSelection:d,handleRename:h,handleDeleteSelected:f,handleCopy:r.useCallback(()=>{a()},[a]),handleMove:r.useCallback(()=>{o()},[o]),handleEdit:r.useCallback(()=>{console.log("onEdit"),u()},[u])}})({files:I||[],selectedFiles:T||new Set,toggleFileSelection:B,showRenameModal:V,showMoveModal:H,showCopyModal:d.actions.showCopyModal||(()=>{}),handleDeleteFile:R,handleDeleteFolder:_e,showDeleteConfirm:J,onEdit:pe.handleEdit}),ke=w||O,{options:Ae}=i.useContext(ci),Ee=null==Ae?void 0:Ae.config;a(()=>{pn(),x()},[x]),i.useEffect(()=>{if(!re||0===b.length)return;const e=!!(null==Ee?void 0:Ee.rememberLastFolder),t=`em_fm:lastFolder:${(null==Ee?void 0:Ee.projectId)||"default"}`;if(e&&"undefined"!=typeof window)try{const e=localStorage.getItem(t);if(e&&b.some(t=>t.id===e))return void re(e)}catch(e){}te||re("folders")},[te,re,b,null==Ee?void 0:Ee.rememberLastFolder,null==Ee?void 0:Ee.projectId]);const{state:Ie,actions:Te,options:Oe}=i.useContext(ci),{form:Fe,urlForm:Pe,renameForm:Me,moveForm:Re,renameFolderForm:Le,copyForm:je,isModalVisible:De,isUrlModalVisible:Ne,isMoveModalVisible:ze,isRenameFolderModalVisible:Be,isCopyModalVisible:Ve,isDeleteConfirmVisible:Ue,folderToRename:$e,activeLibraryItem:We}=Ie,{setIsUrlModalVisible:He,setSortField:Ge,setActiveLibraryItem:Ye,setUndoDeletion:qe}=Te,{config:Xe}=Oe,Ke=gi(),{handleRenameFolderCancel:Ze,handleRenameFolderOk:Je}=E.actions,Qe=c(e=>{fe(e.current||ae.current,e.pageSize||ae.pageSize)},[fe,ae]),et=i.useCallback(e=>{const{sortBy:t,sortOrder:n}=(e=>{const[t,n]=e.split("-");return{sortBy:t,sortOrder:n}})(e);he(t,n)},[he]),[tt,nt]=o(IP),[rt,it]=o([]),ot=u(null),[at,st]=o(sn),[lt,ct]=o([]),ut=u(null),[dt,ht]=o(""),[ft,pt]=o([]),gt=i.useRef(void 0),[mt,vt]=o(!1),[yt,bt]=o(!1),wt=i.useRef(null),xt=i.useRef(null),Ct=c(async()=>{const e=null==Xe?void 0:Xe.fileForEdit;if(gt.current!==e){gt.current=e;try{if(!(We===Jt&&e&&!pe.editingFile))return;if("string"==typeof e){if(e.startsWith("data:"))return void(null==pe||pe.handleEdit({thumbnail:e}));const t=await m.handleAddFileByUrl(e,!0);if(!t)throw new Error("Не удалось загрузить файл");gt.current===e&&(null==pe||pe.handleEdit(t))}}finally{gt.current===e&&(gt.current=null)}}},[null==Xe?void 0:Xe.fileForEdit,We,pe,m]);a(()=>{Ct()},[Ct]),a(()=>{var e,t,n;We===qt?(console.warn("reset requests"),it([]),nt(IP),ct([]),st(sn),pt([]),ht(""),bt(!1),vt(!1)):We===Zt?null===(e=xt.current)||void 0===e||e.focus():We===Xt?null===(t=ot.current)||void 0===t||t.focus():We===Kt&&(null===(n=ut.current)||void 0===n||n.focus())},[We]);const _t=i.useCallback(async()=>{var e;await Je(),await(null===(e=y.current)||void 0===e?void 0:e.refreshFileCounts())},[Je]),St=T.size,kt=i.useMemo(()=>{var e,t;if(1!==St)return!1;const n=Array.from(T)[0],r=I.find(e=>e.id===n);if(!r||r.isFolder)return!1;let i=!1;if(r.type&&r.type.startsWith("image/"))i=!0;else if(r.extension){const e=r.extension.toLowerCase();i=on.includes(e)}else{const t=null===(e=r.name.split(".").pop())||void 0===e?void 0:e.toLowerCase();i=!!t&&on.includes(t)}return console.log("isImageSelected проверка:",{fileName:r.name,fileType:r.type,fileExtension:r.extension,nameExtension:null===(t=r.name.split(".").pop())||void 0===t?void 0:t.toLowerCase(),isImage:i,IMAGE_EXTENSIONS:on}),i},[St,T,I]);return t(K,{className:"file-manager__layout",children:[p.showResizeGuide&&e("div",{className:"resize-guide",style:{left:`${p.resizeGuidePosition}px`}}),t(K,{className:"file-manager__content",children:[t(kP,{width:320,theme:"light",className:"file-manager-sider",children:[e(go,{ref:y,selectedFolder:te||"folders",generateMenuItems:A,onFolderSelect:e=>null==re?void 0:re(e),folders:b||[],fetchFolders:x,fetchChildFolders:C,handleAddFile:ye,setIsUrlModalVisible:e=>null==He?void 0:He(e),handleDeleteFolder:_e,handleCreateFolder:_,activeLibraryItem:We,setActiveLibraryItem:e=>null==Ye?void 0:Ye(e)}),e("div",{className:"sidebar-resizer "+(p.isResizing?"resizing":""),onMouseDown:p.handleResizeStart,onDoubleClick:p.handleDoubleClick,children:e("div",{className:"sidebar-resizer-indicator"})})]}),e(K,{className:"file-manager__main-content",children:t(AP,{className:"main-content",ref:wt,children:[e(YF,{activeLibraryItem:We,selectedFolder:(null===(s=null==b?void 0:b.find(e=>(null==e?void 0:e.id)===te))||void 0===s?void 0:s.name)||v("Folders")}),e(X,{className:"zero-divider"}),We===qt&&e(so,{searchTerm:le,sortField:Ie.sortField||"name",setSortField:e=>null==Ge?void 0:Ge(e),pathHistory:ne||[],handleBreadcrumbClick:e=>null==ie?void 0:ie(e),handleAddFile:ye,setIsUrlModalVisible:e=>null==He?void 0:He(e),files:I||[],handleSearch:de,handleSort:he,sortBy:ce,sortOrder:ue,handleSortOptionChange:et,pagination:ae,setPagination:Qe,loading:ke,handleItemClick:e=>null==oe?void 0:oe(e),handleDeleteFile:xe,selectedFiles:T||new Set,toggleFileSelection:e=>null==B?void 0:B(e),handleDroppedFiles:Ce,fileUpload:g,onClearSelection:Se.handleClearSelection,onRename:Se.handleRename,onCopy:Se.handleCopy,onMove:Se.handleMove,onDelete:Se.handleDeleteSelected,onEdit:pe.handleEdit}),We===Xt&&e(uP,{imageGifList:rt,setImageGifList:it,currentReqGif:tt,setCurrentReqGif:nt,inputRef:ot,customRequest:be}),We===Kt&&e(fP,{imageStockList:lt,setImageStockList:ct,currentReq:at,setCurrentReq:st,inputRef:ut,customRequest:be}),We===Zt&&!!(null==Xe?void 0:Xe.sseQuery)&&e(_P,{imageAiList:ft,setImageAiList:pt,aiImageRequest:dt,setAiImageRequest:ht,inputAiRef:xt,customRequest:we,isLoadingAi:mt,setIsLoadingAi:vt,isImageUploaded:yt,setIsImageUploaded:bt,aiTabRef:wt}),We===Jt&&e(n,{}),e("div",{children:kt&&t(n,{children:[e(X,{className:"zero-divider"}),e("div",{style:{display:"flex",justifyContent:"right",padding:"17px 24px",alignItems:"center"},children:e(D,{size:"large",type:"primary",style:{height:40},onClick:()=>{if(Oe.onEditorOk){const e=Array.from(T)[0],t=I.find(t=>t.id===e);t&&Oe.onEditorOk(t)}},children:v("Choose")})})]})})]})})]}),e(fo,{isModalVisible:De,handleModalOk:S,handleModalCancel:k,form:Fe,selectedFolder:te||null,folders:b||[],isUrlModalVisible:Ne,setIsUrlModalVisible:e=>null==He?void 0:He(e),handleAddFileByUrl:be,urlForm:Pe,isRenameModalVisible:F,handleRenameOk:()=>null==$?void 0:$(),handleRenameCancel:()=>null==U?void 0:U(),renameForm:Me,fileToRename:P,files:I||[],isMoveModalVisible:ze,handleMoveOk:me,handleMoveCancel:G,moveForm:Re,selectedFiles:T||new Set,isRenameFolderModalVisible:Be,handleRenameFolderOk:_t,handleRenameFolderCancel:Ze,renameFolderForm:Le,folderToRename:$e,isCopyModalVisible:Ve,handleCopyOk:ve,handleCopyCancel:Z,copyForm:je,isDeleteConfirmVisible:Ue,handleDeleteConfirmOk:ge,handleDeleteConfirmCancel:()=>null==Q?void 0:Q(),fetchChildFolders:C}),Ie.undoDeletion&&e(EP,{itemIds:Ie.undoDeletion.itemIds,sourceFolderId:Ie.undoDeletion.sourceFolderId||"folders",onClose:()=>null==qe?void 0:qe(null),onUndo:async()=>{var e,t,n,r,i,o,a,s,l,c,u,d,h;try{const o=null!==(t=null===(e=Ie.undoDeletion)||void 0===e?void 0:e.itemIds)&&void 0!==t?t:[],a=(null===(n=Ie.undoDeletion)||void 0===n?void 0:n.sourceFolderId)||"folders";if(null===(r=Oe.dataProviders)||void 0===r?void 0:r.moveItems)await Oe.dataProviders.moveItems("folders"===a?"":a,o);else if(null===(i=Oe.dataProviders)||void 0===i?void 0:i.moveItem)for(const e of o){const t=e.startsWith("folder_");await Oe.dataProviders.moveItem({itemId:e,targetFolderId:"folders"===a?"":a,isFolder:t})}Ke.success({id:"FILES_MOVE_SUCCESS",message:v("restored_items",{count:o.length}),placement:"bottomRight",data:{successCount:o.length,totalCount:o.length,itemIds:o}}),null==qe||qe(null),await x(),await M({folderId:te||"",page:ae.current,limit:ae.pageSize})}catch(e){Ke.error({id:"FILES_MOVE_ERROR",message:v("Error when moving a file"),placement:"bottomRight",data:{failCount:null!==(s=null===(a=null===(o=Ie.undoDeletion)||void 0===o?void 0:o.itemIds)||void 0===a?void 0:a.length)&&void 0!==s?s:0,totalCount:null!==(u=null===(c=null===(l=Ie.undoDeletion)||void 0===l?void 0:l.itemIds)||void 0===c?void 0:c.length)&&void 0!==u?u:0,itemIds:null!==(h=null===(d=Ie.undoDeletion)||void 0===d?void 0:d.itemIds)&&void 0!==h?h:[]},innerException:e})}}}),e(WF,{visible:pe.isPixieEditorVisible,onClose:pe.handlePixieEditorClose,file:pe.editingFile,onSave:pe.handlePixieEditorSave})]})},OP=f(({config:r={},onPathChange:o,onChangeSelection:s,onEditorOk:l,searchQuery:c="",sortBySize:d="name",apiEndpoints:h={},customIcons:f,dragDropIcon:p,dataProviders:g,handleNotify:m,handleError:v,handleSuccess:y})=>{const b=i.useMemo(()=>Object.assign({folderTreeLoading:"lazy",expandAllFoldersOnInit:!1,expandRootFolderOnInit:!1,iconStrokeWidth:1.4},r),[r]);i.useEffect(()=>{b.theme&&(e=>{if("system"===e){const t=matchMedia(nn).matches?en:Qt;e=e===tn?t:e}document.documentElement.setAttribute("data-theme",e)})(b.theme),SP(b)},[b]),a(()=>{b.locale&&b.locale!==Tr.language&&(console.warn("FileManagerApp: меняем локаль с",Tr.language,"на",b.locale),Tr.changeLanguage(b.locale)),b.customLocale&&b.locale&&Tr.addResourceBundle(b.locale,"translation",b.customLocale,!0,!0)},[b.locale,b.customLocale]);const w=u(null);return e(I,{className:"em-filemanager",children:t(n,{children:[e(E,{getPopupContainer:()=>w.current||document.body,children:e(di,{options:{apiEndpoints:h,searchQuery:c,sortBySize:d,onPathChange:o,onChangeSelection:s,onEditorOk:l,config:b,customIcons:f,dragDropIcon:p,dataProviders:g,handleNotify:m,handleError:v,handleSuccess:y},children:e(TP,{})})}),e("div",{ref:w,className:"file-manager-modal-root"})]})})});OP.displayName="FileManagerApp";const FP=t=>{var n,r,i;return e(zn,{i18n:Tr,children:e(un,{externalTheme:null!==(r=null===(n=t.config)||void 0===n?void 0:n.theme)&&void 0!==r?r:"light",customThemeToken:null===(i=t.config)||void 0===i?void 0:i.customTheme,children:e(te,{children:e(OP,Object.assign({},t))})})})},PP=new Map,MP=(t,n)=>{var r;let i;pn();let o={};const a=e=>{const t=!e||"fileManager"!==e.mode&&"imageCenter"!==e.mode&&"plugin"!==e.mode?void 0:e.mode;return"imageCenter"===t?hn("imageCenter",e):hn(t)};if(t instanceof HTMLElement){i=t;o={config:a(n),apiEndpoints:null==n?void 0:n.apiEndpoints}}else{i=t.element;const e=a(t.config),n=Object.assign(Object.assign({},null===(r=t.config)||void 0===r?void 0:r.apiEndpoints),t.apiEndpoints);o={config:e,currentPath:t.currentPath,onPathChange:t.onPathChange,onChangeSelection:t.onChangeSelection,searchQuery:t.searchQuery,sortBySize:t.sortBySize,apiEndpoints:n,dataProviders:t.dataProviders,customIcons:t.customIcons,dragDropIcon:t.dragDropIcon,handleNotify:t.handleNotify,handleError:t.handleError,handleSuccess:t.handleSuccess}}const s=S(i);s.render(e(FP,Object.assign({},o))),PP.set(i.id||`container_${Date.now()}`,s)},RP=e=>{const t=e.id||Object.keys(PP).find(e=>e.startsWith("container_"));if(t&&PP.has(t)){const e=PP.get(t);null==e||e.unmount(),PP.delete(t)}else{console.warn("Не удалось найти корень для размонтирования");try{S(e).unmount()}catch(e){console.error("Ошибка при размонтировании компонента:",e)}}},LP=new Map,jP=r=>{const{onClose:o,onSave:a,dataProviders:s,theme:l}=r,c=i.useMemo(()=>{if(r.file)return r.file;const e=r.name||"edited-image",t=r.extension||(r.type?r.type.split("/")[1]:"png"),n=r.type||`image/${t}`;return{thumbnail:r.imageDataUrl||"",name:e,id:void 0,type:n,extension:t}},[r.file,r.imageDataUrl,r.name,r.extension,r.type]),d=i.useCallback(async e=>{if(console.log("🔧 saveFileToServer: dataProviders доступны:",{hasUpdateFile:!!(null==s?void 0:s.updateFile),hasThumbnail:!!e.thumbnail,fileId:e.id}),(null==s?void 0:s.updateFile)&&e.thumbnail)try{const t=mn(e.thumbnail,e.type),n=vn(t),r=e.name.substring(0,e.name.lastIndexOf("."))+"."+n,i=xn(e.thumbnail,t);return await s.updateFile(e.id,{name:r,type:t,data:i})}catch(e){return console.error("Ошибка при обновлении файла через updateFile:",e),null}return console.warn("DataProvider для обновления файлов не настроен"),null},[s]),h=i.useCallback(async e=>{if((null==s?void 0:s.updateFile)&&e.id&&e.thumbnail)try{const t=await d(e);t&&(e=t)}catch(e){console.error("Standalone Pixie: saveFileToServer error",e)}return a&&await a(e),o&&o(),e},[s,a,o,d]),f=u(null);return e(I,{className:"em-filemanager",children:t(n,{children:[e(E,{getPopupContainer:()=>f.current||document.body,children:e(zn,{i18n:Tr,children:e(un,{externalTheme:null!=l?l:"light",children:e(te,{children:e(di,{options:{dataProviders:s,handleNotify:r.handleNotify,handleError:r.handleError,handleSuccess:r.handleSuccess,config:{theme:null!=l?l:"light",locale:r.locale,baseUrl:r.baseUrl,assetsUrl:r.assetsUrl,showNotifications:r.showNotifications}},children:e(WF,{visible:!0,onClose:o,file:c,onSave:h})})})})})}),e("div",{ref:f,className:"file-manager-modal-root"})]})})},DP=t=>{pn();const n=t.element,r=S(n);r.render(e(jP,Object.assign({},t))),LP.set(n.id||`pixie_container_${Date.now()}`,r)},NP=e=>{const t=Array.from(LP.keys()).find(e=>e.startsWith("pixie_container_")),n=e.id||t;if(n&&LP.has(n)){const e=LP.get(n);null==e||e.unmount(),LP.delete(n)}else{console.warn("Не удалось найти корень Pixie для размонтирования");try{S(e).unmount()}catch(e){console.error("Ошибка при размонтировании Pixie:",e)}}},zP=e=>{var t,n;const{mode:r,element:i,fileManager:o,pixieEditor:a,theme:s,dataProviders:l}=e;let c,u;const d={unmount:()=>{c&&RP(c),u&&NP(u)},unmountFileManager:void 0,unmountPixieEditor:void 0};switch(r){case"fileManager":c=i,MP(i,Object.assign(Object.assign({},null==o?void 0:o.config),{theme:s||(null===(t=null==o?void 0:o.config)||void 0===t?void 0:t.theme),apiEndpoints:null==o?void 0:o.apiEndpoints})),d.unmountFileManager=()=>RP(c);break;case"pixieEditor":u=i,DP(Object.assign({element:i,theme:s||(null==a?void 0:a.theme),dataProviders:l||(null==a?void 0:a.dataProviders)},a)),d.unmountPixieEditor=()=>NP(u);break;case"both":{const e=document.createElement("div");e.id="file-manager-container",e.style.cssText="height: 50%; border-bottom: 1px solid #d9d9d9;";const t=document.createElement("div");t.id="pixie-editor-container",t.style.cssText="height: 50%;",i.appendChild(e),i.appendChild(t),c=e,u=t,MP(c,Object.assign(Object.assign({},null==o?void 0:o.config),{theme:s||(null===(n=null==o?void 0:o.config)||void 0===n?void 0:n.theme),apiEndpoints:null==o?void 0:o.apiEndpoints})),DP(Object.assign({element:u,theme:s||(null==a?void 0:a.theme),dataProviders:l||(null==a?void 0:a.dataProviders)},a)),d.unmountFileManager=()=>RP(c),d.unmountPixieEditor=()=>NP(u);break}}return d};class BP extends Error{constructor(e,t,n,r){super(e),this.name="FileManagerApiError",this.code=t,this.httpStatus=n,this.details=r,Error.captureStackTrace&&Error.captureStackTrace(this,BP)}}var VP={init:MP,unmount:RP,initPixieEditor:DP,unmountPixieEditor:NP,initFileManager:zP};export{so as FileContent,BP as FileManagerApiError,OP as FileManagerApp,FP as FileManagerAppWithContext,fo as FileModals,go as FolderSidebar,jP as PixieOnlyApp,VP as default,MP as init,zP as initFileManager,DP as initPixieEditor,pn as installResizeObserverErrorHandler,gn as uninstallResizeObserverErrorHandler,RP as unmount,NP as unmountPixieEditor};
77
77
  //# sourceMappingURL=file-manager.esm.js.map