"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const g=require("vue"),v=require("../../../vc-util/warning.js");function h(n,u){const o=g.ref(null);function i(){try{const{selectionStart:e,selectionEnd:r,value:s}=n.value,a=s.substring(0,e),t=s.substring(r);o.value={start:e,end:r,value:s,beforeTxt:a,afterTxt:t}}catch{}}function c(){if(n.value&&o.value&&u.value)try{const{value:e}=n.value,{beforeTxt:r,afterTxt:s,start:a}=o.value;let t=e.length;if(e.endsWith(s))t=e.length-o.value.afterTxt.length;else if(e.startsWith(r))t=r.length;else{const f=r[a-1],l=e.indexOf(f,a-1);l!==-1&&(t=l+1)}n.value.setSelectionRange(t,t)}catch(e){v.warning(!1,`Something warning of cursor restore. Please fire issue about this: ${e.message}`)}}return[i,c]}exports.default=h;
