(()=>{"use strict";const e=window.wp.i18n,t=window.qligg.store;!function({url:a,i18n:o}){if(!1!==window?.QLIGG_IS_PREMIUM)return;const l={account_id:"all",source:["tagged","stories"],layout_type:["masonry","highlight"],highlight_tag:"all",highlight_id:"all",highlight_position:"all",tablet_breakpoint:"all",mobile_breakpoint:"all",tablet_columns:"all",mobile_columns:"all",tablet_spacing:"all",mobile_spacing:"all",profile_display:"all",profile_nickname:"all",profile_link_text:"all",profile_website:"all",profile_website_text:"all",profile_avatar:"all",profile_biography:"all",box_display:"all",box_padding:"all",box_radius:"all",box_background:"all",box_text_color:"all",card_display:"all",card_radius:"all",card_font_size:"all",card_background:"all",card_background_hover:"all",card_text_color:"all",card_padding:"all",card_likes_count:"all",card_comments_count:"all",card_text_length:"all",card_text_align:"all",modal_comments_list:"all",modal_text_align:"all",modal_font_size:"all",button_load_display:"all",button_load_text:"all",button_load_text_color:"all",button_load_background:"all",button_load_background_hover:"all"};let i=!1;elementor.hooks.addAction("panel/open_editor/widget/instagram_feed",(e,t,n)=>{const s=t.get("settings"),r=e=>{if(i)return;const t=e.changedAttributes()||{},n=Object.entries(t).filter(([e,t])=>{if(!(e in l))return!1;const a=l[e];return"all"===a||a.includes(t)}).map(([e])=>e);n.length&&(i=!0,n.forEach(t=>{const a=e.previous(t);e.set(t,a)}),i=!1,elementorCommon.dialogsManager.createWidget("alert",{headerMessage:o.headerMessage,message:o.message,strings:{confirm:o.confirm,cancel:o.close},onConfirm:()=>window.open(a,"_blank")}).show())};s.on("change",r),n.once("destroy",()=>s.off("change",r))}),elementor.hooks.addAction("panel/open_editor/widget/instagram_feed",(a,o,l)=>{const i=a.$el.find('[data-event="qligg:clear_cache"]');i.off("click").on("click",async a=>{if(a.preventDefault(),window.confirm((0,e.__)("You are about to reset the cache of this feed.","insta-gallery"))){i.addClass("elementor-button-state-loading");try{const a=o.get("settings").toJSON();await(0,t.clearFeedCache)({method:"POST",data:{feedSettings:a}}),elementor.notifications.showToast({message:(0,e.__)("Instagram feed cache cleared successfully!","insta-gallery"),type:"success"})}catch(t){elementor.notifications.showToast({message:(0,e.__)("Error clearing Instagram feed cache. Please try again.","insta-gallery"),type:"error"})}finally{i.removeClass("elementor-button-state-loading")}}})}),elementor.hooks.addAction("panel/open_editor/widget/instagram_feed",(e,t,a)=>{const o=t.get("settings"),l=e=>{const t=e.changedAttributes();if(!t||void 0===t.limit)return;const a=parseInt(t.limit,10),o=e.previous("limit");(isNaN(a)||a<1||a>33)&&(e.set("limit",o),elementor.notifications.showToast({message:'El valor de "Limit" debe estar entre 1 y 33.',type:"error",duration:3e3,position:"bottom-left"}))};o.on("change",l),a.once("destroy",()=>o.off("change",l))}),elementor.hooks.addAction("panel/open_editor/widget/instagram_feed",(e,t,a)=>{const o=t.get("settings"),l=e=>{const t=e.changedAttributes();if(t){if(void 0!==t.aspect_ratio_width){const a=t.aspect_ratio_width?.size||t.aspect_ratio_width,o=parseInt(a,10),l=e.previous("aspect_ratio_width");(isNaN(o)||o<1||o>100)&&(e.set("aspect_ratio_width",l),elementor.notifications.showToast({message:"Aspect Ratio Width debe estar entre 1 y 100.",type:"error",duration:3e3,position:"bottom-left"}))}if(void 0!==t.aspect_ratio_height){const a=t.aspect_ratio_height?.size||t.aspect_ratio_height,o=parseInt(a,10),l=e.previous("aspect_ratio_height");(isNaN(o)||o<1||o>100)&&(e.set("aspect_ratio_height",l),elementor.notifications.showToast({message:"Aspect Ratio Height debe estar entre 1 y 100.",type:"error",duration:3e3,position:"bottom-left"}))}}};o.on("change",l),a.once("destroy",()=>o.off("change",l))}),elementor.hooks.addAction("panel/open_editor/widget/instagram_feed",(e,t,a)=>{const o=t.get("settings"),l=e=>{const t=e.changedAttributes();t&&[{field:"desktop_columns",min:1,max:10,label:"Desktop Columns"},{field:"tablet_columns",min:1,max:8,label:"Tablet Columns"},{field:"mobile_columns",min:1,max:6,label:"Mobile Columns"}].forEach(({field:a,min:o,max:l,label:i})=>{if(void 0!==t[a]){const n=t[a]?.size||t[a],s=parseInt(n,10),r=e.previous(a);(isNaN(s)||s<o||s>l)&&(e.set(a,r),elementor.notifications.showToast({message:`${i} debe estar entre ${o} y ${l}.`,type:"error",duration:3e3,position:"bottom-left"}))}})};o.on("change",l),a.once("destroy",()=>o.off("change",l))})}(qligg_elementor_widget)})();