'use strict'; const sample=[{name:'Rechargeable headlamp',icon:'☼',qty:1,spot:'Trail kit · 85 g'},{name:'Water bottle',icon:'◉',qty:2,spot:'Trail kit · 150 g each'},{name:'Spare batteries',icon:'ϟ',qty:0,spot:'Shared station · refill'},{name:'First-aid pouch',icon:'+',qty:1,spot:'Trail kit'}]; const sampleOriginal=sample.map(i=>i.qty); function renderSample(){document.getElementById('demoRows').innerHTML=sample.map((i,n)=>`
${i.name}${i.qty===0?'Empty · tap + to refill':i.spot}
${i.qty}
`).join('')} document.getElementById('demoRows').addEventListener('click',e=>{const b=e.target.closest('[data-sample]');if(!b)return;const i=sample[Number(b.dataset.sample)];if(i.qty===0&&b.dataset.delta==='-1'){document.getElementById('demoStatus').textContent='In the app, another minus archives an empty item.';return}i.qty=Math.max(0,Math.min(99,i.qty+Number(b.dataset.delta)));renderSample();document.getElementById('demoStatus').textContent=i.qty===0?i.name+' stays under Empty. Tap + to refill.':'Sample updated. Your real inventory is untouched.'}); document.getElementById('demoReset').onclick=()=>{sample.forEach((i,n)=>i.qty=sampleOriginal[n]);renderSample();document.getElementById('demoStatus').textContent='Sample reset. Your real inventory is untouched.'};renderSample();