(function(){ if(location.hostname==="s.salla.sa"||window.__btq)return; window.__btq=1; var R="https://weuth02x1.github.io/btq-site/"; var EN=/^\/en(\/|$)/.test(location.pathname),LOC=EN?"/en":"/ar"; function tr(a,b){return EN?b:a} function langHref(code){var p=location.pathname;if(/^\/(ar|en)(\/|$)/.test(p))p=p.replace(/^\/(ar|en)/,"/"+code);else p="/"+code+(p.charAt(0)==="/"?p:"/"+p);return p+location.search+location.hash} function cartMoney(cart){var el=cart&&cart.querySelector(".s-cart-summary-total");var raw=el&&el.textContent?el.textContent.replace(/\s+/g," ").trim():"";raw=raw.replace(/ريال|ر\.?\s*س|SAR/ig,"").trim();return raw||(EN?"0":"٠")} document.documentElement.classList.add("btqOn"); function apply(mode){ document.documentElement.setAttribute("data-btq-theme",mode); try{localStorage.setItem("btq-theme",mode)}catch(e){} var b=document.getElementById("btq-theme"); if(b)b.setAttribute("aria-pressed",mode==="dark"?"true":"false"); } function num(v){return String(v||"0").replace(/[٠-٩]/g,function(d){return "٠١٢٣٤٥٦٧٨٩".indexOf(d)}).replace(/\D/g,"")||"0"} function theme(){ if(document.getElementById("btq-theme"))return true; var row=document.querySelector("#mainnav .container > .flex"); if(!row)return false; var search=document.querySelector("salla-search"),cart=document.querySelector("salla-cart-summary"),user=document.querySelector("salla-user-menu"),logo=document.querySelector(".navbar-brand"),burger=document.querySelector(".mburger"); var img=logo&&logo.querySelector("img"); if(img){img.src=R+"assets/logo-lockup.svg";img.alt="بي بوتيك — btq.sa";img.classList.add("btqLock");img.removeAttribute("width");img.removeAttribute("height")} if(burger){burger.classList.remove("lg:hidden");burger.innerHTML=''+tr("التصنيفات","Categories")+''} var tg=document.createElement("button"); tg.id="btq-theme";tg.type="button";tg.className="btqTg";tg.setAttribute("aria-label",tr("تبديل الوضع الداكن والفاتح","Switch light and dark"));tg.innerHTML=""; tg.onclick=function(){apply(document.documentElement.getAttribute("data-btq-theme")==="dark"?"light":"dark")}; var lang=document.createElement("div"); lang.className="btqLang"; lang.innerHTML='عربيEN'; var pill=document.createElement("button"); pill.type="button";pill.className="btqCart";pill.setAttribute("aria-label",tr("السلة","Cart")); pill.innerHTML=''+tr("سلتك","Your cart")+''+(EN?"0":"٠")+''; function paint(){pill.querySelector("b").textContent=cartMoney(cart)} pill.paint=paint; pill.onclick=function(){var hit=cart&&cart.querySelector("a.s-cart-summary-wrapper");if(hit)hit.click();else location.href=LOC+"/cart"}; paint();setTimeout(paint,700); try{if(window.salla&&salla.cart&&salla.cart.event){salla.cart.event.onUpdated(paint);salla.cart.event.onItemAdded(paint);salla.cart.event.onItemDeleted(paint)}}catch(e){} var acts=document.createElement("div");acts.className="btqActs"; [user,lang,tg,pill].forEach(function(n){if(n)acts.appendChild(n)}); row.classList.add("btqHead"); [burger,search,acts,logo].forEach(function(n){if(n)row.appendChild(n)}); var saved="light";try{saved=localStorage.getItem("btq-theme")||"light"}catch(e){} apply(saved);return true; } function box(h){var d=document.createElement("div");d.innerHTML=h;return d.firstElementChild} var lib,line=[]; function viewer(done){ if(customElements.get("model-viewer")){done();return} if(lib){lib.then(done,function(){step.busy=false});return} lib=new Promise(function(ok,bad){ var s=document.createElement("script"); s.src=R+"assets/f7d94a497f6ce08e6774ae4ecf84c50f.js"; s.async=true; s.onload=function(){try{customElements.get("model-viewer").meshoptDecoderLocation=R+"assets/ea9a1fc9a7eb92d851502e4976a30459.js"}catch(e){}ok()}; s.onerror=bad; document.head.appendChild(s); }); lib.then(done,function(){step.busy=false}); } function step(){ if(step.busy||!line.length)return; step.busy=true; viewer(function(){ var make=line.shift(),v=make&&make(); var go=function(){step.busy=false;step()}; if(!v){go();return} var t=setTimeout(go,12000); var done=function(){clearTimeout(t);matte(v);go()}; if(v.loaded)done();else v.addEventListener("load",done,{once:true}); }); } function matte(v){ try{ var m=v.model; if(m&&m.materials)m.materials.forEach(function(mt){ var pr=mt.pbrMetallicRoughness; try{pr.metallicRoughnessTexture.setTexture(null)}catch(e){} pr.setMetallicFactor(0); pr.setRoughnessFactor(1); }); v.exposure=0.85; var sym=Object.getOwnPropertySymbols(v).find(function(s){return String(s)==="Symbol(scene)"}); var scene=sym&&v[sym]; if(scene&&scene.traverse)scene.traverse(function(o){ if(!o.isMesh||!o.material)return; (Array.isArray(o.material)?o.material:[o.material]).forEach(function(mat){ mat.metalness=0;mat.roughness=1;mat.metalnessMap=null;mat.roughnessMap=null; if("envMapIntensity" in mat)mat.envMapIntensity=0.15; mat.needsUpdate=true; }); }); }catch(e){} } function live(img,src,orbit,still){ line.push(function(){ if(!img||!img.isConnected)return null; var v=document.createElement("model-viewer"); v.setAttribute("alt",img.alt||""); v.setAttribute("poster",img.currentSrc||img.src); v.setAttribute("camera-orbit",orbit); v.setAttribute("interaction-prompt","none"); v.setAttribute("shadow-intensity","0"); v.setAttribute("exposure","0.85"); v.setAttribute("environment-image","neutral"); v.setAttribute("reveal","auto"); if(!still){v.setAttribute("camera-controls","");v.setAttribute("disable-zoom","");v.setAttribute("disable-pan","")} if(still)v.style.cssText="position:absolute;inset:0;width:100%;height:100%;max-width:120px;max-height:120px;background:transparent"; else v.style.cssText="display:block;width:100%;height:100%;max-width:100%;background:transparent"; img.replaceWith(v); v.src=src; return v; }); step(); } function real(hero){ var pics=hero.querySelectorAll(".btqFace img"); var run=function(){ if(pics[2])live(pics[2],R+"models/bisht-sculpture.glb","0deg 75deg 118%"); if(pics[1])live(pics[1],R+"models/travel-tumbler.glb","0deg 75deg 150%"); if(pics[0])live(pics[0],R+"models/watches-saudi-time.glb","0deg 75deg 160%"); }; var idle=window.requestIdleCallback||function(fn){setTimeout(fn,700)}; idle(run); } function page(){ if(document.getElementById("btq-hero"))return true; var products=document.querySelector("[data-testid='store-home-fixed-products']"); if(!products)return location.pathname.indexOf("/edit")===-1&&!/\/(ar|en)\/?$/.test(location.pathname); var reviews=document.querySelector("[data-testid='store-home-testimonials']"); var hero=box('
'+tr(
'+tr(
'+tr(

'+tr("قطع حصرية بهوية سعودية","Exclusive pieces, Saudi identity")+'

'); products.before(hero); (function(){ var ring=hero.querySelector(".btqOrbit"),holds=[].slice.call(ring.children),shown=1,at=1,raf=0,auto=0; function radius(){return Math.min(ring.clientWidth*0.34,230)} function pose(i,deg){var r=deg*Math.PI/180,c=Math.cos(r),el=holds[i];if(!el)return;el.style.transform="translateX("+(Math.sin(r)*radius()).toFixed(1)+"px) translateY("+((1-c)*22).toFixed(1)+"px) scale("+(0.68+0.32*c).toFixed(3)+")";el.style.zIndex=c>0.45?"3":"1"} function draw(t){var i;for(i=0;i<3;i++)pose(i,(i-t)*120)} var hot=false; function go(next){ var from=shown,to=next,t0=performance.now(); clearInterval(auto); if(window.matchMedia&&matchMedia("(prefers-reduced-motion: reduce)").matches){shown=at=to;draw(to);arm();return} cancelAnimationFrame(raf); (function frame(now){var k=Math.min(1,(now-t0)/1100),e=k<0.5?2*k*k:1-Math.pow(-2*k+2,2)/2;shown=from+(to-from)*e;draw(shown);if(k<1)raf=requestAnimationFrame(frame);else{shown=at=to;draw(to);arm()}})(t0); } function arm(){clearInterval(auto);if(hot)return;auto=setInterval(function(){go(at+1)},5200)} ring.addEventListener("pointerenter",function(){hot=true;clearInterval(auto)}); ring.addEventListener("pointerleave",function(){hot=false;arm()}); holds.forEach(function(el,i){var x=0,y=0;el.addEventListener("pointerdown",function(e){x=e.clientX;y=e.clientY});el.addEventListener("pointerup",function(e){if(Math.hypot(e.clientX-x,e.clientY-y)>8)return;if(i!==((Math.round(at)%3)+3)%3)go(i)})}); window.addEventListener("resize",function(){draw(shown)}); requestAnimationFrame(function(){draw(at);arm()}); })(); var cats=box('
'); var title=products.querySelector(".s-block__title"),menu=cats.querySelector(".btqCatMenu"),label=cats.querySelector("span"); if(title)title.before(cats);else products.prepend(cats); function fill(list){menu.textContent="";list.forEach(function(c){var a=document.createElement("a");a.href=c[1];a.textContent=c[0];menu.appendChild(a)})} products.id="btq-products"; fill([[tr("الكل","All"),"#btq-products"],[tr("أكواب","Cups"),"https://btq.sa"+LOC+"/%D8%A3%D9%83%D9%88%D8%A7%D8%A8/c770691679"],[tr("تصميم","Design"),"https://btq.sa"+LOC+"/%D8%AA%D8%B5%D9%85%D9%8A%D9%85/c1167619005"],[tr("كتب","Books"),"https://btq.sa"+LOC+"/%D9%83%D8%AA%D8%A8/c1686764735"],[tr("ساعات","Watches"),"https://btq.sa"+LOC+"/%D8%B3%D8%A7%D8%B9%D8%A7%D8%AA/c1935988606"],[tr("ألعاب","Games"),"https://btq.sa"+LOC+"/%D8%A3%D9%84%D8%B9%D8%A7%D8%A8/c466182504"],[tr("حقائب","Bags"),"https://btq.sa"+LOC+"/%D8%AD%D9%82%D8%A7%D8%A6%D8%A8/c1848104180"],[tr("تحف","Sculptures"),"https://btq.sa"+LOC+"/%D8%AA%D8%AD%D9%81/c701296930"],[tr("ذهب و مجوهرات","Gold and jewelry"),"https://btq.sa"+LOC+"/%D8%B0%D9%87%D8%A8-%D9%88-%D9%85%D8%AC%D9%88%D9%87%D8%B1%D8%A7%D8%AA/c1209433323"],[tr("إكسسوارات","Accessories"),"https://btq.sa"+LOC+"/%D8%A5%D9%83%D8%B3%D8%B3%D9%88%D8%A7%D8%B1%D8%A7%D8%AA/c2010757877"],[tr("ملابس","Clothing"),"https://btq.sa"+LOC+"/%D9%85%D9%84%D8%A7%D8%A8%D8%B3/c1645998116"]]); cats.querySelector("button").onclick=function(){var o=cats.classList.toggle("open");this.setAttribute("aria-expanded",o?"true":"false")}; menu.onclick=function(e){var a=e.target.closest&&e.target.closest("a");if(!a)return;var all=tr("الكل","All");label.textContent=a.textContent===all?tr("التصنيفات","Categories"):tr("التصنيفات: ","Categories: ")+a.textContent;cats.classList.remove("open")}; document.addEventListener("click",function(e){if(!cats.contains(e.target))cats.classList.remove("open")}); fetch(LOC+"/api/v1/categories",{headers:{Accept:"application/json"}}).then(function(r){return r.json()}).then(function(d){var list=[[tr("الكل","All"),"#btq-products"]];(d.data||[]).forEach(function(c){if(c&&c.name&&c.url)list.push([c.name,c.url])});if(list.length>1)fill(list)}).catch(function(){}); var files=[["life-shirt.jpg?v=8",""],["life-write.jpg?v=1","w"],["life-mercedes.jpg?v=1","w"],["life-ring.jpg?v=5",""],["life-together.jpg?v=1","w"]],imgs="",i,k; for(i=0;i<2;i++)for(k=0;k'; var life=box('
'+imgs+"
"); var pour=box('

'+tr("اسكب القهوة","Pour the coffee")+'

'+tr(
'+(EN?"0%":"٠٪")+'
'); var rv=box('

'+tr("آراء العملاء","Reviews")+'

'); var track=rv.querySelector(".btqRvTrack"); function star(n){var s="",i;for(i=0;i<5;i++)s+='';return s} function showNative(){var bar=document.getElementById("btq-pay");rv.remove();if(reviews){reviews.style.display="";if(bar)reviews.after(bar)}} if(reviews)reviews.style.display="none"; fetch(LOC+"/api/v1/reviews?type=store&sort=latest&limit=9",{headers:{Accept:"application/json"}}).then(function(r){return r.json()}).then(function(d){ var list=(d.data||[]).filter(function(x){return x&&x.content&&!x.is_pending}).slice(0,9); if(!list.length){showNative();return} list.forEach(function(x){ var card=document.createElement("article"); card.className="btqRvCard"; card.innerHTML='
“
'+star(x.stars||5)+'

'; card.querySelector("p").textContent=x.content; card.querySelector("b").textContent=(x.name||"").trim()||tr("عميل","Customer"); card.querySelector("span").textContent=x.city||""; track.appendChild(card); }); }).catch(showNative); rv.querySelector(".btqPrev").onclick=function(){var c=track.querySelector(".btqRvCard");track.scrollBy({left:(c?c.getBoundingClientRect().width+16:280),behavior:"smooth"})}; rv.querySelector(".btqNext").onclick=function(){var c=track.querySelector(".btqRvCard");track.scrollBy({left:-(c?c.getBoundingClientRect().width+16:280),behavior:"smooth"})}; var stage=pour.querySelector(".btqStage"),jug=pour.querySelector(".btqJug"),mug=pour.querySelector(".btqCup"),quip=pour.querySelector(".btqQuip"),splash=pour.querySelector(".btqSplash"),rings=pour.querySelectorAll(".btqRing"),bar=pour.querySelector(".btqMeter i"),pct=pour.querySelector(".btqPct"),reset=pour.querySelector(".btqReset"); var L=0,mode="idle",raf=0,last=0,qt=0,drag=null,done=false,MOUTH={x:214,y:321},OFF=0,bought=true,fl=0,flT=0,W=235,REST={x:312,y:397},PRE={fx:.26,fy:.98},autoT=0,AR="٠١٢٣٤٥٦٧٨٩"; var QS=EN?["You have not added me to the cart yet","Nice try. Cart first","I said: cart first","Okay, I am tired. Add me to the cart"]:["لسا ما حطيتني بالسلة!","ولا تحاول، لسا ما حطيتني بالسلة","قلت لك: السلة أول!","هههه تعبتني، حطّني بالسلة"]; function say(t,ms){quip.textContent=t;quip.classList.add("on");clearTimeout(qt);qt=setTimeout(function(){quip.classList.remove("on")},ms||1800)} function paint(){var lv=Math.min(1,L);mug.classList.toggle("has",L>0.02);mug.style.setProperty("--lv",(0.28+0.72*lv).toFixed(3));bar.style.width=(lv*100)+"%";var n=String(Math.round(lv*100));pct.textContent=EN?n+"%":n.replace(/\d/g,function(d){return AR[d]})+"٪"} function ring(){[].forEach.call(rings,function(r,k){r.classList.remove("go");void r.offsetWidth;setTimeout(function(){r.classList.add("go")},k*220)})} function pose(on){if(on){jug.classList.add("pour");jug.style.left=(MOUTH.x-PRE.fx*W)+"px";jug.style.top=(MOUTH.y-PRE.fy*W)+"px";splash.style.left=MOUTH.x+"px";splash.style.top=(MOUTH.y-4)+"px";splash.classList.add("on")}else{jug.classList.remove("pour");splash.classList.remove("on")}} function tick(t){if(mode!=="pour"){raf=0;return}var dt=Math.min(.05,(t-last)/1000);last=t;L+=dt/3.4;if(!done&&Math.random()=1.08&&!done){done=true;mug.classList.add("over");say(tr("فاض! هههه","It overflowed"),2200);reset.classList.add("on")}if(L>=1.25)L=1.25;paint();raf=requestAnimationFrame(tick)} function start(){if(mode==="pour")return;mode="pour";pose(true);ring();last=performance.now();if(!raf)raf=requestAnimationFrame(tick);if(L<.05)say(tr("بالعافية","Enjoy"),1600)} function stop(){mode="idle";pose(false);if(L>0.02)reset.classList.add("on")} function home(){jug.style.left=REST.x+"px";jug.style.top=REST.y+"px"} function overMouth(x,y){return Math.abs(x-MOUTH.x)<95&&yMOUTH.y-170} function moveCup(o){OFF=o;MOUTH.x=214+o;mug.style.transform="translateX("+o+"px)";var sh=stage.querySelector(".btqShadow");if(sh)sh.style.transform="translateX("+o+"px)"} function flee(sx){if(flT)return;flT=setTimeout(function(){flT=0},650);var dir=sx>=MOUTH.x?-1:1;var o=OFF+dir*150;if(o>150||o<-150)o=OFF-dir*150;if(Math.abs(o)>150)o=0;moveCup(o);try{mug.animate([{rotate:"0deg"},{rotate:(dir*-8)+"deg"},{rotate:"0deg"}],{duration:450})}catch(e){}say(QS[fl++%QS.length],2000)} function empty(){reset.classList.remove("on");mug.classList.remove("over");done=false;var s=L,t0=performance.now();(function d(t){var k=Math.min(1,(t-t0)/700);L=s*(1-k);paint();if(k<1)requestAnimationFrame(d);else{L=0;paint()}})(t0);say(tr("جاهزين من جديد!","Ready again"),1400)} function auto(){if(mode==="pour"||autoT)return;if(!bought){flee(MOUTH.x+(OFF>=0?-1:1)*-1);return}if(done){empty();return}start();autoT=setTimeout(function(){stop();home();autoT=0},3600)} jug.addEventListener("pointerdown",function(e){if(e.button!=null&&e.button!==0)return;e.preventDefault();drag={ox:e.clientX,oy:e.clientY,l:parseFloat(jug.style.left)||REST.x,t:parseFloat(jug.style.top)||REST.y,moved:false};jug.classList.add("drag");jug.classList.remove("pour");try{jug.setPointerCapture(e.pointerId)}catch(err){}}); jug.addEventListener("pointermove",function(e){if(!drag)return;var sc=stage.getBoundingClientRect().width/stage.offsetWidth||1;var dx=(e.clientX-drag.ox)/sc,dy=(e.clientY-drag.oy)/sc;if(Math.abs(dx)+Math.abs(dy)>5)drag.moved=true;var x=drag.l+dx,y=drag.t+dy;var sx=x+.25*W,sy=y+.2*W;if(overMouth(sx,sy)&&!bought){flee(sx);jug.style.left=x+"px";jug.style.top=y+"px"}else if(overMouth(sx,sy)){jug.classList.remove("drag");start()}else{if(mode==="pour"){stop();jug.classList.add("drag")}jug.style.left=x+"px";jug.style.top=y+"px"}}); function up(){if(!drag)return;var moved=drag.moved;drag=null;jug.classList.remove("drag");if(mode==="pour")stop();home();if(!moved)auto()} jug.addEventListener("pointerup",up);jug.addEventListener("pointercancel",up); real(hero); reset.onclick=empty; var gift=box('

'+tr("اكتب إهداءك، ونرفقه في كرت مع مشترياتك","Write a note. We put it on a card with your order")+'

'+tr("المحاذاة","Align")+'
'); var plate=gift.querySelector(".btqPlate"),line=gift.querySelector(".btqLine"),noteT=0,AN={right:"يمين",center:"وسط",left:"يسار"}; function dedication(){var t=(line.value||"").replace(/\s+/g," ").trim().slice(0,26);var a=plate.dataset.a||"right";return t?("إهداء: "+t+" — محاذاة: "+(AN[a]||"يمين")):""} function pushNote(){clearTimeout(noteT);noteT=setTimeout(function(){if(!window.salla||!salla.cart||!salla.cart.api)return;var text=dedication();salla.cart.api.details().then(function(d){var items=(d&&d.data&&d.data.cart&&d.data.cart.items)||[];items.forEach(function(it){if(!it||!it.id||(it.notes||"")===text)return;var options=(it.options||[]).map(function(o){var sel=(o.details||[]).filter(function(x){return x.is_selected})[0];return {id:o.id,value:sel?sel.id:o.value}});salla.cart.api.updateItem({id:it.id,quantity:it.quantity||1,notes:text,options:options}).catch(function(){})})}).catch(function(){})},450)} (EN?["For Faisal, with love","To my mother","Congrats","Our home","Just for you"]:["لفيصل، من القلب","إلى أمي","مبروك التخرج","بيتنا","لك وحدك"]).forEach(function(t){ var s=document.createElement("button");s.type="button";s.textContent=t;s.onclick=function(){line.value=t;pushNote()};gift.querySelector(".btqSugs").appendChild(s); }); line.oninput=pushNote; gift.querySelectorAll(".btqAl").forEach(function(b){b.onclick=function(){gift.querySelectorAll(".btqAl").forEach(function(x){x.classList.toggle("on",x===b)});plate.dataset.a=b.dataset.a;pushNote()}}); var saveBtn=gift.querySelector(".btqSave"),printBtn=gift.querySelector(".btqPrint"),cardP=null; function loadImg(url){return fetch(url).then(function(r){return r.text()}).then(function(txt){var m=txt.match(/viewBox\s*=\s*"([^"]+)"/),b=m?m[1].trim().split(/[\s,]+/).map(Number):[],vw=b.length===4?b[2]:0,vh=b.length===4?b[3]:0;return new Promise(function(ok){var im=new Image();im.crossOrigin="anonymous";var u=URL.createObjectURL(new Blob([txt],{type:"image/svg+xml"}));im.onload=function(){if(vw&&vh){im._w=vw;im._h=vh}ok(im)};im.onerror=function(){ok(null)};im.src=u})}).catch(function(){return null})} function cardReady(){ if(cardP)return cardP; var font=(document.fonts&&document.fonts.load)?document.fonts.load('900 112px "Thmanyah Serif Display"').catch(function(){}):Promise.resolve(); cardP=Promise.all([loadImg(R+"assets/e33da441b1b35d0bd32dd59ffd2d3454.svg"),loadImg(R+"assets/logo-lockup.svg"),font]); return cardP; } function makeCard(pat,logo){ var W=2480,H=1500,c=document.createElement("canvas"),ctx=c.getContext("2d"),ph=168; c.width=W;c.height=H; ctx.fillStyle="#fff";ctx.fillRect(0,0,W,H); if(pat&&(pat._w||pat.width)){var pw=(pat._w||pat.width)*(ph/(pat._h||pat.height)),i;ctx.save();ctx.beginPath();ctx.rect(0,0,W,ph);ctx.clip();for(i=-pw;imax){lines.push(cur.replace(/\s+$/,""));cur=ch===" "?"":ch}else cur+=ch} if(cur.trim())lines.push(cur.trim()); if(!lines.length)lines=[""]; var gap=150,logoH=148,top=ph+36,bot=H-230,block=lines.length*gap,y=top+Math.max(0,(bot-top-block)/2)+gap/2; var tx=align==="center"?W/2:align==="left"?160:W-160; lines.forEach(function(ln,n){ctx.fillText(ln,tx,y+n*gap)}); if(logo&&(logo._w||logo.width)){var lw=(logo._w||logo.width)*(logoH/(logo._h||logo.height)),ly=H-96-logoH,lx=align==="center"?(W-lw)/2:align==="left"?160:W-160-lw;ctx.drawImage(logo,lx,ly,lw,logoH)} ctx.strokeStyle="#e6e6e6";ctx.lineWidth=4;ctx.strokeRect(2,2,W-4,H-4); try{c.toDataURL("image/png")}catch(e){return null} return c; } function grab(done){ saveBtn.disabled=true;printBtn.disabled=true; cardReady().then(function(pair){var c=makeCard(pair[0],pair[1]);saveBtn.disabled=false;printBtn.disabled=false;done(c)}).catch(function(){saveBtn.disabled=false;printBtn.disabled=false;done(null)}); } function fileOf(c){ c.toBlob(function(blob){ if(!blob)return; var a=document.createElement("a"),old=saveBtn.textContent; a.href=URL.createObjectURL(blob);a.download="btq-card.png"; document.body.appendChild(a);a.click();a.remove(); setTimeout(function(){URL.revokeObjectURL(a.href)},2500); saveBtn.textContent=tr("تم الحفظ","Saved"); setTimeout(function(){saveBtn.textContent=old},1600); },"image/png"); } function paper(c,win){ var url=c.toDataURL("image/png"); var html=''+tr("كرت الإهداء","Gift card")+''; var w=win; if(!w||w.closed)w=window.open("","btqCard"); if(w){w.document.open();w.document.write(html);w.document.close();setTimeout(function(){try{w.focus();w.print()}catch(e){}},300);return} var frame=document.getElementById("btq-print"); if(!frame){frame=document.createElement("iframe");frame.id="btq-print";frame.setAttribute("aria-hidden","true");frame.style.cssText="position:fixed;width:0;height:0;border:0";document.body.appendChild(frame)} var doc=frame.contentWindow.document;doc.open();doc.write(html);doc.close(); setTimeout(function(){try{frame.contentWindow.focus();frame.contentWindow.print()}catch(e){}},300); } saveBtn.onclick=function(){grab(function(c){if(c)fileOf(c)})}; printBtn.onclick=function(){var w=window.open("","btqCard");if(w){w.document.open();w.document.write(""+tr("كرت الإهداء","Gift card")+"

"+tr("جارٍ تجهيز الكرت…","Preparing the card…")+"

");w.document.close()}grab(function(c){if(c)paper(c,w);else if(w&&!w.closed)w.close()})}; try{if(window.salla&&salla.cart&&salla.cart.event)salla.cart.event.onItemAdded(pushNote)}catch(e){} products.after(life);life.after(pour);pour.after(rv);if(reviews)reviews.after(gift);else rv.after(gift); home(); return true; } function pay(){ if(document.getElementById("btq-pay"))return true; var src=document.querySelector("salla-payments"); var root=src&&(src.shadowRoot||src); if(!root)return false; var imgs=[].slice.call(root.querySelectorAll("img")); if(!imgs.length)return false; var rank={tabby_installment:0,tamara_installment:1,SBC:2}; imgs.sort(function(a,b){var ra=a.alt in rank?rank[a.alt]:9,rb=b.alt in rank?rank[b.alt]:9;return ra-rb||0}); var bar=document.createElement("div"); bar.id="btq-pay";bar.className="btqPay"; imgs.forEach(function(im){ var n=document.createElement("img"); n.src=im.currentSrc||im.src; n.alt=im.alt==="SBC"?"موثوق":(im.alt||""); bar.appendChild(n); }); var anchor=document.querySelector("[data-testid='store-home-testimonials']")||document.querySelector(".btqRv"); if(!anchor)return false; anchor.after(bar); return true; } function boot(){return theme()&&page()&&pay()} if(!boot()){var n=0,wait=setInterval(function(){if(boot()||++n>20)clearInterval(wait)},300)} })();