import{s as n}from"./transliterate-CfUtte1u.js";import{L as h,b as v}from"./lucide-vue-next-DqYmV2Wg.js";import{R as V}from"./refresh-cw-g88GDjr5.js";import{r as x,w as B,v as l,x as a,E as c,B as f,D as g,l as o,s as m,z as r,k as S,A as C,p as q,F as b}from"./x-CuOWXDIc.js";const w={class:"form-group"},L={key:0,class:"form-group__label"},N={key:0,class:"form-group__required"},z={class:"slug-field__row"},D={key:0,class:"slug-field__prefix"},F={class:"slug-field__input-wrap"},A=["value","placeholder","disabled","required"],E=["disabled","title"],G=["disabled"],I={key:1,class:"form-group__error"},R={key:2,class:"slug-field__hint"},J={__name:"SlugField",props:{modelValue:{type:String,default:""},sourceValue:{type:String,default:""},label:{type:String,default:"Alias (slug)"},error:{type:String,default:""},prefix:{type:String,default:""},autoGenerate:{type:Boolean,default:!0},disabled:{type:Boolean,default:!1},required:{type:Boolean,default:!1}},emits:["update:modelValue"],setup(e,{emit:_}){const u=e,d=_,t=x(u.autoGenerate);B(()=>u.sourceValue,s=>{t.value&&s&&d("update:modelValue",n(s))});function p(){t.value=!t.value}function y(){u.sourceValue&&d("update:modelValue",n(u.sourceValue))}function k(s){let i=s.target.value;i=i.toLowerCase().replace(/[^a-z0-9-]/g,"-").replace(/-+/g,"-"),d("update:modelValue",i)}return(s,i)=>(l(),a("div",w,[e.label?(l(),a("label",L,[c(f(e.label)+" ",1),e.required?(l(),a("span",N,"*")):g("",!0)])):g("",!0),o("div",z,[e.prefix?(l(),a("div",D,f(e.prefix),1)):g("",!0),o("div",F,[o("input",{type:"text",value:e.modelValue,placeholder:e.sourceValue?r(n)(e.sourceValue):"page-slug",disabled:e.disabled||t.value,required:e.required,class:m(["slug-field__input",e.prefix?"":"slug-field__input--no-prefix",e.error?"slug-field__input--error":""]),onInput:k},null,42,A)]),o("button",{type:"button",class:m(["slug-field__btn",t.value?"slug-field__btn--locked":"slug-field__btn--lock"]),disabled:e.disabled,title:t.value?"Редактировать вручную":"Включить автогенерацию",onClick:p},[(l(),S(C(t.value?r(h):r(v)),{class:"icon-md"}))],10,E),o("button",{type:"button",class:"slug-field__btn slug-field__btn--regen",disabled:e.disabled||!e.sourceValue,title:"Сгенерировать из заголовка",onClick:y},[q(r(V),{class:"icon-md"})],8,G)]),e.error?(l(),a("p",I,f(e.error),1)):(l(),a("p",R,[t.value?(l(),a(b,{key:0},[c("Автогенерация из заголовка")],64)):(l(),a(b,{key:1},[c("Ручной режим")],64))]))]))}};export{J as _};
