import { useRef, useEvent, h } from 'atomico';
import 'funfix';
import { g as getComponentOrDefine } from './chunks/65ef80fe.js';
import './kun-icon.js';
import '@caedman/kit/dist/use-stylesheet';
import 'lazyload-image';
import './kun-image.js';
import { m as mockStyle } from './chunks/b7110801.js';
import { e as execWithSixLoad } from './chunks/19492529.js';
import { r as requestUploadFile1 } from './chunks/237ddcfd.js';

const _jsxFileName = "/Users/rang/rang/frond_ng/packages/six/src/components/kun-image-upload/kun-image-upload.tsx";
const Comp = () => {
  const refLabel = useRef();
  const updateImg = useEvent("MyChange", {
    composed: true,
    bubbles: true,
  });

  const updateImageFile = async (event) => {
    console.log("upload image");
    await execWithSixLoad(async () => {
      const file = event.target.files[0];
      const formData = new FormData();
      formData.set("file", file);
      const r = await requestUploadFile1(formData);
      updateImg({
        url: r.msg,
      });
    });
  };

  const clk = () => {
    console.log("clik");
    refLabel.current.click();
  };

  return (
    h('host', {__self: undefined, __source: {fileName: _jsxFileName, lineNumber: 37}}
      , h('style', {__self: undefined, __source: {fileName: _jsxFileName, lineNumber: 38}}, mockStyle)
      , h('div', { class: "flex flex-row" , __self: undefined, __source: {fileName: _jsxFileName, lineNumber: 39}}
        , h('kun-icon', { iconType: "tupian", iconWidth: 18, iconHeight: 18, onclick: clk, __self: undefined, __source: {fileName: _jsxFileName, lineNumber: 40}} )
        , h('div', {
          className: "none display-none hidden ml-4 cursor-pointer rounded-lg flex leading-normal bg-orange-400 text-white h-8 px-8 items-center"            , __self: undefined, __source: {fileName: _jsxFileName, lineNumber: 41}}
        , "图片"

        )
        , h('input', {
          type: "file",
          className: "none display-none hidden"  ,
          ref: refLabel,
          id: "asd",
          onchange: (evt) => updateImageFile(evt),
          ignore: true, __self: undefined, __source: {fileName: _jsxFileName, lineNumber: 46}}
        )
      )
    )
  );
};

Comp.props = {
};

var kunImageUpload = getComponentOrDefine("kun-image-upload", Comp);

export default kunImageUpload;
