var __defProp = Object.defineProperty;
var __defProps = Object.defineProperties;
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
  for (var prop in b || (b = {}))
    if (__hasOwnProp.call(b, prop))
      __defNormalProp(a, prop, b[prop]);
  if (__getOwnPropSymbols)
    for (var prop of __getOwnPropSymbols(b)) {
      if (__propIsEnum.call(b, prop))
        __defNormalProp(a, prop, b[prop]);
    }
  return a;
};
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
import { E as ElementModel, h as hexaToRgba } from "./background.js";
import { i as inherit, P as Promise$1, B as BaseElement } from "./base-element.js";
import "./watermark.js";
import "./index.js";
import "vue";
import "./v4.js";
class lineModel extends ElementModel {
  constructor(data) {
    super(data);
    this.stroke = hexaToRgba(this.stroke);
    this.fill = hexaToRgba(this.fill);
    this.height = this.strokeWidth;
  }
}
var model = lineModel;
var methods = {};
var template = `<div
    class="editor-element"
    :class="[
        'editor-element-' + model.type,
        model.lock ? 'editor-element-lock' : '',
        model.hidden ? 'editor-element-hidden' : '',
        model.frozen ? 'editor-element-frozen' : '',
        model.$loaded ? '' : 'editor-element-loading',
        model.$selected ? 'editor-element-selected' : '',
        model.$editing ? 'editor-element-editing' : ''
    ]"
    :style="[baseStyle, cssStyle]"
>
    <svg
        class="element-main"
        :width="model.width"
        :height="model.height"
        :viewBox="'0 0 ' + model.width + ' ' + model.strokeWidth"
        version="1.1"
        xmlns="http://www.w3.org/2000/svg"
    >
        <line
            :x1="shapeAttr.x1"
            :y1="shapeAttr.y1"
            :x2="shapeAttr.x2"
            :y2="shapeAttr.y2"
            :style="shapeStyle"
        />
    </svg>

    <ElementCommon
        :element="model"
        :options="options"
        :global="global"
        :editor="editor"
        :layout="editor.currentLayout"
        :hideBlink="hideBlink"
        :isShowBlink="isShowBlink"
        :bgNinePatch="bgNinePatch"
    />
</div>
`;
var lineElement = inherit(BaseElement, {
  name: "line-element",
  template,
  data() {
    return {};
  },
  computed: {
    cssStyle() {
      const { model: model2, global } = this;
      return {
        height: Math.max(1, model2.strokeWidth * global.zoom) + "px"
      };
    },
    shapeAttr() {
      const { model: model2, shapeStyle } = this;
      let x1 = 0;
      let x2 = model2.width;
      if (shapeStyle.strokeLinecap === "round") {
        x1 = model2.strokeWidth / 2;
        x2 = model2.width - model2.strokeWidth / 2;
      }
      return {
        x1,
        x2,
        y1: model2.strokeWidth / 2,
        y2: model2.strokeWidth / 2
      };
    },
    shapeStyle() {
      const { model: model2 } = this;
      const strokeLineStyle = {};
      if (model2.strokeLineStyle === "dashed") {
        strokeLineStyle.strokeDasharray = `${model2.strokeWidth * 2} ${model2.strokeWidth}`;
        if (model2.strokeDasharray.length) {
          strokeLineStyle.strokeDasharray = model2.strokeDasharray.map((val) => val * model2.strokeWidth).join(" ");
        }
      } else if (model2.strokeLineStyle === "dotted") {
        strokeLineStyle.strokeLinecap = "round";
        strokeLineStyle.strokeDasharray = `0 ${model2.strokeWidth * 2}`;
        if (model2.strokeDasharray.length) {
          strokeLineStyle.strokeDasharray = model2.strokeDasharray.map((val, i) => {
            if (i % 2 === 0) {
              return val * model2.strokeWidth - model2.strokeWidth;
            }
            return val * model2.strokeWidth * 2;
          }).join(" ");
        }
      } else {
        strokeLineStyle.strokeLinecap = "round";
      }
      return __spreadProps(__spreadValues({}, strokeLineStyle), {
        stroke: model2.stroke,
        strokeWidth: model2.strokeWidth,
        fill: "none"
      });
    }
  },
  methods: {
    load() {
      return Promise$1.resolve();
    }
  },
  mounted() {
    this.model.$getResizeLimit = () => ({
      maxWidth: Infinity,
      minWidth: this.model.strokeWidth * this.editor.zoom,
      maxHeight: Infinity,
      minHeight: this.model.strokeWidth * this.editor.zoom
    });
  }
});
var index = {
  model,
  methods,
  layoutComponent: lineElement
};
export { index as default };
