{
  "version": 3,
  "sources": ["/cdn/shop/t/4/assets/ims-deals.js?bust=20260702"],
  "sourcesContent": ["(function(){\r\n  'use strict';\r\n  const db=()=>window.SM.DB, ui=()=>window.SM.UI, util=()=>window.SM.UTIL;\r\n\r\n  // \u2500\u2500\u2500 LOAD \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\r\n  async function load(){\r\n    const content=document.getElementById('ims-deals-content');\r\n    if(!content)return;\r\n    content.innerHTML=`<div class=\"ims__loading\"><i class=\"ti ti-loader-2 ims__spin\"></i></div>`;\r\n\r\n    const client=window.supabase.createClient(window.IMS_SUPABASE_URL,window.IMS_SUPABASE_ANON_KEY,{global:{headers:{Authorization:`Bearer ${window.SM.AUTH.session?.access_token}`}}});\r\n    const {data:deals,error}=await client\r\n      .from('deals')\r\n      .select('*, deal_customers(customer_id), deal_platforms(platform_id)')\r\n      .eq('company_id',window.SM.AUTH.company?.id)\r\n      .order('valid_from',{ascending:false});\r\n\r\n    if(error){content.innerHTML=`<div class=\"ims__coming-soon\"><i class=\"ti ti-tag\"></i><h3>Failed to load deals</h3><p>${error.message}</p></div>`;return;}\r\n\r\n    const today=new Date().toISOString().split('T')[0];\r\n    const items=deals||[];\r\n    const active=items.filter(d=>d.is_active&&d.valid_from<=today&&d.valid_to>=today);\r\n    const upcoming=items.filter(d=>d.is_active&&d.valid_from>today);\r\n    const expired=items.filter(d=>!d.is_active||d.valid_to<today);\r\n\r\n    content.innerHTML=`\r\n      <div style=\"display:grid;grid-template-columns:repeat(3,1fr);gap:12px;margin-bottom:18px\">\r\n        <div class=\"ims__stat\" style=\"padding:12px\">\r\n          <div class=\"ims__stat-label\">Active deals</div>\r\n          <div class=\"ims__stat-value ims__stat-value--success\" style=\"font-size:24px\">${active.length}</div>\r\n        </div>\r\n        <div class=\"ims__stat\" style=\"padding:12px\">\r\n          <div class=\"ims__stat-label\">Upcoming</div>\r\n          <div class=\"ims__stat-value ims__stat-value--accent\" style=\"font-size:24px\">${upcoming.length}</div>\r\n        </div>\r\n        <div class=\"ims__stat\" style=\"padding:12px\">\r\n          <div class=\"ims__stat-label\">Expired</div>\r\n          <div class=\"ims__stat-value\" style=\"font-size:24px\">${expired.length}</div>\r\n        </div>\r\n      </div>\r\n      <div class=\"ims__card\">\r\n        <div class=\"ims__table-wrap\">\r\n          <table class=\"ims__table\">\r\n            <thead><tr>\r\n              <th>Deal name</th><th>Discount</th><th>Stacking</th>\r\n              <th>Targets</th><th>Valid from</th><th>Valid to</th>\r\n              <th>Status</th><th></th>\r\n            </tr></thead>\r\n            <tbody>${items.map(d=>{\r\n              const isActive=d.is_active&&d.valid_from<=today&&d.valid_to>=today;\r\n              const isUpcoming=d.is_active&&d.valid_from>today;\r\n              const statusPill=isActive\r\n                ?'<span class=\"ims__pill ims__pill--success\">Active</span>'\r\n                :isUpcoming\r\n                  ?'<span class=\"ims__pill ims__pill--accent\">Upcoming</span>'\r\n                  :'<span class=\"ims__pill ims__pill--neutral\">Expired</span>';\r\n\r\n              const discount=d.discount_type==='percentage'\r\n                ?`${d.discount_value}% off`\r\n                :`\u00A3${d.discount_value} off`;\r\n\r\n              const targets=_summariseTargets(d);\r\n\r\n              return`<tr>\r\n                <td><strong>${util().sanitize(d.name)}</strong>${d.description?`<div style=\"font-size:11px;color:var(--ims-text-muted)\">${util().sanitize(d.description)}</div>`:''}</td>\r\n                <td><span style=\"font-weight:600;color:var(--ims-accent)\">${discount}</span></td>\r\n                <td><span class=\"ims__pill ims__pill--${d.stacking_behaviour==='stack'?'info':'neutral'}\">${d.stacking_behaviour==='stack'?'Stacks':'Replaces'}</span></td>\r\n                <td style=\"font-size:12px;max-width:200px\">${targets}</td>\r\n                <td style=\"font-size:12px\">${util().formatDate(d.valid_from)}</td>\r\n                <td style=\"font-size:12px;color:${d.valid_to<today?'var(--ims-danger)':''}\">${util().formatDate(d.valid_to)}</td>\r\n                <td>${statusPill}</td>\r\n                <td><div class=\"ims__btn-group\">\r\n                  <button class=\"ims__btn ims__btn--secondary ims__btn--sm ims__btn--icon\" onclick=\"window.IMS_DEALS.editDeal('${util().jsArg(d.id)}')\" title=\"Edit\"><i class=\"ti ti-edit\"></i></button>\r\n                  <button class=\"ims__btn ims__btn--secondary ims__btn--sm ims__btn--icon\" onclick=\"window.IMS_DEALS.toggleDeal('${util().jsArg(d.id)}',${!d.is_active},'${util().jsArg(d.name)}')\" title=\"${d.is_active?'Deactivate':'Activate'}\">\r\n                    <i class=\"ti ti-${d.is_active?'eye-off':'eye'}\"></i>\r\n                  </button>\r\n                  ${window.SM.AUTH.isAdmin()?`<button class=\"ims__btn ims__btn--danger ims__btn--sm ims__btn--icon\" onclick=\"window.IMS_DEALS.deleteDeal('${util().jsArg(d.id)}','${util().jsArg(d.name)}')\" title=\"Delete\"><i class=\"ti ti-trash\"></i></button>`:''}\r\n                </div></td>\r\n              </tr>`;\r\n            }).join('')||'<tr><td colspan=\"8\" class=\"ims__table-empty\">No deals yet \u2014 create your first deal</td></tr>'}\r\n            </tbody>\r\n          </table>\r\n        </div>\r\n      </div>`;\r\n  }\r\n\r\n  function _summariseTargets(d){\r\n    const parts=[];\r\n    if(d.applies_to_all_customers) parts.push('All customers');\r\n    else{\r\n      if(d.applies_to_customer_types?.length) parts.push(d.applies_to_customer_types.map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(', ')+' customers');\r\n      if(d.deal_customers?.length) parts.push(`${d.deal_customers.length} specific customer${d.deal_customers.length>1?'s':''}`);\r\n    }\r\n    if(d.applies_to_all_platforms) parts.push('All platforms');\r\n    else{\r\n      if(d.applies_to_walkin) parts.push('Walk-in');\r\n      if(d.deal_platforms?.length) parts.push(`${d.deal_platforms.length} platform${d.deal_platforms.length>1?'s':''}`);\r\n    }\r\n    return parts.length?parts.join(' \u00B7 '):'<span style=\"color:var(--ims-text-muted)\">No targets set</span>';\r\n  }\r\n\r\n  // \u2500\u2500\u2500 SHOW FORM \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\r\n  async function showNewDeal(){ await _openDealForm(null); }\r\n  async function editDeal(id){ await _openDealForm(id); }\r\n\r\n  async function _openDealForm(existingId){\r\n    const client=window.supabase.createClient(window.IMS_SUPABASE_URL,window.IMS_SUPABASE_ANON_KEY,{global:{headers:{Authorization:`Bearer ${window.SM.AUTH.session?.access_token}`}}});\r\n    let d=null, selCustomers=new Set(), selPlatforms=new Set();\r\n\r\n    if(existingId){\r\n      const {data:deal}=await client.from('deals').select('*, deal_customers(customer_id), deal_platforms(platform_id)').eq('id',existingId).maybeSingle();\r\n      d=deal;\r\n      (d?.deal_customers||[]).forEach(dc=>selCustomers.add(dc.customer_id));\r\n      (d?.deal_platforms||[]).forEach(dp=>selPlatforms.add(dp.platform_id));\r\n    }\r\n\r\n    // Fetch customers and platforms.\r\n    // Dropship customers are targeted from a separate section in the\r\n    // Dropship module \u2014 this deals screen only ever targets customers\r\n    // from the main `customers` table (wholesale/retailer/trade).\r\n    const [{data:customers},{data:sysPlatforms},{data:customPlatforms}]=await Promise.all([\r\n      client.from('customers').select('id,business_name,customer_type,is_active').eq('company_id',window.SM.AUTH.company?.id).order('business_name'),\r\n      client.from('platforms').select('id,name,order_type').is('company_id',null).eq('is_active',true).order('sort_order'),\r\n      client.from('platforms').select('id,name,order_type').eq('company_id',window.SM.AUTH.company?.id).eq('is_active',true).order('name')\r\n    ]);\r\n    const platforms=[...(sysPlatforms||[]),...(customPlatforms||[])];\r\n    // Deactivated customers are not offered, except any already on this\r\n    // deal, which stay listed (and ticked) so saving never drops them.\r\n    const allCustomers=(customers||[]).filter(c=>c.is_active!==false||selCustomers.has(c.id)).sort((a,b)=>a.business_name.localeCompare(b.business_name));\r\n\r\n    const today=new Date().toISOString().split('T')[0];\r\n    const nextMonth=new Date(Date.now()+30*86400000).toISOString().split('T')[0];\r\n\r\n    ui().openModal(existingId?`Edit deal: ${d?.name}`:'New deal',`\r\n      <!-- SECTION 1: Deal details -->\r\n      <div style=\"font-size:13px;font-weight:600;color:var(--ims-text);margin-bottom:12px\"><i class=\"ti ti-tag\" style=\"color:var(--ims-accent)\"></i> Deal details</div>\r\n      <div class=\"ims__form-grid\">\r\n        <div class=\"ims__form-group ims__form-group--full\">\r\n          <label class=\"ims__label ims__label--req\">Deal name</label>\r\n          <input class=\"ims__input\" type=\"text\" id=\"ims-deal-name\" value=\"${util().sanitize(d?.name||'')}\" placeholder=\"e.g. Summer Sale, VIP Discount, Clearance Event\">\r\n        </div>\r\n        <div class=\"ims__form-group ims__form-group--full\">\r\n          <label class=\"ims__label\">Description</label>\r\n          <input class=\"ims__input\" type=\"text\" id=\"ims-deal-desc\" value=\"${util().sanitize(d?.description||'')}\" placeholder=\"Internal note about this deal\">\r\n        </div>\r\n        <div class=\"ims__form-group\">\r\n          <label class=\"ims__label ims__label--req\">Discount type</label>\r\n          <select class=\"ims__select\" id=\"ims-deal-dtype\" onchange=\"window.IMS_DEALS.onDealDiscountTypeChange()\">\r\n            <option value=\"percentage\" ${(d?.discount_type||'percentage')==='percentage'?'selected':''}>Percentage off (%)</option>\r\n            <option value=\"fixed_amount\" ${d?.discount_type==='fixed_amount'?'selected':''}>Fixed amount off (\u00A3)</option>\r\n          </select>\r\n        </div>\r\n        <div class=\"ims__form-group\">\r\n          <label class=\"ims__label ims__label--req\">Discount value</label>\r\n          <input class=\"ims__input\" type=\"number\" step=\"0.01\" min=\"0\" id=\"ims-deal-dvalue\"\r\n            value=\"${d?.discount_value||''}\"\r\n            placeholder=\"${(d?.discount_type||'percentage')==='percentage'?'e.g. 10 for 10% off':'e.g. 50 for \u00A350 off'}\"\r\n            oninput=\"window.IMS_DEALS.updatePreview()\">\r\n        </div>\r\n        <div class=\"ims__form-group\">\r\n          <label class=\"ims__label ims__label--req\">Stacking behaviour</label>\r\n          <select class=\"ims__select\" id=\"ims-deal-stack\" onchange=\"window.IMS_DEALS.updatePreview()\">\r\n            <option value=\"replace\" ${(d?.stacking_behaviour||'replace')==='replace'?'selected':''}>Replace customer's standing discount</option>\r\n            <option value=\"stack\" ${d?.stacking_behaviour==='stack'?'selected':''}>Stack on top of standing discount</option>\r\n          </select>\r\n          <span class=\"ims__input-hint\">\r\n            Replace: deal discount used instead of standing discount.<br>\r\n            Stack: deal discount applied after standing discount.\r\n          </span>\r\n        </div>\r\n        <div class=\"ims__form-group\">\r\n          <label class=\"ims__label ims__label--req\">Status</label>\r\n          <select class=\"ims__select\" id=\"ims-deal-active\">\r\n            <option value=\"true\" ${(d?.is_active!==false)?'selected':''}>Active</option>\r\n            <option value=\"false\" ${d?.is_active===false?'selected':''}>Inactive (draft)</option>\r\n          </select>\r\n        </div>\r\n        <div class=\"ims__form-group\">\r\n          <label class=\"ims__label ims__label--req\">Valid from</label>\r\n          <input class=\"ims__input\" type=\"date\" id=\"ims-deal-from\" value=\"${d?.valid_from||today}\">\r\n        </div>\r\n        <div class=\"ims__form-group\">\r\n          <label class=\"ims__label ims__label--req\">Valid to</label>\r\n          <input class=\"ims__input\" type=\"date\" id=\"ims-deal-to\" value=\"${d?.valid_to||nextMonth}\">\r\n        </div>\r\n      </div>\r\n\r\n      <hr class=\"ims__divider\">\r\n\r\n      <!-- SECTION 2: Customer targeting -->\r\n      <div style=\"font-size:13px;font-weight:600;color:var(--ims-text);margin-bottom:12px\"><i class=\"ti ti-users\" style=\"color:var(--ims-accent)\"></i> Customer targeting</div>\r\n      <div style=\"margin-bottom:10px\">\r\n        <label style=\"display:flex;align-items:center;gap:8px;font-size:13px;cursor:pointer;margin-bottom:8px\">\r\n          <input type=\"checkbox\" id=\"ims-deal-all-cust\" ${d?.applies_to_all_customers?'checked':''}\r\n            onchange=\"window.IMS_DEALS.onAllCustomersChange()\">\r\n          <strong>Apply to ALL customers</strong>\r\n        </label>\r\n      </div>\r\n      <div id=\"ims-deal-cust-detail\" style=\"${d?.applies_to_all_customers?'opacity:0.4;pointer-events:none':''}\">\r\n        <div style=\"font-size:12px;font-weight:600;color:var(--ims-text-sec);margin-bottom:8px\">Customer types:</div>\r\n        <div style=\"display:flex;gap:12px;margin-bottom:14px;flex-wrap:wrap\">\r\n          ${['wholesale','retailer','trade'].map(type=>`\r\n            <label style=\"display:flex;align-items:center;gap:6px;font-size:13px;cursor:pointer\">\r\n              <input type=\"checkbox\" id=\"ims-deal-ctype-${type}\"\r\n                ${(d?.applies_to_customer_types||[]).includes(type)?'checked':''}>\r\n              ${type.charAt(0).toUpperCase()+type.slice(1)}\r\n            </label>`).join('')}\r\n        </div>\r\n        <div style=\"font-size:12px;font-weight:600;color:var(--ims-text-sec);margin-bottom:8px\">Specific customers:</div>\r\n        <div style=\"max-height:180px;overflow-y:auto;border:1px solid var(--ims-border);border-radius:var(--ims-radius);padding:8px\">\r\n          ${allCustomers.length?allCustomers.map(c=>`\r\n            <label style=\"display:flex;align-items:center;gap:8px;padding:5px 4px;cursor:pointer;font-size:13px;border-bottom:1px solid var(--ims-border)\">\r\n              <input type=\"checkbox\" class=\"ims-deal-cust-cb\" value=\"${c.id}\"\r\n                ${selCustomers.has(c.id)?'checked':''}>\r\n              <span>${util().sanitize(c.business_name)}</span>${c.is_active===false?' <span class=\"ims__pill ims__pill--neutral\" style=\"font-size:10px\">Inactive</span>':''}\r\n              <span class=\"ims__pill ims__pill--${c.customer_type==='wholesale'?'info':'neutral'}\" style=\"font-size:10px;margin-left:auto\">${c.customer_type}</span>\r\n            </label>`).join('')\r\n          :'<div style=\"font-size:12px;color:var(--ims-text-muted);padding:8px\">No customers found</div>'}\r\n        </div>\r\n      </div>\r\n\r\n      <hr class=\"ims__divider\">\r\n\r\n      <!-- SECTION 3: Platform targeting -->\r\n      <div style=\"font-size:13px;font-weight:600;color:var(--ims-text);margin-bottom:12px\"><i class=\"ti ti-apps\" style=\"color:var(--ims-accent)\"></i> Platform targeting</div>\r\n      <div style=\"margin-bottom:10px\">\r\n        <label style=\"display:flex;align-items:center;gap:8px;font-size:13px;cursor:pointer;margin-bottom:8px\">\r\n          <input type=\"checkbox\" id=\"ims-deal-all-plat\" ${d?.applies_to_all_platforms?'checked':''}\r\n            onchange=\"window.IMS_DEALS.onAllPlatformsChange()\">\r\n          <strong>Apply to ALL platforms</strong>\r\n        </label>\r\n        <span class=\"ims__input-hint\">Select \"Walk-in\" under specific platforms below to target walk-in customers directly.</span>\r\n      </div>\r\n      <div id=\"ims-deal-plat-detail\" style=\"${d?.applies_to_all_platforms?'opacity:0.4;pointer-events:none':''}\">\r\n        <div style=\"font-size:12px;font-weight:600;color:var(--ims-text-sec);margin-bottom:8px\">Specific platforms:</div>\r\n        <div style=\"max-height:180px;overflow-y:auto;border:1px solid var(--ims-border);border-radius:var(--ims-radius);padding:8px\">\r\n          ${platforms.length?platforms.map(p=>`\r\n            <label style=\"display:flex;align-items:center;gap:8px;padding:5px 4px;cursor:pointer;font-size:13px;border-bottom:1px solid var(--ims-border)\">\r\n              <input type=\"checkbox\" class=\"ims-deal-plat-cb\" value=\"${p.id}\"\r\n                ${selPlatforms.has(p.id)?'checked':''}>\r\n              <span>${util().sanitize(p.name)}</span>\r\n              <span class=\"ims__pill ims__pill--${p.order_type==='wholesale'?'info':'neutral'}\" style=\"font-size:10px;margin-left:auto\">${p.order_type}</span>\r\n            </label>`).join('')\r\n          :'<div style=\"font-size:12px;color:var(--ims-text-muted);padding:8px\">No platforms found</div>'}\r\n        </div>\r\n      </div>\r\n\r\n      <!-- Price preview -->\r\n      <hr class=\"ims__divider\">\r\n      <div style=\"font-size:13px;font-weight:600;color:var(--ims-text);margin-bottom:10px\"><i class=\"ti ti-calculator\" style=\"color:var(--ims-accent)\"></i> Price preview</div>\r\n      <div style=\"display:grid;grid-template-columns:1fr 1fr;gap:10px;align-items:end\">\r\n        <div class=\"ims__form-group\">\r\n          <label class=\"ims__label\">Example wholesale price (\u00A3)</label>\r\n          <input class=\"ims__input\" type=\"number\" step=\"0.01\" id=\"ims-deal-preview-price\" value=\"100\" oninput=\"window.IMS_DEALS.updatePreview()\">\r\n        </div>\r\n        <div class=\"ims__form-group\">\r\n          <label class=\"ims__label\">Customer standing discount (%)</label>\r\n          <input class=\"ims__input\" type=\"number\" step=\"0.01\" id=\"ims-deal-preview-standing\" value=\"0\" oninput=\"window.IMS_DEALS.updatePreview()\">\r\n        </div>\r\n      </div>\r\n      <div id=\"ims-deal-preview\" style=\"background:var(--ims-surface2);border-radius:var(--ims-radius);padding:12px;font-size:13px;margin-top:8px\">\r\n        Enter values above to see price calculation\r\n      </div>\r\n    `,`\r\n      <button class=\"ims__btn ims__btn--ghost\" onclick=\"window.SM.UI.closeModal()\">Cancel</button>\r\n      <button class=\"ims__btn ims__btn--primary\" onclick=\"window.IMS_DEALS.saveDeal('${util().jsArg(existingId||'')}')\"><i class=\"ti ti-check\"></i> ${existingId?'Save changes':'Create deal'}</button>\r\n    `,'xl');\r\n\r\n    // Trigger initial preview\r\n    setTimeout(()=>updatePreview(),100);\r\n  }\r\n\r\n  // \u2500\u2500\u2500 FORM HELPERS \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\r\n  function onDealDiscountTypeChange(){\r\n    const type=document.getElementById('ims-deal-dtype')?.value;\r\n    const input=document.getElementById('ims-deal-dvalue');\r\n    if(input) input.placeholder=type==='percentage'?'e.g. 10 for 10% off':'e.g. 50 for \u00A350 off';\r\n    updatePreview();\r\n  }\r\n\r\n  function onAllCustomersChange(){\r\n    const checked=document.getElementById('ims-deal-all-cust')?.checked;\r\n    const detail=document.getElementById('ims-deal-cust-detail');\r\n    if(detail){detail.style.opacity=checked?'0.4':'1';detail.style.pointerEvents=checked?'none':'';}\r\n  }\r\n\r\n  function onAllPlatformsChange(){\r\n    const checked=document.getElementById('ims-deal-all-plat')?.checked;\r\n    const detail=document.getElementById('ims-deal-plat-detail');\r\n    if(detail){detail.style.opacity=checked?'0.4':'1';detail.style.pointerEvents=checked?'none':'';}\r\n  }\r\n\r\n  function updatePreview(){\r\n    const preview=document.getElementById('ims-deal-preview');\r\n    if(!preview)return;\r\n    const base=parseFloat(document.getElementById('ims-deal-preview-price')?.value)||100;\r\n    const standing=parseFloat(document.getElementById('ims-deal-preview-standing')?.value)||0;\r\n    const dtype=document.getElementById('ims-deal-dtype')?.value||'percentage';\r\n    const dvalue=parseFloat(document.getElementById('ims-deal-dvalue')?.value)||0;\r\n    const stack=document.getElementById('ims-deal-stack')?.value||'replace';\r\n\r\n    const fmt=v=>`\u00A3${v.toFixed(2)}`;\r\n    const afterStanding=base*(1-standing/100);\r\n    let finalPrice,lines='';\r\n\r\n    lines+=`<div style=\"display:flex;justify-content:space-between;padding:4px 0;border-bottom:1px solid var(--ims-border)\"><span>Wholesale price</span><span>${fmt(base)}</span></div>`;\r\n\r\n    if(stack==='replace'){\r\n      // Ignore standing discount, apply deal only\r\n      if(dtype==='percentage'){\r\n        finalPrice=base*(1-dvalue/100);\r\n        lines+=`<div style=\"display:flex;justify-content:space-between;padding:4px 0;border-bottom:1px solid var(--ims-border);color:var(--ims-accent)\"><span>Deal discount (${dvalue}% \u2014 replaces standing)</span><span>-${fmt(base*dvalue/100)}</span></div>`;\r\n      } else {\r\n        finalPrice=base-dvalue;\r\n        lines+=`<div style=\"display:flex;justify-content:space-between;padding:4px 0;border-bottom:1px solid var(--ims-border);color:var(--ims-accent)\"><span>Deal discount (\u00A3${dvalue} \u2014 replaces standing)</span><span>-${fmt(dvalue)}</span></div>`;\r\n      }\r\n    } else {\r\n      // Stack: apply standing first, then deal\r\n      if(standing>0){\r\n        lines+=`<div style=\"display:flex;justify-content:space-between;padding:4px 0;border-bottom:1px solid var(--ims-border);color:var(--ims-text-sec)\"><span>Standing discount (${standing}%)</span><span>-${fmt(base*standing/100)}</span></div>`;\r\n      }\r\n      if(dtype==='percentage'){\r\n        finalPrice=afterStanding*(1-dvalue/100);\r\n        lines+=`<div style=\"display:flex;justify-content:space-between;padding:4px 0;border-bottom:1px solid var(--ims-border);color:var(--ims-accent)\"><span>Deal discount (${dvalue}% stacked)</span><span>-${fmt(afterStanding*dvalue/100)}</span></div>`;\r\n      } else {\r\n        finalPrice=afterStanding-dvalue;\r\n        lines+=`<div style=\"display:flex;justify-content:space-between;padding:4px 0;border-bottom:1px solid var(--ims-border);color:var(--ims-accent)\"><span>Deal discount (\u00A3${dvalue} stacked)</span><span>-${fmt(dvalue)}</span></div>`;\r\n      }\r\n    }\r\n\r\n    finalPrice=Math.max(0,finalPrice);\r\n    lines+=`<div style=\"display:flex;justify-content:space-between;padding:6px 0;font-size:15px;font-weight:700\"><span>Customer pays</span><span style=\"color:var(--ims-success)\">${fmt(finalPrice)}</span></div>`;\r\n    preview.innerHTML=lines;\r\n  }\r\n\r\n  // \u2500\u2500\u2500 SAVE DEAL \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\r\n  async function saveDeal(existingId){\r\n    const g=id=>document.getElementById(id)?.value?.trim()||'';\r\n    const name=g('ims-deal-name');\r\n    if(!name){ui().toast('Deal name is required','error');return;}\r\n    const dvalue=parseFloat(g('ims-deal-dvalue'));\r\n    if(!dvalue||dvalue<=0){ui().toast('Please enter a valid discount value','error');return;}\r\n    const from=g('ims-deal-from'), to=g('ims-deal-to');\r\n    if(!from||!to){ui().toast('Valid from and valid to dates are required','error');return;}\r\n    if(to<from){ui().toast('Valid to must be after valid from','error');return;}\r\n\r\n    // Collect customer selections\r\n    const allCust=document.getElementById('ims-deal-all-cust')?.checked||false;\r\n    const custTypes=['wholesale','retailer','trade'].filter(t=>document.getElementById(`ims-deal-ctype-${t}`)?.checked);\r\n    const specificCustomers=[...document.querySelectorAll('.ims-deal-cust-cb:checked')].map(cb=>cb.value);\r\n\r\n    // Collect platform selections\r\n    const allPlat=document.getElementById('ims-deal-all-plat')?.checked||false;\r\n    const specificPlatforms=[...document.querySelectorAll('.ims-deal-plat-cb:checked')].map(cb=>cb.value);\r\n\r\n    const companyId=window.SM.AUTH.company?.id;\r\n    const accessToken=window.SM.AUTH.session?.access_token;\r\n    const client=window.supabase.createClient(window.IMS_SUPABASE_URL,window.IMS_SUPABASE_ANON_KEY,{\r\n      global:{headers:{Authorization:`Bearer ${accessToken}`}}\r\n    });\r\n\r\n    // Check for overlapping deals for specific customers (Option C \u2014 block overlaps)\r\n    if(!allCust&&specificCustomers.length){\r\n      for(const custId of specificCustomers){\r\n        const {data:overlap}=await client.rpc('check_deal_customer_overlap',{\r\n          p_deal_id: existingId||'00000000-0000-0000-0000-000000000000',\r\n          p_customer_id: custId,\r\n          p_valid_from: from,\r\n          p_valid_to: to,\r\n          p_company_id: companyId\r\n        });\r\n        if(!overlap){\r\n          // Find customer name for error message\r\n          const {data:cust}=await client.from('customers').select('business_name').eq('id',custId).maybeSingle();\r\n          ui().toast(`Deal overlap: ${cust?.business_name||'A customer'} already has an active deal in this date range. Only one deal per customer at a time is allowed.`,'error',6000);\r\n          return;\r\n        }\r\n      }\r\n    }\r\n\r\n    const dealData={\r\n      company_id:companyId,\r\n      name,\r\n      description:g('ims-deal-desc')||null,\r\n      discount_type:g('ims-deal-dtype')||'percentage',\r\n      discount_value:dvalue,\r\n      stacking_behaviour:g('ims-deal-stack')||'replace',\r\n      applies_to_all_customers:allCust,\r\n      applies_to_customer_types:custTypes.length?custTypes:null,\r\n      applies_to_all_platforms:allPlat,\r\n      valid_from:from,\r\n      valid_to:to,\r\n      is_active:document.getElementById('ims-deal-active')?.value==='true',\r\n      created_by:window.SM.AUTH.user?.id\r\n    };\r\n\r\n    let dealId=existingId;\r\n    if(existingId){\r\n      const {error}=await db().update('deals',existingId,dealData);\r\n      if(error){ui().toast('Failed: '+error.message,'error');return;}\r\n      await client.from('deal_customers').delete().eq('deal_id',existingId);\r\n      await client.from('deal_platforms').delete().eq('deal_id',existingId);\r\n    } else {\r\n      const {data:newDeal,error}=await db().insert('deals',dealData);\r\n      if(error){ui().toast('Failed: '+error.message,'error');return;}\r\n      if(!newDeal?.id){ui().toast('Deal created but ID not returned','error');return;}\r\n      dealId=newDeal.id;\r\n    }\r\n\r\n    // Insert customer links\r\n    if(!allCust&&specificCustomers.length){\r\n      await Promise.all(specificCustomers.map(custId=>\r\n        client.from('deal_customers').insert({deal_id:dealId,customer_id:custId})\r\n      ));\r\n    }\r\n\r\n    // Insert platform links\r\n    if(!allPlat&&specificPlatforms.length){\r\n      await Promise.all(specificPlatforms.map(platId=>\r\n        client.from('deal_platforms').insert({deal_id:dealId,platform_id:platId})\r\n      ));\r\n    }\r\n\r\n    ui().closeModal();\r\n    ui().toast(`Deal \"${name}\" ${existingId?'updated':'created'}`,'success');\r\n    load();\r\n  }\r\n\r\n  // \u2500\u2500\u2500 TOGGLE ACTIVE \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\r\n  async function toggleDeal(id,newActive,name){\r\n    const client=window.supabase.createClient(window.IMS_SUPABASE_URL,window.IMS_SUPABASE_ANON_KEY);\r\n    await client.from('deals').update({is_active:newActive}).eq('id',id);\r\n    ui().toast(`\"${name}\" ${newActive?'activated':'deactivated'}`,'success');\r\n    load();\r\n  }\r\n\r\n  // \u2500\u2500\u2500 DELETE DEAL \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\r\n  async function deleteDeal(id,name){\r\n    ui().confirm(\r\n      `Delete deal \"${name}\"? This cannot be undone. Orders that used this deal will keep their discount records.`,\r\n      async()=>{\r\n        const client=window.supabase.createClient(window.IMS_SUPABASE_URL,window.IMS_SUPABASE_ANON_KEY);\r\n        await client.from('deal_customers').delete().eq('deal_id',id);\r\n        await client.from('deal_platforms').delete().eq('deal_id',id);\r\n        const {error}=await client.from('deals').delete().eq('id',id);\r\n        if(error){ui().toast('Failed: '+error.message,'error');return;}\r\n        ui().toast(`Deal \"${name}\" deleted`,'success');\r\n        load();\r\n      },\r\n      'Delete deal',\r\n      true\r\n    );\r\n  }\r\n\r\n  // \u2500\u2500\u2500 PUBLIC: FETCH ACTIVE DEALS FOR AN ORDER \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\r\n  // Called by ims-orders.js when customer is selected\r\n  async function getActiveDealsForOrder(customerId, customerType, platformId){\r\n    const client=window.supabase.createClient(window.IMS_SUPABASE_URL,window.IMS_SUPABASE_ANON_KEY);\r\n    const today=new Date().toISOString().split('T')[0];\r\n    const companyId=window.SM.AUTH.company?.id;\r\n\r\n    const {data:deals}=await client\r\n      .from('deals')\r\n      .select('*, deal_customers(customer_id), deal_platforms(platform_id)')\r\n      .eq('company_id',companyId)\r\n      .eq('is_active',true)\r\n      .lte('valid_from',today)\r\n      .gte('valid_to',today);\r\n\r\n    return (deals||[]).filter(d=>{\r\n      // Customer match\r\n      const custMatch=\r\n        d.applies_to_all_customers ||\r\n        (d.applies_to_customer_types||[]).includes(customerType) ||\r\n        (d.deal_customers||[]).some(dc=>dc.customer_id===customerId);\r\n\r\n      // Platform match\r\n      const platMatch=\r\n        d.applies_to_all_platforms ||\r\n        (platformId&&(d.deal_platforms||[]).some(dp=>dp.platform_id===platformId));\r\n\r\n      // Deal applies if customer OR platform matches\r\n      return custMatch||platMatch;\r\n    });\r\n  }\r\n\r\n  // \u2500\u2500\u2500 PUBLIC: CALCULATE DEAL PRICE \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\r\n  // Returns { finalPrice, breakdown } given wholesale price + customer + deal\r\n  function calculateDealPrice(wholesalePrice, customerDiscountType, customerDiscountValue, deal){\r\n    let afterStanding=wholesalePrice;\r\n    const breakdown=[];\r\n\r\n    breakdown.push({label:'Wholesale price', amount:wholesalePrice, type:'base'});\r\n\r\n    // Apply standing discount if stacking\r\n    if(deal.stacking_behaviour==='stack'&&customerDiscountType&&customerDiscountValue>0){\r\n      if(customerDiscountType==='percentage'){\r\n        const disc=wholesalePrice*customerDiscountValue/100;\r\n        afterStanding=wholesalePrice-disc;\r\n        breakdown.push({label:`Standing discount (${customerDiscountValue}%)`,amount:-disc,type:'standing'});\r\n      } else {\r\n        afterStanding=wholesalePrice-customerDiscountValue;\r\n        breakdown.push({label:`Standing discount (\u00A3${customerDiscountValue})`,amount:-customerDiscountValue,type:'standing'});\r\n      }\r\n    }\r\n\r\n    // Apply deal discount\r\n    let finalPrice=afterStanding;\r\n    if(deal.discount_type==='percentage'){\r\n      const disc=afterStanding*deal.discount_value/100;\r\n      finalPrice=afterStanding-disc;\r\n      breakdown.push({label:`Deal: ${deal.name} (${deal.discount_value}% ${deal.stacking_behaviour==='stack'?'stacked':'replaces standing'})`,amount:-disc,type:'deal'});\r\n    } else {\r\n      finalPrice=afterStanding-deal.discount_value;\r\n      breakdown.push({label:`Deal: ${deal.name} (\u00A3${deal.discount_value} off ${deal.stacking_behaviour==='stack'?'stacked':'replaces standing'})`,amount:-deal.discount_value,type:'deal'});\r\n    }\r\n\r\n    finalPrice=Math.max(0,finalPrice);\r\n    breakdown.push({label:'Customer pays',amount:finalPrice,type:'final'});\r\n    return{finalPrice:parseFloat(finalPrice.toFixed(2)),breakdown};\r\n  }\r\n\r\n  // \u2500\u2500\u2500 BINDINGS \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\r\n  window.addEventListener('ims:panel',e=>{if(e.detail.panel==='deals')load();});\r\n  window.addEventListener('ims:ready',()=>{\r\n    document.getElementById('ims-deals-new-btn')?.addEventListener('click',showNewDeal);\r\n  });\r\n\r\n  window.IMS_DEALS={\r\n    load,showNewDeal,editDeal,saveDeal,toggleDeal,deleteDeal,\r\n    onDealDiscountTypeChange,onAllCustomersChange,onAllPlatformsChange,\r\n    updatePreview,getActiveDealsForOrder,calculateDealPrice\r\n  };\r\n})();"],
  "mappings": "CAAC,UAAU,CACT,aACA,MAAM,GAAG,IAAI,OAAO,GAAG,GA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