"use strict";
let fs = require("fs");
let path = require("path");
const EditorAPI = require('./src/main/editor-api');

module.exports = {
	/**
	 * 獲取場景節點下的配置信息
	 * @param event event
	 * @param data 這邊把panel的Node帶進來
	 */
	"replaceResource": function (event, request) {
		let self = this;
		var response = null;
		var args = request.args;
		try {
			let uuid1 = args[0];
			let uuid2 = args[1];
			let uuid3 = args[2];
			let path = Editor.assetdb.uuidToUrl(uuid3);
			// let assetInfo = EditorAPI.assetInfoByUuid(uuid1);
			Editor.log(`path: ${path}`);
			// Editor.log(`node: ${JSON.stringify(assetInfo)}`);
			// let Version_path = Version_assetInfo.path;
			// Editor.log("Version_path: " + Version_path);
			// let Version = fs.readFileSync(Version_path, "utf8"); // 讀取檔案
			// Editor.log(`uuid3: ${uuid3}`);
			// Editor.assetdb.queryInfoByUuid(uuid1, function (err, info) {
			// 	Editor.log(`path: ${info.path}`);
			// 	Editor.log(`url: ${info.url}`);
			// 	Editor.log(`type: ${info.type}`);
			// 	// Editor.assetdb.queryAssets(info.url, info.type, function (err, info) {
			// 	// 	Editor.log(`info: ${JSON.stringify(info)}`);
			// 	// });
			// });

			// Editor.Selection.select('asset', uuid1);
			// Editor.Selection.clear('node')
			// let nodeUuids = Editor.Selection.curSelection("node");
			// Editor.Ipc.sendToPanel("scene", "scene:create-nodes-by-uuids", [uuid1], nodeUuids, { unlinkPrefab: null })
			// Editor.Selection.select('node', uuid1)
			// nodeUuids = Editor.Selection.curSelection("node");

			// let source = cc.find("SlotPaytable_66");
			// // 修改运行中的节点属性:
			// Editor.Ipc.sendToPanel('scene', 'scene:set-property', {
			// 	id: uuid1,
			// 	path: "name",//要修改的属性
			// 	type: "String",
			// 	value: "8787",
			// 	isSubProp: false,
			// });
			// Editor.log(`node: ${JSON.stringify(source)}`);
			// Editor.log(`node: ${source}`);

			// response = JSON.stringify(res);
		} catch (error) {
			Editor.error(`replaceResource error: ${error}`);
		}
		response = "666";
		if (event.reply) {
			event.reply(null, response);
		}
	},
};