She spent a long time choosing a hat.

Literal

She [topic-は] long-time spending hat [object-を] chose.

長時間かけて means 'spending a long time' — かける marks the expenditure of time. 帽子を選んだ means 'chose a hat.'