(a) The detention hearing for a status offender or nonoffender who has not been released administratively under Section 53.02 shall be held before the 24th hour after the time the child arrived at a detention facility, excluding hours of a weekend or a holiday. Except as otherwise provided by this section, the judge or referee conducting the detention hearing shall release the status offender or nonoffender from secure detention.
(b) The judge or referee may order a child in detention accused of the violation of a valid court order as defined by Section 51.02 detained not longer than 72 hours after the time the detention order was entered, excluding weekends and holidays, if: