import{c as X,b as d,t as c,n as S,d as Y,r as D,e as v,o as R,b3 as Z,w,a2 as p,a as I,g as y,v as _,h as z,H as A,bf as O,W as K,z as ee,bg as te,p as k,$ as se,bh as ne,b7 as ae,k as ie,bi as le,J as N,O as oe,bj as ue}from"./index-4cdbb637.js";const[de,V]=X("stepper"),ce=200,T=(e,a)=>String(e)===String(a),re={min:d(1),max:d(1/0),name:d(""),step:d(1),theme:String,integer:Boolean,disabled:Boolean,showPlus:c,showMinus:c,showInput:c,longPress:c,autoFixed:c,allowEmpty:Boolean,modelValue:S,inputWidth:S,buttonSize:S,placeholder:String,disablePlus:Boolean,disableMinus:Boolean,disableInput:Boolean,beforeChange:Function,defaultValue:d(1),decimalLength:S};var he=Y({name:de,props:re,emits:["plus","blur","minus","focus","change","overlimit","update:modelValue"],setup(e,{emit:a}){const l=(t,s=!0)=>{const{min:i,max:b,allowEmpty:o,decimalLength:f}=e;return o&&t===""||(t=O(String(t),!e.integer),t=t===""?0:+t,t=Number.isNaN(t)?+i:t,t=s?Math.max(Math.min(+b,t),+i):t,K(f)&&(t=t.toFixed(+f))),t},W=()=>{var t;const s=(t=e.modelValue)!=null?t:e.defaultValue,i=l(s);return T(i,e.modelValue)||a("update:modelValue",i),i};let u;const C=D(),n=D(W()),h=v(()=>e.disabled||e.disableMinus||+n.value<=+e.min),m=v(()=>e.disabled||e.disablePlus||+n.value>=+e.max),$=v(()=>({width:R(e.inputWidth),height:R(e.buttonSize)})),E=v(()=>Z(e.buttonSize)),q=()=>{const t=l(n.value);T(t,n.value)||(n.value=t)},G=t=>{e.beforeChange?se(e.beforeChange,{args:[t],done(){n.value=t}}):n.value=t},x=()=>{if(u==="plus"&&m.value||u==="minus"&&h.value){a("overlimit",u);return}const t=u==="minus"?-e.step:+e.step,s=l(ne(+n.value,t));G(s),a(u)},H=t=>{const s=t.target,{value:i}=s,{decimalLength:b}=e;let o=O(String(i),!e.integer);if(K(b)&&o.includes(".")){const F=o.split(".");o=`${F[0]}.${F[1].slice(0,+b)}`}e.beforeChange?s.value=String(n.value):T(i,o)||(s.value=o);const f=o===String(+o);G(f?+o:o)},j=t=>{var s;e.disableInput?(s=C.value)==null||s.blur():a("focus",t)},J=t=>{const s=t.target,i=l(s.value,e.autoFixed);s.value=String(i),n.value=i,ee(()=>{a("blur",t),te()})};let P,g;const L=()=>{g=setTimeout(()=>{x(),L()},ce)},U=()=>{e.longPress&&(P=!1,clearTimeout(g),g=setTimeout(()=>{P=!0,x(),L()},ae))},B=t=>{e.longPress&&(clearTimeout(g),P&&k(t))},Q=t=>{e.disableInput&&k(t)},M=t=>({onClick:s=>{k(s),u=t,x()},onTouchstartPassive:()=>{u=t,U()},onTouchend:B,onTouchcancel:B});return w(()=>[e.max,e.min,e.integer,e.decimalLength],q),w(()=>e.modelValue,t=>{T(t,n.value)||(n.value=l(t))}),w(n,t=>{a("update:modelValue",t),a("change",t,{name:e.name})}),p(()=>e.modelValue),()=>I("div",{role:"group",class:V([e.theme])},[y(I("button",z({type:"button",style:E.value,class:[V("minus",{disabled:h.value}),{[A]:!h.value}],"aria-disabled":h.value||void 0},M("minus")),null),[[_,e.showMinus]]),y(I("input",{ref:C,type:e.integer?"tel":"text",role:"spinbutton",class:V("input"),value:n.value,style:$.value,disabled:e.disabled,readonly:e.disableInput,inputmode:e.integer?"numeric":"decimal",placeholder:e.placeholder,"aria-valuemax":e.max,"aria-valuemin":e.min,"aria-valuenow":n.value,onBlur:J,onInput:H,onFocus:j,onMousedown:Q},null),[[_,e.showInput]]),y(I("button",z({type:"button",style:E.value,class:[V("plus",{disabled:m.value}),{[A]:!m.value}],"aria-disabled":m.value||void 0},M("plus")),null),[[_,e.showPlus]])])}});const ge=ie(he),r=ue({prefixKey:"",storage:sessionStorage}),be=le("student-register-store",{state:()=>({token:r.get(N,""),selectGoods:[],selectVip:[],schoolId:r.get("register_school_id","")}),getters:{getToken(){return this.token},getGoods(){return this.selectGoods},getVip(){return this.selectVip},getSchoolId(){return this.schoolId}},actions:{setToken(e){this.token=e,r.set(N,e)},deleteToken(){this.token="",r.remove(N)},setGoods(e){this.selectGoods.push(e)},deleteGoods(e){const a=this.selectGoods.findIndex(l=>l.productSkuId===e);this.selectGoods.splice(a,1)},setVip(e){this.selectVip=e},deleteVip(e){const a=this.selectVip.findIndex(l=>l.goodsId===e);this.selectVip.splice(a,1)},selectedVip(e){return this.selectVip.findIndex(l=>l.goodsId===e)>=0},setShoolId(e){this.schoolId=e,r.set("register_school_id",e)},studentLoutOut(){this.deleteToken(),oe.replace({path:"/student-register",query:{sId:this.schoolId}})}}});export{ge as S,be as u};
