mirror of
https://github.com/Macrame-App/Macrame
synced 2025-12-29 07:19:26 +00:00
47 lines
26 KiB
JavaScript
47 lines
26 KiB
JavaScript
import{c as V,d as f,f as g,e as d,k as r,t as O,u as i,H as ae,a as x,s as B,x as T,_ as j,r as h,o as S,G as le,g as a,F as R,i as H,j as p,l as _,q as m,J as re,b as Y,E as C,h as b,K as E,L as W,w as ie,v as de,M as ue}from"./index-oAtpp-VZ.js";import{I as Z,b as ee,a as ce}from"./IconTrash-DtIpQ-M_.js";import{_ as z}from"./DialogComp-CyRyORDj.js";/**
|
|
* @license @tabler/icons-vue v3.31.0 - MIT
|
|
*
|
|
* This source code is licensed under the MIT license.
|
|
* See the LICENSE file in the root directory of this source tree.
|
|
*/var ve=V("outline","alarm","IconAlarm",[["path",{d:"M12 13m-7 0a7 7 0 1 0 14 0a7 7 0 1 0 -14 0",key:"svg-0"}],["path",{d:"M12 10l0 3l2 0",key:"svg-1"}],["path",{d:"M7 4l-2.75 2",key:"svg-2"}],["path",{d:"M17 4l2.75 2",key:"svg-3"}]]);/**
|
|
* @license @tabler/icons-vue v3.31.0 - MIT
|
|
*
|
|
* This source code is licensed under the MIT license.
|
|
* See the LICENSE file in the root directory of this source tree.
|
|
*/var ye=V("outline","arrow-left-circle","IconArrowLeftCircle",[["path",{d:"M17 12h-14",key:"svg-0"}],["path",{d:"M6 9l-3 3l3 3",key:"svg-1"}],["path",{d:"M19 12m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0",key:"svg-2"}]]);/**
|
|
* @license @tabler/icons-vue v3.31.0 - MIT
|
|
*
|
|
* This source code is licensed under the MIT license.
|
|
* See the LICENSE file in the root directory of this source tree.
|
|
*/var pe=V("outline","arrow-right-circle","IconArrowRightCircle",[["path",{d:"M18 15l3 -3l-3 -3",key:"svg-0"}],["path",{d:"M5 12m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0",key:"svg-1"}],["path",{d:"M7 12h14",key:"svg-2"}]]);/**
|
|
* @license @tabler/icons-vue v3.31.0 - MIT
|
|
*
|
|
* This source code is licensed under the MIT license.
|
|
* See the LICENSE file in the root directory of this source tree.
|
|
*/var fe=V("outline","loader-3","IconLoader3",[["path",{d:"M3 12a9 9 0 0 0 9 9a9 9 0 0 0 9 -9a9 9 0 0 0 -9 -9",key:"svg-0"}],["path",{d:"M17 12a5 5 0 1 0 -5 5",key:"svg-1"}]]);/**
|
|
* @license @tabler/icons-vue v3.31.0 - MIT
|
|
*
|
|
* This source code is licensed under the MIT license.
|
|
* See the LICENSE file in the root directory of this source tree.
|
|
*/var me=V("outline","plus","IconPlus",[["path",{d:"M12 5l0 14",key:"svg-0"}],["path",{d:"M5 12l14 0",key:"svg-1"}]]);/**
|
|
* @license @tabler/icons-vue v3.31.0 - MIT
|
|
*
|
|
* This source code is licensed under the MIT license.
|
|
* See the LICENSE file in the root directory of this source tree.
|
|
*/var ke=V("outline","restore","IconRestore",[["path",{d:"M3.06 13a9 9 0 1 0 .49 -4.087",key:"svg-0"}],["path",{d:"M3 4.001v5h5",key:"svg-1"}],["path",{d:"M12 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-2"}]]);/**
|
|
* @license @tabler/icons-vue v3.31.0 - MIT
|
|
*
|
|
* This source code is licensed under the MIT license.
|
|
* See the LICENSE file in the root directory of this source tree.
|
|
*/var ge=V("outline","time-duration-15","IconTimeDuration15",[["path",{d:"M12 15h2a1 1 0 0 0 1 -1v-1a1 1 0 0 0 -1 -1h-2v-3h3",key:"svg-0"}],["path",{d:"M9 9v6",key:"svg-1"}],["path",{d:"M3 12v.01",key:"svg-2"}],["path",{d:"M12 21v.01",key:"svg-3"}],["path",{d:"M7.5 4.2v.01",key:"svg-4"}],["path",{d:"M16.5 19.8v.01",key:"svg-5"}],["path",{d:"M7.5 19.8v.01",key:"svg-6"}],["path",{d:"M4.2 16.5v.01",key:"svg-7"}],["path",{d:"M19.8 16.5v.01",key:"svg-8"}],["path",{d:"M4.2 7.5v.01",key:"svg-9"}],["path",{d:"M21 12a9 9 0 0 0 -9 -9",key:"svg-10"}]]);/**
|
|
* @license @tabler/icons-vue v3.31.0 - MIT
|
|
*
|
|
* This source code is licensed under the MIT license.
|
|
* See the LICENSE file in the root directory of this source tree.
|
|
*/var _e=V("filled","player-record-filled","IconPlayerRecordFilled",[["path",{d:"M8 5.072a8 8 0 1 1 -3.995 7.213l-.005 -.285l.005 -.285a8 8 0 0 1 3.995 -6.643z",key:"svg-0"}]]);/**
|
|
* @license @tabler/icons-vue v3.31.0 - MIT
|
|
*
|
|
* This source code is licensed under the MIT license.
|
|
* See the LICENSE file in the root directory of this source tree.
|
|
*/var X=V("filled","player-stop-filled","IconPlayerStopFilled",[["path",{d:"M17 4h-10a3 3 0 0 0 -3 3v10a3 3 0 0 0 3 3h10a3 3 0 0 0 3 -3v-10a3 3 0 0 0 -3 -3z",key:"svg-0"}]]);const we={key:0,class:"loading-component"},$e={key:0},De={__name:"LoadComp",props:{loading:Boolean,text:String},setup(s){return(e,t)=>s.loading?(d(),f("div",we,[s.text?(d(),f("span",$e,O(s.text),1)):g("",!0),r(i(fe),{class:"duration-1000 animate-spin"})])):g("",!0)}},U={Control:"Ctrl",Shift:"Shift",Alt:"Alt",Meta:"Win",CapsLock:"Caps",PageUp:"PgUp",PageDown:"PgDn",ScrollLock:"Scr Lk",Insert:"Ins",Delete:"Del",Escape:"Esc",Space:"Space",Backquote:"`",Backslash:"\\",BracketLeft:"[",BracketRight:"]",Comma:",",Equal:"=",Minus:"-",Period:".",Quote:"'",Semicolon:";",Slash:"/",ArrowUp:"▲",ArrowRight:"▶",ArrowDown:"▼",ArrowLeft:"◀",MediaPlayPause:"Play",MediaStop:"Stop",MediaTrackNext:"Next",MediaTrackPrevious:"Prev",MediaVolumeDown:"Down",MediaVolumeUp:"Up",AudioVolumeMute:"Mute",AudioVolumeDown:"Down",AudioVolumeUp:"Up"},P=s=>{const e={};return s.location===1&&(e.loc="left"),s.location===2&&(e.loc="right"),s.location===3&&(e.loc="num"),(s.key.includes("Media")||s.key.includes("Audio"))&&(e.loc=be(s)),U[s.code]||U[s.key]?e.str=U[s.code]||U[s.key]:e.str=s.key.toLowerCase(),e},be=s=>{switch(s.key){case"MediaPlayPause":case"MediaStop":case"MediaTrackNext":case"MediaTrackPrevious":return"Media";case"MediaVolumeDown":case"MediaVolumeUp":case"AudioVolumeDown":case"AudioVolumeUp":case"AudioVolumeMute":return"Volume"}},xe=(s,e,t)=>s&&s.type==="key"&&s.code===e.code&&s.direction===t,Me=s=>{const e=[],t=[];return Object.keys(s).forEach(n=>{const l=s[n];l.type==="key"&&(l.direction=="down"&&e.push(l.key),l.direction=="up"&&(e.includes(l.key)?e.splice(e.indexOf(l.key),1):t.push(l.key)))}),t.length===0&&e.length===0?!1:{down:e,up:t}},Ke=s=>{const e=[];return s.forEach(t=>{t.type==="delay"&&e.push(t),t.type==="key"&&e.push(Ce(t.code,t.direction))}),e},Ce=(s,e)=>{let t="",n=0,l=s;s.includes("Left")&&(t=s.replace("Left",""),n=1),s.includes("Right")&&(t=s.replace("Right",""),n=2),s.includes("Numpad")&&(t=s.replace("Numpad",""),n=3),s.includes("Media")&&(l=""),t===""&&(t=s);const o={type:"key",code:l,key:t,location:n,direction:e};return{...o,keyObj:P(o)}},I=ae("macrorecorder",()=>{const s=x({record:!1,edit:!1,editKey:!1,editDelay:!1,validationErrors:!1}),e=x(""),t=x([]),n=x({start:0,fixed:!1}),l=()=>t.value[s.value.editKey],o=(k,M=!1)=>{let $=!1;const K=k=="before"?-1:1,D=s.value.editKey+2*K,N=M?s.value.editKey+1*K:!1;return t.value[D]&&($=t.value[D]),N&&t.value[N]&&($={delay:t.value[N],key:t.value[D],delayIndex:N}),$},v=()=>t.value[s.value.editDelay],u=(k,M=!1,$=!1)=>{k.ctrlKey,k.shiftKey,k.altKey,k.metaKey&&k.preventDefault();const K=t.value[t.value.length-1];let D={};typeof k=="object"&&!xe(K,k,M)?($===!1&&y(),D={type:"key",key:k.key,code:k.code,location:k.location,direction:M,keyObj:P(k)}):M&&$!==!1?(D=t.value[$],D.direction=M):typeof k=="number"&&(D={type:"delay",value:parseFloat(k.toFixed())}),$!==!1?t.value[$]=D:t.value.push(D)},y=()=>{n.value.fixed!==!1?u(n.value.fixed):(n.value.start==0||u(performance.now()-n.value.start),n.value.start=performance.now())},c=(k,M,$)=>{let K,D,N,L;if($===null?(K=s.value.editKey==0?0:s.value.editKey,D=s.value.editKey==0?1:!1,N=D===!1?K+2:K,L=K+1):s.value.editKey<$?(K=s.value.editKey,D=$,N=K+2,L=K+1):(K=$,D=s.value.editKey,N=K+1,L=K+2),D!==!1)for(let F=Object.keys(t.value).length-1;F>=D;F--)t.value[F+2]=t.value[F];u(k,M,N),u(10,!1,L),s.value.editKey=!1},w=()=>{s.value.editKey===0?t.value.splice(s.value.editKey,2):t.value.splice(s.value.editKey-1,2),s.value.editKey=!1},G=()=>{n.value.start=performance.now()},J=k=>{e.value=k},se=k=>{n.value.fixed=k,ne()},ne=()=>{t.value=t.value.map(k=>(k.type==="delay"&&n.value.fixed!==!1&&(k.value=n.value.fixed),k))},oe=(k,M)=>{k==="key"&&(s.value.editKey=M,s.value.editDelay=!1),k==="delay"&&(s.value.editKey=!1,s.value.editDelay=M)},Q=()=>{s.value.edit=!1,s.value.editKey=!1,s.value.editDelay=!1};return{state:s,macroName:e,steps:t,delay:n,getEditKey:l,getAdjacentKey:o,getEditDelay:v,recordStep:u,insertKey:c,deleteEditKey:w,restartDelay:G,changeName:J,changeDelay:se,toggleEdit:oe,resetEdit:Q,resetMacro:()=>{s.value.record=!1,n.value.start=0,e.value="",t.value=[],s.value.edit&&Q()},checkMacro:async()=>(await B.post(T()+"/macro/check",{macro:e.value})).data,saveMacro:async()=>(s.value.validationErrors=Me(t.value),s.value.validationErrors?!1:(await B.post(T()+"/macro/record",{name:e.value,steps:t.value})).status==200),deleteMacro:async k=>{const M=await B.post(T()+"/macro/delete",{macro:k});return M.status==200?M.data:!1},openMacro:async(k,M)=>{const $=await B.post(T()+"/macro/open",{macro:k});$.data&&(t.value=Ke($.data)),e.value=M}}}),je={class:"macro-overview mcrm-block block__dark"},Ie={class:"macro-overview__list"},Ee={class:"overview__macro-delete"},Oe={class:"grid gap-2"},Re={class:"mb-2 text-center text-sky-500"},Se={class:"flex justify-between"},Ne={__name:"MacroOverview",setup(s){const e=h({loading:!0,list:[]}),t=I(),n=x(""),l=x();S(()=>{o()});const o=async()=>{const y=await le();e.list=y,e.loading=!1},v=y=>{n.value=y,l.value.toggleDialog(!0)},u=async()=>{await t.deleteMacro(n.value)&&(l.value.toggleDialog(!1),n.value===t.macroName&&t.resetMacro(),n.value="",o())};return(y,c)=>(d(),f("div",je,[c[6]||(c[6]=a("h4",{class:"border-b-2 border-transparent"},"Saved Macros",-1)),a("div",Ie,[r(De,{loading:e.loading,text:"Loading macros..."},null,8,["loading"]),(d(!0),f(R,null,H(e.list,(w,G)=>(d(),f("div",{class:"macro-item",key:G},[r(_,{variant:i(t).macroName===w.name?"secondary":"dark",class:"overview__macro-open",size:"sm",onClick:J=>i(t).openMacro(w.macroname,w.name)},{default:p(()=>[r(i(re)),c[2]||(c[2]=m()),a("span",null,O(w.name),1)]),_:2},1032,["variant","onClick"]),a("div",Ee,[r(_,{class:"!text-red-500 hover:!text-red-300",variant:"ghost",size:"sm",onClick:J=>v(w.name)},{default:p(()=>[r(i(Z))]),_:2},1032,["onClick"])])]))),128))]),r(z,{ref_key:"deleteDialog",ref:l},{content:p(()=>[a("div",Oe,[c[5]||(c[5]=a("h4",{class:"pr-4"},"Are you sure you want to delete:",-1)),a("h3",Re,O(n.value),1),a("div",Se,[r(_,{size:"sm",variant:"subtle",onClick:c[0]||(c[0]=w=>l.value.toggleDialog(!1))},{default:p(()=>c[3]||(c[3]=[m(" No ")])),_:1}),r(_,{size:"sm",variant:"danger",onClick:c[1]||(c[1]=w=>u())},{default:p(()=>c[4]||(c[4]=[m("Yes")])),_:1})])])]),_:1},512)]))}},Ve=j(Ne,[["__scopeId","data-v-07eda649"]]),ze={key:0},Ae=["innerHTML"],Pe={class:"dir"},he={key:1},A={__name:"MacroKey",props:{keyObj:Object,direction:String,active:Boolean,empty:Boolean},setup(s){const e=s,t=h({value:!1});S(()=>{e.empty||n()}),Y(()=>{n()});const n=()=>{e.direction?t.value=e.direction:t.value=e.keyObj.direction};return(l,o)=>(d(),f("kbd",{class:C(`${s.active?"active":""} ${s.empty?"empty":""}`)},[s.keyObj?(d(),f(R,{key:0},[s.keyObj.loc?(d(),f("sup",ze,O(s.keyObj.loc),1)):g("",!0),a("span",{innerHTML:s.keyObj.str},null,8,Ae),a("span",Pe,O(t.value==="down"?"↓":"↑"),1)],64)):s.empty?(d(),f("span",he,"[ ]")):g("",!0)],2))}},Le={__name:"DelaySpan",props:{value:Number,active:Boolean,preset:Boolean},setup(s){return(e,t)=>(d(),f("span",{class:C(`delay ${s.active?"active":""} ${s.preset?"preset":""}`)},[s.value<1e4?(d(),f(R,{key:0},[m(O(s.value)+" ",1),t[0]||(t[0]=a("i",null,"ms",-1))],64)):(d(),f(R,{key:1},[t[1]||(t[1]=m(" >10 ")),t[2]||(t[2]=a("i",null,"s",-1))],64))],2))}},q=j(Le,[["__scopeId","data-v-eb548d44"]]),Fe={__name:"RecorderOutput",setup(s){const e=I();return(t,n)=>(d(),f("div",{class:C(`macro-recorder__output ${i(e).state.record&&"record"} ${i(e).state.edit&&"edit"}`)},[(d(!0),f(R,null,H(i(e).steps,(l,o)=>(d(),f(R,null,[l.type==="key"?(d(),b(A,{key:o,"key-obj":l.keyObj,direction:l.direction,active:i(e).state.editKey===o,onClick:v=>i(e).state.edit?i(e).toggleEdit("key",o):!1},null,8,["key-obj","direction","active","onClick"])):l.type==="delay"?(d(),b(q,{key:o,value:l.value,active:i(e).state.editDelay===o,onClick:v=>i(e).toggleEdit("delay",o)},null,8,["value","active","onClick"])):g("",!0),n[0]||(n[0]=a("hr",{class:"spacer"},null,-1))],64))),256))],2))}},Be=j(Fe,[["__scopeId","data-v-bfb55e2e"]]),Te={__name:"RecorderInput",setup(s){const e=x(null),t=I();return Y(()=>{t.state.record&&(e.value.focus(),t.delay.start!==0&&t.restartDelay())}),(n,l)=>(d(),f("div",{class:C(`recorder-input__container ${i(t).state.record&&"record"}`)},[i(t).state.record?(d(),f("input",{key:0,class:C(`macro-recorder__input ${i(t).state.record&&"record"}`),type:"text",ref_key:"macroInput",ref:e,onKeydown:l[0]||(l[0]=E(o=>i(t).recordStep(o,"down"),["prevent"])),onKeyup:l[1]||(l[1]=E(o=>i(t).recordStep(o,"up"),["prevent"]))},null,34)):g("",!0)],2))}},Ue=j(Te,[["__scopeId","data-v-f1475559"]]),He={class:"context-menu"},te={__name:"ContextMenu",props:{open:Boolean},setup(s,{expose:e}){e({toggle:l});const t=s,n=x(!1);S(()=>{n.value=t.open});function l(){n.value=!n.value}return(o,v)=>(d(),f("div",He,[a("div",{class:"context-menu__trigger",onClick:l},[W(o.$slots,"trigger")]),a("div",{class:C(`context-menu__content ${n.value?"open":""}`)},[W(o.$slots,"content")],2)]))}},qe={type:"number",step:"10",min:"0",max:"3600000",ref:"customDelayInput",placeholder:"100"},Ge={class:"flex justify-end"},Je={__name:"FixedDelayMenu",setup(s){const e=I(),t=x();function n(l){e.changeDelay(l),t.value.toggle()}return(l,o)=>(d(),b(te,{ref_key:"ctxtMenu",ref:t},{trigger:p(()=>[r(_,{variant:"secondary",size:"sm"},{default:p(()=>[r(i(ge)),o[5]||(o[5]=m("Fixed delay "))]),_:1})]),content:p(()=>[a("ul",null,[a("li",{onClick:o[0]||(o[0]=v=>n(0))},"0ms"),a("li",{onClick:o[1]||(o[1]=v=>n(15))},"15ms"),a("li",{onClick:o[2]||(o[2]=v=>n(50))},"50ms"),a("li",{onClick:o[3]||(o[3]=v=>n(100))},"100ms"),a("li",null,[r(z,null,{trigger:p(()=>o[6]||(o[6]=[a("span",null,"Custom delay",-1)])),content:p(()=>[o[9]||(o[9]=a("h4",{class:"text-slate-50 mb-4"},"Custom delay",-1)),a("form",{class:"grid gap-4 w-44",onSubmit:o[4]||(o[4]=E(v=>n(parseInt(l.$refs.customDelayInput.value)),["prevent"]))},[a("div",null,[a("input",qe,null,512),o[7]||(o[7]=a("span",null,"ms",-1))]),a("div",Ge,[r(_,{variant:"primary",size:"sm"},{default:p(()=>o[8]||(o[8]=[m("Set custom delay")])),_:1})])],32)]),_:1})])])]),_:1},512))}},Ye=j(Je,[["__scopeId","data-v-de355396"]]),Qe={id:"edit-key-dialog",class:"dialog__content"},We={class:"grid gap-4","submit.prevent":""},Xe={class:"flex gap-2 justify-center"},Ze={class:"flex justify-end"},et={__name:"EditKeyDialog",setup(s){const e=h({key:{},newKey:{}}),t=I(),n=x(null);S(()=>{e.key=t.getEditKey(),e.newKey.direction=e.key.direction});const l=u=>{e.newKey.e=u,e.newKey.keyObj=P(u)},o=u=>{e.newKey.direction=u,e.newKey.keyObj=P(e.key)},v=()=>{t.recordStep(e.newKey.e,e.newKey.direction,t.state.editKey),t.state.editKey=!1};return(u,y)=>(d(),f("div",Qe,[y[9]||(y[9]=a("h4",{class:"text-slate-50 mb-4"},"Press a key",-1)),a("div",{class:"flex justify-center",onClick:y[0]||(y[0]=c=>u.$refs.newKeyInput.focus())},[e.key.keyObj?(d(),b(A,{key:0,"key-obj":e.key.keyObj,direction:e.key.direction},null,8,["key-obj","direction"])):g("",!0),typeof e.newKey.keyObj=="object"?(d(),f(R,{key:1},[y[5]||(y[5]=a("span",{class:"px-4 flex items-center text-white"}," >>> ",-1)),r(A,{"key-obj":e.newKey.keyObj,direction:e.newKey.direction},null,8,["key-obj","direction"])],64)):g("",!0)]),a("form",We,[a("input",{class:"size-0 opacity-0",type:"text",min:"0",max:"1",ref_key:"newKeyInput",ref:n,placeholder:"New key",autofocus:"",onKeydown:y[1]||(y[1]=E(c=>l(c),["prevent"]))},null,544),a("div",Xe,[r(_,{variant:"secondary",class:C(e.newKey.direction==="down"?"selected":""),size:"sm",onClick:y[2]||(y[2]=E(c=>o("down"),["prevent"]))},{default:p(()=>y[6]||(y[6]=[m(" ↓ Down ")])),_:1},8,["class"]),r(_,{variant:"secondary",class:C(e.newKey.direction==="up"?"selected":""),size:"sm",onClick:y[3]||(y[3]=E(c=>o("up"),["prevent"]))},{default:p(()=>y[7]||(y[7]=[m(" ↑ Up ")])),_:1},8,["class"])]),a("div",Ze,[r(_,{variant:"primary",size:"sm",onClick:y[4]||(y[4]=E(c=>v(),["prevent"]))},{default:p(()=>y[8]||(y[8]=[m(" Change key ")])),_:1})])])]))}},tt=j(et,[["__scopeId","data-v-ba580ef2"]]),st={id:"edit-delay-dialog",class:"dialog__content"},nt={key:0,class:"flex justify-center"},ot={class:"grid gap-4 mt-6","submit.prevent":""},at={key:0},lt={class:"flex justify-end"},rt={__name:"EditDelayDialog",setup(s){const e=I(),t=h({delay:{},newDelay:{value:0}});S(()=>{t.delay=e.getEditDelay(),t.newDelay.value=t.delay.value});const n=()=>{t.newDelay.value&&(e.recordStep(t.newDelay.value,!1,e.state.editDelay),e.state.editDelay=!1)};return(l,o)=>(d(),f("div",st,[o[4]||(o[4]=a("h4",{class:"mb-4 text-slate-50"},"Edit delay",-1)),t.delay.value?(d(),f("div",nt,[r(q,{class:"!text-lg",value:t.delay.value},null,8,["value"])])):g("",!0),a("form",ot,[t.newDelay.value?(d(),f("div",at,[ie(a("input",{type:"number",min:"0",max:"3600000",step:"10","onUpdate:modelValue":o[0]||(o[0]=v=>t.newDelay.value=v),autofocus:""},null,512),[[de,t.newDelay.value]]),o[2]||(o[2]=a("span",null,"ms",-1))])):g("",!0),a("div",lt,[r(_,{variant:"primary",size:"sm",onClick:o[1]||(o[1]=E(v=>n(),["prevent"]))},{default:p(()=>o[3]||(o[3]=[m(" Change delay ")])),_:1})])])]))}},it=j(rt,[["__scopeId","data-v-a988f674"]]),dt={id:"delete-key-dialog",class:"dialog__content"},ut={class:"flex justify-center w-full mb-4"},ct={class:"flex justify-end gap-2 mt-6"},vt={__name:"DeleteKeyDialog",setup(s){const e=I(),t=x(null);return S(()=>{t.value=P(e.getEditKey())}),(n,l)=>(d(),f("div",dt,[l[2]||(l[2]=a("h4",{class:"mb-4 text-slate-50"},"Delete key",-1)),a("div",ut,[t.value?(d(),b(A,{key:0,"key-obj":t.value},null,8,["key-obj"])):g("",!0)]),l[3]||(l[3]=a("p",{class:"text-sm text-slate-300"},"Are you sure you want to delete this key?",-1)),a("div",ct,[r(_,{variant:"danger",size:"sm",onClick:l[0]||(l[0]=o=>i(e).deleteEditKey())},{default:p(()=>l[1]||(l[1]=[m(" Delete key ")])),_:1})])]))}},yt=j(vt,[["__scopeId","data-v-a48b7cc7"]]),pt={id:"insert-key-dialog",class:"dialog__content w-96"},ft={class:"text-slate-50 mb-4"},mt={key:0,class:"text-center"},kt={class:"insert-key__direction"},gt={class:"flex justify-end"},_t={__name:"InsertKeyDialog",props:{position:String},setup(s){const e=s,t=I(),n=h({selected:null,insert:null,insertEvent:null,insertDirection:"down",adjacent:null,adjacentDelay:null,adjacentDelayIndex:null}),l=x(null),o=x(!1);S(()=>{n.selected=P(t.getEditKey());const y=t.getAdjacentKey(e.position,!0);y&&(n.adjacent=P(y.key)),y.delay&&(n.adjacentDelay=y.delay,n.adjacentDelayIndex=y.delayIndex)});const v=y=>{n.insert=P(y),n.insertEvent=y},u=()=>{t.insertKey(n.insertEvent,n.insertDirection,n.adjacentDelayIndex)};return(y,c)=>(d(),f("div",pt,[a("h4",ft,"Insert key "+O(s.position),1),o.value?(d(),f("p",mt,"[Press a key]")):g("",!0),a("input",{class:"size-0 opacity-0",type:"text",min:"0",max:"1",ref_key:"insertKeyInput",ref:l,placeholder:"New key",onFocusin:c[0]||(c[0]=w=>o.value=!0),onFocusout:c[1]||(c[1]=w=>o.value=!1),onKeydown:c[2]||(c[2]=E(w=>v(w),["prevent"])),autofocus:""},null,544),a("div",{class:C(["insert-output",s.position=="before"?"flex-row-reverse":""])},[n.selected?(d(),b(A,{key:0,"key-obj":n.selected},null,8,["key-obj"])):g("",!0),c[10]||(c[10]=a("hr",{class:"spacer"},null,-1)),r(q,{preset:!0,value:10}),c[11]||(c[11]=a("hr",{class:"spacer"},null,-1)),n.insert?(d(),b(A,{key:1,class:"insert","key-obj":n.insert,direction:n.insertDirection,onClick:c[3]||(c[3]=w=>l.value.focus())},null,8,["key-obj","direction"])):g("",!0),n.insert?g("",!0):(d(),b(A,{key:2,empty:!0,onClick:c[4]||(c[4]=w=>l.value.focus())})),n.adjacentDelay?(d(),f(R,{key:3},[c[8]||(c[8]=a("hr",{class:"spacer"},null,-1)),r(q,{value:n.adjacentDelay.value},null,8,["value"])],64)):g("",!0),n.adjacent?(d(),f(R,{key:4},[c[9]||(c[9]=a("hr",{class:"spacer"},null,-1)),r(A,{"key-obj":n.adjacent},null,8,["key-obj"])],64)):g("",!0)],2),a("div",kt,[r(_,{variant:"secondary",class:C(n.insertDirection==="down"?"selected":""),size:"sm",onClick:c[5]||(c[5]=E(w=>n.insertDirection="down",["prevent"]))},{default:p(()=>c[12]||(c[12]=[m(" ↓ Down ")])),_:1},8,["class"]),r(_,{variant:"secondary",class:C(n.insertDirection==="up"?"selected":""),size:"sm",onClick:c[6]||(c[6]=E(w=>n.insertDirection="up",["prevent"]))},{default:p(()=>c[13]||(c[13]=[m(" ↑ Up ")])),_:1},8,["class"])]),a("div",gt,[r(_,{variant:"primary",size:"sm",onClick:c[7]||(c[7]=w=>u())},{default:p(()=>c[14]||(c[14]=[m("Insert key")])),_:1})])]))}},wt=j(_t,[["__scopeId","data-v-046a1063"]]),$t={key:0,class:"macro-edit__dialogs"},Dt={key:0,class:"flex gap-2"},bt={__name:"EditDialogs",setup(s){const e=I(),t=h({position:null}),n=x();S(()=>{e.$subscribe(v=>{v.events&&v.events.key=="editKey"&&v.events.newValue===!1&&(t.position=null)})});function l(){t.position!==null&&n.value.toggle()}function o(){e.state.editKey=!1,e.state.editDelay=!1,t.position=null}return(v,u)=>i(e).state.edit!==!1?(d(),f("div",$t,[i(e).state.editKey!==!1&&typeof i(e).getEditKey()=="object"?(d(),f("div",Dt,[r(te,{ref_key:"ctxtMenu",ref:n},{trigger:p(()=>[r(_,{variant:"dark",size:"sm"},{default:p(()=>[r(i(me)),u[2]||(u[2]=m(" Insert "))]),_:1})]),content:p(()=>[a("ul",null,[a("li",{onClick:u[0]||(u[0]=y=>t.position="before")},[r(i(ye)),u[3]||(u[3]=m(" Before"))]),a("li",{onClick:u[1]||(u[1]=y=>t.position="after")},[r(i(pe)),u[4]||(u[4]=m(" After"))])])]),_:1},512),t.position!==null?(d(),b(z,{key:0,open:t.position!==null,onOnOpen:l,onOnClose:o},{content:p(()=>[r(wt,{position:t.position},null,8,["position"])]),_:1},8,["open"])):g("",!0),r(z,{id:`edit-key-${i(e).state.editKey}`,onOnOpen:l,onOnClose:o},{trigger:p(()=>[r(_,{variant:"secondary",size:"sm"},{default:p(()=>[r(i(ee)),u[5]||(u[5]=m("Edit "))]),_:1})]),content:p(()=>[r(tt)]),_:1},8,["id"]),r(z,{onOnOpen:l,onOnClose:o},{trigger:p(()=>[r(_,{size:"sm",variant:"danger"},{default:p(()=>[r(i(Z)),u[6]||(u[6]=m("Delete "))]),_:1})]),content:p(()=>[r(yt)]),_:1})])):g("",!0),i(e).state.editDelay!==!1&&typeof i(e).getEditDelay()=="object"?(d(),b(z,{key:1,onOnOpen:l,onOnClose:o},{trigger:p(()=>[r(_,{variant:"secondary",size:"sm"},{default:p(()=>[r(i(ve)),u[7]||(u[7]=m("Edit "))]),_:1})]),content:p(()=>[r(it)]),_:1})):g("",!0)])):g("",!0)}},xt=j(bt,[["__scopeId","data-v-2ff36c22"]]),Mt={class:"macro-recorder__header"},Kt={class:"w-full grid grid-cols-[auto_1fr_auto] gap-2"},Ct=["value"],jt={__name:"RecorderHeader",setup(s){const e=I(),t=ue(()=>e.macroName),n=x(!1);Y(()=>{n.value=t.value&&t.value.length>0});function l(o){e.changeName(o),n.value=o.length>0}return(o,v)=>(d(),f("div",Mt,[a("div",Kt,[v[7]||(v[7]=a("h4",{class:""},"Name:",-1)),a("input",{id:"macro-name",type:"text",onInput:v[0]||(v[0]=E(u=>l(u.target.value),["prevent"])),value:t.value,placeholder:"New macro"},null,40,Ct),a("div",{class:C(`recording__buttons ${!n.value||i(e).state.edit?"disabled":""}`)},[m(O(i(e).name)+" ",1),i(e).state.record?g("",!0):(d(),b(_,{key:0,variant:"primary",onClick:v[1]||(v[1]=u=>i(e).state.record=!0)},{default:p(()=>[r(i(_e),{class:"text-red-500"}),v[5]||(v[5]=m("Record "))]),_:1})),i(e).state.record?(d(),b(_,{key:1,variant:"danger",onClick:v[2]||(v[2]=u=>i(e).state.record=!1)},{default:p(()=>[r(i(X),{class:"text-white"}),v[6]||(v[6]=m("Stop "))]),_:1})):g("",!0)],2)]),i(e).steps.length>0?(d(),f("div",{key:0,class:C(`edit__buttons ${i(e).state.record?"disabled":""}`)},[a("div",null,[i(e).state.edit?g("",!0):(d(),b(_,{key:0,variant:"secondary",onClick:v[3]||(v[3]=u=>i(e).state.edit=!0)},{default:p(()=>[r(i(ee)),v[8]||(v[8]=m("Edit "))]),_:1})),i(e).state.edit?(d(),b(_,{key:1,variant:"danger",onClick:v[4]||(v[4]=u=>i(e).resetEdit())},{default:p(()=>[r(i(X)),v[9]||(v[9]=m("Stop "))]),_:1})):g("",!0)]),i(e).state.edit?(d(),b(Ye,{key:0})):g("",!0),r(xt)],2)):g("",!0)]))}},It=j(jt,[["__scopeId","data-v-f2d09e68"]]),Et={id:"validation-error__dialog",class:"dialog__content"},Ot={key:0,class:"grid gap-4"},Rt={key:0},St={key:1},Nt={class:"flex justify-end mt-4"},Vt={__name:"ValidationErrorDialog",setup(s){const e=I(),t=h({up:[],down:[]});return S(()=>{e.$subscribe(n=>{n.events&&n.events.key=="validationErrors"&&(t.up=n.events.newValue!==!1?e.state.validationErrors.up:[],t.down=n.events.newValue!==!1?e.state.validationErrors.down:[])})}),(n,l)=>(d(),f("div",Et,[l[4]||(l[4]=a("h4",{class:"mb-4 text-slate-50"},"There's an error in your macro",-1)),t&&t.up.length>0||t.down.length>0?(d(),f("div",Ot,[t.down.length>0?(d(),f("div",Rt,[l[1]||(l[1]=a("p",null,[m(" The following keys have been "),a("strong",null,"pressed"),m(" down, but "),a("strong",null,"not released"),m(". ")],-1)),a("ul",null,[(d(!0),f(R,null,H(t.down,o=>(d(),f("li",{key:o},O(o.toUpperCase()),1))),128))])])):g("",!0),t.up.length>0?(d(),f("div",St,[l[2]||(l[2]=a("p",null,[m(" The following keys have been "),a("strong",null,"released"),m(", but "),a("strong",null,"not pressed"),m(" down. ")],-1)),a("ul",null,[(d(!0),f(R,null,H(t.up,o=>(d(),f("li",{key:o},O(o.toUpperCase()),1))),128))])])):g("",!0)])):g("",!0),a("div",Nt,[r(_,{size:"sm",variant:"danger",onClick:l[0]||(l[0]=o=>i(e).state.validationErrors=!1)},{default:p(()=>l[3]||(l[3]=[m(" Close ")])),_:1})])]))}},zt=j(Vt,[["__scopeId","data-v-d58db43f"]]),At={class:"macro-recorder__footer"},Pt={class:"grid gap-2"},ht={class:"mb-2 text-center text-sky-500"},Lt={class:"flex justify-between"},Ft={__name:"RecorderFooter",setup(s){const e=I(),t=x(),n=x();S(()=>{e.$subscribe(v=>{v.events&&v.events.key=="validationErrors"&&t.value.toggleDialog(v.events.newValue!==!1)})});const l=async()=>{await e.checkMacro()?n.value.toggleDialog(!0):o()},o=async()=>{n.value.toggleDialog(!1),await e.saveMacro()?window.location.reload():t.value.toggleDialog(!0)};return(v,u)=>(d(),f("div",At,[i(e).steps.length>0?(d(),b(_,{key:0,variant:"danger",onClick:u[0]||(u[0]=y=>i(e).reset())},{default:p(()=>[r(i(ke)),u[4]||(u[4]=m(" Reset "))]),_:1})):g("",!0),r(z,{ref_key:"errorDialog",ref:t},{content:p(()=>[r(zt)]),_:1},512),r(z,{ref_key:"overwriteDialog",ref:n},{content:p(()=>[a("div",Pt,[u[7]||(u[7]=a("h4",{class:"pr-4"},"Are you sure you want to overwrite:",-1)),a("h3",ht,O(i(e).macroName),1),a("div",Lt,[r(_,{size:"sm",variant:"subtle",onClick:u[1]||(u[1]=y=>n.value.toggleDialog(!1))},{default:p(()=>u[5]||(u[5]=[m("No")])),_:1}),r(_,{size:"sm",variant:"primary",onClick:u[2]||(u[2]=y=>o())},{default:p(()=>u[6]||(u[6]=[m("Yes")])),_:1})])])]),_:1},512),i(e).steps.length>0?(d(),b(_,{key:1,disabled:i(e).state.record||i(e).state.edit,variant:"success",onClick:u[3]||(u[3]=y=>l())},{default:p(()=>[r(i(ce)),u[8]||(u[8]=m(" Save "))]),_:1},8,["disabled"])):g("",!0)]))}},Bt=j(Ft,[["__scopeId","data-v-0a809300"]]),Tt={class:"macro-recorder mcrm-block block__light"},Ut={class:"recorder-interface"},Ht={__name:"MacroRecorder",setup(s){const e=I();return(t,n)=>(d(),f("div",Tt,[a("div",Ut,[r(It),a("div",{class:C(`recorder-interface__container ${i(e).state.record&&"record"} ${i(e).state.edit&&"edit"}`)},[r(Be),r(Ue)],2),r(Bt)])]))}},qt={id:"macros",class:"panel"},Gt={class:"panel__content !p-0 !overflow-hidden"},Jt={class:"macro-panel__content"},Yt={__name:"MacrosView",setup(s){return(e,t)=>(d(),f("div",qt,[t[0]||(t[0]=a("h1",{class:"panel__title"},"Macros",-1)),a("div",Gt,[a("div",Jt,[r(Ve),r(Ht)])])]))}},os=j(Yt,[["__scopeId","data-v-fc7e8117"]]);export{os as default};
|
|
//# sourceMappingURL=MacrosView-CE74eyGa.js.map
|