@tdh-keyboard/vue 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,2 @@
1
+ (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require(`vue`),require(`@tdh-keyboard/core`)):typeof define==`function`&&define.amd?define([`exports`,`vue`,`@tdh-keyboard/core`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.TdhKeyboardVue={},e.Vue,e.TdhKeyboardCore))})(this,function(e,t,n){Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});function r(e){return(0,t.getCurrentScope)()?((0,t.onScopeDispose)(e),!0):!1}var i=typeof window<`u`&&typeof document<`u`;typeof WorkerGlobalScope<`u`&&globalThis instanceof WorkerGlobalScope;var a=e=>e!=null,o=Object.prototype.toString,s=e=>o.call(e)===`[object Object]`,c=()=>{};function l(e,t){function n(...n){return new Promise((r,i)=>{Promise.resolve(e(()=>t.apply(this,n),{fn:t,thisArg:this,args:n})).then(r).catch(i)})}return n}function u(e,n={}){let r,i,a=c,o=e=>{clearTimeout(e),a(),a=c},s;return c=>{let l=(0,t.toValue)(e),u=(0,t.toValue)(n.maxWait);return r&&o(r),l<=0||u!==void 0&&u<=0?(i&&=(o(i),null),Promise.resolve(c())):new Promise((e,t)=>{a=n.rejectOnCancel?t:e,s=c,u&&!i&&(i=setTimeout(()=>{r&&o(r),i=null,e(s())},u)),r=setTimeout(()=>{i&&o(i),i=null,e(c())},l)})}}function d(e){return Array.isArray(e)?e:[e]}function f(e){return e||(0,t.getCurrentInstance)()}function p(e,t=200,n={}){return l(u(t,n),e)}function m(e,n=!0,r){f(r)?(0,t.onMounted)(e,r):n?e():(0,t.nextTick)(e)}function h(e,n,r){return(0,t.watch)(e,n,{...r,immediate:!0})}var g=i?window:void 0;i&&window.document,i&&window.navigator,i&&window.location;function _(e){let n=(0,t.toValue)(e);return n?.$el??n}function v(...e){let n=[],i=()=>{n.forEach(e=>e()),n.length=0},a=(e,t,n,r)=>(e.addEventListener(t,n,r),()=>e.removeEventListener(t,n,r)),o=(0,t.computed)(()=>{let n=d((0,t.toValue)(e[0])).filter(e=>e!=null);return n.every(e=>typeof e!=`string`)?n:void 0}),c=h(()=>[o.value?.map(e=>_(e))??[g].filter(e=>e!=null),d((0,t.toValue)(o.value?e[1]:e[0])),d((0,t.unref)(o.value?e[2]:e[1])),(0,t.toValue)(o.value?e[3]:e[2])],([e,t,r,o])=>{if(i(),!e?.length||!t?.length||!r?.length)return;let c=s(o)?{...o}:o;n.push(...e.flatMap(e=>t.flatMap(t=>r.map(n=>a(e,t,n,c)))))},{flush:`post`});return r(i),()=>{c(),i()}}function y(){let e=(0,t.shallowRef)(!1),n=(0,t.getCurrentInstance)();return n&&(0,t.onMounted)(()=>{e.value=!0},n),e}function b(e){let n=y();return(0,t.computed)(()=>(n.value,!!e()))}function x(e,n,i={}){let{window:o=g,...s}=i,c,l=b(()=>o&&`MutationObserver`in o),u=()=>{c&&=(c.disconnect(),void 0)},f=(0,t.computed)(()=>{let n=d((0,t.toValue)(e)).map(_).filter(a);return new Set(n)}),p=(0,t.watch)(()=>f.value,e=>{u(),l.value&&e.size&&(c=new MutationObserver(n),e.forEach(e=>c.observe(e,s)))},{immediate:!0,flush:`post`}),m=()=>c?.takeRecords(),h=()=>{p(),u()};return r(h),{isSupported:l,stop:h,takeRecords:m}}function S(e,n,i={}){let{window:a=g,document:o=a?.document,flush:s=`sync`}=i;if(!a||!o)return c;let l,u=e=>{l?.(),l=e},d=(0,t.watchEffect)(()=>{let t=_(e);if(t){let{stop:e}=x(o,e=>{e.map(e=>[...e.removedNodes]).flat().some(e=>e===t||e.contains(t))&&n(e)},{window:a,childList:!0,subtree:!0});u(e)}},{flush:s}),f=()=>{d(),u()};return r(f),f}function C(e={}){let{window:n=g,deep:r=!0,triggerOnRemoval:i=!1}=e,a=e.document??n?.document,o=()=>{let e=a?.activeElement;if(r)for(;e?.shadowRoot;)e=e?.shadowRoot?.activeElement;return e},s=(0,t.shallowRef)(),c=()=>{s.value=o()};if(n){let e={capture:!0,passive:!0};v(n,`blur`,e=>{e.relatedTarget===null&&c()},e),v(n,`focus`,c,e)}return i&&S(s,c,{document:a}),c(),s}function w(e,n,i={}){let{window:a=g,...o}=i,s,c=b(()=>a&&`ResizeObserver`in a),l=()=>{s&&=(s.disconnect(),void 0)},u=(0,t.watch)((0,t.computed)(()=>{let n=(0,t.toValue)(e);return Array.isArray(n)?n.map(e=>_(e)):[_(n)]}),e=>{if(l(),c.value&&a){s=new ResizeObserver(n);for(let t of e)t&&s.observe(t,o)}},{immediate:!0,flush:`post`}),d=()=>{l(),u()};return r(d),{isSupported:c,stop:d}}function T(e,n={width:0,height:0},r={}){let{window:i=g,box:a=`content-box`}=r,o=(0,t.computed)(()=>(_(e)?.namespaceURI)?.includes(`svg`)),s=(0,t.shallowRef)(n.width),c=(0,t.shallowRef)(n.height),{stop:l}=w(e,([t])=>{let n=a===`border-box`?t.borderBoxSize:a===`content-box`?t.contentBoxSize:t.devicePixelContentBoxSize;if(i&&o.value){let t=_(e);if(t){let e=t.getBoundingClientRect();s.value=e.width,c.value=e.height}}else if(n){let e=d(n);s.value=e.reduce((e,{inlineSize:t})=>e+t,0),c.value=e.reduce((e,{blockSize:t})=>e+t,0)}else s.value=t.contentRect.width,c.value=t.contentRect.height},r);m(()=>{let t=_(e);t&&(s.value=`offsetWidth`in t?t.offsetWidth:n.width,c.value=`offsetHeight`in t?t.offsetHeight:n.height)});let u=(0,t.watch)(()=>_(e),e=>{s.value=e?n.width:0,c.value=e?n.height:0});function f(){l(),u()}return{width:s,height:c,stop:f}}function ee(e=!1){let r=(0,t.ref)(!1),i=(0,t.ref)(0);async function a(){let e=(0,n.getHandwritingRecognizer)();if(e)try{r.value=await e.initialize({onProgress:e=>{i.value=e}})}catch(e){console.error(`初始化手写识别服务失败:`,e),r.value=!1}else console.warn(`未注册手写识别服务`),r.value=!1}async function o(){let e=(0,n.getHandwritingRecognizer)();if(e&&r.value)try{await e.close(),r.value=!1}catch(e){console.error(`关闭手写识别服务失败:`,e)}}return(0,t.onMounted)(()=>{e&&a()}),(0,t.onUnmounted)(()=>{o()}),{recognizerInitialized:r,recognizerProgress:i}}var E=`data:image/svg+xml,%3csvg%20t='1777011781316'%20class='icon'%20viewBox='0%200%201439%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20p-id='5887'%20width='200'%20height='200'%3e%3cpath%20d='M1283.03672%200.000187H465.243153a158.045778%20158.045778%200%200%200-122.329921%2057.680486L24.083875%20440.475014c-0.622227%200.68445-1.182232%201.431123-1.742237%202.177796A115.672087%20115.672087%200%200%200%200.003672%20511.906728a118.658779%20118.658779%200%200%200%2026.818004%2074.667297l316.713783%20380.492099a158.232446%20158.232446%200%200%200%20121.707694%2056.933814H1283.03672a156.303541%20156.303541%200%200%200%20156.05465-156.116873V156.054837A156.241318%20156.241318%200%200%200%201283.03672%200.000187z%20m-257.477728%20689.863598a47.538179%2047.538179%200%200%201-33.600284%2013.937896%2047.662624%2047.662624%200%200%201-33.662506-13.937896L847.72638%20579.293963l-110.569822%20110.569822a47.911515%2047.911515%200%200%201-33.724729%2013.937896%2047.662624%2047.662624%200%200%201-33.662506-81.325131l110.383154-110.569822-110.569822-110.569822a47.662624%2047.662624%200%200%201%200-67.387235%2047.600402%2047.600402%200%200%201%2067.325012%200l110.632045%20110.632045%20110.569822-110.632045A47.625291%2047.625291%200%200%201%201025.434546%20401.336906l-110.383153%20110.569822%20110.569821%20110.569822a47.662624%2047.662624%200%200%201-0.062222%2067.387235z'%20fill='%232C2C2C'%20p-id='5888'%3e%3c/path%3e%3c/svg%3e`,D=`data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%3e%3cpath%20d='M19,7V11H5.83L9.41,7.41L8,6L2,12L8,18L9.41,16.58L5.83,13H21V7H19Z'%20/%3e%3c/svg%3e`;function O(){let e=(0,n.createKeyRepeater)();function r(t,n){t.preventDefault(),t.currentTarget?.setPointerCapture?.(t.pointerId),e.start(n)}function i(){e.stop()}return(0,t.onBeforeUnmount)(()=>{e.stop()}),{startRepeat:r,stopRepeat:i}}var k={class:`tdhk-candidate-list`},A=[`onClick`],j=(0,t.defineComponent)({__name:`CandidateList`,props:{candidates:{}},emits:[`select`],setup(e,{emit:n}){let r=n;function i(e){r(`select`,e)}return(e,n)=>((0,t.openBlock)(),(0,t.createElementBlock)(`div`,k,[((0,t.openBlock)(!0),(0,t.createElementBlock)(t.Fragment,null,(0,t.renderList)(e.candidates,(e,n)=>((0,t.openBlock)(),(0,t.createElementBlock)(`button`,{key:`candidate-${n}`,class:`tdhk-candidate-list__item`,onClick:e=>i(n)},(0,t.toDisplayString)(e),9,A))),128))]))}}),M=`data:image/svg+xml,%3csvg%20width='28'%20height='28'%20viewBox='0%200%2028%2028'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3crect%20x='4.5'%20y='5.5'%20width='19'%20height='17'%20rx='3.5'%20stroke='%235E6773'%20stroke-width='2'/%3e%3cpath%20d='M8.5%2010H10'%20stroke='%235E6773'%20stroke-width='2'%20stroke-linecap='round'/%3e%3cpath%20d='M12%2010H13.5'%20stroke='%235E6773'%20stroke-width='2'%20stroke-linecap='round'/%3e%3cpath%20d='M15.5%2010H17'%20stroke='%235E6773'%20stroke-width='2'%20stroke-linecap='round'/%3e%3cpath%20d='M19%2010H20.5'%20stroke='%235E6773'%20stroke-width='2'%20stroke-linecap='round'/%3e%3cpath%20d='M8%2014H10.5'%20stroke='%235E6773'%20stroke-width='2'%20stroke-linecap='round'/%3e%3cpath%20d='M12%2014H14.5'%20stroke='%235E6773'%20stroke-width='2'%20stroke-linecap='round'/%3e%3cpath%20d='M16%2014H18.5'%20stroke='%235E6773'%20stroke-width='2'%20stroke-linecap='round'/%3e%3cpath%20d='M10%2018.5H18'%20stroke='%235E6773'%20stroke-width='2'%20stroke-linecap='round'/%3e%3c/svg%3e`,N=`data:image/svg+xml,%3csvg%20width='28'%20height='28'%20viewBox='0%200%2028%2028'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3crect%20x='6.5'%20y='3.5'%20width='15'%20height='21'%20rx='3.5'%20stroke='%235E6773'%20stroke-width='2'/%3e%3cpath%20d='M14%207H14.01'%20stroke='%235E6773'%20stroke-width='2.4'%20stroke-linecap='round'/%3e%3cpath%20d='M17.5%2016.5V14C17.5%2012.6193%2016.3807%2011.5%2015%2011.5C13.6193%2011.5%2012.5%2012.6193%2012.5%2014V19L11.25%2017.75C10.4697%2016.9697%209.20435%2016.9697%208.42401%2017.75C7.64366%2018.5303%207.64366%2019.7956%208.42401%2020.576L11.6766%2023.8284C12.0516%2024.2034%2012.5603%2024.4141%2013.0909%2024.4141H16C18.4853%2024.4141%2020.5%2022.3994%2020.5%2019.9141V16.5'%20stroke='%235E6773'%20stroke-width='2'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3c/svg%3e`,P={class:`tdhk-toolbar`},F=[`aria-label`,`disabled`],I=[`src`,`alt`],L=(0,t.defineComponent)({__name:`KeyboardToolbar`,props:{enableHandwriting:{type:Boolean,default:!1},isHandwritingMode:{type:Boolean,default:!1}},emits:[`toggleKeyboard`,`collapse`],setup(e,{emit:n}){let r=e,i=n,a=(0,t.computed)(()=>r.isHandwritingMode?`切换到输入键盘`:`切换到手写键盘`),o=(0,t.computed)(()=>r.isHandwritingMode?M:N);return(e,n)=>((0,t.openBlock)(),(0,t.createElementBlock)(`div`,P,[(0,t.createElementVNode)(`button`,{class:(0,t.normalizeClass)([`tdhk-toolbar__button`,{"tdhk-toolbar__button--disabled":!e.enableHandwriting}]),type:`button`,"aria-label":a.value,disabled:!e.enableHandwriting,onClick:n[0]||=e=>i(`toggleKeyboard`),onContextmenu:n[1]||=(0,t.withModifiers)(()=>{},[`prevent`])},[(0,t.createElementVNode)(`img`,{src:o.value,class:`tdhk-toolbar__icon`,alt:a.value},null,8,I)],42,F),n[5]||=(0,t.createElementVNode)(`div`,{class:`tdhk-toolbar__spacer`},null,-1),n[6]||=(0,t.createElementVNode)(`div`,{class:`tdhk-toolbar__divider`},null,-1),(0,t.createElementVNode)(`button`,{class:`tdhk-toolbar__button tdhk-toolbar__button--collapse`,type:`button`,"aria-label":`收起键盘`,onClick:n[2]||=e=>i(`collapse`),onContextmenu:n[3]||=(0,t.withModifiers)(()=>{},[`prevent`])},n[4]||=[(0,t.createElementVNode)(`img`,{src:`data:image/svg+xml,%3csvg%20width='28'%20height='28'%20viewBox='0%200%2028%2028'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M7%2011L14%2018L21%2011'%20stroke='%235E6773'%20stroke-width='2.5'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3c/svg%3e`,class:`tdhk-toolbar__icon`,alt:`收起键盘`},null,-1)],32)]))}}),R={class:`handwriting-input`},z={class:`handwriting-input__header`},B={key:0,class:`handwriting-input__candidates`},V={class:`handwriting-content`},H={class:`handwriting-buttons`},U={class:`handwriting-canvas-container`},te={key:0,class:`handwriting-loading`},ne={class:`progress-bar`},W={class:`progress-text`},G={class:`handwriting-buttons`},K=(0,t.defineComponent)({__name:`HandwritingInput`,props:{recognizerInitialized:{type:Boolean},recognizerProgress:{}},emits:[`key`,`exit`,`toggleKeyboard`,`switchToSymbol`,`collapse`],setup(e,{emit:r}){let i=e,a=r,o=(0,t.ref)(null),s=null,c=(0,t.ref)(!1),{width:l,height:u}=T(o);function d(){s&&s.clearCanvas()}function f(){o.value&&(s&&s.destroy(),o.value.width=l.value,o.value.height=u.value,s=new n.CanvasDrawer(o.value,{onDrawEnd:g}))}let p=(0,t.ref)([]),{startRepeat:m,stopRepeat:h}=O();async function g(){if(!s||s.getStrokeData().length===0||c.value)return;let e=(0,n.getHandwritingRecognizer)();if(e){c.value=!0;try{let t=[...s.getStrokeData()];p.value=await e.recognize(t)}catch(e){console.error(`识别笔迹失败:`,e)}finally{c.value=!1}}else console.warn(`手写识别服务不可用`)}(0,t.onUnmounted)(()=>{s&&s.destroy()}),(0,t.watchEffect)(()=>{o.value&&(l.value||u.value)&&i.recognizerInitialized&&(0,t.nextTick)(()=>{f()})});function _(e){let t=p.value[e];t&&(a(`key`,{key:t}),p.value=[],d())}return(e,n)=>((0,t.openBlock)(),(0,t.createElementBlock)(`div`,R,[(0,t.createElementVNode)(`div`,z,[p.value.length>0?((0,t.openBlock)(),(0,t.createElementBlock)(`div`,B,[(0,t.createVNode)(j,{candidates:p.value,onSelect:_},null,8,[`candidates`])])):((0,t.openBlock)(),(0,t.createBlock)(L,{key:1,"enable-handwriting":``,"is-handwriting-mode":``,onToggleKeyboard:n[0]||=e=>a(`toggleKeyboard`),onCollapse:n[1]||=e=>a(`collapse`)}))]),(0,t.createElementVNode)(`div`,V,[(0,t.createElementVNode)(`div`,H,[(0,t.createElementVNode)(`button`,{class:`handwriting-btn handwriting-btn--function`,onPointerdown:n[2]||=e=>(0,t.unref)(m)(e,()=>a(`key`,{key:`。`})),onPointerup:n[3]||=(...e)=>(0,t.unref)(h)&&(0,t.unref)(h)(...e),onPointerleave:n[4]||=(...e)=>(0,t.unref)(h)&&(0,t.unref)(h)(...e),onPointercancel:n[5]||=(...e)=>(0,t.unref)(h)&&(0,t.unref)(h)(...e),onContextmenu:n[6]||=(0,t.withModifiers)(()=>{},[`prevent`])},` 。 `,32),(0,t.createElementVNode)(`button`,{class:`handwriting-btn handwriting-btn--function`,onPointerdown:n[7]||=e=>(0,t.unref)(m)(e,()=>a(`key`,{key:`?`})),onPointerup:n[8]||=(...e)=>(0,t.unref)(h)&&(0,t.unref)(h)(...e),onPointerleave:n[9]||=(...e)=>(0,t.unref)(h)&&(0,t.unref)(h)(...e),onPointercancel:n[10]||=(...e)=>(0,t.unref)(h)&&(0,t.unref)(h)(...e),onContextmenu:n[11]||=(0,t.withModifiers)(()=>{},[`prevent`])},` ? `,32),(0,t.createElementVNode)(`button`,{class:`handwriting-btn handwriting-btn--function`,onPointerdown:n[12]||=e=>(0,t.unref)(m)(e,()=>a(`key`,{key:`!`})),onPointerup:n[13]||=(...e)=>(0,t.unref)(h)&&(0,t.unref)(h)(...e),onPointerleave:n[14]||=(...e)=>(0,t.unref)(h)&&(0,t.unref)(h)(...e),onPointercancel:n[15]||=(...e)=>(0,t.unref)(h)&&(0,t.unref)(h)(...e),onContextmenu:n[16]||=(0,t.withModifiers)(()=>{},[`prevent`])},` ! `,32),(0,t.createElementVNode)(`button`,{class:`handwriting-btn handwriting-btn--function`,onClick:n[17]||=e=>a(`switchToSymbol`),onContextmenu:n[18]||=(0,t.withModifiers)(()=>{},[`prevent`])},` 符 `,32)]),(0,t.createElementVNode)(`div`,U,[e.recognizerInitialized?((0,t.openBlock)(),(0,t.createElementBlock)(`canvas`,{key:1,ref_key:`canvasRef`,ref:o,class:`handwriting-canvas`},null,512)):((0,t.openBlock)(),(0,t.createElementBlock)(`div`,te,[n[39]||=(0,t.createElementVNode)(`div`,{class:`loading-text`},` 正在加载手写识别... `,-1),(0,t.createElementVNode)(`div`,ne,[(0,t.createElementVNode)(`div`,{class:`progress-fill`,style:(0,t.normalizeStyle)({width:`${e.recognizerProgress*100}%`})},null,4)]),(0,t.createElementVNode)(`div`,W,(0,t.toDisplayString)(Math.round(e.recognizerProgress*100))+`% `,1)]))]),(0,t.createElementVNode)(`div`,G,[(0,t.createElementVNode)(`button`,{class:`handwriting-btn handwriting-btn--function`,onPointerdown:n[19]||=e=>(0,t.unref)(m)(e,()=>a(`key`,{key:`delete`,isControl:!0})),onPointerup:n[20]||=(...e)=>(0,t.unref)(h)&&(0,t.unref)(h)(...e),onPointerleave:n[21]||=(...e)=>(0,t.unref)(h)&&(0,t.unref)(h)(...e),onPointercancel:n[22]||=(...e)=>(0,t.unref)(h)&&(0,t.unref)(h)(...e),onContextmenu:n[23]||=(0,t.withModifiers)(()=>{},[`prevent`])},n[40]||=[(0,t.createElementVNode)(`img`,{src:`data:image/svg+xml,%3csvg%20t='1777011781316'%20class='icon'%20viewBox='0%200%201439%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20p-id='5887'%20width='200'%20height='200'%3e%3cpath%20d='M1283.03672%200.000187H465.243153a158.045778%20158.045778%200%200%200-122.329921%2057.680486L24.083875%20440.475014c-0.622227%200.68445-1.182232%201.431123-1.742237%202.177796A115.672087%20115.672087%200%200%200%200.003672%20511.906728a118.658779%20118.658779%200%200%200%2026.818004%2074.667297l316.713783%20380.492099a158.232446%20158.232446%200%200%200%20121.707694%2056.933814H1283.03672a156.303541%20156.303541%200%200%200%20156.05465-156.116873V156.054837A156.241318%20156.241318%200%200%200%201283.03672%200.000187z%20m-257.477728%20689.863598a47.538179%2047.538179%200%200%201-33.600284%2013.937896%2047.662624%2047.662624%200%200%201-33.662506-13.937896L847.72638%20579.293963l-110.569822%20110.569822a47.911515%2047.911515%200%200%201-33.724729%2013.937896%2047.662624%2047.662624%200%200%201-33.662506-81.325131l110.383154-110.569822-110.569822-110.569822a47.662624%2047.662624%200%200%201%200-67.387235%2047.600402%2047.600402%200%200%201%2067.325012%200l110.632045%20110.632045%20110.569822-110.632045A47.625291%2047.625291%200%200%201%201025.434546%20401.336906l-110.383153%20110.569822%20110.569821%20110.569822a47.662624%2047.662624%200%200%201-0.062222%2067.387235z'%20fill='%232C2C2C'%20p-id='5888'%3e%3c/path%3e%3c/svg%3e`,alt:`删除`},null,-1)],32),(0,t.createElementVNode)(`button`,{class:`handwriting-btn handwriting-btn--function`,onPointerdown:n[24]||=e=>(0,t.unref)(m)(e,()=>a(`key`,{key:`、`})),onPointerup:n[25]||=(...e)=>(0,t.unref)(h)&&(0,t.unref)(h)(...e),onPointerleave:n[26]||=(...e)=>(0,t.unref)(h)&&(0,t.unref)(h)(...e),onPointercancel:n[27]||=(...e)=>(0,t.unref)(h)&&(0,t.unref)(h)(...e),onContextmenu:n[28]||=(0,t.withModifiers)(()=>{},[`prevent`])},` 、 `,32),(0,t.createElementVNode)(`button`,{class:`handwriting-btn handwriting-btn--function`,onPointerdown:n[29]||=e=>(0,t.unref)(m)(e,()=>a(`key`,{key:`,`})),onPointerup:n[30]||=(...e)=>(0,t.unref)(h)&&(0,t.unref)(h)(...e),onPointerleave:n[31]||=(...e)=>(0,t.unref)(h)&&(0,t.unref)(h)(...e),onPointercancel:n[32]||=(...e)=>(0,t.unref)(h)&&(0,t.unref)(h)(...e),onContextmenu:n[33]||=(0,t.withModifiers)(()=>{},[`prevent`])},` , `,32),(0,t.createElementVNode)(`button`,{class:`handwriting-btn handwriting-btn--function`,onPointerdown:n[34]||=e=>(0,t.unref)(m)(e,()=>a(`key`,{key:`enter`,isControl:!0})),onPointerup:n[35]||=(...e)=>(0,t.unref)(h)&&(0,t.unref)(h)(...e),onPointerleave:n[36]||=(...e)=>(0,t.unref)(h)&&(0,t.unref)(h)(...e),onPointercancel:n[37]||=(...e)=>(0,t.unref)(h)&&(0,t.unref)(h)(...e),onContextmenu:n[38]||=(0,t.withModifiers)(()=>{},[`prevent`])},n[41]||=[(0,t.createElementVNode)(`img`,{src:`data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%3e%3cpath%20d='M19,7V11H5.83L9.41,7.41L8,6L2,12L8,18L9.41,16.58L5.83,13H21V7H19Z'%20/%3e%3c/svg%3e`,alt:`回车`},null,-1)],32)])])]))}}),q=`data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%3e%3cpath%20d='M3%2015H5V19H19V15H21V19C21%2020.1%2020.1%2021%2019%2021H5C3.9%2021%203%2020.1%203%2019V15Z'%20/%3e%3c/svg%3e`,J={class:`tdhk-selection`},Y={class:`tdhk-selection__list`},X=[`onClick`],Z=(0,t.defineComponent)({__name:`CandidateSelection`,props:{candidates:{}},emits:[`select`,`close`],setup(e,{emit:n}){let r=n;function i(e){r(`select`,e)}function a(){r(`close`)}function o(e){let t=Array.from(e).length;return t>=2&&t<=3?2:t>=4?3:1}return(e,n)=>((0,t.openBlock)(),(0,t.createElementBlock)(`div`,J,[(0,t.createElementVNode)(`div`,Y,[((0,t.openBlock)(!0),(0,t.createElementBlock)(t.Fragment,null,(0,t.renderList)(e.candidates,(e,n)=>((0,t.openBlock)(),(0,t.createElementBlock)(`div`,{key:n,class:(0,t.normalizeClass)([`tdhk-selection__text`,[`tdhk-selection__text--span-${o(e)}`]]),onClick:e=>i(n)},(0,t.toDisplayString)(e),11,X))),128))]),(0,t.createElementVNode)(`div`,{class:`tdhk-selection__func`},[(0,t.createElementVNode)(`button`,{class:`tdhk-selection__func-btn`,onClick:a},` 返回 `)])]))}}),re={class:`tdhk-candidate`},ie={class:`tdhk-candidate__container`},ae={key:0,class:`tdhk-candidate__pinyin`},oe={class:`tdhk-candidate__bottom-container`},se=(0,t.defineComponent)({__name:`CandidateBar`,props:{modelValue:{required:!0},modelModifiers:{}},emits:(0,t.mergeModels)([`key`,`input`],[`update:modelValue`]),setup(e,{expose:r,emit:i}){let a=i,o=(0,t.useModel)(e,`modelValue`),s=null,c=(0,t.ref)(null),l=(0,t.computed)(()=>c.value?.candidates.map(e=>e.text)??[]),u=(0,t.ref)(!1);(0,t.onMounted)(async()=>{if(s=(0,n.getPinyinEngine)(),!s)throw Error(`未找到拼音引擎实例,请确保已正确注册引擎`);o.value&&(c.value=await s.processInput(o.value))}),(0,t.onUnmounted)(()=>{s?.processInput(``).catch(()=>{}),s=null}),(0,t.watch)(o,async e=>{let t=s;if(t){if(e===``){t.processInput(``).catch(()=>{}),c.value=null;return}c.value=await t.processInput(e)}});async function d(e){if(!s)return;let t=await s.pickCandidate(e);c.value=t,t.preeditBody||(a(`input`,t.committed||``),o.value=``,c.value=null,u.value=!1)}r({handleSelection:d});let f=(0,t.computed)(()=>{let e=c.value;return e?e.preeditHead+e.preeditBody:``});return(e,n)=>((0,t.openBlock)(),(0,t.createElementBlock)(`div`,re,[(0,t.createElementVNode)(`div`,ie,[f.value?((0,t.openBlock)(),(0,t.createElementBlock)(`div`,ae,(0,t.toDisplayString)(f.value),1)):(0,t.createCommentVNode)(``,!0),(0,t.createElementVNode)(`div`,oe,[l.value.length>0?((0,t.openBlock)(),(0,t.createBlock)(j,{key:0,candidates:l.value,onSelect:d},null,8,[`candidates`])):(0,t.createCommentVNode)(``,!0),l.value.length>0?((0,t.openBlock)(),(0,t.createElementBlock)(`button`,{key:1,class:`tdhk-candidate__more`,onClick:n[0]||=e=>u.value=!0},n[2]||=[(0,t.createElementVNode)(`img`,{src:`data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%3e%3cpath%20d='M8.59,16.58L13.17,12L8.59,7.41L10,6L16,12L10,18L8.59,16.58Z'%20/%3e%3c/svg%3e`,alt:`更多`},null,-1)])):(0,t.createCommentVNode)(``,!0)])]),u.value?((0,t.openBlock)(),(0,t.createBlock)(Z,{key:0,candidates:l.value,onSelect:d,onClose:n[1]||=e=>u.value=!1},null,8,[`candidates`])):(0,t.createCommentVNode)(``,!0)]))}}),ce={class:`tdhk-base`},le={class:`tdhk-base__row tdhk-base__row--header`},ue=[`onPointerdown`],de={class:`tdhk-base__row`},fe={class:`tdhk-base__toggle-main`},pe={class:`tdhk-base__toggle-sub`},me=(0,t.defineComponent)({__name:`KeyboardBase`,props:(0,t.mergeModels)({enableHandwriting:{type:Boolean}},{modelValue:{default:`en`},modelModifiers:{},capsReturnToChinese:{type:Boolean,default:!1},capsReturnToChineseModifiers:{}}),emits:(0,t.mergeModels)([`key`,`collapse`,`toggleKeyboard`],[`update:modelValue`,`update:capsReturnToChinese`]),setup(e,{emit:n}){let r=n,i=(0,t.useModel)(e,`modelValue`),a=(0,t.useModel)(e,`capsReturnToChinese`),o=(0,t.computed)(()=>i.value===`en_cap`),s=(0,t.computed)(()=>i.value===`zh`),c=(0,t.computed)(()=>s.value?!0:o.value),l=(0,t.ref)(``),u=(0,t.ref)(null),d=(0,t.computed)(()=>s.value&&l.value.length>0);function f(e,t=!1){r(`key`,{key:e,isControl:t})}function p(){s.value?(l.value=``,a.value=!0,i.value=`en_cap`):o.value&&a.value?(a.value=!1,i.value=`zh`):(a.value=!1,i.value=o.value?`en`:`en_cap`)}function m(){i.value=`num`}function h(){i.value=`symbol`}let g=[[`q`,`w`,`e`,`r`,`t`,`y`,`u`,`i`,`o`,`p`],[`a`,`s`,`d`,`f`,`g`,`h`,`j`,`k`,`l`],[`z`,`x`,`c`,`v`,`b`,`n`,`m`]],{startRepeat:_,stopRepeat:v}=O();function y(){if(i.value===`zh`&&l.value){l.value=l.value.slice(0,-1);return}f(`delete`,!0)}function b(){if(i.value===`zh`&&l.value){u.value?.handleSelection(0);return}f(` `)}function x(){if(i.value===`zh`&&l.value){f(l.value),l.value=``;return}f(`enter`,!0)}function S(e){if(i.value===`zh`){l.value+=e;return}f(o.value?e.toUpperCase():e)}function C(){a.value=!1,i.value=i.value===`zh`?`en`:`zh`}return(e,n)=>((0,t.openBlock)(),(0,t.createElementBlock)(`div`,ce,[(0,t.createElementVNode)(`div`,le,[d.value?((0,t.openBlock)(),(0,t.createBlock)(se,{key:0,ref_key:`candidateBarRef`,ref:u,modelValue:l.value,"onUpdate:modelValue":n[0]||=e=>l.value=e,onInput:n[1]||=e=>f(e,!1)},null,8,[`modelValue`])):((0,t.openBlock)(),(0,t.createBlock)(L,{key:1,"enable-handwriting":e.enableHandwriting,onToggleKeyboard:n[2]||=e=>r(`toggleKeyboard`),onCollapse:n[3]||=e=>r(`collapse`)},null,8,[`enable-handwriting`]))]),((0,t.openBlock)(),(0,t.createElementBlock)(t.Fragment,null,(0,t.renderList)(g,(e,r)=>(0,t.createElementVNode)(`div`,{key:`row-${r}`,class:`tdhk-base__row`},[r===2?((0,t.openBlock)(),(0,t.createElementBlock)(`button`,{key:0,class:(0,t.normalizeClass)([`tdhk-base__key tdhk-base__key--function tdhk-base__key--shift`,{"tdhk-base__key--active":o.value}]),onClick:p,onContextmenu:n[4]||=(0,t.withModifiers)(()=>{},[`prevent`])},n[37]||=[(0,t.createElementVNode)(`img`,{src:`data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%3e%3cpath%20d='M6,18H18V16H6M12,8.41L16.59,13L18,11.58L12,5.58L6,11.58L7.41,13L12,8.41Z'%20/%3e%3c/svg%3e`,class:`tdhk-base__key-icon`,alt:`Shift`},null,-1)],34)):(0,t.createCommentVNode)(``,!0),((0,t.openBlock)(!0),(0,t.createElementBlock)(t.Fragment,null,(0,t.renderList)(e,(e,i)=>((0,t.openBlock)(),(0,t.createElementBlock)(`button`,{key:`key-${r}-${i}`,class:`tdhk-base__key tdhk-base__key--letter`,onPointerdown:n=>(0,t.unref)(_)(n,()=>S(e)),onPointerup:n[5]||=(...e)=>(0,t.unref)(v)&&(0,t.unref)(v)(...e),onPointerleave:n[6]||=(...e)=>(0,t.unref)(v)&&(0,t.unref)(v)(...e),onPointercancel:n[7]||=(...e)=>(0,t.unref)(v)&&(0,t.unref)(v)(...e),onContextmenu:n[8]||=(0,t.withModifiers)(()=>{},[`prevent`])},(0,t.toDisplayString)(c.value?e.toUpperCase():e),41,ue))),128)),r===2?((0,t.openBlock)(),(0,t.createElementBlock)(`button`,{key:1,class:`tdhk-base__key tdhk-base__key--function tdhk-base__key--delete`,onPointerdown:n[9]||=e=>(0,t.unref)(_)(e,()=>y()),onPointerup:n[10]||=(...e)=>(0,t.unref)(v)&&(0,t.unref)(v)(...e),onPointerleave:n[11]||=(...e)=>(0,t.unref)(v)&&(0,t.unref)(v)(...e),onPointercancel:n[12]||=(...e)=>(0,t.unref)(v)&&(0,t.unref)(v)(...e),onContextmenu:n[13]||=(0,t.withModifiers)(()=>{},[`prevent`])},n[38]||=[(0,t.createElementVNode)(`img`,{src:`data:image/svg+xml,%3csvg%20t='1777011781316'%20class='icon'%20viewBox='0%200%201439%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20p-id='5887'%20width='200'%20height='200'%3e%3cpath%20d='M1283.03672%200.000187H465.243153a158.045778%20158.045778%200%200%200-122.329921%2057.680486L24.083875%20440.475014c-0.622227%200.68445-1.182232%201.431123-1.742237%202.177796A115.672087%20115.672087%200%200%200%200.003672%20511.906728a118.658779%20118.658779%200%200%200%2026.818004%2074.667297l316.713783%20380.492099a158.232446%20158.232446%200%200%200%20121.707694%2056.933814H1283.03672a156.303541%20156.303541%200%200%200%20156.05465-156.116873V156.054837A156.241318%20156.241318%200%200%200%201283.03672%200.000187z%20m-257.477728%20689.863598a47.538179%2047.538179%200%200%201-33.600284%2013.937896%2047.662624%2047.662624%200%200%201-33.662506-13.937896L847.72638%20579.293963l-110.569822%20110.569822a47.911515%2047.911515%200%200%201-33.724729%2013.937896%2047.662624%2047.662624%200%200%201-33.662506-81.325131l110.383154-110.569822-110.569822-110.569822a47.662624%2047.662624%200%200%201%200-67.387235%2047.600402%2047.600402%200%200%201%2067.325012%200l110.632045%20110.632045%20110.569822-110.632045A47.625291%2047.625291%200%200%201%201025.434546%20401.336906l-110.383153%20110.569822%20110.569821%20110.569822a47.662624%2047.662624%200%200%201-0.062222%2067.387235z'%20fill='%232C2C2C'%20p-id='5888'%3e%3c/path%3e%3c/svg%3e`,class:`tdhk-base__key-icon`,alt:`Delete`},null,-1)],32)):(0,t.createCommentVNode)(``,!0)])),64)),(0,t.createElementVNode)(`div`,de,[(0,t.createElementVNode)(`button`,{class:`tdhk-base__key tdhk-base__key--function`,onClick:h,onContextmenu:n[14]||=(0,t.withModifiers)(()=>{},[`prevent`])},` 符 `,32),(0,t.createElementVNode)(`button`,{class:`tdhk-base__key tdhk-base__key--function`,onClick:m,onContextmenu:n[15]||=(0,t.withModifiers)(()=>{},[`prevent`])},` 123 `,32),(0,t.createElementVNode)(`button`,{class:`tdhk-base__key`,onPointerdown:n[16]||=e=>(0,t.unref)(_)(e,()=>f(`,`)),onPointerup:n[17]||=(...e)=>(0,t.unref)(v)&&(0,t.unref)(v)(...e),onPointerleave:n[18]||=(...e)=>(0,t.unref)(v)&&(0,t.unref)(v)(...e),onPointercancel:n[19]||=(...e)=>(0,t.unref)(v)&&(0,t.unref)(v)(...e),onContextmenu:n[20]||=(0,t.withModifiers)(()=>{},[`prevent`])},` , `,32),(0,t.createElementVNode)(`button`,{class:`tdhk-base__key tdhk-base__key--space`,onPointerdown:n[21]||=e=>(0,t.unref)(_)(e,()=>b()),onPointerup:n[22]||=(...e)=>(0,t.unref)(v)&&(0,t.unref)(v)(...e),onPointerleave:n[23]||=(...e)=>(0,t.unref)(v)&&(0,t.unref)(v)(...e),onPointercancel:n[24]||=(...e)=>(0,t.unref)(v)&&(0,t.unref)(v)(...e),onContextmenu:n[25]||=(0,t.withModifiers)(()=>{},[`prevent`])},n[39]||=[(0,t.createElementVNode)(`img`,{src:`data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%3e%3cpath%20d='M3%2015H5V19H19V15H21V19C21%2020.1%2020.1%2021%2019%2021H5C3.9%2021%203%2020.1%203%2019V15Z'%20/%3e%3c/svg%3e`,class:`tdhk-base__key-icon`,alt:`Space`},null,-1)],32),(0,t.createElementVNode)(`button`,{class:`tdhk-base__key`,onPointerdown:n[26]||=e=>(0,t.unref)(_)(e,()=>f(`。`)),onPointerup:n[27]||=(...e)=>(0,t.unref)(v)&&(0,t.unref)(v)(...e),onPointerleave:n[28]||=(...e)=>(0,t.unref)(v)&&(0,t.unref)(v)(...e),onPointercancel:n[29]||=(...e)=>(0,t.unref)(v)&&(0,t.unref)(v)(...e),onContextmenu:n[30]||=(0,t.withModifiers)(()=>{},[`prevent`])},` 。 `,32),(0,t.createElementVNode)(`button`,{class:`tdhk-base__key tdhk-base__key--function`,onClick:C,onContextmenu:n[31]||=(0,t.withModifiers)(()=>{},[`prevent`])},[(0,t.createElementVNode)(`span`,fe,(0,t.toDisplayString)(s.value?`中`:`英`),1),(0,t.createElementVNode)(`span`,pe,`/`+(0,t.toDisplayString)(s.value?`英`:`中`),1)],32),(0,t.createElementVNode)(`button`,{class:`tdhk-base__key tdhk-base__key--function`,onPointerdown:n[32]||=e=>(0,t.unref)(_)(e,()=>x()),onPointerup:n[33]||=(...e)=>(0,t.unref)(v)&&(0,t.unref)(v)(...e),onPointerleave:n[34]||=(...e)=>(0,t.unref)(v)&&(0,t.unref)(v)(...e),onPointercancel:n[35]||=(...e)=>(0,t.unref)(v)&&(0,t.unref)(v)(...e),onContextmenu:n[36]||=(0,t.withModifiers)(()=>{},[`prevent`])},n[40]||=[(0,t.createElementVNode)(`img`,{src:`data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%3e%3cpath%20d='M19,7V11H5.83L9.41,7.41L8,6L2,12L8,18L9.41,16.58L5.83,13H21V7H19Z'%20/%3e%3c/svg%3e`,class:`tdhk-base__key-icon`,alt:`Enter`},null,-1)],32)])]))}}),he={class:`num-keyboard`},ge={class:`num-keyboard__container`},_e={class:`num-keyboard__left`},ve={class:`num-keyboard__rows`},ye=[`onClick`,`onPointerdown`],be={key:1,src:q,class:`tdhk-base__key-icon`,alt:`Space`},xe={class:`num-keyboard__right`},Se=[`onPointerdown`],Ce=[`src`,`alt`],we={key:1},Te=(0,t.defineComponent)({__name:`NumericKeyboard`,props:{keyboardRows:{default:()=>(0,n.getKeyboardConfig)().numKeys||[[`1`,`2`,`3`],[`4`,`5`,`6`],[`7`,`8`,`9`],[`back`,`0`,`space`]]}},emits:[`key`,`exit`],setup(e,{emit:n}){let r=n,i=[{key:`delete`,icon:E,text:``,alt:`Delete`},{key:`.`,icon:``,text:`.`,alt:`.`},{key:`@`,icon:``,text:`@`,alt:`@`},{key:`enter`,icon:D,text:``,alt:`Enter`}];function a(e){r(`key`,{key:e})}function o(e,t=!0){r(`key`,{key:e,isControl:t})}function s(){r(`exit`)}let{startRepeat:c,stopRepeat:l}=O();function u(e,t){e===`back`||(e===`space`&&(e=` `),e===`delete`||e===`enter`?c(t,()=>o(e)):c(t,()=>a(e)))}return(e,n)=>((0,t.openBlock)(),(0,t.createElementBlock)(`div`,he,[(0,t.createElementVNode)(`div`,ge,[(0,t.createElementVNode)(`div`,_e,[(0,t.createElementVNode)(`div`,ve,[((0,t.openBlock)(!0),(0,t.createElementBlock)(t.Fragment,null,(0,t.renderList)(e.keyboardRows,(e,r)=>((0,t.openBlock)(),(0,t.createElementBlock)(`div`,{key:`row-${r}`,class:`num-keyboard__row`},[((0,t.openBlock)(!0),(0,t.createElementBlock)(t.Fragment,null,(0,t.renderList)(e,(e,i)=>((0,t.openBlock)(),(0,t.createElementBlock)(`button`,{key:`key-${r}-${i}`,class:(0,t.normalizeClass)([`num-keyboard__key`,{"num-keyboard__key--back":e===`back`,"num-keyboard__key--space":e===`space`}]),onClick:t=>e===`back`&&s(),onPointerdown:t=>u(e,t),onPointerup:n[0]||=(...e)=>(0,t.unref)(l)&&(0,t.unref)(l)(...e),onPointerleave:n[1]||=(...e)=>(0,t.unref)(l)&&(0,t.unref)(l)(...e),onPointercancel:n[2]||=(...e)=>(0,t.unref)(l)&&(0,t.unref)(l)(...e),onContextmenu:n[3]||=(0,t.withModifiers)(()=>{},[`prevent`])},[e===`back`?((0,t.openBlock)(),(0,t.createElementBlock)(t.Fragment,{key:0},[(0,t.createTextVNode)(` 返回 `)],64)):e===`space`?((0,t.openBlock)(),(0,t.createElementBlock)(`img`,be)):((0,t.openBlock)(),(0,t.createElementBlock)(t.Fragment,{key:2},[(0,t.createTextVNode)((0,t.toDisplayString)(e),1)],64))],42,ye))),128))]))),128))])]),(0,t.createElementVNode)(`div`,xe,[((0,t.openBlock)(),(0,t.createElementBlock)(t.Fragment,null,(0,t.renderList)(i,(e,r)=>(0,t.createElementVNode)(`button`,{key:`func-${r}`,class:`num-keyboard__key num-keyboard__key--function`,onPointerdown:t=>u(e.key,t),onPointerup:n[4]||=(...e)=>(0,t.unref)(l)&&(0,t.unref)(l)(...e),onPointerleave:n[5]||=(...e)=>(0,t.unref)(l)&&(0,t.unref)(l)(...e),onPointercancel:n[6]||=(...e)=>(0,t.unref)(l)&&(0,t.unref)(l)(...e),onContextmenu:n[7]||=(0,t.withModifiers)(()=>{},[`prevent`])},[e.icon?((0,t.openBlock)(),(0,t.createElementBlock)(`img`,{key:0,src:e.icon,class:`num-keyboard__key-icon`,alt:e.alt},null,8,Ce)):((0,t.openBlock)(),(0,t.createElementBlock)(`span`,we,(0,t.toDisplayString)(e.text),1))],40,Se)),64))])])]))}}),Ee=`data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%3e%3cpath%20d='M18,20V10H6V20H18M18,8A2,2%200%200,1%2020,10V20A2,2%200%200,1%2018,22H6C4.89,22%204,21.1%204,20V10A2,2%200%200,1%206,8H15V6A3,3%200%200,0%2012,3A3,3%200%200,0%209,6H7A5,5%200%200,1%2012,1A5,5%200%200,1%2017,6V8H18M12,17A2,2%200%200,1%2010,15A2,2%200%200,1%2012,13A2,2%200%200,1%2014,15A2,2%200%200,1%2012,17Z'%20/%3e%3c/svg%3e`,De=`data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%3e%3cpath%20d='M12,17C10.89,17%2010,16.1%2010,15C10,13.89%2010.89,13%2012,13A2,2%200%200,1%2014,15A2,2%200%200,1%2012,17M18,20V10H6V20H18M18,8A2,2%200%200,1%2020,10V20A2,2%200%200,1%2018,22H6C4.89,22%204,21.1%204,20V10C4,8.89%204.89,8%206,8H7V6A5,5%200%200,1%2012,1A5,5%200%200,1%2017,6V8H18M12,3A3,3%200%200,0%209,6V8H15V6A3,3%200%200,0%2012,3Z'%20/%3e%3c/svg%3e`,Oe={class:`symbol-keyboard`},Q={class:`symbol-keyboard__content`},ke={class:`symbol-keyboard__functions`},Ae={class:`symbol-keyboard__lang-selector`},je={class:`symbol-keyboard__control-group`},Me=[`src`],Ne=[`src`],Pe={class:`symbol-keyboard__symbols-container`},Fe={class:`symbol-keyboard__symbols-grid`},Ie=[`onClick`,`onPointerdown`],Le=`!@#$%^&*(){}[]<>/\\|:;"',.?+-=_~\`€£¥₹©®™°`,Re=`!@#¥%…&*(){}[]<>/\|:;"',。?+-=_~·€£¥₹©®™°`,ze=(0,t.defineComponent)({__name:`SymbolKeyboard`,emits:[`key`,`exit`],setup(e,{emit:n}){let r=n,i=(0,t.ref)(`en`),a=(0,t.computed)(()=>i.value===`zh`?Re:Le),o=(0,t.ref)(!1),{startRepeat:s,stopRepeat:c}=O();function l(e,t){o.value&&s(t,()=>u(e))}function u(e){r(`key`,{key:e}),o.value||r(`exit`)}function d(){r(`exit`)}function f(e){i.value=e}function p(){o.value=!o.value}return(e,n)=>((0,t.openBlock)(),(0,t.createElementBlock)(`div`,Oe,[(0,t.createElementVNode)(`div`,Q,[(0,t.createElementVNode)(`div`,ke,[(0,t.createElementVNode)(`div`,Ae,[(0,t.createElementVNode)(`button`,{class:(0,t.normalizeClass)([`symbol-keyboard__lang-btn`,{"symbol-keyboard__lang-btn--active":i.value===`zh`}]),onClick:n[0]||=e=>f(`zh`),onContextmenu:n[1]||=(0,t.withModifiers)(()=>{},[`prevent`])},` 中文 `,34),(0,t.createElementVNode)(`button`,{class:(0,t.normalizeClass)([`symbol-keyboard__lang-btn`,{"symbol-keyboard__lang-btn--active":i.value===`en`}]),onClick:n[2]||=e=>f(`en`),onContextmenu:n[3]||=(0,t.withModifiers)(()=>{},[`prevent`])},` 英文 `,34)]),(0,t.createElementVNode)(`div`,je,[(0,t.createElementVNode)(`button`,{class:(0,t.normalizeClass)([`symbol-keyboard__key symbol-keyboard__key--function symbol-keyboard__key--lock`,{"symbol-keyboard__key--locked":o.value}]),onClick:p,onContextmenu:n[4]||=(0,t.withModifiers)(()=>{},[`prevent`])},[o.value?((0,t.openBlock)(),(0,t.createElementBlock)(`img`,{key:1,src:(0,t.unref)(De),alt:`Lock closed`},null,8,Ne)):((0,t.openBlock)(),(0,t.createElementBlock)(`img`,{key:0,src:(0,t.unref)(Ee),alt:`Lock open`},null,8,Me))],34),(0,t.createElementVNode)(`button`,{class:`symbol-keyboard__key symbol-keyboard__key--function symbol-keyboard__key--back`,onClick:d,onContextmenu:n[5]||=(0,t.withModifiers)(()=>{},[`prevent`])},` 返回 `,32)])]),(0,t.createElementVNode)(`div`,Pe,[(0,t.createElementVNode)(`div`,Fe,[((0,t.openBlock)(!0),(0,t.createElementBlock)(t.Fragment,null,(0,t.renderList)(a.value,(e,r)=>((0,t.openBlock)(),(0,t.createElementBlock)(`button`,{key:`key-${r}`,class:`symbol-keyboard__key`,onClick:t=>!o.value&&u(e),onPointerdown:t=>l(e,t),onPointerup:n[6]||=(...e)=>(0,t.unref)(c)&&(0,t.unref)(c)(...e),onPointerleave:n[7]||=(...e)=>(0,t.unref)(c)&&(0,t.unref)(c)(...e),onPointercancel:n[8]||=(...e)=>(0,t.unref)(c)&&(0,t.unref)(c)(...e),onContextmenu:n[9]||=(0,t.withModifiers)(()=>{},[`prevent`])},(0,t.toDisplayString)(e),41,Ie))),128))])])])]))}}),Be={key:0,class:`tdhk__disabled-overlay`},$=(0,t.defineComponent)({__name:`TdhKeyboard`,props:{defaultMode:{type:String,default:()=>(0,n.getKeyboardConfig)().defaultMode??`en`},enableHandwriting:{type:Boolean,default:()=>(0,n.getKeyboardConfig)().enableHandwriting??!1},position:{type:String,default:()=>(0,n.getKeyboardConfig)().position??`static`},floatMarginTop:{type:Number,default:()=>(0,n.getKeyboardConfig)().floatMarginTop??0},disableWhenNoFocus:{type:Boolean,default:()=>(0,n.getKeyboardConfig)().disableWhenNoFocus??!0},manual:{type:Boolean,default:()=>(0,n.getKeyboardConfig)().manual??!1},numKeys:{type:Array||void 0}},emits:[`key`],setup(e,{expose:r,emit:i}){let a=e,o=i;function s(e){return e===`zh`||e===`en`||e===`en_cap`}function c(e){return s(e)?e:`zh`}let l=(0,t.ref)(a.defaultMode),u=(0,t.ref)(!1),d=(0,t.ref)(c(a.defaultMode)),f=(0,t.ref)(!1),m=(0,t.ref)(!1),h=(0,t.ref)([]),g=(0,t.ref)(!1),_=(0,t.ref)(null),y=(0,t.ref)(null),b=(0,t.ref)(null),x=(0,t.ref)(!a.manual),S=(0,t.ref)(!1),{recognizerInitialized:w,recognizerProgress:E}=ee(a.enableHandwriting);(0,t.watch)(l,e=>{s(e)&&(d.value=e)});let D=C(),O=(0,t.computed)(()=>a.manual?b.value:D.value&&(0,n.isInputElement)(D.value)?D.value:null),k=(0,t.computed)(()=>S.value||!x.value||u.value&&!O.value?!1:a.manual||a.position===`static`||!!(D.value&&(0,n.isInputElement)(D.value)));(0,t.watch)(O,(e,t)=>{!a.manual&&!S.value&&e&&e!==t&&(x.value=!0)});let{height:A}=T(y);(0,t.watchEffect)(()=>{if(x.value&&O.value){u.value=!1;let e=O.value.dataset.inputmode;e&&(f.value=!1,m.value=!1,s(e)?d.value=e:e===`hand`&&(d.value=`zh`),l.value=e)}});let j=(0,t.computed)(()=>a.manual?!b.value:a.disableWhenNoFocus===!1?!1:!O.value);function M(){A.value&&(_.value=(0,n.calculateKeyboardPosition)(O.value,y.value,a.position,a.floatMarginTop))}(0,t.watchEffect)(M);let N=p(M,100);v(window,`scroll`,N,{passive:!0}),v(window,`resize`,N,{passive:!0});function P(e){if(e.isControl){switch(e.key){case`delete`:(0,n.delToInputElement)(O.value);break;case`more`:g.value=!0;break;default:break}return}else F(e.key);o(`key`,e)}function F(e){(0,n.writeToInputElement)(O.value,e)}function I(){if(l.value===`symbol`&&m.value){m.value=!1,l.value=`hand`;return}m.value=!1,l.value=d.value}function L(e){h.value=e}function R(){if(a.enableHandwriting){if(l.value===`hand`){l.value=d.value;return}s(l.value)&&(d.value=l.value,l.value=`hand`)}}function z(){H(),O.value?.blur()}function B(){m.value=!0,l.value=`symbol`}function V(e){S.value=!1,e?(b.value=e,e.focus()):D.value&&(0,n.isInputElement)(D.value)&&(b.value=D.value),u.value=!1,x.value=!0,M()}function H(){u.value=!0,x.value=!1}function U(){H(),b.value=null,_.value=null,h.value=[],g.value=!1,S.value=!0}return(0,t.watch)(()=>a.manual,e=>{if(!e){x.value=!0,b.value=null,S.value=!1;return}x.value=!1,b.value=null}),r({open:V,close:H,destroy:U}),(n,r)=>(0,t.withDirectives)(((0,t.openBlock)(),(0,t.createElementBlock)(`div`,{ref_key:`keyboardRef`,ref:y,class:(0,t.normalizeClass)([`tdhk`,{"tdhk--floating":e.position===`float`,"tdhk--bottom":e.position===`bottom`,"tdhk--disabled":j.value}]),style:(0,t.normalizeStyle)({"--keyboard-height":`${(0,t.unref)(A)}px`,..._.value}),onMousedown:r[2]||=(0,t.withModifiers)(()=>{},[`prevent`])},[j.value||!k.value||!(0,t.unref)(A)?((0,t.openBlock)(),(0,t.createElementBlock)(`div`,Be,r[3]||=[(0,t.createElementVNode)(`span`,null,`请选择输入框以启用键盘`,-1)])):((0,t.openBlock)(),(0,t.createElementBlock)(t.Fragment,{key:1},[l.value===`hand`?((0,t.openBlock)(),(0,t.createBlock)(K,{key:0,"recognizer-initialized":(0,t.unref)(w),"recognizer-progress":(0,t.unref)(E),onKey:P,onExit:I,onToggleKeyboard:R,onSwitchToSymbol:B,onCollapse:z,onRecognize:L},null,8,[`recognizer-initialized`,`recognizer-progress`])):l.value===`num`?((0,t.openBlock)(),(0,t.createBlock)(Te,{key:1,"keyboard-rows":e.numKeys,onKey:P,onExit:I},null,8,[`keyboard-rows`])):l.value===`symbol`?((0,t.openBlock)(),(0,t.createBlock)(ze,{key:2,onKey:P,onExit:I})):l.value===`en`||l.value===`en_cap`||l.value===`zh`?((0,t.openBlock)(),(0,t.createBlock)(me,{key:3,modelValue:l.value,"onUpdate:modelValue":r[0]||=e=>l.value=e,"caps-return-to-chinese":f.value,"onUpdate:capsReturnToChinese":r[1]||=e=>f.value=e,"enable-handwriting":e.enableHandwriting,onKey:P,onToggleKeyboard:R,onCollapse:z},null,8,[`modelValue`,`caps-return-to-chinese`,`enable-handwriting`])):(0,t.createCommentVNode)(``,!0)],64))],38)),[[t.vShow,k.value]])}});e.TdhKeyboard=$,e.default={install:e=>{e.component(`TdhKeyboard`,$)}},Object.keys(n).forEach(function(t){t!==`default`&&!Object.prototype.hasOwnProperty.call(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:function(){return n[t]}})})});
2
+ //# sourceMappingURL=tdh-keyboard-vue.umd.cjs.map