var D=Object.defineProperty;var x=Object.getOwnPropertySymbols;var O=Object.prototype.hasOwnProperty,V=Object.prototype.propertyIsEnumerable;var C=(o,e,a)=>e in o?D(o,e,{enumerable:!0,configurable:!0,writable:!0,value:a}):o[e]=a,E=(o,e)=>{for(var a in e||(e={}))O.call(e,a)&&C(o,a,e[a]);if(x)for(var a of x(e))V.call(e,a)&&C(o,a,e[a]);return o};var h=(o,e,a)=>new Promise((s,i)=>{var t=l=>{try{r(a.next(l))}catch(m){i(m)}},n=l=>{try{r(a.throw(l))}catch(m){i(m)}},r=l=>l.done?s(l.value):Promise.resolve(l.value).then(t,n);r((a=a.apply(o,e)).next())});import{d as _,f as w,w as S,n as B,h as M,u as F,o as N,b as P,a2 as y,a3 as k,e as A,k as p,U as f,ad as G,af as d,G as g}from"./vue-vendor-CxLCUzY4.js";import{z as J,v as T,P as U,w as $,_ as W}from"./index-CLZzJyTP.js";import{useWindowSizeFn as z}from"./useWindowSizeFn-D9PllI8g.js";import{a as I,C as H}from"./htmlmixed-DoVLO6sG.js";/* empty css             */import{a as de,M as q,a8 as K,R as b}from"./antd-vue-vendor-CahNzUUa.js";import{P as X}from"./index-D55rh6hR.js";import"./vxe-table-vendor-Cdi8WfTx.js";import"./useContentHeight-DLfJuPsF.js";import"./useContentViewHeight-BIb_dTbE.js";import"./usePageContext-FyDvfV_K.js";import"./injectionKey-DPVn4AgL.js";var we=I();const Y=_({__name:"CodeMirror",props:{mode:{type:String,default:"application/json"},value:{type:String,default:""},readonly:{type:Boolean,default:!1}},emits:["change"],setup(o,{emit:e}){const a=o,s=e,i=w();let t;const n=T(m,100),r=J();S(()=>a.value,u=>h(this,null,function*(){yield B();const c=t==null?void 0:t.getValue();u!==c&&(t==null||t.setValue(u||""))}),{flush:"post"}),M(()=>{t==null||t.setOption("mode",a.mode)}),S(()=>r.getDarkMode,()=>h(this,null,function*(){l()}),{immediate:!0});function l(){var u;(u=F(t))==null||u.setOption("theme",r.getDarkMode==="light"?"idea":"material-palenight")}function m(){t==null||t.refresh()}function v(){return h(this,null,function*(){const u={autoCloseBrackets:!0,autoCloseTags:!0,foldGutter:!0,gutters:["CodeMirror-linenumbers"]};t=H(i.value,E({value:"",mode:a.mode,readOnly:a.readonly,tabSize:2,theme:"material-palenight",lineWrapping:!0,lineNumbers:!0},u)),t==null||t.setValue(a.value),l(),t==null||t.on("change",()=>{s("change",t==null?void 0:t.getValue())})})}return N(()=>h(this,null,function*(){yield B(),v(),z(n)})),P(()=>{t=null}),(u,c)=>(y(),k("div",{class:"relative !h-full w-full overflow-hidden",ref_key:"el",ref:i},null,512))}}),L={class:"h-full"},R={JSON:"application/json",html:"htmlmixed",js:"javascript"},Q=_({__name:"CodeEditor",props:{value:{type:[Object,String]},mode:{type:String,default:R.JSON},readonly:{type:Boolean},autoFormat:{type:Boolean,default:!0}},emits:["change","update:value","format-error"],setup(o,{emit:e}){const a=o,s=e,i=A(()=>{const{value:n,mode:r,autoFormat:l}=a;if(!l||r!==R.JSON)return n;let m=n;if(U(n))try{m=JSON.parse(n)}catch(v){return s("format-error",n),n}return JSON.stringify(m,null,2)});function t(n){s("update:value",n),s("change",n)}return(n,r)=>(y(),k("div",L,[p(Y,{value:i.value,onChange:t,mode:o.mode,readonly:o.readonly},null,8,["value","mode","readonly"])]))}}),Z=$(Q),j='{"name":"BeJson","url":"http://www.xxx.com","page":88,"isNonProfit":true,"address":{"street":"科技园路.","city":"江苏苏州","country":"中国"},"links":[{"name":"Google","url":"http://www.xxx.com"},{"name":"Baidu","url":"http://www.xxx.com"},{"name":"SoSo","url":"http://www.xxx.com"}]}',ee=`
      (() => {
        var htmlRoot = document.getElementById('htmlRoot');
        var theme = window.localStorage.getItem('__APP__DARK__MODE__');
        if (htmlRoot && theme) {
          htmlRoot.setAttribute('data-theme', theme);
          theme = htmlRoot = null;
        }
      })();
  `,te=`
     <!DOCTYPE html>
<html lang="en" id="htmlRoot">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    <meta name="renderer" content="webkit" />
    <meta
      name="viewport"
      content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=0"
    />
    <title><%= title %></title>
    <link rel="icon" href="/favicon.ico" />
  </head>
  <body>
    <div id="app">
    </div>
  </body>
</html>
  `,ae=_({components:{CodeEditor:Z,PageWrapper:X,RadioButton:b.Button,RadioGroup:b.Group,ASpace:K},setup(){const o=w("application/json"),e=w(j);function a(i){const t=i.target.value;if(t==="application/json"){e.value=j;return}if(t==="htmlmixed"){e.value=te;return}if(t==="javascript"){e.value=ee;return}}function s(){q.info({title:"编辑器当前值",content:e.value})}return{value:e,modeValue:o,handleModeChange:a,showData:s}}});function oe(o,e,a,s,i,t){const n=f("a-button"),r=f("RadioButton"),l=f("RadioGroup"),m=f("a-space"),v=f("CodeEditor"),u=f("PageWrapper");return y(),G(u,{title:"代码编辑器组件示例",contentFullHeight:"",fixedHeight:"",contentBackground:""},{extra:d(()=>[p(m,{size:"middle"},{default:d(()=>[p(n,{onClick:o.showData,type:"primary"},{default:d(()=>e[2]||(e[2]=[g("获取数据")])),_:1},8,["onClick"]),p(l,{"button-style":"solid",value:o.modeValue,"onUpdate:value":e[0]||(e[0]=c=>o.modeValue=c),onChange:o.handleModeChange},{default:d(()=>[p(r,{value:"application/json"},{default:d(()=>e[3]||(e[3]=[g(" json数据 ")])),_:1}),p(r,{value:"htmlmixed"},{default:d(()=>e[4]||(e[4]=[g(" html代码 ")])),_:1}),p(r,{value:"javascript"},{default:d(()=>e[5]||(e[5]=[g(" javascript代码 ")])),_:1})]),_:1},8,["value","onChange"])]),_:1})]),default:d(()=>[p(v,{value:o.value,"onUpdate:value":e[1]||(e[1]=c=>o.value=c),mode:o.modeValue},null,8,["value","mode"])]),_:1})}const _e=W(ae,[["render",oe]]);export{_e as default};
