@overturo/js 1.5.1 → 1.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/field/index.cjs +5 -1
- package/dist/field/index.cjs.map +1 -1
- package/dist/field/index.d.cts +3 -1
- package/dist/field/index.d.ts +3 -1
- package/dist/field/index.js +5 -1
- package/dist/field/index.js.map +1 -1
- package/dist/index.cjs +5 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/dist/overturo-field.global.js +1 -1
- package/dist/overturo.global.js +1 -1
- package/package.json +1 -1
package/dist/overturo.global.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var Overturo=(()=>{var Ke=Object.defineProperty;var lr=Object.getOwnPropertyDescriptor;var pr=Object.getOwnPropertyNames;var ur=Object.prototype.hasOwnProperty;var lt=s=>{throw TypeError(s)};var pt=(s,e)=>()=>{try{return e||s((e={exports:{}}).exports,e),e.exports}catch(o){throw e=0,o}},cr=(s,e)=>{for(var o in e)Ke(s,o,{get:e[o],enumerable:!0})},mr=(s,e,o,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let d of pr(e))!ur.call(s,d)&&d!==o&&Ke(s,d,{get:()=>e[d],enumerable:!(a=lr(e,d))||a.enumerable});return s};var fr=s=>mr(Ke({},"__esModule",{value:!0}),s);var Be=(s,e,o)=>e.has(s)||lt("Cannot "+o);var u=(s,e,o)=>(Be(s,e,"read from private field"),o?o.call(s):e.get(s)),h=(s,e,o)=>e.has(s)?lt("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(s):e.set(s,o),g=(s,e,o,a)=>(Be(s,e,"write to private field"),a?a.call(s,o):e.set(s,o),o),E=(s,e,o)=>(Be(s,e,"access private method"),o);var R=pt(x=>{"use strict";Object.defineProperty(x,"__esModule",{value:!0});x.formatNames=x.fastFormats=x.fullFormats=void 0;function q(s,e){return{validate:s,compare:e}}x.fullFormats={date:q(Et,et),time:q(Je(!0),tt),"date-time":q(bt(!0),At),"iso-time":q(Je(),Pt),"iso-date-time":q(bt(),Tt),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:jr,"uri-reference":/^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,"uri-template":/^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i,url:/^(?:https?|ftp):\/\/(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)(?:\.(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu,email:/^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i,hostname:/^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i,ipv4:/^(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)$/,ipv6:/^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/i,regex:Kr,uuid:/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,"json-pointer":/^(?:\/(?:[^~/]|~0|~1)*)*$/,"json-pointer-uri-fragment":/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,"relative-json-pointer":/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,byte:Nr,int32:{type:"number",validate:Ur},int64:{type:"number",validate:Vr},float:{type:"number",validate:kt},double:{type:"number",validate:kt},password:!0,binary:!0};x.fastFormats={...x.fullFormats,date:q(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,et),time:q(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,tt),"date-time":q(/^\d\d\d\d-[0-1]\d-[0-3]\dt(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,At),"iso-time":q(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,Pt),"iso-date-time":q(/^\d\d\d\d-[0-1]\d-[0-3]\d[t\s](?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,Tt),uri:/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/)?[^\s]*$/i,"uri-reference":/^(?:(?:[a-z][a-z0-9+\-.]*:)?\/?\/)?(?:[^\\\s#][^\s#]*)?(?:#[^\\\s]*)?$/i,email:/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/i};x.formatNames=Object.keys(x.fullFormats);function Rr(s){return s%4===0&&(s%100!==0||s%400===0)}var Ir=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,Mr=[0,31,28,31,30,31,30,31,31,30,31,30,31];function Et(s){let e=Ir.exec(s);if(!e)return!1;let o=+e[1],a=+e[2],d=+e[3];return a>=1&&a<=12&&d>=1&&d<=(a===2&&Rr(o)?29:Mr[a])}function et(s,e){if(s&&e)return s>e?1:s<e?-1:0}var Xe=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function Je(s){return function(o){let a=Xe.exec(o);if(!a)return!1;let d=+a[1],p=+a[2],t=+a[3],i=a[4],l=a[5]==="-"?-1:1,r=+(a[6]||0),n=+(a[7]||0);if(r>23||n>59||s&&!i)return!1;if(d<=23&&p<=59&&t<60)return!0;let m=p-n*l,y=d-r*l-(m<0?1:0);return(y===23||y===-1)&&(m===59||m===-1)&&t<61}}function tt(s,e){if(!(s&&e))return;let o=new Date("2020-01-01T"+s).valueOf(),a=new Date("2020-01-01T"+e).valueOf();if(o&&a)return o-a}function Pt(s,e){if(!(s&&e))return;let o=Xe.exec(s),a=Xe.exec(e);if(o&&a)return s=o[1]+o[2]+o[3],e=a[1]+a[2]+a[3],s>e?1:s<e?-1:0}var Qe=/t|\s/i;function bt(s){let e=Je(s);return function(a){let d=a.split(Qe);return d.length===2&&Et(d[0])&&e(d[1])}}function At(s,e){if(!(s&&e))return;let o=new Date(s).valueOf(),a=new Date(e).valueOf();if(o&&a)return o-a}function Tt(s,e){if(!(s&&e))return;let[o,a]=s.split(Qe),[d,p]=e.split(Qe),t=et(o,d);if(t!==void 0)return t||tt(a,p)}var $r=/\/|:/,Lr=/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;function jr(s){return $r.test(s)&&Lr.test(s)}var _t=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function Nr(s){return _t.lastIndex=0,_t.test(s)}var Fr=-(2**31),Hr=2**31-1;function Ur(s){return Number.isInteger(s)&&s<=Hr&&s>=Fr}function Vr(s){return Number.isInteger(s)}function kt(){return!0}var zr=/[^\\]\\Z/;function Kr(s){if(zr.test(s))return!1;try{return new RegExp(s),!0}catch{return!1}}});var Dt=pt(rt=>{"use strict";Object.defineProperty(rt,"__esModule",{value:!0});function xt(s){let e=s.length,o=0,a=0,d;for(;a<e;)o++,d=s.charCodeAt(a++),d>=55296&&d<=56319&&a<e&&(d=s.charCodeAt(a),(d&64512)===56320&&a++);return o}rt.default=xt;xt.code='require("ajv/dist/runtime/ucs2length").default'});var fs={};cr(fs,{ALREADY_DEFINED_CODE:()=>ze,DecisionElement:()=>z,ELEMENT_NAME:()=>J,OapAuthorizationDenied:()=>te,OapDenied:()=>U,OapIntentDenied:()=>re,OapSequenceDenied:()=>se,OapTrajectoryDenied:()=>Y,Overturo:()=>de,OverturoApiError:()=>b,OverturoError:()=>P,OverturoNetworkError:()=>F,OverturoTimeoutError:()=>H,OverturoValidationError:()=>c,createSetupEmbed:()=>Fe,createSetupPopup:()=>He,default:()=>de,registerDecisionElement:()=>pe,setupRedirect:()=>Ue});var f={READY:"overturo:ready",STATE:"overturo:state",COMPLETE:"overturo:complete",CANCEL:"overturo:cancel",ERROR:"overturo:error",RESIZE:"overturo:resize",DEADLINE:"overturo:deadline"},N={width:"100%",minHeight:"400px",maxHeight:"none",border:"none",borderRadius:"0",background:"transparent"},ut=Object.keys(N),B={width:500,height:700},T={READY:"overturoid:ready",RESIZE:"overturoid:resize",STEP:"overturoid:setup:step",CREATED:"overturoid:setup:created",CANCEL:"overturoid:cancel",ERROR:"overturoid:error",PING:"overturoid:ping",HEARTBEAT:"overturoid:heartbeat"},Ye={width:600,height:800},ue="/api/v1/consent_sessions",D="/api/v1/decisions",ct="/decisions",Ge="/api/v1/meeting_consents",mt="/api/v1/accord_setup_sessions",We="/api/v1/preview_tokens",ft="https://overturo.com",yr="overturo:";function ee(s){let e=s?.type;return typeof e=="string"&&!e.startsWith(yr)}var yt=3e4,ce="overturo-consent-field";var P=class extends Error{constructor(e){super(e),this.name="OverturoError"}},c=class extends P{constructor(e){super(e),this.name="OverturoValidationError"}},b=class extends P{constructor(e,o,a){super(e),this.name="OverturoApiError",this.status=o,this.body=a}},F=class extends P{constructor(e,o){super(e),this.name="OverturoNetworkError",this.cause=o}},H=class extends P{constructor(e="Operation timed out"){super(e),this.name="OverturoTimeoutError"}},U=class s extends b{constructor(e,o,a){super(e.message,o,a),this.name="OapDenied",this.reason_code=e.reason_code,this.failed_bound=e.failed_bound,this.denial_category=e.denial_category,this.cascade_step=e.cascade_step,this.detail=e.detail}static fromEnvelope(e,o,a){if(e.reason_code==="sequence_prohibited"||e.reason_code==="sequence_missing_predecessor")return new se(e,o,a);switch(e.denial_category){case"authorization_denied":return new te(e,o,a);case"intent_denied":return new re(e,o,a);case"trajectory_denied":return new Y(e,o,a);default:return new s(e,o,a)}}},te=class extends U{constructor(e,o,a){super(e,o,a),this.name="OapAuthorizationDenied"}},re=class extends U{constructor(e,o,a){super(e,o,a),this.name="OapIntentDenied"}},Y=class extends U{constructor(e,o,a){super(e,o,a),this.name="OapTrajectoryDenied"}},se=class extends Y{constructor(e,o,a){super(e,o,a),this.name="OapSequenceDenied"}};function ye(s,e){if(s&&typeof s=="object"){let o=s.error;if(typeof o=="string"&&o.length>0)return o;if(o&&typeof o=="object"){let d=o;if(typeof d.message=="string"&&d.message.length>0)return typeof d.code=="string"&&d.code.length>0?`${d.code}: ${d.message}`:d.message;if(d.errors&&typeof d.errors=="object"){let p=Object.keys(d.errors)[0];if(p){let t=d.errors[p],i=Array.isArray(t)?t[0]:t;if(typeof i=="string")return`${typeof d.code=="string"&&d.code.length>0?`${d.code}: `:""}${p} ${i}`}}if(typeof d.code=="string"&&d.code.length>0)return d.code}let a=s.message;if(typeof a=="string"&&a.length>0)return a}return`HTTP ${e}`}function hr(s){return s.replace(/[A-Z]/g,e=>`_${e.toLowerCase()}`)}function gr(s){return s.replace(/_([a-z])/g,(e,o)=>o.toUpperCase())}function me(s){if(Array.isArray(s))return s.map(me);if(s!==null&&typeof s=="object"){let e={};for(let[o,a]of Object.entries(s))e[hr(o)]=me(a);return e}return s}function G(s){if(Array.isArray(s))return s.map(G);if(s!==null&&typeof s=="object"){let e={};for(let[o,a]of Object.entries(s))e[gr(o)]=G(a);return e}return s}var fe=class{constructor(e){this.baseUrl=e.baseUrl,this.publishableKey=e.publishableKey,this.apiKey=e.apiKey,this.timeout=e.timeout??yt}async get(e){return this.request("GET",e)}async post(e,o){return this.request("POST",e,o)}async rawGet(e){return this.rawRequest("GET",e)}async rawPost(e,o){return this.rawRequest("POST",e,o)}async rawRequest(e,o,a){let d=`${this.baseUrl}${o}`,p={"Content-Type":"application/json","X-Publishable-Key":this.publishableKey};this.apiKey&&(p.Authorization=`Bearer ${this.apiKey}`);let t=new AbortController,i;this.timeout>0&&(i=setTimeout(()=>t.abort(),this.timeout));try{return await fetch(d,{method:e,headers:p,body:a===void 0?void 0:JSON.stringify(me(a)),signal:t.signal})}catch(l){throw l instanceof DOMException&&l.name==="AbortError"?new H(`Request timed out after ${this.timeout}ms`):new F("Network request failed",l)}finally{i!==void 0&&clearTimeout(i)}}async request(e,o,a){let d=`${this.baseUrl}${o}`,p={"Content-Type":"application/json","X-Publishable-Key":this.publishableKey};this.apiKey&&(p.Authorization=`Bearer ${this.apiKey}`);let t=new AbortController,i;this.timeout>0&&(i=setTimeout(()=>t.abort(),this.timeout));let l;try{l=await fetch(d,{method:e,headers:p,body:a?JSON.stringify(me(a)):void 0,signal:t.signal})}catch(n){throw n instanceof DOMException&&n.name==="AbortError"?new H(`Request timed out after ${this.timeout}ms`):new F("Network request failed",n)}finally{i!==void 0&&clearTimeout(i)}if(!l.ok){let n;try{n=await l.json()}catch{n=null}let m=ye(n,l.status);throw new b(m,l.status,n)}let r=await l.text();return r?G(JSON.parse(r)):{}}};var C,ne,he=class{constructor(e,o){h(this,C);h(this,ne);g(this,C,e),g(this,ne,o)}async open(e){if(!e.escalationId)throw new c("escalationId is required");let o=e.mode??"embed",a=await u(this,C).createSession({kind:"approval",subjectRef:e.escalationId,mode:o,embedOrigin:e.embedOrigin,state:e.state,redirectUri:e.redirectUri});if(o==="popup")return u(this,C).popup({token:a.token,onComplete:d=>{d.kind==="approval"&&e.onComplete?.(d)},onCancel:e.onCancel,onError:e.onError});if(o==="redirect"){let d=u(this,C).url({token:a.token,mode:"redirect"});return window.location.href=d,{token:a.token,mode:"redirect",destroy:async()=>{}}}return u(this,C).embed({token:a.token,container:e.container,style:e.style,loading:e.loading,onReady:e.onReady,onState:(d,p)=>e.onState?.(p),onComplete:d=>{d.kind==="approval"&&e.onComplete?.(d)},onCancel:e.onCancel,onError:e.onError,onDeadline:e.onDeadline,onCounter:e.onCounter})}url(e){return u(this,C).url({token:e.escalationId,mode:e.mode})}async deadline(e){if(!e)throw new c("token is required for deadline");let o=await u(this,ne).get(`${D}/${e}`);return{remainingMs:Math.max(0,new Date(o.deadlineAt).getTime()-Date.now()),deadlineAt:o.deadlineAt}}};C=new WeakMap,ne=new WeakMap;var S,ge=class{constructor(e){h(this,S);g(this,S,e)}async open(e){if(!e.flowId)throw new c("flowId is required");let o=e.mode??"embed",a=await u(this,S).createSession({kind:"consent",subjectRef:e.flowId,mode:o,embedOrigin:e.embedOrigin,scope:e.scope,state:e.state,nonce:e.nonce,redirectUri:e.redirectUri});if(o==="popup")return u(this,S).popup({token:a.token,onComplete:d=>{d.kind==="consent"&&e.onComplete?.(d)},onCancel:e.onCancel,onError:e.onError});if(o==="redirect"){let d=u(this,S).url({token:a.token,mode:"redirect"});return window.location.href=d,{token:a.token,mode:"redirect",destroy:async()=>{}}}return u(this,S).embed({token:a.token,container:e.container,style:e.style,loading:e.loading,onReady:e.onReady,onState:(d,p)=>e.onStep?.(p),onComplete:d=>{d.kind==="consent"&&e.onComplete?.(d)},onCancel:e.onCancel,onError:e.onError})}url(e){return u(this,S).url({token:e.flowId,mode:e.mode})}discover(e){return u(this,S).discover(e)}};S=new WeakMap;var vr="overturo_capture_token",ve="overturoCaptured",wr=5e3,Ze=new WeakMap;function ht(s,e,o){if(Ze.has(s))throw new c("duplicate_attach: this form already has a capture interception; detach it before attaching again");Ze.set(s,!0);let a=!1,d=e.tokenFieldName??vr,p=t=>{if(s.dataset[ve]==="1"){delete s.dataset[ve];return}if(t.preventDefault(),t.stopImmediatePropagation(),a)return;a=!0,s.querySelector(`input[name="${d}"]`)?.remove();let i=t.submitter??null;(async()=>{try{let{token:l}=await br(o({submitter:i}),wr);kr(s,d,l)}catch(l){e.onError?.(l)}finally{a=!1,e.submitAfterCapture!==!1&&(s.dataset[ve]="1",_r(s,i))}})()};return s.addEventListener("submit",p,{capture:!0}),()=>{Ze.delete(s),s.removeEventListener("submit",p,{capture:!0}),delete s.dataset[ve],s.querySelector(`input[name="${d}"]`)?.remove()}}function br(s,e){return new Promise((o,a)=>{let d=setTimeout(()=>a(new c(`capture timed out after ${e} ms; the form submits without a capture token`)),e);s.then(p=>{clearTimeout(d),o(p)},p=>{clearTimeout(d),a(p)})})}function _r(s,e){if(e&&e.isConnected&&typeof s.requestSubmit=="function")try{s.requestSubmit(e);return}catch{}typeof s.requestSubmit=="function"?s.requestSubmit():e&&typeof e.click=="function"?e.click():s.submit()}function gt(s){let e=typeof s=="string"?document.querySelector(s):s;if(!(e instanceof HTMLFormElement))throw new c("form must resolve to a <form> element");return e}function kr(s,e,o){let a=s.querySelector(`input[name="${e}"]`);a||(a=document.createElement("input"),a.type="hidden",a.name=e,s.appendChild(a)),a.value=o}function W(s,e){let o=s.querySelector(e);return o instanceof HTMLInputElement?o:null}function Er(s,e){return!s||s.type!=="checkbox"&&s.type!=="radio"?{decision:"declined",default_checked:!1,mandatory:!1}:{decision:s.checked?"granted":"declined",default_checked:s.defaultChecked||e===!0,mandatory:Pr(s)}}function Pr(s){if(!s.required)return!1;if(s.type!=="radio"||!s.name)return!0;let e=s.form??s.ownerDocument;return Array.from(e.querySelectorAll('input[type="radio"]')).filter(a=>a.name===s.name).length<=1}function vt(s,e,o={}){let a={};for(let[d,p]of Object.entries(e))a[d]=Er(W(s,p),o[d]);return a}var Ar="input, textarea, select",Tr=/^on/i,Sr=new Set(["title","aria-label","aria-description"]);function wt(s,e){let o=s.cloneNode(!0),a=new Set;for(let p of e){let t=o.querySelector(p);t&&a.add(t)}o.querySelectorAll("script, style, iframe, object, embed").forEach(p=>p.remove()),[o,...Array.from(o.querySelectorAll("*"))].forEach(p=>{for(let t of Array.from(p.attributes)){let i=t.name.toLowerCase();(Tr.test(i)||i==="srcdoc"||i.startsWith("data-")||Sr.has(i))&&p.removeAttribute(t.name)}}),o.querySelectorAll(Ar).forEach(p=>{let t=p;if(a.has(t)){let i=t;i.checked?i.setAttribute("checked",""):i.removeAttribute("checked"),t.removeAttribute("value");return}t.removeAttribute("value"),t.removeAttribute("placeholder"),t instanceof HTMLTextAreaElement&&(t.textContent=""),t instanceof HTMLSelectElement&&t.querySelectorAll("option").forEach(i=>{i.removeAttribute("selected"),i.removeAttribute("value")}),t instanceof HTMLInputElement&&(t.removeAttribute("checked"),t.type==="hidden"&&t.remove())});let d=o.outerHTML;return qr(d,16384)}function qr(s,e){let o=new TextEncoder;if(o.encode(s).byteLength<=e)return s;let a=s;for(;o.encode(a).byteLength>e;)a=a.slice(0,Math.floor(a.length*.9));return a}var xr="/api/v1/decisions/capture",we=class{constructor(e,o,a,d){this.api=e;this.decisions=o;this.flowBaseUrl=a;this.publishableKey=d}attach(e){if(!e.flowId)throw new c("flowId is required");let o=gt(e.form);if(e.field)return this.attachField(o,e);let a=e.map;if(!a||Object.keys(a).length===0)throw new c("map must name at least one purpose (or pass field)");let d=Cr(o,a);return e.wording&&this.writeWording(o,e),ht(o,e,async()=>{let p=Object.entries(a).filter(([,n])=>!W(o,n));if(p.length)throw new c(`consent control not found for: ${p.map(([n])=>n).join(", ")}`);let t=this.buildCaptureBody(o,e,d),i=await this.labelDigests(o,e);i&&(t.noticeHashes=i);let l=await this.api.post(xr,t),r={token:l.capture.sessionToken,attestationId:l.capture.attestationId,committed:l.capture.committed,wordingVerdict:l.capture.wordingVerdict??null,recordId:l.capture.recordId??null};return e.onCaptured?.(r),{token:r.token}})}attachField(e,o){let a=Or(e,o.field),d=a.getAttribute("flow");if(d&&d!==o.flowId)throw new c("the field's flow attribute must match flowId");if(Array.from(e.querySelectorAll(ce)).some(t=>t!==a&&(t.getAttribute("flow")||o.flowId)===o.flowId))throw new c("duplicate_field: one consent field per flow per form");return a.attachTo(e,o,{flowBaseUrl:this.flowBaseUrl,publishableKey:this.publishableKey})}buildCaptureBody(e,o,a={}){let d=W(e,o.subjectField),p=o.externalIdField?W(e,o.externalIdField):null,t=o.map??{},i={flowId:o.flowId,decisions:vt(e,t,a),subject:{email:d?.value?.trim()||void 0,externalId:p?.value?.trim()||void 0},snapshot:wt(e,Object.values(t)),pageUrl:typeof window<"u"?window.location.href:void 0,formId:e.getAttribute("id")||void 0};return o.commit&&(i.commit=!0),o.locale&&(i.locale=o.locale),i}async labelDigests(e,o){let a=o.labels??o.wording;if(!a||typeof crypto>"u"||!crypto.subtle)return;let d={};for(let[p,t]of Object.entries(a)){let i=e.querySelector(t)?.textContent?.trim();if(!i)continue;let l=await crypto.subtle.digest("SHA-256",new TextEncoder().encode(i));d[p]=Array.from(new Uint8Array(l)).map(r=>r.toString(16).padStart(2,"0")).join("")}return Object.keys(d).length?d:void 0}async writeWording(e,o){if(o.wording)try{let a=await this.decisions.discover({flowId:o.flowId,locale:o.locale});for(let[d,p]of Object.entries(o.wording)){let t=e.querySelector(p),i=a.purposes.find(l=>l.name===d);t&&i&&Dr(t,i.description??i.label)}}catch(a){o.onError?.(a)}}};function Dr(s,e){let o=Array.from(s.childNodes).filter(a=>a.nodeType===Node.TEXT_NODE);if(o.length===0||s.children.length===0){s.children.length===0?s.textContent=e:s.appendChild(document.createTextNode(" "+e));return}o.forEach((a,d)=>{a.textContent=d===0?e:""})}function Cr(s,e){let o={};for(let[a,d]of Object.entries(e)){let p=W(s,d);p&&(o[a]=p.checked)}return o}function Or(s,e){let o=typeof e=="string"?s.querySelector(e)||document.querySelector(e):e;if(!(o instanceof HTMLElement)||o.tagName.toLowerCase()!==ce)throw new c(`field must resolve to an <${ce}> element`);if(typeof o.attachTo!="function")throw new c("field_entry_not_loaded: load @overturo/js/field (overturo-field.js) before attaching a field");return o}var O,oe,be=class{constructor(e,o){h(this,O);h(this,oe);g(this,O,e),g(this,oe,o)}async open(e){if(!e.signatureRef)throw new c("signatureRef is required");let o=e.mode??"embed",a=await u(this,O).createSession({kind:"signature_request",subjectRef:e.signatureRef,mode:o,embedOrigin:e.embedOrigin,state:e.state,redirectUri:e.redirectUri});if(o==="popup")return u(this,O).popup({token:a.token,onComplete:d=>{d.kind==="signature_request"&&e.onComplete?.(d)},onCancel:e.onCancel,onError:e.onError});if(o==="redirect"){let d=u(this,O).url({token:a.token,mode:"redirect"});return window.location.href=d,{token:a.token,mode:"redirect",destroy:async()=>{}}}return u(this,O).embed({token:a.token,container:e.container,style:e.style,loading:e.loading,onReady:e.onReady,onState:(d,p)=>e.onState?.(p),onComplete:d=>{d.kind==="signature_request"&&e.onComplete?.(d)},onCancel:e.onCancel,onError:e.onError,onDeadline:e.onDeadline,onCounter:e.onCounter})}url(e){return u(this,O).url({token:e.signatureRef,mode:e.mode})}async deadline(e){if(!e)throw new c("token is required for deadline");let o=await u(this,oe).get(`${D}/${e}`);return{remainingMs:Math.max(0,new Date(o.deadlineAt).getTime()-Date.now()),deadlineAt:o.deadlineAt}}};O=new WeakMap,oe=new WeakMap;function Z(s){if(typeof s=="string"){let e=document.querySelector(s);if(!e)throw new c(`Container element not found: "${s}"`);return e}return s}function X(s,e,o){let a={...e};if(o)for(let d of ut)d in o&&(a[d]=o[d]);for(let[d,p]of Object.entries(a))s.style[d]=p}var qt=_e,St={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://schemas.overturo.com/postmessage-v2/envelope.json",title:"TrustSurface postMessage envelope v2",type:"object",additionalProperties:!1,required:["type","kind","version","payload","ts","message_id"],properties:{type:{type:"string",enum:["overturo:ready","overturo:state","overturo:complete","overturo:cancel","overturo:error","overturo:resize","overturo:deadline"]},kind:{type:"string",enum:["consent","approval","signature_request"]},version:{type:"integer",const:2},payload:{type:"object",additionalProperties:!0},ts:{type:"string",format:"date-time"},message_id:{type:"string",pattern:"^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"}}},Br=R().fullFormats["date-time"],Yr=new RegExp("^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$","u");function _e(s,{instancePath:e="",parentData:o,parentDataProperty:a,rootData:d=s,dynamicAnchors:p={}}={}){let t=null,i=0,l=_e.evaluated;if(l.dynamicProps&&(l.props=void 0),l.dynamicItems&&(l.items=void 0),s&&typeof s=="object"&&!Array.isArray(s)){if(s.type===void 0){let r={instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:"type"},message:"must have required property 'type'"};t===null?t=[r]:t.push(r),i++}if(s.kind===void 0){let r={instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:"kind"},message:"must have required property 'kind'"};t===null?t=[r]:t.push(r),i++}if(s.version===void 0){let r={instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:"version"},message:"must have required property 'version'"};t===null?t=[r]:t.push(r),i++}if(s.payload===void 0){let r={instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:"payload"},message:"must have required property 'payload'"};t===null?t=[r]:t.push(r),i++}if(s.ts===void 0){let r={instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:"ts"},message:"must have required property 'ts'"};t===null?t=[r]:t.push(r),i++}if(s.message_id===void 0){let r={instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:"message_id"},message:"must have required property 'message_id'"};t===null?t=[r]:t.push(r),i++}for(let r in s)if(!(r==="type"||r==="kind"||r==="version"||r==="payload"||r==="ts"||r==="message_id")){let n={instancePath:e,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:r},message:"must NOT have additional properties"};t===null?t=[n]:t.push(n),i++}if(s.type!==void 0){let r=s.type;if(typeof r!="string"){let n={instancePath:e+"/type",schemaPath:"#/properties/type/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[n]:t.push(n),i++}if(!(r==="overturo:ready"||r==="overturo:state"||r==="overturo:complete"||r==="overturo:cancel"||r==="overturo:error"||r==="overturo:resize"||r==="overturo:deadline")){let n={instancePath:e+"/type",schemaPath:"#/properties/type/enum",keyword:"enum",params:{allowedValues:St.properties.type.enum},message:"must be equal to one of the allowed values"};t===null?t=[n]:t.push(n),i++}}if(s.kind!==void 0){let r=s.kind;if(typeof r!="string"){let n={instancePath:e+"/kind",schemaPath:"#/properties/kind/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[n]:t.push(n),i++}if(!(r==="consent"||r==="approval"||r==="signature_request")){let n={instancePath:e+"/kind",schemaPath:"#/properties/kind/enum",keyword:"enum",params:{allowedValues:St.properties.kind.enum},message:"must be equal to one of the allowed values"};t===null?t=[n]:t.push(n),i++}}if(s.version!==void 0){let r=s.version;if(!(typeof r=="number"&&!(r%1)&&!isNaN(r))){let n={instancePath:e+"/version",schemaPath:"#/properties/version/type",keyword:"type",params:{type:"integer"},message:"must be integer"};t===null?t=[n]:t.push(n),i++}if(r!==2){let n={instancePath:e+"/version",schemaPath:"#/properties/version/const",keyword:"const",params:{allowedValue:2},message:"must be equal to constant"};t===null?t=[n]:t.push(n),i++}}if(s.payload!==void 0){let r=s.payload;if(!(r&&typeof r=="object"&&!Array.isArray(r))){let n={instancePath:e+"/payload",schemaPath:"#/properties/payload/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[n]:t.push(n),i++}}if(s.ts!==void 0){let r=s.ts;if(typeof r=="string"){if(!Br.validate(r)){let n={instancePath:e+"/ts",schemaPath:"#/properties/ts/format",keyword:"format",params:{format:"date-time"},message:'must match format "date-time"'};t===null?t=[n]:t.push(n),i++}}else{let n={instancePath:e+"/ts",schemaPath:"#/properties/ts/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[n]:t.push(n),i++}}if(s.message_id!==void 0){let r=s.message_id;if(typeof r=="string"){if(!Yr.test(r)){let n={instancePath:e+"/message_id",schemaPath:"#/properties/message_id/pattern",keyword:"pattern",params:{pattern:"^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"},message:'must match pattern "^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"'};t===null?t=[n]:t.push(n),i++}}else{let n={instancePath:e+"/message_id",schemaPath:"#/properties/message_id/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[n]:t.push(n),i++}}}else{let r={instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[r]:t.push(r),i++}return _e.errors=t,i===0}_e.evaluated={props:!0,dynamicProps:!1,dynamicItems:!1};var Ot=ke,ie={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://schemas.overturo.com/postmessage-v2/ready.json",title:"READY payload (kind-agnostic; branding fields vary per application)",type:"object",additionalProperties:!0,required:["kind","session_token","deadline_at","branding","mode","locale"],properties:{kind:{type:"string",enum:["consent","approval","signature_request"]},session_token:{type:"string",minLength:43,maxLength:43},deadline_at:{type:["string","null"],format:"date-time"},branding:{type:"object",additionalProperties:!0,required:["application_name"],properties:{application_name:{type:"string"},logo_url:{type:["string","null"]},primary_color:{type:["string","null"]}}},mode:{type:"string",enum:["embed","popup","redirect"]},locale:{type:"string"}}},Ct=Dt().default,Gr=R().fullFormats["date-time"];function ke(s,{instancePath:e="",parentData:o,parentDataProperty:a,rootData:d=s,dynamicAnchors:p={}}={}){let t=null,i=0,l=ke.evaluated;if(l.dynamicProps&&(l.props=void 0),l.dynamicItems&&(l.items=void 0),s&&typeof s=="object"&&!Array.isArray(s)){if(s.kind===void 0){let r={instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:"kind"},message:"must have required property 'kind'"};t===null?t=[r]:t.push(r),i++}if(s.session_token===void 0){let r={instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:"session_token"},message:"must have required property 'session_token'"};t===null?t=[r]:t.push(r),i++}if(s.deadline_at===void 0){let r={instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:"deadline_at"},message:"must have required property 'deadline_at'"};t===null?t=[r]:t.push(r),i++}if(s.branding===void 0){let r={instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:"branding"},message:"must have required property 'branding'"};t===null?t=[r]:t.push(r),i++}if(s.mode===void 0){let r={instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:"mode"},message:"must have required property 'mode'"};t===null?t=[r]:t.push(r),i++}if(s.locale===void 0){let r={instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:"locale"},message:"must have required property 'locale'"};t===null?t=[r]:t.push(r),i++}if(s.kind!==void 0){let r=s.kind;if(typeof r!="string"){let n={instancePath:e+"/kind",schemaPath:"#/properties/kind/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[n]:t.push(n),i++}if(!(r==="consent"||r==="approval"||r==="signature_request")){let n={instancePath:e+"/kind",schemaPath:"#/properties/kind/enum",keyword:"enum",params:{allowedValues:ie.properties.kind.enum},message:"must be equal to one of the allowed values"};t===null?t=[n]:t.push(n),i++}}if(s.session_token!==void 0){let r=s.session_token;if(typeof r=="string"){if(Ct(r)>43){let n={instancePath:e+"/session_token",schemaPath:"#/properties/session_token/maxLength",keyword:"maxLength",params:{limit:43},message:"must NOT have more than 43 characters"};t===null?t=[n]:t.push(n),i++}if(Ct(r)<43){let n={instancePath:e+"/session_token",schemaPath:"#/properties/session_token/minLength",keyword:"minLength",params:{limit:43},message:"must NOT have fewer than 43 characters"};t===null?t=[n]:t.push(n),i++}}else{let n={instancePath:e+"/session_token",schemaPath:"#/properties/session_token/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[n]:t.push(n),i++}}if(s.deadline_at!==void 0){let r=s.deadline_at;if(typeof r!="string"&&r!==null){let n={instancePath:e+"/deadline_at",schemaPath:"#/properties/deadline_at/type",keyword:"type",params:{type:ie.properties.deadline_at.type},message:"must be string,null"};t===null?t=[n]:t.push(n),i++}if(typeof r=="string"&&!Gr.validate(r)){let n={instancePath:e+"/deadline_at",schemaPath:"#/properties/deadline_at/format",keyword:"format",params:{format:"date-time"},message:'must match format "date-time"'};t===null?t=[n]:t.push(n),i++}}if(s.branding!==void 0){let r=s.branding;if(r&&typeof r=="object"&&!Array.isArray(r)){if(r.application_name===void 0){let n={instancePath:e+"/branding",schemaPath:"#/properties/branding/required",keyword:"required",params:{missingProperty:"application_name"},message:"must have required property 'application_name'"};t===null?t=[n]:t.push(n),i++}if(r.application_name!==void 0&&typeof r.application_name!="string"){let n={instancePath:e+"/branding/application_name",schemaPath:"#/properties/branding/properties/application_name/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[n]:t.push(n),i++}if(r.logo_url!==void 0){let n=r.logo_url;if(typeof n!="string"&&n!==null){let m={instancePath:e+"/branding/logo_url",schemaPath:"#/properties/branding/properties/logo_url/type",keyword:"type",params:{type:ie.properties.branding.properties.logo_url.type},message:"must be string,null"};t===null?t=[m]:t.push(m),i++}}if(r.primary_color!==void 0){let n=r.primary_color;if(typeof n!="string"&&n!==null){let m={instancePath:e+"/branding/primary_color",schemaPath:"#/properties/branding/properties/primary_color/type",keyword:"type",params:{type:ie.properties.branding.properties.primary_color.type},message:"must be string,null"};t===null?t=[m]:t.push(m),i++}}}else{let n={instancePath:e+"/branding",schemaPath:"#/properties/branding/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[n]:t.push(n),i++}}if(s.mode!==void 0){let r=s.mode;if(typeof r!="string"){let n={instancePath:e+"/mode",schemaPath:"#/properties/mode/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[n]:t.push(n),i++}if(!(r==="embed"||r==="popup"||r==="redirect")){let n={instancePath:e+"/mode",schemaPath:"#/properties/mode/enum",keyword:"enum",params:{allowedValues:ie.properties.mode.enum},message:"must be equal to one of the allowed values"};t===null?t=[n]:t.push(n),i++}}if(s.locale!==void 0&&typeof s.locale!="string"){let r={instancePath:e+"/locale",schemaPath:"#/properties/locale/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[r]:t.push(r),i++}}else{let r={instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[r]:t.push(r),i++}return ke.errors=t,i===0}ke.evaluated={props:!0,dynamicProps:!1,dynamicItems:!1};var Rt=Ee;function Ee(s,{instancePath:e="",parentData:o,parentDataProperty:a,rootData:d=s,dynamicAnchors:p={}}={}){let t=null,i=0,l=Ee.evaluated;if(l.dynamicProps&&(l.props=void 0),l.dynamicItems&&(l.items=void 0),s&&typeof s=="object"&&!Array.isArray(s)){if(s.height===void 0){let r={instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:"height"},message:"must have required property 'height'"};t===null?t=[r]:t.push(r),i++}if(s.height!==void 0){let r=s.height;if(!(typeof r=="number"&&!(r%1)&&!isNaN(r))){let n={instancePath:e+"/height",schemaPath:"#/properties/height/type",keyword:"type",params:{type:"integer"},message:"must be integer"};t===null?t=[n]:t.push(n),i++}if(typeof r=="number"&&(r<0||isNaN(r))){let n={instancePath:e+"/height",schemaPath:"#/properties/height/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};t===null?t=[n]:t.push(n),i++}}}else{let r={instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[r]:t.push(r),i++}return Ee.errors=t,i===0}Ee.evaluated={props:!0,dynamicProps:!1,dynamicItems:!1};var Mt=Pe,It={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://schemas.overturo.com/postmessage-v2/cancel.json",title:"CANCEL payload (kind-agnostic \u2014 bidirectional)",type:"object",additionalProperties:!0,required:["reason","cancelled_by"],properties:{reason:{type:"string",enum:["user_declined","principal_navigated_away","host_requested","system_revoked"]},cancelled_by:{type:"string",enum:["principal","host","system"]}}};function Pe(s,{instancePath:e="",parentData:o,parentDataProperty:a,rootData:d=s,dynamicAnchors:p={}}={}){let t=null,i=0,l=Pe.evaluated;if(l.dynamicProps&&(l.props=void 0),l.dynamicItems&&(l.items=void 0),s&&typeof s=="object"&&!Array.isArray(s)){if(s.reason===void 0){let r={instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:"reason"},message:"must have required property 'reason'"};t===null?t=[r]:t.push(r),i++}if(s.cancelled_by===void 0){let r={instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:"cancelled_by"},message:"must have required property 'cancelled_by'"};t===null?t=[r]:t.push(r),i++}if(s.reason!==void 0){let r=s.reason;if(typeof r!="string"){let n={instancePath:e+"/reason",schemaPath:"#/properties/reason/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[n]:t.push(n),i++}if(!(r==="user_declined"||r==="principal_navigated_away"||r==="host_requested"||r==="system_revoked")){let n={instancePath:e+"/reason",schemaPath:"#/properties/reason/enum",keyword:"enum",params:{allowedValues:It.properties.reason.enum},message:"must be equal to one of the allowed values"};t===null?t=[n]:t.push(n),i++}}if(s.cancelled_by!==void 0){let r=s.cancelled_by;if(typeof r!="string"){let n={instancePath:e+"/cancelled_by",schemaPath:"#/properties/cancelled_by/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[n]:t.push(n),i++}if(!(r==="principal"||r==="host"||r==="system")){let n={instancePath:e+"/cancelled_by",schemaPath:"#/properties/cancelled_by/enum",keyword:"enum",params:{allowedValues:It.properties.cancelled_by.enum},message:"must be equal to one of the allowed values"};t===null?t=[n]:t.push(n),i++}}}else{let r={instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[r]:t.push(r),i++}return Pe.errors=t,i===0}Pe.evaluated={props:!0,dynamicProps:!1,dynamicItems:!1};var $t=Ae,Wr={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://schemas.overturo.com/postmessage-v2/consent/state.json",title:"consent STATE payload",type:"object",additionalProperties:!0,required:["from","to","step_index","total_steps"],properties:{from:{type:["string","null"]},to:{type:"string"},step_index:{type:"integer",minimum:0},total_steps:{type:"integer",minimum:1},kind_payload:{type:"object",additionalProperties:!0}}};function Ae(s,{instancePath:e="",parentData:o,parentDataProperty:a,rootData:d=s,dynamicAnchors:p={}}={}){let t=null,i=0,l=Ae.evaluated;if(l.dynamicProps&&(l.props=void 0),l.dynamicItems&&(l.items=void 0),s&&typeof s=="object"&&!Array.isArray(s)){if(s.from===void 0){let r={instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:"from"},message:"must have required property 'from'"};t===null?t=[r]:t.push(r),i++}if(s.to===void 0){let r={instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:"to"},message:"must have required property 'to'"};t===null?t=[r]:t.push(r),i++}if(s.step_index===void 0){let r={instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:"step_index"},message:"must have required property 'step_index'"};t===null?t=[r]:t.push(r),i++}if(s.total_steps===void 0){let r={instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:"total_steps"},message:"must have required property 'total_steps'"};t===null?t=[r]:t.push(r),i++}if(s.from!==void 0){let r=s.from;if(typeof r!="string"&&r!==null){let n={instancePath:e+"/from",schemaPath:"#/properties/from/type",keyword:"type",params:{type:Wr.properties.from.type},message:"must be string,null"};t===null?t=[n]:t.push(n),i++}}if(s.to!==void 0&&typeof s.to!="string"){let r={instancePath:e+"/to",schemaPath:"#/properties/to/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[r]:t.push(r),i++}if(s.step_index!==void 0){let r=s.step_index;if(!(typeof r=="number"&&!(r%1)&&!isNaN(r))){let n={instancePath:e+"/step_index",schemaPath:"#/properties/step_index/type",keyword:"type",params:{type:"integer"},message:"must be integer"};t===null?t=[n]:t.push(n),i++}if(typeof r=="number"&&(r<0||isNaN(r))){let n={instancePath:e+"/step_index",schemaPath:"#/properties/step_index/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};t===null?t=[n]:t.push(n),i++}}if(s.total_steps!==void 0){let r=s.total_steps;if(!(typeof r=="number"&&!(r%1)&&!isNaN(r))){let n={instancePath:e+"/total_steps",schemaPath:"#/properties/total_steps/type",keyword:"type",params:{type:"integer"},message:"must be integer"};t===null?t=[n]:t.push(n),i++}if(typeof r=="number"&&(r<1||isNaN(r))){let n={instancePath:e+"/total_steps",schemaPath:"#/properties/total_steps/minimum",keyword:"minimum",params:{comparison:">=",limit:1},message:"must be >= 1"};t===null?t=[n]:t.push(n),i++}}if(s.kind_payload!==void 0){let r=s.kind_payload;if(!(r&&typeof r=="object"&&!Array.isArray(r))){let n={instancePath:e+"/kind_payload",schemaPath:"#/properties/kind_payload/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[n]:t.push(n),i++}}}else{let r={instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[r]:t.push(r),i++}return Ae.errors=t,i===0}Ae.evaluated={props:!0,dynamicProps:!1,dynamicItems:!1};var jt=Te,Lt={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://schemas.overturo.com/postmessage-v2/consent/complete.json",title:"consent COMPLETE payload",type:"object",additionalProperties:!0,required:["outcome","completed_at"],properties:{outcome:{type:"string",enum:["granted","declined"]},exchange_token:{type:["string","null"],description:"Consent token the host exchanges via POST /api/v1/decisions/:token/exchange"},completed_at:{type:"string",format:"date-time"}}},Zr=R().fullFormats["date-time"];function Te(s,{instancePath:e="",parentData:o,parentDataProperty:a,rootData:d=s,dynamicAnchors:p={}}={}){let t=null,i=0,l=Te.evaluated;if(l.dynamicProps&&(l.props=void 0),l.dynamicItems&&(l.items=void 0),s&&typeof s=="object"&&!Array.isArray(s)){if(s.outcome===void 0){let r={instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:"outcome"},message:"must have required property 'outcome'"};t===null?t=[r]:t.push(r),i++}if(s.completed_at===void 0){let r={instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:"completed_at"},message:"must have required property 'completed_at'"};t===null?t=[r]:t.push(r),i++}if(s.outcome!==void 0){let r=s.outcome;if(typeof r!="string"){let n={instancePath:e+"/outcome",schemaPath:"#/properties/outcome/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[n]:t.push(n),i++}if(!(r==="granted"||r==="declined")){let n={instancePath:e+"/outcome",schemaPath:"#/properties/outcome/enum",keyword:"enum",params:{allowedValues:Lt.properties.outcome.enum},message:"must be equal to one of the allowed values"};t===null?t=[n]:t.push(n),i++}}if(s.exchange_token!==void 0){let r=s.exchange_token;if(typeof r!="string"&&r!==null){let n={instancePath:e+"/exchange_token",schemaPath:"#/properties/exchange_token/type",keyword:"type",params:{type:Lt.properties.exchange_token.type},message:"must be string,null"};t===null?t=[n]:t.push(n),i++}}if(s.completed_at!==void 0){let r=s.completed_at;if(typeof r=="string"){if(!Zr.validate(r)){let n={instancePath:e+"/completed_at",schemaPath:"#/properties/completed_at/format",keyword:"format",params:{format:"date-time"},message:'must match format "date-time"'};t===null?t=[n]:t.push(n),i++}}else{let n={instancePath:e+"/completed_at",schemaPath:"#/properties/completed_at/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[n]:t.push(n),i++}}}else{let r={instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[r]:t.push(r),i++}return Te.errors=t,i===0}Te.evaluated={props:!0,dynamicProps:!1,dynamicItems:!1};var Ft=Se,Nt={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://schemas.overturo.com/postmessage-v2/consent/error.json",title:"consent ERROR payload",type:"object",additionalProperties:!0,required:["code","message","fatal"],properties:{code:{type:"string"},message:{type:"string"},fatal:{type:"boolean"},recoverable_via:{type:["string","null"],enum:["reload","new_session",null]}}};function Se(s,{instancePath:e="",parentData:o,parentDataProperty:a,rootData:d=s,dynamicAnchors:p={}}={}){let t=null,i=0,l=Se.evaluated;if(l.dynamicProps&&(l.props=void 0),l.dynamicItems&&(l.items=void 0),s&&typeof s=="object"&&!Array.isArray(s)){if(s.code===void 0){let r={instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:"code"},message:"must have required property 'code'"};t===null?t=[r]:t.push(r),i++}if(s.message===void 0){let r={instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:"message"},message:"must have required property 'message'"};t===null?t=[r]:t.push(r),i++}if(s.fatal===void 0){let r={instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:"fatal"},message:"must have required property 'fatal'"};t===null?t=[r]:t.push(r),i++}if(s.code!==void 0&&typeof s.code!="string"){let r={instancePath:e+"/code",schemaPath:"#/properties/code/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[r]:t.push(r),i++}if(s.message!==void 0&&typeof s.message!="string"){let r={instancePath:e+"/message",schemaPath:"#/properties/message/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[r]:t.push(r),i++}if(s.fatal!==void 0&&typeof s.fatal!="boolean"){let r={instancePath:e+"/fatal",schemaPath:"#/properties/fatal/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};t===null?t=[r]:t.push(r),i++}if(s.recoverable_via!==void 0){let r=s.recoverable_via;if(typeof r!="string"&&r!==null){let n={instancePath:e+"/recoverable_via",schemaPath:"#/properties/recoverable_via/type",keyword:"type",params:{type:Nt.properties.recoverable_via.type},message:"must be string,null"};t===null?t=[n]:t.push(n),i++}if(!(r==="reload"||r==="new_session"||r===null)){let n={instancePath:e+"/recoverable_via",schemaPath:"#/properties/recoverable_via/enum",keyword:"enum",params:{allowedValues:Nt.properties.recoverable_via.enum},message:"must be equal to one of the allowed values"};t===null?t=[n]:t.push(n),i++}}}else{let r={instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[r]:t.push(r),i++}return Se.errors=t,i===0}Se.evaluated={props:!0,dynamicProps:!1,dynamicItems:!1};var Ht=qe,Xr={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://schemas.overturo.com/postmessage-v2/consent/deadline.json",title:"consent DEADLINE payload",type:"object",additionalProperties:!0,required:["remaining_seconds","level","deadline_at"],properties:{remaining_seconds:{type:"integer",minimum:0},level:{type:"string",enum:["warning","expired"]},deadline_at:{type:"string",format:"date-time"}}},Jr=R().fullFormats["date-time"];function qe(s,{instancePath:e="",parentData:o,parentDataProperty:a,rootData:d=s,dynamicAnchors:p={}}={}){let t=null,i=0,l=qe.evaluated;if(l.dynamicProps&&(l.props=void 0),l.dynamicItems&&(l.items=void 0),s&&typeof s=="object"&&!Array.isArray(s)){if(s.remaining_seconds===void 0){let r={instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:"remaining_seconds"},message:"must have required property 'remaining_seconds'"};t===null?t=[r]:t.push(r),i++}if(s.level===void 0){let r={instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:"level"},message:"must have required property 'level'"};t===null?t=[r]:t.push(r),i++}if(s.deadline_at===void 0){let r={instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:"deadline_at"},message:"must have required property 'deadline_at'"};t===null?t=[r]:t.push(r),i++}if(s.remaining_seconds!==void 0){let r=s.remaining_seconds;if(!(typeof r=="number"&&!(r%1)&&!isNaN(r))){let n={instancePath:e+"/remaining_seconds",schemaPath:"#/properties/remaining_seconds/type",keyword:"type",params:{type:"integer"},message:"must be integer"};t===null?t=[n]:t.push(n),i++}if(typeof r=="number"&&(r<0||isNaN(r))){let n={instancePath:e+"/remaining_seconds",schemaPath:"#/properties/remaining_seconds/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};t===null?t=[n]:t.push(n),i++}}if(s.level!==void 0){let r=s.level;if(typeof r!="string"){let n={instancePath:e+"/level",schemaPath:"#/properties/level/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[n]:t.push(n),i++}if(!(r==="warning"||r==="expired")){let n={instancePath:e+"/level",schemaPath:"#/properties/level/enum",keyword:"enum",params:{allowedValues:Xr.properties.level.enum},message:"must be equal to one of the allowed values"};t===null?t=[n]:t.push(n),i++}}if(s.deadline_at!==void 0){let r=s.deadline_at;if(typeof r=="string"){if(!Jr.validate(r)){let n={instancePath:e+"/deadline_at",schemaPath:"#/properties/deadline_at/format",keyword:"format",params:{format:"date-time"},message:'must match format "date-time"'};t===null?t=[n]:t.push(n),i++}}else{let n={instancePath:e+"/deadline_at",schemaPath:"#/properties/deadline_at/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[n]:t.push(n),i++}}}else{let r={instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[r]:t.push(r),i++}return qe.errors=t,i===0}qe.evaluated={props:!0,dynamicProps:!1,dynamicItems:!1};var Ut=xe,st={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://schemas.overturo.com/postmessage-v2/approval/state.json",title:"approval STATE payload",type:"object",additionalProperties:!0,required:["from","to","kind_payload"],properties:{from:{type:["string","null"]},to:{type:"string",enum:["pending","opened","in_progress","approved","denied","expired"]},kind_payload:{type:"object",additionalProperties:!0,required:["agent_id","action_class","scope_invoked"],properties:{agent_id:{type:"string"},action_class:{type:"string"},bounded_authority:{type:"object",additionalProperties:!0},scope_invoked:{type:"string"},value_invoked:{type:["object","null"],additionalProperties:!0}}}}};function xe(s,{instancePath:e="",parentData:o,parentDataProperty:a,rootData:d=s,dynamicAnchors:p={}}={}){let t=null,i=0,l=xe.evaluated;if(l.dynamicProps&&(l.props=void 0),l.dynamicItems&&(l.items=void 0),s&&typeof s=="object"&&!Array.isArray(s)){if(s.from===void 0){let r={instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:"from"},message:"must have required property 'from'"};t===null?t=[r]:t.push(r),i++}if(s.to===void 0){let r={instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:"to"},message:"must have required property 'to'"};t===null?t=[r]:t.push(r),i++}if(s.kind_payload===void 0){let r={instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:"kind_payload"},message:"must have required property 'kind_payload'"};t===null?t=[r]:t.push(r),i++}if(s.from!==void 0){let r=s.from;if(typeof r!="string"&&r!==null){let n={instancePath:e+"/from",schemaPath:"#/properties/from/type",keyword:"type",params:{type:st.properties.from.type},message:"must be string,null"};t===null?t=[n]:t.push(n),i++}}if(s.to!==void 0){let r=s.to;if(typeof r!="string"){let n={instancePath:e+"/to",schemaPath:"#/properties/to/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[n]:t.push(n),i++}if(!(r==="pending"||r==="opened"||r==="in_progress"||r==="approved"||r==="denied"||r==="expired")){let n={instancePath:e+"/to",schemaPath:"#/properties/to/enum",keyword:"enum",params:{allowedValues:st.properties.to.enum},message:"must be equal to one of the allowed values"};t===null?t=[n]:t.push(n),i++}}if(s.kind_payload!==void 0){let r=s.kind_payload;if(r&&typeof r=="object"&&!Array.isArray(r)){if(r.agent_id===void 0){let n={instancePath:e+"/kind_payload",schemaPath:"#/properties/kind_payload/required",keyword:"required",params:{missingProperty:"agent_id"},message:"must have required property 'agent_id'"};t===null?t=[n]:t.push(n),i++}if(r.action_class===void 0){let n={instancePath:e+"/kind_payload",schemaPath:"#/properties/kind_payload/required",keyword:"required",params:{missingProperty:"action_class"},message:"must have required property 'action_class'"};t===null?t=[n]:t.push(n),i++}if(r.scope_invoked===void 0){let n={instancePath:e+"/kind_payload",schemaPath:"#/properties/kind_payload/required",keyword:"required",params:{missingProperty:"scope_invoked"},message:"must have required property 'scope_invoked'"};t===null?t=[n]:t.push(n),i++}if(r.agent_id!==void 0&&typeof r.agent_id!="string"){let n={instancePath:e+"/kind_payload/agent_id",schemaPath:"#/properties/kind_payload/properties/agent_id/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[n]:t.push(n),i++}if(r.action_class!==void 0&&typeof r.action_class!="string"){let n={instancePath:e+"/kind_payload/action_class",schemaPath:"#/properties/kind_payload/properties/action_class/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[n]:t.push(n),i++}if(r.bounded_authority!==void 0){let n=r.bounded_authority;if(!(n&&typeof n=="object"&&!Array.isArray(n))){let m={instancePath:e+"/kind_payload/bounded_authority",schemaPath:"#/properties/kind_payload/properties/bounded_authority/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[m]:t.push(m),i++}}if(r.scope_invoked!==void 0&&typeof r.scope_invoked!="string"){let n={instancePath:e+"/kind_payload/scope_invoked",schemaPath:"#/properties/kind_payload/properties/scope_invoked/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[n]:t.push(n),i++}if(r.value_invoked!==void 0){let n=r.value_invoked;if(!(n&&typeof n=="object"&&!Array.isArray(n))&&n!==null){let m={instancePath:e+"/kind_payload/value_invoked",schemaPath:"#/properties/kind_payload/properties/value_invoked/type",keyword:"type",params:{type:st.properties.kind_payload.properties.value_invoked.type},message:"must be object,null"};t===null?t=[m]:t.push(m),i++}}}else{let n={instancePath:e+"/kind_payload",schemaPath:"#/properties/kind_payload/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[n]:t.push(n),i++}}}else{let r={instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[r]:t.push(r),i++}return xe.errors=t,i===0}xe.evaluated={props:!0,dynamicProps:!1,dynamicItems:!1};var zt=De,Vt={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://schemas.overturo.com/postmessage-v2/approval/complete.json",title:"approval COMPLETE payload",type:"object",additionalProperties:!0,required:["outcome","completed_at"],properties:{outcome:{type:"string",enum:["approved","denied"]},exchange_token:{type:["string","null"],description:"Approval-decision exchange token; host calls POST /api/v1/decisions/:token/exchange"},completed_at:{type:"string",format:"date-time"}}},Qr=R().fullFormats["date-time"];function De(s,{instancePath:e="",parentData:o,parentDataProperty:a,rootData:d=s,dynamicAnchors:p={}}={}){let t=null,i=0,l=De.evaluated;if(l.dynamicProps&&(l.props=void 0),l.dynamicItems&&(l.items=void 0),s&&typeof s=="object"&&!Array.isArray(s)){if(s.outcome===void 0){let r={instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:"outcome"},message:"must have required property 'outcome'"};t===null?t=[r]:t.push(r),i++}if(s.completed_at===void 0){let r={instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:"completed_at"},message:"must have required property 'completed_at'"};t===null?t=[r]:t.push(r),i++}if(s.outcome!==void 0){let r=s.outcome;if(typeof r!="string"){let n={instancePath:e+"/outcome",schemaPath:"#/properties/outcome/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[n]:t.push(n),i++}if(!(r==="approved"||r==="denied")){let n={instancePath:e+"/outcome",schemaPath:"#/properties/outcome/enum",keyword:"enum",params:{allowedValues:Vt.properties.outcome.enum},message:"must be equal to one of the allowed values"};t===null?t=[n]:t.push(n),i++}}if(s.exchange_token!==void 0){let r=s.exchange_token;if(typeof r!="string"&&r!==null){let n={instancePath:e+"/exchange_token",schemaPath:"#/properties/exchange_token/type",keyword:"type",params:{type:Vt.properties.exchange_token.type},message:"must be string,null"};t===null?t=[n]:t.push(n),i++}}if(s.completed_at!==void 0){let r=s.completed_at;if(typeof r=="string"){if(!Qr.validate(r)){let n={instancePath:e+"/completed_at",schemaPath:"#/properties/completed_at/format",keyword:"format",params:{format:"date-time"},message:'must match format "date-time"'};t===null?t=[n]:t.push(n),i++}}else{let n={instancePath:e+"/completed_at",schemaPath:"#/properties/completed_at/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[n]:t.push(n),i++}}}else{let r={instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[r]:t.push(r),i++}return De.errors=t,i===0}De.evaluated={props:!0,dynamicProps:!1,dynamicItems:!1};var Bt=Ce,Kt={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://schemas.overturo.com/postmessage-v2/approval/error.json",title:"approval ERROR payload",type:"object",additionalProperties:!0,required:["code","message","fatal"],properties:{code:{type:"string"},message:{type:"string"},fatal:{type:"boolean"},recoverable_via:{type:["string","null"],enum:["reload","new_session",null]}}};function Ce(s,{instancePath:e="",parentData:o,parentDataProperty:a,rootData:d=s,dynamicAnchors:p={}}={}){let t=null,i=0,l=Ce.evaluated;if(l.dynamicProps&&(l.props=void 0),l.dynamicItems&&(l.items=void 0),s&&typeof s=="object"&&!Array.isArray(s)){if(s.code===void 0){let r={instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:"code"},message:"must have required property 'code'"};t===null?t=[r]:t.push(r),i++}if(s.message===void 0){let r={instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:"message"},message:"must have required property 'message'"};t===null?t=[r]:t.push(r),i++}if(s.fatal===void 0){let r={instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:"fatal"},message:"must have required property 'fatal'"};t===null?t=[r]:t.push(r),i++}if(s.code!==void 0&&typeof s.code!="string"){let r={instancePath:e+"/code",schemaPath:"#/properties/code/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[r]:t.push(r),i++}if(s.message!==void 0&&typeof s.message!="string"){let r={instancePath:e+"/message",schemaPath:"#/properties/message/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[r]:t.push(r),i++}if(s.fatal!==void 0&&typeof s.fatal!="boolean"){let r={instancePath:e+"/fatal",schemaPath:"#/properties/fatal/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};t===null?t=[r]:t.push(r),i++}if(s.recoverable_via!==void 0){let r=s.recoverable_via;if(typeof r!="string"&&r!==null){let n={instancePath:e+"/recoverable_via",schemaPath:"#/properties/recoverable_via/type",keyword:"type",params:{type:Kt.properties.recoverable_via.type},message:"must be string,null"};t===null?t=[n]:t.push(n),i++}if(!(r==="reload"||r==="new_session"||r===null)){let n={instancePath:e+"/recoverable_via",schemaPath:"#/properties/recoverable_via/enum",keyword:"enum",params:{allowedValues:Kt.properties.recoverable_via.enum},message:"must be equal to one of the allowed values"};t===null?t=[n]:t.push(n),i++}}}else{let r={instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[r]:t.push(r),i++}return Ce.errors=t,i===0}Ce.evaluated={props:!0,dynamicProps:!1,dynamicItems:!1};var Yt=Oe,es={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://schemas.overturo.com/postmessage-v2/approval/deadline.json",title:"approval DEADLINE payload",type:"object",additionalProperties:!0,required:["remaining_seconds","level","deadline_at"],properties:{remaining_seconds:{type:"integer",minimum:0},level:{type:"string",enum:["warning","expired"]},deadline_at:{type:"string",format:"date-time"}}},ts=R().fullFormats["date-time"];function Oe(s,{instancePath:e="",parentData:o,parentDataProperty:a,rootData:d=s,dynamicAnchors:p={}}={}){let t=null,i=0,l=Oe.evaluated;if(l.dynamicProps&&(l.props=void 0),l.dynamicItems&&(l.items=void 0),s&&typeof s=="object"&&!Array.isArray(s)){if(s.remaining_seconds===void 0){let r={instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:"remaining_seconds"},message:"must have required property 'remaining_seconds'"};t===null?t=[r]:t.push(r),i++}if(s.level===void 0){let r={instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:"level"},message:"must have required property 'level'"};t===null?t=[r]:t.push(r),i++}if(s.deadline_at===void 0){let r={instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:"deadline_at"},message:"must have required property 'deadline_at'"};t===null?t=[r]:t.push(r),i++}if(s.remaining_seconds!==void 0){let r=s.remaining_seconds;if(!(typeof r=="number"&&!(r%1)&&!isNaN(r))){let n={instancePath:e+"/remaining_seconds",schemaPath:"#/properties/remaining_seconds/type",keyword:"type",params:{type:"integer"},message:"must be integer"};t===null?t=[n]:t.push(n),i++}if(typeof r=="number"&&(r<0||isNaN(r))){let n={instancePath:e+"/remaining_seconds",schemaPath:"#/properties/remaining_seconds/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};t===null?t=[n]:t.push(n),i++}}if(s.level!==void 0){let r=s.level;if(typeof r!="string"){let n={instancePath:e+"/level",schemaPath:"#/properties/level/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[n]:t.push(n),i++}if(!(r==="warning"||r==="expired")){let n={instancePath:e+"/level",schemaPath:"#/properties/level/enum",keyword:"enum",params:{allowedValues:es.properties.level.enum},message:"must be equal to one of the allowed values"};t===null?t=[n]:t.push(n),i++}}if(s.deadline_at!==void 0){let r=s.deadline_at;if(typeof r=="string"){if(!ts.validate(r)){let n={instancePath:e+"/deadline_at",schemaPath:"#/properties/deadline_at/format",keyword:"format",params:{format:"date-time"},message:'must match format "date-time"'};t===null?t=[n]:t.push(n),i++}}else{let n={instancePath:e+"/deadline_at",schemaPath:"#/properties/deadline_at/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[n]:t.push(n),i++}}}else{let r={instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[r]:t.push(r),i++}return Oe.errors=t,i===0}Oe.evaluated={props:!0,dynamicProps:!1,dynamicItems:!1};var Gt=Ie,Re={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://schemas.overturo.com/postmessage-v2/signature/state.json",title:"signature STATE payload",type:"object",additionalProperties:!0,required:["from","to","kind_payload"],properties:{from:{type:["string","null"]},to:{type:"string",enum:["pending","opened","in_progress","signed","declined","expired"]},kind_payload:{type:"object",additionalProperties:!0,required:["required_assurance_level"],properties:{required_assurance_level:{type:"string",enum:["integrity_proof","advanced","qualified"]},participant_role:{type:["string","null"]}}}}};function Ie(s,{instancePath:e="",parentData:o,parentDataProperty:a,rootData:d=s,dynamicAnchors:p={}}={}){let t=null,i=0,l=Ie.evaluated;if(l.dynamicProps&&(l.props=void 0),l.dynamicItems&&(l.items=void 0),s&&typeof s=="object"&&!Array.isArray(s)){if(s.from===void 0){let r={instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:"from"},message:"must have required property 'from'"};t===null?t=[r]:t.push(r),i++}if(s.to===void 0){let r={instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:"to"},message:"must have required property 'to'"};t===null?t=[r]:t.push(r),i++}if(s.kind_payload===void 0){let r={instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:"kind_payload"},message:"must have required property 'kind_payload'"};t===null?t=[r]:t.push(r),i++}if(s.from!==void 0){let r=s.from;if(typeof r!="string"&&r!==null){let n={instancePath:e+"/from",schemaPath:"#/properties/from/type",keyword:"type",params:{type:Re.properties.from.type},message:"must be string,null"};t===null?t=[n]:t.push(n),i++}}if(s.to!==void 0){let r=s.to;if(typeof r!="string"){let n={instancePath:e+"/to",schemaPath:"#/properties/to/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[n]:t.push(n),i++}if(!(r==="pending"||r==="opened"||r==="in_progress"||r==="signed"||r==="declined"||r==="expired")){let n={instancePath:e+"/to",schemaPath:"#/properties/to/enum",keyword:"enum",params:{allowedValues:Re.properties.to.enum},message:"must be equal to one of the allowed values"};t===null?t=[n]:t.push(n),i++}}if(s.kind_payload!==void 0){let r=s.kind_payload;if(r&&typeof r=="object"&&!Array.isArray(r)){if(r.required_assurance_level===void 0){let n={instancePath:e+"/kind_payload",schemaPath:"#/properties/kind_payload/required",keyword:"required",params:{missingProperty:"required_assurance_level"},message:"must have required property 'required_assurance_level'"};t===null?t=[n]:t.push(n),i++}if(r.required_assurance_level!==void 0){let n=r.required_assurance_level;if(typeof n!="string"){let m={instancePath:e+"/kind_payload/required_assurance_level",schemaPath:"#/properties/kind_payload/properties/required_assurance_level/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[m]:t.push(m),i++}if(!(n==="integrity_proof"||n==="advanced"||n==="qualified")){let m={instancePath:e+"/kind_payload/required_assurance_level",schemaPath:"#/properties/kind_payload/properties/required_assurance_level/enum",keyword:"enum",params:{allowedValues:Re.properties.kind_payload.properties.required_assurance_level.enum},message:"must be equal to one of the allowed values"};t===null?t=[m]:t.push(m),i++}}if(r.participant_role!==void 0){let n=r.participant_role;if(typeof n!="string"&&n!==null){let m={instancePath:e+"/kind_payload/participant_role",schemaPath:"#/properties/kind_payload/properties/participant_role/type",keyword:"type",params:{type:Re.properties.kind_payload.properties.participant_role.type},message:"must be string,null"};t===null?t=[m]:t.push(m),i++}}}else{let n={instancePath:e+"/kind_payload",schemaPath:"#/properties/kind_payload/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[n]:t.push(n),i++}}}else{let r={instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[r]:t.push(r),i++}return Ie.errors=t,i===0}Ie.evaluated={props:!0,dynamicProps:!1,dynamicItems:!1};var Wt=Me,nt={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://schemas.overturo.com/postmessage-v2/signature/complete.json",title:"signature COMPLETE payload",type:"object",additionalProperties:!0,required:["outcome","completed_at"],properties:{outcome:{type:"string",enum:["signed","declined","countered"]},assurance_level:{type:["string","null"],enum:["integrity_proof","advanced","qualified",null],description:"The signature assurance level recorded on the agreement."},completed_at:{type:"string",format:"date-time"}}},rs=R().fullFormats["date-time"];function Me(s,{instancePath:e="",parentData:o,parentDataProperty:a,rootData:d=s,dynamicAnchors:p={}}={}){let t=null,i=0,l=Me.evaluated;if(l.dynamicProps&&(l.props=void 0),l.dynamicItems&&(l.items=void 0),s&&typeof s=="object"&&!Array.isArray(s)){if(s.outcome===void 0){let r={instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:"outcome"},message:"must have required property 'outcome'"};t===null?t=[r]:t.push(r),i++}if(s.completed_at===void 0){let r={instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:"completed_at"},message:"must have required property 'completed_at'"};t===null?t=[r]:t.push(r),i++}if(s.outcome!==void 0){let r=s.outcome;if(typeof r!="string"){let n={instancePath:e+"/outcome",schemaPath:"#/properties/outcome/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[n]:t.push(n),i++}if(!(r==="signed"||r==="declined"||r==="countered")){let n={instancePath:e+"/outcome",schemaPath:"#/properties/outcome/enum",keyword:"enum",params:{allowedValues:nt.properties.outcome.enum},message:"must be equal to one of the allowed values"};t===null?t=[n]:t.push(n),i++}}if(s.assurance_level!==void 0){let r=s.assurance_level;if(typeof r!="string"&&r!==null){let n={instancePath:e+"/assurance_level",schemaPath:"#/properties/assurance_level/type",keyword:"type",params:{type:nt.properties.assurance_level.type},message:"must be string,null"};t===null?t=[n]:t.push(n),i++}if(!(r==="integrity_proof"||r==="advanced"||r==="qualified"||r===null)){let n={instancePath:e+"/assurance_level",schemaPath:"#/properties/assurance_level/enum",keyword:"enum",params:{allowedValues:nt.properties.assurance_level.enum},message:"must be equal to one of the allowed values"};t===null?t=[n]:t.push(n),i++}}if(s.completed_at!==void 0){let r=s.completed_at;if(typeof r=="string"){if(!rs.validate(r)){let n={instancePath:e+"/completed_at",schemaPath:"#/properties/completed_at/format",keyword:"format",params:{format:"date-time"},message:'must match format "date-time"'};t===null?t=[n]:t.push(n),i++}}else{let n={instancePath:e+"/completed_at",schemaPath:"#/properties/completed_at/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[n]:t.push(n),i++}}}else{let r={instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[r]:t.push(r),i++}return Me.errors=t,i===0}Me.evaluated={props:!0,dynamicProps:!1,dynamicItems:!1};var Xt=$e,Zt={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://schemas.overturo.com/postmessage-v2/signature/error.json",title:"signature ERROR payload",type:"object",additionalProperties:!0,required:["code","message","fatal"],properties:{code:{type:"string"},message:{type:"string"},fatal:{type:"boolean"},recoverable_via:{type:["string","null"],enum:["reload","new_session",null]}}};function $e(s,{instancePath:e="",parentData:o,parentDataProperty:a,rootData:d=s,dynamicAnchors:p={}}={}){let t=null,i=0,l=$e.evaluated;if(l.dynamicProps&&(l.props=void 0),l.dynamicItems&&(l.items=void 0),s&&typeof s=="object"&&!Array.isArray(s)){if(s.code===void 0){let r={instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:"code"},message:"must have required property 'code'"};t===null?t=[r]:t.push(r),i++}if(s.message===void 0){let r={instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:"message"},message:"must have required property 'message'"};t===null?t=[r]:t.push(r),i++}if(s.fatal===void 0){let r={instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:"fatal"},message:"must have required property 'fatal'"};t===null?t=[r]:t.push(r),i++}if(s.code!==void 0&&typeof s.code!="string"){let r={instancePath:e+"/code",schemaPath:"#/properties/code/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[r]:t.push(r),i++}if(s.message!==void 0&&typeof s.message!="string"){let r={instancePath:e+"/message",schemaPath:"#/properties/message/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[r]:t.push(r),i++}if(s.fatal!==void 0&&typeof s.fatal!="boolean"){let r={instancePath:e+"/fatal",schemaPath:"#/properties/fatal/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};t===null?t=[r]:t.push(r),i++}if(s.recoverable_via!==void 0){let r=s.recoverable_via;if(typeof r!="string"&&r!==null){let n={instancePath:e+"/recoverable_via",schemaPath:"#/properties/recoverable_via/type",keyword:"type",params:{type:Zt.properties.recoverable_via.type},message:"must be string,null"};t===null?t=[n]:t.push(n),i++}if(!(r==="reload"||r==="new_session"||r===null)){let n={instancePath:e+"/recoverable_via",schemaPath:"#/properties/recoverable_via/enum",keyword:"enum",params:{allowedValues:Zt.properties.recoverable_via.enum},message:"must be equal to one of the allowed values"};t===null?t=[n]:t.push(n),i++}}}else{let r={instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[r]:t.push(r),i++}return $e.errors=t,i===0}$e.evaluated={props:!0,dynamicProps:!1,dynamicItems:!1};var Jt=Le,ss={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://schemas.overturo.com/postmessage-v2/signature/deadline.json",title:"signature DEADLINE payload",type:"object",additionalProperties:!0,required:["remaining_seconds","level","deadline_at"],properties:{remaining_seconds:{type:"integer",minimum:0},level:{type:"string",enum:["warning","expired"]},deadline_at:{type:"string",format:"date-time"}}},ns=R().fullFormats["date-time"];function Le(s,{instancePath:e="",parentData:o,parentDataProperty:a,rootData:d=s,dynamicAnchors:p={}}={}){let t=null,i=0,l=Le.evaluated;if(l.dynamicProps&&(l.props=void 0),l.dynamicItems&&(l.items=void 0),s&&typeof s=="object"&&!Array.isArray(s)){if(s.remaining_seconds===void 0){let r={instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:"remaining_seconds"},message:"must have required property 'remaining_seconds'"};t===null?t=[r]:t.push(r),i++}if(s.level===void 0){let r={instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:"level"},message:"must have required property 'level'"};t===null?t=[r]:t.push(r),i++}if(s.deadline_at===void 0){let r={instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:"deadline_at"},message:"must have required property 'deadline_at'"};t===null?t=[r]:t.push(r),i++}if(s.remaining_seconds!==void 0){let r=s.remaining_seconds;if(!(typeof r=="number"&&!(r%1)&&!isNaN(r))){let n={instancePath:e+"/remaining_seconds",schemaPath:"#/properties/remaining_seconds/type",keyword:"type",params:{type:"integer"},message:"must be integer"};t===null?t=[n]:t.push(n),i++}if(typeof r=="number"&&(r<0||isNaN(r))){let n={instancePath:e+"/remaining_seconds",schemaPath:"#/properties/remaining_seconds/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};t===null?t=[n]:t.push(n),i++}}if(s.level!==void 0){let r=s.level;if(typeof r!="string"){let n={instancePath:e+"/level",schemaPath:"#/properties/level/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[n]:t.push(n),i++}if(!(r==="warning"||r==="expired")){let n={instancePath:e+"/level",schemaPath:"#/properties/level/enum",keyword:"enum",params:{allowedValues:ss.properties.level.enum},message:"must be equal to one of the allowed values"};t===null?t=[n]:t.push(n),i++}}if(s.deadline_at!==void 0){let r=s.deadline_at;if(typeof r=="string"){if(!ns.validate(r)){let n={instancePath:e+"/deadline_at",schemaPath:"#/properties/deadline_at/format",keyword:"format",params:{format:"date-time"},message:'must match format "date-time"'};t===null?t=[n]:t.push(n),i++}}else{let n={instancePath:e+"/deadline_at",schemaPath:"#/properties/deadline_at/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[n]:t.push(n),i++}}}else{let r={instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[r]:t.push(r),i++}return Le.errors=t,i===0}Le.evaluated={props:!0,dynamicProps:!1,dynamicItems:!1};var os={[f.READY]:{_agnostic:Ot},[f.RESIZE]:{_agnostic:Rt},[f.CANCEL]:{_agnostic:Mt},[f.STATE]:{consent:$t,approval:Ut,signature_request:Gt},[f.COMPLETE]:{consent:jt,approval:zt,signature_request:Wt},[f.ERROR]:{consent:Ft,approval:Bt,signature_request:Xt},[f.DEADLINE]:{consent:Ht,approval:Yt,signature_request:Jt}},Qt=qt;function is(s){let e=Qt(s);return{valid:e,errors:e?null:Qt.errors??null}}function as(s){let e=os[s.type];if(!e)return{valid:!1,errors:[{message:`Unknown type ${s.type}`}]};let o=e._agnostic??e[s.kind];if(!o)return{valid:!1,errors:[{message:`No validator for ${s.type}/${s.kind}`}]};let a=o(s.payload);return{valid:a,errors:a?null:o.errors??null}}function I(s){let e=is(s);return e.valid?as(s):e}var L,ae,A,M,Ne,tr,je=class{constructor(e){h(this,Ne);h(this,L);h(this,ae);h(this,A);h(this,M,new Set);g(this,L,e.api),g(this,ae,e.flowBaseUrl),g(this,A,e.debug)}url(e){let o=e.mode==="embed"?"/embed":"";return`${u(this,ae)}${ct}/${e.token}${o}`}async createSession(e){if(!e.subjectRef)throw new c("subjectRef is required");let o=e.embedOrigin??(typeof window<"u"?window.location.origin:void 0),a={kind:e.kind,subjectRef:e.subjectRef,deliveryMode:e.mode??"embed",embedOrigin:o,state:e.state,redirectUri:e.redirectUri};e.kind==="consent"&&(a.scope=e.scope,a.nonce=e.nonce);let p=(await u(this,L).post(D,a)).decision;return u(this,A)&&console.debug("[overturo:sdk]","session_created",{kind:p.kind,mode:p.mode}),{token:p.sessionToken,kind:p.kind,mode:p.mode,expiresAt:p.deadlineAt??"",embedUrl:p.embedUrl}}async discover(e){if(!e.flowId)throw new c("flowId is required");let o=e.locale?`?locale=${encodeURIComponent(e.locale)}`:"",a=await u(this,L).get(`${D}/flows/${encodeURIComponent(e.flowId)}/disclosures${o}`);if(!a||typeof a!="object"||!("flow"in a))throw new b("Malformed discovery response: missing 'flow'",200,a);return a.flow}embed(e){if(!e.token)throw new c("token is required");let o=this.url({token:e.token,mode:"embed"}),a=new URL(o).origin,d=Z(e.container);if(d.innerHTML="",e.loading){let n=document.createElement("div");n.setAttribute("data-overturo-loading",""),typeof e.loading=="string"?n.innerHTML=e.loading:n.appendChild(e.loading),d.appendChild(n)}let p=document.createElement("iframe");p.src=o,p.setAttribute("sandbox","allow-scripts allow-forms allow-same-origin allow-popups"),X(p,{...N},e.style);let t=()=>{let n=d.querySelector("[data-overturo-loading]");n&&d.removeChild(n)};p.addEventListener("load",t),p.addEventListener("error",()=>{t(),e.onError?.({code:"iframe_load_failed",message:"The trust-host iframe failed to load."})});let i=new AbortController,l=n=>{if(n.origin!==a||ee(n.data))return;let m=I(n.data);if(!m.valid){e.onError?.({code:"protocol_violation",errors:m.errors}),u(this,A)&&console.debug("[overturo:sdk]","envelope_dropped",{reason:"schema_invalid"});return}E(this,Ne,tr).call(this,n.data,e,p)};window.addEventListener("message",l,{signal:i.signal}),d.appendChild(p);let r={token:e.token,mode:"embed",destroy:async()=>{i.abort(),p.parentNode&&p.parentNode.removeChild(p),u(this,M).delete(r),u(this,A)&&console.debug("[overturo:sdk]","iframe_destroyed",{})}};return u(this,M).add(r),u(this,A)&&console.debug("[overturo:sdk]","iframe_mounted",{sandboxAttr:p.getAttribute("sandbox")}),r}popup(e){if(!e.token)throw new c("token is required");let o=this.url({token:e.token,mode:"popup"}),a=new URL(o).origin,d=e.width??B.width,p=e.height??B.height,t=Math.round((screen.width-d)/2),i=Math.round((screen.height-p)/2),l=`width=${d},height=${p},left=${t},top=${i},scrollbars=yes,status=yes`,r=window.open(o,"_blank",l);if(!r)throw u(this,A)&&console.debug("[overturo:sdk]","popup_blocked",{}),new P("Popup was blocked by the browser. Allow popups for this site and try again.");u(this,A)&&console.debug("[overturo:sdk]","popup_opened",{features:l});let n=new AbortController,m=k=>{if(k.origin!==a||ee(k.data))return;if(!I(k.data).valid){e.onError?.({code:"protocol_violation"});return}let Q=k.data;switch(Q.type){case f.COMPLETE:e.onComplete?.(er(Q.kind,Q.payload)),w.destroy();break;case f.CANCEL:e.onCancel?.(Q.payload),w.destroy();break;case f.ERROR:e.onError?.(Q.payload);break}};window.addEventListener("message",m,{signal:n.signal});let y=setInterval(()=>{r.closed&&(y&&(clearInterval(y),y=null),e.onCancel?.({reason:"user_closed_popup"}),w.destroy())},500),w={token:e.token,mode:"popup",destroy:async()=>{y&&(clearInterval(y),y=null),n.abort(),r&&!r.closed&&r.close(),u(this,M).delete(w)}};return u(this,M).add(w),w}async exchange(e){if(!e.token||!e.exchangeToken)throw new c("token and exchangeToken are required for exchange");let o=`${D}/${e.token}/exchange`;return await u(this,L).post(o,{exchangeToken:e.exchangeToken})}async cancel(e){if(!e)throw new c("token is required for cancel");await u(this,L).post(`${D}/${e}/cancel`,{})}async destroyAll(){let e=[...u(this,M)];await Promise.allSettled(e.map(o=>o.destroy())),u(this,M).clear()}};L=new WeakMap,ae=new WeakMap,A=new WeakMap,M=new WeakMap,Ne=new WeakSet,tr=function(e,o,a){let d=e.type===f.STATE&&e.kind==="approval"&&e.payload?.phase==="countered";switch(e.type){case f.READY:o.onReady?.(e.payload);break;case f.STATE:d?o.onCounter?.(e.payload):o.onState?.(e.kind,e.payload);break;case f.RESIZE:{let p=e.payload.height;typeof p=="number"&&(a.style.height=`${p}px`,o.onResize?.(p));break}case f.COMPLETE:o.onComplete?.(er(e.kind,e.payload));break;case f.CANCEL:o.onCancel?.(e.payload);break;case f.ERROR:o.onError?.(e.payload);break;case f.DEADLINE:o.onDeadline?.(e.payload);break}u(this,A)&&console.debug("[overturo:sdk]","envelope_received",{type:e.type,kind:e.kind})};function er(s,e){let o=e??{};return s==="consent"?{kind:"consent",result:o.outcome??o.result??"granted",consentToken:o.exchange_token??o.consentToken,purposesGranted:o.purposesGranted,purposesDeclined:o.purposesDeclined}:s==="signature_request"?{kind:"signature_request",result:o.outcome??o.result??"signed",assuranceLevel:o.assurance_level??o.assuranceLevel,completedAt:o.completed_at??o.completedAt}:{kind:"approval",result:o.outcome??o.result??"approved",escalationToken:o.exchange_token??o.escalationToken,counterProposal:o.counterProposal}}function rr(s,e){let o=Z(e.container),a=new URL(s).origin,d=`${s}/accord/embed/${e.sessionToken}`;if(o.innerHTML="",e.loading){let l=document.createElement("div");l.setAttribute("data-overturo-loading",""),typeof e.loading=="string"?l.innerHTML=e.loading:l.appendChild(e.loading),o.appendChild(l)}let p=document.createElement("iframe");p.src=d,p.setAttribute("sandbox","allow-scripts allow-forms allow-same-origin allow-popups"),X(p,{...N},e.style),p.addEventListener("load",()=>{let l=o.querySelector("[data-overturo-loading]");l&&o.removeChild(l)});let t=new AbortController;function i(l){if(l.origin!==a||!I(l.data).valid)return;let n=l.data;switch(n.type){case f.READY:e.onReady?.(n.payload);break;case f.RESIZE:{let m=n.payload.height;typeof m=="number"&&(p.style.height=`${m}px`,e.onResize?.(m));break}case f.STATE:e.onState?.(n.kind,n.payload);break;case f.DEADLINE:e.onDeadline?.(n.payload);break;case f.COMPLETE:e.onComplete?.(n.kind,n.payload);break;case f.CANCEL:e.onCancel?.(n.payload);break;case f.ERROR:e.onError?.(n.payload);break}}return window.addEventListener("message",i,{signal:t.signal}),o.appendChild(p),{iframe:p,destroy(){t.abort(),p.parentNode&&p.parentNode.removeChild(p)}}}var ds=0;function sr(s,e){if(!e.sessionToken)throw new c("sessionToken is required for popup mode");let o=`${s}/accord/embed/${e.sessionToken}`,a=e.width??B.width,d=e.height??B.height,p=Math.round((screen.width-a)/2),t=Math.round((screen.height-d)/2),i=`overturo_decision_${++ds}`,l=window.open(o,i,`width=${a},height=${d},left=${p},top=${t},scrollbars=yes,status=yes`);if(!l)throw new P("Popup was blocked by the browser. Allow popups for this site and try again.");let r=new URL(s).origin,n=new AbortController;function m(w){if(w.origin!==r||!I(w.data).valid)return;let K=w.data;switch(K.type){case f.COMPLETE:e.onComplete?.(K.kind,K.payload),y();break;case f.CANCEL:e.onCancel?.(K.payload),y();break;case f.ERROR:e.onError?.(K.payload);break}}function y(){n.abort(),l&&!l.closed&&l.close()}return window.addEventListener("message",m,{signal:n.signal}),{close:y}}var nr={mobile:{width:375,height:667},tablet:{width:768,height:1024},desktop:{width:null,height:800}};function it(s,e){let o=ls(e.container),a=e.device||"desktop",d=e.theme||"default",p=e.locale,t=ot(s,d,a,p);e.loading&&us(o,e.loading);let i=document.createElement("iframe");return i.src=t,i.sandbox.add("allow-scripts","allow-same-origin"),i.style.border="none",i.title="Preview",or(i,a),ps(i,e.style),i.addEventListener("load",()=>{let r=o.querySelector("[data-preview-loading]");r&&r.remove()},{once:!0}),o.appendChild(i),{iframe:i,setDevice(r){a=r,or(i,r),i.src=ot(s,d,a,p)},setTheme(r){d=r,i.src=ot(s,d,a,p)},destroy(){i.remove()}}}function ls(s){if(typeof s=="string"){let e=document.querySelector(s);if(!e)throw new Error(`Preview container not found: ${s}`);return e}return s}function ot(s,e,o,a){let d=new URL(s,window.location.origin);return d.searchParams.set("theme",e),d.searchParams.set("device",o),a&&d.searchParams.set("locale",a),d.toString()}function or(s,e){let o=nr[e]||nr.desktop;o.width?(s.style.width=`${o.width}px`,s.style.maxWidth="100%"):(s.style.width="100%",s.style.maxWidth="none"),s.style.height=`${o.height}px`}function ps(s,e){e&&(e.width&&(s.style.width=e.width),e.minHeight&&(s.style.minHeight=e.minHeight),e.maxHeight&&(s.style.maxHeight=e.maxHeight),e.borderRadius&&(s.style.borderRadius=e.borderRadius),e.border&&(s.style.border=e.border),e.background&&(s.style.background=e.background))}function us(s,e){let o=document.createElement("div");o.setAttribute("data-preview-loading",""),typeof e=="string"?o.textContent=e:o.appendChild(e),s.appendChild(o)}function ir(s,e){if(!e.flowId)throw new c("flowId is required for redirect mode");if(!e.redirectUri)throw new c("redirectUri is required for redirect mode");let o=new URL(`${s}/accord/${e.flowId}`),a=new URLSearchParams;a.set("redirect_uri",e.redirectUri),e.state&&a.set("state",e.state),e.nonce&&a.set("nonce",e.nonce),e.scope&&a.set("scope",e.scope),o.search=a.toString(),window.location.href=o.toString()}function Fe(s,e){let o=Z(e.container),a=new URL(s).origin,d=`${s}/accord_setup/embed/${e.sessionToken}`;if(o.innerHTML="",e.loading){let l=document.createElement("div");l.setAttribute("data-overturo-loading",""),typeof e.loading=="string"?l.innerHTML=e.loading:l.appendChild(e.loading),o.appendChild(l)}let p=document.createElement("iframe");p.src=d,p.setAttribute("allow","popups"),p.setAttribute("sandbox","allow-scripts allow-forms allow-same-origin allow-popups"),X(p,{...N},e.style),p.addEventListener("load",()=>{let l=o.querySelector("[data-overturo-loading]");l&&o.removeChild(l)});let t=new AbortController;function i(l){if(l.origin!==a)return;let r=l.data;if(!(!r||!r.type))switch(r.type){case T.READY:e.onReady?.();break;case T.RESIZE:r.height&&(p.style.height=`${r.height}px`,e.onResize?.(r.height));break;case T.STEP:e.onStep?.({key:r.step,index:r.stepIndex,total:r.totalSteps});break;case T.CREATED:e.onCreated?.({accordId:r.accordId,flowId:r.flowId});break;case T.CANCEL:e.onCancel?.();break;case T.ERROR:e.onError?.(r.error);break}}return window.addEventListener("message",i,{signal:t.signal}),o.appendChild(p),{iframe:p,destroy(){t.abort(),p.parentNode&&p.parentNode.removeChild(p)}}}function He(s,e){let o=`${s}/accord_setup/embed/${e.sessionToken}`,a=new URL(s).origin,d=e.width??Ye.width,p=e.height??Ye.height,t=Math.round((screen.width-d)/2),i=Math.round((screen.height-p)/2),l=window.open(o,"accord_setup_popup",`width=${d},height=${p},left=${t},top=${i},scrollbars=yes`),r=new AbortController,n=null;function m(w){if(w.origin!==a)return;let k=w.data;if(!(!k||!k.type))switch(k.type){case T.CREATED:e.onCreated?.({accordId:k.accordId,flowId:k.flowId}),y();break;case T.CANCEL:e.onCancel?.(),y();break;case T.ERROR:e.onError?.(k.error);break}}function y(){r.abort(),n&&clearInterval(n)}return window.addEventListener("message",m,{signal:r.signal}),n=setInterval(()=>{l&&l.closed&&(e.onCancel?.(),y())},500),{close(){l?.close(),y()}}}function Ue(s,e){let o=`${s}/accord_setup/embed/${e.sessionToken}`;window.location.href=o}var de=class{constructor(e){if(!e.publishableKey)throw new c("publishableKey is required");if(this.baseUrl=(e.baseUrl??ft).replace(/\/+$/,""),this.flowBaseUrl=(e.flowBaseUrl??this.baseUrl).replace(/\/+$/,""),this.debugFlag=e.debug===!0,this.api=new fe({baseUrl:this.baseUrl,publishableKey:e.publishableKey,apiKey:e.apiKey,timeout:e.timeout}),this.decisions=new je({api:this.api,flowBaseUrl:this.flowBaseUrl,debug:this.debugFlag}),this.consent=new ge(this.decisions),this.approvals=new he(this.decisions,this.api),this.signing=new be(this.decisions,this.api),this.forms=new we(this.api,this.decisions,this.flowBaseUrl,e.publishableKey),this.debugFlag&&typeof window<"u"){let o=new URL(this.baseUrl),a=o.hostname==="localhost"||o.hostname==="127.0.0.1"||o.hostname==="lvh.me"||o.hostname.endsWith(".lvh.me")||o.hostname.endsWith(".localhost");o.protocol==="http:"&&!a&&console.warn("[overturo:sdk]","OVERTURO_INSECURE_HOST",`API host ${o.host} is not HTTPS; treat this as dev-only.`)}}async destroy(){await this.decisions.destroyAll()}async createSession(e){return this.api.post(ue,{accordId:e.flowId,deliveryMode:e.deliveryMode,embedOrigin:e.embedOrigin,redirectUri:e.redirectUri,state:e.state,nonce:e.nonce,scope:e.scope,skipSteps:e.skipSteps})}async getSession(e){return this.api.get(`${ue}/${e}`)}async getMeetingParticipantStatus(e,o){if(!e)throw new c("meetingId is required");if(!o)throw new c("sessionToken is required");let a=await this.api.rawGet(`${Ge}/${encodeURIComponent(e)}/status?session_token=${encodeURIComponent(o)}`);return this.decodeParticipantStatus(a)}async withdrawMeetingConsent(e,o){if(!e)throw new c("meetingId is required");if(!o)throw new c("sessionToken is required");let a=await this.api.rawPost(`${Ge}/${encodeURIComponent(e)}/revoke`,{sessionToken:o});return this.decodeParticipantStatus(a)}async decodeParticipantStatus(e){if(!e.ok){let p;try{p=await e.json()}catch{p=null}throw new b(ye(p,e.status),e.status,p)}let o=JSON.parse(await e.text()),a=o.purposes??{};return{...G({...o,purposes:{}}),purposes:{...a}}}embed(e){return rr(this.flowBaseUrl,e)}popup(e){return sr(this.flowBaseUrl,e)}redirect(e){ir(this.flowBaseUrl,e)}async exchange(e){let a=`${ue}/${e.sessionToken}/exchange`,d={consentToken:e.consentToken};for(let p=0;p<=5;p++){let t=await this.api.rawPost(a,d);if(t.status===202){if(p===5)throw new b("Exchange timeout: fulfillment still pending",202,null);let l=parseInt(t.headers.get("Retry-After")||"1",10);await new Promise(r=>setTimeout(r,l*1e3));continue}if(!t.ok){let l;try{l=await t.json()}catch{l=null}let r=ye(l,t.status);throw new b(r===`HTTP ${t.status}`?`Exchange failed: HTTP ${t.status}`:r,t.status,l)}let i=await t.text();return G(JSON.parse(i))}throw new b("Exchange failed: max retries exceeded",202,null)}async createSetupSession(e){return this.api.post(mt,{solution:e.solution,vertical:e.vertical,archetype:e.archetype,templateKey:e.templateKey,deliveryMode:e.deliveryMode||"embed",embedOrigin:e.embedOrigin||(typeof window<"u"?window.location.origin:void 0),redirectUri:e.redirectUri,state:e.state,locale:e.locale||(typeof navigator<"u"?navigator.language:void 0),constraints:e.constraints,presetId:e.presetId})}async accordSetup(e){let o=await this.createSetupSession(this.buildSetupParams(e,"embed"));return Fe(this.flowBaseUrl,{...e,sessionToken:o.sessionToken})}async accordSetupPopup(e){let o=await this.createSetupSession(this.buildSetupParams(e,"popup"));return He(this.flowBaseUrl,{...e,sessionToken:o.sessionToken})}async accordSetupRedirect(e){let o=await this.createSetupSession({...this.buildSetupParams(e,"redirect"),redirectUri:e.redirectUri,state:e.state});Ue(this.flowBaseUrl,{...e,sessionToken:o.sessionToken})}async previewTemplate(e){if(!e.templateId)throw new c("templateId is required");if(!e.container)throw new c("container is required");let o=await this.api.post(We,{previewable_type:"template",previewable_id:e.templateId,theme:e.theme,device:e.device,locale:e.locale});return it(o.preview_url,e)}async previewSetup(e){if(!e.sessionToken)throw new c("sessionToken is required");if(!e.container)throw new c("container is required");let o=await this.api.post(We,{previewable_type:"setup_session",previewable_id:e.sessionToken,theme:e.theme,device:e.device,locale:e.locale});return it(o.preview_url,e)}buildSetupParams(e,o){return{solution:e.solution,vertical:e.vertical,archetype:e.archetype,templateKey:e.templateKey,deliveryMode:o,locale:e.locale,constraints:e.constraints,presetId:e.presetId}}};var J="overturo-decision",ze="OVERTURO_ELEMENT_ALREADY_DEFINED",V,$,j,_,v,at,ar,dr,dt,Ve,le,z=class extends HTMLElement{constructor(){super();h(this,v);h(this,V);h(this,$,null);h(this,j,null);h(this,_,null);h(this,le,o=>{o.key==="Escape"&&(this.dispatchEvent(new CustomEvent("decision:cancel",{detail:{reason:"user_pressed_esc"},bubbles:!0,composed:!0})),E(this,v,Ve).call(this))});g(this,V,this.attachShadow({mode:"open"}))}connectedCallback(){this.hasAttribute("role")||this.setAttribute("role","region"),this.hasAttribute("aria-label")||this.setAttribute("aria-label","Loading decision"),this.setAttribute("aria-busy","true"),this.hasAttribute("tabindex")||this.setAttribute("tabindex","0"),this.addEventListener("keydown",u(this,le)),E(this,v,at).call(this)}disconnectedCallback(){this.removeEventListener("keydown",u(this,le)),E(this,v,Ve).call(this)}attributeChangedCallback(o,a,d){a!==d&&this.isConnected&&(o==="token"||o==="mode"||o==="flow-base-url"||o==="theme")&&(E(this,v,Ve).call(this),E(this,v,at).call(this))}};V=new WeakMap,$=new WeakMap,j=new WeakMap,_=new WeakMap,v=new WeakSet,at=function(){let o=this.getAttribute("token");if(!o)return;let a=this.getAttribute("mode")??"embed",d=this.getAttribute("flow-base-url")??ms();if(a!=="embed"){E(this,v,ar).call(this,d,o,a);return}let p=this.getAttribute("theme"),t=`${d.replace(/\/+$/,"")}/decisions/${o}/embed`,i=p?`${t}?theme=${encodeURIComponent(p)}`:t,l=new URL(i).origin,r=document.createElement("iframe");r.src=i,r.title="Overturo decision form",r.setAttribute("allow","popups"),r.setAttribute("sandbox","allow-scripts allow-forms allow-same-origin allow-popups"),r.style.cssText="width:100%;min-height:400px;border:0;background:transparent;",p&&(r.dataset.theme=p);let n=cs();n&&r.setAttribute("nonce",n),r.addEventListener("error",()=>{this.dispatchEvent(new CustomEvent("decision:error",{detail:{code:"iframe_load_failed",message:"The trust-host iframe failed to load."},bubbles:!0,composed:!0})),this.setAttribute("aria-busy","false")}),g(this,j,new AbortController);let m=y=>{if(y.origin!==l||ee(y.data))return;if(!I(y.data).valid){E(this,v,dt).call(this,{code:"protocol_violation"});return}E(this,v,dr).call(this,y.data,r)};window.addEventListener("message",m,{signal:u(this,j).signal}),g(this,$,r),u(this,V).appendChild(r)},ar=function(o,a,d){let p=document.createElement("a");p.href=`${o.replace(/\/+$/,"")}/decisions/${a}`,p.target=d==="popup"?"_blank":"_self",p.rel="noopener noreferrer",p.textContent="Open decision",p.style.cssText="display:inline-block;padding:0.5em 1em;text-decoration:none;",u(this,V).appendChild(p),this.setAttribute("aria-busy","false")},dr=function(o,a){switch(o.type){case f.READY:{this.setAttribute("aria-busy","false");let d=o.payload??{},p=(typeof d.title=="string"?d.title:null)??d.branding?.application_name??null;p&&this.setAttribute("aria-label",p),this.dispatchEvent(new CustomEvent("decision:ready",{detail:o.payload}));break}case f.STATE:this.dispatchEvent(new CustomEvent("decision:state",{detail:{kind:o.kind,payload:o.payload}}));break;case f.RESIZE:{let d=o.payload.height;typeof d=="number"&&(a.style.height=`${d}px`);break}case f.COMPLETE:this.dispatchEvent(new CustomEvent("decision:complete",{detail:{kind:o.kind,payload:o.payload},bubbles:!0,composed:!0}));break;case f.CANCEL:this.dispatchEvent(new CustomEvent("decision:cancel",{detail:o.payload,bubbles:!0,composed:!0}));break;case f.ERROR:E(this,v,dt).call(this,o.payload);break;case f.DEADLINE:this.dispatchEvent(new CustomEvent("decision:deadline",{detail:o.payload}));break}},dt=function(o){this.dispatchEvent(new CustomEvent("decision:error",{detail:o,bubbles:!0})),u(this,_)||(g(this,_,document.createElement("div")),u(this,_).setAttribute("role","alert"),u(this,_).setAttribute("aria-live","assertive"),u(this,_).style.cssText="position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);",u(this,V).appendChild(u(this,_)));let a=typeof o.message=="string"?o.message:"An error occurred. Please try again.";u(this,_).textContent=a,window.setTimeout(()=>{u(this,_)&&(u(this,_).textContent="")},3e4)},Ve=function(){u(this,j)&&(u(this,j).abort(),g(this,j,null)),u(this,$)&&u(this,$).parentNode&&u(this,$).parentNode.removeChild(u(this,$)),g(this,$,null),u(this,_)&&(u(this,_).textContent=""),this.setAttribute("aria-busy","true")},le=new WeakMap,z.observedAttributes=["token","mode","theme","flow-base-url"];function cs(){return typeof document>"u"?null:document.querySelector('meta[name="csp-nonce"]')?.getAttribute("content")??null}function ms(){return typeof window<"u"?window.location.origin:"https://overturo.com"}function pe(){if(!(typeof customElements>"u")){if(customElements.get(J)){console.warn("[overturo:sdk]",ze,`<${J}> already registered; skipping.`);return}customElements.define(J,z)}}pe();return fr(fs);})();
|
|
1
|
+
"use strict";var Overturo=(()=>{var Be=Object.defineProperty;var pr=Object.getOwnPropertyDescriptor;var ur=Object.getOwnPropertyNames;var cr=Object.prototype.hasOwnProperty;var lt=s=>{throw TypeError(s)};var pt=(s,e)=>()=>{try{return e||s((e={exports:{}}).exports,e),e.exports}catch(o){throw e=0,o}},mr=(s,e)=>{for(var o in e)Be(s,o,{get:e[o],enumerable:!0})},fr=(s,e,o,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let d of ur(e))!cr.call(s,d)&&d!==o&&Be(s,d,{get:()=>e[d],enumerable:!(a=pr(e,d))||a.enumerable});return s};var yr=s=>fr(Be({},"__esModule",{value:!0}),s);var Ke=(s,e,o)=>e.has(s)||lt("Cannot "+o);var u=(s,e,o)=>(Ke(s,e,"read from private field"),o?o.call(s):e.get(s)),h=(s,e,o)=>e.has(s)?lt("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(s):e.set(s,o),g=(s,e,o,a)=>(Ke(s,e,"write to private field"),a?a.call(s,o):e.set(s,o),o),E=(s,e,o)=>(Ke(s,e,"access private method"),o);var R=pt(x=>{"use strict";Object.defineProperty(x,"__esModule",{value:!0});x.formatNames=x.fastFormats=x.fullFormats=void 0;function q(s,e){return{validate:s,compare:e}}x.fullFormats={date:q(Et,et),time:q(Je(!0),tt),"date-time":q(bt(!0),At),"iso-time":q(Je(),Pt),"iso-date-time":q(bt(),Tt),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:Nr,"uri-reference":/^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,"uri-template":/^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i,url:/^(?:https?|ftp):\/\/(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)(?:\.(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu,email:/^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i,hostname:/^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i,ipv4:/^(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)$/,ipv6:/^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/i,regex:Kr,uuid:/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,"json-pointer":/^(?:\/(?:[^~/]|~0|~1)*)*$/,"json-pointer-uri-fragment":/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,"relative-json-pointer":/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,byte:Hr,int32:{type:"number",validate:Vr},int64:{type:"number",validate:zr},float:{type:"number",validate:kt},double:{type:"number",validate:kt},password:!0,binary:!0};x.fastFormats={...x.fullFormats,date:q(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,et),time:q(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,tt),"date-time":q(/^\d\d\d\d-[0-1]\d-[0-3]\dt(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,At),"iso-time":q(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,Pt),"iso-date-time":q(/^\d\d\d\d-[0-1]\d-[0-3]\d[t\s](?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,Tt),uri:/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/)?[^\s]*$/i,"uri-reference":/^(?:(?:[a-z][a-z0-9+\-.]*:)?\/?\/)?(?:[^\\\s#][^\s#]*)?(?:#[^\\\s]*)?$/i,email:/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/i};x.formatNames=Object.keys(x.fullFormats);function Ir(s){return s%4===0&&(s%100!==0||s%400===0)}var Mr=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,$r=[0,31,28,31,30,31,30,31,31,30,31,30,31];function Et(s){let e=Mr.exec(s);if(!e)return!1;let o=+e[1],a=+e[2],d=+e[3];return a>=1&&a<=12&&d>=1&&d<=(a===2&&Ir(o)?29:$r[a])}function et(s,e){if(s&&e)return s>e?1:s<e?-1:0}var Xe=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function Je(s){return function(o){let a=Xe.exec(o);if(!a)return!1;let d=+a[1],p=+a[2],t=+a[3],i=a[4],l=a[5]==="-"?-1:1,r=+(a[6]||0),n=+(a[7]||0);if(r>23||n>59||s&&!i)return!1;if(d<=23&&p<=59&&t<60)return!0;let m=p-n*l,y=d-r*l-(m<0?1:0);return(y===23||y===-1)&&(m===59||m===-1)&&t<61}}function tt(s,e){if(!(s&&e))return;let o=new Date("2020-01-01T"+s).valueOf(),a=new Date("2020-01-01T"+e).valueOf();if(o&&a)return o-a}function Pt(s,e){if(!(s&&e))return;let o=Xe.exec(s),a=Xe.exec(e);if(o&&a)return s=o[1]+o[2]+o[3],e=a[1]+a[2]+a[3],s>e?1:s<e?-1:0}var Qe=/t|\s/i;function bt(s){let e=Je(s);return function(a){let d=a.split(Qe);return d.length===2&&Et(d[0])&&e(d[1])}}function At(s,e){if(!(s&&e))return;let o=new Date(s).valueOf(),a=new Date(e).valueOf();if(o&&a)return o-a}function Tt(s,e){if(!(s&&e))return;let[o,a]=s.split(Qe),[d,p]=e.split(Qe),t=et(o,d);if(t!==void 0)return t||tt(a,p)}var Lr=/\/|:/,jr=/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;function Nr(s){return Lr.test(s)&&jr.test(s)}var _t=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function Hr(s){return _t.lastIndex=0,_t.test(s)}var Fr=-(2**31),Ur=2**31-1;function Vr(s){return Number.isInteger(s)&&s<=Ur&&s>=Fr}function zr(s){return Number.isInteger(s)}function kt(){return!0}var Br=/[^\\]\\Z/;function Kr(s){if(Br.test(s))return!1;try{return new RegExp(s),!0}catch{return!1}}});var Dt=pt(rt=>{"use strict";Object.defineProperty(rt,"__esModule",{value:!0});function xt(s){let e=s.length,o=0,a=0,d;for(;a<e;)o++,d=s.charCodeAt(a++),d>=55296&&d<=56319&&a<e&&(d=s.charCodeAt(a),(d&64512)===56320&&a++);return o}rt.default=xt;xt.code='require("ajv/dist/runtime/ucs2length").default'});var ys={};mr(ys,{ALREADY_DEFINED_CODE:()=>ze,DecisionElement:()=>z,ELEMENT_NAME:()=>J,OapAuthorizationDenied:()=>te,OapDenied:()=>U,OapIntentDenied:()=>re,OapSequenceDenied:()=>se,OapTrajectoryDenied:()=>Y,Overturo:()=>de,OverturoApiError:()=>b,OverturoError:()=>P,OverturoNetworkError:()=>H,OverturoTimeoutError:()=>F,OverturoValidationError:()=>c,createSetupEmbed:()=>He,createSetupPopup:()=>Fe,default:()=>de,registerDecisionElement:()=>pe,setupRedirect:()=>Ue});var f={READY:"overturo:ready",STATE:"overturo:state",COMPLETE:"overturo:complete",CANCEL:"overturo:cancel",ERROR:"overturo:error",RESIZE:"overturo:resize",DEADLINE:"overturo:deadline"},N={width:"100%",minHeight:"400px",maxHeight:"none",border:"none",borderRadius:"0",background:"transparent"},ut=Object.keys(N),K={width:500,height:700},T={READY:"overturoid:ready",RESIZE:"overturoid:resize",STEP:"overturoid:setup:step",CREATED:"overturoid:setup:created",CANCEL:"overturoid:cancel",ERROR:"overturoid:error",PING:"overturoid:ping",HEARTBEAT:"overturoid:heartbeat"},Ye={width:600,height:800},ue="/api/v1/consent_sessions",D="/api/v1/decisions",ct="/decisions",Ge="/api/v1/meeting_consents",mt="/api/v1/accord_setup_sessions",We="/api/v1/preview_tokens",ft="https://overturo.com",hr="overturo:";function ee(s){let e=s?.type;return typeof e=="string"&&!e.startsWith(hr)}var yt=3e4,ce="overturo-consent-field";var P=class extends Error{constructor(e){super(e),this.name="OverturoError"}},c=class extends P{constructor(e){super(e),this.name="OverturoValidationError"}},b=class extends P{constructor(e,o,a){super(e),this.name="OverturoApiError",this.status=o,this.body=a}},H=class extends P{constructor(e,o){super(e),this.name="OverturoNetworkError",this.cause=o}},F=class extends P{constructor(e="Operation timed out"){super(e),this.name="OverturoTimeoutError"}},U=class s extends b{constructor(e,o,a){super(e.message,o,a),this.name="OapDenied",this.reason_code=e.reason_code,this.failed_bound=e.failed_bound,this.denial_category=e.denial_category,this.cascade_step=e.cascade_step,this.detail=e.detail}static fromEnvelope(e,o,a){if(e.reason_code==="sequence_prohibited"||e.reason_code==="sequence_missing_predecessor")return new se(e,o,a);switch(e.denial_category){case"authorization_denied":return new te(e,o,a);case"intent_denied":return new re(e,o,a);case"trajectory_denied":return new Y(e,o,a);default:return new s(e,o,a)}}},te=class extends U{constructor(e,o,a){super(e,o,a),this.name="OapAuthorizationDenied"}},re=class extends U{constructor(e,o,a){super(e,o,a),this.name="OapIntentDenied"}},Y=class extends U{constructor(e,o,a){super(e,o,a),this.name="OapTrajectoryDenied"}},se=class extends Y{constructor(e,o,a){super(e,o,a),this.name="OapSequenceDenied"}};function ye(s,e){if(s&&typeof s=="object"){let o=s.error;if(typeof o=="string"&&o.length>0)return o;if(o&&typeof o=="object"){let d=o;if(typeof d.message=="string"&&d.message.length>0)return typeof d.code=="string"&&d.code.length>0?`${d.code}: ${d.message}`:d.message;if(d.errors&&typeof d.errors=="object"){let p=Object.keys(d.errors)[0];if(p){let t=d.errors[p],i=Array.isArray(t)?t[0]:t;if(typeof i=="string")return`${typeof d.code=="string"&&d.code.length>0?`${d.code}: `:""}${p} ${i}`}}if(typeof d.code=="string"&&d.code.length>0)return d.code}let a=s.message;if(typeof a=="string"&&a.length>0)return a}return`HTTP ${e}`}function gr(s){return s.replace(/[A-Z]/g,e=>`_${e.toLowerCase()}`)}function vr(s){return s.replace(/_([a-z])/g,(e,o)=>o.toUpperCase())}function me(s){if(Array.isArray(s))return s.map(me);if(s!==null&&typeof s=="object"){let e={};for(let[o,a]of Object.entries(s))e[gr(o)]=me(a);return e}return s}function G(s){if(Array.isArray(s))return s.map(G);if(s!==null&&typeof s=="object"){let e={};for(let[o,a]of Object.entries(s))e[vr(o)]=G(a);return e}return s}var fe=class{constructor(e){this.baseUrl=e.baseUrl,this.publishableKey=e.publishableKey,this.apiKey=e.apiKey,this.timeout=e.timeout??yt}async get(e){return this.request("GET",e)}async post(e,o){return this.request("POST",e,o)}async rawGet(e){return this.rawRequest("GET",e)}async rawPost(e,o){return this.rawRequest("POST",e,o)}async rawRequest(e,o,a){let d=`${this.baseUrl}${o}`,p={"Content-Type":"application/json","X-Publishable-Key":this.publishableKey};this.apiKey&&(p.Authorization=`Bearer ${this.apiKey}`);let t=new AbortController,i;this.timeout>0&&(i=setTimeout(()=>t.abort(),this.timeout));try{return await fetch(d,{method:e,headers:p,body:a===void 0?void 0:JSON.stringify(me(a)),signal:t.signal})}catch(l){throw l instanceof DOMException&&l.name==="AbortError"?new F(`Request timed out after ${this.timeout}ms`):new H("Network request failed",l)}finally{i!==void 0&&clearTimeout(i)}}async request(e,o,a){let d=`${this.baseUrl}${o}`,p={"Content-Type":"application/json","X-Publishable-Key":this.publishableKey};this.apiKey&&(p.Authorization=`Bearer ${this.apiKey}`);let t=new AbortController,i;this.timeout>0&&(i=setTimeout(()=>t.abort(),this.timeout));let l;try{l=await fetch(d,{method:e,headers:p,body:a?JSON.stringify(me(a)):void 0,signal:t.signal})}catch(n){throw n instanceof DOMException&&n.name==="AbortError"?new F(`Request timed out after ${this.timeout}ms`):new H("Network request failed",n)}finally{i!==void 0&&clearTimeout(i)}if(!l.ok){let n;try{n=await l.json()}catch{n=null}let m=ye(n,l.status);throw new b(m,l.status,n)}let r=await l.text();return r?G(JSON.parse(r)):{}}};var C,ne,he=class{constructor(e,o){h(this,C);h(this,ne);g(this,C,e),g(this,ne,o)}async open(e){if(!e.escalationId)throw new c("escalationId is required");let o=e.mode??"embed",a=await u(this,C).createSession({kind:"approval",subjectRef:e.escalationId,mode:o,embedOrigin:e.embedOrigin,state:e.state,redirectUri:e.redirectUri});if(o==="popup")return u(this,C).popup({token:a.token,onComplete:d=>{d.kind==="approval"&&e.onComplete?.(d)},onCancel:e.onCancel,onError:e.onError});if(o==="redirect"){let d=u(this,C).url({token:a.token,mode:"redirect"});return window.location.href=d,{token:a.token,mode:"redirect",destroy:async()=>{}}}return u(this,C).embed({token:a.token,container:e.container,style:e.style,loading:e.loading,onReady:e.onReady,onState:(d,p)=>e.onState?.(p),onComplete:d=>{d.kind==="approval"&&e.onComplete?.(d)},onCancel:e.onCancel,onError:e.onError,onDeadline:e.onDeadline,onCounter:e.onCounter})}url(e){return u(this,C).url({token:e.escalationId,mode:e.mode})}async deadline(e){if(!e)throw new c("token is required for deadline");let o=await u(this,ne).get(`${D}/${e}`);return{remainingMs:Math.max(0,new Date(o.deadlineAt).getTime()-Date.now()),deadlineAt:o.deadlineAt}}};C=new WeakMap,ne=new WeakMap;var S,ge=class{constructor(e){h(this,S);g(this,S,e)}async open(e){if(!e.flowId)throw new c("flowId is required");let o=e.mode??"embed",a=await u(this,S).createSession({kind:"consent",subjectRef:e.flowId,mode:o,embedOrigin:e.embedOrigin,scope:e.scope,state:e.state,nonce:e.nonce,redirectUri:e.redirectUri});if(o==="popup")return u(this,S).popup({token:a.token,onComplete:d=>{d.kind==="consent"&&e.onComplete?.(d)},onCancel:e.onCancel,onError:e.onError});if(o==="redirect"){let d=u(this,S).url({token:a.token,mode:"redirect"});return window.location.href=d,{token:a.token,mode:"redirect",destroy:async()=>{}}}return u(this,S).embed({token:a.token,container:e.container,style:e.style,loading:e.loading,onReady:e.onReady,onState:(d,p)=>e.onStep?.(p),onComplete:d=>{d.kind==="consent"&&e.onComplete?.(d)},onCancel:e.onCancel,onError:e.onError})}url(e){return u(this,S).url({token:e.flowId,mode:e.mode})}discover(e){return u(this,S).discover(e)}};S=new WeakMap;var wr="overturo_capture_token",ve="overturoCaptured",br=5e3,Ze=new WeakMap;function ht(s,e,o){if(Ze.has(s))throw new c("duplicate_attach: this form already has a capture interception; detach it before attaching again");Ze.set(s,!0);let a=!1,d=e.tokenFieldName??wr,p=t=>{if(s.dataset[ve]==="1"){delete s.dataset[ve];return}if(t.preventDefault(),t.stopImmediatePropagation(),a)return;a=!0,s.querySelector(`input[name="${d}"]`)?.remove();let i=t.submitter??null;(async()=>{try{let{token:l}=await _r(o({submitter:i}),br);Er(s,d,l)}catch(l){e.onError?.(l)}finally{a=!1,e.submitAfterCapture!==!1&&(s.dataset[ve]="1",kr(s,i))}})()};return s.addEventListener("submit",p,{capture:!0}),()=>{Ze.delete(s),s.removeEventListener("submit",p,{capture:!0}),delete s.dataset[ve],s.querySelector(`input[name="${d}"]`)?.remove()}}function _r(s,e){return new Promise((o,a)=>{let d=setTimeout(()=>a(new c(`capture timed out after ${e} ms; the form submits without a capture token`)),e);s.then(p=>{clearTimeout(d),o(p)},p=>{clearTimeout(d),a(p)})})}function kr(s,e){if(e&&e.isConnected&&typeof s.requestSubmit=="function")try{s.requestSubmit(e);return}catch{}typeof s.requestSubmit=="function"?s.requestSubmit():e&&typeof e.click=="function"?e.click():s.submit()}function gt(s){let e=typeof s=="string"?document.querySelector(s):s;if(!(e instanceof HTMLFormElement))throw new c("form must resolve to a <form> element");return e}function Er(s,e,o){let a=s.querySelector(`input[name="${e}"]`);a||(a=document.createElement("input"),a.type="hidden",a.name=e,s.appendChild(a)),a.value=o}function W(s,e){let o=s.querySelector(e);return o instanceof HTMLInputElement?o:null}function Pr(s,e){return!s||s.type!=="checkbox"&&s.type!=="radio"?{decision:"declined",default_checked:!1,mandatory:!1}:{decision:s.checked?"granted":"declined",default_checked:s.defaultChecked||e===!0,mandatory:Ar(s)}}function Ar(s){if(!s.required)return!1;if(s.type!=="radio"||!s.name)return!0;let e=s.form??s.ownerDocument;return Array.from(e.querySelectorAll('input[type="radio"]')).filter(a=>a.name===s.name).length<=1}function vt(s,e,o={}){let a={};for(let[d,p]of Object.entries(e))a[d]=Pr(W(s,p),o[d]);return a}var Tr="input, textarea, select",Sr=/^on/i,qr=new Set(["title","aria-label","aria-description"]);function wt(s,e){let o=s.cloneNode(!0),a=new Set;for(let p of e){let t=o.querySelector(p);t&&a.add(t)}o.querySelectorAll("script, style, iframe, object, embed").forEach(p=>p.remove()),[o,...Array.from(o.querySelectorAll("*"))].forEach(p=>{for(let t of Array.from(p.attributes)){let i=t.name.toLowerCase();(Sr.test(i)||i==="srcdoc"||i.startsWith("data-")||qr.has(i))&&p.removeAttribute(t.name)}}),o.querySelectorAll(Tr).forEach(p=>{let t=p;if(a.has(t)){let i=t;i.checked?i.setAttribute("checked",""):i.removeAttribute("checked"),t.removeAttribute("value");return}t.removeAttribute("value"),t.removeAttribute("placeholder"),t instanceof HTMLTextAreaElement&&(t.textContent=""),t instanceof HTMLSelectElement&&t.querySelectorAll("option").forEach(i=>{i.removeAttribute("selected"),i.removeAttribute("value")}),t instanceof HTMLInputElement&&(t.removeAttribute("checked"),t.type==="hidden"&&t.remove())});let d=o.outerHTML;return xr(d,16384)}function xr(s,e){let o=new TextEncoder;if(o.encode(s).byteLength<=e)return s;let a=s;for(;o.encode(a).byteLength>e;)a=a.slice(0,Math.floor(a.length*.9));return a}var Dr="/api/v1/decisions/capture",we=class{constructor(e,o,a,d){this.api=e;this.decisions=o;this.flowBaseUrl=a;this.publishableKey=d}attach(e){if(!e.flowId)throw new c("flowId is required");let o=gt(e.form);if(e.field)return this.attachField(o,e);let a=e.map;if(!a||Object.keys(a).length===0)throw new c("map must name at least one purpose (or pass field)");let d=Or(o,a);return e.wording&&this.writeWording(o,e),ht(o,e,async()=>{let p=Object.entries(a).filter(([,n])=>!W(o,n));if(p.length)throw new c(`consent control not found for: ${p.map(([n])=>n).join(", ")}`);let t=this.buildCaptureBody(o,e,d),i=await this.labelDigests(o,e);i&&(t.noticeHashes=i);let l=await this.api.post(Dr,t),r={token:l.capture.sessionToken,attestationId:l.capture.attestationId,committed:l.capture.committed,wordingVerdict:l.capture.wordingVerdict??null,recordId:l.capture.recordId??null};return e.onCaptured?.(r),{token:r.token}})}attachField(e,o){let a=Rr(e,o.field),d=a.getAttribute("flow");if(d&&d!==o.flowId)throw new c("the field's flow attribute must match flowId");if(Array.from(e.querySelectorAll(ce)).some(t=>t!==a&&(t.getAttribute("flow")||o.flowId)===o.flowId))throw new c("duplicate_field: one consent field per flow per form");return a.attachTo(e,o,{flowBaseUrl:this.flowBaseUrl,publishableKey:this.publishableKey})}buildCaptureBody(e,o,a={}){let d=W(e,o.subjectField),p=o.externalIdField?W(e,o.externalIdField):null,t=o.map??{},i={flowId:o.flowId,decisions:vt(e,t,a),subject:{email:d?.value?.trim()||void 0,externalId:p?.value?.trim()||void 0},snapshot:wt(e,Object.values(t)),pageUrl:typeof window<"u"?window.location.href:void 0,formId:e.getAttribute("id")||void 0};return o.commit&&(i.commit=!0),o.locale&&(i.locale=o.locale),i}async labelDigests(e,o){let a=o.labels??o.wording;if(!a||typeof crypto>"u"||!crypto.subtle)return;let d={};for(let[p,t]of Object.entries(a)){let i=e.querySelector(t)?.textContent?.trim();if(!i)continue;let l=await crypto.subtle.digest("SHA-256",new TextEncoder().encode(i));d[p]=Array.from(new Uint8Array(l)).map(r=>r.toString(16).padStart(2,"0")).join("")}return Object.keys(d).length?d:void 0}async writeWording(e,o){if(o.wording)try{let a=await this.decisions.discover({flowId:o.flowId,locale:o.locale});for(let[d,p]of Object.entries(o.wording)){let t=e.querySelector(p),i=a.purposes.find(l=>l.name===d);t&&i&&Cr(t,i.description??i.label)}}catch(a){o.onError?.(a)}}};function Cr(s,e){let o=Array.from(s.childNodes).filter(a=>a.nodeType===Node.TEXT_NODE);if(o.length===0||s.children.length===0){s.children.length===0?s.textContent=e:s.appendChild(document.createTextNode(" "+e));return}o.forEach((a,d)=>{a.textContent=d===0?e:""})}function Or(s,e){let o={};for(let[a,d]of Object.entries(e)){let p=W(s,d);p&&(o[a]=p.checked)}return o}function Rr(s,e){let o=typeof e=="string"?s.querySelector(e)||document.querySelector(e):e;if(!(o instanceof HTMLElement)||o.tagName.toLowerCase()!==ce)throw new c(`field must resolve to an <${ce}> element`);if(typeof o.attachTo!="function")throw new c("field_entry_not_loaded: load @overturo/js/field (overturo-field.js) before attaching a field");return o}var O,oe,be=class{constructor(e,o){h(this,O);h(this,oe);g(this,O,e),g(this,oe,o)}async open(e){if(!e.signatureRef)throw new c("signatureRef is required");let o=e.mode??"embed",a=await u(this,O).createSession({kind:"signature_request",subjectRef:e.signatureRef,mode:o,embedOrigin:e.embedOrigin,state:e.state,redirectUri:e.redirectUri});if(o==="popup")return u(this,O).popup({token:a.token,onComplete:d=>{d.kind==="signature_request"&&e.onComplete?.(d)},onCancel:e.onCancel,onError:e.onError});if(o==="redirect"){let d=u(this,O).url({token:a.token,mode:"redirect"});return window.location.href=d,{token:a.token,mode:"redirect",destroy:async()=>{}}}return u(this,O).embed({token:a.token,container:e.container,style:e.style,loading:e.loading,onReady:e.onReady,onState:(d,p)=>e.onState?.(p),onComplete:d=>{d.kind==="signature_request"&&e.onComplete?.(d)},onCancel:e.onCancel,onError:e.onError,onDeadline:e.onDeadline,onCounter:e.onCounter})}url(e){return u(this,O).url({token:e.signatureRef,mode:e.mode})}async deadline(e){if(!e)throw new c("token is required for deadline");let o=await u(this,oe).get(`${D}/${e}`);return{remainingMs:Math.max(0,new Date(o.deadlineAt).getTime()-Date.now()),deadlineAt:o.deadlineAt}}};O=new WeakMap,oe=new WeakMap;function Z(s){if(typeof s=="string"){let e=document.querySelector(s);if(!e)throw new c(`Container element not found: "${s}"`);return e}return s}function X(s,e,o){let a={...e};if(o)for(let d of ut)d in o&&(a[d]=o[d]);for(let[d,p]of Object.entries(a))s.style[d]=p}var qt=_e,St={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://schemas.overturo.com/postmessage-v2/envelope.json",title:"TrustSurface postMessage envelope v2",type:"object",additionalProperties:!1,required:["type","kind","version","payload","ts","message_id"],properties:{type:{type:"string",enum:["overturo:ready","overturo:state","overturo:complete","overturo:cancel","overturo:error","overturo:resize","overturo:deadline"]},kind:{type:"string",enum:["consent","approval","signature_request"]},version:{type:"integer",const:2},payload:{type:"object",additionalProperties:!0},ts:{type:"string",format:"date-time"},message_id:{type:"string",pattern:"^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"}}},Yr=R().fullFormats["date-time"],Gr=new RegExp("^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$","u");function _e(s,{instancePath:e="",parentData:o,parentDataProperty:a,rootData:d=s,dynamicAnchors:p={}}={}){let t=null,i=0,l=_e.evaluated;if(l.dynamicProps&&(l.props=void 0),l.dynamicItems&&(l.items=void 0),s&&typeof s=="object"&&!Array.isArray(s)){if(s.type===void 0){let r={instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:"type"},message:"must have required property 'type'"};t===null?t=[r]:t.push(r),i++}if(s.kind===void 0){let r={instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:"kind"},message:"must have required property 'kind'"};t===null?t=[r]:t.push(r),i++}if(s.version===void 0){let r={instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:"version"},message:"must have required property 'version'"};t===null?t=[r]:t.push(r),i++}if(s.payload===void 0){let r={instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:"payload"},message:"must have required property 'payload'"};t===null?t=[r]:t.push(r),i++}if(s.ts===void 0){let r={instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:"ts"},message:"must have required property 'ts'"};t===null?t=[r]:t.push(r),i++}if(s.message_id===void 0){let r={instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:"message_id"},message:"must have required property 'message_id'"};t===null?t=[r]:t.push(r),i++}for(let r in s)if(!(r==="type"||r==="kind"||r==="version"||r==="payload"||r==="ts"||r==="message_id")){let n={instancePath:e,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:r},message:"must NOT have additional properties"};t===null?t=[n]:t.push(n),i++}if(s.type!==void 0){let r=s.type;if(typeof r!="string"){let n={instancePath:e+"/type",schemaPath:"#/properties/type/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[n]:t.push(n),i++}if(!(r==="overturo:ready"||r==="overturo:state"||r==="overturo:complete"||r==="overturo:cancel"||r==="overturo:error"||r==="overturo:resize"||r==="overturo:deadline")){let n={instancePath:e+"/type",schemaPath:"#/properties/type/enum",keyword:"enum",params:{allowedValues:St.properties.type.enum},message:"must be equal to one of the allowed values"};t===null?t=[n]:t.push(n),i++}}if(s.kind!==void 0){let r=s.kind;if(typeof r!="string"){let n={instancePath:e+"/kind",schemaPath:"#/properties/kind/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[n]:t.push(n),i++}if(!(r==="consent"||r==="approval"||r==="signature_request")){let n={instancePath:e+"/kind",schemaPath:"#/properties/kind/enum",keyword:"enum",params:{allowedValues:St.properties.kind.enum},message:"must be equal to one of the allowed values"};t===null?t=[n]:t.push(n),i++}}if(s.version!==void 0){let r=s.version;if(!(typeof r=="number"&&!(r%1)&&!isNaN(r))){let n={instancePath:e+"/version",schemaPath:"#/properties/version/type",keyword:"type",params:{type:"integer"},message:"must be integer"};t===null?t=[n]:t.push(n),i++}if(r!==2){let n={instancePath:e+"/version",schemaPath:"#/properties/version/const",keyword:"const",params:{allowedValue:2},message:"must be equal to constant"};t===null?t=[n]:t.push(n),i++}}if(s.payload!==void 0){let r=s.payload;if(!(r&&typeof r=="object"&&!Array.isArray(r))){let n={instancePath:e+"/payload",schemaPath:"#/properties/payload/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[n]:t.push(n),i++}}if(s.ts!==void 0){let r=s.ts;if(typeof r=="string"){if(!Yr.validate(r)){let n={instancePath:e+"/ts",schemaPath:"#/properties/ts/format",keyword:"format",params:{format:"date-time"},message:'must match format "date-time"'};t===null?t=[n]:t.push(n),i++}}else{let n={instancePath:e+"/ts",schemaPath:"#/properties/ts/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[n]:t.push(n),i++}}if(s.message_id!==void 0){let r=s.message_id;if(typeof r=="string"){if(!Gr.test(r)){let n={instancePath:e+"/message_id",schemaPath:"#/properties/message_id/pattern",keyword:"pattern",params:{pattern:"^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"},message:'must match pattern "^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"'};t===null?t=[n]:t.push(n),i++}}else{let n={instancePath:e+"/message_id",schemaPath:"#/properties/message_id/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[n]:t.push(n),i++}}}else{let r={instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[r]:t.push(r),i++}return _e.errors=t,i===0}_e.evaluated={props:!0,dynamicProps:!1,dynamicItems:!1};var Ot=ke,ie={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://schemas.overturo.com/postmessage-v2/ready.json",title:"READY payload (kind-agnostic; branding fields vary per application)",type:"object",additionalProperties:!0,required:["kind","session_token","deadline_at","branding","mode","locale"],properties:{kind:{type:"string",enum:["consent","approval","signature_request"]},session_token:{type:"string",minLength:43,maxLength:43},deadline_at:{type:["string","null"],format:"date-time"},branding:{type:"object",additionalProperties:!0,required:["application_name"],properties:{application_name:{type:"string"},logo_url:{type:["string","null"]},primary_color:{type:["string","null"]}}},mode:{type:"string",enum:["embed","popup","redirect"]},locale:{type:"string"}}},Ct=Dt().default,Wr=R().fullFormats["date-time"];function ke(s,{instancePath:e="",parentData:o,parentDataProperty:a,rootData:d=s,dynamicAnchors:p={}}={}){let t=null,i=0,l=ke.evaluated;if(l.dynamicProps&&(l.props=void 0),l.dynamicItems&&(l.items=void 0),s&&typeof s=="object"&&!Array.isArray(s)){if(s.kind===void 0){let r={instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:"kind"},message:"must have required property 'kind'"};t===null?t=[r]:t.push(r),i++}if(s.session_token===void 0){let r={instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:"session_token"},message:"must have required property 'session_token'"};t===null?t=[r]:t.push(r),i++}if(s.deadline_at===void 0){let r={instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:"deadline_at"},message:"must have required property 'deadline_at'"};t===null?t=[r]:t.push(r),i++}if(s.branding===void 0){let r={instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:"branding"},message:"must have required property 'branding'"};t===null?t=[r]:t.push(r),i++}if(s.mode===void 0){let r={instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:"mode"},message:"must have required property 'mode'"};t===null?t=[r]:t.push(r),i++}if(s.locale===void 0){let r={instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:"locale"},message:"must have required property 'locale'"};t===null?t=[r]:t.push(r),i++}if(s.kind!==void 0){let r=s.kind;if(typeof r!="string"){let n={instancePath:e+"/kind",schemaPath:"#/properties/kind/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[n]:t.push(n),i++}if(!(r==="consent"||r==="approval"||r==="signature_request")){let n={instancePath:e+"/kind",schemaPath:"#/properties/kind/enum",keyword:"enum",params:{allowedValues:ie.properties.kind.enum},message:"must be equal to one of the allowed values"};t===null?t=[n]:t.push(n),i++}}if(s.session_token!==void 0){let r=s.session_token;if(typeof r=="string"){if(Ct(r)>43){let n={instancePath:e+"/session_token",schemaPath:"#/properties/session_token/maxLength",keyword:"maxLength",params:{limit:43},message:"must NOT have more than 43 characters"};t===null?t=[n]:t.push(n),i++}if(Ct(r)<43){let n={instancePath:e+"/session_token",schemaPath:"#/properties/session_token/minLength",keyword:"minLength",params:{limit:43},message:"must NOT have fewer than 43 characters"};t===null?t=[n]:t.push(n),i++}}else{let n={instancePath:e+"/session_token",schemaPath:"#/properties/session_token/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[n]:t.push(n),i++}}if(s.deadline_at!==void 0){let r=s.deadline_at;if(typeof r!="string"&&r!==null){let n={instancePath:e+"/deadline_at",schemaPath:"#/properties/deadline_at/type",keyword:"type",params:{type:ie.properties.deadline_at.type},message:"must be string,null"};t===null?t=[n]:t.push(n),i++}if(typeof r=="string"&&!Wr.validate(r)){let n={instancePath:e+"/deadline_at",schemaPath:"#/properties/deadline_at/format",keyword:"format",params:{format:"date-time"},message:'must match format "date-time"'};t===null?t=[n]:t.push(n),i++}}if(s.branding!==void 0){let r=s.branding;if(r&&typeof r=="object"&&!Array.isArray(r)){if(r.application_name===void 0){let n={instancePath:e+"/branding",schemaPath:"#/properties/branding/required",keyword:"required",params:{missingProperty:"application_name"},message:"must have required property 'application_name'"};t===null?t=[n]:t.push(n),i++}if(r.application_name!==void 0&&typeof r.application_name!="string"){let n={instancePath:e+"/branding/application_name",schemaPath:"#/properties/branding/properties/application_name/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[n]:t.push(n),i++}if(r.logo_url!==void 0){let n=r.logo_url;if(typeof n!="string"&&n!==null){let m={instancePath:e+"/branding/logo_url",schemaPath:"#/properties/branding/properties/logo_url/type",keyword:"type",params:{type:ie.properties.branding.properties.logo_url.type},message:"must be string,null"};t===null?t=[m]:t.push(m),i++}}if(r.primary_color!==void 0){let n=r.primary_color;if(typeof n!="string"&&n!==null){let m={instancePath:e+"/branding/primary_color",schemaPath:"#/properties/branding/properties/primary_color/type",keyword:"type",params:{type:ie.properties.branding.properties.primary_color.type},message:"must be string,null"};t===null?t=[m]:t.push(m),i++}}}else{let n={instancePath:e+"/branding",schemaPath:"#/properties/branding/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[n]:t.push(n),i++}}if(s.mode!==void 0){let r=s.mode;if(typeof r!="string"){let n={instancePath:e+"/mode",schemaPath:"#/properties/mode/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[n]:t.push(n),i++}if(!(r==="embed"||r==="popup"||r==="redirect")){let n={instancePath:e+"/mode",schemaPath:"#/properties/mode/enum",keyword:"enum",params:{allowedValues:ie.properties.mode.enum},message:"must be equal to one of the allowed values"};t===null?t=[n]:t.push(n),i++}}if(s.locale!==void 0&&typeof s.locale!="string"){let r={instancePath:e+"/locale",schemaPath:"#/properties/locale/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[r]:t.push(r),i++}}else{let r={instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[r]:t.push(r),i++}return ke.errors=t,i===0}ke.evaluated={props:!0,dynamicProps:!1,dynamicItems:!1};var Rt=Ee;function Ee(s,{instancePath:e="",parentData:o,parentDataProperty:a,rootData:d=s,dynamicAnchors:p={}}={}){let t=null,i=0,l=Ee.evaluated;if(l.dynamicProps&&(l.props=void 0),l.dynamicItems&&(l.items=void 0),s&&typeof s=="object"&&!Array.isArray(s)){if(s.height===void 0){let r={instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:"height"},message:"must have required property 'height'"};t===null?t=[r]:t.push(r),i++}if(s.height!==void 0){let r=s.height;if(!(typeof r=="number"&&!(r%1)&&!isNaN(r))){let n={instancePath:e+"/height",schemaPath:"#/properties/height/type",keyword:"type",params:{type:"integer"},message:"must be integer"};t===null?t=[n]:t.push(n),i++}if(typeof r=="number"&&(r<0||isNaN(r))){let n={instancePath:e+"/height",schemaPath:"#/properties/height/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};t===null?t=[n]:t.push(n),i++}}}else{let r={instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[r]:t.push(r),i++}return Ee.errors=t,i===0}Ee.evaluated={props:!0,dynamicProps:!1,dynamicItems:!1};var Mt=Pe,It={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://schemas.overturo.com/postmessage-v2/cancel.json",title:"CANCEL payload (kind-agnostic \u2014 bidirectional)",type:"object",additionalProperties:!0,required:["reason","cancelled_by"],properties:{reason:{type:"string",enum:["user_declined","principal_navigated_away","host_requested","system_revoked"]},cancelled_by:{type:"string",enum:["principal","host","system"]}}};function Pe(s,{instancePath:e="",parentData:o,parentDataProperty:a,rootData:d=s,dynamicAnchors:p={}}={}){let t=null,i=0,l=Pe.evaluated;if(l.dynamicProps&&(l.props=void 0),l.dynamicItems&&(l.items=void 0),s&&typeof s=="object"&&!Array.isArray(s)){if(s.reason===void 0){let r={instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:"reason"},message:"must have required property 'reason'"};t===null?t=[r]:t.push(r),i++}if(s.cancelled_by===void 0){let r={instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:"cancelled_by"},message:"must have required property 'cancelled_by'"};t===null?t=[r]:t.push(r),i++}if(s.reason!==void 0){let r=s.reason;if(typeof r!="string"){let n={instancePath:e+"/reason",schemaPath:"#/properties/reason/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[n]:t.push(n),i++}if(!(r==="user_declined"||r==="principal_navigated_away"||r==="host_requested"||r==="system_revoked")){let n={instancePath:e+"/reason",schemaPath:"#/properties/reason/enum",keyword:"enum",params:{allowedValues:It.properties.reason.enum},message:"must be equal to one of the allowed values"};t===null?t=[n]:t.push(n),i++}}if(s.cancelled_by!==void 0){let r=s.cancelled_by;if(typeof r!="string"){let n={instancePath:e+"/cancelled_by",schemaPath:"#/properties/cancelled_by/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[n]:t.push(n),i++}if(!(r==="principal"||r==="host"||r==="system")){let n={instancePath:e+"/cancelled_by",schemaPath:"#/properties/cancelled_by/enum",keyword:"enum",params:{allowedValues:It.properties.cancelled_by.enum},message:"must be equal to one of the allowed values"};t===null?t=[n]:t.push(n),i++}}}else{let r={instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[r]:t.push(r),i++}return Pe.errors=t,i===0}Pe.evaluated={props:!0,dynamicProps:!1,dynamicItems:!1};var $t=Ae,Zr={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://schemas.overturo.com/postmessage-v2/consent/state.json",title:"consent STATE payload",type:"object",additionalProperties:!0,required:["from","to","step_index","total_steps"],properties:{from:{type:["string","null"]},to:{type:"string"},step_index:{type:"integer",minimum:0},total_steps:{type:"integer",minimum:1},kind_payload:{type:"object",additionalProperties:!0}}};function Ae(s,{instancePath:e="",parentData:o,parentDataProperty:a,rootData:d=s,dynamicAnchors:p={}}={}){let t=null,i=0,l=Ae.evaluated;if(l.dynamicProps&&(l.props=void 0),l.dynamicItems&&(l.items=void 0),s&&typeof s=="object"&&!Array.isArray(s)){if(s.from===void 0){let r={instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:"from"},message:"must have required property 'from'"};t===null?t=[r]:t.push(r),i++}if(s.to===void 0){let r={instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:"to"},message:"must have required property 'to'"};t===null?t=[r]:t.push(r),i++}if(s.step_index===void 0){let r={instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:"step_index"},message:"must have required property 'step_index'"};t===null?t=[r]:t.push(r),i++}if(s.total_steps===void 0){let r={instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:"total_steps"},message:"must have required property 'total_steps'"};t===null?t=[r]:t.push(r),i++}if(s.from!==void 0){let r=s.from;if(typeof r!="string"&&r!==null){let n={instancePath:e+"/from",schemaPath:"#/properties/from/type",keyword:"type",params:{type:Zr.properties.from.type},message:"must be string,null"};t===null?t=[n]:t.push(n),i++}}if(s.to!==void 0&&typeof s.to!="string"){let r={instancePath:e+"/to",schemaPath:"#/properties/to/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[r]:t.push(r),i++}if(s.step_index!==void 0){let r=s.step_index;if(!(typeof r=="number"&&!(r%1)&&!isNaN(r))){let n={instancePath:e+"/step_index",schemaPath:"#/properties/step_index/type",keyword:"type",params:{type:"integer"},message:"must be integer"};t===null?t=[n]:t.push(n),i++}if(typeof r=="number"&&(r<0||isNaN(r))){let n={instancePath:e+"/step_index",schemaPath:"#/properties/step_index/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};t===null?t=[n]:t.push(n),i++}}if(s.total_steps!==void 0){let r=s.total_steps;if(!(typeof r=="number"&&!(r%1)&&!isNaN(r))){let n={instancePath:e+"/total_steps",schemaPath:"#/properties/total_steps/type",keyword:"type",params:{type:"integer"},message:"must be integer"};t===null?t=[n]:t.push(n),i++}if(typeof r=="number"&&(r<1||isNaN(r))){let n={instancePath:e+"/total_steps",schemaPath:"#/properties/total_steps/minimum",keyword:"minimum",params:{comparison:">=",limit:1},message:"must be >= 1"};t===null?t=[n]:t.push(n),i++}}if(s.kind_payload!==void 0){let r=s.kind_payload;if(!(r&&typeof r=="object"&&!Array.isArray(r))){let n={instancePath:e+"/kind_payload",schemaPath:"#/properties/kind_payload/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[n]:t.push(n),i++}}}else{let r={instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[r]:t.push(r),i++}return Ae.errors=t,i===0}Ae.evaluated={props:!0,dynamicProps:!1,dynamicItems:!1};var jt=Te,Lt={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://schemas.overturo.com/postmessage-v2/consent/complete.json",title:"consent COMPLETE payload",type:"object",additionalProperties:!0,required:["outcome","completed_at"],properties:{outcome:{type:"string",enum:["granted","declined"]},exchange_token:{type:["string","null"],description:"Consent token the host exchanges via POST /api/v1/decisions/:token/exchange"},completed_at:{type:"string",format:"date-time"}}},Xr=R().fullFormats["date-time"];function Te(s,{instancePath:e="",parentData:o,parentDataProperty:a,rootData:d=s,dynamicAnchors:p={}}={}){let t=null,i=0,l=Te.evaluated;if(l.dynamicProps&&(l.props=void 0),l.dynamicItems&&(l.items=void 0),s&&typeof s=="object"&&!Array.isArray(s)){if(s.outcome===void 0){let r={instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:"outcome"},message:"must have required property 'outcome'"};t===null?t=[r]:t.push(r),i++}if(s.completed_at===void 0){let r={instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:"completed_at"},message:"must have required property 'completed_at'"};t===null?t=[r]:t.push(r),i++}if(s.outcome!==void 0){let r=s.outcome;if(typeof r!="string"){let n={instancePath:e+"/outcome",schemaPath:"#/properties/outcome/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[n]:t.push(n),i++}if(!(r==="granted"||r==="declined")){let n={instancePath:e+"/outcome",schemaPath:"#/properties/outcome/enum",keyword:"enum",params:{allowedValues:Lt.properties.outcome.enum},message:"must be equal to one of the allowed values"};t===null?t=[n]:t.push(n),i++}}if(s.exchange_token!==void 0){let r=s.exchange_token;if(typeof r!="string"&&r!==null){let n={instancePath:e+"/exchange_token",schemaPath:"#/properties/exchange_token/type",keyword:"type",params:{type:Lt.properties.exchange_token.type},message:"must be string,null"};t===null?t=[n]:t.push(n),i++}}if(s.completed_at!==void 0){let r=s.completed_at;if(typeof r=="string"){if(!Xr.validate(r)){let n={instancePath:e+"/completed_at",schemaPath:"#/properties/completed_at/format",keyword:"format",params:{format:"date-time"},message:'must match format "date-time"'};t===null?t=[n]:t.push(n),i++}}else{let n={instancePath:e+"/completed_at",schemaPath:"#/properties/completed_at/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[n]:t.push(n),i++}}}else{let r={instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[r]:t.push(r),i++}return Te.errors=t,i===0}Te.evaluated={props:!0,dynamicProps:!1,dynamicItems:!1};var Ht=Se,Nt={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://schemas.overturo.com/postmessage-v2/consent/error.json",title:"consent ERROR payload",type:"object",additionalProperties:!0,required:["code","message","fatal"],properties:{code:{type:"string"},message:{type:"string"},fatal:{type:"boolean"},recoverable_via:{type:["string","null"],enum:["reload","new_session",null]}}};function Se(s,{instancePath:e="",parentData:o,parentDataProperty:a,rootData:d=s,dynamicAnchors:p={}}={}){let t=null,i=0,l=Se.evaluated;if(l.dynamicProps&&(l.props=void 0),l.dynamicItems&&(l.items=void 0),s&&typeof s=="object"&&!Array.isArray(s)){if(s.code===void 0){let r={instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:"code"},message:"must have required property 'code'"};t===null?t=[r]:t.push(r),i++}if(s.message===void 0){let r={instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:"message"},message:"must have required property 'message'"};t===null?t=[r]:t.push(r),i++}if(s.fatal===void 0){let r={instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:"fatal"},message:"must have required property 'fatal'"};t===null?t=[r]:t.push(r),i++}if(s.code!==void 0&&typeof s.code!="string"){let r={instancePath:e+"/code",schemaPath:"#/properties/code/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[r]:t.push(r),i++}if(s.message!==void 0&&typeof s.message!="string"){let r={instancePath:e+"/message",schemaPath:"#/properties/message/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[r]:t.push(r),i++}if(s.fatal!==void 0&&typeof s.fatal!="boolean"){let r={instancePath:e+"/fatal",schemaPath:"#/properties/fatal/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};t===null?t=[r]:t.push(r),i++}if(s.recoverable_via!==void 0){let r=s.recoverable_via;if(typeof r!="string"&&r!==null){let n={instancePath:e+"/recoverable_via",schemaPath:"#/properties/recoverable_via/type",keyword:"type",params:{type:Nt.properties.recoverable_via.type},message:"must be string,null"};t===null?t=[n]:t.push(n),i++}if(!(r==="reload"||r==="new_session"||r===null)){let n={instancePath:e+"/recoverable_via",schemaPath:"#/properties/recoverable_via/enum",keyword:"enum",params:{allowedValues:Nt.properties.recoverable_via.enum},message:"must be equal to one of the allowed values"};t===null?t=[n]:t.push(n),i++}}}else{let r={instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[r]:t.push(r),i++}return Se.errors=t,i===0}Se.evaluated={props:!0,dynamicProps:!1,dynamicItems:!1};var Ft=qe,Jr={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://schemas.overturo.com/postmessage-v2/consent/deadline.json",title:"consent DEADLINE payload",type:"object",additionalProperties:!0,required:["remaining_seconds","level","deadline_at"],properties:{remaining_seconds:{type:"integer",minimum:0},level:{type:"string",enum:["warning","expired"]},deadline_at:{type:"string",format:"date-time"}}},Qr=R().fullFormats["date-time"];function qe(s,{instancePath:e="",parentData:o,parentDataProperty:a,rootData:d=s,dynamicAnchors:p={}}={}){let t=null,i=0,l=qe.evaluated;if(l.dynamicProps&&(l.props=void 0),l.dynamicItems&&(l.items=void 0),s&&typeof s=="object"&&!Array.isArray(s)){if(s.remaining_seconds===void 0){let r={instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:"remaining_seconds"},message:"must have required property 'remaining_seconds'"};t===null?t=[r]:t.push(r),i++}if(s.level===void 0){let r={instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:"level"},message:"must have required property 'level'"};t===null?t=[r]:t.push(r),i++}if(s.deadline_at===void 0){let r={instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:"deadline_at"},message:"must have required property 'deadline_at'"};t===null?t=[r]:t.push(r),i++}if(s.remaining_seconds!==void 0){let r=s.remaining_seconds;if(!(typeof r=="number"&&!(r%1)&&!isNaN(r))){let n={instancePath:e+"/remaining_seconds",schemaPath:"#/properties/remaining_seconds/type",keyword:"type",params:{type:"integer"},message:"must be integer"};t===null?t=[n]:t.push(n),i++}if(typeof r=="number"&&(r<0||isNaN(r))){let n={instancePath:e+"/remaining_seconds",schemaPath:"#/properties/remaining_seconds/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};t===null?t=[n]:t.push(n),i++}}if(s.level!==void 0){let r=s.level;if(typeof r!="string"){let n={instancePath:e+"/level",schemaPath:"#/properties/level/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[n]:t.push(n),i++}if(!(r==="warning"||r==="expired")){let n={instancePath:e+"/level",schemaPath:"#/properties/level/enum",keyword:"enum",params:{allowedValues:Jr.properties.level.enum},message:"must be equal to one of the allowed values"};t===null?t=[n]:t.push(n),i++}}if(s.deadline_at!==void 0){let r=s.deadline_at;if(typeof r=="string"){if(!Qr.validate(r)){let n={instancePath:e+"/deadline_at",schemaPath:"#/properties/deadline_at/format",keyword:"format",params:{format:"date-time"},message:'must match format "date-time"'};t===null?t=[n]:t.push(n),i++}}else{let n={instancePath:e+"/deadline_at",schemaPath:"#/properties/deadline_at/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[n]:t.push(n),i++}}}else{let r={instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[r]:t.push(r),i++}return qe.errors=t,i===0}qe.evaluated={props:!0,dynamicProps:!1,dynamicItems:!1};var Ut=xe,st={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://schemas.overturo.com/postmessage-v2/approval/state.json",title:"approval STATE payload",type:"object",additionalProperties:!0,required:["from","to","kind_payload"],properties:{from:{type:["string","null"]},to:{type:"string",enum:["pending","opened","in_progress","approved","denied","expired"]},kind_payload:{type:"object",additionalProperties:!0,required:["agent_id","action_class","scope_invoked"],properties:{agent_id:{type:"string"},action_class:{type:"string"},bounded_authority:{type:"object",additionalProperties:!0},scope_invoked:{type:"string"},value_invoked:{type:["object","null"],additionalProperties:!0}}}}};function xe(s,{instancePath:e="",parentData:o,parentDataProperty:a,rootData:d=s,dynamicAnchors:p={}}={}){let t=null,i=0,l=xe.evaluated;if(l.dynamicProps&&(l.props=void 0),l.dynamicItems&&(l.items=void 0),s&&typeof s=="object"&&!Array.isArray(s)){if(s.from===void 0){let r={instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:"from"},message:"must have required property 'from'"};t===null?t=[r]:t.push(r),i++}if(s.to===void 0){let r={instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:"to"},message:"must have required property 'to'"};t===null?t=[r]:t.push(r),i++}if(s.kind_payload===void 0){let r={instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:"kind_payload"},message:"must have required property 'kind_payload'"};t===null?t=[r]:t.push(r),i++}if(s.from!==void 0){let r=s.from;if(typeof r!="string"&&r!==null){let n={instancePath:e+"/from",schemaPath:"#/properties/from/type",keyword:"type",params:{type:st.properties.from.type},message:"must be string,null"};t===null?t=[n]:t.push(n),i++}}if(s.to!==void 0){let r=s.to;if(typeof r!="string"){let n={instancePath:e+"/to",schemaPath:"#/properties/to/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[n]:t.push(n),i++}if(!(r==="pending"||r==="opened"||r==="in_progress"||r==="approved"||r==="denied"||r==="expired")){let n={instancePath:e+"/to",schemaPath:"#/properties/to/enum",keyword:"enum",params:{allowedValues:st.properties.to.enum},message:"must be equal to one of the allowed values"};t===null?t=[n]:t.push(n),i++}}if(s.kind_payload!==void 0){let r=s.kind_payload;if(r&&typeof r=="object"&&!Array.isArray(r)){if(r.agent_id===void 0){let n={instancePath:e+"/kind_payload",schemaPath:"#/properties/kind_payload/required",keyword:"required",params:{missingProperty:"agent_id"},message:"must have required property 'agent_id'"};t===null?t=[n]:t.push(n),i++}if(r.action_class===void 0){let n={instancePath:e+"/kind_payload",schemaPath:"#/properties/kind_payload/required",keyword:"required",params:{missingProperty:"action_class"},message:"must have required property 'action_class'"};t===null?t=[n]:t.push(n),i++}if(r.scope_invoked===void 0){let n={instancePath:e+"/kind_payload",schemaPath:"#/properties/kind_payload/required",keyword:"required",params:{missingProperty:"scope_invoked"},message:"must have required property 'scope_invoked'"};t===null?t=[n]:t.push(n),i++}if(r.agent_id!==void 0&&typeof r.agent_id!="string"){let n={instancePath:e+"/kind_payload/agent_id",schemaPath:"#/properties/kind_payload/properties/agent_id/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[n]:t.push(n),i++}if(r.action_class!==void 0&&typeof r.action_class!="string"){let n={instancePath:e+"/kind_payload/action_class",schemaPath:"#/properties/kind_payload/properties/action_class/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[n]:t.push(n),i++}if(r.bounded_authority!==void 0){let n=r.bounded_authority;if(!(n&&typeof n=="object"&&!Array.isArray(n))){let m={instancePath:e+"/kind_payload/bounded_authority",schemaPath:"#/properties/kind_payload/properties/bounded_authority/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[m]:t.push(m),i++}}if(r.scope_invoked!==void 0&&typeof r.scope_invoked!="string"){let n={instancePath:e+"/kind_payload/scope_invoked",schemaPath:"#/properties/kind_payload/properties/scope_invoked/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[n]:t.push(n),i++}if(r.value_invoked!==void 0){let n=r.value_invoked;if(!(n&&typeof n=="object"&&!Array.isArray(n))&&n!==null){let m={instancePath:e+"/kind_payload/value_invoked",schemaPath:"#/properties/kind_payload/properties/value_invoked/type",keyword:"type",params:{type:st.properties.kind_payload.properties.value_invoked.type},message:"must be object,null"};t===null?t=[m]:t.push(m),i++}}}else{let n={instancePath:e+"/kind_payload",schemaPath:"#/properties/kind_payload/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[n]:t.push(n),i++}}}else{let r={instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[r]:t.push(r),i++}return xe.errors=t,i===0}xe.evaluated={props:!0,dynamicProps:!1,dynamicItems:!1};var zt=De,Vt={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://schemas.overturo.com/postmessage-v2/approval/complete.json",title:"approval COMPLETE payload",type:"object",additionalProperties:!0,required:["outcome","completed_at"],properties:{outcome:{type:"string",enum:["approved","denied"]},exchange_token:{type:["string","null"],description:"Approval-decision exchange token; host calls POST /api/v1/decisions/:token/exchange"},completed_at:{type:"string",format:"date-time"}}},es=R().fullFormats["date-time"];function De(s,{instancePath:e="",parentData:o,parentDataProperty:a,rootData:d=s,dynamicAnchors:p={}}={}){let t=null,i=0,l=De.evaluated;if(l.dynamicProps&&(l.props=void 0),l.dynamicItems&&(l.items=void 0),s&&typeof s=="object"&&!Array.isArray(s)){if(s.outcome===void 0){let r={instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:"outcome"},message:"must have required property 'outcome'"};t===null?t=[r]:t.push(r),i++}if(s.completed_at===void 0){let r={instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:"completed_at"},message:"must have required property 'completed_at'"};t===null?t=[r]:t.push(r),i++}if(s.outcome!==void 0){let r=s.outcome;if(typeof r!="string"){let n={instancePath:e+"/outcome",schemaPath:"#/properties/outcome/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[n]:t.push(n),i++}if(!(r==="approved"||r==="denied")){let n={instancePath:e+"/outcome",schemaPath:"#/properties/outcome/enum",keyword:"enum",params:{allowedValues:Vt.properties.outcome.enum},message:"must be equal to one of the allowed values"};t===null?t=[n]:t.push(n),i++}}if(s.exchange_token!==void 0){let r=s.exchange_token;if(typeof r!="string"&&r!==null){let n={instancePath:e+"/exchange_token",schemaPath:"#/properties/exchange_token/type",keyword:"type",params:{type:Vt.properties.exchange_token.type},message:"must be string,null"};t===null?t=[n]:t.push(n),i++}}if(s.completed_at!==void 0){let r=s.completed_at;if(typeof r=="string"){if(!es.validate(r)){let n={instancePath:e+"/completed_at",schemaPath:"#/properties/completed_at/format",keyword:"format",params:{format:"date-time"},message:'must match format "date-time"'};t===null?t=[n]:t.push(n),i++}}else{let n={instancePath:e+"/completed_at",schemaPath:"#/properties/completed_at/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[n]:t.push(n),i++}}}else{let r={instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[r]:t.push(r),i++}return De.errors=t,i===0}De.evaluated={props:!0,dynamicProps:!1,dynamicItems:!1};var Kt=Ce,Bt={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://schemas.overturo.com/postmessage-v2/approval/error.json",title:"approval ERROR payload",type:"object",additionalProperties:!0,required:["code","message","fatal"],properties:{code:{type:"string"},message:{type:"string"},fatal:{type:"boolean"},recoverable_via:{type:["string","null"],enum:["reload","new_session",null]}}};function Ce(s,{instancePath:e="",parentData:o,parentDataProperty:a,rootData:d=s,dynamicAnchors:p={}}={}){let t=null,i=0,l=Ce.evaluated;if(l.dynamicProps&&(l.props=void 0),l.dynamicItems&&(l.items=void 0),s&&typeof s=="object"&&!Array.isArray(s)){if(s.code===void 0){let r={instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:"code"},message:"must have required property 'code'"};t===null?t=[r]:t.push(r),i++}if(s.message===void 0){let r={instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:"message"},message:"must have required property 'message'"};t===null?t=[r]:t.push(r),i++}if(s.fatal===void 0){let r={instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:"fatal"},message:"must have required property 'fatal'"};t===null?t=[r]:t.push(r),i++}if(s.code!==void 0&&typeof s.code!="string"){let r={instancePath:e+"/code",schemaPath:"#/properties/code/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[r]:t.push(r),i++}if(s.message!==void 0&&typeof s.message!="string"){let r={instancePath:e+"/message",schemaPath:"#/properties/message/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[r]:t.push(r),i++}if(s.fatal!==void 0&&typeof s.fatal!="boolean"){let r={instancePath:e+"/fatal",schemaPath:"#/properties/fatal/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};t===null?t=[r]:t.push(r),i++}if(s.recoverable_via!==void 0){let r=s.recoverable_via;if(typeof r!="string"&&r!==null){let n={instancePath:e+"/recoverable_via",schemaPath:"#/properties/recoverable_via/type",keyword:"type",params:{type:Bt.properties.recoverable_via.type},message:"must be string,null"};t===null?t=[n]:t.push(n),i++}if(!(r==="reload"||r==="new_session"||r===null)){let n={instancePath:e+"/recoverable_via",schemaPath:"#/properties/recoverable_via/enum",keyword:"enum",params:{allowedValues:Bt.properties.recoverable_via.enum},message:"must be equal to one of the allowed values"};t===null?t=[n]:t.push(n),i++}}}else{let r={instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[r]:t.push(r),i++}return Ce.errors=t,i===0}Ce.evaluated={props:!0,dynamicProps:!1,dynamicItems:!1};var Yt=Oe,ts={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://schemas.overturo.com/postmessage-v2/approval/deadline.json",title:"approval DEADLINE payload",type:"object",additionalProperties:!0,required:["remaining_seconds","level","deadline_at"],properties:{remaining_seconds:{type:"integer",minimum:0},level:{type:"string",enum:["warning","expired"]},deadline_at:{type:"string",format:"date-time"}}},rs=R().fullFormats["date-time"];function Oe(s,{instancePath:e="",parentData:o,parentDataProperty:a,rootData:d=s,dynamicAnchors:p={}}={}){let t=null,i=0,l=Oe.evaluated;if(l.dynamicProps&&(l.props=void 0),l.dynamicItems&&(l.items=void 0),s&&typeof s=="object"&&!Array.isArray(s)){if(s.remaining_seconds===void 0){let r={instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:"remaining_seconds"},message:"must have required property 'remaining_seconds'"};t===null?t=[r]:t.push(r),i++}if(s.level===void 0){let r={instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:"level"},message:"must have required property 'level'"};t===null?t=[r]:t.push(r),i++}if(s.deadline_at===void 0){let r={instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:"deadline_at"},message:"must have required property 'deadline_at'"};t===null?t=[r]:t.push(r),i++}if(s.remaining_seconds!==void 0){let r=s.remaining_seconds;if(!(typeof r=="number"&&!(r%1)&&!isNaN(r))){let n={instancePath:e+"/remaining_seconds",schemaPath:"#/properties/remaining_seconds/type",keyword:"type",params:{type:"integer"},message:"must be integer"};t===null?t=[n]:t.push(n),i++}if(typeof r=="number"&&(r<0||isNaN(r))){let n={instancePath:e+"/remaining_seconds",schemaPath:"#/properties/remaining_seconds/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};t===null?t=[n]:t.push(n),i++}}if(s.level!==void 0){let r=s.level;if(typeof r!="string"){let n={instancePath:e+"/level",schemaPath:"#/properties/level/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[n]:t.push(n),i++}if(!(r==="warning"||r==="expired")){let n={instancePath:e+"/level",schemaPath:"#/properties/level/enum",keyword:"enum",params:{allowedValues:ts.properties.level.enum},message:"must be equal to one of the allowed values"};t===null?t=[n]:t.push(n),i++}}if(s.deadline_at!==void 0){let r=s.deadline_at;if(typeof r=="string"){if(!rs.validate(r)){let n={instancePath:e+"/deadline_at",schemaPath:"#/properties/deadline_at/format",keyword:"format",params:{format:"date-time"},message:'must match format "date-time"'};t===null?t=[n]:t.push(n),i++}}else{let n={instancePath:e+"/deadline_at",schemaPath:"#/properties/deadline_at/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[n]:t.push(n),i++}}}else{let r={instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[r]:t.push(r),i++}return Oe.errors=t,i===0}Oe.evaluated={props:!0,dynamicProps:!1,dynamicItems:!1};var Gt=Ie,Re={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://schemas.overturo.com/postmessage-v2/signature/state.json",title:"signature STATE payload",type:"object",additionalProperties:!0,required:["from","to","kind_payload"],properties:{from:{type:["string","null"]},to:{type:"string",enum:["pending","opened","in_progress","signed","declined","expired"]},kind_payload:{type:"object",additionalProperties:!0,required:["required_assurance_level"],properties:{required_assurance_level:{type:"string",enum:["integrity_proof","advanced","qualified"]},participant_role:{type:["string","null"]}}}}};function Ie(s,{instancePath:e="",parentData:o,parentDataProperty:a,rootData:d=s,dynamicAnchors:p={}}={}){let t=null,i=0,l=Ie.evaluated;if(l.dynamicProps&&(l.props=void 0),l.dynamicItems&&(l.items=void 0),s&&typeof s=="object"&&!Array.isArray(s)){if(s.from===void 0){let r={instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:"from"},message:"must have required property 'from'"};t===null?t=[r]:t.push(r),i++}if(s.to===void 0){let r={instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:"to"},message:"must have required property 'to'"};t===null?t=[r]:t.push(r),i++}if(s.kind_payload===void 0){let r={instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:"kind_payload"},message:"must have required property 'kind_payload'"};t===null?t=[r]:t.push(r),i++}if(s.from!==void 0){let r=s.from;if(typeof r!="string"&&r!==null){let n={instancePath:e+"/from",schemaPath:"#/properties/from/type",keyword:"type",params:{type:Re.properties.from.type},message:"must be string,null"};t===null?t=[n]:t.push(n),i++}}if(s.to!==void 0){let r=s.to;if(typeof r!="string"){let n={instancePath:e+"/to",schemaPath:"#/properties/to/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[n]:t.push(n),i++}if(!(r==="pending"||r==="opened"||r==="in_progress"||r==="signed"||r==="declined"||r==="expired")){let n={instancePath:e+"/to",schemaPath:"#/properties/to/enum",keyword:"enum",params:{allowedValues:Re.properties.to.enum},message:"must be equal to one of the allowed values"};t===null?t=[n]:t.push(n),i++}}if(s.kind_payload!==void 0){let r=s.kind_payload;if(r&&typeof r=="object"&&!Array.isArray(r)){if(r.required_assurance_level===void 0){let n={instancePath:e+"/kind_payload",schemaPath:"#/properties/kind_payload/required",keyword:"required",params:{missingProperty:"required_assurance_level"},message:"must have required property 'required_assurance_level'"};t===null?t=[n]:t.push(n),i++}if(r.required_assurance_level!==void 0){let n=r.required_assurance_level;if(typeof n!="string"){let m={instancePath:e+"/kind_payload/required_assurance_level",schemaPath:"#/properties/kind_payload/properties/required_assurance_level/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[m]:t.push(m),i++}if(!(n==="integrity_proof"||n==="advanced"||n==="qualified")){let m={instancePath:e+"/kind_payload/required_assurance_level",schemaPath:"#/properties/kind_payload/properties/required_assurance_level/enum",keyword:"enum",params:{allowedValues:Re.properties.kind_payload.properties.required_assurance_level.enum},message:"must be equal to one of the allowed values"};t===null?t=[m]:t.push(m),i++}}if(r.participant_role!==void 0){let n=r.participant_role;if(typeof n!="string"&&n!==null){let m={instancePath:e+"/kind_payload/participant_role",schemaPath:"#/properties/kind_payload/properties/participant_role/type",keyword:"type",params:{type:Re.properties.kind_payload.properties.participant_role.type},message:"must be string,null"};t===null?t=[m]:t.push(m),i++}}}else{let n={instancePath:e+"/kind_payload",schemaPath:"#/properties/kind_payload/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[n]:t.push(n),i++}}}else{let r={instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[r]:t.push(r),i++}return Ie.errors=t,i===0}Ie.evaluated={props:!0,dynamicProps:!1,dynamicItems:!1};var Wt=Me,nt={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://schemas.overturo.com/postmessage-v2/signature/complete.json",title:"signature COMPLETE payload",type:"object",additionalProperties:!0,required:["outcome","completed_at"],properties:{outcome:{type:"string",enum:["signed","declined","countered"]},assurance_level:{type:["string","null"],enum:["integrity_proof","advanced","qualified",null],description:"The signature assurance level recorded on the agreement."},completed_at:{type:"string",format:"date-time"}}},ss=R().fullFormats["date-time"];function Me(s,{instancePath:e="",parentData:o,parentDataProperty:a,rootData:d=s,dynamicAnchors:p={}}={}){let t=null,i=0,l=Me.evaluated;if(l.dynamicProps&&(l.props=void 0),l.dynamicItems&&(l.items=void 0),s&&typeof s=="object"&&!Array.isArray(s)){if(s.outcome===void 0){let r={instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:"outcome"},message:"must have required property 'outcome'"};t===null?t=[r]:t.push(r),i++}if(s.completed_at===void 0){let r={instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:"completed_at"},message:"must have required property 'completed_at'"};t===null?t=[r]:t.push(r),i++}if(s.outcome!==void 0){let r=s.outcome;if(typeof r!="string"){let n={instancePath:e+"/outcome",schemaPath:"#/properties/outcome/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[n]:t.push(n),i++}if(!(r==="signed"||r==="declined"||r==="countered")){let n={instancePath:e+"/outcome",schemaPath:"#/properties/outcome/enum",keyword:"enum",params:{allowedValues:nt.properties.outcome.enum},message:"must be equal to one of the allowed values"};t===null?t=[n]:t.push(n),i++}}if(s.assurance_level!==void 0){let r=s.assurance_level;if(typeof r!="string"&&r!==null){let n={instancePath:e+"/assurance_level",schemaPath:"#/properties/assurance_level/type",keyword:"type",params:{type:nt.properties.assurance_level.type},message:"must be string,null"};t===null?t=[n]:t.push(n),i++}if(!(r==="integrity_proof"||r==="advanced"||r==="qualified"||r===null)){let n={instancePath:e+"/assurance_level",schemaPath:"#/properties/assurance_level/enum",keyword:"enum",params:{allowedValues:nt.properties.assurance_level.enum},message:"must be equal to one of the allowed values"};t===null?t=[n]:t.push(n),i++}}if(s.completed_at!==void 0){let r=s.completed_at;if(typeof r=="string"){if(!ss.validate(r)){let n={instancePath:e+"/completed_at",schemaPath:"#/properties/completed_at/format",keyword:"format",params:{format:"date-time"},message:'must match format "date-time"'};t===null?t=[n]:t.push(n),i++}}else{let n={instancePath:e+"/completed_at",schemaPath:"#/properties/completed_at/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[n]:t.push(n),i++}}}else{let r={instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[r]:t.push(r),i++}return Me.errors=t,i===0}Me.evaluated={props:!0,dynamicProps:!1,dynamicItems:!1};var Xt=$e,Zt={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://schemas.overturo.com/postmessage-v2/signature/error.json",title:"signature ERROR payload",type:"object",additionalProperties:!0,required:["code","message","fatal"],properties:{code:{type:"string"},message:{type:"string"},fatal:{type:"boolean"},recoverable_via:{type:["string","null"],enum:["reload","new_session",null]}}};function $e(s,{instancePath:e="",parentData:o,parentDataProperty:a,rootData:d=s,dynamicAnchors:p={}}={}){let t=null,i=0,l=$e.evaluated;if(l.dynamicProps&&(l.props=void 0),l.dynamicItems&&(l.items=void 0),s&&typeof s=="object"&&!Array.isArray(s)){if(s.code===void 0){let r={instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:"code"},message:"must have required property 'code'"};t===null?t=[r]:t.push(r),i++}if(s.message===void 0){let r={instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:"message"},message:"must have required property 'message'"};t===null?t=[r]:t.push(r),i++}if(s.fatal===void 0){let r={instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:"fatal"},message:"must have required property 'fatal'"};t===null?t=[r]:t.push(r),i++}if(s.code!==void 0&&typeof s.code!="string"){let r={instancePath:e+"/code",schemaPath:"#/properties/code/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[r]:t.push(r),i++}if(s.message!==void 0&&typeof s.message!="string"){let r={instancePath:e+"/message",schemaPath:"#/properties/message/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[r]:t.push(r),i++}if(s.fatal!==void 0&&typeof s.fatal!="boolean"){let r={instancePath:e+"/fatal",schemaPath:"#/properties/fatal/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};t===null?t=[r]:t.push(r),i++}if(s.recoverable_via!==void 0){let r=s.recoverable_via;if(typeof r!="string"&&r!==null){let n={instancePath:e+"/recoverable_via",schemaPath:"#/properties/recoverable_via/type",keyword:"type",params:{type:Zt.properties.recoverable_via.type},message:"must be string,null"};t===null?t=[n]:t.push(n),i++}if(!(r==="reload"||r==="new_session"||r===null)){let n={instancePath:e+"/recoverable_via",schemaPath:"#/properties/recoverable_via/enum",keyword:"enum",params:{allowedValues:Zt.properties.recoverable_via.enum},message:"must be equal to one of the allowed values"};t===null?t=[n]:t.push(n),i++}}}else{let r={instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[r]:t.push(r),i++}return $e.errors=t,i===0}$e.evaluated={props:!0,dynamicProps:!1,dynamicItems:!1};var Jt=Le,ns={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://schemas.overturo.com/postmessage-v2/signature/deadline.json",title:"signature DEADLINE payload",type:"object",additionalProperties:!0,required:["remaining_seconds","level","deadline_at"],properties:{remaining_seconds:{type:"integer",minimum:0},level:{type:"string",enum:["warning","expired"]},deadline_at:{type:"string",format:"date-time"}}},os=R().fullFormats["date-time"];function Le(s,{instancePath:e="",parentData:o,parentDataProperty:a,rootData:d=s,dynamicAnchors:p={}}={}){let t=null,i=0,l=Le.evaluated;if(l.dynamicProps&&(l.props=void 0),l.dynamicItems&&(l.items=void 0),s&&typeof s=="object"&&!Array.isArray(s)){if(s.remaining_seconds===void 0){let r={instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:"remaining_seconds"},message:"must have required property 'remaining_seconds'"};t===null?t=[r]:t.push(r),i++}if(s.level===void 0){let r={instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:"level"},message:"must have required property 'level'"};t===null?t=[r]:t.push(r),i++}if(s.deadline_at===void 0){let r={instancePath:e,schemaPath:"#/required",keyword:"required",params:{missingProperty:"deadline_at"},message:"must have required property 'deadline_at'"};t===null?t=[r]:t.push(r),i++}if(s.remaining_seconds!==void 0){let r=s.remaining_seconds;if(!(typeof r=="number"&&!(r%1)&&!isNaN(r))){let n={instancePath:e+"/remaining_seconds",schemaPath:"#/properties/remaining_seconds/type",keyword:"type",params:{type:"integer"},message:"must be integer"};t===null?t=[n]:t.push(n),i++}if(typeof r=="number"&&(r<0||isNaN(r))){let n={instancePath:e+"/remaining_seconds",schemaPath:"#/properties/remaining_seconds/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};t===null?t=[n]:t.push(n),i++}}if(s.level!==void 0){let r=s.level;if(typeof r!="string"){let n={instancePath:e+"/level",schemaPath:"#/properties/level/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[n]:t.push(n),i++}if(!(r==="warning"||r==="expired")){let n={instancePath:e+"/level",schemaPath:"#/properties/level/enum",keyword:"enum",params:{allowedValues:ns.properties.level.enum},message:"must be equal to one of the allowed values"};t===null?t=[n]:t.push(n),i++}}if(s.deadline_at!==void 0){let r=s.deadline_at;if(typeof r=="string"){if(!os.validate(r)){let n={instancePath:e+"/deadline_at",schemaPath:"#/properties/deadline_at/format",keyword:"format",params:{format:"date-time"},message:'must match format "date-time"'};t===null?t=[n]:t.push(n),i++}}else{let n={instancePath:e+"/deadline_at",schemaPath:"#/properties/deadline_at/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[n]:t.push(n),i++}}}else{let r={instancePath:e,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[r]:t.push(r),i++}return Le.errors=t,i===0}Le.evaluated={props:!0,dynamicProps:!1,dynamicItems:!1};var is={[f.READY]:{_agnostic:Ot},[f.RESIZE]:{_agnostic:Rt},[f.CANCEL]:{_agnostic:Mt},[f.STATE]:{consent:$t,approval:Ut,signature_request:Gt},[f.COMPLETE]:{consent:jt,approval:zt,signature_request:Wt},[f.ERROR]:{consent:Ht,approval:Kt,signature_request:Xt},[f.DEADLINE]:{consent:Ft,approval:Yt,signature_request:Jt}},Qt=qt;function as(s){let e=Qt(s);return{valid:e,errors:e?null:Qt.errors??null}}function ds(s){let e=is[s.type];if(!e)return{valid:!1,errors:[{message:`Unknown type ${s.type}`}]};let o=e._agnostic??e[s.kind];if(!o)return{valid:!1,errors:[{message:`No validator for ${s.type}/${s.kind}`}]};let a=o(s.payload);return{valid:a,errors:a?null:o.errors??null}}function I(s){let e=as(s);return e.valid?ds(s):e}var L,ae,A,M,Ne,tr,je=class{constructor(e){h(this,Ne);h(this,L);h(this,ae);h(this,A);h(this,M,new Set);g(this,L,e.api),g(this,ae,e.flowBaseUrl),g(this,A,e.debug)}url(e){let o=e.mode==="embed"?"/embed":"";return`${u(this,ae)}${ct}/${e.token}${o}`}async createSession(e){if(!e.subjectRef)throw new c("subjectRef is required");let o=e.embedOrigin??(typeof window<"u"?window.location.origin:void 0),a={kind:e.kind,subjectRef:e.subjectRef,deliveryMode:e.mode??"embed",embedOrigin:o,state:e.state,redirectUri:e.redirectUri};e.kind==="consent"&&(a.scope=e.scope,a.nonce=e.nonce);let p=(await u(this,L).post(D,a)).decision;return u(this,A)&&console.debug("[overturo:sdk]","session_created",{kind:p.kind,mode:p.mode}),{token:p.sessionToken,kind:p.kind,mode:p.mode,expiresAt:p.deadlineAt??"",embedUrl:p.embedUrl}}async discover(e){if(!e.flowId)throw new c("flowId is required");let o=e.locale?`?locale=${encodeURIComponent(e.locale)}`:"",a=await u(this,L).get(`${D}/flows/${encodeURIComponent(e.flowId)}/disclosures${o}`);if(!a||typeof a!="object"||!("flow"in a))throw new b("Malformed discovery response: missing 'flow'",200,a);return a.flow}embed(e){if(!e.token)throw new c("token is required");let o=this.url({token:e.token,mode:"embed"}),a=new URL(o).origin,d=Z(e.container);if(d.innerHTML="",e.loading){let n=document.createElement("div");n.setAttribute("data-overturo-loading",""),typeof e.loading=="string"?n.innerHTML=e.loading:n.appendChild(e.loading),d.appendChild(n)}let p=document.createElement("iframe");p.src=o,p.setAttribute("sandbox","allow-scripts allow-forms allow-same-origin allow-popups"),X(p,{...N},e.style);let t=()=>{let n=d.querySelector("[data-overturo-loading]");n&&d.removeChild(n)};p.addEventListener("load",t),p.addEventListener("error",()=>{t(),e.onError?.({code:"iframe_load_failed",message:"The trust-host iframe failed to load."})});let i=new AbortController,l=n=>{if(n.origin!==a||ee(n.data))return;let m=I(n.data);if(!m.valid){e.onError?.({code:"protocol_violation",errors:m.errors}),u(this,A)&&console.debug("[overturo:sdk]","envelope_dropped",{reason:"schema_invalid"});return}E(this,Ne,tr).call(this,n.data,e,p)};window.addEventListener("message",l,{signal:i.signal}),d.appendChild(p);let r={token:e.token,mode:"embed",destroy:async()=>{i.abort(),p.parentNode&&p.parentNode.removeChild(p),u(this,M).delete(r),u(this,A)&&console.debug("[overturo:sdk]","iframe_destroyed",{})}};return u(this,M).add(r),u(this,A)&&console.debug("[overturo:sdk]","iframe_mounted",{sandboxAttr:p.getAttribute("sandbox")}),r}popup(e){if(!e.token)throw new c("token is required");let o=this.url({token:e.token,mode:"popup"}),a=new URL(o).origin,d=e.width??K.width,p=e.height??K.height,t=Math.round((screen.width-d)/2),i=Math.round((screen.height-p)/2),l=`width=${d},height=${p},left=${t},top=${i},scrollbars=yes,status=yes`,r=window.open(o,"_blank",l);if(!r)throw u(this,A)&&console.debug("[overturo:sdk]","popup_blocked",{}),new P("Popup was blocked by the browser. Allow popups for this site and try again.");u(this,A)&&console.debug("[overturo:sdk]","popup_opened",{features:l});let n=new AbortController,m=k=>{if(k.origin!==a||ee(k.data))return;if(!I(k.data).valid){e.onError?.({code:"protocol_violation"});return}let Q=k.data;switch(Q.type){case f.COMPLETE:e.onComplete?.(er(Q.kind,Q.payload)),w.destroy();break;case f.CANCEL:e.onCancel?.(Q.payload),w.destroy();break;case f.ERROR:e.onError?.(Q.payload);break}};window.addEventListener("message",m,{signal:n.signal});let y=setInterval(()=>{r.closed&&(y&&(clearInterval(y),y=null),e.onCancel?.({reason:"user_closed_popup"}),w.destroy())},500),w={token:e.token,mode:"popup",destroy:async()=>{y&&(clearInterval(y),y=null),n.abort(),r&&!r.closed&&r.close(),u(this,M).delete(w)}};return u(this,M).add(w),w}async exchange(e){if(!e.token||!e.exchangeToken)throw new c("token and exchangeToken are required for exchange");let o=`${D}/${e.token}/exchange`;return await u(this,L).post(o,{exchangeToken:e.exchangeToken})}async cancel(e){if(!e)throw new c("token is required for cancel");await u(this,L).post(`${D}/${e}/cancel`,{})}async destroyAll(){let e=[...u(this,M)];await Promise.allSettled(e.map(o=>o.destroy())),u(this,M).clear()}};L=new WeakMap,ae=new WeakMap,A=new WeakMap,M=new WeakMap,Ne=new WeakSet,tr=function(e,o,a){let d=e.type===f.STATE&&e.kind==="approval"&&e.payload?.phase==="countered";switch(e.type){case f.READY:o.onReady?.(e.payload);break;case f.STATE:d?o.onCounter?.(e.payload):o.onState?.(e.kind,e.payload);break;case f.RESIZE:{let p=e.payload.height;typeof p=="number"&&(a.style.height=`${p}px`,o.onResize?.(p));break}case f.COMPLETE:o.onComplete?.(er(e.kind,e.payload));break;case f.CANCEL:o.onCancel?.(e.payload);break;case f.ERROR:o.onError?.(e.payload);break;case f.DEADLINE:o.onDeadline?.(e.payload);break}u(this,A)&&console.debug("[overturo:sdk]","envelope_received",{type:e.type,kind:e.kind})};function er(s,e){let o=e??{};return s==="consent"?{kind:"consent",result:o.outcome??o.result??"granted",consentToken:o.exchange_token??o.consentToken,purposesGranted:o.purposesGranted,purposesDeclined:o.purposesDeclined}:s==="signature_request"?{kind:"signature_request",result:o.outcome??o.result??"signed",assuranceLevel:o.assurance_level??o.assuranceLevel,completedAt:o.completed_at??o.completedAt}:{kind:"approval",result:o.outcome??o.result??"approved",escalationToken:o.exchange_token??o.escalationToken,counterProposal:o.counterProposal}}function rr(s,e){let o=Z(e.container),a=new URL(s).origin,d=`${s}/accord/embed/${e.sessionToken}`;if(o.innerHTML="",e.loading){let l=document.createElement("div");l.setAttribute("data-overturo-loading",""),typeof e.loading=="string"?l.innerHTML=e.loading:l.appendChild(e.loading),o.appendChild(l)}let p=document.createElement("iframe");p.src=d,p.setAttribute("sandbox","allow-scripts allow-forms allow-same-origin allow-popups"),X(p,{...N},e.style),p.addEventListener("load",()=>{let l=o.querySelector("[data-overturo-loading]");l&&o.removeChild(l)});let t=new AbortController;function i(l){if(l.origin!==a||!I(l.data).valid)return;let n=l.data;switch(n.type){case f.READY:e.onReady?.(n.payload);break;case f.RESIZE:{let m=n.payload.height;typeof m=="number"&&(p.style.height=`${m}px`,e.onResize?.(m));break}case f.STATE:e.onState?.(n.kind,n.payload);break;case f.DEADLINE:e.onDeadline?.(n.payload);break;case f.COMPLETE:e.onComplete?.(n.kind,n.payload);break;case f.CANCEL:e.onCancel?.(n.payload);break;case f.ERROR:e.onError?.(n.payload);break}}return window.addEventListener("message",i,{signal:t.signal}),o.appendChild(p),{iframe:p,destroy(){t.abort(),p.parentNode&&p.parentNode.removeChild(p)}}}var ls=0;function sr(s,e){if(!e.sessionToken)throw new c("sessionToken is required for popup mode");let o=`${s}/accord/embed/${e.sessionToken}`,a=e.width??K.width,d=e.height??K.height,p=Math.round((screen.width-a)/2),t=Math.round((screen.height-d)/2),i=`overturo_decision_${++ls}`,l=window.open(o,i,`width=${a},height=${d},left=${p},top=${t},scrollbars=yes,status=yes`);if(!l)throw new P("Popup was blocked by the browser. Allow popups for this site and try again.");let r=new URL(s).origin,n=new AbortController;function m(w){if(w.origin!==r||!I(w.data).valid)return;let B=w.data;switch(B.type){case f.COMPLETE:e.onComplete?.(B.kind,B.payload),y();break;case f.CANCEL:e.onCancel?.(B.payload),y();break;case f.ERROR:e.onError?.(B.payload);break}}function y(){n.abort(),l&&!l.closed&&l.close()}return window.addEventListener("message",m,{signal:n.signal}),{close:y}}var nr={mobile:{width:375,height:667},tablet:{width:768,height:1024},desktop:{width:null,height:800}};function it(s,e){let o=ps(e.container),a=e.device||"desktop",d=e.theme||"default",p=e.locale,t=ot(s,d,a,p);e.loading&&cs(o,e.loading);let i=document.createElement("iframe");return i.src=t,i.sandbox.add("allow-scripts","allow-same-origin"),i.style.border="none",i.title="Preview",or(i,a),us(i,e.style),i.addEventListener("load",()=>{let r=o.querySelector("[data-preview-loading]");r&&r.remove()},{once:!0}),o.appendChild(i),{iframe:i,setDevice(r){a=r,or(i,r),i.src=ot(s,d,a,p)},setTheme(r){d=r,i.src=ot(s,d,a,p)},destroy(){i.remove()}}}function ps(s){if(typeof s=="string"){let e=document.querySelector(s);if(!e)throw new Error(`Preview container not found: ${s}`);return e}return s}function ot(s,e,o,a){let d=new URL(s,window.location.origin);return d.searchParams.set("theme",e),d.searchParams.set("device",o),a&&d.searchParams.set("locale",a),d.toString()}function or(s,e){let o=nr[e]||nr.desktop;o.width?(s.style.width=`${o.width}px`,s.style.maxWidth="100%"):(s.style.width="100%",s.style.maxWidth="none"),s.style.height=`${o.height}px`}function us(s,e){e&&(e.width&&(s.style.width=e.width),e.minHeight&&(s.style.minHeight=e.minHeight),e.maxHeight&&(s.style.maxHeight=e.maxHeight),e.borderRadius&&(s.style.borderRadius=e.borderRadius),e.border&&(s.style.border=e.border),e.background&&(s.style.background=e.background))}function cs(s,e){let o=document.createElement("div");o.setAttribute("data-preview-loading",""),typeof e=="string"?o.textContent=e:o.appendChild(e),s.appendChild(o)}function ir(s,e){if(!e.flowId)throw new c("flowId is required for redirect mode");if(!e.redirectUri)throw new c("redirectUri is required for redirect mode");let o=new URL(`${s}/accord/${e.flowId}`),a=new URLSearchParams;a.set("redirect_uri",e.redirectUri),e.state&&a.set("state",e.state),e.nonce&&a.set("nonce",e.nonce),e.scope&&a.set("scope",e.scope),o.search=a.toString(),window.location.href=o.toString()}function He(s,e){let o=Z(e.container),a=new URL(s).origin,d=`${s}/accord_setup/embed/${e.sessionToken}`;if(o.innerHTML="",e.loading){let l=document.createElement("div");l.setAttribute("data-overturo-loading",""),typeof e.loading=="string"?l.innerHTML=e.loading:l.appendChild(e.loading),o.appendChild(l)}let p=document.createElement("iframe");p.src=d,p.setAttribute("allow","popups"),p.setAttribute("sandbox","allow-scripts allow-forms allow-same-origin allow-popups"),X(p,{...N},e.style),p.addEventListener("load",()=>{let l=o.querySelector("[data-overturo-loading]");l&&o.removeChild(l)});let t=new AbortController;function i(l){if(l.origin!==a)return;let r=l.data;if(!(!r||!r.type))switch(r.type){case T.READY:e.onReady?.();break;case T.RESIZE:r.height&&(p.style.height=`${r.height}px`,e.onResize?.(r.height));break;case T.STEP:e.onStep?.({key:r.step,index:r.stepIndex,total:r.totalSteps});break;case T.CREATED:e.onCreated?.({accordId:r.accordId,flowId:r.flowId});break;case T.CANCEL:e.onCancel?.();break;case T.ERROR:e.onError?.(r.error);break}}return window.addEventListener("message",i,{signal:t.signal}),o.appendChild(p),{iframe:p,destroy(){t.abort(),p.parentNode&&p.parentNode.removeChild(p)}}}function Fe(s,e){let o=`${s}/accord_setup/embed/${e.sessionToken}`,a=new URL(s).origin,d=e.width??Ye.width,p=e.height??Ye.height,t=Math.round((screen.width-d)/2),i=Math.round((screen.height-p)/2),l=window.open(o,"accord_setup_popup",`width=${d},height=${p},left=${t},top=${i},scrollbars=yes`),r=new AbortController,n=null;function m(w){if(w.origin!==a)return;let k=w.data;if(!(!k||!k.type))switch(k.type){case T.CREATED:e.onCreated?.({accordId:k.accordId,flowId:k.flowId}),y();break;case T.CANCEL:e.onCancel?.(),y();break;case T.ERROR:e.onError?.(k.error);break}}function y(){r.abort(),n&&clearInterval(n)}return window.addEventListener("message",m,{signal:r.signal}),n=setInterval(()=>{l&&l.closed&&(e.onCancel?.(),y())},500),{close(){l?.close(),y()}}}function Ue(s,e){let o=`${s}/accord_setup/embed/${e.sessionToken}`;window.location.href=o}var de=class{constructor(e){if(!e.publishableKey)throw new c("publishableKey is required");if(this.baseUrl=(e.baseUrl??ft).replace(/\/+$/,""),this.flowBaseUrl=(e.flowBaseUrl??this.baseUrl).replace(/\/+$/,""),this.debugFlag=e.debug===!0,this.api=new fe({baseUrl:this.baseUrl,publishableKey:e.publishableKey,apiKey:e.apiKey,timeout:e.timeout}),this.decisions=new je({api:this.api,flowBaseUrl:this.flowBaseUrl,debug:this.debugFlag}),this.consent=new ge(this.decisions),this.approvals=new he(this.decisions,this.api),this.signing=new be(this.decisions,this.api),this.forms=new we(this.api,this.decisions,this.flowBaseUrl,e.publishableKey),this.debugFlag&&typeof window<"u"){let o=new URL(this.baseUrl),a=o.hostname==="localhost"||o.hostname==="127.0.0.1"||o.hostname==="lvh.me"||o.hostname.endsWith(".lvh.me")||o.hostname.endsWith(".localhost");o.protocol==="http:"&&!a&&console.warn("[overturo:sdk]","OVERTURO_INSECURE_HOST",`API host ${o.host} is not HTTPS; treat this as dev-only.`)}}async destroy(){await this.decisions.destroyAll()}async createSession(e){return this.api.post(ue,{accordId:e.flowId,deliveryMode:e.deliveryMode,embedOrigin:e.embedOrigin,redirectUri:e.redirectUri,state:e.state,nonce:e.nonce,scope:e.scope,skipSteps:e.skipSteps})}async getSession(e){return this.api.get(`${ue}/${e}`)}async getMeetingParticipantStatus(e,o){if(!e)throw new c("meetingId is required");if(!o)throw new c("sessionToken is required");let a=await this.api.rawGet(`${Ge}/${encodeURIComponent(e)}/status?session_token=${encodeURIComponent(o)}`);return this.decodeParticipantStatus(a)}async withdrawMeetingConsent(e,o){if(!e)throw new c("meetingId is required");if(!o)throw new c("sessionToken is required");let a=await this.api.rawPost(`${Ge}/${encodeURIComponent(e)}/revoke`,{sessionToken:o});return this.decodeParticipantStatus(a)}async decodeParticipantStatus(e){if(!e.ok){let p;try{p=await e.json()}catch{p=null}throw new b(ye(p,e.status),e.status,p)}let o=JSON.parse(await e.text()),a=o.purposes??{};return{...G({...o,purposes:{}}),purposes:{...a}}}embed(e){return rr(this.flowBaseUrl,e)}popup(e){return sr(this.flowBaseUrl,e)}redirect(e){ir(this.flowBaseUrl,e)}async exchange(e){let a=`${ue}/${e.sessionToken}/exchange`,d={consentToken:e.consentToken};for(let p=0;p<=5;p++){let t=await this.api.rawPost(a,d);if(t.status===202){if(p===5)throw new b("Exchange timeout: fulfillment still pending",202,null);let l=parseInt(t.headers.get("Retry-After")||"1",10);await new Promise(r=>setTimeout(r,l*1e3));continue}if(!t.ok){let l;try{l=await t.json()}catch{l=null}let r=ye(l,t.status);throw new b(r===`HTTP ${t.status}`?`Exchange failed: HTTP ${t.status}`:r,t.status,l)}let i=await t.text();return G(JSON.parse(i))}throw new b("Exchange failed: max retries exceeded",202,null)}async createSetupSession(e){return this.api.post(mt,{solution:e.solution,vertical:e.vertical,archetype:e.archetype,templateKey:e.templateKey,deliveryMode:e.deliveryMode||"embed",embedOrigin:e.embedOrigin||(typeof window<"u"?window.location.origin:void 0),redirectUri:e.redirectUri,state:e.state,locale:e.locale||(typeof navigator<"u"?navigator.language:void 0),constraints:e.constraints,presetId:e.presetId})}async accordSetup(e){let o=await this.createSetupSession(this.buildSetupParams(e,"embed"));return He(this.flowBaseUrl,{...e,sessionToken:o.sessionToken})}async accordSetupPopup(e){let o=await this.createSetupSession(this.buildSetupParams(e,"popup"));return Fe(this.flowBaseUrl,{...e,sessionToken:o.sessionToken})}async accordSetupRedirect(e){let o=await this.createSetupSession({...this.buildSetupParams(e,"redirect"),redirectUri:e.redirectUri,state:e.state});Ue(this.flowBaseUrl,{...e,sessionToken:o.sessionToken})}async previewTemplate(e){if(!e.templateId)throw new c("templateId is required");if(!e.container)throw new c("container is required");let o=await this.api.post(We,{previewable_type:"template",previewable_id:e.templateId,theme:e.theme,device:e.device,locale:e.locale});return it(o.preview_url,e)}async previewSetup(e){if(!e.sessionToken)throw new c("sessionToken is required");if(!e.container)throw new c("container is required");let o=await this.api.post(We,{previewable_type:"setup_session",previewable_id:e.sessionToken,theme:e.theme,device:e.device,locale:e.locale});return it(o.preview_url,e)}buildSetupParams(e,o){return{solution:e.solution,vertical:e.vertical,archetype:e.archetype,templateKey:e.templateKey,deliveryMode:o,locale:e.locale,constraints:e.constraints,presetId:e.presetId}}};var ar=typeof HTMLElement>"u"?class{}:HTMLElement;var J="overturo-decision",ze="OVERTURO_ELEMENT_ALREADY_DEFINED",V,$,j,_,v,at,dr,lr,dt,Ve,le,z=class extends ar{constructor(){super();h(this,v);h(this,V);h(this,$,null);h(this,j,null);h(this,_,null);h(this,le,o=>{o.key==="Escape"&&(this.dispatchEvent(new CustomEvent("decision:cancel",{detail:{reason:"user_pressed_esc"},bubbles:!0,composed:!0})),E(this,v,Ve).call(this))});g(this,V,this.attachShadow({mode:"open"}))}connectedCallback(){this.hasAttribute("role")||this.setAttribute("role","region"),this.hasAttribute("aria-label")||this.setAttribute("aria-label","Loading decision"),this.setAttribute("aria-busy","true"),this.hasAttribute("tabindex")||this.setAttribute("tabindex","0"),this.addEventListener("keydown",u(this,le)),E(this,v,at).call(this)}disconnectedCallback(){this.removeEventListener("keydown",u(this,le)),E(this,v,Ve).call(this)}attributeChangedCallback(o,a,d){a!==d&&this.isConnected&&(o==="token"||o==="mode"||o==="flow-base-url"||o==="theme")&&(E(this,v,Ve).call(this),E(this,v,at).call(this))}};V=new WeakMap,$=new WeakMap,j=new WeakMap,_=new WeakMap,v=new WeakSet,at=function(){let o=this.getAttribute("token");if(!o)return;let a=this.getAttribute("mode")??"embed",d=this.getAttribute("flow-base-url")??fs();if(a!=="embed"){E(this,v,dr).call(this,d,o,a);return}let p=this.getAttribute("theme"),t=`${d.replace(/\/+$/,"")}/decisions/${o}/embed`,i=p?`${t}?theme=${encodeURIComponent(p)}`:t,l=new URL(i).origin,r=document.createElement("iframe");r.src=i,r.title="Overturo decision form",r.setAttribute("allow","popups"),r.setAttribute("sandbox","allow-scripts allow-forms allow-same-origin allow-popups"),r.style.cssText="width:100%;min-height:400px;border:0;background:transparent;",p&&(r.dataset.theme=p);let n=ms();n&&r.setAttribute("nonce",n),r.addEventListener("error",()=>{this.dispatchEvent(new CustomEvent("decision:error",{detail:{code:"iframe_load_failed",message:"The trust-host iframe failed to load."},bubbles:!0,composed:!0})),this.setAttribute("aria-busy","false")}),g(this,j,new AbortController);let m=y=>{if(y.origin!==l||ee(y.data))return;if(!I(y.data).valid){E(this,v,dt).call(this,{code:"protocol_violation"});return}E(this,v,lr).call(this,y.data,r)};window.addEventListener("message",m,{signal:u(this,j).signal}),g(this,$,r),u(this,V).appendChild(r)},dr=function(o,a,d){let p=document.createElement("a");p.href=`${o.replace(/\/+$/,"")}/decisions/${a}`,p.target=d==="popup"?"_blank":"_self",p.rel="noopener noreferrer",p.textContent="Open decision",p.style.cssText="display:inline-block;padding:0.5em 1em;text-decoration:none;",u(this,V).appendChild(p),this.setAttribute("aria-busy","false")},lr=function(o,a){switch(o.type){case f.READY:{this.setAttribute("aria-busy","false");let d=o.payload??{},p=(typeof d.title=="string"?d.title:null)??d.branding?.application_name??null;p&&this.setAttribute("aria-label",p),this.dispatchEvent(new CustomEvent("decision:ready",{detail:o.payload}));break}case f.STATE:this.dispatchEvent(new CustomEvent("decision:state",{detail:{kind:o.kind,payload:o.payload}}));break;case f.RESIZE:{let d=o.payload.height;typeof d=="number"&&(a.style.height=`${d}px`);break}case f.COMPLETE:this.dispatchEvent(new CustomEvent("decision:complete",{detail:{kind:o.kind,payload:o.payload},bubbles:!0,composed:!0}));break;case f.CANCEL:this.dispatchEvent(new CustomEvent("decision:cancel",{detail:o.payload,bubbles:!0,composed:!0}));break;case f.ERROR:E(this,v,dt).call(this,o.payload);break;case f.DEADLINE:this.dispatchEvent(new CustomEvent("decision:deadline",{detail:o.payload}));break}},dt=function(o){this.dispatchEvent(new CustomEvent("decision:error",{detail:o,bubbles:!0})),u(this,_)||(g(this,_,document.createElement("div")),u(this,_).setAttribute("role","alert"),u(this,_).setAttribute("aria-live","assertive"),u(this,_).style.cssText="position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);",u(this,V).appendChild(u(this,_)));let a=typeof o.message=="string"?o.message:"An error occurred. Please try again.";u(this,_).textContent=a,window.setTimeout(()=>{u(this,_)&&(u(this,_).textContent="")},3e4)},Ve=function(){u(this,j)&&(u(this,j).abort(),g(this,j,null)),u(this,$)&&u(this,$).parentNode&&u(this,$).parentNode.removeChild(u(this,$)),g(this,$,null),u(this,_)&&(u(this,_).textContent=""),this.setAttribute("aria-busy","true")},le=new WeakMap,z.observedAttributes=["token","mode","theme","flow-base-url"];function ms(){return typeof document>"u"?null:document.querySelector('meta[name="csp-nonce"]')?.getAttribute("content")??null}function fs(){return typeof window<"u"?window.location.origin:"https://overturo.com"}function pe(){if(!(typeof customElements>"u")){if(customElements.get(J)){console.warn("[overturo:sdk]",ze,`<${J}> already registered; skipping.`);return}customElements.define(J,z)}}pe();return yr(ys);})();
|
|
2
2
|
if(typeof window!=='undefined'){window.Overturo=Overturo.Overturo||Overturo}
|