File "editor-variables.min.js"

Full Path: /home/diablzlo/glucosebalnce.com/wp-content/plugins/elementor/assets/js/packages/editor-variables/editor-variables.min.js
File size: 35.02 KB
MIME-type: text/plain
Charset: utf-8

!function(){"use strict";var e={d:function(t,n){for(var r in n)e.o(n,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:n[r]})},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 qe}});var n=window.elementorV2.editor,r=window.elementorV2.editorCanvas,o=window.elementorV2.editorEditingPanel,a=window.React,l=window.elementorV2.editorControls,i=window.elementorV2.editorProps,c=window.elementorV2.ui;const s=(0,c.styled)(c.UnstableColorIndicator)(({theme:e})=>({borderRadius:e.shape.borderRadius/2+"px",marginRight:e.spacing(.25)}));var m=window.elementorV2.icons,u=window.elementorV2.editorCurrentUser;const p=()=>{const{canUser:e}=(0,u.useCurrentUserCapabilities)();return{canAssign:()=>e("edit_posts"),canUnlink:()=>e("edit_posts"),canAdd:()=>e("manage_options"),canDelete:()=>e("manage_options"),canEdit:()=>e("manage_options"),canRestore:()=>e("manage_options"),canManageSettings:()=>e("manage_options")}};var d=window.elementorV2.schema;const v=(0,i.createPropUtils)("global-color-variable",d.z.string()),E=(0,i.createPropUtils)("global-font-variable",d.z.string());var h=window.elementorV2.editorUi,b=window.wp.i18n,g=window.elementorV2.httpClient;const y="elementor/v1/variables",f="elementor-global-variables",C="elementor-global-variables-watermark",_="RW",k=(()=>{const e={};let t;const n=(t,n)=>!(t in e)||e[t].label!==n.label||e[t].value!==n.value||!(e[t]?.deleted||!n?.deleted)||!(!e[t]?.deleted||n?.deleted),r=e=>{if(e)try{((e,t="preview")=>{const n=window;n.elementor?.helpers?.enqueueFont?.(e,t)})(e)}catch{}};return{subscribe:e=>(t=e,()=>{t=()=>{}}),update:o=>{(t=>{let o=!1;for(const[a,l]of Object.entries(t))n(a,l)&&(e[a]=l,l.type===E.key&&r(l.value),o=!0);return o})(o)&&"function"==typeof t&&t({...e})}}})(),w={MISSING_VARIABLE_NAME:(0,b.__)("Give your variable a name.","elementor"),MISSING_VARIABLE_VALUE:(0,b.__)("Add a value to complete your variable.","elementor"),INVALID_CHARACTERS:(0,b.__)("Use letters, numbers, dashes (-), or underscores (_) for the name.","elementor"),NO_NON_SPECIAL_CHARACTER:(0,b.__)("Names have to include at least one non-special character.","elementor"),VARIABLE_LABEL_MAX_LENGTH:(0,b.__)("Keep names up to 50 characters.","elementor"),DUPLICATED_LABEL:(0,b.__)("This variable name already exists. Please choose a unique name.","elementor"),UNEXPECTED_ERROR:(0,b.__)("There was a glitch. Try saving your variable again.","elementor")},S=e=>39<e.length?w.VARIABLE_LABEL_MAX_LENGTH:"",I=e=>e.trim()?"":w.MISSING_VARIABLE_VALUE,P=new class{constructor(){this.state={watermark:-1,variables:{}}}load(){return this.state.watermark=parseInt(localStorage.getItem(C)||"-1"),this.state.variables=JSON.parse(localStorage.getItem(f)||"{}"),this.state.variables}fill(e,t){this.state.variables={},e&&Object.keys(e).length&&(this.state.variables=e),this.state.watermark=t,localStorage.setItem(C,this.state.watermark.toString()),localStorage.setItem(f,JSON.stringify(this.state.variables))}add(e,t){this.load(),this.state.variables[e]=t,localStorage.setItem(f,JSON.stringify(this.state.variables))}update(e,t){this.load(),this.state.variables[e]=t,localStorage.setItem(f,JSON.stringify(this.state.variables))}watermark(e){this.state.watermark=e,localStorage.setItem(C,this.state.watermark.toString())}watermarkDiff(e,t){const n=t-this.state.watermark;return _===e?1!==n:"RO"===e&&0!==n}},T={variables:()=>P.load(),init:()=>{T.load()},load:()=>(0,g.httpService)().get(y+"/list").then(e=>{const{success:t,data:n}=e.data;if(!t)throw new Error("Unexpected response from server");return n}).then(e=>{const{variables:t,watermark:n}=e;return P.fill(t,n),k.update(t),t}),create:({type:e,label:t,value:n})=>((e,t,n)=>(0,g.httpService)().post(y+"/create",{type:e,label:t,value:n}))(e,t,n).then(e=>{const{success:t,data:n}=e.data;if(!t){const e=n?.message||(0,b.__)("Unexpected response from server","elementor");throw new Error(e)}return n}).then(e=>{const{variable:t,watermark:n}=e;x(_,n);const{id:r,...o}=t;return P.add(r,o),k.update({[r]:o}),{id:r,variable:o}}).catch(e=>{const t=A(e.response);throw t?new Error(t):e}),update:(e,{label:t,value:n})=>((e,t,n)=>(0,g.httpService)().put(y+"/update",{id:e,label:t,value:n}))(e,t,n).then(e=>{const{success:t,data:n}=e.data;if(!t){const e=n?.message||(0,b.__)("Unexpected response from server","elementor");throw new Error(e)}return n}).then(e=>{const{variable:t,watermark:n}=e;x(_,n);const{id:r,...o}=t;return P.update(r,o),k.update({[r]:o}),{id:r,variable:o}}).catch(e=>{const t=A(e.response);throw t?new Error(t):e}),delete:e=>(e=>(0,g.httpService)().post(y+"/delete",{id:e}))(e).then(e=>{const{success:t,data:n}=e.data;if(!t)throw new Error("Unexpected response from server");return n}).then(e=>{const{variable:t,watermark:n}=e;x(_,n);const{id:r,...o}=t;return P.update(r,o),k.update({[r]:o}),{id:r,variable:o}}),restore:(e,t,n)=>((e,t,n)=>{const r={id:e};return t&&(r.label=t),n&&(r.value=n),(0,g.httpService)().post(y+"/restore",r)})(e,t,n).then(e=>{const{success:t,data:n}=e.data;if(!t)throw new Error("Unexpected response from server");return n}).then(e=>{const{variable:t,watermark:n}=e;x(_,n);const{id:r,...o}=t;return P.update(r,o),k.update({[r]:o}),{id:r,variable:o}}).catch(e=>{const t=A(e.response);throw t?new Error(t):e})},x=(e,t)=>{P.watermarkDiff(e,t)&&setTimeout(()=>T.load(),500),P.watermark(t)},A=e=>"duplicated_label"===e?.data?.code?w.DUPLICATED_LABEL:w.UNEXPECTED_ERROR,B=e=>{const t=T.variables();return t?.[e]?{...t[e],key:e}:null},z=(e,t)=>{const n=V(t),r=n.filter(({label:t})=>t.toLowerCase().includes(e.toLowerCase()));return{list:r,hasMatches:r.length>0,isSourceNotEmpty:n.length>0}},V=e=>(0,a.useMemo)(()=>L(e),[e]),L=e=>{const t=T.variables();return Object.entries(t).filter(([,t])=>t.type===e&&(({deleted:e})=>!e)(t)).map(([e,{label:t,value:n}])=>({key:e,label:t,value:n}))},R=e=>T.create(e).then(({id:e})=>e),O=(e,{value:t,label:n})=>T.update(e,{value:t,label:n}).then(({id:e})=>e),U=e=>T.delete(e).then(({id:e})=>e),F=(e,t,n)=>T.restore(e,t,n).then(({id:e})=>e),D=({varType:e,controlPath:t,action:n})=>{const r=window,o=r?.elementor?.editorEvents?.config;if(!o?.names?.variables?.[n])return;const a=o.names.variables[n];r.elementor?.editorEvents?.dispatchEvent(a,{location:o.locations.variables,secondaryLocation:o.secondaryLocations.variablesPopover,trigger:o.triggers.click,var_type:e,control_path:t,action_type:a})},G=(0,a.createContext)(null),j=({children:e})=>{const[t,n]=(0,a.useState)(null);return a.createElement(G.Provider,{value:t},a.createElement(c.Box,{ref:n},e))},H=()=>(0,a.useContext)(G),N=({value:e,onChange:t})=>{const[n,r]=(0,a.useState)(e),[o,l]=(0,a.useState)(""),i=(0,a.useRef)(null),s=H()??i.current;return a.createElement(c.Grid,{container:!0,gap:.75,alignItems:"center"},a.createElement(c.Grid,{item:!0,xs:12},a.createElement(c.FormLabel,{size:"tiny"},(0,b.__)("Value","elementor"))),a.createElement(c.Grid,{item:!0,xs:12},a.createElement(c.UnstableColorField,{size:"tiny",fullWidth:!0,value:n,onChange:e=>{r(e);const n=I(e);l(n),t(n?"":e)},error:o??void 0,slotProps:{colorPicker:{anchorEl:s,anchorOrigin:{vertical:"top",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:-10}}}}),o&&a.createElement(c.FormHelperText,{error:!0},o)))},M=({value:e,onChange:t})=>{const[n,r]=(0,a.useState)(e),[o,l]=(0,a.useState)(""),[i,s]=(0,a.useState)(()=>S(e)),m=(0,a.useId)();return a.createElement(c.Grid,{container:!0,gap:.75,alignItems:"center"},a.createElement(c.Grid,{item:!0,xs:12},a.createElement(c.FormLabel,{htmlFor:m,size:"tiny"},(0,b.__)("Name","elementor"))),a.createElement(c.Grid,{item:!0,xs:12},a.createElement(c.TextField,{id:m,size:"tiny",fullWidth:!0,value:n,error:!!o,onChange:e=>(e=>{r(e);const n=(o=e).trim()?/^[a-zA-Z0-9_-]+$/.test(o)?/[a-zA-Z0-9]/.test(o)?50<o.length?w.VARIABLE_LABEL_MAX_LENGTH:"":w.NO_NON_SPECIAL_CHARACTER:w.INVALID_CHARACTERS:w.MISSING_VARIABLE_NAME;var o;const a=S(e);l(n),s(n?"":a),t(n?"":e)})(e.target.value),inputProps:{maxLength:50}}),o&&a.createElement(c.FormHelperText,{error:!0},o),i&&a.createElement(c.FormHelperText,null,i)))},W="tiny",$=({onGoBack:e,onClose:t})=>{const{setValue:n,path:r}=(0,l.useBoundProp)(v),[i,s]=(0,a.useState)(""),[u,p]=(0,a.useState)(""),[d,E]=(0,a.useState)(""),g=()=>{s(""),p(""),E(""),t()},y=""===i.trim()||""===u.trim()||!!d;return a.createElement(o.PopoverBody,{height:"auto"},a.createElement(h.PopoverHeader,{icon:a.createElement(a.Fragment,null,e&&a.createElement(c.IconButton,{size:W,"aria-label":(0,b.__)("Go Back","elementor"),onClick:e},a.createElement(m.ArrowLeftIcon,{fontSize:W})),a.createElement(m.BrushIcon,{fontSize:W})),title:(0,b.__)("Create variable","elementor"),onClose:g}),a.createElement(c.Divider,null),a.createElement(l.PopoverContent,{p:2},a.createElement(M,{value:u,onChange:e=>{p(e),E("")}}),a.createElement(N,{value:i,onChange:e=>{s(e),E("")}}),d&&a.createElement(c.FormHelperText,{error:!0},d)),a.createElement(c.CardActions,{sx:{pt:.5,pb:1}},a.createElement(c.Button,{size:"small",variant:"contained",disabled:y,onClick:()=>{R({value:i,label:u,type:v.key}).then(e=>{n(e),g()}).catch(e=>{E(e.message)}),D({varType:"color",controlPath:r.join("."),action:"save"})}},(0,b.__)("Create","elementor"))))},K="delete-variable-dialog",X=({open:e,label:t,closeDialog:n,onConfirm:r})=>a.createElement(c.Dialog,{open:e,onClose:n,"aria-labelledby":K,maxWidth:"xs"},a.createElement(c.DialogTitle,{id:K,display:"flex",alignItems:"center",gap:1,sx:{lineHeight:1}},a.createElement(m.AlertOctagonFilledIcon,{color:"error"}),(0,b.__)("Delete this variable?","elementor")),a.createElement(c.DialogContent,null,a.createElement(c.DialogContentText,{variant:"body2",color:"textPrimary"},(0,b.__)("All elements using","elementor"),a.createElement(c.Typography,{variant:"subtitle2",component:"span"}," ",t," "),(0,b.__)("will keep their current values, but the variable itself will be removed.","elementor"))),a.createElement(c.DialogActions,null,a.createElement(c.Button,{color:"secondary",onClick:n},(0,b.__)("Not now","elementor")),a.createElement(c.Button,{variant:"contained",color:"error",onClick:r},(0,b.__)("Delete","elementor")))),J="tiny",q=({onClose:e,onGoBack:t,onSubmit:n,editId:r})=>{const{setValue:i,value:s}=(0,l.useBoundProp)(v),[u,d]=(0,a.useState)(!1),[E,g]=(0,a.useState)(""),y=B(r);if(!y)throw new Error("Global color variable not found");const f=p(),[C,_]=(0,a.useState)(y.value),[k,w]=(0,a.useState)(y.label),S=()=>{r===s&&i(r)},I=[];f.canDelete()&&I.push(a.createElement(c.IconButton,{key:"delete",size:J,"aria-label":(0,b.__)("Delete","elementor"),onClick:()=>{d(!0)}},a.createElement(m.TrashIcon,{fontSize:J})));const P=C===y.value&&k===y.label||!C.trim()||!k.trim()||!!E;return a.createElement(a.Fragment,null,a.createElement(o.PopoverBody,{height:"auto"},a.createElement(h.PopoverHeader,{title:(0,b.__)("Edit variable","elementor"),onClose:e,icon:a.createElement(a.Fragment,null,t&&a.createElement(c.IconButton,{size:J,"aria-label":(0,b.__)("Go Back","elementor"),onClick:t},a.createElement(m.ArrowLeftIcon,{fontSize:J})),a.createElement(m.BrushIcon,{fontSize:J})),actions:I}),a.createElement(c.Divider,null),a.createElement(l.PopoverContent,{p:2},a.createElement(M,{value:k,onChange:e=>{w(e),g("")}}),a.createElement(N,{value:C,onChange:e=>{_(e),g("")}}),E&&a.createElement(c.FormHelperText,{error:!0},E)),a.createElement(c.CardActions,{sx:{pt:.5,pb:1}},a.createElement(c.Button,{size:"small",variant:"contained",disabled:P,onClick:()=>{O(r,{value:C,label:k}).then(()=>{S(),n?.()}).catch(e=>{g(e.message)})}},(0,b.__)("Save","elementor")))),u&&a.createElement(X,{open:!0,label:k,onConfirm:()=>{U(r).then(()=>{S(),n?.()})},closeDialog:()=>{d(!1)}}))},Z=({item:e})=>{const t=e.onEdit;return a.createElement(a.Fragment,null,a.createElement(c.ListItemIcon,null,e.icon),a.createElement(c.Box,{sx:{flex:1,minWidth:0,display:"flex",alignItems:"center",gap:1}},a.createElement(h.EllipsisWithTooltip,{title:e.label||e.value,as:c.Typography,variant:"caption",color:"text.primary",sx:{marginTop:"1px",lineHeight:"2"},maxWidth:"50%"}),e.secondaryText&&a.createElement(h.EllipsisWithTooltip,{title:e.secondaryText,as:c.Typography,variant:"caption",color:"text.tertiary",sx:{marginTop:"1px",lineHeight:"1"},maxWidth:"50%"})),!!t&&a.createElement(c.IconButton,{sx:{mx:1,opacity:"0"},onClick:n=>{n.stopPropagation(),t(e.value)},"aria-label":(0,b.__)("Edit","elementor")},a.createElement(m.EditIcon,{color:"action",fontSize:"tiny"})))},Y=({searchValue:e,onClear:t,icon:n})=>a.createElement(c.Stack,{gap:1,alignItems:"center",justifyContent:"center",height:"100%",p:2.5,color:"text.secondary",sx:{pb:3.5}},n,a.createElement(c.Typography,{align:"center",variant:"subtitle2"},(0,b.__)("Sorry, nothing matched","elementor"),a.createElement("br",null),"“",e,"”."),a.createElement(c.Typography,{align:"center",variant:"caption",sx:{display:"flex",flexDirection:"column"}},(0,b.__)("Try something else.","elementor"),a.createElement(c.Link,{color:"text.secondary",variant:"caption",component:"button",onClick:t},(0,b.__)("Clear & try again","elementor")))),Q=({icon:e,title:t,onAdd:n})=>{const r=p().canAdd();return a.createElement(c.Stack,{gap:1,alignItems:"center",justifyContent:"center",height:"100%",color:"text.secondary",sx:{p:2.5,pb:5.5}},e,r?a.createElement(a.Fragment,null,a.createElement(ee,{title:t||(0,b.__)("Create your first variable","elementor"),message:(0,b.__)("Variables are saved attributes that you can apply anywhere on your site.","elementor")}),n&&a.createElement(c.Button,{variant:"outlined",color:"secondary",size:"small",onClick:n},(0,b.__)("Create a variable","elementor"))):a.createElement(ee,{title:(0,b.__)("There are no variables","elementor"),message:(0,b.__)("With your current role, you can only connect and detach variables.","elementor")}))};function ee({title:e,message:t}){return a.createElement(a.Fragment,null,a.createElement(c.Typography,{align:"center",variant:"subtitle2"},e),a.createElement(c.Typography,{align:"center",variant:"caption",maxWidth:"180px"},t))}const te=(0,c.styled)(c.MenuList)(({theme:e})=>({"& > li":{height:32,width:"100%",display:"flex",alignItems:"center"},'& > [role="option"]':{...e.typography.caption,lineHeight:"inherit",padding:e.spacing(.5,1,.5,2),"&:hover, &:focus":{backgroundColor:e.palette.action.hover},'&[aria-selected="true"]':{backgroundColor:e.palette.action.selected},cursor:"pointer",textOverflow:"ellipsis",position:"absolute",top:0,left:0,"&:hover .MuiIconButton-root, .MuiIconButton-root:focus":{opacity:1}},width:"100%",position:"relative"})),ne="tiny",re=({closePopover:e,onAdd:t,onEdit:n,onSettings:r})=>{const{value:i,setValue:u,path:p}=(0,l.useBoundProp)(v),[d,E]=(0,a.useState)(""),{list:g,hasMatches:y,isSourceNotEmpty:f}=z(d,v.key),C=[];t&&C.push(a.createElement(c.IconButton,{key:"add",size:ne,onClick:()=>{t?.(),D({varType:"color",controlPath:p.join("."),action:"add"})}},a.createElement(m.PlusIcon,{fontSize:ne}))),r&&C.push(a.createElement(c.IconButton,{key:"settings",size:ne,onClick:r},a.createElement(m.SettingsIcon,{fontSize:ne})));const _=g.map(({value:e,label:t,key:r})=>({type:"item",value:r,label:t,icon:a.createElement(s,{size:"inherit",component:"span",value:e}),secondaryText:e,onEdit:n?()=>n?.(r):void 0}));return a.createElement(o.PopoverBody,null,a.createElement(h.PopoverHeader,{title:(0,b.__)("Variables","elementor"),icon:a.createElement(m.ColorFilterIcon,{fontSize:ne}),onClose:e,actions:C}),f&&a.createElement(h.PopoverSearch,{value:d,onSearch:e=>{E(e)},placeholder:(0,b.__)("Search","elementor")}),a.createElement(c.Divider,null),f&&y&&a.createElement(h.PopoverMenuList,{items:_,onSelect:t=>{u(t),D({varType:"color",controlPath:p.join("."),action:"connect"}),e()},onClose:()=>{},selectedValue:i,"data-testid":"color-variables-list",menuListTemplate:te,menuItemContentTemplate:e=>a.createElement(Z,{item:e})}),!y&&f&&a.createElement(Y,{searchValue:d,onClear:()=>{E("")},icon:a.createElement(m.BrushIcon,{fontSize:"large"})}),!f&&a.createElement(Q,{title:(0,b.__)("Create your first color variable","elementor"),icon:a.createElement(m.BrushIcon,{fontSize:"large"}),onAdd:t}))};function oe(){return oe=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},oe.apply(null,arguments)}const ae=({value:e,onChange:t})=>{const[n,r]=(0,a.useState)(e),[i,s]=(0,a.useState)(""),u=(0,a.useRef)(null),p=H()??u.current,d=(0,c.usePopupState)({variant:"popover"}),v=(0,o.useFontFamilies)(),E=(0,o.useSectionWidth)();return a.createElement(c.Grid,{container:!0,gap:.75,alignItems:"center"},a.createElement(c.Grid,{item:!0,xs:12},a.createElement(c.FormLabel,{size:"tiny"},(0,b.__)("Value","elementor"))),a.createElement(c.Grid,{item:!0,xs:12},a.createElement(c.UnstableTag,oe({variant:"outlined",label:n,endIcon:a.createElement(m.ChevronDownIcon,{fontSize:"tiny"})},(0,c.bindTrigger)(d),{fullWidth:!0})),a.createElement(c.Popover,oe({disablePortal:!0,disableScrollLock:!0,anchorEl:p,anchorOrigin:{vertical:"top",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:-28}},(0,c.bindPopover)(d)),a.createElement(l.FontFamilySelector,{fontFamilies:v,fontFamily:n,onFontFamilyChange:e=>{(e=>{r(e);const n=I(e);s(n),t(n?"":e)})(e),d.close()},onClose:d.close,sectionWidth:E})),i&&a.createElement(c.FormHelperText,{error:!0},i)))},le="tiny",ie=({onClose:e,onGoBack:t})=>{const{setValue:n,path:r}=(0,l.useBoundProp)(E),[i,s]=(0,a.useState)(""),[u,p]=(0,a.useState)(""),[d,v]=(0,a.useState)(""),g=()=>{s(""),p(""),v(""),e()},y=""===i.trim()||""===u.trim()||!!d;return a.createElement(o.PopoverBody,{height:"auto"},a.createElement(h.PopoverHeader,{icon:a.createElement(a.Fragment,null,t&&a.createElement(c.IconButton,{size:le,"aria-label":(0,b.__)("Go Back","elementor"),onClick:t},a.createElement(m.ArrowLeftIcon,{fontSize:le})),a.createElement(m.TextIcon,{fontSize:le})),title:(0,b.__)("Create variable","elementor"),onClose:g}),a.createElement(c.Divider,null),a.createElement(l.PopoverContent,{p:2},a.createElement(M,{value:u,onChange:e=>{p(e),v("")}}),a.createElement(ae,{value:i,onChange:e=>{s(e),v("")}}),d&&a.createElement(c.FormHelperText,{error:!0},d)),a.createElement(c.CardActions,{sx:{pt:.5,pb:1}},a.createElement(c.Button,{size:"small",variant:"contained",disabled:y,onClick:()=>{R({value:i,label:u,type:E.key}).then(e=>{n(e),g()}).catch(e=>{v(e.message)}),D({varType:"font",controlPath:r.join("."),action:"save"})}},(0,b.__)("Create","elementor"))))},ce="tiny",se=({onClose:e,onGoBack:t,onSubmit:n,editId:r})=>{const{setValue:i,value:s}=(0,l.useBoundProp)(E),[u,d]=(0,a.useState)(!1),[v,g]=(0,a.useState)(""),y=B(r);if(!y)throw new Error(`Global font variable "${r}" not found`);const f=p(),[C,_]=(0,a.useState)(y.value),[k,w]=(0,a.useState)(y.label),S=()=>{r===s&&i(r)},I=C===y.value&&k===y.label||!C.trim()||!k.trim()||!!v,P=[];return f.canDelete()&&P.push(a.createElement(c.IconButton,{key:"delete",size:ce,"aria-label":(0,b.__)("Delete","elementor"),onClick:()=>{d(!0)}},a.createElement(m.TrashIcon,{fontSize:ce}))),a.createElement(a.Fragment,null,a.createElement(o.PopoverBody,{height:"auto"},a.createElement(h.PopoverHeader,{icon:a.createElement(a.Fragment,null,t&&a.createElement(c.IconButton,{size:ce,"aria-label":(0,b.__)("Go Back","elementor"),onClick:t},a.createElement(m.ArrowLeftIcon,{fontSize:ce})),a.createElement(m.TextIcon,{fontSize:ce})),title:(0,b.__)("Edit variable","elementor"),onClose:e,actions:P}),a.createElement(c.Divider,null),a.createElement(l.PopoverContent,{p:2},a.createElement(M,{value:k,onChange:e=>{w(e),g("")}}),a.createElement(ae,{value:C,onChange:e=>{_(e),g("")}}),v&&a.createElement(c.FormHelperText,{error:!0},v)),a.createElement(c.CardActions,{sx:{pt:.5,pb:1}},a.createElement(c.Button,{size:"small",variant:"contained",disabled:I,onClick:()=>{O(r,{value:C,label:k}).then(()=>{S(),n?.()}).catch(e=>{g(e.message)})}},(0,b.__)("Save","elementor")))),u&&a.createElement(X,{open:!0,label:k,onConfirm:()=>{U(r).then(()=>{S(),n?.()})},closeDialog:()=>{d(!1)}}))},me="tiny",ue=({closePopover:e,onAdd:t,onEdit:n,onSettings:r})=>{const{value:i,setValue:s,path:u}=(0,l.useBoundProp)(E),[p,d]=(0,a.useState)(""),{list:v,hasMatches:g,isSourceNotEmpty:y}=z(p,E.key),f=[];t&&f.push(a.createElement(c.IconButton,{key:"add",size:me,onClick:()=>{t?.(),D({varType:"font",controlPath:u.join("."),action:"add"})}},a.createElement(m.PlusIcon,{fontSize:me}))),r&&f.push(a.createElement(c.IconButton,{key:"settings",size:me,onClick:r},a.createElement(m.SettingsIcon,{fontSize:me})));const C=v.map(({value:e,label:t,key:r})=>({type:"item",value:r,label:t,icon:a.createElement(m.TextIcon,{fontSize:me}),secondaryText:e,onEdit:n?()=>n?.(r):void 0}));return a.createElement(o.PopoverBody,null,a.createElement(h.PopoverHeader,{title:(0,b.__)("Variables","elementor"),onClose:e,icon:a.createElement(m.ColorFilterIcon,{fontSize:me}),actions:f}),y&&a.createElement(h.PopoverSearch,{value:p,onSearch:e=>{d(e)},placeholder:(0,b.__)("Search","elementor")}),a.createElement(c.Divider,null),y&&g&&a.createElement(h.PopoverMenuList,{items:C,onSelect:t=>{s(t),D({varType:"font",controlPath:u.join("."),action:"connect"}),e()},onClose:()=>{},selectedValue:i,"data-testid":"font-variables-list",menuListTemplate:te,menuItemContentTemplate:e=>a.createElement(Z,{item:e})}),!g&&y&&a.createElement(Y,{searchValue:p,onClear:()=>{d("")},icon:a.createElement(m.TextIcon,{fontSize:"large"})}),!y&&a.createElement(Q,{title:(0,b.__)("Create your first font variable","elementor"),icon:a.createElement(m.TextIcon,{fontSize:"large"}),onAdd:t}))},pe="list",de="add",ve="edit",Ee=({closePopover:e,propTypeKey:t,selectedVariable:n})=>{const[r,o]=(0,a.useState)(pe),[l,i]=(0,a.useState)("");return a.createElement(j,null,function(e){const t=p(),n={onClose:()=>{e.closePopover()},onGoBack:()=>{e.setCurrentView(pe)}};t.canAdd()&&(n.onAdd=()=>{e.setCurrentView(de)}),t.canEdit()&&(n.onEdit=t=>{e.setEditId(t),e.setCurrentView(ve)});const r=()=>{e?.selectedVariable?.key===e.editId?n.onClose():n.onGoBack?.()};if(E.key===e.propTypeKey){if(pe===e.currentView)return a.createElement(ue,{closePopover:n.onClose,onAdd:n.onAdd,onEdit:n.onEdit});if(de===e.currentView)return a.createElement(ie,{onGoBack:n.onGoBack,onClose:n.onClose});if(ve===e.currentView)return a.createElement(se,{editId:e.editId,onGoBack:n.onGoBack,onClose:n.onClose,onSubmit:r})}if(v.key===e.propTypeKey){if(pe===e.currentView)return a.createElement(re,{closePopover:n.onClose,onAdd:n.onAdd,onEdit:n.onEdit});if(de===e.currentView)return a.createElement($,{onGoBack:n.onGoBack,onClose:n.onClose});if(ve===e.currentView)return a.createElement(q,{editId:e.editId,onGoBack:n.onGoBack,onClose:n.onClose,onSubmit:r})}return null}({propTypeKey:t,currentView:r,selectedVariable:n,editId:l,setEditId:i,setCurrentView:o,closePopover:e}))};function he(){return he=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},he.apply(null,arguments)}const be="tiny",ge=({startIcon:e,label:t,onUnlink:n,...r})=>{const o=[];return n&&o.push(a.createElement(c.IconButton,{key:"unlink",size:be,onClick:n,"aria-label":(0,b.__)("Unlink","elementor")},a.createElement(m.DetachIcon,{fontSize:be}))),a.createElement(c.Tooltip,{title:t,placement:"top"},a.createElement(c.UnstableTag,he({fullWidth:!0,showActionsOnHover:!0,startIcon:a.createElement(c.Stack,{gap:.5,direction:"row",alignItems:"center"},e),label:a.createElement(c.Box,{sx:{display:"inline-grid",minWidth:0}},a.createElement(c.Typography,{sx:{lineHeight:1.34},variant:"caption",noWrap:!0},t)),actions:o},r)))};function ye(){return ye=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},ye.apply(null,arguments)}const fe=({variable:e,variablePropTypeUtil:t,fallbackPropTypeUtil:n,additionalStartIcon:r})=>{const{setValue:o}=(0,l.useBoundProp)(),i=(0,a.useRef)(null),s=(0,a.useId)(),u=(0,c.usePopupState)({variant:"popover",popupId:`elementor-variables-list-${s}`});return a.createElement(c.Box,{ref:i},a.createElement(ge,ye({label:e.label,startIcon:a.createElement(a.Fragment,null,a.createElement(m.ColorFilterIcon,{fontSize:be}),r),onUnlink:()=>{o(n.create(e.value))}},(0,c.bindTrigger)(u))),a.createElement(c.Popover,ye({disableScrollLock:!0,anchorEl:i.current,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},PaperProps:{sx:{my:1}}},(0,c.bindPopover)(u)),a.createElement(Ee,{selectedVariable:e,closePopover:u.close,propTypeKey:t.key})))},Ce=({variableId:e,onClose:t,onSubmit:n})=>{const{setValue:r}=(0,l.useBoundProp)(v),i=B(e);if(!i)throw new Error("Global color variable not found");const[s,u]=(0,a.useState)(w.DUPLICATED_LABEL),[p,d]=(0,a.useState)(i.label),[E,g]=(0,a.useState)(i.value),y=E===i.value&&p===i.label||!E.trim()||!p.trim()||!!s;return a.createElement(j,null,a.createElement(o.PopoverBody,{height:"auto"},a.createElement(h.PopoverHeader,{icon:a.createElement(m.BrushIcon,{fontSize:"tiny"}),title:(0,b.__)("Restore variable","elementor"),onClose:t}),a.createElement(c.Divider,null),a.createElement(l.PopoverContent,{p:2},a.createElement(M,{value:p,onChange:e=>{d(e),u("")}}),a.createElement(N,{value:E,onChange:e=>{g(e),u("")}}),s&&a.createElement(c.FormHelperText,{error:!0},s)),a.createElement(c.CardActions,{sx:{pt:.5,pb:1}},a.createElement(c.Button,{size:"small",variant:"contained",disabled:y,onClick:()=>{F(e,p,E).then(()=>{r(e),n?.()}).catch(e=>{u(e.message)})}},(0,b.__)("Restore","elementor")))))},_e=({variableId:e,onClose:t,onSubmit:n})=>{const{setValue:r}=(0,l.useBoundProp)(E),i=B(e);if(!i)throw new Error(`Global font variable "${e}" not found`);const[s,u]=(0,a.useState)(w.DUPLICATED_LABEL),[p,d]=(0,a.useState)(i.value),[v,g]=(0,a.useState)(i.label),y=p===i.value&&v===i.label||!p.trim()||!v.trim()||!!s;return a.createElement(j,null,a.createElement(o.PopoverBody,{height:"auto"},a.createElement(h.PopoverHeader,{icon:a.createElement(m.TextIcon,{fontSize:"tiny"}),title:(0,b.__)("Restore variable","elementor"),onClose:t}),a.createElement(c.Divider,null),a.createElement(l.PopoverContent,{p:2},a.createElement(M,{value:v,onChange:e=>{g(e),u("")}}),a.createElement(ae,{value:p,onChange:e=>{d(e),u("")}}),s&&a.createElement(c.FormHelperText,{error:!0},s)),a.createElement(c.CardActions,{sx:{pt:.5,pb:1}},a.createElement(c.Button,{size:"small",variant:"contained",disabled:y,onClick:()=>{F(e,v,p).then(()=>{r(e),n?.()}).catch(e=>{u(e.message)})}},(0,b.__)("Restore","elementor")))))},ke=({onClose:e,onUnlink:t,onRestore:n,label:r})=>{const l=(0,o.useSectionWidth)();return a.createElement(c.ClickAwayListener,{onClickAway:e},a.createElement(c.Alert,{variant:"standard",severity:"warning",onClose:e,action:a.createElement(a.Fragment,null,t&&a.createElement(c.AlertAction,{variant:"contained",onClick:t},(0,b.__)("Unlink","elementor")),n&&a.createElement(c.AlertAction,{variant:"outlined",onClick:n},(0,b.__)("Restore","elementor"))),sx:{width:l}},a.createElement(c.AlertTitle,null,(0,b.__)("Deleted variable","elementor")),(0,b.__)("The variable","elementor")," '",r,"'"," ",(0,b.__)("has been deleted, but it is still referenced in this location. You may restore the variable or unlink it to assign a different value.","elementor")))};function we(){return we=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},we.apply(null,arguments)}const Se=a.forwardRef(({label:e,onClick:t,...n},r)=>a.createElement(c.Chip,we({ref:r,size:"tiny",color:"warning",shape:"rounded",variant:"standard",onClick:t,icon:a.createElement(m.AlertTriangleFilledIcon,null),label:a.createElement(c.Tooltip,{title:e,placement:"top"},a.createElement(c.Box,{sx:{display:"flex",gap:.5,alignItems:"center"}},a.createElement(c.Typography,{variant:"caption",noWrap:!0},e),a.createElement(c.Typography,{variant:"caption",noWrap:!0,sx:{textOverflow:"initial",overflow:"visible"}},"(",(0,b.__)("deleted","elementor"),")"))),sx:{height:e=>e.spacing(3.5),borderRadius:e=>e.spacing(1),justifyContent:"flex-start",width:"100%"}},n)));function Ie(){return Ie=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Ie.apply(null,arguments)}const Pe=({variable:e,variablePropTypeUtil:t,fallbackPropTypeUtil:n})=>{const{setValue:r}=(0,l.useBoundProp)(),o=p(),[i,s]=(0,a.useState)(!1),m=()=>s(!1),u=(0,a.useRef)(null),d=(0,a.useId)(),h=(0,c.usePopupState)({variant:"popover",popupId:`elementor-variables-restore-${d}`}),b={};o.canUnlink()&&(b.onUnlink=()=>{r(n.create(e.value))}),o.canRestore()&&(b.onRestore=()=>{e.key&&F(e.key).then(e=>{r(t.create(e)),m()}).catch(()=>{m(),h.setAnchorEl(u.current),h.open()})});const g=()=>{h.close()};return a.createElement(a.Fragment,null,a.createElement(c.Box,{ref:u},i&&a.createElement(c.Backdrop,{open:!0,onClick:m,invisible:!0}),a.createElement(c.Infotip,{color:"warning",placement:"right-start",open:i,disableHoverListener:!0,onClose:m,content:a.createElement(ke,{onClose:m,onUnlink:b.onUnlink,onRestore:b.onRestore,label:e.label}),slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[0,24]}}]}}},a.createElement(Se,{label:e.label,onClick:()=>s(e=>!e)})),a.createElement(c.Popover,Ie({disableScrollLock:!0,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"},PaperProps:{sx:{my:1}}},(0,c.bindPopover)(h)),E.key===t.key&&a.createElement(_e,{variableId:e.key??"",onClose:h.close,onSubmit:g}),v.key===t.key&&a.createElement(Ce,{variableId:e.key??"",onClose:h.close,onSubmit:g}))))},Te=({onClose:e,onClear:t})=>{const n=(0,o.useSectionWidth)();return a.createElement(c.ClickAwayListener,{onClickAway:e},a.createElement(c.Alert,{variant:"standard",severity:"warning",onClose:e,action:a.createElement(a.Fragment,null,t&&a.createElement(c.AlertAction,{variant:"contained",onClick:t},(0,b.__)("Clear","elementor"))),sx:{width:n}},a.createElement(c.AlertTitle,null,(0,b.__)("This variable is missing","elementor")),(0,b.__)("It may have been deleted. Try clearing this field and select a different value or variable.","elementor")))};function xe(){return xe=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},xe.apply(null,arguments)}const Ae=a.forwardRef(({label:e,onClick:t,...n},r)=>a.createElement(c.Chip,xe({ref:r,size:"tiny",color:"warning",shape:"rounded",variant:"standard",onClick:t,icon:a.createElement(m.AlertTriangleFilledIcon,null),label:e,sx:{height:e=>e.spacing(3.5),borderRadius:e=>e.spacing(1),justifyContent:"flex-start",width:"100%"}},n))),Be=()=>{const{setValue:e}=(0,l.useBoundProp)(),[t,n]=(0,a.useState)(!1),r=()=>n(!1);return a.createElement(a.Fragment,null,t&&a.createElement(c.Backdrop,{open:!0,onClick:r,invisible:!0}),a.createElement(c.Infotip,{color:"warning",placement:"right-start",open:t,disableHoverListener:!0,onClose:r,content:a.createElement(Te,{onClose:r,onClear:()=>e(null)}),slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[0,24]}}]}}},a.createElement(Ae,{label:(0,b.__)("Missing variable","elementor"),onClick:()=>n(e=>!e)})))},ze=()=>{const{value:e}=(0,l.useBoundProp)(v),t=B(e);return t?t?.deleted?a.createElement(Pe,{variable:t,variablePropTypeUtil:v,fallbackPropTypeUtil:i.colorPropTypeUtil}):a.createElement(fe,{variable:t,variablePropTypeUtil:v,fallbackPropTypeUtil:i.colorPropTypeUtil,additionalStartIcon:a.createElement(s,{size:"inherit",value:t.value,component:"span"})}):a.createElement(Be,null)},Ve=e=>!!v.isValid(e),Le=e=>!!E.isValid(e),Re=()=>{const{propType:e,path:t}=(0,o.useBoundProp)(),n=!!e&&(e=>"union"===e.kind&&v.key in e.prop_types)(e);return{visible:n,icon:m.ColorFilterIcon,title:(0,b.__)("Variables","elementor"),content:({close:e})=>(D({varType:"color",controlPath:t.join("."),action:"open"}),a.createElement(Ee,{closePopover:e,propTypeKey:v.key}))}},Oe=e=>{const t=e?.value?.color?.value;return B(t||"")},Ue=({value:e})=>{const t=Oe(e);return a.createElement(s,{component:"span",size:"inherit",value:t?.value})},Fe=({value:e})=>{const t=Oe(e);return a.createElement("span",null,t?.label)},De=({value:e})=>{const t=Oe(e);return a.createElement(s,{component:"span",size:"inherit",value:t?.value})},Ge=(e,t)=>{let n=e,r="";return t&&(r=t.value),t&&!t.deleted&&(n=t.label),n.trim()?r.trim()?`var(--${n}, ${r})`:`var(--${n})`:null},je=(0,r.createTransformer)(e=>{const t=T.variables()[e];if(!t)return a.createElement("span",null,(0,b.__)("Missing variable","elementor"));const n=t.type===v.key,r=Ge(e,t);return a.createElement(c.Stack,{direction:"row",spacing:.5,sx:{paddingInline:"1px"},alignItems:"center"},n&&a.createElement(s,{size:"inherit",value:t.value}),a.createElement(c.Typography,{variant:"caption",overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis"},r))}),He=(0,r.createTransformer)(e=>{const t=T.variables();return t[e]?Ge(e,t[e]):null}),{registerPopoverAction:Ne}=o.controlActionsMenu;const Me=()=>{const{value:e}=(0,l.useBoundProp)(E),t=B(e);return t?t?.deleted?a.createElement(Pe,{variable:t,variablePropTypeUtil:E,fallbackPropTypeUtil:i.stringPropTypeUtil}):a.createElement(fe,{variable:t,variablePropTypeUtil:E,fallbackPropTypeUtil:i.stringPropTypeUtil}):a.createElement(Be,null)},We=()=>{const{propType:e,path:t}=(0,o.useBoundProp)(),n=!!e&&(e=>"union"===e.kind&&E.key in e.prop_types)(e);return{visible:n,icon:m.ColorFilterIcon,title:(0,b.__)("Variables","elementor"),content:({close:e})=>(D({varType:"font",controlPath:t.join("."),action:"open"}),a.createElement(Ee,{closePopover:e,propTypeKey:E.key}))}},{registerPopoverAction:$e}=o.controlActionsMenu;var Ke=window.elementorV2.editorV1Adapters;const Xe="body";function Je(){const e=(0,Ke.__privateUseListenTo)((0,Ke.commandEndEvent)("editor/documents/attach-preview"),()=>function(){const e=window;return e.elementor?.$preview?.[0]?.contentDocument}()?.head),t=function(){const[e,t]=(0,a.useState)({});return(0,a.useEffect)(()=>{const e=k.subscribe(t);return()=>{e()}},[]),e}(),n=Object.keys(t).length>0;if(!e||!n)return null;const r=(o=t,Object.entries(o).map(([e,t])=>function(e,t){return`--${t?.deleted?e:t.label}:${t.value};`}(e,t)).join(""));var o;const l=`${Xe}{${r}}`;return a.createElement(c.Portal,{container:e},a.createElement("style",{"data-e-style-id":"e-variables",key:l},l))}function qe(){(0,o.registerControlReplacement)({component:ze,condition:({value:e})=>Ve(e)}),Ne({id:"color-variables",useProps:Re}),r.styleTransformersRegistry.register(v.key,He),o.stylesInheritanceTransformersRegistry.register(v.key,je),(0,l.injectIntoRepeaterItemIcon)({id:"color-variables-background-icon",component:Ue,condition:({value:e})=>Ve(i.backgroundColorOverlayPropTypeUtil.extract(e)?.color)}),(0,l.injectIntoRepeaterItemIcon)({id:"color-variables-icon",component:De,condition:({value:e})=>Ve(i.shadowPropTypeUtil.extract(e)?.color)}),(0,l.injectIntoRepeaterItemLabel)({id:"color-variables-label",component:Fe,condition:({value:e})=>Ve(i.backgroundColorOverlayPropTypeUtil.extract(e)?.color)}),(0,o.registerControlReplacement)({component:Me,condition:({value:e})=>Le(e)}),$e({id:"font-variables",useProps:We}),r.styleTransformersRegistry.register(E.key,He),o.stylesInheritanceTransformersRegistry.register(E.key,je),T.init(),(0,n.injectIntoTop)({id:"canvas-style-variables-render",component:Je})}(window.elementorV2=window.elementorV2||{}).editorVariables=t}(),window.elementorV2.editorVariables?.init?.();