"use strict";
const common_vendor = require("../../common/vendor.js");
const tongji_utils_svgDataUrl = require("../utils/svgDataUrl.js");
const tongji_utils_treeLevels = require("../utils/treeLevels.js");
const _sfc_main = {
__name: "SugarTreeGraphic",
props: {
level: { type: Number, default: 0 },
size: { type: String, default: "md" },
watering: { type: Boolean, default: false }
},
setup(__props) {
const MAX_LEVEL = tongji_utils_treeLevels.TREE_MAX_LEVEL;
const treeUseFallback = common_vendor.ref(true);
const props = __props;
const clampedLevel = common_vendor.computed(() => Math.min(MAX_LEVEL, Math.max(0, Number(props.level) || 0)));
const visualTier = common_vendor.computed(() => {
const lv = clampedLevel.value;
if (lv <= 0)
return 0;
if (lv <= 2)
return 1;
if (lv <= 4)
return 2;
if (lv <= 6)
return 3;
if (lv <= 8)
return 4;
return 5;
});
const treeEmoji = common_vendor.computed(() => (tongji_utils_treeLevels.TREE_LEVELS[clampedLevel.value] || tongji_utils_treeLevels.TREE_LEVELS[0]).emoji);
function buildTreeSvg(level) {
const pot = `
`;
const soil = ``;
if (level <= 0) {
return ``;
}
const trunkH = level >= 6 ? 16 : level >= 3 ? 14 : 10;
const trunkY = 46 - trunkH;
const trunk = `
`;
const leaf = (cx, cy, r, fill, opacity = 1) => `
`;
const bloom = level >= 7 ? leaf(17, 18, 3, "#fda4af", 0.95) + leaf(31, 17, 2.8, "#f9a8d4", 0.9) + leaf(24, 13, 3.2, "#fb7185", 0.95) + `` : "";
const crown = level >= 9 ? leaf(12, 22, 6, "#34d399", 0.9) + leaf(36, 22, 6, "#34d399", 0.9) + leaf(24, 10, 7, "#386641", 0.95) + bloom : bloom;
let canopy = "";
if (level === 1) {
canopy = leaf(24, 38, 4, "#afe2b3") + ``;
} else if (level === 2) {
canopy = leaf(24, 32, 5.5, "#34d399") + leaf(20, 34, 3.5, "#6ee7b7", 0.9);
} else if (level <= 4) {
canopy = leaf(24, 28, 7, "#34d399") + leaf(17, 30, 5, "#6ee7b7", 0.9) + leaf(31, 30, 5, "#6ee7b7", 0.9);
} else if (level <= 6) {
canopy = leaf(24, 24, 9, "#22c55e") + leaf(14, 26, 7, "#4ade80", 0.92) + leaf(34, 26, 7, "#4ade80", 0.92) + leaf(24, 16, 6, "#386641", 0.88);
} else {
canopy = leaf(24, 20, 10, "#204e2b") + leaf(13, 24, 8, "#34d399", 0.95) + leaf(35, 24, 8, "#34d399", 0.95) + crown;
}
return ``;
}
const treeImageSrc = common_vendor.computed(() => tongji_utils_svgDataUrl.svgToDataUrl(buildTreeSvg(clampedLevel.value)));
return (_ctx, _cache) => {
return common_vendor.e({
a: clampedLevel.value >= 7
}, clampedLevel.value >= 7 ? {} : {}, {
b: !treeUseFallback.value
}, !treeUseFallback.value ? {
c: treeImageSrc.value,
d: common_vendor.o(($event) => treeUseFallback.value = true, "20")
} : {
e: common_vendor.t(treeEmoji.value)
}, {
f: clampedLevel.value >= 7
}, clampedLevel.value >= 7 ? {} : {}, {
g: clampedLevel.value >= 8
}, clampedLevel.value >= 8 ? {} : {}, {
h: clampedLevel.value >= common_vendor.unref(MAX_LEVEL)
}, clampedLevel.value >= common_vendor.unref(MAX_LEVEL) ? {} : {}, {
i: common_vendor.n(`lv-${clampedLevel.value}`),
j: common_vendor.n(`tier-${visualTier.value}`),
k: common_vendor.n(`size-${__props.size}`),
l: common_vendor.n({
watering: __props.watering,
"is-max": clampedLevel.value >= common_vendor.unref(MAX_LEVEL)
})
});
};
}
};
const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-d91cb5e7"]]);
wx.createComponent(Component);
//# sourceMappingURL=../../../.sourcemap/mp-weixin/tongji/components/SugarTreeGraphic.js.map