@emailmaker/filemanager 0.10.58 → 0.10.59
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/file-manager.css +28 -12
- package/file-manager.esm.js +1 -1
- package/file-manager.esm.js.map +1 -1
- package/file-manager.js +1 -1
- package/package.json +1 -1
package/file-manager.esm.js
CHANGED
|
@@ -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 xR=function(e,t){return xR=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])},xR(e,t)};var CR=function(){return CR=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},CR.apply(this,arguments)};var _R="Pixel",SR="Percent",AR={unit:SR,value:.8};function kR(e){return"number"==typeof e?{unit:SR,value:100*e}:"string"==typeof e?e.match(/^(\d*(\.\d+)?)px$/)?{unit:_R,value:parseFloat(e)}:e.match(/^(\d*(\.\d+)?)%$/)?{unit:SR,value:parseFloat(e)}:(console.warn('scrollThreshold format is invalid. Valid formats: "120px", "50%"...'),AR):(console.warn("scrollThreshold should be string or number"),AR)}var ER=function(e){function t(t){var r=e.call(this,t)||this;return r.lastScrollTop=0,r.actionTriggered=!1,r.startY=0,r.currentY=0,r.dragging=!1,r.maxPullDownDistance=0,r.getScrollableTarget=function(){return r.props.scrollableTarget instanceof HTMLElement?r.props.scrollableTarget:"string"==typeof r.props.scrollableTarget?document.getElementById(r.props.scrollableTarget):(null===r.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)},r.onStart=function(e){r.lastScrollTop||(r.dragging=!0,e instanceof MouseEvent?r.startY=e.pageY:e instanceof TouchEvent&&(r.startY=e.touches[0].pageY),r.currentY=r.startY,r._infScroll&&(r._infScroll.style.willChange="transform",r._infScroll.style.transition="transform 0.2s cubic-bezier(0,0,0.31,1)"))},r.onMove=function(e){r.dragging&&(e instanceof MouseEvent?r.currentY=e.pageY:e instanceof TouchEvent&&(r.currentY=e.touches[0].pageY),r.currentY<r.startY||(r.currentY-r.startY>=Number(r.props.pullDownToRefreshThreshold)&&r.setState({pullToRefreshThresholdBreached:!0}),r.currentY-r.startY>1.5*r.maxPullDownDistance||r._infScroll&&(r._infScroll.style.overflow="visible",r._infScroll.style.transform="translate3d(0px, "+(r.currentY-r.startY)+"px, 0px)")))},r.onEnd=function(){r.startY=0,r.currentY=0,r.dragging=!1,r.state.pullToRefreshThresholdBreached&&(r.props.refreshFunction&&r.props.refreshFunction(),r.setState({pullToRefreshThresholdBreached:!1})),requestAnimationFrame(function(){r._infScroll&&(r._infScroll.style.overflow="auto",r._infScroll.style.transform="none",r._infScroll.style.willChange="unset")})},r.onScrollListener=function(e){"function"==typeof r.props.onScroll&&setTimeout(function(){return r.props.onScroll&&r.props.onScroll(e)},0);var t=r.props.height||r._scrollableNode?e.target:document.documentElement.scrollTop?document.documentElement:document.body;r.actionTriggered||((r.props.inverse?r.isElementAtTop(t,r.props.scrollThreshold):r.isElementAtBottom(t,r.props.scrollThreshold))&&r.props.hasMore&&(r.actionTriggered=!0,r.setState({showLoader:!0}),r.props.next&&r.props.next()),r.lastScrollTop=t.scrollTop)},r.state={showLoader:!1,pullToRefreshThresholdBreached:!1,prevDataLength:t.dataLength},r.throttledOnScrollListener=function(e,t,r,n){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(),r.apply(l,u)}o||(n&&!i&&d(),s(),void 0===n&&c>e?d():!0!==t&&(i=setTimeout(n?function(){i=void 0}:d,void 0===n?e-c:e)))}return"boolean"!=typeof t&&(n=r,r=t,t=void 0),l.cancel=function(){s(),o=!0},l}(150,r.onScrollListener).bind(r),r.onStart=r.onStart.bind(r),r.onMove=r.onMove.bind(r),r.onEnd=r.onEnd.bind(r),r}return function(e,t){function r(){this.constructor=e}xR(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}(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?CR(CR({},t),{prevDataLength:e.dataLength}):null},t.prototype.isElementAtTop=function(e,t){void 0===t&&(t=.8);var r=e===document.body||e===document.documentElement?window.screen.availHeight:e.clientHeight,n=kR(t);return n.unit===_R?e.scrollTop<=n.value+r-e.scrollHeight+1:e.scrollTop<=n.value/100+r-e.scrollHeight+1},t.prototype.isElementAtBottom=function(e,t){void 0===t&&(t=.8);var r=e===document.body||e===document.documentElement?window.screen.availHeight:e.clientHeight,n=kR(t);return n.unit===_R?e.scrollTop+r>=e.scrollHeight-n.value:e.scrollTop+r>=n.value/100*e.scrollHeight},t.prototype.render=function(){var e=this,t=CR({height:this.props.height||"auto",overflow:"auto",WebkitOverflowScrolling:"touch"},this.props.style),r=this.props.hasChildren||!!(this.props.children&&this.props.children instanceof Array&&this.props.children.length),n=this.props.pullDownToRefresh&&this.props.height?{overflow:"auto"}:{};return i.createElement("div",{style:n,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&&!r&&this.props.hasMore&&this.props.loader,this.state.showLoader&&this.props.hasMore&&this.props.loader,!this.props.hasMore&&this.props.endMessage))},t}(_);function IR(e,t){if(null==e)return{};var r,n,i=function(e,t){if(null==e)return{};var r,n,i={},o=Object.keys(e);for(n=0;n<o.length;n++)r=o[n],t.indexOf(r)>=0||(i[r]=e[r]);return i}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(n=0;n<o.length;n++)r=o[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i}function TR(){return TR=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},TR.apply(this,arguments)}function FR(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function OR(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?FR(Object(r),!0).forEach(function(t){PR(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):FR(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function PR(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}const MR={breakpointCols:void 0,className:void 0,columnClassName:void 0,children:void 0,columnAttrs:void 0,column:void 0};class RR 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 r=1/0,n=t.default||2;for(let i in t){const o=parseInt(i);o>0&&e<=o&&o<r&&(r=o,n=t[i])}n=Math.max(1,parseInt(n)||1),this.state.columnCount!==n&&this.setState({columnCount:n})}itemsInColumns(){const e=this.state.columnCount,t=new Array(e),r=i.Children.toArray(this.props.children);for(let n=0;n<r.length;n++){const i=n%e;t[i]||(t[i]=[]),t[i].push(r[n])}return t}renderColumns(){const{column:e,columnAttrs:t={},columnClassName:r}=this.props,n=this.itemsInColumns(),o=100/n.length+"%";let a=r;a&&"string"!=typeof a&&(this.logDeprecated('The property "columnClassName" requires a string'),void 0===a&&(a="my-masonry-grid_column"));const s=OR(OR(OR({},e),t),{},{style:OR(OR({},t.style),{},{width:o}),className:a});return n.map((e,t)=>i.createElement("div",TR({},s,{key:t}),e))}logDeprecated(e){console.error("[Masonry]",e)}render(){const e=this.props,{children:t,breakpointCols:r,columnClassName:n,columnAttrs:o,column:a,className:s}=e,l=IR(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",TR({},l,{className:c}),this.renderColumns())}}RR.defaultProps=MR;var LR={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"};const NR={default:4,1600:3,1100:2,700:1},jR=({setImageGifList:n,imageGifList:i=[],currentReqGif:s,setCurrentReqGif:l,inputRef:c,customRequest:d})=>{const{t:h}=Zr(),{GifPlayIcon:f}=Va(),{options:p}=Fi(),{config:g}=p,[m,v]=o(null),[y,b]=o(!1),[w,x]=o(25),[C,_]=o(null),[S]=T.useForm(),k=u(s);a(()=>{S.setFieldsValue({keywords:s.keywords})},[]);const E=null==g?void 0:g.handleProxyUrl,I=async e=>E?Promise.resolve(E(e)):e,O=async e=>Promise.all(e.map(async e=>Object.assign(Object.assign({},e),{images:Object.assign(Object.assign({},e.images),{downsized:Object.assign(Object.assign({},e.images.downsized),{url:await I(e.images.downsized.url)})})}))),P=async function({query:e,page:t}){var r;const n=e.keywords.replace(/[^\w\sа-яёА-ЯЁ]|_/g,"").replace(/[\s_-]+/g," ");try{const e=`https://api.giphy.com/v1/gifs/search?api_key=${null!==(r=null==g?void 0:g.REACT_APP_GIPHY_KEY)&&void 0!==r?r:"Nh77eBlPeMn1ed9MBAvL542NUGeNO26F"}&q=${encodeURIComponent(n)}&limit=25&offset=${t}&lang=en`,i=await fetch(await I(e));return{data:await i.json()}}catch(e){console.warn(e)}},M=async()=>{var e,t;const r=await P({query:k.current,page:0});(null===(t=null===(e=null==r?void 0:r.data)||void 0===e?void 0:e.data)||void 0===t?void 0:t.length)&&r.data.data.length>0&&n(await O(r.data.data))};return a(()=>()=>{C&&clearTimeout(C)},[C]),e("div",{className:LR.gifTab,children:e("div",{className:LR.searchOutputWrapper,children:t("div",{id:"scrollableDiv",className:LR.scrollableDiv,children:[t(T,{form:S,onValuesChange:e=>{if(void 0!==e.keywords){const t=Object.assign(Object.assign({},k.current),{keywords:e.keywords});l(t),k.current=t,C&&clearTimeout(C);const r=setTimeout(M,800);_(r)}},className:i.length>0?LR.searchResults:LR.search,children:[e(T.Item,{name:"keywords",className:LR.gifSearchInput,children:e(F,{onKeyDown:e=>"Space"===e.code&&M(),onPressEnter:e=>M(),allowClear:!0,placeholder:h("Search GIFs"),ref:c,spellCheck:"false",prefix:e(bi,{size:16,strokeWidth:null==g?void 0:g.iconStrokeWidth,onClick:M})})}),i.length>0&&!y&&e("div",{className:`ant-divider ${LR.divider}`,role:"separator"})]}),!i.length&&!y&&e(r,{children:s.keywords?e(qa,{}):t("div",{className:LR.resultsContainer,children:[e("div",{className:LR.videoIcon,children:e(f,{className:LR.playButton})}),e("h1",{className:LR.title,children:h("Over 350,000 live images")}),e("p",{className:LR.subtitle,children:h("Enter a search query and we'll find the perfect image for you")})]})}),!i.length&&y&&e(cs,{}),i.length>0&&e(ER,{dataLength:i&&i.length,next:async()=>{y||(b(!0),P({query:k.current,page:w}).then(async e=>{if(e&&e.data&&e.data.data){const t=await O(e.data.data);n(e=>[...e,...t])}b(!1),x(e=>e+25)}).catch(()=>{b(!1)}))},hasMore:!!i,endMessage:t(K,{plain:!0,children:[h("That`s all we could find.")," 🤐"]}),scrollableTarget:"scrollableDiv",style:{overflow:"visible"},loader:e(cs,{}),children:e(RR,{breakpointCols:NR,className:LR.myMasonryGrid,columnClassName:LR.myMasonryGridColumn,children:i.map((r,n)=>t("div",{className:LR.listItem,onClick:()=>(async(e,t)=>{var r;v(t),setTimeout(()=>{v(null)},2e3);const n=await I(e);let i=n.split("?")[0].split("#")[0].split("/"),o=i[i.length-1]||"uploaded-file";o.includes(".")&&(null===(r=o.split(".").pop())||void 0===r?void 0:r.length)&&o.split(".").pop().length<=5||(o+=".gif"),d(n,o)})(r.images.downsized.url,r.id,r.title),children:[e("img",{className:m===r.id?LR.loadedImage:"",width:"100%",src:r.images.downsized.url,alt:r.title,onLoad:e=>{const t=e.target.parentNode;t&&t instanceof HTMLElement&&t.classList.add(LR.loaded)}}),e("a",{rel:"noreferrer",href:"https://giphy.com/",target:"_blank",onClick:e=>e.stopPropagation()}),m===r.id&&e(A,{className:LR.antSpin})]},r.id+n))})})]})})})};var DR={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"};const zR={default:4,1600:3,1100:2,700:1},BR=({imageStockList:n,setImageStockList:i,currentReq:s,setCurrentReq:l,inputRef:c,customRequest:d})=>{var h,f;const{t:p}=Zr(),{StockBigIcon:g,MixedViewIcon:m,LandscapeViewIcon:v,PortraitViewIcon:y,SquareViewIcon:b}=Va(),{options:w}=Fi(),{config:x}=w,[C,_]=o(!1),[S,k]=o(2),[E,I]=o(null),[O,P]=o(null),[M,R]=o(!0),[N]=T.useForm(),j=null==x?void 0:x.handleProxyUrl,D=null!==(h=null==x?void 0:x.UNSPLASH_KEY)&&void 0!==h?h:"HX2_qqq3F3ljmtYtfmb9P6h0dn2u9mnnOl36IdV8el0",z=u(s),B=async e=>j?Promise.resolve(j(e)):e,U=async e=>Promise.all(e.map(async e=>Object.assign(Object.assign({},e),{urls:Object.assign(Object.assign({},e.urls),{raw:await B(e.urls.raw)})})));a(()=>{z.current=s},[s]),a(()=>{0===n.length&&N.setFieldsValue({color:"",orientation:""})},[n,N]),a(()=>{N.setFieldsValue({keywords:s.keywords,color:s.color,orientation:s.orientation})},[]);const V=async function({query:e,page:t}){const r=e.keywords.replace(/[^\w\sа-яёА-ЯЁ]|_/g,"").replace(/[\s_-]+/g," ");try{let n=`https://api.unsplash.com/search/photos?client_id=${D}&lang=ru&per_page=18&query=${encodeURIComponent(r)}&page=${t}`;""!==e.color&&(n+=`&color=${e.color}`),""!==e.orientation&&(n+=`&orientation=${e.orientation}`);const i=await fetch(await B(n));return{data:await i.json()}}catch(e){console.warn(e)}finally{_(!1)}},W=async()=>{var e,t,r;_(!0);const n=await V({query:z.current,page:1});(null===(e=null==n?void 0:n.data)||void 0===e?void 0:e.results)&&(i(await U(n.data.results)),R(18===n.data.results.length),(null===(r=null===(t=null==n?void 0:n.data)||void 0===t?void 0:t.results)||void 0===r?void 0:r.length)&&n.data.results.length>0&&k(2))};a(()=>()=>{O&&clearTimeout(O)},[O]);const G=async(e,t,r,n)=>{var i;!async function(e){try{const t=`${e}${e.includes("?")?"&":"?"}client_id=${D}`,r=await B(t),n=await fetch(r);return{data:await n.json()}}catch(e){console.warn(e)}}(t.download_location),I(r),setTimeout(()=>I(null),2e3);const o=e.raw,a=await B(o),s=a.split("?")[0].split("#")[0].split("/");let l=s[s.length-1]||"uploaded-file";l.includes(".")&&(null===(i=l.split(".").pop())||void 0===i?void 0:i.length)&&l.split(".").pop().length<=5||(l+=".jpg"),d(a,l)};return e("div",{className:DR.stockTab,children:e("div",{className:DR.searchOutputWrapper,children:t("div",{className:DR.scrollableDiv,id:"scrollableDiv",children:[t(T,{form:N,initialValues:yr,onValuesChange:(e,t)=>{const r=Object.assign(Object.assign({},yr),t);if(l(r),z.current=r,O&&clearTimeout(O),""!==t.keywords){const e=setTimeout(W,800);P(e)}else n.length||(l(Object.assign({},yr)),z.current=yr,N.resetFields())},className:n.length>0?DR.searchResults:DR.search,children:[t($,{gutter:24,children:[e(H,{span:n.length>0?void 0:24,children:e(T.Item,{name:"keywords",className:DR.stockSearchInput,children:e(F,{allowClear:!0,placeholder:p("Search image"),ref:c,spellCheck:"false",prefix:e(bi,{size:16,strokeWidth:null==x?void 0:x.iconStrokeWidth})})})}),!!n.length&&t(r,{children:[e(H,{children:e(T.Item,{name:"orientation",children:t(ee.Group,{onChange:e=>l(t=>Object.assign(Object.assign({},t),{orientation:e.target.value})),children:[e(L,{title:p("All"),placement:"top",children:e(ee.Button,{value:"",children:e(m,{})})}),e(L,{title:p("Landscape"),placement:"top",children:e(ee.Button,{value:"landscape",children:e(v,{})})}),e(L,{title:p("Portrait"),placement:"top",children:e(ee.Button,{value:"portrait",children:e(y,{})})}),e(L,{title:p("Squarish"),placement:"top",children:e(ee.Button,{value:"squarish",children:e(b,{})})})]})})}),e(H,{children:e(T.Item,{name:"color",children:t(ee.Group,{className:DR.stockColorFilter,onChange:e=>l(t=>Object.assign(Object.assign({},t),{color:e.target.value})),children:[e(L,{title:p("All"),placement:"top",children:e(ee.Button,{className:DR.allColors,value:"",children:"All"})}),e(L,{title:p("Black"),placement:"top",children:e(ee.Button,{className:DR.blackColor,value:"black",children:"B"})}),e(L,{title:p("Black and White"),placement:"top",children:e(ee.Button,{className:DR.bwColor,value:"black_and_white",children:"B&W"})}),e(L,{title:p("White"),placement:"top",children:e(ee.Button,{className:DR.whiteColor,value:"white",children:"W"})}),e(L,{title:p("Orange"),placement:"top",children:e(ee.Button,{className:DR.orangeColor,value:"orange",children:"O"})}),e(L,{title:p("Red"),placement:"top",children:e(ee.Button,{className:DR.redColor,value:"red",children:"R"})}),e(L,{title:p("Purple"),placement:"top",children:e(ee.Button,{className:DR.purpleColor,value:"purple",children:"P"})}),e(L,{title:p("Magenta"),placement:"top",children:e(ee.Button,{className:DR.magentaColor,value:"magenta",children:"M"})}),e(L,{title:p("Green"),placement:"top",children:e(ee.Button,{className:DR.greenColor,value:"green",children:"G"})}),e(L,{title:p("Teal"),placement:"top",children:e(ee.Button,{className:DR.tealColor,value:"teal",children:"T"})}),e(L,{title:p("Blue"),placement:"top",children:e(ee.Button,{className:DR.blueColor,value:"blue",children:"B"})})]})})})]})]}),n.length>0&&!C&&e("div",{className:`ant-divider ${DR.divider}`,role:"separator"})]}),!n.length&&!C&&e(r,{children:s.keywords?e(qa,{}):t("div",{className:DR.resultsContainer,children:[e("div",{className:DR.videoIcon,children:e(g,{className:DR.playButton})}),e("h1",{className:DR.title,children:p("Millions of free stock images")}),e("p",{className:DR.subtitle,children:p("Enter a search query and we'll find the perfect image for you")})]})}),!n.length&&C&&e(cs,{}),n.length>0&&e(ER,{dataLength:n&&n.length,next:async()=>{if(C||""===z.current.keywords)return _(!1),void(""===z.current.keywords&&R(!1));_(!0),V({query:z.current,page:S}).then(async e=>{if(e&&e.data&&e.data.results){const t=await U(e.data.results);i(e=>[...e,...t]),R(18===e.data.results.length)}k(e=>e+1)}).catch(e=>{console.warn("catch",e)}).finally(()=>{_(!1)})},hasMore:M&&""!==(null===(f=z.current)||void 0===f?void 0:f.keywords),endMessage:t(K,{plain:!0,children:[p("That`s all we could find.")," 🤐"]}),scrollableTarget:"scrollableDiv",style:{overflow:"visible"},loader:e(cs,{}),children:e(RR,{breakpointCols:zR,className:DR.myMasonryGrid,columnClassName:DR.myMasonryGridColumn,children:n.map((r,n)=>t("div",{className:DR.listItem,onClick:()=>G(r.urls,r.links,r.id,r.description),children:[e("img",{className:E===r.id?DR.loadedImage:"",width:"100%",src:r.urls.raw,alt:r.description,onLoad:e=>{const t=e.target.parentNode;t&&t instanceof HTMLElement&&t.classList.add(DR.loaded)}}),t("p",{className:DR.creatorInfo,onClick:e=>e.stopPropagation(),children:[p("Photo by")," ",e("a",{target:"_blank",href:`${r.user.links.html}?utm_source=${null==x?void 0:x.APP_NAME_UNSPLASH}&utm_medium=referral`,rel:"noreferrer",children:r.user.name})," ",p("on")," ",e("a",{target:"_blank",href:`https://unsplash.com/?utm_source=${null==x?void 0:x.APP_NAME_UNSPLASH}&utm_medium=referral`,rel:"noreferrer",children:"Unsplash"})]}),E===r.id&&e(A,{className:DR.antSpin})]},r.id+n))})})]})})})},UR=()=>{const{options:e}=Fi(),t=e.config;return c((e,r)=>{!1!==(null==t?void 0:t.pushToGTM)&&((e,t)=>{const r=()=>{try{const t=Object.assign(Object.assign({},e),{appLabel:"blocks_app"});window.dataLayer&&"function"==typeof window.dataLayer.push&&window.dataLayer.push(t)}catch(e){console.error("Ошибка при вызове GTM:",e)}};t?setTimeout(r,t):r()})(e,r)},[null==t?void 0:t.pushToGTM])};var VR="slideshowContainer",$R="slideshowImage";const HR=({images:t,transitionDuration:r=1e3,frameHeight:n})=>{const[i,s]=o([]),[l,c]=o(n);a(()=>{const e=()=>{if("undefined"==typeof window)return void c(n);const e=window.innerHeight,t=Math.max(e-260,130);if("number"==typeof n){const e=Math.min(n,t);c(e)}else c(t)};if(e(),"undefined"!=typeof window)return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[n]);const u=()=>{s(e=>e.map((t,r)=>r===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(u,1e3)}else s([])},[t]),e("div",{className:VR,style:{height:l,minHeight:130},children:i.map((t,n)=>e("img",{src:`data:image/jpeg;base64, ${t.src}`,alt:`Slide ${n+1}`,className:$R,style:{opacity:t.opacity,transition:`opacity ${r}ms linear`,display:"block"}},n))})};"function"==typeof SuppressedError&&SuppressedError;const WR=t=>{var{className:r,style:n,color:i,text:o,bordered:a}=t,s=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(e);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(r[n[i]]=e[n[i]])}return r}(t,["className","style","color","text","bordered"]);const l=o||"";return e(te,Object.assign({style:n,color:i,bordered:a,className:r},s,{children:l}))},GR=({text:r,counter:n,limits:i,wrapperStyles:o})=>{const{t:a}=Zr(),{options:s}=Fi(),l=s.config,{token:c}=k.useToken(),u=+i>0,d=!u||n<+i,h=(null==l?void 0:l.billingPageUrl)||"/billing",f=n+" "+a("of")+" "+(u?i:"∞")+" "+(r||a("tests",{count:i}))+" "+a("was used",{count:n});return t("div",{className:"limits-couter-wrapper",style:o,children:[e(WR,{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 qR={imageAi:"imageAi",imageAiExample:"imageAiExample",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 YR=f(({className:t,onClick:r})=>e("div",{className:`${qR.arrow} ${qR.arrowNext} ${t||""}`,onClick:r,children:e(j,{className:`${qR.arrowBtn} ${qR.arrowBtnNext}`,size:"large",icon:e(ke,{})})}));YR.displayName="SampleNextArrow";const XR=f(({className:t,onClick:r})=>e("div",{className:`${qR.arrow} ${qR.arrowPrev} ${t||""}`,onClick:r,children:e(j,{className:`${qR.arrowBtn} ${qR.arrowBtnPrev}`,size:"large",icon:e(Ee,{})})}));XR.displayName="SamplePrevArrow";const KR=({customRequest:r,inputAiRef:n,isImageUploaded:s,setIsImageUploaded:l,aiImageRequest:h,setAiImageRequest:f,imageAiList:p,setImageAiList:g,isLoadingAi:m,setIsLoadingAi:v})=>{const{t:y}=Zr(),{AiIcon_2:b}=Va(),w=i.useRef(null),[x,C]=o("auto"),{aiImageCounter:_,currentAiImgLimits:S,loadingDuringGeneration:A,requestStatus:k,handleGenerate:E,convertBase64ToFile:I,isShiftPressed:O,setIsShiftPressed:P,limitsInPlugin:M}=function({setFrameHeight:e,customRequest:t,aiTabRef:r,isImageUploaded:n,setIsImageUploaded:i,aiImageRequest:s,imageAiList:l,setImageAiList:h,isLoadingAi:f,setIsLoadingAi:p}){const{t:g}=Zr(),{options:m}=Fi(),v=m.config,y=Li(),b=UR(),{messages:w}=m.config,[x,C]=o([]),[_,S]=o(0),[A,k]=o(null),[E,I]=o(!1),[T,F]=o(g("Evaluating the task")),[O,P]=o(!1),M=u(new Set),R=u(new Set),L=u(new Set);a(()=>{C(w)},[w]),a(()=>{l.length||A||(C([]),M.current.clear(),R.current.clear(),L.current.clear(),D.current=-1)},[l,A]);const N=d(()=>v&&"function"==typeof(null==v?void 0:v.sendAIImageRequest)?null==v?void 0:v.sendAIImageRequest:()=>Promise.resolve({}),[v]),j=c(e=>{const t=`${A}-${e.progress}-${JSON.stringify(e.images||e.data)}`;if(!L.current.has(t))if(L.current.add(t),"error"!==e.status&&"Canceled"!==e.status){if(e.images){if(F(String(e.status)),100===e.progress){p(!1),h(e.images);const t=A,r=Array.isArray(e.images)?e.images:[];r.length>0&&t&&!M.current.has(t)&&(M.current.add(t),y.success({id:"AI_IMAGE_GENERERATION_SUCCESS",message:g("Images generated successfully"),placement:"bottomRight",data:{request:s,taskId:t,images:r}})),k(null),P(!1)}}else if(e.data&&(h([String(e.data)]),100===e.progress)){p(!1);const t=A,r=e.data?[String(e.data)]:[];r.length>0&&t&&!M.current.has(t)&&(M.current.add(t),y.success({id:"AI_IMAGE_GENERERATION_SUCCESS",message:g("Images generated successfully"),placement:"bottomRight",data:{request:s,taskId:t,images:r}})),k(null),P(!1)}}else p(!1),P(!1),A&&!R.current.has(A)&&(R.current.add(A),y.error({id:"AI_RESPONSE_INVALID",message:g("Something went wrong, please try again"),placement:"bottomRight",description:String(A)||void 0,data:{requestId:A,request:s,response:e},innerException:e}))},[s,h,F,g,p,A,y,P]),D=u(-1);a(()=>{if(x.length>0){const e=x.length-1;e>D.current&&(D.current=e,j(x[e]))}},[j,x]);const z=d(()=>{if(v&&"function"==typeof(null==v?void 0:v.sseQuery)){const e=null==v?void 0:v.sseQuery;return t=>e(t)}return e=>{}},[v]),B=d(()=>v&&"object"==typeof(null==v?void 0:v.handleLimitUsageEmitter)?null==v?void 0:v.handleLimitUsageEmitter:{fire:()=>{}},[v]),U=null==v?void 0:v.elementId,{projectId:V}=v,{limits:$}=(null==v?void 0:v.limits)?v:{limits:{ai_img_limit:0}},{ai_img_limit:H}=$,W=H>0&&_>=H,G=!(!(null==v?void 0:v.limits)||!v.counters)&&pr,q=c(()=>{B.fire({name:"AiImgCount",count:_+1})},[B,_]),Y=d(()=>!W&&!G,[W,G,_,H]),X=c(async()=>{F(g("Evaluating the task")),""===s||f||(p(!0),P(!0),h([]),C([]),b({event:"submit_form",action:"ai_image_generation",entity_id:U,project_id:V}),N({body:{project_id:V,request:"create-image",connection:"midjourney",message:s}}).then(e=>{var t,r,n,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===(r=null==c?void 0:c.data)||void 0===r?void 0:r.task),d=null!==(i=null!==(n=null==u?void 0:u.id)&&void 0!==n?n:A)&&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)&&(F(u.message),k(u.id)),(null==c?void 0:c.message)&&y.success({id:"AI_IMAGE_GENERATION_STARTED",message:c.message,placement:"bottomRight",data:{request:s,taskId:d,response:null==c?void 0:c.data}}),z({task_id:null==u?void 0:u.id,entity_id:U})):(p(!1),P(!1),d&&!R.current.has(d)&&(R.current.add(d),y.error({id:"AI_IMAGE_GENERATION_FAILED",message:(null==c?void 0:c.message)||g("Something went wrong, please try again"),placement:"bottomRight",description:s,data:{request:s,taskId:d,response:c},innerException:c})))}).catch(e=>{p(!1),P(!1);const t=e;return((null==t?void 0:t.error)||(null==t?void 0:t.data))&&A&&!R.current.has(A)&&(R.current.add(A),null==y||y.error({id:"AI_IMAGE_GENERATION_FAILED",message:g("Something went wrong, please try again"),placement:"bottomRight",description:s,innerException:e,data:{request:s,taskId:A,response:null==t?void 0:t.data,error:Hi(null==t?void 0:t.error)}})),t}))},[s,f,p,P,h,b,U,V,N,y,z,g,A]),K=c(()=>{Y&&X()},[Y,G,S,q,X,y,g]);a(()=>{},[v,G]);const Z=c(e=>{if(n)return;const r=e.match(/^data:image\/([A-Za-z-+/]+);base64,(.+)$/);if(!r)return;const o=r[1],a=r[2],s=atob(a),l=new Array(s.length);for(let e=0;e<s.length;e++)l[e]=s.charCodeAt(e);const c=new Uint8Array(l),u=new Blob([c],{type:`image/${o}`}),d=new File([u],"image.jpeg",{type:u.type,lastModified:Date.now()});i(!0),(async()=>{try{"function"==typeof t&&await Promise.resolve(t({file:d}))}catch(e){console.error("FM AI: customRequest error",e)}finally{i(!1)}})()},[n,i,t]);return a(()=>{(f||l.length>0)&&setTimeout(()=>{var t,n;let i=350;if(r.current){const e=null===(t=r.current)||void 0===t?void 0:t.firstChild;e&&e instanceof HTMLElement&&(i=(null===(n=r.current.getBoundingClientRect())||void 0===n?void 0:n.height)-48-e.clientHeight)}e(i)},0)},[r,l.length,f,e]),{aiImageCounter:_,setAiImageCounter:S,currentAiImgLimits:H,isFieldsDisabled:W,canGenerateImage:Y,aiImageRequest:s,imageAiList:l,setImageAiList:h,isLoadingAi:f,setIsLoadingAi:p,loadingDuringGeneration:O,setLoadingDuringGeneration:P,requestStatus:T,setRequestStatus:F,handleGenerate:K,handleLimitAiImgCount:q,convertBase64ToFile:Z,isShiftPressed:E,setIsShiftPressed:I,currentReqId:A,setCurrentReqId:k,limitsInPlugin:G}}({setFrameHeight:C,customRequest:r,aiTabRef:w,isImageUploaded:s,setIsImageUploaded:l,aiImageRequest:h,imageAiList:p,setImageAiList:g,isLoadingAi:m,setIsLoadingAi:v});a(()=>{},[s]);const[R,L]=o(!1),N=c(()=>L(!0),[]),D=c(()=>L(!1),[]),z=c(e=>f(e.target.value),[f]),B=c(e=>{"Shift"===e.key?P(!0):"Enter"!==e.key||O||(e.preventDefault(),E())},[O,E,P]),U=c(e=>{"Shift"===e.key&&P(!1)},[P]);return t("div",{className:qR.imageAi,ref:w,children:[M&&e(GR,{text:"images",counter:_,limits:S,wrapperStyles:{marginTop:-25}}),e($,{gutter:24,className:qR.row,children:t(H,{span:24,children:[e(T.Item,{children:t("span",{className:`ant-input-affix-wrapper ant-input-affix-wrapper-lg ${qR.inputAffixWrapper}${R?" ant-input-affix-wrapper-focused":""}`,children:[e(F.TextArea,{ref:n,onKeyDown:B,onKeyUp:U,onFocus:N,onBlur:D,autoSize:!0,allowClear:!0,className:`${qR.textAreaInputHybrid} ${qR.textarea}`,placeholder:y("Generate image"),value:h,onChange:z,spellCheck:"false"}),e("span",{className:`ant-input-suffix ${qR.inputSuffix}`,children:m||A?e(le,{className:`${qR.inputIcon} input-icon`,spin:!0}):e(b,{className:`${qR.inputIcon} input-icon`,onClick:E})})]})}),t("div",{className:qR.imageAiExample,children:[e("span",{children:y("For example:")})," ",y("A beautiful image of a sunset over a calm ocean.")]})]})}),(m||p.length>0)&&t(re,{dotPosition:"top",arrows:!0,nextArrow:e(YR,{}),prevArrow:e(XR,{}),className:qR.carousel,infinite:!1,children:[m&&!p.length&&e("div",{className:qR.loading,children:t("div",{className:"spin",children:[e(le,{style:{fontSize:48},spin:!0}),e("p",{className:"status",children:k})]})}),p.length>0&&p.map((r,n)=>t("div",{className:qR.imageItem,children:[e(HR,{images:p,frameHeight:x}),e("div",{className:"buttons",children:p.length>0&&!m&&e(j,{onClick:()=>I(`data:image/jpeg;base64, ${r}`),loading:s,icon:e(Ie,{}),children:y("Use this variant")})})]},n))]})]})};var ZR={iconsTab:"iconsTab",hasSearch:"hasSearch",iconsSearchFormCenteredContainer:"iconsSearchFormCenteredContainer",iconsSearchFormCentered:"iconsSearchFormCentered",iconsSearchFormInput:"iconsSearchFormInput",iconsSearchFormInputInput:"iconsSearchFormInputInput",iconsSearchResults:"iconsSearchResults",iconsControlsControls:"iconsControlsControls",iconsControls:"iconsControls",iconsControlElement:"iconsControlElement",iconsControlsStrokeWidth:"iconsControlsStrokeWidth",iconsControlsHeader:"iconsControlsHeader",iconsSearchFormSelect:"iconsSearchFormSelect",iconsSearchFormStyleItem:"iconsSearchFormStyleItem",iconsSearchDivider:"iconsSearchDivider",iconsGrid:"iconsGrid",iconsBottomBar:"iconsBottomBar",iconsBottomBarContent:"iconsBottomBarContent",iconsGridEmptyState:"iconsGridEmptyState",resultsContainer:"resultsContainer",playButton:"playButton",title:"title",subtitle:"subtitle",iconsGridInfiniteScroll:"iconsGridInfiniteScroll",iconsGridGrid:"iconsGridGrid",iconsGridItem:"iconsGridItem",iconsGridItemThumbnail:"iconsGridItemThumbnail",iconsGridItemSvg:"iconsGridItemSvg",iconsGridItemImg:"iconsGridItemImg",iconsGridItemName:"iconsGridItemName",iconsGridLoading:"iconsGridLoading",iconsControlsBackButton:"iconsControlsBackButton",iconsGridCheckbox:"iconsGridCheckbox",iconsGridShowCheckboxes:"iconsGridShowCheckboxes",iconsHeaderContainer:"iconsHeaderContainer",iconsHeaderContainerLeft:"iconsHeaderContainerLeft",copyToFolderModalBody:"copyToFolderModalBody",copyToFolderModalLoadingOverlay:"copyToFolderModalLoadingOverlay"};const JR=[{label:"Line",value:"line"},{label:"Solid",value:"solid"},{label:"Flat",value:"flat"},{label:"Duo",value:"duo"},{label:"Handrawn",value:"handrawn"},{label:"Creative",value:"creative"},{label:"Gradient",value:"gradient"},{label:"Remix",value:"remix"},{label:"Neon",value:"neon"},{label:"Pop",value:"pop"},{label:"Light",value:"light"},{label:"Glyph",value:"glyph"},{label:"Minimal",value:"minimal"},{label:"Outlined",value:"outlined"},{label:"Geometric",value:"geometric"},{label:"Bold",value:"bold"},{label:"Stroke",value:"stroke"},{label:"Wireframe",value:"wireframe"},{label:"Filled",value:"filled"}],QR=({query:r,onQueryChange:n,onSubmit:i,styleFilter:o,onStyleChange:a,hasResults:s=!1,inputRef:l})=>{const{t:c}=Zr(),{options:u}=Fi(),{config:d}=u,h=r.length>0&&s;return t("div",{className:ZR.iconsSearchFormCenteredContainer,children:[t(T,{layout:"inline",onFinish:i,className:h?ZR.iconsSearchResults:ZR.iconsSearchFormCentered,children:[e(T.Item,{className:ZR.iconsSearchFormInput,children:e(F,{ref:l,className:ZR.iconsSearchFormInputInput,allowClear:!0,prefix:e(bi,{size:16,strokeWidth:null==d?void 0:d.iconStrokeWidth,onClick:i}),placeholder:c("Search icons"),value:r,onChange:e=>n(e.target.value),onKeyDown:e=>"Space"===e.code&&i(),onPressEnter:i,spellCheck:"false"})}),h&&e(T.Item,{className:ZR.iconsSearchFormStyleItem,children:e(M,{allowClear:!0,placeholder:c("Style"),value:null!=o?o:void 0,onChange:e=>a(null!=e?e:null),className:ZR.iconsSearchFormSelect,options:JR.map(e=>({label:c(e.label),value:e.value}))})})]}),h&&e("div",{className:`ant-divider ${ZR.iconsSearchDivider}`,role:"separator"})]})},eL=n=>{const{t:i}=Zr(),{mode:o,colorHex:a,setColorHex:s,colorHex2:l,setColorHex2:c,colorHex3:u,setColorHex3:d,sizePx:h,setSizePx:f,strokeWidth:p,setStrokeWidth:g,showSecondColor:m,showThirdColor:v,onBack:y,styleFilter:b}=n;return t("div",{className:ZR.iconsControls,children:[e("div",{className:ZR.iconsControlsControls,children:"family"===o&&t(r,{children:[t("div",{className:ZR.iconsControlsStrokeWidth,children:[e("span",{children:i("Size")}),e(ne,{min:20,max:200,value:h,formatter:e=>`${e}px`,parser:e=>e?e.replace("px",""):"",onChange:e=>f("number"==typeof e?e:50)})]}),t("div",{className:ZR.iconsControlsStrokeWidth,children:[e("span",{children:i("Stroke width")}),e(ne,{min:.3,max:3,step:.1,value:"number"==typeof p?p:1,formatter:e=>`${e}px`,parser:e=>e?e.replace("px",""):"",onChange:e=>g("number"==typeof e?e:1)})]}),"gradient"===b?e(D,{size:8,children:e(ie,{defaultValue:[{color:a||"#108ee9",percent:0},{color:l||"#87d068",percent:100}],showText:!0,mode:"gradient",onChangeComplete:e=>{try{const t=e.toCssString().match(/(rgba?\([^)]+\)|#[0-9a-fA-F]{3,8})/g)||[];t[0]&&s(t[0]),t[1]&&c(t[1])}catch(e){console.warn("ColorPicker gradient parsing error",e)}},size:"small"})}):t(r,{children:[t("div",{className:ZR.iconsControlElement,children:[e("span",{children:i("Color1")}),e(ie,{value:a,format:"hex",disabledAlpha:!0,onChange:(e,t)=>s(t),size:"middle"})]}),m&&t("div",{className:ZR.iconsControlElement,children:[e("span",{children:i("Color2")}),e(ie,{value:l,format:"hex",disabledAlpha:!0,onChange:(e,t)=>c(t),size:"middle"})]}),v&&t("div",{className:ZR.iconsControlElement,children:[e("span",{children:i("Color3")}),e(ie,{value:u,format:"hex",disabledAlpha:!0,onChange:(e,t)=>d(t),size:"middle"})]})]})]})}),e("div",{className:ZR.iconsControlsHeader,children:e("div",{children:"family"===o?e(j,{className:ZR.iconsControlsBackButton,type:"default",onClick:y,title:i("Back"),children:i("Back")}):null})})]})},tL=e(le,{style:{fontSize:20},spin:!0}),rL=({items:r,hasMore:n,loading:i,hasQuery:o,mode:a,selectedHash:s,onLoadMore:l,onItemClick:c,onInsert:u,scrollContainerRef:d,colorVars:h,svgTextMap:f,previewSize:p,selectedHashes:g,onToggleSelect:m})=>{const{t:v}=Zr(),{ThumbsUpIcon:y}=Va(),b=Boolean(g&&g.size>0),w=e("div",o?{className:ZR.iconsGridEmptyState,children:e(qa,{})}:{className:ZR.iconsGridEmptyState,children:t("div",{className:ZR.resultsContainer,children:[e("span",{className:ZR.videoIcon,children:e(y,{className:ZR.playButton,style:{width:48,height:49,marginBottom:10}})}),e("h1",{className:ZR.title,children:v("Millions of icons")}),e("p",{className:ZR.subtitle,children:v("Enter a search query and we'll find the perfect icon for you")})]})});return t("div",{id:"iconsScrollableDiv",ref:d,className:ZR.iconsGrid,children:[0!==r.length||i?e(ER,{dataLength:r.length,next:l,hasMore:n,scrollableTarget:"iconsScrollableDiv",className:ZR.iconsGridInfiniteScroll,loader:e(A,{indicator:tL}),children:e("div",{className:`${ZR.iconsGridGrid} ${b?ZR.iconsGridShowCheckboxes:""}`,style:{"--icons-grid-min-col":`${Math.max(100,(null!=p?p:50)+48)}px`},children:r.map(r=>{var n,i,o,l,u,d,v,y,b,w,x;return t("div",{style:{border:g&&g.has(r.hash)||s===r.hash?"1px solid #1890ff":"1px solid #f0f0f0",boxShadow:g&&g.has(r.hash)||s===r.hash?"0 0 0 2px rgba(24,144,255,0.2)":"none"},className:ZR.iconsGridItem,onClick:()=>{c(r),m&&"family"===a&&m(r.hash)},children:[e("div",{style:{height:null!=p?p:50},className:ZR.iconsGridItemThumbnail,children:"family"===a&&f[r.hash]?e("div",{style:{color:null==h?void 0:h.colorHex,"--icon-grad-1":null!==(n=null==h?void 0:h.colorHex)&&void 0!==n?n:"#000","--icon-grad-2":null!==(i=null==h?void 0:h.colorHex2)&&void 0!==i?i:"#ff007a","--icon-color-1":null!==(o=null==h?void 0:h.colorHex)&&void 0!==o?o:"#000","--icon-color-2":null!==(l=null==h?void 0:h.colorHex2)&&void 0!==l?l:"#ff007a","--icon-color-3":null!==(u=null==h?void 0:h.colorHex3)&&void 0!==u?u:"#00C2FF","--icon-stroke-1":null!==(d=null==h?void 0:h.colorHex)&&void 0!==d?d:"#000","--icon-stroke-2":null!==(v=null==h?void 0:h.colorHex2)&&void 0!==v?v:"#ff007a","--icon-stroke-3":null!==(y=null==h?void 0:h.colorHex3)&&void 0!==y?y:"#00C2FF","--icon-fill-1":null!==(b=null==h?void 0:h.colorHex)&&void 0!==b?b:"#000","--icon-fill-2":null!==(w=null==h?void 0:h.colorHex2)&&void 0!==w?w:"#ff007a","--icon-fill-3":null!==(x=null==h?void 0:h.colorHex3)&&void 0!==x?x:"#00C2FF"},dangerouslySetInnerHTML:{__html:f[r.hash]},className:ZR.iconsGridItemSvg}):e("img",{src:r.imagePreviewUrl,alt:r.name,style:{maxHeight:null!=p?p:96},className:ZR.iconsGridItemImg})}),e("div",{className:ZR.iconsGridItemName,title:r.name,children:r.name}),m?e("div",{onClick:e=>{e.stopPropagation()},className:ZR.iconsGridCheckbox,children:e(R,{checked:Boolean(g&&g.has(r.hash)),onChange:()=>m(r.hash)})}):null]},r.hash)})})}):w,!i&&n&&r.length>0&&e("div",{style:{height:1},ref:e=>{if(!e||!d.current)return;const t=d.current;t.scrollHeight<=t.clientHeight&&l()}}),i&&0===r.length&&e("div",{className:ZR.iconsGridLoading,children:e(A,{indicator:tL})})]})},nL="path|rect|circle|ellipse|polygon|line|polyline|g";function iL(e){const t=e.trim();if(!t||"none"===t||"transparent"===t)return null;if(/^url\(#/.test(t))return null;if(/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/.test(t)){const e=t.match(/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})/);return e?"#"+(3===e[1].length?e[1].replace(/(.)/g,"$1$1"):e[1]).toLowerCase():null}if(/^rgb\(/.test(t)){const e=t.match(/^rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/);if(e)return"#"+[1,2,3].map(t=>parseInt(e[t],10).toString(16).padStart(2,"0")).join("")}if(/^rgba\(/.test(t)){const e=t.match(/^rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*[\d.]+\s*\)/);if(e)return"#"+[1,2,3].map(t=>parseInt(e[t],10).toString(16).padStart(2,"0")).join("")}const r={black:"#000000",white:"#ffffff",red:"#ff0000",green:"#008000",blue:"#0000ff"},n=t.toLowerCase();return r[n]?r[n]:("currentcolor"===n||"inherit"===n||/^[a-zA-Z]+$/.test(t),null)}function oL(e,t){const r=new RegExp(`${t}\\s*:\\s*([^;]+)`,"i"),n=e.match(r);return n?n[1].trim():null}function aL(e){let t=0;const r=new RegExp(`<(?:${nL})([^>]*)>`,"gi");let n;for(;null!==(n=r.exec(e));){const e=n[1],r=e.match(/fill\s*=\s*["']([^"']*)["']/i),i=e.match(/style\s*=\s*["']([^"']*)["']/i),o=r&&r[1]&&!/^none$/i.test(r[1])&&!/^url\(#/i.test(r[1]),a=i&&oL(i[1],"fill")&&!/^none$/i.test(oL(i[1],"fill"));(o||a)&&(t+=1)}return t}function sL(e){let t=0;const r=new RegExp(`<(?:${nL})([^>]*)>`,"gi");let n;for(;null!==(n=r.exec(e));){const e=n[1],r=e.match(/stroke\s*=\s*["']([^"']*)["']/i),i=e.match(/style\s*=\s*["']([^"']*)["']/i),o=r&&r[1]&&!/^none$/i.test(r[1])&&!/^url\(#/i.test(r[1]),a=i&&oL(i[1],"stroke")&&!/^none$/i.test(oL(i[1],"stroke"));(o||a)&&(t+=1)}return t}function lL(e){return/<linearGradient/i.test(e)||/<radialGradient/i.test(e)||/fill="url\(#|stroke="url\(#/i.test(e)}function cL(e){const t=e.trim().replace(/(?:px|em|ex|%)\s*$/i,""),r=parseFloat(t);return Number.isNaN(r)||r<=0||r>10?null:Math.round(10*r)/10}function uL(e){const t=[],r=e.indexOf("</defs>"),n=r>=0?e.slice(r):e,i=new RegExp(`<(?:${nL})[^>]*stroke-width\\s*=\\s*["']([^"']+)["']`,"gi");let o;for(;null!==(o=i.exec(n));){const e=cL(o[1]);null!=e&&t.push(e)}const a=new RegExp(`<(?:${nL})[^>]*style\\s*=\\s*["'][^"']*stroke-width\\s*:\\s*([^;"]+)[^"']*["']`,"gi");for(;null!==(o=a.exec(n));){const e=cL(o[1]);null!=e&&t.push(e)}if(0===t.length)return;t.sort((e,t)=>e-t);const s=Math.floor(t.length/2);return t.length%2==1?t[s]:(t[s-1]+t[s])/2}function dL(e){const t=function(e){const t=[],r=new Set;Array.from(e.matchAll(/<stop[^>]*?stop-color\s*=\s*["']([^"']+)["']/gi)).map(e=>e[1]).forEach(e=>{const n=iL(e);n&&!r.has(n)&&(r.add(n),t.push(e))});const n=new RegExp(`<(?:${nL})([^>]*)>`,"gi");let i;for(;null!==(i=n.exec(e));){const e=i[1],n=e.match(/fill\s*=\s*["']([^"']*)["']/i);if(n&&n[1]){const e=iL(n[1]);e&&!r.has(e)&&(r.add(e),t.push(n[1]))}const o=e.match(/stroke\s*=\s*["']([^"']*)["']/i);if(o&&o[1]){const e=iL(o[1]);e&&!r.has(e)&&(r.add(e),t.push(o[1]))}const a=e.match(/style\s*=\s*["']([^"']*)["']/i);if(a&&a[1]){const e=oL(a[1],"fill");if(e){const n=iL(e);n&&!r.has(n)&&(r.add(n),t.push(e))}const n=oL(a[1],"stroke");if(n){const e=iL(n);e&&!r.has(e)&&(r.add(e),t.push(n))}}}const o=e.match(/<svg([^>]*)>/i);if(o&&o[1]){const e=o[1];for(const[n,i]of[["fill",/fill\s*=\s*["']([^"']*)["']/i],["stroke",/stroke\s*=\s*["']([^"']*)["']/i]]){const n=e.match(i);if(n&&n[1]){const e=iL(n[1]);e&&!r.has(e)&&(r.add(e),t.push(n[1]))}}const n=e.match(/style\s*=\s*["']([^"']*)["']/i);if(n&&n[1])for(const e of["fill","stroke"]){const i=oL(n[1],e);if(i){const e=iL(i);e&&!r.has(e)&&(r.add(e),t.push(i))}}}return t}(e);return{colors:t,fillsCount:aL(e),strokesCount:sL(e),hasGradient:lL(e),strokeWidth:uL(e)}}const hL=new Map,fL="https://public-api.streamlinehq.com/v1";function pL(e,t,r,n){const o=i.useMemo(()=>t&&"string"==typeof t?t.replace(/\/$/,""):"/streamline",[t]),a=async e=>r?Promise.resolve(r(e)):e,s=null==n?void 0:n.trim(),l=i.useCallback(async e=>r?a(function(e){const{mode:t,q:r,offset:n,limit:i,familySlug:o,style:a}=e,s=new URLSearchParams;"global"===t&&(s.set("productType","icons"),s.set("productTier","free")),s.set("query",r),s.set("offset",String(n)),s.set("limit",String(i)),a&&s.set("style",a);const l="global"===t?"search/global":`search/family/${encodeURIComponent(o||"")}`;return`${fL}/${l}?${s.toString()}`}(e)):function(e,t){const{mode:r,q:n,offset:i,limit:o,familySlug:a,style:s}=t,l="global"===r?"search/global":`search/family/${encodeURIComponent(a||"")}`,c=new URL(`${e}/${l}`,window.location.origin);return"global"===r&&(c.searchParams.set("productType","icons"),c.searchParams.set("productTier","free")),c.searchParams.set("query",n),c.searchParams.set("offset",String(i)),c.searchParams.set("limit",String(o)),s&&c.searchParams.set("style",s),c.toString().replace(window.location.origin,"")}(o,e),[o,r]),c=i.useCallback(async e=>{var t;const r=await l({mode:e.mode,q:e.query.trim(),offset:e.offset,limit:e.limit,familySlug:e.familySlug,style:null!==(t=e.style)&&void 0!==t?t:null}),n={Accept:"application/json"};s&&(n["x-api-key"]=s);const i=await fetch(r,{method:"GET",headers:n,signal:e.signal});if(!i.ok){const e=await i.text();throw new Error(`Request failed: ${i.status} ${e}`)}return await i.json()},[l,s]),u=i.useCallback((e,t)=>{let r=e;const n=/<linearGradient[\s\S]*?<\/linearGradient>/i.test(r)||/<radialGradient[\s\S]*?<\/radialGradient>/i.test(r);if(!(/fill="url\(#/i.test(r)||/stroke="url\(#/i.test(r))){const e=function(e){var t,r,n,i,o,a,s,l;const c=new Map,u={v:1},d=e=>{const t=iL(e);t&&!c.has(t)&&(c.set(t,u.v),u.v=Math.min(u.v+1,3))},h=e.match(/<svg([^>]*)>/i);if(null==h?void 0:h[1]){const e=h[1],t=e.match(/fill\s*=\s*["']([^"']*)["']/i),r=e.match(/stroke\s*=\s*["']([^"']*)["']/i);!(null==t?void 0:t[1])||/^none$/i.test(t[1])||/^url\(#/i.test(t[1])||d(t[1]),!(null==r?void 0:r[1])||/^none$/i.test(r[1])||/^url\(#/i.test(r[1])||d(r[1])}const f=new RegExp(`<(?:${nL})([^>]*)>`,"gi");let p;for(;null!==(p=f.exec(e));){const e=p[1],c=e.match(/fill\s*=\s*["']([^"']*)["']/i),u=e.match(/style\s*=\s*["']([^"']*)["']/i),h=null===(t=null==u?void 0:u[1])||void 0===t?void 0:t.match(/fill\s*:\s*([^;]+)/i),f=null===(i=null!==(r=null==c?void 0:c[1])&&void 0!==r?r:null===(n=null==h?void 0:h[1])||void 0===n?void 0:n.trim())||void 0===i?void 0:i.trim();!f||/^none$/i.test(f)||/^url\(#/i.test(f)||d(f);const g=e.match(/stroke\s*=\s*["']([^"']*)["']/i),m=e.match(/style\s*=\s*["']([^"']*)["']/i),v=null===(o=null==m?void 0:m[1])||void 0===o?void 0:o.match(/stroke\s*:\s*([^;]+)/i),y=null===(l=null!==(a=null==g?void 0:g[1])&&void 0!==a?a:null===(s=null==v?void 0:v[1])||void 0===s?void 0:s.trim())||void 0===l?void 0:l.trim();!y||/^none$/i.test(y)||/^url\(#/i.test(y)||d(y)}return c}(r),t=t=>{const r=iL(t),n=r?e.get(r):void 0;return 1===n?"var(--icon-color-1)":2===n?"var(--icon-color-2)":3===n?"var(--icon-color-3)":"currentColor"};r=r.replace(/<svg([^>]*)>/i,(e,r)=>{let n=r;const i=r.match(/fill\s*=\s*["']([^"']*)["']/i);!(null==i?void 0:i[1])||/^none$/i.test(i[1])||/^url\(#/i.test(i[1])||(n=n.replace(/fill\s*=\s*["'][^"']*["']/i,`fill="${t(i[1])}"`));const o=r.match(/stroke\s*=\s*["']([^"']*)["']/i);return!(null==o?void 0:o[1])||/^none$/i.test(o[1])||/^url\(#/i.test(o[1])||(n=n.replace(/stroke\s*=\s*["'][^"']*["']/i,`stroke="${t(o[1])}"`)),`<svg${n}>`}),r=r.replace(/<(path|rect|circle|ellipse|polygon|line|polyline)([^>]*?)(\/>|>)/gi,(e,r,n,i)=>{var o,a,s,l,c,u,d,h;let f=n;const p=n.match(/fill\s*=\s*["']([^"']*)["']/i),g=n.match(/style\s*=\s*["']([^"']*)["']/i),m=null===(o=null==g?void 0:g[1])||void 0===o?void 0:o.match(/fill\s*:\s*([^;]+)/i),v=null===(l=null!==(a=null==p?void 0:p[1])&&void 0!==a?a:null===(s=null==m?void 0:m[1])||void 0===s?void 0:s.trim())||void 0===l?void 0:l.trim();if(v&&!/^none$/i.test(v)&&!/^url\(#/i.test(v)){const e=t(v);p?f=f.replace(/fill\s*=\s*["'][^"']*["']/i,`fill="${e}"`):(null==g?void 0:g[1])&&(f=f.replace(/style\s*=\s*["']([^"']*)["']/i,(t,r)=>`style="${r.replace(/fill\s*:\s*[^;]+/gi,`fill: ${e}`)}"`))}const y=n.match(/stroke\s*=\s*["']([^"']*)["']/i),b=n.match(/style\s*=\s*["']([^"']*)["']/i),w=null===(c=null==b?void 0:b[1])||void 0===c?void 0:c.match(/stroke\s*:\s*([^;]+)/i),x=null===(h=null!==(u=null==y?void 0:y[1])&&void 0!==u?u:null===(d=null==w?void 0:w[1])||void 0===d?void 0:d.trim())||void 0===h?void 0:h.trim();if(x&&!/^none$/i.test(x)&&!/^url\(#/i.test(x)){const e=t(x);y?f=f.replace(/stroke\s*=\s*["'][^"']*["']/i,`stroke="${e}"`):(null==b?void 0:b[1])&&(f=f.replace(/style\s*=\s*["']([^"']*)["']/i,(t,r)=>`style="${r.replace(/stroke\s*:\s*[^;]+/gi,`stroke: ${e}`)}"`))}return`<${r}${f}${i}`})}return n&&(r=r.replace(/<linearGradient([^>]*?)>([\s\S]*?)<\/linearGradient>/gi,(e,t,r)=>{let n=0;return`<linearGradient${t}>${r.replace(/<stop([^>]*?)>/gi,(e,t)=>{const r=0===n?"var(--icon-grad-1)":"var(--icon-grad-2)";if(n+=1,/stop-color\s*=/.test(t)){return"<stop"+t.replace(/stop-color="[^"]*"/i,'stop-color="'+r+'"')+">"}return"<stop"+t+' stop-color="'+r+'">'})}</linearGradient>`}),r=r.replace(/<radialGradient([^>]*?)>([\s\S]*?)<\/radialGradient>/gi,(e,t,r)=>{let n=0;return`<radialGradient${t}>${r.replace(/<stop([^>]*?)>/gi,(e,t)=>{const r=0===n?"var(--icon-grad-1)":"var(--icon-grad-2)";if(n+=1,/stop-color\s*=/.test(t)){return"<stop"+t.replace(/stop-color="[^"]*"/i,'stop-color="'+r+'"')+">"}return"<stop"+t+' stop-color="'+r+'">'})}</radialGradient>`})),"number"!=typeof(null==t?void 0:t.strokeWidth)||Number.isNaN(t.strokeWidth)||(/stroke-width\s*=\s*["'][^"']*["']/i.test(r)&&(r=r.replace(/stroke-width\s*=\s*["'][^"']*["']/gi,`stroke-width="${t.strokeWidth}"`)),/stroke-width\s*:/.test(r)&&(r=r.replace(/stroke-width\s*:\s*[^;]+/gi,`stroke-width: ${t.strokeWidth}`)),/stroke-width/i.test(r)||(r=r.replace(/<svg/,`<svg stroke-width="${t.strokeWidth}"`))),r=r.replace(/<svg([^>]*)>/i,(e,t)=>`<svg${t.replace(/\swidth="[^"]*"/i,"").replace(/\sheight="[^"]*"/i,"")} width="100%" height="100%">`),r},[]),d=i.useCallback(async(t,n)=>{const i=[t,e?"css=1":"css=0",(null==n?void 0:n.colors)?`c=${n.colors}`:"",(null==n?void 0:n.backgroundColor)?`bg=${n.backgroundColor}`:"",null!=(null==n?void 0:n.strokeWidth)?`sw=${n.strokeWidth}`:"",null!=(null==n?void 0:n.size)?`s=${n.size}`:"",null!=(null==n?void 0:n.responsive)?`r=${n.responsive}`:"",null!=(null==n?void 0:n.strokeToFill)?`sf=${n.strokeToFill}`:""].filter(Boolean).join("|"),l=hL.get(i);if(l)return l;const c=await(async(e,t)=>{var n,i;const s=new URLSearchParams;(null==t?void 0:t.colors)&&s.set("colors",t.colors),(null==t?void 0:t.backgroundColor)&&s.set("backgroundColor",t.backgroundColor),null!=(null==t?void 0:t.strokeWidth)&&s.set("strokeWidth",String(t.strokeWidth)),s.set("size",String(null!==(n=null==t?void 0:t.size)&&void 0!==n?n:96)),s.set("responsive",String(null===(i=null==t?void 0:t.responsive)||void 0===i||i)),null!=(null==t?void 0:t.strokeToFill)&&s.set("strokeToFill",String(t.strokeToFill));const l=`${fL}/icons/${encodeURIComponent(e)}/download/svg?${s.toString()}`;if(r)return a(l);const c=new URL(`${o}/icons/${encodeURIComponent(e)}/download/svg`,window.location.origin);return s.forEach((e,t)=>c.searchParams.set(t,e)),c.toString().replace(window.location.origin,"")})(t,n),d={Accept:"image/svg+xml"};s&&(d["x-api-key"]=s);const h=await fetch(c,{method:"GET",headers:d,signal:null==n?void 0:n.signal});if(!h.ok){const e=await h.text();throw new Error(`SVG request failed: ${h.status} ${e}`)}let f=await h.text();const p=f;e&&!(null==n?void 0:n.colors)&&(f=u(f,{strokeWidth:null==n?void 0:n.strokeWidth}));const g={text:f,url:`data:image/svg+xml;utf8,${encodeURIComponent(f)}`,original:p};return hL.set(i,g),g},[o,u,e,r,a,s]),h=i.useCallback(async(e,t)=>{const n=await(async(e,t)=>{var n;const i=new URLSearchParams;i.set("size",String(null!==(n=null==t?void 0:t.size)&&void 0!==n?n:96)),(null==t?void 0:t.colors)&&i.set("colors",t.colors),(null==t?void 0:t.backgroundColor)&&i.set("backgroundColor",t.backgroundColor),null!=(null==t?void 0:t.strokeWidth)&&i.set("strokeWidth",String(t.strokeWidth));const s=`${fL}/icons/${encodeURIComponent(e)}/download/png?${i.toString()}`;if(r)return a(s);const l=new URL(`${o}/icons/${encodeURIComponent(e)}/download/png`,window.location.origin);return i.forEach((e,t)=>l.searchParams.set(t,e)),l.toString().replace(window.location.origin,"")})(e,t),i={Accept:"image/png"};s&&(i["x-api-key"]=s);const l=await fetch(n,{method:"GET",headers:i,signal:null==t?void 0:t.signal});if(!l.ok){const e=await l.text();throw new Error(`PNG request failed: ${l.status} ${e}`)}const c=await l.blob();return await new Promise((e,t)=>{const r=new FileReader;r.onload=()=>e(r.result),r.onerror=()=>t(new Error("Failed to read PNG blob")),r.readAsDataURL(c)})},[o,r,a,s]);return{buildUrl:l,performSearch:c,fetchSvgDataUrl:d,fetchPngDataUrl:h,normalizeSvgForCss:u}}const gL=({apiKey:n,customRequest:o,query:a,setQuery:s,inputRef:l})=>{var c,u,d,h,f,p,g,m,v;const{t:y}=Zr(),[b,w]=i.useState(""),x=void 0!==a?a:b,C=void 0!==s?s:w,[_,S]=i.useState(""),[k,E]=i.useState("global"),[I,O]=i.useState(null),[M,R]=i.useState(null),[L,N]=i.useState(null),[z,B]=i.useState(null),[U,V]=i.useState([]),[$,H]=i.useState(0),[W,G]=i.useState(!1),[Y,X]=i.useState(!1),[Z,J]=i.useState(null),[Q,ee]=i.useState({}),[te,re]=i.useState({}),[ne,ie]=i.useState({}),[ae,se]=i.useState("#000000"),[le,ce]=i.useState("#ff007a"),[ue,de]=i.useState("#00C2FF"),[he,fe]=i.useState(1),[pe,ge]=i.useState(50),[me,ve]=i.useState(!0),[ye,be]=i.useState(!0),[we,xe]=i.useState(!1),Ce=Fi(),{options:_e}=Ce,Se=i.useRef(null),Ae=i.useRef(!1),ke=i.useRef(null),Ee=i.useRef(0),Ie=i.useRef(!1),Te=i.useRef(null),Fe=i.useRef(null===(c=null==_e?void 0:_e.config)||void 0===c?void 0:c.handleTranslate),Oe=i.useRef(null===(u=null==_e?void 0:_e.config)||void 0===u?void 0:u.locale);i.useEffect(()=>{var e,t;Fe.current=null===(e=null==_e?void 0:_e.config)||void 0===e?void 0:e.handleTranslate,Oe.current=null===(t=null==_e?void 0:_e.config)||void 0===t?void 0:t.locale},[null===(d=null==_e?void 0:_e.config)||void 0===d?void 0:d.handleTranslate,null===(h=null==_e?void 0:_e.config)||void 0===h?void 0:h.locale]);const Pe=i.useRef(null),Me=i.useRef(null),Re=i.useRef(null),[Le,Ne]=i.useState(new Set),je=null!==(p=null===(f=null==_e?void 0:_e.config)||void 0===f?void 0:f.STREAMLINE_API_KEY)&&void 0!==p?p:"3pAQQzwUNMmcgSr2.f4eb08cd5886d44b1fc6a701a3ba797c",De=null===(g=null==_e?void 0:_e.config)||void 0===g?void 0:g.handleProxyUrl,ze=async e=>De?Promise.resolve(De(e)):e,Be=async e=>Promise.all(e.map(async e=>Object.assign(Object.assign({},e),{imagePreviewUrl:await ze(e.imagePreviewUrl)}))),{performSearch:Ue,fetchSvgDataUrl:Ve,fetchPngDataUrl:$e,normalizeSvgForCss:He}=pL(ye,null===(m=null==_e?void 0:_e.config)||void 0===m?void 0:m.STREAMLINE_BASE_URL,De,je),We=i.useMemo(()=>{if("family"!==k||0===U.length)return null;const e=new Set(U.map(e=>e.hash)),t=Object.keys(ne).some(t=>e.has(t))?ne:te,r=U.map(e=>t[e.hash]).filter(e=>Boolean(e));if(0===r.length)return null;return function(e){const t=[],r=new Set;let n,i=0,o=0,a=!1;for(const s of e){i+=s.fillsCount,o+=s.strokesCount,s.hasGradient&&(a=!0);for(const e of s.colors){const n=iL(e);n&&!r.has(n)&&(r.add(n),t.push(e))}null==n&&null!=s.strokeWidth&&(n=s.strokeWidth)}return{colors:t,fillsCount:i,strokesCount:o,hasGradient:a,strokeWidth:n}}(r.map(e=>dL(e)))},[U,k,ne,te]);i.useMemo(()=>"family"===k&&(!!(null==We?void 0:We.hasGradient)||!!(I||"").toLowerCase().includes("gradient")),[We,I,k]);const Ge=i.useMemo(()=>"family"===k&&U.some(e=>{const t=te[e.hash];return t&&/var\(--icon-color-2\)/i.test(t)}),[U,k,te]),qe=i.useMemo(()=>"family"===k&&U.some(e=>{const t=te[e.hash];return t&&/var\(--icon-color-3\)/i.test(t)}),[U,k,te]),Ye=i.useMemo(()=>!!ye&&(!!We&&(We.hasGradient||We.colors.length>=2&&Ge)),[We,ye,Ge]),Xe=i.useMemo(()=>!!ye&&(!!We&&(We.colors.length>=3&&qe)),[We,ye,qe]);i.useEffect(()=>(Ae.current=!0,()=>{var e,t,r;Ae.current=!1;try{null===(e=Pe.current)||void 0===e||e.abort(),null===(t=Me.current)||void 0===t||t.abort(),null===(r=Re.current)||void 0===r||r.abort()}catch(e){}}),[]);const Ke=i.useRef(x),Ze=i.useCallback(async e=>{var t,r,n,i,o,a,s,l;const c=null!==(r=null===(t=e.override)||void 0===t?void 0:t.query)&&void 0!==r?r:_;if(!c||0===c.trim().length)return;if(Y)return;if(!Ae.current)return;null===(n=Pe.current)||void 0===n||n.abort();const u=new AbortController;Pe.current=u,X(!0);const d=e.initial?0:$,h=e.initial?30:20,f=null!==(o=null===(i=e.override)||void 0===i?void 0:i.mode)&&void 0!==o?o:k,p=null!==(s=null===(a=e.override)||void 0===a?void 0:a.familySlug)&&void 0!==s?s:I,g=c.trim();try{const t=await Ue({mode:f,familySlug:p||null,query:g,offset:d,limit:h,style:L,signal:u.signal});if(!Ae.current)return;if(e.initial)V(await Be(t.results));else{const e=await Be(t.results);V(t=>[...t,...e])}G(Boolean(null===(l=t.pagination)||void 0===l?void 0:l.hasMore)),H(d+h)}catch(e){if("AbortError"===(null==e?void 0:e.name))return;console.error(e),oe.error(y("Request error"))}finally{Ae.current&&X(!1)}},[_,I,De,U,Y,k,$,Ue,L,y]);i.useEffect(()=>{Te.current=Ze},[Ze]),i.useEffect(()=>{if("family"===k){const e=window.setTimeout(()=>{Ie.current=!1},100);return()=>window.clearTimeout(e)}Ie.current=!1},[k]);const Je=i.useCallback(async e=>{var t;if(!e||0===e.trim().length)return;const r=++Ee.current;let n=e.trim();if(Fe.current)try{n=await Fe.current(e,{locale:Oe.current})}catch(t){console.error("IconsTab: translation error",t),n=e}r===Ee.current&&(E("global"),O(null),B(null),V([]),G(!1),H(0),J(null),Ne(new Set),S(n),await(null===(t=Te.current)||void 0===t?void 0:t.call(Te,{initial:!0,override:{query:n}})))},[]),Qe=i.useCallback(async()=>{x&&0!==x.trim().length&&await Je(x)},[x,Je]),et=i.useCallback(()=>{Ee.current+=1,E("global"),O(null),R(null),B(null),N(null),S(""),V([]),G(!1),H(0),J(null),Ne(new Set),se("#000000"),ce("#ff007a"),de("#00C2FF")},[]);i.useEffect(()=>{const e=Ke.current;e&&e.trim().length>=3&&Je(e)},[]),i.useEffect(()=>{const e=x.trim();ke.current&&(window.clearTimeout(ke.current),ke.current=null),e.length<3?et():ke.current=window.setTimeout(()=>{Je(e)},700)},[x,L,et,Je]);const tt=i.useCallback(()=>{Ie.current||W&&!Y&&Ze({initial:!1})},[Ze,W,Y]),rt=i.useCallback(e=>{if("global"===k){if(!e.familySlug||!_)return;return ke.current&&(window.clearTimeout(ke.current),ke.current=null),Ie.current=!0,E("family"),O(e.familySlug),R(e.hash),B(e.categoryName||null),V([]),G(!1),H(0),J(null),Ne(new Set),se("#000000"),ce("#ff007a"),de("#00C2FF"),void Ze({initial:!0,override:{mode:"family",familySlug:e.familySlug,query:_}})}J(e.hash)},[_,Ze,k]),nt=i.useCallback(()=>{const e=_.trim();E("global"),O(null),R(null),B(null),V([]),G(!1),H(0),J(null),Ne(new Set),se("#000000"),ce("#ff007a"),de("#00C2FF"),e&&Ze({initial:!0,override:{mode:"global",familySlug:null,query:e}})},[_,Ze]);i.useEffect(()=>{var e;if("family"!==k||0===U.length)return;const t=new Set(U.map(e=>e.hash));let r=U.map(e=>e.hash).filter(e=>!Q[e]||!te[e]);if(!M||t.has(M)||ne[M]||(r=[M,...r]),0===r.length)return;let n=!1;null===(e=Me.current)||void 0===e||e.abort();const i=new AbortController;return Me.current=i,Promise.all(r.map(e=>Ve(e,{colors:ye?void 0:ae,strokeWidth:he,size:pe,responsive:me,signal:i.signal}).then(t=>({h:e,r:t})).catch(()=>null))).then(e=>{if(n||!Ae.current)return;const t={},r={},i={};e.forEach(e=>{e&&e.h&&e.r&&(t[e.h]=e.r.url,r[e.h]=e.r.text,e.r.original&&(i[e.h]=e.r.original))}),Object.keys(t).length>0&&ee(e=>Object.assign(Object.assign({},e),t)),Object.keys(r).length>0&&re(e=>Object.assign(Object.assign({},e),r)),Object.keys(i).length>0&&ie(e=>Object.assign(Object.assign({},e),i))}),()=>{n=!0,i.abort()}},[ae,M,Ve,U,k,ne,me,pe,he,te,Q,ye]),i.useEffect(()=>{if("family"!==k)return;if(0===U.length)return;const e=U.map(e=>e.hash),t={},r={};let n=!1;e.forEach(e=>{const i=ne[e]||te[e];if(!i)return;const o=He(i,{strokeWidth:"number"==typeof he?he:void 0});o&&o!==te[e]&&(t[e]=o,r[e]=`data:image/svg+xml;utf8,${encodeURIComponent(o)}`,n=!0)}),n&&(Object.keys(t).length>0&&re(e=>Object.assign(Object.assign({},e),t)),Object.keys(r).length>0&&ee(e=>Object.assign(Object.assign({},e),r)))},[U,k,He,ne,he,te]);const it=i.useRef(null);i.useEffect(()=>{var e;if("family"!==k||0===U.length)return;const t=M&&ne[M]?M:null===(e=U[0])||void 0===e?void 0:e.hash;if(!t||!ne[t])return;if(it.current===I)return;const r=ne[t];if(!r)return;it.current=I;const n=function(e){var t,r,n,i,o,a,s,l;const c=[],u=new Set,d=e=>{const t=iL(e);t&&!u.has(t)&&(u.add(t),c.push(e))},h=Array.from(e.matchAll(/<stop[^>]*?stop-color\s*=\s*["']([^"']+)["']/gi)).map(e=>e[1]);if(h.length>=2)return h.slice(0,3).forEach(e=>d(e)),c;const f=e.match(/<svg([^>]*)>/i);if(null==f?void 0:f[1]){const e=f[1],t=e.match(/fill\s*=\s*["']([^"']*)["']/i),r=e.match(/stroke\s*=\s*["']([^"']*)["']/i);!(null==t?void 0:t[1])||/^none$/i.test(t[1])||/^url\(#/i.test(t[1])||d(t[1]),!(null==r?void 0:r[1])||/^none$/i.test(r[1])||/^url\(#/i.test(r[1])||d(r[1])}const p=new RegExp(`<(?:${nL})([^>]*)>`,"gi");let g;for(;null!==(g=p.exec(e));){const e=g[1],c=e.match(/fill\s*=\s*["']([^"']*)["']/i),u=e.match(/style\s*=\s*["']([^"']*)["']/i),h=null===(t=null==u?void 0:u[1])||void 0===t?void 0:t.match(/fill\s*:\s*([^;]+)/i),f=null===(i=null!==(r=null==c?void 0:c[1])&&void 0!==r?r:null===(n=null==h?void 0:h[1])||void 0===n?void 0:n.trim())||void 0===i?void 0:i.trim();!f||/^none$/i.test(f)||/^url\(#/i.test(f)||d(f);const p=e.match(/stroke\s*=\s*["']([^"']*)["']/i),m=e.match(/style\s*=\s*["']([^"']*)["']/i),v=null===(o=null==m?void 0:m[1])||void 0===o?void 0:o.match(/stroke\s*:\s*([^;]+)/i),y=null===(l=null!==(a=null==p?void 0:p[1])&&void 0!==a?a:null===(s=null==v?void 0:v[1])||void 0===s?void 0:s.trim())||void 0===l?void 0:l.trim();!y||/^none$/i.test(y)||/^url\(#/i.test(y)||d(y)}return c.slice(0,3)}(r),i=e=>{const t=(e||"").trim().match(/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/);if(t){return"#"+(3===t[1].length?t[1].replace(/(.)/g,"$1$1"):t[1]).toLowerCase()}return function(e){var t;const r=e.trim();if(/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/.test(r)){const e=r.match(/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})/);if(e)return"#"+(3===e[1].length?e[1].replace(/(.)/g,"$1$1"):e[1]).toLowerCase()}const n=r.match(/^rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/);if(n)return"#"+[1,2,3].map(e=>parseInt(n[e],10).toString(16).padStart(2,"0")).join("");const i=r.match(/^rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*[\d.]+\s*\)/);return i?"#"+[1,2,3].map(e=>parseInt(i[e],10).toString(16).padStart(2,"0")).join(""):null!==(t={black:"#000000",white:"#ffffff",red:"#ff0000",green:"#008000",blue:"#0000ff"}[r.toLowerCase()])&&void 0!==t?t:iL(r)||"#000000"}(e)};n[0]&&se(i(n[0])),n[1]&&ce(i(n[1])),n[2]&&de(i(n[2]))},[U,k,ne,I,M]),i.useEffect(()=>{"family"!==k&&(it.current=null)},[k]);const ot=i.useRef(null);i.useEffect(()=>{if("family"!==k||!I||0===U.length)return;const e=U[0];if(!e||!ne[e.hash])return;if(ot.current===I)return;const t=ne[e.hash];if(!t)return;const r=dL(t);"number"==typeof r.strokeWidth&&r.strokeWidth>0&&(ot.current=I,fe(r.strokeWidth))},[U,k,ne,I]),i.useEffect(()=>{"family"!==k&&(ot.current=null)},[k]);const at=i.useCallback(e=>function(e,t){const{colorHex:r,colorHex2:n,colorHex3:i}=t,o=[`--icon-grad-1: ${r}`,`--icon-grad-2: ${n}`,`--icon-stroke-1: ${r}`,`--icon-stroke-2: ${n}`,`--icon-stroke-3: ${i}`,`--icon-fill-1: ${r}`,`--icon-fill-2: ${n}`,`--icon-fill-3: ${i}`,`color: ${r}`].join(";");let a=e.replace(/<svg([^>]*)>/i,(e,t)=>{let r=t;return/style="/i.test(r)?r=r.replace(/style="([^"]*)"/i,(e,t)=>`style="${t};${o}"`):r+=` style="${o}"`,`<svg${r}>`});return a=a.replace(/var\(--icon-color-1\)/g,r).replace(/var\(--icon-color-2\)/g,n).replace(/var\(--icon-color-3\)/g,i).replace(/var\(--icon-fill-1\)/g,r).replace(/var\(--icon-fill-2\)/g,n).replace(/var\(--icon-fill-3\)/g,i).replace(/var\(--icon-stroke-1\)/g,r).replace(/var\(--icon-stroke-2\)/g,n).replace(/var\(--icon-stroke-3\)/g,i).replace(/var\(--icon-grad-1\)/g,r).replace(/var\(--icon-grad-2\)/g,n).replace(/currentColor/g,r),a}(e,{colorHex:ae,colorHex2:le,colorHex3:ue}),[ae,le,ue]),st=i.useCallback(e=>{Ne(t=>{const r=new Set(t);return r.has(e)?r.delete(e):r.add(e),r})},[]),lt=i.useCallback(()=>{Ne(new Set)},[]),ct=i.useMemo(()=>{if(1===Le.size){const[e]=Array.from(Le);return U.find(t=>t.hash===e)||null}return 0===Le.size&&Z&&U.find(e=>e.hash===Z)||null},[U,Z,Le]),ut=i.useCallback((e,t="image/png")=>{try{const r=e.split(",");if(r.length<2)return new Blob([],{type:t});const n=r[1]||"",i=atob(n),o=new Array(i.length);for(let e=0;e<i.length;e+=1)o[e]=i.charCodeAt(e);const a=new Uint8Array(o);return new Blob([a],{type:t})}catch(e){return new Blob([],{type:t})}},[]),dt=i.useCallback(async(e,t)=>{try{const r=async e=>{const t="family"===k?at(e):e,r=function(e,t){const r=e.match(/\swidth="([0-9.]+)(px)?"/i),n=e.match(/\sheight="([0-9.]+)(px)?"/i);if(r&&n){const e=parseFloat(r[1]),i=parseFloat(n[1]);if(Number.isFinite(e)&&Number.isFinite(i)&&e>0&&i>0){const r=e/i;return r>=1?{width:t,height:Math.max(1,Math.round(t/r))}:{width:Math.max(1,Math.round(t*r)),height:t}}}const i=e.match(/viewBox="([^"]+)"/i);if(i){const e=i[1].trim().split(/\s+/);if(4===e.length){const r=parseFloat(e[2]),n=parseFloat(e[3]);if(Number.isFinite(r)&&Number.isFinite(n)&&r>0&&n>0){const e=r/n;return e>=1?{width:t,height:Math.max(1,Math.round(t/e))}:{width:Math.max(1,Math.round(t*e)),height:t}}}}return{width:t,height:t}}(t,pe);return async function(e,t,r){const n=new Blob([e],{type:"image/svg+xml;charset=utf-8"}),i=URL.createObjectURL(n);try{const e=new Image;return await new Promise((n,o)=>{e.onload=()=>{const i=document.createElement("canvas"),a=Math.max(1,Math.round(2*t)),s=Math.max(1,Math.round(2*r));i.width=a,i.height=s;const l=i.getContext("2d");l?(l.clearRect(0,0,a,s),l.drawImage(e,0,0,a,s),n(i.toDataURL("image/png"))):o(new Error("Canvas 2D context is not available"))},e.onerror=()=>o(new Error("Failed to load SVG image")),e.src=i})}finally{URL.revokeObjectURL(i)}}(t,r.width,r.height)},n=async e=>{const n=await Ve(e,{colors:ye?void 0:ae,strokeWidth:"number"==typeof he?he:void 0,size:pe,responsive:me,signal:t}),i=n.original||n.text;return r(i)};if("family"!==k)try{return await $e(e.hash,{size:pe,colors:ye?void 0:ae,strokeWidth:"number"==typeof he?he:void 0,signal:t})}catch(t){return e.hash?await n(e.hash):null}const i=te[e.hash]||ne[e.hash];return i?r(i):e.hash?await n(e.hash):null}catch(e){return null}},[at,ae,Ve,$e,k,ne,me,pe,he,te,ye]),ht=i.useCallback(async e=>{var t;try{if(!Ae.current)return;xe(!0),null===(t=Re.current)||void 0===t||t.abort();const r=new AbortController;Re.current=r;const n=await dt(e,r.signal);if(!Ae.current||!n)return;await Promise.resolve(o(n))}catch(e){console.error("IconsTab: insert error",e),oe.error(y("Request error"))}finally{Ae.current&&xe(!1)}},[o,dt,y]);i.useCallback(()=>{var e;J(null),lt();const t=null===(e=null==_e?void 0:_e.config)||void 0===e?void 0:e.onClose;"function"==typeof t&&t()},[lt,_e]);const{isCopyIconsModalVisible:ft,isCopyLoading:pt,copyForm:gt,openCopyModal:mt,closeCopyModal:vt,resetAfterClose:yt,handleCopyTreeSelect:bt,handleIconsCopyOk:wt,fetchChildFolders:xt,generateMenuItemsFromFolders:Ct,handleCreateFolderAndCopy:_t}=(({items:e,selectedHashes:t,getPngDataUrlForItem:r,dataUrlToBlob:n,clearSelection:o})=>{const{t:a}=Zr(),{options:s,state:l}=Fi(),c=Li(),[u,d]=i.useState(!1),[h]=T.useForm(),[f,p]=i.useState(!1),g=i.useRef(!1),{state:m,actions:{fetchFolders:v,fetchChildFolders:y,handleModalOk:b}}=io(),{EmptyFolderIcon:w}=Va(),{activeFormField:x,setActiveFormField:C,generateMenuItemsFromFolders:_}=hs({folders:Array.isArray(m.folders)?m.folders:[],selectedFolder:l.selectedFolder,EmptyFolderIcon:w,handleCreateFolderModalOk:b,setIsLoading:p,t:a}),S=i.useCallback(async()=>{await v(),d(!0)},[v]),A=i.useCallback(async e=>{e.length>0&&(h.setFieldsValue({targetFolder:e[0]}),x!==e[0].toString()&&C(""))},[x,h,C]),k=i.useCallback(async i=>{var u,d;try{const{dataProviders:d}=s;if(!d||!d.uploadFile&&!d.uploadFiles)return void c.error({id:"FILES_UPLOAD_PROVIDER_NOT_CONFIGURED",message:a("API-endpoint for file upload is not configured"),placement:"bottomRight"});const h=i||(null==l?void 0:l.selectedFolder)||void 0,f=Array.from(t);if(0===f.length)return;const p=null!==(u=d.uploadFile)&&void 0!==u?u:async e=>{var t,r,n;if(!d.uploadFiles)throw new Error("Upload is not supported by data provider");const i=await d.uploadFiles({folderId:e.folderId,items:[{name:e.name,size:e.size,type:e.type,folderId:e.folderId,data:e.data,extension:e.extension}]}),o=null===(t=null==i?void 0:i.detailed)||void 0===t?void 0:t[0];if(!i||!i.success||!o||!1===o.success){const e=(null===(r=null==o?void 0:o.error)||void 0===r?void 0:r.message)||(null===(n=null==i?void 0:i.error)||void 0===n?void 0:n.message)||"Upload failed";throw new Error(e)}return o.data},{successCount:g,failCount:m}=await async function(e){var t;const{hashes:r,items:n,folderId:i,dataProviders:o,getPngDataUrlForItem:a,dataUrlToBlob:s}=e;let l=0,c=0;for(const e of r){const r=n.find(t=>t.hash===e);if(!r){c+=1;continue}const u=await a(r);if(!u){c+=1;continue}const d=`${(null===(t=r.name)||void 0===t?void 0:t.trim())||`icon-${e}`}.png`,h=s(u,"image/png");try{await o.uploadFile({name:d,size:h.size,type:"image/png",folderId:i,data:h,extension:"png"}),l+=1}catch(e){c+=1}}return{successCount:l,failCount:c}}({hashes:f,items:e,folderId:h,dataProviders:{uploadFile:p},getPngDataUrlForItem:r,dataUrlToBlob:n});g>0&&c.success({id:"FILES_COPY_SUCCESS",message:a("Files copied"),placement:"bottomRight",data:{successCount:g,totalCount:f.length,itemIds:f,folderId:null!=h?h:null}}),m>0&&c.error({id:"FILES_COPY_ERROR",message:a("При копировании произошли ошибки"),placement:"bottomRight",data:{failCount:m,totalCount:f.length,itemIds:f,folderId:null!=h?h:null}}),o()}catch(e){console.error(e),c.error({id:"FILES_COPY_ERROR",message:a("При копировании произошли ошибки"),placement:"bottomRight",innerException:e,data:{failCount:Array.from(t).length||0,totalCount:Array.from(t).length||0,itemIds:Array.from(t),folderId:null!==(d=null==l?void 0:l.selectedFolder)&&void 0!==d?d:null}})}},[o,n,r,e,c,s,t,null==l?void 0:l.selectedFolder,a]),E=i.useCallback(()=>{f||g.current||(d(!1),C(""),p(!1))},[f,C]),I=i.useCallback(()=>{C(""),p(!1)},[C]),F=i.useCallback(async e=>{if(!g.current){g.current=!0,p(!0);try{await k(null!=e?e:null),d(!1),C("")}finally{g.current=!1,p(!1)}}},[k,C]),O=i.useCallback(()=>{var e;const t=null!==(e=l.selectedFolder)&&void 0!==e?e:"folders";C(t),h.setFieldsValue({folderName:a("New folder"),targetFolder:t})},[h,l.selectedFolder,C,a]);return{isCopyIconsModalVisible:u,isCopyLoading:f,copyForm:h,openCopyModal:S,closeCopyModal:E,resetAfterClose:I,handleCopyTreeSelect:A,handleIconsCopyOk:F,handleCreateFolderAndCopy:O,fetchChildFolders:y,generateMenuItemsFromFolders:_}})({items:U,selectedHashes:Le,getPngDataUrlForItem:dt,dataUrlToBlob:ut,clearSelection:lt});return t(r,{children:[t("div",{className:`${ZR.iconsTab} ${_.trim()?ZR.hasSearch:""}`,children:[_.trim()&&(U.length>0||Y)&&Le.size>0?e(r,{children:t("div",{className:ZR.iconsHeaderContainer,children:[t("div",{className:ZR.iconsHeaderContainerLeft,children:[t(P.Text,{type:"secondary",children:[Le.size," ",y("selected")]}),e(j,{icon:e(yi,{size:16}),onClick:lt,children:y("Deselected")})]}),e(D,{children:e(j,{icon:e(ii,{size:16}),onClick:mt,children:y("Copy to folder")})})]})}):e(QR,{query:x,onQueryChange:C,onSubmit:Qe,styleFilter:L,onStyleChange:N,hasResults:U.length>0||Y,inputRef:l}),"family"===k?e(eL,{mode:k,familySlug:I,categoryName:z,colorHex:ae,setColorHex:se,colorHex2:le,setColorHex2:ce,colorHex3:ue,setColorHex3:de,sizePx:pe,setSizePx:ge,strokeWidth:he,setStrokeWidth:fe,responsiveSvg:me,setResponsiveSvg:ve,useCssColor:ye,setUseCssColor:be,showSecondColor:Ye,showThirdColor:Xe,styleFilter:L,onBack:nt}):null,e(rL,{items:U,hasMore:W,loading:Y,hasQuery:Boolean(_.trim()),mode:k,selectedHash:Z,onLoadMore:tt,onItemClick:rt,onInsert:ht,scrollContainerRef:Se,colorVars:{colorHex:ae,colorHex2:le,colorHex3:ue},svgTextMap:te,previewSize:pe,selectedHashes:Le,onToggleSelect:st}),ct?t("div",{className:ZR.iconsBottomBar,children:[e(K,{className:"zero-divider"}),e("div",{className:ZR.iconsBottomBarContent,children:e(D,{children:e(j,{size:"large",type:"primary",style:{height:40},loading:we,onClick:()=>ht(ct),children:y("Choose")})})})]}):null]}),e(q,{title:e("div",{className:"modal-title",children:y("Copy to folder")}),open:ft,onCancel:()=>{pt||vt()},maskClosable:!pt,closable:!pt,keyboard:!pt,footer:t("div",{className:us.formFooter,children:[t(j,{className:us.folderButton,onClick:_t,loading:pt,children:[e(ci,{size:18,strokeWidth:null===(v=_e.config)||void 0===v?void 0:v.iconStrokeWidth}),y("Create folder")]}),e(j,{type:"primary",className:us.folderButton,onClick:()=>{vt()},loading:pt,children:y("Done")})]}),afterClose:()=>yt(),children:t("div",{className:ZR.copyToFolderModalBody,children:[pt?e("div",{className:ZR.copyToFolderModalLoadingOverlay,children:e(A,{size:"large"})}):null,e(T,{form:gt,layout:"vertical",initialValues:{targetFolder:"folders",folderName:y("New folder"),is_force_create:!1},children:t("div",{className:us.foldersWrapper,children:[e(T.Item,{name:"targetFolder",rules:[{required:!0,message:y("Select the destination folder")}],className:us.formItem,children:e(ls,{onSelect:bt,generateMenuItems:()=>Ct({targetForm:gt,onTreeSelect:bt,onComplete:wt,actionButtonText:y("Copy here")}),fetchChildFolders:xt,disabledFolders:[],mode:"selection",className:"folderSelectionTree",defaultExpandAll:!0})}),e(T.Item,{name:"folderName",style:{display:"none"},rules:[{required:!0,validator:(e,t)=>"string"==typeof t&&0===t.trim().length?Promise.reject(new Error(y("Enter the name of the folder"))):Promise.resolve()}],children:e(F,{})}),e(T.Item,{name:"is_force_create",style:{display:"none"},children:e(F,{})})]})})]})})]})},mL=e=>{(null==e?void 0:e.customTheme)&&((e={})=>{const t=document.querySelector("head");if(!t)return;const r=document.createElement("style");if(r.type="text/css",r.dataset.themeVariablesFm="true",r.setAttribute("data-file-manager","true"),Object.entries(e).length){let n="";Object.entries(e).forEach(([e,t])=>{"object"!=typeof t&&(n+=`\t--${e}: ${t};\n`)}),n=`.em-filemanager {\n${n}}`,r.appendChild(document.createTextNode(n));const i=t.querySelector('[data-theme-variables-fm="true"]');i?t.replaceChild(r,i):t.insertBefore(r,t.firstChild)}})(null==e?void 0:e.customTheme)},{Sider:vL,Content:yL}=Q,bL={keywords:""},wL=()=>{var s,l,d;const h=io(),f=oa(),p=ta(),g=(()=>{const{state:e,actions:t}=Fi(),{pagination:r}=e,{setPagination:n}=t,i=c((e,t)=>{const i=t||r.pageSize;null==n||n({current:e,pageSize:i,total:r.total})},[r.pageSize,r.total,n]);return{state:{pagination:r},actions:{handlePaginationChange:i}}})(),m=(()=>{const[e,t]=n.useState(()=>{const e=localStorage.getItem(aa);return e?Math.max(290,parseInt(e,10)):298}),[r,i]=n.useState(!1),[o,a]=n.useState(!1),[s,l]=n.useState(0),c=n.useCallback(()=>{t(298),localStorage.setItem(aa,298..toString())},[]),u=n.useCallback(r=>{r.preventDefault(),r.stopPropagation(),i(!0),document.body.classList.add("resizing");const n=r.clientX,o=e;let s=o;const c=e=>{e.preventDefault();const r=Math.max(Math.min(o+e.clientX-n,600),290);s=r,t(r),l(e.clientX),a(!0)},u=()=>{i(!1),document.body.classList.remove("resizing"),a(!1),localStorage.setItem(aa,s.toString()),document.removeEventListener("mousemove",c),document.removeEventListener("mouseup",u)};document.addEventListener("mousemove",c),document.addEventListener("mouseup",u)},[e]);return n.useEffect(()=>()=>{document.body.classList.remove("resizing")},[]),{sidebarWidth:e,isResizing:r,showResizeGuide:o,resizeGuidePosition:s,handleResizeStart:u,handleDoubleClick:c}})(),v=(()=>{const[e,t]=o([]),[r,n]=o(!1),[i,a]=o(!1),s=u(0),l=u(new Map),d=c(()=>(s.current+=1,`upload_${s.current}_${Date.now()}`),[]),h=c(e=>Di(e.size),[]),f=c((e,r)=>{const i=r.map(t=>({id:d(),folderId:e,name:t.name,size:h(t),status:"uploading",progress:0}));return t(i),n(!0),a(!1),i.map(e=>e.id)},[d,h]),p=c((e,r)=>{const i={id:d(),folderId:e,name:r,size:void 0,status:"uploading",progress:0};return t(e=>[...e,i]),n(!0),a(!1),i.id},[d]),g=c((e,r)=>{t(t=>t.map(t=>t.id===e?Object.assign(Object.assign({},t),{progress:Math.min(100,Math.max(0,r))}):t))},[]),m=c((e,r)=>{r&&l.current.set(e,r),t(t=>t.map(t=>{if(t.id===e){const e=Object.assign(Object.assign({},t),{status:"success",progress:100});return(null==r?void 0:r.size)&&void 0===t.size&&(e.size=Di(r.size)),e}return t}))},[]),v=c((e,r)=>{t(t=>t.map(t=>t.id===e?Object.assign(Object.assign({},t),{status:"error",error:r}):t))},[]),y=c(()=>{n(!1),a(!1),setTimeout(()=>{t([]),l.current.clear()},300)},[]),b=c(()=>{a(e=>!e)},[]),w=c(e=>l.current.get(e),[]),x=e.length,C=e.filter(e=>"success"===e.status||"error"===e.status).length;return{uploadFiles:e,isUploadVisible:r,isUploadMinimized:i,totalFiles:x,completedFiles:C,startUpload:f,startUploadByUrl:p,updateProgress:g,markAsSuccess:m,markAsError:v,getUploadedFile:w,closeUpload:y,minimizeUpload:b}})(),y=Xo(),{deleteItems:b}=oo(),w=Li(),{t:x}=Zr(),{options:C,state:_}=Fi(),S=null==C?void 0:C.config,{dataProviders:k}=C,{DropZoneFileIcon:E}=Va(),[I,T]=o(!1),[F,O]=o(!1),[P,M]=o(!1),R=u(0),L=u(!1);L.current=F;const N=i.useRef(null),D=i.useRef([]),[z,B]=o(!1),[U,V]=o(!1),{folders:$,loading:H}=h.state,{fetchFolders:W,fetchChildFolders:G,handleCreateFolder:q,handleModalOk:Y,handleModalCancel:X,generateMenuItems:Z}=h.actions,J=(e=>{var t;const{state:r,actions:n,options:i}=Fi(),{t:o}=Zr(),a=Li(),{folders:s,folderToRename:l,renameFolderForm:u,isRenameFolderModalVisible:d}=r,{setFolderToRename:h,setIsRenameFolderModalVisible:f}=n,{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,r;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(o("renameFolder is not implemented in 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,error:{message:"invalidResponse"}}});a.success({id:"FOLDER_RENAME_SUCCESS",message:o("Folder renamed"),placement:"bottomRight",data:{itemId:s.id,itemName:s.name,folderId:null!==(r=s.parentId)&&void 0!==r?r:null}}),y(),await e(),l!==s.id&&n.setSelectedFolder&&n.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"),error:{message: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}}})(W),{files:ee,selectedFiles:te,loading:re,isRenamingFile:ne,fileToRename:ie}=f.state,{fetchFiles:oe,handleDeleteFile:ae,handleDeleteFolder:se,handleAddFile:le,handleAddFileByUrl:ce,toggleFileSelection:ue,showRenameModal:de,handleRenameCancel:he,handleRenameOk:fe,handleDroppedFiles:pe,showMoveModal:ge,handleMoveCancel:me,handleMoveOk:ve,handleCopyOk:ye,handleCopyCancel:be,showDeleteConfirm:we,handleDeleteConfirmCancel:xe,handleDeleteConfirmOk:Ce}=f.actions,{selectedFolder:_e,pathHistory:Se}=p.state,{handleFolderSelect:Ae,handleBreadcrumbClick:ke,handleItemClick:Ee}=p.actions,{pagination:Ie}=g.state,Te=Ri(oe),{searchTerm:Oe,sortBy:Pe,sortOrder:Me}=Te.state,{handleSearch:Re,handleSort:Le,handlePaginationChange:Ne}=Te.actions,je=c(async()=>{const e=(e=>Xi(e))(Se||[]);try{await Zi({options:C,pathFolder:e,dataProviders:null==C?void 0:C.dataProviders})}catch(e){console.error("Cache clear failed:",e)}await W(),await oe({folderId:_e||"",page:Ie.current,limit:Ie.pageSize,search:Oe,sortBy:Pe,sortOrder:Me,itemType:"all"})},[oe,W,C,Ie.current,Ie.pageSize,Se,Oe,_e,Pe,Me]),De=(({files:e,selectedFiles:t,fetchFiles:r,selectedFolder:i})=>{const{t:o}=Zr(),a=Li(),{options:s,actions:l,state:c}=n.useContext(Ti),{setActiveLibraryItem:u}=l,{activeLibraryItem:d}=c,h=Xo(),[f,p]=n.useState(!1),[g,m]=n.useState(null),v=n.useCallback(e=>{var t;if(e.type&&e.type.startsWith("image/"))return!0;if(e.extension){const t=e.extension.toLowerCase();return mr.includes(t)}const r=null===(t=e.name.split(".").pop())||void 0===t?void 0:t.toLowerCase();return!!r&&mr.includes(r)},[]),y=n.useCallback(async e=>{var t,r,n,i;const{dataProviders:o}=s;if(!1!==(null===(r=null===(t=s.config)||void 0===t?void 0:t.features)||void 0===r?void 0:r.enableUpdateFile)&&(null==o?void 0:o.updateFile)&&e.thumbnail)try{const t=Tr(e.thumbnail,e.type),r=Fr(t),n=e.name.substring(0,e.name.lastIndexOf("."))+"."+r,i=Rr(e.thumbnail,t);return await o.updateFile(e.id,{name:n,type:t,data:i})}catch(e){return console.error("Error updating the file through updateFile:",e),null}else if(e.thumbnail)try{const t=Tr(e.thumbnail,e.type),r=Rr(e.thumbnail,t),n=new File([r],e.name,{type:t,lastModified:Date.now()});return await h.uploadFileWithProvider(n,e.folderId||void 0)||null}catch(e){return console.error("Error saving the file:",e),null}else if(!1!==(null===(i=null===(n=s.config)||void 0===n?void 0:n.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("Error renaming the file:",e),null}return console.warn("DataProvider for updating files is not configured"),null},[s,h]),b=n.useCallback(r=>{let n;if(r)n=r;else{if(1!==t.size)return;const r=Array.from(t)[0];if(n=e.find(e=>e.id===r),!n||n.isFolder||!v(n))return}u&&u(lr),m(n),p(!0)},[t,e,v,p,u]),w=n.useCallback(()=>{u&&d===lr&&u(nr),p(!1),m(null)},[d,u]),x=n.useCallback(async e=>{var t,n,l,c;try{const l=await y(e);if(l)return a.success({id:"IMAGE_UPDATE_SUCCESS",message:o("Success"),description:o("Image updated successfully"),placement:"bottomRight",data:{itemId:null!==(t=l.id)&&void 0!==t?t:void 0,itemName:l.name,folderId:null!==(n=l.folderId)&&void 0!==n?n:null,thumbnail:l.thumbnail}}),s.onEditorOk&&s.onEditorOk(l),await r({folderId:i||""}),w(),l}catch(t){console.error("Error saving the file:",t),a.error({id:"IMAGE_SAVE_FAILED",message:o("Error"),description:o("Failed to save changes",{error:t}),innerException:t,placement:"bottomRight",data:{itemId:null!==(l=e.id)&&void 0!==l?l:void 0,itemName:e.name,folderId:null!==(c=e.folderId)&&void 0!==c?c:null,thumbnail:e.thumbnail}})}},[y,s,r,i,a,w]);return{isPixieEditorVisible:f,editingFile:g,handleEdit:b,handlePixieEditorSave:x,handlePixieEditorClose:w}})({files:ee||[],selectedFiles:te||new Set,fetchFiles:oe,selectedFolder:_e||null}),[ze,Be]=o(!1),Ue=c(e=>{if(e.preventDefault(),e.stopPropagation(),!e.dataTransfer||!e.dataTransfer.types||!e.dataTransfer.types.includes("Files"))return;e.dataTransfer.dropEffect="copy";const t=e.relatedTarget,r=e.currentTarget;t&&r.contains(t)||(R.current+=1,R.current>0&&T(!0))},[]),Ve=c(e=>{e.preventDefault(),e.stopPropagation();const t=e.relatedTarget,r=e.currentTarget;if(t&&!r.contains(t))R.current=Math.max(0,R.current-1),R.current<=0&&T(!1);else if(t){const e=t.closest('[class*="dragOverlay"]');if(e&&r.contains(e))return}},[]),$e=c(e=>{e.preventDefault(),e.stopPropagation(),e.dataTransfer&&(e.dataTransfer.dropEffect="copy")},[]),He=c(e=>{e.preventDefault(),e.stopPropagation(),T(!1),R.current=0;const t=(()=>{var t;const r=e.dataTransfer;if(!r)return[];if(null===(t=r.files)||void 0===t?void 0:t.length)return Array.from(r.files);const n=[];if(r.items)for(let e=0;e<r.items.length;e++){const t=r.items[e].getAsFile();t&&n.push(t)}return n})();t.length&&(Be(!0),pe(t).catch(e=>{"StaleLoad"!==(null==e?void 0:e.name)&&console.error("Ошибка при загрузке файлов:",e)}).finally(()=>{Be(!1)}))},[pe]),We=c(()=>{T(!1),R.current=0,document.body.removeAttribute("data-fm-dragging"),M(!1),O(!1)},[]);i.useEffect(()=>{D.current=ee||[]},[ee]);const Ge=null==_?void 0:_.activeLibraryItem;a(()=>{const e=e=>{e?document.body.setAttribute("data-fm-dragging","true"):document.body.removeAttribute("data-fm-dragging")};let t=0;const r=r=>{var n,i;t++,1===t&&(M(!0),e(!0)),(null===(i=null===(n=r.dataTransfer)||void 0===n?void 0:n.types)||void 0===i?void 0:i.includes("Files"))&&Ge===nr&&O(!0)},n=r=>{t--,t<=0&&(t=0,M(!1),O(!1),e(!1))};return window.addEventListener("dragenter",r,!0),window.addEventListener("dragleave",n,!0),()=>{window.removeEventListener("dragenter",r,!0),window.removeEventListener("dragleave",n,!0),document.body.removeAttribute("data-fm-dragging")}},[Ge]),a(()=>{const e=e=>{var t,r;if(document.body.removeAttribute("data-fm-dragging"),M(!1),!(null===(r=null===(t=e.dataTransfer)||void 0===t?void 0:t.types)||void 0===r?void 0:r.includes("Files")))return;e.preventDefault();const n=(e=>{var t;if(!e)return[];if(null===(t=e.files)||void 0===t?void 0:t.length)return Array.from(e.files);const r=[];if(e.items)for(let t=0;t<e.items.length;t++){const n=e.items[t].getAsFile();n&&r.push(n)}return r})(e.dataTransfer);if(!n.length)return;const i=e.target,o=i.closest(`.${Xa.filesContainer.replace(/\s+/g,".")}`)||i.closest("[data-files-container]"),a=i.closest(".em-filemanager")||i.closest(".file-manager__layout")||i.closest("[data-drop-overlay]")||i.closest("[data-drag-capture]");(L.current||I||o||a)&&(e.preventDefault(),e.stopPropagation(),O(!1),T(!1),R.current=0,Be(!0),pe(n).catch(e=>{"StaleLoad"!==(null==e?void 0:e.name)&&console.error("Ошибка при загрузке файлов:",e)}).finally(()=>Be(!1)))},t=e=>{var t,r;(null===(r=null===(t=e.dataTransfer)||void 0===t?void 0:t.types)||void 0===r?void 0:r.includes("Files"))&&(e.preventDefault(),e.dataTransfer.dropEffect="copy",document.body.hasAttribute("data-fm-dragging")||document.body.setAttribute("data-fm-dragging","true"),Ge!==nr||L.current||O(!0))},r=e=>{var t,r;(null===(r=null===(t=e.dataTransfer)||void 0===t?void 0:t.types)||void 0===r?void 0:r.includes("Files"))&&(e.preventDefault(),e.dataTransfer.dropEffect="copy",document.body.setAttribute("data-fm-dragging","true"))},n={capture:!0,passive:!1};return window.addEventListener("drop",e,n),window.addEventListener("dragover",t,n),window.addEventListener("dragenter",r,n),()=>{window.removeEventListener("drop",e,n),window.removeEventListener("dragover",t,n),window.removeEventListener("dragenter",r,n)}},[I,pe,Ge]),a(()=>{const e=e=>{I&&We(),O(!1),M(!1),document.body.removeAttribute("data-fm-dragging")};return window.addEventListener("dragend",e,!0),()=>window.removeEventListener("dragend",e,!0)},[I,We]),a(()=>{let e=null;const t=t=>{I&&(e=setTimeout(()=>{I&&We()},200))};return document.addEventListener("mouseup",t,!0),()=>{document.removeEventListener("mouseup",t,!0),e&&clearTimeout(e)}},[I,We]),a(()=>{const e=e=>{"Escape"===e.key&&I&&We()};return document.addEventListener("keydown",e),()=>{document.removeEventListener("keydown",e)}},[I,We]),a(()=>{const e=e=>{I&&setTimeout(()=>{I&&We()},100)};return document.addEventListener("click",e,!0),()=>{document.removeEventListener("click",e,!0)}},[I,We]);const qe=i.useCallback(async()=>{await Ce(),await W(),_e===cr&&G&&await G(cr),requestAnimationFrame(()=>{requestAnimationFrame(()=>{var e,t;return null===(t=null===(e=N.current)||void 0===e?void 0:e.refreshFileCounts)||void 0===t?void 0:t.call(e)})})},[W,G,Ce,_e]),Ye=i.useCallback(()=>{V(!0)},[]),Xe=i.useCallback(async()=>{var e,t;if(_e!==cr)return console.error("Clear trash called outside of trash folder"),void V(!1);try{if(null==k?void 0:k.cleanTrash){const t=await k.cleanTrash();await oe({folderId:cr}),await(null===(e=N.current)||void 0===e?void 0:e.refreshFileCounts()),t.success?w.success({id:"TRASH_CLEARED_SUCCESS",message:x("Trash cleared successfully"),description:x("{{count}} items permanently deleted",{count:t.deletedCount||0}),placement:"bottomRight"}):w.error({id:"TRASH_CLEAR_FAILED",message:x("Failed to clear trash"),placement:"bottomRight"})}else{const e=D.current||[];if(0===e.length)return void V(!1);const r=e.map(e=>({id:e.id,isFolder:e.isFolder})),n=await b({items:r,selectedFolder:cr,getItemNameById:t=>{var r;return(null===(r=e.find(e=>e.id===t))||void 0===r?void 0:r.name)||t||""},showNotifications:!1});await oe({folderId:cr}),await(null===(t=N.current)||void 0===t?void 0:t.refreshFileCounts());const{successCount:i,failCount:o}=n;0===o?w.success({id:"TRASH_CLEARED_SUCCESS",message:x("Trash cleared successfully"),description:x("{{count}} items permanently deleted",{count:i}),placement:"bottomRight"}):i>0?w.warning({id:"TRASH_CLEARED_PARTIAL",message:x("Trash partially cleared"),description:x("{{succeeded}} items deleted, {{failed}} items failed",{succeeded:i,failed:o}),placement:"bottomRight"}):w.error({id:"TRASH_CLEAR_FAILED",message:x("Failed to clear trash"),placement:"bottomRight"})}V(!1)}catch(e){console.error("Error clearing trash:",e),w.error({id:"TRASH_CLEAR_ERROR",message:x("Error clearing trash"),placement:"bottomRight"}),V(!1)}},[_e,k,oe,w,x,b]),Ke=i.useCallback(()=>{V(!1)},[]),Ze=i.useCallback(async e=>{var t;await ve(e),await(null===(t=N.current)||void 0===t?void 0:t.refreshFileCounts())},[ve]),Je=i.useCallback(async e=>{var t;await ye(e),await(null===(t=N.current)||void 0===t?void 0:t.refreshFileCounts())},[ye]),Qe=i.useCallback(async()=>{let e=[],t=new Map;const r=null==C?void 0:C.config;await le({onStartBatch:n=>{e=v.startUpload(_e||void 0,n),t=new Map,n.forEach((n,i)=>{const o=e[i];o&&(t.set(n.name,o),t.set(ro(n.name,r),o))})},onStart:n=>{if(0===e.length){e=v.startUpload(_e||void 0,[n]);const i=e[0];i&&(t.set(n.name,i),t.set(ro(n.name,r),i))}},onProgress:(e,r)=>{const n=t.get(e);n&&v.updateProgress(n,r)},onComplete:async e=>{var r;const n=t.get(e);if(n){await new Promise(e=>setTimeout(e,100));const t=null==ee?void 0:ee.find(t=>t.name===e&&!t.isFolder);v.markAsSuccess(n,t)}await(null===(r=N.current)||void 0===r?void 0:r.refreshFileCounts())},onError:(r,n,i)=>{var o;const a=null!==(o=t.get(r))&&void 0!==o?o:null!=i&&i<e.length?e[i]:void 0;a&&v.markAsError(a,n)},onBatchComplete:async r=>{var n,i,o,a,s,l,c,u;for(let u=0;u<r.successes.length;u++){const d=r.successes[u],h=null===(n=r.uploadedFiles)||void 0===n?void 0:n.get(d),f=null!==(a=null!==(o=null!==(i=t.get(d))&&void 0!==i?i:(null==h?void 0:h.originalFileName)?t.get(h.originalFileName):void 0)&&void 0!==o?o:null!=(null==h?void 0:h.originalIndex)&&h.originalIndex<e.length?e[h.originalIndex]:void 0)&&void 0!==a?a:u<e.length?e[u]:void 0;if(f){let e;if(null==h?void 0:h.id){const t=h;e={id:t.id,name:null!==(s=t.name)&&void 0!==s?s:d,folderId:null!==(c=null!==(l=t.folderId)&&void 0!==l?l:_e)&&void 0!==c?c:null,isFolder:!1,size:t.size}}else await new Promise(e=>setTimeout(e,100)),e=null==ee?void 0:ee.find(e=>e.name===d&&!e.isFolder);v.updateProgress(f,100),v.markAsSuccess(f,e)}}r.errors.forEach(({fileName:e,error:r})=>{const n=t.get(e);n&&v.markAsError(n,r)}),await(null===(u=N.current)||void 0===u?void 0:u.refreshFileCounts())}})},[le,v,ee,_e,null==C?void 0:C.config]),et=i.useCallback(async(e,t,r,n)=>{var i,o;try{B(!0);let a=r||"uploaded-file";if(!r&&e){const t=e.split("?")[0].split("#")[0].split("/");a=t[t.length-1]||"uploaded-file";a.includes(".")&&(null===(i=a.split(".").pop())||void 0===i?void 0:i.length)&&a.split(".").pop().length<=5||(a+=".jpg")}const s=v.startUploadByUrl(_e||void 0,a);try{const r=await ce(e,t,!0,null!=n?n:"uploadByUrl");if(v.updateProgress(s,100),r){await new Promise(e=>setTimeout(e,100));const e=(null==ee?void 0:ee.find(e=>e.id===r.id&&!e.isFolder))||r;v.markAsSuccess(s,e)}else v.markAsSuccess(s);await(null===(o=N.current)||void 0===o?void 0:o.refreshFileCounts())}catch(e){const t=Hi(e),r=Yi(t,x);v.markAsError(s,r)}}finally{B(!1)}},[ce,v,_e,ee,x]),tt=i.useCallback(async({file:e})=>{var t;const r=v.startUpload(_e||void 0,[e])[0];let n=0;const i=setInterval(()=>{n=Math.min(n+10+Math.floor(Date.now()%10),90),v.updateProgress(r,n)},200);try{const n=await y.uploadFileWithProvider(e,void 0,!0);if(clearInterval(i),v.updateProgress(r,100),n){await new Promise(e=>setTimeout(e,100));const e=(null==ee?void 0:ee.find(e=>e.id===n.id&&!e.isFolder))||n;v.markAsSuccess(r,e)}else v.markAsSuccess(r);const o=n&&n.folderId||_e||null;return Ae&&Ae(o&&"folders"!==o?o:"folders"),await(null===(t=N.current)||void 0===t?void 0:t.refreshFileCounts()),n}catch(e){clearInterval(i);const t=e instanceof Error?e.message:String(e);throw v.markAsError(r,t),e}},[y,v,_e,ee,Ae]),rt=i.useCallback(async e=>{var t;await ae(e),await(null===(t=N.current)||void 0===t?void 0:t.refreshFileCounts())},[ae]),nt=i.useCallback(async e=>{var t;if(pe){const r=v.startUpload(_e||void 0,e);e.forEach(async(e,t)=>{const n=r[t];if(!n)return;let i=0;const o=setInterval(()=>{i=Math.min(i+10+Math.floor(Date.now()%10),85),v.updateProgress(n,i)},200);setTimeout(()=>{clearInterval(o)},2e3)}),await pe(e),r.forEach(e=>{v.updateProgress(e,100),v.markAsSuccess(e)}),await(null===(t=N.current)||void 0===t?void 0:t.refreshFileCounts())}},[pe,v,_e]),it=i.useCallback(async e=>{var t;await se(e),await W(),await(null===(t=N.current)||void 0===t?void 0:t.refreshFileCounts())},[se,W]),ot=(({files:e,selectedFiles:t,toggleFileSelection:r,showRenameModal:i,showMoveModal:o,showCopyModal:a,handleDeleteFile:s,handleDeleteFolder:l,showDeleteConfirm:c,onEdit:u})=>{const d=n.useCallback(()=>{t&&t.size>0&&t.forEach(e=>{r(e)})},[t,r]),h=n.useCallback(e=>{if(t&&1===t.size||e){const r=e||Array.from(t)[0];i(r)}},[t,i]),f=n.useCallback(r=>{if(t&&t.size>0||(null==r?void 0:r.id)){if(c)return void c();(r?[r.id]:t).forEach(t=>{const r=e.find(e=>e.id===t);r?r.isFolder?l(t):s(t):console.warn(`Объект с ID ${t} не найден в списке файлов`)})}},[t,e,s,l,c]);return{handleClearSelection:d,handleRename:h,handleDeleteSelected:f,handleCopy:n.useCallback(()=>{a()},[a]),handleMove:n.useCallback(()=>{o()},[o]),handleEdit:n.useCallback(()=>{u()},[u])}})({files:ee||[],selectedFiles:te||new Set,toggleFileSelection:ue,showRenameModal:de,showMoveModal:ge,showCopyModal:f.actions.showCopyModal||(()=>{}),handleDeleteFile:ae,handleDeleteFolder:it,showDeleteConfirm:we,onEdit:De.handleEdit}),at=H||re||ze;a(()=>{Ar()},[]),i.useEffect(()=>{if(!Ae||0===$.length)return;const e=!1!==(null==S?void 0:S.rememberLastFolder),t=`em_fm:lastFolder:${(null==S?void 0:S.projectId)||"default"}`;if(e&&"undefined"!=typeof window)try{const e=localStorage.getItem(t),r=e&&$.some(t=>t.id===e);if(r)return void Ae(e)}catch(e){}_e||Ae("folders")},[_e,Ae,$,null==S?void 0:S.rememberLastFolder,null==S?void 0:S.projectId]);const{state:st,actions:lt,options:ct}=i.useContext(Ti),{form:ut,urlForm:dt,renameForm:ht,moveForm:ft,renameFolderForm:pt,copyForm:gt,isModalVisible:mt,isUrlModalVisible:vt,isMoveModalVisible:yt,isRenameFolderModalVisible:bt,isCopyModalVisible:wt,isDeleteConfirmVisible:xt,folderToRename:Ct,activeLibraryItem:_t}=st,{setIsUrlModalVisible:St,setSortField:At,setActiveLibraryItem:kt}=lt,{config:Et}=ct,{handleRenameFolderCancel:It,handleRenameFolderOk:Tt}=J.actions;a(()=>{const e=async e=>{if(_t!==nr)return;const t=document.activeElement;if(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||"true"===(null==t?void 0:t.getAttribute("contenteditable")))return;const r=e.clipboardData;if(!r)return;const n=Array.from(r.items),i=n.filter(e=>e.type.startsWith("image/"));if(i.length>0){const t=i.map(e=>e.getAsFile()).filter(e=>null!==e);return void(t.length>0&&(e.preventDefault(),await nt(t)))}const o=n.find(e=>"text/plain"===e.type);o&&o.getAsString(async t=>{const r=t.trim();if(r.startsWith("http://")||r.startsWith("https://"))e.preventDefault(),await et(r);else if(r.includes("<meta")||r.includes("http")){const t=r.match(/https?:\/\/[^\s"']+/);t&&(e.preventDefault(),await et(t[0]))}})};return document.addEventListener("paste",e),()=>{document.removeEventListener("paste",e)}},[_t,et,nt]);const Ft=c(e=>{Ne(e.current||Ie.current,e.pageSize||Ie.pageSize)},[Ne,Ie]),Ot=i.useCallback(e=>{const{sortBy:t,sortOrder:r}=(e=>{const[t,r]=e.split("-");return{sortBy:t,sortOrder:r}})(e);Le(t,r)},[Le]),[Pt,Mt]=o(bL),[Rt,Lt]=o([]),Nt=u(null),[jt,Dt]=o(yr),[zt,Bt]=o([]),Ut=u(null),[Vt,$t]=o(""),Ht=u(null),[Wt,Gt]=o(""),[qt,Yt]=o([]),Xt=i.useRef(void 0),[Kt,Zt]=o(!1),[Jt,Qt]=o(!1),er=i.useRef(null),tr=i.useRef(_t),rr=i.useCallback(e=>{const t=e.indexOf(",");if(-1===t)return null;const r=e.substring(0,t),n=r.match(/^data:([^;]+)/),i=n&&n[1]||"image/svg+xml";let o,a="svg";if(i.includes("png")?a="png":(i.includes("jpeg")||i.includes("jpg"))&&(a="jpg"),/;base64/i.test(r)){const r=e.substring(t+1),n=atob(r),a=new Uint8Array(n.length);for(let e=0;e<n.length;e+=1)a[e]=n.charCodeAt(e);o=new Blob([a],{type:i})}else{const r=decodeURIComponent(e.substring(t+1));o=new Blob([r],{type:i})}return new File([o],`icon_${Date.now()}.${a}`,{type:i})},[]),ur=i.useCallback(async e=>{var t;const r=v.startUpload(_e||void 0,[e])[0];let n=0;const i=setInterval(()=>{n=Math.min(n+10+Math.floor(Date.now()%10),90),v.updateProgress(r,n)},200);try{const n=await y.uploadFileWithProvider(e,void 0,!0);if(clearInterval(i),v.updateProgress(r,100),n){await new Promise(e=>setTimeout(e,100));const e=(null==ee?void 0:ee.find(e=>e.id===n.id&&!e.isFolder))||n;v.markAsSuccess(r,e)}else v.markAsSuccess(r);await(null===(t=N.current)||void 0===t?void 0:t.refreshFileCounts())}catch(e){clearInterval(i);const t=e instanceof Error?e.message:String(e);throw v.markAsError(r,t),e}},[v,ee,y,_e]),dr=c(async e=>{if(Boolean(e&&e.startsWith("data:"))){const t=rr(e);if(!t)return;return void await ur(t)}e&&await et(e,void 0,void 0,"iconStock")},[rr,et,ur]),hr=c(async()=>{const e=null==Et?void 0:Et.fileForEdit;if(Xt.current===e)return;if(_t===lr&&e&&!De.editingFile){Xt.current=e;try{if("string"==typeof e){if(e.startsWith("data:"))return void(null==De||De.handleEdit({thumbnail:e}));const t=await y.handleAddFileByUrl(e,!0,void 0,"pixie");if(!t)throw new Error(x("Failed to download file"));Xt.current===e&&(null==De||De.handleEdit(t))}}catch(t){throw Xt.current===e&&(Xt.current=null),t}}},[null==Et?void 0:Et.fileForEdit,_t,De,y,x]);a(()=>{hr()},[hr]),a(()=>{var e,t,r,n;const i=tr.current;tr.current=_t,_t===nr?(Lt([]),Mt(bL),Bt([]),Dt(yr),Yt([]),Gt(""),Qt(!1),Zt(!1),i===nr||i!==or&&i!==ir&&i!==sr||Re("")):_t===sr?null===(e=er.current)||void 0===e||e.focus():_t===ir?null===(t=Nt.current)||void 0===t||t.focus():_t===or?null===(r=Ut.current)||void 0===r||r.focus():_t===ar&&(null===(n=Ht.current)||void 0===n||n.focus())},[_t,Re]);const fr=i.useCallback(async()=>{var e;await Tt(),await(null===(e=N.current)||void 0===e?void 0:e.refreshFileCounts())},[Tt]),pr=te.size,gr=i.useMemo(()=>{var e,t,r;if(1!==pr)return!1;const[n]=Array.from(te),i=ee.find(e=>e.id===n);if(!i||i.isFolder)return!1;const o="string"==typeof i.name?i.name:"",a=o?null===(e=o.split(".").pop())||void 0===e?void 0:e.toLowerCase():void 0,s=null!==(r=null===(t=i.extension)||void 0===t?void 0:t.toLowerCase())&&void 0!==r?r:a;return"string"==typeof i.type&&i.type.startsWith("image/")||"string"==typeof s&&mr.includes(s)},[pr,te,ee]),vr=null!==(l=null===(s=null==S?void 0:S.getDropOverlayContainer)||void 0===s?void 0:s.call(S))&&void 0!==l?l:document.body;return t(r,{children:[P&&Ge===nr&&Fe(e("div",{className:Xa.dragCaptureLayer,"data-drag-capture":"true",onDragOver:e=>{var t,r;e.preventDefault(),e.stopPropagation(),e.dataTransfer&&(e.dataTransfer.dropEffect="copy"),(null===(r=null===(t=e.dataTransfer)||void 0===t?void 0:t.types)||void 0===r?void 0:r.includes("Files"))&&!L.current&&O(!0)},onDragEnter:e=>{var t,r;e.preventDefault(),e.stopPropagation(),(null===(r=null===(t=e.dataTransfer)||void 0===t?void 0:t.types)||void 0===r?void 0:r.includes("Files"))&&O(!0)},onDragLeave:e=>{const t=e.currentTarget.getBoundingClientRect(),r=e.clientX,n=e.clientY;(r<=t.left||r>=t.right||n<=t.top||n>=t.bottom)&&O(!1)},onDrop:e=>{var t;e.preventDefault(),e.stopPropagation(),M(!1),O(!1),document.body.removeAttribute("data-fm-dragging");const r=e.dataTransfer,n=(null===(t=null==r?void 0:r.files)||void 0===t?void 0:t.length)?Array.from(r.files):(null==r?void 0:r.items)?Array.from(r.items).map(e=>e.getAsFile()).filter(e=>Boolean(e)):[];n.length&&(Be(!0),pe(n).catch(e=>{"StaleLoad"!==(null==e?void 0:e.name)&&console.error(e)}).finally(()=>Be(!1)))},"aria-hidden":"true"}),vr),F&&Fe(e("div",{className:Xa.dragOverlayGlobal,"data-drop-overlay":"true",onDragOver:e=>{e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect="copy")},onDragEnter:e=>e.preventDefault(),onDrop:e=>{var t;e.preventDefault(),e.stopPropagation(),O(!1),M(!1),document.body.removeAttribute("data-fm-dragging");const r=e.dataTransfer,n=(null===(t=null==r?void 0:r.files)||void 0===t?void 0:t.length)?Array.from(r.files):(null==r?void 0:r.items)?Array.from(r.items).map(e=>e.getAsFile()).filter(e=>Boolean(e)):[];n.length&&(Be(!0),pe(n).catch(e=>{"StaleLoad"!==(null==e?void 0:e.name)&&console.error(e)}).finally(()=>Be(!1)))},"aria-hidden":"true",children:t("div",{className:Xa.dragOverlayInner,children:[e("div",{className:Xa.uploadIcon,children:e(E,{})}),e("div",{className:Xa.textTitle,children:x("Drop files here to upload")}),e("div",{className:Xa.textDescription,children:x("Supported files:")+" .jpg, .jpeg, .svg, .png"})]})}),vr),e(Q,{className:"file-manager__layout",children:t("div",{className:Xa.filesContainer,"data-files-container":"true",onDragOver:$e,onDragLeave:Ve,onDragEnter:Ue,onDrop:He,children:[I&&e("div",{className:Xa.dragOverlay,children:t("div",{className:Xa.dragOverlayInner,children:[e("div",{className:Xa.uploadIcon,children:e(E,{})}),e("div",{className:Xa.textTitle,children:x("Drop files here to upload")}),e("div",{className:Xa.textDescription,children:x("Supported files:")+" .jpg, .jpeg, .svg, .png"})]})}),m.showResizeGuide&&e("div",{className:"resize-guide",style:{left:`${m.resizeGuidePosition}px`}}),t(Q,{className:"file-manager__content",children:[t(vL,{width:320,theme:"light",className:"file-manager-sider",children:[e(ms,{ref:N,selectedFolder:_e||"folders",generateMenuItems:Z,onFolderSelect:e=>null==Ae?void 0:Ae(e),folders:$||[],fetchFolders:W,fetchChildFolders:G,handleAddFile:Qe,setIsUrlModalVisible:e=>null==St?void 0:St(e),handleDeleteFolder:it,handleCreateFolder:q,activeLibraryItem:_t,setActiveLibraryItem:e=>null==kt?void 0:kt(e)}),e("div",{className:"sidebar-resizer "+(m.isResizing?"resizing":""),onMouseDown:m.handleResizeStart,onDoubleClick:m.handleDoubleClick,children:e("div",{className:"sidebar-resizer-indicator"})})]}),t(Q,{className:"file-manager__main-content",children:[ze&&e(cs,{style:{position:"absolute",width:"100%",height:"100%",top:0,left:0,zIndex:100,background:"var(--colorBgLayout)"}}),t(yL,{className:"main-content",children:[e(wR,{activeLibraryItem:_t,selectedFolder:(null===(d=null==$?void 0:$.find(e=>(null==e?void 0:e.id)===_e))||void 0===d?void 0:d.name)||x("Folders"),isTrashFolder:"Trash"===_e,onClearTrash:Ye,files:ee||[],loading:at,onRefresh:je,refreshDisabled:re||H}),e(K,{className:"zero-divider"}),_t===nr&&e(Ja,{searchTerm:Oe,sortField:st.sortField||"name",setSortField:e=>null==At?void 0:At(e),pathHistory:Se||[],handleBreadcrumbClick:e=>null==ke?void 0:ke(e),handleAddFile:Qe,setIsUrlModalVisible:e=>null==St?void 0:St(e),files:ee||[],handleSearch:Re,handleSort:Le,sortBy:Pe,sortOrder:Me,handleSortOptionChange:Ot,pagination:Ie,setPagination:Ft,loading:at,handleItemClick:e=>null==Ee?void 0:Ee(e),handleDeleteFile:rt,selectedFiles:te||new Set,toggleFileSelection:(e,t)=>null==ue?void 0:ue(e,t),handleDroppedFiles:nt,fileUpload:v,onClearSelection:ot.handleClearSelection,onRename:ot.handleRename,onCopy:ot.handleCopy,onMove:ot.handleMove,onDelete:ot.handleDeleteSelected,onEdit:De.handleEdit}),_t===ir&&e(jR,{imageGifList:Rt,setImageGifList:Lt,currentReqGif:Pt,setCurrentReqGif:Mt,inputRef:Nt,customRequest:(e,t)=>et(e,void 0,t,"gif")}),_t===or&&e(BR,{imageStockList:zt,setImageStockList:Bt,currentReq:jt,setCurrentReq:Dt,inputRef:Ut,customRequest:(e,t)=>et(e,void 0,t,"imageStock")}),_t===ar&&e(gL,{apiKey:null==Et?void 0:Et.STREAMLINE_API_KEY,customRequest:dr,query:Vt,setQuery:$t,inputRef:Ht}),_t===sr&&!!(null==Et?void 0:Et.sseQuery)&&e(KR,{imageAiList:qt,setImageAiList:Yt,aiImageRequest:Wt,setAiImageRequest:Gt,inputAiRef:er,customRequest:tt,isLoadingAi:Kt,setIsLoadingAi:Zt,isImageUploaded:Jt,setIsImageUploaded:Qt}),_t===lr&&e(r,{}),e(r,{children:gr&&t(r,{children:[e(K,{className:"zero-divider"}),e("div",{style:{display:"flex",justifyContent:"right",padding:"17px 24px",alignItems:"center"},children:e(j,{size:"large",type:"primary",style:{height:40},onClick:()=>{if(ct.onEditorOk){const e=Array.from(te)[0],t=ee.find(t=>t.id===e);t&&ct.onEditorOk(t)}},children:x("Choose")})})]})})]})]})]}),z&&e("div",{style:{position:"fixed",inset:0,zIndex:1500,backgroundColor:"rgba(255, 255, 255, 0.5)",pointerEvents:"all",display:"flex",alignItems:"center",justifyContent:"center"},children:e(A,{size:"large"})}),e(ps,{isModalVisible:mt,handleModalOk:Y,handleModalCancel:X,form:ut,selectedFolder:_e||null,folders:$||[],isUrlModalVisible:vt,setIsUrlModalVisible:e=>null==St?void 0:St(e),handleAddFileByUrl:et,urlForm:dt,isRenameModalVisible:ne,handleRenameOk:()=>null==fe?void 0:fe(),handleRenameCancel:()=>null==he?void 0:he(),renameForm:ht,fileToRename:ie,files:ee||[],isMoveModalVisible:yt,handleMoveOk:Ze,handleMoveCancel:me,moveForm:ft,selectedFiles:te||new Set,isRenameFolderModalVisible:bt,handleRenameFolderOk:fr,handleRenameFolderCancel:It,renameFolderForm:pt,folderToRename:Ct,isCopyModalVisible:wt,handleCopyOk:Je,handleCopyCancel:be,copyForm:gt,isDeleteConfirmVisible:xt,handleDeleteConfirmOk:qe,handleDeleteConfirmCancel:()=>null==xe?void 0:xe(),isClearTrashConfirmVisible:U,handleClearTrashConfirm:Xe,handleClearTrashCancel:Ke,fetchChildFolders:G}),e(VM,{visible:De.isPixieEditorVisible,onClose:De.handlePixieEditorClose,file:De.editingFile,onSave:De.handlePixieEditorSave}),e(vR,{files:v.uploadFiles,visible:v.isUploadVisible,minimized:v.isUploadMinimized,totalFiles:v.totalFiles,completedFiles:v.completedFiles,onClose:v.closeUpload,onMinimize:v.minimizeUpload,onInsert:e=>{var t;const r=v.getUploadedFile(e.id)||e;null===(t=ct.onEditorOk)||void 0===t||t.call(ct,r)}})]})})]})},xL=f(({config:n={},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,availableImageExtensions:["jpg","jpeg","png","gif"],fileNameProcessing:Object.assign(Object.assign({},{transliterate:!0,replaceSpaces:!0,removeForbiddenChars:!0,toLowerCase:!0}),n.fileNameProcessing),folderNameProcessing:Object.assign(Object.assign({},{transliterate:!0,replaceSpaces:!0,removeForbiddenChars:!0,toLowerCase:!0}),n.folderNameProcessing)},n),[n]);i.useEffect(()=>{b.theme&&(e=>{if("system"===e){const t=matchMedia(fr).matches?dr:ur;e=e===hr?t:e}document.documentElement.setAttribute("data-theme",e)})(b.theme),mL(b)},[b]),a(()=>{b.locale&&b.locale!==$n.language&&$n.changeLanguage(b.locale),b.customLocale&&b.locale&&$n.addResourceBundle(b.locale,"translation",b.customLocale,!0,!0)},[b.locale,b.customLocale]);const w=u(null);return e(I,{className:"em-filemanager",children:t(r,{children:[e(E,{getPopupContainer:()=>w.current||document.body,children:e(Oi,{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(wL,{})})}),e("div",{ref:w,className:"file-manager-modal-root"})]})})});xL.displayName="FileManagerApp";const CL=t=>{var r,n,i;return e(Jr,{i18n:$n,children:e(xr,{externalTheme:null!==(n=null===(r=t.config)||void 0===r?void 0:r.theme)&&void 0!==n?n:"light",customThemeToken:null===(i=t.config)||void 0===i?void 0:i.customTheme,children:e(ae,{children:e(xL,Object.assign({},t))})})})},_L=new Map,SL=(t,r)=>{var n;let i;Ar();let o={};const a=e=>{const t=!e||"fileManager"!==e.mode&&"imageCenter"!==e.mode&&"plugin"!==e.mode?void 0:e.mode;return"imageCenter"===t?_r("imageCenter",e):_r(t)};if(t instanceof HTMLElement){i=t;o={config:a(r),apiEndpoints:null==r?void 0:r.apiEndpoints}}else{i=t.element;const e=a(t.config),r=Object.assign(Object.assign({},null===(n=t.config)||void 0===n?void 0:n.apiEndpoints),t.apiEndpoints);o={config:e,currentPath:t.currentPath,onPathChange:t.onPathChange,onChangeSelection:t.onChangeSelection,searchQuery:t.searchQuery,sortBySize:t.sortBySize,apiEndpoints:r,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(CL,Object.assign({},o))),_L.set(i.id||`container_${Date.now()}`,s)},AL=e=>{const t=e.id||Object.keys(_L).find(e=>e.startsWith("container_"));if(t&&_L.has(t)){const e=_L.get(t);null==e||e.unmount(),_L.delete(t)}else{console.warn("Couldn t find the root to unmount");try{S(e).unmount()}catch(e){console.error("Error unmounting the component:",e)}}},kL=new Map,EL=n=>{const{onClose:o,onSave:s,dataProviders:l,theme:c,locale:d}=n,h=i.useMemo(()=>{if(n.file)return n.file;const e=n.name||"edited-image",t=n.extension||(n.type?n.type.split("/")[1]:"png"),r=n.type||`image/${t}`;return{thumbnail:n.imageDataUrl||"",name:e,id:void 0,type:r,extension:t}},[n.file,n.imageDataUrl,n.name,n.extension,n.type]),f=i.useCallback(async e=>{if((null==l?void 0:l.updateFile)&&e.thumbnail)try{const t=Tr(e.thumbnail,e.type),r=Fr(t),n=e.name.substring(0,e.name.lastIndexOf("."))+"."+r,i=Rr(e.thumbnail,t);return await l.updateFile(e.id,{name:n,type:t,data:i})}catch(e){return console.error("Error updating the file through updateFile:",e),null}return console.warn("DataProvider for updating files is not configured"),null},[l]),p=i.useCallback(async e=>{if((null==l?void 0:l.updateFile)&&e.id&&e.thumbnail)try{const t=await f(e);t&&(e=t)}catch(e){console.error("Standalone Pixie: saveFileToServer error",e)}return s&&await s(e),o&&o(),e},[l,s,o,f]),g=u(null);return a(()=>{d&&d!==$n.language&&$n.changeLanguage(d)},[d]),e(I,{className:"em-filemanager",children:t(r,{children:[e(E,{getPopupContainer:()=>g.current||document.body,children:e(Jr,{i18n:$n,children:e(xr,{externalTheme:null!=c?c:"light",children:e(ae,{children:e(Oi,{options:{dataProviders:l,handleNotify:n.handleNotify,handleError:n.handleError,handleSuccess:n.handleSuccess,config:{theme:null!=c?c:"light",locale:d,baseUrl:n.baseUrl,assetsUrl:n.assetsUrl,showNotifications:n.showNotifications}},children:e(VM,{visible:!0,onClose:o,file:h,onSave:p})})})})})}),e("div",{ref:g,className:"file-manager-modal-root"})]})})},IL=t=>{Ar();const r=t.element,n=S(r);n.render(e(EL,Object.assign({},t))),kL.set(r.id||`pixie_container_${Date.now()}`,n)},TL=e=>{const t=Array.from(kL.keys()).find(e=>e.startsWith("pixie_container_")),r=e.id||t;if(r&&kL.has(r)){const e=kL.get(r);null==e||e.unmount(),kL.delete(r)}else{console.warn("Couldn t find the root to unmount Pixie");try{S(e).unmount()}catch(e){console.error("Error unmounting Pixie:",e)}}},FL=e=>{var t,r;const{mode:n,element:i,fileManager:o,pixieEditor:a,theme:s,dataProviders:l}=e;let c,u;const d={unmount:()=>{c&&AL(c),u&&TL(u)},unmountFileManager:void 0,unmountPixieEditor:void 0};switch(n){case"fileManager":c=i,SL(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=()=>AL(c);break;case"pixieEditor":u=i,IL(Object.assign({element:i,theme:s||(null==a?void 0:a.theme),dataProviders:l||(null==a?void 0:a.dataProviders)},a)),d.unmountPixieEditor=()=>TL(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,SL(c,Object.assign(Object.assign({},null==o?void 0:o.config),{theme:s||(null===(r=null==o?void 0:o.config)||void 0===r?void 0:r.theme),apiEndpoints:null==o?void 0:o.apiEndpoints})),IL(Object.assign({element:u,theme:s||(null==a?void 0:a.theme),dataProviders:l||(null==a?void 0:a.dataProviders)},a)),d.unmountFileManager=()=>AL(c),d.unmountPixieEditor=()=>TL(u);break}}return d};function OL(e,t="BackendError"){switch(e){case 400:return"ValidationError";case 401:return"AuthenticationFailed";case 403:return"AuthorizationFailed";case 404:return"FileNotFound";case 413:return"PayloadTooLarge";case 415:return"UnsupportedMediaType";case 429:return"RateLimitExceeded";case 500:return"BackendError";case 503:return"ServiceUnavailable";case 504:return"Timeout";default:return t}}var PL={init:SL,unmount:AL,initPixieEditor:IL,unmountPixieEditor:TL,initFileManager:FL};export{Ja as FileContent,ao as FileManagerApiError,xL as FileManagerApp,CL as FileManagerAppWithContext,ps as FileModals,ms as FolderSidebar,EL as PixieOnlyApp,PL as default,SL as init,FL as initFileManager,IL as initPixieEditor,Ar as installResizeObserverErrorHandler,OL as mapHttpStatusToErrorCode,kr as uninstallResizeObserverErrorHandler,AL as unmount,TL as unmountPixieEditor};
|
|
76
|
+
var xR=function(e,t){return xR=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])},xR(e,t)};var CR=function(){return CR=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var i in t=arguments[r])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},CR.apply(this,arguments)};var _R="Pixel",SR="Percent",AR={unit:SR,value:.8};function kR(e){return"number"==typeof e?{unit:SR,value:100*e}:"string"==typeof e?e.match(/^(\d*(\.\d+)?)px$/)?{unit:_R,value:parseFloat(e)}:e.match(/^(\d*(\.\d+)?)%$/)?{unit:SR,value:parseFloat(e)}:(console.warn('scrollThreshold format is invalid. Valid formats: "120px", "50%"...'),AR):(console.warn("scrollThreshold should be string or number"),AR)}var ER=function(e){function t(t){var r=e.call(this,t)||this;return r.lastScrollTop=0,r.actionTriggered=!1,r.startY=0,r.currentY=0,r.dragging=!1,r.maxPullDownDistance=0,r.getScrollableTarget=function(){return r.props.scrollableTarget instanceof HTMLElement?r.props.scrollableTarget:"string"==typeof r.props.scrollableTarget?document.getElementById(r.props.scrollableTarget):(null===r.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)},r.onStart=function(e){r.lastScrollTop||(r.dragging=!0,e instanceof MouseEvent?r.startY=e.pageY:e instanceof TouchEvent&&(r.startY=e.touches[0].pageY),r.currentY=r.startY,r._infScroll&&(r._infScroll.style.willChange="transform",r._infScroll.style.transition="transform 0.2s cubic-bezier(0,0,0.31,1)"))},r.onMove=function(e){r.dragging&&(e instanceof MouseEvent?r.currentY=e.pageY:e instanceof TouchEvent&&(r.currentY=e.touches[0].pageY),r.currentY<r.startY||(r.currentY-r.startY>=Number(r.props.pullDownToRefreshThreshold)&&r.setState({pullToRefreshThresholdBreached:!0}),r.currentY-r.startY>1.5*r.maxPullDownDistance||r._infScroll&&(r._infScroll.style.overflow="visible",r._infScroll.style.transform="translate3d(0px, "+(r.currentY-r.startY)+"px, 0px)")))},r.onEnd=function(){r.startY=0,r.currentY=0,r.dragging=!1,r.state.pullToRefreshThresholdBreached&&(r.props.refreshFunction&&r.props.refreshFunction(),r.setState({pullToRefreshThresholdBreached:!1})),requestAnimationFrame(function(){r._infScroll&&(r._infScroll.style.overflow="auto",r._infScroll.style.transform="none",r._infScroll.style.willChange="unset")})},r.onScrollListener=function(e){"function"==typeof r.props.onScroll&&setTimeout(function(){return r.props.onScroll&&r.props.onScroll(e)},0);var t=r.props.height||r._scrollableNode?e.target:document.documentElement.scrollTop?document.documentElement:document.body;r.actionTriggered||((r.props.inverse?r.isElementAtTop(t,r.props.scrollThreshold):r.isElementAtBottom(t,r.props.scrollThreshold))&&r.props.hasMore&&(r.actionTriggered=!0,r.setState({showLoader:!0}),r.props.next&&r.props.next()),r.lastScrollTop=t.scrollTop)},r.state={showLoader:!1,pullToRefreshThresholdBreached:!1,prevDataLength:t.dataLength},r.throttledOnScrollListener=function(e,t,r,n){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(),r.apply(l,u)}o||(n&&!i&&d(),s(),void 0===n&&c>e?d():!0!==t&&(i=setTimeout(n?function(){i=void 0}:d,void 0===n?e-c:e)))}return"boolean"!=typeof t&&(n=r,r=t,t=void 0),l.cancel=function(){s(),o=!0},l}(150,r.onScrollListener).bind(r),r.onStart=r.onStart.bind(r),r.onMove=r.onMove.bind(r),r.onEnd=r.onEnd.bind(r),r}return function(e,t){function r(){this.constructor=e}xR(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}(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?CR(CR({},t),{prevDataLength:e.dataLength}):null},t.prototype.isElementAtTop=function(e,t){void 0===t&&(t=.8);var r=e===document.body||e===document.documentElement?window.screen.availHeight:e.clientHeight,n=kR(t);return n.unit===_R?e.scrollTop<=n.value+r-e.scrollHeight+1:e.scrollTop<=n.value/100+r-e.scrollHeight+1},t.prototype.isElementAtBottom=function(e,t){void 0===t&&(t=.8);var r=e===document.body||e===document.documentElement?window.screen.availHeight:e.clientHeight,n=kR(t);return n.unit===_R?e.scrollTop+r>=e.scrollHeight-n.value:e.scrollTop+r>=n.value/100*e.scrollHeight},t.prototype.render=function(){var e=this,t=CR({height:this.props.height||"auto",overflow:"auto",WebkitOverflowScrolling:"touch"},this.props.style),r=this.props.hasChildren||!!(this.props.children&&this.props.children instanceof Array&&this.props.children.length),n=this.props.pullDownToRefresh&&this.props.height?{overflow:"auto"}:{};return i.createElement("div",{style:n,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&&!r&&this.props.hasMore&&this.props.loader,this.state.showLoader&&this.props.hasMore&&this.props.loader,!this.props.hasMore&&this.props.endMessage))},t}(_);function IR(e,t){if(null==e)return{};var r,n,i=function(e,t){if(null==e)return{};var r,n,i={},o=Object.keys(e);for(n=0;n<o.length;n++)r=o[n],t.indexOf(r)>=0||(i[r]=e[r]);return i}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(n=0;n<o.length;n++)r=o[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i}function TR(){return TR=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},TR.apply(this,arguments)}function FR(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function OR(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?FR(Object(r),!0).forEach(function(t){PR(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):FR(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function PR(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}const MR={breakpointCols:void 0,className:void 0,columnClassName:void 0,children:void 0,columnAttrs:void 0,column:void 0};class RR 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 r=1/0,n=t.default||2;for(let i in t){const o=parseInt(i);o>0&&e<=o&&o<r&&(r=o,n=t[i])}n=Math.max(1,parseInt(n)||1),this.state.columnCount!==n&&this.setState({columnCount:n})}itemsInColumns(){const e=this.state.columnCount,t=new Array(e),r=i.Children.toArray(this.props.children);for(let n=0;n<r.length;n++){const i=n%e;t[i]||(t[i]=[]),t[i].push(r[n])}return t}renderColumns(){const{column:e,columnAttrs:t={},columnClassName:r}=this.props,n=this.itemsInColumns(),o=100/n.length+"%";let a=r;a&&"string"!=typeof a&&(this.logDeprecated('The property "columnClassName" requires a string'),void 0===a&&(a="my-masonry-grid_column"));const s=OR(OR(OR({},e),t),{},{style:OR(OR({},t.style),{},{width:o}),className:a});return n.map((e,t)=>i.createElement("div",TR({},s,{key:t}),e))}logDeprecated(e){console.error("[Masonry]",e)}render(){const e=this.props,{children:t,breakpointCols:r,columnClassName:n,columnAttrs:o,column:a,className:s}=e,l=IR(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",TR({},l,{className:c}),this.renderColumns())}}RR.defaultProps=MR;var LR={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"};const NR={default:4,1600:3,1100:2,700:1},jR=({setImageGifList:n,imageGifList:i=[],currentReqGif:s,setCurrentReqGif:l,inputRef:c,customRequest:d})=>{const{t:h}=Zr(),{GifPlayIcon:f}=Va(),{options:p}=Fi(),{config:g}=p,[m,v]=o(null),[y,b]=o(!1),[w,x]=o(25),[C,_]=o(null),[S]=T.useForm(),k=u(s);a(()=>{S.setFieldsValue({keywords:s.keywords})},[]);const E=null==g?void 0:g.handleProxyUrl,I=async e=>E?Promise.resolve(E(e)):e,O=async e=>Promise.all(e.map(async e=>Object.assign(Object.assign({},e),{images:Object.assign(Object.assign({},e.images),{downsized:Object.assign(Object.assign({},e.images.downsized),{url:await I(e.images.downsized.url)})})}))),P=async function({query:e,page:t}){var r;const n=e.keywords.replace(/[^\w\sа-яёА-ЯЁ]|_/g,"").replace(/[\s_-]+/g," ");try{const e=`https://api.giphy.com/v1/gifs/search?api_key=${null!==(r=null==g?void 0:g.REACT_APP_GIPHY_KEY)&&void 0!==r?r:"Nh77eBlPeMn1ed9MBAvL542NUGeNO26F"}&q=${encodeURIComponent(n)}&limit=25&offset=${t}&lang=en`,i=await fetch(await I(e));return{data:await i.json()}}catch(e){console.warn(e)}},M=async()=>{var e,t;const r=await P({query:k.current,page:0});(null===(t=null===(e=null==r?void 0:r.data)||void 0===e?void 0:e.data)||void 0===t?void 0:t.length)&&r.data.data.length>0&&n(await O(r.data.data))};return a(()=>()=>{C&&clearTimeout(C)},[C]),e("div",{className:LR.gifTab,children:e("div",{className:LR.searchOutputWrapper,children:t("div",{id:"scrollableDiv",className:LR.scrollableDiv,children:[t(T,{form:S,onValuesChange:e=>{if(void 0!==e.keywords){const t=Object.assign(Object.assign({},k.current),{keywords:e.keywords});l(t),k.current=t,C&&clearTimeout(C);const r=setTimeout(M,800);_(r)}},className:i.length>0?LR.searchResults:LR.search,children:[e(T.Item,{name:"keywords",className:LR.gifSearchInput,children:e(F,{onKeyDown:e=>"Space"===e.code&&M(),onPressEnter:e=>M(),allowClear:!0,placeholder:h("Search GIFs"),ref:c,spellCheck:"false",prefix:e(bi,{size:16,strokeWidth:null==g?void 0:g.iconStrokeWidth,onClick:M})})}),i.length>0&&!y&&e("div",{className:`ant-divider ${LR.divider}`,role:"separator"})]}),!i.length&&!y&&e(r,{children:s.keywords?e(qa,{}):t("div",{className:LR.resultsContainer,children:[e("div",{className:LR.videoIcon,children:e(f,{className:LR.playButton})}),e("h1",{className:LR.title,children:h("Over 350,000 live images")}),e("p",{className:LR.subtitle,children:h("Enter a search query and we'll find the perfect image for you")})]})}),!i.length&&y&&e(cs,{}),i.length>0&&e(ER,{dataLength:i&&i.length,next:async()=>{y||(b(!0),P({query:k.current,page:w}).then(async e=>{if(e&&e.data&&e.data.data){const t=await O(e.data.data);n(e=>[...e,...t])}b(!1),x(e=>e+25)}).catch(()=>{b(!1)}))},hasMore:!!i,endMessage:t(K,{plain:!0,children:[h("That`s all we could find.")," 🤐"]}),scrollableTarget:"scrollableDiv",style:{overflow:"visible"},loader:e(cs,{}),children:e(RR,{breakpointCols:NR,className:LR.myMasonryGrid,columnClassName:LR.myMasonryGridColumn,children:i.map((r,n)=>t("div",{className:LR.listItem,onClick:()=>(async(e,t)=>{var r;v(t),setTimeout(()=>{v(null)},2e3);const n=await I(e);let i=n.split("?")[0].split("#")[0].split("/"),o=i[i.length-1]||"uploaded-file";o.includes(".")&&(null===(r=o.split(".").pop())||void 0===r?void 0:r.length)&&o.split(".").pop().length<=5||(o+=".gif"),d(n,o)})(r.images.downsized.url,r.id,r.title),children:[e("img",{className:m===r.id?LR.loadedImage:"",width:"100%",src:r.images.downsized.url,alt:r.title,onLoad:e=>{const t=e.target.parentNode;t&&t instanceof HTMLElement&&t.classList.add(LR.loaded)}}),e("a",{rel:"noreferrer",href:"https://giphy.com/",target:"_blank",onClick:e=>e.stopPropagation()}),m===r.id&&e(A,{className:LR.antSpin})]},r.id+n))})})]})})})};var DR={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"};const zR={default:4,1600:3,1100:2,700:1},BR=({imageStockList:n,setImageStockList:i,currentReq:s,setCurrentReq:l,inputRef:c,customRequest:d})=>{var h,f;const{t:p}=Zr(),{StockBigIcon:g,MixedViewIcon:m,LandscapeViewIcon:v,PortraitViewIcon:y,SquareViewIcon:b}=Va(),{options:w}=Fi(),{config:x}=w,[C,_]=o(!1),[S,k]=o(2),[E,I]=o(null),[O,P]=o(null),[M,R]=o(!0),[N]=T.useForm(),j=null==x?void 0:x.handleProxyUrl,D=null!==(h=null==x?void 0:x.UNSPLASH_KEY)&&void 0!==h?h:"HX2_qqq3F3ljmtYtfmb9P6h0dn2u9mnnOl36IdV8el0",z=u(s),B=async e=>j?Promise.resolve(j(e)):e,U=async e=>Promise.all(e.map(async e=>Object.assign(Object.assign({},e),{urls:Object.assign(Object.assign({},e.urls),{raw:await B(e.urls.raw)})})));a(()=>{z.current=s},[s]),a(()=>{0===n.length&&N.setFieldsValue({color:"",orientation:""})},[n,N]),a(()=>{N.setFieldsValue({keywords:s.keywords,color:s.color,orientation:s.orientation})},[]);const V=async function({query:e,page:t}){const r=e.keywords.replace(/[^\w\sа-яёА-ЯЁ]|_/g,"").replace(/[\s_-]+/g," ");try{let n=`https://api.unsplash.com/search/photos?client_id=${D}&lang=ru&per_page=18&query=${encodeURIComponent(r)}&page=${t}`;""!==e.color&&(n+=`&color=${e.color}`),""!==e.orientation&&(n+=`&orientation=${e.orientation}`);const i=await fetch(await B(n));return{data:await i.json()}}catch(e){console.warn(e)}finally{_(!1)}},W=async()=>{var e,t,r;_(!0);const n=await V({query:z.current,page:1});(null===(e=null==n?void 0:n.data)||void 0===e?void 0:e.results)&&(i(await U(n.data.results)),R(18===n.data.results.length),(null===(r=null===(t=null==n?void 0:n.data)||void 0===t?void 0:t.results)||void 0===r?void 0:r.length)&&n.data.results.length>0&&k(2))};a(()=>()=>{O&&clearTimeout(O)},[O]);const G=async(e,t,r,n)=>{var i;!async function(e){try{const t=`${e}${e.includes("?")?"&":"?"}client_id=${D}`,r=await B(t),n=await fetch(r);return{data:await n.json()}}catch(e){console.warn(e)}}(t.download_location),I(r),setTimeout(()=>I(null),2e3);const o=e.raw,a=await B(o),s=a.split("?")[0].split("#")[0].split("/");let l=s[s.length-1]||"uploaded-file";l.includes(".")&&(null===(i=l.split(".").pop())||void 0===i?void 0:i.length)&&l.split(".").pop().length<=5||(l+=".jpg"),d(a,l)};return e("div",{className:DR.stockTab,children:e("div",{className:DR.searchOutputWrapper,children:t("div",{className:DR.scrollableDiv,id:"scrollableDiv",children:[t(T,{form:N,initialValues:yr,onValuesChange:(e,t)=>{const r=Object.assign(Object.assign({},yr),t);if(l(r),z.current=r,O&&clearTimeout(O),""!==t.keywords){const e=setTimeout(W,800);P(e)}else n.length||(l(Object.assign({},yr)),z.current=yr,N.resetFields())},className:n.length>0?DR.searchResults:DR.search,children:[t($,{gutter:24,children:[e(H,{span:n.length>0?void 0:24,children:e(T.Item,{name:"keywords",className:DR.stockSearchInput,children:e(F,{allowClear:!0,placeholder:p("Search image"),ref:c,spellCheck:"false",prefix:e(bi,{size:16,strokeWidth:null==x?void 0:x.iconStrokeWidth})})})}),!!n.length&&t(r,{children:[e(H,{children:e(T.Item,{name:"orientation",children:t(ee.Group,{onChange:e=>l(t=>Object.assign(Object.assign({},t),{orientation:e.target.value})),children:[e(L,{title:p("All"),placement:"top",children:e(ee.Button,{value:"",children:e(m,{})})}),e(L,{title:p("Landscape"),placement:"top",children:e(ee.Button,{value:"landscape",children:e(v,{})})}),e(L,{title:p("Portrait"),placement:"top",children:e(ee.Button,{value:"portrait",children:e(y,{})})}),e(L,{title:p("Squarish"),placement:"top",children:e(ee.Button,{value:"squarish",children:e(b,{})})})]})})}),e(H,{children:e(T.Item,{name:"color",children:t(ee.Group,{className:DR.stockColorFilter,onChange:e=>l(t=>Object.assign(Object.assign({},t),{color:e.target.value})),children:[e(L,{title:p("All"),placement:"top",children:e(ee.Button,{className:DR.allColors,value:"",children:"All"})}),e(L,{title:p("Black"),placement:"top",children:e(ee.Button,{className:DR.blackColor,value:"black",children:"B"})}),e(L,{title:p("Black and White"),placement:"top",children:e(ee.Button,{className:DR.bwColor,value:"black_and_white",children:"B&W"})}),e(L,{title:p("White"),placement:"top",children:e(ee.Button,{className:DR.whiteColor,value:"white",children:"W"})}),e(L,{title:p("Orange"),placement:"top",children:e(ee.Button,{className:DR.orangeColor,value:"orange",children:"O"})}),e(L,{title:p("Red"),placement:"top",children:e(ee.Button,{className:DR.redColor,value:"red",children:"R"})}),e(L,{title:p("Purple"),placement:"top",children:e(ee.Button,{className:DR.purpleColor,value:"purple",children:"P"})}),e(L,{title:p("Magenta"),placement:"top",children:e(ee.Button,{className:DR.magentaColor,value:"magenta",children:"M"})}),e(L,{title:p("Green"),placement:"top",children:e(ee.Button,{className:DR.greenColor,value:"green",children:"G"})}),e(L,{title:p("Teal"),placement:"top",children:e(ee.Button,{className:DR.tealColor,value:"teal",children:"T"})}),e(L,{title:p("Blue"),placement:"top",children:e(ee.Button,{className:DR.blueColor,value:"blue",children:"B"})})]})})})]})]}),n.length>0&&!C&&e("div",{className:`ant-divider ${DR.divider}`,role:"separator"})]}),!n.length&&!C&&e(r,{children:s.keywords?e(qa,{}):t("div",{className:DR.resultsContainer,children:[e("div",{className:DR.videoIcon,children:e(g,{className:DR.playButton})}),e("h1",{className:DR.title,children:p("Millions of free stock images")}),e("p",{className:DR.subtitle,children:p("Enter a search query and we'll find the perfect image for you")})]})}),!n.length&&C&&e(cs,{}),n.length>0&&e(ER,{dataLength:n&&n.length,next:async()=>{if(C||""===z.current.keywords)return _(!1),void(""===z.current.keywords&&R(!1));_(!0),V({query:z.current,page:S}).then(async e=>{if(e&&e.data&&e.data.results){const t=await U(e.data.results);i(e=>[...e,...t]),R(18===e.data.results.length)}k(e=>e+1)}).catch(e=>{console.warn("catch",e)}).finally(()=>{_(!1)})},hasMore:M&&""!==(null===(f=z.current)||void 0===f?void 0:f.keywords),endMessage:t(K,{plain:!0,children:[p("That`s all we could find.")," 🤐"]}),scrollableTarget:"scrollableDiv",style:{overflow:"visible"},loader:e(cs,{}),children:e(RR,{breakpointCols:zR,className:DR.myMasonryGrid,columnClassName:DR.myMasonryGridColumn,children:n.map((r,n)=>t("div",{className:DR.listItem,onClick:()=>G(r.urls,r.links,r.id,r.description),children:[e("img",{className:E===r.id?DR.loadedImage:"",width:"100%",src:r.urls.raw,alt:r.description,onLoad:e=>{const t=e.target.parentNode;t&&t instanceof HTMLElement&&t.classList.add(DR.loaded)}}),t("p",{className:DR.creatorInfo,onClick:e=>e.stopPropagation(),children:[p("Photo by")," ",e("a",{target:"_blank",href:`${r.user.links.html}?utm_source=${null==x?void 0:x.APP_NAME_UNSPLASH}&utm_medium=referral`,rel:"noreferrer",children:r.user.name})," ",p("on")," ",e("a",{target:"_blank",href:`https://unsplash.com/?utm_source=${null==x?void 0:x.APP_NAME_UNSPLASH}&utm_medium=referral`,rel:"noreferrer",children:"Unsplash"})]}),E===r.id&&e(A,{className:DR.antSpin})]},r.id+n))})})]})})})},UR=()=>{const{options:e}=Fi(),t=e.config;return c((e,r)=>{!1!==(null==t?void 0:t.pushToGTM)&&((e,t)=>{const r=()=>{try{const t=Object.assign(Object.assign({},e),{appLabel:"blocks_app"});window.dataLayer&&"function"==typeof window.dataLayer.push&&window.dataLayer.push(t)}catch(e){console.error("Ошибка при вызове GTM:",e)}};t?setTimeout(r,t):r()})(e,r)},[null==t?void 0:t.pushToGTM])};var VR="slideshowContainer",$R="slideshowImage";const HR=({images:t,transitionDuration:r=1e3,frameHeight:n})=>{const[i,s]=o([]),[l,c]=o(n);a(()=>{const e=()=>{if("undefined"==typeof window)return void c(n);const e=window.innerHeight,t=Math.max(e-260,130);if("number"==typeof n){const e=Math.min(n,t);c(e)}else c(t)};if(e(),"undefined"!=typeof window)return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[n]);const u=()=>{s(e=>e.map((t,r)=>r===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(u,1e3)}else s([])},[t]),e("div",{className:VR,style:{height:l,minHeight:130},children:i.map((t,n)=>e("img",{src:`data:image/jpeg;base64, ${t.src}`,alt:`Slide ${n+1}`,className:$R,style:{opacity:t.opacity,transition:`opacity ${r}ms linear`,display:"block"}},n))})};"function"==typeof SuppressedError&&SuppressedError;const WR=t=>{var{className:r,style:n,color:i,text:o,bordered:a}=t,s=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(e);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(r[n[i]]=e[n[i]])}return r}(t,["className","style","color","text","bordered"]);const l=o||"";return e(te,Object.assign({style:n,color:i,bordered:a,className:r},s,{children:l}))},GR=({text:r,counter:n,limits:i,wrapperStyles:o})=>{const{t:a}=Zr(),{options:s}=Fi(),l=s.config,{token:c}=k.useToken(),u=+i>0,d=!u||n<+i,h=(null==l?void 0:l.billingPageUrl)||"/billing",f=n+" "+a("of")+" "+(u?i:"∞")+" "+(r||a("tests",{count:i}))+" "+a("was used",{count:n});return t("div",{className:"limits-couter-wrapper",style:o,children:[e(WR,{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 qR={imageAi:"imageAi",imageAiExample:"imageAiExample",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 YR=f(({className:t,onClick:r})=>e("div",{className:`${qR.arrow} ${qR.arrowNext} ${t||""}`,onClick:r,children:e(j,{className:`${qR.arrowBtn} ${qR.arrowBtnNext}`,size:"large",icon:e(ke,{})})}));YR.displayName="SampleNextArrow";const XR=f(({className:t,onClick:r})=>e("div",{className:`${qR.arrow} ${qR.arrowPrev} ${t||""}`,onClick:r,children:e(j,{className:`${qR.arrowBtn} ${qR.arrowBtnPrev}`,size:"large",icon:e(Ee,{})})}));XR.displayName="SamplePrevArrow";const KR=({customRequest:r,inputAiRef:n,isImageUploaded:s,setIsImageUploaded:l,aiImageRequest:h,setAiImageRequest:f,imageAiList:p,setImageAiList:g,isLoadingAi:m,setIsLoadingAi:v})=>{const{t:y}=Zr(),{AiIcon_2:b}=Va(),w=i.useRef(null),[x,C]=o("auto"),{aiImageCounter:_,currentAiImgLimits:S,loadingDuringGeneration:A,requestStatus:k,handleGenerate:E,convertBase64ToFile:I,isShiftPressed:O,setIsShiftPressed:P,limitsInPlugin:M}=function({setFrameHeight:e,customRequest:t,aiTabRef:r,isImageUploaded:n,setIsImageUploaded:i,aiImageRequest:s,imageAiList:l,setImageAiList:h,isLoadingAi:f,setIsLoadingAi:p}){const{t:g}=Zr(),{options:m}=Fi(),v=m.config,y=Li(),b=UR(),{messages:w}=m.config,[x,C]=o([]),[_,S]=o(0),[A,k]=o(null),[E,I]=o(!1),[T,F]=o(g("Evaluating the task")),[O,P]=o(!1),M=u(new Set),R=u(new Set),L=u(new Set);a(()=>{C(w)},[w]),a(()=>{l.length||A||(C([]),M.current.clear(),R.current.clear(),L.current.clear(),D.current=-1)},[l,A]);const N=d(()=>v&&"function"==typeof(null==v?void 0:v.sendAIImageRequest)?null==v?void 0:v.sendAIImageRequest:()=>Promise.resolve({}),[v]),j=c(e=>{const t=`${A}-${e.progress}-${JSON.stringify(e.images||e.data)}`;if(!L.current.has(t))if(L.current.add(t),"error"!==e.status&&"Canceled"!==e.status){if(e.images){if(F(String(e.status)),100===e.progress){p(!1),h(e.images);const t=A,r=Array.isArray(e.images)?e.images:[];r.length>0&&t&&!M.current.has(t)&&(M.current.add(t),y.success({id:"AI_IMAGE_GENERERATION_SUCCESS",message:g("Images generated successfully"),placement:"bottomRight",data:{request:s,taskId:t,images:r}})),k(null),P(!1)}}else if(e.data&&(h([String(e.data)]),100===e.progress)){p(!1);const t=A,r=e.data?[String(e.data)]:[];r.length>0&&t&&!M.current.has(t)&&(M.current.add(t),y.success({id:"AI_IMAGE_GENERERATION_SUCCESS",message:g("Images generated successfully"),placement:"bottomRight",data:{request:s,taskId:t,images:r}})),k(null),P(!1)}}else p(!1),P(!1),A&&!R.current.has(A)&&(R.current.add(A),y.error({id:"AI_RESPONSE_INVALID",message:g("Something went wrong, please try again"),placement:"bottomRight",description:String(A)||void 0,data:{requestId:A,request:s,response:e},innerException:e}))},[s,h,F,g,p,A,y,P]),D=u(-1);a(()=>{if(x.length>0){const e=x.length-1;e>D.current&&(D.current=e,j(x[e]))}},[j,x]);const z=d(()=>{if(v&&"function"==typeof(null==v?void 0:v.sseQuery)){const e=null==v?void 0:v.sseQuery;return t=>e(t)}return e=>{}},[v]),B=d(()=>v&&"object"==typeof(null==v?void 0:v.handleLimitUsageEmitter)?null==v?void 0:v.handleLimitUsageEmitter:{fire:()=>{}},[v]),U=null==v?void 0:v.elementId,{projectId:V}=v,{limits:$}=(null==v?void 0:v.limits)?v:{limits:{ai_img_limit:0}},{ai_img_limit:H}=$,W=H>0&&_>=H,G=!(!(null==v?void 0:v.limits)||!v.counters)&&pr,q=c(()=>{B.fire({name:"AiImgCount",count:_+1})},[B,_]),Y=d(()=>!W&&!G,[W,G,_,H]),X=c(async()=>{F(g("Evaluating the task")),""===s||f||(p(!0),P(!0),h([]),C([]),b({event:"submit_form",action:"ai_image_generation",entity_id:U,project_id:V}),N({body:{project_id:V,request:"create-image",connection:"midjourney",message:s}}).then(e=>{var t,r,n,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===(r=null==c?void 0:c.data)||void 0===r?void 0:r.task),d=null!==(i=null!==(n=null==u?void 0:u.id)&&void 0!==n?n:A)&&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)&&(F(u.message),k(u.id)),(null==c?void 0:c.message)&&y.success({id:"AI_IMAGE_GENERATION_STARTED",message:c.message,placement:"bottomRight",data:{request:s,taskId:d,response:null==c?void 0:c.data}}),z({task_id:null==u?void 0:u.id,entity_id:U})):(p(!1),P(!1),d&&!R.current.has(d)&&(R.current.add(d),y.error({id:"AI_IMAGE_GENERATION_FAILED",message:(null==c?void 0:c.message)||g("Something went wrong, please try again"),placement:"bottomRight",description:s,data:{request:s,taskId:d,response:c},innerException:c})))}).catch(e=>{p(!1),P(!1);const t=e;return((null==t?void 0:t.error)||(null==t?void 0:t.data))&&A&&!R.current.has(A)&&(R.current.add(A),null==y||y.error({id:"AI_IMAGE_GENERATION_FAILED",message:g("Something went wrong, please try again"),placement:"bottomRight",description:s,innerException:e,data:{request:s,taskId:A,response:null==t?void 0:t.data,error:Hi(null==t?void 0:t.error)}})),t}))},[s,f,p,P,h,b,U,V,N,y,z,g,A]),K=c(()=>{Y&&X()},[Y,G,S,q,X,y,g]);a(()=>{},[v,G]);const Z=c(e=>{if(n)return;const r=e.match(/^data:image\/([A-Za-z-+/]+);base64,(.+)$/);if(!r)return;const o=r[1],a=r[2],s=atob(a),l=new Array(s.length);for(let e=0;e<s.length;e++)l[e]=s.charCodeAt(e);const c=new Uint8Array(l),u=new Blob([c],{type:`image/${o}`}),d=new File([u],"image.jpeg",{type:u.type,lastModified:Date.now()});i(!0),(async()=>{try{"function"==typeof t&&await Promise.resolve(t({file:d}))}catch(e){console.error("FM AI: customRequest error",e)}finally{i(!1)}})()},[n,i,t]);return a(()=>{(f||l.length>0)&&setTimeout(()=>{var t,n;let i=350;if(r.current){const e=null===(t=r.current)||void 0===t?void 0:t.firstChild;e&&e instanceof HTMLElement&&(i=(null===(n=r.current.getBoundingClientRect())||void 0===n?void 0:n.height)-48-e.clientHeight)}e(i)},0)},[r,l.length,f,e]),{aiImageCounter:_,setAiImageCounter:S,currentAiImgLimits:H,isFieldsDisabled:W,canGenerateImage:Y,aiImageRequest:s,imageAiList:l,setImageAiList:h,isLoadingAi:f,setIsLoadingAi:p,loadingDuringGeneration:O,setLoadingDuringGeneration:P,requestStatus:T,setRequestStatus:F,handleGenerate:K,handleLimitAiImgCount:q,convertBase64ToFile:Z,isShiftPressed:E,setIsShiftPressed:I,currentReqId:A,setCurrentReqId:k,limitsInPlugin:G}}({setFrameHeight:C,customRequest:r,aiTabRef:w,isImageUploaded:s,setIsImageUploaded:l,aiImageRequest:h,imageAiList:p,setImageAiList:g,isLoadingAi:m,setIsLoadingAi:v});a(()=>{},[s]);const[R,L]=o(!1),N=c(()=>L(!0),[]),D=c(()=>L(!1),[]),z=c(e=>f(e.target.value),[f]),B=c(e=>{"Shift"===e.key?P(!0):"Enter"!==e.key||O||(e.preventDefault(),E())},[O,E,P]),U=c(e=>{"Shift"===e.key&&P(!1)},[P]);return t("div",{className:qR.imageAi,ref:w,children:[M&&e(GR,{text:"images",counter:_,limits:S,wrapperStyles:{marginTop:-25}}),e($,{gutter:24,className:qR.row,children:t(H,{span:24,children:[e(T.Item,{children:t("span",{className:`ant-input-affix-wrapper ant-input-affix-wrapper-lg ${qR.inputAffixWrapper}${R?" ant-input-affix-wrapper-focused":""}`,children:[e(F.TextArea,{ref:n,onKeyDown:B,onKeyUp:U,onFocus:N,onBlur:D,autoSize:!0,allowClear:!0,className:`${qR.textAreaInputHybrid} ${qR.textarea}`,placeholder:y("Generate image"),value:h,onChange:z,spellCheck:"false"}),e("span",{className:`ant-input-suffix ${qR.inputSuffix}`,children:m||A?e(le,{className:`${qR.inputIcon} input-icon`,spin:!0}):e(b,{className:`${qR.inputIcon} input-icon`,onClick:E})})]})}),t("div",{className:qR.imageAiExample,children:[e("span",{children:y("For example:")})," ",y("A beautiful image of a sunset over a calm ocean.")]})]})}),(m||p.length>0)&&t(re,{dotPosition:"top",arrows:!0,nextArrow:e(YR,{}),prevArrow:e(XR,{}),className:qR.carousel,infinite:!1,children:[m&&!p.length&&e("div",{className:qR.loading,children:t("div",{className:"spin",children:[e(le,{style:{fontSize:48},spin:!0}),e("p",{className:"status",children:k})]})}),p.length>0&&p.map((r,n)=>t("div",{className:qR.imageItem,children:[e(HR,{images:p,frameHeight:x}),e("div",{className:"buttons",children:p.length>0&&!m&&e(j,{onClick:()=>I(`data:image/jpeg;base64, ${r}`),loading:s,icon:e(Ie,{}),children:y("Use this variant")})})]},n))]})]})};var ZR={iconsTab:"iconsTab",hasSearch:"hasSearch",iconsSearchFormCenteredContainer:"iconsSearchFormCenteredContainer",iconsSearchFormCentered:"iconsSearchFormCentered",iconsSearchFormInput:"iconsSearchFormInput",iconsSearchFormInputInput:"iconsSearchFormInputInput",iconsSearchResults:"iconsSearchResults",iconsControlsControls:"iconsControlsControls",iconsControls:"iconsControls",iconsControlElement:"iconsControlElement",iconsControlsStrokeWidth:"iconsControlsStrokeWidth",iconsControlsHeader:"iconsControlsHeader",iconsSearchFormSelect:"iconsSearchFormSelect",iconsSearchFormStyleItem:"iconsSearchFormStyleItem",iconsSearchDivider:"iconsSearchDivider",iconsGrid:"iconsGrid",iconsBottomBar:"iconsBottomBar",iconsBottomBarContent:"iconsBottomBarContent",iconsGridEmptyState:"iconsGridEmptyState",resultsContainer:"resultsContainer",playButton:"playButton",title:"title",subtitle:"subtitle",iconsGridInfiniteScroll:"iconsGridInfiniteScroll",iconsGridGrid:"iconsGridGrid",iconsGridItem:"iconsGridItem",iconsGridItemThumbnail:"iconsGridItemThumbnail",iconsGridItemSvg:"iconsGridItemSvg",iconsGridItemImg:"iconsGridItemImg",iconsGridItemName:"iconsGridItemName",iconsGridLoading:"iconsGridLoading",iconsControlsBackButton:"iconsControlsBackButton",iconsGridCheckbox:"iconsGridCheckbox",iconsGridShowCheckboxes:"iconsGridShowCheckboxes",iconsHeaderContainer:"iconsHeaderContainer",iconsHeaderContainerLeft:"iconsHeaderContainerLeft",copyToFolderModalBody:"copyToFolderModalBody",copyToFolderModalLoadingOverlay:"copyToFolderModalLoadingOverlay"};const JR=[{label:"Line",value:"line"},{label:"Solid",value:"solid"},{label:"Flat",value:"flat"},{label:"Duo",value:"duo"},{label:"Handrawn",value:"handrawn"},{label:"Creative",value:"creative"},{label:"Gradient",value:"gradient"},{label:"Remix",value:"remix"},{label:"Neon",value:"neon"},{label:"Pop",value:"pop"},{label:"Light",value:"light"},{label:"Glyph",value:"glyph"},{label:"Minimal",value:"minimal"},{label:"Outlined",value:"outlined"},{label:"Geometric",value:"geometric"},{label:"Bold",value:"bold"},{label:"Stroke",value:"stroke"},{label:"Wireframe",value:"wireframe"},{label:"Filled",value:"filled"}],QR=({query:r,onQueryChange:n,onSubmit:i,styleFilter:o,onStyleChange:a,hasResults:s=!1,inputRef:l})=>{const{t:c}=Zr(),{options:u}=Fi(),{config:d}=u,h=r.length>0&&s;return t("div",{className:ZR.iconsSearchFormCenteredContainer,children:[t(T,{layout:"inline",onFinish:i,className:h?ZR.iconsSearchResults:ZR.iconsSearchFormCentered,children:[e(T.Item,{className:ZR.iconsSearchFormInput,children:e(F,{ref:l,className:ZR.iconsSearchFormInputInput,allowClear:!0,prefix:e(bi,{size:16,strokeWidth:null==d?void 0:d.iconStrokeWidth,onClick:i}),placeholder:c("Search icons"),value:r,onChange:e=>n(e.target.value),onKeyDown:e=>"Space"===e.code&&i(),onPressEnter:i,spellCheck:"false"})}),h&&e(T.Item,{className:ZR.iconsSearchFormStyleItem,children:e(M,{allowClear:!0,placeholder:c("Style"),value:null!=o?o:void 0,onChange:e=>a(null!=e?e:null),className:ZR.iconsSearchFormSelect,options:JR.map(e=>({label:c(e.label),value:e.value}))})})]}),h&&e("div",{className:`ant-divider ${ZR.iconsSearchDivider}`,role:"separator"})]})},eL=n=>{const{t:i}=Zr(),{mode:o,colorHex:a,setColorHex:s,colorHex2:l,setColorHex2:c,colorHex3:u,setColorHex3:d,sizePx:h,setSizePx:f,strokeWidth:p,setStrokeWidth:g,showSecondColor:m,showThirdColor:v,onBack:y,styleFilter:b}=n;return t("div",{className:ZR.iconsControls,children:[e("div",{className:ZR.iconsControlsControls,children:"family"===o&&t(r,{children:[t("div",{className:ZR.iconsControlsStrokeWidth,children:[e("span",{children:i("Size")}),e(ne,{min:20,max:200,value:h,formatter:e=>`${e}px`,parser:e=>e?e.replace("px",""):"",onChange:e=>f("number"==typeof e?e:50)})]}),t("div",{className:ZR.iconsControlsStrokeWidth,children:[e("span",{children:i("Stroke width")}),e(ne,{min:.3,max:3,step:.1,value:"number"==typeof p?p:1,formatter:e=>`${e}px`,parser:e=>e?e.replace("px",""):"",onChange:e=>g("number"==typeof e?e:1)})]}),"gradient"===b?e(D,{size:8,children:e(ie,{defaultValue:[{color:a||"#108ee9",percent:0},{color:l||"#87d068",percent:100}],showText:!0,mode:"gradient",onChangeComplete:e=>{try{const t=e.toCssString().match(/(rgba?\([^)]+\)|#[0-9a-fA-F]{3,8})/g)||[];t[0]&&s(t[0]),t[1]&&c(t[1])}catch(e){console.warn("ColorPicker gradient parsing error",e)}},size:"small"})}):t(r,{children:[t("div",{className:ZR.iconsControlElement,children:[e("span",{children:i("Color1")}),e(ie,{value:a,format:"hex",disabledAlpha:!0,onChange:(e,t)=>s(t),size:"middle"})]}),m&&t("div",{className:ZR.iconsControlElement,children:[e("span",{children:i("Color2")}),e(ie,{value:l,format:"hex",disabledAlpha:!0,onChange:(e,t)=>c(t),size:"middle"})]}),v&&t("div",{className:ZR.iconsControlElement,children:[e("span",{children:i("Color3")}),e(ie,{value:u,format:"hex",disabledAlpha:!0,onChange:(e,t)=>d(t),size:"middle"})]})]})]})}),e("div",{className:ZR.iconsControlsHeader,children:e("div",{children:"family"===o?e(j,{className:ZR.iconsControlsBackButton,type:"default",onClick:y,title:i("Back"),children:i("Back")}):null})})]})},tL=e(le,{style:{fontSize:20},spin:!0}),rL=({items:r,hasMore:n,loading:i,hasQuery:o,mode:a,selectedHash:s,onLoadMore:l,onItemClick:c,onInsert:u,scrollContainerRef:d,colorVars:h,svgTextMap:f,previewSize:p,selectedHashes:g,onToggleSelect:m})=>{const{t:v}=Zr(),{ThumbsUpIcon:y}=Va(),b=Boolean(g&&g.size>0),w=e("div",o?{className:ZR.iconsGridEmptyState,children:e(qa,{})}:{className:ZR.iconsGridEmptyState,children:t("div",{className:ZR.resultsContainer,children:[e("span",{className:ZR.videoIcon,children:e(y,{className:ZR.playButton,style:{width:48,height:49,marginBottom:10}})}),e("h1",{className:ZR.title,children:v("Millions of icons")}),e("p",{className:ZR.subtitle,children:v("Enter a search query and we'll find the perfect icon for you")})]})});return t("div",{id:"iconsScrollableDiv",ref:d,className:ZR.iconsGrid,children:[0!==r.length||i?e(ER,{dataLength:r.length,next:l,hasMore:n,scrollableTarget:"iconsScrollableDiv",className:ZR.iconsGridInfiniteScroll,loader:e(A,{indicator:tL}),children:e("div",{className:`${ZR.iconsGridGrid} ${b?ZR.iconsGridShowCheckboxes:""}`,style:{"--icons-grid-min-col":`${Math.max(100,(null!=p?p:50)+48)}px`},children:r.map(r=>{var n,i,o,l,u,d,v,y,b,w,x;return t("div",{style:{border:g&&g.has(r.hash)||s===r.hash?"1px solid #1890ff":"1px solid #f0f0f0",boxShadow:g&&g.has(r.hash)||s===r.hash?"0 0 0 2px rgba(24,144,255,0.2)":"none"},className:ZR.iconsGridItem,onClick:()=>{c(r),m&&"family"===a&&m(r.hash)},children:[e("div",{style:{height:null!=p?p:50},className:ZR.iconsGridItemThumbnail,children:"family"===a&&f[r.hash]?e("div",{style:{color:null==h?void 0:h.colorHex,"--icon-grad-1":null!==(n=null==h?void 0:h.colorHex)&&void 0!==n?n:"#000","--icon-grad-2":null!==(i=null==h?void 0:h.colorHex2)&&void 0!==i?i:"#ff007a","--icon-color-1":null!==(o=null==h?void 0:h.colorHex)&&void 0!==o?o:"#000","--icon-color-2":null!==(l=null==h?void 0:h.colorHex2)&&void 0!==l?l:"#ff007a","--icon-color-3":null!==(u=null==h?void 0:h.colorHex3)&&void 0!==u?u:"#00C2FF","--icon-stroke-1":null!==(d=null==h?void 0:h.colorHex)&&void 0!==d?d:"#000","--icon-stroke-2":null!==(v=null==h?void 0:h.colorHex2)&&void 0!==v?v:"#ff007a","--icon-stroke-3":null!==(y=null==h?void 0:h.colorHex3)&&void 0!==y?y:"#00C2FF","--icon-fill-1":null!==(b=null==h?void 0:h.colorHex)&&void 0!==b?b:"#000","--icon-fill-2":null!==(w=null==h?void 0:h.colorHex2)&&void 0!==w?w:"#ff007a","--icon-fill-3":null!==(x=null==h?void 0:h.colorHex3)&&void 0!==x?x:"#00C2FF"},dangerouslySetInnerHTML:{__html:f[r.hash]},className:ZR.iconsGridItemSvg}):e("img",{src:r.imagePreviewUrl,alt:r.name,style:{maxHeight:null!=p?p:96},className:ZR.iconsGridItemImg})}),e("div",{className:ZR.iconsGridItemName,title:r.name,children:r.name}),m?e("div",{onClick:e=>{e.stopPropagation()},className:ZR.iconsGridCheckbox,children:e(R,{checked:Boolean(g&&g.has(r.hash)),onChange:()=>m(r.hash)})}):null]},r.hash)})})}):w,!i&&n&&r.length>0&&e("div",{style:{height:1},ref:e=>{if(!e||!d.current)return;const t=d.current;t.scrollHeight<=t.clientHeight&&l()}}),i&&0===r.length&&e("div",{className:ZR.iconsGridLoading,children:e(A,{indicator:tL})})]})},nL="path|rect|circle|ellipse|polygon|line|polyline|g";function iL(e){const t=e.trim();if(!t||"none"===t||"transparent"===t)return null;if(/^url\(#/.test(t))return null;if(/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/.test(t)){const e=t.match(/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})/);return e?"#"+(3===e[1].length?e[1].replace(/(.)/g,"$1$1"):e[1]).toLowerCase():null}if(/^rgb\(/.test(t)){const e=t.match(/^rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/);if(e)return"#"+[1,2,3].map(t=>parseInt(e[t],10).toString(16).padStart(2,"0")).join("")}if(/^rgba\(/.test(t)){const e=t.match(/^rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*[\d.]+\s*\)/);if(e)return"#"+[1,2,3].map(t=>parseInt(e[t],10).toString(16).padStart(2,"0")).join("")}const r={black:"#000000",white:"#ffffff",red:"#ff0000",green:"#008000",blue:"#0000ff"},n=t.toLowerCase();return r[n]?r[n]:("currentcolor"===n||"inherit"===n||/^[a-zA-Z]+$/.test(t),null)}function oL(e,t){const r=new RegExp(`${t}\\s*:\\s*([^;]+)`,"i"),n=e.match(r);return n?n[1].trim():null}function aL(e){let t=0;const r=new RegExp(`<(?:${nL})([^>]*)>`,"gi");let n;for(;null!==(n=r.exec(e));){const e=n[1],r=e.match(/fill\s*=\s*["']([^"']*)["']/i),i=e.match(/style\s*=\s*["']([^"']*)["']/i),o=r&&r[1]&&!/^none$/i.test(r[1])&&!/^url\(#/i.test(r[1]),a=i&&oL(i[1],"fill")&&!/^none$/i.test(oL(i[1],"fill"));(o||a)&&(t+=1)}return t}function sL(e){let t=0;const r=new RegExp(`<(?:${nL})([^>]*)>`,"gi");let n;for(;null!==(n=r.exec(e));){const e=n[1],r=e.match(/stroke\s*=\s*["']([^"']*)["']/i),i=e.match(/style\s*=\s*["']([^"']*)["']/i),o=r&&r[1]&&!/^none$/i.test(r[1])&&!/^url\(#/i.test(r[1]),a=i&&oL(i[1],"stroke")&&!/^none$/i.test(oL(i[1],"stroke"));(o||a)&&(t+=1)}return t}function lL(e){return/<linearGradient/i.test(e)||/<radialGradient/i.test(e)||/fill="url\(#|stroke="url\(#/i.test(e)}function cL(e){const t=e.trim().replace(/(?:px|em|ex|%)\s*$/i,""),r=parseFloat(t);return Number.isNaN(r)||r<=0||r>10?null:Math.round(10*r)/10}function uL(e){const t=[],r=e.indexOf("</defs>"),n=r>=0?e.slice(r):e,i=new RegExp(`<(?:${nL})[^>]*stroke-width\\s*=\\s*["']([^"']+)["']`,"gi");let o;for(;null!==(o=i.exec(n));){const e=cL(o[1]);null!=e&&t.push(e)}const a=new RegExp(`<(?:${nL})[^>]*style\\s*=\\s*["'][^"']*stroke-width\\s*:\\s*([^;"]+)[^"']*["']`,"gi");for(;null!==(o=a.exec(n));){const e=cL(o[1]);null!=e&&t.push(e)}if(0===t.length)return;t.sort((e,t)=>e-t);const s=Math.floor(t.length/2);return t.length%2==1?t[s]:(t[s-1]+t[s])/2}function dL(e){const t=function(e){const t=[],r=new Set;Array.from(e.matchAll(/<stop[^>]*?stop-color\s*=\s*["']([^"']+)["']/gi)).map(e=>e[1]).forEach(e=>{const n=iL(e);n&&!r.has(n)&&(r.add(n),t.push(e))});const n=new RegExp(`<(?:${nL})([^>]*)>`,"gi");let i;for(;null!==(i=n.exec(e));){const e=i[1],n=e.match(/fill\s*=\s*["']([^"']*)["']/i);if(n&&n[1]){const e=iL(n[1]);e&&!r.has(e)&&(r.add(e),t.push(n[1]))}const o=e.match(/stroke\s*=\s*["']([^"']*)["']/i);if(o&&o[1]){const e=iL(o[1]);e&&!r.has(e)&&(r.add(e),t.push(o[1]))}const a=e.match(/style\s*=\s*["']([^"']*)["']/i);if(a&&a[1]){const e=oL(a[1],"fill");if(e){const n=iL(e);n&&!r.has(n)&&(r.add(n),t.push(e))}const n=oL(a[1],"stroke");if(n){const e=iL(n);e&&!r.has(e)&&(r.add(e),t.push(n))}}}const o=e.match(/<svg([^>]*)>/i);if(o&&o[1]){const e=o[1];for(const[n,i]of[["fill",/fill\s*=\s*["']([^"']*)["']/i],["stroke",/stroke\s*=\s*["']([^"']*)["']/i]]){const n=e.match(i);if(n&&n[1]){const e=iL(n[1]);e&&!r.has(e)&&(r.add(e),t.push(n[1]))}}const n=e.match(/style\s*=\s*["']([^"']*)["']/i);if(n&&n[1])for(const e of["fill","stroke"]){const i=oL(n[1],e);if(i){const e=iL(i);e&&!r.has(e)&&(r.add(e),t.push(i))}}}return t}(e);return{colors:t,fillsCount:aL(e),strokesCount:sL(e),hasGradient:lL(e),strokeWidth:uL(e)}}const hL=new Map,fL="https://public-api.streamlinehq.com/v1";function pL(e,t,r,n){const o=i.useMemo(()=>t&&"string"==typeof t?t.replace(/\/$/,""):"/streamline",[t]),a=async e=>r?Promise.resolve(r(e)):e,s=null==n?void 0:n.trim(),l=i.useCallback(async e=>r?a(function(e){const{mode:t,q:r,offset:n,limit:i,familySlug:o,style:a}=e,s=new URLSearchParams;"global"===t&&(s.set("productType","icons"),s.set("productTier","free")),s.set("query",r),s.set("offset",String(n)),s.set("limit",String(i)),a&&s.set("style",a);const l="global"===t?"search/global":`search/family/${encodeURIComponent(o||"")}`;return`${fL}/${l}?${s.toString()}`}(e)):function(e,t){const{mode:r,q:n,offset:i,limit:o,familySlug:a,style:s}=t,l="global"===r?"search/global":`search/family/${encodeURIComponent(a||"")}`,c=new URL(`${e}/${l}`,window.location.origin);return"global"===r&&(c.searchParams.set("productType","icons"),c.searchParams.set("productTier","free")),c.searchParams.set("query",n),c.searchParams.set("offset",String(i)),c.searchParams.set("limit",String(o)),s&&c.searchParams.set("style",s),c.toString().replace(window.location.origin,"")}(o,e),[o,r]),c=i.useCallback(async e=>{var t;const r=await l({mode:e.mode,q:e.query.trim(),offset:e.offset,limit:e.limit,familySlug:e.familySlug,style:null!==(t=e.style)&&void 0!==t?t:null}),n={Accept:"application/json"};s&&(n["x-api-key"]=s);const i=await fetch(r,{method:"GET",headers:n,signal:e.signal});if(!i.ok){const e=await i.text();throw new Error(`Request failed: ${i.status} ${e}`)}return await i.json()},[l,s]),u=i.useCallback((e,t)=>{let r=e;const n=/<linearGradient[\s\S]*?<\/linearGradient>/i.test(r)||/<radialGradient[\s\S]*?<\/radialGradient>/i.test(r);if(!(/fill="url\(#/i.test(r)||/stroke="url\(#/i.test(r))){const e=function(e){var t,r,n,i,o,a,s,l;const c=new Map,u={v:1},d=e=>{const t=iL(e);t&&!c.has(t)&&(c.set(t,u.v),u.v=Math.min(u.v+1,3))},h=e.match(/<svg([^>]*)>/i);if(null==h?void 0:h[1]){const e=h[1],t=e.match(/fill\s*=\s*["']([^"']*)["']/i),r=e.match(/stroke\s*=\s*["']([^"']*)["']/i);!(null==t?void 0:t[1])||/^none$/i.test(t[1])||/^url\(#/i.test(t[1])||d(t[1]),!(null==r?void 0:r[1])||/^none$/i.test(r[1])||/^url\(#/i.test(r[1])||d(r[1])}const f=new RegExp(`<(?:${nL})([^>]*)>`,"gi");let p;for(;null!==(p=f.exec(e));){const e=p[1],c=e.match(/fill\s*=\s*["']([^"']*)["']/i),u=e.match(/style\s*=\s*["']([^"']*)["']/i),h=null===(t=null==u?void 0:u[1])||void 0===t?void 0:t.match(/fill\s*:\s*([^;]+)/i),f=null===(i=null!==(r=null==c?void 0:c[1])&&void 0!==r?r:null===(n=null==h?void 0:h[1])||void 0===n?void 0:n.trim())||void 0===i?void 0:i.trim();!f||/^none$/i.test(f)||/^url\(#/i.test(f)||d(f);const g=e.match(/stroke\s*=\s*["']([^"']*)["']/i),m=e.match(/style\s*=\s*["']([^"']*)["']/i),v=null===(o=null==m?void 0:m[1])||void 0===o?void 0:o.match(/stroke\s*:\s*([^;]+)/i),y=null===(l=null!==(a=null==g?void 0:g[1])&&void 0!==a?a:null===(s=null==v?void 0:v[1])||void 0===s?void 0:s.trim())||void 0===l?void 0:l.trim();!y||/^none$/i.test(y)||/^url\(#/i.test(y)||d(y)}return c}(r),t=t=>{const r=iL(t),n=r?e.get(r):void 0;return 1===n?"var(--icon-color-1)":2===n?"var(--icon-color-2)":3===n?"var(--icon-color-3)":"currentColor"};r=r.replace(/<svg([^>]*)>/i,(e,r)=>{let n=r;const i=r.match(/fill\s*=\s*["']([^"']*)["']/i);!(null==i?void 0:i[1])||/^none$/i.test(i[1])||/^url\(#/i.test(i[1])||(n=n.replace(/fill\s*=\s*["'][^"']*["']/i,`fill="${t(i[1])}"`));const o=r.match(/stroke\s*=\s*["']([^"']*)["']/i);return!(null==o?void 0:o[1])||/^none$/i.test(o[1])||/^url\(#/i.test(o[1])||(n=n.replace(/stroke\s*=\s*["'][^"']*["']/i,`stroke="${t(o[1])}"`)),`<svg${n}>`}),r=r.replace(/<(path|rect|circle|ellipse|polygon|line|polyline)([^>]*?)(\/>|>)/gi,(e,r,n,i)=>{var o,a,s,l,c,u,d,h;let f=n;const p=n.match(/fill\s*=\s*["']([^"']*)["']/i),g=n.match(/style\s*=\s*["']([^"']*)["']/i),m=null===(o=null==g?void 0:g[1])||void 0===o?void 0:o.match(/fill\s*:\s*([^;]+)/i),v=null===(l=null!==(a=null==p?void 0:p[1])&&void 0!==a?a:null===(s=null==m?void 0:m[1])||void 0===s?void 0:s.trim())||void 0===l?void 0:l.trim();if(v&&!/^none$/i.test(v)&&!/^url\(#/i.test(v)){const e=t(v);p?f=f.replace(/fill\s*=\s*["'][^"']*["']/i,`fill="${e}"`):(null==g?void 0:g[1])&&(f=f.replace(/style\s*=\s*["']([^"']*)["']/i,(t,r)=>`style="${r.replace(/fill\s*:\s*[^;]+/gi,`fill: ${e}`)}"`))}const y=n.match(/stroke\s*=\s*["']([^"']*)["']/i),b=n.match(/style\s*=\s*["']([^"']*)["']/i),w=null===(c=null==b?void 0:b[1])||void 0===c?void 0:c.match(/stroke\s*:\s*([^;]+)/i),x=null===(h=null!==(u=null==y?void 0:y[1])&&void 0!==u?u:null===(d=null==w?void 0:w[1])||void 0===d?void 0:d.trim())||void 0===h?void 0:h.trim();if(x&&!/^none$/i.test(x)&&!/^url\(#/i.test(x)){const e=t(x);y?f=f.replace(/stroke\s*=\s*["'][^"']*["']/i,`stroke="${e}"`):(null==b?void 0:b[1])&&(f=f.replace(/style\s*=\s*["']([^"']*)["']/i,(t,r)=>`style="${r.replace(/stroke\s*:\s*[^;]+/gi,`stroke: ${e}`)}"`))}return`<${r}${f}${i}`})}return n&&(r=r.replace(/<linearGradient([^>]*?)>([\s\S]*?)<\/linearGradient>/gi,(e,t,r)=>{let n=0;return`<linearGradient${t}>${r.replace(/<stop([^>]*?)>/gi,(e,t)=>{const r=0===n?"var(--icon-grad-1)":"var(--icon-grad-2)";if(n+=1,/stop-color\s*=/.test(t)){return"<stop"+t.replace(/stop-color="[^"]*"/i,'stop-color="'+r+'"')+">"}return"<stop"+t+' stop-color="'+r+'">'})}</linearGradient>`}),r=r.replace(/<radialGradient([^>]*?)>([\s\S]*?)<\/radialGradient>/gi,(e,t,r)=>{let n=0;return`<radialGradient${t}>${r.replace(/<stop([^>]*?)>/gi,(e,t)=>{const r=0===n?"var(--icon-grad-1)":"var(--icon-grad-2)";if(n+=1,/stop-color\s*=/.test(t)){return"<stop"+t.replace(/stop-color="[^"]*"/i,'stop-color="'+r+'"')+">"}return"<stop"+t+' stop-color="'+r+'">'})}</radialGradient>`})),"number"!=typeof(null==t?void 0:t.strokeWidth)||Number.isNaN(t.strokeWidth)||(/stroke-width\s*=\s*["'][^"']*["']/i.test(r)&&(r=r.replace(/stroke-width\s*=\s*["'][^"']*["']/gi,`stroke-width="${t.strokeWidth}"`)),/stroke-width\s*:/.test(r)&&(r=r.replace(/stroke-width\s*:\s*[^;]+/gi,`stroke-width: ${t.strokeWidth}`)),/stroke-width/i.test(r)||(r=r.replace(/<svg/,`<svg stroke-width="${t.strokeWidth}"`))),r=r.replace(/<svg([^>]*)>/i,(e,t)=>`<svg${t.replace(/\swidth="[^"]*"/i,"").replace(/\sheight="[^"]*"/i,"")} width="100%" height="100%">`),r},[]),d=i.useCallback(async(t,n)=>{const i=[t,e?"css=1":"css=0",(null==n?void 0:n.colors)?`c=${n.colors}`:"",(null==n?void 0:n.backgroundColor)?`bg=${n.backgroundColor}`:"",null!=(null==n?void 0:n.strokeWidth)?`sw=${n.strokeWidth}`:"",null!=(null==n?void 0:n.size)?`s=${n.size}`:"",null!=(null==n?void 0:n.responsive)?`r=${n.responsive}`:"",null!=(null==n?void 0:n.strokeToFill)?`sf=${n.strokeToFill}`:""].filter(Boolean).join("|"),l=hL.get(i);if(l)return l;const c=await(async(e,t)=>{var n,i;const s=new URLSearchParams;(null==t?void 0:t.colors)&&s.set("colors",t.colors),(null==t?void 0:t.backgroundColor)&&s.set("backgroundColor",t.backgroundColor),null!=(null==t?void 0:t.strokeWidth)&&s.set("strokeWidth",String(t.strokeWidth)),s.set("size",String(null!==(n=null==t?void 0:t.size)&&void 0!==n?n:96)),s.set("responsive",String(null===(i=null==t?void 0:t.responsive)||void 0===i||i)),null!=(null==t?void 0:t.strokeToFill)&&s.set("strokeToFill",String(t.strokeToFill));const l=`${fL}/icons/${encodeURIComponent(e)}/download/svg?${s.toString()}`;if(r)return a(l);const c=new URL(`${o}/icons/${encodeURIComponent(e)}/download/svg`,window.location.origin);return s.forEach((e,t)=>c.searchParams.set(t,e)),c.toString().replace(window.location.origin,"")})(t,n),d={Accept:"image/svg+xml"};s&&(d["x-api-key"]=s);const h=await fetch(c,{method:"GET",headers:d,signal:null==n?void 0:n.signal});if(!h.ok){const e=await h.text();throw new Error(`SVG request failed: ${h.status} ${e}`)}let f=await h.text();const p=f;e&&!(null==n?void 0:n.colors)&&(f=u(f,{strokeWidth:null==n?void 0:n.strokeWidth}));const g={text:f,url:`data:image/svg+xml;utf8,${encodeURIComponent(f)}`,original:p};return hL.set(i,g),g},[o,u,e,r,a,s]),h=i.useCallback(async(e,t)=>{const n=await(async(e,t)=>{var n;const i=new URLSearchParams;i.set("size",String(null!==(n=null==t?void 0:t.size)&&void 0!==n?n:96)),(null==t?void 0:t.colors)&&i.set("colors",t.colors),(null==t?void 0:t.backgroundColor)&&i.set("backgroundColor",t.backgroundColor),null!=(null==t?void 0:t.strokeWidth)&&i.set("strokeWidth",String(t.strokeWidth));const s=`${fL}/icons/${encodeURIComponent(e)}/download/png?${i.toString()}`;if(r)return a(s);const l=new URL(`${o}/icons/${encodeURIComponent(e)}/download/png`,window.location.origin);return i.forEach((e,t)=>l.searchParams.set(t,e)),l.toString().replace(window.location.origin,"")})(e,t),i={Accept:"image/png"};s&&(i["x-api-key"]=s);const l=await fetch(n,{method:"GET",headers:i,signal:null==t?void 0:t.signal});if(!l.ok){const e=await l.text();throw new Error(`PNG request failed: ${l.status} ${e}`)}const c=await l.blob();return await new Promise((e,t)=>{const r=new FileReader;r.onload=()=>e(r.result),r.onerror=()=>t(new Error("Failed to read PNG blob")),r.readAsDataURL(c)})},[o,r,a,s]);return{buildUrl:l,performSearch:c,fetchSvgDataUrl:d,fetchPngDataUrl:h,normalizeSvgForCss:u}}const gL=({apiKey:n,customRequest:o,query:a,setQuery:s,inputRef:l})=>{var c,u,d,h,f,p,g,m,v;const{t:y}=Zr(),[b,w]=i.useState(""),x=void 0!==a?a:b,C=void 0!==s?s:w,[_,S]=i.useState(""),[k,E]=i.useState("global"),[I,O]=i.useState(null),[M,R]=i.useState(null),[L,N]=i.useState(null),[z,B]=i.useState(null),[U,V]=i.useState([]),[$,H]=i.useState(0),[W,G]=i.useState(!1),[Y,X]=i.useState(!1),[Z,J]=i.useState(null),[Q,ee]=i.useState({}),[te,re]=i.useState({}),[ne,ie]=i.useState({}),[ae,se]=i.useState("#000000"),[le,ce]=i.useState("#ff007a"),[ue,de]=i.useState("#00C2FF"),[he,fe]=i.useState(1),[pe,ge]=i.useState(50),[me,ve]=i.useState(!0),[ye,be]=i.useState(!0),[we,xe]=i.useState(!1),Ce=Fi(),{options:_e}=Ce,Se=i.useRef(null),Ae=i.useRef(!1),ke=i.useRef(null),Ee=i.useRef(0),Ie=i.useRef(!1),Te=i.useRef(null),Fe=i.useRef(null===(c=null==_e?void 0:_e.config)||void 0===c?void 0:c.handleTranslate),Oe=i.useRef(null===(u=null==_e?void 0:_e.config)||void 0===u?void 0:u.locale);i.useEffect(()=>{var e,t;Fe.current=null===(e=null==_e?void 0:_e.config)||void 0===e?void 0:e.handleTranslate,Oe.current=null===(t=null==_e?void 0:_e.config)||void 0===t?void 0:t.locale},[null===(d=null==_e?void 0:_e.config)||void 0===d?void 0:d.handleTranslate,null===(h=null==_e?void 0:_e.config)||void 0===h?void 0:h.locale]);const Pe=i.useRef(null),Me=i.useRef(null),Re=i.useRef(null),[Le,Ne]=i.useState(new Set),je=null!==(p=null===(f=null==_e?void 0:_e.config)||void 0===f?void 0:f.STREAMLINE_API_KEY)&&void 0!==p?p:"3pAQQzwUNMmcgSr2.f4eb08cd5886d44b1fc6a701a3ba797c",De=null===(g=null==_e?void 0:_e.config)||void 0===g?void 0:g.handleProxyUrl,ze=async e=>De?Promise.resolve(De(e)):e,Be=async e=>Promise.all(e.map(async e=>Object.assign(Object.assign({},e),{imagePreviewUrl:await ze(e.imagePreviewUrl)}))),{performSearch:Ue,fetchSvgDataUrl:Ve,fetchPngDataUrl:$e,normalizeSvgForCss:He}=pL(ye,null===(m=null==_e?void 0:_e.config)||void 0===m?void 0:m.STREAMLINE_BASE_URL,De,je),We=i.useMemo(()=>{if("family"!==k||0===U.length)return null;const e=new Set(U.map(e=>e.hash)),t=Object.keys(ne).some(t=>e.has(t))?ne:te,r=U.map(e=>t[e.hash]).filter(e=>Boolean(e));if(0===r.length)return null;return function(e){const t=[],r=new Set;let n,i=0,o=0,a=!1;for(const s of e){i+=s.fillsCount,o+=s.strokesCount,s.hasGradient&&(a=!0);for(const e of s.colors){const n=iL(e);n&&!r.has(n)&&(r.add(n),t.push(e))}null==n&&null!=s.strokeWidth&&(n=s.strokeWidth)}return{colors:t,fillsCount:i,strokesCount:o,hasGradient:a,strokeWidth:n}}(r.map(e=>dL(e)))},[U,k,ne,te]);i.useMemo(()=>"family"===k&&(!!(null==We?void 0:We.hasGradient)||!!(I||"").toLowerCase().includes("gradient")),[We,I,k]);const Ge=i.useMemo(()=>"family"===k&&U.some(e=>{const t=te[e.hash];return t&&/var\(--icon-color-2\)/i.test(t)}),[U,k,te]),qe=i.useMemo(()=>"family"===k&&U.some(e=>{const t=te[e.hash];return t&&/var\(--icon-color-3\)/i.test(t)}),[U,k,te]),Ye=i.useMemo(()=>!!ye&&(!!We&&(We.hasGradient||We.colors.length>=2&&Ge)),[We,ye,Ge]),Xe=i.useMemo(()=>!!ye&&(!!We&&(We.colors.length>=3&&qe)),[We,ye,qe]);i.useEffect(()=>(Ae.current=!0,()=>{var e,t,r;Ae.current=!1;try{null===(e=Pe.current)||void 0===e||e.abort(),null===(t=Me.current)||void 0===t||t.abort(),null===(r=Re.current)||void 0===r||r.abort()}catch(e){}}),[]);const Ke=i.useRef(x),Ze=i.useCallback(async e=>{var t,r,n,i,o,a,s,l;const c=null!==(r=null===(t=e.override)||void 0===t?void 0:t.query)&&void 0!==r?r:_;if(!c||0===c.trim().length)return;if(Y)return;if(!Ae.current)return;null===(n=Pe.current)||void 0===n||n.abort();const u=new AbortController;Pe.current=u,X(!0);const d=e.initial?0:$,h=e.initial?30:20,f=null!==(o=null===(i=e.override)||void 0===i?void 0:i.mode)&&void 0!==o?o:k,p=null!==(s=null===(a=e.override)||void 0===a?void 0:a.familySlug)&&void 0!==s?s:I,g=c.trim();try{const t=await Ue({mode:f,familySlug:p||null,query:g,offset:d,limit:h,style:L,signal:u.signal});if(!Ae.current)return;if(e.initial)V(await Be(t.results));else{const e=await Be(t.results);V(t=>[...t,...e])}G(Boolean(null===(l=t.pagination)||void 0===l?void 0:l.hasMore)),H(d+h)}catch(e){if("AbortError"===(null==e?void 0:e.name))return;console.error(e),oe.error(y("Request error"))}finally{Ae.current&&X(!1)}},[_,I,De,U,Y,k,$,Ue,L,y]);i.useEffect(()=>{Te.current=Ze},[Ze]),i.useEffect(()=>{if("family"===k){const e=window.setTimeout(()=>{Ie.current=!1},100);return()=>window.clearTimeout(e)}Ie.current=!1},[k]);const Je=i.useCallback(async e=>{var t;if(!e||0===e.trim().length)return;const r=++Ee.current;let n=e.trim();if(Fe.current)try{n=await Fe.current(e,{locale:Oe.current})}catch(t){console.error("IconsTab: translation error",t),n=e}r===Ee.current&&(E("global"),O(null),B(null),V([]),G(!1),H(0),J(null),Ne(new Set),S(n),await(null===(t=Te.current)||void 0===t?void 0:t.call(Te,{initial:!0,override:{query:n}})))},[]),Qe=i.useCallback(async()=>{x&&0!==x.trim().length&&await Je(x)},[x,Je]),et=i.useCallback(()=>{Ee.current+=1,E("global"),O(null),R(null),B(null),N(null),S(""),V([]),G(!1),H(0),J(null),Ne(new Set),se("#000000"),ce("#ff007a"),de("#00C2FF")},[]);i.useEffect(()=>{const e=Ke.current;e&&e.trim().length>=3&&Je(e)},[]),i.useEffect(()=>{const e=x.trim();ke.current&&(window.clearTimeout(ke.current),ke.current=null),e.length<3?et():ke.current=window.setTimeout(()=>{Je(e)},700)},[x,L,et,Je]);const tt=i.useCallback(()=>{Ie.current||W&&!Y&&Ze({initial:!1})},[Ze,W,Y]),rt=i.useCallback(e=>{if("global"===k){if(!e.familySlug||!_)return;return ke.current&&(window.clearTimeout(ke.current),ke.current=null),Ie.current=!0,E("family"),O(e.familySlug),R(e.hash),B(e.categoryName||null),V([]),G(!1),H(0),J(null),Ne(new Set),se("#000000"),ce("#ff007a"),de("#00C2FF"),void Ze({initial:!0,override:{mode:"family",familySlug:e.familySlug,query:_}})}J(e.hash)},[_,Ze,k]),nt=i.useCallback(()=>{const e=_.trim();E("global"),O(null),R(null),B(null),V([]),G(!1),H(0),J(null),Ne(new Set),se("#000000"),ce("#ff007a"),de("#00C2FF"),e&&Ze({initial:!0,override:{mode:"global",familySlug:null,query:e}})},[_,Ze]);i.useEffect(()=>{var e;if("family"!==k||0===U.length)return;const t=new Set(U.map(e=>e.hash));let r=U.map(e=>e.hash).filter(e=>!Q[e]||!te[e]);if(!M||t.has(M)||ne[M]||(r=[M,...r]),0===r.length)return;let n=!1;null===(e=Me.current)||void 0===e||e.abort();const i=new AbortController;return Me.current=i,Promise.all(r.map(e=>Ve(e,{colors:ye?void 0:ae,strokeWidth:he,size:pe,responsive:me,signal:i.signal}).then(t=>({h:e,r:t})).catch(()=>null))).then(e=>{if(n||!Ae.current)return;const t={},r={},i={};e.forEach(e=>{e&&e.h&&e.r&&(t[e.h]=e.r.url,r[e.h]=e.r.text,e.r.original&&(i[e.h]=e.r.original))}),Object.keys(t).length>0&&ee(e=>Object.assign(Object.assign({},e),t)),Object.keys(r).length>0&&re(e=>Object.assign(Object.assign({},e),r)),Object.keys(i).length>0&&ie(e=>Object.assign(Object.assign({},e),i))}),()=>{n=!0,i.abort()}},[ae,M,Ve,U,k,ne,me,pe,he,te,Q,ye]),i.useEffect(()=>{if("family"!==k)return;if(0===U.length)return;const e=U.map(e=>e.hash),t={},r={};let n=!1;e.forEach(e=>{const i=ne[e]||te[e];if(!i)return;const o=He(i,{strokeWidth:"number"==typeof he?he:void 0});o&&o!==te[e]&&(t[e]=o,r[e]=`data:image/svg+xml;utf8,${encodeURIComponent(o)}`,n=!0)}),n&&(Object.keys(t).length>0&&re(e=>Object.assign(Object.assign({},e),t)),Object.keys(r).length>0&&ee(e=>Object.assign(Object.assign({},e),r)))},[U,k,He,ne,he,te]);const it=i.useRef(null);i.useEffect(()=>{var e;if("family"!==k||0===U.length)return;const t=M&&ne[M]?M:null===(e=U[0])||void 0===e?void 0:e.hash;if(!t||!ne[t])return;if(it.current===I)return;const r=ne[t];if(!r)return;it.current=I;const n=function(e){var t,r,n,i,o,a,s,l;const c=[],u=new Set,d=e=>{const t=iL(e);t&&!u.has(t)&&(u.add(t),c.push(e))},h=Array.from(e.matchAll(/<stop[^>]*?stop-color\s*=\s*["']([^"']+)["']/gi)).map(e=>e[1]);if(h.length>=2)return h.slice(0,3).forEach(e=>d(e)),c;const f=e.match(/<svg([^>]*)>/i);if(null==f?void 0:f[1]){const e=f[1],t=e.match(/fill\s*=\s*["']([^"']*)["']/i),r=e.match(/stroke\s*=\s*["']([^"']*)["']/i);!(null==t?void 0:t[1])||/^none$/i.test(t[1])||/^url\(#/i.test(t[1])||d(t[1]),!(null==r?void 0:r[1])||/^none$/i.test(r[1])||/^url\(#/i.test(r[1])||d(r[1])}const p=new RegExp(`<(?:${nL})([^>]*)>`,"gi");let g;for(;null!==(g=p.exec(e));){const e=g[1],c=e.match(/fill\s*=\s*["']([^"']*)["']/i),u=e.match(/style\s*=\s*["']([^"']*)["']/i),h=null===(t=null==u?void 0:u[1])||void 0===t?void 0:t.match(/fill\s*:\s*([^;]+)/i),f=null===(i=null!==(r=null==c?void 0:c[1])&&void 0!==r?r:null===(n=null==h?void 0:h[1])||void 0===n?void 0:n.trim())||void 0===i?void 0:i.trim();!f||/^none$/i.test(f)||/^url\(#/i.test(f)||d(f);const p=e.match(/stroke\s*=\s*["']([^"']*)["']/i),m=e.match(/style\s*=\s*["']([^"']*)["']/i),v=null===(o=null==m?void 0:m[1])||void 0===o?void 0:o.match(/stroke\s*:\s*([^;]+)/i),y=null===(l=null!==(a=null==p?void 0:p[1])&&void 0!==a?a:null===(s=null==v?void 0:v[1])||void 0===s?void 0:s.trim())||void 0===l?void 0:l.trim();!y||/^none$/i.test(y)||/^url\(#/i.test(y)||d(y)}return c.slice(0,3)}(r),i=e=>{const t=(e||"").trim().match(/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/);if(t){return"#"+(3===t[1].length?t[1].replace(/(.)/g,"$1$1"):t[1]).toLowerCase()}return function(e){var t;const r=e.trim();if(/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/.test(r)){const e=r.match(/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})/);if(e)return"#"+(3===e[1].length?e[1].replace(/(.)/g,"$1$1"):e[1]).toLowerCase()}const n=r.match(/^rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/);if(n)return"#"+[1,2,3].map(e=>parseInt(n[e],10).toString(16).padStart(2,"0")).join("");const i=r.match(/^rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*[\d.]+\s*\)/);return i?"#"+[1,2,3].map(e=>parseInt(i[e],10).toString(16).padStart(2,"0")).join(""):null!==(t={black:"#000000",white:"#ffffff",red:"#ff0000",green:"#008000",blue:"#0000ff"}[r.toLowerCase()])&&void 0!==t?t:iL(r)||"#000000"}(e)};n[0]&&se(i(n[0])),n[1]&&ce(i(n[1])),n[2]&&de(i(n[2]))},[U,k,ne,I,M]),i.useEffect(()=>{"family"!==k&&(it.current=null)},[k]);const ot=i.useRef(null);i.useEffect(()=>{if("family"!==k||!I||0===U.length)return;const e=U[0];if(!e||!ne[e.hash])return;if(ot.current===I)return;const t=ne[e.hash];if(!t)return;const r=dL(t);"number"==typeof r.strokeWidth&&r.strokeWidth>0&&(ot.current=I,fe(r.strokeWidth))},[U,k,ne,I]),i.useEffect(()=>{"family"!==k&&(ot.current=null)},[k]);const at=i.useCallback(e=>function(e,t){const{colorHex:r,colorHex2:n,colorHex3:i}=t,o=[`--icon-grad-1: ${r}`,`--icon-grad-2: ${n}`,`--icon-stroke-1: ${r}`,`--icon-stroke-2: ${n}`,`--icon-stroke-3: ${i}`,`--icon-fill-1: ${r}`,`--icon-fill-2: ${n}`,`--icon-fill-3: ${i}`,`color: ${r}`].join(";");let a=e.replace(/<svg([^>]*)>/i,(e,t)=>{let r=t;return/style="/i.test(r)?r=r.replace(/style="([^"]*)"/i,(e,t)=>`style="${t};${o}"`):r+=` style="${o}"`,`<svg${r}>`});return a=a.replace(/var\(--icon-color-1\)/g,r).replace(/var\(--icon-color-2\)/g,n).replace(/var\(--icon-color-3\)/g,i).replace(/var\(--icon-fill-1\)/g,r).replace(/var\(--icon-fill-2\)/g,n).replace(/var\(--icon-fill-3\)/g,i).replace(/var\(--icon-stroke-1\)/g,r).replace(/var\(--icon-stroke-2\)/g,n).replace(/var\(--icon-stroke-3\)/g,i).replace(/var\(--icon-grad-1\)/g,r).replace(/var\(--icon-grad-2\)/g,n).replace(/currentColor/g,r),a}(e,{colorHex:ae,colorHex2:le,colorHex3:ue}),[ae,le,ue]),st=i.useCallback(e=>{Ne(t=>{const r=new Set(t);return r.has(e)?r.delete(e):r.add(e),r})},[]),lt=i.useCallback(()=>{Ne(new Set)},[]),ct=i.useMemo(()=>{if(1===Le.size){const[e]=Array.from(Le);return U.find(t=>t.hash===e)||null}return 0===Le.size&&Z&&U.find(e=>e.hash===Z)||null},[U,Z,Le]),ut=i.useCallback((e,t="image/png")=>{try{const r=e.split(",");if(r.length<2)return new Blob([],{type:t});const n=r[1]||"",i=atob(n),o=new Array(i.length);for(let e=0;e<i.length;e+=1)o[e]=i.charCodeAt(e);const a=new Uint8Array(o);return new Blob([a],{type:t})}catch(e){return new Blob([],{type:t})}},[]),dt=i.useCallback(async(e,t)=>{try{const r=async e=>{const t="family"===k?at(e):e,r=function(e,t){const r=e.match(/\swidth="([0-9.]+)(px)?"/i),n=e.match(/\sheight="([0-9.]+)(px)?"/i);if(r&&n){const e=parseFloat(r[1]),i=parseFloat(n[1]);if(Number.isFinite(e)&&Number.isFinite(i)&&e>0&&i>0){const r=e/i;return r>=1?{width:t,height:Math.max(1,Math.round(t/r))}:{width:Math.max(1,Math.round(t*r)),height:t}}}const i=e.match(/viewBox="([^"]+)"/i);if(i){const e=i[1].trim().split(/\s+/);if(4===e.length){const r=parseFloat(e[2]),n=parseFloat(e[3]);if(Number.isFinite(r)&&Number.isFinite(n)&&r>0&&n>0){const e=r/n;return e>=1?{width:t,height:Math.max(1,Math.round(t/e))}:{width:Math.max(1,Math.round(t*e)),height:t}}}}return{width:t,height:t}}(t,pe);return async function(e,t,r){const n=new Blob([e],{type:"image/svg+xml;charset=utf-8"}),i=URL.createObjectURL(n);try{const e=new Image;return await new Promise((n,o)=>{e.onload=()=>{const i=document.createElement("canvas"),a=Math.max(1,Math.round(2*t)),s=Math.max(1,Math.round(2*r));i.width=a,i.height=s;const l=i.getContext("2d");l?(l.clearRect(0,0,a,s),l.drawImage(e,0,0,a,s),n(i.toDataURL("image/png"))):o(new Error("Canvas 2D context is not available"))},e.onerror=()=>o(new Error("Failed to load SVG image")),e.src=i})}finally{URL.revokeObjectURL(i)}}(t,r.width,r.height)},n=async e=>{const n=await Ve(e,{colors:ye?void 0:ae,strokeWidth:"number"==typeof he?he:void 0,size:pe,responsive:me,signal:t}),i=n.original||n.text;return r(i)};if("family"!==k)try{return await $e(e.hash,{size:pe,colors:ye?void 0:ae,strokeWidth:"number"==typeof he?he:void 0,signal:t})}catch(t){return e.hash?await n(e.hash):null}const i=te[e.hash]||ne[e.hash];return i?r(i):e.hash?await n(e.hash):null}catch(e){return null}},[at,ae,Ve,$e,k,ne,me,pe,he,te,ye]),ht=i.useCallback(async e=>{var t;try{if(!Ae.current)return;xe(!0),null===(t=Re.current)||void 0===t||t.abort();const r=new AbortController;Re.current=r;const n=await dt(e,r.signal);if(!Ae.current||!n)return;await Promise.resolve(o(n))}catch(e){console.error("IconsTab: insert error",e),oe.error(y("Request error"))}finally{Ae.current&&xe(!1)}},[o,dt,y]);i.useCallback(()=>{var e;J(null),lt();const t=null===(e=null==_e?void 0:_e.config)||void 0===e?void 0:e.onClose;"function"==typeof t&&t()},[lt,_e]);const{isCopyIconsModalVisible:ft,isCopyLoading:pt,copyForm:gt,openCopyModal:mt,closeCopyModal:vt,resetAfterClose:yt,handleCopyTreeSelect:bt,handleIconsCopyOk:wt,fetchChildFolders:xt,generateMenuItemsFromFolders:Ct,handleCreateFolderAndCopy:_t}=(({items:e,selectedHashes:t,getPngDataUrlForItem:r,dataUrlToBlob:n,clearSelection:o})=>{const{t:a}=Zr(),{options:s,state:l}=Fi(),c=Li(),[u,d]=i.useState(!1),[h]=T.useForm(),[f,p]=i.useState(!1),g=i.useRef(!1),{state:m,actions:{fetchFolders:v,fetchChildFolders:y,handleModalOk:b}}=io(),{EmptyFolderIcon:w}=Va(),{activeFormField:x,setActiveFormField:C,generateMenuItemsFromFolders:_}=hs({folders:Array.isArray(m.folders)?m.folders:[],selectedFolder:l.selectedFolder,EmptyFolderIcon:w,handleCreateFolderModalOk:b,setIsLoading:p,t:a}),S=i.useCallback(async()=>{await v(),d(!0)},[v]),A=i.useCallback(async e=>{e.length>0&&(h.setFieldsValue({targetFolder:e[0]}),x!==e[0].toString()&&C(""))},[x,h,C]),k=i.useCallback(async i=>{var u,d;try{const{dataProviders:d}=s;if(!d||!d.uploadFile&&!d.uploadFiles)return void c.error({id:"FILES_UPLOAD_PROVIDER_NOT_CONFIGURED",message:a("API-endpoint for file upload is not configured"),placement:"bottomRight"});const h=i||(null==l?void 0:l.selectedFolder)||void 0,f=Array.from(t);if(0===f.length)return;const p=null!==(u=d.uploadFile)&&void 0!==u?u:async e=>{var t,r,n;if(!d.uploadFiles)throw new Error("Upload is not supported by data provider");const i=await d.uploadFiles({folderId:e.folderId,items:[{name:e.name,size:e.size,type:e.type,folderId:e.folderId,data:e.data,extension:e.extension}]}),o=null===(t=null==i?void 0:i.detailed)||void 0===t?void 0:t[0];if(!i||!i.success||!o||!1===o.success){const e=(null===(r=null==o?void 0:o.error)||void 0===r?void 0:r.message)||(null===(n=null==i?void 0:i.error)||void 0===n?void 0:n.message)||"Upload failed";throw new Error(e)}return o.data},{successCount:g,failCount:m}=await async function(e){var t;const{hashes:r,items:n,folderId:i,dataProviders:o,getPngDataUrlForItem:a,dataUrlToBlob:s}=e;let l=0,c=0;for(const e of r){const r=n.find(t=>t.hash===e);if(!r){c+=1;continue}const u=await a(r);if(!u){c+=1;continue}const d=`${(null===(t=r.name)||void 0===t?void 0:t.trim())||`icon-${e}`}.png`,h=s(u,"image/png");try{await o.uploadFile({name:d,size:h.size,type:"image/png",folderId:i,data:h,extension:"png"}),l+=1}catch(e){c+=1}}return{successCount:l,failCount:c}}({hashes:f,items:e,folderId:h,dataProviders:{uploadFile:p},getPngDataUrlForItem:r,dataUrlToBlob:n});g>0&&c.success({id:"FILES_COPY_SUCCESS",message:a("Files copied"),placement:"bottomRight",data:{successCount:g,totalCount:f.length,itemIds:f,folderId:null!=h?h:null}}),m>0&&c.error({id:"FILES_COPY_ERROR",message:a("При копировании произошли ошибки"),placement:"bottomRight",data:{failCount:m,totalCount:f.length,itemIds:f,folderId:null!=h?h:null}}),o()}catch(e){console.error(e),c.error({id:"FILES_COPY_ERROR",message:a("При копировании произошли ошибки"),placement:"bottomRight",innerException:e,data:{failCount:Array.from(t).length||0,totalCount:Array.from(t).length||0,itemIds:Array.from(t),folderId:null!==(d=null==l?void 0:l.selectedFolder)&&void 0!==d?d:null}})}},[o,n,r,e,c,s,t,null==l?void 0:l.selectedFolder,a]),E=i.useCallback(()=>{f||g.current||(d(!1),C(""),p(!1))},[f,C]),I=i.useCallback(()=>{C(""),p(!1)},[C]),F=i.useCallback(async e=>{if(!g.current){g.current=!0,p(!0);try{await k(null!=e?e:null),d(!1),C("")}finally{g.current=!1,p(!1)}}},[k,C]),O=i.useCallback(()=>{var e;const t=null!==(e=l.selectedFolder)&&void 0!==e?e:"folders";C(t),h.setFieldsValue({folderName:a("New folder"),targetFolder:t})},[h,l.selectedFolder,C,a]);return{isCopyIconsModalVisible:u,isCopyLoading:f,copyForm:h,openCopyModal:S,closeCopyModal:E,resetAfterClose:I,handleCopyTreeSelect:A,handleIconsCopyOk:F,handleCreateFolderAndCopy:O,fetchChildFolders:y,generateMenuItemsFromFolders:_}})({items:U,selectedHashes:Le,getPngDataUrlForItem:dt,dataUrlToBlob:ut,clearSelection:lt});return t(r,{children:[t("div",{className:`${ZR.iconsTab} ${_.trim()?ZR.hasSearch:""}`,children:[_.trim()&&(U.length>0||Y)&&Le.size>0?e(r,{children:t("div",{className:ZR.iconsHeaderContainer,children:[t("div",{className:ZR.iconsHeaderContainerLeft,children:[t(P.Text,{type:"secondary",children:[Le.size," ",y("selected")]}),e(j,{icon:e(yi,{size:16}),onClick:lt,children:y("Deselected")})]}),e(D,{children:e(j,{icon:e(ii,{size:16}),onClick:mt,children:y("Copy to folder")})})]})}):e(QR,{query:x,onQueryChange:C,onSubmit:Qe,styleFilter:L,onStyleChange:N,hasResults:U.length>0||Y,inputRef:l}),"family"===k?e(eL,{mode:k,familySlug:I,categoryName:z,colorHex:ae,setColorHex:se,colorHex2:le,setColorHex2:ce,colorHex3:ue,setColorHex3:de,sizePx:pe,setSizePx:ge,strokeWidth:he,setStrokeWidth:fe,responsiveSvg:me,setResponsiveSvg:ve,useCssColor:ye,setUseCssColor:be,showSecondColor:Ye,showThirdColor:Xe,styleFilter:L,onBack:nt}):null,e(rL,{items:U,hasMore:W,loading:Y,hasQuery:Boolean(_.trim()),mode:k,selectedHash:Z,onLoadMore:tt,onItemClick:rt,onInsert:ht,scrollContainerRef:Se,colorVars:{colorHex:ae,colorHex2:le,colorHex3:ue},svgTextMap:te,previewSize:pe,selectedHashes:Le,onToggleSelect:st}),ct?t("div",{className:ZR.iconsBottomBar,children:[e(K,{className:"zero-divider"}),e("div",{className:ZR.iconsBottomBarContent,children:e(D,{children:e(j,{size:"large",type:"primary",style:{height:40},loading:we,onClick:()=>ht(ct),children:y("Choose")})})})]}):null]}),e(q,{title:e("div",{className:"modal-title",children:y("Copy to folder")}),open:ft,onCancel:()=>{pt||vt()},maskClosable:!pt,closable:!pt,keyboard:!pt,footer:t("div",{className:us.formFooter,children:[t(j,{className:us.folderButton,onClick:_t,loading:pt,children:[e(ci,{size:18,strokeWidth:null===(v=_e.config)||void 0===v?void 0:v.iconStrokeWidth}),y("Create folder")]}),e(j,{type:"primary",className:us.folderButton,onClick:()=>{vt()},loading:pt,children:y("Done")})]}),afterClose:()=>yt(),children:t("div",{className:ZR.copyToFolderModalBody,children:[pt?e("div",{className:ZR.copyToFolderModalLoadingOverlay,children:e(A,{size:"large"})}):null,e(T,{form:gt,layout:"vertical",initialValues:{targetFolder:"folders",folderName:y("New folder"),is_force_create:!1},children:t("div",{className:us.foldersWrapper,children:[e(T.Item,{name:"targetFolder",rules:[{required:!0,message:y("Select the destination folder")}],className:us.formItem,children:e(ls,{onSelect:bt,generateMenuItems:()=>Ct({targetForm:gt,onTreeSelect:bt,onComplete:wt,actionButtonText:y("Copy here")}),fetchChildFolders:xt,disabledFolders:[],mode:"selection",className:"folderSelectionTree",defaultExpandAll:!0})}),e(T.Item,{name:"folderName",style:{display:"none"},rules:[{required:!0,validator:(e,t)=>"string"==typeof t&&0===t.trim().length?Promise.reject(new Error(y("Enter the name of the folder"))):Promise.resolve()}],children:e(F,{})}),e(T.Item,{name:"is_force_create",style:{display:"none"},children:e(F,{})})]})})]})})]})},mL=e=>{(null==e?void 0:e.customTheme)&&((e={})=>{const t=document.querySelector("head");if(!t)return;const r=document.createElement("style");if(r.type="text/css",r.dataset.themeVariablesFm="true",r.setAttribute("data-file-manager","true"),Object.entries(e).length){let n="";Object.entries(e).forEach(([e,t])=>{"object"!=typeof t&&(n+=`\t--${e}: ${t};\n`)}),n=`.em-filemanager {\n${n}}`,r.appendChild(document.createTextNode(n));const i=t.querySelector('[data-theme-variables-fm="true"]');i?t.replaceChild(r,i):t.insertBefore(r,t.firstChild)}})(null==e?void 0:e.customTheme)},{Sider:vL,Content:yL}=Q,bL={keywords:""},wL=()=>{var s,l,d;const h=io(),f=oa(),p=ta(),g=(()=>{const{state:e,actions:t}=Fi(),{pagination:r}=e,{setPagination:n}=t,i=c((e,t)=>{const i=t||r.pageSize;null==n||n({current:e,pageSize:i,total:r.total})},[r.pageSize,r.total,n]);return{state:{pagination:r},actions:{handlePaginationChange:i}}})(),m=(()=>{const[e,t]=n.useState(()=>{const e=localStorage.getItem(aa);return e?Math.max(290,parseInt(e,10)):298}),[r,i]=n.useState(!1),[o,a]=n.useState(!1),[s,l]=n.useState(0),c=n.useCallback(()=>{t(298),localStorage.setItem(aa,298..toString())},[]),u=n.useCallback(r=>{r.preventDefault(),r.stopPropagation(),i(!0),document.body.classList.add("resizing");const n=r.clientX,o=e;let s=o;const c=e=>{e.preventDefault();const r=Math.max(Math.min(o+e.clientX-n,600),290);s=r,t(r),l(e.clientX),a(!0)},u=()=>{i(!1),document.body.classList.remove("resizing"),a(!1),localStorage.setItem(aa,s.toString()),document.removeEventListener("mousemove",c),document.removeEventListener("mouseup",u)};document.addEventListener("mousemove",c),document.addEventListener("mouseup",u)},[e]);return n.useEffect(()=>()=>{document.body.classList.remove("resizing")},[]),{sidebarWidth:e,isResizing:r,showResizeGuide:o,resizeGuidePosition:s,handleResizeStart:u,handleDoubleClick:c}})(),v=(()=>{const[e,t]=o([]),[r,n]=o(!1),[i,a]=o(!1),s=u(0),l=u(new Map),d=c(()=>(s.current+=1,`upload_${s.current}_${Date.now()}`),[]),h=c(e=>Di(e.size),[]),f=c((e,r)=>{const i=r.map(t=>({id:d(),folderId:e,name:t.name,size:h(t),status:"uploading",progress:0}));return t(i),n(!0),a(!1),i.map(e=>e.id)},[d,h]),p=c((e,r)=>{const i={id:d(),folderId:e,name:r,size:void 0,status:"uploading",progress:0};return t(e=>[...e,i]),n(!0),a(!1),i.id},[d]),g=c((e,r)=>{t(t=>t.map(t=>t.id===e?Object.assign(Object.assign({},t),{progress:Math.min(100,Math.max(0,r))}):t))},[]),m=c((e,r)=>{r&&l.current.set(e,r),t(t=>t.map(t=>{if(t.id===e){const e=Object.assign(Object.assign({},t),{status:"success",progress:100});return(null==r?void 0:r.size)&&void 0===t.size&&(e.size=Di(r.size)),e}return t}))},[]),v=c((e,r)=>{t(t=>t.map(t=>t.id===e?Object.assign(Object.assign({},t),{status:"error",error:r}):t))},[]),y=c(()=>{n(!1),a(!1),setTimeout(()=>{t([]),l.current.clear()},300)},[]),b=c(()=>{a(e=>!e)},[]),w=c(e=>l.current.get(e),[]),x=e.length,C=e.filter(e=>"success"===e.status||"error"===e.status).length;return{uploadFiles:e,isUploadVisible:r,isUploadMinimized:i,totalFiles:x,completedFiles:C,startUpload:f,startUploadByUrl:p,updateProgress:g,markAsSuccess:m,markAsError:v,getUploadedFile:w,closeUpload:y,minimizeUpload:b}})(),y=Xo(),{deleteItems:b}=oo(),w=Li(),{t:x}=Zr(),{options:C,state:_}=Fi(),S=null==C?void 0:C.config,{dataProviders:k}=C,{DropZoneFileIcon:E}=Va(),[I,T]=o(!1),[F,O]=o(!1),[P,M]=o(!1),R=u(0),L=u(!1);L.current=F;const N=i.useRef(null),D=i.useRef([]),[z,B]=o(!1),[U,V]=o(!1),{folders:$,loading:H}=h.state,{fetchFolders:W,fetchChildFolders:G,handleCreateFolder:q,handleModalOk:Y,handleModalCancel:X,generateMenuItems:Z}=h.actions,J=(e=>{var t;const{state:r,actions:n,options:i}=Fi(),{t:o}=Zr(),a=Li(),{folders:s,folderToRename:l,renameFolderForm:u,isRenameFolderModalVisible:d}=r,{setFolderToRename:h,setIsRenameFolderModalVisible:f}=n,{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,r;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(o("renameFolder is not implemented in 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,error:{message:"invalidResponse"}}});a.success({id:"FOLDER_RENAME_SUCCESS",message:o("Folder renamed"),placement:"bottomRight",data:{itemId:s.id,itemName:s.name,folderId:null!==(r=s.parentId)&&void 0!==r?r:null}}),y(),await e(),l!==s.id&&n.setSelectedFolder&&n.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"),error:{message: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}}})(W),{files:ee,selectedFiles:te,loading:re,isRenamingFile:ne,fileToRename:ie}=f.state,{fetchFiles:oe,handleDeleteFile:ae,handleDeleteFolder:se,handleAddFile:le,handleAddFileByUrl:ce,toggleFileSelection:ue,showRenameModal:de,handleRenameCancel:he,handleRenameOk:fe,handleDroppedFiles:pe,showMoveModal:ge,handleMoveCancel:me,handleMoveOk:ve,handleCopyOk:ye,handleCopyCancel:be,showDeleteConfirm:we,handleDeleteConfirmCancel:xe,handleDeleteConfirmOk:Ce}=f.actions,{selectedFolder:_e,pathHistory:Se}=p.state,{handleFolderSelect:Ae,handleBreadcrumbClick:ke,handleItemClick:Ee}=p.actions,{pagination:Ie}=g.state,Te=Ri(oe),{searchTerm:Oe,sortBy:Pe,sortOrder:Me}=Te.state,{handleSearch:Re,handleSort:Le,handlePaginationChange:Ne}=Te.actions,je=c(async()=>{const e=(e=>Xi(e))(Se||[]);try{await Zi({options:C,pathFolder:e,dataProviders:null==C?void 0:C.dataProviders})}catch(e){console.error("Cache clear failed:",e)}await W(),await oe({folderId:_e||"",page:Ie.current,limit:Ie.pageSize,search:Oe,sortBy:Pe,sortOrder:Me,itemType:"all"})},[oe,W,C,Ie.current,Ie.pageSize,Se,Oe,_e,Pe,Me]),De=(({files:e,selectedFiles:t,fetchFiles:r,selectedFolder:i})=>{const{t:o}=Zr(),a=Li(),{options:s,actions:l,state:c}=n.useContext(Ti),{setActiveLibraryItem:u}=l,{activeLibraryItem:d}=c,h=Xo(),[f,p]=n.useState(!1),[g,m]=n.useState(null),v=n.useCallback(e=>{var t;if(e.type&&e.type.startsWith("image/"))return!0;if(e.extension){const t=e.extension.toLowerCase();return mr.includes(t)}const r=null===(t=e.name.split(".").pop())||void 0===t?void 0:t.toLowerCase();return!!r&&mr.includes(r)},[]),y=n.useCallback(async e=>{var t,r,n,i;const{dataProviders:o}=s;if(!1!==(null===(r=null===(t=s.config)||void 0===t?void 0:t.features)||void 0===r?void 0:r.enableUpdateFile)&&(null==o?void 0:o.updateFile)&&e.thumbnail)try{const t=Tr(e.thumbnail,e.type),r=Fr(t),n=e.name.substring(0,e.name.lastIndexOf("."))+"."+r,i=Rr(e.thumbnail,t);return await o.updateFile(e.id,{name:n,type:t,data:i})}catch(e){return console.error("Error updating the file through updateFile:",e),null}else if(e.thumbnail)try{const t=Tr(e.thumbnail,e.type),r=Rr(e.thumbnail,t),n=new File([r],e.name,{type:t,lastModified:Date.now()});return await h.uploadFileWithProvider(n,e.folderId||void 0)||null}catch(e){return console.error("Error saving the file:",e),null}else if(!1!==(null===(i=null===(n=s.config)||void 0===n?void 0:n.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("Error renaming the file:",e),null}return console.warn("DataProvider for updating files is not configured"),null},[s,h]),b=n.useCallback(r=>{let n;if(r)n=r;else{if(1!==t.size)return;const r=Array.from(t)[0];if(n=e.find(e=>e.id===r),!n||n.isFolder||!v(n))return}u&&u(lr),m(n),p(!0)},[t,e,v,p,u]),w=n.useCallback(()=>{u&&d===lr&&u(nr),p(!1),m(null)},[d,u]),x=n.useCallback(async e=>{var t,n,l,c;try{const l=await y(e);if(l)return a.success({id:"IMAGE_UPDATE_SUCCESS",message:o("Success"),description:o("Image updated successfully"),placement:"bottomRight",data:{itemId:null!==(t=l.id)&&void 0!==t?t:void 0,itemName:l.name,folderId:null!==(n=l.folderId)&&void 0!==n?n:null,thumbnail:l.thumbnail}}),s.onEditorOk&&s.onEditorOk(l),await r({folderId:i||""}),w(),l}catch(t){console.error("Error saving the file:",t),a.error({id:"IMAGE_SAVE_FAILED",message:o("Error"),description:o("Failed to save changes",{error:t}),innerException:t,placement:"bottomRight",data:{itemId:null!==(l=e.id)&&void 0!==l?l:void 0,itemName:e.name,folderId:null!==(c=e.folderId)&&void 0!==c?c:null,thumbnail:e.thumbnail}})}},[y,s,r,i,a,w]);return{isPixieEditorVisible:f,editingFile:g,handleEdit:b,handlePixieEditorSave:x,handlePixieEditorClose:w}})({files:ee||[],selectedFiles:te||new Set,fetchFiles:oe,selectedFolder:_e||null}),[ze,Be]=o(!1),Ue=c(e=>{if(e.preventDefault(),e.stopPropagation(),!e.dataTransfer||!e.dataTransfer.types||!e.dataTransfer.types.includes("Files"))return;e.dataTransfer.dropEffect="copy";const t=e.relatedTarget,r=e.currentTarget;t&&r.contains(t)||(R.current+=1,R.current>0&&T(!0))},[]),Ve=c(e=>{e.preventDefault(),e.stopPropagation();const t=e.relatedTarget,r=e.currentTarget;if(t&&!r.contains(t))R.current=Math.max(0,R.current-1),R.current<=0&&T(!1);else if(t){const e=t.closest('[class*="dragOverlay"]');if(e&&r.contains(e))return}},[]),$e=c(e=>{e.preventDefault(),e.stopPropagation(),e.dataTransfer&&(e.dataTransfer.dropEffect="copy")},[]),He=c(e=>{e.preventDefault(),e.stopPropagation(),T(!1),R.current=0;const t=(()=>{var t;const r=e.dataTransfer;if(!r)return[];if(null===(t=r.files)||void 0===t?void 0:t.length)return Array.from(r.files);const n=[];if(r.items)for(let e=0;e<r.items.length;e++){const t=r.items[e].getAsFile();t&&n.push(t)}return n})();t.length&&(Be(!0),pe(t).catch(e=>{"StaleLoad"!==(null==e?void 0:e.name)&&console.error("Ошибка при загрузке файлов:",e)}).finally(()=>{Be(!1)}))},[pe]),We=c(()=>{T(!1),R.current=0,document.body.removeAttribute("data-fm-dragging"),M(!1),O(!1)},[]);i.useEffect(()=>{D.current=ee||[]},[ee]);const Ge=null==_?void 0:_.activeLibraryItem;a(()=>{const e=e=>{e?document.body.setAttribute("data-fm-dragging","true"):document.body.removeAttribute("data-fm-dragging")};let t=!1;const r=r=>{var n,i;!t&&(null===(i=null===(n=r.dataTransfer)||void 0===n?void 0:n.types)||void 0===i?void 0:i.includes("Files"))&&(t=!0,M(!0),e(!0),Ge===nr&&O(!0))},n=r=>{const n=r.relatedTarget;(!n||!document.documentElement.contains(n))&&t&&(t=!1,M(!1),O(!1),e(!1))};return window.addEventListener("dragenter",r,!0),window.addEventListener("dragleave",n,!0),()=>{window.removeEventListener("dragenter",r,!0),window.removeEventListener("dragleave",n,!0),document.body.removeAttribute("data-fm-dragging")}},[Ge]),a(()=>{const e=e=>{var t,r;if(document.body.removeAttribute("data-fm-dragging"),M(!1),!(null===(r=null===(t=e.dataTransfer)||void 0===t?void 0:t.types)||void 0===r?void 0:r.includes("Files")))return;e.preventDefault();const n=(e=>{var t;if(!e)return[];if(null===(t=e.files)||void 0===t?void 0:t.length)return Array.from(e.files);const r=[];if(e.items)for(let t=0;t<e.items.length;t++){const n=e.items[t].getAsFile();n&&r.push(n)}return r})(e.dataTransfer);if(!n.length)return;const i=e.target,o=i.closest(`.${Xa.filesContainer.replace(/\s+/g,".")}`)||i.closest("[data-files-container]"),a=i.closest(".em-filemanager")||i.closest(".file-manager__layout")||i.closest("[data-drop-overlay]")||i.closest("[data-drag-capture]");(L.current||I||o||a)&&(e.preventDefault(),e.stopPropagation(),O(!1),T(!1),R.current=0,Be(!0),pe(n).catch(e=>{"StaleLoad"!==(null==e?void 0:e.name)&&console.error("Ошибка при загрузке файлов:",e)}).finally(()=>Be(!1)))},t=e=>{var t,r;(null===(r=null===(t=e.dataTransfer)||void 0===t?void 0:t.types)||void 0===r?void 0:r.includes("Files"))&&(e.preventDefault(),e.dataTransfer.dropEffect="copy",document.body.hasAttribute("data-fm-dragging")||(document.body.setAttribute("data-fm-dragging","true"),M(!0)),Ge!==nr||L.current||O(!0))},r=e=>{var t,r;(null===(r=null===(t=e.dataTransfer)||void 0===t?void 0:t.types)||void 0===r?void 0:r.includes("Files"))&&(e.preventDefault(),e.dataTransfer.dropEffect="copy",document.body.setAttribute("data-fm-dragging","true"),M(!0))},n={capture:!0,passive:!1};return window.addEventListener("drop",e,n),window.addEventListener("dragover",t,n),window.addEventListener("dragenter",r,n),()=>{window.removeEventListener("drop",e,n),window.removeEventListener("dragover",t,n),window.removeEventListener("dragenter",r,n)}},[I,pe,Ge]),a(()=>{const e=e=>{I&&We(),O(!1),M(!1),document.body.removeAttribute("data-fm-dragging")};return window.addEventListener("dragend",e,!0),()=>window.removeEventListener("dragend",e,!0)},[I,We]),a(()=>{let e=null;const t=t=>{I&&(e=setTimeout(()=>{I&&We()},200))};return document.addEventListener("mouseup",t,!0),()=>{document.removeEventListener("mouseup",t,!0),e&&clearTimeout(e)}},[I,We]),a(()=>{const e=e=>{"Escape"===e.key&&I&&We()};return document.addEventListener("keydown",e),()=>{document.removeEventListener("keydown",e)}},[I,We]),a(()=>{const e=e=>{I&&setTimeout(()=>{I&&We()},100)};return document.addEventListener("click",e,!0),()=>{document.removeEventListener("click",e,!0)}},[I,We]);const qe=i.useCallback(async()=>{await Ce(),await W(),_e===cr&&G&&await G(cr),requestAnimationFrame(()=>{requestAnimationFrame(()=>{var e,t;return null===(t=null===(e=N.current)||void 0===e?void 0:e.refreshFileCounts)||void 0===t?void 0:t.call(e)})})},[W,G,Ce,_e]),Ye=i.useCallback(()=>{V(!0)},[]),Xe=i.useCallback(async()=>{var e,t;if(_e!==cr)return console.error("Clear trash called outside of trash folder"),void V(!1);try{if(null==k?void 0:k.cleanTrash){const t=await k.cleanTrash();await oe({folderId:cr}),await(null===(e=N.current)||void 0===e?void 0:e.refreshFileCounts()),t.success?w.success({id:"TRASH_CLEARED_SUCCESS",message:x("Trash cleared successfully"),description:x("{{count}} items permanently deleted",{count:t.deletedCount||0}),placement:"bottomRight"}):w.error({id:"TRASH_CLEAR_FAILED",message:x("Failed to clear trash"),placement:"bottomRight"})}else{const e=D.current||[];if(0===e.length)return void V(!1);const r=e.map(e=>({id:e.id,isFolder:e.isFolder})),n=await b({items:r,selectedFolder:cr,getItemNameById:t=>{var r;return(null===(r=e.find(e=>e.id===t))||void 0===r?void 0:r.name)||t||""},showNotifications:!1});await oe({folderId:cr}),await(null===(t=N.current)||void 0===t?void 0:t.refreshFileCounts());const{successCount:i,failCount:o}=n;0===o?w.success({id:"TRASH_CLEARED_SUCCESS",message:x("Trash cleared successfully"),description:x("{{count}} items permanently deleted",{count:i}),placement:"bottomRight"}):i>0?w.warning({id:"TRASH_CLEARED_PARTIAL",message:x("Trash partially cleared"),description:x("{{succeeded}} items deleted, {{failed}} items failed",{succeeded:i,failed:o}),placement:"bottomRight"}):w.error({id:"TRASH_CLEAR_FAILED",message:x("Failed to clear trash"),placement:"bottomRight"})}V(!1)}catch(e){console.error("Error clearing trash:",e),w.error({id:"TRASH_CLEAR_ERROR",message:x("Error clearing trash"),placement:"bottomRight"}),V(!1)}},[_e,k,oe,w,x,b]),Ke=i.useCallback(()=>{V(!1)},[]),Ze=i.useCallback(async e=>{var t;await ve(e),await(null===(t=N.current)||void 0===t?void 0:t.refreshFileCounts())},[ve]),Je=i.useCallback(async e=>{var t;await ye(e),await(null===(t=N.current)||void 0===t?void 0:t.refreshFileCounts())},[ye]),Qe=i.useCallback(async()=>{let e=[],t=new Map;const r=null==C?void 0:C.config;await le({onStartBatch:n=>{e=v.startUpload(_e||void 0,n),t=new Map,n.forEach((n,i)=>{const o=e[i];o&&(t.set(n.name,o),t.set(ro(n.name,r),o))})},onStart:n=>{if(0===e.length){e=v.startUpload(_e||void 0,[n]);const i=e[0];i&&(t.set(n.name,i),t.set(ro(n.name,r),i))}},onProgress:(e,r)=>{const n=t.get(e);n&&v.updateProgress(n,r)},onComplete:async e=>{var r;const n=t.get(e);if(n){await new Promise(e=>setTimeout(e,100));const t=null==ee?void 0:ee.find(t=>t.name===e&&!t.isFolder);v.markAsSuccess(n,t)}await(null===(r=N.current)||void 0===r?void 0:r.refreshFileCounts())},onError:(r,n,i)=>{var o;const a=null!==(o=t.get(r))&&void 0!==o?o:null!=i&&i<e.length?e[i]:void 0;a&&v.markAsError(a,n)},onBatchComplete:async r=>{var n,i,o,a,s,l,c,u;for(let u=0;u<r.successes.length;u++){const d=r.successes[u],h=null===(n=r.uploadedFiles)||void 0===n?void 0:n.get(d),f=null!==(a=null!==(o=null!==(i=t.get(d))&&void 0!==i?i:(null==h?void 0:h.originalFileName)?t.get(h.originalFileName):void 0)&&void 0!==o?o:null!=(null==h?void 0:h.originalIndex)&&h.originalIndex<e.length?e[h.originalIndex]:void 0)&&void 0!==a?a:u<e.length?e[u]:void 0;if(f){let e;if(null==h?void 0:h.id){const t=h;e={id:t.id,name:null!==(s=t.name)&&void 0!==s?s:d,folderId:null!==(c=null!==(l=t.folderId)&&void 0!==l?l:_e)&&void 0!==c?c:null,isFolder:!1,size:t.size}}else await new Promise(e=>setTimeout(e,100)),e=null==ee?void 0:ee.find(e=>e.name===d&&!e.isFolder);v.updateProgress(f,100),v.markAsSuccess(f,e)}}r.errors.forEach(({fileName:e,error:r})=>{const n=t.get(e);n&&v.markAsError(n,r)}),await(null===(u=N.current)||void 0===u?void 0:u.refreshFileCounts())}})},[le,v,ee,_e,null==C?void 0:C.config]),et=i.useCallback(async(e,t,r,n)=>{var i,o;try{B(!0);let a=r||"uploaded-file";if(!r&&e){const t=e.split("?")[0].split("#")[0].split("/");a=t[t.length-1]||"uploaded-file";a.includes(".")&&(null===(i=a.split(".").pop())||void 0===i?void 0:i.length)&&a.split(".").pop().length<=5||(a+=".jpg")}const s=v.startUploadByUrl(_e||void 0,a);try{const r=await ce(e,t,!0,null!=n?n:"uploadByUrl");if(v.updateProgress(s,100),r){await new Promise(e=>setTimeout(e,100));const e=(null==ee?void 0:ee.find(e=>e.id===r.id&&!e.isFolder))||r;v.markAsSuccess(s,e)}else v.markAsSuccess(s);await(null===(o=N.current)||void 0===o?void 0:o.refreshFileCounts())}catch(e){const t=Hi(e),r=Yi(t,x);v.markAsError(s,r)}}finally{B(!1)}},[ce,v,_e,ee,x]),tt=i.useCallback(async({file:e})=>{var t;const r=v.startUpload(_e||void 0,[e])[0];let n=0;const i=setInterval(()=>{n=Math.min(n+10+Math.floor(Date.now()%10),90),v.updateProgress(r,n)},200);try{const n=await y.uploadFileWithProvider(e,void 0,!0);if(clearInterval(i),v.updateProgress(r,100),n){await new Promise(e=>setTimeout(e,100));const e=(null==ee?void 0:ee.find(e=>e.id===n.id&&!e.isFolder))||n;v.markAsSuccess(r,e)}else v.markAsSuccess(r);const o=n&&n.folderId||_e||null;return Ae&&Ae(o&&"folders"!==o?o:"folders"),await(null===(t=N.current)||void 0===t?void 0:t.refreshFileCounts()),n}catch(e){clearInterval(i);const t=e instanceof Error?e.message:String(e);throw v.markAsError(r,t),e}},[y,v,_e,ee,Ae]),rt=i.useCallback(async e=>{var t;await ae(e),await(null===(t=N.current)||void 0===t?void 0:t.refreshFileCounts())},[ae]),nt=i.useCallback(async e=>{var t;if(pe){const r=v.startUpload(_e||void 0,e);e.forEach(async(e,t)=>{const n=r[t];if(!n)return;let i=0;const o=setInterval(()=>{i=Math.min(i+10+Math.floor(Date.now()%10),85),v.updateProgress(n,i)},200);setTimeout(()=>{clearInterval(o)},2e3)}),await pe(e),r.forEach(e=>{v.updateProgress(e,100),v.markAsSuccess(e)}),await(null===(t=N.current)||void 0===t?void 0:t.refreshFileCounts())}},[pe,v,_e]),it=i.useCallback(async e=>{var t;await se(e),await W(),await(null===(t=N.current)||void 0===t?void 0:t.refreshFileCounts())},[se,W]),ot=(({files:e,selectedFiles:t,toggleFileSelection:r,showRenameModal:i,showMoveModal:o,showCopyModal:a,handleDeleteFile:s,handleDeleteFolder:l,showDeleteConfirm:c,onEdit:u})=>{const d=n.useCallback(()=>{t&&t.size>0&&t.forEach(e=>{r(e)})},[t,r]),h=n.useCallback(e=>{if(t&&1===t.size||e){const r=e||Array.from(t)[0];i(r)}},[t,i]),f=n.useCallback(r=>{if(t&&t.size>0||(null==r?void 0:r.id)){if(c)return void c();(r?[r.id]:t).forEach(t=>{const r=e.find(e=>e.id===t);r?r.isFolder?l(t):s(t):console.warn(`Объект с ID ${t} не найден в списке файлов`)})}},[t,e,s,l,c]);return{handleClearSelection:d,handleRename:h,handleDeleteSelected:f,handleCopy:n.useCallback(()=>{a()},[a]),handleMove:n.useCallback(()=>{o()},[o]),handleEdit:n.useCallback(()=>{u()},[u])}})({files:ee||[],selectedFiles:te||new Set,toggleFileSelection:ue,showRenameModal:de,showMoveModal:ge,showCopyModal:f.actions.showCopyModal||(()=>{}),handleDeleteFile:ae,handleDeleteFolder:it,showDeleteConfirm:we,onEdit:De.handleEdit}),at=H||re||ze;a(()=>{Ar()},[]),i.useEffect(()=>{if(!Ae||0===$.length)return;const e=!1!==(null==S?void 0:S.rememberLastFolder),t=`em_fm:lastFolder:${(null==S?void 0:S.projectId)||"default"}`;if(e&&"undefined"!=typeof window)try{const e=localStorage.getItem(t),r=e&&$.some(t=>t.id===e);if(r)return void Ae(e)}catch(e){}_e||Ae("folders")},[_e,Ae,$,null==S?void 0:S.rememberLastFolder,null==S?void 0:S.projectId]);const{state:st,actions:lt,options:ct}=i.useContext(Ti),{form:ut,urlForm:dt,renameForm:ht,moveForm:ft,renameFolderForm:pt,copyForm:gt,isModalVisible:mt,isUrlModalVisible:vt,isMoveModalVisible:yt,isRenameFolderModalVisible:bt,isCopyModalVisible:wt,isDeleteConfirmVisible:xt,folderToRename:Ct,activeLibraryItem:_t}=st,{setIsUrlModalVisible:St,setSortField:At,setActiveLibraryItem:kt}=lt,{config:Et}=ct,{handleRenameFolderCancel:It,handleRenameFolderOk:Tt}=J.actions;a(()=>{const e=async e=>{if(_t!==nr)return;const t=document.activeElement;if(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||"true"===(null==t?void 0:t.getAttribute("contenteditable")))return;const r=e.clipboardData;if(!r)return;const n=Array.from(r.items),i=n.filter(e=>e.type.startsWith("image/"));if(i.length>0){const t=i.map(e=>e.getAsFile()).filter(e=>null!==e);return void(t.length>0&&(e.preventDefault(),await nt(t)))}const o=n.find(e=>"text/plain"===e.type);o&&o.getAsString(async t=>{const r=t.trim();if(r.startsWith("http://")||r.startsWith("https://"))e.preventDefault(),await et(r);else if(r.includes("<meta")||r.includes("http")){const t=r.match(/https?:\/\/[^\s"']+/);t&&(e.preventDefault(),await et(t[0]))}})};return document.addEventListener("paste",e),()=>{document.removeEventListener("paste",e)}},[_t,et,nt]);const Ft=c(e=>{Ne(e.current||Ie.current,e.pageSize||Ie.pageSize)},[Ne,Ie]),Ot=i.useCallback(e=>{const{sortBy:t,sortOrder:r}=(e=>{const[t,r]=e.split("-");return{sortBy:t,sortOrder:r}})(e);Le(t,r)},[Le]),[Pt,Mt]=o(bL),[Rt,Lt]=o([]),Nt=u(null),[jt,Dt]=o(yr),[zt,Bt]=o([]),Ut=u(null),[Vt,$t]=o(""),Ht=u(null),[Wt,Gt]=o(""),[qt,Yt]=o([]),Xt=i.useRef(void 0),[Kt,Zt]=o(!1),[Jt,Qt]=o(!1),er=i.useRef(null),tr=i.useRef(_t),rr=i.useCallback(e=>{const t=e.indexOf(",");if(-1===t)return null;const r=e.substring(0,t),n=r.match(/^data:([^;]+)/),i=n&&n[1]||"image/svg+xml";let o,a="svg";if(i.includes("png")?a="png":(i.includes("jpeg")||i.includes("jpg"))&&(a="jpg"),/;base64/i.test(r)){const r=e.substring(t+1),n=atob(r),a=new Uint8Array(n.length);for(let e=0;e<n.length;e+=1)a[e]=n.charCodeAt(e);o=new Blob([a],{type:i})}else{const r=decodeURIComponent(e.substring(t+1));o=new Blob([r],{type:i})}return new File([o],`icon_${Date.now()}.${a}`,{type:i})},[]),ur=i.useCallback(async e=>{var t;const r=v.startUpload(_e||void 0,[e])[0];let n=0;const i=setInterval(()=>{n=Math.min(n+10+Math.floor(Date.now()%10),90),v.updateProgress(r,n)},200);try{const n=await y.uploadFileWithProvider(e,void 0,!0);if(clearInterval(i),v.updateProgress(r,100),n){await new Promise(e=>setTimeout(e,100));const e=(null==ee?void 0:ee.find(e=>e.id===n.id&&!e.isFolder))||n;v.markAsSuccess(r,e)}else v.markAsSuccess(r);await(null===(t=N.current)||void 0===t?void 0:t.refreshFileCounts())}catch(e){clearInterval(i);const t=e instanceof Error?e.message:String(e);throw v.markAsError(r,t),e}},[v,ee,y,_e]),dr=c(async e=>{if(Boolean(e&&e.startsWith("data:"))){const t=rr(e);if(!t)return;return void await ur(t)}e&&await et(e,void 0,void 0,"iconStock")},[rr,et,ur]),hr=c(async()=>{const e=null==Et?void 0:Et.fileForEdit;if(Xt.current===e)return;if(_t===lr&&e&&!De.editingFile){Xt.current=e;try{if("string"==typeof e){if(e.startsWith("data:"))return void(null==De||De.handleEdit({thumbnail:e}));const t=await y.handleAddFileByUrl(e,!0,void 0,"pixie");if(!t)throw new Error(x("Failed to download file"));Xt.current===e&&(null==De||De.handleEdit(t))}}catch(t){throw Xt.current===e&&(Xt.current=null),t}}},[null==Et?void 0:Et.fileForEdit,_t,De,y,x]);a(()=>{hr()},[hr]),a(()=>{var e,t,r,n;const i=tr.current;tr.current=_t,_t===nr?(Lt([]),Mt(bL),Bt([]),Dt(yr),Yt([]),Gt(""),Qt(!1),Zt(!1),i===nr||i!==or&&i!==ir&&i!==sr||Re("")):_t===sr?null===(e=er.current)||void 0===e||e.focus():_t===ir?null===(t=Nt.current)||void 0===t||t.focus():_t===or?null===(r=Ut.current)||void 0===r||r.focus():_t===ar&&(null===(n=Ht.current)||void 0===n||n.focus())},[_t,Re]);const fr=i.useCallback(async()=>{var e;await Tt(),await(null===(e=N.current)||void 0===e?void 0:e.refreshFileCounts())},[Tt]),pr=te.size,gr=i.useMemo(()=>{var e,t,r;if(1!==pr)return!1;const[n]=Array.from(te),i=ee.find(e=>e.id===n);if(!i||i.isFolder)return!1;const o="string"==typeof i.name?i.name:"",a=o?null===(e=o.split(".").pop())||void 0===e?void 0:e.toLowerCase():void 0,s=null!==(r=null===(t=i.extension)||void 0===t?void 0:t.toLowerCase())&&void 0!==r?r:a;return"string"==typeof i.type&&i.type.startsWith("image/")||"string"==typeof s&&mr.includes(s)},[pr,te,ee]);return null!==(l=null===(s=null==S?void 0:S.getDropOverlayContainer)||void 0===s?void 0:s.call(S))&&void 0!==l||document.body,t(r,{children:[P&&Ge===nr&&Fe(e("div",{className:Xa.dragCaptureLayer,"data-drag-capture":"true",onDragOver:e=>{var t,r;e.preventDefault(),e.stopPropagation(),e.dataTransfer&&(e.dataTransfer.dropEffect="copy"),(null===(r=null===(t=e.dataTransfer)||void 0===t?void 0:t.types)||void 0===r?void 0:r.includes("Files"))&&!L.current&&O(!0)},onDragEnter:e=>{var t,r;e.preventDefault(),e.stopPropagation(),(null===(r=null===(t=e.dataTransfer)||void 0===t?void 0:t.types)||void 0===r?void 0:r.includes("Files"))&&O(!0)},onDragLeave:e=>{const t=e.relatedTarget;t&&document.documentElement.contains(t)||(O(!1),M(!1),document.body.removeAttribute("data-fm-dragging"))},onDrop:e=>{var t;e.preventDefault(),e.stopPropagation(),M(!1),O(!1),document.body.removeAttribute("data-fm-dragging");const r=e.dataTransfer,n=(null===(t=null==r?void 0:r.files)||void 0===t?void 0:t.length)?Array.from(r.files):(null==r?void 0:r.items)?Array.from(r.items).map(e=>e.getAsFile()).filter(e=>Boolean(e)):[];n.length&&(Be(!0),pe(n).catch(e=>{"StaleLoad"!==(null==e?void 0:e.name)&&console.error(e)}).finally(()=>Be(!1)))},"aria-hidden":"true"}),document.body),F&&Fe(e("div",{className:Xa.dragOverlayGlobal,"data-drop-overlay":"true",onDragOver:e=>{e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect="copy")},onDragEnter:e=>e.preventDefault(),onDrop:e=>{var t;e.preventDefault(),e.stopPropagation(),O(!1),M(!1),document.body.removeAttribute("data-fm-dragging");const r=e.dataTransfer,n=(null===(t=null==r?void 0:r.files)||void 0===t?void 0:t.length)?Array.from(r.files):(null==r?void 0:r.items)?Array.from(r.items).map(e=>e.getAsFile()).filter(e=>Boolean(e)):[];n.length&&(Be(!0),pe(n).catch(e=>{"StaleLoad"!==(null==e?void 0:e.name)&&console.error(e)}).finally(()=>Be(!1)))},"aria-hidden":"true",children:t("div",{className:Xa.dragOverlayInner,children:[e("div",{className:Xa.uploadIcon,children:e(E,{})}),e("div",{className:Xa.textTitle,children:x("Drop files here to upload")}),e("div",{className:Xa.textDescription,children:x("Supported files:")+" .jpg, .jpeg, .svg, .png"})]})}),document.body),e(Q,{className:"file-manager__layout",children:t("div",{className:Xa.filesContainer,"data-files-container":"true",onDragOver:$e,onDragLeave:Ve,onDragEnter:Ue,onDrop:He,children:[I&&e("div",{className:Xa.dragOverlay,children:t("div",{className:Xa.dragOverlayInner,children:[e("div",{className:Xa.uploadIcon,children:e(E,{})}),e("div",{className:Xa.textTitle,children:x("Drop files here to upload")}),e("div",{className:Xa.textDescription,children:x("Supported files:")+" .jpg, .jpeg, .svg, .png"})]})}),m.showResizeGuide&&e("div",{className:"resize-guide",style:{left:`${m.resizeGuidePosition}px`}}),t(Q,{className:"file-manager__content",children:[t(vL,{width:320,theme:"light",className:"file-manager-sider",children:[e(ms,{ref:N,selectedFolder:_e||"folders",generateMenuItems:Z,onFolderSelect:e=>null==Ae?void 0:Ae(e),folders:$||[],fetchFolders:W,fetchChildFolders:G,handleAddFile:Qe,setIsUrlModalVisible:e=>null==St?void 0:St(e),handleDeleteFolder:it,handleCreateFolder:q,activeLibraryItem:_t,setActiveLibraryItem:e=>null==kt?void 0:kt(e)}),e("div",{className:"sidebar-resizer "+(m.isResizing?"resizing":""),onMouseDown:m.handleResizeStart,onDoubleClick:m.handleDoubleClick,children:e("div",{className:"sidebar-resizer-indicator"})})]}),t(Q,{className:"file-manager__main-content",children:[ze&&e(cs,{style:{position:"absolute",width:"100%",height:"100%",top:0,left:0,zIndex:100,background:"var(--colorBgLayout)"}}),t(yL,{className:"main-content",children:[e(wR,{activeLibraryItem:_t,selectedFolder:(null===(d=null==$?void 0:$.find(e=>(null==e?void 0:e.id)===_e))||void 0===d?void 0:d.name)||x("Folders"),isTrashFolder:"Trash"===_e,onClearTrash:Ye,files:ee||[],loading:at,onRefresh:je,refreshDisabled:re||H}),e(K,{className:"zero-divider"}),_t===nr&&e(Ja,{searchTerm:Oe,sortField:st.sortField||"name",setSortField:e=>null==At?void 0:At(e),pathHistory:Se||[],handleBreadcrumbClick:e=>null==ke?void 0:ke(e),handleAddFile:Qe,setIsUrlModalVisible:e=>null==St?void 0:St(e),files:ee||[],handleSearch:Re,handleSort:Le,sortBy:Pe,sortOrder:Me,handleSortOptionChange:Ot,pagination:Ie,setPagination:Ft,loading:at,handleItemClick:e=>null==Ee?void 0:Ee(e),handleDeleteFile:rt,selectedFiles:te||new Set,toggleFileSelection:(e,t)=>null==ue?void 0:ue(e,t),handleDroppedFiles:nt,fileUpload:v,onClearSelection:ot.handleClearSelection,onRename:ot.handleRename,onCopy:ot.handleCopy,onMove:ot.handleMove,onDelete:ot.handleDeleteSelected,onEdit:De.handleEdit}),_t===ir&&e(jR,{imageGifList:Rt,setImageGifList:Lt,currentReqGif:Pt,setCurrentReqGif:Mt,inputRef:Nt,customRequest:(e,t)=>et(e,void 0,t,"gif")}),_t===or&&e(BR,{imageStockList:zt,setImageStockList:Bt,currentReq:jt,setCurrentReq:Dt,inputRef:Ut,customRequest:(e,t)=>et(e,void 0,t,"imageStock")}),_t===ar&&e(gL,{apiKey:null==Et?void 0:Et.STREAMLINE_API_KEY,customRequest:dr,query:Vt,setQuery:$t,inputRef:Ht}),_t===sr&&!!(null==Et?void 0:Et.sseQuery)&&e(KR,{imageAiList:qt,setImageAiList:Yt,aiImageRequest:Wt,setAiImageRequest:Gt,inputAiRef:er,customRequest:tt,isLoadingAi:Kt,setIsLoadingAi:Zt,isImageUploaded:Jt,setIsImageUploaded:Qt}),_t===lr&&e(r,{}),e(r,{children:gr&&t(r,{children:[e(K,{className:"zero-divider"}),e("div",{style:{display:"flex",justifyContent:"right",padding:"17px 24px",alignItems:"center"},children:e(j,{size:"large",type:"primary",style:{height:40},onClick:()=>{if(ct.onEditorOk){const e=Array.from(te)[0],t=ee.find(t=>t.id===e);t&&ct.onEditorOk(t)}},children:x("Choose")})})]})})]})]})]}),z&&e("div",{style:{position:"fixed",inset:0,zIndex:1500,backgroundColor:"rgba(255, 255, 255, 0.5)",pointerEvents:"all",display:"flex",alignItems:"center",justifyContent:"center"},children:e(A,{size:"large"})}),e(ps,{isModalVisible:mt,handleModalOk:Y,handleModalCancel:X,form:ut,selectedFolder:_e||null,folders:$||[],isUrlModalVisible:vt,setIsUrlModalVisible:e=>null==St?void 0:St(e),handleAddFileByUrl:et,urlForm:dt,isRenameModalVisible:ne,handleRenameOk:()=>null==fe?void 0:fe(),handleRenameCancel:()=>null==he?void 0:he(),renameForm:ht,fileToRename:ie,files:ee||[],isMoveModalVisible:yt,handleMoveOk:Ze,handleMoveCancel:me,moveForm:ft,selectedFiles:te||new Set,isRenameFolderModalVisible:bt,handleRenameFolderOk:fr,handleRenameFolderCancel:It,renameFolderForm:pt,folderToRename:Ct,isCopyModalVisible:wt,handleCopyOk:Je,handleCopyCancel:be,copyForm:gt,isDeleteConfirmVisible:xt,handleDeleteConfirmOk:qe,handleDeleteConfirmCancel:()=>null==xe?void 0:xe(),isClearTrashConfirmVisible:U,handleClearTrashConfirm:Xe,handleClearTrashCancel:Ke,fetchChildFolders:G}),e(VM,{visible:De.isPixieEditorVisible,onClose:De.handlePixieEditorClose,file:De.editingFile,onSave:De.handlePixieEditorSave}),e(vR,{files:v.uploadFiles,visible:v.isUploadVisible,minimized:v.isUploadMinimized,totalFiles:v.totalFiles,completedFiles:v.completedFiles,onClose:v.closeUpload,onMinimize:v.minimizeUpload,onInsert:e=>{var t;const r=v.getUploadedFile(e.id)||e;null===(t=ct.onEditorOk)||void 0===t||t.call(ct,r)}})]})})]})},xL=f(({config:n={},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,availableImageExtensions:["jpg","jpeg","png","gif"],fileNameProcessing:Object.assign(Object.assign({},{transliterate:!0,replaceSpaces:!0,removeForbiddenChars:!0,toLowerCase:!0}),n.fileNameProcessing),folderNameProcessing:Object.assign(Object.assign({},{transliterate:!0,replaceSpaces:!0,removeForbiddenChars:!0,toLowerCase:!0}),n.folderNameProcessing)},n),[n]);i.useEffect(()=>{b.theme&&(e=>{if("system"===e){const t=matchMedia(fr).matches?dr:ur;e=e===hr?t:e}document.documentElement.setAttribute("data-theme",e)})(b.theme),mL(b)},[b]),a(()=>{b.locale&&b.locale!==$n.language&&$n.changeLanguage(b.locale),b.customLocale&&b.locale&&$n.addResourceBundle(b.locale,"translation",b.customLocale,!0,!0)},[b.locale,b.customLocale]);const w=u(null);return e(I,{className:"em-filemanager",children:t(r,{children:[e(E,{getPopupContainer:()=>w.current||document.body,children:e(Oi,{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(wL,{})})}),e("div",{ref:w,className:"file-manager-modal-root"})]})})});xL.displayName="FileManagerApp";const CL=t=>{var r,n,i;return e(Jr,{i18n:$n,children:e(xr,{externalTheme:null!==(n=null===(r=t.config)||void 0===r?void 0:r.theme)&&void 0!==n?n:"light",customThemeToken:null===(i=t.config)||void 0===i?void 0:i.customTheme,children:e(ae,{children:e(xL,Object.assign({},t))})})})},_L=new Map,SL=(t,r)=>{var n;let i;Ar();let o={};const a=e=>{const t=!e||"fileManager"!==e.mode&&"imageCenter"!==e.mode&&"plugin"!==e.mode?void 0:e.mode;return"imageCenter"===t?_r("imageCenter",e):_r(t)};if(t instanceof HTMLElement){i=t;o={config:a(r),apiEndpoints:null==r?void 0:r.apiEndpoints}}else{i=t.element;const e=a(t.config),r=Object.assign(Object.assign({},null===(n=t.config)||void 0===n?void 0:n.apiEndpoints),t.apiEndpoints);o={config:e,currentPath:t.currentPath,onPathChange:t.onPathChange,onChangeSelection:t.onChangeSelection,searchQuery:t.searchQuery,sortBySize:t.sortBySize,apiEndpoints:r,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(CL,Object.assign({},o))),_L.set(i.id||`container_${Date.now()}`,s)},AL=e=>{const t=e.id||Object.keys(_L).find(e=>e.startsWith("container_"));if(t&&_L.has(t)){const e=_L.get(t);null==e||e.unmount(),_L.delete(t)}else{console.warn("Couldn t find the root to unmount");try{S(e).unmount()}catch(e){console.error("Error unmounting the component:",e)}}},kL=new Map,EL=n=>{const{onClose:o,onSave:s,dataProviders:l,theme:c,locale:d}=n,h=i.useMemo(()=>{if(n.file)return n.file;const e=n.name||"edited-image",t=n.extension||(n.type?n.type.split("/")[1]:"png"),r=n.type||`image/${t}`;return{thumbnail:n.imageDataUrl||"",name:e,id:void 0,type:r,extension:t}},[n.file,n.imageDataUrl,n.name,n.extension,n.type]),f=i.useCallback(async e=>{if((null==l?void 0:l.updateFile)&&e.thumbnail)try{const t=Tr(e.thumbnail,e.type),r=Fr(t),n=e.name.substring(0,e.name.lastIndexOf("."))+"."+r,i=Rr(e.thumbnail,t);return await l.updateFile(e.id,{name:n,type:t,data:i})}catch(e){return console.error("Error updating the file through updateFile:",e),null}return console.warn("DataProvider for updating files is not configured"),null},[l]),p=i.useCallback(async e=>{if((null==l?void 0:l.updateFile)&&e.id&&e.thumbnail)try{const t=await f(e);t&&(e=t)}catch(e){console.error("Standalone Pixie: saveFileToServer error",e)}return s&&await s(e),o&&o(),e},[l,s,o,f]),g=u(null);return a(()=>{d&&d!==$n.language&&$n.changeLanguage(d)},[d]),e(I,{className:"em-filemanager",children:t(r,{children:[e(E,{getPopupContainer:()=>g.current||document.body,children:e(Jr,{i18n:$n,children:e(xr,{externalTheme:null!=c?c:"light",children:e(ae,{children:e(Oi,{options:{dataProviders:l,handleNotify:n.handleNotify,handleError:n.handleError,handleSuccess:n.handleSuccess,config:{theme:null!=c?c:"light",locale:d,baseUrl:n.baseUrl,assetsUrl:n.assetsUrl,showNotifications:n.showNotifications}},children:e(VM,{visible:!0,onClose:o,file:h,onSave:p})})})})})}),e("div",{ref:g,className:"file-manager-modal-root"})]})})},IL=t=>{Ar();const r=t.element,n=S(r);n.render(e(EL,Object.assign({},t))),kL.set(r.id||`pixie_container_${Date.now()}`,n)},TL=e=>{const t=Array.from(kL.keys()).find(e=>e.startsWith("pixie_container_")),r=e.id||t;if(r&&kL.has(r)){const e=kL.get(r);null==e||e.unmount(),kL.delete(r)}else{console.warn("Couldn t find the root to unmount Pixie");try{S(e).unmount()}catch(e){console.error("Error unmounting Pixie:",e)}}},FL=e=>{var t,r;const{mode:n,element:i,fileManager:o,pixieEditor:a,theme:s,dataProviders:l}=e;let c,u;const d={unmount:()=>{c&&AL(c),u&&TL(u)},unmountFileManager:void 0,unmountPixieEditor:void 0};switch(n){case"fileManager":c=i,SL(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=()=>AL(c);break;case"pixieEditor":u=i,IL(Object.assign({element:i,theme:s||(null==a?void 0:a.theme),dataProviders:l||(null==a?void 0:a.dataProviders)},a)),d.unmountPixieEditor=()=>TL(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,SL(c,Object.assign(Object.assign({},null==o?void 0:o.config),{theme:s||(null===(r=null==o?void 0:o.config)||void 0===r?void 0:r.theme),apiEndpoints:null==o?void 0:o.apiEndpoints})),IL(Object.assign({element:u,theme:s||(null==a?void 0:a.theme),dataProviders:l||(null==a?void 0:a.dataProviders)},a)),d.unmountFileManager=()=>AL(c),d.unmountPixieEditor=()=>TL(u);break}}return d};function OL(e,t="BackendError"){switch(e){case 400:return"ValidationError";case 401:return"AuthenticationFailed";case 403:return"AuthorizationFailed";case 404:return"FileNotFound";case 413:return"PayloadTooLarge";case 415:return"UnsupportedMediaType";case 429:return"RateLimitExceeded";case 500:return"BackendError";case 503:return"ServiceUnavailable";case 504:return"Timeout";default:return t}}var PL={init:SL,unmount:AL,initPixieEditor:IL,unmountPixieEditor:TL,initFileManager:FL};export{Ja as FileContent,ao as FileManagerApiError,xL as FileManagerApp,CL as FileManagerAppWithContext,ps as FileModals,ms as FolderSidebar,EL as PixieOnlyApp,PL as default,SL as init,FL as initFileManager,IL as initPixieEditor,Ar as installResizeObserverErrorHandler,OL as mapHttpStatusToErrorCode,kr as uninstallResizeObserverErrorHandler,AL as unmount,TL as unmountPixieEditor};
|
|
77
77
|
//# sourceMappingURL=file-manager.esm.js.map
|