Sonny and Cher were married for over a decade and performing partners for even longer. The world initially met Cher as half of the duo, thanks to their folk-pop hit “I Got You Babe” and popular variety show The Sonny & Cher Comedy Hour. But before any of that, she was just an aimless teenager, living away from home and wanting to know more about this confident Sicilian musician she encountered in a coffee shop. In this exclusive excerpt from Cher: The Memoir, Part One, she remembers her early days with Sonny Bono.
Excerpt from ‘ Cher, The Memoir: Part One'
On a weekday night in November 1962, a Sicilian with an amazing smile joined our booth in Aldo’s coffee shop. It was directly underneath KFWB, so all the radio promotion guys would come down after meeting with the disc jockeys to hang out and have coffee.
I was sitting with a jazz promo guy named Red and my friend Melissa when there was a sudden buzz and I heard someone cry, “Hey, Sonny!” And then a bunch of people yelled, “Hey, Son, come to our table!” “Come sit with us!” Everyone was calling out to this guy. Based on all the commotion, I was expecting a tall, handsome man to walk up behind me. I turned around to look, and an intriguing stranger with a Caesar-style haircut walked toward us. He was wearing a black mohair suit, a mustard shirt with an oversized starched white collar, and a tie that matched his shirt. On his feet he wore Cuban boots with heels, the first I’d ever seen, though later the Beatles would be wearing boots just like them and calling them Beatle boots. I swear to God, it was like Maria and Tony in West Side Story: everyone else in the room faded.
To this day, I can see our Hollywood meet-cute in my mind. Grinning from ear to ear as people jumped up to say hello and shake his hand, Salvatore Phillip Bono was one of the most interesting men I’d ever seen. As he sat at our table, I noticed his beautiful hands with their long, tapered fingers and a gold chain-link ID bracelet with a watch face where the name would normally have been. Sonny definitely caught my attention. I was always interested in fascinating people because those were the kind of people I grew up around. He was the ’60s version of my mom’s friends. It wasn’t love at first sight. I just thought this guy was special.
It was immediately clear to me that everyone loved Sonny, but at the moment he was fascinated by my friend Melissa, a knockout brunette Red suggested I invite to make up a double date. The women knew each other from the promo business because they both schmoozed DJs into playing the latest releases. Easygoing with already smile, at twenty-seven, he was the youngest of three and the only boy in a Sicilian family. One of the first things he told me was that he was a descendant of Napoleon Bonaparte, but his father had shortened their name when he came to the United States. It didn’t occur to me to question how a Sicilian could be related to a Corsican, and it didn’t occur to me that he was lying. When Sonny was young, the family moved to Inglewood, a working-class suburb of L.A. After being kicked out of high school for hiring a Black band for the prom, he did every kind of job, including delivering meat and working as a masseur — until the day he spilled rubbing alcohol into the crack of a client’s ass when the bottle slipped from his fingers.
A songwriter since his teens, his first hit was “Koko Joe,” which had been inspired by having to unpack Koko Joe cookies while working in a grocery store. It did well enough for Sonny to continue writing, and he sang his own numbers as “Don Christy”(after his recently estranged wife, Donna, and his daughter Christy). That didn’t prove successful, but a couple of his songs went on to be recorded by Sam Cooke, the Righteous Brothers, Jackie DeShannon, and the duo Don and Dewey.
Saying little, I watched him chatting up Melissa like a pro and admired the way he put everyone around him at ease. What he didn’t know was that although he amused Melissa, he wasn’t her type — she was gay. Then someone suggested we go to the Red Velvet Club on Sunset and Wilcox, and I was thrilled. As soon as we arrived, I went straight onto the dance floor to lose myself in music. Sonny only joined me because neither Red nor Melissa danced.
“I love your clothes,” I told him. “Black on black. So cool.”
“I love yours too,” he said, sizing up my T-shirt and boy’s jeans. (From the time I can remember, my grandma wore 501s, my mom wore 501s, my sister wore 501s. They were cheap and indestructible and are perpetually cool.) As Sonny told me years later, he couldn’t figure me out that night. The truth is he wasn’t trying to figure me out that night, he was trying to figure Melissa out. He may have wondered if I was gay or straight after learning that Melissa was the former, but she was just a friend who let me crash on her couch rent-free. Melissa lived in a complex with a pool at Franklin and Highland. The place was filled with the most beautiful women I had seen since I’d hung out with Mom and her girlfriends. These were strippers, hookers, actresses, and showgirls, all of them with knock-out bodies. Those chicks were the whole package — great asses, long legs, and fabulous clothes.
It wasn’t long after that that Melissa told me I’d have to find someplace else to live. Her place was too small. Without any money, I had no idea where I’d go, as I couldn’t go back to Red and the last thing I wanted was to return to my mother’s. That’s when I spotted Sonny moving into the building next door. We’d only hung out that one night a few weeks before, but I was happy to see him. When he saw me waving through the window, he smiled and gestured for me to meet him. Running outside, I asked, “What are you doing here?” and he told me he’d taken a one-bedroom apartment in the building next door. I laughed at the coincidence. I didn’t know until later that the whole building was owned by a wealthy family who’d bought it in order to get their daughter to come home from working as a stripper in Las Vegas.
Over the next ten days or so, Sonny and I hung out and became friends. He liked that I was quirky and non-judgmental. I liked that he was funny and different. He was a grown-up without being too grown up, and I was a sixteen-year-old lying about my age. He took me to the park, or we’d talk in his apartment until his friends came over, at which point I’d see myself out. I neglected to tell him that I was about to get kicked out of the apartment until Melissa finally told me my time had officially run out.
Looking for a sympathetic ear, I walked over to Sonny’s and sat on his couch to tell him I had no choice but to move home. Tears sprang to my eyes at the mere thought of it. I didn’t mean to cry, but I think it made Sonny take pity on me.
“Well, Cher,” he said. “If you cook and clean the place, you could always move in with me for a while.”
In my mind I was thinking, Yeah, OK, this old line. But I must have had a look on my face because he shook his head and laughed. “Don’t worry, I’ve got twin beds,” he said. With a grin he added, “And honestly, I don’t find you particularly attractive.” I was both insulted and relieved. And that’s how I became the potty-mouthed sidekick to a man eleven years older than me who was in the middle of a divorce.
I thought Sonny was the coolest person I’d ever met. If a girl called in those days and I answered the phone, she would invariably ask him, “Who was that?” and he would say, “Oh, that’s just Cher.”
One of the girls who came to the apartment told me that she knew Sonny was cheating on her. “That’s just how he is, I suppose,” she added with a tearful sigh. The news didn’t surprise me at all. What surprised me is that she told me, a total stranger. Plus, I was just Cher. While waiting for his divorce, Sonny started seeing several women simultaneously, including one who claimed she was pregnant with his child, took his money for an abortion (along with that of two other men to whom she made the same claim), and flew to Hawaii to get her teeth fixed instead. That chick was so smart. She got a suntan and her teeth fixed all on their dime.
Almost all his relationships remained casual, because he certainly wasn’t looking for love and most of the women were looking for a man who could support them. He was charming and funny, but he had no money, drove an old Chevy Monza, and lived in a one-bedroom apartment with a random teenager. He wasn’t a catch.
Aside from keeping out of the way when his latest girlfriend was over, I became his housekeeper and general assistant, handing out beer and chips to his male friends who came to play liar’s poker while I sat in the bedroom drawing or watching TV.
It was one of those friends who one day mentioned to him, “You know, I don’t think Cher is eighteen.” It could have been Melissa who tipped him off, but who knows? When Sonny asked me if it was true, I knew I couldn’t come clean. Thinking on my feet, I came up with another lie: “Okay … I’m not eighteen now, I’m seventeen. But my birthday is in May, so I’ll be eighteen in two months.” He was a little cranky about it, but I guess I was so convincing that he believed me, even though I think a blind person would have seen the guilty look on my face. (I think whenever someone gives you an “Okay, but,” everything that follows is probably bullshit.) With that, our friendship was back on track.
I learned so much from Sonny and enjoyed how he took care of me in his macho Sicilian way. When I got sick again, he took my temperature and tucked me into bed, got what I needed from the pharmacy, and kept an eye on me in case my fever got worse. I came to feel that he was the kind of guy who’d be there if something bad happened.
'He realized I was a better dancer, and that made him feel uncomfortable.' Photo: Marcello Salustri/Mondadori/Getty ImagesPhoto: CBS/Getty ImagesPhoto: Courtesy Cher.
'He realized I was a better dancer, and that made him feel uncomfortable.' Photo: Marcello Salustri/Mondadori/Getty ImagesPhoto: CBS/Getty ImagesPhoto...'He realized I was a better dancer, and that made him feel uncomfortable.' Photo: Marcello Salustri/Mondadori/Getty ImagesPhoto: CBS/Getty ImagesPhoto: Courtesy Cher.
Before too long, I thought the sun rose and set on his Sicilian ass, even though I knew that I wasn’t his type. My kind of body wasn’t in style yet, and one day when I borrowed a bathing suit from Melissa to go to the beach, I watched Sonny’s face drop when he saw me. “My God, you’re skinny. You don’t have any shape at all! Is that all there is to you?” He was looking right at me. He knew all the answers to those questions. With no curves, I looked like a matchstick.
As the weeks passed, Sonny and I became more like a brother and sister, or perhaps more accurately a father and daughter, because I was the insecure kid full of phobias, the teenager who didn’t like silence and couldn’t get to sleep unless the television was on, which is still sometimes true. In those days, TV programming ended at midnight and the station would play “The Star-Spangled Banner” before shutting off. For some reason, one night the waving flag followed by a black screen and absolute silence gave me a panic attack and I freaked out. “What’s the matter?” Sonny asked, woken by my whimpering.
“I’m afraid, Son.”
“Go to sleep, Cher.”
“I can’t.”
“Then get over here, but just sleep, okay? Don’t bother me.” He pulled back his covers. I slid in beside him. He put the covers over me and then he rolled toward the wall. I tried to be quiet as a church mouse, just like when I was a kid at my parents’ cocktail parties. That was our first night in bed together.
Like a guru, Sonny persuaded me to read my first book from cover to cover, something I’d resisted for years because of my wonky (dyslexic) brain. It was The Saracen Blade by Frank Yerby and was set in Sicily at a time when the three religions coexisted there peacefully. Taking my time like he told me, I discovered that if I went at my own pace and a book held my interest, then I could finish it. I never knew that I could read for pleasure, and I’ll always be grateful to Son for teaching me that. Six decades later, I still remember the story and the feeling of excitement is baked in the cake. Before too long, I began to hero-worship my roommate.
Although the feeling wasn’t mutual, Sonny dug my weird sense of humor and was happy to do the things I liked because he was still a big kid inside. The women he dated wanted to be wined and dined at expensive restaurants, not taken shopping at Safeway for the promise of a pizza. Nor would they be happy to spend an afternoon painting together (he was terrible), modeling things out of clay, or heading to the park with a picnic. Having virtually raised my sister single-handedly, I was also glad to hang out with his four-year-old daughter, Christy, whenever she came to visit with his pet Yorkshire terrier, Scunci. Sonny loved that dog, and he loved Christy, who was cute as a button. She adored him too, and was always eager to please him. Sonny was a great dad.
I also found it strange that, practically from the day we met, Sonny didn’t want to go dancing anymore, even though he knew how much I loved it. He realized I was a better dancer, and that made him feel uncomfortable, but he also didn’t want me going dancing on my own either. I guess he was a little possessive, but the idea thrilled me because it meant he cared. Later I would find out that possessive and caring didn’t exactly go hand in hand.
By submitting your email, you agree to our
Terms and Privacy Notice
and to receive email correspondence from us. This site is protected by reCAPTCHA and the Google
Privacy Policy and
Terms of Service apply.
or
Already a subscriber?
What is your email?
This email will be used to sign into all New York sites. By submitting your email, you agree to our Terms and Privacy Policy and to receive email correspondence from us.
Password must be at least 8 characters and contain:
Lower case letters (a-z)
Upper case letters (A-Z)
Numbers (0-9)
Special Characters (!@#$%^&*)
This password will be used to sign into all New York sites. By submitting your email, you agree to our Terms and Privacy Policy and to receive email correspondence from us.
You’re in!
As part of your account, you’ll receive occasional updates and offers from New York, which you can opt out of anytime.
or
Already a subscriber?
What is your email?
This email will be used to sign into all New York sites. By submitting your email, you agree to our Terms and Privacy Policy and to receive email correspondence from us.
Password must be at least 8 characters and contain:
Lower case letters (a-z)
Upper case letters (A-Z)
Numbers (0-9)
Special Characters (!@#$%^&*)
This password will be used to sign into all New York sites. By submitting your email, you agree to our Terms and Privacy Policy and to receive email correspondence from us.
You’re in!
As part of your account, you’ll receive occasional updates and offers from New York, which you can opt out of anytime.
Already a subscriber?
Already a subscriber?
`;
// integrate Sub(x) scripts and elements
if (hostname !== 'subs.nymag.com') { // do not integrate on this subdomain
document.head.appendChild(trackingScript);
document.body.insertAdjacentHTML('beforeend', subXAnimationElements);
}
There was an error processing the request. Please try again later."}).catch(e=>console.error("Error verifying email: ",e)))(r.querySelector(".content"),o.bannerCTAVerification)})):(l.remove(),s.remove()),o.dismissable||n.remove(),o.useAlertIcon||a.remove(),r.classList.add("show"),n.addEventListener("click",()=>{u(),r.classList.remove("show")})}else r.remove()}});
}, {"1":1,"6":6,"12":12,"35":35,"40":40}];
window.modules["global-nav.client"] = [function(require,module,exports){"use strict";const dom=require(4),auth=require(12),signInButton=dom.find(".user-signin"),signOutButton=dom.find(".user-signout"),globalNav=dom.find('[class^="global-nav"]'),body=dom.find("body"),dropdownItems=dom.findAll(".dropdown-wrap"),gtm=require(1),appendLandingPageParams=require(135),pageUri=require(124).getPageUri(),subscriptionPromoLinks=dom.findAll(".persist-params"),searchString=window.location.search||"";function closeDropdowns(e){let n=globalNav.querySelectorAll(".dropdown.open");dropdownItems.forEach(function(t){let o=t.querySelector(".dropdown");!n||t.contains(e.target)&&27!==e.keyCode||o.classList.remove("open")})}function gtmSendReport(e,n,t){let o={eventCategory:"ecommerce",eventAction:"componentClick",brand:e,dimension23:"global-nav",list:pageUri,pageZone:"header",variant:"nav-link"};"global-nav-link"===t&&(o.eventLabel=n.href),gtm.reportNow(o)}function updateElementTargetUrlsIfQueryStrings(e){if(searchString){const n=new URLSearchParams(searchString);let t=e.href;if(t.includes("?")){const o=t.split("?"),i=new URLSearchParams(o[1]);for(let e of n.entries())i.set(e[0],e[1]);t=`${o[0]}?${i.toString()}`,e.href=t}else e.href=`${t}?${n.toString()}`}}function init(e){const n=e.querySelectorAll(".to-landing-page");window.addEventListener("auth:init",()=>{signInButton.addEventListener("click",function(e){e.preventDefault(),auth.showEmbeddedLoginFlow("top navigation")}),signOutButton.addEventListener("click",function(e){e.preventDefault(),gtmSendReport("Sign Out",e.target,"user-info-link"),auth.logout()}),auth.isAuthenticated()&&e.classList.add("signed-in"),auth.isSubscriber()&&e.classList.add("subscribed"),e.querySelectorAll(".user-link").forEach(e=>{e.classList.add("active")}),subscriptionPromoLinks.forEach(e=>{updateElementTargetUrlsIfQueryStrings(e)}),appendLandingPageParams(n)})}dropdownItems.forEach(function(e){e.addEventListener("click",function(){e.querySelector(".dropdown").classList.toggle("open")})}),body.addEventListener("click",closeDropdowns),document.addEventListener("keydown",closeDropdowns),globalNav.addEventListener("click",function(e){let n=e.target;n.classList.contains("global-nav-track")&>mSendReport(n.text,n,"global-nav-link")}),module.exports=init;
}, {"1":1,"4":4,"12":12,"124":124,"135":135}];
window.modules["aaa-module-mounting.legacy"] = [function(require,module,exports){"use strict";const _pickBy=require(221),_each=require(406),Fingerprint2=require(408),DS=require(407),Eventify=require(246);function registerGlobals(){window.DS=DS,window.Eventify=Eventify,window.Fingerprint2=Fingerprint2,DS.value("Eventify",Eventify),DS.value("Fingerprint2",Fingerprint2),DS.value("$document",window.document),DS.value("$window",window)}function mountDollarSliceComponents(){DS.service("components",["$document","$module",function(e,n){var o=_pickBy(n.definitions,e=>e.providerStrategy===n.providers.controller),r=Object.keys(o);function t(e){return o=>{try{n.get(e,o)}catch(e){logMountError(o,e)}}}_each(r,n=>{var o=e.querySelectorAll('[data-uri*="/_components/'+n+'/"]'),r=e.querySelectorAll('[data-uri$="/_components/'+n+'"]');_each(o,t(n)),_each(r,t(n))}),this.components=r}]),DS.get("components")}function logMountError(e,n){const o=e.outerHTML.slice(0,e.outerHTML.indexOf(e.innerHTML));console.error("Error attaching controller to "+o,n)}registerGlobals(),"loading"===document.readyState?document.addEventListener("DOMContentLoaded",()=>{mountDollarSliceComponents()}):mountDollarSliceComponents();
}, {"221":221,"246":246,"406":406,"407":407,"408":408}];
window.modules["ads.legacy"] = [function(require,module,exports){"use strict";const _map=require(118),_forEach=require(107),_isString=require(268),_intersectionWith=require(409),_isEqual=require(274),_each=require(406),_debounce=require(182),_sortBy=require(205),page=require(124),visit=require(114);DS.service("adService",["Eventify","$cid","$document","$window",function(e,t,a,i){var o,n,s,r,d,c,u,l,g={},p=this,h=[],f=visit.getQueryParamsObject(["utm_campaign"]),m=document.querySelector('script[data-type="ad-a9"]'),b=[],w=!1,v=[],y=document.querySelector('script[data-name="ad-doubleverify"]');document.querySelector('script[data-name="concert-ads"]')||(i.NYM={},i.NYM.analytics={},i.NYM.analytics.adStartTime=i.performance.now(),i.googletag=i.googletag||{},i.googletag.cmd=i.googletag.cmd||[],u=i.googletag,(m||y)&&(i.googletag.cmd=i.googletag.cmd||[],i.googletag.cmd.push(function(){i.googletag.pubads().disableInitialLoad()})),m&&(l=i.setInterval(function(){void 0!==window.apstag&&void 0!==window.apstag.timeout&&(i.clearInterval(l),window.apstag.cleared=!0,l=null)},10),setTimeout(function(){l&&(i.clearInterval(l),i.googletag.pubads().refresh(),window.apstag||console.log("MESSAGE: Timeout for A9 load exceeded, aborting"))},500)),y&&(b.push(new Promise(function(e){w?e():v.push(e)})),c=i.setTimeout(T,2500)),o=function(e){var t,a,o=e.data,n=[];return o.loaded?e:(o.loaded=!0,t=null,(t=o.sizes?u.defineSlot(o.name,o.sizes,o.id).addService(u.pubads()):u.defineOutOfPageSlot(o.name,o.id).addService(u.pubads())).setTargeting("adid",o.id),f.hasOwnProperty("utm_campaign")&&t.setTargeting("utmcamp",f.utm_campaign),a=p.getAdCount(o.label),t.setTargeting("label",o.label+"_"+o.site+"-"+a),u.display(o.id),u.pubads().addEventListener("slotOnload",function(){i.NYM.analytics.firstAdLoadTime||(i.NYM.analytics.firstAdLoadTime=i.performance.now(),i.NYM.analytics.firstAdLoadLabel=e.data.label)}),n=_(o),Promise.all(b).then(function(){n?window.apstag&&window.apstag.cleared?window.apstag.fetchBids({slots:[n],timeout:window.apstag.timeout},function(){u.cmd.push(function(){window.apstag.setDisplayBids(),u.pubads().refresh([t],{changeCorrelator:!1})})}):y&&u.pubads().refresh([t],{changeCorrelator:!1}):u.pubads().refresh([t],{changeCorrelator:!1})}),e.slot=t,e)},n=function(e){var a,i,o,n=t(),s=e.getAttribute("data-name"),r=e.getAttribute("data-sizes"),d=e.getAttribute("data-label"),c=e.getAttribute("data-site");n=e.id,r&&r.length?(r=r.split(","),a=[],_map(r,function(e){e=e.split("x"),i=parseInt(e[0]),o=parseInt(e[1]),a.push([i,o])})):(e.classList.add("oop"),a=!1),this.data={id:n,name:s,sizes:a,loaded:!1,label:d,site:c},g[n]=this},r=function(e){u.cmd.push(function(){var t=o(e);g[e.data.id]=t})},s=function(e){var t=[];e.slot?(t=_(e))&&window.apstag&&window.apstag.cleared&&window.apstag.fetchBids({slots:[t],timeout:window.apstag.timeout},function(){u.cmd.push(function(){window.apstag.setDisplayBids(),u.pubads().refresh([e.slot],{changeCorrelator:!1})})}):e&&r(e)},u.cmd.push(function(){var e,t,o,n=page.getMeta("article:tag"),s=page.getMeta("author"),r=i.location.href,d=(e=a.head.querySelector(".head-gtm"),t=a.body.querySelector(".gtm"),e&&"top"===e.getAttribute("data-gtm")?"gtmtop":t&&"bottom"===t.getAttribute("data-gtm")?"gtmbottom":"");o=[],_forEach([n,s,d],function(e){_forEach(e.split(","),function(e){(e=e.trim().toLowerCase().replace(/\s/g,"-").replace(/\'|\’/g,"")).length&&o.push(e)})}),u.pubads().setTargeting("kw",o),u.pubads().setTargeting("entry_group",o),r=r.slice(r.lastIndexOf("/")+1),u.pubads().setTargeting("pn",r),u.companionAds().setRefreshUnfilledSlots(!0),u.pubads().enableAsyncRendering(),u.enableServices()}),this.load=r,this.create=function(e){return new n(e)},this.refresh=function(e){var t;_isString(e)?(t=this.getById(e),s(t)):s(e)},this.remove=function(e){var t=e.data.id;a.getElementById(t).innerHTML=""},this.getAdCount=function(e){var t,a=0,i=Object.keys(g);return _each(i,function(i){(t=g[i]).data.loaded&&t.data.label===e&&a++}),a},this.getById=function(e){return g[e]},d=_debounce(function(){var e={TopLeaderboard:1,RightColTopMPU:2,outOfPage:99,"homepageTakeover/TopLeaderboard":1},t=_sortBy(h,function(t){return e[t.data.label]||10});_forEach(t,function(e){return e.data.sizes?r(e):i.setTimeout(function(){r(e)},2e3)}),y&&window.PQ.cmd.push(()=>{try{window.PQ.loadSignals(["ids","bsc","vlp"],T)}catch(e){T(),console.error(`There has been an error loading Double Verify signals: ${e}`)}}),h=[]},10),this.addToPageLoadQueue=function(e){h.push(e),d()});function _(e){var t,a=e.sizes;return a=_intersectionWith(a,[[970,250],[970,90],[728,90],[300,600],[300,250],[320,100],[320,50]],_isEqual),e.sizes&&e.sizes.length&&(t={slotID:e.id,sizes:a,slotName:e.label}),t}function T(){i.clearTimeout(c),w=!0,_forEach(v,function(e){e()})}}]);
}, {"107":107,"114":114,"118":118,"124":124,"182":182,"205":205,"268":268,"274":274,"406":406,"409":409}];
window.modules["cid.legacy"] = [function(require,module,exports){"use strict";DS.service("$cid",function(){var r=Math.floor(100*Math.random());return function(){return"cid-"+ ++r}});
}, {}];
window.modules["client.legacy"] = [function(require,module,exports){"use strict";require("cid.legacy"),require("ads.legacy"),require("facebook.legacy"),require("aaa-module-mounting.legacy");
}, {"cid.legacy":"cid.legacy","ads.legacy":"ads.legacy","facebook.legacy":"facebook.legacy","aaa-module-mounting.legacy":"aaa-module-mounting.legacy"}];
window.modules["facebook.legacy"] = [function(require,module,exports){"use strict";DS.service("facebook",[function(){this.fb=function(i){window.FB&&window.FB[i].apply(this,Array.prototype.slice.call(arguments,1))}}]);
}, {}];
require=(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o typeof key === 'string' && key.match(/\.legacy$/)).forEach(key => window.require(key));
}
function tryToMount(fn, el, name) {
try {
fn(el); // init the controller
} catch (e) {
const elementTag = el.outerHTML.slice(0, el.outerHTML.indexOf(el.innerHTML));
console.error(`Error initializing controller for "${name}" on "${elementTag}"`, e);
}
}
/**
* mount client.js component controllers
*/
function mountComponentModules() {
Object.keys(window.modules).filter(key => typeof key === 'string' && key.match(/\.client$/)).forEach(key => {
let controllerFn = window.require(key);
if (typeof controllerFn === 'function') {
const name = key.replace('.client', ''),
instancesSelector = `[data-uri*="_components/${name}/"]`,
defaultSelector = `[data-uri$="_components${name}"]`,
instances = document.querySelectorAll(instancesSelector),
defaults = document.querySelectorAll(defaultSelector);
for (let el of instances) {
tryToMount(controllerFn, el, name);
}
for (let el of defaults) {
tryToMount(controllerFn, el, name);
}
}
});
}
// Make sure that a `window.process.env.NODE_ENV` is available in the client for any dependencies,
// services, or components that could require it
// note: the `` value is swapped for the actual environment variable in /lib/cmd/compile/scripts.js
window.process = window.process || {};
window.process.env = window.process.env || {};
if (!window.process.env.NODE_ENV) {
window.process.env.NODE_ENV = '';
}
// note: legacy controllers that require legacy services (e.g. dollar-slice) must
// wait for DOMContentLoaded to initialize themselves, as the files themselves must be mounted first
mountLegacyServices();
mountComponentModules();
// ]]