import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{Ht as t}from"./vendor-react-N_fu9J_Y.js";var n=e(t());function r(e,t){window.dispatchEvent(new StorageEvent(`storage`,{key:e,newValue:t}))}function i(e,t=null){if(e===null)return t;try{return JSON.parse(e)}catch(e){return console.warn(`Error parsing JSON from localStorage:`,e),t}}function a(e){try{return JSON.stringify(e)}catch(e){throw console.warn(`Error stringifying value for localStorage:`,e),e}}var o=(e,t)=>{try{let n=a(t);window.localStorage.setItem(e,n),r(e,n)}catch(t){console.warn(`[useLocalStorage] Failed to set item "${e}" in localStorage:`,t)}},s=e=>{try{window.localStorage.removeItem(e),r(e,null)}catch(t){console.warn(`[useLocalStorage] Failed to remove item "${e}" from localStorage:`,t)}},c=e=>{try{return window.localStorage.getItem(e)}catch(e){return console.warn(`Error accessing localStorage:`,e),null}},l=e=>(window.addEventListener(`storage`,e),()=>window.removeEventListener(`storage`,e)),u=()=>{throw Error(`useLocalStorage is a client-only hook`)};function d(e,t){let r=i((0,n.useSyncExternalStore)(l,()=>c(e),u),t??null),a=(0,n.useCallback)(n=>{try{let r=i(c(e),t??null),a=typeof n==`function`?n(r):n;a==null?s(e):o(e,a)}catch(e){console.warn(`Error updating localStorage:`,e)}},[e,t]);return(0,n.useEffect)(()=>{c(e)===null&&t!==void 0&&o(e,t)},[e,t]),[r,a]}var f=new class{isDevelopment=!1;error(e,t,n){let r=this.formatPrefix(`error`,n);console.error(r,e,t||``,...n?[n]:[])}warn(e,t){let n=this.formatPrefix(`warn`,t);console.warn(n,e,...t?[t]:[])}info(e,t){if(this.isDevelopment){let n=this.formatPrefix(`info`,t);console.info(n,e)}}debug(e,t,n){if(this.isDevelopment){let r=this.formatPrefix(`debug`,n);console.debug(r,e,t||``)}}formatPrefix(e,t){let n=[`[${e.toUpperCase()}]`];return t?.component&&n.push(`[${t.component}]`),t?.action&&n.push(`[${t.action}]`),n.join(` `)}},p=`https://assets-staging.matsuyaginza.com`,m=[`360x270`,`540x400`,`720x540`,`960x720`,`1200x900`],h=[`480x600`,`768x960`,`1024x1280`,`1280x1600`,`1600x2000`,`2000x2880`],g=[`32x32`,`64x64`],_=[`32x32`,`64x64`],v=(e,t,n)=>{if(!e)return{};let r=e.split(`.`).pop()?.toLowerCase();if(!r)return{};let i=encodeURI(e),a={};for(let e of n)a[e]=`${p}${t}/${i}/${e}.${r}`;return a},y=(e,t)=>{if(!e)return{};let n=decodeURIComponent(e),r=n.split(`.`).pop()?.toLowerCase();if(!r)return{};let i=encodeURI(n),a={};for(let e of t)a[e]=`${p}${i}/${e}.${r}`;return a},b=e=>v(e,`/catalog/brands`,m),x=e=>y(e,h),S=e=>e?v(decodeURIComponent(e).replace(/^\/catalog\/brand-colors\//,``),`/catalog/brand-colors`,_):{},C=e=>y(e,g),w=(e,t=0)=>{if(e)return x(e)[h[t]]},T=(e,t)=>b(e)[m[t]],E=(e,t=0)=>{if(e){if(e.startsWith(`http`))return e;try{return T(decodeURIComponent(e).replace(/^\/catalog\/brands\//,``),t)}catch(n){return f.warn(`Failed to decode brand image URI: ${e}`,{component:`image-src-transformer`,action:`getBrandImageUrl`,image:e,error:n}),T(e.replace(/^\/catalog\/brands\//,``),t)}}},D=(e,t=0)=>{if(!e)return;let n=`${_[t]||_[0]}.png`,r=e.replace(/\/+$/,``);if(/^https?:\/\//i.test(r))return`${r}/${n}`;let i=decodeURIComponent(r).replace(/^\/+/g,``).replace(/^catalog\/brand-colors\//i,``);return`${p}/catalog/brand-colors/${encodeURI(i)}/${n}`},O=(e,t=0)=>C(e)[g[t]],k=(e,t=0)=>{if(!e)return;let n=g[t]||g[0];try{let t=decodeURIComponent(e),r=/^https?:\/\//i.test(t),i=``,a=t;if(r)try{let e=new URL(t);i=e.origin,a=e.pathname}catch{a=t}let o=a.replace(/\/+$/,``),s=o.split(`.`).pop()?.toLowerCase();if(!s)return;let c=RegExp(`/${n}\\.${s}$`,`i`).test(o),l=/\/\d+x\d+\.[a-z0-9]+$/i.test(o),u=o;!c&&!l&&(u=`${o.slice(0,-(s.length+1))}/${n}.${s}`);let d=encodeURI(u.startsWith(`/`)?u:`/${u}`),f=`${i||p}${d}`;return f.includes(`/catalog/brand-colors/`)&&(f=f.replace(`/catalog/brand-colors/`,`/catalog/color-groups/`)),f}catch{return}},A=e=>{if(!e)return``;let t=x(e);return h.map(e=>`${t[e]} ${parseInt(e.split(`x`)[0],10)}w`).join(`, `)},j=(e,t=`(max-width: 640px) 50vw, (max-width: 1024px) 33vw, 25vw`)=>({src:w(e,1)||``,srcSet:A(e),sizes:t}),M={GIFT_WRAPPING_STATE:`giftWrappingState`,GIFT_SENDER_NAME:`giftSenderName`,GIFT_WRAPPING_ITEMS:`giftWrappingItems`,CHECKOUT_ACCORDION_STATES:`checkoutAccordionStates`,SHIPPING_ADDRESS_FORM:`checkoutShippingAddressForm`,BILLING_ADDRESS_FORM:`checkoutBillingAddressForm`,AGREED:`checkout_agreed`,AGREED_PRIVACY:`checkout_agreed_privacy`,SHARE_INFO:`checkout_share_info`,CREATE_ACCOUNT:`checkout_create_account`,TRIGGER_ADDRESS_FORM:`checkout_trigger_address_form`,TRIGGER_APPOINTMENT_FORM:`checkout_trigger_appointment_form`,FORM_SHIPPING_ADDRESS:`checkout_form_shipping_address`,FORM_BILLING_ADDRESS:`checkout_form_billing_address`,ORDER_ID:`checkout_order_id`,PLACE_ORDER_DISABLED:`checkout_place_order_disabled`,TIFFANY_APPOINTMENT:`checkout_tiffany_appointment`,CHECKOUT_ID:`checkoutId`},N=()=>{Object.values(M).forEach(e=>{localStorage.removeItem(e)})};export{E as a,k as c,j as d,f,S as i,w as l,N as n,O as o,d as p,D as r,C as s,M as t,x as u};