var e=Object.defineProperty,t=Object.defineProperties,a=Object.getOwnPropertyDescriptors,s=Object.getOwnPropertySymbols,l=Object.prototype.hasOwnProperty,o=Object.prototype.propertyIsEnumerable,r=(t,a,s)=>a in t?e(t,a,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[a]=s;import{_ as i}from"./index.vue_vue_type_script_setup_true_lang-Dnj11IW3.js";import{t as n,a2 as u,ap as d,r as c,S as h,Y as v,a1 as p,c as g,v as f,a0 as y,u as x,B as b,H as m,y as k,I as w,K as _,L as M,O as B,x as O}from"./vendor-core-k7kcNcJz.js";import{b as T}from"./index-BLric5IS.js";const j=n((I=((e,t)=>{for(var a in t||(t={}))l.call(t,a)&&r(e,a,t[a]);if(s)for(var a of s(t))o.call(t,a)&&r(e,a,t[a]);return e})({},{name:"ArtDragVerify"}),P={__name:"index",props:{value:{type:Boolean,default:!1},width:{default:"100%"},height:{default:40},text:{default:"按住滑块拖动"},successText:{default:"success"},background:{default:"#eee"},progressBarBg:{default:"#1385FF"},completedBg:{default:"#57D187"},circle:{type:Boolean,default:!1},radius:{default:"calc(var(--custom-radius) / 3 + 2px)"},handlerIcon:{default:"solar:double-alt-arrow-right-linear"},successIcon:{default:"ri:check-fill"},handlerBg:{default:"#fff"},textSize:{default:"13px"},textColor:{default:"#333"}},emits:["handlerMove","update:value","passCallback"],setup(e,{expose:t,emit:a}){const s=a,l=e,o=u({isMoving:!1,x:0,isOk:!1}),{isOk:r}=d(o),n=c(),T=c(),j=c(),I=c();let P,X,E,L;const z=e=>{P=e.targetTouches[0].pageX,X=e.targetTouches[0].pageY},C=e=>{E=e.targetTouches[0].pageX,L=e.targetTouches[0].pageY,Math.abs(E-P)>Math.abs(L-X)&&e.preventDefault()};document.addEventListener("touchstart",z),document.addEventListener("touchmove",C,{passive:!1});const S=()=>{var e;return"string"==typeof l.width?(null==(e=n.value)?void 0:e.offsetWidth)||260:l.width};h(()=>{var e;null==(e=n.value)||e.style.setProperty("--textColor",l.textColor),v(()=>{var e,t;const a=S();null==(e=n.value)||e.style.setProperty("--width",Math.floor(a/2)+"px"),null==(t=n.value)||t.style.setProperty("--pwidth",-Math.floor(a/2)+"px")}),document.addEventListener("touchstart",z),document.addEventListener("touchmove",C,{passive:!1})}),p(()=>{document.removeEventListener("touchstart",z),document.removeEventListener("touchmove",C)});const D={left:"0",width:l.height+"px",height:l.height+"px",background:l.handlerBg},F=g(()=>({width:"string"==typeof l.width?l.width:l.width+"px",height:l.height+"px",lineHeight:l.height+"px",background:l.background,borderRadius:l.circle?l.height/2+"px":l.radius})),$={background:l.progressBarBg,height:l.height+"px",borderRadius:l.circle?l.height/2+"px 0 0 "+l.height/2+"px":l.radius},A=g(()=>({fontSize:l.textSize})),R=g(()=>l.value?l.successText:l.text),Y=e=>{l.value||(o.isMoving=!0,j.value.style.transition="none",o.x=(e.pageX||e.touches[0].pageX)-parseInt(j.value.style.left.replace("px",""),10)),s("handlerMove")},H=e=>{if(o.isMoving&&!l.value){const t=S();let a=(e.pageX||e.touches[0].pageX)-o.x;a>0&&a<=t-l.height?(j.value.style.left=a+"px",I.value.style.width=a+l.height/2+"px"):a>t-l.height&&(j.value.style.left=t-l.height+"px",I.value.style.width=t-l.height/2+"px",K())}},V=e=>{if(o.isMoving&&!l.value){const t=S();(e.pageX||e.changedTouches[0].pageX)-o.x<t-l.height?(o.isOk=!0,j.value.style.left="0",j.value.style.transition="all 0.2s",I.value.style.width="0",o.isOk=!1):(j.value.style.transition="none",j.value.style.left=t-l.height+"px",I.value.style.width=t-l.height/2+"px",K()),o.isMoving=!1}},K=()=>{s("update:value",!0),o.isMoving=!1,I.value.style.background=l.completedBg,T.value.style["-webkit-text-fill-color"]="unset",T.value.style.animation="slidetounlock2 2s cubic-bezier(0, 0.2, 1, 1) infinite",T.value.style.color="#fff",s("passCallback")};return t({reset:()=>{j.value.style.left="0",I.value.style.width="0",I.value.style.background=l.progressBarBg,T.value.style["-webkit-text-fill-color"]="transparent",T.value.style.animation="slidetounlock 2s cubic-bezier(0, 0.2, 1, 1) infinite",T.value.style.color=l.background,s("update:value",!1),o.isOk=!1,o.isMoving=!1,o.x=0}}),(t,a)=>{const s=i;return O(),f("div",{ref_key:"dragVerify",ref:n,class:"drag_verify",style:y(x(F)),onMousemove:H,onMouseup:V,onMouseleave:V,onTouchmove:H,onTouchend:V},[b("div",{class:m(["dv_progress_bar",{goFirst2:x(r)}]),ref_key:"progressBar",ref:I,style:$},null,2),b("div",{class:"dv_text",style:y(x(A)),ref_key:"messageRef",ref:T},[t.$slots.textBefore?k(t.$slots,"textBefore",{key:0},void 0,!0):w("",!0),_(" "+M(x(R))+" ",1),t.$slots.textAfter?k(t.$slots,"textAfter",{key:1},void 0,!0):w("",!0)],4),b("div",{class:m(["dv_handler dv_handler_bg",{goFirst:x(r)}]),onMousedown:Y,onTouchstart:Y,ref_key:"handler",ref:j,style:D},[B(s,{icon:e.value?e.successIcon:e.handlerIcon,class:"text-g-600"},null,8,["icon"])],34)],36)}}},t(I,a(P))));var I,P;const X=T(j,[["__scopeId","data-v-9732f8d7"]]);export{X as _};
