!function(){"use strict";var e={d:function(t,n){for(var o in n)e.o(n,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:n[o]})},o:function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r:function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{init:function(){return v}});var n=window.elementorV2.editor,o=window.React,r=window.elementorV2.editorMcp,i=window.elementorV2.editorUi,l=window.elementorV2.events,a=window.elementorV2.icons,c=window.elementorV2.ui,s=window.wp.i18n;const d="elementor/editor/create-widget",m="https://assets.elementor.com/packages/v1/images/angie-modal-promotion.png",g="ai_widget_cta_clicked",u="angie_install_started",p="angie_install_completed",_="angie_install_abandoned";function w({prompt:e,entryPoint:t,onClose:n}){const[d,g]=(0,o.useState)("idle"),[w,y]=(0,o.useState)(!1),v=()=>{"installing"!==d&&((0,l.trackEvent)({eventName:_,abandon_step:"error"===d?"install_error":"install_modal",trigger_source:t}),n())};return o.createElement(i.ThemeProvider,null,o.createElement(c.Dialog,{fullWidth:!0,maxWidth:"md",open:!0,onClose:v},o.createElement(c.IconButton,{"aria-label":(0,s.__)("Close","elementor"),onClick:v,sx:{position:"absolute",right:8,top:8,zIndex:1}},o.createElement(a.XIcon,null)),o.createElement(c.DialogContent,{sx:{p:0,overflow:"hidden"}},o.createElement(c.Stack,{direction:"row",sx:{height:400}},o.createElement(c.Image,{sx:{height:"100%",aspectRatio:"1 / 1",objectFit:"cover",objectPosition:"right center"},src:m}),o.createElement(c.Stack,{justifyContent:"space-between",p:4},o.createElement(c.Stack,{gap:2.5,justifyContent:"center",sx:{flex:1,paddingInlineEnd:2.5}},o.createElement(c.Typography,{variant:"h4",fontWeight:600,color:"text.secondary"},"error"===d?(0,s.__)("Installation failed","elementor"):(0,s.__)("Create custom widgets with Angie","elementor")),o.createElement(c.Typography,{variant:"body2"},"error"===d?(0,s.__)("We couldn't install Angie automatically. Click below to install it manually.","elementor"):(0,s.__)("Build custom widgets, sections, and code using simple instructions. Install once to start building directly from the editor.","elementor")),"error"!==d&&o.createElement(c.FormControlLabel,{control:o.createElement(c.Checkbox,{size:"small",checked:w,onChange:(e,t)=>y(t)}),label:o.createElement(c.Typography,{variant:"body2",color:"text.secondary"},(0,s.__)("I agree to the","elementor"),o.createElement(c.Link,{sx:{px:.5},href:"https://elementor.com/terms/angie-terms-conditions/",target:"_blank",rel:"noopener noreferrer"},(0,s.__)("Terms","elementor")),(0,s.__)("&","elementor"),o.createElement(c.Link,{sx:{px:.5},href:"https://elementor.com/about/privacy/",target:"_blank",rel:"noopener noreferrer"},(0,s.__)("Privacy Policy.","elementor")))})),o.createElement(c.Stack,{direction:"row",justifyContent:"flex-end"},"error"===d?o.createElement(c.Button,{variant:"contained",color:"accent",onClick:()=>{(0,r.redirectToInstallation)(e)}},(0,s.__)("Install Manually","elementor")):o.createElement(c.Button,{variant:"contained",color:"accent",onClick:async()=>{g("installing"),(0,l.trackEvent)({eventName:u,trigger_source:t});const[n]=await Promise.all([(0,r.installAngiePlugin)(),(0,r.saveAngieConsent)()]);n.success?((0,l.trackEvent)({eventName:p,trigger_source:t}),(0,r.redirectToAppAdmin)(e)):g("error")},disabled:"installing"===d||!w,startIcon:"installing"===d?o.createElement(c.CircularProgress,{size:18,color:"inherit"}):void 0},"installing"===d?(0,s.__)("Installing…","elementor"):(0,s.__)("Install & Activate","elementor"))))))))}function y(){const[e,t]=(0,o.useState)(null);return(0,o.useEffect)(()=>{const e=e=>{const n=e,o=(0,r.isAngieAvailable)();(0,l.trackEvent)({eventName:g,entry_point:n.detail.entry_point,has_angie_installed:o}),o?(0,r.sendPromptToAngie)(n.detail?.prompt):t(n.detail)};return window.addEventListener(d,e),()=>{window.removeEventListener(d,e)}},[]),e?o.createElement(w,{prompt:e.prompt,entryPoint:e.entry_point,onClose:()=>t(null)}):null}function v(){(0,n.injectIntoTop)({id:"create-widget",component:y})}(window.elementorV2=window.elementorV2||{}).editorWidgetCreation=t}(),window.elementorV2.editorWidgetCreation?.init?.();