LOS ANGELES (AP) — The nation’s largest legal marijuana market opened for business in January with jubilation and long lines of customers.

As the year ends, California’s pot economy remains a work in progress.

Consumers can buy legal buds from San Diego to San Francisco, and thousands of growers have state licenses.

But the market is dogged by thousands of illegal operators that undercut legal shops.

Because of rules that vary from city to city, whether you can buy marijuana products depends on where you are.

State regulators get credit for beginning the massive job of transforming the longstanding illegal and medicinal marijuana markets into a unified, multibillion-dollar industry. But the results have been mixed.

Some companies are doing well, but many others are not.

And some already are casualties.