@corti/embedded-web 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/README.md +70 -47
  2. package/dist/CortiEmbedded.d.ts +5 -4
  3. package/dist/CortiEmbedded.js +186 -103
  4. package/dist/CortiEmbedded.js.map +1 -1
  5. package/dist/bundle.js +1615 -20
  6. package/dist/corti-embedded.d.ts +17 -1
  7. package/dist/corti-embedded.js +4 -3
  8. package/dist/corti-embedded.js.map +1 -1
  9. package/dist/index.d.ts +5 -5
  10. package/dist/index.js +4 -4
  11. package/dist/index.js.map +1 -1
  12. package/dist/react/CortiEmbeddedReact.d.ts +30 -23
  13. package/dist/react/CortiEmbeddedReact.js +67 -21
  14. package/dist/react/CortiEmbeddedReact.js.map +1 -1
  15. package/dist/react/index.d.ts +2 -2
  16. package/dist/react/index.js +1 -1
  17. package/dist/react/index.js.map +1 -1
  18. package/dist/styles/base.js +1 -1
  19. package/dist/styles/base.js.map +1 -1
  20. package/dist/styles/container-styles.js +2 -2
  21. package/dist/styles/container-styles.js.map +1 -1
  22. package/dist/styles/theme.js +2 -2
  23. package/dist/styles/theme.js.map +1 -1
  24. package/dist/types/api.d.ts +3 -14
  25. package/dist/types/api.js.map +1 -1
  26. package/dist/types/payloads.d.ts +1 -4
  27. package/dist/types/payloads.js.map +1 -1
  28. package/dist/types/protocol.d.ts +0 -1
  29. package/dist/types/protocol.js.map +1 -1
  30. package/dist/utils/PostMessageHandler.d.ts +19 -70
  31. package/dist/utils/PostMessageHandler.js +98 -202
  32. package/dist/utils/PostMessageHandler.js.map +1 -1
  33. package/dist/utils/baseUrl.js +8 -8
  34. package/dist/utils/baseUrl.js.map +1 -1
  35. package/dist/utils/embedUrl.js +3 -3
  36. package/dist/utils/embedUrl.js.map +1 -1
  37. package/dist/utils/errorFormatter.js +44 -20
  38. package/dist/utils/errorFormatter.js.map +1 -1
  39. package/dist/web-bundle.js +1473 -13
  40. package/dist/web-index.d.ts +3 -3
  41. package/dist/web-index.js +3 -3
  42. package/dist/web-index.js.map +1 -1
  43. package/package.json +18 -10
  44. package/dist/tsconfig.tsbuildinfo +0 -1
@@ -1,10 +1,591 @@
1
- var D=globalThis,I=D.ShadowRoot&&(D.ShadyCSS===void 0||D.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,V=Symbol(),dt=new WeakMap,R=class{constructor(t,e,s){if(this._$cssResult$=!0,s!==V)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e}get styleSheet(){let t=this.o,e=this.t;if(I&&t===void 0){let s=e!==void 0&&e.length===1;s&&(t=dt.get(e)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),s&&dt.set(e,t))}return t}toString(){return this.cssText}},ct=r=>new R(typeof r=="string"?r:r+"",void 0,V),x=(r,...t)=>{let e=r.length===1?r[0]:t.reduce(((s,i,o)=>s+(n=>{if(n._$cssResult$===!0)return n.cssText;if(typeof n=="number")return n;throw Error("Value passed to 'css' function must be a 'css' function result: "+n+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(i)+r[o+1]),r[0]);return new R(e,r,V)},ht=(r,t)=>{if(I)r.adoptedStyleSheets=t.map((e=>e instanceof CSSStyleSheet?e:e.styleSheet));else for(let e of t){let s=document.createElement("style"),i=D.litNonce;i!==void 0&&s.setAttribute("nonce",i),s.textContent=e.cssText,r.appendChild(s)}},J=I?r=>r:r=>r instanceof CSSStyleSheet?(t=>{let e="";for(let s of t.cssRules)e+=s.cssText;return ct(e)})(r):r;var{is:Ct,defineProperty:Ut,getOwnPropertyDescriptor:Ot,getOwnPropertyNames:Ht,getOwnPropertySymbols:Lt,getPrototypeOf:Pt}=Object,N=globalThis,lt=N.trustedTypes,Tt=lt?lt.emptyScript:"",Dt=N.reactiveElementPolyfillSupport,M=(r,t)=>r,C={toAttribute(r,t){switch(t){case Boolean:r=r?Tt:null;break;case Object:case Array:r=r==null?r:JSON.stringify(r)}return r},fromAttribute(r,t){let e=r;switch(t){case Boolean:e=r!==null;break;case Number:e=r===null?null:Number(r);break;case Object:case Array:try{e=JSON.parse(r)}catch{e=null}}return e}},q=(r,t)=>!Ct(r,t),pt={attribute:!0,type:String,converter:C,reflect:!1,useDefault:!1,hasChanged:q};Symbol.metadata??=Symbol("metadata"),N.litPropertyMetadata??=new WeakMap;var m=class extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??=[]).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,e=pt){if(e.state&&(e.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(t)&&((e=Object.create(e)).wrapped=!0),this.elementProperties.set(t,e),!e.noAccessor){let s=Symbol(),i=this.getPropertyDescriptor(t,s,e);i!==void 0&&Ut(this.prototype,t,i)}}static getPropertyDescriptor(t,e,s){let{get:i,set:o}=Ot(this.prototype,t)??{get(){return this[e]},set(n){this[e]=n}};return{get:i,set(n){let d=i?.call(this);o?.call(this,n),this.requestUpdate(t,d,s)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??pt}static _$Ei(){if(this.hasOwnProperty(M("elementProperties")))return;let t=Pt(this);t.finalize(),t.l!==void 0&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(M("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(M("properties"))){let e=this.properties,s=[...Ht(e),...Lt(e)];for(let i of s)this.createProperty(i,e[i])}let t=this[Symbol.metadata];if(t!==null){let e=litPropertyMetadata.get(t);if(e!==void 0)for(let[s,i]of e)this.elementProperties.set(s,i)}this._$Eh=new Map;for(let[e,s]of this.elementProperties){let i=this._$Eu(e,s);i!==void 0&&this._$Eh.set(i,e)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){let e=[];if(Array.isArray(t)){let s=new Set(t.flat(1/0).reverse());for(let i of s)e.unshift(J(i))}else t!==void 0&&e.push(J(t));return e}static _$Eu(t,e){let s=e.attribute;return s===!1?void 0:typeof s=="string"?s:typeof t=="string"?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise((t=>this.enableUpdating=t)),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach((t=>t(this)))}addController(t){(this._$EO??=new Set).add(t),this.renderRoot!==void 0&&this.isConnected&&t.hostConnected?.()}removeController(t){this._$EO?.delete(t)}_$E_(){let t=new Map,e=this.constructor.elementProperties;for(let s of e.keys())this.hasOwnProperty(s)&&(t.set(s,this[s]),delete this[s]);t.size>0&&(this._$Ep=t)}createRenderRoot(){let t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return ht(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach((t=>t.hostConnected?.()))}enableUpdating(t){}disconnectedCallback(){this._$EO?.forEach((t=>t.hostDisconnected?.()))}attributeChangedCallback(t,e,s){this._$AK(t,s)}_$ET(t,e){let s=this.constructor.elementProperties.get(t),i=this.constructor._$Eu(t,s);if(i!==void 0&&s.reflect===!0){let o=(s.converter?.toAttribute!==void 0?s.converter:C).toAttribute(e,s.type);this._$Em=t,o==null?this.removeAttribute(i):this.setAttribute(i,o),this._$Em=null}}_$AK(t,e){let s=this.constructor,i=s._$Eh.get(t);if(i!==void 0&&this._$Em!==i){let o=s.getPropertyOptions(i),n=typeof o.converter=="function"?{fromAttribute:o.converter}:o.converter?.fromAttribute!==void 0?o.converter:C;this._$Em=i;let d=n.fromAttribute(e,o.type);this[i]=d??this._$Ej?.get(i)??d,this._$Em=null}}requestUpdate(t,e,s){if(t!==void 0){let i=this.constructor,o=this[t];if(s??=i.getPropertyOptions(t),!((s.hasChanged??q)(o,e)||s.useDefault&&s.reflect&&o===this._$Ej?.get(t)&&!this.hasAttribute(i._$Eu(t,s))))return;this.C(t,e,s)}this.isUpdatePending===!1&&(this._$ES=this._$EP())}C(t,e,{useDefault:s,reflect:i,wrapped:o},n){s&&!(this._$Ej??=new Map).has(t)&&(this._$Ej.set(t,n??e??this[t]),o!==!0||n!==void 0)||(this._$AL.has(t)||(this.hasUpdated||s||(e=void 0),this._$AL.set(t,e)),i===!0&&this._$Em!==t&&(this._$Eq??=new Set).add(t))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(e){Promise.reject(e)}let t=this.scheduleUpdate();return t!=null&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(let[i,o]of this._$Ep)this[i]=o;this._$Ep=void 0}let s=this.constructor.elementProperties;if(s.size>0)for(let[i,o]of s){let{wrapped:n}=o,d=this[i];n!==!0||this._$AL.has(i)||d===void 0||this.C(i,void 0,o,d)}}let t=!1,e=this._$AL;try{t=this.shouldUpdate(e),t?(this.willUpdate(e),this._$EO?.forEach((s=>s.hostUpdate?.())),this.update(e)):this._$EM()}catch(s){throw t=!1,this._$EM(),s}t&&this._$AE(e)}willUpdate(t){}_$AE(t){this._$EO?.forEach((e=>e.hostUpdated?.())),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return!0}update(t){this._$Eq&&=this._$Eq.forEach((e=>this._$ET(e,this[e]))),this._$EM()}updated(t){}firstUpdated(t){}};m.elementStyles=[],m.shadowRootOptions={mode:"open"},m[M("elementProperties")]=new Map,m[M("finalized")]=new Map,Dt?.({ReactiveElement:m}),(N.reactiveElementVersions??=[]).push("2.1.1");var tt=globalThis,k=tt.trustedTypes,ut=k?k.createPolicy("lit-html",{createHTML:r=>r}):void 0,$t="$lit$",y=`lit$${Math.random().toFixed(9).slice(2)}$`,_t="?"+y,It=`<${_t}>`,w=document,O=()=>w.createComment(""),H=r=>r===null||typeof r!="object"&&typeof r!="function",et=Array.isArray,Nt=r=>et(r)||typeof r?.[Symbol.iterator]=="function",K=`[
2
- \f\r]`,U=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,ft=/-->/g,mt=/>/g,_=RegExp(`>|${K}(?:([^\\s"'>=/]+)(${K}*=${K}*(?:[^
3
- \f\r"'\`<>=]|("|')|))|$)`,"g"),gt=/'/g,yt=/"/g,vt=/^(?:script|style|textarea|title)$/i,st=r=>(t,...e)=>({_$litType$:r,strings:t,values:e}),rt=st(1),Zt=st(2),Gt=st(3),b=Symbol.for("lit-noChange"),p=Symbol.for("lit-nothing"),Et=new WeakMap,v=w.createTreeWalker(w,129);function wt(r,t){if(!et(r)||!r.hasOwnProperty("raw"))throw Error("invalid template strings array");return ut!==void 0?ut.createHTML(t):t}var qt=(r,t)=>{let e=r.length-1,s=[],i,o=t===2?"<svg>":t===3?"<math>":"",n=U;for(let d=0;d<e;d++){let a=r[d],h,l,c=-1,f=0;for(;f<a.length&&(n.lastIndex=f,l=n.exec(a),l!==null);)f=n.lastIndex,n===U?l[1]==="!--"?n=ft:l[1]!==void 0?n=mt:l[2]!==void 0?(vt.test(l[2])&&(i=RegExp("</"+l[2],"g")),n=_):l[3]!==void 0&&(n=_):n===_?l[0]===">"?(n=i??U,c=-1):l[1]===void 0?c=-2:(c=n.lastIndex-l[2].length,h=l[1],n=l[3]===void 0?_:l[3]==='"'?yt:gt):n===yt||n===gt?n=_:n===ft||n===mt?n=U:(n=_,i=void 0);let g=n===_&&r[d+1].startsWith("/>")?" ":"";o+=n===U?a+It:c>=0?(s.push(h),a.slice(0,c)+$t+a.slice(c)+y+g):a+y+(c===-2?d:g)}return[wt(r,o+(r[e]||"<?>")+(t===2?"</svg>":t===3?"</math>":"")),s]},L=class r{constructor({strings:t,_$litType$:e},s){let i;this.parts=[];let o=0,n=0,d=t.length-1,a=this.parts,[h,l]=qt(t,e);if(this.el=r.createElement(h,s),v.currentNode=this.el.content,e===2||e===3){let c=this.el.content.firstChild;c.replaceWith(...c.childNodes)}for(;(i=v.nextNode())!==null&&a.length<d;){if(i.nodeType===1){if(i.hasAttributes())for(let c of i.getAttributeNames())if(c.endsWith($t)){let f=l[n++],g=i.getAttribute(c).split(y),T=/([.?@])?(.*)/.exec(f);a.push({type:1,index:o,name:T[2],strings:g,ctor:T[1]==="."?G:T[1]==="?"?Q:T[1]==="@"?X:S}),i.removeAttribute(c)}else c.startsWith(y)&&(a.push({type:6,index:o}),i.removeAttribute(c));if(vt.test(i.tagName)){let c=i.textContent.split(y),f=c.length-1;if(f>0){i.textContent=k?k.emptyScript:"";for(let g=0;g<f;g++)i.append(c[g],O()),v.nextNode(),a.push({type:2,index:++o});i.append(c[f],O())}}}else if(i.nodeType===8)if(i.data===_t)a.push({type:2,index:o});else{let c=-1;for(;(c=i.data.indexOf(y,c+1))!==-1;)a.push({type:7,index:o}),c+=y.length-1}o++}}static createElement(t,e){let s=w.createElement("template");return s.innerHTML=t,s}};function A(r,t,e=r,s){if(t===b)return t;let i=s!==void 0?e._$Co?.[s]:e._$Cl,o=H(t)?void 0:t._$litDirective$;return i?.constructor!==o&&(i?._$AO?.(!1),o===void 0?i=void 0:(i=new o(r),i._$AT(r,e,s)),s!==void 0?(e._$Co??=[])[s]=i:e._$Cl=i),i!==void 0&&(t=A(r,i._$AS(r,t.values),i,s)),t}var Z=class{constructor(t,e){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){let{el:{content:e},parts:s}=this._$AD,i=(t?.creationScope??w).importNode(e,!0);v.currentNode=i;let o=v.nextNode(),n=0,d=0,a=s[0];for(;a!==void 0;){if(n===a.index){let h;a.type===2?h=new P(o,o.nextSibling,this,t):a.type===1?h=new a.ctor(o,a.name,a.strings,this,t):a.type===6&&(h=new Y(o,this,t)),this._$AV.push(h),a=s[++d]}n!==a?.index&&(o=v.nextNode(),n++)}return v.currentNode=w,i}p(t){let e=0;for(let s of this._$AV)s!==void 0&&(s.strings!==void 0?(s._$AI(t,s,e),e+=s.strings.length-2):s._$AI(t[e])),e++}},P=class r{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(t,e,s,i){this.type=2,this._$AH=p,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=s,this.options=i,this._$Cv=i?.isConnected??!0}get parentNode(){let t=this._$AA.parentNode,e=this._$AM;return e!==void 0&&t?.nodeType===11&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=A(this,t,e),H(t)?t===p||t==null||t===""?(this._$AH!==p&&this._$AR(),this._$AH=p):t!==this._$AH&&t!==b&&this._(t):t._$litType$!==void 0?this.$(t):t.nodeType!==void 0?this.T(t):Nt(t)?this.k(t):this._(t)}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}_(t){this._$AH!==p&&H(this._$AH)?this._$AA.nextSibling.data=t:this.T(w.createTextNode(t)),this._$AH=t}$(t){let{values:e,_$litType$:s}=t,i=typeof s=="number"?this._$AC(t):(s.el===void 0&&(s.el=L.createElement(wt(s.h,s.h[0]),this.options)),s);if(this._$AH?._$AD===i)this._$AH.p(e);else{let o=new Z(i,this),n=o.u(this.options);o.p(e),this.T(n),this._$AH=o}}_$AC(t){let e=Et.get(t.strings);return e===void 0&&Et.set(t.strings,e=new L(t)),e}k(t){et(this._$AH)||(this._$AH=[],this._$AR());let e=this._$AH,s,i=0;for(let o of t)i===e.length?e.push(s=new r(this.O(O()),this.O(O()),this,this.options)):s=e[i],s._$AI(o),i++;i<e.length&&(this._$AR(s&&s._$AB.nextSibling,i),e.length=i)}_$AR(t=this._$AA.nextSibling,e){for(this._$AP?.(!1,!0,e);t!==this._$AB;){let s=t.nextSibling;t.remove(),t=s}}setConnected(t){this._$AM===void 0&&(this._$Cv=t,this._$AP?.(t))}},S=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,s,i,o){this.type=1,this._$AH=p,this._$AN=void 0,this.element=t,this.name=e,this._$AM=i,this.options=o,s.length>2||s[0]!==""||s[1]!==""?(this._$AH=Array(s.length-1).fill(new String),this.strings=s):this._$AH=p}_$AI(t,e=this,s,i){let o=this.strings,n=!1;if(o===void 0)t=A(this,t,e,0),n=!H(t)||t!==this._$AH&&t!==b,n&&(this._$AH=t);else{let d=t,a,h;for(t=o[0],a=0;a<o.length-1;a++)h=A(this,d[s+a],e,a),h===b&&(h=this._$AH[a]),n||=!H(h)||h!==this._$AH[a],h===p?t=p:t!==p&&(t+=(h??"")+o[a+1]),this._$AH[a]=h}n&&!i&&this.j(t)}j(t){t===p?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}},G=class extends S{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===p?void 0:t}},Q=class extends S{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==p)}},X=class extends S{constructor(t,e,s,i,o){super(t,e,s,i,o),this.type=5}_$AI(t,e=this){if((t=A(this,t,e,0)??p)===b)return;let s=this._$AH,i=t===p&&s!==p||t.capture!==s.capture||t.once!==s.once||t.passive!==s.passive,o=t!==p&&(s===p||i);i&&this.element.removeEventListener(this.name,this,s),o&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){typeof this._$AH=="function"?this._$AH.call(this.options?.host??this.element,t):this._$AH.handleEvent(t)}},Y=class{constructor(t,e,s){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=s}get _$AU(){return this._$AM._$AU}_$AI(t){A(this,t)}};var kt=tt.litHtmlPolyfillSupport;kt?.(L,P),(tt.litHtmlVersions??=[]).push("3.3.1");var bt=(r,t,e)=>{let s=e?.renderBefore??t,i=s._$litPart$;if(i===void 0){let o=e?.renderBefore??null;s._$litPart$=i=new P(t.insertBefore(O(),o),o,void 0,e??{})}return i._$AI(r),i};var it=globalThis,E=class extends m{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){let t=super.createRenderRoot();return this.renderOptions.renderBefore??=t.firstChild,t}update(t){let e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=bt(e,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return b}};E._$litElement$=!0,E.finalized=!0,it.litElementHydrateSupport?.({LitElement:E});var Bt=it.litElementPolyfillSupport;Bt?.({LitElement:E});(it.litElementVersions??=[]).push("4.2.1");var zt={attribute:!0,type:String,converter:C,reflect:!1,hasChanged:q},jt=(r=zt,t,e)=>{let{kind:s,metadata:i}=e,o=globalThis.litPropertyMetadata.get(i);if(o===void 0&&globalThis.litPropertyMetadata.set(i,o=new Map),s==="setter"&&((r=Object.create(r)).wrapped=!0),o.set(e.name,r),s==="accessor"){let{name:n}=e;return{set(d){let a=t.get.call(this);t.set.call(this,d),this.requestUpdate(n,a,r)},init(d){return d!==void 0&&this.C(n,void 0,r,d),d}}}if(s==="setter"){let{name:n}=e;return function(d){let a=this[n];t.call(this,d),this.requestUpdate(n,a,r)}}throw Error("Unsupported decorator location: "+s)};function B(r){return(t,e)=>typeof e=="object"?jt(r,t,e):((s,i,o)=>{let n=i.hasOwnProperty(o);return i.constructor.createProperty(o,s),n?Object.getOwnPropertyDescriptor(i,o):void 0})(r,t,e)}var At=x`
1
+ // node_modules/@lit/reactive-element/css-tag.js
2
+ var t = globalThis;
3
+ var e = t.ShadowRoot && (void 0 === t.ShadyCSS || t.ShadyCSS.nativeShadow) && "adoptedStyleSheets" in Document.prototype && "replace" in CSSStyleSheet.prototype;
4
+ var s = Symbol();
5
+ var o = /* @__PURE__ */ new WeakMap();
6
+ var n = class {
7
+ constructor(t3, e5, o6) {
8
+ if (this._$cssResult$ = true, o6 !== s) throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");
9
+ this.cssText = t3, this.t = e5;
10
+ }
11
+ get styleSheet() {
12
+ let t3 = this.o;
13
+ const s4 = this.t;
14
+ if (e && void 0 === t3) {
15
+ const e5 = void 0 !== s4 && 1 === s4.length;
16
+ e5 && (t3 = o.get(s4)), void 0 === t3 && ((this.o = t3 = new CSSStyleSheet()).replaceSync(this.cssText), e5 && o.set(s4, t3));
17
+ }
18
+ return t3;
19
+ }
20
+ toString() {
21
+ return this.cssText;
22
+ }
23
+ };
24
+ var r = (t3) => new n("string" == typeof t3 ? t3 : t3 + "", void 0, s);
25
+ var i = (t3, ...e5) => {
26
+ const o6 = 1 === t3.length ? t3[0] : e5.reduce(((e6, s4, o7) => e6 + ((t4) => {
27
+ if (true === t4._$cssResult$) return t4.cssText;
28
+ if ("number" == typeof t4) return t4;
29
+ throw Error("Value passed to 'css' function must be a 'css' function result: " + t4 + ". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.");
30
+ })(s4) + t3[o7 + 1]), t3[0]);
31
+ return new n(o6, t3, s);
32
+ };
33
+ var S = (s4, o6) => {
34
+ if (e) s4.adoptedStyleSheets = o6.map(((t3) => t3 instanceof CSSStyleSheet ? t3 : t3.styleSheet));
35
+ else for (const e5 of o6) {
36
+ const o7 = document.createElement("style"), n5 = t.litNonce;
37
+ void 0 !== n5 && o7.setAttribute("nonce", n5), o7.textContent = e5.cssText, s4.appendChild(o7);
38
+ }
39
+ };
40
+ var c = e ? (t3) => t3 : (t3) => t3 instanceof CSSStyleSheet ? ((t4) => {
41
+ let e5 = "";
42
+ for (const s4 of t4.cssRules) e5 += s4.cssText;
43
+ return r(e5);
44
+ })(t3) : t3;
45
+
46
+ // node_modules/@lit/reactive-element/reactive-element.js
47
+ var { is: i2, defineProperty: e2, getOwnPropertyDescriptor: h, getOwnPropertyNames: r2, getOwnPropertySymbols: o2, getPrototypeOf: n2 } = Object;
48
+ var a = globalThis;
49
+ var c2 = a.trustedTypes;
50
+ var l = c2 ? c2.emptyScript : "";
51
+ var p = a.reactiveElementPolyfillSupport;
52
+ var d = (t3, s4) => t3;
53
+ var u = { toAttribute(t3, s4) {
54
+ switch (s4) {
55
+ case Boolean:
56
+ t3 = t3 ? l : null;
57
+ break;
58
+ case Object:
59
+ case Array:
60
+ t3 = null == t3 ? t3 : JSON.stringify(t3);
61
+ }
62
+ return t3;
63
+ }, fromAttribute(t3, s4) {
64
+ let i5 = t3;
65
+ switch (s4) {
66
+ case Boolean:
67
+ i5 = null !== t3;
68
+ break;
69
+ case Number:
70
+ i5 = null === t3 ? null : Number(t3);
71
+ break;
72
+ case Object:
73
+ case Array:
74
+ try {
75
+ i5 = JSON.parse(t3);
76
+ } catch (t4) {
77
+ i5 = null;
78
+ }
79
+ }
80
+ return i5;
81
+ } };
82
+ var f = (t3, s4) => !i2(t3, s4);
83
+ var b = { attribute: true, type: String, converter: u, reflect: false, useDefault: false, hasChanged: f };
84
+ Symbol.metadata ??= Symbol("metadata"), a.litPropertyMetadata ??= /* @__PURE__ */ new WeakMap();
85
+ var y = class extends HTMLElement {
86
+ static addInitializer(t3) {
87
+ this._$Ei(), (this.l ??= []).push(t3);
88
+ }
89
+ static get observedAttributes() {
90
+ return this.finalize(), this._$Eh && [...this._$Eh.keys()];
91
+ }
92
+ static createProperty(t3, s4 = b) {
93
+ if (s4.state && (s4.attribute = false), this._$Ei(), this.prototype.hasOwnProperty(t3) && ((s4 = Object.create(s4)).wrapped = true), this.elementProperties.set(t3, s4), !s4.noAccessor) {
94
+ const i5 = Symbol(), h3 = this.getPropertyDescriptor(t3, i5, s4);
95
+ void 0 !== h3 && e2(this.prototype, t3, h3);
96
+ }
97
+ }
98
+ static getPropertyDescriptor(t3, s4, i5) {
99
+ const { get: e5, set: r5 } = h(this.prototype, t3) ?? { get() {
100
+ return this[s4];
101
+ }, set(t4) {
102
+ this[s4] = t4;
103
+ } };
104
+ return { get: e5, set(s5) {
105
+ const h3 = e5?.call(this);
106
+ r5?.call(this, s5), this.requestUpdate(t3, h3, i5);
107
+ }, configurable: true, enumerable: true };
108
+ }
109
+ static getPropertyOptions(t3) {
110
+ return this.elementProperties.get(t3) ?? b;
111
+ }
112
+ static _$Ei() {
113
+ if (this.hasOwnProperty(d("elementProperties"))) return;
114
+ const t3 = n2(this);
115
+ t3.finalize(), void 0 !== t3.l && (this.l = [...t3.l]), this.elementProperties = new Map(t3.elementProperties);
116
+ }
117
+ static finalize() {
118
+ if (this.hasOwnProperty(d("finalized"))) return;
119
+ if (this.finalized = true, this._$Ei(), this.hasOwnProperty(d("properties"))) {
120
+ const t4 = this.properties, s4 = [...r2(t4), ...o2(t4)];
121
+ for (const i5 of s4) this.createProperty(i5, t4[i5]);
122
+ }
123
+ const t3 = this[Symbol.metadata];
124
+ if (null !== t3) {
125
+ const s4 = litPropertyMetadata.get(t3);
126
+ if (void 0 !== s4) for (const [t4, i5] of s4) this.elementProperties.set(t4, i5);
127
+ }
128
+ this._$Eh = /* @__PURE__ */ new Map();
129
+ for (const [t4, s4] of this.elementProperties) {
130
+ const i5 = this._$Eu(t4, s4);
131
+ void 0 !== i5 && this._$Eh.set(i5, t4);
132
+ }
133
+ this.elementStyles = this.finalizeStyles(this.styles);
134
+ }
135
+ static finalizeStyles(s4) {
136
+ const i5 = [];
137
+ if (Array.isArray(s4)) {
138
+ const e5 = new Set(s4.flat(1 / 0).reverse());
139
+ for (const s5 of e5) i5.unshift(c(s5));
140
+ } else void 0 !== s4 && i5.push(c(s4));
141
+ return i5;
142
+ }
143
+ static _$Eu(t3, s4) {
144
+ const i5 = s4.attribute;
145
+ return false === i5 ? void 0 : "string" == typeof i5 ? i5 : "string" == typeof t3 ? t3.toLowerCase() : void 0;
146
+ }
147
+ constructor() {
148
+ super(), this._$Ep = void 0, this.isUpdatePending = false, this.hasUpdated = false, this._$Em = null, this._$Ev();
149
+ }
150
+ _$Ev() {
151
+ this._$ES = new Promise(((t3) => this.enableUpdating = t3)), this._$AL = /* @__PURE__ */ new Map(), this._$E_(), this.requestUpdate(), this.constructor.l?.forEach(((t3) => t3(this)));
152
+ }
153
+ addController(t3) {
154
+ (this._$EO ??= /* @__PURE__ */ new Set()).add(t3), void 0 !== this.renderRoot && this.isConnected && t3.hostConnected?.();
155
+ }
156
+ removeController(t3) {
157
+ this._$EO?.delete(t3);
158
+ }
159
+ _$E_() {
160
+ const t3 = /* @__PURE__ */ new Map(), s4 = this.constructor.elementProperties;
161
+ for (const i5 of s4.keys()) this.hasOwnProperty(i5) && (t3.set(i5, this[i5]), delete this[i5]);
162
+ t3.size > 0 && (this._$Ep = t3);
163
+ }
164
+ createRenderRoot() {
165
+ const t3 = this.shadowRoot ?? this.attachShadow(this.constructor.shadowRootOptions);
166
+ return S(t3, this.constructor.elementStyles), t3;
167
+ }
168
+ connectedCallback() {
169
+ this.renderRoot ??= this.createRenderRoot(), this.enableUpdating(true), this._$EO?.forEach(((t3) => t3.hostConnected?.()));
170
+ }
171
+ enableUpdating(t3) {
172
+ }
173
+ disconnectedCallback() {
174
+ this._$EO?.forEach(((t3) => t3.hostDisconnected?.()));
175
+ }
176
+ attributeChangedCallback(t3, s4, i5) {
177
+ this._$AK(t3, i5);
178
+ }
179
+ _$ET(t3, s4) {
180
+ const i5 = this.constructor.elementProperties.get(t3), e5 = this.constructor._$Eu(t3, i5);
181
+ if (void 0 !== e5 && true === i5.reflect) {
182
+ const h3 = (void 0 !== i5.converter?.toAttribute ? i5.converter : u).toAttribute(s4, i5.type);
183
+ this._$Em = t3, null == h3 ? this.removeAttribute(e5) : this.setAttribute(e5, h3), this._$Em = null;
184
+ }
185
+ }
186
+ _$AK(t3, s4) {
187
+ const i5 = this.constructor, e5 = i5._$Eh.get(t3);
188
+ if (void 0 !== e5 && this._$Em !== e5) {
189
+ const t4 = i5.getPropertyOptions(e5), h3 = "function" == typeof t4.converter ? { fromAttribute: t4.converter } : void 0 !== t4.converter?.fromAttribute ? t4.converter : u;
190
+ this._$Em = e5;
191
+ const r5 = h3.fromAttribute(s4, t4.type);
192
+ this[e5] = r5 ?? this._$Ej?.get(e5) ?? r5, this._$Em = null;
193
+ }
194
+ }
195
+ requestUpdate(t3, s4, i5) {
196
+ if (void 0 !== t3) {
197
+ const e5 = this.constructor, h3 = this[t3];
198
+ if (i5 ??= e5.getPropertyOptions(t3), !((i5.hasChanged ?? f)(h3, s4) || i5.useDefault && i5.reflect && h3 === this._$Ej?.get(t3) && !this.hasAttribute(e5._$Eu(t3, i5)))) return;
199
+ this.C(t3, s4, i5);
200
+ }
201
+ false === this.isUpdatePending && (this._$ES = this._$EP());
202
+ }
203
+ C(t3, s4, { useDefault: i5, reflect: e5, wrapped: h3 }, r5) {
204
+ i5 && !(this._$Ej ??= /* @__PURE__ */ new Map()).has(t3) && (this._$Ej.set(t3, r5 ?? s4 ?? this[t3]), true !== h3 || void 0 !== r5) || (this._$AL.has(t3) || (this.hasUpdated || i5 || (s4 = void 0), this._$AL.set(t3, s4)), true === e5 && this._$Em !== t3 && (this._$Eq ??= /* @__PURE__ */ new Set()).add(t3));
205
+ }
206
+ async _$EP() {
207
+ this.isUpdatePending = true;
208
+ try {
209
+ await this._$ES;
210
+ } catch (t4) {
211
+ Promise.reject(t4);
212
+ }
213
+ const t3 = this.scheduleUpdate();
214
+ return null != t3 && await t3, !this.isUpdatePending;
215
+ }
216
+ scheduleUpdate() {
217
+ return this.performUpdate();
218
+ }
219
+ performUpdate() {
220
+ if (!this.isUpdatePending) return;
221
+ if (!this.hasUpdated) {
222
+ if (this.renderRoot ??= this.createRenderRoot(), this._$Ep) {
223
+ for (const [t5, s5] of this._$Ep) this[t5] = s5;
224
+ this._$Ep = void 0;
225
+ }
226
+ const t4 = this.constructor.elementProperties;
227
+ if (t4.size > 0) for (const [s5, i5] of t4) {
228
+ const { wrapped: t5 } = i5, e5 = this[s5];
229
+ true !== t5 || this._$AL.has(s5) || void 0 === e5 || this.C(s5, void 0, i5, e5);
230
+ }
231
+ }
232
+ let t3 = false;
233
+ const s4 = this._$AL;
234
+ try {
235
+ t3 = this.shouldUpdate(s4), t3 ? (this.willUpdate(s4), this._$EO?.forEach(((t4) => t4.hostUpdate?.())), this.update(s4)) : this._$EM();
236
+ } catch (s5) {
237
+ throw t3 = false, this._$EM(), s5;
238
+ }
239
+ t3 && this._$AE(s4);
240
+ }
241
+ willUpdate(t3) {
242
+ }
243
+ _$AE(t3) {
244
+ this._$EO?.forEach(((t4) => t4.hostUpdated?.())), this.hasUpdated || (this.hasUpdated = true, this.firstUpdated(t3)), this.updated(t3);
245
+ }
246
+ _$EM() {
247
+ this._$AL = /* @__PURE__ */ new Map(), this.isUpdatePending = false;
248
+ }
249
+ get updateComplete() {
250
+ return this.getUpdateComplete();
251
+ }
252
+ getUpdateComplete() {
253
+ return this._$ES;
254
+ }
255
+ shouldUpdate(t3) {
256
+ return true;
257
+ }
258
+ update(t3) {
259
+ this._$Eq &&= this._$Eq.forEach(((t4) => this._$ET(t4, this[t4]))), this._$EM();
260
+ }
261
+ updated(t3) {
262
+ }
263
+ firstUpdated(t3) {
264
+ }
265
+ };
266
+ y.elementStyles = [], y.shadowRootOptions = { mode: "open" }, y[d("elementProperties")] = /* @__PURE__ */ new Map(), y[d("finalized")] = /* @__PURE__ */ new Map(), p?.({ ReactiveElement: y }), (a.reactiveElementVersions ??= []).push("2.1.1");
267
+
268
+ // node_modules/lit-html/lit-html.js
269
+ var t2 = globalThis;
270
+ var i3 = t2.trustedTypes;
271
+ var s2 = i3 ? i3.createPolicy("lit-html", { createHTML: (t3) => t3 }) : void 0;
272
+ var e3 = "$lit$";
273
+ var h2 = `lit$${Math.random().toFixed(9).slice(2)}$`;
274
+ var o3 = "?" + h2;
275
+ var n3 = `<${o3}>`;
276
+ var r3 = document;
277
+ var l2 = () => r3.createComment("");
278
+ var c3 = (t3) => null === t3 || "object" != typeof t3 && "function" != typeof t3;
279
+ var a2 = Array.isArray;
280
+ var u2 = (t3) => a2(t3) || "function" == typeof t3?.[Symbol.iterator];
281
+ var d2 = "[ \n\f\r]";
282
+ var f2 = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g;
283
+ var v = /-->/g;
284
+ var _ = />/g;
285
+ var m = RegExp(`>|${d2}(?:([^\\s"'>=/]+)(${d2}*=${d2}*(?:[^
286
+ \f\r"'\`<>=]|("|')|))|$)`, "g");
287
+ var p2 = /'/g;
288
+ var g = /"/g;
289
+ var $ = /^(?:script|style|textarea|title)$/i;
290
+ var y2 = (t3) => (i5, ...s4) => ({ _$litType$: t3, strings: i5, values: s4 });
291
+ var x = y2(1);
292
+ var b2 = y2(2);
293
+ var w = y2(3);
294
+ var T = Symbol.for("lit-noChange");
295
+ var E = Symbol.for("lit-nothing");
296
+ var A = /* @__PURE__ */ new WeakMap();
297
+ var C = r3.createTreeWalker(r3, 129);
298
+ function P(t3, i5) {
299
+ if (!a2(t3) || !t3.hasOwnProperty("raw")) throw Error("invalid template strings array");
300
+ return void 0 !== s2 ? s2.createHTML(i5) : i5;
301
+ }
302
+ var V = (t3, i5) => {
303
+ const s4 = t3.length - 1, o6 = [];
304
+ let r5, l3 = 2 === i5 ? "<svg>" : 3 === i5 ? "<math>" : "", c4 = f2;
305
+ for (let i6 = 0; i6 < s4; i6++) {
306
+ const s5 = t3[i6];
307
+ let a3, u3, d3 = -1, y3 = 0;
308
+ for (; y3 < s5.length && (c4.lastIndex = y3, u3 = c4.exec(s5), null !== u3); ) y3 = c4.lastIndex, c4 === f2 ? "!--" === u3[1] ? c4 = v : void 0 !== u3[1] ? c4 = _ : void 0 !== u3[2] ? ($.test(u3[2]) && (r5 = RegExp("</" + u3[2], "g")), c4 = m) : void 0 !== u3[3] && (c4 = m) : c4 === m ? ">" === u3[0] ? (c4 = r5 ?? f2, d3 = -1) : void 0 === u3[1] ? d3 = -2 : (d3 = c4.lastIndex - u3[2].length, a3 = u3[1], c4 = void 0 === u3[3] ? m : '"' === u3[3] ? g : p2) : c4 === g || c4 === p2 ? c4 = m : c4 === v || c4 === _ ? c4 = f2 : (c4 = m, r5 = void 0);
309
+ const x2 = c4 === m && t3[i6 + 1].startsWith("/>") ? " " : "";
310
+ l3 += c4 === f2 ? s5 + n3 : d3 >= 0 ? (o6.push(a3), s5.slice(0, d3) + e3 + s5.slice(d3) + h2 + x2) : s5 + h2 + (-2 === d3 ? i6 : x2);
311
+ }
312
+ return [P(t3, l3 + (t3[s4] || "<?>") + (2 === i5 ? "</svg>" : 3 === i5 ? "</math>" : "")), o6];
313
+ };
314
+ var N = class _N {
315
+ constructor({ strings: t3, _$litType$: s4 }, n5) {
316
+ let r5;
317
+ this.parts = [];
318
+ let c4 = 0, a3 = 0;
319
+ const u3 = t3.length - 1, d3 = this.parts, [f3, v2] = V(t3, s4);
320
+ if (this.el = _N.createElement(f3, n5), C.currentNode = this.el.content, 2 === s4 || 3 === s4) {
321
+ const t4 = this.el.content.firstChild;
322
+ t4.replaceWith(...t4.childNodes);
323
+ }
324
+ for (; null !== (r5 = C.nextNode()) && d3.length < u3; ) {
325
+ if (1 === r5.nodeType) {
326
+ if (r5.hasAttributes()) for (const t4 of r5.getAttributeNames()) if (t4.endsWith(e3)) {
327
+ const i5 = v2[a3++], s5 = r5.getAttribute(t4).split(h2), e5 = /([.?@])?(.*)/.exec(i5);
328
+ d3.push({ type: 1, index: c4, name: e5[2], strings: s5, ctor: "." === e5[1] ? H : "?" === e5[1] ? I : "@" === e5[1] ? L : k }), r5.removeAttribute(t4);
329
+ } else t4.startsWith(h2) && (d3.push({ type: 6, index: c4 }), r5.removeAttribute(t4));
330
+ if ($.test(r5.tagName)) {
331
+ const t4 = r5.textContent.split(h2), s5 = t4.length - 1;
332
+ if (s5 > 0) {
333
+ r5.textContent = i3 ? i3.emptyScript : "";
334
+ for (let i5 = 0; i5 < s5; i5++) r5.append(t4[i5], l2()), C.nextNode(), d3.push({ type: 2, index: ++c4 });
335
+ r5.append(t4[s5], l2());
336
+ }
337
+ }
338
+ } else if (8 === r5.nodeType) if (r5.data === o3) d3.push({ type: 2, index: c4 });
339
+ else {
340
+ let t4 = -1;
341
+ for (; -1 !== (t4 = r5.data.indexOf(h2, t4 + 1)); ) d3.push({ type: 7, index: c4 }), t4 += h2.length - 1;
342
+ }
343
+ c4++;
344
+ }
345
+ }
346
+ static createElement(t3, i5) {
347
+ const s4 = r3.createElement("template");
348
+ return s4.innerHTML = t3, s4;
349
+ }
350
+ };
351
+ function S2(t3, i5, s4 = t3, e5) {
352
+ if (i5 === T) return i5;
353
+ let h3 = void 0 !== e5 ? s4._$Co?.[e5] : s4._$Cl;
354
+ const o6 = c3(i5) ? void 0 : i5._$litDirective$;
355
+ return h3?.constructor !== o6 && (h3?._$AO?.(false), void 0 === o6 ? h3 = void 0 : (h3 = new o6(t3), h3._$AT(t3, s4, e5)), void 0 !== e5 ? (s4._$Co ??= [])[e5] = h3 : s4._$Cl = h3), void 0 !== h3 && (i5 = S2(t3, h3._$AS(t3, i5.values), h3, e5)), i5;
356
+ }
357
+ var M = class {
358
+ constructor(t3, i5) {
359
+ this._$AV = [], this._$AN = void 0, this._$AD = t3, this._$AM = i5;
360
+ }
361
+ get parentNode() {
362
+ return this._$AM.parentNode;
363
+ }
364
+ get _$AU() {
365
+ return this._$AM._$AU;
366
+ }
367
+ u(t3) {
368
+ const { el: { content: i5 }, parts: s4 } = this._$AD, e5 = (t3?.creationScope ?? r3).importNode(i5, true);
369
+ C.currentNode = e5;
370
+ let h3 = C.nextNode(), o6 = 0, n5 = 0, l3 = s4[0];
371
+ for (; void 0 !== l3; ) {
372
+ if (o6 === l3.index) {
373
+ let i6;
374
+ 2 === l3.type ? i6 = new R(h3, h3.nextSibling, this, t3) : 1 === l3.type ? i6 = new l3.ctor(h3, l3.name, l3.strings, this, t3) : 6 === l3.type && (i6 = new z(h3, this, t3)), this._$AV.push(i6), l3 = s4[++n5];
375
+ }
376
+ o6 !== l3?.index && (h3 = C.nextNode(), o6++);
377
+ }
378
+ return C.currentNode = r3, e5;
379
+ }
380
+ p(t3) {
381
+ let i5 = 0;
382
+ for (const s4 of this._$AV) void 0 !== s4 && (void 0 !== s4.strings ? (s4._$AI(t3, s4, i5), i5 += s4.strings.length - 2) : s4._$AI(t3[i5])), i5++;
383
+ }
384
+ };
385
+ var R = class _R {
386
+ get _$AU() {
387
+ return this._$AM?._$AU ?? this._$Cv;
388
+ }
389
+ constructor(t3, i5, s4, e5) {
390
+ this.type = 2, this._$AH = E, this._$AN = void 0, this._$AA = t3, this._$AB = i5, this._$AM = s4, this.options = e5, this._$Cv = e5?.isConnected ?? true;
391
+ }
392
+ get parentNode() {
393
+ let t3 = this._$AA.parentNode;
394
+ const i5 = this._$AM;
395
+ return void 0 !== i5 && 11 === t3?.nodeType && (t3 = i5.parentNode), t3;
396
+ }
397
+ get startNode() {
398
+ return this._$AA;
399
+ }
400
+ get endNode() {
401
+ return this._$AB;
402
+ }
403
+ _$AI(t3, i5 = this) {
404
+ t3 = S2(this, t3, i5), c3(t3) ? t3 === E || null == t3 || "" === t3 ? (this._$AH !== E && this._$AR(), this._$AH = E) : t3 !== this._$AH && t3 !== T && this._(t3) : void 0 !== t3._$litType$ ? this.$(t3) : void 0 !== t3.nodeType ? this.T(t3) : u2(t3) ? this.k(t3) : this._(t3);
405
+ }
406
+ O(t3) {
407
+ return this._$AA.parentNode.insertBefore(t3, this._$AB);
408
+ }
409
+ T(t3) {
410
+ this._$AH !== t3 && (this._$AR(), this._$AH = this.O(t3));
411
+ }
412
+ _(t3) {
413
+ this._$AH !== E && c3(this._$AH) ? this._$AA.nextSibling.data = t3 : this.T(r3.createTextNode(t3)), this._$AH = t3;
414
+ }
415
+ $(t3) {
416
+ const { values: i5, _$litType$: s4 } = t3, e5 = "number" == typeof s4 ? this._$AC(t3) : (void 0 === s4.el && (s4.el = N.createElement(P(s4.h, s4.h[0]), this.options)), s4);
417
+ if (this._$AH?._$AD === e5) this._$AH.p(i5);
418
+ else {
419
+ const t4 = new M(e5, this), s5 = t4.u(this.options);
420
+ t4.p(i5), this.T(s5), this._$AH = t4;
421
+ }
422
+ }
423
+ _$AC(t3) {
424
+ let i5 = A.get(t3.strings);
425
+ return void 0 === i5 && A.set(t3.strings, i5 = new N(t3)), i5;
426
+ }
427
+ k(t3) {
428
+ a2(this._$AH) || (this._$AH = [], this._$AR());
429
+ const i5 = this._$AH;
430
+ let s4, e5 = 0;
431
+ for (const h3 of t3) e5 === i5.length ? i5.push(s4 = new _R(this.O(l2()), this.O(l2()), this, this.options)) : s4 = i5[e5], s4._$AI(h3), e5++;
432
+ e5 < i5.length && (this._$AR(s4 && s4._$AB.nextSibling, e5), i5.length = e5);
433
+ }
434
+ _$AR(t3 = this._$AA.nextSibling, i5) {
435
+ for (this._$AP?.(false, true, i5); t3 !== this._$AB; ) {
436
+ const i6 = t3.nextSibling;
437
+ t3.remove(), t3 = i6;
438
+ }
439
+ }
440
+ setConnected(t3) {
441
+ void 0 === this._$AM && (this._$Cv = t3, this._$AP?.(t3));
442
+ }
443
+ };
444
+ var k = class {
445
+ get tagName() {
446
+ return this.element.tagName;
447
+ }
448
+ get _$AU() {
449
+ return this._$AM._$AU;
450
+ }
451
+ constructor(t3, i5, s4, e5, h3) {
452
+ this.type = 1, this._$AH = E, this._$AN = void 0, this.element = t3, this.name = i5, this._$AM = e5, this.options = h3, s4.length > 2 || "" !== s4[0] || "" !== s4[1] ? (this._$AH = Array(s4.length - 1).fill(new String()), this.strings = s4) : this._$AH = E;
453
+ }
454
+ _$AI(t3, i5 = this, s4, e5) {
455
+ const h3 = this.strings;
456
+ let o6 = false;
457
+ if (void 0 === h3) t3 = S2(this, t3, i5, 0), o6 = !c3(t3) || t3 !== this._$AH && t3 !== T, o6 && (this._$AH = t3);
458
+ else {
459
+ const e6 = t3;
460
+ let n5, r5;
461
+ for (t3 = h3[0], n5 = 0; n5 < h3.length - 1; n5++) r5 = S2(this, e6[s4 + n5], i5, n5), r5 === T && (r5 = this._$AH[n5]), o6 ||= !c3(r5) || r5 !== this._$AH[n5], r5 === E ? t3 = E : t3 !== E && (t3 += (r5 ?? "") + h3[n5 + 1]), this._$AH[n5] = r5;
462
+ }
463
+ o6 && !e5 && this.j(t3);
464
+ }
465
+ j(t3) {
466
+ t3 === E ? this.element.removeAttribute(this.name) : this.element.setAttribute(this.name, t3 ?? "");
467
+ }
468
+ };
469
+ var H = class extends k {
470
+ constructor() {
471
+ super(...arguments), this.type = 3;
472
+ }
473
+ j(t3) {
474
+ this.element[this.name] = t3 === E ? void 0 : t3;
475
+ }
476
+ };
477
+ var I = class extends k {
478
+ constructor() {
479
+ super(...arguments), this.type = 4;
480
+ }
481
+ j(t3) {
482
+ this.element.toggleAttribute(this.name, !!t3 && t3 !== E);
483
+ }
484
+ };
485
+ var L = class extends k {
486
+ constructor(t3, i5, s4, e5, h3) {
487
+ super(t3, i5, s4, e5, h3), this.type = 5;
488
+ }
489
+ _$AI(t3, i5 = this) {
490
+ if ((t3 = S2(this, t3, i5, 0) ?? E) === T) return;
491
+ const s4 = this._$AH, e5 = t3 === E && s4 !== E || t3.capture !== s4.capture || t3.once !== s4.once || t3.passive !== s4.passive, h3 = t3 !== E && (s4 === E || e5);
492
+ e5 && this.element.removeEventListener(this.name, this, s4), h3 && this.element.addEventListener(this.name, this, t3), this._$AH = t3;
493
+ }
494
+ handleEvent(t3) {
495
+ "function" == typeof this._$AH ? this._$AH.call(this.options?.host ?? this.element, t3) : this._$AH.handleEvent(t3);
496
+ }
497
+ };
498
+ var z = class {
499
+ constructor(t3, i5, s4) {
500
+ this.element = t3, this.type = 6, this._$AN = void 0, this._$AM = i5, this.options = s4;
501
+ }
502
+ get _$AU() {
503
+ return this._$AM._$AU;
504
+ }
505
+ _$AI(t3) {
506
+ S2(this, t3);
507
+ }
508
+ };
509
+ var j = t2.litHtmlPolyfillSupport;
510
+ j?.(N, R), (t2.litHtmlVersions ??= []).push("3.3.1");
511
+ var B = (t3, i5, s4) => {
512
+ const e5 = s4?.renderBefore ?? i5;
513
+ let h3 = e5._$litPart$;
514
+ if (void 0 === h3) {
515
+ const t4 = s4?.renderBefore ?? null;
516
+ e5._$litPart$ = h3 = new R(i5.insertBefore(l2(), t4), t4, void 0, s4 ?? {});
517
+ }
518
+ return h3._$AI(t3), h3;
519
+ };
520
+
521
+ // node_modules/lit-element/lit-element.js
522
+ var s3 = globalThis;
523
+ var i4 = class extends y {
524
+ constructor() {
525
+ super(...arguments), this.renderOptions = { host: this }, this._$Do = void 0;
526
+ }
527
+ createRenderRoot() {
528
+ const t3 = super.createRenderRoot();
529
+ return this.renderOptions.renderBefore ??= t3.firstChild, t3;
530
+ }
531
+ update(t3) {
532
+ const r5 = this.render();
533
+ this.hasUpdated || (this.renderOptions.isConnected = this.isConnected), super.update(t3), this._$Do = B(r5, this.renderRoot, this.renderOptions);
534
+ }
535
+ connectedCallback() {
536
+ super.connectedCallback(), this._$Do?.setConnected(true);
537
+ }
538
+ disconnectedCallback() {
539
+ super.disconnectedCallback(), this._$Do?.setConnected(false);
540
+ }
541
+ render() {
542
+ return T;
543
+ }
544
+ };
545
+ i4._$litElement$ = true, i4["finalized"] = true, s3.litElementHydrateSupport?.({ LitElement: i4 });
546
+ var o4 = s3.litElementPolyfillSupport;
547
+ o4?.({ LitElement: i4 });
548
+ (s3.litElementVersions ??= []).push("4.2.1");
549
+
550
+ // node_modules/@lit/reactive-element/decorators/property.js
551
+ var o5 = { attribute: true, type: String, converter: u, reflect: false, hasChanged: f };
552
+ var r4 = (t3 = o5, e5, r5) => {
553
+ const { kind: n5, metadata: i5 } = r5;
554
+ let s4 = globalThis.litPropertyMetadata.get(i5);
555
+ if (void 0 === s4 && globalThis.litPropertyMetadata.set(i5, s4 = /* @__PURE__ */ new Map()), "setter" === n5 && ((t3 = Object.create(t3)).wrapped = true), s4.set(r5.name, t3), "accessor" === n5) {
556
+ const { name: o6 } = r5;
557
+ return { set(r6) {
558
+ const n6 = e5.get.call(this);
559
+ e5.set.call(this, r6), this.requestUpdate(o6, n6, t3);
560
+ }, init(e6) {
561
+ return void 0 !== e6 && this.C(o6, void 0, t3, e6), e6;
562
+ } };
563
+ }
564
+ if ("setter" === n5) {
565
+ const { name: o6 } = r5;
566
+ return function(r6) {
567
+ const n6 = this[o6];
568
+ e5.call(this, r6), this.requestUpdate(o6, n6, t3);
569
+ };
570
+ }
571
+ throw Error("Unsupported decorator location: " + n5);
572
+ };
573
+ function n4(t3) {
574
+ return (e5, o6) => "object" == typeof o6 ? r4(t3, e5, o6) : ((t4, e6, o7) => {
575
+ const r5 = e6.hasOwnProperty(o7);
576
+ return e6.constructor.createProperty(o7, t4), r5 ? Object.getOwnPropertyDescriptor(e6, o7) : void 0;
577
+ })(t3, e5, o6);
578
+ }
579
+
580
+ // dist/styles/base.js
581
+ var baseStyles = i`
4
582
  * {
5
583
  box-sizing: border-box;
6
584
  }
7
- `;var St=x`
585
+ `;
586
+
587
+ // dist/styles/container-styles.js
588
+ var containerStyles = i`
8
589
  :host {
9
590
  /* Make the component fill its container completely */
10
591
  display: block;
@@ -23,7 +604,7 @@ var D=globalThis,I=D.ShadowRoot&&(D.ShadyCSS===void 0||D.ShadyCSS.nativeShadow)&
23
604
  }
24
605
 
25
606
  /* Handle visibility state */
26
- :host([visibility='hidden']) {
607
+ :host([visibility="hidden"]) {
27
608
  display: none;
28
609
  }
29
610
 
@@ -35,17 +616,896 @@ var D=globalThis,I=D.ShadowRoot&&(D.ShadyCSS===void 0||D.ShadyCSS.nativeShadow)&
35
616
  margin: 0 !important;
36
617
  padding: 0 !important;
37
618
  }
38
- `;function j(r){let t;try{t=new URL(r)}catch{throw new Error("Invalid baseURL: not a parseable URL")}if(t.protocol!=="https:")throw new Error("Invalid baseURL: must use https");let e=t.host.toLowerCase();if(!/^assistant\.[a-z0-9-]+\.corti\.app$/i.test(e))throw new Error("Invalid baseURL: host must match assistant.xxx.corti.app");if(t.pathname&&t.pathname!=="/"&&t.pathname!=="")throw new Error("Invalid baseURL: must not include a path");if(t.username||t.password)throw new Error("Invalid baseURL: must not include credentials");return t.origin.replace(/\/+$/,"")}function ot(r){return`${r}/embedded`}function Rt(r,t){if(!r||r.startsWith("about:"))return!1;try{let e=new URL(r,window.location.href),s=new URL(t);return e.origin!==s.origin?!1:e.pathname.replace(/\/+$/,"")==="/embedded"}catch{return!1}}function Ft(r){try{return JSON.parse(r)}catch{return null}}function F(r){let t=r.match(/\b([1-5]\d{2})\b/);return t?t[1]:void 0}function nt(r){return typeof r=="object"&&r!==null&&("expected"in r||"code"in r||"path"in r||"message"in r)}function at(r){let{path:t,expected:e,message:s,code:i}=r;if(s)return s;let o=t&&t.length>0?t.join("."):"field";return e?`Invalid ${o}: expected ${e}`:i?`Validation error in ${o} (${i})`:`Validation error in ${o}`}function xt(r){return r.length===0?"Unknown validation error":r.length===1?at(r[0]):`Multiple validation errors: ${r.map(at).join("; ")}`}function u(r,t="An error occurred"){if(!r)return{message:t,details:r};if(r instanceof Error){let e=F(r.message);return{message:r.message||t,code:e,details:r}}if(typeof r=="string"){let e=F(r);return{message:r,code:e,details:r}}if(Array.isArray(r)){if(r.every(nt)){let e=r;return{message:xt(e),code:e[0]?.code,details:r}}return{message:`Multiple errors: ${r.length} item(s)`,details:r}}if(typeof r=="object"){let e=r;if(e.message&&typeof e.message=="string"){let s=e.message,{code:i}=e;if(i||(i=F(s)),e.details?.message&&typeof e.details.message=="string"){let o=Ft(e.details.message);Array.isArray(o)&&o.every(nt)&&(s=xt(o))}return{message:s,code:i,details:e.details}}if(nt(e))return{message:at(e),code:e.code,details:r};if(e.error||e.message||e.detail){let s=e.error||e.message||e.detail,i=typeof s=="string"?s:t,o=e.code||e.status;return!o&&typeof s=="string"&&(o=F(s)),{message:i,code:o,details:r}}}return{message:t,details:r}}var W=class r{constructor(t,e={}){this.pendingRequests=new Map,this.messageListener=null,this.isReady=!1,this.iframe=t,this.callbacks=e,this.setupMessageListener()}setupMessageListener(){this.messageListener=t=>{if(t.source!==this.iframe.contentWindow)return;let e=this.getTrustedOrigin();if(!e||t.origin!==e)return;let{data:s}=t;if(s?.type==="CORTI_EMBEDDED_EVENT"){this.handleEvent(s);return}s.requestId&&this.pendingRequests.has(s.requestId)&&this.handleResponse(s)},window.addEventListener("message",this.messageListener)}handleEvent(t){let e=t.event,{payload:s}=t;(e==="ready"||e==="loaded"||e==="embedded.ready")&&(this.isReady=!0),this.callbacks.onEvent?.({name:e,payload:s})}handleResponse(t){let e=this.pendingRequests.get(t.requestId);if(e){let{resolve:s,reject:i}=e;if(this.pendingRequests.delete(t.requestId),t.success===!1||t.error){let o={message:t.error||"Request failed",code:t.errorCode,details:t.errorDetails};this.callbacks.onError?.(o),i(o)}else s(t)}}destroy(){this.messageListener&&(window.removeEventListener("message",this.messageListener),this.messageListener=null),this.pendingRequests.clear()}updateCallbacks(t){this.callbacks={...this.callbacks,...t}}get ready(){return this.isReady}async waitForReady(t=3e4){return this.isReady?Promise.resolve():new Promise((e,s)=>{let i=setTimeout(()=>{s(new Error("Timeout waiting for iframe to be ready"))},t),o=n=>{n.source===this.iframe.contentWindow&&n.origin===this.getTrustedOrigin()&&n.data?.type==="CORTI_EMBEDDED_EVENT"&&(n.data.event==="ready"||n.data.event==="loaded"||n.data.event==="embedded.ready")&&(clearTimeout(i),window.removeEventListener("message",o),e())};window.addEventListener("message",o)})}async postMessage(t,e=1e4){if(!this.iframe.contentWindow)throw new Error("Iframe not ready");await this.waitForReady();let{contentWindow:s}=this.iframe,i=r.generateRequestId();return new Promise((o,n)=>{let d=setTimeout(()=>{this.pendingRequests.delete(i),n(new Error("Request timeout"))},e),a={resolve:c=>{clearTimeout(d),o(c)},reject:c=>{clearTimeout(d),n(c)}};this.pendingRequests.set(i,a);let h={...t,requestId:i},l=this.getTrustedOrigin();if(!l){this.pendingRequests.delete(i),n(new Error("Cannot determine trusted origin for postMessage"));return}s.postMessage(h,l)})}async auth(t){let e=await this.postMessage({type:"CORTI_EMBEDDED",version:"v1",action:"auth",payload:t});if(this.isReady=!1,e.payload&&e.success)return e.payload.user;throw new Error(e.error)}async configureSession(t){await this.postMessage({type:"CORTI_EMBEDDED",version:"v1",action:"configureSession",payload:t})}async navigate(t){await this.postMessage({type:"CORTI_EMBEDDED",version:"v1",action:"navigate",payload:t})}async addFacts(t){await this.postMessage({type:"CORTI_EMBEDDED",version:"v1",action:"addFacts",payload:t})}async createInteraction(t){let e=await this.postMessage({type:"CORTI_EMBEDDED",version:"v1",action:"createInteraction",payload:t});if(e.payload&&e.success)return e.payload;throw new Error(e.error)}async startRecording(){await this.postMessage({type:"CORTI_EMBEDDED",version:"v1",action:"startRecording",payload:{}})}async stopRecording(){await this.postMessage({type:"CORTI_EMBEDDED",version:"v1",action:"stopRecording",payload:{}})}async getStatus(){let t=await this.postMessage({type:"CORTI_EMBEDDED",version:"v1",action:"getStatus",payload:{}});if(t.payload&&t.success)return t.payload;throw new Error(t.error)}async configure(t){let e=await this.postMessage({type:"CORTI_EMBEDDED",version:"v1",action:"configure",payload:t});if(e.payload&&e.success)return e.payload;throw new Error(e.error)}async setCredentials(t){await this.postMessage({type:"CORTI_EMBEDDED",version:"v1",action:"setCredentials",payload:t})}async getTemplates(){let t=await this.postMessage({type:"CORTI_EMBEDDED",version:"v1",action:"getTemplates"});if(t.payload&&t.success)return t.payload;throw new Error(t.error)}static generateRequestId(){return`req_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}getTrustedOrigin(){try{let t=this.iframe.getAttribute("src")||this.iframe.src;return t?new URL(t,window.location.href).origin:null}catch{return null}}};var Mt=function(r,t,e,s){var i=arguments.length,o=i<3?t:s===null?s=Object.getOwnPropertyDescriptor(t,e):s,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(r,t,e,s);else for(var d=r.length-1;d>=0;d--)(n=r[d])&&(o=(i<3?n(o):i>3?n(t,e,o):n(t,e))||o);return i>3&&o&&Object.defineProperty(t,e,o),o},$=class extends E{constructor(){super(...arguments),this.visibility="hidden",this.postMessageHandler=null,this.normalizedBaseURL=null}connectedCallback(){if(super.connectedCallback(),!this.baseURL){this.dispatchErrorEvent({message:"baseURL is required"});return}try{this.normalizedBaseURL=j(this.baseURL)}catch(t){throw this.dispatchErrorEvent({message:t.message||"Invalid baseURL"}),t}}disconnectedCallback(){super.disconnectedCallback(),this.postMessageHandler&&(this.postMessageHandler.destroy(),this.postMessageHandler=null)}async setupPostMessageHandler(){if(this.postMessageHandler)return;let t=this.getIframe();if(t?.contentWindow){let e={onEvent:s=>{this.dispatchEmbeddedEvent(s.name,s.payload)},onError:s=>{this.dispatchErrorEvent(s)}};this.postMessageHandler=new W(t,e)}else this.dispatchErrorEvent({message:"No iframe or contentWindow available"})}dispatchPublicEvent(t,e){this.dispatchEvent(new CustomEvent(t,{detail:e}))}dispatchEmbeddedEvent(t,e){this.dispatchPublicEvent(t,e),this.dispatchPublicEvent("embedded-event",{name:t,payload:e})}dispatchErrorEvent(t){this.dispatchPublicEvent("error",t)}isRealIframeLoad(t){let e=t.getAttribute("src")||"";return this.normalizedBaseURL?Rt(e,this.normalizedBaseURL):!1}async handleIframeLoad(t){let e=t.target;if(e&&this.isRealIframeLoad(e))try{await this.setupPostMessageHandler()}catch(s){this.dispatchErrorEvent({message:`Failed to setup PostMessageHandler on iframe load: ${s}`})}}getIframe(){return this.shadowRoot?.querySelector("iframe")||null}updated(t){if(super.updated(t),t.has("baseURL")){try{this.normalizedBaseURL=j(this.baseURL)}catch(s){this.postMessageHandler&&(this.postMessageHandler.destroy(),this.postMessageHandler=null);let i=this.getIframe();i&&i.setAttribute("src","about:blank"),this.dispatchErrorEvent({message:s.message||"Invalid baseURL"});return}this.postMessageHandler&&(this.postMessageHandler.destroy(),this.postMessageHandler=null);let e=this.getIframe();if(e){let s=this.normalizedBaseURL?ot(this.normalizedBaseURL):"";e.getAttribute("src")!==s&&(e.setAttribute("src",s),e.setAttribute("allow",`microphone ${s}; camera ${s}; device-capture ${s}; display-capture ${s}`))}}}async auth(t){if(!this.postMessageHandler)throw new Error("Component not ready");try{let e={access_token:t.access_token,token_type:t.token_type,expires_at:t.expires_at,expires_in:t.expires_in,refresh_expires_in:t.refresh_expires_in,refresh_token:t.refresh_token,id_token:t.id_token,"not-before-policy":t["not-before-policy"],session_state:t.session_state,scope:t.scope,profile:t.profile,mode:t.mode};return await this.postMessageHandler.auth(e)}catch(e){let s=u(e,"Authentication failed");throw this.dispatchErrorEvent(s),new Error(JSON.stringify(s))}}async createInteraction(t){if(!this.postMessageHandler)throw new Error("Component not ready");try{let e=await this.postMessageHandler.createInteraction(t);return{id:e.id,createdAt:e.createdAt}}catch(e){let s=u(e,"Failed to create interaction");throw this.dispatchErrorEvent(s),new Error(JSON.stringify(s))}}async configureSession(t){if(!this.postMessageHandler)throw new Error("Component not ready");try{let e={defaultLanguage:t.defaultLanguage,defaultOutputLanguage:t.defaultOutputLanguage,defaultTemplateKey:t.defaultTemplateKey,defaultMode:t.defaultMode};await this.postMessageHandler.configureSession(e)}catch(e){let s=u(e,"Failed to configure session");throw this.dispatchErrorEvent(s),new Error(JSON.stringify(s))}}async addFacts(t){if(!this.postMessageHandler)throw new Error("Component not ready");try{let e={facts:t};await this.postMessageHandler.addFacts(e)}catch(e){let s=u(e,"Failed to add facts");throw this.dispatchErrorEvent(s),new Error(JSON.stringify(s))}}async navigate(t){if(!this.postMessageHandler)throw new Error("Component not ready");try{let e={path:t};await this.postMessageHandler.navigate(e)}catch(e){let s=u(e,"Failed to navigate");throw this.dispatchErrorEvent(s),new Error(JSON.stringify(s))}}async startRecording(){if(!this.postMessageHandler)throw new Error("Component not ready");try{await this.postMessageHandler.startRecording()}catch(t){let e=u(t,"Failed to start recording");throw this.dispatchErrorEvent(e),new Error(JSON.stringify(e))}}async stopRecording(){if(!this.postMessageHandler)throw new Error("Component not ready");try{await this.postMessageHandler.stopRecording()}catch(t){let e=u(t,"Failed to stop recording");throw this.dispatchErrorEvent(e),new Error(JSON.stringify(e))}}async getStatus(){if(!this.postMessageHandler)return{auth:{isAuthenticated:!1,user:void 0},currentUrl:"",interaction:null};try{return await this.postMessageHandler.getStatus()}catch(t){let e=u(t,"Failed to get status");throw this.dispatchErrorEvent(e),new Error(JSON.stringify(e))}}async configure(t){if(!this.postMessageHandler)throw new Error("Component not ready");try{return await this.postMessageHandler.configure(t)}catch(e){let s=u(e,"Failed to configure component");throw this.dispatchErrorEvent(s),new Error(JSON.stringify(s))}}async setCredentials(t){if(!this.postMessageHandler)throw new Error("Component not ready");try{if(!t.password)throw new Error("Password is required");await this.postMessageHandler.setCredentials(t)}catch(e){let s=u(e,"Failed to set credentials");throw this.dispatchErrorEvent(s),new Error(JSON.stringify(s))}}show(){this.visibility="visible"}hide(){this.visibility="hidden"}async getTemplates(){if(!this.postMessageHandler)throw new Error("Component not ready");try{return await this.postMessageHandler.getTemplates()}catch(t){let e=u(t,"Failed to get templates");throw this.dispatchErrorEvent(e),new Error(JSON.stringify(e))}}getDebugStatus(){let t=this.getIframe();return{ready:t?.contentDocument?.readyState==="complete",iframeExists:!!t,iframeSrc:t?.src,iframeContentWindow:!!t?.contentWindow,iframeContentDocument:!!t?.contentDocument,iframeReadyState:t?.contentDocument?.readyState,postMessageHandlerExists:!!this.postMessageHandler,postMessageHandlerReady:this.postMessageHandler?.ready||!1,baseURL:this.baseURL}}render(){return this.baseURL?rt`
619
+ `;
620
+
621
+ // dist/utils/baseUrl.js
622
+ function validateAndNormalizeBaseURL(url) {
623
+ let parsed;
624
+ try {
625
+ parsed = new URL(url);
626
+ } catch {
627
+ throw new Error("Invalid baseURL: not a parseable URL");
628
+ }
629
+ if (parsed.protocol !== "https:") {
630
+ throw new Error("Invalid baseURL: must use https");
631
+ }
632
+ const host = parsed.host.toLowerCase();
633
+ const pattern = /^assistant\.[a-z0-9-]+\.corti\.app$/i;
634
+ if (!pattern.test(host)) {
635
+ throw new Error("Invalid baseURL: host must match assistant.xxx.corti.app");
636
+ }
637
+ if (parsed.pathname && parsed.pathname !== "/" && parsed.pathname !== "") {
638
+ throw new Error("Invalid baseURL: must not include a path");
639
+ }
640
+ if (parsed.username || parsed.password) {
641
+ throw new Error("Invalid baseURL: must not include credentials");
642
+ }
643
+ return parsed.origin.replace(/\/+$/, "");
644
+ }
645
+
646
+ // dist/utils/embedUrl.js
647
+ function buildEmbeddedUrl(normalizedBaseURL) {
648
+ return `${normalizedBaseURL}/embedded`;
649
+ }
650
+ function isRealEmbeddedLoad(src, normalizedBaseURL) {
651
+ if (!src || src.startsWith("about:")) {
652
+ return false;
653
+ }
654
+ try {
655
+ const srcUrl = new URL(src, window.location.href);
656
+ const baseUrl = new URL(normalizedBaseURL);
657
+ if (srcUrl.origin !== baseUrl.origin) {
658
+ return false;
659
+ }
660
+ const normalizedPath = srcUrl.pathname.replace(/\/+$/, "");
661
+ return normalizedPath === "/embedded";
662
+ } catch {
663
+ return false;
664
+ }
665
+ }
666
+
667
+ // dist/utils/errorFormatter.js
668
+ function isRecord(value) {
669
+ return typeof value === "object" && value !== null;
670
+ }
671
+ function toStringIfFiniteNumberOrString(value) {
672
+ if (typeof value === "string") {
673
+ return value;
674
+ }
675
+ if (typeof value === "number" && Number.isFinite(value)) {
676
+ return String(value);
677
+ }
678
+ return void 0;
679
+ }
680
+ function tryParseJson(str) {
681
+ try {
682
+ return JSON.parse(str);
683
+ } catch {
684
+ return null;
685
+ }
686
+ }
687
+ function extractStatusCode(message) {
688
+ const statusCodeMatch = message.match(/\b([1-5]\d{2})\b/);
689
+ return statusCodeMatch ? statusCodeMatch[1] : void 0;
690
+ }
691
+ function isValidationError(obj) {
692
+ return typeof obj === "object" && obj !== null && ("expected" in obj || "code" in obj || "path" in obj || "message" in obj);
693
+ }
694
+ function formatValidationError(error) {
695
+ const { path, expected, message, code } = error;
696
+ if (message) {
697
+ return message;
698
+ }
699
+ const pathString = path && path.length > 0 ? path.join(".") : "field";
700
+ if (expected) {
701
+ return `Invalid ${pathString}: expected ${expected}`;
702
+ }
703
+ if (code) {
704
+ return `Validation error in ${pathString} (${code})`;
705
+ }
706
+ return `Validation error in ${pathString}`;
707
+ }
708
+ function formatValidationErrors(errors) {
709
+ if (errors.length === 0) {
710
+ return "Unknown validation error";
711
+ }
712
+ if (errors.length === 1) {
713
+ return formatValidationError(errors[0]);
714
+ }
715
+ const errorMessages = errors.map(formatValidationError);
716
+ return `Multiple validation errors: ${errorMessages.join("; ")}`;
717
+ }
718
+ function formatError(error, fallbackMessage = "An error occurred") {
719
+ if (!error) {
720
+ return {
721
+ message: fallbackMessage,
722
+ details: error
723
+ };
724
+ }
725
+ if (error instanceof Error) {
726
+ const extractedCode = extractStatusCode(error.message);
727
+ return {
728
+ message: error.message || fallbackMessage,
729
+ code: extractedCode,
730
+ details: error
731
+ };
732
+ }
733
+ if (typeof error === "string") {
734
+ const extractedCode = extractStatusCode(error);
735
+ return {
736
+ message: error,
737
+ code: extractedCode,
738
+ details: error
739
+ };
740
+ }
741
+ if (Array.isArray(error)) {
742
+ if (error.every(isValidationError)) {
743
+ const validationErrors = error;
744
+ return {
745
+ message: formatValidationErrors(validationErrors),
746
+ code: validationErrors[0]?.code,
747
+ // Use the first error's code if available
748
+ details: error
749
+ };
750
+ }
751
+ return {
752
+ message: `Multiple errors: ${error.length} item(s)`,
753
+ details: error
754
+ };
755
+ }
756
+ if (isRecord(error)) {
757
+ const errorObj = error;
758
+ const objectMessage = typeof errorObj.message === "string" ? errorObj.message : void 0;
759
+ const objectCode = toStringIfFiniteNumberOrString(errorObj.code);
760
+ const objectStatus = toStringIfFiniteNumberOrString(errorObj.status);
761
+ if (objectMessage) {
762
+ let formattedMessage = objectMessage;
763
+ let code = objectCode;
764
+ if (!code) {
765
+ code = extractStatusCode(formattedMessage);
766
+ }
767
+ if (isRecord(errorObj.details) && typeof errorObj.details.message === "string") {
768
+ const parsedDetails = tryParseJson(errorObj.details.message);
769
+ if (Array.isArray(parsedDetails) && parsedDetails.every(isValidationError)) {
770
+ formattedMessage = formatValidationErrors(parsedDetails);
771
+ }
772
+ }
773
+ return {
774
+ message: formattedMessage,
775
+ code,
776
+ details: errorObj.details
777
+ };
778
+ }
779
+ if (isValidationError(errorObj)) {
780
+ const validationError = {
781
+ expected: typeof errorObj.expected === "string" ? errorObj.expected : void 0,
782
+ code: objectCode,
783
+ path: Array.isArray(errorObj.path) && errorObj.path.every((pathPart) => typeof pathPart === "string") ? errorObj.path : void 0,
784
+ message: objectMessage
785
+ };
786
+ return {
787
+ message: formatValidationError(validationError),
788
+ code: validationError.code,
789
+ details: error
790
+ };
791
+ }
792
+ if (errorObj.error || errorObj.detail || objectStatus || objectCode) {
793
+ const message = errorObj.error ?? objectMessage ?? errorObj.detail;
794
+ const messageStr = typeof message === "string" ? message : fallbackMessage;
795
+ let code = objectCode ?? objectStatus;
796
+ if (!code && typeof message === "string") {
797
+ code = extractStatusCode(message);
798
+ }
799
+ return {
800
+ message: messageStr,
801
+ code,
802
+ details: error
803
+ };
804
+ }
805
+ }
806
+ return {
807
+ message: fallbackMessage,
808
+ details: error
809
+ };
810
+ }
811
+
812
+ // dist/utils/PostMessageHandler.js
813
+ function isRecord2(value) {
814
+ return typeof value === "object" && value !== null;
815
+ }
816
+ function isEmbeddedEventMessage(value) {
817
+ return isRecord2(value) && value.type === "CORTI_EMBEDDED_EVENT" && typeof value.event === "string";
818
+ }
819
+ function isEmbeddedResponseMessage(value) {
820
+ return isRecord2(value) && value.type === "CORTI_EMBEDDED_RESPONSE" && typeof value.action === "string" && typeof value.requestId === "string" && typeof value.success === "boolean";
821
+ }
822
+ var PostMessageHandler = class _PostMessageHandler {
823
+ constructor(iframe, callbacks = {}) {
824
+ this.pendingRequests = /* @__PURE__ */ new Map();
825
+ this.messageListener = null;
826
+ this.isReady = false;
827
+ this._protocolVersion = null;
828
+ this.iframe = iframe;
829
+ this.callbacks = callbacks;
830
+ this.requestTimeout = callbacks.requestTimeout ?? 1e4;
831
+ this.setupMessageListener();
832
+ }
833
+ setupMessageListener() {
834
+ this.messageListener = (event) => {
835
+ if (event.source !== this.iframe.contentWindow) {
836
+ return;
837
+ }
838
+ const trustedOrigin = this.getTrustedOrigin();
839
+ if (!trustedOrigin || event.origin !== trustedOrigin) {
840
+ return;
841
+ }
842
+ const { data } = event;
843
+ if (isEmbeddedEventMessage(data)) {
844
+ this.handleEvent(data);
845
+ return;
846
+ }
847
+ if (isEmbeddedResponseMessage(data) && this.pendingRequests.has(data.requestId)) {
848
+ this.handleResponse(data);
849
+ }
850
+ };
851
+ window.addEventListener("message", this.messageListener);
852
+ }
853
+ handleEvent(eventData) {
854
+ const eventType = eventData.event;
855
+ const { payload } = eventData;
856
+ if (eventType === "embedded.ready") {
857
+ this.isReady = true;
858
+ const version = isRecord2(payload) && typeof payload.version === "string" ? payload.version : void 0;
859
+ if (typeof version === "string") {
860
+ this._protocolVersion = version;
861
+ if (version !== _PostMessageHandler.SUPPORTED_PROTOCOL_VERSION) {
862
+ this.callbacks.onError?.({
863
+ message: `Protocol version mismatch: host supports '${_PostMessageHandler.SUPPORTED_PROTOCOL_VERSION}', iframe reported '${version}'. Some features may not work correctly.`
864
+ });
865
+ }
866
+ }
867
+ }
868
+ if (eventType === "error.triggered") {
869
+ const errorPayload = payload && typeof payload === "object" ? payload : void 0;
870
+ const payloadMessage = errorPayload && typeof errorPayload.message === "string" ? errorPayload.message : void 0;
871
+ const payloadCode = errorPayload && typeof errorPayload.code === "string" ? errorPayload.code : void 0;
872
+ this.callbacks.onError?.({
873
+ message: payloadMessage || (typeof payload === "string" ? payload : "Embedded event reported an error"),
874
+ code: payloadCode,
875
+ details: eventData
876
+ });
877
+ return;
878
+ }
879
+ this.callbacks.onEvent?.({
880
+ name: eventType,
881
+ payload
882
+ });
883
+ }
884
+ handleResponse(data) {
885
+ const pendingRequest = this.pendingRequests.get(data.requestId);
886
+ if (pendingRequest) {
887
+ const { resolve, reject } = pendingRequest;
888
+ this.pendingRequests.delete(data.requestId);
889
+ if (data.success === false || data.error) {
890
+ const error = {
891
+ message: data.error || "Request failed",
892
+ code: data.errorCode,
893
+ details: data.errorDetails
894
+ };
895
+ this.callbacks.onError?.(error);
896
+ reject(error);
897
+ } else {
898
+ resolve(data);
899
+ }
900
+ }
901
+ }
902
+ destroy() {
903
+ if (this.messageListener) {
904
+ window.removeEventListener("message", this.messageListener);
905
+ this.messageListener = null;
906
+ }
907
+ this.pendingRequests.clear();
908
+ }
909
+ /**
910
+ * Update callbacks after construction
911
+ */
912
+ updateCallbacks(callbacks) {
913
+ this.callbacks = { ...this.callbacks, ...callbacks };
914
+ }
915
+ /**
916
+ * Whether the iframe has signaled it is ready to receive postMessages
917
+ */
918
+ get ready() {
919
+ return this.isReady;
920
+ }
921
+ /**
922
+ * The protocol version reported by the iframe in its 'embedded.ready' event,
923
+ * or null if the version was not included in the ready payload.
924
+ */
925
+ get protocolVersion() {
926
+ return this._protocolVersion;
927
+ }
928
+ /**
929
+ * Wait for the iframe to signal readiness via the 'embedded.ready' event.
930
+ * @param timeout - Optional timeout in milliseconds (default: 30000ms)
931
+ */
932
+ async waitForReady(timeout = 3e4) {
933
+ if (this.isReady) {
934
+ return Promise.resolve();
935
+ }
936
+ return new Promise((resolve, reject) => {
937
+ let timeoutId = null;
938
+ let readyListener = () => {
939
+ };
940
+ function cleanup() {
941
+ if (timeoutId !== null) {
942
+ clearTimeout(timeoutId);
943
+ }
944
+ window.removeEventListener("message", readyListener);
945
+ }
946
+ readyListener = (event) => {
947
+ if (event.source === this.iframe.contentWindow && event.origin === this.getTrustedOrigin() && event.data?.type === "CORTI_EMBEDDED_EVENT" && event.data.event === "embedded.ready") {
948
+ cleanup();
949
+ resolve();
950
+ }
951
+ };
952
+ timeoutId = setTimeout(() => {
953
+ cleanup();
954
+ reject(new Error("Timeout waiting for iframe to be ready"));
955
+ }, timeout);
956
+ window.addEventListener("message", readyListener);
957
+ });
958
+ }
959
+ /**
960
+ * Sends a postMessage to the iframe and returns a Promise that resolves with the response.
961
+ * @param message - The message to send
962
+ * @param timeout - Optional timeout in milliseconds. Defaults to the requestTimeout set at construction.
963
+ */
964
+ async postMessage(message, timeout) {
965
+ if (!this.iframe.contentWindow) {
966
+ throw new Error("Iframe not ready");
967
+ }
968
+ await this.waitForReady();
969
+ const { contentWindow } = this.iframe;
970
+ const requestId = _PostMessageHandler.generateRequestId();
971
+ const effectiveTimeout = timeout ?? this.requestTimeout;
972
+ return new Promise((resolve, reject) => {
973
+ const timeoutId = setTimeout(() => {
974
+ this.pendingRequests.delete(requestId);
975
+ reject(new Error("Request timeout"));
976
+ }, effectiveTimeout);
977
+ this.pendingRequests.set(requestId, {
978
+ resolve: (value) => {
979
+ clearTimeout(timeoutId);
980
+ resolve(value);
981
+ },
982
+ reject: (reason) => {
983
+ clearTimeout(timeoutId);
984
+ reject(reason);
985
+ }
986
+ });
987
+ const fullMessage = {
988
+ ...message,
989
+ requestId
990
+ };
991
+ const targetOrigin = this.getTrustedOrigin();
992
+ if (!targetOrigin) {
993
+ this.pendingRequests.delete(requestId);
994
+ reject(new Error("Cannot determine trusted origin for postMessage"));
995
+ return;
996
+ }
997
+ contentWindow.postMessage(fullMessage, targetOrigin);
998
+ });
999
+ }
1000
+ static generateRequestId() {
1001
+ return `req_${Date.now()}_${Math.random().toString(36).substring(2, 9)}`;
1002
+ }
1003
+ /**
1004
+ * Derive the trusted origin from the iframe src (constructed from baseURL).
1005
+ * Returns null if it cannot be determined.
1006
+ */
1007
+ getTrustedOrigin() {
1008
+ try {
1009
+ const src = this.iframe.getAttribute("src") || this.iframe.src;
1010
+ if (!src)
1011
+ return null;
1012
+ const url = new URL(src, window.location.href);
1013
+ return url.origin;
1014
+ } catch {
1015
+ return null;
1016
+ }
1017
+ }
1018
+ };
1019
+ PostMessageHandler.SUPPORTED_PROTOCOL_VERSION = "v1";
1020
+
1021
+ // dist/CortiEmbedded.js
1022
+ var __decorate = function(decorators, target, key, desc) {
1023
+ var c4 = arguments.length, r5 = c4 < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d3;
1024
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r5 = Reflect.decorate(decorators, target, key, desc);
1025
+ else for (var i5 = decorators.length - 1; i5 >= 0; i5--) if (d3 = decorators[i5]) r5 = (c4 < 3 ? d3(r5) : c4 > 3 ? d3(target, key, r5) : d3(target, key)) || r5;
1026
+ return c4 > 3 && r5 && Object.defineProperty(target, key, r5), r5;
1027
+ };
1028
+ var IFRAME_SANDBOX_POLICY = "allow-forms allow-modals allow-scripts allow-same-origin";
1029
+ var CortiEmbedded = class extends i4 {
1030
+ constructor() {
1031
+ super(...arguments);
1032
+ this.visibility = "hidden";
1033
+ this.postMessageHandler = null;
1034
+ this.normalizedBaseURL = null;
1035
+ }
1036
+ // eslint-disable-next-line class-methods-use-this
1037
+ getIframeAllowPolicy(normalizedBaseURL) {
1038
+ const permissionTarget = normalizedBaseURL ? new URL(normalizedBaseURL).origin : "*";
1039
+ return [
1040
+ `microphone ${permissionTarget}`,
1041
+ `camera ${permissionTarget}`,
1042
+ `device-capture ${permissionTarget}`,
1043
+ `display-capture ${permissionTarget}`,
1044
+ `clipboard-write ${permissionTarget}`
1045
+ ].join("; ");
1046
+ }
1047
+ connectedCallback() {
1048
+ super.connectedCallback();
1049
+ if (!this.baseURL) {
1050
+ this.dispatchErrorEvent({
1051
+ message: "baseURL is required"
1052
+ });
1053
+ return;
1054
+ }
1055
+ try {
1056
+ this.normalizedBaseURL = validateAndNormalizeBaseURL(this.baseURL);
1057
+ } catch (error) {
1058
+ this.dispatchErrorEvent({
1059
+ message: error.message || "Invalid baseURL"
1060
+ });
1061
+ }
1062
+ }
1063
+ disconnectedCallback() {
1064
+ super.disconnectedCallback();
1065
+ if (this.postMessageHandler) {
1066
+ this.postMessageHandler.destroy();
1067
+ this.postMessageHandler = null;
1068
+ }
1069
+ }
1070
+ async setupPostMessageHandler() {
1071
+ if (this.postMessageHandler) {
1072
+ return;
1073
+ }
1074
+ const iframe = this.getIframe();
1075
+ if (iframe?.contentWindow) {
1076
+ const callbacks = {
1077
+ onEvent: (event) => {
1078
+ this.dispatchEmbeddedEvent(event.name, event.payload);
1079
+ },
1080
+ onError: (error) => {
1081
+ this.dispatchErrorEvent(error);
1082
+ }
1083
+ };
1084
+ this.postMessageHandler = new PostMessageHandler(iframe, callbacks);
1085
+ } else {
1086
+ this.dispatchErrorEvent({
1087
+ message: "No iframe or contentWindow available"
1088
+ });
1089
+ }
1090
+ }
1091
+ dispatchPublicEvent(event, data) {
1092
+ this.dispatchEvent(new CustomEvent(event, { detail: data }));
1093
+ }
1094
+ dispatchEmbeddedEvent(rawEventName, payload) {
1095
+ if (rawEventName === "ready" || rawEventName === "loaded")
1096
+ return;
1097
+ this.dispatchPublicEvent(rawEventName, payload);
1098
+ this.dispatchPublicEvent("event", {
1099
+ name: rawEventName,
1100
+ payload
1101
+ });
1102
+ this.dispatchPublicEvent("embedded-event", {
1103
+ name: rawEventName,
1104
+ payload
1105
+ });
1106
+ }
1107
+ dispatchErrorEvent(error) {
1108
+ this.dispatchPublicEvent("error", error);
1109
+ }
1110
+ isRealIframeLoad(iframe) {
1111
+ const src = iframe.getAttribute("src") || "";
1112
+ if (!this.normalizedBaseURL)
1113
+ return false;
1114
+ return isRealEmbeddedLoad(src, this.normalizedBaseURL);
1115
+ }
1116
+ async handleIframeLoad(event) {
1117
+ const iframe = event.target;
1118
+ if (!iframe) {
1119
+ return;
1120
+ }
1121
+ if (!this.isRealIframeLoad(iframe)) {
1122
+ return;
1123
+ }
1124
+ try {
1125
+ await this.setupPostMessageHandler();
1126
+ } catch (error) {
1127
+ this.dispatchErrorEvent({
1128
+ message: `Failed to setup PostMessageHandler on iframe load: ${error}`
1129
+ });
1130
+ }
1131
+ }
1132
+ getIframe() {
1133
+ return this.shadowRoot?.querySelector("iframe") || null;
1134
+ }
1135
+ updated(changedProps) {
1136
+ super.updated(changedProps);
1137
+ if (changedProps.has("baseURL")) {
1138
+ if (this.postMessageHandler) {
1139
+ this.postMessageHandler.destroy();
1140
+ this.postMessageHandler = null;
1141
+ }
1142
+ try {
1143
+ this.normalizedBaseURL = validateAndNormalizeBaseURL(this.baseURL);
1144
+ } catch (error) {
1145
+ this.normalizedBaseURL = null;
1146
+ const iframe2 = this.getIframe();
1147
+ if (iframe2) {
1148
+ iframe2.setAttribute("src", "about:blank");
1149
+ }
1150
+ this.dispatchErrorEvent({
1151
+ message: error.message || "Invalid baseURL"
1152
+ });
1153
+ return;
1154
+ }
1155
+ const iframe = this.getIframe();
1156
+ if (iframe) {
1157
+ const expected = buildEmbeddedUrl(this.normalizedBaseURL);
1158
+ iframe.setAttribute("allow", this.getIframeAllowPolicy(expected));
1159
+ if (iframe.getAttribute("src") !== expected) {
1160
+ iframe.setAttribute("src", expected);
1161
+ }
1162
+ }
1163
+ }
1164
+ }
1165
+ // Public API Implementation
1166
+ /**
1167
+ * Authenticate with the Corti system
1168
+ * @param credentials Authentication credentials
1169
+ * @returns Promise resolving to user information
1170
+ */
1171
+ async auth(credentials) {
1172
+ if (!this.postMessageHandler) {
1173
+ throw new Error("Component not ready");
1174
+ }
1175
+ try {
1176
+ const payload = {
1177
+ access_token: credentials.access_token,
1178
+ token_type: credentials.token_type,
1179
+ expires_at: credentials.expires_at,
1180
+ expires_in: credentials.expires_in,
1181
+ refresh_expires_in: credentials.refresh_expires_in,
1182
+ refresh_token: credentials.refresh_token,
1183
+ id_token: credentials.id_token,
1184
+ "not-before-policy": credentials["not-before-policy"],
1185
+ session_state: credentials.session_state,
1186
+ scope: credentials.scope,
1187
+ profile: credentials.profile
1188
+ };
1189
+ const response = await this.postMessageHandler.postMessage({
1190
+ type: "CORTI_EMBEDDED",
1191
+ version: "v1",
1192
+ action: "auth",
1193
+ payload
1194
+ });
1195
+ if (response.success && response.payload) {
1196
+ return response.payload.user;
1197
+ }
1198
+ throw new Error(response.error);
1199
+ } catch (error) {
1200
+ const formattedError = formatError(error, "Authentication failed");
1201
+ throw new Error(JSON.stringify(formattedError));
1202
+ }
1203
+ }
1204
+ /**
1205
+ * Create a new interaction
1206
+ * @param encounter Encounter request data
1207
+ * @returns Promise resolving to interaction details
1208
+ */
1209
+ async createInteraction(encounter) {
1210
+ if (!this.postMessageHandler) {
1211
+ throw new Error("Component not ready");
1212
+ }
1213
+ try {
1214
+ const response = await this.postMessageHandler.postMessage({
1215
+ type: "CORTI_EMBEDDED",
1216
+ version: "v1",
1217
+ action: "createInteraction",
1218
+ payload: encounter
1219
+ });
1220
+ if (response.success && response.payload) {
1221
+ const result = response.payload;
1222
+ return {
1223
+ id: result.id,
1224
+ createdAt: result.createdAt
1225
+ };
1226
+ }
1227
+ throw new Error(response.error);
1228
+ } catch (error) {
1229
+ const formattedError = formatError(error, "Failed to create interaction");
1230
+ throw new Error(JSON.stringify(formattedError));
1231
+ }
1232
+ }
1233
+ /**
1234
+ * Configure the current session
1235
+ * @param config Session configuration
1236
+ * @returns Promise that resolves when configuration is complete
1237
+ */
1238
+ async configureSession(config) {
1239
+ if (!this.postMessageHandler) {
1240
+ throw new Error("Component not ready");
1241
+ }
1242
+ try {
1243
+ const payload = {
1244
+ defaultLanguage: config.defaultLanguage,
1245
+ defaultOutputLanguage: config.defaultOutputLanguage,
1246
+ defaultTemplateKey: config.defaultTemplateKey,
1247
+ defaultMode: config.defaultMode
1248
+ };
1249
+ await this.postMessageHandler.postMessage({
1250
+ type: "CORTI_EMBEDDED",
1251
+ version: "v1",
1252
+ action: "configureSession",
1253
+ payload
1254
+ });
1255
+ } catch (error) {
1256
+ const formattedError = formatError(error, "Failed to configure session");
1257
+ throw new Error(JSON.stringify(formattedError));
1258
+ }
1259
+ }
1260
+ /**
1261
+ * Add facts to the current session
1262
+ * @param facts Array of facts to add
1263
+ * @returns Promise that resolves when facts are added
1264
+ */
1265
+ async addFacts(facts) {
1266
+ if (!this.postMessageHandler) {
1267
+ throw new Error("Component not ready");
1268
+ }
1269
+ try {
1270
+ const payload = { facts };
1271
+ await this.postMessageHandler.postMessage({
1272
+ type: "CORTI_EMBEDDED",
1273
+ version: "v1",
1274
+ action: "addFacts",
1275
+ payload
1276
+ });
1277
+ } catch (error) {
1278
+ const formattedError = formatError(error, "Failed to add facts");
1279
+ throw new Error(JSON.stringify(formattedError));
1280
+ }
1281
+ }
1282
+ /**
1283
+ * Navigate to a specific path within the embedded UI
1284
+ * @param path Path to navigate to
1285
+ * @returns Promise that resolves when navigation is complete
1286
+ */
1287
+ async navigate(path) {
1288
+ if (!this.postMessageHandler) {
1289
+ throw new Error("Component not ready");
1290
+ }
1291
+ try {
1292
+ const payload = { path };
1293
+ await this.postMessageHandler.postMessage({
1294
+ type: "CORTI_EMBEDDED",
1295
+ version: "v1",
1296
+ action: "navigate",
1297
+ payload
1298
+ });
1299
+ } catch (error) {
1300
+ const formattedError = formatError(error, "Failed to navigate");
1301
+ throw new Error(JSON.stringify(formattedError));
1302
+ }
1303
+ }
1304
+ /**
1305
+ * Start recording
1306
+ * @returns Promise that resolves when recording starts
1307
+ */
1308
+ async startRecording() {
1309
+ if (!this.postMessageHandler) {
1310
+ throw new Error("Component not ready");
1311
+ }
1312
+ try {
1313
+ await this.postMessageHandler.postMessage({
1314
+ type: "CORTI_EMBEDDED",
1315
+ version: "v1",
1316
+ action: "startRecording",
1317
+ payload: {}
1318
+ });
1319
+ } catch (error) {
1320
+ const formattedError = formatError(error, "Failed to start recording");
1321
+ throw new Error(JSON.stringify(formattedError));
1322
+ }
1323
+ }
1324
+ /**
1325
+ * Stop recording
1326
+ * @returns Promise that resolves when recording stops
1327
+ */
1328
+ async stopRecording() {
1329
+ if (!this.postMessageHandler) {
1330
+ throw new Error("Component not ready");
1331
+ }
1332
+ try {
1333
+ await this.postMessageHandler.postMessage({
1334
+ type: "CORTI_EMBEDDED",
1335
+ version: "v1",
1336
+ action: "stopRecording",
1337
+ payload: {}
1338
+ });
1339
+ } catch (error) {
1340
+ const formattedError = formatError(error, "Failed to stop recording");
1341
+ throw new Error(JSON.stringify(formattedError));
1342
+ }
1343
+ }
1344
+ /**
1345
+ * Get current component status
1346
+ * @returns Promise resolving to current status
1347
+ */
1348
+ async getStatus() {
1349
+ if (!this.postMessageHandler) {
1350
+ return {
1351
+ auth: {
1352
+ isAuthenticated: false,
1353
+ user: void 0
1354
+ },
1355
+ currentUrl: "",
1356
+ interaction: null
1357
+ };
1358
+ }
1359
+ try {
1360
+ const response = await this.postMessageHandler.postMessage({
1361
+ type: "CORTI_EMBEDDED",
1362
+ version: "v1",
1363
+ action: "getStatus",
1364
+ payload: {}
1365
+ });
1366
+ if (response.success && response.payload) {
1367
+ return response.payload;
1368
+ }
1369
+ throw new Error(response.error);
1370
+ } catch (error) {
1371
+ const formattedError = formatError(error, "Failed to get status");
1372
+ throw new Error(JSON.stringify(formattedError));
1373
+ }
1374
+ }
1375
+ /**
1376
+ * Configure the component
1377
+ * @param config Component configuration
1378
+ * @returns Promise that resolves when configuration is applied
1379
+ */
1380
+ async configure(config) {
1381
+ if (!this.postMessageHandler) {
1382
+ throw new Error("Component not ready");
1383
+ }
1384
+ try {
1385
+ const response = await this.postMessageHandler.postMessage({
1386
+ type: "CORTI_EMBEDDED",
1387
+ version: "v1",
1388
+ action: "configure",
1389
+ payload: config
1390
+ });
1391
+ if (response.success && response.payload) {
1392
+ return response.payload;
1393
+ }
1394
+ throw new Error(response.error);
1395
+ } catch (error) {
1396
+ const formattedError = formatError(error, "Failed to configure component");
1397
+ throw new Error(JSON.stringify(formattedError));
1398
+ }
1399
+ }
1400
+ /**
1401
+ * Set authentication credentials without triggering auth flow
1402
+ * @param credentials Authentication credentials to store
1403
+ * @returns Promise that resolves when credentials are set
1404
+ */
1405
+ async setCredentials(credentials) {
1406
+ if (!this.postMessageHandler) {
1407
+ throw new Error("Component not ready");
1408
+ }
1409
+ try {
1410
+ if (!credentials.password) {
1411
+ throw new Error("Password is required");
1412
+ }
1413
+ await this.postMessageHandler.postMessage({
1414
+ type: "CORTI_EMBEDDED",
1415
+ version: "v1",
1416
+ action: "setCredentials",
1417
+ payload: credentials
1418
+ });
1419
+ } catch (error) {
1420
+ const formattedError = formatError(error, "Failed to set credentials");
1421
+ throw new Error(JSON.stringify(formattedError));
1422
+ }
1423
+ }
1424
+ /**
1425
+ * Show the embedded UI
1426
+ */
1427
+ show() {
1428
+ this.visibility = "visible";
1429
+ }
1430
+ /**
1431
+ * Hide the embedded UI
1432
+ */
1433
+ hide() {
1434
+ this.visibility = "hidden";
1435
+ }
1436
+ /**
1437
+ * Get templates
1438
+ */
1439
+ async getTemplates() {
1440
+ if (!this.postMessageHandler) {
1441
+ throw new Error("Component not ready");
1442
+ }
1443
+ try {
1444
+ const response = await this.postMessageHandler.postMessage({
1445
+ type: "CORTI_EMBEDDED",
1446
+ version: "v1",
1447
+ action: "getTemplates"
1448
+ });
1449
+ if (response.success && response.payload) {
1450
+ return response.payload;
1451
+ }
1452
+ throw new Error(response.error);
1453
+ } catch (error) {
1454
+ const formattedError = formatError(error, "Failed to get templates");
1455
+ throw new Error(JSON.stringify(formattedError));
1456
+ }
1457
+ }
1458
+ /**
1459
+ * Check the current status of the iframe and PostMessageHandler
1460
+ * Useful for debugging
1461
+ * @deprecated Use getStatus() instead
1462
+ */
1463
+ getDebugStatus() {
1464
+ const iframe = this.getIframe();
1465
+ return {
1466
+ ready: iframe?.contentDocument?.readyState === "complete",
1467
+ iframeExists: !!iframe,
1468
+ iframeSrc: iframe?.src,
1469
+ iframeContentWindow: !!iframe?.contentWindow,
1470
+ iframeContentDocument: !!iframe?.contentDocument,
1471
+ iframeReadyState: iframe?.contentDocument?.readyState,
1472
+ postMessageHandlerExists: !!this.postMessageHandler,
1473
+ postMessageHandlerReady: this.postMessageHandler?.ready || false,
1474
+ baseURL: this.baseURL
1475
+ };
1476
+ }
1477
+ render() {
1478
+ if (!this.normalizedBaseURL) {
1479
+ return x``;
1480
+ }
1481
+ return x`
39
1482
  <iframe
40
- src=${ot(j(this.baseURL))}
1483
+ src=${buildEmbeddedUrl(this.normalizedBaseURL)}
41
1484
  title="Corti Embedded UI"
42
- sandbox=${"allow-forms allow-modals allow-scripts allow-same-origin"}
43
- allow="microphone *; camera *; device-capture *; display-capture *"
44
- @load=${t=>this.handleIframeLoad(t)}
45
- @unload=${()=>this.postMessageHandler?.destroy()}
46
- style=${this.visibility==="hidden"?"display: none;":"display: block;"}
1485
+ sandbox=${IFRAME_SANDBOX_POLICY}
1486
+ allow=${this.getIframeAllowPolicy(this.normalizedBaseURL)}
1487
+ @load=${(event) => this.handleIframeLoad(event)}
1488
+ @unload=${() => this.postMessageHandler?.destroy()}
1489
+ style=${this.visibility === "hidden" ? "display: none;" : "display: block;"}
47
1490
  ></iframe>
48
- `:rt`<div>baseURL is required</div>`}};$.styles=[At,St];Mt([B({type:String,reflect:!0})],$.prototype,"visibility",void 0);Mt([B({type:String,reflect:!0})],$.prototype,"baseURL",void 0);customElements.get("corti-embedded")||customElements.define("corti-embedded",$);export{$ as CortiEmbedded};
1491
+ `;
1492
+ }
1493
+ };
1494
+ CortiEmbedded.styles = [baseStyles, containerStyles];
1495
+ __decorate([
1496
+ n4({ type: String, reflect: true })
1497
+ ], CortiEmbedded.prototype, "visibility", void 0);
1498
+ __decorate([
1499
+ n4({ type: String, reflect: true })
1500
+ ], CortiEmbedded.prototype, "baseURL", void 0);
1501
+
1502
+ // dist/corti-embedded.js
1503
+ if (!customElements.get("corti-embedded")) {
1504
+ customElements.define("corti-embedded", CortiEmbedded);
1505
+ }
1506
+ export {
1507
+ CortiEmbedded
1508
+ };
49
1509
  /*! Bundled license information:
50
1510
 
51
1511
  @lit/reactive-element/css-tag.js: