s/use-apply-and-unapply-class.ts");const x="elementor-css-class-selector",v=50,h={label:(0,p.__)("local","elementor"),value:null,fixed:!0,color:getTempStylesProviderColorName("accent"),icon:o.createElement(i.MapPinIcon,null),provider:null},{Slot:b,inject:E}=(0,l.createLocation)();function CssClassSelector(){const e=function useOptions(){const{element:e}=(0,u.useElement)(),isProviderEditable=e=>!!e.actions.updateProps;return(0,s.useProviders)().filter(isProviderEditable).flatMap(t=>{const n=(0,s.isElementsStylesProvider)(t.getKey()),r=t.actions.all({elementId:e.id});return n&&0===r.length?[h]:r.map(e=>({label:e.label,value:e.id,fixed:n,color:getTempStylesProviderColorName((0,m.getStylesProviderColorName)(t.getKey())),icon:n?o.createElement(i.MapPinIcon,null):null,provider:t.getKey()}))})}(),{id:t,setId:n}=(0,g.useStyle)(),l=(0,o.useRef)(null),[E,S]=(0,o.useState)(null),_=function useHandleSelect(){const e=(0,k.useApplyClass)(),t=(0,k.useUnapplyClass)();return(n,o,r)=>{if(r.value)switch(o){case"selectOption":e({classId:r.value,classLabel:r.label});break;case"removeOption":t({classId:r.value,classLabel:r.label})}}}(),{create:C,validate:w,entityName:P}=function useCreateAction(){const[e,t]=(0,k.useCreateAndApplyClass)();if(!e||!t)return{};const create=e=>{t({classLabel:e})},validate=(t,n)=>function hasReachedLimit(e){return e.actions.all().length>=e.limit}(e)?{isValid:!1,errorMessage:(0,p.__)("You’ve reached the limit of 50 classes. Please remove an existing one to create a new class.","elementor")}:(0,s.validateStyleLabel)(t,n),n=e.labels.singular&&e.labels.plural?e.labels:void 0;return{create:create,validate:validate,entityName:n}}(),T=function useAppliedOptions(e){const{element:t}=(0,u.useElement)(),n=(0,d.useClassesProp)(),o=(0,r.useElementSetting)(t.id,n)?.value||[],a=e.filter(e=>e.value&&o.includes(e.value)),i=a.some(e=>e.provider&&(0,s.isElementsStylesProvider)(e.provider));i||a.unshift(h);return a}(e),I=T.find(e=>e.value===t)??h,F=T.every(({fixed:e})=>e),{userCan:D}=(0,s.useUserStylesCapability)(),z=!I.provider||D(I.provider).updateProps;return o.createElement(c.Stack,{p:2},o.createElement(c.Stack,{direction:"row",gap:1,alignItems:"center",justifyContent:"space-between"},o.createElement(c.FormLabel,{htmlFor:x,size:"small"},(0,p.__)("Classes","elementor")),o.createElement(c.Stack,{direction:"row",gap:1},o.createElement(b,null))),o.createElement(a.WarningInfotip,{open:Boolean(E),text:E??"",placement:"bottom",width:l.current?.getBoundingClientRect().width,offset:[0,-15]},o.createElement(y.CreatableAutocomplete,{id:x,ref:l,size:"tiny",placeholder:F?(0,p.__)("Type class name","elementor"):void 0,options:e,selected:T,entityName:P,onSelect:_,onCreate:C??void 0,validate:w??void 0,limitTags:v,renderEmptyState:EmptyState,getLimitTagsText:e=>o.createElement(c.Chip,{size:"tiny",variant:"standard",label:`+${e}`,clickable:!0}),renderTags:(e,t)=>e.map((e,r)=>{const s=t({index:r}),a=e.value===I?.value;return o.createElement(f.CssClassItem,{key:s.key,fi