Please anyone correct me if I am wrong, there is no overlaying of clientlibs.
Clientlibs are registered globally via a 'Category Name'. Category are then called on to be placed into a page.
If you create a custom javascript, and add it to a category that already exists, say 'cq.authoring.dialog' then when that clientlib is called, that code gets called as well. If you create a file that already exists in the clientlib, it doesn't replace that file during clientlib resolution, it just gets stacked onto it.
There is a tool that might help explain this concept:
http://localhost:4502/libs/granite/ui/content/dumplibs.html
The hard part about a single category that are being created from multiple areas, is the script resolution order.
Another link that might help, as I believe they go into validation inside of AEM dialogs, is this AEM Gem of Customizing Dialogs:
https://docs.adobe.com/ddc/en/gems/customizing-dialog-fields-in-touch-ui.html
You can just extending the clientlib, and this is performed just putting in your clientlib the same categories of foundation clientlib.
~kautuk
Kautuk Sahni