import{I as _}from"./parser-RGrRIRgY.js";import{P as h}from"./index-eSfribeX.js";import{c as k}from"./api-I791pgl2.js";import{u as b}from"./widget-qjKd4HCd.js";import{M as P,$ as v,v as B,g as i}from"./app-JmgyQoR0.js";import{b as M,h as S,t as T,l as C,j as E,K as N,E as $,z as c}from"./vue-y3KLWBaS.js";const D={class:"mkw-button"},p="button",U=M({__name:"button",props:{widget:{}},emits:["updateProps"],setup(l,{expose:u,emit:m}){const d={label:{type:"string",default:"BUTTON"},colored:{type:"boolean",default:!0},script:{type:"string",multiline:!0,default:'Mk:dialog("hello" "world")'}},e=l,f=m,{widgetProps:r,configure:g}=b(p,d,e,f),y=new h,w=async()=>{var s;const a=new _(k({storageKey:"widget",token:(s=v)==null?void 0:s.token}),{in:t=>new Promise(n=>{B({title:t}).then(({canceled:I,result:x})=>{n(x)})}),out:t=>{},log:(t,n)=>{}});let o;try{o=y.parse(r.script)}catch(t){i({type:"error",text:`Syntax error: ${t}`});return}try{await a.exec(o)}catch(t){i({type:"error",text:String(t)})}};return u({name:p,configure:g,id:e.widget?e.widget.id:null}),(a,o)=>(S(),T("div",D,[C(P,{primary:c(r).colored,full:"",onClick:w},{default:E(()=>[N($(c(r).label),1)]),_:1},8,["primary"])]))}});export{U as default};
