First, we are going to create the scoreboard to work as a timer.
scoreboard objectives add mine_reset dummy
You can display the time of this scoreboard using the following command:
scoreboard objectives setdisplay sidebar mine_reset
Place a Repeat command block set to Always Active, and a Chain command block connected to it and facing the same direction as the Repeat command block.
Put this command in the Repeat command block to add 1 point every Minecraft tick:
scoreboard players add temporizador mine_reset 1
Every 20 ticks = 1 second, 40 = 2 seconds, and so on...
Now, in the Chain command block, put this command to detect when we reach a time of 10 seconds or more:
execute if score temporizador mine_reset matches 200..
After that, place a comparator and any other command blocks you want to run in front of the comparator.
The video at the end of the page shows what to do, so check it out if you need a better understanding.
In this case, I will place 3 Impulse command blocks side by side and use the following commands in each one:
execute as @a run execute if entity @a[x=58,y=22,z=-646,dx=3,dy=5,dz=3] run tp @s 65 22 -646
fill 56 26 -648 60 22 -644 iron_ore
scoreboard players set temporizador mine_reset 0
In short, we will detect if a player is inside the mine using the first command, and if someone is there, that player will be teleported to the top of the mine. (dx -> Extra detection distance on the X axis, same logic applies to Y and Z)
At the same time, the mine will be rebuilt using the fill command.
And our scoreboard, responsible for the cooldown to rebuild the mine, will be reset.
By following all these steps, we create a loop.