Socket
Socket
Sign inDemoInstall

@archilogic/embed-api

Package Overview
Dependencies
0
Maintainers
6
Versions
12
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.2 to 1.0.3

3

dist/embed.d.ts

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

export default class ArchilogicEmbed {
#private;
constructor(el: HTMLElement, options?: EmbedOptionsUpdate);
viewer: CallSender;
private options;
private listeners;
readonly containerEl: HTMLElement;

@@ -40,0 +41,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)}var t=0;function r(e){return"__private_"+t+++"_"+e}function o(e,t){if(!Object.prototype.hasOwnProperty.call(e,t))throw new TypeError("attempted to use private field on non-instance");return e}const n={"http:":"80","https:":"443"},i=/^(https?:)?\/\/([^/:]+)?(:(\d+))?/,s=["file:","data:"];var a,c,d,l,u;!function(e){e.Call="call",e.Reply="reply",e.Syn="syn",e.SynAck="synAck",e.Ack="ack"}(a||(a={})),function(e){e.Fulfilled="fulfilled",e.Rejected="rejected"}(c||(c={})),function(e){e.ConnectionDestroyed="ConnectionDestroyed",e.ConnectionTimeout="ConnectionTimeout",e.NotInIframe="NotInIframe",e.NoIframeSrc="NoIframeSrc"}(d||(d={})),function(e){e.DataCloneError="DataCloneError"}(l||(l={})),function(e){e.Message="message"}(u||(u={}));const m=({name:e,message:t,stack:r})=>({name:e,message:t,stack:r});let v=0;var h,f=0,p=function(e){return JSON.parse(JSON.stringify(e))};(h=exports.PresentationMode||(exports.PresentationMode={}))[h.none=0]="none",h[h.goToCameraDefault=1]="goToCameraDefault",h[h.goToFirstBookmark=2]="goToFirstBookmark",h[h.jumpToCameraDefault=3]="jumpToCameraDefault",h[h.jumpToFirstBookmark=4]="jumpToFirstBookmark",h[h.tourOnce=5]="tourOnce",h[h.tourOnceAndGoBack=6]="tourOnceAndGoBack",h[h.tourLoop=7]="tourLoop";var g={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}},w=r("options"),y=r("listeners");exports.default=function(){function t(t,r){var h=this,f=this;void 0===r&&(r={}),Object.defineProperty(this,w,{writable:!0,value:void 0}),Object.defineProperty(this,y,{writable:!0,value:void 0}),o(this,y)[y]=new Map,this.handleEvent=function(e,t){var r=o(f,y)[y].get(e);if(r)return r(t);console.warn("Listener not found")},o(this,w)[w]=p(e({},g,r)),this.containerEl=t,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_2?embedType=api",width:"100%",height:"100%",title:"Archilogic Embed",frameBorder:"0",scrolling:"no",allowTransparency:"true",allowFullscreen:"true",style:"border: 0;"}),e.appendChild(r),r}(t),this.viewerReadyPromise=(e=>{let{iframe:t,methods:r={},childOrigin:o,timeout:h,debug:f=!1}=e;const p=(e=>(...t)=>{e&&console.log("[Penpal]",...t)})(f),g=(()=>{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}=g;o||((e=>{if(!e.src&&!e.srcdoc){const e=new Error("Iframe must have src or srcdoc property defined.");throw e.code=d.NoIframeSrc,e}})(t),o=(e=>{if(e&&s.find(t=>e.startsWith(t)))return"null";const t=document.location,r=i.exec(e);let o,a,c;return r?(o=r[1]?r[1]:t.protocol,a=r[2],c=r[4]):(o=t.protocol,a=t.hostname,c=t.port),`${o}//${a}${c&&c!==n[o]?":"+c:""}`})(t.src));const k="null"===o?"*":o,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 i={penpal:a.SynAck,methodNames:Object.keys(t)};n.source.postMessage(i,o)})(p,r,o,k),P=((e,t,r,o,n)=>{const{destroy:i,onDestroy:s}=o;let h,f;const p={};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 g={localName:"Parent",local:window,remote:o.source,originForSending:r,originForReceiving:t};h&&h(),h=((e,t,r)=>{const{localName:o,local:n,remote:i,originForSending:s,originForReceiving:d}=e;let v=!1;const h=e=>{if(e.source!==i||e.data.penpal!==a.Call)return;if(e.origin!==d)return void r(`${o} received message from origin ${e.origin} which did not match expected origin ${d}`);const n=e.data,{methodName:u,args:h,id:f}=n;r(`${o}: Received ${u}() call`);const p=e=>t=>{if(r(`${o}: Sending ${u}() reply`),v)return void r(`${o}: Unable to send ${u}() reply due to destroyed connection`);const n={penpal:a.Reply,id:f,resolution:e,returnValue:t};e===c.Rejected&&t instanceof Error&&(n.returnValue=m(t),n.returnValueIsError=!0);try{i.postMessage(n,s)}catch(e){if(e.name===l.DataCloneError){const t={penpal:a.Reply,id:f,resolution:c.Rejected,returnValue:m(e),returnValueIsError:!0};i.postMessage(t,s)}throw e}};new Promise(e=>e(t[u].apply(t,h))).then(p(c.Fulfilled),p(c.Rejected))};return n.addEventListener(u.Message,h),()=>{v=!0,n.removeEventListener(u.Message,h)}})(g,e,n),s(h),f&&f.forEach(e=>{delete p[e]}),f=o.data.methodNames;const w=((e,t,r,o,n)=>{const{localName:i,local:s,remote:l,originForSending:m,originForReceiving:h}=t;let f=!1;return n(i+": Connecting call sender"),r.reduce((e,t)=>(e[t]=(e=>(...t)=>{let r;n(`${i}: Sending ${e}() call`);try{l.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=d.ConnectionDestroyed,t}return new Promise((r,o)=>{const d=++v,f=t=>{if(t.source!==l||t.data.penpal!==a.Reply||t.data.id!==d)return;if(t.origin!==h)return void n(`${i} received message from origin ${t.origin} which did not match expected origin ${h}`);const m=t.data;n(`${i}: Received ${e}() reply`),s.removeEventListener(u.Message,f);let v=m.returnValue;m.returnValueIsError&&(v=(e=>{const t=new Error;return Object.keys(e).forEach(r=>t[r]=e[r]),t})(v)),(m.resolution===c.Fulfilled?r:o)(v)};s.addEventListener(u.Message,f),l.postMessage({penpal:a.Call,id:d,methodName:e,args:t},m)})})(t),e),e),()=>{f=!0}})(p,g,f,i,n);return s(w),p}})(r,o,k,g,p);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=d.ConnectionTimeout,t(r)},e)),()=>{clearTimeout(r)}})(h,y),n=r=>{if(r.source===t.contentWindow&&r.data)if(r.data.penpal!==a.Syn)if(r.data.penpal!==a.Ack);else{const t=P(r);t&&(o(),e(t))}else E(r)};window.addEventListener(u.Message,n),p("Parent: Awaiting handshake"),((e,t)=>{const{destroy:r,onDestroy:o}=t,n=setInterval(()=>{document.contains(e)||(clearInterval(n),r())},6e4);o(()=>{clearInterval(n)})})(t,g),w(e=>{window.removeEventListener(u.Message,n),e||((e=new Error("Connection destroyed")).code=d.ConnectionDestroyed),r(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(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:o(h,w)[w].accessToken,origin:window.location.origin,viewer:e})).then(function(){return h.viewer=e,h.viewer.set(o(h,w)[w]),!0})}catch(e){return Promise.reject(e)}})}var r=t.prototype;return r.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)}},r.listBookmarks=function(){try{return Promise.resolve(this.viewer.listBookmarks())}catch(e){return Promise.reject(e)}},r.listSpaces=function(){try{return Promise.resolve(this.viewer.listSpaces())}catch(e){return Promise.reject(e)}},r.startPresentation=function(){try{var e=this;return Promise.resolve(e.viewerReadyPromise).then(function(){return e.viewer.startPresentation()})}catch(e){return Promise.reject(e)}},r.goToBookmark=function(e){var t=e.animate;return this.viewer.goToBookmark({bookmarkId:e.bookmarkId,animate:void 0===t||t})},r.goToBirdMode=function(e){var t=(void 0===e?{}:e).animate;return this.viewer.goToBirdMode({animate:void 0===t||t})},r.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})},r.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})},r.toggleFullscreen=function(){return document.fullscreenElement&&document.fullscreenElement===this.containerEl?document.exitFullscreen():this.containerEl.requestFullscreen()},r.set=function(e){this.viewer.set(p(e))},r.on=function(e,t){return f++,o(this,y)[y].set(f,t),this.viewer.addListener(e,f),f},r.off=function(e){return this.viewer.removeListener(e)},t}(),exports.defaultEmbedOptions=g;
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;

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

var e=0;function t(t){return"__private_"+e+++"_"+t}function o(e,t){if(!Object.prototype.hasOwnProperty.call(e,t))throw new TypeError("attempted to use private field on non-instance");return e}const n={"http:":"80","https:":"443"},r=/^(https?:)?\/\/([^/:]+)?(:(\d+))?/,i=["file:","data:"];var a,s,c,d,l;!function(e){e.Call="call",e.Reply="reply",e.Syn="syn",e.SynAck="synAck",e.Ack="ack"}(a||(a={})),function(e){e.Fulfilled="fulfilled",e.Rejected="rejected"}(s||(s={})),function(e){e.ConnectionDestroyed="ConnectionDestroyed",e.ConnectionTimeout="ConnectionTimeout",e.NotInIframe="NotInIframe",e.NoIframeSrc="NoIframeSrc"}(c||(c={})),function(e){e.DataCloneError="DataCloneError"}(d||(d={})),function(e){e.Message="message"}(l||(l={}));const u=({name:e,message:t,stack:o})=>({name:e,message:t,stack:o});let m=0,h=0;const g=e=>JSON.parse(JSON.stringify(e));var p;!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"}(p||(p={}));const f={accessToken:void 0,transparentBackground:!0,presentationMode:p.jumpToCameraDefault,showTitle:!1,showLogo:!1,minimap:!1,uiButtons:{birdMode:!1,personMode:!1,fullscreen:!1,bookmarkStrip:!1,share:!1,help:!1,presentation:!1}};var v=t("options"),w=t("listeners");export default class{constructor(e,t={}){var h=this;Object.defineProperty(this,v,{writable:!0,value:void 0}),Object.defineProperty(this,w,{writable:!0,value:void 0}),o(this,w)[w]=new Map,this.handleEvent=(e,t)=>{const n=o(this,w)[w].get(e);if(n)return n(t);console.warn("Listener not found")},o(this,v)[v]=g({...f,...t}),this.containerEl=e,this.viewerEl=function(e=document.body,t){const o=document.createElement("iframe");return Object.assign(o,{src:"https://viewer.archilogic.com/v1_0_2?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:o={},childOrigin:h,timeout:g,debug:p=!1}=e;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:y}=v;h||((e=>{if(!e.src&&!e.srcdoc){const e=new Error("Iframe must have src or srcdoc property defined.");throw e.code=c.NoIframeSrc,e}})(t),h=(e=>{if(e&&i.find(t=>e.startsWith(t)))return"null";const t=document.location,o=r.exec(e);let a,s,c;return o?(a=o[1]?o[1]:t.protocol,s=o[2],c=o[4]):(a=t.protocol,s=t.hostname,c=t.port),`${a}//${s}${c&&c!==n[a]?":"+c:""}`})(t.src));const k="null"===h?"*":h,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 i={penpal:a.SynAck,methodNames:Object.keys(t)};r.source.postMessage(i,n)})(f,o,h,k),$=((e,t,o,n,r)=>{const{destroy:i,onDestroy:h}=n;let g,p;const f={};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 v={localName:"Parent",local:window,remote:n.source,originForSending:o,originForReceiving:t};g&&g(),g=((e,t,o)=>{const{localName:n,local:r,remote:i,originForSending:c,originForReceiving:m}=e;let h=!1;const g=e=>{if(e.source!==i||e.data.penpal!==a.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:l,args:g,id:p}=r;o(`${n}: Received ${l}() call`);const f=e=>t=>{if(o(`${n}: Sending ${l}() reply`),h)return void o(`${n}: Unable to send ${l}() reply due to destroyed connection`);const r={penpal:a.Reply,id:p,resolution:e,returnValue:t};e===s.Rejected&&t instanceof Error&&(r.returnValue=u(t),r.returnValueIsError=!0);try{i.postMessage(r,c)}catch(e){if(e.name===d.DataCloneError){const t={penpal:a.Reply,id:p,resolution:s.Rejected,returnValue:u(e),returnValueIsError:!0};i.postMessage(t,c)}throw e}};new Promise(e=>e(t[l].apply(t,g))).then(f(s.Fulfilled),f(s.Rejected))};return r.addEventListener(l.Message,g),()=>{h=!0,r.removeEventListener(l.Message,g)}})(v,e,r),h(g),p&&p.forEach(e=>{delete f[e]}),p=n.data.methodNames;const w=((e,t,o,n,r)=>{const{localName:i,local:d,remote:u,originForSending:h,originForReceiving:g}=t;let p=!1;return r(i+": Connecting call sender"),o.reduce((e,t)=>(e[t]=(e=>(...t)=>{let o;r(`${i}: Sending ${e}() call`);try{u.closed&&(o=!0)}catch(e){o=!0}if(o&&n(),p){const t=new Error(`Unable to send ${e}() call due to destroyed connection`);throw t.code=c.ConnectionDestroyed,t}return new Promise((o,n)=>{const c=++m,p=t=>{if(t.source!==u||t.data.penpal!==a.Reply||t.data.id!==c)return;if(t.origin!==g)return void r(`${i} received message from origin ${t.origin} which did not match expected origin ${g}`);const m=t.data;r(`${i}: Received ${e}() reply`),d.removeEventListener(l.Message,p);let h=m.returnValue;m.returnValueIsError&&(h=(e=>{const t=new Error;return Object.keys(e).forEach(o=>t[o]=e[o]),t})(h)),(m.resolution===s.Fulfilled?o:n)(h)};d.addEventListener(l.Message,p),u.postMessage({penpal:a.Call,id:c,methodName:e,args:t},h)})})(t),e),e),()=>{p=!0}})(f,v,p,i,r);return h(w),f}})(o,h,k,v,f);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=c.ConnectionTimeout,t(o)},e)),()=>{clearTimeout(o)}})(g,y),r=o=>{if(o.source===t.contentWindow&&o.data)if(o.data.penpal!==a.Syn)if(o.data.penpal!==a.Ack);else{const t=$(o);t&&(n(),e(t))}else E(o)};window.addEventListener(l.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)})})(t,v),w(e=>{window.removeEventListener(l.Message,r),e||((e=new Error("Connection destroyed")).code=c.ConnectionDestroyed),o(e)})}),destroy(){y()}}})({iframe:this.viewerEl,methods:{handleEvent:this.handleEvent}}).promise.then(async function(e){return 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(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:o(h,v)[v].accessToken,origin:window.location.origin,viewer:e}),h.viewer=e,h.viewer.set(o(h,v)[v]),!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: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(g(e))}on(e,t){return h++,o(this,w)[w].set(h,t),this.viewer.addListener(e,h),h}off(e){return this.viewer.removeListener(e)}}export{p as PresentationMode,f as defaultEmbedOptions};
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};

@@ -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)}var r=0;function t(e){return"__private_"+r+++"_"+e}function o(e,r){if(!Object.prototype.hasOwnProperty.call(e,r))throw new TypeError("attempted to use private field on non-instance");return e}const n={"http:":"80","https:":"443"},i=/^(https?:)?\/\/([^/:]+)?(:(\d+))?/,a=["file:","data:"];var s,c,d,l,u;!function(e){e.Call="call",e.Reply="reply",e.Syn="syn",e.SynAck="synAck",e.Ack="ack"}(s||(s={})),function(e){e.Fulfilled="fulfilled",e.Rejected="rejected"}(c||(c={})),function(e){e.ConnectionDestroyed="ConnectionDestroyed",e.ConnectionTimeout="ConnectionTimeout",e.NotInIframe="NotInIframe",e.NoIframeSrc="NoIframeSrc"}(d||(d={})),function(e){e.DataCloneError="DataCloneError"}(l||(l={})),function(e){e.Message="message"}(u||(u={}));const m=({name:e,message:r,stack:t})=>({name:e,message:r,stack:t});let v=0;var h,f=0,p=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"}(h||(h={}));var 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}},w=t("options"),y=t("listeners"),k=function(){function r(r,t){var h=this,f=this;void 0===t&&(t={}),Object.defineProperty(this,w,{writable:!0,value:void 0}),Object.defineProperty(this,y,{writable:!0,value:void 0}),o(this,y)[y]=new Map,this.handleEvent=function(e,r){var t=o(f,y)[y].get(e);if(t)return t(r);console.warn("Listener not found")},o(this,w)[w]=p(e({},g,t)),this.containerEl=r,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_2?embedType=api",width:"100%",height:"100%",title:"Archilogic Embed",frameBorder:"0",scrolling:"no",allowTransparency:"true",allowFullscreen:"true",style:"border: 0;"}),e.appendChild(t),t}(r),this.viewerReadyPromise=(e=>{let{iframe:r,methods:t={},childOrigin:o,timeout:h,debug:f=!1}=e;const p=(e=>(...r)=>{e&&console.log("[Penpal]",...r)})(f),g=(()=>{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}=g;o||((e=>{if(!e.src&&!e.srcdoc){const e=new Error("Iframe must have src or srcdoc property defined.");throw e.code=d.NoIframeSrc,e}})(r),o=(e=>{if(e&&a.find(r=>e.startsWith(r)))return"null";const r=document.location,t=i.exec(e);let o,s,c;return t?(o=t[1]?t[1]:r.protocol,s=t[2],c=t[4]):(o=r.protocol,s=r.hostname,c=r.port),`${o}//${s}${c&&c!==n[o]?":"+c:""}`})(r.src));const k="null"===o?"*":o,E=((e,r,t,o)=>n=>{if(n.origin!==t)return void e(`Parent: Handshake - Received SYN message from origin ${n.origin} which did not match expected origin ${t}`);e("Parent: Handshake - Received SYN, responding with SYN-ACK");const i={penpal:s.SynAck,methodNames:Object.keys(r)};n.source.postMessage(i,o)})(p,t,o,k),P=((e,r,t,o,n)=>{const{destroy:i,onDestroy:a}=o;let h,f;const p={};return o=>{if(o.origin!==r)return void n(`Parent: Handshake - Received ACK message from origin ${o.origin} which did not match expected origin ${r}`);n("Parent: Handshake - Received ACK");const g={localName:"Parent",local:window,remote:o.source,originForSending:t,originForReceiving:r};h&&h(),h=((e,r,t)=>{const{localName:o,local:n,remote:i,originForSending:a,originForReceiving:d}=e;let v=!1;const h=e=>{if(e.source!==i||e.data.penpal!==s.Call)return;if(e.origin!==d)return void t(`${o} received message from origin ${e.origin} which did not match expected origin ${d}`);const n=e.data,{methodName:u,args:h,id:f}=n;t(`${o}: Received ${u}() call`);const p=e=>r=>{if(t(`${o}: Sending ${u}() reply`),v)return void t(`${o}: Unable to send ${u}() reply due to destroyed connection`);const n={penpal:s.Reply,id:f,resolution:e,returnValue:r};e===c.Rejected&&r instanceof Error&&(n.returnValue=m(r),n.returnValueIsError=!0);try{i.postMessage(n,a)}catch(e){if(e.name===l.DataCloneError){const r={penpal:s.Reply,id:f,resolution:c.Rejected,returnValue:m(e),returnValueIsError:!0};i.postMessage(r,a)}throw e}};new Promise(e=>e(r[u].apply(r,h))).then(p(c.Fulfilled),p(c.Rejected))};return n.addEventListener(u.Message,h),()=>{v=!0,n.removeEventListener(u.Message,h)}})(g,e,n),a(h),f&&f.forEach(e=>{delete p[e]}),f=o.data.methodNames;const w=((e,r,t,o,n)=>{const{localName:i,local:a,remote:l,originForSending:m,originForReceiving:h}=r;let f=!1;return n(i+": Connecting call sender"),t.reduce((e,r)=>(e[r]=(e=>(...r)=>{let t;n(`${i}: Sending ${e}() call`);try{l.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=d.ConnectionDestroyed,r}return new Promise((t,o)=>{const d=++v,f=r=>{if(r.source!==l||r.data.penpal!==s.Reply||r.data.id!==d)return;if(r.origin!==h)return void n(`${i} received message from origin ${r.origin} which did not match expected origin ${h}`);const m=r.data;n(`${i}: Received ${e}() reply`),a.removeEventListener(u.Message,f);let v=m.returnValue;m.returnValueIsError&&(v=(e=>{const r=new Error;return Object.keys(e).forEach(t=>r[t]=e[t]),r})(v)),(m.resolution===c.Fulfilled?t:o)(v)};a.addEventListener(u.Message,f),l.postMessage({penpal:s.Call,id:d,methodName:e,args:r},m)})})(r),e),e),()=>{f=!0}})(p,g,f,i,n);return a(w),p}})(t,o,k,g,p);return{promise:new Promise((e,t)=>{const o=((e,r)=>{let t;return void 0!==e&&(t=window.setTimeout(()=>{const t=new Error(`Connection timed out after ${e}ms`);t.code=d.ConnectionTimeout,r(t)},e)),()=>{clearTimeout(t)}})(h,y),n=t=>{if(t.source===r.contentWindow&&t.data)if(t.data.penpal!==s.Syn)if(t.data.penpal!==s.Ack);else{const r=P(t);r&&(o(),e(r))}else E(t)};window.addEventListener(u.Message,n),p("Parent: Awaiting handshake"),((e,r)=>{const{destroy:t,onDestroy:o}=r,n=setInterval(()=>{document.contains(e)||(clearInterval(n),t())},6e4);o(()=>{clearInterval(n)})})(r,g),w(e=>{window.removeEventListener(u.Message,n),e||((e=new Error("Connection destroyed")).code=d.ConnectionDestroyed),t(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(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:o(h,w)[w].accessToken,origin:window.location.origin,viewer:e})).then(function(){return h.viewer=e,h.viewer.set(o(h,w)[w]),!0})}catch(e){return Promise.reject(e)}})}var t=r.prototype;return t.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)}},t.listBookmarks=function(){try{return Promise.resolve(this.viewer.listBookmarks())}catch(e){return Promise.reject(e)}},t.listSpaces=function(){try{return Promise.resolve(this.viewer.listSpaces())}catch(e){return Promise.reject(e)}},t.startPresentation=function(){try{var e=this;return Promise.resolve(e.viewerReadyPromise).then(function(){return e.viewer.startPresentation()})}catch(e){return Promise.reject(e)}},t.goToBookmark=function(e){var r=e.animate;return this.viewer.goToBookmark({bookmarkId:e.bookmarkId,animate:void 0===r||r})},t.goToBirdMode=function(e){var r=(void 0===e?{}:e).animate;return this.viewer.goToBirdMode({animate:void 0===r||r})},t.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})},t.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,a=this.viewerEl.getBoundingClientRect();return this.viewer.zoomExtents({spaceId:o,animate:i,aspect:a.width/a.height})},t.toggleFullscreen=function(){return document.fullscreenElement&&document.fullscreenElement===this.containerEl?document.exitFullscreen():this.containerEl.requestFullscreen()},t.set=function(e){this.viewer.set(p(e))},t.on=function(e,r){return f++,o(this,y)[y].set(f,r),this.viewer.addListener(e,f),f},t.off=function(e){return this.viewer.removeListener(e)},r}();export default k;export{h as PresentationMode,g 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 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};

@@ -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 r=arguments[t];for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(e[o]=r[o])}return e}).apply(this,arguments)}var r=0;function o(e){return"__private_"+r+++"_"+e}function n(e,t){if(!Object.prototype.hasOwnProperty.call(e,t))throw new TypeError("attempted to use private field on non-instance");return e}const i={"http:":"80","https:":"443"},a=/^(https?:)?\/\/([^/:]+)?(:(\d+))?/,s=["file:","data:"];var c,d,l,u,m;!function(e){e.Call="call",e.Reply="reply",e.Syn="syn",e.SynAck="synAck",e.Ack="ack"}(c||(c={})),function(e){e.Fulfilled="fulfilled",e.Rejected="rejected"}(d||(d={})),function(e){e.ConnectionDestroyed="ConnectionDestroyed",e.ConnectionTimeout="ConnectionTimeout",e.NotInIframe="NotInIframe",e.NoIframeSrc="NoIframeSrc"}(l||(l={})),function(e){e.DataCloneError="DataCloneError"}(u||(u={})),function(e){e.Message="message"}(m||(m={}));const f=({name:e,message:t,stack:r})=>({name:e,message:t,stack:r});let h=0;var v,p=0,g=function(e){return JSON.parse(JSON.stringify(e))};(v=e.PresentationMode||(e.PresentationMode={}))[v.none=0]="none",v[v.goToCameraDefault=1]="goToCameraDefault",v[v.goToFirstBookmark=2]="goToFirstBookmark",v[v.jumpToCameraDefault=3]="jumpToCameraDefault",v[v.jumpToFirstBookmark=4]="jumpToFirstBookmark",v[v.tourOnce=5]="tourOnce",v[v.tourOnceAndGoBack=6]="tourOnceAndGoBack",v[v.tourLoop=7]="tourLoop";var w={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}},y=o("options"),k=o("listeners");e.default=function(){function e(e,r){var o=this,v=this;void 0===r&&(r={}),Object.defineProperty(this,y,{writable:!0,value:void 0}),Object.defineProperty(this,k,{writable:!0,value:void 0}),n(this,k)[k]=new Map,this.handleEvent=function(e,t){var r=n(v,k)[k].get(e);if(r)return r(t);console.warn("Listener not found")},n(this,y)[y]=g(t({},w,r)),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_2?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:r={},childOrigin:o,timeout:n,debug:v=!1}=e;const p=(e=>(...t)=>{e&&console.log("[Penpal]",...t)})(v),g=(()=>{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}=g;o||((e=>{if(!e.src&&!e.srcdoc){const e=new Error("Iframe must have src or srcdoc property defined.");throw e.code=l.NoIframeSrc,e}})(t),o=(e=>{if(e&&s.find(t=>e.startsWith(t)))return"null";const t=document.location,r=a.exec(e);let o,n,c;return r?(o=r[1]?r[1]:t.protocol,n=r[2],c=r[4]):(o=t.protocol,n=t.hostname,c=t.port),`${o}//${n}${c&&c!==i[o]?":"+c:""}`})(t.src));const k="null"===o?"*":o,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 i={penpal:c.SynAck,methodNames:Object.keys(t)};n.source.postMessage(i,o)})(p,r,o,k),P=((e,t,r,o,n)=>{const{destroy:i,onDestroy:a}=o;let s,v;const p={};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 g={localName:"Parent",local:window,remote:o.source,originForSending:r,originForReceiving:t};s&&s(),s=((e,t,r)=>{const{localName:o,local:n,remote:i,originForSending:a,originForReceiving:s}=e;let l=!1;const h=e=>{if(e.source!==i||e.data.penpal!==c.Call)return;if(e.origin!==s)return void r(`${o} received message from origin ${e.origin} which did not match expected origin ${s}`);const n=e.data,{methodName:m,args:h,id:v}=n;r(`${o}: Received ${m}() call`);const p=e=>t=>{if(r(`${o}: Sending ${m}() reply`),l)return void r(`${o}: Unable to send ${m}() reply due to destroyed connection`);const n={penpal:c.Reply,id:v,resolution:e,returnValue:t};e===d.Rejected&&t instanceof Error&&(n.returnValue=f(t),n.returnValueIsError=!0);try{i.postMessage(n,a)}catch(e){if(e.name===u.DataCloneError){const t={penpal:c.Reply,id:v,resolution:d.Rejected,returnValue:f(e),returnValueIsError:!0};i.postMessage(t,a)}throw e}};new Promise(e=>e(t[m].apply(t,h))).then(p(d.Fulfilled),p(d.Rejected))};return n.addEventListener(m.Message,h),()=>{l=!0,n.removeEventListener(m.Message,h)}})(g,e,n),a(s),v&&v.forEach(e=>{delete p[e]}),v=o.data.methodNames;const w=((e,t,r,o,n)=>{const{localName:i,local:a,remote:s,originForSending:u,originForReceiving:f}=t;let v=!1;return n(i+": Connecting call sender"),r.reduce((e,t)=>(e[t]=(e=>(...t)=>{let r;n(`${i}: Sending ${e}() call`);try{s.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=l.ConnectionDestroyed,t}return new Promise((r,o)=>{const l=++h,v=t=>{if(t.source!==s||t.data.penpal!==c.Reply||t.data.id!==l)return;if(t.origin!==f)return void n(`${i} received message from origin ${t.origin} which did not match expected origin ${f}`);const u=t.data;n(`${i}: Received ${e}() reply`),a.removeEventListener(m.Message,v);let h=u.returnValue;u.returnValueIsError&&(h=(e=>{const t=new Error;return Object.keys(e).forEach(r=>t[r]=e[r]),t})(h)),(u.resolution===d.Fulfilled?r:o)(h)};a.addEventListener(m.Message,v),s.postMessage({penpal:c.Call,id:l,methodName:e,args:t},u)})})(t),e),e),()=>{v=!0}})(p,g,v,i,n);return a(w),p}})(r,o,k,g,p);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=l.ConnectionTimeout,t(r)},e)),()=>{clearTimeout(r)}})(n,y),i=r=>{if(r.source===t.contentWindow&&r.data)if(r.data.penpal!==c.Syn)if(r.data.penpal!==c.Ack);else{const t=P(r);t&&(o(),e(t))}else E(r)};window.addEventListener(m.Message,i),p("Parent: Awaiting handshake"),((e,t)=>{const{destroy:r,onDestroy:o}=t,n=setInterval(()=>{document.contains(e)||(clearInterval(n),r())},6e4);o(()=>{clearInterval(n)})})(t,g),w(e=>{window.removeEventListener(m.Message,i),e||((e=new Error("Connection destroyed")).code=l.ConnectionDestroyed),r(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(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:n(o,y)[y].accessToken,origin:window.location.origin,viewer:e})).then(function(){return o.viewer=e,o.viewer.set(n(o,y)[y]),!0})}catch(e){return Promise.reject(e)}})}var r=e.prototype;return r.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)}},r.listBookmarks=function(){try{return Promise.resolve(this.viewer.listBookmarks())}catch(e){return Promise.reject(e)}},r.listSpaces=function(){try{return Promise.resolve(this.viewer.listSpaces())}catch(e){return Promise.reject(e)}},r.startPresentation=function(){try{var e=this;return Promise.resolve(e.viewerReadyPromise).then(function(){return e.viewer.startPresentation()})}catch(e){return Promise.reject(e)}},r.goToBookmark=function(e){var t=e.animate;return this.viewer.goToBookmark({bookmarkId:e.bookmarkId,animate:void 0===t||t})},r.goToBirdMode=function(e){var t=(void 0===e?{}:e).animate;return this.viewer.goToBirdMode({animate:void 0===t||t})},r.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})},r.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,a=this.viewerEl.getBoundingClientRect();return this.viewer.zoomExtents({spaceId:o,animate:i,aspect:a.width/a.height})},r.toggleFullscreen=function(){return document.fullscreenElement&&document.fullscreenElement===this.containerEl?document.exitFullscreen():this.containerEl.requestFullscreen()},r.set=function(e){this.viewer.set(g(e))},r.on=function(e,t){return p++,n(this,k)[k].set(p,t),this.viewer.addListener(e,p),p},r.off=function(e){return this.viewer.removeListener(e)},e}(),e.defaultEmbedOptions=w});
!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});
{
"name": "@archilogic/embed-api",
"version": "1.0.2",
"version": "1.0.3",
"description": "",

@@ -5,0 +5,0 @@ "source": "src/embed.ts",

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc