"use strict";

const idlUtils = require("../generated/utils");
var plugins = {
	"0": {
		"0": {
			"description": "Portable Document Format",
			"suffixes": "pdf",
			"type": "application/pdf",
			"enabledPlugin": []
		},
		"1": {
			"description": "Portable Document Format",
			"suffixes": "pdf",
			"type": "text/pdf",
			"enabledPlugin": []
		},
		"application/pdf": {
			"description": "Portable Document Format",
			"suffixes": "pdf",
			"type": "application/pdf",
			"enabledPlugin": []
		},
		"text/pdf": {
			"description": "Portable Document Format",
			"suffixes": "pdf",
			"type": "text/pdf",
			"enabledPlugin": []
		},
		"description": "Portable Document Format",
		"filename": "internal-pdf-viewer",
		"length": 2,
		"name": "PDF Viewer"
	},
	"1": {
		"0": {
			"description": "Portable Document Format",
			"suffixes": "pdf",
			"type": "application/pdf",
			"enabledPlugin": []
		},
		"1": {
			"description": "Portable Document Format",
			"suffixes": "pdf",
			"type": "text/pdf",
			"enabledPlugin": []
		},
		"application/pdf": {
			"description": "Portable Document Format",
			"suffixes": "pdf",
			"type": "application/pdf",
			"enabledPlugin": []
		},
		"text/pdf": {
			"description": "Portable Document Format",
			"suffixes": "pdf",
			"type": "text/pdf",
			"enabledPlugin": []
		},
		"description": "Portable Document Format",
		"filename": "internal-pdf-viewer",
		"length": 2,
		"name": "Chrome PDF Viewer"
	},
	"2": {
		"0": {
			"description": "Portable Document Format",
			"suffixes": "pdf",
			"type": "application/pdf",
			"enabledPlugin": []
		},
		"1": {
			"description": "Portable Document Format",
			"suffixes": "pdf",
			"type": "text/pdf",
			"enabledPlugin": []
		},
		"application/pdf": {
			"description": "Portable Document Format",
			"suffixes": "pdf",
			"type": "application/pdf",
			"enabledPlugin": []
		},
		"text/pdf": {
			"description": "Portable Document Format",
			"suffixes": "pdf",
			"type": "text/pdf",
			"enabledPlugin": []
		},
		"description": "Portable Document Format",
		"filename": "internal-pdf-viewer",
		"length": 2,
		"name": "Chromium PDF Viewer"
	},
	"3": {
		"0": {
			"description": "Portable Document Format",
			"suffixes": "pdf",
			"type": "application/pdf",
			"enabledPlugin": []
		},
		"1": {
			"description": "Portable Document Format",
			"suffixes": "pdf",
			"type": "text/pdf",
			"enabledPlugin": []
		},
		"application/pdf": {
			"description": "Portable Document Format",
			"suffixes": "pdf",
			"type": "application/pdf",
			"enabledPlugin": []
		},
		"text/pdf": {
			"description": "Portable Document Format",
			"suffixes": "pdf",
			"type": "text/pdf",
			"enabledPlugin": []
		},
		"description": "Portable Document Format",
		"filename": "internal-pdf-viewer",
		"length": 2,
		"name": "Microsoft Edge PDF Viewer"
	},
	"4": {
		"0": {
			"description": "Portable Document Format",
			"suffixes": "pdf",
			"type": "application/pdf",
			"enabledPlugin": []
		},
		"1": {
			"description": "Portable Document Format",
			"suffixes": "pdf",
			"type": "text/pdf",
			"enabledPlugin": []
		},
		"application/pdf": {
			"description": "Portable Document Format",
			"suffixes": "pdf",
			"type": "application/pdf",
			"enabledPlugin": []
		},
		"text/pdf": {
			"description": "Portable Document Format",
			"suffixes": "pdf",
			"type": "text/pdf",
			"enabledPlugin": []
		},
		"description": "Portable Document Format",
		"filename": "internal-pdf-viewer",
		"length": 2,
		"name": "WebKit built-in PDF"
	}
}
let proxy = function (tt, name) {
    return new Proxy(tt, {
        get(target, p, receiver) {
            let res = Reflect.get(target, p, receiver);
            console.log(`${name} get`, p, typeof res)

            return res;
        }
    })
}
exports.implementation = class PluginArray {
    refresh() {
    }

    get length() {
        return 5;
    }

    item() {
        console.log('getPlugin idx', arguments[0])
        return proxy( plugins[arguments[0]], 'plugins.'+arguments[0])
        // switch (arguments[0]){
        //   case 2:
        //     return {
        //       description:"Portable Document Format",
        //       filename:"internal-pdf-viewer",
        //       length:2,
        //       name:"Chromium PDF Viewer"
        //     }
        //   case 0:
        //     return {
        //       description:"Portable Document Format",
        //       filename:"internal-pdf-viewer",
        //       length:2,
        //       name:"PDF Viewer"
        //     }
        //   default:
        //     return {
        //       description:"Portable Document Format",
        //       filename:"internal-pdf-viewer",
        //       length:2,
        //       name:"PDF Viewer"
        //     }
        // }
        // return null;
    }

    namedItem() {
        console.log('namedItem', arguments)
        return null;
    }

    get [idlUtils.supportedPropertyIndices]() {
        return [];
    }
};
