import{b as S,g as M,i as l,u as i,j as p,q as r,l as C,W as B,p as d,G as D,F as T,J as I,D as u,a as N,x as V}from"./vue-Cm77DuTi.js";import{I as $,a as m}from"./parser-DaoUb5SB.js";import{P as q}from"./index-BT0jOPXg.js";import{u as E}from"./widget-jbnupkVY.js";import{b as F,$ as H,o as U,q as g,_ as W}from"./app-QjDgb7aF.js";import{M as j}from"./MkContainer-CNBcUt5w.js";import{c as z}from"./api-D2oYCc9G.js";import"./charts-3gEHPHRq.js";import"./media-DuCIZ-3n.js";const A={class:"uylguesu _monospace"},G={class:"logs"},h="aiscript",J=S({__name:"aiscript",props:{widget:{}},emits:["updateProps"],setup(w,{expose:f,emit:x}){const _={showHeader:{type:"boolean",default:!0},script:{type:"string",multiline:!0,default:"(1 + 1)",hidden:!0}},o=w,y=x,{widgetProps:s,configure:v}=E(h,_,o,y),a=N([]),k=new q,b=async()=>{a.value=[];const c=new $(z({storageKey:"widget",token:H?.token}),{in:t=>new Promise(n=>{U({title:t}).then(({canceled:K,result:P})=>{n(P)})}),out:t=>{a.value.push({id:Math.random().toString(),text:t.type==="str"?t.value:m(t),print:!0})},log:(t,n)=>{t==="end"&&a.value.push({id:Math.random().toString(),text:m(n.val,!0),print:!1})}});let e;try{e=k.parse(s.script)}catch(t){g({type:"error",text:`Syntax error : ${t}`});return}try{await c.exec(e)}catch(t){g({type:"error",text:String(t)})}};return f({name:h,configure:v,id:o.widget?o.widget.id:null}),(c,e)=>(p(),M(j,{"show-header":i(s).showHeader,class:"mkw-aiscript"},{header:l(()=>[e[1]||(e[1]=r("i",{class:"ph-terminal-window ph-bold ph-lg"},null,-1)),I(u(i(F).ts._widgets.aiscript),1)]),default:l(()=>[r("div",A,[C(r("textarea",{"onUpdate:modelValue":e[0]||(e[0]=t=>i(s).script=t),placeholder:"(1 + 1)"},null,512),[[B,i(s).script]]),r("button",{class:"_buttonPrimary",onClick:b},"RUN"),r("div",G,[(p(!0),d(T,null,D(a.value,t=>(p(),d("div",{key:t.id,class:V(["log",{print:t.print}])},u(t.text),3))),128))])])]),_:1},8,["show-header"]))}}),rt=W(J,[["__scopeId","data-v-9adcbf97"]]);export{rt as default};
//# sourceMappingURL=aiscript-8X1WBqD5.js.map
