Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@archilogic/embed-api

Package Overview
Dependencies
Maintainers
6
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@archilogic/embed-api - npm Package Compare versions

Comparing version 1.0.3 to 1.0.4

jest.config.js

7

dist/embed.d.ts

@@ -36,5 +36,6 @@ import { CallSender } from 'penpal/es5/types';

constructor(el: HTMLElement, options?: EmbedOptionsUpdate);
viewer: CallSender;
private options;
private listeners;
viewerInstance: CallSender;
options: EmbedOptions;
listeners: Map<any, any>;
get viewer(): CallSender;
readonly containerEl: HTMLElement;

@@ -41,0 +42,0 @@ readonly viewerEl: HTMLIFrameElement;

@@ -1,1 +0,1 @@

function e(){return(e=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(e[o]=r[o])}return e}).apply(this,arguments)}const t={"http:":"80","https:":"443"},r=/^(https?:)?\/\/([^/:]+)?(:(\d+))?/,o=["file:","data:"];var n,i,s,a,c;!function(e){e.Call="call",e.Reply="reply",e.Syn="syn",e.SynAck="synAck",e.Ack="ack"}(n||(n={})),function(e){e.Fulfilled="fulfilled",e.Rejected="rejected"}(i||(i={})),function(e){e.ConnectionDestroyed="ConnectionDestroyed",e.ConnectionTimeout="ConnectionTimeout",e.NotInIframe="NotInIframe",e.NoIframeSrc="NoIframeSrc"}(s||(s={})),function(e){e.DataCloneError="DataCloneError"}(a||(a={})),function(e){e.Message="message"}(c||(c={}));const d=({name:e,message:t,stack:r})=>({name:e,message:t,stack:r});let l=0;var u,m=()=>++l,h=0,v=function(e){return JSON.parse(JSON.stringify(e))};(u=exports.PresentationMode||(exports.PresentationMode={}))[u.none=0]="none",u[u.goToCameraDefault=1]="goToCameraDefault",u[u.goToFirstBookmark=2]="goToFirstBookmark",u[u.jumpToCameraDefault=3]="jumpToCameraDefault",u[u.jumpToFirstBookmark=4]="jumpToFirstBookmark",u[u.tourOnce=5]="tourOnce",u[u.tourOnceAndGoBack=6]="tourOnceAndGoBack",u[u.tourLoop=7]="tourLoop";var f={accessToken:void 0,transparentBackground:!0,presentationMode:exports.PresentationMode.jumpToCameraDefault,showTitle:!1,showLogo:!1,minimap:!1,uiButtons:{birdMode:!1,personMode:!1,fullscreen:!1,bookmarkStrip:!1,share:!1,help:!1,presentation:!1}};exports.default=function(){function l(l,u){var h=this,g=this;void 0===u&&(u={}),this.listeners=new Map,this.handleEvent=function(e,t){var r=g.listeners.get(e);if(r)return r(t);console.warn("Listener not found")},this.options=v(e({},f,u)),this.containerEl=l,this.viewerEl=function(e,t){void 0===e&&(e=document.body);var r=document.createElement("iframe");return Object.assign(r,{src:"https://viewer.archilogic.com/v1_0_3?embedType=api",width:"100%",height:"100%",title:"Archilogic Embed",frameBorder:"0",scrolling:"no",allowTransparency:"true",allowFullscreen:"true",style:"border: 0;"}),e.appendChild(r),r}(l),this.viewerReadyPromise=(e=>{let{iframe:l,methods:u={},childOrigin:h,timeout:v,debug:f=!1}=e;const g=(e=>(...t)=>{e&&console.log("[Penpal]",...t)})(f),p=(()=>{const e=[];let t=!1;return{destroy(r){t=!0,e.forEach(e=>{e(r)})},onDestroy(r){t?r():e.push(r)}}})(),{onDestroy:w,destroy:y}=p;h||((e=>{if(!e.src&&!e.srcdoc){const e=new Error("Iframe must have src or srcdoc property defined.");throw e.code=s.NoIframeSrc,e}})(l),h=(e=>{if(e&&o.find(t=>e.startsWith(t)))return"null";const n=document.location,i=r.exec(e);let s,a,c;return i?(s=i[1]?i[1]:n.protocol,a=i[2],c=i[4]):(s=n.protocol,a=n.hostname,c=n.port),`${s}//${a}${c&&c!==t[s]?":"+c:""}`})(l.src));const k="null"===h?"*":h,E=((e,t,r,o)=>i=>{if(i.origin!==r)return void e(`Parent: Handshake - Received SYN message from origin ${i.origin} which did not match expected origin ${r}`);e("Parent: Handshake - Received SYN, responding with SYN-ACK");const s={penpal:n.SynAck,methodNames:Object.keys(t)};i.source.postMessage(s,o)})(g,u,h,k),P=((e,t,r,o,l)=>{const{destroy:u,onDestroy:h}=o;let v,f;const g={};return o=>{if(o.origin!==t)return void l(`Parent: Handshake - Received ACK message from origin ${o.origin} which did not match expected origin ${t}`);l("Parent: Handshake - Received ACK");const p={localName:"Parent",local:window,remote:o.source,originForSending:r,originForReceiving:t};v&&v(),v=((e,t,r)=>{const{localName:o,local:s,remote:l,originForSending:u,originForReceiving:m}=e;let h=!1;const v=e=>{if(e.source!==l||e.data.penpal!==n.Call)return;if(e.origin!==m)return void r(`${o} received message from origin ${e.origin} which did not match expected origin ${m}`);const s=e.data,{methodName:c,args:v,id:f}=s;r(`${o}: Received ${c}() call`);const g=e=>t=>{if(r(`${o}: Sending ${c}() reply`),h)return void r(`${o}: Unable to send ${c}() reply due to destroyed connection`);const s={penpal:n.Reply,id:f,resolution:e,returnValue:t};e===i.Rejected&&t instanceof Error&&(s.returnValue=d(t),s.returnValueIsError=!0);try{l.postMessage(s,u)}catch(e){if(e.name===a.DataCloneError){const t={penpal:n.Reply,id:f,resolution:i.Rejected,returnValue:d(e),returnValueIsError:!0};l.postMessage(t,u)}throw e}};new Promise(e=>e(t[c].apply(t,v))).then(g(i.Fulfilled),g(i.Rejected))};return s.addEventListener(c.Message,v),()=>{h=!0,s.removeEventListener(c.Message,v)}})(p,e,l),h(v),f&&f.forEach(e=>{delete g[e]}),f=o.data.methodNames;const w=((e,t,r,o,a)=>{const{localName:d,local:l,remote:u,originForSending:h,originForReceiving:v}=t;let f=!1;return a(d+": Connecting call sender"),r.reduce((e,t)=>(e[t]=(e=>(...t)=>{let r;a(`${d}: Sending ${e}() call`);try{u.closed&&(r=!0)}catch(e){r=!0}if(r&&o(),f){const t=new Error(`Unable to send ${e}() call due to destroyed connection`);throw t.code=s.ConnectionDestroyed,t}return new Promise((r,o)=>{const s=m(),f=t=>{if(t.source!==u||t.data.penpal!==n.Reply||t.data.id!==s)return;if(t.origin!==v)return void a(`${d} received message from origin ${t.origin} which did not match expected origin ${v}`);const m=t.data;a(`${d}: Received ${e}() reply`),l.removeEventListener(c.Message,f);let h=m.returnValue;m.returnValueIsError&&(h=(e=>{const t=new Error;return Object.keys(e).forEach(r=>t[r]=e[r]),t})(h)),(m.resolution===i.Fulfilled?r:o)(h)};l.addEventListener(c.Message,f),u.postMessage({penpal:n.Call,id:s,methodName:e,args:t},h)})})(t),e),e),()=>{f=!0}})(g,p,f,u,l);return h(w),g}})(u,h,k,p,g);return{promise:new Promise((e,t)=>{const r=((e,t)=>{let r;return void 0!==e&&(r=window.setTimeout(()=>{const r=new Error(`Connection timed out after ${e}ms`);r.code=s.ConnectionTimeout,t(r)},e)),()=>{clearTimeout(r)}})(v,y),o=t=>{if(t.source===l.contentWindow&&t.data)if(t.data.penpal!==n.Syn)if(t.data.penpal!==n.Ack);else{const o=P(t);o&&(r(),e(o))}else E(t)};window.addEventListener(c.Message,o),g("Parent: Awaiting handshake"),((e,t)=>{const{destroy:r,onDestroy:o}=t,n=setInterval(()=>{document.contains(e)||(clearInterval(n),r())},6e4);o(()=>{clearInterval(n)})})(l,p),w(e=>{window.removeEventListener(c.Message,o),e||((e=new Error("Connection destroyed")).code=s.ConnectionDestroyed),t(e)})}),destroy(){y()}}})({iframe:this.viewerEl,methods:{handleEvent:this.handleEvent}}).promise.then(function(e){try{return Promise.resolve(function(e){var t=e.token,r=e.origin,o=e.viewer;try{if(!t)throw new Error("Error: You need to include a valid access token, to create a new access token visit https://developers.archilogic.com");return Promise.resolve(o.validateAccessToken({token:t,origin:r})).then(function(e){if(!e.isValid)throw new Error("string"==typeof e.message?"Access token: "+(n={reason:e.message,token:t}).token+" is not valid: "+n.reason:"Access token: "+(o={origin:r,token:t}).token+" is not valid for origin "+o.origin);var o,n;return!0})}catch(e){return Promise.reject(e)}}({token:h.options.accessToken,origin:window.location.origin,viewer:e})).then(function(){return h.viewer=e,h.viewer.set(h.options),!0})}catch(e){return Promise.reject(e)}})}var u=l.prototype;return u.loadScene=function(e){try{var t=this;return Promise.resolve(t.viewerReadyPromise).then(function(){return t.viewer.loadScene(e)})}catch(e){return Promise.reject(e)}},u.listBookmarks=function(){try{return Promise.resolve(this.viewer.listBookmarks())}catch(e){return Promise.reject(e)}},u.listSpaces=function(){try{return Promise.resolve(this.viewer.listSpaces())}catch(e){return Promise.reject(e)}},u.startPresentation=function(){try{var e=this;return Promise.resolve(e.viewerReadyPromise).then(function(){return e.viewer.startPresentation()})}catch(e){return Promise.reject(e)}},u.goToBookmark=function(e){var t=e.animate;return this.viewer.goToBookmark({bookmarkId:e.bookmarkId,animate:void 0===t||t})},u.goToBirdMode=function(e){var t=(void 0===e?{}:e).animate;return this.viewer.goToBirdMode({animate:void 0===t||t})},u.goToPersonMode=function(e){var t=void 0===e?{}:e,r=t.findSafeLanding,o=t.animate;return this.viewer.goToPersonMode({findSafeLanding:void 0===r||r,animate:void 0===o||o})},u.zoomExtents=function(e){var t=void 0===e?{}:e,r=t.spaceId,o=void 0===r?void 0:r,n=t.animate,i=void 0===n||n,s=this.viewerEl.getBoundingClientRect();return this.viewer.zoomExtents({spaceId:o,animate:i,aspect:s.width/s.height})},u.toggleFullscreen=function(){return document.fullscreenElement&&document.fullscreenElement===this.containerEl?document.exitFullscreen():this.containerEl.requestFullscreen()},u.set=function(e){this.viewer.set(v(e))},u.on=function(e,t){return h++,this.listeners.set(h,t),this.viewer.addListener(e,h),h},u.off=function(e){return this.viewer.removeListener(e)},l}(),exports.defaultEmbedOptions=f;
function e(){return(e=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e}).apply(this,arguments)}const r={"http:":"80","https:":"443"},t=/^(https?:)?\/\/([^/:]+)?(:(\d+))?/,o=["file:","data:"];var n,i,s,a,c;!function(e){e.Call="call",e.Reply="reply",e.Syn="syn",e.SynAck="synAck",e.Ack="ack"}(n||(n={})),function(e){e.Fulfilled="fulfilled",e.Rejected="rejected"}(i||(i={})),function(e){e.ConnectionDestroyed="ConnectionDestroyed",e.ConnectionTimeout="ConnectionTimeout",e.NotInIframe="NotInIframe",e.NoIframeSrc="NoIframeSrc"}(s||(s={})),function(e){e.DataCloneError="DataCloneError"}(a||(a={})),function(e){e.Message="message"}(c||(c={}));const d=({name:e,message:r,stack:t})=>({name:e,message:r,stack:t});let l=0;var u,m=()=>++l,h=0,v=function(e){return JSON.parse(JSON.stringify(e))};(u=exports.PresentationMode||(exports.PresentationMode={}))[u.none=0]="none",u[u.goToCameraDefault=1]="goToCameraDefault",u[u.goToFirstBookmark=2]="goToFirstBookmark",u[u.jumpToCameraDefault=3]="jumpToCameraDefault",u[u.jumpToFirstBookmark=4]="jumpToFirstBookmark",u[u.tourOnce=5]="tourOnce",u[u.tourOnceAndGoBack=6]="tourOnceAndGoBack",u[u.tourLoop=7]="tourLoop";var f={accessToken:void 0,transparentBackground:!0,presentationMode:exports.PresentationMode.jumpToCameraDefault,showTitle:!1,showLogo:!1,minimap:!1,uiButtons:{birdMode:!1,personMode:!1,fullscreen:!1,bookmarkStrip:!1,share:!1,help:!1,presentation:!1}};exports.default=function(){function l(l,u){var h=this,g=this;void 0===u&&(u={}),this.listeners=new Map,this.handleEvent=function(e,r){var t=g.listeners.get(e);if(t)return t(r);console.warn("Listener not found")},this.options=v(e({},f,u)),this.containerEl=l,this.viewerEl=function(e,r){void 0===e&&(e=document.body);var t=document.createElement("iframe");return Object.assign(t,{src:"https://viewer.archilogic.com/v1_0_4?embedType=api",width:"100%",height:"100%",title:"Archilogic Embed",frameBorder:"0",scrolling:"no",allowTransparency:"true",allowFullscreen:"true",style:"border: 0;"}),e.appendChild(t),t}(l),this.viewerReadyPromise=(e=>{let{iframe:l,methods:u={},childOrigin:h,timeout:v,debug:f=!1}=e;const g=(e=>(...r)=>{e&&console.log("[Penpal]",...r)})(f),p=(()=>{const e=[];let r=!1;return{destroy(t){r=!0,e.forEach(e=>{e(t)})},onDestroy(t){r?t():e.push(t)}}})(),{onDestroy:w,destroy:y}=p;h||((e=>{if(!e.src&&!e.srcdoc){const e=new Error("Iframe must have src or srcdoc property defined.");throw e.code=s.NoIframeSrc,e}})(l),h=(e=>{if(e&&o.find(r=>e.startsWith(r)))return"null";const n=document.location,i=t.exec(e);let s,a,c;return i?(s=i[1]?i[1]:n.protocol,a=i[2],c=i[4]):(s=n.protocol,a=n.hostname,c=n.port),`${s}//${a}${c&&c!==r[s]?":"+c:""}`})(l.src));const k="null"===h?"*":h,E=((e,r,t,o)=>i=>{if(i.origin!==t)return void e(`Parent: Handshake - Received SYN message from origin ${i.origin} which did not match expected origin ${t}`);e("Parent: Handshake - Received SYN, responding with SYN-ACK");const s={penpal:n.SynAck,methodNames:Object.keys(r)};i.source.postMessage(s,o)})(g,u,h,k),P=((e,r,t,o,l)=>{const{destroy:u,onDestroy:h}=o;let v,f;const g={};return o=>{if(o.origin!==r)return void l(`Parent: Handshake - Received ACK message from origin ${o.origin} which did not match expected origin ${r}`);l("Parent: Handshake - Received ACK");const p={localName:"Parent",local:window,remote:o.source,originForSending:t,originForReceiving:r};v&&v(),v=((e,r,t)=>{const{localName:o,local:s,remote:l,originForSending:u,originForReceiving:m}=e;let h=!1;const v=e=>{if(e.source!==l||e.data.penpal!==n.Call)return;if(e.origin!==m)return void t(`${o} received message from origin ${e.origin} which did not match expected origin ${m}`);const s=e.data,{methodName:c,args:v,id:f}=s;t(`${o}: Received ${c}() call`);const g=e=>r=>{if(t(`${o}: Sending ${c}() reply`),h)return void t(`${o}: Unable to send ${c}() reply due to destroyed connection`);const s={penpal:n.Reply,id:f,resolution:e,returnValue:r};e===i.Rejected&&r instanceof Error&&(s.returnValue=d(r),s.returnValueIsError=!0);try{l.postMessage(s,u)}catch(e){if(e.name===a.DataCloneError){const r={penpal:n.Reply,id:f,resolution:i.Rejected,returnValue:d(e),returnValueIsError:!0};l.postMessage(r,u)}throw e}};new Promise(e=>e(r[c].apply(r,v))).then(g(i.Fulfilled),g(i.Rejected))};return s.addEventListener(c.Message,v),()=>{h=!0,s.removeEventListener(c.Message,v)}})(p,e,l),h(v),f&&f.forEach(e=>{delete g[e]}),f=o.data.methodNames;const w=((e,r,t,o,a)=>{const{localName:d,local:l,remote:u,originForSending:h,originForReceiving:v}=r;let f=!1;return a(d+": Connecting call sender"),t.reduce((e,r)=>(e[r]=(e=>(...r)=>{let t;a(`${d}: Sending ${e}() call`);try{u.closed&&(t=!0)}catch(e){t=!0}if(t&&o(),f){const r=new Error(`Unable to send ${e}() call due to destroyed connection`);throw r.code=s.ConnectionDestroyed,r}return new Promise((t,o)=>{const s=m(),f=r=>{if(r.source!==u||r.data.penpal!==n.Reply||r.data.id!==s)return;if(r.origin!==v)return void a(`${d} received message from origin ${r.origin} which did not match expected origin ${v}`);const m=r.data;a(`${d}: Received ${e}() reply`),l.removeEventListener(c.Message,f);let h=m.returnValue;m.returnValueIsError&&(h=(e=>{const r=new Error;return Object.keys(e).forEach(t=>r[t]=e[t]),r})(h)),(m.resolution===i.Fulfilled?t:o)(h)};l.addEventListener(c.Message,f),u.postMessage({penpal:n.Call,id:s,methodName:e,args:r},h)})})(r),e),e),()=>{f=!0}})(g,p,f,u,l);return h(w),g}})(u,h,k,p,g);return{promise:new Promise((e,r)=>{const t=((e,r)=>{let t;return void 0!==e&&(t=window.setTimeout(()=>{const t=new Error(`Connection timed out after ${e}ms`);t.code=s.ConnectionTimeout,r(t)},e)),()=>{clearTimeout(t)}})(v,y),o=r=>{if(r.source===l.contentWindow&&r.data)if(r.data.penpal!==n.Syn)if(r.data.penpal!==n.Ack);else{const o=P(r);o&&(t(),e(o))}else E(r)};window.addEventListener(c.Message,o),g("Parent: Awaiting handshake"),((e,r)=>{const{destroy:t,onDestroy:o}=r,n=setInterval(()=>{document.contains(e)||(clearInterval(n),t())},6e4);o(()=>{clearInterval(n)})})(l,p),w(e=>{window.removeEventListener(c.Message,o),e||((e=new Error("Connection destroyed")).code=s.ConnectionDestroyed),r(e)})}),destroy(){y()}}})({timeout:4e3,iframe:this.viewerEl,methods:{handleEvent:this.handleEvent}}).promise.then(function(e){try{return h.viewerInstance=e,Promise.resolve(function(e){var r=e.token,t=e.origin,o=e.viewer;try{if(!r)throw new Error("Error: You need to include a valid access token, to create a new access token visit https://developers.archilogic.com");return Promise.resolve(o.validateAccessToken({token:r,origin:t})).then(function(e){if(!e.isValid)throw new Error("string"==typeof e.message?"Access token: "+(n={reason:e.message,token:r}).token+" is not valid: "+n.reason:"Access token: "+(o={origin:t,token:r}).token+" is not valid for origin "+o.origin);var o,n;return!0})}catch(e){return Promise.reject(e)}}({token:h.options.accessToken,origin:window.location.origin,viewer:e})).then(function(){return h.viewer.set(h.options),!0})}catch(e){return Promise.reject(e)}}).catch(function(e){return console.error(e),!1})}var u,g=l.prototype;return g.loadScene=function(e){try{var r=this;return Promise.resolve(r.viewerReadyPromise).then(function(){return r.viewer.loadScene(e)})}catch(e){return Promise.reject(e)}},g.listBookmarks=function(){try{return Promise.resolve(this.viewer.listBookmarks())}catch(e){return Promise.reject(e)}},g.listSpaces=function(){try{return Promise.resolve(this.viewer.listSpaces())}catch(e){return Promise.reject(e)}},g.startPresentation=function(){try{var e=this;return Promise.resolve(e.viewerReadyPromise).then(function(){return e.viewer.startPresentation()})}catch(e){return Promise.reject(e)}},g.goToBookmark=function(e){var r=e.animate;return this.viewer.goToBookmark({bookmarkId:e.bookmarkId,animate:void 0===r||r})},g.goToBirdMode=function(e){var r=(void 0===e?{}:e).animate;return this.viewer.goToBirdMode({animate:void 0===r||r})},g.goToPersonMode=function(e){var r=void 0===e?{}:e,t=r.findSafeLanding,o=r.animate;return this.viewer.goToPersonMode({findSafeLanding:void 0===t||t,animate:void 0===o||o})},g.zoomExtents=function(e){var r=void 0===e?{}:e,t=r.spaceId,o=void 0===t?void 0:t,n=r.animate,i=void 0===n||n,s=this.viewerEl.getBoundingClientRect();return this.viewer.zoomExtents({spaceId:o,animate:i,aspect:s.width/s.height})},g.toggleFullscreen=function(){return document.fullscreenElement&&document.fullscreenElement===this.containerEl?document.exitFullscreen():this.containerEl.requestFullscreen()},g.set=function(e){this.viewer.set(v(e))},g.on=function(e,r){return h++,this.listeners.set(h,r),this.viewer.addListener(e,h),h},g.off=function(e){return this.viewer.removeListener(e)},(u=[{key:"viewer",get:function(){if(!this.viewerInstance)throw new Error("Method called before viewer initialization. Wait for viewerReadyPromise to resolve before performing this action");return this.viewerInstance}}])&&function(e,r){for(var t=0;t<r.length;t++){var o=r[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}(l.prototype,u),l}(),exports.defaultEmbedOptions=f;

@@ -1,1 +0,1 @@

const e={"http:":"80","https:":"443"},o=/^(https?:)?\/\/([^/:]+)?(:(\d+))?/,t=["file:","data:"];var n,r,i,s,a;!function(e){e.Call="call",e.Reply="reply",e.Syn="syn",e.SynAck="synAck",e.Ack="ack"}(n||(n={})),function(e){e.Fulfilled="fulfilled",e.Rejected="rejected"}(r||(r={})),function(e){e.ConnectionDestroyed="ConnectionDestroyed",e.ConnectionTimeout="ConnectionTimeout",e.NotInIframe="NotInIframe",e.NoIframeSrc="NoIframeSrc"}(i||(i={})),function(e){e.DataCloneError="DataCloneError"}(s||(s={})),function(e){e.Message="message"}(a||(a={}));const c=({name:e,message:o,stack:t})=>({name:e,message:o,stack:t});let d=0;var l=()=>++d;let u=0;const m=e=>JSON.parse(JSON.stringify(e));var g;!function(e){e[e.none=0]="none",e[e.goToCameraDefault=1]="goToCameraDefault",e[e.goToFirstBookmark=2]="goToFirstBookmark",e[e.jumpToCameraDefault=3]="jumpToCameraDefault",e[e.jumpToFirstBookmark=4]="jumpToFirstBookmark",e[e.tourOnce=5]="tourOnce",e[e.tourOnceAndGoBack=6]="tourOnceAndGoBack",e[e.tourLoop=7]="tourLoop"}(g||(g={}));const h={accessToken:void 0,transparentBackground:!0,presentationMode:g.jumpToCameraDefault,showTitle:!1,showLogo:!1,minimap:!1,uiButtons:{birdMode:!1,personMode:!1,fullscreen:!1,bookmarkStrip:!1,share:!1,help:!1,presentation:!1}};export default class{constructor(d,u={}){var g=this;this.listeners=new Map,this.handleEvent=(e,o)=>{const t=this.listeners.get(e);if(t)return t(o);console.warn("Listener not found")},this.options=m({...h,...u}),this.containerEl=d,this.viewerEl=function(e=document.body,o){const t=document.createElement("iframe");return Object.assign(t,{src:"https://viewer.archilogic.com/v1_0_3?embedType=api",width:"100%",height:"100%",title:"Archilogic Embed",frameBorder:"0",scrolling:"no",allowTransparency:"true",allowFullscreen:"true",style:"border: 0;"}),e.appendChild(t),t}(d),this.viewerReadyPromise=(d=>{let{iframe:u,methods:m={},childOrigin:g,timeout:h,debug:p=!1}=d;const f=(e=>(...o)=>{e&&console.log("[Penpal]",...o)})(p),v=(()=>{const e=[];let o=!1;return{destroy(t){o=!0,e.forEach(e=>{e(t)})},onDestroy(t){o?t():e.push(t)}}})(),{onDestroy:w,destroy:k}=v;g||((e=>{if(!e.src&&!e.srcdoc){const e=new Error("Iframe must have src or srcdoc property defined.");throw e.code=i.NoIframeSrc,e}})(u),g=(n=>{if(n&&t.find(e=>n.startsWith(e)))return"null";const r=document.location,i=o.exec(n);let s,a,c;return i?(s=i[1]?i[1]:r.protocol,a=i[2],c=i[4]):(s=r.protocol,a=r.hostname,c=r.port),`${s}//${a}${c&&c!==e[s]?":"+c:""}`})(u.src));const y="null"===g?"*":g,E=((e,o,t,r)=>i=>{if(i.origin!==t)return void e(`Parent: Handshake - Received SYN message from origin ${i.origin} which did not match expected origin ${t}`);e("Parent: Handshake - Received SYN, responding with SYN-ACK");const s={penpal:n.SynAck,methodNames:Object.keys(o)};i.source.postMessage(s,r)})(f,m,g,y),$=((e,o,t,d,u)=>{const{destroy:m,onDestroy:g}=d;let h,p;const f={};return d=>{if(d.origin!==o)return void u(`Parent: Handshake - Received ACK message from origin ${d.origin} which did not match expected origin ${o}`);u("Parent: Handshake - Received ACK");const v={localName:"Parent",local:window,remote:d.source,originForSending:t,originForReceiving:o};h&&h(),h=((e,o,t)=>{const{localName:i,local:d,remote:l,originForSending:u,originForReceiving:m}=e;let g=!1;const h=e=>{if(e.source!==l||e.data.penpal!==n.Call)return;if(e.origin!==m)return void t(`${i} received message from origin ${e.origin} which did not match expected origin ${m}`);const a=e.data,{methodName:d,args:h,id:p}=a;t(`${i}: Received ${d}() call`);const f=e=>o=>{if(t(`${i}: Sending ${d}() reply`),g)return void t(`${i}: Unable to send ${d}() reply due to destroyed connection`);const a={penpal:n.Reply,id:p,resolution:e,returnValue:o};e===r.Rejected&&o instanceof Error&&(a.returnValue=c(o),a.returnValueIsError=!0);try{l.postMessage(a,u)}catch(e){if(e.name===s.DataCloneError){const o={penpal:n.Reply,id:p,resolution:r.Rejected,returnValue:c(e),returnValueIsError:!0};l.postMessage(o,u)}throw e}};new Promise(e=>e(o[d].apply(o,h))).then(f(r.Fulfilled),f(r.Rejected))};return d.addEventListener(a.Message,h),()=>{g=!0,d.removeEventListener(a.Message,h)}})(v,e,u),g(h),p&&p.forEach(e=>{delete f[e]}),p=d.data.methodNames;const w=((e,o,t,s,c)=>{const{localName:d,local:u,remote:m,originForSending:g,originForReceiving:h}=o;let p=!1;return c(d+": Connecting call sender"),t.reduce((e,o)=>(e[o]=(e=>(...o)=>{let t;c(`${d}: Sending ${e}() call`);try{m.closed&&(t=!0)}catch(e){t=!0}if(t&&s(),p){const o=new Error(`Unable to send ${e}() call due to destroyed connection`);throw o.code=i.ConnectionDestroyed,o}return new Promise((t,i)=>{const s=l(),p=o=>{if(o.source!==m||o.data.penpal!==n.Reply||o.data.id!==s)return;if(o.origin!==h)return void c(`${d} received message from origin ${o.origin} which did not match expected origin ${h}`);const l=o.data;c(`${d}: Received ${e}() reply`),u.removeEventListener(a.Message,p);let g=l.returnValue;l.returnValueIsError&&(g=(e=>{const o=new Error;return Object.keys(e).forEach(t=>o[t]=e[t]),o})(g)),(l.resolution===r.Fulfilled?t:i)(g)};u.addEventListener(a.Message,p),m.postMessage({penpal:n.Call,id:s,methodName:e,args:o},g)})})(o),e),e),()=>{p=!0}})(f,v,p,m,u);return g(w),f}})(m,g,y,v,f);return{promise:new Promise((e,o)=>{const t=((e,o)=>{let t;return void 0!==e&&(t=window.setTimeout(()=>{const t=new Error(`Connection timed out after ${e}ms`);t.code=i.ConnectionTimeout,o(t)},e)),()=>{clearTimeout(t)}})(h,k),r=o=>{if(o.source===u.contentWindow&&o.data)if(o.data.penpal!==n.Syn)if(o.data.penpal!==n.Ack);else{const n=$(o);n&&(t(),e(n))}else E(o)};window.addEventListener(a.Message,r),f("Parent: Awaiting handshake"),((e,o)=>{const{destroy:t,onDestroy:n}=o,r=setInterval(()=>{document.contains(e)||(clearInterval(r),t())},6e4);n(()=>{clearInterval(r)})})(u,v),w(e=>{window.removeEventListener(a.Message,r),e||((e=new Error("Connection destroyed")).code=i.ConnectionDestroyed),o(e)})}),destroy(){k()}}})({iframe:this.viewerEl,methods:{handleEvent:this.handleEvent}}).promise.then(async function(e){return await async function({token:e,origin:o,viewer:t}){if(!e)throw new Error("Error: You need to include a valid access token, to create a new access token visit https://developers.archilogic.com");const n={token:e,origin:o},r=await t.validateAccessToken(n);if(!r.isValid)throw new Error("string"==typeof r.message?(({token:e,reason:o})=>`Access token: ${e} is not valid: ${o}`)({reason:r.message,token:e}):(({token:e,origin:o})=>`Access token: ${e} is not valid for origin ${o}`)({origin:o,token:e}));return!0}({token:g.options.accessToken,origin:window.location.origin,viewer:e}),g.viewer=e,g.viewer.set(g.options),!0})}async loadScene(e){return await this.viewerReadyPromise,this.viewer.loadScene(e)}async listBookmarks(){return this.viewer.listBookmarks()}async listSpaces(){return this.viewer.listSpaces()}async startPresentation(){return await this.viewerReadyPromise,this.viewer.startPresentation()}goToBookmark({bookmarkId:e,animate:o=!0}){return this.viewer.goToBookmark({bookmarkId:e,animate:o})}goToBirdMode({animate:e=!0}={}){return this.viewer.goToBirdMode({animate:e})}goToPersonMode({findSafeLanding:e=!0,animate:o=!0}={}){return this.viewer.goToPersonMode({findSafeLanding:e,animate:o})}zoomExtents({spaceId:e,animate:o=!0}={}){const t=this.viewerEl.getBoundingClientRect();return this.viewer.zoomExtents({spaceId:e,animate:o,aspect:t.width/t.height})}toggleFullscreen(){return document.fullscreenElement&&document.fullscreenElement===this.containerEl?document.exitFullscreen():this.containerEl.requestFullscreen()}set(e){this.viewer.set(m(e))}on(e,o){return u++,this.listeners.set(u,o),this.viewer.addListener(e,u),u}off(e){return this.viewer.removeListener(e)}}export{g as PresentationMode,h as defaultEmbedOptions};
const e={"http:":"80","https:":"443"},t=/^(https?:)?\/\/([^/:]+)?(:(\d+))?/,o=["file:","data:"];var n,r,i,s,a;!function(e){e.Call="call",e.Reply="reply",e.Syn="syn",e.SynAck="synAck",e.Ack="ack"}(n||(n={})),function(e){e.Fulfilled="fulfilled",e.Rejected="rejected"}(r||(r={})),function(e){e.ConnectionDestroyed="ConnectionDestroyed",e.ConnectionTimeout="ConnectionTimeout",e.NotInIframe="NotInIframe",e.NoIframeSrc="NoIframeSrc"}(i||(i={})),function(e){e.DataCloneError="DataCloneError"}(s||(s={})),function(e){e.Message="message"}(a||(a={}));const c=({name:e,message:t,stack:o})=>({name:e,message:t,stack:o});let d=0;var l=()=>++d;let u=0;const m=e=>JSON.parse(JSON.stringify(e));var h;!function(e){e[e.none=0]="none",e[e.goToCameraDefault=1]="goToCameraDefault",e[e.goToFirstBookmark=2]="goToFirstBookmark",e[e.jumpToCameraDefault=3]="jumpToCameraDefault",e[e.jumpToFirstBookmark=4]="jumpToFirstBookmark",e[e.tourOnce=5]="tourOnce",e[e.tourOnceAndGoBack=6]="tourOnceAndGoBack",e[e.tourLoop=7]="tourLoop"}(h||(h={}));const g={accessToken:void 0,transparentBackground:!0,presentationMode:h.jumpToCameraDefault,showTitle:!1,showLogo:!1,minimap:!1,uiButtons:{birdMode:!1,personMode:!1,fullscreen:!1,bookmarkStrip:!1,share:!1,help:!1,presentation:!1}};export default class{constructor(d,u={}){var h=this;this.listeners=new Map,this.handleEvent=(e,t)=>{const o=this.listeners.get(e);if(o)return o(t);console.warn("Listener not found")},this.options=m({...g,...u}),this.containerEl=d,this.viewerEl=function(e=document.body,t){const o=document.createElement("iframe");return Object.assign(o,{src:"https://viewer.archilogic.com/v1_0_4?embedType=api",width:"100%",height:"100%",title:"Archilogic Embed",frameBorder:"0",scrolling:"no",allowTransparency:"true",allowFullscreen:"true",style:"border: 0;"}),e.appendChild(o),o}(d),this.viewerReadyPromise=(d=>{let{iframe:u,methods:m={},childOrigin:h,timeout:g,debug:p=!1}=d;const f=(e=>(...t)=>{e&&console.log("[Penpal]",...t)})(p),v=(()=>{const e=[];let t=!1;return{destroy(o){t=!0,e.forEach(e=>{e(o)})},onDestroy(o){t?o():e.push(o)}}})(),{onDestroy:w,destroy:k}=v;h||((e=>{if(!e.src&&!e.srcdoc){const e=new Error("Iframe must have src or srcdoc property defined.");throw e.code=i.NoIframeSrc,e}})(u),h=(n=>{if(n&&o.find(e=>n.startsWith(e)))return"null";const r=document.location,i=t.exec(n);let s,a,c;return i?(s=i[1]?i[1]:r.protocol,a=i[2],c=i[4]):(s=r.protocol,a=r.hostname,c=r.port),`${s}//${a}${c&&c!==e[s]?":"+c:""}`})(u.src));const y="null"===h?"*":h,E=((e,t,o,r)=>i=>{if(i.origin!==o)return void e(`Parent: Handshake - Received SYN message from origin ${i.origin} which did not match expected origin ${o}`);e("Parent: Handshake - Received SYN, responding with SYN-ACK");const s={penpal:n.SynAck,methodNames:Object.keys(t)};i.source.postMessage(s,r)})(f,m,h,y),$=((e,t,o,d,u)=>{const{destroy:m,onDestroy:h}=d;let g,p;const f={};return d=>{if(d.origin!==t)return void u(`Parent: Handshake - Received ACK message from origin ${d.origin} which did not match expected origin ${t}`);u("Parent: Handshake - Received ACK");const v={localName:"Parent",local:window,remote:d.source,originForSending:o,originForReceiving:t};g&&g(),g=((e,t,o)=>{const{localName:i,local:d,remote:l,originForSending:u,originForReceiving:m}=e;let h=!1;const g=e=>{if(e.source!==l||e.data.penpal!==n.Call)return;if(e.origin!==m)return void o(`${i} received message from origin ${e.origin} which did not match expected origin ${m}`);const a=e.data,{methodName:d,args:g,id:p}=a;o(`${i}: Received ${d}() call`);const f=e=>t=>{if(o(`${i}: Sending ${d}() reply`),h)return void o(`${i}: Unable to send ${d}() reply due to destroyed connection`);const a={penpal:n.Reply,id:p,resolution:e,returnValue:t};e===r.Rejected&&t instanceof Error&&(a.returnValue=c(t),a.returnValueIsError=!0);try{l.postMessage(a,u)}catch(e){if(e.name===s.DataCloneError){const t={penpal:n.Reply,id:p,resolution:r.Rejected,returnValue:c(e),returnValueIsError:!0};l.postMessage(t,u)}throw e}};new Promise(e=>e(t[d].apply(t,g))).then(f(r.Fulfilled),f(r.Rejected))};return d.addEventListener(a.Message,g),()=>{h=!0,d.removeEventListener(a.Message,g)}})(v,e,u),h(g),p&&p.forEach(e=>{delete f[e]}),p=d.data.methodNames;const w=((e,t,o,s,c)=>{const{localName:d,local:u,remote:m,originForSending:h,originForReceiving:g}=t;let p=!1;return c(d+": Connecting call sender"),o.reduce((e,t)=>(e[t]=(e=>(...t)=>{let o;c(`${d}: Sending ${e}() call`);try{m.closed&&(o=!0)}catch(e){o=!0}if(o&&s(),p){const t=new Error(`Unable to send ${e}() call due to destroyed connection`);throw t.code=i.ConnectionDestroyed,t}return new Promise((o,i)=>{const s=l(),p=t=>{if(t.source!==m||t.data.penpal!==n.Reply||t.data.id!==s)return;if(t.origin!==g)return void c(`${d} received message from origin ${t.origin} which did not match expected origin ${g}`);const l=t.data;c(`${d}: Received ${e}() reply`),u.removeEventListener(a.Message,p);let h=l.returnValue;l.returnValueIsError&&(h=(e=>{const t=new Error;return Object.keys(e).forEach(o=>t[o]=e[o]),t})(h)),(l.resolution===r.Fulfilled?o:i)(h)};u.addEventListener(a.Message,p),m.postMessage({penpal:n.Call,id:s,methodName:e,args:t},h)})})(t),e),e),()=>{p=!0}})(f,v,p,m,u);return h(w),f}})(m,h,y,v,f);return{promise:new Promise((e,t)=>{const o=((e,t)=>{let o;return void 0!==e&&(o=window.setTimeout(()=>{const o=new Error(`Connection timed out after ${e}ms`);o.code=i.ConnectionTimeout,t(o)},e)),()=>{clearTimeout(o)}})(g,k),r=t=>{if(t.source===u.contentWindow&&t.data)if(t.data.penpal!==n.Syn)if(t.data.penpal!==n.Ack);else{const n=$(t);n&&(o(),e(n))}else E(t)};window.addEventListener(a.Message,r),f("Parent: Awaiting handshake"),((e,t)=>{const{destroy:o,onDestroy:n}=t,r=setInterval(()=>{document.contains(e)||(clearInterval(r),o())},6e4);n(()=>{clearInterval(r)})})(u,v),w(e=>{window.removeEventListener(a.Message,r),e||((e=new Error("Connection destroyed")).code=i.ConnectionDestroyed),t(e)})}),destroy(){k()}}})({timeout:4e3,iframe:this.viewerEl,methods:{handleEvent:this.handleEvent}}).promise.then(async function(e){return h.viewerInstance=e,await async function({token:e,origin:t,viewer:o}){if(!e)throw new Error("Error: You need to include a valid access token, to create a new access token visit https://developers.archilogic.com");const n={token:e,origin:t},r=await o.validateAccessToken(n);if(!r.isValid)throw new Error("string"==typeof r.message?(({token:e,reason:t})=>`Access token: ${e} is not valid: ${t}`)({reason:r.message,token:e}):(({token:e,origin:t})=>`Access token: ${e} is not valid for origin ${t}`)({origin:t,token:e}));return!0}({token:h.options.accessToken,origin:window.location.origin,viewer:e}),h.viewer.set(h.options),!0}).catch(e=>(console.error(e),!1))}get viewer(){if(!this.viewerInstance)throw new Error("Method called before viewer initialization. Wait for viewerReadyPromise to resolve before performing this action");return this.viewerInstance}async loadScene(e){return await this.viewerReadyPromise,this.viewer.loadScene(e)}async listBookmarks(){return this.viewer.listBookmarks()}async listSpaces(){return this.viewer.listSpaces()}async startPresentation(){return await this.viewerReadyPromise,this.viewer.startPresentation()}goToBookmark({bookmarkId:e,animate:t=!0}){return this.viewer.goToBookmark({bookmarkId:e,animate:t})}goToBirdMode({animate:e=!0}={}){return this.viewer.goToBirdMode({animate:e})}goToPersonMode({findSafeLanding:e=!0,animate:t=!0}={}){return this.viewer.goToPersonMode({findSafeLanding:e,animate:t})}zoomExtents({spaceId:e,animate:t=!0}={}){const o=this.viewerEl.getBoundingClientRect();return this.viewer.zoomExtents({spaceId:e,animate:t,aspect:o.width/o.height})}toggleFullscreen(){return document.fullscreenElement&&document.fullscreenElement===this.containerEl?document.exitFullscreen():this.containerEl.requestFullscreen()}set(e){this.viewer.set(m(e))}on(e,t){return u++,this.listeners.set(u,t),this.viewer.addListener(e,u),u}off(e){return this.viewer.removeListener(e)}}export{h as PresentationMode,g as defaultEmbedOptions};

@@ -1,1 +0,1 @@

function e(){return(e=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e}).apply(this,arguments)}const r={"http:":"80","https:":"443"},t=/^(https?:)?\/\/([^/:]+)?(:(\d+))?/,o=["file:","data:"];var n,i,s,a,c;!function(e){e.Call="call",e.Reply="reply",e.Syn="syn",e.SynAck="synAck",e.Ack="ack"}(n||(n={})),function(e){e.Fulfilled="fulfilled",e.Rejected="rejected"}(i||(i={})),function(e){e.ConnectionDestroyed="ConnectionDestroyed",e.ConnectionTimeout="ConnectionTimeout",e.NotInIframe="NotInIframe",e.NoIframeSrc="NoIframeSrc"}(s||(s={})),function(e){e.DataCloneError="DataCloneError"}(a||(a={})),function(e){e.Message="message"}(c||(c={}));const d=({name:e,message:r,stack:t})=>({name:e,message:r,stack:t});let l=0;var u,m=()=>++l,h=0,v=function(e){return JSON.parse(JSON.stringify(e))};!function(e){e[e.none=0]="none",e[e.goToCameraDefault=1]="goToCameraDefault",e[e.goToFirstBookmark=2]="goToFirstBookmark",e[e.jumpToCameraDefault=3]="jumpToCameraDefault",e[e.jumpToFirstBookmark=4]="jumpToFirstBookmark",e[e.tourOnce=5]="tourOnce",e[e.tourOnceAndGoBack=6]="tourOnceAndGoBack",e[e.tourLoop=7]="tourLoop"}(u||(u={}));var f={accessToken:void 0,transparentBackground:!0,presentationMode:u.jumpToCameraDefault,showTitle:!1,showLogo:!1,minimap:!1,uiButtons:{birdMode:!1,personMode:!1,fullscreen:!1,bookmarkStrip:!1,share:!1,help:!1,presentation:!1}},g=function(){function l(l,u){var h=this,g=this;void 0===u&&(u={}),this.listeners=new Map,this.handleEvent=function(e,r){var t=g.listeners.get(e);if(t)return t(r);console.warn("Listener not found")},this.options=v(e({},f,u)),this.containerEl=l,this.viewerEl=function(e,r){void 0===e&&(e=document.body);var t=document.createElement("iframe");return Object.assign(t,{src:"https://viewer.archilogic.com/v1_0_3?embedType=api",width:"100%",height:"100%",title:"Archilogic Embed",frameBorder:"0",scrolling:"no",allowTransparency:"true",allowFullscreen:"true",style:"border: 0;"}),e.appendChild(t),t}(l),this.viewerReadyPromise=(e=>{let{iframe:l,methods:u={},childOrigin:h,timeout:v,debug:f=!1}=e;const g=(e=>(...r)=>{e&&console.log("[Penpal]",...r)})(f),p=(()=>{const e=[];let r=!1;return{destroy(t){r=!0,e.forEach(e=>{e(t)})},onDestroy(t){r?t():e.push(t)}}})(),{onDestroy:w,destroy:y}=p;h||((e=>{if(!e.src&&!e.srcdoc){const e=new Error("Iframe must have src or srcdoc property defined.");throw e.code=s.NoIframeSrc,e}})(l),h=(e=>{if(e&&o.find(r=>e.startsWith(r)))return"null";const n=document.location,i=t.exec(e);let s,a,c;return i?(s=i[1]?i[1]:n.protocol,a=i[2],c=i[4]):(s=n.protocol,a=n.hostname,c=n.port),`${s}//${a}${c&&c!==r[s]?":"+c:""}`})(l.src));const k="null"===h?"*":h,E=((e,r,t,o)=>i=>{if(i.origin!==t)return void e(`Parent: Handshake - Received SYN message from origin ${i.origin} which did not match expected origin ${t}`);e("Parent: Handshake - Received SYN, responding with SYN-ACK");const s={penpal:n.SynAck,methodNames:Object.keys(r)};i.source.postMessage(s,o)})(g,u,h,k),P=((e,r,t,o,l)=>{const{destroy:u,onDestroy:h}=o;let v,f;const g={};return o=>{if(o.origin!==r)return void l(`Parent: Handshake - Received ACK message from origin ${o.origin} which did not match expected origin ${r}`);l("Parent: Handshake - Received ACK");const p={localName:"Parent",local:window,remote:o.source,originForSending:t,originForReceiving:r};v&&v(),v=((e,r,t)=>{const{localName:o,local:s,remote:l,originForSending:u,originForReceiving:m}=e;let h=!1;const v=e=>{if(e.source!==l||e.data.penpal!==n.Call)return;if(e.origin!==m)return void t(`${o} received message from origin ${e.origin} which did not match expected origin ${m}`);const s=e.data,{methodName:c,args:v,id:f}=s;t(`${o}: Received ${c}() call`);const g=e=>r=>{if(t(`${o}: Sending ${c}() reply`),h)return void t(`${o}: Unable to send ${c}() reply due to destroyed connection`);const s={penpal:n.Reply,id:f,resolution:e,returnValue:r};e===i.Rejected&&r instanceof Error&&(s.returnValue=d(r),s.returnValueIsError=!0);try{l.postMessage(s,u)}catch(e){if(e.name===a.DataCloneError){const r={penpal:n.Reply,id:f,resolution:i.Rejected,returnValue:d(e),returnValueIsError:!0};l.postMessage(r,u)}throw e}};new Promise(e=>e(r[c].apply(r,v))).then(g(i.Fulfilled),g(i.Rejected))};return s.addEventListener(c.Message,v),()=>{h=!0,s.removeEventListener(c.Message,v)}})(p,e,l),h(v),f&&f.forEach(e=>{delete g[e]}),f=o.data.methodNames;const w=((e,r,t,o,a)=>{const{localName:d,local:l,remote:u,originForSending:h,originForReceiving:v}=r;let f=!1;return a(d+": Connecting call sender"),t.reduce((e,r)=>(e[r]=(e=>(...r)=>{let t;a(`${d}: Sending ${e}() call`);try{u.closed&&(t=!0)}catch(e){t=!0}if(t&&o(),f){const r=new Error(`Unable to send ${e}() call due to destroyed connection`);throw r.code=s.ConnectionDestroyed,r}return new Promise((t,o)=>{const s=m(),f=r=>{if(r.source!==u||r.data.penpal!==n.Reply||r.data.id!==s)return;if(r.origin!==v)return void a(`${d} received message from origin ${r.origin} which did not match expected origin ${v}`);const m=r.data;a(`${d}: Received ${e}() reply`),l.removeEventListener(c.Message,f);let h=m.returnValue;m.returnValueIsError&&(h=(e=>{const r=new Error;return Object.keys(e).forEach(t=>r[t]=e[t]),r})(h)),(m.resolution===i.Fulfilled?t:o)(h)};l.addEventListener(c.Message,f),u.postMessage({penpal:n.Call,id:s,methodName:e,args:r},h)})})(r),e),e),()=>{f=!0}})(g,p,f,u,l);return h(w),g}})(u,h,k,p,g);return{promise:new Promise((e,r)=>{const t=((e,r)=>{let t;return void 0!==e&&(t=window.setTimeout(()=>{const t=new Error(`Connection timed out after ${e}ms`);t.code=s.ConnectionTimeout,r(t)},e)),()=>{clearTimeout(t)}})(v,y),o=r=>{if(r.source===l.contentWindow&&r.data)if(r.data.penpal!==n.Syn)if(r.data.penpal!==n.Ack);else{const o=P(r);o&&(t(),e(o))}else E(r)};window.addEventListener(c.Message,o),g("Parent: Awaiting handshake"),((e,r)=>{const{destroy:t,onDestroy:o}=r,n=setInterval(()=>{document.contains(e)||(clearInterval(n),t())},6e4);o(()=>{clearInterval(n)})})(l,p),w(e=>{window.removeEventListener(c.Message,o),e||((e=new Error("Connection destroyed")).code=s.ConnectionDestroyed),r(e)})}),destroy(){y()}}})({iframe:this.viewerEl,methods:{handleEvent:this.handleEvent}}).promise.then(function(e){try{return Promise.resolve(function(e){var r=e.token,t=e.origin,o=e.viewer;try{if(!r)throw new Error("Error: You need to include a valid access token, to create a new access token visit https://developers.archilogic.com");return Promise.resolve(o.validateAccessToken({token:r,origin:t})).then(function(e){if(!e.isValid)throw new Error("string"==typeof e.message?"Access token: "+(n={reason:e.message,token:r}).token+" is not valid: "+n.reason:"Access token: "+(o={origin:t,token:r}).token+" is not valid for origin "+o.origin);var o,n;return!0})}catch(e){return Promise.reject(e)}}({token:h.options.accessToken,origin:window.location.origin,viewer:e})).then(function(){return h.viewer=e,h.viewer.set(h.options),!0})}catch(e){return Promise.reject(e)}})}var u=l.prototype;return u.loadScene=function(e){try{var r=this;return Promise.resolve(r.viewerReadyPromise).then(function(){return r.viewer.loadScene(e)})}catch(e){return Promise.reject(e)}},u.listBookmarks=function(){try{return Promise.resolve(this.viewer.listBookmarks())}catch(e){return Promise.reject(e)}},u.listSpaces=function(){try{return Promise.resolve(this.viewer.listSpaces())}catch(e){return Promise.reject(e)}},u.startPresentation=function(){try{var e=this;return Promise.resolve(e.viewerReadyPromise).then(function(){return e.viewer.startPresentation()})}catch(e){return Promise.reject(e)}},u.goToBookmark=function(e){var r=e.animate;return this.viewer.goToBookmark({bookmarkId:e.bookmarkId,animate:void 0===r||r})},u.goToBirdMode=function(e){var r=(void 0===e?{}:e).animate;return this.viewer.goToBirdMode({animate:void 0===r||r})},u.goToPersonMode=function(e){var r=void 0===e?{}:e,t=r.findSafeLanding,o=r.animate;return this.viewer.goToPersonMode({findSafeLanding:void 0===t||t,animate:void 0===o||o})},u.zoomExtents=function(e){var r=void 0===e?{}:e,t=r.spaceId,o=void 0===t?void 0:t,n=r.animate,i=void 0===n||n,s=this.viewerEl.getBoundingClientRect();return this.viewer.zoomExtents({spaceId:o,animate:i,aspect:s.width/s.height})},u.toggleFullscreen=function(){return document.fullscreenElement&&document.fullscreenElement===this.containerEl?document.exitFullscreen():this.containerEl.requestFullscreen()},u.set=function(e){this.viewer.set(v(e))},u.on=function(e,r){return h++,this.listeners.set(h,r),this.viewer.addListener(e,h),h},u.off=function(e){return this.viewer.removeListener(e)},l}();export default g;export{u as PresentationMode,f as defaultEmbedOptions};
function e(){return(e=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e}).apply(this,arguments)}const r={"http:":"80","https:":"443"},t=/^(https?:)?\/\/([^/:]+)?(:(\d+))?/,o=["file:","data:"];var n,i,s,a,c;!function(e){e.Call="call",e.Reply="reply",e.Syn="syn",e.SynAck="synAck",e.Ack="ack"}(n||(n={})),function(e){e.Fulfilled="fulfilled",e.Rejected="rejected"}(i||(i={})),function(e){e.ConnectionDestroyed="ConnectionDestroyed",e.ConnectionTimeout="ConnectionTimeout",e.NotInIframe="NotInIframe",e.NoIframeSrc="NoIframeSrc"}(s||(s={})),function(e){e.DataCloneError="DataCloneError"}(a||(a={})),function(e){e.Message="message"}(c||(c={}));const l=({name:e,message:r,stack:t})=>({name:e,message:r,stack:t});let d=0;var u,m=()=>++d,h=0,v=function(e){return JSON.parse(JSON.stringify(e))};!function(e){e[e.none=0]="none",e[e.goToCameraDefault=1]="goToCameraDefault",e[e.goToFirstBookmark=2]="goToFirstBookmark",e[e.jumpToCameraDefault=3]="jumpToCameraDefault",e[e.jumpToFirstBookmark=4]="jumpToFirstBookmark",e[e.tourOnce=5]="tourOnce",e[e.tourOnceAndGoBack=6]="tourOnceAndGoBack",e[e.tourLoop=7]="tourLoop"}(u||(u={}));var f={accessToken:void 0,transparentBackground:!0,presentationMode:u.jumpToCameraDefault,showTitle:!1,showLogo:!1,minimap:!1,uiButtons:{birdMode:!1,personMode:!1,fullscreen:!1,bookmarkStrip:!1,share:!1,help:!1,presentation:!1}},g=function(){function d(d,u){var h=this,g=this;void 0===u&&(u={}),this.listeners=new Map,this.handleEvent=function(e,r){var t=g.listeners.get(e);if(t)return t(r);console.warn("Listener not found")},this.options=v(e({},f,u)),this.containerEl=d,this.viewerEl=function(e,r){void 0===e&&(e=document.body);var t=document.createElement("iframe");return Object.assign(t,{src:"https://viewer.archilogic.com/v1_0_4?embedType=api",width:"100%",height:"100%",title:"Archilogic Embed",frameBorder:"0",scrolling:"no",allowTransparency:"true",allowFullscreen:"true",style:"border: 0;"}),e.appendChild(t),t}(d),this.viewerReadyPromise=(e=>{let{iframe:d,methods:u={},childOrigin:h,timeout:v,debug:f=!1}=e;const g=(e=>(...r)=>{e&&console.log("[Penpal]",...r)})(f),p=(()=>{const e=[];let r=!1;return{destroy(t){r=!0,e.forEach(e=>{e(t)})},onDestroy(t){r?t():e.push(t)}}})(),{onDestroy:w,destroy:y}=p;h||((e=>{if(!e.src&&!e.srcdoc){const e=new Error("Iframe must have src or srcdoc property defined.");throw e.code=s.NoIframeSrc,e}})(d),h=(e=>{if(e&&o.find(r=>e.startsWith(r)))return"null";const n=document.location,i=t.exec(e);let s,a,c;return i?(s=i[1]?i[1]:n.protocol,a=i[2],c=i[4]):(s=n.protocol,a=n.hostname,c=n.port),`${s}//${a}${c&&c!==r[s]?":"+c:""}`})(d.src));const k="null"===h?"*":h,E=((e,r,t,o)=>i=>{if(i.origin!==t)return void e(`Parent: Handshake - Received SYN message from origin ${i.origin} which did not match expected origin ${t}`);e("Parent: Handshake - Received SYN, responding with SYN-ACK");const s={penpal:n.SynAck,methodNames:Object.keys(r)};i.source.postMessage(s,o)})(g,u,h,k),P=((e,r,t,o,d)=>{const{destroy:u,onDestroy:h}=o;let v,f;const g={};return o=>{if(o.origin!==r)return void d(`Parent: Handshake - Received ACK message from origin ${o.origin} which did not match expected origin ${r}`);d("Parent: Handshake - Received ACK");const p={localName:"Parent",local:window,remote:o.source,originForSending:t,originForReceiving:r};v&&v(),v=((e,r,t)=>{const{localName:o,local:s,remote:d,originForSending:u,originForReceiving:m}=e;let h=!1;const v=e=>{if(e.source!==d||e.data.penpal!==n.Call)return;if(e.origin!==m)return void t(`${o} received message from origin ${e.origin} which did not match expected origin ${m}`);const s=e.data,{methodName:c,args:v,id:f}=s;t(`${o}: Received ${c}() call`);const g=e=>r=>{if(t(`${o}: Sending ${c}() reply`),h)return void t(`${o}: Unable to send ${c}() reply due to destroyed connection`);const s={penpal:n.Reply,id:f,resolution:e,returnValue:r};e===i.Rejected&&r instanceof Error&&(s.returnValue=l(r),s.returnValueIsError=!0);try{d.postMessage(s,u)}catch(e){if(e.name===a.DataCloneError){const r={penpal:n.Reply,id:f,resolution:i.Rejected,returnValue:l(e),returnValueIsError:!0};d.postMessage(r,u)}throw e}};new Promise(e=>e(r[c].apply(r,v))).then(g(i.Fulfilled),g(i.Rejected))};return s.addEventListener(c.Message,v),()=>{h=!0,s.removeEventListener(c.Message,v)}})(p,e,d),h(v),f&&f.forEach(e=>{delete g[e]}),f=o.data.methodNames;const w=((e,r,t,o,a)=>{const{localName:l,local:d,remote:u,originForSending:h,originForReceiving:v}=r;let f=!1;return a(l+": Connecting call sender"),t.reduce((e,r)=>(e[r]=(e=>(...r)=>{let t;a(`${l}: Sending ${e}() call`);try{u.closed&&(t=!0)}catch(e){t=!0}if(t&&o(),f){const r=new Error(`Unable to send ${e}() call due to destroyed connection`);throw r.code=s.ConnectionDestroyed,r}return new Promise((t,o)=>{const s=m(),f=r=>{if(r.source!==u||r.data.penpal!==n.Reply||r.data.id!==s)return;if(r.origin!==v)return void a(`${l} received message from origin ${r.origin} which did not match expected origin ${v}`);const m=r.data;a(`${l}: Received ${e}() reply`),d.removeEventListener(c.Message,f);let h=m.returnValue;m.returnValueIsError&&(h=(e=>{const r=new Error;return Object.keys(e).forEach(t=>r[t]=e[t]),r})(h)),(m.resolution===i.Fulfilled?t:o)(h)};d.addEventListener(c.Message,f),u.postMessage({penpal:n.Call,id:s,methodName:e,args:r},h)})})(r),e),e),()=>{f=!0}})(g,p,f,u,d);return h(w),g}})(u,h,k,p,g);return{promise:new Promise((e,r)=>{const t=((e,r)=>{let t;return void 0!==e&&(t=window.setTimeout(()=>{const t=new Error(`Connection timed out after ${e}ms`);t.code=s.ConnectionTimeout,r(t)},e)),()=>{clearTimeout(t)}})(v,y),o=r=>{if(r.source===d.contentWindow&&r.data)if(r.data.penpal!==n.Syn)if(r.data.penpal!==n.Ack);else{const o=P(r);o&&(t(),e(o))}else E(r)};window.addEventListener(c.Message,o),g("Parent: Awaiting handshake"),((e,r)=>{const{destroy:t,onDestroy:o}=r,n=setInterval(()=>{document.contains(e)||(clearInterval(n),t())},6e4);o(()=>{clearInterval(n)})})(d,p),w(e=>{window.removeEventListener(c.Message,o),e||((e=new Error("Connection destroyed")).code=s.ConnectionDestroyed),r(e)})}),destroy(){y()}}})({timeout:4e3,iframe:this.viewerEl,methods:{handleEvent:this.handleEvent}}).promise.then(function(e){try{return h.viewerInstance=e,Promise.resolve(function(e){var r=e.token,t=e.origin,o=e.viewer;try{if(!r)throw new Error("Error: You need to include a valid access token, to create a new access token visit https://developers.archilogic.com");return Promise.resolve(o.validateAccessToken({token:r,origin:t})).then(function(e){if(!e.isValid)throw new Error("string"==typeof e.message?"Access token: "+(n={reason:e.message,token:r}).token+" is not valid: "+n.reason:"Access token: "+(o={origin:t,token:r}).token+" is not valid for origin "+o.origin);var o,n;return!0})}catch(e){return Promise.reject(e)}}({token:h.options.accessToken,origin:window.location.origin,viewer:e})).then(function(){return h.viewer.set(h.options),!0})}catch(e){return Promise.reject(e)}}).catch(function(e){return console.error(e),!1})}var u,g=d.prototype;return g.loadScene=function(e){try{var r=this;return Promise.resolve(r.viewerReadyPromise).then(function(){return r.viewer.loadScene(e)})}catch(e){return Promise.reject(e)}},g.listBookmarks=function(){try{return Promise.resolve(this.viewer.listBookmarks())}catch(e){return Promise.reject(e)}},g.listSpaces=function(){try{return Promise.resolve(this.viewer.listSpaces())}catch(e){return Promise.reject(e)}},g.startPresentation=function(){try{var e=this;return Promise.resolve(e.viewerReadyPromise).then(function(){return e.viewer.startPresentation()})}catch(e){return Promise.reject(e)}},g.goToBookmark=function(e){var r=e.animate;return this.viewer.goToBookmark({bookmarkId:e.bookmarkId,animate:void 0===r||r})},g.goToBirdMode=function(e){var r=(void 0===e?{}:e).animate;return this.viewer.goToBirdMode({animate:void 0===r||r})},g.goToPersonMode=function(e){var r=void 0===e?{}:e,t=r.findSafeLanding,o=r.animate;return this.viewer.goToPersonMode({findSafeLanding:void 0===t||t,animate:void 0===o||o})},g.zoomExtents=function(e){var r=void 0===e?{}:e,t=r.spaceId,o=void 0===t?void 0:t,n=r.animate,i=void 0===n||n,s=this.viewerEl.getBoundingClientRect();return this.viewer.zoomExtents({spaceId:o,animate:i,aspect:s.width/s.height})},g.toggleFullscreen=function(){return document.fullscreenElement&&document.fullscreenElement===this.containerEl?document.exitFullscreen():this.containerEl.requestFullscreen()},g.set=function(e){this.viewer.set(v(e))},g.on=function(e,r){return h++,this.listeners.set(h,r),this.viewer.addListener(e,h),h},g.off=function(e){return this.viewer.removeListener(e)},(u=[{key:"viewer",get:function(){if(!this.viewerInstance)throw new Error("Method called before viewer initialization. Wait for viewerReadyPromise to resolve before performing this action");return this.viewerInstance}}])&&function(e,r){for(var t=0;t<r.length;t++){var o=r[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}(d.prototype,u),d}();export default g;export{u as PresentationMode,f as defaultEmbedOptions};

@@ -1,1 +0,1 @@

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).embedApi={})}(this,function(e){function t(){return(t=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var o=arguments[t];for(var n in o)Object.prototype.hasOwnProperty.call(o,n)&&(e[n]=o[n])}return e}).apply(this,arguments)}const o={"http:":"80","https:":"443"},n=/^(https?:)?\/\/([^/:]+)?(:(\d+))?/,r=["file:","data:"];var i,s,a,c,d;!function(e){e.Call="call",e.Reply="reply",e.Syn="syn",e.SynAck="synAck",e.Ack="ack"}(i||(i={})),function(e){e.Fulfilled="fulfilled",e.Rejected="rejected"}(s||(s={})),function(e){e.ConnectionDestroyed="ConnectionDestroyed",e.ConnectionTimeout="ConnectionTimeout",e.NotInIframe="NotInIframe",e.NoIframeSrc="NoIframeSrc"}(a||(a={})),function(e){e.DataCloneError="DataCloneError"}(c||(c={})),function(e){e.Message="message"}(d||(d={}));const l=({name:e,message:t,stack:o})=>({name:e,message:t,stack:o});let u=0;var m,f=()=>++u,h=0,v=function(e){return JSON.parse(JSON.stringify(e))};(m=e.PresentationMode||(e.PresentationMode={}))[m.none=0]="none",m[m.goToCameraDefault=1]="goToCameraDefault",m[m.goToFirstBookmark=2]="goToFirstBookmark",m[m.jumpToCameraDefault=3]="jumpToCameraDefault",m[m.jumpToFirstBookmark=4]="jumpToFirstBookmark",m[m.tourOnce=5]="tourOnce",m[m.tourOnceAndGoBack=6]="tourOnceAndGoBack",m[m.tourLoop=7]="tourLoop";var g={accessToken:void 0,transparentBackground:!0,presentationMode:e.PresentationMode.jumpToCameraDefault,showTitle:!1,showLogo:!1,minimap:!1,uiButtons:{birdMode:!1,personMode:!1,fullscreen:!1,bookmarkStrip:!1,share:!1,help:!1,presentation:!1}};e.default=function(){function e(e,u){var m=this,h=this;void 0===u&&(u={}),this.listeners=new Map,this.handleEvent=function(e,t){var o=h.listeners.get(e);if(o)return o(t);console.warn("Listener not found")},this.options=v(t({},g,u)),this.containerEl=e,this.viewerEl=function(e,t){void 0===e&&(e=document.body);var o=document.createElement("iframe");return Object.assign(o,{src:"https://viewer.archilogic.com/v1_0_3?embedType=api",width:"100%",height:"100%",title:"Archilogic Embed",frameBorder:"0",scrolling:"no",allowTransparency:"true",allowFullscreen:"true",style:"border: 0;"}),e.appendChild(o),o}(e),this.viewerReadyPromise=(e=>{let{iframe:t,methods:u={},childOrigin:m,timeout:h,debug:v=!1}=e;const g=(e=>(...t)=>{e&&console.log("[Penpal]",...t)})(v),p=(()=>{const e=[];let t=!1;return{destroy(o){t=!0,e.forEach(e=>{e(o)})},onDestroy(o){t?o():e.push(o)}}})(),{onDestroy:w,destroy:y}=p;m||((e=>{if(!e.src&&!e.srcdoc){const e=new Error("Iframe must have src or srcdoc property defined.");throw e.code=a.NoIframeSrc,e}})(t),m=(e=>{if(e&&r.find(t=>e.startsWith(t)))return"null";const t=document.location,i=n.exec(e);let s,a,c;return i?(s=i[1]?i[1]:t.protocol,a=i[2],c=i[4]):(s=t.protocol,a=t.hostname,c=t.port),`${s}//${a}${c&&c!==o[s]?":"+c:""}`})(t.src));const k="null"===m?"*":m,E=((e,t,o,n)=>r=>{if(r.origin!==o)return void e(`Parent: Handshake - Received SYN message from origin ${r.origin} which did not match expected origin ${o}`);e("Parent: Handshake - Received SYN, responding with SYN-ACK");const s={penpal:i.SynAck,methodNames:Object.keys(t)};r.source.postMessage(s,n)})(g,u,m,k),P=((e,t,o,n,r)=>{const{destroy:u,onDestroy:m}=n;let h,v;const g={};return n=>{if(n.origin!==t)return void r(`Parent: Handshake - Received ACK message from origin ${n.origin} which did not match expected origin ${t}`);r("Parent: Handshake - Received ACK");const p={localName:"Parent",local:window,remote:n.source,originForSending:o,originForReceiving:t};h&&h(),h=((e,t,o)=>{const{localName:n,local:r,remote:a,originForSending:u,originForReceiving:m}=e;let f=!1;const h=e=>{if(e.source!==a||e.data.penpal!==i.Call)return;if(e.origin!==m)return void o(`${n} received message from origin ${e.origin} which did not match expected origin ${m}`);const r=e.data,{methodName:d,args:h,id:v}=r;o(`${n}: Received ${d}() call`);const g=e=>t=>{if(o(`${n}: Sending ${d}() reply`),f)return void o(`${n}: Unable to send ${d}() reply due to destroyed connection`);const r={penpal:i.Reply,id:v,resolution:e,returnValue:t};e===s.Rejected&&t instanceof Error&&(r.returnValue=l(t),r.returnValueIsError=!0);try{a.postMessage(r,u)}catch(e){if(e.name===c.DataCloneError){const t={penpal:i.Reply,id:v,resolution:s.Rejected,returnValue:l(e),returnValueIsError:!0};a.postMessage(t,u)}throw e}};new Promise(e=>e(t[d].apply(t,h))).then(g(s.Fulfilled),g(s.Rejected))};return r.addEventListener(d.Message,h),()=>{f=!0,r.removeEventListener(d.Message,h)}})(p,e,r),m(h),v&&v.forEach(e=>{delete g[e]}),v=n.data.methodNames;const w=((e,t,o,n,r)=>{const{localName:c,local:l,remote:u,originForSending:m,originForReceiving:h}=t;let v=!1;return r(c+": Connecting call sender"),o.reduce((e,t)=>(e[t]=(e=>(...t)=>{let o;r(`${c}: Sending ${e}() call`);try{u.closed&&(o=!0)}catch(e){o=!0}if(o&&n(),v){const t=new Error(`Unable to send ${e}() call due to destroyed connection`);throw t.code=a.ConnectionDestroyed,t}return new Promise((o,n)=>{const a=f(),v=t=>{if(t.source!==u||t.data.penpal!==i.Reply||t.data.id!==a)return;if(t.origin!==h)return void r(`${c} received message from origin ${t.origin} which did not match expected origin ${h}`);const m=t.data;r(`${c}: Received ${e}() reply`),l.removeEventListener(d.Message,v);let f=m.returnValue;m.returnValueIsError&&(f=(e=>{const t=new Error;return Object.keys(e).forEach(o=>t[o]=e[o]),t})(f)),(m.resolution===s.Fulfilled?o:n)(f)};l.addEventListener(d.Message,v),u.postMessage({penpal:i.Call,id:a,methodName:e,args:t},m)})})(t),e),e),()=>{v=!0}})(g,p,v,u,r);return m(w),g}})(u,m,k,p,g);return{promise:new Promise((e,o)=>{const n=((e,t)=>{let o;return void 0!==e&&(o=window.setTimeout(()=>{const o=new Error(`Connection timed out after ${e}ms`);o.code=a.ConnectionTimeout,t(o)},e)),()=>{clearTimeout(o)}})(h,y),r=o=>{if(o.source===t.contentWindow&&o.data)if(o.data.penpal!==i.Syn)if(o.data.penpal!==i.Ack);else{const t=P(o);t&&(n(),e(t))}else E(o)};window.addEventListener(d.Message,r),g("Parent: Awaiting handshake"),((e,t)=>{const{destroy:o,onDestroy:n}=t,r=setInterval(()=>{document.contains(e)||(clearInterval(r),o())},6e4);n(()=>{clearInterval(r)})})(t,p),w(e=>{window.removeEventListener(d.Message,r),e||((e=new Error("Connection destroyed")).code=a.ConnectionDestroyed),o(e)})}),destroy(){y()}}})({iframe:this.viewerEl,methods:{handleEvent:this.handleEvent}}).promise.then(function(e){try{return Promise.resolve(function(e){var t=e.token,o=e.origin,n=e.viewer;try{if(!t)throw new Error("Error: You need to include a valid access token, to create a new access token visit https://developers.archilogic.com");return Promise.resolve(n.validateAccessToken({token:t,origin:o})).then(function(e){if(!e.isValid)throw new Error("string"==typeof e.message?"Access token: "+(r={reason:e.message,token:t}).token+" is not valid: "+r.reason:"Access token: "+(n={origin:o,token:t}).token+" is not valid for origin "+n.origin);var n,r;return!0})}catch(e){return Promise.reject(e)}}({token:m.options.accessToken,origin:window.location.origin,viewer:e})).then(function(){return m.viewer=e,m.viewer.set(m.options),!0})}catch(e){return Promise.reject(e)}})}var u=e.prototype;return u.loadScene=function(e){try{var t=this;return Promise.resolve(t.viewerReadyPromise).then(function(){return t.viewer.loadScene(e)})}catch(e){return Promise.reject(e)}},u.listBookmarks=function(){try{return Promise.resolve(this.viewer.listBookmarks())}catch(e){return Promise.reject(e)}},u.listSpaces=function(){try{return Promise.resolve(this.viewer.listSpaces())}catch(e){return Promise.reject(e)}},u.startPresentation=function(){try{var e=this;return Promise.resolve(e.viewerReadyPromise).then(function(){return e.viewer.startPresentation()})}catch(e){return Promise.reject(e)}},u.goToBookmark=function(e){var t=e.animate;return this.viewer.goToBookmark({bookmarkId:e.bookmarkId,animate:void 0===t||t})},u.goToBirdMode=function(e){var t=(void 0===e?{}:e).animate;return this.viewer.goToBirdMode({animate:void 0===t||t})},u.goToPersonMode=function(e){var t=void 0===e?{}:e,o=t.findSafeLanding,n=t.animate;return this.viewer.goToPersonMode({findSafeLanding:void 0===o||o,animate:void 0===n||n})},u.zoomExtents=function(e){var t=void 0===e?{}:e,o=t.spaceId,n=void 0===o?void 0:o,r=t.animate,i=void 0===r||r,s=this.viewerEl.getBoundingClientRect();return this.viewer.zoomExtents({spaceId:n,animate:i,aspect:s.width/s.height})},u.toggleFullscreen=function(){return document.fullscreenElement&&document.fullscreenElement===this.containerEl?document.exitFullscreen():this.containerEl.requestFullscreen()},u.set=function(e){this.viewer.set(v(e))},u.on=function(e,t){return h++,this.listeners.set(h,t),this.viewer.addListener(e,h),h},u.off=function(e){return this.viewer.removeListener(e)},e}(),e.defaultEmbedOptions=g});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).embedApi={})}(this,function(e){function t(){return(t=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(e[o]=r[o])}return e}).apply(this,arguments)}const r={"http:":"80","https:":"443"},o=/^(https?:)?\/\/([^/:]+)?(:(\d+))?/,n=["file:","data:"];var i,s,a,c,d;!function(e){e.Call="call",e.Reply="reply",e.Syn="syn",e.SynAck="synAck",e.Ack="ack"}(i||(i={})),function(e){e.Fulfilled="fulfilled",e.Rejected="rejected"}(s||(s={})),function(e){e.ConnectionDestroyed="ConnectionDestroyed",e.ConnectionTimeout="ConnectionTimeout",e.NotInIframe="NotInIframe",e.NoIframeSrc="NoIframeSrc"}(a||(a={})),function(e){e.DataCloneError="DataCloneError"}(c||(c={})),function(e){e.Message="message"}(d||(d={}));const l=({name:e,message:t,stack:r})=>({name:e,message:t,stack:r});let u=0;var m,f=()=>++u,h=0,v=function(e){return JSON.parse(JSON.stringify(e))};(m=e.PresentationMode||(e.PresentationMode={}))[m.none=0]="none",m[m.goToCameraDefault=1]="goToCameraDefault",m[m.goToFirstBookmark=2]="goToFirstBookmark",m[m.jumpToCameraDefault=3]="jumpToCameraDefault",m[m.jumpToFirstBookmark=4]="jumpToFirstBookmark",m[m.tourOnce=5]="tourOnce",m[m.tourOnceAndGoBack=6]="tourOnceAndGoBack",m[m.tourLoop=7]="tourLoop";var g={accessToken:void 0,transparentBackground:!0,presentationMode:e.PresentationMode.jumpToCameraDefault,showTitle:!1,showLogo:!1,minimap:!1,uiButtons:{birdMode:!1,personMode:!1,fullscreen:!1,bookmarkStrip:!1,share:!1,help:!1,presentation:!1}};e.default=function(){function e(e,u){var m=this,h=this;void 0===u&&(u={}),this.listeners=new Map,this.handleEvent=function(e,t){var r=h.listeners.get(e);if(r)return r(t);console.warn("Listener not found")},this.options=v(t({},g,u)),this.containerEl=e,this.viewerEl=function(e,t){void 0===e&&(e=document.body);var r=document.createElement("iframe");return Object.assign(r,{src:"https://viewer.archilogic.com/v1_0_4?embedType=api",width:"100%",height:"100%",title:"Archilogic Embed",frameBorder:"0",scrolling:"no",allowTransparency:"true",allowFullscreen:"true",style:"border: 0;"}),e.appendChild(r),r}(e),this.viewerReadyPromise=(e=>{let{iframe:t,methods:u={},childOrigin:m,timeout:h,debug:v=!1}=e;const g=(e=>(...t)=>{e&&console.log("[Penpal]",...t)})(v),p=(()=>{const e=[];let t=!1;return{destroy(r){t=!0,e.forEach(e=>{e(r)})},onDestroy(r){t?r():e.push(r)}}})(),{onDestroy:w,destroy:y}=p;m||((e=>{if(!e.src&&!e.srcdoc){const e=new Error("Iframe must have src or srcdoc property defined.");throw e.code=a.NoIframeSrc,e}})(t),m=(e=>{if(e&&n.find(t=>e.startsWith(t)))return"null";const t=document.location,i=o.exec(e);let s,a,c;return i?(s=i[1]?i[1]:t.protocol,a=i[2],c=i[4]):(s=t.protocol,a=t.hostname,c=t.port),`${s}//${a}${c&&c!==r[s]?":"+c:""}`})(t.src));const k="null"===m?"*":m,E=((e,t,r,o)=>n=>{if(n.origin!==r)return void e(`Parent: Handshake - Received SYN message from origin ${n.origin} which did not match expected origin ${r}`);e("Parent: Handshake - Received SYN, responding with SYN-ACK");const s={penpal:i.SynAck,methodNames:Object.keys(t)};n.source.postMessage(s,o)})(g,u,m,k),P=((e,t,r,o,n)=>{const{destroy:u,onDestroy:m}=o;let h,v;const g={};return o=>{if(o.origin!==t)return void n(`Parent: Handshake - Received ACK message from origin ${o.origin} which did not match expected origin ${t}`);n("Parent: Handshake - Received ACK");const p={localName:"Parent",local:window,remote:o.source,originForSending:r,originForReceiving:t};h&&h(),h=((e,t,r)=>{const{localName:o,local:n,remote:a,originForSending:u,originForReceiving:m}=e;let f=!1;const h=e=>{if(e.source!==a||e.data.penpal!==i.Call)return;if(e.origin!==m)return void r(`${o} received message from origin ${e.origin} which did not match expected origin ${m}`);const n=e.data,{methodName:d,args:h,id:v}=n;r(`${o}: Received ${d}() call`);const g=e=>t=>{if(r(`${o}: Sending ${d}() reply`),f)return void r(`${o}: Unable to send ${d}() reply due to destroyed connection`);const n={penpal:i.Reply,id:v,resolution:e,returnValue:t};e===s.Rejected&&t instanceof Error&&(n.returnValue=l(t),n.returnValueIsError=!0);try{a.postMessage(n,u)}catch(e){if(e.name===c.DataCloneError){const t={penpal:i.Reply,id:v,resolution:s.Rejected,returnValue:l(e),returnValueIsError:!0};a.postMessage(t,u)}throw e}};new Promise(e=>e(t[d].apply(t,h))).then(g(s.Fulfilled),g(s.Rejected))};return n.addEventListener(d.Message,h),()=>{f=!0,n.removeEventListener(d.Message,h)}})(p,e,n),m(h),v&&v.forEach(e=>{delete g[e]}),v=o.data.methodNames;const w=((e,t,r,o,n)=>{const{localName:c,local:l,remote:u,originForSending:m,originForReceiving:h}=t;let v=!1;return n(c+": Connecting call sender"),r.reduce((e,t)=>(e[t]=(e=>(...t)=>{let r;n(`${c}: Sending ${e}() call`);try{u.closed&&(r=!0)}catch(e){r=!0}if(r&&o(),v){const t=new Error(`Unable to send ${e}() call due to destroyed connection`);throw t.code=a.ConnectionDestroyed,t}return new Promise((r,o)=>{const a=f(),v=t=>{if(t.source!==u||t.data.penpal!==i.Reply||t.data.id!==a)return;if(t.origin!==h)return void n(`${c} received message from origin ${t.origin} which did not match expected origin ${h}`);const m=t.data;n(`${c}: Received ${e}() reply`),l.removeEventListener(d.Message,v);let f=m.returnValue;m.returnValueIsError&&(f=(e=>{const t=new Error;return Object.keys(e).forEach(r=>t[r]=e[r]),t})(f)),(m.resolution===s.Fulfilled?r:o)(f)};l.addEventListener(d.Message,v),u.postMessage({penpal:i.Call,id:a,methodName:e,args:t},m)})})(t),e),e),()=>{v=!0}})(g,p,v,u,n);return m(w),g}})(u,m,k,p,g);return{promise:new Promise((e,r)=>{const o=((e,t)=>{let r;return void 0!==e&&(r=window.setTimeout(()=>{const r=new Error(`Connection timed out after ${e}ms`);r.code=a.ConnectionTimeout,t(r)},e)),()=>{clearTimeout(r)}})(h,y),n=r=>{if(r.source===t.contentWindow&&r.data)if(r.data.penpal!==i.Syn)if(r.data.penpal!==i.Ack);else{const t=P(r);t&&(o(),e(t))}else E(r)};window.addEventListener(d.Message,n),g("Parent: Awaiting handshake"),((e,t)=>{const{destroy:r,onDestroy:o}=t,n=setInterval(()=>{document.contains(e)||(clearInterval(n),r())},6e4);o(()=>{clearInterval(n)})})(t,p),w(e=>{window.removeEventListener(d.Message,n),e||((e=new Error("Connection destroyed")).code=a.ConnectionDestroyed),r(e)})}),destroy(){y()}}})({timeout:4e3,iframe:this.viewerEl,methods:{handleEvent:this.handleEvent}}).promise.then(function(e){try{return m.viewerInstance=e,Promise.resolve(function(e){var t=e.token,r=e.origin,o=e.viewer;try{if(!t)throw new Error("Error: You need to include a valid access token, to create a new access token visit https://developers.archilogic.com");return Promise.resolve(o.validateAccessToken({token:t,origin:r})).then(function(e){if(!e.isValid)throw new Error("string"==typeof e.message?"Access token: "+(n={reason:e.message,token:t}).token+" is not valid: "+n.reason:"Access token: "+(o={origin:r,token:t}).token+" is not valid for origin "+o.origin);var o,n;return!0})}catch(e){return Promise.reject(e)}}({token:m.options.accessToken,origin:window.location.origin,viewer:e})).then(function(){return m.viewer.set(m.options),!0})}catch(e){return Promise.reject(e)}}).catch(function(e){return console.error(e),!1})}var u,m=e.prototype;return m.loadScene=function(e){try{var t=this;return Promise.resolve(t.viewerReadyPromise).then(function(){return t.viewer.loadScene(e)})}catch(e){return Promise.reject(e)}},m.listBookmarks=function(){try{return Promise.resolve(this.viewer.listBookmarks())}catch(e){return Promise.reject(e)}},m.listSpaces=function(){try{return Promise.resolve(this.viewer.listSpaces())}catch(e){return Promise.reject(e)}},m.startPresentation=function(){try{var e=this;return Promise.resolve(e.viewerReadyPromise).then(function(){return e.viewer.startPresentation()})}catch(e){return Promise.reject(e)}},m.goToBookmark=function(e){var t=e.animate;return this.viewer.goToBookmark({bookmarkId:e.bookmarkId,animate:void 0===t||t})},m.goToBirdMode=function(e){var t=(void 0===e?{}:e).animate;return this.viewer.goToBirdMode({animate:void 0===t||t})},m.goToPersonMode=function(e){var t=void 0===e?{}:e,r=t.findSafeLanding,o=t.animate;return this.viewer.goToPersonMode({findSafeLanding:void 0===r||r,animate:void 0===o||o})},m.zoomExtents=function(e){var t=void 0===e?{}:e,r=t.spaceId,o=void 0===r?void 0:r,n=t.animate,i=void 0===n||n,s=this.viewerEl.getBoundingClientRect();return this.viewer.zoomExtents({spaceId:o,animate:i,aspect:s.width/s.height})},m.toggleFullscreen=function(){return document.fullscreenElement&&document.fullscreenElement===this.containerEl?document.exitFullscreen():this.containerEl.requestFullscreen()},m.set=function(e){this.viewer.set(v(e))},m.on=function(e,t){return h++,this.listeners.set(h,t),this.viewer.addListener(e,h),h},m.off=function(e){return this.viewer.removeListener(e)},(u=[{key:"viewer",get:function(){if(!this.viewerInstance)throw new Error("Method called before viewer initialization. Wait for viewerReadyPromise to resolve before performing this action");return this.viewerInstance}}])&&function(e,t){for(var r=0;r<t.length;r++){var o=t[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}(e.prototype,u),e}(),e.defaultEmbedOptions=g});
{
"name": "@archilogic/embed-api",
"version": "1.0.3",
"version": "1.0.4",
"description": "",

@@ -12,3 +12,4 @@ "source": "src/embed.ts",

"build": "microbundle --sourcemap=false",
"dev": "microbundle watch"
"dev": "microbundle watch",
"test": "jest"
},

@@ -18,5 +19,8 @@ "author": "",

"devDependencies": {
"@types/jest": "^26.0.12",
"jest": "^26.4.2",
"microbundle": "^0.12.3",
"penpal": "^5.2.0"
"penpal": "^5.2.0",
"ts-jest": "^26.3.0"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc