She took a long time choosing a hat.

Literal

She [topic-は] long time [object-をかけて] hat [object-を] chose.

時間をかけて ('spending time') uses かける in its 'to spend/invest' sense — here investing time into the selection process. 帽子を選ぶ ('to choose a hat') is the core action. The structure [time]をかけて[action] is a productive pattern for expressing how long something took.