@neurodyn/core-ar 0.2.6 → 0.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core-ar.embed.min.js +2 -2
- package/dist/index.js +8 -4
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(()=>{"use strict";let e,t,i;function r(e,t){let i;try{i=new URL(e)}catch{throw TypeError(`${t} must be an absolute HTTP(S) URL`)}if("http:"!==i.protocol&&"https:"!==i.protocol)throw TypeError(`${t} must be an absolute HTTP(S) URL`);return i.origin}function n(){if(!e)throw Error("Core AR widget runtime is not configured");return e}function o(){return"u"<typeof navigator?"":navigator.userAgent||navigator.vendor||""}function a(){if("u"<typeof window||"u"<typeof navigator)return!1;let e="MacIntel"===navigator.platform&&navigator.maxTouchPoints>1;return(/iPad|iPhone|iPod/.test(o())||e)&&!("MSStream"in window)}function s(){if("u"<typeof window||"u"<typeof navigator)return!1;let e=navigator.maxTouchPoints>1,t=window.matchMedia?.("(pointer: coarse)").matches??!1,i=/Android|iPhone|iPad|iPod|webOS|BlackBerry|Windows Phone|Opera Mini|IEMobile|Mobile/i.test(o());return e&&t&&(i||a())}function d(){let e=o();return[[/edg/i,"Microsoft Edge"],[/trident/i,"Microsoft Internet Explorer"],[/firefox|fxios/i,"Mozilla Firefox"],[/opr\//i,"Opera"],[/ucbrowser/i,"UC Browser"],[/samsungbrowser/i,"Samsung Browser"],[/chrome|chromium|crios/i,"Google Chrome"],[/safari/i,"Apple Safari"]].find(([t])=>t.test(e))?.[1]??"Other"}function l(){let e=function(){let e=o(),t=e.match(/\bOS (\d+)/)?.[1]??e.match(/Version\/(\d+)/)?.[1];if(!t)return null;let i=Number.parseInt(t,10);return Number.isNaN(i)?null:i}();return null!==e&&e>=17}function c(e){let t;try{t=new URL(e)}catch{throw TypeError("Native AR asset URL must be absolute HTTP(S)")}if("http:"!==t.protocol&&"https:"!==t.protocol)throw TypeError("Native AR asset URL must be absolute HTTP(S)");return t.href}function u(e,t){let i=c(e.glbUrl),r=c(e.usdzUrl),n=encodeURIComponent(i),o=`intent://arvr.google.com/scene-viewer/1.0?file=${n}&resizable=false${"wall"===t||"ceiling"===t?"&enable_vertical_placement=true":""}&mode=ar_preferred#Intent;scheme=https;package=com.google.android.googlequicksearchbox;action=android.intent.action.VIEW;end;`,s=`${r}#allowsContentScaling=0`;return a()?s:o}function g(e,t=0){let i=document.createElement("a"),r=document.createElement("img");i.rel="ar",i.href=e,i.hidden=!0,r.alt="",r.hidden=!0,i.appendChild(r),document.body.appendChild(i),window.setTimeout(()=>{i.click(),i.remove()},t)}function m(e,t,i){let r=function(e,t,i){let{brand:r}=i??n();if(a()){let i=new URL("https://appclip.apple.com/id");return i.searchParams.set("p","com.us.vizbl.Clip"),i.searchParams.set("tinuuid",e),t&&i.searchParams.set("hid",t),i.searchParams.set("region","arizo"===r?"ru":"en"),i.toString()}return`intent:/${window.location.pathname}#Intent;scheme=open;package=com.us.vizbl;end`}(e,t,i);window.self===window.top||d().toLowerCase().includes("edge")?window.location.assign(r):window.open(r,"_top")}function h(e,t,i=!1,r){let{viewerOrigin:o}=r??n(),a=new URL("/ar/index.html",o);return a.searchParams.set("tinuuid",e),t&&a.searchParams.set("hid",t),i&&a.searchParams.set("appview","true"),a.toString()}function p(){let e=new WeakMap;return function(t){let i=e.get(t);i?.cleanup?.();let r={revision:(i?.revision??0)+1};return e.set(t,r),{isCurrent:()=>e.get(t)===r,register(i){let n=!1,o=()=>{n||(n=!0,i())};return e.get(t)!==r?(o(),o):(r.cleanup=o,()=>{e.get(t)===r&&e.delete(t),o()})}}}}let f=0,b={arizo:{conjunction:"и",privacyLabel:"Политика конфиденциальности",privacyUrl:"https://arizo.ru/privacy-policy/",termsLabel:"Условия использования",termsUrl:"https://arizo.ru/terms-of-use/"},vizbl:{conjunction:"and",privacyLabel:"Privacy Policy",privacyUrl:"https://vizbl.com/legal/privacy-policy",termsLabel:"Terms of Use",termsUrl:"https://vizbl.com/legal/terms-of-use"}};function v(){return window.QRCode}function w(e,t,i){let r=document.createElement("a");return r.dataset.vizblLegalLink=e,r.href=t,r.rel="noopener noreferrer",r.target="_blank",r.textContent=i,Object.assign(r.style,{color:"inherit",textDecoration:"underline",textUnderlineOffset:"2px",whiteSpace:"nowrap"}),r}async function y(e,r="vizblQrModal",o,a){let s,d=++f;i?.(),document.querySelectorAll("[data-vizbl-qr-modal]").forEach(e=>e.remove());let l=function(e){let{brand:t,viewerOrigin:i}=e??n(),r="arizo"===t,o=document.createElement("div");o.dataset.vizblQrModal="",o.setAttribute("aria-label","View object in augmented reality"),o.setAttribute("aria-modal","true"),o.setAttribute("role","dialog"),Object.assign(o.style,{alignItems:"center",backgroundColor:"rgba(0,0,0,0.25)",display:"none",height:"100%",justifyContent:"center",left:"0",position:"fixed",top:"0",width:"100%",zIndex:"9999"});let a=document.createElement("div");Object.assign(a.style,{backgroundColor:"#fff",borderRadius:"12px",boxSizing:"border-box",color:"#000",fontFamily:"Inter, sans-serif",minHeight:"372px",padding:"48px 52px 40px",position:"relative",width:"min(460px, calc(100vw - 32px))"});let s=document.createElement("button");s.type="button",s.dataset.vizblQrClose="",s.setAttribute("aria-label","Close QR code"),s.textContent="\xd7",Object.assign(s.style,{background:"none",border:"none",color:"#AEB1B7",cursor:"pointer",fontSize:"24px",position:"absolute",right:"20px",top:"20px"});let d=document.createElement("div");d.dataset.vizblQrCode="",d.style.margin="0 auto",d.style.width="fit-content";let l=document.createElement("p");l.textContent=r?"Отсканируйте этот QR-код камерой телефона, чтобы примерить объект в интерьере":"Scan this QR code with your phone camera to view the object in Augmented Reality",Object.assign(l.style,{fontSize:"16px",fontWeight:"500",lineHeight:"24px",margin:"24px 0 0",textAlign:"center"});let c=document.createElement("p");Object.assign(c.style,{color:"#93979F",fontSize:"12px",lineHeight:"16px",margin:"12px 0 0",textAlign:"center"});let u=b[t],g=w("terms",u.termsUrl,u.termsLabel),m=w("privacy",u.privacyUrl,u.privacyLabel);c.append(r?"*Требуется устройство и браузер с поддержкой AR. Рекомендуем iOS 12 или новее с Safari либо Android 7.0 или новее с Chrome.":"*Requires an AR-compatible device and browser. We recommend iOS 12 or later with Safari, or Android 7.0 or later with Chrome.",document.createElement("br"),g,` ${u.conjunction} `,m);let h=document.createElement("p");h.textContent=`Powered by ${r?"Arizo":"Vizbl"}`,Object.assign(h.style,{color:"#93979F",fontSize:"11px",letterSpacing:"1.5px",margin:"24px 0 4px",textAlign:"center",textTransform:"uppercase"});let p=document.createElement("a");p.dataset.vizblBrandLink="",p.href=r?"https://arizo.ru":"https://vizbl.com",p.style.display="block",p.style.textAlign="center";let f=document.createElement("img");return f.alt=`${r?"Arizo":"Vizbl"} logo`,f.src=`${i}/${r?"logoArizo.svg":"logo.svg"}`,f.height=20,f.width=r?76:60,p.appendChild(f),a.append(s,d,l,c,h,p),o.appendChild(a),o}(a);l.id=r;let c=l.querySelector("[data-vizbl-qr-close]"),u=Array.from(l.querySelectorAll("button, a[href]")),g=!1,m=e=>{if("Escape"===e.key){e.preventDefault(),s();return}if("Tab"!==e.key||0===u.length)return;let t=u[0],i=u.at(-1)??t;e.shiftKey&&(document.activeElement===t||!l.contains(document.activeElement))?(e.preventDefault(),i.focus()):e.shiftKey||document.activeElement!==i||(e.preventDefault(),t.focus())};i=s=()=>{g||(g=!0,document.removeEventListener("keydown",m),l.remove(),i===s&&(i=void 0),o?.focus({preventScroll:!0}))},c?.addEventListener("click",s),l.addEventListener("click",e=>{e.target===l&&s()}),document.body.appendChild(l),document.addEventListener("keydown",m),function(){let e="https://fonts.googleapis.com/css2?family=Inter&display=swap";if(Array.from(document.querySelectorAll('link[rel="stylesheet"]')).some(t=>t.href===e||t.getAttribute("href")===e))return;let t=document.createElement("link");t.rel="stylesheet",t.href=e,document.head.appendChild(t)}();try{let i=await function(e){let i=v();if(i)return Promise.resolve(i);if(t)return t;let{qrCodeScriptUrl:r}=e??n();return t=new Promise((e,i)=>{let n,o=document.createElement("script"),a=()=>{n();let r=v();r?e(r):(o.remove(),t=void 0,i(Error("QR code runtime did not expose QRCode")))},s=()=>{n(),o.remove(),t=void 0,i(Error("Failed to load QR code runtime"))};n=()=>{o.removeEventListener("load",a),o.removeEventListener("error",s)},o.addEventListener("load",a,{once:!0}),o.addEventListener("error",s,{once:!0}),o.src=r,o.async=!0,o.dataset.vizblQrScript="true",document.head.appendChild(o)})}(a);if(d!==f||!l.isConnected)return s(),s;let r=l.querySelector("[data-vizbl-qr-code]");return r&&new i(r,{correctLevel:i.CorrectLevel.L,height:148,text:e,width:148}),l.style.display="flex",c?.focus({preventScroll:!0}),s}catch(e){throw s(),e}}class E extends Error{code;constructor(e){super(e),this.code=e,this.name="WidgetRuntimeError"}}function A(e){return e.runtimeConfig??n()}function C(e,t,i={}){let r=new URL(t,e);for(let[e,t]of Object.entries(i))t&&r.searchParams.set(e,t);return r.toString()}async function I(e,t,i){try{return await (i.fetchImpl??i.runtimeConfig?.fetchImpl??n().fetchImpl)(e,{...t,signal:i.signal})}catch(e){if(e instanceof DOMException&&"AbortError"===e.name)throw e;throw new E("NETWORK_ERROR")}}async function x(e){try{let t=await e.json();return[t.code,t.error,t.message].flatMap(e=>Array.isArray(e)?e:[e]).filter(e=>"string"==typeof e).join(" ").toLowerCase()}catch{return""}}async function O(e,t){let i=await x(e);return new E(429===e.status?"RATE_LIMITED":e.status>=500?"API_UNAVAILABLE":404===e.status&&"object"===t?"OBJECT_NOT_FOUND":i.includes("domain")||i.includes("origin")?"DOMAIN_NOT_ALLOWED":i.includes("revoked")?"KEY_REVOKED":i.includes("expired")?"activation"===t?"KEY_EXPIRED":"SESSION_EXPIRED":i.includes("policy")||i.includes("not available for this object")?"POLICY_DENIED":401===e.status||403===e.status?"activation"===t?"INVALID_KEY":"SESSION_EXPIRED":"REQUEST_FAILED")}async function S(e){try{return await e.json()}catch{throw new E("INVALID_RESPONSE")}}function k(e){if(!e||"object"!=typeof e||"string"!=typeof e.token||!e.token.trim()||"string"!=typeof e.sid||!e.sid.trim()||"number"!=typeof e.expiresIn||!Number.isFinite(e.expiresIn)||e.expiresIn<=0)throw new E("INVALID_RESPONSE");return e}async function T(e,t={}){let{apiOrigin:i}=A(t),r=await I(C(i,"/public/widget/activate-core",{mode:t.mode}),{cache:"no-store",headers:{"x-api-key":e},method:"POST"},t);if(!r.ok)throw await O(r,"activation");let n=await S(r);if("string"!=typeof n.productType)throw new E("INVALID_RESPONSE");return{...k(n.widgetSession),productType:n.productType}}async function L(e,t,i={}){let{apiOrigin:r}=A(i),n=await I(`${r}/public/widget/token`,{body:JSON.stringify({token:t,...i.mode?{mode:i.mode}:{}}),cache:"no-store",headers:{"Content-Type":"application/json","x-api-key":e},method:"POST"},i);if(!n.ok)throw await O(n,"token");return k(await S(n))}async function z(e,t,i={}){let{apiOrigin:r}=A(i),n=await I(C(r,`/public/objects/by-tinuuid/${encodeURIComponent(e)}`,{variantId:i.variantId}),{cache:"no-store",headers:{"x-widget-session-token":t},method:"GET"},i);if(!n.ok)throw await O(n,"object");let o=await S(n);if(!o||"object"!=typeof o||Array.isArray(o))throw new E("INVALID_RESPONSE");return o}async function R(e,t,i,r={}){let{apiOrigin:n}=A(r),o=await I(`${n}/public/widget/events`,{body:JSON.stringify({event:e,...i?{objectId:i}:{},...r.variantId?{variantId:r.variantId}:{},timestamp:new Date().toISOString()}),cache:"no-store",headers:{"Content-Type":"application/json","x-widget-session-token":t},keepalive:!0,method:"POST"},r);if(!o.ok)throw await O(o,"event");let a=await S(o);if(!a||"object"!=typeof a||Array.isArray(a)||"boolean"!=typeof a.ok)throw new E("INVALID_RESPONSE")}async function N(e,t,i){let r=i??n(),{fetchImpl:o,legacyApiOrigin:a}=r,s=await I(`${a}/obj/Fetch`,{body:JSON.stringify({tinuuid:e}),headers:{"Content-Type":"application/json"},method:"POST"},{fetchImpl:o,runtimeConfig:r,signal:t});if(!s.ok)throw await O(s,"object");let d=await S(s);if(!d||"object"!=typeof d||Array.isArray(d))throw new E("INVALID_RESPONSE");return d}async function P(e,t){let{fetchImpl:i,legacyApiOrigin:r}=t??n();await i(`${r}/obj/IncrViews`,{body:JSON.stringify({tinuuid:e}),headers:{"Content-Type":"application/json"},method:"POST"})}function D(e){try{let t=e?.();t instanceof Promise&&t.catch(()=>void 0)}catch{}}let j=p();function _(e){if(e?.aborted)throw new DOMException("Aborted","AbortError")}async function U(e,t={}){let i,r,n=j(e),o=e.getAttribute("data-native-link"),c=e.dataset.objectTinuuid?.trim(),p=e.dataset.objectHid?.trim()||void 0;if(!c)throw Error("Object ID is required");_(t.signal);let f=t.loadObject??((e,i)=>N(e,i,t.runtimeConfig)),b=t.object??await f(c,t.signal);if(_(t.signal),!n.isCurrent())return()=>void 0;let v=p?b.materials.find(e=>e.hid===p):b.materials[0];if(!v?.native?.glbUrl||!v.native.usdzUrl)throw Error("Native AR assets are unavailable");let w=u(v.native,b.type),E=s(),A=!1,C=0;e.querySelector("img")||((i=document.createElement("img")).alt="",i.hidden=!0,e.appendChild(i));let I=()=>t.trackView?t.trackView():P(c,t.runtimeConfig),x=i=>{i.preventDefault();let o=++C;r?.(),r=void 0,Promise.resolve(t.getDesktopQrUrl?.()??h(c,p,!0,t.runtimeConfig)).then(i=>{if(o===C&&n.isCurrent())return D(()=>t.onAction?.("interacted")),y(i,`vizbl-${c}`,e,t.runtimeConfig)}).then(e=>{if(e){if(o!==C||!n.isCurrent())return void e();r=e}}).catch(()=>void 0)},O=async e=>{let i;if(i=d().toLowerCase(),["firefox","edge","opera"].some(e=>i.includes(e))){if(e.preventDefault(),A)return;A=!0,D(()=>t.onAction?.("ar_launched"));try{await Promise.resolve(I()).catch(()=>void 0)}finally{A=!1,a()&&l()?m(c,p,t.runtimeConfig):g(w)}return}D(()=>t.onAction?.("ar_launched")),D(I),a()&&l()?(e.preventDefault(),m(c,p,t.runtimeConfig)):g(w)};return E?(e.dataset.nativeLink=w,e.addEventListener("click",O)):e.addEventListener("click",x),n.register(()=>{C+=1,e.removeEventListener("click",x),e.removeEventListener("click",O),r?.(),i?.remove(),null===o?e.removeAttribute("data-native-link"):e.setAttribute("data-native-link",o)})}var V=!1;if("u">typeof window){var M={get passive(){V=!0;return}};window.addEventListener("testPassive",null,M),window.removeEventListener("testPassive",null,M)}var $="u">typeof window&&window.navigator&&window.navigator.platform&&(/iP(ad|hone|od)/.test(window.navigator.platform)||"MacIntel"===window.navigator.platform&&window.navigator.maxTouchPoints>1),B=[],q=!1,H=-1,W=void 0,F=void 0,K=void 0,Q=function(e){return B.some(function(t){return!!(t.options.allowTouchMove&&t.options.allowTouchMove(e))})},Y=function(e){var t=e||window.event;return!!Q(t.target)||t.touches.length>1||(t.preventDefault&&t.preventDefault(),!1)},X=function(e){if(void 0===K){var t=!!e&&!0===e.reserveScrollBarGap,i=window.innerWidth-document.documentElement.clientWidth;if(t&&i>0){var r=parseInt(window.getComputedStyle(document.body).getPropertyValue("padding-right"),10);K=document.body.style.paddingRight,document.body.style.paddingRight=r+i+"px"}}void 0===W&&(W=document.body.style.overflow,document.body.style.overflow="hidden")},J=function(){void 0!==K&&(document.body.style.paddingRight=K,K=void 0),void 0!==W&&(document.body.style.overflow=W,W=void 0)},Z=function(){if(void 0!==F){var e=-parseInt(document.body.style.top,10),t=-parseInt(document.body.style.left,10);document.body.style.position=F.position,document.body.style.top=F.top,document.body.style.left=F.left,window.scrollTo(t,e),F=void 0}},G=function(e,t){var i=e.targetTouches[0].clientY-H;return!Q(e.target)&&(t&&0===t.scrollTop&&i>0?Y(e):t&&t.scrollHeight-t.scrollTop<=t.clientHeight&&i<0?Y(e):(e.stopPropagation(),!0))},ee=function(e,t){e?!B.some(function(t){return t.targetElement===e})&&(B=[].concat(function(e){if(!Array.isArray(e))return Array.from(e);for(var t=0,i=Array(e.length);t<e.length;t++)i[t]=e[t];return i}(B),[{targetElement:e,options:t||{}}]),$?window.requestAnimationFrame(function(){if(void 0===F){F={position:document.body.style.position,top:document.body.style.top,left:document.body.style.left};var e=window,t=e.scrollY,i=e.scrollX,r=e.innerHeight;document.body.style.position="fixed",document.body.style.top=-t,document.body.style.left=-i,setTimeout(function(){return window.requestAnimationFrame(function(){var e=r-window.innerHeight;e&&t>=r&&(document.body.style.top=-(t+e))})},300)}}):X(t),$&&(e.ontouchstart=function(e){1===e.targetTouches.length&&(H=e.targetTouches[0].clientY)},e.ontouchmove=function(t){1===t.targetTouches.length&&G(t,e)},q||(document.addEventListener("touchmove",Y,V?{passive:!1}:void 0),q=!0))):console.error("disableBodyScroll unsuccessful - targetElement must be provided when calling disableBodyScroll on IOS devices.")},et=function(e){e?(B=B.filter(function(t){return t.targetElement!==e}),$&&(e.ontouchstart=null,e.ontouchmove=null,q&&0===B.length&&(document.removeEventListener("touchmove",Y,V?{passive:!1}:void 0),q=!1)),$?Z():J()):console.error("enableBodyScroll unsuccessful - targetElement must be provided when calling enableBodyScroll on IOS devices.")};let ei=["cm","inch"],er=["x","y","z"],en=[...er],eo="vizbl_viewer",ea=p();function es(e){return e&&ei.includes(e)?e:"inch"}function ed(e){if(!e)return en;let t=Array.from(new Set(e.split(",").map(e=>e.trim().toLowerCase()).filter(e=>er.includes(e))));return t.length>0?t:en}function el(e){let t=new URL("/model-viewer",e.modelViewerOrigin??n().modelViewerOrigin),i=e.dimensionAxes??en;t.searchParams.set("tinuuid",e.tinuuid),e.hid&&t.searchParams.set("hid",e.hid),t.searchParams.set("size-type",e.sizeType),i.length<en.length&&t.searchParams.set("dimension-axes",i.join(",")),e.cameraOrbit&&t.searchParams.set("camera-orbit",e.cameraOrbit),e.minCameraOrbit&&t.searchParams.set("min-camera-orbit",e.minCameraOrbit),e.maxCameraOrbit&&t.searchParams.set("max-camera-orbit",e.maxCameraOrbit);let r=new URLSearchParams;return e.apiKey&&r.set("api-key",e.apiKey),e.mode&&r.set("mode",e.mode),e.widgetSessionToken&&r.set("widget-session-token",e.widgetSessionToken),t.hash=r.toString(),t.toString()}let ec=p();function eu(e){if(e?.aborted)throw new DOMException("Aborted","AbortError")}async function eg(e,t={}){let i,r,n=ec(e),o=e.getAttribute("href"),a=e.getAttribute("rel"),d=e.dataset.objectTinuuid?.trim(),l=e.dataset.objectHid?.trim()||void 0;if(!d)throw Error("Object ID is required");eu(t.signal);let c=t.loadObject??((e,i)=>N(e,i,t.runtimeConfig)),g=t.object??await c(d,t.signal);if(eu(t.signal),!n.isCurrent())return()=>void 0;let m=l?g.materials.find(e=>e.hid===l):g.materials[0];if(!m?.native?.glbUrl||!m.native.usdzUrl)throw Error("Native AR assets are unavailable");let p=u(m.native,g.type),f=s(),b=0;e.rel="ar",e.querySelector("img")||((i=document.createElement("img")).alt="",i.hidden=!0,e.appendChild(i));let v=i=>{i.preventDefault();let o=++b;r?.(),r=void 0,Promise.resolve(t.getDesktopQrUrl?.()??h(d,l,!1,t.runtimeConfig)).then(i=>{if(o===b&&n.isCurrent())return D(()=>t.onAction?.("interacted")),y(i,`vizbl-${d}`,e,t.runtimeConfig)}).then(e=>{if(e){if(o!==b||!n.isCurrent())return void e();r=e}}).catch(()=>void 0)},w=()=>{D(t.trackView??(()=>P(d,t.runtimeConfig))),D(()=>t.onAction?.("ar_launched"))};return f?(e.href=p,e.addEventListener("click",w)):(e.href="#",e.addEventListener("click",v)),n.register(()=>{b+=1,e.removeEventListener("click",v),e.removeEventListener("click",w),r?.(),i?.remove(),null===o?e.removeAttribute("href"):e.setAttribute("href",o),null===a?e.removeAttribute("rel"):e.setAttribute("rel",a)})}let em=["advanced-ar","ar-one-click","ar-viewer"],eh={arizo:"arizo-core",vizbl:"vizbl-core"},ep=new Set(["core-ar","core-ar-shopify"]),ef={"advanced-ar":"View in advanced AR","ar-one-click":"View in AR","ar-viewer":"View in 3D & AR"},eb={"advanced-ar":"advanced-ar-view","ar-one-click":"ar-view","ar-viewer":"ar-viewer"},ev=["api-key","camera-orbit","dev","dimension-axes","max-camera-orbit","min-camera-orbit","object-id","size-type","trigger-class","type","variant-id"],ew=new Set(["API_UNAVAILABLE","INVALID_RESPONSE","NETWORK_ERROR","REQUEST_FAILED","SESSION_EXPIRED"]),ey="core-ar-widget-styles";class eE extends Error{code;constructor(e){super(e),this.code=e,this.name="CoreArWidgetComponentError"}}function eA(e){return em.includes(e)}function eC(e,t){let i=Array.isArray(e.materials)?e.materials:[],r=t?i.find(e=>e.hid===t):i[0];if(!r)throw new eE(t?"VARIANT_NOT_FOUND":"MODEL_UNAVAILABLE");return r}function eI(e,t){if("ar-one-click"===e&&t.policy?.instantArView===!1)throw new eE("POLICY_DENIED")}let ex="u"<typeof HTMLElement?class{}:HTMLElement;class eO extends ex{static get observedAttributes(){return[...ev]}get triggerClass(){return this.getAttribute("trigger-class")??""}set triggerClass(e){let t="string"==typeof e?e.trim():"";t?this.setAttribute("trigger-class",t):this.removeAttribute("trigger-class")}get unstyled(){return this.hasAttribute("unstyled")}set unstyled(e){this.toggleAttribute("unstyled",!!e)}abortController;actionResetTimer;cleanup;customLabelNodes=null;initializationRevision=0;object;queued=!1;session;trigger;variantId;widgetMode;connectedCallback(){!function(){if(document.getElementById(ey))return;let e=document.createElement("style");e.id=ey,e.textContent=`
|
|
1
|
+
(()=>{"use strict";let e,t,i;function r(e,t){let i;try{i=new URL(e)}catch{throw TypeError(`${t} must be an absolute HTTP(S) URL`)}if("http:"!==i.protocol&&"https:"!==i.protocol)throw TypeError(`${t} must be an absolute HTTP(S) URL`);return i.origin}function n(){if(!e)throw Error("Core AR widget runtime is not configured");return e}function o(){return"u"<typeof navigator?"":navigator.userAgent||navigator.vendor||""}function a(){if("u"<typeof window||"u"<typeof navigator)return!1;let e="MacIntel"===navigator.platform&&navigator.maxTouchPoints>1;return(/iPad|iPhone|iPod/.test(o())||e)&&!("MSStream"in window)}function s(){if("u"<typeof window||"u"<typeof navigator)return!1;let e=navigator.maxTouchPoints>1,t=window.matchMedia?.("(pointer: coarse)").matches??!1,i=/Android|iPhone|iPad|iPod|webOS|BlackBerry|Windows Phone|Opera Mini|IEMobile|Mobile/i.test(o());return e&&t&&(i||a())}function d(){let e=o();return[[/edg/i,"Microsoft Edge"],[/trident/i,"Microsoft Internet Explorer"],[/firefox|fxios/i,"Mozilla Firefox"],[/opr\//i,"Opera"],[/ucbrowser/i,"UC Browser"],[/samsungbrowser/i,"Samsung Browser"],[/chrome|chromium|crios/i,"Google Chrome"],[/safari/i,"Apple Safari"]].find(([t])=>t.test(e))?.[1]??"Other"}function l(){let e=function(){let e=o(),t=e.match(/\bOS (\d+)/)?.[1]??e.match(/Version\/(\d+)/)?.[1];if(!t)return null;let i=Number.parseInt(t,10);return Number.isNaN(i)?null:i}();return null!==e&&e>=17}function c(e){let t;try{t=new URL(e)}catch{throw TypeError("Native AR asset URL must be absolute HTTP(S)")}if("http:"!==t.protocol&&"https:"!==t.protocol)throw TypeError("Native AR asset URL must be absolute HTTP(S)");return t.href}function u(e,t){let i=c(e.glbUrl),r=c(e.usdzUrl),n=encodeURIComponent(i),o=`intent://arvr.google.com/scene-viewer/1.0?file=${n}&resizable=false${"wall"===t||"ceiling"===t?"&enable_vertical_placement=true":""}&mode=ar_preferred#Intent;scheme=https;package=com.google.android.googlequicksearchbox;action=android.intent.action.VIEW;end;`,s=`${r}#allowsContentScaling=0`;return a()?s:o}function g(e,t=0){let i=document.createElement("a"),r=document.createElement("img");i.rel="ar",i.href=e,i.hidden=!0,r.alt="",r.hidden=!0,i.appendChild(r),document.body.appendChild(i),window.setTimeout(()=>{i.click(),i.remove()},t)}function m(e,t,i){let r=function(e,t,i){let{brand:r}=i??n();if(a()){let i=new URL("https://appclip.apple.com/id");return i.searchParams.set("p","com.us.vizbl.Clip"),i.searchParams.set("tinuuid",e),t&&i.searchParams.set("hid",t),i.searchParams.set("region","arizo"===r?"ru":"en"),i.toString()}return`intent:/${window.location.pathname}#Intent;scheme=open;package=com.us.vizbl;end`}(e,t,i);window.self===window.top||d().toLowerCase().includes("edge")?window.location.assign(r):window.open(r,"_top")}function h(e,t,i=!1,r){let{viewerOrigin:o}=r??n(),a=new URL("/ar/index.html",o);return a.searchParams.set("tinuuid",e),t&&a.searchParams.set("hid",t),i&&a.searchParams.set("appview","true"),a.toString()}function p(){let e=new WeakMap;return function(t){let i=e.get(t);i?.cleanup?.();let r={revision:(i?.revision??0)+1};return e.set(t,r),{isCurrent:()=>e.get(t)===r,register(i){let n=!1,o=()=>{n||(n=!0,i())};return e.get(t)!==r?(o(),o):(r.cleanup=o,()=>{e.get(t)===r&&e.delete(t),o()})}}}}let f=0,b={arizo:{conjunction:"и",privacyLabel:"Политика конфиденциальности",privacyUrl:"https://arizo.ru/privacy-policy/",termsLabel:"Условия использования",termsUrl:"https://arizo.ru/terms-of-use/"},vizbl:{conjunction:"and",privacyLabel:"Privacy Policy",privacyUrl:"https://vizbl.com/legal/privacy-policy",termsLabel:"Terms of Use",termsUrl:"https://vizbl.com/legal/terms-of-use"}};function v(){return window.QRCode}function w(e,t,i){let r=document.createElement("a");return r.dataset.vizblLegalLink=e,r.href=t,r.rel="noopener noreferrer",r.target="_blank",r.textContent=i,Object.assign(r.style,{color:"inherit",textDecoration:"underline",textUnderlineOffset:"2px",whiteSpace:"nowrap"}),r}async function y(e,r="vizblQrModal",o,a){let s,d=++f;i?.(),document.querySelectorAll("[data-vizbl-qr-modal]").forEach(e=>e.remove());let l=function(e){let{brand:t,viewerOrigin:i}=e??n(),r="arizo"===t,o=document.createElement("div");o.dataset.vizblQrModal="",o.setAttribute("aria-label","View object in augmented reality"),o.setAttribute("aria-modal","true"),o.setAttribute("role","dialog"),Object.assign(o.style,{alignItems:"center",backgroundColor:"rgba(0,0,0,0.25)",display:"none",height:"100%",justifyContent:"center",left:"0",position:"fixed",top:"0",width:"100%",zIndex:"9999"});let a=document.createElement("div");Object.assign(a.style,{backgroundColor:"#fff",borderRadius:"12px",boxSizing:"border-box",color:"#000",fontFamily:"Inter, sans-serif",minHeight:"372px",padding:"48px 52px 40px",position:"relative",width:"min(460px, calc(100vw - 32px))"});let s=document.createElement("button");s.type="button",s.dataset.vizblQrClose="",s.setAttribute("aria-label","Close QR code"),s.textContent="\xd7",Object.assign(s.style,{background:"none",border:"none",color:"#AEB1B7",cursor:"pointer",fontSize:"24px",position:"absolute",right:"20px",top:"20px"});let d=document.createElement("div");d.dataset.vizblQrCode="",d.style.margin="0 auto",d.style.width="fit-content";let l=document.createElement("p");l.textContent=r?"Отсканируйте этот QR-код камерой телефона, чтобы примерить объект в интерьере":"Scan this QR code with your phone camera to view the object in Augmented Reality",Object.assign(l.style,{fontSize:"16px",fontWeight:"500",lineHeight:"24px",margin:"24px 0 0",textAlign:"center"});let c=document.createElement("p");Object.assign(c.style,{color:"#93979F",fontSize:"12px",lineHeight:"16px",margin:"12px 0 0",textAlign:"center"});let u=b[t],g=w("terms",u.termsUrl,u.termsLabel),m=w("privacy",u.privacyUrl,u.privacyLabel);c.append(r?"*Требуется устройство и браузер с поддержкой AR. Рекомендуем iOS 12 или новее с Safari либо Android 7.0 или новее с Chrome.":"*Requires an AR-compatible device and browser. We recommend iOS 12 or later with Safari, or Android 7.0 or later with Chrome.",document.createElement("br"),g,` ${u.conjunction} `,m);let h=document.createElement("p");h.textContent=`Powered by ${r?"Arizo":"Vizbl"}`,Object.assign(h.style,{color:"#93979F",fontSize:"11px",letterSpacing:"1.5px",margin:"24px 0 4px",textAlign:"center",textTransform:"uppercase"});let p=document.createElement("a");p.dataset.vizblBrandLink="",p.href=r?"https://arizo.ru":"https://vizbl.com",p.style.display="block",p.style.textAlign="center";let f=document.createElement("img");return f.alt=`${r?"Arizo":"Vizbl"} logo`,f.src=`${i}/${r?"logoArizo.svg":"logo.svg"}`,f.height=20,f.width=r?76:60,p.appendChild(f),a.append(s,d,l,c,h,p),o.appendChild(a),o}(a);l.id=r;let c=l.querySelector("[data-vizbl-qr-close]"),u=Array.from(l.querySelectorAll("button, a[href]")),g=!1,m=e=>{if("Escape"===e.key){e.preventDefault(),s();return}if("Tab"!==e.key||0===u.length)return;let t=u[0],i=u.at(-1)??t;e.shiftKey&&(document.activeElement===t||!l.contains(document.activeElement))?(e.preventDefault(),i.focus()):e.shiftKey||document.activeElement!==i||(e.preventDefault(),t.focus())};i=s=()=>{g||(g=!0,document.removeEventListener("keydown",m),l.remove(),i===s&&(i=void 0),o?.focus({preventScroll:!0}))},c?.addEventListener("click",s),l.addEventListener("click",e=>{e.target===l&&s()}),document.body.appendChild(l),document.addEventListener("keydown",m),function(){let e="https://fonts.googleapis.com/css2?family=Inter&display=swap";if(Array.from(document.querySelectorAll('link[rel="stylesheet"]')).some(t=>t.href===e||t.getAttribute("href")===e))return;let t=document.createElement("link");t.rel="stylesheet",t.href=e,document.head.appendChild(t)}();try{let i=await function(e){let i=v();if(i)return Promise.resolve(i);if(t)return t;let{qrCodeScriptUrl:r}=e??n();return t=new Promise((e,i)=>{let n,o=document.createElement("script"),a=()=>{n();let r=v();r?e(r):(o.remove(),t=void 0,i(Error("QR code runtime did not expose QRCode")))},s=()=>{n(),o.remove(),t=void 0,i(Error("Failed to load QR code runtime"))};n=()=>{o.removeEventListener("load",a),o.removeEventListener("error",s)},o.addEventListener("load",a,{once:!0}),o.addEventListener("error",s,{once:!0}),o.src=r,o.async=!0,o.dataset.vizblQrScript="true",document.head.appendChild(o)})}(a);if(d!==f||!l.isConnected)return s(),s;let r=l.querySelector("[data-vizbl-qr-code]");return r&&new i(r,{correctLevel:i.CorrectLevel.L,height:148,text:e,width:148}),l.style.display="flex",c?.focus({preventScroll:!0}),s}catch(e){throw s(),e}}class E extends Error{code;constructor(e){super(e),this.code=e,this.name="WidgetRuntimeError"}}function A(e){return e.runtimeConfig??n()}function C(e,t,i={}){let r=new URL(t,e);for(let[e,t]of Object.entries(i))t&&r.searchParams.set(e,t);return r.toString()}async function I(e,t,i){try{return await (i.fetchImpl??i.runtimeConfig?.fetchImpl??n().fetchImpl)(e,{...t,signal:i.signal})}catch(e){if(e instanceof DOMException&&"AbortError"===e.name)throw e;throw new E("NETWORK_ERROR")}}async function x(e){try{let t=await e.json();return[t.code,t.error,t.message].flatMap(e=>Array.isArray(e)?e:[e]).filter(e=>"string"==typeof e).join(" ").toLowerCase()}catch{return""}}async function O(e,t){let i=await x(e);return new E(429===e.status?"RATE_LIMITED":e.status>=500?"API_UNAVAILABLE":404===e.status&&"object"===t?"OBJECT_NOT_FOUND":i.includes("domain")||i.includes("origin")?"DOMAIN_NOT_ALLOWED":i.includes("revoked")?"KEY_REVOKED":i.includes("expired")?"activation"===t?"KEY_EXPIRED":"SESSION_EXPIRED":i.includes("policy")||i.includes("not available for this object")?"POLICY_DENIED":401===e.status||403===e.status?"activation"===t?"INVALID_KEY":"SESSION_EXPIRED":"REQUEST_FAILED")}async function S(e){try{return await e.json()}catch{throw new E("INVALID_RESPONSE")}}function k(e){if(!e||"object"!=typeof e||"string"!=typeof e.token||!e.token.trim()||"string"!=typeof e.sid||!e.sid.trim()||"number"!=typeof e.expiresIn||!Number.isFinite(e.expiresIn)||e.expiresIn<=0)throw new E("INVALID_RESPONSE");return e}async function T(e,t={}){let{apiOrigin:i}=A(t),r=await I(C(i,"/public/widget/activate-core",{mode:t.mode}),{cache:"no-store",headers:{"x-api-key":e},method:"POST"},t);if(!r.ok)throw await O(r,"activation");let n=await S(r);if("string"!=typeof n.productType)throw new E("INVALID_RESPONSE");return{...k(n.widgetSession),productType:n.productType}}async function L(e,t,i={}){let{apiOrigin:r}=A(i),n=await I(`${r}/public/widget/token`,{body:JSON.stringify({token:t,...i.mode?{mode:i.mode}:{}}),cache:"no-store",headers:{"Content-Type":"application/json","x-api-key":e},method:"POST"},i);if(!n.ok)throw await O(n,"token");return k(await S(n))}async function z(e,t,i={}){let{apiOrigin:r}=A(i),n=await I(C(r,`/public/objects/by-tinuuid/${encodeURIComponent(e)}`,{variantId:i.variantId}),{cache:"no-store",headers:{"x-widget-session-token":t},method:"GET"},i);if(!n.ok)throw await O(n,"object");let o=await S(n);if(!o||"object"!=typeof o||Array.isArray(o))throw new E("INVALID_RESPONSE");return o}async function R(e,t,i,r={}){let{apiOrigin:n}=A(r),o=await I(`${n}/public/widget/events`,{body:JSON.stringify({event:e,...i?{objectId:i}:{},...r.variantId?{variantId:r.variantId}:{},timestamp:new Date().toISOString()}),cache:"no-store",headers:{"Content-Type":"application/json","x-widget-session-token":t},keepalive:!0,method:"POST"},r);if(!o.ok)throw await O(o,"event");let a=await S(o);if(!a||"object"!=typeof a||Array.isArray(a)||"boolean"!=typeof a.ok)throw new E("INVALID_RESPONSE")}async function N(e,t,i){let r=i??n(),{fetchImpl:o,legacyApiOrigin:a}=r,s=await I(`${a}/obj/Fetch`,{body:JSON.stringify({tinuuid:e}),headers:{"Content-Type":"application/json"},method:"POST"},{fetchImpl:o,runtimeConfig:r,signal:t});if(!s.ok)throw await O(s,"object");let d=await S(s);if(!d||"object"!=typeof d||Array.isArray(d))throw new E("INVALID_RESPONSE");return d}async function P(e,t){let{fetchImpl:i,legacyApiOrigin:r}=t??n();await i(`${r}/obj/IncrViews`,{body:JSON.stringify({tinuuid:e}),headers:{"Content-Type":"application/json"},method:"POST"})}function D(e){try{let t=e?.();t instanceof Promise&&t.catch(()=>void 0)}catch{}}let j=p();function _(e){if(e?.aborted)throw new DOMException("Aborted","AbortError")}async function U(e,t={}){let i,r,n=j(e),o=e.getAttribute("data-native-link"),c=e.dataset.objectTinuuid?.trim(),p=e.dataset.objectHid?.trim()||void 0;if(!c)throw Error("Object ID is required");_(t.signal);let f=t.loadObject??((e,i)=>N(e,i,t.runtimeConfig)),b=t.object??await f(c,t.signal);if(_(t.signal),!n.isCurrent())return()=>void 0;let v=p?b.materials.find(e=>e.hid===p):b.materials[0];if(!v?.native?.glbUrl||!v.native.usdzUrl)throw Error("Native AR assets are unavailable");let w=u(v.native,b.type),E=s(),A=!1,C=0;e.querySelector("img")||((i=document.createElement("img")).alt="",i.hidden=!0,e.appendChild(i));let I=()=>t.trackView?t.trackView():P(c,t.runtimeConfig),x=i=>{i.preventDefault();let o=++C;r?.(),r=void 0,Promise.resolve(t.getDesktopQrUrl?.()??h(c,p,!0,t.runtimeConfig)).then(i=>{if(o===C&&n.isCurrent())return D(()=>t.onAction?.("interacted")),y(i,`vizbl-${c}`,e,t.runtimeConfig)}).then(e=>{if(e){if(o!==C||!n.isCurrent())return void e();r=e}}).catch(()=>void 0)},O=async e=>{let i;if(i=d().toLowerCase(),["firefox","edge","opera"].some(e=>i.includes(e))){if(e.preventDefault(),A)return;A=!0,D(()=>t.onAction?.("ar_launched"));try{await Promise.resolve(I()).catch(()=>void 0)}finally{A=!1,a()&&l()?m(c,p,t.runtimeConfig):g(w)}return}D(()=>t.onAction?.("ar_launched")),D(I),a()&&l()?(e.preventDefault(),m(c,p,t.runtimeConfig)):g(w)};return E?(e.dataset.nativeLink=w,e.addEventListener("click",O)):e.addEventListener("click",x),n.register(()=>{C+=1,e.removeEventListener("click",x),e.removeEventListener("click",O),r?.(),i?.remove(),null===o?e.removeAttribute("data-native-link"):e.setAttribute("data-native-link",o)})}var V=!1;if("u">typeof window){var M={get passive(){V=!0;return}};window.addEventListener("testPassive",null,M),window.removeEventListener("testPassive",null,M)}var $="u">typeof window&&window.navigator&&window.navigator.platform&&(/iP(ad|hone|od)/.test(window.navigator.platform)||"MacIntel"===window.navigator.platform&&window.navigator.maxTouchPoints>1),B=[],q=!1,H=-1,W=void 0,F=void 0,K=void 0,Q=function(e){return B.some(function(t){return!!(t.options.allowTouchMove&&t.options.allowTouchMove(e))})},Y=function(e){var t=e||window.event;return!!Q(t.target)||t.touches.length>1||(t.preventDefault&&t.preventDefault(),!1)},X=function(e){if(void 0===K){var t=!!e&&!0===e.reserveScrollBarGap,i=window.innerWidth-document.documentElement.clientWidth;if(t&&i>0){var r=parseInt(window.getComputedStyle(document.body).getPropertyValue("padding-right"),10);K=document.body.style.paddingRight,document.body.style.paddingRight=r+i+"px"}}void 0===W&&(W=document.body.style.overflow,document.body.style.overflow="hidden")},J=function(){void 0!==K&&(document.body.style.paddingRight=K,K=void 0),void 0!==W&&(document.body.style.overflow=W,W=void 0)},Z=function(){if(void 0!==F){var e=-parseInt(document.body.style.top,10),t=-parseInt(document.body.style.left,10);document.body.style.position=F.position,document.body.style.top=F.top,document.body.style.left=F.left,window.scrollTo(t,e),F=void 0}},G=function(e,t){var i=e.targetTouches[0].clientY-H;return!Q(e.target)&&(t&&0===t.scrollTop&&i>0?Y(e):t&&t.scrollHeight-t.scrollTop<=t.clientHeight&&i<0?Y(e):(e.stopPropagation(),!0))},ee=function(e,t){e?!B.some(function(t){return t.targetElement===e})&&(B=[].concat(function(e){if(!Array.isArray(e))return Array.from(e);for(var t=0,i=Array(e.length);t<e.length;t++)i[t]=e[t];return i}(B),[{targetElement:e,options:t||{}}]),$?window.requestAnimationFrame(function(){if(void 0===F){F={position:document.body.style.position,top:document.body.style.top,left:document.body.style.left};var e=window,t=e.scrollY,i=e.scrollX,r=e.innerHeight;document.body.style.position="fixed",document.body.style.top=-t,document.body.style.left=-i,setTimeout(function(){return window.requestAnimationFrame(function(){var e=r-window.innerHeight;e&&t>=r&&(document.body.style.top=-(t+e))})},300)}}):X(t),$&&(e.ontouchstart=function(e){1===e.targetTouches.length&&(H=e.targetTouches[0].clientY)},e.ontouchmove=function(t){1===t.targetTouches.length&&G(t,e)},q||(document.addEventListener("touchmove",Y,V?{passive:!1}:void 0),q=!0))):console.error("disableBodyScroll unsuccessful - targetElement must be provided when calling disableBodyScroll on IOS devices.")},et=function(e){e?(B=B.filter(function(t){return t.targetElement!==e}),$&&(e.ontouchstart=null,e.ontouchmove=null,q&&0===B.length&&(document.removeEventListener("touchmove",Y,V?{passive:!1}:void 0),q=!1)),$?Z():J()):console.error("enableBodyScroll unsuccessful - targetElement must be provided when calling enableBodyScroll on IOS devices.")};let ei=["cm","inch"],er=["x","y","z"],en=[...er],eo="vizbl_viewer",ea=p();function es(e){return e&&ei.includes(e)?e:"inch"}function ed(e){if(!e)return en;let t=Array.from(new Set(e.split(",").map(e=>e.trim().toLowerCase()).filter(e=>er.includes(e))));return t.length>0?t:en}function el(e){let t=new URL("/model-viewer",e.modelViewerOrigin??n().modelViewerOrigin),i=e.dimensionAxes??en;t.searchParams.set("tinuuid",e.tinuuid),e.hid&&t.searchParams.set("hid",e.hid),t.searchParams.set("size-type",e.sizeType),i.length<en.length&&t.searchParams.set("dimension-axes",i.join(",")),e.cameraOrbit&&t.searchParams.set("camera-orbit",e.cameraOrbit),e.minCameraOrbit&&t.searchParams.set("min-camera-orbit",e.minCameraOrbit),e.maxCameraOrbit&&t.searchParams.set("max-camera-orbit",e.maxCameraOrbit),e.lang&&t.searchParams.set("lang",e.lang);let r=new URLSearchParams;return e.apiKey&&r.set("api-key",e.apiKey),e.mode&&r.set("mode",e.mode),e.widgetSessionToken&&r.set("widget-session-token",e.widgetSessionToken),t.hash=r.toString(),t.toString()}let ec=p();function eu(e){if(e?.aborted)throw new DOMException("Aborted","AbortError")}async function eg(e,t={}){let i,r,n=ec(e),o=e.getAttribute("href"),a=e.getAttribute("rel"),d=e.dataset.objectTinuuid?.trim(),l=e.dataset.objectHid?.trim()||void 0;if(!d)throw Error("Object ID is required");eu(t.signal);let c=t.loadObject??((e,i)=>N(e,i,t.runtimeConfig)),g=t.object??await c(d,t.signal);if(eu(t.signal),!n.isCurrent())return()=>void 0;let m=l?g.materials.find(e=>e.hid===l):g.materials[0];if(!m?.native?.glbUrl||!m.native.usdzUrl)throw Error("Native AR assets are unavailable");let p=u(m.native,g.type),f=s(),b=0;e.rel="ar",e.querySelector("img")||((i=document.createElement("img")).alt="",i.hidden=!0,e.appendChild(i));let v=i=>{i.preventDefault();let o=++b;r?.(),r=void 0,Promise.resolve(t.getDesktopQrUrl?.()??h(d,l,!1,t.runtimeConfig)).then(i=>{if(o===b&&n.isCurrent())return D(()=>t.onAction?.("interacted")),y(i,`vizbl-${d}`,e,t.runtimeConfig)}).then(e=>{if(e){if(o!==b||!n.isCurrent())return void e();r=e}}).catch(()=>void 0)},w=()=>{D(t.trackView??(()=>P(d,t.runtimeConfig))),D(()=>t.onAction?.("ar_launched"))};return f?(e.href=p,e.addEventListener("click",w)):(e.href="#",e.addEventListener("click",v)),n.register(()=>{b+=1,e.removeEventListener("click",v),e.removeEventListener("click",w),r?.(),i?.remove(),null===o?e.removeAttribute("href"):e.setAttribute("href",o),null===a?e.removeAttribute("rel"):e.setAttribute("rel",a)})}let em=["advanced-ar","ar-one-click","ar-viewer"],eh={arizo:"arizo-core",vizbl:"vizbl-core"},ep=new Set(["core-ar","core-ar-shopify"]),ef={"advanced-ar":"View in advanced AR","ar-one-click":"View in AR","ar-viewer":"View in 3D & AR"},eb={"advanced-ar":"advanced-ar-view","ar-one-click":"ar-view","ar-viewer":"ar-viewer"},ev=["api-key","camera-orbit","dev","dimension-axes","max-camera-orbit","min-camera-orbit","object-id","size-type","trigger-class","type","variant-id"],ew=new Set(["API_UNAVAILABLE","INVALID_RESPONSE","NETWORK_ERROR","REQUEST_FAILED","SESSION_EXPIRED"]),ey="core-ar-widget-styles";class eE extends Error{code;constructor(e){super(e),this.code=e,this.name="CoreArWidgetComponentError"}}function eA(e){return em.includes(e)}function eC(e,t){let i=Array.isArray(e.materials)?e.materials:[],r=t?i.find(e=>e.hid===t):i[0];if(!r)throw new eE(t?"VARIANT_NOT_FOUND":"MODEL_UNAVAILABLE");return r}function eI(e,t){if("ar-one-click"===e&&t.policy?.instantArView===!1)throw new eE("POLICY_DENIED")}let ex="u"<typeof HTMLElement?class{}:HTMLElement;class eO extends ex{static get observedAttributes(){return[...ev]}get triggerClass(){return this.getAttribute("trigger-class")??""}set triggerClass(e){let t="string"==typeof e?e.trim():"";t?this.setAttribute("trigger-class",t):this.removeAttribute("trigger-class")}get unstyled(){return this.hasAttribute("unstyled")}set unstyled(e){this.toggleAttribute("unstyled",!!e)}abortController;actionResetTimer;cleanup;customLabelNodes=null;initializationRevision=0;object;queued=!1;session;trigger;variantId;widgetMode;connectedCallback(){!function(){if(document.getElementById(ey))return;let e=document.createElement("style");e.id=ey,e.textContent=`
|
|
2
2
|
:where(vizbl-core, arizo-core) {
|
|
3
3
|
display: inline-block;
|
|
4
4
|
--core-ar-widget-background: #3556f0;
|
|
@@ -65,4 +65,4 @@
|
|
|
65
65
|
:where(vizbl-core, arizo-core)[data-state="error"] [data-core-ar-widget-trigger] {
|
|
66
66
|
cursor: not-allowed;
|
|
67
67
|
}
|
|
68
|
-
`,document.head.appendChild(e)}(),this.captureCustomLabel(),this.queueInitialization()}disconnectedCallback(){this.initializationRevision+=1,this.abortController?.abort(),this.abortController=void 0,this.cleanup?.(),this.cleanup=void 0,this.clearActionResetTimer()}attributeChangedCallback(e,t,i){if(t!==i){if("trigger-class"===e)return void this.applyTriggerClass();("api-key"===e||"dev"===e)&&(this.session=void 0),this.isConnected&&(this.abortController?.abort(),this.cleanup?.(),this.cleanup=void 0,this.setState("loading"),this.queueInitialization())}}captureCustomLabel(){if(null!==this.customLabelNodes)return;let e=Array.from(this.childNodes),t=e.some(e=>e.nodeType!==Node.TEXT_NODE||!!e.textContent?.trim());this.customLabelNodes=t?e:[]}queueInitialization(){this.queued||(this.queued=!0,queueMicrotask(()=>{this.queued=!1,this.isConnected&&this.initialize()}))}async initialize(){let e=++this.initializationRevision;this.abortController?.abort(),this.cleanup?.(),this.cleanup=void 0,this.object=void 0,this.variantId=void 0,this.widgetMode=void 0,this.clearActionResetTimer();let t=new AbortController;this.abortController=t;let i=this.getAttribute("type")?.trim()??"",r=eA(i)?i:"ar-viewer",n=this.getAttribute("object-id")?.trim()??"",o=this.getAttribute("variant-id")?.trim()||void 0,a=this.getAttribute("api-key")?.trim()??"",d=this.getAttribute("size-type")?.trim()||void 0,l=this.getAttribute("dimension-axes")?.trim()||void 0,c=this.getAttribute("camera-orbit")?.trim()||void 0,u=this.getAttribute("min-camera-orbit")?.trim()||void 0,g=this.getAttribute("max-camera-orbit")?.trim()||void 0;this.removeAttribute("data-error-code"),this.setState("loading"),this.renderTrigger(r);try{let r,m=this.resolveRuntimeConfig();if(!a)throw new eE("MISSING_API_KEY");if(!n)throw new eE("MISSING_OBJECT_ID");if(!eA(i))throw new eE("INVALID_TYPE");if("ar-viewer"===i&&d&&"cm"!==d&&"inch"!==d)throw new eE("INVALID_SIZE_TYPE");let h=eb[i],p=await this.ensureSession(a,m,h,t.signal);if(this.assertCurrent(e,t.signal),this.variantId=o,this.widgetMode=h,this.applyIntegrationData(n,o,d,l,c,u,g),"ar-viewer"===i)r=await N(n,t.signal,m),this.assertCurrent(e,t.signal),eC(r,o),eI(i,r),this.object=r;else{r=s()?await this.fetchObjectWithSession(n,a,p,m,t.signal,o):await N(n,t.signal,m),this.assertCurrent(e,t.signal);let d=eC(r,o);if(eI(i,r),!d.native?.glbUrl||!d.native.usdzUrl)throw new eE("MODEL_UNAVAILABLE");this.object=r}let f=await this.initializeTrigger(i,r,m,t.signal,a,p);try{this.assertCurrent(e,t.signal)}catch(e){throw f(),e}this.cleanup=f,this.setState("ready"),this.dispatchWidgetEvent("core-ar-ready",{objectId:n,type:i})}catch(o){if(e!==this.initializationRevision||t.signal.aborted||o instanceof DOMException&&"AbortError"===o.name)return;let r=o instanceof eE||o instanceof E?o.code:"INITIALIZATION_FAILED";this.setAttribute("data-error-code",r),this.setState("error"),this.dispatchWidgetEvent("core-ar-error",{code:r,objectId:n,type:i})}}async ensureSession(e,t,i,r,n=!1){let o=`${t.apiOrigin}|${t.viewerOrigin}|${t.modelViewerOrigin}|${i}`,a=this.session?.publicKey===e&&this.session.runtimeKey===o?this.session:void 0;if(a&&!n&&a.expiresAt-Date.now()>3e4)return a;if(a)try{let i=await L(e,a.token,{mode:a.mode,runtimeConfig:t,signal:r}),n={...a,...i,expiresAt:Date.now()+1e3*i.expiresIn};return this.session=n,n}catch(e){if(!(e instanceof E)||!ew.has(e.code))throw e;this.session=void 0}let s=await T(e,{mode:i,runtimeConfig:t,signal:r});if(!ep.has(s.productType))throw new eE("POLICY_DENIED");let d={expiresAt:Date.now()+1e3*s.expiresIn,mode:i,productType:s.productType,publicKey:e,runtimeKey:o,sid:s.sid,token:s.token};return this.session=d,d}async fetchObjectWithSession(e,t,i,r,n,o){try{return await z(e,i.token,{runtimeConfig:r,signal:n,variantId:o})}catch(a){if(!(a instanceof E)||"SESSION_EXPIRED"!==a.code)throw a;return z(e,(await this.ensureSession(t,r,i.mode,n,!0)).token,{runtimeConfig:r,signal:n,variantId:o})}}assertCurrent(e,t){if(e!==this.initializationRevision||t.aborted)throw new DOMException("Aborted","AbortError")}renderTrigger(e){let t="ar-one-click"===e?document.createElement("a"):document.createElement("button");if(t.dataset.coreArWidgetTrigger="",t.setAttribute("part","trigger"),t.addEventListener("click",e=>{"ready"!==this.dataset.state&&(e.preventDefault(),e.stopImmediatePropagation())}),t instanceof HTMLButtonElement&&(t.type="button"),t instanceof HTMLAnchorElement&&(t.href="#",t.rel="ar"),"ar-viewer"===e&&t.setAttribute("aria-haspopup","dialog"),"ar-viewer"!==e){let e=document.createElement("img");e.alt="",e.hidden=!0,t.appendChild(e)}let i=document.createElement("span");i.dataset.coreArWidgetLabel="",this.customLabelNodes?.length?i.append(...this.customLabelNodes):i.textContent=ef[e],t.appendChild(i),this.trigger=t,this.applyTriggerClass(),this.replaceChildren(t),this.updateTriggerAccessibility(this.dataset.state)}applyTriggerClass(){if(!this.trigger)return;let e=this.triggerClass.trim();e?this.trigger.className=e:this.trigger.removeAttribute("class")}applyIntegrationData(e,t,i,r,n,o,a){this.trigger&&(this.trigger.dataset.objectTinuuid=e,t?this.trigger.dataset.objectHid=t:delete this.trigger.dataset.objectHid,i?this.trigger.dataset.sizeType=i:delete this.trigger.dataset.sizeType,r?this.trigger.dataset.dimensionAxes=r:delete this.trigger.dataset.dimensionAxes,n?this.trigger.dataset.cameraOrbit=n:delete this.trigger.dataset.cameraOrbit,o?this.trigger.dataset.minCameraOrbit=o:delete this.trigger.dataset.minCameraOrbit,a?this.trigger.dataset.maxCameraOrbit=a:delete this.trigger.dataset.maxCameraOrbit)}async initializeTrigger(e,t,i,r,n,o){if(!this.trigger)throw new eE("INITIALIZATION_FAILED");if("ar-viewer"===e)return function(e,t={}){let i,r=ea(e),n=!1,o=async()=>{if(i||n)return;let o=e.dataset.objectTinuuid?.trim();if(!o)return;n=!0;let a=t.widgetSessionToken;try{t.getWidgetSessionToken&&(a=await t.getWidgetSessionToken())}catch{n=!1;return}if(n=!1,i||!r.isCurrent())return;let s=function(e){var t,i,r,n;let o,a,s;if(document.getElementById(eo))return null;let d=document.createElement("div"),l=document.createElement("div"),c=document.createElement("div"),u=e.containerClassName?document.getElementsByClassName(e.containerClassName)[0]:null,g=!!u,m=g?l:d,h=!1,p=e=>{"Escape"===e.key&&o()};o=()=>{h||(h=!0,document.removeEventListener("keydown",p),et(m),(g?l:d).remove(),e.onClose?.(),e.restoreFocusTo?.focus({preventScroll:!0}))},d.id=eo,Object.assign(d.style,{inset:"0",overflow:"auto",position:"fixed",zIndex:"11111"}),d.style.webkitOverflowScrolling="touch",l.setAttribute("role","dialog"),l.setAttribute("aria-modal","true"),l.setAttribute("aria-label","3D model viewer"),Object.assign(c.style,{animation:"vex-fadein 0.5s",background:"#fff",inset:"0",position:"fixed",zIndex:"11111"}),c.addEventListener("click",o),(e.width||e.height)&&(c.style.background="rgba(0, 0, 0, 0.8)",Object.assign(l.style,{borderRadius:"12px",height:e.height??"100%",left:"50%",overflow:"hidden",position:"absolute",top:"50%",transform:"translate(-50%, -50%)",width:e.width??"100%",zIndex:"11112"}));let f=(t=e.crossClassName,i=o,(a=document.createElement("button")).type="button",a.setAttribute("aria-label","Close 3D model viewer"),t&&(a.className=t),Object.assign(a.style,{alignItems:"center",background:"#fff",border:"1px solid #E3E7E7",borderRadius:"4px",boxSizing:"border-box",cursor:"pointer",display:"flex",height:"40px",inset:"24px 24px auto auto",justifyContent:"center",padding:"8px 16px",position:"absolute",width:"56px",zIndex:"11113"}),a.innerHTML='<svg aria-hidden="true" style="flex-shrink:0" width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M19 6.41L17.59 5L12 10.59L6.41 5L5 6.41L10.59 12L5 17.59L6.41 19L12 13.41L17.59 19L19 17.59L13.41 12L19 6.41Z" fill="#484D50"/></svg>',a.addEventListener("click",i),a);return l.append((r=el(e),n=e.backgroundColor,(s=document.createElement("iframe")).src=r,s.title="3D model viewer",s.allow="fullscreen; xr-spatial-tracking",Object.assign(s.style,{backgroundColor:n??"white",border:"none",height:"100%",inset:"0",position:"absolute",width:"100%",zIndex:"11112"}),s),f),u?(l.id=eo,u.appendChild(l)):(d.append(c,l),document.body.appendChild(d)),document.addEventListener("keydown",p),ee(m),f.focus({preventScroll:!0}),o}({apiKey:t.apiKey,backgroundColor:e.dataset.background,buttonBgColor:e.dataset.buttonBgColor,buttonBorderColor:e.dataset.buttonBorderColor,buttonTextColor:e.dataset.buttonTextColor,cameraOrbit:e.dataset.cameraOrbit,containerClassName:e.dataset.container,crossClassName:e.dataset.crossClassName,dimensionAxes:ed(e.dataset.dimensionAxes),height:e.dataset.height?.trim(),hid:e.dataset.objectHid,hidePreview:e.dataset.hidePreview,hideTitle:e.dataset.hideTitle,maxCameraOrbit:e.dataset.maxCameraOrbit,minCameraOrbit:e.dataset.minCameraOrbit,mode:t.mode,modelViewerOrigin:t.modelViewerOrigin,onClose:()=>{i=void 0,t.onClose?.()},restoreFocusTo:e,sizeType:es(e.dataset.sizeType),tinuuid:o,widgetSessionToken:a,width:e.dataset.width?.trim()});s&&(i=s,t.onOpen?.(),D(()=>t.onAction?.("widget_opened")))};return e.addEventListener("click",o),r.register(()=>{e.removeEventListener("click",o),i?.(),i=void 0})}(this.trigger,{apiKey:n,getWidgetSessionToken:async()=>(await this.ensureSession(n,i,o.mode)).token,mode:o.mode,modelViewerOrigin:i.modelViewerOrigin,onAction:e=>this.handleAction(e,i),onClose:()=>{this.isConnected&&this.setState("ready")},onOpen:()=>this.setState("opening"),widgetSessionToken:o.token});if(!t)throw new eE("INITIALIZATION_FAILED");let a={getDesktopQrUrl:async()=>{let e=await this.ensureSession(n,i,o.mode);return el({apiKey:n,cameraOrbit:this.trigger?.dataset.cameraOrbit,dimensionAxes:ed(this.trigger?.dataset.dimensionAxes),hid:this.variantId,maxCameraOrbit:this.trigger?.dataset.maxCameraOrbit,minCameraOrbit:this.trigger?.dataset.minCameraOrbit,mode:e.mode,modelViewerOrigin:i.modelViewerOrigin,sizeType:es(this.trigger?.dataset.sizeType),tinuuid:this.trigger?.dataset.objectTinuuid??"",widgetSessionToken:e.token})},object:t,onAction:e=>this.handleAction(e,i),runtimeConfig:i,signal:r,trackView:()=>this.trackEvent("ar_launched",i)};if("ar-one-click"===e){if(!(this.trigger instanceof HTMLAnchorElement))throw new eE("INITIALIZATION_FAILED");return eg(this.trigger,a)}return U(this.trigger,a)}handleAction(e,t){this.setState("opening"),("interacted"===e||"widget_opened"===e)&&"ar-viewer"!==this.getAttribute("type")&&this.trackEvent(e,t),"ar-viewer"!==this.getAttribute("type")&&(this.clearActionResetTimer(),this.actionResetTimer=window.setTimeout(()=>{this.isConnected&&this.setState("ready")},300))}async trackEvent(e,t){let i=this.getAttribute("api-key")?.trim(),r=this.widgetMode;if(i&&r&&this.isConnected)try{let n=await this.ensureSession(i,t,r);await R(e,n.token,this.object?.uuid,{runtimeConfig:t,variantId:this.variantId})}catch{}}clearActionResetTimer(){void 0!==this.actionResetTimer&&(window.clearTimeout(this.actionResetTimer),this.actionResetTimer=void 0)}setState(e){this.dataset.state=e,this.updateTriggerAccessibility(e)}updateTriggerAccessibility(e){if(!this.trigger)return;let t="ready"===e;this.trigger.setAttribute("aria-busy",String("loading"===e)),this.trigger.setAttribute("aria-disabled",String(!t)),this.trigger.tabIndex=t?0:-1,this.trigger instanceof HTMLButtonElement&&(this.trigger.disabled=!t)}dispatchWidgetEvent(e,t){this.dispatchEvent(new CustomEvent(e,{bubbles:!0,composed:!0,detail:t}))}}function eS(e){if("u"<typeof customElements)return;let t=eh[e],i=customElements.get(t);if(i)return i;class n extends eO{resolveRuntimeConfig(){return function(e,t="prod"){var i,n;let o,a,s,d,l,c,u,g,m="arizo"===e?"arizo.ru":"vizbl.com",h="dev"===t?"-dev":"";return o=r((i={apiOrigin:`https://api${h}.${m}`,modelViewerOrigin:`https://integrations${h}.${m}`,viewerOrigin:`https://viewer${h}.${m}`}).apiOrigin,"apiOrigin"),a=r(i.viewerOrigin,"viewerOrigin"),l=i.modelViewerOrigin?r(i.modelViewerOrigin,"modelViewerOrigin"):(d=(s=new URL(a)).hostname.match(/^viewer(-dev)?\.(vizbl\.com|arizo\.ru)$/))?`${s.protocol}//integrations${d[1]??""}.${d[2]}`:a,g=i.legacyApiOrigin?(c=r(n=i.legacyApiOrigin,"legacyApiOrigin"),(u=new URL(n).pathname.replace(/\/+$/,""))?`${c}${u}`:c):`${o}/v1`,{apiOrigin:o,brand:new URL(a).hostname.endsWith("arizo.ru")?"arizo":"vizbl",fetchImpl:i.fetchImpl??fetch,legacyApiOrigin:g,modelViewerOrigin:l,qrCodeScriptUrl:i.qrCodeScriptUrl??`${a}/vendor/qrcode.min.js`,viewerOrigin:a}}(e,this.hasAttribute("dev")?"dev":"prod")}}return customElements.define(t,n),n}eS("arizo"),eS("vizbl")})();
|
|
68
|
+
`,document.head.appendChild(e)}(),this.captureCustomLabel(),this.queueInitialization()}disconnectedCallback(){this.initializationRevision+=1,this.abortController?.abort(),this.abortController=void 0,this.cleanup?.(),this.cleanup=void 0,this.clearActionResetTimer()}attributeChangedCallback(e,t,i){if(t!==i){if("trigger-class"===e)return void this.applyTriggerClass();("api-key"===e||"dev"===e)&&(this.session=void 0),this.isConnected&&(this.abortController?.abort(),this.cleanup?.(),this.cleanup=void 0,this.setState("loading"),this.queueInitialization())}}captureCustomLabel(){if(null!==this.customLabelNodes)return;let e=Array.from(this.childNodes),t=e.some(e=>e.nodeType!==Node.TEXT_NODE||!!e.textContent?.trim());this.customLabelNodes=t?e:[]}queueInitialization(){this.queued||(this.queued=!0,queueMicrotask(()=>{this.queued=!1,this.isConnected&&this.initialize()}))}async initialize(){let e=++this.initializationRevision;this.abortController?.abort(),this.cleanup?.(),this.cleanup=void 0,this.object=void 0,this.variantId=void 0,this.widgetMode=void 0,this.clearActionResetTimer();let t=new AbortController;this.abortController=t;let i=this.getAttribute("type")?.trim()??"",r=eA(i)?i:"ar-viewer",n=this.getAttribute("object-id")?.trim()??"",o=this.getAttribute("variant-id")?.trim()||void 0,a=this.getAttribute("api-key")?.trim()??"",d=this.getAttribute("size-type")?.trim()||void 0,l=this.getAttribute("dimension-axes")?.trim()||void 0,c=this.getAttribute("camera-orbit")?.trim()||void 0,u=this.getAttribute("min-camera-orbit")?.trim()||void 0,g=this.getAttribute("max-camera-orbit")?.trim()||void 0;this.removeAttribute("data-error-code"),this.setState("loading"),this.renderTrigger(r);try{let r,m=this.resolveRuntimeConfig();if(!a)throw new eE("MISSING_API_KEY");if(!n)throw new eE("MISSING_OBJECT_ID");if(!eA(i))throw new eE("INVALID_TYPE");if("ar-viewer"===i&&d&&"cm"!==d&&"inch"!==d)throw new eE("INVALID_SIZE_TYPE");let h=eb[i],p=await this.ensureSession(a,m,h,t.signal);if(this.assertCurrent(e,t.signal),this.variantId=o,this.widgetMode=h,this.applyIntegrationData(n,o,d,l,c,u,g),"ar-viewer"===i)r=await N(n,t.signal,m),this.assertCurrent(e,t.signal),eC(r,o),eI(i,r),this.object=r;else{r=s()?await this.fetchObjectWithSession(n,a,p,m,t.signal,o):await N(n,t.signal,m),this.assertCurrent(e,t.signal);let d=eC(r,o);if(eI(i,r),!d.native?.glbUrl||!d.native.usdzUrl)throw new eE("MODEL_UNAVAILABLE");this.object=r}let f=await this.initializeTrigger(i,r,m,t.signal,a,p);try{this.assertCurrent(e,t.signal)}catch(e){throw f(),e}this.cleanup=f,this.setState("ready"),this.dispatchWidgetEvent("core-ar-ready",{objectId:n,type:i})}catch(o){if(e!==this.initializationRevision||t.signal.aborted||o instanceof DOMException&&"AbortError"===o.name)return;let r=o instanceof eE||o instanceof E?o.code:"INITIALIZATION_FAILED";this.setAttribute("data-error-code",r),this.setState("error"),this.dispatchWidgetEvent("core-ar-error",{code:r,objectId:n,type:i})}}async ensureSession(e,t,i,r,n=!1){let o=`${t.apiOrigin}|${t.viewerOrigin}|${t.modelViewerOrigin}|${i}`,a=this.session?.publicKey===e&&this.session.runtimeKey===o?this.session:void 0;if(a&&!n&&a.expiresAt-Date.now()>3e4)return a;if(a)try{let i=await L(e,a.token,{mode:a.mode,runtimeConfig:t,signal:r}),n={...a,...i,expiresAt:Date.now()+1e3*i.expiresIn};return this.session=n,n}catch(e){if(!(e instanceof E)||!ew.has(e.code))throw e;this.session=void 0}let s=await T(e,{mode:i,runtimeConfig:t,signal:r});if(!ep.has(s.productType))throw new eE("POLICY_DENIED");let d={expiresAt:Date.now()+1e3*s.expiresIn,mode:i,productType:s.productType,publicKey:e,runtimeKey:o,sid:s.sid,token:s.token};return this.session=d,d}async fetchObjectWithSession(e,t,i,r,n,o){try{return await z(e,i.token,{runtimeConfig:r,signal:n,variantId:o})}catch(a){if(!(a instanceof E)||"SESSION_EXPIRED"!==a.code)throw a;return z(e,(await this.ensureSession(t,r,i.mode,n,!0)).token,{runtimeConfig:r,signal:n,variantId:o})}}assertCurrent(e,t){if(e!==this.initializationRevision||t.aborted)throw new DOMException("Aborted","AbortError")}renderTrigger(e){let t="ar-one-click"===e?document.createElement("a"):document.createElement("button");if(t.dataset.coreArWidgetTrigger="",t.setAttribute("part","trigger"),t.addEventListener("click",e=>{"ready"!==this.dataset.state&&(e.preventDefault(),e.stopImmediatePropagation())}),t instanceof HTMLButtonElement&&(t.type="button"),t instanceof HTMLAnchorElement&&(t.href="#",t.rel="ar"),"ar-viewer"===e&&t.setAttribute("aria-haspopup","dialog"),"ar-viewer"!==e){let e=document.createElement("img");e.alt="",e.hidden=!0,t.appendChild(e)}let i=document.createElement("span");i.dataset.coreArWidgetLabel="",this.customLabelNodes?.length?i.append(...this.customLabelNodes):i.textContent=ef[e],t.appendChild(i),this.trigger=t,this.applyTriggerClass(),this.replaceChildren(t),this.updateTriggerAccessibility(this.dataset.state)}applyTriggerClass(){if(!this.trigger)return;let e=this.triggerClass.trim();e?this.trigger.className=e:this.trigger.removeAttribute("class")}applyIntegrationData(e,t,i,r,n,o,a){this.trigger&&(this.trigger.dataset.objectTinuuid=e,t?this.trigger.dataset.objectHid=t:delete this.trigger.dataset.objectHid,i?this.trigger.dataset.sizeType=i:delete this.trigger.dataset.sizeType,r?this.trigger.dataset.dimensionAxes=r:delete this.trigger.dataset.dimensionAxes,n?this.trigger.dataset.cameraOrbit=n:delete this.trigger.dataset.cameraOrbit,o?this.trigger.dataset.minCameraOrbit=o:delete this.trigger.dataset.minCameraOrbit,a?this.trigger.dataset.maxCameraOrbit=a:delete this.trigger.dataset.maxCameraOrbit)}async initializeTrigger(e,t,i,r,n,o){if(!this.trigger)throw new eE("INITIALIZATION_FAILED");if("ar-viewer"===e)return function(e,t={}){let i,r=ea(e),n=!1,o=async()=>{if(i||n)return;let o=e.dataset.objectTinuuid?.trim();if(!o)return;n=!0;let a=t.widgetSessionToken;try{t.getWidgetSessionToken&&(a=await t.getWidgetSessionToken())}catch{n=!1;return}if(n=!1,i||!r.isCurrent())return;let s=function(e){var t,i;let r,n;if(document.getElementById(eo))return null;let o=document.createElement("div"),a=document.createElement("div"),s=document.createElement("div"),d=e.containerClassName?document.getElementsByClassName(e.containerClassName)[0]:null,l=!!d,c=l?a:o,u=!1,g=e=>{"Escape"===e.key&&r()};r=()=>{u||(u=!0,document.removeEventListener("keydown",g),et(c),(l?a:o).remove(),e.onClose?.(),e.restoreFocusTo?.focus({preventScroll:!0}))},o.id=eo,Object.assign(o.style,{inset:"0",overflow:"auto",position:"fixed",zIndex:"11111"}),o.style.webkitOverflowScrolling="touch",a.setAttribute("role","dialog"),a.setAttribute("aria-modal","true"),a.setAttribute("aria-label","ru"===e.lang?"Просмотр 3D-модели":"3D model viewer"),Object.assign(s.style,{animation:"vex-fadein 0.5s",background:"#fff",inset:"0",position:"fixed",zIndex:"11111"}),s.addEventListener("click",r),(e.width||e.height)&&(s.style.background="rgba(0, 0, 0, 0.8)",Object.assign(a.style,{borderRadius:"12px",height:e.height??"100%",left:"50%",overflow:"hidden",position:"absolute",top:"50%",transform:"translate(-50%, -50%)",width:e.width??"100%",zIndex:"11112"}));let m=function(e,t,i="en"){let r=document.createElement("button");return r.type="button",r.setAttribute("aria-label","ru"===i?"Закрыть просмотр 3D-модели":"Close 3D model viewer"),e&&(r.className=e),Object.assign(r.style,{alignItems:"center",background:"#fff",border:"1px solid #E3E7E7",borderRadius:"4px",boxSizing:"border-box",cursor:"pointer",display:"flex",height:"40px",inset:"24px 24px auto auto",justifyContent:"center",padding:"8px 16px",position:"absolute",width:"56px",zIndex:"11113"}),r.innerHTML='<svg aria-hidden="true" style="flex-shrink:0" width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M19 6.41L17.59 5L12 10.59L6.41 5L5 6.41L10.59 12L5 17.59L6.41 19L12 13.41L17.59 19L19 17.59L13.41 12L19 6.41Z" fill="#484D50"/></svg>',r.addEventListener("click",t),r}(e.crossClassName,r,e.lang);return a.append((t=el(e),i=e.backgroundColor,(n=document.createElement("iframe")).src=t,n.title="3D model viewer",n.allow="fullscreen; xr-spatial-tracking",Object.assign(n.style,{backgroundColor:i??"white",border:"none",height:"100%",inset:"0",position:"absolute",width:"100%",zIndex:"11112"}),n),m),d?(a.id=eo,d.appendChild(a)):(o.append(s,a),document.body.appendChild(o)),document.addEventListener("keydown",g),ee(c),m.focus({preventScroll:!0}),r}({apiKey:t.apiKey,backgroundColor:e.dataset.background,buttonBgColor:e.dataset.buttonBgColor,buttonBorderColor:e.dataset.buttonBorderColor,buttonTextColor:e.dataset.buttonTextColor,cameraOrbit:e.dataset.cameraOrbit,containerClassName:e.dataset.container,crossClassName:e.dataset.crossClassName,dimensionAxes:ed(e.dataset.dimensionAxes),height:e.dataset.height?.trim(),hid:e.dataset.objectHid,hidePreview:e.dataset.hidePreview,hideTitle:e.dataset.hideTitle,lang:t.lang,maxCameraOrbit:e.dataset.maxCameraOrbit,minCameraOrbit:e.dataset.minCameraOrbit,mode:t.mode,modelViewerOrigin:t.modelViewerOrigin,onClose:()=>{i=void 0,t.onClose?.()},restoreFocusTo:e,sizeType:es(e.dataset.sizeType),tinuuid:o,widgetSessionToken:a,width:e.dataset.width?.trim()});s&&(i=s,t.onOpen?.(),D(()=>t.onAction?.("widget_opened")))};return e.addEventListener("click",o),r.register(()=>{e.removeEventListener("click",o),i?.(),i=void 0})}(this.trigger,{apiKey:n,getWidgetSessionToken:async()=>(await this.ensureSession(n,i,o.mode)).token,lang:"arizo"===i.brand?"ru":"en",mode:o.mode,modelViewerOrigin:i.modelViewerOrigin,onAction:e=>this.handleAction(e,i),onClose:()=>{this.isConnected&&this.setState("ready")},onOpen:()=>this.setState("opening"),widgetSessionToken:o.token});if(!t)throw new eE("INITIALIZATION_FAILED");let a={getDesktopQrUrl:async()=>{let e=await this.ensureSession(n,i,o.mode);return el({apiKey:n,cameraOrbit:this.trigger?.dataset.cameraOrbit,dimensionAxes:ed(this.trigger?.dataset.dimensionAxes),hid:this.variantId,lang:"arizo"===i.brand?"ru":"en",maxCameraOrbit:this.trigger?.dataset.maxCameraOrbit,minCameraOrbit:this.trigger?.dataset.minCameraOrbit,mode:e.mode,modelViewerOrigin:i.modelViewerOrigin,sizeType:es(this.trigger?.dataset.sizeType),tinuuid:this.trigger?.dataset.objectTinuuid??"",widgetSessionToken:e.token})},object:t,onAction:e=>this.handleAction(e,i),runtimeConfig:i,signal:r,trackView:()=>this.trackEvent("ar_launched",i)};if("ar-one-click"===e){if(!(this.trigger instanceof HTMLAnchorElement))throw new eE("INITIALIZATION_FAILED");return eg(this.trigger,a)}return U(this.trigger,a)}handleAction(e,t){this.setState("opening"),("interacted"===e||"widget_opened"===e)&&"ar-viewer"!==this.getAttribute("type")&&this.trackEvent(e,t),"ar-viewer"!==this.getAttribute("type")&&(this.clearActionResetTimer(),this.actionResetTimer=window.setTimeout(()=>{this.isConnected&&this.setState("ready")},300))}async trackEvent(e,t){let i=this.getAttribute("api-key")?.trim(),r=this.widgetMode;if(i&&r&&this.isConnected)try{let n=await this.ensureSession(i,t,r);await R(e,n.token,this.object?.uuid,{runtimeConfig:t,variantId:this.variantId})}catch{}}clearActionResetTimer(){void 0!==this.actionResetTimer&&(window.clearTimeout(this.actionResetTimer),this.actionResetTimer=void 0)}setState(e){this.dataset.state=e,this.updateTriggerAccessibility(e)}updateTriggerAccessibility(e){if(!this.trigger)return;let t="ready"===e;this.trigger.setAttribute("aria-busy",String("loading"===e)),this.trigger.setAttribute("aria-disabled",String(!t)),this.trigger.tabIndex=t?0:-1,this.trigger instanceof HTMLButtonElement&&(this.trigger.disabled=!t)}dispatchWidgetEvent(e,t){this.dispatchEvent(new CustomEvent(e,{bubbles:!0,composed:!0,detail:t}))}}function eS(e){if("u"<typeof customElements)return;let t=eh[e],i=customElements.get(t);if(i)return i;class n extends eO{resolveRuntimeConfig(){return function(e,t="prod"){var i,n;let o,a,s,d,l,c,u,g,m="arizo"===e?"arizo.ru":"vizbl.com",h="dev"===t?"-dev":"";return o=r((i={apiOrigin:`https://api${h}.${m}`,modelViewerOrigin:`https://integrations${h}.${m}`,viewerOrigin:`https://viewer${h}.${m}`}).apiOrigin,"apiOrigin"),a=r(i.viewerOrigin,"viewerOrigin"),l=i.modelViewerOrigin?r(i.modelViewerOrigin,"modelViewerOrigin"):(d=(s=new URL(a)).hostname.match(/^viewer(-dev)?\.(vizbl\.com|arizo\.ru)$/))?`${s.protocol}//integrations${d[1]??""}.${d[2]}`:a,g=i.legacyApiOrigin?(c=r(n=i.legacyApiOrigin,"legacyApiOrigin"),(u=new URL(n).pathname.replace(/\/+$/,""))?`${c}${u}`:c):`${o}/v1`,{apiOrigin:o,brand:new URL(a).hostname.endsWith("arizo.ru")?"arizo":"vizbl",fetchImpl:i.fetchImpl??fetch,legacyApiOrigin:g,modelViewerOrigin:l,qrCodeScriptUrl:i.qrCodeScriptUrl??`${a}/vendor/qrcode.min.js`,viewerOrigin:a}}(e,this.hasAttribute("dev")?"dev":"prod")}}return customElements.define(t,n),n}eS("arizo"),eS("vizbl")})();
|
package/dist/index.js
CHANGED
|
@@ -766,6 +766,7 @@ function createModalViewerUrl(params) {
|
|
|
766
766
|
if (params.cameraOrbit) url.searchParams.set('camera-orbit', params.cameraOrbit);
|
|
767
767
|
if (params.minCameraOrbit) url.searchParams.set('min-camera-orbit', params.minCameraOrbit);
|
|
768
768
|
if (params.maxCameraOrbit) url.searchParams.set('max-camera-orbit', params.maxCameraOrbit);
|
|
769
|
+
if (params.lang) url.searchParams.set('lang', params.lang);
|
|
769
770
|
const fragment = new URLSearchParams();
|
|
770
771
|
if (params.apiKey) fragment.set('api-key', params.apiKey);
|
|
771
772
|
if (params.mode) fragment.set('mode', params.mode);
|
|
@@ -789,10 +790,10 @@ function createFrame(src, backgroundColor) {
|
|
|
789
790
|
});
|
|
790
791
|
return frame;
|
|
791
792
|
}
|
|
792
|
-
function createCloseButton(className, close) {
|
|
793
|
+
function createCloseButton(className, close, lang = 'en') {
|
|
793
794
|
const button = document.createElement('button');
|
|
794
795
|
button.type = 'button';
|
|
795
|
-
button.setAttribute('aria-label', 'Close 3D model viewer');
|
|
796
|
+
button.setAttribute('aria-label', 'ru' === lang ? 'Закрыть просмотр 3D-модели' : 'Close 3D model viewer');
|
|
796
797
|
if (className) button.className = className;
|
|
797
798
|
Object.assign(button.style, {
|
|
798
799
|
alignItems: 'center',
|
|
@@ -848,7 +849,7 @@ function openModal(options) {
|
|
|
848
849
|
root.style.webkitOverflowScrolling = 'touch';
|
|
849
850
|
viewer.setAttribute('role', 'dialog');
|
|
850
851
|
viewer.setAttribute('aria-modal', 'true');
|
|
851
|
-
viewer.setAttribute('aria-label', '3D model viewer');
|
|
852
|
+
viewer.setAttribute('aria-label', 'ru' === options.lang ? 'Просмотр 3D-модели' : '3D model viewer');
|
|
852
853
|
Object.assign(overlay.style, {
|
|
853
854
|
animation: 'vex-fadein 0.5s',
|
|
854
855
|
background: '#fff',
|
|
@@ -871,7 +872,7 @@ function openModal(options) {
|
|
|
871
872
|
zIndex: '11112'
|
|
872
873
|
});
|
|
873
874
|
}
|
|
874
|
-
const closeButton = createCloseButton(options.crossClassName, close);
|
|
875
|
+
const closeButton = createCloseButton(options.crossClassName, close, options.lang);
|
|
875
876
|
viewer.append(createFrame(createModalViewerUrl(options), options.backgroundColor), closeButton);
|
|
876
877
|
if (targetContainer) {
|
|
877
878
|
viewer.id = VIEWER_CONTAINER_ID;
|
|
@@ -919,6 +920,7 @@ function initializeModalTrigger(trigger, options = {}) {
|
|
|
919
920
|
hid: trigger.dataset.objectHid,
|
|
920
921
|
hidePreview: trigger.dataset.hidePreview,
|
|
921
922
|
hideTitle: trigger.dataset.hideTitle,
|
|
923
|
+
lang: options.lang,
|
|
922
924
|
maxCameraOrbit: trigger.dataset.maxCameraOrbit,
|
|
923
925
|
minCameraOrbit: trigger.dataset.minCameraOrbit,
|
|
924
926
|
mode: options.mode,
|
|
@@ -1424,6 +1426,7 @@ class CoreArWidgetElement extends HTMLElementBase {
|
|
|
1424
1426
|
const currentSession = await this.ensureSession(publicKey, runtimeConfig, session.mode);
|
|
1425
1427
|
return currentSession.token;
|
|
1426
1428
|
},
|
|
1429
|
+
lang: 'arizo' === runtimeConfig.brand ? 'ru' : 'en',
|
|
1427
1430
|
mode: session.mode,
|
|
1428
1431
|
modelViewerOrigin: runtimeConfig.modelViewerOrigin,
|
|
1429
1432
|
onAction: (action)=>this.handleAction(action, runtimeConfig),
|
|
@@ -1442,6 +1445,7 @@ class CoreArWidgetElement extends HTMLElementBase {
|
|
|
1442
1445
|
cameraOrbit: this.trigger?.dataset.cameraOrbit,
|
|
1443
1446
|
dimensionAxes: resolveDimensionAxes(this.trigger?.dataset.dimensionAxes),
|
|
1444
1447
|
hid: this.variantId,
|
|
1448
|
+
lang: 'arizo' === runtimeConfig.brand ? 'ru' : 'en',
|
|
1445
1449
|
maxCameraOrbit: this.trigger?.dataset.maxCameraOrbit,
|
|
1446
1450
|
minCameraOrbit: this.trigger?.dataset.minCameraOrbit,
|
|
1447
1451
|
mode: currentSession.mode,
|