File: /var/www/html/wavecolordrop.com/wp-content/plugins/insta-gallery/build/gutenberg/js/index.js
/*! For license information please see index.js.LICENSE.txt */
(()=>{var e={500:(e,t)=>{var a;!function(){"use strict";var l={}.hasOwnProperty;function n(){for(var e="",t=0;t<arguments.length;t++){var a=arguments[t];a&&(e=i(e,r(a)))}return e}function r(e){if("string"==typeof e||"number"==typeof e)return e;if("object"!=typeof e)return"";if(Array.isArray(e))return n.apply(null,e);if(e.toString!==Object.prototype.toString&&!e.toString.toString().includes("[native code]"))return e.toString();var t="";for(var a in e)l.call(e,a)&&e[a]&&(t=i(t,a));return t}function i(e,t){return t?e?e+" "+t:e+t:e}e.exports?(n.default=n,e.exports=n):void 0===(a=function(){return n}.apply(t,[]))||(e.exports=a)}()}},t={};function a(l){var n=t[l];if(void 0!==n)return n.exports;var r=t[l]={exports:{}};return e[l](r,r.exports,a),r.exports}a.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return a.d(t,{a:t}),t},a.d=(e,t)=>{for(var l in t)a.o(t,l)&&!a.o(e,l)&&Object.defineProperty(e,l,{enumerable:!0,get:t[l]})},a.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{"use strict";const e=window.React,t=window.wp.i18n,l=window.wp.blocks,n=window.wp.blockEditor,r=window.wp.compose,i=window.wp.hooks,o=(0,r.createHigherOrderComponent)((t=>a=>("qligg/box"===a.name&&(a.attributes.username&&(a.attributes.account_id=a.attributes.username,a.attributes.username=void 0),a.attributes.type&&(a.atributes.source=a.attributes.type,a.attributes.type=void 0),a.attributes.popup&&(a.attributes.modal=a.attributes.popup,a.attributes.popup=void 0)),(0,e.createElement)(t,{...a}))),"withCustomBlockEdit");(0,i.addFilter)("editor.BlockEdit","qligg/box/edit",o);const s=window.qligg.store;var c=a(500),g=a.n(c);const m=window.wp.element,_=window.wp.components,d=a=>{const{attributes:l,setAttributes:i}=a,[o,c]=(0,m.useState)(l.tag),[d,u]=(0,m.useState)(l.limit),p=(0,r.useDebounce)((e=>{i({tag:e})}),1e3),y=(0,r.useDebounce)((e=>{i({limit:e})}),1e3);(0,m.useEffect)((()=>{p(o)}),[o,p]),(0,m.useEffect)((()=>{y(d)}),[d,y]);const{accounts:h}=(0,s.useAccountsEntities)(),f=qligg_gutenberg.image_url,b=h?.find((e=>e.id===l.account_id)),[E,v]=(0,m.useState)(!1);return(0,e.createElement)(n.InspectorControls,{key:"inspector"},(0,e.createElement)(_.PanelBody,{initialOpen:!0,title:(0,t.__)("Cache","insta-gallery")},(0,e.createElement)(_.Button,{variant:"secondary",onClick:async()=>{confirm((0,t.__)("You are about to reset the cache of this feed.","insta-gallery"))&&(v(!0),await(0,s.clearFeedCache)({method:"POST",data:{feedSettings:l}}),v(!1))}},"Clear cache"),E&&(0,e.createElement)("span",{style:{visibility:"visible",position:"absolute"},className:"spinner"})),(0,e.createElement)(_.PanelBody,{initialOpen:!0,title:(0,t.__)("General","insta-gallery")},(0,e.createElement)(_.SelectControl,{label:(0,t.__)("Account","insta-gallery"),help:(0,t.__)("Please select Instagram account","insta-gallery"),value:l.account_id,onChange:e=>i({account_id:e}),options:h.map((e=>({value:e.id,label:e.nickname||e.username})))}),(0,e.createElement)(_.SelectControl,{label:(0,t.__)("Source","insta-gallery"),value:l.source,onChange:e=>i({source:e}),options:[{value:"tag",label:(0,t.__)("Tag","insta-gallery")},{value:"username",label:(0,t.__)("Username","insta-gallery")}]}),"tag"==l.source&&(0,e.createElement)(e.Fragment,null,(0,e.createElement)(_.TextControl,{label:(0,t.__)("Tag","insta-gallery"),help:(0,t.__)("Please enter Instagram tag","insta-gallery"),value:o,onChange:function(e){c(e)}}),(0,e.createElement)(_.SelectControl,{label:(0,t.__)("Order by","insta-gallery"),help:(0,t.__)("Please enter Instagram tag order","insta-gallery"),value:l.order_by,onChange:e=>i({order_by:e}),options:[{value:"recent_media",label:(0,t.__)("Recent (Within 24 hours)","insta-gallery")},{value:"top_media",label:(0,t.__)("Top (Most popular first)","insta-gallery")}]})),(0,e.createElement)(e.Fragment,null,(0,e.createElement)("ul",{className:"qligg-list-videos"},["carousel","gallery","masonry","highlight"].map(((t,a)=>(0,e.createElement)("li",{key:a,className:g()("qligg-modal-image",l.layout==t&&"active","carousel"!==t&&"gallery"!==t&&"qligg-premium-field"),onClick:()=>i({layout:t})},(0,e.createElement)("span",null,t.replace("-"," ")),(0,e.createElement)("img",{src:`${f}/${t}.png`,alt:"layout"})))))),"tag"!==l.source&&(0,e.createElement)(_.ToggleControl,{label:(0,t.__)("Hide feed reels","insta-gallery"),help:(0,t.__)("Hide reels from feed","insta-gallery"),checked:!!l.reel.hide,onChange:e=>i({reel:{...l.reel,hide:e}})}),(0,e.createElement)(e.Fragment,null,(0,e.createElement)(_.ToggleControl,{label:(0,t.__)("Hide feed copyright","insta-gallery"),help:(0,t.__)("Hide the feeds that have copyright","insta-gallery"),checked:!!l.copyright.hide,onChange:e=>i({copyright:{...l.copyright,hide:e}})})),(0,e.createElement)(_.RangeControl,{label:(0,t.__)("Limit","insta-gallery"),help:(0,t.__)("Number of videos to display","insta-gallery"),value:d,onChange:function(e){u(e)},min:1,max:33}),"carousel"!==l.layout&&(0,e.createElement)(_.RangeControl,{label:(0,t.__)("Columns","insta-gallery"),help:(0,t.__)("Number of videos in a row","insta-gallery"),value:l.columns,onChange:e=>i({columns:e}),min:1,max:20}),"highlight"===l.layout&&(0,e.createElement)(e.Fragment,null,(0,e.createElement)(_.TextControl,{label:(0,t.__)(" highlight by tag","insta-gallery"),help:(0,t.__)("Highlight feeds items with this tags","insta-gallery"),value:l.highlight.tag,onChange:e=>i({highlight:{...l.highlight,tag:e}})}),(0,e.createElement)(_.TextControl,{label:(0,t.__)(" highlight by id","insta-gallery"),help:(0,t.__)(" highlight by id","insta-gallery"),value:l.highlight.id,onChange:e=>i({highlight:{...l.highlight,id:e}})}),(0,e.createElement)(_.TextControl,{label:(0,t.__)(" highlight by position","insta-gallery"),help:(0,t.__)("Highlight feeds items in this positions","insta-gallery"),value:l.highlight.position,onChange:e=>i({highlight:{...l.highlight,position:e}})}))),"carousel"==l.layout&&(0,e.createElement)(_.PanelBody,{initialOpen:!1,title:(0,t.__)("Carousel","insta-gallery")},(0,e.createElement)(_.RangeControl,{label:(0,t.__)("Slides per view","insta-gallery"),help:(0,t.__)("Number of images per slide","insta-gallery"),value:l.carousel.slidespv,onChange:e=>i({carousel:{...l.carousel,slidespv:e}}),min:1,max:10}),(0,e.createElement)(_.ToggleControl,{label:(0,t.__)("Autoplay","insta-gallery"),help:(0,t.__)("Autoplay carousel items","insta-gallery"),checked:!!l.carousel.autoplay,onChange:e=>i({carousel:{...l.carousel,autoplay:e}})}),l.carousel.autoplay&&(0,e.createElement)(_.RangeControl,{label:(0,t.__)("Autoplay Interval","insta-gallery"),help:(0,t.__)("Moves carousel after a certain amount of time ","insta-gallery"),value:l.carousel.autoplay_interval,onChange:e=>i({carousel:{...l.carousel,autoplay_interval:e}}),min:1e3,max:3e5,step:100}),(0,e.createElement)(_.ToggleControl,{label:(0,t.__)("Navigation","insta-gallery"),help:(0,t.__)("Display navigation arrows","insta-gallery"),checked:!!l.carousel.navarrows,onChange:e=>i({carousel:{...l.carousel,navarrows:e}})}),l.carousel.navarrows&&(0,e.createElement)(_.BaseControl,{label:(0,t.__)("Navigation color","insta-gallery"),help:(0,t.__)("Change navigation arrows color","insta-gallery")},(0,e.createElement)(n.ColorPalette,{value:l.carousel.navarrows_color,onChange:e=>i({carousel:{...l.carousel,navarrows_color:e}})})),(0,e.createElement)(_.ToggleControl,{label:(0,t.__)("Pagination","insta-gallery"),help:(0,t.__)("Display pagination dots","insta-gallery"),checked:!!l.carousel.pagination,onChange:e=>i({carousel:{...l.carousel,pagination:e}})}),l.carousel.pagination&&(0,e.createElement)(_.BaseControl,{label:(0,t.__)("Pagination color","insta-gallery"),help:(0,t.__)("Change pagination dots color","insta-gallery")},(0,e.createElement)(n.ColorPalette,{value:l.carousel.pagination_color,onChange:e=>i({carousel:{...l.carousel,pagination_color:e}})}))),(0,e.createElement)(_.PanelBody,{initialOpen:!1,title:(0,t.__)("Profile","insta-gallery")},(0,e.createElement)(_.ToggleControl,{label:(0,t.__)("Display","insta-gallery"),className:"qligg-premium-field",help:(0,t.__)("Display user profile or tag info","insta-gallery"),checked:!!l.profile.display,onChange:e=>i({profile:{...l.profile,display:e}})}),l.profile.display&&(0,e.createElement)(e.Fragment,null,(0,e.createElement)(_.TextControl,{label:(0,t.__)("Full name","insta-gallery"),help:(0,t.__)("Feed profile full name","insta-gallery"),value:l.profile.nickname,onChange:e=>{i({profile:{...l.profile,nickname:e}})}}),(0,e.createElement)(_.TextControl,{label:(0,t.__)("Follow text","insta-gallery"),help:(0,t.__)("Follow text here","insta-gallery"),value:l.profile.link_text,onChange:e=>{i({profile:{...l.profile,link_text:e}})}}),(0,e.createElement)(_.TextControl,{label:(0,t.__)("Website","insta-gallery"),help:(0,t.__)("Website url here","insta-gallery"),value:l.profile.website,onChange:e=>{i({profile:{...l.profile,website:e}})}}),(0,e.createElement)(_.TextControl,{label:(0,t.__)("Website link text","insta-gallery"),help:(0,t.__)("Website link text here","insta-gallery"),value:l.profile.website_text,onChange:e=>{i({profile:{...l.profile,website_text:e}})}}),(0,e.createElement)("div",{style:{display:"flex",flexDirection:"column",alignItems:"right"}},(0,e.createElement)("img",{alt:"",width:"150",height:"150",src:l.profile.avatar||b.avatar||"http://2.gravatar.com/avatar/b642b4217b34b1e8d3bd915fc65c4452?s=150&d=mm&r=g"}),(0,e.createElement)(n.MediaUpload,{onSelect:e=>{i({profile:{...l.profile,avatar:e.url}})},allowedTypes:["image"],value:l.profile.avatar,render:({open:a})=>(0,e.createElement)("div",null,(0,e.createElement)(_.Button,{style:{margin:"15px 5px 15px 0"},variant:"secondary",onClick:a},(0,t.__)("Upload","insta-gallery")),(0,e.createElement)(_.Button,{style:{margin:"15px 0"},variant:"secondary",disabled:!l.profile.avatar||l.profile.avatar===b.avatar,onClick:()=>{i({profile:{...l.profile,avatar:b.avatar||""}})}},"×"))}),(0,e.createElement)(_.TextareaControl,{label:(0,t.__)("Biography","insta-gallery"),help:(0,t.__)("Feed profile biography","insta-gallery"),value:l.profile.biography,onChange:e=>{i({profile:{...l.profile,biography:e}})}})))),(0,e.createElement)(_.PanelBody,{initialOpen:!1,title:(0,t.__)("Box","insta-gallery")},(0,e.createElement)(_.ToggleControl,{label:(0,t.__)("Display","insta-gallery"),className:"qligg-premium-field",help:(0,t.__)("Display the Instagram Feed inside a customizable box","insta-gallery"),checked:!!l.box.display,onChange:e=>i({box:{...l.box,display:e}})}),l.box.display&&(0,e.createElement)(e.Fragment,null,(0,e.createElement)(_.RangeControl,{label:(0,t.__)("Padding","insta-gallery"),className:"qligg-premium-field",help:(0,t.__)("Add padding to the box","insta-gallery"),value:l.box.padding,onChange:e=>i({box:{...l.box,padding:e}}),min:0,max:300}),(0,e.createElement)(_.RangeControl,{label:(0,t.__)("Radius","insta-gallery"),help:(0,t.__)("Add radius to the box","insta-gallery"),className:"qligg-premium-field",value:l.box.radius,onChange:e=>i({box:{...l.box,radius:e}}),min:0,max:1e3}),(0,e.createElement)(_.BaseControl,{label:(0,t.__)("Background","insta-gallery"),help:(0,t.__)("Change background color in box","insta-gallery"),className:"qligg-premium-field"},(0,e.createElement)(n.ColorPalette,{value:l.box.background,onChange:e=>i({box:{...l.box,background:e}})})),(0,e.createElement)(_.BaseControl,{label:(0,t.__)("Text color","insta-gallery"),className:"qligg-premium-field",help:(0,t.__)("Change text color in box","insta-gallery")},(0,e.createElement)(n.ColorPalette,{value:l.box.text_color,onChange:e=>i({box:{...l.box,text_color:e}})})))),(0,e.createElement)(_.PanelBody,{initialOpen:!1,title:(0,t.__)("Image","insta-gallery")},(0,e.createElement)(_.RangeControl,{label:(0,t.__)("Spacing","insta-gallery"),help:(0,t.__)("Add spacing between images","insta-gallery"),value:l.spacing,onChange:e=>i({spacing:e}),min:0,max:50,required:!0}),(0,e.createElement)(_.ToggleControl,{label:(0,t.__)("Lazy load","insta-gallery"),help:(0,t.__)("Defers image load","insta-gallery"),checked:!!l.lazy,onChange:e=>i({lazy:e})}),(0,e.createElement)(_.ToggleControl,{label:(0,t.__)("Mask","insta-gallery"),help:(0,t.__)("Display mask on hover","insta-gallery"),checked:!!l.mask.display,onChange:e=>i({mask:{...l.mask,display:e}})}),l.mask.display&&(0,e.createElement)(e.Fragment,null,(0,e.createElement)(_.BaseControl,{label:(0,t.__)("Mask background","insta-gallery"),help:(0,t.__)("Change background color in mask","insta-gallery")},(0,e.createElement)(n.ColorPalette,{value:l.mask.background,onChange:e=>i({mask:{...l.mask,background:e}})})),"PERSONAL"===b.access_token_type&&(0,e.createElement)("p",{className:"form-field"},(0,e.createElement)("span",{className:"notice error",style:{marginleft:"0",marginright:"0",paddingtop:" 10px",paddingbottom:" 10px",display:" flex",justifycontent:" left",alignitems:" center"}},(0,e.createElement)("small",null,(0,t.__)("Likes and comments options are only available for business account.","insta-gallery")))),(0,e.createElement)(_.ToggleControl,{label:(0,t.__)("Likes","insta-gallery"),help:(0,t.__)("Display likes count in mask","insta-gallery"),checked:!!l.mask.likes_count,disabled:"PERSONAL"===b.access_token_type,onChange:e=>i({mask:{...l.mask,likes_count:e}})}),(0,e.createElement)(_.ToggleControl,{label:(0,t.__)("Comments","insta-gallery"),help:(0,t.__)("Display comments count in mask","insta-gallery"),checked:!!l.mask.comments_count,disabled:"PERSONAL"===b.access_token_type,onChange:e=>i({mask:{...l.mask,comments_count:e}})}))),(0,e.createElement)(_.PanelBody,{initialOpen:!1,title:(0,t.__)("Card","insta-gallery")},(0,e.createElement)(_.ToggleControl,{label:(0,t.__)("Display","insta-gallery"),className:"qligg-premium-field",help:(0,t.__)("Display card in image","insta-gallery"),checked:!!l.card.display,onChange:e=>i({card:{...l.card,display:e}})}),l.card.display&&(0,e.createElement)(e.Fragment,null,(0,e.createElement)(_.RangeControl,{label:(0,t.__)("Radius","insta-gallery"),help:(0,t.__)("Add radius to the card","insta-gallery"),className:"qligg-premium-field",value:l.card.radius,onChange:e=>i({card:{...l.card,radius:e}}),min:0,max:1e3}),(0,e.createElement)(_.RangeControl,{label:(0,t.__)("Font size","insta-gallery"),help:(0,t.__)("Change font size in cards","insta-gallery"),className:"qligg-premium-field",value:l.card.font_size,onChange:e=>i({card:{...l.card,font_size:e}}),min:8,max:36}),(0,e.createElement)(_.BaseControl,{label:(0,t.__)("Background","insta-gallery"),className:"qligg-premium-field",help:(0,t.__)("Change background color in cards","insta-gallery")},(0,e.createElement)(n.ColorPalette,{value:l.card.background,onChange:e=>i({card:{...l.card,background:e}})})),(0,e.createElement)(_.BaseControl,{label:(0,t.__)("Background hover","insta-gallery"),className:"qligg-premium-field",help:(0,t.__)("Change background color hover in cards","insta-gallery")},(0,e.createElement)(n.ColorPalette,{value:l.card.background_hover,onChange:e=>i({card:{...l.card,background_hover:e}})})),(0,e.createElement)(_.BaseControl,{label:(0,t.__)("Text color","insta-gallery"),className:"qligg-premium-field",help:(0,t.__)("Change text color","insta-gallery")},(0,e.createElement)(n.ColorPalette,{value:l.card.text_color,onChange:e=>i({card:{...l.card,text_color:e}})})),(0,e.createElement)(_.RangeControl,{label:(0,t.__)("Padding","insta-gallery"),help:(0,t.__)("Add padding in cards","insta-gallery"),className:"qligg-premium-field",value:l.card.padding,onChange:e=>i({card:{...l.card,padding:e}}),min:0,max:20}),"PERSONAL"===b.access_token_type&&(0,e.createElement)("p",{className:"form-field"},(0,e.createElement)("span",{className:"notice error",style:{marginleft:"0",marginright:"0",paddingtop:" 10px",paddingbottom:" 10px",display:" flex",justifycontent:" left",alignitems:" center"}},(0,e.createElement)("small",null,(0,t.__)("Likes and comments options are only available for business account.","insta-gallery")))),(0,e.createElement)(_.ToggleControl,{label:(0,t.__)("Likes","insta-gallery"),className:"qligg-premium-field",help:(0,t.__)("Display likes count in cards","insta-gallery"),checked:!!l.card.likes_count,disabled:"PERSONAL"===b.access_token_type,onChange:e=>i({card:{...l.card,likes_count:e}})}),(0,e.createElement)(_.ToggleControl,{label:(0,t.__)("Comments","insta-gallery"),className:"qligg-premium-field",help:(0,t.__)("Display comments count in cards","insta-gallery"),checked:!!l.card.comments_count,disabled:"PERSONAL"===b.access_token_type,onChange:e=>i({card:{...l.card,comments_count:e}})}),(0,e.createElement)(_.RangeControl,{label:(0,t.__)("Length","insta-gallery"),help:(0,t.__)("Limit the length of the description in the card","insta-gallery"),className:"qligg-premium-field",value:l.card.text_length,onChange:e=>i({card:{...l.card,text_length:e}}),min:1,max:100}),(0,e.createElement)(_.SelectControl,{label:(0,t.__)("Text align","insta-gallery"),help:(0,t.__)("Align description in card","insta-gallery"),className:"qligg-premium-field",value:l.card.text_align||"",onChange:e=>i({card:{...l.card,text_align:e}}),options:[{value:"left",label:(0,t.__)("Left","insta-gallery")},{value:"center",label:(0,t.__)("Center","insta-gallery")},{value:"right",label:(0,t.__)("Right","insta-gallery")}]}))),(0,e.createElement)(_.PanelBody,{initialOpen:!1,title:(0,t.__)("Modal","insta-gallery")},(0,e.createElement)(_.ToggleControl,{label:(0,t.__)("Display","insta-gallery"),help:(0,t.__)("Display Modal by clicking on image","insta-gallery"),checked:!!l.modal.display,onChange:e=>i({modal:{...l.modal,display:e}})}),l.modal.display&&(0,e.createElement)(e.Fragment,null,(0,e.createElement)(_.SelectControl,{label:(0,t.__)("Sidebar align","insta-gallery"),help:(0,t.__)("Align sidebar in modal","insta-gallery"),className:"qligg-premium-field",value:l.modal.modal_align||"",onChange:e=>i({modal:{...l.modal,modal_align:e}}),options:[{value:"top",label:(0,t.__)("Top","insta-gallery")},{value:"right",label:(0,t.__)("Right","insta-gallery")},{value:"bottom",label:(0,t.__)("Bottom","insta-gallery")},{value:"left",label:(0,t.__)("Left","insta-gallery")}]}),(0,e.createElement)(_.ToggleControl,{label:(0,t.__)("Profile","insta-gallery"),help:(0,t.__)("Display user profile or tag info","insta-gallery"),className:"qligg-premium-field",checked:!!l.modal.profile,onChange:e=>i({modal:{...l.modal,profile:e}})}),"PERSONAL"===b.access_token_type&&(0,e.createElement)("p",{className:"form-field"},(0,e.createElement)("span",{className:"notice error",style:{marginleft:"0",marginright:"0",paddingtop:" 10px",paddingbottom:" 10px",display:" flex",justifycontent:" left",alignitems:" center"}},(0,e.createElement)("small",null,(0,t.__)("Likes and comments options are only available for business account.","insta-gallery")))),(0,e.createElement)(_.ToggleControl,{label:(0,t.__)("Likes","insta-gallery"),help:(0,t.__)("Display likes count in sidebar","insta-gallery"),className:"qligg-premium-field",checked:!!l.modal.likes_count,disabled:"PERSONAL"===b.access_token_type,onChange:e=>i({modal:{...l.modal,likes_count:e}})}),(0,e.createElement)(_.ToggleControl,{label:(0,t.__)("Comments","insta-gallery"),help:(0,t.__)("Display comments count in sidebar","insta-gallery"),className:"qligg-premium-field",checked:!!l.modal.comments_count,disabled:"PERSONAL"===b.access_token_type,onChange:e=>i({modal:{...l.modal,comments_count:e}})}),(0,e.createElement)(_.ToggleControl,{label:(0,t.__)("Description","insta-gallery"),help:(0,t.__)("Display description in the sidebar","insta-gallery"),className:"qligg-premium-field",checked:!!l.modal.media_description,onChange:e=>i({modal:{...l.modal,media_description:e}})}),(0,e.createElement)(_.SelectControl,{label:(0,t.__)("Text align","insta-gallery"),help:(0,t.__)("Align description in sidebar","insta-gallery"),className:"qligg-premium-field",value:l.modal.text_align||"",onChange:e=>i({modal:{...l.modal,text_align:e}}),options:[{value:"left",label:(0,t.__)("Left","insta-gallery")},{value:"center",label:(0,t.__)("Center","insta-gallery")},{value:"right",label:(0,t.__)("Right","insta-gallery")}]}),(0,e.createElement)(_.RangeControl,{label:(0,t.__)("Font size","insta-gallery"),help:(0,t.__)("Change font size in sidebar","insta-gallery"),className:"qligg-premium-field",value:l.modal.font_size,onChange:e=>i({modal:{...l.modal,font_size:e}}),min:8,max:36}))),(0,e.createElement)(_.PanelBody,{initialOpen:!1,title:(0,t.__)("Button","insta-gallery")},(0,e.createElement)(_.ToggleControl,{label:(0,t.__)("Display","insta-gallery"),help:(0,t.__)("Display the button to open Instagram site link","insta-gallery"),checked:!!l.button.display,onChange:e=>i({button:{...l.button,display:e}})}),l.button.display&&(0,e.createElement)(e.Fragment,null,(0,e.createElement)(_.TextControl,{label:(0,t.__)("Text","insta-gallery"),help:(0,t.__)("Change button text","insta-gallery"),value:l.button.text,onChange:e=>i({button:{...l.button,text:e}})}),(0,e.createElement)(_.BaseControl,{label:(0,t.__)("Text color","insta-gallery"),help:(0,t.__)("Change Color text in button","insta-gallery")},(0,e.createElement)(n.ColorPalette,{value:l.button.text_color,onChange:e=>i({button:{...l.button,text_color:e}})})),(0,e.createElement)(_.BaseControl,{label:(0,t.__)("Background","insta-gallery"),help:(0,t.__)("Change background color in button","insta-gallery")},(0,e.createElement)(n.ColorPalette,{value:l.button.background,onChange:e=>i({button:{...l.button,background:e}})})),(0,e.createElement)(_.BaseControl,{label:(0,t.__)("Background hover","insta-gallery"),help:(0,t.__)("Change background hover in button","insta-gallery")},(0,e.createElement)(n.ColorPalette,{value:l.button.background_hover,onChange:e=>i({button:{...l.button,background_hover:e}})})))),(0,e.createElement)(_.PanelBody,{initialOpen:!1,title:(0,t.__)("Button Load More","insta-gallery")},(0,e.createElement)(_.ToggleControl,{label:(0,t.__)("Display","insta-gallery"),help:(0,t.__)("Display the button to load more videos","insta-gallery"),className:"qligg-premium-field",checked:!!l.button_load.display,onChange:e=>i({button_load:{...l.button_load,display:e}})}),l.button_load.display&&(0,e.createElement)(e.Fragment,null,(0,e.createElement)(_.TextControl,{label:(0,t.__)("Text","insta-gallery"),help:(0,t.__)("Change button text","insta-gallery"),value:l.button_load.text,onChange:e=>i({button_load:{...l.button_load,text:e}})}),(0,e.createElement)(_.BaseControl,{label:(0,t.__)("Text color","insta-gallery"),help:(0,t.__)("Change Color text in button","insta-gallery")},(0,e.createElement)(n.ColorPalette,{value:l.button_load.text_color,onChange:e=>i({button_load:{...l.button_load,text_color:e}})})),(0,e.createElement)(_.BaseControl,{label:(0,t.__)("Background","insta-gallery"),help:(0,t.__)("Change background color in button","insta-gallery")},(0,e.createElement)(n.ColorPalette,{value:l.button_load.background,onChange:e=>i({button_load:{...l.button_load,background:e}})})),(0,e.createElement)(_.BaseControl,{label:(0,t.__)("Background hover","insta-gallery"),help:(0,t.__)("Change background hover in button","insta-gallery")},(0,e.createElement)(n.ColorPalette,{value:l.button_load.background_hover,onChange:e=>i({button_load:{...l.button_load,background_hover:e}})})))))},u=(0,m.createContext)({}),p=()=>(0,m.useContext)(u),y=(e,t)=>{switch(t.type){case"SET_CURRENT_FEED_INDEX":case"SET_IS_OPEN":case"SET_IS_IMAGE_LOAD":case"SET_COUNTER":return{...e,...t.payload}}},h=t=>{const{children:a}=t,[l,n]=(0,m.useReducer)(y,{currentFeedIndex:0,isOpen:!1,isImageLoad:!1,counter:0});return(0,e.createElement)(u.Provider,{value:{...l,setCurrentFeedIndex:e=>{l.currentFeedIndex!=e&&n({type:"SET_CURRENT_FEED_INDEX",payload:{currentFeedIndex:e}})},setIsOpen:e=>{l.isOpen!=e&&n({type:"SET_IS_OPEN",payload:{isOpen:e}})},setIsImageLoad:e=>{l.isImageLoad!=e&&n({type:"SET_IS_IMAGE_LOAD",payload:{isImageLoad:e}})},setCounter:e=>{l.counter!=e&&n({type:"SET_COUNTER",payload:{counter:e}})}}},a)};async function f({url:e,data:t,method:a}){if(!e)throw new Error(`Empty url: ${e}`);return await fetch(e,{body:JSON.stringify(t),method:a}).then((e=>e.json())).then((e=>{if(e.code)throw new Error(`${e.code}: ${e?.message||"Unknown"}`);return e})).catch((e=>{throw new Error(e)}))}function b(e,t){const a=[];for(const l in e)if(e.hasOwnProperty(l)){const n=t?t+"["+l+"]":l,r=e[l];a.push(null!==r&&"object"==typeof r?b(r,n):encodeURIComponent(n)+"="+encodeURIComponent(r))}return a.join("&")}u.Consumer;const E=({href:t,className:a,children:l,onClick:n,disabled:r})=>(0,e.createElement)("a",{href:t,target:"blank",onClick:n,className:g()("instagram-gallery__button",a,r&&"instagram-gallery__button--disabled")},l);function v(e,t){const{tag:a,source:l}=e,{username:n}=t;switch(l){case"username":return`https://www.instagram.com/${n}`;case"tag":return`https://www.instagram.com/explore/tags/${a}`;default:return"https://www.instagram.com"}}const k=(C=({userProfile:t,feedSettings:a,onClick:l,after:n})=>{const r=!!a?.button?.display,i=!!a?.button_load?.display;return(0,e.createElement)("div",{className:"instagram-gallery__actions"},r&&(0,e.createElement)(E,{feedSettings:a,href:v(a,t),target:"blank",className:"instagram-gallery__button--follow"},(0,e.createElement)("i",{className:"qligg-icon-instagram "}),a.button.text),i&&(0,e.createElement)(E,{feedSettings:a,className:"instagram-gallery__button--load",disabled:""===n,onClick:l},a.button_load.text))},t=>{const{feedSettings:a}=t,l=!!a.button.display,n=!!a.button_load.display;return(0,e.createElement)(m.Fragment,null,(0,e.createElement)("style",null,l&&`\n #instagram-gallery-feed-${a.id} .instagram-gallery__actions .instagram-gallery__button--follow {\n color: ${a.button.text_color};\n }\n\n #instagram-gallery-feed-${a.id} .instagram-gallery__actions .instagram-gallery__button--follow {\n background-color: ${a.button.background};\n }\n\n #instagram-gallery-feed-${a.id} .instagram-gallery__actions .instagram-gallery__button--follow:hover {\n background-color: ${a.button.background_hover};\n }\n `,n&&`\n #instagram-gallery-feed-${a.id} .instagram-gallery__actions .instagram-gallery__button--load {\n color: ${a.button_load.text_color};\n }\n\n #instagram-gallery-feed-${a.id} .instagram-gallery__actions .instagram-gallery__button--load {\n background-color: ${a.button_load.background};\n }\n\n #instagram-gallery-feed-${a.id} .instagram-gallery__actions .instagram-gallery__button--load:hover {\n background-color: ${a.button_load.background_hover};\n }\n `),(0,e.createElement)(C,{...t}))});var C;const w=()=>{const t=window?.qligg_frontend?.settings?.spinner_image_url;return(0,e.createElement)("div",{className:"instagram-gallery__spinner",style:t?{backgroundImage:`url(${t})`}:{}})},x=({errorUserProfile:t,errorUserMediaList:a})=>(0,e.createElement)("div",{className:"instagram-gallery__alert"},(0,e.createElement)("ul",null,t&&(0,e.createElement)("li",null,(0,e.createElement)("b",null,t.error),(0,e.createElement)("p",null,t.message)),a&&(0,e.createElement)("li",null,(0,e.createElement)("b",null,a.error),(0,e.createElement)("p",null,a.message)))),N=(0,m.memo)((({feedSettings:t,userProfile:a})=>{const l={...a,...function(e){const t={};for(const a in e)e.hasOwnProperty(a)&&""!==e[a]&&(t[a]=e[a]);return t}(t.profile)};return!!t?.profile?.display&&(0,e.createElement)("div",{className:"instagram-gallery__profile"},(0,e.createElement)("div",{className:"avatar"},(0,e.createElement)("img",{src:l.avatar||"http://2.gravatar.com/avatar/b642b4217b34b1e8d3bd915fc65c4452?s=150&d=mm&r=g",alt:l.nickname})),(0,e.createElement)("div",{className:"info"},(0,e.createElement)("div",null,(0,e.createElement)("span",{className:"user"},"@",l.username),l.nickname&&(0,e.createElement)(m.Fragment,null,(0,e.createElement)("span",{className:"separator"},"•"),(0,e.createElement)("span",{className:"user"},l.nickname)),(0,e.createElement)("span",{className:"separator"},"•"),(0,e.createElement)("a",{className:"follow",href:l.link,target:"_blank",rel:"noopener noreferrer"},l.link_text),!!l.website&&(0,e.createElement)(m.Fragment,null,(0,e.createElement)("span",{className:"separator"},"•"),(0,e.createElement)("a",{className:"follow",href:l.website,target:"_blank",rel:"noopener noreferrer"},l.website_text)),(0,e.createElement)("div",{className:"description"},l.biography))))}));var S,I,P,L,A,T,D,M,B,F,R={},q=[],$=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,O=Array.isArray;function U(e,t){for(var a in t)e[a]=t[a];return e}function j(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function z(e,t,a,l,n){var r={type:e,props:t,key:a,ref:l,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,constructor:void 0,__v:null==n?++P:n,__i:-1,__u:0};return null==n&&null!=I.vnode&&I.vnode(r),r}function W(e){return e.children}function V(e,t){this.props=e,this.context=t}function H(e,t){if(null==t)return e.__?H(e.__,e.__i+1):null;for(var a;t<e.__k.length;t++)if(null!=(a=e.__k[t])&&null!=a.__e)return a.__e;return"function"==typeof e.type?H(e):null}function G(e){var t,a;if(null!=(e=e.__)&&null!=e.__c){for(e.__e=e.__c.base=null,t=0;t<e.__k.length;t++)if(null!=(a=e.__k[t])&&null!=a.__e){e.__e=e.__c.base=a.__e;break}return G(e)}}function Z(e){(!e.__d&&(e.__d=!0)&&L.push(e)&&!J.__r++||A!==I.debounceRendering)&&((A=I.debounceRendering)||T)(J)}function J(){var e,t,a,l,n,r,i,o;for(L.sort(D);e=L.shift();)e.__d&&(t=L.length,l=void 0,r=(n=(a=e).__v).__e,i=[],o=[],a.__P&&((l=U({},n)).__v=n.__v+1,I.vnode&&I.vnode(l),le(a.__P,l,n,a.__n,a.__P.namespaceURI,32&n.__u?[r]:null,i,null==r?H(n):r,!!(32&n.__u),o),l.__v=n.__v,l.__.__k[l.__i]=l,ne(i,l,o),l.__e!=r&&G(l)),L.length>t&&L.sort(D));J.__r=0}function X(e,t,a,l,n,r,i,o,s,c,g){var m,_,d,u,p,y=l&&l.__k||q,h=t.length;for(a.__d=s,Y(a,t,y),s=a.__d,m=0;m<h;m++)null!=(d=a.__k[m])&&(_=-1===d.__i?R:y[d.__i]||R,d.__i=m,le(e,d,_,n,r,i,o,s,c,g),u=d.__e,d.ref&&_.ref!=d.ref&&(_.ref&&ie(_.ref,null,d),g.push(d.ref,d.__c||u,d)),null==p&&null!=u&&(p=u),65536&d.__u||_.__k===d.__k?s=Q(d,s,e):"function"==typeof d.type&&void 0!==d.__d?s=d.__d:u&&(s=u.nextSibling),d.__d=void 0,d.__u&=-196609);a.__d=s,a.__e=p}function Y(e,t,a){var l,n,r,i,o,s=t.length,c=a.length,g=c,m=0;for(e.__k=[],l=0;l<s;l++)null!=(n=t[l])&&"boolean"!=typeof n&&"function"!=typeof n?(i=l+m,(n=e.__k[l]="string"==typeof n||"number"==typeof n||"bigint"==typeof n||n.constructor==String?z(null,n,null,null,null):O(n)?z(W,{children:n},null,null,null):void 0===n.constructor&&n.__b>0?z(n.type,n.props,n.key,n.ref?n.ref:null,n.__v):n).__=e,n.__b=e.__b+1,r=null,-1!==(o=n.__i=K(n,a,i,g))&&(g--,(r=a[o])&&(r.__u|=131072)),null==r||null===r.__v?(-1==o&&m--,"function"!=typeof n.type&&(n.__u|=65536)):o!==i&&(o==i-1?m--:o==i+1?m++:(o>i?m--:m++,n.__u|=65536))):n=e.__k[l]=null;if(g)for(l=0;l<c;l++)null!=(r=a[l])&&!(131072&r.__u)&&(r.__e==e.__d&&(e.__d=H(r)),oe(r,r))}function Q(e,t,a){var l,n;if("function"==typeof e.type){for(l=e.__k,n=0;l&&n<l.length;n++)l[n]&&(l[n].__=e,t=Q(l[n],t,a));return t}e.__e!=t&&(t&&e.type&&!a.contains(t)&&(t=H(e)),a.insertBefore(e.__e,t||null),t=e.__e);do{t=t&&t.nextSibling}while(null!=t&&8===t.nodeType);return t}function K(e,t,a,l){var n=e.key,r=e.type,i=a-1,o=a+1,s=t[a];if(null===s||s&&n==s.key&&r===s.type&&!(131072&s.__u))return a;if(l>(null==s||131072&s.__u?0:1))for(;i>=0||o<t.length;){if(i>=0){if((s=t[i])&&!(131072&s.__u)&&n==s.key&&r===s.type)return i;i--}if(o<t.length){if((s=t[o])&&!(131072&s.__u)&&n==s.key&&r===s.type)return o;o++}}return-1}function ee(e,t,a){"-"===t[0]?e.setProperty(t,null==a?"":a):e[t]=null==a?"":"number"!=typeof a||$.test(t)?a:a+"px"}function te(e,t,a,l,n){var r;e:if("style"===t)if("string"==typeof a)e.style.cssText=a;else{if("string"==typeof l&&(e.style.cssText=l=""),l)for(t in l)a&&t in a||ee(e.style,t,"");if(a)for(t in a)l&&a[t]===l[t]||ee(e.style,t,a[t])}else if("o"===t[0]&&"n"===t[1])r=t!==(t=t.replace(/(PointerCapture)$|Capture$/i,"$1")),t=t.toLowerCase()in e||"onFocusOut"===t||"onFocusIn"===t?t.toLowerCase().slice(2):t.slice(2),e.l||(e.l={}),e.l[t+r]=a,a?l?a.u=l.u:(a.u=M,e.addEventListener(t,r?F:B,r)):e.removeEventListener(t,r?F:B,r);else{if("http://www.w3.org/2000/svg"==n)t=t.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if("width"!=t&&"height"!=t&&"href"!=t&&"list"!=t&&"form"!=t&&"tabIndex"!=t&&"download"!=t&&"rowSpan"!=t&&"colSpan"!=t&&"role"!=t&&"popover"!=t&&t in e)try{e[t]=null==a?"":a;break e}catch(e){}"function"==typeof a||(null==a||!1===a&&"-"!==t[4]?e.removeAttribute(t):e.setAttribute(t,"popover"==t&&1==a?"":a))}}function ae(e){return function(t){if(this.l){var a=this.l[t.type+e];if(null==t.t)t.t=M++;else if(t.t<a.u)return;return a(I.event?I.event(t):t)}}}function le(e,t,a,l,n,r,i,o,s,c){var g,m,_,d,u,p,y,h,f,b,E,v,k,C,w,x,N=t.type;if(void 0!==t.constructor)return null;128&a.__u&&(s=!!(32&a.__u),r=[o=t.__e=a.__e]),(g=I.__b)&&g(t);e:if("function"==typeof N)try{if(h=t.props,f="prototype"in N&&N.prototype.render,b=(g=N.contextType)&&l[g.__c],E=g?b?b.props.value:g.__:l,a.__c?y=(m=t.__c=a.__c).__=m.__E:(f?t.__c=m=new N(h,E):(t.__c=m=new V(h,E),m.constructor=N,m.render=se),b&&b.sub(m),m.props=h,m.state||(m.state={}),m.context=E,m.__n=l,_=m.__d=!0,m.__h=[],m._sb=[]),f&&null==m.__s&&(m.__s=m.state),f&&null!=N.getDerivedStateFromProps&&(m.__s==m.state&&(m.__s=U({},m.__s)),U(m.__s,N.getDerivedStateFromProps(h,m.__s))),d=m.props,u=m.state,m.__v=t,_)f&&null==N.getDerivedStateFromProps&&null!=m.componentWillMount&&m.componentWillMount(),f&&null!=m.componentDidMount&&m.__h.push(m.componentDidMount);else{if(f&&null==N.getDerivedStateFromProps&&h!==d&&null!=m.componentWillReceiveProps&&m.componentWillReceiveProps(h,E),!m.__e&&(null!=m.shouldComponentUpdate&&!1===m.shouldComponentUpdate(h,m.__s,E)||t.__v===a.__v)){for(t.__v!==a.__v&&(m.props=h,m.state=m.__s,m.__d=!1),t.__e=a.__e,t.__k=a.__k,t.__k.some((function(e){e&&(e.__=t)})),v=0;v<m._sb.length;v++)m.__h.push(m._sb[v]);m._sb=[],m.__h.length&&i.push(m);break e}null!=m.componentWillUpdate&&m.componentWillUpdate(h,m.__s,E),f&&null!=m.componentDidUpdate&&m.__h.push((function(){m.componentDidUpdate(d,u,p)}))}if(m.context=E,m.props=h,m.__P=e,m.__e=!1,k=I.__r,C=0,f){for(m.state=m.__s,m.__d=!1,k&&k(t),g=m.render(m.props,m.state,m.context),w=0;w<m._sb.length;w++)m.__h.push(m._sb[w]);m._sb=[]}else do{m.__d=!1,k&&k(t),g=m.render(m.props,m.state,m.context),m.state=m.__s}while(m.__d&&++C<25);m.state=m.__s,null!=m.getChildContext&&(l=U(U({},l),m.getChildContext())),f&&!_&&null!=m.getSnapshotBeforeUpdate&&(p=m.getSnapshotBeforeUpdate(d,u)),X(e,O(x=null!=g&&g.type===W&&null==g.key?g.props.children:g)?x:[x],t,a,l,n,r,i,o,s,c),m.base=t.__e,t.__u&=-161,m.__h.length&&i.push(m),y&&(m.__E=m.__=null)}catch(e){if(t.__v=null,s||null!=r){for(t.__u|=s?160:32;o&&8===o.nodeType&&o.nextSibling;)o=o.nextSibling;r[r.indexOf(o)]=null,t.__e=o}else t.__e=a.__e,t.__k=a.__k;I.__e(e,t,a)}else null==r&&t.__v===a.__v?(t.__k=a.__k,t.__e=a.__e):t.__e=re(a.__e,t,a,l,n,r,i,s,c);(g=I.diffed)&&g(t)}function ne(e,t,a){t.__d=void 0;for(var l=0;l<a.length;l++)ie(a[l],a[++l],a[++l]);I.__c&&I.__c(t,e),e.some((function(t){try{e=t.__h,t.__h=[],e.some((function(e){e.call(t)}))}catch(e){I.__e(e,t.__v)}}))}function re(e,t,a,l,n,r,i,o,s){var c,g,m,_,d,u,p,y=a.props,h=t.props,f=t.type;if("svg"===f?n="http://www.w3.org/2000/svg":"math"===f?n="http://www.w3.org/1998/Math/MathML":n||(n="http://www.w3.org/1999/xhtml"),null!=r)for(c=0;c<r.length;c++)if((d=r[c])&&"setAttribute"in d==!!f&&(f?d.localName===f:3===d.nodeType)){e=d,r[c]=null;break}if(null==e){if(null===f)return document.createTextNode(h);e=document.createElementNS(n,f,h.is&&h),o&&(I.__m&&I.__m(t,r),o=!1),r=null}if(null===f)y===h||o&&e.data===h||(e.data=h);else{if(r=r&&S.call(e.childNodes),y=a.props||R,!o&&null!=r)for(y={},c=0;c<e.attributes.length;c++)y[(d=e.attributes[c]).name]=d.value;for(c in y)if(d=y[c],"children"==c);else if("dangerouslySetInnerHTML"==c)m=d;else if(!(c in h)){if("value"==c&&"defaultValue"in h||"checked"==c&&"defaultChecked"in h)continue;te(e,c,null,d,n)}for(c in h)d=h[c],"children"==c?_=d:"dangerouslySetInnerHTML"==c?g=d:"value"==c?u=d:"checked"==c?p=d:o&&"function"!=typeof d||y[c]===d||te(e,c,d,y[c],n);if(g)o||m&&(g.__html===m.__html||g.__html===e.innerHTML)||(e.innerHTML=g.__html),t.__k=[];else if(m&&(e.innerHTML=""),X(e,O(_)?_:[_],t,a,l,"foreignObject"===f?"http://www.w3.org/1999/xhtml":n,r,i,r?r[0]:a.__k&&H(a,0),o,s),null!=r)for(c=r.length;c--;)j(r[c]);o||(c="value","progress"===f&&null==u?e.removeAttribute("value"):void 0!==u&&(u!==e[c]||"progress"===f&&!u||"option"===f&&u!==y[c])&&te(e,c,u,y[c],n),c="checked",void 0!==p&&p!==e[c]&&te(e,c,p,y[c],n))}return e}function ie(e,t,a){try{if("function"==typeof e){var l="function"==typeof e.__u;l&&e.__u(),l&&null==t||(e.__u=e(t))}else e.current=t}catch(e){I.__e(e,a)}}function oe(e,t,a){var l,n;if(I.unmount&&I.unmount(e),(l=e.ref)&&(l.current&&l.current!==e.__e||ie(l,null,t)),null!=(l=e.__c)){if(l.componentWillUnmount)try{l.componentWillUnmount()}catch(e){I.__e(e,t)}l.base=l.__P=null}if(l=e.__k)for(n=0;n<l.length;n++)l[n]&&oe(l[n],t,a||"function"!=typeof e.type);a||j(e.__e),e.__c=e.__=e.__e=e.__d=void 0}function se(e,t,a){return this.constructor(e,a)}S=q.slice,I={__e:function(e,t,a,l){for(var n,r,i;t=t.__;)if((n=t.__c)&&!n.__)try{if((r=n.constructor)&&null!=r.getDerivedStateFromError&&(n.setState(r.getDerivedStateFromError(e)),i=n.__d),null!=n.componentDidCatch&&(n.componentDidCatch(e,l||{}),i=n.__d),i)return n.__E=n}catch(t){e=t}throw e}},P=0,V.prototype.setState=function(e,t){var a;a=null!=this.__s&&this.__s!==this.state?this.__s:this.__s=U({},this.state),"function"==typeof e&&(e=e(U({},a),this.props)),e&&U(a,e),null!=e&&this.__v&&(t&&this._sb.push(t),Z(this))},V.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),Z(this))},V.prototype.render=W,L=[],T="function"==typeof Promise?Promise.prototype.then.bind(Promise.resolve()):setTimeout,D=function(e,t){return e.__v.__b-t.__v.__b},J.__r=0,M=0,B=ae(!1),F=ae(!0);const ce=({feedSettings:t,feedItem:a})=>(0,e.createElement)(m.Fragment,null,(0,e.createElement)("div",{className:"instagram-gallery-item__media-mask"}),"BUSINESS"==a.user_type&&(0,e.createElement)("div",{className:"instagram-gallery-item__media-mask--content"},!!t.mask.likes_count&&(0,e.createElement)("span",{className:"instagram-gallery-item__likes_count--mask"},(0,e.createElement)("i",{className:"qligg-icon-heart instagram-gallery-item__icon-heart"}),a.likes_count||0),!!t.mask.comments_count&&(0,e.createElement)("span",{className:"instagram-gallery-item__comments_count--mask"},(0,e.createElement)("i",{className:"qligg-icon-comment instagram-gallery-item__icon-bubble_chat"}),a.comments_count||0))),ge=({feedItem:t,length:a,index:l,feedSettings:n})=>{const{setIsImageLoad:r}=p(),i="CAROUSEL_ALBUM"===t.media_type&&"VIDEO"===t.media.type,o=null===t.media.url,s=()=>{r(l===a-1)};return(0,e.createElement)("div",{className:"instagram-gallery-item__media-wrap"},o?(0,e.createElement)("img",{alt:"instagram",className:g()("instagram-gallery-item__media"),src:n.copyright.placeholder?n.copyright.placeholder:t.media.thumbnail,onLoad:()=>s()}):"VIDEO"===t.media_type||i?(0,e.createElement)("video",{alt:"instagram",poster:t.media.thumbnail,className:"instagram-gallery-item__media",src:t.media.url,onLoadedData:()=>s()}):(0,e.createElement)("img",{alt:"instagram",className:"instagram-gallery-item__media",src:t.media.url,onLoad:()=>s()}),n.mask.display&&(0,e.createElement)(ce,{feedItem:t,feedSettings:n}),"VIDEO"===t.media_type&&!o&&(0,e.createElement)("i",{className:"instagram-gallery-item__icon qligg-icon-video instagram-gallery-item__icon--views"}),"CAROUSEL_ALBUM"===t.media_type&&(0,e.createElement)("i",{className:"instagram-gallery-item__icon qligg-icon-gallery instagram-gallery-item__icon--views"}),(0,e.createElement)("a",{className:"instagram-gallery-item__icon qligg-icon-instagram instagram-gallery-item__icon--views_count",href:t.link,target:"_blank",rel:"noreferrer"}))},me=e=>{const t=e.highlight.tag?.split(" ");return t.map((e=>e.includes("#")?e:e.split(" ").map((e=>"#"+e)).join(" ")))},_e=(e,t)=>{if(!e)return;const a=e.replace(/<[^>]+>/g,"");let l=a;return l=e.match("[-ヿ㐀-䶿一-鿿豈-ヲ-゚]")?a.split("",t).join(""):a.split(" ",t).join(" "),l.length<e.length?`${l}...`:l},de=(0,m.memo)((({feedSettings:t,feedItem:a})=>(0,e.createElement)("div",{className:"instagram-gallery-item__media-card"},(0,e.createElement)("div",{className:"instagram-gallery-item__info"},!!a.date&&(0,e.createElement)("span",{className:"instagram-gallery-item__date"},(0,e.createElement)("i",{className:"qligg-icon-date"}),a.date),"BUSINESS"==a.user_type&&(0,e.createElement)("div",{className:"instagram-gallery-item__icons"},!!t.card.likes_count&&(0,e.createElement)("span",{className:"instagram-gallery-item__likes_count"},(0,e.createElement)("i",{className:"qligg-icon-heart"}),a.likes_count||0),!!t.card.comments_count&&(0,e.createElement)("span",{className:"instagram-gallery-item__comments_count"},(0,e.createElement)("i",{className:"qligg-icon-comment"}),a.comments_count||0))),!!t.card.text_length&&!!a.media_description&&(0,e.createElement)("p",{className:"instagram-gallery-item__media_description"},_e(a.media_description,t.card.text_length))))),ue=(t=>(a,l)=>{const{feedSettings:n}=a;return(0,e.createElement)(m.Fragment,null,(0,e.createElement)("style",null,n.card.text_align&&`\n\t\t\t\t\t\t#instagram-gallery-feed-${n.id} .instagram-gallery-item .instagram-gallery-item__media-card .instagram-gallery-item__media_description{\n\t\t\t\t\t\ttext-align: ${n.card.text_align};\n\t\t\t\t\t\t}\n\t\t\t\t\t`),(0,e.createElement)(t,{...a,forwardRef:l}))})((({index:t,length:a,feedSettings:l,feedItem:n,onClick:r})=>{const i=function(e,t,a){if(!["highlight","highlight-square"].includes(e.layout))return!1;if(!e?.highlight)return!1;for(const l in e.highlight){const n=e.highlight[l].split(",").map((e=>e.toString().trim()));switch(l){case"position":if(n.includes(a.toString()))return!0;break;case"id":if(n.includes(t.id))return!0;break;case"tag":const l=t.tags?.filter((t=>me(e).includes(t))).length;if(l)return!0}}return!1}(l,n,t),o=function(e){return["carousel","carousel-vertical"].includes(e.layout)}(l),s=!l?.modal?.display&&!!n?.share_url,c=s?"a":"div";return(0,e.createElement)(c,{href:s?n.share_url:void 0,target:s?"_blank":void 0,className:g()("instagram-gallery-item",o&&"swiper-slide",i&&"highlight",`instagram-gallery-item--cols-${l.columns}`),"data-elementor-open-lightbox":"no","data-feed-item-index":t,onClick:r},(0,e.createElement)("div",{className:"instagram-gallery-item__wrap"},(0,e.createElement)(ge,{index:t,feedItem:n,length:a,feedSettings:l}),l.card.display&&(0,e.createElement)(de,{feedItem:n,feedSettings:l})))})),pe="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB3aWR0aD0iMjRweCIgaGVpZ2h0PSIyNHB4IiBwcmVzZXJ2ZUFzcGVjdFJhdGlvPSJ4TWlkWU1pZCBtZWV0IiB2aWV3Qm94PSIwIDAgMjAgMjAiIHN0eWxlPSItbXMtdHJhbnNmb3JtOiByb3RhdGUoMzYwZGVnKTsgLXdlYmtpdC10cmFuc2Zvcm06IHJvdGF0ZSgzNjBkZWcpOyB0cmFuc2Zvcm06IHJvdGF0ZSgzNjBkZWcpOyI+PHBhdGggZmlsbD0iI2ZmZiIgZD0iTTE2IDE3SDJsMy41LTQuNWwyLjUgM2wzLTMuODFBMiAyIDAgMCAxIDEwIDEwVjZIMmEyIDIgMCAwIDAtMiAydjEwYTIgMiAwIDAgMCAyIDJoMTRhMiAyIDAgMCAwIDItMnYtNmgtNS43NXoiLz48cGF0aCBmaWxsPSIjZmZmIiBkPSJNMTkgNGgtLjVWMi41YTIuNSAyLjUgMCAwIDAtNSAwVjRIMTNhMSAxIDAgMCAwLTEgMXY0YTEgMSAwIDAgMCAxIDFoNmExIDEgMCAwIDAgMS0xVjVhMSAxIDAgMCAwLTEtMXptLTMgNGExIDEgMCAxIDEgMS0xYTEgMSAwIDAgMS0xIDF6bTEuNS00aC0zVjIuNzVDMTQuNSAyIDE0LjUgMSAxNiAxczEuNSAxIDEuNSAxLjc1eiIvPjwvc3ZnPgo=",ye=({currentFeedItem:t,feedSettings:a})=>{const l=(0,m.useRef)(null);return(0,e.createElement)("section",{className:"instagram-gallery-modal__media-container insta-gallery-slider-container"},(0,e.createElement)("div",{ref:l,className:"insta-gallery-slider"},t.children.map((t=>(0,e.createElement)("div",{className:"insta-gallery__media"},null===t.media.url?(0,e.createElement)("img",{className:g()("instagram-gallery-modal__media",!a.copyright.placeholder&&"instagram-gallery-modal__media--placeholder"),src:a.copyright.placeholder?a.copyright.placeholder:pe}):"VIDEO"===t.media.type?(0,e.createElement)("video",{controls:!0,poster:t.media.thumbnail,className:"instagram-gallery-modal__media",src:t.media.url}):(0,e.createElement)("img",{className:"instagram-gallery-modal__media",src:t.media.url}))))),(0,e.createElement)("div",{className:"insta-gallery-slider__button-container"},(0,e.createElement)("span",{onClick:()=>{if(l.current.children.length>0){const e=l.current.children.length-1,t=l.current.children[e];l.current.insertBefore(t,l.current.firstChild),l.current.style.transition="none";const a=l.current.children[0].offsetWidth;l.current.style.transform=`translateX(-${a}px)`,setTimeout((()=>{l.current.style.transition="200ms ease-out all",l.current.style.transform="translateX(0)"}),30)}},className:"insta-gallery-slider__button insta-gallery-slider__button--left qligg-icon-prev"}),(0,e.createElement)("span",{onClick:()=>{if(l.current.children.length>0){const e=l.current.children[0];l.current.style.transition="300ms ease-out all";const t=l.current.children[0].offsetWidth;l.current.style.transform=`translateX(-${t}px)`;const a=()=>{l.current.style.transition="none",l.current.style.transform="translateX(0)",l.current.appendChild(e),l.current.removeEventListener("transitionend",a)};l.current.addEventListener("transitionend",a)}},className:"insta-gallery-slider__button insta-gallery-slider__button--right qligg-icon-next"})))},he=(0,m.memo)((({currentFeedItem:t,feedSettings:a})=>{const l=null===t.media.url;if(null===t?.media.url&&"CAROUSEL_ALBUM"!==t?.media_type)return(0,e.createElement)("section",{className:"instagram-gallery-modal__media-container"},(0,e.createElement)("img",{className:"instagram-gallery-modal__media",src:a.copyright.placeholder?a.copyright.placeholder:t.media.thumbnail}),"VIDEO"===t.media_type&&l&&(0,e.createElement)("img",{alt:"thumbnail",src:pe,className:"instagram-gallery-item__icon qligg-icon-video instagram-gallery-item__icon--views"}));switch(t.media_type){case"CAROUSEL_ALBUM":return(0,e.createElement)(ye,{feedSettings:a,currentFeedItem:t});case"VIDEO":return(0,e.createElement)("section",{className:"instagram-gallery-modal__media-container"},(0,e.createElement)("video",{poster:t.media.thumbnail,controls:!0,className:"instagram-gallery-modal__media",src:t.media.url}));default:return(0,e.createElement)("section",{className:"instagram-gallery-modal__media-container"},!!t.media.url&&(0,e.createElement)("img",{className:"instagram-gallery-modal__media",src:t.media.url}))}})),fe=(t=>(a,l)=>{const{feedSettings:n}=a;return(0,e.createElement)(m.Fragment,null,(0,e.createElement)("style",null,n.modal.text_align&&`\n\t\t\t\t\t\t#instagram-gallery-modal-${n.id} .instagram-gallery-modal .instagram-gallery-modal__body .instagram-gallery-modal__media-sidebar .instagram-gallery-modal__media_description {\n\t\t\t\t\t\ttext-align: ${n.modal.text_align};\n\t\t\t\t\t\tfont-size: ${n.modal.font_size}px;\n\t\t\t\t\t\t}\n\t\t\t\t\t`),(0,e.createElement)(t,{...a,forwardRef:l}))})((({currentFeedItem:t,userProfile:a,feedItemsNumber:l,feedSettings:n})=>{const{currentFeedIndex:r}=p();return(0,e.createElement)("section",{className:"instagram-gallery-modal__media-sidebar"},n.modal.profile&&"tag"!==n.source&&(0,e.createElement)("div",{className:"instagram-gallery-modal__profile"},"BUSINESS"==t.user_type&&(0,e.createElement)("img",{alt:a.nickname,src:a.avatar}),(0,e.createElement)("div",null,(0,e.createElement)("span",null,a.nickname),(0,e.createElement)("a",{href:a.link,title:a.nickname,target:"_blank",rel:"noopener noreferrer"},`@${a.username}`))),(0,e.createElement)("div",{className:"instagram-gallery-modal__icons"},(0,e.createElement)("span",{className:"instagram-gallery-modal__counter"},`${r+1} / ${l}`),(0,e.createElement)("a",{className:"instagram-gallery-modal__link",href:t.share_url,target:"_blank",rel:"noopener noreferrer"},(0,e.createElement)("i",{className:"qligg-icon-instagram"})," Instagram")),n.modal.media_description&&(0,e.createElement)("p",{className:"instagram-gallery-modal__media_description",dangerouslySetInnerHTML:{__html:_e(t.media_description,n.modal.text_length)}}),(n.modal.likes_count||n.modal.comments_count)&&"BUSINESS"==t.user_type&&(0,e.createElement)("div",{className:"instagram-gallery-modal__info"},n.modal.likes_count&&(0,e.createElement)("span",{className:"instagram-gallery-modal__likes_count"},(0,e.createElement)("i",{className:"qligg-icon-heart"}),t.likes_count||0),n.modal.comments_count&&(0,e.createElement)("span",{className:"instagram-gallery-modal__comments_count"},(0,e.createElement)("i",{className:"qligg-icon-comment"}),t.comments_count||0)))})),be=({isPrevious:t,classname:a,onClick:l})=>(0,e.createElement)("span",{className:g()("instagram-gallery-modal__button-arrow",a,t&&"qligg-icon-prev",!t&&"qligg-icon-next"),onClick:l}),Ee=({onClick:t})=>(0,e.createElement)("span",{className:"instagram-gallery-modal__button-close",onClick:t}),ve=({children:t,id:a})=>{const{isOpen:l,setIsOpen:n}=p();return l?(0,e.createElement)("div",{className:"instagram-gallery-modal__overlay",id:a,onClick:()=>n(!1)},t):null},ke=({feedItems:t,feedSettings:a,userProfile:l})=>{const{currentFeedIndex:n,setCurrentFeedIndex:r}=p(),{setIsOpen:i}=p(),[o,s]=(0,m.useState)(t[n]),c=!!t[n-1],_=!!t[n+1];return(0,m.useEffect)((()=>{s(t[n])}),[n]),(0,e.createElement)(ve,{id:`instagram-gallery-modal-${a.id}`},(0,e.createElement)("div",{className:"instagram-gallery-modal",onClick:e=>e.stopPropagation()},(0,e.createElement)("div",{className:"instagram-gallery-modal__options"},(0,e.createElement)("div",{className:"instagram-gallery-modal__options--arrows"},(0,e.createElement)(be,{isPrevious:!0,onClick:e=>{e.stopPropagation(),r(c?n-1:t.length-1)}}),(0,e.createElement)(be,{next:!0,onClick:e=>{e.stopPropagation(),r(_?n+1:0)}})),(0,e.createElement)(Ee,{onClick:()=>i(!1)})),(0,e.createElement)("section",{className:g()("instagram-gallery-modal__body","right"!==a.modal.modal_align&&`instagram-gallery-modal__body--sidebar-${a.modal.modal_align}`)},(0,e.createElement)(he,{feedSettings:a,currentFeedItem:o}),(0,e.createElement)(fe,{feedSettings:a,currentFeedItem:o,userProfile:l,feedItemsNumber:t.length}))))},Ce=(0,m.forwardRef)((t=>(a,l)=>{const{feedSettings:n}=a,r=!!n.box.display,i="carousel"==n.layout,o="carousel"!==n.layout,s=!!n.card.display,c=!!n.mask.display,g=["masonry","highlight"].includes(n.layout);return(0,e.createElement)(m.Fragment,null,(0,e.createElement)("style",null,r&&`#instagram-gallery-feed-${n.id} {\n\t\t\t\t\t\t\t\tbackground-color: ${n.box.background}; \n\t\t\t\t\t\t\t\tcolor: ${n.box.text_color}; \n\t\t\t\t\t\t\t\tborder-radius: ${n.box.radius}px;\n\t\t\t\t\t\t\t\tpadding: ${n.box.padding}px;\n\t\t\t\t\t\t\t}`,i&&`#instagram-gallery-feed-${n.id} .swiper-container .swiper-button-prev,\n\t\t\t\t\t\t\t#instagram-gallery-feed-${n.id} .swiper-container .swiper-button-next {\n\t\t\t\t\t\t\t\tcolor: ${n.carousel.navarrows_color}\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t#instagram-gallery-feed-${n.id} .swiper-container .swiper-pagination .swiper-pagination-bullet {\n\t\t\t\t\t\t\t\tbackground-color: ${n.carousel.pagination_color}\n\t\t\t\t\t\t\t}`,o&&`#instagram-gallery-feed-${n.id} .instagram-gallery-item {\n\t\t\t\t\t\t\t\tpadding: ${n.spacing}px;\n\t\t\t\t\t\t\t}`,s&&`#instagram-gallery-feed-${n.id} .instagram-gallery-item__wrap {\n\t\t\t\t\t\t\t\tbackground-color: ${n.card.background};\n\t\t\t\t\t\t\t\tcolor: ${n.card.text_color};\n\t\t\t\t\t\t\t\tfont-size: ${n.card.font_size}px;\n\t\t\t\t\t\t\t\tpadding: ${n.card.padding}px;\n\t\t\t\t\t\t\t\tborder-radius: ${n.card.radius}px;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t#instagram-gallery-feed-${n.id} .instagram-gallery-item__wrap:hover {\n\t\t\t\t\t\t\t\tbackground-color: ${n.card.background_hover};\n\t\t\t\t\t\t\t}`,s&&g&&`#instagram-gallery-feed-${n.id} .instagram-gallery-item__wrap {\n\t\t\t\t\t\t\t\twidth: initial !important;\n\t\t\t\t\t\t\t`,c&&`#instagram-gallery-feed-${n.id} .instagram-gallery-item__media-mask { \n \t\t\t\tbackground-color: ${n.mask.background} !important;\n \t\t\t\t}`),(0,e.createElement)(t,{...a,forwardRef:l}))})((t=>{const a=t.target.parentNode,{masonryRef:l,userMediaList:n,feedSettings:r,className:i,userProfile:o}=t,{currentFeedIndex:s,setCurrentFeedIndex:c}=p(),{setIsOpen:_}=p(),d=!!r?.modal?.display;return(0,e.createElement)(m.Fragment,null,(0,e.createElement)("div",{ref:l,className:g()("instagram-gallery-list",i),"data-feed_layout":r.layout},n.data.map(((t,a)=>{const l=n.data.length;return(0,e.createElement)(ue,{key:t.id,index:a,length:l,feedItem:t,feedSettings:r,onClick:()=>{d&&(c(a),_(!0))}})}))),d&&(0,m.createPortal)((0,e.createElement)(ke,{userProfile:o,feedSettings:r,currentFeedIndex:s,feedItems:n.data}),a))}))),we=function(e,t){const a=(0,m.useRef)();return(0,m.useCallback)((t=>{t?a.current=e(t):a.current&&a.current()}),t)},xe=t=>{const{target:a,userMediaList:l}=t,[n,r]=(0,m.useState)(!0),{isImageLoad:i}=p(),o=we((e=>{const{ownerDocument:t}=e,{defaultView:l}=t;if(!l.Masonry&&!i)return;const n=new l.Masonry(e,{itemSelector:".instagram-gallery-item",isResizable:!0,isAnimated:!1,transitionDuration:0,percentPosition:!0,columnWidth:".instagram-gallery-item:last-child"});r(!1),a.classList.add("loaded");const o=new l.MutationObserver((()=>{n.layout()})),s=e.querySelector(".instagram-gallery-item__wrap");return s&&o.observe(s,{childList:!0,subtree:!0}),()=>{o.disconnect(),n.destroy()}}),[l,i]);return(0,e.createElement)(m.Fragment,null,n&&(0,e.createElement)(w,null),(0,e.createElement)(Ce,{...t,masonryRef:o}))},Ne=t=>{const{userMediaList:a,feedSettings:l}=t,{setCurrentFeedIndex:n}=p(),{setIsOpen:r}=p(),i=(0,m.useCallback)((e=>{if(e){const{defaultView:t}=document;if(!t.Swiper)return;new t.Swiper(e,{slideClass:"instagram-gallery-item",loop:!0,loopedSlidesLimit:!1,centeredSlides:l.carousel.centered_slides,allowTouchMove:!1,slidesPerView:l.carousel.slidespv,spaceBetween:l.spacing?Number(l.spacing):0,autoplay:l.carousel.autoplay&&{delay:l.carousel.autoplay_interval},pagination:{el:e.querySelector(".swiper-pagination"),dynamicBullets:!0,clickable:!0,type:"bullets"},navigation:{nextEl:e.querySelector(".swiper-button-next"),prevEl:e.querySelector(".swiper-button-prev")},breakpoints:{320:{slidesPerView:1,spaceBetween:1},480:{spaceBetween:l.spacing?Number(l.spacing):0,slidesPerView:Math.min(2,l.carousel.slidespv)},768:{spaceBetween:l.spacing?Number(l.spacing):0,slidesPerView:Math.min(3,l.carousel.slidespv)},1024:{spaceBetween:l.spacing?Number(l.spacing):0,slidesPerView:l.carousel.slidespv}}});const a=()=>{e.addEventListener("click",(e=>{(e.target.classList.contains(".swiper-slide-duplicate")||e.target.closest(".swiper-slide-duplicate"))&&(r(!0),n(Number(e.target.closest(".swiper-slide-duplicate").dataset.feedItemIndex)))}))};a()}}),[a,l]);return(0,e.createElement)("div",{ref:i,className:"swiper-container"},(0,e.createElement)(Ce,{className:"swiper-wrapper instagram-gallery-square",...t}),l.carousel.pagination&&(0,e.createElement)("div",{className:"swiper-pagination"}),l.carousel.navarrows&&(0,e.createElement)(m.Fragment,null,(0,e.createElement)("div",{tabIndex:"1",className:"swiper-button-prev"}),(0,e.createElement)("div",{tabIndex:"1",className:"swiper-button-next"})))},Se=t=>{const a=(0,m.useRef)();return(0,e.createElement)(Ce,{ref:a,className:"instagram-gallery-square",...t})},Ie=t=>{const{feedSettings:a,target:l,userMediaList:n}=t,[r,i]=(0,m.useState)(!0),{isImageLoad:o}=p(),s=we((e=>{const{ownerDocument:t}=e,{defaultView:n}=t;if(!n.Masonry&&!o)return;const r=new n.Masonry(e,{itemSelector:".instagram-gallery-item",isResizable:!0,isAnimated:!1,transitionDuration:0,percentPosition:!0,columnWidth:(()=>{const t=e?.querySelector(".instagram-gallery-item:not(.highlight)").offsetWidth,l=e?.offsetWidth;return l/(t-a.spacing)})()});i(!1),l.classList.add("loaded");const s=new n.MutationObserver((()=>{r.layout()})),c=e.querySelector(".instagram-gallery-item__wrap");return c&&s.observe(c,{childList:!0,subtree:!0}),()=>{s.disconnect(),r.destroy()}}),[n,o]);return(0,e.createElement)(m.Fragment,null,r&&(0,e.createElement)(w,null),(0,e.createElement)(Ce,{masonryRef:s,...t}))},Pe=t=>{const{feedSettings:a}=t,{layout:l}=a;switch(l){case"masonry":return(0,e.createElement)(xe,{...t});case"carousel":return(0,e.createElement)(Ne,{...t});case"highlight":return(0,e.createElement)(Ie,{...t});default:return(0,e.createElement)(Se,{...t})}},Le=t=>{const{target:a,feedSettings:l}=t,{isLoading:n,userProfile:r,error:i}=(e=>{const{account_id:t}=e,[a,l]=(0,m.useState)(!0),[n,r]=(0,m.useState)(null),[i,o]=(0,m.useState)(null);return(0,m.useEffect)((()=>{(async()=>{l(!0);try{const t=await async function(e){const t=window?.qligg_frontend?.restRoutePaths.userprofile,a=b({account_id:e.account_id}).toString(),l=`${t}${t.includes("?")?"&":"?"}${a}`;return await f({url:l,method:"GET"})}(e);r(t),l(!1)}catch(e){l(!1),o(e)}})()}),[t]),{isLoading:a,userProfile:n,error:i}})(l),{isLoading:o,isLoadingMore:s,userMediaList:c,error:g,setAfter:_}=(e=>{const{source:t,limit:a,account_id:l,tag:n,order_by:r,copyright:i,reel:o}=e,{counter:s}=p(),[c,g]=(0,m.useState)(!0),[_,d]=(0,m.useState)(!1),[u,y]=(0,m.useState)({paging:{next:null,prev:null},data:[]}),[h,E]=(0,m.useState)(""),[v,k]=(0,m.useState)(null),{setIsImageLoad:C}=p();return(0,m.useEffect)((()=>{k(null),(async()=>{0===s?g(!0):d(!0),C(!1);try{const t=await async function(e,t="",a=0){const l=e?.account_id,n=e?.limit,r=e?.copyright?.hide,i=e?.reel?.hide,o=e?.order_by,s=e?.tag,c=e?.source,g=window?.qligg_frontend?.restRoutePaths?.[c];if(!g)throw new Error(`Unknown source: ${c}`);const m=b({account_id:l,limit:n,hide_items_with_copyright:r,hide_reels:i,after:t,pagination:a,order_by:o,tag:s}).toString(),_=`${g}${g.includes("?")?"&":"?"}${m}`;return await f({url:_,method:"GET"})}(e,h,s);y(0===s?{paging:t?.paging,data:t?.data}:{paging:t?.paging,data:[...u?.data,...t?.data]}),g(!1),d(!1)}catch(e){g(!1),d(!1),k(e)}})()}),[a,r,l,t,n,i?.hide,o?.hide,s]),{isLoading:c,isLoadingMore:_,userMediaList:u,error:v,setAfter:E}})(l),d=n||o,u=i||g,{counter:y,setCounter:h}=p();return(0,m.useEffect)((()=>{d||["masonry","highlight"].includes(l.layout)||a.classList.add("loaded")}),[d]),d?(0,e.createElement)(w,null):u?(0,e.createElement)(x,{errorUserProfile:i,errorUserMediaList:g}):(0,e.createElement)(m.Fragment,null,!!l?.profile?.display&&(0,e.createElement)(N,{feedSettings:l,userProfile:r}),(0,e.createElement)(Pe,{target:a,feedSettings:l,userMediaList:c,userProfile:r}),s&&(0,e.createElement)(w,null),(0,e.createElement)(k,{userProfile:r,feedSettings:l,onClick:e=>{e.preventDefault(),_(c.paging.next),h(y+1)},after:c?.paging?.next}))},Ae=t=>{const{attributes:a,setAttributes:l}=t,i=(0,m.useRef)(null),[o,s]=(0,m.useState)(!1),c=(0,n.useBlockProps)({className:"qligg-box-editor"}),g=(0,r.useInstanceId)(Ae,"qligg");return(0,m.useEffect)((()=>{l({id:g})}),[g,l]),(0,m.useEffect)((()=>{i.current&&!o&&s(!0)}),[i.current]),(0,e.createElement)("div",{...c},(0,e.createElement)("div",{className:"instagram-gallery-feed",ref:i,id:`instagram-gallery-feed-${g}`},o&&(0,e.createElement)(h,null,(0,e.createElement)(Le,{target:i.current,feedSettings:a}))))},Te=(0,m.forwardRef)(Ae),De=t=>{const{href:a,target:l="_self",title:n,children:r,className:i,alert:o}=t;return(0,e.createElement)("a",{href:a,className:g()("insta-gallery__account-button",i),target:l,title:n,onClick:e=>!confirm(o)&&e.preventDefault()},r)},Me=()=>(0,e.createElement)(_.Placeholder,{label:(0,t.__)("Please create access token","insta-gallery"),instructions:(0,t.__)("Before you start creating feeds, you have to create an access token. Please go to the account tab to connect your Instagram account and then reload this page.","insta-gallery")},(0,e.createElement)(e.Fragment,null,(0,e.createElement)("p",null,(0,e.createElement)(De,{href:qligg_gutenberg.QLIGG_PERSONAL_LINK,target:"_blank",title:(0,t.__)("Add Personal Account","insta-gallery")},(0,t.__)("Add Personal Account","insta-gallery")),(0,e.createElement)(De,{className:"qligg-premium-field",href:qligg_gutenberg.QLIGG_BUSSINESS_LINK,target:"_blank",title:(0,t.__)("Add Business Account","insta-gallery")},(0,t.__)("Add Business Account","insta-gallery"))))),Be=({attributes:a,setAttributes:l,accounts:n})=>(0,e.createElement)(_.Placeholder,{label:(0,t.__)("Please select account","insta-gallery"),instructions:(0,t.__)("Before you start creating feeds, you have to select your Instagram account.","insta-gallery")},(0,e.createElement)("p",null,(0,e.createElement)(_.RadioControl,{selected:a.account_id,onChange:e=>l({account_id:e}),options:n.map((e=>({value:e.id,label:e.nickname||e.username})))}))),{U:Fe}={U:"qligg/box"};(0,l.registerBlockType)(Fe,{title:(0,t.__)("Social Feed Gallery","insta-gallery"),description:(0,t.__)("Display beautiful and responsive galleries on your website from your Instagram feed account.","insta-gallery"),icon:"awards",keywords:[(0,t.__)("qligg","insta-gallery"),(0,t.__)("instagram","insta-gallery"),(0,t.__)("quadlayers","insta-gallery")],edit:a=>{const{attributes:l}=a,{accounts:n,hasResolvedAccounts:r}=(0,s.useAccountsEntities)();return r?n&&0!==n.length?n?.find((e=>e.id===l.account_id))?(0,e.createElement)(e.Fragment,null,(0,e.createElement)(d,{...a}),(0,e.createElement)(Te,{...a})):(0,e.createElement)(Be,{...a,accounts:n}):(0,e.createElement)(Me,{...a}):(0,e.createElement)("p",null,(0,e.createElement)("span",{style:{visibility:"visible"},className:"spinner"}),(0,t.__)("Loading…","insta-gallery"))},save:()=>(0,e.createElement)(n.InnerBlocks.Content,null)})})()})();