"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
    var ownKeys = function(o) {
        ownKeys = Object.getOwnPropertyNames || function (o) {
            var ar = [];
            for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
            return ar;
        };
        return ownKeys(o);
    };
    return function (mod) {
        if (mod && mod.__esModule) return mod;
        var result = {};
        if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
        __setModuleDefault(result, mod);
        return result;
    };
})();
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const node_test_1 = __importDefault(require("node:test"));
const strict_1 = __importDefault(require("node:assert/strict"));
const THREE = __importStar(require("three"));
const src_1 = require("../src");
(0, node_test_1.default)('assertValidVoxBuffer rejects invalid magic', () => {
    strict_1.default.throws(() => (0, src_1.assertValidVoxBuffer)(new Uint8Array([0, 1, 2, 3, 150, 0, 0, 0])), /vox_header_invalid/);
});
(0, node_test_1.default)('convertVoxChunksToBoxel creates voxel primitive and palette', () => {
    const chunk = {
        palette: [0, 0xff0000ff, 0xff00ff00],
        size: { x: 2, y: 1, z: 1 },
        data: new Uint8Array([
            0, 0, 0, 1,
            1, 0, 0, 2,
        ]),
    };
    const boxel = (0, src_1.convertVoxChunksToBoxel)([chunk], 'sample_vox');
    strict_1.default.equal(boxel.id, 'sample_vox');
    strict_1.default.equal(boxel.materials.length, 2);
    strict_1.default.equal(boxel.primitives.length, 1);
    const primitive = boxel.primitives[0];
    strict_1.default.equal(primitive.kind, 'voxel_box');
    if (primitive.kind !== 'voxel_box') {
        throw new Error('expected voxel_box primitive');
    }
    strict_1.default.deepEqual(primitive.size, [2, 1, 1]);
    strict_1.default.deepEqual(primitive.voxels, [1, 2]);
});
(0, node_test_1.default)('buildVoxGroupFromChunks uses the provided Three runtime for materials', () => {
    const chunk = {
        palette: [0, 0xff0000ff],
        size: { x: 1, y: 1, z: 1 },
        data: new Uint8Array([0, 0, 0, 1]),
    };
    const group = (0, src_1.buildVoxGroupFromChunks)([chunk], THREE);
    strict_1.default.equal(group.children.length, 1);
    const mesh = group.children[0];
    strict_1.default.equal(mesh.material instanceof THREE.MeshStandardMaterial, true);
    strict_1.default.equal(mesh.material.vertexColors, true);
});
(0, node_test_1.default)('extractVoxChunks accepts the current three.js loader result shape', () => {
    const chunk = {
        palette: [0, 0xff0000ff],
        size: { x: 1, y: 1, z: 1 },
        data: new Uint8Array([0, 0, 0, 1]),
    };
    strict_1.default.deepEqual((0, src_1.extractVoxChunks)({ chunks: [chunk], scene: null }), [chunk]);
});
(0, node_test_1.default)('extractVoxChunks still accepts a direct chunk array', () => {
    const chunk = {
        palette: [0, 0xff0000ff],
        size: { x: 1, y: 1, z: 1 },
        data: new Uint8Array([0, 0, 0, 1]),
    };
    strict_1.default.deepEqual((0, src_1.extractVoxChunks)([chunk]), [chunk]);
});
//# sourceMappingURL=vox.test.js.map