SACRAMENTO, Calif. (AP) — The future of California’s legal marijuana industry is being shaped in a warren of cubicles tucked inside a retired basketball arena, where a garden of paper cannabis leaves sprouts on file cabinets and a burlap sack advertising “USA Home Grown” dangles from a wall.

Here, in the outskirts of Sacramento, a handful of government workers face a daunting task: By next year, craft regulations and rules that will govern the state’s emerging legal pot market, from where and how plants can be grown to setting guidelines to track the buds from fields to stores.

Getting it wrong could mean the robust cannabis black market stays that way – outside the law – undercutting the attempt to create the nation’s largest legal marijuana economy. The new industry has a projected value of $7 billion, and state and local governments could eventually collect $1 billion a year in taxes.

California is “building the airplane while it’s being flown,” lamented state Sen. Mike McGuire, a Democrat whose sprawling Northern California district includes some of the world’s most prized pot fields.

He questions if the state can meet January deadlines to create a coherent system that accounts for the loosely regulated medical marijuana industry, now two decades old and developing its own rules, while transforming the enormous illegal market into a legal, licensed one.

“It’s going to take us 10 years to dig out of the mess we are in,” predicted McGuire, referring to the unruly market, legal and not.

It’s likely that tens of thousands of people and businesses will need licensing. The job of overseeing the industry touches on issues from protecting water quality for fish in streams near pot grows, to safely collecting hundreds of millions of dollars in taxes from businesses that often operate in cash.

Inside the former arena, Lori Ajax, the state’s top pot regulator, acknowledged the challenges but said the state can, indeed must, be ready on Jan. 1 when California is required to issue licenses.

“We’re small but mighty,” she said of her staff of 11 full-time workers spearheading the project.

The new law calls for nearly 20 different types of licenses, including permits for farmers; delivery services that will take pot to a buyer’s front door; testing labs; distributors; and dispensary operators at the retail level.

Part of the job heading toward the start of next year falls to other agencies, including the Food and Agriculture Department, which will issue licenses for cultivators.

In November, California joined a growing number of states in legalizing recreational marijuana use for adults. In general, the state will treat cannabis like alcohol, allowing people 21 and older to legally possess up to an ounce of pot and grow six marijuana plants at home.