@neurodyn/core-ar 0.4.0 → 0.5.0
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/README.md +13 -0
- package/dist/core-ar.embed.min.js +2 -2
- package/dist/index.js +32 -15
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -23,6 +23,19 @@ and Model Viewer. Load it once and then add any number of branded elements:
|
|
|
23
23
|
</vizbl-core>
|
|
24
24
|
```
|
|
25
25
|
|
|
26
|
+
On platform-owned `vizbl.com`, `vizbl.us`, `arizo.ru` and their subdomains,
|
|
27
|
+
`api-key` can be omitted. The widget reads public objects anonymously and opens
|
|
28
|
+
WebAR, the viewer or the native handoff without creating a merchant Widget Session.
|
|
29
|
+
The tag still selects the brand and `variant-id` selects the initial material.
|
|
30
|
+
On other hosts a public widget key is required. An explicitly supplied key always
|
|
31
|
+
uses the authenticated integration flow, including on platform hosts.
|
|
32
|
+
|
|
33
|
+
```html
|
|
34
|
+
<vizbl-core type="advanced-ar" object-id="OBJECT_TINUUID" variant-id="MATERIAL_HID">
|
|
35
|
+
View in my room
|
|
36
|
+
</vizbl-core>
|
|
37
|
+
```
|
|
38
|
+
|
|
26
39
|
The credential attribute is `api-key`, not `key`. React reserves `key` for its
|
|
27
40
|
own reconciliation and does not forward it to Custom Elements.
|
|
28
41
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(()=>{"use strict";var e,t,r,i={2585(e,t,r){r.d(t,{_:()=>i});function i(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}}},n={};function a(e){var t=n[e];if(void 0!==t)return t.exports;var r=n[e]={id:e,exports:{}};return i[e](r,r.exports,a),r.exports}a.m=i,a.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return a.d(t,{a:t}),t},s=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,a.t=function(e,t){if(1&t&&(e=this(e)),8&t||"object"==typeof e&&e&&(4&t&&e.__esModule||16&t&&"function"==typeof e.then))return e;var r=Object.create(null);a.r(r);var i={};o=o||[null,s({}),s([]),s(s)];for(var n=2&t&&e;("object"==typeof n||"function"==typeof n)&&!~o.indexOf(n);n=s(n))Object.getOwnPropertyNames(n).forEach(t=>{i[t]=()=>e[t]});return i.default=()=>e,a.d(r,i),r},a.d=(e,t)=>{for(var r in t)a.o(t,r)&&!a.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},a.f={},a.e=e=>Promise.all(Object.keys(a.f).reduce((t,r)=>(a.f[r](e,t),t),[])),a.u=e=>"core-ar.chunk."+({117:"c3761997",152:"b35bb825",270:"f52e1e86",292:"27b4ab37",343:"87bc2890",393:"5d925ec9",548:"df43e0ae",59:"f136c05d",759:"66c7fd24",789:"86e9b748",872:"e2e05712",886:"c15d19d9",986:"f57ba10e"})[e]+".min.js",a.miniCssF=e=>""+e+".css",a.g=(()=>{if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}})(),a.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),l={},a.l=function(e,t,r,i){if(l[e])return void l[e].push(t);if(void 0!==r)for(var n,o,s=document.getElementsByTagName("script"),c=0;c<s.length;c++){var d=s[c];if(d.getAttribute("src")==e||d.getAttribute("data-rspack")=="@neurodyn/core-ar:"+r){n=d;break}}n||(o=!0,(n=document.createElement("script")).timeout=120,a.nc&&n.setAttribute("nonce",a.nc),n.setAttribute("data-rspack","@neurodyn/core-ar:"+r),n.src=e),l[e]=[t];var u=function(t,r){n.onerror=n.onload=null,clearTimeout(h);var i=l[e];if(delete l[e],n.parentNode&&n.parentNode.removeChild(n),i&&i.forEach(function(e){return e(r)}),t)return t(r)},h=setTimeout(u.bind(null,void 0,{type:"timeout",target:n}),12e4);n.onerror=u.bind(null,n.onerror),n.onload=u.bind(null,n.onload),o&&document.head.appendChild(n)},a.r=e=>{"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},a.nc=void 0,a.g.importScripts&&(c=a.g.location+"");var o,s,l,c,d=a.g.document;if(!c&&d&&(d.currentScript&&"SCRIPT"===d.currentScript.tagName.toUpperCase()&&(c=d.currentScript.src),!c)){var u=d.getElementsByTagName("script");if(u.length)for(var h=u.length-1;h>-1&&(!c||!/^http(s?):/.test(c));)c=u[h--].src}if(!c)throw Error("Automatic publicPath is not supported in this browser");a.p=c=c.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),e={964:0},a.f.j=function(t,r){var i=a.o(e,t)?e[t]:void 0;if(0!==i)if(i)r.push(i[2]);else{var n=new Promise((r,n)=>i=e[t]=[r,n]);r.push(i[2]=n);var o=a.p+a.u(t),s=Error();a.l(o,function(r){if(a.o(e,t)&&(0!==(i=e[t])&&(e[t]=void 0),i)){var n=r&&("load"===r.type?"missing":r.type),o=r&&r.target&&r.target.src;s.message="Loading chunk "+t+" failed.\n("+n+": "+o+")",s.name="ChunkLoadError",s.type=n,s.request=o,i[1](s)}},"chunk-"+t,t)}},t=(t,r)=>{var i,n,[o,s,l]=r,c=0;if(o.some(t=>0!==e[t])){for(i in s)a.o(s,i)&&(a.m[i]=s[i]);l&&l(a)}for(t&&t(r);c<o.length;c++)n=o[c],a.o(e,n)&&e[n]&&e[n][0](),e[n]=0},(r=self.webpackChunk_neurodyn_core_ar=self.webpackChunk_neurodyn_core_ar||[]).forEach(t.bind(null,0)),r.push=t.bind(null,r.push.bind(r)),(()=>{let e,t,r,i,n;var o=a(2585);function s(e,t){let r;try{r=new URL(e)}catch{throw TypeError(`${t} must be an absolute HTTP(S) URL`)}if("http:"!==r.protocol&&"https:"!==r.protocol)throw TypeError(`${t} must be an absolute HTTP(S) URL`);return r.origin}function l(){if(!e)throw Error("Core AR widget runtime is not configured");return e}function c(){return"u"<typeof navigator?"":navigator.userAgent||navigator.vendor||""}function d(){if("u"<typeof window||"u"<typeof navigator)return!1;let e="MacIntel"===navigator.platform&&navigator.maxTouchPoints>1;return(/iPad|iPhone|iPod/.test(c())||e)&&!("MSStream"in window)}function u(){var e,t;if("u"<typeof window||"u"<typeof navigator)return!1;if(d())return!0;let r=navigator.maxTouchPoints>1,i=(null==(e=(t=window).matchMedia)?void 0:e.call(t,"(pointer: coarse)").matches)??!1,n=/Android|iPhone|iPad|iPod|webOS|BlackBerry|Windows Phone|Opera Mini|IEMobile|Mobile/i.test(c());return r&&i&&(n||d())}function h(){var e;let t=c();return(null==(e=[[/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(e=>{let[r]=e;return r.test(t)}))?void 0:e[1])??"Other"}function g(){let e=function(){var e,t;let r=c(),i=(null==(e=r.match(/\bOS (\d+)/))?void 0:e[1])??(null==(t=r.match(/Version\/(\d+)/))?void 0:t[1]);if(!i)return null;let n=Number.parseInt(i,10);return Number.isNaN(n)?null:n}();return null!==e&&e>=17}function m(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 v(e,t){let r=m(e.glbUrl),i=m(e.usdzUrl),n=encodeURIComponent(r),a=`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;`,o=`${i}#allowsContentScaling=0`;return d()?o:a}function p(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=document.createElement("a"),i=document.createElement("img");r.rel="ar",r.href=e,r.hidden=!0,i.alt="",i.hidden=!0,r.appendChild(i),document.body.appendChild(r),window.setTimeout(()=>{r.click(),r.remove()},t)}function f(e,t,r){let i=function(e,t,r){let{brand:i}=r??l();if(d()){let r=new URL("https://appclip.apple.com/id");return r.searchParams.set("p","com.us.vizbl.Clip"),r.searchParams.set("tinuuid",e),t&&r.searchParams.set("hid",t),r.searchParams.set("region","arizo"===i?"ru":"en"),r.toString()}return`intent:/${window.location.pathname}#Intent;scheme=open;package=com.us.vizbl;end`}(e,t,r);window.self===window.top||h().toLowerCase().includes("edge")?window.location.assign(i):window.open(i,"_top")}function b(e,t){let r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=arguments.length>3?arguments[3]:void 0,{viewerOrigin:n}=i??l(),a=new URL("/ar/index.html",n);return a.searchParams.set("tinuuid",e),t&&a.searchParams.set("hid",t),r&&a.searchParams.set("appview","true"),a.toString()}function w(){let e=new WeakMap;return function(t){var r;let i=e.get(t);null==i||null==(r=i.cleanup)||r.call(i);let n={revision:((null==i?void 0:i.revision)??0)+1};return e.set(t,n),{isCurrent:()=>e.get(t)===n,register(r){let i=!1,a=()=>{i||(i=!0,r())};return e.get(t)!==n?(a(),a):(n.cleanup=a,()=>{e.get(t)===n&&e.delete(t),a()})}}}}let y=0,A={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 E(){return window.QRCode}function C(e,t,r){let i=document.createElement("a");return i.dataset.vizblLegalLink=e,i.href=t,i.rel="noopener noreferrer",i.target="_blank",i.textContent=r,Object.assign(i.style,{color:"inherit",textDecoration:"underline",textUnderlineOffset:"2px",whiteSpace:"nowrap"}),i}async function O(e){let i,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"vizblQrModal",a=arguments.length>2?arguments[2]:void 0,o=arguments.length>3?arguments[3]:void 0,s=++y;null==r||r(),document.querySelectorAll("[data-vizbl-qr-modal]").forEach(e=>e.remove());let c=function(e){let{brand:t,viewerOrigin:r}=e??l(),i="arizo"===t,n=document.createElement("div");n.dataset.vizblQrModal="",n.setAttribute("aria-label","View object in augmented reality"),n.setAttribute("aria-modal","true"),n.setAttribute("role","dialog"),Object.assign(n.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 o=document.createElement("button");o.type="button",o.dataset.vizblQrClose="",o.setAttribute("aria-label","Close QR code"),o.textContent="\xd7",Object.assign(o.style,{background:"none",border:"none",color:"#AEB1B7",cursor:"pointer",fontSize:"24px",position:"absolute",right:"20px",top:"20px"});let s=document.createElement("div");s.dataset.vizblQrCode="",s.style.margin="0 auto",s.style.width="fit-content";let c=document.createElement("p");c.textContent=i?"Отсканируйте этот QR-код камерой телефона, чтобы примерить объект в интерьере":"Scan this QR code with your phone camera to view the object in Augmented Reality",Object.assign(c.style,{fontSize:"16px",fontWeight:"500",lineHeight:"24px",margin:"24px 0 0",textAlign:"center"});let d=document.createElement("p");Object.assign(d.style,{color:"#93979F",fontSize:"12px",lineHeight:"16px",margin:"12px 0 0",textAlign:"center"});let u=A[t],h=C("terms",u.termsUrl,u.termsLabel),g=C("privacy",u.privacyUrl,u.privacyLabel);d.append(i?"*Требуется устройство и браузер с поддержкой AR. Рекомендуем iOS 18 или новее с Safari либо Android 7.0 или новее с Chrome.":"*Requires an AR-compatible device and browser. We recommend iOS 18 or later with Safari, or Android 7.0 or later with Chrome.",document.createElement("br"),h,` ${u.conjunction} `,g);let m=document.createElement("p");m.textContent=`Powered by ${i?"Arizo":"Vizbl"}`,Object.assign(m.style,{color:"#93979F",fontSize:"11px",letterSpacing:"1.5px",margin:"24px 0 4px",textAlign:"center",textTransform:"uppercase"});let v=document.createElement("a");v.dataset.vizblBrandLink="",v.href=i?"https://arizo.ru":"https://vizbl.com",v.style.display="block",v.style.textAlign="center";let p=document.createElement("img");return p.alt=`${i?"Arizo":"Vizbl"} logo`,p.src=`${r}/${i?"logoArizo.svg":"logo.svg"}`,p.height=20,p.width=i?76:60,v.appendChild(p),a.append(o,s,c,d,m,v),n.appendChild(a),n}(o);c.id=n;let d=c.querySelector("[data-vizbl-qr-close]"),u=Array.from(c.querySelectorAll("button, a[href]")),h=!1,g=e=>{if("Escape"===e.key){e.preventDefault(),i();return}if("Tab"!==e.key||0===u.length)return;let t=u[0],r=u.at(-1)??t;e.shiftKey&&(document.activeElement===t||!c.contains(document.activeElement))?(e.preventDefault(),r.focus()):e.shiftKey||document.activeElement!==r||(e.preventDefault(),t.focus())};r=i=()=>{h||(h=!0,document.removeEventListener("keydown",g),c.remove(),r===i&&(r=void 0),null==a||a.focus({preventScroll:!0}))},null==d||d.addEventListener("click",i),c.addEventListener("click",e=>{e.target===c&&i()}),document.body.appendChild(c),document.addEventListener("keydown",g),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 r=await function(e){let r=E();if(r)return Promise.resolve(r);if(t)return t;let{qrCodeScriptUrl:i}=e??l();return t=new Promise((e,r)=>{let n,a=document.createElement("script"),o=()=>{n();let i=E();i?e(i):(a.remove(),t=void 0,r(Error("QR code runtime did not expose QRCode")))},s=()=>{n(),a.remove(),t=void 0,r(Error("Failed to load QR code runtime"))};n=()=>{a.removeEventListener("load",o),a.removeEventListener("error",s)},a.addEventListener("load",o,{once:!0}),a.addEventListener("error",s,{once:!0}),a.src=i,a.async=!0,a.dataset.vizblQrScript="true",document.head.appendChild(a)})}(o);if(s!==y||!c.isConnected)return i(),i;let n=c.querySelector("[data-vizbl-qr-code]");return n&&new r(n,{correctLevel:r.CorrectLevel.L,height:148,text:e,width:148}),c.style.display="flex",null==d||d.focus({preventScroll:!0}),i}catch(e){throw i(),e}}class S extends Error{constructor(e){super(e),(0,o._)(this,"code",void 0),this.code=e,this.name="WidgetRuntimeError"}}function I(e){return e.runtimeConfig??l()}function k(e){return{"x-app-type":e.brand}}function T(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=new URL(t,e);for(let[e,t]of Object.entries(r))t&&i.searchParams.set(e,t);return i.toString()}async function x(e,t,r){try{var i;return await (r.fetchImpl??(null==(i=r.runtimeConfig)?void 0:i.fetchImpl)??l().fetchImpl)(e,{...t,signal:r.signal})}catch(e){if(e instanceof DOMException&&"AbortError"===e.name)throw e;throw new S("NETWORK_ERROR")}}async function z(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 L(e,t){let r=await z(e);return new S(429===e.status?"RATE_LIMITED":e.status>=500?"API_UNAVAILABLE":404===e.status&&"object"===t?"OBJECT_NOT_FOUND":r.includes("domain")||r.includes("origin")?"DOMAIN_NOT_ALLOWED":r.includes("revoked")?"KEY_REVOKED":r.includes("expired")?"activation"===t?"KEY_EXPIRED":"SESSION_EXPIRED":r.includes("policy")||r.includes("not available for this object")?"POLICY_DENIED":401===e.status||403===e.status?"activation"===t?"INVALID_KEY":"SESSION_EXPIRED":"REQUEST_FAILED")}async function _(e){try{return await e.json()}catch{throw new S("INVALID_RESPONSE")}}function P(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 S("INVALID_RESPONSE");return e}async function R(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=I(t),i=await x(T(r.apiOrigin,"/public/widget/activate-core",{mode:t.mode}),{cache:"no-store",headers:{...k(r),"x-api-key":e},method:"POST"},t);if(!i.ok)throw await L(i,"activation");let n=await _(i);if("string"!=typeof n.productType)throw new S("INVALID_RESPONSE");return{...P(n.widgetSession),productType:n.productType}}async function j(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=I(r),n=await x(`${i.apiOrigin}/public/widget/token`,{body:JSON.stringify({token:t,...r.mode?{mode:r.mode}:{}}),cache:"no-store",headers:{...k(i),"Content-Type":"application/json","x-api-key":e},method:"POST"},r);if(!n.ok)throw await L(n,"token");return P(await _(n))}async function N(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=I(r),n=await x(T(i.apiOrigin,`/public/objects/by-tinuuid/${encodeURIComponent(e)}`,{variantId:r.variantId}),{cache:"no-store",headers:{...k(i),"x-widget-session-token":t},method:"GET"},r);if(!n.ok)throw await L(n,"object");let a=await _(n);if(!a||"object"!=typeof a||Array.isArray(a))throw new S("INVALID_RESPONSE");return a}async function D(e,t,r){let i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},n=I(i),a=await x(`${n.apiOrigin}/public/widget/events`,{body:JSON.stringify({event:e,...r?{objectId:r}:{},...i.variantId?{variantId:i.variantId}:{},timestamp:new Date().toISOString()}),cache:"no-store",headers:{...k(n),"Content-Type":"application/json","x-widget-session-token":t},keepalive:!0,method:"POST"},i);if(!a.ok)throw await L(a,"event");let o=await _(a);if(!o||"object"!=typeof o||Array.isArray(o)||"boolean"!=typeof o.ok)throw new S("INVALID_RESPONSE")}async function U(e,t,r){let i=r??l(),{apiOrigin:n,fetchImpl:a}=i,o=await x(`${n}/catalog/object`,{body:JSON.stringify({tinuuid:e}),headers:{...k(i),"Content-Type":"application/json"},method:"POST"},{fetchImpl:a,runtimeConfig:i,signal:t});if(!o.ok)throw await L(o,"object");let s=await _(o);if(!s||"object"!=typeof s||Array.isArray(s))throw new S("INVALID_RESPONSE");return s}async function V(e,t){let r=t??l();await r.fetchImpl(`${r.apiOrigin}/catalog/object/incr-views`,{body:JSON.stringify({tinuuid:e}),headers:{...k(r),"Content-Type":"application/json"},method:"POST"})}function M(e){try{let t=null==e?void 0:e();t instanceof Promise&&t.catch(()=>void 0)}catch{}}let W=w();function $(e){if(null==e?void 0:e.aborted)throw new DOMException("Aborted","AbortError")}async function q(e){var t,r,i;let n,a,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},s=W(e),l=e.getAttribute("data-native-link"),c=null==(t=e.dataset.objectTinuuid)?void 0:t.trim(),m=(null==(r=e.dataset.objectHid)?void 0:r.trim())||void 0;if(!c)throw Error("Object ID is required");$(o.signal);let w=o.loadObject??((e,t)=>U(e,t,o.runtimeConfig)),y=o.object??await w(c,o.signal);if($(o.signal),!s.isCurrent())return()=>void 0;let A=m?y.materials.find(e=>e.hid===m):y.materials[0];if(!(null==A||null==(i=A.native)?void 0:i.glbUrl)||!A.native.usdzUrl)throw Error("Native AR assets are unavailable");let E=v(A.native,y.type),C=u(),S=!1,I=!1,k=0;e.querySelector("img")||((n=document.createElement("img")).alt="",n.hidden=!0,e.appendChild(n));let T=()=>o.trackView?o.trackView():V(c,o.runtimeConfig),x=t=>{var r;t.preventDefault();let i=++k;null==a||a(),a=void 0,Promise.resolve((null==(r=o.getDesktopQrUrl)?void 0:r.call(o))??b(c,m,!0,o.runtimeConfig)).then(t=>{if(i===k&&s.isCurrent())return M(()=>{var e;return null==(e=o.onAction)?void 0:e.call(o,"interacted")}),O(t,`vizbl-${c}`,e,o.runtimeConfig)}).then(e=>{if(e){if(i!==k||!s.isCurrent())return void e();a=e}}).catch(()=>void 0)},z=async e=>{var t;let r;if(null==(t=o.webAr)?void 0:t.isAvailable()){if(e.preventDefault(),I)return;I=!0;let t=!1;try{t=await o.webAr.open().catch(()=>!1)}finally{I=!1}if(t||!s.isCurrent())return}if(r=h().toLowerCase(),["firefox","edge","opera"].some(e=>r.includes(e))){if(e.preventDefault(),S)return;S=!0,M(()=>{var e;return null==(e=o.onAction)?void 0:e.call(o,"ar_launched")});try{await Promise.resolve(T()).catch(()=>void 0)}finally{S=!1,d()&&g()?f(c,m,o.runtimeConfig):p(E)}return}M(()=>{var e;return null==(e=o.onAction)?void 0:e.call(o,"ar_launched")}),M(T),d()&&g()?(e.preventDefault(),f(c,m,o.runtimeConfig)):p(E)};return C?(e.dataset.nativeLink=E,e.addEventListener("click",z)):e.addEventListener("click",x),s.register(()=>{k+=1,e.removeEventListener("click",x),e.removeEventListener("click",z),null==a||a(),null==n||n.remove(),null===l?e.removeAttribute("data-native-link"):e.setAttribute("data-native-link",l)})}async function B(){let[{ModelViewerDialog:e},{createElement:t},{createRoot:r}]=await Promise.all([Promise.all([a.e("759"),a.e("117"),a.e("872"),a.e("59"),a.e("548")]).then(a.bind(a,5535)),a.e("986").then(a.t.bind(a,9081,19)),Promise.all([a.e("117"),a.e("886")]).then(a.t.bind(a,8181,19))]);return{open:i=>{let{onClose:n,...a}=i,o=document.createElement("div");o.setAttribute("data-core-ar-model-viewer",""),document.body.appendChild(o);let s=r(o),l=!1,c=r=>s.render(t(e,{...a,onOpenChange:e=>{e||d()},open:r}));function d(){l||(l=!0,c(!1),setTimeout(()=>{s.unmount(),o.remove()},300),null==n||n())}return c(!0),d}}}let K=["cm","inch"],H=["x","y","z"],F=[...H],Q=w();function Y(e){return e&&K.includes(e)?e:"inch"}function J(e){if(!e)return F;let t=Array.from(new Set(e.split(",").map(e=>e.trim().toLowerCase()).filter(e=>H.includes(e))));return t.length>0?t:F}let X=w();function Z(e){if(null==e?void 0:e.aborted)throw new DOMException("Aborted","AbortError")}async function G(e){var t,r,i;let n,a,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},s=X(e),l=e.getAttribute("href"),c=e.getAttribute("rel"),d=null==(t=e.dataset.objectTinuuid)?void 0:t.trim(),h=(null==(r=e.dataset.objectHid)?void 0:r.trim())||void 0;if(!d)throw Error("Object ID is required");Z(o.signal);let g=o.loadObject??((e,t)=>U(e,t,o.runtimeConfig)),m=o.object??await g(d,o.signal);if(Z(o.signal),!s.isCurrent())return()=>void 0;let f=h?m.materials.find(e=>e.hid===h):m.materials[0];if(!(null==f||null==(i=f.native)?void 0:i.glbUrl)||!f.native.usdzUrl)throw Error("Native AR assets are unavailable");let w=v(f.native,m.type),y=u(),A=!1,E=0;e.rel="ar",e.querySelector("img")||((n=document.createElement("img")).alt="",n.hidden=!0,e.appendChild(n));let C=t=>{var r;t.preventDefault();let i=++E;null==a||a(),a=void 0,Promise.resolve((null==(r=o.getDesktopQrUrl)?void 0:r.call(o))??b(d,h,!1,o.runtimeConfig)).then(t=>{if(i===E&&s.isCurrent())return M(()=>{var e;return null==(e=o.onAction)?void 0:e.call(o,"interacted")}),O(t,`vizbl-${d}`,e,o.runtimeConfig)}).then(e=>{if(e){if(i!==E||!s.isCurrent())return void e();a=e}}).catch(()=>void 0)},S=()=>{M(o.trackView??(()=>V(d,o.runtimeConfig))),M(()=>{var e;return null==(e=o.onAction)?void 0:e.call(o,"ar_launched")})},I=async e=>{var t;if(!(null==(t=o.webAr)?void 0:t.isAvailable()))return void S();if(e.preventDefault(),A)return;A=!0;let r=!1;try{r=await o.webAr.open().catch(()=>!1)}finally{A=!1}!r&&s.isCurrent()&&(S(),p(w))};return y?(e.href=w,e.addEventListener("click",I)):(e.href="#",e.addEventListener("click",C)),s.register(()=>{E+=1,e.removeEventListener("click",C),e.removeEventListener("click",I),null==a||a(),null==n||n.remove(),null===l?e.removeAttribute("href"):e.setAttribute("href",l),null===c?e.removeAttribute("rel"):e.setAttribute("rel",c)})}async function ee(){let{ArDialog:e,prepareArSessionInPage:t}=await Promise.all([a.e("117"),a.e("59"),a.e("270"),a.e("152")]).then(a.bind(a,5907)),{createElement:r}=await a.e("986").then(a.t.bind(a,9081,19)),{createRoot:i}=await Promise.all([a.e("117"),a.e("886")]).then(a.t.bind(a,8181,19));return{open:t=>{let{onClose:n,...a}=t,o=document.createElement("div");o.setAttribute("data-core-ar-web-ar",""),document.body.appendChild(o);let s=i(o),l=!1,c=t=>s.render(r(e,{...a,onOpenChange:e=>{e||d()},open:t}));function d(){l||(l=!0,c(!1),setTimeout(()=>{s.unmount(),o.remove()},300),null==n||n())}return c(!0),d},prepare:t}}async function et(e){let t=await function(){if(n)return n;let e=ee();return n=e,e.catch(()=>{n===e&&(n=void 0)}),e}();return await t.prepare(e)?t:null}let er=["advanced-ar","ar-one-click","ar-viewer"],ei={arizo:"arizo-core",vizbl:"vizbl-core"},en=new Set(["core-ar","core-ar-shopify"]),ea={arizo:{"advanced-ar":"Посмотреть в расширенной AR","ar-one-click":"Посмотреть в AR","ar-viewer":"Посмотреть в 3D и AR"},vizbl:{"advanced-ar":"View in advanced AR","ar-one-click":"View in AR","ar-viewer":"View in 3D & AR"}},eo={"advanced-ar":"advanced-ar-view","ar-one-click":"ar-view","ar-viewer":"ar-viewer"},es=["api-key","camera-orbit","dev","dimension-axes","max-camera-orbit","min-camera-orbit","object-id","size-type","trigger-class","type","variant-id"],el=new Set(["API_UNAVAILABLE","INVALID_RESPONSE","NETWORK_ERROR","REQUEST_FAILED","SESSION_EXPIRED"]),ec="core-ar-widget-styles";class ed extends Error{constructor(e){super(e),(0,o._)(this,"code",void 0),this.code=e,this.name="CoreArWidgetComponentError"}}function eu(e){return er.includes(e)}function eh(e,t){let r=Array.isArray(e.materials)?e.materials:[],i=t?r.find(e=>e.hid===t):r[0];if(!i)throw new ed(t?"VARIANT_NOT_FOUND":"MODEL_UNAVAILABLE");return i}function eg(e,t){var r;if("ar-one-click"===e&&(null==(r=t.policy)?void 0:r.instantArView)===!1)throw new ed("POLICY_DENIED")}let em="u"<typeof HTMLElement?class{}:HTMLElement;class ev extends em{static get observedAttributes(){return[...es]}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)}connectedCallback(){!function(){if(document.getElementById(ec))return;let e=document.createElement("style");e.id=ec,e.textContent=`
|
|
1
|
+
(()=>{"use strict";var e,t,i,r={2585(e,t,i){i.d(t,{_:()=>r});function r(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}}},n={};function a(e){var t=n[e];if(void 0!==t)return t.exports;var i=n[e]={id:e,exports:{}};return r[e](i,i.exports,a),i.exports}a.m=r,a.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return a.d(t,{a:t}),t},s=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,a.t=function(e,t){if(1&t&&(e=this(e)),8&t||"object"==typeof e&&e&&(4&t&&e.__esModule||16&t&&"function"==typeof e.then))return e;var i=Object.create(null);a.r(i);var r={};o=o||[null,s({}),s([]),s(s)];for(var n=2&t&&e;("object"==typeof n||"function"==typeof n)&&!~o.indexOf(n);n=s(n))Object.getOwnPropertyNames(n).forEach(t=>{r[t]=()=>e[t]});return r.default=()=>e,a.d(i,r),i},a.d=(e,t)=>{for(var i in t)a.o(t,i)&&!a.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},a.f={},a.e=e=>Promise.all(Object.keys(a.f).reduce((t,i)=>(a.f[i](e,t),t),[])),a.u=e=>"core-ar.chunk."+({117:"c3761997",152:"b35bb825",270:"f52e1e86",292:"27b4ab37",343:"87bc2890",393:"5d925ec9",548:"df43e0ae",59:"f136c05d",759:"66c7fd24",789:"86e9b748",872:"e2e05712",886:"c15d19d9",986:"f57ba10e"})[e]+".min.js",a.miniCssF=e=>""+e+".css",a.g=(()=>{if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}})(),a.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),l={},a.l=function(e,t,i,r){if(l[e])return void l[e].push(t);if(void 0!==i)for(var n,o,s=document.getElementsByTagName("script"),c=0;c<s.length;c++){var d=s[c];if(d.getAttribute("src")==e||d.getAttribute("data-rspack")=="@neurodyn/core-ar:"+i){n=d;break}}n||(o=!0,(n=document.createElement("script")).timeout=120,a.nc&&n.setAttribute("nonce",a.nc),n.setAttribute("data-rspack","@neurodyn/core-ar:"+i),n.src=e),l[e]=[t];var u=function(t,i){n.onerror=n.onload=null,clearTimeout(h);var r=l[e];if(delete l[e],n.parentNode&&n.parentNode.removeChild(n),r&&r.forEach(function(e){return e(i)}),t)return t(i)},h=setTimeout(u.bind(null,void 0,{type:"timeout",target:n}),12e4);n.onerror=u.bind(null,n.onerror),n.onload=u.bind(null,n.onload),o&&document.head.appendChild(n)},a.r=e=>{"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},a.nc=void 0,a.g.importScripts&&(c=a.g.location+"");var o,s,l,c,d=a.g.document;if(!c&&d&&(d.currentScript&&"SCRIPT"===d.currentScript.tagName.toUpperCase()&&(c=d.currentScript.src),!c)){var u=d.getElementsByTagName("script");if(u.length)for(var h=u.length-1;h>-1&&(!c||!/^http(s?):/.test(c));)c=u[h--].src}if(!c)throw Error("Automatic publicPath is not supported in this browser");a.p=c=c.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),e={964:0},a.f.j=function(t,i){var r=a.o(e,t)?e[t]:void 0;if(0!==r)if(r)i.push(r[2]);else{var n=new Promise((i,n)=>r=e[t]=[i,n]);i.push(r[2]=n);var o=a.p+a.u(t),s=Error();a.l(o,function(i){if(a.o(e,t)&&(0!==(r=e[t])&&(e[t]=void 0),r)){var n=i&&("load"===i.type?"missing":i.type),o=i&&i.target&&i.target.src;s.message="Loading chunk "+t+" failed.\n("+n+": "+o+")",s.name="ChunkLoadError",s.type=n,s.request=o,r[1](s)}},"chunk-"+t,t)}},t=(t,i)=>{var r,n,[o,s,l]=i,c=0;if(o.some(t=>0!==e[t])){for(r in s)a.o(s,r)&&(a.m[r]=s[r]);l&&l(a)}for(t&&t(i);c<o.length;c++)n=o[c],a.o(e,n)&&e[n]&&e[n][0](),e[n]=0},(i=self.webpackChunk_neurodyn_core_ar=self.webpackChunk_neurodyn_core_ar||[]).forEach(t.bind(null,0)),i.push=t.bind(null,i.push.bind(i)),(()=>{let e,t,i,r,n;var o=a(2585);function s(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 l(){if(!e)throw Error("Core AR widget runtime is not configured");return e}function c(){return"u"<typeof navigator?"":navigator.userAgent||navigator.vendor||""}function d(){if("u"<typeof window||"u"<typeof navigator)return!1;let e="MacIntel"===navigator.platform&&navigator.maxTouchPoints>1;return(/iPad|iPhone|iPod/.test(c())||e)&&!("MSStream"in window)}function u(){var e,t;if("u"<typeof window||"u"<typeof navigator)return!1;if(d())return!0;let i=navigator.maxTouchPoints>1,r=(null==(e=(t=window).matchMedia)?void 0:e.call(t,"(pointer: coarse)").matches)??!1,n=/Android|iPhone|iPad|iPod|webOS|BlackBerry|Windows Phone|Opera Mini|IEMobile|Mobile/i.test(c());return i&&r&&(n||d())}function h(){var e;let t=c();return(null==(e=[[/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(e=>{let[i]=e;return i.test(t)}))?void 0:e[1])??"Other"}function g(){let e=function(){var e,t;let i=c(),r=(null==(e=i.match(/\bOS (\d+)/))?void 0:e[1])??(null==(t=i.match(/Version\/(\d+)/))?void 0:t[1]);if(!r)return null;let n=Number.parseInt(r,10);return Number.isNaN(n)?null:n}();return null!==e&&e>=17}function m(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 v(e,t){let i=m(e.glbUrl),r=m(e.usdzUrl),n=encodeURIComponent(i),a=`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;`,o=`${r}#allowsContentScaling=0`;return d()?o:a}function p(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,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 b(e,t,i){let r=function(e,t,i){let{brand:r}=i??l();if(d()){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||h().toLowerCase().includes("edge")?window.location.assign(r):window.open(r,"_top")}function f(e,t){let i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=arguments.length>3?arguments[3]:void 0,{viewerOrigin:n}=r??l(),a=new URL("/ar/index.html",n);return a.searchParams.set("tinuuid",e),t&&a.searchParams.set("hid",t),i&&a.searchParams.set("appview","true"),a.toString()}function w(){let e=new WeakMap;return function(t){var i;let r=e.get(t);null==r||null==(i=r.cleanup)||i.call(r);let n={revision:((null==r?void 0:r.revision)??0)+1};return e.set(t,n),{isCurrent:()=>e.get(t)===n,register(i){let r=!1,a=()=>{r||(r=!0,i())};return e.get(t)!==n?(a(),a):(n.cleanup=a,()=>{e.get(t)===n&&e.delete(t),a()})}}}}let y=0,A={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 E(){return window.QRCode}function C(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 O(e){let r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"vizblQrModal",a=arguments.length>2?arguments[2]:void 0,o=arguments.length>3?arguments[3]:void 0,s=++y;null==i||i(),document.querySelectorAll("[data-vizbl-qr-modal]").forEach(e=>e.remove());let c=function(e){let{brand:t,viewerOrigin:i}=e??l(),r="arizo"===t,n=document.createElement("div");n.dataset.vizblQrModal="",n.setAttribute("aria-label","View object in augmented reality"),n.setAttribute("aria-modal","true"),n.setAttribute("role","dialog"),Object.assign(n.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 o=document.createElement("button");o.type="button",o.dataset.vizblQrClose="",o.setAttribute("aria-label","Close QR code"),o.textContent="\xd7",Object.assign(o.style,{background:"none",border:"none",color:"#AEB1B7",cursor:"pointer",fontSize:"24px",position:"absolute",right:"20px",top:"20px"});let s=document.createElement("div");s.dataset.vizblQrCode="",s.style.margin="0 auto",s.style.width="fit-content";let c=document.createElement("p");c.textContent=r?"Отсканируйте этот QR-код камерой телефона, чтобы примерить объект в интерьере":"Scan this QR code with your phone camera to view the object in Augmented Reality",Object.assign(c.style,{fontSize:"16px",fontWeight:"500",lineHeight:"24px",margin:"24px 0 0",textAlign:"center"});let d=document.createElement("p");Object.assign(d.style,{color:"#93979F",fontSize:"12px",lineHeight:"16px",margin:"12px 0 0",textAlign:"center"});let u=A[t],h=C("terms",u.termsUrl,u.termsLabel),g=C("privacy",u.privacyUrl,u.privacyLabel);d.append(r?"*Требуется устройство и браузер с поддержкой AR. Рекомендуем iOS 18 или новее с Safari либо Android 7.0 или новее с Chrome.":"*Requires an AR-compatible device and browser. We recommend iOS 18 or later with Safari, or Android 7.0 or later with Chrome.",document.createElement("br"),h,` ${u.conjunction} `,g);let m=document.createElement("p");m.textContent=`Powered by ${r?"Arizo":"Vizbl"}`,Object.assign(m.style,{color:"#93979F",fontSize:"11px",letterSpacing:"1.5px",margin:"24px 0 4px",textAlign:"center",textTransform:"uppercase"});let v=document.createElement("a");v.dataset.vizblBrandLink="",v.href=r?"https://arizo.ru":"https://vizbl.com",v.style.display="block",v.style.textAlign="center";let p=document.createElement("img");return p.alt=`${r?"Arizo":"Vizbl"} logo`,p.src=`${i}/${r?"logoArizo.svg":"logo.svg"}`,p.height=20,p.width=r?76:60,v.appendChild(p),a.append(o,s,c,d,m,v),n.appendChild(a),n}(o);c.id=n;let d=c.querySelector("[data-vizbl-qr-close]"),u=Array.from(c.querySelectorAll("button, a[href]")),h=!1,g=e=>{if("Escape"===e.key){e.preventDefault(),r();return}if("Tab"!==e.key||0===u.length)return;let t=u[0],i=u.at(-1)??t;e.shiftKey&&(document.activeElement===t||!c.contains(document.activeElement))?(e.preventDefault(),i.focus()):e.shiftKey||document.activeElement!==i||(e.preventDefault(),t.focus())};i=r=()=>{h||(h=!0,document.removeEventListener("keydown",g),c.remove(),i===r&&(i=void 0),null==a||a.focus({preventScroll:!0}))},null==d||d.addEventListener("click",r),c.addEventListener("click",e=>{e.target===c&&r()}),document.body.appendChild(c),document.addEventListener("keydown",g),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=E();if(i)return Promise.resolve(i);if(t)return t;let{qrCodeScriptUrl:r}=e??l();return t=new Promise((e,i)=>{let n,a=document.createElement("script"),o=()=>{n();let r=E();r?e(r):(a.remove(),t=void 0,i(Error("QR code runtime did not expose QRCode")))},s=()=>{n(),a.remove(),t=void 0,i(Error("Failed to load QR code runtime"))};n=()=>{a.removeEventListener("load",o),a.removeEventListener("error",s)},a.addEventListener("load",o,{once:!0}),a.addEventListener("error",s,{once:!0}),a.src=r,a.async=!0,a.dataset.vizblQrScript="true",document.head.appendChild(a)})}(o);if(s!==y||!c.isConnected)return r(),r;let n=c.querySelector("[data-vizbl-qr-code]");return n&&new i(n,{correctLevel:i.CorrectLevel.L,height:148,text:e,width:148}),c.style.display="flex",null==d||d.focus({preventScroll:!0}),r}catch(e){throw r(),e}}class S extends Error{constructor(e){super(e),(0,o._)(this,"code",void 0),this.code=e,this.name="WidgetRuntimeError"}}function I(e){return e.runtimeConfig??l()}function k(e){return{"x-app-type":e.brand}}function T(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=new URL(t,e);for(let[e,t]of Object.entries(i))t&&r.searchParams.set(e,t);return r.toString()}async function x(e,t,i){try{var r;return await (i.fetchImpl??(null==(r=i.runtimeConfig)?void 0:r.fetchImpl)??l().fetchImpl)(e,{...t,signal:i.signal})}catch(e){if(e instanceof DOMException&&"AbortError"===e.name)throw e;throw new S("NETWORK_ERROR")}}async function z(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 L(e,t){let i=await z(e);return new S(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 _(e){try{return await e.json()}catch{throw new S("INVALID_RESPONSE")}}function P(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 S("INVALID_RESPONSE");return e}async function R(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=I(t),r=await x(T(i.apiOrigin,"/public/widget/activate-core",{mode:t.mode}),{cache:"no-store",headers:{...k(i),"x-api-key":e},method:"POST"},t);if(!r.ok)throw await L(r,"activation");let n=await _(r);if("string"!=typeof n.productType)throw new S("INVALID_RESPONSE");return{...P(n.widgetSession),productType:n.productType}}async function j(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=I(i),n=await x(`${r.apiOrigin}/public/widget/token`,{body:JSON.stringify({token:t,...i.mode?{mode:i.mode}:{}}),cache:"no-store",headers:{...k(r),"Content-Type":"application/json","x-api-key":e},method:"POST"},i);if(!n.ok)throw await L(n,"token");return P(await _(n))}async function N(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=I(i),n=await x(T(r.apiOrigin,`/public/objects/by-tinuuid/${encodeURIComponent(e)}`,{variantId:i.variantId}),{cache:"no-store",headers:{...k(r),"x-widget-session-token":t},method:"GET"},i);if(!n.ok)throw await L(n,"object");let a=await _(n);if(!a||"object"!=typeof a||Array.isArray(a))throw new S("INVALID_RESPONSE");return a}async function D(e,t,i){let r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},n=I(r),a=await x(`${n.apiOrigin}/public/widget/events`,{body:JSON.stringify({event:e,...i?{objectId:i}:{},...r.variantId?{variantId:r.variantId}:{},timestamp:new Date().toISOString()}),cache:"no-store",headers:{...k(n),"Content-Type":"application/json","x-widget-session-token":t},keepalive:!0,method:"POST"},r);if(!a.ok)throw await L(a,"event");let o=await _(a);if(!o||"object"!=typeof o||Array.isArray(o)||"boolean"!=typeof o.ok)throw new S("INVALID_RESPONSE")}async function U(e,t,i){let r=i??l(),{apiOrigin:n,fetchImpl:a}=r,o=await x(`${n}/catalog/object`,{body:JSON.stringify({tinuuid:e}),headers:{...k(r),"Content-Type":"application/json"},method:"POST"},{fetchImpl:a,runtimeConfig:r,signal:t});if(!o.ok)throw await L(o,"object");let s=await _(o);if(!s||"object"!=typeof s||Array.isArray(s))throw new S("INVALID_RESPONSE");return s}async function V(e,t){let i=t??l();await i.fetchImpl(`${i.apiOrigin}/catalog/object/incr-views`,{body:JSON.stringify({tinuuid:e}),headers:{...k(i),"Content-Type":"application/json"},method:"POST"})}function M(e){try{let t=null==e?void 0:e();t instanceof Promise&&t.catch(()=>void 0)}catch{}}let W=w();function $(e){if(null==e?void 0:e.aborted)throw new DOMException("Aborted","AbortError")}async function q(e){var t,i,r;let n,a,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},s=W(e),l=e.getAttribute("data-native-link"),c=null==(t=e.dataset.objectTinuuid)?void 0:t.trim(),m=(null==(i=e.dataset.objectHid)?void 0:i.trim())||void 0;if(!c)throw Error("Object ID is required");$(o.signal);let w=o.loadObject??((e,t)=>U(e,t,o.runtimeConfig)),y=o.object??await w(c,o.signal);if($(o.signal),!s.isCurrent())return()=>void 0;let A=m?y.materials.find(e=>e.hid===m):y.materials[0];if(!(null==A||null==(r=A.native)?void 0:r.glbUrl)||!A.native.usdzUrl)throw Error("Native AR assets are unavailable");let E=v(A.native,y.type),C=u(),S=!1,I=!1,k=0;e.querySelector("img")||((n=document.createElement("img")).alt="",n.hidden=!0,e.appendChild(n));let T=()=>o.trackView?o.trackView():V(c,o.runtimeConfig),x=t=>{var i;t.preventDefault();let r=++k;null==a||a(),a=void 0,Promise.resolve((null==(i=o.getDesktopQrUrl)?void 0:i.call(o))??f(c,m,!0,o.runtimeConfig)).then(t=>{if(r===k&&s.isCurrent())return M(()=>{var e;return null==(e=o.onAction)?void 0:e.call(o,"interacted")}),O(t,`vizbl-${c}`,e,o.runtimeConfig)}).then(e=>{if(e){if(r!==k||!s.isCurrent())return void e();a=e}}).catch(()=>void 0)},z=async e=>{var t;let i;if(null==(t=o.webAr)?void 0:t.isAvailable()){if(e.preventDefault(),I)return;I=!0;let t=!1;try{t=await o.webAr.open().catch(()=>!1)}finally{I=!1}if(t||!s.isCurrent())return}if(i=h().toLowerCase(),["firefox","edge","opera"].some(e=>i.includes(e))){if(e.preventDefault(),S)return;S=!0,M(()=>{var e;return null==(e=o.onAction)?void 0:e.call(o,"ar_launched")});try{await Promise.resolve(T()).catch(()=>void 0)}finally{S=!1,d()&&g()?b(c,m,o.runtimeConfig):p(E)}return}M(()=>{var e;return null==(e=o.onAction)?void 0:e.call(o,"ar_launched")}),M(T),d()&&g()?(e.preventDefault(),b(c,m,o.runtimeConfig)):p(E)};return C?(e.dataset.nativeLink=E,e.addEventListener("click",z)):e.addEventListener("click",x),s.register(()=>{k+=1,e.removeEventListener("click",x),e.removeEventListener("click",z),null==a||a(),null==n||n.remove(),null===l?e.removeAttribute("data-native-link"):e.setAttribute("data-native-link",l)})}async function B(){let[{ModelViewerDialog:e},{createElement:t},{createRoot:i}]=await Promise.all([Promise.all([a.e("759"),a.e("117"),a.e("872"),a.e("59"),a.e("548")]).then(a.bind(a,5535)),a.e("986").then(a.t.bind(a,9081,19)),Promise.all([a.e("117"),a.e("886")]).then(a.t.bind(a,8181,19))]);return{open:r=>{let{onClose:n,...a}=r,o=document.createElement("div");o.setAttribute("data-core-ar-model-viewer",""),document.body.appendChild(o);let s=i(o),l=!1,c=i=>s.render(t(e,{...a,onOpenChange:e=>{e||d()},open:i}));function d(){l||(l=!0,c(!1),setTimeout(()=>{s.unmount(),o.remove()},300),null==n||n())}return c(!0),d}}}let K=["cm","inch"],H=["x","y","z"],F=[...H],Q=w();function Y(e){return e&&K.includes(e)?e:"inch"}function J(e){if(!e)return F;let t=Array.from(new Set(e.split(",").map(e=>e.trim().toLowerCase()).filter(e=>H.includes(e))));return t.length>0?t:F}let X=w();function Z(e){if(null==e?void 0:e.aborted)throw new DOMException("Aborted","AbortError")}async function G(e){var t,i,r;let n,a,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},s=X(e),l=e.getAttribute("href"),c=e.getAttribute("rel"),d=null==(t=e.dataset.objectTinuuid)?void 0:t.trim(),h=(null==(i=e.dataset.objectHid)?void 0:i.trim())||void 0;if(!d)throw Error("Object ID is required");Z(o.signal);let g=o.loadObject??((e,t)=>U(e,t,o.runtimeConfig)),m=o.object??await g(d,o.signal);if(Z(o.signal),!s.isCurrent())return()=>void 0;let b=h?m.materials.find(e=>e.hid===h):m.materials[0];if(!(null==b||null==(r=b.native)?void 0:r.glbUrl)||!b.native.usdzUrl)throw Error("Native AR assets are unavailable");let w=v(b.native,m.type),y=u(),A=!1,E=0;e.rel="ar",e.querySelector("img")||((n=document.createElement("img")).alt="",n.hidden=!0,e.appendChild(n));let C=t=>{var i;t.preventDefault();let r=++E;null==a||a(),a=void 0,Promise.resolve((null==(i=o.getDesktopQrUrl)?void 0:i.call(o))??f(d,h,!1,o.runtimeConfig)).then(t=>{if(r===E&&s.isCurrent())return M(()=>{var e;return null==(e=o.onAction)?void 0:e.call(o,"interacted")}),O(t,`vizbl-${d}`,e,o.runtimeConfig)}).then(e=>{if(e){if(r!==E||!s.isCurrent())return void e();a=e}}).catch(()=>void 0)},S=()=>{M(o.trackView??(()=>V(d,o.runtimeConfig))),M(()=>{var e;return null==(e=o.onAction)?void 0:e.call(o,"ar_launched")})},I=async e=>{var t;if(!(null==(t=o.webAr)?void 0:t.isAvailable()))return void S();if(e.preventDefault(),A)return;A=!0;let i=!1;try{i=await o.webAr.open().catch(()=>!1)}finally{A=!1}!i&&s.isCurrent()&&(S(),p(w))};return y?(e.href=w,e.addEventListener("click",I)):(e.href="#",e.addEventListener("click",C)),s.register(()=>{E+=1,e.removeEventListener("click",C),e.removeEventListener("click",I),null==a||a(),null==n||n.remove(),null===l?e.removeAttribute("href"):e.setAttribute("href",l),null===c?e.removeAttribute("rel"):e.setAttribute("rel",c)})}async function ee(){let{ArDialog:e,prepareArSessionInPage:t}=await Promise.all([a.e("117"),a.e("59"),a.e("270"),a.e("152")]).then(a.bind(a,5907)),{createElement:i}=await a.e("986").then(a.t.bind(a,9081,19)),{createRoot:r}=await Promise.all([a.e("117"),a.e("886")]).then(a.t.bind(a,8181,19));return{open:t=>{let{onClose:n,...a}=t,o=document.createElement("div");o.setAttribute("data-core-ar-web-ar",""),document.body.appendChild(o);let s=r(o),l=!1,c=t=>s.render(i(e,{...a,onOpenChange:e=>{e||d()},open:t}));function d(){l||(l=!0,c(!1),setTimeout(()=>{s.unmount(),o.remove()},300),null==n||n())}return c(!0),d},prepare:t}}async function et(e){let t=await function(){if(n)return n;let e=ee();return n=e,e.catch(()=>{n===e&&(n=void 0)}),e}();return await t.prepare(e)?t:null}let ei=["advanced-ar","ar-one-click","ar-viewer"],er={arizo:"arizo-core",vizbl:"vizbl-core"},en=new Set(["core-ar","core-ar-shopify"]),ea={arizo:{"advanced-ar":"Посмотреть в расширенной AR","ar-one-click":"Посмотреть в AR","ar-viewer":"Посмотреть в 3D и AR"},vizbl:{"advanced-ar":"View in advanced AR","ar-one-click":"View in AR","ar-viewer":"View in 3D & AR"}},eo={"advanced-ar":"advanced-ar-view","ar-one-click":"ar-view","ar-viewer":"ar-viewer"},es=["api-key","camera-orbit","dev","dimension-axes","max-camera-orbit","min-camera-orbit","object-id","size-type","trigger-class","type","variant-id"],el=new Set(["API_UNAVAILABLE","INVALID_RESPONSE","NETWORK_ERROR","REQUEST_FAILED","SESSION_EXPIRED"]),ec="core-ar-widget-styles";class ed extends Error{constructor(e){super(e),(0,o._)(this,"code",void 0),this.code=e,this.name="CoreArWidgetComponentError"}}function eu(e){return ei.includes(e)}function eh(e,t){let i=Array.isArray(e.materials)?e.materials:[],r=t?i.find(e=>e.hid===t):i[0];if(!r)throw new ed(t?"VARIANT_NOT_FOUND":"MODEL_UNAVAILABLE");return r}function eg(e,t){var i;if("ar-one-click"===e&&(null==(i=t.policy)?void 0:i.instantArView)===!1)throw new ed("POLICY_DENIED")}let em="u"<typeof HTMLElement?class{}:HTMLElement;class ev extends em{static get observedAttributes(){return[...es]}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)}connectedCallback(){!function(){if(document.getElementById(ec))return;let e=document.createElement("style");e.id=ec,e.textContent=`
|
|
2
2
|
:where(vizbl-core, arizo-core) {
|
|
3
3
|
display: inline-block;
|
|
4
4
|
--core-ar-widget-background: #3556f0;
|
|
@@ -90,4 +90,4 @@
|
|
|
90
90
|
transform: rotate(360deg);
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
|
-
`,document.head.appendChild(e)}(),this.captureCustomLabel(),this.queueInitialization()}disconnectedCallback(){var e,t;this.initializationRevision+=1,null==(e=this.abortController)||e.abort(),this.abortController=void 0,null==(t=this.cleanup)||t.call(this),this.cleanup=void 0,this.clearActionResetTimer()}attributeChangedCallback(e,t,r){if(t!==r){if("trigger-class"===e)return void this.applyTriggerClass();if(("api-key"===e||"dev"===e)&&(this.session=void 0),this.isConnected){var i,n;null==(i=this.abortController)||i.abort(),null==(n=this.cleanup)||n.call(this),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=>{var t;return e.nodeType!==Node.TEXT_NODE||!!(null==(t=e.textContent)?void 0:t.trim())});this.customLabelNodes=t?e:[]}queueInitialization(){this.queued||(this.queued=!0,queueMicrotask(()=>{this.queued=!1,this.isConnected&&this.initialize()}))}async initialize(){var e,t,r,i,n,a,o,s,l,c,d,h;let g=++this.initializationRevision;null==(e=this.abortController)||e.abort(),null==(t=this.cleanup)||t.call(this),this.cleanup=void 0,this.object=void 0,this.variantId=void 0,this.widgetMode=void 0,this.clearActionResetTimer();let m=new AbortController;this.abortController=m;let v=(null==(r=this.getAttribute("type"))?void 0:r.trim())??"",p=eu(v)?v:"ar-viewer",f=(null==(i=this.getAttribute("object-id"))?void 0:i.trim())??"",b=(null==(n=this.getAttribute("variant-id"))?void 0:n.trim())||void 0,w=(null==(a=this.getAttribute("api-key"))?void 0:a.trim())??"",y=(null==(o=this.getAttribute("size-type"))?void 0:o.trim())||void 0,A=(null==(s=this.getAttribute("dimension-axes"))?void 0:s.trim())||void 0,E=(null==(l=this.getAttribute("camera-orbit"))?void 0:l.trim())||void 0,C=(null==(c=this.getAttribute("min-camera-orbit"))?void 0:c.trim())||void 0,O=(null==(d=this.getAttribute("max-camera-orbit"))?void 0:d.trim())||void 0;this.removeAttribute("data-error-code"),this.setState("loading"),this.renderTrigger(p);try{let e,t=this.resolveRuntimeConfig();if(!w)throw new ed("MISSING_API_KEY");if(!f)throw new ed("MISSING_OBJECT_ID");if(!eu(v))throw new ed("INVALID_TYPE");if("ar-viewer"===v&&y&&"cm"!==y&&"inch"!==y)throw new ed("INVALID_SIZE_TYPE");let r=eo[v],i=await this.ensureSession(w,t,r,m.signal);if(this.assertCurrent(g,m.signal),this.variantId=b,this.widgetMode=r,this.applyIntegrationData(f,b,y,A,E,C,O),"ar-viewer"===v)e=await U(f,m.signal,t),this.assertCurrent(g,m.signal),eh(e,b),eg(v,e),this.object=e;else{e=u()?await this.fetchObjectWithSession(f,w,i,t,m.signal,b):await U(f,m.signal,t),this.assertCurrent(g,m.signal);let r=eh(e,b);if(eg(v,e),!(null==(h=r.native)?void 0:h.glbUrl)||!r.native.usdzUrl)throw new ed("MODEL_UNAVAILABLE");this.object=e}let n=await this.initializeTrigger(v,e,t,m.signal,w,i);try{this.assertCurrent(g,m.signal)}catch(e){throw n(),e}this.cleanup=()=>{var e;n(),null==(e=this.closeWebAr)||e.call(this)},this.setState("ready"),this.dispatchWidgetEvent("core-ar-ready",{objectId:f,type:v})}catch(t){if(g!==this.initializationRevision||m.signal.aborted||t instanceof DOMException&&"AbortError"===t.name)return;let e=t instanceof ed||t instanceof S?t.code:"INITIALIZATION_FAILED";this.setAttribute("data-error-code",e),this.setState("error"),this.dispatchWidgetEvent("core-ar-error",{code:e,objectId:f,type:v})}}failInteraction(e,t){var r;this.isConnected&&(this.setAttribute("data-error-code",e),this.setState("error"),this.dispatchWidgetEvent("core-ar-error",{code:e,objectId:(null==(r=this.getAttribute("object-id"))?void 0:r.trim())??"",type:t}))}async ensureSession(e,t,r,i){var n;let a=arguments.length>4&&void 0!==arguments[4]&&arguments[4],o=`${t.apiOrigin}|${t.viewerOrigin}|${t.modelViewerOrigin}|${r}`,s=(null==(n=this.session)?void 0:n.publicKey)===e&&this.session.runtimeKey===o?this.session:void 0;if(s&&!a&&s.expiresAt-Date.now()>3e4)return s;if(s)try{let r=await j(e,s.token,{mode:s.mode,runtimeConfig:t,signal:i}),n={...s,...r,expiresAt:Date.now()+1e3*r.expiresIn};return this.session=n,n}catch(e){if(!(e instanceof S)||!el.has(e.code))throw e;this.session=void 0}let l=await R(e,{mode:r,runtimeConfig:t,signal:i});if(!en.has(l.productType))throw new ed("POLICY_DENIED");let c={expiresAt:Date.now()+1e3*l.expiresIn,mode:r,productType:l.productType,publicKey:e,runtimeKey:o,sid:l.sid,token:l.token};return this.session=c,c}async fetchObjectWithSession(e,t,r,i,n,a){try{return await N(e,r.token,{runtimeConfig:i,signal:n,variantId:a})}catch(o){if(!(o instanceof S)||"SESSION_EXPIRED"!==o.code)throw o;return N(e,(await this.ensureSession(t,i,r.mode,n,!0)).token,{runtimeConfig:i,signal:n,variantId:a})}}assertCurrent(e,t){if(e!==this.initializationRevision||t.aborted)throw new DOMException("Aborted","AbortError")}renderTrigger(e){var t;let r="ar-one-click"===e?document.createElement("a"):document.createElement("button");if(r.dataset.coreArWidgetTrigger="",r.setAttribute("part","trigger"),r.addEventListener("click",e=>{"ready"!==this.dataset.state&&(e.preventDefault(),e.stopImmediatePropagation())}),r instanceof HTMLButtonElement&&(r.type="button"),r instanceof HTMLAnchorElement&&(r.href="#",r.rel="ar"),"ar-viewer"===e&&r.setAttribute("aria-haspopup","dialog"),"ar-viewer"!==e){let e=document.createElement("img");e.alt="",e.hidden=!0,r.appendChild(e)}let i=document.createElement("span");i.dataset.coreArWidgetLabel="",(null==(t=this.customLabelNodes)?void 0:t.length)?i.append(...this.customLabelNodes):i.textContent=ea[this.resolveRuntimeConfig().brand][e],r.appendChild(i),this.trigger=r,this.applyTriggerClass(),this.replaceChildren(r),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,r,i,n,a,o){this.trigger&&(this.trigger.dataset.objectTinuuid=e,t?this.trigger.dataset.objectHid=t:delete this.trigger.dataset.objectHid,r?this.trigger.dataset.sizeType=r:delete this.trigger.dataset.sizeType,i?this.trigger.dataset.dimensionAxes=i:delete this.trigger.dataset.dimensionAxes,n?this.trigger.dataset.cameraOrbit=n:delete this.trigger.dataset.cameraOrbit,a?this.trigger.dataset.minCameraOrbit=a:delete this.trigger.dataset.minCameraOrbit,o?this.trigger.dataset.maxCameraOrbit=o:delete this.trigger.dataset.maxCameraOrbit)}async initializeTrigger(e,t,r,n,a,o){if(!this.trigger)throw new ed("INITIALIZATION_FAILED");if("ar-viewer"===e){var s,c;let t,d,u,h;return s=this.trigger,c={apiKey:a,getWidgetSessionToken:async()=>(await this.ensureSession(a,r,o.mode)).token,lang:"arizo"===r.brand?"ru":"en",launchAr:ep()?e=>this.openWebAr({apiBaseUrl:e.apiBaseUrl??r.apiOrigin,apiKey:e.apiKey??a,hid:e.hid,language:e.lang,name:e.name,tinuuid:e.tinuuid},()=>e.widgetSessionToken,()=>!n.aborted):void 0,mode:o.mode,modelViewerOrigin:r.modelViewerOrigin,onAction:e=>this.handleAction(e,r),onClose:()=>{this.isConnected&&this.setState("ready")},onError:()=>this.failInteraction("VIEWER_UNAVAILABLE",e),onLoading:()=>this.setState("loading"),onOpen:()=>this.setState("opening"),viewer:{apiBaseUrl:r.apiOrigin},widgetSessionToken:o.token},d=Q(s),u=!1,h=async()=>{var e,r;if(t||u)return;let n=null==(e=s.dataset.objectTinuuid)?void 0:e.trim();if(n){u=!0,M(()=>{var e;return null==(e=c.onLoading)?void 0:e.call(c)});try{let e=c.getWidgetSessionToken?await c.getWidgetSessionToken():c.widgetSessionToken,r=await function(){if(i)return i;let e=B();return i=e,e.catch(()=>{i===e&&(i=void 0)}),e}();if(t||!d.isCurrent())return;let a=c.modelViewerOrigin??l().modelViewerOrigin,o=!1;t=r.open({apiBaseUrl:c.viewer.apiBaseUrl,apiKey:c.apiKey,cameraOrbit:s.dataset.cameraOrbit,dimensionAxes:J(s.dataset.dimensionAxes),handoffUrl:new URL("/model-viewer",a).toString(),hid:s.dataset.objectHid,initialWidgetSessionToken:e,lang:c.lang,launchAr:c.launchAr,maxCameraOrbit:s.dataset.maxCameraOrbit,minCameraOrbit:s.dataset.minCameraOrbit,mode:c.mode,onClose:()=>{var e;o||(o=!0,t=void 0,null==(e=c.onClose)||e.call(c),s.focus({preventScroll:!0}))},sizeType:Y(s.dataset.sizeType),tinuuid:n})}catch(e){d.isCurrent()&&M(()=>{var t;return null==(t=c.onError)?void 0:t.call(c,e)});return}finally{u=!1}null==(r=c.onOpen)||r.call(c),M(()=>{var e;return null==(e=c.onAction)?void 0:e.call(c,"widget_opened")})}},s.addEventListener("click",h),d.register(()=>{s.removeEventListener("click",h),null==t||t(),t=void 0})}if(!t)throw new ed("INITIALIZATION_FAILED");let d={getDesktopQrUrl:async()=>{var e,t,i,n,s,c,d;let u,h,g,m=await this.ensureSession(a,r,o.mode);return u=new URL("/model-viewer",(d={apiKey:a,cameraOrbit:null==(e=this.trigger)?void 0:e.dataset.cameraOrbit,dimensionAxes:J(null==(t=this.trigger)?void 0:t.dataset.dimensionAxes),hid:this.variantId,lang:"arizo"===r.brand?"ru":"en",maxCameraOrbit:null==(i=this.trigger)?void 0:i.dataset.maxCameraOrbit,minCameraOrbit:null==(n=this.trigger)?void 0:n.dataset.minCameraOrbit,mode:m.mode,modelViewerOrigin:r.modelViewerOrigin,sizeType:Y(null==(s=this.trigger)?void 0:s.dataset.sizeType),tinuuid:(null==(c=this.trigger)?void 0:c.dataset.objectTinuuid)??"",widgetSessionToken:m.token}).modelViewerOrigin??l().modelViewerOrigin),h=d.dimensionAxes??F,u.searchParams.set("tinuuid",d.tinuuid),d.hid&&u.searchParams.set("hid",d.hid),u.searchParams.set("size-type",d.sizeType),h.length<F.length&&u.searchParams.set("dimension-axes",h.join(",")),d.cameraOrbit&&u.searchParams.set("camera-orbit",d.cameraOrbit),d.minCameraOrbit&&u.searchParams.set("min-camera-orbit",d.minCameraOrbit),d.maxCameraOrbit&&u.searchParams.set("max-camera-orbit",d.maxCameraOrbit),d.lang&&u.searchParams.set("lang",d.lang),g=new URLSearchParams,d.apiKey&&g.set("api-key",d.apiKey),d.mode&&g.set("mode",d.mode),d.widgetSessionToken&&g.set("widget-session-token",d.widgetSessionToken),u.hash=g.toString(),u.toString()},object:t,onAction:e=>this.handleAction(e,r),runtimeConfig:r,signal:n,trackView:()=>this.trackEvent("ar_launched",r),webAr:this.createWebArLauncher(t,a,r,o.mode,n)};if("ar-one-click"===e){if(!(this.trigger instanceof HTMLAnchorElement))throw new ed("INITIALIZATION_FAILED");return G(this.trigger,d)}return q(this.trigger,d)}createWebArLauncher(e,t,r,i,n){let a=()=>!n.aborted;return{isAvailable:ep,open:async()=>{var n;this.setState("loading");let o=await this.openWebAr({apiBaseUrl:r.apiOrigin,apiKey:t,hid:this.variantId,language:"arizo"===r.brand?"ru":"en",name:"string"==typeof e.name?e.name:void 0,onClose:()=>{a()&&this.setState("ready")},tinuuid:(null==(n=this.trigger)?void 0:n.dataset.objectTinuuid)??e.tinuuid},async()=>(await this.ensureSession(t,r,i)).token,a);return a()&&this.setState(o?"opening":"ready"),o}}}async openWebAr(e,t,r){var i,n;let a=null==(i=e.tinuuid)?void 0:i.trim();if(!a)return!1;let[o,s]=await (function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3e3;return new Promise((r,i)=>{let n=setTimeout(()=>r(null),t);e.then(e=>{clearTimeout(n),r(e)},e=>{clearTimeout(n),i(e)})})})(Promise.all([et(a),Promise.resolve().then(t)])).catch(()=>null)??[];if(!o||!this.isConnected||!r())return!1;null==(n=this.closeWebAr)||n.call(this);let l=o.open({...e,initialWidgetSessionToken:s,onClose:()=>{var t;this.closeWebAr===l&&(this.closeWebAr=void 0),null==(t=e.onClose)||t.call(e)}});return this.closeWebAr=l,!0}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){var r,i;let n=null==(r=this.getAttribute("api-key"))?void 0:r.trim(),a=this.widgetMode;if(n&&a&&this.isConnected)try{let r=await this.ensureSession(n,t,a);await D(e,r.token,null==(i=this.object)?void 0:i.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}))}constructor(...e){super(...e),(0,o._)(this,"abortController",void 0),(0,o._)(this,"actionResetTimer",void 0),(0,o._)(this,"cleanup",void 0),(0,o._)(this,"closeWebAr",void 0),(0,o._)(this,"customLabelNodes",null),(0,o._)(this,"initializationRevision",0),(0,o._)(this,"object",void 0),(0,o._)(this,"queued",!1),(0,o._)(this,"session",void 0),(0,o._)(this,"trigger",void 0),(0,o._)(this,"variantId",void 0),(0,o._)(this,"widgetMode",void 0)}}function ep(){return u()&&!d()}function ef(e){if("u"<typeof customElements)return;let t=ei[e],r=customElements.get(t);if(r)return r;class i extends ev{resolveRuntimeConfig(){return function(e){var t;let r,i,n,a,o,l=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"prod",c="arizo"===e?"arizo.ru":"vizbl.com",d="dev"===l?"-dev":"";return r=s((t={apiOrigin:`https://api${d}.${c}`,modelViewerOrigin:`https://integrations${d}.${c}`,viewerOrigin:`https://viewer${d}.${c}`}).apiOrigin,"apiOrigin"),i=s(t.viewerOrigin,"viewerOrigin"),o=t.modelViewerOrigin?s(t.modelViewerOrigin,"modelViewerOrigin"):(a=(n=new URL(i)).hostname.match(/^viewer(-dev)?\.(vizbl\.com|arizo\.ru)$/))?`${n.protocol}//integrations${a[1]??""}.${a[2]}`:i,{apiOrigin:r,brand:new URL(i).hostname.endsWith("arizo.ru")?"arizo":"vizbl",fetchImpl:t.fetchImpl??fetch,modelViewerOrigin:o,qrCodeScriptUrl:t.qrCodeScriptUrl??`${i}/vendor/qrcode.min.js`,viewerOrigin:i}}(e,this.hasAttribute("dev")?"dev":"prod")}}return customElements.define(t,i),i}ef("arizo"),ef("vizbl")})()})();
|
|
93
|
+
`,document.head.appendChild(e)}(),this.captureCustomLabel(),this.queueInitialization()}disconnectedCallback(){var e,t;this.initializationRevision+=1,null==(e=this.abortController)||e.abort(),this.abortController=void 0,null==(t=this.cleanup)||t.call(this),this.cleanup=void 0,this.clearActionResetTimer()}attributeChangedCallback(e,t,i){if(t!==i){if("trigger-class"===e)return void this.applyTriggerClass();if(("api-key"===e||"dev"===e)&&(this.session=void 0),this.isConnected){var r,n;null==(r=this.abortController)||r.abort(),null==(n=this.cleanup)||n.call(this),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=>{var t;return e.nodeType!==Node.TEXT_NODE||!!(null==(t=e.textContent)?void 0:t.trim())});this.customLabelNodes=t?e:[]}queueInitialization(){this.queued||(this.queued=!0,queueMicrotask(()=>{this.queued=!1,this.isConnected&&this.initialize()}))}async initialize(){var e,t,i,r,n,a,o,s,l,c,d,h;let g=++this.initializationRevision;null==(e=this.abortController)||e.abort(),null==(t=this.cleanup)||t.call(this),this.cleanup=void 0,this.object=void 0,this.variantId=void 0,this.widgetMode=void 0,this.clearActionResetTimer();let m=new AbortController;this.abortController=m;let v=(null==(i=this.getAttribute("type"))?void 0:i.trim())??"",p=eu(v)?v:"ar-viewer",b=(null==(r=this.getAttribute("object-id"))?void 0:r.trim())??"",f=(null==(n=this.getAttribute("variant-id"))?void 0:n.trim())||void 0,w=(null==(a=this.getAttribute("api-key"))?void 0:a.trim())??"",y=(null==(o=this.getAttribute("size-type"))?void 0:o.trim())||void 0,A=(null==(s=this.getAttribute("dimension-axes"))?void 0:s.trim())||void 0,E=(null==(l=this.getAttribute("camera-orbit"))?void 0:l.trim())||void 0,C=(null==(c=this.getAttribute("min-camera-orbit"))?void 0:c.trim())||void 0,O=(null==(d=this.getAttribute("max-camera-orbit"))?void 0:d.trim())||void 0;this.removeAttribute("data-error-code"),this.setState("loading"),this.renderTrigger(p);try{let e,t=this.resolveRuntimeConfig();if(!w&&!function(){var e;let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:(null==(e=globalThis.location)?void 0:e.hostname)??"",i=t.toLowerCase();return["vizbl.com","vizbl.us","arizo.ru"].some(e=>i===e||i.endsWith(`.${e}`))}())throw new ed("MISSING_API_KEY");if(!b)throw new ed("MISSING_OBJECT_ID");if(!eu(v))throw new ed("INVALID_TYPE");if("ar-viewer"===v&&y&&"cm"!==y&&"inch"!==y)throw new ed("INVALID_SIZE_TYPE");let i=eo[v],r=w?await this.ensureSession(w,t,i,m.signal):void 0;if(this.assertCurrent(g,m.signal),this.variantId=f,this.widgetMode=i,this.applyIntegrationData(b,f,y,A,E,C,O),"ar-viewer"===v)e=await U(b,m.signal,t),this.assertCurrent(g,m.signal),eh(e,f),eg(v,e),this.object=e;else{e=u()&&r?await this.fetchObjectWithSession(b,w,r,t,m.signal,f):await U(b,m.signal,t),this.assertCurrent(g,m.signal);let i=eh(e,f);if(eg(v,e),!(null==(h=i.native)?void 0:h.glbUrl)||!i.native.usdzUrl)throw new ed("MODEL_UNAVAILABLE");this.object=e}let n=await this.initializeTrigger(v,e,t,m.signal,w,r);try{this.assertCurrent(g,m.signal)}catch(e){throw n(),e}this.cleanup=()=>{var e;n(),null==(e=this.closeWebAr)||e.call(this)},this.setState("ready"),this.dispatchWidgetEvent("core-ar-ready",{objectId:b,type:v})}catch(t){if(g!==this.initializationRevision||m.signal.aborted||t instanceof DOMException&&"AbortError"===t.name)return;let e=t instanceof ed||t instanceof S?t.code:"INITIALIZATION_FAILED";this.setAttribute("data-error-code",e),this.setState("error"),this.dispatchWidgetEvent("core-ar-error",{code:e,objectId:b,type:v})}}failInteraction(e,t){var i;this.isConnected&&(this.setAttribute("data-error-code",e),this.setState("error"),this.dispatchWidgetEvent("core-ar-error",{code:e,objectId:(null==(i=this.getAttribute("object-id"))?void 0:i.trim())??"",type:t}))}async ensureSession(e,t,i,r){var n;let a=arguments.length>4&&void 0!==arguments[4]&&arguments[4],o=`${t.apiOrigin}|${t.viewerOrigin}|${t.modelViewerOrigin}|${i}`,s=(null==(n=this.session)?void 0:n.publicKey)===e&&this.session.runtimeKey===o?this.session:void 0;if(s&&!a&&s.expiresAt-Date.now()>3e4)return s;if(s)try{let i=await j(e,s.token,{mode:s.mode,runtimeConfig:t,signal:r}),n={...s,...i,expiresAt:Date.now()+1e3*i.expiresIn};return this.session=n,n}catch(e){if(!(e instanceof S)||!el.has(e.code))throw e;this.session=void 0}let l=await R(e,{mode:i,runtimeConfig:t,signal:r});if(!en.has(l.productType))throw new ed("POLICY_DENIED");let c={expiresAt:Date.now()+1e3*l.expiresIn,mode:i,productType:l.productType,publicKey:e,runtimeKey:o,sid:l.sid,token:l.token};return this.session=c,c}async fetchObjectWithSession(e,t,i,r,n,a){try{return await N(e,i.token,{runtimeConfig:r,signal:n,variantId:a})}catch(o){if(!(o instanceof S)||"SESSION_EXPIRED"!==o.code)throw o;return N(e,(await this.ensureSession(t,r,i.mode,n,!0)).token,{runtimeConfig:r,signal:n,variantId:a})}}assertCurrent(e,t){if(e!==this.initializationRevision||t.aborted)throw new DOMException("Aborted","AbortError")}renderTrigger(e){var t;let i="ar-one-click"===e?document.createElement("a"):document.createElement("button");if(i.dataset.coreArWidgetTrigger="",i.setAttribute("part","trigger"),i.addEventListener("click",e=>{"ready"!==this.dataset.state&&(e.preventDefault(),e.stopImmediatePropagation())}),i instanceof HTMLButtonElement&&(i.type="button"),i instanceof HTMLAnchorElement&&(i.href="#",i.rel="ar"),"ar-viewer"===e&&i.setAttribute("aria-haspopup","dialog"),"ar-viewer"!==e){let e=document.createElement("img");e.alt="",e.hidden=!0,i.appendChild(e)}let r=document.createElement("span");r.dataset.coreArWidgetLabel="",(null==(t=this.customLabelNodes)?void 0:t.length)?r.append(...this.customLabelNodes):r.textContent=ea[this.resolveRuntimeConfig().brand][e],i.appendChild(r),this.trigger=i,this.applyTriggerClass(),this.replaceChildren(i),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,a,o){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,a?this.trigger.dataset.minCameraOrbit=a:delete this.trigger.dataset.minCameraOrbit,o?this.trigger.dataset.maxCameraOrbit=o:delete this.trigger.dataset.maxCameraOrbit)}async initializeTrigger(e,t,i,n,a,o){if(!this.trigger)throw new ed("INITIALIZATION_FAILED");let s=eo[e];if("ar-viewer"===e){var c,d;let t,u,h,g;return c=this.trigger,d={apiKey:a,getWidgetSessionToken:a?async()=>(await this.ensureSession(a,i,s)).token:void 0,lang:"arizo"===i.brand?"ru":"en",launchAr:ep()?e=>this.openWebAr({apiBaseUrl:e.apiBaseUrl??i.apiOrigin,apiKey:e.apiKey??a,hid:e.hid,language:e.lang,name:e.name,tinuuid:e.tinuuid},()=>e.widgetSessionToken,()=>!n.aborted):void 0,mode:s,modelViewerOrigin:i.modelViewerOrigin,onAction:e=>this.handleAction(e,i),onClose:()=>{this.isConnected&&this.setState("ready")},onError:()=>this.failInteraction("VIEWER_UNAVAILABLE",e),onLoading:()=>this.setState("loading"),onOpen:()=>this.setState("opening"),viewer:{apiBaseUrl:i.apiOrigin},widgetSessionToken:null==o?void 0:o.token},u=Q(c),h=!1,g=async()=>{var e,i;if(t||h)return;let n=null==(e=c.dataset.objectTinuuid)?void 0:e.trim();if(n){h=!0,M(()=>{var e;return null==(e=d.onLoading)?void 0:e.call(d)});try{let e=d.getWidgetSessionToken?await d.getWidgetSessionToken():d.widgetSessionToken,i=await function(){if(r)return r;let e=B();return r=e,e.catch(()=>{r===e&&(r=void 0)}),e}();if(t||!u.isCurrent())return;let a=d.modelViewerOrigin??l().modelViewerOrigin,o=!1;t=i.open({apiBaseUrl:d.viewer.apiBaseUrl,apiKey:d.apiKey,cameraOrbit:c.dataset.cameraOrbit,dimensionAxes:J(c.dataset.dimensionAxes),handoffUrl:new URL("/model-viewer",a).toString(),hid:c.dataset.objectHid,initialWidgetSessionToken:e,lang:d.lang,launchAr:d.launchAr,maxCameraOrbit:c.dataset.maxCameraOrbit,minCameraOrbit:c.dataset.minCameraOrbit,mode:d.mode,onClose:()=>{var e;o||(o=!0,t=void 0,null==(e=d.onClose)||e.call(d),c.focus({preventScroll:!0}))},sizeType:Y(c.dataset.sizeType),tinuuid:n})}catch(e){u.isCurrent()&&M(()=>{var t;return null==(t=d.onError)?void 0:t.call(d,e)});return}finally{h=!1}null==(i=d.onOpen)||i.call(d),M(()=>{var e;return null==(e=d.onAction)?void 0:e.call(d,"widget_opened")})}},c.addEventListener("click",g),u.register(()=>{c.removeEventListener("click",g),null==t||t(),t=void 0})}if(!t)throw new ed("INITIALIZATION_FAILED");let u={getDesktopQrUrl:async()=>{var e,t,r,n,o,c,d;let u,h,g,m=a?await this.ensureSession(a,i,s):void 0;return u=new URL("/model-viewer",(d={apiKey:a,cameraOrbit:null==(e=this.trigger)?void 0:e.dataset.cameraOrbit,dimensionAxes:J(null==(t=this.trigger)?void 0:t.dataset.dimensionAxes),hid:this.variantId,lang:"arizo"===i.brand?"ru":"en",maxCameraOrbit:null==(r=this.trigger)?void 0:r.dataset.maxCameraOrbit,minCameraOrbit:null==(n=this.trigger)?void 0:n.dataset.minCameraOrbit,mode:s,modelViewerOrigin:i.modelViewerOrigin,sizeType:Y(null==(o=this.trigger)?void 0:o.dataset.sizeType),tinuuid:(null==(c=this.trigger)?void 0:c.dataset.objectTinuuid)??"",widgetSessionToken:null==m?void 0:m.token}).modelViewerOrigin??l().modelViewerOrigin),h=d.dimensionAxes??F,u.searchParams.set("tinuuid",d.tinuuid),d.hid&&u.searchParams.set("hid",d.hid),u.searchParams.set("size-type",d.sizeType),h.length<F.length&&u.searchParams.set("dimension-axes",h.join(",")),d.cameraOrbit&&u.searchParams.set("camera-orbit",d.cameraOrbit),d.minCameraOrbit&&u.searchParams.set("min-camera-orbit",d.minCameraOrbit),d.maxCameraOrbit&&u.searchParams.set("max-camera-orbit",d.maxCameraOrbit),d.lang&&u.searchParams.set("lang",d.lang),g=new URLSearchParams,d.apiKey&&g.set("api-key",d.apiKey),d.mode&&g.set("mode",d.mode),d.widgetSessionToken&&g.set("widget-session-token",d.widgetSessionToken),u.hash=g.toString(),u.toString()},object:t,onAction:e=>this.handleAction(e,i),runtimeConfig:i,signal:n,trackView:()=>a?this.trackEvent("ar_launched",i):V(this.getAttribute("object-id")??"",i),webAr:this.createWebArLauncher(t,a,i,s,n)};if("ar-one-click"===e){if(!(this.trigger instanceof HTMLAnchorElement))throw new ed("INITIALIZATION_FAILED");return G(this.trigger,u)}return q(this.trigger,u)}createWebArLauncher(e,t,i,r,n){let a=()=>!n.aborted;return{isAvailable:ep,open:async()=>{var n;this.setState("loading");let o=await this.openWebAr({apiBaseUrl:i.apiOrigin,apiKey:t||void 0,hid:this.variantId,language:"arizo"===i.brand?"ru":"en",name:"string"==typeof e.name?e.name:void 0,onClose:()=>{a()&&this.setState("ready")},tinuuid:(null==(n=this.trigger)?void 0:n.dataset.objectTinuuid)??e.tinuuid},async()=>t?(await this.ensureSession(t,i,r)).token:void 0,a);return a()&&this.setState(o?"opening":"ready"),o}}}async openWebAr(e,t,i){var r,n;let a=null==(r=e.tinuuid)?void 0:r.trim();if(!a)return!1;let[o,s]=await (function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3e3;return new Promise((i,r)=>{let n=setTimeout(()=>i(null),t);e.then(e=>{clearTimeout(n),i(e)},e=>{clearTimeout(n),r(e)})})})(Promise.all([et(a),Promise.resolve().then(t)])).catch(()=>null)??[];if(!o||!this.isConnected||!i())return!1;null==(n=this.closeWebAr)||n.call(this);let l=!1,c=o.open({...e,initialWidgetSessionToken:s,onAnalyticsEvent:t=>{var r;return!i()||e.apiKey||s||l||"ar_session_started"!==t.name||(l=!0,V(a,this.resolveRuntimeConfig()).catch(()=>void 0)),null==(r=e.onAnalyticsEvent)?void 0:r.call(e,t)},onClose:()=>{var t;this.closeWebAr===c&&(this.closeWebAr=void 0),null==(t=e.onClose)||t.call(e)}});return this.closeWebAr=c,!0}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){var i,r;let n=null==(i=this.getAttribute("api-key"))?void 0:i.trim(),a=this.widgetMode;if(n&&a&&this.isConnected)try{let i=await this.ensureSession(n,t,a);await D(e,i.token,null==(r=this.object)?void 0:r.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}))}constructor(...e){super(...e),(0,o._)(this,"abortController",void 0),(0,o._)(this,"actionResetTimer",void 0),(0,o._)(this,"cleanup",void 0),(0,o._)(this,"closeWebAr",void 0),(0,o._)(this,"customLabelNodes",null),(0,o._)(this,"initializationRevision",0),(0,o._)(this,"object",void 0),(0,o._)(this,"queued",!1),(0,o._)(this,"session",void 0),(0,o._)(this,"trigger",void 0),(0,o._)(this,"variantId",void 0),(0,o._)(this,"widgetMode",void 0)}}function ep(){return u()&&!d()}function eb(e){if("u"<typeof customElements)return;let t=er[e],i=customElements.get(t);if(i)return i;class r extends ev{resolveRuntimeConfig(){return function(e){var t;let i,r,n,a,o,l=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"prod",c="arizo"===e?"arizo.ru":"vizbl.com",d="dev"===l?"-dev":"";return i=s((t={apiOrigin:`https://api${d}.${c}`,modelViewerOrigin:`https://integrations${d}.${c}`,viewerOrigin:`https://viewer${d}.${c}`}).apiOrigin,"apiOrigin"),r=s(t.viewerOrigin,"viewerOrigin"),o=t.modelViewerOrigin?s(t.modelViewerOrigin,"modelViewerOrigin"):(a=(n=new URL(r)).hostname.match(/^viewer(-dev)?\.(vizbl\.com|arizo\.ru)$/))?`${n.protocol}//integrations${a[1]??""}.${a[2]}`:r,{apiOrigin:i,brand:new URL(r).hostname.endsWith("arizo.ru")?"arizo":"vizbl",fetchImpl:t.fetchImpl??fetch,modelViewerOrigin:o,qrCodeScriptUrl:t.qrCodeScriptUrl??`${r}/vendor/qrcode.min.js`,viewerOrigin:r}}(e,this.hasAttribute("dev")?"dev":"prod")}}return customElements.define(t,r),r}eb("arizo"),eb("vizbl")})()})();
|
package/dist/index.js
CHANGED
|
@@ -977,6 +977,14 @@ async function initializeNativeArAnchor(link, options = {}) {
|
|
|
977
977
|
else link.setAttribute('rel', originalRel);
|
|
978
978
|
});
|
|
979
979
|
}
|
|
980
|
+
function isCoreArPublicHost(hostname = globalThis.location?.hostname ?? '') {
|
|
981
|
+
const host = hostname.toLowerCase();
|
|
982
|
+
return [
|
|
983
|
+
'vizbl.com',
|
|
984
|
+
'vizbl.us',
|
|
985
|
+
'arizo.ru'
|
|
986
|
+
].some((domain)=>host === domain || host.endsWith(`.${domain}`));
|
|
987
|
+
}
|
|
980
988
|
const WEB_AR_TAP_WINDOW_MS = 3000;
|
|
981
989
|
const web_ar_dialog_DIALOG_EXIT_MS = 300;
|
|
982
990
|
let web_ar_dialog_pendingLoad;
|
|
@@ -1313,12 +1321,12 @@ class CoreArWidgetElement extends HTMLElementBase {
|
|
|
1313
1321
|
this.renderTrigger(renderType);
|
|
1314
1322
|
try {
|
|
1315
1323
|
const runtimeConfig = this.resolveRuntimeConfig();
|
|
1316
|
-
if (!publicKey) throw new CoreArWidgetComponentError('MISSING_API_KEY');
|
|
1324
|
+
if (!publicKey && !isCoreArPublicHost()) throw new CoreArWidgetComponentError('MISSING_API_KEY');
|
|
1317
1325
|
if (!objectId) throw new CoreArWidgetComponentError('MISSING_OBJECT_ID');
|
|
1318
1326
|
if (!isCoreArWidgetType(rawType)) throw new CoreArWidgetComponentError('INVALID_TYPE');
|
|
1319
1327
|
if ('ar-viewer' === rawType && sizeType && 'cm' !== sizeType && 'inch' !== sizeType) throw new CoreArWidgetComponentError('INVALID_SIZE_TYPE');
|
|
1320
1328
|
const mode = BACKEND_WIDGET_MODES[rawType];
|
|
1321
|
-
const session = await this.ensureSession(publicKey, runtimeConfig, mode, abortController.signal);
|
|
1329
|
+
const session = publicKey ? await this.ensureSession(publicKey, runtimeConfig, mode, abortController.signal) : void 0;
|
|
1322
1330
|
this.assertCurrent(revision, abortController.signal);
|
|
1323
1331
|
this.variantId = variantId;
|
|
1324
1332
|
this.widgetMode = mode;
|
|
@@ -1331,7 +1339,7 @@ class CoreArWidgetElement extends HTMLElementBase {
|
|
|
1331
1339
|
assertPolicy(rawType, object);
|
|
1332
1340
|
this.object = object;
|
|
1333
1341
|
} else {
|
|
1334
|
-
object = isMobile() ? await this.fetchObjectWithSession(objectId, publicKey, session, runtimeConfig, abortController.signal, variantId) : await fetchPublicObject(objectId, abortController.signal, runtimeConfig);
|
|
1342
|
+
object = isMobile() && session ? await this.fetchObjectWithSession(objectId, publicKey, session, runtimeConfig, abortController.signal, variantId) : await fetchPublicObject(objectId, abortController.signal, runtimeConfig);
|
|
1335
1343
|
this.assertCurrent(revision, abortController.signal);
|
|
1336
1344
|
const material = getSelectedMaterial(object, variantId);
|
|
1337
1345
|
assertPolicy(rawType, object);
|
|
@@ -1490,12 +1498,13 @@ class CoreArWidgetElement extends HTMLElementBase {
|
|
|
1490
1498
|
}
|
|
1491
1499
|
async initializeTrigger(type, object, runtimeConfig, signal, publicKey, session) {
|
|
1492
1500
|
if (!this.trigger) throw new CoreArWidgetComponentError('INITIALIZATION_FAILED');
|
|
1501
|
+
const mode = BACKEND_WIDGET_MODES[type];
|
|
1493
1502
|
if ('ar-viewer' === type) return initializeModalTrigger(this.trigger, {
|
|
1494
1503
|
apiKey: publicKey,
|
|
1495
|
-
getWidgetSessionToken: async ()=>{
|
|
1496
|
-
const currentSession = await this.ensureSession(publicKey, runtimeConfig,
|
|
1504
|
+
getWidgetSessionToken: publicKey ? async ()=>{
|
|
1505
|
+
const currentSession = await this.ensureSession(publicKey, runtimeConfig, mode);
|
|
1497
1506
|
return currentSession.token;
|
|
1498
|
-
},
|
|
1507
|
+
} : void 0,
|
|
1499
1508
|
lang: 'arizo' === runtimeConfig.brand ? 'ru' : 'en',
|
|
1500
1509
|
launchAr: canOpenWebAr() ? (target)=>this.openWebAr({
|
|
1501
1510
|
apiBaseUrl: target.apiBaseUrl ?? runtimeConfig.apiOrigin,
|
|
@@ -1505,7 +1514,7 @@ class CoreArWidgetElement extends HTMLElementBase {
|
|
|
1505
1514
|
name: target.name,
|
|
1506
1515
|
tinuuid: target.tinuuid
|
|
1507
1516
|
}, ()=>target.widgetSessionToken, ()=>!signal.aborted) : void 0,
|
|
1508
|
-
mode
|
|
1517
|
+
mode,
|
|
1509
1518
|
modelViewerOrigin: runtimeConfig.modelViewerOrigin,
|
|
1510
1519
|
onAction: (action)=>this.handleAction(action, runtimeConfig),
|
|
1511
1520
|
onClose: ()=>{
|
|
@@ -1517,12 +1526,12 @@ class CoreArWidgetElement extends HTMLElementBase {
|
|
|
1517
1526
|
viewer: {
|
|
1518
1527
|
apiBaseUrl: runtimeConfig.apiOrigin
|
|
1519
1528
|
},
|
|
1520
|
-
widgetSessionToken: session
|
|
1529
|
+
widgetSessionToken: session?.token
|
|
1521
1530
|
});
|
|
1522
1531
|
if (!object) throw new CoreArWidgetComponentError('INITIALIZATION_FAILED');
|
|
1523
1532
|
const options = {
|
|
1524
1533
|
getDesktopQrUrl: async ()=>{
|
|
1525
|
-
const currentSession = await this.ensureSession(publicKey, runtimeConfig,
|
|
1534
|
+
const currentSession = publicKey ? await this.ensureSession(publicKey, runtimeConfig, mode) : void 0;
|
|
1526
1535
|
return createModalViewerUrl({
|
|
1527
1536
|
apiKey: publicKey,
|
|
1528
1537
|
cameraOrbit: this.trigger?.dataset.cameraOrbit,
|
|
@@ -1531,19 +1540,19 @@ class CoreArWidgetElement extends HTMLElementBase {
|
|
|
1531
1540
|
lang: 'arizo' === runtimeConfig.brand ? 'ru' : 'en',
|
|
1532
1541
|
maxCameraOrbit: this.trigger?.dataset.maxCameraOrbit,
|
|
1533
1542
|
minCameraOrbit: this.trigger?.dataset.minCameraOrbit,
|
|
1534
|
-
mode
|
|
1543
|
+
mode,
|
|
1535
1544
|
modelViewerOrigin: runtimeConfig.modelViewerOrigin,
|
|
1536
1545
|
sizeType: resolveSizeType(this.trigger?.dataset.sizeType),
|
|
1537
1546
|
tinuuid: this.trigger?.dataset.objectTinuuid ?? '',
|
|
1538
|
-
widgetSessionToken: currentSession
|
|
1547
|
+
widgetSessionToken: currentSession?.token
|
|
1539
1548
|
});
|
|
1540
1549
|
},
|
|
1541
1550
|
object,
|
|
1542
1551
|
onAction: (action)=>this.handleAction(action, runtimeConfig),
|
|
1543
1552
|
runtimeConfig,
|
|
1544
1553
|
signal,
|
|
1545
|
-
trackView: ()=>this.trackEvent('ar_launched', runtimeConfig),
|
|
1546
|
-
webAr: this.createWebArLauncher(object, publicKey, runtimeConfig,
|
|
1554
|
+
trackView: ()=>publicKey ? this.trackEvent('ar_launched', runtimeConfig) : incrementObjectViews(this.getAttribute('object-id') ?? '', runtimeConfig),
|
|
1555
|
+
webAr: this.createWebArLauncher(object, publicKey, runtimeConfig, mode, signal)
|
|
1547
1556
|
};
|
|
1548
1557
|
if ('ar-one-click' === type) {
|
|
1549
1558
|
if (!(this.trigger instanceof HTMLAnchorElement)) throw new CoreArWidgetComponentError('INITIALIZATION_FAILED');
|
|
@@ -1559,7 +1568,7 @@ class CoreArWidgetElement extends HTMLElementBase {
|
|
|
1559
1568
|
this.setState('loading');
|
|
1560
1569
|
const opened = await this.openWebAr({
|
|
1561
1570
|
apiBaseUrl: runtimeConfig.apiOrigin,
|
|
1562
|
-
apiKey: publicKey,
|
|
1571
|
+
apiKey: publicKey || void 0,
|
|
1563
1572
|
hid: this.variantId,
|
|
1564
1573
|
language: 'arizo' === runtimeConfig.brand ? 'ru' : 'en',
|
|
1565
1574
|
name: 'string' == typeof object.name ? object.name : void 0,
|
|
@@ -1567,7 +1576,7 @@ class CoreArWidgetElement extends HTMLElementBase {
|
|
|
1567
1576
|
if (isCurrent()) this.setState('ready');
|
|
1568
1577
|
},
|
|
1569
1578
|
tinuuid: this.trigger?.dataset.objectTinuuid ?? object.tinuuid
|
|
1570
|
-
}, async ()=>(await this.ensureSession(publicKey, runtimeConfig, mode)).token, isCurrent);
|
|
1579
|
+
}, async ()=>publicKey ? (await this.ensureSession(publicKey, runtimeConfig, mode)).token : void 0, isCurrent);
|
|
1571
1580
|
if (isCurrent()) this.setState(opened ? 'opening' : 'ready');
|
|
1572
1581
|
return opened;
|
|
1573
1582
|
}
|
|
@@ -1583,9 +1592,17 @@ class CoreArWidgetElement extends HTMLElementBase {
|
|
|
1583
1592
|
const [dialog, token] = ready ?? [];
|
|
1584
1593
|
if (!dialog || !this.isConnected || !isCurrent()) return false;
|
|
1585
1594
|
this.closeWebAr?.();
|
|
1595
|
+
let publicViewTracked = false;
|
|
1586
1596
|
const close = dialog.open({
|
|
1587
1597
|
...options,
|
|
1588
1598
|
initialWidgetSessionToken: token,
|
|
1599
|
+
onAnalyticsEvent: (event)=>{
|
|
1600
|
+
if (isCurrent() && !options.apiKey && !token && !publicViewTracked && 'ar_session_started' === event.name) {
|
|
1601
|
+
publicViewTracked = true;
|
|
1602
|
+
incrementObjectViews(tinuuid, this.resolveRuntimeConfig()).catch(()=>void 0);
|
|
1603
|
+
}
|
|
1604
|
+
return options.onAnalyticsEvent?.(event);
|
|
1605
|
+
},
|
|
1589
1606
|
onClose: ()=>{
|
|
1590
1607
|
if (this.closeWebAr === close) this.closeWebAr = void 0;
|
|
1591
1608
|
options.onClose?.();
|